alsa.audio: limit the supported frequencies to common set
[AROS.git] / workbench / network / stacks / AROSTCP / netlib / _fstat.c
blobfbc15b64bbbb2afb9b90ce260a9ab5f38f04a4a2
1 /* $Id$
3 * _fstat.c - fstat() for Network Support Library (SAS/C)
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
7 * All rights reserved.
8 */
10 #include <sys/types.h>
11 #include <sys/socket.h>
12 #include <sys/stat.h>
13 #include <errno.h>
15 #include <string.h>
16 #include <stdlib.h>
18 /* DOS 3.0 and MuFS extensions to file info block */
19 #include "fibex.h"
20 #include <proto/dos.h>
21 #include <proto/utility.h>
23 #include <ios1.h>
25 int fstat(int fd, struct stat *st)
27 struct UFB *ufb = chkufb(fd);
29 if (st == NULL || ((1 & (long)st) == 1)) {
30 errno = EFAULT;
31 return -1;
34 if (ufb == NULL || ufb->ufbflg == 0) {
35 errno = EBADF;
36 return -1;
39 if (ufb->ufbflg & UFB_SOCK) { /* a socket */
40 long value;
41 long size = sizeof(value);
42 bzero(st, sizeof(*st));
44 /* st->st_dev = ??? */
45 st->st_mode = S_IFSOCK | S_IRUSR | S_IWUSR;
46 st->st_uid = geteuid();
47 st->st_gid = getegid();
49 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &value, &size) == 0)
50 st->st_blksize = value;
52 return 0;
53 } else { /* ordinal file */
54 /* test if it is a NIL: file handle (ExamineFH() crashes on those!) */
55 if (((struct FileHandle *)BADDR((BPTR)ufb->ufbfh))->fh_Type == NULL) {
56 /* It is NIL:, make up something... */
57 bzero(st, sizeof(*st));
58 st->st_mode = S_IFIFO | S_IRWXU | S_IRWXG | S_IRWXO;
59 return 0;
61 else {
62 if (ExamineFH(ufb->ufbfh, __dostat_fib)) {
63 __dostat(__dostat_fib, st);
64 st->st_dev = (dev_t)((struct FileHandle *)BADDR(ufb->ufbfh))->fh_Type;
65 return 0;
66 } else {
67 errno = EIO;
68 return -1;