Esempio n. 1
0
/*
**++
**  ROUTINE:	netlib___get_domain
**
**  FUNCTIONAL DESCRIPTION:
**
**  	Returns the DNS domain name for this host, either derived from the
**  logical name provided by UCX, or by picking apart the local host name.
**
**  RETURNS:	int
**
**  PROTOTYPE:
**
**  	NETLIB___GET_DOMAIN  buf, bufsize, retlen
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
int netlib___get_domain (char *buf, unsigned short bufsize, unsigned short *retlen) {

    struct dsc$descriptor dsc;
    ITMLST lnmlst[2];
    char name[256], *cp;
    unsigned short namlen;

    static $DESCRIPTOR(lognamdsc, "UCX$BIND_DOMAIN");
    static $DESCRIPTOR(lognamdsc_v5, "TCPIP$BIND_DOMAIN");
    static $DESCRIPTOR(tabnam, "LNM$FILE_DEV");

    ITMLST_INIT(lnmlst[0], LNM$_STRING, sizeof(name), name, &namlen);
    ITMLST_INIT(lnmlst[1], 0, 0, 0, 0);

    if (OK(sys$trnlnm(0, &tabnam, &lognamdsc_v5, 0, lnmlst)))
    	cp = name;
    else if (OK(sys$trnlnm(0, &tabnam, &lognamdsc, 0, lnmlst)))
    	cp = name;
    else {
    	INIT_SDESC(dsc, sizeof(name), name);
    	if (!OK(netlib_get_hostname(&dsc, &namlen))) return 0;
    	cp = memchr(name, '.', namlen);
    	if (cp == 0) return 0;
    	cp += 1;
    	namlen -= (cp - name);
    }

    if (memchr(cp, '.', namlen) == 0) return 0;
    if (namlen > bufsize-1) namlen = bufsize-1;
    memcpy(buf, cp, namlen);
    *retlen = namlen;

    return 1;

} /* netlib___get_domain */
std::string EnvironmentImpl::trnlnm(const std::string& name)
{
	#pragma pointer_size save
	#pragma pointer_size 32

	unsigned char result[LNM$C_NAMLENGTH];
	unsigned short length;
	
	ILE3 items[2];
	items[0].ile3$w_code         = LNM$_STRING;
	items[0].ile3$w_length       = sizeof(result);
	items[0].ile3$ps_bufaddr     = result;
	items[0].ile3$ps_retlen_addr = &length;
	items[1].ile3$w_code         = 0;
	items[1].ile3$w_length       = 0;

	#pragma pointer_size restore

	unsigned int trnAttr = LNM$M_CASE_BLIND;
	POCO_DESCRIPTOR_LITERAL(tableDsc, "LNM$FILE_DEV");
	POCO_DESCRIPTOR_STRING(nameDsc, name);
	if (sys$trnlnm(&trnAttr, &tableDsc, &nameDsc, 0, &items) == 1)
	{
		if (result[0] == 0x1B)
			return std::string((char*) result + 4, length - 4);
		else
			return std::string((char*) result, length);
	}
	else
	{
		return std::string();
	}
}
Esempio n. 3
0
/*
**++
**  ROUTINE:	netlib___get_nameservers
**
**  FUNCTIONAL DESCRIPTION:
**
**  	Obtains the list of DNS servers configured for this TCP/IP package.
**
**  RETURNS:	int
**
**  PROTOTYPE:
**
**  	NETLIB___GET_NAMESERVERS nsq
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
int netlib___get_nameservers (QUEUE *nsq) {

    struct NAMESERVER *ns;
    struct INADDRDEF a;
    struct CTX *tmpctx;
    struct dsc$descriptor dsc, lognamdsc;
    ITMLST lnmlst[2];
    char name[256], lognam[256], *cp, *anchor;
    unsigned int status, size, maxidx;
    unsigned short namlen;
    int index, i, remain;
    int v5, count;
    static unsigned int one = 1;

    tmpctx = 0;
    count = 0;

    ITMLST_INIT(lnmlst[0], LNM$_STRING, sizeof(name), name, &namlen);
    ITMLST_INIT(lnmlst[1], 0, 0, 0, 0);

    INIT_SDESC(lognamdsc, 0, lognam);

    for (v5 = 1; (count == 0) && (v5 >= 0); v5--) {
    	for (index = 0; index <= 16; index++) {
    	    lognamdsc.dsc$w_length = sprintf(lognam, (v5 == 0 ? "UCX$BIND_SERVER%03d" : "TCPIP$BIND_SERVER%03d"), index);
    	    status = sys$trnlnm(0, &nameserver_tabnam, &lognamdsc, 0, lnmlst);
    	    if (!OK(status) || namlen == 0) continue;
    	    for (anchor = name, remain = namlen; remain > 0;
    	    	    	    	    	remain -= i+1, anchor = cp+1) {
    	    	cp = memchr(anchor, ',', remain);
    	    	if (cp == 0) i = remain;
    	    	else i = cp - anchor;
    	    	INIT_SDESC(dsc, i, anchor);
    	    	if (!OK(netlib_strtoaddr(&dsc, &a))) {
    	    	    if (tmpctx == 0) {
    	    	    	if (!OK(netlib_socket(&tmpctx, 0, 0))) continue;
    	    	    }
    	    	    if (!OK(netlib_name_to_address(&tmpctx, 0, &dsc, &a, &one, 0,
    	    	    	    	0, 0, 0))) continue;
    	    	}
    	    	size = sizeof(struct NAMESERVER);
    	    	status = lib$get_vm(&size, &ns);
    	    	if (!OK(status)) break;
    	    	ns->addr = a;
    	    	queue_insert(ns, nsq->tail);
    	    	count += 1;
    	    }
    	}
    }

    if (tmpctx != 0) netlib_close(&tmpctx);
    return count;

} /* netlib___get_nameservers */
Esempio n. 4
0
String
osGetEnv(String envar)
{
	/*
	 * The string value returned is declared as being static, so
	 * successive calls to osGetEnv will overwrite this string. This is
	 * compatible with the semantics of the ANSI C getenv function.
	 */
	ULong		status;
	static char	equiv_buffer[LNM$C_NAMLENGTH + 1]; /* xlation of LNM */
	static UShort	equiv_length;		/* length of translated name */
	struct dsc$descriptor_s lognam;		/* logical name */
	ULong		attr;			/* LNM search attributes */
	$DESCRIPTOR(tabnam, "LNM$FILE_DEV");    /* L. name table search path */
	struct item_list_3 itmlst[] = {
		{LNM$C_NAMLENGTH, LNM$_STRING, equiv_buffer, &equiv_length},
		{0, 0, 0, 0}
	};

	lognam.dsc$a_pointer = envar;		/* string */
	lognam.dsc$w_length = strlen(envar);	/* string length (w/o null) */
	lognam.dsc$b_class = DSC$K_CLASS_S;	/* string descriptor */
	lognam.dsc$b_dtype = DSC$K_DTYPE_T;	/* ASCII string */

	attr = LNM$M_CASE_BLIND;/* ignore case in LNM searches */

	status = sys$trnlnm(
		&attr,		/* attributes */
		&tabnam,	/* LNM table(s) to search */
		&lognam,	/* logical name to translate */
		NULL,		/* acmode: ignore access mode */
		&itmlst);	/* information to return */

	if (status == SS$_NOLOGNAM) {
		equiv_length = 0;
		return NULL;
	}
	else if (!(status & 1))
		lib$signal(status, NULL);	/* report unexpected errors */

	equiv_buffer[equiv_length] = '\0';
	return equiv_buffer;
}
Esempio n. 5
0
Boolean ComputerSystem::getInitialLoadInfo(CIMProperty& p)
{
   long status, dst_desc[2];
   char log_string[]="SYS$SYSDEVICE";
   char res_string[256]="", *ptr1=0, *ptr2=0;
   unsigned int retlen;
   static $DESCRIPTOR(lnm_tbl,"LNM$SYSTEM");
   struct {
        unsigned short wLength;
        unsigned short wCode;
        void*    pBuffer;
        unsigned int* pRetLen;
        int term;
        } item_list;

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

   status = sys$trnlnm (0,&lnm_tbl,&dst_desc,0,&item_list);
   if ($VMS_STATUS_SUCCESS(status))
   {
	ptr1 = res_string;
	ptr2 = strchr(ptr1,':');
	if (ptr2) res_string[ptr2-ptr1] = '\0';
	p = CIMProperty(PROPERTY_INITIAL_LOAD_INFO, res_string);
	return true;
   }
   else
   {
	p = CIMProperty(PROPERTY_INITIAL_LOAD_INFO, "Unknown");
	return false;
   }
}
Esempio n. 6
0
struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
{
    struct tm *ts = NULL;

#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) && !defined(OPENSSL_SYS_MACOSX)
    /*
     * should return &data, but doesn't on some systems, so we don't even
     * look at the return value
     */
    gmtime_r(timer, result);
    ts = result;
#elif !defined(OPENSSL_SYS_VMS) || defined(VMS_GMTIME_OK)
    ts = gmtime(timer);
    if (ts == NULL)
        return NULL;

    memcpy(result, ts, sizeof(struct tm));
    ts = result;
#endif
#if defined( OPENSSL_SYS_VMS) && !defined( VMS_GMTIME_OK)
    if (ts == NULL) {
        static $DESCRIPTOR(tabnam, "LNM$DCL_LOGICAL");
        static $DESCRIPTOR(lognam, "SYS$TIMEZONE_DIFFERENTIAL");
        char logvalue[256];
        unsigned int reslen = 0;
        struct {
            short buflen;
            short code;
            void *bufaddr;
            unsigned int *reslen;
        } itemlist[] = {
            {
                0, LNM$_STRING, 0, 0
            },
            {
                0, 0, 0, 0
            },
        };
        int status;
        time_t t;

        /* Get the value for SYS$TIMEZONE_DIFFERENTIAL */
        itemlist[0].buflen = sizeof(logvalue);
        itemlist[0].bufaddr = logvalue;
        itemlist[0].reslen = &reslen;
        status = sys$trnlnm(0, &tabnam, &lognam, 0, itemlist);
        if (!(status & 1))
            return NULL;
        logvalue[reslen] = '\0';

        t = *timer;

/* The following is extracted from the DEC C header time.h */
        /*
         **  Beginning in OpenVMS Version 7.0 mktime, time, ctime, strftime
         **  have two implementations.  One implementation is provided
         **  for compatibility and deals with time in terms of local time,
         **  the other __utc_* deals with time in terms of UTC.
         */
        /*
         * We use the same conditions as in said time.h to check if we should
         * assume that t contains local time (and should therefore be
         * adjusted) or UTC (and should therefore be left untouched).
         */
# if __CRTL_VER < 70000000 || defined _VMS_V6_SOURCE
        /* Get the numerical value of the equivalence string */
        status = atoi(logvalue);

        /* and use it to move time to GMT */
        t -= status;
# endif

        /* then convert the result to the time structure */

        /*
         * Since there was no gmtime_r() to do this stuff for us, we have to
         * do it the hard way.
         */
        {
            /*-
             * The VMS epoch is the astronomical Smithsonian date,
               if I remember correctly, which is November 17, 1858.
               Furthermore, time is measure in tenths of microseconds
               and stored in quadwords (64 bit integers).  unix_epoch
               below is January 1st 1970 expressed as a VMS time.  The
               following code was used to get this number:

               #include <stdio.h>
               #include <stdlib.h>
               #include <lib$routines.h>
               #include <starlet.h>

               main()
               {
                 unsigned long systime[2];
                 unsigned short epoch_values[7] =
                   { 1970, 1, 1, 0, 0, 0, 0 };

                 lib$cvt_vectim(epoch_values, systime);

                 printf("%u %u", systime[0], systime[1]);
               }
            */
            unsigned long unix_epoch[2] = { 1273708544, 8164711 };
            unsigned long deltatime[2];
            unsigned long systime[2];
            struct vms_vectime {
                short year, month, day, hour, minute, second, centi_second;
            } time_values;
            long operation;

            /*
             * Turn the number of seconds since January 1st 1970 to an
             * internal delta time. Note that lib$cvt_to_internal_time() will
             * assume that t is signed, and will therefore break on 32-bit
             * systems some time in 2038.
             */
            operation = LIB$K_DELTA_SECONDS;
            status = lib$cvt_to_internal_time(&operation, &t, deltatime);

            /*
             * Add the delta time with the Unix epoch and we have the current
             * UTC time in internal format
             */
            status = lib$add_times(unix_epoch, deltatime, systime);

            /* Turn the internal time into a time vector */
            status = sys$numtim(&time_values, systime);

            /* Fill in the struct tm with the result */
            result->tm_sec = time_values.second;
            result->tm_min = time_values.minute;
            result->tm_hour = time_values.hour;
            result->tm_mday = time_values.day;
            result->tm_mon = time_values.month - 1;
            result->tm_year = time_values.year - 1900;

            operation = LIB$K_DAY_OF_WEEK;
            status = lib$cvt_from_internal_time(&operation,
                                                &result->tm_wday, systime);
            result->tm_wday %= 7;

            operation = LIB$K_DAY_OF_YEAR;
            status = lib$cvt_from_internal_time(&operation,
                                                &result->tm_yday, systime);
            result->tm_yday--;

            result->tm_isdst = 0; /* There's no way to know... */

            ts = result;
        }
    }
#endif
    return ts;
}
Esempio n. 7
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;
}
Esempio n. 8
0
void
ttinit (void)
{
  char *t, *p;
  char *tv_stype;
  int cinsl;			/* cost of inserting a line     */
  int cdell;			/* cost of deleting a line      */
  int i;
#ifdef	XKEYS
  char kname[3], lname[3];
#endif

#ifdef	VAXC
  if ((tv_stype = trnlnm ("TERM")) == NULL)
#else
  if ((tv_stype = getenv ("TERM")) == NULL)	/* Don't want VAX C getenv() */
#endif
    panic ("Environment variable TERM not defined!");

  /* If -m flag (mouse reporting) is enabled and we're running
   * on an xterm, enable X10-compatible mouse button press reporting.
   */
  if (mouse && (strncmp (tv_stype, "xterm", 5) == 0))
    {
      xterm_mouse = TRUE;
      ttputs ("\033[?9h", 5);
    }

  if ((tgetent (tcbuf, tv_stype)) != 1)
    {
      strcpy (tcbuf, "Unknown terminal type ");
      strcat (tcbuf, tv_stype);
      panic (tcbuf);
    }

  p = tcapbuf;
  t = tgetstr ("pc", &p);
  if (t)
    PC = *t;

  LI = tgetnum ("li");
  CD = tgetstr ("cd", &p);
  CM = tgetstr ("cm", &p);
  CE = tgetstr ("ce", &p);
  UP = tgetstr ("up", &p);
  BC = tgetstr ("bc", &p);
  IM = tgetstr ("im", &p);
  IC = tgetstr ("ic", &p);
  EI = tgetstr ("ei", &p);
  DC = tgetstr ("dc", &p);
  AL = tgetstr ("al", &p);
  DL = tgetstr ("dl", &p);
  pAL = tgetstr ("AL", &p);	/* parameterized insert and del. line */
  pDL = tgetstr ("DL", &p);
  TI = tgetstr ("ti", &p);
  TE = tgetstr ("te", &p);
  SO = tgetstr ("so", &p);
  SE = tgetstr ("se", &p);
  CS = tgetstr ("cs", &p);	/* set scrolling region */
  SR = tgetstr ("sr", &p);
  SG = tgetnum ("sg");		/* standout glitch      */
#ifdef	XKEYS
  /* get the 10 standard termcap keys */
  strcpy (kname, "kx");
  strcpy (lname, "lx");
  for (i = 0; i < 10; i++)
    {
      kname[1] = i + '1';
      K[i] = tgetstr (kname, &p);
      lname[1] = i + '1';
      L[i] = tgetstr (lname, &p);
    }
  /* Hack to get another bunch */
  strcpy (kname, "Kx");
  strcpy (lname, "Lx");
  for (i = 0; i < 10; i++)
    {
      kname[1] = i + '1';
      K[10 + i] = tgetstr (kname, &p);
      lname[1] = i + '1';
      L[10 + i] = tgetstr (lname, &p);
    }

  /* Get the rest of the sequences */
  KS = tgetstr ("ks", &p);
  KE = tgetstr ("ke", &p);
  KH = tgetstr ("kh", &p);
  KU = tgetstr ("ku", &p);
  KD = tgetstr ("kd", &p);
  KL = tgetstr ("kl", &p);
  KR = tgetstr ("kr", &p);
#endif

  if (CM == NULL || UP == NULL)
    panic ("This terminal is to stupid to run MicroGnuEmacs\n");
  ttresize ();			/* set nrow & ncol      */

  /* watch out for empty capabilities (sure to be wrong)  */
  if (CE && !*CE)
    CE = NULL;
  if (CS && !*CS)
    CS = NULL;
  if (SR && !*SR)
    SR = NULL;
  if (AL && !*AL)
    AL = NULL;
  if (DL && !*DL)
    DL = NULL;
  if (pAL && !*pAL)
    pAL = NULL;
  if (pDL && !*pDL)
    pDL = NULL;
  if (CD && !*CD)
    CD = NULL;

  if (!CE)
    tceeol = ncol;
  else
    tceeol = charcost (CE);

  /* Estimate cost of inserting a line */
  if (CS && SR)
    cinsl = charcost (CS) * 2 + charcost (SR);
  else if (pAL)
    cinsl = charcost (pAL);
  else if (AL)
    cinsl = charcost (AL);
  else
    cinsl = NROW * NCOL;	/* make this cost high enough */


  /* MicroEMACS requires an array of costs, not just a single value.
   * Fill the array with a single value.
   */
  for (i = 0; i <= NROW; i++)
    tcinsl[i] = 20 * cinsl * (i + 1);

  /* Estimate cost of deleting a line */
  if (CS)
    cdell = charcost (CS) * 2 + 1;
  else if (pDL)
    cdell = charcost (pDL);
  else if (DL)
    cdell = charcost (DL);
  else
    cdell = NROW * NCOL;	/* make this cost high enough */

  /* MicroEMACS requires an array of costs, not just a single value.
   * Fill the array with a single value.
   */
  for (i = 0; i <= NROW; i++)
    tcdell[i] = 20 * cdell * (i + 1);

  /* Flag to indicate that we can both insert and delete lines */
  insdel = (AL || pAL) && (DL || pDL);

  if (p >= &tcapbuf[TCAPSLEN])
    panic ("Terminal description too big!\n");
  if (TI && *TI)
    putpad (TI);		/* init the term */
}
Esempio n. 9
0
Boolean Process::getCreationDate (CIMDateTime & d)
  const
  {
    long status,
      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,
      libdayweek,
      libdayear;
    unsigned int retlen;
    struct tm timetm;
    struct tm *ptimetm = &timetm;
    static $DESCRIPTOR (lnm_tbl, "LNM$SYSTEM");
    struct
    {
      unsigned short wLength;
      unsigned short wCode;
      void *pBuffer;
      unsigned int *pRetLen;
      int term;
    }
    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;
    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;
    }
    timetm.tm_gmtoff = -18000;
    timetm.tm_zone = "EST";

    if (convertToCIMDateString (ptimetm, cimtime) != -1)
    {
      d = CIMDateTime (cimtime);
      return true;
    }
    return false;
  }
