global.c

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Kevin McBride                                   *
00003  *   kevin@planetsaphire.com                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Library General Public License as       *
00007  *   published by the Free Software Foundation; either version 2 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU Library General Public     *
00016  *   License along with this program; if not, write to the                 *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 
00022 #define     LIBTEKLTI_EXPORT  (0)
00023 
00024 #include "teklti.h"
00025 #include <string.h>
00026 
00027 #ifdef      DEBUG_USE_FERROR
00028 #include <stdio.h>
00029 #endif      /* DEBUG_USE_FERROR */
00030 
00031 
00032 #ifdef      DEBUG_USE_FERROR
00033 static const char _mkuuid_t_uuidstr_null[] = 
00034 "POTENTIAL SEGFAULT in _mkuuid_t: uuid_str is NULL!\n";
00035 static const char _mkuuid_t_uuidstr_overrun[] = 
00036 "POTENTIAL OVERRUN in _mkuuid_t: uuid_str will cause a buffer overrun!\n";
00037 #endif      /* DEBUG_USE_FERROR */
00038 
00039 
00040 #ifndef     USE_386_ASM
00041 TEKLTI_DECLSPEC void _mkuuid_t ( const char * uuid_str, uuid_t uuid_raw )
00042 {     
00043 #ifndef     NO_SIZE_T_CHECKS
00044       if ( uuid_str == NULL )
00045       {
00046 #ifdef      DEBUG_USE_FERROR
00047             fputs(_mkuuid_t_uuidstr_null, stderr);
00048 #endif      /* DEBUG_USE_FERROR */
00049             return;
00050       }
00051       if ( strlen(uuid_str) >= 40 * sizeof(char) )
00052       {
00053 #ifdef      DEBUG_USE_FERROR
00054             fputs(_mkuuid_t_uuidstr_overrun, stderr);
00055 #endif      /* DEBUG_USE_FERROR */
00056             return;
00057       }
00058 #endif      /* not NO_SIZE_T_CHECKS */
00059       (void)uuid_parse(uuid_str, uuid_raw);
00060 
00061       /* Return to caller. */
00062       return;
00063 }
00064 #endif      /* not USE_386_ASM */
00065 
00066 
00067 /*
00068 NOTE: TekStdGlobalVariables will NEVER be programmed in assembly due to
00069 its nature of grabbing global variables and passing them to the caller.
00070 The caller can then determine, without advanced asm causing undesirable
00071 problems, whether or not libTekLTI is compiled in a manner suitable
00072 enough to the caller to run in a "smooth, yet safe" manner.
00073 */
00074 
00075 TEKLTI_DECLSPEC TEKERR TekStdGetGlobalVariables ( 
00076       struct TekStdGlobalVars * RetVal
00077 )
00078 {
00079 #ifndef     NO_SIZE_T_CHECKS
00080       /* Check for a valid RetVal. */
00081       if ( RetVal == NULL )
00082             return TEKERR_POINTER;
00083 #endif      /* not NO_SIZE_T_CHECKS */
00084 
00085       /* Make sure size is set enough for us to work with. */
00086       if ( RetVal->TekStdGlobalVarsSize < sizeof(struct TekStdGlobalVars) )
00087             return TEKERR_UNAVAILABLE;
00088 
00089       /* Reduce GlobalVarsSize as needed. */
00090       if ( RetVal->TekStdGlobalVarsSize > sizeof(struct TekStdGlobalVars) )
00091             RetVal->TekStdGlobalVarsSize = sizeof(struct TekStdGlobalVars);
00092 
00093       /* Reduce VersionSize as needed. */
00094       if ( RetVal->TekStdGlobalVarsVersion.TekStdVerSize
00095            > sizeof(struct TekStdVersion) )
00096       {
00097             RetVal->TekStdGlobalVarsVersion.TekStdVerSize = 
00098                   sizeof(struct TekStdVersion);
00099       }
00100 
00101       /* Set up the versioning structures. */
00102       RetVal->TekStdGlobalVarsVersion.TekStdVerMajor = TEKLTI_VER_MAJOR;
00103       RetVal->TekStdGlobalVarsVersion.TekStdVerMinor = TEKLTI_VER_MINOR;
00104       RetVal->TekStdGlobalVarsVersion.TekStdVerRev = TEKLTI_VER_REVISION;
00105       RetVal->TekStdGlobalVarsVersion.TekStdVerPatchNo = TEKLTI_VER_PATCHNO;
00106       strcpy(
00107             RetVal->TekStdGlobalVarsVersion.TekStdVerMisc,
00108             TEKLTI_VER_MISCINFO
00109       );
00110 
00111       /* Now set up the maximum implementations variable. */
00112       RetVal->TekStdGlobalVarsMaxImpl = TEKSTD_MAXIMPL;
00113       
00114       /* Set up the Unicode variable. */
00115 #ifdef      UNICODE
00116       RetVal->TekStdGlobalVarsUnicode = 1;
00117 #else /* not UNICODE */
00118       RetVal->TekStdGlobalVarsUnicode = 0;
00119 #endif      /* not UNICODE */
00120 
00121 #ifdef      USE_386_ASM_MMX
00122       RetVal->TekStdGlobalVarsMMX = 1;
00123 #else /* not USE_386_ASM_MMX */
00124       RetVal->TekStdGlobalVarsMMX = 0;
00125 #endif      /* not USE_386_ASM_MMX */
00126 
00127 #ifdef      USE_386_ASM_MMX_RESET_MM7
00128       RetVal->TekStdGlobalVarsMMXResetMM7 = 0;
00129 #else /* not USE_386_ASM_MMX_RESET_MM7 */
00130       RetVal->TekStdGlobalVarsMMXResetMM7 = 1;
00131 #endif      /* not USE_386_ASM_MMX_RESET_MM7 */
00132 
00133       /* Set up the internal checks variable. */
00134 #ifdef      NO_INTERNAL_NULL_CHECKS
00135       RetVal->TekStdGlobalVarsInternalChecks = 0;
00136 #else /* not NO_INTERNAL_NULL_CHECKS */
00137       RetVal->TekStdGlobalVarsInternalChecks = 1;
00138 #endif      /* not NO_INTERNAL_NULL_CHECKS */
00139 
00140       /* Set up the pass in pointer checks variable. */
00141 #ifdef      NO_SIZE_T_CHECKS  
00142       RetVal->TekStdGlobalVarsPassInPointerChecks = 0;
00143 #else /* not NO_SIZE_T_CHECKS */
00144       RetVal->TekStdGlobalVarsPassInPointerChecks = 1;
00145 #endif      /* not NO_SIZE_T_CHECKS */
00146 
00147       /* Set up the push pop enforced variable. */
00148 #ifdef      USE_386_ASM_PUSHPOP
00149       RetVal->TekStdGlobalVarsPushPopEnforced = 1;
00150 #else /* not USE_386_ASM_PUSHPOP */
00151       RetVal->TekStdGlobalVarsPushPopEnforced = 0;
00152 #endif      /* not USE_386_ASM_PUSHPOP */
00153 
00154 #ifdef      USE_386_ASM_ENFORCE_PRIVACY
00155       RetVal->TekStdGlobalVarsPrivacyEnforced = 1;
00156 #else /* not USE_386_ASM_ENFORCE_PRIVACY */
00157       RetVal->TekStdGlobalVarsPrivacyEnforced = 0;
00158 #endif      /* not USE_386_ASM_ENFORCE_PRIVACY */
00159 
00160       return TEKERR_OK;
00161 }
00162 
00163 
00164 TEKLTI_DECLSPEC TEKERR TekStdCreateInstance (
00165       CPTekStdCIInput InterfaceStructs,
00166       size_t InterfaceStructCount,
00167       void ** InstanceArray,
00168       size_t InstanceArrayCount,
00169       const uuid_t * UUIDArray,
00170       size_t UUIDArrayCount,
00171       unsigned int Flags,
00172       PTekStdVersion VersionStruct
00173 )
00174 {
00175       return TEKERR_NOTIMPL;
00176 }
00177 
00178 
00179 TEKLTI_DECLSPEC TEKERR TekStdGetLibraryVersion (
00180       PTekStdVersion * VersionStruct,
00181       size_t VersionStructCount
00182 )
00183 {
00184       return TEKERR_NOTIMPL;
00185 }
00186 
00187 /*int main()
00188 {
00189       unsigned char * tmp;
00190       char chrout[64];
00191       uuid_t uuidmake;
00192       int i;
00193 
00194       uuid_generate_time(uuidmake);
00195       tmp = uuidmake;
00196       for ( i=0; i < 16; i++ )
00197             printf("0x%.2X ", (unsigned int)tmp[i]);
00198       printf("\n");
00199 
00200       uuid_unparse(uuidmake, chrout);
00201 
00202       printf("%s\n", chrout);
00203 }*/
00204 
00205 
SourceForge.net Logo  Technical Library Template Interface Project Page