1: #include "parms.h"
   2: #include "structs.h"
   3: 
   4: #ifdef  RCSIDENT
   5: static char rcsid[] = "$Header: asearch.c,v 1.7 85/01/18 15:04:25 notes Rel $";
   6: #endif	RCSIDENT
   7: 
   8: /*
   9:  *	asearch(io, notenum, respnum, grabname)
  10:  *	int *notenum, *respnum; struct io_f *io;
  11:  *
  12:  *	searches for an article by the specified author. The author to
  13:  *	look for is kept in io->xasys and io->xaname
  14:  *	The search starts with note # notenum, and the respnum'th
  15:  *	response of that note.
  16:  *
  17:  *	The search proceeds out to the end of the response chain and
  18:  *	then goes through the previous note and its responses
  19:  *	--so it is not strictly backwards, but instead is backwards on
  20:  *	the notes and forward within a notes responses.
  21:  *	---This could be changed later.
  22:  *
  23:  *	Returns:	0 nothing found
  24:  *			>0 Found something. Correct place is in
  25:  *			   notenum and respnum....
  26:  *			-1 did not specify a search string!
  27:  *
  28:  *
  29:  *	Ray Essick			Feb 1982
  30:  */
  31: 
  32: asearch (io, notenum, respnum, grabname)
  33: struct io_f *io;
  34: int    *notenum,
  35:        *respnum;
  36: {
  37:     struct note_f   note;
  38:     struct resp_f   rsprec;
  39:     register int    i,
  40:                     j;                  /* scratch counters */
  41:     int     rblock,
  42:             roffset;
  43:     char    buf[SYSSZ + NAMESZ + 5];
  44:     char    author[SYSSZ + NAMESZ + 2];         /* must hold either */
  45:     char    checkit[SYSSZ + NAMESZ + 2];        /* built from note */
  46: 
  47:     if (grabname || (io -> xauthor[0] == '\0'))
  48:     {                           /* get an author */
  49: rekey:                          /* re-enter */
  50:     at (-1, 1);
  51:     printf ("Search author:                          ");
  52:     at (-1, 16);
  53:     i = gline (buf, NNLEN + SYSSZ + 1);     /* grab name */
  54:     at (-1, 1);
  55:     printf ("%*s", i + 15, " ");
  56:     if (i == 1)
  57:         return (-1);                /* no name */
  58:     if (sscanf (buf, "%s", author) == 1)
  59:     {
  60:         strcpy (io -> xauthor, author);     /* load it */
  61:     }
  62:     else
  63:     {
  64:         at (0, 1);
  65:         printf ("Bad author specification - reenter");
  66:         goto rekey;
  67:     }
  68:     }
  69: 
  70:     at (-1, 1);
  71:     printf ("Searching for articles by %s    ", io -> xauthor);
  72:     fflush (stdout);
  73: 
  74:     if (*notenum > io -> descr.d_nnote)         /* check boundaries */
  75:     {
  76:     *respnum = 0;
  77:     *notenum = io -> descr.d_nnote;
  78:     }
  79: 
  80:     for (j = 0; io -> xauthor[j]; j++)          /* force lower case */
  81:     io -> xauthor[j] = tolcase (io -> xauthor[j]);
  82: 
  83:     if (*respnum != 0)
  84:     {
  85:     getnrec (io, *notenum, &note);
  86:     goto inloop;
  87:     }
  88: 
  89:     intflag = 0;                    /* for quit signals */
  90:     while (*notenum > 0)
  91:     {
  92:     getnrec (io, *notenum, &note);
  93:     if (note.n_stat & DELETED)
  94:     {
  95:         (*notenum)--;
  96:         continue;                   /* dead note */
  97:     }
  98: #ifdef  USERHOST
  99:     sprintf (checkit, "%s@%s", note.n_auth.aname, note.n_id.sys);
 100: #else
 101:     sprintf (checkit, "%s!%s", note.n_id.sys, note.n_auth.aname);
 102: #endif	USERHOST
 103:     for (j = strlen (checkit) - 1; j >= 0; j--) /* use lower case */
 104:         checkit[j] = tolcase (checkit[j]);
 105:     if (substr (io -> xauthor, checkit))
 106:         return (*notenum);              /* found him! */
 107:     *respnum = 1;                   /* set it now */
 108: inloop:                         /* start on a resp */
 109:     for (; *respnum <= note.n_nresp; (*respnum)++)
 110:     {
 111:         if (lrsp (io, *notenum, *respnum, &rsprec, &roffset, &rblock) == -1)
 112:         break;
 113: #ifdef  USERHOST
 114:         sprintf (checkit, "%s@%s", rsprec.r_auth[roffset].aname,
 115:             rsprec.r_id[roffset].sys);
 116: #else
 117:         sprintf (checkit, "%s!%s", rsprec.r_id[roffset].sys,
 118:             rsprec.r_auth[roffset].aname);
 119: #endif	USERHOST
 120:         if (substr (io -> xauthor, checkit))
 121:         return * notenum;           /* found him */
 122:         if (intflag)
 123:         break;                  /* impatience */
 124:     }
 125:     *respnum = 0;                   /* make it a main note */
 126:     (*notenum)--;                   /* and proceed to next note */
 127:     if (intflag)
 128:         break;                  /* impatient little boy */
 129:     }
 130:     at (0, 1);
 131:     if (intflag)
 132:     {
 133:     intflag = 0;                    /* don't field same one later */
 134:     printf ("Search aborted");
 135:     }
 136:     else
 137:     {
 138:     printf ("Can't find any articles by %s", io -> xauthor);
 139:     }
 140:     return 0;
 141: }

Defined functions

Defined variables

rcsid defined in line 5; never used
Last modified: 1985-01-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2540
Valid CSS Valid XHTML 1.0 Strict