Deleted Added
full compact
lib.h (3364) lib.h (4546)
1/* $Id: lib.h,v 1.9 1994/09/29 13:19:42 jkh Exp $ */
1/* $Id: lib.h,v 1.10 1994/10/04 16:07:50 jkh Exp $ */
2
3/*
4 * FreeBSD install - a package for the installation and maintainance
5 * of non-core utilities.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Jordan K. Hubbard
17 * 18 July 1993
18 *
19 * Include and define various things wanted by the library routines.
20 *
21 */
22
23#ifndef _INST_LIB_LIB_H_
24#define _INST_LIB_LIB_H_
25
26/* Includes */
27#include <stdio.h>
28#include <stdlib.h>
29#include <stdarg.h>
30#include <string.h>
31#include <unistd.h>
32#include <ctype.h>
33#include <dirent.h>
34#include <sys/stat.h>
35#include <sys/types.h>
36#include <sys/file.h>
37
38/* Macros */
39#define SUCCESS (0)
40#define FAIL (-1)
41
42#ifndef TRUE
43#define TRUE (1)
44#endif
45
46#ifndef FALSE
47#define FALSE (0)
48#endif
49
50#define YES 2
51#define NO 1
52
53/* Usually "rm", but often "echo" during debugging! */
54#define REMOVE_CMD "rm"
55
56/* Usually "rm", but often "echo" during debugging! */
57#define RMDIR_CMD "rmdir"
58
59/* Where we put logging information */
60#define LOG_DIR "/var/db/pkg"
61
62/* The names of our "special" files */
63#define CONTENTS_FNAME "+CONTENTS"
64#define COMMENT_FNAME "+COMMENT"
65#define DESC_FNAME "+DESC"
66#define INSTALL_FNAME "+INSTALL"
67#define DEINSTALL_FNAME "+DEINSTALL"
68#define REQUIRE_FNAME "+REQUIRE"
69
70#define CMD_CHAR '@' /* prefix for extended PLIST cmd */
71
72/* The name of the "prefix" environment variable given to scripts */
73#define PKG_PREFIX_VNAME "PKG_PREFIX"
74
75enum _plist_t {
76 PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD,
77 PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT,
78 PLIST_IGNORE, PLIST_NAME, PLIST_UNEXEC, PLIST_SRC
79};
80typedef enum _plist_t plist_t;
81
82/* Types */
83typedef unsigned int Boolean;
84
85struct _plist {
86 struct _plist *prev, *next;
87 char *name;
88 Boolean marked;
89 plist_t type;
90};
91typedef struct _plist *PackingList;
92
93struct _pack {
94 struct _plist *head, *tail;
95};
96typedef struct _pack Package;
97
98/* Prototypes */
99/* Misc */
100int vsystem(const char *, ...);
101void cleanup(int);
102char *make_playpen(char *, size_t);
103void leave_playpen(void);
104char *where_playpen(void);
105
106/* String */
107char *get_dash_string(char **);
108char *copy_string(char *);
109Boolean suffix(char *, char *);
110void nuke_suffix(char *);
111void str_lowercase(char *);
2
3/*
4 * FreeBSD install - a package for the installation and maintainance
5 * of non-core utilities.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Jordan K. Hubbard
17 * 18 July 1993
18 *
19 * Include and define various things wanted by the library routines.
20 *
21 */
22
23#ifndef _INST_LIB_LIB_H_
24#define _INST_LIB_LIB_H_
25
26/* Includes */
27#include <stdio.h>
28#include <stdlib.h>
29#include <stdarg.h>
30#include <string.h>
31#include <unistd.h>
32#include <ctype.h>
33#include <dirent.h>
34#include <sys/stat.h>
35#include <sys/types.h>
36#include <sys/file.h>
37
38/* Macros */
39#define SUCCESS (0)
40#define FAIL (-1)
41
42#ifndef TRUE
43#define TRUE (1)
44#endif
45
46#ifndef FALSE
47#define FALSE (0)
48#endif
49
50#define YES 2
51#define NO 1
52
53/* Usually "rm", but often "echo" during debugging! */
54#define REMOVE_CMD "rm"
55
56/* Usually "rm", but often "echo" during debugging! */
57#define RMDIR_CMD "rmdir"
58
59/* Where we put logging information */
60#define LOG_DIR "/var/db/pkg"
61
62/* The names of our "special" files */
63#define CONTENTS_FNAME "+CONTENTS"
64#define COMMENT_FNAME "+COMMENT"
65#define DESC_FNAME "+DESC"
66#define INSTALL_FNAME "+INSTALL"
67#define DEINSTALL_FNAME "+DEINSTALL"
68#define REQUIRE_FNAME "+REQUIRE"
69
70#define CMD_CHAR '@' /* prefix for extended PLIST cmd */
71
72/* The name of the "prefix" environment variable given to scripts */
73#define PKG_PREFIX_VNAME "PKG_PREFIX"
74
75enum _plist_t {
76 PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD,
77 PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT,
78 PLIST_IGNORE, PLIST_NAME, PLIST_UNEXEC, PLIST_SRC
79};
80typedef enum _plist_t plist_t;
81
82/* Types */
83typedef unsigned int Boolean;
84
85struct _plist {
86 struct _plist *prev, *next;
87 char *name;
88 Boolean marked;
89 plist_t type;
90};
91typedef struct _plist *PackingList;
92
93struct _pack {
94 struct _plist *head, *tail;
95};
96typedef struct _pack Package;
97
98/* Prototypes */
99/* Misc */
100int vsystem(const char *, ...);
101void cleanup(int);
102char *make_playpen(char *, size_t);
103void leave_playpen(void);
104char *where_playpen(void);
105
106/* String */
107char *get_dash_string(char **);
108char *copy_string(char *);
109Boolean suffix(char *, char *);
110void nuke_suffix(char *);
111void str_lowercase(char *);
112char *basename_of(char *);
112
113/* File */
114Boolean fexists(char *);
115Boolean isdir(char *);
116Boolean isempty(char *);
117char *get_file_contents(char *);
118void write_file(char *, char *);
119void copy_file(char *, char *, char *);
120void copy_hierarchy(char *, char *, Boolean);
121int delete_hierarchy(char *, Boolean);
122int unpack(char *, char *);
123void format_cmd(char *, char *, char *, char *);
124
125/* Msg */
126void upchuck(const char *);
127void barf(const char *, ...);
128void whinge(const char *, ...);
129Boolean y_or_n(Boolean, const char *, ...);
130
131/* Packing list */
132PackingList new_plist_entry(void);
133PackingList last_plist(Package *);
134PackingList find_plist(Package *, plist_t);
135void plist_delete(Package *, Boolean, plist_t, char *);
136void free_plist(Package *);
137void mark_plist(Package *);
138void csum_plist_entry(char *, PackingList);
139void add_plist(Package *, plist_t, char *);
140void add_plist_top(Package *, plist_t, char *);
141void write_plist(Package *, FILE *);
142void read_plist(Package *, FILE *);
143int plist_cmd(char *, char **);
144int delete_package(Boolean, Package *);
145
146/* For all */
147void usage(const char *, const char *, ...);
148int pkg_perform(char **);
149
150/* Externs */
151extern Boolean Verbose;
152extern Boolean Fake;
153extern int AutoAnswer;
154
155#endif /* _INST_LIB_LIB_H_ */
113
114/* File */
115Boolean fexists(char *);
116Boolean isdir(char *);
117Boolean isempty(char *);
118char *get_file_contents(char *);
119void write_file(char *, char *);
120void copy_file(char *, char *, char *);
121void copy_hierarchy(char *, char *, Boolean);
122int delete_hierarchy(char *, Boolean);
123int unpack(char *, char *);
124void format_cmd(char *, char *, char *, char *);
125
126/* Msg */
127void upchuck(const char *);
128void barf(const char *, ...);
129void whinge(const char *, ...);
130Boolean y_or_n(Boolean, const char *, ...);
131
132/* Packing list */
133PackingList new_plist_entry(void);
134PackingList last_plist(Package *);
135PackingList find_plist(Package *, plist_t);
136void plist_delete(Package *, Boolean, plist_t, char *);
137void free_plist(Package *);
138void mark_plist(Package *);
139void csum_plist_entry(char *, PackingList);
140void add_plist(Package *, plist_t, char *);
141void add_plist_top(Package *, plist_t, char *);
142void write_plist(Package *, FILE *);
143void read_plist(Package *, FILE *);
144int plist_cmd(char *, char **);
145int delete_package(Boolean, Package *);
146
147/* For all */
148void usage(const char *, const char *, ...);
149int pkg_perform(char **);
150
151/* Externs */
152extern Boolean Verbose;
153extern Boolean Fake;
154extern int AutoAnswer;
155
156#endif /* _INST_LIB_LIB_H_ */