]> code.citadel.org Git - citadel.git/blob - libCxClient/src/CxClient.h
Initial revision
[citadel.git] / libCxClient / src / CxClient.h
1 /**
2  ** CxClient - Improved Citadel/UX Client
3  ** Copyright (c) 2000, SCCG/Flaming Sword Productions
4  ** All Rights Reserved
5  **
6  ** Module: CxClient.h
7  ** Date: 2000-12-14
8  ** Last Revision: 2000-12-14
9  ** Description: Global CxClient library header.
10  ** CVS: $Id$
11  **/
12 #ifndef         __CXCLIENT_H__
13 #define         __CXCLIENT_H__
14
15 #define         CXREVISION              "$Id$"
16
17 #define         RC_LISTING              100     // LISTING_FOLLOWS
18 #define         RC_OK                   200     // OK
19 #define         RC_MOREDATA             300     // MORE_DATA
20 #define         RC_SENDLIST             400     // SEND_LISTING
21 #define         RC_ERROR                500     // ERROR
22 #define         RC_RECVBIN              600     // BINARY_FOLLOWS
23 #define         RC_SENDBIN              700     // SEND_BINARY
24 #define         RC_STARTCHAT            800     // START_CHAT_MODE
25 #define         RC_ASYNCMSG             900     // Asynchronous Message
26 #define         RC_AEXPMSG              901     // Express Message Follows
27 #define         RC_MESGWAIT             1000    // Message Waiting
28
29 /**
30  ** The CHECKRC() macro is used to compare a Result Code 'x' with
31  ** the expected result 'y'.
32  **/
33 #define         CHECKRC(x,y)            ((x - (x % y)) == y)
34
35 #ifdef          DEBUG
36
37 #define         DFA             __FILE__,__LINE__,__FUNCTION__
38 #define         DPF(a)          CxDebug a
39
40 #else
41
42 #define         DFA             NULL
43 #define         DPF(a)  
44
45 #endif
46
47 typedef
48 struct          _file_info {
49
50  char           name[255];
51  long unsigned
52  int            size;
53  char           descr[255];
54
55  /**
56   ** Reserved for future use.  Cit/UX may not
57   ** support this yet....
58   **/
59  long unsigned
60  int            owner,
61                 group;
62  short int      mode;
63
64 } FILEINFO;
65
66 /**
67  ** Linked-List Structure
68  **/
69 typedef struct  _linked_list {
70         char    *data;
71         struct
72         _linked_list *next;
73 } CLIST;
74 typedef CLIST*  CXLIST;
75
76 typedef
77 struct          _message_info {
78  long unsigned
79  int            message_id;
80  char           author[255],
81                 rcpt[255],
82                 subject[255],
83                 room[255],
84                 path[255],
85                 node[255],
86                 date[255];
87  char           *body;
88 } MESGINFO;
89
90 /**
91  ** struct ROOMINFO: This structure contains all information related
92  ** to a room.
93  **/
94 typedef
95 struct          _room_info {
96  char           name[255];
97  long unsigned
98  int            msgs_unread,
99                 msgs_total;
100  short int      info_flag;
101  long unsigned
102  int            flags,
103                 msgs_highest,
104                 msgs_highest_u;
105  short int      mailroom,
106                 aide,
107                 mode;
108  long unsigned
109  int            msgs_newmail,
110                 floor_id;
111 } ROOMINFO;
112
113 /**
114  ** struct USERINFO: This structure contains all information related
115  ** to a user account.
116  **/
117 typedef
118 struct          _user_info {
119  char           username[255],
120                 fullname[255],
121                 password[255];
122
123  /**
124   ** USERINFO.addr: Address information.
125   **/
126  struct _a {
127   char          street[255],
128                 city[255],
129                 st[255],
130                 zip[255];
131  } addr;
132
133  /**
134   ** USERINFO.contact: Contact information.
135   **/
136  struct _c {
137   char          telephone[255],
138                 emailaddr[255];
139  } contact;
140
141  /**
142   ** USERINFO.system: System information.  Should not be modified.
143   **/
144  struct _sys {
145   int           access_level;
146   long unsigned
147   int           times_called,
148                 messages_posted,
149                 user_flags,
150                 user_number;
151  } system;
152
153 } USERINFO;
154
155 /**
156  ** struct _Cmd_Callback: This record contains information regarding Server->Client
157  ** message callbacks.  The general rule is such: IF the client wishes to handle
158  ** certain types of Server-to-Client traffic [currently unimplemented], the author
159  ** should register a Callback function to handle the command sent by the server.
160  ** The client can register a callback function for a single message type, or for
161  ** a specific data session (like, to handle a file download). Similarly, if a
162  ** client wishes to stop processing a certain type of message, the client can
163  ** deregister the command's callback.
164  **
165  ** Any messages received which do not have an attached callback function will be
166  ** ignored.
167  **/
168 typedef
169 struct          _Cmd_Callback {
170
171  int            cmd;            // Command sent from server.  [9xx]
172  char           session[10];    // Optional session id.
173  void           (*Function)(void *); // Function to call upon success.
174
175  struct _Cmd_Callback *next;
176
177 } CXCSCALLBACK;
178 typedef CXCSCALLBACK* CXCBHNDL;
179
180 #ifdef          __cplusplus
181 extern "C" {
182 #endif
183
184 float           CxRevision();
185 void            CxSerialize(const char *, char **);
186
187 /**
188  ** Client/Server Communications
189  **/
190 void            CxClRegClient(const char *);
191 int             CxClConnect(const char *);
192 void            CxClDisconnect();
193 int             CxClStat();
194 void            CxClSend(const char *s);
195 int             CxClRecv(char *s);
196 int             CxClChatInit();
197 void            CxClChatShutdown();
198 int             CxClCbRegister(int, void *);
199 void            CxClCbShutdown();
200 void            CxClCbRemove(int);
201 CXCBHNDL        CxClCbExists(int);
202
203 /**
204  ** File Input/Output
205  **/
206 CXLIST          CxFiIndex();
207 int             CxFiPut(FILEINFO, int);
208 char            *CxFiGet(const char *);
209
210 /**
211  ** Message Input/Output
212  **/
213 CXLIST          CxMsInfo(CXLIST);
214 CXLIST          CxMsList();
215 int             CxMsLoad(const char *, int, MESGINFO *);
216 int             CxMsSaveOk(const char *);
217 int             CxMsSave(MESGINFO);
218
219 /**
220  ** Room/Floor Commands
221  **/
222 ROOMINFO        *CxRmGoto(const char *, int);
223 CXLIST          CxRmList();
224 CXLIST          CxFlList();
225 int             CxRmCreate(ROOMINFO);
226
227 /**
228  ** Miscellaneous Commands
229  **/
230 int             CxMiExpSend(const char *, const char *);
231 char            *CxMiExpRecv();
232 int             CxMiExpCheck();
233 void            CxMiExpHook(void (*)(const char *, const char*));
234 char            *CxMiMessage(const char *);
235 char            *CxMiImage(const char *);
236
237 /**
238  ** Linked-List Handlers
239  **/
240 CXLIST          CxLlInsert(CXLIST, char *);
241 CXLIST          CxLlRemove(CXLIST, unsigned int);
242 CXLIST          CxLlFlush(CXLIST);
243
244 /**
245  ** User Info Commands
246  **/
247 CXLIST          CxUsOnline(int);
248 CXLIST          CxUsList();
249 int             CxUsCreate(USERINFO);
250 USERINFO        *CxUsAuth(const char *, const char *);
251
252 #ifdef          __cplusplus
253 } // extern "C"
254 #endif
255
256 #endif