MCPcopy Create free account
hub / github.com/F-Stack/f-stack / print_media_word

Function print_media_word

tools/ifconfig/ifmedia.c:678–736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

676}
677
678static void
679print_media_word(int ifmw, int print_toptype)
680{
681 struct ifmedia_description *desc;
682 struct ifmedia_type_to_subtype *ttos;
683 int seen_option = 0, i;
684
685 /* Find the top-level interface type. */
686 desc = get_toptype_desc(ifmw);
687 ttos = get_toptype_ttos(ifmw);
688 if (desc->ifmt_string == NULL) {
689 printf("<unknown type>");
690 return;
691 } else if (print_toptype) {
692 printf("%s", desc->ifmt_string);
693 }
694
695 /*
696 * Don't print the top-level type; it's not like we can
697 * change it, or anything.
698 */
699
700 /* Find subtype. */
701 desc = get_subtype_desc(ifmw, ttos);
702 if (desc == NULL) {
703 printf("<unknown subtype>");
704 return;
705 }
706
707 if (print_toptype)
708 putchar(' ');
709
710 printf("%s", desc->ifmt_string);
711
712 if (print_toptype) {
713 desc = get_mode_desc(ifmw, ttos);
714 if (desc != NULL && strcasecmp("autoselect", desc->ifmt_string))
715 printf(" mode %s", desc->ifmt_string);
716 }
717
718 /* Find options. */
719 for (i = 0; ttos->options[i].desc != NULL; i++) {
720 if (ttos->options[i].alias)
721 continue;
722 for (desc = ttos->options[i].desc;
723 desc->ifmt_string != NULL; desc++) {
724 if (ifmw & desc->ifmt_word) {
725 if (seen_option == 0)
726 printf(" <");
727 printf("%s%s", seen_option++ ? "," : "",
728 desc->ifmt_string);
729 }
730 }
731 }
732 printf("%s", seen_option ? ">" : "");
733
734 if (print_toptype && IFM_INST(ifmw) != 0)
735 printf(" instance %d", IFM_INST(ifmw));

Callers 1

media_statusFunction · 0.85

Calls 7

get_toptype_descFunction · 0.85
get_toptype_ttosFunction · 0.85
get_subtype_descFunction · 0.85
putcharFunction · 0.85
get_mode_descFunction · 0.85
strcasecmpFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected