00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TEKLTI_H_C35A2A4C_D475_11D9_90BC_000BDBC434D9
00023 #define TEKLTI_H_C35A2A4C_D475_11D9_90BC_000BDBC434D9
00024
00025 #define TEKSTD_MAXIMPL 10
00026
00027 #if defined(__cplusplus) && !defined(_cplusplus)
00028 #define _cplusplus (1)
00029 #endif
00030
00031 #ifdef _WINDOWS
00032 #include <windows.h>
00033
00034 #ifdef LIBTEKLTI_EXPORT
00035 #define TEKLTI_DECLSPEC __declspec(dllexport)
00036 #ifdef HAVE_CONFIG_H
00037 #include <config.h>
00038 #endif
00039 #else
00040 #define TEKLTI_DECLSPEC __declspec(dllimport)
00041 #endif
00042
00043 #ifndef USE_UUID_T_FROM_SYSTEM
00044 typedef unsigned char uuid_t[16];
00045 #endif
00046 #else
00047 #ifdef LIBTEKLTI_EXPORT
00048 #ifdef HAVE_CONFIG_H
00049 #include <config.h>
00050 #endif
00051
00052 #ifdef TEKLTI_NO_SIZE_T_CHECKS
00053 #define NO_SIZE_T_CHECKS
00054 #endif
00055
00056 #ifdef USE_386_ASM
00057 #define TEKLTI_USE_386_ASM (1)
00058 #else
00059 #ifdef TEKLTI_USE_386_ASM
00060 #if TEKLTI_USE_386_ASM != 0
00061 #define USE_386_ASM (1)
00062 #endif
00063 #endif
00064 #endif
00065
00066 #ifdef USE_386_ASM_MMX
00067 #define TEKLTI_USE_386_ASM_MMX (1)
00068 #else
00069 #ifdef TEKLTI_USE_386_ASM_MMX
00070 #if TEKLTI_USE_386_ASM_MMX != 0
00071 #define USE_386_ASM_MMX (1)
00072 #endif
00073 #endif
00074 #endif
00075
00076 #ifdef TEKLTI_ENFORCE_PRIVACY
00077 #define USE_386_ASM_ENFORCE_PRIVACY (1)
00078 #endif
00079
00080 #ifdef TEKLTI_USE_386_ASM_FPUTS_FIX1
00081 #define USE_386_ASM_FPUTS_FIX1 (1)
00082 #endif
00083
00084 #ifdef TEKLTI_USE_386_ASM_MALLOC_FIX1
00085 #define USE_386_ASM_MALLOC_FIX1
00086 #endif
00087
00088 #ifdef TEKLTI_USE_386_ASM_MALLOC_FIX2
00089 #define USE_386_ASM_MALLOC_FIX2
00090 #endif
00091
00092
00093 #ifdef TEKLTI_UUID_H_LOC
00094 #if TEKLTI_UUID_H_LOC == 2
00095 #include <uuid.h>
00096 #else
00097 #include <uuid/uuid.h>
00098 #endif
00099 #else
00100 #include <uuid.h>
00101 #endif
00102 #else
00103 #ifndef TEKLTI_DO_NOT_INCLUDE_SYS_HEADERS
00104 #ifdef TEKLTI_UUID_H_NOTRAIL
00105 #include <uuid.h>
00106 #else
00107 #include <uuid/uuid.h>
00108 #endif
00109 #endif
00110 #endif
00111
00112 #define TEKLTI_DECLSPEC
00113
00114 #ifndef TEKLTI_DO_NOT_INCLUDE_SYS_HEADERS
00115
00116 #ifdef HAVE_STDLIB_H
00117 #include <stdlib.h>
00118 #endif
00119
00120 #ifdef HAVE_STRINGS_H
00121 #include <string.h>
00122 #endif
00123
00124 #ifdef HAVE_INTTYPES_H
00125 #include <inttypes.h>
00126 #endif
00127
00128 #ifdef HAVE_STDIO_H
00129 #ifdef _cplusplus
00130 #include <iostream>
00131 #else
00132 #include <stdio.h>
00133 #endif
00134 #endif
00135
00136 #ifdef HAVE_STDINT_H
00137 #if HAVE_STDINT_H != 0
00138 #include <stdint.h>
00139 #endif
00140 #endif
00141
00142 #ifdef HAVE_SYS_STAT_H
00143 #include <sys/stat.h>
00144 #endif
00145 #endif
00146
00147 #ifndef TEKLTI_DO_NOT_DEFINE_INTTYPES
00148 #ifndef HAVE_U_INT64_T
00149 typedef unsigned long long int u_int64_t;
00150 #endif
00151 #ifndef HAVE_UINT64_T
00152 typedef unsigned long long int uint64_t;
00153 #endif
00154 #ifndef HAVE_INT64_T
00155 typedef signed long long int int64_t;
00156 #endif
00157
00158 #ifndef HAVE_U_INT32_T
00159 typedef unsigned long u_int32_t;
00160 #endif
00161 #ifndef HAVE_UINT32_T
00162 typedef unsigned long uint32_t;
00163 #endif
00164 #ifndef HAVE_INT32_T
00165 typedef signed long int32_t;
00166 #endif
00167
00168 #ifndef HAVE_U_INT16_T
00169 typedef unsigned short u_int16_t;
00170 #endif
00171 #ifndef HAVE_UINT16_T
00172 typedef unsigned short uint16_t;
00173 #endif
00174 #ifndef HAVE_INT16_T
00175 typedef signed long int16_t;
00176 #endif
00177
00178 #ifndef HAVE_U_INT8_T
00179 typedef unsigned char u_int8_t;
00180 #endif
00181 #ifndef HAVE_UINT8_T
00182 typedef unsigned char uint8_t;
00183 #endif
00184 #ifndef HAVE_INT8_T
00185 typedef signed char int8_t;
00186 #endif
00187 #endif
00188
00189
00190
00191
00192
00193
00194
00195 #endif
00196
00197
00198
00199
00200
00201
00202 #ifdef TEKLTI_USE_BZIP2
00203 #ifdef TEKLTI_USE_PROVIDED_BZIP2
00204 #include "../bzip2/bzlib.h"
00205 #else
00206 #include <bzlib.h>
00207 #endif
00208 #endif
00209
00210
00211 #ifdef _cplusplus
00212 extern "C"
00213 {
00214 #endif
00215
00216 #ifdef COMPILING_LIBTEKLTI
00217
00220 struct i64
00221 {
00225 unsigned int i64_a;
00229 unsigned int i64_b;
00230 };
00231 #endif
00232
00233
00234
00235
00236
00237
00238
00239 #if !defined(USE_386_ASM) && defined(USE_386_ASM_MMX)
00240 #error USE_386_ASM_MMX cannot be defined unless USE_386_ASM is defined.
00241 #endif
00242
00243 #if !defined(USE_386_ASM_MMX) && defined(USE_386_ASM_MMX_RESET_MM7)
00244 #error USE_386_ASM_MMX_RESET_MM7 cannot be defined unless USE_386_ASM_MMX is defined.
00245 #endif
00246
00247
00248 #ifdef TEKLTI_USE_386_ASM_MMX_FPUTS_SAFE
00249 #ifndef TEKLTI_USE_386_ASM_FPUTS_FIX1
00250 #error TEKLTI_USE_386_ASM_MMX_FPUTS_SAFE cannot be defined unless TEKLTI_USE_386_ASM_FPUTS_FIX1 is defined.
00251 #endif
00252 #define USE_386_ASM_MMX_FPUTS_SAFE (1)
00253 #endif
00254
00255
00261 typedef struct _uchar_t
00262 {
00266 char * uchar_t_ascii;
00270 size_t uchar_t_asciilen;
00271 #ifdef UNICODE
00272
00275 wchar_t * uchar_t_unicode;
00279 size_t uchar_t_unicodelen;
00280 #endif
00281 } uchar_t;
00282
00283
00284
00285 typedef unsigned long TEKERR;
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304 #define TEKERR_OK 0x00000000
00305
00306 #define TEKERR_NOTIMPL 0x00000001
00307
00308 #define TEKERR_FAIL 0x00000002
00309
00310 #define TEKERR_UNEXPECTED 0x00000004
00311
00312 #define TEKERR_MEMORY 0x00000008
00313
00314 #define TEKERR_ACCESS 0x00000010
00315
00316 #define TEKERR_POINTER 0x00000020
00317
00318 #define TEKERR_UNAVAILABLE 0x00000040
00319
00320 #define TEKERR_SEQUENCE 0x00000080
00321
00322
00323 #define TEKERR_DB_CANTCONNECT 0x00000100
00324
00325 #define TEKERR_DB_ACCESSDENIED 0x00000200
00326
00327 #define TEKERR_DB_NOTALLOWED 0x00000400
00328
00329 #define TEKERR_DB_CORRUPT 0x00000800
00330
00331
00332 #define TEKERR_FILE_DISKFULL 0x00001000
00333
00334 #define TEKERR_FILE_READONLY 0x00002000
00335 #define TEKERR_FILE_EOF 0x00002000
00336
00337 #define TEKERR_FILE_IO 0x00004000
00338
00339 #define TEKERR_FILE_PIPE 0x00008000
00340 #define TEKERR_NO_SUCH_FILE 0x00008000
00341
00342
00343
00344
00345 #define TEKLTI_VER_MAJOR 1
00346 #define TEKLTI_VER_MINOR 0
00347 #define TEKLTI_VER_REVISION 0
00348 #define TEKLTI_VER_PATCHNO 4
00349 #ifdef DEBUG
00350 #define TEKLTI_VER_MISCINFO "libTekLTI 1.0-0 pre5 Debug Build"
00351 #else
00352 #define TEKLTI_VER_MISCINFO "libTekLTI 1.0-0 pre5"
00353 #endif
00354
00355 #define TEKLTI_VER_MATCH(s,m,i,r,p) (((s->TekStdGlobalVarsVersion.TekStdVerMajor >= m) && (s->TekStdGlobalVarsVersion.TekStdVerMinor >= i)) && ((s->TekStdGlobalVarsVersion.TekStdVerRev >= r) && (s->TekStdGlobalVarsVersion.TekStdVerPatchNo >= p)))
00356
00357
00358
00359
00368 typedef struct TekStdVersion
00369 {
00375 size_t TekStdVerSize;
00381 uuid_t TekStdVerUUID;
00388 int TekStdVerVersionOK;
00394 TEKERR TekStdVerErrCode;
00398 unsigned int TekStdVerMajor;
00402 unsigned int TekStdVerMinor;
00406 unsigned int TekStdVerRev;
00410 unsigned int TekStdVerPatchNo;
00414 char TekStdVerMisc[64];
00415 } _TekStdVersion;
00416
00417 typedef struct TekStdVersion * PTekStdVersion;
00418
00425 typedef struct TekStdCIInput
00426 {
00432 const uuid_t * TekStdCIUUIDArray;
00436 size_t TekStdCIUUIDArrayCount;
00441 size_t TekStdCIInstanceCount;
00445 int TekStdCIFlags;
00450 TEKERR TekStdCIError;
00454 struct TekStdVersion TekStdCIVersion;
00455 } _TekStdCIInput;
00456
00457 typedef struct TekStdCIInput * PTekStdCIInput;
00458 typedef const struct TekStdCIInput * CPTekStdCIInput;
00459
00466 typedef struct TekStdGlobalVars
00467 {
00473 size_t TekStdGlobalVarsSize;
00477 struct TekStdVersion TekStdGlobalVarsVersion;
00481 unsigned int TekStdGlobalVarsMaxImpl;
00485 short TekStdGlobalVarsUnicode;
00489 short TekStdGlobalVarsMMX;
00493 short TekStdGlobalVarsMMXResetMM7;
00497 short TekStdGlobalVarsInternalChecks;
00501 short TekStdGlobalVarsPassInPointerChecks;
00505 short TekStdGlobalVarsPushPopEnforced;
00509 short TekStdGlobalVarsPrivacyEnforced;
00510 } _TekStdGlobalVars;
00511
00512
00518 typedef struct TekStdProcessorInfo
00519 {
00525 size_t TekStdProcessorInfoSize;
00529 unsigned int TekStdProcessorInfoType;
00533 unsigned int TekStdProcessorInfoFeatures;
00537 char TekStdProcessorInfoDesc[116];
00538 } _TekStdProcessorInfo;
00539
00540
00547 typedef struct UUID_C
00548 {
00552 unsigned int uuid_l;
00556 unsigned short uuid_s1;
00560 unsigned short uuid_s2;
00564 unsigned short uuid_s3;
00568 unsigned char uuid_c1;
00572 unsigned char uuid_c2;
00576 unsigned char uuid_c3;
00580 unsigned char uuid_c4;
00584 unsigned char uuid_c5;
00588 unsigned char uuid_c6;
00589 } _UUID_C;
00590
00591 typedef const struct UUID_C CUUID;
00592
00593 #define TEKARRAY_MACRODEF ;
00594
00601 typedef struct TekArray
00602 {
00606 unsigned long TekArraySize;
00610 uint8_t ** TekArrayAccessPoint;
00614 uint8_t * TekArrayMemoryLoc;
00618 unsigned long TekArrayMaxElements;
00622 unsigned long TekArrayElementSize;
00626 unsigned long TekArrayEnumLoc;
00630 unsigned int TekArrayRef;
00674 TEKARRAY_MACRODEF;
00675 } _TekArray;
00676
00677
00683 typedef struct TekUserInfo
00684 {
00689 unsigned long TekUserInfo_Size;
00694 void * TekUserInfo_DB;
00698 uchar_t * TekUserInfo_Description;
00702 uchar_t * TekUserInfo_Username;
00706 uchar_t * TekUserInfo_HomeDir;
00710 uid_t TekUserInfo_UserID;
00714 gid_t TekUserInfo_GroupID;
00718 uchar_t * TekUserInfo_Password;
00719 } _TekUserInfo;
00720
00721
00722
00723
00724 #ifdef USE_386_ASM
00725
00726 extern const void * tek_asm_null;
00727
00728 extern uint64_t tekzerovar;
00729 #endif
00730
00731
00732
00733
00734 extern void _mkuuid_t (
00735 const char *,
00736 uuid_t
00737 );
00738
00739 extern uchar_t * char2uchar ( const char * );
00740
00741 extern uchar_t * char2ucharlen ( const char *, size_t );
00742
00743 extern void ucharempty ( uchar_t * );
00744
00745 extern uchar_t * uchardup ( const uchar_t * );
00746
00747 #define uchar2char(uchr) uchr->uchar_t_ascii
00748
00749 #ifdef UNICODE
00750 #define mkucharnull(uchr, extradw) \
00751 uchr.uchar_t_ascii = NULL; \
00752 uchr.uchar_t_unicode = NULL \
00753 uchr.uchar_t_asciilen = uchr.uchar_t_unicodelen = 0;
00754 #else
00755 #define mkucharnull(uchr, extradw) \
00756 uchr.uchar_t_ascii = NULL; \
00757 uchr.uchar_t_asciilen = 0;
00758 #endif
00759
00760
00761 #ifdef USE_386_ASM_MMX_RESET_MM7
00762 #define tekresetmm7 __asm__ ( " movq %0, %%mm7 " : "=m" (tekzerovar) )
00763 #define tekresetmm7withemms \
00764 tekresetmm7; \
00765 __asm__ ( " emms " );
00766 #else
00767 #define tekresetmm7 ;
00768 #define tekresetmm7withemms ;
00769 #endif
00770
00771
00772 extern TEKERR TekStdGetLibraryVersion (
00773 PTekStdVersion *,
00774 size_t
00775 );
00776 extern TEKERR TekStdCreateInstance (
00777 CPTekStdCIInput,
00778 size_t,
00779 void **,
00780 size_t,
00781 const uuid_t *,
00782 size_t,
00783 unsigned int,
00784 PTekStdVersion
00785 );
00786 extern TEKERR TekStdGetGlobalVariables (
00787 struct TekStdGlobalVars *
00788 );
00789
00790
00791 #ifndef ANSI_ONLY
00792 TEKLTI_DECLSPEC void _mkuuid_t (
00793 const char * uuid_str,
00794 uuid_t uuid_raw
00795 );
00796
00797 TEKLTI_DECLSPEC uchar_t * char2uchar ( const char * src );
00798
00799 TEKLTI_DECLSPEC uchar_t * char2ucharlen ( const char * src, size_t len );
00800
00801 TEKLTI_DECLSPEC void ucharempty ( uchar_t * uchrtofree );
00802
00803 TEKLTI_DECLSPEC uchar_t * uchardup ( const uchar_t * src );
00804
00805 TEKLTI_DECLSPEC TEKERR TekStdGetLibraryVersion (
00806 PTekStdVersion * VersionStruct,
00807 size_t VersionStructCount
00808 );
00809 TEKLTI_DECLSPEC TEKERR TekStdCreateInstance (
00810 CPTekStdCIInput InterfaceStructs,
00811 size_t InterfaceStructCount,
00812 void ** InstanceArray,
00813 size_t InstanceArrayCount,
00814 const uuid_t * UUIDArray,
00815 size_t UUIDArrayCount,
00816 unsigned int Flags,
00817 PTekStdVersion VersionStruct
00818 );
00819
00820 TEKLTI_DECLSPEC TEKERR TekStdGetGlobalVariables (
00821 struct TekStdGlobalVars * RetVal
00822 );
00823
00824 #endif
00825
00826 #ifdef _cplusplus
00827 }
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845 #define MKTEKUUID(name, s) const char name[] = s;
00846
00847 #define TEKUUIDIMPORT(name) extern const char name[];
00848
00849 #define GETTEKUUID(name, ret) _mkuuid_t(name, ret);
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859 #define TEKFILEASCII_STDBUFLEN 1024
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872 #ifdef DEBUG_USE_FERROR
00873 #define MKTEKDEBUGSTRING(name, s) \
00874 static const char name[] = s;
00875
00876 #define TEKDEBUGSTRING(name) name
00877 #else
00878 #define MKTEKDEBUGSTRING(name, s)
00879
00880 #define TEKDEBUGSTRING(name)
00881 #endif
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929 #define DEFINETEKARRAY(d) struct TekArray d;
00930
00931 #define INITTEKARRAY(s, r, t) \
00932 if ( ( t = (struct TekArray *)malloc(sizeof(struct _TekArray)) ) != NULL ) \
00933 { \
00934 if ( ( t->TekArrayAccessPoint = t->TekArrayMemoryLoc = \
00935 (uint8_t *)calloc(s, r) ) != NULL ) \
00936 { \
00937 t->TekArraySize = t->TekArrayEnumLoc = 0; \
00938 t->TekArrayMax = s; \
00939 t->TekArrayRef = 1; \
00940 } else { \
00941 free(t); t = NULL; \
00942 } \
00943 }
00944
00945 #define INITTEKARRAY_TEKSTD(s, t) INITTEKARRAY(s, sizeof(TekStd *), t)
00946
00947 #define GETTEKARRAYELEMENT(a, i) = \
00948 (void *)a->TekArrayAccessPoint[i * a->TekArrayElementSize]
00949
00950 #define ADDTEKARRAYELEMENT(a, e) \
00951 if ( a->TekArraySize < a->TekArrayMaxElements ) { \
00952 a->TekArraySize++; \
00953 memcpy( \
00954 a->TekArrayAccessPoint[a->TekArraySize * a->TekArrayElementSize], \
00955 e, \
00956 a->TekArrayElementSize \
00957 ); \
00958 }
00959
00960 #define REMOVETEKARRAYELEMENT(a, i, n) \
00961 if ( i <= TekArraySize ) { \
00962 for ( n=i; n < a->TekArraySize; n++ ) \
00963 { \
00964 memcpy( \
00965 a->TekArrayAccessPoint[n * a->TekArrayElementSize], \
00966 a->TekArrayAccessPoint[(n * a->TekArrayElementSize)+1], \
00967 a->TekArrayElementSize); \
00968 ); \
00969 } \
00970 memset( \
00971 a->TekArrayAccessPoint[a->TekArraySize * a->TekArrayElementSize], \
00972 '\0', \
00973 a->TekArrayElementSize \
00974 ); \
00975 a->TekArraySize--; \
00976 }
00977
00978 #define CLEARTEKARRAY(a) \
00979 memset( \
00980 a->TekArrayMemoryLoc, \
00981 '\0', \
00982 a->TekArrayElementSize * a->TekArrayMaxElements \
00983 ); \
00984 a->TekArraySize = 0;
00985
00986
00987 #define ADDTEKARRAYELEMENT_TEKSTD(a, e) \
00988 e->AddRef(); \
00989 ADDTEKARRAYELEMENT(a, e)
00990
00991 #define REMOVETEKARRAYELEMENT_TEKSTD(a, i, n, t) \
00992 t = (TekStd *)a->TekArrayAccessPoint[n]; \
00993 t->Release(); \
00994 REMOVETEKARRAYELEMENT(a, i, n)
00995
00996 #define CLEARTEKARRAY_TEKSTD(a, n, t) \
00997 for ( n=0; n <= a->TekArraySize; n++ ) \
00998 { \
00999 t = (TekStd *)a->TekArrayAccessPoint[n * sizeof(TekStd *)]; \
01000 t->Release(); \
01001 } \
01002 CLEARTEKARRAY(a)
01003
01004
01005 #define ADDREFTEKARRAY(a) a->TekArrayRef++;
01006
01007 #define RELEASETEKARRAY(a) \
01008 a->TekArrayRef--; \
01009 if ( a->TekArrayRef == 0 ) \
01010 { \
01011 CLEARTEKARRAY(a) \
01012 free(a->TekArrayMemoryLoc); free(a); \
01013 }
01014
01015 #define ADDREFTEKARRAY_TEKSTD(a) a->TekArrayRef++;
01016
01017 #define RELEASETEKARRAY_TEKSTD(a, n, t) \
01018 a->TekArrayRef--; \
01019 if ( a->TekArrayRef == 0 ) \
01020 { \
01021 CLEARTEKARRAY_TEKSTD(a) \
01022 free(a->TekArrayMemoryLoc); free(a); \
01023 }
01024
01025 #define FOREACH_ELEMENT_IN_TEKARRAY(a, i) \
01026 for ( a->TekArrayEnumLoc=0; a->TekArrayEnumLoc <= a->TekArraySize; a++ ) \
01027 { \
01028 i = (void *)a->TekArrayAccessPoint[a->TekArrayEnumLoc * \
01029 a->TekArrayElementSize]; \
01030 if ( i == NULL ) \
01031 break;
01032
01033 #define FOREACH_TEKSTD_IN_TEKARRAY(a, i) \
01034 for ( a->TekArrayEnumLoc=0; a->TekArrayEnumLoc <= a->TekArraySize; a++ ) \
01035 { \
01036 i = (void *)a->TekArrayAccessPoint[a->TekArrayEnumLoc * \
01037 sizeof(TekStd *)]; \
01038 if ( i == NULL ) \
01039 break;
01040
01041 #define ENDFOR_TEKARRAY(a) }
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055 #define TEKSTD_IMPLEMENT_BEGIN \
01056 this->__uuidbeginsize = 1; \
01057 this->__uuidbegin = (uuid_t *)calloc(TEKSTD_MAXIMPL, sizeof(uuid_t)); \
01058 if ( __uuidbegin == NULL ) \
01059 throw; \
01060 _mkuuid_t(UTekStd, this->__uuidbegin[0]);
01061
01062 #define TEKSTD_IMPLEMENT_BEGIN_MYSELF \
01063 TEKSTD_IMPLEMENT_BEGIN
01064
01065 #ifdef NO_SIZE_T_CHECKS
01066 #define TEKSTD_IMPLEMENT_INTERFACE(name) \
01067 _mkuuid_t(name, TekStd::__uuidbegin[TekStd::__uuidbeginsize]); \
01068 TekStd::__uuidbeginsize++;
01069 #define TEKSTD_IMPLEMENT_INTERFACE_MYSELF(name) \
01070 _mkuuid_t(name, this->__uuidbegin[this->__uuidbeginsize]); \
01071 this->__uuidbeginsize++;
01072 #else
01073 #define TEKSTD_IMPLEMENT_INTERFACE(name) \
01074 if ( TekStd::__uuidbeginsize >= TEKSTD_MAXIMPL ) {\
01075 throw; }\
01076 _mkuuid_t(name, TekStd::__uuidbegin[TekStd::__uuidbeginsize]); \
01077 TekStd::__uuidbeginsize++;
01078 #define TEKSTD_IMPLEMENT_INTERFACE_MYSELF(name) \
01079 if ( this->__uuidbeginsize >= TEKSTD_MAXIMPL ) {\
01080 throw; }\
01081 _mkuuid_t(name, this->__uuidbegin[this->__uuidbeginsize]); \
01082 this->__uuidbeginsize++;
01083 #endif
01084
01085
01086
01087
01088
01089 #define TEKSTD_IMPLEMENT_ENDBASE \
01090 TekStd::__uuidarray = (uuid_t *)TekStd::__uuidbegin; \
01091 TekStd::__uuidarraycount = TekStd::__uuidbeginsize;
01092 #define TEKSTD_IMPLEMENT_ENDBASE_MYSELF \
01093 this->__uuidarray = (uuid_t *)this->__uuidbegin; \
01094 this->__uuidarraycount = this->__uuidbeginsize;
01095
01096 #define TEKSTD_IMPLEMENT_ENDVARS \
01097 TekStd::__instancecount = 1;
01098
01099 #define TEKSTD_IMPLEMENT_ENDVARS_MYSELF \
01100 this->__instancecount = 1;
01101
01102 #define TEKSTD_IMPLEMENT_FREE \
01103 free(this->__uuidarray);
01104
01105 #define TEKSTD_IMPLEMENT_END \
01106 TEKSTD_IMPLEMENT_ENDBASE \
01107 TEKSTD_IMPLEMENT_ENDVARS
01108 #define TEKSTD_IMPLEMENT_END_MYSELF \
01109 TEKSTD_IMPLEMENT_ENDBASE_MYSELF \
01110 TEKSTD_IMPLEMENT_ENDVARS_MYSELF
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135 #define TEKSTD_HEADER_VARS \
01136 protected: \
01137 uuid_t * __uuidarray; \
01138 uuid_t * __uuidbegin; \
01139 uuid_t __uuidtmp; \
01140 size_t __uuidarraycount; \
01141 size_t __uuidbeginsize; \
01142 unsigned int __instancecount;
01143
01144 #define TEKSTD_HEADER_FUNC(cls) \
01145 public: \
01146 \
01147 virtual unsigned int AddRef(); \
01148 virtual TEKERR CheckFor( \
01149 const uuid_t * UUIDArray, \
01150 size_t UUIDArraySize, \
01151 unsigned short Flags = 0x0000, \
01152 void ** RetVal = (void **)NULL, \
01153 unsigned int ** RefCountPtrRet = (unsigned int **)NULL \
01154 ); \
01155 virtual unsigned int Release(); \
01156 virtual TEKERR CallFunc( \
01157 const uchar_t * FuncName, \
01158 void * RetVal, \
01159 unsigned short ParamsCount, \
01160 void ** Params \
01161 );
01162
01163 #define TEKSTD_PUREVIRTUAL_FUNC_V1 \
01164 virtual TEKERR CallFunc(const uchar_t* FuncName, void* RetVal, unsigned short ParamsCount, void** Params) = 0; \
01165 virtual TEKERR CheckFor(const uuid_t* UUIDArray, size_t UUIDArraySize, unsigned short Flags, void** RetVal, unsigned int** RefCountPtrRet) = 0; \
01166 virtual unsigned int AddRef() = 0; \
01167 virtual unsigned int Release() = 0;
01168
01169 #define TEKSTD_HEADER_VARSANDFUNC(cls) \
01170 TEKSTD_HEADER_VARS \
01171 TEKSTD_HEADER_FUNC(cls)
01172
01173 #ifdef NO_SIZE_T_CHECKS
01174 #define TEKSTD_SOURCE_FUNC_CHECKFOR(cls)
01175 #else
01176 #ifdef DEBUG_USE_FERROR
01177 #define TEKSTD_SOURCE_FUNC_CHECKFOR \
01178 if ( UUIDArray == NULL ) { \
01179 fprintf( \
01180 stderr, \
01181 "POTENTIAL SEGFAULT in interface %s, function CheckFor(): UUIDArray is null!\n", \
01182 "TekStd" \
01183 ); \
01184 return TEKERR_POINTER; \
01185 } \
01186 \
01187 if ( Flags ) { \
01188 if ( RetVal == NULL ) { \
01189 fprintf( \
01190 stderr, \
01191 "POTENTIAL SEGFAULT in interface %s, function CheckFor(): RetVal is null!\n", \
01192 "TekStd" \
01193 ); \
01194 return TEKERR_POINTER; \
01195 } \
01196 }
01197 #else
01198 #define TEKSTD_SOURCE_FUNC_CHECKFOR \
01199 if ( UUIDArray == NULL ) { \
01200 return TEKERR_POINTER; \
01201 } \
01202 \
01203 if ( Flags ) { \
01204 if ( RetVal == NULL ) { \
01205 return TEKERR_POINTER; \
01206 } \
01207 }
01208 #endif
01209 #endif
01210
01211 #define TEKSTD_SOURCE_FUNC_CALLFUNC(cls) \
01212 TEKERR cls::CallFunc( \
01213 const uchar_t * FuncName, \
01214 void * RetVal, \
01215 unsigned short ParamsCount, \
01216 void ** Params \
01217 ) { \
01218 return TEKERR_NOTIMPL; \
01219 }
01220
01221 #define TEKSTD_SOURCE_FUNC(cls) \
01222 unsigned int cls::AddRef() { this->__instancecount++; return this->__instancecount; } \
01223 TEKERR cls::CheckFor( \
01224 const uuid_t * UUIDArray, \
01225 size_t UUIDArraySize, \
01226 unsigned short Flags, \
01227 void ** RetVal, \
01228 unsigned int ** RefCountPtrRet \
01229 ) { \
01230 TEKERR result; \
01231 size_t i; \
01232 size_t j; \
01233 TEKSTD_SOURCE_FUNC_CHECKFOR \
01234 for ( i=0; i < UUIDArraySize; i++ ) \
01235 { \
01236 for ( j=0; j < this->__uuidarraycount; j++ ) \
01237 if ( uuid_compare(this->__uuidarray[j], UUIDArray[i]) == 0 ) \
01238 goto FoundUUID; \
01239 \
01240 i++; \
01241 result = i << (8 * sizeof(short)); \
01242 result |= TEKERR_NOTIMPL; \
01243 return result; \
01244 FoundUUID: \
01245 ; \
01246 } \
01247 \
01248 if ( Flags ) { \
01249 this->AddRef(); \
01250 *RetVal = this; \
01251 } \
01252 \
01253 if ( RefCountPtrRet != (unsigned int **)NULL ) \
01254 *RefCountPtrRet = &this->__instancecount; \
01255 \
01256 return TEKERR_OK; \
01257 } \
01258 unsigned int cls::Release() { \
01259 this->__instancecount--; \
01260 if ( this->__instancecount == 0 ) \
01261 { \
01262 delete this; \
01263 return 0; \
01264 } \
01265 return this->__instancecount; \
01266 } \
01267 TEKSTD_SOURCE_FUNC_CALLFUNC(cls)
01268
01269 #define TEKSTD_CHECKFOR_UUIDNO(err) (unsigned short)((err >> 8 * sizeof(short))
01270 #define TEKSTD_CHECKFOR_ERRNO(err) (unsigned short)((err << 8 * sizeof(short))
01271
01272
01273
01274 TEKUUIDIMPORT(UTekStd);
01275
01287 class TekStd
01288 {
01289 TEKSTD_HEADER_VARS
01290 public:
01294 TekStd();
01298 ~TekStd();
01299 #ifndef TEKSTD_INTERNAL
01300
01303 virtual unsigned int AddRef();
01323 virtual TEKERR CheckFor(
01324 const uuid_t * UUIDArray,
01325 size_t UUIDArraySize,
01326 unsigned short Flags = 0x0000,
01327 void ** RetVal = (void **)NULL,
01328 unsigned int ** RefCountPtrRet = (unsigned int **)NULL
01329 );
01333 virtual unsigned int Release();
01341 virtual TEKERR CallFunc(
01342 const uchar_t * FuncName,
01343 void * RetVal,
01344 unsigned short ParamsCount,
01345 void ** Params
01346 );
01347 #endif
01348 };
01349
01350
01351 #ifdef COMPILING_LIBTEKLTI
01352
01353
01354
01355
01356
01357
01358 #include "tekenum.h"
01359
01360
01361
01362
01363 #include "tekfile.h"
01364 #include "tekfilebinary.h"
01365 #include "tekfileascii.h"
01366 #include "tekfileasciibare.h"
01367
01368
01369
01370
01371 #include "tekuser.h"
01372 #include "tekuserunixro.h"
01373 #include "tekuserunixrw.h"
01374
01375
01376
01377
01378 #include "tekuserdb.h"
01379 #ifdef _WINDOWS
01380 #include "tekuserdbwindows.h"
01381 #endif
01382 #include "tekuserdbunix.h"
01383
01384
01385
01386
01387 #include "tekstatfile.h"
01388 #include "tekstatfileposix.h"
01389
01390
01391
01392
01393 #ifdef TEKLTI_USE_BZIP2
01394 #include "tekfilebz2.h"
01395 #include "tekfilebz2binary.h"
01396 #include "tekfilebz2ascii.h"
01397 #endif
01398 #else
01399
01400
01401
01402
01403
01404
01405 #include <tekenum.h>
01406
01407
01408
01409
01410 #include <tekfile.h>
01411 #include <tekfilebinary.h>
01412 #include <tekfileascii.h>
01413 #include <tekfileasciibare.h>
01414
01415
01416
01417
01418 #include <tekuser.h>
01419 #include <tekuserunixro.h>
01420 #include <tekuserunixrw.h>
01421
01422
01423
01424
01425 #include <tekuserdb.h>
01426 #ifdef _WINDOWS
01427 #include <tekuserdbwindows.h>
01428 #endif
01429 #include <tekuserdbunix.h>
01430
01431
01432
01433
01434 #include <tekstatfile.h>
01435 #include <tekstatfileposix.h>
01436
01437
01438
01439
01440 #ifdef TEKLTI_USE_BZIP2
01441 #include <tekfilebz2.h>
01442 #include <tekfilebz2binary.h>
01443 #include <tekfilebz2ascii.h>
01444 #endif
01445 #endif
01446 #else
01447
01448
01449
01450 typedef unsigned int TekFileType;
01451
01452 #define TekFileType_Binary 0x0000
01453 #define TekFileType_ASCII 0x0001
01454 #define TekFileType_ConfigASCII 0x0002
01455 #define TekFileType_UNICODE 0x0004
01456 #define TekFileType_ConfigUNICODE 0x0008
01457 #define TekFileType_BinaryPipe 0x0010
01458 #define TekFileType_ASCIIPipe 0x0020
01459 #define TekFileType_UnicodePipe 0x0040
01460 #define TekFileType_BZIP2 0x0100
01461
01462 TEKLTI_DECLSPEC TEKERR TekFileCreate(TekFileType FileType, void ** RetVal, uchar_t * FileName);
01463
01464
01465
01466
01467
01468
01469 typedef unsigned int TekUserType;
01470
01471 #define TekUserType_Any 0x0000
01472 #define TekUserType_POSIX 0x0001
01473 #define TekUserType_Linux 0x0002
01474 #define TekUserType_Windows 0x0004
01475
01476 TEKLTI_DECLSPEC TEKERR TekUserInfoCreate(
01477 struct TekUserInfo * UserInfo,
01478 void ** RetVal,
01479 TekUserType UserType
01480 );
01481 #endif
01482
01483 #define TEKLTI_CHECKFOR_FAILING_ELEMENT(i) i >> 16
01484
01485 #ifdef TEKLTI_USE_386_ASM
01486 #ifdef COMPILING_LIBTEKLTI
01487 #include "teklti386.h"
01488 #else
01489 #include <teklti386.h>
01490 #endif
01491 #else
01492 #define TekStdCheckAndRecieveProcessorInfo(a, b, c) ;
01493
01494 typedef void * TekStdProcessorInfoGeneric;
01495 #endif
01496
01497 #endif
01498