© Digital Equipment Corporation 1994. All rights reserved. Example 11-3: Displaying User Profile Information /* show_profile.c */ #include #include #include #include #include #include #include struct itmlst { short buffer_length; short item_code; long buffer_address; long return_length_address; }; int user_context = 0 ; struct itmlst nulllist[] = { {0,0,0,0} }; int main (int argc, char *argv[]) { int userlen = 0, /* return length of strings */ editor_len = 0, form_len = 0, forwarding_len = 0, full_directory_len = 0, personal_name_len = 0, queue_len = 0, /* Flags */ auto_purge = 0, cc_prompt = 0, copy_forward = 0, copy_reply = 0, copy_send = 0 ; char user[13], editor[NAM$C_MAXRSS], form[NAM$C_MAXRSS], forwarding[NAM$C_MAXRSS], full_directory[NAM$C_MAXRSS], personal_name[NAM$C_MAXRSS], queue[NAM$C_MAXRSS] ; short new_messages = 0 ; struct itmlst jpi_list[] = { {sizeof(user) - 1, JPI$_USERNAME, user, &userlen}, {0,0,0,0}}, user_itmlst[] = { {0, MAIL$_USER_USERNAME, 0, 0}, {0,0,0,0}}, out_itmlst[] = { /* Full directory spec */ {sizeof(full_directory),MAIL$_USER_FULL_DIRECTORY,full_directory,&full_directory_len}, /* New message count */ {sizeof(new_messages), MAIL$_USER_NEW_MESSAGES, &new_messages, 0}, /* Forwarding field */ {sizeof(forwarding), MAIL$_USER_FORWARDING, forwarding, &forwarding_len}, /* Personal name field */ {sizeof(personal_name), MAIL$_USER_PERSONAL_NAME, personal_name, &personal_name_len}, /* Editor field */ {sizeof(editor), MAIL$_USER_EDITOR, editor, &editor_len}, /* CC prompting flag */ {sizeof(cc_prompt), MAIL$_USER_CC_PROMPT, &cc_prompt, 0}, /* Copy send flag */ {sizeof(copy_send), MAIL$_USER_COPY_SEND, ©_send, 0}, /* Copy reply flag */ {sizeof(copy_reply), MAIL$_USER_COPY_REPLY, ©_reply, 0}, /* Copy forward flag */ {sizeof(copy_forward), MAIL$_USER_COPY_FORWARD, ©_forward, 0}, /* Auto purge flag */ {sizeof(auto_purge), MAIL$_USER_AUTO_PURGE, &auto_purge, 0}, /* Queue field */ {sizeof(queue), MAIL$_USER_QUEUE, queue, &queue_len}, /* Form field */ {sizeof(form), MAIL$_USER_FORM, form, &form_len}, {0,0,0,0}}; int status = SS$_NORMAL ; /* Get a mail user context */ status = MAIL$USER_BEGIN(&user_context, &nulllist, &nulllist); if (status != SS$_NORMAL) return(status); if (argc > 1) { strcpy(user,argv[1]); } else { sys$getjpiw(0,0,0,jpi_list,0,0,0); user[userlen] = '\0'; }; while(isspace(user[--userlen])) user[userlen] = '\0'; user_itmlst[0].buffer_length = strlen(user); user_itmlst[0].buffer_address = user; status = MAIL$USER_GET_INFO(&user_context, user_itmlst, out_itmlst); if (status != SS$_NORMAL) return (status); /* Release the mail USER context */ status = MAIL$USER_END(&user_context, &nulllist, &nulllist); if (status != SS$_NORMAL) return(status); /* display the information just gathered */ full_directory[full_directory_len] = '\0'; printf("Your mail file directory is %s.\n", full_directory); printf("You have %d new messages.\n", new_messages); forwarding[forwarding_len] = '\0'; if (strlen(forwarding) == 0) printf("You have not set a forwarding address.\n"); else printf("Your mail is being forwarded to %s.\n", forwarding); personal_name[personal_name_len] = '\0'; printf("Your personal name is \"%s\"\n", personal_name); editor[editor_len] = '\0'; if (strlen(editor) == 0) printf("You have not specified an editor.\n"); else printf("Your editor is %s\n", editor); printf("CC prompting is %s.\n", (cc_prompt == TRUE) ? "disabled" : "enabled"); printf("Automatic copy to yourself on"); if (copy_send == TRUE) printf(" SEND"); if (copy_reply == TRUE) { if (copy_send == TRUE) printf(","); printf(" REPLY"); } if (copy_forward == TRUE) { if ((copy_reply == TRUE) || (copy_send == TRUE)) printf(","); printf(" FORWARD"); } if ((copy_reply == FALSE) && (copy_send == FALSE) && (copy_forward == FALSE)) printf(" Nothing"); printf("\n"); printf("Automatic deleted message purge is %s.\n", (auto_purge == TRUE) ? "disabled" : "enabled"); queue[queue_len] = '\0'; if (strlen(queue) == 0) printf("You have not specified a default queue.\n"); else printf("Your default print queue is %s.\n", queue); form[form_len] = '\0'; if (strlen(form) == 0) printf("You have not specified a default print form.\n"); else printf("Your default print form is %s.\n", form); }