home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / winsock / wstim101 / src / ntime.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  4.7 KB  |  159 lines

  1. // Contents ---------------------------------------------------------------
  2. //
  3. //   ntime.rc -- Windows Resources
  4. //
  5. //   Version 1.0, a Freeware Windows Socket Time Client
  6. //
  7. //   Copyright (C) Frederick W. Bent 1994
  8. //   All rights reserved.
  9. //
  10. //
  11. // Redistribution and use in source and binary forms are permitted provided
  12. // that the above copyright notice and this paragraph are duplicated in all
  13. // such forms and that any documentation, advertising materials, and other
  14. // materials related to such distribution and use acknowledge that the
  15. // software was developed by Frederick W. Bent.  The name of the author may
  16. // not be used to endorse or promote products derived from this software
  17. // without specific prior written permission.  THIS SOFTWARE IS PROVIDED
  18. // "AS IS" AND WITHOUT ANY EXPRESS OF IMPLIED WARRANTIES, INCLUDING,
  19. // WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS 
  20. // FOR A PARTICULAR PURPOSE.
  21. //
  22. // Ends -------------------------------------------------------------------
  23.  
  24. //
  25. // Windows Sockets 1.0 versions define inet_addr as returning a struct,
  26. // whereas later version use an unsigned long.  We use the latter
  27. // definition and provide a #define for backwards compatability.
  28. //
  29. #include <winsock.h>
  30.  
  31. #ifdef USE_CTL3D
  32.   #define CTL3DVERSION_REQ    0x200
  33.   #define CTL3DVERSION_MAJOR    HIBYTE(CTL3DVERSION_REQ)
  34.   #define CTL3DVERSION_MINOR     LOBYTE(CTL3DVERSION_REQ)
  35. #endif
  36.  
  37. #define WSVERSION 0x101                   // Windows Sockets version
  38.  
  39. #if (WSVERSION == 0x100)
  40.    #define INET_ADDR ul_inet_addr
  41.    u_long ul_inet_addr(char *szIP);
  42.  
  43.    u_long ul_inet_addr(char *szIP)        // make our own inet_addr
  44.    {
  45.       IN_ADDR in;
  46.  
  47.       in = inet_addr(szIP);
  48.       return in.s_addr;
  49.    }
  50. #else                               
  51.    #define INET_ADDR inet_addr            // WS DLL has the right inet_addr
  52. #endif
  53.  
  54. #define WSVERSION_REQ    0x0101           // windows sockets version 1.1
  55. #define WSVERSION_MAJOR    LOBYTE(WSVERSION_REQ)
  56. #define WSVERSION_MINOR HIBYTE(WSVERSION_REQ)
  57.  
  58. //
  59. // miscellaneous
  60. //
  61.  
  62.  
  63. typedef struct                      // associates messages (or menu ids) 
  64. {                                   // with a handler function
  65.    UINT Code;
  66.    LRESULT (*Fxn)(HWND, UINT, WPARAM, LPARAM);
  67. } DECODEWORD;
  68.  
  69. #define dim(x) (sizeof(x) / sizeof(x[0]))
  70.  
  71. typedef unsigned long IPA;
  72. typedef IPA FAR *LPIPA;
  73. typedef LPIPA FAR *LPPIPA;
  74.  
  75.  
  76. //
  77. // exported from NETWRK_ 
  78. //
  79.  
  80. #define FE_ERROR         1  // finger operation was not successful
  81. #define FE_NOPORT        2  // failure to resolve finger service to a port 
  82. #define FE_NOHOST        3  // failure to resolve host specifier
  83. #define FE_NOSOCK        4  // failure to obtain socket for connection
  84. #define FE_NOCONN        5  // failure to connect to remote finger server
  85. #define FE_NOSEND        6  // failure to send finger query
  86. #define FE_NORECV        7  // failure to receive finger data
  87. #define FE_SHUTDWN       8  // failure to shutdown socket
  88. #define IDS_EXIT_ACTIVE 9
  89. #define IDS_EXITING    10
  90. #define FE_INVLDTIME    11    // failed to get time from server
  91. #define FE_INIT        12
  92. #define FE_CANCEL    13
  93. #define IDS_BAD_VERSION 14
  94. #define FE_NOBIND    15    // failed to bind to local port
  95. #define IDS_BRK_WINSOCK    16
  96. #define IDS_CTL3D_VER    17
  97.  
  98. extern SOCKET sSocket;
  99. extern int nUDPNumberRetry;
  100. extern int nUDPTimeOutValue;
  101.  
  102. VOID FingerStart(PSTR szHost);
  103. BOOL InitNetInst(HWND hWnd, int, int, int);
  104. VOID InitNetApp(VOID);
  105. VOID NetClose(VOID);
  106. VOID FingerStop(VOID);
  107.  
  108. //
  109. // exported from module FINGER
  110. //
  111.  
  112. #define MAXHOST       64        // maximum hostname
  113. #define MAXUSER       40
  114. #define MAX_PATH      (260)
  115. #define APP_NAME  "Time Client"
  116.  
  117. extern char szUser[];        // user id for query
  118. extern char szAppName[];
  119. extern char szHelpFileName[MAX_PATH];
  120. extern HINSTANCE hInst;                // this instance of finger
  121. extern HWND    hFrame;
  122. extern BOOL    bShouldUseTCP;        // use stream instead of datagram
  123. extern BOOL    bUpdateSystemTime;    // should update the system time
  124.  
  125.  
  126. VOID WinPrintf( HDC   hdc, int row, UINT   col, LPSTR pszFormat, ... );
  127. VOID ReportFingerErr(UINT Err, int nWSErr);
  128. VOID ReportWSError(int nWSErr);
  129. VOID TimeFinish(UINT Err);
  130. VOID SetWinCaption(PSTR szString);
  131.  
  132. //
  133. // menu & dialog identifiers
  134. //
  135.  
  136. #define IDM_OPEN         1
  137. #define IDM_SETUP        2
  138. #define IDM_EXIT         3
  139. #define IDM_HELP_INDEX     4
  140. #define IDM_ABOUT        5
  141.  
  142. #define IDM_HOST1    10
  143. #define IDM_HOST2    11
  144. #define IDM_HOST3    12
  145. #define IDM_HOST4    13
  146. #define IDM_HOST5    14
  147.  
  148. #define IDC_HOSTNAME     20
  149. #define IDC_USER         21
  150. #define IDC_USETCP       22
  151. #define IDC_UPDATE       23
  152. #define IDB_CONNECT       24
  153. #define IDC_UDPRETRY    25
  154. #define IDC_UDPTIME    26
  155.  
  156. #define IDT_UDP1    30
  157. #define IDT_UDP2    31
  158.  
  159.