home *** CD-ROM | disk | FTP | other *** search
/ Oracle Video Server 3.0.3.1 / OVS_3031_NT.iso / win32 / sqlnet / net23 / client / tftpdef.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-05  |  4.5 KB  |  127 lines

  1. /*
  2.   $Header: /netrcs/RCS/oracle/network/tns/tnsapi/RCS/tftpdef.h,v 1.4 1995/09/13 06:59:35 yzheng Exp $
  3. */
  4.  
  5. #ifndef TFTPDEF
  6. #define TFTPDEF
  7.  
  8. #include <stdio.h>
  9. #include <sys/types.h>
  10. #include <setjmp.h>
  11. #include <signal.h>
  12. #ifndef TNSAPI
  13. #include <tnsapi.h>
  14. #endif
  15. #ifdef WIN32
  16. #include "windows.h"
  17. #endif
  18. #ifdef _HPUX_SOURCE
  19. # include <netinet/in.h>    /* HPUX */
  20. #endif /* HPUX */
  21. /*#include "systype.h"*/
  22.  
  23. #ifdef WIN32
  24. #define ntohs(x)  ((0xff & (x))<<8)+((0xff00 & (x))>>8) 
  25. #define htons(x)  ((0xff & (x))<<8)+((0xff00 & (x))>>8)
  26. #define fileno   _fileno
  27. #endif 
  28.  
  29. #define MAXBUFF     2048       /* transmit and receive buffer length */
  30. #define MAXDATA     1024       /* maximum size of data per packet to send
  31.                                   or rcv, specified by RFC           */
  32.  
  33. #define MAXFILENAME  128       /* max filename length                */
  34.  
  35. #define MAXLINE      512       /* max command line length            */
  36. #define MAXTOKEN     128       /* max token length                   */
  37.  
  38. #ifdef SERVER
  39. extern void *svrtnshdl;        /* the tns connection handle of server */
  40. #else
  41. extern void *clitnshdl;        /* the tns connection handle of client*/
  42. #endif
  43.  
  44. extern int connected;          /* we are connected with the server */
  45. extern FILE *localfp;          /* fp of local file to read or write */
  46. extern int modetype;           /* the transfer mode */
  47. extern int nextblknum;         /* next block# to send/receive */
  48.  
  49. extern char command[];         /* the command being processed */
  50. extern int interactive;        /* true if we are running interactively */
  51. extern jmp_buf jmp_mainloop;   /* to return to main command loop */
  52. extern int lastsend;           /* #bytes in the last data packet */
  53.  
  54. extern char *pname;            /* the name by which we are invoked */
  55. extern char *prompt;           /* prompt string, for interactive */
  56.  
  57. extern long totnbytes;         /* for get/put statistics printing */
  58. extern int traceflag;          /* -t command line option, or "trace" cmd */
  59. /*extern int verboseflag; */   /* -v command line option, or "verbose" cmd */
  60.  
  61. #define MODE_ASCII    0
  62. #define MODE_BINARY   1
  63.  
  64. #define OP_RRQ   1             /* Read request */
  65. #define OP_WRQ   2             /* Write request */
  66. #define OP_DATA  3             /* Data */
  67. #define OP_ACK   4             /* Acknowledgment */
  68. #define OP_ERROR 5             /* Error */
  69.  
  70. /*
  71.  * This extra opcode is added to handle disconnect.
  72.  * When the client calls "connect" to a different address, the first
  73.  * connection should be disconnected, and the server process should 
  74.  * go away. The client inform the server by sending a "disconnect" opcode
  75.  * packet. When the server receives it, it calls tnsclose() to clean up
  76.  * the connection, and then exit.
  77.  */
  78. #define OP_DISCONNECT 6        /* DISCONNECT */
  79.   
  80. #define OP_MIN   1             /* minimum op value */
  81. #define OP_MAX   5             /* max op value */
  82.  
  83. extern int op_sent;            /* last opcode sent */
  84. extern int op_recv;            /* last opcode received */
  85.  
  86.  
  87. #define DEBUG1(fmt, arg1)    if (traceflag) {\
  88.                                 fprintf(stderr, fmt, arg1); \
  89.                                 fputc('\n', stderr); \
  90.                                 fflush(stderr); \
  91.                                            } else;
  92.  
  93. #define DEBUG2(fmt, arg1, arg2) if (traceflag) { \
  94.                                 fprintf(stderr, fmt, arg1, arg2); \
  95.                                 fputc('\n', stderr); \
  96.                                 fflush(stderr); \
  97.                                            } else;                                
  98.  
  99. /* 
  100.  * define macros to load and store 2-bytes integers, since these are used
  101.  * in the TFTP headers for opcode, block numbers and error. These macros
  102.  * handle the conversion between host format and network byte ordering
  103.  */
  104. #define ldshort(addr)      (ntohs(*(u_short *)(addr)))
  105. #define stshort(sval, addr) ( *((u_short *)(addr)) = htons(sval))
  106.  
  107. extern char recvbuff[];
  108. extern char sendbuff[];
  109. extern int sendlen;        /* #bytes in sendbuff[] */
  110.  
  111. /*#define CONNECT_DATA "connect data"
  112. #define CON_LEN 128*/
  113.  
  114. /*
  115.  * tftp error code
  116.  */
  117. #define ERR_UNDEF     0          /* not defined, */
  118. #define ERR_NOFILE    1          /* File not found */
  119. #define ERR_ACCESS    2          /* Access violation */
  120. #define ERR_NOSPACE   3          /* Disk full */
  121. #define ERR_BADOP     4          /* Illegal tftp operation */
  122. #define ERR_FILE      5          /* File already exists */
  123. #define ERR_NOUSER    6          /* No such user */
  124.  
  125. #endif
  126.  
  127.