Article View: vmsnet.sources
Article #136DWProfile V3.3, part 02/06
From: tanner
Date: Mon, 04 Jan 1993 20:46
Date: Mon, 04 Jan 1993 20:46
1403 lines
50193 bytes
50193 bytes
Submitted-by: tanner@cerritos.edu
Posting-number: Volume 4, Issue 27
Archive-name: dwprofile/part02
-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
X `7B"versionLimit", "VersionLimit", XtRInt, sizeof(int),
X XtOffset(ApplicationDataPtr, version_limit), XtRString, "0"`7D,
X `7B"minimumGroup", "MinimumGroup", XtRInt, sizeof(int),
X XtOffset(ApplicationDataPtr, minimum_group), XtRString, "0"`7D,
X `7B"maximumGroup", "MaximumGroup", XtRInt, sizeof(int),
X XtOffset(ApplicationDataPtr, maximum_group), XtRString, "32767"`7D
X`7D;
X
X#define dwp32_width 32
X#define dwp32_height 32
Xstatic char dwp32_bits`5B`5D = `7B
X 0x00, 0x00, 0x20, 0x80, 0xfe, 0xff, 0xaf, 0xbf, 0x82, 0x20, 0xa8, 0xaa,
X 0xfe, 0xff, 0xaf, 0xbf, 0x82, 0x20, 0xa8, 0xaa, 0xfe, 0xff, 0xaf, 0xbf,
X 0x82, 0x20, 0xa8, 0xaa, 0xfe, 0xff, 0xaf, 0xbf, 0xaa, 0xaa, 0xaa, 0xaa,
X 0xfe, 0xff, 0xaf, 0xbf, 0xaa, 0xaa, 0xaa, 0xaa, 0xfe, 0xff, 0xaf, 0xbf,
X 0xfe, 0xff, 0x2f, 0x80, 0xe2, 0x38, 0xee, 0xff, 0xfe, 0xff, 0xef, 0xff,
X 0xe2, 0x38, 0xee, 0xff, 0xfe, 0xff, 0xef, 0xff, 0xe2, 0x38, 0xee, 0xff,
X 0xfe, 0xff, 0xef, 0xff, 0xe2, 0x38, 0xee, 0xff, 0xfe, 0xff, 0xef, 0xff,
X 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
X 0x00, 0x00, 0xe0, 0xff, 0xfe, 0xff, 0xef, 0xff, 0x02, 0x06, 0xe8, 0xff,
X 0xfe, 0xff, 0xef, 0xff, 0x02, 0x06, 0xe8, 0xff, 0xfe, 0xff, 0xef, 0xff,
X 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff`7D;
X
Xstatic String uidname`5B`5D = `7B
X "DWPUID:DWPROFILE.UID",
X "DWPUID:ACCESS.UID",
X "DWPUID:PRIVS.UID",
X "DWPUID:IDENTS.UID",
X`7D;
X
X#define HELP_LIBRARY "DWPUID:DWPROFILE.HLB"
$ CALL UNPACK DWPDEF.H;49 408054743
$ create 'f'
X/* DWPROFILE.C -- Authorize/Profile/DECburger replacement */
X/* Copyright `A9 1990,1991,1992 Bruce Tanner - Cerritos College */
X
X/*
X * Revision history:
X * 9/4/90 Version 1.0
X * 9/12/90 Version 1.1
X * Added popup menu for access, privs boxes.
X * Forced 12 point Helvetica Bold font.
X * Moved lots of stuff to the resource file.
X * Added date of last login, logfails.
X * 10/10/90 Version 2.0
X * Create/delete directory.
X * Add/delete disk quota.
X * Grant/revoke identifiers.
X * Take username from command line.
X * 11/28/90 Version 2.1
X * Fixed: Dup UIC from calc_uic() on multiple adds from same reco
Vrd.
X * Fixed: Identifier not changed on UIC change.
X * 8/21/91 Version 2.2
X * Fixed: directory creation; add quota THEN create directory.
X * Check for blank owner, account DEFAULT, defdir `5BUSER`5D
X * Fixed: New account created bad UIC.
X * 10/9/92 Version 2.3
X * Keep list of identifiers up to date.
X * Minor code cleanup.
X * 10/27/92 Version 3.0
X * Converted to Motif.
X * 11/4/92 Version 3.1
X * Added Select menu and Find Next button.
X * 11/13/92 Version 3.2
X * Added Help menu item.
X * 11/30/92 Version 3.3
X * Beta test bug fixes and the usual code randomizing.
X */
X
X#define TITLE "DWProfile"
X#module DWProfile "DWProfile V3.3"
X#include descrip
X#include string
X#include ssdef
X#include stdio
X#include clidef
X#include jpidef
X#include prvdef
X#include rmsdef
X#include strdef
X#include str$routines
X#include <decw$cursor.h>
X#include "dwpdef.h"
X#include <X11/Intrinsic.h>
X#include <Xm/Xm.h>
X#include <Xm/MwmUtil.h>
X#include <Mrm/Mrm.h>
X#include <Xm/RowColumn.h>
X#include <Xm/MessageB.h>
X#include <Xm/SelectioB.h>
X#include <Xm/DrawingA.h>
X#include <DXm/DECspecific.h>
X#include <DXm/DXmHelpB.h>
X
Xstatic MrmHierarchy Hierarchy;
Xstatic MrmType class;
Xstatic XtAppContext context;
Xstatic Widget toplevel, dwprofile_main, access_box, privs_box,
X widget_array`5BMAX_WIDGET`5D, flags_array`5BMAX_FLAGS`5D,
X prime_array`5BMAX_PRIME`5D, privs_array`5BMAX_PRIVS`5D,
X button_array`5BMAX_MENUS`5D, idents_box, accounts_box, work_box;
Xstatic void init_application(), get_gc(), update_prime(),
X update_time(Cardinal), update_strings(), update_flags(),
X update_privs(), set_translations(), set_handlers(),
X trans_uic(Cardinal), make_cursor(), build_popup(),
X update_held(), set_defaults(), build_accounts(), pos_functions(),
X DWPerror(String, String, int), DWPmsg(String, Cardinal),
X progress(ident *), read_identifiers(Boolean);
Xstatic Boolean get_record(String), parse_uic(int);
Xstatic XtEventHandler popup_handler(), access_handler();
Xstatic XtCallbackProc WidgetCreated(), WidgetChanged(),
X Quit(), Write(), Read(), Find(), Remove(), Access(),
X Privs(), Accounts(), Idents(),
X FlagsCreated(), FlagsChanged(),
X PrimeCreated(), PrimeChanged(),
X PrivsCreated(), PrivsChanged(),
X AccountChanged(), CautionCallback(),
X MessageCallback(), ReadIdentifiers(),
X ListSelect(), IdentsCancelCallback(),
X ButtonCreated(), Select(), FindCancelCallback(),
X Help(), DestroyHelpCallback();
Xstatic XtActionProc return_key(), select_key();
Xstatic MrmRegisterArg regvec`5B`5D = `7B
X `7B"WidgetCreated", WidgetCreated`7D,
X `7B"WidgetChanged", WidgetChanged`7D,
X `7B"Quit", Quit`7D,
X `7B"Write", Write`7D,
X `7B"Read", Read`7D,
X `7B"Find", Find`7D,
X `7B"Remove", Remove`7D,
X `7B"Access", Access`7D,
X `7B"Privs", Privs`7D,
X `7B"Accounts", Accounts`7D,
X `7B"FlagsCreated", FlagsCreated`7D,
X `7B"FlagsChanged", FlagsChanged`7D,
X `7B"PrimeCreated", PrimeCreated`7D,
X `7B"PrimeChanged", PrimeChanged`7D,
X `7B"PrivsCreated", PrivsCreated`7D,
X `7B"PrivsChanged", PrivsChanged`7D,
X `7B"ReadIdentifiers", ReadIdentifiers`7D,
X `7B"Idents", Idents`7D,
X `7B"ListSelect", ListSelect`7D,
X `7B"ButtonCreated", ButtonCreated`7D,
X `7B"Select", Select`7D,
X `7B"Help", Help`7D
X`7D;
Xstatic char return_translation`5B`5D = "<Key>Return: return_key()",
X select_translation`5B`5D = "<Key>osfSelect: select_key()";
Xstatic XtActionsRec action_table`5B`5D = `7B
X `7B"return_key", return_key`7D,
X `7B"select_key", select_key`7D
X`7D; `20
Xstatic String fallbacks`5B`5D = `7B
X "*fontList: -Adobe-Helvetica-Bold-R-Normal--12-120-75-75-P-*-*-*",
X NULL
X`7D;
Xstatic String select_string, unpad(String);
Xstatic ApplicationData resource_data;
Xstatic struct `7B
X int idata;
X Boolean changed;
X char sdata`5BSDATA_LEN`5D, odata`5BSDATA_LEN`5D;
X `7D uafdata`5BMAX_WIDGET`5D;
Xstatic struct itemlist3 itmlst`5BMAX_WIDGET`5D;
Xstatic Display *top_display;
Xstatic Window top_window;
Xstatic GC gc_draw, gc_clear;
Xstatic Boolean setting_widgets, setting_prime, setting_flags, setting_privs;
Xstatic ident *ident_list = NULL, *select_ptr = NULL, *ident_ptr, *found_ptr,
X *found_add, found_list = `7BNULL, 0, 0, NULL`7D;
Xstatic held_ident *held_list = NULL;
Xstatic Cardinal uic_count, account_count, ident_count, select_index;
Xstatic XtIntervalId timeout_id, progress_id;
Xstatic Cursor wait_cursor;
Xstatic XtWorkProcId idents_work_proc_id, find_work_proc_id;
X
X
Xmain(unsigned int argc, char *argv`5B`5D)
X`7B
X Cardinal status, ac;
X Arg arglist`5B5`5D;
X Pixmap icon_pixmap;
X
X init_application();
X MrmInitialize();
X DXmInitialize();
X ac = 0;
X XtSetArg(arglist`5Bac`5D, XmNtitle, TITLE); ac++;
X XtSetArg(arglist`5Bac`5D, XmNmwmDecorations,
X MWM_DECOR_MENU `7CMWM_DECOR_BORDER `7C MWM_DECOR_TITLE `7C
X MWM_DECOR_MINIMIZE); ac++;
X toplevel = XtAppInitialize(&context, "DWProfile", NULL, 0, &argc, argv,
X fallbacks, arglist, ac);
X
X status = MrmOpenHierarchy(XtNumber(uidname), uidname, NULL, &Hierarchy);
X if (status != MrmSUCCESS) lib$signal(status);
X
X status = MrmRegisterNames(regvec, XtNumber(regvec));
X if (status != MrmSUCCESS) lib$signal(status);
X
X if ((MrmFetchWidget(Hierarchy, "dwprofile_main", toplevel,
X &dwprofile_main, &class)) != MrmSUCCESS)
X XtAppError(context, "Error Fetching main widget");
X
X XtGetApplicationResources(toplevel, &resource_data, resources,
X XtNumber(resources), NULL, 0);
X
X XtManageChild(dwprofile_main);
X XtRealizeWidget(toplevel);
X
X top_display = XtDisplay(toplevel);
X top_window = XtWindow(toplevel);
X icon_pixmap = XCreateBitmapFromData(top_display, top_window,
X dwp32_bits, dwp32_width, dwp32_heigh
Vt);
X
X /* Set up the WM icons via shell widget attributes */
X ac = 0;
X XtSetArg(arglist`5Bac`5D, XmNiconPixmap, icon_pixmap); ac++;
X XtSetValues(toplevel, arglist, ac);
X
X make_cursor(); /* create wait_cursor */
X set_translations(); /* set text widget translations */
X build_popup(); /* build a popup menu */
X get_gc(); /* set up stuff for access windows */
X pos_functions(); /* center the functions box */
X
X if (argc == 1)
X get_record(""); /* Initialize text fields */
X
X /* load username if given on command line */
X if (argc == 2)
X if (!get_record(argv`5B1`5D))
X if (get_record("DEFAULT"))
X set_defaults(argv`5B1`5D);
X else
X DWPerror("Main Init", "Cannot read username DEFAULT", 0);
X
X /* set up the windows based on resource file */
X if (resource_data.show_access) Access(NULL, NULL, NULL);
X if (resource_data.show_privs) Privs(NULL, NULL, NULL);
X if (resource_data.show_accounts) Accounts(NULL, NULL, NULL);
X if (resource_data.show_idents) Idents(NULL, NULL, NULL);
X
X /* traverse to the username widget */
X XmProcessTraversal(widget_array`5BUAI$_USERNAME`5D, XmTRAVERSE_CURRENT);
X
X XtAppMainLoop(context);
X`7D
X
X
X/*** Initialization Routines ***/
X
X/*
X * Set sysprv
X * Clear out widget arrays
X */
X
Xstatic void init_application()
X`7B
X Cardinal ind, status, my_privs`5B2`5D,
X jpicode = JPI$_AUTHPRIV, priv_mask`5B2`5D = `7B0, 0`7D;
X
X status = lib$getjpi(&jpicode, 0, 0, &my_privs, 0, 0);
X if (status != SS$_NORMAL)
X XtAppError(context, "lib$getjpi failed");
X `20
X if (my_privs`5B0`5D & (PRV$M_SYSPRV `7C PRV$M_SETPRV)) `7B
X priv_mask`5B0`5D `7C= PRV$M_SYSPRV;
X status = sys$setprv(ON, &priv_mask, 0, 0);
X if (status != SS$_NORMAL)
X XtAppError(context, "sys$setprv failed");
X `7D
X else `7B
X printf("Insufficient privilege to see other than your own UAF record
V\n");
X/* exit(); */
X `7D
X
X for (ind = 0; ind < MAX_WIDGET; ind++) widget_array`5Bind`5D = NULL;
X for (ind = 0; ind < MAX_FLAGS; ind++) flags_array`5Bind`5D = NULL;
X for (ind = 0; ind < MAX_PRIVS; ind++) privs_array`5Bind`5D = NULL;
X for (ind = 0; ind < MAX_PRIME; ind++) prime_array`5Bind`5D = NULL;
X`7D
X
X
X/*
X * Load the cursor font and allocate colors for the cursor
X */
X
Xstatic void make_cursor()
X`7B
X Colormap cmap;
X XColor red, white, dummy;
X Font cursorfont;
X
X cmap = DefaultColormap(top_display, DefaultScreen(top_display));
X
X XAllocNamedColor(top_display, cmap, "white", &white, &dummy);
X XAllocNamedColor(top_display, cmap, "red", &red, &dummy);
X
X cursorfont = XLoadFont(top_display, "DECW$CURSOR");
X wait_cursor = XCreateGlyphCursor(top_display, cursorfont, cursorfont,
X decw$c_wait_cursor, decw$c_wait_cursor+1, &red, &white);
X
X`7D
X
X
X/*
X * Override the translation table of the Username, Account text widgets
X * Override Select translation for selectable fields
X */
X
Xstatic void set_translations()
X`7B
X Cardinal si;
X XtTranslations compiled_trans;
X
X XtAppAddActions(context, action_table, XtNumber(action_table));
X
X compiled_trans = XtParseTranslationTable(return_translation);
X XtOverrideTranslations(widget_array`5BUAI$_USERNAME`5D, compiled_trans);
X XtOverrideTranslations(widget_array`5BUAI$_ACCOUNT`5D, compiled_trans);
X
X compiled_trans = XtParseTranslationTable(select_translation);
X for(si = 0; select_data`5Bsi`5D.code; si++)
X if (select_data`5Bsi`5D.type != DWP_RINT)
X XtOverrideTranslations(widget_array`5Bselect_data`5Bsi`5D.code`5
VD, compiled_trans);
X`7D
X
X
X/*
X * Set up event handlers for access windows
X */
X
Xstatic void set_handlers()
X`7B
X Cardinal wi;
X
X for (wi = UAI$_NETWORK_ACCESS_P; wi <= UAI$_REMOTE_ACCESS_S; wi++)
X if (widget_array`5Bwi`5D)
X XtAddEventHandler(widget_array`5Bwi`5D,
X ButtonPressMask `7C ButtonReleaseMask `7C Expo
VsureMask `7C
X Button1MotionMask, FALSE, access_handler, wi);
X`7D
X
X
X/*
X * Build a MenuPopup widget and children
X */
X
Xstatic void build_popup()
X`7B
X#define MENUS 4
X Arg arglist`5B2`5D;
X Cardinal ac, ind;
X struct `7B
X String resource;
X String title;
X XtCallbackProc callback;
X `7D params`5BMENUS`5D = `7B
X `7B"access_button", "Access...", Access`7D,
X `7B"privs_button", "Privs...", Privs`7D,
X `7B"accounts_button", "Accounts...", Accounts`7D,
X `7B"idents_button", "Identifiers...", Idents`7D
X `7D;
X Widget menu_items`5BMENUS`5D, popup_menu;
X
X popup_menu = XmCreatePopupMenu(dwprofile_main, "popup", NULL, 0);
X /* pass popup_menu as the client data for popup() */
X XtAddEventHandler(dwprofile_main, ButtonPressMask, FALSE, popup_handler,
V popup_menu);
X
X for (ind = 0; ind < MENUS; ind++) `7B
X ac = 0;
X XtSetArg(arglist`5Bac`5D, XmNlabelString, XmStringCreateSimple(param
Vs`5Bind`5D.title)); ac++;
X menu_items`5Bind`5D = XmCreatePushButtonGadget(popup_menu, params`5B
Vind`5D.resource, arglist, ac);
X XtAddCallback(menu_items`5Bind`5D, XmNactivateCallback, params`5Bind
V`5D.callback, 0);
X `7D
X
X XtManageChildren(menu_items, ind); /* just the buttons, not the menu *
V/
X`7D
X
X
X/*
X * Set up the graphic contexts gc_draw and gc_clear
X */
X
Xstatic void get_gc()
X`7B
X Cardinal ac;
X Arg arglist`5B2`5D;
X XGCValues gc_values;
X Pixel foreground, background;
X
X ac = 0;
X XtSetArg(arglist`5Bac`5D, XmNforeground, &foreground); ac++;
X XtSetArg(arglist`5Bac`5D, XmNbackground, &background); ac++;
X XtGetValues(dwprofile_main, arglist, ac);
X gc_values.foreground = foreground;
X gc_values.background = background;
X gc_draw = XtGetGC(dwprofile_main, GCForeground `7C GCBackground, &gc_val
Vues);
X gc_values.foreground = background;
X gc_clear = XtGetGC(dwprofile_main, GCForeground, &gc_values);
X`7D
X
X
X
X/*** Utility Routines ***/
X
X/*
X * Set the username, password and directory name
X * Called by main, Read
X */
X
Xstatic void set_defaults(String user)
X`7B
X Arg arg`5B1`5D;
X char text`5B40`5D;
X
X /* SetString sets .sdata and .changed */
X XmTextSetString(widget_array`5BUAI$_USERNAME`5D, user);
X XmTextSetString(widget_array`5BUAI$_PWD`5D, user);
X sprintf(uafdata`5BUAI$_DEFDIR`5D.sdata, "`5B%s`5D", user);
X XmTextSetString(widget_array`5BUAI$_DEFDIR`5D, uafdata`5BUAI$_DEFDIR`5D.
Vsdata);
X
X sprintf(text, "%s\n%s", TITLE, user);
X XtSetArg(arg`5B0`5D, XmNiconName, text);
X XtSetValues(toplevel, arg, 1); /* update the icon name */
X`7D
X
X
X/*
X * Center the functions box
X */
X
Xstatic void pos_functions()
X`7B
X Arg arglist`5B5`5D;
X Cardinal ac;
X Dimension funct_width, main_width, funct_x, new_x;
X
X ac = 0;
X XtSetArg(arglist`5Bac`5D, XmNwidth, &funct_width); ac++;
X XtSetArg(arglist`5Bac`5D, XmNx, &funct_x); ac++;
X XtGetValues(button_array`5Bfunctions_menu`5D, arglist, ac);
X ac = 0;
X XtSetArg(arglist`5Bac`5D, XmNwidth, &main_width); ac++;
X XtGetValues(dwprofile_main, arglist, ac);
X new_x = (main_width - funct_width) / 2;
X ac = 0;
X XtSetArg(arglist`5Bac`5D, XmNx, new_x); ac++;
X XtSetValues(button_array`5Bfunctions_menu`5D, arglist, ac);
X`7D
X
X
X/*
X * Lookup a UAF record and fill those widgets
X * Called by Read and program initialization
X */
X
Xstatic Boolean get_record(String acct)
X`7B
X Cardinal status, ind, si, resid, rdbctx = 0, holder`5B2`5D = `7B0, 0`7D;
X ushort namlen;
X ident *ptr;
X held_ident *hptr, *tptr;
X Arg arg`5B1`5D;
X char text`5B40`5D, nambuf`5B40`5D;
X $DESCRIPTOR(acct_dsc, acct);
X $DESCRIPTOR(name_dsc, nambuf);
X
X /* reset all the data storage */
X for (ind = 0; ind < MAX_WIDGET; ind++) `7B
X memset(uafdata`5Bind`5D.sdata, 0, SDATA_LEN);
X uafdata`5Bind`5D.idata = 0;
X uafdata`5Bind`5D.changed = FALSE;
X `7D
X
X /* acct = "" means clear form */
X if (strlen(acct)) `7B`20
X acct_dsc.dsc$w_length = strlen(acct);
X for (ind = 0; ; ind++) `7B
X itmlst`5Bind`5D.buflen = items`5Bind`5D.size;
X itmlst`5Bind`5D.itmcode = items`5Bind`5D.code;
X if (!items`5Bind`5D.code) break; /* exit after copying zero e
Vntry */
X if (items`5Bind`5D.size > 4) /* anything that fits goes i
Vn .idata */
X itmlst`5Bind`5D.bufadr = uafdata`5Bitems`5Bind`5D.code`5D.sd
Vata;
X else
X itmlst`5Bind`5D.bufadr = &uafdata`5Bitems`5Bind`5D.code`5D.i
Vdata;
X itmlst`5Bind`5D.retadr = 0;
X `7D
X status = sys$getuai(0, 0, &acct_dsc, &itmlst, 0, 0, 0);
X
X if ((status & 7) != SS$_NORMAL) /* often SS$_BUFFEROVF */
X return FALSE; /* probably not found */
X
X for (ind = 0; items`5Bind`5D.code; ind++) /* reset changed flags
V */
X uafdata`5Bitems`5Bind`5D.code`5D.changed = FALSE;
X
X /* remember the old values of device and directory */
X memcpy(uafdata`5BUAI$_DEFDEV`5D.odata, uafdata`5BUAI$_DEFDEV`5D.sdat
Va, 32);
X memcpy(uafdata`5BUAI$_DEFDIR`5D.odata, uafdata`5BUAI$_DEFDIR`5D.sdat
Va, 64);
X `7D
X
X for (hptr = held_list; hptr;) `7B /* free old held list */
X tptr = hptr;
X hptr = hptr->next;
X XtFree(tptr);
X `7D
X held_list = NULL;
X
X if (strlen(acct)) `7B
X holder`5B0`5D = uafdata`5BUAI$_UIC`5D.idata;
X for (hptr = held_list;;) `7B
X status = sys$find_held(&holder, &resid, 0, &rdbctx);
X if (status == SS$_NOSUCHID) break;
X if (status != SS$_NORMAL) `7B
X sys$finish_rdb(&rdbctx);
X DWPmsg("get_record", status);
X break;
X `7D
X if (hptr)
X hptr = hptr->next = XtNew(held_ident);
X else
X held_list = hptr = XtNew(held_ident);
X hptr->next = NULL;
X hptr->identifier = resid;
X hptr->status = original;
X status = sys$idtoasc(resid, &namlen, &name_dsc, 0, 0, 0);
X nambuf`5Bnamlen`5D = '\0';
X hptr->name = XtNewString(nambuf);
X `7D
X `7D
X
X uafdata`5BUAI$_PWD`5D.sdata`5B0`5D = '\0'; /* discard password for Wr
Vite()*/
X
X update_strings(); /* update the string widgets */
X update_flags(); /* update the flag toggle button widgets */
X update_prime(); /* update the primary days and time widgets */
X update_privs(); /* update the privs toggle button widgets */
X update_held(); /* update the list of held identifiers */
X
X if (strlen(acct)) `7B
X sprintf(text, "%s\n%s", TITLE, acct);
X XtSetArg(arg`5B0`5D, XmNiconName, text);
X XtSetValues(toplevel, arg, 1); /* update the icon name */
X `7D
X return TRUE;
X`7D
X
X
X/*
X * Find all UAI elements that have (text) widgets and update them
X */
X
Xstatic void update_strings()
X`7B
X Cardinal ind, value, status;
X ushort length;
X char str`5BSDATA_LEN`5D, *ptr;
X Arg arg`5B1`5D;
X XmString xmstr;
X
X setting_widgets = TRUE;
X for (ind = 0; value = items`5Bind`5D.code; ind++)
X if (widget_array`5Bvalue`5D)
X switch (items`5Bind`5D.type) `7B
X case DWP_LALPHA: /* string with length byte */
X /* can't use unpad() because owner field contains spaces */
X length = (ushort) uafdata`5Bvalue`5D.sdata`5B0`5D;
X uafdata`5Bvalue`5D.sdata`5Blength+1`5D = '\0';
X XmTextSetString(widget_array`5Bvalue`5D,
X &uafdata`5Bvalue`5D.sdata`5B1`5D);
X break;
X case DWP_ALPHA: /* string (username, account) */
X XmTextSetString(widget_array`5Bvalue`5D,
X unpad(uafdata`5Bvalue`5D.sdata));
X break;
X case DWP_ENCR: /* password */
X XmTextSetString(widget_array`5Bvalue`5D, ""); /* clear fiel
Vd */
X break;
X case DWP_DATE: /* text date */
X `7B
X $DESCRIPTOR(time_dsc, str);
X
X sys$asctim(&length, &time_dsc, uafdata`5Bvalue`5D.sdata, 0);
X str`5Blength`5D = '\0';
X ptr = strstr(str, ":00.00");
X if (ptr) *ptr = '\0';
X if (!strncmp(str, "17-NOV-1858", 11))
X strcpy(str,"(none)"); /* handle 'none' */
X XmTextSetString(widget_array`5Bvalue`5D, str);
X break;
X `7D
X case DWP_RDATE: /* label date */
X `7B
X $DESCRIPTOR(time_dsc, str);
X
X sys$asctim(&length, &time_dsc, uafdata`5Bvalue`5D.sdata, 0);
X str`5Blength`5D = '\0';
X ptr = strrchr(str, ':');
X if (ptr) *ptr = '\0'; /* chop off :ss.cc */
X if (!strncmp(str, "17-NOV-1858", 11))
X strcpy(str,"(none)"); /* handle 'none' */
X xmstr = XmStringCreateSimple(str);
X XtSetArg(arg`5B0`5D, XmNlabelString, xmstr);
X XtSetValues(widget_array`5Bvalue`5D, arg, 1);
X XmStringFree(xmstr);
X break;
X `7D
X case DWP_CPU: /* CPU time */
X if (!uafdata`5Bvalue`5D.idata)
X strcpy(str, "(none)");
X else `7B
X Cardinal dd, hh, mm, ss, cc, time = uafdata`5Bvalue`5D.i
Vdata;
X
X dd = time / 8640000;
X time -= dd * 8640000;
X hh = time / 360000;
X time -= hh * 360000;
X mm = time / 6000;
X time -= mm * 6000;
X ss = time / 100;
X time -= ss * 100;
X cc = time;
X sprintf(str, "%d %02d:%02d:%02d.%02d",
X dd, hh, mm, ss, cc);
X `7D
X XmTextSetString(widget_array`5Bvalue`5D, str);
X break;
X case DWP_UIC: /* UIC */
X sprintf(uafdata`5Bvalue`5D.sdata, "`5B%o,%o`5D",
X uafdata`5Bvalue`5D.idata >> 16,
X uafdata`5Bvalue`5D.idata & 0xFFFF);
X XmTextSetString(widget_array`5Bvalue`5D,
X uafdata`5Bvalue`5D.sdata);
X trans_uic(uafdata`5Bvalue`5D.idata);
X break;
X case DWP_INT: /* text integer */
X sprintf(str, "%d", uafdata`5Bvalue`5D.idata);
X XmTextSetString(widget_array`5Bvalue`5D, str);
X break;
X case DWP_RINT: /* label integer */
X sprintf(str, "%d", uafdata`5Bvalue`5D.idata);
X xmstr = XmStringCreateSimple(str);
X XtSetArg(arg`5B0`5D, XmNlabelString, xmstr);
X XtSetValues(widget_array`5Bvalue`5D, arg, 1);
X XmStringFree(xmstr);
X break;
X `7D
X setting_widgets = FALSE;
X`7D
X
X
X/*
X * Update login flags toggle buttons according to UAI data
X */
X
Xstatic void update_flags()
X`7B
X Cardinal ind;
X Boolean notify = NO;
X
X setting_flags = TRUE;
X for (ind = 0; ind < MAX_FLAGS; ind++)
X if (flags_array`5Bind`5D)
X if (uafdata`5BUAI$_FLAGS`5D.idata >> ind & 1)
X XmToggleButtonSetState(flags_array`5Bind`5D, ON, notify);
X else
X XmToggleButtonSetState(flags_array`5Bind`5D, OFF, notify);
X setting_flags = FALSE;
X`7D
X
X
X/*
X * Set the buttons to reflect primedays
X * Set the time map window widgets
X */
X
Xstatic void update_prime()
X`7B
X Cardinal ind;
X Boolean notify = NO;
X
X setting_prime = TRUE;
X for (ind = 0; ind < MAX_PRIME; ind++)
X if (prime_array`5Bind`5D)
X XmToggleButtonSetState(prime_array`5Bind`5D,
X uafdata`5BUAI$_PRIMEDAYS`5D.idata >> ind & 1 `5E 1, notify);
X setting_prime = FALSE;
X
X update_time(UAI$_NETWORK_ACCESS_P);
X update_time(UAI$_NETWORK_ACCESS_S);
X update_time(UAI$_BATCH_ACCESS_P);
X update_time(UAI$_BATCH_ACCESS_S);
X update_time(UAI$_LOCAL_ACCESS_P);
X update_time(UAI$_LOCAL_ACCESS_S);
X update_time(UAI$_DIALUP_ACCESS_P);
X update_time(UAI$_DIALUP_ACCESS_S);
X update_time(UAI$_REMOTE_ACCESS_P);
X update_time(UAI$_REMOTE_ACCESS_S);
X`7D
X
X
X/*
X * Set the priv buttons to reflect auth priv & default priv
X * the buttons for default privs 0-38 are kept in privs_array`5B0-38`5D
X * the buttons for auth privs 0-38 are kept in privs_array`5B40-78`5D
X * (PRIVS_BIAS is 40)
X */
X
Xstatic void update_privs()
X`7B
X Cardinal ind;
X Boolean notify = NO;
X
X setting_privs = TRUE;
X for (ind = 0; ind < MAX_PRIVS/2; ind++)
X if (privs_array`5Bind`5D)
X if (uafdata`5BUAI$_PRIV`5D.sdata`5Bind >> 3`5D >> (ind & 7) & 1)
X XmToggleButtonSetState(privs_array`5Bind`5D, ON, notify);
X else
X XmToggleButtonSetState(privs_array`5Bind`5D, OFF, notify);
X
X for (ind = PRIVS_BIAS; ind < MAX_PRIVS; ind++)
X if (privs_array`5Bind`5D)
X if (uafdata`5BUAI$_DEF_PRIV`5D.sdata`5Bind - PRIVS_BIAS >> 3`5D
V >>
X (ind - PRIVS_BIAS & 7) & 1)
X XmToggleButtonSetState(privs_array`5Bind`5D, ON, notify);
X else
X XmToggleButtonSetState(privs_array`5Bind`5D, OFF, notify);
X setting_privs = FALSE;
X`7D `20
X
X
X/*
X * Update a time map window widget
X */
X
Xstatic void update_time(Cardinal code)
X`7B
X Cardinal ind;
X Display *display;
X Window window;
X
X if (!widget_array`5Bcode`5D) return; /* return if no widget */
X
X display = XtDisplay(widget_array`5Bcode`5D); /* get display for XFill *
V/
X window = XtWindow(widget_array`5Bcode`5D); /* get window for XFill */
X if (!window) return; /* Just paranoia? */
X
X switch (uafdata`5Bcode`5D.idata) `7B /* speed up special case
Vs */
X case 0: /* full access */
X XFillRectangle(display, window, gc_draw,
X 0, 0, resource_data.hour_size * 24, k_hours_height);
X break;
X case 0xFFFFFF: /* no access */
X XFillRectangle(display, window, gc_clear,
X 0, 0, resource_data.hour_size * 24, k_hours_height);
X break;
X default:
X XFillRectangle(display, window, gc_draw,
X 0, 0, resource_data.hour_size * 24, k_hours_height);
X for (ind = 0; ind < 24; ind++)
X if (uafdata`5Bcode`5D.idata >> ind & 1)
X XFillRectangle(display, window, gc_clear,
X ind * resource_data.hour_size, 0,
X resource_data.hour_size, k_hours_height);
X `7D
X`7D
X
X
X/*
X * Update the list of held identifiers
X */
X
Xstatic void update_held()
X`7B
X Cardinal status, ac, ind, entries, position;
X Boolean already_granted;
X Arg arglist`5B5`5D;
X ident *ptr;
X held_ident *hptr;
X XmString *items;
X
X /* quit if the idents box is not there, or still building ident_list */
X if (!idents_box `7C`7C !XtIsManaged(idents_box) `7C`7C idents_work_proc_
Vid)
X return;
X
X items = (XmString *)XtCalloc(ident_count, sizeof(XmString));
X
X /* show the held idents list */
X for (hptr = held_list, ind = 0; hptr; hptr = hptr->next)
X if (hptr->status == original `7C`7C hptr->status == add_ident)
X items`5Bind++`5D = XmStringCreateSimple(hptr->name);
X entries = ind; /* save count of list entries */
X if (ind > ident_count)
X XtAppError(context, "held ident array overflow in update_held()");
X /* The Motif FAQ says that this will free memory used by the old list */
X ac = 0;
X XtSetArg(arglist`5Bac`5D, XmNitems, items); ac++;
X XtSetArg(arglist`5Bac`5D, XmNitemCount, ind); ac++;
X XtSetValues(widget_array`5Bk_widget_held_list`5D, arglist, ac);
X for (ind = 0; ind < entries; ind++)
X XmStringFree(items`5Bind`5D);
X
X /* show all the non-uic idents not already held */
X for (ptr = ident_list, ind = 0; ptr; ptr = ptr->next)
X if (ptr->status == user_ident) `7B
X already_granted = FALSE;
X for (hptr = held_list; hptr; hptr = hptr->next)
X already_granted `7C= (hptr->identifier == ptr->identifier) &
V&
X (hptr->status != del_orig);
X if (!already_granted) `7B /* if user doesn't already have id */
X if (!strcmp(ptr->name, resource_data.default_ident))
X position = ind;
X items`5Bind++`5D = XmStringCreateSimple(ptr->name);
X `7D
X `7D
X entries = ind; /* save count of list entries */
X if (ind > ident_count)
X XtAppError(context, "all ident array overflow in update_held()");
X ac = 0;
X XtSetArg(arglist`5Bac`5D, XmNitems, items); ac++;
X XtSetArg(arglist`5Bac`5D, XmNitemCount, ind); ac++;
X XtSetArg(arglist`5Bac`5D, XmNtopItemPosition, position + 1); ac++;
X XtSetValues(widget_array`5Bk_widget_all_list`5D, arglist, ac);
X for (ind = 0; ind < entries; ind++)
X XmStringFree(items`5Bind`5D);
X
X XtFree(items);
X`7D
X
X
X/*
X * Force text to uppercase
X * Called by WidgetChanged, AccountChanged
X */
X
Xstatic void uppercase(String str)
X`7B
X String str2;
X
X for (str2 = str; *str2; str2++)
X *str2 = toupper(*str2);
X`7D
X `20
X
X/*
X * Remove trailing blanks from a DWP_LALPHA data item
X * Returns the address of the string
X */
X
Xstatic String unpad(String alpha)
X`7B
X String ptr;
X
X ptr = strchr(alpha, ' ');
X if (ptr) *ptr = '\0'; /* if there is a trailing space, trim it */
X if ((Cardinal) alpha`5B0`5D < 32)
X return alpha + 1; /* if there is a length byte, return the start of
V the string */
X else
X return alpha;
X`7D
X
X
X/*
X * Signal a local error
X * Interval = -2 means don't do anything
X * -1 means just printf to stdout
X * 0 means popup message box without timeout
X * > 0 means popup message box with timeout in 'interval' ms
X */
X
Xstatic void DWPerror(String where, String what, int interval)
X`7B
X Cardinal ac;
X Arg arglist`5B5`5D;
X char msg`5B100`5D;
X XmString xmstr;
X static Widget message_box = NULL;
X
X if (interval == -2)
X return;
X if (interval == -1) `7B
X printf("%s (From: %s)\n", what, where);
X return;
X `7D
X if (!message_box) `7B
X ac = 0;
X xmstr = XmStringCreateSimple("DWProfile: Warning Message");
X XtSetArg(arglist`5Bac`5D, XmNdialogTitle, xmstr); ac++;
X`09message_box = XmCreateMessageDialog(dwprofile_main, "message_box", arglis
Vt, ac);
X XmStringFree(xmstr);
X XtUnmanageChild(XmMessageBoxGetChild(message_box, XmDIALOG_HELP_BUTT
VON));
X XtUnmanageChild(XmMessageBoxGetChild(message_box, XmDIALOG_CANCEL_BU
VTTON));
X`09XtAddCallback(message_box, XmNokCallback, MessageCallback, NULL);
X `7D
X ac = 0;
X sprintf(msg, "%s\nFrom: %s", what, where);
X xmstr = XmStringCreateLtoR(msg,XmSTRING_DEFAULT_CHARSET);
X XtSetArg(arglist`5Bac`5D, XmNmessageString, xmstr); ac++;
X XtSetValues(message_box, arglist, ac);
X XmStringFree(xmstr);
X XtManageChild(message_box); /* popup message box */
X if (interval)
X timeout_id = XtAppAddTimeOut(context, interval, MessageCallback, mes
Vsage_box);
X XFlush(top_display);
X`7D
X
X
X/*
X * Signal an external error
X */
X
Xstatic void DWPmsg(String where, Cardinal msg)
X`7B
X char buffer`5B100`5D;
X Cardinal status;
X ushort length;
X $DESCRIPTOR(txt_dsc, buffer);
X
X status = sys$getmsg(msg, &length, &txt_dsc, 0, 0);
X buffer`5Blength`5D = '\0';
X if ((status & 7) == SS$_NORMAL)
X DWPerror(where, buffer, 0);
X else
X DWPerror(where, "Unknown", 0);
X`7D
X
X
X/*
X * Do a DCL command
X * Called by Write
X */
X
Xstatic void spawn_dcl(String str)
X`7B
X Cardinal status, substatus = SS$_NORMAL, flags = CLI$M_NOCLISYM, /* `7C
V CLI$M_NOLOGNAM */
X devlen, ctx, count = 0;
X char *cptr, dev1`5B40`5D = "", dev2`5B40`5D, dir`5B40`5D, result`5B40`5D
V, filespec`5B40`5D;
X ident *iptr, *prev;
X FILE *file;
X $DESCRIPTOR(dcl_dsc, "DCL.TMP");
X#ifdef DEBUG
X $DESCRIPTOR(out_dsc, "TT:");
X#else
X $DESCRIPTOR(out_dsc, "NL:"); /* change to TT: for debugging command fil
Ves */
X#endif
X $DESCRIPTOR(dev1_dsc, dev1);
X $DESCRIPTOR(dev2_dsc, dev2);
X $DESCRIPTOR(res_dsc, result);
X $DESCRIPTOR(file_dsc, filespec);
X Boolean remove_command = !strncmp(str, "$ UAF REMOVE", 12);
X Boolean modify_uic = strstr(str, "$ UAF MODIFY") && strstr(str, "/UIC");
X
X#ifdef DEBUG
X printf("spawn_dcl(%s)\n", str);
X#endif
X
X /* set up dev1, dev2, dir */
X /* if from getuai, it has a length byte; if from text widget, not */
X strcpy(dev1, unpad(uafdata`5BUAI$_DEFDEV`5D.sdata));
X if (dev1`5Bstrlen(dev1) - 1`5D == ':')
X dev1`5Bstrlen(dev1) - 1`5D = '\0'; /* strip off trailing ':' */
X dev1_dsc.dsc$w_length = strlen(dev1);
X status = lib$sys_trnlog(&dev1_dsc, &devlen, &dev2_dsc, 0, 0, 0);
X cptr = strchr(dev2, ' ');
X if (cptr) *cptr = '\0'; /* null terminate */
X cptr = strchr(dev2, ':');
X if (cptr) *cptr = '\0'; /* physical device without ':' */
X strcpy(dir, unpad(uafdata`5BUAI$_DEFDIR`5D.sdata));
X if (dir`5B0`5D == '`5B')
X strcpy(dir, dir + 1); /* strip off `5B */
X if (dir`5Bstrlen(dir) - 1`5D == '`5D')
X dir`5Bstrlen(dir) - 1`5D = '\0'; /* strip off `5D */
X
X file = fopen("DCL.TMP","w");
X#ifdef DEBUG
X fprintf(file, "$ SET VERIFY\n");
X fprintf(file, "$ SHOW LOGICAL DWPUID\n");
X#endif `20
X fprintf(file, "$ DELETE DCL.TMP;*\n");
X fprintf(file, "$ PREVPRIV = F$SETPRV(\"ALL\")\n");
X fprintf(file, "$ DEFINE/USER SYSUAF SYS$SYSTEM:SYSUAF\n");
X fprintf(file, "$ UAF :== $AUTHORIZE\n");
X fprintf(file, "%s\n", str);
X
X /* if the command is REMOVE, delete mail profile */
X if (remove_command) `7B
X fprintf(file, "$ MAIL\n");
X fprintf(file, "%s\n", str);
X fprintf(file, "EXIT\n");
X `7D
X
X /* if the command is REMOVE, delete disk files and directory */
X if (remove_command && strlen(dev1) && strlen(dir))
X fprintf(file, "$ @DWPUID:DELTREE %s:`5B%s`5D\n", dev1, dir);
X
X /* add the quota and overdraft resources.
X The default (0) is to do nothing, i.e. use the `5Bgroup,0`5D entry
X in quota.sys. Set the resources 'quota' and 'overdraft' to use
X a fixed quota
X */
X /* if defdev exists and a fixed disk quota specified */
X if (strlen(dev1) && (resource_data.quota)) `7B
X sprintf(filespec, "%s:`5B000000`5DQUOTA.SYS", dev2);
X file_dsc.dsc$w_length = strlen(filespec);
X ctx = 0;
X status = lib$find_file(&file_dsc, &res_dsc, &ctx, 0, 0, 0, 0);
X lib$find_file_end(&ctx);
X if ((status & 7) == SS$_NORMAL) `7B /* QUOTA.SYS exists */
X fprintf(file, "$ RUN SYS$SYSTEM:DISKQUOTA\n");
X fprintf(file, "USE %s\n", dev2);
X if (remove_command)
X fprintf(file, "REMOVE %s\n", uafdata`5BUAI$_UIC`5D.sdata);
X else
X fprintf(file, "ADD %s /PERMQUOTA=%d /OVERDRAFT=%d\n",
X uafdata`5BUAI$_UIC`5D.sdata, resource_data.quota,
X resource_data.overdraft);
X fprintf(file, "EXIT\n");
X `7D
X `7D `20
X fclose(file);
X status = lib$spawn(0, &dcl_dsc, &out_dsc, &flags, 0, 0, &substatus, 0, 0
V, 0, 0, 0);
X if ((substatus & 7) != SS$_NORMAL) /* probably CLI$_NORMAL */
X DWPmsg("Spawned process status", substatus);
X if (status != SS$_NORMAL)
X DWPmsg("Spawn_DCL", status);
X
X if (!remove_command && strlen(dev1) && strlen(dir)) `7B
X sprintf(filespec, "%s:`5B000000`5D%s.DIR", dev1, dir);
X file_dsc.dsc$w_length = strlen(filespec);
X ctx = 0;
X status = lib$find_file(&file_dsc, &res_dsc, &ctx, 0, 0, 0, 0);
X lib$find_file_end(&ctx);
X filespec`5B0`5D == '\0';
X if (status == RMS$_FNF) `7B
X/* setpriv(ON, PRV$M_BYPASS `7C PRV$M_EXQUOTA `7C PRV$M_SYSPRV); */
X sprintf(filespec, "%s:`5B%s`5D", dev1, dir);
X file_dsc.dsc$w_length = strlen(filespec);
X if (strlen(filespec)) `7B
X status = lib$create_dir(&file_dsc, &uafdata`5BUAI$_UIC`5D.id
Vata, 0, 0,
X &resource_data.version_limit, 0);
X#ifdef DEBUG
X printf("create_dir %s status = %d\n", filespec, status);
X#endif
X if (status != SS$_CREATED)
X DWPmsg("Create Dir", status);
X `7D
X `7D
X `7D
X
X /* If REMOVE, remove identifier from ident_list */
X if (remove_command `7C`7C modify_uic) `7B
X for (iptr = ident_list, prev = NULL; iptr; prev = iptr, iptr = iptr-
V>next)
X if (!strcmp(iptr->name, uafdata`5BUAI$_USERNAME`5D.sdata)) break
V;
X if (iptr) `7B
X if (prev)
X prev->next = iptr->next;
X else
X ident_list = iptr->next;
X XtFree(iptr->name);
X XtFree(iptr);
X uic_count--;
X `7D
X /* identifier may still be on found_list */
X for (iptr = found_list.next, prev = &found_list; iptr; prev = iptr,
V iptr = iptr->next)
X if (!strcmp(iptr->name, uafdata`5BUAI$_USERNAME`5D.sdata)) break
V;
X if (iptr) `7B
X prev->next = iptr->next;
X XtFree(iptr->name);
X XtFree(iptr);
X if (iptr == found_ptr)
X found_ptr = prev;
X if (iptr == found_add)
X found_add = prev;
X `7D
X /* remove group identifier if no other uic in group */
X for (iptr = ident_list; iptr; iptr = iptr->next)
X if ((iptr->identifier >> 16) == (uafdata`5BUAI$_UIC`5D.idata >>
V 16))
X count++;
X if (count == 1) `7B
X for (iptr = ident_list, prev = NULL; iptr; prev = iptr, iptr = i
Vptr->next)
X if (iptr->identifier == (uafdata`5BUAI$_UIC`5D.idata `7C 0xF
VFFF)) break;
X if (iptr) `7B
X if (prev)
X prev->next = iptr->next;
X else
X ident_list = iptr->next;
X XtFree(iptr->name);
X XtFree(iptr);
X account_count--;
X `7D
X `7D
X if (accounts_box && XtIsManaged(accounts_box)) `7B
X XtUnmanageChild(accounts_box);
X Accounts(NULL, NULL, NULL); /* reload accounts select box */
X `7D
X `7D
X`7D
X
X
X/*
X * Calculate the next available UIC in the group that matches the account
X * or finds the next available group if there is no match
X * Updates the UIC widget and uafdata fields.
X * Called when an account is selected via selector widget or from return_ke
Vy
X * when in the account text widget
X */
X
Xstatic void calc_uic()
X`7B
X Cardinal status, maxgroup = resource_data.minimum_group,
X groupid = 0, uic = 0;
X ushort length;
X ident *ptr;
X $DESCRIPTOR(group_dsc, uafdata`5BUAI$_ACCOUNT`5D.sdata);
X `20
X /* read in text widget */
X if (!parse_uic(UAI$_UIC))
X DWPerror("calc_uic","Illegal UIC format", 0);
X if (uafdata`5BUAI$_UIC`5D.idata) return; /* don't recalc if UIC exist
Vs */
X read_identifiers(FALSE);
X group_dsc.dsc$w_length = strlen(uafdata`5BUAI$_ACCOUNT`5D.sdata);
X status = sys$asctoid(&group_dsc, &groupid, 0);
X for (ptr = ident_list; ptr; ptr = ptr->next) `7B
X /* if groups match and not in `5Bn,*`5D and higher than old uic, sav
Ve it */
X if (((ptr->identifier >> 16) == (groupid >> 16)) &&
X ((ptr->identifier & 0xFFFF) != 0xFFFF))
X uic = (ptr->identifier > uic) ? ptr->identifier : uic;
X /* if this is a new group name, remember highest `5Bn,*`5D ident */
X if (!groupid &&
X (ptr->identifier < 0x80000000) &&
X (ptr->identifier < (resource_data.maximum_group << 16)) &&
X (ptr->identifier > maxgroup))
X maxgroup = ptr->identifier;
X `7D
X if (!groupid) /* new group name */
X groupid = maxgroup + 0x10000; /* highest group + 1 */
X if (!uic) /* if only `5Bx,177777`5D in UAF, give `5Bx,101`5D as uic *
V/
X uic = (groupid & 0x7FFF0000) + 0100;
X uafdata`5BUAI$_UIC`5D.idata = ++uic;
X sprintf(uafdata`5BUAI$_UIC`5D.sdata, "`5B%o,%o`5D", uic >> 16, uic & 0xF
VFFF);
X XmTextSetString(widget_array`5BUAI$_UIC`5D, uafdata`5BUAI$_UIC`5D.sdata)
V;
X`7D
X
X
X/*
X * Translate UIC to identifier format, if identifiers are loaded
X * Called by update_strings, return key in Account widget, and Accounts sel
Vector
X */
X
Xstatic void trans_uic(Cardinal uic)
X`7B
X ident *ptr;
X char group`5B32`5D = "", member`5B32`5D = "", suic`5B32`5D;
X Arg arg`5B1`5D;
X XmString xmstr;
X
X for (ptr = ident_list; ptr; ptr = ptr->next)
X if (ptr->identifier == uic)
X strcpy(member, ptr->name);
X else if (ptr->identifier == (uic & 0x7FFF0000 `7C 0xFFFF))
X strcpy(group, ptr->name);
X if (member`5B0`5D)
X if (group`5B0`5D)
X sprintf(suic, "(`5B%s,%s`5D)", group, member);
X else
X sprintf(suic, "(`5B%s`5D)", member);
X else
X sprintf(suic, "(`5B%o,%o`5D)", uic >> 16, uic & 0xFFFF);
X
X xmstr = XmStringCreateSimple(suic);
X XtSetArg(arg`5B0`5D, XmNlabelString, xmstr);
X XtSetValues(widget_array`5Bk_widget_uic_trans`5D, arg, 1);
X XmStringFree(xmstr);
X`7D
X `20
X
X/*
X * Close the work_box dialog box
X */
X
Xstatic void close_work_box()
X`7B
X if (XtIsManaged(work_box))
X XtUnmanageChild(work_box);
X XUndefineCursor(top_display, top_window);
X`7D
X
X
X/*
X * WorkProc to put one identifier on the idents list
X */
X
Xstatic Boolean idents_work_proc(XtPointer data)
X`7B
X Cardinal status, resid, ac = 0, pct;
X static int id, count, rdbctx;
X Arg arglist`5B5`5D;
X ushort namlen;
X XmString xmstr;
X char idbuf`5B35`5D, str`5B30`5D;
X Pixmap gague_pixmap;
X char gague`5B100`5D;
X $DESCRIPTOR(name_dsc, idbuf);
X
X if (!ident_ptr) `7B /* init count, id, context on first & subsequent ca
Vlls */
X count = 0;
X id = -1;
X sys$finish_rdb(&rdbctx);
X `7D
X count++;
X if (((count % 100) == 0) && (count >= 200)) `7B
X sprintf(str, "Reading identifier %d", count);
X ac = 0;
X xmstr = XmStringCreateSimple(str);
X XtSetArg(arglist`5Bac`5D, XmNmessageString, xmstr); ac++;
X XtSetValues(work_box, arglist, ac);
X XmStringFree(xmstr);
X `7D
X
X status = sys$idtoasc(id, &namlen, &name_dsc, &resid, 0, &rdbctx);
X if (status == SS$_NOSUCHID) `7B
X close_work_box();
X idents_work_proc_id = (XtWorkProcId) 0;
X build_accounts();
X update_held();
X return TRUE;
X `7D
X if (status != SS$_NORMAL) `7B
X sys$finish_rdb(&rdbctx);
X DWPmsg("read_identifiers", status);
X close_work_box();
X idents_work_proc_id = (XtWorkProcId) 0;
X return TRUE;
X `7D
X if (ident_ptr)
X ident_ptr = ident_ptr->next = XtNew(ident);
X else
X ident_list = ident_ptr = XtNew(ident);
X idbuf`5Bnamlen`5D = '\0';
X ident_ptr->name = XtNewString(idbuf);
X ident_ptr->next = NULL;
X ident_ptr->identifier = resid;
X if ((resid > 0x80010000) && /* if not VMS defined idents */
X strncmp(idbuf, "SYS$NODE", 8)) `7B /* and not SYS$NODE_xxx */
X ident_ptr->status = user_ident; /* it's a regular ident */
X ident_count++;
X `7D
X else if (resid > 0x80000000) /* if a non-uic ident and not a user ident
V */
X ident_ptr->status = intern_ident; /* it's a internal ident */
X else if ((resid & 0xFFFF) == 0xFFFF) `7B
X ident_ptr->status = account; /* accounts end in FFFF */
X account_count++;
X `7D
X else `7B
X ident_ptr->status = uic_ident;
X uic_count++;
X `7D
X return FALSE;
X`7D
X
X
X/*
X * Build list of identifiers if list is empty or if 'force' true
X */
X
Xstatic void read_identifiers(Boolean force)
X`7B
X Cardinal ac;
X Arg arglist`5B10`5D;
X XmString xmstr;
X ident *ptr, *tptr;
X
X if (!idents_work_proc_id && (!ident_list `7C`7C force)) `7B
X if (!work_box) `7B
X ac = 0;
X XtSetArg(arglist`5Bac`5D, XmNheight, 120); ac++;
X XtSetArg(arglist`5Bac`5D, XmNwidth, 220); ac++;
X XtSetArg(arglist`5Bac`5D, XmNresizePolicy, XmRESIZE_NONE); ac++;
X xmstr = XmStringCreateSimple("DWProfile: Reading Identifiers");
X XtSetArg(arglist`5Bac`5D, XmNdialogTitle, xmstr); ac++;
X work_box = XmCreateWorkingDialog(dwprofile_main, "work_box", arg
Vlist, ac);
X XmStringFree(xmstr);
X XtUnmanageChild(XmMessageBoxGetChild(work_box, XmDIALOG_OK_BUTTO
VN));
X XtUnmanageChild(XmMessageBoxGetChild(work_box, XmDIALOG_HELP_BUT
VTON));
X XtAddCallback(work_box, XmNcancelCallback, IdentsCancelCallback,
V NULL);
X `7D
X ac = 0;
X xmstr = XmStringCreateSimple("Reading identifiers");
X XtSetArg(arglist`5Bac`5D, XmNmessageString, xmstr); ac++;
X XtSetValues(work_box, arglist, ac);
X XmStringFree(xmstr);
X if (resource_data.show_work && !XtIsManaged(work_box))
X XtManageChild(work_box); /* pop up work box */
X
X for (ptr = ident_list; ptr;) `7B /* free old ident list */
X XtFree(ptr->name);
X tptr = ptr;
X ptr = ptr->next;
X XtFree(tptr);
X `7D
X ident_list = ident_ptr = select_ptr = NULL;
X account_count = uic_count = ident_count = 0;
X idents_work_proc_id = XtAppAddWorkProc(context, idents_work_proc, NU
VLL);
X `7D
X`7D
X
X
X/*
X * Check each uic identifier for match against select_string
X * Update found_add (the end of found_list)
X */
X
Xstatic Boolean find_work_proc(XtPointer data)
X`7B
X char message`5B80`5D, match_string`5B80`5D;
X Boolean matched;
X Cardinal status, uic;
X ushort length, logfails;
X String sptr;
X struct dsc$descriptor_s ident_dsc = `7B 0, DSC$K_DTYPE_T, DSC$K_CLASS_S,
V NULL `7D;
X $DESCRIPTOR(select_dsc, select_string);
X $DESCRIPTOR(match_dsc, match_string);
X
X select_dsc.dsc$w_length = strlen(select_string);
X if (!ident_list) `7B /* No idents read, this is bad and shouldn't hap
Vpen */
X find_work_proc_id = (XtWorkProcId) 0;
X return TRUE;
X `7D
X if (!select_ptr) /* select_ptr is the workproc control variable */
X select_ptr = ident_list;
X if (select_ptr->status != uic_ident) `7B
X select_ptr = select_ptr->next; /* only look at uic type idents */
X return FALSE;
X `7D
X ident_dsc.dsc$a_pointer = select_ptr->name;
+-+-+-+-+-+-+-+- END OF PART 2 +-+-+-+-+-+-+-+-
Technical Details
Message-ID:
<9908584@MVB.SAIC.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!usc!sdd.hp.com!network.ucsd.edu!mvb.saic.com!vmsnet-sourcesShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!usc!sdd.hp.com!network.ucsd.edu!mvb.saic.com!vmsnet-sources From: tanner@cerritos.edu Newsgroups: vmsnet.sources Subject: DWProfile V3.3, part 02/06 Message-ID: <9908584@MVB.SAIC.COM> Date: Mon, 04 Jan 1993 20:46:37 GMT Organization: Cerritos College, Norwalk CA Lines: 1403 Approved: Mark.Berryman@Mvb.Saic.Com