Beispiel #1
0
int getmaxprocount()
{
    int status;
    unsigned long maxprocount;
    item_list itmlst3[2];
    item_list *itml3 = itmlst3;

    itmlst3[0].wlength = sizeof (maxprocount);
    itmlst3[0].wcode = SYI$_MAXPROCESSCNT;
    itmlst3[0].pbuffer = &maxprocount;
    itmlst3[0].pretlen = NULL;
    itmlst3[1].wlength = 0;
    itmlst3[1].wcode = 0;
    itmlst3[1].pbuffer = NULL;
    itmlst3[1].pretlen = NULL;

    status = sys$getsyiw (0, 0, 0, itmlst3, 0, 0, 0);
    if ($VMS_STATUS_SUCCESS (status))
    {
        return maxprocount;
    }
    else
    {
      return 0;
    }
}
Boolean ComputerSystem::getSerialNumber(CIMProperty& p)
{
    long status = SS$_NORMAL, i;
    char lrSerNum[16]="",lSerNum[16]="";

    struct k1_arglist {                 // kernel call arguments
            long    lCount;             // number of arguments
            char *pSerNum;
        } getsernumkargs = {1};                // init 1 argument

    getsernumkargs.pSerNum = lrSerNum;

    status = sys$cmkrnl(GetSerNum,&getsernumkargs);
    if ($VMS_STATUS_SUCCESS(status))
    {
        for (i=0;i<strlen(lrSerNum);i++)
        {
           lSerNum[strlen(lrSerNum)-i-1] = lrSerNum[i];
        }
	_serialNumber.assign(lSerNum);
	p = CIMProperty(PROPERTY_SERIAL_NUMBER, _serialNumber);
        return true;
    }

    return false;
}
Beispiel #3
0
Boolean Process::getUserModeTime (Uint64& i64)
const
{
    int status = SS$_NORMAL;
    long lKernelTicks = 0;
    long lExecTicks = 0;
    long lSuperTicks = 0;
    long lUserTicks = 0;

    struct k1_arglist
    {                             // kernel call arguments
        long lCount;              // number of arguments
        long epid;
        long *pKernelTicks;
        long *pExecTicks;
        long *pSuperTicks;
        long *pUserTicks;
    } getcputickskargs = {5};     // init to 5 arguments

    getcputickskargs.epid = pInfo.pid;
    getcputickskargs.pKernelTicks = &lKernelTicks;
    getcputickskargs.pExecTicks = &lExecTicks;
    getcputickskargs.pSuperTicks = &lSuperTicks;
    getcputickskargs.pUserTicks = &lUserTicks;

    status = sys$cmkrnl (GetCPUTicks, &getcputickskargs);
    if (!$VMS_STATUS_SUCCESS (status))
    {
        return false;
    }

    i64 = lUserTicks / 10;      // milliseconds
    return true;
}
Boolean ComputerSystem::getOtherIdentifyingInfo(CIMProperty& p)
{
  // return model for this property

   int status;
   Array<String> s;
   char hwname[32];
   typedef struct {
        unsigned short wlength;
        unsigned short wcode;
        void *pbuffer;
        void *pretlen; } item_list;
   item_list itmlst3[2];

   itmlst3[0].wlength = sizeof(hwname);
   itmlst3[0].wcode = SYI$_HW_NAME;
   itmlst3[0].pbuffer = hwname;
   itmlst3[0].pretlen = NULL;
   itmlst3[1].wlength = 0;
   itmlst3[1].wcode = 0;
   itmlst3[1].pbuffer = NULL;
   itmlst3[1].pretlen = NULL;

   status = sys$getsyiw (0, 0, 0, itmlst3, 0, 0, 0);
   if ($VMS_STATUS_SUCCESS(status))
   {
	_otherInfo.assign(hwname);
	s.append(_otherInfo);
	p = CIMProperty(PROPERTY_OTHER_IDENTIFYING_INFO,s);
        return true;
   }
   else
        return false;
}
Beispiel #5
0
/* <crt_init>:
 * Initialize the screen and this module:
 */
void	crt_init (int (*func)(short *lpp_, short *width_))
{
	register int	j;
	static	short	ttchan;
	unsigned status;
	static	$DESCRIPTOR(terminal,"SYS$COMMAND");

	/* Assign channel to terminal	*/
	status = sys$assign(&terminal, &ttchan, 0, 0);
	if (! $VMS_STATUS_SUCCESS(status)) lib$stop(status);

	/* Enable control-C AST	*/
	status = sys$qiow (0,
			ttchan,
			IO$_SETMODE | IO$M_CTRLCAST, 0, 0, 0,
			&crt_ctl_c_ast, &ttchan, 0, 0, 0, 0);
	if (! $VMS_STATUS_SUCCESS(status)) error(status, 0);

	/* Get screen size, terminal type: */
	lib$screen_info (&term_flags, &term_type, &width, &lpp);
	if ((term_flags & FLAG_DEC) == 0)
		error (0, "Terminal must be VT52, VT100 or ANSI\n");

	lpp = crt__lpp0 (lpp);

	crt__NL0 (TRUE);	/* Normally must absorb 1st '\n'	*/
	if (func)	(*func)(&lpp, &width);

	top_line = end_line = 0;
	lpp	= min(CRT_LINES-1, lpp);
	width	= min(CRT_COLS-1,  width);
	v_width	= max(width, 132);

	lastx	= lasty	= 0;

	top_margin = 1;
	end_margin = lpp;

	bigvec = calloc(lpp, 1+v_width);
	for (j = 0; j <= lpp; j++)
	{
		sgrvec[j] = 0;
		crtvec[j] = &bigvec[(1+v_width) * j];
	}
	crt_clear();
}
Beispiel #6
0
static void *sqlite3MemMalloc(int nByte){
  long *pNew, szNew = nByte + sizeof(int);
  if( $VMS_STATUS_SUCCESS(lib$get_vm(&szNew, &pNew, &_sqliteZone_)) ){
    *pNew = nByte;
    return ++pNew;
  }
  return 0;
}
Beispiel #7
0
int main(int argc, char ** argv) {


void * libptr;
const char * (*ssl_version)(int t);
const char * version;

   if (argc < 1) {
       puts("report_openssl_version filename");
       exit(1);
   }

   libptr = dlopen(argv[1], 0);

   ssl_version = (const char * (*)(int))dlsym(libptr, "SSLeay_version");
   if ((void *)ssl_version == NULL) {
      ssl_version = (const char * (*)(int))dlsym(libptr, "ssleay_version");
      if ((void *)ssl_version == NULL) {
         ssl_version = (const char * (*)(int))dlsym(libptr, "SSLEAY_VERSION");
      }
   }

   dlclose(libptr);

   if ((void *)ssl_version == NULL) {
      puts("Unable to lookup version of OpenSSL");
      exit(1);
   }

   version = ssl_version(SSLEAY_VERSION);

   puts(version);

   /* Was a symbol argument given? */
   if (argc > 1) {
      int status;
      struct dsc$descriptor_s symbol_dsc;
      struct dsc$descriptor_s value_dsc;
      const unsigned long table_type = LIB$K_CLI_LOCAL_SYM;

      symbol_dsc.dsc$a_pointer = argv[2];
      symbol_dsc.dsc$w_length = strlen(argv[2]);
      symbol_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
      symbol_dsc.dsc$b_class = DSC$K_CLASS_S;

      value_dsc.dsc$a_pointer = (char *)version; /* Cast ok */
      value_dsc.dsc$w_length = strlen(version);
      value_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
      value_dsc.dsc$b_class = DSC$K_CLASS_S;

      status = LIB$SET_SYMBOL(&symbol_dsc, &value_dsc, &table_type);
      if (!$VMS_STATUS_SUCCESS(status)) {
         exit(status);
      }
   }

   exit(0);
}
Beispiel #8
0
/* <crt_ctl_c_ast>:
 * CTRL/C AST routine.  Reset terminal characteristics, cancel pending I/O.
 */
