Four Js Genero Report Writer
libgre.h
1 /*
2  * FOURJS_START_COPYRIGHT(D,2011)
3  * Property of Four Js*
4  * (c) Copyright Four Js 2011, 2019. All Rights Reserved.
5  * * Trademark of Four Js Development Tools Europe Ltd
6  * in the United States and elsewhere
7  *
8  * This file can be modified by licensees according to the
9  * product manual.
10  * FOURJS_END_COPYRIGHT
11 */
12 
13 #ifndef _LIBGRE_H
14 #define _LIBGRE_H 1
15 
16 #include "gre.h"
17 #include <stdio.h>
18 #include <sys/types.h>
19 
20 #ifdef _MSC_VER
21 typedef unsigned int pid_t;
22 #endif
23 
24 typedef struct
25 {
26  int (*flush)(void *state);
27  int (*close)(void *state);
28  int (*print)(void *state,const char* s);
29  int (*println)(void *state,const char* s);
30  ssize_t (*write)(void *state,const void *buf, size_t count);
31  int (*data_available)(void *state);
32  char* (*readln)(void *state,char* buffer,int size);
33  int (*supports_reading)(void *state);
34 } ConnectorMethods;
35 
36 typedef struct
37 {
38  ConnectorMethods* methods;
39  void *state;
40 } Connector;
41 
42 typedef struct
43 {
44  FILE *fd;
45 } FileConnectorState;
46 
47 typedef struct
48 {
49  FILE *fd_out;
50  FILE *fd_in;
51  pid_t child_pid;
52 } PipeConnectorState;
53 
54 typedef struct
55 {
56 #ifdef _MSC_VER
57  int sockfd;
58 #else
59  FILE *fd_out;
60  FILE *fd_in;
61 #endif
62 } SocketConnectorState;
63 
64 Connector* fgl_report_createFileConnector(FILE *fd);
65 void fgl_report_destroyFileConnector(Connector* connector);
66 
67 Connector* fgl_report_createPipeConnector(char* command);
68 void fgl_report_destroyPipeConnector(Connector* connector);
69 
70 Connector* fgl_report_createSocketConnector(const char* host,int port);
71 void fgl_report_destroySocketConnector(Connector* connector);
72 
73 #define LC_INITIAL 0
74 #define LC_PROCESSING_INSTRUCTION 1
75 #define LC_START_ELEMENT 2
76 #define LC_ATTRIBUTE 3
77 #define LC_CHARACTERS 4
78 #define LC_END_ELEMENT 5
79 
80 
81 struct ContentHandler
82 {
83  Connector* connector;
84  int indent;
85  int last_call;
86 } ;
87 
88 ContentHandler* fgl_report_createContentHandlerForConnector(Connector* connector);
89 
90 #endif /* _LIBGRE_H */