"Fossies" - the Fresh Open Source Software Archive

Member "dmidecode-3.3/dmioutput.c" (14 Oct 2020, 2584 Bytes) of package /linux/privat/dmidecode-3.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "dmioutput.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Generic output functions
    3  * This file is part of the dmidecode project.
    4  *
    5  *   Copyright (C) 2020 Jean Delvare <jdelvare@suse.de>
    6  *
    7  *   This program is free software; you can redistribute it and/or modify
    8  *   it under the terms of the GNU General Public License as published by
    9  *   the Free Software Foundation; either version 2 of the License, or
   10  *   (at your option) any later version.
   11  *
   12  *   This program is distributed in the hope that it will be useful,
   13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15  *   GNU General Public License for more details.
   16  *
   17  *   You should have received a copy of the GNU General Public License
   18  *   along with this program; if not, write to the Free Software
   19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
   20  */
   21 
   22 #include <stdarg.h>
   23 #include <stdio.h>
   24 #include "dmioutput.h"
   25 
   26 void pr_comment(const char *format, ...)
   27 {
   28     va_list args;
   29 
   30     printf("# ");
   31     va_start(args, format);
   32     vprintf(format, args);
   33     va_end(args);
   34     printf("\n");
   35 }
   36 
   37 void pr_info(const char *format, ...)
   38 {
   39     va_list args;
   40 
   41     va_start(args, format);
   42     vprintf(format, args);
   43     va_end(args);
   44     printf("\n");
   45 }
   46 
   47 void pr_handle(const struct dmi_header *h)
   48 {
   49     printf("Handle 0x%04X, DMI type %d, %d bytes\n",
   50            h->handle, h->type, h->length);
   51 }
   52 
   53 void pr_handle_name(const char *format, ...)
   54 {
   55     va_list args;
   56 
   57     va_start(args, format);
   58     vprintf(format, args);
   59     va_end(args);
   60     printf("\n");
   61 }
   62 
   63 void pr_attr(const char *name, const char *format, ...)
   64 {
   65     va_list args;
   66 
   67     printf("\t%s: ", name);
   68 
   69     va_start(args, format);
   70     vprintf(format, args);
   71     va_end(args);
   72     printf("\n");
   73 }
   74 
   75 void pr_subattr(const char *name, const char *format, ...)
   76 {
   77     va_list args;
   78 
   79     printf("\t\t%s: ", name);
   80 
   81     va_start(args, format);
   82     vprintf(format, args);
   83     va_end(args);
   84     printf("\n");
   85 }
   86 
   87 void pr_list_start(const char *name, const char *format, ...)
   88 {
   89     va_list args;
   90 
   91     printf("\t%s:", name);
   92 
   93     /* format is optional, skip value if not provided */
   94     if (format)
   95     {
   96         printf(" ");
   97         va_start(args, format);
   98         vprintf(format, args);
   99         va_end(args);
  100     }
  101     printf("\n");
  102 
  103 }
  104 
  105 void pr_list_item(const char *format, ...)
  106 {
  107     va_list args;
  108 
  109     printf("\t\t");
  110 
  111     va_start(args, format);
  112     vprintf(format, args);
  113     va_end(args);
  114     printf("\n");
  115 }
  116 
  117 void pr_list_end(void)
  118 {
  119     /* a no-op for text output */
  120 }
  121 
  122 void pr_sep(void)
  123 {
  124     printf("\n");
  125 }
  126 
  127 void pr_struct_err(const char *format, ...)
  128 {
  129     va_list args;
  130 
  131     printf("\t");
  132 
  133     va_start(args, format);
  134     vprintf(format, args);
  135     va_end(args);
  136     printf("\n");
  137 }