static void download_staff_file_complete(char *url, char *file, char *errorbuf, int cached, void *dummy) { Download.in_progress = 0; Download.once_completed = 1; if (!cached) { if (!file) { config_error("Error downloading %s: %s", url, errorbuf); return; } remove_staff_file(); Download.path = strdup(file); read_motd(Download.path, &staff); } else { char *urlfile = url_getfilename(url); char *file = unreal_getfilename(urlfile); char *tmp = unreal_mktemp("tmp", file); /* TODO: handle null returns ? */ unreal_copyfile(Download.path, tmp); remove_staff_file(); Download.path = strdup(tmp); MyFree(urlfile); } }
static int download_staff_file(ConfigEntry *ce) { int ret = 0; struct stat sb; char *file, *filename; if (Download.in_progress) return 0; Download.is_url = 1; ircstrdup(Download.url, ce->ce_vardata); file = url_getfilename(ce->ce_vardata); filename = unreal_getfilename(file); /* TODO: handle NULL returns */ ircstrdup(Download.file, filename); MyFree(file); if (!loop.ircd_rehashing && !Download.once_completed) { char *error; if (config_verbose > 0) config_status("Downloading %s", Download.url); if (!(file = download_file(ce->ce_vardata, &error))) { config_error("%s:%i: test: error downloading '%s': %s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_vardata, error); return -1; } Download.once_completed = 1; ircstrdup(Download.path, file); read_motd(Download.path, &staff); MyFree(file); return 0; } file = Download.path ? Download.path : Download.file; if ((ret = stat(file, &sb)) && errno != ENOENT) { /* I know, stat shouldn't fail... */ config_error("%s:%i: could not get the creation time of %s: stat() returned %d: %s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, Download.file, ret, strerror(errno)); return -1; } if (config_verbose > 0) config_status("Downloading %s", Download.url); Download.in_progress = 1; download_file_async(Download.url, sb.st_ctime, download_staff_file_complete, NULL); return 0; }
char *generate_crash_report(char *coredump) { static char reportfname[512]; FILE *reportfd; if (coredump == NULL) coredump = find_best_coredump(); if (coredump == NULL) return NULL; /* nothing available */ if (corefile_vs_binary_mismatch(coredump)) return NULL; snprintf(reportfname, sizeof(reportfname), "%s/crash.report.%s.%ld.txt", TMPDIR, unreal_getfilename(coredump), (long)time(NULL)); reportfd = fopen(reportfname, "w"); if (!reportfd) { printf("ERROR: could not open '%s' for writing\n", reportfname); return NULL; } crash_report_header(reportfd, coredump); crash_report_fix_libs(coredump); if (!crash_report_backtrace(reportfd, coredump)) { printf("ERROR: Could not produce a backtrace. " "Possibly your system is missing the 'gdb' package or something else is wrong.\n"); fclose(reportfd); return NULL; } fclose(reportfd); return reportfname; }