 |
Crossfire Client, Trunk
|
Go to the documentation of this file.
56 LOG(
LOG_ERROR,
"SockList_AddChar",
"Could not write %hu to socket: Buffer full.\n", (
unsigned short)c);
68 sl->
buf[sl->
len++] = (data>>8)&0xff;
69 sl->
buf[sl->
len++] = data & 0xff;
72 LOG(
LOG_ERROR,
"SockList_AddShort",
"Could not write %hu to socket: Buffer full.\n", data);
84 sl->
buf[sl->
len++] = (data>>24)&0xff;
85 sl->
buf[sl->
len++] = (data>>16)&0xff;
86 sl->
buf[sl->
len++] = (data>>8)&0xff;
87 sl->
buf[sl->
len++] = data & 0xff;
90 LOG(
LOG_ERROR,
"SockList_AddInt",
"Could not write %u to socket: Buffer full.\n", data);
101 int len = strlen(str);
106 memcpy(sl->
buf + sl->
len, str, len);
114 sl->
buf[-2] = sl->
len / 256;
115 sl->
buf[-1] = sl->
len % 256;
117 LOG(
LOG_WARNING,
"SockList_Send",
"Sending data while not connected!");
122 if (data_print != NULL) {
127 GOutputStream* out = g_io_stream_get_output_stream(G_IO_STREAM(c));
128 bool ret = g_output_stream_write_all(out, sl->
buf - 2, sl->
len + 2, NULL,
152 return ((data[0]<<24) + (data[1]<<16) + (data[2]<<8) + data[3]);
165 return (((gint64)data[0]<<56) + ((gint64)data[1]<<48) +
166 ((gint64)data[2]<<40) + ((gint64)data[3]<<32) +
167 ((gint64)data[4]<<24) + ((gint64)data[5]<<16) + ((gint64)data[6]<<8) + (gint64)data[7]);
169 return (((guint64)data[0]<<56) + ((guint64)data[1]<<48) +
170 ((guint64)data[2]<<40) + ((guint64)data[3]<<32) +
171 ((guint64)data[4]<<24) + (data[5]<<16) + (data[6]<<8) + data[7]);
182 return ((data[0]<<8)+data[1]);
200 return ((data[0]<<8)+data[1]);
216 if (!g_input_stream_read_all(
in, sl->
buf, 2, &read, NULL, error)) {
224 if (to_read + 2 > len) {
226 "Server packet too big");
229 if (!g_input_stream_read_all(
in, sl->
buf + 2, to_read, &read, NULL, error)) {
232 if (read != to_read) {
236 sl->
len = to_read + 2;
@ LOG_INFO
Minor, non-harmful issues.
int ibytes
ibytes, obytes are bytes in, out.
short GetShort_String(const unsigned char *data)
@ LOG_WARNING
Warning that something might not work.
void SockList_Init(SockList *sl, guint8 *buf)
int SockList_Send(SockList *sl, GSocketConnection *c)
Send data from a socklist to the socket.
void SockList_AddShort(SockList *sl, guint16 data)
void SockList_AddChar(SockList *sl, char c)
int GetInt_String(const unsigned char *data)
The reverse of SockList_AddInt, but on strings instead.
static guint16 GetUShort_String(const unsigned char data[static 2])
Get an unsigned short from the stream.
void SockList_AddInt(SockList *sl, guint32 data)
void script_monitor_str(const char *command)
void SockList_AddString(SockList *sl, const char *str)
void LOG(LogLevel level, const char *origin, const char *format,...)
Log messages of a certain importance to stderr.
int cs_print_string(GSocketConnection *fd, const char *str,...)
Send a printf-formatted packet to the socket.
bool SockList_ReadPacket(GInputStream in[static 1], SockList sl[static 1], size_t len, GError **error)
Reads from the socket and puts data into a socklist.
char * printable(void *data, int len)
Replace the non-printable characters in 'data' with a dot ('.
@ LOG_ERROR
Warning that something definitely didn't work.
gint64 GetInt64_String(const unsigned char *data)
The reverse of SockList_AddInt, but on strings instead.
char GetChar_String(const unsigned char *data)
unsigned char buf[MAXSOCKBUF]
Contains the base information we use to make up a packet we want to send.