src/sg_ses.c
static void
enumerate_work(const struct opts_t * op)
{
    int num;
    const struct element_type_t * etp;
    const struct acronym2tuple * ap;
    char b[64];
    char a[160];
    const char * cp;

    if (op->dev_name)
        printf(">>> DEVICE %s ignored when --%s option given.\n",
               op->dev_name, (op->do_list ? "list" : "enumerate"));
    num = op->enumerate + op->do_list;
    if (num < 2) {
        enumerate_diag_pages();
        printf("\nSES element type names, followed by abbreviation and "
               "element type code:\n");
        for (etp = element_type_arr; etp->desc; ++etp)
            printf("    %s  [%s] [0x%x]\n", etp->desc, etp->abbrev,
                   etp->elem_type_code);
    } else {
        /* command line has multiple --enumerate and/or --list options */
        printf("--clear, --get, --set acronyms for Enclosure Status/Control "
               "['es' or 'ec'] page:\n");
        for (ap = ecs_a2t_arr; ap->acron; ++ap) {
            cp = (ap->etype < 0) ?
                         "*" : find_element_tname(ap->etype, b, sizeof(b));
            snprintf(a, sizeof(a), "  %s  [%s] [%d:%d:%d]", ap->acron,
                     (cp ? cp : "??"), ap->start_byte, ap->start_bit,
                     ap->num_bits);
            if (ap->info)
                printf("%-44s  %s\n", a, ap->info);
            else
                printf("%s\n", a);
        }
        printf("\n--clear, --get, --set acronyms for Threshold In/Out "
               "['th'] page:\n");
        for (ap = th_a2t_arr; ap->acron; ++ap) {
            cp = (ap->etype < 0) ? "*" :
                         find_element_tname(ap->etype, b, sizeof(b));
            snprintf(a, sizeof(a), "  %s  [%s] [%d:%d:%d]", ap->acron,
                     (cp ? cp : "??"), ap->start_byte, ap->start_bit,
                     ap->num_bits);
            if (ap->info)
                printf("%-34s  %s\n", a, ap->info);
            else
                printf("%s\n", a);
        }
        printf("\n--get acronyms for Additional Element Status ['aes'] page "
               "(SAS EIP=1):\n");
        for (ap = ae_sas_a2t_arr; ap->acron; ++ap) {
            cp = (ap->etype < 0) ? "*" :
                        find_element_tname(ap->etype, b, sizeof(b));
            snprintf(a, sizeof(a), "  %s  [%s] [%d:%d:%d]", ap->acron,
                     (cp ? cp : "??"), ap->start_byte, ap->start_bit,
                     ap->num_bits);
            if (ap->info)
                printf("%-34s  %s\n", a, ap->info);
            else
                printf("%s\n", a);
        }
    }
}
/* Output from --enumerate or --list option. Note that the output is
 * different when the option is given twice. */
