Re: getting login name in 4GL
Posted in 1996
montgomery f. tidwell wrote: > > Howdy, > > does anyone know how i can get the login name of a User > from within a 4GL program? > > TIA > -- > There are three kinds of people in the World. Those who > can count, and those who can't. > Here's two solutions for you: Create a C function: #include <stdio.h> #include <pwd.h> get_usr_id( nargs ) int nargs; { char *usr_name; popint( &nargs ); usr_name = (char *) getlogin(); retquote(usr_name); return(1); } Link it into your 4GL: cc get_uid.c -o get_uid.o c4gl get_uid.o myfgl.4gl -o myfgl.4ge OR c4gl get_uid.c myfgl.4gl -o myfgl.4ge With RDS you need the fgiusr.c: /* fgiusr.c: INFORMIX r4gl C Function Linkage */ #include "fgicfunc.h" int get_usr_id(); cfunc_t usrcfuncs[] = { "get_usr_id",get_usr_id,1, 0, 0, 0 }; Build the runner: cfglgo fgiusr.c get_uid.c -o mynewrunner -s Create a 4GL program to test it: MAIN DEFINE user_id CHAR(8) DEFINE nargs SMALLINT # INITIALIZE user_id TO NULL LET user_id = "" LET nargs = 0 CALL get_usr_id( nargs ) RETURNING user_id DISPLAY user_id END MAIN I just tested this with the c4gl and not RDS so it should work, but your UNIX may vary...It may not fool rlogin, using the current rlogin id instead of the original user id. :-) -- \\\\|// (6 6) ==============================---o00--(_)--00o---============================ Tim Schaefer tschaefe@encore.com tschaefe@shadow.net Encore Computer Corp http://www.shadow.net/~tschaefe =============================================================================