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

  1. /*
  2.   $Header: /netrcs/RCS/oracle/network/tns/tnsapi/RCS/maincli.c,v 1.4 1995/09/13 07:03:40 yzheng Exp $
  3. */
  4.  
  5. /*
  6.  * main function of the client. parse the command line argument, 
  7.  * set up the option flag like trace, call underlying 
  8.  * routine to process the file. 
  9.  */
  10.  
  11. #include "tftpdef.h"
  12. #include <stdio.h>
  13.  
  14. char *prompt = "tftp> ";
  15. void *clitnshdl = 0;
  16.  
  17. main(argc, argv)
  18. int argc;
  19. char **argv;
  20. {
  21.   register int i;
  22.   register char *s;
  23.   register FILE *fp;
  24.  
  25.   pname = argv[0];
  26.  
  27.   /*
  28.    * parse the command line argument, e.g.
  29.    * tftp -t     - trace
  30.    */
  31.  
  32.   /*
  33.    * take command line argument, process the command. Standard
  34.    * input is processed by default 
  35.    */
  36.  
  37.   fp = stdin;
  38.  
  39.   mainloop(fp);
  40.     
  41.   exit(0);
  42. }
  43.  
  44. /*
  45.  * Main loop. Read a command and execute it.
  46.  * This loop is terminated by a "quit" command, or an end-of-file
  47.  * on the command stream
  48.  */ 
  49. mainloop(fp)
  50. FILE *fp;
  51. {
  52.   void sig_intr();
  53.  
  54.   if (signal(SIGINT, SIG_IGN) != SIG_IGN)
  55.     signal(SIGINT, sig_intr);
  56.  
  57.   if (setjmp(jmp_mainloop) < 0)
  58.     err_ret("Timeout");
  59.  
  60.   /*
  61.    * print the prompt for interactive 
  62.    */
  63.   if (interactive)
  64.     printf("%s", prompt);
  65.   
  66.   while (getline(fp))
  67.   {
  68.     if (gettoken(command) != NULL)
  69.       docmd(command);
  70.     
  71.     if (interactive)
  72.       printf("%s", prompt);
  73.  
  74.     command[0] = '\0';
  75.   }
  76. }
  77.  
  78. /* 
  79.  * INTR signal handler. Just return to the main loop.
  80.  * In case we were waiting for a read to complete, turn off any 
  81.  * possible alarm clock interrupts.
  82.  *
  83.  * Note that with TFTP, if the client aborts a file transfer (such as
  84.  * with the interrupt signal), the server is not notified. The protocol
  85.  * counts on the server eventually timing out and exiting.
  86.  * 
  87.  */
  88. void sig_intr()
  89. {
  90. #ifndef WIN32
  91.   signal(SIGALRM, SIG_IGN);
  92.   alarm(0);
  93. #endif
  94.  
  95.   longjmp(jmp_mainloop, 1);
  96. }
  97.  
  98.