/************************************************************************** * File Name: report.h * Short Desc.: Type and function header definitons for report.c * Date: 21/07/1997 * Author: Antal Nagy, Dept. of Applied Informatics, * Jozsef Attila University, Szeged, Hungary * email: nagya@inf.u-szeged.hu * WWW: http://www.inf.u-szeged.hu/~nagya * Copyright (c) 1997 **************************************************************************/ #ifndef __REPORT_H #define __REPORT_H #include "dstrbuf.h" #define DSTRINGBUFFER_SIZE 4096 #ifndef ifprint #define ifprint(t, value) if(value) printf("%s: %s\n", t, value) #endif #ifndef printReport #define printReport(Report) printStruct(Report->Root) #endif typedef enum { HT_REPORT = 0, HT_FINDING = 1, HT_OBSERV = 2, HT_RELAT = 3 } HT; typedef enum { VT_VALUE = 0, VT_CID = 1, VT_CV = 2, VT_MR = 3, VT_MRV = 4, VT_CSD = 5, VT_CM = 6, VT_TID = 7 } VT; typedef struct HEAD { HT type; char *id; char *comment; char *class; /*if type == OBSERV*/ struct ATPER *permitted; /*if type == OBSERV*/ } HeadElement; typedef struct ATVAL { VT type; char *value; char *comment; struct ATVAL *next; /*next field of last element of the list is NULL*/ struct ATVAL *prev; /*prev field of first element of the list points to last*/ } AttrValElement; typedef struct ATPER { char *pervalue; struct ATPER *next; /*next field of last element of the list is NULL*/ struct ATPER *prev; /*prev field of first element of the list points to last*/ } PerAttrValElement; typedef struct ATTR { char *attrname; char *comment; char *percomment; struct ATVAL *values; struct ATPER *permitted; } AttrElement; typedef struct ITEM { long int index; } ItemElement; typedef union { struct HEAD *head; struct ATTR *attr; struct ITEM *item; } ValueType; typedef struct REP { ValueType value; char *comment; /*comment for one element of the list*/ char *groupComment; /*comment for Findings, Observation Gr., Relation Gr.*/ struct REP *parent; struct REP *next; /*next field of last element of the list is NULL*/ struct REP *prev; /*prev field of first element of the list points to last*/ struct REP *attributum; struct REP *header; } ReportElement; typedef struct { char *filename; DStringBuffer *dstring; struct REP *Root ; struct REP *Current; } Report; void reperror(char *s); int repwrap(void); void fillparent(ReportElement *target, ReportElement *source); void fillgroupComment(ReportElement *target, char *source); void fillsqItems(ReportElement *target); int openReport(char *filename, Report **ReportObject); void closeReport(Report **ReportObject); int writeReport(char *filename, Report *ReportObject); void freeAttrVals(AttrValElement **Values); void freePerAttrVals(PerAttrValElement **Permitted); void freeAttrTAG(AttrElement **AttrTAG); void freeAttrS(ReportElement **Attr); void freeSQ(ReportElement **SQ); void freeStruct(ReportElement **Tree); void printAttrVals(AttrValElement *Values); void printPerAttrVals(PerAttrValElement *Permitted); void printAttrTAG(AttrElement *AttrTAG); void printAttrS(ReportElement *Attr); void printSQ(ReportElement *SQItem); void printHeader(HeadElement *Head); void printStruct(ReportElement *Tree); void writeAttrVals(AttrValElement *Values); void writePerAttrVals(PerAttrValElement *Permitted); void writeAttrS(ReportElement *Attr); void writeSQ(ReportElement *SQItem); void writeStruct(ReportElement *Tree); #endif /* !__REPORT_H */