home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / winsock / wvnsc926 / rcs / wvutil.c < prev   
Encoding:
C/C++ Source or Header  |  1995-05-19  |  275.8 KB  |  11,027 lines

  1. head     1.69;
  2. branch   ;
  3. access   ;
  4. symbols  V80:1.17 V76d:1.3;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.69
  10. date     94.09.18.22.35.49;  author jcooper;  state Exp;
  11. branches ;
  12. next     1.68;
  13.  
  14. 1.68
  15. date     94.09.16.01.13.18;  author jcooper;  state Exp;
  16. branches ;
  17. next     1.67;
  18.  
  19. 1.67
  20. date     94.08.26.21.08.04;  author dumoulin;  state Exp;
  21. branches ;
  22. next     1.66;
  23.  
  24. 1.66
  25. date     94.08.24.18.40.15;  author mrr;  state Exp;
  26. branches ;
  27. next     1.65;
  28.  
  29. 1.65
  30. date     94.08.11.02.25.59;  author dumoulin;  state Exp;
  31. branches ;
  32. next     1.64;
  33.  
  34. 1.64
  35. date     94.08.11.00.13.22;  author jcooper;  state Exp;
  36. branches ;
  37. next     1.63;
  38.  
  39. 1.63
  40. date     94.08.05.21.33.22;  author finken;  state Exp;
  41. branches ;
  42. next     1.62;
  43.  
  44. 1.62
  45. date     94.08.04.06.30.36;  author dumoulin;  state Exp;
  46. branches ;
  47. next     1.61;
  48.  
  49. 1.61
  50. date     94.07.27.21.34.22;  author pearse_w_r;  state Exp;
  51. branches ;
  52. next     1.60;
  53.  
  54. 1.60
  55. date     94.07.27.21.33.47;  author pearse_w_r;  state Exp;
  56. branches ;
  57. next     1.59;
  58.  
  59. 1.59
  60. date     94.07.27.20.08.57;  author rushing;  state Exp;
  61. branches ;
  62. next     1.58;
  63.  
  64. 1.58
  65. date     94.07.25.23.32.16;  author rushing;  state Exp;
  66. branches ;
  67. next     1.57;
  68.  
  69. 1.57
  70. date     94.07.25.22.39.06;  author rushing;  state Exp;
  71. branches ;
  72. next     1.56;
  73.  
  74. 1.56
  75. date     94.07.25.18.51.48;  author jcooper;  state Exp;
  76. branches ;
  77. next     1.55;
  78.  
  79. 1.55
  80. date     94.06.30.16.34.44;  author dumoulin;  state Exp;
  81. branches ;
  82. next     1.54;
  83.  
  84. 1.54
  85. date     94.06.23.23.09.05;  author dumoulin;  state Exp;
  86. branches ;
  87. next     1.53;
  88.  
  89. 1.53
  90. date     94.06.17.09.09.30;  author dumoulin;  state Exp;
  91. branches ;
  92. next     1.52;
  93.  
  94. 1.52
  95. date     94.06.09.21.47.08;  author rushing;  state Exp;
  96. branches ;
  97. next     1.51;
  98.  
  99. 1.51
  100. date     94.06.09.18.39.34;  author rushing;  state Exp;
  101. branches ;
  102. next     1.50;
  103.  
  104. 1.50
  105. date     94.06.08.21.01.45;  author gardnerd;  state Exp;
  106. branches ;
  107. next     1.49;
  108.  
  109. 1.49
  110. date     94.06.06.22.06.13;  author gardnerd;  state Exp;
  111. branches ;
  112. next     1.48;
  113.  
  114. 1.48
  115. date     94.06.02.00.17.07;  author rushing;  state Exp;
  116. branches ;
  117. next     1.47;
  118.  
  119. 1.47
  120. date     94.05.27.01.29.29;  author rushing;  state Exp;
  121. branches ;
  122. next     1.46;
  123.  
  124. 1.46
  125. date     94.05.26.22.43.06;  author jglasser;  state Exp;
  126. branches ;
  127. next     1.45;
  128.  
  129. 1.45
  130. date     94.05.23.18.36.00;  author jcooper;  state Exp;
  131. branches ;
  132. next     1.44;
  133.  
  134. 1.44
  135. date     94.05.19.02.02.10;  author rushing;  state Exp;
  136. branches ;
  137. next     1.43;
  138.  
  139. 1.43
  140. date     94.05.02.20.33.46;  author rushing;  state Exp;
  141. branches ;
  142. next     1.42;
  143.  
  144. 1.42
  145. date     94.03.22.22.44.24;  author rushing;  state Exp;
  146. branches ;
  147. next     1.41;
  148.  
  149. 1.41
  150. date     94.02.24.21.35.41;  author jcoop;  state Exp;
  151. branches ;
  152. next     1.40;
  153.  
  154. 1.40
  155. date     94.02.16.21.05.33;  author cnolan;  state Exp;
  156. branches ;
  157. next     1.39;
  158.  
  159. 1.39
  160. date     94.02.16.20.59.17;  author rushing;  state Exp;
  161. branches ;
  162. next     1.38;
  163.  
  164. 1.38
  165. date     94.02.09.18.01.08;  author cnolan;  state Exp;
  166. branches ;
  167. next     1.37;
  168.  
  169. 1.37
  170. date     94.01.24.17.40.28;  author jcoop;  state Exp;
  171. branches ;
  172. next     1.36;
  173.  
  174. 1.36
  175. date     94.01.17.21.54.16;  author jcoop;  state Exp;
  176. branches ;
  177. next     1.35;
  178.  
  179. 1.35
  180. date     94.01.12.19.46.06;  author cedwards;  state Exp;
  181. branches ;
  182. next     1.34;
  183.  
  184. 1.34
  185. date     94.01.12.19.27.55;  author mrr;  state Exp;
  186. branches ;
  187. next     1.33;
  188.  
  189. 1.33
  190. date     94.01.05.22.36.05;  author rushing;  state Exp;
  191. branches ;
  192. next     1.32;
  193.  
  194. 1.32
  195. date     93.12.08.01.28.01;  author rushing;  state Exp;
  196. branches ;
  197. next     1.31;
  198.  
  199. 1.31
  200. date     93.12.01.23.24.06;  author rushing;  state Exp;
  201. branches ;
  202. next     1.30;
  203.  
  204. 1.30
  205. date     93.11.24.23.07.20;  author rushing;  state Exp;
  206. branches ;
  207. next     1.29;
  208.  
  209. 1.29
  210. date     93.11.22.20.30.50;  author rushing;  state Exp;
  211. branches ;
  212. next     1.28;
  213.  
  214. 1.28
  215. date     93.08.25.18.53.17;  author mbretherton;  state Exp;
  216. branches ;
  217. next     1.27;
  218.  
  219. 1.27
  220. date     93.08.25.17.05.17;  author mbretherton;  state Exp;
  221. branches ;
  222. next     1.26;
  223.  
  224. 1.26
  225. date     93.08.18.21.49.21;  author rushing;  state Exp;
  226. branches ;
  227. next     1.25;
  228.  
  229. 1.25
  230. date     93.08.05.20.06.07;  author jcoop;  state Exp;
  231. branches ;
  232. next     1.24;
  233.  
  234. 1.24
  235. date     93.07.13.16.03.04;  author riordan;  state Exp;
  236. branches ;
  237. next     1.23;
  238.  
  239. 1.23
  240. date     93.06.28.17.52.17;  author rushing;  state Exp;
  241. branches ;
  242. next     1.22;
  243.  
  244. 1.22
  245. date     93.06.25.20.18.51;  author dumoulin;  state Exp;
  246. branches ;
  247. next     1.21;
  248.  
  249. 1.21
  250. date     93.06.22.16.43.03;  author bretherton;  state Exp;
  251. branches ;
  252. next     1.20;
  253.  
  254. 1.20
  255. date     93.06.22.14.04.05;  author dumoulin;  state Exp;
  256. branches ;
  257. next     1.19;
  258.  
  259. 1.19
  260. date     93.06.19.18.40.17;  author dumoulin;  state Exp;
  261. branches ;
  262. next     1.18;
  263.  
  264. 1.18
  265. date     93.06.15.21.16.59;  author rushing;  state Exp;
  266. branches ;
  267. next     1.17;
  268.  
  269. 1.17
  270. date     93.06.11.00.10.35;  author rushing;  state Exp;
  271. branches ;
  272. next     1.16;
  273.  
  274. 1.16
  275. date     93.06.10.18.25.17;  author rushing;  state Exp;
  276. branches ;
  277. next     1.15;
  278.  
  279. 1.15
  280. date     93.06.08.19.42.38;  author rushing;  state Exp;
  281. branches ;
  282. next     1.14;
  283.  
  284. 1.14
  285. date     93.06.05.03.18.25;  author rushing;  state Exp;
  286. branches ;
  287. next     1.13;
  288.  
  289. 1.13
  290. date     93.06.01.18.22.40;  author rushing;  state Exp;
  291. branches ;
  292. next     1.12;
  293.  
  294. 1.12
  295. date     93.05.26.23.59.40;  author rushing;  state Exp;
  296. branches ;
  297. next     1.11;
  298.  
  299. 1.11
  300. date     93.05.24.23.56.51;  author rushing;  state Exp;
  301. branches ;
  302. next     1.10;
  303.  
  304. 1.10
  305. date     93.05.13.19.58.09;  author SOMEONE;  state Exp;
  306. branches ;
  307. next     1.9;
  308.  
  309. 1.9
  310. date     93.05.13.16.16.06;  author rushing;  state Exp;
  311. branches ;
  312. next     1.8;
  313.  
  314. 1.8
  315. date     93.05.08.17.11.05;  author rushing;  state Exp;
  316. branches ;
  317. next     1.7;
  318.  
  319. 1.7
  320. date     93.04.29.21.42.11;  author rushing;  state Exp;
  321. branches ;
  322. next     1.6;
  323.  
  324. 1.6
  325. date     93.04.29.20.24.59;  author rushing;  state Exp;
  326. branches ;
  327. next     1.5;
  328.  
  329. 1.5
  330. date     93.04.27.21.03.20;  author rushing;  state Exp;
  331. branches ;
  332. next     1.4;
  333.  
  334. 1.4
  335. date     93.04.23.22.10.48;  author rushing;  state Exp;
  336. branches ;
  337. next     1.3;
  338.  
  339. 1.3
  340. date     93.02.18.20.34.16;  author rushing;  state Exp;
  341. branches ;
  342. next     1.2;
  343.  
  344. 1.2
  345. date     93.02.16.21.20.28;  author rushing;  state Exp;
  346. branches ;
  347. next     1.1;
  348.  
  349. 1.1
  350. date     93.02.16.20.54.22;  author rushing;  state Exp;
  351. branches ;
  352. next     ;
  353.  
  354.  
  355. desc
  356. @winvn version 0.76 placed into RCS
  357. @
  358.  
  359.  
  360. 1.69
  361. log
  362. @New window cascade routines, and cleanup of other batch window ops
  363. @
  364. text
  365. @/*
  366.  * $Id: wvutil.c 1.68 1994/09/16 01:13:18 jcooper Exp $
  367.  *
  368.  */
  369.  
  370. /*-- WVUTIL.C -- File containing utility routines.
  371.  */
  372.  
  373. #include <windows.h>
  374. #include <windowsx.h>      // for GlobalFreePtr (JSC)
  375. #include "wvglob.h"
  376. #include "winvn.h"
  377. #pragma hdrstop
  378. #include <commdlg.h>    // for GetOpenFileName dialog (JSC)
  379. #include <ctype.h>
  380. #include <stdlib.h>
  381. #include <time.h>
  382.  
  383. char far *mylstrcpy (char_p ptr1, char far * ptr2);
  384. char *get_xhdr_line (char *line);
  385. time_t parse_usenet_date (char *date);
  386. void finish_header_retrieval ();
  387. void GenerateFileFilters (HWND hParentWnd, char *filters);
  388.  
  389. // please update this if you modify XHDR retrieval
  390. // This will now be either 4 or 6, depending on whether threading
  391. // is enabled via 'threadp'.
  392. unsigned int total_xhdrs = 4;
  393.  
  394. /*--- function GetNum --------------------------------------------
  395.  *
  396.  *  Cracks off a positive integer number from a string.
  397.  *
  398.  *  Entry    *ptr  is the character position to start scanning
  399.  *                 for an integer
  400.  *
  401.  *  Exit     *ptr  is the character position at which we stopped
  402.  *                 scanning (because of a non-digit).
  403.  *           *num  is the cracked off number.
  404.  *           Returns TRUE iff we got a number.
  405.  */
  406. BOOL
  407. GetNum (ptr, num)
  408.      char **ptr;
  409.      long int *num;
  410. {
  411.   BOOL gotit = FALSE;
  412.  
  413.   /* Skip initial spaces                                            */
  414.  
  415.   while ((**ptr) && **ptr == ' ')
  416.     (*ptr)++;
  417.  
  418.   *num = 0;
  419.   while (**ptr && isdigit (**ptr)) {
  420.     *num = 10 * (*num) + (**ptr - '0');
  421.     gotit = TRUE;
  422.     (*ptr)++;
  423.   }
  424.   return (gotit);
  425. }
  426.  
  427. char *
  428. get_xhdr_line (char *line)
  429. {
  430.   char *cptr;
  431. /* skip past the art # and space */
  432.   for (cptr = line; isdigit (*cptr); cptr++);
  433.   for (; *cptr == ' '; cptr++);
  434.   return (cptr);
  435. }
  436.  
  437. #if 0
  438. MRB already did this
  439. void
  440. make_neat_from (char far * in, char far * out)
  441. {
  442.   char far *left, far * right;
  443.  
  444.   /* this is controlled from .ini */
  445.   if (FullNameFrom) {
  446.     left = strchr (in, '(');
  447.     right = strrchr (in, ')');
  448.  
  449.     if ((left && right) && (left < right)) {
  450.       strncpy (out, left + 1, (size_t) (right - left - 1));
  451.       out[(right - left - 1)] = (char) 0;
  452.     }
  453.     else       /* No name in parens */
  454.       strcpy (out, in);
  455.   }
  456.   else            /* !FullNameFrom */
  457.     strcpy (out, in);
  458. }
  459. #endif
  460.  
  461. /*-- function StrToRGB -------------------------------------------------
  462.  *
  463.  *  Takes an ASCII string of the form "r,g,b" where r, g, and b are
  464.  *  decimal ASCII numbers, and converts it to an RGB color number.
  465.  */
  466. COLORREF
  467. StrToRGB (cstring)
  468.      char *cstring;
  469. {
  470.   BYTE red, green, blue;
  471.   long int lred, lgreen, lblue;
  472.  
  473.   GetNum (&cstring, &lred);
  474.   cstring++;
  475.   GetNum (&cstring, &lgreen);
  476.   cstring++;
  477.   GetNum (&cstring, &lblue);
  478.   red = (BYTE) lred;
  479.   green = (BYTE) lgreen;
  480.   blue = (BYTE) lblue;
  481.  
  482.   return (RGB (red, green, blue));
  483. }
  484.  
  485. /*-- function RGBToStr -------------------------------------------------
  486.  *
  487.  *  Takes an RGB color ref and converts to a string of the form "r,g,b"
  488.  *  result is placed in buf
  489.  *  (JSC)
  490.  */
  491. char *
  492. RGBToStr (char *buf, DWORD rgbVal)
  493. {
  494.   sprintf (buf, "%u,%u,%u", GetRValue (rgbVal),
  495.       GetGValue (rgbVal),
  496.       GetBValue (rgbVal));
  497.   return (buf);
  498. }
  499.  
  500. /* This was lifted from ANU news. */
  501.  
  502. time_t
  503. parse_usenet_date (char *s)
  504. {
  505.   struct tm datetime;
  506.   char *cp, mon[80];
  507.   int dom = 0, yr = 0, hr = 0, mn = 0, sc = 0, mth = 0;
  508.   static char fmtMonthTable[37] = "janfebmaraprmayjunjulaugsepoctnovdec";
  509.  
  510.   if (!s || !*s)
  511.     return (0);
  512.   if (cp = strchr (s, ','))
  513.     s = ++cp;
  514.   while (isspace (*s))
  515.     s++;
  516.   *mon = '\0';
  517.   if (isdigit (*s)) {
  518.     sscanf (s, "%d %s %d %d:%d:%d", &dom, mon, &yr, &hr, &mn, &sc);
  519.     if (yr < 100)
  520.       yr += 1900;
  521.   }
  522.   else
  523.     sscanf (s, "%*s %s %d %d:%d:%d %d", mon, &dom, &hr, &mn, &sc, &yr);
  524.  
  525.   if (!dom || !yr || !*(cp = mon))
  526.     return (0);
  527.   if ((dom <= 0) || (dom >= 32))
  528.     return (0);
  529.   if ((yr < 1980) || (yr > 2020))
  530.     return (0);
  531.   if (strlen (mon) > 10)
  532.     return (0);
  533.   if ((hr < 0) || (hr > 23))
  534.     return (0);
  535.   if ((mn < 0) || (mn > 59))
  536.     return (0);
  537.   if ((sc < 0) || (sc > 59))
  538.     return (0);
  539.  
  540.   for (cp = mon; *cp; cp++)
  541.     *cp = tolower (*cp);
  542.  
  543.   if (cp = strstr (fmtMonthTable, mon))
  544.     mth = (cp - fmtMonthTable) / 3;
  545.  
  546. /*  Setup a Posix time structure and calculate time in absolute
  547.    time (seconds since midnight, Jan 1, 1970    JD 06/25/93 */
  548.  
  549.   datetime.tm_year = yr - 1900;
  550.   datetime.tm_mon = mth;
  551.   datetime.tm_mday = dom;
  552.   datetime.tm_hour = hr;
  553.   datetime.tm_min = mn;
  554.   datetime.tm_sec = sc;
  555.  
  556.   return (mktime (&datetime));
  557. }
  558.  
  559. /*-- function StringDate ----------------*/
  560. char *
  561. StringDate (char *s, time_t time)
  562. {
  563.   struct tm *datetime;
  564.   if (time != 0) {
  565.     datetime = localtime (&time);
  566.  
  567.     if (fmtDaysB4Mth) {
  568.       sprintf (s, "%02d%s%02d", datetime->tm_mday, fmtDateDelim, datetime->tm_mon + 1);
  569.     }
  570.     else {
  571.       sprintf (s, "%02d%s%02d", datetime->tm_mon + 1, fmtDateDelim, datetime->tm_mday);
  572.     }
  573.     return (s);
  574.   }
  575.   else
  576.     return ("-----");
  577. }
  578.  
  579. /*-- function DoCommInput ---------------------------------------
  580.  *
  581.  *
  582.  */
  583. void
  584. DoCommInput ()
  585. {
  586.   int ch;
  587.  
  588.   while ((CommState != ST_CLOSED_COMM) && ((ch = MRRReadComm ()) >= 0)) {
  589.     if (ch == IgnoreCommCh) {
  590.     }
  591.     else if (ch == EOLCommCh) {
  592.       *CommLinePtr = '\0';
  593.       DoCommState ();
  594.       CommLinePtr = CommLineIn;
  595.     }
  596.     else {
  597.       *(CommLinePtr++) = (char) ch;
  598.       if (CommLinePtr == CommLineLWAp1)
  599.    CommLinePtr--;
  600.     }
  601.   }
  602. }
  603.  
  604. void
  605. update_window_title (HWND hwnd,
  606.            char *group_name,
  607.            unsigned long line_number,
  608.            unsigned long total_lines)
  609. {
  610.   char title[200];
  611.   static int prevPercent, newPercent;
  612.   // to avoid flicker, update percent only if it has changed more than 1%
  613.  
  614.   line_number *= 100;
  615.   if (newPercent < prevPercent)
  616.     prevPercent = 0;
  617.  
  618.   if ((line_number % UPDATE_TITLE_FREQ) == 0) {
  619.     newPercent = (int) (line_number / total_lines);
  620.     if (newPercent != prevPercent && newPercent - prevPercent > 1) {
  621.       sprintf (title, "Retrieving headers for '%s' : %d%%", group_name, newPercent);
  622.       SetWindowText (hwnd, title);
  623.       prevPercent = newPercent;
  624.     }
  625.   }
  626. }
  627.  
  628. int
  629. check_server_code (int retcode)
  630. {
  631.   int class = retcode / 100;
  632.   switch (class) {
  633.   case 5:
  634.     MessageBox (hWndConf, "News Server Error", "WinVN", MB_OK | MB_ICONHAND);
  635.     CommBusy = FALSE;
  636.     CommState = ST_NONE;
  637.     return (1);
  638.     break;
  639.   case 4:
  640.     MessageBox (hWndConf, CommLineIn, "WinVN", MB_OK | MB_ICONHAND);
  641.     switch (class) {
  642.     case 400:
  643.       /* service discontinued */
  644.       MRRCloseComm ();
  645.       PostQuitMessage (0);
  646.       break;
  647.     default:
  648.       break;
  649.     }
  650.     CommBusy = FALSE;
  651.     CommState = ST_NONE;
  652.     return (1);
  653.     break;
  654.   }
  655.   return (0);
  656. }
  657.  
  658. /*  Function sync_artnum
  659.  
  660.    Normally XREF returns lists of the same length for each header type
  661.    but some servers have errors that could cause these lists to get
  662.    out of sync. This function tries to find the proper location in the
  663.    headers array and returns that location.  If the article number isn't
  664.    found, it returns -1.  JD 6/19/93 */
  665.  
  666. long
  667. sync_artnum (unsigned long artnum,
  668.         unsigned long activenum,
  669.         header_p headers, TypGroup far * GroupDoc)
  670. {
  671.   long headerloc = CommDoc->ActiveLines;
  672.   if (artnum == activenum)
  673.     return (headerloc);
  674.   else if (artnum < activenum) {
  675.     while ((artnum != activenum) && (headerloc > 0)) {
  676.       headerloc--;
  677.       if ((header_elt (headers, headerloc))->number == artnum)
  678.    return (headerloc);
  679.     }
  680.     return (-1);
  681.   }
  682.   else {
  683.     while ((artnum != activenum) && (headerloc <= GroupDoc->total_headers)) {
  684.       headerloc++;
  685.       if ((header_elt (headers, headerloc))->number == artnum)
  686.    return (headerloc);
  687.     }
  688.     return (-1);
  689.   }
  690. }
  691.  
  692. char *
  693. get_best_reference (char *refer)
  694. {
  695.   char *bracket1, *bracket2;
  696.   char *end = refer + strlen (refer) - 1; /* points to NULL */
  697.   int bracket_len;
  698.  
  699.   bracket1 = strrchr (refer, '<');
  700.   if (bracket1) {
  701.     bracket_len = (int) (end - bracket1) + 2;
  702.     if ((bracket_len < 30) && (!strrchr (bracket1, '>'))) {
  703.       *bracket1 = (char) NULL;
  704.       bracket1 = strrchr (refer, '<');
  705.       if (!bracket1)
  706.    bracket_len = 0;
  707.       else {
  708.    bracket2 = strrchr (refer, '>');
  709.    if (bracket2)
  710.      bracket_len = (int) (bracket2 - bracket1) + 1;
  711.       }
  712.     }
  713.   }
  714.   else
  715.     bracket_len = 0;
  716.  
  717.   if (!bracket_len)
  718.     return (NULL);
  719.   else if (bracket_len > 29)
  720.     bracket_len = 29;
  721.  
  722.   if ((bracket1 + bracket_len) < end)
  723.     *(bracket1 + bracket_len) = (char) NULL;
  724.  
  725.   return (bracket1);
  726. }
  727.  
  728. /*-- function DoCommState ----------------------------------------------
  729.  *
  730.  *  Function to implement an FSA to process incoming lines from
  731.  *  the server.
  732.  *  This function is called once for each line from the server.
  733.  *
  734.  *    Entry    CommLineIn  is a zero-terminated line received from
  735.  *                         the server.
  736.  *             CommState   is the current state of the FSA.
  737.  */
  738. void
  739. DoCommState ()
  740. {
  741.   static BOOL dialog_active = FALSE;
  742.   TypLine far *LinePtr;
  743.   TypBlock far *BlockPtr;
  744.   HANDLE hBlock;
  745.   unsigned int Offset;
  746.   TypLineID MyLineID;
  747.   int retcode;
  748.   int found;
  749.   unsigned long estnum;
  750.   long int first, last, syncnum;
  751.   unsigned long artnum;
  752.   int mylen;
  753.   BOOL done = FALSE;
  754.   BOOL DlgStatus = FALSE;
  755.   BOOL dolist, do_authinfo;
  756.   static char group[MAXINTERNALLINE];
  757.   char mybuf[MAXINTERNALLINE];
  758.   char mybuf2[MAXINTERNALLINE];
  759.   char far *lpsz;
  760.   HANDLE header_handle;
  761.   HANDLE thread_handle;
  762.   header_p headers;
  763.   header_p header;
  764.   TypGroup far *GroupDoc;
  765.   TypRange *RangePtr;
  766.  
  767.   /* CommDoc is !NULL if retrieving group list, article headers or articles */
  768.   /* CommDecoding is true if retrieving article in decode mode (not to a doc) */
  769.   /* PostEdit !NULL if we are posting (this is from an edit, no doc involved) */
  770.   if (CommDoc || CommDecoding || PostEdit) {
  771.  
  772.     switch (CommState) {
  773.     case ST_NONE:
  774.       break;
  775.  
  776.     case ST_ESTABLISH_COMM:
  777.       if (!sscanf (CommLineIn, "%u", &retcode))
  778.    break;
  779.       if (retcode == 200 || retcode == 201) {   /* was 500 from induced error */
  780.    CommBusy = TRUE;
  781.    do_authinfo = FALSE;
  782.    Authenticated = FALSE;
  783.    if (strlen (NNTPUserName)) {
  784.      /* We have the AUTHINFO username.  Do we have the password? */
  785.      if (!strlen (NNTPPasswordEncrypted)) {
  786.        /* Get the news server user password from the user */
  787.        if (DialogBox (hInst, (LPCSTR) "WinVnComm", hWndConf, (DLGPROC) lpfnWinVnCommDlg)
  788.       && strlen (NNTPPasswordEncrypted)) {
  789.          do_authinfo = TRUE;
  790.        }
  791.      }
  792.      else {
  793.        do_authinfo = TRUE;
  794.      }
  795.    }
  796.    if (do_authinfo) {
  797.      sprintf (mybuf, "AUTHINFO user %s", NNTPUserName);
  798.      CommState = ST_CHECK_AUTHINFO_USERNAME;
  799.      PutCommLine (mybuf);
  800.    }
  801.    else {
  802.      goto End_Authinfo;
  803.    }
  804.  
  805.       }
  806.       else {
  807.    MessageBox (hWndConf, CommLineIn, "Access Problem", MB_OK);
  808.    /*      MRRCloseComm (); */
  809.    /*        PostQuitMessage (0); */
  810.    Initializing = INIT_NOT_CONNECTED;
  811.    InvalidateRect (hWndConf, NULL, TRUE);
  812.       }
  813.  
  814.       break;
  815.  
  816.     case ST_CHECK_AUTHINFO_USERNAME:
  817.       retcode = 0;
  818.       sscanf (CommLineIn, "%u", &retcode);
  819.       if (!retcode)
  820.    break;
  821.       if (retcode >= 500) {
  822.    MessageBox (hWndConf, "Error authorizing your username with the News Server.", "WinVN", MB_OK | MB_ICONHAND);
  823.    goto End_Authinfo;
  824.       }
  825.       MRRDecrypt (NNTPPasswordEncrypted, (unsigned char *) mybuf2, MAXINTERNALLINE);
  826.       sprintf (mybuf, "AUTHINFO pass %s", mybuf2);
  827.       CommState = ST_CHECK_AUTHINFO_PASSWORD;
  828.       PutCommLine (mybuf);
  829.       break;
  830.  
  831.     case ST_CHECK_AUTHINFO_PASSWORD:
  832.       if (dialog_active)
  833.    break;
  834.       retcode = 0;
  835.       if (sscanf (CommLineIn, "%u", &retcode) <= 0)
  836.    break;
  837.       if (retcode < 200 || retcode > 299) {
  838.    dialog_active = TRUE;
  839.    sprintf (mybuf, "Error authorizing your password with the News Server:\n%s.", CommLineIn);
  840.    MessageBox (hWndConf, mybuf, "WinVN", MB_OK | MB_ICONHAND);
  841.    dialog_active = FALSE;
  842.       } else {                                               
  843.          /* Authentication was successful.  Store this fact, and the name under
  844.           * which the user was authenticated.
  845.           */
  846.          Authenticated = TRUE;
  847.          strncpy(AuthenticatedName,NNTPUserName,MAXNNTPSIZE);
  848.       }
  849.       goto End_Authinfo;
  850.  
  851.  
  852.     case ST_END_AUTHINFO:
  853.     End_Authinfo:;
  854.       /* now check for the XOVER command */
  855.       CommState = ST_XOVER_CHECK;
  856.       PutCommLine ("XOVER");
  857.       break;
  858.  
  859.     case ST_XOVER_CHECK:
  860.       retcode = 0;
  861.       sscanf (CommLineIn, "%u", &retcode);
  862.       if (retcode == 412 && !force_xhdr)  /* 412 == 'not in a newsgroup' */
  863.    xoverp = 1;
  864.       else        /* 500 == 'command not understood' */
  865.    xoverp = 0;
  866.  
  867.       dolist = DoList;
  868.       if (dolist == ID_DOLIST_ASK - ID_DOLIST_BASE)
  869.    if (MessageBox (hWndConf, "Request the latest group list from server?\n(This can be time consuming)",
  870.          "Request LIST from server?", MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDNO)
  871.      dolist = 0;
  872.  
  873.       if (dolist) {
  874.    StartList ();
  875.    did_list = 1;
  876.       }
  877.       else {
  878.    did_list = 0;
  879.    CommState = ST_NONE;
  880.    CommBusy = FALSE;
  881.    Initializing = INIT_READY;
  882.       }
  883.       InvalidateRect (hWndConf, NULL, FALSE);
  884.       break;
  885.  
  886.     case ST_LIST_RESP:
  887.       retcode = 0;
  888.       sscanf (CommLineIn, "%u", &retcode);
  889.       if (retcode != 215) {
  890.    check_server_code (retcode);
  891.    break;
  892.       }
  893.  
  894.       CommState = ST_LIST_GROUPLINE;
  895.       RcvLineCount = 0;
  896.       break;
  897.  
  898.     case ST_LIST_GROUPLINE:
  899.       if (strcmp (CommLineIn, ".") == 0) {
  900.    CommState = ST_NONE;
  901.    CommBusy = FALSE;
  902.    Initializing = INIT_READY;
  903.    InvalidateRect (hWndConf, NULL, FALSE);
  904.  
  905.    ProcEndList ();
  906.       }
  907.       else {
  908.    ProcListLine ((unsigned char *) CommLineIn);
  909.       }
  910.       break;
  911.  
  912.     case ST_GROUP_RESP:
  913.       retcode = 0;
  914.       sscanf (CommLineIn, "%u", &retcode);
  915.       switch (retcode) {
  916.       case 411:
  917.    MessageBox (hWndConf, "No Such Newsgroup", "Error", MB_OK | MB_ICONHAND);
  918.    /* abort the fledgling group window */
  919.    DestroyWindow (CommDoc->hDocWnd);
  920.    CommBusy = FALSE;
  921.    CommState = ST_NONE;
  922.    return;
  923.    break;
  924.       case 502:
  925.    MessageBox (hWndConf, "Restricted Access", "WinVN", MB_OK | MB_ICONHAND);
  926.    /* abort the fledgling group window */
  927.    DestroyWindow (CommDoc->hDocWnd);
  928.    CommBusy = FALSE;
  929.    CommState = ST_NONE;
  930.    return;
  931.    break;
  932.       default:
  933.    if (check_server_code (retcode))
  934.      return;
  935.    break;
  936.       }
  937.  
  938.       sscanf (CommLineIn, "%u %lu %ld %ld %s", &retcode, &estnum, &first, &last, group);
  939.  
  940.       LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  941.       CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  942.       GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  943.       RangePtr = (TypRange far *) ((char far *) GroupDoc + RangeOffset (GroupDoc->NameLen));
  944.       GroupDoc->Determined = TRUE;
  945.  
  946.       /* we don't want to grab *that* many! */
  947.       if (estnum >= article_threshold) {
  948.    if (!ShowUnreadOnly)
  949.      { 
  950.      arts_to_retrieve = (int) estnum;
  951.      DlgStatus = DialogBox (hInst, (LPCSTR) "THRESHOLD", CommDoc->hDocWnd, (DLGPROC) lpfnWinVnThresholdDlg);
  952.           if (DlgStatus == FALSE)
  953.              {             
  954.               DestroyWindow (CommDoc->hDocWnd);
  955.          CommBusy = FALSE;
  956.          CommState = ST_NONE;
  957.          GroupDoc->ServerFirst = GroupDoc->ServerLast;
  958.          GroupDoc->ServerEstNum = estnum;
  959.               return;
  960.               }
  961.           }
  962.    if ((arts_to_retrieve > 0)
  963.        && ((last - arts_to_retrieve) > first)) {
  964.      first = (last - arts_to_retrieve) + 1;
  965.    }
  966.    else if (arts_to_retrieve == -1) /* they clicked 'all of them' */
  967.      arts_to_retrieve = (int) estnum;
  968.    /* added by jlg */
  969.    else if ((arts_to_retrieve == -2)   /* they clicked 'unread' */
  970.        ||(ShowUnreadOnly)) {
  971.      if (GroupDoc->nRanges) {
  972.        first = RangePtr[0].Last + 1;
  973.        arts_to_retrieve = (int) ((last - first) + 1);
  974.        if (arts_to_retrieve < 50) {
  975.          arts_to_retrieve = 50;
  976.          first = last - 49;
  977.        }
  978.      }
  979.      else
  980.        arts_to_retrieve = (int) estnum;
  981.    }
  982.       }
  983.       else {
  984.    if (estnum > 0)
  985.      arts_to_retrieve = (int) estnum;
  986.    else {
  987.      MessageBox (hWndConf, "Empty Newsgroup", "WinVN", MB_OK | MB_ICONHAND);
  988.      /* abort the fledgling group window */
  989.      DestroyWindow (CommDoc->hDocWnd);
  990.      InvalidateRect(hWndConf, NULL, FALSE);
  991.      CommBusy = FALSE;
  992.      CommState = ST_NONE;
  993.      GroupDoc->ServerFirst = GroupDoc->ServerLast;
  994.      GroupDoc->ServerEstNum = 0;
  995.      return;
  996.    }
  997.       }
  998.  
  999.       CommDoc->TotalLines = arts_to_retrieve;
  1000.  
  1001.       if (arts_to_retrieve > 0) {
  1002.    header_handle =
  1003.      GlobalAlloc (GMEM_MOVEABLE, (long)
  1004.              ((sizeof (TypHeader)) *
  1005.             (long) (arts_to_retrieve)) + sizeof (thread_array *));
  1006.  
  1007.    /* allocate space for the header_array index table */
  1008.    thread_handle =
  1009.      GlobalAlloc (GMEM_MOVEABLE,
  1010.              (long) ((sizeof (long)) * (long) (arts_to_retrieve)));
  1011.  
  1012.    GroupDoc->header_handle = header_handle;
  1013.    GroupDoc->thread_handle = thread_handle;
  1014.  
  1015.       }
  1016.  
  1017.       /* stick nulls and 0's, etc.. in case display code get mis-threaded */
  1018.       initialize_header_array (header_handle, thread_handle, arts_to_retrieve);
  1019.  
  1020.       GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  1021.       GroupDoc->ServerEstNum = estnum;
  1022.       GroupDoc->ServerFirst = first;
  1023.       GroupDoc->ServerLast = last;
  1024.  
  1025.       GlobalUnlock (BlockPtr->hCurBlock);
  1026.  
  1027.       if (xoverp) {
  1028.    mylen = sprintf (mybuf, "XOVER %ld-%ld", first, last);
  1029.    CommState = ST_XOVER_START;
  1030.    PutCommLine (mybuf);
  1031.       }
  1032.       else {
  1033.    mylen = sprintf (mybuf, "XHDR from %ld-%ld", first, last);
  1034.    CommState = ST_XHDR_FROM_START;
  1035.    PutCommLine (mybuf);
  1036.       }
  1037.  
  1038.       break;
  1039.  
  1040.       /* The next few cases handle retrieval of XHDR information for display */
  1041.       /* in the group window.  If you change the number of XHDR's retrieved */
  1042.       /* (such as adding 'XHDR References' back into the state machine), you */
  1043.       /* need to reflect that change in the variable total_xhdrs. */
  1044.  
  1045.       /* the current flow is FROM -> DATE -> LINES -> SUBJECT */
  1046.       /* (threadp) FROM -> DATE -> LINES -> REF -> ID -> SUBJECT */
  1047.  
  1048.       /* this will now be done dynamically, depending on the state of */
  1049.       /* the 'threadp' variable */
  1050.  
  1051.     case ST_XOVER_START:
  1052.       retcode = 0;
  1053.       sscanf (CommLineIn, "%d", &retcode);
  1054.       if (retcode == 224) {
  1055.    CommState = ST_XOVER_DATA;
  1056.    CommDoc->ActiveLines = 0;
  1057.       }
  1058.       else {
  1059.    mylen = sprintf (mybuf, "XHDR from %ld-%ld", first, last);
  1060.    CommState = ST_XHDR_FROM_START;
  1061.    PutCommLine (mybuf);
  1062.       }
  1063.       break;
  1064.  
  1065.     case ST_XOVER_DATA:
  1066.       if (strcmp (CommLineIn, ".") == 0) {
  1067.    /* this is a yuck way to do this */
  1068.    CommState = ST_IN_GROUP;
  1069.    CommBusy = FALSE;
  1070.    finish_header_retrieval (CommDoc);
  1071.    InvalidateRect (CommDoc->hDocWnd, NULL, FALSE);
  1072.       }
  1073.       else {
  1074.    char *this_hop, *next_hop;
  1075.    char *reference;
  1076.  
  1077.    LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1078.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1079.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  1080.    header_handle = GroupDoc->header_handle;
  1081.    thread_handle = GroupDoc->thread_handle;
  1082.  
  1083.    GlobalUnlock (BlockPtr->hCurBlock);
  1084.  
  1085.    /* Lock the header data */
  1086.    headers = lock_headers (header_handle, thread_handle);
  1087.    header = header_elt (headers, CommDoc->ActiveLines);
  1088.  
  1089.    this_hop = CommLineIn;
  1090.  
  1091.    /* article number */
  1092.    next_hop = strchr (this_hop, '\t');
  1093.    *(next_hop++) = (char) NULL;
  1094.  
  1095.    header->number = atol (this_hop);
  1096.  
  1097.    /* subject */
  1098.    this_hop = next_hop;
  1099.    next_hop = strchr (this_hop, '\t');
  1100.    *(next_hop++) = (char) NULL;
  1101.  
  1102.    mylstrncpy (header->subject, this_hop, HEADER_SUBJECT_LENGTH);
  1103.    CommDoc->LongestLine = max (CommDoc->LongestLine,
  1104.                 ARTICLE_SUBJECT_OFFSET +
  1105.                 (unsigned) lstrlen (header->subject));
  1106.    /* author */
  1107.    this_hop = next_hop;
  1108.    next_hop = strchr (this_hop, '\t');
  1109.    *(next_hop++) = (char) NULL;
  1110.  
  1111.    ParseAddress (this_hop,
  1112.             AddressString, MAXDIALOGSTRING,
  1113.             NameString, MAXDIALOGSTRING);
  1114.  
  1115.    if (FullNameFrom)
  1116.      mylstrncpy (header->from, NameString, HEADER_FROM_LENGTH);
  1117.    else
  1118.      mylstrncpy (header->from, this_hop, HEADER_FROM_LENGTH);
  1119.  
  1120.    /* date */
  1121.    this_hop = next_hop;
  1122.    next_hop = strchr (this_hop, '\t');
  1123.    *(next_hop++) = (char) NULL;
  1124.  
  1125.    header->date = parse_usenet_date (this_hop);
  1126.  
  1127.    /* message-id */
  1128.    this_hop = next_hop;
  1129.    next_hop = strchr (this_hop, '\t');
  1130.    *(next_hop++) = (char) NULL;
  1131.  
  1132.    mylstrncpy (header->message_id, this_hop, HEADER_MESSAGE_ID_LENGTH);
  1133.  
  1134.    /* references */
  1135.    this_hop = next_hop;
  1136.    next_hop = strchr (this_hop, '\t');
  1137.    *(next_hop++) = (char) NULL;
  1138.  
  1139.    reference = get_best_reference (this_hop);
  1140.    if (reference)
  1141.      mylstrncpy (header->references, reference, HEADER_REFERENCES_LENGTH);
  1142.  
  1143.    /* bytes (ignored) */
  1144.    this_hop = next_hop;
  1145.    next_hop = strchr (this_hop, '\t');
  1146.    *(next_hop++) = (char) NULL;
  1147.  
  1148.    /* lines (last one doesn't have to have the tab */
  1149.    this_hop = next_hop;
  1150.    header->lines = atoi (this_hop);
  1151.  
  1152.    /* set other header fields */
  1153.    header->Selected = FALSE;
  1154.    header->ArtDoc = (TypDoc *) NULL;
  1155.    header->Seen = WasArtSeen (header->number, GroupDoc);
  1156.  
  1157.    unlock_headers (header_handle, thread_handle);
  1158.  
  1159.    CommDoc->ActiveLines++;
  1160.  
  1161.    update_window_title (CommDoc->hDocWnd, group,
  1162.               RcvLineCount++,
  1163.               CommDoc->TotalLines);
  1164.       }
  1165.  
  1166.       break;
  1167.  
  1168.  
  1169.       /* The next few cases handle retrieval of XHDR information for display */
  1170.       /* in the group window.  If you change the number of XHDR's retrieved */
  1171.       /* (such as adding 'XHDR References' back into the state machine), you */
  1172.       /* need to reflect that change in the variable total_xhdrs. */
  1173.  
  1174.       /* the current flow is FROM -> DATE -> LINES -> SUBJECT */
  1175.       /* (threadp) FROM -> DATE -> LINES -> REF -> ID -> SUBJECT */
  1176.  
  1177.       /* this will now be done dynamically, depending on the state of */
  1178.       /* the 'threadp' variable */
  1179.  
  1180.     case ST_XHDR_FROM_START:
  1181.       retcode = 0;
  1182.       sscanf (CommLineIn, "%d", &retcode);
  1183.       total_xhdrs = threadp ? 6 : 4;   /* we do this here to allow */
  1184.       /* mid-session change-of-mind  */
  1185.       if (retcode < 100)
  1186.    break;
  1187.       CommState = ST_XHDR_FROM_DATA;
  1188.       CommDoc->ActiveLines = 0;
  1189.       break;
  1190.  
  1191.     case ST_XHDR_FROM_DATA:
  1192.       if (strcmp (CommLineIn, ".") == 0) {
  1193.    LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1194.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1195.  
  1196.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  1197.    GroupDoc->total_headers = CommDoc->ActiveLines;
  1198.  
  1199.    first = GroupDoc->ServerFirst;
  1200.    last = GroupDoc->ServerLast;
  1201.  
  1202.    GlobalUnlock (BlockPtr->hCurBlock);
  1203.    CommDoc->ActiveLines = 0;
  1204.  
  1205.    /* Now ask for the date lines */
  1206.    mylen = sprintf (mybuf, "XHDR date %ld-%ld", first, last);
  1207.    CommState = ST_XHDR_DATE_START;
  1208.    PutCommLine (mybuf);
  1209.       }
  1210.       else {
  1211.    /*      char neat_from [80]; */
  1212.    /* Access the Group struct, get HANDLE for header data */
  1213.    LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1214.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1215.  
  1216.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  1217.    header_handle = GroupDoc->header_handle;
  1218.    thread_handle = GroupDoc->thread_handle;
  1219.  
  1220.    GlobalUnlock (BlockPtr->hCurBlock);
  1221.  
  1222.    /* Lock the header data */
  1223.    headers = lock_headers (header_handle, thread_handle);
  1224.  
  1225.    sscanf (CommLineIn, "%ld", &artnum);
  1226.    header = header_elt (headers, CommDoc->ActiveLines);
  1227.    header->number = artnum;
  1228.  
  1229.    /* now use some of our nice formatting of email addresses */
  1230.    ParseAddress (get_xhdr_line (CommLineIn),
  1231.             AddressString, MAXDIALOGSTRING,
  1232.             NameString, MAXDIALOGSTRING);
  1233.  
  1234.    /* copy that into headers[].from */
  1235.    if (FullNameFrom)
  1236.      mylstrncpy (header->from, NameString, HEADER_FROM_LENGTH);
  1237.    else
  1238.      mylstrncpy (header->from, AddressString, HEADER_FROM_LENGTH);
  1239.  
  1240.    unlock_headers (header_handle, thread_handle);
  1241.  
  1242.    CommDoc->ActiveLines++;
  1243.  
  1244.    update_window_title (CommDoc->hDocWnd, group,
  1245.               RcvLineCount++,
  1246.               CommDoc->TotalLines * total_xhdrs);
  1247.       }
  1248.  
  1249.       break;
  1250.  
  1251.     case ST_XHDR_DATE_START:
  1252.       retcode = 0;
  1253.       sscanf (CommLineIn, "%d", &retcode);
  1254.       if (check_server_code (retcode))
  1255.    break;
  1256.       CommState = ST_XHDR_DATE_DATA;
  1257.       CommDoc->ActiveLines = 0;
  1258.       break;
  1259.  
  1260.     case ST_XHDR_DATE_DATA:
  1261.       if (strcmp (CommLineIn, ".") == 0) {
  1262.    LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1263.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1264.  
  1265.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  1266.    GroupDoc->total_headers = CommDoc->ActiveLines;
  1267.  
  1268.    first = GroupDoc->ServerFirst;
  1269.    last = GroupDoc->ServerLast;
  1270.  
  1271.    GlobalUnlock (BlockPtr->hCurBlock);
  1272.    CommDoc->ActiveLines = 0;
  1273.  
  1274.    /* Now ask for the #of lines */
  1275.    mylen = sprintf (mybuf, "XHDR lines %ld-%ld", first, last);
  1276.    CommState = ST_XHDR_LINES_START;
  1277.    PutCommLine (mybuf);
  1278.       }
  1279.       else {
  1280.  
  1281.    /* Access the Group struct, get HANDLE for header data */
  1282.    LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1283.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1284.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  1285.    header_handle = GroupDoc->header_handle;
  1286.    thread_handle = GroupDoc->thread_handle;
  1287.  
  1288.    GlobalUnlock (BlockPtr->hCurBlock);
  1289.  
  1290.    /* Lock the header data */
  1291.    headers = lock_headers (header_handle, thread_handle);
  1292.    syncnum = sync_artnum (atol (CommLineIn),
  1293.              (header_elt (headers, CommDoc->ActiveLines))->number,
  1294.                 headers,
  1295.                 GroupDoc);
  1296.    if (syncnum >= 0)
  1297.      (header_elt (headers, syncnum))->date
  1298.        = parse_usenet_date (get_xhdr_line (CommLineIn));
  1299.  
  1300.    unlock_headers (header_handle, thread_handle);
  1301.  
  1302.    CommDoc->ActiveLines++;
  1303.    update_window_title (CommDoc->hDocWnd, group,
  1304.               RcvLineCount++,
  1305.               CommDoc->TotalLines * total_xhdrs);
  1306.       }
  1307.  
  1308.       break;
  1309.  
  1310.     case ST_XHDR_LINES_START:
  1311.       retcode = 0;
  1312.       sscanf (CommLineIn, "%d", &retcode);
  1313.       if (check_server_code (retcode))
  1314.    break;
  1315.       CommState = ST_XHDR_LINES_DATA;
  1316.       CommDoc->ActiveLines = 0;
  1317.       break;
  1318.  
  1319.     case ST_XHDR_LINES_DATA:
  1320.       if (strcmp (CommLineIn, ".") == 0) {
  1321.    LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1322.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1323.  
  1324.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  1325.    GroupDoc->total_headers = CommDoc->ActiveLines;
  1326.  
  1327.    first = GroupDoc->ServerFirst;
  1328.    last = GroupDoc->ServerLast;
  1329.  
  1330.    GlobalUnlock (BlockPtr->hCurBlock);
  1331.    CommDoc->ActiveLines = 0;
  1332.  
  1333.    /* Check for threading option, if enabled, go to REF & ID */
  1334.    /* states first */
  1335.  
  1336.    if (threadp) {
  1337.      CommState = ST_XHDR_REF_START;
  1338.      mylen = sprintf (mybuf, "XHDR references %ld-%ld", first, last);
  1339.      PutCommLine (mybuf);
  1340.    }
  1341.    else {
  1342.      CommState = ST_XHDR_SUBJECT_START;
  1343.      mylen = sprintf (mybuf, "XHDR subject %ld-%ld", first, last);
  1344.      PutCommLine (mybuf);
  1345.    }
  1346.       }
  1347.  
  1348.       else {
  1349.  
  1350.    /* Access the Group struct, get HANDLE for header data */
  1351.    LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1352.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1353.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  1354.  
  1355.    header_handle = GroupDoc->header_handle;
  1356.    thread_handle = GroupDoc->thread_handle;
  1357.  
  1358.    GlobalUnlock (BlockPtr->hCurBlock);
  1359.  
  1360.    /* Lock the header data */
  1361.    headers = lock_headers (header_handle, thread_handle);
  1362.  
  1363.    syncnum = sync_artnum (atol (CommLineIn),
  1364.              (header_elt (headers, CommDoc->ActiveLines))->number,
  1365.                 headers,
  1366.                 GroupDoc);
  1367.    if (syncnum >= 0)
  1368.      sscanf (CommLineIn, "%ld %Fd", &artnum, &((header_elt (headers, syncnum))->lines));
  1369.  
  1370.    unlock_headers (header_handle, thread_handle);
  1371.    CommDoc->ActiveLines++;
  1372.    update_window_title (CommDoc->hDocWnd, group,
  1373.               RcvLineCount++,
  1374.               CommDoc->TotalLines * total_xhdrs);
  1375.       }
  1376.  
  1377.       break;
  1378.  
  1379.     case ST_XHDR_REF_START:
  1380.       retcode = 0;
  1381.       sscanf (CommLineIn, "%d", &retcode);
  1382.       if (check_server_code (retcode))
  1383.    break;
  1384.       CommState = ST_XHDR_REF_DATA;
  1385.       CommDoc->ActiveLines = 0;
  1386.       break;
  1387.  
  1388.     case ST_XHDR_REF_DATA:
  1389.       if (strcmp (CommLineIn, ".") == 0) {
  1390.    LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1391.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1392.  
  1393.    GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  1394.    GroupDoc->total_headers = CommDoc->ActiveLines;
  1395.  
  1396.    first = GroupDoc->ServerFirst;
  1397.    last = GroupDoc->ServerLast;
  1398.  
  1399.    GlobalUnlock (BlockPtr->hCurBlock);
  1400.    CommDoc->ActiveLines = 0;
  1401.  
  1402.    /* Now ask for the message-id lines */
  1403.    mylen = sprintf (mybuf, "XHDR message-id %ld-%ld", first, last);
  1404.    CommState = ST_XHDR_MID_START;
  1405.    PutCommLine (mybuf);
  1406.       }
  1407.       else {
  1408.    char far *refer;  /* , far * end,far * bracket1,far *bracket2; */
  1409.    /*      int bracket_len; */
  1410.  
  1411.    /* Access the Group struct, get HANDLE for header data */
  1412.    LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1413.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1414.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  1415.  
  1416.    header_handle = GroupDoc->header_handle;
  1417.    thread_handle = GroupDoc->thread_handle;
  1418.  
  1419.    GlobalUnlock (BlockPtr->hCurBlock);
  1420.  
  1421.    /* Lock the header data */
  1422.    headers = lock_headers (header_handle, thread_handle);
  1423.  
  1424.    /* for now, we only pay attention to first (whole) referral */
  1425.    refer = get_xhdr_line (CommLineIn);
  1426.  
  1427.    refer = get_best_reference (refer);
  1428.  
  1429.    if (refer) {
  1430.      /* Patch to check for bad info from server JD 6/19/93 */
  1431.      syncnum = sync_artnum (atol (CommLineIn),
  1432.              (header_elt (headers,
  1433.                      CommDoc->ActiveLines))->number,
  1434.              headers, GroupDoc);
  1435.      if (syncnum >= 0)
  1436.        mylstrncpy ((header_elt (headers, syncnum))->references,
  1437.          refer, HEADER_REFERENCES_LENGTH);
  1438.    }
  1439.  
  1440.    unlock_headers (header_handle, thread_handle);
  1441.  
  1442.    CommDoc->ActiveLines++;
  1443.    update_window_title (CommDoc->hDocWnd, group,
  1444.               RcvLineCount++,
  1445.               CommDoc->TotalLines * total_xhdrs);
  1446.  
  1447.       }
  1448.  
  1449.       break;
  1450.  
  1451.  
  1452.     case ST_XHDR_MID_START:
  1453.       retcode = 0;
  1454.       sscanf (CommLineIn, "%d", &retcode);
  1455.       if (check_server_code (retcode))
  1456.    break;
  1457.       CommState = ST_XHDR_MID_DATA;
  1458.       CommDoc->ActiveLines = 0;
  1459.       break;
  1460.  
  1461.     case ST_XHDR_MID_DATA:
  1462.       if (strcmp (CommLineIn, ".") == 0) {
  1463.    LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1464.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1465.  
  1466.    GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  1467.  
  1468.    GroupDoc->total_headers = CommDoc->ActiveLines;
  1469.  
  1470.    first = GroupDoc->ServerFirst;
  1471.    last = GroupDoc->ServerLast;
  1472.  
  1473.    GlobalUnlock (BlockPtr->hCurBlock);
  1474.    CommDoc->ActiveLines = 0;
  1475.  
  1476.    /* Now ask for the subject lines */
  1477.    mylen = sprintf (mybuf, "XHDR subject %ld-%ld", first, last);
  1478.    CommState = ST_XHDR_SUBJECT_START;
  1479.    PutCommLine (mybuf);
  1480.       }
  1481.       else {
  1482.    /* Access the Group struct, get HANDLE for header data */
  1483.    LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1484.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1485.  
  1486.    GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  1487.  
  1488.    header_handle = GroupDoc->header_handle;
  1489.    thread_handle = GroupDoc->thread_handle;
  1490.  
  1491.    GlobalUnlock (BlockPtr->hCurBlock);
  1492.  
  1493.    /* Lock the header data */
  1494.    headers = lock_headers (header_handle, thread_handle);
  1495.  
  1496.    syncnum = sync_artnum (atol (CommLineIn),
  1497.              (header_elt (headers, CommDoc->ActiveLines))->number,
  1498.                 headers,
  1499.                 GroupDoc);
  1500.    if (syncnum >= 0)
  1501.      mylstrncpy ((header_elt (headers, syncnum))->message_id,
  1502.             (char far *) (get_xhdr_line (CommLineIn)),
  1503.             HEADER_MESSAGE_ID_LENGTH); /* bad, hardcoded. */
  1504.  
  1505.    unlock_headers (header_handle, thread_handle);
  1506.  
  1507.    CommDoc->ActiveLines++;
  1508.    update_window_title (CommDoc->hDocWnd, group,
  1509.               RcvLineCount++,
  1510.               CommDoc->TotalLines * total_xhdrs);
  1511.  
  1512.       }
  1513.  
  1514.       break;
  1515.  
  1516.  
  1517.     case ST_XHDR_SUBJECT_START:
  1518.       retcode = 0;
  1519.       sscanf (CommLineIn, "%d", &retcode);
  1520.       if (check_server_code (retcode))
  1521.    break;
  1522.       CommState = ST_XHDR_SUBJECT_DATA;
  1523.       break;
  1524.  
  1525.     case ST_XHDR_SUBJECT_DATA:
  1526.  
  1527.       if (strcmp (CommLineIn, ".") == 0) {
  1528.    CommState = ST_IN_GROUP;
  1529.    CommBusy = FALSE;
  1530.    finish_header_retrieval (CommDoc);
  1531.    InvalidateRect (CommDoc->hDocWnd, NULL, FALSE);
  1532.       }
  1533.       else {
  1534.  
  1535.    artnum = 0;
  1536.    sscanf (CommLineIn, "%ld", &artnum);
  1537.    if (artnum) {
  1538.      LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1539.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1540.  
  1541.      GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  1542.      header_handle = GroupDoc->header_handle;
  1543.      thread_handle = GroupDoc->thread_handle;
  1544.      headers = lock_headers (header_handle, thread_handle);
  1545.  
  1546.      /* update the seen thing. */
  1547.      syncnum = sync_artnum (atol (CommLineIn),
  1548.              (header_elt (headers, CommDoc->ActiveLines))->number,
  1549.              headers,
  1550.              GroupDoc);
  1551.      if (syncnum >= 0)
  1552.        header = header_elt (headers, syncnum);
  1553.      else
  1554.        header = header_elt (headers, CommDoc->ActiveLines);
  1555.  
  1556.      header->Selected = FALSE;
  1557.      header->ArtDoc = (TypDoc *) NULL;
  1558.      header->Seen =
  1559.        WasArtSeen (artnum, (TypGroup far *) (((char far *) LinePtr) +
  1560.                     sizeof (TypLine)));
  1561.  
  1562.      UnlockLine (BlockPtr, LinePtr, &(CommDoc->hParentBlock),
  1563.             &(CommDoc->ParentOffset), &(CommDoc->ParentLineID));
  1564.  
  1565.      mylstrncpy (header->subject,
  1566.             get_xhdr_line (CommLineIn), HEADER_SUBJECT_LENGTH);
  1567.  
  1568.      CommDoc->LongestLine = max (CommDoc->LongestLine,
  1569.                   ARTICLE_SUBJECT_OFFSET +
  1570.                   (unsigned) lstrlen (header->subject));
  1571.  
  1572.      unlock_headers (header_handle, thread_handle);
  1573.      CommDoc->ActiveLines++;
  1574.      update_window_title (CommDoc->hDocWnd, group,
  1575.                 RcvLineCount++,
  1576.                 CommDoc->TotalLines * total_xhdrs);
  1577.  
  1578.    }
  1579.       }
  1580.  
  1581.       break;
  1582.  
  1583.     case ST_IN_GROUP:
  1584.       break;
  1585.  
  1586.     case ST_ARTICLE_RESP:
  1587.       retcode = 0;
  1588.       sscanf (CommLineIn, "%d", &retcode);
  1589.       if (check_server_code (retcode)) {
  1590.    if (CommDoc->hDocWnd)
  1591.      DestroyWindow (CommDoc->hDocWnd);
  1592.    break;
  1593.       }
  1594.       CommState = ST_REC_ARTICLE_HEADER;
  1595.       /*      Bossanova = FALSE; */
  1596.       break;
  1597.  
  1598.     case ST_REC_ARTICLE_HEADER:
  1599.       if (strcmp (CommLineIn, ".") == 0) {
  1600.    ;        /* error: empty article (end in middle of header) */
  1601.  
  1602.       }
  1603.       if (IsBlankStr (CommLineIn))  /* headers end in blank line */
  1604.    CommState = ST_REC_ARTICLE;
  1605.       AddCommLineToDoc (CommLineIn);
  1606.       break;
  1607.  
  1608.     case ST_REC_ARTICLE:
  1609.       if (strcmp (CommLineIn, ".") == 0) {   /* article receive complete */
  1610.  
  1611.    CommState = ST_IN_GROUP;
  1612.    CommBusy = FALSE;
  1613.  
  1614.    if (CommDecoding) {
  1615.      SendMessage (currentCoded->hParentWnd, IDM_ARTICLE_RETRIEVE_COMPLETE, 0, 0);
  1616.      break;
  1617.    }
  1618.    else
  1619.    {
  1620.           SendMessage (CommDoc->ParentDoc->hDocWnd, IDM_ARTICLE_RETRIEVE_COMPLETE, 0, 0);
  1621.           SendMessage(CommDoc->hDocWnd, IDM_ARTICLE_RETRIEVE_COMPLETE, 0, 0);
  1622.         }
  1623.  
  1624.    LockLine (CommDoc->ParentDoc->hParentBlock,
  1625.         CommDoc->ParentDoc->ParentOffset,
  1626.         CommDoc->ParentDoc->ParentLineID,
  1627.         &BlockPtr, &LinePtr);
  1628.  
  1629.    GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  1630.    header_handle = GroupDoc->header_handle;
  1631.    thread_handle = GroupDoc->thread_handle;
  1632.  
  1633.    headers = lock_headers (header_handle, thread_handle);
  1634.    lpsz = (char far *) ((header_elt (headers, CommDoc->LastSeenLineID))->subject);
  1635.    unlock_headers (header_handle, thread_handle);
  1636.  
  1637.    mylstrncpy (group, lpsz, MAXGROUPNAME);
  1638.    sprintf (mybuf, "%s (%u lines)", group, CommDoc->TotalLines);
  1639.    SetWindowText (CommDoc->hDocWnd, mybuf);
  1640.    InvalidateRect (CommDoc->hDocWnd, NULL, FALSE);
  1641.    GlobalUnlock (BlockPtr->hCurBlock);
  1642.  
  1643.    /* Skip to the first line of the text of the article
  1644.     * and make sure it's visible on the screen.  This is
  1645.     * so that the user doesn't have to have the first
  1646.     * screen filled with a lengthy, worthless header.
  1647.     *
  1648.     * and save number of header lines (on display)
  1649.     * for later (Bretherton)
  1650.     */
  1651.    TopOfDoc (CommDoc, &BlockPtr, &LinePtr);
  1652.    found = FALSE;
  1653.    do {
  1654.      lpsz = ((char far *) LinePtr + sizeof (TypLine) + sizeof (TypText));
  1655.      if (IsLineBlank (lpsz)) {
  1656.        found = TRUE;
  1657.        CommDoc->HeaderLines = WhatLine (BlockPtr, LinePtr);
  1658.        break;
  1659.      }
  1660.      if (!NextLine (&BlockPtr, &LinePtr))
  1661.        break;
  1662.    }
  1663.    while (!found);
  1664.    NextLine (&BlockPtr, &LinePtr);
  1665.  
  1666.    /* If the line is in the last screen's worth of lines, back
  1667.     * up the pointer so it points to the first line of the last
  1668.     * screen.
  1669.     */
  1670.    if (found && CommDoc->TotalLines > CommDoc->ScYLines &&
  1671.        !CommDoc->TopScLineID)
  1672.      AdjustTopSc (BlockPtr, LinePtr);
  1673.  
  1674.    UnlockLine (BlockPtr, LinePtr, &hBlock, &Offset, &MyLineID);
  1675.       }
  1676.       else        /* not finished, continue article receive */
  1677.    AddCommLineToDoc (CommLineIn);
  1678.  
  1679.       break;
  1680.  
  1681.     case ST_POST_WAIT_PERMISSION:
  1682.  
  1683.       /*      WndPost = getWndEdit(WndPosts,CommWnd,MAXPOSTWNDS) ; */
  1684.       /*      found = (WndPost != NULL) ; */
  1685.  
  1686.       /* lock out changes */
  1687.       SendMessage (PostEdit->hWndEdit, EM_SETREADONLY, TRUE, 0L);
  1688.  
  1689.       retcode = 0;
  1690.       sscanf (CommLineIn, "%u", &retcode);
  1691.  
  1692.       if (retcode == 340) {
  1693.    if (Attaching && !ReviewAttach)
  1694.      ProcessAttach (CONTINUE);
  1695.    else
  1696.      PostText (PostEdit);
  1697.       }
  1698.       else {
  1699.    check_server_code (retcode);
  1700.    MessageBox (PostEdit->hWnd, CommLineIn + 4, "Cannot Post Article",
  1701.           MB_OK | MB_ICONEXCLAMATION);
  1702.    CommBusy = FALSE;
  1703.    CommState = ST_NONE;
  1704.  
  1705.    if (Attaching && !ReviewAttach)
  1706.      ProcessAttach (ABORT);   /* cancel attachment */
  1707.  
  1708.    else
  1709.      /* unlock to allow user modification */
  1710.      SendMessage (PostEdit->hWndEdit, EM_SETREADONLY, FALSE, 0L);
  1711.       }
  1712.       break;
  1713.  
  1714.     case ST_POST_WAIT_END:
  1715.  
  1716.       /*      WndPost = getWndEdit(WndPosts,CommWnd,MAXPOSTWNDS) ; */
  1717.       /*      found = (WndPost != NULL) ; */
  1718.  
  1719.       /* no check for failure to find posting documents */
  1720.       retcode = 0;
  1721.       sscanf (CommLineIn, "%d", &retcode);
  1722.       if (retcode == 441 || retcode == 440) {
  1723.    CompletePost(PostEdit, FAIL);
  1724.    done = TRUE;
  1725.    nextBatchIndex = 0;  /* cancel any batch */
  1726.  
  1727.    if (Attaching && !ReviewAttach)
  1728.      ProcessAttach (ABORT);/* cancel attachment */
  1729.  
  1730.       }
  1731.       else if (retcode == 240) {
  1732.    CompletePost(PostEdit, SUCCESS);
  1733.    done = TRUE;
  1734.       }
  1735.       else if (check_server_code (retcode))
  1736.    break;
  1737.  
  1738.       if (done) {
  1739.    CommBusy = FALSE;
  1740.    CommState = ST_NONE;
  1741.    PostEdit = (WndEdit *) NULL;
  1742.  
  1743.    if (nextBatchIndex)  /* if we're sending a batch, send the next */
  1744.      BatchSend (DOCTYPE_POSTING);
  1745.       }
  1746.       if (Attaching && !ReviewAttach)
  1747.    ProcessAttach (CONTINUE);
  1748.       break;
  1749.  
  1750.       /* the following code is for an MRR-hacked nntp server */
  1751.  
  1752.     case ST_GROUP_REJOIN:
  1753.       CommState = ST_ARTICLE_RESP;
  1754.       break;
  1755.     }
  1756.   }
  1757. }
  1758.  
  1759. BOOL
  1760. isLineQuotation (char *textptr)
  1761. {
  1762.   char *loc;
  1763.   loc = memchr (textptr, QuoteLineInd, 2);
  1764.   if (!loc)
  1765.     loc = memchr (textptr, '|', 2);
  1766.   if (!loc)
  1767.     loc = memchr (textptr, ':', 2);
  1768.   return (loc != NULL);
  1769. }
  1770.  
  1771.  
  1772. /*-- function AddCommLineToDoc ---------------------------------------
  1773.  *
  1774.  *  Adds the given line to the comm doc
  1775.  */
  1776. void
  1777. AddCommLineToDoc (char *line)
  1778. {
  1779.   TypLine far *LinePtr;
  1780.   TypBlock far *BlockPtr;
  1781.   char *cptr, *cdest;
  1782.   int col, mylen;
  1783.   char artline[MAXINTERNALLINE];
  1784.  
  1785.   /* special case for lines starting with '..' */
  1786.   if (strncmp (CommLineIn, "..", 2))
  1787.     cptr = CommLineIn;
  1788.   else
  1789.     cptr = CommLineIn + 1;
  1790.  
  1791.   if (CommDecoding) {
  1792.     DecodeLine (currentCoded, cptr);
  1793.     return;
  1794.   }
  1795.   /* Copy this line into an image of a textblock line,
  1796.    * expanding tabs.
  1797.    */
  1798.   cdest = artline + sizeof (TypLine) + sizeof (TypText);
  1799.   for (col = 0;
  1800.   *cptr && col < (MAXINTERNALLINE - 3 * sizeof (TypLine) - sizeof (TypText));
  1801.        cptr++) {
  1802.     if (*cptr == '\t') {
  1803.       do {
  1804.    *(cdest++) = ' ';
  1805.       }
  1806.       while (++col & 7);
  1807.     }
  1808.     else {
  1809.       *(cdest++) = *cptr;
  1810.       col++;
  1811.     }
  1812.   }
  1813.   *(cdest++) = '\0';
  1814.  
  1815.   ((TypLine *) artline)->LineID = NextLineID++;
  1816.   LockLine (CommDoc->hCurAddBlock, CommDoc->AddOffset, CommDoc->AddLineID, &BlockPtr, &LinePtr);
  1817.   mylen = (cdest - artline) + sizeof (int);
  1818.   mylen += mylen % 2;
  1819.   ((TypText *) (artline + sizeof (TypLine)))->NameLen =
  1820.     (cdest - 1) - (artline + sizeof (TypLine) + sizeof (TypText));
  1821.   ((TypLine *) artline)->length = mylen;
  1822.   ((TypLine *) artline)->active = TRUE;
  1823.   *((int *) (artline + mylen - sizeof (int))) = mylen;
  1824.   AddLine ((TypLine *) artline, &BlockPtr, &LinePtr);
  1825.   CommDoc->LongestLine = max (CommDoc->LongestLine, (unsigned) mylen);
  1826.   CommDoc->ActiveLines++;
  1827.   UnlockLine (BlockPtr, LinePtr, &(CommDoc->hCurAddBlock),
  1828.          &(CommDoc->AddOffset), &(CommDoc->AddLineID));
  1829.  
  1830.   if ((CommDoc->TotalLines % UPDATE_ART_FREQ) == 0)
  1831.     InvalidateRect (CommDoc->hDocWnd, NULL, FALSE);
  1832. }
  1833.  
  1834. /*-- function WasArtSeen ---------------------------------------------
  1835.  *
  1836.  *  Determines whether (according to the information in a TypGroup entry)
  1837.  *  a given article number was seen.
  1838.  *
  1839.  *  Returns TRUE iff the article has been seen.
  1840.  */
  1841. BOOL
  1842. WasArtSeen (ArtNum, GroupPtr)
  1843.      unsigned long ArtNum;
  1844.      TypGroup far *GroupPtr;
  1845. {
  1846.   TypRange far *RangePtr = (TypRange far *) ((char far *)
  1847.             GroupPtr + RangeOffset (GroupPtr->NameLen));
  1848.   unsigned int nr;
  1849.  
  1850.   for (nr = 0; nr < GroupPtr->nRanges; nr++) {
  1851.     if (ArtNum >= (unsigned long) RangePtr->First &&
  1852.    ArtNum <= (unsigned long) RangePtr->Last) {
  1853.       return (TRUE);
  1854.     }
  1855.     else {
  1856.       RangePtr++;
  1857.     }
  1858.   }
  1859.   return (FALSE);
  1860. }
  1861.  
  1862.  
  1863. /*--- function mylstrncmp -----------------------------------------------
  1864.  *
  1865.  *   Just like strncmp, except takes long pointers.
  1866.  */
  1867. int
  1868. mylstrncmp (ptr1, ptr2, len)
  1869.      char far *ptr1;
  1870.      char far *ptr2;
  1871.      int len;
  1872. {
  1873.   for (; len--; ptr1++, ptr2++) {
  1874.     if (*ptr1 > *ptr2) {
  1875.       return (1);
  1876.     }
  1877.     else if (*ptr1 < *ptr2) {
  1878.       return (-1);
  1879.     }
  1880.   }
  1881.   return (0);
  1882. }
  1883.  
  1884. /*--- function mylstrncpy -----------------------------------------------
  1885.  *
  1886.  *   Just like strncpy, except takes long pointers.
  1887.  */
  1888. char far *
  1889. mylstrncpy (ptr1, ptr2, len)
  1890.      char far *ptr1;
  1891.      char far *ptr2;
  1892.      int len;
  1893. {
  1894.   char far *targ = ptr1;
  1895.  
  1896.   for (; --len && *ptr2; ptr1++, ptr2++) {
  1897.     *ptr1 = *ptr2;
  1898.   }
  1899.   *ptr1 = '\0';
  1900.   return (targ);
  1901. }
  1902.  
  1903. /* this is a temporary test... */
  1904. char far *
  1905. mylstrcpy (ptr1, ptr2)
  1906.      char_p ptr1;
  1907.      char far *ptr2;
  1908. {
  1909.   char far *targ = ptr1;
  1910.   for (; *ptr2; ptr1++, ptr2++) {
  1911.     *ptr1 = *ptr2;
  1912.   }
  1913.   *ptr1 = '\0';
  1914.   return (targ);
  1915. }
  1916.  
  1917. #if 0
  1918. /*--- function lstrcmpnoblank ------------------------------------------
  1919.  *
  1920.  *   Like strcmp, except takes long pointers and also stops at
  1921.  *   the first blank.
  1922.  */
  1923. int
  1924. lstrcmpnoblank (str1, str2)
  1925.      char far **str1;
  1926.      char far **str2;
  1927. {
  1928.   register char far *s1 = *str1, far * s2 = *str2;
  1929.  
  1930.   for (; *s1 && *s2 && *s1 != ' ' && *s2 != ' '; s1++, s2++) {
  1931.     if (*s1 > *s2) {
  1932.       return (1);
  1933.     }
  1934.     else if (*s1 < *s2) {
  1935.       return (-1);
  1936.     }
  1937.   }
  1938.   if (*s1 == *s2) {
  1939.     return (0);
  1940.   }
  1941.   else if (*s1) {
  1942.     return (1);
  1943.   }
  1944.   else {
  1945.     return (-1);
  1946.   }
  1947. }
  1948. #endif
  1949.  
  1950. void
  1951. finish_header_retrieval ()
  1952. {
  1953.   TypLine far *LinePtr;
  1954.   TypBlock far *BlockPtr;
  1955.   TypGroup far *GroupDoc;
  1956.   HANDLE header_handle, thread_handle;
  1957. /*  HANDLE hBlock; */
  1958.   char far *lpsz;
  1959.   char group[MAXGROUPNAME];
  1960.   char mybuf[MAXINTERNALLINE];
  1961.   header_p headers;
  1962.  
  1963.   /* release the mouse that is captured to the usenet window */
  1964.   ReleaseCapture ();
  1965.  
  1966.   CommDoc->TotalLines = CommDoc->ActiveLines;
  1967.   /* Disabled by MRR so that ActiveLines is the number of lines
  1968.    * we should display in the Group window.  Eventually, will
  1969.    * change it so that ActiveLines will count only unread articles
  1970.    * if the user desires.
  1971.    */
  1972.   /* CommDoc->ActiveLines = 0; */
  1973.   /* Fetch this group's line in NetDoc so we can get the
  1974.    * group's name for the window's title bar.
  1975.    */
  1976.   LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  1977.        CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  1978.  
  1979.   GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  1980.   header_handle = GroupDoc->header_handle;
  1981.   thread_handle = GroupDoc->thread_handle;
  1982.   lock_headers (header_handle, thread_handle);
  1983.  
  1984.   if (threadp) {
  1985.     SetWindowText (CommDoc->hDocWnd, "sorting headers...");
  1986.     sort_by_threads (header_handle, thread_handle, CommDoc->TotalLines);
  1987.   }
  1988.  
  1989.   unlock_headers (header_handle, thread_handle);
  1990.  
  1991.   GroupDoc->total_headers = CommDoc->TotalLines;
  1992.  
  1993.   lpsz = (char far *) (((char far *) LinePtr) +
  1994.              sizeof (TypLine) + sizeof (TypGroup));
  1995.  
  1996.   mylstrncpy (group, lpsz, MAXGROUPNAME);
  1997.   sprintf (mybuf, "%s (%u articles)", group, CommDoc->TotalLines);
  1998.   SetWindowText (CommDoc->hDocWnd, mybuf);
  1999.  
  2000.   /* If we have information from NEWSRC on the highest-
  2001.    * numbered article previously seen, position the window
  2002.    * so the new articles can be seen without scrolling.
  2003.    */
  2004.   {
  2005.     unsigned int i;
  2006.  
  2007.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  2008.          CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  2009.  
  2010.     /* inside the lock, can access the GroupStruct */
  2011.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  2012.     header_handle = GroupDoc->header_handle;
  2013.     thread_handle = GroupDoc->thread_handle;
  2014.     headers = lock_headers (header_handle, thread_handle);
  2015.  
  2016.     if (CommDoc->TotalLines > 0)
  2017.       for (i = CommDoc->TotalLines - 1;
  2018.       ((i > 0) && ((header_elt (headers, i))->Seen == FALSE));
  2019.       i--);
  2020.     CommDoc->TopLineOrd = (i > 5) ? i - 4 : 0;
  2021.  
  2022.     unlock_headers (header_handle, thread_handle);
  2023.   }
  2024.  
  2025.   SendMessage (CommDoc->hDocWnd, IDM_RETRIEVE_COMPLETE, 0, 0);
  2026.   InvalidateRect (CommDoc->hDocWnd, NULL, FALSE);
  2027. }
  2028.  
  2029. /*
  2030.  * Look through the MAIL or Post edits and return the edit with
  2031.  * matching window handle Consider - centralising initial window
  2032.  * location in wvmail and wndpost using a single array (save passing
  2033.  * structure and size into this module)
  2034.  *
  2035.  */
  2036.  
  2037. WndEdit *
  2038. getWndEdit (WndEdit * WndEdits, HWND hWnd, int numEntries)
  2039. {
  2040.   int ih;
  2041.  
  2042.   for (ih = 0; ih < numEntries; ih++) {
  2043.     if (WndEdits[ih].hWnd == hWnd) {
  2044.       return &WndEdits[ih];
  2045.     }
  2046.   }
  2047.  
  2048.   /*MessageBox(0,"getWndEditFound Nothing","mrb debug", MB_OK | MB_ICONHAND); */
  2049.  
  2050.   return (WndEdit *) NULL;
  2051. }
  2052.  
  2053.  
  2054.  
  2055. /* ------------------------------------------------------------------------
  2056.  * Replace any white space at end of string with NULL's
  2057.  * JSC 11/1/93
  2058.  */
  2059. void
  2060. RemoveTrailingWhiteSpace (char *str)
  2061. {
  2062.   register int i;
  2063.  
  2064.   for (i = strlen (str) - 1; i > 0 && isspace (str[i]); i--)
  2065.     str[i] = '\0';
  2066. }
  2067.  
  2068. /*------------------------------------------------------------------------------
  2069.  * IsBlankStr
  2070.  * Returns true if the string is entirely whitespace, else false
  2071.  * JSC 12/6/93
  2072.  */
  2073. BOOL
  2074. IsBlankStr (char *temp)
  2075. {
  2076.   register char *ptr;
  2077.  
  2078.   for (ptr = temp; *ptr; ptr++)
  2079.     if (!isspace (*ptr))
  2080.       return (FALSE);
  2081.   return (TRUE);
  2082. }
  2083.  
  2084. /*------------------------------------------------------------------------------
  2085.  * isnumber
  2086.  * Returns true if the string is a all digits
  2087.  * JSC 12/6/93
  2088.  */
  2089. BOOL
  2090. isnumber (char *str)
  2091. {
  2092.   char *ptr;
  2093.  
  2094.   for (ptr = str; *ptr != '\0'; ptr++)
  2095.     if (!isdigit (*ptr))
  2096.       return (FALSE);
  2097.   return (TRUE);
  2098. }
  2099.  
  2100. /* ------------------------------------------------------------------------
  2101.  *    Open the common font dialog
  2102.  *      Place resulting selection name and size in face,style and size
  2103.  *      Note: to select a printer font, send style as "Printer"
  2104.  *      printer font selection ignores any chosen style
  2105.  *      (JSC 1/9/94)
  2106.  */
  2107. BOOL
  2108. AskForFont (HWND hParentWnd, char *face, int *size, char *style)
  2109. {
  2110.   LOGFONT lf;
  2111.   CHOOSEFONT cf;
  2112.   HDC hDC;
  2113.  
  2114.   memset (&lf, 0, sizeof (LOGFONT));
  2115.   strcpy (lf.lfFaceName, face);
  2116.   /* convert points to logical units (1 pt = 1/72 inch) */
  2117.   /* For printer fonts, use ScreenYPixels here anyway - the choosefont */
  2118.   /* dialog appears to require the lfHeight to be in screen units */
  2119.   /* we will convert point size to PrinterUnits in InitPrinterFonts() */
  2120.   lf.lfHeight = -MulDiv (*size, ScreenYPixels, 72);
  2121.  
  2122.   memset (&cf, 0, sizeof (CHOOSEFONT));
  2123.   cf.lStructSize = sizeof (CHOOSEFONT);
  2124.   cf.hwndOwner = hParentWnd;
  2125.   cf.lpLogFont = &lf;
  2126.   if (!stricmp (style, "Printer")) {
  2127.     cf.nFontType = PRINTER_FONTTYPE;
  2128.     hDC = GetPrinterDC (hParentWnd);
  2129.     cf.hDC = hDC;
  2130.     cf.Flags = CF_PRINTERFONTS | CF_INITTOLOGFONTSTRUCT | CF_FORCEFONTEXIST;
  2131.   }
  2132.   else {
  2133.     cf.nFontType = SCREEN_FONTTYPE;
  2134.     cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_USESTYLE | CF_FORCEFONTEXIST;
  2135.     cf.lpszStyle = style;
  2136.   }
  2137.   if (!ChooseFont (&cf))
  2138.     return (FAIL);
  2139.  
  2140. /*      if (!stricmp (style, "Printer"))      // commented out JD 6/17/94 */
  2141.   /*         ReleaseDC (hWndConf, hDC);  */
  2142.  
  2143. /*      if (!stricmp (style, "Printer")) */
  2144.   /*         DeletePrinterDC (hDC); */
  2145.  
  2146.   *size = cf.iPointSize / 10; /* iPointSize is in tenths of a point */
  2147.  
  2148.   strcpy (face, lf.lfFaceName);
  2149.   return (SUCCESS);
  2150. }
  2151.  
  2152. /* ------------------------------------------------------------------------
  2153.  *    Open the common color dialog
  2154.  *      (JSC 1/9/94)
  2155.  */
  2156. BOOL
  2157. AskForColor (HWND hParentWnd, COLORREF * color)
  2158. {
  2159.   CHOOSECOLOR cc;
  2160.   COLORREF nearC;
  2161.   HDC hDC;
  2162.  
  2163.   memset (&cc, 0, sizeof (CHOOSECOLOR));
  2164.   cc.lStructSize = sizeof (CHOOSECOLOR);
  2165.   cc.hwndOwner = hParentWnd;
  2166.   cc.rgbResult = *color;
  2167.   cc.lpCustColors = CustomColors;
  2168.   cc.Flags = CC_RGBINIT;
  2169.  
  2170.   if (!ChooseColor (&cc))
  2171.     return (FAIL);
  2172.  
  2173.   /* until we figure out how to deal with dithered colors, force */
  2174.   /* the color to the nearest physical color */
  2175.   hDC = GetDC (hParentWnd);
  2176.   nearC = GetNearestColor (hDC, cc.rgbResult);
  2177.   if (cc.rgbResult != nearC)
  2178.     MessageBox (hParentWnd, "WinVn does not currently support dithered (non-solid) colors.\nThe nearest physical solid color has been selected.",
  2179.       "Sorry", MB_OK | MB_ICONINFORMATION);
  2180.   *color = nearC;
  2181.   ReleaseDC (hParentWnd, hDC);
  2182.   return (SUCCESS);
  2183. }
  2184.  
  2185. /* ------------------------------------------------------------------------
  2186.  * This should be used instead of EM_GETHANDLE on global edit buf
  2187.  * Returns a string containing the contents of an edit wnd
  2188.  * It is the reponsibility of the caller to GlobalFreePtr the string
  2189.  * (JSC)
  2190.  */
  2191. char *
  2192. GetEditText (HWND hWndEdit)
  2193. {
  2194.   unsigned int size;
  2195.   char *newText;
  2196.  
  2197.   /* SendMessage (hWndEdit, EM_FMTLINES, TRUE, 0); */
  2198.  
  2199.   size = (unsigned int) SendMessage (hWndEdit, WM_GETTEXTLENGTH, 0, 0L) + 1;
  2200.  
  2201.   if ((newText = (char *) GlobalAllocPtr (GMEM_MOVEABLE, size * sizeof (char))) == NULL) {
  2202.     MessageBox (hWndEdit, "Memory allocation failure", "Edit Text", MB_OK);
  2203.     return (NULL);
  2204.   }
  2205.   if (SendMessage (hWndEdit, WM_GETTEXT, size, (LPARAM) ((LPCSTR) newText)) != (long) (size - 1)) {
  2206.     MessageBox (hWndEdit, "Failed to get text", "Edit Text", MB_OK);
  2207.     return (NULL);
  2208.   }
  2209.  
  2210.   return (newText);
  2211. }
  2212. LRESULT
  2213. SetEditText (HWND hWndEdit, char *editMem)
  2214. {
  2215.   return (SendMessage (hWndEdit, WM_SETTEXT, 0, (LPARAM) (LPCSTR) editMem));
  2216. }
  2217.  
  2218. /* ------------------------------------------------------------------------
  2219.  * To maximize amount of data allowable in posting, allocate a new
  2220.  * data segment for this posting from the Global heap, and set the
  2221.  * window hInstance to this segment
  2222.  * Don't forget you can't use EM_GET/SETHANDLE on an edit buf with
  2223.  * a global mem segment
  2224.  */
  2225. BOOL
  2226. CreateEditWnd (WndEdit * NewWnd)
  2227. {
  2228. #ifndef _WIN32
  2229.   GLOBALHANDLE editDS;
  2230.   LPVOID lpPtr;
  2231.   if ((editDS = GlobalAlloc (GMEM_DDESHARE | GMEM_MOVEABLE | GMEM_ZEROINIT, 1024L)) == NULL) {
  2232.     MessageBox (NewWnd->hWnd, "Memory allocation failure", "Edit Buffer", MB_OK);
  2233.     editDS = hInst;     /* use local heap instead */
  2234.  
  2235.   }
  2236.   else {
  2237.     lpPtr = GlobalLock (editDS);
  2238.     LocalInit (HIWORD ((LONG) lpPtr), 0, (WORD) (GlobalSize (editDS) - 16));
  2239.     UnlockSegment (HIWORD ((LONG) lpPtr));   /* we still have a global lock */
  2240.  
  2241.   }
  2242.   NewWnd->hWndEdit = CreateWindow ((LPCSTR) "edit", (LPCSTR) NULL,
  2243.           WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER |
  2244.          ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
  2245.                0, 0, 0, 0,
  2246.           NewWnd->hWnd, (HMENU) EDITID, (HINSTANCE) HIWORD ((LONG) lpPtr), NULL);
  2247. #else
  2248.   NewWnd->hWndEdit = CreateWindow ("edit", (char *) NULL,
  2249.           WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER |
  2250.          ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
  2251.                0, 0, 0, 0,
  2252.                NewWnd->hWnd, (HMENU) EDITID, hInst, NULL);  /* No problems with Win32 */
  2253. #endif
  2254.   if (!NewWnd->hWndEdit) {
  2255.     MessageBox (NewWnd->hWnd, "Window creation failure", "Edit Buffer", MB_OK);
  2256.     return (FAIL);
  2257.   }
  2258.  
  2259.   SendMessage (NewWnd->hWndEdit, EM_LIMITTEXT, 0, 0L);
  2260.   SetHandleBkBrush (NewWnd->hWndEdit, hArticleBackgroundBrush);
  2261.   NewWnd->dirty = DT_CLEAN;
  2262.  
  2263.   return (SUCCESS);
  2264. }
  2265. /* ------------------------------------------------------------------------
  2266.  *    Write an integer to the private profile
  2267.  */
  2268. BOOL
  2269. WritePrivateProfileInt (lpAppName, lpKeyName, intval, lpProFile)
  2270.      char far *lpAppName;
  2271.      char far *lpKeyName;
  2272.      char far *lpProFile;
  2273.      int intval;
  2274. {
  2275.   char msg[20];
  2276.  
  2277.   itoa (intval, msg, 10);
  2278.   return (WritePrivateProfileString (lpAppName, lpKeyName, msg, lpProFile));
  2279. }
  2280.  
  2281. /* ------------------------------------------------------------------------
  2282.  *    Write an unsigned integer to the private profile
  2283.  *      (JSC 1/8/94)
  2284.  */
  2285. BOOL
  2286. WritePrivateProfileUInt (lpAppName, lpKeyName, intval, lpProFile)
  2287.      char far *lpAppName;
  2288.      char far *lpKeyName;
  2289.      char far *lpProFile;
  2290.      unsigned int intval;
  2291. {
  2292.   char msg[20];
  2293.  
  2294.   uitoa (intval, msg, 10);
  2295.   return (WritePrivateProfileString (lpAppName, lpKeyName, msg, lpProFile));
  2296. }
  2297.  
  2298. /* ------------------------------------------------------------------------
  2299.  *    Get an unsigned integer to the private profile
  2300.  *      (JSC 1/8/94)
  2301.  */
  2302. unsigned int
  2303. GetPrivateProfileUInt (lpAppName, lpKeyName, intval, lpProFile)
  2304.      char far *lpAppName;
  2305.      char far *lpKeyName;
  2306.      char far *lpProFile;
  2307.      unsigned int intval;
  2308. {
  2309.   char buf[20];
  2310.  
  2311.   GetPrivateProfileString (lpAppName, lpKeyName, "", buf, 20, lpProFile);
  2312.  
  2313.   if (buf[0] == '\0')
  2314.     return (intval);
  2315.   else
  2316.     return (atoui (buf));
  2317. }
  2318. /* ------------------------------------------------------------------------
  2319.  *    Refresh Window functions
  2320.  *      Called after a font/color selection has changed to affect all
  2321.  *      windows of a certain type (group/article/status)
  2322.  *      (JSC 1/9/94)
  2323.  */
  2324. void
  2325. RefreshGroupWnds ()
  2326. {
  2327.   register int i;
  2328.   for (i = 0; i < MAXGROUPWNDS; i++)
  2329.     if (GroupDocs[i].InUse && GroupDocs[i].hDocWnd) {
  2330.       SetHandleBkBrush (GroupDocs[i].hDocWnd, hListBackgroundBrush);
  2331.       SendMessage (GroupDocs[i].hDocWnd, WM_SIZE, 0, 0L);
  2332.       InvalidateRect (GroupDocs[i].hDocWnd, NULL, TRUE);
  2333.     }
  2334. }
  2335.  
  2336. void
  2337. RefreshArticleWnds ()
  2338. {
  2339.   register int i;
  2340.  
  2341.   for (i = 0; i < MAXARTICLEWNDS; i++)
  2342.     if (ArticleDocs[i].InUse && ArticleDocs[i].hDocWnd) {
  2343.       SetHandleBkBrush (ArticleDocs[i].hDocWnd, hArticleBackgroundBrush);
  2344.       SendMessage (ArticleDocs[i].hDocWnd, WM_SIZE, 0, 0L);
  2345.       InvalidateRect (ArticleDocs[i].hDocWnd, NULL, TRUE);
  2346.     }
  2347.  
  2348.   for (i = 0; i < MAXPOSTWNDS; i++)
  2349.     if (WndPosts[i].hWnd) {
  2350.       SendMessage (WndPosts[i].hWndEdit, WM_SETFONT, (WPARAM) hFontArtNormal, TRUE);
  2351.       SetHandleBkBrush (WndPosts[i].hWndEdit, hArticleBackgroundBrush);
  2352.       InvalidateRect (WndPosts[i].hWndEdit, NULL, TRUE);
  2353.     }
  2354.  
  2355.   for (i = 0; i < MAXMAILWNDS; i++)
  2356.     if (WndMails[i].hWnd) {
  2357.       SendMessage (WndMails[i].hWndEdit, WM_SETFONT, (WPARAM) hFontArtNormal, TRUE);
  2358.       SetHandleBkBrush (WndMails[i].hWndEdit, hArticleBackgroundBrush);
  2359.       InvalidateRect (WndMails[i].hWndEdit, NULL, TRUE);
  2360.     }
  2361.  
  2362. }
  2363. void
  2364. RefreshStatusWnds ()
  2365. {
  2366.   register int i;
  2367.  
  2368.   for (i = 0; i < NumStatusTexts; i++)
  2369.     if (CodingStatusText[i]->hTextWnd) {
  2370.       SetHandleBkBrush (CodingStatusText[i]->hTextWnd, hStatusBackgroundBrush);
  2371.       SendMessage (CodingStatusText[i]->hTextWnd, WM_SIZE, 0, 0L);
  2372.       InvalidateRect (CodingStatusText[i]->hTextWnd, NULL, TRUE);
  2373.     }
  2374.   if (hCodedBlockWnd) {
  2375.     SetHandleBkBrush (hCodedBlockWnd, hStatusBackgroundBrush);
  2376.     SendMessage (hCodedBlockWnd, WM_SIZE, 0, 0L);
  2377.     InvalidateRect (hCodedBlockWnd, NULL, TRUE);
  2378.   }
  2379.  
  2380. }
  2381. /* ------------------------------------------------------------------------
  2382.  *    Close Window functions
  2383.  *      Batch operation, close all windows of a certain type
  2384.  *      (group/article/status)
  2385.  *      (JSC 1/18/94)
  2386.  */
  2387. void
  2388. CloseGroupWnds ()
  2389. {
  2390.   register int i;
  2391.   for (i = 0; i < MAXGROUPWNDS; i++)
  2392.     if (GroupDocs[i].InUse && GroupDocs[i].hDocWnd && (!CommBusy || &GroupDocs[i] != CommDoc))
  2393.       SendMessage (GroupDocs[i].hDocWnd, WM_CLOSE, 0, 0L);
  2394. }
  2395.  
  2396. void
  2397. CloseArticleWnds ()
  2398. {
  2399.   register int i;
  2400.  
  2401.   for (i = 0; i < MAXARTICLEWNDS; i++)
  2402.     if (ArticleDocs[i].InUse && ArticleDocs[i].hDocWnd && (!CommBusy || &ArticleDocs[i] != CommDoc))
  2403.       SendMessage (ArticleDocs[i].hDocWnd, WM_CLOSE, 0, 0L);
  2404. }
  2405. void
  2406. CloseStatusWnds ()
  2407. {
  2408.   /* destroying a coding status text is like popping from a stack */
  2409.   /* so we just loop while the top of the stack still exists */
  2410.   int numSkipped = 0;
  2411.   while (numSkipped < NumStatusTexts && CodingStatusText[numSkipped]->hTextWnd)
  2412.     if (!CodingStatusText[numSkipped]->IsBusy)
  2413.       SendMessage (CodingStatusText[numSkipped]->hTextWnd, WM_CLOSE, 0, 0L);
  2414.     else
  2415.       numSkipped++;
  2416. #if 0
  2417.     if (CodingState) {
  2418.       MessageBox (CodingStatusText[0]->hTextWnd,
  2419.         "Please wait until en/decoding is complete",
  2420.         "Cannot close status window", MB_OK | MB_ICONSTOP);
  2421.       break;
  2422.     }
  2423.     else
  2424.       SendMessage (CodingStatusText[0]->hTextWnd, WM_CLOSE, 0, 0L);
  2425. #endif
  2426. }
  2427.  
  2428. /* ------------------------------------------------------------------------
  2429.  *    CascadeWindows (and helper CascadeWnd)
  2430.  *      cascade em
  2431.  *      jsc 9/18/94
  2432.  */
  2433. HWND
  2434. CascadeWnd(HWND hWnd, HWND prevWnd, int nthWnd, int width, int height, int maxX, int maxY)
  2435. {
  2436.   short x, y;
  2437.   
  2438. //  if (IsMaximized(hWnd))
  2439. //     ShowWindow(hWnd, SW_SHOWNORMAL);
  2440.  
  2441.   x = (nthWnd * 12) % maxX;
  2442.   y = (nthWnd * (CaptionHeight+2)) % maxY;
  2443.   SetWindowPos(hWnd, prevWnd, x, y, width, height, SWP_DRAWFRAME);
  2444.   
  2445.   return hWnd;
  2446. }
  2447.  
  2448. void
  2449. CascadeWindows()
  2450. {
  2451.   register int i;
  2452.   int nthWnd, width, height, maxX, maxY;
  2453.   HWND prevWnd;
  2454.  
  2455.   width = (int)(xScreen>>1);
  2456.   height = (int)(yScreen>>1);
  2457.   maxX = 3 * (width>>1);    /* 3/4 screen width  */
  2458.   maxY = 3 * (height>>1);    /* 3/4 screen height */
  2459.   
  2460.   prevWnd = CascadeWnd(hWndConf, (HWND)NULL, 1, width, height, maxX, maxY);
  2461.   nthWnd = 2;
  2462.   for (i = 0; i < MAXGROUPWNDS; i++)
  2463.     if (GroupDocs[i].InUse && GroupDocs[i].hDocWnd && !IsMinimized(GroupDocs[i].hDocWnd)) {
  2464.         prevWnd = CascadeWnd(GroupDocs[i].hDocWnd, prevWnd, nthWnd, width, height, maxX, maxY);
  2465.         nthWnd++;
  2466.     }
  2467.     
  2468.   for (i = 0; i < MAXARTICLEWNDS; i++)
  2469.     if (ArticleDocs[i].InUse && ArticleDocs[i].hDocWnd && !IsMinimized(ArticleDocs[i].hDocWnd)) {
  2470.         prevWnd = CascadeWnd(ArticleDocs[i].hDocWnd, prevWnd, nthWnd, width, height, maxX, maxY);
  2471.         nthWnd++;
  2472.     }
  2473.  
  2474.   for (i = 0; i < MAXPOSTWNDS; i++)
  2475.     if (WndPosts[i].hWnd && !IsMinimized(WndPosts[i].hWnd)) {
  2476.         prevWnd = CascadeWnd(WndPosts[i].hWnd, prevWnd, nthWnd, width, height, maxX, maxY);
  2477.         nthWnd++;
  2478.     }
  2479.  
  2480.   for (i = 0; i < MAXMAILWNDS; i++)
  2481.     if (WndMails[i].hWnd && !IsMinimized(WndMails[i].hWnd)) {
  2482.         prevWnd = CascadeWnd(WndMails[i].hWnd, prevWnd, nthWnd, width, height, maxX, maxY);
  2483.         nthWnd++;
  2484.     }
  2485.  
  2486.   for (i = 0; i < NumStatusTexts; i++)
  2487.     if (CodingStatusText[i]->hTextWnd && !IsMinimized(CodingStatusText[i]->hTextWnd)) {
  2488.         prevWnd = CascadeWnd(CodingStatusText[i]->hTextWnd, prevWnd, nthWnd, width, height, maxX, maxY);
  2489.         nthWnd++;
  2490.     }
  2491.  
  2492.   /* move coded block status window to top center */
  2493.   if (hCodedBlockWnd)
  2494.     SetWindowPos(hCodedBlockWnd, (HWND)NULL, (xScreen-STATUSWIDTH)>>1, 1, STATUSWIDTH, STATUSHEIGHT, SWP_DRAWFRAME);
  2495.   
  2496. }
  2497. /* ------------------------------------------------------------------------
  2498.  *    BatchSend
  2499.  *      type is DOCTYPE_MAIL or _POST
  2500.  *      Increments nextBatchIndex and initiates mail/post
  2501.  *      Note: on entry nextBatchIndex is the index we will use for this send
  2502.  *      on exit, nextBatchIndex is either 0 (no more to send) or the index
  2503.  *      of the next mail/post to send
  2504.  *      (JSC 1/18/94)
  2505.  */
  2506. void
  2507. BatchSend (int type)
  2508. {
  2509.   int thisSend;
  2510.   int maxWnds;
  2511.   WndEdit *WndEdits;
  2512.  
  2513.   if (type == DOCTYPE_POSTING) {
  2514.     WndEdits = WndPosts;
  2515.     maxWnds = MAXPOSTWNDS;
  2516.   }
  2517.   else {
  2518.     WndEdits = WndMails;
  2519.     maxWnds = MAXMAILWNDS;
  2520.   }
  2521.  
  2522.   thisSend = nextBatchIndex;
  2523.   if (thisSend == 0) {     /* find first in batch (if any) */
  2524.     while (thisSend < maxWnds)
  2525.       if (WndEdits[thisSend].hWnd)
  2526.    break;
  2527.       else
  2528.    thisSend++;
  2529.  
  2530.     if (thisSend == maxWnds)
  2531.       return;        /* no open windows.  cancel */
  2532.  
  2533.     nextBatchIndex = thisSend;
  2534.   }
  2535.  
  2536.   /* find next in batch (if any) */
  2537.   while (++nextBatchIndex < maxWnds)
  2538.     if (WndEdits[nextBatchIndex].hWnd)
  2539.       break;
  2540.  
  2541.   if (nextBatchIndex == maxWnds)
  2542.     nextBatchIndex = 0;    /* no more */
  2543.  
  2544.   if (type == DOCTYPE_POSTING)
  2545.     StartPost (&WndEdits[thisSend]);
  2546.   else
  2547.     StartMail (&WndEdits[thisSend]);
  2548. }
  2549.  
  2550. /* ------------------------------------------------------------------------
  2551.  *    Test busy functions
  2552.  *      Called to test if a comm or decoding is busy
  2553.  *      Returns true if busy, false if not busy
  2554.  *      (JSC 1/9/94)
  2555.  */
  2556. BOOL
  2557. TestCommBusy (HWND hParentWnd, char *msg)
  2558. {
  2559.   if (CommBusy) {
  2560.     MessageBox (hParentWnd,
  2561.       "Sorry, I am already busy communicating with the server.\n"
  2562.       "Try again in a little while.", msg,
  2563.       MB_OK | MB_ICONASTERISK);
  2564.     return (TRUE);
  2565.   }
  2566.   else
  2567.     return (FALSE);
  2568. }
  2569.  
  2570. BOOL
  2571. TestDecodeBusy (HWND hParentWnd, char *msg)
  2572. {
  2573.   if (Decoding || CommDecoding) {
  2574.     MessageBox (hParentWnd,
  2575.         "Sorry, I can only handle one en/decoding session at a time.\n"
  2576.       "Try again in a little while.", msg,
  2577.       MB_OK | MB_ICONASTERISK);
  2578.     return (TRUE);
  2579.   }
  2580.   else
  2581.     return (FALSE);
  2582. }
  2583.  
  2584. /* ------------------------------------------------------------------------
  2585.  *        Update the mail menus -- called on mail transport change
  2586.  *        jsc 9/9/94
  2587.  */
  2588. void
  2589. UpdateAllMailMenus()
  2590. {
  2591.     register int i;
  2592.     
  2593.     SetMainMailMenu(hWndConf);
  2594.     for (i = 0; i < MAXARTICLEWNDS; i++)
  2595.         if (ArticleDocs[i].hDocWnd) 
  2596.             SetArticleMailMenu(ArticleDocs[i].hDocWnd);
  2597.  
  2598.     for (i = 0; i < MAXGROUPWNDS; i++)
  2599.         if (GroupDocs[i].hDocWnd)
  2600.             SetGroupMailMenu(GroupDocs[i].hDocWnd);
  2601. }       
  2602. @
  2603.  
  2604.  
  2605. 1.68
  2606. log
  2607. @massive cleanup for 92.6.  moved some code to wvfiler.c
  2608. @
  2609. text
  2610. @d2 1
  2611. a2 1
  2612.  * $Id: wvutil.c 1.67 1994/08/26 21:08:04 dumoulin Exp $
  2613. d1965 1
  2614. a1965 1
  2615.     if (GroupDocs[i].hDocWnd) {
  2616. d1978 1
  2617. a1978 1
  2618.     if (ArticleDocs[i].hDocWnd) {
  2619. d2004 5
  2620. a2008 5
  2621.   for (i = 0; i < numStatusTexts; i++)
  2622.     if (codingStatusText[i]->hTextWnd) {
  2623.       SetHandleBkBrush (codingStatusText[i]->hTextWnd, hStatusBackgroundBrush);
  2624.       SendMessage (codingStatusText[i]->hTextWnd, WM_SIZE, 0, 0L);
  2625.       InvalidateRect (codingStatusText[i]->hTextWnd, NULL, TRUE);
  2626. d2028 1
  2627. a2028 1
  2628.     if (GroupDocs[i].hDocWnd)
  2629. d2038 1
  2630. a2038 1
  2631.     if (ArticleDocs[i].hDocWnd)
  2632. d2046 7
  2633. a2052 1
  2634.   while (numStatusTexts > 0 && codingStatusText[0]->hTextWnd)
  2635. d2054 1
  2636. a2054 1
  2637.       MessageBox (codingStatusText[0]->hTextWnd,
  2638. d2060 2
  2639. a2061 1
  2640.       SendMessage (codingStatusText[0]->hTextWnd, WM_CLOSE, 0, 0L);
  2641. d2064 12
  2642. d2077 56
  2643. d2237 1
  2644. a2237 1
  2645. }       @
  2646.  
  2647.  
  2648. 1.67
  2649. log
  2650. @fix problem with estimated number of articles in a group
  2651. @
  2652. text
  2653. @d2 1
  2654. a2 1
  2655.  * $Id: wvutil.c 1.66 1994/08/24 18:40:15 mrr Exp dumoulin $
  2656. d9 1
  2657. a9 3
  2658. #define STRICT
  2659. #include "windows.h"
  2660. #include <commdlg.h>    // for GetOpenFileName dialog (JSC)
  2661. d13 2
  2662. a17 1
  2663. #include <dos.h>     // _dos_getfileattr
  2664. a29 2
  2665. #define MAXFILTERLEN 512
  2666.  
  2667. a388 1
  2668.   int mbcode;
  2669. a394 1
  2670.   char *cptr;
  2671. d580 1
  2672. d626 1
  2673. d1359 1
  2674. a1359 6
  2675.    cptr = "Posting Failed";
  2676.    mbcode = MB_OK | MB_ICONEXCLAMATION;
  2677.    MessageBox (PostEdit->hWnd, CommLineIn + 4, cptr, mbcode);
  2678.    /* let 'em fix the post! */
  2679.    SendMessage (PostEdit->hWndEdit, EM_SETREADONLY, FALSE, 0L);
  2680.  
  2681. d1368 1
  2682. a1368 16
  2683.    cptr = "Article Posted OK";
  2684.    mbcode = MB_OKCANCEL;
  2685.    /*      if (MessageBox(hPostEdit,CommLineIn+4,cptr,mbcode) */
  2686.    /*           == ID_OK) */
  2687.    if (!Attaching || (Attaching && ReviewAttach)) {
  2688.      if (PostLog) {
  2689.        char *mbuf;
  2690.        mbuf = GetEditText (PostEdit->hWndEdit);
  2691.        WriteEditLog (PostEdit->hWnd, PostLogFile, mbuf,
  2692.            (unsigned int) SendMessage (PostEdit->hWndEdit,
  2693.                     WM_GETTEXTLENGTH, 0, 0L));
  2694.        GlobalFreePtr (mbuf);
  2695.      }
  2696.      PostEdit->dirty = DT_CLEAN;
  2697.      DestroyWindow (PostEdit->hWnd);
  2698.    }
  2699. a1690 58
  2700. /*------------------------------------------------------------------------------
  2701.  * ExtWithoutName
  2702.  * Copies into tempName: the extension only
  2703.  * i.e. c:\windows\system\xyz.txt returns txt
  2704.  * JSC 11/1/93
  2705.  */
  2706. char *
  2707. GetFileExtension (char *tempName, char *fileName)
  2708. {
  2709.   char *theDot;
  2710.  
  2711.   if ((theDot = strrchr (fileName, '.')) == NULL)
  2712.     *tempName = '\0';
  2713.   else
  2714.     strcpy (tempName, &fileName[theDot - fileName + 1]);
  2715.  
  2716.   return (tempName);
  2717. }
  2718.  
  2719. /*------------------------------------------------------------------------------
  2720.  * NameWithoutPath
  2721.  * Copies into tempName: the name of fileName (chops off the path)
  2722.  * i.e. c:\windows\system\xyz.txt returns xyz.txt
  2723.  * JSC 11/1/93
  2724.  */
  2725. char *
  2726. NameWithoutPath (char *tempName, char *fileName)
  2727. {
  2728.   char *lastSlash;
  2729.  
  2730.   if ((lastSlash = strrchr (fileName, '\\')) == NULL)
  2731.     strcpy (tempName, fileName); /* no path given.  done */
  2732.   else
  2733.     strcpy (tempName, &fileName[lastSlash - fileName + 1]);
  2734.  
  2735.   return (tempName);
  2736. }
  2737.  
  2738. /*------------------------------------------------------------------------------
  2739.  * NameWithoutPath
  2740.  * Copies into tempName: the path of fileName (chops off the name)
  2741.  * i.e. c:\windows\system\xyz.txt returns c:\windows\system
  2742.  * JSC 7/16/94
  2743.  */
  2744. char *
  2745. PathWithoutName (char *tempName, char *fileName)
  2746. {
  2747.   char *lastSlash;
  2748.  
  2749.   if ((lastSlash = strrchr (fileName, '\\')) == NULL)
  2750.     strcpy (tempName, fileName); /* no path given.  done */
  2751.   else {
  2752.     strncpy (tempName, fileName, lastSlash - fileName);
  2753.     tempName[lastSlash - fileName] = '\0';
  2754.   }
  2755.   return (tempName);
  2756. }
  2757.  
  2758. d1722 1
  2759. a1722 1
  2760.  * Returns true if the string is a all digits, allowing 1st char to be + or -
  2761. d1731 1
  2762. a1731 1
  2763.     if (!isdigit (*ptr) && (ptr != str || !strchr ("+-", *ptr)))
  2764. a1821 221
  2765.  *    Asks for a path - uses hook callback to allow just a path (usual
  2766.  *      behavior requires the user to enter a filename)
  2767.  *
  2768.  *      See example MSJ Jan 93, Question&Answers (Fran Finnegan)
  2769.  *      JSC 7/17/94
  2770.  *      don't forget to add  GETPATHHOOKPROC  to winvn.def and compile with /Gw
  2771.  *
  2772.  *      Damn! Doesn't work because the the OK msg is only generated if
  2773.  *      the user has entered a complete filename.  How to do this then?!
  2774.  */
  2775. #if 0
  2776. extern UINT CALLBACK
  2777. GetPathHookProc (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
  2778. {
  2779.   static LPOPENFILENAME ofn;
  2780.   static UINT fileNameMsg;
  2781.   unsigned attrib;
  2782.  
  2783.   if (iMessage == WM_INITDIALOG) {
  2784.     ofn = (LPOPENFILENAME) lParam;
  2785.     fileNameMsg = (UINT) LOWORD ((DWORD) ofn->lCustData);
  2786.     return TRUE;
  2787.   }
  2788.   else {
  2789.     if (iMessage == fileNameMsg) {  /* Trap the FILEOKSTRING msg */
  2790.       /* if it exists and its a directory, then bypass default  */
  2791.       /* OK processing */
  2792.       if (_dos_getfileattr (ofn->lpstrFile, &attrib) == 0 && (attrib & _A_SUBDIR))
  2793.    return TRUE;
  2794.     }
  2795.   }
  2796.   return FALSE;         /* Allow standard processing */
  2797.  
  2798. }
  2799. #endif
  2800.  
  2801. BOOL
  2802. AskForFilePath (HWND hParentWnd, char *pathName, char *title)
  2803. {
  2804.   OPENFILENAME ofn;
  2805.   char szFile[MAXFILENAME];
  2806.   char filters[MAXFILTERLEN];
  2807.  
  2808.   GenerateFileFilters (hParentWnd, filters);
  2809.  
  2810. /*      Open dialog to ask user for a new file name */
  2811.   memset (&ofn, 0, sizeof (OPENFILENAME));
  2812.   szFile[0] = '\0';
  2813.   ofn.lpstrTitle = title;
  2814.   ofn.lStructSize = sizeof (OPENFILENAME);
  2815.   ofn.hwndOwner = hParentWnd;
  2816.   ofn.lpstrFilter = filters;
  2817.   ofn.nFilterIndex = 1;
  2818.   ofn.lpstrFile = szFile;
  2819.   ofn.nMaxFile = sizeof (szFile);
  2820.   ofn.lpstrFileTitle = NULL;
  2821.   ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST;
  2822.  
  2823. #if 0
  2824.   UINT fileNameMsg;
  2825.   ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_ENABLEHOOK;
  2826.   ofn.lpfnHook = MakeProcInstance ((FARPROC) GetPathHookProc, (HINSTANCE) hInst);
  2827.   /* Register the FILEOKSTRING message */
  2828.   fileNameMsg = RegisterWindowMessage ((LPCSTR) FILEOKSTRING);
  2829.   /* Pass the FILEOKSTRING message ID in LOWORD of lCustData field */
  2830.   ofn.lCustData = MAKELPARAM (fileNameMsg, 0);
  2831. #endif
  2832.  
  2833.   if (GetOpenFileName (&ofn) == 0)
  2834.     return (FAIL);
  2835.  
  2836. /*      FreeProcInstance(&ofn.lpfnHook); */
  2837.   PathWithoutName (pathName, strlwr (szFile));
  2838.   return (SUCCESS);
  2839. }
  2840.  
  2841.  
  2842. /*      Set up filters */
  2843. void
  2844. GenerateFileFilters (HWND hParentWnd, char *filters)
  2845. {
  2846.   register int i;
  2847.   int len;
  2848.   char chReplace;
  2849.  
  2850.   if ((len = LoadString (hInst, IDS_FILTERSTRING, filters, MAXFILTERLEN - 1)) == 0) {
  2851.     MessageBox (hParentWnd, "No Filters Available", "String Load Failure", MB_OK);
  2852.     *filters = '\0';
  2853.   }
  2854.   else {
  2855.     chReplace = filters[len - 1];   /* grab separator */
  2856.  
  2857.     for (i = 0; filters[i] != '\0'; i++)
  2858.       if (filters[i] == chReplace)
  2859.    filters[i] = '\0';
  2860.   }
  2861. }
  2862.  
  2863. /* ------------------------------------------------------------------------
  2864.  *    Asks for a filename which must exist
  2865.  *      (JSC)
  2866.  */
  2867. BOOL
  2868. AskForExistingFileName (HWND hParentWnd, char *fileName, char *title)
  2869. {
  2870.   OPENFILENAME ofn;
  2871.   char szFile[MAXFILENAME];
  2872.   char filters[MAXFILTERLEN];
  2873.  
  2874.   GenerateFileFilters (hParentWnd, filters);
  2875.  
  2876. /*      Open dialog to ask user for a new file name */
  2877.   memset (&ofn, 0, sizeof (OPENFILENAME));
  2878.   szFile[0] = '\0';
  2879.   ofn.lpstrTitle = title;
  2880.   ofn.lStructSize = sizeof (OPENFILENAME);
  2881.   ofn.hwndOwner = hParentWnd;
  2882.   ofn.lpstrFilter = filters;
  2883.   ofn.nFilterIndex = 1;
  2884.   ofn.lpstrFile = szFile;
  2885.   ofn.nMaxFile = sizeof (szFile);
  2886.   ofn.lpstrFileTitle = NULL;
  2887.   ofn.Flags = OFN_SHOWHELP | OFN_FILEMUSTEXIST;
  2888.  
  2889.   if (GetOpenFileName (&ofn) == 0)
  2890.     return (FAIL);
  2891.   strcpy (fileName, strlwr (szFile));
  2892.   return (SUCCESS);
  2893. }
  2894. /* ------------------------------------------------------------------------
  2895.  *    Make sure file name is OK for DOS 8.3
  2896.  *      Check if file name is OK for DOS.  If not, prompt user new name
  2897.  *      Check if file already exists.  If so, prompt user OK to overwrite
  2898.  *      If fileName contains a name on entry, check if it's OK, if yes-done
  2899.  *      (JSC)
  2900.  */
  2901. BOOL
  2902. AskForNewFileName (HWND hParentWnd, char *fileName, char *startDir)
  2903. {
  2904.   OFSTRUCT outFileStruct;
  2905.   OPENFILENAME ofn;
  2906.   HFILE hWriteFile;
  2907.   char mybuf[MAXINTERNALLINE];
  2908.   char szDirName[256];
  2909.   char szFile[256];
  2910.   BOOL retcode;
  2911.   char filters[MAXFILTERLEN];
  2912.  
  2913.   GenerateFileFilters (hParentWnd, filters);
  2914.   while (fileName[0] == '\0' ||
  2915.     (retcode = VerifyFileName (fileName)) == FAIL ||
  2916.     (hWriteFile = OpenFile ((char far *) fileName, &outFileStruct, OF_EXIST)) >= 0) {
  2917.     if (fileName[0] != '\0' && retcode == SUCCESS) {
  2918. /*      File name ok, but file exists.  Ask user if ok to wipe it */
  2919.       sprintf (mybuf, "File %s exists.  OK to overwrite it?", fileName);
  2920.       retcode = MessageBox (hParentWnd, mybuf, "File exists",
  2921.              MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION);
  2922.       if (retcode == IDYES)
  2923.    break;
  2924.     }
  2925.  
  2926. /*      Open dialog to ask user for a new file name */
  2927.     memset (&ofn, 0, sizeof (OPENFILENAME));
  2928.     if (fileName[0] != '\0')
  2929.       sprintf (mybuf, "Invalid file name %s. Select new name", fileName);
  2930.     else
  2931.       strcpy (mybuf, "Select new file name to create/overwrite");
  2932.  
  2933.     ofn.lpstrTitle = mybuf;
  2934.     strcpy (szDirName, startDir);
  2935.     ofn.lpstrInitialDir = szDirName;
  2936.     ofn.lStructSize = sizeof (OPENFILENAME);
  2937.     ofn.hwndOwner = hParentWnd;
  2938.     ofn.lpstrFilter = filters;
  2939.     ofn.nFilterIndex = 1;
  2940.     szFile[0] = '\0';
  2941.     ofn.lpstrFile = szFile;
  2942.     ofn.nMaxFile = sizeof (szFile);
  2943.     ofn.lpstrFileTitle = NULL;
  2944.     ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST;
  2945.  
  2946.     if (GetOpenFileName (&ofn) == 0)
  2947.       return (FAIL);
  2948.  
  2949.     strcpy (fileName, strlwr (ofn.lpstrFile));
  2950.   }
  2951.   return (SUCCESS);
  2952. }
  2953. /* ------------------------------------------------------------------------
  2954.  *    Make sure file name is OK for DOS 8.3
  2955.  *      (JSC)
  2956.  */
  2957. BOOL
  2958. VerifyFileName (char *fileName)
  2959. {
  2960.   char *beg, *ptr;
  2961.  
  2962.   if ((beg = strrchr (fileName, '\\')) == NULL)
  2963.     beg = fileName;
  2964.   else
  2965.     beg++;        /* skip to after path slash */
  2966.  
  2967.   if ((ptr = strchr (beg, '.')) == NULL)
  2968.     if (strlen (beg) <= 8) /* no extension */
  2969.       return (SUCCESS);
  2970.  
  2971.   if (ptr - beg > 8)
  2972.     return (FAIL);
  2973.  
  2974.   beg = ptr + 1;     /* multiple extensions */
  2975.   if ((ptr = strchr (beg, '.')) != NULL)
  2976.     return (FAIL);
  2977.  
  2978.   if (strlen (beg) > 3)    /* extension too long */
  2979.     return (FAIL);
  2980.  
  2981.   return (SUCCESS);
  2982. }
  2983.  
  2984.  
  2985. /* ------------------------------------------------------------------------
  2986. d2144 19
  2987. @
  2988.  
  2989.  
  2990.  
  2991. 1.66
  2992. log
  2993. @authorization enables post/mail
  2994. @
  2995. text
  2996. @d2 1
  2997. a2 1
  2998.  * $Id: wvutil.c 1.65 1994/08/11 02:25:59 dumoulin Exp $
  2999. d589 2
  3000. a590 1
  3001.      {
  3002. d593 1
  3003. a593 2
  3004.              { 
  3005.               arts_to_retrieve = (int) estnum;
  3006. @
  3007.  
  3008.  
  3009.  
  3010. 1.65
  3011. log
  3012. @enabled STRICT compile and cleaned up parameter casting
  3013. @
  3014. text
  3015. @d2 1
  3016. a2 1
  3017.  * $Id: wvutil.c 1.64 1994/08/11 00:13:22 jcooper Exp dumoulin $
  3018. d11 2
  3019. a12 2
  3020. #include <commdlg.h>        // for GetOpenFileName dialog (JSC)
  3021. #include <windowsx.h>        // for GlobalFreePtr (JSC)
  3022. d18 1
  3023. a18 1
  3024. #include <dos.h>        // _dos_getfileattr
  3025. d92 1
  3026. a92 1
  3027.     else            /* No name in parens */
  3028. d95 1
  3029. a95 1
  3030.   else                /* !FullNameFrom */
  3031. d134 2
  3032. a135 2
  3033.        GetGValue (rgbVal),
  3034.        GetBValue (rgbVal));
  3035. d238 1
  3036. a238 1
  3037.     CommLinePtr--;
  3038. d245 3
  3039. a247 3
  3040.              char *group_name,
  3041.              unsigned long line_number,
  3042.              unsigned long total_lines)
  3043. d307 2
  3044. a308 2
  3045.          unsigned long activenum,
  3046.          header_p headers, TypGroup far * GroupDoc)
  3047. d317 1
  3048. a317 1
  3049.     return (headerloc);
  3050. d325 1
  3051. a325 1
  3052.     return (headerloc);
  3053. d335 1
  3054. a335 1
  3055.   char *end = refer + strlen (refer) - 1;    /* points to NULL */
  3056. d345 1
  3057. a345 1
  3058.     bracket_len = 0;
  3059. d347 3
  3060. a349 3
  3061.     bracket2 = strrchr (refer, '>');
  3062.     if (bracket2)
  3063.       bracket_len = (int) (bracket2 - bracket1) + 1;
  3064. d419 26
  3065. a444 25
  3066.     break;
  3067.       if (retcode == 200 || retcode == 201) {    /* was 500 from induced error */
  3068.     CommBusy = TRUE;
  3069.     do_authinfo = FALSE;
  3070.     if (strlen (NNTPUserName)) {
  3071.       /* We have the AUTHINFO username.  Do we have the password? */
  3072.       if (!strlen (NNTPPasswordEncrypted)) {
  3073.         /* Get the news server user password from the user */
  3074.         if (DialogBox (hInst, (LPCSTR) "WinVnComm", hWndConf, (DLGPROC) lpfnWinVnCommDlg)
  3075.         && strlen (NNTPPasswordEncrypted)) {
  3076.           do_authinfo = TRUE;
  3077.         }
  3078.       }
  3079.       else {
  3080.         do_authinfo = TRUE;
  3081.       }
  3082.     }
  3083.     if (do_authinfo) {
  3084.       sprintf (mybuf, "AUTHINFO user %s", NNTPUserName);
  3085.       CommState = ST_CHECK_AUTHINFO_USERNAME;
  3086.       PutCommLine (mybuf);
  3087.     }
  3088.     else {
  3089.       goto End_Authinfo;
  3090.     }
  3091. d448 5
  3092. a452 5
  3093.     MessageBox (hWndConf, CommLineIn, "Access Problem", MB_OK);
  3094.     /*      MRRCloseComm (); */
  3095.     /*        PostQuitMessage (0); */
  3096.     Initializing = INIT_NOT_CONNECTED;
  3097.     InvalidateRect (hWndConf, NULL, TRUE);
  3098. d461 1
  3099. a461 1
  3100.     break;
  3101. d463 2
  3102. a464 2
  3103.     MessageBox (hWndConf, "Error authorizing your username with the News Server.", "WinVN", MB_OK | MB_ICONHAND);
  3104.     goto End_Authinfo;
  3105. d474 1
  3106. a474 1
  3107.     break;
  3108. d477 1
  3109. a477 1
  3110.     break;
  3111. d479 10
  3112. a488 4
  3113.     dialog_active = TRUE;
  3114.     sprintf (mybuf, "Error authorizing your password with the News Server:\n%s.", CommLineIn);
  3115.     MessageBox (hWndConf, mybuf, "WinVN", MB_OK | MB_ICONHAND);
  3116.     dialog_active = FALSE;
  3117. d503 4
  3118. a506 4
  3119.       if (retcode == 412 && !force_xhdr)    /* 412 == 'not in a newsgroup' */
  3120.     xoverp = 1;
  3121.       else            /* 500 == 'command not understood' */
  3122.     xoverp = 0;
  3123. d510 3
  3124. a512 3
  3125.     if (MessageBox (hWndConf, "Request the latest group list from server?\n(This can be time consuming)",
  3126.             "Request LIST from server?", MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDNO)
  3127.       dolist = 0;
  3128. d515 2
  3129. a516 2
  3130.     StartList ();
  3131.     did_list = 1;
  3132. d519 4
  3133. a522 4
  3134.     did_list = 0;
  3135.     CommState = ST_NONE;
  3136.     CommBusy = FALSE;
  3137.     Initializing = INIT_READY;
  3138. d531 2
  3139. a532 2
  3140.     check_server_code (retcode);
  3141.     break;
  3142. d541 4
  3143. a544 4
  3144.     CommState = ST_NONE;
  3145.     CommBusy = FALSE;
  3146.     Initializing = INIT_READY;
  3147.     InvalidateRect (hWndConf, NULL, FALSE);
  3148. d546 1
  3149. a546 1
  3150.     ProcEndList ();
  3151. d549 1
  3152. a549 1
  3153.     ProcListLine ((unsigned char *) CommLineIn);
  3154. d558 7
  3155. a564 7
  3156.     MessageBox (hWndConf, "No Such Newsgroup", "Error", MB_OK | MB_ICONHAND);
  3157.     /* abort the fledgling group window */
  3158.     DestroyWindow (CommDoc->hDocWnd);
  3159.     CommBusy = FALSE;
  3160.     CommState = ST_NONE;
  3161.     return;
  3162.     break;
  3163. d566 7
  3164. a572 7
  3165.     MessageBox (hWndConf, "Restricted Access", "WinVN", MB_OK | MB_ICONHAND);
  3166.     /* abort the fledgling group window */
  3167.     DestroyWindow (CommDoc->hDocWnd);
  3168.     CommBusy = FALSE;
  3169.     CommState = ST_NONE;
  3170.     return;
  3171.     break;
  3172. d574 3
  3173. a576 3
  3174.     if (check_server_code (retcode))
  3175.       return;
  3176.     break;
  3177. d582 1
  3178. a582 1
  3179.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3180. d588 3
  3181. a590 3
  3182.     if (!ShowUnreadOnly)
  3183.       {
  3184.       DlgStatus = DialogBox (hInst, (LPCSTR) "THRESHOLD", CommDoc->hDocWnd, (DLGPROC) lpfnWinVnThresholdDlg);
  3185. d595 4
  3186. a598 4
  3187.           CommBusy = FALSE;
  3188.           CommState = ST_NONE;
  3189.           GroupDoc->ServerFirst = GroupDoc->ServerLast;
  3190.           GroupDoc->ServerEstNum = estnum;
  3191. d602 20
  3192. a621 20
  3193.     if ((arts_to_retrieve > 0)
  3194.         && ((last - arts_to_retrieve) > first)) {
  3195.       first = (last - arts_to_retrieve) + 1;
  3196.     }
  3197.     else if (arts_to_retrieve == -1)    /* they clicked 'all of them' */
  3198.       arts_to_retrieve = (int) estnum;
  3199.     /* added by jlg */
  3200.     else if ((arts_to_retrieve == -2)    /* they clicked 'unread' */
  3201.          ||(ShowUnreadOnly)) {
  3202.       if (GroupDoc->nRanges) {
  3203.         first = RangePtr[0].Last + 1;
  3204.         arts_to_retrieve = (int) ((last - first) + 1);
  3205.         if (arts_to_retrieve < 50) {
  3206.           arts_to_retrieve = 50;
  3207.           first = last - 49;
  3208.         }
  3209.       }
  3210.       else
  3211.         arts_to_retrieve = (int) estnum;
  3212.     }
  3213. d624 12
  3214. a635 12
  3215.     if (estnum > 0)
  3216.       arts_to_retrieve = (int) estnum;
  3217.     else {
  3218.       MessageBox (hWndConf, "Empty Newsgroup", "WinVN", MB_OK | MB_ICONHAND);
  3219.       /* abort the fledgling group window */
  3220.       DestroyWindow (CommDoc->hDocWnd);
  3221.       CommBusy = FALSE;
  3222.       CommState = ST_NONE;
  3223.       GroupDoc->ServerFirst = GroupDoc->ServerLast;
  3224.       GroupDoc->ServerEstNum = 0;
  3225.       return;
  3226.     }
  3227. d641 9
  3228. a649 9
  3229.     header_handle =
  3230.       GlobalAlloc (GMEM_MOVEABLE, (long)
  3231.                ((sizeof (TypHeader)) *
  3232.               (long) (arts_to_retrieve)) + sizeof (thread_array *));
  3233.  
  3234.     /* allocate space for the header_array index table */
  3235.     thread_handle =
  3236.       GlobalAlloc (GMEM_MOVEABLE,
  3237.                (long) ((sizeof (long)) * (long) (arts_to_retrieve)));
  3238. d651 2
  3239. a652 2
  3240.     GroupDoc->header_handle = header_handle;
  3241.     GroupDoc->thread_handle = thread_handle;
  3242. d667 3
  3243. a669 3
  3244.     mylen = sprintf (mybuf, "XOVER %ld-%ld", first, last);
  3245.     CommState = ST_XOVER_START;
  3246.     PutCommLine (mybuf);
  3247. d672 3
  3248. a674 3
  3249.     mylen = sprintf (mybuf, "XHDR from %ld-%ld", first, last);
  3250.     CommState = ST_XHDR_FROM_START;
  3251.     PutCommLine (mybuf);
  3252. d694 2
  3253. a695 2
  3254.     CommState = ST_XOVER_DATA;
  3255.     CommDoc->ActiveLines = 0;
  3256. d698 3
  3257. a700 3
  3258.     mylen = sprintf (mybuf, "XHDR from %ld-%ld", first, last);
  3259.     CommState = ST_XHDR_FROM_START;
  3260.     PutCommLine (mybuf);
  3261. d706 5
  3262. a710 5
  3263.     /* this is a yuck way to do this */
  3264.     CommState = ST_IN_GROUP;
  3265.     CommBusy = FALSE;
  3266.     finish_header_retrieval (CommDoc);
  3267.     InvalidateRect (CommDoc->hDocWnd, NULL, FALSE);
  3268. d713 2
  3269. a714 2
  3270.     char *this_hop, *next_hop;
  3271.     char *reference;
  3272. d716 87
  3273. a802 87
  3274.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3275.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3276.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  3277.     header_handle = GroupDoc->header_handle;
  3278.     thread_handle = GroupDoc->thread_handle;
  3279.  
  3280.     GlobalUnlock (BlockPtr->hCurBlock);
  3281.  
  3282.     /* Lock the header data */
  3283.     headers = lock_headers (header_handle, thread_handle);
  3284.     header = header_elt (headers, CommDoc->ActiveLines);
  3285.  
  3286.     this_hop = CommLineIn;
  3287.  
  3288.     /* article number */
  3289.     next_hop = strchr (this_hop, '\t');
  3290.     *(next_hop++) = (char) NULL;
  3291.  
  3292.     header->number = atol (this_hop);
  3293.  
  3294.     /* subject */
  3295.     this_hop = next_hop;
  3296.     next_hop = strchr (this_hop, '\t');
  3297.     *(next_hop++) = (char) NULL;
  3298.  
  3299.     mylstrncpy (header->subject, this_hop, HEADER_SUBJECT_LENGTH);
  3300.     CommDoc->LongestLine = max (CommDoc->LongestLine,
  3301.                     ARTICLE_SUBJECT_OFFSET +
  3302.                     (unsigned) lstrlen (header->subject));
  3303.     /* author */
  3304.     this_hop = next_hop;
  3305.     next_hop = strchr (this_hop, '\t');
  3306.     *(next_hop++) = (char) NULL;
  3307.  
  3308.     ParseAddress (this_hop,
  3309.               AddressString, MAXDIALOGSTRING,
  3310.               NameString, MAXDIALOGSTRING);
  3311.  
  3312.     if (FullNameFrom)
  3313.       mylstrncpy (header->from, NameString, HEADER_FROM_LENGTH);
  3314.     else
  3315.       mylstrncpy (header->from, this_hop, HEADER_FROM_LENGTH);
  3316.  
  3317.     /* date */
  3318.     this_hop = next_hop;
  3319.     next_hop = strchr (this_hop, '\t');
  3320.     *(next_hop++) = (char) NULL;
  3321.  
  3322.     header->date = parse_usenet_date (this_hop);
  3323.  
  3324.     /* message-id */
  3325.     this_hop = next_hop;
  3326.     next_hop = strchr (this_hop, '\t');
  3327.     *(next_hop++) = (char) NULL;
  3328.  
  3329.     mylstrncpy (header->message_id, this_hop, HEADER_MESSAGE_ID_LENGTH);
  3330.  
  3331.     /* references */
  3332.     this_hop = next_hop;
  3333.     next_hop = strchr (this_hop, '\t');
  3334.     *(next_hop++) = (char) NULL;
  3335.  
  3336.     reference = get_best_reference (this_hop);
  3337.     if (reference)
  3338.       mylstrncpy (header->references, reference, HEADER_REFERENCES_LENGTH);
  3339.  
  3340.     /* bytes (ignored) */
  3341.     this_hop = next_hop;
  3342.     next_hop = strchr (this_hop, '\t');
  3343.     *(next_hop++) = (char) NULL;
  3344.  
  3345.     /* lines (last one doesn't have to have the tab */
  3346.     this_hop = next_hop;
  3347.     header->lines = atoi (this_hop);
  3348.  
  3349.     /* set other header fields */
  3350.     header->Selected = FALSE;
  3351.     header->ArtDoc = (TypDoc *) NULL;
  3352.     header->Seen = WasArtSeen (header->number, GroupDoc);
  3353.  
  3354.     unlock_headers (header_handle, thread_handle);
  3355.  
  3356.     CommDoc->ActiveLines++;
  3357.  
  3358.     update_window_title (CommDoc->hDocWnd, group,
  3359.                  RcvLineCount++,
  3360.                  CommDoc->TotalLines);
  3361. d822 1
  3362. a822 1
  3363.       total_xhdrs = threadp ? 6 : 4;    /* we do this here to allow */
  3364. d825 1
  3365. a825 1
  3366.     break;
  3367. d832 2
  3368. a833 2
  3369.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3370.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3371. d835 2
  3372. a836 2
  3373.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  3374.     GroupDoc->total_headers = CommDoc->ActiveLines;
  3375. d838 2
  3376. a839 2
  3377.     first = GroupDoc->ServerFirst;
  3378.     last = GroupDoc->ServerLast;
  3379. d841 7
  3380. a847 7
  3381.     GlobalUnlock (BlockPtr->hCurBlock);
  3382.     CommDoc->ActiveLines = 0;
  3383.  
  3384.     /* Now ask for the date lines */
  3385.     mylen = sprintf (mybuf, "XHDR date %ld-%ld", first, last);
  3386.     CommState = ST_XHDR_DATE_START;
  3387.     PutCommLine (mybuf);
  3388. d850 36
  3389. a885 36
  3390.     /*      char neat_from [80]; */
  3391.     /* Access the Group struct, get HANDLE for header data */
  3392.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3393.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3394.  
  3395.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  3396.     header_handle = GroupDoc->header_handle;
  3397.     thread_handle = GroupDoc->thread_handle;
  3398.  
  3399.     GlobalUnlock (BlockPtr->hCurBlock);
  3400.  
  3401.     /* Lock the header data */
  3402.     headers = lock_headers (header_handle, thread_handle);
  3403.  
  3404.     sscanf (CommLineIn, "%ld", &artnum);
  3405.     header = header_elt (headers, CommDoc->ActiveLines);
  3406.     header->number = artnum;
  3407.  
  3408.     /* now use some of our nice formatting of email addresses */
  3409.     ParseAddress (get_xhdr_line (CommLineIn),
  3410.               AddressString, MAXDIALOGSTRING,
  3411.               NameString, MAXDIALOGSTRING);
  3412.  
  3413.     /* copy that into headers[].from */
  3414.     if (FullNameFrom)
  3415.       mylstrncpy (header->from, NameString, HEADER_FROM_LENGTH);
  3416.     else
  3417.       mylstrncpy (header->from, AddressString, HEADER_FROM_LENGTH);
  3418.  
  3419.     unlock_headers (header_handle, thread_handle);
  3420.  
  3421.     CommDoc->ActiveLines++;
  3422.  
  3423.     update_window_title (CommDoc->hDocWnd, group,
  3424.                  RcvLineCount++,
  3425.                  CommDoc->TotalLines * total_xhdrs);
  3426. d894 1
  3427. a894 1
  3428.     break;
  3429. d901 2
  3430. a902 2
  3431.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3432.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3433. d904 2
  3434. a905 2
  3435.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  3436.     GroupDoc->total_headers = CommDoc->ActiveLines;
  3437. d907 2
  3438. a908 2
  3439.     first = GroupDoc->ServerFirst;
  3440.     last = GroupDoc->ServerLast;
  3441. d910 7
  3442. a916 7
  3443.     GlobalUnlock (BlockPtr->hCurBlock);
  3444.     CommDoc->ActiveLines = 0;
  3445.  
  3446.     /* Now ask for the #of lines */
  3447.     mylen = sprintf (mybuf, "XHDR lines %ld-%ld", first, last);
  3448.     CommState = ST_XHDR_LINES_START;
  3449.     PutCommLine (mybuf);
  3450. d920 25
  3451. a944 25
  3452.     /* Access the Group struct, get HANDLE for header data */
  3453.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3454.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3455.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  3456.     header_handle = GroupDoc->header_handle;
  3457.     thread_handle = GroupDoc->thread_handle;
  3458.  
  3459.     GlobalUnlock (BlockPtr->hCurBlock);
  3460.  
  3461.     /* Lock the header data */
  3462.     headers = lock_headers (header_handle, thread_handle);
  3463.     syncnum = sync_artnum (atol (CommLineIn),
  3464.                (header_elt (headers, CommDoc->ActiveLines))->number,
  3465.                    headers,
  3466.                    GroupDoc);
  3467.     if (syncnum >= 0)
  3468.       (header_elt (headers, syncnum))->date
  3469.         = parse_usenet_date (get_xhdr_line (CommLineIn));
  3470.  
  3471.     unlock_headers (header_handle, thread_handle);
  3472.  
  3473.     CommDoc->ActiveLines++;
  3474.     update_window_title (CommDoc->hDocWnd, group,
  3475.                  RcvLineCount++,
  3476.                  CommDoc->TotalLines * total_xhdrs);
  3477. d953 1
  3478. a953 1
  3479.     break;
  3480. d960 2
  3481. a961 2
  3482.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3483.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3484. d963 2
  3485. a964 2
  3486.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  3487.     GroupDoc->total_headers = CommDoc->ActiveLines;
  3488. d966 2
  3489. a967 2
  3490.     first = GroupDoc->ServerFirst;
  3491.     last = GroupDoc->ServerLast;
  3492. d969 16
  3493. a984 16
  3494.     GlobalUnlock (BlockPtr->hCurBlock);
  3495.     CommDoc->ActiveLines = 0;
  3496.  
  3497.     /* Check for threading option, if enabled, go to REF & ID */
  3498.     /* states first */
  3499.  
  3500.     if (threadp) {
  3501.       CommState = ST_XHDR_REF_START;
  3502.       mylen = sprintf (mybuf, "XHDR references %ld-%ld", first, last);
  3503.       PutCommLine (mybuf);
  3504.     }
  3505.     else {
  3506.       CommState = ST_XHDR_SUBJECT_START;
  3507.       mylen = sprintf (mybuf, "XHDR subject %ld-%ld", first, last);
  3508.       PutCommLine (mybuf);
  3509.     }
  3510. d989 25
  3511. a1013 25
  3512.     /* Access the Group struct, get HANDLE for header data */
  3513.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3514.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3515.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  3516.  
  3517.     header_handle = GroupDoc->header_handle;
  3518.     thread_handle = GroupDoc->thread_handle;
  3519.  
  3520.     GlobalUnlock (BlockPtr->hCurBlock);
  3521.  
  3522.     /* Lock the header data */
  3523.     headers = lock_headers (header_handle, thread_handle);
  3524.  
  3525.     syncnum = sync_artnum (atol (CommLineIn),
  3526.                (header_elt (headers, CommDoc->ActiveLines))->number,
  3527.                    headers,
  3528.                    GroupDoc);
  3529.     if (syncnum >= 0)
  3530.       sscanf (CommLineIn, "%ld %Fd", &artnum, &((header_elt (headers, syncnum))->lines));
  3531.  
  3532.     unlock_headers (header_handle, thread_handle);
  3533.     CommDoc->ActiveLines++;
  3534.     update_window_title (CommDoc->hDocWnd, group,
  3535.                  RcvLineCount++,
  3536.                  CommDoc->TotalLines * total_xhdrs);
  3537. d1022 1
  3538. a1022 1
  3539.     break;
  3540. d1029 2
  3541. a1030 2
  3542.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3543.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3544. d1032 2
  3545. a1033 2
  3546.     GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  3547.     GroupDoc->total_headers = CommDoc->ActiveLines;
  3548. d1035 2
  3549. a1036 2
  3550.     first = GroupDoc->ServerFirst;
  3551.     last = GroupDoc->ServerLast;
  3552. d1038 7
  3553. a1044 7
  3554.     GlobalUnlock (BlockPtr->hCurBlock);
  3555.     CommDoc->ActiveLines = 0;
  3556.  
  3557.     /* Now ask for the message-id lines */
  3558.     mylen = sprintf (mybuf, "XHDR message-id %ld-%ld", first, last);
  3559.     CommState = ST_XHDR_MID_START;
  3560.     PutCommLine (mybuf);
  3561. d1047 2
  3562. a1048 2
  3563.     char far *refer;    /* , far * end,far * bracket1,far *bracket2; */
  3564.     /*      int bracket_len; */
  3565. d1050 35
  3566. a1084 35
  3567.     /* Access the Group struct, get HANDLE for header data */
  3568.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3569.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3570.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  3571.  
  3572.     header_handle = GroupDoc->header_handle;
  3573.     thread_handle = GroupDoc->thread_handle;
  3574.  
  3575.     GlobalUnlock (BlockPtr->hCurBlock);
  3576.  
  3577.     /* Lock the header data */
  3578.     headers = lock_headers (header_handle, thread_handle);
  3579.  
  3580.     /* for now, we only pay attention to first (whole) referral */
  3581.     refer = get_xhdr_line (CommLineIn);
  3582.  
  3583.     refer = get_best_reference (refer);
  3584.  
  3585.     if (refer) {
  3586.       /* Patch to check for bad info from server JD 6/19/93 */
  3587.       syncnum = sync_artnum (atol (CommLineIn),
  3588.                  (header_elt (headers,
  3589.                           CommDoc->ActiveLines))->number,
  3590.                  headers, GroupDoc);
  3591.       if (syncnum >= 0)
  3592.         mylstrncpy ((header_elt (headers, syncnum))->references,
  3593.             refer, HEADER_REFERENCES_LENGTH);
  3594.     }
  3595.  
  3596.     unlock_headers (header_handle, thread_handle);
  3597.  
  3598.     CommDoc->ActiveLines++;
  3599.     update_window_title (CommDoc->hDocWnd, group,
  3600.                  RcvLineCount++,
  3601.                  CommDoc->TotalLines * total_xhdrs);
  3602. d1095 1
  3603. a1095 1
  3604.     break;
  3605. d1102 2
  3606. a1103 2
  3607.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3608.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3609. d1105 1
  3610. a1105 1
  3611.     GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  3612. d1107 1
  3613. a1107 1
  3614.     GroupDoc->total_headers = CommDoc->ActiveLines;
  3615. d1109 2
  3616. a1110 2
  3617.     first = GroupDoc->ServerFirst;
  3618.     last = GroupDoc->ServerLast;
  3619. d1112 2
  3620. a1113 2
  3621.     GlobalUnlock (BlockPtr->hCurBlock);
  3622.     CommDoc->ActiveLines = 0;
  3623. d1115 4
  3624. a1118 4
  3625.     /* Now ask for the subject lines */
  3626.     mylen = sprintf (mybuf, "XHDR subject %ld-%ld", first, last);
  3627.     CommState = ST_XHDR_SUBJECT_START;
  3628.     PutCommLine (mybuf);
  3629. d1121 29
  3630. a1149 29
  3631.     /* Access the Group struct, get HANDLE for header data */
  3632.     LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3633.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3634.  
  3635.     GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  3636.  
  3637.     header_handle = GroupDoc->header_handle;
  3638.     thread_handle = GroupDoc->thread_handle;
  3639.  
  3640.     GlobalUnlock (BlockPtr->hCurBlock);
  3641.  
  3642.     /* Lock the header data */
  3643.     headers = lock_headers (header_handle, thread_handle);
  3644.  
  3645.     syncnum = sync_artnum (atol (CommLineIn),
  3646.                (header_elt (headers, CommDoc->ActiveLines))->number,
  3647.                    headers,
  3648.                    GroupDoc);
  3649.     if (syncnum >= 0)
  3650.       mylstrncpy ((header_elt (headers, syncnum))->message_id,
  3651.               (char far *) (get_xhdr_line (CommLineIn)),
  3652.               HEADER_MESSAGE_ID_LENGTH);    /* bad, hardcoded. */
  3653.  
  3654.     unlock_headers (header_handle, thread_handle);
  3655.  
  3656.     CommDoc->ActiveLines++;
  3657.     update_window_title (CommDoc->hDocWnd, group,
  3658.                  RcvLineCount++,
  3659.                  CommDoc->TotalLines * total_xhdrs);
  3660. d1160 1
  3661. a1160 1
  3662.     break;
  3663. d1167 4
  3664. a1170 4
  3665.     CommState = ST_IN_GROUP;
  3666.     CommBusy = FALSE;
  3667.     finish_header_retrieval (CommDoc);
  3668.     InvalidateRect (CommDoc->hDocWnd, NULL, FALSE);
  3669. d1174 42
  3670. a1215 42
  3671.     artnum = 0;
  3672.     sscanf (CommLineIn, "%ld", &artnum);
  3673.     if (artnum) {
  3674.       LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  3675.             CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3676.  
  3677.       GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  3678.       header_handle = GroupDoc->header_handle;
  3679.       thread_handle = GroupDoc->thread_handle;
  3680.       headers = lock_headers (header_handle, thread_handle);
  3681.  
  3682.       /* update the seen thing. */
  3683.       syncnum = sync_artnum (atol (CommLineIn),
  3684.                (header_elt (headers, CommDoc->ActiveLines))->number,
  3685.                  headers,
  3686.                  GroupDoc);
  3687.       if (syncnum >= 0)
  3688.         header = header_elt (headers, syncnum);
  3689.       else
  3690.         header = header_elt (headers, CommDoc->ActiveLines);
  3691.  
  3692.       header->Selected = FALSE;
  3693.       header->ArtDoc = (TypDoc *) NULL;
  3694.       header->Seen =
  3695.         WasArtSeen (artnum, (TypGroup far *) (((char far *) LinePtr) +
  3696.                           sizeof (TypLine)));
  3697.  
  3698.       UnlockLine (BlockPtr, LinePtr, &(CommDoc->hParentBlock),
  3699.               &(CommDoc->ParentOffset), &(CommDoc->ParentLineID));
  3700.  
  3701.       mylstrncpy (header->subject,
  3702.               get_xhdr_line (CommLineIn), HEADER_SUBJECT_LENGTH);
  3703.  
  3704.       CommDoc->LongestLine = max (CommDoc->LongestLine,
  3705.                       ARTICLE_SUBJECT_OFFSET +
  3706.                       (unsigned) lstrlen (header->subject));
  3707.  
  3708.       unlock_headers (header_handle, thread_handle);
  3709.       CommDoc->ActiveLines++;
  3710.       update_window_title (CommDoc->hDocWnd, group,
  3711.                    RcvLineCount++,
  3712.                    CommDoc->TotalLines * total_xhdrs);
  3713. d1217 1
  3714. a1217 1
  3715.     }
  3716. d1229 3
  3717. a1231 3
  3718.     if (CommDoc->hDocWnd)
  3719.       DestroyWindow (CommDoc->hDocWnd);
  3720.     break;
  3721. d1239 1
  3722. a1239 1
  3723.     ;            /* error: empty article (end in middle of header) */
  3724. d1242 2
  3725. a1243 2
  3726.       if (IsBlankStr (CommLineIn))    /* headers end in blank line */
  3727.     CommState = ST_REC_ARTICLE;
  3728. d1248 1
  3729. a1248 1
  3730.       if (strcmp (CommLineIn, ".") == 0) {    /* article receive complete */
  3731. d1250 2
  3732. a1251 2
  3733.     CommState = ST_IN_GROUP;
  3734.     CommBusy = FALSE;
  3735. d1253 6
  3736. a1258 6
  3737.     if (CommDecoding) {
  3738.       SendMessage (currentCoded->hParentWnd, IDM_ARTICLE_RETRIEVE_COMPLETE, 0, 0);
  3739.       break;
  3740.     }
  3741.     else
  3742.     {
  3743. d1263 49
  3744. a1311 49
  3745.     LockLine (CommDoc->ParentDoc->hParentBlock,
  3746.           CommDoc->ParentDoc->ParentOffset,
  3747.           CommDoc->ParentDoc->ParentLineID,
  3748.           &BlockPtr, &LinePtr);
  3749.  
  3750.     GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  3751.     header_handle = GroupDoc->header_handle;
  3752.     thread_handle = GroupDoc->thread_handle;
  3753.  
  3754.     headers = lock_headers (header_handle, thread_handle);
  3755.     lpsz = (char far *) ((header_elt (headers, CommDoc->LastSeenLineID))->subject);
  3756.     unlock_headers (header_handle, thread_handle);
  3757.  
  3758.     mylstrncpy (group, lpsz, MAXGROUPNAME);
  3759.     sprintf (mybuf, "%s (%u lines)", group, CommDoc->TotalLines);
  3760.     SetWindowText (CommDoc->hDocWnd, mybuf);
  3761.     InvalidateRect (CommDoc->hDocWnd, NULL, FALSE);
  3762.     GlobalUnlock (BlockPtr->hCurBlock);
  3763.  
  3764.     /* Skip to the first line of the text of the article
  3765.      * and make sure it's visible on the screen.  This is
  3766.      * so that the user doesn't have to have the first
  3767.      * screen filled with a lengthy, worthless header.
  3768.      *
  3769.      * and save number of header lines (on display)
  3770.      * for later (Bretherton)
  3771.      */
  3772.     TopOfDoc (CommDoc, &BlockPtr, &LinePtr);
  3773.     found = FALSE;
  3774.     do {
  3775.       lpsz = ((char far *) LinePtr + sizeof (TypLine) + sizeof (TypText));
  3776.       if (IsLineBlank (lpsz)) {
  3777.         found = TRUE;
  3778.         CommDoc->HeaderLines = WhatLine (BlockPtr, LinePtr);
  3779.         break;
  3780.       }
  3781.       if (!NextLine (&BlockPtr, &LinePtr))
  3782.         break;
  3783.     }
  3784.     while (!found);
  3785.     NextLine (&BlockPtr, &LinePtr);
  3786.  
  3787.     /* If the line is in the last screen's worth of lines, back
  3788.      * up the pointer so it points to the first line of the last
  3789.      * screen.
  3790.      */
  3791.     if (found && CommDoc->TotalLines > CommDoc->ScYLines &&
  3792.         !CommDoc->TopScLineID)
  3793.       AdjustTopSc (BlockPtr, LinePtr);
  3794. d1313 1
  3795. a1313 1
  3796.     UnlockLine (BlockPtr, LinePtr, &hBlock, &Offset, &MyLineID);
  3797. d1315 2
  3798. a1316 2
  3799.       else            /* not finished, continue article receive */
  3800.     AddCommLineToDoc (CommLineIn);
  3801. d1332 4
  3802. a1335 4
  3803.     if (Attaching && !ReviewAttach)
  3804.       ProcessAttach (CONTINUE);
  3805.     else
  3806.       PostText (PostEdit);
  3807. d1338 12
  3808. a1349 12
  3809.     check_server_code (retcode);
  3810.     MessageBox (PostEdit->hWnd, CommLineIn + 4, "Cannot Post Article",
  3811.             MB_OK | MB_ICONEXCLAMATION);
  3812.     CommBusy = FALSE;
  3813.     CommState = ST_NONE;
  3814.  
  3815.     if (Attaching && !ReviewAttach)
  3816.       ProcessAttach (ABORT);    /* cancel attachment */
  3817.  
  3818.     else
  3819.       /* unlock to allow user modification */
  3820.       SendMessage (PostEdit->hWndEdit, EM_SETREADONLY, FALSE, 0L);
  3821. d1362 5
  3822. a1366 5
  3823.     cptr = "Posting Failed";
  3824.     mbcode = MB_OK | MB_ICONEXCLAMATION;
  3825.     MessageBox (PostEdit->hWnd, CommLineIn + 4, cptr, mbcode);
  3826.     /* let 'em fix the post! */
  3827.     SendMessage (PostEdit->hWndEdit, EM_SETREADONLY, FALSE, 0L);
  3828. d1368 2
  3829. a1369 2
  3830.     done = TRUE;
  3831.     nextBatchIndex = 0;    /* cancel any batch */
  3832. d1371 2
  3833. a1372 2
  3834.     if (Attaching && !ReviewAttach)
  3835.       ProcessAttach (ABORT);/* cancel attachment */
  3836. d1376 17
  3837. a1392 17
  3838.     cptr = "Article Posted OK";
  3839.     mbcode = MB_OKCANCEL;
  3840.     /*      if (MessageBox(hPostEdit,CommLineIn+4,cptr,mbcode) */
  3841.     /*           == ID_OK) */
  3842.     if (!Attaching || (Attaching && ReviewAttach)) {
  3843.       if (PostLog) {
  3844.         char *mbuf;
  3845.         mbuf = GetEditText (PostEdit->hWndEdit);
  3846.         WriteEditLog (PostEdit->hWnd, PostLogFile, mbuf,
  3847.               (unsigned int) SendMessage (PostEdit->hWndEdit,
  3848.                           WM_GETTEXTLENGTH, 0, 0L));
  3849.         GlobalFreePtr (mbuf);
  3850.       }
  3851.       PostEdit->dirty = DT_CLEAN;
  3852.       DestroyWindow (PostEdit->hWnd);
  3853.     }
  3854.     done = TRUE;
  3855. d1395 1
  3856. a1395 1
  3857.     break;
  3858. d1398 3
  3859. a1400 3
  3860.     CommBusy = FALSE;
  3861.     CommState = ST_NONE;
  3862.     PostEdit = (WndEdit *) NULL;
  3863. d1402 2
  3864. a1403 2
  3865.     if (nextBatchIndex)    /* if we're sending a batch, send the next */
  3866.       BatchSend (DOCTYPE_POSTING);
  3867. d1406 1
  3868. a1406 1
  3869.     ProcessAttach (CONTINUE);
  3870. d1463 1
  3871. a1463 1
  3872.     *(cdest++) = ' ';
  3873. d1487 1
  3874. a1487 1
  3875.           &(CommDoc->AddOffset), &(CommDoc->AddLineID));
  3876. d1506 1
  3877. a1506 1
  3878.                 GroupPtr + RangeOffset (GroupPtr->NameLen));
  3879. d1511 1
  3880. a1511 1
  3881.     ArtNum <= (unsigned long) RangePtr->Last) {
  3882. d1636 1
  3883. a1636 1
  3884.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3885. d1653 1
  3886. a1653 1
  3887.                sizeof (TypLine) + sizeof (TypGroup));
  3888. d1667 1
  3889. a1667 1
  3890.           CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  3891. d1677 2
  3892. a1678 2
  3893.        ((i > 0) && ((header_elt (headers, i))->Seen == FALSE));
  3894.        i--);
  3895. d1745 1
  3896. a1745 1
  3897.     strcpy (tempName, fileName);    /* no path given.  done */
  3898. d1764 1
  3899. a1764 1
  3900.     strcpy (tempName, fileName);    /* no path given.  done */
  3901. d1863 1
  3902. a1863 1
  3903.   *size = cf.iPointSize / 10;    /* iPointSize is in tenths of a point */
  3904. d1896 1
  3905. a1896 1
  3906.         "Sorry", MB_OK | MB_ICONINFORMATION);
  3907. d1927 1
  3908. a1927 1
  3909.     if (iMessage == fileNameMsg) {    /* Trap the FILEOKSTRING msg */
  3910. d1931 1
  3911. a1931 1
  3912.     return TRUE;
  3913. d1934 1
  3914. a1934 1
  3915.   return FALSE;            /* Allow standard processing */
  3916. d1993 1
  3917. a1993 1
  3918.     chReplace = filters[len - 1];    /* grab separator */
  3919. d1997 1
  3920. a1997 1
  3921.     filters[i] = '\0';
  3922. d2053 2
  3923. a2054 2
  3924.      (retcode = VerifyFileName (fileName)) == FAIL ||
  3925.      (hWriteFile = OpenFile ((char far *) fileName, &outFileStruct, OF_EXIST)) >= 0) {
  3926. d2059 1
  3927. a2059 1
  3928.                 MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION);
  3929. d2061 1
  3930. a2061 1
  3931.     break;
  3932. d2103 1
  3933. a2103 1
  3934.     beg++;            /* skip to after path slash */
  3935. d2106 1
  3936. a2106 1
  3937.     if (strlen (beg) <= 8)    /* no extension */
  3938. d2112 1
  3939. a2112 1
  3940.   beg = ptr + 1;        /* multiple extensions */
  3941. d2116 1
  3942. a2116 1
  3943.   if (strlen (beg) > 3)        /* extension too long */
  3944. d2171 1
  3945. a2171 1
  3946.     editDS = hInst;        /* use local heap instead */
  3947. d2177 1
  3948. a2177 1
  3949.     UnlockSegment (HIWORD ((LONG) lpPtr));    /* we still have a global lock */
  3950. d2181 4
  3951. a2184 4
  3952.            WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER |
  3953.            ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
  3954.                    0, 0, 0, 0,
  3955.              NewWnd->hWnd, (HMENU) EDITID, (HINSTANCE) HIWORD ((LONG) lpPtr), NULL);
  3956. d2187 4
  3957. a2190 4
  3958.            WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER |
  3959.            ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
  3960.                    0, 0, 0, 0,
  3961.                    NewWnd->hWnd, (HMENU) EDITID, hInst, NULL);    /* No problems with Win32 */
  3962. d2351 2
  3963. a2352 2
  3964.           "Please wait until en/decoding is complete",
  3965.           "Cannot close status window", MB_OK | MB_ICONSTOP);
  3966. d2386 1
  3967. a2386 1
  3968.   if (thisSend == 0) {        /* find first in batch (if any) */
  3969. d2389 1
  3970. a2389 1
  3971.     break;
  3972. d2391 1
  3973. a2391 1
  3974.     thisSend++;
  3975. d2394 1
  3976. a2394 1
  3977.       return;            /* no open windows.  cancel */
  3978. d2405 1
  3979. a2405 1
  3980.     nextBatchIndex = 0;        /* no more */
  3981. d2424 3
  3982. a2426 3
  3983.         "Sorry, I am already busy communicating with the server.\n"
  3984.         "Try again in a little while.", msg,
  3985.         MB_OK | MB_ICONASTERISK);
  3986. d2438 3
  3987. a2440 3
  3988.          "Sorry, I can only handle one en/decoding session at a time.\n"
  3989.         "Try again in a little while.", msg,
  3990.         MB_OK | MB_ICONASTERISK);
  3991. @
  3992.  
  3993.  
  3994.  
  3995. 1.64
  3996. log
  3997. @bug fixes to message attachments
  3998. @
  3999. text
  4000. @d2 1
  4001. a2 1
  4002.  * $Id: wvutil.c 1.63 1994/08/05 21:33:22 finken Exp $
  4003. d9 1
  4004. d427 1
  4005. a427 1
  4006.         if (DialogBox (hInst, "WinVnComm", hWndConf, lpfnWinVnCommDlg)
  4007. d583 1
  4008. a583 1
  4009.       DlgStatus = DialogBox (hInst, "THRESHOLD", CommDoc->hDocWnd, lpfnWinVnThresholdDlg);
  4010. d2173 1
  4011. a2173 1
  4012.   NewWnd->hWndEdit = CreateWindow ("edit", (char *) NULL,
  4013. d2177 1
  4014. a2177 1
  4015.              NewWnd->hWnd, EDITID, HIWORD ((LONG) lpPtr), NULL);
  4016. d2183 1
  4017. a2183 1
  4018.                    NewWnd->hWnd, EDITID, hInst, NULL);    /* No problems with Win32 */
  4019. d2281 1
  4020. a2281 1
  4021.       SendMessage (WndPosts[i].hWndEdit, WM_SETFONT, hFontArtNormal, TRUE);
  4022. d2288 1
  4023. a2288 1
  4024.       SendMessage (WndMails[i].hWndEdit, WM_SETFONT, hFontArtNormal, TRUE);
  4025. @
  4026.  
  4027.  
  4028.  
  4029. 1.63
  4030. log
  4031. @Fixed problem with estimated number of articles in a group getting
  4032. zeroed after a cancel from the dialog box.
  4033. @
  4034. text
  4035. @d2 1
  4036. a2 1
  4037.  * $Id: wvutil.c 1.62 1994/08/04 06:30:36 dumoulin Exp finken $
  4038. d1246 1
  4039. a1246 1
  4040.       SendMessage (currentCoded->hParentWnd, IDM_RETRIEVE_COMPLETE, 0, 0);
  4041. d1250 4
  4042. a1253 1
  4043.       SendMessage (CommDoc->ParentDoc->hDocWnd, IDM_RETRIEVE_COMPLETE, 0, 0);
  4044. d1325 1
  4045. a1325 1
  4046.       ProcessAttach (0);
  4047. d1337 1
  4048. a1337 1
  4049.       ProcessAttach (1);    /* cancel attachment */
  4050. d1364 1
  4051. a1364 1
  4052.       ProcessAttach (1);    /* cancel attachment */
  4053. d1398 1
  4054. a1398 1
  4055.     ProcessAttach (0);
  4056. d1676 1
  4057. @
  4058.  
  4059.  
  4060.  
  4061. 1.62
  4062. log
  4063. @Fixed bug with improper cleanup if Cancel selected from threshold
  4064. dialog box.
  4065. @
  4066. text
  4067. @d2 1
  4068. a2 1
  4069.  * $Id: wvutil.c 1.61 1994/07/27 21:34:22 pearse_w_r Exp dumoulin $
  4070. d584 2
  4071. a585 1
  4072.              {
  4073. d590 1
  4074. a590 1
  4075.           GroupDoc->ServerEstNum = 0;
  4076. @
  4077.  
  4078.  
  4079.  
  4080. 1.61
  4081. log
  4082. @reindent
  4083. @
  4084. text
  4085. @d2 1
  4086. a2 1
  4087.  * $Id: wvutil.c 1.59 1994/07/27 20:08:57 rushing Exp pearse_w_r $
  4088. d393 1
  4089. d581 12
  4090. a592 1
  4091.       DialogBox (hInst, "THRESHOLD", CommDoc->hDocWnd, lpfnWinVnThresholdDlg);
  4092. @
  4093.  
  4094.  
  4095.  
  4096. 1.60
  4097. log
  4098. @more showunreadonly stuff
  4099. @
  4100. text
  4101. @d418 1
  4102. a418 1
  4103.       if (retcode == 200 || retcode == 201) { /* was 500 from induced error */
  4104. d494 1
  4105. a494 1
  4106.       if (retcode == 412 && !force_xhdr) /* 412 == 'not in a newsgroup' */
  4107. d569 6
  4108. a574 6
  4109.       
  4110.       sscanf(CommLineIn,"%u %lu %ld %ld %s", &retcode,&estnum,&first,&last,group);
  4111.       
  4112.       LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  4113.            CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  4114.       GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  4115. d576 1
  4116. a576 1
  4117.       
  4118. d582 15
  4119. a596 3
  4120.         && ((last - arts_to_retrieve) > first))
  4121.       {
  4122.         first = (last - arts_to_retrieve) + 1;
  4123. d598 1
  4124. a598 2
  4125.     else
  4126.       if (arts_to_retrieve == -1) /* they clicked 'all of them' */
  4127. d600 1
  4128. a600 18
  4129.     /* added by jlg */
  4130.       else
  4131.         if ((arts_to_retrieve == -2) /* they clicked 'unread' */
  4132.         || (ShowUnreadOnly))   
  4133.           {
  4134.         if (GroupDoc->nRanges)
  4135.           {
  4136.             first = RangePtr[0].Last + 1;
  4137.             arts_to_retrieve = (int) ((last - first) + 1);
  4138.             if (arts_to_retrieve < 50)
  4139.               {
  4140.             arts_to_retrieve = 50;
  4141.             first = last - 49;
  4142.               }
  4143.           }
  4144.         else
  4145.           arts_to_retrieve = (int) estnum;
  4146.           }
  4147. d616 1
  4148. a616 1
  4149.       
  4150. d623 1
  4151. a623 1
  4152.             (long) (arts_to_retrieve)) + sizeof (thread_array *));
  4153. d801 1
  4154. a801 1
  4155.       total_xhdrs = threadp ? 6 : 4; /* we do this here to allow */
  4156. d911 1
  4157. a911 1
  4158.                    (header_elt (headers, CommDoc->ActiveLines))->number,
  4159. d982 1
  4160. a982 1
  4161.                    (header_elt (headers, CommDoc->ActiveLines))->number,
  4162. d1115 1
  4163. a1115 1
  4164.                    (header_elt (headers, CommDoc->ActiveLines))->number,
  4165. d1121 1
  4166. a1121 1
  4167.               HEADER_MESSAGE_ID_LENGTH); /* bad, hardcoded. */
  4168. d1166 1
  4169. a1166 1
  4170.                  (header_elt (headers, CommDoc->ActiveLines))->number,
  4171. d1221 1
  4172. a1221 2
  4173.       if (IsBlankStr (CommLineIn)) /* headers end in blank line */
  4174.  
  4175. d1227 1
  4176. a1227 1
  4177.       if (strcmp (CommLineIn, ".") == 0) { /* article receive complete */
  4178. a1291 1
  4179.  
  4180. d1362 1
  4181. a1362 1
  4182.                               WM_GETTEXTLENGTH, 0, 0L));
  4183. a1378 1
  4184.  
  4185. d1902 1
  4186. a1902 3
  4187.     if (iMessage == fileNameMsg)    /* Trap the FILEOKSTRING msg */
  4188.  
  4189.     {
  4190. d2156 2
  4191. a2157 2
  4192.      WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER |
  4193.         ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL  | ES_AUTOVSCROLL,
  4194. d2162 2
  4195. a2163 2
  4196.      WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER |
  4197.         ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
  4198. d2361 1
  4199. a2361 3
  4200.   if (thisSend == 0)        /* find first in batch (if any) */
  4201.  
  4202.   {
  4203. @
  4204.  
  4205.  
  4206.  
  4207. 1.59
  4208. log
  4209. @removed word wrap <sigh>
  4210. @
  4211. text
  4212. @d2 1
  4213. a2 1
  4214.  * $Id: wvutil.c 1.58 1994/07/25 23:32:16 rushing Exp rushing $
  4215. d406 3
  4216. a408 3
  4217.   // CommDoc is !NULL if retrieving group list, article headers or articles
  4218.   // CommDecoding is true if retrieving article in decode mode (not to a doc)
  4219.   // PostEdit !NULL if we are posting (this is from an edit, no doc involved)
  4220. d418 1
  4221. a418 1
  4222.       if (retcode == 200 || retcode == 201) {    /* was 500 from induced error */
  4223. d446 2
  4224. a447 2
  4225. /*      MRRCloseComm (); */
  4226. /*        PostQuitMessage (0); */
  4227. d494 1
  4228. a494 1
  4229.       if (retcode == 412 && !force_xhdr)    /* 412 == 'not in a newsgroup' */
  4230. d569 6
  4231. a574 7
  4232.  
  4233.       sscanf (CommLineIn, "%u %lu %ld %ld %s",
  4234.           &retcode, &estnum, &first, &last, group);
  4235.  
  4236.       LockLine (CommDoc->hParentBlock, CommDoc->ParentOffset,
  4237.         CommDoc->ParentLineID, &BlockPtr, &LinePtr);
  4238.       GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof (TypLine)));
  4239. d576 1
  4240. a576 1
  4241.  
  4242. d579 35
  4243. a613 3
  4244.     arts_to_retrieve = (unsigned int) estnum;
  4245.     if (!DialogBox (hInst, "THRESHOLD", CommDoc->hDocWnd, lpfnWinVnThresholdDlg)) {
  4246.       // they clicked cancel.  abort it
  4247. a620 32
  4248.  
  4249.     if ((arts_to_retrieve > 0) && ((last - arts_to_retrieve) > first)) {
  4250.       first = (last - arts_to_retrieve) + 1;
  4251.     }
  4252.     else if (arts_to_retrieve == -1)    /* they clicked 'all of them' */
  4253.       arts_to_retrieve = (int) estnum;
  4254.     // added by jlg
  4255.     else if ((arts_to_retrieve == -2)
  4256.          || (ShowUnreadOnly)) {        /* they clicked 'unread' */
  4257.       if (GroupDoc->nRanges) {
  4258.         first = RangePtr[0].Last + 1;
  4259.         arts_to_retrieve = (int) ((last - first) + 1);
  4260.         if (arts_to_retrieve < 50) {
  4261.           arts_to_retrieve = 50;
  4262.           first = last - 49;
  4263.         }
  4264.       }
  4265.       else
  4266.         arts_to_retrieve = (int) estnum;
  4267.     }
  4268.       }
  4269.       else if (estnum > 0)
  4270.     arts_to_retrieve = (int) estnum;
  4271.       else {
  4272.     MessageBox (hWndConf, "Empty Newsgroup", "WinVN", MB_OK | MB_ICONHAND);
  4273.     /* abort the fledgling group window */
  4274.     DestroyWindow (CommDoc->hDocWnd);
  4275.     CommBusy = FALSE;
  4276.     CommState = ST_NONE;
  4277.     GroupDoc->ServerFirst = GroupDoc->ServerLast;
  4278.     GroupDoc->ServerEstNum = 0;
  4279.     return;
  4280. d622 1
  4281. a622 1
  4282.  
  4283. d629 1
  4284. a629 1
  4285.               (long) (arts_to_retrieve)) + sizeof (thread_array *));
  4286. d807 1
  4287. a807 1
  4288.       total_xhdrs = threadp ? 6 : 4;    /* we do this here to allow */
  4289. d917 1
  4290. a917 1
  4291.                (header_elt (headers, CommDoc->ActiveLines))->number,
  4292. d988 1
  4293. a988 1
  4294.                (header_elt (headers, CommDoc->ActiveLines))->number,
  4295. d1032 2
  4296. a1033 2
  4297.     char far *refer;    // , far * end,far * bracket1,far *bracket2;
  4298.     //      int bracket_len;
  4299. d1121 1
  4300. a1121 1
  4301.                (header_elt (headers, CommDoc->ActiveLines))->number,
  4302. d1127 1
  4303. a1127 1
  4304.               HEADER_MESSAGE_ID_LENGTH);    /* bad, hardcoded. */
  4305. d1172 1
  4306. a1172 1
  4307.                (header_elt (headers, CommDoc->ActiveLines))->number,
  4308. d1219 1
  4309. a1219 1
  4310. //      Bossanova = FALSE;
  4311. d1224 1
  4312. a1224 1
  4313.     ;            // error: empty article (end in middle of header)
  4314. d1227 1
  4315. a1227 1
  4316.       if (IsBlankStr (CommLineIn))    // headers end in blank line
  4317. d1234 1
  4318. a1234 1
  4319.       if (strcmp (CommLineIn, ".") == 0) {    // article receive complete
  4320. d1298 1
  4321. a1298 1
  4322.       else            // not finished, continue article receive
  4323. d1306 2
  4324. a1307 2
  4325. //      WndPost = getWndEdit(WndPosts,CommWnd,MAXPOSTWNDS) ;
  4326.       //      found = (WndPost != NULL) ;
  4327. d1309 1
  4328. a1309 1
  4329.       // lock out changes
  4330. d1329 1
  4331. a1329 1
  4332.       ProcessAttach (1);    // cancel attachment
  4333. d1332 1
  4334. a1332 1
  4335.       // unlock to allow user modification
  4336. d1339 2
  4337. a1340 2
  4338. //      WndPost = getWndEdit(WndPosts,CommWnd,MAXPOSTWNDS) ;
  4339.       //      found = (WndPost != NULL) ;
  4340. d1353 1
  4341. a1353 1
  4342.     nextBatchIndex = 0;    // cancel any batch
  4343. d1356 1
  4344. a1356 1
  4345.       ProcessAttach (1);    // cancel attachment
  4346. d1362 2
  4347. a1363 2
  4348. //      if (MessageBox(hPostEdit,CommLineIn+4,cptr,mbcode)
  4349.     //           == ID_OK)
  4350. d1370 1
  4351. a1370 1
  4352.                           WM_GETTEXTLENGTH, 0, 0L));
  4353. d1386 1
  4354. a1386 1
  4355.     if (nextBatchIndex)    // if we're sending a batch, send the next
  4356. d1601 1
  4357. a1601 1
  4358. //  HANDLE hBlock;
  4359. d1691 1
  4360. a1691 1
  4361.   //MessageBox(0,"getWndEditFound Nothing","mrb debug", MB_OK | MB_ICONHAND);
  4362. d1817 4
  4363. a1820 4
  4364.   // convert points to logical units (1 pt = 1/72 inch)
  4365.   // For printer fonts, use ScreenYPixels here anyway - the choosefont
  4366.   // dialog appears to require the lfHeight to be in screen units
  4367.   // we will convert point size to PrinterUnits in InitPrinterFonts()
  4368. d1841 2
  4369. a1842 2
  4370. //      if (!stricmp (style, "Printer"))      // commented out JD 6/17/94
  4371.   //         ReleaseDC (hWndConf, hDC); 
  4372. d1844 2
  4373. a1845 2
  4374. //      if (!stricmp (style, "Printer"))
  4375.   //         DeletePrinterDC (hDC);
  4376. d1847 1
  4377. a1847 1
  4378.   *size = cf.iPointSize / 10;    // iPointSize is in tenths of a point
  4379. d1874 2
  4380. a1875 2
  4381.   // until we figure out how to deal with dithered colors, force
  4382.   // the color to the nearest physical color
  4383. d1911 1
  4384. a1911 1
  4385.     if (iMessage == fileNameMsg)    // Trap the FILEOKSTRING msg
  4386. d1914 2
  4387. a1915 2
  4388.       // if it exists and its a directory, then bypass default 
  4389.       // OK processing
  4390. d1920 1
  4391. a1920 1
  4392.   return FALSE;            // Allow standard processing
  4393. d1934 1
  4394. a1934 1
  4395. //      Open dialog to ask user for a new file name
  4396. d1951 1
  4397. a1951 1
  4398.   // Register the FILEOKSTRING message
  4399. d1953 1
  4400. a1953 1
  4401.   // Pass the FILEOKSTRING message ID in LOWORD of lCustData field
  4402. d1960 1
  4403. a1960 1
  4404. //      FreeProcInstance(&ofn.lpfnHook);
  4405. d1966 1
  4406. a1966 1
  4407. //      Set up filters
  4408. d1979 1
  4409. a1979 1
  4410.     chReplace = filters[len - 1];    // grab separator
  4411. d2000 1
  4412. a2000 1
  4413. //      Open dialog to ask user for a new file name
  4414. d2042 1
  4415. a2042 1
  4416. //      File name ok, but file exists.  Ask user if ok to wipe it
  4417. d2050 1
  4418. a2050 1
  4419. //      Open dialog to ask user for a new file name
  4420. d2157 1
  4421. a2157 1
  4422.     editDS = hInst;        // use local heap instead
  4423. d2163 1
  4424. a2163 1
  4425.     UnlockSegment (HIWORD ((LONG) lpPtr));    // we still have a global lock
  4426. d2176 1
  4427. a2176 1
  4428.                    NewWnd->hWnd, EDITID, hInst, NULL);    // No problems with Win32
  4429. d2332 2
  4430. a2333 2
  4431.   // destroying a coding status text is like popping from a stack
  4432.   // so we just loop while the top of the stack still exists
  4433. d2372 1
  4434. a2372 1
  4435.   if (thisSend == 0)        // find first in batch (if any)
  4436. d2382 1
  4437. a2382 1
  4438.       return;            // no open windows.  cancel
  4439. d2387 1
  4440. a2387 1
  4441.   // find next in batch (if any)
  4442. d2393 1
  4443. a2393 1
  4444.     nextBatchIndex = 0;        // no more
  4445. d2400 1
  4446. @
  4447.  
  4448.  
  4449.  
  4450. 1.58
  4451. log
  4452. @oops.  left of a paren.
  4453. @
  4454. text
  4455. @d2 1
  4456. a2 1
  4457.  * $Id: wvutil.c 1.57 1994/07/25 22:39:06 rushing Exp $
  4458. d2122 1
  4459. a2122 1
  4460.   SendMessage (hWndEdit, EM_FMTLINES, TRUE, 0);
  4461. d2168 2
  4462. a2169 2
  4463.      WS_CHILD | WS_VISIBLE | /* WS_HSCROLL | */ WS_VSCROLL | WS_BORDER |
  4464.         ES_LEFT | ES_MULTILINE | /* ES_AUTOHSCROLL  | */ ES_AUTOVSCROLL,
  4465. d2174 2
  4466. a2175 2
  4467.      WS_CHILD | WS_VISIBLE | /* WS_HSCROLL | */ WS_VSCROLL | WS_BORDER |
  4468.         ES_LEFT | ES_MULTILINE | /* ES_AUTOHSCROLL  | */ ES_AUTOVSCROLL,
  4469. @
  4470.  
  4471.  
  4472.  
  4473. 1.57
  4474. log
  4475. @unreadonly option from pearse, and reindented.
  4476. @
  4477. text
  4478. @d2 1
  4479. a2 1
  4480.  * $Id: wvutil.c 1.56 1994/07/25 18:51:48 jcooper Exp $
  4481. d598 1
  4482. a598 1
  4483.          || (ShowUnreadOnly) {        /* they clicked 'unread' */
  4484. @
  4485.  
  4486.  
  4487.  
  4488. 1.56
  4489. log
  4490. @execution of decoded files
  4491. @
  4492. text
  4493. @d2 1
  4494. a2 1
  4495.  * $Id: wvutil.c 1.55 1994/06/30 16:34:44 dumoulin Exp $
  4496. d10 2
  4497. a11 2
  4498. #include <commdlg.h>    // for GetOpenFileName dialog (JSC)
  4499. #include <windowsx.h>    // for GlobalFreePtr (JSC)
  4500. d17 1
  4501. a17 1
  4502. #include <dos.h>    // _dos_getfileattr
  4503. d19 3
  4504. a21 3
  4505. char far *mylstrcpy(char_p ptr1, char far *ptr2);
  4506. char * get_xhdr_line (char * line);
  4507. time_t parse_usenet_date (char * date);
  4508. d45 18
  4509. a62 17
  4510. GetNum(ptr,num)
  4511. char **ptr;
  4512. long int *num;
  4513. {
  4514.    BOOL gotit = FALSE;
  4515.  
  4516.    /* Skip initial spaces                                            */
  4517.  
  4518.    while((**ptr) && **ptr == ' ') (*ptr)++;
  4519.  
  4520.    *num = 0;
  4521.    while(**ptr && isdigit(**ptr)) {
  4522.       *num = 10*(*num) + (**ptr - '0');
  4523.       gotit = TRUE;
  4524.       (*ptr)++;
  4525.    }
  4526.    return(gotit);
  4527. d65 2
  4528. a66 1
  4529. char * get_xhdr_line (char *line)
  4530. d68 1
  4531. a68 1
  4532.   char * cptr;
  4533. d70 2
  4534. a71 2
  4535.   for(cptr=line; isdigit(*cptr); cptr++);
  4536.   for(;*cptr == ' ';cptr++);
  4537. d77 2
  4538. a78 1
  4539. void make_neat_from (char far *in, char far *out)
  4540. d80 1
  4541. a80 1
  4542.   char far * left, far *right;
  4543. d91 1
  4544. a91 1
  4545.     else                        /* No name in parens */
  4546. d94 2
  4547. a95 2
  4548.   else                          /* !FullNameFrom */
  4549.     strcpy (out,in);
  4550. d105 2
  4551. a106 2
  4552. StrToRGB(cstring)
  4553. char *cstring;
  4554. d108 2
  4555. a109 2
  4556.    BYTE red, green, blue;
  4557.    long int lred, lgreen, lblue;
  4558. d111 8
  4559. a118 6
  4560.    GetNum(&cstring,&lred);
  4561.    cstring++;
  4562.    GetNum(&cstring,&lgreen);
  4563.    cstring++;
  4564.    GetNum(&cstring,&lblue);
  4565.    red = (BYTE) lred; green = (BYTE) lgreen; blue = (BYTE) lblue;
  4566. d120 1
  4567. a120 1
  4568.    return(RGB(red,green,blue));
  4569. d129 2
  4570. a130 1
  4571. char *RGBToStr(char *buf, DWORD rgbVal)
  4572. d132 4
  4573. a135 4
  4574.     sprintf (buf, "%u,%u,%u", GetRValue (rgbVal),
  4575.                   GetGValue (rgbVal),
  4576.                   GetBValue (rgbVal));
  4577.     return (buf);
  4578. d141 1
  4579. a141 1
  4580. parse_usenet_date(char * s)
  4581. d145 1
  4582. a145 1
  4583.   int dom = 0, yr = 0, hr = 0, mn = 0, sc = 0, mth=0 ;
  4584. d148 6
  4585. a153 3
  4586.   if (!s || !*s) return(0);
  4587.   if (cp = strchr(s,',')) s = ++cp;
  4588.   while (isspace(*s)) s++;
  4589. d155 22
  4590. a176 13
  4591.   if (isdigit(*s)) {
  4592.     sscanf(s,"%d %s %d %d:%d:%d",&dom,mon,&yr,&hr,&mn,&sc);
  4593.     if (yr < 100 ) yr += 1900;
  4594.     }
  4595.   else sscanf(s,"%*s %s %d %d:%d:%d %d",mon,&dom,&hr,&mn,&sc,&yr);
  4596.  
  4597.   if (!dom || !yr || !*(cp = mon)) return(0);
  4598.   if ((dom <= 0) || (dom >= 32)) return(0);
  4599.   if ((yr < 1980) || (yr > 2020)) return(0);
  4600.   if (strlen(mon) > 10) return(0);
  4601.   if ((hr < 0) || (hr > 23)) return(0);
  4602.   if ((mn < 0) || (mn > 59)) return(0);
  4603.   if ((sc < 0) || (sc > 59)) return(0);
  4604. d178 2
  4605. a179 2
  4606.   for (cp=mon; *cp; cp++)
  4607.     *cp=tolower(*cp);
  4608. d181 2
  4609. a182 1
  4610.   if (cp=strstr(fmtMonthTable,mon)) mth=(cp-fmtMonthTable)/3;
  4611. d185 1
  4612. a185 1
  4613.     time (seconds since midnight, Jan 1, 1970    JD 06/25/93 */
  4614. d187 6
  4615. a192 6
  4616.     datetime.tm_year = yr - 1900;
  4617.     datetime.tm_mon = mth;
  4618.     datetime.tm_mday = dom;
  4619.     datetime.tm_hour = hr;
  4620.     datetime.tm_min = mn;
  4621.     datetime.tm_sec = sc;
  4622. d194 1
  4623. a194 1
  4624.     return (mktime(&datetime));
  4625. d199 1
  4626. a199 2
  4627. StringDate(char * s,time_t time)
  4628.  
  4629. d202 2
  4630. a203 3
  4631.   if (time != 0)
  4632.     {
  4633.      datetime = localtime(&time);
  4634. d205 2
  4635. a206 8
  4636.      if (fmtDaysB4Mth)
  4637.       {
  4638.        sprintf(s,"%02d%s%02d",datetime->tm_mday,fmtDateDelim,datetime->tm_mon+1);
  4639.       } else
  4640.        {
  4641.    sprintf(s,"%02d%s%02d",datetime->tm_mon+1,fmtDateDelim,datetime->tm_mday);
  4642.        }
  4643.     return(s);
  4644. d208 5
  4645. d214 1
  4646. a214 1
  4647.     return("-----");
  4648. d222 1
  4649. a222 1
  4650. DoCommInput()
  4651. d224 1
  4652. a224 1
  4653.    int ch;
  4654. d226 14
  4655. a239 11
  4656.    while((CommState != ST_CLOSED_COMM) && ((ch = MRRReadComm()) >= 0)) {
  4657.       if(ch == IgnoreCommCh) {
  4658.       } else if(ch == EOLCommCh) {
  4659.     *CommLinePtr = '\0';
  4660.     DoCommState();
  4661.     CommLinePtr = CommLineIn;
  4662.       } else {
  4663.     *(CommLinePtr++) = (char) ch;
  4664.     if(CommLinePtr == CommLineLWAp1) CommLinePtr--;
  4665.       }
  4666.    }
  4667. d244 3
  4668. a246 3
  4669.           char * group_name,
  4670.           unsigned long line_number,
  4671.           unsigned long total_lines)
  4672. d254 1
  4673. a254 1
  4674.       prevPercent = 0;
  4675. d256 1
  4676. a256 1
  4677.   if ((line_number%UPDATE_TITLE_FREQ) == 0) {
  4678. d258 4
  4679. a261 5
  4680.     if (newPercent != prevPercent && newPercent-prevPercent > 1)
  4681.     {
  4682.         sprintf (title, "Retrieving headers for '%s' : %d%%", group_name, newPercent);
  4683.         SetWindowText(hwnd,title);
  4684.         prevPercent = newPercent;
  4685. d266 2
  4686. a267 1
  4687. int check_server_code (int retcode)
  4688. d298 10
  4689. a307 9
  4690.   Normally XREF returns lists of the same length for each header type
  4691.   but some servers have errors that could cause these lists to get
  4692.   out of sync. This function tries to find the proper location in the
  4693.   headers array and returns that location.  If the article number isn't
  4694.   found, it returns -1.  JD 6/19/93 */
  4695.  
  4696. long sync_artnum (unsigned long artnum,
  4697.         unsigned long activenum,
  4698.         header_p headers,TypGroup far * GroupDoc)
  4699. d310 19
  4700. a328 23
  4701.   if (artnum == activenum) return(headerloc);
  4702.    else
  4703.      if (artnum < activenum)
  4704.        {
  4705.    while((artnum != activenum) && (headerloc > 0))
  4706.    {
  4707.     headerloc--;
  4708.     if ((header_elt(headers,headerloc))->number == artnum)
  4709.       return(headerloc);
  4710.    }
  4711.    return(-1);
  4712.        }
  4713.      else
  4714.        {
  4715.    while ((artnum != activenum) && (headerloc <= GroupDoc->total_headers))
  4716.    {
  4717.     headerloc++;
  4718.     if ((header_elt(headers,headerloc))->number == artnum)
  4719.       return(headerloc);
  4720.    }
  4721.    return(-1);
  4722.        }
  4723.  }
  4724. d331 1
  4725. a331 1
  4726. get_best_reference (char * refer)
  4727. d333 2
  4728. a334 2
  4729.   char * bracket1, * bracket2;
  4730.   char * end = refer + strlen(refer) - 1; /* points to NULL */
  4731. d340 1
  4732. a340 1
  4733.     if ((bracket_len < 30) && (!strrchr(bracket1,'>'))) {
  4734. d344 1
  4735. a344 1
  4736.    bracket_len = 0;
  4737. d346 3
  4738. a348 3
  4739.    bracket2 = strrchr (refer, '>');
  4740.    if (bracket2)
  4741.      bracket_len = (int) (bracket2 - bracket1) + 1;
  4742. d360 2
  4743. a361 2
  4744.   if ((bracket1+bracket_len) < end)
  4745.     *(bracket1+bracket_len) = (char) NULL;
  4746. d377 1
  4747. a377 1
  4748. DoCommState()
  4749. d379 1
  4750. a379 1
  4751.   static BOOL dialog_active=FALSE;
  4752. d388 1
  4753. a388 1
  4754.   long int first,last,syncnum;
  4755. d392 1
  4756. a392 1
  4757.   BOOL done=FALSE;
  4758. d403 1
  4759. a403 1
  4760.   TypGroup far * GroupDoc;
  4761. d409 1
  4762. a409 1
  4763.   if(CommDoc || CommDecoding || PostEdit) {
  4764. d411 1
  4765. a411 1
  4766.     switch(CommState) {
  4767. d416 26
  4768. a441 23
  4769.       if(!sscanf(CommLineIn,"%u",&retcode)) break;
  4770.       if(retcode == 200 || retcode == 201) { /* was 500 from induced error */
  4771.         CommBusy = TRUE;
  4772.         do_authinfo = FALSE;
  4773.         if(strlen(NNTPUserName)) {
  4774.           /* We have the AUTHINFO username.  Do we have the password?*/
  4775.           if(!strlen(NNTPPasswordEncrypted)) {
  4776.             /* Get the news server user password from the user */
  4777.             if (DialogBox (hInst, "WinVnComm", hWndConf, lpfnWinVnCommDlg)
  4778.                && strlen(NNTPPasswordEncrypted)) {
  4779.               do_authinfo = TRUE;
  4780.             }
  4781.           } else {
  4782.             do_authinfo = TRUE;
  4783.           }
  4784.         }
  4785.         if(do_authinfo) {
  4786.           sprintf(mybuf,"AUTHINFO user %s",NNTPUserName);
  4787.           CommState = ST_CHECK_AUTHINFO_USERNAME;
  4788.           PutCommLine(mybuf);
  4789.         } else {
  4790.           goto End_Authinfo;
  4791.         }
  4792. d443 3
  4793. a445 2
  4794.       } else {
  4795.         MessageBox (hWndConf, CommLineIn, "Access Problem", MB_OK);
  4796. d456 6
  4797. a461 5
  4798.       sscanf(CommLineIn,"%u",&retcode);
  4799.       if(!retcode) break;
  4800.       if(retcode >= 500) {
  4801.         MessageBox (hWndConf, "Error authorizing your username with the News Server.", "WinVN", MB_OK | MB_ICONHAND);
  4802.         goto End_Authinfo;
  4803. d463 2
  4804. a464 2
  4805.       MRRDecrypt(NNTPPasswordEncrypted,(unsigned char *)mybuf2,MAXINTERNALLINE);
  4806.       sprintf(mybuf,"AUTHINFO pass %s",mybuf2);
  4807. d466 1
  4808. a466 1
  4809.       PutCommLine(mybuf);
  4810. d469 3
  4811. a471 2
  4812.    case ST_CHECK_AUTHINFO_PASSWORD:
  4813.       if(dialog_active)break;
  4814. d473 7
  4815. a479 6
  4816.       if(sscanf(CommLineIn,"%u",&retcode) <= 0) break;
  4817.       if(retcode < 200 || retcode > 299) {
  4818.         dialog_active = TRUE;
  4819.         sprintf(mybuf,"Error authorizing your password with the News Server:\n%s.",CommLineIn);
  4820.         MessageBox (hWndConf,mybuf , "WinVN", MB_OK | MB_ICONHAND);
  4821.         dialog_active = FALSE;
  4822. d485 1
  4823. a485 1
  4824.   End_Authinfo:;
  4825. d493 2
  4826. a494 2
  4827.       sscanf(CommLineIn, "%u", &retcode);
  4828.       if (retcode == 412 && !force_xhdr) /* 412 == 'not in a newsgroup' */
  4829. d496 2
  4830. a497 2
  4831.       else                      /* 500 == 'command not understood' */
  4832.         xoverp = 0;
  4833. d500 1
  4834. a500 1
  4835.       if(dolist == ID_DOLIST_ASK-ID_DOLIST_BASE)
  4836. d502 2
  4837. a503 2
  4838.         "Request LIST from server?", MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2) == IDNO)
  4839.        dolist = 0;
  4840. d505 3
  4841. a507 8
  4842.       if(dolist) {
  4843.         StartList();
  4844.         did_list = 1;
  4845.       } else {
  4846.         did_list = 0;
  4847.         CommState = ST_NONE;
  4848.         CommBusy = FALSE;
  4849.         Initializing = INIT_READY;
  4850. d509 7
  4851. a515 1
  4852.       InvalidateRect(hWndConf,NULL,FALSE);
  4853. d518 1
  4854. a518 1
  4855.      case ST_LIST_RESP:
  4856. d520 4
  4857. a523 4
  4858.       sscanf(CommLineIn,"%u",&retcode);
  4859.       if(retcode != 215) {
  4860.    check_server_code (retcode);
  4861.    break;
  4862. d531 10
  4863. a540 9
  4864.       if(strcmp(CommLineIn,".") == 0) {
  4865.    CommState = ST_NONE;
  4866.    CommBusy = FALSE;
  4867.    Initializing = INIT_READY;
  4868.    InvalidateRect(hWndConf,NULL,FALSE);
  4869.  
  4870.    ProcEndList();
  4871.       } else {
  4872.    ProcListLine((unsigned char *)CommLineIn);
  4873. d546 1
  4874. a546 1
  4875.       sscanf(CommLineIn,"%u",&retcode);
  4876. d549 7
  4877. a555 7
  4878.    MessageBox (hWndConf, "No Such Newsgroup", "Error", MB_OK | MB_ICONHAND);
  4879.    /* abort the fledgling group window */
  4880.    DestroyWindow (CommDoc->hDocWnd);
  4881.    CommBusy = FALSE;
  4882.    CommState = ST_NONE;
  4883.    return;
  4884.    break;
  4885. d557 7
  4886. a563 7
  4887.    MessageBox (hWndConf, "Restricted Access", "WinVN", MB_OK | MB_ICONHAND);
  4888.    /* abort the fledgling group window */
  4889.    DestroyWindow (CommDoc->hDocWnd);
  4890.    CommBusy = FALSE;
  4891.    CommState = ST_NONE;
  4892.    return;
  4893.    break;
  4894. d565 3
  4895. a567 2
  4896.    if (check_server_code(retcode)) return;
  4897.    break;
  4898. d570 2
  4899. a571 2
  4900.       sscanf(CommLineIn,"%u %lu %ld %ld %s",
  4901.         &retcode,&estnum,&first,&last,group);
  4902. d573 3
  4903. a575 3
  4904.       LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  4905.           CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  4906.       GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  4907. d580 30
  4908. a609 33
  4909.         arts_to_retrieve = (unsigned int)estnum;
  4910.         if (!DialogBox (hInst, "THRESHOLD", CommDoc->hDocWnd, lpfnWinVnThresholdDlg))
  4911.         {
  4912.           // they clicked cancel.  abort it
  4913.           DestroyWindow (CommDoc->hDocWnd);
  4914.           CommBusy = FALSE;
  4915.           CommState = ST_NONE;
  4916.           GroupDoc->ServerFirst = GroupDoc->ServerLast;
  4917.           GroupDoc->ServerEstNum = 0;
  4918.           return;
  4919.         }
  4920.    
  4921.    if ((arts_to_retrieve > 0) && ((last - arts_to_retrieve) > first)) {
  4922.      first = (last - arts_to_retrieve) + 1;
  4923.    }
  4924.    else
  4925.      if (arts_to_retrieve == -1) /* they clicked 'all of them' */
  4926.        arts_to_retrieve = (int) estnum;
  4927.                   // added by jlg
  4928.                   else
  4929.                      if (arts_to_retrieve == -2) /* they clicked 'unread' */
  4930.                      {
  4931.                       if (GroupDoc->nRanges) {
  4932.                          first = RangePtr[0].Last + 1;
  4933.                          arts_to_retrieve = (int) ((last - first) + 1);
  4934.                          if (arts_to_retrieve < 50) {
  4935.                            arts_to_retrieve = 50;
  4936.                            first = last - 49;
  4937.                            }
  4938.                          }
  4939.                       else
  4940.                          arts_to_retrieve = (int) estnum;
  4941.                      }
  4942. d612 1
  4943. a612 1
  4944.    arts_to_retrieve = (int) estnum;
  4945. d614 8
  4946. a621 8
  4947.    MessageBox (hWndConf, "Empty Newsgroup", "WinVN", MB_OK | MB_ICONHAND);
  4948.    /* abort the fledgling group window */
  4949.    DestroyWindow (CommDoc->hDocWnd);
  4950.    CommBusy = FALSE;
  4951.    CommState = ST_NONE;
  4952.    GroupDoc->ServerFirst = GroupDoc->ServerLast;
  4953.    GroupDoc->ServerEstNum = 0;
  4954.    return;
  4955. d626 10
  4956. a635 11
  4957.       if (arts_to_retrieve > 0)
  4958.    {
  4959.      header_handle =
  4960.        GlobalAlloc (GMEM_MOVEABLE, (long)
  4961.           ((sizeof (TypHeader)) *
  4962.            (long)(arts_to_retrieve)) + sizeof (thread_array *));
  4963.  
  4964.      /* allocate space for the header_array index table */
  4965.      thread_handle =
  4966.        GlobalAlloc (GMEM_MOVEABLE,
  4967.           (long) ((sizeof (long)) * (long) (arts_to_retrieve)));
  4968. d637 2
  4969. a638 2
  4970.      GroupDoc->header_handle = header_handle;
  4971.      GroupDoc->thread_handle = thread_handle;
  4972. d640 1
  4973. a640 1
  4974.    }
  4975. d645 1
  4976. a645 1
  4977.       GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof(TypLine));
  4978. d650 1
  4979. a650 1
  4980.       GlobalUnlock(BlockPtr->hCurBlock);
  4981. d653 3
  4982. a655 3
  4983.    mylen = sprintf (mybuf, "XOVER %ld-%ld", first, last);
  4984.    CommState = ST_XOVER_START;
  4985.    PutCommLine(mybuf);
  4986. d658 3
  4987. a660 3
  4988.    mylen = sprintf(mybuf,"XHDR from %ld-%ld",first,last);
  4989.    CommState = ST_XHDR_FROM_START;
  4990.    PutCommLine(mybuf);
  4991. d678 4
  4992. a681 4
  4993.       sscanf(CommLineIn,"%d",&retcode);
  4994.       if(retcode == 224) {
  4995.         CommState = ST_XOVER_DATA;
  4996.         CommDoc->ActiveLines = 0;
  4997. d684 3
  4998. a686 3
  4999.           mylen = sprintf(mybuf,"XHDR from %ld-%ld",first,last);
  5000.         CommState = ST_XHDR_FROM_START;
  5001.         PutCommLine(mybuf);
  5002. d691 6
  5003. a696 6
  5004.       if(strcmp(CommLineIn,".") == 0) {
  5005.    /* this is a yuck way to do this */
  5006.    CommState = ST_IN_GROUP;
  5007.    CommBusy = FALSE;
  5008.    finish_header_retrieval (CommDoc);
  5009.    InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);
  5010. d699 14
  5011. a712 2
  5012.    char * this_hop, * next_hop;
  5013.    char * reference;
  5014. d714 75
  5015. a788 86
  5016.    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5017.        CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5018.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  5019.    header_handle = GroupDoc->header_handle;
  5020.    thread_handle = GroupDoc->thread_handle;
  5021.  
  5022.    GlobalUnlock(BlockPtr->hCurBlock);
  5023.  
  5024.    /* Lock the header data */
  5025.    headers = lock_headers (header_handle, thread_handle);
  5026.    header = header_elt (headers, CommDoc->ActiveLines);
  5027.  
  5028.    this_hop=CommLineIn;
  5029.  
  5030.    /* article number */
  5031.    next_hop = strchr (this_hop, '\t');
  5032.    *(next_hop++) = (char) NULL;
  5033.  
  5034.    header->number = atol (this_hop);
  5035.  
  5036.    /* subject */
  5037.    this_hop = next_hop;
  5038.    next_hop = strchr (this_hop, '\t');
  5039.    *(next_hop++) = (char) NULL;
  5040.  
  5041.    mylstrncpy (header->subject, this_hop, HEADER_SUBJECT_LENGTH);
  5042.    CommDoc->LongestLine = max(CommDoc->LongestLine,
  5043.                               ARTICLE_SUBJECT_OFFSET + 
  5044.                                 (unsigned)lstrlen(header->subject) );
  5045.    /* author */
  5046.    this_hop = next_hop;
  5047.    next_hop = strchr (this_hop, '\t');
  5048.    *(next_hop++) = (char) NULL;
  5049.  
  5050.    ParseAddress (this_hop,
  5051.             AddressString,MAXDIALOGSTRING,
  5052.             NameString,MAXDIALOGSTRING ) ;
  5053.  
  5054.    if (FullNameFrom)
  5055.      mylstrncpy (header->from, NameString, HEADER_FROM_LENGTH);
  5056.    else
  5057.      mylstrncpy (header->from, this_hop, HEADER_FROM_LENGTH);
  5058.  
  5059.    /* date */
  5060.    this_hop = next_hop;
  5061.    next_hop = strchr (this_hop, '\t');
  5062.    *(next_hop++) = (char) NULL;
  5063.  
  5064.    header->date = parse_usenet_date (this_hop);
  5065.  
  5066.    /* message-id */
  5067.    this_hop = next_hop;
  5068.    next_hop = strchr (this_hop, '\t');
  5069.    *(next_hop++) = (char) NULL;
  5070.  
  5071.    mylstrncpy (header->message_id, this_hop, HEADER_MESSAGE_ID_LENGTH);
  5072.  
  5073.    /* references */
  5074.    this_hop = next_hop;
  5075.    next_hop = strchr (this_hop, '\t');
  5076.    *(next_hop++) = (char) NULL;
  5077.  
  5078.    reference = get_best_reference (this_hop);
  5079.    if (reference) mylstrncpy (header->references, reference, HEADER_REFERENCES_LENGTH);
  5080.  
  5081.    /* bytes (ignored) */
  5082.    this_hop = next_hop;
  5083.    next_hop = strchr (this_hop, '\t');
  5084.    *(next_hop++) = (char) NULL;
  5085.  
  5086.    /* lines (last one doesn't have to have the tab */
  5087.    this_hop = next_hop;
  5088.    header->lines = atoi (this_hop);
  5089.  
  5090.    /* set other header fields */
  5091.    header->Selected= FALSE ;
  5092.    header->ArtDoc  = (TypDoc *) NULL;
  5093.    header->Seen = WasArtSeen (header->number,GroupDoc);
  5094.  
  5095.    unlock_headers (header_handle, thread_handle);
  5096.  
  5097.    CommDoc->ActiveLines++;
  5098.  
  5099.    update_window_title (CommDoc->hDocWnd, group,
  5100.               RcvLineCount++,
  5101.               CommDoc->TotalLines);
  5102. d807 5
  5103. a811 4
  5104.       sscanf(CommLineIn,"%d",&retcode);
  5105.       total_xhdrs = threadp ? 6 : 4; /* we do this here to allow */
  5106.                  /* mid-session change-of-mind  */
  5107.       if(retcode < 100) break;
  5108. d817 17
  5109. a833 17
  5110.       if(strcmp(CommLineIn,".") == 0) {
  5111.    LockLine(CommDoc->hParentBlock, CommDoc->ParentOffset,
  5112.        CommDoc->ParentLineID, &BlockPtr,&LinePtr);
  5113.  
  5114.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) );
  5115.    GroupDoc->total_headers = CommDoc->ActiveLines;
  5116.  
  5117.    first = GroupDoc->ServerFirst;
  5118.    last = GroupDoc->ServerLast;
  5119.  
  5120.    GlobalUnlock(BlockPtr->hCurBlock);
  5121.    CommDoc->ActiveLines = 0;
  5122.  
  5123.    /* Now ask for the date lines */
  5124.    mylen = sprintf(mybuf,"XHDR date %ld-%ld",first,last);
  5125.    CommState = ST_XHDR_DATE_START;
  5126.    PutCommLine(mybuf);
  5127. d836 36
  5128. a871 36
  5129.    /*      char neat_from [80]; */
  5130.    /* Access the Group struct, get HANDLE for header data */
  5131.    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5132.        CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5133.  
  5134.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) );
  5135.    header_handle = GroupDoc->header_handle;
  5136.    thread_handle = GroupDoc->thread_handle;
  5137.  
  5138.    GlobalUnlock(BlockPtr->hCurBlock);
  5139.  
  5140.    /* Lock the header data */
  5141.    headers = lock_headers (header_handle, thread_handle);
  5142.  
  5143.    sscanf (CommLineIn, "%ld", &artnum);
  5144.    header = header_elt (headers, CommDoc->ActiveLines);
  5145.    header->number = artnum;
  5146.  
  5147.    /* now use some of our nice formatting of email addresses */
  5148.    ParseAddress (get_xhdr_line (CommLineIn),
  5149.             AddressString,MAXDIALOGSTRING,
  5150.             NameString,MAXDIALOGSTRING ) ;
  5151.  
  5152.    /* copy that into headers[].from */
  5153.    if (FullNameFrom)
  5154.      mylstrncpy (header->from, NameString,HEADER_FROM_LENGTH);
  5155.    else
  5156.      mylstrncpy (header->from, AddressString,HEADER_FROM_LENGTH);
  5157.  
  5158.    unlock_headers (header_handle, thread_handle);
  5159.  
  5160.    CommDoc->ActiveLines++;
  5161.  
  5162.    update_window_title (CommDoc->hDocWnd, group,
  5163.               RcvLineCount++,
  5164.               CommDoc->TotalLines * total_xhdrs);
  5165. d878 3
  5166. a880 2
  5167.       sscanf(CommLineIn,"%d",&retcode);
  5168.       if (check_server_code(retcode)) break;
  5169. d886 17
  5170. a902 17
  5171.       if(strcmp(CommLineIn,".") == 0) {
  5172.    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5173.        CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5174.  
  5175.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) );
  5176.    GroupDoc->total_headers = CommDoc->ActiveLines;
  5177.  
  5178.    first = GroupDoc->ServerFirst;
  5179.    last = GroupDoc->ServerLast;
  5180.  
  5181.    GlobalUnlock(BlockPtr->hCurBlock);
  5182.    CommDoc->ActiveLines = 0;
  5183.  
  5184.    /* Now ask for the #of lines */
  5185.    mylen = sprintf(mybuf,"XHDR lines %ld-%ld",first,last);
  5186.    CommState = ST_XHDR_LINES_START;
  5187.    PutCommLine(mybuf);
  5188. d906 25
  5189. a930 21
  5190.    /* Access the Group struct, get HANDLE for header data */
  5191.    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5192.        CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5193.    GroupDoc = ((TypGroup far *)((char far *)LinePtr+sizeof(TypLine)));
  5194.    header_handle = GroupDoc->header_handle;
  5195.    thread_handle = GroupDoc->thread_handle;
  5196.  
  5197.    GlobalUnlock(BlockPtr->hCurBlock);
  5198.  
  5199.    /* Lock the header data */
  5200.    headers = lock_headers (header_handle, thread_handle);
  5201.    syncnum = sync_artnum(atol (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  5202.    if (syncnum >= 0)
  5203.      (header_elt(headers,syncnum))->date = parse_usenet_date (get_xhdr_line (CommLineIn));
  5204.  
  5205.    unlock_headers (header_handle, thread_handle);
  5206.  
  5207.    CommDoc->ActiveLines++;
  5208.    update_window_title (CommDoc->hDocWnd, group,
  5209.               RcvLineCount++,
  5210.               CommDoc->TotalLines * total_xhdrs);
  5211. d937 3
  5212. a939 2
  5213.       sscanf(CommLineIn,"%d",&retcode);
  5214.       if (check_server_code(retcode)) break;
  5215. d945 26
  5216. a970 26
  5217.       if(strcmp(CommLineIn,".") == 0) {
  5218.    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5219.        CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5220.  
  5221.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) );
  5222.    GroupDoc->total_headers = CommDoc->ActiveLines;
  5223.  
  5224.    first = GroupDoc->ServerFirst;
  5225.    last = GroupDoc->ServerLast;
  5226.  
  5227.    GlobalUnlock(BlockPtr->hCurBlock);
  5228.    CommDoc->ActiveLines = 0;
  5229.  
  5230.    /* Check for threading option, if enabled, go to REF & ID */
  5231.    /* states first */
  5232.  
  5233.    if (threadp) {
  5234.      CommState = ST_XHDR_REF_START;
  5235.      mylen = sprintf(mybuf,"XHDR references %ld-%ld",first,last);
  5236.      PutCommLine(mybuf);
  5237.    }
  5238.    else {
  5239.      CommState = ST_XHDR_SUBJECT_START;
  5240.      mylen = sprintf(mybuf,"XHDR subject %ld-%ld",first,last);
  5241.      PutCommLine(mybuf);
  5242.    }
  5243. d975 25
  5244. a999 22
  5245.    /* Access the Group struct, get HANDLE for header data */
  5246.    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5247.        CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5248.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  5249.  
  5250.    header_handle = GroupDoc->header_handle;
  5251.    thread_handle = GroupDoc->thread_handle;
  5252.  
  5253.    GlobalUnlock(BlockPtr->hCurBlock);
  5254.  
  5255.    /* Lock the header data */
  5256.    headers = lock_headers (header_handle, thread_handle);
  5257.  
  5258.    syncnum = sync_artnum(atol (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  5259.    if (syncnum >= 0)
  5260.       sscanf (CommLineIn, "%ld %Fd", &artnum,&((header_elt(headers,syncnum))->lines));
  5261.  
  5262.    unlock_headers (header_handle, thread_handle);
  5263.    CommDoc->ActiveLines++;
  5264.    update_window_title (CommDoc->hDocWnd, group,
  5265.               RcvLineCount++,
  5266.               CommDoc->TotalLines * total_xhdrs);
  5267. d1006 3
  5268. a1008 2
  5269.       sscanf(CommLineIn,"%d",&retcode);
  5270.       if (check_server_code(retcode)) break;
  5271. d1014 17
  5272. a1030 17
  5273.       if(strcmp(CommLineIn,".") == 0) {
  5274.    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5275.        CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5276.  
  5277.    GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof(TypLine));
  5278.    GroupDoc->total_headers = CommDoc->ActiveLines;
  5279.  
  5280.    first = GroupDoc->ServerFirst;
  5281.    last = GroupDoc->ServerLast;
  5282.  
  5283.    GlobalUnlock(BlockPtr->hCurBlock);
  5284.    CommDoc->ActiveLines = 0;
  5285.  
  5286.    /* Now ask for the message-id lines */
  5287.    mylen = sprintf(mybuf,"XHDR message-id %ld-%ld",first,last);
  5288.    CommState = ST_XHDR_MID_START;
  5289.    PutCommLine(mybuf);
  5290. d1033 31
  5291. a1063 2
  5292.    char far * refer;    // , far * end,far * bracket1,far *bracket2;
  5293. //      int bracket_len;
  5294. d1065 6
  5295. a1070 36
  5296.    /* Access the Group struct, get HANDLE for header data */
  5297.    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5298.        CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5299.    GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  5300.  
  5301.    header_handle = GroupDoc->header_handle;
  5302.    thread_handle = GroupDoc->thread_handle;
  5303.  
  5304.    GlobalUnlock(BlockPtr->hCurBlock);
  5305.  
  5306.    /* Lock the header data */
  5307.    headers = lock_headers (header_handle, thread_handle);
  5308.  
  5309.    /* for now, we only pay attention to first (whole) referral */
  5310.    refer = get_xhdr_line(CommLineIn);
  5311.  
  5312.    refer = get_best_reference (refer);
  5313.  
  5314.    if (refer)
  5315.      {
  5316.       /* Patch to check for bad info from server JD 6/19/93 */
  5317.      syncnum = sync_artnum(atol (CommLineIn),
  5318.             (header_elt(headers,
  5319.                    CommDoc->ActiveLines))->number,
  5320.             headers,GroupDoc);
  5321.      if (syncnum >= 0)
  5322.             mylstrncpy ((header_elt (headers,syncnum))->references,
  5323.          refer,HEADER_REFERENCES_LENGTH);
  5324.      }
  5325.  
  5326.    unlock_headers (header_handle, thread_handle);
  5327.  
  5328.    CommDoc->ActiveLines++;
  5329.    update_window_title (CommDoc->hDocWnd, group,
  5330.               RcvLineCount++,
  5331.               CommDoc->TotalLines * total_xhdrs);
  5332. d1079 3
  5333. a1081 2
  5334.       sscanf(CommLineIn,"%d",&retcode);
  5335.       if (check_server_code(retcode)) break;
  5336. d1087 3
  5337. a1089 3
  5338.       if(strcmp(CommLineIn,".") == 0) {
  5339.    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5340.        CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5341. d1091 1
  5342. a1091 1
  5343.    GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof(TypLine));
  5344. d1093 1
  5345. a1093 1
  5346.    GroupDoc->total_headers = CommDoc->ActiveLines;
  5347. d1095 2
  5348. a1096 2
  5349.    first = GroupDoc->ServerFirst;
  5350.    last = GroupDoc->ServerLast;
  5351. d1098 2
  5352. a1099 2
  5353.    GlobalUnlock(BlockPtr->hCurBlock);
  5354.    CommDoc->ActiveLines = 0;
  5355. d1101 4
  5356. a1104 4
  5357.    /* Now ask for the subject lines */
  5358.    mylen = sprintf(mybuf,"XHDR subject %ld-%ld",first,last);
  5359.    CommState = ST_XHDR_SUBJECT_START;
  5360.    PutCommLine(mybuf);
  5361. d1107 3
  5362. a1109 3
  5363.    /* Access the Group struct, get HANDLE for header data */
  5364.    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5365.        CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5366. d1111 1
  5367. a1111 1
  5368.    GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof(TypLine));
  5369. d1113 2
  5370. a1114 2
  5371.    header_handle = GroupDoc->header_handle;
  5372.    thread_handle = GroupDoc->thread_handle;
  5373. d1116 1
  5374. a1116 1
  5375.    GlobalUnlock(BlockPtr->hCurBlock);
  5376. d1118 2
  5377. a1119 2
  5378.    /* Lock the header data */
  5379.    headers = lock_headers (header_handle, thread_handle);
  5380. d1121 8
  5381. a1128 5
  5382.    syncnum = sync_artnum(atol (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  5383.    if (syncnum >= 0)
  5384.      mylstrncpy((header_elt (headers,syncnum))->message_id,
  5385.            (char far *) (get_xhdr_line (CommLineIn)),
  5386.            HEADER_MESSAGE_ID_LENGTH);         /* bad, hardcoded. */
  5387. d1130 1
  5388. a1130 1
  5389.    unlock_headers (header_handle, thread_handle);
  5390. d1132 4
  5391. a1135 4
  5392.    CommDoc->ActiveLines++;
  5393.    update_window_title (CommDoc->hDocWnd, group,
  5394.               RcvLineCount++,
  5395.               CommDoc->TotalLines * total_xhdrs);
  5396. d1144 3
  5397. a1146 2
  5398.       sscanf(CommLineIn,"%d",&retcode);
  5399.       if (check_server_code(retcode)) break;
  5400. d1152 5
  5401. a1156 5
  5402.       if(strcmp(CommLineIn,".") == 0) {
  5403.    CommState = ST_IN_GROUP;
  5404.    CommBusy = FALSE;
  5405.    finish_header_retrieval (CommDoc);
  5406.    InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);
  5407. d1160 42
  5408. a1201 39
  5409.    artnum = 0;
  5410.    sscanf(CommLineIn,"%ld",&artnum);
  5411.    if(artnum) {
  5412.      LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5413.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5414.  
  5415.      GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  5416.      header_handle = GroupDoc->header_handle;
  5417.      thread_handle = GroupDoc->thread_handle;
  5418.      headers = lock_headers (header_handle, thread_handle);
  5419.  
  5420.      /* update the seen thing. */
  5421.      syncnum = sync_artnum(atol (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  5422.      if (syncnum >= 0)
  5423.         header = header_elt (headers, syncnum);
  5424.      else
  5425.         header = header_elt (headers, CommDoc->ActiveLines);
  5426.  
  5427.      header->Selected= FALSE ;
  5428.      header->ArtDoc  = (TypDoc *) NULL;
  5429.      header->Seen =
  5430.        WasArtSeen (artnum,(TypGroup far *)( ((char far *)LinePtr) +
  5431.                   sizeof(TypLine) ) );
  5432.  
  5433.      UnlockLine(BlockPtr,LinePtr,&(CommDoc->hParentBlock),
  5434.            &(CommDoc->ParentOffset),&(CommDoc->ParentLineID));
  5435.  
  5436.      mylstrncpy(header->subject,
  5437.            get_xhdr_line (CommLineIn), HEADER_SUBJECT_LENGTH);
  5438.  
  5439.      CommDoc->LongestLine = max(CommDoc->LongestLine,
  5440.                                 ARTICLE_SUBJECT_OFFSET + 
  5441.                                 (unsigned)lstrlen(header->subject));
  5442.  
  5443.      unlock_headers (header_handle, thread_handle);
  5444.      CommDoc->ActiveLines++;
  5445.      update_window_title (CommDoc->hDocWnd, group,
  5446.                 RcvLineCount++,
  5447.                 CommDoc->TotalLines * total_xhdrs);
  5448. d1203 1
  5449. a1203 1
  5450.    }
  5451. d1213 5
  5452. a1217 6
  5453.       sscanf(CommLineIn,"%d",&retcode);
  5454.       if (check_server_code(retcode))
  5455.       {
  5456.         if (CommDoc->hDocWnd)
  5457.            DestroyWindow (CommDoc->hDocWnd);
  5458.           break;
  5459. d1224 3
  5460. a1226 2
  5461.       if(strcmp(CommLineIn,".") == 0) {
  5462.     ; // error: empty article (end in middle of header)
  5463. d1228 3
  5464. a1230 14
  5465.       if (IsBlankStr (CommLineIn))      // headers end in blank line
  5466.          CommState = ST_REC_ARTICLE;
  5467. /*      else if (!strnicmp (CommLineIn, "MIME-Version:"))
  5468.       {
  5469.          Bossanova = TRUE;
  5470.          // add line to doc or eat it?
  5471.          // instantiate new MIME object
  5472.          PushMIME (InitMIMEObject());
  5473.          AddCommLineToDoc (CommLineIn);
  5474.          continue;
  5475.       }
  5476.       if (Bossanova)
  5477.          ProcessMIME (CommLineIn)
  5478. */
  5479. d1235 1
  5480. a1235 10
  5481.       if(strcmp(CommLineIn,".") == 0) {        // article receive complete
  5482.         CommState = ST_IN_GROUP;
  5483.         CommBusy = FALSE;
  5484.  
  5485.     if (CommDecoding)
  5486.            {
  5487.              SendMessage(currentCoded->hParentWnd, IDM_RETRIEVE_COMPLETE, 0, 0);
  5488.        break;
  5489.     } else
  5490.       SendMessage(CommDoc->ParentDoc->hDocWnd, IDM_RETRIEVE_COMPLETE, 0, 0);
  5491. d1237 10
  5492. d1260 5
  5493. a1264 5
  5494.     mylstrncpy(group,lpsz,MAXGROUPNAME);
  5495.     sprintf(mybuf,"%s (%u lines)",group,CommDoc->TotalLines);
  5496.     SetWindowText(CommDoc->hDocWnd,mybuf);
  5497.     InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);
  5498.     GlobalUnlock(BlockPtr->hCurBlock);
  5499. d1274 1
  5500. a1274 1
  5501.     TopOfDoc(CommDoc,&BlockPtr,&LinePtr);
  5502. d1277 2
  5503. a1278 2
  5504.         lpsz = ((char far *)LinePtr + sizeof(TypLine) + sizeof(TypText));
  5505.       if(IsLineBlank(lpsz)) {
  5506. d1280 1
  5507. a1280 1
  5508.         CommDoc->HeaderLines=WhatLine (BlockPtr, LinePtr);
  5509. d1283 13
  5510. a1295 11
  5511.       if(!NextLine(&BlockPtr,&LinePtr)) break;
  5512.     } while(!found);
  5513.     NextLine(&BlockPtr,&LinePtr);
  5514.  
  5515.         /* If the line is in the last screen's worth of lines, back
  5516.          * up the pointer so it points to the first line of the last
  5517.          * screen.
  5518.          */
  5519.     if(found && CommDoc->TotalLines > CommDoc->ScYLines &&
  5520.        !CommDoc->TopScLineID)
  5521.           AdjustTopSc(BlockPtr,LinePtr);
  5522. d1297 1
  5523. a1297 1
  5524.         UnlockLine(BlockPtr,LinePtr,&hBlock,&Offset,&MyLineID);
  5525. d1299 3
  5526. a1301 2
  5527.       else    // not finished, continue article receive
  5528.         AddCommLineToDoc (CommLineIn);
  5529. d1308 1
  5530. a1308 1
  5531. //      found = (WndPost != NULL) ;
  5532. d1311 1
  5533. a1311 1
  5534.       SendMessage(PostEdit->hWndEdit, EM_SETREADONLY, TRUE, 0L);
  5535. d1314 1
  5536. a1314 1
  5537.       sscanf(CommLineIn,"%u",&retcode);
  5538. d1316 19
  5539. a1334 17
  5540.       if(retcode == 340) {
  5541.         if (Attaching && !ReviewAttach)
  5542.             ProcessAttach (0);
  5543.         else
  5544.            PostText(PostEdit);
  5545.       } else {
  5546.         check_server_code (retcode);
  5547.         MessageBox(PostEdit->hWnd,CommLineIn+4,"Cannot Post Article",
  5548.                    MB_OK|MB_ICONEXCLAMATION);
  5549.         CommBusy = FALSE;
  5550.         CommState = ST_NONE;
  5551.  
  5552.         if (Attaching && !ReviewAttach)
  5553.             ProcessAttach (1);        // cancel attachment
  5554.          else
  5555.         // unlock to allow user modification
  5556.             SendMessage(PostEdit->hWndEdit, EM_SETREADONLY, FALSE, 0L);
  5557. d1341 1
  5558. a1341 1
  5559. //      found = (WndPost != NULL) ;
  5560. d1343 1
  5561. a1343 1
  5562.  /* no check for failure to find posting documents */
  5563. d1345 18
  5564. a1362 15
  5565.       sscanf(CommLineIn,"%d",&retcode);
  5566.       if(retcode == 441 || retcode == 440) {
  5567.    cptr = "Posting Failed";
  5568.    mbcode = MB_OK|MB_ICONEXCLAMATION;
  5569.    MessageBox(PostEdit->hWnd,CommLineIn+4,cptr,mbcode);
  5570.    /* let 'em fix the post! */
  5571.    SendMessage(PostEdit->hWndEdit, EM_SETREADONLY, FALSE, 0L);
  5572.  
  5573.    done = TRUE;
  5574.    nextBatchIndex = 0;    // cancel any batch
  5575.    if (Attaching && !ReviewAttach)
  5576.         ProcessAttach (1);    // cancel attachment
  5577.    } else if(retcode == 240) {
  5578.    cptr = "Article Posted OK";
  5579.    mbcode = MB_OKCANCEL;
  5580. d1364 12
  5581. a1375 10
  5582. //           == ID_OK)
  5583.    if (!Attaching || (Attaching && ReviewAttach))
  5584.    {
  5585.     if (PostLog)
  5586.     {
  5587.        char *mbuf ;
  5588.        mbuf = GetEditText (PostEdit->hWndEdit);
  5589.        WriteEditLog(PostEdit->hWnd,PostLogFile,mbuf,
  5590.                    (unsigned int) SendMessage (PostEdit->hWndEdit, WM_GETTEXTLENGTH, 0, 0L)) ;
  5591.        GlobalFreePtr (mbuf);
  5592. d1377 1
  5593. a1377 14
  5594.     PostEdit->dirty=DT_CLEAN ;
  5595.     DestroyWindow(PostEdit->hWnd) ;
  5596.    }
  5597.    done = TRUE;
  5598.   } else
  5599.    if (check_server_code (retcode)) break;
  5600.  
  5601.       if(done) {
  5602.         CommBusy = FALSE;
  5603.         CommState = ST_NONE;
  5604.         PostEdit = (WndEdit *) NULL;
  5605.  
  5606.         if (nextBatchIndex)    // if we're sending a batch, send the next
  5607.           BatchSend (DOCTYPE_POSTING);
  5608. d1379 2
  5609. a1380 3
  5610.       if (Attaching && !ReviewAttach)
  5611.         ProcessAttach (0);
  5612.       break;
  5613. d1382 4
  5614. a1385 1
  5615.       /* the following code is for an MRR-hacked nntp server */
  5616. d1387 1
  5617. a1387 3
  5618. /* Code not used anywhere
  5619.          M Bretherton 14 June 1993
  5620. #if 0
  5621. d1389 1
  5622. a1389 9
  5623.     case ST_MAIL_WAIT_PERMISSION:
  5624.       for(ih=0,found=FALSE; !found && ih<MAXMAILWNDS; ih++) {
  5625.    if( WndMails[ih].hWnd) == CommWnd) {
  5626.  
  5627.      hWndPost = WndMails[ih];
  5628.  
  5629.      found = TRUE;
  5630.      break;
  5631.    }
  5632. d1391 2
  5633. a1392 13
  5634.       retcode = 0;
  5635.       sscanf(CommLineIn,"%d",&retcode);
  5636.       if(retcode <= 0) {
  5637.    break;
  5638.       } else if(retcode == 350) {
  5639.    PostText(ih,DOCTYPE_MAIL);
  5640.       } else {
  5641.    MessageBox(WndPost->hWnd,CommLineIn+4,"Cannot Mail Message",
  5642.          MB_OK|MB_ICONEXCLAMATION);
  5643.    CommBusy = FALSE;
  5644.    CommState = ST_NONE;
  5645.       }
  5646.  
  5647. d1395 1
  5648. a1395 32
  5649.     case ST_POST_WAIT_END:
  5650.       for(ih=0,found=FALSE; !found && ih<MAXPOSTWNDS; ih++) {
  5651.    if(WbdPosts[ih].hWnd) == CommWnd) {
  5652.  
  5653.      WndPost = WndPosts[ih];
  5654.  
  5655.      found = TRUE;
  5656.      break;
  5657.    }
  5658.       }
  5659.       retcode = 0;
  5660.       sscanf(CommLineIn,"%d",&retcode);
  5661.       if(retcode == 441 || retcode == 440) {
  5662.    cptr = "Posting Failed";
  5663.    mbcode = MB_OK|MB_ICONEXCLAMATION;
  5664.    MessageBox(WndPost->hWnd,CommLineIn+4,cptr,mbcode);
  5665.    done = TRUE;
  5666.       } else if(retcode == 240) {
  5667.    cptr = "Article Posted OK";
  5668.    mbcode = MB_OKCANCEL;
  5669. //      if (MessageBox(WndPost->hWnd,CommLineIn+4,cptr,mbcode)
  5670. //           == ID_OK)
  5671.    DestroyWindow(WndPost->hWnd) ;
  5672.    done = TRUE;
  5673.       } else
  5674.    if (check_server_code (retcode)) break;
  5675.  
  5676.       if(done) {
  5677.    CommBusy = FALSE;
  5678.    CommState = ST_NONE;
  5679.       }
  5680.       break;
  5681. a1396 2
  5682. #endif
  5683. */
  5684. d1405 1
  5685. a1405 1
  5686. isLineQuotation(char *textptr)
  5687. d1407 7
  5688. a1413 5
  5689.    char *loc ;
  5690.    loc = memchr(textptr,QuoteLineInd,2);
  5691.    if (!loc) loc = memchr(textptr,'|',2);
  5692.    if (!loc) loc = memchr(textptr,':',2);
  5693.    return(loc!=NULL) ;
  5694. d1424 11
  5695. a1434 11
  5696.     TypLine far *LinePtr;
  5697.     TypBlock far *BlockPtr;
  5698.     char *cptr, *cdest;
  5699.     int col, mylen;
  5700.     char artline[MAXINTERNALLINE];
  5701.  
  5702.     /* special case for lines starting with '..' */
  5703.     if (strncmp (CommLineIn, "..", 2))
  5704.       cptr = CommLineIn;
  5705.     else
  5706.       cptr = CommLineIn + 1;
  5707. d1436 23
  5708. a1458 22
  5709.     if (CommDecoding)
  5710.     {
  5711.       DecodeLine (currentCoded, cptr);
  5712.        return;
  5713.      }
  5714.     /* Copy this line into an image of a textblock line,
  5715.      * expanding tabs.
  5716.      */
  5717.     cdest = artline+sizeof(TypLine)+sizeof(TypText);
  5718.     for(col=0;
  5719.         *cptr && col<(MAXINTERNALLINE-3*sizeof(TypLine)-sizeof(TypText));
  5720.         cptr++) {
  5721.       if(*cptr == '\t') {
  5722.         do {
  5723.           *(cdest++) = ' ';
  5724.         } while (++col & 7);
  5725.       } else {
  5726.         *(cdest++) = *cptr;
  5727.         col++;
  5728.       }
  5729.     }
  5730.     *(cdest++) = '\0';
  5731. d1460 14
  5732. a1473 14
  5733.     ((TypLine *)artline)->LineID = NextLineID++;
  5734.     LockLine(CommDoc->hCurAddBlock,CommDoc->AddOffset,CommDoc->AddLineID,&BlockPtr,&LinePtr);
  5735.     mylen = (cdest-artline) + sizeof(int);
  5736.     mylen += mylen%2;
  5737.     ((TypText *)(artline+sizeof(TypLine)))->NameLen =
  5738.       (cdest-1) - (artline+sizeof(TypLine)+sizeof(TypText));
  5739.     ((TypLine *)artline)->length = mylen;
  5740.     ((TypLine *)artline)->active = TRUE;
  5741.     *( (int *) (artline+mylen-sizeof(int)) ) = mylen;
  5742.     AddLine((TypLine *)artline,&BlockPtr,&LinePtr);
  5743.     CommDoc->LongestLine = max(CommDoc->LongestLine,(unsigned)mylen);
  5744.     CommDoc->ActiveLines++;
  5745.     UnlockLine(BlockPtr,LinePtr,&(CommDoc->hCurAddBlock),
  5746.            &(CommDoc->AddOffset),&(CommDoc->AddLineID));
  5747. d1475 2
  5748. a1476 2
  5749.     if ((CommDoc->TotalLines % UPDATE_ART_FREQ) == 0)
  5750.       InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);
  5751. d1487 18
  5752. a1504 17
  5753. WasArtSeen(ArtNum,GroupPtr)
  5754. unsigned long ArtNum;
  5755. TypGroup far *GroupPtr;
  5756. {
  5757.    TypRange far *RangePtr = (TypRange far *) ((char far *)
  5758.       GroupPtr + RangeOffset(GroupPtr->NameLen));
  5759.    unsigned int nr;
  5760.  
  5761.    for(nr=0; nr < GroupPtr->nRanges; nr++) {
  5762.       if(ArtNum >= (unsigned long) RangePtr->First &&
  5763.      ArtNum <= (unsigned long) RangePtr->Last) {
  5764.     return(TRUE);
  5765.       } else {
  5766.     RangePtr++;
  5767.       }
  5768.    }
  5769.    return(FALSE);
  5770. d1513 14
  5771. a1526 13
  5772. mylstrncmp(ptr1,ptr2,len)
  5773. char far *ptr1;
  5774. char far *ptr2;
  5775. int len;
  5776. {
  5777.    for(;len--;ptr1++,ptr2++) {
  5778.       if(*ptr1 > *ptr2) {
  5779.     return(1);
  5780.       } else if(*ptr1 < *ptr2) {
  5781.     return(-1);
  5782.       }
  5783.    }
  5784.    return(0);
  5785. d1534 12
  5786. a1545 12
  5787. mylstrncpy(ptr1,ptr2,len)
  5788. char far *ptr1;
  5789. char far *ptr2;
  5790. int len;
  5791. {
  5792.    char far *targ = ptr1;
  5793.  
  5794.    for(; --len && *ptr2; ptr1++,ptr2++) {
  5795.       *ptr1 = *ptr2;
  5796.    }
  5797.    *ptr1 = '\0';
  5798.    return(targ);
  5799. d1551 2
  5800. a1552 2
  5801. char_p ptr1;
  5802. char far *ptr2;
  5803. d1556 1
  5804. a1556 1
  5805.      *ptr1 = *ptr2;
  5806. d1569 23
  5807. a1591 20
  5808. lstrcmpnoblank(str1,str2)
  5809. char far **str1;
  5810. char far **str2;
  5811. {
  5812.    register char far *s1=*str1, far *s2=*str2;
  5813.  
  5814.    for(;*s1 && *s2 && *s1!=' ' && *s2!=' '; s1++,s2++) {
  5815.       if(*s1 > *s2) {
  5816.          return (1);
  5817.       } else if(*s1 < *s2) {
  5818.          return (-1);
  5819.       }
  5820.    }
  5821.    if(*s1 == *s2) {
  5822.       return(0);
  5823.    } else if(*s1) {
  5824.       return(1);
  5825.    } else {
  5826.       return(-1);
  5827.    }
  5828. d1600 1
  5829. a1600 1
  5830.   TypGroup far * GroupDoc;
  5831. d1603 1
  5832. a1603 1
  5833.   char far * lpsz;
  5834. d1617 1
  5835. a1617 1
  5836.   /* CommDoc->ActiveLines = 0;*/
  5837. d1621 2
  5838. a1622 2
  5839.   LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5840.       CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5841. d1624 1
  5842. a1624 1
  5843.   GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  5844. d1638 2
  5845. a1639 2
  5846.   lpsz = (char far *) ( ((char far *)LinePtr) +
  5847.              sizeof(TypLine)+ sizeof(TypGroup) ) ;
  5848. d1641 3
  5849. a1643 3
  5850.   mylstrncpy(group,lpsz,MAXGROUPNAME);
  5851.   sprintf(mybuf,"%s (%u articles)",group,CommDoc->TotalLines);
  5852.   SetWindowText(CommDoc->hDocWnd,mybuf);
  5853. d1652 2
  5854. a1653 2
  5855.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  5856.         CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  5857. d1656 1
  5858. a1656 1
  5859.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  5860. d1661 1
  5861. a1661 1
  5862.     if (CommDoc->TotalLines >0)
  5863. d1663 2
  5864. a1664 2
  5865.        ((i > 0) && ((header_elt(headers,i))->Seen == FALSE));
  5866.        i--) ;
  5867. d1670 1
  5868. a1670 1
  5869.   InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);
  5870. d1681 2
  5871. a1682 1
  5872. WndEdit * getWndEdit(WndEdit * WndEdits,HWND hWnd,int numEntries)
  5873. d1684 1
  5874. a1684 1
  5875.   int ih ;
  5876. d1686 3
  5877. a1688 6
  5878.   for(ih=0; ih<numEntries; ih++)
  5879.     {
  5880.       if(WndEdits[ih].hWnd == hWnd)
  5881.    {
  5882.      return & WndEdits[ih] ;
  5883.    }
  5884. d1690 1
  5885. d1694 1
  5886. a1694 1
  5887.   return(WndEdit *) NULL ;
  5888. d1708 1
  5889. a1708 1
  5890.     char *theDot;
  5891. d1710 4
  5892. a1713 4
  5893.     if ((theDot = strrchr (fileName, '.')) == NULL)
  5894.        *tempName = '\0';
  5895.     else
  5896.        strcpy (tempName, &fileName[theDot - fileName + 1]);
  5897. d1715 1
  5898. a1715 1
  5899.     return (tempName);
  5900. d1727 1
  5901. a1727 1
  5902.     char *lastSlash;
  5903. d1729 4
  5904. a1732 4
  5905.     if ((lastSlash = strrchr (fileName, '\\')) == NULL)
  5906.        strcpy (tempName, fileName);        /* no path given.  done */
  5907.     else
  5908.        strcpy (tempName, &fileName[lastSlash - fileName + 1]);
  5909. d1734 1
  5910. a1734 1
  5911.     return (tempName);
  5912. d1746 1
  5913. a1746 1
  5914.     char *lastSlash;
  5915. d1748 7
  5916. a1754 8
  5917.     if ((lastSlash = strrchr (fileName, '\\')) == NULL)
  5918.        strcpy (tempName, fileName);               /* no path given.  done */
  5919.     else
  5920.     {
  5921.        strncpy (tempName, fileName, lastSlash - fileName);
  5922.        tempName[lastSlash - fileName] = '\0';
  5923.     }
  5924.     return (tempName);
  5925. d1764 1
  5926. a1764 1
  5927.     register int i;
  5928. d1766 2
  5929. a1767 2
  5930.     for (i = strlen(str)-1; i > 0 && isspace (str[i]); i--)
  5931.         str[i] = '\0';
  5932. d1778 1
  5933. a1778 1
  5934.     register char *ptr;
  5935. d1780 4
  5936. a1783 4
  5937.     for (ptr = temp; *ptr; ptr++)
  5938.         if (!isspace(*ptr))
  5939.             return (FALSE);
  5940.     return (TRUE);
  5941. d1794 1
  5942. a1794 1
  5943.     char *ptr;
  5944. d1796 4
  5945. a1799 4
  5946.     for (ptr = str; *ptr != '\0'; ptr++)
  5947.         if (!isdigit (*ptr) && (ptr != str || !strchr ("+-", *ptr)))
  5948.             return (FALSE);
  5949.     return (TRUE);
  5950. d1803 5
  5951. a1807 5
  5952.  *    Open the common font dialog
  5953.  *    Place resulting selection name and size in face,style and size
  5954.  *    Note: to select a printer font, send style as "Printer"
  5955.  *    printer font selection ignores any chosen style
  5956.  *    (JSC 1/9/94)
  5957. d1812 35
  5958. a1846 31
  5959.     LOGFONT lf;
  5960.     CHOOSEFONT cf;
  5961.     HDC hDC;
  5962.  
  5963.     memset(&lf, 0, sizeof(LOGFONT));
  5964.     strcpy (lf.lfFaceName, face);
  5965.     // convert points to logical units (1 pt = 1/72 inch)
  5966.     // For printer fonts, use ScreenYPixels here anyway - the choosefont
  5967.     // dialog appears to require the lfHeight to be in screen units
  5968.     // we will convert point size to PrinterUnits in InitPrinterFonts()
  5969.     lf.lfHeight = -MulDiv(*size, ScreenYPixels, 72);
  5970.  
  5971.     memset(&cf, 0, sizeof(CHOOSEFONT));
  5972.     cf.lStructSize = sizeof(CHOOSEFONT);
  5973.     cf.hwndOwner = hParentWnd;
  5974.     cf.lpLogFont = &lf;
  5975.     if (!stricmp (style, "Printer"))
  5976.     {
  5977.        cf.nFontType = PRINTER_FONTTYPE;
  5978.        hDC = GetPrinterDC (hParentWnd);
  5979.        cf.hDC = hDC;                                                       
  5980.        cf.Flags = CF_PRINTERFONTS|CF_INITTOLOGFONTSTRUCT|CF_FORCEFONTEXIST;
  5981.     }
  5982.     else
  5983.     {
  5984.        cf.nFontType = SCREEN_FONTTYPE;
  5985.        cf.Flags = CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT|CF_USESTYLE|CF_FORCEFONTEXIST;
  5986.        cf.lpszStyle = style;
  5987.     }
  5988.     if (!ChooseFont(&cf))
  5989.         return (FAIL);
  5990. d1848 1
  5991. a1848 2
  5992. //    if (!stricmp (style, "Printer"))      // commented out JD 6/17/94
  5993. //       ReleaseDC (hWndConf, hDC); 
  5994. d1850 2
  5995. a1851 6
  5996. //     if (!stricmp (style, "Printer"))
  5997. //       DeletePrinterDC (hDC);
  5998.        
  5999.     *size = cf.iPointSize / 10;    // iPointSize is in tenths of a point
  6000.     strcpy (face, lf.lfFaceName);
  6001.     return (SUCCESS);
  6002. d1855 2
  6003. a1856 2
  6004.  *    Open the common color dialog
  6005.  *    (JSC 1/9/94)
  6006. d1859 1
  6007. a1859 1
  6008. AskForColor (HWND hParentWnd, COLORREF *color)
  6009. d1861 24
  6010. a1884 24
  6011.     CHOOSECOLOR cc;
  6012.     COLORREF nearC;
  6013.     HDC hDC;
  6014.  
  6015.     memset(&cc, 0, sizeof(CHOOSECOLOR));
  6016.     cc.lStructSize = sizeof(CHOOSECOLOR);
  6017.     cc.hwndOwner = hParentWnd;
  6018.     cc.rgbResult = *color;
  6019.     cc.lpCustColors = CustomColors;
  6020.     cc.Flags = CC_RGBINIT;
  6021.  
  6022.     if (!ChooseColor(&cc))
  6023.         return (FAIL);
  6024.  
  6025.     // until we figure out how to deal with dithered colors, force
  6026.     // the color to the nearest physical color
  6027.     hDC = GetDC (hParentWnd);
  6028.     nearC = GetNearestColor (hDC, cc.rgbResult);
  6029.     if (cc.rgbResult != nearC)
  6030.         MessageBox (hParentWnd, "WinVn does not currently support dithered (non-solid) colors.\nThe nearest physical solid color has been selected.",
  6031.                    "Sorry", MB_OK|MB_ICONINFORMATION);
  6032.     *color = nearC;
  6033.     ReleaseDC (hParentWnd, hDC);
  6034.     return (SUCCESS);
  6035. d1888 2
  6036. a1889 2
  6037.  *    Asks for a path - uses hook callback to allow just a path (usual
  6038.  *    behavior requires the user to enter a filename)
  6039. d1891 3
  6040. a1893 3
  6041.  *    See example MSJ Jan 93, Question&Answers (Fran Finnegan)
  6042.  *    JSC 7/17/94
  6043.  *     don't forget to add  GETPATHHOOKPROC  to winvn.def and compile with /Gw
  6044. d1895 2
  6045. a1896 2
  6046.  *     Damn! Doesn't work because the the OK msg is only generated if
  6047.  *    the user has entered a complete filename.  How to do this then?!
  6048. d1899 2
  6049. a1900 1
  6050. extern UINT CALLBACK GetPathHookProc (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
  6051. d1902 21
  6052. a1922 21
  6053.     static  LPOPENFILENAME  ofn;
  6054.     static  UINT fileNameMsg;
  6055.     unsigned attrib;
  6056.     
  6057.     if (iMessage == WM_INITDIALOG)
  6058.     {
  6059.         ofn = (LPOPENFILENAME)lParam;
  6060.         fileNameMsg = (UINT)LOWORD((DWORD)ofn->lCustData);
  6061.         return TRUE;
  6062.     }
  6063.     else
  6064.     {
  6065.         if (iMessage == fileNameMsg)  // Trap the FILEOKSTRING msg
  6066.         {
  6067.             // if it exists and its a directory, then bypass default 
  6068.             // OK processing
  6069.             if (_dos_getfileattr(ofn->lpstrFile, &attrib) == 0 && (attrib&_A_SUBDIR))
  6070.                 return TRUE;
  6071.         }
  6072.     }
  6073.     return FALSE;   // Allow standard processing
  6074. d1929 18
  6075. a1946 18
  6076.     OPENFILENAME ofn;
  6077.     char szFile[MAXFILENAME];
  6078.     char filters[MAXFILTERLEN];
  6079.  
  6080.     GenerateFileFilters (hParentWnd, filters);
  6081.  
  6082. //    Open dialog to ask user for a new file name
  6083.     memset(&ofn, 0, sizeof(OPENFILENAME));
  6084.     szFile[0] = '\0';
  6085.     ofn.lpstrTitle = title;
  6086.     ofn.lStructSize = sizeof(OPENFILENAME);
  6087.     ofn.hwndOwner = hParentWnd;
  6088.     ofn.lpstrFilter = filters;
  6089.     ofn.nFilterIndex = 1;
  6090.     ofn.lpstrFile= szFile;
  6091.     ofn.nMaxFile = sizeof(szFile);
  6092.     ofn.lpstrFileTitle = NULL;
  6093.     ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST;
  6094. d1949 7
  6095. a1955 7
  6096.     UINT fileNameMsg;
  6097.     ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_ENABLEHOOK;
  6098.     ofn.lpfnHook = MakeProcInstance((FARPROC)GetPathHookProc, (HINSTANCE)hInst);
  6099.     // Register the FILEOKSTRING message
  6100.     fileNameMsg = RegisterWindowMessage((LPCSTR)FILEOKSTRING);
  6101.     // Pass the FILEOKSTRING message ID in LOWORD of lCustData field
  6102.     ofn.lCustData = MAKELPARAM (fileNameMsg, 0);
  6103. d1958 6
  6104. a1963 6
  6105.     if (GetOpenFileName(&ofn) == 0)
  6106.         return (FAIL);
  6107.     
  6108. //    FreeProcInstance(&ofn.lpfnHook);
  6109.     PathWithoutName (pathName, strlwr(szFile));
  6110.     return (SUCCESS);
  6111. d1967 1
  6112. a1967 1
  6113. //     Set up filters
  6114. d1971 10
  6115. a1980 12
  6116.     register int i;
  6117.     int len;
  6118.     char chReplace;
  6119.  
  6120.     if ((len = LoadString(hInst, IDS_FILTERSTRING, filters, MAXFILTERLEN-1)) == 0)
  6121.     {
  6122.         MessageBox (hParentWnd, "No Filters Available", "String Load Failure", MB_OK);
  6123.         *filters = '\0';
  6124.     }
  6125.     else
  6126.     {
  6127.         chReplace = filters[len - 1];        // grab separator
  6128. d1982 4
  6129. a1985 4
  6130.         for (i = 0; filters[i] != '\0'; i++)
  6131.             if (filters[i] == chReplace)
  6132.                 filters[i] = '\0';
  6133.     }
  6134. d1989 2
  6135. a1990 2
  6136.  *    Asks for a filename which must exist
  6137.  *    (JSC)
  6138. d1995 23
  6139. a2017 23
  6140.     OPENFILENAME ofn;
  6141.     char szFile[MAXFILENAME];
  6142.     char filters[MAXFILTERLEN];
  6143.  
  6144.     GenerateFileFilters (hParentWnd, filters);
  6145.  
  6146. //    Open dialog to ask user for a new file name
  6147.     memset(&ofn, 0, sizeof(OPENFILENAME));
  6148.     szFile[0] = '\0';
  6149.     ofn.lpstrTitle = title;
  6150.     ofn.lStructSize = sizeof(OPENFILENAME);
  6151.     ofn.hwndOwner = hParentWnd;
  6152.     ofn.lpstrFilter = filters;
  6153.     ofn.nFilterIndex = 1;
  6154.     ofn.lpstrFile= szFile;
  6155.     ofn.nMaxFile = sizeof(szFile);
  6156.     ofn.lpstrFileTitle = NULL;
  6157.     ofn.Flags = OFN_SHOWHELP | OFN_FILEMUSTEXIST;
  6158.  
  6159.     if (GetOpenFileName(&ofn) == 0)
  6160.         return (FAIL);
  6161.     strcpy (fileName, strlwr(szFile));
  6162.     return (SUCCESS);
  6163. d2020 5
  6164. a2024 5
  6165.  *     Make sure file name is OK for DOS 8.3
  6166.  *     Check if file name is OK for DOS.  If not, prompt user new name
  6167.  *    Check if file already exists.  If so, prompt user OK to overwrite
  6168.  *    If fileName contains a name on entry, check if it's OK, if yes-done
  6169.  *    (JSC)
  6170. d2029 41
  6171. a2069 43
  6172.     OFSTRUCT outFileStruct;
  6173.     OPENFILENAME ofn;
  6174.     HFILE     hWriteFile;
  6175.     char mybuf[MAXINTERNALLINE];
  6176.     char szDirName[256];
  6177.     char szFile[256];
  6178.     BOOL retcode;
  6179.     char filters[MAXFILTERLEN];
  6180.  
  6181.     GenerateFileFilters (hParentWnd, filters);
  6182.     while (fileName[0] == '\0' ||
  6183.           (retcode = VerifyFileName (fileName)) == FAIL ||
  6184.           (hWriteFile = OpenFile ((char far *)fileName, &outFileStruct, OF_EXIST)) >= 0)
  6185.     {
  6186.             if (fileName[0] != '\0' && retcode == SUCCESS)
  6187.         {
  6188. //    File name ok, but file exists.  Ask user if ok to wipe it
  6189.             sprintf (mybuf, "File %s exists.  OK to overwrite it?", fileName);
  6190.              retcode = MessageBox(hParentWnd, mybuf, "File exists",
  6191.                    MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION);
  6192.             if (retcode == IDYES)
  6193.                 break;
  6194.         }
  6195.  
  6196. //    Open dialog to ask user for a new file name
  6197.         memset(&ofn, 0, sizeof(OPENFILENAME));
  6198.         if (fileName[0] != '\0')
  6199.             sprintf (mybuf, "Invalid file name %s. Select new name", fileName);
  6200.         else
  6201.             strcpy (mybuf, "Select new file name to create/overwrite");
  6202.  
  6203.         ofn.lpstrTitle = mybuf;
  6204.         strcpy (szDirName, startDir);
  6205.         ofn.lpstrInitialDir = szDirName;
  6206.         ofn.lStructSize = sizeof(OPENFILENAME);
  6207.         ofn.hwndOwner = hParentWnd;
  6208.         ofn.lpstrFilter = filters;
  6209.         ofn.nFilterIndex = 1;
  6210.         szFile[0] = '\0';
  6211.         ofn.lpstrFile= szFile;
  6212.         ofn.nMaxFile = sizeof(szFile);
  6213.         ofn.lpstrFileTitle = NULL;
  6214.         ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST;
  6215. d2071 2
  6216. a2072 2
  6217.         if (GetOpenFileName(&ofn) == 0)
  6218.             return (FAIL);
  6219. d2074 3
  6220. a2076 3
  6221.         strcpy (fileName, strlwr (ofn.lpstrFile));
  6222.     }
  6223.     return (SUCCESS);
  6224. d2079 2
  6225. a2080 2
  6226.  *     Make sure file name is OK for DOS 8.3
  6227.  *    (JSC)
  6228. d2085 1
  6229. a2085 1
  6230.     char *beg, *ptr;
  6231. d2087 4
  6232. a2090 4
  6233.     if ((beg = strrchr (fileName, '\\'))==NULL)
  6234.         beg = fileName;
  6235.     else
  6236.         beg++;            /* skip to after path slash */
  6237. d2092 3
  6238. a2094 3
  6239.     if ((ptr = strchr (beg, '.')) == NULL)
  6240.         if (strlen (beg) <= 8)    /* no extension */
  6241.             return (SUCCESS);
  6242. d2096 2
  6243. a2097 2
  6244.     if (ptr - beg > 8)
  6245.         return (FAIL);
  6246. d2099 3
  6247. a2101 3
  6248.     beg = ptr + 1;            /* multiple extensions */
  6249.     if ((ptr = strchr (beg, '.')) != NULL)
  6250.         return (FAIL);
  6251. d2103 2
  6252. a2104 2
  6253.     if (strlen (beg) > 3)        /* extension too long */
  6254.         return (FAIL);
  6255. d2106 1
  6256. a2106 1
  6257.     return (SUCCESS);
  6258. d2119 2
  6259. a2120 2
  6260.     unsigned int size;
  6261.     char *newText;
  6262. d2122 1
  6263. a2122 1
  6264.     SendMessage (hWndEdit, EM_FMTLINES, TRUE, 0);
  6265. d2124 1
  6266. a2124 1
  6267.     size = (unsigned int) SendMessage (hWndEdit, WM_GETTEXTLENGTH, 0, 0L) + 1;
  6268. d2126 8
  6269. a2133 10
  6270.     if ((newText = (char *) GlobalAllocPtr (GMEM_MOVEABLE, size*sizeof(char))) == NULL)
  6271.     {
  6272.         MessageBox (hWndEdit, "Memory allocation failure", "Edit Text", MB_OK);
  6273.         return (NULL);
  6274.     }
  6275.     if (SendMessage (hWndEdit, WM_GETTEXT, size, (LPARAM)((LPCSTR)newText)) != (long)(size-1))
  6276.     {
  6277.         MessageBox (hWndEdit, "Failed to get text", "Edit Text", MB_OK);
  6278.         return (NULL);
  6279.     }
  6280. d2135 1
  6281. a2135 1
  6282.     return (newText);
  6283. d2140 1
  6284. a2140 1
  6285.     return (SendMessage (hWndEdit, WM_SETTEXT, 0, (LPARAM)(LPCSTR)editMem));
  6286. d2151 1
  6287. a2151 1
  6288. CreateEditWnd (WndEdit *NewWnd)
  6289. d2154 18
  6290. a2171 18
  6291.       GLOBALHANDLE editDS;
  6292.       LPVOID lpPtr;
  6293.       if ((editDS = GlobalAlloc (GMEM_DDESHARE|GMEM_MOVEABLE|GMEM_ZEROINIT, 1024L)) == NULL)
  6294.       {
  6295.     MessageBox (NewWnd->hWnd, "Memory allocation failure", "Edit Buffer", MB_OK);
  6296.     editDS = hInst;        // use local heap instead
  6297.       }
  6298.       else
  6299.       {
  6300.      lpPtr = GlobalLock (editDS);
  6301.     LocalInit (HIWORD((LONG)lpPtr), 0, (WORD)(GlobalSize (editDS) - 16));
  6302.     UnlockSegment (HIWORD((LONG)lpPtr));    // we still have a global lock
  6303.       }
  6304.       NewWnd->hWndEdit = CreateWindow ("edit", (char *) NULL,
  6305.         WS_CHILD | WS_VISIBLE | /* WS_HSCROLL | */ WS_VSCROLL | WS_BORDER |
  6306.         ES_LEFT | ES_MULTILINE | /* ES_AUTOHSCROLL  | */  ES_AUTOVSCROLL,
  6307.         0, 0, 0, 0,
  6308.         NewWnd->hWnd, EDITID, HIWORD((LONG)lpPtr), NULL);
  6309. d2173 5
  6310. a2177 5
  6311.       NewWnd->hWndEdit = CreateWindow ("edit", (char *) NULL,
  6312.         WS_CHILD | WS_VISIBLE | /* WS_HSCROLL | */ WS_VSCROLL | WS_BORDER |
  6313.         ES_LEFT | ES_MULTILINE |  /* ES_AUTOHSCROLL  | */ ES_AUTOVSCROLL,
  6314.         0, 0, 0, 0,
  6315.         NewWnd->hWnd, EDITID, hInst, NULL);        // No problems with Win32
  6316. d2179 4
  6317. a2182 5
  6318.       if (!NewWnd->hWndEdit)
  6319.       {
  6320.     MessageBox (NewWnd->hWnd, "Window creation failure", "Edit Buffer", MB_OK);
  6321.     return (FAIL);
  6322.       }
  6323. d2184 3
  6324. a2186 3
  6325.       SendMessage (NewWnd->hWndEdit, EM_LIMITTEXT, 0, 0L);
  6326.       SetHandleBkBrush (NewWnd->hWndEdit,   hArticleBackgroundBrush);
  6327.       NewWnd->dirty = DT_CLEAN;
  6328. d2188 1
  6329. a2188 1
  6330.       return (SUCCESS);
  6331. d2191 1
  6332. a2191 1
  6333.  *     Write an integer to the private profile
  6334. d2194 1
  6335. a2194 1
  6336. WritePrivateProfileInt (lpAppName, lpKeyName, intval,lpProFile)
  6337. d2207 2
  6338. a2208 2
  6339.  *    Write an unsigned integer to the private profile
  6340.  *    (JSC 1/8/94)
  6341. d2211 1
  6342. a2211 1
  6343. WritePrivateProfileUInt (lpAppName, lpKeyName, intval,lpProFile)
  6344. d2224 2
  6345. a2225 2
  6346.  *    Get an unsigned integer to the private profile
  6347.  *    (JSC 1/8/94)
  6348. d2228 1
  6349. a2228 1
  6350. GetPrivateProfileUInt (lpAppName, lpKeyName, intval,lpProFile)
  6351. d2239 1
  6352. a2239 1
  6353.      return (intval);
  6354. d2241 1
  6355. a2241 1
  6356.      return (atoui(buf));
  6357. d2244 4
  6358. a2247 4
  6359.  *    Refresh Window functions
  6360.  *    Called after a font/color selection has changed to affect all
  6361.  *    windows of a certain type (group/article/status)
  6362.  *    (JSC 1/9/94)
  6363. d2250 1
  6364. a2250 1
  6365. RefreshGroupWnds()
  6366. d2252 7
  6367. a2258 8
  6368.     register int i;
  6369.     for (i = 0; i < MAXGROUPWNDS; i++)
  6370.         if (GroupDocs[i].hDocWnd)
  6371.         {
  6372.             SetHandleBkBrush ( GroupDocs[i].hDocWnd, hListBackgroundBrush);
  6373.             SendMessage (GroupDocs[i].hDocWnd, WM_SIZE, 0, 0L);
  6374.             InvalidateRect (GroupDocs[i].hDocWnd, NULL, TRUE);
  6375.         }
  6376. d2262 1
  6377. a2262 1
  6378. RefreshArticleWnds()
  6379. d2264 8
  6380. a2271 1
  6381.     register int i;
  6382. d2273 13
  6383. a2285 23
  6384.     for (i = 0; i < MAXARTICLEWNDS; i++)
  6385.        if (ArticleDocs[i].hDocWnd)
  6386.        {
  6387.         SetHandleBkBrush(ArticleDocs[i].hDocWnd, hArticleBackgroundBrush);
  6388.         SendMessage (ArticleDocs[i].hDocWnd, WM_SIZE, 0, 0L);
  6389.         InvalidateRect (ArticleDocs[i].hDocWnd, NULL, TRUE);
  6390.        }
  6391.  
  6392.     for (i = 0; i < MAXPOSTWNDS; i++)
  6393.        if (WndPosts[i].hWnd)
  6394.         {
  6395.             SendMessage (WndPosts[i].hWndEdit, WM_SETFONT, hFontArtNormal, TRUE);
  6396.             SetHandleBkBrush (WndPosts[i].hWndEdit, hArticleBackgroundBrush);
  6397.             InvalidateRect (WndPosts[i].hWndEdit, NULL, TRUE);
  6398.         }
  6399.  
  6400.     for (i = 0; i < MAXMAILWNDS; i++)
  6401.        if (WndMails[i].hWnd)
  6402.         {
  6403.             SendMessage (WndMails[i].hWndEdit, WM_SETFONT, hFontArtNormal, TRUE);
  6404.             SetHandleBkBrush (WndMails[i].hWndEdit, hArticleBackgroundBrush);
  6405.             InvalidateRect (WndMails[i].hWndEdit, NULL, TRUE);
  6406.         }
  6407. d2289 1
  6408. a2289 1
  6409. RefreshStatusWnds()
  6410. d2291 1
  6411. a2291 1
  6412.     register int i;
  6413. d2293 11
  6414. a2303 13
  6415.     for (i = 0; i < numStatusTexts; i++)
  6416.         if (codingStatusText[i]->hTextWnd)
  6417.         {
  6418.             SetHandleBkBrush (codingStatusText[i]->hTextWnd, hStatusBackgroundBrush);
  6419.             SendMessage (codingStatusText[i]->hTextWnd, WM_SIZE, 0, 0L);
  6420.             InvalidateRect (codingStatusText[i]->hTextWnd, NULL, TRUE);
  6421.         }
  6422.     if (hCodedBlockWnd)
  6423.     {
  6424.         SetHandleBkBrush (hCodedBlockWnd, hStatusBackgroundBrush);
  6425.         SendMessage (hCodedBlockWnd, WM_SIZE, 0, 0L);
  6426.         InvalidateRect (hCodedBlockWnd, NULL, TRUE);
  6427.     }
  6428. d2307 4
  6429. a2310 4
  6430.  *    Close Window functions
  6431.  *    Batch operation, close all windows of a certain type
  6432.  *    (group/article/status)
  6433.  *    (JSC 1/18/94)
  6434. d2313 1
  6435. a2313 1
  6436. CloseGroupWnds()
  6437. d2315 4
  6438. a2318 4
  6439.     register int i;
  6440.     for (i = 0; i < MAXGROUPWNDS; i++)
  6441.        if (GroupDocs[i].hDocWnd)
  6442.         SendMessage(GroupDocs[i].hDocWnd, WM_CLOSE, 0, 0L);
  6443. d2322 1
  6444. a2322 1
  6445. CloseArticleWnds()
  6446. d2324 1
  6447. a2324 1
  6448.     register int i;
  6449. d2326 3
  6450. a2328 3
  6451.     for (i = 0; i < MAXARTICLEWNDS; i++)
  6452.        if (ArticleDocs[i].hDocWnd)
  6453.         SendMessage(ArticleDocs[i].hDocWnd, WM_CLOSE, 0, 0L);
  6454. d2331 1
  6455. a2331 1
  6456. CloseStatusWnds()
  6457. d2333 5
  6458. a2337 6
  6459.     // destroying a coding status text is like popping from a stack
  6460.     // so we just loop while the top of the stack still exists
  6461.     while (numStatusTexts > 0 && codingStatusText[0]->hTextWnd)
  6462.         if (CodingState)
  6463.         {
  6464.         MessageBox (codingStatusText[0]->hTextWnd,
  6465. d2339 5
  6466. a2343 5
  6467.           "Cannot close status window", MB_OK|MB_ICONSTOP);
  6468.         break;
  6469.         }
  6470.         else
  6471.         SendMessage(codingStatusText[0]->hTextWnd, WM_CLOSE, 0, 0L);
  6472. d2348 7
  6473. a2354 7
  6474.  *    BatchSend
  6475.  *    type is DOCTYPE_MAIL or _POST
  6476.  *    Increments nextBatchIndex and initiates mail/post
  6477.  *    Note: on entry nextBatchIndex is the index we will use for this send
  6478.  *    on exit, nextBatchIndex is either 0 (no more to send) or the index
  6479.  *    of the next mail/post to send
  6480.  *    (JSC 1/18/94)
  6481. d2359 15
  6482. a2373 14
  6483.     int thisSend;
  6484.     int maxWnds;
  6485.     WndEdit *WndEdits;
  6486.  
  6487.     if (type == DOCTYPE_POSTING)
  6488.     {
  6489.        WndEdits = WndPosts;
  6490.        maxWnds = MAXPOSTWNDS;
  6491.     }
  6492.     else
  6493.     {
  6494.        WndEdits = WndMails;
  6495.        maxWnds = MAXMAILWNDS;
  6496.     }
  6497. d2375 6
  6498. a2380 8
  6499.     thisSend = nextBatchIndex;
  6500.     if (thisSend == 0)    // find first in batch (if any)
  6501.     {
  6502.         while (thisSend < maxWnds)
  6503.            if (WndEdits[thisSend].hWnd)
  6504.             break;
  6505.            else
  6506.                thisSend++;
  6507. d2382 2
  6508. a2383 2
  6509.         if (thisSend == maxWnds)
  6510.            return;    // no open windows.  cancel
  6511. d2385 2
  6512. a2386 2
  6513.         nextBatchIndex = thisSend;
  6514.     }
  6515. d2388 4
  6516. a2391 4
  6517.     // find next in batch (if any)
  6518.         while (++nextBatchIndex < maxWnds)
  6519.          if (WndEdits[nextBatchIndex].hWnd)
  6520.            break;
  6521. d2393 2
  6522. a2394 2
  6523.     if (nextBatchIndex == maxWnds)
  6524.        nextBatchIndex = 0;         // no more
  6525. d2396 4
  6526. a2399 4
  6527.     if (type == DOCTYPE_POSTING)
  6528.        StartPost (&WndEdits[thisSend]);
  6529.     else
  6530.        StartMail (&WndEdits[thisSend]);
  6531. d2402 4
  6532. a2405 4
  6533.  *    Test busy functions
  6534.  *    Called to test if a comm or decoding is busy
  6535.  *    Returns true if busy, false if not busy
  6536.  *    (JSC 1/9/94)
  6537. d2410 2
  6538. a2411 3
  6539.     if (CommBusy)
  6540.      {
  6541.         MessageBox (hParentWnd,
  6542. d2415 4
  6543. a2418 4
  6544.        return (TRUE);
  6545.     }
  6546.     else
  6547.        return (FALSE);
  6548. d2424 3
  6549. a2426 4
  6550.     if (Decoding || CommDecoding)
  6551.      {
  6552.         MessageBox (hParentWnd,
  6553.         "Sorry, I can only handle one en/decoding session at a time.\n"
  6554. d2429 4
  6555. a2432 4
  6556.        return (TRUE);
  6557.     }
  6558.     else
  6559.        return (FALSE);
  6560. @
  6561.  
  6562.  
  6563.  
  6564. 1.55
  6565. log
  6566. @Fix a problem with printer device context getting freed prematurely
  6567. @
  6568. text
  6569. @d2 1
  6570. a2 1
  6571.  * $Id: wvutil.c 1.54 1994/06/23 23:09:05 dumoulin Exp dumoulin $
  6572. d17 1
  6573. d23 1
  6574. d30 2
  6575. d554 12
  6576. a565 2
  6577.    DialogBox (hInst, "THRESHOLD",
  6578.          CommDoc->hDocWnd, lpfnWinVnThresholdDlg);
  6579. d1728 3
  6580. a1730 1
  6581.         return ("\0");
  6582. a1731 2
  6583.     strcpy (tempName, &fileName[theDot - fileName + 1]);
  6584.  
  6585. d1747 21
  6586. d1769 2
  6587. a1770 2
  6588.         strcpy (tempName, fileName);        /* no path given.  done */
  6589.         return (tempName);
  6590. a1771 2
  6591.     strcpy (tempName, &fileName[lastSlash - fileName + 1]);
  6592.  
  6593. d1905 1
  6594. d1907 9
  6595. a1915 2
  6596.  *    Asks for a filename which must exist
  6597.  *    (JSC)
  6598. d1917 27
  6599. d1945 1
  6600. a1945 1
  6601. AskForExistingFileName (HWND hParentWnd, char *fileName, char *title)
  6602. d1949 40
  6603. a1990 1
  6604.     char filters[512];
  6605. d1993 2
  6606. a1994 2
  6607. //     Set up filters
  6608.     if ((len = LoadString(hInst, IDS_FILTERSTRING, filters, sizeof (filters))) == 0)
  6609. d1996 2
  6610. d2000 1
  6611. a2000 1
  6612.         chReplace = filters[len - 1];        // retrieve separator
  6613. d2006 14
  6614. d2056 1
  6615. a2056 4
  6616.     register int i;
  6617.     int len;
  6618.     char filters[512];
  6619.     char chReplace;
  6620. d2058 1
  6621. a2070 12
  6622.         }
  6623.  
  6624. //     Set up filters
  6625.         if ((len = LoadString(hInst, IDS_FILTERSTRING, filters, sizeof (filters))) == 0)
  6626.             MessageBox (hParentWnd, "No Filters Available", "String Load Failure", MB_OK);
  6627.         else
  6628.         {
  6629.             chReplace = filters[len - 1];    // retrieve separator
  6630.  
  6631.             for (i = 0; filters[i] != '\0'; i++)
  6632.                 if (filters[i] == chReplace)
  6633.                     filters[i] = '\0';
  6634. @
  6635.  
  6636.  
  6637.  
  6638. 1.54
  6639. log
  6640. @fixed error codes and changed call to GetPrinterDC to pass window handle
  6641. @
  6642. text
  6643. @d2 1
  6644. a2 1
  6645.  * $Id: wvutil.c 1.53 1994/06/17 09:09:30 dumoulin Exp dumoulin $
  6646. d1830 1
  6647. a1830 1
  6648. //       ReleaseDC (hWndConf, hDC);
  6649. d1832 3
  6650. @
  6651.  
  6652.  
  6653.  
  6654. 1.53
  6655. log
  6656. @Attempts to fix the Unable to Initialize Document printing bug
  6657. @
  6658. text
  6659. @d2 1
  6660. a2 1
  6661.  * $Id: wvutil.c 1.52 1994/06/09 21:47:08 rushing Exp dumoulin $
  6662. d693 2
  6663. a694 1
  6664.                               ARTICLE_SUBJECT_OFFSET + lstrlen(header->subject) );
  6665. d1139 2
  6666. a1140 1
  6667.                                 ARTICLE_SUBJECT_OFFSET+lstrlen(header->subject));
  6668. d1816 1
  6669. a1816 1
  6670.        hDC = GetPrinterDC (NULL);
  6671. @
  6672.  
  6673.  
  6674.  
  6675. 1.52
  6676. log
  6677. @handle unexpected disconnect, and smtp mail while disconnected from nntp
  6678. @
  6679. text
  6680. @d2 1
  6681. a2 1
  6682.  * $Id: wvutil.c 1.51 1994/06/09 18:39:34 rushing Exp $
  6683. d1814 2
  6684. a1815 2
  6685.        hDC = GetPrinterDC ();
  6686.        cf.hDC = hDC;
  6687. d1827 2
  6688. a1828 2
  6689.     if (!stricmp (style, "Printer"))
  6690.        ReleaseDC (hWndConf, hDC);
  6691. @
  6692.  
  6693.  
  6694.  
  6695. 1.51
  6696. log
  6697. @word-wrap, dot-doubling, and default port numbers
  6698. @
  6699. text
  6700. @d2 1
  6701. a2 1
  6702.  * $Id: wvutil.c 1.50 1994/06/08 21:01:45 gardnerd Exp rushing $
  6703. d69 1
  6704. a69 1
  6705. #if 0  
  6706. d74 1
  6707. a74 1
  6708.   
  6709. d83 1
  6710. a83 1
  6711.     } 
  6712. d123 1
  6713. a123 1
  6714.                   GetGValue (rgbVal), 
  6715. d125 1
  6716. a125 1
  6717.     return (buf); 
  6718. d147 1
  6719. a147 1
  6720.   
  6721. d154 2
  6722. a155 2
  6723.   if ((sc < 0) || (sc > 59)) return(0);  
  6724.   
  6725. d168 1
  6726. a168 1
  6727.     datetime.tm_min = mn; 
  6728. d188 1
  6729. a188 1
  6730.        { 
  6731. d228 1
  6732. a228 1
  6733.   
  6734. d232 1
  6735. a232 1
  6736.       
  6737. d284 1
  6738. a284 1
  6739. d334 1
  6740. a334 1
  6741.   
  6742. d339 1
  6743. a339 1
  6744.   
  6745. d423 3
  6746. a425 2
  6747. //        PostQuitMessage (0);
  6748.         Initializing = INIT_NOT_CONNECTED;
  6749. d471 1
  6750. a471 1
  6751.       
  6752. d489 1
  6753. a489 1
  6754.  
  6755. d572 1
  6756. a572 1
  6757.                      }     
  6758. d595 1
  6759. a595 1
  6760.  
  6761. d600 1
  6762. a600 1
  6763.      
  6764. d603 1
  6765. a603 1
  6766.      
  6767. d638 1
  6768. a638 1
  6769.       /* the 'threadp' variable */ 
  6770. d665 1
  6771. a665 1
  6772.    
  6773. d685 1
  6774. a685 1
  6775.    
  6776. d690 1
  6777. a690 1
  6778.    
  6779. d692 1
  6780. a692 1
  6781.    CommDoc->LongestLine = max(CommDoc->LongestLine, 
  6782. d726 1
  6783. a726 1
  6784.    
  6785. d734 1
  6786. a734 1
  6787.    
  6788. d763 1
  6789. a763 1
  6790.              
  6791. d765 1
  6792. a765 1
  6793.       /* the 'threadp' variable */ 
  6794. d801 1
  6795. a801 1
  6796.    
  6797. d860 2
  6798. a861 2
  6799.    mylen = sprintf(mybuf,"XHDR lines %ld-%ld",first,last); 
  6800.    CommState = ST_XHDR_LINES_START; 
  6801. d865 1
  6802. a865 1
  6803.    
  6804. d876 1
  6805. a876 1
  6806.    headers = lock_headers (header_handle, thread_handle); 
  6807. d917 2
  6808. a918 2
  6809.      CommState = ST_XHDR_REF_START;          
  6810.      mylen = sprintf(mybuf,"XHDR references %ld-%ld",first,last); 
  6811. d922 2
  6812. a923 2
  6813.      CommState = ST_XHDR_SUBJECT_START; 
  6814.      mylen = sprintf(mybuf,"XHDR subject %ld-%ld",first,last); 
  6815. d985 1
  6816. a985 1
  6817. //      int bracket_len; 
  6818. d1041 1
  6819. a1041 1
  6820.    
  6821. d1045 1
  6822. a1045 1
  6823.    
  6824. d1115 1
  6825. a1115 1
  6826.      thread_handle = GroupDoc->thread_handle;        
  6827. d1120 1
  6828. a1120 1
  6829.      if (syncnum >= 0) 
  6830. d1157 2
  6831. a1158 2
  6832.       if (check_server_code(retcode)) 
  6833.       { 
  6834. d1168 1
  6835. a1168 1
  6836.       if(strcmp(CommLineIn,".") == 0) {    
  6837. d1181 1
  6838. a1181 1
  6839.       } 
  6840. d1183 1
  6841. a1183 1
  6842.          ProcessMIME (CommLineIn) 
  6843. d1186 2
  6844. a1187 2
  6845.       break;      
  6846.     
  6847. d1244 1
  6848. a1244 1
  6849.     if(found && CommDoc->TotalLines > CommDoc->ScYLines && 
  6850. d1247 1
  6851. a1247 1
  6852.     
  6853. d1268 1
  6854. a1268 1
  6855.             ProcessAttach (0);           
  6856. d1313 1
  6857. a1313 1
  6858.     {  
  6859. d1331 1
  6860. a1331 1
  6861.         
  6862. d1435 1
  6863. a1435 1
  6864.     
  6865. d1445 1
  6866. a1445 1
  6867.        return;                           
  6868. d1475 1
  6869. a1475 1
  6870.     CommDoc->LongestLine = max(CommDoc->LongestLine,(unsigned)mylen); 
  6871. d1479 1
  6872. a1479 1
  6873.     
  6874. d1481 1
  6875. a1481 1
  6876.       InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);  
  6877. d1615 1
  6878. a1615 1
  6879.    * if the user desires. 
  6880. d1626 1
  6881. a1626 1
  6882.   thread_handle = GroupDoc->thread_handle;        
  6883. d1635 1
  6884. a1635 1
  6885.    
  6886. d1658 1
  6887. a1658 1
  6888.     thread_handle = GroupDoc->thread_handle;      
  6889. d1660 1
  6890. a1660 1
  6891.      
  6892. d1682 1
  6893. a1682 1
  6894. d1717 1
  6895. a1717 1
  6896. }               
  6897. d1752 1
  6898. a1752 1
  6899.         
  6900. d1762 1
  6901. a1762 1
  6902.     
  6903. d1778 1
  6904. a1778 1
  6905.     
  6906. d1798 1
  6907. a1798 1
  6908.             
  6909. d1806 1
  6910. a1806 1
  6911.     
  6912. d1812 1
  6913. a1812 1
  6914.     {       
  6915. d1823 1
  6916. a1823 1
  6917.     }    
  6918. d1852 1
  6919. a1852 1
  6920.     
  6921. d1858 1
  6922. a1858 1
  6923.     hDC = GetDC (hParentWnd);    
  6924. d1863 1
  6925. a1863 1
  6926.     *color = nearC;               
  6927. d1871 1
  6928. a1871 1
  6929. BOOL 
  6930. d1882 1
  6931. a1882 1
  6932.     if ((len = LoadString(hInst, IDS_FILTERSTRING, filters, sizeof (filters))) == 0) 
  6933. d1885 1
  6934. a1885 1
  6935.     {        
  6936. d1887 1
  6937. a1887 1
  6938.     
  6939. d1895 1
  6940. a1895 1
  6941.     szFile[0] = '\0';      
  6942. d1918 1
  6943. a1918 1
  6944. BOOL 
  6945. d1933 1
  6946. a1933 1
  6947.     while (fileName[0] == '\0' || 
  6948. d1938 1
  6949. a1938 1
  6950.         { 
  6951. d1940 1
  6952. a1940 1
  6953.             sprintf (mybuf, "File %s exists.  OK to overwrite it?", fileName);    
  6954. d1948 1
  6955. a1948 1
  6956.         if ((len = LoadString(hInst, IDS_FILTERSTRING, filters, sizeof (filters))) == 0) 
  6957. d1951 1
  6958. a1951 1
  6959.         {        
  6960. d1953 1
  6961. a1953 1
  6962.         
  6963. d1965 1
  6964. a1965 1
  6965.     
  6966. d1981 1
  6967. a1981 1
  6968.         
  6969. d1983 1
  6970. a1983 1
  6971.     }    
  6972. d1994 1
  6973. a1994 1
  6974.     
  6975. d1999 1
  6976. a1999 1
  6977.             
  6978. d2002 2
  6979. a2003 2
  6980.             return (SUCCESS);    
  6981.     
  6982. d2006 1
  6983. a2006 1
  6984.         
  6985. d2013 1
  6986. a2013 1
  6987.     
  6988. d2015 1
  6989. a2015 1
  6990. }    
  6991. d2029 1
  6992. a2029 1
  6993.     
  6994. d2031 1
  6995. a2031 1
  6996.     
  6997. d2033 1
  6998. a2033 1
  6999.         
  7000. d2044 1
  7001. a2044 1
  7002.     
  7003. d2046 1
  7004. a2046 1
  7005. }    
  7006. d2084 2
  7007. a2085 2
  7008.         WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER |
  7009.         ES_LEFT | ES_MULTILINE |  ES_AUTOHSCROLL  |  ES_AUTOVSCROLL,
  7010. d2093 2
  7011. a2094 2
  7012.       }    
  7013.     
  7014. d2148 1
  7015. a2148 1
  7016.   
  7017. d2167 1
  7018. a2167 1
  7019.             SetHandleBkBrush ( GroupDocs[i].hDocWnd, hListBackgroundBrush); 
  7020. d2216 1
  7021. a2216 1
  7022.     {        
  7023. d2225 1
  7024. a2225 1
  7025.  *    Batch operation, close all windows of a certain type 
  7026. d2261 1
  7027. a2261 1
  7028.         SendMessage(codingStatusText[0]->hTextWnd, WM_CLOSE, 0, 0L);        
  7029. d2291 1
  7030. a2291 1
  7031.     
  7032. d2298 1
  7033. a2298 1
  7034.            else 
  7035. d2303 1
  7036. a2303 1
  7037.            
  7038. d2314 1
  7039. a2314 1
  7040.        
  7041. @
  7042.  
  7043.  
  7044.  
  7045. 1.50
  7046. log
  7047. @more scrolling changes...
  7048. @
  7049. text
  7050. @d2 1
  7051. a2 1
  7052.  * $Id: wvutil.c 1.49 1994/06/06 22:06:13 gardnerd Exp $
  7053. d2029 2
  7054. d2077 2
  7055. a2078 2
  7056.         WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER |
  7057.         ES_LEFT | ES_MULTILINE |  ES_AUTOHSCROLL  |  ES_AUTOVSCROLL,
  7058. @
  7059.  
  7060.  
  7061.  
  7062. 1.49
  7063. log
  7064. @horizontal scrolling support
  7065. @
  7066. text
  7067. @d2 1
  7068. a2 1
  7069.  * $Id: wvutil.c 1.48 1994/06/02 00:17:07 rushing Exp $
  7070. d692 1
  7071. a692 1
  7072.                               HEADER_SUBJECT_OFFSET + strlen(header->subject) );
  7073. d1136 2
  7074. d1474 1
  7075. @
  7076.  
  7077.  
  7078.  
  7079. 1.48
  7080. log
  7081. @put id key back in, remove log messages
  7082. @
  7083. text
  7084. @d2 1
  7085. a2 1
  7086.  * $Id: $
  7087. d691 2
  7088. a692 1
  7089.  
  7090. @
  7091.  
  7092.  
  7093.  
  7094. 1.47
  7095. log
  7096. @unnecessary winundoc.h
  7097. @
  7098. text
  7099. @d2 1
  7100. a2 143
  7101.  *
  7102.  * Revision 1.44  1994/05/19  02:02:10  rushing
  7103.  * changes for gensock & version 0.91
  7104.  *
  7105.  * Revision 1.43  1994/05/02  20:33:46  rushing
  7106.  * changes from jody glasser
  7107.  *
  7108.  * Revision 1.42  1994/03/22  22:44:24  rushing
  7109.  * handle failure of XOVER command (punt to XHDR).
  7110.  *
  7111.  * Revision 1.41  1994/02/24  21:35:41  jcoop
  7112.  * jcoop changes.
  7113.  *
  7114.  * Revision 1.40  1994/02/16  21:05:33  cnolan
  7115.  * cnolan changes to 90.3
  7116.  *
  7117.  * Revision 1.39  1994/02/16  20:59:17  rushing
  7118.  * Added .ini param to force use of XHDR over XOVER
  7119.  *
  7120.  * Revision 1.38  1994/02/09  18:01:08  cnolan
  7121.  * cnolan 90.2 changes
  7122.  *
  7123.  * Revision 1.37  1994/01/24  17:40:28  jcoop
  7124.  * 90.2 changes
  7125.  *
  7126.  * Revision 1.36  1994/01/17  21:54:16  jcoop
  7127.  * Decoder integration, lots of new utilities (fonts/colors, etc)
  7128.  *
  7129.  * Revision 1.35  1994/01/12  19:46:06  cedwards
  7130.  * fullnamefrom not working with XHDR
  7131.  * 
  7132.  * Revision 1.34  1994/01/12  19:27:55  mrr
  7133.  * mrr mods 4
  7134.  *
  7135.  * Revision 1.33  1994/01/05  22:36:05  rushing
  7136.  * off by one bug in PutCommLine ("XOVER\r", 5) fixed
  7137.  * l.
  7138.  *
  7139.  * Revision 1.32  1993/12/08  01:28:01  rushing
  7140.  * new version box and cr lf consistency
  7141.  *
  7142.  * Revision 1.31  1993/12/01  23:24:06  rushing
  7143.  * off by one on date problem shows up dec. 1.
  7144.  *
  7145.  * Revision 1.30  1993/11/24  23:07:20  rushing
  7146.  * let the user know about access trouble
  7147.  *
  7148.  * Revision 1.29  1993/11/22  20:30:50  rushing
  7149.  * handle mixed-case dates
  7150.  *
  7151.  * Revision 1.28  1993/08/25  18:53:17  mbretherton
  7152.  * MRB merge, mail & post logging
  7153.  *
  7154.  * Revision 1.27  1993/08/25  17:05:17  mbretherton
  7155.  * merge from first newsrc.zip
  7156.  *
  7157.  * Revision 1.26  1993/08/18  21:49:21  rushing
  7158.  * more 16-bit article number fixes.
  7159.  *
  7160.  * Revision 1.25  1993/08/05  20:06:07  jcoop
  7161.  * save multiple articles changes by jcoop@@oakb2s01.apl.com (John S Cooper)
  7162.  *
  7163.  * Revision 1.24  1993/07/13  16:03:04  riordan
  7164.  * MRR mods
  7165.  *
  7166.  * Revision 1.23  1993/06/28  17:52:17  rushing
  7167.  * fixed compiler warnings
  7168.  *
  7169.  * Revision 1.22  1993/06/25  20:18:51  dumoulin
  7170.  * Changed Date fields from Strings to Posix standard time format
  7171.  *
  7172.  * Revision 1.21  1993/06/22  16:43:03  bretherton
  7173.  * auto close on posting window
  7174.  *
  7175.  *
  7176.  * Revision 1.20  1993/06/22  14:04:05  dumoulin
  7177.  * Fixed problems with article numbers larger than 32K
  7178.  *
  7179.  * Revision 1.19  1993/06/19  18:40:17  dumoulin
  7180.  * Added error routines to handle unsyncd XHDRS from screwed up servers
  7181.  *
  7182.  * Revision 1.18  1993/06/15  21:16:59  rushing
  7183.  * headers-> to header-> in two lines.
  7184.  *
  7185.  * Revision 1.17  1993/06/11  00:10:35  rushing
  7186.  * second merge from Matt Bretherton sources
  7187.  *
  7188.  * Revision 1.16  1993/06/10  18:25:17  rushing
  7189.  * XOVER support.
  7190.  *
  7191.  * Revision 1.15  1993/06/08  19:42:38  rushing
  7192.  * always do the thread_index array so we can sort on other fields.
  7193.  *
  7194.  * Revision 1.14  1993/06/05  03:18:25  rushing
  7195.  * primitive functional threading.
  7196.  *
  7197.  * Revision 1.13  1993/06/01  18:22:40  rushing
  7198.  * moved header funcs to headarry.c
  7199.  *
  7200.  * Revision 1.12  1993/05/26  23:59:40  rushing
  7201.  * reimplemented positioning group window near last read article
  7202.  *
  7203.  * Revision 1.11  1993/05/24  23:56:51  rushing
  7204.  * date formatting for group list window
  7205.  * and save header size for article repaing (MRB)
  7206.  *
  7207.  * Revision 1.10  1993/05/13  19:58:09  SOMEONE
  7208.  * fancy 'from' in group window
  7209.  *
  7210.  * Revision 1.9  1993/05/13  16:16:06  rushing
  7211.  * article fetch limit support
  7212.  *
  7213.  * Revision 1.8  1993/05/08  17:11:05  rushing
  7214.  * correct handling of 4XX response codes, and
  7215.  * of NNTP data lines beginning with '.'
  7216.  *
  7217.  * Revision 1.7  1993/04/29  21:42:11  rushing
  7218.  * checked for null from parse_usenet_date on bad date.
  7219.  *
  7220.  * Revision 1.6  1993/04/29  20:24:59  rushing
  7221.  * attempted support for WSAAsyncSelect
  7222.  *
  7223.  * Revision 1.5  1993/04/27  21:03:20  rushing
  7224.  * clicking on a group that doesn't exist is correctly handled.
  7225.  * the prematurely created group window is destroyed correctly
  7226.  * after telling the user it doesn't exist.
  7227.  *
  7228.  * Revision 1.4  1993/04/23  22:10:48  rushing
  7229.  * added function check_server_code and used it
  7230.  * to watch for server and other errors, rather
  7231.  * than just ignoring and crashing 8^)
  7232.  *
  7233.  * Revision 1.3  1993/02/18  20:34:16  rushing
  7234.  * set CommState to ST_NONE after closing connection.
  7235.  *
  7236.  * Revision 1.2  1993/02/16  21:20:28  rushing
  7237.  * Added a function (initialize_header_array) to ensure
  7238.  * valid data in the header array in case a WM_PAINT gets
  7239.  * sent to the group window before the retrieval is finished.
  7240.  *
  7241.  * Revision 1.1  1993/02/16  20:54:22  rushing
  7242.  * Initial revision
  7243.  *
  7244. @
  7245.  
  7246.  
  7247.  
  7248. 1.46
  7249. log
  7250. @warnings
  7251. @
  7252. text
  7253. @a155 1
  7254. #include "winundoc.h"
  7255. @
  7256.  
  7257.  
  7258.  
  7259. 1.45
  7260. log
  7261. @new attach code, session [dis]connect
  7262. @
  7263. text
  7264. @d699 1
  7265. a699 1
  7266.        arts_to_retrieve = estnum;
  7267. d706 1
  7268. a706 1
  7269.                          arts_to_retrieve = (last - first) + 1;
  7270. d713 1
  7271. a713 1
  7272.                          arts_to_retrieve = estnum;
  7273. d717 1
  7274. a717 1
  7275.    arts_to_retrieve = estnum;
  7276. d1639 2
  7277. a1640 1
  7278.       if(ArtNum >= RangePtr->First && ArtNum <= RangePtr->Last) {
  7279. @
  7280.  
  7281.  
  7282.  
  7283. 1.44
  7284. log
  7285. @changes for gensock & version 0.91
  7286. @
  7287. text
  7288. @d3 3
  7289. a5 2
  7290.  * $Id: wvutil.c 1.43 1994/05/02 20:33:46 rushing Exp rushing $
  7291.  * $Log: wvutil.c $
  7292. a403 1
  7293.       return (1);
  7294. a405 1
  7295.       return (1);
  7296. d408 3
  7297. d566 2
  7298. a567 1
  7299.         PostQuitMessage (0);
  7300. d627 1
  7301. a627 1
  7302.         Initializing = INIT_DONE;
  7303. d648 1
  7304. a648 1
  7305.    Initializing = INIT_DONE;
  7306. d1296 6
  7307. a1301 1
  7308.       if (check_server_code(retcode)) break;
  7309. d1406 4
  7310. a1409 1
  7311.         PostText(PostEdit);
  7312. d1417 3
  7313. d1421 1
  7314. a1421 1
  7315.         SendMessage(PostEdit->hWndEdit, EM_SETREADONLY, FALSE, 0L);
  7316. a1422 1
  7317.  
  7318. d1442 3
  7319. a1444 1
  7320.       } else if(retcode == 240) {
  7321. d1449 2
  7322. d1461 3
  7323. a1463 2
  7324.     done = TRUE;
  7325.       } else
  7326. d1474 2
  7327. a1475 1
  7328.       
  7329. @
  7330.  
  7331.  
  7332.  
  7333. 1.43
  7334. log
  7335. @changes from jody glasser
  7336. @
  7337. text
  7338. @d3 1
  7339. a3 1
  7340.  * $Id: wvutil.c 1.42 1994/03/22 22:44:24 rushing Exp $
  7341. d5 3
  7342. d348 1
  7343. a348 1
  7344.    while((CommState != ST_CLOSED_COMM) && (ch = MRRReadComm()) >= 0) {
  7345. d554 1
  7346. a554 1
  7347.           sprintf(mybuf,"AUTHINFO user %s\r",NNTPUserName);
  7348. d556 1
  7349. a556 1
  7350.           PutCommLine(mybuf,strlen(mybuf));
  7351. d578 1
  7352. a578 1
  7353.       sprintf(mybuf,"AUTHINFO pass %s\r",mybuf2);
  7354. d580 1
  7355. a580 1
  7356.       PutCommLine(mybuf,strlen(mybuf));
  7357. d600 1
  7358. a600 1
  7359.       PutCommLine ("XOVER\r", 6);
  7360. d702 1
  7361. a702 1
  7362.                          first = RangePtr[GroupDoc->nRanges-1].Last + 1;
  7363. d756 1
  7364. a756 1
  7365.    mylen = sprintf (mybuf, "XOVER %ld-%ld\r", first, last);
  7366. d758 1
  7367. a758 1
  7368.    PutCommLine(mybuf,mylen);
  7369. d761 1
  7370. a761 1
  7371.    mylen = sprintf(mybuf,"XHDR from %ld-%ld\r",first,last);
  7372. d763 1
  7373. a763 1
  7374.    PutCommLine(mybuf,mylen);
  7375. d787 1
  7376. a787 1
  7377.           mylen = sprintf(mybuf,"XHDR from %ld-%ld\r",first,last);
  7378. d789 1
  7379. a789 1
  7380.         PutCommLine(mybuf,mylen);
  7381. d930 1
  7382. a930 1
  7383.    mylen = sprintf(mybuf,"XHDR date %ld-%ld\r",first,last);
  7384. d932 1
  7385. a932 1
  7386.    PutCommLine(mybuf,mylen);
  7387. d998 1
  7388. a998 1
  7389.    mylen = sprintf(mybuf,"XHDR lines %ld-%ld\r",first,last); 
  7390. d1000 1
  7391. a1000 1
  7392.    PutCommLine(mybuf,mylen);
  7393. d1056 2
  7394. a1057 2
  7395.      mylen = sprintf(mybuf,"XHDR references %ld-%ld\r",first,last); 
  7396.      PutCommLine(mybuf,mylen);
  7397. d1061 2
  7398. a1062 2
  7399.      mylen = sprintf(mybuf,"XHDR subject %ld-%ld\r",first,last); 
  7400.      PutCommLine(mybuf,mylen);
  7401. d1117 1
  7402. a1117 1
  7403.    mylen = sprintf(mybuf,"XHDR message-id %ld-%ld\r",first,last);
  7404. d1119 1
  7405. a1119 1
  7406.    PutCommLine(mybuf,mylen);
  7407. d1191 1
  7408. a1191 1
  7409.    mylen = sprintf(mybuf,"XHDR subject %ld-%ld\r",first,last);
  7410. d1193 1
  7411. a1193 1
  7412.    PutCommLine(mybuf,mylen);
  7413. d1424 3
  7414. @
  7415.  
  7416.  
  7417.  
  7418. 1.42
  7419. log
  7420. @handle failure of XOVER command (punt to XHDR).
  7421. @
  7422. text
  7423. @d3 1
  7424. a3 1
  7425.  * $Id: wvutil.c 1.41 1994/02/24 21:35:41 jcoop Exp rushing $
  7426. d5 3
  7427. d522 1
  7428. d679 5
  7429. d694 15
  7430. d718 2
  7431. a724 3
  7432.       LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  7433.           CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  7434.  
  7435. a736 1
  7436.      GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  7437. @
  7438.  
  7439.  
  7440.  
  7441. 1.41
  7442. log
  7443. @jcoop changes.
  7444. @
  7445. text
  7446. @d3 1
  7447. a3 1
  7448.  * $Id: wvutil.c 1.40 1994/02/16 21:05:33 cnolan Exp $
  7449. d5 3
  7450. d757 9
  7451. a765 3
  7452.       if(retcode < 100) break;
  7453.       CommState = ST_XOVER_DATA;
  7454.       CommDoc->ActiveLines = 0;
  7455. @
  7456.  
  7457.  
  7458.  
  7459. 1.40
  7460. log
  7461. @cnolan changes to 90.3
  7462. @
  7463. text
  7464. @d3 1
  7465. a3 1
  7466.  * $Id: wvutil.c 1.39 1994/02/16 20:59:17 rushing Exp $
  7467. d5 3
  7468. a502 1
  7469.   int col;
  7470. d509 1
  7471. a509 2
  7472.   char artline[MAXINTERNALLINE];
  7473.   char *cptr, *cdest;
  7474. d1260 2
  7475. a1261 1
  7476.       CommState = ST_REC_ARTICLE;
  7477. d1264 21
  7478. d1286 3
  7479. a1288 3
  7480.       if(strcmp(CommLineIn,".") == 0) {
  7481.    CommState = ST_IN_GROUP;
  7482.    CommBusy = FALSE;
  7483. d1337 12
  7484. a1348 53
  7485.     if(CommDoc->TotalLines > CommDoc->ScYLines
  7486.        && !CommDoc->TopScLineID) {
  7487.       TopOfDoc(CommDoc,&BlockPtr,&LinePtr);
  7488.       found = FALSE;
  7489.       do {
  7490.           lpsz = ((char far *)LinePtr + sizeof(TypLine) + sizeof(TypText));
  7491.         if(IsLineBlank(lpsz)) {
  7492.           found = TRUE;
  7493.           break;
  7494.         }
  7495.         if(!NextLine(&BlockPtr,&LinePtr)) break;
  7496.       } while(!found);
  7497.       NextLine(&BlockPtr,&LinePtr);
  7498.  
  7499.       /* If the line is in the last screen's worth of lines, back
  7500.        * up the pointer so it points to the first line of the last
  7501.        * screen.
  7502.        */
  7503.       if(found) {
  7504.           AdjustTopSc(BlockPtr,LinePtr);
  7505.       } else {
  7506.         UnlockLine(BlockPtr,LinePtr,&hBlock,&Offset,&MyLineID);
  7507.       }
  7508.     }
  7509.       } else {
  7510.     /* special case for lines starting with '..' */
  7511.     if (strncmp (CommLineIn, "..", 2))
  7512.       cptr = CommLineIn;
  7513.     else
  7514.       cptr = CommLineIn + 1;
  7515.  
  7516.     if (CommDecoding)
  7517.     {
  7518.       DecodeLine (currentCoded, cptr);
  7519.        break;                           
  7520.      }
  7521.     /* Copy this line into an image of a textblock line,
  7522.      * expanding tabs.
  7523.      */
  7524.     cdest = artline+sizeof(TypLine)+sizeof(TypText);
  7525.     for(col=0;
  7526.         *cptr && col<(MAXINTERNALLINE-3*sizeof(TypLine)-sizeof(TypText));
  7527.         cptr++) {
  7528.       if(*cptr == '\t') {
  7529.         do {
  7530.           *(cdest++) = ' ';
  7531.         } while (++col & 7);
  7532.       } else {
  7533.         *(cdest++) = *cptr;
  7534.         col++;
  7535.       }
  7536.     }
  7537.     *(cdest++) = '\0';
  7538. a1349 15
  7539.     ((TypLine *)artline)->LineID = NextLineID++;
  7540.     LockLine(CommDoc->hCurAddBlock,CommDoc->AddOffset,CommDoc->AddLineID,&BlockPtr,&LinePtr);
  7541.     mylen = (cdest-artline) + sizeof(int);
  7542.     mylen += mylen%2;
  7543.     ((TypText *)(artline+sizeof(TypLine)))->NameLen =
  7544.       (cdest-1) - (artline+sizeof(TypLine)+sizeof(TypText));
  7545.     ((TypLine *)artline)->length = mylen;
  7546.     *( (int *) (artline+mylen-sizeof(int)) ) = mylen;
  7547.     AddLine((TypLine *)artline,&BlockPtr,&LinePtr);
  7548.     UnlockLine(BlockPtr,LinePtr,&(CommDoc->hCurAddBlock),
  7549.            &(CommDoc->AddOffset),&(CommDoc->AddLineID));
  7550.     if((CommDoc->TotalLines % UPDATE_ART_FREQ) == 0) {
  7551.       InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);  
  7552.     }
  7553.       }
  7554. d1364 1
  7555. a1364 1
  7556.    PostText(PostEdit);
  7557. d1366 8
  7558. a1373 5
  7559.    check_server_code (retcode);
  7560.    MessageBox(PostEdit->hWnd,CommLineIn+4,"Cannot Post Article",
  7561.          MB_OK|MB_ICONEXCLAMATION);
  7562.    CommBusy = FALSE;
  7563.    CommState = ST_NONE;
  7564. d1506 60
  7565. d1917 1
  7566. a1917 2
  7567.  *    Open the common font dialog
  7568.  *    Place resulting selection name and size in face and size
  7569. d1924 2
  7570. d1936 10
  7571. a1945 1
  7572.     *color = cc.rgbResult;        
  7573. @
  7574.  
  7575.  
  7576.  
  7577. 1.39
  7578. log
  7579. @Added .ini param to force use of XHDR over XOVER
  7580. @
  7581. text
  7582. @d3 1
  7583. a3 1
  7584.  * $Id: wvutil.c 1.38 1994/02/09 18:01:08 cnolan Exp rushing $
  7585. d5 3
  7586. d1531 1
  7587. d2102 1
  7588. a2104 1
  7589.  
  7590. a2112 1
  7591. #ifndef _WIN32
  7592. a2114 1
  7593. #endif
  7594. d2118 1
  7595. a2118 1
  7596.         ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
  7597. d2121 7
  7598. a2127 1
  7599.  
  7600. @
  7601.  
  7602.  
  7603.  
  7604. 1.38
  7605. log
  7606. @cnolan 90.2 changes
  7607. @
  7608. text
  7609. @d3 1
  7610. a3 1
  7611.  * $Id: wvutil.c 1.37 1994/01/24 17:40:28 jcoop Exp $
  7612. d5 3
  7613. d584 1
  7614. a584 1
  7615.    /* now check for the XOVER command */
  7616. d592 2
  7617. a593 2
  7618.       if (retcode == 412)       /* 412 == 'not in a newsgroup' */
  7619.         xoverp = 1;
  7620. d596 1
  7621. a596 1
  7622.  
  7623. @
  7624.  
  7625.  
  7626.  
  7627. 1.37
  7628. log
  7629. @90.2 changes
  7630. @
  7631. text
  7632. @d3 1
  7633. a3 1
  7634.  * $Id: wvutil.c 1.36 1994/01/17 21:54:16 jcoop Exp $
  7635. d5 3
  7636. d2106 1
  7637. d2109 1
  7638. d2124 1
  7639. a2124 1
  7640.       SetClassWord (NewWnd->hWndEdit, GCW_HBRBACKGROUND, hArticleBackgroundBrush);
  7641. d2195 1
  7642. a2195 1
  7643.             SetClassWord (GroupDocs[i].hDocWnd, GCW_HBRBACKGROUND, hListBackgroundBrush);
  7644. d2209 1
  7645. a2209 1
  7646.         SetClassWord (ArticleDocs[i].hDocWnd, GCW_HBRBACKGROUND, hArticleBackgroundBrush);
  7647. d2218 1
  7648. a2218 1
  7649.             SetClassWord (WndPosts[i].hWndEdit, GCW_HBRBACKGROUND, hArticleBackgroundBrush);
  7650. d2226 1
  7651. a2226 1
  7652.             SetClassWord (WndMails[i].hWndEdit, GCW_HBRBACKGROUND, hArticleBackgroundBrush);
  7653. d2239 1
  7654. a2239 1
  7655.             SetClassWord (codingStatusText[i]->hTextWnd, GCW_HBRBACKGROUND, hStatusBackgroundBrush);
  7656. d2245 1
  7657. a2245 1
  7658.         SetClassWord (hCodedBlockWnd, GCW_HBRBACKGROUND, hStatusBackgroundBrush);
  7659. d2382 1
  7660. a2382 1
  7661. }@
  7662.  
  7663.  
  7664.  
  7665. 1.36
  7666. log
  7667. @Decoder integration, lots of new utilities (fonts/colors, etc)
  7668. @
  7669. text
  7670. @d3 1
  7671. a3 1
  7672.  * $Id: wvutil.c 1.36 1994/01/17 21:15:46 jcoop Exp $
  7673. d5 3
  7674. a482 1
  7675.   WndEdit * WndPost;
  7676. d507 4
  7677. a510 1
  7678.   if(CommDoc || CommDecoding) {
  7679. d1378 5
  7680. a1382 2
  7681.       WndPost = getWndEdit(WndPosts,CommWnd,MAXPOSTWNDS) ;
  7682.       found = (WndPost != NULL) ;
  7683. d1388 1
  7684. a1388 1
  7685.    PostText(WndPost);
  7686. d1391 1
  7687. a1391 1
  7688.    MessageBox(WndPost->hWnd,CommLineIn+4,"Cannot Post Article",
  7689. d1401 2
  7690. a1402 2
  7691.       WndPost = getWndEdit(WndPosts,CommWnd,MAXPOSTWNDS) ;
  7692.       found = (WndPost != NULL) ;
  7693. d1410 1
  7694. a1410 1
  7695.    MessageBox(WndPost->hWnd,CommLineIn+4,cptr,mbcode);
  7696. d1412 1
  7697. d1416 1
  7698. a1416 1
  7699. //      if (MessageBox(hWndPost,CommLineIn+4,cptr,mbcode)
  7700. d1421 3
  7701. a1423 3
  7702.        mbuf = GetEditText (WndPost->hWndEdit);
  7703.        WriteEditLog(WndPost->hWnd,PostLogFile,mbuf,
  7704.                    (unsigned int) SendMessage (WndPost->hWndEdit, WM_GETTEXTLENGTH, 0, 0L)) ;
  7705. d1426 2
  7706. a1427 2
  7707.     WndPost->dirty=DT_CLEAN ;
  7708.     DestroyWindow(WndPost->hWnd) ;
  7709. d1433 6
  7710. a1438 2
  7711.    CommBusy = FALSE;
  7712.    CommState = ST_NONE;
  7713. d1440 1
  7714. d2158 20
  7715. d2246 83
  7716. d2330 13
  7717. d2355 1
  7718. a2355 1
  7719.         "Sorry, I am already busy retrieving information from the server.\n"
  7720. @
  7721.  
  7722.  
  7723.  
  7724. 1.35
  7725. log
  7726. @fullnamefrom not working with XHDR
  7727. @
  7728. text
  7729. @a0 1
  7730.  
  7731. d3 1
  7732. a3 1
  7733.  * $Id: wvutil.c 1.34 1994/01/12 19:27:55 mrr Exp cedwards $
  7734. d5 3
  7735. d127 2
  7736. d215 1
  7737. a215 1
  7738. DWORD
  7739. d232 14
  7740. d344 3
  7741. a346 1
  7742.  
  7743. d348 3
  7744. a350 1
  7745.   
  7746. d352 7
  7747. a358 3
  7748.     sprintf (title, "Retrieving headers for '%s' : %d%%", group_name,
  7749.         (int) (line_number / total_lines));
  7750.     SetWindowText(hwnd,title);
  7751. a361 1
  7752.  
  7753. d484 1
  7754. a484 1
  7755.   int ih, found;
  7756. d505 1
  7757. a505 1
  7758.   if(CommDoc) {
  7759. d582 1
  7760. a582 1
  7761.    xoverp = 1;
  7762. d584 1
  7763. a584 1
  7764.    xoverp = 0;
  7765. d587 5
  7766. a591 3
  7767.       if(dolist == ID_DOLIST_ASK-ID_DOLIST_BASE) {
  7768.    dolist = DialogBox(hInst,"WinVnDoList",hWndConf,lpfnWinVnDoListDlg);
  7769.       }
  7770. d593 2
  7771. a594 2
  7772.    StartList();
  7773.    did_list = 1;
  7774. d596 4
  7775. a599 4
  7776.    did_list = 0;
  7777.    CommState = ST_NONE;
  7778.    CommBusy = FALSE;
  7779.    Initializing = INIT_DONE;
  7780. a600 1
  7781.  
  7782. a601 1
  7783.  
  7784. d603 2
  7785. a604 3
  7786.  
  7787.  
  7788.     case ST_LIST_RESP:
  7789. d1253 6
  7790. a1258 4
  7791.    LockLine (CommDoc->ParentDoc->hParentBlock,
  7792.         CommDoc->ParentDoc->ParentOffset,
  7793.         CommDoc->ParentDoc->ParentLineID,
  7794.         &BlockPtr, &LinePtr);
  7795. d1260 4
  7796. a1263 1
  7797.    GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  7798. d1265 3
  7799. a1267 2
  7800.    header_handle = GroupDoc->header_handle;
  7801.    thread_handle = GroupDoc->thread_handle;
  7802. d1269 3
  7803. a1271 3
  7804.    headers = lock_headers (header_handle, thread_handle);
  7805.    lpsz = (char far *) ((header_elt (headers, CommDoc->LastSeenLineID))->subject);
  7806.    unlock_headers (header_handle, thread_handle);
  7807. d1273 5
  7808. a1277 5
  7809.    mylstrncpy(group,lpsz,MAXGROUPNAME);
  7810.    sprintf(mybuf,"%s (%u lines)",group,CommDoc->TotalLines);
  7811.    SetWindowText(CommDoc->hDocWnd,mybuf);
  7812.    InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);
  7813.    GlobalUnlock(BlockPtr->hCurBlock);
  7814. d1279 20
  7815. a1298 1
  7816.    SendMessage(CommDoc->ParentDoc->hDocWnd, IDM_RETRIEVE_COMPLETE, 0, 0);
  7817. d1300 13
  7818. a1312 20
  7819.    /* Skip to the first line of the text of the article
  7820.     * and make sure it's visible on the screen.  This is
  7821.     * so that the user doesn't have to have the first
  7822.     * screen filled with a lengthy, worthless header.
  7823.     *
  7824.     * and save number of header lines (on display)
  7825.     * for later (Bretherton)
  7826.     */
  7827.    TopOfDoc(CommDoc,&BlockPtr,&LinePtr);
  7828.    found = FALSE;
  7829.    do {
  7830.      lpsz = ((char far *)LinePtr + sizeof(TypLine) + sizeof(TypText));
  7831.      if(IsLineBlank(lpsz)) {
  7832.        found = TRUE;
  7833.        CommDoc->HeaderLines=WhatLine (BlockPtr, LinePtr);
  7834.        break;
  7835.      }
  7836.      if(!NextLine(&BlockPtr,&LinePtr)) break;
  7837.    } while(!found);
  7838.    NextLine(&BlockPtr,&LinePtr);
  7839. d1314 10
  7840. a1323 25
  7841.    if(CommDoc->TotalLines > CommDoc->ScYLines
  7842.       && !CommDoc->TopScLineID) {
  7843.      TopOfDoc(CommDoc,&BlockPtr,&LinePtr);
  7844.      found = FALSE;
  7845.      do {
  7846.        lpsz = ((char far *)LinePtr + sizeof(TypLine) + sizeof(TypText));
  7847.        if(IsLineBlank(lpsz)) {
  7848.          found = TRUE;
  7849.          break;
  7850.        }
  7851.        if(!NextLine(&BlockPtr,&LinePtr)) break;
  7852.      } while(!found);
  7853.      NextLine(&BlockPtr,&LinePtr);
  7854.  
  7855.      /* If the line is in the last screen's worth of lines, back
  7856.       * up the pointer so it points to the first line of the last
  7857.       * screen.
  7858.       */
  7859.      if(found) {
  7860.        AdjustTopSc(BlockPtr,LinePtr);
  7861.      } else {
  7862.        UnlockLine(BlockPtr,LinePtr,&hBlock,&Offset,&MyLineID);
  7863.      }
  7864.    }
  7865.  
  7866. d1325 5
  7867. a1329 4
  7868.    /* Copy this line into an image of a textblock line,
  7869.     * expanding tabs.
  7870.     */
  7871.    cdest = artline+sizeof(TypLine)+sizeof(TypText);
  7872. d1331 22
  7873. a1352 5
  7874.    /* special case for lines starting with '..' */
  7875.    if (strncmp (CommLineIn, "..", 2))
  7876.      cptr = CommLineIn;
  7877.    else
  7878.      cptr = CommLineIn + 1;
  7879. d1354 14
  7880. a1367 29
  7881.    for(col=0;
  7882.        *cptr && col<(MAXINTERNALLINE-3*sizeof(TypLine)-sizeof(TypText));
  7883.        cptr++) {
  7884.      if(*cptr == '\t') {
  7885.        do {
  7886.          *(cdest++) = ' ';
  7887.        } while (++col & 7);
  7888.      } else {
  7889.        *(cdest++) = *cptr;
  7890.        col++;
  7891.      }
  7892.    }
  7893.    *(cdest++) = '\0';
  7894.  
  7895.    mylen = (cdest-artline) + sizeof(int);
  7896.    mylen += mylen%2;
  7897.    ((TypText *)(artline+sizeof(TypLine)))->NameLen =
  7898.      (cdest-1) - (artline+sizeof(TypLine)+sizeof(TypText));
  7899.    ((TypLine *)artline)->length = mylen;
  7900.    ((TypLine *)artline)->LineID = NextLineID++;
  7901.    ((TypLine *)artline)->active = TRUE;
  7902.    *( (int *) (artline+mylen-sizeof(int)) ) = mylen;
  7903.    LockLine(CommDoc->hCurAddBlock,CommDoc->AddOffset,CommDoc->AddLineID,&BlockPtr,&LinePtr);
  7904.    AddLine((TypLine *)artline,&BlockPtr,&LinePtr);
  7905.    UnlockLine(BlockPtr,LinePtr,&(CommDoc->hCurAddBlock),
  7906.          &(CommDoc->AddOffset),&(CommDoc->AddLineID));
  7907.    if((CommDoc->TotalLines % UPDATE_ART_FREQ) == 0) {
  7908.      InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);  
  7909.    }
  7910. a1368 1
  7911.  
  7912. d1409 11
  7913. a1419 11
  7914.    if (PostLog)
  7915.    {  HANDLE hEditBuffer ;
  7916.       char *mbuf ;
  7917.       hEditBuffer = (HANDLE) SendMessage (WndPost->hWndEdit, EM_GETHANDLE, 0, 0L);
  7918.       mbuf = LocalLock (hEditBuffer);
  7919.       WriteEditLog(WndPost->hWnd,PostLogFile,mbuf) ;
  7920.       LocalUnlock (hEditBuffer);
  7921.    }
  7922.    WndPost->dirty=DT_CLEAN ;
  7923.    DestroyWindow(WndPost->hWnd) ;
  7924.    done = TRUE;
  7925. d1727 10
  7926. d1738 2
  7927. d1741 1
  7928. d1743 505
  7929. @
  7930.  
  7931.  
  7932.  
  7933. 1.34
  7934. log
  7935. @mrr mods 4
  7936. @
  7937. text
  7938. @d4 1
  7939. a4 1
  7940.  * $Id: wvutil.c 1.33 1994/01/05 22:36:05 rushing Exp $
  7941. d6 3
  7942. d862 1
  7943. a862 1
  7944. //      char neat_from [80];
  7945. d886 4
  7946. a889 1
  7947.    mylstrncpy (header->from, NameString,HEADER_FROM_LENGTH);
  7948. @
  7949.  
  7950.  
  7951.  
  7952. 1.33
  7953. log
  7954. @off by one bug in PutCommLine ("XOVER\r", 5) fixed
  7955. l.
  7956. @
  7957. text
  7958. @d4 1
  7959. a4 1
  7960.  * $Id: wvutil.c 1.32 1993/12/08 01:28:01 rushing Exp rushing $
  7961. d6 4
  7962. d286 1
  7963. a286 1
  7964.     sprintf(s,"%02d%s%02d",datetime->tm_mon+1,fmtDateDelim,datetime->tm_mday);
  7965. d306 3
  7966. a308 3
  7967.      *CommLinePtr = '\0';
  7968.      DoCommState();
  7969.      CommLinePtr = CommLineIn;
  7970. d310 2
  7971. a311 2
  7972.      *(CommLinePtr++) = (char) ch;
  7973.      if(CommLinePtr == CommLineLWAp1) CommLinePtr--;
  7974. d318 3
  7975. a320 3
  7976.              char * group_name,
  7977.              unsigned long line_number,
  7978.              unsigned long total_lines)
  7979. d328 1
  7980. a328 1
  7981.          (int) (line_number / total_lines));
  7982. d371 2
  7983. a372 2
  7984.           unsigned long activenum,
  7985.           header_p headers,TypGroup far * GroupDoc)
  7986. d379 7
  7987. a385 7
  7988.     while((artnum != activenum) && (headerloc > 0))
  7989.     {
  7990.      headerloc--;
  7991.      if ((header_elt(headers,headerloc))->number == artnum)
  7992.        return(headerloc);
  7993.     }
  7994.     return(-1);
  7995. d389 7
  7996. a395 7
  7997.     while ((artnum != activenum) && (headerloc <= GroupDoc->total_headers))
  7998.     {
  7999.      headerloc++;
  8000.      if ((header_elt(headers,headerloc))->number == artnum)
  8001.        return(headerloc);
  8002.     }
  8003.     return(-1);
  8004. d413 1
  8005. a413 1
  8006.     bracket_len = 0;
  8007. d415 3
  8008. a417 3
  8009.     bracket2 = strrchr (refer, '>');
  8010.     if (bracket2)
  8011.       bracket_len = (int) (bracket2 - bracket1) + 1;
  8012. d484 57
  8013. a540 57
  8014.         if(!sscanf(CommLineIn,"%u",&retcode)) break;
  8015.         if(retcode == 200 || retcode == 201) { /* was 500 from induced error */
  8016.           CommBusy = TRUE;
  8017.           do_authinfo = FALSE;
  8018.           if(strlen(NNTPUserName)) {
  8019.              /* We have the AUTHINFO username.    Do we have the password?*/
  8020.              if(!strlen(NNTPPasswordEncrypted)) {
  8021.                 /* Get the news server user password from the user */
  8022.                 if (DialogBox (hInst, "WinVnComm", hWndConf, lpfnWinVnCommDlg)
  8023.                     && strlen(NNTPPasswordEncrypted)) {
  8024.                   do_authinfo = TRUE;
  8025.                 }
  8026.              } else {
  8027.                 do_authinfo = TRUE;
  8028.              }
  8029.           }
  8030.           if(do_authinfo) {
  8031.              sprintf(mybuf,"AUTHINFO user %s\r",NNTPUserName);
  8032.              CommState = ST_CHECK_AUTHINFO_USERNAME;
  8033.              PutCommLine(mybuf,strlen(mybuf));
  8034.           } else {
  8035.              goto End_Authinfo;
  8036.           }
  8037.  
  8038.         } else {
  8039.           MessageBox (hWndConf, CommLineIn, "Access Problem", MB_OK);
  8040. /*          MRRCloseComm (); */
  8041.           PostQuitMessage (0);
  8042.         }
  8043.  
  8044.         break;
  8045.  
  8046.      case ST_CHECK_AUTHINFO_USERNAME:
  8047.         retcode = 0;
  8048.         sscanf(CommLineIn,"%u",&retcode);
  8049.         if(!retcode) break;
  8050.         if(retcode >= 500) {
  8051.           MessageBox (hWndConf, "Error authorizing your username with the News Server.", "WinVN", MB_OK | MB_ICONHAND);
  8052.           goto End_Authinfo;
  8053.         }
  8054.         MRRDecrypt(NNTPPasswordEncrypted,(unsigned char *)mybuf2,MAXINTERNALLINE);
  8055.         sprintf(mybuf,"AUTHINFO pass %s\r",mybuf2);
  8056.         CommState = ST_CHECK_AUTHINFO_PASSWORD;
  8057.         PutCommLine(mybuf,strlen(mybuf));
  8058.         break;
  8059.  
  8060.     case ST_CHECK_AUTHINFO_PASSWORD:
  8061.         if(dialog_active)break;
  8062.         retcode = 0;
  8063.         if(sscanf(CommLineIn,"%u",&retcode) <= 0) break;
  8064.         if(retcode < 200 || retcode > 299) {
  8065.           dialog_active = TRUE;
  8066.           sprintf(mybuf,"Error authorizing your password with the News Server:\n%s.",CommLineIn);
  8067.           MessageBox (hWndConf,mybuf , "WinVN", MB_OK | MB_ICONHAND);
  8068.           dialog_active = FALSE;
  8069.         }
  8070.         goto End_Authinfo;
  8071. d543 1
  8072. a543 1
  8073.      case ST_END_AUTHINFO:
  8074. d545 4
  8075. a548 4
  8076.     /* now check for the XOVER command */
  8077.         CommState = ST_XOVER_CHECK;
  8078.         PutCommLine ("XOVER\r", 6);
  8079.         break;
  8080. d554 1
  8081. a554 1
  8082.     xoverp = 1;
  8083. d556 1
  8084. a556 1
  8085.     xoverp = 0;
  8086. d560 1
  8087. a560 1
  8088.     dolist = DialogBox(hInst,"WinVnDoList",hWndConf,lpfnWinVnDoListDlg);
  8089. d563 2
  8090. a564 2
  8091.     StartList();
  8092.     did_list = 1;
  8093. d566 4
  8094. a569 4
  8095.     did_list = 0;
  8096.     CommState = ST_NONE;
  8097.     CommBusy = FALSE;
  8098.     Initializing = INIT_DONE;
  8099. d581 2
  8100. a582 2
  8101.     check_server_code (retcode);
  8102.     break;
  8103. d591 4
  8104. a594 4
  8105.     CommState = ST_NONE;
  8106.     CommBusy = FALSE;
  8107.     Initializing = INIT_DONE;
  8108.     InvalidateRect(hWndConf,NULL,FALSE);
  8109. d596 1
  8110. a596 1
  8111.     ProcEndList();
  8112. d598 1
  8113. a598 1
  8114.     ProcListLine((unsigned char *)CommLineIn);
  8115. d607 7
  8116. a613 7
  8117.     MessageBox (hWndConf, "No Such Newsgroup", "Error", MB_OK | MB_ICONHAND);
  8118.     /* abort the fledgling group window */
  8119.     DestroyWindow (CommDoc->hDocWnd);
  8120.     CommBusy = FALSE;
  8121.     CommState = ST_NONE;
  8122.     return;
  8123.     break;
  8124. d615 7
  8125. a621 7
  8126.     MessageBox (hWndConf, "Restricted Access", "WinVN", MB_OK | MB_ICONHAND);
  8127.     /* abort the fledgling group window */
  8128.     DestroyWindow (CommDoc->hDocWnd);
  8129.     CommBusy = FALSE;
  8130.     CommState = ST_NONE;
  8131.     return;
  8132.     break;
  8133. d623 2
  8134. a624 2
  8135.     if (check_server_code(retcode)) return;
  8136.     break;
  8137. d628 1
  8138. a628 1
  8139.          &retcode,&estnum,&first,&last,group);
  8140. d632 8
  8141. a639 8
  8142.     DialogBox (hInst, "THRESHOLD",
  8143.            CommDoc->hDocWnd, lpfnWinVnThresholdDlg);
  8144.     if ((arts_to_retrieve > 0) && ((last - arts_to_retrieve) > first)) {
  8145.       first = (last - arts_to_retrieve) + 1;
  8146.     }
  8147.     else
  8148.       if (arts_to_retrieve == -1) /* they clicked 'all of them' */
  8149.         arts_to_retrieve = estnum;
  8150. d642 1
  8151. a642 1
  8152.     arts_to_retrieve = estnum;
  8153. d644 6
  8154. a649 6
  8155.     MessageBox (hWndConf, "Empty Newsgroup", "WinVN", MB_OK | MB_ICONHAND);
  8156.     /* abort the fledgling group window */
  8157.     DestroyWindow (CommDoc->hDocWnd);
  8158.     CommBusy = FALSE;
  8159.     CommState = ST_NONE;
  8160.     return;
  8161. d655 1
  8162. a655 1
  8163.            CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8164. d658 5
  8165. a662 5
  8166.     {
  8167.       header_handle =
  8168.         GlobalAlloc (GMEM_MOVEABLE, (long)
  8169.              ((sizeof (TypHeader)) *
  8170.               (long)(arts_to_retrieve)) + sizeof (thread_array *));
  8171. d664 10
  8172. a673 10
  8173.       /* allocate space for the header_array index table */
  8174.       thread_handle =
  8175.         GlobalAlloc (GMEM_MOVEABLE,
  8176.              (long) ((sizeof (long)) * (long) (arts_to_retrieve)));
  8177.       
  8178.       GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  8179.       GroupDoc->header_handle = header_handle;
  8180.       GroupDoc->thread_handle = thread_handle;
  8181.       
  8182.     }
  8183. d686 3
  8184. a688 3
  8185.     mylen = sprintf (mybuf, "XOVER %ld-%ld\r", first, last);
  8186.     CommState = ST_XOVER_START;
  8187.     PutCommLine(mybuf,mylen);
  8188. d691 3
  8189. a693 3
  8190.     mylen = sprintf(mybuf,"XHDR from %ld-%ld\r",first,last);
  8191.     CommState = ST_XHDR_FROM_START;
  8192.     PutCommLine(mybuf,mylen);
  8193. d719 5
  8194. a723 5
  8195.     /* this is a yuck way to do this */
  8196.     CommState = ST_IN_GROUP;
  8197.     CommBusy = FALSE;
  8198.     finish_header_retrieval (CommDoc);
  8199.     InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);
  8200. d726 87
  8201. a812 87
  8202.     char * this_hop, * next_hop;
  8203.     char * reference;
  8204.     
  8205.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  8206.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8207.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  8208.     header_handle = GroupDoc->header_handle;
  8209.     thread_handle = GroupDoc->thread_handle;
  8210.  
  8211.     GlobalUnlock(BlockPtr->hCurBlock);
  8212.  
  8213.     /* Lock the header data */
  8214.     headers = lock_headers (header_handle, thread_handle);
  8215.     header = header_elt (headers, CommDoc->ActiveLines);
  8216.  
  8217.     this_hop=CommLineIn;
  8218.  
  8219.     /* article number */
  8220.     next_hop = strchr (this_hop, '\t');
  8221.     *(next_hop++) = (char) NULL;
  8222.  
  8223.     header->number = atol (this_hop);
  8224.     
  8225.     /* subject */
  8226.     this_hop = next_hop;
  8227.     next_hop = strchr (this_hop, '\t');
  8228.     *(next_hop++) = (char) NULL;
  8229.     
  8230.     mylstrncpy (header->subject, this_hop, HEADER_SUBJECT_LENGTH);
  8231.  
  8232.     /* author */
  8233.     this_hop = next_hop;
  8234.     next_hop = strchr (this_hop, '\t');
  8235.     *(next_hop++) = (char) NULL;
  8236.  
  8237.     ParseAddress (this_hop,
  8238.               AddressString,MAXDIALOGSTRING,
  8239.               NameString,MAXDIALOGSTRING ) ;
  8240.  
  8241.     if (FullNameFrom)
  8242.       mylstrncpy (header->from, NameString, HEADER_FROM_LENGTH);
  8243.     else
  8244.       mylstrncpy (header->from, this_hop, HEADER_FROM_LENGTH);
  8245.  
  8246.     /* date */
  8247.     this_hop = next_hop;
  8248.     next_hop = strchr (this_hop, '\t');
  8249.     *(next_hop++) = (char) NULL;
  8250.  
  8251.     header->date = parse_usenet_date (this_hop);
  8252.  
  8253.     /* message-id */
  8254.     this_hop = next_hop;
  8255.     next_hop = strchr (this_hop, '\t');
  8256.     *(next_hop++) = (char) NULL;
  8257.  
  8258.     mylstrncpy (header->message_id, this_hop, HEADER_MESSAGE_ID_LENGTH);
  8259.  
  8260.     /* references */
  8261.     this_hop = next_hop;
  8262.     next_hop = strchr (this_hop, '\t');
  8263.     *(next_hop++) = (char) NULL;
  8264.     
  8265.     reference = get_best_reference (this_hop);
  8266.     if (reference) mylstrncpy (header->references, reference, HEADER_REFERENCES_LENGTH);
  8267.  
  8268.     /* bytes (ignored) */
  8269.     this_hop = next_hop;
  8270.     next_hop = strchr (this_hop, '\t');
  8271.     *(next_hop++) = (char) NULL;
  8272.     
  8273.     /* lines (last one doesn't have to have the tab */
  8274.     this_hop = next_hop;
  8275.     header->lines = atoi (this_hop);
  8276.  
  8277.     /* set other header fields */
  8278.     header->Selected= FALSE ;
  8279.     header->ArtDoc  = (TypDoc *) NULL;
  8280.     header->Seen = WasArtSeen (header->number,GroupDoc);
  8281.  
  8282.     unlock_headers (header_handle, thread_handle);
  8283.  
  8284.     CommDoc->ActiveLines++;
  8285.  
  8286.     update_window_title (CommDoc->hDocWnd, group,
  8287.                  RcvLineCount++,
  8288.                  CommDoc->TotalLines);
  8289. d825 1
  8290. a825 1
  8291.                 
  8292. d833 1
  8293. a833 1
  8294.                      /* mid-session change-of-mind  */
  8295. d841 2
  8296. a842 2
  8297.     LockLine(CommDoc->hParentBlock, CommDoc->ParentOffset,
  8298.          CommDoc->ParentLineID, &BlockPtr,&LinePtr);
  8299. d844 2
  8300. a845 2
  8301.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) );
  8302.     GroupDoc->total_headers = CommDoc->ActiveLines;
  8303. d847 2
  8304. a848 2
  8305.     first = GroupDoc->ServerFirst;
  8306.     last = GroupDoc->ServerLast;
  8307. d850 7
  8308. a856 7
  8309.     GlobalUnlock(BlockPtr->hCurBlock);
  8310.     CommDoc->ActiveLines = 0;
  8311.  
  8312.     /* Now ask for the date lines */
  8313.     mylen = sprintf(mybuf,"XHDR date %ld-%ld\r",first,last);
  8314.     CommState = ST_XHDR_DATE_START;
  8315.     PutCommLine(mybuf,mylen);
  8316. d860 32
  8317. a891 32
  8318.     /* Access the Group struct, get HANDLE for header data */
  8319.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  8320.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8321.     
  8322.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) );
  8323.     header_handle = GroupDoc->header_handle;
  8324.     thread_handle = GroupDoc->thread_handle;
  8325.  
  8326.     GlobalUnlock(BlockPtr->hCurBlock);
  8327.  
  8328.     /* Lock the header data */
  8329.     headers = lock_headers (header_handle, thread_handle);
  8330.  
  8331.     sscanf (CommLineIn, "%ld", &artnum);
  8332.     header = header_elt (headers, CommDoc->ActiveLines);
  8333.     header->number = artnum;
  8334.  
  8335.     /* now use some of our nice formatting of email addresses */
  8336.     ParseAddress (get_xhdr_line (CommLineIn),
  8337.               AddressString,MAXDIALOGSTRING,
  8338.               NameString,MAXDIALOGSTRING ) ;
  8339.  
  8340.     /* copy that into headers[].from */
  8341.     mylstrncpy (header->from, NameString,HEADER_FROM_LENGTH);
  8342.  
  8343.     unlock_headers (header_handle, thread_handle);
  8344.  
  8345.     CommDoc->ActiveLines++;
  8346.  
  8347.     update_window_title (CommDoc->hDocWnd, group,
  8348.                  RcvLineCount++,
  8349.                  CommDoc->TotalLines * total_xhdrs);
  8350. d906 2
  8351. a907 2
  8352.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  8353.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8354. d909 2
  8355. a910 2
  8356.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) );
  8357.     GroupDoc->total_headers = CommDoc->ActiveLines;
  8358. d912 2
  8359. a913 2
  8360.     first = GroupDoc->ServerFirst;
  8361.     last = GroupDoc->ServerLast;
  8362. d915 7
  8363. a921 7
  8364.     GlobalUnlock(BlockPtr->hCurBlock);
  8365.     CommDoc->ActiveLines = 0;
  8366.  
  8367.     /* Now ask for the #of lines */
  8368.     mylen = sprintf(mybuf,"XHDR lines %ld-%ld\r",first,last); 
  8369.     CommState = ST_XHDR_LINES_START; 
  8370.     PutCommLine(mybuf,mylen);
  8371. d924 22
  8372. a945 22
  8373.     
  8374.     /* Access the Group struct, get HANDLE for header data */
  8375.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  8376.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8377.     GroupDoc = ((TypGroup far *)((char far *)LinePtr+sizeof(TypLine)));
  8378.     header_handle = GroupDoc->header_handle;
  8379.     thread_handle = GroupDoc->thread_handle;
  8380.  
  8381.     GlobalUnlock(BlockPtr->hCurBlock);
  8382.  
  8383.     /* Lock the header data */
  8384.     headers = lock_headers (header_handle, thread_handle); 
  8385.     syncnum = sync_artnum(atol (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  8386.     if (syncnum >= 0)
  8387.       (header_elt(headers,syncnum))->date = parse_usenet_date (get_xhdr_line (CommLineIn));
  8388.  
  8389.     unlock_headers (header_handle, thread_handle);
  8390.  
  8391.     CommDoc->ActiveLines++;
  8392.     update_window_title (CommDoc->hDocWnd, group,
  8393.                  RcvLineCount++,
  8394.                  CommDoc->TotalLines * total_xhdrs);
  8395. d960 2
  8396. a961 2
  8397.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  8398.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8399. d963 2
  8400. a964 2
  8401.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) );
  8402.     GroupDoc->total_headers = CommDoc->ActiveLines;
  8403. d966 2
  8404. a967 2
  8405.     first = GroupDoc->ServerFirst;
  8406.     last = GroupDoc->ServerLast;
  8407. d969 16
  8408. a984 16
  8409.     GlobalUnlock(BlockPtr->hCurBlock);
  8410.     CommDoc->ActiveLines = 0;
  8411.  
  8412.     /* Check for threading option, if enabled, go to REF & ID */
  8413.     /* states first */
  8414.  
  8415.     if (threadp) {
  8416.       CommState = ST_XHDR_REF_START;          
  8417.       mylen = sprintf(mybuf,"XHDR references %ld-%ld\r",first,last); 
  8418.       PutCommLine(mybuf,mylen);
  8419.     }
  8420.     else {
  8421.       CommState = ST_XHDR_SUBJECT_START; 
  8422.       mylen = sprintf(mybuf,"XHDR subject %ld-%ld\r",first,last); 
  8423.       PutCommLine(mybuf,mylen);
  8424.     }
  8425. d989 22
  8426. a1010 22
  8427.     /* Access the Group struct, get HANDLE for header data */
  8428.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  8429.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8430.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  8431.  
  8432.     header_handle = GroupDoc->header_handle;
  8433.     thread_handle = GroupDoc->thread_handle;
  8434.  
  8435.     GlobalUnlock(BlockPtr->hCurBlock);
  8436.  
  8437.     /* Lock the header data */
  8438.     headers = lock_headers (header_handle, thread_handle);
  8439.  
  8440.     syncnum = sync_artnum(atol (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  8441.     if (syncnum >= 0)
  8442.        sscanf (CommLineIn, "%ld %Fd", &artnum,&((header_elt(headers,syncnum))->lines));
  8443.  
  8444.     unlock_headers (header_handle, thread_handle);
  8445.     CommDoc->ActiveLines++;
  8446.     update_window_title (CommDoc->hDocWnd, group,
  8447.                  RcvLineCount++,
  8448.                  CommDoc->TotalLines * total_xhdrs);
  8449. d1025 2
  8450. a1026 2
  8451.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  8452.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8453. d1028 2
  8454. a1029 2
  8455.     GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof(TypLine));
  8456.     GroupDoc->total_headers = CommDoc->ActiveLines;
  8457. d1031 2
  8458. a1032 2
  8459.     first = GroupDoc->ServerFirst;
  8460.     last = GroupDoc->ServerLast;
  8461. d1034 7
  8462. a1040 7
  8463.     GlobalUnlock(BlockPtr->hCurBlock);
  8464.     CommDoc->ActiveLines = 0;
  8465.  
  8466.     /* Now ask for the message-id lines */
  8467.     mylen = sprintf(mybuf,"XHDR message-id %ld-%ld\r",first,last);
  8468.     CommState = ST_XHDR_MID_START;
  8469.     PutCommLine(mybuf,mylen);
  8470. d1043 1
  8471. a1043 1
  8472.     char far * refer;    // , far * end,far * bracket1,far *bracket2;
  8473. d1046 26
  8474. a1071 26
  8475.     /* Access the Group struct, get HANDLE for header data */
  8476.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  8477.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8478.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  8479.  
  8480.     header_handle = GroupDoc->header_handle;
  8481.     thread_handle = GroupDoc->thread_handle;
  8482.  
  8483.     GlobalUnlock(BlockPtr->hCurBlock);
  8484.  
  8485.     /* Lock the header data */
  8486.     headers = lock_headers (header_handle, thread_handle);
  8487.  
  8488.     /* for now, we only pay attention to first (whole) referral */
  8489.     refer = get_xhdr_line(CommLineIn);
  8490.  
  8491.     refer = get_best_reference (refer);
  8492.  
  8493.     if (refer)
  8494.       {
  8495.        /* Patch to check for bad info from server JD 6/19/93 */
  8496.       syncnum = sync_artnum(atol (CommLineIn),
  8497.                 (header_elt(headers,
  8498.                         CommDoc->ActiveLines))->number,
  8499.                 headers,GroupDoc);
  8500.       if (syncnum >= 0)
  8501. d1073 2
  8502. a1074 2
  8503.             refer,HEADER_REFERENCES_LENGTH);
  8504.       }
  8505. d1076 1
  8506. a1076 1
  8507.     unlock_headers (header_handle, thread_handle);
  8508. d1078 4
  8509. a1081 4
  8510.     CommDoc->ActiveLines++;
  8511.     update_window_title (CommDoc->hDocWnd, group,
  8512.                  RcvLineCount++,
  8513.                  CommDoc->TotalLines * total_xhdrs);
  8514. d1098 17
  8515. a1114 17
  8516.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  8517.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8518.     
  8519.     GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof(TypLine));
  8520.  
  8521.     GroupDoc->total_headers = CommDoc->ActiveLines;
  8522.     
  8523.     first = GroupDoc->ServerFirst;
  8524.     last = GroupDoc->ServerLast;
  8525.  
  8526.     GlobalUnlock(BlockPtr->hCurBlock);
  8527.     CommDoc->ActiveLines = 0;
  8528.  
  8529.     /* Now ask for the subject lines */
  8530.     mylen = sprintf(mybuf,"XHDR subject %ld-%ld\r",first,last);
  8531.     CommState = ST_XHDR_SUBJECT_START;
  8532.     PutCommLine(mybuf,mylen);
  8533. d1117 3
  8534. a1119 3
  8535.     /* Access the Group struct, get HANDLE for header data */
  8536.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  8537.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8538. d1121 1
  8539. a1121 1
  8540.     GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof(TypLine));
  8541. d1123 2
  8542. a1124 2
  8543.     header_handle = GroupDoc->header_handle;
  8544.     thread_handle = GroupDoc->thread_handle;
  8545. d1126 1
  8546. a1126 1
  8547.     GlobalUnlock(BlockPtr->hCurBlock);
  8548. d1128 2
  8549. a1129 2
  8550.     /* Lock the header data */
  8551.     headers = lock_headers (header_handle, thread_handle);
  8552. d1131 5
  8553. a1135 5
  8554.     syncnum = sync_artnum(atol (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  8555.     if (syncnum >= 0)
  8556.       mylstrncpy((header_elt (headers,syncnum))->message_id,
  8557.              (char far *) (get_xhdr_line (CommLineIn)),
  8558.              HEADER_MESSAGE_ID_LENGTH);         /* bad, hardcoded. */
  8559. d1137 1
  8560. a1137 1
  8561.     unlock_headers (header_handle, thread_handle);
  8562. d1139 4
  8563. a1142 4
  8564.     CommDoc->ActiveLines++;
  8565.     update_window_title (CommDoc->hDocWnd, group,
  8566.                  RcvLineCount++,
  8567.                  CommDoc->TotalLines * total_xhdrs);
  8568. d1159 4
  8569. a1162 4
  8570.     CommState = ST_IN_GROUP;
  8571.     CommBusy = FALSE;
  8572.     finish_header_retrieval (CommDoc);
  8573.     InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);
  8574. d1166 36
  8575. a1201 36
  8576.     artnum = 0;
  8577.     sscanf(CommLineIn,"%ld",&artnum);
  8578.     if(artnum) {
  8579.       LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  8580.            CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8581.  
  8582.       GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  8583.       header_handle = GroupDoc->header_handle;
  8584.       thread_handle = GroupDoc->thread_handle;        
  8585.       headers = lock_headers (header_handle, thread_handle);
  8586.  
  8587.       /* update the seen thing. */
  8588.       syncnum = sync_artnum(atol (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  8589.       if (syncnum >= 0) 
  8590.          header = header_elt (headers, syncnum);
  8591.       else
  8592.          header = header_elt (headers, CommDoc->ActiveLines);
  8593.  
  8594.       header->Selected= FALSE ;
  8595.       header->ArtDoc  = (TypDoc *) NULL;
  8596.       header->Seen =
  8597.         WasArtSeen (artnum,(TypGroup far *)( ((char far *)LinePtr) +
  8598.                         sizeof(TypLine) ) );
  8599.  
  8600.       UnlockLine(BlockPtr,LinePtr,&(CommDoc->hParentBlock),
  8601.              &(CommDoc->ParentOffset),&(CommDoc->ParentLineID));
  8602.  
  8603.       mylstrncpy(header->subject,
  8604.              get_xhdr_line (CommLineIn), HEADER_SUBJECT_LENGTH);
  8605.  
  8606.  
  8607.       unlock_headers (header_handle, thread_handle);
  8608.       CommDoc->ActiveLines++;
  8609.       update_window_title (CommDoc->hDocWnd, group,
  8610.                    RcvLineCount++,
  8611.                    CommDoc->TotalLines * total_xhdrs);
  8612. d1203 1
  8613. a1203 1
  8614.     }
  8615. d1220 2
  8616. a1221 2
  8617.     CommState = ST_IN_GROUP;
  8618.     CommBusy = FALSE;
  8619. d1223 67
  8620. a1289 67
  8621.     LockLine (CommDoc->ParentDoc->hParentBlock,
  8622.           CommDoc->ParentDoc->ParentOffset,
  8623.           CommDoc->ParentDoc->ParentLineID,
  8624.           &BlockPtr, &LinePtr);
  8625.  
  8626.     GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  8627.  
  8628.     header_handle = GroupDoc->header_handle;
  8629.     thread_handle = GroupDoc->thread_handle;
  8630.  
  8631.     headers = lock_headers (header_handle, thread_handle);
  8632.     lpsz = (char far *) ((header_elt (headers, CommDoc->LastSeenLineID))->subject);
  8633.     unlock_headers (header_handle, thread_handle);
  8634.  
  8635.     mylstrncpy(group,lpsz,MAXGROUPNAME);
  8636.     sprintf(mybuf,"%s (%u lines)",group,CommDoc->TotalLines);
  8637.     SetWindowText(CommDoc->hDocWnd,mybuf);
  8638.     InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);
  8639.     GlobalUnlock(BlockPtr->hCurBlock);
  8640.  
  8641.     SendMessage(CommDoc->ParentDoc->hDocWnd, IDM_RETRIEVE_COMPLETE, 0, 0);
  8642.  
  8643.     /* Skip to the first line of the text of the article
  8644.      * and make sure it's visible on the screen.  This is
  8645.      * so that the user doesn't have to have the first
  8646.      * screen filled with a lengthy, worthless header.
  8647.      *
  8648.      * and save number of header lines (on display)
  8649.      * for later (Bretherton)
  8650.      */
  8651.     TopOfDoc(CommDoc,&BlockPtr,&LinePtr);
  8652.     found = FALSE;
  8653.     do {
  8654.       lpsz = ((char far *)LinePtr + sizeof(TypLine) + sizeof(TypText));
  8655.       if(IsLineBlank(lpsz)) {
  8656.         found = TRUE;
  8657.         CommDoc->HeaderLines=WhatLine (BlockPtr, LinePtr);
  8658.         break;
  8659.       }
  8660.       if(!NextLine(&BlockPtr,&LinePtr)) break;
  8661.     } while(!found);
  8662.     NextLine(&BlockPtr,&LinePtr);
  8663.  
  8664.     if(CommDoc->TotalLines > CommDoc->ScYLines
  8665.        && !CommDoc->TopScLineID) {
  8666.       TopOfDoc(CommDoc,&BlockPtr,&LinePtr);
  8667.       found = FALSE;
  8668.       do {
  8669.         lpsz = ((char far *)LinePtr + sizeof(TypLine) + sizeof(TypText));
  8670.         if(IsLineBlank(lpsz)) {
  8671.           found = TRUE;
  8672.           break;
  8673.         }
  8674.         if(!NextLine(&BlockPtr,&LinePtr)) break;
  8675.       } while(!found);
  8676.       NextLine(&BlockPtr,&LinePtr);
  8677.  
  8678.       /* If the line is in the last screen's worth of lines, back
  8679.        * up the pointer so it points to the first line of the last
  8680.        * screen.
  8681.        */
  8682.       if(found) {
  8683.         AdjustTopSc(BlockPtr,LinePtr);
  8684.       } else {
  8685.         UnlockLine(BlockPtr,LinePtr,&hBlock,&Offset,&MyLineID);
  8686.       }
  8687.     }
  8688. d1292 40
  8689. a1331 39
  8690.     /* Copy this line into an image of a textblock line,
  8691.      * expanding tabs.
  8692.      */
  8693.     cdest = artline+sizeof(TypLine)+sizeof(TypText);
  8694.  
  8695.     /* special case for lines starting with '..' */
  8696.     if (strncmp (CommLineIn, "..", 2))
  8697.       cptr = CommLineIn;
  8698.     else
  8699.       cptr = CommLineIn + 1;
  8700.  
  8701.     for(col=0;
  8702.         *cptr && col<(MAXINTERNALLINE-3*sizeof(TypLine)-sizeof(TypText));
  8703.         cptr++) {
  8704.       if(*cptr == '\t') {
  8705.         do {
  8706.           *(cdest++) = ' ';
  8707.         } while (++col & 7);
  8708.       } else {
  8709.         *(cdest++) = *cptr;
  8710.         col++;
  8711.       }
  8712.     }
  8713.     *(cdest++) = '\0';
  8714.  
  8715.     mylen = (cdest-artline) + sizeof(int);
  8716.     mylen += mylen%2;
  8717.     ((TypText *)(artline+sizeof(TypLine)))->NameLen =
  8718.       (cdest-1) - (artline+sizeof(TypLine)+sizeof(TypText));
  8719.     ((TypLine *)artline)->length = mylen;
  8720.     ((TypLine *)artline)->LineID = NextLineID++;
  8721.     *( (int *) (artline+mylen-sizeof(int)) ) = mylen;
  8722.     LockLine(CommDoc->hCurAddBlock,CommDoc->AddOffset,CommDoc->AddLineID,&BlockPtr,&LinePtr);
  8723.     AddLine((TypLine *)artline,&BlockPtr,&LinePtr);
  8724.     UnlockLine(BlockPtr,LinePtr,&(CommDoc->hCurAddBlock),
  8725.            &(CommDoc->AddOffset),&(CommDoc->AddLineID));
  8726.     if((CommDoc->TotalLines % UPDATE_ART_FREQ) == 0) {
  8727.       InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);  
  8728.     }
  8729. d1345 1
  8730. a1345 1
  8731.     PostText(WndPost);
  8732. d1347 5
  8733. a1351 5
  8734.     check_server_code (retcode);
  8735.     MessageBox(WndPost->hWnd,CommLineIn+4,"Cannot Post Article",
  8736.            MB_OK|MB_ICONEXCLAMATION);
  8737.     CommBusy = FALSE;
  8738.     CommState = ST_NONE;
  8739. d1365 4
  8740. a1368 4
  8741.     cptr = "Posting Failed";
  8742.     mbcode = MB_OK|MB_ICONEXCLAMATION;
  8743.     MessageBox(WndPost->hWnd,CommLineIn+4,cptr,mbcode);
  8744.     done = TRUE;
  8745. d1370 2
  8746. a1371 2
  8747.     cptr = "Article Posted OK";
  8748.     mbcode = MB_OKCANCEL;
  8749. d1374 11
  8750. a1384 11
  8751.     if (PostLog)
  8752.     {  HANDLE hEditBuffer ;
  8753.        char *mbuf ;
  8754.        hEditBuffer = (HANDLE) SendMessage (WndPost->hWndEdit, EM_GETHANDLE, 0, 0L);
  8755.        mbuf = LocalLock (hEditBuffer);
  8756.        WriteEditLog(WndPost->hWnd,PostLogFile,mbuf) ;
  8757.        LocalUnlock (hEditBuffer);
  8758.     }
  8759.     WndPost->dirty=DT_CLEAN ;
  8760.     DestroyWindow(WndPost->hWnd) ;
  8761.     done = TRUE;
  8762. d1386 1
  8763. a1386 1
  8764.     if (check_server_code (retcode)) break;
  8765. d1389 2
  8766. a1390 2
  8767.     CommBusy = FALSE;
  8768.     CommState = ST_NONE;
  8769. d1397 1
  8770. a1397 1
  8771.             M Bretherton 14 June 1993
  8772. d1402 1
  8773. a1402 1
  8774.     if( WndMails[ih].hWnd) == CommWnd) {
  8775. d1404 1
  8776. a1404 1
  8777.       hWndPost = WndMails[ih];
  8778. d1406 3
  8779. a1408 3
  8780.       found = TRUE;
  8781.       break;
  8782.     }
  8783. d1413 1
  8784. a1413 1
  8785.     break;
  8786. d1415 1
  8787. a1415 1
  8788.     PostText(ih,DOCTYPE_MAIL);
  8789. d1417 4
  8790. a1420 4
  8791.     MessageBox(WndPost->hWnd,CommLineIn+4,"Cannot Mail Message",
  8792.            MB_OK|MB_ICONEXCLAMATION);
  8793.     CommBusy = FALSE;
  8794.     CommState = ST_NONE;
  8795. d1427 1
  8796. a1427 1
  8797.     if(WbdPosts[ih].hWnd) == CommWnd) {
  8798. d1429 1
  8799. a1429 1
  8800.       WndPost = WndPosts[ih];
  8801. d1431 3
  8802. a1433 3
  8803.       found = TRUE;
  8804.       break;
  8805.     }
  8806. d1438 4
  8807. a1441 4
  8808.     cptr = "Posting Failed";
  8809.     mbcode = MB_OK|MB_ICONEXCLAMATION;
  8810.     MessageBox(WndPost->hWnd,CommLineIn+4,cptr,mbcode);
  8811.     done = TRUE;
  8812. d1443 2
  8813. a1444 2
  8814.     cptr = "Article Posted OK";
  8815.     mbcode = MB_OKCANCEL;
  8816. d1447 2
  8817. a1448 2
  8818.     DestroyWindow(WndPost->hWnd) ;
  8819.     done = TRUE;
  8820. d1450 1
  8821. a1450 1
  8822.     if (check_server_code (retcode)) break;
  8823. d1453 2
  8824. a1454 2
  8825.     CommBusy = FALSE;
  8826.     CommState = ST_NONE;
  8827. d1495 1
  8828. a1495 1
  8829.      return(TRUE);
  8830. d1497 1
  8831. a1497 1
  8832.      RangePtr++;
  8833. d1516 1
  8834. a1516 1
  8835.      return(1);
  8836. d1518 1
  8837. a1518 1
  8838.      return(-1);
  8839. d1570 14
  8840. a1583 14
  8841.     for(;*s1 && *s2 && *s1!=' ' && *s2!=' '; s1++,s2++) {
  8842.         if(*s1 > *s2) {
  8843.             return (1);
  8844.         } else if(*s1 < *s2) {
  8845.             return (-1);
  8846.         }
  8847.     }
  8848.     if(*s1 == *s2) {
  8849.         return(0);
  8850.     } else if(*s1) {
  8851.         return(1);
  8852.     } else {
  8853.         return(-1);
  8854.     }
  8855. d1604 6
  8856. a1609 1
  8857.   CommDoc->ActiveLines = 0;
  8858. d1614 1
  8859. a1614 1
  8860.        CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8861. d1627 1
  8862. a1627 1
  8863.     
  8864. d1631 1
  8865. a1631 1
  8866.                sizeof(TypLine)+ sizeof(TypGroup) ) ;
  8867. d1645 1
  8868. a1645 1
  8869.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  8870. d1652 1
  8871. a1652 1
  8872.       
  8873. d1654 3
  8874. a1656 3
  8875.         for (i = CommDoc->TotalLines - 1;
  8876.          ((i > 0) && ((header_elt(headers,i))->Seen == FALSE));
  8877.          i--) ;
  8878. d1680 3
  8879. a1682 3
  8880.     {
  8881.       return & WndEdits[ih] ;
  8882.     }
  8883. @
  8884.  
  8885.  
  8886.  
  8887. 1.32
  8888. log
  8889. @new version box and cr lf consistency
  8890. @
  8891. text
  8892. @d4 1
  8893. a4 1
  8894.  * $Id: wvutil.c 1.31 1993/12/01 23:24:06 rushing Exp rushing $
  8895. d6 3
  8896. d543 1
  8897. a543 1
  8898.         PutCommLine ("XOVER\r", 5);
  8899. @
  8900.  
  8901.  
  8902.  
  8903. 1.31
  8904. log
  8905. @off by one on date problem shows up dec. 1.
  8906. @
  8907. text
  8908. @d1 1
  8909. d4 1
  8910. a4 1
  8911.  * $Id: wvutil.c 1.30 1993/11/24 23:07:20 rushing Exp rushing $
  8912. d6 3
  8913. d494 1
  8914. a494 1
  8915.              sprintf(mybuf,"AUTHINFO user %s",NNTPUserName);
  8916. d518 1
  8917. a518 1
  8918.         sprintf(mybuf,"AUTHINFO pass %s",mybuf2);
  8919. d540 1
  8920. a540 1
  8921.         PutCommLine ("XOVER", 5);
  8922. d679 1
  8923. a679 1
  8924.     mylen = sprintf (mybuf, "XOVER %ld-%ld", first, last);
  8925. @
  8926.  
  8927.  
  8928.  
  8929. 1.30
  8930. log
  8931. @let the user know about access trouble
  8932. @
  8933. text
  8934. @d3 1
  8935. a3 1
  8936.  * $Id: wvutil.c 1.29 1993/11/22 20:30:50 rushing Exp rushing $
  8937. d5 3
  8938. d245 1
  8939. a245 1
  8940.   if (cp=strstr(fmtMonthTable,mon)) mth=(cp-fmtMonthTable)/3 + 1;
  8941. d272 1
  8942. a272 1
  8943.        sprintf(s,"%02d%s%02d",datetime->tm_mday,fmtDateDelim,datetime->tm_mon);
  8944. d275 1
  8945. a275 1
  8946.     sprintf(s,"%02d%s%02d",datetime->tm_mon,fmtDateDelim,datetime->tm_mday);
  8947. @
  8948.  
  8949.  
  8950.  
  8951. 1.29
  8952. log
  8953. @handle mixed-case dates
  8954. @
  8955. text
  8956. @d3 1
  8957. a3 1
  8958.  * $Id: wvutil.c 1.28 1993/08/25 18:53:17 mbretherton Exp rushing $
  8959. d5 3
  8960. d495 2
  8961. a496 1
  8962.           MRRCloseComm ();
  8963. d498 1
  8964. a498 1
  8965.       }
  8966. @
  8967.  
  8968.  
  8969.  
  8970. 1.28
  8971. log
  8972. @MRB merge, mail & post logging
  8973. @
  8974. text
  8975. @d3 1
  8976. a3 1
  8977.  * $Id: wvutil.c 1.27 1993/08/25 17:05:17 mbretherton Exp $
  8978. d5 3
  8979. d216 1
  8980. a216 1
  8981.   static char fmtMonthTable[37] = "JanFebMarAprMayJunJulAugSepOctNovDec" ;
  8982. d227 1
  8983. a227 1
  8984.  
  8985. d234 4
  8986. a237 1
  8987.   if ((sc < 0) || (sc > 59)) return(0);
  8988. @
  8989.  
  8990.  
  8991.  
  8992. 1.27
  8993. log
  8994. @merge from first newsrc.zip
  8995. @
  8996. text
  8997. @d3 1
  8998. a3 1
  8999.  * $Id: wvutil.c 1.26 1993/08/18 21:49:21 rushing Exp $
  9000. d5 3
  9001. d835 1
  9002. a835 1
  9003. //    char neat_from [80];
  9004. d900 1
  9005. a900 1
  9006.         
  9007. d913 2
  9008. a914 2
  9009.         if (syncnum >= 0)
  9010.           (header_elt(headers,syncnum))->date = parse_usenet_date (get_xhdr_line (CommLineIn));
  9011. d978 2
  9012. a979 2
  9013.         syncnum = sync_artnum(atol (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  9014.         if (syncnum >= 0)
  9015. d1020 1
  9016. a1020 1
  9017. //    int bracket_len; 
  9018. d1043 4
  9019. a1046 1
  9020.       syncnum = sync_artnum(atol (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  9021. d1048 2
  9022. a1049 1
  9023.             mylstrncpy ((header_elt (headers,syncnum))->references, refer,HEADER_REFERENCES_LENGTH);
  9024. d1107 2
  9025. a1108 2
  9026.         syncnum = sync_artnum(atol (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  9027.         if (syncnum >= 0)
  9028. d1155 1
  9029. a1155 1
  9030.           if (syncnum >= 0) 
  9031. d1157 2
  9032. a1158 2
  9033.           else
  9034.              header = header_elt (headers, CommDoc->ActiveLines);
  9035. d1320 1
  9036. a1320 1
  9037.     PostText(ih,DOCTYPE_POSTING);
  9038. d1347 2
  9039. a1348 2
  9040. //    if (MessageBox(hWndPost,CommLineIn+4,cptr,mbcode)
  9041. //         == ID_OK)
  9042. d1353 1
  9043. a1353 1
  9044.            mbuf = LocalLock (hEditBuffer);
  9045. d1420 2
  9046. a1421 2
  9047. //    if (MessageBox(WndPost->hWnd,CommLineIn+4,cptr,mbcode)
  9048. //         == ID_OK)
  9049. d1636 4
  9050. a1639 6
  9051.  *  Look through the MAIL or Post edits and return the edit with
  9052.  *  matching window handle
  9053.  Consider - centralising initial window location in wvmail and wndpost
  9054.             using a single array (save passing structure and size into this module)
  9055.  
  9056.  
  9057. d1643 7
  9058. a1649 7
  9059.  WndEdit * getWndEdit(WndEdit * WndEdits,HWND hWnd,int numEntries)
  9060.  { 
  9061.    int ih ;
  9062.  
  9063.    for(ih=0; ih<numEntries; ih++)
  9064.    {
  9065.     if(WndEdits[ih].hWnd == hWnd)
  9066. d1652 1
  9067. a1652 1
  9068.      }
  9069. d1655 9
  9070. a1663 1
  9071. //   MessageBox(0,"getWndEditFound Nothing","mrb debug", MB_OK | MB_ICONHAND);
  9072. a1664 2
  9073.    return(WndEdit *) NULL ;
  9074.  }@
  9075.  
  9076.  
  9077.  
  9078. 1.26
  9079. log
  9080. @more 16-bit article number fixes.
  9081. @
  9082. text
  9083. @d3 1
  9084. a3 1
  9085.  * $Id: wvutil.c 1.25 1993/08/05 20:06:07 jcoop Exp rushing $
  9086. d5 3
  9087. d426 1
  9088. a426 1
  9089.   HWND hWndPost;
  9090. a1304 2
  9091.       for(ih=0,found=FALSE; !found && ih<MAXPOSTWNDS; ih++) {
  9092.     if(&(PostingDocs[ih]) == CommDoc) {
  9093. d1306 2
  9094. a1307 1
  9095.       hWndPost = hWndPosts[ih];
  9096. a1308 4
  9097.       found = TRUE;
  9098.       break;
  9099.     }
  9100.       }
  9101. d1316 1
  9102. a1316 1
  9103.     MessageBox(hWndPost,CommLineIn+4,"Cannot Post Article",
  9104. a1324 2
  9105.       for(ih=0,found=FALSE; !found && ih<MAXPOSTWNDS; ih++) {
  9106.     if(&(PostingDocs[ih]) == CommDoc) {
  9107. d1326 2
  9108. a1327 1
  9109.       hWndPost = hWndPosts[ih];
  9110. d1329 1
  9111. a1329 4
  9112.       found = TRUE;
  9113.       break;
  9114.     }
  9115.       }
  9116. d1335 1
  9117. a1335 1
  9118.     MessageBox(hWndPost,CommLineIn+4,cptr,mbcode);
  9119. d1342 10
  9120. a1351 1
  9121.         DestroyWindow(hWndPost) ;
  9122. d1370 1
  9123. a1370 1
  9124.     if(&(MailDocs[ih]) == CommDoc) {
  9125. d1372 1
  9126. a1372 1
  9127.       hWndPost = hWndMails[ih];
  9128. d1385 1
  9129. a1385 1
  9130.     MessageBox(hWndPost,CommLineIn+4,"Cannot Mail Message",
  9131. d1395 1
  9132. a1395 1
  9133.     if(&(PostingDocs[ih]) == CommDoc) {
  9134. d1397 1
  9135. a1397 1
  9136.       hWndPost = hWndPosts[ih];
  9137. d1408 1
  9138. a1408 1
  9139.     MessageBox(hWndPost,CommLineIn+4,cptr,mbcode);
  9140. d1413 1
  9141. a1413 1
  9142. //    if (MessageBox(hWndPost,CommLineIn+4,cptr,mbcode)
  9143. d1415 1
  9144. a1415 1
  9145.         DestroyWindow(hWndPost) ;
  9146. d1627 27
  9147. @
  9148.  
  9149.  
  9150.  
  9151. 1.25
  9152. log
  9153. @save multiple articles changes by jcoop@@oakb2s01.apl.com (John S Cooper)
  9154. @
  9155. text
  9156. @d3 1
  9157. a3 1
  9158.  * $Id: wvutil.c 1.24 1993/07/13 16:03:04 riordan Exp $
  9159. d5 3
  9160. d274 1
  9161. a274 1
  9162.    while((ch = MRRReadComm()) >= 0) {
  9163. d428 1
  9164. a428 1
  9165.   unsigned int estnum;
  9166. d430 1
  9167. a430 1
  9168.   unsigned int artnum;
  9169. d473 1
  9170. a474 1
  9171.              CommState = ST_CHECK_AUTHINFO_USERNAME;
  9172. d496 1
  9173. a497 1
  9174.         CommState = ST_CHECK_AUTHINFO_PASSWORD;
  9175. d516 1
  9176. a517 1
  9177.         CommState = ST_XOVER_CHECK;
  9178. d597 1
  9179. a597 1
  9180.       sscanf(CommLineIn,"%u %u %ld %ld %s",
  9181. d657 1
  9182. a658 1
  9183.     CommState = ST_XOVER_START;
  9184. d662 1
  9185. a663 1
  9186.     CommState = ST_XHDR_FROM_START;
  9187. d724 1
  9188. a724 1
  9189.     mylstrcpy (header->subject, this_hop);
  9190. d736 1
  9191. a736 1
  9192.       mylstrcpy (header->from, NameString);
  9193. d738 1
  9194. a738 1
  9195.       mylstrcpy (header->from, this_hop);
  9196. d752 1
  9197. a752 1
  9198.     mylstrncpy (header->message_id, this_hop, 30);
  9199. d760 1
  9200. a760 1
  9201.     if (reference) mylstrncpy (header->references, reference, 30);
  9202. d825 1
  9203. a826 1
  9204.     CommState = ST_XHDR_DATE_START;
  9205. d853 1
  9206. a853 1
  9207.     mylstrcpy (header->from, NameString);
  9208. d890 1
  9209. a891 1
  9210.     CommState = ST_XHDR_LINES_START; 
  9211. d1009 1
  9212. a1010 1
  9213.     CommState = ST_XHDR_MID_START;
  9214. d1039 1
  9215. a1039 1
  9216.             mylstrcpy ((header_elt (headers,syncnum))->references, refer);
  9217. d1079 1
  9218. a1080 1
  9219.     CommState = ST_XHDR_SUBJECT_START;
  9220. d1100 2
  9221. a1101 2
  9222.            (char far *) (get_xhdr_line (CommLineIn)),
  9223.            30);         /* bad, hardcoded. */
  9224. d1159 2
  9225. a1160 2
  9226.       mylstrcpy(header->subject,
  9227.             get_xhdr_line (CommLineIn));
  9228. d1451 1
  9229. a1451 1
  9230. long int ArtNum;
  9231. d1613 4
  9232. a1616 3
  9233.     for (i = CommDoc->TotalLines - 1;
  9234.      (((header_elt(headers,i))->Seen == FALSE) && (i > 0));
  9235.      i--) ;
  9236. @
  9237.  
  9238.  
  9239.  
  9240. 1.24
  9241. log
  9242. @MRR mods
  9243. @
  9244. text
  9245. @d3 1
  9246. a3 1
  9247.  * $Id: wvutil.c 1.23 1993/06/28 17:52:17 rushing Exp $
  9248. d5 3
  9249. d1205 2
  9250. @
  9251.  
  9252.  
  9253.  
  9254. 1.23
  9255. log
  9256. @fixed compiler warnings
  9257. @
  9258. text
  9259. @d3 1
  9260. a3 1
  9261.  * $Id: wvutil.c 1.22 1993/06/25 20:18:51 dumoulin Exp rushing $
  9262. d5 3
  9263. d413 1
  9264. d429 1
  9265. a429 1
  9266.   BOOL dolist;
  9267. d432 1
  9268. d449 27
  9269. a475 6
  9270.       retcode = 0;
  9271.       sscanf(CommLineIn,"%u",&retcode);
  9272.       if(retcode == 200 || retcode == 201) { /* was 500 from induced error */
  9273.     /* now check for the XOVER command */
  9274.     PutCommLine ("XOVER", 5);
  9275.     CommState = ST_XOVER_CHECK;
  9276. d477 29
  9277. a505 4
  9278.       else {
  9279.     MRRCloseComm ();
  9280.     PostQuitMessage (0);
  9281.       }
  9282. d507 6
  9283. a512 1
  9284.       break;
  9285. @
  9286.  
  9287.  
  9288.  
  9289. 1.22
  9290. log
  9291. @Changed Date fields from Strings to Posix standard time format
  9292. @
  9293. text
  9294. @d3 1
  9295. a3 1
  9296.  * $Id: wvutil.c 1.21 1993/06/22 16:43:03 bretherton Exp rushing $
  9297. d5 3
  9298. d332 3
  9299. a334 1
  9300. long sync_artnum (long artnum,long activenum,header_p headers,TypGroup far * GroupDoc)
  9301. d1392 1
  9302. a1392 1
  9303.    int nr;
  9304. @
  9305.  
  9306.  
  9307.  
  9308. 1.21
  9309. log
  9310. @auto close on posting window
  9311. @
  9312. text
  9313. @d3 1
  9314. a3 1
  9315.  * $Id: wvutil.c 1.20 1993/06/22 14:04:05 dumoulin Exp $
  9316. d5 2
  9317. d8 1
  9318. d89 1
  9319. d93 1
  9320. a93 1
  9321. char * parse_usenet_date (char * date);
  9322. d189 1
  9323. a189 1
  9324. char *
  9325. d192 1
  9326. a196 1
  9327.  
  9328. d215 1
  9329. a215 3
  9330. /*  while (*cp) { *cp = toupper(*cp); ++cp; } */
  9331. /*  sprintf(s,"%d-%s-%d %d:%d:%d",dom,mon,yr,hr,mn,sc); */
  9332. /* use international format in date
  9333. d217 2
  9334. a218 2
  9335.   fmtDaysB4Mth  = European format ( windows type 1)
  9336.   fmtDateDelim  normally '/' or "."
  9337. d220 6
  9338. a225 4
  9339.   and save a character
  9340.     Matthew Bretherton  15/5/93
  9341. */
  9342.   if (cp=strstr(fmtMonthTable,mon)) mth=(cp-fmtMonthTable)/3 + 1;
  9343. d227 1
  9344. a227 9
  9345.   if (fmtDaysB4Mth)
  9346.   {
  9347.       sprintf(s,"%2d%s%-2d",dom,fmtDateDelim,mth);
  9348.   } else
  9349.   { 
  9350.       sprintf(s,"%2d%s%-2d",mth,fmtDateDelim,dom);
  9351.   }
  9352.  
  9353.   return(s);
  9354. d230 22
  9355. d630 1
  9356. a630 1
  9357.     char * reference, * parsed_date;
  9358. d678 1
  9359. a678 3
  9360.     parsed_date = parse_usenet_date (this_hop);
  9361.     
  9362.     mylstrcpy (header->date, parsed_date ? parsed_date : "-----");
  9363. d702 1
  9364. a702 1
  9365.     header->lines = atol (this_hop);
  9366. d762 1
  9367. a762 1
  9368.     char neat_from [80];
  9369. a826 1
  9370.     char far * parsed_date;
  9371. a838 1
  9372.     parsed_date = parse_usenet_date (get_xhdr_line (CommLineIn));
  9373. d841 1
  9374. a841 1
  9375.           mylstrcpy((header_elt(headers,syncnum))->date,parsed_date ? parsed_date : "-----");
  9376. d946 2
  9377. a947 2
  9378.     char far * refer, far * end,far * bracket1,far *bracket2;
  9379.     int bracket_len; 
  9380. d1029 1
  9381. a1029 1
  9382.       
  9383. d1056 1
  9384. a1056 1
  9385.       
  9386. d1095 1
  9387. a1095 1
  9388.       
  9389. d1490 1
  9390. a1490 1
  9391.   HANDLE hBlock;
  9392. d1533 1
  9393. a1533 1
  9394.     long i;
  9395. @
  9396.  
  9397.  
  9398.  
  9399. 1.20
  9400. log
  9401. @Fixed problems with article numbers larger than 32K
  9402. @
  9403. text
  9404. @d3 1
  9405. a3 1
  9406.  * $Id: wvutil.c 1.19 1993/06/19 18:40:17 dumoulin Exp dumoulin $
  9407. d5 4
  9408. d390 1
  9409. a390 1
  9410.   HWND hWndPostEdit;
  9411. d1222 1
  9412. a1222 1
  9413.       hWndPostEdit = hWndPostEdits[ih];
  9414. d1235 1
  9415. a1235 1
  9416.     MessageBox(hWndPostEdit,CommLineIn+4,"Cannot Post Article",
  9417. d1247 1
  9418. a1247 1
  9419.       hWndPostEdit = hWndPostEdits[ih];
  9420. d1258 1
  9421. d1262 4
  9422. a1265 1
  9423.     mbcode = MB_OK;
  9424. a1272 1
  9425.     MessageBox(hWndPostEdit,CommLineIn+4,cptr,mbcode);
  9426. d1277 3
  9427. d1286 1
  9428. a1286 1
  9429.       hWndPostEdit = hWndMailEdits[ih];
  9430. d1299 1
  9431. a1299 1
  9432.     MessageBox(hWndPostEdit,CommLineIn+4,"Cannot Mail Message",
  9433. d1307 3
  9434. a1309 3
  9435.     case ST_MAIL_WAIT_END:
  9436.       for(ih=0,found=FALSE; !found && ih<MAXMAILWNDS; ih++) {
  9437.     if(&(MailDocs[ih]) == CommDoc) {
  9438. d1311 1
  9439. a1311 1
  9440.       hWndPostEdit = hWndMailEdits[ih];
  9441. d1319 2
  9442. a1320 2
  9443.       if(retcode == 451 || retcode == 450) {
  9444.     cptr = "Mailing Failed";
  9445. d1322 1
  9446. d1324 6
  9447. a1329 3
  9448.       } else if(retcode == 250) {
  9449.     cptr = "Message sent OK";
  9450.     mbcode = MB_OK;
  9451. d1331 3
  9452. a1333 1
  9453.       }
  9454. a1336 1
  9455.     MessageBox(hWndPostEdit,CommLineIn+4,cptr,mbcode);
  9456. d1341 1
  9457. a1341 1
  9458.  
  9459. @
  9460.  
  9461.  
  9462.  
  9463. 1.19
  9464. log
  9465. @Added error routines to handle unsyncd XHDRS from screwed up servers
  9466. @
  9467. text
  9468. @d3 1
  9469. a3 1
  9470.  * $Id: wvutil.c 1.18 1993/06/15 21:16:59 rushing Exp dumoulin $
  9471. d5 3
  9472. d628 1
  9473. a628 1
  9474.     header->number = atoi (this_hop);
  9475. d682 1
  9476. a682 1
  9477.     header->lines = atoi (this_hop);
  9478. d821 1
  9479. a821 1
  9480.     syncnum = sync_artnum(atoi (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  9481. d887 1
  9482. a887 1
  9483.         syncnum = sync_artnum(atoi (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  9484. d952 1
  9485. a952 1
  9486.       syncnum = sync_artnum(atoi (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  9487. d1012 1
  9488. a1012 1
  9489.         syncnum = sync_artnum(atoi (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  9490. d1059 1
  9491. a1059 1
  9492.       syncnum = sync_artnum(atoi (CommLineIn),(header_elt(headers,CommDoc->ActiveLines))->number,headers,GroupDoc);
  9493. @
  9494.  
  9495.  
  9496.  
  9497. 1.18
  9498. log
  9499. @headers-> to header-> in two lines.
  9500. @
  9501. text
  9502. @d3 1
  9503. a3 1
  9504.  * $Id: wvutil.c 1.17 1993/06/11 00:10:35 rushing Exp rushing $
  9505. d5 3
  9506. d146 1
  9507. a146 1
  9508.     else            /* No name in parens */
  9509. d149 1
  9510. a149 1
  9511.   else                /* !FullNameFrom */
  9512. d240 3
  9513. a242 3
  9514.          *CommLinePtr = '\0';
  9515.          DoCommState();
  9516.          CommLinePtr = CommLineIn;
  9517. d244 2
  9518. a245 2
  9519.          *(CommLinePtr++) = (char) ch;
  9520.          if(CommLinePtr == CommLineLWAp1) CommLinePtr--;
  9521. d252 3
  9522. a254 3
  9523.                          char * group_name,
  9524.                          unsigned long line_number,
  9525.                          unsigned long total_lines)
  9526. d296 34
  9527. d389 1
  9528. a389 1
  9529.   long int first,last;
  9530. d431 1
  9531. a431 1
  9532.       if (retcode == 412)    /* 412 == 'not in a newsgroup' */
  9533. d433 1
  9534. a433 1
  9535.       else            /* 500 == 'command not understood' */
  9536. d536 1
  9537. a536 1
  9538.           {
  9539. d551 1
  9540. a551 1
  9541.           }
  9542. d705 1
  9543. a705 1
  9544.  
  9545. d805 1
  9546. d816 1
  9547. a816 2
  9548.     headers = lock_headers (header_handle, thread_handle);
  9549.  
  9550. d818 3
  9551. a820 2
  9552.     mylstrcpy((header_elt(headers,CommDoc->ActiveLines))->date,
  9553.           parsed_date ? parsed_date : "-----");
  9554. d858 1
  9555. a858 1
  9556.       CommState = ST_XHDR_REF_START;      
  9557. a870 1
  9558.  
  9559. d884 3
  9560. a886 2
  9561.     sscanf (CommLineIn, "%ld %Fd", &artnum,
  9562.         &((header_elt(headers,CommDoc->ActiveLines))->lines));
  9563. d926 1
  9564. a926 1
  9565.     int bracket_len;
  9566. d947 6
  9567. a952 1
  9568.       mylstrcpy ((header_elt (headers,CommDoc->ActiveLines))->references, refer);
  9569. d1008 4
  9570. a1011 2
  9571.  
  9572.     mylstrncpy((header_elt (headers,CommDoc->ActiveLines))->message_id,
  9573. d1013 1
  9574. a1013 1
  9575.            30);        /* bad, hardcoded. */
  9576. d1052 1
  9577. a1052 1
  9578.       thread_handle = GroupDoc->thread_handle;      
  9579. d1056 5
  9580. a1060 2
  9581.  
  9582.       header = header_elt (headers, CommDoc->ActiveLines);
  9583. d1359 1
  9584. a1359 1
  9585.          return(TRUE);
  9586. d1361 1
  9587. a1361 1
  9588.          RangePtr++;
  9589. d1380 1
  9590. a1380 1
  9591.          return(1);
  9592. d1382 1
  9593. a1382 1
  9594.          return(-1);
  9595. d1477 1
  9596. a1477 1
  9597.   thread_handle = GroupDoc->thread_handle;      
  9598. d1509 1
  9599. a1509 1
  9600.     thread_handle = GroupDoc->thread_handle;      
  9601. @
  9602.  
  9603.  
  9604.  
  9605. 1.17
  9606. log
  9607. @second merge from Matt Bretherton sources
  9608. @
  9609. text
  9610. @d3 1
  9611. a3 1
  9612.  * $Id: wvutil.c 1.16 1993/06/10 18:25:17 rushing Exp rushing $
  9613. d5 3
  9614. d1015 2
  9615. a1016 2
  9616.       headers->ArtDoc  = (TypDoc *) NULL;
  9617.       headers->Seen =
  9618. @
  9619.  
  9620.  
  9621.  
  9622. 1.16
  9623. log
  9624. @XOVER support.
  9625. @
  9626. text
  9627. @d3 1
  9628. a3 1
  9629.  * $Id: wvutil.c 1.15 1993/06/08 19:42:38 rushing Exp rushing $
  9630. d5 3
  9631. d176 3
  9632. a178 1
  9633.   int dom = 0, yr = 0, hr = 0, mn = 0, sc = 0;
  9634. d200 4
  9635. a203 1
  9636. /* use standard Unix format in date
  9637. d205 1
  9638. a205 2
  9639.    could save a character by using win.ini date format
  9640.    US = mm.dd and others dd/mm, letting delimiter show type of format
  9641. d208 10
  9642. a217 1
  9643.   sprintf(s,"%2d %s",dom,mon);
  9644. @
  9645.  
  9646.  
  9647.  
  9648. 1.15
  9649. log
  9650. @always do the thread_index array so we can sort on other fields.
  9651. @
  9652. text
  9653. @d3 1
  9654. a3 1
  9655.  * $Id: wvutil.c 1.14 1993/06/05 03:18:25 rushing Exp rushing $
  9656. d5 3
  9657. d69 1
  9658. d74 1
  9659. d275 36
  9660. d361 3
  9661. a363 13
  9662.     dolist = DoList;
  9663.     if(dolist == ID_DOLIST_ASK-ID_DOLIST_BASE) {
  9664.       dolist = DialogBox(hInst,"WinVnDoList",hWndConf,lpfnWinVnDoListDlg);
  9665.     }
  9666.     if(dolist) {
  9667.       StartList();
  9668.     } else {
  9669.       CommState = ST_NONE;
  9670.       CommBusy = FALSE;
  9671.       Initializing = INIT_DONE;
  9672.     }
  9673.  
  9674.     InvalidateRect(hWndConf,NULL,FALSE);
  9675. d372 27
  9676. d507 132
  9677. a638 4
  9678.       mylen = sprintf(mybuf,"XHDR from %ld-%ld\r",first,last);
  9679.       PutCommLine(mybuf,mylen);
  9680.       CommState = ST_XHDR_FROM_START;
  9681.       
  9682. d641 1
  9683. a885 1
  9684.     end = refer + strlen(refer) - 1; /* points to NULL */
  9685. d887 1
  9686. a887 1
  9687.     /* yikes this is ugly */
  9688. d889 2
  9689. a890 25
  9690.     bracket1 = strrchr (refer, '<');
  9691.     if (bracket1) {
  9692.       bracket_len = (int) (end - bracket1) + 2;
  9693.       if ((bracket_len < 30) && (!strrchr(bracket1,'>'))) {
  9694.         *bracket1 = (char) NULL;
  9695.         bracket1 = strrchr (refer, '<');
  9696.         if (!bracket1)
  9697.           bracket_len = 0;
  9698.         else {
  9699.           bracket2 = strrchr (refer, '>');
  9700.           if (bracket2)
  9701.         bracket_len = (int) (bracket2 - bracket1) + 1;
  9702.         }
  9703.       }
  9704.     }
  9705.     else
  9706.       bracket_len = 0;
  9707.         
  9708.     if (bracket_len > 30)
  9709.       bracket_len = 30;
  9710.  
  9711.     if (bracket_len)
  9712.       mylstrncpy((header_elt (headers,CommDoc->ActiveLines))->references,
  9713.              bracket1,
  9714.              bracket_len);
  9715. d971 1
  9716. d975 1
  9717. a975 55
  9718.  
  9719.     /* release the mouse that is captured to the usenet window */
  9720.     ReleaseCapture ();
  9721.  
  9722.     CommDoc->TotalLines = CommDoc->ActiveLines;
  9723.     CommDoc->ActiveLines = 0;
  9724.     /* Fetch this group's line in NetDoc so we can get the
  9725.      * group's name for the window's title bar.
  9726.      */
  9727.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  9728.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  9729.  
  9730.     GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  9731.     header_handle = GroupDoc->header_handle;
  9732.     thread_handle = GroupDoc->thread_handle;      
  9733.     lock_headers (header_handle, thread_handle);
  9734.  
  9735.     if (threadp) {
  9736.       SetWindowText (CommDoc->hDocWnd, "sorting headers...");
  9737.       sort_by_threads (header_handle, thread_handle, CommDoc->TotalLines);
  9738.     }
  9739.  
  9740.     unlock_headers (header_handle, thread_handle);
  9741.     
  9742.     lpsz = (char far *) ( ((char far *)LinePtr) +
  9743.                  sizeof(TypLine)+ sizeof(TypGroup) ) ;
  9744.  
  9745.     mylstrncpy(group,lpsz,MAXGROUPNAME);
  9746.     sprintf(mybuf,"%s (%u articles)",group,CommDoc->TotalLines);
  9747.     SetWindowText(CommDoc->hDocWnd,mybuf);
  9748.  
  9749.     /* If we have information from NEWSRC on the highest-
  9750.      * numbered article previously seen, position the window
  9751.      * so the new articles can be seen without scrolling.
  9752.      */
  9753.     {
  9754.       long i;
  9755.  
  9756.       LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  9757.            CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  9758.  
  9759.       /* inside the lock, can access the GroupStruct */
  9760.       GroupDoc = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)));
  9761.       header_handle = GroupDoc->header_handle;
  9762.       thread_handle = GroupDoc->thread_handle;      
  9763.       headers = lock_headers (header_handle, thread_handle);
  9764.       
  9765.       for (i = CommDoc->TotalLines - 1;
  9766.            (((header_elt(headers,i))->Seen == FALSE) && (i > 0));
  9767.         i--) ;
  9768.            CommDoc->TopLineOrd = (i > 5) ? i - 4 : 0;
  9769.  
  9770.       unlock_headers (header_handle, thread_handle);
  9771.     }
  9772.  
  9773. d977 2
  9774. a978 1
  9775.       } else {
  9776. d1384 15
  9777. d1400 52
  9778. d1453 2
  9779. @
  9780.  
  9781.  
  9782.  
  9783. 1.14
  9784. log
  9785. @primitive functional threading.
  9786. @
  9787. text
  9788. @d3 1
  9789. a3 1
  9790.  * $Id: wvutil.c 1.13 1993/06/01 18:22:40 rushing Exp rushing $
  9791. d5 3
  9792. d231 2
  9793. d234 2
  9794. a235 1
  9795.     sprintf (title, "Retrieving headers for '%s' : %d%%", group_name, ((line_number *100) / total_lines));
  9796. a236 1
  9797.     // InvalidateRect (hwnd, NULL, FALSE);
  9798. d428 5
  9799. a432 10
  9800.       /* if threading is enabled, allocate space for the */
  9801.       /* header_array index table */
  9802.       if (threadp) {
  9803.         thread_handle =
  9804.           GlobalAlloc (GMEM_MOVEABLE,
  9805.                (long) ((sizeof (long)) * (long) (arts_to_retrieve)));
  9806.       }
  9807.       else
  9808.         thread_handle = NULL;
  9809.  
  9810. d828 4
  9811. a831 2
  9812.     /* temporary */
  9813.     sort_by_threads (header_handle, thread_handle, CommDoc->TotalLines);
  9814. @
  9815.  
  9816.  
  9817.  
  9818. 1.13
  9819. log
  9820. @moved header funcs to headarry.c
  9821. @
  9822. text
  9823. @d3 1
  9824. a3 1
  9825.  * $Id: wvutil.c 1.12 1993/05/26 23:59:40 rushing Exp rushing $
  9826. d5 3
  9827. d681 3
  9828. d697 31
  9829. a727 4
  9830.     mylstrncpy((header_elt (headers,CommDoc->ActiveLines))->references,
  9831.            (char far *) (get_xhdr_line (CommLineIn)),
  9832.            30);        /* bad, hardcoded. */
  9833.  
  9834. @
  9835.  
  9836.  
  9837.  
  9838. 1.12
  9839. log
  9840. @reimplemented positioning group window near last read article
  9841. @
  9842. text
  9843. @d3 1
  9844. a3 1
  9845.  * $Id: wvutil.c 1.11 1993/05/24 23:56:51 rushing Exp rushing $
  9846. d5 3
  9847. a11 1
  9848.  *
  9849. d61 1
  9850. a61 3
  9851.  
  9852. /* temporary test */
  9853. char far *mylstrcpy(char huge *ptr1, char far *ptr2);
  9854. d66 2
  9855. a69 1
  9856.  
  9857. a231 23
  9858. void
  9859. initialize_header_array (HANDLE header_handle, long length)
  9860. {
  9861.   long i;
  9862.   TypHeader huge * headers;
  9863.  
  9864.   // Lock the header data
  9865.   headers = (TypHeader huge *) (GlobalLock (header_handle) + sizeof(char huge *));
  9866.  
  9867.   for (i=0; i < length ; i++) {
  9868.     headers[i].Seen = (char) 0;
  9869.     headers[i].Selected = (char) 0;
  9870.     headers[i].number = 0;
  9871.     headers[i].lines = 0;
  9872.     headers[i].date[0] = (char) 0;
  9873.     headers[i].subject[0] = (char) 0;
  9874.     headers[i].from[0] = (char) 0;
  9875.     headers[i].message_id[0] = (char) 0;
  9876.     headers[i].references[0] = (char) 0;
  9877.     headers[i].ArtDoc = NULL;
  9878.   }
  9879. }
  9880.  
  9881. d297 3
  9882. a299 1
  9883.   TypHeader huge * headers;
  9884. d418 11
  9885. a428 1
  9886.               (long)(arts_to_retrieve)) + sizeof (char huge *));
  9887. d430 4
  9888. a433 2
  9889.       (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)))
  9890.        ->header_handle) = header_handle;
  9891. d437 1
  9892. a437 1
  9893.       initialize_header_array (header_handle, arts_to_retrieve);
  9894. d457 6
  9895. d466 2
  9896. d475 9
  9897. a483 10
  9898.     LockLine(CommDoc->hParentBlock,
  9899.          CommDoc->ParentOffset,
  9900.          CommDoc->ParentLineID,
  9901.          &BlockPtr,&LinePtr);
  9902.     (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )
  9903.      ->total_headers) = CommDoc->ActiveLines;
  9904.     first = (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)))
  9905.          ->ServerFirst );
  9906.     last = (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)))
  9907.         ->ServerLast );
  9908. d495 7
  9909. a501 2
  9910.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  9911.     header_handle = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->header_handle;
  9912. d505 1
  9913. a505 1
  9914.     headers = (TypHeader huge *) (GlobalLock (header_handle) + sizeof(char huge *));
  9915. d508 2
  9916. a509 3
  9917.     headers[CommDoc->ActiveLines].number = artnum;
  9918.  
  9919.     /* use name@@host (This Name) if available */
  9920. a510 5
  9921. #if 0
  9922.     make_neat_from (get_xhdr_line (CommLineIn),
  9923.             headers[CommDoc->ActiveLines].from); 
  9924. #endif
  9925.  
  9926. d517 3
  9927. a519 1
  9928.     strcpy (headers[CommDoc->ActiveLines].from, NameString);
  9929. a520 1
  9930.     GlobalUnlock (header_handle);
  9931. a541 6
  9932.     (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->
  9933.      total_headers) = CommDoc->ActiveLines;
  9934.     first =
  9935.       (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) ) ->ServerFirst );
  9936.     last = (((TypGroup far *)
  9937.          ((char far *) LinePtr + sizeof(TypLine)) ) ->ServerLast );
  9938. d543 6
  9939. d562 4
  9940. a565 2
  9941.     header_handle =
  9942.       ((TypGroup far *)((char far *)LinePtr+sizeof(TypLine)))->header_handle;
  9943. d569 2
  9944. a570 1
  9945.     headers = (TypHeader huge *)(GlobalLock (header_handle) + sizeof (char huge *));
  9946. d572 2
  9947. a573 2
  9948.     mylstrcpy(headers[CommDoc->ActiveLines].date,
  9949.           parsed_date ? parsed_date : "no date");
  9950. d575 2
  9951. a576 1
  9952.     GlobalUnlock (header_handle);
  9953. d595 5
  9954. a599 3
  9955.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  9956.     (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->total_headers) = CommDoc->ActiveLines;
  9957.     first = (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerFirst );
  9958. d601 2
  9959. a602 2
  9960.     last = (((TypGroup far *)
  9961.          ((char far *) LinePtr + sizeof(TypLine)) )->ServerLast);
  9962. d607 13
  9963. a619 4
  9964.     /* Now ask for the subject headers */
  9965.     mylen = sprintf(mybuf,"XHDR subject %ld-%ld\r",first,last); 
  9966.     PutCommLine(mybuf,mylen);
  9967.     CommState = ST_XHDR_RESP; 
  9968. d621 1
  9969. d623 2
  9970. d626 7
  9971. a632 2
  9972.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  9973.     header_handle = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->header_handle;
  9974. d636 1
  9975. a636 1
  9976.     headers = (TypHeader huge *)(GlobalLock (header_handle) + sizeof (char huge *));
  9977. d638 2
  9978. a639 1
  9979.     sscanf (CommLineIn, "%ld %Fd", &artnum, &(headers[CommDoc->ActiveLines].lines));
  9980. d641 1
  9981. a641 1
  9982.     GlobalUnlock (header_handle);
  9983. d660 62
  9984. a721 4
  9985.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  9986.     (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->total_headers) = CommDoc->ActiveLines;
  9987.     first = (((TypGroup far *)
  9988.           ((char far *) LinePtr + sizeof(TypLine)) )->ServerFirst );
  9989. d723 4
  9990. a726 2
  9991.     last = (((TypGroup far *)
  9992.          ((char far *) LinePtr + sizeof(TypLine)) )->ServerLast );
  9993. d734 1
  9994. a734 1
  9995.     CommState = ST_XHDR_RESP;
  9996. d738 8
  9997. a745 2
  9998.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  9999.     header_handle = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->header_handle;
  10000. d749 1
  10001. a749 1
  10002.     headers = (TypHeader huge *)(GlobalLock (header_handle) + sizeof (char huge *));
  10003. d751 1
  10004. a751 1
  10005.     mylstrncpy(headers[CommDoc->ActiveLines].references,
  10006. d755 2
  10007. a756 1
  10008.     GlobalUnlock (header_handle);
  10009. d766 2
  10010. a767 1
  10011.     case ST_XHDR_RESP:
  10012. d771 1
  10013. a771 1
  10014.       CommState = ST_XHDR_SUBJ;
  10015. d774 1
  10016. a774 1
  10017.     case ST_XHDR_SUBJ:
  10018. d787 13
  10019. a799 1
  10020.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10021. d802 1
  10022. d818 5
  10023. a822 6
  10024.       header_handle =
  10025.         ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )
  10026.           ->header_handle;
  10027.       headers = (TypHeader huge *) (GlobalLock (header_handle) +
  10028.                     sizeof(char huge *)) ;
  10029.  
  10030. d824 1
  10031. a824 1
  10032.            ((headers[i].Seen == FALSE) && (i > 0));
  10033. d827 2
  10034. d837 2
  10035. a838 1
  10036.       LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10037. d840 4
  10038. a843 3
  10039.       /* inside the lock, can access the GroupStruct */
  10040.       header_handle = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->header_handle;
  10041.       headers = (TypHeader huge *) (GlobalLock (header_handle) + sizeof(char huge *)) ;
  10042. d847 7
  10043. a853 4
  10044.       headers[CommDoc->ActiveLines].Selected= FALSE ;
  10045.       headers[CommDoc->ActiveLines].ArtDoc  = (TypDoc *) NULL;
  10046.       headers[CommDoc->ActiveLines].Seen =
  10047.         WasArtSeen (artnum,(TypGroup far *)( ((char far *)LinePtr) + sizeof(TypLine) ) );
  10048. d855 2
  10049. a856 1
  10050.       UnlockLine(BlockPtr,LinePtr,&(CommDoc->hParentBlock),&(CommDoc->ParentOffset),&(CommDoc->ParentLineID));
  10051. d858 1
  10052. a858 1
  10053.       mylstrcpy(headers[CommDoc->ActiveLines].subject,
  10054. d861 2
  10055. a862 2
  10056.       GlobalUnlock (header_handle);
  10057.  
  10058. d896 1
  10059. a896 1
  10060.     headers = (TypHeader huge *) (GlobalLock (header_handle) + sizeof(char huge *)) ;
  10061. d898 3
  10062. a900 1
  10063.     lpsz = (char far *) headers[CommDoc->LastSeenLineID].subject;
  10064. a901 1
  10065.     GlobalUnlock (header_handle);
  10066. d1197 1
  10067. a1197 1
  10068. char huge *ptr1;
  10069. @
  10070.  
  10071.  
  10072.  
  10073. 1.11
  10074. log
  10075. @date formatting for group list window
  10076. and save header size for article repaing (MRB)
  10077. @
  10078. text
  10079. @d3 1
  10080. a3 1
  10081.  * $Id: wvutil.c 1.10 1993/05/13 19:58:09 rushing Exp $
  10082. d5 3
  10083. d9 1
  10084. d707 5
  10085. d713 12
  10086. a724 1
  10087.     /* reinsert this code */
  10088. @
  10089.  
  10090.  
  10091.  
  10092. 1.10
  10093. log
  10094. @fancy 'from' in group window
  10095. @
  10096. text
  10097. @d3 1
  10098. a3 1
  10099.  * $Id: wvutil.c 1.9 1993/05/13 16:16:06 rushing Exp SOMEONE $
  10100. d5 4
  10101. d106 2
  10102. a107 1
  10103.  
  10104. d127 1
  10105. a127 1
  10106.  
  10107. d179 7
  10108. a185 1
  10109.   sprintf(s,"%s %2.2d",mon,dom);
  10110. d409 3
  10111. d504 1
  10112. d507 1
  10113. d509 8
  10114. d780 3
  10115. d784 13
  10116. d985 10
  10117. @
  10118.  
  10119.  
  10120.  
  10121. 1.9
  10122. log
  10123. @article fetch limit support
  10124. @
  10125. text
  10126. @d3 1
  10127. a3 1
  10128.  * $Id: wvutil.c 1.8 1993/05/08 17:11:05 rushing Exp rushing $
  10129. d5 3
  10130. d102 22
  10131. d410 1
  10132. a411 2
  10133.       CommDoc->TotalLines = estnum;
  10134.  
  10135. d476 1
  10136. d488 4
  10137. a491 2
  10138.     mylstrcpy(headers[CommDoc->ActiveLines].from,
  10139.           (char far *) get_xhdr_line (CommLineIn));
  10140. @
  10141.  
  10142.  
  10143.  
  10144. 1.8
  10145. log
  10146. @correct handling of 4XX response codes, and
  10147. of NNTP data lines beginning with '.'
  10148. @
  10149. text
  10150. @d3 1
  10151. a3 1
  10152.  * $Id: wvutil.c 1.7 1993/04/29 21:42:11 rushing Exp rushing $
  10153. d5 4
  10154. d365 21
  10155. d391 1
  10156. a391 1
  10157.       if (estnum > 0)
  10158. d393 7
  10159. a399 2
  10160.       header_handle = GlobalAlloc (GMEM_MOVEABLE, (long)((sizeof (TypHeader)) * (long)(estnum)) + sizeof (char huge *)); /* How risky is this? */
  10161.       (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->header_handle) = header_handle;
  10162. d402 2
  10163. a403 2
  10164.       // stick nulls and 0's, etc.. in case display code get mis-threaded
  10165.     initialize_header_array (header_handle, estnum);
  10166. d405 17
  10167. a421 15
  10168.       (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerEstNum) = estnum;
  10169.       (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerFirst ) = first;
  10170.       (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerLast  ) = last;
  10171.           GlobalUnlock(BlockPtr->hCurBlock);
  10172.  
  10173.             mylen = sprintf(mybuf,"XHDR from %ld-%ld\r",first,999999L);
  10174.             PutCommLine(mybuf,mylen);
  10175.             CommState = ST_XHDR_FROM_START;
  10176.  
  10177.             break;
  10178.  
  10179. // The next few cases handle retrieval of XHDR information for display
  10180. // in the group window.  If you change the number of XHDR's retrieved
  10181.   // (such as adding 'XHDR References' back into the state machine), you
  10182.     // need to reflect that change in the variable total_xhdrs.
  10183. d433 10
  10184. a442 3
  10185.     LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10186.     (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->total_headers) = CommDoc->ActiveLines;
  10187.     first = (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerFirst );
  10188. d447 1
  10189. a447 1
  10190.     mylen = sprintf(mybuf,"XHDR date %ld-%ld\r",first,999999L);
  10191. d492 3
  10192. d499 1
  10193. a499 1
  10194.     mylen = sprintf(mybuf,"XHDR lines %ld-%ld\r",first,999999L); 
  10195. d540 4
  10196. d548 1
  10197. a548 1
  10198.     mylen = sprintf(mybuf,"XHDR subject %ld-%ld\r",first,999999L); 
  10199. d584 6
  10200. a589 1
  10201.     first = (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerFirst );
  10202. d594 1
  10203. a594 1
  10204.     mylen = sprintf(mybuf,"XHDR subject %ld-%ld\r",first,999999L);
  10205. @
  10206.  
  10207.  
  10208.  
  10209. 1.7
  10210. log
  10211. @checked for null from parse_usenet_date on bad date.
  10212. @
  10213. text
  10214. @d3 1
  10215. a3 1
  10216.  * $Id: wvutil.c 1.6 1993/04/29 20:24:59 rushing Exp rushing $
  10217. d5 3
  10218. d222 12
  10219. a233 4
  10220.     MessageBox (hWndConf, "News Server No Longer Available", "WinVN", MB_OK | MB_ICONHAND);
  10221.     MRRCloseComm ();
  10222.     PostQuitMessage (0);
  10223.     return (1);
  10224. d709 10
  10225. a718 2
  10226.     for(col=0,cptr=CommLineIn; *cptr &&
  10227.         col<(MAXINTERNALLINE-3*sizeof(TypLine)-sizeof(TypText)); cptr++) {
  10228. @
  10229.  
  10230.  
  10231.  
  10232. 1.6
  10233. log
  10234. @attempted support for WSAAsyncSelect
  10235. @
  10236. text
  10237. @d3 1
  10238. a3 1
  10239.  * $Id: wvutil.c 1.5 1993/04/27 21:03:20 rushing Exp rushing $
  10240. d5 3
  10241. d242 24
  10242. a265 24
  10243.    TypLine far *LinePtr;
  10244.    TypBlock far *BlockPtr;
  10245.    HANDLE hBlock;
  10246.    HWND hWndPostEdit;
  10247.    unsigned int Offset;
  10248.    TypLineID MyLineID;
  10249.    int retcode;
  10250.    int ih, found;
  10251.    unsigned int estnum;
  10252.    long int first,last;
  10253.    unsigned int artnum;
  10254.    int mylen;
  10255.    int col;
  10256.    int mbcode;
  10257.    BOOL done=FALSE;
  10258.    BOOL dolist;
  10259.    static char group[MAXINTERNALLINE];
  10260.    char mybuf[MAXINTERNALLINE];
  10261.    char artline[MAXINTERNALLINE];
  10262.    char *cptr, *cdest;
  10263.    char far *lpsz;
  10264.    HANDLE header_handle;
  10265.    TypHeader huge * headers;
  10266.    TypGroup far * GroupDoc;
  10267. d267 1
  10268. a267 1
  10269.    if(CommDoc) {
  10270. d269 19
  10271. a287 3
  10272.       switch(CommState) {
  10273.          case ST_NONE:
  10274.             break;
  10275. d289 6
  10276. a294 22
  10277.          case ST_ESTABLISH_COMM:
  10278.             retcode = 0;
  10279.             sscanf(CommLineIn,"%u",&retcode);
  10280.             if(retcode == 200 || retcode == 201) {/* was 500 from induced error */
  10281.                dolist = DoList;
  10282.                if(dolist == ID_DOLIST_ASK-ID_DOLIST_BASE) {
  10283.                   dolist = DialogBox(hInst,"WinVnDoList",hWndConf,lpfnWinVnDoListDlg);
  10284.                }
  10285.                if(dolist) {
  10286.                   StartList();
  10287.                } else {
  10288.                   CommState = ST_NONE;
  10289.                   CommBusy = FALSE;
  10290.                   Initializing = INIT_DONE;
  10291.                }
  10292.  
  10293.                InvalidateRect(hWndConf,NULL,FALSE);
  10294.             }
  10295.         else {
  10296.               MRRCloseComm ();
  10297.               PostQuitMessage (0);
  10298.         }
  10299. d296 1
  10300. a296 1
  10301.             break;
  10302. d298 7
  10303. a304 7
  10304.          case ST_LIST_RESP:
  10305.             retcode = 0;
  10306.             sscanf(CommLineIn,"%u",&retcode);
  10307.             if(retcode != 215) {
  10308.           check_server_code (retcode);
  10309.               break;
  10310.             }
  10311. d306 10
  10312. a315 3
  10313.             CommState = ST_LIST_GROUPLINE;
  10314.             RcvLineCount = 0;
  10315.             break;
  10316. d317 5
  10317. a321 12
  10318.          case ST_LIST_GROUPLINE:
  10319.             if(strcmp(CommLineIn,".") == 0) {
  10320.                CommState = ST_NONE;
  10321.                CommBusy = FALSE;
  10322.                Initializing = INIT_DONE;
  10323.                InvalidateRect(hWndConf,NULL,FALSE);
  10324.  
  10325.                ProcEndList();
  10326.             } else {
  10327.                ProcListLine((unsigned char *)CommLineIn);
  10328.             }
  10329.             break;
  10330. d323 24
  10331. a346 24
  10332.          case ST_GROUP_RESP:
  10333.             retcode = 0;
  10334.         sscanf(CommLineIn,"%u",&retcode);
  10335.         switch (retcode) {
  10336.         case 411:
  10337.           MessageBox (hWndConf, "No Such Newsgroup", "Error", MB_OK | MB_ICONHAND);
  10338.           /* abort the fledgling group window */
  10339.           DestroyWindow (CommDoc->hDocWnd);
  10340.           CommBusy = FALSE;
  10341.           CommState = ST_NONE;
  10342.           return;
  10343.           break;
  10344.         case 502:
  10345.           MessageBox (hWndConf, "Restricted Access", "WinVN", MB_OK | MB_ICONHAND);
  10346.           /* abort the fledgling group window */
  10347.           DestroyWindow (CommDoc->hDocWnd);
  10348.           CommBusy = FALSE;
  10349.           CommState = ST_NONE;
  10350.           return;
  10351.           break;
  10352.         default:
  10353.           if (check_server_code(retcode)) return;
  10354.           break;
  10355.         }
  10356. d348 3
  10357. a350 3
  10358.             sscanf(CommLineIn,"%u %u %ld %ld %s",
  10359.            &retcode,&estnum,&first,&last,group);
  10360.         CommDoc->TotalLines = estnum;
  10361. d352 2
  10362. a353 2
  10363.           LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,
  10364.          CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10365. d355 1
  10366. a355 1
  10367.           if (estnum > 0)
  10368. d357 2
  10369. a358 2
  10370.           header_handle = GlobalAlloc (GMEM_MOVEABLE, (long)((sizeof (TypHeader)) * (long)(estnum)) + sizeof (char huge *));  /* How risky is this? */
  10371.         (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->header_handle) = header_handle;
  10372. d361 1
  10373. a361 1
  10374.     // stick nulls and 0's, etc.. in case display code get mis-threaded
  10375. d377 218
  10376. a594 2
  10377. // (such as adding 'XHDR References' back into the state machine), you
  10378. // need to reflect that change in the variable total_xhdrs.
  10379. d596 96
  10380. a691 179
  10381.           case ST_XHDR_FROM_START:
  10382.             retcode = 0;
  10383.             sscanf(CommLineIn,"%d",&retcode);
  10384.             if(retcode < 100) break;
  10385.             CommState = ST_XHDR_FROM_DATA;
  10386.         CommDoc->ActiveLines = 0;
  10387.         break;
  10388.  
  10389.     case ST_XHDR_FROM_DATA:
  10390.             if(strcmp(CommLineIn,".") == 0) {
  10391.                    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10392.                 (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->total_headers) = CommDoc->ActiveLines;
  10393.         first = (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerFirst );
  10394.                 GlobalUnlock(BlockPtr->hCurBlock);
  10395.         CommDoc->ActiveLines = 0;
  10396.  
  10397.         /* Now ask for the date lines */
  10398.                 mylen = sprintf(mybuf,"XHDR date %ld-%ld\r",first,999999L);
  10399.                 PutCommLine(mybuf,mylen);
  10400.                 CommState = ST_XHDR_DATE_START;
  10401.             }
  10402.             else {
  10403.         /* Access the Group struct, get HANDLE for header data */
  10404.                    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10405.                 header_handle = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->header_handle;
  10406.                 GlobalUnlock(BlockPtr->hCurBlock);
  10407.  
  10408.         /* Lock the header data */
  10409.                 headers = (TypHeader huge *) (GlobalLock (header_handle) + sizeof(char huge *));
  10410.  
  10411.         sscanf (CommLineIn, "%ld", &artnum);
  10412.                 headers[CommDoc->ActiveLines].number = artnum;
  10413.  
  10414.                 mylstrcpy(headers[CommDoc->ActiveLines].from,
  10415.                           (char far *) get_xhdr_line (CommLineIn));
  10416.  
  10417.         GlobalUnlock (header_handle);
  10418.                 CommDoc->ActiveLines++;
  10419.  
  10420.         update_window_title (CommDoc->hDocWnd, group,
  10421.                                      RcvLineCount++,
  10422.                      CommDoc->TotalLines * total_xhdrs);
  10423.             }
  10424.  
  10425.         break;
  10426.  
  10427.           case ST_XHDR_DATE_START:
  10428.             retcode = 0;
  10429.             sscanf(CommLineIn,"%d",&retcode);
  10430.             if (check_server_code(retcode)) break;
  10431.             CommState = ST_XHDR_DATE_DATA;
  10432.         CommDoc->ActiveLines = 0;
  10433.         break;
  10434.  
  10435.     case ST_XHDR_DATE_DATA:
  10436.             if(strcmp(CommLineIn,".") == 0) {
  10437.                    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10438.                 (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->total_headers) = CommDoc->ActiveLines;
  10439.         first = (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerFirst );
  10440.                 GlobalUnlock(BlockPtr->hCurBlock);
  10441.         CommDoc->ActiveLines = 0;
  10442.  
  10443.         /* Now ask for the #of lines */
  10444.                 mylen = sprintf(mybuf,"XHDR lines %ld-%ld\r",first,999999L); 
  10445.                 PutCommLine(mybuf,mylen);
  10446.                 CommState = ST_XHDR_LINES_START; 
  10447.             }
  10448.             else {
  10449.         /* Access the Group struct, get HANDLE for header data */
  10450.                    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10451.                 header_handle = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->header_handle;
  10452.                 GlobalUnlock(BlockPtr->hCurBlock);
  10453.  
  10454.         /* Lock the header data */
  10455.                 headers = (TypHeader huge *)(GlobalLock (header_handle) + sizeof (char huge *));
  10456.  
  10457.                 mylstrcpy(headers[CommDoc->ActiveLines].date,
  10458.                           (char far *) (parse_usenet_date (get_xhdr_line (CommLineIn))));
  10459.  
  10460.         GlobalUnlock (header_handle);
  10461.                 CommDoc->ActiveLines++;
  10462.         update_window_title (CommDoc->hDocWnd, group,
  10463.                                      RcvLineCount++,
  10464.                      CommDoc->TotalLines * total_xhdrs);
  10465.             }
  10466.  
  10467.         break;
  10468.  
  10469.           case ST_XHDR_LINES_START:
  10470.             retcode = 0;
  10471.             sscanf(CommLineIn,"%d",&retcode);
  10472.             if (check_server_code(retcode)) break;
  10473.             CommState = ST_XHDR_LINES_DATA;
  10474.         CommDoc->ActiveLines = 0;
  10475.         break;
  10476.  
  10477.     case ST_XHDR_LINES_DATA:
  10478.             if(strcmp(CommLineIn,".") == 0) {
  10479.                    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10480.                 (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->total_headers) = CommDoc->ActiveLines;
  10481.         first = (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerFirst );
  10482.                 GlobalUnlock(BlockPtr->hCurBlock);
  10483.         CommDoc->ActiveLines = 0;
  10484.  
  10485.         /* Now ask for the subject headers */
  10486.                 mylen = sprintf(mybuf,"XHDR subject %ld-%ld\r",first,999999L); 
  10487.                 PutCommLine(mybuf,mylen);
  10488.                 CommState = ST_XHDR_RESP; 
  10489.             }
  10490.             else {
  10491.         /* Access the Group struct, get HANDLE for header data */
  10492.                    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10493.                 header_handle = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->header_handle;
  10494.                 GlobalUnlock(BlockPtr->hCurBlock);
  10495.  
  10496.         /* Lock the header data */
  10497.                 headers = (TypHeader huge *)(GlobalLock (header_handle) + sizeof (char huge *));
  10498.  
  10499.         sscanf (CommLineIn, "%ld %Fd", &artnum, &(headers[CommDoc->ActiveLines].lines));
  10500.  
  10501.         GlobalUnlock (header_handle);
  10502.                 CommDoc->ActiveLines++;
  10503.         update_window_title (CommDoc->hDocWnd, group,
  10504.                                      RcvLineCount++,
  10505.                      CommDoc->TotalLines * total_xhdrs);
  10506.             }
  10507.  
  10508.         break;
  10509.  
  10510.           case ST_XHDR_REF_START:
  10511.             retcode = 0;
  10512.             sscanf(CommLineIn,"%d",&retcode);
  10513.             if (check_server_code(retcode)) break;
  10514.             CommState = ST_XHDR_REF_DATA;
  10515.         CommDoc->ActiveLines = 0;
  10516.         break;
  10517.  
  10518.     case ST_XHDR_REF_DATA:
  10519.             if(strcmp(CommLineIn,".") == 0) {
  10520.                    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10521.                 (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->total_headers) = CommDoc->ActiveLines;
  10522.         first = (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerFirst );
  10523.                 GlobalUnlock(BlockPtr->hCurBlock);
  10524.         CommDoc->ActiveLines = 0;
  10525.  
  10526.         /* Now ask for the subject lines */
  10527.                 mylen = sprintf(mybuf,"XHDR subject %ld-%ld\r",first,999999L);
  10528.                 PutCommLine(mybuf,mylen);
  10529.                 CommState = ST_XHDR_RESP;
  10530.             }
  10531.             else {
  10532.         /* Access the Group struct, get HANDLE for header data */
  10533.                    LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10534.                 header_handle = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->header_handle;
  10535.                 GlobalUnlock(BlockPtr->hCurBlock);
  10536.  
  10537.         /* Lock the header data */
  10538.                 headers = (TypHeader huge *)(GlobalLock (header_handle) + sizeof (char huge *));
  10539.  
  10540.                 mylstrncpy(headers[CommDoc->ActiveLines].references,
  10541.                           (char far *) (get_xhdr_line (CommLineIn)),
  10542.                            30);        /* bad, hardcoded. */
  10543.  
  10544.         GlobalUnlock (header_handle);
  10545.                 CommDoc->ActiveLines++;
  10546.         update_window_title (CommDoc->hDocWnd, group,
  10547.                                      RcvLineCount++,
  10548.                      CommDoc->TotalLines * total_xhdrs);
  10549.  
  10550.             }
  10551.  
  10552.         break;
  10553.  
  10554.          case ST_XHDR_RESP:
  10555.             retcode = 0;
  10556.             sscanf(CommLineIn,"%d",&retcode);
  10557.             if (check_server_code(retcode)) break;
  10558.             CommState = ST_XHDR_SUBJ;
  10559.             break;
  10560. d693 33
  10561. a725 57
  10562.          case ST_XHDR_SUBJ:
  10563.             if(strcmp(CommLineIn,".") == 0) {
  10564.                CommState = ST_IN_GROUP;
  10565.                CommBusy = FALSE;
  10566.  
  10567.         /* release the mouse that is captured to the usenet window */
  10568.         ReleaseCapture ();
  10569.  
  10570.         CommDoc->TotalLines = CommDoc->ActiveLines;
  10571.         CommDoc->ActiveLines = 0;
  10572.                /* Fetch this group's line in NetDoc so we can get the
  10573.                 * group's name for the window's title bar.
  10574.                 */
  10575.                LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10576.                lpsz = (char far *) ( ((char far *)LinePtr) +
  10577.                 sizeof(TypLine)+ sizeof(TypGroup) ) ;
  10578.                mylstrncpy(group,lpsz,MAXGROUPNAME);
  10579.                sprintf(mybuf,"%s (%u articles)",group,CommDoc->TotalLines);
  10580.                SetWindowText(CommDoc->hDocWnd,mybuf);
  10581.  
  10582.                /* If we have information from NEWSRC on the highest-
  10583.                 * numbered article previously seen, position the window
  10584.                 * so the new articles can be seen without scrolling.
  10585.                 */
  10586.  
  10587.                 /* reinsert this code */
  10588.  
  10589.                 InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);
  10590.             } else {
  10591.  
  10592.                artnum = 0;
  10593.                sscanf(CommLineIn,"%ld",&artnum);
  10594.                if(artnum) {
  10595.                 LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10596.  
  10597.         /* inside the lock, can access the GroupStruct */
  10598.                 header_handle = ((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->header_handle;
  10599.                    headers = (TypHeader huge *) (GlobalLock (header_handle) + sizeof(char huge *)) ;
  10600.  
  10601.         /* update the seen thing. */
  10602.  
  10603.                 headers[CommDoc->ActiveLines].Selected= FALSE ;
  10604.                 headers[CommDoc->ActiveLines].ArtDoc  = (TypDoc *) NULL;
  10605.         headers[CommDoc->ActiveLines].Seen =
  10606.            WasArtSeen (artnum,(TypGroup far *)( ((char far *)LinePtr) + sizeof(TypLine) ) );
  10607.  
  10608.                 UnlockLine(BlockPtr,LinePtr,&(CommDoc->hParentBlock),&(CommDoc->ParentOffset),&(CommDoc->ParentLineID));
  10609.  
  10610.                 mylstrcpy(headers[CommDoc->ActiveLines].subject,
  10611.                           get_xhdr_line (CommLineIn));
  10612.  
  10613.         GlobalUnlock (header_handle);
  10614.  
  10615.         CommDoc->ActiveLines++;
  10616.         update_window_title (CommDoc->hDocWnd, group,
  10617.                                      RcvLineCount++,
  10618.                      CommDoc->TotalLines * total_xhdrs);
  10619. d727 1
  10620. a727 2
  10621.                 }
  10622.             }
  10623. d729 3
  10624. a731 1
  10625.               break;
  10626. d733 1
  10627. a733 2
  10628.          case ST_IN_GROUP:
  10629.             break;
  10630. d735 6
  10631. a740 6
  10632.          case ST_ARTICLE_RESP:
  10633.             retcode = 0;
  10634.             sscanf(CommLineIn,"%d",&retcode);
  10635.             if (check_server_code(retcode)) break;
  10636.             CommState = ST_REC_ARTICLE;
  10637.             break;
  10638. d742 9
  10639. a750 87
  10640.          case ST_REC_ARTICLE:
  10641.             if(strcmp(CommLineIn,".") == 0) {
  10642.                CommState = ST_IN_GROUP;
  10643.                CommBusy = FALSE;
  10644.  
  10645.                 LockLine (CommDoc->ParentDoc->hParentBlock,
  10646.                           CommDoc->ParentDoc->ParentOffset,
  10647.                           CommDoc->ParentDoc->ParentLineID,
  10648.                           &BlockPtr, &LinePtr);
  10649.  
  10650.                 GroupDoc = (TypGroup far *) ((char far *) LinePtr + sizeof (TypLine));
  10651.  
  10652.                 header_handle = GroupDoc->header_handle;
  10653.                 headers = (TypHeader huge *) (GlobalLock (header_handle) + sizeof(char huge *)) ;
  10654.  
  10655.         lpsz = (char far *) headers[CommDoc->LastSeenLineID].subject;
  10656.  
  10657.         GlobalUnlock (header_handle);
  10658.                mylstrncpy(group,lpsz,MAXGROUPNAME);
  10659.                sprintf(mybuf,"%s (%u lines)",group,CommDoc->TotalLines);
  10660.                SetWindowText(CommDoc->hDocWnd,mybuf);
  10661.                InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);
  10662.                GlobalUnlock(BlockPtr->hCurBlock);
  10663.  
  10664.                /* Skip to the first line of the text of the article
  10665.                 * and make sure it's visible on the screen.  This is
  10666.                 * so that the user doesn't have to have the first
  10667.                 * screen filled with a lengthy, worthless header.
  10668.                 */
  10669.                if(CommDoc->TotalLines > CommDoc->ScYLines
  10670.                  && !CommDoc->TopScLineID) {
  10671.                   TopOfDoc(CommDoc,&BlockPtr,&LinePtr);
  10672.                   found = FALSE;
  10673.                   do {
  10674.                      lpsz = ((char far *)LinePtr + sizeof(TypLine) + sizeof(TypText));
  10675.                      if(IsLineBlank(lpsz)) {
  10676.                         found = TRUE;
  10677.                         break;
  10678.                      }
  10679.                      if(!NextLine(&BlockPtr,&LinePtr)) break;
  10680.                   } while(!found);
  10681.                   NextLine(&BlockPtr,&LinePtr);
  10682.  
  10683.                   /* If the line is in the last screen's worth of lines, back
  10684.                    * up the pointer so it points to the first line of the last
  10685.                    * screen.
  10686.                    */
  10687.                   if(found) {
  10688.                      AdjustTopSc(BlockPtr,LinePtr);
  10689.                   } else {
  10690.                      UnlockLine(BlockPtr,LinePtr,&hBlock,&Offset,&MyLineID);
  10691.                   }
  10692.                }
  10693.  
  10694.             } else {
  10695.                /* Copy this line into an image of a textblock line,
  10696.                 * expanding tabs.
  10697.                 */
  10698.                cdest = artline+sizeof(TypLine)+sizeof(TypText);
  10699.                for(col=0,cptr=CommLineIn; *cptr &&
  10700.                 col<(MAXINTERNALLINE-3*sizeof(TypLine)-sizeof(TypText)); cptr++) {
  10701.                   if(*cptr == '\t') {
  10702.                      do {
  10703.                         *(cdest++) = ' ';
  10704.                      } while (++col & 7);
  10705.                   } else {
  10706.                      *(cdest++) = *cptr;
  10707.                      col++;
  10708.                   }
  10709.                }
  10710.                *(cdest++) = '\0';
  10711.  
  10712.                mylen = (cdest-artline) + sizeof(int);
  10713.                mylen += mylen%2;
  10714.                ((TypText *)(artline+sizeof(TypLine)))->NameLen =
  10715.                 (cdest-1) - (artline+sizeof(TypLine)+sizeof(TypText));
  10716.                ((TypLine *)artline)->length = mylen;
  10717.                ((TypLine *)artline)->LineID = NextLineID++;
  10718.                *( (int *) (artline+mylen-sizeof(int)) ) = mylen;
  10719.                LockLine(CommDoc->hCurAddBlock,CommDoc->AddOffset,CommDoc->AddLineID,&BlockPtr,&LinePtr);
  10720.                AddLine((TypLine *)artline,&BlockPtr,&LinePtr);
  10721.                UnlockLine(BlockPtr,LinePtr,&(CommDoc->hCurAddBlock),
  10722.                 &(CommDoc->AddOffset),&(CommDoc->AddLineID));
  10723.                if((CommDoc->TotalLines % UPDATE_ART_FREQ) == 0) {
  10724.             InvalidateRect(CommDoc->hDocWnd,NULL,FALSE);  
  10725.                }
  10726.             }
  10727. d752 1
  10728. a752 1
  10729.             break;
  10730. d754 3
  10731. a756 22
  10732.          case ST_POST_WAIT_PERMISSION:
  10733.             for(ih=0,found=FALSE; !found && ih<MAXPOSTWNDS; ih++) {
  10734.               if(&(PostingDocs[ih]) == CommDoc) {
  10735.  
  10736.                  hWndPostEdit = hWndPostEdits[ih];
  10737.  
  10738.                  found = TRUE;
  10739.                  break;
  10740.               }
  10741.             }
  10742.             retcode = 0;
  10743.             sscanf(CommLineIn,"%u",&retcode);
  10744.  
  10745.             if(retcode == 340) {
  10746.                PostText(ih,DOCTYPE_POSTING);
  10747.             } else {
  10748.            check_server_code (retcode);
  10749.                MessageBox(hWndPostEdit,CommLineIn+4,"Cannot Post Article",
  10750.                   MB_OK|MB_ICONEXCLAMATION);
  10751.                CommBusy = FALSE;
  10752.                CommState = ST_NONE;
  10753.             }
  10754. d758 1
  10755. a758 1
  10756.             break;
  10757. d760 23
  10758. a782 29
  10759.          case ST_POST_WAIT_END:
  10760.             for(ih=0,found=FALSE; !found && ih<MAXPOSTWNDS; ih++) {
  10761.               if(&(PostingDocs[ih]) == CommDoc) {
  10762.  
  10763.                  hWndPostEdit = hWndPostEdits[ih];
  10764.  
  10765.                  found = TRUE;
  10766.                  break;
  10767.               }
  10768.             }
  10769.             retcode = 0;
  10770.             sscanf(CommLineIn,"%d",&retcode);
  10771.             if(retcode == 441 || retcode == 440) {
  10772.                cptr = "Posting Failed";
  10773.                mbcode = MB_OK|MB_ICONEXCLAMATION;
  10774.                done = TRUE;
  10775.             } else if(retcode == 240) {
  10776.                cptr = "Article Posted OK";
  10777.                mbcode = MB_OK;
  10778.                done = TRUE;
  10779.             } else
  10780.                if (check_server_code (retcode)) break;
  10781.  
  10782.             if(done) {
  10783.                CommBusy = FALSE;
  10784.                CommState = ST_NONE;
  10785.                MessageBox(hWndPostEdit,CommLineIn+4,cptr,mbcode);
  10786.             }
  10787.             break;
  10788. d784 1
  10789. a784 1
  10790. /* the following code is for an MRR-hacked nntp server */
  10791. d787 24
  10792. a810 22
  10793.          case ST_MAIL_WAIT_PERMISSION:
  10794.             for(ih=0,found=FALSE; !found && ih<MAXMAILWNDS; ih++) {
  10795.               if(&(MailDocs[ih]) == CommDoc) {
  10796.  
  10797.                  hWndPostEdit = hWndMailEdits[ih];
  10798.  
  10799.                  found = TRUE;
  10800.                  break;
  10801.               }
  10802.             }
  10803.             retcode = 0;
  10804.             sscanf(CommLineIn,"%d",&retcode);
  10805.             if(retcode <= 0) {
  10806.                break;
  10807.             } else if(retcode == 350) {
  10808.                PostText(ih,DOCTYPE_MAIL);
  10809.             } else {
  10810.                MessageBox(hWndPostEdit,CommLineIn+4,"Cannot Mail Message",
  10811.                   MB_OK|MB_ICONEXCLAMATION);
  10812.                CommBusy = FALSE;
  10813.                CommState = ST_NONE;
  10814.             }
  10815. d812 5
  10816. a816 1
  10817.             break;
  10818. d818 21
  10819. a838 27
  10820.          case ST_MAIL_WAIT_END:
  10821.             for(ih=0,found=FALSE; !found && ih<MAXMAILWNDS; ih++) {
  10822.               if(&(MailDocs[ih]) == CommDoc) {
  10823.  
  10824.                  hWndPostEdit = hWndMailEdits[ih];
  10825.  
  10826.                  found = TRUE;
  10827.                  break;
  10828.               }
  10829.             }
  10830.             retcode = 0;
  10831.             sscanf(CommLineIn,"%d",&retcode);
  10832.             if(retcode == 451 || retcode == 450) {
  10833.                cptr = "Mailing Failed";
  10834.                mbcode = MB_OK|MB_ICONEXCLAMATION;
  10835.                done = TRUE;
  10836.             } else if(retcode == 250) {
  10837.                cptr = "Message sent OK";
  10838.                mbcode = MB_OK;
  10839.                done = TRUE;
  10840.             }
  10841.             if(done) {
  10842.                CommBusy = FALSE;
  10843.                CommState = ST_NONE;
  10844.                MessageBox(hWndPostEdit,CommLineIn+4,cptr,mbcode);
  10845.             }
  10846.             break;
  10847. d842 5
  10848. a846 5
  10849.       case ST_GROUP_REJOIN:
  10850.          CommState = ST_ARTICLE_RESP;
  10851.          break;
  10852.       }
  10853.    }
  10854. @
  10855.  
  10856.  
  10857.  
  10858. 1.5
  10859. log
  10860. @clicking on a group that doesn't exist is correctly handled.
  10861. the prematurely created group window is destroyed correctly
  10862. after telling the user it doesn't exist.
  10863. @
  10864. text
  10865. @d3 1
  10866. a3 1
  10867.  * $Id: wvutil.c 1.4 1993/04/23 22:10:48 rushing Exp rushing $
  10868. d5 5
  10869. d153 1
  10870. a153 2
  10871.    while(    (CommState != ST_NONE)
  10872.           && ((ch = MRRReadComm()) >= 0)) {
  10873. d209 12
  10874. a220 12
  10875.     case 5:
  10876.       MessageBox (hWndConf, "News Server Error", "WinVN", MB_OK | MB_ICONHAND);
  10877.       CommBusy = FALSE;
  10878.       CommState = ST_NONE;
  10879.       return (1);
  10880.       break;
  10881.     case 4:
  10882.       MessageBox (hWndConf, "News Server No Longer Available", "WinVN", MB_OK | MB_ICONHAND);
  10883.       MRRCloseComm ();
  10884.       PostQuitMessage (0);
  10885.       return (1);
  10886.       break;
  10887. @
  10888.  
  10889.  
  10890.  
  10891. 1.4
  10892. log
  10893. @added function check_server_code and used it
  10894. to watch for server and other errors, rather
  10895. than just ignoring and crashing 8^)
  10896. @
  10897. text
  10898. @d3 1
  10899. a3 1
  10900.  * $Id: wvutil.c 1.3 1993/02/18 20:34:16 rushing Exp rushing $
  10901. d5 5
  10902. d320 19
  10903. a338 14
  10904.               case 411:
  10905.             MessageBox (hWndConf, "No Such Newsgroup", "Error", MB_OK | MB_ICONHAND);
  10906.             CommBusy = FALSE;
  10907.             CommState = ST_NONE;
  10908.         break;
  10909.           case 502:
  10910.             MessageBox (hWndConf, "Restricted Access", "WinVN", MB_OK | MB_ICONHAND);
  10911.             CommBusy = FALSE;
  10912.             CommState = ST_NONE;
  10913.             return;
  10914.         break;
  10915.               default:
  10916.                 if (check_server_code(retcode)) return;
  10917.             break;
  10918. d341 2
  10919. a342 1
  10920.             sscanf(CommLineIn,"%u %u %ld %ld %s",&retcode,&estnum,&first,&last,group);
  10921. d345 2
  10922. a346 1
  10923.           LockLine(CommDoc->hParentBlock,CommDoc->ParentOffset,CommDoc->ParentLineID,&BlockPtr,&LinePtr);
  10924. @
  10925.  
  10926.  
  10927.  
  10928. 1.3
  10929. log
  10930. @set CommState to ST_NONE after closing connection.
  10931. @
  10932. text
  10933. @d3 5
  10934. a7 2
  10935.  * $Id: wvutil.c%v 1.2 1993/02/16 21:20:28 rushing Exp DUMOULIN $
  10936.  * $Log: wvutil.c%v $
  10937. d196 21
  10938. d280 2
  10939. a281 3
  10940.             MessageBox (hWndConf, CommLineIn, "Error", MB_OK | MB_ICONHAND);
  10941.         MRRCloseComm ();
  10942.         PostQuitMessage (0);
  10943. d288 6
  10944. a293 2
  10945.             sscanf(CommLineIn,"%d",&retcode);
  10946.             if(retcode != 215) break;
  10947. d313 3
  10948. a315 3
  10949.             sscanf(CommLineIn,"%u %u %ld %ld %s",&retcode,&estnum,&first,&last,group);
  10950.         CommDoc->TotalLines = estnum;
  10951.         if (retcode == 415) {
  10952. d320 9
  10953. d330 3
  10954. a332 1
  10955.             if(retcode < 100) break;
  10956. d410 1
  10957. a410 1
  10958.             if(retcode < 100) break;
  10959. d452 1
  10960. a452 1
  10961.             if(retcode < 100) break;
  10962. d493 1
  10963. a493 1
  10964.             if(retcode < 100) break;
  10965. d537 1
  10966. a537 1
  10967.             if(retcode < 100) break;
  10968. d610 1
  10969. a610 1
  10970.             if(retcode < 100) break;
  10971. d715 3
  10972. a717 4
  10973.             sscanf(CommLineIn,"%d",&retcode);
  10974.             if(retcode <= 0) {
  10975.                break;
  10976.             } else if(retcode == 340) {
  10977. d720 1
  10978. d749 3
  10979. a751 1
  10980.             }
  10981. d759 3
  10982. d814 2
  10983. @
  10984.  
  10985.  
  10986.  
  10987. 1.2
  10988. log
  10989. @Added a function (initialize_header_array) to ensure
  10990. valid data in the header array in case a WM_PAINT gets
  10991. sent to the group window before the retrieval is finished.
  10992. @
  10993. text
  10994. @d3 1
  10995. a3 1
  10996.  * $Id: wvutil.c%v 1.1 1993/02/16 20:54:22 rushing Exp rushing $
  10997. d5 5
  10998. d140 2
  10999. a141 2
  11000.    while((ch = MRRReadComm()) >= 0) {
  11001.       /*   putchar(ch); */  /* debug */
  11002. @
  11003.  
  11004.  
  11005.  
  11006. 1.1
  11007. log
  11008. @Initial revision
  11009. @
  11010. text
  11011. @d3 4
  11012. a6 2
  11013.  * $Id$
  11014.  * $Log$
  11015. d8 1
  11016. d164 23
  11017. d299 7
  11018. a305 4
  11019.             (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerEstNum) = estnum;
  11020.             (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerFirst ) = first;
  11021.             (((TypGroup far *) ((char far *) LinePtr + sizeof(TypLine)) )->ServerLast  ) = last;
  11022.             GlobalUnlock(BlockPtr->hCurBlock);
  11023. @
  11024.  
  11025.