Changeset 21 in ntrip for trunk/ntripserver


Ignore:
Timestamp:
Apr 27, 2005, 10:32:43 AM (19 years ago)
Author:
stoecker
Message:

added initfile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ntripserver/NtripLinuxServer.c

    r18 r21  
    4141 */
    4242
    43 /* $Id: NtripLinuxServer.c,v 1.8 2005/03/21 13:02:47 stoecker Exp $
     43/* $Id: NtripLinuxServer.c,v 1.9 2005/04/19 11:28:17 stoecker Exp $
    4444 * Changes - Version 0.7
    4545 * Sep 22 2003  Steffen Tschirpke <St.Tschirpke@actina.de>
     
    134134  char *mountpoint = NULL;
    135135  char *password = "";
     136  char *initfile = NULL;
    136137  int sock_id;
    137138  char szSendBuffer[BUFSZ];
     
    160161    exit(1);
    161162  }
    162   while((c = getopt(argc, argv, "M:i:h:b:p:s:a:m:c:H:P:")) != EOF)
     163  while((c = getopt(argc, argv, "M:i:h:b:p:s:a:m:c:H:P:f:")) != EOF)
    163164  {
    164165    switch (c)
    165166    {
    166167    case 'M':
    167       mode = atoi(optarg);
     168      if(!strcmp(optarg, "serial")) mode = 1;
     169      else if(!strcmp(optarg, "tcpsocket")) mode = 2;
     170      else if(!strcmp(optarg, "file")) mode = 3;
     171      else mode = atoi(optarg);
    168172      if((mode == 0) || (mode > 3))
    169173      {
     
    205209      mountpoint = optarg;
    206210      break;
    207     case 'f':                  /* datastream from file */
     211    case 's':                  /* datastream from file */
    208212      filepath = optarg;
     213      break;
     214    case 'f':
     215      initfile = optarg;
    209216      break;
    210217    case 'c':                  /* password */
     
    309316      }
    310317
    311       printf("socket input: host = %s, port = %d\n",
    312         inet_ntoa(in_addr.sin_addr), in_port);
     318      printf("socket input: host = %s, port = %d%s%s\n",
     319        inet_ntoa(in_addr.sin_addr), in_port, initfile ? ", initfile = " : "",
     320        initfile ? initfile : "");
    313321
    314322      if(connect(gpsfd, (struct sockaddr *) &in_addr, sizeof(in_addr)) < 0)
     
    317325          inet_ntoa(in_addr.sin_addr), in_port);
    318326        exit(1);
     327      }
     328      if(initfile)
     329      {
     330        char buffer[1024];
     331        FILE *fh;
     332        int i;
     333
     334        if((fh = fopen(initfile, "r")))
     335        {
     336          while((i = fread(buffer, 1, sizeof(buffer), fh)) > 0)
     337          {
     338            if((send(gpsfd, buffer, i, 0)) != i)
     339            {
     340              perror("ERROR: sending init file");
     341              exit(1);
     342            }
     343          }
     344          if(i < 0)
     345          {
     346            perror("ERROR: reading init file");
     347            exit(1);
     348          }
     349          fclose(fh);
     350        }
     351        else
     352        {
     353          fprintf(stderr, "ERROR: can't read init file %s\n", initfile);
     354          exit(1);
     355        }
    319356      }
    320357    }
     
    594631  fprintf(stderr, "    -P receiver port (default: 1025)\n");
    595632  fprintf(stderr, "    -H hostname of TCP server (default: 127.0.0.1)\n");
     633  fprintf(stderr, "    -f initfile send to server\n");
    596634  fprintf(stderr, "    \n");
    597635  exit(rc);
Note: See TracChangeset for help on using the changeset viewer.