static void maybe_save_session_output (const char *cmdfile) { char outfile[FILENAME_MAX]; printf(_("type a filename to store output (enter to quit): ")); *outfile = '\0'; if (fgets(outfile, sizeof outfile, stdin) != NULL) { top_n_tail(outfile, 0, NULL); } if (*outfile != '\0' && *outfile != '\n' && *outfile != '\r' && strcmp(outfile, "q")) { const char *udir = gretl_workdir(); char *syscmd; printf(_("writing session output to %s%s\n"), udir, outfile); #ifdef WIN32 syscmd = gretl_strdup_printf("\"%sgretlcli\" -b \"%s\" > \"%s%s\"", gretl_home(), cmdfile, udir, outfile); system(syscmd); #else syscmd = gretl_strdup_printf("gretlcli -b \"%s\" > \"%s%s\"", cmdfile, udir, outfile); gretl_spawn(syscmd); #endif printf("%s\n", syscmd); free(syscmd); } }
void do_nistcheck (GtkAction *action) { void *handle; int (*run_nist_tests)(const char *, const char *, int); gchar *datadir = NULL; gchar *fname = NULL; run_nist_tests = gui_get_plugin_function("run_nist_tests", &handle); if (run_nist_tests == NULL) { return; } datadir = g_strdup_printf("%sdata%s", gretl_home(), SLASHSTR); fname = g_strdup_printf("%snist.out", gretl_dotdir()); (*run_nist_tests)(datadir, fname, nist_verbosity(action)); close_plugin(handle); view_file(fname, 0, 1, 78, 400, VIEW_CODEBOOK); g_free(datadir); g_free(fname); }
static void nls_init (void) { #ifdef ENABLE_NLS # ifdef WIN32 char LOCALEDIR[MAXLEN]; build_path(LOCALEDIR, gretl_home(), "locale", NULL); # endif /* WIN32 */ setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); iso_gettext("@CLI_INIT"); gretl_setenv("LC_NUMERIC", ""); setlocale(LC_NUMERIC, ""); reset_local_decpoint(); # ifdef WIN32 cli_set_win32_charset(PACKAGE); # endif #endif /* ENABLE_NLS */ }
static int curl_get (urlinfo *u) { CURL *curl; CURLcode res; int err = 0; err = gretl_curl_toggle(1); if (err) { return err; } curl = curl_easy_init(); if (curl == NULL) { gretl_errmsg_set("curl_easy_init failed"); err = 1; } else { if (u->verbose) { fprintf(stderr, "curl_get: %s\n", u->url); } curl_easy_setopt(curl, CURLOPT_URL, u->url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, gretl_write_func); curl_easy_setopt(curl, CURLOPT_WRITEDATA, u); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(curl, CURLOPT_USERAGENT, u->agent); curl_easy_setopt(curl, CURLOPT_VERBOSE, u->verbose); if (u->timeout > 0) { curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long) u->timeout); } if (wproxy && *proxyhost != '\0') { set_curl_proxy(u, curl); } #if SSLWIN if (!strncmp(u->url, "https", 5)) { char cpath[MAXLEN]; sprintf(cpath, "%scurl-ca-bundle.crt", gretl_home()); curl_easy_setopt(curl, CURLOPT_CAINFO, cpath); } #endif if (u->progfunc != NULL) { curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_func); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, u); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); } else { curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); } res = curl_easy_perform(curl); if (u->progfunc != NULL) { stop_progress_bar(u); } if (res != CURLE_OK) { gretl_errmsg_sprintf("cURL error %d (%s)", res, curl_easy_strerror(res)); err = u->err ? u->err : 1; } curl_easy_cleanup(curl); } return err; }