/usr/include/snacc/c/str-stk.h is in libsnacc-dev 1.3bbn-11ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | /*
* str_stk.h - maintains a stack of the components of a bit string
* or octet string so they can be copied into a single chunk
*
*
* CONSTRUCTED BIT AND OCTET STRINGS SUCK. They should be
* specified in the application's ASN.1 spec as SEQUENCE OF OCTET STRING
*
* this stack stuff is for decoding constructed bit/octet strings
* so the user gets a single contiguous bit/octet str instead of
* irritating little pieces. This does not cost a lot more than
* a linked octet/bit string type since we're copying from the
* buffer anyway, not referencing it directly (even in simple case).
* It will cost more if the string stk overflows and
* needs to be enlarged via realloc - set the values of
* initialStkSizeG, and stkGrowSize carefully for your application.
* Once the StkSize grows, it doesn't shrink back ever.
*
* Only three routine use/deal with this stack garbage
* BDecConsAsnOcts
* BDecConsAsnBits
* SetupConsBitsOctsStringStk
*
* Copyright (C) 1992 Michael Sample and the University of British Columbia
*
* This library is free software; you can redistribute it and/or
* modify it provided that this copyright/license information is retained
* in original form.
*
* If you modify this file, you must clearly indicate your changes.
*
* This source code is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/str-stk.h,v 1.2 1995/07/24 21:01:24 rj Exp $
* $Log: str-stk.h,v $
* Revision 1.2 1995/07/24 21:01:24 rj
* changed `_' to `-' in file names.
*
* Revision 1.1 1994/08/28 09:45:41 rj
* first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
*
*/
typedef struct StrStkElmt
{
char *str;
unsigned long int len;
} StrStkElmt;
typedef struct StrStk
{
StrStkElmt *stk; /* ptr to array of SSElmts with 'size' elmts */
unsigned long int initialNumElmts;
unsigned long int numElmts; /* total # of elements in str stk */
unsigned long int growElmts; /* # elmts to increase size by when nec */
unsigned long int nextFreeElmt; /* index of next free element */
unsigned long int totalByteLen; /* octet len of string stored in stk */
} StrStk;
extern StrStk strStkG;
/*
* initializes stk (Allocates if nec.)
* once stk is enlarged, it doesn't shrink
*/
#define RESET_STR_STK()\
{\
strStkG.nextFreeElmt = 0;\
strStkG.totalByteLen = 0;\
if (strStkG.stk == NULL){\
strStkG.stk = (StrStkElmt*) malloc ((strStkG.initialNumElmts) *sizeof (StrStkElmt));\
strStkG.numElmts = strStkG.initialNumElmts;}\
}
/*
* add a char*,len pair to top of stack.
* grows stack if necessary using realloc (!)
*/
#define PUSH_STR(strPtr, strsLen, env)\
{\
if (strStkG.nextFreeElmt >= strStkG.numElmts)\
{\
strStkG.stk = (StrStkElmt*) realloc (strStkG.stk, (strStkG.numElmts + strStkG.growElmts) *sizeof (StrStkElmt));\
strStkG.numElmts += strStkG.growElmts;\
}\
strStkG.totalByteLen += strsLen;\
strStkG.stk[strStkG.nextFreeElmt].str = strPtr;\
strStkG.stk[strStkG.nextFreeElmt].len = strsLen;\
strStkG.nextFreeElmt++;\
}
/*
* Set up size values for the stack that is used for merging constructed
* octet or bit string into single strings.
* **** Call this before decoding anything. *****
* Note: you don't have to call this if the default values
* for initialStkSizeG and stkGrowSizeG are acceptable
*/
#define SetupConsBitsOctsStringStk (initialNumberOfElmts, numberOfElmtsToGrowBy)\
{\
strStkG.initialNumElmts = initialNumberOfElmts; \
strStkG.growElmts = numberOfElmtsToGrowBy;\
}
|