blob: 4ef15325e37c6fadca1692db1ae87a907f7832be [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Eric Andersen2b69c401999-10-05 22:58:32 +00002/*
Eric Andersenc4996011999-10-20 22:08:37 +00003 * Busybox main internal header file
Eric Andersen2b69c401999-10-05 22:58:32 +00004 *
Eric Andersen2b69c401999-10-05 22:58:32 +00005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
21 * Permission has been granted to redistribute this code under the GPL.
22 *
23 */
Erik Andersenfac10d72000-02-07 05:29:42 +000024#ifndef _BB_INTERNAL_H_
25#define _BB_INTERNAL_H_ 1
Eric Andersencc8ed391999-10-05 16:24:54 +000026
27#include "busybox.def.h"
28
29#include <stdlib.h>
Erik Andersen5509af72000-01-23 18:19:02 +000030#include <stdarg.h>
Eric Andersencc8ed391999-10-05 16:24:54 +000031#include <string.h>
32#include <unistd.h>
Eric Andersen10dc9d42000-06-26 10:45:52 +000033#include <errno.h>
Eric Andersencc8ed391999-10-05 16:24:54 +000034#include <sys/stat.h>
Erik Andersen4f3f7572000-04-28 00:18:56 +000035#include <sys/param.h>
Eric Andersen29d2e361999-11-06 06:07:27 +000036#include <mntent.h>
Mark Whitleydf5f6ba2000-07-11 16:53:56 +000037#include <regex.h>
Eric Andersencc8ed391999-10-05 16:24:54 +000038
39/* Some useful definitions */
Eric Andersenf811e071999-10-09 00:25:00 +000040#define FALSE ((int) 1)
41#define TRUE ((int) 0)
Eric Andersencc8ed391999-10-05 16:24:54 +000042
Erik Andersenfac10d72000-02-07 05:29:42 +000043/* for mtab.c */
44#define MTAB_GETMOUNTPT '1'
45#define MTAB_GETDEVICE '2'
46
Eric Andersencc8ed391999-10-05 16:24:54 +000047#define BUF_SIZE 8192
48#define EXPAND_ALLOC 1024
49
Erik Andersen298854f2000-03-23 01:09:18 +000050
Eric Andersencc8ed391999-10-05 16:24:54 +000051#define isBlank(ch) (((ch) == ' ') || ((ch) == '\t'))
52#define isDecimal(ch) (((ch) >= '0') && ((ch) <= '9'))
53#define isOctal(ch) (((ch) >= '0') && ((ch) <= '7'))
54#define isWildCard(ch) (((ch) == '*') || ((ch) == '?') || ((ch) == '['))
55
Erik Andersen4f3f7572000-04-28 00:18:56 +000056/* Macros for min/max. */
57#ifndef MIN
58#define MIN(a,b) (((a)<(b))?(a):(b))
59#endif
60
61#ifndef MAX
62#define MAX(a,b) (((a)>(b))?(a):(b))
63#endif
64
65
66/* I don't like nested includes, but the string and io functions are used
67 * too often
68 */
69#include <stdio.h>
70#if !defined(NO_STRING_H) || defined(STDC_HEADERS)
71# include <string.h>
72# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
73# include <memory.h>
74# endif
75# define memzero(s, n) memset ((void *)(s), 0, (n))
76#else
77# include <strings.h>
78# define strchr index
79# define strrchr rindex
80# define memcpy(d, s, n) bcopy((s), (d), (n))
81# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
82# define memzero(s, n) bzero((s), (n))
83#endif
84
85
Erik Andersend75af992000-03-16 08:09:09 +000086enum Location {
87 _BB_DIR_ROOT = 0,
88 _BB_DIR_BIN,
89 _BB_DIR_SBIN,
90 _BB_DIR_USR_BIN,
91 _BB_DIR_USR_SBIN
92};
Eric Andersencc8ed391999-10-05 16:24:54 +000093
Erik Andersenbcd61772000-05-13 06:33:19 +000094struct BB_applet {
Eric Andersencc8ed391999-10-05 16:24:54 +000095 const char* name;
96 int (*main)(int argc, char** argv);
Erik Andersend75af992000-03-16 08:09:09 +000097 enum Location location;
Eric Andersencc8ed391999-10-05 16:24:54 +000098};
Erik Andersenbcd61772000-05-13 06:33:19 +000099/* From busybox.c */
100extern const struct BB_applet applets[];
Eric Andersencc8ed391999-10-05 16:24:54 +0000101
Eric Andersen86ab8a32000-06-02 03:21:42 +0000102extern int ar_main(int argc, char **argv);
Erik Andersene2729152000-02-18 21:34:17 +0000103extern int basename_main(int argc, char **argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000104extern int busybox_main(int argc, char** argv);
Eric Andersene77ae3a1999-10-19 20:03:34 +0000105extern int cat_main(int argc, char** argv);
Eric Andersen1b61f411999-10-13 18:56:42 +0000106extern int chmod_chown_chgrp_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000107extern int chroot_main(int argc, char** argv);
Erik Andersen6f23cec1999-12-15 22:14:12 +0000108extern int chvt_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000109extern int clear_main(int argc, char** argv);
Erik Andersen7ab9c7e2000-05-12 19:41:47 +0000110extern int cp_mv_main(int argc, char** argv);
111extern int cut_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000112extern int date_main(int argc, char** argv);
John Beppu00216792000-06-21 19:06:16 +0000113extern int dc_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000114extern int dd_main(int argc, char** argv);
Erik Andersenfb002d02000-03-05 08:07:00 +0000115extern int dirname_main(int argc, char** argv);
Erik Andersen6f23cec1999-12-15 22:14:12 +0000116extern int deallocvt_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000117extern int df_main(int argc, char** argv);
118extern int dmesg_main(int argc, char** argv);
John Beppu7a986061999-12-09 18:29:29 +0000119extern int du_main(int argc, char** argv);
Eric Andersene77ae3a1999-10-19 20:03:34 +0000120extern int dutmp_main(int argc, char** argv);
Erik Andersend75af992000-03-16 08:09:09 +0000121extern int echo_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000122extern int false_main(int argc, char** argv);
Erik Andersen1c5b2581999-12-16 20:59:36 +0000123extern int fbset_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000124extern int fdisk_main(int argc, char** argv);
Eric Andersenf6be9441999-10-13 21:12:06 +0000125extern int fdflush_main(int argc, char **argv);
Eric Andersene494fdd1999-10-19 20:23:03 +0000126extern int fsck_minix_main(int argc, char **argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000127extern int find_main(int argc, char** argv);
Eric Andersenabc0f4f1999-12-08 23:19:36 +0000128extern int free_main(int argc, char** argv);
Erik Andersen64371702000-03-04 22:23:27 +0000129extern int freeramdisk_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000130extern int grep_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000131extern int gunzip_main (int argc, char** argv);
132extern int gzip_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000133extern int halt_main(int argc, char** argv);
John Beppu3157b1f1999-12-10 07:42:50 +0000134extern int head_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000135extern int hostid_main(int argc, char** argv);
Eric Andersen485b9551999-12-07 23:14:59 +0000136extern int hostname_main(int argc, char** argv);
Erik Andersen94f5e0b2000-05-01 19:10:52 +0000137extern int id_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000138extern int init_main(int argc, char** argv);
Erik Andersen6da0ae81999-12-17 01:08:27 +0000139extern int insmod_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000140extern int kill_main(int argc, char** argv);
141extern int length_main(int argc, char** argv);
142extern int ln_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000143extern int loadacm_main(int argc, char** argv);
Eric Andersen3e0fbae1999-10-19 06:02:44 +0000144extern int loadfont_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000145extern int loadkmap_main(int argc, char** argv);
146extern int losetup_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000147extern int logger_main(int argc, char **argv);
148extern int logname_main(int argc, char **argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000149extern int ls_main(int argc, char** argv);
Erik Andersen6f23cec1999-12-15 22:14:12 +0000150extern int lsmod_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000151extern int makedevs_main(int argc, char** argv);
Eric Andersen2b6ab3c2000-06-13 06:54:53 +0000152extern int md5sum_main(int argc, char** argv);
Eric Andersenf6be9441999-10-13 21:12:06 +0000153extern int mkdir_main(int argc, char** argv);
Eric Andersen19db07b1999-12-11 08:41:28 +0000154extern int mkfifo_main(int argc, char **argv);
155extern int mkfs_minix_main(int argc, char **argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000156extern int mknod_main(int argc, char** argv);
157extern int mkswap_main(int argc, char** argv);
Erik Andersen227a59b2000-04-25 23:24:55 +0000158extern int mktemp_main(int argc, char **argv);
Erik Andersen7ab9c7e2000-05-12 19:41:47 +0000159extern int nc_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000160extern int more_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000161extern int mount_main(int argc, char** argv);
162extern int mt_main(int argc, char** argv);
Erik Andersenfac10d72000-02-07 05:29:42 +0000163extern int nslookup_main(int argc, char **argv);
Eric Andersen485b9551999-12-07 23:14:59 +0000164extern int ping_main(int argc, char **argv);
Eric Andersen2cb55071999-12-10 08:25:07 +0000165extern int poweroff_main(int argc, char **argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000166extern int printf_main(int argc, char** argv);
Eric Andersenef8b6c71999-10-20 08:05:35 +0000167extern int ps_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000168extern int pwd_main(int argc, char** argv);
169extern int reboot_main(int argc, char** argv);
170extern int rm_main(int argc, char** argv);
Erik Andersen3d7e3411999-12-16 23:04:20 +0000171extern int rmdir_main(int argc, char **argv);
172extern int rmmod_main(int argc, char** argv);
Eric Andersenc1525e81999-10-29 00:07:31 +0000173extern int sed_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000174extern int sfdisk_main(int argc, char** argv);
Erik Andersen4f3f7572000-04-28 00:18:56 +0000175extern int setkeycodes_main(int argc, char** argv);
Erik Andersen3522eb12000-03-12 23:49:18 +0000176extern int shell_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000177extern int sleep_main(int argc, char** argv);
John Beppu019513a1999-12-22 17:57:31 +0000178extern int sort_main(int argc, char** argv);
Eric Andersen87590061999-10-18 21:22:59 +0000179extern int swap_on_off_main(int argc, char** argv);
Eric Andersene77ae3a1999-10-19 20:03:34 +0000180extern int sync_main(int argc, char** argv);
Eric Andersen3843e961999-11-25 07:30:46 +0000181extern int syslogd_main(int argc, char **argv);
Eric Andersenabc0f4f1999-12-08 23:19:36 +0000182extern int tail_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000183extern int tar_main(int argc, char** argv);
John Beppu059f1521999-12-10 05:27:16 +0000184extern int tee_main(int argc, char** argv);
Erik Andersend75af992000-03-16 08:09:09 +0000185extern int test_main(int argc, char** argv);
Erik Andersenf7c49ef2000-02-22 17:17:45 +0000186extern int telnet_main(int argc, char** argv);
Eric Andersen596e5461999-10-07 08:30:23 +0000187extern int touch_main(int argc, char** argv);
Erik Andersenfb002d02000-03-05 08:07:00 +0000188extern int tr_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000189extern int true_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000190extern int tput_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000191extern int tryopen_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000192extern int tty_main(int argc, char** argv);
Eric Andersen2b6ab3c2000-06-13 06:54:53 +0000193extern int uuencode_main(int argc, char** argv);
194extern int uudecode_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000195extern int umount_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000196extern int uname_main(int argc, char** argv);
Erik Andersen66be5e72000-03-05 07:52:05 +0000197extern int uptime_main(int argc, char** argv);
John Beppuabb47722000-01-06 00:48:21 +0000198extern int uniq_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000199extern int update_main(int argc, char** argv);
Erik Andersenb99ca132000-04-04 18:49:18 +0000200extern int usleep_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000201extern int wc_main(int argc, char** argv);
Erik Andersen330fd2b2000-05-19 05:35:19 +0000202extern int which_main(int argc, char** argv);
Erik Andersen31638212000-01-15 22:28:50 +0000203extern int whoami_main(int argc, char** argv);
204extern int yes_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000205
Eric Andersen2b69c401999-10-05 22:58:32 +0000206
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000207extern void usage(const char *usage) __attribute__ ((noreturn));
Erik Andersen93d65132000-04-06 08:06:36 +0000208extern void errorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
209extern void fatalError(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000210
Eric Andersen2b69c401999-10-05 22:58:32 +0000211const char *modeString(int mode);
212const char *timeString(time_t timeVal);
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000213int isDirectory(const char *name, const int followLinks, struct stat *statBuf);
Eric Andersenf811e071999-10-09 00:25:00 +0000214int isDevice(const char *name);
Erik Andersen029011b2000-03-04 21:19:32 +0000215
216typedef struct ino_dev_hash_bucket_struct {
217 struct ino_dev_hash_bucket_struct *next;
218 ino_t ino;
219 dev_t dev;
220 char name[1];
221} ino_dev_hashtable_bucket_t;
222int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
223void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
224void reset_ino_dev_hashtable(void);
225
Erik Andersen59b9e872000-05-10 05:05:45 +0000226int copyFile(const char *srcName, const char *destName,
227 int setModes, int followLinks, int forceFlag);
Eric Andersenf811e071999-10-09 00:25:00 +0000228char *buildName(const char *dirName, const char *fileName);
229int makeString(int argc, const char **argv, char *buf, int bufLen);
Eric Andersen2b69c401999-10-05 22:58:32 +0000230char *getChunk(int size);
231char *chunkstrdup(const char *str);
232void freeChunks(void);
233int fullWrite(int fd, const char *buf, int len);
234int fullRead(int fd, char *buf, int len);
Eric Andersen63a0e531999-10-22 05:12:14 +0000235int recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst,
Erik Andersen3364d782000-03-28 00:58:14 +0000236 int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
237 int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
238 void* userData);
Eric Andersen17d49ef1999-10-06 20:25:32 +0000239const char* timeString(time_t timeVal);
Eric Andersencc8ed391999-10-05 16:24:54 +0000240
Erik Andersen06936df2000-01-23 02:14:20 +0000241extern int createPath (const char *name, int mode);
Eric Andersenf6be9441999-10-13 21:12:06 +0000242extern int parse_mode( const char* s, mode_t* theMode);
Eric Andersenb0e9a701999-10-18 22:28:26 +0000243
Erik Andersen1ad302a2000-03-24 00:54:46 +0000244extern int get_kernel_revision(void);
Erik Andersen94f5e0b2000-05-01 19:10:52 +0000245
Eric Andersen0460ff21999-10-25 23:32:44 +0000246extern int get_console_fd(char* tty_name);
Eric Andersen29d2e361999-11-06 06:07:27 +0000247extern struct mntent *findMountPoint(const char *name, const char *table);
Eric Andersend0246fb1999-11-04 21:18:07 +0000248extern void write_mtab(char* blockDevice, char* directory,
249 char* filesystemType, long flags, char* string_flags);
250extern void erase_mtab(const char * name);
Erik Andersenfac10d72000-02-07 05:29:42 +0000251extern void mtab_read(void);
Erik Andersenfac10d72000-02-07 05:29:42 +0000252extern char *mtab_first(void **iter);
253extern char *mtab_next(void **iter);
254extern char *mtab_getinfo(const char *match, const char which);
Eric Andersenb186d981999-12-03 09:19:54 +0000255extern int check_wildcard_match(const char* text, const char* pattern);
Eric Andersen1792f8c1999-12-09 06:11:36 +0000256extern long getNum (const char *cp);
Erik Andersen825aead2000-04-07 06:00:07 +0000257extern pid_t* findPidByName( char* pidName);
Erik Andersenec5bd902000-03-22 07:12:05 +0000258extern int find_real_root_device_name(char* name);
Mark Whitley1ca41772000-06-28 22:15:26 +0000259extern char *get_line_from_file(FILE *file);
Eric Andersenf7cf2f72000-07-05 17:26:35 +0000260extern char process_escape_sequence(char **ptr);
Eric Andersen0b4551f2000-07-10 16:44:03 +0000261extern char *get_last_path_component(char *path);
Mark Whitleydf5f6ba2000-07-11 16:53:56 +0000262extern int bb_regcomp(regex_t *preg, const char *regex, int cflags);
John Beppu5a728cf2000-04-17 04:22:09 +0000263
Eric Andersenda1d1e72000-07-10 23:39:44 +0000264extern void *xmalloc (size_t size);
265extern char *xstrdup (const char *s);
266extern char *xstrndup (const char *s, int n);
267
268
Erik Andersen94f5e0b2000-05-01 19:10:52 +0000269/* These parse entries in /etc/passwd and /etc/group. This is desirable
270 * for BusyBox since we want to avoid using the glibc NSS stuff, which
271 * increases target size and is often not needed embedded systems. */
Erik Andersen5b46d792000-05-17 05:24:24 +0000272extern unsigned long my_getpwnam(char *name);
273extern unsigned long my_getgrnam(char *name);
274extern void my_getpwuid(char *name, unsigned long uid);
275extern void my_getgrgid(char *group, unsigned long gid);
276extern unsigned long my_getpwnamegid(char *name);
Erik Andersen94f5e0b2000-05-01 19:10:52 +0000277
Erik Andersenec5bd902000-03-22 07:12:05 +0000278
Erik Andersen31cf8e02000-02-07 20:31:19 +0000279#if defined BB_INIT || defined BB_SYSLOGD
Erik Andersend0480c22000-02-07 20:35:14 +0000280extern int device_open(char *device, int mode);
Erik Andersen31cf8e02000-02-07 20:31:19 +0000281#endif
Erik Andersen5cbdd712000-01-26 20:06:48 +0000282#if defined BB_FEATURE_MOUNT_LOOP
283extern int del_loop(const char *device);
Erik Andersende7965c2000-01-26 23:49:21 +0000284extern int set_loop(const char *device, const char *file, int offset, int *loopro);
285extern char *find_unused_loop_device (void);
Erik Andersen5cbdd712000-01-26 20:06:48 +0000286#endif
287
Erik Andersen3fe39dc2000-01-25 18:13:53 +0000288
Erik Andersen5509af72000-01-23 18:19:02 +0000289#if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
Erik Andersen7dc16072000-01-04 01:10:25 +0000290extern int vdprintf(int d, const char *format, va_list ap);
291#endif
Eric Andersene674eb71999-10-19 20:52:57 +0000292
Eric Andersena9c95ea1999-11-15 17:33:30 +0000293#if defined BB_NFSMOUNT
294int nfsmount(const char *spec, const char *node, unsigned long *flags,
295 char **extra_opts, char **mount_opts, int running_bg);
296#endif
Eric Andersen29d2e361999-11-06 06:07:27 +0000297
Erik Andersen31638212000-01-15 22:28:50 +0000298#ifndef RB_POWER_OFF
Eric Andersen74c66ad2000-06-16 19:57:44 +0000299/* Stop system and switch power off if possible. */
Erik Andersen31638212000-01-15 22:28:50 +0000300#define RB_POWER_OFF 0x4321fedc
301#endif
302
Eric Andersen10dc9d42000-06-26 10:45:52 +0000303/* Include our own copy of struct sysinfo to avoid binary compatability
304 * problems with Linux 2.4, which changed things. Grumble, grumble. */
305struct sysinfo {
306 long uptime; /* Seconds since boot */
307 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
308 unsigned long totalram; /* Total usable main memory size */
309 unsigned long freeram; /* Available memory size */
310 unsigned long sharedram; /* Amount of shared memory */
311 unsigned long bufferram; /* Memory used by buffers */
312 unsigned long totalswap; /* Total swap space size */
313 unsigned long freeswap; /* swap space still available */
314 unsigned short procs; /* Number of current processes */
315 unsigned long totalhigh; /* Total high memory size */
316 unsigned long freehigh; /* Available high memory size */
317 unsigned int mem_unit; /* Memory unit size in bytes */
318 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
319};
320extern int sysinfo (struct sysinfo* info);
Eric Andersenaa0765e1999-10-22 04:30:20 +0000321
Eric Andersenbd4a75f2000-06-19 20:03:48 +0000322/* Bit map related macros -- libc5 doens't provide these... sigh. */
Eric Andersen10dc9d42000-06-26 10:45:52 +0000323#ifndef setbit
Eric Andersenbd4a75f2000-06-19 20:03:48 +0000324#define NBBY CHAR_BIT
325#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
326#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
327#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
328#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
329#endif
330
Erik Andersenfac10d72000-02-07 05:29:42 +0000331#endif /* _BB_INTERNAL_H_ */