home *** CD-ROM | disk | FTP | other *** search
- # include <stdio.h>
- # include <bench.h>
- # include <proc.io>
- # include "field.h"
- # include "sup.h"
- # include "screen.h"
- # include "iodef.h"
- # include "passwd.h"
-
-
- /*
- * Read the next record forward or backward, using the
- * next on the list, or from the file if at end of list
- */
- int next_mode(tab, head, lptr, table, mode)
- struct _table *tab;
- struct a_line **head, **lptr;
- int table, mode;
- {
- int stat, try = 0;
-
- /*
- * Cannot read next if no
- * records to start from
- */
- if (*head == ANULL)
- return (IOGOOD);
-
- if (!(tab->perms & PERM_INQUIRE))
- {
- errmsg(ERR_NOINQ);
- return (IOPERM);
- }
-
- /*
- * Display current record in normal attributes
- * if list is > 1 deep
- */
- if (tab->maximum > 1)
- if (tab->dsp_fn != (void (*)())0)
- (*tab->dsp_fn)(REVVID, mode);
-
- /*
- * Make sure we are searching on the right key
- */
- selectinx(tab->fd, *(tab->keynum), *(tab->keymatch), tab->retry);
-
- tab->mode = K_DOWN;
-
- no_msg = !(tab->messages);
-
- stat = nextrec(tab->fd, tab->rec);
-
- /*
- * Try & Lock retry times before failing
- * If No locking is specified, the lock
- * will just re-estgablish the current record
- */
- if (stat != IOEOF)
- while (stat != IOGOOD && ++try <= tab->retry)
- {
- if (stat != IOGOOD && stat != IOLOCKED)
- {
- if (tab->dsp_fn != (void (*)())0)
- (*tab->dsp_fn)(UNDERLINED, mode);
- return (do_error(stat));
- }
-
- stat = lock_rec(tab->fd, tab->rec);
- }
- else
- while (lock_rec(tab->fd, tab->rec) != IOGOOD && ++try <= tab->retry);
-
- if (tab->retry != 0)
- ulock_rec(tab->fd, tab->rec);
-
- if (stat != IOGOOD)
- {
- if (tab->dsp_fn != (void (*)())0)
- (*tab->dsp_fn)(UNDERLINED, mode);
- return (do_error(stat));
- }
-
- if (*(tab->index) == tab->maximum - 1)
- {
- if (tab->maximum > 1)
- {
- reorder_mode(tab, head, lptr, FORWARD);
- do_page_mode(tab, head, lptr, mode);
- }
- /*
- * Display current record hi-lighted
- */
- else if (tab->dsp_fn != (void (*)())0)
- (*tab->dsp_fn)(UNDERLINED, mode);
- }
- else
- {
- if ((*lptr)->next == ANULL)
- new_line(tab, head, lptr);
- else
- {
- *lptr = (*lptr)->next;
- (*(tab->index))++;
- }
-
- /*
- * Display current record hi-lighted
- */
- if (tab->dsp_fn != (void (*)())0)
- (*tab->dsp_fn)(UNDERLINED, mode);
- }
-
- bytecpy((*lptr)->rec, tab->rec, tab->size);
-
- return (stat);
- }
-
-