1. Sync with master
[apps/core/preloaded/print-service.git] / include / pt_db.h
1 /*
2 *       Printservice
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9
10 * http://floralicense.org/license/
11
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 #ifndef __PRINT_PTDB_H__
21 #define __PRINT_PTDB_H__
22
23 #include <stdint.h>
24 #include <glib.h>
25
26 typedef enum {
27         PT_SEARCH_MODEL = 0, /** search ppd file by ModelName field */
28         PT_SEARCH_PROD,          /** search ppd file by Product field */
29         PT_SEARCH_ALL            /** search ppd file by PT_SEARCH_MODEL or PT_SEARCH_PROD */
30 } pt_search;
31
32 typedef struct {
33         GPtrArray *models;
34         GPtrArray *strings;
35 } drvm;
36
37 typedef struct {
38         FILE *dbfile;
39         const char *dbpath;
40         char *dbbuffer;
41 } pt_dbconfig;
42
43 typedef struct {
44         pt_dbconfig *dbconfig;
45         drvm *dbstruct;
46 } pt_db;
47
48 /**
49  *      Create in-core representation of print-service database.
50  *  This database is used for searching, extracting ppd files.
51  *      @return   If success, returns pointer to in-core database representation ,
52  *  else returns NULL
53  *      @param[in] absolute or relative path to the database file
54  */
55 pt_db *pt_create_db(const char *path);
56
57 /**
58  *      Extract ppd file
59  *      @return   If success, returns string with ppdc output,
60  *  else returns NULL
61  *      @param[in] database pointer to the database
62  *      @param[in] search key used for searching ppd file
63  *      @param[in] type which type of searching will be performed
64  */
65 char* pt_extract_ppd(pt_db *database, const char *search, pt_search type);
66
67 /**
68  *      Free memory and other resources used by in-core database representation.
69  *      @return   If success, returns pointer to in-core database representation ,
70  *  else returns NULL
71  *      @param[in] database pointer to the database
72  */
73 void pt_free_db(pt_db *database);
74
75 #endif /* __PRINT_PTDB_H__ */