VirtualBox

source: vbox/trunk/include/iprt/inifile.h@ 68716

Last change on this file since 68716 was 68317, checked in by vboxsync, 7 years ago

IPRT: Added simple INI-file parser (completely untested).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: inifile.h 68317 2017-08-07 14:24:08Z vboxsync $ */
2/** @file
3 * IPRT - INI-file parser.
4 */
5
6/*
7 * Copyright (C) 2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___iprt_inifile_h
28#define ___iprt_inifile_h
29
30
31#include <iprt/types.h>
32
33RT_C_DECLS_BEGIN
34
35/** @defgroup grp_rt_inifile RTIniFile - INI-file parser
36 * @ingroup grp_rt
37 * @{
38 */
39
40/** @name RTINIFILE_F_XXX - INI-file open flags.
41 * @{ */
42/** Readonly. */
43#define RTINIFILE_F_READONLY RT_BIT(0)
44/** Valid mask. */
45#define RTINIFILE_F_VALID_MASK UINT32_C(0x00000001)
46/** @} */
47
48
49
50/**
51 * Creates a INI-file instance from a VFS file handle.
52 *
53 * @returns IPRT status code
54 * @param phIniFile Where to return the INI-file handle.
55 * @param hVfsFile The VFS file handle (not consumed, additional
56 * reference is retained).
57 * @param fFlags Flags, RTINIFILE_F_XXX.
58 */
59RTDECL(int) RTIniFileCreateFromVfsFile(PRTINIFILE phIniFile, RTVFSFILE hVfsFile, uint32_t fFlags);
60
61/**
62 * Retains a reference to an INI-file instance.
63 *
64 * @returns New reference count, UINT32_MAX on failure.
65 * @param hIniFile The INI-file handle.
66 */
67RTDECL(uint32_t) RTIniFileRetain(RTINIFILE hIniFile);
68
69/**
70 * Releases a reference to an INI-file instance, destroying it if the count
71 * reaches zero.
72 *
73 * @returns New reference count, UINT32_MAX on failure.
74 * @param hIniFile The INI-file handle. NIL is ignored.
75 */
76RTDECL(uint32_t) RTIniFileRelease(RTINIFILE hIniFile);
77
78/**
79 * Queries a value in a section.
80 *
81 * The first matching value is returned. The matching is by default case
82 * insensitive.
83 *
84 * @returns IPRT status code.
85 * @retval VERR_NOT_FOUND if section or key not found.
86 *
87 * @param hIniFile The INI-file handle.
88 * @param pszSection The section name. Pass NULL to refer to the
89 * unsectioned key space at the top of the file.
90 * @param pszKey The key name.
91 * @param pszValue Where to return the value.
92 * @param cbValue Size of the buffer @a pszValue points to.
93 * @param pcbActual Where to return the actual value size excluding
94 * terminator on success. On VERR_BUFFER_OVERFLOW this
95 * will be set to the buffer size needed to hold the
96 * value, terminator included. Optional.
97 */
98RTDECL(int) RTIniFileQueryValue(RTINIFILE hIniFile, const char *pszSection, const char *pszKey,
99 char *pszValue, size_t cbValue, size_t *pcbActual);
100
101
102/** @} */
103
104RT_C_DECLS_END
105
106#endif
107
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette