/usr/src/redhat/BUILD/libsmbios-2.2.21/src/include/smbios_c/obj/token.h

Go to the documentation of this file.
00001 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
00002 /*
00003  * Copyright (C) 2005 Dell Inc.
00004  *  by Michael Brown <Michael_E_Brown@dell.com>
00005  * Licensed under the Open Software License version 2.1
00006  *
00007  * Alternatively, you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published
00009  * by the Free Software Foundation; either version 2 of the License,
00010  * or (at your option) any later version.
00011 
00012  * This program is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00015  * See the GNU General Public License for more details.
00016  */
00017 
00018 
00019 #ifndef C_OBJ_TOKEN_H
00020 #define C_OBJ_TOKEN_H
00021 
00022 // include smbios_c/compat.h first
00023 #include "smbios_c/compat.h"
00024 #include "smbios_c/types.h"
00025 
00026 // abi_prefix should be last header included before declarations
00027 #include "smbios_c/config/abi_prefix.h"
00028 
00029 EXTERN_C_BEGIN;
00030 
00031 #define TOKEN_DEFAULTS       0x0000
00032 #define TOKEN_GET_SINGLETON  0x0001
00033 #define TOKEN_GET_NEW        0x0002
00034 #define TOKEN_UNIT_TEST_MODE 0x0004
00035 #define TOKEN_NO_ERR_CLEAR   0x0008
00036 
00037 struct token_table;
00038 struct token_obj;
00039 
00040 // construct
00041 DLL_SPEC struct token_table * DLL_SPEC token_table_factory(int flags, ...);
00042 
00043 // destruct
00044 DLL_SPEC void  DLL_SPEC token_table_free(struct token_table *);
00045 
00046 // format error string
00047 DLL_SPEC const char * DLL_SPEC token_table_strerror(const struct token_table *);
00048 DLL_SPEC const char * DLL_SPEC token_obj_strerror(const struct token_obj *);
00049 
00050 // for looping/searching
00051 DLL_SPEC const struct token_obj * DLL_SPEC token_table_get_next(const struct token_table *, const struct token_obj *cur);
00052 DLL_SPEC const struct token_obj * DLL_SPEC token_table_get_next_by_id(const struct token_table *, const struct token_obj *cur, u16 id);
00053 
00054 DLL_SPEC u16  DLL_SPEC token_obj_get_id(const struct token_obj *);
00055 
00056 #define token_table_for_each(table_name, struct_name)  \
00057         for(    \
00058             const struct token_obj *struct_name = token_table_get_next(table_name, 0);\
00059             struct_name;\
00060             struct_name = token_table_get_next(table_name, struct_name)\
00061            )
00062 
00063 #define token_table_for_each_id(table_name, struct_name, id)  \
00064         for(    \
00065             const struct token_obj *struct_name = token_table_get_next_id(table_name, 0, id);\
00066             struct_name;\
00067             struct_name = token_table_get_next_id(table_name, struct_name, id)\
00068            )
00069 
00070 DLL_SPEC int  DLL_SPEC token_obj_get_type(const struct token_obj *);
00071 DLL_SPEC bool  DLL_SPEC token_obj_is_bool(const struct token_obj *);
00072 DLL_SPEC int  DLL_SPEC token_obj_is_active(const struct token_obj *);  // return 0,1 or negative error
00073 DLL_SPEC int  DLL_SPEC token_obj_activate(const struct token_obj *);   // return error
00074 
00075 DLL_SPEC bool  DLL_SPEC token_obj_is_string(const struct token_obj *);
00076 DLL_SPEC char*  DLL_SPEC token_obj_get_string(const struct token_obj *, size_t *len);  // return 0 on error
00077 DLL_SPEC int  DLL_SPEC token_obj_set_string(const struct token_obj *, const char *, size_t size);  // return error
00078 
00079 DLL_SPEC const struct smbios_struct * DLL_SPEC token_obj_get_smbios_struct(const struct token_obj *);
00080 DLL_SPEC int  DLL_SPEC token_obj_try_password(const struct token_obj *, const char *pass_ascii, const char *pass_scancode);
00081 DLL_SPEC const void * DLL_SPEC token_obj_get_ptr(const struct token_obj *t);
00082 
00083 #if defined(_MSC_VER)
00084 #pragma pack(push,1)
00085 #endif
00086 struct indexed_io_token
00087 {
00088     u16 tokenId;
00089     u8  location;
00090     u8  andMask;
00091     union {
00092         u8 orValue;
00093         u8 stringLength;
00094     };
00095 }
00096 LIBSMBIOS_C_PACKED_ATTR;
00097 
00098 struct indexed_io_access_structure
00099 { /* 0xD4 structure */
00100     u8       type;
00101     u8       length;
00102     u16      handle;
00103     u16      indexPort;
00104     u16      dataPort;
00105     u8       checkType;
00106     u8       checkedRangeStartIndex;
00107     u8       checkedRangeEndIndex;
00108     u8       checkValueIndex;
00109     //variable number of tokens present, but at least one.
00110     struct   indexed_io_token  tokens[];
00111 }
00112 LIBSMBIOS_C_PACKED_ATTR;
00113 
00114 struct dell_protected_value_1_structure
00115 {  /* 0xD5 structure */
00116     u8       type;
00117     u8       length;
00118     u16      handle;
00119     u16      tokenId;
00120     u8       valueLen;
00121     u8       valueFormat;
00122     u16      validationKey;
00123     u16      indexPort;
00124     u16      dataPort;
00125     u8       checkType;
00126     u8       valueStartIndex;
00127     u8       checkIndex;
00128 }
00129 LIBSMBIOS_C_PACKED_ATTR;
00130 
00131 struct dell_protected_value_2_structure
00132 {  /* 0xD6 structure */
00133     u8       type;
00134     u8       length;
00135     u16      handle;
00136     u16      tokenId;
00137     u8       valueLen;
00138     u8       valueFormat;
00139     u16      validationKey;
00140     u16      indexPort;
00141     u16      dataPort;
00142     u8       checkType;
00143     u8       valueStartIndex;
00144     u8       checkIndex;
00145     u8       rangeCheckType;
00146     u8       rangeCheckStart;
00147     u8       rangeCheckEnd;
00148     u8       rangeCheckIndex;
00149 }
00150 LIBSMBIOS_C_PACKED_ATTR;
00151 #if defined(_MSC_VER)
00152 #pragma pack(pop)
00153 #endif
00154 
00155 enum
00156 {
00157     CHECK_TYPE_WORD_CHECKSUM   = 0x00, //simple running sum in word
00158     CHECK_TYPE_BYTE_CHECKSUM   = 0x01, //simple running sum in byte
00159     CHECK_TYPE_WORD_CRC        = 0x02, // crc
00160     CHECK_TYPE_WORD_CHECKSUM_N = 0x03, //simple runnign sum in word, then (~result + 1)
00161 };
00162 
00163 EXTERN_C_END;
00164 
00165 // always should be last thing in header file
00166 #include "smbios_c/config/abi_suffix.h"
00167 
00168 #endif  /* TOKEN_H */

Generated on Mon Apr 23 19:33:53 2012 for libsmbios_c library by  doxygen 1.4.7