Changeset 362 in ntrip for trunk/ntripclient


Ignore:
Timestamp:
Jan 9, 2007, 9:16:33 AM (13 years ago)
Author:
stoecker
Message:

added NMEA

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ntripclient/NtripLinuxClient.c

    r339 r362  
    11/*
    22  Easy example NTRIP client for Linux/Unix.
    3   $Id: NtripLinuxClient.c,v 1.22 2006/11/23 14:39:50 stoecker Exp $
     3  $Id: NtripLinuxClient.c,v 1.23 2006/11/29 10:43:15 stoecker Exp $
    44  Copyright (C) 2003-2005 by Dirk Stoecker <soft@dstoecker.de>
    55   
     
    4141
    4242/* CVS revision and version */
    43 static char revisionstr[] = "$Revision: 1.22 $";
    44 static char datestr[]     = "$Date: 2006/11/23 14:39:50 $";
     43static char revisionstr[] = "$Revision: 1.23 $";
     44static char datestr[]     = "$Date: 2006/11/29 10:43:15 $";
    4545
    4646struct Args
     
    5050  const char *user;
    5151  const char *password;
     52  const char *nmea;
    5253  const char *data;
    5354  int         bitrate;
     
    6667{ "port",       required_argument, 0, 'r'},
    6768{ "user",       required_argument, 0, 'u'},
     69{ "nmea",       required_argument, 0, 'n'},
    6870{ "help",       no_argument,       0, 'h'},
    6971{0,0,0,0}};
    7072#endif
    71 #define ARGOPT "-d:bhp:r:s:u:"
     73#define ARGOPT "-d:bhp:r:s:u:n:"
    7274
    7375#ifdef __GNUC__
     
    9698    /* scan for mountpoint */
    9799    args->data = Buffer;
    98     while(*url && *url != '@' && *url != '/' && Buffer != Bufend)
     100    while(*url && *url != '@' &&  *url != ';' &&*url != '/' && Buffer != Bufend)
    99101      *(Buffer++) = *(url++);
    100102    if(Buffer == args->data)
     
    109111    ++url;
    110112    args->user = Buffer;
    111     while(*url && *url != '@' && *url != ':' && Buffer != Bufend)
     113    while(*url && *url != '@' && *url != ';' && *url != ':' && Buffer != Bufend)
    112114      *(Buffer++) = *(url++);
    113115    if(Buffer == args->user)
     
    120122
    121123    args->password = Buffer;
    122     while(*url && *url != '@' && Buffer != Bufend)
     124    while(*url && *url != '@' && *url != ';' && Buffer != Bufend)
    123125      *(Buffer++) = *(url++);
    124126    if(Buffer == args->password)
     
    133135    ++url;
    134136    args->server = Buffer;
    135     while(*url && *url != ':' && Buffer != Bufend)
     137    while(*url && *url != ':' && *url != ';' && Buffer != Bufend)
    136138      *(Buffer++) = *(url++);
    137139    if(Buffer == args->server)
     
    145147      char *s2 = 0;
    146148      args->port = strtol(++url, &s2, 10);
    147       if(*s2 || args->port <= 0 || args->port > 0xFFFF)
     149      if((*s2 && *s2 != ';') || args->port <= 0 || args->port > 0xFFFF)
    148150        return "Illegal port number.";
    149151      url = s2;
    150152    }
     153  }
     154  if(*url == ';') /* NMEA */
     155  {
     156    args->nmea = ++url;
     157    while(*url)
     158      ++url;
    151159  }
    152160
     
    166174  args->user = "";
    167175  args->password = "";
     176  args->nmea = 0;
    168177  args->data = 0;
    169178  args->bitrate = 0;
     
    182191    case 'p': args->password = optarg; break;
    183192    case 'd': args->data = optarg; break;
     193    case 'n': args->nmea = optarg; break;
    184194    case 'b': args->bitrate = 1; break;
    185195    case 'h': help=1; break;
     
    358368      buf[i++] = '\r';
    359369      buf[i++] = '\n';
     370      if(args.nmea)
     371      {
     372        int j = snprintf(buf+i, MAXDATASIZE-i, "%s\r\n", args.nmea);
     373        if(j >= 0 && i < MAXDATASIZE-i)
     374          i += j;
     375        else
     376        {
     377          fprintf(stderr, "NMEA string too long\n");
     378          exit(1);
     379        }
     380      }
    360381    }
    361382    if(send(sockfd, buf, (size_t)i, 0) != i)
Note: See TracChangeset for help on using the changeset viewer.