3a60bc597dfea03bd36a1f104340d15192cdb43d
[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
28 #include "hash_table.h"
29 #include "pkg_src_list.h"
30 #include "pkg_dest_list.h"
31 #include "nv_pair_list.h"
32
33 #define OPKG_CONF_DEFAULT_TMP_DIR_BASE "/tmp"
34 #define OPKG_CONF_TMP_DIR_SUFFIX "opkg-XXXXXX"
35 #define OPKG_CONF_LISTS_DIR  OPKG_STATE_DIR_PREFIX "/lists"
36
37 #define OPKG_CONF_DEFAULT_CONF_FILE_DIR OPKGETCDIR"/opkg"
38
39 /* In case the config file defines no dest */
40 #define OPKG_CONF_DEFAULT_DEST_NAME "root"
41 #define OPKG_CONF_DEFAULT_DEST_ROOT_DIR "/"
42
43 #define OPKG_CONF_DEFAULT_HASH_LEN 1024
44
45 struct opkg_conf
46 {
47      pkg_src_list_t pkg_src_list;
48      pkg_src_list_t dist_src_list;
49      pkg_dest_list_t pkg_dest_list;
50      pkg_dest_list_t tmp_dest_list;
51      nv_pair_list_t arch_list;
52
53      int restrict_to_default_dest;
54      pkg_dest_t *default_dest;
55      char *dest_str;
56
57      char *conf_file;
58
59      char *tmp_dir;
60      char *lists_dir;
61
62      unsigned int pfm; /* package field mask */
63
64      /* For libopkg users to capture messages. */
65      void (*opkg_vmessage)(int, const char *fmt, va_list ap);
66
67      /* options */
68      int autoremove;
69      int force_depends;
70      int force_defaults;
71      int force_maintainer;
72      int force_overwrite;
73      int force_downgrade;
74      int force_reinstall;
75      int force_space;
76      int force_removal_of_dependent_packages;
77      int force_removal_of_essential_packages;
78      int force_postinstall;
79      int force_remove;
80      int check_signature;
81      int nodeps; /* do not follow dependencies */
82      char *offline_root;
83      char *overlay_root;
84      int query_all;
85      int verbosity;
86      int noaction;
87      int download_only;
88      char *cache;
89
90 #ifdef HAVE_SSLCURL
91      /* some options could be used by
92       * wget if curl support isn't builtin
93       * If someone want to try...
94       */
95      char *ssl_engine;
96      char *ssl_cert;
97      char *ssl_cert_type;
98      char *ssl_key;
99      char *ssl_key_type;
100      char *ssl_key_passwd;
101      char *ssl_ca_file;
102      char *ssl_ca_path;
103      int ssl_dont_verify_peer;
104 #endif
105 #ifdef HAVE_PATHFINDER
106      int check_x509_path;
107 #endif
108
109      /* proxy options */
110      char *http_proxy;
111      char *ftp_proxy;
112      char *no_proxy;
113      char *proxy_user;
114      char *proxy_passwd;
115
116      char *signature_ca_file;
117      char *signature_ca_path;
118
119      hash_table_t pkg_hash;
120      hash_table_t file_hash;
121      hash_table_t obs_file_hash;
122 };
123
124 enum opkg_option_type {
125      OPKG_OPT_TYPE_BOOL,
126      OPKG_OPT_TYPE_INT,
127      OPKG_OPT_TYPE_STRING
128 };
129 typedef enum opkg_option_type opkg_option_type_t;
130
131 typedef struct opkg_option opkg_option_t;
132 struct opkg_option {
133      const char *name;
134      const opkg_option_type_t type;
135      void * const value;
136 };
137
138 int opkg_conf_init(void);
139 int opkg_conf_load(void);
140 void opkg_conf_deinit(void);
141
142 int opkg_conf_write_status_files(void);
143 char *root_filename_alloc(char *filename);
144
145 #endif