BBString * bmx_boostlocale_intascurrency(MaxLocale * loc, int value) { std::stringstream stream; stream.imbue(loc->Locale()); stream << boost::locale::as::currency << value; return bbStringFromUTF8String(stream.str().c_str()); }
BBString * bmx_boostlocale_locale_encoding(MaxLocale * loc) { return bbStringFromUTF8String(std::use_facet<boost::locale::info>(loc->Locale()).encoding().c_str()); }
BBString * bmx_boostlocale_floatasnumber(MaxLocale * loc, float value) { std::stringstream stream; stream.imbue(loc->Locale()); stream << boost::locale::as::number << value; return bbStringFromUTF8String(stream.str().c_str()); }
void XMLCALL bmx_expat_EntityDeclHandler(void *userData, const char *entityName, int is_parameter_entity, const char *value, int value_length, const char *base, const char *systemId, const char *publicId, const char *notationName) { if (value_length > 0) { char buf[value_length +1]; memcpy(&buf, value, value_length); _bah_expat_TXMLParser__EntityDeclHandler((BBObject *)userData, bbStringFromUTF8String(entityName), is_parameter_entity, bbStringFromUTF8String((char*)&buf), bbStringFromUTF8String(base), bbStringFromUTF8String(systemId), bbStringFromUTF8String(publicId), bbStringFromUTF8String(notationName)); } else { _bah_expat_TXMLParser__EntityDeclHandler((BBObject *)userData, bbStringFromUTF8String(entityName), is_parameter_entity, &bbEmptyString, bbStringFromUTF8String(base), bbStringFromUTF8String(systemId), bbStringFromUTF8String(publicId), bbStringFromUTF8String(notationName)); } }
void bbStartup( int argc,char *argv[],void *dummy1,void *dummy2 ){ int i,k; BBString **p; //Start up GC and create bbAppFile, bbAppDir and bbLaunchDir #if _WIN32 char *ebp; OSVERSIONINFO os={ sizeof(os) }; //asm( "movl %%ebp,%0;":"=r"(ebp) );//::"%ebp" ); //bbGCStackTop=ebp+28; // BaH bbThreadStartup(); bbGCStartup(); if( GetVersionEx( &os ) ){ if( os.dwPlatformId==VER_PLATFORM_WIN32_NT ){ _bbusew=1; } } if( _bbusew ){ int e=0; wchar_t buf[MAX_PATH]; _wgetcwd( buf,MAX_PATH ); for( i=0;buf[i];++i ){ if( buf[i]=='\\' ) buf[i]='/'; } bbLaunchDir=bbStringFromWString( buf ); GetModuleFileNameW( GetModuleHandleW(0),buf,MAX_PATH ); for( i=0;buf[i];++i ){ if( buf[i]=='\\' ) buf[i]='/'; if( buf[i]=='/' ) e=i; } bbAppFile=bbStringFromWString( buf ); if( e ){ if( buf[e-1]==':' ) ++e; bbAppDir=bbStringFromShorts( buf,e ); }else{ bbAppDir=&bbEmptyString; } _wchdir( bbTmpWString( bbAppDir ) ); }else{ int e=0; char buf[MAX_PATH]; _getcwd( buf,MAX_PATH ); for( i=0;buf[i];++i ){ if( buf[i]=='\\' ) buf[i]='/'; } bbLaunchDir=bbStringFromCString( buf ); GetModuleFileNameA( GetModuleHandleA(0),buf,MAX_PATH ); for( i=0;buf[i];++i ){ if( buf[i]=='\\' ) buf[i]='/'; if( buf[i]=='/' ) e=i; } bbAppFile=bbStringFromCString( buf ); if( e ){ if( buf[e-1]==':' ) ++e; bbAppDir=bbStringFromBytes( buf,e ); }else{ bbAppDir=&bbEmptyString; } _chdir( bbTmpCString( bbAppDir ) ); } #elif __linux char *ebp; char buf[PATH_MAX]; char lnk[PATH_MAX]; pid_t pid; // asm( "movl %%ebp,%0;":"=r"(ebp) );//::"%ebp" ); bbGCStackTop=ebp+28; // BaH bbThreadStartup(); bbGCStartup(); getcwd( buf,PATH_MAX ); bbLaunchDir=bbStringFromUTF8String( buf ); pid=getpid(); sprintf( lnk,"/proc/%i/exe",pid ); i=readlink( lnk,buf,PATH_MAX ); if( i>0 ){ char *p; buf[i]=0; bbAppFile=bbStringFromUTF8String( buf ); p=strrchr( buf,'/' ); if( p ){ *p=0; bbAppDir=bbStringFromUTF8String( buf ); }else{ bbAppDir=&bbEmptyString; } }else{ bbAppFile=&bbEmptyString; bbAppDir=&bbEmptyString; } chdir( bbTmpUTF8String( bbAppDir ) ); #elif __APPLE__ CFURLRef url; char buf[PATH_MAX],*e; //#if BB_ARGP // bbGCStackTop=bbArgp(0); //#else bbGCStackTop=&argc; //#endif // BaH bbThreadStartup(); bbGCStartup(); getcwd( buf,PATH_MAX ); bbLaunchDir=bbStringFromUTF8String( buf ); url=CFBundleCopyExecutableURL( CFBundleGetMainBundle() ); CFURLGetFileSystemRepresentation( url,true,(UInt8*)buf,PATH_MAX ); CFRelease( url ); bbAppFile=bbStringFromUTF8String( buf ); if( e=strstr( buf,".app/Contents/MacOS/" ) ){ *e=0; } if( e=strrchr( buf,'/' ) ){ *e=0; bbAppDir=bbStringFromUTF8String( buf ); }else{ bbAppDir=&bbEmptyString; } chdir( bbTmpUTF8String( bbAppDir ) ); #endif BBINCREFS( bbLaunchDir ); BBINCREFS( bbAppDir ); BBINCREFS( bbAppFile ); bbAppTitle=bbStringFromCString( "BlitzMax Application" ); BBINCREFS( bbAppTitle ); bbAppArgs=bbArrayNew1D( "$",argc ); BBINCREFS( bbAppArgs ); p=(BBString**)BBARRAYDATA( bbAppArgs,1 ); for( k=0;k<argc;++k ){ BBString *arg=bbStringFromCString( argv[k] ); BBINCREFS( arg ); *p++=arg; } startup(); }
void XMLCALL bmx_expat_EndNamespaceDeclHandler(void *userData, const char *prefix) { _bah_expat_TXMLParser__EndNamespaceDeclHandler((BBObject *)userData, bbStringFromUTF8String(prefix)); }
void XMLCALL bmx_expat_XmlDeclHandler(void *userData, const char *version, const char *encoding, int standalone) { _bah_expat_TXMLParser__XmlDeclHandler((BBObject *)userData, bbStringFromUTF8String(version), bbStringFromUTF8String(encoding), standalone); }
void XMLCALL bmx_expat_DefaultHandlerExpand(void *userData, const char *s, int len) { char buf[len+1]; memcpy(&buf, s, len); _bah_expat_TXMLParser__DefaultHandlerExpand((BBObject *)userData, bbStringFromUTF8String((char*)&buf)); }
void XMLCALL bmx_expat_SkippedEntityHandler(void *userData, const char *entityName, int is_parameter_entity) { _bah_expat_TXMLParser__SkippedEntityHandler((BBObject *)userData, bbStringFromUTF8String(entityName), is_parameter_entity); }
void XMLCALL bmx_expat_ProcessingInstructionHandler(void *userData, const char *target, const char *data) { _bah_expat_TXMLParser__ProcessingInstructionHandler((BBObject *)userData, bbStringFromUTF8String(target), bbStringFromUTF8String(data)); }
void XMLCALL bmx_expat_CommentHandler(void *userData, const char *data) { _bah_expat_TXMLParser__CommentHandler((BBObject *)userData, bbStringFromUTF8String(data)); }
void XMLCALL bmx_expat_CharacterDataHandler(void *userData, const char *text, int len) { char buf[len+1]; memcpy(&buf, text, len); _bah_expat_TXMLParser__CharacterDataHandler((BBObject *)userData, bbStringFromUTF8String((char*)&buf)); }
void XMLCALL bmx_expat_EndElementHandler(void *userData, const char *name) { _bah_expat_TXMLParser__EndElementHandler((BBObject *)userData, bbStringFromUTF8String(name)); }
BBString *readdir_( int dir ){ struct dirent *t=readdir( (DIR*)dir ); return t ? bbStringFromUTF8String( t->d_name ) : &bbEmptyString; }
BBString *getcwd_(){ char buf[PATH_MAX]; getcwd( buf,PATH_MAX ); return bbStringFromUTF8String( buf ); }
BBString *getenv_( BBString *str ){ return bbStringFromUTF8String( getenv( bbTmpUTF8String(str) ) ); }