Make sexpString and sexpList opaque and abstract.
authorjbj <devnull@localhost>
Fri, 28 May 2004 01:48:49 +0000 (01:48 +0000)
committerjbj <devnull@localhost>
Fri, 28 May 2004 01:48:49 +0000 (01:48 +0000)
CVS patchset: 7265
CVS date: 2004/05/28 01:48:49

rpmio/sexp/sexp-basic.c
rpmio/sexp/sexp-input.c
rpmio/sexp/sexp-output.c
rpmio/sexp/sexp.h

index c4d3003..8d8cb57 100644 (file)
@@ -12,6 +12,9 @@
 
 /*@access sexpIter @*/
 /*@access sexpSimpleString @*/
+
+/*@access sexpList @*/
+/*@access sexpString @*/
 /*@access sexpObject @*/
 
 /******************/
@@ -146,10 +149,10 @@ void appendCharToSimpleString(int c, sexpSimpleString ss)
  * Creates and initializes a new sexpString object.
  * Both the presentation hint and the string are initialized to NULL.
  */
-sexpString *newSexpString(void)
+sexpString newSexpString(void)
 {
-  sexpString *s;
-  s = (sexpString *) sexpAlloc(sizeof(*s));
+  sexpString s;
+  s = (sexpString) sexpAlloc(sizeof(*s));
   s->type = SEXP_STRING;
   s->presentationHint = NULL;
   s->string = NULL;
@@ -159,31 +162,39 @@ sexpString *newSexpString(void)
 /* sexpStringPresentationHint()
  * returns presentation hint field of the string
  */
-sexpSimpleString sexpStringPresentationHint(sexpString *s)
+sexpSimpleString sexpStringPresentationHint(sexpString s)
 { return s->presentationHint; }
 
 /* setSexpStringPresentationHint()
  * assigns the presentation hint field of the string
  */
-void setSexpStringPresentationHint(sexpString *s, sexpSimpleString ss)
-{ s->presentationHint = ss; }
+void setSexpStringPresentationHint(sexpString s, sexpSimpleString ss)
+{
+/*@-assignexpose@*/
+    s->presentationHint = ss;
+/*@=assignexpose@*/
+}
 
 /* setSexpStringString()
  * assigns the string field of the string
  */
-void setSexpStringString(sexpString *s, sexpSimpleString ss)
-{ s->string = ss; }
+void setSexpStringString(sexpString s, sexpSimpleString ss)
+{
+/*@-assignexpose@*/
+    s->string = ss;
+/*@=assignexpose@*/
+}
 
 /* sexpStringString()
  * returns the string field of the string
  */
-sexpSimpleString sexpStringString(sexpString *s)
+sexpSimpleString sexpStringString(sexpString s)
 { return s->string; }
 
 /* closeSexpString()
  * finish up string computations after created
  */
-void closeSexpString(/*@unused@*/ sexpString *s)
+void closeSexpString(/*@unused@*/ sexpString s)
 { ; }  /* do nothing in this implementation */
 
 /**************************/
@@ -195,10 +206,10 @@ void closeSexpString(/*@unused@*/ sexpString *s)
  * Both the first and rest fields are initialized to NULL, which is
  * SEXP's representation of an empty list.
  */
-sexpList *newSexpList(void)
+sexpList newSexpList(void)
 {
-  sexpList *list;
-  list = (sexpList *) sexpAlloc(sizeof(*list));
+  sexpList list;
+  list = (sexpList) sexpAlloc(sizeof(*list));
   list->type = SEXP_LIST;
   list->first = NULL;
   list->rest = NULL;
@@ -208,25 +219,30 @@ sexpList *newSexpList(void)
 /* sexpAddSexpListObject()
  * add object to end of list
  */
-void sexpAddSexpListObject(sexpList *list, sexpObject object)
+void sexpAddSexpListObject(sexpList list, sexpObject object)
 {
-  if (list->first == NULL)
-    list->first = object;
-  else {
-    while (list->rest != NULL)
-      list = list->rest;
-    list->rest = newSexpList();
+    if (list->first == NULL) {
+/*@-assignexpose@*/
+       list->first = object;
+/*@=assignexpose@*/
+    } else {
+       while (list->rest != NULL)
+           list = list->rest;
+       list->rest = newSexpList();
 /*@-branchstate@*/
-    if ((list = list->rest) != NULL)
-      list->first = object;
+       if ((list = list->rest) != NULL) {
+/*@-assignexpose@*/
+           list->first = object;
+/*@=assignexpose@*/
+       }
 /*@=branchstate@*/
-  }
+    }
 }
 
 /* closeSexpList()
  * finish off a list that has just been input
  */
-void closeSexpList(/*@unused@*/ sexpList *list)
+void closeSexpList(/*@unused@*/ sexpList list)
 { ; } /* nothing in this implementation */
 
 /* Iteration on lists.
@@ -237,7 +253,7 @@ void closeSexpList(/*@unused@*/ sexpList *list)
 /* sexpListIter()
  * return the iterator for going over a list
  */
-sexpIter sexpListIter(sexpList *list)
+sexpIter sexpListIter(sexpList list)
 {
 /*@-castexpose@*/
     return (sexpIter)list;
@@ -249,7 +265,7 @@ sexpIter sexpListIter(sexpList *list)
  */
 sexpIter sexpIterNext(sexpIter iter)
 { if (iter == NULL) return NULL;
-  return (sexpIter)(((sexpList *)iter)->rest);
+  return (sexpIter)(((sexpList)iter)->rest);
 }
 
 /* sexpIterObject ()
@@ -257,7 +273,7 @@ sexpIter sexpIterNext(sexpIter iter)
  */
 sexpObject sexpIterObject(sexpIter iter)
 { if (iter == NULL) return NULL;
-  return ((sexpList *)iter)->first;
+  return ((sexpList)iter)->first;
 }
 
 /****************************/
@@ -265,11 +281,11 @@ sexpObject sexpIterObject(sexpIter iter)
 /****************************/
 
 int isObjectString(sexpObject object)
-{ if (((sexpString *)object)->type == SEXP_STRING) return TRUE;
+{ if (((sexpString)object)->type == SEXP_STRING) return TRUE;
   else                                             return FALSE;
 }
 
 int isObjectList(sexpObject object)
-{ if (((sexpList *)object)->type == SEXP_LIST) return TRUE;
+{ if (((sexpList)object)->type == SEXP_LIST) return TRUE;
   else                                         return FALSE;
 }
index d59715b..5f92c51 100644 (file)
@@ -8,6 +8,9 @@
 #include "sexp.h"
 
 /*@access sexpInputStream @*/
+
+/*@access sexpList @*/
+/*@access sexpString @*/
 /*@access sexpObject @*/
 
 /**************************************/
@@ -256,7 +259,7 @@ void scanToken(sexpInputStream is, sexpSimpleString ss)
 sexpObject scanToEOF(sexpInputStream is)
 {
   sexpSimpleString ss = newSimpleString();
-  sexpString *s = newSexpString();
+  sexpString s = newSexpString();
   setSexpStringString(s,ss);
   skipWhiteSpace(is);
   while (is->nextChar != EOF)
@@ -465,9 +468,9 @@ 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;
+  sexpString s;
   sexpSimpleString ss;
   s = newSexpString();
   if (is->nextChar == '[')
@@ -488,8 +491,8 @@ sexpString *scanString(sexpInputStream is)
 /* scanList(is)
  * Read and return a sexpList from the input stream.
  */
-sexpList *scanList(sexpInputStream is)
-{ sexpList *list;
+sexpList scanList(sexpInputStream is)
+{ sexpList list;
   sexpObject object;
   skipChar(is,'(');
   skipWhiteSpace(is);
index 291f92c..4d2b68b 100644 (file)
@@ -9,6 +9,9 @@
 
 /*@access sexpOutputStream @*/
 /*@access sexpSimpleString @*/
+
+/*@access sexpList @*/
+/*@access sexpString @*/
 /*@access sexpObject @*/
 
 /*@unchecked@*/ /*@observer@*/
@@ -183,7 +186,7 @@ void canonicalPrintVerbatimSimpleString(sexpOutputStream os, sexpSimpleString ss
 /* 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 = sexpStringPresentationHint(s);
   sexpSimpleString ss;
@@ -203,7 +206,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,'(');
@@ -224,9 +227,9 @@ void canonicalPrintList(sexpOutputStream os, sexpList *list)
 void canonicalPrintObject(sexpOutputStream os, sexpObject object)
 {
   if (isObjectString(object))
-    canonicalPrintString(os,(sexpString *)object);
+    canonicalPrintString(os,(sexpString)object);
   else if (isObjectList(object))
-    canonicalPrintList(os,(sexpList *)object);
+    canonicalPrintList(os,(sexpList)object);
   else ErrorMessage(ERROR,"NULL object can't be printed.");
 }
 
@@ -449,7 +452,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);
@@ -491,7 +494,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)
 {
     sexpSimpleString ph = sexpStringPresentationHint(s);
     sexpSimpleString ss = sexpStringString(s);
@@ -507,7 +510,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;
@@ -516,10 +519,10 @@ int advancedLengthList(sexpOutputStream os, sexpList *list)
     { object = sexpIterObject(iter);
       if (object != NULL)
        { if (isObjectString(object))
-           len += advancedLengthString(os,((sexpString *)object));
+           len += advancedLengthString(os,((sexpString)object));
          /* else */
          if (isObjectList(object))
-           len += advancedLengthList(os,((sexpList *)object));
+           len += advancedLengthList(os,((sexpList)object));
          len++;                     /* for space after item */
        }
       iter = sexpIterNext(iter);
@@ -534,7 +537,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;
@@ -570,9 +573,9 @@ void advancedPrintObject(sexpOutputStream os, sexpObject object)
   if (os->maxcolumn>0 && os->column>os->maxcolumn-4)
     os->newLine(os,ADVANCED);
   if (isObjectString(object))
-    advancedPrintString(os,(sexpString *)object);
+    advancedPrintString(os,(sexpString)object);
   else if (isObjectList(object))
-    advancedPrintList(os,(sexpList *)object);
+    advancedPrintList(os,(sexpList)object);
   else
     ErrorMessage(ERROR,"NULL object can't be printed.");
 }
index 5deacbe..a033932 100644 (file)
 
 #define DEFAULTLINELENGTH 75
 
-typedef unsigned char octet;
-
 /* TYPES OF OBJECTS */
 #define SEXP_STRING 1
 #define SEXP_LIST   2
 
+typedef unsigned char octet;
+
+typedef /*@abstract@*/ struct sexpSimpleString_s * sexpSimpleString;
+typedef /*@abstract@*/ struct sexpString_s * sexpString;
+typedef /*@abstract@*/ struct sexpList_s * sexpList;
+typedef /*@abstract@*/ union sexpObject_u * sexpObject;
+
+typedef /*@abstract@*/ struct sexpInputStream_s * sexpInputStream;
+typedef /*@abstract@*/ struct sexpOutputStream_s * sexpOutputStream;
+
 /* sexpSimpleString */
-typedef /*@abstract@*/ struct sexp_simplestring { 
+struct sexpSimpleString_s { 
   long int length;
   long int allocatedLength;
 /*@null@*/
   octet *string;
-} * sexpSimpleString;
+};
 
 /* sexpString */
-typedef struct sexp_string {
+struct sexpString_s {
   int type;
 /*@null@*/
   sexpSimpleString presentationHint;
 /*@null@*/
   sexpSimpleString string;
-} sexpString;
+};
 
 /* sexpObject */
-typedef /*@abstract@*/ union sexpObject_u * sexpObject;
 
 /* sexpList */
 /* If first is NULL, then rest must also be NULL; this is empty list */
-typedef struct sexp_list {  
-  char type;
+struct sexpList_s {  
+    int type;
 /*@null@*/
-  sexpObject first;
+    sexpObject first;
 /*@null@*/
-  struct sexp_list  *rest;
-} sexpList;
+    sexpList rest;
+};
 
 /* sexpObject */
 /* so we can have a pointer to something of either type */
 union sexpObject_u {
 /*@unused@*/
-  sexpString string;
+  struct sexpString_s string;
 /*@unused@*/
-  sexpList list;
+  struct sexpList_s list;
 };
 
 /* sexpIter */
@@ -68,7 +75,7 @@ union sexpObject_u {
 /* In this implementation, it is the same as a list */
 typedef /*@abstract@*/ sexpList * sexpIter;
 
-typedef /*@abstract@*/ struct sexpInputStream_s {
+struct sexpInputStream_s {
   int nextChar;        /* character currently being scanned */
   int byteSize;        /* 4 or 6 or 8 == currently scanning mode */
   int bits;            /* Bits waiting to be used */
@@ -77,9 +84,9 @@ typedef /*@abstract@*/ struct sexpInputStream_s {
   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 sexpOutputStream_s {
+struct sexpOutputStream_s {
   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) */
@@ -93,7 +100,7 @@ typedef /*@abstract@*/ struct sexpOutputStream_s {
   int mode;                 /* BASE64, ADVANCED, or CANONICAL */
 /*@shared@*/ /*@relnull@*/
   FILE *outputFile;         /* where to put output, if not stdout */
-} * sexpOutputStream;
+};
 
 /* Function prototypes */
 
@@ -122,31 +129,31 @@ sexpSimpleString reallocateSimpleString(sexpSimpleString ss)
 void appendCharToSimpleString(int c, sexpSimpleString ss)
        /*@globals fileSystem @*/
        /*@modifies ss, fileSystem @*/;
-sexpString *newSexpString(void)
+sexpString newSexpString(void)
        /*@globals fileSystem @*/
        /*@modifies fileSystem @*/;
-/*@null@*/
-sexpSimpleString sexpStringPresentationHint(sexpString *s)
+/*@exposed@*/ /*@null@*/
+sexpSimpleString sexpStringPresentationHint(sexpString s)
        /*@*/;
-void setSexpStringPresentationHint(sexpString *s, sexpSimpleString ss)
+void setSexpStringPresentationHint(sexpString s, sexpSimpleString ss)
        /*@modifies s @*/;
-void setSexpStringString(sexpString *s, sexpSimpleString ss)
+void setSexpStringString(sexpString s, sexpSimpleString ss)
        /*@modifies s @*/;
-/*@null@*/
-sexpSimpleString sexpStringString(sexpString *s)
+/*@exposed@*/ /*@null@*/
+sexpSimpleString sexpStringString(sexpString s)
        /*@*/;
-void closeSexpString(sexpString *s)
+void closeSexpString(sexpString s)
        /*@*/;
-sexpList *newSexpList(void)
+sexpList newSexpList(void)
        /*@globals fileSystem @*/
        /*@modifies fileSystem @*/;
-void sexpAddSexpListObject(sexpList *list, sexpObject object)
+void sexpAddSexpListObject(sexpList list, sexpObject object)
        /*@globals fileSystem @*/
        /*@modifies list, fileSystem @*/;
-void closeSexpList(sexpList *list)
+void closeSexpList(sexpList list)
        /*@*/;
 /*@observer@*/
-sexpIter sexpListIter(sexpList *list)
+sexpIter sexpListIter(sexpList list)
        /*@*/;
 /*@exposed@*/ /*@observer@*/ /*@null@*/
 sexpIter sexpIterNext(sexpIter iter)
@@ -213,10 +220,10 @@ void scanBase64String(sexpInputStream is, sexpSimpleString ss, long int length)
 sexpSimpleString scanSimpleString(sexpInputStream is)
        /*@globals fileSystem @*/
        /*@modifies is, fileSystem @*/;
-sexpString *scanString(sexpInputStream is)
+sexpString scanString(sexpInputStream is)
        /*@globals fileSystem @*/
        /*@modifies is, fileSystem @*/;
-sexpList *scanList(sexpInputStream is)
+sexpList scanList(sexpInputStream is)
        /*@globals fileSystem @*/
        /*@modifies is, fileSystem @*/;
 sexpObject scanObject(sexpInputStream is)
@@ -244,10 +251,10 @@ void printDecimal(sexpOutputStream os, long int n)
 void canonicalPrintVerbatimSimpleString(sexpOutputStream os, sexpSimpleString ss)
        /*@globals fileSystem @*/
        /*@modifies os, fileSystem @*/;
-void canonicalPrintString(sexpOutputStream os, sexpString *s)
+void canonicalPrintString(sexpOutputStream os, sexpString s)
        /*@globals fileSystem @*/
        /*@modifies os, fileSystem @*/;
-void canonicalPrintList(sexpOutputStream os, sexpList *list)
+void canonicalPrintList(sexpOutputStream os, sexpList list)
        /*@globals fileSystem @*/
        /*@modifies os, fileSystem @*/;
 void canonicalPrintObject(sexpOutputStream os, sexpObject object)
@@ -286,18 +293,18 @@ int advancedLengthSimpleStringQuotedString(sexpSimpleString ss)
 void advancedPrintSimpleString(sexpOutputStream os, sexpSimpleString ss)
        /*@globals fileSystem @*/
        /*@modifies os, fileSystem @*/;
-void advancedPrintString(sexpOutputStream os, sexpString *s)
+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 advancedLengthString(sexpOutputStream os, sexpString s)
        /*@*/;
-int advancedLengthList(sexpOutputStream os, sexpList *list)
+int advancedLengthList(sexpOutputStream os, sexpList list)
        /*@*/;
-void advancedPrintList(sexpOutputStream os, sexpList *list)
+void advancedPrintList(sexpOutputStream os, sexpList list)
        /*@globals fileSystem @*/
        /*@modifies os, fileSystem @*/;
 void advancedPrintObject(sexpOutputStream os, sexpObject object)