1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2  *
3  * Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
4  *
5  * SPDX-License-Identifier: LGPL-2.1+
6  */
7 
8 /**
9  * SECTION:as-inf
10  * @short_description: Helper functions for parsing .inf files
11  * @include: appstream-glib.h
12  * @stability: Stable
13  *
14  * These functions are used internally to libappstream-glib, and some may be
15  * useful to user-applications.
16  */
17 
18 #include "config.h"
19 
20 #include <gio/gio.h>
21 //#include <string.h>
22 //#include <stdlib.h>
23 
24 #include "as-inf.h"
25 
26 /**
27  * as_inf_error_quark:
28  *
29  * Return value: An error quark.
30  *
31  * Since: 0.3.7
32  **/
33 G_DEFINE_QUARK (as-inf-error-quark, as_inf_error)
34 
35 /**
36  * as_inf_load_data:
37  * @keyfile: a #GKeyFile
38  * @data: the .inf file date to parse
39  * @flags: #AsInfLoadFlags, e.g. %AS_INF_LOAD_FLAG_NONE
40  * @error: A #GError or %NULL
41  *
42  * Repairs .inf file data and opens it as a keyfile.
43  *
44  * Important: The group and keynames are all forced to lower case as INF files
45  * are specified as case insensitive and GKeyFile *is* case sensitive.
46  * Any backslashes or spaces in the key name are also converted to '_'.
47  *
48  * Returns: %TRUE for success
49  *
50  * Since: 0.3.5
51  */
52 gboolean
as_inf_load_data(GKeyFile * keyfile,const gchar * data,AsInfLoadFlags flags,GError ** error)53 as_inf_load_data (GKeyFile *keyfile,
54 		  const gchar *data,
55 		  AsInfLoadFlags flags,
56 		  GError **error)
57 {
58 	g_set_error (error,
59 		     AS_INF_ERROR,
60 		     AS_INF_ERROR_FAILED,
61 		     "Loading .inf data is no longer supported, see libginf");
62 	return FALSE;
63 }
64 
65 /**
66  * as_inf_load_file:
67  * @keyfile: a #GKeyFile
68  * @filename: the .inf file to open
69  * @flags: #AsInfLoadFlags, e.g. %AS_INF_LOAD_FLAG_NONE
70  * @error: A #GError or %NULL
71  *
72  * Repairs an .inf file and opens it as a keyfile.
73  *
74  * Returns: %TRUE for success
75  *
76  * Since: 0.3.5
77  */
78 gboolean
as_inf_load_file(GKeyFile * keyfile,const gchar * filename,AsInfLoadFlags flags,GError ** error)79 as_inf_load_file (GKeyFile *keyfile,
80 		  const gchar *filename,
81 		  AsInfLoadFlags flags,
82 		  GError **error)
83 {
84 	g_set_error (error,
85 		     AS_INF_ERROR,
86 		     AS_INF_ERROR_FAILED,
87 		     "Loading .inf files is no longer supported, see libginf");
88 	return FALSE;
89 }
90 
91 /**
92  * as_inf_get_driver_version:
93  * @keyfile: a #GKeyFile
94  * @timestamp: the returned driverver timestamp, or %NULL
95  * @error: A #GError or %NULL
96  *
97  * Parses the DriverVer string into a recognisable version and timestamp;
98  *
99  * Returns: the version string, or %NULL for error.
100  *
101  * Since: 0.3.5
102  */
103 gchar *
as_inf_get_driver_version(GKeyFile * keyfile,guint64 * timestamp,GError ** error)104 as_inf_get_driver_version (GKeyFile *keyfile, guint64 *timestamp, GError **error)
105 {
106 	g_set_error (error,
107 		     AS_INF_ERROR,
108 		     AS_INF_ERROR_FAILED,
109 		     "Loading .inf files is no longer supported, see libginf");
110 	return NULL;
111 }
112