kvaMemoLibXML.h
Go to the documentation of this file.
1 /*
2 * Copyright 2017 by Kvaser AB, Molndal, Sweden
3 * http://www.kvaser.com
4 *
5 * This software is dual licensed under the following two licenses:
6 * BSD-new and GPLv2. You may use either one. See the included
7 * COPYING file for details.
8 *
9 * License: BSD-new
10 * ==============================================================================
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * * Neither the name of the <organization> nor the
19 * names of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
30 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * License: GPLv2
36 * ==============================================================================
37 * This program is free software; you can redistribute it and/or modify
38 * it under the terms of the GNU General Public License as published by
39 * the Free Software Foundation; either version 2 of the License, or
40 * (at your option) any later version.
41 *
42 * This program is distributed in the hope that it will be useful,
43 * but WITHOUT ANY WARRANTY; without even the implied warranty of
44 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 * GNU General Public License for more details.
46 *
47 * You should have received a copy of the GNU General Public License
48 * along with this program; if not, write to the Free Software
49 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
50 *
51 *
52 * IMPORTANT NOTICE:
53 * ==============================================================================
54 * This source code is made available for free, as an open license, by Kvaser AB,
55 * for use with its applications. Kvaser AB does not accept any liability
56 * whatsoever for any third party patent or other immaterial property rights
57 * violations that may result from any usage of this source code, regardless of
58 * the combination of source code and various applications that it can be used
59 * in, or with.
60 *
61 * -----------------------------------------------------------------------------
62 */
63 
64 #ifndef KVAMEMOLIBXML_H
65 #define KVAMEMOLIBXML_H
66 
93 #include <stdlib.h>
94 #define WINAPI
95 
96 #ifdef __cplusplus
97 extern "C" {
98 #endif
99 
109 #define XML_ERROR_MESSAGE_LENGTH 2048
110 
122 typedef enum {
136 } KvaXmlStatus;
149 typedef enum {
167 
189 
207 KvaXmlStatus WINAPI kvaXmlGetLastError (char *buf, unsigned int len, KvaXmlStatus *err);
208 
230 KvaXmlStatus WINAPI kvaXmlToBuffer (const char *xmlbuf, unsigned int xmllen, char *outbuf, unsigned int *outlen, long *version);
231 
247 KvaXmlStatus WINAPI kvaXmlToFile (const char *infile, const char *outfile);
248 
264 KvaXmlStatus WINAPI kvaFileToXml(const char * parfile, const char * xmlfile);
265 
279 
301 KvaXmlStatus WINAPI kvaBufferToXml (const char *inbuf, unsigned int inlen, char *xmlbuf, unsigned int *xmllen, long *version, const char * scriptpath);
302 
317 KvaXmlStatus WINAPI kvaXmlValidate (const char *xmlbuf, unsigned int xmllen);
318 
333 KvaXmlStatus WINAPI kvaXmlGetValidationStatusCount (int *countErr, int *countWarn);
334 
351 KvaXmlStatus WINAPI kvaXmlGetValidationError (KvaXmlValidationStatus *status, char *buf, unsigned int len);
352 
369 KvaXmlStatus WINAPI kvaXmlGetValidationWarning (KvaXmlValidationStatus *status, char *buf, unsigned int len);
370 
386 KvaXmlStatus WINAPI kvaXmlGetErrorText (KvaXmlStatus status, char *buf, unsigned int len);
387 
404 KvaXmlStatus WINAPI kvaXmlGetValidationText (KvaXmlValidationStatus status, char *buf, unsigned int len);
405 
418 unsigned short WINAPI kvaXmlGetVersion (void);
419 
420 
421 // Functions and definitions provided by kv_parser, used for going back and
422 // forth between infix and postfix notation.
423 
430 typedef struct tag_token {
431  int type; // T_xxx
432  char *name; // Name for identifiers
433  struct tag_token *left; // Left part of expr if this is an op
434  struct tag_token *right; // Right dito
435  int start_pos; // Token's start pos
436  int end_pos; // Token's end pos
437  struct tag_token *next; // For later memory deallocation
438  int errCode; // ERR_xxx if this is a T_ERROR
439 } Token;
440 
446 typedef struct {
448 } KvParseHandle;
449 
461 
470 
481 void WINAPI kvaToolsExprGetErrorString(int errCode, char *s, size_t bufsiz);
482 
495 int WINAPI kvaToolsParseExpr(KvParseHandle *h, char* expr, Token **t);
496 
508 
521 
535 
549 int WINAPI kvaToolsExprGetError(KvParseHandle *h, Token *t, int *errCode, int *pos);
550 
582 #ifdef __cplusplus
583 }
584 #endif
585 
586 #endif //KVAMEMOLIBXML_H
A trigger on disk full starts the logging.
Definition: kvaMemoLibXML.h:157
KvaXmlValidationStatus
Definition: kvaMemoLibXML.h:149
Token * next
Definition: kvaMemoLibXML.h:447
Failed to find an attribute in a node.
Definition: kvaMemoLibXML.h:125
The trigger expression could not be parsed.
Definition: kvaMemoLibXML.h:131
A general t-script error found during parsing.
Definition: kvaMemoLibXML.h:165
OK.
Definition: kvaMemoLibXML.h:150
Internal errors, e.g. null pointers.
Definition: kvaMemoLibXML.h:135
KvaXmlStatus kvaXmlValidate(const char *xmlbuf, unsigned int xmllen)
struct tag_token * left
Definition: kvaMemoLibXML.h:433
struct tag_token Token
Token used when parsing postfix expressions (deprecated):
KvaXmlStatus
Definition: kvaMemoLibXML.h:122
unsigned short kvaXmlGetVersion(void)
int kvaToolsFreeExpr(KvParseHandle *h, Token *t)
KvaXmlStatus kvaXmlInitialize(void)
KvaXmlStatus kvaXmlToBuffer(const char *xmlbuf, unsigned int xmllen, char *outbuf, unsigned int *outlen, long *version)
No active logging detected.
Definition: kvaMemoLibXML.h:169
t-script related errors, e.g. file not found.
Definition: kvaMemoLibXML.h:134
KvaXmlStatus kvaXmlGetValidationError(KvaXmlValidationStatus *status, char *buf, unsigned int len)
Generic error.
Definition: kvaMemoLibXML.h:151
int end_pos
Definition: kvaMemoLibXML.h:436
int kvaToolsDumpExpr(KvParseHandle *h, Token *t)
KvaXmlStatus kvaXmlGetValidationWarning(KvaXmlValidationStatus *status, char *buf, unsigned int len)
KvaXmlStatus kvaFileToXml(const char *parfile, const char *xmlfile)
void kvaToolsParseDestroy(KvParseHandle *h)
This XML element was ignored.
Definition: kvaMemoLibXML.h:171
A numerical value is out of range.
Definition: kvaMemoLibXML.h:158
struct tag_token * next
Definition: kvaMemoLibXML.h:437
Token used when parsing postfix expressions (deprecated):
Definition: kvaMemoLibXML.h:430
OK.
Definition: kvaMemoLibXML.h:123
KvaXmlStatus kvaXmlToFile(const char *infile, const char *outfile)
KvParseHandle * kvaToolsParseCreate(void)
char * name
Definition: kvaMemoLibXML.h:432
Transmit lists used in silent mode.
Definition: kvaMemoLibXML.h:153
The value is outside the allowed range.
Definition: kvaMemoLibXML.h:128
A t-script file could not be opened.
Definition: kvaMemoLibXML.h:159
int kvaToolsParseExpr(KvParseHandle *h, char *expr, Token **t)
Using more than one external trigger requires firmware version 3.7 or better.
Definition: kvaMemoLibXML.h:172
An undefined trigger is used in an expression.
Definition: kvaMemoLibXML.h:154
KvaXmlStatus kvaXmlGetValidationText(KvaXmlValidationStatus status, char *buf, unsigned int len)
KvaXmlStatus kvaXmlDebugOutput(int on)
A general trigger expression found during parsing.
Definition: kvaMemoLibXML.h:166
int start_pos
Definition: kvaMemoLibXML.h:435
Could not find a required element.
Definition: kvaMemoLibXML.h:127
Too many or too few elements of this type.
Definition: kvaMemoLibXML.h:163
The value is not unique; usually idx attributes.
Definition: kvaMemoLibXML.h:129
int type
Definition: kvaMemoLibXML.h:431
A general error found during parsing.
Definition: kvaMemoLibXML.h:164
Too many warnings, validation aborted.
Definition: kvaMemoLibXML.h:168
There are more than one external trigger defined.
Definition: kvaMemoLibXML.h:155
The XML settings contain syntax errors.
Definition: kvaMemoLibXML.h:132
Handle used when parsing postfix expressions (deprecated):
Definition: kvaMemoLibXML.h:446
Too many errors, validation aborted.
Definition: kvaMemoLibXML.h:152
Generic error.
Definition: kvaMemoLibXML.h:124
int kvaToolsExprHasErrors(KvParseHandle *h, Token *t)
There are more than one start up trigger defined.
Definition: kvaMemoLibXML.h:156
A trigger on disk full used with FIFO mode.
Definition: kvaMemoLibXML.h:170
The values are not consecutive; usually idx attributes.
Definition: kvaMemoLibXML.h:130
The XML settings do not follow the DTD.
Definition: kvaMemoLibXML.h:133
A t-script is too large for the configuration.
Definition: kvaMemoLibXML.h:160
KvaXmlStatus kvaXmlGetValidationStatusCount(int *countErr, int *countWarn)
int kvaToolsExprGetError(KvParseHandle *h, Token *t, int *errCode, int *pos)
The attribute value is not correct, e.g. whitespace after a number.
Definition: kvaMemoLibXML.h:126
struct tag_token * right
Definition: kvaMemoLibXML.h:434
KvaXmlStatus kvaBufferToXml(const char *inbuf, unsigned int inlen, char *xmlbuf, unsigned int *xmllen, long *version, const char *scriptpath)
#define WINAPI
Definition: kvaMemoLibXML.h:94
Too many active t-scripts for selected device.
Definition: kvaMemoLibXML.h:161
KvaXmlStatus kvaXmlGetLastError(char *buf, unsigned int len, KvaXmlStatus *err)
KvaXmlStatus kvaXmlGetErrorText(KvaXmlStatus status, char *buf, unsigned int len)
void kvaToolsExprGetErrorString(int errCode, char *s, size_t bufsiz)
More than one active script is set as &#39;primary&#39;.
Definition: kvaMemoLibXML.h:162
int errCode
Definition: kvaMemoLibXML.h:438