home *** CD-ROM | disk | FTP | other *** search
- /**-----------------------------------------------------------**
- * *
- * Bill Nolde 10-89 *
- **------------------------------------------------------------**/
- #include "NETCONS.H"
- #include "DOSCALLS.H"
- #include "REMUTIL.H"
- #include "TIME.H"
-
- #ifdef _DOS_
- #include "dos.h"
- #endif
-
- /**------------------------------------------------------**/
- main( int argc , char *argv[] )
- {
- unsigned short retcode , phandle , bytesread ;
- char servername[22] ;
- struct time_of_day_info ti;
- struct DateTime dt;
-
-
- if ( argc < 2 ) {
- printf ( "\nTime Server Name Must be Specified\n" );
- exit (1);
- }
- if ( argv[1][0] != '\\' ) {
- strcpy ( servername , "\\\\" );
- strcat ( servername , argv[1] );
- }
- else strcpy ( servername , argv[1] );
-
- strupr ( servername );
-
- printf ( "\nCalling %s\n" , servername );
-
- retcode = NetRemoteTOD ( servername , ( char *) &ti ,
- sizeof ( struct time_of_day_info ) );
-
- if ( retcode == 0 ) {
- dt.hour = ti.tod_hours;
- dt.minutes = ti.tod_mins;
- dt.seconds = ti.tod_secs;
- dt.day = ti.tod_day;
- dt.month = ti.tod_month;
- dt.year = ti.tod_year;
- retcode = DoSetTime ( &dt );
- if ( retcode == 0 ) printf ( "\nTime Set\n" );
- else printf ( "\nTime And Date Not Set , error %d\n" ,retcode);
- }
- else printf ( "\nError %d Trying to get the Time from %s\n",
- retcode , servername );
- }
- /**---------------------------------------------------------**/
- DoSetTime ( struct DateTime *dt )
- {
- int retcode;
- #ifdef _OS2_
- return ( DOSSETDATETIME ( dt ) );
- #endif
-
- #ifdef _DOS_
- union REGS inregs , outregs ;
-
-
- inregs.h.ah = 0x2d; /* Set Time */
- inregs.h.ch = dt->hour;
- inregs.h.cl = dt->minutes ;
- inregs.h.dh = dt->seconds ;
- inregs.h.dl = 0 ;
-
- int86 ( 0x21 , &inregs , &outregs );
- if ( outregs.h.al ) return ( 1 );
-
- inregs.h.ah = 0x2b; /* Set Date */
- inregs.x.cx = dt->year ;
- inregs.h.dh = dt->month ;
- inregs.h.dl = dt->day ;
- int86 ( 0x21 , &inregs , &outregs );
- if ( outregs.h.al ) return ( retcode );
-
- return ( 0 );
- #endif
- }
- /**---------------------------------------------------------**/
-