Crossfire Client, Trunk  R19362
Macros | Functions
newsocket.c File Reference

Made this either client or server specific for 0.95.2 release - getting too complicated to keep them the same, and the common code is pretty much frozen now. More...

#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
#include <client.h>
#include <shared/newclient.h>
#include <script.h>
Include dependency graph for newsocket.c:

Go to the source code of this file.

Macros

#define llevDebug   LOG_DEBUG
 
#define llevError   LOG_ERROR
 

Functions

int cs_print_string (int fd, const char *str,...)
 Send a printf-formatted packet to the socket. More...
 
char GetChar_String (const unsigned char *data)
 
sint64 GetInt64_String (const unsigned char *data)
 The reverse of SockList_AddInt, but on strings instead. More...
 
int GetInt_String (const unsigned char *data)
 The reverse of SockList_AddInt, but on strings instead. More...
 
short GetShort_String (const unsigned char *data)
 
void SockList_AddChar (SockList *sl, char c)
 
void SockList_AddInt (SockList *sl, uint32 data)
 
void SockList_AddShort (SockList *sl, uint16 data)
 
void SockList_AddString (SockList *sl, const char *str)
 
void SockList_Init (SockList *sl, uint8 *buf)
 
int SockList_ReadPacket (int fd, SockList *sl, int len)
 Reads from the socket and puts data into a socklist. More...
 
int SockList_Send (SockList *sl, int fd)
 Send data from a socklist to the socket. More...
 
static int write_socket (int fd, const unsigned char *buf, int len)
 Write at least a specified amount of data in a buffer to the socket unless an error occurs. More...
 

Detailed Description

Made this either client or server specific for 0.95.2 release - getting too complicated to keep them the same, and the common code is pretty much frozen now.

Definition in file newsocket.c.

Macro Definition Documentation

#define llevDebug   LOG_DEBUG

Definition at line 42 of file newsocket.c.

Referenced by SockList_ReadPacket().

#define llevError   LOG_ERROR

Definition at line 43 of file newsocket.c.

Referenced by SockList_ReadPacket(), and write_socket().

Function Documentation

int cs_print_string ( int  fd,
const char *  str,
  ... 
)

Send a printf-formatted packet to the socket.

Parameters
fdThe socket to send to.
strThe printf format string.
...An optional list of values to fulfill the format string.

Definition at line 329 of file newsocket.c.

References SockList::buf, SockList::len, MAX_BUF, script_monitor_str(), SockList_Init(), and SockList_Send().

Referenced by client_send_apply(), client_send_examine(), client_send_move(), command_take(), create_character_window_show(), get_image_info(), get_new_char_info(), look_at(), negotiate_connection(), on_drawingarea_map_configure_event(), read_config_window(), ReplyInfoCmd(), requestface(), script_process_cmd(), send_command(), send_reply(), SendAddMe(), SendVersion(), and SetupCmd().

Here is the call graph for this function:

Here is the caller graph for this function:

char GetChar_String ( const unsigned char *  data)
Parameters
data
Returns

Definition at line 164 of file newsocket.c.

Referenced by AddspellCmd(), ExtSmooth(), get_new_char_info(), MapExtendedCmd(), process_race_class_info(), and UpdspellCmd().

Here is the caller graph for this function:

sint64 GetInt64_String ( const unsigned char *  data)

The reverse of SockList_AddInt, but on strings instead.

Same for the GetShort, but for 64 bits

Parameters
data
Returns

Definition at line 188 of file newsocket.c.

Referenced by get_exp_info(), script_watch(), and StatsCmd().

Here is the caller graph for this function:

int GetInt_String ( const unsigned char *  data)

The reverse of SockList_AddInt, but on strings instead.

Same for the GetShort, but for 16 bits.

Parameters
data
Returns

Definition at line 176 of file newsocket.c.

Referenced by AddspellCmd(), common_item_command(), CompleteCmd(), DeleteItem(), DeleteSpell(), Face2Cmd(), get_image_sums(), Image2Cmd(), PickupCmd(), PlayerCmd(), script_watch(), StatsCmd(), TickCmd(), UpdateItemCmd(), and UpdspellCmd().

Here is the caller graph for this function:

short GetShort_String ( const unsigned char *  data)
void SockList_AddChar ( SockList sl,
char  c 
)
void SockList_AddInt ( SockList sl,
uint32  data 
)
Parameters
sl
data

Definition at line 121 of file newsocket.c.

References SockList::buf, and SockList::len.

Referenced by inscribe_magical_scroll(), script_process_cmd(), send_command(), send_mark_obj(), and toggle_locked().

Here is the caller graph for this function:

void SockList_AddShort ( SockList sl,
uint16  data 
)
Parameters
sl
data

Definition at line 110 of file newsocket.c.

References SockList::buf, and SockList::len.

Referenced by send_command().

Here is the caller graph for this function:

void SockList_AddString ( SockList sl,
const char *  str 
)
void SockList_Init ( SockList sl,
uint8 buf 
)
int SockList_ReadPacket ( int  fd,
SockList sl,
int  len 
)

Reads from the socket and puts data into a socklist.

The only processing done is to remove the initial size value. An assumption made is that the buffer is at least 2 bytes long.

Parameters
fdSocket to read from.
slPointer to a buffer to put the read data.
lenSize of the buffer allocated to accept data.
Returns
Return true if we think we have a full packet, 0 if we have a partial packet, or -1 if an error occurred.

Definition at line 222 of file newsocket.c.

References SockList::buf, cst_lst, cst_tot, CS_Stats::ibytes, SockList::len, llevDebug, llevError, and LOG().

Referenced by DoClient().

Here is the call graph for this function:

Here is the caller graph for this function:

int SockList_Send ( SockList sl,
int  fd 
)

Send data from a socklist to the socket.

Parameters
sl
fd

Definition at line 151 of file newsocket.c.

References SockList::buf, SockList::len, and write_socket().

Referenced by add_character_to_account(), create_new_character(), cs_print_string(), do_account_change(), do_account_create(), do_account_login(), inscribe_magical_scroll(), play_character(), script_process_cmd(), send_command(), send_create_player_to_server(), send_mark_obj(), and toggle_locked().

Here is the call graph for this function:

Here is the caller graph for this function:

static int write_socket ( int  fd,
const unsigned char *  buf,
int  len 
)
static

Write at least a specified amount of data in a buffer to the socket unless an error occurs.

Parameters
fdSocket to write to.
bufBuffer with data to write.
len
Returns

Definition at line 54 of file newsocket.c.

References llevError, and LOG().

Referenced by SockList_Send().

Here is the call graph for this function:

Here is the caller graph for this function: