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 
204 KvaXmlStatus WINAPI kvaXmlGetLastError (char *buf, unsigned int len, KvaXmlStatus *err);
205 
224 KvaXmlStatus WINAPI kvaXmlToBuffer (const char *xmlbuf, unsigned int xmllen, char *outbuf, unsigned int *outlen, long *version);
225 
238 KvaXmlStatus WINAPI kvaXmlToFile (const char *infile, const char *outfile);
239 
252 KvaXmlStatus WINAPI kvaFileToXml(const char * parfile, const char * xmlfile);
253 
267 
286 KvaXmlStatus WINAPI kvaBufferToXml (const char *inbuf, unsigned int inlen, char *xmlbuf, unsigned int *xmllen, long *version, const char * scriptpath);
287 
299 KvaXmlStatus WINAPI kvaXmlValidate (const char *xmlbuf, unsigned int xmllen);
300 
312 KvaXmlStatus WINAPI kvaXmlGetValidationStatusCount (int *countErr, int *countWarn);
313 
327 KvaXmlStatus WINAPI kvaXmlGetValidationError (KvaXmlValidationStatus *status, char *buf, unsigned int len);
328 
342 KvaXmlStatus WINAPI kvaXmlGetValidationWarning (KvaXmlValidationStatus *status, char *buf, unsigned int len);
343 
356 KvaXmlStatus WINAPI kvaXmlGetErrorText (KvaXmlStatus status, char *buf, unsigned int len);
357 
371 KvaXmlStatus WINAPI kvaXmlGetValidationText (KvaXmlValidationStatus status, char *buf, unsigned int len);
372 
385 unsigned short WINAPI kvaXmlGetVersion (void);
386 
387 
388 // Functions and definitions provided by kv_parser, used for going back and
389 // forth between infix and postfix notation.
390 
397 typedef struct tag_token {
398  int type; // T_xxx
399  char *name; // Name for identifiers
400  struct tag_token *left; // Left part of expr if this is an op
401  struct tag_token *right; // Right dito
402  int start_pos; // Token's start pos
403  int end_pos; // Token's end pos
404  struct tag_token *next; // For later memory deallocation
405  int errCode; // ERR_xxx if this is a T_ERROR
406 } Token;
407 
413 typedef struct {
415 } KvParseHandle;
416 
428 
437 
448 void WINAPI kvaToolsExprGetErrorString(int errCode, char *s, size_t bufsiz);
449 
462 int WINAPI kvaToolsParseExpr(KvParseHandle *h, char* expr, Token **t);
463 
475 
488 
502 
516 int WINAPI kvaToolsExprGetError(KvParseHandle *h, Token *t, int *errCode, int *pos);
517 
547 #ifdef __cplusplus
548 }
549 #endif
550 
551 #endif //KVAMEMOLIBXML_H
int kvaToolsExprHasErrors(KvParseHandle *h, Token *t)
There are more than one start up trigger defined.
Definition: kvaMemoLibXML.h:156
struct tag_token * next
Definition: kvaMemoLibXML.h:404
KvaXmlValidationStatus
Definition: kvaMemoLibXML.h:149
Too many errors, validation aborted.
Definition: kvaMemoLibXML.h:152
More than one active script is set as &#39;primary&#39;.
Definition: kvaMemoLibXML.h:162
There are more than one external trigger defined.
Definition: kvaMemoLibXML.h:155
Too many warnings, validation aborted.
Definition: kvaMemoLibXML.h:168
KvaXmlStatus kvaXmlGetValidationWarning(KvaXmlValidationStatus *status, char *buf, unsigned int len)
Using more than one external trigger requires firmware version 3.7 or better.
Definition: kvaMemoLibXML.h:172
Could not find a required element.
Definition: kvaMemoLibXML.h:127
int type
Definition: kvaMemoLibXML.h:398
Generic error.
Definition: kvaMemoLibXML.h:151
A general trigger expression found during parsing.
Definition: kvaMemoLibXML.h:166
KvaXmlStatus kvaXmlGetErrorText(KvaXmlStatus status, char *buf, unsigned int len)
No active logging detected.
Definition: kvaMemoLibXML.h:169
KvaXmlStatus kvaXmlToFile(const char *infile, const char *outfile)
The value is outside the allowed range.
Definition: kvaMemoLibXML.h:128
struct tag_token Token
Token used when parsing postfix expressions (deprecated):
Generic error.
Definition: kvaMemoLibXML.h:124
#define WINAPI
Definition: kvaMemoLibXML.h:94
Transmit lists used in silent mode.
Definition: kvaMemoLibXML.h:153
Token * next
Definition: kvaMemoLibXML.h:414
int kvaToolsFreeExpr(KvParseHandle *h, Token *t)
int start_pos
Definition: kvaMemoLibXML.h:402
A general t-script error found during parsing.
Definition: kvaMemoLibXML.h:165
This XML element was ignored.
Definition: kvaMemoLibXML.h:171
Failed to find an attribute in a node.
Definition: kvaMemoLibXML.h:125
int end_pos
Definition: kvaMemoLibXML.h:403
KvaXmlStatus kvaXmlDebugOutput(int on)
int errCode
Definition: kvaMemoLibXML.h:405
A trigger on disk full starts the logging.
Definition: kvaMemoLibXML.h:157
A t-script file could not be opened.
Definition: kvaMemoLibXML.h:159
Too many active t-scripts for selected device.
Definition: kvaMemoLibXML.h:161
Internal errors, e.g. null pointers.
Definition: kvaMemoLibXML.h:135
KvaXmlStatus kvaXmlGetValidationError(KvaXmlValidationStatus *status, char *buf, unsigned int len)
An undefined trigger is used in an expression.
Definition: kvaMemoLibXML.h:154
The value is not unique; usually idx attributes.
Definition: kvaMemoLibXML.h:129
The XML settings contain syntax errors.
Definition: kvaMemoLibXML.h:132
KvaXmlStatus kvaXmlGetValidationStatusCount(int *countErr, int *countWarn)
KvaXmlStatus kvaXmlToBuffer(const char *xmlbuf, unsigned int xmllen, char *outbuf, unsigned int *outlen, long *version)
Handle used when parsing postfix expressions (deprecated):
Definition: kvaMemoLibXML.h:413
t-script related errors, e.g. file not found.
Definition: kvaMemoLibXML.h:134
OK.
Definition: kvaMemoLibXML.h:150
Too many or too few elements of this type.
Definition: kvaMemoLibXML.h:163
KvaXmlStatus
Definition: kvaMemoLibXML.h:122
char * name
Definition: kvaMemoLibXML.h:399
The trigger expression could not be parsed.
Definition: kvaMemoLibXML.h:131
KvParseHandle * kvaToolsParseCreate(void)
The XML settings do not follow the DTD.
Definition: kvaMemoLibXML.h:133
The values are not consecutive; usually idx attributes.
Definition: kvaMemoLibXML.h:130
The attribute value is not correct, e.g. whitespace after a number.
Definition: kvaMemoLibXML.h:126
OK.
Definition: kvaMemoLibXML.h:123
int kvaToolsParseExpr(KvParseHandle *h, char *expr, Token **t)
KvaXmlStatus kvaXmlGetValidationText(KvaXmlValidationStatus status, char *buf, unsigned int len)
A trigger on disk full used with FIFO mode.
Definition: kvaMemoLibXML.h:170
int kvaToolsExprGetError(KvParseHandle *h, Token *t, int *errCode, int *pos)
KvaXmlStatus kvaXmlGetLastError(char *buf, unsigned int len, KvaXmlStatus *err)
Token used when parsing postfix expressions (deprecated):
Definition: kvaMemoLibXML.h:397
int kvaToolsDumpExpr(KvParseHandle *h, Token *t)
KvaXmlStatus kvaXmlInitialize(void)
A general error found during parsing.
Definition: kvaMemoLibXML.h:164
A t-script is too large for the configuration.
Definition: kvaMemoLibXML.h:160
void kvaToolsExprGetErrorString(int errCode, char *s, size_t bufsiz)
struct tag_token * left
Definition: kvaMemoLibXML.h:400
void kvaToolsParseDestroy(KvParseHandle *h)
A numerical value is out of range.
Definition: kvaMemoLibXML.h:158
KvaXmlStatus kvaFileToXml(const char *parfile, const char *xmlfile)
KvaXmlStatus kvaXmlValidate(const char *xmlbuf, unsigned int xmllen)
KvaXmlStatus kvaBufferToXml(const char *inbuf, unsigned int inlen, char *xmlbuf, unsigned int *xmllen, long *version, const char *scriptpath)
unsigned short kvaXmlGetVersion(void)
struct tag_token * right
Definition: kvaMemoLibXML.h:401