Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
feat: initial work
Browse files Browse the repository at this point in the history
  • Loading branch information
RossComputerGuy committed Feb 26, 2023
1 parent 8a7dbb1 commit 940cd68
Show file tree
Hide file tree
Showing 14 changed files with 815 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/manual.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
<bookinfo>
<title>libexpidus Reference Manual</title>
<releaseinfo>
for ExpidusOS's libexpidus library v&version;
</releaseinfo>

<copyright>
<year>2023</year>
<holder>Midstall Software &amp; The ExpidusOS Team</holder>
</copyright>
</bookinfo>

<chapter>
<title>API Reference</title>
<xi:include href="xml/config-parser.xml" />
</chapter>

<index id="api-index-full">
<title>API Index</title>
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
</index>
</book>
9 changes: 9 additions & 0 deletions docs/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
gnome.gtkdoc('libexpidus',
main_xml: 'manual.xml',
content_files: configure_file(input: 'version.xml.in', output: 'version.xml', configuration: conf_data),
src_dir: [
join_paths(meson.project_source_root(), 'include'),
],
scan_args: ['--rebuild-sections'],
dependencies: [libexpidus],
install: true)
1 change: 1 addition & 0 deletions docs/version.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@VERSION_LONG@
115 changes: 115 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
description = "Library for handling a lot of the ExpidusOS specific functionality";

nixConfig = rec {
trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ];
substituters = [ "https://cache.nixos.org" "https://cache.garnix.io" ];
trusted-substituters = substituters;
fallback = true;
http2 = false;
};

inputs.expidus-sdk.url = github:ExpidusOS/sdk/refactor;

outputs = { self, expidus-sdk }:
with expidus-sdk.lib;
flake-utils.simpleFlake {
inherit self;
nixpkgs = expidus-sdk;
name = "expidus";
overlay = import ./overlay.nix { inherit self; };
shell = import ./shell.nix { inherit self; };
};
}
141 changes: 141 additions & 0 deletions include/expidus/config-parser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#pragma once

#include <neutron/elemental.h>

NT_BEGIN_DECLS

/**
* SECTION: config-parser
* @title: Config Parser
* @short_description: Parsing of ExpidusOS configuration files
*/

#if defined(__GNUC__)
#pragma GCC visibility push(default)
#elif defined(__clang__)
#pragma clang visibility push(default)
#endif

/**
* ExpidusConfigParser:
* @instance: The %NtTypeInstance associated
* @priv: Private data
*
* Type for parsing ExpidusOS configuration files
*/
typedef struct _ExpidusConfigParser {
NtTypeInstance instance;

/*< private >*/
struct _ExpidusConfigParserPrivate* priv;
} ExpidusConfigParser;

/**
* ExpidusConfigProperty:
* @name: Name of the property
* @type: The type of property this should be
* @default_value: The default value data to use
*
* Structure for defining properties for %ExpidusConfigParser
*/
typedef struct _ExpidusConfigProperty {
const char* name;
NtValueType type;
NtValueData default_value;
} ExpidusConfigProperty;

/**
* EXPIDUS_TYPE_CONFIG_PARSER:
*
* The %NtType ID of %ExpidusConfigParser
*/
#define EXPIDUS_TYPE_CONFIG_PARSER expidus_config_parser_get_type()
NT_DECLARE_TYPE(EXPIDUS, CONFIG_PARSER, ExpidusConfigParser, expidus_config_parser);

/**
* expidus_config_parser_new:
*
* Creates a new empty configuration parser
*
* Returns: A new instance
*/
ExpidusConfigParser* expidus_config_parser_new();

/**
* expidus_config_parser_remove_property:
* @self: Instance
* @name: Name of the property
*
* Removes the property by its name
*/
void expidus_config_parser_remove_property(ExpidusConfigParser* self, const char* name);

/**
* expidus_config_parser_add_property:
* @self: Instance
* @name: Name of the property
* @type: The type of property this should be
* @default_value: The default value data to use
*
* Adds the new property
*/
void expidus_config_parser_add_property(ExpidusConfigParser* self, const char* name, NtValueType type, NtValueData default_value);

/**
* expidus_config_parser_set_properties:
* @self: Instance
* @props: An array of properties with the last one having name set to %NULL
*
* Fills the configuration parser with all the properties at one go.
*/
void expidus_config_parser_set_properties(ExpidusConfigParser* self, ExpidusConfigProperty* props);

/**
* expidus_config_parser_read_line:
* @self: Instance
* @str: The string to read as a single line
* @length: The length of @str
* @backtrace: The backtrace to append to in case of an error
* @error: Pointer to store the error in
*
* Parses the string as a single line with a determined length.
* If it failed to parse the line, then an error is pushed through @error.
* If the property doesn't exist then name in %NtTypeArgument will be %NULL.
*
* Returns: The property name and value represented as a type argument. If it doesn't exist, then name will be %NULL.
*/
NtTypeArgument expidus_config_parser_read_line(ExpidusConfigParser* self, const char* str, size_t length, NtBacktrace* backtrace, NtError** error);

/**
* expidus_config_parser_read:
* @self: Instance
* @str: The configuration to parse
* @backtrace: The backtrace to append to in case of an error
* @error: Pointer to store the error in
*
* Parse the configuration line by line
*
* Returns: A list of %NtTypeArgument's which are keyed based on %ExpidusVendorConfigProperty. %NULL is returned if failure.
*/
NtTypeArgument* expidus_config_parser_read(ExpidusConfigParser* self, const char* str, NtBacktrace* backtrace, NtError** error);

/**
* expidus_config_parser_read_file:
* @self: Instance
* @path: The path to the file
* @backtrace: The backtrace to append to in case of an error
* @error: Pointer to store the error in
*
* Parses the configuration from a file
*
* Returns: A list of %NtTypeArgument's which are keyed based on %ExpidusVendorConfigProperty. %NULL is returned if failure.
*/
NtTypeArgument* expidus_config_parser_read_file(ExpidusConfigParser* self, const char* path, NtBacktrace* backtrace, NtError** error);

#if defined(__GNUC__)
#pragma GCC visibility pop
#elif defined(__clang__)
#pragma clang visibility pop
#endif

NT_END_DECLS
Loading

0 comments on commit 940cd68

Please sign in to comment.