Commit fe1cb3bbdb47567aecd87d1a9c23a303e09ec689
1 parent
73cd92cf
add possibility to just open a socket without bind or listen or connect
Showing
3 changed files
with
14 additions
and
4 deletions
@@ -16,5 +16,12 @@ coverage-html: | @@ -16,5 +16,12 @@ coverage-html: | ||
16 | -$(MAKE) -C tests $(AM_MAKEFLAGS) -k $@ | 16 | -$(MAKE) -C tests $(AM_MAKEFLAGS) -k $@ |
17 | endif | 17 | endif |
18 | 18 | ||
19 | +REGEX_CCLASS=/^[ \t]*\(TR_CLASS\|TR_INTERFACE\)\(([a-zA-Z0-9_]+)/\2/d,definition/ | ||
19 | tags: | 20 | tags: |
20 | - ctags -R -V --langdef=cclass --langmap=cclass:.h --regex-cclass='/^[ \t]*\(TR_CLASS\|TR_INTERFACE\)\(([a-zA-Z0-9_]+)/\2/d,definition/' | 21 | + @ctags -R -V --langdef=cclass --langmap=cclass:.h \ |
22 | + --regex-cclass='$(REGEX_CCLASS)' | ||
23 | + | ||
24 | +loc: | ||
25 | + @find src/ include/ -not -path testers -and -name "*.[ch]" \ | ||
26 | + -exec sed '/\/\*/,/\*\//d;/\/\//d' {} \; | wc -l | ||
27 | + |
@@ -139,14 +139,17 @@ TR_SocketFin TR_socketShutdown(TR_Socket); | @@ -139,14 +139,17 @@ TR_SocketFin TR_socketShutdown(TR_Socket); | ||
139 | void TR_socketClose(TR_Socket); | 139 | void TR_socketClose(TR_Socket); |
140 | void TR_socketNonblock(TR_Socket); | 140 | void TR_socketNonblock(TR_Socket); |
141 | 141 | ||
142 | -#define TR_socketBind(socket) \ | 142 | +#define TR_socketBind(socket) \ |
143 | (TR_socketInit((socket), TR_socketBindAction)) | 143 | (TR_socketInit((socket), TR_socketBindAction)) |
144 | 144 | ||
145 | TR_TcpSocket TR_socketAccept(TR_TcpSocket); | 145 | TR_TcpSocket TR_socketAccept(TR_TcpSocket); |
146 | 146 | ||
147 | -#define TR_socketConnect(socket) \ | 147 | +#define TR_socketConnect(socket) \ |
148 | (TR_socketInit((socket), TR_socketConnectAction)) | 148 | (TR_socketInit((socket), TR_socketConnectAction)) |
149 | 149 | ||
150 | +#define TR_socketOpen(socket) \ | ||
151 | + (TR_socketInit((socket), NULL)) | ||
152 | + | ||
150 | #endif // __TR_SOCKET_H__ | 153 | #endif // __TR_SOCKET_H__ |
151 | 154 | ||
152 | // vim: set ts=4 sw=4: | 155 | // vim: set ts=4 sw=4: |
@@ -80,7 +80,7 @@ TR_socketInit(TR_Socket this, TR_socketAction_fptr action) | @@ -80,7 +80,7 @@ TR_socketInit(TR_Socket this, TR_socketAction_fptr action) | ||
80 | this->addrlen = current_info->ai_addrlen; | 80 | this->addrlen = current_info->ai_addrlen; |
81 | memcpy(&(this->addr), current_info->ai_addr, this->addrlen); | 81 | memcpy(&(this->addr), current_info->ai_addr, this->addrlen); |
82 | 82 | ||
83 | - if (0 == action(this)) { | 83 | + if (! action || 0 == action(this)) { |
84 | break; // success / open and bind or open and connect... | 84 | break; // success / open and bind or open and connect... |
85 | } | 85 | } |
86 | 86 |
Please
register
or
login
to post a comment