コード例 #1
0
ファイル: timer.c プロジェクト: epicsdeb/sdds
long memory_count()
{
    static ITEM_LIST *item;
    static long initialized = 0;
    long mem;
   
    if (!initialized) {
        /* allocate an item list structure */
        item = tmalloc((unsigned)sizeof(*item)+sizeof(long));
        item->buffer_address = tmalloc((unsigned)4);   /* 1 longword */
        item->return_length_address = tmalloc((unsigned)4); /* 1 longword */
        *((char*)item+sizeof(*item)) = 0;
        initialized = 1;
        }

    /* get global page count */
    item->code = JPI$_GPGCNT;
    item->buffer_length = 4;
    if (sys$getjpiw(0, 0, 0, item, 0, 0, 0)!=SS$_NORMAL)
        return(0);
    mem = *(item->buffer_address);

    /* get page count in working set */
    item->code = JPI$_PPGCNT;
    item->buffer_length = 4;
    if (sys$getjpiw(0, 0, 0, item, 0, 0, 0)!=SS$_NORMAL)
        return(0);

    return(mem + *(item->buffer_address));
    }
コード例 #2
0
ファイル: vmsUtils.c プロジェクト: venediktov/nedit
/*
 * ProcAlive: see if a process (identified by pID) is still alive on VMS.
 *
 *    Returns:  1 - process exists
 *	        0 - process does not exist
 *	       -1 - error getting process info
 */
int ProcAlive(const unsigned int pID)
{
    int jpiStat;
    short retLen;
    char userName[13];			/* 12 plus 1 for ending null */
    struct getJPIdescriptor {
	short bufLength;
	short itemCode;
	char  *bufAddr;
	short *retLenAddr;
	int   *endList;
    } getJPID;

    getJPID.bufLength  = 12;		/* (max) size of user name */
    getJPID.itemCode   = JPI$_USERNAME;
    getJPID.bufAddr    = userName;
    getJPID.retLenAddr = &retLen;
    getJPID.endList    = 0;
    jpiStat = sys$getjpiw(1,&pID,0,&getJPID,0,0,0);
    /* printf("in ProcAlive - jpiStat = %d, pid = %X\n", jpiStat, pID); */
    if (jpiStat == SS$_NORMAL || jpiStat == SS$_NOPRIV 
		|| jpiStat == SS$_SUSPENDED)
	return 1;			/* process exists	  */
    if (jpiStat == SS$_NONEXPR)
	return 0;			/* process does not exist */
    fprintf(stderr, "Error calling GETJPI in ProcAlive.  Status = %d\n",
	    jpiStat);
    return -1;				/* error		  */
}
コード例 #3
0
void
PCpid(
PID	*pidp)
{
	static	PID	holdpid = 0;
	static	bool	got_pid = FALSE;
	ILE3		itemlist[2];
	IOSB		iosb;

	PCstatus = OK;
	if (!got_pid)
	{
		itemlist[0].ile3$w_length = sizeof(PID);
		itemlist[0].ile3$w_code = JPI$_PID;
		itemlist[0].ile3$ps_bufaddr = (PTR)&holdpid;
		itemlist[0].ile3$ps_retlen_addr = NULL;

		itemlist[1].ile3$w_length = NULL;
		itemlist[1].ile3$w_code = NULL;
		itemlist[1].ile3$ps_bufaddr = NULL;
		itemlist[1].ile3$ps_retlen_addr = NULL;

		PCstatus = sys$getjpiw(EFN$C_ENF, 0, 0, &itemlist, &iosb, 0, 0);
		if (PCstatus & 1)
		    PCstatus = iosb.iosb$w_status;
		if (PCstatus == SS$_NORMAL)
		{
			PCstatus = OK;
			got_pid = TRUE;
		}
	}
	MEcopy((PTR)&holdpid, (u_i2)sizeof(PID), (PTR)pidp);
}
コード例 #4
0
ファイル: HTVMSUtils.c プロジェクト: AaronDP/lynx_adbshell
/* PUBLIC							HTVMS_authSysPrv()
 *		CHECKS IF THIS PROCESS IS AUTHORIZED TO ENABLE SYSPRV
 * ON ENTRY:
 *	No arguments.
 *
 * ON EXIT:
 *	returns	YES if SYSPRV is authorized
 */
