diff --git a/src/cd_check_capabilities.c b/src/cd_check_capabilities.c index 77a7f9d..8645a62 100644 --- a/src/cd_check_capabilities.c +++ b/src/cd_check_capabilities.c @@ -13,12 +13,21 @@ static inline void die(int code, const char* message, int fd){ exit(code); } +static inline void print_usage(){ + printf("Usage: %s [-h]\n\t-h\tdisplays this help message.\n\t\ + Calling the program with no arguments will check the CD \ + tray and its' capabilities.", program_name); + die(127); +} + int main(int argc, char** argv){ register int fd, caps; if(!argv) die(127, "How did you do that? No argv?", -1); program_name = argv[0]; + if(argc > 1) print_usage(); + if((fd = open("/dev/cdrom", O_RDONLY | O_NONBLOCK)) == -1) die(127, "Cannot open /dev/cdrom", fd); diff --git a/src/cd_check_eject.c b/src/cd_check_eject.c index 03539dd..1e12491 100644 --- a/src/cd_check_eject.c +++ b/src/cd_check_eject.c @@ -13,12 +13,21 @@ static inline void die(int code, const char* message, int fd){ exit(code); } +static inline void print_usage(){ + printf("Usage: %s [-h]\n\t-h\tdisplays this help message.\n\t\ + Calling the program with no arguments will open the CD \ + tray.", program_name); + die(127); +} + int main(int argc, char** argv){ register int fd; if(!argv) die(127, "How did you do that? No argv?", -1); program_name = argv[0]; + if(argc > 1) print_usage(); + if((fd = open("/dev/cdrom", O_RDONLY | O_NONBLOCK)) == -1) die(127, "Cannot open /dev/cdrom", fd); diff --git a/src/cd_check_read.c b/src/cd_check_read.c index 66e54ce..8e481ba 100644 --- a/src/cd_check_read.c +++ b/src/cd_check_read.c @@ -14,6 +14,13 @@ static inline void die(int code, const char* message, int fd){ exit(code); } +static inline void print_usage(){ + printf("Usage: %s [-h]\n\t-h\tdisplays this help message.\n\t\ + Calling the program with no arguments will read the \ + CD lying in the tray and play it.", program_name); + die(127); +} + int main(int argc, char** argv){ register int fd; struct cdrom_tocentry toc_entry; @@ -22,6 +29,8 @@ int main(int argc, char** argv){ if(!argv) die(127, "How did you do that? No argv?", -1); program_name = argv[0]; + if(argc > 1) print_usage(); + if((fd = open("/dev/cdrom", O_RDONLY)) == -1){ if(errno == ENOMEDIUM) die(127, "No CD in drive", fd); diff --git a/src/cd_check_read_toc.c b/src/cd_check_read_toc.c index 2e04d60..8ebc33c 100644 --- a/src/cd_check_read_toc.c +++ b/src/cd_check_read_toc.c @@ -14,6 +14,13 @@ static inline void die(int code, const char* message, int fd){ exit(code); } +static inline void print_usage(){ + printf("Usage: %s [-h]\n\t-h\tdisplays this help message.\n\t\ + Calling the program with no arguments will read the \ + table of contents of the CD lying in the tray.", program_name); + die(127); +} + int main(int argc, char** argv){ register int fd; register unsigned char i; @@ -23,6 +30,8 @@ int main(int argc, char** argv){ if(!argv) die(127, "How did you do that? No argv?", -1); program_name = argv[0]; + if(argc > 1) print_usage(); + if((fd = open("/dev/cdrom", O_RDONLY)) == -1){ if(errno == ENOMEDIUM) die(127, "No CD in drive", fd);