예제 #1
0
파일: dsmuser.c 프로젝트: TangentOrg/Gemini
/* PROGRAM: dsmUserAdminStatus - sets the user name associated w/current context
 *          
 *
 * RETURNS: 0 unqualified success
 *          DSM_S_FAILURE on failure
 */
dsmStatus_t
dsmUserAdminStatus(
        dsmContext_t      *pcontext,    /* IN database context */
        psc_user_number_t  userNumber,  /* IN user number for info retrieval */
        dsmUserStatus_t   *puserStatus) /* OUT user status info structure */
{
    dbcontext_t *pdbcontext = pcontext->pdbcontext;
    usrctl_t    *pusr;

    /* find user number */
    if (userNumber > pdbcontext->pdbpub->argnusr)
        return DSM_S_INVALID_USER;

    pusr = pdbcontext->p1usrctl + userNumber;

    /* fill in structure */
    puserStatus->userNumber   = pusr->uc_usrnum;
    puserStatus->objectNumber = pusr->uc_objectId;
    puserStatus->objectType   = pusr->uc_objectType;
    puserStatus->phase        = pusr->uc_state;
    puserStatus->counter      = pusr->uc_counter;
    puserStatus->target       = pusr->uc_target;
    stncop(puserStatus->operation, pusr->uc_operation,
           sizeof(puserStatus->operation));

    return DSM_S_SUCCESS;

}  /* end dsmUserAdminStatus */
예제 #2
0
/* PROGRAM: utmypath - Creates a full path using the input components
 *
 */
DLLEXPORT TEXT *
utmypath(TEXT *pfullpath, TEXT *pdatadir,TEXT *prelname,TEXT *psuffix)
{
    int i = 0;
    TEXT dirsep;
    
#if OPSYS == WIN32API
        dirsep = '\\';
#else
        dirsep = '/';
#endif

    if (prelname[0] != dirsep
#if OPSYS == WIN32API
        && prelname[1] != ':'
#endif
        )
    {
        
        stncop(pfullpath, pdatadir, MAXUTFLEN);
        i = stlen(pdatadir);

        pfullpath[i] = dirsep;
        i++;
    }
        
    stncop(&pfullpath[i],prelname,MAXUTFLEN);
    i+= stlen(prelname);
    if(psuffix)
    {
        stncop(&pfullpath[i],psuffix,MAXUTFLEN);
        i += stlen(psuffix);
    }
    pfullpath[i] = '\0';
    i++;
    return &pfullpath[i];    
}
예제 #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
파일: bklog.c 프로젝트: TangentOrg/Gemini
int
dbLogMessage(
        dsmContext_t *pcontext,
        TEXT         *pmsg)	/* the message to be written		*/
{
        dbcontext_t *pdbcontext = pcontext->pdbcontext;
        dbshm_t *pdbpub = pdbcontext->pdbpub;
	TEXT	 msgbuf[MYBUFSZ+2];   /* 2 extra bytes for \r\n */
	int	 bufused;
	int	 ret = 0;
	LONG	 thisday;

    /* build the entire message in contiguous storage so that in */
    /* multi-thread, the messages wont inter-leave each other	 */
    thisday = uthms(msgbuf);	/* start with HH:MM:SS */
    msgbuf[8] = ' ';
    bufused = 9;
    if (pdbcontext)
	/* Add the appropriate prefix   */
    {
        /* add Server: or Usr NN: pfx*/
        bufused += dbLogAddPrefix(pcontext, msgbuf+bufused); 
    }
    bufused += stncop(msgbuf+bufused, pmsg, MYBUFSZ-bufused);
    msgbuf[bufused++] = '\n';

    /* add message to log */
    if (pdbcontext && pdbcontext->logopen)
    {   /* this piece of code to check if this is the first message */
	    /* written this day should really be protected by utlockdb  */
	    /* but utlockdb may call drmsg and that would cause infinite*/
	    /* loops.  The danger of 2 users doing this at the same tiem*/
	    /* is small and if they do, it merely messes up the .lg file*/
	    if (   !pdbcontext->shmgone && pdbcontext->pmtctl
	        && thisday != pdbpub->lastday)
	    {   pdbpub->lastday = thisday;
	        wrtdate(pdbcontext->lgfd);
	    }
        else
        {
            /* The code below prints the date to the log for gateways */
            /* Gateways do not allocate the mtctl structure so the code */
            /* above doesn't do the job.  For gateways, the lastday is */
            /* kept in the gwlgctl structure                         */
            if (!pdbcontext->shmgone && pdbcontext->pdbpub &&
                thisday != pdbcontext->pdbpub->lastday)
            {
                pdbcontext->pdbpub->lastday = thisday;
                wrtdate(pdbcontext->lgfd);
            }
        }
        wrtmsg(pcontext, pdbcontext->lgfd, msgbuf, bufused);

    }
    else ret = -1;

    /* find out if this is a server running in the foreground */
    if (pdbcontext->usertype & (BROKER | DBSERVER))
    {
        if((utCheckTerm()) == 1)
        {
	    wrtmsg(pcontext, 1, msgbuf, bufused);
            ret = 0;
        }
    }

    if (ret)
        wrtmsg(pcontext, 1, msgbuf, bufused);

    return ret;

} /* end dbLogMessage */