Guardtime Parameter and Task Handling SDK libparamset
param_set.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013-2017 Guardtime, Inc.
3  *
4  * This file is part of the Guardtime client SDK.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License").
7  * You may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  * http://www.apache.org/licenses/LICENSE-2.0
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES, CONDITIONS, OR OTHER LICENSES OF ANY KIND, either
13  * express or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  * "Guardtime" and "KSI" are trademarks or registered trademarks of
16  * Guardtime, Inc., and no license to trademarks is granted; Guardtime
17  * reserves and retains all trademark rights.
18  */
19 
20 #ifndef PARAM_SET_H
21 #define PARAM_SET_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <stdio.h>
28 #include "param_value.h"
29 #include "parameter.h"
30 
31 #ifndef PARAM_SET_ERROR_BASE
32 # define PARAM_SET_ERROR_BASE 0x30001
33 #endif
34 
40  PST_OK = 0,
41 
44 
47 
50 
53 
56 
59 
62 
65 
68 
71 
74 
77 
80 
83 
86 
89 
92 
95 
98 
101 
104 
107 
110 
113 
116 
119 };
120 
125 typedef struct PARAM_SET_st PARAM_SET;
126 
131 const char *PST_getVersion(void);
132 
149 int PARAM_SET_new(const char *names, PARAM_SET **set);
150 
155 void PARAM_SET_free(PARAM_SET *set);
156 
209 int PARAM_SET_addControl(PARAM_SET *set, const char *names,
210  int (*controlFormat)(const char *),
211  int (*controlContent)(const char *),
212  int (*convert)(const char*, char*, unsigned),
213  int (*extractObject)(void **, const char *, void**));
214 
239 int PARAM_SET_setPrintName(PARAM_SET *set, const char *names,
240  const char *constv, const char* (*getPrintName)(PARAM *param, char *buf, unsigned buf_len));
241 
251 int PARAM_SET_setPrintNameAlias(PARAM_SET *set, const char *names,
252  const char *constv, const char* (*getPrintName)(PARAM *param, char *buf, unsigned buf_len));
253 
262 int PARAM_SET_setHelpText(PARAM_SET *set, const char *names, const char *txt);
263 
279 char* PARAM_SET_helpToString(const PARAM_SET *set, const char *names, int indent, int header, int rowWidth, char *buf, size_t buf_len);
280 
299 int PARAM_SET_add(PARAM_SET *set, const char *name, const char *value, const char *source, int priority);
300 
325 int PARAM_SET_getStr(PARAM_SET *set, const char *name, const char *source, int priority, int at, char **value);
326 
356 int PARAM_SET_getObj(PARAM_SET *set, const char *name, const char *source, int priority, int at, void **obj);
357 
372 int PARAM_SET_getObjExtended(PARAM_SET *set, const char *name, const char *source, int priority, int at, void *ctx, void **obj);
373 
386 int PARAM_SET_getAtr(PARAM_SET *set, const char *name, const char *source, int priority, int at, PARAM_ATR *atr);
387 
399 int PARAM_SET_getPrintName(PARAM_SET *set, const char *name, const char **print_name);
400 
410 int PARAM_SET_getPrintNameAlias(PARAM_SET *set, const char *name, const char **print_name);
411 
420 int PARAM_SET_clearParameter(PARAM_SET *set, const char *names);
421 
433 int PARAM_SET_clearValue(PARAM_SET *set, const char *names, const char *source, int priority, int at);
434 
447 int PARAM_SET_getValueCount(PARAM_SET *set, const char *names, const char *source, int priority, int *count);
448 
458 int PARAM_SET_isSetByName(const PARAM_SET *set, const char *names);
459 
469 int PARAM_SET_isOneOfSetByName(const PARAM_SET *set, const char *names);
470 
477 int PARAM_SET_isFormatOK(const PARAM_SET *set);
478 
486 
516 int PARAM_SET_isTypoFailure(const PARAM_SET *set);
517 
524 int PARAM_SET_isSyntaxError(const PARAM_SET *set);
525 
532 int PARAM_SET_isUnknown(const PARAM_SET *set);
533 
555 int PARAM_SET_readFromFile(PARAM_SET *set, const char *fname, const char* source, int priority);
556 
583 int PARAM_SET_readFromCMD(PARAM_SET *set, int argc, char **argv, const char *source, int priority);
584 
585 
612 int PARAM_SET_parseCMD(PARAM_SET *set, int argc, char **argv, const char *source, int priority);
613 
624 int PARAM_SET_setParseOptions(PARAM_SET *set, const char *names, int options);
625 
637 int PARAM_SET_IncludeSet(PARAM_SET *target, PARAM_SET *src);
638 
646 char* PARAM_SET_toString(PARAM_SET *set, char *buf, size_t buf_len);
647 
657 char* PARAM_SET_typosToString(PARAM_SET *set, const char *prefix, char *buf, size_t buf_len);
658 
668 char* PARAM_SET_unknownsToString(const PARAM_SET *set, const char *prefix, char *buf, size_t buf_len);
669 
684 char* PARAM_SET_invalidParametersToString(const PARAM_SET *set, const char *prefix, const char* (*getErrString)(int), char *buf, size_t buf_len);
685 
694 char* PARAM_SET_constraintErrorToString(const PARAM_SET *set, const char *prefix, char *buf, size_t buf_len);
695 
701 const char* PARAM_SET_errorToString(int err);
702 
712 char* PARAM_SET_syntaxErrorsToString(const PARAM_SET *set, const char *prefix, char *buf, size_t buf_len);
713 
726 const char* extract_next_name(const char* name_string, int (*isValidNameChar)(int), char *buf, short len, int *flags);
727 
750 int parse_key_value_pair(const char *line, char *key, char *value, size_t buf_len);
751 
767 int read_line(FILE *file, char *buf, size_t len, size_t *row_pointer, size_t *read_count);
768 
769 
796 int PARAM_SET_setWildcardExpander(PARAM_SET *set, const char *names,
797  const char* charList,
798  void *ctx,
799  void (*ctx_free)(void*),
800  int (*expand_wildcard)(PARAM_VAL *param_value, void *ctx, int *value_shift));
801 
802 #ifdef __cplusplus
803 }
804 #endif
805 
806 #endif
Definition: param_set.h:91
#define PARAM_SET_ERROR_BASE
Definition: param_set.h:32
char * PARAM_SET_toString(PARAM_SET *set, char *buf, size_t buf_len)
Definition: param_set.h:118
Definition: param_set.h:70
int PARAM_SET_isFormatOK(const PARAM_SET *set)
int PARAM_SET_isSetByName(const PARAM_SET *set, const char *names)
int PARAM_SET_isTypoFailure(const PARAM_SET *set)
Definition: param_set.h:52
char * PARAM_SET_constraintErrorToString(const PARAM_SET *set, const char *prefix, char *buf, size_t buf_len)
char * PARAM_SET_helpToString(const PARAM_SET *set, const char *names, int indent, int header, int rowWidth, char *buf, size_t buf_len)
Definition: param_set.h:106
Definition: param_set.h:97
Definition: param_set.h:88
int PARAM_SET_getValueCount(PARAM_SET *set, const char *names, const char *source, int priority, int *count)
int PARAM_SET_getPrintName(PARAM_SET *set, const char *name, const char **print_name)
struct PARAM_VAL_st PARAM_VAL
Definition: param_value.h:34
Definition: param_set.h:64
int PARAM_SET_getObjExtended(PARAM_SET *set, const char *name, const char *source, int priority, int at, void *ctx, void **obj)
Definition: param_set.h:40
int PARAM_SET_clearParameter(PARAM_SET *set, const char *names)
int PARAM_SET_isConstraintViolation(const PARAM_SET *set)
const char * PARAM_SET_errorToString(int err)
int parse_key_value_pair(const char *line, char *key, char *value, size_t buf_len)
Definition: param_set.h:76
Definition: param_set.h:43
char * PARAM_SET_typosToString(PARAM_SET *set, const char *prefix, char *buf, size_t buf_len)
Definition: param_set.h:85
Definition: param_set.h:94
Definition: parameter.h:59
Definition: param_set.h:112
int PARAM_SET_add(PARAM_SET *set, const char *name, const char *value, const char *source, int priority)
int PARAM_SET_getPrintNameAlias(PARAM_SET *set, const char *name, const char **print_name)
int PARAM_SET_setPrintNameAlias(PARAM_SET *set, const char *names, const char *constv, const char *(*getPrintName)(PARAM *param, char *buf, unsigned buf_len))
int PARAM_SET_isSyntaxError(const PARAM_SET *set)
int PARAM_SET_addControl(PARAM_SET *set, const char *names, int(*controlFormat)(const char *), int(*controlContent)(const char *), int(*convert)(const char *, char *, unsigned), int(*extractObject)(void **, const char *, void **))
int read_line(FILE *file, char *buf, size_t len, size_t *row_pointer, size_t *read_count)
Definition: param_set.h:109
Definition: param_set.h:103
Definition: param_set.h:82
struct PARAM_SET_st PARAM_SET
Definition: param_set.h:125
Definition: param_set.h:46
Definition: param_set.h:67
int PARAM_SET_clearValue(PARAM_SET *set, const char *names, const char *source, int priority, int at)
Definition: param_set.h:79
Definition: param_set.h:73
int PARAM_SET_new(const char *names, PARAM_SET **set)
Definition: param_set.h:61
int PARAM_SET_isOneOfSetByName(const PARAM_SET *set, const char *names)
char * PARAM_SET_syntaxErrorsToString(const PARAM_SET *set, const char *prefix, char *buf, size_t buf_len)
const char * PST_getVersion(void)
int PARAM_SET_getStr(PARAM_SET *set, const char *name, const char *source, int priority, int at, char **value)
Definition: param_set.h:55
int PARAM_SET_isUnknown(const PARAM_SET *set)
Definition: param_set.h:49
int PARAM_SET_getObj(PARAM_SET *set, const char *name, const char *source, int priority, int at, void **obj)
int PARAM_SET_IncludeSet(PARAM_SET *target, PARAM_SET *src)
int PARAM_SET_getAtr(PARAM_SET *set, const char *name, const char *source, int priority, int at, PARAM_ATR *atr)
int PARAM_SET_setParseOptions(PARAM_SET *set, const char *names, int options)
PARAM_SET_ERR_enum
Definition: param_set.h:38
int PARAM_SET_setWildcardExpander(PARAM_SET *set, const char *names, const char *charList, void *ctx, void(*ctx_free)(void *), int(*expand_wildcard)(PARAM_VAL *param_value, void *ctx, int *value_shift))
const char * extract_next_name(const char *name_string, int(*isValidNameChar)(int), char *buf, short len, int *flags)
int PARAM_SET_parseCMD(PARAM_SET *set, int argc, char **argv, const char *source, int priority)
Definition: param_set.h:58
Definition: param_set.h:115
int PARAM_SET_readFromFile(PARAM_SET *set, const char *fname, const char *source, int priority)
int PARAM_SET_setPrintName(PARAM_SET *set, const char *names, const char *constv, const char *(*getPrintName)(PARAM *param, char *buf, unsigned buf_len))
char * PARAM_SET_unknownsToString(const PARAM_SET *set, const char *prefix, char *buf, size_t buf_len)
struct PARAM_st PARAM
Definition: parameter.h:35
int PARAM_SET_readFromCMD(PARAM_SET *set, int argc, char **argv, const char *source, int priority)
int PARAM_SET_setHelpText(PARAM_SET *set, const char *names, const char *txt)
char * PARAM_SET_invalidParametersToString(const PARAM_SET *set, const char *prefix, const char *(*getErrString)(int), char *buf, size_t buf_len)
void PARAM_SET_free(PARAM_SET *set)