1: #include "parms.h"
   2: #include "structs.h"
   3: 
   4: #ifdef  RCSIDENT
   5: static char rcsid[] = "$Header: next.c,v 1.7 85/01/18 15:23:59 notes Rel $";
   6: #endif	RCSIDENT
   7: 
   8: /*
   9:  *	next.c -	find the next note/response after a certain time
  10:  *
  11:  *	nxtnote(io, note,date)
  12:  *		finds the next note whith number > note which has been
  13:  *	modified after date. If none exists, a -1 is returned, otherwise
  14:  *	the note number is returned.
  15:  *
  16:  *	nxtresp(io,note,resp,date)
  17:  *		same idea as above, except, we look through the responses
  18:  *	after resp to note # note. If there is no response, we return
  19:  *	a -1, else we return the response number.
  20:  *
  21:  *	inorder(date1, date2) struct when_f *date1, *date2)
  22:  *		return 1 if date1 before date2, otherwise return 0.
  23:  *
  24:  *	Original coding:	Ray Essick	november 1981
  25:  */
  26: 
  27: nxtnote (io, note, date)
  28: struct io_f *io;
  29: struct when_f  *date;
  30: {
  31:     struct note_f   znote;
  32:     if (note < 0)
  33:     note = 0;                   /* start at beginning */
  34: 
  35:     note++;                     /* find starts with next note ! */
  36:     while (note <= io -> descr.d_nnote)
  37:     {
  38:     getnrec (io, note, &znote);         /* get note header */
  39:     if (znote.n_stat & DELETED)
  40:     {
  41:         note++;                 /* go on to the next note */
  42:         continue;                   /* try the next note */
  43:     }
  44:     if (inorder (&znote.n_lmod, date) == 0)     /* want eqauls to show */
  45:         return note;                /* modified after date */
  46:     note++;                     /* go try the next note */
  47:     }
  48:     return (-1);                    /* no deal, wasn't a more recent note */
  49: }
  50: 
  51: nxtresp (io, note, resp, date)
  52: struct io_f *io;
  53: struct when_f  *date;
  54: {
  55:     struct note_f   znote;
  56:     struct resp_f   rrec;
  57:     int     poffset,
  58:             recnum;
  59: 
  60:     getnrec (io, note, &znote);
  61:     if (resp < 0)
  62:     resp = 0;                   /* can't look at negative response */
  63:     resp++;                     /* start search at next response */
  64:     while (resp <= znote.n_nresp)
  65:     {
  66:     if (lrsp (io, note, resp, &rrec, &poffset, &recnum) == -1)
  67:         break;                  /* no response, drop out */
  68:     if (inorder (&rrec.r_rcvd[poffset], date) == 0)
  69:         return resp;                /* return if date earlier or same */
  70:     resp++;
  71:     }
  72:     return (-1);                    /* no later responses to this note */
  73: }
  74: 
  75: /*
  76:  *	see if the time specified by "d1" is before "d2".
  77:  *	this is a STRICT test.  if d1 == d2, they are not
  78:  *	in order.
  79:  */
  80: inorder (d1, d2)
  81: struct when_f  *d1,
  82:                *d2;
  83: {
  84:     if (d1 -> w_gmttime && d2 -> w_gmttime)     /* if both there */
  85:     return (d1 -> w_gmttime < d2 -> w_gmttime); /* relationship */
  86:     if (d1 -> w_year < d2 -> w_year)
  87:     return 1;
  88:     if (d1 -> w_year > d2 -> w_year)
  89:     return 0;
  90: 
  91:     if (d1 -> w_month < d2 -> w_month)
  92:     return 1;
  93:     if (d1 -> w_month > d2 -> w_month)
  94:     return 0;
  95: 
  96:     if (d1 -> w_day < d2 -> w_day)
  97:     return 1;
  98:     if (d1 -> w_day > d2 -> w_day)
  99:     return 0;
 100: 
 101:     if (d1 -> w_hours < d2 -> w_hours)
 102:     return 1;
 103:     if (d1 -> w_hours > d2 -> w_hours)
 104:     return 0;
 105: 
 106:     if (d1 -> w_mins < d2 -> w_mins)
 107:     return 1;
 108:     if (d1 -> w_mins > d2 -> w_mins)
 109:     return 0;
 110: 
 111:     return 0;                       /* equal dates are not in order */
 112: }
Last modified: 1985-01-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2448
Valid CSS Valid XHTML 1.0 Strict