Changeset 120 for branches/dev/lswm
- Timestamp:
- 06/01/07 00:38:37 (2 years ago)
- Files:
-
- branches/dev/lswm/Makefile.in (modified) (1 diff)
- branches/dev/lswm/lswm.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dev/lswm/Makefile.in
r83 r120 7 7 SOURCES = lswm.c 8 8 9 CFLAGS += -I@top_builddir@/libcwiid 9 CFLAGS += -I@top_builddir@/libcwiid -DCWIID_VERSION=\"${PACKAGE_VERSION}\" 10 10 LDFLAGS += -L@top_builddir@/libcwiid 11 11 LDLIBS += -lcwiid branches/dev/lswm/lswm.c
r83 r120 16 16 * 17 17 * ChangeLog: 18 * 2007-06-01 Nick <nickishappy@gmail.com> 19 * * reworked command-line options (added standard options, long options) 20 * 18 21 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * updated for libcwiid rename … … 32 35 #include <bluetooth/bluetooth.h> 33 36 #include <cwiid.h> 37 #include <getopt.h> 34 38 35 #define OPTSTRING "ahlq" 36 37 #define USAGE \ 38 "%s [OPTIONS]\n" \ 39 " -a list all bluetooth devices (not just wiimotes)\n" \ 40 " -h print this help message\n" \ 41 " -l long format (device details)\n" \ 42 " -q quiet mode\n" 39 void print_usage(void) 40 { 41 printf("lswm lists availiable wiimotes\n"); 42 printf("Usage: %s [OPTIONS]...\n\n", "lswm"); 43 printf("Options:\n"); 44 printf("\t-h, --help\t\tPrints this output.\n"); 45 printf("\t-v, --version\t\toutput version information and exit.\n"); 46 printf("\t-l, --long\t\tlong format (device details).\n"); 47 printf("\t-q, --quiet\t\tquiet mode (less verbose).\n"); 48 printf("\t-a, --all\t\tlist all bluetooth devices (not just wiimotes).\n"); 49 } 43 50 44 51 int main(int argc, char *argv[]) … … 54 61 55 62 /* Parse options */ 56 while ((c = getopt(argc, argv, OPTSTRING)) != -1) { 63 while (1) { 64 int option_index = 0; 65 66 static struct option long_options[] = { 67 {"help", 0, 0, 'h'}, 68 {"all", 0, 0, 'a'}, 69 {"long", 0, 0, 'l'}, 70 {"version", 0, 0, 'v'}, 71 {"quiet", 0, 0, 'q'}, 72 {0, 0, 0, 0} 73 }; 74 75 c = getopt_long(argc, argv, "halvq", long_options, &option_index); 76 77 if (c == -1) { 78 break; 79 } 80 57 81 switch (c) { 58 82 case 'h': 59 print f(USAGE, argv[0]);83 print_usage(); 60 84 return 0; 61 85 break; … … 66 90 long_format = 1; 67 91 break; 92 case 'v': 93 printf("CWiid Version %s\n", CWIID_VERSION); 94 return 0; 95 break; 68 96 case 'q': 69 97 quiet = 1; … … 71 99 case '?': 72 100 default: 73 fprintf(stderr, "Try '%s - h' for more information\n", argv[0]);101 fprintf(stderr, "Try '%s --help' for more information\n", argv[0]); 74 102 return -1; 75 103 break; 76 104 } 77 105 } 78 79 /* TODO: check for other stuff on the command-line? */80 106 81 107 /* Handle quiet mode */ … … 112 138 return 0; 113 139 } 114
