[409] | 1 | /* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc. |
---|
| 2 | See the COPYRIGHT file for more information. */ |
---|
| 3 | |
---|
| 4 | #include "config.h" |
---|
| 5 | #include "oc.h" |
---|
| 6 | #include "ocinternal.h" |
---|
| 7 | #include "ocdebug.h" |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | This file exports procedures |
---|
| 11 | that access the internals of |
---|
| 12 | oc. They are intended to be called |
---|
| 13 | by the drno code to avoid at least |
---|
| 14 | the appearance of breaking the oc |
---|
| 15 | encapsulation. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | #if 0 |
---|
| 19 | |
---|
| 20 | OCerror |
---|
| 21 | oc_svcerrordata(OCconnection conn, char** codep, char** msgp, long* httpp) |
---|
| 22 | { |
---|
| 23 | OCstate* state = (OCstate*)conn; |
---|
| 24 | if(codep) *codep = state->error.code; |
---|
| 25 | if(msgp) *msgp = state->error.message; |
---|
| 26 | if(httpp) *httpp = state->error.httpcode; |
---|
| 27 | return OC_NOERR; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | /* DRNO need to explicitly get and walk string values*/ |
---|
| 31 | int |
---|
| 32 | oc_stringcontent(OCstate* state, OCcontent* content, char** stringp, size_t* slenp) |
---|
| 33 | { |
---|
| 34 | int stat = OC_NOERR; |
---|
| 35 | XDR* xdrs; |
---|
| 36 | unsigned int slen; |
---|
| 37 | char* stringmemory; |
---|
| 38 | |
---|
| 39 | if(state == NULL || content == NULL) return OCTHROW(OC_EINVAL); |
---|
| 40 | |
---|
| 41 | if(content->node->octype != OC_Primitive) return OCTHROW(OC_EINVAL); |
---|
| 42 | if(content->node->etype != OC_String |
---|
| 43 | && content->node->etype != OC_URL) return OCTHROW(OC_EINVAL); |
---|
| 44 | |
---|
| 45 | xdrs = state->dap.xdrs; |
---|
| 46 | if(xdrs == NULL) return OCTHROW(OC_EXDR); |
---|
| 47 | |
---|
| 48 | if(oc_contentmode(state,content) != Datamode) return OCTHROW(OC_EINVAL); |
---|
| 49 | /* We are at a single instance of a string data type*/ |
---|
| 50 | if(!xdr_setpos(xdrs,content->xdroffset)) return xdrerror(); |
---|
| 51 | if(!xdr_u_int(xdrs,&slen)) return xdrerror(); |
---|
| 52 | stringmemory = (char*)ocmalloc(slen+1); |
---|
| 53 | MEMCHECK(stringmemory,OC_ENOMEM); |
---|
| 54 | if(!xdr_opaque(xdrs,stringmemory,slen)) return xdrerror(); |
---|
| 55 | stringmemory[slen] = '\0'; |
---|
| 56 | /* restore location*/ |
---|
| 57 | if(!xdr_setpos(xdrs,content->xdroffset)) return xdrerror(); |
---|
| 58 | if(stringp != NULL) *stringp = stringmemory; |
---|
| 59 | if(slenp != NULL) *slenp = slen; |
---|
| 60 | return OCTHROW(stat); |
---|
| 61 | } |
---|
| 62 | #endif |
---|