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 >
Wrap
C/C++ Source or Header
|
1995-06-02
|
4KB
|
132 lines
/****************************************************************************
** DISCLAIMER
**
** Novell, Inc. makes no representations or warranties with respect to
** any NetWare software, and specifically disclaims any express or
** implied warranties of merchantability, title, or fitness for a
** particular purpose.
**
** Distribution of any NetWare software is forbidden without the
** express written consent of Novell, Inc. Further, Novell reserves
** the right to discontinue distribution of any NetWare software.
**
** Novell is not responsible for lost profits or revenue, loss of use
** of the software, loss of data, costs of re-creating lost data, the
** cost of any substitute equipment or program, or claims by any party
** other than you. Novell strongly recommends a backup be made before
** any software is installed. Technical support for this software
** may be provided at the discretion of Novell.
*****************************************************************************
**
** File: DateTime.c
**
** Desc: Example program of how to Get the Servers Date and Time.
**
**
** Parameter descriptions: > input
** < output
**
**
** Netware API Calls:
**
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** ARM A. Ray Maxwell Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 06-01-95 ARM First code.
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------
** ANSI
*/
#include <stdio.h> /* printf() */
#include <stdlib.h> /* exit() */
#include <string.h> /* strcpy() strupr() */
#include <dos.h> /* getdate() gettime() */
/*------------------------------------------------------------------
** NetWare
*/
#define NWDOS
#include <nwcalls.h>
/****************************************************************************
** Main Program
*/
void main(int argc,char *argv[])
{
typedef struct{
BYTE year;
BYTE month;
BYTE day;
BYTE hour;
BYTE minute;
BYTE second;
BYTE dayOfWeek;
}TIMEDATE;
TIMEDATE datebytes;
NWCCODE ccode;
NWCONN_HANDLE connHandle; /* connection handle */
char server[48];
//getdate(&d);
//gettime(&t);
if (argc < 2){
printf("USAGE:servdate <servername>\n");
exit(1);
}
strcpy(server,strupr(argv[1])); /* server name */
ccode = NWCallsInit(NULL, NULL);
if (ccode != 0x0000){
printf("NWCallsInit failed with ccode =%X\n",ccode);
exit(0);
}
ccode = NWGetConnectionHandle(
/* server name */ server,
/* reserved */ 0,
/* connection handle */ &connHandle,
/* reserved */ NULL);
if(ccode){
printf("NWGetDefaultConnectionID failed %X\n");
exit(0);
}
ccode=NWGetFileServerDateAndTime(
/* > connection Handle */ connHandle,
/* < 7 byte buffer for date and time */ (BYTE *)&datebytes);
if (ccode){
printf("NWGetFileServerDateAndTime failed %X\n",ccode);
exit(1);
}
printf("Date and time-> %2d/%2d/%2d %2d:%2d:%2d\n",
datebytes.month,
datebytes.day,
datebytes.year,
datebytes.hour,
datebytes.minute,
datebytes.second);
}