(root)/
gawk-5.2.2/
vms/
redirect.h
       1  /*
       2   * redirect.h --- definitions for functions that are OS specific.
       3   */
       4  
       5  /*
       6   * Copyright (C) 1986, 1988, 1989, 1991-1993, 1996, 1997, 2007, 2010, 2011,
       7   * 2023 the Free Software Foundation, Inc.
       8   *
       9   * This file is part of GAWK, the GNU implementation of the
      10   * AWK Programming Language.
      11   *
      12   * GAWK is free software; you can redistribute it and/or modify
      13   * it under the terms of the GNU General Public License as published by
      14   * the Free Software Foundation; either version 3 of the License, or
      15   * (at your option) any later version.
      16   *
      17   * GAWK is distributed in the hope that it will be useful,
      18   * but WITHOUT ANY WARRANTY; without even the implied warranty of
      19   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      20   * GNU General Public License for more details.
      21   *
      22   * You should have received a copy of the GNU General Public License
      23   * along with this program; if not, write to the Free Software
      24   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
      25   */
      26  
      27  /* This file is included by custom.h for VMS-POSIX, or first
      28     by config.h (vms-conf.h) then again by awk.h for normal VMS.  */
      29  
      30  #if defined(VMS_POSIX) || defined(IN_CONFIG_H)
      31  
      32  #define DEFAULT_FILETYPE ".awk"
      33  
      34  /* some macros to redirect some non-VMS-specific code */
      35  #define getopt		gnu_getopt
      36  #define opterr		gnu_opterr
      37  #define optarg		gnu_optarg
      38  #define optind		gnu_optind
      39  #define optopt		gnu_optopt
      40  #define regcomp		gnu_regcomp
      41  #define regexec		gnu_regexec
      42  #define regfree		gnu_regfree
      43  #define regerror	gnu_regerror
      44  #define setenv		gawk_setenv
      45  #define unsetenv	gawk_unsetenv
      46  #ifndef VMS_POSIX
      47  #define strftime	gnu_strftime	/* always use missing/strftime.c */
      48  #define strcasecmp	gnu_strcasecmp
      49  #define strncasecmp	gnu_strncasecmp
      50  #ifndef VMS_V7
      51  #define tzset		fake_tzset
      52  #define tzname		fake_tzname
      53  #define daylight	fake_daylight
      54  #define timezone	fake_timezone
      55  #define altzone		fake_altzone
      56  #endif
      57  #if !defined(__DECC) && !defined(VAXC2DECC) && !defined(__alpha)
      58  #define strcoll(s,t) strcmp((s),(t))	/* VAXCRTL lacks locale support */
      59  #endif
      60  #endif
      61  
      62  #ifdef STDC_HEADERS
      63  /* This is for getopt.c and alloca.c (compiled with HAVE_CONFIG_H defined),
      64     to prevent diagnostics about various implicitly declared functions.  */
      65  #include <stdlib.h>
      66  #include <string.h>
      67  #endif
      68  #ifndef VMS_POSIX
      69  /* This if for random.c. */
      70  #define gettimeofday	vms_gettimeofday
      71  #ifndef __TIMEVAL
      72  #define __TIMEVAL 1
      73  struct timeval	{ long tv_sec, tv_usec; };
      74  #endif
      75  extern int   gettimeofday(struct timeval *,void *);
      76  #endif
      77  
      78  #else	/* awk.h, not POSIX */
      79  
      80  /* some macros to redirect to code in vms/vms_misc.c */
      81  #ifndef bcopy
      82  #define bcopy		vms_bcopy
      83  #endif
      84  #define open		vms_open
      85  #define popen		vms_popen
      86  #define pclose		vms_pclose
      87  #ifndef HAVE_SNPRINTF
      88  #define snprintf gawk_snprintf	/* avoid %CC-I-INTRINSICDECL diagnostic */
      89  #define vsnprintf gawk_vsnprintf
      90  #endif
      91  /* supply missing or suppressed (due to defines in config.h) declarations */
      92  extern int snprintf(char *,size_t,const char *,...);
      93  extern int vsnprintf(char *restrict,size_t,const char *,va_list);
      94  extern int setenv(const char *,const char *,int);
      95  extern int unsetenv(const char *);
      96  #define strerror	vms_strerror
      97  #define strdup		vms_strdup
      98  #define unlink		vms_unlink
      99  #if defined(VAXC) || (defined(__GNUC__) && !defined(__alpha))
     100  #define fstat(fd,sb)	VMS_fstat(fd,sb)
     101  #endif
     102  extern void  exit(int);
     103  extern int   open(const char *,int,...);
     104  extern char *strerror(int);
     105  extern char *strdup(const char *str);
     106  extern int   vms_devopen(const char *,int);
     107  # ifndef NO_TTY_FWRITE
     108  #define fwrite		tty_fwrite
     109  #define fclose		tty_fclose
     110  extern size_t fwrite(const void *,size_t,size_t,FILE *);
     111  extern int    fclose(FILE *);
     112  # endif
     113  extern FILE *popen(const char *,const char *);
     114  extern int   pclose(FILE *);
     115  extern void vms_arg_fixup(int *,char ***);
     116  /* some things not in STDC_HEADERS */
     117  extern size_t gnu_strftime(char *,size_t,const char *,const struct tm *);
     118  extern int unlink(const char *);
     119  extern int getopt(int,char **,char *);
     120  extern int isatty(int);
     121  #ifndef fileno
     122  extern int fileno(FILE *);
     123  #endif
     124  extern int close(int);
     125  extern int dup(int);
     126  extern int dup2(int, int);
     127  extern ssize_t read(int, void *, size_t);
     128  extern int getpgrp(void);
     129  extern void tzset(void);
     130  
     131  #endif	/* not VMS_POSIX and not IN_CONFIG_H */
     132  
     133  /*vms/redirect.h*/