libfru 2.0+git20240917.25293b1
FRU Manupulation Library
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
frugen.h File Reference

FRU generator utility header file. More...

#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include "fru.h"
Include dependency graph for frugen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  frugen_fruinfo_s
 
struct  frugen_config_s
 
struct  fieldopt_t
 

Macros

#define fatal(fmt, args...)
 
#define warn(fmt, args...)
 
#define debug(level, fmt, args...)
 
#define FRU_FIELD_CUSTOM   (-1)
 
#define DATEBUF_SZ   20
 Date string buffer length (must fit "DD/MM/YYYY HH:MM:SS")
 

Enumerations

enum  frugen_format_t {
  FRUGEN_FMT_UNSET ,
  FRUGEN_FMT_FIRST ,
  FRUGEN_FMT_JSON = FRUGEN_FMT_FIRST ,
  FRUGEN_FMT_BINARY ,
  FRUGEN_FMT_TEXTOUT ,
  FRUGEN_FMT_LAST = FRUGEN_FMT_TEXTOUT
}
 

Functions

bool datestr_to_tv (const char *datestr, struct timeval *tv)
 
void tv_to_datestr (char *datestr, const struct timeval *tv)
 
fieldopt_t arg_to_fieldopt (char *arg)
 
fru_mr_mgmt_type_t fru_mr_mgmt_type_by_name (const char *name)
 
const char * fru_mr_mgmt_name_by_type (fru_mr_mgmt_type_t type)
 

Variables

volatile int debug_level
 

Detailed Description

FRU generator utility header file.

Copyright (C) 2016-2023 Alexander Amelkin alexa.nosp@m.nder.nosp@m.@amel.nosp@m.kin..nosp@m.msk.r.nosp@m.u SPDX-License-Identifier: GPL-2.0-or-later OR Apache-2.0

Macro Definition Documentation

◆ DATEBUF_SZ

#define DATEBUF_SZ   20

Date string buffer length (must fit "DD/MM/YYYY HH:MM:SS")

◆ debug

#define debug (   level,
  fmt,
  args... 
)
Value:
do { \
typeof(errno) e = errno; \
if(level <= debug_level) { \
printf("DEBUG: "); \
errno = e; \
printf(fmt, ##args); \
printf("\n"); \
errno = e; \
} \
} while(0)
volatile int debug_level
Definition frugen.c:39

◆ fatal

#define fatal (   fmt,
  args... 
)
Value:
do { \
fprintf(stderr, fmt, ##args); \
fprintf(stderr, "\n"); \
exit(1); \
} while(0)

◆ FRU_FIELD_CUSTOM

#define FRU_FIELD_CUSTOM   (-1)

◆ warn

#define warn (   fmt,
  args... 
)
Value:
do { \
typeof(errno) e = errno; \
fprintf(stderr, "WARNING: "); \
errno = e; \
fprintf(stderr, fmt, ##args); \
fprintf(stderr, "\n"); \
errno = e; \
} while(0)

Enumeration Type Documentation

◆ frugen_format_t

Enumerator
FRUGEN_FMT_UNSET 
FRUGEN_FMT_FIRST 
FRUGEN_FMT_JSON 
FRUGEN_FMT_BINARY 
FRUGEN_FMT_TEXTOUT 
FRUGEN_FMT_LAST 

Function Documentation

◆ arg_to_fieldopt()

fieldopt_t arg_to_fieldopt ( char *  arg)

Split a --set command line option argument string into fields.

The argument format is expected to be:

[<encoding>:]<area>.<field>=

Works for string fields only (i.e. not chassis.type or board.date)

Examples: 6bitascii:product.pn=ABCDEF123 // Force 6-bit ASCII if possible text:procuct.name=SOMEPRODUCT // Force plain text, prevent 6-bit board.serial=Whatever // Autodetect encoding product.custom=Sometext // Autodetect, request addition product.custom.1=Sometext // Autodetect, request replacement of field 1

Returns field_opt_t structure. Terminates the program on parsing failure.

WARNING: Modifies the input string.

References fieldopt_t::area, fieldopt_t::custom_index, debug, fatal, fieldopt_t::field, fru_enc_name_by_type(), fru_enc_type_by_name(), FRU_FIELD_CUSTOM, FRU_FIELD_NOT_PRESENT, fieldopt_t::index, fieldopt_t::type, and fieldopt_t::value.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ datestr_to_tv()

bool datestr_to_tv ( const char *  datestr,
struct timeval *  tv 
)

Convert local date/time string to UTC time in seconds for FRU

Referenced by load_from_json_file(), and main().

Here is the caller graph for this function:

◆ fru_mr_mgmt_name_by_type()

const char * fru_mr_mgmt_name_by_type ( fru_mr_mgmt_type_t  type)

Get Multirecord Area Record name by its type

Reverse of fru_mr_mgmt_type_by_name()

References fatal, and MGMT_TYPE_ID.

◆ fru_mr_mgmt_type_by_name()

fru_mr_mgmt_type_t fru_mr_mgmt_type_by_name ( const char *  name)

Find a Management Access record subtype by its short name

Takes a short name of the subtype from the following list and returs the ID as per Table 18-6.

Terminates the program on failure.

Parameters
[in]nameThe short name of the type: surl = System URL sname = System Name spingaddr = System ping address curl = Component URL cname = Component name cpingaddr = Component ping address uuid = System UUID
Returns
The ID of the subtype as per Table 18-6 of IPMI FRU Spec
Return values
1..7The subtype ID

References fatal.

◆ tv_to_datestr()

void tv_to_datestr ( char *  datestr,
const struct timeval *  tv 
)

Convert FRU time (in UTC) to a local date/time string

Referenced by save_to_json_file(), and save_to_text_file().

Here is the caller graph for this function:

Variable Documentation

◆ debug_level

volatile int debug_level
extern

Referenced by main().