From: Mario D. S. <sa...@us...> - 2002-09-06 04:49:10
|
Update of /cvsroot/macs/macs/upc/apxs In directory usw-pr-cvs1:/tmp/cvs-serv3405/upc/apxs Modified Files: mod_macs_upc.c Log Message: Apache module now uses new API LIA, secure page now use SWIG perl binding Index: mod_macs_upc.c =================================================================== RCS file: /cvsroot/macs/macs/upc/apxs/mod_macs_upc.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** mod_macs_upc.c 1 Jun 2002 03:32:30 -0000 1.7 --- mod_macs_upc.c 6 Sep 2002 04:49:07 -0000 1.8 *************** *** 39,42 **** --- 39,55 ---- /** + * \brief Parses a namespace/type spec "type:namespace" + * \ingroup upc + */ + int macs_apxs_parsensp(const char *nsp, char **type, char **ns, + request_rec *r) { + if (!(*type=ap_pstrdup(r->pool,nsp))) return 0; + for (*ns=*type; **ns && **ns != ':'; ++*ns) ; + if (!**ns) return 0; + *ns='\0'; ++*ns; + return 1; + } /* macs_apxs_parsensp */ + + /** * \brief Callback function for profile exposure list iteration. * \ingroup upc *************** *** 45,62 **** * incoming ones. */ ! int macs_apxs_expose_upc_cb(void *vcd,const char *header,const char *elt) { ! char *v, *c, *buf; ! const char *aid; long int size; macs_apxs_expose_upc_cbdata *cd=(macs_apxs_expose_upc_cbdata *)vcd; ! ! aid=ap_table_get(cd->dc->aids,header); ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, cd->r, ! "Exposing aid %s elt %s as %s", aid, elt, header); ! buf=ap_psprintf(cd->r->pool, "%s%s%s","MACS_UPC_ELEMENT_",aid,elt); /* we'll cache these in the request notes */ ! /* FIXME: does this make sense? connection notes maybe... */ if (!(v=(char *)ap_table_get(cd->r->notes,buf))) { ! v=macs_upc_get(aid,cd->uid,elt,&size); ap_table_set(cd->r->notes,buf,v); } --- 58,99 ---- * incoming ones. */ ! int macs_apxs_expose_upc_cb(void *vcd,const char *header,const char *nsp) { ! char *v, *buf, *c, *ns=NULL, *nsid=NULL, *res=NULL, *rid=NULL, *type=NULL; long int size; + macs_profile_type t; macs_apxs_expose_upc_cbdata *cd=(macs_apxs_expose_upc_cbdata *)vcd; ! ! res=(char *)ap_table_get(cd->dc->res,header); ! type=(char *)ap_table_get(cd->dc->types,header); ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, cd->r, ! "Exposing %s:%s:%s as %s", type,ns,res,header); ! buf=ap_psprintf(cd->r->pool,"MACS_UPC_ELEMENT_%s:%s:%s",type,ns,res); ! if (!buf) { ! ap_log_rerror(APLOG_MARK,APLOG_ERR|APLOG_NOERRNO,cd->r,"Out of memory"); ! return SERVER_ERROR; ! } /* we'll cache these in the request notes */ ! /* FIXME: is this useful? connection notes maybe... */ if (!(v=(char *)ap_table_get(cd->r->notes,buf))) { ! if (!strcasecmp(res,"%user")) rid=cd->uid; ! else if (!strcasecmp(res,"%url")) { ! /* fetch or determine the resource here */ ! if (!cd->dc->resource && !macs_apxs_demapres(cd->dc,cd->r)) { ! ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, cd->r, ! "Could not demap uri:%s to resource",cd->r->uri); ! ap_table_set(cd->r->notes,"MACS_EXPOSE_UPC_CB","ERROR"); ! return 0; ! } ! res=cd->dc->resource; ! } ! if (!macs_apxs_parsensp(nsp,&type,&ns,cd->r)) { ! ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, cd->r, ! "Could not parse namespace/type spec: %s",nsp); ! ap_table_set(cd->r->notes,"MACS_EXPOSE_UPC_CB","ERROR"); ! return 0; ! } ! nsid=macs_upc_path2id(cd->c->ctx,NULL,ns); ! v=macs_upc_get(cd->c->ctx,NULL,rid,nsid,&t,&size); ! free(rid); free(nsid); ap_table_set(cd->r->notes,buf,v); } *************** *** 71,78 **** ap_pstrcat(cd->r->pool,c,"; ",header,"=",v,"\0",NULL)); ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, cd->r, ! "exposed aid %s elt %s as %s", aid, elt, header); } else { ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, cd->r, ! "got nothing for aid %s elt %s", aid, elt); } return 1; --- 108,115 ---- ap_pstrcat(cd->r->pool,c,"; ",header,"=",v,"\0",NULL)); ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, cd->r, ! "exposed %s:%s as %s",ns,res,header); } else { ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, cd->r, ! "got nothing for %s:%s",ns,res); } return 1; *************** *** 100,104 **** dc=(macs_apxs_dir_cfg *) ap_get_module_config(r->per_dir_config, &macs_module); ! if (ap_is_empty_table(dc->elts)) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, r, "No profile exposure configured for %s", r->uri); --- 137,141 ---- dc=(macs_apxs_dir_cfg *) ap_get_module_config(r->per_dir_config, &macs_module); ! if (ap_is_empty_table(dc->ns)) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, r, "No profile exposure configured for %s", r->uri); *************** *** 109,113 **** /* iterate through profile exposure list and expose */ cd->r=r; cd->c=c; cd->dc=dc; ! ap_table_do(macs_apxs_expose_upc_cb,(void *)cd,dc->elts,NULL); return OK; } /* macs_apxs_expose_upc */ --- 146,151 ---- /* iterate through profile exposure list and expose */ cd->r=r; cd->c=c; cd->dc=dc; ! ap_table_do(macs_apxs_expose_upc_cb,(void *)cd,dc->ns,NULL); ! if (ap_table_get(r->notes,"MACS_EXPOSE_UPC_CB")) return SERVER_ERROR; return OK; } /* macs_apxs_expose_upc */ |