Ignore:
Timestamp:
Nov 10, 2005, 9:41:13 PM (17 years ago)
Author:
Sam Hocevar
Message:
  • absolute shitloads of 64 bit fixes.
Location:
abuse/trunk/src/net
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/net/engine.cpp

    r2 r17  
    246246
    247247    // wait for engine to ack it has attached
    248     uchar ack=0;
     248    uint8_t ack=0;
    249249    if (read(driver_in_fd,&ack,1)!=1 || ack!=1)
    250250      comm_failed();
     
    467467  int fd=connect_to_server(name);
    468468  if (fd<0) return 0;
    469   uchar ctype=CLIENT_LSF_WAITER;
     469  uint8_t ctype=CLIENT_LSF_WAITER;
    470470  if (write(fd,&ctype,1)!=1) { close(fd); return 0; }
    471   uchar len;
     471  uint8_t len;
    472472  if (read(fd,&len,1)!=1 || len==0) { close(fd); return 0; }
    473473  if (read(fd,name_start,len)!=len) { close(fd); return 0; }
     
    482482
    483483  int fd=connect_to_server(server_name);
    484   uchar ctype=CLIENT_ABUSE;
     484  uint8_t ctype=CLIENT_ABUSE;
    485485  if (write(fd,&ctype,1)!=1) { close(fd); return 0; }
    486486
    487487  // send server out game port
    488   ushort port=lstl(packet_port);
     488  uint16_t port=lstl(packet_port);
    489489  if (write(fd,&port,2)!=2) { close(fd); return 0; }
    490490
     
    493493  port=lstl(port);
    494494
    495   ushort cnum;
     495  uint16_t cnum;
    496496  if (read(fd,&cnum,2)!=2 || cnum==0) { close(fd); return 0; }
    497497  cnum=lstl(cnum);
     
    516516    if (!c->has_joined)
    517517    {
    518       ushort cnum=lstl(c->client_id);
     518      uint16_t cnum=lstl(c->client_id);
    519519      if (write(c->socket_fd,&cnum,2)!=2) { c->delete_me=1; }
    520520      c->wait_reload=1;
     
    522522    } else if (!c->delete_me)
    523523    {
    524       uchar reload=CLCMD_RELOAD;
     524      uint8_t reload=CLCMD_RELOAD;
    525525      if (write(c->socket_fd,&reload,1)!=1) { c->delete_me=1; }
    526526      c->wait_reload=1;
     
    582582void process_engine_command()
    583583{
    584   uchar cmd;
     584  uint8_t cmd;
    585585  if (read(driver_in_fd,&cmd,1)!=1) { mdie("could not read command from engine"); }
    586586  switch (cmd)
     
    644644      if (game_server_fd>0)
    645645      {
    646         uchar ok=CLCMD_RELOADED;
     646        uint8_t ok=CLCMD_RELOADED;
    647647        if (!write(game_server_fd,&ok,1)) { mdie("could not send join_ok msg"); }       
    648648        next_process();
     
    657657    case NFCMD_REQUEST_ENTRY :
    658658    {
    659       uchar len;
     659      uint8_t len;
    660660      char name[256];
    661661      if (read(driver_in_fd,&len,1)!=1) { mdie("could not read server name length"); }
    662662      if (read(driver_in_fd,name,len)!=len) { mdie("could not read server name"); }
    663663      strcpy(net_server,name);
    664       ushort success=join_game(name);
     664      uint16_t success=join_game(name);
    665665      if (write(driver_out_fd,&success,2)!=2) mdie("cound not send lsf read failure");     
    666666      next_process();
     
    669669    case NFCMD_REQUEST_LSF :
    670670    {
    671       uchar len;
     671      uint8_t len;
    672672      char name[256];
    673673      if (read(driver_in_fd,&len,1)!=1) { mdie("could not read lsf name length"); }
     
    688688    case NFCMD_PROCESS_LSF :
    689689    {
    690       uchar len,name[256];
     690      uint8_t len,name[256];
    691691      if (read(driver_in_fd,&len,1)!=1) { mdie("could not read lsf name length"); }
    692692      if (read(driver_in_fd,name,len)!=len) { mdie("could not read lsf name"); }
     
    695695        lsf_waiter *c=lsf_wait_list;
    696696        lsf_wait_list=lsf_wait_list->next;
    697         uchar status=1;
     697        uint8_t status=1;
    698698        write(c->socket_fd,&len,1);
    699699        write(c->socket_fd,name,len);
     
    709709        crc_waiter *c=crc_wait_list;
    710710        crc_wait_list=crc_wait_list->next;
    711         uchar status=1;
     711        uint8_t status=1;
    712712        write(c->socket_fd,&status,1);
    713713        delete c;
     
    718718    case NFCMD_SET_FS :
    719719    {
    720       uchar size;
     720      uint8_t size;
    721721      char sn[256];
    722722      if (read(driver_in_fd,&size,1)!=1) mdie("could not read filename length");
     
    730730    case NFCMD_OPEN :
    731731    {
    732       uchar size[2];
     732      uint8_t size[2];
    733733      char filename[300],mode[20],*fn;
    734734      fn=filename;
     
    740740      if (fd==-2)
    741741      {
    742         uchar st[2];
     742        uint8_t st[2];
    743743        st[0]=NF_OPEN_LOCAL_FILE;
    744744        st[1]=strlen(fn)+1;
     
    750750      } else if (fd==-1)
    751751      {
    752         uchar st=NF_OPEN_FAILED;
     752        uint8_t st=NF_OPEN_FAILED;
    753753        if (write(driver_out_fd,&st,1)!=1) comm_failed();
    754754      } else
    755755      {
    756         uchar st=NF_OPEN_REMOTE_FILE;
     756        uint8_t st=NF_OPEN_REMOTE_FILE;
    757757        if (write(driver_out_fd,&st,1)!=1) comm_failed();       
    758758        if (write(driver_out_fd,&fd,sizeof(fd))!=sizeof(fd)) comm_failed();     
     
    778778          unlink_remote_file(rf);
    779779          delete rf;
    780           uchar st=1;
     780          uint8_t st=1;
    781781          if (write(driver_out_fd,&st,1)!=1) comm_failed();     
    782782        } break;
     
    814814int process_client_command(client *c)
    815815{
    816   uchar cmd;
     816  uint8_t cmd;
    817817  if (read(c->socket_fd,&cmd,1)!=1) return 0;
    818818  switch (cmd)
     
    829829    case CLCMD_REQUEST_RESEND :
    830830    {
    831       uchar tick;
     831      uint8_t tick;
    832832      if (read(c->socket_fd,&tick,1)!=1) return 0;
    833833
     
    878878int add_game_client(int fd, sockaddr *from)     // returns false if could not join client
    879879
    880   ushort port;
     880  uint16_t port;
    881881  if (read(fd,&port,2)!=2) { close(fd);  return 0; }
    882882  port=lstl(port);
    883883
    884   ushort pport=lstl(packet_port);
     884  uint16_t pport=lstl(packet_port);
    885885  if (write(fd,&pport,2)!=2) { close(fd);  return 0; } 
    886886
     
    893893  if (f===-1) { close(fd); return 0; }
    894894
    895   ushort client_id=lstl(f);
     895  uint16_t client_id=lstl(f);
    896896  if (write(fd,&client_id,2)!=2) { close(fd);  return 0; }   
    897897
     
    11241124      } else if (FD_ISSET(game_server_fd,&read_set))
    11251125      {
    1126         uchar cmd;
     1126        uint8_t cmd;
    11271127        if (read(game_server_fd,&cmd,1)!=1) { mdie("unable to read command from server"); }
    11281128        switch (cmd)
     
    11341134          case CLCMD_REQUEST_RESEND :
    11351135          {
    1136             uchar tick;
     1136            uint8_t tick;
    11371137            if (read(game_server_fd,&tick,1)!=1) { mdie("unable to read resend tick from server"); }
    11381138
  • abuse/trunk/src/net/fileman.cpp

    r2 r17  
    8181    case NFCMD_READ :
    8282    {
    83       long size;
     83      int32_t size;
    8484      if (c->sock->read(&size,sizeof(size))!=sizeof(size)) return 0;
    8585      size=lltl(size);
     
    9494    case NFCMD_SEEK :
    9595    {
    96       long offset;
     96      int32_t offset;
    9797      if (c->sock->read(&offset,sizeof(offset))!=sizeof(offset)) return 0;
    9898      offset=lltl(offset);
     
    104104    case NFCMD_TELL :
    105105    {
    106       long offset=lseek(c->file_fd,0,SEEK_CUR);
     106      int32_t offset=lseek(c->file_fd,0,SEEK_CUR);
    107107      offset=lltl(offset);
    108108      if (c->sock->write(&offset,sizeof(offset))!=sizeof(offset)) return 0;
     
    215215void file_manager::add_nfs_client(net_socket *sock)
    216216{
    217   uchar size[2];
     217  uint8_t size[2];
    218218  char filename[300],mode[20],*mp;
    219219  if (sock->read(size,2)!=2) { delete sock; return ; }
     
    249249
    250250
    251   long ret=lltl(f);
     251  int32_t ret=lltl(f);
    252252  if (sock->write(&ret,sizeof(ret))!=sizeof(ret)) { delete sock; return ; }
    253253
     
    256256  else
    257257  {
    258     long cur_pos=lseek(f,0,SEEK_CUR);
    259     long size=lseek(f,0,SEEK_END);
     258    int32_t cur_pos=lseek(f,0,SEEK_CUR);
     259    int32_t size=lseek(f,0,SEEK_END);
    260260    lseek(f,cur_pos,SEEK_SET);
    261261    size=lltl(size);
     
    286286  open_local=0;
    287287
    288   uchar sizes[3]={CLIENT_NFS,strlen(filename)+1,strlen(mode)+1};
     288  uint8_t sizes[3]={CLIENT_NFS,strlen(filename)+1,strlen(mode)+1};
    289289  if (sock->write(sizes,3)!=3) { r_close("could not send open info"); return ; }
    290290  if (sock->write(filename,sizes[1])!=sizes[1]) { r_close("could not send filename"); return ; }
    291291  if (sock->write(mode,sizes[2])!=sizes[2]) { r_close("could not send mode"); return ; }
    292292
    293   long remote_file_fd;
     293  int32_t remote_file_fd;
    294294  if (sock->read(&remote_file_fd,sizeof(remote_file_fd))!=sizeof(remote_file_fd))
    295295  { r_close("could not read remote fd"); return ; }   
     
    306306  if (sock && count)
    307307  {
    308     uchar cmd=NFCMD_READ;
     308    uint8_t cmd=NFCMD_READ;
    309309    if (sock->write(&cmd,sizeof(cmd))!=sizeof(cmd)) { r_close("read : could not send command"); return 0; }
    310310
    311     long rsize=lltl(count);
     311    int32_t rsize=lltl(count);
    312312    if (sock->write(&rsize,sizeof(rsize))!=sizeof(rsize)) { r_close("read : could not send size"); return 0; }
    313313
    314     long total_read=0;
     314    int32_t total_read=0;
    315315    char buf[READ_PACKET_SIZE];
    316316
     
    348348}
    349349
    350 long file_manager::remote_file::unbuffered_tell()   // ask server where the offset of the file pointer is
     350int32_t file_manager::remote_file::unbuffered_tell()   // ask server where the offset of the file pointer is
    351351{
    352352  if (sock)
    353353  {
    354     uchar cmd=NFCMD_TELL;
     354    uint8_t cmd=NFCMD_TELL;
    355355    if (sock->write(&cmd,sizeof(cmd))!=sizeof(cmd)) { r_close("tell : could not send command"); return 0; }
    356356
    357     long offset;
     357    int32_t offset;
    358358    if (sock->read(&offset,sizeof(offset))!=sizeof(offset)) { r_close("tell : could not read offset"); return 0; }   
    359359    return lltl(offset);
     
    362362}
    363363
    364 long file_manager::remote_file::unbuffered_seek(long offset)  // tell server to seek to a spot in a file
     364int32_t file_manager::remote_file::unbuffered_seek(int32_t offset)  // tell server to seek to a spot in a file
    365365{
    366366  if (sock)
    367367  {
    368     uchar cmd=NFCMD_SEEK;
     368    uint8_t cmd=NFCMD_SEEK;
    369369    if (sock->write(&cmd,sizeof(cmd))!=sizeof(cmd)) { r_close("seek : could not send command"); return 0; }
    370370
    371     long off=lltl(offset);
     371    int32_t off=lltl(offset);
    372372    if (sock->write(&off,sizeof(off))!=sizeof(off)) { r_close("seek : could not send offset"); return 0; }
    373373
     
    466466
    467467
    468 long file_manager::rf_tell(int fd)
     468int32_t file_manager::rf_tell(int fd)
    469469{
    470470  remote_file *rf=find_rf(fd);
     
    473473}
    474474
    475 long file_manager::rf_seek(int fd, long offset)
     475int32_t file_manager::rf_seek(int fd, int32_t offset)
    476476{
    477477  remote_file *rf=find_rf(fd);
     
    504504}
    505505
    506 long file_manager::rf_file_size(int fd)
     506int32_t file_manager::rf_file_size(int fd)
    507507{
    508508  remote_file *rf=find_rf(fd);
  • abuse/trunk/src/net/gclient.cpp

    r13 r17  
    2424int game_client::process_server_command()
    2525{
    26   uchar cmd;
     26  uint8_t cmd;
    2727  if (client_sock->read(&cmd,1)!=1) return 0;
    2828  switch (cmd)
     
    3030    case CLCMD_REQUEST_RESEND :
    3131    {
    32       uchar tick;
     32      uint8_t tick;
    3333      if (client_sock->read(&tick,1)!=1) return 0;
    3434
     
    6767    if (bytes_received==tmp.packet_size()+tmp.packet_prefix_size())   // was the packet complete?
    6868    {
    69       unsigned short rec_crc=tmp.get_checksum();
     69      uint16_t rec_crc=tmp.get_checksum();
    7070      if (rec_crc==tmp.calc_checksum())
    7171      {
     
    141141int game_client::end_reload(int disconnect)  // notify evryone you've reloaded the level (at server request)
    142142{
    143   uchar cmd=CLCMD_RELOAD_END;
     143  uint8_t cmd=CLCMD_RELOAD_END;
    144144  if (client_sock->write(&cmd,1)!=1) return 0;
    145145  return 1;
     
    148148int game_client::start_reload()
    149149{
    150   uchar cmd=CLCMD_RELOAD_START;
     150  uint8_t cmd=CLCMD_RELOAD_START;
    151151  if (client_sock->write(&cmd,1)!=1) return 0;
    152152  if (client_sock->read(&cmd,1)!=1) return 0;
     
    166166int game_client::quit()
    167167{
    168   uchar cmd=CLCMD_UNJOIN;
     168  uint8_t cmd=CLCMD_UNJOIN;
    169169  if (client_sock->write(&cmd,1)!=1) return 0;
    170170  if (client_sock->read(&cmd,1)!=1) return 0;
  • abuse/trunk/src/net/gserver.cpp

    r4 r17  
    110110      if (c->delete_me())
    111111      {
    112         base->packet.write_byte(SCMD_DELETE_CLIENT);
    113         base->packet.write_byte(c->client_id);
     112        base->packet.write_uint8(SCMD_DELETE_CLIENT);
     113        base->packet.write_uint8(c->client_id);
    114114        if (c->wait_reload())
    115115        {
     
    180180int game_server::process_client_command(player_client *c)
    181181{
    182   uchar cmd;
     182  uint8_t cmd;
    183183  if (c->comm->read(&cmd,1)!=1) return 0;
    184184  switch (cmd)
     
    186186    case CLCMD_REQUEST_RESEND :
    187187    {
    188       uchar tick;
     188      uint8_t tick;
    189189      if (c->comm->read(&tick,1)!=1) return 0;
    190190
     
    244244      if (bytes_received==use->packet_size()+use->packet_prefix_size())
    245245      {
    246         unsigned short rec_crc=use->get_checksum();
     246        uint16_t rec_crc=use->get_checksum();
    247247        if (rec_crc==use->calc_checksum())
    248248        {
     
    351351    if (!c->delete_me() && c->need_reload_start_ok())    // if the client is already waiting for reload state to start, send ok
    352352    {
    353       uchar cmd=CLCMD_RELOAD_START;
     353      uint8_t cmd=CLCMD_RELOAD_START;
    354354      if (c->comm->write(&cmd,1)!=1) { c->set_delete_me(1); }
    355355      c->set_need_reload_start_ok(0);
     
    375375                if( total_players() >= main_net_cfg->max_players )
    376376                {
    377                         uchar too_many = 2;
     377                        uint8_t too_many = 2;
    378378                        sock->write( &too_many, 1 );
    379379                        return 0;
    380380                }
    381381
    382                 uchar reg = registered ? 1 : 0;
     382                uint8_t reg = registered ? 1 : 0;
    383383                if( sock->write( &reg, 1 ) != 1 )
    384384                        return 0;
    385385
    386                 ushort our_port = lstl( main_net_cfg->port + 1 ), cport;
     386                uint16_t our_port = lstl( main_net_cfg->port + 1 ), cport;
    387387                char name[256];
    388                 uchar len;
    389                 short nkills=lstl(main_net_cfg->kills);
     388                uint8_t len;
     389                int16_t nkills=lstl(main_net_cfg->kills);
    390390
    391391                if( sock->read(&len,1)!=1 ||
     
    420420                from->set_port( cport );
    421421
    422                 ushort client_id = lstl( f );
     422                uint16_t client_id = lstl( f );
    423423                if( sock->write( &client_id, 2 ) != 2 )
    424424                {
  • abuse/trunk/src/net/include/endian.hpp

    r2 r17  
    1919
    2020#ifdef BIGUNS
    21 #define swap_short(x) (((((unsigned short) (x)))<<8)|((((unsigned short) (x)))>>8))
    22 #define swap_long(x) \
    23    ((( ((unsigned long)(x)) )>>24)|((( ((unsigned long)(x)) )&0x00ff0000)>>8)| \
    24    ((( ((unsigned long)(x)) )&0x0000ff00)<<8)|(( ((unsigned long)(x)) )<<24))
     21#define swap_uint16(x) (((((uint16_t) (x)))<<8)|((((uint16_t) (x)))>>8))
     22#define swap_uint32(x) \
     23   ((( ((uint32_t)(x)) )>>24)|((( ((uint32_t)(x)) )&0x00ff0000)>>8)| \
     24   ((( ((uint32_t)(x)) )&0x0000ff00)<<8)|(( ((uint32_t)(x)) )<<24))
    2525#else
    26 #define swap_short(x) (x)
    27 #define swap_long(x) (x)
     26#define swap_uint16(x) (x)
     27#define swap_uint32(x) (x)
    2828
    2929#endif
    30 
    31 #define uchar unsigned char
    3230
    3331#endif
  • abuse/trunk/src/net/include/fileman.hpp

    r4 r17  
    2020
    2121    nfs_client *next;
    22     long size_to_read; 
    23     long size;
     22    int32_t size_to_read; 
     23    int32_t size;
    2424    nfs_client(net_socket *sock, int file_fd, nfs_client *next);
    2525    int send_read();     // flushes as much of size_to_read as possible
     
    3333    net_socket *sock;
    3434    void r_close(char *reason);
    35     long size;   // server tells us the size of the file when we open it
     35    int32_t size;   // server tells us the size of the file when we open it
    3636    int open_local;
    3737    remote_file *next;
     
    4040    int unbuffered_read(void *buffer, size_t count);
    4141    int unbuffered_write(void *buf, size_t count) { return 0; } // not supported
    42     long unbuffered_tell();
    43     long unbuffered_seek(long offset);
    44     long file_size() { return size; }
     42    int32_t unbuffered_tell();
     43    int32_t unbuffered_seek(int32_t offset);
     44    int32_t file_size() { return size; }
    4545    int open_failure() { return sock==NULL; }   
    4646    ~remote_file();
     
    6464
    6565  int rf_open_file(char *&filename, char *mode);
    66   long rf_tell(int fd);
    67   long rf_seek(int fd, long offset);
     66  int32_t rf_tell(int fd);
     67  int32_t rf_seek(int fd, int32_t offset);
    6868  int rf_read(int fd, void *buffer, size_t count);
    6969  int rf_close(int fd);
    70   long rf_file_size(int fd);
     70  int32_t rf_file_size(int fd);
    7171  void set_default_fs(net_address *def) { default_fs=def->copy(); }
    7272  ~file_manager() { if (default_fs) delete default_fs; }
  • abuse/trunk/src/net/include/indian.hpp

    r2 r17  
    1010
    1111#ifdef BIGUNS
    12 #define lstl(x) (((((unsigned short) (x)))<<8)|((((unsigned short) (x)))>>8))
     12#define lstl(x) (((((uint16_t) (x)))<<8)|((((uint16_t) (x)))>>8))
    1313#define lltl(x) \
    14    ((( ((unsigned long)(x)) )>>24)|((( ((unsigned long)(x)) )&0x00ff0000)>>8)| \
    15    ((( ((unsigned long)(x)) )&0x0000ff00)<<8)|(( ((unsigned long)(x)) )<<24))
     14   ((( ((uint32_t)(x)) )>>24)|((( ((uint32_t)(x)) )&0x00ff0000)>>8)| \
     15   ((( ((uint32_t)(x)) )&0x0000ff00)<<8)|(( ((uint32_t)(x)) )<<24))
    1616#else
    1717#define lstl(x) (x)
     
    1919
    2020#endif
    21 
    22 #define uchar unsigned char
    2321
    2422#endif
  • abuse/trunk/src/net/include/ipx.hpp

    r2 r17  
    141141    void add_to_packet(void *buf, int size);
    142142
    143     void write_byte(unsigned char x) { add_to_packet(&x,1); }
    144     void write_short(unsigned short x) { x=lstl(x); add_to_packet(&x,2); }
    145     void write_long(unsigned long x) { x=lltl(x); add_to_packet(&x,4); }
     143    void write_uint8(uint8_t x) { add_to_packet(&x,1); }
     144    void write_uint16(uint16_t x) { x=lstl(x); add_to_packet(&x,2); }
     145    void write_uint32(uint32_t x) { x=lltl(x); add_to_packet(&x,4); }
    146146
    147147
  • abuse/trunk/src/net/netdrv.cpp

    r2 r17  
    2424#include <netdb.h>
    2525
    26 #define real2shm(type,ptr) (ptr==NULL ? NULL : ((type *)((char *)(ptr)-(char *)base)))
    27 #define shm2real(type,ptr) (ptr==NULL ? NULL : ((type *)((long)(ptr)+(long)(base))))
     26#define real2shm(type,ptr) (ptr==NULL ? NULL : ((type *)((uint8_t *)(ptr)-(uint8_t *)base)))
     27#define shm2real(type,ptr) (ptr==NULL ? NULL : ((type *)((intptr_t)(ptr)+(intptr_t)(base))))
    2828
    2929net_driver *driver=NULL;
     
    138138
    139139  // wait for engine to ack it has attached
    140   uchar ack=0;
     140  uint8_t ack=0;
    141141  if (in->read(&ack,1)!=1 || ack!=1)
    142142    comm_failed();
     
    216216  if (in->ready_to_read())       // commands from engine?
    217217  {
    218     uchar cmd;
     218    uint8_t cmd;
    219219    if (in->read(&cmd,1)!=1) return 0;
    220220
     
    281281      case NFCMD_REQUEST_ENTRY :
    282282      {
    283         uchar len;
     283        uint8_t len;
    284284        char name[256];
    285285        if (in->read(&len,1)!=1) { mdie("could not read server name length"); }
    286286        if (in->read(name,len)!=len) { mdie("could not read server name"); }
    287         ushort success=join_server(name);
     287        uint16_t success=join_server(name);
    288288        if (out->write(&success,2)!=2) mdie("cound not send lsf read failure");     
    289289      } break;
     
    295295      case NFCMD_REQUEST_LSF :
    296296      {
    297         uchar len;
     297        uint8_t len;
    298298        char name[256];
    299299        if (in->read(&len,1)!=1) { mdie("could not read lsf name length"); }
     
    313313      case NFCMD_PROCESS_LSF :
    314314      {
    315         uchar len,name[256];
     315        uint8_t len,name[256];
    316316        if (in->read(&len,1)!=1) { mdie("could not read lsf name length"); }
    317317        if (in->read(name,len)!=len) { mdie("could not read lsf name"); }
     
    321321          lsf_waiter *c=lsf_wait_list;
    322322          lsf_wait_list=lsf_wait_list->next;
    323           uchar status=1;
     323          uint8_t status=1;
    324324          c->sock->write(&len,1);
    325325          c->sock->write(name,len);
     
    334334          crc_waiter *c=crc_wait_list;
    335335          crc_wait_list=crc_wait_list->next;
    336           uchar status=1;
     336          uint8_t status=1;
    337337          c->sock->write(&status,1);
    338338          delete c;
     
    342342      case NFCMD_SET_FS :
    343343      {
    344         uchar size;
     344        uint8_t size;
    345345        char sn[256];
    346346        if (in->read(&size,1)!=1) mdie("could not read filename length");
     
    354354      case NFCMD_OPEN :
    355355      {
    356         uchar size[2];
     356        uint8_t size[2];
    357357        char filename[300],mode[20],*fn;
    358358        fn=filename;
     
    365365        if (fd==-2)
    366366        {
    367           uchar st[2];
     367          uint8_t st[2];
    368368          st[0]=NF_OPEN_LOCAL_FILE;
    369369          st[1]=strlen(fn)+1;
     
    372372        } else if (fd==-1)
    373373        {
    374           uchar st=NF_OPEN_FAILED;
     374          uint8_t st=NF_OPEN_FAILED;
    375375          if (out->write(&st,1)!=1) comm_failed();
    376376        } else
    377377        {
    378           uchar st=NF_OPEN_REMOTE_FILE;
     378          uint8_t st=NF_OPEN_REMOTE_FILE;
    379379          if (out->write(&st,1)!=1) comm_failed();     
    380380          if (out->write(&fd,sizeof(fd))!=sizeof(fd)) comm_failed();   
     
    395395          {
    396396            fman->rf_close(fd);
    397             uchar st=1;
     397            uint8_t st=1;
    398398            if (out->write(&st,1)!=1) comm_failed();   
    399399          } break;
    400400          case NFCMD_SIZE  :
    401401          {
    402             long x=fman->rf_file_size(fd);
     402            int32_t x=fman->rf_file_size(fd);
    403403            if (out->write(&x,sizeof(x))!=sizeof(x)) comm_failed();               
    404404          } break;
    405405          case NFCMD_TELL :
    406406          {
    407             long offset=fman->rf_tell(fd);
     407            int32_t offset=fman->rf_tell(fd);
    408408            if (out->write(&offset,sizeof(offset))!=sizeof(offset)) comm_failed(); 
    409409          } break;
    410410          case NFCMD_SEEK :
    411411          {
    412             long offset;
     412            int32_t offset;
    413413            if (in->read(&offset,sizeof(offset))!=sizeof(offset)) comm_failed();
    414414            offset=fman->rf_seek(fd,offset);
     
    417417          case NFCMD_READ :
    418418          {
    419             long size;
     419            int32_t size;
    420420            if (in->read(&size,sizeof(size))!=sizeof(size)) comm_failed();
    421421            fman->rf_read(fd,out,size);
     
    446446  }
    447447
    448   uchar ctype=CLIENT_ABUSE;
    449   ushort port=lstl(game_port),cnum;
    450 
    451   uchar reg;
     448  uint8_t ctype=CLIENT_ABUSE;
     449  uint16_t port=lstl(game_port),cnum;
     450
     451  uint8_t reg;
    452452  if (sock->write(&ctype,1)!=1 ||   // send server out game port
    453453      sock->read(&reg,1)!=1)        // is remote engine registered?
     
    484484    strcpy(uname,getlogin());
    485485  else strcpy(uname,"unknown");
    486   uchar len=strlen(uname)+1;
     486  uint8_t len=strlen(uname)+1;
    487487
    488488  if (sock->write(&len,1)!=1 ||
     
    532532  if (!sock) return 0;
    533533
    534   uchar ctype=CLIENT_LSF_WAITER;
    535   uchar len;
     534  uint8_t ctype=CLIENT_LSF_WAITER;
     535  uint8_t len;
    536536
    537537  if (sock->write(&ctype,1)!=1 ||
     
    553553  net_socket *sock=connect_to_server(server);
    554554  if (!sock) return 0;
    555   uchar cmd=CLIENT_CRC_WAITER;
     555  uint8_t cmd=CLIENT_CRC_WAITER;
    556556  if (sock->write(&cmd,1)!=1 ||
    557557      sock->read(&cmd,1)!=1) 
  • abuse/trunk/src/net/netfile.cpp

    r2 r17  
    101101    {
    102102      char buf[READ_PACKET_SIZE];   
    103       short read_total;
    104       short actual;
     103      int16_t read_total;
     104      int16_t actual;
    105105
    106106      do
     
    160160    case NFCMD_READ :
    161161    {
    162       long size;
     162      int32_t size;
    163163      if (read(c->socket_fd,&size,sizeof(size))!=sizeof(size)) return 0;
    164164      size=lltl(size);
     
    173173    case NFCMD_SEEK :
    174174    {
    175       long offset;
     175      int32_t offset;
    176176      if (read(c->socket_fd,&offset,sizeof(offset))!=sizeof(offset)) return 0;
    177177      offset=lltl(offset);
     
    183183    case NFCMD_TELL :
    184184    {
    185       long offset=lseek(c->file_fd,0,SEEK_CUR);
     185      int32_t offset=lseek(c->file_fd,0,SEEK_CUR);
    186186      offset=lltl(offset);
    187187      if (write(c->socket_fd,&offset,sizeof(offset))!=sizeof(offset)) return 0;
     
    200200void add_nfs_client(int fd)
    201201{
    202   uchar size[2];
     202  uint8_t size[2];
    203203  char filename[300],mode[20],*mp;
    204204  if (read(fd,size,2)!=2) { close(fd); return ; }
     
    229229  }
    230230
    231   long ret=lltl(f);
     231  int32_t ret=lltl(f);
    232232  if (write(fd,&ret,sizeof(ret))!=sizeof(ret)) { close(fd); return ; }
    233233
     
    236236  else
    237237  {
    238     long cur_pos=lseek(f,0,SEEK_CUR);
    239     long size=lseek(f,0,SEEK_END);
     238    int32_t cur_pos=lseek(f,0,SEEK_CUR);
     239    int32_t size=lseek(f,0,SEEK_END);
    240240    lseek(f,cur_pos,SEEK_SET);
    241241    size=lltl(size);
     
    253253  if (socket_fd>=0)
    254254  {
    255     uchar cmd=NFCMD_CLOSE;
     255    uint8_t cmd=NFCMD_CLOSE;
    256256    write(socket_fd,&cmd,1);
    257257    close(socket_fd);
     
    272272  }
    273273
    274   uchar sizes[3]={CLIENT_NFS,strlen(filename)+1,strlen(mode)+1};
     274  uint8_t sizes[3]={CLIENT_NFS,strlen(filename)+1,strlen(mode)+1};
    275275  if (write(socket_fd,sizes,3)!=3) { r_close("could not send open info"); return ; }
    276276  if (write(socket_fd,filename,sizes[1])!=sizes[1]) { r_close("could not send filename"); return ; }
    277277  if (write(socket_fd,mode,sizes[2])!=sizes[2]) { r_close("could not send mode"); return ; }
    278278
    279   long remote_file_fd;
     279  int32_t remote_file_fd;
    280280  if (read(socket_fd,&remote_file_fd,sizeof(remote_file_fd))!=sizeof(remote_file_fd))
    281281  { r_close("could not read remote fd"); return ; }   
     
    284284
    285285  if (read(socket_fd,&size,sizeof(size))!=sizeof(size)) { r_close("could not read remote filesize"); return ; }
    286 //  ulong remote_crc;
     286//  uint32_t remote_crc;
    287287//  if (read(socket_fd,&remote_crc,sizeof(remote_crc))!=sizeof(remote_crc)) { r_close("could not read remote checksum"); return ; }
    288 //  ulong local_crc=
     288//  uint32_t local_crc=
    289289
    290290  size=lltl(size);
     
    295295  if (socket_fd>=0 && count)
    296296  {
    297     uchar cmd=NFCMD_READ;
     297    uint8_t cmd=NFCMD_READ;
    298298    if (write(socket_fd,&cmd,sizeof(cmd))!=sizeof(cmd)) { r_close("read : could not send command"); return 0; }
    299299
    300     long rsize=lltl(count);
     300    int32_t rsize=lltl(count);
    301301    if (write(socket_fd,&rsize,sizeof(rsize))!=sizeof(rsize)) { r_close("read : could not send size"); return 0; }
    302302
    303     long total_read=0,total;
     303    int32_t total_read=0,total;
    304304    char buf[READ_PACKET_SIZE];
    305     ushort size;
    306 
    307     ushort packet_size;   
     305    uint16_t size;
     306
     307    uint16_t packet_size;   
    308308    do
    309309    {
     
    315315      packet_size=lstl(packet_size);
    316316
    317       ushort size_read=read(socket_fd,buf+2,packet_size);   
     317      uint16_t size_read=read(socket_fd,buf+2,packet_size);   
    318318
    319319      if (size_read!=packet_size)
     
    326326      }
    327327
    328       *((short *)buf)=packet_size;
     328      *((int16_t *)buf)=packet_size;
    329329      if (write(out_fd,buf,packet_size+2)!=packet_size+2) comm_failed();
    330330
     
    341341  if (socket_fd>=0)
    342342  {
    343     uchar cmd=NFCMD_TELL;
     343    uint8_t cmd=NFCMD_TELL;
    344344    if (write(socket_fd,&cmd,sizeof(cmd))!=sizeof(cmd)) { r_close("tell : could not send command"); return 0; }
    345345
    346     long offset;
     346    int32_t offset;
    347347    if (read(socket_fd,&offset,sizeof(offset))!=sizeof(offset)) { r_close("tell : could not read offset"); return 0; }   
    348348    return lltl(offset);
     
    351351}
    352352
    353 int remote_file::unbuffered_seek(long offset)  // tell server to seek to a spot in a file
     353int remote_file::unbuffered_seek(int32_t offset)  // tell server to seek to a spot in a file
    354354{
    355355  if (socket_fd>=0)
    356356  {
    357     uchar cmd=NFCMD_SEEK;
     357    uint8_t cmd=NFCMD_SEEK;
    358358    if (write(socket_fd,&cmd,sizeof(cmd))!=sizeof(cmd)) { r_close("seek : could not send command"); return 0; }
    359359
    360     long off=lltl(offset);
     360    int32_t off=lltl(offset);
    361361    if (write(socket_fd,&off,sizeof(off))!=sizeof(off)) { r_close("seek : could not send offset"); return 0; }
    362362
     
    450450  }
    451451
    452   uchar cmd=CLIENT_CRC_WAITER;
     452  uint8_t cmd=CLIENT_CRC_WAITER;
    453453  if (write(socket_fd,&cmd,1)!=1)  { close(socket_fd); return 0; }
    454454  if (read(socket_fd,&cmd,1)!=1)  { close(socket_fd); return 0; }
Note: See TracChangeset for help on using the changeset viewer.