diff --git a/sesman/libscp_types.h b/sesman/libscp_types.h index 4aa16753..46e1ed39 100644 --- a/sesman/libscp_types.h +++ b/sesman/libscp_types.h @@ -28,9 +28,6 @@ #ifndef LIBSCP_TYPES_H #define LIBSCP_TYPES_H -#include -#include - #include "os_calls.h" #include "parse.h" #include "arch.h" @@ -39,11 +36,8 @@ //sesman requires its own tcp streaming functions for threading safety #include "tcp.h" -#define SCP_SID uint32_t -#define SCP_DISPLAY uint16_t - -//#warning this should be an INT16 on every platform... -//typedef unsigned int SCP_DISPLAY_PORT; --> uint16_t is it portable? +#define SCP_SID tui32 +#define SCP_DISPLAY tui16 #define SCP_RESOURCE_SHARING_REQUEST_YES 0x01 #define SCP_RESOURCE_SHARING_REQUEST_NO 0x00 @@ -71,33 +65,33 @@ struct SCP_CONNECTION struct SCP_SESSION { - unsigned char type; - uint32_t version; - uint16_t height; - uint16_t width; - unsigned char bpp; - unsigned char rsr; + tui8 type; + tui32 version; + tui16 height; + tui16 width; + tui8 bpp; + tui8 rsr; char locale[18]; char* username; char* password; char* hostname; - unsigned char addr_type; - uint32_t ipv4addr; //htons - uint32_t ipv6addr; //should be 128bit - uint16_t display; + tui8 addr_type; + tui32 ipv4addr; //htons + tui32 ipv6addr; //should be 128bit + tui16 display; char* errstr; }; struct SCP_DISCONNECTED_SESSION { - uint32_t SID; - uint8_t type; - uint16_t height; - uint16_t width; - uint8_t bpp; - uint8_t idle_days; - uint8_t idle_hours; - uint8_t idle_minutes; + tui32 SID; + tui8 type; + tui16 height; + tui16 width; + tui8 bpp; + tui8 idle_days; + tui8 idle_hours; + tui8 idle_minutes; }; enum SCP_CLIENT_STATES_E @@ -134,4 +128,3 @@ enum SCP_SERVER_STATES_E }; #endif - diff --git a/sesman/libscp_v0.c b/sesman/libscp_v0.c index 34675874..c900d9dc 100644 --- a/sesman/libscp_v0.c +++ b/sesman/libscp_v0.c @@ -32,9 +32,9 @@ /******************************************************************************/ enum SCP_CLIENT_STATES_E scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s) { - uint32_t version; - uint32_t size; - uint16_t sz; + tui32 version; + tui32 size; + tui16 sz; init_stream(c->in_s, c->in_s->size); init_stream(c->out_s, c->in_s->size); @@ -122,11 +122,11 @@ enum SCP_CLIENT_STATES_E scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SE /******************************************************************************/ enum SCP_SERVER_STATES_E scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk) { - uint32_t version=0; - uint32_t size; + tui32 version=0; + tui32 size; struct SCP_SESSION* session=0; - uint16_t sz; - uint32_t code=0; + tui16 sz; + tui32 code=0; if (!skipVchk) { diff --git a/sesman/libscp_v1c.c b/sesman/libscp_v1c.c index 17bfb0e0..82242f2b 100644 --- a/sesman/libscp_v1c.c +++ b/sesman/libscp_v1c.c @@ -36,11 +36,8 @@ static enum SCP_CLIENT_STATES_E _scp_v1c_check_response(struct SCP_CONNECTION* c /* 001 */ enum SCP_CLIENT_STATES_E scp_v1c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s) { - unsigned char sz; - uint32_t size; - //uint32_t version; - //uint16_t cmd; - //uint16_t dim; + tui8 sz; + tui32 size; init_stream(c->out_s, c->out_s->size); init_stream(c->in_s, c->in_s->size); @@ -103,11 +100,8 @@ enum SCP_CLIENT_STATES_E scp_v1c_connect(struct SCP_CONNECTION* c, struct SCP_SE /* 004 */ enum SCP_CLIENT_STATES_E scp_v1c_resend_credentials(struct SCP_CONNECTION* c, struct SCP_SESSION* s) { - unsigned char sz; - uint32_t size; - //uint32_t version; - //uint16_t cmd; - //uint16_t dim; + tui8 sz; + tui32 size; init_stream(c->out_s, c->out_s->size); init_stream(c->in_s, c->in_s->size); @@ -145,14 +139,14 @@ enum SCP_CLIENT_STATES_E scp_v1c_resend_credentials(struct SCP_CONNECTION* c, st enum SCP_CLIENT_STATES_E scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount, struct SCP_DISCONNECTED_SESSION** s) { - uint32_t version=1; - uint32_t size=12; - uint16_t cmd=41; - uint32_t sescnt=0; /* total session number */ - uint32_t sestmp=0; /* additional total session number */ - uint8_t pktcnt=0; /* packet session count */ - uint32_t totalcnt=0; /* session counter */ - uint8_t continued=0; /* continue flag */ + tui32 version=1; + tui32 size=12; + tui16 cmd=41; + tui32 sescnt=0; /* total session number */ + tui32 sestmp=0; /* additional total session number */ + tui8 pktcnt=0; /* packet session count */ + tui32 totalcnt=0; /* session counter */ + tui8 continued=0; /* continue flag */ int firstpkt=1; /* "first packet" flag */ int idx; struct SCP_DISCONNECTED_SESSION* ds=0; @@ -255,9 +249,9 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount, struct SCP_DISCO enum SCP_CLIENT_STATES_E scp_v1c_select_session(struct SCP_CONNECTION* c, struct SCP_SESSION* s, SCP_SID sid) { - uint32_t version = 1; - uint32_t size = 16; - uint16_t cmd = 43; + tui32 version = 1; + tui32 size = 16; + tui16 cmd = 43; init_stream(c->out_s, c->out_s->size); @@ -324,9 +318,9 @@ scp_v1c_select_session(struct SCP_CONNECTION* c, struct SCP_SESSION* s, SCP_SID enum SCP_CLIENT_STATES_E scp_v1c_select_session_cancel(struct SCP_CONNECTION* c) { - uint32_t version = 1; - uint32_t size = 12; - uint16_t cmd = 44; + tui32 version = 1; + tui32 size = 12; + tui16 cmd = 44; init_stream(c->out_s, c->out_s->size); @@ -346,10 +340,10 @@ scp_v1c_select_session_cancel(struct SCP_CONNECTION* c) static enum SCP_CLIENT_STATES_E _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s) { - uint32_t version; - uint32_t size; - uint16_t cmd; - uint16_t dim; + tui32 version; + tui32 size; + tui16 cmd; + tui16 dim; init_stream(c->in_s, c->in_s->size); if (0!=tcp_force_recv(c->in_sck, c->in_s->data, 8)) diff --git a/sesman/libscp_v1s.c b/sesman/libscp_v1s.c index 9a3e2df6..0de0dc5a 100644 --- a/sesman/libscp_v1s.c +++ b/sesman/libscp_v1s.c @@ -34,11 +34,11 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk) { struct SCP_SESSION* session; - uint32_t version; - uint32_t size; - uint16_t cmdset; - uint16_t cmd; - unsigned char sz; + tui32 version; + tui32 size; + tui16 cmdset; + tui16 cmd; + tui8 sz; if (!skipVchk) { @@ -202,13 +202,13 @@ scp_v1s_deny_connection(struct SCP_CONNECTION* c, char* reason) enum SCP_SERVER_STATES_E scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char* reason) { - unsigned char sz; + tui8 sz; char *ubuf; char *pbuf; - uint32_t version; - uint32_t size; - uint16_t cmdset; - uint16_t cmd; + tui32 version; + tui32 size; + tui16 cmdset; + tui16 cmd; int rlen; init_stream(c->in_s, c->in_s->size); @@ -325,9 +325,9 @@ enum SCP_SERVER_STATES_E scp_v1s_connect_new_session(struct SCP_CONNECTION* c, SCP_DISPLAY d) { /* send password request */ - uint32_t version=1; - uint32_t size=14; - uint16_t cmd=30; + tui32 version=1; + tui32 size=14; + tui16 cmd=30; init_stream(c->out_s, c->out_s->size); @@ -358,9 +358,9 @@ scp_v1s_connection_error(struct SCP_CONNECTION* c, char* error) enum SCP_SERVER_STATES_E scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNECTED_SESSION* ds, SCP_SID* sid) { - uint32_t version=1; - uint32_t size=12; - uint16_t cmd=40; + tui32 version=1; + tui32 size=12; + tui16 cmd=40; int pktcnt; int idx; int sidx; @@ -564,9 +564,9 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC enum SCP_SERVER_STATES_E scp_v1s_reconnect_session(struct SCP_CONNECTION* c, SCP_DISPLAY d) { - uint32_t version = 1; - uint32_t size = 14; - uint16_t cmd = 46; + tui32 version = 1; + tui32 size = 14; + tui16 cmd = 46; /* ok, we send session data and display */ init_stream(c->out_s, c->out_s->size); diff --git a/sesman/libscp_vX.c b/sesman/libscp_vX.c index 6eeff90c..b186abbf 100644 --- a/sesman/libscp_vX.c +++ b/sesman/libscp_vX.c @@ -22,7 +22,7 @@ * @file libscp_vX.c * @brief libscp version neutral code * @author Simone Fedele - * + * */ #include "libscp_vX.h" @@ -30,16 +30,16 @@ /* server API */ enum SCP_SERVER_STATES_E scp_vXs_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s) { - uint32_t version; + tui32 version; /* reading version and packet size */ if (0!=tcp_force_recv(c->in_sck, c->in_s->data, 8)) { return SCP_SERVER_STATE_NETWORK_ERR; } - + in_uint32_be(c->in_s, version); - + if (version == 0) { return scp_v0s_accept(c, s, 1); @@ -48,6 +48,6 @@ enum SCP_SERVER_STATES_E scp_vXs_accept(struct SCP_CONNECTION* c, struct SCP_SES { return scp_v1s_accept(c, s, 1); } - + return SCP_SERVER_STATE_VERSION_ERR; }