From 75e1e268c3236ab5bfd6d891839260ca7f7b20be Mon Sep 17 00:00:00 2001 From: jbj Date: Fri, 28 May 2004 00:55:56 +0000 Subject: [PATCH] Continue making structures abstarct and opaque. CVS patchset: 7263 CVS date: 2004/05/28 00:55:56 --- rpmio/sexp/sexp-input.c | 40 ++-- rpmio/sexp/sexp-main.c | 7 +- rpmio/sexp/sexp-output.c | 58 ++--- rpmio/sexp/sexp.h | 604 +++++++++++++++++++++++------------------------ 4 files changed, 360 insertions(+), 349 deletions(-) diff --git a/rpmio/sexp/sexp-input.c b/rpmio/sexp/sexp-input.c index 88af197..4f81760 100644 --- a/rpmio/sexp/sexp-input.c +++ b/rpmio/sexp/sexp-input.c @@ -7,6 +7,8 @@ #include #include "sexp.h" +/*@access sexpInputStream @*/ + /**************************************/ /* CHARACTER ROUTINES AND DEFINITIONS */ /**************************************/ @@ -121,7 +123,7 @@ int isAlpha(int c) /* changeInputByteSize(is,newByteSize) */ -void changeInputByteSize(sexpInputStream *is, int newByteSize) +void changeInputByteSize(sexpInputStream is, int newByteSize) { is->byteSize = newByteSize; is->nBits = 0; @@ -136,7 +138,7 @@ void changeInputByteSize(sexpInputStream *is, int newByteSize) * The value EOF is obtained when no more input is available. * This code handles 4-bit/6-bit/8-bit channels. */ -void getChar(sexpInputStream *is) +void getChar(sexpInputStream is) { int c; if (is->nextChar == EOF) { is->byteSize = 8; @@ -190,17 +192,19 @@ void getChar(sexpInputStream *is) * (Prefixes stream with one blank, and initializes stream * so that it reads from standard input.) */ -sexpInputStream *newSexpInputStream(void) +sexpInputStream newSexpInputStream(void) { - sexpInputStream *is; - is = (sexpInputStream *) sexpAlloc(sizeof(*is)); + sexpInputStream is; + is = (sexpInputStream) sexpAlloc(sizeof(*is)); is->nextChar = ' '; is->getChar = getChar; is->count = -1; is->byteSize = 8; is->bits = 0; is->nBits = 0; +/*@-assignexpose@*/ is->inputFile = stdin; +/*@=assignexpose@*/ return is; } @@ -211,7 +215,7 @@ sexpInputStream *newSexpInputStream(void) /* skipWhiteSpace(is) * Skip over any white space on the given sexpInputStream. */ -void skipWhiteSpace(sexpInputStream *is) +void skipWhiteSpace(sexpInputStream is) { while (isWhiteSpace(is->nextChar)) is->getChar(is); } @@ -220,7 +224,7 @@ void skipWhiteSpace(sexpInputStream *is) * Skip the following input character on input stream is, if it is * equal to the character c. If it is not equal, then an error occurs. */ -void skipChar(sexpInputStream *is, int c) +void skipChar(sexpInputStream is, int c) { if (is->nextChar==c) is->getChar(is); @@ -233,7 +237,7 @@ void skipChar(sexpInputStream *is, int c) /* scanToken(is,ss) * scan one or more characters into simple string ss as a token. */ -void scanToken(sexpInputStream *is, sexpSimpleString *ss) +void scanToken(sexpInputStream is, sexpSimpleString *ss) { skipWhiteSpace(is); while (isTokenChar(is->nextChar)) @@ -248,7 +252,7 @@ void scanToken(sexpInputStream *is, sexpSimpleString *ss) * scan one or more characters (until EOF reached) * return an object that is just that string */ -sexpObject *scanToEOF(sexpInputStream *is) +sexpObject *scanToEOF(sexpInputStream is) { sexpSimpleString *ss = newSimpleString(); sexpString *s = newSexpString(); @@ -265,7 +269,7 @@ sexpObject *scanToEOF(sexpInputStream *is) /* scanDecimal(is) * returns long integer that is value of decimal number */ -unsigned long int scanDecimal(sexpInputStream *is) +unsigned long int scanDecimal(sexpInputStream is) { unsigned long int value = 0L; int i = 0; while (isDecDigit(is->nextChar)) @@ -280,7 +284,7 @@ unsigned long int scanDecimal(sexpInputStream *is) /* scanVerbatimString(is,ss,length) * Reads verbatim string of given length into simple string ss. */ -void scanVerbatimString(sexpInputStream *is, sexpSimpleString *ss, long int length) +void scanVerbatimString(sexpInputStream is, sexpSimpleString *ss, long int length) { long int i = 0L; skipWhiteSpace(is); @@ -299,7 +303,7 @@ void scanVerbatimString(sexpInputStream *is, sexpSimpleString *ss, long int leng * Handles ordinary C escapes. * If of indefinite length, length is -1. */ -void scanQuotedString(sexpInputStream *is, sexpSimpleString *ss, long int length) +void scanQuotedString(sexpInputStream is, sexpSimpleString *ss, long int length) { int c; skipChar(is,'"'); @@ -384,7 +388,7 @@ void scanQuotedString(sexpInputStream *is, sexpSimpleString *ss, long int length * Reads hexadecimal string into simple string ss. * String is of given length result, or length = -1 if indefinite length. */ -void scanHexString(sexpInputStream *is, sexpSimpleString *ss, long int length) +void scanHexString(sexpInputStream is, sexpSimpleString *ss, long int length) { changeInputByteSize(is,4); skipChar(is,'#'); while (is->nextChar != EOF && (is->nextChar != '#' || is->byteSize==4)) @@ -404,7 +408,7 @@ void scanHexString(sexpInputStream *is, sexpSimpleString *ss, long int length) * Reads base64 string into simple string ss. * String is of given length result, or length = -1 if indefinite length. */ -void scanBase64String(sexpInputStream *is, sexpSimpleString *ss, long int length) +void scanBase64String(sexpInputStream is, sexpSimpleString *ss, long int length) { changeInputByteSize(is,6); skipChar(is,'|'); while (is->nextChar != EOF && (is->nextChar != '|' || is->byteSize == 6)) @@ -425,7 +429,7 @@ void scanBase64String(sexpInputStream *is, sexpSimpleString *ss, long int length * Determines type of simple string from the initial character, and * dispatches to appropriate routine based on that. */ -sexpSimpleString *scanSimpleString(sexpInputStream *is) +sexpSimpleString *scanSimpleString(sexpInputStream is) { long int length; sexpSimpleString *ss; @@ -460,7 +464,7 @@ sexpSimpleString *scanSimpleString(sexpInputStream *is) /* scanString(is) * Reads and returns a string [presentationhint]string from input stream. */ -sexpString *scanString(sexpInputStream *is) +sexpString *scanString(sexpInputStream is) { sexpString *s; sexpSimpleString *ss; @@ -483,7 +487,7 @@ sexpString *scanString(sexpInputStream *is) /* scanList(is) * Read and return a sexpList from the input stream. */ -sexpList *scanList(sexpInputStream *is) +sexpList *scanList(sexpInputStream is) { sexpList *list; sexpObject *object; skipChar(is,'('); @@ -515,7 +519,7 @@ sexpList *scanList(sexpInputStream *is) /* scanObject(is) * Reads and returns a sexpObject from the given input stream. */ -sexpObject *scanObject(sexpInputStream *is) +sexpObject *scanObject(sexpInputStream is) { sexpObject *object; skipWhiteSpace(is); diff --git a/rpmio/sexp/sexp-main.c b/rpmio/sexp/sexp-main.c index bdf9a29..0a779f8 100644 --- a/rpmio/sexp/sexp-main.c +++ b/rpmio/sexp/sexp-main.c @@ -9,6 +9,9 @@ #include #include "sexp.h" +/*@access sexpInputStream @*/ +/*@access sexpOutputStream @*/ + /*@unchecked@*/ /*@observer@*/ static const char *help = "The program `sexp' reads, parses, and prints out S-expressions.\n" @@ -102,8 +105,8 @@ int main(int argc, char **argv) poptContext optCon; int rc; sexpObject *object; - sexpInputStream *is; - sexpOutputStream *os; + sexpInputStream is; + sexpOutputStream os; initializeCharacterTables(); initializeMemory(); diff --git a/rpmio/sexp/sexp-output.c b/rpmio/sexp/sexp-output.c index 647639e..dc77f9e 100644 --- a/rpmio/sexp/sexp-output.c +++ b/rpmio/sexp/sexp-output.c @@ -7,6 +7,8 @@ #include #include "sexp.h" +/*@access sexpOutputStream @*/ + /*@unchecked@*/ /*@observer@*/ static char *hexDigits = "0123456789ABCDEF"; @@ -22,7 +24,7 @@ static char *base64Digits = * Puts the character c out on the output stream os. * Keeps track of the "column" the next output char will go to. */ -void putChar(sexpOutputStream *os, int c) +void putChar(sexpOutputStream os, int c) { (void) putc(c,os->outputFile); os->column++; @@ -31,7 +33,7 @@ void putChar(sexpOutputStream *os, int c) /* varPutChar(os,c) * putChar with variable sized output bytes considered. */ -void varPutChar(sexpOutputStream *os, int c) +void varPutChar(sexpOutputStream os, int c) { c &= 0xFF; os->bits = (os->bits << 8) | c; @@ -60,7 +62,7 @@ void varPutChar(sexpOutputStream *os, int c) * Change os->byteSize to newByteSize * record mode in output stream for automatic line breaks */ -void changeOutputByteSize(sexpOutputStream *os, int newByteSize, int mode) +void changeOutputByteSize(sexpOutputStream os, int newByteSize, int mode) { if (newByteSize != 4 && newByteSize !=6 && newByteSize !=8) ErrorMessage(ERROR,"Illegal output base %d.",newByteSize); @@ -77,7 +79,7 @@ void changeOutputByteSize(sexpOutputStream *os, int newByteSize, int mode) /* flushOutput(os) * flush out any remaining bits */ -void flushOutput(sexpOutputStream * os) +void flushOutput(sexpOutputStream os) { if (os->nBits > 0) { if (os->byteSize == 4) @@ -104,7 +106,7 @@ void flushOutput(sexpOutputStream * os) * indentation level (but never indents more than half of maxcolumn). * Resets column for next output character. */ -void newLine(sexpOutputStream *os, int mode) +void newLine(sexpOutputStream os, int mode) { int i; if (mode == ADVANCED || mode == BASE64) { os->putChar(os,'\n'); @@ -118,10 +120,10 @@ void newLine(sexpOutputStream *os, int mode) /* newSexpOutputStream() * Creates and initializes new sexpOutputStream object. */ -sexpOutputStream *newSexpOutputStream(void) +sexpOutputStream newSexpOutputStream(void) { - sexpOutputStream *os; - os = (sexpOutputStream *) sexpAlloc(sizeof(*os)); + sexpOutputStream os; + os = (sexpOutputStream) sexpAlloc(sizeof(*os)); os->column = 0; os->maxcolumn = DEFAULTLINELENGTH; os->indent = 0; @@ -130,7 +132,9 @@ sexpOutputStream *newSexpOutputStream(void) os->byteSize = 8; os->bits = 0; os->nBits = 0; +/*@-assignexpose@*/ os->outputFile = stdout; +/*@=assignexpose@*/ os->mode = CANONICAL; return os; } @@ -142,7 +146,7 @@ sexpOutputStream *newSexpOutputStream(void) /* printDecimal(os,n) * print out n in decimal to output stream os */ -void printDecimal(sexpOutputStream *os, long int n) +void printDecimal(sexpOutputStream os, long int n) { char buffer[50]; int i; /*@-bufferoverflowhigh@*/ @@ -159,7 +163,7 @@ void printDecimal(sexpOutputStream *os, long int n) /* canonicalPrintVerbatimSimpleString(os,ss) * Print out simple string ss on output stream os as verbatim string. */ -void canonicalPrintVerbatimSimpleString(sexpOutputStream *os, sexpSimpleString *ss) +void canonicalPrintVerbatimSimpleString(sexpOutputStream os, sexpSimpleString *ss) { long int len = simpleStringLength(ss); long int i; @@ -177,7 +181,7 @@ void canonicalPrintVerbatimSimpleString(sexpOutputStream *os, sexpSimpleString * /* canonicalPrintString(os,s) * Prints out sexp string s onto output stream os */ -void canonicalPrintString(sexpOutputStream *os, sexpString *s) +void canonicalPrintString(sexpOutputStream os, sexpString *s) { sexpSimpleString *ph, *ss; ph = sexpStringPresentationHint(s); if (ph != NULL) { @@ -195,7 +199,7 @@ void canonicalPrintString(sexpOutputStream *os, sexpString *s) /* canonicalPrintList(os,list) * Prints out the list "list" onto output stream os */ -void canonicalPrintList(sexpOutputStream *os, sexpList *list) +void canonicalPrintList(sexpOutputStream os, sexpList *list) { sexpIter iter; sexpObject *object; varPutChar(os,'('); @@ -213,7 +217,7 @@ void canonicalPrintList(sexpOutputStream *os, sexpList *list) * Prints out object on output stream os * Note that this uses the common "type" field of lists and strings. */ -void canonicalPrintObject(sexpOutputStream *os, sexpObject *object) +void canonicalPrintObject(sexpOutputStream os, sexpObject *object) { if (isObjectString(object)) canonicalPrintString(os,(sexpString *)object); @@ -227,7 +231,7 @@ void canonicalPrintObject(sexpOutputStream *os, sexpObject *object) /* *************/ /* Same as canonical, except all characters get put out as base 64 ones */ -void base64PrintWholeObject(sexpOutputStream *os, sexpObject *object) +void base64PrintWholeObject(sexpOutputStream os, sexpObject *object) { changeOutputByteSize(os,8,BASE64); varPutChar(os,'{'); @@ -248,7 +252,7 @@ void base64PrintWholeObject(sexpOutputStream *os, sexpObject *object) * Returns TRUE if simple string ss can be printed as a token. * Doesn't begin with a digit, and all characters are tokenchars. */ -int canPrintAsToken(sexpOutputStream *os, sexpSimpleString *ss) +int canPrintAsToken(sexpOutputStream os, sexpSimpleString *ss) { int i; octet *c; @@ -269,7 +273,7 @@ int canPrintAsToken(sexpOutputStream *os, sexpSimpleString *ss) * Prints out simple string ss as a token (assumes that this is OK). * May run over max-column, but there is no fragmentation allowed... */ -void advancedPrintTokenSimpleString(sexpOutputStream *os, sexpSimpleString *ss) +void advancedPrintTokenSimpleString(sexpOutputStream os, sexpSimpleString *ss) { int i; long int len; octet *c; @@ -294,7 +298,7 @@ int advancedLengthSimpleStringToken(sexpSimpleString *ss) * Print out simple string ss on output stream os as verbatim string. * Again, can't fragment string, so max-column is just a suggestion... */ -void advancedPrintVerbatimSimpleString(sexpOutputStream *os, sexpSimpleString *ss) +void advancedPrintVerbatimSimpleString(sexpOutputStream os, sexpSimpleString *ss) { long int len = simpleStringLength(ss); long int i; @@ -324,7 +328,7 @@ int advancedLengthSimpleStringVerbatim(sexpSimpleString *ss) /* advancedPrintBase64SimpleString(os,ss) * Prints out simple string ss as a base64 value. */ -void advancedPrintBase64SimpleString(sexpOutputStream *os, sexpSimpleString *ss) +void advancedPrintBase64SimpleString(sexpOutputStream os, sexpSimpleString *ss) { long int i,len; octet *c = simpleStringString(ss); @@ -345,7 +349,7 @@ void advancedPrintBase64SimpleString(sexpOutputStream *os, sexpSimpleString *ss) /* advancedPrintHexSimpleString(os,ss) * Prints out simple string ss as a hexadecimal value. */ -void advancedPrintHexSimpleString(sexpOutputStream *os, sexpSimpleString *ss) +void advancedPrintHexSimpleString(sexpOutputStream os, sexpSimpleString *ss) { long int i,len; octet *c = simpleStringString(ss); @@ -394,7 +398,7 @@ int canPrintAsQuotedString(sexpSimpleString *ss) * so no escape sequences need to be generated. * May run over max-column, but there is no fragmentation allowed... */ -void advancedPrintQuotedStringSimpleString(sexpOutputStream *os, sexpSimpleString *ss) +void advancedPrintQuotedStringSimpleString(sexpOutputStream os, sexpSimpleString *ss) { long int i; long int len = simpleStringLength(ss); octet *c = simpleStringString(ss); @@ -424,7 +428,7 @@ int advancedLengthSimpleStringQuotedString(sexpSimpleString *ss) /* advancedPrintSimpleString(os,ss) * Prints out simple string ss onto output stream ss */ -void advancedPrintSimpleString(sexpOutputStream *os, sexpSimpleString *ss) +void advancedPrintSimpleString(sexpOutputStream os, sexpSimpleString *ss) { long int len = simpleStringLength(ss); if (canPrintAsToken(os,ss)) advancedPrintTokenSimpleString(os,ss); @@ -441,7 +445,7 @@ void advancedPrintSimpleString(sexpOutputStream *os, sexpSimpleString *ss) /* advancedPrintString(os,s) * Prints out sexp string s onto output stream os */ -void advancedPrintString(sexpOutputStream *os, sexpString *s) +void advancedPrintString(sexpOutputStream os, sexpString *s) { sexpSimpleString *ph = sexpStringPresentationHint(s); sexpSimpleString *ss = sexpStringString(s); @@ -465,7 +469,7 @@ int advancedLengthSimpleStringBase64(sexpSimpleString *ss) /* advancedLengthSimpleString(os,ss) * Returns length of printed image of s */ -int advancedLengthSimpleString(sexpOutputStream *os, sexpSimpleString *ss) +int advancedLengthSimpleString(sexpOutputStream os, sexpSimpleString *ss) { long int len = simpleStringLength(ss); if (canPrintAsToken(os,ss)) return advancedLengthSimpleStringToken(ss); @@ -482,7 +486,7 @@ int advancedLengthSimpleString(sexpOutputStream *os, sexpSimpleString *ss) /* advancedLengthString(os,s) * Returns length of printed image of string s */ -int advancedLengthString(sexpOutputStream *os, sexpString *s) +int advancedLengthString(sexpOutputStream os, sexpString *s) { int len = 0; sexpSimpleString *ph = sexpStringPresentationHint(s); sexpSimpleString *ss = sexpStringString(s); @@ -496,7 +500,7 @@ int advancedLengthString(sexpOutputStream *os, sexpString *s) /* advancedLengthList(os,list) * Returns length of printed image of list given as iterator */ -int advancedLengthList(sexpOutputStream *os, sexpList *list) +int advancedLengthList(sexpOutputStream os, sexpList *list) { int len = 1; /* for left paren */ sexpIter iter; sexpObject *object; @@ -523,7 +527,7 @@ int advancedLengthList(sexpOutputStream *os, sexpList *list) * written out in "vertical" mode, with items of the list starting in * the same column on successive lines. */ -void advancedPrintList(sexpOutputStream *os, sexpList *list) +void advancedPrintList(sexpOutputStream os, sexpList *list) { int vertical = FALSE; int firstelement = TRUE; sexpIter iter; @@ -554,7 +558,7 @@ void advancedPrintList(sexpOutputStream *os, sexpList *list) /* advancedPrintObject(os,object) * Prints out object on output stream os */ -void advancedPrintObject(sexpOutputStream *os, sexpObject *object) +void advancedPrintObject(sexpOutputStream os, sexpObject *object) { if (os->maxcolumn>0 && os->column>os->maxcolumn-4) os->newLine(os,ADVANCED); diff --git a/rpmio/sexp/sexp.h b/rpmio/sexp/sexp.h index 1106a95..cd2cdb7 100644 --- a/rpmio/sexp/sexp.h +++ b/rpmio/sexp/sexp.h @@ -1,302 +1,302 @@ -/* SEXP standard header file: sexp.h - * Ronald L. Rivest - * 6/29/1997 - */ - -/* GLOBAL DECLARATIONS */ -#define TRUE 1 -#define FALSE 0 - -/* PRINTING MODES */ -#define CANONICAL 1 /* standard for hashing and tranmission */ -#define BASE64 2 /* base64 version of canonical */ -#define ADVANCED 3 /* pretty-printed */ - -/* ERROR MESSAGE LEVELS */ -#define WARNING 1 -#define ERROR 2 - -#define DEFAULTLINELENGTH 75 - -typedef unsigned char octet; - -/* TYPES OF OBJECTS */ -#define SEXP_STRING 1 -#define SEXP_LIST 2 - -/* sexpSimpleString */ -typedef struct sexp_simplestring { - long int length; - long int allocatedLength; -/*@null@*/ - octet *string; -} sexpSimpleString; - -/* sexpString */ -typedef struct sexp_string { - int type; -/*@null@*/ - sexpSimpleString *presentationHint; -/*@null@*/ - sexpSimpleString *string; -} sexpString; - -/* sexpList */ -/* If first is NULL, then rest must also be NULL; this is empty list */ -typedef struct sexp_list { - char type; -/*@null@*/ - union sexp_object *first; -/*@null@*/ - struct sexp_list *rest; -} sexpList; - -/* sexpObject */ -/* so we can have a pointer to something of either type */ -typedef union sexp_object { -/*@unused@*/ - sexpString string; -/*@unused@*/ - sexpList list; -} sexpObject; - -/* sexpIter */ -/* an "iterator" for going over lists */ -/* In this implementation, it is the same as a list */ -typedef /*@abstract@*/ sexpList * sexpIter; - -typedef struct sexp_inputstream { - int nextChar; /* character currently being scanned */ - int byteSize; /* 4 or 6 or 8 == currently scanning mode */ - int bits; /* Bits waiting to be used */ - int nBits; /* number of such bits waiting to be used */ - void (*getChar)(); - int count; /* number of 8-bit characters output by getChar */ -/*@shared@*/ /*@relnull@*/ - FILE *inputFile; /* where to get input, if not stdin */ -} sexpInputStream; - -typedef struct sexp_outputstream { - long int column; /* column where next character will go */ - long int maxcolumn; /* max usable column, or -1 if no maximum */ - long int indent; /* current indentation level (starts at 0) */ - void (*putChar)(); /* output a character */ - void (*newLine)(); /* go to next line (and indent) */ - int byteSize; /* 4 or 6 or 8 depending on output mode */ - int bits; /* bits waiting to go out */ - int nBits; /* number of bits waiting to go out */ - long int base64Count; /* number of hex or base64 chars printed - this region */ - int mode; /* BASE64, ADVANCED, or CANONICAL */ -/*@shared@*/ /*@relnull@*/ - FILE *outputFile; /* where to put output, if not stdout */ -} sexpOutputStream; - -/* Function prototypes */ - -/* sexp-basic */ -/*@mayexit@*/ /*@printflike@*/ -void ErrorMessage(int level, const char *fmt, ...) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; -void initializeMemory(void) - /*@*/; -char *sexpAlloc(int n) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; -sexpSimpleString *newSimpleString(void) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; -long int simpleStringLength(sexpSimpleString *ss) - /*@*/; -/*@null@*/ -octet *simpleStringString(sexpSimpleString *ss) - /*@*/; -/*@null@*/ -sexpSimpleString *reallocateSimpleString(sexpSimpleString *ss) - /*@globals fileSystem @*/ - /*@modifies ss, fileSystem @*/; -void appendCharToSimpleString(int c, sexpSimpleString *ss) - /*@globals fileSystem @*/ - /*@modifies ss, fileSystem @*/; -sexpString *newSexpString(void) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; -/*@null@*/ -sexpSimpleString *sexpStringPresentationHint(sexpString *s) - /*@*/; -void setSexpStringPresentationHint(sexpString *s, sexpSimpleString *ss) - /*@modifies s @*/; -void setSexpStringString(sexpString *s, sexpSimpleString *ss) - /*@modifies s @*/; -/*@null@*/ -sexpSimpleString *sexpStringString(sexpString *s) - /*@*/; -void closeSexpString(sexpString *s) - /*@*/; -sexpList *newSexpList(void) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; -void sexpAddSexpListObject(sexpList *list, sexpObject *object) - /*@globals fileSystem @*/ - /*@modifies list, fileSystem @*/; -void closeSexpList(sexpList *list) - /*@*/; -/*@observer@*/ -sexpIter sexpListIter(sexpList *list) - /*@*/; -/*@exposed@*/ /*@observer@*/ /*@null@*/ -sexpIter sexpIterNext(sexpIter iter) - /*@*/; -/*@exposed@*/ /*@observer@*/ /*@null@*/ -sexpObject *sexpIterObject(sexpIter iter) - /*@*/; -int isObjectString(sexpObject *object) - /*@*/; -int isObjectList(sexpObject *object) - /*@*/; - -/* sexp-input */ -void initializeCharacterTables(void) - /*@globals internalState @*/ - /*@modifies internalState @*/; -int isWhiteSpace(int c) - /*@*/; -int isDecDigit(int c) - /*@*/; -int isHexDigit(int c) - /*@*/; -int isBase64Digit(int c) - /*@*/; -int isTokenChar(int c) - /*@*/; -/*@unused@*/ -int isAlpha(int c) - /*@*/; -void changeInputByteSize(sexpInputStream *is, int newByteSize) - /*@modifies is @*/; -void getChar(sexpInputStream *is) - /*@globals fileSystem @*/ - /*@modifies is, fileSystem @*/; -sexpInputStream *newSexpInputStream(void) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; -void skipWhiteSpace(sexpInputStream *is) - /*@modifies is @*/; -void skipChar(sexpInputStream *is, int c) - /*@globals fileSystem @*/ - /*@modifies is, fileSystem @*/; -void scanToken(sexpInputStream *is, sexpSimpleString *ss) - /*@globals fileSystem @*/ - /*@modifies is, ss, fileSystem @*/; -sexpObject *scanToEOF(sexpInputStream *is) - /*@globals fileSystem @*/ - /*@modifies is, fileSystem @*/; -unsigned long int scanDecimal(sexpInputStream *is) - /*@globals fileSystem @*/ - /*@modifies is, fileSystem @*/; -void scanVerbatimString(sexpInputStream *is, sexpSimpleString *ss, long int length) - /*@globals fileSystem @*/ - /*@modifies is, ss, fileSystem @*/; -void scanQuotedString(sexpInputStream *is, sexpSimpleString *ss, long int length) - /*@globals fileSystem @*/ - /*@modifies is, ss, fileSystem @*/; -void scanHexString(sexpInputStream *is, sexpSimpleString *ss, long int length) - /*@globals fileSystem @*/ - /*@modifies is, ss, fileSystem @*/; -void scanBase64String(sexpInputStream *is, sexpSimpleString *ss, long int length) - /*@globals fileSystem @*/ - /*@modifies is, ss, fileSystem @*/; -sexpSimpleString *scanSimpleString(sexpInputStream *is) - /*@globals fileSystem @*/ - /*@modifies is, fileSystem @*/; -sexpString *scanString(sexpInputStream *is) - /*@globals fileSystem @*/ - /*@modifies is, fileSystem @*/; -sexpList *scanList(sexpInputStream *is) - /*@globals fileSystem @*/ - /*@modifies is, fileSystem @*/; -sexpObject *scanObject(sexpInputStream *is) - /*@globals fileSystem @*/ - /*@modifies is, fileSystem @*/; - -/* sexp-output */ -void putChar(sexpOutputStream *os, int c) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -void varPutChar(sexpOutputStream *os, int c) - /*@modifies os @*/; -void changeOutputByteSize(sexpOutputStream *os, int newByteSize, int mode) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -void flushOutput(sexpOutputStream * os) - /*@modifies os @*/; -void newLine(sexpOutputStream *os, int mode) - /*@modifies os @*/; -sexpOutputStream *newSexpOutputStream(void) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; -void printDecimal(sexpOutputStream *os, long int n) - /*@modifies os @*/; -void canonicalPrintVerbatimSimpleString(sexpOutputStream *os, sexpSimpleString *ss) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -void canonicalPrintString(sexpOutputStream *os, sexpString *s) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -void canonicalPrintList(sexpOutputStream *os, sexpList *list) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -void canonicalPrintObject(sexpOutputStream *os, sexpObject *object) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -void base64PrintWholeObject(sexpOutputStream *os, sexpObject *object) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -int canPrintAsToken(sexpOutputStream *os, sexpSimpleString *ss) - /*@*/; -void advancedPrintTokenSimpleString(sexpOutputStream *os, sexpSimpleString *ss) - /*@modifies os @*/; -int advancedLengthSimpleStringToken(sexpSimpleString *ss) - /*@*/; -/*@unused@*/ -void advancedPrintVerbatimSimpleString(sexpOutputStream *os, sexpSimpleString *ss) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -/*@unused@*/ -int advancedLengthSimpleStringVerbatim(sexpSimpleString *ss) - /*@*/; -void advancedPrintBase64SimpleString(sexpOutputStream *os, sexpSimpleString *ss) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -void advancedPrintHexSimpleString(sexpOutputStream *os, sexpSimpleString *ss) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -int advancedLengthSimpleStringHexadecimal(sexpSimpleString *ss) - /*@*/; -int canPrintAsQuotedString(sexpSimpleString *ss) - /*@*/; -void advancedPrintQuotedStringSimpleString(sexpOutputStream *os, sexpSimpleString *ss) - /*@modifies os @*/; -int advancedLengthSimpleStringQuotedString(sexpSimpleString *ss) - /*@*/; -void advancedPrintSimpleString(sexpOutputStream *os, sexpSimpleString *ss) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -void advancedPrintString(sexpOutputStream *os, sexpString *s) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -int advancedLengthSimpleStringBase64(sexpSimpleString *ss) - /*@*/; -int advancedLengthSimpleString(sexpOutputStream *os, sexpSimpleString *ss) - /*@*/; -int advancedLengthString(sexpOutputStream *os, sexpString *s) - /*@*/; -int advancedLengthList(sexpOutputStream *os, sexpList *list) - /*@*/; -void advancedPrintList(sexpOutputStream *os, sexpList *list) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; -void advancedPrintObject(sexpOutputStream *os, sexpObject *object) - /*@globals fileSystem @*/ - /*@modifies os, fileSystem @*/; +/* SEXP standard header file: sexp.h + * Ronald L. Rivest + * 6/29/1997 + */ + +/* GLOBAL DECLARATIONS */ +#define TRUE 1 +#define FALSE 0 + +/* PRINTING MODES */ +#define CANONICAL 1 /* standard for hashing and tranmission */ +#define BASE64 2 /* base64 version of canonical */ +#define ADVANCED 3 /* pretty-printed */ + +/* ERROR MESSAGE LEVELS */ +#define WARNING 1 +#define ERROR 2 + +#define DEFAULTLINELENGTH 75 + +typedef unsigned char octet; + +/* TYPES OF OBJECTS */ +#define SEXP_STRING 1 +#define SEXP_LIST 2 + +/* sexpSimpleString */ +typedef struct sexp_simplestring { + long int length; + long int allocatedLength; +/*@null@*/ + octet *string; +} sexpSimpleString; + +/* sexpString */ +typedef struct sexp_string { + int type; +/*@null@*/ + sexpSimpleString *presentationHint; +/*@null@*/ + sexpSimpleString *string; +} sexpString; + +/* sexpList */ +/* If first is NULL, then rest must also be NULL; this is empty list */ +typedef struct sexp_list { + char type; +/*@null@*/ + union sexp_object *first; +/*@null@*/ + struct sexp_list *rest; +} sexpList; + +/* sexpObject */ +/* so we can have a pointer to something of either type */ +typedef union sexp_object { +/*@unused@*/ + sexpString string; +/*@unused@*/ + sexpList list; +} sexpObject; + +/* sexpIter */ +/* an "iterator" for going over lists */ +/* In this implementation, it is the same as a list */ +typedef /*@abstract@*/ sexpList * sexpIter; + +typedef /*@abstract@*/ struct sexp_inputstream { + int nextChar; /* character currently being scanned */ + int byteSize; /* 4 or 6 or 8 == currently scanning mode */ + int bits; /* Bits waiting to be used */ + int nBits; /* number of such bits waiting to be used */ + void (*getChar)(); + int count; /* number of 8-bit characters output by getChar */ +/*@shared@*/ /*@relnull@*/ + FILE *inputFile; /* where to get input, if not stdin */ +} * sexpInputStream; + +typedef /*@abstract@*/ struct sexp_outputstream { + long int column; /* column where next character will go */ + long int maxcolumn; /* max usable column, or -1 if no maximum */ + long int indent; /* current indentation level (starts at 0) */ + void (*putChar)(); /* output a character */ + void (*newLine)(); /* go to next line (and indent) */ + int byteSize; /* 4 or 6 or 8 depending on output mode */ + int bits; /* bits waiting to go out */ + int nBits; /* number of bits waiting to go out */ + long int base64Count; /* number of hex or base64 chars printed + this region */ + int mode; /* BASE64, ADVANCED, or CANONICAL */ +/*@shared@*/ /*@relnull@*/ + FILE *outputFile; /* where to put output, if not stdout */ +} * sexpOutputStream; + +/* Function prototypes */ + +/* sexp-basic */ +/*@mayexit@*/ /*@printflike@*/ +void ErrorMessage(int level, const char *fmt, ...) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/; +void initializeMemory(void) + /*@*/; +char *sexpAlloc(int n) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/; +sexpSimpleString *newSimpleString(void) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/; +long int simpleStringLength(sexpSimpleString *ss) + /*@*/; +/*@null@*/ +octet *simpleStringString(sexpSimpleString *ss) + /*@*/; +/*@null@*/ +sexpSimpleString *reallocateSimpleString(sexpSimpleString *ss) + /*@globals fileSystem @*/ + /*@modifies ss, fileSystem @*/; +void appendCharToSimpleString(int c, sexpSimpleString *ss) + /*@globals fileSystem @*/ + /*@modifies ss, fileSystem @*/; +sexpString *newSexpString(void) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/; +/*@null@*/ +sexpSimpleString *sexpStringPresentationHint(sexpString *s) + /*@*/; +void setSexpStringPresentationHint(sexpString *s, sexpSimpleString *ss) + /*@modifies s @*/; +void setSexpStringString(sexpString *s, sexpSimpleString *ss) + /*@modifies s @*/; +/*@null@*/ +sexpSimpleString *sexpStringString(sexpString *s) + /*@*/; +void closeSexpString(sexpString *s) + /*@*/; +sexpList *newSexpList(void) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/; +void sexpAddSexpListObject(sexpList *list, sexpObject *object) + /*@globals fileSystem @*/ + /*@modifies list, fileSystem @*/; +void closeSexpList(sexpList *list) + /*@*/; +/*@observer@*/ +sexpIter sexpListIter(sexpList *list) + /*@*/; +/*@exposed@*/ /*@observer@*/ /*@null@*/ +sexpIter sexpIterNext(sexpIter iter) + /*@*/; +/*@exposed@*/ /*@observer@*/ /*@null@*/ +sexpObject *sexpIterObject(sexpIter iter) + /*@*/; +int isObjectString(sexpObject *object) + /*@*/; +int isObjectList(sexpObject *object) + /*@*/; + +/* sexp-input */ +void initializeCharacterTables(void) + /*@globals internalState @*/ + /*@modifies internalState @*/; +int isWhiteSpace(int c) + /*@*/; +int isDecDigit(int c) + /*@*/; +int isHexDigit(int c) + /*@*/; +int isBase64Digit(int c) + /*@*/; +int isTokenChar(int c) + /*@*/; +/*@unused@*/ +int isAlpha(int c) + /*@*/; +void changeInputByteSize(sexpInputStream is, int newByteSize) + /*@modifies is @*/; +void getChar(sexpInputStream is) + /*@globals fileSystem @*/ + /*@modifies is, fileSystem @*/; +sexpInputStream newSexpInputStream(void) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/; +void skipWhiteSpace(sexpInputStream is) + /*@modifies is @*/; +void skipChar(sexpInputStream is, int c) + /*@globals fileSystem @*/ + /*@modifies is, fileSystem @*/; +void scanToken(sexpInputStream is, sexpSimpleString *ss) + /*@globals fileSystem @*/ + /*@modifies is, ss, fileSystem @*/; +sexpObject *scanToEOF(sexpInputStream is) + /*@globals fileSystem @*/ + /*@modifies is, fileSystem @*/; +unsigned long int scanDecimal(sexpInputStream is) + /*@globals fileSystem @*/ + /*@modifies is, fileSystem @*/; +void scanVerbatimString(sexpInputStream is, sexpSimpleString *ss, long int length) + /*@globals fileSystem @*/ + /*@modifies is, ss, fileSystem @*/; +void scanQuotedString(sexpInputStream is, sexpSimpleString *ss, long int length) + /*@globals fileSystem @*/ + /*@modifies is, ss, fileSystem @*/; +void scanHexString(sexpInputStream is, sexpSimpleString *ss, long int length) + /*@globals fileSystem @*/ + /*@modifies is, ss, fileSystem @*/; +void scanBase64String(sexpInputStream is, sexpSimpleString *ss, long int length) + /*@globals fileSystem @*/ + /*@modifies is, ss, fileSystem @*/; +sexpSimpleString *scanSimpleString(sexpInputStream is) + /*@globals fileSystem @*/ + /*@modifies is, fileSystem @*/; +sexpString *scanString(sexpInputStream is) + /*@globals fileSystem @*/ + /*@modifies is, fileSystem @*/; +sexpList *scanList(sexpInputStream is) + /*@globals fileSystem @*/ + /*@modifies is, fileSystem @*/; +sexpObject *scanObject(sexpInputStream is) + /*@globals fileSystem @*/ + /*@modifies is, fileSystem @*/; + +/* sexp-output */ +void putChar(sexpOutputStream os, int c) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +void varPutChar(sexpOutputStream os, int c) + /*@modifies os @*/; +void changeOutputByteSize(sexpOutputStream os, int newByteSize, int mode) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +void flushOutput(sexpOutputStream os) + /*@modifies os @*/; +void newLine(sexpOutputStream os, int mode) + /*@modifies os @*/; +sexpOutputStream newSexpOutputStream(void) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/; +void printDecimal(sexpOutputStream os, long int n) + /*@modifies os @*/; +void canonicalPrintVerbatimSimpleString(sexpOutputStream os, sexpSimpleString *ss) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +void canonicalPrintString(sexpOutputStream os, sexpString *s) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +void canonicalPrintList(sexpOutputStream os, sexpList *list) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +void canonicalPrintObject(sexpOutputStream os, sexpObject *object) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +void base64PrintWholeObject(sexpOutputStream os, sexpObject *object) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +int canPrintAsToken(sexpOutputStream os, sexpSimpleString *ss) + /*@*/; +void advancedPrintTokenSimpleString(sexpOutputStream os, sexpSimpleString *ss) + /*@modifies os @*/; +int advancedLengthSimpleStringToken(sexpSimpleString *ss) + /*@*/; +/*@unused@*/ +void advancedPrintVerbatimSimpleString(sexpOutputStream os, sexpSimpleString *ss) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +/*@unused@*/ +int advancedLengthSimpleStringVerbatim(sexpSimpleString *ss) + /*@*/; +void advancedPrintBase64SimpleString(sexpOutputStream os, sexpSimpleString *ss) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +void advancedPrintHexSimpleString(sexpOutputStream os, sexpSimpleString *ss) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +int advancedLengthSimpleStringHexadecimal(sexpSimpleString *ss) + /*@*/; +int canPrintAsQuotedString(sexpSimpleString *ss) + /*@*/; +void advancedPrintQuotedStringSimpleString(sexpOutputStream os, sexpSimpleString *ss) + /*@modifies os @*/; +int advancedLengthSimpleStringQuotedString(sexpSimpleString *ss) + /*@*/; +void advancedPrintSimpleString(sexpOutputStream os, sexpSimpleString *ss) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +void advancedPrintString(sexpOutputStream os, sexpString *s) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +int advancedLengthSimpleStringBase64(sexpSimpleString *ss) + /*@*/; +int advancedLengthSimpleString(sexpOutputStream os, sexpSimpleString *ss) + /*@*/; +int advancedLengthString(sexpOutputStream os, sexpString *s) + /*@*/; +int advancedLengthList(sexpOutputStream os, sexpList *list) + /*@*/; +void advancedPrintList(sexpOutputStream os, sexpList *list) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; +void advancedPrintObject(sexpOutputStream os, sexpObject *object) + /*@globals fileSystem @*/ + /*@modifies os, fileSystem @*/; -- 2.7.4