FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ZipFile/smbios: Simple parser of SMBIOS structure tables. · GitHub

This repository was archived by the owner on Mar 21, 2023. It is now read-only.
/ smbios Public archive

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Simple parser of SMBIOS structure tables. Nothing more, nothing less.
Code is purely for studying purposes: minimum oop, readability in cost of error handling and assuming that you always feed right data.
Read SMBIOS documentation for details.

Installation

Just include header file where needed.

Usage

#include <cstdio>
#include "smbios.hpp"

int main() {
  using namespace smbios;
  
  parser meta;
  byte_t *buff = nullptr;
  size_t  buff_size = 0;
  
  //////////////////////////////////////////////////////
  // Code that makes buffer to point (or hold) smbios //
  // structure table. Don't forget about size.        //
  //////////////////////////////////////////////////////

  meta.feed(buff, buff_size);
  
  for (auto it = meta.headers.begin(); it != meta.headers.end(); ++it) {
  	string_array_t strings;
  
  	parser::extract_strings(*it, strings);
  
  	switch ((*it)->type) {
  	// ...
  		case types::memory_device: {
  			auto x = static_cast<mem_device *>(*it);
  
  			if (x->total_width == 0)
  				break;
  
  			printf("Memory device %s (%s):\n", strings[x->device_locator], strings[x->bank_locator]);
  			printf("  Data width:    %d bit\n", x->data_width);
  			printf("  Size:          %d M\n",   x->size);
  			printf("  Speed:         %d MHz\n", x->speed);
  			printf("  Clock speed:   %d MHz\n", x->clock_speed);
  			printf("  Manufacturer:  %s\n",     strings[x->manufacturer]);
  			printf("  S/N:           %s\n",     strings[x->serial_number]);
  			printf("  Tag number:    %s\n",     strings[x->assert_tag]);
  			printf("  Part number:   %s\n",     strings[x->part_number]);
  			printf("\n");
  		} break;
  
  	// ...
  	// Handle all other struct types
  	// ...
  
  		default: printf("Unknown structure type %d\n", (*it)->type);
  	}
  }
  
  //////////////////
  // Free buffers //
  //////////////////

  return 0;
}

About

Simple parser of SMBIOS structure tables.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages


Back | FazBrowse Home | New Git URL