Пример #1
0
//
// Routines
//
int
main(int argc, char **argv)
{
#if defined(__linux__) || defined(__unix__)
    int name_index;
#else
    SIOUXSettings.rows = 100;
    printf("This app uses the SIOUX console library\n");
    printf("Choose 'Quit' from the file menu to quit.\n\n");
    printf("Use fake disk names (/dev/scsi<bus>.<id>; i.e. /dev/scsi0.1, /dev/scsi1.3, etc.).\n\n");
 
    SIOUXSettings.autocloseonquit = 0;	/* Do we close the SIOUX window on program termination ... */
    SIOUXSettings.asktosaveonclose = 0;	/* Do we offer to save on a close ... */
#endif

    init_program_name(argv);

    if (sizeof(DPME) != PBLOCK_SIZE) {
	fatal(-1, "Size of partition map entry (%d) "
		"is not equal to block size (%d)\n",
		sizeof(DPME), PBLOCK_SIZE);
    }
    if (sizeof(Block0) != PBLOCK_SIZE) {
	fatal(-1, "Size of block zero structure (%d) "
		"is not equal to block size (%d)\n",
		sizeof(Block0), PBLOCK_SIZE);
    }
    if (strcmp(VERSION, get_version_string()) != 0) {
	fatal(-1, "Version string static form (%s) does not match dynamic form (%s)\n",
		VERSION, get_version_string());
    }

#if defined(__linux__) || defined(__unix__)
    name_index = get_options(argc, argv);

    if (vflag) {
	printf("version " VERSION " (" RELEASE_DATE ")\n");
    }
    if (hflag) {
 	do_help();
    } else if (interactive) {
	interact();
    } else if (lflag) {
	if (lfile != NULL) {
	    dump(lfile);
	} else if (name_index < argc) {
	    while (name_index < argc) {
		dump(argv[name_index++]);
	    }
	} else {
#ifdef __linux__
	    list_all_disks();
#else
	    usage("no device argument");
	    do_help();
#endif
	}
    } else if (name_index < argc) {
	while (name_index < argc) {
	    edit(argv[name_index++], 0);
	}
    } else if (!vflag) {
	usage("no device argument");
 	do_help();
    }
    return 0;
#else
    interactive = 1;

    interact();

    SIOUXSettings.autocloseonquit = 1;
    //printf("Processing stopped: Choose 'Quit' from the file menu to quit.\n\n");
    exit(0);
#endif
}
Пример #2
0
/*
 * Start here ...
 */
int
main(int argc, char **argv)
{
    register int i;
#ifdef notdef
    register int c;
    extern char *optarg;	/* pointer to argument */
    extern int optind;		/* next argv index */
    extern int opterr;		/* who does error messages */
    extern int optopt;		/* char that caused the error */
    int getopt_error;		/* getopt choked */
    char option_error[100];	/* buffer for error message */
    char *arg_option = 0;
    int bool_option = 0;
#else
    int optind = 1;
#endif

    init_program_name(argv);

#ifdef notdef
    opterr = 0;	/* tell getopt to be quiet */

    /*
     * Changes to getopt's last argument should
     * be reflected in the string printed by the
     * usage() function.
     */
    while ((c = getopt(argc, argv, "a:b")) != EOF) {
	if (c == '?') {
	    getopt_error = 1;
	    c = optopt;
	} else {
	    getopt_error = 0;
	}

	switch (c) {
	case 'a':
	    if (getopt_error) {
		usage("missing argument");
	    } else {
		arg_option = optarg;
	    }
	    break;
	case 'b':
	    bool_option = 1;
	    break;
	default:
	    sprintf(option_error, "no such option as -%c", c);
	    usage(option_error);
	}
    }
#endif

    if (optind >= argc) {
	usage("no file argument");
    }
    for (i = optind ; i < argc; i++) {
	process(argv[i]);
    }
    return 0;
}