libsmbios_c library
token.h
Go to the documentation of this file.
1// vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
2/*
3 * Copyright (C) 2005 Dell Inc.
4 * by Michael Brown <Michael_E_Brown@dell.com>
5 * Licensed under the Open Software License version 2.1
6 *
7 * Alternatively, you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2 of the License,
10 * or (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
16 */
17
18
19#ifndef C_OBJ_TOKEN_H
20#define C_OBJ_TOKEN_H
21
22// include smbios_c/compat.h first
23#include "smbios_c/compat.h"
24#include "smbios_c/types.h"
25
26// abi_prefix should be last header included before declarations
28
30
31#define TOKEN_DEFAULTS 0x0000
32#define TOKEN_GET_SINGLETON 0x0001
33#define TOKEN_GET_NEW 0x0002
34#define TOKEN_UNIT_TEST_MODE 0x0004
35#define TOKEN_NO_ERR_CLEAR 0x0008
36
37struct token_table;
38struct token_obj;
39
40// construct
41LIBSMBIOS_C_DLL_SPEC struct token_table *token_table_factory(int flags, ...);
42
43// destruct
44LIBSMBIOS_C_DLL_SPEC void token_table_free(struct token_table *);
45
46// format error string
47LIBSMBIOS_C_DLL_SPEC const char *token_table_strerror(const struct token_table *);
48LIBSMBIOS_C_DLL_SPEC const char *token_obj_strerror(const struct token_obj *);
49
50// for looping/searching
51LIBSMBIOS_C_DLL_SPEC const struct token_obj *token_table_get_next(const struct token_table *, const struct token_obj *cur);
52LIBSMBIOS_C_DLL_SPEC const struct token_obj *token_table_get_next_by_id(const struct token_table *, const struct token_obj *cur, u16 id);
53
54LIBSMBIOS_C_DLL_SPEC u16 token_obj_get_id(const struct token_obj *);
55
56#define token_table_for_each(table_name, struct_name) \
57 for( \
58 const struct token_obj *struct_name = token_table_get_next(table_name, 0);\
59 struct_name;\
60 struct_name = token_table_get_next(table_name, struct_name)\
61 )
62
63#define token_table_for_each_id(table_name, struct_name, id) \
64 for( \
65 const struct token_obj *struct_name = token_table_get_next_id(table_name, 0, id);\
66 struct_name;\
67 struct_name = token_table_get_next_id(table_name, struct_name, id)\
68 )
69
70LIBSMBIOS_C_DLL_SPEC int token_obj_get_type(const struct token_obj *);
71LIBSMBIOS_C_DLL_SPEC bool token_obj_is_bool(const struct token_obj *);
72LIBSMBIOS_C_DLL_SPEC int token_obj_is_active(const struct token_obj *); // return 0,1 or negative error
73LIBSMBIOS_C_DLL_SPEC int token_obj_activate(const struct token_obj *); // return error
74
75LIBSMBIOS_C_DLL_SPEC bool token_obj_is_string(const struct token_obj *);
76LIBSMBIOS_C_DLL_SPEC char* token_obj_get_string(const struct token_obj *, size_t *len); // return 0 on error
77LIBSMBIOS_C_DLL_SPEC int token_obj_set_string(const struct token_obj *, const char *, size_t size); // return error
78
79LIBSMBIOS_C_DLL_SPEC const struct smbios_struct *token_obj_get_smbios_struct(const struct token_obj *);
80LIBSMBIOS_C_DLL_SPEC int token_obj_try_password(const struct token_obj *, const char *pass_ascii, const char *pass_scancode);
81LIBSMBIOS_C_DLL_SPEC const void *token_obj_get_ptr(const struct token_obj *t);
82
83#if defined(_MSC_VER)
84#pragma pack(push,1)
85#endif
97
113
130
151#if defined(_MSC_VER)
152#pragma pack(pop)
153#endif
154
155enum
156{
157 CHECK_TYPE_WORD_CHECKSUM = 0x00, //simple running sum in word
158 CHECK_TYPE_BYTE_CHECKSUM = 0x01, //simple running sum in byte
159 CHECK_TYPE_WORD_CRC = 0x02, // crc
160 CHECK_TYPE_WORD_CHECKSUM_N = 0x03, //simple runnign sum in word, then (~result + 1)
161};
162
164
165// always should be last thing in header file
167
168#endif /* TOKEN_H */
#define LIBSMBIOS_C_DLL_SPEC
Definition compat.h:48
#define EXTERN_C_BEGIN
Definition compat.h:55
#define EXTERN_C_END
Definition compat.h:56
#define LIBSMBIOS_C_PACKED_ATTR
Definition gcc.h:16
LIBSMBIOS_C_DLL_SPEC const struct token_obj * token_table_get_next(const struct token_table *, const struct token_obj *cur)
LIBSMBIOS_C_DLL_SPEC const void * token_obj_get_ptr(const struct token_obj *t)
LIBSMBIOS_C_DLL_SPEC void token_table_free(struct token_table *)
LIBSMBIOS_C_DLL_SPEC int token_obj_get_type(const struct token_obj *)
LIBSMBIOS_C_DLL_SPEC int token_obj_set_string(const struct token_obj *, const char *, size_t size)
LIBSMBIOS_C_DLL_SPEC const struct smbios_struct * token_obj_get_smbios_struct(const struct token_obj *)
LIBSMBIOS_C_DLL_SPEC int token_obj_activate(const struct token_obj *)
LIBSMBIOS_C_DLL_SPEC bool token_obj_is_string(const struct token_obj *)
LIBSMBIOS_C_DLL_SPEC int token_obj_try_password(const struct token_obj *, const char *pass_ascii, const char *pass_scancode)
LIBSMBIOS_C_DLL_SPEC const char * token_obj_strerror(const struct token_obj *)
LIBSMBIOS_C_DLL_SPEC bool token_obj_is_bool(const struct token_obj *)
@ CHECK_TYPE_WORD_CRC
Definition token.h:159
@ CHECK_TYPE_WORD_CHECKSUM
Definition token.h:157
@ CHECK_TYPE_WORD_CHECKSUM_N
Definition token.h:160
@ CHECK_TYPE_BYTE_CHECKSUM
Definition token.h:158
LIBSMBIOS_C_DLL_SPEC char * token_obj_get_string(const struct token_obj *, size_t *len)
LIBSMBIOS_C_DLL_SPEC const char * token_table_strerror(const struct token_table *)
LIBSMBIOS_C_DLL_SPEC struct token_table * token_table_factory(int flags,...)
LIBSMBIOS_C_DLL_SPEC const struct token_obj * token_table_get_next_by_id(const struct token_table *, const struct token_obj *cur, u16 id)
LIBSMBIOS_C_DLL_SPEC int token_obj_is_active(const struct token_obj *)
LIBSMBIOS_C_DLL_SPEC u16 token_obj_get_id(const struct token_obj *)
Definition token.h:115
u16 dataPort
Definition token.h:124
u8 valueStartIndex
Definition token.h:126
u16 indexPort
Definition token.h:123
u16 validationKey
Definition token.h:122
u8 length
Definition token.h:117
u8 checkType
Definition token.h:125
u8 valueFormat
Definition token.h:121
u16 tokenId
Definition token.h:119
u8 checkIndex
Definition token.h:127
u8 type
Definition token.h:116
u16 handle
Definition token.h:118
u8 valueLen
Definition token.h:120
Definition token.h:132
u8 checkIndex
Definition token.h:144
u8 rangeCheckIndex
Definition token.h:148
u8 valueStartIndex
Definition token.h:143
u16 tokenId
Definition token.h:136
u8 type
Definition token.h:133
u8 length
Definition token.h:134
u16 indexPort
Definition token.h:140
u8 valueFormat
Definition token.h:138
u16 handle
Definition token.h:135
u8 rangeCheckType
Definition token.h:145
u8 rangeCheckStart
Definition token.h:146
u16 dataPort
Definition token.h:141
u16 validationKey
Definition token.h:139
u8 rangeCheckEnd
Definition token.h:147
u8 valueLen
Definition token.h:137
u8 checkType
Definition token.h:142
Definition token.h:99
u8 checkedRangeEndIndex
Definition token.h:107
u16 dataPort
Definition token.h:104
u8 length
Definition token.h:101
struct indexed_io_token tokens[]
Definition token.h:110
u8 checkedRangeStartIndex
Definition token.h:106
u16 indexPort
Definition token.h:103
u8 type
Definition token.h:100
u8 checkType
Definition token.h:105
u8 checkValueIndex
Definition token.h:108
u16 handle
Definition token.h:102
Definition token.h:87
u8 location
Definition token.h:89
u8 stringLength
Definition token.h:93
u16 tokenId
Definition token.h:88
u8 andMask
Definition token.h:90
u8 orValue
Definition token.h:92
unsigned short u16
Definition types.h:33
unsigned char u8
Definition types.h:29