]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/pkg_install/lib/lib.h
This is the Linux generic soundcard driver, version 1.0c. Supports
[FreeBSD/FreeBSD.git] / usr.sbin / pkg_install / lib / lib.h
1 /* $Id: lib.h,v 1.3 1993/09/05 04:54:21 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 /* Usually "rm", but often "echo" during debugging! */
51 #define REMOVE_CMD      "rm"
52
53 /* Usually "rm", but often "echo" during debugging! */
54 #define RMDIR_CMD       "rmdir"
55
56 /* Where we put logging information */
57 #define LOG_DIR         "/var/db/pkg"
58
59 /* The names of our "special" files */
60 #define CONTENTS_FNAME  "+CONTENTS"
61 #define COMMENT_FNAME   "+COMMENT"
62 #define DESC_FNAME      "+DESC"
63 #define INSTALL_FNAME   "+INSTALL"
64 #define DEINSTALL_FNAME "+DEINSTALL"
65 #define REQUIRE_FNAME   "+REQUIRE"
66
67 #define CMD_CHAR        '@'     /* prefix for extended PLIST cmd */
68
69
70 enum _plist_t {
71     PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD,
72     PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT,
73     PLIST_IGNORE, PLIST_NAME, PLIST_UNEXEC
74 };
75 typedef enum _plist_t plist_t;
76
77 /* Types */
78 typedef unsigned int Boolean;
79
80 struct _plist {
81     struct _plist *prev, *next;
82     char *name;
83     Boolean marked;
84     plist_t type;
85 };
86 typedef struct _plist *PackingList;
87
88 struct _pack {
89     struct _plist *head, *tail;
90 };
91 typedef struct _pack Package;
92
93 /* Prototypes */
94 /* Misc */
95 int             vsystem(const char *, ...);
96 void            cleanup(int);
97 char            *make_playpen(char *);
98 void            leave_playpen(void);
99 char            *where_playpen(void);
100
101 /* String */
102 char            *get_dash_string(char **);
103 char            *copy_string(char *);
104 Boolean         suffix(char *, char *);
105 void            nuke_suffix(char *);
106 void            str_lowercase(char *);
107
108 /* File */
109 Boolean         fexists(char *);
110 Boolean         isdir(char *);
111 Boolean         isempty(char *);
112 char            *get_file_contents(char *);
113 void            write_file(char *, char *);
114 void            copy_file(char *, char *, char *);
115 void            copy_hierarchy(char *, char *, Boolean);
116 int             delete_hierarchy(char *, Boolean);
117 int             unpack(char *, char *);
118 void            format_cmd(char *, char *, char *, char *);
119
120 /* Msg */
121 void            upchuck(const char *);
122 void            barf(const char *, ...);
123 void            whinge(const char *, ...);
124 Boolean         y_or_n(Boolean, const char *, ...);
125
126 /* Packing list */
127 PackingList     new_plist_entry(void);
128 PackingList     last_plist(Package *);
129 Boolean         in_plist(Package *, plist_t);
130 void            plist_delete(Package *, Boolean, plist_t, char *);
131 void            free_plist(Package *);
132 void            mark_plist(Package *);
133 void            csum_plist_entry(char *, PackingList);
134 void            add_plist(Package *, plist_t, char *);
135 void            add_plist_top(Package *, plist_t, char *);
136 void            write_plist(Package *, FILE *);
137 void            read_plist(Package *, FILE *);
138 int             plist_cmd(char *, char **);
139 void            delete_package(Boolean, Package *);
140
141 /* For all */
142 void            usage(const char *, const char *, ...);
143 int             pkg_perform(char **);
144
145 /* Externs */
146 extern Boolean  Verbose;
147 extern Boolean  Fake;
148
149 #endif /* _INST_LIB_LIB_H_ */