1995-04-26 15:08:23 +00:00
|
|
|
/* $Id: lib.h,v 1.15 1995/04/22 13:58:43 jkh Exp $ */
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* FreeBSD install - a package for the installation and maintainance
|
|
|
|
* of non-core utilities.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* Jordan K. Hubbard
|
|
|
|
* 18 July 1993
|
|
|
|
*
|
|
|
|
* Include and define various things wanted by the library routines.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INST_LIB_LIB_H_
|
|
|
|
#define _INST_LIB_LIB_H_
|
|
|
|
|
|
|
|
/* Includes */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
|
|
|
|
/* Macros */
|
|
|
|
#define SUCCESS (0)
|
|
|
|
#define FAIL (-1)
|
|
|
|
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE (1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE (0)
|
|
|
|
#endif
|
|
|
|
|
1994-04-05 14:08:47 +00:00
|
|
|
#define YES 2
|
|
|
|
#define NO 1
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
/* Usually "rm", but often "echo" during debugging! */
|
|
|
|
#define REMOVE_CMD "rm"
|
|
|
|
|
|
|
|
/* Usually "rm", but often "echo" during debugging! */
|
|
|
|
#define RMDIR_CMD "rmdir"
|
|
|
|
|
1995-04-19 14:02:01 +00:00
|
|
|
/* Where we put logging information by default, else ${PKG_DBDIR} if set */
|
|
|
|
#define DEF_LOG_DIR "/var/db/pkg"
|
|
|
|
/* just in case we change the environment variable name */
|
|
|
|
#define PKG_DBDIR "PKG_DBDIR"
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
/* The names of our "special" files */
|
|
|
|
#define CONTENTS_FNAME "+CONTENTS"
|
|
|
|
#define COMMENT_FNAME "+COMMENT"
|
|
|
|
#define DESC_FNAME "+DESC"
|
|
|
|
#define INSTALL_FNAME "+INSTALL"
|
|
|
|
#define DEINSTALL_FNAME "+DEINSTALL"
|
|
|
|
#define REQUIRE_FNAME "+REQUIRE"
|
1994-12-06 00:51:50 +00:00
|
|
|
#define REQUIRED_BY_FNAME "+REQUIRED_BY"
|
|
|
|
#define DISPLAY_FNAME "+DISPLAY"
|
|
|
|
#define MTREE_FNAME "+MTREE_DIRS"
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
#define CMD_CHAR '@' /* prefix for extended PLIST cmd */
|
|
|
|
|
1994-05-25 18:00:04 +00:00
|
|
|
/* The name of the "prefix" environment variable given to scripts */
|
|
|
|
#define PKG_PREFIX_VNAME "PKG_PREFIX"
|
1993-09-18 03:39:50 +00:00
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
enum _plist_t {
|
|
|
|
PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD,
|
|
|
|
PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT,
|
1994-12-06 00:51:50 +00:00
|
|
|
PLIST_IGNORE, PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY,
|
1995-04-22 07:41:02 +00:00
|
|
|
PLIST_PKGDEP, PLIST_MTREE, PLIST_DIR_RM, PLIST_IGNORE_INST,
|
|
|
|
PLIST_OPTION
|
1993-08-26 01:19:55 +00:00
|
|
|
};
|
|
|
|
typedef enum _plist_t plist_t;
|
|
|
|
|
|
|
|
/* Types */
|
|
|
|
typedef unsigned int Boolean;
|
|
|
|
|
|
|
|
struct _plist {
|
|
|
|
struct _plist *prev, *next;
|
|
|
|
char *name;
|
|
|
|
Boolean marked;
|
|
|
|
plist_t type;
|
|
|
|
};
|
|
|
|
typedef struct _plist *PackingList;
|
|
|
|
|
|
|
|
struct _pack {
|
|
|
|
struct _plist *head, *tail;
|
|
|
|
};
|
|
|
|
typedef struct _pack Package;
|
|
|
|
|
|
|
|
/* Prototypes */
|
|
|
|
/* Misc */
|
|
|
|
int vsystem(const char *, ...);
|
|
|
|
void cleanup(int);
|
1994-10-04 16:07:50 +00:00
|
|
|
char *make_playpen(char *, size_t);
|
1993-08-26 01:19:55 +00:00
|
|
|
void leave_playpen(void);
|
1993-09-05 04:54:24 +00:00
|
|
|
char *where_playpen(void);
|
1995-04-22 13:58:44 +00:00
|
|
|
long min_free(char *);
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
/* String */
|
|
|
|
char *get_dash_string(char **);
|
|
|
|
char *copy_string(char *);
|
|
|
|
Boolean suffix(char *, char *);
|
|
|
|
void nuke_suffix(char *);
|
|
|
|
void str_lowercase(char *);
|
1994-11-17 10:51:51 +00:00
|
|
|
char *basename_of(char *);
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
/* File */
|
|
|
|
Boolean fexists(char *);
|
|
|
|
Boolean isdir(char *);
|
|
|
|
Boolean isempty(char *);
|
1995-04-26 15:08:23 +00:00
|
|
|
Boolean isURL(char *);
|
|
|
|
char *fileGetURL(char *);
|
|
|
|
char *fileURLFilename(char *, char *, int);
|
|
|
|
char *fileURLHost(char *, char *, int);
|
|
|
|
char *fileFindByPath(char *);
|
|
|
|
char *fileGetContents(char *);
|
1993-08-26 01:19:55 +00:00
|
|
|
void write_file(char *, char *);
|
|
|
|
void copy_file(char *, char *, char *);
|
1995-04-22 13:58:44 +00:00
|
|
|
void move_file(char *, char *, char *);
|
1993-08-26 01:19:55 +00:00
|
|
|
void copy_hierarchy(char *, char *, Boolean);
|
1994-12-06 00:51:50 +00:00
|
|
|
int delete_hierarchy(char *, Boolean, Boolean);
|
1993-08-26 01:19:55 +00:00
|
|
|
int unpack(char *, char *);
|
1993-09-18 03:39:50 +00:00
|
|
|
void format_cmd(char *, char *, char *, char *);
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
/* Msg */
|
|
|
|
void upchuck(const char *);
|
|
|
|
void barf(const char *, ...);
|
|
|
|
void whinge(const char *, ...);
|
|
|
|
Boolean y_or_n(Boolean, const char *, ...);
|
|
|
|
|
|
|
|
/* Packing list */
|
|
|
|
PackingList new_plist_entry(void);
|
|
|
|
PackingList last_plist(Package *);
|
1994-05-25 06:27:24 +00:00
|
|
|
PackingList find_plist(Package *, plist_t);
|
1995-04-22 07:41:02 +00:00
|
|
|
char *find_plist_option(Package *, char *name);
|
1993-09-05 04:54:24 +00:00
|
|
|
void plist_delete(Package *, Boolean, plist_t, char *);
|
1993-08-26 01:19:55 +00:00
|
|
|
void free_plist(Package *);
|
|
|
|
void mark_plist(Package *);
|
|
|
|
void csum_plist_entry(char *, PackingList);
|
1993-09-03 23:01:17 +00:00
|
|
|
void add_plist(Package *, plist_t, char *);
|
|
|
|
void add_plist_top(Package *, plist_t, char *);
|
1993-08-26 01:19:55 +00:00
|
|
|
void write_plist(Package *, FILE *);
|
|
|
|
void read_plist(Package *, FILE *);
|
|
|
|
int plist_cmd(char *, char **);
|
1994-12-06 00:51:50 +00:00
|
|
|
int delete_package(Boolean, Boolean, Package *);
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
/* For all */
|
|
|
|
void usage(const char *, const char *, ...);
|
|
|
|
int pkg_perform(char **);
|
|
|
|
|
|
|
|
/* Externs */
|
|
|
|
extern Boolean Verbose;
|
|
|
|
extern Boolean Fake;
|
1994-04-05 14:08:47 +00:00
|
|
|
extern int AutoAnswer;
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
#endif /* _INST_LIB_LIB_H_ */
|