diff --git a/uppsrc/Core/App.cpp b/uppsrc/Core/App.cpp index 4fe2bb0f5..c75a39df8 100644 --- a/uppsrc/Core/App.cpp +++ b/uppsrc/Core/App.cpp @@ -392,7 +392,7 @@ void AppExit__() } #if defined(PLATFORM_WIN32) && !defined(PLATFORM_WINCE) -static rawthread_t rawthread__ sShellExecuteOpen(void *str) +static auxthread_t auxthread__ sShellExecuteOpen(void *str) { ShellExecuteW(NULL, L"open", (wchar *)str, NULL, L".", SW_SHOWDEFAULT); free(str); @@ -406,7 +406,7 @@ void LaunchWebBrowser(const String& url) int l = sizeof(wchar) * wurl.GetLength() + 1; char *curl = (char *)malloc(l); memcpy(curl, wurl, l); - StartRawThread(sShellExecuteOpen, curl); + StartAuxThread(sShellExecuteOpen, curl); } } #endif diff --git a/uppsrc/Core/Inet.h b/uppsrc/Core/Inet.h index 3c8b6eecd..0ef2c5a8d 100644 --- a/uppsrc/Core/Inet.h +++ b/uppsrc/Core/Inet.h @@ -34,7 +34,7 @@ class IpAddrInfo { static void EnterPool(); static void LeavePool(); - static rawthread_t rawthread__ Thread(void *ptr); + static auxthread_t auxthread__ Thread(void *ptr); void Start(); diff --git a/uppsrc/Core/Mt.cpp b/uppsrc/Core/Mt.cpp index 17035867c..25cb10bcb 100644 --- a/uppsrc/Core/Mt.cpp +++ b/uppsrc/Core/Mt.cpp @@ -597,7 +597,7 @@ LazyUpdate::LazyUpdate() #endif -bool StartRawThread(rawthread_t (rawthread__ *fn)(void *ptr), void *ptr) +bool StartAuxThread(auxthread_t (auxthread__ *fn)(void *ptr), void *ptr) { #ifdef PLATFORM_WIN32 HANDLE handle; diff --git a/uppsrc/Core/Mt.h b/uppsrc/Core/Mt.h index b05b68e40..c35f16b6e 100644 --- a/uppsrc/Core/Mt.h +++ b/uppsrc/Core/Mt.h @@ -556,44 +556,44 @@ inline void AssertST() {} typedef Mutex CriticalSection; // deprecated typedef StaticMutex StaticCriticalSection; // deprecated -// Raw multirthreading intended for use even in single-threaded applications -// to resolve some host platform issues. Raw threads cannot use U++ heap +// Auxiliary multithreading intended for use even in single-threaded applications +// to resolve some host platform issues. Raw threads cannot use U++ heap (nor indirectly) #ifdef PLATFORM_WIN32 -#define rawthread_t DWORD -#define rawthread__ WINAPI +#define auxthread_t DWORD +#define auxthread__ WINAPI #else -#define rawthread_t void * -#define rawthread__ +#define auxthread_t void * +#define auxthread__ #endif #ifdef PLATFORM_WIN32 -struct RawMutex { +struct AuxMutex { CRITICAL_SECTION cs; void Enter() { EnterCriticalSection(&cs); } void Leave() { LeaveCriticalSection(&cs); } - RawMutex() { InitializeCriticalSection(&cs); } - ~RawMutex() { DeleteCriticalSection(&cs); } + AuxMutex() { InitializeCriticalSection(&cs); } + ~AuxMutex() { DeleteCriticalSection(&cs); } }; #endif #ifdef PLATFORM_POSIX -struct RawMutex { +struct AuxMutex { pthread_mutex_t mutex[1]; void Enter() { pthread_mutex_lock(mutex); } void Leave() { pthread_mutex_unlock(mutex); } - RawMutex() { + AuxMutex() { pthread_mutexattr_t mutex_attr[1]; pthread_mutexattr_init(mutex_attr); pthread_mutexattr_settype(mutex_attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(mutex, mutex_attr); } - ~RawMutex() { pthread_mutex_destroy(mutex); } + ~AuxMutex() { pthread_mutex_destroy(mutex); } }; #endif -bool StartRawThread(rawthread_t (rawthread__ *fn)(void *ptr), void *ptr); +bool StartAuxThread(auxthread_t (auxthread__ *fn)(void *ptr), void *ptr); diff --git a/uppsrc/Core/Socket.cpp b/uppsrc/Core/Socket.cpp index b7eaf1eb9..ea861de00 100644 --- a/uppsrc/Core/Socket.cpp +++ b/uppsrc/Core/Socket.cpp @@ -22,7 +22,7 @@ NAMESPACE_UPP IpAddrInfo::Entry IpAddrInfo::pool[COUNT]; -RawMutex IpAddrInfoPoolMutex; +AuxMutex IpAddrInfoPoolMutex; void IpAddrInfo::EnterPool() { @@ -45,7 +45,7 @@ int sGetAddrInfo(const char *host, const char *port, addrinfo **result) return getaddrinfo(host, port, &hints, result); } -rawthread_t rawthread__ IpAddrInfo::Thread(void *ptr) +auxthread_t auxthread__ IpAddrInfo::Thread(void *ptr) { Entry *entry = (Entry *)ptr; EnterPool(); @@ -104,7 +104,7 @@ void IpAddrInfo::Start() e->status = WORKING; e->host = host; e->port = port; - StartRawThread(&IpAddrInfo::Thread, e); + StartAuxThread(&IpAddrInfo::Thread, e); } break; } diff --git a/uppsrc/Core/src.tpp/Inet$en-us.tpp b/uppsrc/Core/src.tpp/Inet$en-us.tpp index 05401038d..1fb734a57 100644 --- a/uppsrc/Core/src.tpp/Inet$en-us.tpp +++ b/uppsrc/Core/src.tpp/Inet$en-us.tpp @@ -1,4 +1,4 @@ -topic ""; +topic "Internet format utility functions"; [2 $$0,0#00000000000000000000000000000000:Default] [i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] [l288;2 $$2,2#27521748481378242620020725143825:desc] @@ -9,56 +9,54 @@ topic ""; [l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] [i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] [b42;2 $$9,9#13035079074754324216151401829390:normal] -[{_}%EN-US -[s0;*@7;4 &] -[ {{10000@(113.42.0) [s0; [*@7;4 Internet utility functions]]}}&] -[s4;%- &] -[s5;:WwwFormat`(Time`):%- [_^String^ String]_[* WwwFormat]([_^Time^ Time]_[*@3 tm])&] -[s2; Returns Time in format commonly used in HTTP and other internet +[{_} +[ {{10000@(113.42.0) [s0;%% [*@7;4 Internet format utility functions]]}}&] +[s3; &] +[s5;:WwwFormat`(Time`): [_^String^ String]_[* WwwFormat]([_^Time^ Time]_[*@3 tm])&] +[s2;%% Returns Time in format commonly used in HTTP and other internet protocol, like `"Sun, 15 Apr 2012 16:00:25 GMT`".&] -[s3; &] -[s4;%- &] -[s5;:UrlEncode`(const String`&`):%- [_^String^ String]_[* UrlEncode]([@(0.0.255) const]_[_^String^ S +[s3;%% &] +[s4; &] +[s5;:UrlEncode`(const char`*`,const char`*`): [_^String^ String]_[* UrlEncode]([@(0.0.255) c +onst]_[@(0.0.255) char]_`*[*@3 s], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 end])&] +[s5;:UrlEncode`(const char`*`,int`): [_^String^ String]_[* UrlEncode]([@(0.0.255) const]_[@(0.0.255) c +har]_`*[*@3 s], [@(0.0.255) int]_[*@3 len])&] +[s5;:UrlEncode`(const String`&`): [_^String^ String]_[* UrlEncode]([@(0.0.255) const]_[_^String^ S tring][@(0.0.255) `&]_[*@3 s])&] -[s2; Encodes text to be passed as URL. ASCII alphanumeric characters -and characters `'.`', `'`-`', `'`_`' are used directly, space -is represented by `'`+`' and anything else as %HH, where HH is -two digit hexadecimal number.&] -[s3; &] -[s4;%- &] -[s5;:UrlEncode`(const String`&`,const char`*`):%- [_^String^ String]_[* UrlEncode]([@(0.0.255) c -onst]_[_^String^ String][@(0.0.255) `&]_[*@3 s], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 s -pecials])&] -[s2; [%-*@3 s] [%-*@3 specials] .&] -[s3; &] -[s4;%- &] -[s5;:UrlDecode`(const char`*`,const char`*`):%- [_^String^ String]_[* UrlDecode]([@(0.0.255) c -onst]_[@(0.0.255) char]_`*[*@3 b], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 e])&] -[s2; [%-*@3 b] [%-*@3 e] .&] -[s3; &] -[s4;%- &] -[s5;:UrlDecode`(const String`&`):%- [_^String^ String]_[* UrlDecode]([@(0.0.255) const]_[_^String^ S +[s2;%% Encodes data as required by [^http`:`/`/www`.w3`.org`/TR`/html401`/interact`/forms`.html`#h`-17`.13`.4`.1^ M +IME type application/x`-www`-form`-urlencoded]. ASCII alphanumeric +characters and characters `'.`', `'`-`', `'`_`' are passed directly, +space is represented by `'`+`' and anything else as %HH, where +HH is two digit hexadecimal number.&] +[s3;%% &] +[s4; &] +[s5;:UrlDecode`(const char`*`,const char`*`): [_^String^ String]_[* UrlDecode]([@(0.0.255) c +onst]_[@(0.0.255) char]_`*[*@3 s], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 end])&] +[s5;:UrlDecode`(const char`*`,int`): [_^String^ String]_[* UrlDecode]([@(0.0.255) const]_[@(0.0.255) c +har]_`*[*@3 s], [@(0.0.255) int]_[*@3 len])&] +[s5;:UrlDecode`(const String`&`): [_^String^ String]_[* UrlDecode]([@(0.0.255) const]_[_^String^ S tring][@(0.0.255) `&]_[*@3 s])&] -[s2; [%-*@3 s] .&] -[s3; &] -[s4;%- &] -[s5;:Base64Encode`(const char`*`,const char`*`):%- [_^String^ String]_[* Base64Encode]([@(0.0.255) c +[s2;%% Decodes data as required by [^http`:`/`/www`.w3`.org`/TR`/html401`/interact`/forms`.html`#h`-17`.13`.4`.1^ M +IME type application/x`-www`-form`-urlencoded] (see UrlEncode).&] +[s3;%% &] +[s4; &] +[s5;:Base64Encode`(const char`*`,const char`*`): [_^String^ String]_[* Base64Encode]([@(0.0.255) c onst]_[@(0.0.255) char]_`*[*@3 b], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 e])&] -[s2; [%-*@3 b] [%-*@3 e] .&] -[s3; &] -[s4;%- &] -[s5;:Base64Encode`(const String`&`):%- [_^String^ String]_[* Base64Encode]([@(0.0.255) cons -t]_[_^String^ String][@(0.0.255) `&]_[*@3 data])&] -[s2; [%-*@3 data] .&] -[s3; &] -[s4;%- &] -[s5;:Base64Decode`(const char`*`,const char`*`):%- [_^String^ String]_[* Base64Decode]([@(0.0.255) c +[s5;:Base64Encode`(const char`*`,int`): [_^String^ String]_[* Base64Encode]([@(0.0.255) con +st]_[@(0.0.255) char]_`*[*@3 s], [@(0.0.255) int]_[*@3 len])&] +[s5;:Base64Encode`(const String`&`): [_^String^ String]_[* Base64Encode]([@(0.0.255) const]_ +[_^String^ String][@(0.0.255) `&]_[*@3 data])&] +[s2;%% Encodes binary [%-*@3 data] into [^http`:`/`/en`.wikipedia`.org`/wiki`/Base64^ Bas +e64 format].&] +[s3;%% &] +[s4; &] +[s5;:Base64Decode`(const char`*`,const char`*`): [_^String^ String]_[* Base64Decode]([@(0.0.255) c onst]_[@(0.0.255) char]_`*[*@3 b], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 e])&] -[s2; [%-*@3 b] [%-*@3 e] .&] -[s3; &] -[s4;%- &] -[s5;:Base64Decode`(const String`&`):%- [_^String^ String]_[* Base64Decode]([@(0.0.255) cons -t]_[_^String^ String][@(0.0.255) `&]_[*@3 data])&] -[s2; [%-*@3 data] .&] -[s3; &] -[s0; ] \ No newline at end of file +[s5;:Base64Decode`(const char`*`,int`): [_^String^ String]_[* Base64Decode]([@(0.0.255) con +st]_[@(0.0.255) char]_`*[*@3 s], [@(0.0.255) int]_[*@3 len])&] +[s5;:Base64Decode`(const String`&`): [_^String^ String]_[* Base64Decode]([@(0.0.255) const]_ +[_^String^ String][@(0.0.255) `&]_[*@3 data])&] +[s2;%% Decodes binary [%-*@3 data] from [^http`:`/`/en`.wikipedia`.org`/wiki`/Base64^ Bas +e64 format]..&] +[s3;%% &] +[s0;%% ] \ No newline at end of file diff --git a/uppsrc/Core/src.tpp/IpAddrInfo$en-us.tpp b/uppsrc/Core/src.tpp/IpAddrInfo$en-us.tpp new file mode 100644 index 000000000..3e4b9f902 --- /dev/null +++ b/uppsrc/Core/src.tpp/IpAddrInfo$en-us.tpp @@ -0,0 +1,52 @@ +topic ""; +[2 $$0,0#00000000000000000000000000000000:Default] +[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] +[l288;2 $$2,2#27521748481378242620020725143825:desc] +[0 $$3,0#96390100711032703541132217272105:end] +[H6;0 $$4,0#05600065144404261032431302351956:begin] +[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:item] +[l288;a4;*@5;1 $$6,6#70004532496200323422659154056402:requirement] +[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] +[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] +[b42;2 $$9,9#13035079074754324216151401829390:normal] +[{_} +[ {{10000@(113.42.0) [s0;%% [*@7;4 Title]]}}&] +[s3; &] +[s1;:IpAddrInfo`:`:class: [@(0.0.255)3 class][3 _][*3 IpAddrInfo]&] +[s2;%% This class encapsulates [^http`:`/`/en`.wikipedia`.org`/wiki`/Getaddrinfo^ getad +drinfo] API, also providing optional non`-blocking behaviour +(using auxiliary threads). Note that there is currently no synchronization +available for this non`-blocking behaviour (it is not possible +to e.g. select on IpAddrInfo).&] +[s3; &] +[ {{10000F(128)G(128)@1 [s0;%% [* Public Method List]]}}&] +[s3; &] +[s5;:IpAddrInfo`:`:Start`(const String`&`,int`): [@(0.0.255) void]_[* Start]([@(0.0.255) co +nst]_[_^String^ String][@(0.0.255) `&]_[*@3 host], [@(0.0.255) int]_[*@3 port])&] +[s2;%% Starts resolving address of [%-*@3 host] (with [%-*@3 port]).&] +[s3;%% &] +[s4; &] +[s5;:IpAddrInfo`:`:InProgress`(`): [@(0.0.255) bool]_[* InProgress]()&] +[s2;%% Returns true if resolving of address is still in progress.&] +[s3; &] +[s4; &] +[s5;:IpAddrInfo`:`:Execute`(const String`&`,int`): [@(0.0.255) bool]_[* Execute]([@(0.0.255) c +onst]_[_^String^ String][@(0.0.255) `&]_[*@3 host], [@(0.0.255) int]_[*@3 port])&] +[s2;%% Resolves address [%-*@3 host] (with [%-*@3 port]). This is blocking +variant, returns after address is resolved. Returns true if address +was found.&] +[s3;%% &] +[s4; &] +[s5;:IpAddrInfo`:`:GetResult`(`): addrinfo_`*[* GetResult]()&] +[s2;%% Returns resulting [^http`:`/`/en`.wikipedia`.org`/wiki`/Getaddrinfo^ addrinfo] +if address resolving was finished and successfull, NULL otherwise.&] +[s3; &] +[s4; &] +[s5;:IpAddrInfo`:`:Clear`(`): [@(0.0.255) void]_[* Clear]()&] +[s2;%% Resets IpAddrInfo to initial state.&] +[s3; &] +[s4; &] +[s5;:IpAddrInfo`:`:IpAddrInfo`(`): [* IpAddrInfo]()&] +[s5;:IpAddrInfo`:`:`~IpAddrInfo`(`): [@(0.0.255) `~][* IpAddrInfo]()&] +[s2;%% Constructor, destructor.&] +[s3; ] \ No newline at end of file