static int dcc_send_compiler_version(int out_fd, char *compiler) { char *info = dcc_get_compiler_version(compiler); if (!info) info = ""; return dcc_x_token_string(out_fd, "CVER", info); }
static int dcc_send_system_info(int out_fd) { char *info = dcc_get_system_version(); if (!info) info = ""; return dcc_x_token_string(out_fd, "SINF", info); }
/** * Transmit the current working directory */ int dcc_x_cwd(int fd) { int ret; char cwd[MAXPATHLEN + 1]; char * cwd_ret; cwd_ret = getcwd(cwd, MAXPATHLEN); if (cwd_ret == NULL) { return 0; } ret = dcc_x_token_string(fd, "CDIR", cwd); return ret; }
/** * Transmit an argv array. **/ int dcc_x_argv(int fd, char **argv) { int i; int ret; int argc; argc = dcc_argv_len(argv); if (dcc_x_token_int(fd, "ARGC", (unsigned) argc)) return EXIT_PROTOCOL_ERROR; for (i = 0; i < argc; i++) { if ((ret = dcc_x_token_string(fd, "ARGV", argv[i]))) return ret; } return 0; }
/** * Send down the host info. This includes the OS version, hardware info, and compiler versions. */ int dcc_send_host_info(int out_fd) { int ret; char *sysKey = "SYSTEM="; char *compilerKey = "COMPILER="; char *ncpusKey = "CPUS="; char *cpuSpeedKey = "CPUSPEED="; char *maxJobsKey = "JOBS="; char *priorityKey = "PRIORITY="; char *distcc = "DISTCC=" PACKAGE_VERSION "\n"; char *sysInfo = dcc_get_system_version(); char **compilers = dcc_get_all_compiler_versions(); int ncpus; unsigned long long cpuSpeed; if (dcc_ncpus(&ncpus)) ncpus = 0; if (dcc_cpuspeed(&cpuSpeed)) cpuSpeed = 0; int i, len = 0; char *msg; if (sysInfo) { len += strlen(sysInfo) + strlen(sysKey) + 1; } if (distcc) len += strlen(distcc); if (compilers) { for (i=0; compilers && compilers[i] != NULL; i++) { len += strlen(compilers[i]) + strlen(compilerKey) + 1; } } if (ncpus > 0) { len += strlen(ncpusKey) + 8; // 7 digits for cpu count should be plenty } if (cpuSpeed > 0) { len += strlen(cpuSpeedKey) + 32; // 31 digits for cpu speed } if (dcc_max_kids > 0) { len += strlen(maxJobsKey) + 8; // 7 digits for job count should be plenty } if (build_machine_priority > 0) { len += strlen(maxJobsKey) + 32; // 31 digits for priority } msg = malloc(len+1); msg[0] = 0; if (sysInfo) { strcat(msg, sysKey); strcat(msg, sysInfo); strcat(msg, "\n"); } if (distcc) strcat(msg, distcc); if (compilers) { for (i=0; compilers && compilers[i]!=NULL; i++) { strcat(msg, compilerKey); strcat(msg, compilers[i]); strcat(msg, "\n"); } free(compilers); } if (ncpus > 0) { strcat(msg, ncpusKey); sprintf(&msg[strlen(msg)], "%d\n", ncpus); } if (cpuSpeed > 0) { strcat(msg, cpuSpeedKey); sprintf(&msg[strlen(msg)], "%llu\n", cpuSpeed); } if (dcc_max_kids > 0) { strcat(msg, maxJobsKey); sprintf(&msg[strlen(msg)], "%d\n", dcc_max_kids); } if (build_machine_priority > 0) { strcat(msg, priorityKey); sprintf(&msg[strlen(msg)], "%d\n", build_machine_priority); } // a bit of a hack - if we are writing to stdout then just print the string if (out_fd == 1) ret = write(out_fd, msg, len)==len; else ret = dcc_x_token_string(out_fd, "HINF", msg); free(msg); return ret; }
/* TODO: This code is highly specific to DCC_VER_3; it assumes lzo compression is on, and that the include server has actually compressed the files. */ int dcc_x_many_files(int ofd, unsigned int n_files, char **fnames) { int ret = 0; char link_points_to[MAXPATHLEN + 1]; int is_link; const char *fname; char *original_fname = NULL; #ifdef XCODE_INTEGRATION /* NOTE: If this function is ever used for something besides pump * mode support for sending things to be compiled, then it should * take another argument to include/exclude this fixup. */ char *xci_original_fname, *xci_link_points_to; #endif dcc_x_token_int(ofd, "NFIL", n_files); for (; *fnames != NULL; ++fnames) { fname = *fnames; ret = dcc_get_original_fname(fname, &original_fname); if (ret) return ret; if ((ret = dcc_is_link(fname, &is_link))) { return ret; } #ifdef XCODE_INTEGRATION xci_original_fname = dcc_xci_mask_developer_dir(original_fname); if (xci_original_fname) { free(original_fname); original_fname = xci_original_fname; xci_original_fname = NULL; } else { ret = EXIT_OUT_OF_MEMORY; return ret; } #endif if (is_link) { if ((ret = dcc_read_link(fname, link_points_to))) { return ret; } #ifdef XCODE_INTEGRATION xci_link_points_to = dcc_xci_mask_developer_dir(link_points_to); if (xci_link_points_to) { strlcpy(link_points_to, xci_link_points_to, sizeof(link_points_to)); free(xci_link_points_to); xci_link_points_to = NULL; } else { ret = EXIT_OUT_OF_MEMORY; return ret; } #endif if ((ret = dcc_x_token_string(ofd, "NAME", original_fname)) || (ret = dcc_x_token_string(ofd, "LINK", link_points_to))) { return ret; } } else { ret = dcc_x_token_string(ofd, "NAME", original_fname); if (ret) return ret; /* File should be compressed already. If we ever support non-compressed server-side-cpp, we should have some checks here and then uncompress the file if it is compressed. */ ret = dcc_x_file(ofd, fname, "FILE", DCC_COMPRESS_NONE, NULL); if (ret) return ret; } } return 0; }