Go to the documentation of this file.
55 LOG(
LOG_ERROR,
"SockList_AddChar",
"Could not write %hu to socket: Buffer full.\n", (
unsigned short)c);
67 sl->
buf[sl->
len++] = (data>>8)&0xff;
68 sl->
buf[sl->
len++] = data & 0xff;
71 LOG(
LOG_ERROR,
"SockList_AddShort",
"Could not write %hu to socket: Buffer full.\n", data);
83 sl->
buf[sl->
len++] = (data>>24)&0xff;
84 sl->
buf[sl->
len++] = (data>>16)&0xff;
85 sl->
buf[sl->
len++] = (data>>8)&0xff;
86 sl->
buf[sl->
len++] = data & 0xff;
89 LOG(
LOG_ERROR,
"SockList_AddInt",
"Could not write %u to socket: Buffer full.\n", data);
100 int len = strlen(str);
105 memcpy(sl->
buf + sl->
len, str, len);
113 sl->
buf[-2] = sl->
len / 256;
114 sl->
buf[-1] = sl->
len % 256;
116 LOG(
LOG_WARNING,
"SockList_Send",
"Sending data while not connected!");
121 if (data_print != NULL) {
126 GOutputStream* out = g_io_stream_get_output_stream(G_IO_STREAM(c));
127 bool ret = g_output_stream_write_all(out, sl->
buf - 2, sl->
len + 2, NULL,
151 return ((data[0]<<24) + (data[1]<<16) + (data[2]<<8) + data[3]);
164 return (((gint64)data[0]<<56) + ((gint64)data[1]<<48) +
165 ((gint64)data[2]<<40) + ((gint64)data[3]<<32) +
166 ((gint64)data[4]<<24) + ((gint64)data[5]<<16) + ((gint64)data[6]<<8) + (gint64)data[7]);
168 return (((guint64)data[0]<<56) + ((guint64)data[1]<<48) +
169 ((guint64)data[2]<<40) + ((guint64)data[3]<<32) +
170 ((guint64)data[4]<<24) + (data[5]<<16) + (data[6]<<8) + data[7]);
181 return ((data[0]<<8)+data[1]);
199 return ((data[0]<<8)+data[1]);
214 size_t len, GError** error) {
215 GInputStream*
in = g_io_stream_get_input_stream(G_IO_STREAM(
csocket.
fd));
217 if (!g_input_stream_read_all(
in, sl->
buf, 2, &read, NULL, error)) {
225 if (to_read + 2 > len) {
227 "Server packet too big");
230 if (!g_input_stream_read_all(
in, sl->
buf + 2, to_read, &read, NULL, error)) {
233 if (read != to_read) {
237 sl->
len = to_read + 2;
bool SockList_ReadPacket(GSocketConnection c[static 1], SockList sl[static 1], size_t len, GError **error)
@ LOG_INFO
Minor, non-harmful issues.
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)
void SockList_AddShort(SockList *sl, guint16 data)
void SockList_AddChar(SockList *sl, char c)
int GetInt_String(const unsigned char *data)
static guint16 GetUShort_String(const unsigned char data[static 2])
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,...)
int cs_print_string(GSocketConnection *fd, const char *str,...)
char * printable(void *data, int len)
@ LOG_ERROR
Warning that something definitely didn't work.
gint64 GetInt64_String(const unsigned char *data)
char GetChar_String(const unsigned char *data)
unsigned char buf[MAXSOCKBUF]