?? readozitrack_file.c
字號:
#ident "@(#) readOzitrack_file.c v1.0.0"/* * Copyright (C) 2002 Ricardo Arroyo <ricardo.arroyo@eresmas.net> * * This code may be used under the terms of Version 2 of the GPL, * read the file COPYING for details. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ******************************************************************************//*Test of GPS Reception module*/#include <stdio.h>#include <sys/param.h>#include <sys/stat.h>#include <stdlib.h>#include <errno.h>#include <string.h>#include <signal.h>#include "lc_debug.h"#include "lc_msg_q.h"#include "lc_syslog.h"#include "recGPS.h"#include "gps.h"#include "rGPS_Debug.h"int iDebug;static key_t ktGPSR_q = GPS_REC_Q; /* default GPS reception module queue key */static key_t ktQueue; /* local queue */static int iLocalQid;static int iRemoteQid;int main(int argc, char **argv){ char sGPSdir[MAXPATHLEN]; struct stat buf; FILE *inf; char line[MAXPATHLEN]; RGPS_ctlMsg *pMsg = NULL; RGPS_dataMsg *pDMsg = NULL; char *p; // *************** Check for Debug environment variable **************** iDebug = ( getenv("GPSNAV_DEBUG") == (char *)0 ? 0 : atoi(getenv("GPSNAV_DEBUG"))); if(argc != 2) { fprintf(stdout,"Usage: readOzitrack_file <track file name>\n"); exit(-1); } p = getenv("GPSDIR"); if(p) { (void) strcpy(sGPSdir,p); (void) strcat(sGPSdir,"/"); } else { (void) strcpy(sGPSdir,""); } (void) strcat(sGPSdir,".GPSconf"); if (iDebug & DEP_GPSREC) { fprintf(stderr,"readOzitrack_file: ConfFile = \"%s\"\n",sGPSdir); } if(!stat(sGPSdir,&buf)) { if(buf.st_mode | S_IRUSR) { if((inf=fopen(sGPSdir,"r"))) { while(fgets(line,MAXPATHLEN,inf)) { if (iDebug & DEP_GPSREC) { fprintf(stderr,"readOzitrack_file: line = %s\n",line); } if(*line=='#' || *line=='\n') continue; line[strlen(line)-1]='\0'; if(!strncmp(line,"REC_QUEUE",9)) { sscanf(&line[9],"%d",&ktGPSR_q); if (iDebug & DEP_GPSREC) { fprintf(stderr,"readOzitrack_file: Queue = %d\n",ktGPSR_q); } } } } } } iRemoteQid = iOpenQmsg(ktGPSR_q); if (iRemoteQid < 0) { vLC_syslog(LCLOG_ERR_MSGQOPEN, "readOzitrack_file", ktGPSR_q); exit(-1); } if (iDebug & DEP_GPSREC) { fprintf(stderr,"readOzitrack_file, iRemoteQid=%d\n",iRemoteQid); } pMsg = malloc(sizeof(RGPS_ctlMsg)); if (iDebug & DEP_GPSREC) { fprintf(stderr,"readOzitrack_file, pMsg=%lx\n",(long)pMsg); } pMsg->mtype = MSG_CONTROL; pMsg->iRGPSid = GPSREC_PLTFILE; strncpy(pMsg->RGPSctl.stcRGPS_PLTfile.stFileName, argv[1], 128); if (iDebug & DEP_GPSREC) { fprintf(stderr,"readOzitrack_file, new file message: file=%s\n", pMsg->RGPSctl.stcRGPS_PLTfile.stFileName); } if (iSend2Queue(iRemoteQid, pMsg, sizeof(RGPS_ctlMsg)) < 0) { vLC_syslog(LCLOG_ERR_MSGQSEND, "readOzitrack_file", iRemoteQid); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -