]> cygwin.com Git - cygwin-apps/setup.git/blob - ini.h
2001-11-13 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / ini.h
1 /*
2 * Copyright (c) 2000, Red Hat, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by DJ Delorie <dj@cygnus.com>
13 *
14 */
15
16 #ifndef _INI_H_
17 #define _INI_H_
18
19 /* When setup.ini is parsed, the information is stored according to
20 the declarations here. ini.cc (via inilex and iniparse)
21 initializes these structures. choose.cc sets the action and trust
22 fields. download.cc downloads any needed files for selected
23 packages (the chosen "install" field). install.cc installs
24 selected packages. */
25
26 /* the classes here store installation info *shrug* */
27 /* forward typedefs */
28
29 typedef struct _Category Category;
30 typedef struct _Package Package;
31
32 #include "choose.h"
33
34 #define YYSTYPE char *
35
36 /* lowest number must be most trusted, highest least trusted */
37 typedef enum
38 {
39 TRUST_UNKNOWN,
40 TRUST_PREV,
41 TRUST_CURR,
42 TRUST_TEST,
43 NTRUST
44 }
45 trusts;
46
47 typedef enum
48 {
49 EXCLUDE_NONE = 0,
50 EXCLUDE_BY_SETUP,
51 EXCLUDE_NOT_FOUND
52 }
53 excludes;
54
55 #define is_download_action(pkg) \
56 ((pkg)->action == ACTION_PREV || \
57 (pkg)->action == ACTION_CURR || \
58 (pkg)->action == ACTION_TEST || \
59 (pkg)->action == ACTION_REDO || \
60 (pkg)->action == ACTION_SRC_ONLY)
61
62 #define is_upgrade_action(pkg) \
63 (((pkg)->action >= ACTION_CURR && \
64 (pkg)->action <= ACTION_TEST) || \
65 (pkg)->action == ACTION_REDO)
66
67 #define is_uninstall_action(pkg) \
68 (is_upgrade_action (pkg) || \
69 (pkg)->action == ACTION_PREV || \
70 (pkg)->action == ACTION_UNINSTALL)
71
72 #define is_full_action(pkg) \
73 (((pkg)->action >= ACTION_SAME_PREV && (pkg)->action <= ACTION_SAME_TEST) \
74 || (pkg)->action == ACTION_SKIP)
75
76 #define SRCACTION_NO 0
77 #define SRCACTION_YES 1
78 typedef struct _Info
79 {
80 char *version; /* version part of filename */
81 char *install; /* file name to install */
82 unsigned int install_size; /* in bytes */
83 int install_exists; /* install file exists on disk */
84 int derived; /* True if we "figured out" that this version should
85 go here but it was not in setup.ini */
86 char *source; /* sources for installed binaries */
87 unsigned int source_size; /* in bytes */
88 int source_exists; /* source file exists on disk */
89 #ifdef __cplusplus
90 _Info (const char *_install, const char *_version,
91 int _install_size, const char *_source = NULL,
92 int _source_size = 0);
93 #endif
94 }
95 Info; /* +1 for TRUST_UNKNOWN */
96
97 typedef struct _CategoryPackage
98 {
99 struct _CategoryPackage *next; /* The next package pointer in the list */
100 char *pkgname; /* This should be Package *, but the packages can move */
101 }
102 CategoryPackage;
103
104 struct _Category
105 {
106 struct _Category *next; /* the next category in the list */
107 char *name; /* the category */
108 CategoryPackage *packages; /* the packages in this category */
109 };
110
111 typedef struct _Dependency
112 {
113 struct _Dependency *next; /* the next package in this dependency list */
114 char *package; /* the name of the package that is depended on */
115 }
116 Dependency; /* Dependencies can be used for
117 recommended/required/related... */
118 struct _Package
119 {
120 char *name; /* package name, like "cygwin" */
121 char *sdesc; /* short description (replaces "name" if provided) */
122 char *ldesc; /* long description (multi-line) */
123 Category *category; /* the categories the package belongs to */
124 Dependency *required; /* the packages required for this package to work */
125 actions action; /* A range of states applicable to this package */
126 trusts trust; /* Selects among info[] below, a subset of action */
127 int srcpicked; /* True if source is required */
128
129 Info *installed; /* Info on installed package */
130 trusts installed_ix; /* Index into info array for currently installed package */
131 excludes exclude; /* true if this package should be excluded */
132
133 /* The reason for this weird layout is to allow for loops that scan either
134 the info array, based on trust value or the infoscan array based on a pointer,
135 looking for a particular version. */
136 Info info[1]; /* First element. Intentionally allocated prior
137 to infoscan */
138 Info infoscan[NTRUST - 1]; /* +1 for TRUST_UNKNOWN */
139 Info infoend[0]; /* end marker */
140 };
141
142 extern Package *package;
143 extern int npackages;
144 extern Category *category;
145 extern int ncategories;
146
147 #ifdef __cplusplus
148 extern "C"
149 {
150 #endif
151
152 Package *new_package (char *name);
153 void ini_init (char *string);
154 Package *getpkgbyname (const char *pkgname);
155 void new_requirement (Package * package, char *dependson);
156 Category *getcategorybyname (const char *categoryname);
157 Category *getpackagecategorybyname (Package * pkg,
158 const char *categoryname);
159 Category *register_category (const char *name);
160 void add_category (Package * package, Category * cat);
161
162 #ifdef __cplusplus
163 }
164 #endif
165
166 #endif /* _INI_H_ */
This page took 0.06673 seconds and 6 git commands to generate.