home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / vmsnet / sources / 473 < prev    next >
Encoding:
Text File  |  1993-01-05  |  47.6 KB  |  1,414 lines

  1. Path: sparky!uunet!cs.utexas.edu!usc!sdd.hp.com!network.ucsd.edu!mvb.saic.com!vmsnet-sources
  2. From: tanner@cerritos.edu
  3. Newsgroups: vmsnet.sources
  4. Subject: DWProfile V3.3, part 02/06
  5. Message-ID: <9908584@MVB.SAIC.COM>
  6. Date: Mon, 04 Jan 1993 20:46:37 GMT
  7. Organization: Cerritos College, Norwalk CA
  8. Lines: 1403
  9. Approved: Mark.Berryman@Mvb.Saic.Com
  10.  
  11. Submitted-by: tanner@cerritos.edu
  12. Posting-number: Volume 4, Issue 27
  13. Archive-name: dwprofile/part02
  14.  
  15. -+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
  16. X    `7B"versionLimit", "VersionLimit", XtRInt, sizeof(int),
  17. X     XtOffset(ApplicationDataPtr, version_limit), XtRString, "0"`7D,
  18. X    `7B"minimumGroup", "MinimumGroup", XtRInt, sizeof(int),
  19. X     XtOffset(ApplicationDataPtr, minimum_group), XtRString, "0"`7D,
  20. X    `7B"maximumGroup", "MaximumGroup", XtRInt, sizeof(int),
  21. X     XtOffset(ApplicationDataPtr, maximum_group), XtRString, "32767"`7D
  22. X`7D;
  23. X
  24. X#define dwp32_width 32
  25. X#define dwp32_height 32
  26. Xstatic char dwp32_bits`5B`5D = `7B
  27. X   0x00, 0x00, 0x20, 0x80, 0xfe, 0xff, 0xaf, 0xbf, 0x82, 0x20, 0xa8, 0xaa,
  28. X   0xfe, 0xff, 0xaf, 0xbf, 0x82, 0x20, 0xa8, 0xaa, 0xfe, 0xff, 0xaf, 0xbf,
  29. X   0x82, 0x20, 0xa8, 0xaa, 0xfe, 0xff, 0xaf, 0xbf, 0xaa, 0xaa, 0xaa, 0xaa,
  30. X   0xfe, 0xff, 0xaf, 0xbf, 0xaa, 0xaa, 0xaa, 0xaa, 0xfe, 0xff, 0xaf, 0xbf,
  31. X   0xfe, 0xff, 0x2f, 0x80, 0xe2, 0x38, 0xee, 0xff, 0xfe, 0xff, 0xef, 0xff,
  32. X   0xe2, 0x38, 0xee, 0xff, 0xfe, 0xff, 0xef, 0xff, 0xe2, 0x38, 0xee, 0xff,
  33. X   0xfe, 0xff, 0xef, 0xff, 0xe2, 0x38, 0xee, 0xff, 0xfe, 0xff, 0xef, 0xff,
  34. X   0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  35. X   0x00, 0x00, 0xe0, 0xff, 0xfe, 0xff, 0xef, 0xff, 0x02, 0x06, 0xe8, 0xff,
  36. X   0xfe, 0xff, 0xef, 0xff, 0x02, 0x06, 0xe8, 0xff, 0xfe, 0xff, 0xef, 0xff,
  37. X   0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff`7D;
  38. X
  39. Xstatic String uidname`5B`5D = `7B
  40. X    "DWPUID:DWPROFILE.UID",
  41. X    "DWPUID:ACCESS.UID",
  42. X    "DWPUID:PRIVS.UID",
  43. X    "DWPUID:IDENTS.UID",
  44. X`7D;
  45. X
  46. X#define HELP_LIBRARY "DWPUID:DWPROFILE.HLB"
  47. $ CALL UNPACK DWPDEF.H;49 408054743
  48. $ create 'f'
  49. X/*  DWPROFILE.C -- Authorize/Profile/DECburger replacement     */
  50. X/*  Copyright `A9 1990,1991,1992 Bruce Tanner - Cerritos College */
  51. X
  52. X/*
  53. X *  Revision history:
  54. X *   9/4/90   Version 1.0
  55. X *   9/12/90  Version 1.1
  56. X *            Added popup menu for access, privs boxes.
  57. X *            Forced 12 point Helvetica Bold font.
  58. X *            Moved lots of stuff to the resource file.
  59. X *            Added date of last login, logfails.
  60. X *   10/10/90 Version 2.0
  61. X *            Create/delete directory.
  62. X *            Add/delete disk quota.
  63. X *            Grant/revoke identifiers.
  64. X *            Take username from command line.
  65. X *   11/28/90 Version 2.1
  66. X *            Fixed: Dup UIC from calc_uic() on multiple adds from same reco
  67. Vrd.
  68. X *            Fixed: Identifier not changed on UIC change.
  69. X *   8/21/91  Version 2.2
  70. X *            Fixed: directory creation; add quota THEN create directory.
  71. X *            Check for blank owner, account DEFAULT, defdir `5BUSER`5D
  72. X *            Fixed: New account created bad UIC.
  73. X *   10/9/92  Version 2.3
  74. X *            Keep list of identifiers up to date.
  75. X *            Minor code cleanup.
  76. X *   10/27/92 Version 3.0
  77. X *            Converted to Motif.
  78. X *   11/4/92  Version 3.1
  79. X *            Added Select menu and Find Next button.
  80. X *   11/13/92 Version 3.2
  81. X *            Added Help menu item.
  82. X *   11/30/92 Version 3.3
  83. X *            Beta test bug fixes and the usual code randomizing.
  84. X */
  85. X
  86. X#define TITLE "DWProfile"
  87. X#module DWProfile "DWProfile V3.3"
  88. X#include descrip
  89. X#include string
  90. X#include ssdef
  91. X#include stdio
  92. X#include clidef
  93. X#include jpidef
  94. X#include prvdef
  95. X#include rmsdef
  96. X#include strdef
  97. X#include str$routines
  98. X#include <decw$cursor.h>
  99. X#include "dwpdef.h"
  100. X#include <X11/Intrinsic.h>
  101. X#include <Xm/Xm.h>
  102. X#include <Xm/MwmUtil.h>
  103. X#include <Mrm/Mrm.h>
  104. X#include <Xm/RowColumn.h>
  105. X#include <Xm/MessageB.h>
  106. X#include <Xm/SelectioB.h>
  107. X#include <Xm/DrawingA.h>
  108. X#include <DXm/DECspecific.h>
  109. X#include <DXm/DXmHelpB.h>
  110. X
  111. Xstatic MrmHierarchy Hierarchy;
  112. Xstatic MrmType class;
  113. Xstatic XtAppContext context;
  114. Xstatic Widget toplevel, dwprofile_main, access_box, privs_box,
  115. X    widget_array`5BMAX_WIDGET`5D, flags_array`5BMAX_FLAGS`5D,
  116. X    prime_array`5BMAX_PRIME`5D, privs_array`5BMAX_PRIVS`5D,
  117. X    button_array`5BMAX_MENUS`5D, idents_box, accounts_box, work_box;
  118. Xstatic void init_application(), get_gc(), update_prime(),
  119. X    update_time(Cardinal), update_strings(), update_flags(),
  120. X    update_privs(), set_translations(), set_handlers(),
  121. X    trans_uic(Cardinal), make_cursor(), build_popup(),
  122. X    update_held(), set_defaults(), build_accounts(), pos_functions(),
  123. X    DWPerror(String, String, int), DWPmsg(String, Cardinal),
  124. X    progress(ident *), read_identifiers(Boolean);
  125. Xstatic Boolean get_record(String), parse_uic(int);
  126. Xstatic XtEventHandler popup_handler(), access_handler();
  127. Xstatic XtCallbackProc WidgetCreated(), WidgetChanged(),
  128. X    Quit(), Write(), Read(), Find(), Remove(), Access(),
  129. X    Privs(), Accounts(), Idents(),
  130. X    FlagsCreated(), FlagsChanged(),
  131. X    PrimeCreated(), PrimeChanged(),
  132. X    PrivsCreated(), PrivsChanged(),
  133. X    AccountChanged(), CautionCallback(),
  134. X    MessageCallback(), ReadIdentifiers(),
  135. X    ListSelect(), IdentsCancelCallback(),
  136. X    ButtonCreated(), Select(), FindCancelCallback(),
  137. X    Help(), DestroyHelpCallback();
  138. Xstatic XtActionProc return_key(), select_key();
  139. Xstatic MrmRegisterArg regvec`5B`5D = `7B
  140. X    `7B"WidgetCreated", WidgetCreated`7D,
  141. X    `7B"WidgetChanged", WidgetChanged`7D,
  142. X    `7B"Quit", Quit`7D,
  143. X    `7B"Write", Write`7D,
  144. X    `7B"Read", Read`7D,
  145. X    `7B"Find", Find`7D,
  146. X    `7B"Remove", Remove`7D,
  147. X    `7B"Access", Access`7D,
  148. X    `7B"Privs", Privs`7D,
  149. X    `7B"Accounts", Accounts`7D,
  150. X    `7B"FlagsCreated", FlagsCreated`7D,
  151. X    `7B"FlagsChanged", FlagsChanged`7D,
  152. X    `7B"PrimeCreated", PrimeCreated`7D,
  153. X    `7B"PrimeChanged", PrimeChanged`7D,
  154. X    `7B"PrivsCreated", PrivsCreated`7D,
  155. X    `7B"PrivsChanged", PrivsChanged`7D,
  156. X    `7B"ReadIdentifiers", ReadIdentifiers`7D,
  157. X    `7B"Idents", Idents`7D,
  158. X    `7B"ListSelect", ListSelect`7D,
  159. X    `7B"ButtonCreated", ButtonCreated`7D,
  160. X    `7B"Select", Select`7D,
  161. X    `7B"Help", Help`7D
  162. X`7D;
  163. Xstatic char return_translation`5B`5D = "<Key>Return: return_key()",
  164. X    select_translation`5B`5D = "<Key>osfSelect: select_key()";
  165. Xstatic XtActionsRec action_table`5B`5D = `7B
  166. X    `7B"return_key", return_key`7D,
  167. X    `7B"select_key", select_key`7D
  168. X`7D;                                            `20
  169. Xstatic String fallbacks`5B`5D = `7B
  170. X    "*fontList: -Adobe-Helvetica-Bold-R-Normal--12-120-75-75-P-*-*-*",
  171. X    NULL
  172. X`7D;
  173. Xstatic String select_string, unpad(String);
  174. Xstatic ApplicationData resource_data;
  175. Xstatic struct `7B
  176. X    int idata;
  177. X    Boolean changed;
  178. X    char sdata`5BSDATA_LEN`5D, odata`5BSDATA_LEN`5D;
  179. X    `7D uafdata`5BMAX_WIDGET`5D;
  180. Xstatic struct itemlist3 itmlst`5BMAX_WIDGET`5D;
  181. Xstatic Display *top_display;
  182. Xstatic Window top_window;
  183. Xstatic GC gc_draw, gc_clear;
  184. Xstatic Boolean setting_widgets, setting_prime, setting_flags, setting_privs;
  185. Xstatic ident *ident_list = NULL, *select_ptr = NULL, *ident_ptr, *found_ptr,
  186. X     *found_add, found_list = `7BNULL, 0, 0, NULL`7D;
  187. Xstatic held_ident *held_list = NULL;
  188. Xstatic Cardinal uic_count, account_count, ident_count, select_index;
  189. Xstatic XtIntervalId timeout_id, progress_id;
  190. Xstatic Cursor wait_cursor;
  191. Xstatic XtWorkProcId idents_work_proc_id, find_work_proc_id;
  192. X
  193. X
  194. Xmain(unsigned int argc, char *argv`5B`5D)
  195. X`7B
  196. X    Cardinal status, ac;
  197. X    Arg arglist`5B5`5D;
  198. X    Pixmap icon_pixmap;
  199. X
  200. X    init_application();
  201. X    MrmInitialize();
  202. X    DXmInitialize();
  203. X    ac = 0;
  204. X    XtSetArg(arglist`5Bac`5D, XmNtitle, TITLE); ac++;
  205. X    XtSetArg(arglist`5Bac`5D, XmNmwmDecorations,
  206. X             MWM_DECOR_MENU `7CMWM_DECOR_BORDER `7C MWM_DECOR_TITLE `7C
  207. X             MWM_DECOR_MINIMIZE); ac++;
  208. X    toplevel = XtAppInitialize(&context, "DWProfile", NULL, 0, &argc, argv,
  209. X                               fallbacks, arglist, ac);
  210. X
  211. X    status = MrmOpenHierarchy(XtNumber(uidname), uidname, NULL, &Hierarchy);
  212. X    if (status != MrmSUCCESS) lib$signal(status);
  213. X
  214. X    status = MrmRegisterNames(regvec, XtNumber(regvec));
  215. X    if (status != MrmSUCCESS) lib$signal(status);
  216. X
  217. X    if ((MrmFetchWidget(Hierarchy, "dwprofile_main", toplevel,
  218. X                        &dwprofile_main, &class)) != MrmSUCCESS)
  219. X        XtAppError(context, "Error Fetching main widget");
  220. X
  221. X    XtGetApplicationResources(toplevel, &resource_data, resources,
  222. X                              XtNumber(resources), NULL, 0);
  223. X
  224. X    XtManageChild(dwprofile_main);
  225. X    XtRealizeWidget(toplevel);
  226. X
  227. X    top_display = XtDisplay(toplevel);
  228. X    top_window = XtWindow(toplevel);
  229. X    icon_pixmap = XCreateBitmapFromData(top_display, top_window,
  230. X                                        dwp32_bits, dwp32_width, dwp32_heigh
  231. Vt);
  232. X
  233. X    /* Set up the WM icons via shell widget attributes */
  234. X    ac = 0;
  235. X    XtSetArg(arglist`5Bac`5D, XmNiconPixmap, icon_pixmap); ac++;
  236. X    XtSetValues(toplevel, arglist, ac);
  237. X
  238. X    make_cursor();             /* create wait_cursor */
  239. X    set_translations();        /* set text widget translations */
  240. X    build_popup();             /* build a popup menu */
  241. X    get_gc();                  /* set up stuff for access windows */
  242. X    pos_functions();           /* center the functions box */
  243. X
  244. X    if (argc == 1)
  245. X        get_record("");        /* Initialize text fields */
  246. X
  247. X    /* load username if given on command line */
  248. X    if (argc == 2)
  249. X        if (!get_record(argv`5B1`5D))
  250. X            if (get_record("DEFAULT"))
  251. X                set_defaults(argv`5B1`5D);
  252. X            else
  253. X                DWPerror("Main Init", "Cannot read username DEFAULT", 0);
  254. X
  255. X    /* set up the windows based on resource file */
  256. X    if (resource_data.show_access) Access(NULL, NULL, NULL);
  257. X    if (resource_data.show_privs) Privs(NULL, NULL, NULL);
  258. X    if (resource_data.show_accounts) Accounts(NULL, NULL, NULL);
  259. X    if (resource_data.show_idents) Idents(NULL, NULL, NULL);
  260. X
  261. X    /* traverse to the username widget */
  262. X    XmProcessTraversal(widget_array`5BUAI$_USERNAME`5D, XmTRAVERSE_CURRENT);
  263. X
  264. X    XtAppMainLoop(context);
  265. X`7D
  266. X
  267. X
  268. X/*** Initialization Routines ***/
  269. X
  270. X/*
  271. X *  Set sysprv
  272. X *  Clear out widget arrays
  273. X */
  274. X
  275. Xstatic void init_application()
  276. X`7B
  277. X    Cardinal ind, status, my_privs`5B2`5D,
  278. X        jpicode = JPI$_AUTHPRIV, priv_mask`5B2`5D = `7B0, 0`7D;
  279. X
  280. X    status = lib$getjpi(&jpicode, 0, 0, &my_privs, 0, 0);
  281. X    if (status != SS$_NORMAL)
  282. X        XtAppError(context, "lib$getjpi failed");
  283. X      `20
  284. X    if (my_privs`5B0`5D & (PRV$M_SYSPRV `7C PRV$M_SETPRV)) `7B
  285. X        priv_mask`5B0`5D `7C= PRV$M_SYSPRV;
  286. X        status = sys$setprv(ON, &priv_mask, 0, 0);
  287. X        if (status != SS$_NORMAL)
  288. X            XtAppError(context, "sys$setprv failed");
  289. X    `7D
  290. X    else `7B
  291. X        printf("Insufficient privilege to see other than your own UAF record
  292. V\n");
  293. X/*        exit(); */
  294. X    `7D
  295. X
  296. X    for (ind = 0; ind < MAX_WIDGET; ind++) widget_array`5Bind`5D = NULL;
  297. X    for (ind = 0; ind < MAX_FLAGS; ind++) flags_array`5Bind`5D = NULL;
  298. X    for (ind = 0; ind < MAX_PRIVS; ind++) privs_array`5Bind`5D = NULL;
  299. X    for (ind = 0; ind < MAX_PRIME; ind++) prime_array`5Bind`5D = NULL;
  300. X`7D
  301. X
  302. X
  303. X/*
  304. X *  Load the cursor font and allocate colors for the cursor
  305. X */
  306. X
  307. Xstatic void make_cursor()
  308. X`7B
  309. X    Colormap cmap;
  310. X    XColor red, white, dummy;
  311. X    Font cursorfont;
  312. X
  313. X    cmap = DefaultColormap(top_display, DefaultScreen(top_display));
  314. X
  315. X    XAllocNamedColor(top_display, cmap, "white", &white, &dummy);
  316. X    XAllocNamedColor(top_display, cmap, "red", &red, &dummy);
  317. X
  318. X    cursorfont = XLoadFont(top_display, "DECW$CURSOR");
  319. X    wait_cursor = XCreateGlyphCursor(top_display, cursorfont, cursorfont,
  320. X                  decw$c_wait_cursor, decw$c_wait_cursor+1, &red, &white);
  321. X
  322. X`7D
  323. X
  324. X
  325. X/*
  326. X *  Override the translation table of the Username, Account text widgets
  327. X *  Override Select translation for selectable fields
  328. X */
  329. X
  330. Xstatic void set_translations()
  331. X`7B
  332. X    Cardinal si;
  333. X    XtTranslations compiled_trans;
  334. X
  335. X    XtAppAddActions(context, action_table, XtNumber(action_table));
  336. X
  337. X    compiled_trans = XtParseTranslationTable(return_translation);
  338. X    XtOverrideTranslations(widget_array`5BUAI$_USERNAME`5D, compiled_trans);
  339. X    XtOverrideTranslations(widget_array`5BUAI$_ACCOUNT`5D, compiled_trans);
  340. X
  341. X    compiled_trans = XtParseTranslationTable(select_translation);
  342. X    for(si = 0; select_data`5Bsi`5D.code; si++)
  343. X        if (select_data`5Bsi`5D.type != DWP_RINT)
  344. X            XtOverrideTranslations(widget_array`5Bselect_data`5Bsi`5D.code`5
  345. VD, compiled_trans);
  346. X`7D
  347. X
  348. X
  349. X/*
  350. X *  Set up event handlers for access windows
  351. X */
  352. X
  353. Xstatic void set_handlers()
  354. X`7B
  355. X    Cardinal wi;
  356. X
  357. X    for (wi = UAI$_NETWORK_ACCESS_P; wi <= UAI$_REMOTE_ACCESS_S; wi++)
  358. X        if (widget_array`5Bwi`5D)
  359. X            XtAddEventHandler(widget_array`5Bwi`5D,
  360. X                              ButtonPressMask `7C ButtonReleaseMask `7C Expo
  361. VsureMask `7C
  362. X                              Button1MotionMask, FALSE, access_handler, wi);
  363. X`7D
  364. X
  365. X
  366. X/*
  367. X *  Build a MenuPopup widget and children
  368. X */
  369. X
  370. Xstatic void build_popup()
  371. X`7B
  372. X#define MENUS 4
  373. X    Arg arglist`5B2`5D;
  374. X    Cardinal ac, ind;
  375. X    struct `7B
  376. X        String resource;
  377. X        String title;
  378. X        XtCallbackProc callback;
  379. X    `7D params`5BMENUS`5D = `7B
  380. X        `7B"access_button", "Access...", Access`7D,
  381. X        `7B"privs_button", "Privs...", Privs`7D,
  382. X        `7B"accounts_button", "Accounts...", Accounts`7D,
  383. X        `7B"idents_button", "Identifiers...", Idents`7D
  384. X    `7D;
  385. X    Widget menu_items`5BMENUS`5D, popup_menu;
  386. X
  387. X    popup_menu = XmCreatePopupMenu(dwprofile_main, "popup", NULL, 0);
  388. X    /* pass popup_menu as the client data for popup() */
  389. X    XtAddEventHandler(dwprofile_main, ButtonPressMask, FALSE, popup_handler,
  390. V popup_menu);
  391. X
  392. X    for (ind = 0; ind < MENUS; ind++) `7B
  393. X        ac = 0;
  394. X        XtSetArg(arglist`5Bac`5D, XmNlabelString, XmStringCreateSimple(param
  395. Vs`5Bind`5D.title)); ac++;
  396. X        menu_items`5Bind`5D = XmCreatePushButtonGadget(popup_menu, params`5B
  397. Vind`5D.resource, arglist, ac);
  398. X        XtAddCallback(menu_items`5Bind`5D, XmNactivateCallback, params`5Bind
  399. V`5D.callback, 0);
  400. X    `7D
  401. X
  402. X    XtManageChildren(menu_items, ind);   /* just the buttons, not the menu *
  403. V/
  404. X`7D
  405. X
  406. X
  407. X/*
  408. X *  Set up the graphic contexts gc_draw and gc_clear
  409. X */
  410. X
  411. Xstatic void get_gc()
  412. X`7B
  413. X    Cardinal ac;
  414. X    Arg arglist`5B2`5D;
  415. X    XGCValues gc_values;
  416. X    Pixel foreground, background;
  417. X
  418. X    ac = 0;
  419. X    XtSetArg(arglist`5Bac`5D, XmNforeground, &foreground);  ac++;
  420. X    XtSetArg(arglist`5Bac`5D, XmNbackground, &background);  ac++;
  421. X    XtGetValues(dwprofile_main, arglist, ac);
  422. X    gc_values.foreground = foreground;
  423. X    gc_values.background = background;
  424. X    gc_draw = XtGetGC(dwprofile_main, GCForeground `7C GCBackground, &gc_val
  425. Vues);
  426. X    gc_values.foreground = background;
  427. X    gc_clear = XtGetGC(dwprofile_main, GCForeground, &gc_values);
  428. X`7D
  429. X
  430. X
  431. X
  432. X/*** Utility Routines ***/
  433. X
  434. X/*
  435. X *  Set the username, password and directory name
  436. X *  Called by main, Read
  437. X */
  438. X
  439. Xstatic void set_defaults(String user)
  440. X`7B
  441. X    Arg arg`5B1`5D;
  442. X    char text`5B40`5D;
  443. X
  444. X    /* SetString sets .sdata and .changed */
  445. X    XmTextSetString(widget_array`5BUAI$_USERNAME`5D, user);
  446. X    XmTextSetString(widget_array`5BUAI$_PWD`5D, user);
  447. X    sprintf(uafdata`5BUAI$_DEFDIR`5D.sdata, "`5B%s`5D", user);
  448. X    XmTextSetString(widget_array`5BUAI$_DEFDIR`5D, uafdata`5BUAI$_DEFDIR`5D.
  449. Vsdata);
  450. X
  451. X    sprintf(text, "%s\n%s", TITLE, user);
  452. X    XtSetArg(arg`5B0`5D, XmNiconName, text);
  453. X    XtSetValues(toplevel, arg, 1); /* update the icon name */
  454. X`7D
  455. X
  456. X
  457. X/*
  458. X *  Center the functions box
  459. X */
  460. X
  461. Xstatic void pos_functions()
  462. X`7B
  463. X  Arg arglist`5B5`5D;
  464. X  Cardinal ac;
  465. X  Dimension funct_width, main_width, funct_x, new_x;
  466. X
  467. X  ac = 0;
  468. X  XtSetArg(arglist`5Bac`5D, XmNwidth, &funct_width); ac++;
  469. X  XtSetArg(arglist`5Bac`5D, XmNx, &funct_x); ac++;
  470. X  XtGetValues(button_array`5Bfunctions_menu`5D, arglist, ac);
  471. X  ac = 0;
  472. X  XtSetArg(arglist`5Bac`5D, XmNwidth, &main_width); ac++;
  473. X  XtGetValues(dwprofile_main, arglist, ac);
  474. X  new_x = (main_width - funct_width) / 2;
  475. X  ac = 0;
  476. X  XtSetArg(arglist`5Bac`5D, XmNx, new_x); ac++;
  477. X  XtSetValues(button_array`5Bfunctions_menu`5D, arglist, ac);
  478. X`7D
  479. X
  480. X
  481. X/*
  482. X *  Lookup a UAF record and fill those widgets
  483. X *  Called by Read and program initialization
  484. X */
  485. X
  486. Xstatic Boolean get_record(String acct)
  487. X`7B
  488. X    Cardinal status, ind, si, resid, rdbctx = 0, holder`5B2`5D = `7B0, 0`7D;
  489. X    ushort namlen;
  490. X    ident *ptr;
  491. X    held_ident *hptr, *tptr;
  492. X    Arg arg`5B1`5D;
  493. X    char text`5B40`5D, nambuf`5B40`5D;
  494. X    $DESCRIPTOR(acct_dsc, acct);
  495. X    $DESCRIPTOR(name_dsc, nambuf);
  496. X
  497. X    /* reset all the data storage */
  498. X    for (ind = 0; ind < MAX_WIDGET; ind++) `7B
  499. X        memset(uafdata`5Bind`5D.sdata, 0, SDATA_LEN);
  500. X        uafdata`5Bind`5D.idata = 0;
  501. X        uafdata`5Bind`5D.changed = FALSE;
  502. X    `7D
  503. X
  504. X    /* acct = "" means clear form */
  505. X    if (strlen(acct)) `7B`20
  506. X        acct_dsc.dsc$w_length = strlen(acct);
  507. X        for (ind = 0; ; ind++) `7B
  508. X            itmlst`5Bind`5D.buflen = items`5Bind`5D.size;
  509. X            itmlst`5Bind`5D.itmcode = items`5Bind`5D.code;
  510. X            if (!items`5Bind`5D.code) break;    /* exit after copying zero e
  511. Vntry */
  512. X            if (items`5Bind`5D.size > 4)        /* anything that fits goes i
  513. Vn .idata */
  514. X                itmlst`5Bind`5D.bufadr = uafdata`5Bitems`5Bind`5D.code`5D.sd
  515. Vata;
  516. X            else
  517. X                itmlst`5Bind`5D.bufadr = &uafdata`5Bitems`5Bind`5D.code`5D.i
  518. Vdata;
  519. X            itmlst`5Bind`5D.retadr = 0;
  520. X        `7D
  521. X        status = sys$getuai(0, 0, &acct_dsc, &itmlst, 0, 0, 0);
  522. X
  523. X        if ((status & 7) != SS$_NORMAL)  /* often SS$_BUFFEROVF */
  524. X            return FALSE;    /* probably not found */
  525. X
  526. X        for (ind = 0; items`5Bind`5D.code; ind++)    /* reset changed flags
  527. V */
  528. X            uafdata`5Bitems`5Bind`5D.code`5D.changed = FALSE;
  529. X
  530. X        /* remember the old values of device and directory */
  531. X        memcpy(uafdata`5BUAI$_DEFDEV`5D.odata, uafdata`5BUAI$_DEFDEV`5D.sdat
  532. Va, 32);
  533. X        memcpy(uafdata`5BUAI$_DEFDIR`5D.odata, uafdata`5BUAI$_DEFDIR`5D.sdat
  534. Va, 64);
  535. X    `7D
  536. X
  537. X    for (hptr = held_list; hptr;) `7B /* free old held list */
  538. X        tptr = hptr;
  539. X        hptr = hptr->next;
  540. X        XtFree(tptr);
  541. X    `7D
  542. X    held_list = NULL;
  543. X
  544. X    if (strlen(acct)) `7B
  545. X        holder`5B0`5D = uafdata`5BUAI$_UIC`5D.idata;
  546. X        for (hptr = held_list;;) `7B
  547. X            status = sys$find_held(&holder, &resid, 0, &rdbctx);
  548. X            if (status == SS$_NOSUCHID) break;
  549. X            if (status != SS$_NORMAL) `7B
  550. X                sys$finish_rdb(&rdbctx);
  551. X                DWPmsg("get_record", status);
  552. X                break;
  553. X            `7D
  554. X            if (hptr)
  555. X                hptr = hptr->next = XtNew(held_ident);
  556. X            else
  557. X                held_list = hptr = XtNew(held_ident);
  558. X            hptr->next = NULL;
  559. X            hptr->identifier = resid;
  560. X            hptr->status = original;
  561. X            status = sys$idtoasc(resid, &namlen, &name_dsc, 0, 0, 0);
  562. X            nambuf`5Bnamlen`5D = '\0';
  563. X            hptr->name = XtNewString(nambuf);
  564. X        `7D
  565. X    `7D
  566. X
  567. X    uafdata`5BUAI$_PWD`5D.sdata`5B0`5D = '\0';    /* discard password for Wr
  568. Vite()*/
  569. X
  570. X    update_strings();      /* update the string widgets */
  571. X    update_flags();        /* update the flag toggle button widgets */
  572. X    update_prime();        /* update the primary days and time widgets */
  573. X    update_privs();        /* update the privs toggle button widgets */
  574. X    update_held();         /* update the list of held identifiers */
  575. X
  576. X    if (strlen(acct)) `7B
  577. X        sprintf(text, "%s\n%s", TITLE, acct);
  578. X        XtSetArg(arg`5B0`5D, XmNiconName, text);
  579. X        XtSetValues(toplevel, arg, 1); /* update the icon name */
  580. X    `7D
  581. X    return TRUE;
  582. X`7D
  583. X
  584. X
  585. X/*
  586. X *  Find all UAI elements that have (text) widgets and update them
  587. X */
  588. X
  589. Xstatic void update_strings()
  590. X`7B
  591. X    Cardinal ind, value, status;
  592. X    ushort length;
  593. X    char str`5BSDATA_LEN`5D, *ptr;
  594. X    Arg arg`5B1`5D;
  595. X    XmString xmstr;
  596. X
  597. X    setting_widgets = TRUE;
  598. X    for (ind = 0; value = items`5Bind`5D.code; ind++)
  599. X        if (widget_array`5Bvalue`5D)
  600. X            switch (items`5Bind`5D.type) `7B
  601. X            case DWP_LALPHA:    /* string with length byte */
  602. X                /* can't use unpad() because owner field contains spaces */
  603. X                length = (ushort) uafdata`5Bvalue`5D.sdata`5B0`5D;
  604. X                uafdata`5Bvalue`5D.sdata`5Blength+1`5D = '\0';
  605. X                XmTextSetString(widget_array`5Bvalue`5D,
  606. X                                &uafdata`5Bvalue`5D.sdata`5B1`5D);
  607. X                break;
  608. X            case DWP_ALPHA:    /* string (username, account) */
  609. X                XmTextSetString(widget_array`5Bvalue`5D,
  610. X                    unpad(uafdata`5Bvalue`5D.sdata));
  611. X                break;
  612. X            case DWP_ENCR:    /* password */
  613. X                XmTextSetString(widget_array`5Bvalue`5D, "");  /* clear fiel
  614. Vd */
  615. X                break;
  616. X            case DWP_DATE:    /* text date */
  617. X                `7B
  618. X                $DESCRIPTOR(time_dsc, str);
  619. X
  620. X                sys$asctim(&length, &time_dsc, uafdata`5Bvalue`5D.sdata, 0);
  621. X                str`5Blength`5D = '\0';
  622. X                ptr = strstr(str, ":00.00");
  623. X                if (ptr) *ptr = '\0';
  624. X                if (!strncmp(str, "17-NOV-1858", 11))
  625. X                    strcpy(str,"(none)");    /* handle 'none' */
  626. X                XmTextSetString(widget_array`5Bvalue`5D, str);
  627. X                break;
  628. X                `7D
  629. X            case DWP_RDATE:    /* label date */
  630. X                `7B
  631. X                $DESCRIPTOR(time_dsc, str);
  632. X
  633. X                sys$asctim(&length, &time_dsc, uafdata`5Bvalue`5D.sdata, 0);
  634. X                str`5Blength`5D = '\0';
  635. X                ptr = strrchr(str, ':');
  636. X                if (ptr) *ptr = '\0'; /* chop off :ss.cc */
  637. X                if (!strncmp(str, "17-NOV-1858", 11))
  638. X                    strcpy(str,"(none)");    /* handle 'none' */
  639. X                xmstr = XmStringCreateSimple(str);
  640. X                XtSetArg(arg`5B0`5D, XmNlabelString, xmstr);
  641. X                XtSetValues(widget_array`5Bvalue`5D, arg, 1);
  642. X                XmStringFree(xmstr);
  643. X                break;
  644. X                `7D
  645. X            case DWP_CPU:    /* CPU time */
  646. X                if (!uafdata`5Bvalue`5D.idata)
  647. X                    strcpy(str, "(none)");
  648. X                else `7B
  649. X                    Cardinal dd, hh, mm, ss, cc, time = uafdata`5Bvalue`5D.i
  650. Vdata;
  651. X
  652. X                    dd =  time / 8640000;
  653. X                    time -= dd * 8640000;
  654. X                    hh =  time / 360000;
  655. X                    time -= hh * 360000;
  656. X                    mm =  time / 6000;
  657. X                    time -= mm * 6000;
  658. X                    ss =  time / 100;
  659. X                    time -= ss * 100;
  660. X                    cc =  time;
  661. X                    sprintf(str, "%d %02d:%02d:%02d.%02d",
  662. X                                  dd,  hh,  mm,  ss,  cc);
  663. X                `7D
  664. X                XmTextSetString(widget_array`5Bvalue`5D, str);
  665. X                break;
  666. X            case DWP_UIC:    /* UIC */
  667. X                sprintf(uafdata`5Bvalue`5D.sdata, "`5B%o,%o`5D",
  668. X                    uafdata`5Bvalue`5D.idata >> 16,
  669. X                    uafdata`5Bvalue`5D.idata & 0xFFFF);
  670. X                XmTextSetString(widget_array`5Bvalue`5D,
  671. X                    uafdata`5Bvalue`5D.sdata);
  672. X                trans_uic(uafdata`5Bvalue`5D.idata);
  673. X                break;
  674. X            case DWP_INT:    /* text integer */
  675. X                sprintf(str, "%d", uafdata`5Bvalue`5D.idata);
  676. X                XmTextSetString(widget_array`5Bvalue`5D, str);
  677. X                break;
  678. X            case DWP_RINT:    /* label integer */
  679. X                sprintf(str, "%d", uafdata`5Bvalue`5D.idata);
  680. X                xmstr = XmStringCreateSimple(str);
  681. X                XtSetArg(arg`5B0`5D, XmNlabelString, xmstr);
  682. X                XtSetValues(widget_array`5Bvalue`5D, arg, 1);
  683. X                XmStringFree(xmstr);
  684. X                break;
  685. X            `7D
  686. X    setting_widgets = FALSE;
  687. X`7D
  688. X
  689. X
  690. X/*
  691. X *  Update login flags toggle buttons according to UAI data
  692. X */
  693. X
  694. Xstatic void update_flags()
  695. X`7B
  696. X    Cardinal ind;
  697. X    Boolean notify = NO;
  698. X
  699. X    setting_flags = TRUE;
  700. X    for (ind = 0; ind < MAX_FLAGS; ind++)
  701. X        if (flags_array`5Bind`5D)
  702. X            if (uafdata`5BUAI$_FLAGS`5D.idata >> ind & 1)
  703. X                XmToggleButtonSetState(flags_array`5Bind`5D, ON, notify);
  704. X            else
  705. X                XmToggleButtonSetState(flags_array`5Bind`5D, OFF, notify);
  706. X    setting_flags = FALSE;
  707. X`7D
  708. X
  709. X
  710. X/*
  711. X *  Set the buttons to reflect primedays
  712. X *  Set the time map window widgets
  713. X */
  714. X
  715. Xstatic void update_prime()
  716. X`7B
  717. X    Cardinal ind;
  718. X    Boolean notify = NO;
  719. X
  720. X    setting_prime = TRUE;
  721. X    for (ind = 0; ind < MAX_PRIME; ind++)
  722. X        if (prime_array`5Bind`5D)
  723. X            XmToggleButtonSetState(prime_array`5Bind`5D,
  724. X                uafdata`5BUAI$_PRIMEDAYS`5D.idata >> ind & 1 `5E 1, notify);
  725. X    setting_prime = FALSE;
  726. X
  727. X    update_time(UAI$_NETWORK_ACCESS_P);
  728. X    update_time(UAI$_NETWORK_ACCESS_S);
  729. X    update_time(UAI$_BATCH_ACCESS_P);
  730. X    update_time(UAI$_BATCH_ACCESS_S);
  731. X    update_time(UAI$_LOCAL_ACCESS_P);
  732. X    update_time(UAI$_LOCAL_ACCESS_S);
  733. X    update_time(UAI$_DIALUP_ACCESS_P);
  734. X    update_time(UAI$_DIALUP_ACCESS_S);
  735. X    update_time(UAI$_REMOTE_ACCESS_P);
  736. X    update_time(UAI$_REMOTE_ACCESS_S);
  737. X`7D
  738. X
  739. X
  740. X/*
  741. X *  Set the priv buttons to reflect auth priv & default priv
  742. X *  the buttons for default privs 0-38 are kept in privs_array`5B0-38`5D
  743. X *  the buttons for auth privs 0-38 are kept in privs_array`5B40-78`5D
  744. X *  (PRIVS_BIAS is 40)
  745. X */
  746. X
  747. Xstatic void update_privs()
  748. X`7B
  749. X    Cardinal ind;
  750. X    Boolean notify = NO;
  751. X
  752. X    setting_privs = TRUE;
  753. X    for (ind = 0; ind < MAX_PRIVS/2; ind++)
  754. X        if (privs_array`5Bind`5D)
  755. X            if (uafdata`5BUAI$_PRIV`5D.sdata`5Bind >> 3`5D >> (ind & 7) & 1)
  756. X                XmToggleButtonSetState(privs_array`5Bind`5D, ON, notify);
  757. X            else
  758. X                XmToggleButtonSetState(privs_array`5Bind`5D, OFF, notify);
  759. X
  760. X    for (ind = PRIVS_BIAS; ind < MAX_PRIVS; ind++)
  761. X        if (privs_array`5Bind`5D)
  762. X            if (uafdata`5BUAI$_DEF_PRIV`5D.sdata`5Bind - PRIVS_BIAS >> 3`5D
  763. V >>
  764. X                    (ind - PRIVS_BIAS & 7) & 1)
  765. X                XmToggleButtonSetState(privs_array`5Bind`5D, ON, notify);
  766. X            else
  767. X                XmToggleButtonSetState(privs_array`5Bind`5D, OFF, notify);
  768. X    setting_privs = FALSE;
  769. X`7D   `20
  770. X
  771. X
  772. X/*
  773. X *  Update a time map window widget
  774. X */
  775. X
  776. Xstatic void update_time(Cardinal code)
  777. X`7B
  778. X    Cardinal ind;
  779. X    Display *display;
  780. X    Window window;
  781. X
  782. X    if (!widget_array`5Bcode`5D) return;          /* return if no widget */
  783. X
  784. X    display = XtDisplay(widget_array`5Bcode`5D);  /* get display for XFill *
  785. V/
  786. X    window = XtWindow(widget_array`5Bcode`5D);    /* get window for XFill */
  787. X    if (!window) return;                      /* Just paranoia? */
  788. X
  789. X    switch (uafdata`5Bcode`5D.idata) `7B            /* speed up special case
  790. Vs */
  791. X    case 0:        /* full access */
  792. X        XFillRectangle(display, window, gc_draw,
  793. X                       0, 0, resource_data.hour_size * 24, k_hours_height);
  794. X        break;
  795. X    case 0xFFFFFF:    /* no access */
  796. X        XFillRectangle(display, window, gc_clear,
  797. X                       0, 0, resource_data.hour_size * 24, k_hours_height);
  798. X        break;
  799. X    default:
  800. X        XFillRectangle(display, window, gc_draw,
  801. X                       0, 0, resource_data.hour_size * 24, k_hours_height);
  802. X        for (ind = 0; ind < 24; ind++)
  803. X            if (uafdata`5Bcode`5D.idata >> ind & 1)
  804. X                XFillRectangle(display, window, gc_clear,
  805. X                               ind * resource_data.hour_size, 0,
  806. X                               resource_data.hour_size, k_hours_height);
  807. X    `7D
  808. X`7D
  809. X
  810. X
  811. X/*
  812. X *  Update the list of held identifiers
  813. X */
  814. X
  815. Xstatic void update_held()
  816. X`7B
  817. X    Cardinal status, ac, ind, entries, position;
  818. X    Boolean already_granted;
  819. X    Arg arglist`5B5`5D;
  820. X    ident *ptr;
  821. X    held_ident *hptr;
  822. X    XmString *items;
  823. X
  824. X    /* quit if the idents box is not there, or still building ident_list */
  825. X    if (!idents_box `7C`7C !XtIsManaged(idents_box) `7C`7C idents_work_proc_
  826. Vid)
  827. X        return;
  828. X
  829. X    items = (XmString *)XtCalloc(ident_count, sizeof(XmString));
  830. X
  831. X    /* show the held idents list */
  832. X    for (hptr = held_list, ind = 0; hptr; hptr = hptr->next)
  833. X        if (hptr->status == original `7C`7C hptr->status == add_ident)
  834. X            items`5Bind++`5D = XmStringCreateSimple(hptr->name);
  835. X    entries = ind;  /* save count of list entries */
  836. X    if (ind > ident_count)
  837. X        XtAppError(context, "held ident array overflow in update_held()");
  838. X    /* The Motif FAQ says that this will free memory used by the old list */
  839. X    ac = 0;
  840. X    XtSetArg(arglist`5Bac`5D, XmNitems, items); ac++;
  841. X    XtSetArg(arglist`5Bac`5D, XmNitemCount, ind); ac++;
  842. X    XtSetValues(widget_array`5Bk_widget_held_list`5D, arglist, ac);
  843. X    for (ind = 0; ind < entries; ind++)
  844. X        XmStringFree(items`5Bind`5D);
  845. X
  846. X    /* show all the non-uic idents not already held */
  847. X    for (ptr = ident_list, ind = 0; ptr; ptr = ptr->next)
  848. X        if (ptr->status == user_ident) `7B
  849. X            already_granted = FALSE;
  850. X            for (hptr = held_list; hptr; hptr = hptr->next)
  851. X                already_granted `7C= (hptr->identifier == ptr->identifier) &
  852. V&
  853. X                                   (hptr->status != del_orig);
  854. X            if (!already_granted) `7B  /* if user doesn't already have id */
  855. X                if (!strcmp(ptr->name, resource_data.default_ident))
  856. X                    position = ind;
  857. X                items`5Bind++`5D = XmStringCreateSimple(ptr->name);
  858. X            `7D
  859. X        `7D
  860. X    entries = ind;  /* save count of list entries */
  861. X    if (ind > ident_count)
  862. X        XtAppError(context, "all ident array overflow in update_held()");
  863. X    ac = 0;
  864. X    XtSetArg(arglist`5Bac`5D, XmNitems, items); ac++;
  865. X    XtSetArg(arglist`5Bac`5D, XmNitemCount, ind); ac++;
  866. X    XtSetArg(arglist`5Bac`5D, XmNtopItemPosition, position + 1); ac++;
  867. X    XtSetValues(widget_array`5Bk_widget_all_list`5D, arglist, ac);
  868. X    for (ind = 0; ind < entries; ind++)
  869. X        XmStringFree(items`5Bind`5D);
  870. X
  871. X    XtFree(items);
  872. X`7D
  873. X
  874. X
  875. X/*
  876. X *  Force text to uppercase
  877. X *  Called by WidgetChanged, AccountChanged
  878. X */
  879. X
  880. Xstatic void uppercase(String str)
  881. X`7B
  882. X    String str2;
  883. X
  884. X    for (str2 = str; *str2; str2++)
  885. X        *str2 = toupper(*str2);
  886. X`7D
  887. X   `20
  888. X
  889. X/*
  890. X *  Remove trailing blanks from a DWP_LALPHA data item
  891. X *  Returns the address of the string
  892. X */
  893. X
  894. Xstatic String unpad(String alpha)
  895. X`7B
  896. X    String ptr;
  897. X
  898. X    ptr = strchr(alpha, ' ');
  899. X    if (ptr) *ptr = '\0';  /* if there is a trailing space, trim it */
  900. X    if ((Cardinal) alpha`5B0`5D < 32)
  901. X        return alpha + 1;  /* if there is a length byte, return the start of
  902. V the string */
  903. X    else
  904. X        return alpha;
  905. X`7D
  906. X
  907. X
  908. X/*
  909. X *  Signal a local error
  910. X *  Interval = -2 means don't do anything
  911. X *             -1 means just printf to stdout
  912. X *              0 means popup message box without timeout
  913. X *              > 0 means popup message box with timeout in 'interval' ms
  914. X */
  915. X
  916. Xstatic void DWPerror(String where, String what, int interval)
  917. X`7B
  918. X    Cardinal ac;
  919. X    Arg arglist`5B5`5D;
  920. X    char msg`5B100`5D;
  921. X    XmString xmstr;
  922. X    static Widget message_box = NULL;
  923. X
  924. X    if (interval == -2)
  925. X        return;
  926. X    if (interval == -1) `7B
  927. X        printf("%s  (From: %s)\n", what, where);
  928. X        return;
  929. X    `7D
  930. X    if (!message_box) `7B
  931. X        ac = 0;
  932. X        xmstr = XmStringCreateSimple("DWProfile: Warning Message");
  933. X        XtSetArg(arglist`5Bac`5D, XmNdialogTitle, xmstr); ac++;
  934. X`09message_box = XmCreateMessageDialog(dwprofile_main, "message_box", arglis
  935. Vt, ac);
  936. X        XmStringFree(xmstr);
  937. X        XtUnmanageChild(XmMessageBoxGetChild(message_box, XmDIALOG_HELP_BUTT
  938. VON));
  939. X        XtUnmanageChild(XmMessageBoxGetChild(message_box, XmDIALOG_CANCEL_BU
  940. VTTON));
  941. X`09XtAddCallback(message_box, XmNokCallback, MessageCallback, NULL);
  942. X    `7D
  943. X    ac = 0;
  944. X    sprintf(msg, "%s\nFrom: %s", what, where);
  945. X    xmstr = XmStringCreateLtoR(msg,XmSTRING_DEFAULT_CHARSET);
  946. X    XtSetArg(arglist`5Bac`5D, XmNmessageString, xmstr); ac++;
  947. X    XtSetValues(message_box, arglist, ac);
  948. X    XmStringFree(xmstr);
  949. X    XtManageChild(message_box);    /* popup message box */
  950. X    if (interval)
  951. X        timeout_id = XtAppAddTimeOut(context, interval, MessageCallback, mes
  952. Vsage_box);
  953. X    XFlush(top_display);
  954. X`7D
  955. X
  956. X
  957. X/*
  958. X *  Signal an external error
  959. X */
  960. X
  961. Xstatic void DWPmsg(String where, Cardinal msg)
  962. X`7B
  963. X    char buffer`5B100`5D;
  964. X    Cardinal status;
  965. X    ushort length;
  966. X    $DESCRIPTOR(txt_dsc, buffer);
  967. X
  968. X    status = sys$getmsg(msg, &length, &txt_dsc, 0, 0);
  969. X    buffer`5Blength`5D = '\0';
  970. X    if ((status & 7) == SS$_NORMAL)
  971. X        DWPerror(where, buffer, 0);
  972. X    else
  973. X        DWPerror(where, "Unknown", 0);
  974. X`7D
  975. X
  976. X
  977. X/*
  978. X *  Do a DCL command
  979. X *  Called by Write
  980. X */
  981. X
  982. Xstatic void spawn_dcl(String str)
  983. X`7B
  984. X    Cardinal status, substatus = SS$_NORMAL, flags = CLI$M_NOCLISYM, /* `7C
  985. V CLI$M_NOLOGNAM */
  986. X          devlen, ctx, count = 0;
  987. X    char *cptr, dev1`5B40`5D = "", dev2`5B40`5D, dir`5B40`5D, result`5B40`5D
  988. V, filespec`5B40`5D;
  989. X    ident *iptr, *prev;
  990. X    FILE *file;
  991. X    $DESCRIPTOR(dcl_dsc, "DCL.TMP");
  992. X#ifdef DEBUG
  993. X    $DESCRIPTOR(out_dsc, "TT:");
  994. X#else
  995. X    $DESCRIPTOR(out_dsc, "NL:");  /* change to TT: for debugging command fil
  996. Ves */
  997. X#endif
  998. X    $DESCRIPTOR(dev1_dsc, dev1);
  999. X    $DESCRIPTOR(dev2_dsc, dev2);
  1000. X    $DESCRIPTOR(res_dsc, result);
  1001. X    $DESCRIPTOR(file_dsc, filespec);
  1002. X    Boolean remove_command = !strncmp(str, "$ UAF REMOVE", 12);
  1003. X    Boolean modify_uic = strstr(str, "$ UAF MODIFY") && strstr(str, "/UIC");
  1004. X
  1005. X#ifdef DEBUG
  1006. X    printf("spawn_dcl(%s)\n", str);
  1007. X#endif
  1008. X
  1009. X    /* set up dev1, dev2, dir */
  1010. X    /* if from getuai, it has a length byte; if from text widget, not */
  1011. X    strcpy(dev1, unpad(uafdata`5BUAI$_DEFDEV`5D.sdata));
  1012. X    if (dev1`5Bstrlen(dev1) - 1`5D == ':')
  1013. X        dev1`5Bstrlen(dev1) - 1`5D = '\0'; /* strip off trailing ':' */
  1014. X    dev1_dsc.dsc$w_length = strlen(dev1);
  1015. X    status = lib$sys_trnlog(&dev1_dsc, &devlen, &dev2_dsc, 0, 0, 0);
  1016. X    cptr = strchr(dev2, ' ');
  1017. X    if (cptr) *cptr = '\0'; /* null terminate */
  1018. X    cptr = strchr(dev2, ':');
  1019. X    if (cptr) *cptr = '\0'; /* physical device without ':' */
  1020. X    strcpy(dir, unpad(uafdata`5BUAI$_DEFDIR`5D.sdata));
  1021. X    if (dir`5B0`5D == '`5B')
  1022. X        strcpy(dir, dir + 1);         /* strip off `5B */
  1023. X    if (dir`5Bstrlen(dir) - 1`5D == '`5D')
  1024. X        dir`5Bstrlen(dir) - 1`5D = '\0';  /* strip off `5D */
  1025. X
  1026. X    file = fopen("DCL.TMP","w");
  1027. X#ifdef DEBUG
  1028. X    fprintf(file, "$ SET VERIFY\n");
  1029. X    fprintf(file, "$ SHOW LOGICAL DWPUID\n");
  1030. X#endif   `20
  1031. X    fprintf(file, "$ DELETE DCL.TMP;*\n");
  1032. X    fprintf(file, "$ PREVPRIV = F$SETPRV(\"ALL\")\n");
  1033. X    fprintf(file, "$ DEFINE/USER SYSUAF SYS$SYSTEM:SYSUAF\n");
  1034. X    fprintf(file, "$ UAF :== $AUTHORIZE\n");
  1035. X    fprintf(file, "%s\n", str);
  1036. X
  1037. X    /* if the command is REMOVE, delete mail profile */
  1038. X    if (remove_command) `7B
  1039. X        fprintf(file, "$ MAIL\n");
  1040. X        fprintf(file, "%s\n", str);
  1041. X        fprintf(file, "EXIT\n");
  1042. X    `7D
  1043. X
  1044. X    /* if the command is REMOVE, delete disk files and directory */
  1045. X    if (remove_command && strlen(dev1) && strlen(dir))
  1046. X        fprintf(file, "$ @DWPUID:DELTREE %s:`5B%s`5D\n", dev1, dir);
  1047. X
  1048. X    /* add the quota and overdraft resources.
  1049. X       The default (0) is to do nothing, i.e. use the `5Bgroup,0`5D entry
  1050. X       in quota.sys.  Set the resources 'quota' and 'overdraft' to use
  1051. X       a fixed quota
  1052. X    */
  1053. X    /* if defdev exists and a fixed disk quota specified */
  1054. X    if (strlen(dev1) && (resource_data.quota)) `7B
  1055. X        sprintf(filespec, "%s:`5B000000`5DQUOTA.SYS", dev2);
  1056. X        file_dsc.dsc$w_length = strlen(filespec);
  1057. X        ctx = 0;
  1058. X        status = lib$find_file(&file_dsc, &res_dsc, &ctx, 0, 0, 0, 0);
  1059. X        lib$find_file_end(&ctx);
  1060. X        if ((status & 7) == SS$_NORMAL) `7B  /* QUOTA.SYS exists */
  1061. X            fprintf(file, "$ RUN SYS$SYSTEM:DISKQUOTA\n");
  1062. X            fprintf(file, "USE %s\n", dev2);
  1063. X            if (remove_command)
  1064. X                fprintf(file, "REMOVE %s\n", uafdata`5BUAI$_UIC`5D.sdata);
  1065. X            else
  1066. X                fprintf(file, "ADD %s /PERMQUOTA=%d /OVERDRAFT=%d\n",
  1067. X                    uafdata`5BUAI$_UIC`5D.sdata, resource_data.quota,
  1068. X                    resource_data.overdraft);
  1069. X            fprintf(file, "EXIT\n");
  1070. X        `7D
  1071. X    `7D   `20
  1072. X    fclose(file);
  1073. X    status = lib$spawn(0, &dcl_dsc, &out_dsc, &flags, 0, 0, &substatus, 0, 0
  1074. V, 0, 0, 0);
  1075. X    if ((substatus & 7) != SS$_NORMAL)   /* probably CLI$_NORMAL */
  1076. X        DWPmsg("Spawned process status", substatus);
  1077. X    if (status != SS$_NORMAL)
  1078. X        DWPmsg("Spawn_DCL", status);
  1079. X
  1080. X    if (!remove_command && strlen(dev1) && strlen(dir)) `7B
  1081. X        sprintf(filespec, "%s:`5B000000`5D%s.DIR", dev1, dir);
  1082. X        file_dsc.dsc$w_length = strlen(filespec);
  1083. X        ctx = 0;
  1084. X        status = lib$find_file(&file_dsc, &res_dsc, &ctx, 0, 0, 0, 0);
  1085. X        lib$find_file_end(&ctx);
  1086. X        filespec`5B0`5D == '\0';
  1087. X        if (status == RMS$_FNF) `7B
  1088. X/*          setpriv(ON, PRV$M_BYPASS `7C PRV$M_EXQUOTA `7C PRV$M_SYSPRV); */
  1089. X            sprintf(filespec, "%s:`5B%s`5D", dev1, dir);
  1090. X            file_dsc.dsc$w_length = strlen(filespec);
  1091. X            if (strlen(filespec)) `7B
  1092. X                status = lib$create_dir(&file_dsc, &uafdata`5BUAI$_UIC`5D.id
  1093. Vata, 0, 0,
  1094. X                    &resource_data.version_limit, 0);
  1095. X#ifdef DEBUG
  1096. X                printf("create_dir %s  status = %d\n", filespec, status);
  1097. X#endif
  1098. X                if (status != SS$_CREATED)
  1099. X                    DWPmsg("Create Dir", status);
  1100. X            `7D
  1101. X        `7D
  1102. X    `7D
  1103. X
  1104. X    /* If REMOVE, remove identifier from ident_list */
  1105. X    if (remove_command `7C`7C modify_uic) `7B
  1106. X        for (iptr = ident_list, prev = NULL; iptr; prev = iptr, iptr = iptr-
  1107. V>next)
  1108. X            if (!strcmp(iptr->name, uafdata`5BUAI$_USERNAME`5D.sdata)) break
  1109. V;
  1110. X        if (iptr) `7B
  1111. X            if (prev)
  1112. X                prev->next = iptr->next;
  1113. X            else
  1114. X                ident_list = iptr->next;
  1115. X            XtFree(iptr->name);
  1116. X            XtFree(iptr);
  1117. X            uic_count--;
  1118. X        `7D
  1119. X        /* identifier may still be on found_list */
  1120. X        for (iptr = found_list.next, prev = &found_list; iptr; prev = iptr,
  1121. V iptr = iptr->next)
  1122. X            if (!strcmp(iptr->name, uafdata`5BUAI$_USERNAME`5D.sdata)) break
  1123. V;
  1124. X        if (iptr) `7B
  1125. X            prev->next = iptr->next;
  1126. X            XtFree(iptr->name);
  1127. X            XtFree(iptr);
  1128. X            if (iptr == found_ptr)
  1129. X                found_ptr = prev;
  1130. X            if (iptr == found_add)
  1131. X                found_add = prev;
  1132. X        `7D
  1133. X        /* remove group identifier if no other uic in group */
  1134. X        for (iptr = ident_list; iptr; iptr = iptr->next)
  1135. X            if ((iptr->identifier >> 16) == (uafdata`5BUAI$_UIC`5D.idata >>
  1136. V 16))
  1137. X                count++;
  1138. X        if (count == 1) `7B
  1139. X            for (iptr = ident_list, prev = NULL; iptr; prev = iptr, iptr = i
  1140. Vptr->next)
  1141. X                if (iptr->identifier == (uafdata`5BUAI$_UIC`5D.idata `7C 0xF
  1142. VFFF)) break;
  1143. X            if (iptr) `7B
  1144. X                if (prev)
  1145. X                    prev->next = iptr->next;
  1146. X                else
  1147. X                    ident_list = iptr->next;
  1148. X                XtFree(iptr->name);
  1149. X                XtFree(iptr);
  1150. X                account_count--;
  1151. X            `7D
  1152. X        `7D
  1153. X        if (accounts_box && XtIsManaged(accounts_box)) `7B
  1154. X            XtUnmanageChild(accounts_box);
  1155. X            Accounts(NULL, NULL, NULL);  /* reload accounts select box */
  1156. X        `7D
  1157. X    `7D
  1158. X`7D
  1159. X
  1160. X
  1161. X/*
  1162. X *  Calculate the next available UIC in the group that matches the account
  1163. X *   or finds the next available group if there is no match
  1164. X *  Updates the UIC widget and uafdata fields.
  1165. X *  Called when an account is selected via selector widget or from return_ke
  1166. Vy
  1167. X *   when in the account text widget
  1168. X */
  1169. X
  1170. Xstatic void calc_uic()
  1171. X`7B
  1172. X    Cardinal status, maxgroup = resource_data.minimum_group,
  1173. X          groupid = 0, uic = 0;
  1174. X    ushort length;
  1175. X    ident *ptr;
  1176. X    $DESCRIPTOR(group_dsc, uafdata`5BUAI$_ACCOUNT`5D.sdata);
  1177. X   `20
  1178. X    /* read in text widget */
  1179. X    if (!parse_uic(UAI$_UIC))
  1180. X        DWPerror("calc_uic","Illegal UIC format", 0);
  1181. X    if (uafdata`5BUAI$_UIC`5D.idata) return;    /* don't recalc if UIC exist
  1182. Vs */
  1183. X    read_identifiers(FALSE);
  1184. X    group_dsc.dsc$w_length = strlen(uafdata`5BUAI$_ACCOUNT`5D.sdata);
  1185. X    status = sys$asctoid(&group_dsc, &groupid, 0);
  1186. X    for (ptr = ident_list; ptr; ptr = ptr->next) `7B
  1187. X        /* if groups match and not in `5Bn,*`5D and higher than old uic, sav
  1188. Ve it */
  1189. X        if (((ptr->identifier >> 16) == (groupid >> 16)) &&
  1190. X            ((ptr->identifier & 0xFFFF) != 0xFFFF))
  1191. X            uic = (ptr->identifier > uic) ? ptr->identifier : uic;
  1192. X        /* if this is a new group name, remember highest `5Bn,*`5D ident */
  1193. X        if (!groupid &&
  1194. X            (ptr->identifier < 0x80000000) &&
  1195. X            (ptr->identifier < (resource_data.maximum_group << 16)) &&
  1196. X            (ptr->identifier > maxgroup))
  1197. X            maxgroup = ptr->identifier;
  1198. X    `7D
  1199. X    if (!groupid)    /* new group name */
  1200. X        groupid = maxgroup + 0x10000;  /* highest group + 1 */
  1201. X    if (!uic)    /* if only `5Bx,177777`5D in UAF, give `5Bx,101`5D as uic *
  1202. V/
  1203. X        uic = (groupid & 0x7FFF0000) + 0100;
  1204. X    uafdata`5BUAI$_UIC`5D.idata = ++uic;
  1205. X    sprintf(uafdata`5BUAI$_UIC`5D.sdata, "`5B%o,%o`5D", uic >> 16, uic & 0xF
  1206. VFFF);
  1207. X    XmTextSetString(widget_array`5BUAI$_UIC`5D, uafdata`5BUAI$_UIC`5D.sdata)
  1208. V;
  1209. X`7D
  1210. X
  1211. X
  1212. X/*
  1213. X *  Translate UIC to identifier format, if identifiers are loaded
  1214. X *  Called by update_strings, return key in Account widget, and Accounts sel
  1215. Vector
  1216. X */
  1217. X
  1218. Xstatic void trans_uic(Cardinal uic)
  1219. X`7B
  1220. X    ident *ptr;
  1221. X    char group`5B32`5D = "", member`5B32`5D = "", suic`5B32`5D;
  1222. X    Arg arg`5B1`5D;
  1223. X    XmString xmstr;
  1224. X
  1225. X    for (ptr = ident_list; ptr; ptr = ptr->next)
  1226. X        if (ptr->identifier == uic)
  1227. X            strcpy(member, ptr->name);
  1228. X        else if (ptr->identifier == (uic & 0x7FFF0000 `7C 0xFFFF))
  1229. X            strcpy(group, ptr->name);
  1230. X    if (member`5B0`5D)
  1231. X        if (group`5B0`5D)
  1232. X            sprintf(suic, "(`5B%s,%s`5D)", group, member);
  1233. X        else
  1234. X            sprintf(suic, "(`5B%s`5D)", member);
  1235. X    else
  1236. X        sprintf(suic, "(`5B%o,%o`5D)", uic >> 16, uic & 0xFFFF);
  1237. X
  1238. X    xmstr = XmStringCreateSimple(suic);
  1239. X    XtSetArg(arg`5B0`5D, XmNlabelString, xmstr);
  1240. X    XtSetValues(widget_array`5Bk_widget_uic_trans`5D, arg, 1);
  1241. X    XmStringFree(xmstr);
  1242. X`7D
  1243. X   `20
  1244. X
  1245. X/*
  1246. X *  Close the work_box dialog box
  1247. X */
  1248. X
  1249. Xstatic void close_work_box()
  1250. X`7B
  1251. X        if (XtIsManaged(work_box))
  1252. X            XtUnmanageChild(work_box);
  1253. X        XUndefineCursor(top_display, top_window);
  1254. X`7D
  1255. X
  1256. X
  1257. X/*
  1258. X *  WorkProc to put one identifier on the idents list
  1259. X */
  1260. X
  1261. Xstatic Boolean idents_work_proc(XtPointer data)
  1262. X`7B
  1263. X    Cardinal status, resid, ac = 0, pct;
  1264. X    static int id, count, rdbctx;
  1265. X    Arg arglist`5B5`5D;
  1266. X    ushort namlen;
  1267. X    XmString xmstr;
  1268. X    char idbuf`5B35`5D, str`5B30`5D;
  1269. X    Pixmap gague_pixmap;
  1270. X    char gague`5B100`5D;
  1271. X    $DESCRIPTOR(name_dsc, idbuf);
  1272. X
  1273. X    if (!ident_ptr) `7B  /* init count, id, context on first & subsequent ca
  1274. Vlls */
  1275. X        count = 0;
  1276. X        id = -1;
  1277. X        sys$finish_rdb(&rdbctx);
  1278. X    `7D
  1279. X    count++;
  1280. X    if (((count % 100) == 0) && (count >= 200)) `7B
  1281. X        sprintf(str, "Reading identifier  %d", count);
  1282. X        ac = 0;
  1283. X        xmstr = XmStringCreateSimple(str);
  1284. X        XtSetArg(arglist`5Bac`5D, XmNmessageString, xmstr); ac++;
  1285. X        XtSetValues(work_box, arglist, ac);
  1286. X        XmStringFree(xmstr);
  1287. X    `7D
  1288. X
  1289. X    status = sys$idtoasc(id, &namlen, &name_dsc, &resid, 0, &rdbctx);
  1290. X    if (status == SS$_NOSUCHID) `7B
  1291. X        close_work_box();
  1292. X        idents_work_proc_id = (XtWorkProcId) 0;
  1293. X        build_accounts();
  1294. X        update_held();
  1295. X        return TRUE;
  1296. X    `7D
  1297. X    if (status != SS$_NORMAL) `7B
  1298. X        sys$finish_rdb(&rdbctx);
  1299. X        DWPmsg("read_identifiers", status);
  1300. X        close_work_box();
  1301. X        idents_work_proc_id = (XtWorkProcId) 0;
  1302. X        return TRUE;
  1303. X    `7D
  1304. X    if (ident_ptr)
  1305. X        ident_ptr = ident_ptr->next = XtNew(ident);
  1306. X    else
  1307. X        ident_list = ident_ptr = XtNew(ident);
  1308. X    idbuf`5Bnamlen`5D = '\0';
  1309. X    ident_ptr->name = XtNewString(idbuf);
  1310. X    ident_ptr->next = NULL;
  1311. X    ident_ptr->identifier = resid;
  1312. X    if ((resid > 0x80010000) &&    /* if not VMS defined idents */
  1313. X            strncmp(idbuf, "SYS$NODE", 8)) `7B /* and not SYS$NODE_xxx */
  1314. X        ident_ptr->status = user_ident;      /* it's a regular ident */
  1315. X        ident_count++;
  1316. X    `7D
  1317. X    else if (resid > 0x80000000)  /* if a non-uic ident and not a user ident
  1318. V */
  1319. X        ident_ptr->status = intern_ident;    /* it's a internal ident */
  1320. X    else if ((resid & 0xFFFF) == 0xFFFF) `7B
  1321. X        ident_ptr->status = account;         /* accounts end in FFFF */
  1322. X        account_count++;
  1323. X    `7D
  1324. X    else `7B
  1325. X        ident_ptr->status = uic_ident;
  1326. X        uic_count++;
  1327. X    `7D
  1328. X    return FALSE;
  1329. X`7D
  1330. X
  1331. X
  1332. X/*
  1333. X *  Build list of identifiers if list is empty or if 'force' true
  1334. X */
  1335. X
  1336. Xstatic void read_identifiers(Boolean force)
  1337. X`7B
  1338. X    Cardinal ac;
  1339. X    Arg arglist`5B10`5D;
  1340. X    XmString xmstr;
  1341. X    ident *ptr, *tptr;
  1342. X
  1343. X    if (!idents_work_proc_id && (!ident_list `7C`7C force)) `7B
  1344. X        if (!work_box) `7B
  1345. X            ac = 0;
  1346. X            XtSetArg(arglist`5Bac`5D, XmNheight, 120); ac++;
  1347. X            XtSetArg(arglist`5Bac`5D, XmNwidth, 220); ac++;
  1348. X            XtSetArg(arglist`5Bac`5D, XmNresizePolicy, XmRESIZE_NONE); ac++;
  1349. X            xmstr = XmStringCreateSimple("DWProfile: Reading Identifiers");
  1350. X            XtSetArg(arglist`5Bac`5D, XmNdialogTitle, xmstr); ac++;
  1351. X            work_box = XmCreateWorkingDialog(dwprofile_main, "work_box", arg
  1352. Vlist, ac);
  1353. X            XmStringFree(xmstr);
  1354. X            XtUnmanageChild(XmMessageBoxGetChild(work_box, XmDIALOG_OK_BUTTO
  1355. VN));
  1356. X            XtUnmanageChild(XmMessageBoxGetChild(work_box, XmDIALOG_HELP_BUT
  1357. VTON));
  1358. X            XtAddCallback(work_box, XmNcancelCallback, IdentsCancelCallback,
  1359. V NULL);
  1360. X        `7D
  1361. X        ac = 0;
  1362. X        xmstr = XmStringCreateSimple("Reading identifiers");
  1363. X        XtSetArg(arglist`5Bac`5D, XmNmessageString, xmstr); ac++;
  1364. X        XtSetValues(work_box, arglist, ac);
  1365. X        XmStringFree(xmstr);
  1366. X        if (resource_data.show_work && !XtIsManaged(work_box))
  1367. X            XtManageChild(work_box);    /* pop up work box */
  1368. X
  1369. X        for (ptr = ident_list; ptr;) `7B /* free old ident list */
  1370. X            XtFree(ptr->name);
  1371. X            tptr = ptr;
  1372. X            ptr = ptr->next;
  1373. X            XtFree(tptr);
  1374. X        `7D
  1375. X        ident_list = ident_ptr = select_ptr = NULL;
  1376. X        account_count = uic_count = ident_count = 0;
  1377. X        idents_work_proc_id = XtAppAddWorkProc(context, idents_work_proc, NU
  1378. VLL);
  1379. X    `7D
  1380. X`7D
  1381. X
  1382. X
  1383. X/*
  1384. X *  Check each uic identifier for match against select_string
  1385. X *  Update found_add (the end of found_list)
  1386. X */
  1387. X
  1388. Xstatic Boolean find_work_proc(XtPointer data)
  1389. X`7B
  1390. X    char message`5B80`5D, match_string`5B80`5D;
  1391. X    Boolean matched;
  1392. X    Cardinal status, uic;
  1393. X    ushort length, logfails;
  1394. X    String sptr;
  1395. X    struct dsc$descriptor_s ident_dsc = `7B 0, DSC$K_DTYPE_T, DSC$K_CLASS_S,
  1396. V NULL `7D;
  1397. X    $DESCRIPTOR(select_dsc, select_string);
  1398. X    $DESCRIPTOR(match_dsc, match_string);
  1399. X
  1400. X    select_dsc.dsc$w_length = strlen(select_string);
  1401. X    if (!ident_list) `7B    /* No idents read, this is bad and shouldn't hap
  1402. Vpen */
  1403. X        find_work_proc_id = (XtWorkProcId) 0;
  1404. X        return TRUE;
  1405. X    `7D
  1406. X    if (!select_ptr)  /* select_ptr is the workproc control variable */
  1407. X        select_ptr = ident_list;
  1408. X    if (select_ptr->status != uic_ident) `7B
  1409. X        select_ptr = select_ptr->next;  /* only look at uic type idents */
  1410. X        return FALSE;
  1411. X    `7D
  1412. X    ident_dsc.dsc$a_pointer = select_ptr->name;
  1413. +-+-+-+-+-+-+-+-  END  OF PART 2 +-+-+-+-+-+-+-+-
  1414.