void CPluginConfig::Unload() { if ( _load ) { CPluginManager::Instance().UnloadPlugin( _path + GetLibName( _plugin ) ); } }
static void resolveTypePrototypes( void ) { /*****************************************/ /* adds required protoypes to the protoype section */ statement *finger; statement *rc; long len; char *name; char *libname; if( !SRU.type_sec ) { return; } finger = SRU.forward_prots; /* loop through the chain of prototypes and add them if necessary */ while( finger ) { name = finger->data.sp.name; len = strlen( name ); /* check in hash table for function name */ if( !FindHashEntry(SRU.type_prots, HashString(name, len), name, len) ) { /* add to prototype section */ rc = insertTypePrototype( finger, SRU.type_sec ); rc->link = SRU.cpp_prots; SRU.cpp_prots = rc; rc->keep = TRUE; InsertHashValue( SRU.type_prots, rc->data.sp.name, strlen( rc->data.sp.name ), rc ); } finger = finger->link; } /* generate constructors and destructor prototypes if necessary */ libname = GetLibName(); len = max( sizeof( DES_DECL_TEMPLATE ) + strlen( SRU.des_name ), sizeof( CONS_DECL_TEMPLATE ) + strlen( SRU.con_name ) ); name = alloca( len + strlen( libname ) + 1 ); if( !( SRU.flags & DESTRUCTOR_DEFINED ) ) { sprintf( name, DES_DECL_TEMPLATE, SRU.des_name, libname ); insertStatement( SRU.type_sec, name ); } if( !( SRU.flags & CONSTRUCTOR_DEFINED ) ) { sprintf( name, CONS_DECL_TEMPLATE, SRU.con_name, libname ); insertStatement( SRU.type_sec, name ); } }
/*! ************************************************************************************* * \brief System trace log output in Wels * * \param pCtx instance pointer * \param kiLevel log iLevel ( WELS_LOG_QUIET, ERROR, WARNING, INFO, DEBUG ) * \param kpFmtStr formated string to mount * \param argv pData string argument * * \return NONE * * \note N/A ************************************************************************************* */ void WelsLogDefault( void *pCtx, const int32_t kiLevel, const str_t *kpFmtStr, va_list argv ) { sWelsEncCtx *pEncCtx = (sWelsEncCtx *)pCtx; iWelsLogLevel iVal = (kiLevel & g_iLevelLog); if ( 0 == iVal || NULL == pEncCtx ) // such iLevel not enabled { return; } else { str_t pBuf[WELS_LOG_BUF_SIZE+1] = {0}; const int32_t kiBufSize = sizeof(pBuf) / sizeof(pBuf[0]) - 1; int32_t iCurUsed = 0; int32_t iBufUsed = 0; int32_t iBufLeft = kiBufSize - iBufUsed; if ( pEncCtx ){ time_t l_time; #if defined(WIN32) #if defined(_MSC_VER) #if _MSC_VER >= 1500 struct tm t_now; #else//VC6 struct tm* t_now; #endif//_MSC_VER >= 1500 #endif//_MSC_VER #else//__GNUC__ struct tm* t_now; #endif//WIN32 #if defined( WIN32 ) struct _timeb tb; time(&l_time); #ifdef _MSC_VER #if _MSC_VER >= 1500 LOCALTIME(&t_now, &l_time); #else t_now = LOCALTIME(&l_time); if ( NULL == t_now ) { return; } #endif//_MSC_VER >= 1500 #endif//_MSC_VER FTIME(&tb); #elif defined( __GNUC__ ) struct timeval tv; time(&l_time); t_now = (struct tm *)LOCALTIME(&l_time); gettimeofday(&tv,NULL); #endif//WIN32 if (iBufLeft > 0){ #ifdef _MSC_VER #if _MSC_VER >= 1500 iCurUsed = SNPRINTF( &pBuf[iBufUsed], iBufLeft, iBufLeft, "[0x%p @ ", pEncCtx ); // confirmed_safe_unsafe_usage #else iCurUsed = SNPRINTF( &pBuf[iBufUsed], iBufLeft, "[0x%p @ ", pEncCtx ); // confirmed_safe_unsafe_usage #endif//_MSC_VER >= 1500 #endif//_MSC_VER if (iCurUsed >= 0){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } } else{ return; } if ( iBufLeft > 0 ){ iCurUsed = GetCodeName( &pBuf[iBufUsed], iBufLeft ); if ( iCurUsed > 0 ){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } pBuf[iBufUsed] = ' '; ++ iBufUsed; -- iBufLeft; iCurUsed = GetLibName( &pBuf[iBufUsed], iBufLeft ); if ( iCurUsed > 0 ){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } pBuf[iBufUsed] = ' '; ++ iBufUsed; -- iBufLeft; pBuf[iBufUsed] = 'v'; ++ iBufUsed; -- iBufLeft; iCurUsed = GetVerNum( &pBuf[iBufUsed], iBufLeft ); if ( iCurUsed > 0 ){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } pBuf[iBufUsed] = ' '; ++ iBufUsed; -- iBufLeft; } if (iBufLeft > 0){ #if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1500) iCurUsed = strftime(&pBuf[iBufUsed], iBufLeft, "%y-%m-%d %H:%M:%S", &t_now); #else iCurUsed = strftime(&pBuf[iBufUsed], iBufLeft, "%y-%m-%d %H:%M:%S", t_now); #endif//WIN32.. if (iCurUsed > 0){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } } else{ return; } if (iBufLeft > 0){ #if defined (WIN32) #ifdef _MSC_VER #if _MSC_VER >= 1500 iCurUsed = SNPRINTF(&pBuf[iBufUsed], iBufLeft, iBufLeft, ".%03.3u]: ", tb.millitm); // confirmed_safe_unsafe_usage #else iCurUsed = SNPRINTF(&pBuf[iBufUsed], iBufLeft, ".%3.3u]: ", tb.millitm); // confirmed_safe_unsafe_usage #endif//_MSC_VER >= 1500 #endif//_MSC_VER #elif defined (__GNUC__) iCurUsed = SNPRINTF(&pBuf[iBufUsed], iBufLeft, ".%3.3u]: ", tv.tv_usec/1000); // confirmed_safe_unsafe_usage #endif//WIN32 if (iCurUsed >= 0){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } } else{ return; } } // fixed stack corruption issue on vs2008 if ( iBufLeft > 0 ){ int32_t i_shift = 0; str_t *pStr = NULL; pStr = GetLogTag( kiLevel, &i_shift ); if ( NULL != pCtx){ int32_t iLenTag = STRNLEN( pStr, 8 ); // confirmed_safe_unsafe_usage STRCAT( &pBuf[iBufUsed], iBufLeft, pStr ); // confirmed_safe_unsafe_usage iBufUsed += iLenTag; pBuf[iBufUsed] = ' '; iBufUsed++; ++iLenTag; iBufLeft -= iLenTag; } } if (iBufLeft > 0){ #if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1500) int32_t len = 0; len = _vscprintf( kpFmtStr, argv ) // _vscprintf doesn't count + 1; // terminating '\0' iCurUsed = VSPRINTF(&pBuf[iBufUsed], len, kpFmtStr, argv); // confirmed_safe_unsafe_usage #else iCurUsed = VSPRINTF(&pBuf[iBufUsed], kpFmtStr, argv); // confirmed_safe_unsafe_usage #endif//WIN32.. if (iCurUsed > 0){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } } #ifdef ENABLE_TRACE_FILE if (NULL != pEncCtx && NULL != pEncCtx->pFileLog){ if ( pEncCtx->uiSizeLog > MAX_TRACE_LOG_SIZE){ if (0 == fseek(pEncCtx->pFileLog, 0L, SEEK_SET)) pEncCtx->uiSizeLog = 0; } if ( iBufUsed > 0 && iBufUsed < WELS_LOG_BUF_SIZE ) { iCurUsed = fwrite(pBuf, 1, iBufUsed, pEncCtx->pFileLog); fflush( pEncCtx->pFileLog ); if ( iCurUsed == iBufUsed ) pEncCtx->uiSizeLog += iBufUsed; } } else{ #if defined(WIN32) && defined(_DEBUG) OutputDebugStringA(pBuf); #endif } #endif//ENABLE_TRACE_FILE } }
static statement *insertTypePrototype( statement *func, statement *locale ) { /***************************************************************************/ /* insert a prototype of the external function into the types protoype section*/ char *line; char *name; char *libname; char *sp; char *ret; var_rec *finger; statement *rc; long size; TypeInfo *typ; char typbuf[64]; TypeInfo tmptype; assert( func ); assert( locale ); name = func->data.sp.name; /* determine return type */ if( !func->data.sp.subroutine ) { typ = &func->data.sp.ret_type; sp = FUNCTION; if( _IsRefType( func->data.sp.typ_id ) ) { strcpy( typbuf, REF_MODIFIER ); strcat( typbuf, typ->name ); ret = typbuf; if( !func->data.sp.typ_id ) { func->data.sp.fake = TRUE; } } else { ret = typ->name; } } else { ret = ""; sp = SUBROUTINE; } /* calculate size of statement */ libname = GetLibName(); size = strlen( name ) + strlen( sp ) + strlen( ret ) + strlen( libname ); size += sizeof( DECL_THIS_VAR ) + sizeof( LIBRARY ) + sizeof( LEFT_PAREN ) + sizeof( RIGHT_PAREN ) + sizeof( DLL_SUFFIX ) + sizeof( DQUOTE ) + sizeof( DQUOTE ) + OVERHEAD; finger = func->data.sp.parm_list; while( finger ) { size += sizeof( COMMA_DELIM ) + strlen( finger->name ) + 3; if( _IsRefType( finger->typ_id ) ) { size += sizeof( REF_MODIFIER ); } size += strlen( finger->type.name ); finger = finger->next; } /* build the statement */ line = alloca( size ); finger = func->data.sp.parm_list; if( Options & OPT_GEN_C_CODE ) { sprintf( line, "%s %s %s %s ", sp, ret, name, LEFT_PAREN ); } else { sprintf( line, "%s %s %s %s %s", sp, ret, name, LEFT_PAREN, DECL_THIS_VAR ); if( finger ) { strcat( line, COMMA_DELIM ); } } while( finger ) { if( _IsRefType( finger->typ_id ) ) { strcat( line, REF_MODIFIER ); } strcat( line, finger->type.name ); strcat( line, " " ); strcat( line, finger->name ); if( finger->next ) { strcat( line, COMMA_DELIM ); } finger = finger->next; } strcat( line, RIGHT_PAREN ); strcat( line, " " ); strcat( line, LIBRARY ); strcat( line, DQUOTE ); strcat( line, libname ); strcat( line, DLL_SUFFIX ); strcat( line, DQUOTE ); strcat( line, "\n" ); /* insert statement into our statement linked list */ rc = insertStatement( locale, line ); // beware - when pointers get added to the sp_header structure they // must be explicitly copied here or else things will get freed // twice. This code should be rewritten. DRW memcpy( &(rc->data), &(func->data), sizeof( spec ) ); rc->data.sp.name = MemStrDup( name ); copyTypeInfo( &rc->data.sp.ret_type, &func->data.sp.ret_type ); finger = func->data.sp.parm_list; SRU.curr.sp.parm_list = NULL; SRU.curr.sp.last_parm = NULL; tmptype.name = THIS_TYPE; tmptype.isref = FALSE; AddParm( &tmptype, THIS_VARIABLE, NULL ); while( finger ) { AddParm( &finger->type, finger->name, finger->array ); finger = finger->next; } rc->data.sp.parm_list = SRU.curr.sp.parm_list; rc->data.sp.last_parm = SRU.curr.sp.last_parm; rc->typ = SRU_SUBPROG; return( rc ); }