#!/bin/sh # # This is a shell archive. To extract its contents, # execute this file with /bin/sh to create the file(s): # # get_user.c # # This shell archive created: Wed Feb 19 16:56:05 EST 1992 # echo "Extracting file get_user.c" sed -e 's/^X//' <<\SHAR_EOF > get_user.c X/* get_user.c Get User Login Name X * X * X * Summary: C function to obtain current user's login-ID X * X * Environment: SunOS 4.1, Informix-4GL X * X * Submitted by: Walt Hultgren X * X * X * This function allows an Informix-4GL routine to obtain the Login-ID X * under which the process is running. This is sometimes necessary X * since the "user" keyword can only be used in certain situations. X * X * X * Example: X * X * define user_id char(8) { user login-ID } X * X * call get_user() returning user_id X * X */ X X X#include X#include X X Xint get_user ( narg ) X X int narg; X X { X struct passwd *pwentry; /* pointer to a passwd entry */ X X static char *null_st = ""; /* pointer to a null string, as opposed to */ X /* a null string pointer */ X X X /* Get passwd entry for real uid */ X X if ( ( pwentry = getpwuid ( getuid() ) ) == (struct passwd *)NULL ) X { X pwentry->pw_name = null_st; X } X X X /* Return user name to Informix-4GL by pushing its pointer onto */ X /* I4GL's stack. */ X X retquote( pwentry->pw_name ); X X return 1; X } SHAR_EOF if [ `wc -c < get_user.c` -ne 1232 ] then echo "Lengths do not match -- Bad Copy of get_user.c" fi echo "Done."