2 ** libCxClient - Citadel/UX Extensible Client API
3 ** Copyright (c) 2000, Flaming Sword Productions
4 ** Copyright (c) 2001, The Citadel/UX Consortium
9 ** Last Revision: 2000-10-15
10 ** Description: Functions which manipulate (build) room & floor lists.
21 ** CxRmGoto(): Go to a room.
24 ** (char *) room: The name of the room the user wishes to go to.
25 ** (int) operation: Which room to go to?
26 ** 0: Goto specified room
27 ** 1: Goto next room w/ unread messages
31 ** On Success: The room's full information structure [*]
34 ROOMINFO *CxRmGoto(const char *room, int operation) {
36 char *xmit, buf[255], *g_Ser[20];
39 if((room && *room) && !operation) {
40 xmit = (char *)CxMalloc(strlen(room)+6);
41 sprintf(xmit, "GOTO %s", room);
48 ** If we successfully went to this room, return the
49 ** room's information structure.
51 if(CHECKRC(rc, RC_OK)) {
52 CxSerialize(buf, &g_Ser);
54 room_info = (ROOMINFO *)CxMalloc(sizeof(ROOMINFO));
55 strcpy(room_info->name, g_Ser[0]);
56 room_info->msgs_unread = atol(g_Ser[1]);
57 room_info->msgs_total = atol(g_Ser[2]);
58 room_info->info_flag = (short int) atoi(g_Ser[3]);
59 room_info->flags = atol(g_Ser[4]);
60 room_info->msgs_highest = atol(g_Ser[5]);
61 room_info->msgs_highest_u = atol(g_Ser[6]);
62 room_info->mailroom = (short int) atoi(g_Ser[7]);
63 room_info->aide = (short int) atoi(g_Ser[8]);
64 room_info->msgs_newmail = atol(g_Ser[9]);
65 room_info->floor_id = atol(g_Ser[9]);
67 DPF((DFA,"MEM/MDA:\t-1\t@0x%08x (Needs manual deallocation)", room_info));
73 ** Room not found, Returning NULL.
78 ** GOTO Next Unread Room
80 } else if(operation==1) {
83 ** Set last-read pointer for this room.
85 CxClSend("SLRP highest");
89 ** Retrieve a list of all rooms w/ new messages.
94 if(CHECKRC(rc, RC_LISTING)) {
99 xmit = (char *)CxMalloc(strlen(buf)+6);
100 strcpy(xmit, "GOTO ");
111 if(CHECKRC(rc, RC_OK)) {
112 CxSerialize(buf, &g_Ser);
114 room_info = (ROOMINFO *)CxMalloc(sizeof(ROOMINFO));
115 strcpy(room_info->name, g_Ser[0]);
116 room_info->msgs_unread = atol(g_Ser[1]);
117 room_info->msgs_total = atol(g_Ser[2]);
118 room_info->info_flag = (short int) atoi(g_Ser[3]);
119 room_info->flags = atol(g_Ser[4]);
120 room_info->msgs_highest = atol(g_Ser[5]);
121 room_info->msgs_highest_u = atol(g_Ser[6]);
122 room_info->mailroom = (short int) atoi(g_Ser[7]);
123 room_info->aide = (short int) atoi(g_Ser[8]);
124 room_info->msgs_newmail = atol(g_Ser[9]);
125 room_info->floor_id = atol(g_Ser[9]);
127 DPF((DFA,"MEM/MDA:\t-1\t@0x%08x (Needs manual deallocation)", room_info));
147 ** CxRmCreate(): Create a new room, using CERTAIN information provided in
148 ** a ROOMINFO struct. Any unnecessary information is ignored.
151 ** ROOMINFO: Information about the room to be created.
155 ** On Failure: 1: rm.mode is invalid.
156 ** 2: rm.floor_id is invalid.
158 ** 4: not here/not allowed.
160 int CxRmCreate(ROOMINFO rm) {
164 DPF((DFA,"Creating room '%s'",rm.name));
167 ** User provided an illegal room mode. Can't continue.
169 if((rm.mode<0) || (rm.mode>4)) {
170 DPF((DFA,"FAILED rm.mode_is_invalid"));
175 ** Floor id invalid (How do we check this?)
178 DPF((DFA,"FAILED rm.floor_id_is_invalid"));
183 ** Does the room already exist?
186 DPF((DFA,"FAILED room_exists"));
190 sprintf(buf, "CRE8 1|%s|%d||%d", rm.name, rm.mode, rm.floor_id );
193 if( CHECKRC(rc, RC_OK)) {
194 DPF((DFA,"Success!"));
197 DPF((DFA,"FAILED %d:%s", rc, buf));
203 ** CxRmList(): Retrieve a list of rooms on the current floor. Return it
204 ** as a Character array. THE CALLER IS RESPONSIBLE FOR DEALLOCATING THIS
212 DPF((DFA,"Retrieving list of rooms from the server."));
215 rc = CxClRecv( buf );
216 DPF((DFA,"%s [%d]",buf,rc));
218 if( CHECKRC(rc, RC_LISTING)) {
221 rc = CxClRecv( buf );
222 DPF((DFA,"%s [%d]",buf,rc));
225 rooms = (CXLIST) CxLlInsert(rooms,buf);
236 ** CxFlList(): Retrieve a list of floors.
241 CXLIST floors = NULL;
243 DPF((DFA,"Retrieving list of floors from the server."));
246 rc = CxClRecv( buf );
247 DPF((DFA,"%s [%d]",buf,rc));
249 if( CHECKRC(rc, RC_LISTING)) {
252 rc = CxClRecv( buf );
253 DPF((DFA,"%s [%d]",buf,rc));
256 floors = (CXLIST) CxLlInsert(floors,buf);