static
void	crt_ctl_c_ast (short *ttchan_)
{
	unsigned status;

	crt_quit (FALSE);
	crt_move (lpp-1, 1);
	status = sys$cancel(*ttchan_);
	if (! $VMS_STATUS_SUCCESS(status)) lib$stop(status);
}
Beispiel #9
0
/*
**++
**  ROUTINE:	cli_get_value
**
**  FUNCTIONAL DESCRIPTION:
**
**  	C Interface to CLI$GET_VALUE.
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	cli_get_value (char *argname, DESCRIP *arg)
**
** argname: ASCIZ_string, read only, by reference
** arg:	    char_string, write only, by descriptor (dynamic)
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**  	All those from CLI$PRESENT and CLI$GET_VALUE.
**
**  SIDE EFFECTS:   	None.
**
**--
*/
static unsigned int cli_get_value (char *argname, char *arg, int argsize) {

    DESCRIP argnamd, argd;
    unsigned short arglen;
    int status;

    INIT_SDESC(argnamd, strlen(argname), argname);
    INIT_SDESC(argd, argsize-1, arg);
    status = cli$present(&argnamd);
    if ($VMS_STATUS_SUCCESS(status)) {
    	status = cli$get_value(&argnamd, &argd, &arglen);
    	if (OK(status)) *(arg+arglen) = '\0';
    }
    return status;
}
Beispiel #10
0
int LP_find_file_end(LP_DIR_CTX **ctx)
{
    if (ctx != NULL && *ctx != NULL) {
        int status = lib$find_file_end(&(*ctx)->VMS_context);

        free(*ctx);

        if (!$VMS_STATUS_SUCCESS(status)) {
            errno = EVMSERR;
            vaxc$errno = status;
            return 0;
        }
        return 1;
    }
    errno = EINVAL;
    return 0;
}
Beispiel #11
0
static int sqlite3MemInit(void *NotUsed){
  const int alg = LIB$K_VM_QUICK_FIT, arg = 16, extent = 128;
  const int blocksize = 512, smallest = 8;
  const int flags = LIB$M_VM_BOUNDARY_TAGS | LIB$M_VM_EXTEND_AREA
                  | LIB$M_VM_TAIL_LARGE;
  int rc = SQLITE_OK, status;

  $DESCRIPTOR(name, "Sqlite_heap");

  if( _sqliteZone_ == 0){
    status = lib$create_vm_zone(&_sqliteZone_, &alg, &arg, &flags, &extent,
                                &extent, &blocksize, 0, 0, &smallest, &name);
    if( !$VMS_STATUS_SUCCESS(status) ){
      rc = SQLITE_ERROR;
    }
  }

  return rc;
}
Beispiel #12
0
char* msgtxt(int msgid, char *buffer, int buflen)
{
    int status;
    unsigned short msglen;
    static struct dsc$descriptor bufdsc;
    bufdsc.dsc$w_length = buflen - 1;    // Leave room for null

    bufdsc.dsc$a_pointer = buffer;

    status = sys$getmsg(msgid, &msglen, &bufdsc, 15, 0);
    if (!$VMS_STATUS_SUCCESS(status))
    {
        lib$stop(status);
    }

    buffer[0] = '-';
    buffer[msglen] = '\0';
    return buffer;
}
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;
   }
}
Beispiel #14
0
int
dclwild (
	DCLARG	*dcl_)
{
	if (dcl_->dcl_stat && ! $VMS_STATUS_SUCCESS(dcl_->dcl_stat))
		return (-1);
	else
		return (dcl_->dcl$l_fnb
				& (	NAM$M_WILD_VER
				|	NAM$M_WILD_TYPE
				|	NAM$M_WILD_NAME
				|	NAM$M_WILDCARD	/* inclusive test */
				|	NAM$M_WILD_DIR
				|	NAM$M_WILD_UFD
				|	NAM$M_WILD_GRP
				|	NAM$M_WILD_MBR
				|	NAM$M_WILD_SFD1
				|	NAM$M_WILD_SFD2
				|	NAM$M_WILD_SFD3
				|	NAM$M_WILD_SFD4
				|	NAM$M_WILD_SFD5
				|	NAM$M_WILD_SFD6
				|	NAM$M_WILD_SFD7));
}
Beispiel #15
0
/* Take all the fun out of simply looking up a logical name */
static int sys_trnlnm
   (const char * logname,
    char * value,
    int value_len)
{
    const $DESCRIPTOR(table_dsc, "LNM$FILE_DEV");
    const unsigned long attr = LNM$M_CASE_BLIND;
    struct dsc$descriptor_s name_dsc;
    int status;
    unsigned short result;
    struct itmlst_3 itlst[2];

    itlst[0].buflen = value_len;
    itlst[0].itmcode = LNM$_STRING;
    itlst[0].bufadr = value;
    itlst[0].retlen = &result;

    itlst[1].buflen = 0;
    itlst[1].itmcode = 0;

    name_dsc.dsc$w_length = strlen(logname);
    name_dsc.dsc$a_pointer = (char *)logname;
    name_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
    name_dsc.dsc$b_class = DSC$K_CLASS_S;

    status = SYS$TRNLNM(&attr, &table_dsc, &name_dsc, 0, itlst);

    if ($VMS_STATUS_SUCCESS(status)) {

         /* Null terminate and return the string */
        /*--------------------------------------*/
        value[result] = '\0';
    }

    return status;
}
Beispiel #16
0
/* This is a callback procedure for lib$get_index */
static int
VMS_get_member_info(struct dsc$descriptor_s *module, unsigned long *rfa)
{
  int status, i;
  const int truncated = 0; /* Member name may be truncated */
  time_t member_date; /* Member date */
  char *filename;
  unsigned int buffer_length; /* Actual buffer length */

  /* Unused constants - Make does not actually use most of these */
  const int file_desc = -1; /* archive file descriptor for reading the data */
  const int header_position = 0; /* Header position */
  const int data_position = 0; /* Data position in file */
  const int data_size = 0; /* Data size */
  const int uid = 0; /* member gid */
  const int gid = 0; /* member gid */
  const int mode = 0; /* member protection mode */
  /* End of unused constants */

  static struct dsc$descriptor_s bufdesc =
    { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL };

  /* Only need the module definition */
  struct mhddef *mhd;

  /* If a previous callback is non-zero, just return that status */
  if (VMS_function_ret)
    {
      return SS$_NORMAL;
    }

  /* lbr_set_module returns more than just the module header. So allocate
     a buffer which is big enough: the maximum LBR$C_MAXHDRSIZ. That's at
     least bigger than the size of struct mhddef.
     If the request is too small, a buffer truncated warning is issued so
     it can be reissued with a larger buffer.
     We do not care if the buffer is truncated, so that is still a success. */
  mhd = xmalloc(LBR$C_MAXHDRSIZ);
  bufdesc.dsc$a_pointer = (char *) mhd;
  bufdesc.dsc$w_length = LBR$C_MAXHDRSIZ;

  status = lbr$set_module(&VMS_lib_idx, rfa, &bufdesc, &buffer_length, 0);

  if ((status != LBR$_HDRTRUNC) && !$VMS_STATUS_SUCCESS(status))
    {
      ON(error, NILF,
          _("lbr$set_module() failed to extract module info, status = %d"),
          status);

      lbr$close(&VMS_lib_idx);

      return status;
    }

#ifdef TEST
  /* When testing this code, it is useful to know the length returned */
  printf("Input length = %d, actual = %d\n",
      bufdesc.dsc$w_length, buffer_length);
#endif

  /* Conversion from VMS time to C time.
     VMS defectlet - mhddef is sub-optimal, for the time, it has a 32 bit
     longword, mhd$l_datim, and a 32 bit fill instead of two longwords, or
     equivalent. */
  member_date = vms_time_to_unix(&mhd->mhd$l_datim);
  free(mhd);

  /* Here we have a problem.  The module name on VMS does not have
     a file type, but the filename pattern in the "VMS_saved_arg"
     may have one.
     But only the method being called knows how to interpret the
     filename pattern.
     There are currently two different formats being used.
     This means that we need a VMS specific code in those methods
     to handle it. */
  filename = xmalloc(module->dsc$w_length + 1);

  /* TODO: We may need an option to preserve the case of the module
     For now force the module name to lower case */
  for (i = 0; i < module->dsc$w_length; i++)
    filename[i] = _tolower((unsigned char )module->dsc$a_pointer[i]);

  filename[i] = '\0';

  VMS_function_ret = (*VMS_function)(file_desc, filename, truncated,
      header_position, data_position, data_size, member_date, uid, gid, mode,
      VMS_saved_arg);

  free(filename);
  return SS$_NORMAL;
}
Beispiel #17
0
static int vmsRead(
  sqlite3_file *id,         /* File to read from */
  void *vBuf,               /* Write content into this buffer */
  int amt,                  /* Number of bytes to read */
  sqlite3_int64  offset     /* Begin reading at this offset */
){
  int bcnt;
  char *pBuf = vBuf;
  int remainder;
  char buf[SQLITE_DEFAULT_SECTOR_SIZE];
  unsigned short iosb[4];
  int status = SS$_NORMAL;
  vmsFile *pFile = (vmsFile *)id;

  /*
  ** Determine the virtual block we are to read from, and a possbile byte
  ** position within that block.
  */
  int vbn = (offset / SQLITE_DEFAULT_SECTOR_SIZE) + 1;
  int vpos = offset % SQLITE_DEFAULT_SECTOR_SIZE;

  if( vpos ){
    status = sys$qiow(EFN$C_ENF, pFile->chan, IO$_READVBLK, iosb,
        0, 0, buf, SQLITE_DEFAULT_SECTOR_SIZE, vbn++, 0, 0, 0);
    if( $VMS_STATUS_SUCCESS(status)
        && $VMS_STATUS_SUCCESS(status = iosb[0]) ){
      bcnt = min(amt, SQLITE_DEFAULT_SECTOR_SIZE - vpos);
      memcpy(pBuf, &buf[vpos], bcnt);

      pBuf += bcnt;
      amt -= bcnt;
    }
  }

  if( (amt >= SQLITE_DEFAULT_SECTOR_SIZE) && $VMS_STATUS_SUCCESS(status) ){
    remainder = amt % SQLITE_DEFAULT_SECTOR_SIZE;

    status = sys$qiow(EFN$C_ENF, pFile->chan, IO$_READVBLK, iosb,
        0, 0, pBuf, amt - remainder, vbn, 0, 0, 0);
    if( $VMS_STATUS_SUCCESS(status)
        && $VMS_STATUS_SUCCESS(status = iosb[0]) ){
      bcnt = iosb[1] | (iosb[2] << 16);

      if( bcnt < (amt - remainder) ){
        remainder = amt - bcnt;
        status = SS$_ENDOFFILE;
      }else{
        bcnt = amt - remainder;
      }

      pBuf += bcnt;
      vbn += bcnt / SQLITE_DEFAULT_SECTOR_SIZE;
      amt = remainder;
    }
  }

  if( (amt > 0) && $VMS_STATUS_SUCCESS(status) ){
    status = sys$qiow(EFN$C_ENF, pFile->chan, IO$_READVBLK, iosb,
        0, 0, buf, SQLITE_DEFAULT_SECTOR_SIZE, vbn, 0, 0, 0);
    if( $VMS_STATUS_SUCCESS(status)
        && $VMS_STATUS_SUCCESS(status = iosb[0]) ){
      memcpy(pBuf, buf, amt);
    }
  }

  if( status == SS$_ENDOFFILE ){
    /*
    ** Unread parts of the buffer must be zero-filled.
    */
    memset(pBuf, '\0', amt);
    return SQLITE_IOERR_SHORT_READ;
  }else if( !$VMS_STATUS_SUCCESS(status) ){
    return SQLITE_IOERR_READ;
  }

  return SQLITE_OK;
}
Beispiel #18
0
Boolean Process::getCPUTime (Uint32& i32)
const
{
    int status = SS$_NORMAL;
    long lKernelTicks = 0;
    long lExecTicks = 0;
    long lSuperTicks = 0;
    long lUserTicks = 0;
    long lTotalTicks = 0;
    long avcpucnt;
    __int64 pstartime;
    __int64 qcurtime;
    float fTotalTicks;
    float fpercntime;

    struct k1_arglist
    {                             // kernel call arguments
        long lCount;              // number of arguments
        long epid;
        long *pKernelTicks;
        long *pExecTicks;
        long *pSuperTicks;
        long *pUserTicks;
    } getcputickskargs = {5};     // init to 5 arguments

    item_list itmlst3[2];

    getcputickskargs.epid = pInfo.pid;
    getcputickskargs.pKernelTicks = &lKernelTicks;
    getcputickskargs.pExecTicks = &lExecTicks;
    getcputickskargs.pSuperTicks = &lSuperTicks;
    getcputickskargs.pUserTicks = &lUserTicks;

    status = sys$cmkrnl (GetCPUTicks, &getcputickskargs);
    if (!$VMS_STATUS_SUCCESS (status))
    {
        return false;
    }

    lTotalTicks = lKernelTicks + lExecTicks + lSuperTicks + lUserTicks;

    fTotalTicks = lTotalTicks;  // 10 millisec ticks
    fTotalTicks = fTotalTicks * 10000000;  // 100 nanosec ticks

    pstartime = pInfo.p_stime;  // 100 nanosec ticks

    itmlst3[0].wlength = 4;
    itmlst3[0].wcode = SYI$_AVAILCPU_CNT;
    itmlst3[0].pbuffer = &avcpucnt;
    itmlst3[0].pretlen = NULL;
    itmlst3[1].wlength = 0;
    itmlst3[1].wcode = 0;
    itmlst3[1].pbuffer = NULL;
    itmlst3[1].pretlen = NULL;

    status = sys$getsyiw (0, 0, 0, itmlst3, 0, 0, 0);
    if (!$VMS_STATUS_SUCCESS (status))
    {
        return false;
    }

    status = sys$gettim (&qcurtime);
    if (!$VMS_STATUS_SUCCESS (status))
    {
        return false;
    }

    fpercntime = avcpucnt;
    fpercntime = fpercntime * (qcurtime - pstartime);
    fpercntime = (fTotalTicks / fpercntime) * 100;
    i32 = fpercntime;
    return true;
}
Beispiel #19
0
long int
ar_scan (const char *archive, ar_member_func_t function, const void *varg)
{
  char *vms_archive;

  static struct dsc$descriptor_s libdesc =
    { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL };

  const unsigned long func = LBR$C_READ;
  const unsigned long type = LBR$C_TYP_UNK;
  const unsigned long index = 1;
  unsigned long lib_idx;
  int status;

  VMS_saved_arg = varg;

  /* Null archive string can show up in test and cause an access violation */
  if (archive == NULL)
    {
      /* Null filenames do not exist */
      return -1;
    }

  /* archive path name must be in VMS format */
  vms_archive = (char *) vmsify(archive, 0);

  status = lbr$ini_control(&VMS_lib_idx, &func, &type, 0);

  if (!$VMS_STATUS_SUCCESS(status))
    {
      ON(error, NILF, _("lbr$ini_control() failed with status = %d"), status);
      return -2;
    }

  libdesc.dsc$a_pointer = vms_archive;
  libdesc.dsc$w_length = strlen(vms_archive);

  status = lbr$open(&VMS_lib_idx, &libdesc, 0, NULL, 0, NULL, 0);

  if (!$VMS_STATUS_SUCCESS(status))
    {

      /* TODO: A library format failure could mean that this is a file
         generated by the GNU AR utility and in that case, we need to
         take the UNIX codepath.  This will also take a change to the
         GNV AR wrapper program. */

      switch (status)
        {
      case RMS$_FNF:
        /* Archive does not exist */
        return -1;
      default:
#ifndef TEST
        OSN(error, NILF,
            _("unable to open library '%s' to lookup member status %d"),
            archive, status);
#endif
        /* For library format errors, specification says to return -2 */
        return -2;
        }
    }

  VMS_function = function;

  /* Clear the return status, as we are supposed to stop calling the
     callback function if it becomes non-zero, and this is a static
     variable. */
  VMS_function_ret = 0;

  status = lbr$get_index(&VMS_lib_idx, &index, VMS_get_member_info, NULL, 0);

  lbr$close(&VMS_lib_idx);

  /* Unless a failure occurred in the lbr$ routines, return the
     the status from the 'function' routine. */
  if ($VMS_STATUS_SUCCESS(status))
    {
      return VMS_function_ret;
    }

  /* This must be something wrong with the library and an error
     message should already have been printed. */
  return -2;
}
Beispiel #20
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;
}
Beispiel #21
0
static void set_features(void)
{
    int status;
    char unix_shell_name[255];
    int use_unix_settings = 1;

    status = sys_trnlnm("GNV$UNIX_SHELL",
                        unix_shell_name, sizeof unix_shell_name -1);
    if (!$VMS_STATUS_SUCCESS(status)) {
        unix_shell_name[0] = 0;
        use_unix_settings = 0;
    }

    /* ACCESS should check ACLs or it is lying. */
    set_feature_default("DECC$ACL_ACCESS_CHECK", ENABLE);

    /* We always want the new parse style */
    set_feature_default ("DECC$ARGV_PARSE_STYLE" , ENABLE);


    /* Unless we are in POSIX compliant mode, we want the old POSIX root
     * enabled.
     */
    set_feature_default("DECC$DISABLE_POSIX_ROOT", DISABLE);

    /* EFS charset, means UTF-8 support */
    /* VTF-7 support is controlled by a feature setting called UTF8 */
    set_feature_default ("DECC$EFS_CHARSET", ENABLE);
    set_feature_default ("DECC$EFS_CASE_PRESERVE", ENABLE);

    /* Support timestamps when available */
    set_feature_default ("DECC$EFS_FILE_TIMESTAMPS", ENABLE);

    /* Cache environment variables - performance improvements */
    set_feature_default ("DECC$ENABLE_GETENV_CACHE", ENABLE);

    /* Start out with new file attribute inheritance */
#ifdef __VAX
    set_feature_default ("DECC$EXEC_FILEATTR_INHERITANCE", "2");
#else
    set_feature_default ("DECC$EXEC_FILEATTR_INHERITANCE", 2);
#endif

    /* Don't display trailing dot after files without type */
    set_feature_default ("DECC$READDIR_DROPDOTNOTYPE", ENABLE);

    /* For standard output channels buffer output until terminator */
    /* Gets rid of output logs with single character lines in them. */
    set_feature_default ("DECC$STDIO_CTX_EOL", ENABLE);

    /* Fix mv aa.bb aa  */
    set_feature_default ("DECC$RENAME_NO_INHERIT", ENABLE);

    if (use_unix_settings) {

        /* POSIX requires that open files be able to be removed */
        set_feature_default ("DECC$ALLOW_REMOVE_OPEN_FILES", ENABLE);

        /* Default to outputting Unix filenames in VMS routines */
        set_feature_default ("DECC$FILENAME_UNIX_ONLY", ENABLE);
        /* FILENAME_UNIX_ONLY Implicitly sets */
        /* decc$disable_to_vms_logname_translation */

        set_feature_default ("DECC$FILE_PERMISSION_UNIX", ENABLE);

        set_feature_default ("DECC$FILE_SHARING", ENABLE);

        set_feature_default ("DECC$FILE_OWNER_UNIX", ENABLE);
        set_feature_default ("DECC$POSIX_SEEK_STREAM_FILE", ENABLE);

    } else {
        set_feature_default("DECC$FILENAME_UNIX_REPORT", ENABLE);
    }

    /* When reporting Unix filenames, glob the same way */
    set_feature_default ("DECC$GLOB_UNIX_STYLE", ENABLE);

    /* The VMS version numbers on Unix filenames is incompatible with most */
    /* ported packages. */
    set_feature_default("DECC$FILENAME_UNIX_NO_VERSION", ENABLE);

    /* The VMS version numbers on Unix filenames is incompatible with most */
    /* ported packages. */
    set_feature_default("DECC$UNIX_PATH_BEFORE_LOGNAME", ENABLE);

    /* Set strtol to proper behavior */
    set_feature_default("DECC$STRTOL_ERANGE", ENABLE);

    /* Commented here to prevent future bugs:  A program or user should */
    /* never ever enable DECC$POSIX_STYLE_UID. */
    /* It will probably break all code that accesses UIDs */
    /*  do_not_set_default ("DECC$POSIX_STYLE_UID", TRUE); */
}
Beispiel #22
0
Boolean Process::buildProcessTable (unsigned long& jpictx2,
                                    int& procCount,
                                    item_list* itmlst3,
                                    struct proc_info* procInfoArray)
{
    int status;
    char procimgnambuf[256];
    char proctermbuf[8];
    char usernamebuf[13];
    int procimgnamlen;
    int proctermlen;
    int usernamlen;
    unsigned __int64 proclgntim;
    long procpid;
    long proccputim;
    long procgrp;
    long procppid;
    long procuic;
    long procpgflquo;
    long procpri;
    long procbasepri;
    long procstate;
    long procwssize;
    long proclgnflgs;


    itmlst3[0].wlength = sizeof (usernamebuf);
    itmlst3[0].wcode = JPI$_USERNAME;
    itmlst3[0].pbuffer = usernamebuf;
    itmlst3[0].pretlen = &usernamlen;
    itmlst3[1].wlength = 4;
    itmlst3[1].wcode = JPI$_PID;
    itmlst3[1].pbuffer = &procpid;
    itmlst3[1].pretlen = NULL;
    itmlst3[2].wlength = 4;
    itmlst3[2].wcode = JPI$_CPUTIM;
    itmlst3[2].pbuffer = &proccputim;
    itmlst3[2].pretlen = NULL;
    itmlst3[3].wlength = 4;
    itmlst3[3].wcode = JPI$_GRP;
    itmlst3[3].pbuffer = &procgrp;
    itmlst3[3].pretlen = NULL;
    itmlst3[4].wlength = 4;
    itmlst3[4].wcode = JPI$_MASTER_PID;
    itmlst3[4].pbuffer = &procppid;
    itmlst3[4].pretlen = NULL;
    itmlst3[5].wlength = 4;
    itmlst3[5].wcode = JPI$_UIC;
    itmlst3[5].pbuffer = &procuic;
    itmlst3[5].pretlen = NULL;
    itmlst3[6].wlength = sizeof (procimgnambuf);
    itmlst3[6].wcode = JPI$_IMAGNAME;
    itmlst3[6].pbuffer = procimgnambuf;
    itmlst3[6].pretlen = &procimgnamlen;
    itmlst3[7].wlength = 4;
    itmlst3[7].wcode = JPI$_PGFLQUOTA;
    itmlst3[7].pbuffer = &procpgflquo;
    itmlst3[7].pretlen = NULL;
    itmlst3[8].wlength = 4;
    itmlst3[8].wcode = JPI$_PRI;
    itmlst3[8].pbuffer = &procpri;
    itmlst3[8].pretlen = NULL;
    itmlst3[9].wlength = 4;
    itmlst3[9].wcode = JPI$_PRIB;
    itmlst3[9].pbuffer = &procbasepri;
    itmlst3[9].pretlen = NULL;
    itmlst3[10].wlength = 4;
    itmlst3[10].wcode = JPI$_STATE;
    itmlst3[10].pbuffer = &procstate;
    itmlst3[10].pretlen = NULL;
    itmlst3[11].wlength = 4;
    itmlst3[11].wcode = JPI$_WSSIZE;
    itmlst3[11].pbuffer = &procwssize;
    itmlst3[11].pretlen = NULL;
    itmlst3[12].wlength = 4;
    itmlst3[12].wcode = JPI$_LOGIN_FLAGS;
    itmlst3[12].pbuffer = &proclgnflgs;
    itmlst3[12].pretlen = NULL;
    itmlst3[13].wlength = 8;
    itmlst3[13].wcode = JPI$_LOGINTIM;
    itmlst3[13].pbuffer = &proclgntim;
    itmlst3[13].pretlen = NULL;
    itmlst3[14].wlength = sizeof (proctermbuf);
    itmlst3[14].wcode = JPI$_TERMINAL;
    itmlst3[14].pbuffer = proctermbuf;
    itmlst3[14].pretlen = &proctermlen;
    itmlst3[MAXITMLST - 1].wlength = 0;
    itmlst3[MAXITMLST - 1].wcode = 0;
    itmlst3[MAXITMLST - 1].pbuffer = NULL;
    itmlst3[MAXITMLST - 1].pretlen = NULL;