Esempio n. 10
0
/*
**++
**  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 */    
Esempio n. 11
0
void op_fnztrnlnm(mval *name,mval *table,int4 ind,mval *mode,mval *case_blind,mval *item,mval *ret)
{
	struct dsc$descriptor	lname, ltable;
	uint4		attribute, status, retlen, mask, full_mask;
	char			acmode;
	short int		*item_code, pass, index;
	bool			full;
	char			buff[256], result[MAX_RESULT_SIZE];
	char			i, slot, last_slot;
	char			def_table[] = "LNM$DCL_LOGICAL";

	struct
	{
		item_list_3	item[3];
		int4		terminator;
	} item_list;
	error_def(ERR_BADTRNPARAM);

	if(!name->str.len || MAX_LOGNAM_LENGTH < name->str.len || MAX_LOGNAM_LENGTH < table->str.len)
		rts_error(VARLSTCNT(1) SS$_IVLOGNAM);
	memset(&item_list,0,SIZEOF(item_list));
	item_list.item[0].item_code = 0;
	item_list.item[0].buffer_address = result;
	item_list.item[0].buffer_length = MAX_RESULT_SIZE;
	item_list.item[0].return_length_address = &retlen;
	item_code = &item_list.item[0].item_code;

	lname.dsc$w_length = name->str.len;
	lname.dsc$a_pointer = name->str.addr;
	lname.dsc$b_dtype = DSC$K_DTYPE_T;
	lname.dsc$b_class = DSC$K_CLASS_S;

	if (table->str.len)
	{	ltable.dsc$w_length = table->str.len;
		ltable.dsc$a_pointer = table->str.addr;
	}else
	{	ltable.dsc$a_pointer = def_table;
		ltable.dsc$w_length = strlen(def_table);
	}
	ltable.dsc$b_dtype = DSC$K_DTYPE_T;
	ltable.dsc$b_class = DSC$K_CLASS_S;

	if(ind)
	{	item_list.item[0].item_code = LNM$_INDEX;
		item_list.item[0].buffer_address = &ind;
		item_list.item[1].item_code = 0;
		item_list.item[1].buffer_address = result;
		item_list.item[1].buffer_length = MAX_RESULT_SIZE;
		item_list.item[1].return_length_address = &retlen;
		item_code = &item_list.item[1].item_code;
	}

	attribute = LNM$M_CASE_BLIND;
	if (case_blind->str.len)
	{
		if (case_blind->str.len > 14)
			rts_error(VARLSTCNT(4) ERR_BADTRNPARAM, 2,
				MIN(SHRT_MAX, case_blind->str.len), case_blind->str.addr);
		lower_to_upper(buff,case_blind->str.addr,case_blind->str.len);
		if (case_blind->str.len == 14 && !memcmp(buff,"CASE_SENSITIVE",14))
			attribute = 0;
		else if (case_blind->str.len != 10 || memcmp(buff,"CASE_BLIND",10))
			rts_error(VARLSTCNT(4) ERR_BADTRNPARAM,2,case_blind->str.len,case_blind->str.addr);
	}

	acmode = NOVALUE;
	if (mode->str.len)
	{
		if (mode->str.len > 14)
			rts_error(VARLSTCNT(4) ERR_BADTRNPARAM, 2,
				MIN(SHRT_MAX, mode->str.len), mode->str.addr);
		lower_to_upper(buff,mode->str.addr,mode->str.len);
		switch (buff[0])
		{
		case 'U':
			if ( mode->str.len = 4 && !memcmp(buff, "USER", 4))
				acmode = PSL$C_USER;
		case 'S':
			if ( mode->str.len = 10 && !memcmp(buff, "SUPERVISOR", 10))
				acmode = PSL$C_SUPER;
		case 'K':
			if ( mode->str.len = 6 && !memcmp(buff, "KERNEL", 6))
				acmode = PSL$C_KERNEL;
		case 'E':
			if ( mode->str.len = 9 && !memcmp(buff, "EXECUTIVE", 9))
				acmode = PSL$C_EXEC;
		}
		if (acmode == NOVALUE)
			rts_error(VARLSTCNT(4) ERR_BADTRNPARAM,2,mode->str.len,mode->str.addr);
	}

	full = FALSE;
	*item_code = NOVALUE;
	if (item->str.len)
	{	if (item->str.len > 12)
			rts_error(VARLSTCNT(4) ERR_BADTRNPARAM, 2,
				MIN(SHRT_MAX, item->str.len), item->str.addr);
		lower_to_upper(buff,item->str.addr,item->str.len);
		if ((i = buff[0] - 'A') < MIN_INDEX || i > MAX_INDEX)
		{	rts_error(VARLSTCNT(4) ERR_BADTRNPARAM, 2, item->str.len, item->str.addr);
		}
		if ( trnlnm_index[i].len)
		{	slot = trnlnm_index[i].index;
			last_slot = trnlnm_index[i].len;
			for (; slot < last_slot; slot++)
			{	if (item->str.len == trnlnm_table[slot].len &&
					!memcmp(trnlnm_table[slot].name, buff, item->str.len))
				{	if (trnlnm_table[slot].item_code == FULL_VALUE)
					{	if (ind)
							index = 2;
						else
							index = 1;
						*item_code = LNM$_STRING;
						item_list.item[index].buffer_address = &full_mask;
						item_list.item[index].buffer_length = SIZEOF(full_mask);
						item_list.item[index].item_code = LNM$_ATTRIBUTES;
						item_code = &item_list.item[index].item_code;
						full = TRUE;
					}else
					{	*item_code = trnlnm_table[slot].item_code;
					}
					break;
				}
			}
		}
		if (*item_code == NOVALUE)
		{	rts_error(VARLSTCNT(4) ERR_BADTRNPARAM,2,item->str.len,item->str.addr);
		}
	}else
	{	*item_code = LNM$_STRING;
	}
	for ( pass = 0 ; ; pass++ )
	{	retlen = 0;
		status = sys$trnlnm(&attribute, &ltable, &lname, acmode == NOVALUE ? 0 : &acmode, &item_list);
		if (status & 1)
		{	if (*item_code == LNM$_STRING || *item_code == LNM$_TABLE)
			{	ret->mvtype = MV_STR;
				ENSURE_STP_FREE_SPACE(retlen);
				ret->str.addr = stringpool.free;
				ret->str.len = retlen;
				memcpy(ret->str.addr, result, retlen);
				stringpool.free += retlen;
				return;
			}else if (*item_code == LNM$_LENGTH || *item_code == LNM$_MAX_INDEX)
			{
				MV_FORCE_MVAL(ret,*(int4 *)result) ;
				n2s(ret);
				return;
			}else if (*item_code == LNM$_ACMODE)
			{	ret->mvtype = MV_STR;
				switch(*result)
				{	case PSL$C_USER:
						ENSURE_STP_FREE_SPACE(4);
						ret->str.addr = stringpool.free;
						ret->str.len = 4;
						memcpy(ret->str.addr, "USER", 4);
						stringpool.free += 4;
						return;
					case PSL$C_SUPER:
						ENSURE_STP_FREE_SPACE(5);
						ret->str.addr = stringpool.free;
						ret->str.len = 5;
						memcpy(ret->str.addr, "SUPER", 5);
						stringpool.free += 5;
						return;
					case PSL$C_EXEC:
						ENSURE_STP_FREE_SPACE(9);
						ret->str.addr = stringpool.free;
						ret->str.len = 9;
						memcpy(ret->str.addr, "EXECUTIVE", 9);
						stringpool.free += 9;
						return;
					case PSL$C_KERNEL:
						ENSURE_STP_FREE_SPACE(6);
						ret->str.addr = stringpool.free;
						ret->str.len = 6;
						memcpy(ret->str.addr, "KERNEL", 6);
						stringpool.free += 6;
						return;
					default:
						GTMASSERT;
				}
			}else
			{	assert(*item_code == LNM$_ATTRIBUTES);
				if (full)
				{	if (!retlen)	/* If the logical name exists, but has no entry for the specified index, */
					{		/* then the return status will be normal as the TERMINAL attribute will  */
							/* be filled in, but there will be no equivalence name, thus retlen == 0 */
						ret->mvtype = MV_STR;
						if (!pass)
						{	ret->str.len = 0;
							return;
						}
						ENSURE_STP_FREE_SPACE(lname.dsc$w_length);
						ret->str.addr = stringpool.free;
						ret->str.len = lname.dsc$w_length;
						memcpy(ret->str.addr, lname.dsc$a_pointer, lname.dsc$w_length);
						stringpool.free += lname.dsc$w_length;
						return;
					}
					if(full_mask & LNM$M_TERMINAL)
					{	ret->mvtype = MV_STR;
						ENSURE_STP_FREE_SPACE(retlen);
						ret->str.addr = stringpool.free;
						ret->str.len = retlen;
						memcpy(ret->str.addr, result, retlen);
						stringpool.free += retlen;
						return;
					}
					memcpy(buff,result,retlen);
					lname.dsc$w_length = retlen;
					lname.dsc$a_pointer = buff;
				}else
				{	mask = attr_tab[slot];
					if (mask == NOVALUE)
						GTMASSERT;
					MV_FORCE_MVAL(ret,( *((int4*)result) & mask ? 1 : 0 )) ;
					n2s(ret);
					return;
				}
			}
		}else if (status == SS$_NOLOGNAM)
		{	ret->mvtype = MV_STR;
			if (full && pass > 0)
			{
				ENSURE_STP_FREE_SPACE(lname.dsc$w_length);
				ret->str.addr = stringpool.free;
				ret->str.len = lname.dsc$w_length;
				memcpy(ret->str.addr, lname.dsc$a_pointer, lname.dsc$w_length);
				stringpool.free += lname.dsc$w_length;
			}else
			{	ret->str.len = 0;
			}
			return;
		}else
		{	rts_error(VARLSTCNT(1) status);
		}
	}
	MV_FORCE_MVAL(ret, 0) ;
	return;
}
Esempio n. 12
0
struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
	{
	struct tm *ts = NULL;

#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_OS2) && !defined(__CYGWIN32__) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_SUNOS)
	/* should return &data, but doesn't on some systems,
	   so we don't even look at the return value */
	gmtime_r(timer,result);
	ts = result;
#elif !defined(OPENSSL_SYS_VMS)
	ts = gmtime(timer);
	if (ts == NULL)
		return NULL;

	memcpy(result, ts, sizeof(struct tm));
	ts = result;
#endif
#ifdef OPENSSL_SYS_VMS
	if (ts == NULL)
		{
		static $DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL");
		static $DESCRIPTOR(lognam,"SYS$TIMEZONE_DIFFERENTIAL");
		char logvalue[256];
		unsigned int reslen = 0;
		struct {
			short buflen;
			short code;
			void *bufaddr;
			unsigned int *reslen;
		} itemlist[] = {
			{ 0, LNM$_STRING, 0, 0 },
			{ 0, 0, 0, 0 },
		};
		int status;
		time_t t;

		/* Get the value for SYS$TIMEZONE_DIFFERENTIAL */
		itemlist[0].buflen = sizeof(logvalue);
		itemlist[0].bufaddr = logvalue;
		itemlist[0].reslen = &reslen;
		status = sys$trnlnm(0, &tabnam, &lognam, 0, itemlist);
		if (!(status & 1))
			return NULL;
		logvalue[reslen] = '\0';

		/* Get the numerical value of the equivalence string */
		status = atoi(logvalue);

		/* and use it to move time to GMT */
		t = *timer - status;

		/* then convert the result to the time structure */
#ifndef OPENSSL_THREADS
		ts=(struct tm *)localtime(&t);
#else
		/* Since there was no gmtime_r() to do this stuff for us,
		   we have to do it the hard way. */
		{
		/* The VMS epoch is the astronomical Smithsonian date,
		   if I remember correctly, which is November 17, 1858.
		   Furthermore, time is measure in thenths of microseconds
		   and stored in quadwords (64 bit integers).  unix_epoch
		   below is January 1st 1970 expressed as a VMS time.  The
		   following code was used to get this number:

		   #include <stdio.h>
		   #include <stdlib.h>
		   #include <lib$routines.h>
		   #include <starlet.h>

		   main()
		   {
		     unsigned long systime[2];
		     unsigned short epoch_values[7] =
		       { 1970, 1, 1, 0, 0, 0, 0 };

		     lib$cvt_vectim(epoch_values, systime);

		     printf("%u %u", systime[0], systime[1]);
		   }
		*/
		unsigned long unix_epoch[2] = { 1273708544, 8164711 };
		unsigned long deltatime[2];
		unsigned long systime[2];
		struct vms_vectime
			{
			short year, month, day, hour, minute, second,
				centi_second;
			} time_values;
		long operation;

		/* Turn the number of seconds since January 1st 1970 to
		   an internal delta time.
		   Note that lib$cvt_to_internal_time() will assume
		   that t is signed, and will therefore break on 32-bit
		   systems some time in 2038.
		*/
		operation = LIB$K_DELTA_SECONDS;
		status = lib$cvt_to_internal_time(&operation,
			&t, deltatime);

		/* Add the delta time with the Unix epoch and we have
		   the current UTC time in internal format */
		status = lib$add_times(unix_epoch, deltatime, systime);

		/* Turn the internal time into a time vector */
		status = sys$numtim(&time_values, systime);

		/* Fill in the struct tm with the result */
		result->tm_sec = time_values.second;
		result->tm_min = time_values.minute;
		result->tm_hour = time_values.hour;
		result->tm_mday = time_values.day;
		result->tm_mon = time_values.month - 1;
		result->tm_year = time_values.year - 1900;

		operation = LIB$K_DAY_OF_WEEK;
		status = lib$cvt_from_internal_time(&operation,
			&result->tm_wday, systime);
		result->tm_wday %= 7;

		operation = LIB$K_DAY_OF_YEAR;
		status = lib$cvt_from_internal_time(&operation,
			&result->tm_yday, systime);
		result->tm_yday--;

		result->tm_isdst = 0; /* There's no way to know... */

		ts = result;
#endif
		}
		}
#endif
	return ts;
	}	
