static void check_help_file (void) { const char *hpath = helpfile_path(GRETL_HELPFILE); FILE *fp = fopen(hpath, "r"); if (fp != NULL) { printf(_("\n\"help\" gives a list of commands\n")); fclose(fp); } else { printf(_("help file %s is not accessible\n"), hpath); show_paths(); } }
void afp_options_parse_cmdline(AFPObj *obj, int ac, char **av) { int c, err = 0; while (EOF != ( c = getopt( ac, av, "dF:vVh" )) ) { switch ( c ) { case 'd': obj->cmdlineflags |= OPTION_DEBUG; break; case 'F': obj->cmdlineconfigfile = strdup(optarg); break; case 'v': /* version */ show_version( ); puts( "" ); show_paths( ); puts( "" ); exit( 0 ); break; case 'V': /* extended version */ show_version_extended( ); puts( "" ); show_paths( ); puts( "" ); exit( 0 ); break; case 'h': /* usage */ show_usage(); exit( 0 ); break; default : err++; } } if ( err || optind != ac ) { show_usage(); exit( 2 ); } return; }
static void handle_datafile (char *filearg, char *runfile, DATASET *dset, PRN *prn, PRN *cmdprn) { char given_file[MAXLEN]; int load_datafile = 1; int ftype, err = 0; strcpy(given_file, filearg); strcpy(datafile, filearg); ftype = detect_filetype(datafile, OPT_P); switch (ftype) { case GRETL_UNRECOGNIZED: case GRETL_NATIVE_DB: case GRETL_RATS_DB: exit(EXIT_FAILURE); break; case GRETL_XML_DATA: case GRETL_BINARY_DATA: err = gretl_read_gdt(datafile, dset, OPT_NONE, prn); break; case GRETL_CSV: err = import_csv(datafile, dset, OPT_NONE, prn); break; case GRETL_XLS: case GRETL_GNUMERIC: case GRETL_ODS: err = import_spreadsheet(datafile, ftype, NULL, NULL, dset, OPT_NONE, prn); break; case GRETL_DTA: case GRETL_SAV: case GRETL_SAS: case GRETL_JMULTI: case GRETL_OCTAVE: case GRETL_WF1: err = import_other(datafile, ftype, dset, OPT_NONE, prn); break; case GRETL_SCRIPT: runit = 1; strcpy(runfile, datafile); memset(datafile, 0, sizeof datafile); load_datafile = 0; break; default: break; } if (load_datafile) { if (err) { errmsg(err, prn); if (err == E_FOPEN) { show_paths(); } exit(EXIT_FAILURE); } data_status = 1; if (!batch) { pprintf(cmdprn, "open %s\n", given_file); } } }
int afp_options_parse(int ac, char **av, struct afp_options *options) { extern char *optarg; extern int optind; char *p; char *tmp; /* Used for error checking the result of strtol */ int c, err = 0; if (gethostname(options->hostname, sizeof(options->hostname )) < 0 ) { perror( "gethostname" ); return 0; } if (NULL != ( p = strchr(options->hostname, '.' )) ) { *p = '\0'; } if (NULL == ( p = strrchr( av[ 0 ], '/' )) ) { p = av[ 0 ]; } else { p++; } while (EOF != ( c = getopt( ac, av, OPTIONS )) ) { switch ( c ) { case 'd' : options->flags |= OPTION_DEBUG; break; case 'n' : options->server = optarg; break; case 'f' : options->defaultvol.name = optarg; break; case 's' : options->systemvol.name = optarg; break; case 'u' : options->flags |= OPTION_USERVOLFIRST; break; case 'c' : options->connections = atoi( optarg ); break; case 'g' : options->guest = optarg; break; case 'P' : options->pidfile = optarg; break; case 'p': options->passwdbits |= PASSWD_NOSAVE; break; case 't': options->passwdbits |= PASSWD_SET; break; case 'D': options->transports &= ~AFPTRANS_DDP; break; case 'S': options->port = optarg; break; case 'T': options->transports &= ~AFPTRANS_TCP; break; case 'L': options->loginmesg = optarg; break; case 'F': options->configfile = optarg; break; case 'U': options->uamlist = optarg; break; case 'v': /* version */ show_version( ); puts( "" ); show_paths( ); puts( "" ); exit( 0 ); break; case 'V': /* extended version */ show_version_extended( ); puts( "" ); show_paths( ); puts( "" ); exit( 0 ); break; case 'h': /* usage */ show_usage( p ); exit( 0 ); break; case 'I': options->flags |= OPTION_CUSTOMICON; break; case 'm': options->umask = strtoul(optarg, &tmp, 8); if ((options->umask > 0777)) { fprintf(stderr, "%s: out of range umask setting provided\n", p); err++; } if (tmp[0] != '\0') { fprintf(stderr, "%s: invalid characters in umask setting provided\n", p); err++; } break; default : err++; } } if ( err || optind != ac ) { show_usage( p ); exit( 2 ); } #ifdef ultrix openlog( p, LOG_PID ); /* ultrix only */ #else set_processname(p); #endif /* ultrix */ return 1; }