Changeset efb8d15 in mainline for uspace/app/sysinfo/sysinfo.c


Ignore:
Timestamp:
2012-03-02T15:32:13Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
196c253
Parents:
71232af
Message:

dump sysinfo in a more compact way

File:
1 edited

Legend:

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

    r71232af refb8d15  
    9292}
    9393
    94 static void print_keys(const char *path)
     94static void print_spaces(size_t spaces)
     95{
     96        for (size_t i = 0; i < spaces; i++)
     97                printf(" ");
     98}
     99
     100static void print_keys(const char *path, size_t spaces)
    95101{
    96102        size_t size;
     
    103109                /* Process each key with sanity checks */
    104110                size_t cur_size = str_nsize(keys + pos, size - pos);
     111                if (keys[pos + cur_size] != 0)
     112                        break;
     113               
    105114                size_t path_size = str_size(path) + cur_size + 2;
    106115                char *cur_path = (char *) malloc(path_size);
     
    108117                        break;
    109118               
    110                 if (path[0] != 0)
     119                size_t length;
     120               
     121                if (path[0] != 0) {
     122                        print_spaces(spaces);
     123                        printf(".%s\n", keys + pos);
     124                        length = str_length(keys + pos) + 1;
     125                       
    111126                        snprintf(cur_path, path_size, "%s.%s", path, keys + pos);
    112                 else
     127                } else {
     128                        printf("%s\n", keys + pos);
     129                        length = str_length(keys + pos);
     130                       
    113131                        snprintf(cur_path, path_size, "%s", keys + pos);
     132                }
    114133               
    115                 printf("%s\n", cur_path);
    116                 print_keys(cur_path);
     134                print_keys(cur_path, spaces + length);
    117135               
    118136                free(cur_path);
     
    127145        if (argc != 2) {
    128146                /* Print keys */
    129                 print_keys("");
     147                print_keys("", 0);
    130148                return 0;
    131149        }
Note: See TracChangeset for help on using the changeset viewer.