home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / servdt.exe / SERVDATE.C next >
C/C++ Source or Header  |  1995-06-02  |  4KB  |  132 lines

  1. /****************************************************************************
  2. ** DISCLAIMER
  3. **
  4. ** Novell, Inc. makes no representations or warranties with respect to
  5. ** any NetWare software, and specifically disclaims any express or
  6. ** implied warranties of merchantability, title, or fitness for a
  7. ** particular purpose.
  8. **
  9. ** Distribution of any NetWare software is forbidden without the
  10. ** express written consent of Novell, Inc.  Further, Novell reserves
  11. ** the right to discontinue distribution of any NetWare software.
  12. **
  13. ** Novell is not responsible for lost profits or revenue, loss of use
  14. ** of the software, loss of data, costs of re-creating lost data, the
  15. ** cost of any substitute equipment or program, or claims by any party
  16. ** other than you.  Novell strongly recommends a backup be made before
  17. ** any software is installed.   Technical support for this software
  18. ** may be provided at the discretion of Novell.
  19. *****************************************************************************
  20. **
  21. ** File:   DateTime.c
  22. **
  23. ** Desc:   Example program of how to Get the Servers Date and Time.
  24. **
  25. **         
  26. ** Parameter descriptions:    > input
  27. **                            < output
  28. **
  29. **
  30. ** Netware API Calls:     
  31. **
  32. **
  33. ** Programmers:
  34. ** Ini   Who                Firm
  35. ** ------------------------------------------------------------------
  36. ** ARM   A. Ray Maxwell     Novell Developer Support.
  37. **
  38. ** History:
  39. **
  40. ** ------------------------------------------------------------------
  41. ** 06-01-95   ARM   First code.
  42. */
  43.  
  44. /****************************************************************************
  45. **   Include headers, macros, function prototypes, etc.
  46. */
  47.  
  48.  
  49.     /*------------------------------------------------------------------
  50.     **   ANSI
  51.     */
  52.    #include <stdio.h>       /* printf()          */
  53.     #include <stdlib.h>      /* exit()            */
  54.     #include <string.h>      /* strcpy() strupr() */
  55.     #include <dos.h>        /* getdate() gettime() */
  56.  
  57.     /*------------------------------------------------------------------
  58.     **   NetWare
  59.     */
  60.     #define  NWDOS
  61.     #include <nwcalls.h>
  62.  
  63.  
  64.  
  65. /****************************************************************************
  66. ** Main Program
  67. */
  68. void main(int argc,char *argv[])
  69. {
  70.     typedef struct{
  71.                         BYTE year;
  72.                         BYTE month;
  73.                         BYTE day;
  74.                         BYTE hour;
  75.                         BYTE minute;
  76.                         BYTE second;
  77.                         BYTE dayOfWeek;
  78.                         }TIMEDATE;
  79.  
  80.     TIMEDATE           datebytes;
  81.     NWCCODE            ccode;
  82.     NWCONN_HANDLE      connHandle; /* connection handle                   */
  83.  
  84.     char server[48];
  85.  
  86.  
  87.  
  88.     //getdate(&d);
  89.     //gettime(&t);
  90.  
  91.     if (argc < 2){
  92.         printf("USAGE:servdate <servername>\n");
  93.         exit(1);
  94.     }
  95.     strcpy(server,strupr(argv[1]));                          /* server name     */
  96.  
  97.     ccode = NWCallsInit(NULL, NULL);
  98.  
  99.     if (ccode != 0x0000){
  100.         printf("NWCallsInit failed with ccode =%X\n",ccode);
  101.         exit(0);
  102.     }
  103.  
  104.     ccode = NWGetConnectionHandle(
  105.               /* server name        */ server,
  106.               /* reserved           */ 0,
  107.               /* connection handle  */ &connHandle,
  108.               /* reserved           */ NULL);
  109.     if(ccode){
  110.         printf("NWGetDefaultConnectionID failed %X\n");
  111.         exit(0);
  112.     }
  113.  
  114.     ccode=NWGetFileServerDateAndTime(
  115.             /* > connection Handle               */ connHandle,
  116.             /* < 7 byte buffer for date and time */ (BYTE *)&datebytes);
  117.  
  118.     if (ccode){
  119.         printf("NWGetFileServerDateAndTime failed %X\n",ccode);
  120.         exit(1);
  121.     }
  122.  
  123.  
  124. printf("Date and time->  %2d/%2d/%2d   %2d:%2d:%2d\n",
  125.             datebytes.month,
  126.             datebytes.day,
  127.             datebytes.year,
  128.             datebytes.hour,
  129.             datebytes.minute,
  130.             datebytes.second);
  131. }
  132.