Changeset d8e3467 in mainline for uspace/app/ping/ping.c


Ignore:
Timestamp:
2010-04-18T00:22:35Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9dae191e
Parents:
c39a103
Message:

rename arg_short_long() to arg_parse_short_long() and move it to libc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/ping/ping.c

    rc39a103 rd8e3467  
    132132}
    133133
    134 static int arg_short_long(const char *arg, const char *ashort,
    135     const char *along)
    136 {
    137         if (str_cmp(arg, ashort) == 0)
    138                 return 0;
    139        
    140         if (str_lcmp(arg, along, str_length(along)) == 0)
    141                 return str_length(along);
    142        
    143         return -1;
    144 }
    145 
    146134static int args_parse(int argc, char *argv[], ping_config_t *config)
    147135{
     
    165153               
    166154                int off;
    167                 int tmp;
    168155               
    169156                /* Usage */
    170                 if ((off = arg_short_long(argv[i], "-h", "--help")) != -1)
     157                if ((off = arg_parse_short_long(argv[i], "-h", "--help")) != -1)
    171158                        return CL_USAGE;
    172159               
    173160                /* Verbose */
    174                 if ((off = arg_short_long(argv[i], "-v", "--verbose")) != -1) {
     161                if ((off = arg_parse_short_long(argv[i], "-v", "--verbose")) != -1) {
    175162                        config->verbose = true;
    176163                        continue;
     
    184171               
    185172                /* Count */
    186                 if ((off = arg_short_long(argv[i], "-c", "--count=")) != -1) {
     173                if ((off = arg_parse_short_long(argv[i], "-c", "--count=")) != -1) {
     174                        int tmp;
    187175                        ret = arg_parse_int(argc, argv, &i, &tmp, off);
    188176                       
     
    195183               
    196184                /* Outgoing packet size */
    197                 if ((off = arg_short_long(argv[i], "-s", "--size=")) != -1) {
     185                if ((off = arg_parse_short_long(argv[i], "-s", "--size=")) != -1) {
     186                        int tmp;
    198187                        ret = arg_parse_int(argc, argv, &i, &tmp, off);
    199188                       
     
    206195               
    207196                /* Reply wait timeout */
    208                 if ((off = arg_short_long(argv[i], "-W", "--timeout=")) != -1) {
     197                if ((off = arg_parse_short_long(argv[i], "-W", "--timeout=")) != -1) {
     198                        int tmp;
    209199                        ret = arg_parse_int(argc, argv, &i, &tmp, off);
    210200                       
     
    217207               
    218208                /* Address family */
    219                 if ((off = arg_short_long(argv[i], "-f", "--family=")) != -1) {
     209                if ((off = arg_parse_short_long(argv[i], "-f", "--family=")) != -1) {
    220210                        ret = arg_parse_name_int(argc, argv, &i, &config->af, off,
    221211                            socket_parse_address_family);
     
    228218               
    229219                /* Type of service */
    230                 if ((off = arg_short_long(argv[i], "-Q", "--tos=")) != -1) {
     220                if ((off = arg_parse_short_long(argv[i], "-Q", "--tos=")) != -1) {
     221                        int tmp;
    231222                        ret = arg_parse_name_int(argc, argv, &i, &tmp, off,
    232223                            socket_parse_address_family);
     
    240231               
    241232                /* Time to live */
    242                 if ((off = arg_short_long(argv[i], "-t", "--ttl=")) != -1) {
     233                if ((off = arg_parse_short_long(argv[i], "-t", "--ttl=")) != -1) {
     234                        int tmp;
    243235                        ret = arg_parse_name_int(argc, argv, &i, &tmp, off,
    244236                            socket_parse_address_family);
Note: See TracChangeset for help on using the changeset viewer.