home *** CD-ROM | disk | FTP | other *** search
/ Oracle Video Server 3.0.3.1 / OVS_3031_NT.iso / win32 / sqlnet / net23 / client / cmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-27  |  2.8 KB  |  151 lines

  1. /*
  2.   $Header: /netrcs/RCS/oracle/network/tns/tnsapi/RCS/cmd.c,v 1.2 1995/09/12 21:32:13 mhill Exp $
  3. */
  4.  
  5. /*
  6.  * command processing function on the client side
  7.  */
  8. #ifndef CMD
  9. # include "cmd.h"
  10. #endif
  11.  
  12. int cmd_ascii()
  13. {
  14.   modetype = MODE_ASCII;
  15. }
  16.  
  17. int cmd_binary()
  18. {
  19.   modetype = MODE_BINARY;
  20. }
  21.  
  22. int cmd_connect()
  23. {
  24.   char con_string[MAXBUFF];   /* connect string */
  25.   char *data = "";
  26.   int datalen = 1;
  27.  
  28. /*
  29.  * We need to check if a previous connection is open, if so, we need to
  30.  * send a disconnect packet to the existing server process first, asking
  31.  * it to close down the connect, before we establish a different connection
  32.  */
  33.  
  34.   if (clitnshdl)
  35.   {
  36.     send_DISRQ();
  37.     tnsclose(&clitnshdl);
  38.   }
  39.  
  40.   if (gettoken(con_string) == NULL)
  41.     err_cmd("incorrect connect string or alias");
  42.  
  43.   if (tnsopen(&clitnshdl, con_string) != 0)
  44.     err_cmd("tnsopen failed");
  45.  
  46.   /* send an empty string over to establish connection */
  47.   if (tnssend(clitnshdl, data, &datalen) != 0)
  48.   {
  49.     tnsclose(&clitnshdl);
  50.     err_cmd("Failed to establish connection with the server");
  51.   }
  52.   else
  53.     connected = 1;
  54.   
  55. }
  56.  
  57. int cmd_exit()
  58. {
  59.   if (clitnshdl)
  60.   {
  61.     send_DISRQ();
  62.     tnsclose(&clitnshdl);
  63.   }
  64.   exit(0);
  65. }
  66.  
  67. int cmd_get()
  68. {
  69.   char remfname[MAXFILENAME], locfname[MAXFILENAME];
  70.  
  71.   if (gettoken(remfname) == NULL)
  72.     err_cmd("the remote filename must be specified");
  73.   if (gettoken(locfname) == NULL)
  74.     err_cmd("the local filename must be specified");
  75.  
  76.   do_get(remfname, locfname);
  77. }
  78.  
  79. int cmd_help()
  80. {
  81.   register int i;
  82.   
  83.   for (i = 0; i < ncmds; i++)
  84.     printf(" %s\n", commands[i].cmd_name);
  85.  
  86. }
  87.  
  88. int cmd_mode()
  89. {
  90.   if (gettoken(temptoken) == NULL)
  91.     err_cmd("a mode type must be specified");
  92.   else
  93.   {
  94.     if (strcmp(temptoken, "ascii") == 0)
  95.       modetype = MODE_ASCII;
  96.     else if (strcmp(temptoken, "binary") == 0)
  97.       modetype = MODE_BINARY;
  98.     else
  99.       err_cmd("mode must be 'ascii' or 'binary'");
  100.   }
  101. }
  102.  
  103. int cmd_put()
  104. {
  105.   char remfname[MAXFILENAME], locfname[MAXFILENAME];
  106.  
  107.   if (gettoken(locfname) == NULL)
  108.     err_cmd("the local filename must be specified");
  109.   if (gettoken(remfname) == NULL)
  110.     err_cmd("the remote filename must be specified");
  111.  
  112.   do_put(remfname, locfname);
  113. }
  114.  
  115. int cmd_status()
  116. {
  117.   if (connected)
  118.     printf("Connected\n");
  119.   else
  120.     printf("Not connected\n");
  121.  
  122.   printf("mode = ");
  123.   switch(modetype)
  124.   {
  125.   case MODE_ASCII:
  126.     printf("netascii");
  127.     break;
  128.   case MODE_BINARY:
  129.     printf("octet (binary)");
  130.     break;
  131.   default:
  132.     err_cmd("unknown modetype");
  133.   }
  134.  
  135. /*  printf(", verbose = %s", verboseflag ? "on": "off"); */
  136.   printf(", trace = %s\n", traceflag ? "on" : "off");
  137.  
  138. }
  139.  
  140. int cmd_trace()
  141. {
  142.   traceflag = !traceflag;
  143. }
  144.  
  145. /*int cmd_verbose()
  146. {
  147.   verboseflag = !verboseflag;
  148. }*/
  149.  
  150.  
  151.