/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1989-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Eduardo Krell <[email protected]> *19* *20***********************************************************************/21#pragma prototyped2223#include <sys/types.h>2425#if _stream_peek26#include <ast_tty.h>27#include <stropts.h>28#endif2930#if _socket_peek31#include <sys/socket.h>32#endif3334int35main()36{37int fds[2];38static char msg[] = "test";39#if _stream_peek40struct strpeek pk;41#endif4243if (pipe(fds) || write(fds[1], msg, sizeof(msg)) != sizeof(msg))44return(0);45#if _stream_peek46pk.flags = 0;47pk.ctlbuf.maxlen = -1;48pk.ctlbuf.len = 0;49pk.ctlbuf.buf = 0;50pk.databuf.maxlen = sizeof(msg);51pk.databuf.buf = msg;52pk.databuf.len = 0;53if (ioctl(fds[0], I_PEEK, &pk) > 0 && pk.databuf.len == sizeof(msg))54{55printf("#undef _socket_peek\n");56return(0);57}58#endif59#if _socket_peek60if (recv(fds[0], msg, sizeof(msg), MSG_PEEK) == sizeof(msg))61{62printf("#undef _stream_peek\n");63return(0);64}65#endif66return(0);67}686970