00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include <stdio.h>
00047 #include <string.h>
00048 #include <stdlib.h>
00049 #include <errno.h>
00050 #include "command_line_parser.h"
00051
00052 void print_help (void);
00053
00054 int command_line_parser (int argc, char *argv[], command_options_t *options) {
00055 int i;
00056 const char port_str[]="-p";
00057 const char help_str[]="-h";
00058 long portnum=5555;
00059
00060 for (i=1;i<argc;i++) {
00061 if (!strcmp(argv[i],port_str)) {
00062 if ((i+1)<argc) {
00063 if (!((portnum=strtol(argv[i+1],NULL,10))<1024)) {
00064 options->port=portnum;
00065 }
00066 i++;
00067 }
00068 }
00069 else if (!strcmp(argv[i],help_str)) {
00070 print_help();
00071 exit(0);
00072 }
00073 else {
00074 printf("Error: bad option %s\n",argv[i]);
00075 printf("\"cart_comm -h\" for list of options\n");
00076 exit(0);
00077 }
00078 }
00079 return 0;
00080 }
00081
00082 void print_help (void) {
00083 printf("\nUSAGE: arm-elf-console-proxy [-h] [-r] [-a] [-p portnum]\n");
00084 printf("-h: Print this help message and exit\n");
00085 printf("-p portnum: Specify the port number for the comm server. Default value is 5555\n\n");
00086 }
00087
00088 void init_command_line_options(command_options_t *options) {
00089 options->port=5555;
00090 }
00091
00092
00093
00094
00095