A request of f == FNONE wants json on stdout. */
| 250 | |
| 251 | /* A request of f == FNONE wants json on stdout. */ |
| 252 | void print_rsync_version(enum logcode f) |
| 253 | { |
| 254 | char copyright[] = "(C) 1996-" LATEST_YEAR " by Andrew Tridgell, Wayne Davison, and others."; |
| 255 | char url[] = "https://rsync.samba.org/"; |
| 256 | BOOL first_line = 1; |
| 257 | |
| 258 | #define json_line(name, value) \ |
| 259 | do { \ |
| 260 | printf("%c\n \"%s\": \"%s\"", first_line ? '{' : ',', name, value); \ |
| 261 | first_line = 0; \ |
| 262 | } while (0) |
| 263 | |
| 264 | if (f == FNONE) { |
| 265 | char verbuf[32]; |
| 266 | json_line("program", RSYNC_NAME); |
| 267 | json_line("version", rsync_version()); |
| 268 | (void)snprintf(verbuf, sizeof verbuf, "%d.%d", PROTOCOL_VERSION, SUBPROTOCOL_VERSION); |
| 269 | json_line("protocol", verbuf); |
| 270 | json_line("copyright", copyright); |
| 271 | json_line("url", url); |
| 272 | } else { |
| 273 | #if SUBPROTOCOL_VERSION != 0 |
| 274 | char *subprotocol = istring(".PR%d", SUBPROTOCOL_VERSION); |
| 275 | #else |
| 276 | char *subprotocol = ""; |
| 277 | #endif |
| 278 | rprintf(f, "%s version %s protocol version %d%s\n", |
| 279 | RSYNC_NAME, rsync_version(), PROTOCOL_VERSION, subprotocol); |
| 280 | rprintf(f, "Copyright %s\n", copyright); |
| 281 | rprintf(f, "Web site: %s\n", url); |
| 282 | } |
| 283 | |
| 284 | print_info_flags(f); |
| 285 | |
| 286 | init_checksum_choices(); |
| 287 | |
| 288 | output_nno_list(f, "Checksum list", &valid_checksums); |
| 289 | output_nno_list(f, "Compress list", &valid_compressions); |
| 290 | output_nno_list(f, "Daemon auth list", &valid_auth_checksums); |
| 291 | |
| 292 | if (f == FNONE) { |
| 293 | json_line("license", "GPLv3"); |
| 294 | json_line("caveat", "rsync comes with ABSOLUTELY NO WARRANTY"); |
| 295 | printf("\n}\n"); |
| 296 | fflush(stdout); |
| 297 | return; |
| 298 | } |
| 299 | |
| 300 | #ifdef MAINTAINER_MODE |
| 301 | rprintf(f, "Panic Action: \"%s\"\n", get_panic_action()); |
| 302 | #endif |
| 303 | |
| 304 | #if SIZEOF_INT64 < 8 |
| 305 | rprintf(f, "WARNING: no 64-bit integers on this platform!\n"); |
| 306 | #endif |
| 307 | if (sizeof (int64) != SIZEOF_INT64) { |
| 308 | rprintf(f, |
| 309 | "WARNING: size mismatch in SIZEOF_INT64 define (%d != %d)\n", |
no test coverage detected