Пример #1
0
/* PROGRAM: utMakePathname - concat 2 strings together and print a message if
 *              the result is too big for the buffer
 * NOTE WELL:  The scope of this routine has been narrowed to include only
 *             its standard use to append a type suffix onto a file name.
 *             Using it for any other purpose may not work on VRX or for that
 *             matter anywhere else.  - gb - 9/30/87
 *
 * RETURNS:     -1     string too large for buffer to new string
 *               0     strings concat'd
 */
LONG
utMakePathname(TEXT  *buffer,
               int   buflen,
               TEXT  *pstr1,
               TEXT  *pstr2)
{
    TEXT *nbuffer;
 
    if ( stlen(pstr1) + stlen(pstr2) + 1 > buflen )
    {
        return DBUT_S_NAME_TOO_LONG;
    }
 
    nbuffer =  (TEXT *)stcopy(stcopy(buffer, pstr1), pstr2);
    return 0;
}
Пример #2
0
/*
 * PROGRAM: utshmAddNamedSegment
 * Purpose: Add a named segment and base address for the segment to the
 *          local segment table.  (Segment MUST NOT already exist)
 * Params : SegmentName - Name for the segment to add
 *          SegmentId   - Id associated with the segment name ( >=0 )
 *                        (For NT this is the base address, OS2 the seg id)
 *          data        - 32 bit param to hang user defined data off the
 *                        memory tracking table.
 *
 * Returns: 0 on success, !0 on failure
 */
int
utshmAddNamedSegment(TEXT *SegmentName, int SegmentId, ULONG data )
{
  SHMINFO *temp;

  if (ShmInfoEntries == ShmInfoLength)
  {
    temp = lpShmInfo;
    if ((lpShmInfo = (SHMINFO *)realloc( temp,
                    sizeof(SHMINFO)*(ShmInfoLength + 10))) == (SHMINFO *)NULL)
    {
      lpShmInfo = temp;
      return -1;
    }
    ShmInfoLength += 10;
  }

  /*
   * Add the Segment Info to the table
   */
  lpShmInfo[ ShmInfoEntries ].SegmentId = SegmentId;
  lpShmInfo[ ShmInfoEntries ].UserData  = data;
  stcopy(lpShmInfo[ ShmInfoEntries ].SegmentName, SegmentName);
  ShmInfoEntries++;

  return 0;
}
Пример #3
0
DSMVOID
utmkosnm(
	     TEXT    *prefix,
	     TEXT    *pname,
	     TEXT    *buf,
	     int      len,
	     int      id)
{
    TEXT *p, *pch;

    stnclr(buf, len);
    pch = buf;
    pch = stcopy(pch, prefix);

#if OPSYS==WIN32API
    /* [johnls] */
    for (p = pname; *p && (int)(pch - buf) != len; pch++, p++)
    {
	if (*p == ':' && (*(p+1) == '\\' || *(p+1) == '/'))
	    p++;

	if (*p == '/' || *p == '\\' || *p == ':')
	    *pch = '.';
	else
	    *pch = tolower(*p);
    }
    *pch = 0;
#else
    pch = stncop(pch, pname, MIN(8, len-11-stlen(prefix)));
#endif
    if (id >= 0)
    {  
        pch = stcopy(pch, ".");
        utitoa(id, pch);
    }
} 
Пример #4
0
/* PROGRAM: utapath - given a file name, possibly fully qualified,
 *		an optional suffix, a target buffer, and the length
 *		of the target buffer, put the pieces of the file name
 *		together into the output buffer. If the pathname is
 *		not fully qualified, prepend the current working
 *		directory.
 *
 *		Needs work for MSDOS.
 *
 * RETURNS: the output buffer updated, truncated if the result is
 *		too long
 *
 */
TEXT *
utapath (TEXT	*fullpath,	/* fully qualified path name */
    	 int	 pathlen,	/* length of answer buffer */
		 TEXT	*filename,	/* file name, possibly qualified */
		 TEXT	*suffix)	/* suffix for file name */

