Ignore:
Timestamp:
Nov 10, 2005, 9:41:13 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • absolute shitloads of 64 bit fixes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/unixnfc.cpp

    r4 r17  
    2828#define DOUT_NAME "/tmp/.abuse_ndrv_in"
    2929
    30 #define uchar unsigned char
    31 #define ushort unsigned short
    32 
    33 #define real2shm(type,ptr) (ptr==NULL ? NULL : ((type *)((char *)(ptr)-(char *)base)))
    34 #define shm2real(type,ptr) (ptr==NULL ? NULL : ((type *)((long)(ptr)+(long)(base))))
     30#define real2shm(type,ptr) (ptr==NULL ? NULL : ((type *)((uint8_t *)(ptr)-(uint8_t *)base)))
     31#define shm2real(type,ptr) (ptr==NULL ? NULL : ((type *)((intptr_t)(ptr)+(intptr_t)(base))))
    3532
    3633#ifdef __sgi
     
    192189    if (write(net_out_fd,mode,cm[2])!=cm[2])  { kill_net(); return -1; }
    193190
    194     uchar file_type;
     191    uint8_t file_type;
    195192    if (read(net_in_fd,&file_type,1)!=1)  { kill_net(); return -1; }   
    196193    if (file_type==NF_OPEN_LOCAL_FILE)
    197194    {
    198       uchar name_size;
     195      uint8_t name_size;
    199196      if (read(net_in_fd,&name_size,1)!=1)  { kill_net(); return -1; }         
    200197      int size=read(net_in_fd,filename,name_size);
     
    211208}
    212209
    213 long NF_close(int fd)
     210int32_t NF_close(int fd)
    214211{
    215212  if (net_installed)
     
    225222
    226223
    227 long NF_read(int fd, void *buf, long size)
     224int32_t NF_read(int fd, void *buf, int32_t size)
    228225{
    229226  if (net_installed && size)
     
    235232    if (write(net_out_fd,&size,sizeof(size))!=sizeof(size)) { kill_net(); return 0; }
    236233
    237     long total_read=0;
    238     ushort t=0xffff;
     234    int32_t total_read=0;
     235    uint16_t t=0xffff;
    239236    while (size && t>=READ_PACKET_SIZE-2)
    240237    {
     
    253250
    254251
    255 long NF_filelength(int fd)
     252int32_t NF_filelength(int fd)
    256253{
    257254  if (net_installed)
     
    260257    if (write(net_out_fd,&cm,1)!=1) { kill_net(); return 0; }
    261258    if (write(net_out_fd,&fd,sizeof(fd))!=sizeof(fd)) { kill_net(); return 0; }
    262     long size;
     259    int32_t size;
    263260    if (read(net_in_fd,&size,sizeof(size))!=sizeof(size))  { kill_net(); return 0; }
    264261    return size;
     
    266263}
    267264
    268 long NF_tell(int fd)
     265int32_t NF_tell(int fd)
    269266{
    270267  if (net_installed)
     
    273270    if (write(net_out_fd,&cm,1)!=1) { kill_net(); return 0; }
    274271    if (write(net_out_fd,&fd,sizeof(fd))!=sizeof(fd)) { kill_net(); return 0; }
    275     long offset;
     272    int32_t offset;
    276273    if (read(net_in_fd,&offset,sizeof(offset))!=sizeof(offset))  { kill_net(); return 0; }
    277274    return offset;
     
    279276}
    280277
    281 long NF_seek(int fd, long offset)
     278int32_t NF_seek(int fd, int32_t offset)
    282279{
    283280  if (net_installed)
     
    288285    if (write(net_out_fd,&offset,sizeof(offset))!=sizeof(offset)) { kill_net(); return 0; }
    289286
    290     long offset;
     287    int32_t offset;
    291288    if (read(net_in_fd,&offset,sizeof(offset))!=sizeof(offset))  { kill_net(); return 0; }
    292289    return offset;
     
    322319          base->mem_lock=0;
    323320
    324           uchar cmd=NFCMD_CRCS_CALCED;
     321          uint8_t cmd=NFCMD_CRCS_CALCED;
    325322          if (write(net_out_fd,&cmd,1)!=1) { kill_net(); return ; }
    326323        } else base->mem_lock=0;
     
    332329          base->get_lsf=0;
    333330          base->mem_lock=0;
    334           uchar c[2]={NFCMD_PROCESS_LSF,strlen(lsf)+1};
     331          uint8_t c[2]={NFCMD_PROCESS_LSF,strlen(lsf)+1};
    335332          if (write(net_out_fd,&c,2)!=2) { kill_net(); return ; }
    336333          if (write(net_out_fd,lsf,c[1])!=c[1]) { kill_net(); return ; }
     
    346343  if (net_installed)
    347344  {
    348     uchar cm[2]={NFCMD_REQUEST_LSF,strlen(name)+1};
     345    uint8_t cm[2]={NFCMD_REQUEST_LSF,strlen(name)+1};
    349346    if (write(net_out_fd,cm,2)!=2) { kill_net(); return 0; }
    350347    if (write(net_out_fd,name,cm[1])!=cm[1]) { kill_net(); return 0; }
    351     uchar size;
     348    uint8_t size;
    352349    if (read(net_in_fd,&size,1)!=1) { kill_net(); return 0; }
    353350    if (size==0) return 0;
     
    362359  {
    363360    if (!net_server) return 0;
    364     uchar cm[2]={NFCMD_REQUEST_ENTRY,strlen(net_server)+1};
     361    uint8_t cm[2]={NFCMD_REQUEST_ENTRY,strlen(net_server)+1};
    365362    if (write(net_out_fd,cm,2)!=2) { kill_net(); return 0; }
    366363    if (write(net_out_fd,net_server,cm[1])!=cm[1]) { kill_net(); return 0; }
    367     ushort cnum;  // client number
     364    uint16_t cnum;  // client number
    368365    if (read(net_in_fd,&cnum,2)!=2) { kill_net(); return 0; }
    369366    if (cnum==0) return 0;
     
    378375  if (net_installed)
    379376  {
    380     uchar cmd=NFCMD_RELOAD_START;
     377    uint8_t cmd=NFCMD_RELOAD_START;
    381378    if (write(net_out_fd,&cmd,1)!=1) { kill_net(); return 0; }
    382379    if (read(net_in_fd,&cmd,1)!=1) { kill_net(); return 0; }
     
    390387  if (net_installed)
    391388  {
    392     uchar cmd=NFCMD_RELOAD_END;
     389    uint8_t cmd=NFCMD_RELOAD_END;
    393390    if (write(net_out_fd,&cmd,1)!=1) { kill_net(); return 0; }
    394391    if (read(net_in_fd,&cmd,1)!=1) { kill_net(); return 0; }
     
    505502  {
    506503    if (base->join_list)
    507       base->packet.write_byte(SCMD_RELOAD);
    508 
    509     uchar cmd=NFCMD_SEND_INPUT;
     504      base->packet.write_uint8(SCMD_RELOAD);
     505
     506    uint8_t cmd=NFCMD_SEND_INPUT;
    510507
    511508    if (write(net_out_fd,&cmd,1)!=1) { kill_net(); return ; }   
     
    519516  if (net_installed)
    520517  {
    521     uchar cmd=NFCMD_KILL_SLACKERS;
     518    uint8_t cmd=NFCMD_KILL_SLACKERS;
    522519    if (write(net_out_fd,&cmd,1)!=1) { kill_net(); return ; }   
    523520    if (read(net_in_fd,&cmd,1)!=1) { kill_net(); return ; }       
     
    550547      {
    551548//      fprintf(stderr,"receive timeout %d\n",(((now.tv_sec-start.tv_sec)*100)+(now.tv_usec-start.tv_usec)/10000));
    552         uchar cmd=NFCMD_INPUT_MISSING;
     549        uint8_t cmd=NFCMD_INPUT_MISSING;
    553550        if (write(net_out_fd,&cmd,1)!=1) { kill_net(); return  0; }   
    554551        if (read(net_in_fd,&cmd,1)!=1) { kill_net(); return 0; }     // block, so net driver can request input
     
    624621    else
    625622    {
    626       uchar cmd=NFCMD_BLOCK;
     623      uint8_t cmd=NFCMD_BLOCK;
    627624      if (write(net_out_fd,&cmd,1)!=1) { kill_net(); return ; }   
    628625      if (base->input_state==INPUT_NET_DEAD)
     
    644641  if (net_installed)
    645642  {
    646     uchar cmd=NFCMD_BECOME_SERVER;
     643    uint8_t cmd=NFCMD_BECOME_SERVER;
    647644    if (write(net_out_fd,&cmd,1)!=1) { kill_net(); return 0; }
    648645    if (read(net_in_fd,&cmd,1)!=1) { kill_net(); return 0; }     
Note: See TracChangeset for help on using the changeset viewer.