Changeset 330df83 in mainline for uspace/app


Ignore:
Timestamp:
2013-07-19T20:42:57Z (12 years ago)
Author:
Manuele Conti <conti.ma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f4cbf9dd
Parents:
8a8a08d1 (diff), cd18cd1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge with mainline changes.

Location:
uspace/app
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    r8a8a08d1 r330df83  
    6363static bool should_quit = false;
    6464static bool dash_represents_stdin = false;
     65static unsigned int lineno = 0;
     66static bool number = false;
     67static bool last_char_was_newline = false;
    6568
    6669static console_ctrl_t *console = NULL;
     
    7578        { "hex", no_argument, 0, 'x' },
    7679        { "stdin", no_argument, 0, 's' },
     80        { "number", no_argument, 0, 'n' },
    7781        { 0, 0, 0, 0 }
    7882};
     
    9599                "  -m, --more       Pause after each screen full\n"
    96100                "  -x, --hex        Print bytes as hex values\n"
    97                 "  -s  --stdin      Treat `-' in file list as standard input\n"
     101                "  -s, --stdin      Treat `-' in file list as standard input\n"
     102                "  -n, --number     Number all output lines\n"
    98103                "Currently, %s is under development, some options don't work.\n",
    99104                cmdname, cmdname);
     
    153158static void paged_char(wchar_t c)
    154159{
     160        if (last_char_was_newline && number) {
     161                lineno++;
     162                printf("%6u  ", lineno);
     163        }
    155164        putchar(c);
     165        last_char_was_newline = c == '\n';
    156166        if (paging_enabled) {
    157167                chars_remaining--;
     
    306316        should_quit = false;
    307317        console = console_init(stdin, stdout);
     318        number = false;
     319        lineno = 0;
     320        /* This enables printing of the first number. */
     321        last_char_was_newline = true;
     322
    308323
    309324        argc = cli_count_args(argv);
    310325
    311326        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
    312                 c = getopt_long(argc, argv, "xhvmH:t:b:s", long_options, &opt_ind);
     327                c = getopt_long(argc, argv, "xhvmH:t:b:s:n", long_options, &opt_ind);
    313328                switch (c) {
    314329                case 'h':
     
    347362                        dash_represents_stdin = true;
    348363                        break;
     364                case 'n':
     365                        number = true;
     366                        break;
    349367                }
    350368        }
  • uspace/app/dnsres/dnsres.c

    r8a8a08d1 r330df83  
    3636#include <inet/addr.h>
    3737#include <inet/dnsr.h>
     38#include <net/socket_codes.h>
    3839#include <stdio.h>
    3940#include <stdlib.h>
    4041
    41 #define NAME "dnsres"
     42#define NAME  "dnsres"
    4243
    4344static void print_syntax(void)
    4445{
    45         printf("syntax: " NAME " <host-name>\n");
     46        printf("Syntax: %s [-4|-6] <host-name>\n", NAME);
    4647}
    4748
    4849int main(int argc, char *argv[])
    4950{
    50         int rc;
    51         dnsr_hostinfo_t *hinfo;
    52         char *hname;
    53         char *saddr;
    54 
    55         if (argc != 2) {
     51        if ((argc < 2) || (argc > 3)) {
    5652                print_syntax();
    5753                return 1;
    5854        }
    59 
    60         hname = argv[1];
    61 
    62         rc = dnsr_name2host(hname, &hinfo);
     55       
     56        uint16_t af;
     57        char *hname;
     58       
     59        if (str_cmp(argv[1], "-4") == 0) {
     60                if (argc < 3) {
     61                        print_syntax();
     62                        return 1;
     63                }
     64               
     65                af = AF_INET;
     66                hname = argv[2];
     67        } else if (str_cmp(argv[1], "-6") == 0) {
     68                if (argc < 3) {
     69                        print_syntax();
     70                        return 1;
     71                }
     72               
     73                af = AF_INET6;
     74                hname = argv[2];
     75        } else {
     76                af = 0;
     77                hname = argv[1];
     78        }
     79       
     80        dnsr_hostinfo_t *hinfo;
     81        int rc = dnsr_name2host(hname, &hinfo, af);
    6382        if (rc != EOK) {
    64                 printf(NAME ": Error resolving '%s'.\n", argv[1]);
    65                 return 1;
     83                printf("%s: Error resolving '%s'.\n", NAME, hname);
     84                return rc;
    6685        }
    67 
     86       
     87        char *saddr;
    6888        rc = inet_addr_format(&hinfo->addr, &saddr);
    6989        if (rc != EOK) {
    7090                dnsr_hostinfo_destroy(hinfo);
    71                 printf(NAME ": Out of memory.\n");
    72                 return 1;
     91                printf("%s: Error formatting address.\n", NAME);
     92                return rc;
    7393        }
    74 
     94       
    7595        printf("Host name: %s\n", hname);
     96       
    7697        if (str_cmp(hname, hinfo->cname) != 0)
    7798                printf("Canonical name: %s\n", hinfo->cname);
     99       
    78100        printf("Address: %s\n", saddr);
    79 
     101       
    80102        dnsr_hostinfo_destroy(hinfo);
    81103        free(saddr);
    82 
     104       
    83105        return 0;
    84106}
  • uspace/app/nettest1/nettest1.c

    r8a8a08d1 r330df83  
    335335                /* Interpret as a host name */
    336336                dnsr_hostinfo_t *hinfo = NULL;
    337                 rc = dnsr_name2host(addr_s, &hinfo);
     337                rc = dnsr_name2host(addr_s, &hinfo, family);
    338338               
    339339                if (rc != EOK) {
  • uspace/app/nettest2/nettest2.c

    r8a8a08d1 r330df83  
    271271                /* Interpret as a host name */
    272272                dnsr_hostinfo_t *hinfo = NULL;
    273                 rc = dnsr_name2host(addr_s, &hinfo);
     273                rc = dnsr_name2host(addr_s, &hinfo, family);
    274274               
    275275                if (rc != EOK) {
  • uspace/app/nettest3/nettest3.c

    r8a8a08d1 r330df83  
    7878                if (rc != EOK) {
    7979                        /* Try interpreting as a host name */
    80                         rc = dnsr_name2host(argv[1], &hinfo);
     80                        rc = dnsr_name2host(argv[1], &hinfo, AF_INET);
    8181                        if (rc != EOK) {
    8282                                printf("Error resolving host '%s'.\n", argv[1]);
  • uspace/app/nterm/conn.c

    r8a8a08d1 r330df83  
    8484                /* Interpret as a host name */
    8585                dnsr_hostinfo_t *hinfo = NULL;
    86                 rc = dnsr_name2host(addr_s, &hinfo);
     86                rc = dnsr_name2host(addr_s, &hinfo, 0);
    8787               
    8888                if (rc != EOK) {
  • uspace/app/ping/ping.c

    r8a8a08d1 r330df83  
    212212        if (rc != EOK) {
    213213                /* Try interpreting as a host name */
    214                 rc = dnsr_name2host(argv[argi], &hinfo);
     214                rc = dnsr_name2host(argv[argi], &hinfo, AF_INET);
    215215                if (rc != EOK) {
    216216                        printf(NAME ": Error resolving host '%s'.\n", argv[argi]);
  • uspace/app/ping6/ping6.c

    r8a8a08d1 r330df83  
    102102        }
    103103       
    104         printf("Received ICMP echo reply: from %s to %s, seq. no %u, "
     104        printf("Received ICMPv6 echo reply: from %s to %s, seq. no %u, "
    105105            "payload size %zu\n", asrc, adest, sdu->seq_no, sdu->size);
    106106       
     
    212212        if (rc != EOK) {
    213213                /* Try interpreting as a host name */
    214                 rc = dnsr_name2host(argv[argi], &hinfo);
     214                rc = dnsr_name2host(argv[argi], &hinfo, AF_INET6);
    215215                if (rc != EOK) {
    216216                        printf(NAME ": Error resolving host '%s'.\n", argv[argi]);
Note: See TracChangeset for help on using the changeset viewer.