home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / vmsnet / sources / 365 < prev    next >
Encoding:
Internet Message Format  |  1992-09-11  |  47.7 KB

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!usc!news.service.uci.edu!unogate!mvb.saic.com!vmsnet-sources
  2. From: munroe@dmc.com (Dick Munroe)
  3. Newsgroups: vmsnet.sources
  4. Subject: MAIL-TO-NOTES, part 01/02
  5. Message-ID: <8145897@MVB.SAIC.COM>
  6. Date: Fri, 11 Sep 1992 20:25:34 GMT
  7. Organization: Doyle, Munroe Consultants, Inc., Hudson, MA
  8. Lines: 1697
  9. Approved: Mark.Berryman@Mvb.Saic.Com
  10.  
  11. Submitted-by: munroe@dmc.com (Dick Munroe)
  12. Posting-number: Volume 3, Issue 170
  13. Archive-name: mail_to_vaxnotes/part01
  14.  
  15. The MAILTONOTES program takes a mail file, complete with headers, and
  16. adds it to a VAXNOTES conference.  Most mail headers are stripped out.
  17. The subject of the mail message is used to keep messages together --
  18. messages with the same subject (with leading "re:" stripped off) will
  19. be kept under the same topic.
  20. -- 
  21. Dick Munroe                Internet: munroe@dmc.com
  22. Doyle Munroe Consultants, Inc.        UUCP: ...uunet!thehulk!munroe
  23. 267 Cox St.                Office: (508) 568-1618
  24. Hudson, Ma.                FAX: (508) 562-1133
  25.  
  26. GET CONNECTED!!! Send mail to info@dmc.com to find out about DMConnection.
  27.  
  28. $! ------------------ CUT HERE -----------------------
  29. $ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
  30. $!
  31. $! This archive created by VMS_SHARE Version 7.2-010  25-Jun-1992
  32. $!   On  5-SEP-1992 08:02:19.52   By user MUNROE 
  33. $!
  34. $! This VMS_SHARE Written by:
  35. $!    Andy Harper, Kings College London UK
  36. $!
  37. $! Acknowledgements to:
  38. $!    James Gray       - Original VMS_SHARE
  39. $!    Michael Bednarek - Original Concept and implementation
  40. $!
  41. $!+ THIS PACKAGE DISTRIBUTED IN 2 PARTS, TO KEEP EACH PART
  42. $!  BELOW 100 BLOCKS
  43. $!
  44. $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
  45. $! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
  46. $!
  47. $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
  48. $!       1. 00README.TXT;6
  49. $!       2. DELIVERTONOTES.COM;14
  50. $!       3. ENVELOPE.COM;10
  51. $!       4. MAIL.DELIVERY;14
  52. $!       5. MAILTONOTES.C;1
  53. $!       6. MAILTONOTES.OPT;2
  54. $!       7. MAKESUBJECTS.COM;3
  55. $!       8. NOTEDIR.C;72
  56. $!       9. NOTEDIR.OPT;2
  57. $!      10. NOTES.FDL;6
  58. $!      11. NOTESCODES.H;1
  59. $!
  60. $set="set"
  61. $set symbol/scope=(nolocal,noglobal)
  62. $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
  63. $e="write sys$error  ""%UNPACK"", "
  64. $w="write sys$output ""%UNPACK"", "
  65. $ if f$trnlnm("SHARE_LOG") then $ w = "!"
  66. $ ve=f$getsyi("version")
  67. $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
  68. $ e "-E-OLDVER, Must run at least VMS 4.4"
  69. $ v=f$verify(v)
  70. $ exit 44
  71. $UNPACK: SUBROUTINE ! P1=filename, P2=checksum
  72. $ x = P1 - f$parse(P1,,,"version")
  73. $ y = f$search(x)
  74. $ if y .eqs. "" then $ goto file_absent
  75. $ x = f$integer(f$parse(P1,,,"version")-";")
  76. $ y = f$integer(f$parse(y,,,"version")-";")
  77. $ if x .gt. y then $ goto file_absent
  78. $ if f$mode() .eqs. "INTERACTIVE" then $ goto file_interactive
  79. $ if x .eq. y then e "-W-EXISTS, File ''P1' exists. Skipped."
  80. $ if x .ne. y then e "-W-NEWERVERSION, of File ''P1' exists. Skipped."
  81. $file_delete:
  82. $ delete 'f'*
  83. $ exit
  84. $file_interactive:
  85. $ if x .eq. y then e "-W-EXISTS, File ''P1' exists."
  86. $ if x .ne. y then e "-W-NEWERVERSION, of File ''P1' exists."
  87. $ read/error=file_delete/end=file_delete-
  88.   /prompt="Create new version [y/n]: " -
  89.   sys$command x
  90. $ if .not. x then $ e "-W-SKIPPED, File ''P1' skipped."
  91. $ if .not. x then $ goto file_delete
  92. $ P1 = P1 - f$parse(P1,,,"version")
  93. $file_absent:
  94. $ if f$parse(P1) .nes. "" then $ goto dirok
  95. $ dn=f$parse(P1,,,"DIRECTORY")
  96. $ w "-I-CREDIR, Creating directory ''dn'."
  97. $ create/dir 'dn'
  98. $ if $status then $ goto dirok
  99. $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
  100. $ delete 'f'*
  101. $ exit
  102. $dirok:
  103. $ w "-I-PROCESS, Processing file ''P1'."
  104. $ if .not. f$verify() then $ define/user sys$output nl:
  105. $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
  106. PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
  107. SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
  108. CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
  109. LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
  110. BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
  111. IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
  112. MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
  113. ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
  114. 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
  115. POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
  116. ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
  117. COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
  118. "output_file"));ENDPROCEDURE;Unpacker;QUIT;
  119. $ delete/nolog 'f'*
  120. $ CHECKSUM 'P1'
  121. $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
  122. $ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
  123. $ ENDSUBROUTINE
  124. $START:
  125. $ create 'f'
  126. X17-October-1990
  127. X
  128. XThis documentation is sketchy at best.  Hopefully, it will get
  129. Xyou started.
  130. X
  131. XThe MAILTONOTES program takes a mail file, complete with headers, and
  132. Xadds it to a VAXNOTES conference.  Most mail headers are stripped out.
  133. XThe subject of the mail message used to keep messages together --
  134. Xmessages with the same subject (with leading "re:" stripped off) will
  135. Xbe kept under the same topic.`20
  136. X
  137. XYou must create a subjects index file for each conference you wish
  138. Xto use with MAILTONOTES, see MAKESUBJECTS.COM.
  139. X
  140. XEnclosed in this distribution are the PMDF/DELIVER configuration files
  141. XI use here.  You don't have to use PMDF, it is just one way
  142. Xto direct incoming mail to the MAILTONOTES program.
  143. X
  144. XFor mailing lists, etc, that I want to go to a Notes conference, I
  145. Xsetup a VMS mail forwarding entry:
  146. X
  147. Xe.g.:
  148. XMAIL> SET FORW/USER=INFOVAX DELIVER%MAILTONOTES
  149. X
  150. XThere is a MAILTONOTES account setup to do all the forwarding.
  151. X
  152. XFiles in this distribution:
  153. X
  154. Xmailtonotes.c`09`09Source: $ cc mailtonotes
  155. Xmailtonotes.opt`09`09Link options file:  $link mailtonotes/opt
  156. Xnotes.fdl`09`09Used by makesubjects.com
  157. Xmakesubjects.com`09Creates notes$library:conferencename.subjects
  158. Xmail.delivery`09`09DELIVER configuration file for MAILTONOTES user
  159. Xdelivertonotes.com`09Called by DELIVER in MAILTONOTES account
  160. Xenvelope.com`09`09Called by DELIVER in MAILTONOTES account
  161. Xnotedir.c`09`09A utility program to mangle notesfiles
  162. Xnotedir.opt`09`09Link options for notedir
  163. X
  164. X05-Sep-1992
  165. X
  166. XI ran across a reference to this nifty piece of code and thought it deserved
  167. V a
  168. Xlittle wider distribution.  I'll be working on it to do the "other half" of
  169. V the
  170. Xnotes to news gateway problem I've been working on (as time allows).  I have
  171. Vn't
  172. Xactually had a chance to try it yet, so I really DON'T know if it works or n
  173. Vot.`20
  174. XOne of the interesting things about it though is that it uses the callable
  175. Xnotes interface.
  176. X
  177. XFor those of you without PMDF, you can get the DELIVER piece of it from any
  178. XVMSNET.SOURCES archive site near you.  You may need to to a little adjustmen
  179. Vt
  180. Xto the code as the expected environment for mail delivery is via TWGs SMTP,
  181. V but
  182. Xthat shouldn't be too bad.
  183. X
  184. XIn the mean time use it in good health.
  185. X
  186. XDick Munroe
  187. XDoyle, Munroe Consultants, Inc.
  188. Xmunroe@dmc.com
  189. $ CALL UNPACK 00README.TXT;6 461229752
  190. $ create 'f'
  191. X$!
  192. X$! delivertonotes
  193. X$!
  194. X$! usage: @delivertonotes notefilename
  195. X$! other symbols:  FROM, TO, SUBJECT, QFROM, QQFROM, QTO, QQTO,
  196. X$!                 QSUBJECT, QQSUBJECT, MESSAGE_FILE, MESAGE_DELETE
  197. X$!
  198. X$ on error then goto bomb
  199. X$ define sys$output dua0:`5Bmailtonotes`5Ddelivertonotes.log ! open a log
  200. X$ set verify
  201. X$ p1 = f$edit(p1,"TRIM, UPCASE")
  202. X$ mailtonotes :== $dua0:`5Bmailtonotes`5Dmailtonotes
  203. X$ mailtonotes 'p1' 'message_file' "notes$library:.subjects"
  204. X$ exit
  205. X$!
  206. X$!
  207. X$bomb:
  208. X$ savestatus = $status
  209. X$ define sys$output dua0:`5Bmailtonotes`5Dunknown.log ! open a log
  210. X$ show symbol savestatus
  211. X$ copy 'message_file' dua0:`5Bmailtonotes.unknown`5Dunknown.dat;0
  212. X$ set noverify
  213. X$ write sys$output "unknown.com called at ",f$time()
  214. X$ write sys$output "To:         ", to
  215. X$ write sys$output "From:       ", from
  216. X$ write sys$output "Subject:    ", subject
  217. X$ mail /subject="mailtonotes bomb" nl: _ccaw001
  218. X$ exit
  219. $ CALL UNPACK DELIVERTONOTES.COM;14 1699092688
  220. $ create 'f'
  221. X$!
  222. X$! delivertonotes - envelope version
  223. X$!
  224. X$! This moves the selection of the notesfile from matching
  225. X$! in mail.delivery to mailtolist.  It is assumed that the
  226. X$! "X-Envelope-To" header will point to (probably via a logical)
  227. X$! to the name of the notesfile to use.  This is since the
  228. X$! "To" field of the mail file isn't a very good thing
  229. X$! to match to.  Yuk.
  230. X$!
  231. X$! usage: @envelope
  232. X$! other symbols:  FROM, TO, SUBJECT, QFROM, QQFROM, QTO, QQTO,
  233. X$!                 QSUBJECT, QQSUBJECT, MESSAGE_FILE, MESAGE_DELETE
  234. X$!
  235. X$ on error then goto bomb
  236. X$ define sys$output dua0:`5Bmailtonotes`5Ddelivertonotes.log ! open a log
  237. X$ set verify
  238. X$ p1 = f$edit(p1,"TRIM, UPCASE")
  239. X$ mailtolist :== $dua0:`5Bmailtonotes`5Dmailtolist
  240. X$!
  241. X$! define envelope to actual filename translation here
  242. X$!
  243. X$ define infotcpip "info-tcpip-2"
  244. X$ define infovax "info-vax-2"
  245. X$ define rfclist "rfc-list"
  246. X$ define xwlist "xwindow-list-2"
  247. X$ define egppeople "egp-people"
  248. X$ define snmp "snmp-list"
  249. X$ define ietf "ietf-list"
  250. X$ define unknown "scratch"
  251. X$!
  252. X$ mailtolist envelope 'message_file' "dua0:`5Bnetdist.mailer`5D.subjects"
  253. X$ exit
  254. X$!`20
  255. X$bomb:
  256. X$ savestatus = $status
  257. X$ define sys$output dua0:`5Bmailtonotes`5Dunknown.log ! open a log
  258. X$ show symbol savestatus
  259. X$ copy 'message_file' dua0:`5Bmailtonotes.unknown`5Dunknown.dat;0
  260. X$ set noverify
  261. X$ write sys$output "unknown.com called at ",f$time()
  262. X$ write sys$output "To:         ", to
  263. X$ write sys$output "From:       ", from
  264. X$ write sys$output "Subject:    ", subject
  265. X$ mail /subject="envelope bomb" nl: _ccaw001
  266. X$ exit
  267. $ CALL UNPACK ENVELOPE.COM;10 1818205897
  268. $ create 'f'
  269. X!<from-pat> <to-pat> <subj-pat> <accept> <action> <parameter>
  270. X! Accept items:
  271. X! A - Always apply this directive; ignore results of comparison
  272. X! X - Never apply this directive; ignore the results of comparison
  273. X! T - Apply this directive if all patterns matched
  274. X! F - Apply this directive if not all patterns matched
  275. X! O - Apply this directive if all matched and no other directive has
  276. X!     been applied to this message
  277. X! B - Apply this directive if no matches and no previous directives
  278. X!     have been applied.
  279. X! E - This directive applies if all patterns matched OR no other
  280. X!     directive has been applied so far.
  281. X!
  282. X! Actions:
  283. X! A - append the body of the message to file <parameter>.  File
  284. X!     must already exist.
  285. X! C - copy the body to file <parameter>.
  286. X! D - deliver the message normally (place in NEWMAIL mail folder).
  287. X! V - deliver message normally using SYSTEM privilege.  This identical
  288. X!     to "D" except that the "From:" field is set to match original
  289. X!     sender.  Requires that user be fully privileged.
  290. X! E - execute the specified command. The DCL command <parameter> is executed
  291. V.
  292. X!     DCL symbols provided are: FROM, TO, SUBJECT, QFROM, QQFROM, QTO, QQTO,
  293. X!     QSUBJECT, QQSUBJECT, MESSAGE_FILE, MESAGE_DELETE
  294. X! F - Forward the message.  The message is forwarded to <parameter>
  295. X! W - Forward using privileges.  Similar in effect to V.
  296. X! Q - quit; take no action and abort.
  297. X!
  298. X!
  299. X! New groups must also be defined in envelope.com
  300. X!
  301. X* "infotcpip*"  * O E "@delivertonotes.com info-tcpip-2"
  302. X* "infovax*"    * O E "@delivertonotes.com info-vax-2"
  303. X* "info-vax*"    * O E "@delivertonotes.com info-vax-2"
  304. X* "rfclist*"    * O E "@delivertonotes.com rfc-list"
  305. X* "xwlist*"     * O E "@delivertonotes.com xwindow-list-2"
  306. X* "xpert*"     * O E "@delivertonotes.com xwindow-list-2"
  307. X* "egppeople*"  * O E "@delivertonotes.com egp-people"
  308. X* "snmp*"       * O E "@delivertonotes.com snmp-list"
  309. X* "ietf*"       * O E "@delivertonotes.com ietf-list"
  310. X* *             * O E "@envelope.com"
  311. X
  312. X
  313. $ CALL UNPACK MAIL.DELIVERY;14 1180387275
  314. $ create 'f'
  315. X/*
  316. X * Copyright 1989 The University of Texas at Austin
  317. X *
  318. X * Permission to use, copy, modify, and distribute this software and its
  319. X * documentation for any purpose and without fee is hereby granted,
  320. X * provided that the above copyright notice appear in all copies and that
  321. X * both that copyright notice and this permission notice appear in
  322. X * supporting documentation, and that the name of The University of Texas
  323. X * not be used in advertising or publicity pertaining to distribution of
  324. X * the software without specific, written prior permission.  The
  325. X * University of Texas makes no representations about the suitability of
  326. X * this software for any purpose.  It is provided "as is" without express
  327. X * or implied warranty.
  328. X *`20
  329. X * THE UNIVERSITY OF TEXAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  330. X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  331. X * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS BE LIABLE FOR ANY
  332. X * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  333. X * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  334. X * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  335. X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  336. X *
  337. X * Author:`20
  338. X * Rick Watson`20
  339. X *   The University of Texas Computation Center, 512/471-3241
  340. X *   internet: rick@digate.cc.utexas.edu       bitnet: watson@utadnx
  341. X *   uucp:     ...!cs.utexas.edu!ut-emx!rick   span:   utspan::utadnx::watso
  342. Vn
  343. X */
  344. X
  345. X/***`09mail-to-notes.
  346. X*
  347. X*`09Used by the notes remailer.
  348. X*`091.  Deletes mail extraneous headers.
  349. X*`092.  Keeps an index of subject lines and note id's. Notes
  350. X*`09    with equivalent subjects will be "noted" under the same
  351. X*`09    topic.
  352. X*`09usage: mailtonotes notefilename inputfile `5Bsubjectsfileloc`5D
  353. X*
  354. X*`09Subjectsfile is an optional default specification of the
  355. X*`09subjects file directory.  e.g.: "twg$tcp:`5Bnetdist.mailer`5D.subjects"
  356. X*
  357. X*`0903/12/90 -- R. Watson
  358. X*`09   Add hack for delivertonotes such that if`20
  359. X*`09   notefilename == "envelope" use
  360. X*`09   the x-envelope-to mail header as the notefilename.
  361. X*`09   This notefilename will probably be a logical pointer
  362. X*`09   to the real notefilename so that we can change the
  363. X*`09   name of the notefile.
  364. X*`0906/04/90 -- R. Watson
  365. X*`09   Fix so that if the subject key is invalid (probably we
  366. X*`09   deleted the note) we make a new note instead and update
  367. X*`09   the key.  Don't set duplicate notes hidden anymore - delete
  368. X*`09   them.
  369. X*/
  370. X
  371. X#include <rms.h>
  372. X#include <stdio.h>
  373. X#include "notescodes.h"
  374. X`09
  375. X#define TRUE 1
  376. X#define FALSE 0
  377. X
  378. Xstruct hline `7B
  379. X`09struct hline* next;`09`09`09/* pointer to next */
  380. X`09int type;`09`09`09`09/* type of header */
  381. X`09char buf`5B512`5D;`09`09`09`09/* line buffer */
  382. X`7D;`20
  383. X
  384. Xstruct list `7B
  385. X`09short`09len;
  386. X`09short`09item;
  387. X`09char`09*buf;
  388. X`09short`09*rla;
  389. X`7D;
  390. X
  391. XFILE *inp;`09`09`09`09`09/* files */
  392. Xstatic struct hline *hlist = 0;`09`09`09/* list of headers */
  393. Xstatic struct hline *dlist = 0;`09`09`09/* first data line */
  394. Xstatic struct hline *h;`09`09`09`09/* current line */
  395. Xstatic struct hline *hlast;`09`09`09/* last in list */
  396. Xstatic char *sp;`09`09`09`09/* subject pointer */
  397. Xstatic char *ep;`09`09`09`09/* envelope pointer */
  398. Xstatic char key`5B80 + 8 + 1`5D;
  399. Xstatic char *np;`09`09`09`09/* note number pointer */
  400. Xstatic struct list ilst`5B15`5D;`09`09`09/* input list */
  401. Xstatic struct list olst`5B15`5D;`09`09`09/* output list */
  402. Xstatic int nf_context = 0;`09`09`09/* notesfile context */
  403. Xstatic int note_context = 0;`09`09`09/* note context */
  404. Xstatic int one = 1;
  405. Xstatic int zero = 0;
  406. Xstatic int update = 0;`09`09`09`09/* update flag */
  407. Xstatic int numnotes;
  408. Xstatic char added`5B20`5D;`09`09`09`09/* added note string */
  409. Xstatic char blinkid`5B20`5D;`09`09`09/* topic id */
  410. Xstatic char userarea`5B255`5D;`09`09`09/* existing user area */
  411. Xstatic struct FAB fab;`09`09`09`09/* for subject key */
  412. Xstatic struct RAB rab;
  413. Xstatic char checkbuf`5B`5D = "xxxxxxxx xxxxxxxx xxxxxxxx\0";
  414. Xstatic char *dflt_subjects = "notes$library:.subjects";
  415. X
  416. X#define NKEYS 4
  417. X#define T_SUBJECT 0`09`09`09`09/* must keep following order */
  418. X#define T_ENVELOPE 3
  419. Xstatic char *hdrs`5B`5D =  `7B"subject",`09`09/* must be 0 or fix above */
  420. X`09`09`09"date",
  421. X`09`09`09"from",
  422. X`09`09`09"x-envelope-to"`7D;`09/* must be 3 */
  423. X
  424. Xmain(argc, argv)
  425. Xint argc;
  426. Xchar *argv`5B`5D;
  427. X`7B
  428. X`09int stat, hide;
  429. X`09char record`5B80 + 8`5D;
  430. X`09int newkey;
  431. X`09`09
  432. X/*  parse the parameters */
  433. X
  434. X`09if (argc < 3) `7B
  435. X`09`09fprintf(stdout, "invalid argument count\n");
  436. X`09`09exit(0);
  437. X`09`7D
  438. X
  439. X`09if (argc >= 4)`09`09`09`09/* if specified default subjects */
  440. X`09    dflt_subjects = argv`5B3`5D;
  441. X
  442. X`09inp = fopen(argv`5B2`5D, "r");`09`09/* open the input file */
  443. X`09if (inp == NULL) `7B
  444. X`09`09perror("fopen inp");
  445. X`09`09exit(0);
  446. X`09`7D
  447. X
  448. X`09scavengeheader();`09`09`09/* parse the mail headers */
  449. X
  450. X`09/*
  451. X`09 * If there is an x-envelope-to and the parameter is
  452. X`09 * envelope, then use the envelope for the notefile.
  453. X`09 */
  454. X`09if (ep &&
  455. X`09`09((strcmp(argv`5B1`5D, "envelope")==0) `7C`7C
  456. X`09`09 (strcmp(argv`5B1`5D, "ENVELOPE")==0))) `7B
  457. X`09`09`09argv`5B1`5D = ep;
  458. X`09`09`09fprintf(stdout, "Using envelope: %s\n", ep);
  459. X`09`7D
  460. X
  461. X`09lookup_subjectkey(argv`5B1`5D);`09`09/* look up subject */
  462. X
  463. X`09fprintf(stdout, "Subject key = %s\n", key);
  464. X`09if (np)`20
  465. X`09    fprintf(stdout, "Old note = %s\n", np);
  466. X
  467. X`09stat = notefile_begin(argv`5B1`5D);`09`09/* get the notes file */
  468. X`09checkstat(stat, "notefile_begin");
  469. X
  470. X`09stat = note_begin();
  471. X`09checkstat(stat, "note_begin");
  472. X
  473. X`09stat = note_add();
  474. X
  475. X`09stat = note_add_text();
  476. X
  477. X`09hide = checkother();
  478. X
  479. X`09if (hide) `7B
  480. X`09`09fprintf(stdout, "Duplicate note so deleted\n");
  481. X`09`09stat = deletenote(added);
  482. X`09`09checkstat(stat, "delete note");
  483. X`09`7D
  484. X`09else `7B
  485. X`09`09stat = moduserarea(checkbuf, FALSE);
  486. X`09`09checkstat(stat, "moduserarea");
  487. X`09`7D
  488. X`09
  489. X`09stat = note_end();
  490. X`09checkstat(stat, "note_end");
  491. X
  492. X`09if (!np `7C`7C update) `7B`09`09`09/* if no key or updating */
  493. X`09`09sscanf(added,"%d", &newkey);`09/* get correct format */
  494. X`09`09sprintf(&key`5B80`5D, "%06d.0", newkey);
  495. X`09`09fprintf(stdout, "%s key = %s\n",`20
  496. X`09                (update)? "Updated" : "Added", added);
  497. X`09`09write_key();
  498. X`09`7D
  499. X
  500. X`09notefile_end();
  501. X`7D
  502. X
  503. X
  504. X/**`09scavengeheader - parse the mail headers.
  505. X*/
  506. Xscavengeheader()
  507. X`7B
  508. X`09int hl;`09`09`09`09`09/* header length */
  509. X`09int n, i;
  510. X`09char *buf;
  511. X`09char hdr`5B512`5D;
  512. X`09char *c1, *c2;
  513. X
  514. X`09hlast = &hlist;
  515. X
  516. X`09sp = 0;`09`09`09`09`09/* no subject yet */
  517. X`09ep = 0;`09`09`09`09`09/* no envelope */
  518. X
  519. X/*  prime the input buffer */
  520. X
  521. X`09h = (struct hline *) malloc(sizeof(struct hline));
  522. X`09if (h == 0) `7B
  523. X`09`09fprintf(stdout, "couldn't malloc hline\n");
  524. X`09`09exit(0);
  525. X`09`7D
  526. X
  527. X
  528. X    reread:
  529. X`09if (fgets(h->buf, sizeof(h->buf), inp) == NULL) `7B`09 /* if eof */
  530. X`09`09fprintf(stdout, "no lines in file\n");
  531. X`09`09fclose(inp);
  532. X`09`09exit(0);
  533. X`09`7D
  534. X`09n = strlen(h->buf);
  535. X`09if (h->buf`5Bn-1`5D == '\n') `7B`09`09/* kill \n */
  536. X`09`09h->buf`5Bn-1`5D = 0;
  537. X`09`09n--;
  538. X`09`7D
  539. X`09if (n <= 0) goto reread;`09`09/* if blank ? */
  540. X
  541. X`09for (;;) `7B
  542. X`09`09c1 = strchr(h->buf, ':');`09/* find end of header */
  543. X`09`09if (c1 == NULL) `7B`09`09/* if end of headers */
  544. X`09`09`09dlist = h;`09`09/* save 1st data line */
  545. X`09`09`09break;
  546. X`09`09`7D
  547. X
  548. X`09`09c2 = h->buf;
  549. X`09`09hl = (int) (c1 - c2);`09`09/* # chars in keyword */
  550. X`09`09strncpy(hdr, h->buf, hl);`09/* get keyword */
  551. X`09`09hdr`5Bhl`5D = 0;
  552. X`09`09for (i = 0; i < hl; i++) hdr`5Bi`5D = tolower(hdr`5Bi`5D);
  553. X
  554. X`09`09for (i = 0; i < NKEYS; i++) `7B`09/* match keyword */
  555. X`09`09`09if (strcmp(hdr, hdrs`5Bi`5D) == 0) break;`09/* if match */
  556. X`09`09`7D
  557. X
  558. X`09`09h->type = i;`09`09`09/* save header type */
  559. X`09`09switch (i) `7B
  560. X
  561. X`09`09case T_SUBJECT:`09`09`09/* subject */
  562. X`09`09`09sp = &(h->buf`5B8`5D);`09/* locate nonblank */
  563. X`09`09`09while ((*sp == ' ') `7C`7C (*sp == '\t')) sp++;
  564. X
  565. X`09`09`09hlast->next = h;`09/* link to list */
  566. X`09`09`09h->next = 0;
  567. X`09`09`09hlast = h;
  568. X`09`09`09copyrest(FALSE);
  569. X`09`09`09break;
  570. X
  571. X`09`09case T_ENVELOPE:`09`09/* x-envelope-to */
  572. X`09`09`09ep = &(h->buf`5B14`5D);`09/* locate nonblank */
  573. X`09`09`09while ((*ep == ' ') `7C`7C (*ep == '\t')) ep++;
  574. X
  575. X`09`09`09hlast->next = h;`09/* link to list */
  576. X`09`09`09h->next = 0;
  577. X`09`09`09hlast = h;
  578. X`09`09`09copyrest(FALSE);
  579. X`09`09`09break;
  580. X
  581. X`09`09default:
  582. X`09`09`09if (i >= NKEYS) `7B`09`09/* if not in list */
  583. X`09`09`09`09free(h);`09`09/* drop this header */
  584. X`09`09`09`09copyrest(TRUE);
  585. X`09`09`09`09break;`09`09`09
  586. X`09`09`09`7D
  587. X`09`09`09else `7B`09`09`09
  588. X`09`09`09`09hlast->next = h;`09/* link to list */
  589. X`09`09`09`09h->next = 0;
  590. X`09`09`09`09hlast = h;
  591. X`09`09`09`09copyrest(FALSE);
  592. X`09`09`09`09break;
  593. X`09`09`09`7D
  594. X`09`09`7D /* switch */
  595. X`09`7D /* for */
  596. X`7D
  597. X
  598. X
  599. X/**`09copyrest(flush) - handle possible continuation lines
  600. X*/
  601. Xcopyrest(flush)
  602. Xint flush;`09`09`09/* true if flushing cont lines */
  603. X`7B
  604. X`09int i, n;
  605. X
  606. X`09for (;;) `7B
  607. X`09`09h = (struct hline *) malloc(sizeof(struct hline));
  608. X`09`09if (h == 0) `7B
  609. X`09`09`09fprintf(stdout, "couldn't malloc hline\n");
  610. X`09`09`09exit(0);
  611. X`09`09`7D
  612. X`09`09if (fgets(h->buf, sizeof(h->buf), inp) == NULL) `7B`09 /* if eof */
  613. X`09`09`09fclose(inp);
  614. X`09`09`09fprintf(stdout, "no data after mail headers\n");
  615. X`09`09`09exit(0);
  616. X`09`09`7D
  617. X`09`09n = strlen(h->buf);
  618. X`09`09if (h->buf`5Bn-1`5D == '\n') `7B`09`09/* kill \n */
  619. X`09`09`09h->buf`5Bn-1`5D = 0;
  620. X`09`09`09n--;
  621. X`09`09`7D
  622. X
  623. X`09`09if ((h->buf`5B0`5D == ' ') `7C`7C (h->buf`5B0`5D == '\t')) `7B`09/* po
  624. Vssible cont */
  625. X`09`09`09for (i = 0; i < n; i++) `7B`09/* find non-white */
  626. X`09`09`09`09if ((h->buf`5Bi`5D != ' ') && (h->buf`5Bi`5D != '\t') &&
  627. X`09`09`09`09`09(h->buf`5Bi`5D != '\n')) goto oks;
  628. X`09`09`09`7D
  629. X`09`09`7D
  630. X
  631. X`09`09return;`09`09/* leave line in buf */
  632. X
  633. X`09`09oks:
  634. X`09`09if (!flush) `7B
  635. X`09`09`09hlast->next = h;`09/* link to list */
  636. X`09`09`09h->next = 0;
  637. X`09`09`09hlast = h;
  638. X`09`09`7D
  639. X`09`09else free(h);
  640. X`09`7D /* for */
  641. X`7D
  642. X
  643. X
  644. X/**`09notefile_begin.
  645. X*/
  646. Xnotefile_begin(notefile)
  647. Xchar *notefile;
  648. X`7B
  649. X`09int stat, i;
  650. X`09static char *dflt = "notes$library:.note";
  651. X
  652. X`09i = 0;
  653. X`09ilst`5Bi`5D.item = NOTES$K_NOTEFILE_FILE_NAME;
  654. X`09ilst`5Bi`5D.len = strlen(notefile);
  655. X`09ilst`5Bi`5D.buf = notefile;
  656. X`09ilst`5Bi`5D.rla = 0;
  657. X
  658. X`09ilst`5B++i`5D.item = NOTES$K_NOTEFILE_DEFAULT_NAME;
  659. X`09ilst`5Bi`5D.len = strlen(dflt);
  660. X`09ilst`5Bi`5D.buf = dflt;
  661. X`09ilst`5Bi`5D.rla = 0;
  662. X
  663. X`09ilst`5B++i`5D.item = NOTES$K_NOSIGNAL;
  664. X`09ilst`5Bi`5D.len = 4;
  665. X`09ilst`5Bi`5D.buf = (char*) &one;
  666. X`09ilst`5Bi`5D.rla = 0;
  667. X
  668. X`09ilst`5B++i`5D.item = 0;`09`09/* terminator */
  669. X`09ilst`5Bi`5D.len = 0;
  670. X
  671. X`09i = 0;
  672. X`09olst`5Bi`5D.item = NOTES$K_NOTEFILE_NUMNOTES;
  673. X`09olst`5Bi`5D.len = 4;
  674. X`09olst`5Bi`5D.buf = (char*) &numnotes;
  675. X`09olst`5Bi`5D.rla = 0;
  676. X
  677. X`09olst`5B++i`5D.item = 0;
  678. X
  679. X`09stat = notes$notefile_begin(&nf_context, &ilst, &olst);
  680. X
  681. X`09return stat;
  682. X`7D
  683. X
  684. X
  685. X/**`09notefile_end.
  686. X*/
  687. Xnotefile_end()
  688. X`7B
  689. X`09int stat, i;
  690. X
  691. X`09i = 0;
  692. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  693. X`09ilst`5Bi`5D.len = 4;
  694. X`09ilst`5Bi`5D.buf = (char*) &one;
  695. X`09ilst`5Bi`5D.rla = 0;
  696. X
  697. X`09ilst`5B++i`5D.item = 0;
  698. X
  699. X`09olst`5B0`5D.item = 0;
  700. X
  701. X`09stat = notes$notefile_end(&nf_context, &ilst, &olst);
  702. X
  703. X`09return stat;
  704. X`7D
  705. X`09
  706. X
  707. X/**`09note_begin.
  708. X*/
  709. Xnote_begin()
  710. X`7B
  711. X`09int stat, i;
  712. X
  713. X`09i = 0;
  714. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  715. X`09ilst`5Bi`5D.len = 4;
  716. X`09ilst`5Bi`5D.buf = (char*) &one;
  717. X`09ilst`5Bi`5D.rla = 0;
  718. X
  719. X`09ilst`5B++i`5D.item = NOTES$K_NOTEFILE_CONTEXT;
  720. X`09ilst`5Bi`5D.len = 4;
  721. X`09ilst`5Bi`5D.buf = (char*) &nf_context;
  722. X`09ilst`5Bi`5D.rla = 0;
  723. X
  724. X`09ilst`5B++i`5D.item = 0;
  725. X
  726. X`09olst`5B0`5D.item = 0;
  727. X
  728. X`09stat = notes$note_begin(¬e_context, &ilst, &olst);
  729. X
  730. X`09return stat;
  731. X`7D
  732. X
  733. X
  734. X/**`09note_end.
  735. X*/
  736. Xnote_end()
  737. X`7B
  738. X`09int stat, i;
  739. X
  740. X`09i = 0;
  741. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  742. X`09ilst`5Bi`5D.len = 4;
  743. X`09ilst`5Bi`5D.buf = (char*) &one;
  744. X`09ilst`5Bi`5D.rla = 0;
  745. X
  746. X`09ilst`5B++i`5D.item = 0;
  747. X
  748. X`09olst`5B0`5D.item = 0;
  749. X
  750. X`09stat = notes$note_end(¬e_context, &ilst, &olst);
  751. X
  752. X`09return stat;
  753. X`7D
  754. X
  755. X
  756. X/**`09note_add.
  757. X*/
  758. Xnote_add()
  759. X`7B
  760. X`09int i, stat, blink;
  761. X`09short addedl;
  762. X`09short blinkidl;
  763. X
  764. X`09if (np && !validnote(np)) `7B`09`09/* if old note gone */
  765. X`09`09np = 0;`09`09`09`09/* forget we have a key */
  766. X`09`09update = TRUE;`09`09`09/* but update it */
  767. X`09`09fprintf(stdout, "Old note was invalid (missing)\n");
  768. X`09`7D
  769. X
  770. X`09i = 0;
  771. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  772. X`09ilst`5Bi`5D.len = 4;
  773. X`09ilst`5Bi`5D.buf = (char*) &one;
  774. X`09ilst`5Bi`5D.rla = 0;
  775. X
  776. X`09if (np) `7B`09`09`09/* if reply */
  777. X`09`09ilst`5B++i`5D.item = NOTES$K_NOTE_BLINK_ID;
  778. X`09`09ilst`5Bi`5D.buf = np;
  779. X`09`09ilst`5Bi`5D.len = strlen(np);
  780. X`09`09ilst`5Bi`5D.rla = 0;
  781. X`09`09blink = i;
  782. X`09`7D
  783. X`09else `7B`09`09`09`09/* else main topic - set title */
  784. X`09`09if (!sp) sp = "";`09`09`09/* if empty subject */
  785. X`09`09ilst`5B++i`5D.item = NOTES$K_NOTE_TITLE;
  786. X`09`09ilst`5Bi`5D.len = strlen(sp);
  787. X`09`09ilst`5Bi`5D.buf = sp;
  788. X`09`09ilst`5Bi`5D.rla = 0;
  789. X`09`7D
  790. X
  791. X`09/* add a template user area so record won't change size */
  792. X`09ilst`5B++i`5D.item = NOTES$K_NOTE_USER_AREA;
  793. X`09ilst`5Bi`5D.buf = "xxxxxxxx xxxxxxxx xxxxxxxx";
  794. X`09ilst`5Bi`5D.len = strlen(ilst`5Bi`5D.buf);
  795. X`09ilst`5Bi`5D.rla = 0;
  796. X
  797. X`09ilst`5B++i`5D.item = 0;
  798. X
  799. X/*  THIS SHOULD MATCH UP WITH NUMNOTES+1 IF NEW NOTE */
  800. X
  801. X`09i = 0;
  802. X`09olst`5Bi`5D.item = NOTES$K_NOTE_ID;`09`09/* find out what note was genera
  803. Vted */
  804. X`09olst`5Bi`5D.len = sizeof(added);
  805. X`09olst`5Bi`5D.buf = added;
  806. X`09olst`5Bi`5D.rla = &addedl;
  807. X
  808. X`09olst`5B++i`5D.item = NOTES$K_NOTE_BLINK_ID; /* get topic id */
  809. X`09olst`5Bi`5D.len = sizeof(blinkid);
  810. X`09olst`5Bi`5D.buf = blinkid;
  811. X`09olst`5Bi`5D.rla = &blinkidl;
  812. X
  813. X`09olst`5B++i`5D.item = 0;
  814. X
  815. X`09stat = notes$note_add(¬e_context, &ilst, &olst);
  816. X#if 0
  817. X`09if (np && (stat == 0x3fb10b2)) `7B`09/* if couldn't find old note */
  818. X`09`09/* try again with new note */
  819. X`09`09fprintf(stdout, "Old note must be gone\n");
  820. X`09`09if (!sp) sp = "";`09`09`09/* if empty subject */
  821. X`09`09ilst`5Bblink`5D.item = NOTES$K_NOTE_TITLE;
  822. X`09`09ilst`5Bblink`5D.len = strlen(sp);
  823. X`09`09ilst`5Bblink`5D.buf = sp;
  824. X`09`09ilst`5Bblink`5D.rla = 0;
  825. X`09`09stat = notes$note_add(¬e_context, &ilst, &olst);
  826. X`09`09update = TRUE;
  827. X`09`7D
  828. X#endif
  829. X`09checkstat(stat, "note_add");
  830. X
  831. X`09added`5Baddedl`5D = 0;`09`09`09/* terminate strings */
  832. X`09blinkid`5Bblinkidl`5D = 0;
  833. X`09fprintf(stdout, "note added = %s\n", added);
  834. X`7D
  835. X
  836. X`09
  837. X/**`09note_add_text.
  838. X*/
  839. Xnote_add_text()
  840. X`7B
  841. X`09int i, ti, stat, n;
  842. X`09char fname`5B255`5D;
  843. X`09char buf`5B1024`5D;
  844. X`09FILE *f;
  845. X`09int sum, nline, nchar;
  846. X
  847. X`09sum = nline = nchar = 0;
  848. X
  849. X`09i = 0;
  850. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  851. X`09ilst`5Bi`5D.len = 4;
  852. X`09ilst`5Bi`5D.buf = (char*) &one;
  853. X`09ilst`5Bi`5D.rla = 0;
  854. X
  855. X`09ilst`5B++i`5D.item = NOTES$K_TEXT_STRING;
  856. X`09ilst`5Bi`5D.rla = 0;
  857. X`09ti = i;
  858. X
  859. X`09ilst`5B++i`5D.item = 0;
  860. X
  861. X`09olst`5B0`5D.item = 0;
  862. X
  863. X`09if (hlast != &hlist) `7B`09`09/* if headers were found */
  864. X`09`09h = &hlist;
  865. X`09`09while (h = h->next) `7B
  866. X`09`09`09if (h->type == T_ENVELOPE)`09/* if envelope */
  867. X`09`09`09    continue;`09`09`09/*   don't put */
  868. X`09`09`09ilst`5Bti`5D.buf = h->buf;
  869. X`09`09`09ilst`5Bti`5D.len = strlen(h->buf);
  870. X`09`09`09stat = notes$note_add_text(¬e_context, &ilst, &olst);
  871. X`09`09`09checkstat(stat, "add_text");
  872. X`09`09`7D
  873. X`09`7D
  874. X
  875. X`09if (dlist) `7B`09`09`09`09/* if spare data line */
  876. X`09`09h = dlist;
  877. X
  878. X`09`09for (i = 0; i < strlen(h->buf); i++) `7B`09/* sum the line */
  879. X`09`09`09sum += h->buf`5Bi`5D;
  880. X`09`09`7D
  881. X`09`09nchar += strlen(h->buf);`09`09/* sum chars */
  882. X`09`09nline += 1;
  883. X
  884. X`09`09ilst`5Bti`5D.buf = h->buf;
  885. X`09`09ilst`5Bti`5D.len = strlen(h->buf);
  886. X`09`09stat = notes$note_add_text(¬e_context, &ilst, &olst);
  887. X`09`09checkstat(stat, "add_text");
  888. X`09`7D
  889. X
  890. X`09while (fgets(buf, sizeof(buf)-1, inp) != 0) `7B`09/* while not eof */
  891. X`09`09n = strlen(buf);
  892. X`09`09if (buf`5Bn-1`5D == '\n') `7B`09`09`09/* kill \n */
  893. X`09`09`09buf`5Bn-1`5D = 0;
  894. X`09`09`09n--;
  895. X`09`09`7D
  896. X
  897. X`09`09for (i = 0; i < n; i++) `7B`09`09/* sum the line */
  898. X`09`09`09sum += buf`5Bi`5D;
  899. X`09`09`7D
  900. X`09`09nchar += n;`09`09`09`09/* sum chars */
  901. X`09`09nline += 1;
  902. X
  903. X`09`09ilst`5Bti`5D.buf = buf;
  904. X`09`09ilst`5Bti`5D.len = n;
  905. X`09`09stat = notes$note_add_text(¬e_context, &ilst, &olst);
  906. X`09`09checkstat(stat, "add_text");
  907. X`09`7D
  908. X
  909. X`09fclose(inp);
  910. X
  911. X`09ilst`5Bti`5D.item = NOTES$K_TEXT_END;`09/* signal eof */
  912. X`09ilst`5Bti`5D.len = 4;
  913. X`09ilst`5Bti`5D.buf = (char*) &one;
  914. X`09ilst`5Bti`5D.rla = 0;
  915. X
  916. X`09stat = notes$note_add_text(¬e_context, &ilst, &olst);
  917. X`09checkstat(stat, "add_text");
  918. X
  919. X/*  set the user data area */
  920. X
  921. X`09sprintf(checkbuf, "%08X %08X %08X", nline, nchar, sum);
  922. X`7D
  923. X
  924. X
  925. X/**`09checkstat.
  926. X*/
  927. Xcheckstat(stat, string)
  928. Xint stat;
  929. Xchar *string;
  930. X`7B
  931. X`09if ((stat & 1) == 1) return;
  932. X
  933. X`09fprintf(stdout, "%s: 0x%x\n", string, stat);
  934. X`09lib$stop(stat);
  935. X`7D
  936. X
  937. X
  938. X/**`09lookup_subjectkey.
  939. X*/
  940. Xlookup_subjectkey(subjectfile)
  941. Xchar *subjectfile;
  942. X`7B
  943. X`09static char record`5B80 + 8  + 1`5D;
  944. X`09int i, stat, n;
  945. X`09char *skp;
  946. X
  947. X`09np = 0;
  948. X
  949. X`09skp = 0;`09`09`09`09/* build the key */
  950. X`09key`5B0`5D = 0; key`5B80`5D = 0;
  951. X`09if (sp) strncpy(key, sp, 80);
  952. X`09skp = key;
  953. X`09for(i = 0; i < strlen(key); i++) key`5Bi`5D = tolower(key`5Bi`5D);
  954. X`09for (;;) `7B`09`09`09`09/* remove leading re: */
  955. X`09`09if (strncmp(skp, "re:", 3) == 0) skp += 3;
  956. X`09`09else break;
  957. X`09`7D
  958. X`09for (;;) `7B`09`09`09`09/* remove leading white */
  959. X`09`09if ((*skp == ' ') `7C`7C (*skp == '\t')) skp++;
  960. X`09`09else break;
  961. X`09`7D
  962. X`09n = strlen(skp);
  963. X`09if (skp != key) `7B`09`09`09/* if chars removed */
  964. X`09`09for (i = 0; i < n; i++) key`5Bi`5D = *skp++;
  965. X`09`09key`5Bn`5D = 0;
  966. X`09`7D
  967. X`09skp = key;
  968. X`09for (i = strlen(skp); i < 79; i++) key`5Bi`5D = ' '; /* trail blanks */
  969. X`09key`5B79`5D = '!';
  970. X`09
  971. X`09fab = cc$rms_fab;`09`09`09/* initialize fab */
  972. X`09fab.fab$l_fna = subjectfile;
  973. X`09fab.fab$b_fns = strlen(subjectfile);
  974. X`09fab.fab$l_dna = dflt_subjects;
  975. X`09fab.fab$b_dns = strlen(dflt_subjects);
  976. X`09fab.fab$b_fac `7C= (FAB$M_GET `7C FAB$M_PUT `7C FAB$M_UPD);
  977. X`09fab.fab$b_shr `7C= (FAB$M_SHRGET `7C FAB$M_SHRPUT);
  978. X
  979. X`09stat = sys$open(&fab);
  980. X`09checkstat(stat, "no subject key file");
  981. X
  982. X`09rab = cc$rms_rab;`09`09`09/* initialize rab */
  983. X`09rab.rab$l_fab = &fab;
  984. X`09rab.rab$b_rac = RAB$C_KEY;
  985. X
  986. X`09stat = sys$connect(&rab);
  987. X`09checkstat(stat, "couldn't connect");
  988. X
  989. X`09rab.rab$l_kbf = key;`09`09`09/* set key */
  990. X`09rab.rab$b_ksz = 80;
  991. X`09rab.rab$l_ubf = record;
  992. X`09rab.rab$w_usz = sizeof(record);
  993. X`09rab.rab$l_rop `7C= RAB$M_RRL;`09`09/* read even if locked */
  994. X
  995. X`09stat = sys$get(&rab, 0, 0);
  996. X`09if ((stat & 1) == 1) `7B`09`09`09/* if found */
  997. X`09`09np = &record`5B80`5D;
  998. X`09`09record`5B80+8`5D = 0;`09`09/* insure string terminated */
  999. X`09`7D
  1000. X`09else `7B`09`09`09`09`09/* DEBUG - SEE WHAT HAPPENS */
  1001. X`09`09fprintf(stdout, "no key stat=0x%x\n", stat);
  1002. X`09`7D
  1003. X`7D
  1004. X
  1005. X
  1006. X/**`09write_key - write key to subjects index.
  1007. X*/
  1008. Xwrite_key()
  1009. X`7B
  1010. X`09int stat;
  1011. X
  1012. X`09rab.rab$l_rbf = key;
  1013. X`09rab.rab$w_rsz = 80 + 8;
  1014. X
  1015. X`09if (update)
  1016. X`09    stat = sys$update(&rab, 0, 0);
  1017. X`09else
  1018. X`09    stat = sys$put(&rab, 0, 0);
  1019. X`09checkstat(stat, "put key");
  1020. X
  1021. X`09sys$close(&fab, 0, 0);
  1022. X`7D
  1023. X
  1024. X
  1025. X/**`09moduserarea - modify user area specified by current note id.
  1026. X*/
  1027. Xmoduserarea(string, hide)
  1028. Xchar *string;`09`09`09`09/* string to add to user data */
  1029. Xint hide;`09`09`09`09/* hide flag */
  1030. X`7B
  1031. X`09int i, stat;
  1032. X
  1033. X`09i = 0;
  1034. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  1035. X`09ilst`5Bi`5D.len = 4;
  1036. X`09ilst`5Bi`5D.buf = (char*) &one;
  1037. X`09ilst`5Bi`5D.rla = 0;
  1038. X
  1039. X`09if (hide) `7B
  1040. X`09`09ilst`5Bi`5D.item = NOTES$K_NOTE_HIDDEN;
  1041. X`09`09ilst`5Bi`5D.len = 4;
  1042. X`09`09ilst`5Bi`5D.buf = (char*) &one;
  1043. X`09`09ilst`5Bi`5D.rla = 0;
  1044. X`09`7D
  1045. X
  1046. X`09ilst`5B++i`5D.item = NOTES$K_NOTE_ID;
  1047. X`09ilst`5Bi`5D.len = strlen(added);
  1048. X`09ilst`5Bi`5D.buf = (char *) added;
  1049. X`09ilst`5Bi`5D.rla = 0;
  1050. X
  1051. X`09ilst`5B++i`5D.item = NOTES$K_NOTE_USER_AREA;
  1052. X`09ilst`5Bi`5D.buf = string;
  1053. X`09ilst`5Bi`5D.len = strlen(ilst`5Bi`5D.buf);
  1054. X`09ilst`5Bi`5D.rla = 0;
  1055. X
  1056. X`09ilst`5B++i`5D.item = 0;
  1057. X
  1058. X`09olst`5B0`5D.item = 0;
  1059. X
  1060. X`09stat = notes$note_modify(¬e_context, &ilst, &olst);
  1061. X
  1062. X`09return stat;
  1063. X`7D
  1064. X
  1065. X
  1066. X/**`09checkother - check other notes on this topic for duplicates.
  1067. X*/
  1068. Xcheckother()
  1069. X`7B
  1070. X`09int i, stat;
  1071. X`09static int first = TRUE;
  1072. X`09short userareal;
  1073. X`09int hide = FALSE;
  1074. X`09char currentid`5B20`5D;
  1075. X`09short currentidl;
  1076. X
  1077. X`09for (;;) `7B
  1078. X`09`09i = 0;
  1079. X`09`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  1080. X`09`09ilst`5Bi`5D.len = 4;
  1081. X`09`09ilst`5Bi`5D.buf = (char*) &one;
  1082. X`09`09ilst`5Bi`5D.rla = 0;
  1083. X
  1084. X`09`09ilst`5B++i`5D.item = NOTES$K_NOTE_ALL_RESPONSES;
  1085. X`09`09ilst`5Bi`5D.len = 4;
  1086. X`09`09ilst`5Bi`5D.buf = (char*) &one;
  1087. X`09`09ilst`5Bi`5D.rla = 0;
  1088. X
  1089. X`09`09if (first) `7B
  1090. X`09`09`09first = FALSE;
  1091. X`09`09`09ilst`5B++i`5D.item = NOTES$K_NOTE_ID;
  1092. X`09`09`09ilst`5Bi`5D.len = strlen(blinkid);
  1093. X`09`09`09ilst`5Bi`5D.buf = (char *) blinkid;
  1094. X`09`09`09ilst`5Bi`5D.rla = 0;
  1095. X`09`09`7D
  1096. X`09`09else `7B
  1097. X`09`09`09ilst`5B++i`5D.item = NOTES$K_NOTE_ID;
  1098. X`09`09`09ilst`5Bi`5D.buf = currentid;
  1099. X`09`09`09ilst`5Bi`5D.len = strlen(currentid);
  1100. X`09`09`09ilst`5Bi`5D.rla = 0;
  1101. X
  1102. X`09`09`09ilst`5B++i`5D.item = NOTES$K_NOTE_NEXT_RESPONSE;
  1103. X`09`09`09ilst`5Bi`5D.len = 4;
  1104. X`09`09`09ilst`5Bi`5D.buf = (char*) &one;
  1105. X`09`09`09ilst`5Bi`5D.rla = 0;
  1106. X`09`09`7D
  1107. X
  1108. X`09`09ilst`5B++i`5D.item = 0;
  1109. X
  1110. X`09`09i = 0;
  1111. X`09`09olst`5Bi`5D.item = NOTES$K_NOTE_USER_AREA;
  1112. X`09`09olst`5Bi`5D.buf = userarea;
  1113. X`09`09olst`5Bi`5D.len = sizeof(userarea) - 1;
  1114. X`09`09olst`5Bi`5D.rla = &userareal;
  1115. X`09
  1116. X`09`09olst`5B++i`5D.item = NOTES$K_NOTE_ID;
  1117. X`09`09olst`5Bi`5D.buf = currentid;
  1118. X`09`09olst`5Bi`5D.len = sizeof(currentid);
  1119. X`09`09olst`5Bi`5D.rla = ¤tidl;
  1120. X
  1121. X`09`09olst`5B++i`5D.item = 0;
  1122. X
  1123. X`09`09stat = notes$note_get(¬e_context, &ilst, &olst);
  1124. X`09`09if (stat == NOTES$_NO_MORE_REPLIES) break;
  1125. X`09`09checkstat(stat, "note get");
  1126. X
  1127. X`09`09userarea`5Buserareal`5D = 0;
  1128. X`09`09currentid`5Bcurrentidl`5D = 0;
  1129. X
  1130. X`09`09if (strcmp(currentid, added)==0) continue;
  1131. X
  1132. X`09`09if (strcmp(userarea, checkbuf)==0) `7B`09/* if same check */
  1133. X`09`09`09fprintf(stdout, "new matches %s\n", currentid);
  1134. X`09`09`09hide = TRUE;
  1135. X`09`09`7D
  1136. X`09`7D /* for */
  1137. X
  1138. X`09return hide;
  1139. X`7D
  1140. X
  1141. X
  1142. X/**`09validnote - validate that note exists.
  1143. X*
  1144. X* `09returns FALSE if note does not exist
  1145. X*/
  1146. Xvalidnote(id)
  1147. Xchar *id;`09`09`09`09/* id of note to validate */
  1148. X`7B
  1149. X`09int i, stat;
  1150. X`09int old, new;
  1151. X`09char currentid`5B20`5D;
  1152. X`09short currentidl;
  1153. X
  1154. X`09i = 0;
  1155. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  1156. X`09ilst`5Bi`5D.len = 4;
  1157. X`09ilst`5Bi`5D.buf = (char*) &one;
  1158. X`09ilst`5Bi`5D.rla = 0;
  1159. X
  1160. X`09ilst`5B++i`5D.item = NOTES$K_NOTE_ID;
  1161. X`09ilst`5Bi`5D.len = strlen(id);
  1162. X`09ilst`5Bi`5D.buf = (char *) id;
  1163. X`09ilst`5Bi`5D.rla = 0;
  1164. X
  1165. X`09ilst`5B++i`5D.item = 0;
  1166. X
  1167. X`09i = 0;
  1168. X`09olst`5Bi`5D.item = NOTES$K_NOTE_ID;
  1169. X`09olst`5Bi`5D.buf = currentid;
  1170. X`09olst`5Bi`5D.len = sizeof(currentid);
  1171. X`09olst`5Bi`5D.rla = ¤tidl;
  1172. X
  1173. X`09olst`5B++i`5D.item = 0;
  1174. X
  1175. X`09stat = notes$note_get(¬e_context, &ilst, &olst);
  1176. X`09if (!(stat & 1))
  1177. X`09    return FALSE;
  1178. X
  1179. X`09currentid`5Bcurrentidl`5D = 0;
  1180. X`09sscanf(np, "%d", &old);
  1181. X`09sscanf(currentid, "%d", &new);
  1182. X`09if (new == old)
  1183. X`09    return TRUE;
  1184. X`09else
  1185. X`09    return FALSE;
  1186. X`7D
  1187. X
  1188. X
  1189. X/**`09deletenote - delete a note.
  1190. X*/
  1191. Xdeletenote(id)
  1192. Xchar *id;`09`09`09`09/* id of note to delete */
  1193. X`7B
  1194. X`09int i, stat;
  1195. X
  1196. X`09i = 0;
  1197. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  1198. X`09ilst`5Bi`5D.len = 4;
  1199. X`09ilst`5Bi`5D.buf = (char*) &one;
  1200. X`09ilst`5Bi`5D.rla = 0;
  1201. X
  1202. X`09ilst`5B++i`5D.item = NOTES$K_NOTE_ID;
  1203. X`09ilst`5Bi`5D.len = strlen(id);
  1204. X`09ilst`5Bi`5D.buf = (char *) id;
  1205. X`09ilst`5Bi`5D.rla = 0;
  1206. X
  1207. X`09ilst`5B++i`5D.item = 0;
  1208. X
  1209. X`09i = 0;
  1210. X`09olst`5Bi`5D.item = 0;
  1211. X
  1212. X`09stat = notes$note_delete(¬e_context, &ilst, &olst);
  1213. X`09return stat;
  1214. X`7D
  1215. X
  1216. X
  1217. $ CALL UNPACK MAILTONOTES.C;1 124448320
  1218. $ create 'f'
  1219. Xmailtonotes,sys$share:notes$share/share,sys$share:vaxcrtl/share
  1220. $ CALL UNPACK MAILTONOTES.OPT;2 795441330
  1221. $ create 'f'
  1222. X$ inquire name "Conference name"
  1223. X$ create /fdl=notes notes$library:'name'.subjects
  1224. $ CALL UNPACK MAKESUBJECTS.COM;3 104942486
  1225. $ create 'f'
  1226. X/*
  1227. X * Copyright 1989 The University of Texas at Austin
  1228. X *
  1229. X * Permission to use, copy, modify, and distribute this software and its
  1230. X * documentation for any purpose and without fee is hereby granted,
  1231. X * provided that the above copyright notice appear in all copies and that
  1232. X * both that copyright notice and this permission notice appear in
  1233. X * supporting documentation, and that the name of The University of Texas
  1234. X * not be used in advertising or publicity pertaining to distribution of
  1235. X * the software without specific, written prior permission.  The
  1236. X * University of Texas makes no representations about the suitability of
  1237. X * this software for any purpose.  It is provided "as is" without express
  1238. X * or implied warranty.
  1239. X *`20
  1240. X * THE UNIVERSITY OF TEXAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  1241. X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1242. X * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS BE LIABLE FOR ANY
  1243. X * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  1244. X * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  1245. X * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  1246. X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1247. X *
  1248. X * Author:`20
  1249. X * Rick Watson`20
  1250. X *   The University of Texas Computation Center, 512/471-3241
  1251. X *   internet: watson@utadnx.cc.utexas.edu     bitnet: watson@utadnx
  1252. X *   uucp:     ...!cs.utexas.edu!ut-emx!rick   span:   utspan::utadnx::watso
  1253. Vn
  1254. X */
  1255. X
  1256. X#include <descrip.h>
  1257. X#include <rms.h>
  1258. X#include <stdio.h>
  1259. X#include "notescodes.h"
  1260. X
  1261. Xstruct list `7B
  1262. X`09short`09len;
  1263. X`09short`09item;
  1264. X`09char`09*buf;
  1265. X`09short`09*rla;
  1266. X`7D;
  1267. X
  1268. Xstatic char title`5B256`5D;
  1269. Xstatic short titlel;
  1270. Xstatic char noteid`5B20`5D;
  1271. Xstatic short noteidl;
  1272. Xstatic struct list ilst`5B15`5D;`09`09`09/* input list */
  1273. Xstatic struct list olst`5B15`5D;`09`09`09/* output list */
  1274. Xstatic int nf_context = 0;`09`09`09/* notesfile context */
  1275. Xstatic int note_context = 0;`09`09`09/* note context */
  1276. Xstatic int one = 1;
  1277. Xstatic int zero = 0;
  1278. Xstatic int numnotes;
  1279. Xstatic char *notefile = 0;`09`09`09/* notefile name */
  1280. Xstatic long sincetime`5B2`5D;`09`09`09/* sincetime quadword */
  1281. Xstatic long beforetime`5B2`5D;`09`09`09/* beforetime quadword */
  1282. Xstatic long createtime`5B2`5D;`09`09`09/* note create time */
  1283. Xstatic int since = 0;`09`09`09`09/* since flag */
  1284. Xstatic int before = 0;`09`09`09`09/* before flag */
  1285. Xstatic int delete = 0;`09`09`09`09/* delete flag */
  1286. Xstatic int modify = 0;`09`09`09`09/* modify flag */
  1287. Xstatic int buildsub = 0;`09`09`09/* building subjects flag */
  1288. Xstatic int iflag = 0;`09`09`09`09/* id specified flag */
  1289. Xstatic char userarea`5B255`5D;`09`09`09/* user area data */
  1290. Xstatic short userareal;`09`09`09`09/* length of user area */
  1291. Xstatic char *dflt_subjects = "twg$tcp:`5Bnetdist.mailer`5D.subjects";
  1292. Xstatic char subjects`5B80`5D;`09`09`09/* subjects file */
  1293. Xstatic char key`5B80 + 8 + 1`5D;
  1294. Xstatic struct FAB fab;`09`09`09`09/* for subject key */
  1295. Xstatic struct RAB rab;
  1296. Xstatic int inote, inoterep;`09`09`09/* individual note */
  1297. X
  1298. X#define NKEYS 3
  1299. Xstatic char *hdrs`5B`5D =  `7B"SUBJECT",
  1300. X`09`09`09"DATE",
  1301. X`09`09`09"FROM"`7D;
  1302. X
  1303. Xmain(argc, argv)
  1304. Xint argc;
  1305. Xchar *argv`5B`5D;
  1306. X`7B
  1307. X`09int stat;
  1308. X`09int i;
  1309. X`09char creates`5B24`5D;
  1310. X`09struct dsc$descriptor_s timbuf = `7B23, DSC$K_DTYPE_T, DSC$K_CLASS_S, cre
  1311. Vates`7D;
  1312. X
  1313. X`09parsecommand(argc, argv);
  1314. X
  1315. X`09if (!notefile) `7B
  1316. X`09`09fprintf(stdout, "usage: notedir `5Bopts`5D <notefile>\n");
  1317. X`09`09fprintf(stdout, "               -s since time\n");
  1318. X`09`09fprintf(stdout, "               -b before time\n");
  1319. X`09`09fprintf(stdout, "               -i note id\n");
  1320. X`09`09fprintf(stdout, "               -delete\n");
  1321. X`09`09fprintf(stdout, "               -m (set crc)\n");
  1322. X`09`09fprintf(stdout, "               -r subjectsfile (rebuild file)\n");
  1323. X
  1324. X`09`09exit(-1);
  1325. X`09`7D
  1326. X
  1327. X`09stat = notefile_begin(notefile);`09/* get the notes file */
  1328. X`09checkstat(stat, "notefile_begin");
  1329. X
  1330. X`09stat = note_begin();
  1331. X`09checkstat(stat, "note_begin");
  1332. X
  1333. X`09for (;;) `7B
  1334. X`09`09stat = note_get_next();
  1335. X`09`09if (!(stat & 1)) break;
  1336. X
  1337. X`09`09title`5Btitlel`5D = 0;
  1338. X`09`09noteid`5Bnoteidl`5D = 0;
  1339. X`09`09sys$asctim(0, &timbuf, createtime, 0);
  1340. X`09`09creates`5B17`5D = 0;
  1341. X`09`09creates`5Btimbuf.dsc$w_length`5D = 0;
  1342. X`09`09printf("%s: %s %s\n", noteid, creates, title);
  1343. X`09`09if (userareal) `7B
  1344. X`09`09`09userarea`5Buserareal`5D = 0;
  1345. X`09`09`09printf("user: %s\n", userarea);
  1346. X`09`09`7D
  1347. X
  1348. X`09`09if (delete) `7B
  1349. X`09`09`09int n, nrep;
  1350. X
  1351. X`09`09`09sscanf(noteid, "%d.%d", &n, &nrep);
  1352. X`09`09`09if (iflag && ((inote != n) `7C`7C (inoterep != nrep))) `7B
  1353. X`09`09`09`09fprintf(stderr, "Requested %d.%d != actual %d.%d, not deleted\n"
  1354. V, inote, inoterep, n, nrep);
  1355. X`09`09`09`09break;
  1356. X`09`09`09`7D
  1357. X`09`09`09
  1358. X`09`09`09stat = note_delete();
  1359. X`09`09`09checkstat(stat, "delete note");
  1360. X`09`09`7D
  1361. X
  1362. X`09`09if (modify)`09`09`09/* if crc wanted */
  1363. X`09`09`09get_crc();
  1364. X
  1365. X`09`09if (buildsub)`09`09`09/* if building subjects */
  1366. X`09`09`09write_key(title, noteid);
  1367. X
  1368. X`09`09if (iflag)`20
  1369. X`09`09`09break;`09`09`09/* if 1 note */
  1370. X`09`7D
  1371. X
  1372. X`09stat = note_end();
  1373. X`09checkstat(stat, "note_end");
  1374. X
  1375. X`09notefile_end();
  1376. X`7D
  1377. X
  1378. X
  1379. X/**`09notefile_begin.
  1380. X*/
  1381. Xnotefile_begin(notefile)
  1382. Xchar *notefile;
  1383. X`7B
  1384. X`09int stat, i;
  1385. X`09static char *dflt = "notes$library:.note";
  1386. X
  1387. X`09i = 0;
  1388. X`09ilst`5Bi`5D.item = NOTES$K_NOTEFILE_FILE_NAME;
  1389. X`09ilst`5Bi`5D.len = strlen(notefile);
  1390. X`09ilst`5Bi`5D.buf = notefile;
  1391. X`09ilst`5Bi`5D.rla = 0;
  1392. X
  1393. X`09ilst`5B++i`5D.item = NOTES$K_NOTEFILE_DEFAULT_NAME;
  1394. X`09ilst`5Bi`5D.len = strlen(dflt);
  1395. X`09ilst`5Bi`5D.buf = dflt;
  1396. X`09ilst`5Bi`5D.rla = 0;
  1397. X
  1398. X`09ilst`5B++i`5D.item = NOTES$K_NOSIGNAL;
  1399. X`09ilst`5Bi`5D.len = 4;
  1400. X`09ilst`5Bi`5D.buf = (char*) &one;
  1401. X`09ilst`5Bi`5D.rla = 0;
  1402. X
  1403. X`09ilst`5B++i`5D.item = NOTES$K_NOTEFILE_MODERATE;
  1404. X`09ilst`5Bi`5D.len = 4;
  1405. X`09ilst`5Bi`5D.buf = (char*) &one;
  1406. X`09ilst`5Bi`5D.rla = 0;
  1407. X
  1408. X`09ilst`5B++i`5D.item = 0;`09`09/* terminator */
  1409. X`09ilst`5Bi`5D.len = 0;
  1410. X
  1411. X`09i = 0;
  1412. X`09olst`5Bi`5D.item = NOTES$K_NOTEFILE_NUMNOTES;
  1413. X`09olst`5Bi`5D.len = 4;
  1414. X`09olst`5Bi`5D.buf = (char*) &numnotes;
  1415. X`09olst`5Bi`5D.rla = 0;
  1416. X
  1417. X`09olst`5B++i`5D.item = 0;
  1418. X
  1419. X`09stat = notes$notefile_begin(&nf_context, &ilst, &olst);
  1420. X
  1421. X`09return stat;
  1422. X`7D
  1423. X
  1424. X
  1425. X/**`09notefile_end.
  1426. X*/
  1427. Xnotefile_end()
  1428. X`7B
  1429. X`09int stat, i;
  1430. X
  1431. X`09i = 0;
  1432. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  1433. X`09ilst`5Bi`5D.len = 4;
  1434. X`09ilst`5Bi`5D.buf = (char*) &one;
  1435. X`09ilst`5Bi`5D.rla = 0;
  1436. X
  1437. X`09ilst`5B++i`5D.item = 0;
  1438. X
  1439. X`09olst`5B0`5D.item = 0;
  1440. X
  1441. X`09stat = notes$notefile_end(&nf_context, &ilst, &olst);
  1442. X
  1443. X`09return stat;
  1444. X`7D
  1445. X`09
  1446. X
  1447. X/**`09note_begin.
  1448. X*/
  1449. Xnote_begin()
  1450. X`7B
  1451. X`09int stat, i;
  1452. X
  1453. X`09i = 0;
  1454. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  1455. X`09ilst`5Bi`5D.len = 4;
  1456. X`09ilst`5Bi`5D.buf = (char*) &one;
  1457. X`09ilst`5Bi`5D.rla = 0;
  1458. X
  1459. X`09ilst`5B++i`5D.item = NOTES$K_NOTEFILE_CONTEXT;
  1460. X`09ilst`5Bi`5D.len = 4;
  1461. X`09ilst`5Bi`5D.buf = (char*) &nf_context;
  1462. X`09ilst`5Bi`5D.rla = 0;
  1463. X
  1464. X`09ilst`5B++i`5D.item = 0;
  1465. X
  1466. X`09olst`5B0`5D.item = 0;
  1467. X
  1468. X`09stat = notes$note_begin(¬e_context, &ilst, &olst);
  1469. X
  1470. X`09return stat;
  1471. X`7D
  1472. X
  1473. X
  1474. X/**`09note_end.
  1475. X*/
  1476. Xnote_end()
  1477. X`7B
  1478. X`09int stat, i;
  1479. X
  1480. X`09i = 0;
  1481. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  1482. X`09ilst`5Bi`5D.len = 4;
  1483. X`09ilst`5Bi`5D.buf = (char*) &one;
  1484. X`09ilst`5Bi`5D.rla = 0;
  1485. X
  1486. X`09ilst`5B++i`5D.item = 0;
  1487. X
  1488. X`09olst`5B0`5D.item = 0;
  1489. X
  1490. X`09stat = notes$note_end(¬e_context, &ilst, &olst);
  1491. X
  1492. X`09return stat;
  1493. X`7D
  1494. X
  1495. X
  1496. X/**`09note_delete - delete note specified by current note id.
  1497. X*/
  1498. Xnote_delete()
  1499. X`7B
  1500. X`09int i, stat;
  1501. X`09char junk`5B`5D = "xxxxxxxx xxxxxxxx xxxxxxxx";
  1502. X
  1503. X/*`20
  1504. X *  First delete the user area.  This is because if we delete the
  1505. X *  first note of a series, it doesn't all go away.  If we
  1506. X *  leave the userarea, the note might accidently match a new`20
  1507. X *  note being added.
  1508. X */
  1509. X`09i = 0;
  1510. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  1511. X`09ilst`5Bi`5D.len = 4;
  1512. X`09ilst`5Bi`5D.buf = (char*) &one;
  1513. X`09ilst`5Bi`5D.rla = 0;
  1514. X
  1515. X`09ilst`5B++i`5D.item = NOTES$K_NOTE_ID;
  1516. X`09ilst`5Bi`5D.len = strlen(noteid);
  1517. X`09ilst`5Bi`5D.buf = (char *) ¬eid;
  1518. X`09ilst`5Bi`5D.rla = 0;
  1519. X
  1520. X`09ilst`5B++i`5D.item = NOTES$K_NOTE_USER_AREA;
  1521. X`09ilst`5Bi`5D.buf = junk;
  1522. X`09ilst`5Bi`5D.len = strlen(ilst`5Bi`5D.buf);
  1523. X`09ilst`5Bi`5D.rla = 0;
  1524. X
  1525. X`09ilst`5B++i`5D.item = 0;
  1526. X
  1527. X`09olst`5B0`5D.item = 0;
  1528. X
  1529. X`09stat = notes$note_modify(¬e_context, &ilst, &olst);
  1530. X`09/* ignore bad stat */
  1531. X
  1532. X`09i = 0;
  1533. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  1534. X`09ilst`5Bi`5D.len = 4;
  1535. X`09ilst`5Bi`5D.buf = (char*) &one;
  1536. X`09ilst`5Bi`5D.rla = 0;
  1537. X
  1538. X`09ilst`5B++i`5D.item = NOTES$K_NOTE_ID;
  1539. X`09ilst`5Bi`5D.len = strlen(noteid);
  1540. X`09ilst`5Bi`5D.buf = (char *) ¬eid;
  1541. X`09ilst`5Bi`5D.rla = 0;
  1542. X
  1543. X`09ilst`5B++i`5D.item = 0;
  1544. X
  1545. X`09olst`5B0`5D.item = 0;
  1546. X
  1547. X`09stat = notes$note_delete(¬e_context, &ilst, &olst);
  1548. X
  1549. X`09return stat;
  1550. X`7D
  1551. X
  1552. X
  1553. X/**`09note_modify - modify note specified by current note id.
  1554. X*/
  1555. Xnote_modify(string)
  1556. Xchar *string;`09`09`09`09/* string to add to user data */
  1557. X`7B
  1558. X`09int i, stat;
  1559. X
  1560. X`09i = 0;
  1561. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  1562. X`09ilst`5Bi`5D.len = 4;
  1563. X`09ilst`5Bi`5D.buf = (char*) &one;
  1564. X`09ilst`5Bi`5D.rla = 0;
  1565. X
  1566. X`09ilst`5B++i`5D.item = NOTES$K_NOTE_ID;
  1567. X`09ilst`5Bi`5D.len = strlen(noteid);
  1568. X`09ilst`5Bi`5D.buf = (char *) ¬eid;
  1569. X`09ilst`5Bi`5D.rla = 0;
  1570. X
  1571. X`09ilst`5B++i`5D.item = NOTES$K_NOTE_USER_AREA;
  1572. X`09ilst`5Bi`5D.buf = string;
  1573. X`09ilst`5Bi`5D.len = strlen(ilst`5Bi`5D.buf);
  1574. X`09ilst`5Bi`5D.rla = 0;
  1575. X`09
  1576. X`09ilst`5B++i`5D.item = 0;
  1577. X
  1578. X`09olst`5B0`5D.item = 0;
  1579. X
  1580. X`09stat = notes$note_modify(¬e_context, &ilst, &olst);
  1581. X
  1582. X`09return stat;
  1583. X`7D
  1584. X
  1585. X
  1586. X/**`09note_get_next - get next note.
  1587. X*/
  1588. Xnote_get_next()
  1589. X`7B
  1590. X`09int i, stat;
  1591. X`09static int first = TRUE;
  1592. X
  1593. X`09i = 0;
  1594. X`09ilst`5Bi`5D.item = NOTES$K_NOSIGNAL;
  1595. X`09ilst`5Bi`5D.len = 4;
  1596. X`09ilst`5Bi`5D.buf = (char*) &one;
  1597. X`09ilst`5Bi`5D.rla = 0;
  1598. X
  1599. X`09ilst`5B++i`5D.item = NOTES$K_NOTE_ALL_RESPONSES;
  1600. X`09ilst`5Bi`5D.len = 4;
  1601. X`09ilst`5Bi`5D.buf = (char*) &one;
  1602. X`09ilst`5Bi`5D.rla = 0;
  1603. X
  1604. X`09if (iflag `7C`7C !first) `7B`09`09`09/* if 1 note or not first */
  1605. X`09`09ilst`5B++i`5D.item = NOTES$K_NOTE_ID;
  1606. X`09`09ilst`5Bi`5D.len = strlen(noteid);
  1607. X`09`09ilst`5Bi`5D.buf = (char *) ¬eid;
  1608. X`09`09ilst`5Bi`5D.rla = 0;
  1609. X`09`7D
  1610. X
  1611. X`09if (first) `7B
  1612. X`09`09first = FALSE;
  1613. X`09`7D
  1614. X`09else `7B
  1615. X`09`09ilst`5B++i`5D.item = NOTES$K_NOTE_NEXT_NOTE;
  1616. X`09`09ilst`5Bi`5D.len = 4;
  1617. X`09`09ilst`5Bi`5D.buf = (char*) &one;
  1618. X`09`09ilst`5Bi`5D.rla = 0;
  1619. X`09`7D
  1620. X
  1621. X`09if (since) `7B
  1622. X`09`09ilst`5B++i`5D.item = NOTES$K_NOTE_SINCE_TIME;
  1623. X`09`09ilst`5Bi`5D.len = 8;
  1624. X`09`09ilst`5Bi`5D.buf = sincetime;
  1625. X`09`09ilst`5Bi`5D.rla = 0;
  1626. X`09`7D
  1627. X
  1628. X`09if (before) `7B
  1629. X`09`09ilst`5B++i`5D.item = NOTES$K_NOTE_BEFORE_TIME;
  1630. X`09`09ilst`5Bi`5D.len = 8;
  1631. X`09`09ilst`5Bi`5D.buf = beforetime;
  1632. X`09`09ilst`5Bi`5D.rla = 0;
  1633. X`09`7D
  1634. X
  1635. X`09ilst`5B++i`5D.item = 0;
  1636. X
  1637. X`09i = 0;
  1638. X`09olst`5Bi`5D.item = NOTES$K_NOTE_TITLE;
  1639. X`09olst`5Bi`5D.len = sizeof(title);
  1640. X`09olst`5Bi`5D.buf = title;
  1641. X`09olst`5Bi`5D.rla = &titlel;
  1642. X
  1643. X`09olst`5B++i`5D.item = NOTES$K_NOTE_ID;
  1644. X`09olst`5Bi`5D.len = sizeof(noteid);
  1645. X`09olst`5Bi`5D.buf = (char *) ¬eid;
  1646. X`09olst`5Bi`5D.rla = ¬eidl;
  1647. X
  1648. X`09olst`5B++i`5D.item = NOTES$K_NOTE_CREATE_TIME;
  1649. X`09olst`5Bi`5D.len = 8;
  1650. X`09olst`5Bi`5D.buf = (char *) createtime;
  1651. X`09olst`5Bi`5D.rla = 0;
  1652. X
  1653. X`09olst`5B++i`5D.item = NOTES$K_NOTE_USER_AREA;
  1654. X`09olst`5Bi`5D.buf = userarea;
  1655. X`09olst`5Bi`5D.len = sizeof(userarea) - 1;
  1656. X`09olst`5Bi`5D.rla = &userareal;
  1657. X`09
  1658. X`09olst`5B++i`5D.item = 0;
  1659. X
  1660. X`09stat = notes$note_get(¬e_context, &ilst, &olst);
  1661. X
  1662. X`09return stat;
  1663. X`7D
  1664. X
  1665. X
  1666. X/**`09checkstat.
  1667. X*/
  1668. Xcheckstat(stat, string)
  1669. Xint stat;
  1670. Xchar *string;
  1671. X`7B
  1672. X`09if ((stat & 1) == 1) return;
  1673. X
  1674. X`09fprintf(stdout, "%s: 0x%x\n", string, stat);
  1675. X`09lib$stop(stat);
  1676. X`7D
  1677. X
  1678. X
  1679. X/**`09parsecommand - parse command line.
  1680. X*/
  1681. Xparsecommand(argc, argv)
  1682. Xint argc;
  1683. Xchar *argv`5B`5D;
  1684. X`7B
  1685. X`09int i, stat;
  1686. X`09struct dsc$descriptor_s timbuf = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0`7D
  1687. V;
  1688. X
  1689. X`09for (i = 1; i < argc; i++) `7B
  1690. X`09`09if (argv`5Bi`5D`5B0`5D != '-') `7B`09`09/* if not switch */
  1691. X`09`09`09notefile = argv`5Bi`5D;
  1692. X`09`09`09continue;
  1693. X`09`09`7D
  1694. X
  1695. X`09`09switch (argv`5Bi`5D`5B1`5D) `7B
  1696. X
  1697. X`09`09case 's':`09`09`09/* since time */
  1698. X`09`09`09timbuf.dsc$w_length = strlen(argv`5B++i`5D);
  1699. X`09`09`09timbuf.dsc$a_pointer = argv`5Bi`5D;
  1700. X`09`09`09strtouc(argv`5Bi`5D);
  1701. X`09`09`09stat = sys$bintim(&timbuf, sincetime);
  1702. X`09`09`09checkstat(stat, "bintim");
  1703. X`09`09`09since++;
  1704. X`09`09`09break;
  1705. X
  1706. X`09`09case 'b':`09`09`09/* before time */
  1707. +-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-
  1708.