| 1206 | } |
| 1207 | |
| 1208 | void API_ROUTINE gds__trace(const TEXT* text) |
| 1209 | { |
| 1210 | /************************************** |
| 1211 | * |
| 1212 | * g d s _ t r a c e |
| 1213 | * |
| 1214 | ************************************** |
| 1215 | * |
| 1216 | * Functional description |
| 1217 | * Post trace event to a log file. Function records date and time |
| 1218 | * This function tries to be async-signal safe |
| 1219 | * |
| 1220 | **************************************/ |
| 1221 | const time_t now = time(NULL); // is specified in POSIX to be signal-safe |
| 1222 | |
| 1223 | // 07 Sept 2003, Nickolay Samofatov. |
| 1224 | // Since we cannot call ctime/localtime_r or anything else like this from |
| 1225 | // signal hanlders we need to decode time by hand. |
| 1226 | |
| 1227 | const int days = static_cast<int>(now / SECS_PER_DAY); |
| 1228 | int rem = static_cast<int>(now % SECS_PER_DAY); |
| 1229 | |
| 1230 | tm today; |
| 1231 | TimeStamp::decode_date(days + TimeStamp::GDS_EPOCH_START, &today); |
| 1232 | today.tm_hour = rem / SECS_PER_HOUR; |
| 1233 | rem %= SECS_PER_HOUR; |
| 1234 | today.tm_min = rem / 60; |
| 1235 | today.tm_sec = rem % 60; |
| 1236 | |
| 1237 | char buffer[BUFFER_MEDIUM]; |
| 1238 | char* p = buffer; |
| 1239 | |
| 1240 | gds__ulstr(p, today.tm_year + 1900, 4, '0'); |
| 1241 | p += 4; |
| 1242 | *p++ = '-'; |
| 1243 | gds__ulstr(p, today.tm_mon, 2, '0'); |
| 1244 | p += 2; |
| 1245 | *p++ = '-'; |
| 1246 | gds__ulstr(p, today.tm_mday, 2, '0'); |
| 1247 | p += 2; |
| 1248 | *p++ = 'T'; |
| 1249 | gds__ulstr(p, today.tm_hour, 2, '0'); |
| 1250 | p += 2; |
| 1251 | *p++ = ':'; |
| 1252 | gds__ulstr(p, today.tm_min, 2, '0'); |
| 1253 | p += 2; |
| 1254 | *p++ = ':'; |
| 1255 | gds__ulstr(p, today.tm_sec, 2, '0'); |
| 1256 | p += 2; |
| 1257 | *p++ = ' '; |
| 1258 | ULONG apid = |
| 1259 | #ifdef WIN_NT |
| 1260 | GetCurrentProcessId(); |
| 1261 | #else |
| 1262 | getpid(); |
| 1263 | #endif |
| 1264 | gds__ulstr(p, apid, 5, ' '); |
| 1265 | p += 5; |
nothing calls this directly
no test coverage detected