Description: Debian diff as of version 2.20c-31 --- a/1-CHANGES +++ b/1-CHANGES @@ -12,7 +12,6 @@ Rolled in some obvious bug fixes from the Debian version of 2.14c: * Fixed typo in Seyon.ad: s/replcae/replace * Added #include to SePort.c for Linux - * Minor changes to ExecShellCommand; used to crash, should no more. * Now under GPL (see 1-COPYING for details), new maintainer. Versions up to 2.20b: --- a/config.h +++ b/config.h @@ -302,7 +302,7 @@ * HDB uucp does) rather than in binary form as other uucp prgrams do */ #ifndef LF_USE_ASCII_PID -#define LF_USE_ASCII_PID NO +#define LF_USE_ASCII_PID YES #endif /* @@ -319,7 +319,7 @@ */ #ifndef LF_PATH -#define LF_PATH "/usr/spool/uucp" +#define LF_PATH "/var/lock" #endif /* --- a/makever.sh +++ b/makever.sh @@ -48,9 +48,9 @@ echo "#define VERSION \"$VERSION\"" >> version.h echo "#define REVISION \"$REVISION\"" >> version.h -echo "#ifdef IS_MAIN" >> version.h -echo "static char version[] = \"\$Revision: $VERSION.$REVISION \$\";"\ - >> version.h -echo "#endif" >> version.h +#echo "#ifdef IS_MAIN" >> version.h +#echo "static char version[] = \"\$Revision: $VERSION.$REVISION \$\";"\ +# >> version.h +#echo "#endif" >> version.h echo "Machine type is $machine, OS name is $system" --- a/MultiList.c +++ b/MultiList.c @@ -1031,8 +1031,8 @@ XfwfMultiListWidget mlw; int row,column; { - GC bg_gc,fg_gc; - XfwfMultiListItem *item; + GC bg_gc,fg_gc = 0; + XfwfMultiListItem *item = NULL; int ul_x,ul_y,str_x,str_y,w,h,item_index,has_item,text_h; if (!XtIsRealized((Widget)mlw)) return; --- a/protocols +++ b/protocols @@ -6,7 +6,7 @@ # you have to use the resources # zmodemAutoDownload and # zmodemAutoDownloadCommand for that. -# see the manula page for more details. +# see the manual page for more details. # the format is simple. @@ -24,9 +24,9 @@ # you can put comments on a single line # or at the end of a line - -regular_zmodem_dl "$ cd /usr/dl; rz -vv" n # like in here - +# +#regular_zmodem_dl "$ cd /usr/dl; rz -vv" n # like in here +# # blank lines are OK too, for readability. # the title has to be either a single word, like the above @@ -34,21 +34,29 @@ # you put anything instead of y as long as it starts # with y: y, Y, yes, yep ..etc. - -"regular zmodem ul" "$ cd /usr/src; sz -vv" y - +# +#"regular zmodem ul" "$ cd /usr/src; sz -vv" y +# # anything that doesn't start with a y is a no # e.g. n, N, NO, Not, nope, nien, nono ..etc. # even hello, but the use of words that doesn't start # with n is highly discouraged - -graphic_zmodem_dl "cd /usr/dl; grz No -xrz3D "$cd /usr/dl; xrz" NO - +# +#graphic_zmodem_dl "cd /usr/dl; grz No +#xrz3D "$cd /usr/dl; xrz" NO +# # here is my own protocols file # notice how I make it clear to myself # whether I'm uploading or downloading - -"SEND - Zmodem" "$cd /usr/src; sz -vv" y -"RECEIVE - Reg. Zmodem" "$cd /usr/dl; rz -vv" n -"RECEIVE - Xrz3D" "$cd /usr/dl; xrz" n +# +#"SEND - Zmodem" "$cd /usr/src; sz -vv" y +#"RECEIVE - Reg. Zmodem" "$cd /usr/dl; rz -vv" n +#"RECEIVE - Xrz3D" "$cd /usr/dl; xrz" n + +"Zmodem - RECEIVE" "$lrz" n +"Ymodem - RECEIVE" "$lrb" n +"Xmodem - RECEIVE" "$lrx" y + +"Zmodem - SEND" "$lsz" y +"Ymodem - SEND" "$lsb" y +"Xmodem - SEND" "$lsx" y --- a/SeActions.c +++ b/SeActions.c @@ -28,6 +28,7 @@ /* SeDecl.h includes stdio.h */ #include "SeDecl.h" #include "version.h" +#include "config.h" #define CheckNumParam(num) {if (*numParam != num) \ SimpleError("Wrong Number of Parameters");} @@ -234,7 +235,7 @@ Cardinal* numParam; { int IconifyShell(); - Widget dirWidget; +/* Widget dirWidget; */ static String termWindowId = NULL; int i; @@ -312,10 +313,18 @@ Cardinal* numParam; { void s_set(); + int length; + int length_remaining; ErrorIfBusy(); CheckNumParam(2); - sprintf((lptr = line), "%s %s", param[0], param[1]); + + length_remaining = WBSIZE; + length = 1 + strlen(param[0]) + strlen(param[1]); + if(length_remaining > length) + sprintf((lptr = line), "%s %s", param[0], param[1]); + else + printf("SetAction: string buffer would have overrun: %s %s\n",param[0], param[1]); eof_flag = 0; s_set(); } @@ -372,7 +381,7 @@ prevActionAsync = False, startup = True; static Widget actionWidget; - static String actionStack; + static String actionStack = ""; void (*actionProc)(); static char actionName[SM_BUF], @@ -387,6 +396,9 @@ Boolean async; }; + /* A string containing a script of actions to perform at startup. */ + String startScript; + static struct _actionTable actionTable[] = { {"Beep", BeepAction, False}, {"CloseWindow", CloseWindowAction, False}, @@ -413,12 +425,12 @@ switch (intData) { case ACTION_NEW_ACTION: - strcpy(actionName, stringData); + strncpy(actionName, stringData, sizeof(actionName)); numArgs = 0; return; case ACTION_NEW_ARG: - strcpy((argsArray[numArgs] = args[numArgs]), stringData); + strncpy((argsArray[numArgs] = args[numArgs]), stringData, SM_BUF); numArgs++; return; @@ -461,10 +473,12 @@ XtFree(actionStack); if (startup) { - startup = False; - ParseThis(FmtString("Message(\"Welcome to Seyon version %s.%s\"); %s", - VERSION, REVISION, "RestartTerminal();"), - DispatchActions); + startup = False; + startScript + = XtNewString( FmtString("Message(\"Welcome to Seyon version %s.%s\"); %s", + VERSION, REVISION, "RestartTerminal();")); + ParseThis(startScript, DispatchActions); + XtFree(startScript); } return; --- a/SeDecl.h +++ b/SeDecl.h @@ -66,7 +66,6 @@ extern FILE *open_file(), *open_file_va(); extern void send_break(), - usleep(), show(), showf(), SeyonMessage(), --- a/SeDial.c +++ b/SeDial.c @@ -89,7 +89,7 @@ {XMapRaised(XtDisplay(widget), XtWindow(popup)); return;} if (disItems[0] == NULL) { - strcpy(phoneFile, qres.phoneFile); + strncpy(phoneFile, qres.phoneFile, REG_BUF); if (ReadParsePhoneFile(phoneFile, disItems) < 0) return; form = XtParent(widget); @@ -328,7 +328,7 @@ Widget dialog = XtParent(widget); char phoneNumber[SM_BUF]; - strcpy(phoneNumber, XawDialogGetValueString(dialog)); + strncpy(phoneNumber, XawDialogGetValueString(dialog), SM_BUF); DestroyShell(dialog); ExecManualDial(XtParent(GetShell(widget)), phoneNumber); } @@ -341,7 +341,7 @@ inhibit_child = True; manualDial = True; - strcpy(phone_number, phoneNumber); + strncpy(phone_number, phoneNumber, SM_BUF); dialTry = 1; PreProcessPrep(); @@ -442,15 +442,15 @@ if ((ptr = (char*)strstr(raw, keyword)) != NULL) { ptr += strlen(keyword); if (strncmp(ptr, "CURRENT", 3)) { - strcpy(buf, ptr); + strncpy(buf, ptr, REG_BUF); GetWord(buf, wrd); - strcpy(var, wrd); + strncpy(var, wrd, sizeof(*var)); } else - strcpy(var, "CURRENT"); + strncpy(var, "CURRENT", sizeof(*var)); } else - strcpy(var, def); + strncpy(var, def, sizeof(*var)); } void @@ -463,8 +463,8 @@ char svar[TIN_BUF], sdef[TIN_BUF]; - sprintf(svar, "%d", *var); - sprintf(sdef, "%d", def); + sprintf(svar, "%d", *var); /* safe */ + sprintf(sdef, "%d", def); /* safe */ GetStrField(raw, keyword, svar, sdef); @@ -496,7 +496,7 @@ else { signal(SIGALRM, SIG_DFL); alarm(0); - strcpy(dialMsg, "TIMEOUT"); + strncpy(dialMsg, "TIMEOUT", SM_BUF); longjmp(dial_env, 1); } } @@ -514,6 +514,8 @@ *bufPtr, dialString[REG_BUF]; int i, +/* length, */ + length_remaining, k; if (setjmp(dial_env) != 0) { @@ -534,8 +536,8 @@ if (!manualDial) { itemName = ddItems[k]->name; - sprintf(dialString, "\r%s %s%s", ddItems[k]->prefix, ddItems[k]->number, - ddItems[k]->suffix); + strncpy(dialString, FmtString("\r%s %s%s", ddItems[k]->prefix, + ddItems[k]->number, ddItems[k]->suffix), REG_BUF); if (mbaud(ddItems[k]->baud) < 0) se_warningf("invalid BPS value in dialing directory: %s", @@ -552,14 +554,23 @@ } else { itemName = phone_number; - sprintf(dialString, "\r%s %s%s", qres.dialPrefix, phone_number, - qres.dialSuffix); + strncpy(dialString, FmtString("\r%s %s%s", qres.dialPrefix, phone_number, + qres.dialSuffix), REG_BUF); } + length_remaining = SM_BUF; if (dialTry == 1) - sprintf(dialMsg, "Dialing %s", itemName); + { + strncpy(dialMsg, "Dialing ", length_remaining); + length_remaining -= strlen("Dialing "); + strncat(dialMsg, itemName, length_remaining); + } else - sprintf(dialMsg, "Redialing:%d %s", dialTry, itemName); + strncpy(dialMsg, "Redialing ", length_remaining); + length_remaining -= strlen("Redialing "); + sprintf(dialMsg, "%1.1d ", dialTry); + length_remaining -= 2; + strncat(dialMsg, itemName, length_remaining); ProcRequest(SET_MESSAGE, "Setting Up...", ""); @@ -589,7 +600,7 @@ for (i = 0; i < 3; i++) if (*(bufPtr = StripSpace(qres.noConnectString[i])) && strncmp(modemResponse, bufPtr, strlen(bufPtr)) == 0) { - strcpy(dialMsg, modemResponse); + strncpy(dialMsg, modemResponse, SM_BUF); longjmp(dial_env, 1); } } /* while(1)... */ @@ -601,15 +612,20 @@ String disItems[]; { FILE *fp; + FILE *devnull; String rawItems[MAX_ENT + 1]; char *buf, *sHold, disItemsBuf[REG_BUF]; + char filename[LRG_BUF]; int i, n, + length, iHold; - if ((fp = open_file(fname, qres.defaultDirectory)) == NULL) + strncpy(filename, fname, REG_BUF); + + if ((fp = open_file(filename, REG_BUF, qres.defaultDirectory)) == NULL) return -1; ReadCommentedFile(fp, rawItems); @@ -623,11 +639,9 @@ /* Find the number */ GetWord(buf, ddItems[i]->number); -/* strcpy(ddItems[i]->number, GetFirstWord(buf));*/ /* Find the name */ GetWord((buf = lptr), ddItems[i]->name); -/* strcpy(ddItems[i]->name, GetNextWord());*/ /* Find other stuff */ GetStrField(buf, "BPS=", ddItems[i]->baud, qres.defaultBPS); @@ -643,8 +657,20 @@ FreeList(rawItems); FreeList(disItems); + /* Ick... This is horrible - using a user-provided format string + means we have no easy way of limiting string length. HACK HACK + HACK Use fprintf to output to /dev/null and count the number of + bytes... It would be nice if we could rely on having snprintf() */ + + devnull = fopen("/dev/null", "r+"); + if(NULL == devnull) + { + printf("Open /dev/null failed!?!\n"); + return 1; + } + for (n = 0; n < i; n++) { - sprintf(disItemsBuf, qres.dialDirFormat, + length = fprintf(devnull, qres.dialDirFormat, ddItems[n]->name, ddItems[n]->number, strncmp((sHold = ddItems[n]->baud), "CUR", 3) ? sHold : "????", @@ -658,10 +684,33 @@ strcmp(sHold, qres.dialSuffix) ? 'S' : 'D' : '?', ddItems[n]->script); - disItemsBuf[SM_BUF - 1] = '\0'; - disItems[n] = XtNewString(disItemsBuf); + if(REG_BUF >= length) + { + sprintf(disItemsBuf, qres.dialDirFormat, + ddItems[n]->name, + ddItems[n]->number, + strncmp((sHold = ddItems[n]->baud), "CUR", 3) ? sHold : "????", + (iHold = ddItems[n]->bits) == 100 ? '?' : itoa(iHold), + (iHold = ddItems[n]->parity) ? (iHold == 1 ? 'O' : + (iHold == 2 ? 'E' : '?')) : 'N', + (iHold = ddItems[n]->stopBits) == 100 ? '?' : itoa(iHold), + strncmp((sHold = ddItems[n]->prefix), "CUR", 3) ? + strcmp(sHold, qres.dialPrefix) ? 'P' : 'D' : '?', + strncmp((sHold = ddItems[n]->suffix), "CUR", 3) ? + strcmp(sHold, qres.dialSuffix) ? 'S' : 'D' : '?', + ddItems[n]->script); + disItemsBuf[SM_BUF - 1] = '\0'; + disItems[n] = XtNewString(disItemsBuf); + } + else + { + printf("ReadParsePhoneFile: attempted overrun: %s\n",ddItems[n]->name); + fclose(devnull); + return 1; + } } disItems[n] = NULL; + fclose(devnull); return 0; } --- a/SeErr.c +++ b/SeErr.c @@ -107,28 +107,26 @@ #ifdef notdef void -SePopupWarningF(parent, fmt, a, b, c, d) +SePopupWarningF(parent, fmt, a, b, c) Widget parent; String fmt, a, b, - c, - d; + c; { SePopupNoticeF(parent, 0, "Seyon Warning", DestroyParentPopup, - fmt, a, b, c, d); + fmt, a, b, c); } void -SePopupInitWarningF(parent, fmt, a, b, c, d) +SePopupInitWarningF(parent, fmt, a, b, c) Widget parent; String fmt, a, b, - c, - d; + c; { SePopupNoticeF(parent, 0, "Seyon Initialization Warning", - DestroyParentPopup, fmt, a, b, c, d); + DestroyParentPopup, fmt, a, b, c); } #endif --- a/SeInit.c +++ b/SeInit.c @@ -30,34 +30,34 @@ #include "version.h" #ifndef HELPFILE -#define HELPFILE "/usr/lib/X11/seyon.help" +#define HELPFILE "/usr/share/seyon/seyon.help" #endif extern void TopAbout(), - TopHelp(), - TopSet(), - TopTransfer(), - TopMisc(), - SetNewlineTrMode(), - FunMessage(); + TopHelp(), + TopSet(), + TopTransfer(), + TopMisc(), + SetNewlineTrMode(), + FunMessage(); extern void upload_acc_ok(), - setVal_action_ok(), - manual_dial_action_ok(), - divert_action_ok(); + setVal_action_ok(), + manual_dial_action_ok(), + divert_action_ok(); extern Boolean CvtStringToStringArray(); void HangupConfirm(), - ExecHangup(), - ExitConfirm(), - ExitAction(), - test(); + ExecHangup(), + ExitConfirm(), + ExitAction(), + test(); Boolean inhibit_child = False; Widget w_exit, - w_kill, - statusMessage; + w_kill, + statusMessage; Widget dialWidget, genericWidget; pid_t w_child_pid = 0; Pixmap progIcon; @@ -66,194 +66,202 @@ void InitVariables(topLevel) - Widget topLevel; + Widget topLevel; { - char buffer[REG_BUF]; + char buffer[REG_BUF]; - sprintf(captureFile, "%s/%s", expand_fname(qres.defaultDirectory, buffer), - qres.captureFile); + expand_fname(qres.defaultDirectory, buffer, REG_BUF); - SetNewlineTrMode(qres.newlineTranslation); + if(REG_BUF > (1 + strlen(buffer) + strlen(qres.captureFile))) + sprintf(captureFile, "%s/%s", buffer, qres.captureFile); + else + { + printf("Buffer overflow in InitVariables: %s/%s\nExit\n",buffer, qres.captureFile); + exit(1); + } + + SetNewlineTrMode(qres.newlineTranslation); } void SetIcon(topLevelWidget) - Widget topLevelWidget; + Widget topLevelWidget; { - progIcon = - XCreateBitmapFromData(XtDisplay(topLevelWidget), - DefaultRootWindow(XtDisplay(topLevelWidget)), - progIcon_bits, progIcon_width, - progIcon_height); - XtVaSetValues(topLevelWidget, XtNiconPixmap, progIcon, NULL); + progIcon = + XCreateBitmapFromData(XtDisplay(topLevelWidget), + DefaultRootWindow(XtDisplay(topLevelWidget)), + progIcon_bits, progIcon_width, + progIcon_height); + XtVaSetValues(topLevelWidget, XtNiconPixmap, progIcon, NULL); } void CreateCommandCenter() { - void GetQuickKeyResources(), - GetValueByPopupOKAction(), - DispatchActionsCallback(); - void TopShell(); - void KillChildProc(); - - Widget mainBox, - menuBox, - statusBox, - messageBox, - quickKeyBox; - static Widget status[NUM_MDM_STAT]; - static Atom wm_delete_window; - Dimension menuBoxWidth; - - struct _quickKeyRes quickKeyRes; - Widget quickKeyW; - char qKBuf[REG_BUF]; - int i, n = 0; - - static XtActionsRec actionTable[] = { - {"UploadOk", upload_acc_ok}, - {"SetValOk", setVal_action_ok}, - {"ManualDialOk", manual_dial_action_ok}, - {"DivertOk", divert_action_ok}, - {"Exit", ExitAction}, - {"GetValueByPopupOK", GetValueByPopupOKAction}, - }; - - XtAppAddActions(XtWidgetToApplicationContext(topLevel), actionTable, - XtNumber(actionTable)); - - mainBox = SeAddPaned("mainBox", topLevel); - statusBox = AddBox("statusBox", mainBox); - messageBox = SeAddForm("messageBox", mainBox); - quickKeyBox = AddBox("quickKeyBox", mainBox); - menuBox = AddBox("menuBox", mainBox); - - status[0] = SeAddToggle("dcd", statusBox, NULL); - status[1] = SeAddToggle("dtr", statusBox, NULL); - status[2] = SeAddToggle("dsr", statusBox, NULL); - status[3] = SeAddToggle("rts", statusBox, NULL); - status[4] = SeAddToggle("cts", statusBox, NULL); - status[5] = SeAddToggle("rng", statusBox, NULL); - - statusMessage = SeAddLabel("message", messageBox); - - AddButton("about", menuBox, TopAbout, NULL); - AddButton("help", menuBox, TopHelp, NULL); - AddButton("set", menuBox, TopSet, NULL); - genericWidget = dialWidget = AddButton("dial", menuBox, TopDial, NULL); - AddButton("transfer", menuBox, TopTransfer, NULL); - AddButton("shellCommand", menuBox, TopShell, NULL); - AddButton("misc", menuBox, TopMisc, NULL); - AddButton("hangup", menuBox, HangupConfirm, NULL); - w_exit = AddButton("exit", menuBox, ExitConfirm, NULL); - w_kill = AddButton("kill", menuBox, KillChildProc, NULL); - - for (i = 0; i < MAX_SEQUICKKEYS; i++) { - sprintf(qKBuf, "quickKey%d", i+1); - GetQuickKeyResources(qKBuf, &quickKeyRes); - if (quickKeyRes.visible) { - n++; + void GetQuickKeyResources(), + GetValueByPopupOKAction(), + DispatchActionsCallback(); + void TopShell(); + void KillChildProc(); + + Widget mainBox, + menuBox, + statusBox, + messageBox, + quickKeyBox; + static Widget status[NUM_MDM_STAT]; + static Atom wm_delete_window; + Dimension menuBoxWidth; + + struct _quickKeyRes quickKeyRes; + Widget quickKeyW; + char qKBuf[LRG_BUF]; + int i, n = 0; + + static XtActionsRec actionTable[] = { + {"UploadOk", upload_acc_ok}, + {"SetValOk", setVal_action_ok}, + {"ManualDialOk", manual_dial_action_ok}, + {"DivertOk", divert_action_ok}, + {"Exit", ExitAction}, + {"GetValueByPopupOK", GetValueByPopupOKAction}, + }; + + XtAppAddActions(XtWidgetToApplicationContext(topLevel), actionTable, + XtNumber(actionTable)); + + mainBox = SeAddPaned("mainBox", topLevel); + statusBox = AddBox("statusBox", mainBox); + messageBox = SeAddForm("messageBox", mainBox); + quickKeyBox = AddBox("quickKeyBox", mainBox); + menuBox = AddBox("menuBox", mainBox); + + status[0] = SeAddToggle("dcd", statusBox, NULL); + status[1] = SeAddToggle("dtr", statusBox, NULL); + status[2] = SeAddToggle("dsr", statusBox, NULL); + status[3] = SeAddToggle("rts", statusBox, NULL); + status[4] = SeAddToggle("cts", statusBox, NULL); + status[5] = SeAddToggle("rng", statusBox, NULL); + + statusMessage = SeAddLabel("message", messageBox); + + AddButton("about", menuBox, TopAbout, NULL); + AddButton("help", menuBox, TopHelp, NULL); + AddButton("set", menuBox, TopSet, NULL); + genericWidget = dialWidget = AddButton("dial", menuBox, TopDial, NULL); + AddButton("transfer", menuBox, TopTransfer, NULL); + AddButton("shellCommand", menuBox, TopShell, NULL); + AddButton("misc", menuBox, TopMisc, NULL); + AddButton("hangup", menuBox, HangupConfirm, NULL); + w_exit = AddButton("exit", menuBox, ExitConfirm, NULL); + w_kill = AddButton("kill", menuBox, KillChildProc, NULL); + + for (i = 0; i < MAX_SEQUICKKEYS; i++) { + sprintf(qKBuf, "quickKey%d", i+1); /* qKBuf is large enough here... */ + GetQuickKeyResources(qKBuf, &quickKeyRes); + if (quickKeyRes.visible) { + n++; quickKeyW = - AddButton(qKBuf, quickKeyBox, DispatchActionsCallback, NULL); - } - } - if (n == 0) XtDestroyWidget(quickKeyBox); - - XtOverrideTranslations(topLevel, - XtParseTranslationTable("WM_PROTOCOLS: Exit()")); - - /* Call UpdateStatusBox() before realizing the top-level widget so that - the status widget array in that function would be properly initialized - before the user is able to call hangup(), since the latter passes NULL - to UpdateStatusBox() */ - UpdateStatusBox((XtPointer)status); - - XtSetMappedWhenManaged(topLevel, False); - XtRealizeWidget(topLevel); - XtVaGetValues(menuBox, XtNwidth, &menuBoxWidth, NULL); - XtVaSetValues(statusBox, XtNwidth, menuBoxWidth, NULL); - if (n) XtVaSetValues(quickKeyBox, XtNwidth, menuBoxWidth, NULL); - - /* - * (ideally one should not assume any fixed numbers, but this will do - * for now). - * - * width of message box = label width - * + 2*border width (2*1) - * + defaultDistance (right) (1) - * + horizDistance (left) (4) - * - * desired width of label = width of menu box - * - hSpace of menu box (2*4) (to align with buttons) - * - border with of label (2*1) - * = width of menu box - 10 - * - * => width of message box = width of menu box - 10 + 7 - * => width of message box < width of menu box - * => menu box width is the controlling factor in deciding the widnow - * width, as desired. - */ - XtVaSetValues(statusMessage, XtNresizable, True, NULL); - XtVaSetValues(statusMessage, XtNwidth, menuBoxWidth - 10, NULL); - XtVaSetValues(statusMessage, XtNresizable, False, NULL); - - wm_delete_window = XInternAtom(XtDisplay(topLevel), - "WM_DELETE_WINDOW", False); - XSetWMProtocols(XtDisplay(topLevel), XtWindow(topLevel), - &wm_delete_window, 1); + AddButton(qKBuf, quickKeyBox, DispatchActionsCallback, NULL); + } + } + if (n == 0) XtDestroyWidget(quickKeyBox); + + XtOverrideTranslations(topLevel, + XtParseTranslationTable("WM_PROTOCOLS: Exit()")); + + /* Call UpdateStatusBox() before realizing the top-level widget so that + the status widget array in that function would be properly initialized + before the user is able to call hangup(), since the latter passes NULL + to UpdateStatusBox() */ + UpdateStatusBox((XtPointer)status); + + XtSetMappedWhenManaged(topLevel, False); + XtRealizeWidget(topLevel); + XtVaGetValues(menuBox, XtNwidth, &menuBoxWidth, NULL); + XtVaSetValues(statusBox, XtNwidth, menuBoxWidth, NULL); + if (n) XtVaSetValues(quickKeyBox, XtNwidth, menuBoxWidth, NULL); + + /* + * (ideally one should not assume any fixed numbers, but this will do + * for now). + * + * width of message box = label width + * + 2*border width (2*1) + * + defaultDistance (right) (1) + * + horizDistance (left) (4) + * + * desired width of label = width of menu box + * - hSpace of menu box (2*4) (to align with buttons) + * - border with of label (2*1) + * = width of menu box - 10 + * + * => width of message box = width of menu box - 10 + 7 + * => width of message box < width of menu box + * => menu box width is the controlling factor in deciding the widnow + * width, as desired. + */ + XtVaSetValues(statusMessage, XtNresizable, True, NULL); + XtVaSetValues(statusMessage, XtNwidth, menuBoxWidth - 10, NULL); + XtVaSetValues(statusMessage, XtNresizable, False, NULL); + + wm_delete_window = XInternAtom(XtDisplay(topLevel), + "WM_DELETE_WINDOW", False); + XSetWMProtocols(XtDisplay(topLevel), XtWindow(topLevel), + &wm_delete_window, 1); } void TopAbout(parent) - Widget parent; + Widget parent; { - Widget popup, - mBox, - uBox, - lBox, - pic, - msg, - caption; - Pixmap pix; - Dimension width1, - width2; - char msgStr[LRG_BUF]; + Widget popup, + mBox, + uBox, + lBox, + pic, + msg, + caption; + Pixmap pix; + Dimension width1, + width2; + char msgStr[LRG_BUF]; #include "authPic.h" - popup = SeAddPopup("about", parent); - mBox = SeAddPaned("mBox", popup); - uBox = SeAddBox("uBox", mBox); - lBox = SeAddBox("lBox", mBox); - - msg = SeAddLabel("msg", uBox); - pic = SeAddLabel("pic", uBox); - caption = SeAddLabel("caption", uBox); + popup = SeAddPopup("about", parent); + mBox = SeAddPaned("mBox", popup); + uBox = SeAddBox("uBox", mBox); + lBox = SeAddBox("lBox", mBox); + + msg = SeAddLabel("msg", uBox); + pic = SeAddLabel("pic", uBox); + caption = SeAddLabel("caption", uBox); - sprintf(msgStr, "%s %s rev. %s\n%s\n%s\n%s", "Seyon version", VERSION, + /* msgStr is big enough here */ + sprintf(msgStr, "%s %s rev. %s\n%s\n%s\n%s", "Seyon version", VERSION, REVISION, "Copyright 1992-1993", "(c) Muhammad M. Saggaf", "All rights reserved"); - XtVaSetValues(msg, XtNlabel, msgStr, NULL); + XtVaSetValues(msg, XtNlabel, msgStr, NULL); - pix = XCreateBitmapFromData(XtDisplay(pic), - DefaultRootWindow(XtDisplay(pic)), - authPic_bits, authPic_width, - authPic_height); - XtVaSetValues(pic, XtNbitmap, pix, NULL); - - width1 = SeWidgetWidth(msg); - width2 = SeWidgetWidth(pic); - width1 = width1 > width2 ? width1 : width2; - width2 = SeWidgetWidth(caption); - width1 = width1 > width2 ? width1 : width2; - - XtVaSetValues(msg, XtNwidth, width1, NULL); - XtVaSetValues(pic, XtNwidth, width1, NULL); - XtVaSetValues(caption, XtNwidth, width1, NULL); + pix = XCreateBitmapFromData(XtDisplay(pic), + DefaultRootWindow(XtDisplay(pic)), + authPic_bits, authPic_width, + authPic_height); + XtVaSetValues(pic, XtNbitmap, pix, NULL); + + width1 = SeWidgetWidth(msg); + width2 = SeWidgetWidth(pic); + width1 = width1 > width2 ? width1 : width2; + width2 = SeWidgetWidth(caption); + width1 = width1 > width2 ? width1 : width2; + + XtVaSetValues(msg, XtNwidth, width1, NULL); + XtVaSetValues(pic, XtNwidth, width1, NULL); + XtVaSetValues(caption, XtNwidth, width1, NULL); - SeAddButton("dismiss", lBox, DestroyShell); + SeAddButton("dismiss", lBox, DestroyShell); - XtPopupSpringLoaded(popup); + XtPopupSpringLoaded(popup); } /* @@ -262,151 +270,151 @@ void TopHelp(widget) - Widget widget; + Widget widget; { - Widget DoDisplayFile(); - Widget displayPopup; + Widget DoDisplayFile(); + Widget displayPopup; - XtVaSetValues(widget, XtNsensitive, False, NULL); - displayPopup = DoDisplayFile(widget, qres.helpFile); - XtAddCallback(displayPopup, XtNdestroyCallback, SetSensitiveOn, widget); + XtVaSetValues(widget, XtNsensitive, False, NULL); + displayPopup = DoDisplayFile(widget, qres.helpFile); + XtAddCallback(displayPopup, XtNdestroyCallback, SetSensitiveOn, widget); - PositionShell(displayPopup, widget, SHELLPOS_HWFH); - XtPopup(displayPopup, XtGrabNone); + PositionShell(displayPopup, widget, SHELLPOS_HWFH); + XtPopup(displayPopup, XtGrabNone); } void ExecHangup() { - MdmHangup(); - SeyonMessage("Line Disconnected"); + MdmHangup(); + SeyonMessage("Line Disconnected"); } void DoHangup(widget) - Widget widget; + Widget widget; { - DestroyShell(widget); - ExecHangup(); + DestroyShell(widget); + ExecHangup(); } void HangupConfirm(widget) - Widget widget; + Widget widget; { - Widget popup, - dialog; + Widget popup, + dialog; - ErrorIfBusy() + ErrorIfBusy() - if (qres.hangupConfirm) { - popup = AddSimplePopup("hangup", widget); - dialog = SeAddDialog("dialog", popup); + if (qres.hangupConfirm) { + popup = AddSimplePopup("hangup", widget); + dialog = SeAddDialog("dialog", popup); - XawDialogAddButton(dialog, "yes", DoHangup, (XtPointer) dialog); - XawDialogAddButton(dialog, "cancel", DestroyShell, NULL); + XawDialogAddButton(dialog, "yes", DoHangup, (XtPointer) dialog); + XawDialogAddButton(dialog, "cancel", DestroyShell, NULL); - PopupCentered(popup, widget); - } - else - ExecHangup(); + PopupCentered(popup, widget); + } + else + ExecHangup(); } void ExitNoHangup(widget) - Widget widget; + Widget widget; { - DestroyShell(widget); - s_exit(widget); + DestroyShell(widget); + s_exit(widget); } void ExitHangup(widget) - Widget widget; + Widget widget; { - ExecHangup(); - ExitNoHangup(widget); + ExecHangup(); + ExitNoHangup(widget); } void ExitConfirm(widget) - Widget widget; + Widget widget; { - Widget popup, - dialog; + Widget popup, + dialog; - if (qres.exitConfirm && !qres.ignoreModemDCD && Online()) { - popup = AddSimplePopup("exit", widget); - dialog = SeAddDialog("dialog", popup); + if (qres.exitConfirm && !qres.ignoreModemDCD && Online()) { + popup = AddSimplePopup("exit", widget); + dialog = SeAddDialog("dialog", popup); - XawDialogAddButton(dialog, "yes", ExitHangup, NULL); - XawDialogAddButton(dialog, "no", ExitNoHangup, NULL); - XawDialogAddButton(dialog, "cancel", DestroyShell, NULL); + XawDialogAddButton(dialog, "yes", ExitHangup, NULL); + XawDialogAddButton(dialog, "no", ExitNoHangup, NULL); + XawDialogAddButton(dialog, "cancel", DestroyShell, NULL); - PopupCentered(popup, widget); - } - else - s_exit(); + PopupCentered(popup, widget); + } + else + s_exit(); } void ExitAction(widget) - Widget widget; + Widget widget; { - Boolean wExitButtonStatus; + Boolean wExitButtonStatus; - /* Prevent the user from exiting the program by f.delete if exiting - is not permitted */ - XtVaGetValues(w_exit, XtNsensitive, &wExitButtonStatus, NULL); - ReturnIfTrue(!wExitButtonStatus); - s_exit(); + /* Prevent the user from exiting the program by f.delete if exiting + is not permitted */ + XtVaGetValues(w_exit, XtNsensitive, &wExitButtonStatus, NULL); + ReturnIfTrue(!wExitButtonStatus); + s_exit(); } void w_exit_up(w_exit_status) - Boolean w_exit_status; + Boolean w_exit_status; { - XtVaSetValues(w_exit, XtNsensitive, w_exit_status, NULL); + XtVaSetValues(w_exit, XtNsensitive, w_exit_status, NULL); } void SetKillButtonSens(killWidgetStatus) - Boolean killWidgetStatus; + Boolean killWidgetStatus; { - XtVaSetValues(w_kill, XtNsensitive, killWidgetStatus, NULL); - w_exit_up(!killWidgetStatus); + XtVaSetValues(w_kill, XtNsensitive, killWidgetStatus, NULL); + w_exit_up(!killWidgetStatus); } void w_kill_up(w_kill_status) - Boolean w_kill_status; + Boolean w_kill_status; { - SetKillButtonSens(w_kill_status); + SetKillButtonSens(w_kill_status); } void KillChildProc() { - if (w_child_pid == 0) return; - if (kill(w_child_pid, SIGTERM) == 0) w_child_pid = 0; + if (w_child_pid == 0) return; + if (kill(w_child_pid, SIGTERM) == 0) w_child_pid = 0; } void GetQuickKeyResources(quickKeyName, quickKeyRes) - String quickKeyName; - struct _quickKeyRes *quickKeyRes; + String quickKeyName; + struct _quickKeyRes *quickKeyRes; { #define offset(field) XtOffsetOf(struct _quickKeyRes, field) - static XtResource resources[] = { - {"visible", "Visible", XtRBoolean, sizeof(Boolean), - offset(visible), XtRImmediate, (XtPointer)False}, - {"action", "Action", XtRString, sizeof(String), - offset(action), XtRString, (XtPointer)""}, - }; + static XtResource resources[] = { + {"visible", "Visible", XtRBoolean, sizeof(Boolean), + offset(visible), XtRImmediate, (XtPointer)False}, + {"action", "Action", XtRString, sizeof(String), + offset(action), XtRString, (XtPointer)""}, + }; #undef offset - XtGetSubresources(topLevel, (XtPointer)quickKeyRes, quickKeyName, "Command", - resources, XtNumber(resources), NULL, 0); + XtGetSubresources(topLevel, (XtPointer)quickKeyRes, quickKeyName, "Command", + resources, XtNumber(resources), NULL, 0); } void @@ -414,140 +422,140 @@ { #define offset(field) XtOffsetOf(struct QueryResources, field) - static XtResource resources[] = { - {"modems", "Modems", XtRString, sizeof(String), - offset(modems), XtRString, (XtPointer)""}, - {"script", "Script", XtRString, sizeof(String), - offset(script), XtRString, (XtPointer) NULL}, + static XtResource resources[] = { + {"modems", "Modems", XtRString, sizeof(String), + offset(modems), XtRString, (XtPointer)""}, + {"script", "Script", XtRString, sizeof(String), + offset(script), XtRString, (XtPointer) NULL}, - {"defaultBPS", "DefaultBPS", XtRString, sizeof(String), - offset(defaultBPS), XtRString, (XtPointer) "9600"}, - {"defaultBits", "DefaultBits", XtRInt, sizeof(int), - offset(defaultBits), XtRImmediate, (XtPointer) 8}, - {"defaultParity", "DefaultParity", XtRInt, sizeof(int), - offset(defaultParity), XtRImmediate, (XtPointer) 0}, - {"defaultStopBits", "DefaultStopBits", XtRInt, sizeof(int), - offset(defaultStopBits), XtRImmediate, (XtPointer) 1}, - {"stripHighBit", "StripHighBit", XtRBoolean, sizeof(Boolean), - offset(stripHighBit), XtRImmediate, (XtPointer) False}, - {"backspaceTranslation", "BackspaceTranslation", XtRBoolean, - sizeof(Boolean), offset(backspaceTranslation), XtRImmediate, - (XtPointer) False}, - {"metaKeyTranslation", "MetaKeyTranslation", XtRBoolean, - sizeof(Boolean), offset(metaKeyTranslation), XtRImmediate, - (XtPointer) True}, - {"xonxoffFlowControl", "XonxoffFlowControl", XtRBoolean, - sizeof(Boolean), offset(xonxoffFlowControl), XtRImmediate, - (XtPointer) False}, - {"rtsctsFlowControl", "RtsctsFlowControl", XtRBoolean, - sizeof(Boolean), offset(rtsctsFlowControl), XtRImmediate, - (XtPointer) False}, - {"newlineTranslation", "NewlineTranslation", XtRString, - sizeof(String), offset(newlineTranslation), XtRImmediate, - (XtPointer) "cr"}, - - {"dialPrefix", "DialPrefix", XtRString, sizeof(String), - offset(dialPrefix), XtRString, (XtPointer) "ATDT"}, - {"dialSuffix", "DialSuffix", XtRString, sizeof(String), - offset(dialSuffix), XtRString, (XtPointer) "^M"}, - {"dialCancelString", "DialCancelString", XtRString, sizeof(String), - offset(dialCancelString), XtRString, (XtPointer) "^M"}, - - {"dialTimeOut", "DialTimeOut", XtRInt, sizeof(int), - offset(dialTimeOut), XtRImmediate, (XtPointer) 45}, - {"dialDelay", "DialDelay", XtRInt, sizeof(int), - offset(dialDelay), XtRImmediate, (XtPointer) 10}, - {"dialRepeat", "DialRepeat", XtRInt, sizeof(int), - offset(dialRepeat), XtRImmediate, (XtPointer) 5}, - - {"connectString", "ConnectString", XtRString, sizeof(String), - offset(connectString), XtRString, (XtPointer) "CONNECT"}, - {"noConnectString1", "NoConnectString1", XtRString, sizeof(String), - offset(noConnectString[0]), XtRString, (XtPointer) "NO CARRIER"}, - {"noConnectString2", "NoConnectString2", XtRString, sizeof(String), - offset(noConnectString[1]), XtRString, (XtPointer) "NO DIALTONE"}, - {"noConnectString3", "NoConnectString3", XtRString, sizeof(String), - offset(noConnectString[2]), XtRString, (XtPointer) "BUSY"}, - {"noConnectString4", "NoConnectString4", XtRString, sizeof(String), - offset(noConnectString[3]), XtRString, (XtPointer) "VOICE"}, - - {"hangupBeforeDial", "HangupBeforeDial", XtRBoolean, sizeof(Boolean), - offset(hangupBeforeDial), XtRImmediate, (XtPointer)True}, - {"dialAutoStart", "DialAutoStart", XtRBoolean, sizeof(Boolean), - offset(dialAutoStart), XtRImmediate, (XtPointer)False}, - {"dialDirFormat", "DialDirFormat", XtRString, sizeof(String), - offset(dialDirFormat), XtRString, - (XtPointer)"%-15s %-15s %6s %1c%1c%1c %1c%1c %s"}, - {"defaultPhoneEntries", "DefaultPhoneEntries", XtRString, sizeof(String), - offset(defaultPhoneEntries), XtRString, (XtPointer)NULL}, - - {"startupAction", "StartupAction", XtRString, sizeof(String), - offset(startupAction), XtRString, - (XtPointer)"RunScript(startup);"}, - {"postConnectAction", "PostConnectAction", XtRString, sizeof(String), - offset(postConnectAction), XtRString, (XtPointer)"Beep();"}, - - {"autoZmodem", "AutoZmodem", XtRBoolean, sizeof(Boolean), - offset(autoZmodem), XtRImmediate, (XtPointer)True}, - {"autoZmodemAction", "AutoZmodemAction", XtRString, sizeof(String), - offset(autoZmodemAction), XtRString, - (XtPointer)"ShellCommand($rz);"}, - - {"modemVMin", "ModemVMin", XtRInt, sizeof(int), - offset(modemVMin), XtRImmediate, (XtPointer) 1}, - {"ignoreModemDCD", "IgnoreModemDCD", XtRBoolean, sizeof(Boolean), - offset(ignoreModemDCD), XtRImmediate, (XtPointer) False}, - {"hangupViaDTR", "HangupViaDTR", XtRBoolean, sizeof(Boolean), - offset(hangupViaDTR), XtRImmediate, (XtPointer)False}, - {"modemAttentionString", "ModemAttentionString", XtRString, sizeof(String), - offset(modemAttentionString), XtRString, (XtPointer)"+++"}, - {"modemHangupString", "ModemHangupString", XtRString, sizeof(String), - offset(modemHangupString), XtRString, (XtPointer)"ATH^M"}, - {"hangupConfirm", "HangupConfirm", XtRBoolean, sizeof(Boolean), - offset(hangupConfirm), XtRImmediate, (XtPointer) True}, - {"exitConfirm", "ExitConfirm", XtRBoolean, sizeof(Boolean), - offset(exitConfirm), XtRImmediate, (XtPointer) True}, - {"neverBeep", "NeverBeep", XtRBoolean, sizeof(Boolean), - offset(neverBeep), XtRImmediate, (XtPointer)False}, - - {"defaultDirectory", "DefaultDirectory", XtRString, sizeof(String), - offset(defaultDirectory), XtRString, (XtPointer) "~/.seyon"}, - {"scriptDirectory", "scriptDirectory", XtRString, sizeof(String), - offset(scriptDirectory), XtRString, (XtPointer) NULL}, - {"startupFile", "StartupFile", XtRString, sizeof(String), - offset(startupFile), XtRString, (XtPointer) "startup"}, - {"phoneFile", "PhoneFile", XtRString, sizeof(String), - offset(phoneFile), XtRString, (XtPointer) "phonelist"}, - {"protocolsFile", "ProtocolsFile", XtRString, sizeof(String), - offset(protocolsFile), XtRString, (XtPointer) "protocols"}, - {"captureFile", "CaptureFile", XtRString, sizeof(String), - offset(captureFile), XtRString, (XtPointer) "capture"}, - {"helpFile", "HelpFile", XtRString, sizeof(String), - offset(helpFile), XtRString, (XtPointer) HELPFILE}, - - {"modemStatusInterval", "ModemStatusInterval", XtRInt, sizeof(int), - offset(modemStatusInterval), XtRImmediate, (XtPointer) 5}, - - {"idleGuard", "IdleGuard", XtRBoolean, sizeof(Boolean), - offset(idleGuard), XtRImmediate, (XtPointer) False}, - {"idleGuardInterval", "IdleGuardInterval", XtRInt, sizeof(int), - offset(idleGuardInterval), XtRImmediate, (XtPointer) 300}, - {"idleGuardString", "IdleGuardString", XtRString, sizeof(String), - offset(idleGuardString), XtRImmediate, (XtPointer) " ^H"}, - - {"showFunMessages", "ShowFunMessages", XtRBoolean, sizeof(Boolean), - offset(showFunMessages), XtRImmediate, (XtPointer) True}, - {"funMessagesInterval", "FunMessagesInterval", XtRInt, sizeof(int), - offset(funMessagesInterval), XtRImmediate, (XtPointer) 15}, - {"funMessages", "FunMessages", XtRStringArray, sizeof(String*), - offset(funMessages), XtRStringArray, (XtPointer) NULL}, - }; + {"defaultBPS", "DefaultBPS", XtRString, sizeof(String), + offset(defaultBPS), XtRString, (XtPointer) "9600"}, + {"defaultBits", "DefaultBits", XtRInt, sizeof(int), + offset(defaultBits), XtRImmediate, (XtPointer) 8}, + {"defaultParity", "DefaultParity", XtRInt, sizeof(int), + offset(defaultParity), XtRImmediate, (XtPointer) 0}, + {"defaultStopBits", "DefaultStopBits", XtRInt, sizeof(int), + offset(defaultStopBits), XtRImmediate, (XtPointer) 1}, + {"stripHighBit", "StripHighBit", XtRBoolean, sizeof(Boolean), + offset(stripHighBit), XtRImmediate, (XtPointer) False}, + {"backspaceTranslation", "BackspaceTranslation", XtRBoolean, + sizeof(Boolean), offset(backspaceTranslation), XtRImmediate, + (XtPointer) False}, + {"metaKeyTranslation", "MetaKeyTranslation", XtRBoolean, + sizeof(Boolean), offset(metaKeyTranslation), XtRImmediate, + (XtPointer) True}, + {"xonxoffFlowControl", "XonxoffFlowControl", XtRBoolean, + sizeof(Boolean), offset(xonxoffFlowControl), XtRImmediate, + (XtPointer) False}, + {"rtsctsFlowControl", "RtsctsFlowControl", XtRBoolean, + sizeof(Boolean), offset(rtsctsFlowControl), XtRImmediate, + (XtPointer) False}, + {"newlineTranslation", "NewlineTranslation", XtRString, + sizeof(String), offset(newlineTranslation), XtRImmediate, + (XtPointer) "cr"}, + + {"dialPrefix", "DialPrefix", XtRString, sizeof(String), + offset(dialPrefix), XtRString, (XtPointer) "ATDT"}, + {"dialSuffix", "DialSuffix", XtRString, sizeof(String), + offset(dialSuffix), XtRString, (XtPointer) "^M"}, + {"dialCancelString", "DialCancelString", XtRString, sizeof(String), + offset(dialCancelString), XtRString, (XtPointer) "^M"}, + + {"dialTimeOut", "DialTimeOut", XtRInt, sizeof(int), + offset(dialTimeOut), XtRImmediate, (XtPointer) 45}, + {"dialDelay", "DialDelay", XtRInt, sizeof(int), + offset(dialDelay), XtRImmediate, (XtPointer) 10}, + {"dialRepeat", "DialRepeat", XtRInt, sizeof(int), + offset(dialRepeat), XtRImmediate, (XtPointer) 5}, + + {"connectString", "ConnectString", XtRString, sizeof(String), + offset(connectString), XtRString, (XtPointer) "CONNECT"}, + {"noConnectString1", "NoConnectString1", XtRString, sizeof(String), + offset(noConnectString[0]), XtRString, (XtPointer) "NO CARRIER"}, + {"noConnectString2", "NoConnectString2", XtRString, sizeof(String), + offset(noConnectString[1]), XtRString, (XtPointer) "NO DIALTONE"}, + {"noConnectString3", "NoConnectString3", XtRString, sizeof(String), + offset(noConnectString[2]), XtRString, (XtPointer) "BUSY"}, + {"noConnectString4", "NoConnectString4", XtRString, sizeof(String), + offset(noConnectString[3]), XtRString, (XtPointer) "VOICE"}, + + {"hangupBeforeDial", "HangupBeforeDial", XtRBoolean, sizeof(Boolean), + offset(hangupBeforeDial), XtRImmediate, (XtPointer)True}, + {"dialAutoStart", "DialAutoStart", XtRBoolean, sizeof(Boolean), + offset(dialAutoStart), XtRImmediate, (XtPointer)False}, + {"dialDirFormat", "DialDirFormat", XtRString, sizeof(String), + offset(dialDirFormat), XtRString, + (XtPointer)"%-15s %-15s %6s %1c%1c%1c %1c%1c %s"}, + {"defaultPhoneEntries", "DefaultPhoneEntries", XtRString, sizeof(String), + offset(defaultPhoneEntries), XtRString, (XtPointer)NULL}, + + {"startupAction", "StartupAction", XtRString, sizeof(String), + offset(startupAction), XtRString, + (XtPointer)"RunScript(startup);"}, + {"postConnectAction", "PostConnectAction", XtRString, sizeof(String), + offset(postConnectAction), XtRString, (XtPointer)"Beep();"}, + + {"autoZmodem", "AutoZmodem", XtRBoolean, sizeof(Boolean), + offset(autoZmodem), XtRImmediate, (XtPointer)True}, + {"autoZmodemAction", "AutoZmodemAction", XtRString, sizeof(String), + offset(autoZmodemAction), XtRString, + (XtPointer)"ShellCommand($rz);"}, + + {"modemVMin", "ModemVMin", XtRInt, sizeof(int), + offset(modemVMin), XtRImmediate, (XtPointer) 1}, + {"ignoreModemDCD", "IgnoreModemDCD", XtRBoolean, sizeof(Boolean), + offset(ignoreModemDCD), XtRImmediate, (XtPointer) False}, + {"hangupViaDTR", "HangupViaDTR", XtRBoolean, sizeof(Boolean), + offset(hangupViaDTR), XtRImmediate, (XtPointer)False}, + {"modemAttentionString", "ModemAttentionString", XtRString, sizeof(String), + offset(modemAttentionString), XtRString, (XtPointer)"+++"}, + {"modemHangupString", "ModemHangupString", XtRString, sizeof(String), + offset(modemHangupString), XtRString, (XtPointer)"ATH^M"}, + {"hangupConfirm", "HangupConfirm", XtRBoolean, sizeof(Boolean), + offset(hangupConfirm), XtRImmediate, (XtPointer) True}, + {"exitConfirm", "ExitConfirm", XtRBoolean, sizeof(Boolean), + offset(exitConfirm), XtRImmediate, (XtPointer) True}, + {"neverBeep", "NeverBeep", XtRBoolean, sizeof(Boolean), + offset(neverBeep), XtRImmediate, (XtPointer)False}, + + {"defaultDirectory", "DefaultDirectory", XtRString, sizeof(String), + offset(defaultDirectory), XtRString, (XtPointer) "~/.seyon"}, + {"scriptDirectory", "scriptDirectory", XtRString, sizeof(String), + offset(scriptDirectory), XtRString, (XtPointer) NULL}, + {"startupFile", "StartupFile", XtRString, sizeof(String), + offset(startupFile), XtRString, (XtPointer) "startup"}, + {"phoneFile", "PhoneFile", XtRString, sizeof(String), + offset(phoneFile), XtRString, (XtPointer) "phonelist"}, + {"protocolsFile", "ProtocolsFile", XtRString, sizeof(String), + offset(protocolsFile), XtRString, (XtPointer) "protocols"}, + {"captureFile", "CaptureFile", XtRString, sizeof(String), + offset(captureFile), XtRString, (XtPointer) "capture"}, + {"helpFile", "HelpFile", XtRString, sizeof(String), + offset(helpFile), XtRString, (XtPointer) HELPFILE}, + + {"modemStatusInterval", "ModemStatusInterval", XtRInt, sizeof(int), + offset(modemStatusInterval), XtRImmediate, (XtPointer) 5}, + + {"idleGuard", "IdleGuard", XtRBoolean, sizeof(Boolean), + offset(idleGuard), XtRImmediate, (XtPointer) False}, + {"idleGuardInterval", "IdleGuardInterval", XtRInt, sizeof(int), + offset(idleGuardInterval), XtRImmediate, (XtPointer) 300}, + {"idleGuardString", "IdleGuardString", XtRString, sizeof(String), + offset(idleGuardString), XtRImmediate, (XtPointer) " ^H"}, + + {"showFunMessages", "ShowFunMessages", XtRBoolean, sizeof(Boolean), + offset(showFunMessages), XtRImmediate, (XtPointer) True}, + {"funMessagesInterval", "FunMessagesInterval", XtRInt, sizeof(int), + offset(funMessagesInterval), XtRImmediate, (XtPointer) 15}, + {"funMessages", "FunMessages", XtRStringArray, sizeof(String*), + offset(funMessages), XtRStringArray, (XtPointer) NULL}, + }; #undef offset - XtSetTypeConverter(XtRString, XtRStringArray, CvtStringToStringArray, - NULL, 0, XtCacheNone, NULL); + XtSetTypeConverter(XtRString, XtRStringArray, CvtStringToStringArray, + NULL, 0, XtCacheNone, NULL); - XtGetApplicationResources(topLevel, (XtPointer)&qres, resources, - XtNumber(resources), NULL, 0); + XtGetApplicationResources(topLevel, (XtPointer)&qres, resources, + XtNumber(resources), NULL, 0); } --- a/SeParse.y +++ b/SeParse.y @@ -1,8 +1,11 @@ %{ #include #include +#include #include "SeParse.h" +int yylex(void); + void (*callbackProc)(); %} @@ -81,19 +84,19 @@ { char long_line[1000]; - char input_str[] = "This(is, a, real, funky); script(); - Scripts(); Can(be); Multi(Line, \"Can't they?\"); - Commas(are, no, longer, optional, inside, arglists); - Scripts(); Can(); contain(\"tabs \\t and backspaces \\b\"); - As(\"Well\\ as Quoted Strings\", and, '\"Quoted Strings inside - quoted strings\"'); - esc(can, appear, outside, strings, ^z, \\012\\015\\n); - But(parenthesis, should, match); - We(\"have a funny way of specifying \\012 chars and even)\"); - backslashes( \" \\\\ \"); - new(\"in this version are ^m and ^A ctr-escapes, as in ^S^Q\"); - The(next, line, will, give, a, syntax, error, because, it, has, two, adj, functions, - without, a, separating, semicolon); + char input_str[] = "This(is, a, real, funky); script();\n\ + Scripts(); Can(be); Multi(Line, \"Can't they?\");\n\ + Commas(are, no, longer, optional, inside, arglists);\n\ + Scripts(); Can(); contain(\"tabs \\t and backspaces \\b\");\n\ + As(\"Well\\ as Quoted Strings\", and, '\"Quoted Strings inside\n\ + quoted strings\"');\n\ + esc(can, appear, outside, strings, ^z, \\012\\015\\n)\n\ + But(parenthesis, should, match);\n\ + We(\"have a funny way of specifying \\012 chars and even)\"); \n\ + backslashes( \" \\\\ \");\n\ + new(\"in this version are ^m and ^A ctr-escapes, as in ^S^Q\");\n\ + The(next, line, will, give, a, syntax, error, because, it, has, two, adj, functions,\n\ + without, a, separating, semicolon);\n\ End() script()"; printf("------ String to parse: \n%s\n\n---- Parsing begins:\n", input_str); --- a/SePort.c +++ b/SePort.c @@ -51,7 +51,7 @@ #ifdef linux #include #include -#include +/* #include */ #include #endif #endif @@ -127,20 +127,30 @@ void MdmPutString(s) - char *s; + char *s; { - char c; - - usleep(MDELAY); - for (; (c = *s); s++) { - if (*s == '^' && *(s + 1)) - if (*(++s) == '^') c = *s; - else c = *s & 0x1f; + char c; - if (c == '~') sleep(1); - else send_tbyte(c); usleep(MDELAY); - } + for (; (c = *s); s++) + { + if (*s == '^' && *(s + 1)) + { + if (*(++s) == '^') + { + c = *s; + } + else + { + c = *s & 0x1f; + } + } + if (c == '~') + sleep(1); + else + send_tbyte(c); + usleep(MDELAY); + } } void @@ -150,10 +160,7 @@ *b, *c; { - char buf[REG_BUF]; - - sprintf(buf, fmt, a, b, c); - MdmPutString(buf); + MdmPutString(FmtString(fmt,a,b,c)); } void @@ -224,7 +231,7 @@ int newModem; { static Boolean useModemControl = True; - int retStat; + int retStat = 0; if (newModem) useModemControl = True; @@ -350,11 +357,11 @@ char * mport(s) /* get/set port string */ - char *s; + char *s; { - if (s != NULL) - strcpy(modem_port, s); - return (modem_port); + if (s != NULL) + strncpy(modem_port, s, sizeof(modem_port)); + return (modem_port); } int @@ -650,6 +657,17 @@ ser_io.flags |= ASYNC_SPD_VHI; break; #endif +#else +#ifdef B57600 + case 57600: + baudrate = B57600; + break; +#endif +#ifdef B115200 + case 115200: + baudrate = B115200; + break; +#endif #endif default: return (-1); @@ -702,6 +720,14 @@ #endif #endif return 38400; +#ifdef B57600 + case B57600: + return 57600; +#endif +#ifdef B115200 + case B115200: + return 115200; +#endif } SeError("Consistency error in baud rate"); @@ -822,7 +848,7 @@ modemName, "", "")); break; default: - SeError(FmtString("Unknown Error While Openeong Modem ``%s''", + SeError(FmtString("Unknown Error While Opening Modem ``%s''", modemName, "", "")); break; } @@ -946,16 +972,13 @@ } void -sendf_slowly(format, a, b, c) - char *format, +sendf_slowly(fmt, a, b, c) + char *fmt, *a, *b, *c; { - char buffer[SM_BUF]; - - sprintf(buffer, format, a, b, c); - send_slowly(buffer); + send_slowly(FmtString(fmt,a,b,c)); } void @@ -989,7 +1012,7 @@ LockModem(modem) String modem; { - strcpy(modem_port, modem); + strncpy(modem_port, modem, REG_BUF); return lock_tty(); } @@ -1004,50 +1027,82 @@ int lock_tty() { - int lfd; - pid_t pid, - lckpid; - char *modemname; + int lfd; + pid_t pid, + lckpid; + char *modemname; #if LF_USE_ASCII_PID - char pidstr[20], - lckpidstr[20]; - int nb; + char pidstr[20], + lckpidstr[20]; + int nb; #endif #if LF_USE_DEV_NUMBERS - struct stat mbuf; + struct stat mbuf; #endif - /* Get our PID, and initialize the filename strings */ - pid = getpid(); + /* Get our PID, and initialize the filename strings */ + pid = getpid(); #if !LF_USE_DEV_NUMBERS - modemname = strrchr(modem_port, '/'); - sprintf(lckf, "%s/%s%s", LF_PATH, LF_PREFIX, - (modemname ? (modemname + 1) : modem_port)); -#else - if(stat(modem_port, &mbuf) < 0) { - SePErrorF("could not stat modem port %s", modem_port, "", ""); - return -1; - } - sprintf(lckf,"%s/%s%03u.%03u.%03u", LF_PATH, LF_PREFIX, major(mbuf.st_dev), - major(mbuf.st_rdev), minor(mbuf.st_rdev)); + modemname = strrchr(modem_port, '/'); + if(modemname) + { + if( SM_BUF > (1 + strlen(LF_PATH) + strlen(LF_PREFIX) + strlen(modemname))) + sprintf(lckf, "%s/%s%s", LF_PATH, LF_PREFIX, (modemname + 1)); + else + { + SePErrorF("Buffer too small for lock filename in lock_tty(): %s", modemname, "", ""); + return -1; + } + } + else + { + if( SM_BUF > (1 + strlen(LF_PATH) + strlen(LF_PREFIX) + strlen(modem_port))) + sprintf(lckf, "%s/%s%s", LF_PATH, LF_PREFIX, (modem_port)); + else + { + SePErrorF("Buffer too small for lock filename in lock_tty(): %s", modem_port, "", ""); + return -1; + } + } + +#else + if(stat(modem_port, &mbuf) < 0) { + SePErrorF("could not stat modem port %s", modem_port, "", ""); + return -1; + } + if( SM_BUF > (10 + strlen(LF_PATH) + strlen(LF_PREFIX))) + sprintf(lckf,"%s/%s%03u.%03u.%03u", LF_PATH, LF_PREFIX, major(mbuf.st_dev), + major(mbuf.st_rdev), minor(mbuf.st_rdev)); + else + { + SePErrorF("Buffer too small for lock filename in lock_tty():", "", "", ""); + return -1; + } #endif /* LF_USE_DEV_NUMBERS */ - sprintf(ltmp, "%s/%s%d", LF_PATH, "LTMP.", pid); - /* Create the LTMP. file and scribble our PID in it */ - unlink(ltmp); - if ((lfd = creat(ltmp, 0644)) == -1) { - SePErrorF("Could not create temporary lock file %s", ltmp, "", ""); - return -1; - } + if( SM_BUF > (11 + strlen(LF_PATH))) + sprintf(ltmp, "%s/%s%d", LF_PATH, "LTMP.", pid); + else + { + SePErrorF("Buffer too small for ltmp filename in lock_tty():", "", "", ""); + return -1; + } + /* Create the LTMP. file and scribble our PID in it */ + unlink(ltmp); + if ((lfd = creat(ltmp, 0644)) == -1) { + SePErrorF("Could not create temporary lock file %s", ltmp, "", ""); + return -1; + } #if LF_USE_ASCII_PID - sprintf(pidstr, "%10d\n", pid); - write(lfd, pidstr, 11); + /* pidstr is easily large enough */ + sprintf(pidstr, "%10d\n", pid); + write(lfd, pidstr, 11); #else - write(lfd, (char*)&pid, sizeof(pid)); + write(lfd, (char*)&pid, sizeof(pid)); #endif - close(lfd); + close(lfd); /* * Attempt to link directly - if it works, we're done. --- a/SeScan.c +++ b/SeScan.c @@ -95,8 +95,8 @@ SC_OUTSIDE, }; -static ScanState = SC_OUTSIDE; -static ScanDelim = 0; /* Current string delimiter */ +static int ScanState = SC_OUTSIDE; +static int ScanDelim = 0; /* Current string delimiter */ void NEW_STATE(st) int st; @@ -290,8 +290,8 @@ #ifdef TEST main() { - scSetInputBuf("Just to see if we'\\'re \\n\\033 able to distinguish' words and strings -\"Also 'quotes' inside strings\" and 'strs \"inside quotes\"' + scSetInputBuf("Just to see if we'\\'re \\n\\033 able to distinguish' words and strings\n\ +\"Also 'quotes' inside strings\" and 'strs \"inside quotes\"'\n\ Not to forget ^S and ^q control ^ chars"); while (lGetWord() != 0); --- a/SeScript.c +++ b/SeScript.c @@ -100,8 +100,8 @@ if (qres.scriptDirectory) scriptDir = qres.scriptDirectory; else scriptDir = qres.defaultDirectory; - strcpy(buf, scriptFileName); - if ((scriptFP = open_file(buf, scriptDir)) == NULL) + strncpy(buf, scriptFileName, REG_BUF); + if ((scriptFP = open_file(buf, REG_BUF, scriptDir)) == NULL) return False; exec_close_script(scriptFP); @@ -110,31 +110,33 @@ void exec_close_script(script_fp) - FILE *script_fp; + FILE *script_fp; { - if_flag = 0; - echo_flag = False; - captflag = False; - tty_flag = True; - eof_flag = 0; + if_flag = 0; + echo_flag = False; + captflag = False; + tty_flag = True; + eof_flag = 0; - if (linkflag == 2) - linkflag = 0; + if (linkflag == 2) + linkflag = 0; - while (!eof_flag) - get_line(script_fp); + while (!eof_flag) + get_line(script_fp); - fclose(script_fp); - if (captflag) - fclose(cf); - - eof_flag = 0; - lptr = strcpy(line, ""); - k_when(); + fclose(script_fp); + if (captflag) + fclose(cf); - linkflag = 0; + eof_flag = 0; + /* No buffer length problem here! */ + /* But why do this??? */ + lptr = strcpy(line, ""); + k_when(); - return; + linkflag = 0; + + return; } static char wf[MAX_LINE]; @@ -202,7 +204,7 @@ GETTEST_ARG("waitfor"); - strcpy(wf, word); + strncpy(wf, word, MAX_LINE); GET_ARG(); @@ -331,7 +333,7 @@ return; } - strcpy(label, word); + strncpy(label, word, WBSIZE); rewind(script_fp); while (!found) { @@ -360,7 +362,7 @@ if_flag = 0; /* reset IF flag */ } -static if_negate = 0; +static int if_negate = 0; static int if_test(cond) --- a/SeSet.c +++ b/SeSet.c @@ -18,6 +18,9 @@ #include "seyon.h" #include "SeDecl.h" +#if HAVE_TERMIOS +#include +#endif extern int param_pipe[2]; @@ -84,6 +87,13 @@ {"baud", {"300", "1200", "2400", "4800", "9600", "19200", "38400", #if USE_NONSTD_BAUD "57600", "115200", +#else +#ifdef B57600 + "57600", +#endif +#ifdef B115200 + "115200", +#endif #endif NULL}, 1, MenuSetGetBaud}, {"bits", {"5", "6", "7", "8", NULL}, 1, MenuSetGetCSize}, @@ -191,7 +201,7 @@ struct _setValue *vptr; vptr = set_value; - strcpy(vptr->value, modem_port); + strncpy(vptr->value, modem_port, SM_BUF); vptr++; curValObjPtr = (vptr = (struct _setValue *)client_data); --- a/SeString.c +++ b/SeString.c @@ -22,12 +22,13 @@ char itoa(num) - int num; + int num; { - char buf[TIN_BUF]; + char buf[TIN_BUF]; - sprintf(buf, "%d", num); - return buf[0]; + /* Buffer is safely big enough */ + sprintf(buf, "%d", num); + return buf[0]; } /* @@ -100,8 +101,15 @@ char buffer[REG_BUF], *bufptr; - strcpy(buffer, source); + strncpy(buffer, source, REG_BUF); + + /* Null-terminate, as expected by str_strip_lead_end_space(). */ + buffer[REG_BUF-1] = '\0'; + bufptr = str_strip_lead_end_space(buffer); + + /* Must fit, as we can only have removed things from the original + string */ return strcpy(dest, bufptr); } @@ -128,14 +136,43 @@ return strBuf; } +/* Note that the the (char *) data structure returned by FmtString() + is invalidated on subsequent calls, and that the function is not + re-entrant. Take care that the pointer returned is not held for + use across calls. */ char* FmtString(fmt, a, b, c) - char *fmt, *a, *b, *c; + char *fmt, *a, *b, *c; { - static char strBuf[LRG_BUF]; + static char strBuf[LRG_BUF]; + static FILE *devnull=NULL; + int length = 0; + + /* Clear the buffer as it highlights errors elsewhere, such as + simultaneous use of the static string or re-entry into this + function. */ + memset(strBuf, 0, LRG_BUF); + + /* Ick... This is horrible - using a user-provided format string + means we have no easy way of limiting string length. HACK HACK + HACK Use fprintf to output to /dev/null and count the number of + bytes... It would be nice if we could rely on having snprintf() */ + + if(NULL == devnull) + { + devnull = fopen("/dev/null", "r+"); + if(NULL == devnull) + { + printf("Open /dev/null failed!?!\n"); + return strBuf; + } + length = fprintf(devnull, fmt, a, b, c); + } + + if(LRG_BUF >= length) + sprintf(strBuf, fmt, a, b, c); - sprintf(strBuf, fmt, a, b, c); - return strBuf; + return strBuf; } /* @@ -189,6 +226,7 @@ if (*line == '\0') return NULL; else if (*line == '\"') + for (wrd = ++line; *line != '\"' && *line; line++); else for (wrd = line; !isspace(*line) && *line; line++); @@ -246,38 +284,38 @@ * this routine is not currently used, and I'm not if it works */ -char * -get_word(str, word) - char *str, - *word; -{ - char *wrd, - c; - - while (isspace(*str) && *str) - str++; - - if (!(*str)) - word[0] = '\0'; - - else if (*str == '\"') { - for (wrd = ++str; *str != '\"' && *str; str++); - *str = '\0'; - strcpy(word, wrd); - *str = '\"'; - str++; - } +/* char * */ +/* get_word(str, word) */ +/* char *str, */ +/* *word; */ +/* { */ +/* char *wrd, */ +/* c; */ + +/* while (isspace(*str) && *str) */ +/* str++; */ + +/* if (!(*str)) */ +/* word[0] = '\0'; */ + +/* else if (*str == '\"') { */ +/* for (wrd = ++str; *str != '\"' && *str; str++); */ +/* *str = '\0'; */ +/* strcpy(word, wrd); */ +/* *str = '\"'; */ +/* str++; */ +/* } */ + +/* else { */ +/* for (wrd = str; !isspace(*str) && *str; str++); */ +/* c = *str; */ +/* *str = '\0'; */ +/* strcpy(word, wrd); */ +/* *str = c; */ +/* } */ - else { - for (wrd = str; !isspace(*str) && *str; str++); - c = *str; - *str = '\0'; - strcpy(word, wrd); - *str = c; - } - - return str; -} +/* return str; */ +/* } */ #if !HAVE_STRERROR --- a/SeSubs.c +++ b/SeSubs.c @@ -45,9 +45,9 @@ void toggle_flag(flag) - Boolean *flag; + Boolean *flag; { - *flag = !*flag; + *flag = !*flag; } /* @@ -56,10 +56,10 @@ void show(msg) - char *msg; + char *msg; { - fprintf(tfp, "%s\r\n", msg); - fflush(tfp); + fprintf(tfp, "%s\r\n", msg); + fflush(tfp); } /* @@ -68,105 +68,96 @@ void showf(fmt, a, b, c) - char *fmt, - *a, - *b, - *c; + char *fmt, + *a, + *b, + *c; { - fprintf(tfp, fmt, a, b, c); - fprintf(tfp, "\r\n"); + fprintf(tfp, fmt, a, b, c); + fprintf(tfp, "\r\n"); } void SeError(msg) - char *msg; + char *msg; { - char buf[REG_BUF]; + char buf[REG_BUF]; - sprintf(buf, "\r>> Error: %s.", msg); - show(buf); + strncpy(buf, "\r>> Error: ",REG_BUF); + strncat(buf, msg, REG_BUF-12); + buf[REG_BUF - 1] = 0; /* Null-terminate to be sure */ + show(buf); } void SeErrorF(fmt, a, b, c) - char *fmt, - *a, - *b, - *c; + char *fmt, + *a, + *b, + *c; { - char buf[REG_BUF]; - - sprintf(buf, fmt, a, b, c); - SeError(buf); + SeError(FmtString(fmt, a, b, c)); } void se_warning(msg) - char *msg; + char *msg; { - char buf[REG_BUF]; + char buf[REG_BUF]; - sprintf(buf, "\r>> Warning: %s.", msg); - show(buf); + strncpy(buf, "\r>> Warning: ",REG_BUF); + strncat(buf, msg, REG_BUF-14); + buf[REG_BUF - 1] = 0; /* Null-terminate to be sure */ + show(buf); } void se_warningf(fmt, a, b, c) - char *fmt, - *a, - *b, - *c; + char *fmt, + *a, + *b, + *c; { - char buf[REG_BUF]; - - sprintf(buf, fmt, a, b, c); - se_warning(buf); + se_warning(FmtString(fmt, a, b, c)); } void SeNotice(msg) - char *msg; + char *msg; { - char buf[REG_BUF]; + char buf[REG_BUF]; - sprintf(buf, "\r>> Notice: %s.", msg); - show(buf); + strncpy(buf, "\r>> Notice: ",REG_BUF); + strncat(buf, msg, REG_BUF-13); + buf[REG_BUF - 1] = 0; /* Null-terminate to be sure */ + show(buf); } void SeNoticeF(fmt, a, b, c) - char *fmt, - *a, - *b, - *c; + char *fmt, + *a, + *b, + *c; { - char buf[REG_BUF]; - - sprintf(buf, fmt, a, b, c); - SeNotice(buf); + SeNotice(FmtString(fmt, a, b, c)); } void SePError(msg) - char *msg; + char *msg; { - char buf[REG_BUF]; - - sprintf(buf, "%s: %s", msg, strerror(errno)); - SeError(buf); + SeError(FmtString("%s: %s",msg,strerror(errno))); } void SePErrorF(fmt, a, b, c) - char *fmt, - *a, - *b, - *c; + char *fmt, + *a, + *b, + *c; { - char buf[REG_BUF]; - - sprintf(buf, fmt, a, b, c); - SePError(buf); + SePError(FmtString(fmt,a,b,c)); } /* ------------------------------------------------------------ @@ -180,12 +171,12 @@ int SeFork() { - pid_t pid; + pid_t pid; - if ((pid = fork()) < 0) - SePError("Faild to fork process"); + if ((pid = fork()) < 0) + SePError("Faild to fork process"); - return pid; + return pid; } /* @@ -194,119 +185,119 @@ void ShellCommandHandler(sig, fio_p) - int sig; - XtPointer fio_p; + int sig; + XtPointer fio_p; { - void PostExecPrep(); + void PostExecPrep(); - if (wait((int*)0) < 0) SePError("ShellCommand wait failed"); - XoAppIgnoreSignal(app_con, SIGCHLD); + if (wait((int*)0) < 0) SePError("ShellCommand wait failed"); + XoAppIgnoreSignal(app_con, SIGCHLD); - set_tty_mode(); - set_modem_fio(*(int *)fio_p); + set_tty_mode(); + set_modem_fio(*(int *)fio_p); - SeyonMessage("Shell Command Completed"); - PostExecPrep(); - inhibit_child = False; + SeyonMessage("Shell Command Completed"); + PostExecPrep(); + inhibit_child = False; } void ShellCommand(command) - char *command; + char *command; { - ExecShellCommand(command, 1); + ExecShellCommand(command, 1); } void ExecShellCommand(command, top) - char *command; - int top; + char *command; + int top; { - static char *shell = NULL; - char cmd[REG_BUF], - *scmd; - static int fio=0; - pid_t forkRes; - - if (command == NULL) return; - - if (shell == NULL) { - shell = (char*)getenv("SHELL"); - if (!shell) shell = "/bin/sh"; - } - - if (top) PreExecPrep(); - - io_set_attr(tfd, &oldmode); - fio = get_modem_fio(); - - if (top) - XoAppAddSignal(app_con, SIGCHLD, ShellCommandHandler, (XtPointer)&fio); - else signal(SIGCHLD, SIG_IGN); - - forkRes = SeFork(); - if (forkRes == 0) { - scmd = str_stripspc_copy(cmd, command); - - show(""); - - if (*scmd == '$') { - SeNotice("Redirecting stdin/stdout"); - mattach(); /* Attach modem to stdin/stdout */ - scmd++; + static char *shell = NULL; + char cmd[REG_BUF], + *scmd; + static int fio=0; + pid_t forkRes; + + if (command == NULL) return; + + if (shell == NULL) { + shell = (char*)getenv("SHELL"); + if (!shell) shell = "/bin/sh"; } - if (setuid(getuid()) < 0) - SePError("Failed to set effective uid"); + if (top) PreExecPrep(); - if (*scmd == CNULL) { - SeNotice(FmtString1("Executing the shell `%s'", shell)); - execl(shell, shell, (char*)NULL); - SeError(FmtString1("Execution of the shell `%s' failed", shell)); - exit(1); - } + io_set_attr(tfd, &oldmode); + fio = get_modem_fio(); + + if (top) + XoAppAddSignal(app_con, SIGCHLD, ShellCommandHandler, (XtPointer)&fio); + else signal(SIGCHLD, SIG_IGN); + + forkRes = SeFork(); + if (forkRes == 0) { + scmd = str_stripspc_copy(cmd, command); + + show(""); + + if (*scmd == '$') { + SeNotice("Redirecting stdin/stdout"); + mattach(); /* Attach modem to stdin/stdout */ + scmd++; + } + + if (setuid(getuid()) < 0) + SePError("Failed to set effective uid"); + + if (*scmd == CNULL) { + SeNotice(FmtString1("Executing the shell `%s'", shell)); + execl(shell, shell, (char*)NULL); + SeError(FmtString1("Execution of the shell `%s' failed", shell)); + exit(1); + } - SeNotice(FmtString1("Executing the command `%s'", scmd)); - execl(shell, shell, "-c", scmd, (char*)NULL); - SePError(FmtString1("Execution of the command `%s' failed", scmd)); - exit(1); - } - else if (forkRes > 0) { - if (top) inhibit_child = True; - else { + SeNotice(FmtString1("Executing the command `%s'", scmd)); + execl(shell, shell, "-c", scmd, (char*)NULL); + SePError(FmtString1("Execution of the command `%s' failed", scmd)); + exit(1); + } + else if (forkRes > 0) { + if (top) inhibit_child = True; + else { wait((int*)0); /* Wait for the child process to terminate */ set_tty_mode(); set_modem_fio(fio); - } - } /* if (forkRes == 0)... */ + } + } /* if (forkRes == 0)... */ } void PreProcessPrep() { - SuspContTerminal(TERM_SUSPEND); - SetKillButtonSens(True); + SuspContTerminal(TERM_SUSPEND); + SetKillButtonSens(True); } void PostProcessPrep() { - SuspContTerminal(TERM_CONTINUE); - SetKillButtonSens(False); + SuspContTerminal(TERM_CONTINUE); + SetKillButtonSens(False); } void PreExecPrep() { - SuspContTerminal(0); - w_exit_up(False); + SuspContTerminal(0); + w_exit_up(False); } void PostExecPrep() { - SuspContTerminal(1); - w_exit_up(True); + SuspContTerminal(1); + w_exit_up(True); } /* @@ -318,33 +309,34 @@ */ char * -expand_fname(fname, buffer) - char *fname, - *buffer; -{ - char *home, - *buf, - name[REG_BUF]; - int i; - - str_stripspc_copy(name, fname); - buf = buffer; - - for (i = 0; name[i]; i++) { - if (name[i] == '~') { - if ((home = (char *) getenv("HOME")) == NULL) - return NULL; - strcpy(buf, home); - buf += strlen(home); +expand_fname(fname, buffer, size) + char *fname, + *buffer; + int size; +{ + char *home, + *buf, + name[REG_BUF]; + int i; + + str_stripspc_copy(name, fname); + buf = buffer; + + for (i = 0; (name[i] && (buffer+REG_BUF > buf)); i++) { + if (name[i] == '~') { + if ((home = (char *) getenv("HOME")) == NULL) + return NULL; + strncpy(buf, home, size); + buf += strlen(home); + } + else { + *buf = name[i]; + buf++; + } } - else { - *buf = name[i]; - buf++; - } - } - *buf = '\0'; + *buf = '\0'; - return buffer; + return buffer; } /* @@ -353,11 +345,12 @@ */ FILE* -open_file(fname, directory) - char *fname, - *directory; +open_file(fname, size, directory) + char *fname; + int size; + char *directory; { - return open_file_va(fname, directory, NULL); + return open_file_va(fname, size, directory, NULL); } /* @@ -365,120 +358,79 @@ */ FILE* -open_file_va(fname, dir1, dir2) - char *fname, - *dir1, - *dir2; -{ - FILE *fp; - char name[REG_BUF], - fullname[REG_BUF], - buffer[REG_BUF]; - - str_stripspc_copy(name, fname); - - if (dir1) { - sprintf(fullname, "%s/%s", expand_fname(dir1, buffer), name); - - if ((fp = fopen(fullname, "r")) != NULL) { - strcpy(fname, fullname); - return fp; - } - - if (dir2) { - sprintf(fullname, "%s/%s", expand_fname(dir2, buffer), name); +open_file_va(fname, size, dir1, dir2) + char *fname; + int size; + char *dir1, + *dir2; +{ + FILE *fp; + char *fullname, + name[REG_BUF], + buffer[REG_BUF]; + + str_stripspc_copy(name, fname); + + if (dir1) { + fullname = FmtString("%s/%s", expand_fname(dir1, buffer, REG_BUF), name, ""); + if ((fp = fopen(fullname, "r")) != NULL) { + strncpy(fname, fullname, size); + return fp; + } - if ((fp = fopen(fullname, "r")) != NULL) { - strcpy(fname, fullname); - return fp; - } + if (dir2) { + fullname = FmtString("%s/%s", expand_fname(dir2, buffer, REG_BUF), name, ""); + if ((fp = fopen(fullname, "r")) != NULL) { + strncpy(fname, fullname, size); + return fp; + } + } + } /* if (dir1)... */ + + if ((fp = fopen(name, "r")) != NULL) { + strncpy(fname, name, REG_BUF); + return fp; } - } /* if (dir1)... */ - - if ((fp = fopen(name, "r")) != NULL) { - strcpy(fname, name); - return fp; - } - SeErrorF("/OFV/ Could not open the file `%s'", name, "", ""); - if (dir1) { - SeNoticeF("Tried the default directory `%s'", dir1, "", ""); - if (dir2) - SeNoticeF("Tried the default directory `%s'", dir2, "", ""); - } - SeNotice("Tried the current directory"); + SeErrorF("/OFV/ Could not open the file `%s'", name, "", ""); + if (dir1) { + SeNoticeF("Tried the default directory `%s'", dir1, "", ""); + if (dir2) + SeNoticeF("Tried the default directory `%s'", dir2, "", ""); + } + SeNotice("Tried the current directory"); - return NULL; + return NULL; } /* - * another implementation of the above using varargs, currently not used - */ - -/*FILE *open_file_va(args) - va_list args; - va_decl -{ - FILE *fp; - char *name, *dir, fullname[REG_BUF]; - char buffer[REG_BUF]; - - va_start(args); - name = va_arg(args, char *); - - if (fp = fopen(name, "r")) - return fp; - - while(dir = va_arg(args, char *)) - { - sprintf(fullname, "%s/%s", expand_fname(SSpc(dir), buffer), name); - - if (fp = fopen(fullname, "r")) - return fp; - } - - va_end(args); - - if (dir = (char *) getenv("HOME")) { - sprintf(fullname, "%s/%s", dir, name); - - if (fp = fopen(fullname, "r")) - return fp; - } - - showf("<< Seyon: file '%s' not in current, default, or home directory >>", - name, "", ""); - return NULL; -}*/ - -/* * read a file into a buffer */ void read_file(fp, line) - FILE *fp; - char *line[]; + FILE *fp; + char *line[]; { - char buffer[REG_BUF + 1]; - int i; + char buffer[REG_BUF + 1]; + int i; - for (i = 0; i < MAX_ENT && fgets(buffer, REG_BUF, fp) != NULL; i++) - line[i] = strcpy((char *)malloc(sizeof(buffer)), SSpc(buffer)); - line[i] = NULL; + for (i = 0; i < MAX_ENT && fgets(buffer, REG_BUF, fp) != NULL; i++) + line[i] = strcpy((char *)malloc(sizeof(buffer)), SSpc(buffer)); + line[i] = NULL; } /* - * similar to the above, but closes the file after readsing it + * similar to the above, but closes the file after reading it */ void read_close_file(fp, line) - FILE *fp; - char *line[]; + FILE *fp; + char *line[]; { - read_file(fp, line); - fclose(fp); + read_file(fp, line); + fclose(fp); } /* @@ -487,12 +439,12 @@ void write_pipe_data(pd, data, size) - int *pd; - char *data; - int size; + int *pd; + char *data; + int size; { - if (write(pd[1], data, size) < 0) - show("<< Could not write to pipe >>"); + if (write(pd[1], data, size) < 0) + show("<< Could not write to pipe >>"); } /* @@ -501,11 +453,11 @@ void read_pipe_data(pd, data, size) - int *pd; - char *data; - int size; + int *pd; + char *data; + int size; { - read(pd[0], data, size); + read(pd[0], data, size); } /* @@ -515,30 +467,30 @@ void IdleGuard() { - struct stat statBuf; - time_t idleTime; - static time_t totalIdleTime; - int timeToNextCall; - - if (qres.idleGuard && !inhibit_child) { - if (fstat(tfd, &statBuf) < 0) { - SePError("/IG/ Could not stat the tty"); - return; - } + struct stat statBuf; + time_t idleTime; + static time_t totalIdleTime; + int timeToNextCall; + + if (qres.idleGuard && !inhibit_child) { + if (fstat(tfd, &statBuf) < 0) { + SePError("/IG/ Could not stat the tty"); + return; + } + + if ((idleTime = time((time_t *) 0) - statBuf.st_mtime) >= + qres.idleGuardInterval * 0.99) { + MdmPutString(qres.idleGuardString); + timeToNextCall = qres.idleGuardInterval; + totalIdleTime += idleTime; + SeyonMessagef("Idle for %d minutes", (totalIdleTime + 30) / 60); + } + else { + timeToNextCall = qres.idleGuardInterval - (int)idleTime; + totalIdleTime = 0; + } - if ((idleTime = time((time_t *) 0) - statBuf.st_mtime) >= - qres.idleGuardInterval * 0.99) { - MdmPutString(qres.idleGuardString); - timeToNextCall = qres.idleGuardInterval; - totalIdleTime += idleTime; - SeyonMessagef("Idle for %d minutes", (totalIdleTime + 30) / 60); - } - else { - timeToNextCall = qres.idleGuardInterval - (int)idleTime; - totalIdleTime = 0; - } - - XtAppAddTimeOut(app_con, timeToNextCall * 1000, + XtAppAddTimeOut(app_con, timeToNextCall * 1000, (XtTimerCallbackProc) IdleGuard, (XtPointer) app_con); - } + } } --- a/SeSubsX.c +++ b/SeSubsX.c @@ -70,7 +70,8 @@ if (onlineTime != oldOnlineTime) { oldOnlineTime = onlineTime; - sprintf(buf, "%02d:%02d", onlineTime / 60, onlineTime % 60); + /* Buffer is easily big enough */ + sprintf(buf, "%02ld:%02ld", onlineTime / 60, onlineTime % 60); SeSetLabel(statusWidget[0], buf); } @@ -91,6 +92,7 @@ msg = qres.funMessages[msg_index++]; if (msg == NULL) { msg_index = 0; + /* Buffer is easily big enough */ sprintf(vermsg, "Welcome to Seyon version %s.%s", VERSION, REVISION); msg = vermsg; } @@ -171,7 +173,8 @@ procRequest.action = action; - if (msg) strcpy(procRequest.msg, msg); + if (msg) + strncpy(procRequest.msg, msg, 80); else *procRequest.msg = '\0'; write_pipe_data(pd, &procRequest, sizeof(procRequest)); @@ -186,8 +189,8 @@ struct _procRequest procRequest; procRequest.action = action; - strcpy(procRequest.msg, msg); - strcpy(procRequest.arg, arg); + strncpy(procRequest.msg, msg, 80); + strncpy(procRequest.arg, arg, 90); write_pipe_data(child_pipe, &procRequest, sizeof(procRequest)); } @@ -201,10 +204,7 @@ *b, *c; { - char buffer[SM_BUF]; - - sprintf(buffer, fmt, a, b, c); - write_child_info(pd, action, buffer); + write_child_info(pd, action, FmtString(fmt,a,b,c)); } void @@ -222,10 +222,7 @@ b, c; { - char buf[REG_BUF]; - - sprintf(buf, fmt, a, b, c); - SeyonMessage(buf); + SeyonMessage(FmtString(fmt,a,b,c)); } Boolean --- a/SeTerm.c +++ b/SeTerm.c @@ -10,7 +10,7 @@ * This file contains routines for Seyon's terminal. The main routine is * terminal(), which reads characters from the terminal and sends them to the * port. That routine also forks a child process that reads characters from - * the port and writes them to the temrinal. Once the parent receives SIGTERM + * the port and writes them to the terminal. Once the parent receives SIGTERM * (which should be sent by the grand parent), it kills the child and exits. */ --- a/SeTrans.c +++ b/SeTrans.c @@ -51,7 +51,7 @@ ErrorIfBusy(); if (disItems[0] == NULL) { - strcpy(protocolsFile, qres.protocolsFile); + strncpy(protocolsFile, qres.protocolsFile, REG_BUF); if (ReadParseProtFile(protocolsFile, disItems) < 0) return; } @@ -81,39 +81,47 @@ void DoTransfer(widget, clientData, callData) - Widget widget; - XtPointer clientData, - callData; + Widget widget; + XtPointer clientData, + callData; { - XfwfMultiListReturnStruct *item; - Widget popup; - String* actionData = (String*)clientData; - char fullCommand[LRG_BUF]; - - if (clientData) - {if ((transCurItemIndex = atoi(actionData[0]) - 1) < 0 || - transCurItemIndex > MAX_ENT - 1) - SimpleError("Invalid Entry Number");} - else { - if ((item = XfwfMultiListGetHighlighted(mlw))->num_selected == 0) + XfwfMultiListReturnStruct *item; + Widget popup; + String* actionData = (String*)clientData; + char fullCommand[LRG_BUF]; + int length_remaining; + + if (clientData) + {if ((transCurItemIndex = atoi(actionData[0]) - 1) < 0 || + transCurItemIndex > MAX_ENT - 1) + SimpleError("Invalid Entry Number");} + else { + if ((item = XfwfMultiListGetHighlighted(mlw))->num_selected == 0) SimpleError("No Item Selected"); - transCurItemIndex = item->selected_items[0]; - } + transCurItemIndex = item->selected_items[0]; + } - strcpy(fullCommand, protItems[transCurItemIndex]->command); + strncpy(fullCommand, protItems[transCurItemIndex]->command, LRG_BUF); - if (protItems[transCurItemIndex]->reqName) - if (actionData == NULL || actionData[1] == NULL) { + if (protItems[transCurItemIndex]->reqName) + { + if (actionData == NULL || actionData[1] == NULL) + { popup = GetShell(PopupDialogGetValue("upload", widget, exec_upload, - NULL, lastUploadFile)); + NULL, lastUploadFile)); PopupCentered(popup, (clientData) ? XtParent(GetShell(widget)) : widget); return; - } - else - strcat(strcat(fullCommand, " "), actionData[1]); - - DestroyShell(widget); - ShellCommand(fullCommand); + } + else + { + length_remaining = LRG_BUF - strlen(fullCommand); + strncat(fullCommand, " ", length_remaining); + length_remaining -= 1; + strncat(fullCommand, actionData[1], length_remaining); + } + } + DestroyShell(widget); + ShellCommand(fullCommand); } void @@ -133,11 +141,11 @@ Widget widget; { Widget dialog = XtParent(widget); - static char cmd[REG_BUF]; + static char *cmd; - strcpy(lastUploadFile, XawDialogGetValueString(dialog)); - sprintf(cmd, "%s %s", protItems[transCurItemIndex]->command, - lastUploadFile); + strncpy(lastUploadFile, XawDialogGetValueString(dialog), REG_BUF); + cmd = FmtString("%s %s", protItems[transCurItemIndex]->command, + lastUploadFile, ""); DestroyShell(XtParent(GetShell(widget))); ShellCommand(cmd); --- a/SeWin.c +++ b/SeWin.c @@ -377,7 +377,7 @@ { Widget dialog = XtParent(valueWidget); - strcpy(getValueDefValue, XawDialogGetValueString(dialog)); + strncpy(getValueDefValue, XawDialogGetValueString(dialog), REG_BUF); DestroyShell(dialog); (*getValueExecProc)(XtParent(GetShell(valueWidget)), getValueDefValue); @@ -745,10 +745,7 @@ b, c; { - char buf[REG_BUF]; - - sprintf(buf, fmt, a, b, c); - SePopupMsg(parent, buf); + SePopupMsg(parent, FmtString(fmt,a,b,c)); } Widget @@ -773,20 +770,16 @@ } void -SePopupNoticeF(parent, title, call_back, fmt, a, b, c, d) +SePopupNoticeF(parent, title, call_back, fmt, a, b, c) Widget parent; String title; void (*call_back) (); String fmt, a, b, - c, - d; + c; { - char buf[REG_BUF]; - - sprintf(buf, fmt, a, b, c); - SePopupNotice(parent, title, call_back, buf); + SePopupNotice(parent, title, call_back, FmtString(fmt,a,b,c)); } /* @@ -918,10 +911,7 @@ b, c; { - char buffer[REG_BUF]; - - sprintf(buffer, fmt, a, b, c); - SetStatusMessage(buffer); + SetStatusMessage(FmtString(fmt,a,b,c)); } /*---------------------------------------------------------------------------+ --- a/Seyon.ad +++ b/Seyon.ad @@ -7,6 +7,8 @@ ! * statement of rights and permissions for this program. ! * +#include "/etc/X11/seyon/Seyon-modem" + *.title: Seyon Command Center *.iconName: Seyon @@ -259,31 +261,6 @@ *statusBox.rng.label: RNG ! -! Quick Keys -! - -*quickKeyBox.Command.font: 6x10 - -*quickKey1.visible: on -*quickKey2.visible: on -*quickKey3.visible: on -*quickKey4.visible: on -*quickKey5.visible: on - -!*quickKey1.action: DialEntries(1); -!*quickKey2.action: DialEntries(3); -!*quickKey3.action: FileTransfer(2, ou*); -!*quickKey4.action: DivertFile(/tmp/lo); -!*quickKey5.action: Hangup(); Beep(); -!RunScript(test1); Echo(ll); - -*quickKey1.label: Athena -*quickKey2.label: Ch1 -*quickKey3.label: UpMail -*quickKey4.label: DivMsg -*quickKey5.label: Local - -! ! Fun messages. Send me more please. ! @@ -302,6 +279,7 @@ "Have something funny? send it!" \ "I've fallen and I can't get up!" ++*showFunMessages: off *notImplemented*title: Seyon Feature *notImplemented.dialog.label: \ This feature is not yet implemented\n\ --- a/Seyon.c +++ b/Seyon.c @@ -72,314 +72,365 @@ pid_t mainPid; int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { - int OpenModem(); - void DispatchActions(), - GetParameters(), - ShowOpenModemErrMsg(); - - char *arg[REG_BUF], termEmu[REG_BUF]; - int sepIndex, i, n, retStatus; + int OpenModem(); + void DispatchActions(), + GetParameters(), + ShowOpenModemErrMsg(); + + char *arg[REG_BUF], + termEmu[REG_BUF]; + int sepIndex, + i, + n, + length, + retStatus; #ifdef HAVE_FAS - char large_string[1024]; + char large_string[LRG_BUF]; #endif - XtAppContext appContext; - char modemList[LRG_BUF], - *curModem, - *startupAction = modemList; + int length_remaining; + XtAppContext appContext; + char modemList[LRG_BUF], + *curModem, + *startupAction = modemList; - static char *fallbackResources[] = { + static char *fallbackResources[] = { #include "Seyon.ad.h" - NULL, - }; + NULL, + }; - static XrmOptionDescRec optionList[] = { - {"-modems", "modems", XrmoptionSepArg, NULL}, - {"-script", "script", XrmoptionSepArg, NULL}, - {"-entries", "defaultPhoneEntries", XrmoptionSepArg, NULL}, - {"-dial", "dialAutoStart", XrmoptionNoArg, "True"}, - {"-nodial", "dialAutoStart", XrmoptionNoArg, "False"}, - {"-emulator", "emulator", XrmoptionSepArg, ""}, - {"-noemulator", "noemulator", XrmoptionNoArg, ""}, - {"-nodefargs", "nodefargs", XrmoptionNoArg, ""}, - }; + static XrmOptionDescRec optionList[] = { + {"-modems", "modems", XrmoptionSepArg, NULL}, + {"-script", "script", XrmoptionSepArg, NULL}, + {"-entries", "defaultPhoneEntries", XrmoptionSepArg, NULL}, + {"-dial", "dialAutoStart", XrmoptionNoArg, "True"}, + {"-nodial", "dialAutoStart", XrmoptionNoArg, "False"}, + {"-emulator", "emulator", XrmoptionSepArg, ""}, + {"-noemulator", "noemulator", XrmoptionNoArg, ""}, + {"-nodefargs", "nodefargs", XrmoptionNoArg, ""}, + }; - for (i = 1; i < argc && strcmp(argv[i], "--"); i++); - sepIndex = i; + for (i = 1; i < argc && strcmp(argv[i], "--"); i++); + sepIndex = i; - /* Find if the -noemulator switch is given */ - for (i = 1; i < sepIndex && + /* Find if the -noemulator switch is given */ + for (i = 1; i < sepIndex && strncmp(argv[i], "-noemulator", max(4, strlen(argv[i]))); i++); - /* If no, launch Seyon via the emulator */ - if (i >= sepIndex) { + /* If no, launch Seyon via the emulator */ + if (i >= sepIndex) { - for (i = 1; i < sepIndex && - strncmp(argv[i], "-emulator", max(3, strlen(argv[i]))); i++); - if (i < sepIndex - 1) - strcpy(termEmu, argv[i+1]); - else - strcpy(termEmu, SEYON_EMU_NAME); - - /* Find if the -nodefargs switch is given */ - for (i = 1; i < sepIndex && - strncmp(argv[i], "-nodefargs", max(5, strlen(argv[i]))); i++); + for (i = 1; i < sepIndex && + strncmp(argv[i], "-emulator", max(3, strlen(argv[i]))); i++); + if (i < sepIndex - 1) + strncpy(termEmu, argv[i+1], REG_BUF); + else + strncpy(termEmu, SEYON_EMU_NAME, REG_BUF); + + /* Find if the -nodefargs switch is given */ + for (i = 1; i < sepIndex && + strncmp(argv[i], "-nodefargs", max(5, strlen(argv[i]))); i++); - n = 1; + n = 1; - /* If no, use the default emulator arguments */ - if (i >= sepIndex) { + /* If no, use the default emulator arguments */ + if (i >= sepIndex) { arg[n] = "-name"; n++; arg[n] = "Seyon"; n++; arg[n] = "-T"; n++; arg[n] = "Seyon Terminal Emulator"; n++; arg[n] = "-n"; n++; arg[n] = "Terminal"; n++; - } + } - /* Pass all switches aftetr '--' to the emulator */ - for (i = sepIndex + 1; i < argc; i++, n++) + /* Pass all switches aftetr '--' to the emulator */ + for (i = sepIndex + 1; i < argc; i++, n++) arg[n] = argv[i]; - arg[n] = "-e"; n++; + arg[n] = "-e"; n++; #ifndef HAVE_FAS - arg[n] = argv[0]; n++; - arg[n] = "-noemulator"; n++; + arg[n] = argv[0]; n++; + arg[n] = "-noemulator"; n++; - /* Pass all switches before '--' to Seyon */ - for (i = 1; i < sepIndex; i++, n++) + /* Pass all switches before '--' to Seyon */ + for (i = 1; i < sepIndex; i++, n++) arg[n] = argv[i]; #else - arg[n] = "/bin/sh"; n++; - arg[n] = "-c"; n++; - arg[n] = large_string; - strcpy(arg[n], argv[0]); - strcat(arg[n], " -noemulator"); - for (i = 1; i < sepIndex; i++) { - strcat(arg[n]," "); - strcat(arg[n],argv[i]); - } - n++; + arg[n] = "/bin/sh"; n++; + arg[n] = "-c"; n++; + arg[n] = large_string; + length_remaining = LRG_BUF; + strncpy(arg[n], argv[0], LRG_BUF); + length_remaining -= strlen(argv[0]); + length = strlen(" -noemulator"); + if(length_remaining > length) + { + strncat(arg[n], " -noemulator", length_remaining); + length_remaining -= length; + } + else + { + printf("String overflow in parsing options\n"); + exit (1); + } + for (i = 1; i < sepIndex; i++) { + length = strlen(argv[i]) + 1; + if(length_remaining > length) + { + strncat(arg[n]," ", 1); + strncat(arg[n],argv[i], length_remaining); + } + else + { + printf("String overflow in parsing options\n"); + exit (1); + } + } + n++; #endif - arg[n] = NULL; n++; + arg[n] = NULL; n++; - arg[0] = termEmu; - execvp(arg[0], arg); + arg[0] = termEmu; + execvp(arg[0], arg); - fprintf(stderr, "%s `%s.\n%s\n", ">> Warning: Could not execute", - termEmu, ">> Notice: Falling to `xterm'."); + fprintf(stderr, "%s `%s.\n%s\n", ">> Warning: Could not execute", + termEmu, ">> Notice: Falling to `xterm'."); - arg[0] = "xterm"; - execvp(arg[0], arg); + arg[0] = "xterm"; + execvp(arg[0], arg); - fprintf(stderr, "%s\n%s\n", ">> Error: Could not execute `xterm'.", - ">> Notice: Giving up."); - exit(1); - } /* if (i >= sepIndex)... */ - - /* ---------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- */ - - /* The real program begins here */ - - topLevel = XtAppInitialize(&appContext, "Seyon", optionList, - XtNumber(optionList), &argc, argv, - fallbackResources, NULL, 0); - app_con = appContext; - GetResources(topLevel); - - mainPid = getpid(); - setup_signal_handlers(); - SetIcon(topLevel); - - printf("\r\n%s %s\r\n", "Seyon Copyright (c) 1992-1993 Muhammad M. Saggaf.", - "All rights reserved."); - printf("\rVersion %s rev. %s %s-%s %s@%s %s %s.\r\n\n", VERSION, REVISION, - COMPILE_HOSTTYPE, COMPILE_OSNAME, COMPILE_BY, COMPILE_HOST, - COMPILE_DATE, COMPILE_TIME); - - if ((tfp = fopen("/dev/tty", "r+")) == NULL) { - PopupInitError("errTtyAccess", exit); - goto MainLoop; - } + fprintf(stderr, "%s\n%s\n", ">> Error: Could not execute `xterm'.", + ">> Notice: Giving up."); + exit(1); + } /* if (i >= sepIndex)... */ + + /* ------------------------------------------------------------------ */ + /* ------------------------------------------------------------------ */ + + /* The real program begins here */ + + topLevel = XtAppInitialize(&appContext, "Seyon", optionList, + XtNumber(optionList), &argc, argv, + fallbackResources, NULL, 0); + app_con = appContext; + GetResources(topLevel); + + mainPid = getpid(); + setup_signal_handlers(); + SetIcon(topLevel); + + printf("\r\n%s %s\r\n", "Seyon Copyright (c) 1992-1993 Muhammad M. Saggaf.", + "All rights reserved."); + printf("\rVersion %s rev. %s %s-%s %s@%s %s %s.\r\n\n", VERSION, REVISION, + COMPILE_HOSTTYPE, COMPILE_OSNAME, COMPILE_BY, COMPILE_HOST, + COMPILE_DATE, COMPILE_TIME); + + if ((tfp = fopen("/dev/tty", "r+")) == NULL) { + PopupInitError("errTtyAccess", exit); + goto MainLoop; + } - tfd = fileno(tfp); + tfd = fileno(tfp); - io_get_attr(tfd, &oldmode); /* get current console tty mode */ - newmode = oldmode; /* copy (structure) to newmode */ + io_get_attr(tfd, &oldmode); /* get current console tty mode */ + newmode = oldmode; /* copy (structure) to newmode */ #if HAVE_TERMIOS || HAVE_TERMIO - newmode.c_oflag &= ~OPOST; - newmode.c_iflag |= (IGNBRK | IGNPAR); - newmode.c_iflag &= ~(IXON | IXOFF | ISTRIP | BRKINT); - newmode.c_lflag &= ~(ICANON | ISIG | ECHO); - newmode.c_cflag |= CREAD; - newmode.c_cc[VMIN] = 1; - newmode.c_cc[VTIME] = 1; + newmode.c_oflag &= ~OPOST; + newmode.c_iflag |= (IGNBRK | IGNPAR); + newmode.c_iflag &= ~(IXON | IXOFF | ISTRIP | BRKINT); + newmode.c_lflag &= ~(ICANON | ISIG | ECHO); + newmode.c_cflag |= CREAD; + newmode.c_cc[VMIN] = 1; + newmode.c_cc[VTIME] = 1; #else #if HAVE_SGTTYB - newmode.sg_flags = CBREAK; + newmode.sg_flags = CBREAK; #endif #endif - set_tty_mode(); + set_tty_mode(); - InitVariables(topLevel); + InitVariables(topLevel); - if (argc > 1 && strcmp(argv[1], "--")) { - SeErrorF("Unknown or incomplete command-line switch: `%s'", argv[1], - "", ""); - PopupInitError("errSwitches", do_exit); - goto MainLoop; - } + if (argc > 1 && strcmp(argv[1], "--")) { + SeErrorF("Unknown or incomplete command-line switch: `%s'", argv[1], + "", ""); + PopupInitError("errSwitches", do_exit); + goto MainLoop; + } - /* ---------------------------------------------------------------------- */ + /* ------------------------------------------------------------------- */ - /* Open modem port and configure it */ + /* Open modem port and configure it */ - strcpy(modemList, qres.modems); - curModem = GetFirstWord(modemList); + strncpy(modemList, qres.modems, LRG_BUF); + curModem = GetFirstWord(modemList); - show("Locating Modems..."); + show("Locating Modems..."); - do { - if ((retStatus = OpenModem(curModem)) >= 0) break; + do { + if ((retStatus = OpenModem(curModem)) >= 0) break; - ShowOpenModemErrMsg(curModem, retStatus); - if (retStatus != ERR_MDM_NOMODEM) + ShowOpenModemErrMsg(curModem, retStatus); + if (retStatus != ERR_MDM_NOMODEM) show(FmtString("Modem `%s' is Unavailable.\n", curModem, "", "")); - curModem = GetNextWord(); - } while (curModem[0] != '\0'); - - if (retStatus < 0) { - SeError("No Modems Available"); - PopupInitError("errModemInit", do_exit); - goto MainLoop; - } - - show(FmtString("Modem `%s' is Available.\n", curModem, "", "")); - - /* ---------------------------------------------------------------------- */ - - CreateCommandCenter(); - - /* ---------------------------------------------------------------------- */ + curModem = GetNextWord(); + } while (curModem[0] != '\0'); - pipe(child_pipe); - pipe(scriptToMainPipe); - pipe(mainToTermPipe); - XtAppAddInput(appContext, child_pipe[0], (XtPointer)XtInputReadMask, - ExecProcRequest, NULL); - XtAppAddInput(appContext, scriptToMainPipe[0], (XtPointer)XtInputReadMask, - GetParameters, NULL); + if (retStatus < 0) { + SeError("No Modems Available"); + PopupInitError("errModemInit", do_exit); + goto MainLoop; + } + + show(FmtString("Modem `%s' is Available.\n", curModem, "", "")); + + /* ------------------------------------------------------------------- */ + + CreateCommandCenter(); + + /* ------------------------------------------------------------------- */ + + pipe(child_pipe); + pipe(scriptToMainPipe); + pipe(mainToTermPipe); + XtAppAddInput(appContext, child_pipe[0], (XtPointer)XtInputReadMask, + ExecProcRequest, NULL); + XtAppAddInput(appContext, scriptToMainPipe[0], (XtPointer)XtInputReadMask, + GetParameters, NULL); + + IdleGuard(); + if (qres.showFunMessages) + XtAppAddTimeOut(appContext, qres.funMessagesInterval*1000, + FunMessage, NULL); + + /* ------------------------------------------------------------------- */ + + length_remaining = LRG_BUF; + strncpy(startupAction, qres.startupAction, LRG_BUF); + length_remaining -= strlen(startupAction); + if (qres.script) + { + length = strlen(" RunScript();") + strlen(qres.script); + if (length_remaining > length) + { + sprintf(startupAction + strlen(startupAction), + " RunScript(%s);", qres.script); + length_remaining -= length; + } + else + { + printf("String overflow in parsing options\n"); + exit (1); + } + } + if (qres.dialAutoStart) + { + length = strlen(" DialEntries(Default);"); + if(length_remaining > length) + { + strncat(startupAction, " DialEntries(Default);", length); + length -= length; + } + else + { + printf("String overflow in parsing options\n"); + exit (1); + } + } + + /* ------------------------------------------------------------------- */ - IdleGuard(); - if (qres.showFunMessages) XtAppAddTimeOut(appContext, - qres.funMessagesInterval*1000, FunMessage, NULL); + linkflag = 2; + ProcRequest(DISPATCH_ACTION, "", startupAction); - /* ---------------------------------------------------------------------- */ + /* ------------------------------------------------------------------- */ - strcpy(startupAction, qres.startupAction); - if (qres.script) sprintf(startupAction + strlen(startupAction), - " RunScript(%s);", qres.script); - if (qres.dialAutoStart) strcat(startupAction, " DialEntries(Default);"); - - /* ---------------------------------------------------------------------- */ - - linkflag = 2; - ProcRequest(DISPATCH_ACTION, "", startupAction); - - /* ---------------------------------------------------------------------- */ - - XtSetMappedWhenManaged(topLevel, True); - XtMapWidget(topLevel); /* I don't know why I need this, but I do */ + XtSetMappedWhenManaged(topLevel, True); + XtMapWidget(topLevel); /* I don't know why I need this, but I do */ MainLoop: - XtAppMainLoop(app_con); - return 0; + XtAppMainLoop(app_con); + return 0; } void -setup_signal_handlers() +setup_signal_handlers(void) { - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); #ifdef SIGBUS - signal(SIGBUS, die); + signal(SIGBUS, die); #endif - signal(SIGFPE, die); - signal(SIGILL, die); - signal(SIGIOT, die); - signal(SIGSEGV, die); - signal(SIGTERM, die); - signal(SIGTRAP, die); + signal(SIGFPE, die); + signal(SIGILL, die); + signal(SIGIOT, die); + signal(SIGSEGV, die); + signal(SIGTERM, die); + signal(SIGTRAP, die); } void -die(sig) - int sig; +die(int sig) { - void KillChildProc(); - signal(sig, SIG_IGN); + void KillChildProc(); + signal(sig, SIG_IGN); - SeErrorF("Killed by signal %d", sig, "", ""); - SeNoticeF("Debugging info: pid=%d.", getpid(), "", ""); + SeErrorF("Killed by signal %d", sig, "", ""); + SeNoticeF("Debugging info: pid=%d.", getpid(), "", ""); - if (getpid() == mainPid) { - KillTerminal(); - KillChildProc(); + if (getpid() == mainPid) { + KillTerminal(); + KillChildProc(); - SeNotice("Press any key to exit"); - getchar(); - cleanup_exit(1); - } - else { - write_child_info(child_pipe, KILL_TERM, "Terminal Proc Exited"); - exit(1); - } + SeNotice("Press any key to exit"); + getchar(); + cleanup_exit(1); + } + else { + write_child_info(child_pipe, KILL_TERM, "Terminal Proc Exited"); + exit(1); + } } void -do_exit(rc) - int rc; +do_exit(int rc) { - void KillChildProc(); + void KillChildProc(); - XtUnmapWidget(topLevel); - KillTerminal(); - KillChildProc(); + XtUnmapWidget(topLevel); + KillTerminal(); + KillChildProc(); - unlock_tty(); + unlock_tty(); - fflush(tfp); - restore_orig_mode(); - fclose(tfp); + fflush(tfp); + restore_orig_mode(); + fclose(tfp); - CloseModem(); + CloseModem(); - XtDestroyApplicationContext(XtWidgetToApplicationContext(topLevel)); + XtDestroyApplicationContext(XtWidgetToApplicationContext(topLevel)); /* XCloseDisplay(XtDisplay(topLevel));*/ - exit(rc); + exit(rc); } void -cleanup_exit(status) - int status; +cleanup_exit(int status) { - SeNotice("cleaning up.."); - do_exit(status); + SeNotice("cleaning up.."); + do_exit(status); } void s_exit() { - show("I'm rated PG-34!!"); - do_exit(0); + show("I'm rated PG-34!!"); + do_exit(0); } --- a/Seyon-co.ad +++ b/Seyon-co.ad @@ -13,26 +13,30 @@ *foreground: black *borderColor: white +*background: blue +*foreground: black +*borderColor: lightBlue + *Command.background: lightBlue -*Scrollbar.background: darkSeaGreen -*Toggle.background: darkOliveGreen -*Toggle.foreground: darkTurquoise -*List.background: grey -*XfwfMultiList.background: grey -*Text*background: grey -*Text*Scrollbar.background: darkSeaGreen +*Scrollbar.background: cyan +*Toggle.background: cyan +*Toggle.foreground: black +*List.background: tan +*XfwfMultiList.background: tan +*Text*background: tan +*Text*Scrollbar.background: cyan *ok.background: green -*cancel.background: tomato +*cancel.background: red *dismiss.background: orange -*hangup.background: orange -*exit.background: tomato -*kill.background: tomato +*hangup.background: red +*exit.background: red +*kill.background: red -*about*msg.background: grey -*about*pic.background: grey +*about*msg.background: tan +*about*pic.background: tan -*messageBox.message.background: grey +*messageBox.message.background: tan -*quickKeyBox.Command.background: darkOliveGreen -*quickKeyBox.Command.foreground: darkTurquoise +*quickKeyBox.Command.background: orange +*quickKeyBox.Command.foreground: black --- a/startup +++ b/startup @@ -4,30 +4,30 @@ # see the manual page for a complete listing of the keywords # that can be used with 'set'. -# set baud 9600 +set baud 57600 # can be 5, 6, 7, or 8 -# set bits 8 +set bits 8 # can be 0 (= no parity), 1 (= odd parity), or 2 (= even parity) # set parity 0 # can be 1 or 2 -# set stopBits 1 +set stopBits 1 # can be nl, cr, or cr/lf # set newlineTranslation cr -# set del on -# set meta_tr on -# set xoff off -# set rtscts on -# set autozm on +set del on +set meta_tr on +set xoff off +set rtscts on +set autozm on # set idleGuard on # put the modem initialization string here if you like one. # most modern modems do not need it since they store their setup in # non-volatile memory. -# echo "Initializing modem..." -# transmit "ATZ^M" +echo "Initializing modem..." +transmit "ATM0^M"