Exemple #1
0
TA_RetCode TA_FuncTableFree( TA_StringTable *table )
{
   TA_PROLOG
   TA_StringTablePriv *stringTablePriv;

   TA_TRACE_BEGIN( TA_FuncTableFree );

   if( table )
   {
      stringTablePriv = (TA_StringTablePriv *)table->hiddenData;
      if( !stringTablePriv )
      {
         TA_TRACE_RETURN( TA_INTERNAL_ERROR(3) );
      }
   
      if( stringTablePriv->magicNumber != TA_STRING_TABLE_FUNC_MAGIC_NB )
      {
         TA_TRACE_RETURN( TA_BAD_OBJECT );
      }

      if( table->string )
         TA_Free( (void *)table->string );

      TA_Free( table );
   }

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #2
0
TA_RetCode TA_GetFuncInfo(  const TA_FuncHandle *handle,
                            const TA_FuncInfo **funcInfo )
{
   TA_PROLOG
   const TA_FuncDef *funcDef;

   TA_TRACE_BEGIN( TA_GetFuncInfo );

   if( !funcInfo || !handle )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   /* Validate that this is a valid funcHandle. */
   funcDef = (const TA_FuncDef *)handle;
   if( funcDef->magicNumber != TA_FUNC_DEF_MAGIC_NB )
   {
      TA_TRACE_RETURN( TA_INVALID_HANDLE );
   }

   *funcInfo = funcDef->funcInfo;

   TA_DEBUG_ASSERT( *funcInfo != NULL );

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #3
0
/**** Global functions definitions.   ****/
TA_RetCode TA_GroupTableAlloc( TA_StringTable **table )
{
   TA_PROLOG
   TA_StringTable *stringTable;
   TA_StringTablePriv *stringTablePriv;

   TA_TRACE_BEGIN( TA_GroupTableAlloc );

   if( table == NULL )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   stringTable = (TA_StringTable *)TA_Malloc( sizeof(TA_StringTable) + sizeof(TA_StringTablePriv) );
   if( !stringTable )
   {
      *table = NULL;
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   memset( stringTable, 0, sizeof(TA_StringTable) + sizeof(TA_StringTablePriv) );
   stringTablePriv = (TA_StringTablePriv *)(((char *)stringTable)+sizeof(TA_StringTable));
   stringTablePriv->magicNumber = TA_STRING_TABLE_GROUP_MAGIC_NB;

   stringTable->size = TA_NB_GROUP_ID;
   stringTable->string = &TA_GroupString[0];
   stringTable->hiddenData = stringTablePriv;

   /* From this point, TA_FuncTableFree can be safely called. */

   /* Success. Return the table to the caller. */
   *table = stringTable;

   TA_TRACE_RETURN( TA_SUCCESS );
}
static TA_RetCode freeFileIndexPriv( void *toBeFreed )
{
   TA_PROLOG;
   TA_FileIndexPriv *asciiFileData;
   TA_Libc          *libHandle;
   TA_StringCache   *stringCache;

   asciiFileData = (TA_FileIndexPriv *)toBeFreed;

   libHandle   = asciiFileData->libHandle;
   TA_TRACE_BEGIN( libHandle, freeFileIndexPriv );

   stringCache = TA_GetGlobalStringCache( libHandle );

   if( !asciiFileData )
   {
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   if( freeListAndElement( libHandle, asciiFileData->listLocationToken, freeTokenInfo ) != TA_SUCCESS )
   {
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   if( freeListAndElement( libHandle, asciiFileData->listCategory, freeCategoryData ) != TA_SUCCESS )
   {
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   if( asciiFileData->root )
      TA_FileIndexFreeValueTree( libHandle, asciiFileData->root );

   if( asciiFileData->scratchPad )
      TA_Free( libHandle, asciiFileData->scratchPad );

   if( asciiFileData->wildOneChar )
      TA_StringFree( stringCache, asciiFileData->wildOneChar );

   if( asciiFileData->wildZeroOrMoreChar )
      TA_StringFree( stringCache, asciiFileData->wildZeroOrMoreChar );

   if( asciiFileData->wildOneOrMoreChar )
      TA_StringFree( stringCache, asciiFileData->wildOneOrMoreChar );

   if( asciiFileData->initialCategoryString )
      TA_StringFree( stringCache, asciiFileData->initialCategoryString );

   if( asciiFileData->initialCategoryCountryString )
      TA_StringFree( stringCache, asciiFileData->initialCategoryCountryString );

   if( asciiFileData->initialCategoryExchangeString )
      TA_StringFree( stringCache, asciiFileData->initialCategoryExchangeString );

   if( asciiFileData->initialCategoryTypeString )
      TA_StringFree( stringCache, asciiFileData->initialCategoryTypeString );

   TA_Free( libHandle, asciiFileData );

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #5
0
static TA_RetCode initSymbolHandle( TA_DataSourceHandle *handle,
                                    TA_CategoryHandle   *categoryHandle,
                                    TA_SymbolHandle     *symbolHandle,
                                    unsigned int index )
{
   TA_PROLOG
   TA_YahooCategory *category;

   TA_TRACE_BEGIN( TA_YAHOO_GetFirstSymbolHandle );

   if( (handle == NULL) || (categoryHandle == NULL) || (symbolHandle == NULL) )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   category = (TA_YahooCategory *)categoryHandle->opaqueData;

   if( index >= category->nbSymbol )
      return TA_END_OF_INDEX;

   /* Set the symbolHandle. */
   symbolHandle->string = category->symbols[index];
   symbolHandle->opaqueData = NULL;

   TA_TRACE_RETURN( TA_SUCCESS );
}
static TA_RetCode freeListAndElement( TA_Libc *libHandle, TA_List *list, TA_RetCode (*freeFunc)( TA_Libc *libHandle, void *toBeFreed ) )
{
   TA_PROLOG;
   TA_RetCode retCode;
   void *node;

   TA_TRACE_BEGIN( libHandle, freeListAndElement );

   if( list != NULL )
   {
      while( (node = TA_ListRemoveTail( list )) != NULL )
      {
         retCode = freeFunc( libHandle, node );
         if( retCode != TA_SUCCESS )
         {
            TA_FATAL( libHandle, NULL, node, retCode );
            TA_TRACE_RETURN( TA_ALLOC_ERR );
         }
      }

      retCode = TA_ListFree( list );
      if( retCode != TA_SUCCESS )
      {
         TA_FATAL( libHandle, NULL, list, retCode );
         TA_TRACE_RETURN( TA_ALLOC_ERR );
      }
   }

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #7
0
TA_RetCode TA_SIMULATOR_GetFirstCategoryHandle( TA_DataSourceHandle *handle,
                                                TA_CategoryHandle   *categoryHandle )
{
   TA_PROLOG

   TA_PrivateHandle *privData;

   TA_TRACE_BEGIN(  TA_SIMULATOR_GetFirstCategoryHandle );

   if( (handle == NULL) || (categoryHandle == NULL) )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   privData = (TA_PrivateHandle *)(handle->opaqueData);

   if( !privData )
   {
      TA_TRACE_RETURN( TA_INTERNAL_ERROR(92) );
   }

   categoryHandle->nbSymbol = 2;
   categoryHandle->string = privData->ta_sim_ref_cat;
   categoryHandle->opaqueData = 0;

   privData->categoryIter = 1;   

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #8
0
/**** Global functions definitions.   ****/
TA_RetCode TA_AllocStringFromLibName( TA_Libc *libHandle,
                                      const TA_String *category,
                                      const TA_String *symbol,
                                      TA_String **allocatedYahooName )
{
   TA_PROLOG;

   TA_RetCode retCode;
   TA_StringCache *stringCache;
   char buffer[200];

   TA_TRACE_BEGIN( libHandle, TA_AllocStringFromLibName );
   buffer[199] = '\0'; /* Just to be safe. */

   /* Translate the category/symbol into the yahoo! name. */
   retCode = translateToYahooName( libHandle, category, symbol, &buffer[0], 199 );
   if( retCode != TA_SUCCESS )
   {
      TA_TRACE_RETURN( retCode );
   }

   stringCache = TA_GetGlobalStringCache( libHandle );
   *allocatedYahooName = TA_StringAlloc( stringCache, buffer );
   if( !*allocatedYahooName )
   {
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }
   
   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #9
0
/* Allows to dynamically add a mini-driver. */
TA_RetCode TA_SQL_AddMinidriver( const char scheme[], const TA_SQL_Minidriver *minidriver )
{
   TA_PROLOG
   TA_String *schemeStr;
   TA_StringCache *cache;

   TA_RetCode retCode;

   TA_TRACE_BEGIN( TA_SQL_AddMinidriver );

   if( !minidriverDict )
   {
      minidriverDict = TA_DictAlloc( TA_DICT_KEY_ONE_STRING, NULL );
      if( !minidriverDict )
      {
         TA_TRACE_RETURN( TA_ALLOC_ERR );
      }
   }

   cache = TA_GetGlobalStringCache();
   TA_ASSERT( cache != NULL );
   schemeStr = TA_StringAlloc( cache, scheme );
   if( !schemeStr )
   {
      TA_DictFree(minidriverDict);
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   retCode = TA_DictAddPair_S( minidriverDict, schemeStr, (void *)minidriver );
   TA_StringFree( cache, schemeStr );

   TA_TRACE_RETURN( retCode );
}
Exemple #10
0
   static TA_RetCode getGroupId( const char *groupString, unsigned int *groupId )
#endif
{
   #ifdef TA_GEN_CODE
   TA_PROLOG;
   #endif

   unsigned int i;

   #ifdef TA_GEN_CODE
      TA_TRACE_BEGIN( libHandle, getgroupId );

      TA_ASSERT( libHandle, groupString != NULL );
      TA_ASSERT( libHandle, groupId != NULL );
   #endif

   for( i=0; i < TA_NB_GROUP_ID; i++ )
   {
      if( strcmp( TA_GroupString[i], groupString ) == 0 )
      {
         *groupId = i;
         #ifdef TA_GEN_CODE
            TA_TRACE_RETURN( TA_SUCCESS );
         #else
            return TA_SUCCESS;
         #endif
      }
   }

   #ifdef TA_GEN_CODE
      TA_TRACE_RETURN( TA_GROUP_NOT_FOUND );
   #else
      return TA_GROUP_NOT_FOUND;
   #endif
}
Exemple #11
0
TA_RetCode TA_FileSeqClose( TA_FileHandle *handle )
{
   TA_PROLOG
   TA_RetCode retCode;
   TA_FileHandlePriv *fileHandlePriv;
   TA_SystemGlobal *global;
   #if defined( USE_WIN32_API )
   DWORD win32Error;
   BOOL retValue;
   #endif

   TA_TRACE_BEGIN(  TA_FileSeqClose );

   retCode = TA_GetGlobal(  &TA_SystemGlobalControl, (void **)&global );
   if( retCode != TA_SUCCESS )
   {
      TA_TRACE_RETURN( retCode );
   }

   TA_ASSERT( handle != NULL );

   fileHandlePriv = (TA_FileHandlePriv *)handle;

   if( fileHandlePriv )
   {
      #if defined( USE_WIN32_API )
         if( fileHandlePriv->handle != INVALID_HANDLE_VALUE )
         {
            retValue = CloseHandle( fileHandlePriv->handle );
            if( retValue == 0 )
            {
               win32Error = GetLastError();
               global->lastError = win32Error;
               TA_FATAL(  NULL, 0, win32Error );
            }
         }
         if( fileHandlePriv->allocBuffer )
         {
            freeDiskBuffer( fileHandlePriv->allocBuffer,
                            fileHandlePriv->allocBufferSize );
         }
      #endif

      #if defined( USE_OSLAYER )
         if( fileHandlePriv->handle != NULL )
            fclose( fileHandlePriv->handle );
         if( fileHandlePriv->allocBuffer )
            TA_Free(  fileHandlePriv->allocBuffer );
      #endif

      if( fileHandlePriv->streamAccess )
      {
         TA_StreamAccessFree( fileHandlePriv->streamAccess );
      }

      TA_Free(  fileHandlePriv );
   }

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #12
0
TA_RetCode TA_YAHOO_ShutdownSourceDriver( void )
{
   TA_PROLOG
   TA_TRACE_BEGIN( TA_YAHOO_ShutdownSourceDriver );

    /* Nothing to do for the time being. */
   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #13
0
TA_RetCode TA_YAHOO_ShutdownSourceDriver( TA_Libc *libHandle )
{
   TA_PROLOG;
   TA_TRACE_BEGIN( libHandle, TA_YAHOO_ShutdownSourceDriver );

    /* Nothing to do for the time being. */
   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #14
0
   static TA_RetCode getFuncNameByIdx( TA_GroupId groupId,
                                       unsigned int idx,
                                       const char **stringPtr )
#endif
{
   #ifdef TA_GEN_CODE
      /* Code used only when compiled with gen_code. */
      TA_PROLOG;
      unsigned int curIdx;
      unsigned int i, j, found;
      const TA_FuncDef **funcDefTable;
      unsigned int tableSize;
      const TA_FuncInfo *funcInfo;

      TA_TRACE_BEGIN( libHandle, getFuncNameByIdx );

      TA_ASSERT( libHandle, stringPtr != NULL );

      curIdx = 0;
      found = 0;
      for( i=0; (i < 26) && !found; i++ )
      {
         funcDefTable = TA_DEF_Tables[i];
         tableSize = *(TA_DEF_TablesSize[i]);

         for( j=0; (j < tableSize) && !found; j++ )
         {
            if( funcDefTable[j]->groupId == groupId )
            {
               if( idx == curIdx )
               {
                  funcInfo = funcDefTable[j]->funcInfo;
                  TA_ASSERT( libHandle, funcInfo != NULL );
                  *stringPtr = funcInfo->name;
                  found = 1;
               }
               curIdx++;
            }
         }
      }

      TA_ASSERT( libHandle, found == 1 );
      TA_ASSERT( libHandle, *stringPtr != NULL );

      TA_TRACE_RETURN( TA_SUCCESS );
   #else
      /* Optimized code in the final library. */
      const TA_FuncDef **funcDefTable;
      const TA_FuncInfo *funcInfo;

      funcDefTable = TA_PerGroupFuncDef[groupId];
      funcInfo = funcDefTable[idx]->funcInfo;
      *stringPtr = funcInfo->name;

      return TA_SUCCESS;
   #endif
}
Exemple #15
0
/**** Global functions definitions.   ****/
TA_RetCode TA_SIMULATOR_InitializeSourceDriver( void )
{
   TA_PROLOG

   TA_TRACE_BEGIN(  TA_SIMULATOR_InitializeSourceDriver );

   /* Nothing to do for the time being. */
   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #16
0
TA_RetCode TA_SIMULATOR_GetParameters( TA_DataSourceParameters *param )
{
   TA_PROLOG

   TA_TRACE_BEGIN(  TA_SIMULATOR_GetParameters );
   memset( param, 0, sizeof( TA_DataSourceParameters ) );

   /* All parameters are zero */
   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #17
0
/**** Global functions definitions.   ****/
TA_RetCode TA_HistoryCheckInternal( TA_Libc            *libHandle,
                                    TA_Period           expectedPeriod,
                                    const TA_Timestamp *expectedStart,
                                    const TA_Timestamp *expectedEnd,
                                    TA_Field            fieldToCheck,
                                    const TA_History   *history,
                                    unsigned int       *faultyIndex,
                                    unsigned int       *faultyField )
{
   TA_PROLOG;
   unsigned int allFieldNull;

   (void)faultyField;
   (void)faultyIndex;
   (void)fieldToCheck;
   (void)expectedEnd;
   (void)expectedStart;

   TA_TRACE_BEGIN( libHandle, TA_HistoryCheckInternal );

   TA_ASSERT( libHandle, history != NULL );

   /* Period shall be always set in the history. */
   if( history->period != expectedPeriod )
   {
      TA_TRACE_RETURN( TA_UNKNOWN_ERR );
   }

   /* Verify that an empty history is really empty. */
   if( (history->open  == NULL) &&
       (history->high  == NULL) &&
       (history->low   == NULL) &&
       (history->close == NULL) &&
       (history->volume == NULL) &&
       (history->openInterest == NULL) &&
       (history->timestamp == NULL) )
   {
      allFieldNull = 1;
      if( history->nbBars != 0 )
      {
         TA_TRACE_RETURN( TA_UNKNOWN_ERR );
      }
   }
   else
      allFieldNull = 0;

   if( (history->nbBars == 0) && !allFieldNull )
   {
      TA_TRACE_RETURN( TA_UNKNOWN_ERR );
   }

   /* !!! Some more runtime verification could be added here... */

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #18
0
/* Finally, call a TA function with the parameters. */
TA_RetCode TA_CallFunc( const TA_ParamHolder *param,
                        TA_Integer            startIdx,
                        TA_Integer            endIdx,
                        TA_Integer           *outBegIdx,
                        TA_Integer           *outNbElement )
{
   TA_PROLOG
   TA_RetCode retCode;
   const TA_ParamHolderPriv *paramHolderPriv;

   const TA_FuncDef *funcDef;
   const TA_FuncInfo *funcInfo;
   TA_FrameFunction function;

   TA_TRACE_BEGIN( TA_CallFunc );

   if( (param == NULL) ||
       (outBegIdx == NULL) ||
       (outNbElement == NULL) )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   paramHolderPriv = (TA_ParamHolderPriv *)(param->hiddenData);
   if( paramHolderPriv->magicNumber != TA_PARAM_HOLDER_PRIV_MAGIC_NB )
   {
      TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER );
   }
   
   /* Check that all parameters are initialize (except the optInput). */
   if( paramHolderPriv->inBitmap != 0 )
   {
      TA_TRACE_RETURN( TA_INPUT_NOT_ALL_INITIALIZE );
   }

   if( paramHolderPriv->outBitmap != 0 )
   {
      TA_TRACE_RETURN( TA_OUTPUT_NOT_ALL_INITIALIZE );
   }

   /* Get the pointer on the function */
   funcInfo = paramHolderPriv->funcInfo;
   TA_DEBUG_ASSERT( funcInfo != NULL );
   funcDef = (const TA_FuncDef *)funcInfo->handle;
   TA_DEBUG_ASSERT( funcDef != NULL );
   function = funcDef->function;
   TA_DEBUG_ASSERT( function != NULL );

   /* Perform the function call. */
   retCode = (*function)( paramHolderPriv, startIdx, endIdx,
                          outBegIdx, outNbElement );

   TA_TRACE_RETURN( retCode );
}
TA_RetCode TA_FileIndexMoveToPrevToken( TA_FileIndexPriv *data )
{
   TA_PROLOG;
   TA_Libc *libHandle;
   TA_RetCode retCode;

   if( !data )
      return TA_UNKNOWN_ERR;

   libHandle = data->libHandle;
   TA_TRACE_BEGIN( libHandle, TA_FileIndexMoveToPrevToken );

   if( data->curToken == NULL )
   {
      /* Iterator variable not initialize. Simply position everything on the
       * first token.
       */
      retCode = TA_FileIndexMoveToNextToken( data );
      TA_TRACE_RETURN( retCode ); 
   }
   else if( data->prevToken == NULL )
   {
      /* Can't go further back. Simply return. */
      TA_TRACE_RETURN( TA_SUCCESS );
   }
   else
   {
      if( data->curDirectionForward == 1 )
      {
         if( data->nextToken != NULL )
            TA_ListAccessPrev( data->listLocationToken );
         else
            TA_ListAccessTail( data->listLocationToken );

         TA_ListAccessPrev( data->listLocationToken );
         data->curDirectionForward = 0;
      }

      data->nextToken = data->curToken;
      data->curToken = data->prevToken;
      data->prevToken = (TA_TokenInfo *)TA_ListAccessPrev( data->listLocationToken );

      /* Parano test: Should never happen since the code assume that
       * the 'listLocationToken' is always terminated by TA_END.
       */
      if( !data->curToken )
      {
         TA_FATAL( data->libHandle, NULL, data->curToken->id, data->curTokenDepth );
      }
   }
   data->curTokenDepth--;

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #20
0
TA_RetCode TA_YAHOO_CloseSource( TA_DataSourceHandle *handle )
{
   TA_PROLOG

   TA_TRACE_BEGIN( TA_YAHOO_CloseSource );

   /* Free all ressource used by this handle. */
   if( handle )
      TA_YAHOO_DataSourceHandleFree( handle );

   TA_TRACE_RETURN( TA_SUCCESS );
}
TA_RetCode TA_FileIndexAddTokenInfo( TA_FileIndexPriv *data,
                                     TA_TokenId id,
                                     TA_String *value,
                                     TA_TokenInfo *optBefore )
{
   TA_PROLOG;
   TA_RetCode retCode;
   TA_TokenInfo *info;
   TA_Libc *libHandle;
   TA_StringCache *stringCache;

   libHandle   = data->libHandle;
   TA_TRACE_BEGIN( libHandle, TA_FileIndexAddTokenInfo );

   stringCache = TA_GetGlobalStringCache( libHandle );

   info = TA_Malloc( libHandle, sizeof( TA_TokenInfo ) );

   if( !info )
   {
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   info->id = id;
   if( value == NULL )
      info->value = NULL;
   else
   {
      info->value = TA_StringDup( stringCache, value );

      if( !info->value )
      {
         TA_Free( libHandle, info );
         TA_TRACE_RETURN( TA_ALLOC_ERR );
      }
   }

   if( optBefore )
      retCode = TA_ListAddBefore( data->listLocationToken, optBefore, info );
   else
      retCode = TA_ListAddTail( data->listLocationToken, info );

    if( retCode != TA_SUCCESS )
    {
      if( info->value )
         TA_StringFree( stringCache, info->value );
      TA_Free( libHandle, info );
      TA_TRACE_RETURN( retCode );
   }

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #22
0
TA_RetCode TA_YAHOO_GetParameters( TA_DataSourceParameters *param )
{
   TA_PROLOG

   TA_TRACE_BEGIN(  TA_YAHOO_GetParameters );

   memset( param, 0, sizeof( TA_DataSourceParameters ) );

   /* Internet access is considered slow. */
   param->flags = TA_SLOW_ACCESS;

   TA_TRACE_RETURN( TA_SUCCESS );
}
TA_RetCode TA_FileIndexAddTreeValue( TA_FileIndexPriv *data,
                                     TA_String *string,
                                     TA_ValueTreeNode **added )
{
   TA_PROLOG;
   TA_ValueTreeNode *node;
   unsigned int allocateEmptyString;
   TA_Libc *libHandle;
   TA_StringCache *stringCache;

   libHandle = data->libHandle;
   TA_TRACE_BEGIN( libHandle, TA_FileIndexAddTreeValue );

   stringCache = TA_GetGlobalStringCache( libHandle );

   allocateEmptyString = 0;
   TA_ASSERT( libHandle, data != NULL );

   if( added )
      *added = NULL;

   if( !string )
   {
      string = TA_StringAlloc( stringCache, "" );
      if( !string )
      {
         TA_TRACE_RETURN( TA_ALLOC_ERR );
      }
      allocateEmptyString = 1;
   }

   /* Alloc the TA_ValueTreeNode */
   node = allocTreeNode( libHandle, data->currentNode, string );

   if( allocateEmptyString )
      TA_StringFree( stringCache, string );

   if( !node )
   {
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   data->currentNode = node;

   if( added )
      *added = node;

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #24
0
/**** Local functions definitions.     ****/
static TA_RetCode initCategoryHandle( TA_Libc *libHandle,
                                      TA_DataSourceHandle *handle,
                                      TA_CategoryHandle   *categoryHandle,
                                      unsigned int index )
{
   TA_PROLOG;
   TA_PrivateYahooHandle *privData;
   TA_YahooIdx *yahooIndex;
   TA_String   *string;

   TA_TRACE_BEGIN( libHandle, TA_YAHOO_GetFirstCategoryHandle );

   if( (handle == NULL) || (categoryHandle == NULL) )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   privData = (TA_PrivateYahooHandle *)(handle->opaqueData);

   if( !privData )
   {
      TA_TRACE_RETURN( TA_INTERNAL_ERROR(99) );
   }

   yahooIndex = privData->index;

   if( !yahooIndex )
   {
      TA_TRACE_RETURN( TA_INTERNAL_ERROR(100) );
   }

   if( index >= yahooIndex->nbCategory )
      return TA_END_OF_INDEX;

   string = yahooIndex->categories[index]->name;

   if( !string )
   {
      TA_TRACE_RETURN( TA_INTERNAL_ERROR(101) ); /* At least one category must exist. */
   }

   /* Set the categoryHandle. */
   categoryHandle->string = string;
   categoryHandle->nbSymbol = yahooIndex->categories[index]->nbSymbol;
   categoryHandle->opaqueData = yahooIndex->categories[index];

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #25
0
TA_RetCode TA_YAHOO_GetParameters( TA_DataSourceParameters *param )
{
   TA_PROLOG

   TA_TRACE_BEGIN( TA_YAHOO_GetParameters );

   memset( param, 0, sizeof( TA_DataSourceParameters ) );

   /* Internet access is considered slow. */
   param->flags = TA_SLOW_ACCESS;

   /* Indicate the support for split/value adjustment. */
   param->flags |= TA_DO_NOT_SPLIT_ADJUST;
   param->flags |= TA_DO_NOT_VALUE_ADJUST;

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #26
0
TA_RetCode TA_SetInputParamRealPtr( TA_ParamHolder *param,
                                    unsigned int paramIndex,
                                    const TA_Real *value )
{
   TA_PROLOG
   TA_ParamHolderPriv *paramHolderPriv;
   const TA_InputParameterInfo *paramInfo;
   const TA_FuncInfo *funcInfo;

   TA_TRACE_BEGIN( TA_SetInputParamIntegerPtr );

   if( (param == NULL) || (value == NULL) )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   paramHolderPriv = (TA_ParamHolderPriv *)(param->hiddenData);
   if( paramHolderPriv->magicNumber != TA_PARAM_HOLDER_PRIV_MAGIC_NB )
   {
      TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER );
   }

   /* Make sure this index really exist. */
   funcInfo = paramHolderPriv->funcInfo;
   TA_DEBUG_ASSERT( funcInfo != NULL );
   if( paramIndex >= funcInfo->nbInput )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }   

   /* Verify the type of the parameter. */
   paramInfo = paramHolderPriv->in[paramIndex].inputInfo;
   TA_DEBUG_ASSERT( paramInfo != NULL );
   if( paramInfo->type != TA_Input_Real )
   {
      TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER_TYPE );
   }

   /* keep a copy of the provided parameter. */
   paramHolderPriv->in[paramIndex].data.inReal = value; 

   /* This parameter is now initialized, clear the corresponding bit. */
   paramHolderPriv->inBitmap &= ~(1<<paramIndex);

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #27
0
TA_RetCode TA_SIMULATOR_GetNextSymbolHandle( TA_DataSourceHandle *handle,
                                             TA_CategoryHandle   *categoryHandle,
                                             TA_SymbolHandle     *symbolHandle,
                                             unsigned int index )
{
   TA_PROLOG
   TA_PrivateHandle *privData;

   TA_TRACE_BEGIN(  TA_SIMULATOR_GetNextSymbolHandle );

   (void)index; /* Get ride of compiler warnings. */

   if( (handle == NULL) || (categoryHandle == NULL) || (symbolHandle == NULL) )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   privData = (TA_PrivateHandle *)(handle->opaqueData);

   if( !privData )
   {
      TA_TRACE_RETURN( TA_INTERNAL_ERROR(96) );
   }
   /* Get the first symbol in this category. */
   switch( (unsigned int)categoryHandle->opaqueData )
   {
   case 0: /* This is TA_SIM_REF */
      if( privData->catRefIter == 1 )
      {
         symbolHandle->string = privData->intra_ref_0;
         symbolHandle->opaqueData = (void *)1;
         privData->catRefIter = 2;
      }
      else
      {
         TA_TRACE_RETURN( TA_END_OF_INDEX );
      }
      break;
   case 1: /* This is TA_SIM_MRG */
      TA_TRACE_RETURN( TA_END_OF_INDEX );
   default:
      TA_TRACE_RETURN( TA_INTERNAL_ERROR(97) );
   }

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #28
0
TA_RetCode TA_ParamHolderFree( TA_ParamHolder *paramsToFree )
{
   TA_PROLOG

   TA_ParamHolderPriv     *paramPriv;

   TA_ParamHolderInput    *input;
   TA_ParamHolderOptInput *optInput;
   TA_ParamHolderOutput   *output;

   TA_TRACE_BEGIN( TA_ParamHolderFree );

   if( !paramsToFree )
   {
      TA_TRACE_RETURN( TA_SUCCESS );
   }

   paramPriv = paramsToFree->hiddenData;

   if( !paramPriv )
   {
      TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER );
   }

   if( paramPriv->magicNumber != TA_PARAM_HOLDER_PRIV_MAGIC_NB )
   {
      TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER );
   }

   optInput = paramPriv->optIn;
   if( optInput )
      TA_Free( optInput );

   input = paramPriv->in;
   if( input )
      TA_Free( input );

   output = paramPriv->out;
   if( output )
      TA_Free( output );

   TA_Free( paramsToFree );

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #29
0
TA_RetCode TA_SetOutputParameterInfoPtr( const TA_FuncHandle *handle,
                                         unsigned int paramIndex,
                                         const TA_OutputParameterInfo **info )
{
   TA_PROLOG
   const TA_FuncDef  *funcDef;
   const TA_FuncInfo *funcInfo;
   const TA_OutputParameterInfo **outputTable;

   TA_TRACE_BEGIN( TA_SetOutputParameterInfoPtr );

   if( (handle == NULL) || (info == NULL) )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   *info = NULL;

   /* Validate that this is a valid funcHandle. */
   funcDef = (const TA_FuncDef *)handle;
   if( funcDef->magicNumber != TA_FUNC_DEF_MAGIC_NB )
   {
      TA_TRACE_RETURN( TA_INVALID_HANDLE );
   }

   funcInfo = funcDef->funcInfo;

   TA_DEBUG_ASSERT( funcInfo != NULL );

   if( paramIndex >= funcInfo->nbOutput )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   outputTable = (const TA_OutputParameterInfo **)funcDef->output;

   TA_DEBUG_ASSERT( outputTable != NULL );

   *info = outputTable[paramIndex];

   TA_DEBUG_ASSERT( *info != NULL );

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #30
0
TA_RetCode TA_SetOptInputParamInteger( TA_ParamHolder *param,
                                       unsigned int paramIndex,
                                       TA_Integer value )
{
   TA_PROLOG
   TA_ParamHolderPriv *paramHolderPriv;
   const TA_OptInputParameterInfo *paramInfo;
   const TA_FuncInfo *funcInfo;

   TA_TRACE_BEGIN( TA_SetOptInputParamReal );

   if( param == NULL )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   paramHolderPriv = (TA_ParamHolderPriv *)(param->hiddenData);
   if( paramHolderPriv->magicNumber != TA_PARAM_HOLDER_PRIV_MAGIC_NB )
   {
      TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER );
   }

   /* Make sure this index really exist. */
   funcInfo = paramHolderPriv->funcInfo;
   TA_DEBUG_ASSERT( funcInfo != NULL );
   if( paramIndex >= funcInfo->nbOptInput )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }   

   /* Verify the type of the parameter. */
   paramInfo = paramHolderPriv->optIn[paramIndex].optInputInfo;
   TA_DEBUG_ASSERT( paramInfo != NULL );
   if( (paramInfo->type != TA_OptInput_IntegerRange) &&
       (paramInfo->type != TA_OptInput_IntegerList) )
   {
      TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER_TYPE );
   }

   /* keep a copy of the provided parameter. */
   paramHolderPriv->optIn[paramIndex].data.optInInteger = value; 

   TA_TRACE_RETURN( TA_SUCCESS );
}