void show_help(const std::string& topic, const std::string& info) {
#ifndef _MSC_VER
    // show man page on non-Windows systems
    std::string manpage("osmium-");
    manpage += topic;
    ::execlp("man", "man", manpage.c_str(), nullptr);
    // if exec fails, fall thru
#endif
    // show info string and link on Windows systems
    std::cout << info << "\n";
    std::cout << "You'll find more documentation at http://osmcode.org/osmium/\n";
}
Beispiel #2
0
int main(int argc, char *argv[])
{
    int	    c;
    int	    cmp;
    char    message[BUFSIZ];

    /* Make the program name pretty */
    Prog = strrchr(argv[0], '/');
    if (Prog == NULL) {
	    Prog = &argv[0][0];
    } else {
	    ++Prog;
    }

    /* Deal with --help and --man */
    if (argc > 1) {
	if (
	    (strcmp(argv[1], "--help") == 0)
	    ||
	    (strcmp(argv[1], "--man") == 0)
	) {
	    manpage();
	    exit(0);
	}
    }

    /* One quick sanity check */
    if (argc != 3) {
	(void) sprintf(message,
	    "expected 2 strings, got %d.", argc - 1);
	usage(message);
	exit(1);
    }

    cmp = strcmp(argv[1], argv[2]);
    if (cmp < 0) {
	printf("less\n");
    } else if (cmp == 0) {
	printf("equal\n");
    } else {
	printf("greater\n");
    }

    exit(0);
} /* main */