BOOL HTVMS_authSysPrv(void)
{
    unsigned long Result;
    ItemStruct ItemList[2];
    unsigned long Length;
    unsigned long Buffer[2];

    /* fill Item */
    ItemList[0].BufferLength = sizeof(Buffer);
    ItemList[0].BufferAddress = (unsigned long) Buffer;
    ItemList[0].ReturnLengthAddress = (unsigned long) &Length;
    ItemList[0].ItemCode = JPI$_AUTHPRIV;

    /* terminate list */
    ItemList[1].ItemCode = 0;
    ItemList[1].BufferLength = 0;

    /* call system */
    Result = sys$getjpiw(0, 0, 0, ItemList, 0, 0, 0);

    if (Result != SS$_NORMAL)
	return (NO);

    if (Buffer[0] & PRV$M_SYSPRV)
	return (YES);

    return (NO);
}
コード例 #5
0
ファイル: sp_mgr.c プロジェクト: SysMan-One/mmk
/*
**++
**  ROUTINE:	sp_show_subprocess
**
**  FUNCTIONAL DESCRIPTION:
**
**  	Uses $GETJPI to get info on the subprocess and
**  displays it à la CTRL/T.
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	sp_show_subprocess(SPHANDLE ctx)
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int sp_show_subprocess (SPHANDLE ctx) {

    static $DESCRIPTOR(ctrstr, "<<!AD!AD !8%T !9AD CPU=!%T PF=!UL IO=!UL MEM=!UL>>");
    static int neg10000 = -10000;
    static int zero = 0;
    struct dsc$descriptor bufdsc;
    struct {
    	unsigned short len, code;
    	char *ptr;
    	unsigned int term;
    } fscnlst = {0, FSCN$_NAME, 0, 0};
    ITMLST jpilst[8];
    char nodename[33], buf[256];
    char prcnam[16], imgnam[256];
    unsigned short prcnamlen, imgnamlen, iosb[4], buflen;
    unsigned int cputim[2], xcputim;
    unsigned int pageflts, biocnt, diocnt, wssize;
    unsigned int status;

    if (!get_logical("SYS$NODE", nodename, sizeof(nodename))) nodename[0] = '\0';
    ITMLST_INIT(jpilst[0], JPI$_PRCNAM, sizeof(prcnam), prcnam, &prcnamlen);
    ITMLST_INIT(jpilst[1], JPI$_IMAGNAME, sizeof(imgnam), imgnam, &imgnamlen);
    ITMLST_INIT(jpilst[2], JPI$_CPUTIM, sizeof(xcputim), &xcputim, 0);
    ITMLST_INIT(jpilst[3], JPI$_PAGEFLTS, sizeof(pageflts), &pageflts, 0);
    ITMLST_INIT(jpilst[4], JPI$_DIOCNT, sizeof(diocnt), &diocnt, 0);
    ITMLST_INIT(jpilst[5], JPI$_BIOCNT, sizeof(biocnt), &biocnt, 0);
    ITMLST_INIT(jpilst[6], JPI$_WSSIZE, sizeof(wssize), &wssize, 0);
    ITMLST_INIT(jpilst[7], 0, 0, 0, 0);
    status = sys$getjpiw(0, &ctx->pid, 0, jpilst, iosb, 0, 0);
    if (OK(status)) status = iosb[0];
    if (!OK(status)) return SS$_NORMAL;

    while (imgnamlen > 0 && isspace(imgnam[imgnamlen-1])) imgnamlen--;
    if (imgnamlen > 0) {
    	INIT_SDESC(bufdsc, imgnamlen, imgnam);
    	status = sys$filescan(&bufdsc, &fscnlst, 0);
    	if (!OK(status)) {
    	    fscnlst.ptr = imgnam;
    	    fscnlst.len = imgnamlen;
    	}
    } else {
    	strcpy(imgnam, "  (DCL)");
    	imgnamlen = 7;
    }
    lib$emul(&neg10000, &xcputim, &zero, cputim);
    INIT_SDESC(bufdsc, sizeof(buf), buf);
    status = sys$fao(&ctrstr, &buflen, &bufdsc, strlen(nodename), nodename,
    	prcnamlen, prcnam, 0, fscnlst.len, fscnlst.ptr,
    	cputim, pageflts, diocnt+biocnt, wssize);
    if (OK(status)) {
    	bufdsc.dsc$w_length  = buflen;
    	lib$put_output(&bufdsc);
    }

    return SS$_NORMAL;

} /* sp_show_subprocess */
コード例 #6
0
main () {

   /* Find my group and member IDs for $getjpi */  
   status = sys$getjpiw(0,0,0,getjpi_items,&jpi_iosb,0,0);
   if (!(status & 1)) lib$signal(status);
   if (!(jpi_iosb.iosb_status & 1)) lib$signal(jpi_iosb.iosb_status);

   /* Build the pscan stuff */
   assert (psitems[1].code == PSCAN$_GRP);
   psitems[1].val = mygrp;
   assert (psitems[2].code == PSCAN$_MEM);
   psitems[2].val = mymem;

   /* Build the context for $getjpi */
   status = sys$process_scan(&ps_ctx, &psitems);
   if (!(status & 1)) lib$signal(status);
   status = lib$date_time(&time_desc);
   printf("\n         Checking uptime agent status at: %s\n",timestring);


   printf("\n               Image         Node       Pid       CPUsec        ppgcnt  gpgcnt\n");
   printf("----------------------------------------------------------------------------------\n");

   /* Run the context until all processes found */
   while (TRUE) {
      status = sys$getjpiw (EFN$C_ENF, &ps_ctx, 0, getjpi_items, &jpi_iosb, 0, 0);
      if (jpi_iosb.iosb_status == SS$_NOMOREPROC) {
         printf("----------------------------------------------------------------------------------\n");
         break;
      }else{
         if (!(jpi_iosb.iosb_status & 1)) lib$signal(jpi_iosb.iosb_status);
         total_mem = pages + gblpages;
         lib$trim_filespec(&img_desc,&short_desc,&sizeof(shortname));  /* Just the filename  */
         if (strstr(shortname,"UPTIME-AGENT") != NULL) { 
            status = sys$asctim(&timlen,&time_desc,&logintime,timeflag);  /* Convert binary time */
            printf ("%20s       %6s  %x     %8.1f        %6d  %6d\n",
               shortname,nodename,mypid,(float)cputime/100,pages,gblpages);   
         } 
      }
   }
}
コード例 #7
0
ファイル: libgetjpi.c プロジェクト: ztmr/FreeVMS
int lib$getjpi(signed int * item_code, unsigned int * process_id, void * process_name, signed int * longword_integer_value, void * resultant_string, unsigned short * resultant_length) {
  struct _iosb iosb;
  struct item_list_3 itmlst[2];
  int retlen;
  int * retlenaddr;
  int buflen;
  void * bufaddr;
  struct dsc$descriptor * dsc;
  struct dsc$descriptor * res = resultant_string;
  int sts;
  int efn;

  sts = lib$get_ef(&efn);
  if ((sts&1)==0)
    return sts;

  // doing some approximations since I can not now decide the return type
  
  if (process_id) {
    buflen = 4;
    bufaddr = process_id;
    retlenaddr = &retlen;
  } else {
    if (res) {
      buflen = res->dsc$w_length;
      bufaddr = res->dsc$a_pointer;
    } else {
      buflen = 4;
      bufaddr = longword_integer_value;
    }
    if (resultant_length)
      retlenaddr = resultant_length;
    else
      retlenaddr = &retlen;
  }
  
  itmlst[0].item_code=*item_code;
  itmlst[0].buflen=buflen;
  itmlst[0].retlenaddr=retlenaddr;
  itmlst[0].bufaddr=bufaddr;
  itmlst[1].item_code=0;

  sts=sys$getjpiw(efn,process_id,process_name,itmlst,&iosb,0,0,0);

  if ((sts&1)==0)
    return sts;

  sts = lib$free_ef(&efn);
  if ((sts&1)==0)
    return sts;

  return sts;
}
コード例 #8
0
ファイル: rand_vms.c プロジェクト: RyunosukeOno/rayjack
int RAND_poll(void)
	{
	long pid, iosb[2];
	int status = 0;
	struct
		{
		short length, code;
		long *buffer;
		int *retlen;
		} item[32], *pitem;
	unsigned char data_buffer[256];
	short total_length = 0;
	struct items_data_st *pitems_data;

	pitems_data = items_data;
	pitem = item;

	/* Setup */
	while (pitems_data->length
		&& (total_length + pitems_data->length <= 256))
		{
		pitem->length = pitems_data->length;
		pitem->code = pitems_data->code;
		pitem->buffer = (long *)&data_buffer[total_length];
		pitem->retlen = 0;
		total_length += pitems_data->length;
		pitems_data++;
		pitem++;
		}
	pitem->length = pitem->code = 0;

	/*
	 * Scan through all the processes in the system and add entropy with
	 * results from the processes that were possible to look at.
	 * However, view the information as only half trustable.
	 */
	pid = -1;			/* search context */
	while ((status = sys$getjpiw(0, &pid,  0, item, iosb, 0, 0))
		!= SS$_NOMOREPROC)
		{
		if (status == SS$_NORMAL)
			{
			RAND_add( (PTR_T)data_buffer, total_length,
			 total_length/2);
			}
		}
	sys$gettim(iosb);
	RAND_add( (PTR_T)iosb, sizeof(iosb), sizeof(iosb)/2);
	return 1;
}
コード例 #9
0
uint4	get_proc_info(uint4 pid, uint4 *time, uint4 *icount)
{
	struct
	{
		item_list_3	item[2];
		int4		terminator;
	} item_list;
	unsigned short	iosb[4], retlen, retlen1;
	uint4		status;
	uint4		prvadr[2], prvprv[2];

	GTMSECSHR_SET_PRIV(PRV$M_WORLD, status);
	if (SS$_NORMAL == status)
	{
		item_list.item[0].buffer_length		= SIZEOF(*icount);
		item_list.item[0].item_code		= JPI$_IMAGECOUNT;
		item_list.item[0].buffer_address	= icount;
		item_list.item[0].return_length_address = &retlen1;
		if (NULL != time)
		{
			item_list.item[1].buffer_length		= SIZEOF(uint4) * 2;
			item_list.item[1].item_code		= JPI$_LOGINTIM;
			item_list.item[1].buffer_address	= time;
			item_list.item[1].return_length_address = &retlen;
		} else	/* from is_proc_alive, no need for LOGINTIM which may require an INSWAP */
		{	/* each of these is a short */
			item_list.item[1].buffer_length		= 0;
			item_list.item[1].item_code		= 0;
		}
		item_list.terminator			= 0;
		status = sys$getjpiw(EFN$C_ENF, &pid, NULL, &item_list, iosb, NULL, 0);
		if (SS$_NORMAL == status)
			status = iosb[0];
		GTMSECSHR_REL_PRIV;
	}
	return status;
}
コード例 #10
0
static int 
vms_ualarm(int mseconds, int interval)
{
    Alarm *a, abase;
    struct item_list3 {
        word length;
        word code;
        void *bufaddr;
        void *retlenaddr;
    } ;
    static struct item_list3 itmlst[2];
    static int first = 1;
    unsigned long asten;
    int iss, enabled;

    if (first) {
        first = 0;
        itmlst[0].code       = JPI$_ASTEN;
        itmlst[0].length     = sizeof(asten);
        itmlst[0].retlenaddr = NULL;
        itmlst[1].code       = 0;
        itmlst[1].length     = 0;
        itmlst[1].bufaddr    = NULL;
        itmlst[1].retlenaddr = NULL;

        iss = lib$get_ef(&alarm_ef);
        if (VMSERR(iss)) lib$signal(iss);

        a0 = &alarm_base;
        a0->function = UAL_NULL;
    }
    itmlst[0].bufaddr    = &asten;
    
    iss = sys$getjpiw(0,0,0,itmlst,0,0,0);
    if (VMSERR(iss)) lib$signal(iss);
    if (!(asten&0x08)) return -1;

    a = &abase;
    if (mseconds) {
        a->function = UAL_SET;
    } else {
        a->function = UAL_CLEAR;
    }

    us_to_VMS(mseconds, a->delay);
    if (interval) {
        us_to_VMS(interval, a->interval);
        a->repeat = 1;
    } else 
        a->repeat = 0;

    iss = sys$clref(alarm_ef);
    if (VMSERR(iss)) lib$signal(iss);

    iss = sys$dclast(ualarm_AST,a,0);
    if (VMSERR(iss)) lib$signal(iss);

    iss = sys$waitfr(alarm_ef);
    if (VMSERR(iss)) lib$signal(iss);

    if (a->function == UAL_ACTIVE) 
        return VMS_to_us(a->remain);
    else
        return 0;
}
コード例 #11
0
ファイル: Process_Vms.cpp プロジェクト: deleisha/neopegasus
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;
}
コード例 #12
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;
}
コード例 #13
0
ファイル: os_vms.c プロジェクト: SysMan-One/unqlite
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];
        }
      }
