-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmuiclass_network.h
222 lines (176 loc) · 7.67 KB
/
muiclass_network.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*
The contents of this file are subject to the AROS Public License Version 1.1
(the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.aros.org/license.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
*/
#ifndef MUICLASS_NETWORK_H
#define MUICLASS_NETWORK_H 1
/*************************************************************************/
#include <exec/types.h>
#include <dos/dos.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/time.h>
#include <netdb.h>
#include "system.h"
#include "muiclass.h"
#include "muiclass_serverlist.h"
#include "muiclass_channellist.h"
#include "muiclass_nicklist.h"
#define NetworkObject NEWOBJECT( appclasses[ CLASSID_NETWORK ]->mcc_Class, NULL
/*
** Methods and attributes
*/
enum {
MM_NETWORK_ = 0xFED00b00,
MM_NETWORK_SERVERFIND,
MM_NETWORK_SERVERALLOC,
MM_NETWORK_SERVERFREE,
MM_NETWORK_SERVERSOCKETINIT,
MM_NETWORK_SERVERSOCKETCLOSE,
MM_NETWORK_SERVERCONNECTAUTO,
MM_NETWORK_SERVERCONNECT,
MM_NETWORK_SERVERDISCONNECT,
MM_NETWORK_SERVERLOGIN,
MM_NETWORK_SERVERAUTOJOIN,
MM_NETWORK_SERVERMESSAGERECEIVED,
MM_NETWORK_SERVERMESSAGESENDMSG,
MM_NETWORK_SERVERMESSAGESENDPROC,
MM_NETWORK_SERVERMESSAGEPROCESS,
MM_NETWORK_SERVERMESSAGEPARSEBEGIN,
MM_NETWORK_SERVERMESSAGEPARSEEND,
MM_NETWORK_SERVERRECEIVEDATA,
MM_NETWORK_SERVERSENDDATA,
MM_NETWORK_WAITSELECT,
MM_NETWORK_CHANNELFIND,
MM_NETWORK_CHANNELALLOC,
MM_NETWORK_CHANNELFREE,
MM_NETWORK_CHATNICKENTRYALLOC,
MM_NETWORK_CHATNICKENTRYFREE,
/* Attributes */
MA_NETWORK_OBJECTSETTINGS,
MA_NETWORK_OBJECTAUDIO,
MA_NETWORK_OBJECTCHATLOG,
};
struct MP_NETWORK_SERVERFIND { ULONG MethodID; struct ServerEntry *ServerEntry; };
struct MP_NETWORK_SERVERALLOC { ULONG MethodID; struct ServerEntry *ServerEntry; };
struct MP_NETWORK_SERVERFREE { ULONG MethodID; struct Server *Server; };
struct MP_NETWORK_SERVERCONNECTAUTO { ULONG MethodID; };
struct MP_NETWORK_SERVERSOCKETINIT { ULONG MethodID; struct Server *Server; };
struct MP_NETWORK_SERVERSOCKETCLOSE { ULONG MethodID; struct Server *Server; };
struct MP_NETWORK_SERVERCONNECT { ULONG MethodID; struct Server *Server; };
struct MP_NETWORK_SERVERDISCONNECT { ULONG MethodID; struct Server *Server; };
struct MP_NETWORK_SERVERLOGIN { ULONG MethodID; struct Server *Server; };
struct MP_NETWORK_SERVERAUTOJOIN { ULONG MethodID; struct Server *Server; };
struct MP_NETWORK_SERVERMESSAGERECEIVED { ULONG MethodID; struct Server *Server; char *Message; };
struct MP_NETWORK_SERVERMESSAGESENDMSG { ULONG MethodID; struct Server *Server; struct Channel *Channel; char *Message; };
struct MP_NETWORK_SERVERMESSAGEPARSEBEGIN { ULONG MethodID; struct Server *Server; char *Message; };
struct MP_NETWORK_SERVERMESSAGEPARSEEND { ULONG MethodID; struct ServerMessageParse *ServerMessageParse; };
struct MP_NETWORK_SERVERMESSAGEPROCESS { ULONG MethodID; struct Server *Server; struct ServerMessageParse *ServerMessageParse; };
struct MP_NETWORK_SERVERRECEIVEDATA { ULONG MethodID; struct Server *Server; char *Data; ULONG Length; };
struct MP_NETWORK_SERVERSENDDATA { ULONG MethodID; struct Server *Server; char *Data; ULONG Length; };
struct MP_NETWORK_WAITSELECT { ULONG MethodID; ULONG *SignalMask; };
struct MP_NETWORK_CHANNELFIND { ULONG MethodID; struct Server *Server; char *Name; };
struct MP_NETWORK_CHANNELALLOC { ULONG MethodID; struct Server *Server; char *Name; ULONG Flags; };
struct MP_NETWORK_CHANNELFREE { ULONG MethodID; struct Server *Server; struct Channel *Channel; };
struct MP_NETWORK_CHATNICKENTRYALLOC { ULONG MethodID; struct Channel *Channel; char *NickName; };
struct MP_NETWORK_CHATNICKENTRYFREE { ULONG MethodID; struct Channel *Channel; struct ChatNickEntry *ChatNickEntry; };
/*************************************************************************/
#define SERVERBUFFER_SIZEOF 0xffff
struct Server {
struct Server *s_Succ;
struct Server *s_Pred;
/* copied over from serverentry */
ULONG s_Port;
char s_Name[ SERVERENTRY_NAME_SIZEOF + 2 ];
char s_Address[ SERVERENTRY_ADDRESS_SIZEOF + 2 ];
char s_Charset[ SERVERENTRY_CHARSET_SIZEOF + 2 ];
char s_Password[ SERVERENTRY_PASSWORD_SIZEOF + 2 ];
struct List s_ChannelList;
struct List s_NickList;
struct List s_SendList;
/* network runtime data */
ULONG s_Flags;
ULONG s_State; /* this is the current state */
ULONG s_Retries;
char s_CurrentNick[ NICKENTRY_NICK_SIZEOF + 2 ];
char s_Buffer[ SERVERBUFFER_SIZEOF + 1 ];
LONG s_BufferFilled;
//struct sockaddr_in s_ServerSocket;
LONG s_ServerSocket;
/* ident */
long s_IdentSocket;
long s_Ident_a_Socket;
struct sockaddr_in s_IdentTest;
// long ident_listen_socket;
// struct sockaddr_in ident_their_addr;
// char ident_buffer[2000];
};
struct Channel {
struct Channel *c_Succ;
struct Channel *c_Pred;
struct List c_ChatLogList;
struct List c_ChatNickList;
BPTR c_ChatLogFile;
char *c_Topic;
ULONG c_Flags;
char c_Name[ CHANNELENTRY_CHANNEL_SIZEOF + 2 ];
char c_Password[ CHANNELENTRY_PASSWORD_SIZEOF + 2 ];
};
#define CHANNELF_SERVER 1 /* this is the servers channel */
#define CHANNELF_NAMESLIST 2 /* set after first NAMES command and cleared on last */
#define CHANNELF_MESSAGEOFTHEDAY 4 /* set after MOTD START arrives and clears on MOTD END */
#define CHANNELF_PUBLIC 8 /* set for public channel, clr for private */
struct Nick {
struct Nick *n_Succ;
struct Nick *n_Pred;
char n_Name[ NICKENTRY_NICK_SIZEOF + 2 ];
char n_Password[ NICKENTRY_NICK_SIZEOF + 2 ];
};
struct ChatNickEntry {
struct ChatNickEntry *cne_Succ;
struct ChatNickEntry *cne_Pred;
char cne_Nick[1];
};
enum{
SVRSTATE_NOTCONNECTED = 0,
SVRSTATE_PRECONNECTED,
SVRSTATE_CONNECTED,
SVRSTATE_RETRY,
SVRSTATE_FAILED,
};
/*
** ServerMessageParse
*/
#define SMP_MESSAGEBUFFER_SIZEOF 0x200
#define SMP_STRINGSTORAGE_SIZEOF 0x1000
struct ServerMessageParse {
ULONG smp_Pen;
ULONG smp_ModeFlags;
struct DateStamp smp_DateStamp;
char smp_MessageBuffer[ SMP_MESSAGEBUFFER_SIZEOF ];
char *smp_From;
char *smp_Command;
char *smp_Arguments;
char *smp_Message;
char *smp_Channel; /* extracted from Arguments */
char *smp_Nick; /* extracted from Arguments */
char *smp_FromNick; /* extracted from Arguments */
char *smp_FromUserID; /* extracted from Arguments */
char *smp_FromHost; /* extracted from Arguments */
char *smp_Flags; /* extracted from Arguments */
char *smp_Date; /* extracted from Arguments */
/* do not use this buffers in CMD functions. Use pointers above */
char smp_StringStorage[ SMP_STRINGSTORAGE_SIZEOF ];
char smp_Data[1];
};
/*
** Prototypes
*/
ULONG MCC_Network_InitClass( void );
void MCC_Network_DisposeClass( void );
/*************************************************************************/
#endif /* MUICLASS_NETWORK_H */