Mercurial > hg > nnchat
comparison nnchat.c @ 90:1e0bf7b4fd41
Move socket error handling functions to libnnchat.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 06 May 2009 23:55:21 +0300 |
parents | c2d916b340bf |
children | acfc4b4bc180 |
comparison
equal
deleted
inserted
replaced
89:c2d916b340bf | 90:1e0bf7b4fd41 |
---|---|
6 #include "libnnchat.h" | 6 #include "libnnchat.h" |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include "th_args.h" | 8 #include "th_args.h" |
9 #include <string.h> | 9 #include <string.h> |
10 #include <errno.h> | 10 #include <errno.h> |
11 #include <time.h> | |
12 #ifdef __WIN32 | 11 #ifdef __WIN32 |
13 #define usleep(t) Sleep((t) / 1000) | 12 #define usleep(t) Sleep((t) / 1000) |
14 /* Undefine because both windows.h and curses.h #define it */ | 13 /* Undefine because both windows.h and curses.h #define it */ |
15 #undef MOUSE_MOVED | 14 #undef MOUSE_MOVED |
16 #endif | 15 #endif |
148 } | 147 } |
149 | 148 |
150 return TRUE; | 149 return TRUE; |
151 } | 150 } |
152 | 151 |
153 #ifdef __WIN32 | |
154 const char *hstrerror(int err) | |
155 { | |
156 static char buf[64]; | |
157 snprintf(buf, sizeof(buf), "Error #%d", err); | |
158 return buf; | |
159 } | |
160 | |
161 int getSocketErrno(void) | |
162 { | |
163 return WSAGetLastError(); | |
164 } | |
165 | |
166 const char *getSocketErrStr(int err) | |
167 { | |
168 static char buf[64]; | |
169 snprintf(buf, sizeof(buf), "Error #%d", err); | |
170 return buf; | |
171 } | |
172 #else | |
173 int getSocketErrno(void) | |
174 { | |
175 return errno; | |
176 } | |
177 | |
178 const char *getSocketErrStr(int err) | |
179 { | |
180 return strerror(err); | |
181 } | |
182 #endif | |
183 | 152 |
184 void updateStatus(BOOL insertMode) | 153 void updateStatus(BOOL insertMode) |
185 { | 154 { |
186 char tmpStr[128] = ""; | 155 char tmpStr[128] = ""; |
187 time_t timeStamp; | 156 time_t timeStamp; |