Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of --json CLI option #2

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open

Implementation of --json CLI option #2

wants to merge 25 commits into from

Conversation

jirihnidek
Copy link
Owner

@jirihnidek jirihnidek commented Jun 28, 2023

This is PR with proper implementation of --json CLI option providing machine readable output. Compilation of dmidecode requires json-c library. When --json CLI option is used, then the output is written to stdout using JSON format. This could be useful, when other application tries to parse output of dmidecode. Parsing of output does not require some special tool like jc. The code was tested with valgrind and there should not be any memory leaks.

Other changes:

  • It is not possible to use --json with some other CLI options like --dump-bin
  • Some comments and info messages are not saved to output, when --json is used. Only information about version of SMBIOS and version od dmidecode is added to the output.
  • Manual pages were updates
  • README was updated

* Generated JSON file contains array called "data"
* Array "data" contains objects. Each object in this
  array represents one entry. This object contains
  only header ATM.
* Generated JSON could look like this ATM:

{
  "data":[
    {
      "header":{
        "handle":0,
        "type":222,
        "length":14
      }
    },
    {
      "header":{
        "handle":1,
        "type":14,
        "length":8
      }
    }
  ]
}
* Big commit with lot of changes caused by chanche of pr_attr(),
  because it has new argument json_object. This small change caused
  lot of many changes in the code. As a result lot of information
  is printed to output.
* Big commit with lot of changes
* It is possible to output list of flags, header_and_data,
  strings, etc.
* TODO: Code in dmioutput.c needs refactoring, because
  there is lot of duplicated code now.
* New CLI option --json cannot be used with some other CLI options,
  because it would not make sense
* Updated man page according this change
@jirihnidek jirihnidek changed the title WIP: Proper implementation of --json CLI option Implementation of --json CLI option Jul 19, 2023
@jirihnidek jirihnidek marked this pull request as ready for review July 19, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant