1142425Snectar/* $NetBSD: prog_ops.h,v 1.2 2010/12/13 19:19:10 pooka Exp $ */ 2160814Ssimon 3142425Snectar/* 4142425Snectar * Copyright (c) 2010 The NetBSD Foundation, Inc. 5142425Snectar * All rights reserved. 6142425Snectar * 7142425Snectar * Redistribution and use in source and binary forms, with or without 8142425Snectar * modification, are permitted provided that the following conditions 9142425Snectar * are met: 10142425Snectar * 1. Redistributions of source code must retain the above copyright 11142425Snectar * notice, this list of conditions and the following disclaimer. 12142425Snectar * 2. Redistributions in binary form must reproduce the above copyright 13142425Snectar * notice, this list of conditions and the following disclaimer in the 14142425Snectar * documentation and/or other materials provided with the distribution. 15142425Snectar * 16142425Snectar * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17142425Snectar * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18160814Ssimon * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19142425Snectar * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20142425Snectar * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21160814Ssimon * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22142425Snectar * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23142425Snectar * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24142425Snectar * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25160814Ssimon * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26160814Ssimon * POSSIBILITY OF SUCH DAMAGE. 27142425Snectar */ 28142425Snectar 29142425Snectar#ifndef _PROG_OPS_H_ 30142425Snectar#define _PROG_OPS_H_ 31142425Snectar 32142425Snectar#include <sys/types.h> 33142425Snectar 34142425Snectar#ifndef CRUNCHOPS 35142425Snectarstruct prog_ops { 36142425Snectar int (*op_init)(void); 37142425Snectar 38142425Snectar int (*op_socket)(int, int, int); 39142425Snectar int (*op_setsockopt)(int, int, int, const void *, socklen_t); 40142425Snectar int (*op_shutdown)(int, int); 41238405Sjkim 42142425Snectar int (*op_poll)(struct pollfd *, nfds_t, int); 43142425Snectar 44142425Snectar ssize_t (*op_recvfrom)(int, void *, size_t, int, 45238405Sjkim struct sockaddr *, socklen_t *); 46238405Sjkim ssize_t (*op_sendto)(int, const void *, size_t, int, 47238405Sjkim const struct sockaddr *, socklen_t); 48238405Sjkim 49238405Sjkim int (*op_close)(int); 50238405Sjkim 51142425Snectar uid_t (*op_getuid)(void); 52160814Ssimon int (*op_setuid)(uid_t); 53194206Ssimon}; 54160814Ssimonextern const struct prog_ops prog_ops; 55160814Ssimon 56160814Ssimon#define prog_init prog_ops.op_init 57160814Ssimon#define prog_socket prog_ops.op_socket 58142425Snectar#define prog_setsockopt prog_ops.op_setsockopt 59238405Sjkim#define prog_shutdown prog_ops.op_shutdown 60238405Sjkim#define prog_poll prog_ops.op_poll 61238405Sjkim#define prog_recvfrom prog_ops.op_recvfrom 62238405Sjkim#define prog_sendto prog_ops.op_sendto 63264331Sjkim#define prog_close prog_ops.op_close 64264331Sjkim#define prog_getuid prog_ops.op_getuid 65264331Sjkim#define prog_setuid prog_ops.op_setuid 66238405Sjkim#else 67194206Ssimon#define prog_init ((int (*)(void))NULL) 68238405Sjkim#define prog_socket socket 69238405Sjkim#define prog_setsockopt setsockopt 70238405Sjkim#define prog_shutdown shutdown 71238405Sjkim#define prog_poll poll 72238405Sjkim#define prog_recvfrom recvfrom 73238405Sjkim#define prog_sendto sendto 74194206Ssimon#define prog_close close 75238405Sjkim#define prog_getuid getuid 76238405Sjkim#define prog_setuid setuid 77238405Sjkim#endif 78238405Sjkim 79238405Sjkim#endif /* _PROG_OPS_H_ */ 80238405Sjkim