    procCount = 0;
    while (1)
    {
        status = sys$getjpiw (0, &jpictx2, NULL, itmlst3, 0, NULL, 0);
        if (status == SS$_NOMOREPROC)
        {
            break;
        }
        if (!$VMS_STATUS_SUCCESS (status))
        {
            return status;
        }

        usernamebuf[12] = '\0';

        procInfoArray[procCount].ppid = procppid;
        procInfoArray[procCount].pid = procpid;
        procInfoArray[procCount].uid = procuic & 0xFFFF;
        procInfoArray[procCount].pgrp = (procuic >> 16) & 0xFFFF;
        procInfoArray[procCount].rgid = procgrp;
        procInfoArray[procCount].cpu = proccputim;
        procInfoArray[procCount].virtual_size = procpgflquo;
        procInfoArray[procCount].pri = procpri;
        procInfoArray[procCount].base_pri = procbasepri;
        procInfoArray[procCount].state = procstate;
        procInfoArray[procCount].pset = procwssize;
        procInfoArray[procCount].p_stime = proclgntim;
        strncpy (procInfoArray[procCount].uname, usernamebuf, 12);
        strncpy (procInfoArray[procCount].command, procimgnambuf, 256);
        strncpy (procInfoArray[procCount].tty, proctermbuf, 8);
        procCount++;
    }

