this is the underlying (unformatted) rsync debugging function. Call * it with FINFO, FERROR_*, FWARNING, FLOG, or FCLIENT. Note: recursion * can happen with certain fatal conditions. */
| 249 | * it with FINFO, FERROR_*, FWARNING, FLOG, or FCLIENT. Note: recursion |
| 250 | * can happen with certain fatal conditions. */ |
| 251 | void rwrite(enum logcode code, const char *buf, int len, int is_utf8) |
| 252 | { |
| 253 | char trailing_CR_or_NL; |
| 254 | FILE *f = msgs2stderr == 1 ? stderr : stdout; |
| 255 | #ifdef ICONV_OPTION |
| 256 | iconv_t ic = is_utf8 && ic_recv != (iconv_t)-1 ? ic_recv : ic_chck; |
| 257 | #else |
| 258 | #ifdef ICONV_CONST |
| 259 | iconv_t ic = ic_chck; |
| 260 | #endif |
| 261 | #endif |
| 262 | |
| 263 | if (len < 0) |
| 264 | exit_cleanup(RERR_MESSAGEIO); |
| 265 | |
| 266 | if (msgs2stderr == 1) { |
| 267 | /* A normal daemon can get msgs2stderr set if the socket is busted, so we |
| 268 | * change the message destination into an FLOG message in order to try to |
| 269 | * get some info about an abnormal-exit into the log file. An rsh daemon |
| 270 | * can have this set via user request, so we'll leave the code alone so |
| 271 | * that the msg gets logged and then sent to stderr after that. */ |
| 272 | if (am_daemon > 0 && code != FCLIENT) |
| 273 | code = FLOG; |
| 274 | } else if (send_msgs_to_gen) { |
| 275 | assert(!is_utf8); |
| 276 | /* Pass the message to our sibling in native charset. */ |
| 277 | send_msg((enum msgcode)code, buf, len, 0); |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | if (code == FERROR_SOCKET) /* This gets simplified for a non-sibling. */ |
| 282 | code = FERROR; |
| 283 | else if (code == FERROR_UTF8) { |
| 284 | is_utf8 = 1; |
| 285 | code = FERROR; |
| 286 | } |
| 287 | |
| 288 | if (code == FCLIENT) |
| 289 | code = FINFO; |
| 290 | else if (am_daemon || logfile_name) { |
| 291 | static int in_block; |
| 292 | char msg[2048]; |
| 293 | int priority = code == FINFO || code == FLOG ? LOG_INFO : LOG_WARNING; |
| 294 | |
| 295 | if (in_block) |
| 296 | return; |
| 297 | in_block = 1; |
| 298 | if (!log_initialised) |
| 299 | log_init(0); |
| 300 | strlcpy(msg, buf, MIN((int)sizeof msg, len + 1)); |
| 301 | logit(priority, msg); |
| 302 | in_block = 0; |
| 303 | |
| 304 | if (code == FLOG || (am_daemon && !am_server)) |
| 305 | return; |
| 306 | } else if (code == FLOG) |
| 307 | return; |
| 308 |
no test coverage detected