GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - soheil-01/dmidecode: dmidecode parser in zig

BranchesTags
Open more actions menu

Latest commit

 

History

3 Commits
3 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
build.zig
build.zig
 
 
build.zig.zon
build.zig.zon
 
 

Repository files navigation

DMIDecode

My first project while learning Zig. This is a Zig implementation for parsing the output of the dmidecode command. This is a port of dmidecode-nim.

Quick Start

const std = @import("std");
const DMIDecode = @import("dmidecode.zig").DMIDecode;

pub fn main() !void {
    var parser = DMIDecode.init(std.heap.page_allocator);
    defer parser.deinit();

    const sections = try parser.parse(
        \\Handle 0x0036, DMI type 43, 31 bytes
        \\TPM Device
        \\	Vendor ID: INTC
        \\	Specification Version: 2.0
        \\	Firmware Revision: 500.5
        \\	Strings:
        \\          Insyde_ASF_001
        \\          Insyde_ASF_002
        \\
    );

    const section: DMIDecode.Section = sections.get("TPM Device").?;
    std.debug.print("Handle: {s}, Title: {s}\n", .{ section.handleLine, section.title });

    const vendorID = section.props.get("Vendor ID").?.val;
    std.debug.print("Vendor ID: {s}\n", .{vendorID});

    const strings = section.props.get("Strings").?.items;
    std.debug.print("Strings: {s}, {s}\n", .{ strings.items[0], strings.items[0] });
}

Installation

  1. Declare dmidecode as a project dependency with zig fetch:
zig fetch --save git+https://github.com/soheil-01/dmidecode.git#main
  1. Expose dmidecode as a module in your project's build.zig:
pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const opts = .{ .target = target, .optimize = optimize };      // 👈
    const dmidecode_mod = b.dependency("dmidecode", opts).module("dmidecode"); // 👈

    const exe = b.addExecutable(.{
        .name = "my-project",
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,
    });
    exe.root_module.addImport("dmidecode", dmidecode_mod); // 👈

    // ...
}
  1. Import dmidecode into your code:
const dmidecode = @import("dmidecode");

About

dmidecode parser in zig

Topics

dmidecodezig

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.