FOSSology  4.4.0
Open Source License Compliance by Open Source Software
util.c
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2006-2009 Hewlett-Packard Development Company, L.P.
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 /* Equivalent to core nomos v1.29 */
7 
14 #include <stdarg.h>
15 #include <stdio.h>
16 #include "nomos.h"
17 #include "util.h"
18 #include "list.h"
19 #include "nomos_regex.h"
20 #include "nomos_utils.h"
21 
22 #define MM_CACHESIZE 20
23 #define MAXLENGTH 100
24 
25 #ifdef REUSE_STATIC_MEMORY
26 static char grepzone[10485760]; /* 10M for now, adjust if needed */
27 #endif /* REUSE_STATIC_MEMORY */
28 
29 /*
30  File local variables
31  */
32 static va_list ap;
33 static char utilbuf[myBUFSIZ];
34 static struct mm_cache mmap_data[MM_CACHESIZE];
35 static char cmdBuf[512];
36 
37 
38 #ifdef MEMORY_TRACING
39 #define MEMCACHESIZ 200000
40 static int memlast = -1;
41 static struct mm_cache memcache[MEMCACHESIZ];
42 void memCacheDump();
43 #endif /* MEMORY_TRACING */
44 
50 int isDIR(char *dpath)
51 {
52 #ifdef PROC_TRACE
53  traceFunc("== isDIR(%s)\n", dpath);
54 #endif /* PROC_TRACE */
55 
56  return(isINODE(dpath, S_IFDIR));
57 }
58 
65 int isEMPTYFILE(char *fpath)
66 {
67 #ifdef PROC_TRACE
68  traceFunc("== isEMPTYFILE(%s)\n", fpath);
69 #endif /* PROC_TRACE */
70 
71  if (!isFILE(fpath)) {
72  return(0);
73  }
74  return(cur.stbuf.st_size == 0);
75 }
76 
83 int isBLOCK(char *bpath)
84 {
85 #ifdef PROC_TRACE
86  traceFunc("== isBLOCK(%s)\n", bpath);
87 #endif /* PROC_TRACE */
88 
89  return(isINODE(bpath, S_IFBLK));
90 }
91 
98 int isCHAR(char *cpath)
99 {
100 #ifdef PROC_TRACE
101  traceFunc("== isCHAR(%s)\n", cpath);
102 #endif /* PROC_TRACE */
103 
104  return(isINODE(cpath, S_IFCHR));
105 }
106 
113 int isPIPE(char *ppath)
114 {
115 #ifdef PROC_TRACE
116  traceFunc("== isPIPE(%s)\n", ppath);
117 #endif /* PROC_TRACE */
118 
119  return(isINODE(ppath, S_IFIFO));
120 }
121 
128 int isSYMLINK(char *spath)
129 {
130 #ifdef PROC_TRACE
131  traceFunc("== isSYMLINK(%s)\n", spath);
132 #endif /* PROC_TRACE */
133 
134  return(isINODE(spath, S_IFLNK));
135 }
136 
143 int isINODE(char *ipath, int typ)
144 {
145  int ret;
146  char sErrorBuf[1024];
147 
148 #ifdef PROC_TRACE
149  traceFunc("== isINODE(%s, 0x%x)\n", ipath, typ);
150 #endif /* PROC_TRACE */
151 
152  if ((ret = stat(ipath, &cur.stbuf)) < 0) {
153  /*
154  IF we're trying to stat() a file that doesn't exist,
155  that's no biggie.
156  Any other error, however, is fatal.
157  */
158  if (errno == ENOENT) {
159  return 0;
160  }
161  strerror_r(errno, sErrorBuf, sizeof(sErrorBuf));
162  LOG_ERROR("Error: %s getting stat on file: %s", sErrorBuf, ipath)
163  }
164  if (typ == 0) {
165  return(1);
166  }
167  return((int)(cur.stbuf.st_mode & S_IFMT & typ));
168 }
169 
175 char *newReloTarget(char *basename)
176 {
177  static char newpath[myBUFSIZ];
178  int i;
179 
180 #ifdef PROC_TRACE
181  traceFunc("== newReloTarget(%s)\n", basename);
182 #endif /* PROC_TRACE */
183 
184  for (i = 0; i < MAX_RENAME; i++) {
185  (void) sprintf(newpath, "%s_%s-renamed.%03d", basename, gl.progName, i);
186  if (access(newpath, F_OK) && errno == ENOENT) {
187  break;
188  }
189  }
190  if (i == MAX_RENAME) {
191  LOG_FATAL("%s: no suitable relocation target (%d tries)", basename, i)
192  Bail(-__LINE__);
193  }
194  return(newpath);
195 }
196 
197 
198 
199 #ifdef MEMORY_TRACING
205 char *memAllocTagged(int size, char *name)
206 {
207  void *ptr;
208  sErrorBuf[1024];
209 
210  /*
211  * we don't track memory allocated; we front-end for errors and return
212  * the pointer we were given.
213  */
214 
215 #if defined(PROC_TRACE) || defined(MEM_ACCT)
216  traceFunc("== memAllocTagged(%d, \"%s\")\n", size, name);
217 #endif /* PROC_TRACE || MEM_ACCT */
218 
219  if (size < 1) {
220  LOG_FATAL("Cannot alloc %d bytes!", size)
221  Bail(-__LINE__);
222  }
223  if (++memlast == MEMCACHESIZ) {
224  LOG_FATAL("*** memAllocTagged: out of memcache entries")
225  Bail(-__LINE__);
226  }
227 #ifdef USE_CALLOC
228  if ((ptr = calloc((size_t) 1, (size_t) size)) == (void *) NULL) {
229  strerror_r(errno, sErrorBuf, sizeof(sErrorBuf));
230  LOG_FATAL("calloc for %s, error: %s", name, sErrorBuf)
231  Bail(-__LINE__);
232  }
233 #else /* not USE_CALLOC */
234  if ((ptr = malloc((size_t) size)) == (void *) NULL) {
235  strerror_r(errno, sErrorBuf, sizeof(sErrorBuf));
236  LOG_FATAL("malloc for %s, error: %s", name, sErrorBuf)
237  Bail(-__LINE__);
238  }
239  (void) memset(ptr, 0, (size_t) size);
240 #endif /* not USE_CALLOC */
241 #if DEBUG > 3 || defined(MEM_ACCT)
242  printf("+%p:%p=(%d)\n", ptr, ptr+size-1, size);
243 #endif /* DEBUG > 3 || MEM_ACCT */
244  memcache[memlast].mmPtr = ptr;
245  memcache[memlast].size = size;
246  (void) strcpy(memcache[memlast].label, name);
247 #ifdef MEM_ACCT
248  printf("memAllocTagged(%d, \"%s\") == %p [entry %04d]\n", size, name, ptr,
249  memlast);
250  /* memCacheDump("post-memAllocTagged:"); */
251 #endif /* MEM_ACCT */
252  return(ptr);
253 }
254 
255 
256 void memFreeTagged(void *ptr, char *note)
257 {
258  struct mm_cache *mmp;
259  int i;
260 
261 #if defined(PROC_TRACE) || defined(MEM_ACCT)
262  traceFunc("== memFree(%p, \"%s\")\n", ptr, note);
263 #endif /* PROC_TRACE || MEM_ACCT */
264 
265 #ifdef MEMORY_TRACING
266  DEBUG("mprobe(%p)\n", ptr)
267  mprobe(ptr); /* see if glibc still likes this memory */
268 #endif /* MEMORY_TRACING */
269  for (mmp = memcache, i = 0; i <= memlast; mmp++, i++) {
270  if (mmp->mmPtr == ptr) {
271 #ifdef MEM_ACCT
272  printf("memFree(%p, \"%s\") is entry %04d (%d bytes)\n", ptr, note, i,
273  mmp->size);
274 #endif /* MEM_ACCT */
275  break;
276  }
277  }
278  if (i > memlast) {
279  LOG_FATAL("Could not locate %p to free!", ptr)
280  Bail(-__LINE__);
281  }
282  free(ptr);
283 #if DEBUG > 3 || defined(MEM_ACCT)
284  printf("-%p=(%d)\n", ptr, mmp->size);
285 #endif /* DEBUG > 3 || MEM_ACCT */
286  if (i != memlast) {
287  (void) memmove(&memcache[i], &memcache[i+1],
288  (memlast-i)*sizeof(struct mm_cache));
289  }
290  memset(&memcache[memlast], 0, sizeof(struct mm_cache));
291  memlast--;
292 #ifdef MEM_ACCT
293  memCacheDump("post-memFree:");
294 #endif /* MEM_ACCT */
295  return;
296 }
297 
298 
299 void memCacheDump(char *s)
300 {
301  struct mm_cache *m;
302  static int first = 1;
303  int i, start;
304  /* */
305  if (s != NULL_STR) {
306  printf("%s\n", s);
307  }
308  if (memlast < 0) {
309  printf("%%%%%% mem-cache is EMPTY\n");
310  return;
311  }
312  start = (memlast > 50 ? memlast-50 : 0);
313  printf("%%%%%% mem-cache @ %p [last=%d]\n", memcache, memlast);
314  for (m = memcache+start, i = start; i <= memlast; m++, i++) {
315  printf("mem-entry %04d: %p (%d) - %s\n", i, m->mmPtr,
316  m->size, m->label);
317  if (!first) {
318  printf("... \"%s\"\n", m->mmPtr);
319  }
320  }
321  printf("%%%%%% mem-cache END\n");
322  if (first) {
323  first --;
324  }
325  return;
326 }
327 #endif /* MEMORY_TRACING */
328 
340 char *findBol(char *s, char *upperLimit)
341 {
342  char *cp;
343 
344 #ifdef PROC_TRACE
345  traceFunc("== findBol(%p, %p)\n", s, upperLimit);
346 #endif /* PROC_TRACE */
347 
348  if (s == NULL_STR || upperLimit == NULL_STR) {
349  return(NULL_STR);
350  }
351  for (cp = s; cp > upperLimit; cp--) {
352 #ifdef DEBUG
353  DEBUG("cp %p upperLimit %p\n", cp, upperLimit)
354 #endif /* DEBUG */
355  if (isEOL(*cp)) {
356 #ifdef DEBUG
357  DEBUG("Got it! BOL == %p\n", cp)
358 #endif /* DEBUG */
359  return((char*)(cp+1));
360  }
361  }
362  if (cp == upperLimit) {
363 #ifdef DEBUG
364  DEBUG("AT upperLimit %p\n", upperLimit);
365 #endif /* DEBUG */
366  return(upperLimit);
367  }
368  return(NULL_STR);
369 }
370 
378 char *findEol(char *s)
379 {
380  char *cp;
381 
382 #ifdef PROC_TRACE
383  traceFunc("== findEol(%p)\n", s);
384 #endif /* PROC_TRACE */
385 
386  if (s == NULL_STR) {
387  return(NULL_STR);
388  }
389  for (cp = s; *cp != NULL_CHAR; cp++) {
390  if (isEOL(*cp)) {
391  return(cp); /* return ptr to EOL or NULL */
392  }
393  }
394  if (*cp == NULL_CHAR) {
395  return(cp);
396  }
397  return(NULL_STR);
398 }
399 
409 void renameInode(char *oldpath, char *newpath)
410 {
411  int err = 0;
412  char sErrorBuf[1024];
413  /*
414  * we die here if the unlink() fails.
415  */
416 
417 #if defined(PROC_TRACE) || defined(UNPACK_DEBUG)
418  traceFunc("== renameInode(%s, %s)\n", oldpath, newpath);
419 #endif /* PROC_TRACE || UNPACK_DEBUG */
420 
421 #ifdef DEBUG
422  (void) mySystem("ls -ldi '%s'", oldpath);
423 #endif /* DEBUG */
424  if (rename(oldpath, newpath) < 0) {
425  if (errno == EXDEV) {
426  err = mySystem("mv '%s' %s", oldpath, newpath);
427  }
428  else {
429  err = 1;
430  }
431  if (err) {
432  strerror_r(errno, sErrorBuf, sizeof(sErrorBuf));
433  LOG_FATAL("rename(%s, %s) error: %s", oldpath, newpath, sErrorBuf)
434  Bail(-__LINE__);
435  }
436  }
437 #ifdef DEBUG
438  (void) mySystem("ls -ldi %s", newpath);
439 #endif /* DEBUG */
440  return;
441 }
442 
450 void chmodInode(char *pathname, int mode)
451 {
452  char sErrorBuf[1024];
453  /*
454  * we die here if the chmod() fails.
455  */
456 
457 #if defined(PROC_TRACE) || defined(UNPACK_DEBUG)
458  traceFunc("== chmodInode(%s, 0%o)\n", pathname, mode);
459 #endif /* PROC_TRACE || UNPACK_DEBUG */
460 
461  if (chmod(pathname, mode) < 0) {
462  strerror_r(errno, sErrorBuf, sizeof(sErrorBuf));
463  LOG_FATAL("chmod(\"%s\", 0%o) error: %s", pathname, mode, sErrorBuf)
464  Bail(-__LINE__);
465  }
466  return;
467 }
468 
476 FILE *fopenFile(char *pathname, char *mode)
477 {
478  FILE *fp;
479  char sErrorBuf[1024];
480  /*
481  * we don't track directories opened; we front-end and return what's
482  * given to us. we die here if the fopen() fails.
483  */
484 
485 #ifdef PROC_TRACE
486  traceFunc("== fopenFile(%s, \"%s\")\n", pathname, mode);
487 #endif /* PROC_TRACE */
488 
489  if ((fp = fopen(pathname, mode)) == (FILE *) NULL) {
490  strerror_r(errno, sErrorBuf, sizeof(sErrorBuf));
491  LOG_FATAL("fopen(%s) error: %s", pathname, sErrorBuf);
492  Bail(-__LINE__);
493  }
494  return(fp);
495 }
496 
497 /*
498  *
499  Save for now, could be useful for debugging
500 
501 static void printListToFile(list_t *l, char *filename, char *mode) {
502  FILE *fp;
503  item_t *ip;
504 
505  fp = fopenFile(filename, mode);
506  while ((ip = listIterate(l)) != NULL_ITEM) {
507  fprintf(fp, "%s\n", ip->str);
508  }
509  (void) fclose(fp);
510  return;
511 }
512  */
513 
521 FILE *popenProc(char *command, char *mode)
522 {
523  FILE *pp;
524  char sErrorBuf[1024];
525  /*
526  * we don't track directories opened; we front-end and return what's
527  * given to us. we die here if the popen() fails.
528  */
529 
530 #ifdef PROC_TRACE
531  traceFunc("== popenProc(\"%s\", %s)\n", command, mode);
532 #endif /* PROC_TRACE */
533 
534  if ((pp = popen(command, mode)) == (FILE *) NULL) {
535 #ifdef MEMORY_TRACING
536  memCacheDump("Post-popen-failure:");
537 #endif /* MEMORY_TRACING */
538  strerror_r(errno, sErrorBuf, sizeof(sErrorBuf));
539  LOG_FATAL("popen(\"%s\") error: %s", command, sErrorBuf)
540  Bail(-__LINE__);
541  }
542  return(pp);
543 }
544 
545 
551 char *wordCount(char *textp)
552 {
553  static char wcbuf[64];
554  int lines;
555  char *cp;
556 
557 #ifdef PROC_TRACE
558  traceFunc("== wordCount(%p)\n", textp);
559 #endif /* PROC_TRACE */
560 
561  lines = 0;
562  for (cp = textp; *cp; cp++) {
563  switch (*cp) {
564  case '\f':
565  break;
566  case '\n':
567  case '\r':
568  case '\v':
569  lines++;
570  break;
571  case ' ':
572  case '\t':
573  break;
574  default:
575  break;
576  }
577  }
578  (void) sprintf(wcbuf, "%d lines", lines);
579  /*
580  * Save these values for use elsewhere, too.
581  */
582  cur.nLines = lines;
583  return(wcbuf);
584 }
585 
593 char *copyString(char *s, char *label)
594 {
595  char *cp;
596  int len;
597 
598 #ifdef PROC_TRACE
599  traceFunc("== copyString(%p, \"%s\")\n", s, label);
600 #endif /* PROC_TRACE */
601 
602  cp = memAlloc(len=(strlen(s)+1), label);
603 #ifdef DEBUG
604  printf("+CS: %d @ %p\n", len, cp);
605 #endif /* DEBUG */
606  (void) strcpy(cp, s);
607  return(cp);
608 }
609 
615 char *pathBasename(char *path)
616 {
617  char *cp;
618 
619 #ifdef PROC_TRACE
620  traceFunc("== pathBasename(\"%s\")\n", path);
621 #endif /* PROC_TRACE */
622 
623  cp = strrchr(path, '/');
624  return(cp == NULL_STR ? path : (char *)(cp+1));
625 }
626 
630 char *getInstances(char *textp, int size, int nBefore, int nAfter, char *regex,
631  int recordOffsets)
632 {
633  int i;
634  int notDone;
635  int buflen = 1;
636  static char *ibuf = NULL;
637  static int bufmax = 0;
638  char *sep = _REGEX(_UTIL_XYZZY);
639  item_t *p;
640  item_t *bp = 0;
641  char *fileeof;
642  char *start;
643  char *end;
644  char *curptr;
645  char *bufmark;
646  char save;
647  char *cp;
648  int newDataLen;
649  int regexFlags = REG_ICASE|REG_EXTENDED;
650 
651 #if defined(PROC_TRACE) || defined(PHRASE_DEBUG) || defined(DOCTOR_DEBUG)
652  traceFunc("== getInstances(%p, %d, %d, %d, \"%s\", %d)\n", textp, size,
653  nBefore, nAfter, regex, recordOffsets);
654 #endif /* PROC_TRACE || PHRASE_DEBUG || DOCTOR_DEBUG */
655 
656  if ((notDone = strGrep(regex, textp, regexFlags)) == 0) {
657 #ifdef PHRASE_DEBUG
658  printf("... no match: 1st strGrep()\n");
659 #endif /* PHRASE_DEBUG */
660  return(NULL_STR);
661  }
662  /*
663  * The global 'offsets list' is indexed by the seed/key (a regex) that we
664  * use for doctoring buffers... each entry will contain a list (containing
665  * the "paragraphs" that match the key) AND its size (e.g., # of 'chunks'),
666  * which also means, if there are N chunks, there are N-1 'xyzzy' separators.
667  */
668  p = listGetItem(&cur.offList, regex);
669  p->seqNo = cur.offList.used;
670  p->nMatch = 0;
671  if (recordOffsets) {
672  if (p->bList) free(p->bList);
673  p->bList = (list_t *)memAlloc(sizeof(list_t), MTAG_LIST);
674  (void) sprintf(utilbuf, "\"%c%c%c%c%c%c%c%c%c%c\" match-list",
675  *regex, *(regex+1), *(regex+2), *(regex+3), *(regex+4),
676  *(regex+5), *(regex+6), *(regex+7), *(regex+8), *(regex+9));
677 #ifdef PHRASE_DEBUG
678  printf("Creating %s\n", utilbuf);
679 #endif /* PHRASE_DEBUG */
680  listInit(p->bList, 0, utilbuf); /* <- MEMORY LEAK from p->bList->items not freed */
681 #ifdef QA_CHECKS
682  p->val3++; /* sanity-check -- should never be >1 ! */
683  if (p->val3 > 1) {
684  LOG_FATAL("Called getInstances(%s) more than once", regex)
685  Bail(-__LINE__);
686  }
687 #endif /* QA_CHECKS */
688  }
689 #ifdef REUSE_STATIC_MEMORY
690  if (ibuf == NULL_STR) { /* first time, uninitialized */
691  ibuf = grepzone;
692  bufmax = sizeof(grepzone);
693  }
694  else if (ibuf != grepzone) {
695  memFree(ibuf, MTAG_DOUBLED); /* free the memory... */
696  ibuf = grepzone; /* ... and reset */
697  bufmax = sizeof(grepzone);
698  }
699 #else /* not REUSE_STATIC_MEMORY */
700  if (ibuf == NULL_STR) {
701  ibuf = memAlloc((bufmax = 1024*1024), MTAG_SEARCHBUF);
702  }
703 #endif /* not REUSE_STATIC_MEMORY */
704  *ibuf = NULL_CHAR;
705  bufmark = ibuf;
706  end = NULL_STR;
707  /*
708  * At this point, we know the string we're looking for is IN the file.
709  */
710 #ifdef PHRASE_DEBUG
711  printf("getInstances: \"%s\" [#1] in buf [%d-%d]\n", regex,
712  cur.regm.rm_so, cur.regm.rm_eo-1);
713  printf("Really in the buffer: [");
714  for (cp = textp + cur.regm.rm_so; cp < (textp + cur.regm.rm_eo); cp++) {
715  printf("%c", *cp);
716  }
717  printf("]\n");
718 #endif /* PHRASE_DEBUG */
719  /*
720  * Find the start of the text line containing the "first" match.
721  * locate start of "$nBefore lines above pattern match"; go up to the
722  * text on the _previous_ line before we 'really start counting'
723  */
724  curptr = textp;
725  fileeof = (char *) (textp+size);
726  while (notDone) { /* curptr is the 'current block' ptr */
727  p->nMatch++;
728 #ifdef PHRASE_DEBUG
729  printf("... found Match #%d\n", p->nMatch);
730 #endif /* PHRASE_DEBUG */
731  if (recordOffsets) {
732  (void) sprintf(utilbuf, "buf%05d", p->nMatch);
733  bp = listGetItem(p->bList, utilbuf);
734  }
735  start = findBol(curptr + cur.regm.rm_so, textp);
736  /*
737  * Go to the beggining of the current line and, if nBefore > 0, go 'up'
738  * in the text "$nBefore" lines. Count 2-consecutive EOL-chars as one
739  * line since some text files use <CR><LF> as line-terminators.
740  */
741  if ((nBefore > 0) && (start > textp)) {
742  for (i = 0; (i < nBefore) && (start > textp); i++) {
743  start -= 2;
744  if ((start > textp) && isEOL(*start)) {
745  start--;
746  }
747  if (start > textp) {
748  start = findBol(start, textp);
749  }
750 #ifdef PHRASE_DEBUG
751  DEBUG("start = %p\n", start)
752 #endif /* PHRASE_DEBUG */
753  }
754  }
755  if (recordOffsets) {
756  bp->bStart = start-textp;
757  }
758  /*
759  * Now do what "grep -A $nAfter _filename+" does.
760  *****
761  * If nAfter == 0, we want the end of the current line.
762  *****
763  * If nAfter > 0, locate the end of the line of LAST occurrence of the
764  * string within the next $nAfter lines. Not well-worded, you say?
765  *****
766  * E.g., if we're saving SIX lines below and we see our pattern 4 lines
767  * below the first match then we'll save 10 lines from the first match.
768  * And to continue this example, if we then see our pattern 9 lines from
769  * the start of the buffer (since we're looking up to 10 lines now), we
770  * will save *15* lines. Repeat until the last 6 lines we save DO NOT
771  * have our pattern.
772  */
773  do {
774  curptr += cur.regm.rm_eo;
775  end = findEol(curptr);
776  if (end < fileeof) {
777  end++; /* first char past end-of-line */
778  }
779  if (nAfter > 0) {
780  for (i = 0; end < fileeof; end++) {
781  if (isEOL(*end)) { /* double-EOL */
782  end++; /* <CR><LF>? */
783  }
784  end = findEol(end);
785  if (end == NULL_STR) {
786  LOG_FATAL("lost the end-of-line")
787  Bail(-__LINE__);
788  }
789  if (*end == NULL_CHAR) {
790  break; /* EOF == done */
791  }
792  if (++i == nAfter) {
793  break;
794  }
795  }
796  if ((end < fileeof) && *end) {
797  end++; /* past newline-char */
798  }
799  }
800 #ifdef PHRASE_DEBUG
801  printf("Snippet, with %d lines below:\n----\n", nAfter);
802  for (cp = start; cp < end; cp++) {
803  printf("%c", *cp);
804  }
805  printf("====\n");
806 #endif /* PHRASE_DEBUG */
807  notDone = strGrep(regex, curptr, regexFlags);
808  if (notDone) { /* another match? */
809 #ifdef PHRASE_DEBUG
810  printf("... next match @ %d:%d (end=%d)\n",
811  curptr - textp + cur.regm.rm_so,
812  curptr - textp + cur.regm.rm_eo - 1, end - textp);
813 #endif /* PHRASE_DEBUG */
814 #ifdef QA_CHECKS
815  if ((curptr + cur.regm.rm_eo) > fileeof) {
816  Assert(YES, "Too far into file!");
817  }
818 #endif /* QA_CHECKS */
819  /* next match OUTSIDE the text we've already saved? */
820  if ((curptr + cur.regm.rm_eo) > end) {
821  break;
822  }
823  /* else, next match IS within the text we're looking at! */
824  }
825  } while (notDone);
826  /*
827  * Add this block of text to our buffer. If 'notdone' is true, there's
828  * at least one more block of text that goes in the buffer, so add the
829  * block-o-text-separator, too. And, make sure we don't overflow our
830  * buffer (BEFORE we modify it); we don't KNOW how much text to expect!
831  */
832  save = *end;
833  *end = NULL_CHAR; /* char PAST the newline! */
834  if (recordOffsets) {
835  bp->bLen = end-start;
836  bp->buf = copyString(start, MTAG_TEXTPARA);
837  bp->bDocLen = 0;
838 #ifdef PHRASE_DEBUG
839  printf("%s starts @%d, len %d ends [%c%c%c%c%c%c%c]\n",
840  utilbuf, bp->bStart, bp->bLen, *(end-8), *(end-7),
841  *(end-6), *(end-5), *(end-4), *(end-3), *(end-2));
842 #endif /* PHRASE_DEBUG */
843  }
844  newDataLen = end-start+(notDone ? strlen(sep)+1 : 0);
845  while (buflen+newDataLen > bufmax) {
846  char *new;
847 #ifdef QA_CHECKS
848  Assert(NO, "data(%d) > bufmax(%d)", buflen+newDataLen,
849  bufmax);
850 #endif /* QA_CHECKS */
851  bufmax *= 2;
852 #ifdef MEMSTATS
853  printf("... DOUBLE search-pattern buffer (%d -> %d)\n",
854  bufmax/2, bufmax);
855 #endif /* MEMSTATS */
856  new = memAlloc(bufmax, MTAG_DOUBLED);
857  (void) memcpy(new, ibuf, buflen);
858 #if 0
859  printf("REPLACING buf %p(%d) with %p(%d)\n", ibuf,
860  bufmax/2, new, bufmax);
861 #endif
862 #ifdef REUSE_STATIC_MEMORY
863  if (ibuf != grepzone) {
864  memFree(ibuf, MTAG_TOOSMALL);
865  }
866 #else /* not REUSE_STATIC_MEMORY */
867  memFree(ibuf, MTAG_TOOSMALL);
868 #endif /* not REUSE_STATIC_MEMORY */
869  ibuf = new;
870  }
871  cp = bufmark = ibuf+buflen-1; /* where the NULL is _now_ */
872  buflen += newDataLen; /* new end-of-data ptr */
873  bufmark += sprintf(bufmark, "%s", start);
874  if (notDone) {
875  bufmark += sprintf(bufmark, "%s\n", sep);
876  }
877  /*
878  * Some files use ^M as a line-terminator, so we need to convert those
879  * control-M's to 'regular newlines' in case we need to use the regex
880  * stuff on this buffer; the regex library apparently doesn't have a
881  * flag for interpretting ^M as end-of-line character.
882  */
883  while (*cp) {
884  if (*cp == '\r') { /* '\015'? */
885  *cp = '\n'; /* '\012'! */
886  }
887  cp++;
888  }
889  *end = save;
890 #ifdef PHRASE_DEBUG
891  printf("Loop end, BUF IS NOW: [\"%s\":%d]\n----\n%s====\n",
892  regex, strlen(ibuf), ibuf);
893 #endif /* PHRASE_DEBUG */
894  }
895 
896 #if defined(PHRASE_DEBUG) || defined(DOCTOR_DEBUG)
897  printf("getInstances(\"%s\"): Found %d bytes of data...\n", regex,
898  buflen-1);
899 #endif /* PHRASE_DEBUG || DOCTOR_DEBUG */
900 #ifdef PHRASE_DEBUG
901  printf("getInstances(\"%s\"): buffer %p --------\n%s\n========\n",
902  regex, ibuf, ibuf);
903 #endif /* PHRASE_DEBUG */
904 
905  return(ibuf);
906 }
907 
913 char *curDate()
914 {
915  static char datebuf[32];
916  char *cp;
917  time_t thyme;
918 
919  (void) time(&thyme);
920  (void) ctime_r(&thyme, datebuf);
921  if ((cp = strrchr(datebuf, '\n')) == NULL_STR) {
922  LOG_FATAL("Unexpected time format from ctime_r()!")
923  Bail(-__LINE__);
924  }
925  *cp = NULL_CHAR;
926  return(datebuf);
927 }
928 
929 
930 #ifdef MEMSTATS
931 void memStats(char *s)
932 {
933  static int first = 1;
934  static char mbuf[128];
935 
936  if (first) {
937  first = 0;
938  sprintf(mbuf, "grep VmRSS /proc/%d/status", getpid());
939  }
940  if (s && *s) {
941  int i;
942  printf("%s: ", s);
943  for (i = (int) (strlen(s)+2); i < 50; i++) {
944  printf(" ");
945  }
946  }
947  (void) mySystem(mbuf);
948 #if 0
949  system("grep Vm /proc/self/status");
950  system("grep Brk /proc/self/status");
951 #endif
952 }
953 #endif /* MEMSTATS */
954 
955 
960 void makeSymlink(char *path)
961 {
962 #if defined(PROC_TRACE) || defined(UNPACK_DEBUG)
963  traceFunc("== makeSymlink(%s)\n", path);
964 #endif /* PROC_TRACE || UNPACK_DEBUG */
965 
966  (void) sprintf(cmdBuf, ".%s", strrchr(path, '/'));
967  if (symlink(path, cmdBuf) < 0) {
968  perror(cmdBuf);
969  LOG_FATAL("Failed: symlink(%s, %s)", path, cmdBuf)
970  Bail(-__LINE__);
971  }
972  return;
973 }
974 
975 
986 void printRegexMatch(int n, int cached)
987 {
988  int save_so;
989  int save_eo;
990  int match;
991  static char debugStr[256];
992  static char misc[64];
993  char *cp;
994  char *x = NULL;
995  char *textp;
996 
997 #ifdef PROC_TRACE
998  traceFunc("== printRegexMatch(%d, %d)\n", n, cached);
999 #endif /* PROC_TRACE */
1000 
1001  if (*debugStr == NULL_CHAR) {
1002  strncpy(debugStr, gl.initwd, sizeof(debugStr)-1);
1003  strncat(debugStr, "/Nomos.strings.txt", sizeof(debugStr)-1);
1004 #ifdef DEBUG
1005  printf("File: %s\n", debugStr);
1006 #endif /* DEBUG */
1007  }
1008  save_so = cur.regm.rm_so;
1009  save_eo = cur.regm.rm_eo;
1010  if (isFILE(debugStr)) {
1011  if ((match = (gl.flags & FL_SAVEBASE))) { /* assignment is deliberate */
1012  gl.flags &= ~FL_SAVEBASE;
1013  }
1014 #ifdef DEBUG
1015  printf("Match [%d:%d]\n", save_so, save_eo);
1016 #endif /* DEBUG */
1017  textp = mmapFile(debugStr);
1018  (void) sprintf(misc, "=#%03d", n);
1019  if (strGrep(misc, textp, REG_EXTENDED)) {
1020 #ifdef DEBUG
1021  printf("Patt: %s\nMatch: %d:%d\n", misc,
1022  cur.regm.rm_so, cur.regm.rm_eo);
1023 #endif /* DEBUG */
1024  x = textp + cur.regm.rm_so;
1025  cp = textp + cur.regm.rm_so;
1026  *x = NULL_CHAR;
1027  while (*--x != '[') {
1028  if (x == textp) {
1029  LOG_FATAL("Cannot locate debug symbol")
1030  Bail(-__LINE__);
1031  }
1032  }
1033  ++x; /* CDB - Moved from line below. Hope this is what was intended.*/
1034  (void) strncpy(misc, x, cp - x); /* CDB - Fix */
1035  misc[cp-x] = NULL_CHAR;
1036  } else {
1037  (void) strcpy(misc, "?");
1038  }
1039  munmapFile(textp);
1040  if (match) {
1041  gl.flags |= FL_SAVEBASE;
1042  }
1043 #ifdef DEBUG
1044  printf("RESTR [%d:%d]\n", cur.regm.rm_so, cur.regm.rm_eo);
1045 #endif /* DEBUG */
1046  }
1047  cur.regm.rm_so = save_so;
1048  cur.regm.rm_eo = save_eo;
1049  printf("%s regex %d ", cached ? "Cached" : "Found", n);
1050  if (x) {
1051  printf("(%s) ", misc);
1052  }
1053  if (!cached) {
1054  printf("\"%s\"", _REGEX(n));
1055  }
1056  printf("\n");
1057 #ifdef DEBUG
1058  printf("Seed: \"%s\"\n", _SEED(n));
1059 #endif /* DEBUG */
1060  return;
1061 }
1062 
1068 void ReplaceNulls(char *Buffer, int BufferSize)
1069 {
1070  char *pBuf;
1071 
1072  for (pBuf = Buffer; BufferSize--; pBuf++)
1073  if (*pBuf == 0) *pBuf = ' ';
1074 }
1075 
1082 char *mmapFile(char *pathname) /* read-only for now */
1083 {
1084  struct mm_cache *mmp;
1085  int i;
1086  int n;
1087  int rem;
1088  char *cp;
1089 
1090 #ifdef PROC_TRACE
1091  traceFunc("== mmapFile(%s)\n", pathname);
1092 #endif /* PROC_TRACE */
1093 
1094  for (mmp = mmap_data, i = 0; i < MM_CACHESIZE; i++, mmp++) {
1095  if (mmp->inUse == 0) {
1096  break;
1097  }
1098  }
1099 
1100  if (i == MM_CACHESIZE) {
1101  printf("mmap-cache too small [%d]!\n", MM_CACHESIZE);
1102  mmapOpenListing();
1103  Bail(12);
1104  }
1105 
1106  if ((mmp->fd = open(pathname, O_RDONLY)) < 0) {
1107  if (errno == ENOENT) {
1108  mmp->inUse = 0; /* overkill? */
1109  mmp->size = -1; /* overkill? */
1110  mmp->mmPtr = (void *) NULL;
1111 #if (DEBUG > 3)
1112  printf("mmapFile: ENOENT %s\n", pathname);
1113 #endif /* DEBUG > 3 */
1114  return(NULL_STR);
1115  }
1116  perror(pathname);
1117  (void) mySystem("ls -l %s", pathname);
1118  LOG_FATAL("%s: open failure!", pathname)
1119  Bail(-__LINE__);
1120  }
1121 
1122  if (fstat(mmp->fd, &cur.stbuf) < 0) {
1123  printf("fstat failure!\n");
1124  perror(pathname);
1125  Bail(13);
1126  }
1127  if (S_ISDIR(cur.stbuf.st_mode)) {
1128  printf("mmapFile(%s): is a directory\n", pathname);
1129  Bail(14);
1130  }
1131 
1132  (void) strcpy(mmp->label, pathname);
1133  if (cur.stbuf.st_size)
1134  {
1135  mmp->size = cur.stbuf.st_size + 1;
1136  mmp->mmPtr = memAlloc(mmp->size, MTAG_MMAPFILE);
1137 #ifdef DEBUG
1138  printf("+MM: %lu @ %p\n", mmp->size, mmp->mmPtr);
1139 #endif /* DEBUG */
1140 
1141  /* Limit scan to first MAX_SCANBYTES
1142  * We have never found a license more than 64k into a file.
1143  */
1144 // if (cur.stbuf.st_size > MAX_SCANBYTES) mmp->size = MAX_SCANBYTES;
1145  if (mmp->size > MAX_SCANBYTES) mmp->size = MAX_SCANBYTES;
1146 
1147 
1148  rem = mmp->size-1;
1149  cp = mmp->mmPtr;
1150  while (rem > 0) {
1151  if ((n = (int) read(mmp->fd, cp, (size_t) rem)) < 0) {
1152  /* log error and move on. This way error will be logged
1153  * but job will continue
1154  */
1155  LOG_WARNING("nomos read error: %s, file: %s, read size: %d, pfile_pk: %ld\n", strerror(errno), pathname, rem, cur.pFileFk);
1156  break;
1157  }
1158  rem -= n;
1159  cp += n;
1160  }
1161  mmp->inUse = 1;
1162  /* Replace nulls with blanks so binary files can be scanned */
1163  ReplaceNulls(mmp->mmPtr, mmp->size-1);
1164  return((char *) mmp->mmPtr);
1165  }
1166  /*
1167  * If we're here, we hit some sort of error.
1168  */
1169  (void) close(mmp->fd);
1170 #ifdef QA_CHECKS
1171  Assert(NO, "mmapFile: returning NULL");
1172 #endif /* QA_CHECKS */
1173  return(NULL_STR);
1174 }
1175 
1176 
1177 void mmapOpenListing()
1178 {
1179  struct mm_cache *mmp;
1180  int i;
1181 
1182  printf("=== mm-cache BEGIN ===\n");
1183  for (mmp = mmap_data, i = 0; i < MM_CACHESIZE; i++, mmp++) {
1184  if (mmp->inUse) {
1185  printf("mm[%d]: (%d) %s:%d\n", i, mmp->fd,
1186  mmp->label, (int) mmp->size);
1187  }
1188  }
1189  printf("--- mm-cache END ---\n");
1190  return;
1191 }
1192 
1197 void munmapFile(void *ptr)
1198 {
1199  struct mm_cache *mmp;
1200  int i;
1201 
1202 #ifdef PROC_TRACE
1203  traceFunc("== munmapFile(%p)\n", ptr);
1204 #endif /* PROC_TRACE */
1205 
1206  if (ptr == (void *) NULL) {
1207 #ifdef QA_CHECKS
1208  Assert(NO, "NULL sent to munmapFile()!");
1209 #endif /* QA_CHECKS */
1210  return;
1211  }
1212  for (mmp = mmap_data, i = 0; i < MM_CACHESIZE; i++, mmp++) {
1213  if (mmp->inUse == 0) {
1214  continue;
1215  }
1216  if (mmp->mmPtr == ptr) {
1217 #if DEBUG > 4
1218  printf("munmapFile: clearing entry %d\n", i);
1219 #endif /* DEBUG > 4 */
1220 #if 0
1221  if (mmp->size) {
1222  (void) munmap((void *) ptr, (size_t) mmp->size);
1223  }
1224 #endif
1225  if (close(mmp->fd) < 0) {
1226  perror("close");
1227  Bail(16);
1228  }
1229 #ifdef PARANOID
1230  mmp->buf = (void *) NULL;
1231 #endif /* PARANOID */
1232  mmp->inUse = 0;
1233 #ifdef DEBUG
1234  printf("DEBUG: munmapFile: freeing %lu bytes\n",
1235  mmp->size);
1236 #endif /* DEBUG */
1237  memFree(mmp->mmPtr, MTAG_MMAPFILE);
1238  break;
1239  }
1240  }
1241  return;
1242 }
1243 
1253 int bufferLineCount(char *p, int len)
1254 {
1255  char *cp;
1256  char *eofaddr = NULL;
1257  int i;
1258 
1259 #ifdef PROC_TRACE
1260  traceFunc("== bufferLineCount(%p, %d)\n", p, len);
1261 #endif /* PROC_TRACE */
1262 
1263  if (eofaddr == p) {
1264  return(0);
1265  }
1266  eofaddr = (char *) (p+len);
1267  for (i = 0, cp = p; cp <= eofaddr; cp++, i++) {
1268  if ((cp = findEol(cp)) == NULL_STR || *cp == NULL_CHAR) {
1269  break;
1270  }
1271  }
1272 #if (DEBUG > 3)
1273  printf("bufferLineCount == %d\n", i);
1274 #endif /* DEBUG > 3 */
1275  return(i ? i : 1);
1276 }
1277 
1283 void appendFile(char *pathname, char *str)
1284 {
1285  FILE *fp;
1286 
1287 #ifdef PROC_TRACE
1288  traceFunc("== appendFile(%s, \"%s\")\n", pathname, str);
1289 #endif /* PROC_TRACE */
1290 
1291  fp = fopenFile(pathname, "a+");
1292  fprintf(fp, "%s\n", str);
1293  (void) fclose(fp);
1294  return;
1295 }
1296 
1303 int mySystem(const char *fmt, ...)
1304 {
1305  int ret;
1306  va_start(ap, fmt);
1307  (void) vsprintf(cmdBuf, fmt, ap);
1308  va_end(ap);
1309 
1310 #if defined(PROC_TRACE) || defined(UNPACK_DEBUG)
1311  traceFunc("== mySystem('%s')\n", cmdBuf);
1312 #endif /* PROC_TRACE || UNPACK_DEBUG */
1313 
1314  ret = system(cmdBuf);
1315  if (WIFEXITED(ret)) {
1316  ret = WEXITSTATUS(ret);
1317 #ifdef DEBUG
1318  if (ret) {
1319  LOG_ERROR("system(%s) returns %d", cmdBuf, ret)
1320  }
1321 #endif /* DEBUG */
1322  }
1323  else if (WIFSIGNALED(ret)) {
1324  ret = WTERMSIG(ret);
1325  LOG_ERROR("system(%s) died from signal %d", cmdBuf, ret)
1326  }
1327  else if (WIFSTOPPED(ret)) {
1328  ret = WSTOPSIG(ret);
1329  LOG_ERROR("system(%s) stopped, signal %d", cmdBuf, ret)
1330  }
1331  return(ret);
1332 }
1333 
1334 
1340 int isFILE(char *pathname)
1341 {
1342 
1343 #ifdef PROC_TRACE
1344  traceFunc("== isFILE(%s)\n", pathname);
1345 #endif /* PROC_TRACE */
1346 
1347  return(isINODE(pathname, S_IFREG));
1348 }
1349 
1350 
1358 int addEntry(char *pathname, int forceFlag, const char *fmt, ...)
1359 {
1360  va_start(ap, fmt);
1361  vsprintf(utilbuf, fmt, ap);
1362  va_end(ap);
1363 
1364 #ifdef PROC_TRACE
1365  traceFunc("== addEntry(%s, %d, \"%s\")\n", pathname, forceFlag, utilbuf);
1366 #endif /* PROC_TRACE */
1367 
1368  if (pathname == NULL_STR) {
1369  Assert(YES, "addEntry - NULL pathname");
1370  }
1371  if (forceFlag || !lineInFile(pathname, utilbuf)) {
1372  appendFile(pathname, utilbuf);
1373  return(1);
1374  }
1375  return(0);
1376 }
1377 
1382 void Msg(const char *fmt, ...)
1383 {
1384  va_start(ap, fmt);
1385  (void) vprintf(fmt, ap);
1386  va_end(ap);
1387  return;
1388 }
1389 
1395 void Assert(int fatalFlag, const char *fmt, ...)
1396 {
1397  va_start(ap, fmt);
1398  (void) sprintf(utilbuf, "ASSERT: ");
1399  (void) vsprintf(utilbuf+strlen(utilbuf), fmt, ap);
1400  va_end(ap);
1401 
1402 #ifdef PROC_TRACE
1403  traceFunc("!! Assert(\"%s\")\n", utilbuf+strlen(gl.progName)+3);
1404 #endif /* PROC_TRACE */
1405 
1406  (void) strcat(utilbuf, "\n");
1407  Msg("%s", utilbuf);
1408  if (fatalFlag) {
1409  Bail(17);
1410  }
1411  return;
1412 }
1413 
1414 
1415 void traceFunc(char *fmtStr, ...)
1416 {
1417  va_list args;
1418 
1419 #ifdef PROC_TRACE_SWITCH
1420  if (gl.ptswitch)
1421 #endif /* PROC_TRACE_SWITCH */
1422  va_start(args, fmtStr);
1423 
1424  vprintf(fmtStr, args);
1425  va_end(args);
1426 #ifdef PROC_TRACE_SWITCH
1427 }
1428 #endif /* PROC_TRACE_SWITCH */
1429 }
1430 
1431 
1432 #ifdef MEM_DEBUG
1433 char *memAllocLogged(int size)
1434 {
1435  register void *ptr;
1436  /* */
1437  ptr = calloc(size, 1);
1438  printf("%p = calloc( %d , 1 )\n", ptr, size);
1439  return(ptr);
1440 }
1441 
1442 void memFreeLogged(void *ptr)
1443 {
1444  printf("free( %p )\n", ptr);
1445  free(ptr);
1446  return;
1447 }
1448 #endif /* MEM_DEBUG */
int s
The socket that the CLI will use to communicate.
Definition: fo_cli.c:37
item_t * listGetItem(list_t *l, char *s)
get an item from the itemlist. If the item is not in the itemlist, then add it to the itemlist.
Definition: list.c:246
void listInit(list_t *l, int size, char *label)
intialize a list, if the list is not empty, empty it (initialize it to zero's).
Definition: list.c:54
char * findBol(char *s, char *upperLimit)
Find Begin of Line in a string.
Definition: util.c:340
int isSYMLINK(char *spath)
Check if given path is a symbolic link.
Definition: util.c:128
void munmapFile(void *ptr)
Definition: util.c:1197
void ReplaceNulls(char *Buffer, int BufferSize)
Replace all nulls in Buffer with blanks.
Definition: util.c:1068
FILE * fopenFile(char *pathname, char *mode)
Open a file and return the file pointer.
Definition: util.c:476
int isFILE(char *pathname)
Check if an inode is a file.
Definition: util.c:1340
int isINODE(char *ipath, int typ)
Check for a inode against a flag.
Definition: util.c:143
int isEMPTYFILE(char *fpath)
Check if given file is empty.
Definition: util.c:65
void printRegexMatch(int n, int cached)
CDB – Need to review this code, particularly for the use of an external file (Nomos....
Definition: util.c:986
char * pathBasename(char *path)
Get the basename from a file path.
Definition: util.c:615
char * getInstances(char *textp, int size, int nBefore, int nAfter, char *regex, int recordOffsets)
Get occurrence of a regex in a given string pointer.
Definition: util.c:630
FILE * popenProc(char *command, char *mode)
Open a process pipe using popen()
Definition: util.c:521
int isDIR(char *dpath)
Check if given path is a directory.
Definition: util.c:50
char * copyString(char *s, char *label)
Create a copy of a string.
Definition: util.c:593
int isPIPE(char *ppath)
Check if given path is a pipe.
Definition: util.c:113
char * curDate()
Get the current date.
Definition: util.c:913
void Assert(int fatalFlag, const char *fmt,...)
Raise an assert.
Definition: util.c:1395
char * wordCount(char *textp)
VERY simple line count, does NOT have to be perfect!
Definition: util.c:551
void renameInode(char *oldpath, char *newpath)
Rename an inode at oldpath to newpath.
Definition: util.c:409
int mySystem(const char *fmt,...)
Run a system command.
Definition: util.c:1303
int isBLOCK(char *bpath)
Check if given path is a Block device.
Definition: util.c:83
#define MM_CACHESIZE
MM Cache size.
Definition: util.c:22
int bufferLineCount(char *p, int len)
Finds the length of first line in a buffer.
Definition: util.c:1253
void appendFile(char *pathname, char *str)
Append a string at the end of the file.
Definition: util.c:1283
void chmodInode(char *pathname, int mode)
Change inode mode bits.
Definition: util.c:450
void makeSymlink(char *path)
Create symbolic links for a given path in current directory.
Definition: util.c:960
char * findEol(char *s)
Find first ROL in a string.
Definition: util.c:378
void Msg(const char *fmt,...)
DO NOT automatically add to a string passed to Msg(); in parseDistro, we sometimes want to dump a p...
Definition: util.c:1382
int addEntry(char *pathname, int forceFlag, const char *fmt,...)
adds a line to the specified pathname
Definition: util.c:1358
int isCHAR(char *cpath)
Check if given path is a character device.
Definition: util.c:98
char * mmapFile(char *pathname)
Blarg. Files that are EXACTLY a multiple of the system pagesize do not get a NULL on the end of the b...
Definition: util.c:1082
char * newReloTarget(char *basename)
Check if a relocation target is accessible.
Definition: util.c:175
char debugStr[myBUFSIZ]
Debug string.
Definition: nomos.c:28
Nomos header file.
#define memFree(x, y)
Definition: nomos.h:531
#define NULL_STR
NULL string.
Definition: nomos.h:235
#define _SEED(x)
Definition: nomos.h:451
#define MAX_RENAME
Max rename length.
Definition: nomos.h:124
#define MAX_SCANBYTES
Definition: nomos.h:131
#define _REGEX(x)
Definition: nomos.h:447
#define isEOL(x)
Check if x points to a EOL character.
Definition: nomos.h:240
#define YES
Definition: nomos.h:175
#define NO
Definition: nomos.h:171
void Bail(int exitval)
Close connections and exit.
Definition: nomos_utils.c:533
#define FL_SAVEBASE
Definition: nomos.h:155
#define NULL_CHAR
NULL character.
Definition: nomos.h:234
int lineInFile(char *pathname, char *regex)
Check if a line exists in a file.
Definition: nomos_regex.c:81
int strGrep(char *regex, char *data, int flags)
General-purpose grep function, used for one-time-only searches.
Definition: nomos_regex.c:139
start($application)
start the application Assumes application is restartable via /etc/init.d/<script>....
Definition: pkgConfig.php:1214
long pFileFk
Definition: nomos.h:396
char initwd[myBUFSIZ]
CDB, would like to workaround/eliminate.
Definition: nomos.h:345
int flags
Flags.
Definition: nomos.h:348
char progName[64]
Program name.
Definition: nomos.h:346
list_t type structure used to keep various lists. (e.g. there are multiple lists).
Definition: nomos.h:308
int used
Definition: nomos.h:310
tricky data structure used for a list of 'items'
Definition: nomos.h:274
void * buf
Definition: nomos.h:279
Store the results of a regex match.
Definition: scanners.hpp:28
int inUse
Cache in use.
Definition: nomos.h:253
int fd
File descriptor.
Definition: nomos.h:254
char label[myBUFSIZ]
Label.
Definition: nomos.h:257
void * mmPtr
Memory pointer.
Definition: nomos.h:256
unsigned long size
Size.
Definition: nomos.h:255