2 static char *RCSid
= "$Id$";
6 * The Regina Rexx Interpreter
7 * Copyright (C) 1992-1994 Anders Christensen <anders@pvv.unit.no>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #define OPTION(opt) { #opt, EXT_##opt, NULL }
32 #define METAOP(name,value) { #name, -1, value }
35 static const struct __regina_option all_options
[] = { /* Must be alphabetically sorted! */
36 METAOP( BUFFERS
, "BUFTYPE_BIF DESBUF_BIF DROPBUF_BIF MAKEBUF_BIF" ),
37 OPTION( BUFTYPE_BIF
),
41 OPTION( DROPBUF_BIF
),
42 OPTION( EXT_COMMANDS_AS_FUNCS
),
43 OPTION( FAST_LINES_BIF_DEFAULT
),
44 METAOP( FILEIO
, "OPEN_BIF CLOSE_BIF" ),
47 OPTION( INTERNAL_QUEUES
),
48 OPTION( LINEOUTTRUNC
),
49 OPTION( MAKEBUF_BIF
),
51 OPTION( PRUNE_TRACE
),
52 OPTION( REGINA_BIFS
),
53 OPTION( STDOUT_FOR_STDERR
),
54 OPTION( STRICT_ANSI
),
60 void do_options( const tsd_t
*TSD
, streng
*options
, int toggle
)
62 char *cptr
=NULL
, *eptr
=NULL
, *start
=NULL
;
63 int length
=0, inverse
=0, tmp
=0 ;
64 const struct __regina_option
*lower
=NULL
, *upper
=NULL
, *middle
=NULL
;
66 cptr
= options
->value
;
67 eptr
= cptr
+ options
->len
;
71 for (;cptr
<eptr
&& isspace(*cptr
); cptr
++) ;
72 for (start
=cptr
; cptr
<eptr
&& !isspace(*cptr
); cptr
++ )
73 *cptr
= (char) toupper( *cptr
) ;
75 if (((inverse
=(*start
=='N' && *(start
+1)=='O'))!=0) && cptr
>start
+2)
78 length
= cptr
- start
;
81 upper
= lower
+ (sizeof(all_options
)/sizeof(struct __regina_option
)) - 2 ;
83 while( upper
>= lower
)
85 middle
= lower
+ (upper
-lower
)/2 ;
86 tmp
= strncmp(middle
->name
,start
,length
) ;
87 if (tmp
==0 && middle
->name
[length
]==0x00)
96 /* If option is unknown, don't care ... */
99 assert ( middle
->name
) ;
100 if (middle
->offset
== -1)
102 do_options( TSD
, Str_creTSD(middle
->contains
), toggle
^inverse
) ;
108 set_options_flag( TSD
->currlevel
, middle
->offset
, 0 ) ;
110 set_options_flag( TSD
->currlevel
, middle
->offset
, 1 ) ;
114 Free_stringTSD( options
) ;
117 int get_options_flag( cproclevel pl
, int offset
)
119 register int obyte
= offset
/ ( sizeof( unsigned char ) * 8 ) ;
120 register int obit
= offset
% ( sizeof( unsigned char ) * 8 ) ;
122 return ( pl
->u
.flags
[obyte
] & ( 1 << ( 7 - obit
) ) ) ;
125 void set_options_flag( proclevel pl
, int offset
, int status
)
127 register int obyte
= offset
/ ( sizeof( unsigned char ) * 8 ) ;
128 register int obit
= offset
% ( sizeof( unsigned char ) * 8 ) ;
131 pl
->u
.flags
[obyte
] |= (unsigned char)(1<<(7-obit
)) ;
133 pl
->u
.flags
[obyte
] &= (unsigned char)(~(1<<(7-obit
))) ;