コード例 #1
0
    public static void Main(string[] args)
    {
        if (args.Length != 1)
        {
            Console.WriteLine("Usage: SimpleClient <message>");
            Environment.Exit(1);
        }

        string message = args[0];

        ATMI.tpinit(null);
        try
        {
            byte[]     bytes   = Encoding.Default.GetBytes(message);
            int        sendlen = bytes.Length + 1; // One byte extra for terminating zero
            ByteBuffer sendbuf = ATMI.tpalloc("STRING", null, sendlen);
            try
            {
                ByteBuffer rcvbuf = ATMI.tpalloc("STRING", null, sendlen);
                try
                {
                    sendbuf.PutBytes(bytes);
                    sendbuf.PutByte(bytes.Length, 0); // Terminating zero
                    int rcvlen;
                    ATMI.tpcall("TOUPPER", sendbuf, 0, ref rcvbuf, out rcvlen, 0);
                    rcvbuf.GetBytes(bytes);
                    Console.WriteLine("Returned string is: " + Encoding.Default.GetString(bytes));
                }
                finally
                {
                    ATMI.tpfree(rcvbuf);
                }
            }
            finally
            {
                ATMI.tpfree(sendbuf);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }
コード例 #2
0
ファイル: TestClient.cs プロジェクト: rboerdijk/DotTux
 public static void Main(string[] args)
 {
     ATMI.tpinit(null);
     try {
         ByteBuffer reply = ATMI.tpalloc("STRING", null, 1024);
         try {
             int len;
             ATMI.tpcall("TEST", null, 0, ref reply, out len, 0);
             byte[] bytes = new byte[len - 1];
             reply.GetBytes(bytes);
             string message = Encoding.Default.GetString(bytes);
             Console.WriteLine(message);
         } finally {
             ATMI.tpfree(reply);
         }
     } finally {
         ATMI.tpterm();
     }
 }
コード例 #3
0
ファイル: SimpleFML32Client.cs プロジェクト: rboerdijk/DotTux
    public static void Main(string[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine("Usage: SimpleFML32Client <field>=<value> ...");
            Environment.Exit(1);
        }

        ATMI.tpinit(null);
        try
        {
            ByteBuffer fbfr = ATMI.tpalloc("FML32", null, 512);
            try
            {
                foreach (string arg in args)
                {
                    int    eqPos = arg.IndexOf('=');
                    string key   = arg.Substring(0, eqPos);
                    string val   = arg.Substring(eqPos + 1);
                    int    fldid = FML32.Fldid(key);
                    TPFBuilder.I.FaddString(ref fbfr, fldid, val);
                }

                int len;
                ATMI.tpcall("FML32_TOUPPER", fbfr, 0, ref fbfr, out len, 0);

                Console.WriteLine("Returned FML32 buffer is: " + FML32.ToString(fbfr));
            }
            finally
            {
                ATMI.tpfree(fbfr);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }