home *** CD-ROM | disk | FTP | other *** search
- /* ==( gensup/stdsup.c )== */
- /* ----------------------------------------------- */
- /* Pro-C Copyright (C) 1988 - 1990 Vestronix Inc. */
- /* Modification to this source is not supported */
- /* by Vestronix Inc. */
- /* All Rights Reserved */
- /* ----------------------------------------------- */
- /* Written Nig 1-Jan-90 */
- /* Modified Nig 1-Jan-90 */
- /* ----------------------------------------------- */
- /* %W% (%H% %T%) */
-
-
- # include <stdio.h>
- # include <bench.h>
- # include <proc.io>
- # include "field.h"
- # include "iodef.h"
- # include "sup.h"
- # include "screen.h"
-
- /*
- * Get back to beginning of list
- */
- void head_list(tab, head, lptr, mode)
- struct _table *tab;
- struct a_line **head, **lptr;
- int mode;
- {
- if (*lptr != ANULL)
- while ((*lptr)->prev != ANULL)
- (*lptr) = (*lptr)->prev;
-
- *head = *lptr;
-
- if (*lptr != ANULL)
- bytecpy(tab->rec, (*lptr)->rec, tab->size);
-
- /*
- * Display the records
- */
- do_page_mode(tab, head, lptr, mode);
- }
-
- /*
- * Get to end of list, then look back to top of page
- */
- void tail_list(tab, head, lptr, mode)
- struct _table *tab;
- struct a_line **head, **lptr;
- int mode;
- {
- if (*lptr != ANULL)
- while ((*lptr)->next != ANULL)
- (*lptr) = (*lptr)->next;
-
- /*
- * Really the tail at this stage !!
- */
- *head = *lptr;
-
- if ((*head)->index < tab->maximum)
- {
- while ((*head)->prev != ANULL)
- *head = (*head)->prev;
- }
- else
- {
- int i = tab->maximum;
-
- while (--i > 0)
- (*head) = (*head)->prev;
-
- *(tab->index) = tab->maximum - 1;
- }
-
- if (*lptr != ANULL)
- bytecpy(tab->rec, (*lptr)->rec, tab->size);
-
- /*
- * Display the records
- */
- do_page_mode(tab, head, lptr, mode);
- }
-
-
- /*
- * Display full page of records
- */
- void do_page_mode(tab, head, lptr, mode)
- struct _table *tab;
- struct a_line **head, **lptr;
- int mode;
- {
- int idx, ln, curidx, depth;
- struct a_line *tmp, *cur = ANULL;
-
- /*
- * Clear away any previous excess
- */
- tmp = *head;
-
- ln = 0;
-
- idx = *(tab->index);
- *(tab->index) = 0;
-
- if (tab->tabno == 1)
- depth = tab->maximum;
- else
- depth = tab->fn;
-
- while (ln < depth)
- {
- if (tmp == ANULL && ln >= tab->maximum)
- {
- ln++;
- continue;
- }
- /*
- * Set current Record. Doesn't matter if it's NULL
- */
- *lptr = tmp;
- if (tmp != ANULL)
- bytecpy(tab->rec, (*lptr)->rec, tab->size);
-
- if (tab->dsp_fn != (void (*)())0)
- (*tab->dsp_fn)((*(tab->index) == idx) ? UNDERLINED : -1, (*lptr != ANULL && (*lptr)->deleted == FALSE) ? mode : CLR);
-
- if (tmp != ANULL)
- {
- /*
- * Save Ptr to Current Record
- */
- if (*(tab->index) == idx)
- {
- curidx = *(tab->index);
- cur = tmp;
- }
-
- tmp = tmp->next;
- }
- ln++;
- (*(tab->index))++;
- }
-
- /*
- * Don't continue if we are clearing the display
- */
- if (mode == CLR)
- return;
-
- *lptr = cur;
- if (*lptr != ANULL)
- bytecpy(tab->rec, (*lptr)->rec, tab->size);
- *(tab->index) = idx;
- }
-
-
- void before_input(dummy, tab, fld)
- FIELD *dummy;
- struct _table *tab;
- struct fldinfx *fld;
- {
- short tmpi;
- long tmpl;
- unsigned long tmpy;
- float tmpf;
- double tmpd;
-
- /*
- * If there is no mask then the user has selected the field but
- * does not want it displayed. Therefore, we must still copy the
- * value back into dummy->fbuff
- * BOB Aug 9, 1990
- */
- int mask_len = length_mask(dummy);
- int dec_len = decmasklen(dummy->fmask);
- mask_len = (mask_len == 0) ? 80 : mask_len;
- dec_len = (dec_len == 0) ? 5 : dec_len;
-
- switch (fld->fldtype)
- {
- case CHRTYP : /* Don't copy - Use the buffer directly */
- case MEMTYP :
- dummy->fbuff = tab->rec + fld->fldstart;
- break;
- case INTTYP :
- bytecpy((char *)&tmpi, tab->rec + fld->fldstart, sizeof(short));
- sprintf(dummy->fbuff, "%d", tmpi);
- break;
- case LNGTYP :
- bytecpy((char *)&tmpl, tab->rec + fld->fldstart, sizeof(long));
- sprintf(dummy->fbuff, "%ld", tmpl);
- break;
- case FLTTYP :
- bytecpy((char *)&tmpf, tab->rec + fld->fldstart, sizeof(float));
- f_to_a(dummy->fbuff, tmpf, mask_len, dec_len);
- break;
- case DBLTYP :
- bytecpy((char *)&tmpd, tab->rec + fld->fldstart, sizeof(double));
- f_to_a(dummy->fbuff, tmpd, mask_len, dec_len);
- break;
- case DATTYP :
- case TIMTYP :
- switch (fld->fldlen)
- {
- case 6 :
- strcpy(dummy->fbuff, ltocon(dstrtol(tab->rec + fld->fldstart, "YYMMDD"), dummy->fmask, 1));
- break;
- default :
- bytecpy((char *)&tmpy, tab->rec + fld->fldstart, sizeof(long));
- strcpy(dummy->fbuff, ltocon(tmpy, dummy->fmask, 1));
- }
- break;
- }
- }
-
-
- void after_input(dummy, tab, fld)
- FIELD *dummy;
- struct _table *tab;
- struct fldinfx *fld;
- {
- short tmpi;
- unsigned long tmpy;
- long tmpl;
- float tmpf;
- double tmpd;
-
- switch (fld->fldtype)
- {
- case CHRTYP : /* No Need to Copy - Buffer used directly */
- case MEMTYP :
- break;
- case INTTYP :
- tmpi = atoi(dummy->fbuff);
- bytecpy(tab->rec + fld->fldstart, (char *)&tmpi, sizeof(short));
- break;
- case LNGTYP :
- tmpl = atol(dummy->fbuff);
- bytecpy(tab->rec + fld->fldstart, (char *)&tmpl, sizeof(long));
- break;
- case FLTTYP :
- tmpf = (float) atof(dummy->fbuff);
- bytecpy(tab->rec + fld->fldstart, (char *)&tmpf, sizeof(float));
- break;
- case DBLTYP :
- tmpd = atof(dummy->fbuff);
- bytecpy(tab->rec + fld->fldstart, (char *)&tmpd, sizeof(double));
- break;
- case DATTYP :
- case TIMTYP :
- switch (fld->fldlen)
- {
- case 6 :
- bytecpy(tab->rec + fld->fldstart, ltocon(dstrtol(dummy->fbuff, dummy->fmask), "YYMMDD", 1), 6);
- break;
- default :
- tmpy = dstrtol(dummy->fbuff, dummy->fmask);
- bytecpy(tab->rec + fld->fldstart, (char *)&tmpy, sizeof(long));
- }
- break;
- }
- }
-
-
- void table_defaults(tab)
- struct _table *tab;
- {
- tab->inp_fn = (int (*)())0;
- tab->add_fn = (int (*)())0;
- tab->chg_fn = (int (*)())0;
- tab->dsp_fn = VNULL;
- tab->key_fn = VNULL;
- tab->sel_fn = VNULL;
- tab->extra_fn = VNULL;
- tab->goto_fn = (int (*)())0;
- tab->query_box = TRUE;
- tab->messages = TRUE;
- tab->auto_exit = FALSE;
- tab->no_menus = FALSE;
- tab->tp = FALSE;
- tab->fn = 50; /* Maximum to read into 1 list */
- }
-
- /*
- * Compare 2 records field for field
- */
- int cmp_rec(tab, lptr)
- struct _table *tab;
- struct a_line *lptr;
- {
- struct fldinfx *fld = &tab->fld_off[0];
-
- while (fld->fldname != NULL)
- {
- switch (fld->fldtype)
- {
- case CHRTYP : /* Char Types */
- case MEMTYP :
- case DATTYP :
- if (strncmp(tab->rec + fld->fldstart, lptr->rec + fld->fldstart, fld->fldlen))
- return (TRUE);
- break;
- default : /* Numeric Types */
- if (bytecmp(tab->rec + fld->fldstart, lptr->rec + fld->fldstart, fld->fldlen))
- return (TRUE);
- }
-
- fld++;
- }
-
- return (FALSE);
- }
-
-