Output from --enumerate or --list option. Note that the output is
different when the option is given twice.
Output from -- enumerate or -- list option . Note that the output is different when the option is given twice .
static void
enumerate_work(const struct opts_t * op)
{
    int num;
    const struct element_type_t * etp;
    const struct acronym2tuple * ap;
    char b[64];
    char a[160];
    const char * cp;
    if (op->dev_name)
        printf(">>> DEVICE %s ignored when --%s option given.\n",
               op->dev_name, (op->do_list ? "list" : "enumerate"));
    num = op->enumerate + op->do_list;
    if (num < 2) {
        enumerate_diag_pages();
        printf("\nSES element type names, followed by abbreviation and "
               "element type code:\n");
        for (etp = element_type_arr; etp->desc; ++etp)
            printf("    %s  [%s] [0x%x]\n", etp->desc, etp->abbrev,
                   etp->elem_type_code);
    } else {
        printf("--clear, --get, --set acronyms for Enclosure Status/Control "
               "['es' or 'ec'] page:\n");
        for (ap = ecs_a2t_arr; ap->acron; ++ap) {
            cp = (ap->etype < 0) ?
                         "*" : find_element_tname(ap->etype, b, sizeof(b));
            snprintf(a, sizeof(a), "  %s  [%s] [%d:%d:%d]", ap->acron,
                     (cp ? cp : "??"), ap->start_byte, ap->start_bit,
                     ap->num_bits);
            if (ap->info)
                printf("%-44s  %s\n", a, ap->info);
            else
                printf("%s\n", a);
        }
        printf("\n--clear, --get, --set acronyms for Threshold In/Out "
               "['th'] page:\n");
        for (ap = th_a2t_arr; ap->acron; ++ap) {
            cp = (ap->etype < 0) ? "*" :
                         find_element_tname(ap->etype, b, sizeof(b));
            snprintf(a, sizeof(a), "  %s  [%s] [%d:%d:%d]", ap->acron,
                     (cp ? cp : "??"), ap->start_byte, ap->start_bit,
                     ap->num_bits);
            if (ap->info)
                printf("%-34s  %s\n", a, ap->info);
            else
                printf("%s\n", a);
        }
        printf("\n--get acronyms for Additional Element Status ['aes'] page "
               "(SAS EIP=1):\n");
        for (ap = ae_sas_a2t_arr; ap->acron; ++ap) {
            cp = (ap->etype < 0) ? "*" :
                        find_element_tname(ap->etype, b, sizeof(b));
            snprintf(a, sizeof(a), "  %s  [%s] [%d:%d:%d]", ap->acron,
                     (cp ? cp : "??"), ap->start_byte, ap->start_bit,
                     ap->num_bits);
            if (ap->info)
                printf("%-34s  %s\n", a, ap->info);
            else
                printf("%s\n", a);
        }
    }
}
static void enumerate_work ( const struct opts_t * op ) { int num ; const struct element_type_t * etp ; const struct acronym2tuple * ap ; char b [ 64 ] ; char a [ 160 ] ; const char * cp ; if ( op -> dev_name ) printf ( " \n " , op -> dev_name , ( op -> do_list ? " " : " " ) ) ; num = op -> enumerate + op -> do_list ; if ( num < 2 ) { enumerate_diag_pages ( ) ; printf ( " \n " " \n " ) ; for ( etp = element_type_arr ; etp -> desc ; ++ etp ) printf ( " \n " , etp -> desc , etp -> abbrev , etp -> elem_type_code ) ; } else { printf ( " " " \n " ) ; for ( ap = ecs_a2t_arr ; ap -> acron ; ++ ap ) { cp = ( ap -> etype < 0 ) ? " " : find_element_tname ( ap -> etype , b , sizeof ( b ) ) ; snprintf ( a , sizeof ( a ) , " " , ap -> acron , ( cp ? cp : " " ) , ap -> start_byte , ap -> start_bit , ap -> num_bits ) ; if ( ap -> info ) printf ( " \n " , a , ap -> info ) ; else printf ( " \n " , a ) ; } printf ( " \n " " \n " ) ; for ( ap = th_a2t_arr ; ap -> acron ; ++ ap ) { cp = ( ap -> etype < 0 ) ? " " : find_element_tname ( ap -> etype , b , sizeof ( b ) ) ; snprintf ( a , sizeof ( a ) , " " , ap -> acron , ( cp ? cp : " " ) , ap -> start_byte , ap -> start_bit , ap -> num_bits ) ; if ( ap -> info ) printf ( " \n " , a , ap -> info ) ; else printf ( " \n " , a ) ; } printf ( " \n " " \n " ) ; for ( ap = ae_sas_a2t_arr ; ap -> acron ; ++ ap ) { cp = ( ap -> etype < 0 ) ? " " : find_element_tname ( ap -> etype , b , sizeof ( b ) ) ; snprintf ( a , sizeof ( a ) , " " , ap -> acron , ( cp ? cp : " " ) , ap -> start_byte , ap -> start_bit , ap -> num_bits ) ; if ( ap -> info ) printf ( " \n " , a , ap -> info ) ; else printf ( " \n " , a ) ; } } }
Output from --enumerate or --list option.
Output from -- enumerate or -- list option .
/* command line has multiple --enumerate and/or --list options */