Changeset 4c9b28a in mainline for uspace/app/devctl/devctl.c


Ignore:
Timestamp:
2013-09-11T17:32:45Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5759975a
Parents:
1db5669
Message:

Printing match IDs of drivers and functions.

File:
1 edited

Legend:

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

    r1db5669 r4c9b28a  
    3535#include <devman.h>
    3636#include <errno.h>
     37#include <stdbool.h>
    3738#include <stdio.h>
    3839#include <stdlib.h>
     
    4445#define MAX_NAME_LENGTH 1024
    4546
    46 char name[MAX_NAME_LENGTH];
    47 char drv_name[MAX_NAME_LENGTH];
     47static char name[MAX_NAME_LENGTH];
     48static char drv_name[MAX_NAME_LENGTH];
     49static bool verbose = false;
    4850
    4951static const char *drv_state_str(driver_state_t state)
     
    7375        devman_handle_t *cfuns;
    7476        size_t count, i;
     77        unsigned int score;
    7578        int rc;
    7679        int j;
     
    9497        else
    9598                printf("%s : %s\n", name, drv_name);
     99
     100        if (verbose) {
     101                for (i = 0; true; i++) {
     102                        rc = devman_fun_get_match_id(funh, i, name, MAX_NAME_LENGTH,
     103                            &score);
     104                        if (rc != EOK)
     105                                break;
     106
     107                        for (j = 0; j < lvl; j++)
     108                                printf("    ");
     109
     110                        printf("    %u %s\n", score, name);
     111                }
     112        }
    96113
    97114        rc = devman_fun_get_child(funh, &devh);
     
    226243        driver_state_t state;
    227244        const char *sstate;
     245        unsigned int score;
    228246        size_t ndevs;
    229247        size_t i;
     
    252270        printf("Driver: %s\n", drv_name);
    253271        printf("State: %s\n", sstate);
     272
    254273        printf("Attached devices:\n");
    255274
     
    263282                        goto error;
    264283                printf("\t%s\n", name);
     284        }
     285
     286        printf("Match IDs:\n");
     287
     288        for (i = 0; true; i++) {
     289                rc = devman_driver_get_match_id(drvh, i, name, MAX_NAME_LENGTH,
     290                    &score);
     291                if (rc != EOK)
     292                        break;
     293
     294                printf("\t%u %s\n", score, name);
    265295        }
    266296
     
    306336        int rc;
    307337
    308         if (argc == 1) {
     338        if (argc == 1 || argv[1][0] == '-') {
     339                if (argc > 1) {
     340                        if (str_cmp(argv[1], "-v") == 0) {
     341                                verbose = true;
     342                        } else {
     343                                printf(NAME ": Invalid argument '%s'\n", argv[1]);
     344                                print_syntax();
     345                                return 1;
     346                        }
     347                }
    309348                rc = fun_tree_print();
    310349                if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.