mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
Merged latest trunk changes to my branch.
This commit is contained in:
commit
ef66f0cc06
@ -91,17 +91,19 @@ ${top_builddir}/libdispatch/libdispatch.la
|
||||
|
||||
CLEANFILES += t_dap
|
||||
|
||||
EXTRA_DIST = ce.y
|
||||
|
||||
endif # BUILD_DAP
|
||||
|
||||
# These rule are used if someone wants to rebuild the grammar files.
|
||||
# Otherwise never invoked, but records how to do it.
|
||||
# BTW: note that renaming is essential because otherwise
|
||||
# autoconf will forcibly delete files of the name *.tab.*
|
||||
cetab.c cetab.h: ${top_srcdir}/oc/ce.y
|
||||
bison -d -t -p ce ${top_srcdir}/oc/ce.y
|
||||
rm -f cetab.c cetab.h
|
||||
mv ce.tab.c cetab.c
|
||||
mv ce.tab.h cetab.h
|
||||
#cetab.c cetab.h: ${top_srcdir}/oc/ce.y
|
||||
# bison -d -t -p ce ${top_srcdir}/oc/ce.y
|
||||
# rm -f cetab.c cetab.h
|
||||
# mv ce.tab.c cetab.c
|
||||
# mv ce.tab.h cetab.h
|
||||
|
||||
test: check
|
||||
|
||||
|
195
libncdap3/ce.y
Normal file
195
libncdap3/ce.y
Normal file
@ -0,0 +1,195 @@
|
||||
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
|
||||
See the COPYRIGHT file for more information. */
|
||||
|
||||
/*The lines down to DO NOT DELETE ... comment are specific to the C Parser.
|
||||
They will be commennted out when building a java parser.
|
||||
*/
|
||||
|
||||
%pure-parser
|
||||
%lex-param {CEparsestate* parsestate}
|
||||
%parse-param {CEparsestate* parsestate}
|
||||
%{#include "ceparselex.h"%}
|
||||
|
||||
/*DO NOT DELETE THIS LINE*/
|
||||
|
||||
%token SCAN_WORD
|
||||
%token SCAN_STRINGCONST
|
||||
%token SCAN_NUMBERCONST
|
||||
|
||||
%start constraints
|
||||
|
||||
%%
|
||||
|
||||
constraints:
|
||||
projections {projections(parsestate,$1);}
|
||||
| selections {selections(parsestate,$1);}
|
||||
| projections selections
|
||||
{projections(parsestate,$1); selections(parsestate,$2);}
|
||||
;
|
||||
|
||||
/* %type NClist<NCprojection*> */
|
||||
projections: projectionlist {$$=$1;}
|
||||
|
||||
/* %type NClist<NCselection*> */
|
||||
selections: selectionlist {$$=$1;}
|
||||
|
||||
/* %type NClist<NCprojection*> */
|
||||
projectionlist:
|
||||
projection
|
||||
{$$=projectionlist(parsestate,null,$1);}
|
||||
| projectionlist ',' projection
|
||||
{$$=projectionlist(parsestate,$1,$3);}
|
||||
;
|
||||
|
||||
/* %type NCprojection* */
|
||||
projection:
|
||||
segmentlist
|
||||
{$$=projection(parsestate,$1);}
|
||||
;
|
||||
|
||||
/* %type NClist<NCsegment> */
|
||||
segmentlist:
|
||||
segment
|
||||
{$$=segmentlist(parsestate,null,$1);}
|
||||
| segmentlist '.' segment
|
||||
{$$=segmentlist(parsestate,$1,$3);}
|
||||
;
|
||||
|
||||
/* %type NCsegment */
|
||||
segment:
|
||||
word
|
||||
{$$=segment(parsestate,$1,null);}
|
||||
| word array_indices
|
||||
{$$=segment(parsestate,$1,$2);}
|
||||
;
|
||||
|
||||
/* %type NClist<NCslice*> */
|
||||
array_indices: /* appends indices to state->segment */
|
||||
array_index
|
||||
{$$=array_indices(parsestate,null,$1);}
|
||||
| array_indices array_index
|
||||
{$$=array_indices(parsestate,$1,$2);}
|
||||
;
|
||||
|
||||
/* %type NCslice* */
|
||||
array_index:
|
||||
range {$$=$1;}
|
||||
;
|
||||
|
||||
/* %type NCslice* */
|
||||
range:
|
||||
range1
|
||||
{$$=range(parsestate,$1,null,null);}
|
||||
| '[' index ':' index ']'
|
||||
{$$=range(parsestate,$2,null,$4);}
|
||||
| '[' index ':' index ':' index ']'
|
||||
{$$=range(parsestate,$2,$4,$6);}
|
||||
;
|
||||
|
||||
range1: '[' index ']' {$$=$2;}
|
||||
|
||||
/* %type NClist<NCselection*> */
|
||||
selectionlist:
|
||||
'&' sel_clause
|
||||
{$$=selectionlist(parsestate,null,$2);}
|
||||
| selectionlist sel_clause
|
||||
{$$=selectionlist(parsestate,$1,$2);}
|
||||
;
|
||||
|
||||
/* %type NCselection* */
|
||||
sel_clause:
|
||||
selectionvar rel_op '{' value_list '}'
|
||||
{$$=sel_clause(parsestate,1,$1,$2,$4);} /*1,2 distinguish cases*/
|
||||
| selectionvar rel_op value
|
||||
{$$=sel_clause(parsestate,2,$1,$2,$3);}
|
||||
| function
|
||||
;
|
||||
|
||||
/* %type NClist<NCselection*> */
|
||||
selectionvar:
|
||||
selectionpath
|
||||
{$$=$1;}
|
||||
;
|
||||
/* %type NClist<NCselection*> */
|
||||
selectionpath:
|
||||
arrayelement
|
||||
{$1=selectionpath(parsestate,null,$1);}
|
||||
| segment '.' arrayelement
|
||||
{$$=selectionpath(parsestate,$1,$3);}
|
||||
;
|
||||
|
||||
function:
|
||||
ident '(' ')'
|
||||
{$$=function(parsestate,$1,null);}
|
||||
| ident '(' arg_list ')'
|
||||
{$$=function(parsestate,$1,$3);}
|
||||
;
|
||||
|
||||
arg_list:
|
||||
value
|
||||
{$$=arg_list(parsestate,null,$1);}
|
||||
| value_list ',' value
|
||||
{$$=arg_list(parsestate,$1,$3);}
|
||||
;
|
||||
|
||||
value_list:
|
||||
value
|
||||
{$$=value_list(parsestate,null,$1);}
|
||||
| value_list '|' value
|
||||
{$$=value_list(parsestate,$1,$3);}
|
||||
;
|
||||
|
||||
value:
|
||||
selectionpath /* can be variable or an integer */
|
||||
{$$=value(parsestate,$1,SCAN_WORD);}
|
||||
| number
|
||||
{$$=value(parsestate,$1,SCAN_NUMBERCONST);}
|
||||
| string
|
||||
{$$=value(parsestate,$1,SCAN_STRINGCONST);}
|
||||
;
|
||||
|
||||
/* %type SelectionTag */
|
||||
rel_op:
|
||||
'=' {$$=(Object)ST_EQ;}
|
||||
| '>' {$$=(Object)ST_GT;}
|
||||
| '<' {$$=(Object)ST_LT;}
|
||||
| '!' '=' {$$=(Object)ST_NEQ;}
|
||||
| '=' '~' {$$=(Object)ST_RE;}
|
||||
| '>' '=' {$$=(Object)ST_GE;}
|
||||
| '<' '=' {$$=(Object)ST_LE;}
|
||||
;
|
||||
|
||||
/* type NCsegment* */
|
||||
arrayelement:
|
||||
word
|
||||
{$$=arrayelement(parsestate,$1,null);}
|
||||
| word range1
|
||||
{$$=arrayelement(parsestate,$1,$2);}
|
||||
;
|
||||
|
||||
ident: word
|
||||
{$$ = $1;}
|
||||
;
|
||||
|
||||
index: number
|
||||
{ unsigned long tmp = 0;
|
||||
if(sscanf((char*)$1,"%lu",&tmp) != 1) {
|
||||
yyerror(parsestate,"Index is not an integer");
|
||||
}
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
word: SCAN_WORD
|
||||
{$$ = $1;}
|
||||
;
|
||||
|
||||
number: SCAN_NUMBERCONST
|
||||
{$$ = $1;}
|
||||
;
|
||||
|
||||
string: SCAN_STRINGCONST
|
||||
{$$ = $1;}
|
||||
;
|
||||
|
||||
%%
|
@ -1,10 +1,9 @@
|
||||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.2. */
|
||||
|
||||
/* Skeleton implementation for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -46,7 +45,7 @@
|
||||
#define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "2.4.1"
|
||||
#define YYBISON_VERSION "2.4.2"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
@ -80,7 +79,7 @@
|
||||
#include "ceparselex.h"
|
||||
|
||||
/* Line 189 of yacc.c */
|
||||
#line 84 "ce.tab.c"
|
||||
#line 83 "ce.tab.c"
|
||||
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
@ -127,7 +126,7 @@ typedef int YYSTYPE;
|
||||
|
||||
|
||||
/* Line 264 of yacc.c */
|
||||
#line 131 "ce.tab.c"
|
||||
#line 130 "ce.tab.c"
|
||||
|
||||
#ifdef short
|
||||
# undef short
|
||||
@ -177,7 +176,7 @@ typedef short int yytype_int16;
|
||||
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
|
||||
|
||||
#ifndef YY_
|
||||
# if YYENABLE_NLS
|
||||
# if defined YYENABLE_NLS && YYENABLE_NLS
|
||||
# if ENABLE_NLS
|
||||
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YY_(msgid) dgettext ("bison-runtime", msgid)
|
||||
@ -591,9 +590,18 @@ static const yytype_uint8 yystos[] =
|
||||
|
||||
/* Like YYERROR except do call yyerror. This remains here temporarily
|
||||
to ease the transition to the new meaning of YYERROR, for GCC.
|
||||
Once GCC version 2 has supplanted version 1, this can go. */
|
||||
Once GCC version 2 has supplanted version 1, this can go. However,
|
||||
YYFAIL appears to be in use. Nevertheless, it is formally deprecated
|
||||
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
|
||||
discussed. */
|
||||
|
||||
#define YYFAIL goto yyerrlab
|
||||
#if defined YYFAIL
|
||||
/* This is here to suppress warnings from the GCC cpp's
|
||||
-Wunused-macros. Normally we don't worry about that warning, but
|
||||
some users do, and we want to make it easy for users to remove
|
||||
YYFAIL uses, which will produce warnings from Bison 2.5. */
|
||||
#endif
|
||||
|
||||
#define YYRECOVERING() (!!yyerrstatus)
|
||||
|
||||
@ -650,7 +658,7 @@ while (YYID (0))
|
||||
we won't break user code: when these are the locations we know. */
|
||||
|
||||
#ifndef YY_LOCATION_PRINT
|
||||
# if YYLTYPE_IS_TRIVIAL
|
||||
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
||||
# define YY_LOCATION_PRINT(File, Loc) \
|
||||
fprintf (File, "%d.%d-%d.%d", \
|
||||
(Loc).first_line, (Loc).first_column, \
|
||||
@ -1394,322 +1402,322 @@ yyreduce:
|
||||
{
|
||||
case 2:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 24 "../oc/ce.y"
|
||||
{projections(parsestate,(yyvsp[(1) - (1)]));;}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 25 "../oc/ce.y"
|
||||
{selections(parsestate,(yyvsp[(1) - (1)]));;}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 27 "../oc/ce.y"
|
||||
{projections(parsestate,(yyvsp[(1) - (2)])); selections(parsestate,(yyvsp[(2) - (2)]));;}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 31 "../oc/ce.y"
|
||||
{(yyval)=(yyvsp[(1) - (1)]);;}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 34 "../oc/ce.y"
|
||||
{(yyval)=(yyvsp[(1) - (1)]);;}
|
||||
break;
|
||||
|
||||
case 7:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 39 "../oc/ce.y"
|
||||
{(yyval)=projectionlist(parsestate,null,(yyvsp[(1) - (1)]));;}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 41 "../oc/ce.y"
|
||||
{(yyval)=projectionlist(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
|
||||
break;
|
||||
|
||||
case 9:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 47 "../oc/ce.y"
|
||||
{(yyval)=projection(parsestate,(yyvsp[(1) - (1)]));;}
|
||||
break;
|
||||
|
||||
case 10:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 53 "../oc/ce.y"
|
||||
{(yyval)=segmentlist(parsestate,null,(yyvsp[(1) - (1)]));;}
|
||||
break;
|
||||
|
||||
case 11:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 55 "../oc/ce.y"
|
||||
{(yyval)=segmentlist(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
|
||||
break;
|
||||
|
||||
case 12:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 61 "../oc/ce.y"
|
||||
{(yyval)=segment(parsestate,(yyvsp[(1) - (1)]),null);;}
|
||||
break;
|
||||
|
||||
case 13:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 63 "../oc/ce.y"
|
||||
{(yyval)=segment(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;}
|
||||
break;
|
||||
|
||||
case 14:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 69 "../oc/ce.y"
|
||||
{(yyval)=array_indices(parsestate,null,(yyvsp[(1) - (1)]));;}
|
||||
break;
|
||||
|
||||
case 15:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 71 "../oc/ce.y"
|
||||
{(yyval)=array_indices(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;}
|
||||
break;
|
||||
|
||||
case 16:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 76 "../oc/ce.y"
|
||||
{(yyval)=(yyvsp[(1) - (1)]);;}
|
||||
break;
|
||||
|
||||
case 17:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 82 "../oc/ce.y"
|
||||
{(yyval)=range(parsestate,(yyvsp[(1) - (1)]),null,null);;}
|
||||
break;
|
||||
|
||||
case 18:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 84 "../oc/ce.y"
|
||||
{(yyval)=range(parsestate,(yyvsp[(2) - (5)]),null,(yyvsp[(4) - (5)]));;}
|
||||
break;
|
||||
|
||||
case 19:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 86 "../oc/ce.y"
|
||||
{(yyval)=range(parsestate,(yyvsp[(2) - (7)]),(yyvsp[(4) - (7)]),(yyvsp[(6) - (7)]));;}
|
||||
break;
|
||||
|
||||
case 20:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 89 "../oc/ce.y"
|
||||
{(yyval)=(yyvsp[(2) - (3)]);;}
|
||||
break;
|
||||
|
||||
case 21:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 94 "../oc/ce.y"
|
||||
{(yyval)=selectionlist(parsestate,null,(yyvsp[(2) - (2)]));;}
|
||||
break;
|
||||
|
||||
case 22:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 96 "../oc/ce.y"
|
||||
{(yyval)=selectionlist(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;}
|
||||
break;
|
||||
|
||||
case 23:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 102 "../oc/ce.y"
|
||||
{(yyval)=sel_clause(parsestate,1,(yyvsp[(1) - (5)]),(yyvsp[(2) - (5)]),(yyvsp[(4) - (5)]));;}
|
||||
break;
|
||||
|
||||
case 24:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 104 "../oc/ce.y"
|
||||
{(yyval)=sel_clause(parsestate,2,(yyvsp[(1) - (3)]),(yyvsp[(2) - (3)]),(yyvsp[(3) - (3)]));;}
|
||||
break;
|
||||
|
||||
case 26:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 111 "../oc/ce.y"
|
||||
{(yyval)=(yyvsp[(1) - (1)]);;}
|
||||
break;
|
||||
|
||||
case 27:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 116 "../oc/ce.y"
|
||||
{(yyvsp[(1) - (1)])=selectionpath(parsestate,null,(yyvsp[(1) - (1)]));;}
|
||||
break;
|
||||
|
||||
case 28:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 118 "../oc/ce.y"
|
||||
{(yyval)=selectionpath(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
|
||||
break;
|
||||
|
||||
case 29:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 123 "../oc/ce.y"
|
||||
{(yyval)=function(parsestate,(yyvsp[(1) - (3)]),null);;}
|
||||
break;
|
||||
|
||||
case 30:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 125 "../oc/ce.y"
|
||||
{(yyval)=function(parsestate,(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]));;}
|
||||
break;
|
||||
|
||||
case 31:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 130 "../oc/ce.y"
|
||||
{(yyval)=arg_list(parsestate,null,(yyvsp[(1) - (1)]));;}
|
||||
break;
|
||||
|
||||
case 32:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 132 "../oc/ce.y"
|
||||
{(yyval)=arg_list(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
|
||||
break;
|
||||
|
||||
case 33:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 137 "../oc/ce.y"
|
||||
{(yyval)=value_list(parsestate,null,(yyvsp[(1) - (1)]));;}
|
||||
break;
|
||||
|
||||
case 34:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 139 "../oc/ce.y"
|
||||
{(yyval)=value_list(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
|
||||
break;
|
||||
|
||||
case 35:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 144 "../oc/ce.y"
|
||||
{(yyval)=value(parsestate,(yyvsp[(1) - (1)]),SCAN_WORD);;}
|
||||
break;
|
||||
|
||||
case 36:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 146 "../oc/ce.y"
|
||||
{(yyval)=value(parsestate,(yyvsp[(1) - (1)]),SCAN_NUMBERCONST);;}
|
||||
break;
|
||||
|
||||
case 37:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 148 "../oc/ce.y"
|
||||
{(yyval)=value(parsestate,(yyvsp[(1) - (1)]),SCAN_STRINGCONST);;}
|
||||
break;
|
||||
|
||||
case 38:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 153 "../oc/ce.y"
|
||||
{(yyval)=(Object)ST_EQ;;}
|
||||
break;
|
||||
|
||||
case 39:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 154 "../oc/ce.y"
|
||||
{(yyval)=(Object)ST_GT;;}
|
||||
break;
|
||||
|
||||
case 40:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 155 "../oc/ce.y"
|
||||
{(yyval)=(Object)ST_LT;;}
|
||||
break;
|
||||
|
||||
case 41:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 156 "../oc/ce.y"
|
||||
{(yyval)=(Object)ST_NEQ;;}
|
||||
break;
|
||||
|
||||
case 42:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 157 "../oc/ce.y"
|
||||
{(yyval)=(Object)ST_RE;;}
|
||||
break;
|
||||
|
||||
case 43:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 158 "../oc/ce.y"
|
||||
{(yyval)=(Object)ST_GE;;}
|
||||
break;
|
||||
|
||||
case 44:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 159 "../oc/ce.y"
|
||||
{(yyval)=(Object)ST_LE;;}
|
||||
break;
|
||||
|
||||
case 45:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 165 "../oc/ce.y"
|
||||
{(yyval)=arrayelement(parsestate,(yyvsp[(1) - (1)]),null);;}
|
||||
break;
|
||||
|
||||
case 46:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 167 "../oc/ce.y"
|
||||
{(yyval)=arrayelement(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;}
|
||||
break;
|
||||
|
||||
case 47:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 171 "../oc/ce.y"
|
||||
{(yyval) = (yyvsp[(1) - (1)]);;}
|
||||
break;
|
||||
|
||||
case 48:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 175 "../oc/ce.y"
|
||||
{ unsigned long tmp = 0;
|
||||
if(sscanf((char*)(yyvsp[(1) - (1)]),"%lu",&tmp) != 1) {
|
||||
@ -1721,29 +1729,29 @@ yyreduce:
|
||||
|
||||
case 49:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 184 "../oc/ce.y"
|
||||
{(yyval) = (yyvsp[(1) - (1)]);;}
|
||||
break;
|
||||
|
||||
case 50:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 188 "../oc/ce.y"
|
||||
{(yyval) = (yyvsp[(1) - (1)]);;}
|
||||
break;
|
||||
|
||||
case 51:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 192 "../oc/ce.y"
|
||||
{(yyval) = (yyvsp[(1) - (1)]);;}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
#line 1747 "ce.tab.c"
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 1755 "ce.tab.c"
|
||||
default: break;
|
||||
}
|
||||
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
||||
@ -1954,7 +1962,7 @@ yyreturn:
|
||||
|
||||
|
||||
|
||||
/* Line 1675 of yacc.c */
|
||||
/* Line 1684 of yacc.c */
|
||||
#line 195 "../oc/ce.y"
|
||||
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.2. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -9,7 +9,7 @@ echo ""
|
||||
echo "Testing programs with valgrind..."
|
||||
|
||||
# These are my test programs.
|
||||
list='tst_h_dimscales tst_h_vl2 tst_h_files '\
|
||||
list='tst_h_dimscales tst_h_files '\
|
||||
'tst_h_atts2 tst_h_dimscales2 tst_h_enums '\
|
||||
'tst_h_grps tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl tst_h_atts '\
|
||||
'tst_h_dimscales3 tst_h_files2 tst_h_compounds '\
|
||||
|
@ -10,7 +10,7 @@ echo "Testing programs with valgrind..."
|
||||
|
||||
# These are my test programs.
|
||||
list='tst_v2 '\
|
||||
'tst_vars2 tst_atts tst_atts2 '
|
||||
'tst_vars2 tst_atts tst_atts2 tst_h_vl2'
|
||||
|
||||
# These don't work yet: tst_h_vars3
|
||||
# tst_h_strings tst_h_atts3 tst_h_vars2 tst_vars tst_fills tst_chunks
|
||||
|
@ -53,12 +53,12 @@ test: check
|
||||
# Otherwise never invoked, but records how to do it.
|
||||
# BTW: note that renaming is essential because otherwise
|
||||
# autoconf will forcibly delete files of the name *.tab.*
|
||||
ncgenyy.c: ncgen.l
|
||||
flex -Pncg -8 ncgen.l
|
||||
rm -f ncgenyy.c
|
||||
mv lex.ncg.c ncgenyy.c
|
||||
|
||||
ncgentab.c: ncgen.y ncgenyy.c
|
||||
bison -pncg -t ncgen.y
|
||||
rm -f ncgentab.c
|
||||
mv ncgen.tab.c ncgentab.c
|
||||
#ncgenyy.c: ncgen.l
|
||||
# flex -Pncg -8 ncgen.l
|
||||
# rm -f ncgenyy.c
|
||||
# mv lex.ncg.c ncgenyy.c
|
||||
#
|
||||
#ncgentab.c: ncgen.y ncgenyy.c
|
||||
# bison -pncg -t ncgen.y
|
||||
# rm -f ncgentab.c
|
||||
# mv ncgen.tab.c ncgentab.c
|
||||
|
19
oc/Make0
19
oc/Make0
@ -6,11 +6,10 @@ all::
|
||||
makeoc::
|
||||
rm -f ${THISDIR}/*.[chy]
|
||||
for f in ${OCDIR}/*.[chy]; do \
|
||||
base=`basename $$f` ; \
|
||||
cat $$f | tr -d '
' >${THISDIR}/$$base; \
|
||||
done
|
||||
base=`basename $$f` ; \
|
||||
cat $$f | tr -d '
' >${THISDIR}/$$base; done
|
||||
rm -f i.* apitest.* getoc.* imain.* main.*
|
||||
rm -f config.h dap.tab.c dap.tab.h ceparselex.*
|
||||
rm -f config.h dap.tab.c dap.tab.h ce.y ceparselex.*
|
||||
rm -f ocshadow.*
|
||||
rm -f octest.c
|
||||
rm -f ocinternal.h
|
||||
@ -18,22 +17,20 @@ makeoc::
|
||||
< ${OCDIR}/ocinternal.h | tr -d '\r' >./ocinternal.h
|
||||
|
||||
diffoc::
|
||||
for f in ${OCDIR}/*.[chy] ; do \
|
||||
for f in ${THISDIR}/*.[chy] ; do \
|
||||
x=`basename $$f | tr -d '
' ` ; \
|
||||
if test "x$$x" = "xdaptab.c"; then continue ; fi ; \
|
||||
if test -e ${THISDIR}/$$x ; then \
|
||||
diff -q ${THISDIR}/$$x $$f ; \
|
||||
else \
|
||||
echo "new file: $$f"; \
|
||||
diff -qw ${THISDIR}/$$x $$f ; \
|
||||
fi; \
|
||||
done
|
||||
for f in ${OCDIR}/*.[chy] ; do \
|
||||
x=`basename $$f|tr -d '
' ` ; \
|
||||
if test "x$$x" = "xdaptab.c"; then continue ; fi ; \
|
||||
if test -e ${THISDIR}/$$x ; then \
|
||||
if ! diff -q ${THISDIR}/$$x $$f > /dev/null ; then \
|
||||
echo diff ${THISDIR}/$$x $$f ;\
|
||||
diff -bBw ${THISDIR}/$$x $$f ; \
|
||||
if ! diff -qw ${THISDIR}/$$x $$f > /dev/null ; then \
|
||||
echo diff -w ${THISDIR}/$$x $$f ;\
|
||||
diff -w ${THISDIR}/$$x $$f ; \
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
|
@ -18,47 +18,47 @@ CURL_LIBS = @CURL_LIBS@
|
||||
|
||||
# OC Sources
|
||||
SRC=\
|
||||
oc.c \
|
||||
occontent.c \
|
||||
ocdata.c \
|
||||
ocdebug.c \
|
||||
ocdump.c \
|
||||
oclog.c \
|
||||
ocnode.c \
|
||||
ocutil.c \
|
||||
occompile.c \
|
||||
curlfunctions.c \
|
||||
dapparse.c \
|
||||
daplex.c \
|
||||
dapurl.c \
|
||||
http.c \
|
||||
read.c \
|
||||
curlfunctions.c \
|
||||
ocbytes.c \
|
||||
oc.c \
|
||||
occompile.c \
|
||||
occontent.c \
|
||||
ocdata.c \
|
||||
ocdebug.c \
|
||||
ocdrno.c \
|
||||
ocdump.c \
|
||||
ocinternal.c \
|
||||
oclist.c \
|
||||
ocbytes.c \
|
||||
ocdrno.c \
|
||||
ocxdr_stdio.c \
|
||||
oclog.c \
|
||||
ocnode.c \
|
||||
ocutil.c \
|
||||
occlientparams.c \
|
||||
rc.c
|
||||
ocxdr_stdio.c \
|
||||
rc.c \
|
||||
read.c
|
||||
|
||||
HDRS=\
|
||||
oc.h \
|
||||
constraints.h \
|
||||
curlfunctions.h \
|
||||
dapparselex.h \
|
||||
dapurl.h \
|
||||
http.h \
|
||||
ocbytes.h \
|
||||
occlientparams.h \
|
||||
occontent.h \
|
||||
ocdata.h \
|
||||
ocdatatypes.h \
|
||||
ocdebug.h \
|
||||
ocdrno.h \
|
||||
ocdump.h \
|
||||
oc.h \
|
||||
ocinternal.h \
|
||||
oclist.h \
|
||||
oclog.h \
|
||||
ocnode.h \
|
||||
occlientparams.h \
|
||||
ocutil.h \
|
||||
rc.h \
|
||||
read.h
|
||||
@ -87,3 +87,4 @@ daptab.c daptab.h: dap.y
|
||||
mv dap.tab.c daptab.c; mv dap.tab.h daptab.h
|
||||
|
||||
test: check
|
||||
|
||||
|
197
oc/celex.c
197
oc/celex.c
@ -1,197 +0,0 @@
|
||||
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
|
||||
See the COPYRIGHT file for more information. */
|
||||
|
||||
#include "ceparselex.h"
|
||||
|
||||
/* Forward */
|
||||
static void dumptoken(CElexstate* lexstate);
|
||||
static int tohex(int c);
|
||||
static void ceaddyytext(CElexstate* lex, int c);
|
||||
|
||||
/****************************************************/
|
||||
static char* worddelims =
|
||||
"{}[]:;=,";
|
||||
|
||||
/* Define 1 and > 1st legal characters */
|
||||
static char* wordchars1 =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_/%\\";
|
||||
static char* wordcharsn =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_/%\\";
|
||||
|
||||
/* Number characters */
|
||||
static char* numchars1="+-0123456789";
|
||||
static char* numcharsn="Ee.+-0123456789";
|
||||
|
||||
/**************************************************/
|
||||
|
||||
int
|
||||
celex(YYSTYPE* lvalp, CEparsestate* state)
|
||||
{
|
||||
CElexstate* lexstate = state->lexstate;
|
||||
int token;
|
||||
int c;
|
||||
char* p=lexstate->next;
|
||||
token = 0;
|
||||
ncbytesclear(lexstate->yytext);
|
||||
p=lexstate->next;
|
||||
while(token == 0 && (c=*p)) {
|
||||
if(c <= ' ' || c >= '\177') {p++; continue;}
|
||||
if(c == '"') {
|
||||
int more = 1;
|
||||
/* We have a SCAN_STRINGCONST */
|
||||
while(more && (c=*(++p))) {
|
||||
switch (c) {
|
||||
case '"': p++; more=0; break;
|
||||
case '\\':
|
||||
c=*(++p);
|
||||
switch (c) {
|
||||
case 'r': c = '\r'; break;
|
||||
case 'n': c = '\n'; break;
|
||||
case 'f': c = '\f'; break;
|
||||
case 't': c = '\t'; break;
|
||||
case 'x': {
|
||||
int d1,d2;
|
||||
c = '?';
|
||||
++p;
|
||||
d1 = tohex(*p++);
|
||||
if(d1 < 0) {
|
||||
ceerror(state,"Illegal \\xDD in SCAN_STRING");
|
||||
} else {
|
||||
d2 = tohex(*p++);
|
||||
if(d2 < 0) {
|
||||
ceerror(state,"Illegal \\xDD in SCAN_STRING");
|
||||
} else {
|
||||
c=(((unsigned int)d1)<<4) | (unsigned int)d2;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
ceaddyytext(lexstate,c);
|
||||
}
|
||||
token=SCAN_STRINGCONST;
|
||||
} else if(strchr(numchars1,c) != NULL) {
|
||||
/* we might have a SCAN_NUMBERCONST */
|
||||
int isnumber = 0;
|
||||
double number;
|
||||
char* yytext;
|
||||
ceaddyytext(lexstate,c);
|
||||
for(p++;(c=*p);p++) {
|
||||
if(strchr(numcharsn,c) == NULL) break;
|
||||
ceaddyytext(lexstate,c);
|
||||
}
|
||||
/* See if this is a number */
|
||||
yytext = ncbytescontents(lexstate->yytext);
|
||||
if(sscanf(yytext,"%lg",&number) == 1
|
||||
|| sscanf(yytext,"%lG",&number) == 1)
|
||||
isnumber = 1; /* maybe */
|
||||
/* A number followed by an id char is assumed to just be
|
||||
a funny id */
|
||||
if(isnumber && (*p == '\0' || strchr(wordcharsn,*p) == NULL)) {
|
||||
token = SCAN_NUMBERCONST;
|
||||
} else {
|
||||
/* Now, if the funny word has a "." in it,
|
||||
we have to back up to that dot */
|
||||
char* dotpoint = strchr(yytext,'.');
|
||||
if(dotpoint != NULL) {
|
||||
p = dotpoint;
|
||||
*dotpoint = '\0';
|
||||
}
|
||||
token = SCAN_WORD;
|
||||
}
|
||||
} else if(strchr(wordchars1,c) != NULL) {
|
||||
/* we have a SCAN_WORD */
|
||||
ceaddyytext(lexstate,c);
|
||||
for(p++;(c=*p);p++) {
|
||||
if(strchr(wordcharsn,c) == NULL) break;
|
||||
ceaddyytext(lexstate,c);
|
||||
}
|
||||
token=SCAN_WORD;
|
||||
} else {
|
||||
/* we have a single char token */
|
||||
token = c;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
lexstate->next = p;
|
||||
strncpy(lexstate->lasttokentext,ncbytescontents(lexstate->yytext),MAX_TOKEN_LENGTH);
|
||||
lexstate->lasttoken = token;
|
||||
if(cedebug) dumptoken(lexstate);
|
||||
|
||||
/*Put return value onto Bison stack*/
|
||||
|
||||
if(ncbyteslength(lexstate->yytext) == 0)
|
||||
*lvalp = NULL;
|
||||
else {
|
||||
*lvalp = ncbytesdup(lexstate->yytext);
|
||||
nclistpush(lexstate->reclaim,(ncelem)*lvalp);
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
static void
|
||||
ceaddyytext(CElexstate* lex, int c)
|
||||
{
|
||||
ncbytesappend(lex->yytext,(char)c);
|
||||
}
|
||||
|
||||
static int
|
||||
tohex(int c)
|
||||
{
|
||||
if(c >= 'a' && c <= 'f') return (c - 'a') + 0xa;
|
||||
if(c >= 'A' && c <= 'F') return (c - 'A') + 0xa;
|
||||
if(c >= '0' && c <= '9') return (c - '0');
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
dumptoken(CElexstate* lexstate)
|
||||
{
|
||||
switch (lexstate->lasttoken) {
|
||||
case SCAN_STRINGCONST:
|
||||
fprintf(stderr,"TOKEN = |\"%s\"|\n",lexstate->lasttokentext);
|
||||
break;
|
||||
case SCAN_WORD:
|
||||
case SCAN_NUMBERCONST:
|
||||
default:
|
||||
fprintf(stderr,"TOKEN = |%s|\n",lexstate->lasttokentext);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
celexinit(char* input, CElexstate** lexstatep)
|
||||
{
|
||||
CElexstate* lexstate = (CElexstate*)malloc(sizeof(CElexstate));
|
||||
if(lexstatep) *lexstatep = lexstate;
|
||||
if(lexstate == NULL) return;
|
||||
memset((void*)lexstate,0,sizeof(CElexstate));
|
||||
lexstate->input = strdup(input);
|
||||
lexstate->next = lexstate->input;
|
||||
lexstate->yytext = ncbytesnew();
|
||||
lexstate->reclaim = nclistnew();
|
||||
}
|
||||
|
||||
void
|
||||
celexcleanup(CElexstate** lexstatep)
|
||||
{
|
||||
unsigned int i;
|
||||
CElexstate* lexstate = *lexstatep;
|
||||
if(lexstate == NULL) return;
|
||||
if(lexstate->input != NULL) free(lexstate->input);
|
||||
if(lexstate->reclaim != NULL) {
|
||||
while(nclistlength(lexstate->reclaim) > 0) {
|
||||
char* word = (char*)nclistpop(lexstate->reclaim);
|
||||
if(word) free(word);
|
||||
}
|
||||
nclistfree(lexstate->reclaim);
|
||||
}
|
||||
ncbytesfree(lexstate->yytext);
|
||||
free(lexstate);
|
||||
*lexstatep = NULL;
|
||||
}
|
||||
|
298
oc/ceparse.c
298
oc/ceparse.c
@ -1,298 +0,0 @@
|
||||
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
|
||||
See the COPYRIGHT file for more information. */
|
||||
|
||||
/* Parser actions for constraint expressions */
|
||||
|
||||
/* Since oc does not use the constraint parser,
|
||||
they functions all just abort if called.
|
||||
*/
|
||||
|
||||
#include "ceparselex.h"
|
||||
|
||||
static Object collectlist(Object list0, Object decl);
|
||||
|
||||
void
|
||||
projections(CEparsestate* state, Object list0)
|
||||
{
|
||||
state->projections = (NClist*)list0;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr," ce.projections: %s\n",
|
||||
dumpprojections(state->projections));
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
selections(CEparsestate* state, Object list0)
|
||||
{
|
||||
state->selections = (NClist*)list0;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr," ce.selections: %s\n",
|
||||
dumpselections(state->selections));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Object
|
||||
projectionlist(CEparsestate* state, Object list0, Object decl)
|
||||
{
|
||||
return collectlist(list0,decl);
|
||||
}
|
||||
|
||||
Object
|
||||
projection(CEparsestate* state, Object segmentlist)
|
||||
{
|
||||
NCprojection* p = createncprojection();
|
||||
p->segments = (NClist*)segmentlist;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr," ce.projection: %s\n",
|
||||
dumpprojection1(p));
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
Object
|
||||
segmentlist(CEparsestate* state, Object list0, Object decl)
|
||||
{
|
||||
return collectlist(list0,decl);
|
||||
}
|
||||
|
||||
Object
|
||||
segment(CEparsestate* state, Object name, Object slices0)
|
||||
{
|
||||
NCsegment* segment = createncsegment();
|
||||
NClist* slices = (NClist*)slices0;
|
||||
segment->name = strdup((char*)name);
|
||||
segment->slicerank = nclistlength(slices);
|
||||
if(slices != NULL) {
|
||||
int i;
|
||||
ASSERT(nclistlength(slices) > 0);
|
||||
for(i=0;i<nclistlength(slices);i++) {
|
||||
NCslice* slice = (NCslice*)nclistget(slices,i);
|
||||
segment->slices[i] = *slice;
|
||||
free(slice);
|
||||
}
|
||||
segment->slicesdefined = 1;
|
||||
} else
|
||||
segment->slicesdefined = 0;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr," ce.segment: %s\n",
|
||||
dumpsegment(segment));
|
||||
#endif
|
||||
return segment;
|
||||
}
|
||||
|
||||
Object
|
||||
array_indices(CEparsestate* state, Object list0, Object decl)
|
||||
{
|
||||
return collectlist(list0,decl);
|
||||
}
|
||||
|
||||
Object
|
||||
range(CEparsestate* state, Object sfirst, Object sstride, Object slast)
|
||||
{
|
||||
NCslice* slice = createncslice();
|
||||
unsigned long first,stride,last;
|
||||
|
||||
/* Note: that incoming arguments are strings; we must convert to size_t;
|
||||
but we do know they are legal integers or NULL */
|
||||
sscanf((char*)sfirst,"%lu",&first); /* always defined */
|
||||
if(slast != NULL)
|
||||
sscanf((char*)slast,"%lu",&last);
|
||||
else
|
||||
last = first;
|
||||
if(sstride != NULL)
|
||||
sscanf((char*)sstride,"%lu",&stride);
|
||||
else
|
||||
stride = 1; /* default */
|
||||
|
||||
if(stride == 0)
|
||||
ceerror(state,"Illegal index for range stride");
|
||||
if(last < first)
|
||||
ceerror(state,"Illegal index for range last index");
|
||||
slice->first = first;
|
||||
slice->stride = stride;
|
||||
slice->stop = last + 1;
|
||||
slice->length = slice->stop - slice->first;
|
||||
slice->count = slice->length / slice->stride;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr," ce.slice: %s\n",
|
||||
dumpslice(slice));
|
||||
#endif
|
||||
return slice;
|
||||
}
|
||||
|
||||
/* Selection Procedures */
|
||||
|
||||
Object
|
||||
selectionlist(CEparsestate* state, Object list0, Object decl)
|
||||
{
|
||||
return collectlist(list0,decl);
|
||||
}
|
||||
|
||||
Object
|
||||
sel_clause(CEparsestate* state, int selcase,
|
||||
Object path0, Object relop0, Object values)
|
||||
{
|
||||
NCselection* sel = createncselection();
|
||||
sel->operator = (SelectionTag)relop0;
|
||||
sel->segments = (NClist*)path0;
|
||||
sel->values = (NClist*)values;
|
||||
sel->leaf = NULL;
|
||||
return sel;
|
||||
}
|
||||
|
||||
Object
|
||||
selectionpath(CEparsestate* state, Object list0, Object segment)
|
||||
{
|
||||
ASSERT(segment != NULL);
|
||||
return collectlist(list0,segment);
|
||||
}
|
||||
|
||||
Object
|
||||
arrayelement(CEparsestate* state, Object name, Object index)
|
||||
{
|
||||
NCsegment* segment = createncsegment();
|
||||
segment->name = (char*)name;
|
||||
if(index != null) {/* create a simple slice */
|
||||
/* Make sure this is a number */
|
||||
NCslice* slice = &segment->slices[0];
|
||||
if(sscanf((char*)index,"%lu",slice->first) != 1)
|
||||
ceerror(state,"Illegal index for selection variable");
|
||||
slice->count = 1;
|
||||
slice->length = 1;
|
||||
slice->stride = 1;
|
||||
slice->stop = slice->first+1;
|
||||
slice->declsize = 0;
|
||||
segment->slicerank = 1;
|
||||
segment->slicesdefined = 1;
|
||||
}
|
||||
return segment;
|
||||
}
|
||||
|
||||
|
||||
Object
|
||||
function(CEparsestate* state, Object fcnname, Object args)
|
||||
{
|
||||
NCselection* sel = createncselection();
|
||||
sel->operator = ST_FCN;
|
||||
sel->fcn = nulldup((char*)fcnname);
|
||||
return sel;
|
||||
}
|
||||
|
||||
Object
|
||||
arg_list(CEparsestate* state, Object list0, Object decl)
|
||||
{
|
||||
return collectlist(list0,decl);
|
||||
}
|
||||
|
||||
Object
|
||||
value_list(CEparsestate* state, Object list0, Object decl)
|
||||
{
|
||||
return collectlist(list0,decl);
|
||||
}
|
||||
|
||||
Object
|
||||
value(CEparsestate* state, Object text, int tag)
|
||||
{
|
||||
NCvalue* value = createncvalue();
|
||||
switch (tag) {
|
||||
case SCAN_STRINGCONST:
|
||||
value->kind = ST_STR;
|
||||
value->value.text = text;
|
||||
break;
|
||||
case SCAN_NUMBERCONST:
|
||||
if(sscanf(text,"%lld",&value->value.intvalue)==1)
|
||||
value->kind = ST_INT;
|
||||
else if(sscanf(text,"%lg",&value->value.floatvalue)==1)
|
||||
value->kind = ST_FLOAT;
|
||||
else {
|
||||
sscanf(text,"%lG",&value->value.floatvalue);
|
||||
value->kind = ST_FLOAT;
|
||||
}
|
||||
break;
|
||||
case SCAN_WORD:
|
||||
default:
|
||||
/* In this case, text is actually a path list */
|
||||
value->kind = ST_VAR;
|
||||
value->value.var.segments = (NClist*)text; /* fill-in cdfnode later */
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static Object
|
||||
collectlist(Object list0, Object decl)
|
||||
{
|
||||
NClist* list = (NClist*)list0;
|
||||
if(list == NULL) list = nclistnew();
|
||||
nclistpush(list,(ncelem)decl);
|
||||
return list;
|
||||
}
|
||||
|
||||
int
|
||||
ceerror(CEparsestate* state, char* msg)
|
||||
{
|
||||
strcpy(state->errorbuf,msg);
|
||||
state->errorcode=1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ce_parse_cleanup(CEparsestate* state)
|
||||
{
|
||||
celexcleanup(&state->lexstate); /* will free */
|
||||
}
|
||||
|
||||
static CEparsestate*
|
||||
ce_parse_init(char* input, int ncconstraint)
|
||||
{
|
||||
CEparsestate* state = NULL;
|
||||
if(input==NULL) {
|
||||
ceerror(state,"ce_parse_init: no input buffer");
|
||||
} else {
|
||||
state = (CEparsestate*)emalloc(sizeof(CEparsestate));
|
||||
MEMCHECK(state,(CEparsestate*)NULL);
|
||||
memset((void*)state,0,sizeof(CEparsestate)); /* Zero memory*/
|
||||
state->errorbuf[0] = '\0';
|
||||
state->errorcode = 0;
|
||||
celexinit(input,&state->lexstate);
|
||||
state->projections = NULL;
|
||||
state->selections = NULL;
|
||||
state->ncconstraint = ncconstraint;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
/* Wrapper for ceparse */
|
||||
int
|
||||
ncceparse(char* input, int ncconstraint,
|
||||
NClist** projectionsp, NClist** selectionsp, char** errmsgp)
|
||||
{
|
||||
CEparsestate* state;
|
||||
int errcode = 0;
|
||||
|
||||
if(input != NULL) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"ncceparse: input=%s\n",input);
|
||||
#endif
|
||||
state = ce_parse_init(input,ncconstraint);
|
||||
if(ceparse(state) == 0) {
|
||||
#ifdef DEBUG
|
||||
if(state->projections)
|
||||
fprintf(stderr,"ncceparse: projections=%s\n",dumpprojections(state->projections));
|
||||
#endif
|
||||
if(projectionsp) *projectionsp = state->projections;
|
||||
#ifdef DEBUG
|
||||
if(state->selections)
|
||||
fprintf(stderr,"ncceparse: selections=%s\n",dumpselections(state->selections));
|
||||
#endif
|
||||
if(selectionsp) *selectionsp = state->selections;
|
||||
} else {
|
||||
if(errmsgp) *errmsgp = nulldup(state->errorbuf);
|
||||
}
|
||||
errcode = state->errorcode;
|
||||
ce_parse_cleanup(state);
|
||||
}
|
||||
return errcode;
|
||||
}
|
@ -9,21 +9,6 @@
|
||||
|
||||
#include "rc.h"
|
||||
|
||||
/* Set various general curl flags */
|
||||
int
|
||||
set_curl_flags(CURL* curl, struct OCcurlflags* flags)
|
||||
{
|
||||
if (flags->verify)
|
||||
{if (set_verify(curl) != OC_NOERR) goto fail;}
|
||||
if (flags->compress)
|
||||
{if (set_compression(curl) != OC_NOERR) goto fail;}
|
||||
if (flags->cookies)
|
||||
{if (set_cookies(curl, flags->cookies) != OC_NOERR) goto fail;}
|
||||
return OC_NOERR;
|
||||
fail:
|
||||
return OC_ECURL;
|
||||
}
|
||||
|
||||
/* This is called with arguments while the other functions in this file are
|
||||
* used with global values read from the.dodsrc file.
|
||||
*/
|
||||
@ -58,28 +43,28 @@ set_user_password(CURL* curl, const char *userC, const char *passwordC)
|
||||
}
|
||||
|
||||
int
|
||||
set_proxy(CURL* curl, struct OCproxy *proxy)
|
||||
set_proxy(CURL* curl, struct OCproxy *pstructProxy)
|
||||
{
|
||||
CURLcode cstat;
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXY, proxy->host);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXY, pstructProxy->host);
|
||||
if (cstat != CURLE_OK)
|
||||
return OC_ECURL;
|
||||
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxy->port);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYPORT, pstructProxy->port);
|
||||
if (cstat != CURLE_OK)
|
||||
return OC_ECURL;
|
||||
|
||||
if (proxy->username) {
|
||||
int userPassSize = strlen(proxy->username) + strlen(
|
||||
proxy->password) + 2;
|
||||
if (pstructProxy->user) {
|
||||
int userPassSize = strlen(pstructProxy->user) + strlen(
|
||||
pstructProxy->password) + 2;
|
||||
char *userPassword = malloc(sizeof(char) * userPassSize);
|
||||
if (!userPassword) {
|
||||
oc_log(LOGERR, "Out of Memory\n");
|
||||
return OC_ENOMEM;
|
||||
}
|
||||
strncpy(userPassword, proxy->username, userPassSize);
|
||||
strncpy(userPassword, pstructProxy->user, userPassSize);
|
||||
strncat(userPassword, ":", userPassSize);
|
||||
strncat(userPassword, proxy->password, userPassSize);
|
||||
strncat(userPassword, pstructProxy->password, userPassSize);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userPassword);
|
||||
if (cstat != CURLE_OK) {
|
||||
free(userPassword);
|
||||
@ -137,36 +122,3 @@ set_compression(CURL* curl)
|
||||
return OC_NOERR;
|
||||
}
|
||||
|
||||
int
|
||||
set_credentials(CURL* curl, struct OCcredentials* creds)
|
||||
{
|
||||
CURLcode cstat = CURLE_OK;
|
||||
if(creds->ssl_certificate) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_SSLCERT, creds->ssl_certificate);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
}
|
||||
if(creds->ssl_key) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_SSLKEY, creds->ssl_key);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
}
|
||||
if(creds->cainfo) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_CAINFO, creds->cainfo);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
}
|
||||
if(creds->capath) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_CAPATH, creds->capath);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
}
|
||||
if(creds->cookiefile) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_COOKIEFILE, creds->cookiefile);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
}
|
||||
if(creds->cookiejar) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_COOKIEJAR, creds->cookiejar);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
}
|
||||
return OC_NOERR;
|
||||
|
||||
fail:
|
||||
return OC_ECURL;
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* rc.h
|
||||
*
|
||||
* Created on: Mar 5, 2009
|
||||
* Author: rikki
|
||||
*/
|
||||
|
||||
#ifndef _CURLFUNCTION_H_
|
||||
#define _CURLFUNCTION_H_
|
||||
|
||||
extern int set_curl_flags(CURL*, OCstate*);
|
||||
extern int set_user_password(CURL*, const char *userC, const char *passwordC);
|
||||
extern int set_proxy(CURL*, struct OCproxy*);
|
||||
extern int set_cookies(CURL*, const char *cook);
|
||||
extern int set_verify(CURL* curl);
|
||||
extern int set_compression(CURL* curl);
|
||||
extern int set_credentials(CURL*, struct OCcredentials*);
|
||||
|
||||
#endif /*_CURLFUNCTION_H_*/
|
||||
|
||||
|
||||
|
90
oc/dap.y
90
oc/dap.y
@ -48,32 +48,32 @@ start:
|
||||
| SCAN_ATTR dassetup attributebody
|
||||
| SCAN_ERROR errorbody
|
||||
| error
|
||||
{$$=dap_unrecognizedresponse(parsestate);}
|
||||
{$$=unrecognizedresponse(parsestate);}
|
||||
;
|
||||
|
||||
datasetbody:
|
||||
'{' declarations '}' datasetname ';'
|
||||
{dap_datasetbody(parsestate,$4,$2);}
|
||||
{datasetbody(parsestate,$4,$2);}
|
||||
;
|
||||
|
||||
|
||||
declarations:
|
||||
/* empty */ {$$=dap_declarations(parsestate,null,null);}
|
||||
| declarations declaration {$$=dap_declarations(parsestate,$1,$2);}
|
||||
/* empty */ {$$=declarations(parsestate,null,null);}
|
||||
| declarations declaration {$$=declarations(parsestate,$1,$2);}
|
||||
;
|
||||
|
||||
/* 01/21/08: James says: no dimensions for grids or sequences */
|
||||
/* 05/08/09: James says: no duplicate map names */
|
||||
declaration:
|
||||
base_type var_name array_decls ';'
|
||||
{$$=dap_makebase(parsestate,$2,$1,$3);}
|
||||
{$$=makebase(parsestate,$2,$1,$3);}
|
||||
| SCAN_STRUCTURE '{' declarations '}' var_name array_decls ';'
|
||||
{if(($$=dap_makestructure(parsestate,$5,$6,$3))==null) {YYABORT;}}
|
||||
{if(($$ = makestructure(parsestate,$5,$6,$3))==null) {YYABORT;}}
|
||||
| SCAN_SEQUENCE '{' declarations '}' var_name ';'
|
||||
{if(($$=dap_makesequence(parsestate,$5,$3))==null) {YYABORT;}}
|
||||
{if(($$ = makesequence(parsestate,$5,$3))==null) {YYABORT;}}
|
||||
| SCAN_GRID '{' SCAN_ARRAY ':' declaration SCAN_MAPS ':'
|
||||
declarations '}' var_name ';'
|
||||
{if(($$=dap_makegrid(parsestate,$10,$5,$8))==null) {YYABORT;}}
|
||||
{if(($$ = makegrid(parsestate,$10,$5,$8))==null) {YYABORT;}}
|
||||
| error
|
||||
{daperror(parsestate,"Unrecognized type"); YYABORT;}
|
||||
;
|
||||
@ -92,13 +92,13 @@ base_type:
|
||||
;
|
||||
|
||||
array_decls:
|
||||
/* empty */ {$$=dap_arraydecls(parsestate,null,null);}
|
||||
| array_decls array_decl {$$=dap_arraydecls(parsestate,$1,$2);}
|
||||
/* empty */ {$$=arraydecls(parsestate,null,null);}
|
||||
| array_decls array_decl {$$=arraydecls(parsestate,$1,$2);}
|
||||
;
|
||||
|
||||
array_decl:
|
||||
'[' SCAN_WORD ']' {$$=dap_arraydecl(parsestate,null,$2);}
|
||||
| '[' name '=dap_' SCAN_WORD ']' {$$=dap_arraydecl(parsestate,$2,$4);}
|
||||
'[' SCAN_WORD ']' {$$=arraydecl(parsestate,null,$2);}
|
||||
| '[' name '=' SCAN_WORD ']' {$$=arraydecl(parsestate,$2,$4);}
|
||||
| error
|
||||
{daperror(parsestate,"Illegal dimension declaration"); YYABORT;}
|
||||
;
|
||||
@ -111,84 +111,84 @@ datasetname:
|
||||
|
||||
var_name: name {$$=$1;};
|
||||
|
||||
dassetup: {dap_dassetup(parsestate);}
|
||||
dassetup: {dassetup(parsestate);}
|
||||
|
||||
attributebody:
|
||||
'{' attr_list '}' {dap_attributebody(parsestate,$2);}
|
||||
'{' attr_list '}' {attributebody(parsestate,$2);}
|
||||
| error
|
||||
{daperror(parsestate,"Illegal DAS body"); YYABORT;}
|
||||
;
|
||||
|
||||
attr_list:
|
||||
/* empty */ {$$=dap_attrlist(parsestate,null,null);}
|
||||
| attr_list attribute {$$=dap_attrlist(parsestate,$1,$2);}
|
||||
/* empty */ {$$=attrlist(parsestate,null,null);}
|
||||
| attr_list attribute {$$=attrlist(parsestate,$1,$2);}
|
||||
;
|
||||
|
||||
attribute:
|
||||
alias ';' {$$=null;} /* ignored */
|
||||
| SCAN_BYTE name bytes ';'
|
||||
{$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_BYTE);}
|
||||
{$$=attribute(parsestate,$2,$3,(Object)SCAN_BYTE);}
|
||||
| SCAN_INT16 name int16 ';'
|
||||
{$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_INT16);}
|
||||
{$$=attribute(parsestate,$2,$3,(Object)SCAN_INT16);}
|
||||
| SCAN_UINT16 name uint16 ';'
|
||||
{$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_UINT16);}
|
||||
{$$=attribute(parsestate,$2,$3,(Object)SCAN_UINT16);}
|
||||
| SCAN_INT32 name int32 ';'
|
||||
{$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_INT32);}
|
||||
{$$=attribute(parsestate,$2,$3,(Object)SCAN_INT32);}
|
||||
| SCAN_UINT32 name uint32 ';'
|
||||
{$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_UINT32);}
|
||||
{$$=attribute(parsestate,$2,$3,(Object)SCAN_UINT32);}
|
||||
| SCAN_FLOAT32 name float32 ';'
|
||||
{$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_FLOAT32);}
|
||||
{$$=attribute(parsestate,$2,$3,(Object)SCAN_FLOAT32);}
|
||||
| SCAN_FLOAT64 name float64 ';'
|
||||
{$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_FLOAT64);}
|
||||
{$$=attribute(parsestate,$2,$3,(Object)SCAN_FLOAT64);}
|
||||
| SCAN_STRING name strs ';'
|
||||
{$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_STRING);}
|
||||
{$$=attribute(parsestate,$2,$3,(Object)SCAN_STRING);}
|
||||
| SCAN_URL name urls ';'
|
||||
{$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_URL);}
|
||||
| name '{' attr_list '}' {$$=dap_attrset(parsestate,$1,$3);}
|
||||
{$$=attribute(parsestate,$2,$3,(Object)SCAN_URL);}
|
||||
| name '{' attr_list '}' {$$=attrset(parsestate,$1,$3);}
|
||||
| error
|
||||
{daperror(parsestate,"Illegal attribute"); YYABORT;}
|
||||
;
|
||||
|
||||
bytes:
|
||||
SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_BYTE);}
|
||||
SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_BYTE);}
|
||||
| bytes ',' SCAN_WORD
|
||||
{$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_BYTE);}
|
||||
{$$=attrvalue(parsestate,$1,$3,(Object)SCAN_BYTE);}
|
||||
;
|
||||
int16:
|
||||
SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_INT16);}
|
||||
SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_INT16);}
|
||||
| int16 ',' SCAN_WORD
|
||||
{$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_INT16);}
|
||||
{$$=attrvalue(parsestate,$1,$3,(Object)SCAN_INT16);}
|
||||
;
|
||||
uint16:
|
||||
SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_UINT16);}
|
||||
SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_UINT16);}
|
||||
| uint16 ',' SCAN_WORD
|
||||
{$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_UINT16);}
|
||||
{$$=attrvalue(parsestate,$1,$3,(Object)SCAN_UINT16);}
|
||||
;
|
||||
int32:
|
||||
SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_INT32);}
|
||||
SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_INT32);}
|
||||
| int32 ',' SCAN_WORD
|
||||
{$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_INT32);}
|
||||
{$$=attrvalue(parsestate,$1,$3,(Object)SCAN_INT32);}
|
||||
;
|
||||
uint32:
|
||||
SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_UINT32);}
|
||||
| uint32 ',' SCAN_WORD {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_UINT32);}
|
||||
SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_UINT32);}
|
||||
| uint32 ',' SCAN_WORD {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_UINT32);}
|
||||
;
|
||||
float32:
|
||||
SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT32);}
|
||||
| float32 ',' SCAN_WORD {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT32);}
|
||||
SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT32);}
|
||||
| float32 ',' SCAN_WORD {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT32);}
|
||||
;
|
||||
float64:
|
||||
SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT64);}
|
||||
| float64 ',' SCAN_WORD {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT64);}
|
||||
SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT64);}
|
||||
| float64 ',' SCAN_WORD {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT64);}
|
||||
;
|
||||
strs:
|
||||
str_or_id {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_STRING);}
|
||||
| strs ',' str_or_id {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_STRING);}
|
||||
str_or_id {$$=attrvalue(parsestate,null,$1,(Object)SCAN_STRING);}
|
||||
| strs ',' str_or_id {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_STRING);}
|
||||
;
|
||||
|
||||
urls:
|
||||
url {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_URL);}
|
||||
| urls ',' url {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_URL);}
|
||||
url {$$=attrvalue(parsestate,null,$1,(Object)SCAN_URL);}
|
||||
| urls ',' url {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_URL);}
|
||||
;
|
||||
|
||||
url:
|
||||
@ -211,7 +211,7 @@ alias:
|
||||
|
||||
errorbody:
|
||||
'{' errorcode errormsg errorptype errorprog '}' ';'
|
||||
{$$=dap_errorbody(parsestate,$2,$3,$4,$5);}
|
||||
{$$=errorbody(parsestate,$2,$3,$4,$5);}
|
||||
;
|
||||
|
||||
errorcode: /*empty*/ {$$=null;} | SCAN_CODE '=' SCAN_WORD ';' {$$=$3;}
|
||||
|
@ -248,7 +248,7 @@ Simple lexer
|
||||
*/
|
||||
|
||||
void
|
||||
dapsetwordchars(DAPlexstate* lexstate, int kind)
|
||||
setwordchars(DAPlexstate* lexstate, int kind)
|
||||
{
|
||||
switch (kind) {
|
||||
case 0:
|
||||
@ -281,7 +281,7 @@ daplexinit(char* input, DAPlexstate** lexstatep)
|
||||
lexstate->next = lexstate->input;
|
||||
lexstate->yytext = ocbytesnew();
|
||||
lexstate->reclaim = oclistnew();
|
||||
dapsetwordchars(lexstate,0); /* Assume DDS */
|
||||
setwordchars(lexstate,0); /* Assume DDS */
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -16,13 +16,13 @@ static int check_int32(char* val, long* value);
|
||||
|
||||
/* Switch to DAS parsing SCAN_WORD definition */
|
||||
void
|
||||
dap_dassetup(DAPparsestate* state)
|
||||
dassetup(DAPparsestate* state)
|
||||
{
|
||||
dapsetwordchars(state->lexstate,1);
|
||||
setwordchars(state->lexstate,1);
|
||||
}
|
||||
|
||||
Object
|
||||
dap_datasetbody(DAPparsestate* state, Object name, Object decls)
|
||||
datasetbody(DAPparsestate* state, Object name, Object decls)
|
||||
{
|
||||
OCnode* node = newocnode((char*)name,OC_Dataset,state);
|
||||
node->subnodes = (OClist*)decls;
|
||||
@ -35,7 +35,7 @@ dap_datasetbody(DAPparsestate* state, Object name, Object decls)
|
||||
}
|
||||
|
||||
Object
|
||||
dap_attributebody(DAPparsestate* state, Object attrlist)
|
||||
attributebody(DAPparsestate* state, Object attrlist)
|
||||
{
|
||||
OCnode* node = newocnode(NULL,OC_Attributeset,state);
|
||||
OCASSERT((state->root == NULL));
|
||||
@ -48,7 +48,7 @@ dap_attributebody(DAPparsestate* state, Object attrlist)
|
||||
}
|
||||
|
||||
Object
|
||||
dap_errorbody(DAPparsestate* state,
|
||||
errorbody(DAPparsestate* state,
|
||||
Object code, Object msg, Object ptype, Object prog)
|
||||
{
|
||||
state->svcerror = 1;
|
||||
@ -59,13 +59,13 @@ dap_errorbody(DAPparsestate* state,
|
||||
}
|
||||
|
||||
Object
|
||||
dap_unrecognizedresponse(DAPparsestate* state)
|
||||
unrecognizedresponse(DAPparsestate* state)
|
||||
{
|
||||
return dap_errorbody(state,"0",state->lexstate->input,NULL,NULL);
|
||||
return errorbody(state,"0",state->lexstate->input,NULL,NULL);
|
||||
}
|
||||
|
||||
Object
|
||||
dap_declarations(DAPparsestate* state, Object decls, Object decl)
|
||||
declarations(DAPparsestate* state, Object decls, Object decl)
|
||||
{
|
||||
OClist* alist = (OClist*)decls;
|
||||
if(alist == NULL)
|
||||
@ -76,7 +76,7 @@ dap_declarations(DAPparsestate* state, Object decls, Object decl)
|
||||
}
|
||||
|
||||
Object
|
||||
dap_arraydecls(DAPparsestate* state, Object arraydecls, Object arraydecl)
|
||||
arraydecls(DAPparsestate* state, Object arraydecls, Object arraydecl)
|
||||
{
|
||||
OClist* alist = (OClist*)arraydecls;
|
||||
if(alist == NULL)
|
||||
@ -87,7 +87,7 @@ dap_arraydecls(DAPparsestate* state, Object arraydecls, Object arraydecl)
|
||||
}
|
||||
|
||||
Object
|
||||
dap_arraydecl(DAPparsestate* state, Object name, Object size)
|
||||
arraydecl(DAPparsestate* state, Object name, Object size)
|
||||
{
|
||||
long value;
|
||||
OCnode* dim;
|
||||
@ -102,7 +102,7 @@ dap_arraydecl(DAPparsestate* state, Object name, Object size)
|
||||
}
|
||||
|
||||
Object
|
||||
dap_attrlist(DAPparsestate* state, Object attrlist, Object attrtuple)
|
||||
attrlist(DAPparsestate* state, Object attrlist, Object attrtuple)
|
||||
{
|
||||
OClist* alist = (OClist*)attrlist;
|
||||
if(alist == NULL)
|
||||
@ -122,7 +122,7 @@ dap_attrlist(DAPparsestate* state, Object attrlist, Object attrtuple)
|
||||
}
|
||||
|
||||
Object
|
||||
dap_attrvalue(DAPparsestate* state, Object valuelist, Object value, Object etype)
|
||||
attrvalue(DAPparsestate* state, Object valuelist, Object value, Object etype)
|
||||
{
|
||||
OClist* alist = (OClist*)valuelist;
|
||||
if(alist == NULL) alist = oclistnew();
|
||||
@ -133,7 +133,7 @@ dap_attrvalue(DAPparsestate* state, Object valuelist, Object value, Object etype
|
||||
}
|
||||
|
||||
Object
|
||||
dap_attribute(DAPparsestate* state, Object name, Object values, Object etype)
|
||||
attribute(DAPparsestate* state, Object name, Object values, Object etype)
|
||||
{
|
||||
OCnode* att;
|
||||
att = newocnode((char*)name,OC_Attribute,state);
|
||||
@ -143,7 +143,7 @@ dap_attribute(DAPparsestate* state, Object name, Object values, Object etype)
|
||||
}
|
||||
|
||||
Object
|
||||
dap_attrset(DAPparsestate* state, Object name, Object attributes)
|
||||
attrset(DAPparsestate* state, Object name, Object attributes)
|
||||
{
|
||||
OCnode* attset;
|
||||
attset = newocnode((char*)name,OC_Attributeset,state);
|
||||
@ -204,7 +204,7 @@ dimnameanon(char* basename, unsigned int index)
|
||||
}
|
||||
|
||||
Object
|
||||
dap_makebase(DAPparsestate* state, Object name, Object etype, Object dimensions)
|
||||
makebase(DAPparsestate* state, Object name, Object etype, Object dimensions)
|
||||
{
|
||||
OCnode* node;
|
||||
node = newocnode((char*)name,OC_Primitive,state);
|
||||
@ -214,7 +214,7 @@ dap_makebase(DAPparsestate* state, Object name, Object etype, Object dimensions)
|
||||
}
|
||||
|
||||
Object
|
||||
dap_makestructure(DAPparsestate* state, Object name, Object dimensions, Object fields)
|
||||
makestructure(DAPparsestate* state, Object name, Object dimensions, Object fields)
|
||||
{
|
||||
OCnode* node;
|
||||
char* dupname;
|
||||
@ -230,7 +230,7 @@ dap_makestructure(DAPparsestate* state, Object name, Object dimensions, Object f
|
||||
}
|
||||
|
||||
Object
|
||||
dap_makesequence(DAPparsestate* state, Object name, Object members)
|
||||
makesequence(DAPparsestate* state, Object name, Object members)
|
||||
{
|
||||
OCnode* node;
|
||||
char* dupname;
|
||||
@ -245,7 +245,7 @@ dap_makesequence(DAPparsestate* state, Object name, Object members)
|
||||
}
|
||||
|
||||
Object
|
||||
dap_makegrid(DAPparsestate* state, Object name, Object arraydecl, Object mapdecls)
|
||||
makegrid(DAPparsestate* state, Object name, Object arraydecl, Object mapdecls)
|
||||
{
|
||||
OCnode* node;
|
||||
/* Check for duplicate map names */
|
||||
|
@ -63,30 +63,30 @@ extern void dap_parse_error(DAPparsestate*,const char *fmt, ...);
|
||||
/* bison parse entry point */
|
||||
extern int dapparse(DAPparsestate*);
|
||||
|
||||
extern Object dap_datasetbody(DAPparsestate*,Object decls, Object name);
|
||||
extern Object dap_declarations(DAPparsestate*,Object decls, Object decl);
|
||||
extern Object dap_arraydecls(DAPparsestate*,Object arraydecls, Object arraydecl);
|
||||
extern Object dap_arraydecl(DAPparsestate*,Object name, Object size);
|
||||
extern Object datasetbody(DAPparsestate*,Object decls, Object name);
|
||||
extern Object declarations(DAPparsestate*,Object decls, Object decl);
|
||||
extern Object arraydecls(DAPparsestate*,Object arraydecls, Object arraydecl);
|
||||
extern Object arraydecl(DAPparsestate*,Object name, Object size);
|
||||
|
||||
extern void dap_dassetup(DAPparsestate*);
|
||||
extern Object dap_attributebody(DAPparsestate*,Object attrlist);
|
||||
extern Object dap_attrlist(DAPparsestate*,Object attrlist, Object attrtuple);
|
||||
extern Object dap_attribute(DAPparsestate*,Object name, Object value, Object etype);
|
||||
extern Object dap_attrset(DAPparsestate*,Object name, Object attributes);
|
||||
extern Object dap_attrvalue(DAPparsestate*,Object valuelist, Object value, Object etype);
|
||||
extern void dassetup(DAPparsestate*);
|
||||
extern Object attributebody(DAPparsestate*,Object attrlist);
|
||||
extern Object attrlist(DAPparsestate*,Object attrlist, Object attrtuple);
|
||||
extern Object attribute(DAPparsestate*,Object name, Object value, Object etype);
|
||||
extern Object attrset(DAPparsestate*,Object name, Object attributes);
|
||||
extern Object attrvalue(DAPparsestate*,Object valuelist, Object value, Object etype);
|
||||
|
||||
extern Object dap_makebase(DAPparsestate*,Object name, Object etype, Object dimensions);
|
||||
extern Object dap_makestructure(DAPparsestate*,Object name, Object dimensions, Object fields);
|
||||
extern Object dap_makesequence(DAPparsestate*,Object name, Object members);
|
||||
extern Object dap_makegrid(DAPparsestate*,Object name, Object arraydecl, Object mapdecls);
|
||||
extern Object makebase(DAPparsestate*,Object name, Object etype, Object dimensions);
|
||||
extern Object makestructure(DAPparsestate*,Object name, Object dimensions, Object fields);
|
||||
extern Object makesequence(DAPparsestate*,Object name, Object members);
|
||||
extern Object makegrid(DAPparsestate*,Object name, Object arraydecl, Object mapdecls);
|
||||
|
||||
extern Object dap_errorbody(DAPparsestate*, Object, Object, Object, Object);
|
||||
extern Object dap_unrecognizedresponse(DAPparsestate*);
|
||||
extern Object errorbody(DAPparsestate*, Object, Object, Object, Object);
|
||||
extern Object unrecognizedresponse(DAPparsestate*);
|
||||
|
||||
/* Lexer entry points */
|
||||
extern int daplex(YYSTYPE*, DAPparsestate*);
|
||||
extern void daplexinit(char* input, DAPlexstate** lexstatep);
|
||||
extern void daplexcleanup(DAPlexstate** lexstatep);
|
||||
extern void dapsetwordchars(DAPlexstate* lexstate, int kind);
|
||||
extern void setwordchars(DAPlexstate* lexstate, int kind);
|
||||
|
||||
#endif /*DAPPARSELEX_H*/
|
||||
|
50
oc/http.c
50
oc/http.c
@ -11,6 +11,7 @@
|
||||
|
||||
static size_t WriteFileCallback(void*, size_t, size_t, void*);
|
||||
static size_t WriteMemoryCallback(void*, size_t, size_t, void*);
|
||||
static int ocsetcurlproperties(CURL* curl, const char*);
|
||||
|
||||
struct Fetchdata {
|
||||
FILE* stream;
|
||||
@ -36,6 +37,9 @@ ocfetchurl_file(CURL* curl, char* url, FILE* stream,
|
||||
CURLcode cstat = CURLE_OK;
|
||||
struct Fetchdata fetchdata;
|
||||
|
||||
|
||||
if((stat = ocsetcurlproperties(curl,url)) != OC_NOERR) goto fail;
|
||||
|
||||
/* Set the URL */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url);
|
||||
if (cstat != CURLE_OK)
|
||||
@ -83,6 +87,8 @@ ocfetchurl(CURL* curl, char* url, OCbytes* buf, long* filetime)
|
||||
CURLcode cstat = CURLE_OK;
|
||||
size_t len;
|
||||
|
||||
if((stat = ocsetcurlproperties(curl,url)) != OC_NOERR) goto fail;
|
||||
|
||||
/* Set the URL */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url);
|
||||
if (cstat != CURLE_OK)
|
||||
@ -236,12 +242,56 @@ occurlclose(CURL* curl)
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
static int
|
||||
ocsetcurlproperties(CURL* curl, const char* url)
|
||||
{
|
||||
CURLcode cstat = CURLE_OK;
|
||||
/* These conditionals look for value in four globals set when the
|
||||
* .dodsrc file was read.
|
||||
*/
|
||||
if (dods_verify) {
|
||||
if (set_verify(curl) != OC_NOERR)
|
||||
goto fail;
|
||||
}
|
||||
if (dods_compress) {
|
||||
if (set_compression(curl) != OC_NOERR)
|
||||
goto fail;
|
||||
}
|
||||
if (pstructProxy) {
|
||||
if (set_proxy(curl, pstructProxy) != OC_NOERR)
|
||||
goto fail;
|
||||
}
|
||||
if (cook) {
|
||||
if (set_cookies(curl, cook) != OC_NOERR)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (credentials_in_url(url)) {
|
||||
char *result_url = NULL;
|
||||
if (extract_credentials(url, &userName, &password, &result_url) != OC_NOERR)
|
||||
goto fail;
|
||||
url = result_url;
|
||||
}
|
||||
|
||||
if (userName && password) {
|
||||
if (set_user_password(curl, userName, password) != OC_NOERR)
|
||||
goto fail;
|
||||
}
|
||||
return OC_NOERR;
|
||||
|
||||
fail:
|
||||
oc_log(LOGERR, "curl error: %s", curl_easy_strerror(cstat));
|
||||
return THROW(OC_ECURL);
|
||||
}
|
||||
|
||||
int
|
||||
ocfetchlastmodified(CURL* curl, char* url, long* filetime)
|
||||
{
|
||||
int stat = OC_NOERR;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
|
||||
if((stat = ocsetcurlproperties(curl,url)) != OC_NOERR) goto fail;
|
||||
|
||||
/* Set the URL */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url);
|
||||
if (cstat != CURLE_OK)
|
||||
|
52
oc/oc.c
52
oc/oc.c
@ -9,28 +9,13 @@
|
||||
#include "oclog.h"
|
||||
#include "occlientparams.h"
|
||||
|
||||
#ifdef ENABLE_RC
|
||||
#include "ocrc.h"
|
||||
#endif
|
||||
|
||||
#undef TRACK
|
||||
|
||||
/**************************************************/
|
||||
|
||||
static int ocinitialized = 0;
|
||||
|
||||
/**************************************************/
|
||||
/* .rc file info */
|
||||
#ifdef ENABLE_RC
|
||||
struct OCrcfile {
|
||||
char* rcfilename;
|
||||
ocrcnode* root;
|
||||
} ocrcfile = {NULL,NULL};
|
||||
#endif
|
||||
|
||||
/**************************************************/
|
||||
/* Track legal ids */
|
||||
|
||||
static OClist* ocmap = NULL;
|
||||
|
||||
#ifdef OC_FASTCONSISTENCY
|
||||
|
||||
#define ocverify(object) ((object) != NULL && (*(object) == OCMAGIC)?1:0)
|
||||
@ -40,8 +25,6 @@ struct OCrcfile {
|
||||
|
||||
#else /*!OC_FASTCONSISTENCY*/
|
||||
|
||||
static OClist* ocmap = NULL;
|
||||
|
||||
static int
|
||||
ocverify(unsigned long object)
|
||||
{
|
||||
@ -95,27 +78,15 @@ fprintf(stderr,"assign: %lu\n",(unsigned long)object); fflush(stderr);
|
||||
|
||||
/**************************************************/
|
||||
|
||||
static int
|
||||
oc_initialize(void)
|
||||
{
|
||||
int status = OC_NOERR;
|
||||
#ifndef OC_FASTCONSISTENCY
|
||||
ocmap = oclistnew();
|
||||
oclistsetalloc(ocmap,1024);
|
||||
#endif
|
||||
status = ocinternalinitialize();
|
||||
ocinitialized = 1;
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
|
||||
OCerror
|
||||
oc_open(const char* url, OCconnection* connp)
|
||||
{
|
||||
OCerror ocerr;
|
||||
OCstate* state;
|
||||
if(!ocinitialized) oc_initialize();
|
||||
if(ocmap == NULL) {
|
||||
ocmap = oclistnew();
|
||||
oclistsetalloc(ocmap,1024);
|
||||
}
|
||||
ocerr = ocopen(&state,url);
|
||||
if(ocerr == OC_NOERR && connp) {
|
||||
*connp = (OCconnection)ocassign(state);
|
||||
@ -1063,14 +1034,3 @@ oc_dumpnode(OCconnection conn, OCobject root0)
|
||||
ocdumpnode(root);
|
||||
return ocerr;
|
||||
}
|
||||
|
||||
OCerror
|
||||
oc_setrcfile(char* rcfile)
|
||||
{
|
||||
#ifdef ENABLE_RC
|
||||
return ocsetrcfile(rcfile);
|
||||
#else
|
||||
return OC_EINVAL;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
6
oc/oc.h
6
oc/oc.h
@ -84,7 +84,6 @@ typedef int OCerror;
|
||||
#define OC_EDAS (-21)
|
||||
#define OC_EDDS (-22)
|
||||
#define OC_EDATADDS (-23)
|
||||
#define OC_ERCFILE (-24)
|
||||
|
||||
typedef enum OCmode {
|
||||
OCFIELDMODE = OC_Structure,
|
||||
@ -449,11 +448,6 @@ extern OCerror oc_update_lastmodified_data(OClink);
|
||||
/* Get last known modification time; -1 => data unknown */
|
||||
extern long oc_get_lastmodified_data(OClink);
|
||||
|
||||
/**************************************************/
|
||||
/* New .rc file system support */
|
||||
|
||||
extern OCerror oc_setrcfile(char* rcfile);
|
||||
|
||||
/**************************************************/
|
||||
|
||||
#endif /*OCINTERNAL_H*/
|
||||
|
345
oc/ocinternal.c
345
oc/ocinternal.c
@ -15,10 +15,6 @@
|
||||
#include "occontent.h"
|
||||
#include "occlientparams.h"
|
||||
#include "rc.h"
|
||||
#include "curlfunctions.h"
|
||||
#ifdef ENABLE_RC
|
||||
#include "ocrc.h"
|
||||
#endif
|
||||
|
||||
#include "http.h"
|
||||
#include "read.h"
|
||||
@ -30,15 +26,9 @@
|
||||
/*#define TMPPATH "/tmp/"*/
|
||||
#endif
|
||||
#define TMPPATH "./"
|
||||
|
||||
/* Define default rc files */
|
||||
#define DODSRC ".dodsrc"
|
||||
#define OPENDAPRC ".opendap.rc"
|
||||
|
||||
#ifdef ENABLE_RC
|
||||
static char* defaultrc = NULL;
|
||||
static ocrcnode* ocrcroot = NULL;
|
||||
#endif
|
||||
#define BUFSIZE 512
|
||||
#define DODSRC_SIZE 9
|
||||
#define DODSRC "/.dodsrc"
|
||||
|
||||
static int ocextractdds(OCstate*,OCtree*);
|
||||
static char* constraintescape(const char* url);
|
||||
@ -46,14 +36,8 @@ static char* constraintescape(const char* url);
|
||||
static OCerror createtempfile(OCstate*,OCtree*);
|
||||
#endif
|
||||
|
||||
static void ocsetcurlproperties(OCstate*);
|
||||
|
||||
extern OCnode* makeunlimiteddimension(void);
|
||||
|
||||
#ifdef ENABLE_RC
|
||||
static void loadrc(OCstate* state, ocrcnode* root);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <fcntl.h>
|
||||
#define _S_IREAD 256
|
||||
@ -75,10 +59,15 @@ int oc_network_order; /* network order is big endian */
|
||||
int oc_invert_xdr_double;
|
||||
int oc_curl_file_supported;
|
||||
|
||||
int
|
||||
ocinternalinitialize(void)
|
||||
static int ocinitialized = 0;
|
||||
|
||||
static int
|
||||
ocinitialize(void)
|
||||
{
|
||||
int stat = OC_NOERR;
|
||||
char buf[BUFSIZE];
|
||||
char *env;
|
||||
int len;
|
||||
|
||||
/* Compute if we are same as network order v-a-v xdr */
|
||||
#ifdef XDRBYTEORDER
|
||||
@ -140,6 +129,37 @@ ocinternalinitialize(void)
|
||||
}
|
||||
oc_loginit();
|
||||
|
||||
/* read/write configuration file */
|
||||
env = getenv("HOME");
|
||||
if (env != NULL) {
|
||||
len = strlen(env);
|
||||
if (len >= BUFSIZE - DODSRC_SIZE) {
|
||||
oc_log(LOGERR, "length of home directory is too long\n");
|
||||
stat = OC_EIO;
|
||||
goto end;
|
||||
}
|
||||
strncpy(buf, env, BUFSIZE - 1);
|
||||
buf[len] = '\0';
|
||||
strncat(buf, DODSRC, BUFSIZE - 1);
|
||||
buf[len + DODSRC_SIZE] = '\0';
|
||||
|
||||
if (ocdebug > 1)
|
||||
fprintf(stderr, "Your RC file: %s\n", buf);
|
||||
|
||||
/* stat = OC_NOERR; */
|
||||
if (access(buf, R_OK) != 0) {
|
||||
if (write_dodsrc(buf) != OC_NOERR) {
|
||||
oc_log(LOGERR, "Error getting buffer\n");
|
||||
stat = OC_EIO;
|
||||
}
|
||||
}
|
||||
|
||||
if (read_dodsrc(buf) != OC_NOERR) {
|
||||
oc_log(LOGERR, "Error parsing buffer\n");
|
||||
stat = OC_EIO;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine if this version of curl supports "file://..." urls.*/
|
||||
{
|
||||
const char* const* proto; /*weird*/
|
||||
@ -154,6 +174,9 @@ ocinternalinitialize(void)
|
||||
}
|
||||
}
|
||||
|
||||
ocinitialized = 1;
|
||||
|
||||
end:
|
||||
return THROW(stat);
|
||||
}
|
||||
|
||||
@ -168,6 +191,11 @@ ocopen(OCstate** statep, const char* url)
|
||||
|
||||
memset((void*)&tmpurl,0,sizeof(tmpurl));
|
||||
|
||||
if(!ocinitialized) {
|
||||
stat=ocinitialize();
|
||||
if(stat) {THROWCHK(stat=OC_EBADURL); goto fail;}
|
||||
}
|
||||
|
||||
if(!dapurlparse(url,&tmpurl)) {THROWCHK(stat=OC_EBADURL); goto fail;}
|
||||
|
||||
stat = occurlopen(&curl);
|
||||
@ -188,10 +216,6 @@ ocopen(OCstate** statep, const char* url)
|
||||
}
|
||||
state->packet = ocbytesnew();
|
||||
ocbytessetalloc(state->packet,DFALTPACKETSIZE); /*initial reasonable size*/
|
||||
|
||||
/* set curl properties for this link */
|
||||
ocsetcurlproperties(state);
|
||||
|
||||
if(statep) *statep = state;
|
||||
return THROW(stat);
|
||||
|
||||
@ -504,274 +528,3 @@ ocupdatelastmodifieddata(OCstate* state)
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
Set curl properties for link based on rc files
|
||||
*/
|
||||
static void
|
||||
ocsetcurlproperties(OCstate* state)
|
||||
{
|
||||
CURL* curl = state->curl;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
char* userName = NULL;
|
||||
char* password = NULL;
|
||||
int stat = OC_NOERR;
|
||||
char *homepath;
|
||||
char* path = NULL;
|
||||
|
||||
/* Load dodsrc file */
|
||||
/* locate the configuration files */
|
||||
homepath = getenv("HOME");
|
||||
if (homepath!= NULL) {
|
||||
path = (char*)malloc(strlen(homepath)+1+strlen(DODSRC)+1);
|
||||
strcpy(path,homepath);
|
||||
strcat(path,"/");
|
||||
strcat(path,DODSRC);
|
||||
if (ocdebug > 1)
|
||||
fprintf(stderr, "DODS RC file: %s\n", path);
|
||||
if(read_dodsrc(path,state) != OC_NOERR) {
|
||||
oc_log(LOGERR, "Error parsing %s\n",path);
|
||||
goto fail;
|
||||
}
|
||||
} else {/*complain*/
|
||||
oc_log(LOGWARN,"Cannot find runtime .dodsrc configuration file");
|
||||
goto fail;
|
||||
}
|
||||
if(path != NULL) {free(path) ; path = NULL;}
|
||||
|
||||
if (credentials_in_url(state->url.url)) {
|
||||
char *result_url = NULL;
|
||||
if(userName) free(userName);
|
||||
if(password) free(password);
|
||||
if (extract_credentials(state->url.url, &userName, &password, &result_url) != OC_NOERR)
|
||||
goto fail;
|
||||
dapurlclear(&state->url);
|
||||
dapurlparse(result_url,&state->url);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_RC
|
||||
path = NULL;
|
||||
if(defaultrc == NULL || strlen(defaultrc) == 0) {
|
||||
if(defaultrc != NULL) free(defaultrc);
|
||||
defaultrc = strdup(OPENDAPRC);
|
||||
}
|
||||
if(defaultrc[0] == '/') {
|
||||
path = (char*)malloc(strlen(defaultrc)+1);
|
||||
} else if (homepath!= NULL) {
|
||||
path = (char*)malloc(strlen(homepath)+1+strlen(defaultrc)+1);
|
||||
strcpy(path,homepath);
|
||||
strcat(path,"/");
|
||||
strcat(path,defaultrc);
|
||||
}
|
||||
if(path!= NULL) {
|
||||
FILE* rcfile;
|
||||
ocrcerror err;
|
||||
if (ocdebug > 1)
|
||||
fprintf(stderr, "OPENDAP RC file: %s\n", path);
|
||||
rcfile = fopen(path,"r");
|
||||
if(rcfile != NULL) {
|
||||
if(!ocrc(rcfile,&ocrcroot,&err)) {
|
||||
oc_log(LOGERR, "Error parsing %s; %s: lineno=%d charno=%d\n",
|
||||
path,err.errmsg,err.lineno,err.charno);
|
||||
goto fail;
|
||||
}
|
||||
} else { /* complain */
|
||||
oc_log(LOGWARN,"Cannot find runtime configuration file");
|
||||
goto fail;
|
||||
}
|
||||
loadrc(state,ocrcroot);
|
||||
} else {/*complain*/
|
||||
oc_log(LOGWARN,"Cannot find runtime configuration file");
|
||||
goto fail;
|
||||
}
|
||||
if(path != NULL) {free(path) ; path = NULL;}
|
||||
|
||||
#endif
|
||||
|
||||
if(state->credentials.password) free(state->credentials.password);
|
||||
state->credentials.password = password; password = NULL;
|
||||
if(state->credentials.identity) free(state->credentials.identity);
|
||||
state->credentials.identity = userName; userName = NULL;
|
||||
|
||||
/* Set curl properties */
|
||||
if((stat=set_curl_flags(curl,state)) != OC_NOERR) goto fail;
|
||||
return;
|
||||
|
||||
fail:
|
||||
if(path != NULL) free(path);
|
||||
if(cstat != CURLE_OK)
|
||||
oc_log(LOGERR, "curl error: %s", curl_easy_strerror(cstat));
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_RC
|
||||
/*
|
||||
Presumed format of the .rc file
|
||||
...
|
||||
curl : {
|
||||
<url-prefix|"*">: {
|
||||
compress: true|false
|
||||
verify: true|false
|
||||
cookies: <string>
|
||||
verbose: true|false
|
||||
followlocation: true|false
|
||||
maxredirs: <number>
|
||||
useragent: <string>
|
||||
credentials: {
|
||||
identity: <string>
|
||||
password: <string>
|
||||
ssl-certificate: <string>
|
||||
ssl-key: <string>
|
||||
ssl-authority : <string>
|
||||
capath: <string>
|
||||
cookiefile: <string>
|
||||
cookiejar: <string>
|
||||
} //credentials
|
||||
proxy: {
|
||||
host: <string>
|
||||
port: <number>
|
||||
username: <string>
|
||||
password: <string>
|
||||
} //proxy
|
||||
}
|
||||
<url-prefix>: {
|
||||
...
|
||||
}
|
||||
} // curl
|
||||
|
||||
oc : {
|
||||
<url-prefix>: { // oc specific flags per url
|
||||
...
|
||||
} <url-prefix>
|
||||
} //oc
|
||||
...
|
||||
*/
|
||||
|
||||
static void
|
||||
processproxy(OCstate* state, ocrcnode* creds)
|
||||
{
|
||||
ocrcnode* value;
|
||||
if((value=ocrc_lookup(creds,"host"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->proxy.host = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(creds,"port"))) {
|
||||
if(value->nodeclass == ocrc_const && value->constclass == ocrc_number)
|
||||
state->proxy.port = atoi(value->constvalue);
|
||||
} else if((value=ocrc_lookup(creds,"username"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->proxy.username = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(creds,"password"))) {
|
||||
if(value->nodeclass == ocrc_const && value->constclass == ocrc_number)
|
||||
state->proxy.password = strdup(value->constvalue);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
processcreds(OCstate* state, ocrcnode* match)
|
||||
{
|
||||
ocrcnode* value;
|
||||
ocrcnode* creds = ocrc_lookup(match,"credentials");
|
||||
if((value=ocrc_lookup(match,"compress"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->credentials.identity = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(match,"verify"))) {
|
||||
if(value->nodeclass == ocrc_const && value->constclass == ocrc_number)
|
||||
state->curlflags.verify = atoi(value->constvalue);
|
||||
} else if((value=ocrc_lookup(creds,"identity"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->credentials.identity = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(creds,"password"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->credentials.password = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(creds,"ssl-certificate"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->credentials.ssl_certificate = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(creds,"ssl-key"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->credentials.ssl_key = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(creds,"ssl-authority "))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->credentials.ssl_authority = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(creds,"capath"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->credentials.capath = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(creds,"cookiefile"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->credentials.cookiefile = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(creds,"cookiejar"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->credentials.cookiejar = strdup(value->constvalue);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
processmatch(OCstate* state, ocrcnode* match)
|
||||
{
|
||||
ocrcnode* value;
|
||||
if((value=ocrc_lookup(match,"compress"))) {
|
||||
if(value == ocrc_const_true) state->curlflags.compress = 1;
|
||||
} else if((value=ocrc_lookup(match,"verify"))) {
|
||||
if(value == ocrc_const_true) state->curlflags.verify = 1;
|
||||
} else if((value=ocrc_lookup(match,"cookies"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->curlflags.cookies = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(match,"verbose"))) {
|
||||
if(value == ocrc_const_true) state->curlflags.verbose = 1;
|
||||
} else if((value=ocrc_lookup(match,"followlocation"))) {
|
||||
if(value == ocrc_const_true) state->curlflags.followlocation = 1;
|
||||
} else if((value=ocrc_lookup(match,"maxredirs"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->curlflags.cookies = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(match,"useragent"))) {
|
||||
if(value->nodeclass == ocrc_const)
|
||||
state->curlflags.useragent = strdup(value->constvalue);
|
||||
} else if((value=ocrc_lookup(match,"credentials"))) {
|
||||
processcreds(state,value);
|
||||
} else if((value=ocrc_lookup(match,"proxy"))) {
|
||||
processproxy(state,value);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
loadrc(OCstate* state, ocrcnode* root)
|
||||
{
|
||||
/* Get curl : {...} for matching urls */
|
||||
char* url = state->url.base;
|
||||
ocrcnode** matches;
|
||||
ocrcnode* ocroot;
|
||||
int i;
|
||||
|
||||
ocrcnode* curlroot = ocrc_lookup(root,"curl");
|
||||
if(curlroot->nodeclass != ocrc_map) {
|
||||
oc_log(LOGERR, "non-map oc in rc file");
|
||||
fprintf(stderr,"non-map oc in rc file\n");
|
||||
goto fail;
|
||||
}
|
||||
if(curlroot != NULL) {
|
||||
int nmatches = ocrc_urlmatch(curlroot,url,&matches);
|
||||
if(nmatches == 0) goto oc;
|
||||
for(i=0;i<nmatches;i++) {
|
||||
ocrcnode* match = matches[i];
|
||||
processmatch(state,match);
|
||||
}
|
||||
}
|
||||
|
||||
oc:
|
||||
ocroot = ocrc_lookup(root,"oc");
|
||||
if(ocroot != NULL) {
|
||||
}
|
||||
|
||||
fail:
|
||||
return;
|
||||
}
|
||||
|
||||
OCerror
|
||||
ocsetrcfile(char* rcfile)
|
||||
{
|
||||
if(rcfile == NULL || strlen(rcfile) == 0) return OC_ERCFILE;
|
||||
if(defaultrc != NULL) free(defaultrc);
|
||||
defaultrc = strdup(rcfile);
|
||||
return OC_NOERR;
|
||||
}
|
||||
|
||||
#endif /*ENABLE_RC*/
|
||||
|
@ -94,33 +94,6 @@ typedef struct OCstate
|
||||
} error;
|
||||
long ddslastmodified;
|
||||
long datalastmodified;
|
||||
/* Store .rc file info */
|
||||
struct OCcurlflags {
|
||||
int compress;
|
||||
int verify;
|
||||
char *cookies;
|
||||
int verbose;
|
||||
int followlocation;
|
||||
int maxredirs;
|
||||
char* useragent;
|
||||
} curlflags;
|
||||
struct OCcredentials {
|
||||
char *identity;
|
||||
char *password;
|
||||
char* ssl_certificate;
|
||||
char* ssl_key;
|
||||
char* ssl_authority;
|
||||
char* cainfo; /* certificate authority */
|
||||
char* capath;
|
||||
char* cookiefile;
|
||||
char* cookiejar;
|
||||
} credentials;
|
||||
struct OCproxy {
|
||||
char *host;
|
||||
int port;
|
||||
char *username;
|
||||
char *password;
|
||||
} proxy;
|
||||
} OCstate;
|
||||
|
||||
/*! Specifies all the info about a particular DAP tree
|
||||
@ -212,7 +185,6 @@ extern OCerror ocfetch(OCstate*, const char*, OCdxd, OCnode**);
|
||||
/* Location: ocinternal.c */
|
||||
extern int oc_network_order;
|
||||
extern int oc_invert_xdr_double;
|
||||
extern int ocinternalinitialize(void);
|
||||
|
||||
/* Location: ocnode.c */
|
||||
extern void ocfreetree(OCtree* tree);
|
||||
@ -229,8 +201,6 @@ extern int ocddsdasmerge(struct OCstate*, OCnode* das, OCnode* dds);
|
||||
|
||||
extern OCerror ocupdatelastmodifieddata(OCstate* state);
|
||||
|
||||
extern int ocinternalinitialize(void);
|
||||
|
||||
/* Use my own ntohl an htonl */
|
||||
#define ocntoh(i) (oc_network_order?(i):ocbyteswap((i)))
|
||||
#define ochton(i) ocntoh(i)
|
||||
@ -246,6 +216,4 @@ extern int ocinternalinitialize(void);
|
||||
iswap = (b0 | (b1 << 8) | (b2 << 16) | (b3 << 24)); \
|
||||
}
|
||||
|
||||
extern OCerror ocsetrcfile(char* rcfile);
|
||||
|
||||
#endif /*COMMON_H*/
|
||||
|
@ -381,8 +381,6 @@ ocerrstring(int err)
|
||||
return "OC_EDDS: Malformed or unreadable DDS";
|
||||
case OC_EDATADDS:
|
||||
return "OC_EDATADDS: Malformed or unreadable DATADDS";
|
||||
case OC_ERCFILE:
|
||||
return "OC_ERCFILE: Malformed or unreadable run-time configuration file";
|
||||
default: break;
|
||||
}
|
||||
return "<unknown error code>";
|
||||
|
132
oc/rc.c
132
oc/rc.c
@ -19,7 +19,13 @@
|
||||
/* These globals are where information from the .dodsrc file is stored. See the
|
||||
* functions in curlfunctions.c
|
||||
*/
|
||||
int dods_compress = 0;
|
||||
int dods_verify = 0;
|
||||
struct OCproxy *pstructProxy = NULL;
|
||||
char *cook = NULL;
|
||||
|
||||
char *userName = NULL;
|
||||
char *password = NULL;
|
||||
|
||||
/* The Username and password are in the URL if the URL is of the form:
|
||||
* http://<name>:<passwd>@<host>/....
|
||||
@ -92,11 +98,32 @@ extract_credentials(const char *url, char **name, char **pw, char **result_url)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
set_credentials(const char *name, const char *pw)
|
||||
{
|
||||
if (!(name && pw)) {
|
||||
oc_log(LOGERR, "Both username and password must be given.");
|
||||
return OC_EIO;
|
||||
}
|
||||
|
||||
userName = malloc(sizeof(char) * (strlen(name) + 1));
|
||||
if (!userName)
|
||||
return OC_ENOMEM;
|
||||
strcpy(userName, name);
|
||||
|
||||
password = malloc(sizeof(char) * (strlen(pw) + 1));
|
||||
if (!password)
|
||||
return OC_ENOMEM;
|
||||
strcpy(password, pw);
|
||||
|
||||
return OC_NOERR;
|
||||
}
|
||||
|
||||
/*Allows for a .dodsrc file to be read in and parsed in order to get authentication information*/
|
||||
int
|
||||
read_dodsrc(char *in_file_name, OCstate* state)
|
||||
read_dodsrc(char *in_file_name)
|
||||
{
|
||||
char *p;
|
||||
char *p;
|
||||
char more[1024];
|
||||
char *v;
|
||||
FILE *in_file;
|
||||
@ -105,7 +132,7 @@ read_dodsrc(char *in_file_name, OCstate* state)
|
||||
in_file = fopen(in_file_name, "r"); /* Open the file to read it */
|
||||
if (in_file == NULL) {
|
||||
oc_log(LOGERR, "Could not open the .dodsrc file");
|
||||
return OC_EPERM;
|
||||
return OC_EIO;
|
||||
}
|
||||
|
||||
unsupported[0] = '\0';
|
||||
@ -116,39 +143,48 @@ read_dodsrc(char *in_file_name, OCstate* state)
|
||||
*p = '\0';
|
||||
|
||||
if (strcmp(more, "USE_CACHE") == 0) {
|
||||
/*strcat(unsupported,",USE_CACHE");*/
|
||||
strcat(unsupported,",USE_CACHE");
|
||||
} else if (strcmp(more, "MAX_CACHE_SIZE") == 0) {
|
||||
/*strcat(unsupported,",USE_CACHE");*/
|
||||
strcat(unsupported,",USE_CACHE");
|
||||
} else if (strcmp(more, "MAX_CACHED_OBJ") == 0) {
|
||||
/*strcat(unsupported,",MAX_CACHED_OBJ");*/
|
||||
strcat(unsupported,",MAX_CACHED_OBJ");
|
||||
} else if (strcmp(more, "IGNORE_EXPIRES") == 0) {
|
||||
/*strcat(unsupported,",IGNORE_EXPIRES");*/
|
||||
strcat(unsupported,",IGNORE_EXPIRES");
|
||||
} else if (strcmp(more, "CACHE_ROOT") == 0) {
|
||||
/*strcat(unsupported,",CACHE_ROOT");*/
|
||||
strcat(unsupported,",CACHE_ROOT");
|
||||
} else if (strcmp(more, "DEFAULT_EXPIRES") == 0) {
|
||||
/*strcat(unsupported,",DEFAULT_EXPIRES");*/
|
||||
strcat(unsupported,",DEFAULT_EXPIRES");
|
||||
} else if (strcmp(more, "ALWAYS_VALIDATE") == 0) {
|
||||
/*strcat(unsupported,",ALWAYS_VALIDATE");*/
|
||||
strcat(unsupported,",ALWAYS_VALIDATE");
|
||||
} else if (strcmp(more, "DEFLATE") == 0) {
|
||||
/* int v_len = strlen(v); unused */
|
||||
if(atoi(v)) state->curlflags.compress = 1;
|
||||
dods_compress = atoi(v);
|
||||
if (ocdebug > 1)
|
||||
oc_log(LOGNOTE,"Compression: %d", state->curlflags.compress);
|
||||
oc_log(LOGNOTE,"Compression: %d", dods_compress);
|
||||
} else if (strcmp(more, "VALIDATE_SSL") == 0) {
|
||||
if(atoi(v)) state->curlflags.verify = 1;
|
||||
dods_verify = atoi(v);
|
||||
if (ocdebug > 1)
|
||||
oc_log(LOGNOTE,"SSL Verification: %d", state->curlflags.verify);
|
||||
oc_log(LOGNOTE,"SSL Verification: %d", dods_verify);
|
||||
} else if (strcmp(more, "PROXY_SERVER") == 0) {
|
||||
char *host_pos = NULL;
|
||||
char *port_pos = NULL;
|
||||
/* int v_len = strlen(v); unused */
|
||||
|
||||
if(strlen(v) == 0) continue; /* nothing there*/
|
||||
pstructProxy = malloc(sizeof(struct OCproxy));
|
||||
if (!pstructProxy)
|
||||
return OC_ENOMEM;
|
||||
|
||||
if (credentials_in_url(v)) {
|
||||
char *result_url = NULL;
|
||||
extract_credentials(v, &state->proxy.username, &state->proxy.password, &result_url);
|
||||
extract_credentials(v, &pstructProxy->user, &pstructProxy->password, &result_url);
|
||||
v = result_url;
|
||||
}
|
||||
else {
|
||||
pstructProxy->user = NULL;
|
||||
pstructProxy->password = NULL;
|
||||
}
|
||||
|
||||
/* allocating a bit more than likely needed ... */
|
||||
host_pos = strstr(v, "http://");
|
||||
if (host_pos)
|
||||
@ -161,82 +197,79 @@ read_dodsrc(char *in_file_name, OCstate* state)
|
||||
port_pos++;
|
||||
*port_sep = '\0';
|
||||
host_len = strlen(host_pos);
|
||||
state->proxy.host = malloc(sizeof(char) * host_len + 1);
|
||||
if (!state->proxy.host)
|
||||
pstructProxy->host = malloc(sizeof(char) * host_len + 1);
|
||||
if (!pstructProxy->host)
|
||||
return OC_ENOMEM;
|
||||
|
||||
strncpy(state->proxy.host, host_pos, host_len);
|
||||
state->proxy.host[host_len + 1] = '\0';
|
||||
strncpy(pstructProxy->host, host_pos, host_len);
|
||||
pstructProxy->host[host_len + 1] = '\0';
|
||||
|
||||
state->proxy.port = atoi(port_pos);
|
||||
pstructProxy->port = atoi(port_pos);
|
||||
}
|
||||
else {
|
||||
int host_len = strlen(host_pos);
|
||||
state->proxy.host = malloc(sizeof(char) * host_len + 1);
|
||||
if (!state->proxy.host)
|
||||
pstructProxy->host = malloc(sizeof(char) * host_len + 1);
|
||||
if (!pstructProxy->host)
|
||||
return OC_ENOMEM;
|
||||
|
||||
strncpy(state->proxy.host, host_pos, host_len);
|
||||
state->proxy.host[host_len + 1] = '\0';
|
||||
strncpy(pstructProxy->host, host_pos, host_len);
|
||||
pstructProxy->host[host_len + 1] = '\0';
|
||||
|
||||
state->proxy.port = 80;
|
||||
pstructProxy->port = 80;
|
||||
}
|
||||
#if 0
|
||||
state->proxy.host[v_len] = '\0';
|
||||
pstructProxy->host[v_len] = '\0';
|
||||
|
||||
state->proxy.port = atoi(v);
|
||||
pstructProxy->port = atoi(v);
|
||||
|
||||
s_len = strlen(v);
|
||||
state->proxy.user = malloc(sizeof(char) * s_len + 1);
|
||||
if (!state->proxy.user)
|
||||
pstructProxy->user = malloc(sizeof(char) * s_len + 1);
|
||||
if (!pstructProxy->user)
|
||||
return OC_ENOMEM;
|
||||
strncpy(state->proxy.user, v, s_len);
|
||||
state->proxy.user[s_len] = '\0';
|
||||
strncpy(pstructProxy->user, v, s_len);
|
||||
pstructProxy->user[s_len] = '\0';
|
||||
|
||||
p_len = strlen(v);
|
||||
state->proxy.password = malloc(sizeof(char) * p_len + 1);
|
||||
if (!state->proxy.password)
|
||||
pstructProxy->password = malloc(sizeof(char) * p_len + 1);
|
||||
if (!pstructProxy->password)
|
||||
return OC_ENOMEM;
|
||||
strncpy(state->proxy.password, v, p_len);
|
||||
state->proxy.password[p_len] = '\0';
|
||||
strncpy(pstructProxy->password, v, p_len);
|
||||
pstructProxy->password[p_len] = '\0';
|
||||
#endif
|
||||
if (ocdebug > 1) {
|
||||
oc_log(LOGNOTE,"host name: %s", state->proxy.host);
|
||||
oc_log(LOGNOTE,"user name: %s", state->proxy.username);
|
||||
oc_log(LOGNOTE,"password name: %s", state->proxy.password);
|
||||
oc_log(LOGNOTE,"port number: %d", state->proxy.port);
|
||||
oc_log(LOGNOTE,"host name: %s", pstructProxy->host);
|
||||
oc_log(LOGNOTE,"user name: %s", pstructProxy->user);
|
||||
oc_log(LOGNOTE,"password name: %s", pstructProxy->password);
|
||||
oc_log(LOGNOTE,"port number: %d", pstructProxy->port);
|
||||
}
|
||||
|
||||
} else if (strcmp(more, "NO_PROXY_FOR") == 0) {
|
||||
/*strcat(unsupported,",NO_PROXY_FOR");*/
|
||||
strcat(unsupported,",NO_PROXY_FOR");
|
||||
} else if (strcmp(more, "AIS_DATABASE") == 0) {
|
||||
/*strcat(unsupported,",AIS_DATABASE");*/
|
||||
strcat(unsupported,",AIS_DATABASE");
|
||||
} else if (strcmp(more, "COOKIE_JAR") == 0) {
|
||||
int v_len = strlen(v);
|
||||
state->curlflags.cookies = malloc(sizeof(char) * v_len + 1);
|
||||
if (!state->curlflags.cookies)
|
||||
cook = malloc(sizeof(char) * v_len + 1);
|
||||
if (!cook)
|
||||
return OC_ENOMEM;
|
||||
strncpy(state->curlflags.cookies, v, v_len);
|
||||
state->curlflags.cookies[v_len] = '\0';
|
||||
strncpy(cook, v, v_len);
|
||||
cook[v_len] = '\0';
|
||||
if (ocdebug > 1)
|
||||
oc_log(LOGNOTE,"Cookie jar name: %s", state->curlflags.cookies);
|
||||
oc_log(LOGNOTE,"Cookie jar name: %s", cook);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
fclose(in_file);
|
||||
|
||||
#ifdef IGNORE
|
||||
if(unsupported[0] != '\0') {
|
||||
unsupported[0] = ' '; /* Elide leading comma */
|
||||
oc_log(LOGNOTE,"Not currently supported in .dodsrc: %s",unsupported);
|
||||
}
|
||||
#endif
|
||||
|
||||
return OC_NOERR;
|
||||
}
|
||||
|
||||
#ifdef OBSOLETE
|
||||
/*Allows for a .dodsrc file to be created if one does not currently exist for default authentication
|
||||
* values*/
|
||||
int
|
||||
@ -284,4 +317,3 @@ write_dodsrc(char *out_file_name)
|
||||
|
||||
return OC_NOERR;
|
||||
}
|
||||
#endif
|
||||
|
17
oc/rc.h
17
oc/rc.h
@ -8,6 +8,13 @@
|
||||
#ifndef RC_H_
|
||||
#define RC_H_
|
||||
|
||||
struct OCproxy {
|
||||
char *host;
|
||||
int port;
|
||||
char *user;
|
||||
char *password;
|
||||
};
|
||||
|
||||
extern int dods_compress;
|
||||
extern int dods_verify;
|
||||
extern struct OCproxy *pstructProxy;
|
||||
@ -17,13 +24,13 @@ extern char *password;
|
||||
|
||||
extern int credentials_in_url(const char *url);
|
||||
extern int extract_credentials(const char *url, char **name, char **pw, char **result_url);
|
||||
extern int set_credentials(CURL* curl, struct OCcredentials* creds);
|
||||
extern int read_dodsrc(char *in_file_name, OCstate* state);
|
||||
#ifdef OBSOLETE
|
||||
extern int set_credentials(const char *name, const char *pw);
|
||||
extern int read_dodsrc(char *in_file_name);
|
||||
extern int write_dodsrc(char *out_file_name);
|
||||
#endif
|
||||
|
||||
extern int set_proxy(CURL* curl, struct OCproxy*);
|
||||
extern int set_user_password(CURL* curl, const char *userC,
|
||||
const char *passwordC);
|
||||
extern int set_proxy(CURL* curl, struct OCproxy *pstructProxy);
|
||||
extern int set_cookies(CURL* curl, const char *cook);
|
||||
extern int set_verify(CURL* curl);
|
||||
extern int set_compression(CURL* curl);
|
||||
|
Loading…
Reference in New Issue
Block a user