/* write an attribute to a map (LIBRARY_INTERNAL) * MputAttribute writes exactly the number of bytes specified * by the size argument starting at the address of argument * attr. Which means that you can't simply pass a structure or an * array of structures as argument attr, due to the alignment * of fields within a structure and internal swapping. You can * only pass an array of elementary types (UINT1, REAL4, etc.) * or character string. * If one wants to refresh an attribute, one should first * call MdelAttribute to delete the attribute and then use * MputAttribute to write the new value. * returns argument id or 0 in case of error. * * Merrno * ATTRDUPL * NOACCESS * WRITE_ERROR */ CSF_ATTR_ID CsfPutAttribute( MAP *m, /* map handle */ CSF_ATTR_ID id, /* attribute identification */ size_t itemSize, /* size of each attribute element. * 1 or sizeof(char) in case of a * string */ size_t nitems, /* number of attribute elements or * strlen+1 in case of a variable character * string field. Don't forget to pad a * non-variable field with '\0'! */ void *attr) /* buffer containing attribute */ { size_t size = nitems * itemSize; PRECOND(CsfValidSize(itemSize)); PRECOND(size > 0); if (CsfSeekAttrSpace(m,id,size) == 0) goto error; if (m->write(attr, itemSize, nitems, m->fp) != nitems) { M_ERROR(WRITE_ERROR); goto error; } return(id); /* succes */ error: return(0); /* failure */ }
static CSF_CONV_FUNC ConvFuncBool(CSF_CR cr) { PRECOND(CSF_UNIQ_CR_MASK(cr) < 12); PRECOND(convTableIndex[CSF_UNIQ_CR_MASK(cr)] != -1); return boolConvTable[(int)convTableIndex[CSF_UNIQ_CR_MASK(cr)]]; }
/* Checks a cell on having a lower neighbor. * If the height of a neighbor is less than the height of the * current cell, then the cell has a lower neighbor. * Returns TRUE if this is the case, FALSE otherwise. */ static int HasLowerNeighbor( const MAP_REAL8 *dem, /* dem.map */ const MAP_REAL8 *points, /* points.map */ int rowNr, /* row number of checked cell */ int colNr) /* column number of checked cell */ { REAL8 demVal, newDem; /* heights original cell and neighbor */ REAL8 pntVal; /* if MV, then not a valid lower neighbor */ int i; PRECOND(dem->GetGetTest(dem) == GET_MV_TEST); PRECOND(dem->Get(&demVal, rowNr, colNr, dem)); dem->Get(&demVal, rowNr, colNr, dem); for(i = 1; i <= NR_LDD_DIR; i++) { /* Check all neighbors for being lower */ int rNext = RNeighbor(rowNr, i); int cNext = CNeighbor(colNr, i); if(dem->Get(&newDem, rNext, cNext, dem)&& points->Get(&pntVal, rNext, cNext, points) && (demVal > newDem)) return TRUE; /* has lower neighbor */ } return FALSE; /* no neighbor is lower */ }
/* Initializes a search table. * Returns pointer to initialized table. * */ SEARCH_TABLE *STnew( size_t nrFastList, /* nr. of elements in fast list * these are indexed by their position. * if > 0 then specify ReturnId. */ size_t recSize, /* size of a record */ RETURN_ID ReturnId, /* pointer to function that * returns the id, can be NULL * if nrFastList is 0 or * STinsertOrFind is never used */ INIT_REC InitRec, /* pointer to function to * initialize records in the * fastlist or in the InsertOrFind call, * can be NULL if nrFastList is 0 or * STinsertOrFind is never used */ QSORT_CMP cmp) /* pointer to compare function */ { SEARCH_TABLE *t; PRECOND(cmp != NULL); #ifdef DEBUG if (nrFastList > 0) PRECOND(nrFastList > 0 && ReturnId != NULL && InitRec != NULL); #endif t = (SEARCH_TABLE *)ChkMalloc(sizeof(SEARCH_TABLE)); if(t == NULL) return NULL; /* memory allocation failed */ t->nrFastList = nrFastList; t->recSize = recSize; /* init slowList here so STfree works in this function */ t->slowList = NULL; /* slowlist = empty */ t->nrSlowList = 0; /* nr. elements in slow list */ t->ReturnId = ReturnId; t->cmp = cmp; /* for binary search */ t->InitRec = InitRec; if(nrFastList != 0) { size_t i; char *r; t->fastList = ChkMalloc(nrFastList * recSize); if(t->fastList == NULL) { STfree(t); return NULL; } r = t->fastList; for ( i = 0 ; i < nrFastList; i++) { InitRec((void *)r,(int)i); r += recSize; } } else t->fastList = NULL; # ifdef DEBUG_DEVELOP nrSearchTables++; # endif return t; }
/* Trim string and replace space by single space. * Removes leading and trailing isspace() characters and * substitutes sequences of isspace() chararacters with one * space (that is ' ' not '\t'). * Returns modified string. */ char *LeftRightTabTrim( char *str) /* String to be modified */ { int i, n; PRECOND(str != NULL); n = (int)strlen(str); if (n == 0) return(str); (void)LeftRightTrim(str); /* substitute sequences of isspace() char with one ' ' */ for(n=i=0; str[i] != '\0'; i++) if (isspace(str[i])) { PRECOND(n > 0); /* str[0] is not space, * because leading spaces are removed */ if (!isspace(str[n-1])) str[n++] = ' '; } else str[n++] = str[i]; str[n] = '\0'; return(str); } /* LeftRightTabTrim */
/* wrapper around strcmp() * returns 1 if strings are equal, 0 of not */ int StrEq( const char *s1, /* first string */ const char *s2) /* second string. */ { PRECOND(s1 != NULL); PRECOND(s2 != NULL); return ! strcmp(s1,s2); } /* StrEq */
static int BuildEllipse2(REAL8 xmajor_a, REAL8 yminor_b, REAL8 angle) { int i,nrLines,xCeil; int lineStart,lineEndIncl; REAL8 xIncr,c=cos(angle),s=sin(angle); HOR_CUT_LINE *l; PRECOND(xmajor_a != 0); PRECOND(yminor_b != 0); xmajor_a /= Side(); yminor_b /= Side(); xCeil = (size_t)ceil(xmajor_a); nrLines = (xCeil*2)+1; l = (HOR_CUT_LINE *)ChkMalloc(sizeof(HOR_CUT_LINE)*nrLines); for(i=0; i < nrLines; i++) { /* mark not initialized */ SET_MV_REAL4(&(l[i].start.f)); } for (xIncr = 0; xIncr < xCeil; xIncr+=1) { REAL8 y = sqrt( fabs(1-(sqr(xIncr)/sqr(xmajor_a)))*sqr(yminor_b)); Add2Lines(l,nrLines,xCeil,c,s, xIncr, y); Add2Lines(l,nrLines,xCeil,c,s, xIncr,-y); Add2Lines(l,nrLines,xCeil,c,s,-xIncr, y); Add2Lines(l,nrLines,xCeil,c,s,-xIncr,-y); } if (0) { REAL8 y; xIncr = xmajor_a; y = sqrt( fabs(1-(sqr(xIncr)/sqr(xmajor_a)))*sqr(yminor_b)); Add2Lines(l,nrLines,xCeil,c,s, xIncr, y); Add2Lines(l,nrLines,xCeil,c,s, xIncr,-y); Add2Lines(l,nrLines,xCeil,c,s,-xIncr, y); Add2Lines(l,nrLines,xCeil,c,s,-xIncr,-y); } for(i=0; i < nrLines; i++) { /* mark not initialized */ if (!IS_MV_REAL4(&(l[i].start.f))) break; } POSTCOND(i < nrLines); lineStart = i; for(i = nrLines-1; i >=0;i--) { /* mark not initialized */ if (!IS_MV_REAL4(&(l[i].start.f))) break; } POSTCOND(i >= 0); lineEndIncl = i; for (i=lineStart ; i <= lineEndIncl; i++) { PRECOND(!IS_MV_REAL4(&(l[i].start.f))); l[i].start.i = (int)Rint(l[i].start.f); l[i].end.i = (int)Rint(l[i].end.f); } return 1; }
void CsfSwap(void *buf, size_t size, size_t n) { SWAP l[9] = { NULL, Swap1, Swap2, NULL, Swap4, NULL, NULL, NULL, Swap8}; PRECOND(CsfValidSize(size)); PRECOND(l[size] != NULL); l[size]((unsigned char *)buf,n); }
/* compare strings, ignoring the case of the characters * returns 1 if strings are equal, 0 of not */ int StrCaseEq( const char *s1, /* first string */ const char *s2) /* second string. */ { PRECOND(s1 != NULL); PRECOND(s2 != NULL); return StrNCaseEq(s1,s2, MAX(strlen(s1), strlen(s2)) ); } /* StrCaseEq */
static void Exchange(MAP_INT4 *tmp, INT4 i, INT4 j) { INT4 iv = GetINT4(tmp, i); INT4 jv = GetINT4(tmp, j); PRECOND(i >= 0 && i < (tmp->NrRows(tmp) * tmp->NrCols(tmp))); PRECOND(j >= 0 && j < (tmp->NrRows(tmp) * tmp->NrCols(tmp))); PRECOND(iv >= 0 && iv < (tmp->NrRows(tmp) * tmp->NrCols(tmp))); PRECOND(jv >= 0 && jv < (tmp->NrRows(tmp) * tmp->NrCols(tmp))); PutINT4(iv, j, tmp); PutINT4(jv, i, tmp); }
/* Determines the visibility for each cell in map. * Assumes an UINT1 points map and a spatial REAL8 dem map present. If a * cell has a MV in one of the maps, it gets a MV in the output map also. * Returns 0 if termination is successful, non-zero otherwise */ int View( MAP_UINT1 *out, /* write-only output map */ const MAP_REAL8 *dem, /* Dig. Elevation map */ const MAP_UINT1 *points) /* points map */ { UINT1 pointVal; /* value in points.map */ REAL8 demVal; /* value in dem map */ int r, c , nrRows, nrCols, v = 0; nrRows = dem->NrRows(dem); nrCols = dem->NrCols(dem); PRECOND(nrRows == points->NrRows(points)); PRECOND(nrCols == points->NrCols(points)); /* Fill out with FALSE, this is the initial value */ for(r = 0; r < nrRows; r++) for(c = 0; c < nrCols; c++) { out->Put((UINT1)0, r, c, out); } /* algorithm wants dem->Get() to return FALSE in case of MV */ dem->SetGetTest(GET_MV_TEST, dem); points->SetGetTest(GET_MV_TEST, points); out->SetGetTest(GET_MV_TEST, out); /* For every view point in the points map */ AppProgress("\nBusy with viewpoint:\n"); for (r = 0; r < nrRows; r++) for (c = 0; c < nrCols; c++) { if(dem->Get(&demVal, r, c, dem)&& (points->Get(&pointVal, r, c, points))&& (pointVal)) { v++; AppProgress("\r%d ", v); if(First(out, r, c, dem, points)) return 1; if(Second(out, r, c, dem, points, nrCols)) return 1; if(Third(out, r, c, dem, points, nrRows)) return 1; if(Fourth(out, r, c, dem, points, nrRows, nrCols)) return 1; } } AppEndRowProgress(); return 0; /* successful terminated */ }
static void PutINT4(INT4 val, INT4 linPos, MAP_INT4 *map) { int nrCols = map->NrCols(map); int r = DetRow(nrCols, (int)linPos); int c = DetCol(nrCols, (int)linPos); #ifdef DEBUG int nrRows = map->NrRows(map); PRECOND(0 <= r && r < nrRows); PRECOND(0 <= c && c < nrCols); #endif map->Put(val, r, c, map); }
/* check filename extension. * FileNameExt checks if fileName ends with a period (.) followed * by the given extension. The checks obeys the * conventions of filenames on the current platform (case sensitive or not). * returns 1 if fileName has that extension, 0 of not. */ int FileNameExt( const char *fileName, /* fileName without spaces */ const char *extension) /* the extension without the period */ { const char *p; PRECOND(fileName != NULL); PRECOND(extension != NULL); /* find the position of the extension */ if ( (p=strrchr(fileName, '.')) == NULL) return 0; return FileNamesEq(p+1,extension); }
void *STfindOrInsert( SEARCH_TABLE *t, /* read-write table */ const void *r) /* record to find */ { void *c = STfind(t,r); PRECOND(t->InitRec != NULL); PRECOND(t->ReturnId != NULL); if (c != NULL) return c; c = STinsert(t,r); if (c != NULL) t->InitRec(c,t->ReturnId(r)); return c; }
static CSF_CONV_FUNC ConvFunc(CSF_CR destType, CSF_CR srcType) { PRECOND(CSF_UNIQ_CR_MASK(destType) < 12); PRECOND(CSF_UNIQ_CR_MASK(srcType) < 12); PRECOND(convTableIndex[CSF_UNIQ_CR_MASK(srcType)] != -1); PRECOND(convTableIndex[CSF_UNIQ_CR_MASK(destType)] != -1); /* don't complain on illegal, it can be attached * to a app2file while there's no WRITE_MODE * if it's an error then it's catched in RputSomeCells */ return ConvTable[(int)convTableIndex[CSF_UNIQ_CR_MASK(srcType)]] [(int)convTableIndex[CSF_UNIQ_CR_MASK(destType)]]; }
/* read a stream of cells * RgetSomeCells views a raster as one linear stream of * cells, with row i+1 placed after row i. * In this stream any sequence can be read by specifying an * offset and the number of cells to be read * returns the number of cells read, just as fread * * example * .so examples/somecell.tr */ size_t RgetSomeCells( MAP *map, /* map handle */ size_t offset, /* offset from pixel (row,col) = (0,0) */ size_t nrCells, /* number of cells to be read */ void *buf)/* write-only. Buffer large enough to * hold nrCells cells in the in-file cell representation * or the in-app cell representation. */ { CSF_FADDR readAt; size_t cellsRead; UINT2 inFileCR = RgetCellRepr(map); offset <<= LOG_CELLSIZE(inFileCR); readAt = ADDR_DATA + (CSF_FADDR)offset; fseek(map->fp, (long)readAt, SEEK_SET); cellsRead = map->read(buf, (size_t)CELLSIZE(inFileCR), (size_t)nrCells, map->fp); PRECOND(map->file2app != NULL); map->file2app(nrCells, buf); return(cellsRead); }
static int owner_modify(void) { char *tmp; ne_propname pname = { "http://webdav.org/neon/litmus/", "random" }; ne_proppatch_operation pops[] = { { NULL, ne_propset, "foobar" }, { NULL } }; PRECOND(gotlock); ONV(ne_put(i_session, res, i_foo_fd), ("PUT on locked resource failed: %s", ne_get_error(i_session))); tmp = ne_concat(i_path, "whocares", NULL); ONN("COPY of locked resource", ne_copy(i_session, 1, NE_DEPTH_ZERO, res, tmp) == NE_ERROR); if (STATUS(201)) t_warning("COPY failed with %d not 201", GETSTATUS); ONN("DELETE of locked resource by owner", ne_delete(i_session, tmp) == NE_ERROR); if (STATUS(204)) t_warning("DELETE of %s failed with %d not 200", tmp, GETSTATUS); free(tmp); ONN("PROPPATCH of locked resource", ne_proppatch(i_session, res, pops) == NE_ERROR); if (STATUS(207)) t_warning("PROPPATCH failed with %d", GETSTATUS); return OK; }
/* Gets value of INT4 map at location i. * returns the INT4 value. */ static INT4 GetINT4(const MAP_INT4 *map, /* map to read */ INT4 i) /* location */ { INT4 value; /* value to read */ int nrCols = map->NrCols(map); int r = DetRow(nrCols, i); int c = DetCol(nrCols, i); #ifdef DEBUG int nrRows = map->NrRows(map); PRECOND(0 <= r && r < nrRows); PRECOND(0 <= c && c < nrCols); #endif map->Get(&value, r, c, map); return value; }
/* insert a record in a sorted array with unique ids * InsertSorted copies key to the appropriate place, moving * other elements if necessary. Therefore the array must * have space for one more element. NOTE that no records, * including the key (the new one), * must be equal (all unique id's) * returns the copied record (part of array) */ static void *InsertSorted( const void *key, /* key to be inserted */ void *base, /* array of num+1 elements * with element num being vacant */ size_t num, /* number of elements initially in * base */ size_t width, /* sizeof element */ QSORT_CMP cmp)/* comparisson function */ { int x=0; /* num == 0 case */ int c,l=0; int r=num-1; if (num == 0) goto done; do { x = (l+r)/2; if ( (c = cmp(key, ((char *)base)+(x*width))) < 0) r = x-1; else l = x+1; } while (( c != 0) && l <= r ); POSTCOND(c != 0); /* NOT FOUND */ if (c > 0) x++; /* insertion point is after x */ PRECOND(x <= (int)num); if (x != (int)num) /* no memmove if insertion point is at end */ /* move part of array after insertion point 1 to the right */ (void)memmove( (((char *)base)+((x+1)*width)), (((char *)base)+(x*width)), (num-x)*width ); done: return memcpy((((char *)base)+(x*width)), key, width); }
/* Skip a number of lines in the Lex input * LexSkipLines scans the file, set by LexInstall, * for a certain number of new line characters. * The end-of-file is also viewed as a new line. * returns * * The number of lines that were skipped, which can be smaller * than nrLines if enf-of-file is encountered, or LEX_READ_ERROR * (which is a negative value) */ int LexSkipLines(int nrLines) /* > 0, 1 means skip current line only */ { int c, i=0; PRECOND(nrLines > 0); /* ensure that LexGetTokenValue * returns sensible things */ buf[0] = '\0'; while(1) { read_char: c = fgetc(inFd); switch (c) { case '\n': lineNr++; i++; if (i == nrLines) return i; break; case EOF : return feof(inFd) ? i : LEX_READ_ERROR; case 0x1a: /* skip DOS Ctrl-Z at end of file */ goto read_char; } } /*NOTREACHED*/ return LEX_READ_ERROR; /* never reached */ }
/* compare filenames. * FileNamesEq compares two filenames obeying the naming * conventions of the current platform (case sensitive or not). * returns 1 if filenames are equal, 0 of not */ int FileNamesEq( const char *fileName1, /* first fileName without spaces */ const char *fileName2) /* second fileName without spaces */ { PRECOND(fileName1 != NULL); PRECOND(fileName2 != NULL); #ifdef DOS_FS return StrCaseEq(fileName1, fileName2); #else # ifdef UNIX_FS return StrEq(fileName1, fileName2); # else # error no filesystem defined (UNIX_FS or DOS_FS) # endif #endif }
/* check that locks don't follow copies. */ static int copy(void) { char *dest; int count = 0; PRECOND(gotlock); dest = ne_concat(res, "-copydest", NULL); ne_delete(i_session2, dest); ONNREQ2("could not COPY locked resource", ne_copy(i_session2, 1, NE_DEPTH_ZERO, res, dest)); ONNREQ2("LOCK discovery failed", ne_lock_discover(i_session2, dest, count_discover, &count)); ONV(count != 0, ("found %d locks on copied resource", count)); ONNREQ2("could not delete copy of locked resource", ne_delete(i_session2, dest)); free(dest); return OK; }
/* Drains down from each nonzero point. * If one of the neighbors has a MV it will get a MV as output as well. * All of the lowest neighbors get an extra input from current cell. * Returns 1 if memory allocation fails, 0 otherwise. */ static REAL8 DoDrain( MAP_REAL8 *out, /* read-write output map */ const MAP_REAL8 *dem, /* dem map */ const MAP_REAL8 *points, /* points map */ int r, /* current cell row number */ int c) /* current cell column nr. */ { NODE *list = NULL; REAL8 pntVal; /* value in points.map */ REAL8 drainVal; /* total value to drain down */ PRECOND(points->Get(&pntVal, r, c, points)); points->Get(&pntVal, r, c, points); list = LinkChkReal(list, r, c, pntVal); while(list != NULL) { int rowNr = list->rowNr; int colNr = list->colNr; drainVal = list->val.Real; list = RemFromList(list); if(HasLowerNeighbor(dem, points, rowNr, colNr)) { list = DoNeighbors(out, list, dem, points, rowNr, colNr, drainVal); if(list == NULL) return 1; } } POSTCOND(list == NULL); return 0; }
int tree_add_right(tree* my_tree, tree* adding) { assert(my_tree != NULL); assert(adding != NULL); PRECOND(tree_check(my_tree -> head -> root, NULL) != TREE_CHECK_OK, TREE_BAD, "ADD LEFT ERROR: PRECONDITION FAILED\n"); int tr_counter = 0; VERIFY1(tree_check(my_tree, &tr_counter) == TREE_CHECK_BAD, TREE_INJURED, "# ADD RIGHT ERROR: [%08x] element, tree is broken\n", my_tree); tr_counter = 0; VERIFY1(tree_check(adding, &tr_counter) == TREE_CHECK_BAD, TREE_ADD_INJURED,"# ADD RIGHT ERROR: [%08x] adding element, tree is broken\n", adding); if (my_tree -> right != NULL) return TREE_ALREADY_THERE; my_tree -> right = adding; if (adding -> papa != NULL) { if (adding -> papa -> left == adding) adding -> papa -> left = NULL; if (adding -> papa -> right == adding) adding -> papa -> right = NULL; } adding -> papa = my_tree; adding -> head = my_tree -> head; adding -> head -> size += tr_counter; assert(my_tree -> head); tree_save_head(adding, my_tree -> head); POSTCOND(tree_check(my_tree -> head -> root, NULL) != TREE_CHECK_OK, TREE_BAD, "ADD LEFT ERROR: POSTCONDITION FAILED\n"); return TREE_OK; }
static int copy_overwrite(void) { PRECOND(copy_ok); /* Do it again with Overwrite: F to check that fails. */ ONN("COPY on existing resource with Overwrite: F should fail (RFC2518:S8.8.4)", ne_copy(i_session, 0, NE_DEPTH_INFINITE, src, dest) != NE_ERROR); if (STATUS(412)) { t_warning("COPY-on-existing fails with 412"); } ONV(ne_copy(i_session, 1, NE_DEPTH_INFINITE, src, dest), ("COPY-on-existing with 'Overwrite: T' should succeed (RFC2518:S8.8.4): %s", ne_get_error(i_session))); /* tricky one this, I didn't think it should work, but the spec * makes it look like it should. */ ONV(ne_copy(i_session, 1, NE_DEPTH_INFINITE, src, coll), ("COPY overwrites collection: %s", ne_get_error(i_session))); if (STATUS(204)) { t_warning("COPY to existing resource didn't give 204 (RFC2518:S8.8.5)"); } return OK; }
static size_t DetectNrColsTable( FILE *tableFile) /* file to read */ { LOOK_UP_KEY k; long l =0; int nrCols=0; LexInstall(tableFile, "[]<>,"); while( (!ParseKey(&k, VS_UNDEFINED)) && !TEST_NOKEYREAD(k.t) ) { if (nrCols == 0) l = LexGetLineNr(); else { PRECOND(l!=0); if ( l != LexGetLineNr()) break; } nrCols++; } if (k.t == TEST_ERROR) return RetErrorNested(0,"line '%ld' column '%d':",l,nrCols+1); if (k.t == TEST_NOKEY && nrCols == 0) return RetErrorNested(0,"no columns found"); rewind(tableFile); return nrCols; }
static int notowner_lock(void) { struct ne_lock dummy; PRECOND(gotlock); memcpy(&dummy, &reslock, sizeof(reslock)); dummy.token = ne_strdup("opaquelocktoken:foobar"); dummy.scope = ne_lockscope_exclusive; dummy.owner = ne_strdup("notowner lock"); ONN("UNLOCK with bogus lock token", ne_unlock(i_session2, &dummy) != NE_ERROR); /* 2518 doesn't really say what status code that UNLOCK should * fail with. mod_dav gives a 400 as the locktoken is bogus. */ ONN("LOCK on locked resource", ne_lock(i_session2, &dummy) != NE_ERROR); if (dummy.token) ne_free(dummy.token); if (STATUS2(423)) t_warning("LOCK failed with %d not 423", GETSTATUS2); return OK; }
void *STsearch( const SEARCH_TABLE *t, /* table to search */ SEARCH_REC f) /* */ { size_t i,fastBegin; const void *best; PRECOND(t != NULL && f != NULL); if (t->nrSlowList != 0) { best = t->slowList; for(i = 1; i< t->nrSlowList; i++) best = f(best, (((const char *)(t->slowList))+(i*t->recSize))); fastBegin = 0; } else { best = t->fastList; fastBegin = 1; } for(i = fastBegin; i< t->nrFastList; i++) best = f(best, (((const char *)(t->fastList))+(i*t->recSize))); return (void *)best; }
/* vfprintf-flavour of ErrorNested() * See ErrorNested() for full documentation. */ void vfErrorNested( const char *fmt, /* Format control, see printf() for a description */ va_list marker ) /* Optional arguments */ { char *buf; PRECOND (errorNestLevel < 15); if (!errorNestLevel) { /* reset bufs */ errorBuf[0] = '\0'; ptrs[errorNestLevel] = errorBuf; } buf = ptrs[errorNestLevel]; /* print message in buf */ (void)vsprintf(buf, fmt, marker ); /* remove leading and trailing space and newlines */ (void)LeftRightTrim(buf); ptrs[errorNestLevel+1] = ptrs[errorNestLevel]+strlen(buf)+1; errorNestLevel++; POSTCOND(ptrs[errorNestLevel] < errorBuf+BUF_SIZE); }
/* pad a string attribute with zeros (LIBRARY_INTERNAL) */ char *CsfStringPad(char *s, size_t reqSize) { size_t l = strlen(s); PRECOND(l <= reqSize); (void)memset(s+l, '\0', reqSize-l); return s; }