2
* gawkmisc.atr --- miscellanious gawk routines that are OS specific.
6
* Copyright (C) 1986, 1988, 1989, 1991-1993 the Free Software Foundation, Inc.
8
* This file is part of GAWK, the GNU implementation of the
9
* AWK Progamming Language.
11
* GAWK is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* GAWK is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
30
char *defpath = ".,c:\\lib\\awk,c:\\gnu\\lib\\awk";
32
char *defpath = DEFPATH;
37
/* gawk_name --- pull out the "gawk" part from how the OS called us */
47
if ((q = strrchr(p, '\\')) != NULL)
49
if ((q = strrchr(p, '/')) != NULL)
51
if ((q = strchr(p, '.')) != NULL)
55
return (p == NULL ? (char *)filespec : (char *)p);
58
/* os_arg_fixup --- fixup the command line */
61
os_arg_fixup(argcp, argvp)
69
/* os_devopen --- open special per-OS devices */
72
os_devopen(name, flag)
77
return INVALID_HANDLE;
80
/* optimal_bufsize --- determine optimal buffer size */
83
optimal_bufsize(fd, stb)
87
/* force all members to zero in case OS doesn't use all of them. */
88
memset(stb, '\0', sizeof(struct stat));
90
/* The atari has the st_blksize structure, so we just use it. */
91
#define DEFBLKSIZE (stb->st_blksize ? stb->st_blksize : BUFSIZ)
94
* On ST redirected stdin does not have a name attached
95
* (this could be hard to do to) and fstat would fail
97
if (fd == 0 || isatty(fd))
99
if (fstat(fd, stb) == -1)
100
fatal("can't stat fd %d (%s)", fd, strerror(errno));
101
if (lseek(fd, (off_t)0, 0) == -1) /* not a regular file */
103
if (stb->st_size > 0 && stb->st_size < DEFBLKSIZE) /* small file */
108
/* ispath --- return true if path has directory components */
114
return (strchr(file, '/') != NULL || strchr(file, '\\') != NULL);
117
/* isdirpunct --- return true if char is a directory separator */
123
return (c == '/' || c == '\\');