2019-02-18 14:44:32 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* apps/examples/ini_dumper/ini_dumper_main.c
|
|
|
|
*
|
2021-06-11 06:48:03 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2019-02-18 14:44:32 +01:00
|
|
|
*
|
2021-06-11 06:48:03 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2019-02-18 14:44:32 +01:00
|
|
|
*
|
2021-06-11 06:48:03 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2019-02-18 14:44:32 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2020-05-20 10:29:35 +02:00
|
|
|
#include <fsutils/ini.h>
|
2019-02-18 14:44:32 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: ini_dump
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Prints every value in ini file to stdout
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int ini_dump(void *user, const char *section, const char *name,
|
|
|
|
const char *value, int lineno)
|
|
|
|
{
|
|
|
|
printf(" %-6d %-15s %-13s %s\n", lineno, section, name, value);
|
|
|
|
|
|
|
|
/* 1 is OK here, 0 is error */
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* ini_dumper_main()
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int main(int argc, FAR char *argv[])
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (argc != 2)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "usage: %s <ini-file>\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-05-20 10:29:35 +02:00
|
|
|
printf("------ --------------- ------------- -------------------------\n");
|
2019-02-18 14:44:32 +01:00
|
|
|
printf(" line section key value\n");
|
2020-05-20 10:29:35 +02:00
|
|
|
printf("------ --------------- ------------- -------------------------\n");
|
2019-02-18 14:44:32 +01:00
|
|
|
|
|
|
|
ret = ini_parse(argv[1], ini_dump, NULL);
|
2020-05-20 10:29:35 +02:00
|
|
|
printf("------ --------------- ------------- -------------------------\n");
|
2019-02-18 14:44:32 +01:00
|
|
|
fprintf(stderr, "ini_parse() exited with %d\n", ret);
|
|
|
|
return 0;
|
|
|
|
}
|