VirtualBox

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

Last change on this file since 73768 was 69062, checked in by vboxsync, 7 years ago

IPRT: Added RTIniFileQueryPair for key/value pair enumeration.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/* $Id: inifile.h 69062 2017-10-12 15:05:52Z 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 named 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 * Queries a key-value pair in a section by ordinal.
103 *
104 * @returns IPRT status code.
105 * @retval VERR_NOT_FOUND if the section wasn't found or if it contains no pair
106 * with the given ordinal value.
107 *
108 * @param hIniFile The INI-file handle.
109 * @param pszSection The section name. Pass NULL to refer to the
110 * unsectioned key space at the top of the file.
111 * @param idxPair The pair to fetch (counting from 0).
112 *
113 * @param pszKey Where to return the key name.
114 * @param cbKey Size of the buffer @a pszKey points to.
115 * @param pcbKeyActual Where to return the actual key size excluding
116 * terminator on success. On VERR_BUFFER_OVERFLOW this
117 * will be set to the buffer size needed to hold the
118 * value, terminator included. Optional.
119 *
120 * @param pszValue Where to return the value.
121 * @param cbValue Size of the buffer @a pszValue points to.
122 * @param pcbValueActual Where to return the actual value size excluding
123 * terminator on success. On VERR_BUFFER_OVERFLOW this
124 * will be set to the buffer size needed to hold the
125 * value, terminator included. Optional.
126 */
127RTDECL(int) RTIniFileQueryPair(RTINIFILE hIniFile, const char *pszSection, uint32_t idxPair,
128 char *pszKey, size_t cbKey, size_t *pcbKeyActual,
129 char *pszValue, size_t cbValue, size_t *pcbValueActual);
130
131
132/** @} */
133
134RT_C_DECLS_END
135
136#endif
137
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use