IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 10, 2007, 7:43:40 AM (20 years ago)
Author:
eugene
Message:

fixed macro function error, added restrictions to book selections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.data/page.c

    r10997 r11007  
    2424}
    2525
    26 /* return the given book */
     26/* return the given page */
    2727Page *GetPage (Book *book, int where) {
    2828
     
    3333  if (where >= book[0].Npages) return NULL;
    3434  return (book[0].pages[where]);
     35}
     36
     37/* return the given page with key restrictions */
     38Page *GetPageRestricted (Book *book, int where, char *keyName, char *keyValue) {
     39
     40  int i;
     41  int N, Nout;
     42  char *value;
     43
     44  if (where < 0) where += book[0].Npages;
     45  if (where < 0) return NULL;
     46  if (where >= book[0].Npages) return NULL;
     47
     48  if (where >= 0) {
     49    N = -1;
     50    for (i = 0; (i < book[0].Npages) && (N < where); i++) {
     51      value = BookGetWord (book[0].pages[i], keyName);
     52      if ((value == NULL) && !strcmp (keyValue, "NULL")) {
     53        N++;
     54        Nout = i;
     55      }
     56      if ((value != NULL) && !strcmp (keyValue, value)) {
     57        N++;
     58        Nout = i;
     59      }
     60    }
     61  } else {
     62    N = 0;
     63    for (i = book[0].Npages - 1; (i >= 0) && (N > where); i--) {
     64      value = BookGetWord (book[0].pages[i], keyName);
     65      if ((value == NULL) && !strcmp (keyValue, "NULL")) {
     66        N--;
     67      }
     68      if ((value != NULL) && !strcmp (keyValue, value)) {
     69        N--;
     70      }
     71    }
     72  }
     73
     74  if (N != where) return NULL;
     75
     76  return (book[0].pages[Nout]);
    3577}
    3678
Note: See TracChangeset for help on using the changeset viewer.