💾 Archived View for gmi.noulin.net › gitRepositories › ini › file › example › main.c.gmi captured on 2023-01-29 at 13:20:21. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

ini

Log

Files

Refs

LICENSE

main.c (841B)

     1 #include <stdio.h>
     2 #include <stdlib.h>
     3 #include "../src/ini.h"
     4 #include "libsheepyObject.h"
     5 
     6 int callback(char* section, char* config, char* value)
     7 {
     8         printf("[%s] \"%s\" == \"%s\"\n", section, config, value);
     9         return 0;
    10 }
    11 
    12 int main(int argc, char** argv) {
    13         if (argc < 2) {
    14                 printf("usage: %s file ...\noutput ini configuration values\n", argv[0]);
    15                 return EXIT_FAILURE;
    16         }
    17 
    18         smallDictt *ini = parseIni(argv[1]);
    19         //logVarG(ini);
    20         createAllocateSmallJson(js);
    21         setTopG(js, (baset*) ini);
    22         logNFree(stringifyG(js,2));
    23         XSUCCESS
    24 
    25         int i;
    26         for (i = 1; i < argc; i++) {
    27                 printf("parsing %s\n", argv[i]);
    28                 FILE* fp = fopen(argv[i], "r");
    29                 if (! fp) {
    30                         fprintf(stderr, "Error opening %s\n", argv[i]);
    31                         return EXIT_FAILURE;
    32                 }
    33                 ini_parse_file(fp, callback);
    34                 fclose(fp);
    35         }
    36         return EXIT_SUCCESS;
    37 }