\File{callbacks\-c.c},{10:23},{May 19 1991}
\L{\LB{\C{}\/*}}
\L{\LB{ * Generated by the ICS builderXcessory (BX).}}
\L{\LB{ *}}
\L{\LB{ *}}
\L{\LB{ * Builder Xcessory 1.0.1.}}
\L{\LB{ *}}
\L{\LB{ *\/\CE{}}}
\L{\LB{\K{\#include} \<Xm\/Xm.h\>}}
\L{\LB{\K{\#include} \<Text.h\>}}
\L{\LB{\K{\#include} \<stdio.h\>}}
\L{\LB{\K{\#include} \<strings.h\>}}
\L{\LB{}}
\L{\LB{\K{\#include} \S{}\"widgets.h\"\SE{}  \C{}\/* list of globally defined widgets *\/\CE{}}}
\L{\LB{\K{\#include} \S{}\"errors.h\"\SE{}  \C{}\/* error messages *\/\CE{}}}
\L{\LB{}}
\L{\LB{\K{\#include} \S{}\"params.h\"\SE{}  \C{}\/* lucy\-specific constants *\/\CE{}}}
\L{\LB{}}
\L{\LB{\K{\#include} \S{}\"hes.h\"\SE{}    \C{}\/* help editing system *\/\CE{}}}
\L{\LB{}}
\L{\LB{\K{static} Arg args[64];  \C{}\/* make these global vars local to this file *\/\CE{}}}
\L{\LB{\K{static} \K{int} argcnt;}}
\L{\LB{}}
\L{\LB{\K{static} text\_status = 0; \C{}\/* 0 means no text entered.}}
\L{\LB{}\Tab{24}{   1 means text has been entered.}}
\L{\LB{}\Tab{24}{   2 means that text has been saved.}}
\L{\LB{}\Tab{24}{   *\/\CE{}}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\K{extern} \K{void} Get\_Subjects(\K{void});}}
\L{\LB{\K{extern} \K{void} Get\_Transaction(\K{int}, \K{char} *, \K{int});}}
\L{\LB{}}
\L{\LB{\K{extern} \K{struct} \{}}
\L{\LB{  \K{char} subject[LINE\_SIZE];}}
\L{\LB{  \K{int} tnum; \C{}\/* transaction number *\/\CE{}}}
\L{\LB{\} browser[BROWSER\_MAX];}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\K{extern} \K{struct} \{}}
\L{\LB{  \K{char} name[HELPNAMSIZE];}}
\L{\LB{  \K{char} buffer[HELPBUFSIZE];}}
\L{\LB{  \} hw[MAXWIND]; \C{}\/* hw[MAXWIND]; *\/\CE{} \C{}\/* allow up to MAXWIND help screens *\/\CE{}}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\K{extern} \K{int} num\_browser; \C{}\/* keeps track of how many subjects are in browser *\/\CE{}  }}
\L{\LB{  }}
\L{\LB{\K{static} Boolean help\_on = False; \C{}\/* true means that help screen is onscreen *\/\CE{}}}
\L{\LB{}}
\L{\LB{\K{static} \K{char} text[QUESTION\_SIZE]; \C{}\/* text of question *\/\CE{}}}
\L{\LB{}}
\L{\LB{\C{}\/* browser\-\-up to BROWSER\_MAX topics can be displayed at a time.}}
\L{\LB{   each topic can be up to 128 characters long. *\/\CE{}}}
\L{\LB{}}
\L{\LB{\K{static} XmString browser\_xm[BROWSER\_MAX]; }}
\L{\LB{}}
\L{\LB{\K{void} free\_strings(strarray, index)}}
\L{\LB{     XmString strarray[];}}
\L{\LB{     \K{int} index;}}
\L{\LB{}}
\L{\LB{\{}}
\L{\LB{  \K{int} i;}}
\L{\LB{  \C{}\/* call XmFree for each string in the array *\/\CE{}}}
\L{\LB{}}
\L{\LB{  \K{for} (i=0; i \< index; i++) \{}}
\L{\LB{    XmStringFree(strarray[i]);}}
\L{\LB{  \}}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{\K{void} lucyCallback(w, client, call)}}
\L{\LB{     Widget w;}}
\L{\LB{     caddr\_t client;}}
\L{\LB{     caddr\_t call;}}
\L{\LB{}}
\L{\LB{\{}}
\L{\LB{}}
\L{\LB{  \K{static} \K{char} mess[] = \S{}\"\!n\!nLucy \!n\!}}
\L{\LB{User Interface Created by \!n\!}}
\L{\LB{UChin Kim, May 1991.\!n\!}}
\L{\LB{\!n\!}}
\L{\LB{\!n\!}}
\L{\LB{With help from:\!n\!}}
\L{\LB{the Builder Xcessory (Integrated Computer Solutions, Inc.) \&\&\!n\!}}
\L{\LB{Bruce R. Lewis.\!n\!n\"\SE{};}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{    }}
\L{\LB{  \C{}\/* display a message containing information about lucy program *\/\CE{}}}
\L{\LB{  Widget info;}}
\L{\LB{  XmString xm\_mess; \C{}\/* compound string *\/\CE{}}}
\L{\LB{  Widget bad\_child; \C{}\/* use to get rid of help and cancel buttons *\/\CE{}}}
\L{\LB{  \K{void} ErrorOKed();  \C{}\/* callback procedure *\/\CE{}}}
\L{\LB{}}
\L{\LB{  argcnt = 0;}}
\L{\LB{  xm\_mess = XmStringCreateLtoR(mess, XmSTRING\_DEFAULT\_CHARSET);}}
\L{\LB{  XtSetArg(args[argcnt], XmNmessageString, xm\_mess); argcnt++;}}
\L{\LB{  XtSetArg(args[argcnt], XmNmessageAlignment, XmALIGNMENT\_CENTER); argcnt++;}}
\L{\LB{  info = (Widget) XmCreateInformationDialog(w, \S{}\"error\"\SE{}, args, argcnt);}}
\L{\LB{}}
\L{\LB{  \C{}\/* get rid of help and cancel buttons because we don\'t need them. *\/\CE{}}}
\L{\LB{  bad\_child = (Widget) XmMessageBoxGetChild(info, XmDIALOG\_CANCEL\_BUTTON);}}
\L{\LB{  XtUnmanageChild(bad\_child);}}
\L{\LB{  bad\_child = (Widget) XmMessageBoxGetChild(info, XmDIALOG\_HELP\_BUTTON);}}
\L{\LB{  XtUnmanageChild(bad\_child);  }}
\L{\LB{}}
\L{\LB{}}
\L{\LB{  XtAddCallback(info, XmNokCallback, ErrorOKed, NULL);  \C{}\/* free up mem *\/\CE{}  }}
\L{\LB{  XtManageChild(info);  }}
\L{\LB{  XmStringFree(xm\_mess); \C{}\/* free the compound string space we have allocated *\/\CE{}}}
\L{\LB{}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\K{void}}}
\L{\LB{\Proc{DialogCancelCallback}DialogCancelCallback(w, client, call)}}
\L{\LB{Widget w;}}
\L{\LB{caddr\_t client;}}
\L{\LB{caddr\_t call;}}
\L{\LB{\{}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{  fprintf(stderr, \S{}\"Dialog Cancelled.\!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{  }}
\L{\LB{  XtUnmanageChild(DialogbulletinBoard);   }}
\L{\LB{}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{\K{void} ErrorOKed(w, client, call)}}
\L{\LB{     Widget w;}}
\L{\LB{     caddr\_t client;}}
\L{\LB{     caddr\_t call;}}
\L{\LB{\{}}
\L{\LB{}}
\L{\LB{  XtDestroyWidget(w);  \C{}\/* free up the memory associated with the widget *\/\CE{}}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{\K{void} ExplainError(w, mess)}}
\L{\LB{     Widget w;  \C{}\/* parent widget *\/\CE{}}}
\L{\LB{     \K{char} *mess; \C{}\/* error message *\/\CE{}}}
\L{\LB{}}
\L{\LB{\{}}
\L{\LB{  Widget mess\_box;}}
\L{\LB{  XmString xm\_mess; \C{}\/* compound string *\/\CE{}}}
\L{\LB{}}
\L{\LB{  Widget bad\_child; \C{}\/* use to get rid of help and cancel buttons *\/\CE{}}}
\L{\LB{}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{  fprintf(stderr, mess);}}
\L{\LB{\K{\#endif}}}
\L{\LB{}}
\L{\LB{  \C{}\/* create an error dialog box *\/\CE{}}}
\L{\LB{}}
\L{\LB{  argcnt = 0;}}
\L{\LB{  xm\_mess = XmStringCreateLtoR(mess, XmSTRING\_DEFAULT\_CHARSET);}}
\L{\LB{  XtSetArg(args[argcnt], XmNmessageString, xm\_mess); argcnt++; }}
\L{\LB{  mess\_box = (Widget) XmCreateErrorDialog(w, \S{}\"error\"\SE{}, args, argcnt);}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{  XtAddCallback(mess\_box, XmNokCallback, ErrorOKed, NULL);   }}
\L{\LB{  XtManageChild(mess\_box);}}
\L{\LB{}}
\L{\LB{  \C{}\/* get rid of help and cancel buttons because we don\'t need them. *\/\CE{}  }}
\L{\LB{  bad\_child = (Widget) XmMessageBoxGetChild(mess\_box, XmDIALOG\_CANCEL\_BUTTON);}}
\L{\LB{  XtUnmanageChild(bad\_child);}}
\L{\LB{  bad\_child = (Widget) XmMessageBoxGetChild(mess\_box, XmDIALOG\_HELP\_BUTTON);}}
\L{\LB{  XtUnmanageChild(bad\_child); }}
\L{\LB{}}
\L{\LB{}}
\L{\LB{  XmStringFree(xm\_mess); \C{}\/* free the compound string space we have allocated*\/\CE{}}}
\L{\LB{  }}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY  }}
\L{\LB{  fprintf(stderr, \S{}\"Just managed the error box. \!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{  }}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{     }}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\K{void}}}
\L{\LB{\Proc{DialogOKCallback}DialogOKCallback(w, client, call)}}
\L{\LB{Widget w;}}
\L{\LB{caddr\_t client;}}
\L{\LB{caddr\_t call;}}
\L{\LB{\{}}
\L{\LB{  \C{}\/* data from dialog window *\/\CE{}}}
\L{\LB{  Boolean pubYes, pubNo, replyYes, replyNo;}}
\L{\LB{  \K{char} *edit; \C{}\/* temp var. *\/\CE{}}}
\L{\LB{}}
\L{\LB{  \K{char} subject[LINE\_SIZE], username[LINE\_SIZE]; }}
\L{\LB{  \K{char} reply[LINE\_SIZE], publish[LINE\_SIZE];}}
\L{\LB{  }}
\L{\LB{  Boolean errored;}}
\L{\LB{}}
\L{\LB{    errored = False;  }}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{  fprintf(stderr, \S{}\"Dialog OKed.\!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{  }}
\L{\LB{  }}
\L{\LB{  \C{}\/* get information from dialog box *\/\CE{}}}
\L{\LB{  \C{}\/* need to get: subject text, publish toggles, reply toggles, send reply to}}
\L{\LB{     text *\/\CE{}}}
\L{\LB{  \C{}\/* then, check the data for errors, inconsistencies, \-\-\- error handling. *\/\CE{}}}
\L{\LB{  \C{}\/* then, send it by mail, using Bruce\'s code *\/\CE{}}}
\L{\LB{}}
\L{\LB{  edit = XmTextGetString(subjecttext); \C{}\/* get contents of subjecttext widget *\/\CE{}}}
\L{\LB{  strncpy(subject, edit, LINE\_SIZE);}}
\L{\LB{  XtFree(edit);}}
\L{\LB{}}
\L{\LB{  edit = XmTextGetString(persReplytext);}}
\L{\LB{  strncpy(username, edit, LINE\_SIZE);}}
\L{\LB{  XtFree(edit);}}
\L{\LB{}}
\L{\LB{  pubYes = XmToggleButtonGetState(publishYestoggle);}}
\L{\LB{  pubNo  = XmToggleButtonGetState(publishNotoggle);}}
\L{\LB{  replyYes = XmToggleButtonGetState(replyYestoggle);}}
\L{\LB{  replyNo = XmToggleButtonGetState(replyNotoggle);}}
\L{\LB{  }}
\L{\LB{\C{}\/*}}
\L{\LB{  if (pubYes == True) fprintf(stderr, \"PublishYes on.\!n\");}}
\L{\LB{  if (pubNo == True) fprintf(stderr, \"PublishNo on. \!n\");}}
\L{\LB{  if (replyYes == True) fprintf(stderr, \"ReplyYes on.\!n\");}}
\L{\LB{  if (replyNo == True) fprintf(stderr, \"ReplyNo on.\!n\");}}
\L{\LB{*\/\CE{}}}
\L{\LB{  \C{}\/* possible errors:}}
\L{\LB{     1. pubNo and replyNo are both True.}}
\L{\LB{     2. replyYes is True but username is empty.}}
\L{\LB{     3. pubYes and pubNo are both False.}}
\L{\LB{     4. replyYes and replyNo are both False.}}
\L{\LB{     5. No subject is provided.  \-\-\- delete this one, not necessary.}}
\L{\LB{     *\/\CE{}}}
\L{\LB{}}
\L{\LB{    \C{}\/* handle case 1 *\/\CE{}}}
\L{\LB{    \K{if} ( (pubNo == True) \&\& (replyNo == True) ) \{}}
\L{\LB{      errored = True;}}
\L{\LB{      ExplainError(DialogbulletinBoard, Error1);}}
\L{\LB{    \}}}
\L{\LB{}}
\L{\LB{    \C{}\/* handle case 2 *\/\CE{}}}
\L{\LB{    \K{if} ( (replyYes == True) \&\& (strlen(username) == 0) ) \{}}
\L{\LB{      errored = True;}}
\L{\LB{      ExplainError(DialogbulletinBoard, Error2);}}
\L{\LB{    \}}}
\L{\LB{}}
\L{\LB{    \C{}\/* handle case 3 *\/\CE{}}}
\L{\LB{    \K{if} ( (pubYes == False) \&\& (pubNo == False) ) \{}}
\L{\LB{      errored = True;}}
\L{\LB{      ExplainError(DialogbulletinBoard, Error3);}}
\L{\LB{    \}}}
\L{\LB{}}
\L{\LB{    \C{}\/* handle case 4 *\/\CE{}}}
\L{\LB{    \K{if} ( (replyYes == False) \&\& (replyNo == False) ) \{}}
\L{\LB{      errored = True;}}
\L{\LB{      ExplainError(DialogbulletinBoard, Error4);}}
\L{\LB{    \}}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{    }}
\L{\LB{  \K{if} (errored == False) \{  \C{}\/* concatenate all the information *\/\CE{}}}
\L{\LB{    XtUnmanageChild(DialogbulletinBoard);}}
\L{\LB{}}
\L{\LB{    \C{}\/* collate everything before sending it *\/\CE{}}}
\L{\LB{    \K{if} (replyYes == True) \{}}
\L{\LB{      strcpy(reply, username);}}
\L{\LB{    \} \K{else} \{}}
\L{\LB{      strcpy(reply, \S{}\"ANONYMOUS (NO REPLY)\"\SE{});}}
\L{\LB{    \}}}
\L{\LB{    }}
\L{\LB{    \K{if} (pubYes == True) \{}}
\L{\LB{      strcpy(publish, \S{}\"Yes.\"\SE{});}}
\L{\LB{    \} \K{else} \{}}
\L{\LB{      strcpy(publish, \S{}\"No.\"\SE{});}}
\L{\LB{    \}}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{    fprintf(stderr, \S{}\"Subject: \%s\!n\!n\"\SE{}, subject);}}
\L{\LB{    fprintf(stderr, \S{}\"\%s\!n\"\SE{}, text);}}
\L{\LB{    fprintf(stderr, \S{}\"SEND PERSONAL REPLY TO: \%s\!n\"\SE{}, reply);}}
\L{\LB{    fprintf(stderr, \S{}\"PUBLISH QUESTION\/ANSWER IN BROWSER: \%s\!n\"\SE{}, publish);}}
\L{\LB{    fprintf(stderr, \S{}\"\-\-\-END OF FILE\-\-\-\!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{    luc\_ask(subject, text, reply, publish); }}
\L{\LB{}}
\L{\LB{    text\_status = 0;  \C{}\/* Question is gone, has been sent via mail *\/\CE{}}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{    fprintf(stderr, \S{}\"empty buffer \!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{    }}
\L{\LB{    }}
\L{\LB{  \} \C{}\/* end of if (errored == False) *\/\CE{}}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{  fprintf(stderr, \S{}\"at end of DialogOKed routine \!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\K{void}}}
\L{\LB{\Proc{EnterQuestionCB}EnterQuestionCB(w, client, call)}}
\L{\LB{Widget w;}}
\L{\LB{caddr\_t client;}}
\L{\LB{caddr\_t call;}}
\L{\LB{\{}}
\L{\LB{  \K{static} \K{char} prompt[] = \S{}\"Question:  \"\SE{};}}
\L{\LB{  \K{int} plength = strlen(prompt);}}
\L{\LB{  }}
\L{\LB{  }}
\L{\LB{  XmTextSetString(lucytext, prompt); \C{}\/* display prompt *\/\CE{}}}
\L{\LB{}}
\L{\LB{  \C{}\/* set the cursor position, make it visible, and make it editable *\/\CE{}}}
\L{\LB{  argcnt = 0;}}
\L{\LB{  XtSetArg(args[argcnt], XmNcursorPosition, plength); argcnt++;}}
\L{\LB{  XtSetArg(args[argcnt], XmNcursorPositionVisible, True); argcnt++;}}
\L{\LB{  XtSetArg(args[argcnt], XmNmaxLength, QUESTION\_SIZE); argcnt++;}}
\L{\LB{}}
\L{\LB{  XtSetArg(args[argcnt], XmNautoShowCursorPosition, True); argcnt++;}}
\L{\LB{\C{}\/*  XtSetArg(args[argcnt], XmNblinkRate, 0); argcnt++; *\/\CE{}}}
\L{\LB{  XtSetValues(lucytext, args, argcnt);}}
\L{\LB{  XmTextSetEditable(lucytext, True);}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{  fprintf(stderr, \S{}\"Enter text to edit.\!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{}}
\L{\LB{  }}
\L{\LB{  \C{}\/* now let user edit text *\/\CE{}}}
\L{\LB{  text\_status = 1; \C{}\/* text is being entered *\/\CE{}}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{  fprintf(stderr, \S{}\"text is being entered \!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{\K{void}}}
\L{\LB{\Proc{Exit\_Callback}Exit\_Callback(w, client, call)}}
\L{\LB{Widget w;}}
\L{\LB{caddr\_t client;}}
\L{\LB{caddr\_t call;}}
\L{\LB{\{}}
\L{\LB{  \C{}\/* unmanage the help window *\/\CE{}}}
\L{\LB{  }}
\L{\LB{  \K{if} (help\_on == True) \{}}
\L{\LB{    help\_on = False;}}
\L{\LB{    XtPopdown(Shell001);}}
\L{\LB{  \}}}
\L{\LB{}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{\K{void}}}
\L{\LB{\Proc{GetHelpCallback}GetHelpCallback(w, client, call)}}
\L{\LB{Widget w;}}
\L{\LB{caddr\_t client;}}
\L{\LB{caddr\_t call;}}
\L{\LB{\{}}
\L{\LB{  \K{static} Boolean initialize\_help = True; \C{}\/* only load help windows once *\/\CE{}}}
\L{\LB{  \K{void} HelpItemSelectCallback();}}
\L{\LB{  \K{static} XmString help\_topics[MAX\_HELP];}}
\L{\LB{  \K{static} \K{int} num\_topics = 0;  \C{}\/* number of topics available in help *\/\CE{}}}
\L{\LB{  \K{int} i;  }}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{  fprintf(stderr, \S{}\"Invoked GetHelp routine.\!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{  }}
\L{\LB{  }}
\L{\LB{  \C{}\/* check to see if Shell001 is displayed.  If not, then Pop it up.}}
\L{\LB{     *\/\CE{}}}
\L{\LB{  \K{if} (help\_on == False) \{}}
\L{\LB{    help\_on = True;}}
\L{\LB{}}
\L{\LB{    \K{if} (initialize\_help == True) \{}}
\L{\LB{      initialize\_help = False;}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{      fprintf(stderr, \S{}\"Initializing helplist widget.\!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{}}
\L{\LB{      }}
\L{\LB{      load\_windows(HELPFILE);}}
\L{\LB{      \C{}\/* hw[] now contains help window names and buffers. *\/\CE{}}}
\L{\LB{      \C{}\/* convert help window names to an array of XmStrings *\/\CE{}}}
\L{\LB{      \C{}\/* store pointer to array of XmStrings in helplist widget *\/\CE{}}}
\L{\LB{      \C{}\/* store number of elements in the array in helplist widget also *\/\CE{}}}
\L{\LB{}}
\L{\LB{      \K{for} (i = 0; i \< num\_windows; i++) \{}}
\L{\LB{}\Tab{8}{help\_topics[i] = XmStringCreateLtoR(hw[i].name, XmSTRING\_DEFAULT\_CHARSET);}}
\L{\LB{}\Tab{8}{num\_topics++;}}
\L{\LB{}\Tab{8}{\C{}\/* allow only up to MAX\_HELP topics *\/\CE{}}}
\L{\LB{}\Tab{8}{\K{if} (i \>= MAX\_HELP) num\_windows = MAX\_HELP;  }}
\L{\LB{      \}}}
\L{\LB{}}
\L{\LB{      \C{}\/* add the following stuff to helplist widget *\/\CE{}}}
\L{\LB{      \C{}\/*******\/\CE{}}}
\L{\LB{      argcnt = 0;}}
\L{\LB{      XtSetArg(args[argcnt], XmNitemCount, num\_topics); argcnt++;  }}
\L{\LB{      XtSetArg(args[argcnt], XmNitems, help\_topics); argcnt++;   }}
\L{\LB{      XtSetArg(args[argcnt], XmNvisibleItemCount, 5); argcnt++;}}
\L{\LB{      }}
\L{\LB{      XtSetValues(helplist, args, argcnt);}}
\L{\LB{}}
\L{\LB{      free\_strings(help\_topics, num\_topics); \C{}\/* free the XmString space *\/\CE{}}}
\L{\LB{}}
\L{\LB{      \C{}\/* also set the helptext widget to noneditable *\/\CE{}}}
\L{\LB{      XmTextSetEditable(helptext, False);}}
\L{\LB{    \} \C{}\/* end of one shot initialization routine for helplist *\/\CE{}}}
\L{\LB{    }}
\L{\LB{    XtPopup(Shell001, XtGrabNone); }}
\L{\LB{  \} \C{}\/* end of handler to put help screen on *\/\CE{}}}
\L{\LB{  \K{else} \{}}
\L{\LB{    ExplainError(w, HelpAlreadyOn);}}
\L{\LB{  \}}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{\K{void} HelpItemSelectCallback(w, client, call)}}
\L{\LB{Widget w;}}
\L{\LB{caddr\_t client;}}
\L{\LB{XmListCallbackStruct *call;}}
\L{\LB{}}
\L{\LB{\{  \C{}\/* routine to handle when user selects a help item. *\/\CE{}}}
\L{\LB{  \K{int} n;}}
\L{\LB{  \K{char} name[LINE\_SIZE];}}
\L{\LB{  \K{char} buffer[HELPBUFSIZE];  \C{}\/* in hes.h *\/\CE{}}}
\L{\LB{}}
\L{\LB{  n = call\-\>item\_position \- 1;}}
\L{\LB{  strncpy(name, hw[n].name, LINE\_SIZE);}}
\L{\LB{  strncpy(buffer, hw[n].buffer, HELPBUFSIZE);}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{  fprintf(stderr, \S{}\"Help item selected.\!n\"\SE{});}}
\L{\LB{  fprintf(stderr, \S{}\"You selected item: \%s with position number \%d \!n\"\SE{},}}
\L{\LB{}\Tab{8}{name, n);}}
\L{\LB{  fprintf(stderr, \S{}\"Contents of window: \!n\%s\!n\-\-End of Window\-\-\!n\"\SE{}, buffer);}}
\L{\LB{\K{\#endif}}}
\L{\LB{  }}
\L{\LB{  }}
\L{\LB{}}
\L{\LB{  XmTextSetString(helptext, buffer);  \C{}\/* display text in window *\/\CE{}}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{}\Tab{8}{     }}
\L{\LB{\K{void}}}
\L{\LB{\Proc{QuitCallback}QuitCallback(w, client, call)}}
\L{\LB{Widget w;}}
\L{\LB{caddr\_t client;}}
\L{\LB{caddr\_t call;}}
\L{\LB{\{}}
\L{\LB{}}
\L{\LB{  \C{}\/* works *\/\CE{}}}
\L{\LB{  }}
\L{\LB{}\Tab{8}{XtCloseDisplay(XtDisplay(w));  \C{}\/* exit lucy program *\/\CE{}}}
\L{\LB{}\Tab{8}{exit(0); }}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\K{void}}}
\L{\LB{\Proc{SendQuestionCB}SendQuestionCB(w, client, call)}}
\L{\LB{Widget w;}}
\L{\LB{caddr\_t client;}}
\L{\LB{caddr\_t call;}}
\L{\LB{\{}}
\L{\LB{  \K{char} *edit;}}
\L{\LB{}}
\L{\LB{  \K{if} (text\_status == 0) \{ \C{}\/* no text has been entered *\/\CE{}}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{    fprintf(stderr, \S{}\"empty buffer \!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{    }}
\L{\LB{    }}
\L{\LB{    \C{}\/* pop up an error dialog *\/\CE{}}}
\L{\LB{    ExplainError(w, ErrorNoQuestionText);}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{    fprintf(stderr, \S{}\"error popup: No Text has been entered. \!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{    \K{return}; \C{}\/* don\'t continue with SendQuestion *\/\CE{}}}
\L{\LB{  \}}}
\L{\LB{  \K{if} (text\_status == 1) \{ \C{}\/* text entered, but not saved. *\/\CE{}}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{    fprintf(stderr, \S{}\"text has been entered. \!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{    }}
\L{\LB{    }}
\L{\LB{      XmTextSetEditable(lucytext, False); \C{}\/* prevent further editing *\/\CE{}}}
\L{\LB{    edit = (\K{char} *) XmTextGetString(lucytext);}}
\L{\LB{    \C{}\/* remember to handle empty string error here *\/\CE{}}}
\L{\LB{  strncpy(text, edit, 10000);}}
\L{\LB{  XtFree(edit);}}
\L{\LB{\}}}
\L{\LB{  \C{}\/* if text\_status == 2, then text has previously been saved,}}
\L{\LB{     and we need not save it again . *\/\CE{}}}
\L{\LB{  \K{if} (text\_status == 2) \{}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{    fprintf(stderr, \S{}\"text has been saved to text[] \!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{    }}
\L{\LB{    }}
\L{\LB{  \}}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{  fprintf(stderr, \S{}\"You entered \<\%s\> \!n\"\SE{}, text);}}
\L{\LB{\K{\#endif}}}
\L{\LB{  }}
\L{\LB{}}
\L{\LB{  }}
\L{\LB{  \C{}\/* and now pop up some dialog window to get additional info *\/\CE{}}}
\L{\LB{  XtManageChild(DialogbulletinBoard);}}
\L{\LB{}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\K{void} get\_topics\_list()}}
\L{\LB{\{}}
\L{\LB{  \C{}\/* get\_topics\_list gets a list of topics from the meetings server}}
\L{\LB{     and places them in browser[]..  also sets num\_browser to the}}
\L{\LB{     number of topics in the browser array.  *\/\CE{}}}
\L{\LB{}}
\L{\LB{  \C{}\/* currently, this is a stub routine *\/\CE{}}}
\L{\LB{}}
\L{\LB{\C{}\/*  some old stub code.}}
\L{\LB{  int i;}}
\L{\LB{}}
\L{\LB{  for (i=0; i \< ; i++) \{}}
\L{\LB{    strncpy(browser[i].subject, hw[i].name, LINE\_SIZE);}}
\L{\LB{}}
\L{\LB{\#ifdef DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{    fprintf(stderr, \"browser[\%d] = \%s \!n\", i, browser[i].subject);}}
\L{\LB{    fprintf(stderr, \"hw[\%d].name = \%s \!n\", i, hw[i].name);}}
\L{\LB{}}
\L{\LB{\#endif    }}
\L{\LB{    num\_browser++;}}
\L{\LB{  \}}}
\L{\LB{*\/\CE{}}}
\L{\LB{}}
\L{\LB{  Get\_Subjects();  }}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\K{void}}}
\L{\LB{\Proc{ViewBrowserCallback}ViewBrowserCallback(w, client, call)}}
\L{\LB{Widget w;}}
\L{\LB{caddr\_t client;}}
\L{\LB{caddr\_t call;}}
\L{\LB{\{}}
\L{\LB{  \K{static} one\_shot = True;}}
\L{\LB{  \K{int} i;}}
\L{\LB{  \C{}\/* display CB\'s for transaction select.  add scroll CBs or enable them.}}
\L{\LB{     add CBs for transaction select.  set a flag to indicate that}}
\L{\LB{     we are in browser mode *\/\CE{}}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{  fprintf(stderr, \S{}\"In View Browser.\!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{  }}
\L{\LB{  }}
\L{\LB{}}
\L{\LB{  \K{if} (one\_shot == True) \{}}
\L{\LB{    one\_shot = False;}}
\L{\LB{    get\_topics\_list();  \C{}\/* get the list of topics from the meetings server *\/\CE{}}}
\L{\LB{    \C{}\/* list of topics is now stored in browser[]...}}
\L{\LB{       and num\_browser tells us how many topics are in browser *\/\CE{}}}
\L{\LB{}}
\L{\LB{    \K{for} (i = 0; i \< num\_browser; i++) \{}}
\L{\LB{      browser\_xm[i] = XmStringCreateLtoR(browser[i].subject,}}
\L{\LB{}\Tab{40}{ XmSTRING\_DEFAULT\_CHARSET);}}
\L{\LB{    \}}}
\L{\LB{    argcnt = 0;}}
\L{\LB{    XtSetArg(args[argcnt], XmNitemCount, num\_browser); argcnt++;  }}
\L{\LB{    XtSetArg(args[argcnt], XmNitems, browser\_xm); argcnt++;   }}
\L{\LB{    XtSetArg(args[argcnt], XmNvisibleItemCount, 10); argcnt++;}}
\L{\LB{    XtSetValues(lucylist, args, argcnt);}}
\L{\LB{    free\_strings(browser\_xm, num\_browser);}}
\L{\LB{    XmTextSetEditable(lucytext, False);}}
\L{\LB{  \} \C{}\/* end of one\_shot deal *\/\CE{}}}
\L{\LB{}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\K{void} BrowserSelectCallback(w, client, call)}}
\L{\LB{     Widget w;}}
\L{\LB{     caddr\_t client;}}
\L{\LB{     XmListCallbackStruct *call;     }}
\L{\LB{}}
\L{\LB{\{}}
\L{\LB{  \K{int} n;  \C{}\/* selection number *\/\CE{}}}
\L{\LB{  \K{int} tnum;  \C{}\/* transaction number *\/\CE{}}}
\L{\LB{  \K{char} name[LINE\_SIZE];}}
\L{\LB{  \K{static} \K{char} buffer[QUESTION\_SIZE];}}
\L{\LB{  \K{char} * edit;}}
\L{\LB{}}
\L{\LB{  \K{if} (text\_status == 1) \{  \C{}\/* question has been previously entered, but}}
\L{\LB{}\Tab{24}{      not saved. *\/\CE{}}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{    fprintf(stderr, \S{}\"text has been entered but not saved. \!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{    }}
\L{\LB{}}
\L{\LB{    edit = (\K{char} *) XmTextGetString(lucytext);    }}
\L{\LB{    strncpy(text, edit, HELPBUFSIZE);}}
\L{\LB{    text\_status = 2; \C{}\/* question has been saved *\/\CE{}}}
\L{\LB{    XtFree(edit);    }}
\L{\LB{  \}}}
\L{\LB{}}
\L{\LB{  \C{}\/* code to handle a browser selection *\/\CE{}}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{  fprintf(stderr, \S{}\"You selected something in the browser \!n\"\SE{});}}
\L{\LB{\K{\#endif}}}
\L{\LB{  }}
\L{\LB{  }}
\L{\LB{}}
\L{\LB{  n = call\-\>item\_position \- 1;}}
\L{\LB{}}
\L{\LB{  tnum = browser[n].tnum; \C{}\/* get the transaction number for this item *\/\CE{}}}
\L{\LB{  bzero(buffer, QUESTION\_SIZE);  \C{}\/* clear buffer *\/\CE{}}}
\L{\LB{  Get\_Transaction(tnum, buffer, QUESTION\_SIZE);}}
\L{\LB{\C{}\/*  old code...}}
\L{\LB{  strncpy(name, hw[n].name, LINE\_SIZE);}}
\L{\LB{  strncpy(buffer, hw[n].buffer);}}
\L{\LB{*\/\CE{}}}
\L{\LB{\K{\#ifdef} DEBUG\_LUCY}}
\L{\LB{}}
\L{\LB{  fprintf(stderr, \S{}\"You selected item \%d \!n\"\SE{}, n);}}
\L{\LB{}}
\L{\LB{\K{\#endif}}}
\L{\LB{}}
\L{\LB{  \C{}\/* we want to clear any previous text, to reset the window to}}
\L{\LB{     beginning of text *\/\CE{}}}
\L{\LB{  XmTextSetString(lucytext, \S{}\"\"\SE{}); \C{}\/* clear the previous text *\/\CE{}}}
\L{\LB{  XmTextSetString(lucytext, buffer);  \C{}\/* display text in window *\/\CE{}}}
\L{\LB{}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{}}
