예제 #1
0
void bintim(               /* convert time string to 64 bits, put in binval */
    char *time,
    long int binval[2] )
{
    static struct dsc$descriptor date_str={0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};

    date_str.dsc$w_length = strlen(time);
    date_str.dsc$a_pointer = time;
    sys$bintim(&date_str, binval);
}
예제 #2
0
파일: eftim.c 프로젝트: rroart/freevms
main()
{
    $DESCRIPTOR(tensec,"0 00:00:10.00");

    sys$bintim(&tensec,&step1);

    sys$setimr(50,&step1,my1,0,0);

    printf("before waitfr %x\n",time(0));

    sys$waitfr( 50 );

    printf("after waitfr %x\n",time(0));

}
예제 #3
0
파일: schdwk.c 프로젝트: rroart/freevms
main()
{
    $DESCRIPTOR(secs,"0 00:00:20.00");

    sys$gettim(&now);
    sys$bintim(&secs,&step1);
    if (now<0) printf("now less than 0\n");
    if (step1<0) printf("step1 less than 0\n");
    now=now-step1;

    sys$schdwk(0,0,&now,&step1);

    printf("before hiber %x\n",time(0));

    sys$hiber();

    sys$hiber();

    sys$hiber();

    printf("after hiber %x\n",time(0));

}
예제 #4
0
int
sysbintim (char *ci_, DATENT *obfr)
{
	static	char	bigbfr[MAXBFR];	/* FIXME */
	static	char	midbfr[MAXBFR];
	$DESCRIPTOR(DSCx,bigbfr);
	$DESCRIPTOR(midnite,midbfr);
	DATENT	base;
	int	j;
	int	num	= strlen(ci_);
	char	*c_, *d_, *e_;

	if (num >= (MAXBFR-1))
		num = (MAXBFR-1);
	for (j = 0; j < num; j++)
		bigbfr[j] = _toupper(ci_[j]);
	bigbfr[num] = '\0';

	/*
	 * Compute the base of the current day, to use in keyword-dates:
	 */
	sys$gettim (obfr);
	sysasctim (midbfr, obfr, MAXDAY);
	strcpy (&midbfr[11], zeros);
	midnite.dsc$a_pointer = midbfr;
	midnite.dsc$w_length  = strlen(midbfr);
	sys$bintim (&midnite, obfr);
	base = *obfr;

	if (strabbr (bigbfr, "TODAY", num, 3))
		num = 0;
	else if (strabbr (bigbfr, "YESTERDAY", num, 1))
	{
		lib$subx (base, day, obfr, 0);
		num = 0;
	}
	else if (strabbr (bigbfr, "TOMORROW", num, 3))
	{
		lib$addx (base, day, obfr, 0);
		num = 0;
	}
	/*
	 * $BINTIM cannot parse the ':' used in DCL to separate date, time.
	 * Convert this to a trailing space and supply trailing zeros.  Also,
	 * if the year and/or month is not given, supply these:
	 */
	else
	{
		register int dash = 0;
		d_ = zeros;
		for (c_ = bigbfr; *c_; c_++)
		{
			if (*c_ == '-')
				dash++;
			else
			{
				if (*c_ == ':' && dash)		*c_ = ' ';
				if (*c_ == ' ')
				{
					if (*d_)		d_ += 3;
					break;
				}
				if (ispunct(*c_) && *d_)	d_ += 3;
			}
		}

		if (*d_ && !dash)	d_ += 3;
		e_ = dash ? c_ : bigbfr;
		if (*c_ || !dash)
		{
			if (*c_ == ' ')		c_++;
			while (*c_ && *d_)
			{
				if (ispunct(*c_))	d_ += 3;
				c_++;
			}
			if (*d_) strcpy (c_, d_);
		}
		else		/* Default to midnight for time	*/
			strcpy (c_, zeros);

		/*
		 * Insert month (mmm) and year (yyyy) if omitted, since
		 * $BINTIM does not permit *gaps*, but only loss of significance.
		 */
		if (dash < 2)
		{
			char	time[sizeof(zeros)+2];
			strcpy (time, e_);
			*e_ = '\0';
			if (dash == 1)	/* dd-mmm given	*/
			{
				strncpy (e_, midbfr+6, 5);
				strcpy (e_+5, time);
			}
			else		/* dash==0, assume 'hh' of 'hh:mm' */
			{
				strcpy (bigbfr, midbfr);
				strcpy (bigbfr+12, time);
			}
		}

		DSCx.dsc$w_length  = strlen(bigbfr);

		if ((num = sys$bintim (&DSCx, obfr)) == SS$_NORMAL)	num = 0;
	}
	return (num);
}
예제 #5
0
int
gettimeofday (struct timeval *tp, void *tpz)
{
 long ret;
#ifdef __VAX
 long quad[2];
 long quad1[2];
 long div_100ns_to_secs;
 long div_100ns_to_usecs;
 long quo,rem;
 long quo1,rem1;
#else
 __int64 quad;
 __qdiv_t ans1,ans2;
#endif
/*
        In case of error, tv_usec = 0 and tv_sec = VMS condition code.
        The return from function is also set to -1.
        This is not exactly as per the manual page.
*/

 tp->tv_usec = 0;

#ifdef __VAX
 if (base_adjust[0]==0 && base_adjust[1]==0) {
#else
 if (base_adjust==0) { /* Need to determine epoch adjustment */
#endif
        ret=sys$bintim(&dscepoch,&base_adjust);
        if (1 != (ret &&1)) {
                tp->tv_sec = ret;
                return -1;
        }
 }

 ret=sys$gettim(&quad); /* Get VMS system time */
 if ((1 && ret) == 1) {
#ifdef __VAX
        quad[0] -= base_adjust[0]; /* convert to epoch offset */
        quad[1] -= base_adjust[1]; /* convert 2nd half of quadword */
        div_100ns_to_secs = DIV_100NS_TO_SECS;
        div_100ns_to_usecs = DIV_100NS_TO_USECS;
        lib$ediv(&div_100ns_to_secs,&quad,&quo,&rem);
        quad1[0] = rem;
        quad1[1] = 0L;
        lib$ediv(&div_100ns_to_usecs,&quad1,&quo1,&rem1);
        tp->tv_sec = quo; /* Whole seconds */
        tp->tv_usec = quo1; /* Micro-seconds */
#else
        quad -= base_adjust; /* convert to epoch offset */
        ans1=qdiv(quad,DIV_100NS_TO_SECS);
        ans2=qdiv(ans1.rem,DIV_100NS_TO_USECS);
        tp->tv_sec = ans1.quot; /* Whole seconds */
        tp->tv_usec = ans2.quot; /* Micro-seconds */
#endif
 } else {
        tp->tv_sec = ret;
        return -1;
 }
# ifdef VMSISH_TIME
# ifdef RTL_USES_UTC
  if (VMSISH_TIME) tp->tv_sec = _toloc(tp->tv_sec);
# else
  if (!VMSISH_TIME) tp->tv_sec = _toutc(tp->tv_sec);
# endif
# endif
 return 0;
}
#endif


 /* Do not use H A S _ N A N O S L E E P
  * so that Perl Configure doesn't scan for it.
  * The TIME_HIRES_NANOSLEEP is set by Makefile.PL. */
#if !defined(HAS_USLEEP) && defined(TIME_HIRES_NANOSLEEP)
#define HAS_USLEEP
#define usleep hrt_unanosleep  /* could conflict with ncurses for static build */

void
hrt_unanosleep(unsigned long usec) /* This is used to emulate usleep. */
{
    struct timespec res;
    res.tv_sec = usec/1000/1000;
    res.tv_nsec = ( usec - res.tv_sec*1000*1000 ) * 1000;
    nanosleep(&res, NULL);
}

#endif /* #if !defined(HAS_USLEEP) && defined(TIME_HIRES_NANOSLEEP) */

#if !defined(HAS_USLEEP) && defined(HAS_SELECT)
#ifndef SELECT_IS_BROKEN
#define HAS_USLEEP
#define usleep hrt_usleep  /* could conflict with ncurses for static build */

void
hrt_usleep(unsigned long usec)
{
    struct timeval tv;
    tv.tv_sec = 0;
    tv.tv_usec = usec;
    select(0, (Select_fd_set_t)NULL, (Select_fd_set_t)NULL,
		(Select_fd_set_t)NULL, &tv);
}
#endif
#endif /* #if !defined(HAS_USLEEP) && defined(HAS_SELECT) */

#if !defined(HAS_USLEEP) && defined(WIN32)
#define HAS_USLEEP
#define usleep hrt_usleep  /* could conflict with ncurses for static build */

void
hrt_usleep(unsigned long usec)
{
    long msec;
    msec = usec / 1000;
    Sleep (msec);
}
예제 #6
0
Boolean Process::getCreationDate (CIMDateTime & d)
const
{
    long status;
    long dst_desc[2];
    char cimtime[80] = "";
    char log_string[] = "SYS$TIMEZONE_DAYLIGHT_SAVING";
    char libdst;
    unsigned __int64 bintime = 0;
    unsigned short int timbuf[7];
    unsigned long libop;
    unsigned long libdayweek;
    unsigned long libdayear;
    unsigned int retlen;
    struct tm timetm;
    struct tm *ptimetm = &timetm;

    // Added to get system uptime for SWAPPER process - PTR 73-51-29
    long item = SYI$_BOOTTIME;
    char t_string[24] = "";
    unsigned __int64  val = 0;
    struct dsc$descriptor_s sysinfo;

    sysinfo.dsc$b_dtype = DSC$K_DTYPE_T;
    sysinfo.dsc$b_class = DSC$K_CLASS_S;
    sysinfo.dsc$w_length = sizeof (t_string);
    sysinfo.dsc$a_pointer = t_string;

    static $DESCRIPTOR (lnm_tbl, "LNM$SYSTEM");
    struct
    {
        unsigned short wLength;
        unsigned short wCode;
        void *pBuffer;
        unsigned int *pRetLen;
        int term;
    } dst_item_list;

    bintime = pInfo.p_stime;

    libop = LIB$K_DAY_OF_WEEK;
    status = lib$cvt_from_internal_time (&libop, &libdayweek, &bintime);
    if (!$VMS_STATUS_SUCCESS (status))
    {
        return false;
    }

    libop = LIB$K_DAY_OF_YEAR;
    status = lib$cvt_from_internal_time (&libop, &libdayear, &bintime);
    if (!$VMS_STATUS_SUCCESS (status))
    {
        return false;
    }

    dst_desc[0] = strlen (log_string);
    dst_desc[1] = (long) log_string;
    dst_item_list.wLength = 1;
    dst_item_list.wCode = LNM$_STRING;
    dst_item_list.pBuffer = &libdst;
    dst_item_list.pRetLen = &retlen;
    dst_item_list.term = 0;

    status = sys$trnlnm (0, &lnm_tbl, &dst_desc, 0, &dst_item_list);
    if (!$VMS_STATUS_SUCCESS (status))
    {
        return false;
    }

    //  Added to get sysuptime for SWAPPER process --- PTR 73-51-29
    if (bintime == 0)
    {
        status = lib$getsyi(&item, 0, &sysinfo, &val, 0, 0);
        status = sys$bintim(&sysinfo, &bintime);
    }

    status = sys$numtim (timbuf, &bintime);
    if (!$VMS_STATUS_SUCCESS (status))
    {
        return false;
    }

    timetm.tm_sec = timbuf[5];
    timetm.tm_min = timbuf[4];
    timetm.tm_hour = timbuf[3];
    timetm.tm_mday = timbuf[2];
    timetm.tm_mon = timbuf[1] - 1;
    timetm.tm_year = timbuf[0] - 1900;
    timetm.tm_wday = libdayweek - 1;
    timetm.tm_yday = libdayear - 1;
    timetm.tm_isdst = 0;
    if (libdst != 48)
    {
        timetm.tm_isdst = 1;
    }
    timetm.tm_gmtoff = -18000;
    timetm.tm_zone = "EST";

    if (convertToCIMDateString (ptimetm, cimtime) != -1)
    {
        d = CIMDateTime (cimtime);
        return true;
    }
    return false;
}
예제 #7
0
pwr_tUInt32 bck_WaitBackup (
		void *context,
		pwr_tBoolean timeout)
{
  pwr_tUInt32 sts;
  pwr_tObjid objid;
  pwr_tInt32 c;
  pwr_tTime t;
  pwr_tVaxTime tmo;
  pwr_tVaxTime tmptime;
  pwr_sClass_Backup_Conf *backup_confp;	/* Backup_Conf object pointer */
  $DESCRIPTOR (timeunitdsc, "0 0:0:0.1");	/* 0.1 second units */
  int cycletime;

#ifdef OS_ELN
  pwr_tInt32 res;
  pwr_tVaxTime *tmop;
#endif

#ifdef OS_VMS
  $DESCRIPTOR (efcname, BCK_EFC_NAME);
#endif

/*
 * Initialize
 */

#ifdef OS_ELN
  if (!areas_mapped) {
    BCK_MAP_AREAS;
    areas_mapped = TRUE;
  }
#endif

/*
 * Find the local Backup_Conf object
 */

  sts = gdh_GetClassList (pwr_cClass_Backup_Conf, &objid);
  while (ODD (sts)) {
    sts = gdh_ObjidToPointer (objid, (pwr_tAddress *)&backup_confp);
    if (ODD (sts)) break;
    sts = gdh_GetNextObject (objid, &objid);
  }
  if (EVEN (sts)) return sts;		/* Something wrong, quit */

/*
 * Pick up argument information
 */

  if (context == NULL) time_GetTime(&t);
  else {
    t = *(pwr_tTime *)context;
    free (context);
  }

#ifdef OS_ELN
  tmop = NULL;
#else
  timed_out = FALSE;  
  sts = sys$ascefc (BCK_EFC, &efcname, 0, 0);
  if (EVEN (sts)) lib$signal (sts);			/* BUG */
#endif

  if (timeout) {
    cycletime = backup_confp->CycleSlow * 2;
    if (cycletime == 0) cycletime = BCK_DEFAULT_SLOW * 2;

#ifdef OS_ELN
    tmo = eln$time_value (&timeunitdsc);
#else
    sts = sys$bintim (&timeunitdsc, &tmo);
    if (EVEN (sts)) lib$signal (sts);		/* BUG, should not happen */
#endif

    lib$mult_delta_time (
		&cycletime,		/* multiplier */
		&tmo);			/* delta_time (modified) */
    sys$gettim (&tmptime);
    lib$add_times (&tmo, &tmptime, &tmo); /* Make absolute time */

#ifdef OS_ELN
    tmop = &tmo;
#else
    sts = sys$setimr (BCK_WRITE_DONE, &tmo, &astrtn, 4711, 0);
    if (EVEN (sts)) lib$signal (sts);			/* BUG */
#endif
  }

/*
 * Loop, and wait for things to happen
 */

  while (TRUE) {
#ifdef OS_ELN
    ker$clear_event (NULL, bck_write_done);
    ker$wait_any (NULL, &res, tmop, bck_write_done);

    /* Check for timeout */

    if (res == 0) return SS$_TIMEOUT;
#else

    sts = sys$clref (BCK_WRITE_DONE);
    if (EVEN (sts)) lib$signal (sts);			/* BUG */
    sts = sys$waitfr (BCK_WRITE_DONE);
    if (EVEN (sts)) lib$signal (sts);			/* BUG */

    /* Check for timeout */

    if (timed_out) return SS$_TIMEOUT;

#endif

    /* Check if both cycles done */

    if (time_Acomp(&backup_confp->ObjTimeSlow, &t) < 0) 
        continue;
    if (time_Acomp(&backup_confp->ObjTimeFast, &t) < 0) 
        continue;

    break;

  } /* Loop */

#ifdef OS_VMS
  sys$cantim (4711, 0);
#endif

  return 1;	/* Done. */

} /* bck_WaitBackup */
예제 #8
0
파일: rltime.cpp 프로젝트: 376473984/pvb
void rlTime::setLocalTime()
{
#ifdef RLUNIX
  struct timeval tv;
  struct tm t;

  t.tm_mday  = day;
  t.tm_mon   = month - 1;
  t.tm_year  = year - 1900;
  t.tm_hour  = hour;
  t.tm_min   = minute;
  t.tm_sec   = second;
  tv.tv_sec  = mktime(&t);
  tv.tv_usec = 1000 * millisecond;
  settimeofday(&tv,NULL);
#endif

#ifdef __VMS
  VAX_BIN_TIME vbt;
  struct dsc$descriptor_s  d_time;
  char smonth[12][4],buf[64];

  // Initialize month array
  memset (smonth   , 0, sizeof(smonth));
  memcpy (smonth  [0], "JAN", 3);
  memcpy (smonth  [1], "FEB", 3);
  memcpy (smonth  [2], "MAR", 3);
  memcpy (smonth  [3], "APR", 3);
  memcpy (smonth  [4], "MAY", 3);
  memcpy (smonth  [5], "JUN", 3);
  memcpy (smonth  [6], "JUL", 3);
  memcpy (smonth  [7], "AUG", 3);
  memcpy (smonth  [8], "SEP", 3);
  memcpy (smonth  [9], "OCT", 3);
  memcpy (smonth [10], "NOV", 3);
  memcpy (smonth [11], "DEC", 3);
  // Create time buffer
  sprintf(buf, "%02d-%3.3s-%04d %02d:%02d:%02d.%02d",
                day,
                smonth[month-1],
                year,
                hour,
                minute,
                second,
                millisecond / 10);

  // Fill string descriptor
  d_time.dsc$w_length  = strlen(buf);
  d_time.dsc$b_dtype   = DSC$K_DTYPE_T;
  d_time.dsc$b_class   = DSC$K_CLASS_S;
  d_time.dsc$a_pointer = buf;
  // Convert time buf to VAX bin time
  sys$bintim(&d_time, &vbt);
  // Set the system time
  sys$setime(&vbt);
#endif

#ifdef RLWIN32
  SYSTEMTIME st;
  st.wDay          = day;
  st.wMonth        = month;
  st.wYear         = year;
  st.wHour         = hour;
  st.wMinute       = minute;
  st.wSecond       = second;
  st.wMilliseconds = millisecond;
  SetSystemTime(&st);
#endif
}
예제 #9
0
파일: dns.c 프로젝트: SysMan-One/netlib
/*
**++
**  ROUTINE:	netlib___dns_init
**
**  FUNCTIONAL DESCRIPTION:
**
**  	Initializes an internal DNS resolver context.
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	netlib___dns_init(struct CTX *ctx)
**
**  ctx:    NETLIB context, modify, by reference.
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:	See code.
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib___dns_init (struct CTX *ctx) {

    struct DOMAIN *dom;
    unsigned int status;
    ITMLST lnmlst[3];
    int i, maxidx;
    unsigned int size;
    unsigned short buflen;
    char buf[256];
    int did_tmo;

    static unsigned int socktype = NETLIB_K_TYPE_DGRAM;
    static unsigned int ctxsize = sizeof(struct DNSCTX);
    static $DESCRIPTOR(tabnam, "LNM$FILE_DEV");
    static $DESCRIPTOR(lognam, "NETLIB_SEARCH_DOMAIN");
    static $DESCRIPTOR(tmolnm, "NETLIB_DNS_QUERY_TIMEOUT");

/*
**  Allocate the DNS resolver context
*/
    status = lib$get_vm(&ctxsize, &ctx->dnsctx);
    if (!OK(status)) return status;

    INIT_QUEUE(ctx->dnsctx->nsq);
    INIT_QUEUE(ctx->dnsctx->domq);

/*
**  Get the list of name servers we're supposed to contact
*/
    if (netlib___get_nameservers(&ctx->dnsctx->nsq) == 0) {
    	lib$free_vm(&ctxsize, &ctx->dnsctx);
    	ctx->dnsctx = 0;
    	ctx->flags |= CTX_M_NO_DNS;
    	return SS$_UNSUPPORTED;
    }

/*
**  Get the list of NETLIB search domains, or the package-specific
**  ones.
*/
    ITMLST_INIT(lnmlst[0], LNM$_MAX_INDEX, sizeof(maxidx), &maxidx, 0);
    ITMLST_INIT(lnmlst[1], 0, 0, 0, 0);
    if (OK(sys$trnlnm(0, &tabnam, &lognam, 0, lnmlst))) {
    	ITMLST_INIT(lnmlst[0], LNM$_INDEX, sizeof(i), &i, 0);
    	ITMLST_INIT(lnmlst[1], LNM$_STRING, sizeof(buf), buf, &buflen);
    	ITMLST_INIT(lnmlst[2], 0, 0, 0, 0);
    	for (i = 0; i <= maxidx; i++) {
    	    if (OK(sys$trnlnm(0, &tabnam, &lognam, 0, lnmlst)) && buflen != 0) {
    	    	size = buflen + sizeof(struct DOMAIN);
    	    	if (OK(lib$get_vm(&size, &dom))) {
    	    	    dom->length = buflen;
    	    	    memcpy(dom->name, buf, buflen);
    	    	    dom->name[buflen] = '\0';
    	    	    queue_insert(dom, ctx->dnsctx->domq.tail);
    	    	}
    	    }
    	}
    } else if (netlib___get_domain(buf, sizeof(buf), &buflen)) {
    	char *cp, *cp1;
    	int remain;

    	cp = buf;
    	remain = buflen;
/*
**  A search domain must have at least two parts, to avoid the ".com.edu"
**  problem, which is why we check to make sure that the remaining domain
**  string has at least one dot.
*/
    	while (remain > 0) {
    	    cp1 = memchr(cp, '.', remain);
    	    if (cp1 == 0) break;
    	    size = remain + sizeof(struct DOMAIN);
    	    if (OK(lib$get_vm(&size, &dom))) {
    	    	dom->length = remain;
    	    	memcpy(dom->name, cp, remain);
    	    	dom->name[remain] = '\0';
    	    	queue_insert(dom, ctx->dnsctx->domq.tail);
    	    }
    	    remain -= (cp1 - cp) + 1;
    	    cp = cp1 + 1;
    	}
    }

    did_tmo = 0;
    ITMLST_INIT(lnmlst[0], LNM$_STRING, sizeof(buf), buf, &buflen);
    ITMLST_INIT(lnmlst[1], 0, 0, 0, 0);
    if (OK(sys$trnlnm(0, &tabnam, &tmolnm, 0, lnmlst))) {
        struct dsc$descriptor dsc;
        INIT_SDESC(dsc, buflen, buf);
        /*
         *  Make sure it's a delta time value
         */
        if (OK(sys$bintim(&dsc, &ctx->dnsctx->timeout)))
            did_tmo = (int) ctx->dnsctx->timeout.long2 < 0;
    }
    if (!did_tmo)
        sys$bintim(&default_timeout, &ctx->dnsctx->timeout);
            
    ctx->dnsctx->retry_count = 4;

    return SS$_NORMAL;

} /* netlib___dns_init */    
예제 #10
0
static unsigned long
get_time (struct dsc$descriptor_s *qual, char *timearg)
{
/*
**  Routine:    get_time
**
**  Function:   This routine reads the argument string of the qualifier
**              "qual" that should be a VMS syntax date-time string.  The
**              date-time string is converted into the standard format
**              "mmddyyyy", specifying an absolute date.  The converted
**              string is written into the 9 bytes wide buffer "timearg".
**
**  Formal parameters:
**
**      qual    - Address of descriptor for the qualifier name
**      timearg - Address of a buffer carrying the 8-char time string returned
**
*/

    register unsigned long status;
    struct dsc$descriptor_d time_str;
    struct quadword {
        long high;
        long low;
    } bintimbuf = {0,0};
#ifdef __DECC
#pragma member_alignment save
#pragma nomember_alignment
#endif  /* __DECC */
    struct tim {
        short year;
        short month;
        short day;
        short hour;
        short minute;
        short second;
        short hundred;
    } numtimbuf;
#ifdef __DECC
#pragma member_alignment restore
#endif

    init_dyndesc(time_str);

    status = cli$get_value(qual, &time_str);
    /*
    **  If a date is given, convert it to 64-bit binary.
    */
    if (time_str.dsc$w_length) {
        status = sys$bintim(&time_str, &bintimbuf);
        if (!(status & 1)) return (status);
        str$free1_dx(&time_str);
    }
    /*
    **  Now call $NUMTIM to get the month, day, and year.
    */
    status = sys$numtim(&numtimbuf, (bintimbuf.low ? &bintimbuf : NULL));
    /*
    **  Write the "mmddyyyy" string to the return buffer.
    */
    if (!(status & 1)) {
        *timearg = '\0';
    } else {
        sprintf(timearg, "%02d%02d%04d", numtimbuf.month,
                numtimbuf.day, numtimbuf.year);
    }
    return (status);
}
예제 #11
0
Boolean ComputerSystem::getInstallDate(CIMProperty& p)
{
   int status, istr;
   char record1[512], *rptr1=0;
   FILE *fptr1=0;
   unsigned __int64 bintime=0;
   unsigned short int timbuf[7], val=0;
   char cimtime[80]="";
   struct tm timetm;
   struct tm *ptimetm=&timetm;
   time_t tme=0, tme1=0;
   char t_string[24]="", libdst;
   unsigned int retlen;
   unsigned long libop, libdayweek, libdayear;
   long dst_desc[2];
   char log_string[]="SYS$TIMEZONE_DAYLIGHT_SAVING";
   struct dsc$descriptor_s sysinfo;
   static $DESCRIPTOR(lnm_tbl,"LNM$SYSTEM");
   struct {
        unsigned short wLength;
        unsigned short wCode;
        void*    pBuffer;
        unsigned int* pRetLen;
        int term;
        } item_list;

   sysinfo.dsc$b_dtype=DSC$K_DTYPE_T;
   sysinfo.dsc$b_class=DSC$K_CLASS_S;
   sysinfo.dsc$w_length=sizeof(t_string);
   sysinfo.dsc$a_pointer=t_string;

   status = system("pipe product show history openvms | search/nolog/nowarn/out=history.out sys$input install");
   if (!$VMS_STATUS_SUCCESS(status)) return false;

   if (fptr1 = fopen("history.out", "r"))
   {
        while (fgets(record1, sizeof(record1), fptr1))
        {
           for (istr=0; istr<=(sizeof(record1)-4); istr++)
           {
                if ((rptr1 = strstr(record1+istr,"-")) && !strncmp(rptr1+4,"-",1)) break;
                rptr1 = 0;
           }
           if (rptr1)
           {
                time(&tme);
                tme1 = mktime(ptimetm);		/* get timezone */
		strcpy(t_string,rptr1-2);
                t_string[20]='.';
                t_string[21]='0';
                t_string[22]='0';
                t_string[23]='0';
		status = sys$bintim (&sysinfo, &bintime);
		if (!$VMS_STATUS_SUCCESS(status)) return false;

		libop=LIB$K_DAY_OF_WEEK;
		status=lib$cvt_from_internal_time (&libop,&libdayweek,&bintime);
		if (!$VMS_STATUS_SUCCESS(status)) return false;

		libop=LIB$K_DAY_OF_YEAR;
		status=lib$cvt_from_internal_time (&libop,&libdayear,&bintime);
		if (!$VMS_STATUS_SUCCESS(status)) return false;

		dst_desc[0]  = strlen(log_string);
		dst_desc[1]  = (long) log_string;
		item_list.wLength = 1;
		item_list.wCode = LNM$_STRING;
		item_list.pBuffer = &libdst;
		item_list.pRetLen = &retlen;
		item_list.term =0;

		status = sys$trnlnm (0,&lnm_tbl,&dst_desc,0,&item_list);
		if (!$VMS_STATUS_SUCCESS(status)) return false;

		status = sys$numtim(timbuf,&bintime);
		if (!$VMS_STATUS_SUCCESS(status)) return false;

		timetm.tm_sec = timbuf[5];
		timetm.tm_min = timbuf[4];
		timetm.tm_hour = timbuf[3];
		timetm.tm_mday = timbuf[2];
		timetm.tm_mon = timbuf[1]-1;
		timetm.tm_year = timbuf[0]-1900;
		timetm.tm_wday = libdayweek-1;
		timetm.tm_yday = libdayear-1;
		timetm.tm_isdst = 0;
		if (libdst != 48) timetm.tm_isdst = 1;

		status = convertToCIMDateString(ptimetm,cimtime);
		if (!$VMS_STATUS_SUCCESS(status)) return false;

		CIMDateTime _installDate(cimtime);
		p = CIMProperty(PROPERTY_INSTALL_DATE, _installDate);
                fclose (fptr1);
                status = system("if (f$search(\"history.out\") .nes. \"\") then delete history.out;*");
                return true;
           } // end if (rptr1 = strstr(record1,"Install"))
        }
        fclose (fptr1);
        status = system("if (f$search(\"history.out\") .nes. \"\") then delete history.out;*");
        return false;
   } // end if (fptr1 = fopen(history.out, "r"))
   else
   {
        fclose (fptr1);
        status = system("if (f$search(\"history.out\") .nes. \"\") then delete history.out;*");
        return false;
   }
}
예제 #12
0
int VMSmunch(
    char  *filename,
    int   action,
    char  *ptr )
{

    /* original file.c variables */

    static struct FAB Fab;
    static struct NAM Nam;
    static struct fibdef Fib; /* short fib */

    static struct dsc$descriptor FibDesc =
      {sizeof(Fib),DSC$K_DTYPE_Z,DSC$K_CLASS_S,(char *)&Fib};
    static struct dsc$descriptor_s DevDesc =
      {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,&Nam.nam$t_dvi[1]};
    static struct fatdef Fat;
    static union {
      struct fchdef fch;
      long int dummy;
    } uchar;
    static struct fjndef jnl;
    static long int Cdate[2],Rdate[2],Edate[2],Bdate[2];
    static short int revisions;
    static unsigned long uic;
#if defined(__DECC) || defined(__DECCXX)
#pragma __member_alignment __save
#pragma __nomember_alignment
#endif /* __DECC || __DECCXX */
    static union {
      unsigned short int value;
      struct {
        unsigned system : 4;
        unsigned owner : 4;
        unsigned group : 4;
        unsigned world : 4;
      } bits;
    } prot;
#if defined(__DECC) || defined(__DECCXX)
#pragma __member_alignment __restore
#endif /* __DECC || __DECCXX */

    static struct atrdef Atr[] = {
      {sizeof(Fat),ATR$C_RECATTR,&Fat},        /* record attributes */
      {sizeof(uchar),ATR$C_UCHAR,&uchar},      /* File characteristics */
      {sizeof(Cdate),ATR$C_CREDATE,&Cdate[0]}, /* Creation date */
      {sizeof(Rdate),ATR$C_REVDATE,&Rdate[0]}, /* Revision date */
      {sizeof(Edate),ATR$C_EXPDATE,&Edate[0]}, /* Expiration date */
      {sizeof(Bdate),ATR$C_BAKDATE,&Bdate[0]}, /* Backup date */
      {sizeof(revisions),ATR$C_ASCDATES,&revisions}, /* number of revisions */
      {sizeof(prot),ATR$C_FPRO,&prot},         /* file protection  */
      {sizeof(uic),ATR$C_UIC,&uic},            /* file owner */
      {sizeof(jnl),ATR$C_JOURNAL,&jnl},        /* journal flags */
      {0,0,0}
    } ;

    static char EName[NAM$C_MAXRSS];
    static char RName[NAM$C_MAXRSS];
    static struct dsc$descriptor_s FileName =
      {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
    static struct dsc$descriptor_s string = {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
    static short int DevChan;
    static short int iosb[4];

    static long int i,status;
/*  static char *retval;  */


    /* new VMSmunch variables */

    static int  old_rtype=FAT$C_FIXED;   /* storage for record type */



/*---------------------------------------------------------------------------
    Initialize attribute blocks, parse filename, resolve any wildcards, and
    get the file info.
  ---------------------------------------------------------------------------*/

    /* initialize RMS structures, we need a NAM to retrieve the FID */
    Fab = cc$rms_fab;
    Fab.fab$l_fna = filename;
    Fab.fab$b_fns = strlen(filename);
    Fab.fab$l_nam = &Nam; /* FAB has an associated NAM */
    Nam = cc$rms_nam;
    Nam.nam$l_esa = EName; /* expanded filename */
    Nam.nam$b_ess = sizeof(EName);
    Nam.nam$l_rsa = RName; /* resultant filename */
    Nam.nam$b_rss = sizeof(RName);

    /* do $PARSE and $SEARCH here */
    status = sys$parse(&Fab);
    if (!(status & 1)) return(status);

    /* search for the first file.. If none signal error */
    status = sys$search(&Fab);
    if (!(status & 1)) return(status);

    while (status & 1) {
        /* initialize Device name length, note that this points into the NAM
           to get the device name filled in by the $PARSE, $SEARCH services */
        DevDesc.dsc$w_length = Nam.nam$t_dvi[0];

        status = sys$assign(&DevDesc,&DevChan,0,0);
        if (!(status & 1)) return(status);

        FileName.dsc$a_pointer = Nam.nam$l_name;
        FileName.dsc$w_length = Nam.nam$b_name+Nam.nam$b_type+Nam.nam$b_ver;

        /* Initialize the FIB */
        for (i=0;i<3;i++)
            Fib.FIB$W_FID[i]=Nam.nam$w_fid[i];
        for (i=0;i<3;i++)
            Fib.FIB$W_DID[i]=Nam.nam$w_did[i];

        /* Use the IO$_ACCESS function to return info about the file */
        /* Note, used this way, the file is not opened, and the expiration */
        /* and revision dates are not modified */
        status = sys$qiow(0,DevChan,IO$_ACCESS,&iosb,0,0,
                          &FibDesc,&FileName,0,0,&Atr,0);
        if (!(status & 1)) return(status);
        status = iosb[0];
        if (!(status & 1)) return(status);

    /*-----------------------------------------------------------------------
        We have the current information from the file:  now see what user
        wants done with it.
      -----------------------------------------------------------------------*/

        switch (action) {

          case GET_TIMES:
              asctim(((struct VMStimbuf *)ptr)->modtime, Cdate);
              asctim(((struct VMStimbuf *)ptr)->actime, Rdate);
              break;

          case SET_TIMES:
              bintim(((struct VMStimbuf *)ptr)->modtime, Cdate);
              bintim(((struct VMStimbuf *)ptr)->actime, Rdate);
              break;

          case GET_RTYPE:   /* non-modifying */
              *(int *)ptr = Fat.fat$v_rtype;
              return RMS$_NORMAL;     /* return to user */
              break;

          case CHANGE_RTYPE:
              old_rtype = Fat.fat$v_rtype;              /* save current one */
              if ((*(int *)ptr < FAT$C_UNDEFINED) ||
                  (*(int *)ptr > FAT$C_STREAMCR))
                  Fat.fat$v_rtype = FAT$C_STREAMLF;       /* Unix I/O happy */
              else
                  Fat.fat$v_rtype = *(int *)ptr;
              break;

          case RESTORE_RTYPE:
              Fat.fat$v_rtype = old_rtype;
              break;

          default:
              return SS$_BADPARAM;   /* anything better? */
        }

    /*-----------------------------------------------------------------------
        Go back and write modified data to the file header.
      -----------------------------------------------------------------------*/

        /* note, part of the FIB was cleared by earlier QIOW, so reset it */
        Fib.FIB$L_ACCTL = FIB$M_NORECORD;
        for (i=0;i<3;i++)
            Fib.FIB$W_FID[i]=Nam.nam$w_fid[i];
        for (i=0;i<3;i++)
            Fib.FIB$W_DID[i]=Nam.nam$w_did[i];

        /* Use the IO$_MODIFY function to change info about the file */
        /* Note, used this way, the file is not opened, however this would */
        /* normally cause the expiration and revision dates to be modified. */
        /* Using FIB$M_NORECORD prohibits this from happening. */
        status = sys$qiow(0,DevChan,IO$_MODIFY,&iosb,0,0,
                          &FibDesc,&FileName,0,0,&Atr,0);
        if (!(status & 1)) return(status);

        status = iosb[0];
        if (!(status & 1)) return(status);

        status = sys$dassgn(DevChan);
        if (!(status & 1)) return(status);

        /* look for next file, if none, no big deal.. */
        status = sys$search(&Fab);
    }
    return(status);
} /* end function VMSmunch() */