Changeset 120
- Timestamp:
- 06/01/07 00:38:37 (2 years ago)
- Files:
-
- branches/dev/ChangeLog (modified) (1 diff)
- branches/dev/lswm/Makefile.in (modified) (1 diff)
- branches/dev/lswm/lswm.c (modified) (6 diffs)
- branches/dev/wminput/Makefile.in (modified) (1 diff)
- branches/dev/wminput/main.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dev/ChangeLog
r118 r120 1 2007-06-01 Nick <nickishappy@gmail.com> 2 lswm 3 * reworked command-line options (added standard options, long options) 4 5 wminput 6 * reworked command-line options (added standard options, long options) 7 1 8 2007-06-01 L. Donnie Smith <cwiid@abstrakraft.org> 2 9 python 3 10 * added Wiimote_FromC 4 11 * exported Wiimote_FromC and ConvertMesgArray as CObjects 12 * added get_acc_cal 5 13 6 14 wminput 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 branches/dev/wminput/Makefile.in
r118 r120 10 10 CFLAGS += -I@top_builddir@/libcwiid -I/usr/include/python@PYTHON_VERSION@ \ 11 11 -DWMINPUT_CONFIG_DIR=\"$(WMINPUT_CONFIG_DIR)\" \ 12 -DCWIID_PLUGINS_DIR=\"$(CWIID_PLUGINS_DIR)\" 12 -DCWIID_PLUGINS_DIR=\"$(CWIID_PLUGINS_DIR)\" \ 13 -DCWIID_VERSION=\"${PACKAGE_VERSION}\" 13 14 LDLIBS += -lcwiid -ldl -lpython@PYTHON_VERSION@ 14 15 LDFLAGS += -L@top_builddir@/libcwiid -rdynamic branches/dev/wminput/main.c
r118 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-06-01 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * added python plugin support … … 46 49 #include <stdio.h> 47 50 #include <stdlib.h> 51 #include <getopt.h> 48 52 49 53 #include <pthread.h> … … 60 64 61 65 struct conf conf; 62 63 /* GetOpt */64 #define OPTSTRING "hwc:"65 extern char *optarg;66 extern int optind, opterr, optopt;67 66 68 67 /* Prototypes */ … … 83 82 #define DEFAULT_CONFIG_FILE "default" 84 83 85 #define USAGE "usage:%s [-h] [-w] [-c config] [bdaddr]\n"86 87 84 #define HOME_DIR_LEN 128 85 86 void print_usage(void) 87 { 88 printf("wminput is a program that allows you to use a wiimote as a standard input device\n"); 89 printf("Usage: %s [OPTIONS]...\n\n", "wminput"); 90 printf("Options:\n"); 91 printf("\t-h, --help\t\tPrints this output.\n"); 92 printf("\t-v, --version\t\toutput version information and exit.\n"); 93 printf("\t-c, --config [file]\tChoose config file to use.\n"); 94 printf("\t-w, --wait\t\tWait indefinitely for wiimote to connect.\n"); 95 } 96 88 97 int main(int argc, char *argv[]) 89 98 { … … 107 116 108 117 /* Parse Options */ 109 while ((c = getopt(argc, argv, OPTSTRING)) != -1) { 118 while (1) { 119 int option_index = 0; 120 121 static struct option long_options[] = { 122 {"help", 0, 0, 'h'}, 123 {"wait", 0, 0, 'w'}, 124 {"config", 1, 0, 'c'}, 125 {"version", 0, 0, 'v'}, 126 {0, 0, 0, 0} 127 }; 128 129 c = getopt_long (argc, argv, "hwc:v", long_options, &option_index); 130 131 if (c == -1) { 132 break; 133 } 134 110 135 switch (c) { 111 136 case 'h': 112 print f(USAGE, argv[0]);137 print_usage(); 113 138 return 0; 114 139 break; … … 119 144 config_filename = optarg; 120 145 break; 146 case 'v': 147 printf("CWiid Version %s\n", CWIID_VERSION); 148 return 0; 149 break; 121 150 case '?': 151 printf("Try `wminput --help` for more information\n"); 152 return 1; 153 break; 122 154 default: 123 155 return -1; … … 182 214 if (optind < argc) { 183 215 wminput_err("invalid command-line"); 184 print f(USAGE, argv[0]);216 print_usage(); 185 217 conf_unload(&conf); 186 218 return -1;
