home *** CD-ROM | disk | FTP | other *** search
- #include "defs.h"
- #include "headers.h"
-
- #include <stdarg.h>
- #include <sys/types.h>
- #include <sys/stat.h>
-
- #ifdef LATTICE
- #ifndef __SASC
- #define __SASC
- #endif
- #endif
-
- #ifdef __SASC
- #include <sys/types.h>
- #endif
-
- // #define PROCDEBUG
-
- #ifdef PROCDEBUG
- #define D(x) printf x
- #else
- #define D(x)
- #endif
-
- // EXPORTS
-
- void CloseLibs (LIBDEFS libDefs[]);
- void OpenLibs (LIBDEFS libDefs[]);
- GADGET *CreateGadgets(GADGET *gadArray[], GADDEF gadDefs[]);
- short TextLen (RPORT *rp, char *txt);
- void InitSystem (void);
- void CloseSystem (void);
- WINDOW *CreateWindow(GADGET *gList, short left, short top, short width,
- short height, char *title);
- void DefaultIDCMPFunc (WINDOW *window, IMSG *m);
- int OutputStrings (const int fd, const char *str, ...);
- int Editor (const char *filename, const char *editor);
- char *TempName (void);
- int CopyStrings (char *dest, const char *str, ...);
- char *itoa (const long i);
- void PostNews (const int followupFlag, const char *filename);
- void SendMail (const char *filename);
-
- char prefFontName [128] = "grn.font"; // name of preference font (defaults to grn.font)
- UWORD prefFontSize = 8; // defaults to 8
- UWORD prefWidth = 640, prefHeight = 400; // 640x400 or whatever is in tooltypes
- UWORD prefTop = 0, prefLeft = 0; // defaults to top right edge of screen!
-
- /*
- * List of libraries used
- */
- IBASE *IntuitionBase = 0;
- LIBRARY *GfxBase = 0;
- LIBRARY *DiskfontBase = 0;
- LIBRARY *AslBase = 0;
- LIBRARY *GadToolsBase = 0;
- LIBRARY *WorkbenchBase = 0;
- LIBRARY *IconBase = 0;
- LIBRARY *CxBase = 0;
-
- /*
- * Array of library names/base pointers. To open an additional library, define
- * the base above and add a line here.
- */
- LIBDEFS libDefs[] = {
- "intuition.library", (APTR *) &IntuitionBase,
- "graphics.library", (APTR *) &GfxBase,
- "diskfont.library", (APTR *) &DiskfontBase,
- "asl.library", (APTR *) &AslBase,
- "gadtools.library", (APTR *) &GadToolsBase,
- "workbench.library", (APTR *) &WorkbenchBase,
- "icon.library", (APTR *) &IconBase,
- "commodities.library", (APTR *) &CxBase,
- 0, 0
- };
-
- /*
- * Global variables
- */
- VINFO *vi = 0;
- SCREEN *screen = 0;
- VPORT *vp;
- RPORT *rp;
-
- RPORT topazRastPort, *topazRP = &topazRastPort;
-
- BOOL customScreenFlag = 0;
-
- /*
- * This text attribute is the default text attribute used for various
- * features. It should be openable via OpenFont(), which implies an
- * OpenDiskFont() call to load it into memory. In this case, defaultFontAttr
- * is a ROM font, so I don't bother. BEWARE if you choose another !!!
- */
- TATTR topaz80 = { "topaz.font", 8, 0, 0 };
- TATTR defaultFontAttr = { "grn.font", 8, 0, 0 };
- FONT *defaultFont = 0, *topaz80Font = 0;
-
- /*
- * Without this look3D array passed to the OpenScreenTags() call, you
- * don't get the 3D effect. Why this isn't the default, only CBM knows :)
- */
- UWORD look3D[] = { ~0, };
-
- /*
- * This rect structure contains the overscan info for what size the screen
- * should be!
- */
- RECT oscanRect;
- short screenWidth, screenHeight; /* computed width and height of screen */
- short screenTop; /* computed below title bar */
-
- /************************************************************************/
-
- /*
- * These might be the shortest open/close library routines ever :)
- */
- void CloseLibs (LIBDEFS libDefs[])
- {
- short i;
-
- for (i = 0; libDefs [i+1].name; i++)
- ;
- while (i >= 0) {
- if (*libDefs [i].base)
- CloseLibrary ((LIBRARY *)*libDefs [i].base);
- *libDefs [i--].base = 0;
- }
- return;
- }
-
- void OpenLibs (LIBDEFS libDefs[])
- {
- short i;
-
- for (i = 0; libDefs [i].name; i++) {
- *libDefs [i].base = (APTR) OpenLibrary (libDefs [i].name, 0);
- panic0 (*libDefs [i].base, "Can't open %s", libDefs [i].name);
- }
- return;
- }
-
- /************************************************************************/
-
- /*
- * gadgetList = CreateGadgets(gadDefs);
- * GADGET *gadgetList; list of created gadgets
- * GADDEF gadDefs[]; array of gadget initializations
- *
- * Synopsis:
- * Pass in a gadDefs, and you get an initialized list of gadgets,
- * suitable for linking to a window for GadTools.
- */
- GADGET *CreateGadgets (GADGET *gadArray[], GADDEF gadDefs[])
- {
- GADGET *gadget, *glist = 0;
- int i;
- int kind;
- NEWGAD ng;
-
- gadget = CreateContext (&glist);
- panic0 (gadget, "Can't CreateContext");
- for (i = 0; gadDefs [i].tags; i++) {
- if ((kind = gadDefs [i].kind) != LISTVIEW_KIND)
- ng.ng_TextAttr = &topaz80;
- else
- ng.ng_TextAttr = &defaultFontAttr;
- ng.ng_GadgetID = i;
- ng.ng_VisualInfo = vi;
- ng.ng_LeftEdge = gadDefs [i].left;
- ng.ng_TopEdge = gadDefs [i].top;
- ng.ng_Width = gadDefs [i].width;
- ng.ng_Height = gadDefs [i].height;
- ng.ng_GadgetText = gadDefs [i].text;
- ng.ng_Flags = gadDefs [i].flags;
- gadget = CreateGadgetA (kind, gadget, &ng, gadDefs [i].tags);
- gadArray [i] = gadget;
- panic0 (gadget, "Can't CreateGadget");
- }
- return glist;
- }
-
- /************************************************************************/
-
- short TextLen (RPORT *rp, char *txt)
- {
- if (!rp)
- return 0;
-
- return TextLength (rp, txt, strlen (txt));
- }
-
- static int
- _swrite (char *buf, size_t n1, size_t n2, char **sst)
- {
- size_t n;
-
- if (n1 == 1)
- n = n2;
- else if (n2 == 1)
- n = n1;
- else
- n = n1 * n2;
-
- #ifdef __SASC
- memcpy (*sst, buf, n);
- #else
- _slow_bcopy (buf, *sst, n);
- #endif
- *sst += n;
-
- return (int) n2;
- }
-
- /*
- * void t_printf(fmt, ...);
- * char *fmt;
- *
- * Synopsis:
- * Similar to printf, except the results end up at the end of the
- * "event" listview. Only 4 args supported to printf...
- */
- #ifdef __SASC
- void t_printf (WINDOW *win, const char *fmt, long arg1, long arg2, long arg3, long arg4) {
- #else
- void t_printf (WINDOW *win, const char *fmt, ...) {
- #endif
- static char buf [128];
- extern WINDOW *mainWindow;
- char *ptr = buf;
- va_list va;
-
- if (!win)
- return; // so it's safe to call us from a batch routine
- #ifdef __SASC
- sprintf (buf, fmt, arg1, arg2, arg3, arg4);
- #else
- // DICE or GCC
- va_start (va, fmt);
- _pfmt (fmt, va, _swrite, &ptr);
- *ptr = 0;
- #endif
- SetWindowTitles (win, buf, GRN_VERSION);
- va_end (va);
- return;
- }
-
- /************************************************************************/
-
- /*
- * void GadgetUp(m);
- * IMSG *m; ptr to IntuiMessage received
- *
- * Synopsis:
- * Handles Gadtools/Intuition GADGETUP events. For 2.0 and GadTools, the TAB and HELP
- * keys are special. This routine handles these events, also.
- *
- * NOTES:
- * STRINGA_ExitHelp is not defined in any of the headers I got with SAS 5.10a, so the
- * HELP feature doesn't work.
- */
- static void GadgetUp(void (*func)(), IMSG *m)
- {
- GADGET *gad = (GADGET *)m->IAddress;
-
- (*func)(gad->GadgetID, m->Code);
- }
-
- /*
- * void GadgetDown(m);
- * IMSG *m; ptr to IntuiMessage received
- *
- * Synopsis:
- * Handles Gadtools/Intuition GADGETDOWN events.
- */
- static void GadgetDown(void (*func)(), IMSG *m)
- {
- GADGET *gad = (GADGET *)m->IAddress;
-
- (*func)(gad->GadgetID, m->Code);
- }
-
- /*
- * void MouseMove(m);
- * IMSG *m; ptr to IntuiMessage received
- *
- * Synopsis:
- * Handles Gadtools/Intuition MOUSEMOVE events.
- */
- static void MouseMove(void (*func)(), IMSG *m)
- {
- GADGET *gad = (GADGET *)m->IAddress;
-
- (*func)(gad->GadgetID, m->Code);
- }
-
- /************************************************************************/
-
- void InitSystem (void)
- {
- ULONG modeID;
- extern int update_only_mode;
-
- OpenLibs (libDefs);
-
- if (update_only_mode)
- // don't need any of this
- return;
-
- defaultFontAttr.ta_Name = (STRPTR) prefFontName;
- defaultFontAttr.ta_YSize = prefFontSize;
-
- defaultFont = OpenDiskFont (&defaultFontAttr);
- panic0 (defaultFont, "Can't OpenDiskFont(%s)", prefFontName);
- topaz80Font = OpenDiskFont (&topaz80);
- panic0 (topaz80Font, "Can't open topaz80 font");
- InitRastPort (topazRP);
- SetFont (topazRP, topaz80Font);
-
- #ifdef MYKE_REMOVED_THIS
- From Peter Cherna!
-
- if ( wbscreen = LockPubScreen("Workbench") )
- {
- if ( ( modeID = GetVPModeID( &wbscreen->ViewPort ) ) != INVALID_ID )
- {
- if ( QueryOverscan( modeID, &rect, OSCAN_TEXT ) )
- {
- /* got it */
- }
- }
- UnlockPubScreen( NULL, wbscreen );
- }
- #endif
-
- screen = LockPubScreen(NULL);
- panic0(screen, "Can't lockpubscreen");
- if ((modeID = GetVPModeID( &screen->ViewPort)) == INVALID_ID) panic("Can'g GetVPModeID()");
- panic0 (QueryOverscan (modeID, &oscanRect, OSCAN_TEXT), "Can't QueryOverscan()");
- screenWidth = (oscanRect.MaxX - oscanRect.MinX + 1);
- screenHeight = (oscanRect.MaxY - oscanRect.MinY + 1);
-
- if (screenHeight < prefHeight || screenWidth < prefWidth) {
- UnlockPubScreen (NULL, screen);
-
- modeID = (prefHeight < 400) ? HIRES_KEY : HIRESLACE_KEY;
- panic0 (QueryOverscan (modeID, &oscanRect, OSCAN_TEXT), "Can't QueryOverScan()");
-
- screenWidth = (oscanRect.MaxX - oscanRect.MinX + 1);
- screenHeight = (oscanRect.MaxY - oscanRect.MinY + 1);
- screen = OpenScreenTags(NULL,
- SA_DClip, &oscanRect,
- #ifdef MYKE_REMOVED_THIS
- SA_SysFont, 1,
- #endif
- SA_Left,0,
- SA_Top,0,
- SA_Width,screenWidth,
- SA_Height,screenHeight,
- SA_Depth,2,
- SA_DetailPen,0,
- SA_BlockPen,1,
- SA_Title, GRN_VERSION,
- SA_ErrorCode,0,
- #ifdef MYKE_REMOVED_THIS
- SA_SysFont,0,
- #endif
- SA_Type,CUSTOMSCREEN,
- SA_ShowTitle,TRUE,
- SA_Pens,&look3D[0],
- SA_DisplayID,HIRESLACE_KEY,
- TAG_DONE
- );
- panic0 (screen, "Can't open screen");
- customScreenFlag = !0;
- }
-
- screenTop = screen->BarHeight+1;
- screenWidth = screen->Width;
- screenHeight = screen->Height;
-
- rp = &screen->RastPort;
- vp = &screen->ViewPort;
- vi = GetVisualInfo (screen, TAG_DONE);
- panic0 (vi, "Can't GetVisualInfo");
- return;
- }
-
-
- void CloseSystem (void)
- {
- if (topaz80Font) {
- CloseFont (topaz80Font);
- topaz80Font = 0;
- }
- if (defaultFont) {
- CloseFont (defaultFont);
- defaultFont = 0;
- }
- if (screen) {
- if (customScreenFlag) {
- CloseScreen (screen);
- }
- else {
- UnlockPubScreen (NULL, screen);
- }
- screen = 0;
- }
- if (vi) {
- FreeVisualInfo (vi);
- vi = 0;
- }
- CloseLibs (libDefs);
- return;
- }
-
- WINDOW *CreateWindow (GADGET *gList, short left, short top, short width, short height, char *title)
- {
- WINDOW *window;
-
- if (!top) top = screenTop+1;
-
- if (customScreenFlag) {
- window = OpenWindowTags(NULL,
- WA_Left,left,
- WA_Top,top,
- WA_Width,width,
- WA_Height,height,
- WA_DetailPen,0,
- WA_BlockPen,1,
- WA_IDCMP,MYIDCMP,
- WA_Gadgets,gList,
- WA_Title,0,
- WA_CustomScreen,screen,
- WA_SuperBitMap,0,
- WA_MinWidth,30,
- WA_MinHeight,30,
- WA_MaxWidth,-1,
- WA_MaxHeight,-1,
- WA_SizeGadget,FALSE,
- WA_DragBar,TRUE,
- WA_DepthGadget,TRUE,
- WA_CloseGadget,TRUE,
- WA_Backdrop,FALSE,
- WA_ReportMouse,FALSE,
- WA_Borderless,FALSE,
- WA_Activate,TRUE,
- WA_RMBTrap,FALSE,
- WA_SimpleRefresh,TRUE,
- TAG_DONE
- );
- }
- else {
- window = OpenWindowTags(NULL,
- WA_Left,left,
- WA_Top,top,
- WA_Width,width,
- WA_Height,height,
- WA_DetailPen,0,
- WA_BlockPen,1,
- WA_IDCMP,MYIDCMP,
- WA_Gadgets,gList,
- WA_Title,title,
- WA_SuperBitMap,0,
- WA_MinWidth,30,
- WA_MinHeight,30,
- WA_MaxWidth,-1,
- WA_MaxHeight,-1,
- WA_SizeGadget,FALSE,
- WA_DragBar,TRUE,
- WA_DepthGadget,TRUE,
- WA_CloseGadget,TRUE,
- WA_Backdrop,FALSE,
- WA_ReportMouse,FALSE,
- WA_Borderless,FALSE,
- WA_Activate,TRUE,
- WA_RMBTrap,FALSE,
- WA_SimpleRefresh,TRUE,
- TAG_DONE
- );
- }
- if (window)
- GT_RefreshWindow (window, NULL);
- return window;
- }
-
- void DefaultIDCMPFunc (WINDOW *window, IMSG *m)
- {
- t_printf (window, "Class = 0x%x Code = 0x%x", m->Class, m->Code);
- return;
- }
-
-
- void EventHandler(window, handleFunc, idcmpFunc, refreshFunc)
- WINDOW *window;
- void (*handleFunc)();
- void (*idcmpFunc)();
- void (*refreshFunc)();
- {
- IMSG *m, msg;
-
- while (m = GT_GetIMsg(window->UserPort)) {
- msg = *m;
- GT_ReplyIMsg(m);
-
- switch (msg.Class) {
- case IDCMP_INTUITICKS:
- break;
-
- case IDCMP_MOUSEMOVE:
- MouseMove (handleFunc, &msg);
- break;
-
- case IDCMP_GADGETUP:
- GadgetUp (handleFunc, &msg);
- break;
-
- case IDCMP_GADGETDOWN:
- GadgetDown (handleFunc, &msg);
- break;
-
- case IDCMP_REFRESHWINDOW:
- GT_BeginRefresh (window);
- if (refreshFunc)
- (*refreshFunc)();
- GT_EndRefresh (window, TRUE);
- break;
-
- default:
- if (idcmpFunc)
- (*idcmpFunc)(&msg);
- else
- DefaultIDCMPFunc (window, &msg);
- break;
- }
- }
- return;
- }
-
- /* utility routines */
-
- char *itoa (const long i)
- {
- // itoa - integer to ascii
-
- static char buf [24];
-
- // FIXME - do this by hand to avoid sprintf() overhead
- // D (("itoa(): enter, i = %d\n", i));
-
- sprintf (buf, "%d", i);
-
- // D (("itoa(): exit, buf = %s\n", buf));
- return buf;
- }
-
- int CopyStrings (char *dest, const char *str, ...)
- {
- /*
- Place all passed strings in dest, one after the other.
-
- You *MUST* NULL terminate the list of passed strings.
- (it won't work on both DICE and SAS/C if you don't, not to mention GCC)
- */
-
- va_list valist;
- char *p;
-
- D (("CopyStrings(): enter\n"));
- va_start (valist, str);
-
- *dest = '\0';
- p = str;
- while (p) {
- strcat (dest, p);
- p = va_arg (valist, char *);
- }
- va_end (valist);
-
- D (("CopyStrings(): exit, dest = '%s'\n", dest));
- return 0;
- }
-
- char *TempName (void)
- {
- // TempName - generate a unique GRn-relevant temporary filename
-
- static int count = 0;
- static char *buf = NULL;
-
- D (("TempName(): enter\n"));
-
- if (!buf) {
- buf = malloc (36); // more than enough...
-
- if (!buf) {
- D (("TempName(): exit, get mem failure\n"));
- return NULL;
- }
- }
-
- CopyStrings (buf, "T:GRn", itoa ((long) FindTask (NULL)), ".", NULL);
- // itoa() uses a static buffer. Using it twice in the
- // CopyStrings() call would overwrite the first result.
- strcat (buf, itoa (++count));
-
- D (("TempName(): exit, buf = %s\n", buf));
- return buf;
- }
-
- int Editor (const char *filename, const char *editor)
- {
- // Editor - call the specified editor to edit the specified filename
- // if the Editor failed (non-zero return value), or the
- // user didn't change the input file, then let the user
- // know, and return an appropriate result.
-
- long rslt;
- char buf [128];
- struct stat s1, s2;
-
- D (("Editor(): enter, filename=%s, editor=%s\n", filename, editor));
-
- if (stat (filename, &s1) < 0) {
- t_printf (mainWindow, "Can't stat() %s", filename);
-
- D (("Editor(): no stat 1, exit\n"));
- return 1;
- }
-
- CopyStrings (buf, editor, " ", filename, NULL);
-
- rslt = System (buf, NULL); // System() uses the PATH if any.
- if (rslt == -1) {
- t_printf (mainWindow, "Can't execute your editor");
-
- D (("Editor(): execute failure, exit\n"));
- return 1;
- }
-
- if (rslt != 0) {
- CopyStrings (buf, "GRn - Your editor had a return code of ", itoa (rslt), NULL);
- if (TwoGadgetRequest (buf, "Send it anyway?",
- "_Yes", "_No") == 0) {
-
- D (("Editor(): bad status confirmed, exit\n"));
- return 1;
- }
- }
- if ((stat (filename, &s2) == 0) && s1.st_mtime == s2.st_mtime) {
- if (TwoGadgetRequest ("GRn - You didn't change the input file",
- "Send it anyway?",
- "_Yes", "_No") == 0) {
-
- D (("Editor(): no changes cancel, exit\n"));
- return 1;
- }
- }
-
- D (("Editor(): exit\n"));
- return 0;
- }
-
- int OutputStrings (const int fd, const char *str, ...)
- {
- /*
- Output all passed strings to fd via write().
-
- You *MUST* NULL terminate the list of passed strings.
- (it won't work on both DICE and SAS/C if you don't, not to mention GCC)
- */
- // D (("OutputStrings(): enter\n"));
- va_list valist;
- char *p;
-
- va_start (valist, str);
-
- p = str;
- while (p) {
- write (fd, p, strlen (p));
- p = va_arg (valist, char *);
- }
- va_end (valist);
-
- // D (("OutputStrings(): exit\n"));
- return 0;
- }
-
- void SendMail (const char *filename)
- {
- /*
- SendMail() takes a completely built article residing in
- filename and goes through the required steps to inject
- the message into the mail system.
- */
-
- // save filename -- it may be from TempName()
- char
- temp [256],
- *fname = malloc (strlen (filename) + 1);
- long
- rslt;
-
- D (("SendMail(): enter\n"));
-
- if (!fname) {
- t_printf (mainWindow, "Couldn't get memory for filename");
-
- D (("SendMail(): get mem failure, exit\n"));
- return;
- }
- strcpy (fname, filename);
-
- if (Editor (fname, mailEditor)) {
- remove (fname);
- free (fname);
-
- D (("SendMail(): Editor() goodbye, exit\n"));
- return;
- }
- if (!TwoGadgetRequest ("GRn - Mail Request",
- " Send it off? ",
- "_Yes", "_No")) {
- remove (fname);
- free (fname);
-
- D (("SendMail(): don't send it, exit\n"));
- return;
- }
-
- CopyStrings (temp, sendMail, " >nil: <", fname, " -f ", userName, NULL);
-
- rslt = SystemTags (temp, SYS_Input, 0,
- SYS_Output, 0,
- SYS_Asynch, 0, // NP_Synchronous, 1,
- NP_StackSize, 32000,
- TAG_DONE);
- if (rslt != 0) {
- CopyStrings (temp, "GRn - Your SendMail had a return value of ", itoa (rslt), NULL);
- OneGadgetRequest (temp,
- "It may not have been completely posted",
- "_Continue");
- }
- remove (fname);
- free (fname);
-
- D (("SendMail(): exit\n"));
- return;
- }
-
- void PostNews (const int followupFlag, const char *filename)
- {
- /*
- PostNews() takes a completely built article and goes
- through the machinations required to submit it to
- the news system.
-
- It builds the references file, if needed.
- */
-
- // I require that References and Message_ID be valid when followupFlag
- // is set -- that is, they were NULL'ed and then ScanAndLoadHeaders
- // was called. Results are unpredictable if this isn't true.
-
- // save filename -- it may be from TempName()
-
- char
- *fname = malloc (strlen (filename) + 1);
- char
- temp [256],
- work [256];
- char
- *ptr; // temporary filename
- long
- len, // input read length
- rslt; // result from System()
- int
- fd, // user specified header information
- outfd; // output article being built
-
- D (("PostNews(): enter\n"));
-
- if (!fname) {
- t_printf (mainWindow, "Can't get memory for filename");
-
- D (("PostNews(): get mem failure, exit\n"));
- return;
- }
- strcpy (fname, filename);
-
- // followupFlag == -1 indicates this is an article from Publish().
- // The user isn't allowed to edit those articles, and the verification
- // for submission has already been given.
-
- if (followupFlag != -1) {
-
- if (Editor (fname, newsEditor)) {
- remove (fname);
- free (fname);
-
- D (("PostNews(): Editor() goodbye, exit\n"));
- return;
- }
- if (SendItRequest () == 0) {
- remove (fname);
- free (fname);
-
- D (("PostNews(): SendItRequest() goodbye, exit\n"));
- return;
- }
- }
-
- ptr = TempName ();
- outfd = creat (ptr, 0660);
- // we don't consider a failure on the above creat() to be
- // significant enough to stop the Posting process, since
- // "References:" is not a required field.
- if ((followupFlag > 0) && (outfd >= 0) && Message_ID && References) {
- OutputStrings (outfd, "References: ",
- References ? References : "",
- " ",
- Message_ID ? Message_ID : "",
- "\n",
- NULL);
-
- }
-
- if (outfd >= 0) {
- // append user.nrefs to the refs (header) file
- strcpy (temp, uulib);
- CopyStrings (work, userName, ".nrefs", NULL);
- AddPart (temp, work, 256);
- fd = open (temp, O_RDONLY);
- if (fd < 0) {
- // try Dillon's naming convention (DMail and DNews)
- strcpy (temp, uulib);
- CopyStrings (work, userName, ".header", NULL);
- AddPart (temp, work, 256);
- fd = open (temp, O_RDONLY);
- }
- if (fd >= 0) {
- while ((len = read (fd, temp, 256)) > 0)
- write (outfd, temp, len);
- close (fd);
- }
-
- OutputStrings (outfd, "X-NewsSoftware: ", GRN_VERSION, "\n", NULL);
- close (outfd);
-
- // kick postNews off with the special Refs option
- // postnews t:file -R t:ref-file -x t:file -x t:ref-file
- CopyStrings (temp, postNews, " ", fname, " -R ", ptr,
- " -x ", fname, " -x ", ptr, NULL);
- }
- else {
- // kick postNews off normally if no Refs file
- // postnews t:file -x t:file
-
- CopyStrings (temp, postNews, " ", fname, " -x ", fname, NULL);
- }
- rslt = SystemTags (temp, SYS_Input, 0,
- SYS_Output, 0,
- SYS_Asynch, 1, // NP_Synchronous, 0,
- NP_StackSize, 32000,
- TAG_DONE);
- if (rslt) {
- if (rslt == -1) {
- // Special return from System(). The program didn't
- // run. Probably lack of memory.
- CopyStrings (temp, "Try again later (file=", fname,
- ")", NULL);
- OneGadgetRequest ("GRn - Your PostNews failed",
- temp,
- "_Continue");
- }
- else {
- CopyStrings (temp, "GRn - Your PostNews had a return value of ",
- itoa (rslt), NULL);
- OneGadgetRequest (temp,
- "It may not have been completely posted",
- "_Continue");
- }
- }
- free (fname);
-
- D (("PostNews(): exit\n"));
- return;
- }
-
- void ApplyMailHeaders (int outfd)
- {
- char
- work [256],
- temp [256];
- int
- i,
- rfd,
- rslt;
-
- D (("ApplyMailHeaders(): enter\n"));
-
- // Check for user specified mail headers and apply if found
- strcpy (temp, uulib);
- CopyStrings (work, userName, ".mrefs", NULL); // .mrefs for mail, .nrefs for news
- AddPart (temp, work, 256);
- if ((rfd = open (temp, O_RDONLY)) < 0) {
- // try DMail/DNews naming convention of "user.header"
- strcpy (temp, uulib);
- CopyStrings (work, userName, ".header", NULL);
- AddPart (temp, work, 256);
-
- rfd = open (temp, O_RDONLY);
- }
-
- i = 0;
- if (rfd >= 0) {
- while ((rslt = read (rfd, work, 256)) > 0) {
- write (outfd, work, rslt);
- i = rslt; // save last bufferlength
- }
- close (rfd);
- }
-
- temp [0] = '\n';
-
- // that damn file should end with a newline, but we need to make sure
- if (i && (work [i - 1] != '\n')) {
- // idiot
- write (outfd, temp, 1);
- }
-
- // write the "empty line" to separate the body from the headers
- write (outfd, temp, 1);
-
- D (("ApplyMailHeaders(): exit\n"));
- return;
- }
-