Esempio n. 13
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;
   }
}
Esempio n. 14
0
File: mbx.c Progetto: Rick33/freevms
main(){
  struct _iosb myiosb;

  char mybuf1[MBXBUFSIZ]="test1";
  char mybuf2[MBXBUFSIZ]="test2";
  char mybuf3[MBXBUFSIZ]="test3";

  char * out1="hello";
  char * out2="world";
  char * out3="hi";

  void *p1, mbxast();
  char mbuffer[MBXBUFSIZ];
  unsigned short mbxchan1, mbxchan2, mbxchan3, mbxiosb;
  unsigned int status, outlen;
  unsigned int mbuflen=MBXBUFSIZ, bufquo=MBXBUFQUO, promsk=0;
  $DESCRIPTOR(mblognam1,"MAILBOX1");
  $DESCRIPTOR(mblognam2,"MAILBOX2");
  $DESCRIPTOR(mblognam3,"MAILBOX3");

  printf("this was originally in 1: %s\n",mybuf1);
  printf("this was originally in 2: %s\n",mybuf2);
  printf("this was originally in 3: %s\n",mybuf3);

  status = sys$crembx(0,&mbxchan1,mbuflen,bufquo,promsk,0,&mblognam1,0);
  printf("status %x mbxchan %x \n", status,mbxchan1);
  if ((status&1)==0) signal(status);
  status = sys$crembx(0,&mbxchan2,mbuflen,bufquo,promsk,0,&mblognam2,0);
  printf("status %x mbxchan %x \n", status,mbxchan2);
  if ((status&1)==0) signal(status);
  status = sys$crembx(0,&mbxchan3,mbuflen,bufquo,promsk,0,&mblognam3,0);
  printf("status %x mbxchan %x \n", status,mbxchan3);
  if ((status&1)==0) signal(status);

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

  status=sys$qio(0,mbxchan1,IO$_READVBLK,0,0,0,mybuf1,512,0,0,0,0);

  printf("after qio %x\n",time(0));
  printf("status %x done %x \n", status,done);
  if ((status&1)==0) signal(status);

  printf("before qiow %x\n",time(0));
  status=sys$qio(0,mbxchan1,IO$_WRITEVBLK,0,0,0,out1,strlen(out1),0,0,0,0);
  printf("after qiow %x\n",time(0));
  printf("status %x done %x \n", status,done);
  if ((status&1)==0) signal(status);
  printf("before qiow %x\n",time(0));
  status=sys$qio(0,mbxchan1,IO$_WRITEVBLK,0,0,0,out2,strlen(out2),0,0,0,0);
  printf("after qiow %x\n",time(0));
  printf("status %x done %x \n", status,done);
  if ((status&1)==0) signal(status);

  printf("this was read from 1: %s\n",mybuf1);

  printf("Pausing...\n");
  sleep(2);





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

  status=sys$qio(0,mbxchan2,IO$_READVBLK|IO$M_STREAM,0,0,0,mybuf2,512,0,0,0,0);

  printf("after qio %x\n",time(0));
  printf("status %x done %x \n", status,done);
  if ((status&1)==0) signal(status);

  printf("before qiow %x\n",time(0));
  status=sys$qio(0,mbxchan2,IO$_WRITEVBLK,0,0,0,out1,strlen(out1),0,0,0,0);
  printf("after qiow %x\n",time(0));
  printf("status %x done %x \n", status,done);
  if ((status&1)==0) signal(status);
  printf("before qiow %x\n",time(0));
  status=sys$qio(0,mbxchan2,IO$_WRITEVBLK,0,0,0,out2,strlen(out2),0,0,0,0);
  printf("after qiow %x\n",time(0));
  printf("status %x done %x \n", status,done);
  if ((status&1)==0) signal(status);

  printf("this was read from 2: %s\n",mybuf2);

  printf("Pausing...\n");
  sleep(2);




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

  printf("before qiow %x\n",time(0));
  status=sys$qio(0,mbxchan3,IO$_WRITEVBLK,0,0,0,out1,strlen(out1),0,0,0,0);
  printf("after qiow %x\n",time(0));
  printf("status %x done %x \n", status,done);
  if ((status&1)==0) signal(status);
  printf("before qiow %x\n",time(0));
  status=sys$qio(0,mbxchan3,IO$_WRITEVBLK,0,0,0,out2,strlen(out2),0,0,0,0);
  printf("after qiow %x\n",time(0));
  printf("status %x done %x \n", status,done);
  if ((status&1)==0) signal(status);

  status=sys$qiow(0,mbxchan3,IO$_READVBLK|IO$M_STREAM,0,0,0,mybuf3,512,0,0,0,0);

  printf("after qio %x\n",time(0));
  printf("status %x done %x \n", status,done);
  if ((status&1)==0) signal(status);

  printf("this was read from 3: %s\n",mybuf3);

  sleep(2);


  {

    struct item_list_3 { short buflen, item_code;
			 void *bufaddr;
			 void *retlenaddr;
		       } itmlist[2];

    char buf[50];
    int retlen;

    itmlist[0].item_code=LNM$_STRING;
    itmlist[0].bufaddr=buf;
    itmlist[0].buflen=50;
    itmlist[0].retlenaddr=&retlen;
    itmlist[1].item_code=0;
    itmlist[1].buflen=0;
    itmlist[1].bufaddr=0;

    $DESCRIPTOR(tab,"LNM$TEMPORARY_MAILBOX");

    status = sys$trnlnm(0,
		    &tab,
		    &mblognam1, 0,
		    itmlist);
    if ((status&1)==0) signal(status);
    printf("mailbox1 translates to %s\n",buf);
  }
  return SS$_NORMAL;
}