{
    TEXT *ptxt;		/* current location */
    int	 used = 0;	/* amount used */
    int	 drvno = 0;	
#if OPSYS==WIN32API

        int  i,
             j;
#endif

    /* if file name not fully qualified, get pathname of current
       working directory into answer buffer */
#if OPSYS==UNIX
    if (*filename != '/')
#endif

#if OPSYS==WIN32API
    /* handle drive specfier, if any */
    j = stlen(filename);    
    for (i = 1, ptxt = filename; i <= j; i++, ptxt++)
        if (*ptxt == ':') break;
    if (i < j && i != 2)       
    {     /* file server volume name is specified */
        bufcop(fullpath, filename, i);
        used += i;
        filename += i;
    }
    if ((i == 2) && (filename[1] == ':'))
    {	bufcop(fullpath, filename, 2);
	used += 2;
	drvno = toupper(*filename) - 64;      /* A = 1 B = 2 ..etc */
	filename += 2;
    }
    else
	drvno = 0;   /* means use current drive */

    if ((*filename != '/') && (*filename != '\\'))
#endif  /* OPSYS == WIN32API */
    {
        
        used += utpwd (fullpath+used, pathlen ,drvno);


        if (*filename)
        {
	        if((*(fullpath+used-1) != '\\') && (*(fullpath+used-1) != '/'))
	        {    ptxt = (TEXT *)stcopy ( (TEXT *)fullpath+used, (TEXT *)"/" );
	            ++used;
	        }
        }
    }

    ptxt = fullpath + used;

    /* move in filename and suffix */
    used += stncop ( ptxt, filename, (pathlen - used) );
    ptxt = fullpath + used;
    used += stncop ( ptxt, suffix, (pathlen - used) );
    used = utfCompressPath(fullpath);
    /* return pointer to null terminator */
    return (fullpath + used);
}
Пример #5
0
/* PROGRAM: dbLogAddPrefix - puts prefix for .lg file messages
 *
 *  PREFIXES will be in the form of "XXXXNNNNN: " where
 *  the XXXX equates to a unique type (SRV, Usr, WDOG, SHUT, ...)
 *  and NNNNN equates to the usrctl number.
 *
 *  If the type is more than 4 character (i.e. BACKUP), then 
 *  we will use as much of the NNNNN space as possible to complete 
 *  the name.  For example: If the usernumber is 1, then we have
 *  4 extra spaces we can use for the name.  If the usernumber is 
 *  30040, the we have no extra spaces we can give the name, so if the
 *  name is > 4 characters long, then it will be truncated.
 *
 * RETURNS: number of characters for the prefix
 */
#define DBPREXLEN 11    /* this is the tatal size of the prefix area */
#define DBUSERNUMLEN 6	/* this is the total number of characters for usrnum 
                         * inclusive of the null terminator
                         */
int
dbLogAddPrefix( dsmContext_t *pcontext, TEXT    *pmsg)
{
    COUNT     i;
    COUNT     usrnum = -1;	/* either the usernnum or servernum */
    TEXT      numbuf[DBUSERNUMLEN];
    TEXT     *ptr;

    dbcontext_t *pdbcontext = pcontext->pdbcontext;

    if ( pdbcontext == NULL || !pdbcontext->usertype ) return 0;

    memset(numbuf, ' ', DBUSERNUMLEN);
    memset(pmsg, ' ', DBPREXLEN);


    if( (pdbcontext->usertype & (DBSERVER+BROKER)) &&
       !(pdbcontext->usertype & (NAPPLSV+WDOG)))
    {
	if (pdbcontext->argnoshm || pdbcontext->psrvctl == NULL)
        {
            if (pdbcontext->usertype & (BROKER))
            {
	        stcopy(pmsg, (TEXT *)"GEMINI   : ");
            }
            else
            {
	        stcopy(pmsg, (TEXT *)"SERVER   : ");
            }
            return DBPREXLEN;
        }
#if 0
	else
	{
            if ( (pdbcontext->usertype & (BROKER)) ||
                 (pdbcontext->psrvctl->servtype == BROKLOG) ) 
            { 
	          stcopy(pmsg, (TEXT *)"GEMINI     ");
            }
            else
            {
	          stcopy(pmsg, (TEXT *)"SRV        ");
            }
 
            if (pdbcontext->argnoshm || pdbcontext->shmgone)
            {
                /* at least put in the ": "  */
                /* point to the end of the prefix area */
                ptr = pmsg + DBPREXLEN - 1;

                /* put a ": " at the end of the buffer */
                *ptr-- = ' ';
                *ptr-- = ':';
    
                return DBPREXLEN;
            }
            else
            {
                usrnum = pdbcontext->psrvctl->sv_idx;
            }
	}
#endif
    }
    else if (pdbcontext->usertype & BIW)
    {
	stcopy (pmsg, (TEXT *)"BIW        ");
    }
    else if (pdbcontext->usertype & AIW)
    {
	stcopy (pmsg, (TEXT *)"AIW        ");
    }
    else if (pdbcontext->usertype & APW)
    {
	stcopy (pmsg, (TEXT *)"APW        ");
    }
    else if (pdbcontext->usertype & WDOG)
    {
	stcopy (pmsg, (TEXT *)"WDOG       ");
    }
    else if (pdbcontext->usertype & MONITOR)
    {
	stcopy (pmsg, (TEXT *)"MON        ");
    }
    else if (pdbcontext->usertype & BACKUP)
    {
	stcopy (pmsg, (TEXT *)"BACKUP     ");
    }
    else if (pdbcontext->usertype & RFUTIL )
    {
	stcopy (pmsg, (TEXT *)"RFUTIL     ");
    }
    /* JFJ - This is wrong DBUTIL is reserved for offline _dbutil 
       connections only. DBSHUT is reserved for shutdown. */
    else if( (pdbcontext->usertype & (DBUTIL+DBSHUT)) == (DBUTIL+DBSHUT))
    {
	stcopy (pmsg, (TEXT *)"QUIET      ");
    }
    else if (pdbcontext->usertype & DBSHUT)
    {
	stcopy (pmsg, (TEXT *)"SHUT       ");
    }
    else if (   (pdbcontext->usertype & (SELFSERVE+REMOTECLIENT))
	&& !pdbcontext->arg1usr && pcontext->pusrctl)
    {   
        stcopy (pmsg, (TEXT *)"Usr        ");
    }
    else
    {
        return 0;
    }

    if (usrnum < 0)
    {
        if (pcontext->pusrctl && !pdbcontext->shmgone)
        {
            usrnum = pcontext->pusrctl->uc_usrnum;
        }
        else
        {
            return DBPREXLEN;
        }

    }

    /* add the user number to the prefix */
    sprintf((psc_rtlchar_t *)numbuf,"%5d",usrnum);

    /* copy the usernumber into the buffer */

    /* point to the end of the prefix area */
    ptr = pmsg + DBPREXLEN - 1;
    
    /* put a ": " at the end of the buffer */
    *ptr-- = ' ';
    *ptr-- = ':';
    
    /* work backwards on the number buffer and copy the numbers until 
       you hit a blank.  This works because the formating for sprintf() */
    i = DBUSERNUMLEN -2;
    while(i >= 0 && numbuf[i] != ' ')
    {
        *ptr = numbuf[i];
        ptr--;
        i--;
    }

    return DBPREXLEN;

}
Пример #6
0
/* PROGRAM: dbLogAddPrefix - puts prefix for .lg file messages
 *
 *  PREFIXES will be in the form of "XXXXNNNNN: " where
 *  the XXXX equates to a unique type (SRV, Usr, WDOG, SHUT, ...)
 *  and NNNNN equates to the usrctl number.
 *
 *  If the type is more than 4 character (i.e. BACKUP), then
 *  we will use as much of the NNNNN space as possible to complete
 *  the name.  For example: If the usernumber is 1, then we have
 *  4 extra spaces we can use for the name.  If the usernumber is
 *  30040, the we have no extra spaces we can give the name, so if the
 *  name is > 4 characters long, then it will be truncated.
 *
 * RETURNS: number of characters for the prefix
 */
