# This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # Makefile # README # getDate.h # getDate.man # getDate.x # getDateServer.c # getDate.c # getDate_xdr.c # This archive created: Tue Oct 10 09:21:47 1989 sed 's/^X//' << \SHAR_EOF > Makefile X# Makfile for getDate() X# X# Richard Neitzel X# 10 Oct. 1989 XCC = cc XCFLAGS = -I/vx/h -I/vx/h/rpc -O4 XOBJS = getDate.o getDate_xdr.o getDateServer.o X X# Xall: $(OBJS) X echo "Done compiling" X Xclean: X rm -f $(OBJS) SHAR_EOF sed 's/^X//' << \SHAR_EOF > README XThis is a set of files for implementing a simple date server for XVxWorks. A UNIX system acts as the server, supplying the VxWorks Xclient with the current date/time. The only information passed are: X Xmonth, day, year, hour, minute, second X XMonth is 'normalized' by adding 1 to reflect typical thinking (i.e. XJune is month 6 not month 5). X XAn additional field (.m_sec) is provided to allow passing extra information.SHAR_EOF sed 's/^X//' << \SHAR_EOF > getDate.h X/* X Module: getDate.h X Author: Richard E. K. Neitzel X Date: 10 Oct. 1989 X Xrevision history X---------------- X1.0,10oct89,rekn Archive version. X X X Brief description: X X Header file, slightly modified from rpcgen output, for X obtaining dates from UNIX systems. X X* Copyright notice X* X* The following code is copywrited material of the National X* Center for Atmospheric Research. You may freely use, modify X* and distribute this material, but the copyright notice must be X* included in all such material. NCAR and the author accept no X* responsibility for any damages occurring through the use of X* this material. X X*/ X X#ifndef INCgetdateh X#define INCgetdateh X Xstruct get_date { X int day; X int mth; X int year; X int hour; X int minute; X int sec; X int m_sec; X}; Xtypedef struct get_date GET_DATE; Xbool_t xdr_get_date(); X X#define GET_DATE_PROG 0x30000002 X#define GET_DATE_PROC 1 X#define GET_DATE_VERS 1 X X#endif INCgetdateh SHAR_EOF sed 's/^X//' << \SHAR_EOF > getDate.man X.TH getDate l "10 October 1989" "Eldora Addition" X.SH NAME XgetDate - Get UNIX date X.SH SYNOPSIS X.nf XSTATUS getDate(&date); X Xchar *getDateServer(); X XGET_DATE date; X X#include "local/getDate.h" X.fi X.SH DESCRIPTION X.I getDate Xacts as a VxWorks client RPC call to X.I getDateServer Xrunning on a UNIX system. The call puts the current time on the remote Xmachine into X.I date. XThe GET_DATE structure is: X.nf X struct GET_DATE { X int day; X int mth; X int year; X int hour; X int minute; X int sec; X int m_sec; X }; X.fi X.SH RETURNS X.I getDate Xreturns OK if all is well and ERROR if the call fails. X.SH BUGS AND FLAMES XSend bugs and flames to: X.nf XRichard Neitzel XNational Center for Atmospheric Research XBox 3000 XBoulder, CO 80307 X303-497-2057 Xthor@thor.ucar.edu X SHAR_EOF sed 's/^X//' << \SHAR_EOF > getDate.x Xstruct get_date { X int day; X int mth; X int year; X int hour; X int minute; X int sec; X int m_sec; X}; SHAR_EOF sed 's/^X//' << \SHAR_EOF > getDateServer.c X#include X#include X#include "local/getDate.h" X Xstatic GET_DATE curDate; X Xchar *getDateServer() X{ X struct tm *ptr; X struct timeval tval; X struct timezone tz; X X gettimeofday(&tval,&tz); X X ptr = localtime(&tval.tv_sec); X X curDate.sec = ptr->tm_sec; X curDate.minute = ptr->tm_min; X curDate.hour = ptr->tm_hour; X curDate.day = ptr->tm_mday; X curDate.mth = ptr->tm_mon + 1; X curDate.year = ptr->tm_year; X X return((char *)&curDate); X} SHAR_EOF sed 's/^X//' << \SHAR_EOF > getDate.c X/* X Module: getDate.c X Author: Richard E. K. Neitzel X Date: 10 October 1989 X Xrevision history X---------------- X1.0,10oct89,rekn Archive version. X X X Brief description: X X Calls UNIX to get date, using RPC. X X* Copyright notice X* X* The following code is copywrited material of the National X* Center for Atmospheric Research. You may freely use, modify X* and distribute this material, but the copyright notice must be X* included in all such material. NCAR and the author accept no X* responsibility for any damages occurring through the use of X* this material. X X*/ X#include "vxWorks.h" X#include "rpc/rpc.h" X#include "local/getDate.h" X XSTATUS getDate(host,datePtr) Xchar *host; XGET_DATE *datePtr; X{ X if (callrpc(host,GET_DATE_PROG,GET_DATE_VERS,GET_DATE_PROC,xdr_void, X 0,xdr_get_date,datePtr) != 0) X return(ERROR); X else X return(OK); X} X SHAR_EOF sed 's/^X//' << \SHAR_EOF > getDate_xdr.c X/* X Module: getDate_xdr.c X Author: Richard E. K. Neitzel X Date: 10 October 1989 X Xrevision history X---------------- X1.0,10oct89,rekn Archive version. X X X Brief description: X This is the xdr routine to pass the date structure. X X X* Copyright notice X* X* The following code is copywrited material of the National X* Center for Atmospheric Research. You may freely use, modify X* and distribute this material, but the copyright notice must be X* included in all such material. NCAR and the author accept no X* responsibility for any damages occurring through the use of X* this material. X X*/ X#include "vxWorks.h" X#include "rpc/rpc.h" X#include "local/getDate.h" X Xbool_t Xxdr_get_date(xdrs, objp) XXDR *xdrs; XGET_DATE *objp; X{ X if (!xdr_int(xdrs, &objp->day)) { X return (FALSE); X } X if (!xdr_int(xdrs, &objp->mth)) { X return (FALSE); X } X if (!xdr_int(xdrs, &objp->year)) { X return (FALSE); X } X if (!xdr_int(xdrs, &objp->hour)) { X return (FALSE); X } X if (!xdr_int(xdrs, &objp->minute)) { X return (FALSE); X } X if (!xdr_int(xdrs, &objp->sec)) { X return (FALSE); X } X if (!xdr_int(xdrs, &objp->m_sec)) { X return (FALSE); X } X return (TRUE); X} X X SHAR_EOF # End of shell archive exit 0