cuserid -- Get Current Userid

SYNOPSIS

 #include <lcio.h>

 char *cuserid(char *name);
 

DESCRIPTION

cuserid gets the userid associated with the current job or interactive session.

The argument to cuserid should be NULL, or it should address a character array (name) whose size is at least L_cuserid. The symbol L_cuserid is defined in the header file <lcio.h>.

If the argument is not NULL, the userid (followed by '\0') is copied into name. If the argument is NULL, the userid can only be accessed by using the value returned by cuserid.

Under CMS and TSO, the userid is defined by VM or TSO, respectively. Under MVS batch, the userid is defined only if RACF (or a similar product) is installed.

RETURN VALUE

cuserid returns a pointer to the userid. If the argument to cuserid is NULL, the return value is in static storage and may be overlaid by the next call to cuserid.

DIAGNOSTICS

If no userid can be determined, cuserid returns a pointer to a string with length 0.

IMPLEMENTATION

The size of the string where the userid is stored is determined by the constant L_cuserid, defined in the header file <lcio.h>.

Under CMS, the userid is returned by the VM control program (CP).

EXAMPLE

  #include <lcio.h>
  #include <time.h>
  #include <stdlib.h>

  main()
  {
     FILE *logfile;
     char username[L_cuserid];
     time_t now;

        /* Open SYSLOG to add data to the end of the file. */
     logfile = fopen("ddn:SYSLOG", "a");
     if (!logfile){
        puts("Failed to open log file.");
        exit(EXIT_FAILURE);
     }

     cuserid(username);                     /* Get userid. */
     time(&now);
     fprintf(logfile, "File logfile last accessed by %s on %s",
             username, ctime(&now));
     fclose(logfile);
  }

 

SEE ALSO

System Interface and Environment Variables

Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.