int
xdbLogAddPrefix(
        dsmContext_t *pcontext,
        TEXT         *pmsg)	/* add the prefix to the end of this msg */
{
    dbcontext_t *pdbcontext = pcontext->pdbcontext;

#if 0
    if( (pdbcontext->usertype & (DBSERVER+BROKER)) &&
       !(pdbcontext->usertype & (NAPPLSV+WDOG)))
    {
	if (pdbcontext->argnoshm || pdbcontext->psrvctl == NULL)
	    stcopy(pmsg, (TEXT *) "SERVER: ");
	else
	{
	    stcopy(pmsg, (TEXT *) "SRV 00: ");
	    utintbbn(pmsg+3, pdbcontext->psrvctl->sv_idx);
	}
	return 8;
    }
#endif
    if (pdbcontext->usertype & BIW)
    {
        stcopy (pmsg, (TEXT *) "BIW   : ");
        return (8);
    }
    else if (pdbcontext->usertype & AIW)
    {
        stcopy (pmsg, (TEXT *) "AIW   : ");
        return (8);
    }
    else if (pdbcontext->usertype & APW)
    {
        stcopy (pmsg, (TEXT *) "APW   : ");
        return (8);
    }
    else if (pdbcontext->usertype & WDOG)
    {
        stcopy (pmsg, (TEXT *) "WDOG  : ");
        return (8);
    }
    else if (pdbcontext->usertype & MONITOR)
    {
        stcopy (pmsg, (TEXT *) "MON   : ");
        return (8);
    }
    else if (pdbcontext->usertype & BACKUP)
    {
        stcopy (pmsg, (TEXT *) "BACKUP: ");
        return (8);
    }
    else if (pdbcontext->usertype & RFUTIL )
    {
	stcopy (pmsg, (TEXT *) "RFUTIL: ");
	return (8);
    }
    else if( (pdbcontext->usertype & (NAPPLSV+BROKER)) == (NAPPLSV+BROKER))
    {
	stcopy (pmsg, (TEXT *) "OIBRKR: ");
	return (8);
    }
    else if (pdbcontext->usertype & NAPPLSV)
    {
	stcopy (pmsg, (TEXT *) "OIDRVR: ");
	return (8);
    }
    else if (pdbcontext->usertype & DBSHUT)
    {
        stcopy (pmsg, (TEXT *) "SHUT  : ");
        return (8);
    }
    else
    if (   (pdbcontext->usertype & (SELFSERVE+REMOTECLIENT))
	&& !pdbcontext->arg1usr
	&& pcontext->pusrctl)
    {	stcopy(pmsg, (TEXT *) "Usr 00: ");
	utintbbn(pmsg+3, pcontext->pusrctl->uc_usrnum);
	return 8;
    }

    return 0;	/* no prefix needed */

} /* end dbLogAddPrefix */