コード例 #14
0
ファイル: co_tree.c プロジェクト: Strongc/proview
main ()
{
    tree_sTable	*tp;
    sNode		*np;
    int		key;
    int		i;
    char		s[256];
    char		*cp;
    char		c;

    tp = tree_CreateTable(sizeof(int), offsetof(sNode, key), sizeof(sNode), 100, tree_eComp_int32, NULL);

    for (i = 0; i < 1000; i += 10) {
        tree_Insert(tp, &i);
    }

    for ( ;;) {
        printf("Command: ");
        cp = gets(s);
        c = s[0];
        if (cp == NULL || c == '\0') {
            printf("\nGoodbye\n");
            return;
        }
        switch (c) {
        case 'i':
        case 'I':
            printf("Insert, Key: ");
            gets(s);
            key = atoi(s);
            if (tree_Find(tp, &key) == NULL) {
                tree_Insert(tp, &key);
            } else
                printf("\nKey allready exists!\n");
            break;
        case 'd':
        case 'D':
            printf("Delete, Key: ");
            gets(s);
            key = atoi(s);
            if ((np = tree_Find(tp, &key)) != NULL) {
                tree_Remove(tp, &key);
            } else
                printf("\nKey does not exist!\n");
            break;
        case 'f':
        case 'F':
            printf("Find, Key: ");
            gets(s);
            key = atoi(s);
            if ((np = tree_Find(tp, &key)) == NULL) {
                printf("\nKey does not exist!\n");
            } else
                printf("\nKey exists! %d\n", np->key);
            break;
        case 's':
        case 'S':
            printf("Find successor, Key: ");
            gets(s);
            key = atoi(s);
            if ((np = tree_FindSuccessor(tp, &key)) == NULL) {
                printf("\nKey does not exist!\n");
            } else
                printf("\nKey exists! %d\n", np->key);
            break;
        case 'p':
        case 'P':
            printf("Find predecessor, Key: ");
            gets(s);
            key = atoi(s);
            if ((np = tree_FindPredecessor(tp, &key)) == NULL) {
                printf("\nKey does not exist!\n");
            } else
                printf("\nKey exists! %d\n", np->key);
            break;
#if 0
        case 't':
        case 'T':
            printf("Start: ");
            gets(s);
            start = atoi(s);
            printf("Stop: ");
            gets(s);
            stop = atoi(s);
            printf("Order: ");
            gets(s);
            c = s[0];
            switch (c) {
            case 's':
            case 'S':
                printf("\navl-tree\n");
                i = start;
                j = stop;
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    if (TreeSearch(tp,i) == tp->Null) {
                        np = TreeAlloc(tp, i);
                        TreeInsert(tp, np);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);

                i = start;
                j = stop;
                printf("\nlib$tree\n");
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    sts = lib$lookup_tree(&ltp, i, Compare, &lnp);
                    if (!(sts & 1)) {
                        lib$insert_tree(&ltp, i, &0, Compare, Alloc, &lnp, 0);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);
                break;
            case 'd':
            case 'D':
                i = start;
                j = stop;
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    if ((np = TreeSearch(tp,i)) != tp->Null) {
                        TreeDelete(tp, np);
                    } else {
                        printf("Could not find %d\n", i);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);
                break;
            case 'f':
            case 'F':
                printf("\navl-tree\n");
                i = start;
                j = stop;
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    if ((np = TreeSearch(tp,i)) != tp->Null) {
                    } else {
                        printf("Could not find %d\n", i);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);

                i = start;
                j = stop;
                printf("\nlib$tree\n");
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    sts = lib$lookup_tree(&ltp, i, Compare, &lnp);
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);
                break;
            case 'b':
            case 'B':
                i = start;
                j = stop;
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; j--) {
                    if (TreeSearch(tp,j) == tp->Null) {
                        np = TreeAlloc(tp, j);
                        TreeInsert(tp, np);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);
                break;
            case 'r':
            case 'R':
                i = start;
                j = stop;
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    k = 65535 & rand();
                    if (TreeSearch(tp,k) == tp->Null) {
                        np = TreeAlloc(tp, k);
                        TreeInsert(tp, np);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);
                break;
            default:
                printf("Illegal order!\n");
                break;
            }
            break;
        case 'p':
        case 'P':
            tp->ErrorCount = 0;
            tp->HZCount = 0;
            tp->HNCount = 0;
            tp->HPCount = 0;
            maxlevel = 0;
            count = 0;
            hight = 0;
            TreePrint(tp, tp->Root, NULL, NULL,0);
            TreeCheck (tp, tp->Root, &count, &maxlevel, &hight, 0);
            printf("Hight: %d\n", hight);
#if 0
            TreePrintInorder(tp, tp->Root, 0);
#endif
            sp = TreeMinimum(tp, tp->Root);
            ep = TreeMaximum(tp, tp->Root);
            op = sp;
            for (np = TreeSuccessor(tp, op); op != ep; np = TreeSuccessor(tp, np)) {
#if 0
                printf("Key: %d\n", op->Key);
#endif
                if (op->Key >= np->Key)
                    tp->ErrorCount++;
                op = np;
            }
            printf("Hight.......: %d\n", hight);
            printf("Insert......: %d\n", tp->Insert);
            printf("Search......: %d\n", tp->Search);
            printf("Delete......: %d\n", tp->Delete);
            printf("NodeCount...: %d\n", tp->NodeCount);
            printf("FreeCount...: %d\n", tp->FreeCount);
            printf("MaxDepth....: %d\n", tp->MaxDepth);
            printf("HZCount.....: %d\n", tp->HZCount);
            printf("HNCount.....: %d\n", tp->HNCount);
            printf("HPCount.....: %d\n", tp->HPCount);
            printf("LLCount.....: %d\n", tp->LLCount);
            printf("LRCount.....: %d\n", tp->LRCount);
            printf("RLCount.....: %d\n", tp->RLCount);
            printf("RRCount.....: %d\n", tp->RRCount);
            printf("AllocCount..: %d\n", tp->AllocCount);
            printf("MallocCount.: %d\n", tp->MallocCount);
            printf("ErrorCount..: %d\n", tp->ErrorCount);
            count = maxlevel = 0;
            Print(ltp, &count, &maxlevel, 0);
            printf("\nlib$tree\n");
            printf("Count.......: %d\n", count);
            printf("MaxDepth....: %d\n", maxlevel);
            break;
        case 'l':
        case 'L':
            TreePrintInorder(tp, tp->Root, 0);
            break;
#endif
        case 'q':
        case 'Q':
            printf("\nGoodbye\n");
            return;
            break;
        default:
            printf("Illegal command!\n");

            break;
        }
    }
}
コード例 #15
0
ファイル: rand_vms.c プロジェクト: Vonage/openssl
int RAND_poll_ex(RAND_poll_fn cb, void *arg)
{
    /* determine the number of items in the JPI array */
    struct items_data_st item_entry;
    int item_entry_count = OSSL_NELEM(items_data);
    /* Create the JPI itemlist array to hold item_data content */
    struct {
        short length, code;
        int *buffer;
        int *retlen;
    } item[item_entry_count], *pitem;
    struct items_data_st *pitems_data;
    int data_buffer[(item_entry_count * 2) + 4]; /* 8 bytes per entry max */
    int iosb[2];
    int sys_time[2];
    int *ptr;
    int i, j ;
    int tmp_length   = 0;
    int total_length = 0;

    /* Setup itemlist for GETJPI */
    pitems_data = items_data;
    for (pitem = item; pitems_data->length != 0; pitem++) {
        pitem->length = pitems_data->length;
        pitem->code   = pitems_data->code;
        pitem->buffer = &data_buffer[total_length];
        pitem->retlen = 0;
        /* total_length is in longwords */
        total_length += pitems_data->length / 4;
        pitems_data++;
    }
    pitem->length = pitem->code = 0;

    /* Fill data_buffer with various info bits from this process */
    if (sys$getjpiw(EFN$C_ENF, NULL, NULL, item, &iosb, 0, 0) != SS$_NORMAL)
        return 0;

    /* Now twist that data to seed the SSL random number init */
    for (i = 0; i < total_length; i++) {
        sys$gettim((struct _generic_64 *)&sys_time[0]);
        srand(sys_time[0] * data_buffer[0] * data_buffer[1] + i);

        if (i == (total_length - 1)) { /* for JPI$_FINALEXC */
            ptr = &data_buffer[i];
            for (j = 0; j < 4; j++) {
                data_buffer[i + j] = ptr[j];
                /* OK to use rand() just to scramble the seed */
                data_buffer[i + j] ^= (sys_time[0] ^ rand());
                tmp_length++;
            }
        } else {
            /* OK to use rand() just to scramble the seed */
            data_buffer[i] ^= (sys_time[0] ^ rand());
        }
    }

    total_length += (tmp_length - 1);

    /* size of seed is total_length*4 bytes (64bytes) */
    cb(arg, (PTR_T)data_buffer, total_length * 4, total_length * 2);
    return 1;
}
コード例 #16
0
asmlinkage int exe$getjpiw_wrap(struct struct_getjpi *s)
{
    return exe$getjpiw(s->efn,s->pidadr,s->prcnam,s->itmlst,s->iosb,s->astadr,s->astprm);
}