[comp.os.vms] Network time setting program?

JMS@MIS.ARIZONA.EDU ("I've got an envelope that will wash your car...") (06/25/88)

 sunybcs!leo@rutgers.edu asks

> What I am looking for is a time-synch program
> that will allow any of the machines on our DECNET (1 11/750, 6-12 uVAX II's
> depending on how many customer machines are there) and I think it's just
> atrocious that we have all these CPU's with different system times. Is there

We have something like that.  On all of our VAX systems, there exists
an object, "TIME", which, when connected to, sends the time down the
pipe.  

On all of our PC systems, when they boot, they run a program which connects
to a TIME nearby, and sets the time on the PC thusly.  

Now, a real programmer would have had VAX systems broadcasting the
time on the Ethernet every ten seconds or so, but I didn't have time to
deal with that (and, besides, that doesn't work across non-LAN connections...)

Anyway:

write_time.c

#include time
#include stdio
main()
{
    struct tm *now;
    long time_now;
    FILE sys$net;

    time(&time_now);
    now = localtime(&time_now);
    sys$net = fopen("SYS$NET","a");
    fprintf(sys$net,"%d,%d,%d,%d,%d,%d,00\n",now->tm_year+1900,
	now->tm_mon+1,now->tm_mday,now->tm_hour,now->tm_min,now->tm_sec);
}    

vtime.c

#include <stdio.h>
#include <dos.h>

main()
{
    union REGS inregs;
    union REGS outregs;
    char string[132];
    char *task="\\\\t\\misvax\\\\time";
    int handle;
    int year,month,day,hour,seconds,minutes,hundredths;

    inregs.h.ah=0x3C;
    inregs.h.al=0;
    inregs.x.dx=task;
    intdos(&inregs,&outregs);
    handle=outregs.x.ax;
    if (outregs.x.cflag != 0) {
	printf("error in open/create. code is %d\n",handle);
	exit(1);
    }

    inregs.h.ah=0x3F;
    inregs.h.al=0;
    inregs.x.dx= &string[0];
    inregs.x.cx=80;
    inregs.x.bx=handle;
    intdos(&inregs,&outregs);
    if (outregs.x.cflag != 0) {
	printf("Error in read.\n");
	exit(1);
    }

    inregs.h.ah=0x3E;
    inregs.h.al=0;
    inregs.x.bx=handle;
    intdos(&inregs,&outregs);
    if (outregs.x.cflag != 0) {
	printf("Error in close. Code was %d\n",outregs.x.ax);
	exit(1);
    }

    sscanf (string,"%d,%d,%d,%d,%d,%d,%d",&year,&month,&day,&hour,
		&minutes,&seconds,&hundredths);

    inregs.h.ah=0x2B;
    inregs.h.al=0;
    inregs.x.cx=year;
    inregs.h.dh=month;
    inregs.h.dl=day;
    intdos(&inregs,&outregs);
    if (outregs.h.al != 0) {
	printf("Error in setting date.\n");
	exit(1);
    }

    inregs.h.ah=0x2D;
    inregs.h.ch=hour;
    inregs.h.dh=seconds;
    inregs.h.cl=minutes;
    inregs.h.dl=hundredths;
    intdos(&inregs,&outregs);
    if (outregs.h.al != 0) {
	printf("Error in setting time.\n");
	exit(1);
    }
}

jms

+----------------------------+ BITNET: jms@arizmis.BITNET
|Joel M Snyder               | Inter: jms@mis.arizona.edu     
|Univ of Arizona Dep't of MIS| Phone: 602.621.2748   ICBM: 32 13 N / 110 58 W
|Tucson, AZ 85721            | Quote: "Design is everything. 
+----------------------------+         Implementation is trivial."