stand.h revision 0cfd5ff2ac90c4bdcb8581716c1a2cac17a5a7d4
/*
* Copyright (c) 1998 Michael Smith.
* All rights reserved.
*
* 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
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
* From $NetBSD: stand.h,v 1.22 1997/06/26 19:17:40 drochner Exp $
*/
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* 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
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)stand.h 8.1 (Berkeley) 6/11/93
*/
#ifndef STAND_H
#define STAND_H
/* this header intentionally exports NULL from <string.h> */
#include <string.h>
/* Avoid unwanted userlandish components */
#define _KERNEL
/* special stand error codes */
struct open_file;
/*
* This structure is used to define file system operations in a file system
* independent way.
*
* XXX note that filesystem providers should export a pointer to their fs_ops
* struct, so that consumers can reference this and thus include the
* filesystems that they require.
*/
struct fs_ops {
const char *fs_name;
};
/*
* libstand-supplied filesystems
*/
extern struct fs_ops tftp_fsops;
extern struct fs_ops cd9660_fsops;
extern struct fs_ops nandfs_fsops;
extern struct fs_ops gzipfs_fsops;
extern struct fs_ops bzipfs_fsops;
extern struct fs_ops dosfs_fsops;
extern struct fs_ops ext2fs_fsops;
extern struct fs_ops splitfs_fsops;
extern struct fs_ops pkgfs_fsops;
/* where values for lseek(2) */
#define SEEK_SET 0 /* set file offset to offset */
/*
* Device switch
*/
struct devsw {
const char dv_name[8];
int dv_type; /* opaque type constant, arch-dependant */
int (*dv_init)(void); /* early probe call */
void (*dv_cleanup)(void);
};
/*
* libstand-supplied device switch
*/
extern int errno;
/*
* Generic device specifier; architecture-dependent
* versions may be larger, but should be allowed to
* overlap.
*/
struct devdesc
{
int d_type;
#define DEVT_NONE 0
#define DEVT_DISK 1
#define DEVT_NET 2
#define DEVT_CD 3
#define DEVT_ZFS 4
int d_unit;
void *d_opendata;
};
struct open_file {
int f_flags; /* see F_* below */
void *f_devdata; /* device specific data */
void *f_fsdata; /* file system specific data */
char *f_rabuf; /* readahead buffer pointer */
#define SOPEN_RASIZE 512
};
#define SOPEN_MAX 64
/* f_flags values */
#define isascii(c) (((c) & ~0x7F) == 0)
{
return c >= 'A' && c <= 'Z';
}
{
return c >= 'a' && c <= 'z';
}
{
return c == ' ' || (c >= 0x9 && c <= 0xd);
}
{
return c >= '0' && c <= '9';
}
{
}
{
}
{
}
{
}
{
}
/* sbrk emulation */
/*#define free(p) {CHK("free %p", p); free(p);} */ /* use for catching guard violations */
extern void mallocstats(void);
extern void ngets(char *, int);
extern int open(const char *, int);
#define O_RDONLY 0x0
#define O_WRONLY 0x1
#define O_RDWR 0x2
extern int close(int);
extern void closeall(void);
/* imports from stdlib, locally modified */
extern long strtol(const char *, char **, int);
extern unsigned long strtoul(const char *, char **, int);
extern char *optarg; /* getopt(3) external variables */
extern int getopt(int, char * const [], const char *);
/* pager.c */
extern void pager_open(void);
extern void pager_close(void);
extern int pager_output(const char *lines);
extern int pager_file(const char *fname);
/* No signal state to preserve */
/* environment.c */
struct env_var;
const void *value);
struct env_var
{
char *ev_name;
int ev_flags;
void *ev_value;
};
int overwrite);
/* BCD conversions (undocumented) */
extern u_char const bcd2bin_data[];
extern u_char const bin2bcd_data[];
extern char const hex2ascii_data[];
/* null functions for device/filesystem switches (undocumented) */
extern int nodev(void);
extern void nullsys(void);
extern int null_close(struct open_file *f);
/*
* Machine dependent functions and data, must be provided or stubbed by
* the consumer
*/
extern int getchar(void);
extern int ischar(void);
extern void putchar(int);
extern struct fs_ops *file_system[];
extern struct fs_ops *exclusive_file_system;
/*
* Expose byteorder(3) functions.
*/
#ifndef _BYTEORDER_PROTOTYPED
#define _BYTEORDER_PROTOTYPED
#endif
#ifndef _BYTEORDER_FUNC_DEFINED
#define _BYTEORDER_FUNC_DEFINED
#endif
void Free(void *, const char *, int);
#if 1
#else
#endif
#endif /* STAND_H */