lib.h revision 1547
1/* $Id: lib.h,v 1.5 1994/04/05 14:08:46 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 73enum _plist_t { 74 PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD, 75 PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, 76 PLIST_IGNORE, PLIST_NAME, PLIST_UNEXEC 77}; 78typedef enum _plist_t plist_t; 79 80/* Types */ 81typedef unsigned int Boolean; 82 83struct _plist { 84 struct _plist *prev, *next; 85 char *name; 86 Boolean marked; 87 plist_t type; 88}; 89typedef struct _plist *PackingList; 90 91struct _pack { 92 struct _plist *head, *tail; 93}; 94typedef struct _pack Package; 95 96/* Prototypes */ 97/* Misc */ 98int vsystem(const char *, ...); 99void cleanup(int); 100char *make_playpen(char *); 101void leave_playpen(void); 102char *where_playpen(void); 103 104/* String */ 105char *get_dash_string(char **); 106char *copy_string(char *); 107Boolean suffix(char *, char *); 108void nuke_suffix(char *); 109void str_lowercase(char *); 110 111/* File */ 112Boolean fexists(char *); 113Boolean isdir(char *); 114Boolean isempty(char *); 115char *get_file_contents(char *); 116void write_file(char *, char *); 117void copy_file(char *, char *, char *); 118void copy_hierarchy(char *, char *, Boolean); 119int delete_hierarchy(char *, Boolean); 120int unpack(char *, char *); 121void format_cmd(char *, char *, char *, char *); 122 123/* Msg */ 124void upchuck(const char *); 125void barf(const char *, ...); 126void whinge(const char *, ...); 127Boolean y_or_n(Boolean, const char *, ...); 128 129/* Packing list */ 130PackingList new_plist_entry(void); 131PackingList last_plist(Package *); 132PackingList find_plist(Package *, plist_t); 133void plist_delete(Package *, Boolean, plist_t, char *); 134void free_plist(Package *); 135void mark_plist(Package *); 136void csum_plist_entry(char *, PackingList); 137void add_plist(Package *, plist_t, char *); 138void add_plist_top(Package *, plist_t, char *); 139void write_plist(Package *, FILE *); 140void read_plist(Package *, FILE *); 141int plist_cmd(char *, char **); 142void delete_package(Boolean, Package *); 143 144/* For all */ 145void usage(const char *, const char *, ...); 146int pkg_perform(char **); 147 148/* Externs */ 149extern Boolean Verbose; 150extern Boolean Fake; 151extern int AutoAnswer; 152 153#endif /* _INST_LIB_LIB_H_ */ 154