diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.in | 26 | ||||
-rw-r--r-- | include/dpkg-db.h | 272 | ||||
-rw-r--r-- | include/dpkg.h | 179 | ||||
-rw-r--r-- | include/myopt.h | 38 | ||||
-rw-r--r-- | include/tarfn.h | 57 |
5 files changed, 572 insertions, 0 deletions
diff --git a/include/Makefile.in b/include/Makefile.in new file mode 100644 index 000000000..b2c0ddc89 --- /dev/null +++ b/include/Makefile.in @@ -0,0 +1,26 @@ +# Copyright (C) 1994 Ian Murdock <imurdock@debian.org> +# Copyright (C) 1994,1995 Ian Jackson <ijackson@nyx.cs.du.edu> +# +# This is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2, +# or (at your option) any later version. +# +# This is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with dpkg; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +all: + +clean: + rm -f core + +distclean: clean + rm -f Makefile *.orig *~ *.~* ./#*# + +install: all diff --git a/include/dpkg-db.h b/include/dpkg-db.h new file mode 100644 index 000000000..591885884 --- /dev/null +++ b/include/dpkg-db.h @@ -0,0 +1,272 @@ +/* + * libdpkg - Debian packaging suite library routines + * dpkg-db.h - declarations for in-core package database management + * + * Copyright (C) 1994,1995 Ian Jackson <iwj10@cus.cam.ac.uk> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with dpkg; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef DPKG_DB_H +#define DPKG_DB_H + +#include <stdio.h> +#include <stdlib.h> + +enum deptype { + dep_suggests, + dep_recommends, + dep_depends, + dep_predepends, + dep_conflicts, + dep_provides, + dep_replaces +}; + +struct dependency { /* dy */ + struct pkginfo *up; + struct dependency *next; + struct deppossi *list; + enum deptype type; +}; + +struct deppossi { /* do */ + struct dependency *up; + struct pkginfo *ed; + struct deppossi *next, *nextrev, *backrev; + enum depverrel { + dvrf_earlier= 0001, + dvrf_later= 0002, + dvrf_strict= 0010, + dvrf_orequal= 0020, + dvrf_builtup= 0100, + dvr_none= 0200, + dvr_earlierequal= dvrf_builtup | dvrf_earlier | dvrf_orequal, + dvr_earlierstrict= dvrf_builtup | dvrf_earlier | dvrf_strict, + dvr_laterequal= dvrf_builtup | dvrf_later | dvrf_orequal, + dvr_laterstrict= dvrf_builtup | dvrf_later | dvrf_strict, + dvr_exact= 0400 + } verrel; + char *version, *revision; + int cyclebreak; +}; + +struct arbitraryfield { + struct arbitraryfield *next; + char *name; + char *value; +}; + +struct conffile { + struct conffile *next; + char *name; + char *hash; +}; + +struct filedetails { + struct filedetails *next; + char *name, *msdosname, *size, *md5sum; +}; + +struct pkginfoperfile { /* pif */ + int valid; + struct dependency *depends; + struct deppossi *depended; + int essential; /* The `essential' flag, 1=yes, 0=no (absent) */ + char *description, *maintainer, *version, *revision, *source, *architecture; + struct conffile *conffiles; + struct arbitraryfield *arbs; +}; + +struct perpackagestate; /* used by dselect only, but we keep a pointer here */ + +struct pkginfo { /* pig */ + struct pkginfo *next; + char *name; + enum pkgwant { + want_unknown, want_install, want_deinstall, want_purge + } want; + enum pkgeflag { + eflagv_ok=00, eflagv_hold=01, eflagv_reinstreq=02, eflagv_both=03, + eflagf_hold=01, eflagf_reinstreq=02 + } eflag; /* bitmask */ + enum pkgstatus { + stat_notinstalled, stat_unpacked, stat_halfconfigured, + stat_installed, stat_halfinstalled, stat_configfiles + } status; + enum pkgpriority { + pri_required, pri_important, pri_standard, pri_recommended, + pri_optional, pri_extra, pri_contrib, + pri_other, pri_unknown, pri_unset=-1 + } priority; + char *otherpriority; + char *section; + char *configversion, *configrevision; + struct filedetails *files; + struct pkginfoperfile installed; + struct pkginfoperfile available; + struct perpackagestate *clientdata; +}; + +/*** from lock.c ***/ + +void lockdatabase(const char *admindir); +void unlockdatabase(const char *admindir); + +/*** from dbmodify.c ***/ + +enum modstatdb_rw { + /* Those marked with \*s*\ are possible returns from modstatdb_init. */ + msdbrw_readonly/*s*/, msdbrw_needsuperuserlockonly/*s*/, + msdbrw_writeifposs, + msdbrw_write/*s*/, msdbrw_needsuperuser, + /* Now some optional flags: */ + msdbrw_flagsmask= ~077, + /* Prefer later versions from `status' in `available' info, but do not + * save `available' info: */ + msdbrw_availablepreferversion= 0100 +}; + +enum modstatdb_rw modstatdb_init(const char *admindir, enum modstatdb_rw reqrwflags); +void modstatdb_note(struct pkginfo *pkg); +void modstatdb_shutdown(void); + +extern char *statusfile, *availablefile; /* initialised by modstatdb_init */ + +/*** from database.c ***/ + +struct pkginfo *findpackage(const char *name); +void blankpackage(struct pkginfo *pp); +void blankpackageperfile(struct pkginfoperfile *pifp); +int informative(struct pkginfo *info); +int informativeperfile(struct pkginfoperfile *info); +int countpackages(void); +void resetpackages(void); + +struct pkgiterator *iterpkgstart(void); +struct pkginfo *iterpkgnext(struct pkgiterator*); +void iterpkgend(struct pkgiterator*); + +void hashreport(FILE*); + +/*** from parse.c ***/ + +enum parsedbflags { + pdb_recordavailable =001, /* Store in `available' in-core structures, not `status' */ + pdb_rejectstatus =002, /* Throw up an error if `Status' encountered */ + pdb_weakclassification=004, /* Ignore priority/section info if we already have any */ + pdb_preferversion= 010 /* Discard information about earlier versions */ +}; + +const char *illegal_packagename(const char *p, const char **ep); +int parsedb(const char *filename, enum parsedbflags, struct pkginfo **donep, + FILE *warnto, int *warncount); +void copy_dependency_links(struct pkginfo *pkg, + struct dependency **updateme, + struct dependency *newdepends, + int available); + +/*** from parsehelp.c ***/ + +struct namevalue { + const char *name; + int value; +}; + +extern const struct namevalue booleaninfos[]; +extern const struct namevalue priorityinfos[]; +extern const struct namevalue statusinfos[]; +extern const struct namevalue eflaginfos[]; +extern const struct namevalue wantinfos[]; + +const char *skip_slash_dotslash(const char *p); + +/*** from varbuf.c ***/ + +struct varbuf; + +extern void varbufaddc(struct varbuf *v, int c); +void varbufinit(struct varbuf *v); +void varbufreset(struct varbuf *v); +void varbufextend(struct varbuf *v); +void varbuffree(struct varbuf *v); +void varbufaddstr(struct varbuf *v, const char *s); + +/* varbufinit must be called exactly once before the use of each varbuf + * (including before any call to varbuffree). + * + * However, varbufs allocated `static' are properly initialised anyway and + * do not need varbufinit; multiple consecutive calls to varbufinit before + * any use are allowed. + * + * varbuffree must be called after a varbuf is finished with, if anything + * other than varbufinit has been done. After this you are allowed but + * not required to call varbufinit again if you want to start using the + * varbuf again. + * + * Callers using C++ need not worry about any of this. + */ +struct varbuf { + int used, size; + char *buf; + +#ifdef __cplusplus + void init() { varbufinit(this); } + void free() { varbuffree(this); } + varbuf() { varbufinit(this); } + ~varbuf() { varbuffree(this); } + inline void operator()(int c); // definition below + void operator()(const char *s) { varbufaddstr(this,s); } + inline void terminate(void/*to shut 2.6.3 up*/); // definition below + void reset() { used=0; } + const char *string() { terminate(); return buf; } +#endif +}; + +#if HAVE_INLINE +inline extern void varbufaddc(struct varbuf *v, int c) { + if (v->used >= v->size) varbufextend(v); + v->buf[v->used++]= c; +} +#endif + +#ifdef __cplusplus +inline void varbuf::operator()(int c) { varbufaddc(this,c); } +inline void varbuf::terminate(void/*to shut 2.6.3 up*/) { varbufaddc(this,0); used--; } +#endif + +/*** from dump.c ***/ + +void writerecord(FILE*, const char*, + const struct pkginfo*, const struct pkginfoperfile*); + +void writedb(const char *filename, int available, int mustsync); + +void varbufrecord(struct varbuf*, const struct pkginfo*, const struct pkginfoperfile*); +void varbufdependency(struct varbuf *vb, struct dependency *dep); + /* NB THE VARBUF MUST HAVE BEEN INITIALISED AND WILL NOT BE NULL-TERMINATED */ + +/*** from vercmp.c ***/ + +int versioncompare(const char *version, const char *revision, + const char *refversion, const char *refrevision); + +/*** from nfmalloc.c ***/ + +void *nfmalloc(size_t); +char *nfstrsave(const char*); +void nffreeall(void); + +#endif /* DPKG_DB_H */ diff --git a/include/dpkg.h b/include/dpkg.h new file mode 100644 index 000000000..937c535fc --- /dev/null +++ b/include/dpkg.h @@ -0,0 +1,179 @@ + +/* + * libdpkg - Debian packaging suite library routines + * dpkg.h - general header for Debian package handling + * + * Copyright (C) 1994,1995 Ian Jackson <iwj10@cus.cam.ac.uk> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with dpkg; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef DPKG_H +#define DPKG_H + +#include <setjmp.h> +#include <stdarg.h> +#include <stdio.h> +#include <sys/types.h> + +#define ARCHIVEVERSION "2.0" +#define SPLITVERSION "2.1" +#define OLDARCHIVEVERSION "0.939000" +#define SPLITPARTDEFMAX (450*1024) +#define MAXFIELDNAME 200 +#define MAXCONFFILENAME 1000 +#define MAXDIVERTFILENAME 1024 +#define MAXCONTROLFILENAME 100 +#define BUILDCONTROLDIR "DEBIAN" +#define EXTRACTCONTROLDIR BUILDCONTROLDIR +#define DEBEXT ".deb" +#define OLDDBEXT "-old" +#define NEWDBEXT "-new" +#define OLDOLDDEBDIR ".DEBIAN" +#define OLDDEBDIR "DEBIAN" +#define REMOVECONFFEXTS "~", ".bak", "%", \ + DPKGTEMPEXT, DPKGNEWEXT, DPKGOLDEXT, DPKGDISTEXT + +#define DPKG_VERSION_ARCH DPKG_VERSION " (" ARCHITECTURE ")" + +#define NEWCONFFILEFLAG "newconffile" +#define NONEXISTENTFLAG "nonexistent" + +#define DPKGTEMPEXT ".dpkg-tmp" +#define DPKGNEWEXT ".dpkg-new" +#define DPKGOLDEXT ".dpkg-old" +#define DPKGDISTEXT ".dpkg-dist" + +#define CONTROLFILE "control" +#define CONFFILESFILE "conffiles" +#define PREINSTFILE "preinst" +#define POSTINSTFILE "postinst" +#define PRERMFILE "prerm" +#define POSTRMFILE "postrm" +#define LISTFILE "list" + +#define ADMINDIR "/var/lib/dpkg" +#define STATUSFILE "status" +#define AVAILFILE "available" +#define LOCKFILE "lock" +#define CMETHOPTFILE "cmethopt" +#define METHLOCKFILE "methlock" +#define DIVERSIONSFILE "diversions" +#define UPDATESDIR "updates/" +#define INFODIR "info/" +#define PARTSDIR "parts/" +#define CONTROLDIRTMP "tmp.ci/" +#define IMPORTANTTMP "tmp.i" +#define REASSEMBLETMP "reassemble" DEBEXT +#define IMPORTANTMAXLEN 10 +#define IMPORTANTFMT "%04d" /* change => also change lib/database.c:cleanup_updates */ +#define MAXUPDATES 50 + +#define LIBDIR "/usr/lib/dpkg" +#define LOCALLIBDIR "/usr/local/lib/dpkg" +#define METHODSDIR "methods" + +#define NOJOBCTRLSTOPENV "DPKG_NO_TSTP" +#define SHELLENV "SHELL" +#define DEFAULTSHELL "sh" + +#define IMETHODMAXLEN 50 +#define IOPTIONMAXLEN IMETHODMAXLEN +#define METHODOPTIONSFILE "names" +#define METHODSETUPSCRIPT "setup" +#define METHODUPDATESCRIPT "update" +#define METHODINSTALLSCRIPT "install" +#define OPTIONSDESCPFX "desc." +#define OPTIONINDEXMAXLEN 5 + +#define PKGSCRIPTMAXARGS 10 +#define MD5HASHLEN 32 + +#define CONFFOPTCELLS /* int conffoptcells[2] {* 1= user edited *} \ + [2] {* 1= distributor edited *} = */ \ + /* dist not */ /* dist edited */ \ + /* user did not edit */ { cfo_keep, cfo_install }, \ + /* user did edit */ { cfo_keep, cfo_prompt_keep } + +#define ARCHIVE_FILENAME_PATTERN "*.deb" + +#define BACKEND "dpkg-deb" +#define SPLITTER "dpkg-split" +#define MD5SUM "md5sum" +#define DSELECT "dselect" +#define DPKG "dpkg" + +#define TAR "tar" +#define GZIP "gzip" +#define CAT "cat" +#define RM "rm" +#define FIND "find" +#define SHELL "sh" + +#define SHELLENVIR "SHELL" + +#define FIND_EXPRSTARTCHARS "-(),!" + +#define TARBLKSZ 512 + +extern const char thisname[]; /* defined separately in each program */ +extern const char printforhelp[]; + +/*** from ehandle.c ***/ + +void push_error_handler(jmp_buf *jbufp, + void (*printerror)(const char *, const char *), + const char *contextstring); +void set_error_display(void (*printerror)(const char *, const char *), + const char *contextstring); +void print_error_fatal(const char *emsg, const char *contextstring); +void error_unwind(int flagset); +void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1, + void (*f2)(int argc, void **argv), int flagmask2, + int nargs, ...); +void push_checkpoint(int mask, int value); +void pop_cleanup(int flagset); +enum { ehflag_normaltidy=01, ehflag_bombout=02, ehflag_recursiveerror=04 }; + +void do_internerr(const char *string, int line, const char *file) NONRETURNING; +#define internerr(s) do_internerr(s,__LINE__,__FILE__) + +struct varbuf; +void ohshit(const char *fmt, ...) NONRETURNPRINTFFORMAT(1,2); +void ohshitv(const char *fmt, va_list al) NONRETURNING; +void ohshite(const char *fmt, ...) NONRETURNPRINTFFORMAT(1,2); +void ohshitvb(struct varbuf*) NONRETURNING; +void badusage(const char *fmt, ...) NONRETURNPRINTFFORMAT(1,2); +void werr(const char *what) NONRETURNING; + +/*** from mlib.c ***/ + +void *m_malloc(size_t); +void *m_realloc(void*, size_t); +int m_fork(void); +void m_dup2(int oldfd, int newfd); +void m_pipe(int fds[2]); + +void checksubprocerr(int status, const char *description, int sigpipeok); +void waitsubproc(pid_t pid, const char *description, int sigpipeok); + +extern volatile int onerr_abort; + +/*** from showcright.c ***/ + +struct cmdinfo; +void showcopyright(const struct cmdinfo*, const char*); + +#endif /* DPKG_H */ diff --git a/include/myopt.h b/include/myopt.h new file mode 100644 index 000000000..f7984d290 --- /dev/null +++ b/include/myopt.h @@ -0,0 +1,38 @@ +/* + * libdpkg - Debian packaging suite library routines + * myopt.h - declarations for my very own option parsing + * + * Copyright (C) 1994,1995 Ian Jackson <iwj10@cus.cam.ac.uk> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this file; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef MYOPT_H +#define MYOPT_H + +struct cmdinfo { + const char *olong; + char oshort; + int takesvalue; /* 0 = normal 1 = standard value 2 = option string cont */ + int *iassignto; + const char **sassignto; + void (*call)(const struct cmdinfo*, const char *value); + int arg; + void *parg; +}; + +void myopt(const char *const **argvp, const struct cmdinfo *cmdinfos); + +#endif /* MYOPT_H */ diff --git a/include/tarfn.h b/include/tarfn.h new file mode 100644 index 000000000..5e387b07b --- /dev/null +++ b/include/tarfn.h @@ -0,0 +1,57 @@ +#ifndef _TAR_FUNCTION_H_ +#define _TAR_FUNCTION_H_ + +/* + * Functions for extracting tar archives. + * Bruce Perens, April-May 1995 + * Copyright (C) 1995 Bruce Perens + * This is free software under the GNU General Public License. + */ + +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> + +enum TarFileType { + NormalFile0 = '\0', /* For compatibility with decades-old bug */ + NormalFile1 = '0', + HardLink = '1', + SymbolicLink = '2', + CharacterDevice = '3', + BlockDevice = '4', + Directory = '5', + FIFO = '6' +}; +typedef enum TarFileType TarFileType; + +struct TarInfo { + void * UserData; /* User passed this in as argument */ + char * Name; /* File name */ + mode_t Mode; /* Unix mode, including device bits. */ + size_t Size; /* Size of file */ + time_t ModTime; /* Last-modified time */ + TarFileType Type; /* Regular, Directory, Special, Link */ + char * LinkName; /* Name for symbolic and hard links */ + dev_t Device; /* Special device for mknod() */ + uid_t UserID; /* Numeric UID */ + gid_t GroupID; /* Numeric GID */ +}; +typedef struct TarInfo TarInfo; + +typedef int (*TarReadFunction)(void * userData, char * buffer, int length); + +typedef int (*TarFunction)(TarInfo * h); + +struct TarFunctions { + TarReadFunction Read; + TarFunction ExtractFile; + TarFunction MakeDirectory; + TarFunction MakeHardLink; + TarFunction MakeSymbolicLink; + TarFunction MakeSpecialFile; +}; +typedef struct TarFunctions TarFunctions; + +extern int TarExtractor(void * userData, const TarFunctions * functions); + +#endif |