mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-24 22:02:44 -06:00
Core: inet docs
git-svn-id: svn://ultimatepp.org/upp/trunk@4791 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
e5126df251
commit
02fd64956a
7 changed files with 119 additions and 69 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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; ]
|
||||
[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;%% ]
|
||||
52
uppsrc/Core/src.tpp/IpAddrInfo$en-us.tpp
Normal file
52
uppsrc/Core/src.tpp/IpAddrInfo$en-us.tpp
Normal file
|
|
@ -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; ]
|
||||
Loading…
Add table
Add a link
Reference in a new issue