    return true;
}
Beispiel #23
0
Boolean Process::loadProcessInfo (int &pIndex)
{
    int status;
    unsigned long maxprocount;
    __int64 qpid;
    char handle[100];
    unsigned long jpictx2; /* The context for JPI calls */
    item_list itmlst3[MAXITMLST];
    int procCount;
    Boolean stat;

    /* If this is the first process request. Rebuild proc_table */
    if (pIndex == 0)
    {
        /* Lock the mutex on proc_table */
        pthread_mutex_lock(&proc_table_mutex);

        /* Free the old proc_table */
        if (proc_table != NULL)
        {
            free(proc_table);
            proc_table = NULL;
            proc_table_count = 0;
        }

        /* Find the maximum process that could run on the system */
        if ((maxprocount = getmaxprocount ()) == 0)
        {
            /* Un lock the mutex on proc_table */
            pthread_mutex_unlock(&proc_table_mutex);
            /* Return false */
            return false;
        }

        /* Allocate memory to proc_table */
        proc_table =
            (proc_info_t) calloc (maxprocount + 1, sizeof (struct proc_info));

        /* Error in allocating Memory. return false */
        if (NULL == proc_table)
        {
            /* Un lock the mutex on proc_table */
            pthread_mutex_unlock(&proc_table_mutex);
            return false;
        }

        jpictx2 = 0;
        procCount = 0;
        itmlst3[0].wlength = 0;
        itmlst3[0].wcode = PSCAN$_MODE;
        itmlst3[0].pbuffer = (void *) JPI$K_OTHER;
        itmlst3[0].pretlen = NULL;
        itmlst3[1].wlength = 0;
        itmlst3[1].wcode = 0;
        itmlst3[1].pbuffer = NULL;
        itmlst3[1].pretlen = NULL;

        status = sys$process_scan (&jpictx2, itmlst3);
        if (!$VMS_STATUS_SUCCESS (status))
        {
            /* Free the proc_table */
            free (proc_table);
            proc_table = NULL;
            proc_table_count = 0;

            /* Un lock the mutex on proc_table */
            pthread_mutex_unlock(&proc_table_mutex);

            /* Return failure */
            return false;
        }

        stat = buildProcessTable(jpictx2, procCount, itmlst3, proc_table);
        proc_table_count += procCount;

        jpictx2 = 0;
        procCount = 0;
        itmlst3[0].wlength = 0;
        itmlst3[0].wcode = PSCAN$_MODE;
        itmlst3[0].pbuffer = (void *) JPI$K_BATCH;
        itmlst3[0].pretlen = NULL;
        itmlst3[1].wlength = 0;
        itmlst3[1].wcode = 0;
        itmlst3[1].pbuffer = NULL;
        itmlst3[1].pretlen = NULL;

        status = sys$process_scan (&jpictx2, itmlst3);
        if (!$VMS_STATUS_SUCCESS (status))
        {
            /* Free the proc_table */
            free (proc_table);
            proc_table = NULL;
            proc_table_count = 0;

            /* Un lock the mutex on proc_table */
            pthread_mutex_unlock(&proc_table_mutex);

            /* Return failure */
            return false;
        }

        stat = buildProcessTable(jpictx2, procCount, itmlst3,
                                 &proc_table[proc_table_count]);
        proc_table_count += procCount;

        jpictx2 = 0;
        procCount = 0;
        itmlst3[0].wlength = 0;
        itmlst3[0].wcode = PSCAN$_MODE;
        itmlst3[0].pbuffer = (void *) JPI$K_NETWORK;
        itmlst3[0].pretlen = NULL;
        itmlst3[1].wlength = 0;
        itmlst3[1].wcode = 0;
        itmlst3[1].pbuffer = NULL;
        itmlst3[1].pretlen = NULL;

        status = sys$process_scan (&jpictx2, itmlst3);
        if (!$VMS_STATUS_SUCCESS (status))
        {
            /* Free the proc_table */
            free (proc_table);
            proc_table = NULL;
            proc_table_count = 0;

            /* Un lock the mutex on proc_table */
            pthread_mutex_unlock(&proc_table_mutex);

            /* Return failure */
            return false;
        }

        stat = buildProcessTable(jpictx2, procCount, itmlst3,
                                 &proc_table[proc_table_count]);
        proc_table_count += procCount;

        jpictx2 = 0;
        itmlst3[0].wlength = 0;
        itmlst3[0].wcode = PSCAN$_MODE;
        itmlst3[0].pbuffer = (void *) JPI$K_INTERACTIVE;
        itmlst3[0].pretlen = NULL;
        itmlst3[1].wlength = 0;
        itmlst3[1].wcode = 0;
        itmlst3[1].pbuffer = NULL;
        itmlst3[1].pretlen = NULL;

        status = sys$process_scan (&jpictx2, itmlst3);
        if (!$VMS_STATUS_SUCCESS (status))
        {
            /* Free the proc_table */
            free (proc_table);
            proc_table = NULL;
            proc_table_count = 0;

            /* Un lock the mutex on proc_table */
            pthread_mutex_unlock(&proc_table_mutex);

            /* Return failure */
            return false;
        }

        stat = buildProcessTable(jpictx2, procCount, itmlst3,
                                 &proc_table[proc_table_count]);
        proc_table_count += procCount;

        /* Un lock the mutex on proc_table */
        pthread_mutex_unlock(&proc_table_mutex);
    } /* End if (pIndex == 0), rebuild of proc_table */

    return getProcessInfo(pIndex);
}
Beispiel #24
0
static int vmsWrite(
  sqlite3_file *id,         /* File to read from */
  const void *vBuf,         /* The bytes to be written */
  int amt,                  /* Number of bytes to write */
  sqlite3_int64 offset      /* Offset into the file to begin writing at */
){
  struct atrdef atr[2];
  struct ile3 jpilst[2];
  FAT fat;
  struct fibdef fib;
  char buf[SQLITE_DEFAULT_SECTOR_SIZE];
  const char *pBuf = vBuf;
  int bcnt, extend = 0, filesize, needed, remainder;
  struct dsc$descriptor fibdsc;
  unsigned short iosb[4];
  int status;
  vmsFile *pFile = (vmsFile *)id;

  /*
  ** Determine the virtual block we are to write to, and a possbile byte
  ** position within that block.
  */
  int vbn = (offset / SQLITE_DEFAULT_SECTOR_SIZE) + 1;
  int vpos = offset % SQLITE_DEFAULT_SECTOR_SIZE;

  memset(&fib, 0, sizeof(fib));
  fib.fib$v_writethru = 1;
  fib.fib$w_fid[0] = pFile->nam.nam$w_fid[0];
  fib.fib$w_fid[1] = pFile->nam.nam$w_fid[1];
  fib.fib$w_fid[2] = pFile->nam.nam$w_fid[2];

  fibdsc.dsc$w_length = sizeof(fib);
  fibdsc.dsc$a_pointer = (char *)&fib;

  atr[0].atr$w_size = ATR$S_RECATTR;
  atr[0].atr$w_type = ATR$C_RECATTR;
  atr[0].atr$l_addr = &fat;
  atr[1].atr$w_size = 0;
  atr[1].atr$w_type = 0;

  /*
  ** Before doing a write we determine the size of the file
  ** and if we need to extend it to perform the requested
  ** I/O.
  */
  status = sys$qiow(EFN$C_ENF, pFile->chan, IO$_ACCESS, iosb, 0,
      0, &fibdsc, 0, 0, 0, atr, 0);
  if( $VMS_STATUS_SUCCESS(status)
      && $VMS_STATUS_SUCCESS(status = iosb[0]) ){
    filesize = (fat.fat$w_hiblkh << 16) | fat.fat$w_hiblkl;
    needed = (vbn + (amt / SQLITE_DEFAULT_SECTOR_SIZE)) + 1;

    if( pFile->szHint > 0 ){
      needed = pFile->szHint > needed ? pFile->szHint : needed;
      pFile->szHint = 0;
    }

    if( filesize < needed ){
      fib.fib$v_extend = 1;
      fib.fib$l_exvbn = 0;
      fib.fib$l_exsz = 0;

      /*
      ** Here we first check to see if the user has indicated their
      ** own extension size, otherwise we attempt to respect the
      ** default extensions of the file.  Someone might have
      ** SET FILE/EXTENSION on the database file as a performance
      ** measure. However, if none is set, we just extend by how much
      ** we need of the system default, whichever is larger.
      */
      if( pFile->szChunk > 0 ){
        do{
          fib.fib$l_exsz += pFile->szChunk;
        }while( fib.fib$l_exsz < needed );
      }else{
        if( fat.fat$w_defext ){
          do{
            fib.fib$l_exsz += fat.fat$w_defext;
          }while( fib.fib$l_exsz < needed );
        }else{
          jpilst[0].itmcod = JPI$_RMS_EXTEND_SIZE;
          jpilst[0].buflen = sizeof(extend);
          jpilst[0].bufadr = &extend;
          jpilst[0].retlen = 0;
          jpilst[1].itmcod = 0;
          jpilst[1].buflen = 0;

          sys$getjpiw(EFN$C_ENF, 0, 0, jpilst, iosb, 0, 0);

          fib.fib$l_exsz = extend ? extend : needed;
          fib.fib$v_aldef = 1;
        }
      }

      status = sys$qiow(EFN$C_ENF, pFile->chan, IO$_MODIFY, iosb,
          0, 0, &fibdsc, 0, 0, 0, 0, 0);
      if( $VMS_STATUS_SUCCESS(status)
          && $VMS_STATUS_SUCCESS(status = iosb[0]) ){
        fib.fib$v_extend = 0;
        fib.fib$l_exvbn += fib.fib$l_exsz;

        fat.fat$w_ffbyte = 0;
        fat.fat$w_efblkh = (unsigned short)(fib.fib$l_exvbn >> 16);
        fat.fat$w_efblkl = (unsigned short)fib.fib$l_exvbn;

        status = sys$qiow(EFN$C_ENF, pFile->chan, IO$_MODIFY, iosb,
            0, 0, &fibdsc, 0, 0, 0, atr, 0);
        if( $VMS_STATUS_SUCCESS(status) ){
          status = iosb[0];
        }
      }
Beispiel #25
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;
  }
Beispiel #26
0
void vms_bind_sym(DSO *dso, const char *symname, void **sym)
{
    DSO_VMS_INTERNAL *ptr;
    int status;
# if 0
    int flags = (1 << 4);       /* LIB$M_FIS_MIXEDCASE, but this symbol isn't
                                 * defined in VMS older than 7.0 or so */
# else
    int flags = 0;
# endif
    struct dsc$descriptor_s symname_dsc;

/* Arrange 32-bit pointer to (copied) string storage, if needed. */
# if __INITIAL_POINTER_SIZE == 64
#  define SYMNAME symname_32p
#  pragma pointer_size save
#  pragma pointer_size 32
    char *symname_32p;
#  pragma pointer_size restore
    char symname_32[NAMX_MAXRSS + 1];
# else                          /* __INITIAL_POINTER_SIZE == 64 */
#  define SYMNAME ((char *) symname)
# endif                         /* __INITIAL_POINTER_SIZE == 64 [else] */

    *sym = NULL;

    if ((dso == NULL) || (symname == NULL)) {
        DSOerr(DSO_F_VMS_BIND_SYM, ERR_R_PASSED_NULL_PARAMETER);
        return;
    }
# if __INITIAL_POINTER_SIZE == 64
    /* Copy the symbol name to storage with a 32-bit pointer. */
    symname_32p = symname_32;
    strcpy(symname_32p, symname);
# endif                         /* __INITIAL_POINTER_SIZE == 64 [else] */

    symname_dsc.dsc$w_length = strlen(SYMNAME);
    symname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
    symname_dsc.dsc$b_class = DSC$K_CLASS_S;
    symname_dsc.dsc$a_pointer = SYMNAME;

    if (sk_void_num(dso->meth_data) < 1) {
        DSOerr(DSO_F_VMS_BIND_SYM, DSO_R_STACK_ERROR);
        return;
    }
    ptr = (DSO_VMS_INTERNAL *)sk_void_value(dso->meth_data,
                                            sk_void_num(dso->meth_data) - 1);
    if (ptr == NULL) {
        DSOerr(DSO_F_VMS_BIND_SYM, DSO_R_NULL_HANDLE);
        return;
    }

    if (dso->flags & DSO_FLAG_UPCASE_SYMBOL)
        flags = 0;

    status = do_find_symbol(ptr, &symname_dsc, sym, flags);

    if (!$VMS_STATUS_SUCCESS(status)) {
        unsigned short length;
        char errstring[257];
        struct dsc$descriptor_s errstring_dsc;

        errstring_dsc.dsc$w_length = sizeof(errstring);
        errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
        errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
        errstring_dsc.dsc$a_pointer = errstring;

        *sym = NULL;

        status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);

        if (!$VMS_STATUS_SUCCESS(status))
            lib$signal(status); /* This is really bad.  Abort! */
        else {
            errstring[length] = '\0';

            DSOerr(DSO_F_VMS_BIND_SYM, DSO_R_SYM_FAILURE);
            if (ptr->imagename_dsc.dsc$w_length)
                ERR_add_error_data(9,
                                   "Symbol ", symname,
                                   " in ", ptr->filename,
                                   " (", ptr->imagename, ")",
                                   ": ", errstring);
            else
                ERR_add_error_data(6,
                                   "Symbol ", symname,
                                   " in ", ptr->filename, ": ", errstring);
        }
        return;
    }
    return;
}
Beispiel #27
0
static char *vms_merger(DSO *dso, const char *filespec1,
                        const char *filespec2)
{
    int status;
    int filespec1len, filespec2len;
    struct FAB fab;
    struct NAMX_STRUCT nam;
    char esa[NAMX_MAXRSS + 1];
    char *merged;

/* Arrange 32-bit pointer to (copied) string storage, if needed. */
# if __INITIAL_POINTER_SIZE == 64
#  define FILESPEC1 filespec1_32p;
#  define FILESPEC2 filespec2_32p;
#  pragma pointer_size save
#  pragma pointer_size 32
    char *filespec1_32p;
    char *filespec2_32p;
#  pragma pointer_size restore
    char filespec1_32[NAMX_MAXRSS + 1];
    char filespec2_32[NAMX_MAXRSS + 1];
# else                          /* __INITIAL_POINTER_SIZE == 64 */
#  define FILESPEC1 ((char *) filespec1)
#  define FILESPEC2 ((char *) filespec2)
# endif                         /* __INITIAL_POINTER_SIZE == 64 [else] */

    if (!filespec1)
        filespec1 = "";
    if (!filespec2)
        filespec2 = "";
    filespec1len = strlen(filespec1);
    filespec2len = strlen(filespec2);

# if __INITIAL_POINTER_SIZE == 64
    /* Copy the file names to storage with a 32-bit pointer. */
    filespec1_32p = filespec1_32;
    filespec2_32p = filespec2_32;
    strcpy(filespec1_32p, filespec1);
    strcpy(filespec2_32p, filespec2);
# endif                         /* __INITIAL_POINTER_SIZE == 64 [else] */

    fab = cc$rms_fab;
    nam = CC_RMS_NAMX;

    FAB_OR_NAML(fab, nam).FAB_OR_NAML_FNA = FILESPEC1;
    FAB_OR_NAML(fab, nam).FAB_OR_NAML_FNS = filespec1len;
    FAB_OR_NAML(fab, nam).FAB_OR_NAML_DNA = FILESPEC2;
    FAB_OR_NAML(fab, nam).FAB_OR_NAML_DNS = filespec2len;
    NAMX_DNA_FNA_SET(fab)

        nam.NAMX_ESA = esa;
    nam.NAMX_ESS = NAMX_MAXRSS;
    nam.NAMX_NOP = NAM$M_SYNCHK | NAM$M_PWD;
    SET_NAMX_NO_SHORT_UPCASE(nam);

    fab.FAB_NAMX = &nam;

    status = sys$parse(&fab, 0, 0);

    if (!$VMS_STATUS_SUCCESS(status)) {
        unsigned short length;
        char errstring[257];
        struct dsc$descriptor_s errstring_dsc;

        errstring_dsc.dsc$w_length = sizeof(errstring);
        errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
        errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
        errstring_dsc.dsc$a_pointer = errstring;

        status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);

        if (!$VMS_STATUS_SUCCESS(status))
            lib$signal(status); /* This is really bad.  Abort! */
        else {
            errstring[length] = '\0';

            DSOerr(DSO_F_VMS_MERGER, DSO_R_FAILURE);
            ERR_add_error_data(7,
                               "filespec \"", filespec1, "\", ",
                               "defaults \"", filespec2, "\": ", errstring);
        }
        return (NULL);
    }

    merged = OPENSSL_malloc(nam.NAMX_ESL + 1);
    if (!merged)
        goto malloc_err;
    strncpy(merged, nam.NAMX_ESA, nam.NAMX_ESL);
    merged[nam.NAMX_ESL] = '\0';
    return (merged);
 malloc_err:
    DSOerr(DSO_F_VMS_MERGER, ERR_R_MALLOC_FAILURE);
}
Beispiel #28
0
Boolean Process::loadProcessInfo (int &pIndex)
{
  int status;
  unsigned long maxprocount;
  __int64 qpid;
  char handle[100];

  Boolean stat;

  if ((maxprocount = getmaxprocount ()) == 0)
  {
    return false;
  }

  if (pIndex == 0)
  {
    if (proc_table != NULL)
    {
      free (proc_table);
    }
    proc_table = (proc_info_t) calloc (maxprocount + 1, sizeof (struct proc_info));
    pInfo = pData = proc_table;

    jpictx2 = 0;
    procCount = 0;
    ii = 1;

    itmlst3[0].wlength = 0;
    itmlst3[0].wcode = PSCAN$_MODE;
    itmlst3[0].pbuffer = (void *) JPI$K_OTHER;
    itmlst3[0].pretlen = NULL;
    itmlst3[1].wlength = 0;
    itmlst3[1].wcode = 0;
    itmlst3[1].pbuffer = NULL;
    itmlst3[1].pretlen = NULL;

    status = sys$process_scan (&jpictx2, itmlst3);
    if (!$VMS_STATUS_SUCCESS (status))
    {
      return status;
    }

    stat = buildProcessTable();

    jpictx2 = 0;
    itmlst3[0].wlength = 0;
    itmlst3[0].wcode = PSCAN$_MODE;
    itmlst3[0].pbuffer = (void *) JPI$K_BATCH;
    itmlst3[0].pretlen = NULL;
    itmlst3[1].wlength = 0;
    itmlst3[1].wcode = 0;
    itmlst3[1].pbuffer = NULL;
    itmlst3[1].pretlen = NULL;

    status = sys$process_scan (&jpictx2, itmlst3);
    if (!$VMS_STATUS_SUCCESS (status))
    {
      return status;
    }

    stat = buildProcessTable();

    jpictx2 = 0;
    itmlst3[0].wlength = 0;
    itmlst3[0].wcode = PSCAN$_MODE;
    itmlst3[0].pbuffer = (void *) JPI$K_NETWORK;
    itmlst3[0].pretlen = NULL;
    itmlst3[1].wlength = 0;
    itmlst3[1].wcode = 0;
    itmlst3[1].pbuffer = NULL;
    itmlst3[1].pretlen = NULL;

    status = sys$process_scan (&jpictx2, itmlst3);
    if (!$VMS_STATUS_SUCCESS (status))
    {
      return status;
    }

    stat = buildProcessTable();

    jpictx2 = 0;
    itmlst3[0].wlength = 0;
    itmlst3[0].wcode = PSCAN$_MODE;
    itmlst3[0].pbuffer = (void *) JPI$K_INTERACTIVE;
    itmlst3[0].pretlen = NULL;
    itmlst3[1].wlength = 0;
    itmlst3[1].wcode = 0;
    itmlst3[1].pbuffer = NULL;
    itmlst3[1].pretlen = NULL;

    status = sys$process_scan (&jpictx2, itmlst3);
    if (!$VMS_STATUS_SUCCESS (status))
    {
      return status;
    }

    stat = buildProcessTable();

    pInfo = pData;
  }
  else
  {
    if (ii < procCount)
    {
      pInfo++;
      ii++;
    }
    else
    {
      return false;
    }
  }

  if (procCount > 0)
  {
    return true;
  }
  else
  {
    return false;
  }
}
Beispiel #29
0
const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
{
    int status;
    char *p, *r;
    size_t l;
    unsigned long flags = 0;

/* Arrange 32-bit pointer to (copied) string storage, if needed. */
#if __INITIAL_POINTER_SIZE == 64
# pragma pointer_size save
# pragma pointer_size 32
    char *ctx_filespec_32p;
# pragma pointer_size restore
    char ctx_filespec_32[NAMX_MAXRSS + 1];
#endif                          /* __INITIAL_POINTER_SIZE == 64 */

#ifdef NAML$C_MAXRSS
    flags |= LIB$M_FIL_LONG_NAMES;
#endif

    if (ctx == NULL || directory == NULL) {
        errno = EINVAL;
        return 0;
    }

    errno = 0;
    if (*ctx == NULL) {
        size_t filespeclen = strlen(directory);
        char *filespec = NULL;

        if (filespeclen == 0) {
            errno = ENOENT;
            return 0;
        }

        /* MUST be a VMS directory specification!  Let's estimate if it is. */
        if (directory[filespeclen - 1] != ']'
            && directory[filespeclen - 1] != '>'
            && directory[filespeclen - 1] != ':') {
            errno = EINVAL;
            return 0;
        }

        filespeclen += 4;       /* "*.*;" */

        if (filespeclen > NAMX_MAXRSS) {
            errno = ENAMETOOLONG;
            return 0;
        }

        *ctx = malloc(sizeof(**ctx));
        if (*ctx == NULL) {
            errno = ENOMEM;
            return 0;
        }
        memset(*ctx, 0, sizeof(**ctx));

        strcpy((*ctx)->filespec, directory);
        strcat((*ctx)->filespec, "*.*;");

/* Arrange 32-bit pointer to (copied) string storage, if needed. */
#if __INITIAL_POINTER_SIZE == 64
# define CTX_FILESPEC ctx_filespec_32p
        /* Copy the file name to storage with a 32-bit pointer. */
        ctx_filespec_32p = ctx_filespec_32;
        strcpy(ctx_filespec_32p, (*ctx)->filespec);
#else                           /* __INITIAL_POINTER_SIZE == 64 */
# define CTX_FILESPEC (*ctx)->filespec
#endif                          /* __INITIAL_POINTER_SIZE == 64 [else] */

        (*ctx)->filespec_dsc.dsc$w_length = filespeclen;
        (*ctx)->filespec_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
        (*ctx)->filespec_dsc.dsc$b_class = DSC$K_CLASS_S;
        (*ctx)->filespec_dsc.dsc$a_pointer = CTX_FILESPEC;
    }

    (*ctx)->result_dsc.dsc$w_length = 0;
    (*ctx)->result_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
    (*ctx)->result_dsc.dsc$b_class = DSC$K_CLASS_D;
    (*ctx)->result_dsc.dsc$a_pointer = 0;

    status = lib$find_file(&(*ctx)->filespec_dsc, &(*ctx)->result_dsc,
                           &(*ctx)->VMS_context, 0, 0, 0, &flags);

    if (status == RMS$_NMF) {
        errno = 0;
        vaxc$errno = status;
        return NULL;
    }

    if (!$VMS_STATUS_SUCCESS(status)) {
        errno = EVMSERR;
        vaxc$errno = status;
        return NULL;
    }

    /*
     * Quick, cheap and dirty way to discard any device and directory, since
     * we only want file names
     */
    l = (*ctx)->result_dsc.dsc$w_length;
    p = (*ctx)->result_dsc.dsc$a_pointer;
    r = p;
    for (; *p; p++) {
        if (*p == '^' && p[1] != '\0') { /* Take care of ODS-5 escapes */
            p++;
        } else if (*p == ':' || *p == '>' || *p == ']') {
            l -= p + 1 - r;
            r = p + 1;
        } else if (*p == ';') {
            l = p - r;
            break;
        }
    }

    strncpy((*ctx)->result, r, l);
    (*ctx)->result[l] = '\0';
    str$free1_dx(&(*ctx)->result_dsc);

    return (*ctx)->result;
}
Beispiel #30
0
Boolean Process::buildProcessTable ()
{
  int status;

  itmlst3[0].wlength = sizeof (usernamebuf);
  itmlst3[0].wcode = JPI$_USERNAME;
  itmlst3[0].pbuffer = usernamebuf;
  itmlst3[0].pretlen = &usernamlen;
  itmlst3[1].wlength = 4;
  itmlst3[1].wcode = JPI$_PID;
  itmlst3[1].pbuffer = &procpid;
  itmlst3[1].pretlen = NULL;
  itmlst3[2].wlength = 4;
  itmlst3[2].wcode = JPI$_CPUTIM;
  itmlst3[2].pbuffer = &proccputim;
  itmlst3[2].pretlen = NULL;
  itmlst3[3].wlength = 4;
  itmlst3[3].wcode = JPI$_GRP;
  itmlst3[3].pbuffer = &procgrp;
  itmlst3[3].pretlen = NULL;
  itmlst3[4].wlength = 4;
  itmlst3[4].wcode = JPI$_MASTER_PID;
  itmlst3[4].pbuffer = &procppid;
  itmlst3[4].pretlen = NULL;
  itmlst3[5].wlength = 4;
  itmlst3[5].wcode = JPI$_UIC;
  itmlst3[5].pbuffer = &procuic;
  itmlst3[5].pretlen = NULL;
  itmlst3[6].wlength = sizeof (procimgnambuf);
  itmlst3[6].wcode = JPI$_IMAGNAME;
  itmlst3[6].pbuffer = procimgnambuf;
  itmlst3[6].pretlen = &procimgnamlen;
  itmlst3[7].wlength = 4;
  itmlst3[7].wcode = JPI$_PGFLQUOTA;
  itmlst3[7].pbuffer = &procpgflquo;
  itmlst3[7].pretlen = NULL;
  itmlst3[8].wlength = 4;
  itmlst3[8].wcode = JPI$_PRI;
  itmlst3[8].pbuffer = &procpri;
  itmlst3[8].pretlen = NULL;
  itmlst3[9].wlength = 4;
  itmlst3[9].wcode = JPI$_PRIB;
  itmlst3[9].pbuffer = &procbasepri;
  itmlst3[9].pretlen = NULL;
  itmlst3[10].wlength = 4;
  itmlst3[10].wcode = JPI$_STATE;
  itmlst3[10].pbuffer = &procstate;
  itmlst3[10].pretlen = NULL;
  itmlst3[11].wlength = 4;
  itmlst3[11].wcode = JPI$_WSSIZE;
  itmlst3[11].pbuffer = &procwssize;
  itmlst3[11].pretlen = NULL;
  itmlst3[12].wlength = 4;
  itmlst3[12].wcode = JPI$_LOGIN_FLAGS;
  itmlst3[12].pbuffer = &proclgnflgs;
  itmlst3[12].pretlen = NULL;
  itmlst3[13].wlength = 8;
  itmlst3[13].wcode = JPI$_LOGINTIM;
  itmlst3[13].pbuffer = &proclgntim;
  itmlst3[13].pretlen = NULL;
  itmlst3[14].wlength = sizeof (proctermbuf);
  itmlst3[14].wcode = JPI$_TERMINAL;
  itmlst3[14].pbuffer = proctermbuf;
  itmlst3[14].pretlen = &proctermlen;
  itmlst3[MAXITMLST - 1].wlength = 0;
  itmlst3[MAXITMLST - 1].wcode = 0;
  itmlst3[MAXITMLST - 1].pbuffer = NULL;
  itmlst3[MAXITMLST - 1].pretlen = NULL;

  while (1)
  {
    status = sys$getjpiw (0, &jpictx2, NULL, itmlst3, 0, NULL, 0);
    if (status == SS$_NOMOREPROC)
    {
      break;
    }
    if (!$VMS_STATUS_SUCCESS (status))
    {
      return status;
    }
    procCount++;
    usernamebuf[12] = '\0';

    pInfo->ppid = procppid;
    pInfo->pid = procpid;
    pInfo->uid = procuic & 0xFFFF;
    pInfo->pgrp = (procuic >> 16) & 0xFFFF;
    pInfo->rgid = procgrp;
    pInfo->cpu = proccputim;
    pInfo->virtual_size = procpgflquo;
    pInfo->pri = procpri;
    pInfo->base_pri = procbasepri;
    pInfo->state = procstate;
    pInfo->pset = procwssize;
    pInfo->p_stime = proclgntim;
    strncpy (pInfo->uname, usernamebuf, 12);
    strncpy (pInfo->command, procimgnambuf, 256);
    strncpy (pInfo->tty, proctermbuf, 8);
    pInfo++;
  }
  return true;
}