home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_06_08 / v6n8066a.txt < prev    next >
Text File  |  1989-09-28  |  1KB  |  37 lines

  1.     1: /*
  2.     2:  * Listing 1:
  3.     3:  * 
  4.     4:  * Get login ID of current user.
  5.     5:  * This is a standard QNX library function.
  6.     6:  */
  7.     7: 
  8.     8: #include <stdio.h>       /* Standard FILE definitions  */
  9.     9: #include <systids.h>     /* Kernel task ID's           */
  10.    10: #include <task_msgs.h>   /* Kernel message structures  */
  11.    11: 
  12.    12: extern char Team_num;    /* Accounting group number    */
  13.    13: 
  14.    14: char *cuserid( ustr )
  15.    15: char *ustr;
  16.    16: {
  17.    17:   struct ta_account tsk_msg;
  18.    18:   static char userid[17];
  19.    19: 
  20.    20:   /* Message for TASK_ADMIN */
  21.    21:   tsk_msg.msg_type = TA_GET_ACCOUNT;
  22.    22: 
  23.    23:   /* ID of task group */
  24.    24:   tsk_msg.accteam = Team_num;
  25.    25: 
  26.    26:   /* Send message to TASK_ADMIN to get account info. */
  27.    27:   send( TASK_ADMIN, &tsk_msg, &tsk_msg,
  28.    28:         sizeof(struct ta_account));
  29.    29: 
  30.    30:   /* Copy returned user ID to static variable */
  31.    31:   strcpy( userid, tsk_msg.account_data.account_name );
  32.    32: 
  33.    33:   /* Return userid */
  34.    34:   return((ustr != NULL) ? strcpy( ustr, userid ) : userid);
  35.    35: }
  36.    36: 
  37.