IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40328 for trunk


Ignore:
Timestamp:
Jan 31, 2018, 9:44:40 AM (8 years ago)
Author:
eugene
Message:

update opihi error messages to have a true message stack

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libohana/src/errors.c

    r31635 r40328  
    11# include "ohana.h"
    22
    3 static char errorline[1024];
     3int Nline = 0;
     4int NLINE = 0;
     5char **errorlines = NULL;
    46
    57int init_error () {
    68
    7   bzero (errorline, 1024);
     9  if (!errorlines) {
     10    NLINE = 10;
     11    ALLOCATE (errorlines, char *, NLINE);
     12    for (int i = 0; i < NLINE; i++) {
     13      errorlines[i] = NULL;
     14    }
     15  }
     16
     17  for (int i = 0; i < NLINE; i++) {
     18    FREE (errorlines[i]);
     19    errorlines[i] = NULL;
     20  }
     21
     22  Nline = 0;
     23
    824  return (TRUE);
    925}
     
    1127int push_error (char *line) {
    1228
    13   bzero (errorline, 1024);
    14   strncpy (errorline, line, 1023);
     29  errorlines[Nline] = strcreate (line);
     30  Nline ++;
     31
     32  if (Nline >= NLINE) {
     33    NLINE += 10;
     34    REALLOCATE (errorlines, char *, NLINE);
     35    for (int i = Nline; i < NLINE; i++) {
     36      errorlines[i] = NULL;
     37    }
     38  }
     39
    1540  return (TRUE);
    1641}
     
    1843int print_error () {
    1944
    20   gprint (GP_ERR, "%s\n", errorline);
     45  for (int i = 0; i < Nline; i++) {
     46    gprint (GP_ERR, "%s\n", errorlines[i]);
     47  }
     48 
     49  init_error();
     50
    2151  return (TRUE);
    2252}
Note: See TracChangeset for help on using the changeset viewer.