IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 11, 2006, 10:15:41 PM (20 years ago)
Author:
eugene
Message:

moved global List into ListOps.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.shell/ListOps.c

    r4763 r10647  
    11# include "opihi.h"
    22# include "macro.h"
     3
     4/*** local static variables used to track the command lists  ***/
     5static List *lists;                     /* variable to store the list of all lists */
     6static int  Nlists;                     /* number of currently available lists */
    37
    48void InitLists () {
     
    812}
    913
     14int current_list_depth () {
     15  return Nlists;
     16}
     17
     18int increase_list_depth () {
     19  Nlists ++;
     20  REALLOCATE (lists, List, MAX (Nlists + 1, 0) + 1);
     21  ALLOCATE (lists[Nlists].line, char *, 16);
     22  lists[Nlists].Nalloc = 16;
     23  lists[Nlists].Nlines = 0;
     24  lists[Nlists].n = 0;
     25  return Nlists;
     26}
     27
     28int decrease_list_depth () {
     29 
     30  int i;
     31
     32  for (i = 0; i < lists[Nlists].Nlines; i++) {
     33    free (lists[Nlists].line[i]);
     34  }
     35  free (lists[Nlists].line);
     36  Nlists --;
     37  REALLOCATE (lists, List, MAX (Nlists + 1, 0) + 1);
     38  return Nlists;
     39}
     40
    1041/* return a new string consisting of the next line in the current list */
    1142char *get_next_listentry (int ThisList) {
    1243
     44  int Nline;
    1345  char *output;
    1446
    15   lists[ThisList].n++;
    16 
    17   if (lists[ThisList].n >= lists[Nlists].Nlines)
    18     return ((char *) NULL);
    19 
    20   output = lists[Nlists].line[lists[ThisList].n];
     47  Nline = lists[ThisList].n;
     48
     49  if (Nline >= lists[ThisList].Nlines) return (NULL);
     50
     51  output = strcreate (lists[ThisList].line[Nline]);
     52  lists[ThisList].n ++;
    2153 
    2254  return (output);
    23 
    24 }
    25 
     55}
     56
     57# if (0)
    2658char *remove_listentry (int current) {
    2759
     
    4173  return (output);
    4274
     75}
     76# endif
     77
     78int add_listentry (int ThisList, char *line) {
     79
     80  int Nlines;
     81  char *output;
     82
     83  Nlines = lists[ThisList].Nlines;
     84  lists[ThisList].line[Nlines] = strcreate (line);
     85  lists[ThisList].Nlines ++;
     86
     87  if (lists[ThisList].Nlines == lists[ThisList].Nalloc) {
     88    lists[ThisList].Nalloc += 16;
     89    REALLOCATE (lists[ThisList].line, char *, lists[ThisList].Nalloc);
     90  }
     91   
     92  return (lists[ThisList].Nlines);
    4393}
    4494
Note: See TracChangeset for help on using the changeset viewer.