Initial revision

This commit is contained in:
Jeff Hill
1994-03-30 11:27:16 +00:00
parent 1c065a5b5b
commit be413851bb
4 changed files with 533 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
/*
* $Id$
* Author: Jeffrey O. Hill
* hill@luke.lanl.gov
* (505) 665 1831
* Date: 9-93
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Modification Log:
* -----------------
*
*/
/*
* ANSI includes
*/
#include "assert.h"
#include "string.h"
#include "stdlib.h"
#include "unistd.h"
#include "pwd.h"
#include "sys/param.h"
#include "iocinf.h"
/*
*
* This should work on any POSIX compliant OS
*
* o Indicates failure by setting ptr to nill
*/
char *localUserName()
{
int length;
char *pName;
char *pTmp;
pName = getlogin();
if(!pName){
pName = getpwuid(getuid())->pw_name;
if(!pName){
return NULL;
}
}
length = strlen(pName)+1;
pTmp = malloc(length);
if(!pTmp){
return pTmp;
}
strncpy(pTmp, pName, length-1);
pTmp[length-1] = '\0';
return pTmp;
}
+107
View File
@@ -0,0 +1,107 @@
/*
* $Id$
* Author: Jeffrey O. Hill
* hill@luke.lanl.gov
* (505) 665 1831
* Date: 9-93
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Modification Log:
* -----------------
*
*/
/*
* ANSI includes
*/
#include "assert.h"
#include "string.h"
#include "stdLib.h"
#include "stsdef.h"
#include "ssdef.h"
#include "iocinf.h"
/*
*
* localUserName() - for VMS
*
* o Indicates failure by setting ptr to nill
*
* !! NEEDS TO BE TESTED !!
*
*/
char *localUserName()
{
struct {
short buffer_length;
short item_code;
void *pBuf;
void *pRetSize;
unsigned long end_of_list;
}item_list;
int length;
char pName[8]; /* the size of VMS account names */
short nameLength;
char *psrc;
char *pdest;
int status;
char *pTmp;
item_list.buffer_length = sizeof(pName);
item_list.item_code = JPI$ACCOUNT; /* fetch the account name */
item_list.pBuf = pName;
item_list.pRetSize = &nameLength;
item_list.end_of_list = NULL;
status = sys$getjpiw(
NULL,
NULL,
NULL,
&item_list,
NULL,
NULL,
NULL);
if(status != SS$_NORMAL){
return NULL;
}
psrc = pName;
length = 0;
while(psrc<&pName[sizeof(pName)] && *psrc != ' '){
length++;
psrc++;
}
pTmp = (char *)malloc(length+1);
if(!pTmp){
return pTmp;
}
strncpy(pTmp, pName, length);
pTmp[length] = '\0';
return pTmp;
}
+71
View File
@@ -0,0 +1,71 @@
/*
* $Id$
* Author: Jeffrey O. Hill
* hill@luke.lanl.gov
* (505) 665 1831
* Date: 9-93
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Modification Log:
* -----------------
*
*/
/*
* ANSI includes
*/
#include "assert.h"
#include "string.h"
#include "stdlib.h"
#include "remLib.h"
#include "iocinf.h"
/*
*
* localUserName() - for vxWorks
*
* o Indicates failure by setting ptr to nill
*/
char *localUserName()
{
char *pTmp;
int length;
char pName[MAX_IDENTITY_LEN];
remCurIdGet(pName, NULL);
length = strlen(pName)+1;
pTmp = malloc(length);
if(!pTmp){
return;
}
strncpy(pTmp, pName, length-1);
pTmp[length-1] = '\0';
return pTmp;
}