コード例 #1
0
ファイル: lib_add_times.c プロジェクト: Rick33/freevms
unsigned long lib$add_times(const void *time1a, const void *time2a,
    void *result)
{
    const struct TIME* time1 = (const struct TIME*) time1a;
    const struct TIME* time2 = (const struct TIME*) time2a;

    if (time1->time[7] & 0x80)
    {
        if (time2->time[7] & 0x80)
	{
            return lib$addx(time1,time2,result,NULL);
        }
	else
	{
            return lib$subx(time2,time1,result,NULL);
        }
    }
    else
    {
        if (time2->time[7] & 0x80)
	{
            return lib$subx(time1,time2,result,NULL);
        }
	else
	{
            return LIB$_ONEDELTIM;
        }
    }
}
コード例 #2
0
static void
ualarm_AST(Alarm *a)
{
    int iss;
    unsigned long now[2];

    iss = sys$gettim(now);
    if (VMSERR(iss)) lib$signal(iss);

    if (a->function == UAL_SET || a->function == UAL_CLEAR) {
        if (a0->function == UAL_ACTIVE) {
            iss = sys$cantim(a0,PSL$C_USER);
            if (VMSERR(iss)) lib$signal(iss);

            iss = lib$subx(a0->remain, now, a->remain);
            if (VMSERR(iss)) lib$signal(iss);

            if (a->remain[1] & 0x80000000) 
                a->remain[0] = a->remain[1] = 0;
        }

        if (a->function == UAL_SET) {
            a->function = a0->function;
            a0->function = UAL_ACTIVE;
            a0->repeat = a->repeat;
            if (a0->repeat) {
                a0->interval[0] = a->interval[0];
                a0->interval[1] = a->interval[1];
            }
            a0->delay[0] = a->delay[0];
            a0->delay[1] = a->delay[1];

            iss = lib$subx(now, a0->delay, a0->remain);
            if (VMSERR(iss)) lib$signal(iss);

            iss = sys$setimr(0,a0->delay,ualarm_AST,a0);
            if (VMSERR(iss)) lib$signal(iss);
        } else {
            a->function = a0->function;
            a0->function = UAL_NULL;
        }
        iss = sys$setef(alarm_ef);
        if (VMSERR(iss)) lib$signal(iss);
    } else if (a->function == UAL_ACTIVE) {
        if (a->repeat) {
            iss = lib$subx(now, a->interval, a->remain);
            if (VMSERR(iss)) lib$signal(iss);

            iss = sys$setimr(0,a->interval,ualarm_AST,a);
            if (VMSERR(iss)) lib$signal(iss);
        } else {
            a->function = UAL_NULL;
        }
        iss = sys$wake(0,0);
        if (VMSERR(iss)) lib$signal(iss);
        lib$signal(SS$_ASTFLT);
    } else {
        lib$signal(SS$_BADPARAM);
    }
}
コード例 #3
0
ファイル: co_time_os.c プロジェクト: hfuhuang/proview
static pwr_tTime *
vms_to_abs (
  pwr_tStatus *status,
  pwr_tTime *tp,
  time_tOs *vt
)
{
  time_tOs tmp;
  time_tOs time;
  time_tOs ofs = {0x4beb4000, 0x007c9567};
  int divisor = 10000000;
  struct tm *tmpTm;
  unsigned long t = 0;

  pwr_dStatus(sts, status, TIME__SUCCESS);

  if (tp == NULL)
    tp = (pwr_tTime *) &time;

  *sts = lib$subx(vt, &ofs, &tmp);
  if (EVEN(*sts)) return NULL;
  *sts = lib$ediv(&divisor, &tmp, &tp->tv_sec, &tp->tv_nsec);
  if (EVEN(*sts)) return NULL;
  tp->tv_nsec *= 100;

  /* Get the time zone offset. */

  tmpTm = localtime(&tp->tv_sec);
  tp->tv_sec -= tmpTm->tm_gmtoff - tmpTm->tm_isdst * 3600;

  return tp;
}
コード例 #4
0
static void
us_to_VMS(useconds_t mseconds, unsigned long v[])
{
    int iss;
    unsigned long qq[2];

    qq[0] = mseconds;
    qq[1] = 0;
    v[0] = v[1] = 0;

    iss = lib$addx(qq,qq,qq);
    if (VMSERR(iss)) lib$signal(iss);
    iss = lib$subx(v,qq,v);
    if (VMSERR(iss)) lib$signal(iss);
    iss = lib$addx(qq,qq,qq);
    if (VMSERR(iss)) lib$signal(iss);
    iss = lib$subx(v,qq,v);
    if (VMSERR(iss)) lib$signal(iss);
    iss = lib$subx(v,qq,v);
    if (VMSERR(iss)) lib$signal(iss);
}
コード例 #5
0
ファイル: filevms.c プロジェクト: NeoAnomaly/xray
static void
file_cvttime( 
    unsigned int *curtime,
    time_t *unixtime )
{
    static const size_t divisor = 10000000;
    static unsigned int bastim[2] = { 0x4BEB4000, 0x007C9567 }; /* 1/1/1970 */
    int delta[2], remainder;

    lib$subx( curtime, bastim, delta );
    lib$ediv( &divisor, delta, unixtime, &remainder );
}
コード例 #6
0
ファイル: co_clock.c プロジェクト: hfuhuang/proview
int
clock_gettime (
  clockid_t		clockid,
  struct timespec	*pt
)
{
  unsigned long sts;
  pwr_tVaxTime vt;
  pwr_tVaxTime tmp;
  pwr_tVaxTime ofs = {0x4beb4000, 0x007c9567};
  int divisor = 10000000;
  struct tm	*tmpTm;
  unsigned long	t = 0;
 
  if (clockid != CLOCK_REALTIME) {
    errno = EINVAL;
    return -1;
  }

  sts = sys$gettim(&vt);

  sts = lib$subx(&vt, &ofs, &tmp);
  if (EVEN(sts)) {
    errno = sts;
    return -1;
  }
  sts = lib$ediv(&divisor, &tmp, &pt->tv_sec, &pt->tv_nsec);
  if (EVEN(sts)) {
    errno = sts;
    return -1;
  }

  pt->tv_nsec *= 100;

  tmpTm = localtime(&pt->tv_sec);
  pt->tv_sec -= tmpTm->tm_gmtoff - tmpTm->tm_isdst * 3600;

  return 0;
}
コード例 #7
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);
}
コード例 #8
0
ファイル: superint.cpp プロジェクト: Minerwwm/superint
superint superint::operator -(superint x)// -重载
{
    superint sub;
    superint t;
    t.strint=superint::strint;
    int mark=0,m1=1,m2=1;
    int n1,n2,n;
    n1=t.strint.length();
    n2=x.strint.length();
//倒置字符串
    convert(t.strint);
    convert(x.strint);
//检测是否为负数
    if(t.strint[n1-1]==45)
    {
        n1--;
        m1=-1;
        t.strint.resize(n1);//消除负号
    }
    if(x.strint[n2-1]==45)
    {
        n2--;
        m2=-1;
        x.strint.resize(n2);//消除负号
    }

    n=n1>n2?n1:n2;

//补齐字符串
    if(n==n1)
    {
        for(int i=0;i<n1-n2;i++) x.strint+="0";
    }
    else
    {
        for(int i=0;i<n2-n1;i++) t.strint+="0";
    }
//符号相同
    if(m1==m2)
    {
        superint subx("1");
        int x1,x2,tem;
        for(int i=0;i<n;i++)
        {
            x1=char_to_int(t.strint[i]);
            x2=char_to_int(x.strint[i]);
            tem=x1-x2+mark;
            if(tem<0)
            {
                mark=-1;
                tem+=10;
            }
            else mark=0;

            sub.strint+=int_to_char(tem);
        }
        remove0(sub.strint);
        convert(sub.strint);
        if(mark==-1)
        {
            int ti=sub.strint.length();
            for(int i=0;i<ti;i++) subx.strint+="0";
            sub=subx-sub;
            sub=-sub;
        }
        if(m1+m2==-2) sub=-sub;
    }
//符号相异
    convert(t.strint);
    convert(x.strint);
    if(m1>m2) sub=t+x;
    if(m1<m2)
    {
        sub=t+x;
        sub=-sub;
    }

    return sub;
}