Changeset 22 in ntrip


Ignore:
Timestamp:
Apr 27, 2005, 12:31:12 PM (19 years ago)
Author:
stoecker
Message:

fixed warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ntripserver/NtripLinuxServer.c

    r21 r22  
    4141 */
    4242
    43 /* $Id: NtripLinuxServer.c,v 1.9 2005/04/19 11:28:17 stoecker Exp $
     43/* $Id: NtripLinuxServer.c,v 1.10 2005/04/27 08:32:43 stoecker Exp $
    4444 * Changes - Version 0.7
    4545 * Sep 22 2003  Steffen Tschirpke <St.Tschirpke@actina.de>
     
    9696#define NTRIP_PORT      80
    9797
    98 int ttybaud             = 19200;
    99 char *ttyport           = "/dev/gps";
    100 char *filepath          = "/dev/stdin";
    101 enum MODE mode          = INFILE;
     98static int ttybaud             = 19200;
     99static const char *ttyport     = "/dev/gps";
     100static const char *filepath    = "/dev/stdin";
     101static enum MODE mode          = INFILE;
    102102
    103103/* Forward references */
    104 int openserial(u_char * tty, int blocksz, int ttybaud);
    105 void send_receive_loop(int socket, int fd);
    106 void usage(int);
     104static int openserial(const char * tty, int blocksz, int baud);
     105static void send_receive_loop(int sock, int fd);
     106static void usage(int);
    107107
    108108/*
     
    126126int main(int argc, char **argv)
    127127{
    128   u_char *ttyin = ttyport;
    129128  int c, gpsfd = -1;
    130129  int size = 2048;              /* for setting send buffer size */
     
    132131  unsigned int out_port = 0;
    133132  unsigned int in_port = 0;
    134   char *mountpoint = NULL;
    135   char *password = "";
    136   char *initfile = NULL;
     133  const char *mountpoint = NULL;
     134  const char *password = "";
     135  const char *initfile = NULL;
    137136  int sock_id;
    138137  char szSendBuffer[BUFSZ];
     
    152151  {
    153152    memset((char *) &out_addr, 0x00, sizeof(out_addr));
    154     memcpy(&out_addr.sin_addr, outhost->h_addr, outhost->h_length);
     153    memcpy(&out_addr.sin_addr, outhost->h_addr, (size_t)outhost->h_length);
    155154  }
    156155
     
    176175      }
    177176      break;
    178     case 'i':                  /* gps serial ttyin */
    179       ttyin = optarg;
     177    case 'i':                  /* gps serial ttyport */
     178      ttyport = optarg;
    180179      break;
    181180    case 'b':                  /* serial ttyin speed */
     
    195194      }
    196195      memset((char *) &out_addr, 0x00, sizeof(out_addr));
    197       memcpy(&out_addr.sin_addr, outhost->h_addr, outhost->h_length);
     196      memcpy(&out_addr.sin_addr, outhost->h_addr, (size_t)outhost->h_length);
    198197      break;
    199198    case 'p':                  /* http server port */
     
    226225      }
    227226      memset((char *) &in_addr, 0x00, sizeof(in_addr));
    228       memcpy(&in_addr.sin_addr, inhost->h_addr, inhost->h_length);
     227      memcpy(&in_addr.sin_addr, inhost->h_addr, (size_t)inhost->h_length);
    229228      break;
    230229    case 'P':                  /* port */
     
    297296  case SERIAL:                 /* open serial port */
    298297    {
    299       gpsfd = openserial(ttyin, 1, ttybaud);
     298      gpsfd = openserial(ttyport, 1, ttybaud);
    300299      if(gpsfd < 0)
    301300      {
    302301        exit(1);
    303302      }
    304       printf("serial input: device = %s, speed = %d\n", ttyin, ttybaud);
     303      printf("serial input: device = %s, speed = %d\n", ttyport, ttybaud);
    305304    }
    306305    break;
     
    336335          while((i = fread(buffer, 1, sizeof(buffer), fh)) > 0)
    337336          {
    338             if((send(gpsfd, buffer, i, 0)) != i)
     337            if((send(gpsfd, buffer, (size_t)i, 0)) != i)
    339338            {
    340339              perror("ERROR: sending init file");
     
    397396    strcat(szSendBuffer, "\0");
    398397    nBufferBytes = strlen(szSendBuffer);
    399     if((send(sock_id, szSendBuffer, nBufferBytes, 0)) != nBufferBytes)
     398    if((send(sock_id, szSendBuffer, (size_t)nBufferBytes, 0)) != nBufferBytes)
    400399    {
    401400      fprintf(stderr, "ERROR: could not send to caster\n");
     
    426425}
    427426
    428 void send_receive_loop(int socket, int fd)
     427static void send_receive_loop(int sock, int fd)
    429428{
    430429  char buffer[BUFSZ] = { 0 };
     
    450449    }
    451450    /* send data */
    452     if((i = send(socket, buffer, nBufferBytes, MSG_DONTWAIT)) != nBufferBytes)
     451    if((i = send(sock, buffer, (size_t)nBufferBytes, MSG_DONTWAIT))
     452    != nBufferBytes)
    453453    {
    454454      if(i < 0 && errno != EAGAIN)
    455455      {
    456456        perror("WARNING: could not send data - retry connection");
    457         close(socket);
     457        close(sock);
    458458        sleep(5);
    459459        return;
     
    461461      else if(i)
    462462      {
    463         memmove(buffer, buffer+i, nBufferBytes-i);
     463        memmove(buffer, buffer+i, (size_t)(nBufferBytes-i));
    464464        nBufferBytes -= i;
    465465      }
     
    482482 *               unsigned char   name of the appropriate serial port.
    483483 *     blocksz : integer       : Block size for port I/O
    484  *     ttybaud : integer       : Baud rate for port I/O
     484 *     baud :    integer       : Baud rate for port I/O
    485485 *
    486486 * Return Value:
     
    492492 */
    493493
    494 int openserial(u_char * tty, int blocksz, int ttybaud)
     494static int openserial(const char * tty, int blocksz, int baud)
    495495{
    496496  int fd;
     
    525525   */
    526526
    527   switch (ttybaud)
     527  switch (baud)
    528528  {
    529529  case 300:
    530     ttybaud = B300;
     530    baud = B300;
    531531    break;
    532532  case 1200:
    533     ttybaud = B1200;
     533    baud = B1200;
    534534    break;
    535535  case 2400:
    536     ttybaud = B2400;
     536    baud = B2400;
    537537    break;
    538538  case 4800:
    539     ttybaud = B4800;
     539    baud = B4800;
    540540    break;
    541541  case 9600:
    542     ttybaud = B9600;
     542    baud = B9600;
    543543    break;
    544544  case 19200:
    545     ttybaud = B19200;
     545    baud = B19200;
    546546    break;
    547547  case 38400:
    548     ttybaud = B38400;
     548    baud = B38400;
    549549    break;
    550550#ifdef B57600
    551551  case 57600:
    552     ttybaud = B57600;
     552    baud = B57600;
    553553    break;
    554554#endif
    555555#ifdef B115200
    556556  case 115200:
    557     ttybaud = B115200;
     557    baud = B115200;
    558558    break;
    559559#endif
    560560#ifdef B230400
    561561  case 230400:
    562     ttybaud = B230400;
     562    baud = B230400;
    563563    break;
    564564#endif
    565565  default:
    566566    fprintf(stderr, "WARNING: Baud settings not useful, using 19200\n");
    567     ttybaud = B19200;
     567    baud = B19200;
    568568    break;
    569569  }
    570570#endif
    571571
    572   if(cfsetispeed(&termios, ttybaud) != 0)
     572  if(cfsetispeed(&termios, baud) != 0)
    573573  {
    574574    perror("ERROR: setting serial speed with cfsetispeed");
    575575    return (-1);
    576576  }
    577   if(cfsetospeed(&termios, ttybaud) != 0)
     577  if(cfsetospeed(&termios, baud) != 0)
    578578  {
    579579    perror("ERROR: setting serial speed with cfsetospeed");
     
    607607 */
    608608
    609 void usage(int rc)
     609static void usage(int rc)
    610610{
    611611  fprintf(stderr, "Usage: %s [OPTIONS]\n", VERSION);
Note: See TracChangeset for help on using the changeset viewer.