int main(int argc, char **argv) { /* Parameter check */ if (argc == 1) { usage(); return 1; } /* Initialise */ if (!(tdb = tdb_open(PRINT_TDB, 0, 0, O_RDWR | O_CREAT, 0666))) { printf("%s: unable to open %s\n", argv[0], PRINT_TDB); return 1; } /* Ensure we are modes 666 */ chmod(PRINT_TDB, 0666); /* Do commands */ if (strcmp(argv[1], "lpq") == 0) { return lpq_command(argc - 1, &argv[1]); } if (strcmp(argv[1], "lprm") == 0) { return lprm_command(argc - 1, &argv[1]); } if (strcmp(argv[1], "print") == 0) { return print_command(argc - 1, &argv[1]); } if (strcmp(argv[1], "queuepause") == 0) { return queuepause_command(argc - 1, &argv[1]); } if (strcmp(argv[1], "queueresume") == 0) { return queueresume_command(argc - 1, &argv[1]); } if (strcmp(argv[1], "lppause") == 0) { return lppause_command(argc - 1, &argv[1]); } if (strcmp(argv[1], "lpresume") == 0) { return lpresume_command(argc - 1, &argv[1]); } /* Unknown command */ printf("%s: invalid command %s\n", argv[0], argv[1]); return 1; }
int main(int argc, char **argv) { /* Parameter check */ const char *printdb_path = NULL; if (argc < 2) { usage(); return 1; } if (strncmp(argv[1], "tdbfile", strlen("tdbfile")) != 0) { usage(); return 1; } printdb_path = get_string_param(argv[1]); if (!printdb_path) { return 1; } if (!(tdb = tdb_open(printdb_path, 0, 0, O_RDWR | O_CREAT, 0666))) { printf("%s: unable to open %s\n", argv[0], printdb_path); return 1; } /* Ensure we are modes 666 */ chmod(printdb_path, 0666); /* Do commands */ if (strcmp(argv[2], "lpq") == 0) { return lpq_command(argc - 2, &argv[2]); } if (strcmp(argv[2], "lprm") == 0) { return lprm_command(argc - 2, &argv[2]); } if (strcmp(argv[2], "print") == 0) { return print_command(argc - 2, &argv[2]); } if (strcmp(argv[2], "queuepause") == 0) { return queuepause_command(argc - 2, &argv[2]); } if (strcmp(argv[2], "queueresume") == 0) { return queueresume_command(argc - 2, &argv[2]); } if (strcmp(argv[2], "lppause") == 0) { return lppause_command(argc - 2, &argv[2]); } if (strcmp(argv[2], "lpresume") == 0) { return lpresume_command(argc - 2, &argv[2]); } /* Unknown command */ printf("%s: invalid command %s\n", argv[0], argv[1]); return 1; }