09437f13fff40691071b7428cdfa9a4078cfb7c3
[oweals/opkg-lede.git] / libopkg / opkg_conf.h
1 /* opkg_conf.h - the opkg package management system
2
3    Carl D. Worth
4
5    Copyright (C) 2001 University of Southern California
6
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License as
9    published by the Free Software Foundation; either version 2, or (at
10    your option) any later version.
11
12    This program is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16 */
17
18 #ifndef OPKG_CONF_H
19 #define OPKG_CONF_H
20
21 typedef struct opkg_conf opkg_conf_t;
22 extern opkg_conf_t *conf;
23
24 #include "config.h"
25
26 #include <stdarg.h>
27 #include <fnmatch.h> /* FNM_CASEFOLD */
28
29 #include "hash_table.h"
30 #include "pkg_src_list.h"
31 #include "pkg_dest_list.h"
32 #include "nv_pair_list.h"
33
34 #define OPKG_CONF_DEFAULT_TMP_DIR_BASE "/tmp"
35 #define OPKG_CONF_TMP_DIR_SUFFIX "opkg-XXXXXX"
36 #define OPKG_CONF_LISTS_DIR  OPKG_STATE_DIR_PREFIX "/lists"
37
38 #define OPKG_CONF_DEFAULT_CONF_FILE_DIR OPKGETCDIR"/opkg"
39
40 /* In case the config file defines no dest */
41 #define OPKG_CONF_DEFAULT_DEST_NAME "root"
42 #define OPKG_CONF_DEFAULT_DEST_ROOT_DIR "/"
43
44 #define OPKG_CONF_DEFAULT_HASH_LEN 1024
45
46 struct opkg_conf
47 {
48      pkg_src_list_t pkg_src_list;
49      pkg_src_list_t dist_src_list;
50      pkg_dest_list_t pkg_dest_list;
51      pkg_dest_list_t tmp_dest_list;
52      nv_pair_list_t arch_list;
53
54      int restrict_to_default_dest;
55      pkg_dest_t *default_dest;
56      char *dest_str;
57
58      char *conf_file;
59
60      char *tmp_dir;
61      char *lists_dir;
62
63      unsigned int pfm; /* package field mask */
64
65      /* For libopkg users to capture messages. */
66      void (*opkg_vmessage)(int, const char *fmt, va_list ap);
67
68      /* options */
69      int autoremove;
70      int force_depends;
71      int force_defaults;
72      int force_maintainer;
73      int force_overwrite;
74      int force_downgrade;
75      int force_reinstall;
76      int force_space;
77      int force_removal_of_dependent_packages;
78      int force_removal_of_essential_packages;
79      int force_postinstall;
80      int force_remove;
81      int force_checksum;
82      int check_signature;
83      int nodeps; /* do not follow dependencies */
84      int nocase; /* perform case insensitive matching */
85      char *offline_root;
86      char *overlay_root;
87      int query_all;
88      int verbosity;
89      int noaction;
90      int download_only;
91      char *cache;
92
93 #ifdef HAVE_SSLCURL
94      /* some options could be used by
95       * wget if curl support isn't builtin
96       * If someone want to try...
97       */
98      char *ssl_engine;
99      char *ssl_cert;
100      char *ssl_cert_type;
101      char *ssl_key;
102      char *ssl_key_type;
103      char *ssl_key_passwd;
104      char *ssl_ca_file;
105      char *ssl_ca_path;
106      int ssl_dont_verify_peer;
107 #endif
108 #ifdef HAVE_PATHFINDER
109      int check_x509_path;
110 #endif
111
112      /* proxy options */
113      char *http_proxy;
114      char *ftp_proxy;
115      char *no_proxy;
116      char *proxy_user;
117      char *proxy_passwd;
118
119      char *signature_ca_file;
120      char *signature_ca_path;
121
122      hash_table_t pkg_hash;
123      hash_table_t file_hash;
124      hash_table_t obs_file_hash;
125 };
126
127 enum opkg_option_type {
128      OPKG_OPT_TYPE_BOOL,
129      OPKG_OPT_TYPE_INT,
130      OPKG_OPT_TYPE_STRING
131 };
132 typedef enum opkg_option_type opkg_option_type_t;
133
134 typedef struct opkg_option opkg_option_t;
135 struct opkg_option {
136      const char *name;
137      const opkg_option_type_t type;
138      void * const value;
139 };
140
141 int opkg_conf_init(void);
142 int opkg_conf_load(void);
143 void opkg_conf_deinit(void);
144
145 int opkg_conf_write_status_files(void);
146 char *root_filename_alloc(char *filename);
147
148 #endif