00001 /* 00002 Copyright (c) 2005, David M Howard (daveh at dmh2000.com) 00003 All rights reserved. 00004 00005 This product is licensed for use and distribution under the BSD Open Source License. 00006 see the file COPYING for more details. 00007 00008 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00009 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00010 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00011 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00012 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 00013 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00014 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00015 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00016 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00017 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00018 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00019 00020 */ 00021 00022 #ifndef __NMEAP_DEF_H__ 00023 #define __NMEAP_DEF_H__ 00024 00028 typedef struct nmeap_sentence { 00029 char name[NMEAP_MAX_SENTENCE_NAME_LENGTH + 1]; 00030 int id; 00031 nmeap_sentence_parser_t parser; 00032 nmeap_callout_t callout; 00033 void *data; 00034 } nmeap_sentence_t; 00035 00039 struct nmeap_context { 00041 nmeap_sentence_t sentence[NMEAP_MAX_SENTENCES]; /* sentence descriptors */ 00042 int sentence_count; /* number of initialized descriptors */ 00043 00045 char input[NMEAP_MAX_SENTENCE_LENGTH + 1]; /* input line buffer */ 00046 int input_count; /* index into 'input */ 00047 int input_state; /* current lexical scanner state */ 00048 char input_name[6]; /* sentence name */ 00049 char icks; /* input checksum */ 00050 char ccks; /* computed checksum */ 00051 00052 /* tokenization */ 00053 char *token[NMEAP_MAX_TOKENS]; /* list of delimited tokens */ 00054 int tokens; /* list of tokens */ 00055 00057 unsigned long msgs; /* count of good messages */ 00058 unsigned long err_hdr; /* header error */ 00059 unsigned long err_ovr; /* overrun error */ 00060 unsigned long err_unk; /* unknown error */ 00061 unsigned long err_id; /* bad character in id */ 00062 unsigned long err_cks; /* bad checksum */ 00063 unsigned long err_crl; /* expecting cr or lf, got something else */ 00064 char debug_input[NMEAP_MAX_SENTENCE_LENGTH + 1]; /* input line buffer for debug */ 00065 00067 void *user_data; 00068 }; 00069 00070 typedef struct nmeap_context nmeap_context_t; 00071 00072 #endif /* __NMEAP_DEF_H__ */