From 398ecf91875258964c4ff41c968f0cb14dafa005 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Fri, 10 Dec 2004 07:33:43 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'glite-wms-utils- exception_branch_1_0_0'. Sprout from master 2004-12-10 07:33:42 UTC Elisabetta Ronchieri 'Increased version' Delete: org.glite.deployment.lb/.cvsignore org.glite.deployment.lb/build.xml org.glite.deployment.lb/config/scripts/glite-lb-config.py org.glite.deployment.lb/config/scripts/remove_all_rpms.sh org.glite.deployment.lb/config/templates/glite-lb.cfg.xml org.glite.deployment.lb/doc/release_notes/release_notes.doc org.glite.deployment.lb/doc/release_notes/release_notes.html org.glite.deployment.lb/doc/release_notes/release_notes.pdf org.glite.deployment.lb/project/.cvsignore org.glite.deployment.lb/project/build.properties org.glite.deployment.lb/project/glite-lb.sdf.xml.template org.glite.deployment.lb/project/glite-lb.spec org.glite.deployment.lb/project/lxscript-rpm.xsl org.glite.deployment.lb/project/lxscript-tgz.xsl org.glite.deployment.lb/project/properties.xml org.glite.deployment.lb/project/quattor-template.xsl org.glite.deployment.lb/project/version.properties org.glite.jp.common/.cvsignore org.glite.jp.common/Makefile org.glite.jp.common/build.xml org.glite.jp.common/interface/context.h org.glite.jp.common/interface/strmd5.h org.glite.jp.common/interface/types.h org.glite.jp.common/project/build.properties org.glite.jp.common/project/configure.properties.xml org.glite.jp.common/project/properties.xml org.glite.jp.common/project/tar_exclude org.glite.jp.common/project/version.properties org.glite.jp.common/src/context.c org.glite.jp.common/src/strmd5.c org.glite.jp.index/.cvsignore org.glite.jp.index/Makefile org.glite.jp.index/build.xml org.glite.jp.index/project/JobProvenanceIS.wsdl org.glite.jp.index/project/build.properties org.glite.jp.index/project/configure.properties.xml org.glite.jp.index/project/properties.xml org.glite.jp.index/project/tar_exclude org.glite.jp.index/project/version.properties org.glite.jp.index/src/simple_server.c org.glite.jp.index/src/soap_ops.c org.glite.jp.index/src/typemap.dat org.glite.jp.primary/.cvsignore org.glite.jp.primary/Makefile org.glite.jp.primary/build.xml org.glite.jp.primary/examples/jpps-test.c org.glite.jp.primary/project/build.properties org.glite.jp.primary/project/configure.properties.xml org.glite.jp.primary/project/properties.xml org.glite.jp.primary/project/tar_exclude org.glite.jp.primary/project/version.properties org.glite.jp.primary/src/backend.h org.glite.jp.primary/src/feed.c org.glite.jp.primary/src/feed.h org.glite.jp.primary/src/ftp_backend.c org.glite.jp.primary/src/is_client.c org.glite.jp.primary/src/jptype_map.h org.glite.jp.primary/src/simple_server.c org.glite.jp.primary/src/soap_ops.c org.glite.jp.primary/src/tags.c org.glite.jp.primary/src/tags.h org.glite.jp.primary/src/typemap.dat org.glite.jp/.cvsignore org.glite.jp/build.xml org.glite.jp/project/JobProvenance.wsdl org.glite.jp/project/JobProvenanceIS.wsdl org.glite.jp/project/JobProvenancePS.wsdl org.glite.jp/project/JobProvenanceTypes.wsdl org.glite.jp/project/JobProvenanceTypes.xsd org.glite.jp/project/build.properties org.glite.jp/project/dependencies.properties org.glite.jp/project/glite.jp.csf.xml org.glite.jp/project/properties.xml org.glite.jp/project/run-workspace org.glite.jp/project/taskdefs.xml org.glite.jp/project/version.properties org.glite.lb.client-interface/.cvsignore org.glite.lb.client-interface/LICENSE org.glite.lb.client-interface/Makefile org.glite.lb.client-interface/build.xml org.glite.lb.client-interface/interface/CountRef.h org.glite.lb.client-interface/interface/Event.h.T org.glite.lb.client-interface/interface/Job.h org.glite.lb.client-interface/interface/JobStatus.h.T org.glite.lb.client-interface/interface/LoggingExceptions.h org.glite.lb.client-interface/interface/Notification.h org.glite.lb.client-interface/interface/ServerConnection.h org.glite.lb.client-interface/interface/consumer.h org.glite.lb.client-interface/interface/consumer_fake.h org.glite.lb.client-interface/interface/context.h org.glite.lb.client-interface/interface/dump.h org.glite.lb.client-interface/interface/events.h.T org.glite.lb.client-interface/interface/jobstat.h.T org.glite.lb.client-interface/interface/load.h org.glite.lb.client-interface/interface/notification.h org.glite.lb.client-interface/interface/notifid.h org.glite.lb.client-interface/interface/producer.h.T org.glite.lb.client-interface/interface/producer_fake.h org.glite.lb.client-interface/interface/purge.h org.glite.lb.client-interface/project/build.properties org.glite.lb.client-interface/project/configure.properties.xml org.glite.lb.client-interface/project/properties.xml org.glite.lb.client-interface/project/tar_exclude org.glite.lb.client-interface/project/version.properties org.glite.lb.client/.cvsignore org.glite.lb.client/LICENSE org.glite.lb.client/Makefile org.glite.lb.client/build.xml org.glite.lb.client/doc/README-fake org.glite.lb.client/examples/aborted.l org.glite.lb.client/examples/cancelled.l org.glite.lb.client/examples/chkpt.l org.glite.lb.client/examples/cleared.l org.glite.lb.client/examples/consumer_fake.c org.glite.lb.client/examples/done.l org.glite.lb.client/examples/done_dag.l org.glite.lb.client/examples/done_subjob.l org.glite.lb.client/examples/failed_dag.l org.glite.lb.client/examples/failed_subjob.l org.glite.lb.client/examples/feed_shark.c org.glite.lb.client/examples/gen_begin org.glite.lb.client/examples/gen_sample_job org.glite.lb.client/examples/job_log.c org.glite.lb.client/examples/job_reg.c org.glite.lb.client/examples/log_usertag_proxy.c org.glite.lb.client/examples/notify.c org.glite.lb.client/examples/producer_fake.c org.glite.lb.client/examples/query_ext.c org.glite.lb.client/examples/query_seq_code.c org.glite.lb.client/examples/ready.l org.glite.lb.client/examples/ready_dag.l org.glite.lb.client/examples/ready_subjob.l org.glite.lb.client/examples/running.l org.glite.lb.client/examples/running_dag.l org.glite.lb.client/examples/running_subjob.l org.glite.lb.client/examples/scheduled.l org.glite.lb.client/examples/scheduled_dag.l org.glite.lb.client/examples/scheduled_subjob.l org.glite.lb.client/examples/submitted.l org.glite.lb.client/examples/submitted_dag.l org.glite.lb.client/examples/submitted_subjob.l org.glite.lb.client/examples/waiting.l org.glite.lb.client/examples/waiting_dag.l org.glite.lb.client/examples/waiting_subjob.l org.glite.lb.client/project/build.properties org.glite.lb.client/project/configure.properties.xml org.glite.lb.client/project/properties.xml org.glite.lb.client/project/tar_exclude org.glite.lb.client/project/version.properties org.glite.lb.client/src/Event.cpp.T org.glite.lb.client/src/Job.cpp org.glite.lb.client/src/JobStatus.cpp.T org.glite.lb.client/src/Notification.cpp org.glite.lb.client/src/ServerConnection.cpp org.glite.lb.client/src/args.c.T org.glite.lb.client/src/args.h org.glite.lb.client/src/connection.c org.glite.lb.client/src/connection.h org.glite.lb.client/src/consumer.c org.glite.lb.client/src/dump.c org.glite.lb.client/src/load.c org.glite.lb.client/src/logevent.c.T org.glite.lb.client/src/notification.c org.glite.lb.client/src/prod_proto.c org.glite.lb.client/src/prod_proto.h org.glite.lb.client/src/producer.c org.glite.lb.client/src/purge.c org.glite.lb.client/src/uiwrap.c.T org.glite.lb.client/test/prod_proto_test.c org.glite.lb.client/test/producer_test.cpp org.glite.lb.common/.cvsignore org.glite.lb.common/LICENSE org.glite.lb.common/Makefile org.glite.lb.common/build.xml org.glite.lb.common/interface/authz.h org.glite.lb.common/interface/context-int.h org.glite.lb.common/interface/escape.h org.glite.lb.common/interface/events_parse.h org.glite.lb.common/interface/il_string.h org.glite.lb.common/interface/lb_gss.h org.glite.lb.common/interface/lb_plain_io.h org.glite.lb.common/interface/log_proto.h org.glite.lb.common/interface/mini_http.h org.glite.lb.common/interface/trio.h org.glite.lb.common/interface/ulm_parse.h org.glite.lb.common/interface/xml_conversions.h org.glite.lb.common/interface/xml_parse.h org.glite.lb.common/project/build.properties org.glite.lb.common/project/configure.properties.xml org.glite.lb.common/project/properties.xml org.glite.lb.common/project/tar_exclude org.glite.lb.common/project/version.properties org.glite.lb.common/src/context.c org.glite.lb.common/src/escape.c org.glite.lb.common/src/events.c.T org.glite.lb.common/src/events_parse.c.T org.glite.lb.common/src/il_int.c org.glite.lb.common/src/il_log.c org.glite.lb.common/src/il_msg.c org.glite.lb.common/src/il_string.c org.glite.lb.common/src/lb_gss.c org.glite.lb.common/src/lb_plain_io.c org.glite.lb.common/src/mini_http.c org.glite.lb.common/src/notifid.c org.glite.lb.common/src/param.c org.glite.lb.common/src/query_rec.c org.glite.lb.common/src/status.c.T org.glite.lb.common/src/strio.c org.glite.lb.common/src/strio.h org.glite.lb.common/src/trio.c org.glite.lb.common/src/triop.h org.glite.lb.common/src/ulm_parse.c org.glite.lb.common/src/xml_conversions.c org.glite.lb.common/src/xml_parse.c.T org.glite.lb.common/test/il_int_test.cpp org.glite.lb.common/test/il_string_test.cpp org.glite.lb.common/test/il_test.cpp org.glite.lb.common/test/parse.cpp.T org.glite.lb.common/test/test_gss.cpp org.glite.lb.logger/.cvsignore org.glite.lb.logger/LICENSE org.glite.lb.logger/Makefile org.glite.lb.logger/build.xml org.glite.lb.logger/config/startup org.glite.lb.logger/project/build.properties org.glite.lb.logger/project/configure.properties.xml org.glite.lb.logger/project/properties.xml org.glite.lb.logger/project/tar_exclude org.glite.lb.logger/project/version.properties org.glite.lb.logger/src/event_queue.c org.glite.lb.logger/src/event_store.c org.glite.lb.logger/src/il_error.c org.glite.lb.logger/src/il_error.h org.glite.lb.logger/src/il_master.c org.glite.lb.logger/src/input_queue_socket.c org.glite.lb.logger/src/interlogd.c org.glite.lb.logger/src/interlogd.h org.glite.lb.logger/src/logd.c org.glite.lb.logger/src/logd_proto.c org.glite.lb.logger/src/logd_proto.h org.glite.lb.logger/src/queue_mgr.c org.glite.lb.logger/src/queue_thread.c org.glite.lb.logger/src/recover.c org.glite.lb.logger/src/send_event.c org.glite.lb.logger/src/server_msg.c org.glite.lb.logger/test/IlTestBase.cpp org.glite.lb.logger/test/IlTestBase.h org.glite.lb.logger/test/event_queueTest.cpp org.glite.lb.logger/test/event_storeTest.cpp org.glite.lb.logger/test/il_test.cpp org.glite.lb.logger/test/input_queue_socketTest.cpp org.glite.lb.logger/test/ll_test.cpp org.glite.lb.logger/test/logd_proto_test.c org.glite.lb.logger/test/server_msgTest.cpp org.glite.lb.server-bones/.cvsignore org.glite.lb.server-bones/Makefile org.glite.lb.server-bones/build.xml org.glite.lb.server-bones/examples/cnt_example.c org.glite.lb.server-bones/examples/srv_example.c org.glite.lb.server-bones/interface/srvbones.h org.glite.lb.server-bones/project/build.properties org.glite.lb.server-bones/project/configure.properties.xml org.glite.lb.server-bones/project/properties.xml org.glite.lb.server-bones/project/tar_exclude org.glite.lb.server-bones/project/version.properties org.glite.lb.server-bones/src/srvbones.c org.glite.lb.server/.cvsignore org.glite.lb.server/LICENSE org.glite.lb.server/Makefile org.glite.lb.server/build.xml org.glite.lb.server/config/glite-lb-dbsetup.sql org.glite.lb.server/config/glite-lb-index.conf.template org.glite.lb.server/config/startup org.glite.lb.server/examples/stdsoap2_2.6.0.c org.glite.lb.server/examples/stdsoap2_2.6.2.c org.glite.lb.server/examples/stdsoap2_2.7.0c.c org.glite.lb.server/examples/stdsoap2_2.7.0d.c org.glite.lb.server/examples/ws_getversion.c org.glite.lb.server/examples/ws_jobstat.c org.glite.lb.server/examples/ws_query_ex.c org.glite.lb.server/project/build.properties org.glite.lb.server/project/configure.properties.xml org.glite.lb.server/project/properties.xml org.glite.lb.server/project/tar_exclude org.glite.lb.server/project/version.properties org.glite.lb.server/src/bkindex.c org.glite.lb.server/src/bkserverd.c org.glite.lb.server/src/db_store.c org.glite.lb.server/src/dump.c org.glite.lb.server/src/get_events.c.T org.glite.lb.server/src/get_events.h org.glite.lb.server/src/il_lbproxy.c org.glite.lb.server/src/il_lbproxy.h org.glite.lb.server/src/il_notification.c org.glite.lb.server/src/il_notification.h org.glite.lb.server/src/index.c.T org.glite.lb.server/src/index.h org.glite.lb.server/src/index_lex.l org.glite.lb.server/src/index_parse.y org.glite.lb.server/src/jobstat.c org.glite.lb.server/src/jobstat.h org.glite.lb.server/src/jobstat_supp.c org.glite.lb.server/src/lb_authz.c org.glite.lb.server/src/lb_authz.h org.glite.lb.server/src/lb_html.c org.glite.lb.server/src/lb_html.h org.glite.lb.server/src/lb_http.c org.glite.lb.server/src/lb_http.h org.glite.lb.server/src/lb_proto.c org.glite.lb.server/src/lb_proto.h org.glite.lb.server/src/lb_xml_parse.c.T org.glite.lb.server/src/lb_xml_parse.h org.glite.lb.server/src/lb_xml_parse_V21.c.T org.glite.lb.server/src/lb_xml_parse_V21.h org.glite.lb.server/src/lbproxy.c org.glite.lb.server/src/lbs_db.c org.glite.lb.server/src/lbs_db.h org.glite.lb.server/src/load.c org.glite.lb.server/src/lock.c org.glite.lb.server/src/lock.h org.glite.lb.server/src/notif_match.c org.glite.lb.server/src/notification.c org.glite.lb.server/src/openserver.c org.glite.lb.server/src/purge.h org.glite.lb.server/src/query.c org.glite.lb.server/src/query.h org.glite.lb.server/src/request.c org.glite.lb.server/src/seqcode.c org.glite.lb.server/src/server_state.c org.glite.lb.server/src/server_state.h org.glite.lb.server/src/srv_purge.c org.glite.lb.server/src/store.c.T org.glite.lb.server/src/store.h org.glite.lb.server/src/stored_master.c org.glite.lb.server/src/userjobs.c org.glite.lb.server/src/write2rgma.c org.glite.lb.server/src/ws_fault.c org.glite.lb.server/src/ws_fault.h org.glite.lb.server/src/ws_plugin.c org.glite.lb.server/src/ws_plugin.h org.glite.lb.server/src/ws_query.c org.glite.lb.server/src/ws_typemap.dat org.glite.lb.server/src/ws_typemap.h org.glite.lb.server/src/ws_typeref.c.T org.glite.lb.server/src/ws_typeref.h org.glite.lb.server/test/oneJob.qry org.glite.lb.server/test/test_query_events.cpp org.glite.lb.server/test/test_soap_conv.cpp org.glite.lb.server/test/test_xml.cpp.T org.glite.lb.ws-interface/.Makefile.swp org.glite.lb.ws-interface/.cvsignore org.glite.lb.ws-interface/LICENSE org.glite.lb.ws-interface/Makefile org.glite.lb.ws-interface/build.xml org.glite.lb.ws-interface/interface/LB.wsdl org.glite.lb.ws-interface/project/build.properties org.glite.lb.ws-interface/project/configure.properties.xml org.glite.lb.ws-interface/project/properties.xml org.glite.lb.ws-interface/project/tar_exclude org.glite.lb.ws-interface/project/version.properties org.glite.lb/.cvsignore org.glite.lb/LICENSE org.glite.lb/build.xml org.glite.lb/project/MultiStruct.pm org.glite.lb/project/StructField.pm org.glite.lb/project/at3 org.glite.lb/project/build.properties org.glite.lb/project/dependencies.properties org.glite.lb/project/events.T org.glite.lb/project/glite.lb.csf.xml org.glite.lb/project/properties.xml org.glite.lb/project/run-workspace org.glite.lb/project/status.T org.glite.lb/project/taskdefs.xml org.glite.lb/project/types.T org.glite.lb/project/version.properties org.glite.security.proxyrenewal/.cvsignore org.glite.security.proxyrenewal/LICENSE org.glite.security.proxyrenewal/Makefile org.glite.security.proxyrenewal/build.xml org.glite.security.proxyrenewal/config/startup org.glite.security.proxyrenewal/interface/renewal.h org.glite.security.proxyrenewal/project/build.properties org.glite.security.proxyrenewal/project/configure.properties.xml org.glite.security.proxyrenewal/project/properties.xml org.glite.security.proxyrenewal/project/tar_exclude org.glite.security.proxyrenewal/project/taskdefs.xml org.glite.security.proxyrenewal/project/version.properties org.glite.security.proxyrenewal/src/api.c org.glite.security.proxyrenewal/src/client.c org.glite.security.proxyrenewal/src/commands.c org.glite.security.proxyrenewal/src/common.c org.glite.security.proxyrenewal/src/renew.c org.glite.security.proxyrenewal/src/renewal_locl.h org.glite.security.proxyrenewal/src/renewd.c org.glite.security.proxyrenewal/src/renewd_locl.h org.glite.wms-utils.jobid/.cvsignore org.glite.wms-utils.jobid/LICENSE org.glite.wms-utils.jobid/Makefile.am org.glite.wms-utils.jobid/bootstrap org.glite.wms-utils.jobid/build.xml org.glite.wms-utils.jobid/configure.ac org.glite.wms-utils.jobid/examples/Makefile.am org.glite.wms-utils.jobid/examples/testjobid.c org.glite.wms-utils.jobid/interface/Makefile.am org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/JobId.h org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/JobIdExceptions.h org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/cjobid.h org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/manipulation.h org.glite.wms-utils.jobid/project/build.properties org.glite.wms-utils.jobid/project/configure.properties.xml org.glite.wms-utils.jobid/project/properties.xml org.glite.wms-utils.jobid/project/version.properties org.glite.wms-utils.jobid/src/Makefile.am org.glite.wms-utils.jobid/src/jobid/JobId.cpp org.glite.wms-utils.jobid/src/jobid/JobIdExceptions.cpp org.glite.wms-utils.jobid/src/jobid/Makefile.am org.glite.wms-utils.jobid/src/jobid/cjobid.c org.glite.wms-utils.jobid/src/jobid/manipulation.cpp org.glite.wms-utils.jobid/src/jobid/strmd5.c org.glite.wms-utils.jobid/src/jobid/strmd5.h org.gridsite.core/.cvsignore org.gridsite.core/CHANGES org.gridsite.core/INSTALL org.gridsite.core/LICENSE org.gridsite.core/README org.gridsite.core/VERSION org.gridsite.core/build.xml org.gridsite.core/doc/README.htcp-bin org.gridsite.core/doc/admin.html org.gridsite.core/doc/build-apache2.sh org.gridsite.core/doc/config.html org.gridsite.core/doc/findproxyfile.1 org.gridsite.core/doc/gacl.html org.gridsite.core/doc/htcp.1 org.gridsite.core/doc/htll.1 org.gridsite.core/doc/htls.1 org.gridsite.core/doc/htmkdir.1 org.gridsite.core/doc/htrm.1 org.gridsite.core/doc/httpd-fileserver.conf org.gridsite.core/doc/httpd-webserver.conf org.gridsite.core/doc/index.html org.gridsite.core/doc/install.html org.gridsite.core/doc/library.html org.gridsite.core/doc/module.html org.gridsite.core/doc/urlencode.1 org.gridsite.core/doc/user.html org.gridsite.core/interface/gridsite-gacl.h org.gridsite.core/interface/gridsite.h org.gridsite.core/project/build.properties org.gridsite.core/project/configure.properties.xml org.gridsite.core/project/dependencies.properties org.gridsite.core/project/gridsite.core.csf.xml org.gridsite.core/project/properties.xml org.gridsite.core/project/taskdefs.xml org.gridsite.core/project/version.properties org.gridsite.core/src/Doxyfile org.gridsite.core/src/Makefile org.gridsite.core/src/delegation.h org.gridsite.core/src/doxygen.css org.gridsite.core/src/doxyheader.html org.gridsite.core/src/findproxyfile.c org.gridsite.core/src/gaclexample.c org.gridsite.core/src/gridsite.spec org.gridsite.core/src/grst-delegation.c org.gridsite.core/src/grst_admin.h org.gridsite.core/src/grst_admin_file.c org.gridsite.core/src/grst_admin_gacl.c org.gridsite.core/src/grst_admin_main.c org.gridsite.core/src/grst_gacl.c org.gridsite.core/src/grst_http.c org.gridsite.core/src/grst_x509.c org.gridsite.core/src/htcp org.gridsite.core/src/htcp.c org.gridsite.core/src/htproxyput.c org.gridsite.core/src/mod_gridsite.c org.gridsite.core/src/mod_ssl-private.h org.gridsite.core/src/proxyput-example.c org.gridsite.core/src/real-gridsite-admin.cgi org.gridsite.core/src/roffit org.gridsite.core/src/urlencode.c --- org.glite.deployment.lb/.cvsignore | 1 - org.glite.deployment.lb/build.xml | 104 - .../config/scripts/glite-lb-config.py | 279 - .../config/scripts/remove_all_rpms.sh | 49 - .../config/templates/glite-lb.cfg.xml | 57 - .../doc/release_notes/release_notes.doc | Bin 172032 -> 0 bytes .../doc/release_notes/release_notes.html | 1720 --- .../doc/release_notes/release_notes.pdf | Bin 34870 -> 0 bytes org.glite.deployment.lb/project/.cvsignore | 1 - org.glite.deployment.lb/project/build.properties | 0 .../project/glite-lb.sdf.xml.template | 114 - org.glite.deployment.lb/project/glite-lb.spec | 46 - org.glite.deployment.lb/project/lxscript-rpm.xsl | 254 - org.glite.deployment.lb/project/lxscript-tgz.xsl | 62 - org.glite.deployment.lb/project/properties.xml | 50 - .../project/quattor-template.xsl | 53 - org.glite.deployment.lb/project/version.properties | 4 - org.glite.jp.common/.cvsignore | 1 - org.glite.jp.common/Makefile | 85 - org.glite.jp.common/build.xml | 93 - org.glite.jp.common/interface/context.h | 17 - org.glite.jp.common/interface/strmd5.h | 28 - org.glite.jp.common/interface/types.h | 83 - org.glite.jp.common/project/build.properties | 0 .../project/configure.properties.xml | 52 - org.glite.jp.common/project/properties.xml | 52 - org.glite.jp.common/project/tar_exclude | 10 - org.glite.jp.common/project/version.properties | 4 - org.glite.jp.common/src/context.c | 164 - org.glite.jp.common/src/strmd5.c | 115 - org.glite.jp.index/.cvsignore | 1 - org.glite.jp.index/Makefile | 129 - org.glite.jp.index/build.xml | 93 - org.glite.jp.index/project/JobProvenanceIS.wsdl | 531 - org.glite.jp.index/project/build.properties | 0 .../project/configure.properties.xml | 53 - org.glite.jp.index/project/properties.xml | 52 - org.glite.jp.index/project/tar_exclude | 10 - org.glite.jp.index/project/version.properties | 4 - org.glite.jp.index/src/simple_server.c | 39 - org.glite.jp.index/src/soap_ops.c | 81 - org.glite.jp.index/src/typemap.dat | 2 - org.glite.jp.primary/.cvsignore | 1 - org.glite.jp.primary/Makefile | 155 - org.glite.jp.primary/build.xml | 97 - org.glite.jp.primary/examples/jpps-test.c | 158 - org.glite.jp.primary/project/build.properties | 0 .../project/configure.properties.xml | 52 - org.glite.jp.primary/project/properties.xml | 51 - org.glite.jp.primary/project/tar_exclude | 10 - org.glite.jp.primary/project/version.properties | 4 - org.glite.jp.primary/src/backend.h | 105 - org.glite.jp.primary/src/feed.c | 264 - org.glite.jp.primary/src/feed.h | 21 - org.glite.jp.primary/src/ftp_backend.c | 1701 --- org.glite.jp.primary/src/is_client.c | 33 - org.glite.jp.primary/src/jptype_map.h | 16 - org.glite.jp.primary/src/simple_server.c | 59 - org.glite.jp.primary/src/soap_ops.c | 374 - org.glite.jp.primary/src/tags.c | 233 - org.glite.jp.primary/src/tags.h | 1 - org.glite.jp.primary/src/typemap.dat | 2 - org.glite.jp/.cvsignore | 1 - org.glite.jp/build.xml | 242 - org.glite.jp/project/JobProvenance.wsdl | 531 - org.glite.jp/project/JobProvenanceIS.wsdl | 110 - org.glite.jp/project/JobProvenancePS.wsdl | 307 - org.glite.jp/project/JobProvenanceTypes.wsdl | 162 - org.glite.jp/project/JobProvenanceTypes.xsd | 146 - org.glite.jp/project/build.properties | 0 org.glite.jp/project/dependencies.properties | 11 - org.glite.jp/project/glite.jp.csf.xml | 253 - org.glite.jp/project/properties.xml | 47 - org.glite.jp/project/run-workspace | 10 - org.glite.jp/project/taskdefs.xml | 24 - org.glite.jp/project/version.properties | 4 - org.glite.lb.client-interface/.cvsignore | 2 - org.glite.lb.client-interface/LICENSE | 69 - org.glite.lb.client-interface/Makefile | 70 - org.glite.lb.client-interface/build.xml | 134 - org.glite.lb.client-interface/interface/CountRef.h | 48 - org.glite.lb.client-interface/interface/Event.h.T | 148 - org.glite.lb.client-interface/interface/Job.h | 74 - .../interface/JobStatus.h.T | 151 - .../interface/LoggingExceptions.h | 144 - .../interface/Notification.h | 93 - .../interface/ServerConnection.h | 306 - org.glite.lb.client-interface/interface/consumer.h | 387 - .../interface/consumer_fake.h | 26 - org.glite.lb.client-interface/interface/context.h | 218 - org.glite.lb.client-interface/interface/dump.h | 31 - org.glite.lb.client-interface/interface/events.h.T | 332 - .../interface/jobstat.h.T | 141 - org.glite.lb.client-interface/interface/load.h | 27 - .../interface/notification.h | 157 - org.glite.lb.client-interface/interface/notifid.h | 29 - .../interface/producer.h.T | 454 - .../interface/producer_fake.h | 23 - org.glite.lb.client-interface/interface/purge.h | 59 - .../project/build.properties | 0 .../project/configure.properties.xml | 85 - .../project/properties.xml | 62 - org.glite.lb.client-interface/project/tar_exclude | 10 - .../project/version.properties | 4 - org.glite.lb.client/.cvsignore | 2 - org.glite.lb.client/LICENSE | 69 - org.glite.lb.client/Makefile | 272 - org.glite.lb.client/build.xml | 133 - org.glite.lb.client/doc/README-fake | 126 - org.glite.lb.client/examples/aborted.l | 2 - org.glite.lb.client/examples/cancelled.l | 2 - org.glite.lb.client/examples/chkpt.l | 6 - org.glite.lb.client/examples/cleared.l | 4 - org.glite.lb.client/examples/consumer_fake.c | 162 - org.glite.lb.client/examples/done.l | 4 - org.glite.lb.client/examples/done_dag.l | 4 - org.glite.lb.client/examples/done_subjob.l | 4 - org.glite.lb.client/examples/failed_dag.l | 3 - org.glite.lb.client/examples/failed_subjob.l | 3 - org.glite.lb.client/examples/feed_shark.c | 195 - org.glite.lb.client/examples/gen_begin | 50 - org.glite.lb.client/examples/gen_sample_job | 119 - org.glite.lb.client/examples/job_log.c | 142 - org.glite.lb.client/examples/job_reg.c | 109 - org.glite.lb.client/examples/log_usertag_proxy.c | 103 - org.glite.lb.client/examples/notify.c | 363 - org.glite.lb.client/examples/producer_fake.c | 63 - org.glite.lb.client/examples/query_ext.c | 877 -- org.glite.lb.client/examples/query_seq_code.c | 87 - org.glite.lb.client/examples/ready.l | 18 - org.glite.lb.client/examples/ready_dag.l | 13 - org.glite.lb.client/examples/ready_subjob.l | 8 - org.glite.lb.client/examples/running.l | 4 - org.glite.lb.client/examples/running_dag.l | 4 - org.glite.lb.client/examples/running_subjob.l | 4 - org.glite.lb.client/examples/scheduled.l | 13 - org.glite.lb.client/examples/scheduled_dag.l | 12 - org.glite.lb.client/examples/scheduled_subjob.l | 7 - org.glite.lb.client/examples/submitted.l | 5 - org.glite.lb.client/examples/submitted_dag.l | 4 - org.glite.lb.client/examples/submitted_subjob.l | 4 - org.glite.lb.client/examples/waiting.l | 6 - org.glite.lb.client/examples/waiting_dag.l | 6 - org.glite.lb.client/examples/waiting_subjob.l | 6 - org.glite.lb.client/project/build.properties | 0 .../project/configure.properties.xml | 57 - org.glite.lb.client/project/properties.xml | 62 - org.glite.lb.client/project/tar_exclude | 10 - org.glite.lb.client/project/version.properties | 4 - org.glite.lb.client/src/Event.cpp.T | 337 - org.glite.lb.client/src/Job.cpp | 209 - org.glite.lb.client/src/JobStatus.cpp.T | 481 - org.glite.lb.client/src/Notification.cpp | 340 - org.glite.lb.client/src/ServerConnection.cpp | 1302 --- org.glite.lb.client/src/args.c.T | 533 - org.glite.lb.client/src/args.h | 33 - org.glite.lb.client/src/connection.c | 352 - org.glite.lb.client/src/connection.h | 17 - org.glite.lb.client/src/consumer.c | 583 - org.glite.lb.client/src/dump.c | 230 - org.glite.lb.client/src/load.c | 207 - org.glite.lb.client/src/logevent.c.T | 287 - org.glite.lb.client/src/notification.c | 937 -- org.glite.lb.client/src/prod_proto.c | 303 - org.glite.lb.client/src/prod_proto.h | 29 - org.glite.lb.client/src/producer.c | 940 -- org.glite.lb.client/src/purge.c | 389 - org.glite.lb.client/src/uiwrap.c.T | 116 - org.glite.lb.client/test/prod_proto_test.c | 33 - org.glite.lb.client/test/producer_test.cpp | 60 - org.glite.lb.common/.cvsignore | 2 - org.glite.lb.common/LICENSE | 69 - org.glite.lb.common/Makefile | 217 - org.glite.lb.common/build.xml | 136 - org.glite.lb.common/interface/authz.h | 24 - org.glite.lb.common/interface/context-int.h | 178 - org.glite.lb.common/interface/escape.h | 60 - org.glite.lb.common/interface/events_parse.h | 97 - org.glite.lb.common/interface/il_string.h | 30 - org.glite.lb.common/interface/lb_gss.h | 117 - org.glite.lb.common/interface/lb_plain_io.h | 46 - org.glite.lb.common/interface/log_proto.h | 76 - org.glite.lb.common/interface/mini_http.h | 59 - org.glite.lb.common/interface/trio.h | 187 - org.glite.lb.common/interface/ulm_parse.h | 47 - org.glite.lb.common/interface/xml_conversions.h | 136 - org.glite.lb.common/interface/xml_parse.h | 70 - org.glite.lb.common/project/build.properties | 0 .../project/configure.properties.xml | 57 - org.glite.lb.common/project/properties.xml | 62 - org.glite.lb.common/project/tar_exclude | 10 - org.glite.lb.common/project/version.properties | 3 - org.glite.lb.common/src/context.c | 436 - org.glite.lb.common/src/escape.c | 221 - org.glite.lb.common/src/events.c.T | 350 - org.glite.lb.common/src/events_parse.c.T | 782 -- org.glite.lb.common/src/il_int.c | 69 - org.glite.lb.common/src/il_log.c | 32 - org.glite.lb.common/src/il_msg.c | 53 - org.glite.lb.common/src/il_string.c | 61 - org.glite.lb.common/src/lb_gss.c | 981 -- org.glite.lb.common/src/lb_plain_io.c | 208 - org.glite.lb.common/src/mini_http.c | 373 - org.glite.lb.common/src/notifid.c | 88 - org.glite.lb.common/src/param.c | 458 - org.glite.lb.common/src/query_rec.c | 50 - org.glite.lb.common/src/status.c.T | 172 - org.glite.lb.common/src/strio.c | 581 - org.glite.lb.common/src/strio.h | 227 - org.glite.lb.common/src/trio.c | 5708 --------- org.glite.lb.common/src/triop.h | 138 - org.glite.lb.common/src/ulm_parse.c | 410 - org.glite.lb.common/src/xml_conversions.c | 840 -- org.glite.lb.common/src/xml_parse.c.T | 2746 ----- org.glite.lb.common/test/il_int_test.cpp | 44 - org.glite.lb.common/test/il_string_test.cpp | 45 - org.glite.lb.common/test/il_test.cpp | 15 - org.glite.lb.common/test/parse.cpp.T | 150 - org.glite.lb.common/test/test_gss.cpp | 149 - org.glite.lb.logger/.cvsignore | 2 - org.glite.lb.logger/LICENSE | 69 - org.glite.lb.logger/Makefile | 166 - org.glite.lb.logger/build.xml | 121 - org.glite.lb.logger/config/startup | 81 - org.glite.lb.logger/project/build.properties | 0 .../project/configure.properties.xml | 60 - org.glite.lb.logger/project/properties.xml | 59 - org.glite.lb.logger/project/tar_exclude | 10 - org.glite.lb.logger/project/version.properties | 4 - org.glite.lb.logger/src/event_queue.c | 314 - org.glite.lb.logger/src/event_store.c | 1025 -- org.glite.lb.logger/src/il_error.c | 184 - org.glite.lb.logger/src/il_error.h | 34 - org.glite.lb.logger/src/il_master.c | 419 - org.glite.lb.logger/src/input_queue_socket.c | 207 - org.glite.lb.logger/src/interlogd.c | 279 - org.glite.lb.logger/src/interlogd.h | 205 - org.glite.lb.logger/src/logd.c | 436 - org.glite.lb.logger/src/logd_proto.c | 866 -- org.glite.lb.logger/src/logd_proto.h | 60 - org.glite.lb.logger/src/queue_mgr.c | 244 - org.glite.lb.logger/src/queue_thread.c | 357 - org.glite.lb.logger/src/recover.c | 55 - org.glite.lb.logger/src/send_event.c | 328 - org.glite.lb.logger/src/server_msg.c | 217 - org.glite.lb.logger/test/IlTestBase.cpp | 15 - org.glite.lb.logger/test/IlTestBase.h | 10 - org.glite.lb.logger/test/event_queueTest.cpp | 145 - org.glite.lb.logger/test/event_storeTest.cpp | 58 - org.glite.lb.logger/test/il_test.cpp | 44 - .../test/input_queue_socketTest.cpp | 69 - org.glite.lb.logger/test/ll_test.cpp | 119 - org.glite.lb.logger/test/logd_proto_test.c | 43 - org.glite.lb.logger/test/server_msgTest.cpp | 57 - org.glite.lb.server-bones/.cvsignore | 1 - org.glite.lb.server-bones/Makefile | 91 - org.glite.lb.server-bones/build.xml | 113 - org.glite.lb.server-bones/examples/cnt_example.c | 175 - org.glite.lb.server-bones/examples/srv_example.c | 199 - org.glite.lb.server-bones/interface/srvbones.h | 46 - org.glite.lb.server-bones/project/build.properties | 0 .../project/configure.properties.xml | 56 - org.glite.lb.server-bones/project/properties.xml | 62 - org.glite.lb.server-bones/project/tar_exclude | 10 - .../project/version.properties | 4 - org.glite.lb.server-bones/src/srvbones.c | 602 - org.glite.lb.server/.cvsignore | 2 - org.glite.lb.server/LICENSE | 69 - org.glite.lb.server/Makefile | 268 - org.glite.lb.server/build.xml | 140 - org.glite.lb.server/config/glite-lb-dbsetup.sql | 112 - .../config/glite-lb-index.conf.template | 7 - org.glite.lb.server/config/startup | 108 - org.glite.lb.server/examples/stdsoap2_2.6.0.c | 10775 ----------------- org.glite.lb.server/examples/stdsoap2_2.6.2.c | 11020 ----------------- org.glite.lb.server/examples/stdsoap2_2.7.0c.c | 11629 ------------------ org.glite.lb.server/examples/stdsoap2_2.7.0d.c | 11692 ------------------- org.glite.lb.server/examples/ws_getversion.c | 60 - org.glite.lb.server/examples/ws_jobstat.c | 161 - org.glite.lb.server/examples/ws_query_ex.c | 182 - org.glite.lb.server/project/build.properties | 0 .../project/configure.properties.xml | 78 - org.glite.lb.server/project/properties.xml | 59 - org.glite.lb.server/project/tar_exclude | 10 - org.glite.lb.server/project/version.properties | 4 - org.glite.lb.server/src/bkindex.c | 305 - org.glite.lb.server/src/bkserverd.c | 1368 --- org.glite.lb.server/src/db_store.c | 98 - org.glite.lb.server/src/dump.c | 192 - org.glite.lb.server/src/get_events.c.T | 157 - org.glite.lb.server/src/get_events.h | 32 - org.glite.lb.server/src/il_lbproxy.c | 168 - org.glite.lb.server/src/il_lbproxy.h | 17 - org.glite.lb.server/src/il_notification.c | 388 - org.glite.lb.server/src/il_notification.h | 96 - org.glite.lb.server/src/index.c.T | 227 - org.glite.lb.server/src/index.h | 27 - org.glite.lb.server/src/index_lex.l | 47 - org.glite.lb.server/src/index_parse.y | 242 - org.glite.lb.server/src/jobstat.c | 1250 -- org.glite.lb.server/src/jobstat.h | 30 - org.glite.lb.server/src/jobstat_supp.c | 669 -- org.glite.lb.server/src/lb_authz.c | 933 -- org.glite.lb.server/src/lb_authz.h | 59 - org.glite.lb.server/src/lb_html.c | 146 - org.glite.lb.server/src/lb_html.h | 13 - org.glite.lb.server/src/lb_http.c | 59 - org.glite.lb.server/src/lb_http.h | 13 - org.glite.lb.server/src/lb_proto.c | 841 -- org.glite.lb.server/src/lb_proto.h | 27 - org.glite.lb.server/src/lb_xml_parse.c.T | 1854 --- org.glite.lb.server/src/lb_xml_parse.h | 41 - org.glite.lb.server/src/lb_xml_parse_V21.c.T | 1239 -- org.glite.lb.server/src/lb_xml_parse_V21.h | 21 - org.glite.lb.server/src/lbproxy.c | 543 - org.glite.lb.server/src/lbs_db.c | 224 - org.glite.lb.server/src/lbs_db.h | 85 - org.glite.lb.server/src/load.c | 210 - org.glite.lb.server/src/lock.c | 32 - org.glite.lb.server/src/lock.h | 4 - org.glite.lb.server/src/notif_match.c | 166 - org.glite.lb.server/src/notification.c | 660 -- org.glite.lb.server/src/openserver.c | 18 - org.glite.lb.server/src/purge.h | 49 - org.glite.lb.server/src/query.c | 1414 --- org.glite.lb.server/src/query.h | 5 - org.glite.lb.server/src/request.c | 96 - org.glite.lb.server/src/seqcode.c | 63 - org.glite.lb.server/src/server_state.c | 54 - org.glite.lb.server/src/server_state.h | 10 - org.glite.lb.server/src/srv_purge.c | 562 - org.glite.lb.server/src/store.c.T | 565 - org.glite.lb.server/src/store.h | 49 - org.glite.lb.server/src/stored_master.c | 94 - org.glite.lb.server/src/userjobs.c | 77 - org.glite.lb.server/src/write2rgma.c | 110 - org.glite.lb.server/src/ws_fault.c | 65 - org.glite.lb.server/src/ws_fault.h | 7 - org.glite.lb.server/src/ws_plugin.c | 191 - org.glite.lb.server/src/ws_plugin.h | 8 - org.glite.lb.server/src/ws_query.c | 117 - org.glite.lb.server/src/ws_typemap.dat | 2 - org.glite.lb.server/src/ws_typemap.h | 52 - org.glite.lb.server/src/ws_typeref.c.T | 522 - org.glite.lb.server/src/ws_typeref.h | 68 - org.glite.lb.server/test/oneJob.qry | 24 - org.glite.lb.server/test/test_query_events.cpp | 152 - org.glite.lb.server/test/test_soap_conv.cpp | 319 - org.glite.lb.server/test/test_xml.cpp.T | 212 - org.glite.lb.ws-interface/.Makefile.swp | Bin 12288 -> 0 bytes org.glite.lb.ws-interface/.cvsignore | 2 - org.glite.lb.ws-interface/LICENSE | 69 - org.glite.lb.ws-interface/Makefile | 49 - org.glite.lb.ws-interface/build.xml | 116 - org.glite.lb.ws-interface/interface/LB.wsdl | 358 - org.glite.lb.ws-interface/project/build.properties | 0 .../project/configure.properties.xml | 53 - org.glite.lb.ws-interface/project/properties.xml | 73 - org.glite.lb.ws-interface/project/tar_exclude | 0 .../project/version.properties | 4 - org.glite.lb/.cvsignore | 2 - org.glite.lb/LICENSE | 69 - org.glite.lb/build.xml | 393 - org.glite.lb/project/MultiStruct.pm | 191 - org.glite.lb/project/StructField.pm | 116 - org.glite.lb/project/at3 | 93 - org.glite.lb/project/build.properties | 0 org.glite.lb/project/dependencies.properties | 15 - org.glite.lb/project/events.T | 183 - org.glite.lb/project/glite.lb.csf.xml | 335 - org.glite.lb/project/properties.xml | 55 - org.glite.lb/project/run-workspace | 10 - org.glite.lb/project/status.T | 77 - org.glite.lb/project/taskdefs.xml | 32 - org.glite.lb/project/types.T | 108 - org.glite.lb/project/version.properties | 4 - org.glite.security.proxyrenewal/.cvsignore | 1 - org.glite.security.proxyrenewal/LICENSE | 69 - org.glite.security.proxyrenewal/Makefile | 145 - org.glite.security.proxyrenewal/build.xml | 120 - org.glite.security.proxyrenewal/config/startup | 62 - .../interface/renewal.h | 144 - .../project/build.properties | 0 .../project/configure.properties.xml | 51 - .../project/properties.xml | 62 - .../project/tar_exclude | 10 - .../project/taskdefs.xml | 4 - .../project/version.properties | 4 - org.glite.security.proxyrenewal/src/api.c | 436 - org.glite.security.proxyrenewal/src/client.c | 117 - org.glite.security.proxyrenewal/src/commands.c | 1233 -- org.glite.security.proxyrenewal/src/common.c | 239 - org.glite.security.proxyrenewal/src/renew.c | 1120 -- org.glite.security.proxyrenewal/src/renewal_locl.h | 133 - org.glite.security.proxyrenewal/src/renewd.c | 709 -- org.glite.security.proxyrenewal/src/renewd_locl.h | 86 - org.glite.wms-utils.jobid/.cvsignore | 2 - org.glite.wms-utils.jobid/LICENSE | 69 - org.glite.wms-utils.jobid/Makefile.am | 69 - org.glite.wms-utils.jobid/bootstrap | 9 - org.glite.wms-utils.jobid/build.xml | 100 - org.glite.wms-utils.jobid/configure.ac | 128 - org.glite.wms-utils.jobid/examples/Makefile.am | 28 - org.glite.wms-utils.jobid/examples/testjobid.c | 33 - org.glite.wms-utils.jobid/interface/Makefile.am | 16 - .../interface/glite/wmsutils/jobid/JobId.h | 120 - .../glite/wmsutils/jobid/JobIdExceptions.h | 80 - .../interface/glite/wmsutils/jobid/cjobid.h | 109 - .../interface/glite/wmsutils/jobid/manipulation.h | 24 - org.glite.wms-utils.jobid/project/build.properties | 0 .../project/configure.properties.xml | 9 - org.glite.wms-utils.jobid/project/properties.xml | 86 - .../project/version.properties | 3 - org.glite.wms-utils.jobid/src/Makefile.am | 12 - org.glite.wms-utils.jobid/src/jobid/JobId.cpp | 183 - .../src/jobid/JobIdExceptions.cpp | 58 - org.glite.wms-utils.jobid/src/jobid/Makefile.am | 30 - org.glite.wms-utils.jobid/src/jobid/cjobid.c | 258 - .../src/jobid/manipulation.cpp | 180 - org.glite.wms-utils.jobid/src/jobid/strmd5.c | 118 - org.glite.wms-utils.jobid/src/jobid/strmd5.h | 28 - org.gridsite.core/.cvsignore | 1 - org.gridsite.core/CHANGES | 148 - org.gridsite.core/INSTALL | 39 - org.gridsite.core/LICENSE | 47 - org.gridsite.core/README | 3 - org.gridsite.core/VERSION | 4 - org.gridsite.core/build.xml | 223 - org.gridsite.core/doc/README.htcp-bin | 13 - org.gridsite.core/doc/admin.html | 103 - org.gridsite.core/doc/build-apache2.sh | 79 - org.gridsite.core/doc/config.html | 192 - org.gridsite.core/doc/findproxyfile.1 | 63 - org.gridsite.core/doc/gacl.html | 84 - org.gridsite.core/doc/htcp.1 | 147 - org.gridsite.core/doc/htll.1 | 1 - org.gridsite.core/doc/htls.1 | 1 - org.gridsite.core/doc/htmkdir.1 | 1 - org.gridsite.core/doc/htrm.1 | 1 - org.gridsite.core/doc/httpd-fileserver.conf | 147 - org.gridsite.core/doc/httpd-webserver.conf | 219 - org.gridsite.core/doc/index.html | 92 - org.gridsite.core/doc/install.html | 148 - org.gridsite.core/doc/library.html | 1 - org.gridsite.core/doc/module.html | 271 - org.gridsite.core/doc/urlencode.1 | 46 - org.gridsite.core/doc/user.html | 302 - org.gridsite.core/interface/gridsite-gacl.h | 188 - org.gridsite.core/interface/gridsite.h | 273 - org.gridsite.core/project/build.properties | 0 org.gridsite.core/project/configure.properties.xml | 9 - org.gridsite.core/project/dependencies.properties | 9 - org.gridsite.core/project/gridsite.core.csf.xml | 221 - org.gridsite.core/project/properties.xml | 53 - org.gridsite.core/project/taskdefs.xml | 31 - org.gridsite.core/project/version.properties | 4 - org.gridsite.core/src/Doxyfile | 993 -- org.gridsite.core/src/Makefile | 280 - org.gridsite.core/src/delegation.h | 12 - org.gridsite.core/src/doxygen.css | 49 - org.gridsite.core/src/doxyheader.html | 1 - org.gridsite.core/src/findproxyfile.c | 122 - org.gridsite.core/src/gaclexample.c | 147 - org.gridsite.core/src/gridsite.spec | 78 - org.gridsite.core/src/grst-delegation.c | 295 - org.gridsite.core/src/grst_admin.h | 57 - org.gridsite.core/src/grst_admin_file.c | 1571 --- org.gridsite.core/src/grst_admin_gacl.c | 968 -- org.gridsite.core/src/grst_admin_main.c | 365 - org.gridsite.core/src/grst_gacl.c | 1154 -- org.gridsite.core/src/grst_http.c | 407 - org.gridsite.core/src/grst_x509.c | 1398 --- org.gridsite.core/src/htcp | Bin 29747 -> 0 bytes org.gridsite.core/src/htcp.c | 1237 -- org.gridsite.core/src/htproxyput.c | 565 - org.gridsite.core/src/mod_gridsite.c | 2357 ---- org.gridsite.core/src/mod_ssl-private.h | 106 - org.gridsite.core/src/proxyput-example.c | 131 - org.gridsite.core/src/real-gridsite-admin.cgi | Bin 96256 -> 0 bytes org.gridsite.core/src/roffit | 370 - org.gridsite.core/src/urlencode.c | 73 - 481 files changed, 137190 deletions(-) delete mode 100644 org.glite.deployment.lb/.cvsignore delete mode 100644 org.glite.deployment.lb/build.xml delete mode 100644 org.glite.deployment.lb/config/scripts/glite-lb-config.py delete mode 100755 org.glite.deployment.lb/config/scripts/remove_all_rpms.sh delete mode 100644 org.glite.deployment.lb/config/templates/glite-lb.cfg.xml delete mode 100644 org.glite.deployment.lb/doc/release_notes/release_notes.doc delete mode 100644 org.glite.deployment.lb/doc/release_notes/release_notes.html delete mode 100644 org.glite.deployment.lb/doc/release_notes/release_notes.pdf delete mode 100644 org.glite.deployment.lb/project/.cvsignore delete mode 100644 org.glite.deployment.lb/project/build.properties delete mode 100644 org.glite.deployment.lb/project/glite-lb.sdf.xml.template delete mode 100644 org.glite.deployment.lb/project/glite-lb.spec delete mode 100644 org.glite.deployment.lb/project/lxscript-rpm.xsl delete mode 100644 org.glite.deployment.lb/project/lxscript-tgz.xsl delete mode 100644 org.glite.deployment.lb/project/properties.xml delete mode 100644 org.glite.deployment.lb/project/quattor-template.xsl delete mode 100644 org.glite.deployment.lb/project/version.properties delete mode 100644 org.glite.jp.common/.cvsignore delete mode 100644 org.glite.jp.common/Makefile delete mode 100755 org.glite.jp.common/build.xml delete mode 100644 org.glite.jp.common/interface/context.h delete mode 100755 org.glite.jp.common/interface/strmd5.h delete mode 100644 org.glite.jp.common/interface/types.h delete mode 100644 org.glite.jp.common/project/build.properties delete mode 100644 org.glite.jp.common/project/configure.properties.xml delete mode 100755 org.glite.jp.common/project/properties.xml delete mode 100644 org.glite.jp.common/project/tar_exclude delete mode 100644 org.glite.jp.common/project/version.properties delete mode 100644 org.glite.jp.common/src/context.c delete mode 100755 org.glite.jp.common/src/strmd5.c delete mode 100644 org.glite.jp.index/.cvsignore delete mode 100644 org.glite.jp.index/Makefile delete mode 100755 org.glite.jp.index/build.xml delete mode 100644 org.glite.jp.index/project/JobProvenanceIS.wsdl delete mode 100644 org.glite.jp.index/project/build.properties delete mode 100644 org.glite.jp.index/project/configure.properties.xml delete mode 100755 org.glite.jp.index/project/properties.xml delete mode 100644 org.glite.jp.index/project/tar_exclude delete mode 100644 org.glite.jp.index/project/version.properties delete mode 100644 org.glite.jp.index/src/simple_server.c delete mode 100644 org.glite.jp.index/src/soap_ops.c delete mode 100644 org.glite.jp.index/src/typemap.dat delete mode 100644 org.glite.jp.primary/.cvsignore delete mode 100644 org.glite.jp.primary/Makefile delete mode 100755 org.glite.jp.primary/build.xml delete mode 100644 org.glite.jp.primary/examples/jpps-test.c delete mode 100644 org.glite.jp.primary/project/build.properties delete mode 100644 org.glite.jp.primary/project/configure.properties.xml delete mode 100755 org.glite.jp.primary/project/properties.xml delete mode 100644 org.glite.jp.primary/project/tar_exclude delete mode 100644 org.glite.jp.primary/project/version.properties delete mode 100644 org.glite.jp.primary/src/backend.h delete mode 100644 org.glite.jp.primary/src/feed.c delete mode 100644 org.glite.jp.primary/src/feed.h delete mode 100644 org.glite.jp.primary/src/ftp_backend.c delete mode 100644 org.glite.jp.primary/src/is_client.c delete mode 100644 org.glite.jp.primary/src/jptype_map.h delete mode 100644 org.glite.jp.primary/src/simple_server.c delete mode 100644 org.glite.jp.primary/src/soap_ops.c delete mode 100644 org.glite.jp.primary/src/tags.c delete mode 100644 org.glite.jp.primary/src/tags.h delete mode 100644 org.glite.jp.primary/src/typemap.dat delete mode 100644 org.glite.jp/.cvsignore delete mode 100644 org.glite.jp/build.xml delete mode 100644 org.glite.jp/project/JobProvenance.wsdl delete mode 100644 org.glite.jp/project/JobProvenanceIS.wsdl delete mode 100644 org.glite.jp/project/JobProvenancePS.wsdl delete mode 100644 org.glite.jp/project/JobProvenanceTypes.wsdl delete mode 100644 org.glite.jp/project/JobProvenanceTypes.xsd delete mode 100644 org.glite.jp/project/build.properties delete mode 100644 org.glite.jp/project/dependencies.properties delete mode 100644 org.glite.jp/project/glite.jp.csf.xml delete mode 100755 org.glite.jp/project/properties.xml delete mode 100644 org.glite.jp/project/run-workspace delete mode 100755 org.glite.jp/project/taskdefs.xml delete mode 100644 org.glite.jp/project/version.properties delete mode 100644 org.glite.lb.client-interface/.cvsignore delete mode 100644 org.glite.lb.client-interface/LICENSE delete mode 100644 org.glite.lb.client-interface/Makefile delete mode 100755 org.glite.lb.client-interface/build.xml delete mode 100644 org.glite.lb.client-interface/interface/CountRef.h delete mode 100644 org.glite.lb.client-interface/interface/Event.h.T delete mode 100644 org.glite.lb.client-interface/interface/Job.h delete mode 100644 org.glite.lb.client-interface/interface/JobStatus.h.T delete mode 100644 org.glite.lb.client-interface/interface/LoggingExceptions.h delete mode 100644 org.glite.lb.client-interface/interface/Notification.h delete mode 100644 org.glite.lb.client-interface/interface/ServerConnection.h delete mode 100644 org.glite.lb.client-interface/interface/consumer.h delete mode 100644 org.glite.lb.client-interface/interface/consumer_fake.h delete mode 100644 org.glite.lb.client-interface/interface/context.h delete mode 100644 org.glite.lb.client-interface/interface/dump.h delete mode 100644 org.glite.lb.client-interface/interface/events.h.T delete mode 100644 org.glite.lb.client-interface/interface/jobstat.h.T delete mode 100644 org.glite.lb.client-interface/interface/load.h delete mode 100644 org.glite.lb.client-interface/interface/notification.h delete mode 100644 org.glite.lb.client-interface/interface/notifid.h delete mode 100644 org.glite.lb.client-interface/interface/producer.h.T delete mode 100644 org.glite.lb.client-interface/interface/producer_fake.h delete mode 100644 org.glite.lb.client-interface/interface/purge.h delete mode 100644 org.glite.lb.client-interface/project/build.properties delete mode 100644 org.glite.lb.client-interface/project/configure.properties.xml delete mode 100755 org.glite.lb.client-interface/project/properties.xml delete mode 100644 org.glite.lb.client-interface/project/tar_exclude delete mode 100644 org.glite.lb.client-interface/project/version.properties delete mode 100644 org.glite.lb.client/.cvsignore delete mode 100644 org.glite.lb.client/LICENSE delete mode 100644 org.glite.lb.client/Makefile delete mode 100755 org.glite.lb.client/build.xml delete mode 100644 org.glite.lb.client/doc/README-fake delete mode 100644 org.glite.lb.client/examples/aborted.l delete mode 100644 org.glite.lb.client/examples/cancelled.l delete mode 100644 org.glite.lb.client/examples/chkpt.l delete mode 100644 org.glite.lb.client/examples/cleared.l delete mode 100644 org.glite.lb.client/examples/consumer_fake.c delete mode 100644 org.glite.lb.client/examples/done.l delete mode 100644 org.glite.lb.client/examples/done_dag.l delete mode 100644 org.glite.lb.client/examples/done_subjob.l delete mode 100644 org.glite.lb.client/examples/failed_dag.l delete mode 100644 org.glite.lb.client/examples/failed_subjob.l delete mode 100644 org.glite.lb.client/examples/feed_shark.c delete mode 100755 org.glite.lb.client/examples/gen_begin delete mode 100755 org.glite.lb.client/examples/gen_sample_job delete mode 100644 org.glite.lb.client/examples/job_log.c delete mode 100644 org.glite.lb.client/examples/job_reg.c delete mode 100644 org.glite.lb.client/examples/log_usertag_proxy.c delete mode 100644 org.glite.lb.client/examples/notify.c delete mode 100644 org.glite.lb.client/examples/producer_fake.c delete mode 100644 org.glite.lb.client/examples/query_ext.c delete mode 100644 org.glite.lb.client/examples/query_seq_code.c delete mode 100644 org.glite.lb.client/examples/ready.l delete mode 100644 org.glite.lb.client/examples/ready_dag.l delete mode 100644 org.glite.lb.client/examples/ready_subjob.l delete mode 100644 org.glite.lb.client/examples/running.l delete mode 100644 org.glite.lb.client/examples/running_dag.l delete mode 100644 org.glite.lb.client/examples/running_subjob.l delete mode 100644 org.glite.lb.client/examples/scheduled.l delete mode 100644 org.glite.lb.client/examples/scheduled_dag.l delete mode 100644 org.glite.lb.client/examples/scheduled_subjob.l delete mode 100644 org.glite.lb.client/examples/submitted.l delete mode 100644 org.glite.lb.client/examples/submitted_dag.l delete mode 100644 org.glite.lb.client/examples/submitted_subjob.l delete mode 100644 org.glite.lb.client/examples/waiting.l delete mode 100644 org.glite.lb.client/examples/waiting_dag.l delete mode 100644 org.glite.lb.client/examples/waiting_subjob.l delete mode 100644 org.glite.lb.client/project/build.properties delete mode 100644 org.glite.lb.client/project/configure.properties.xml delete mode 100755 org.glite.lb.client/project/properties.xml delete mode 100644 org.glite.lb.client/project/tar_exclude delete mode 100644 org.glite.lb.client/project/version.properties delete mode 100644 org.glite.lb.client/src/Event.cpp.T delete mode 100644 org.glite.lb.client/src/Job.cpp delete mode 100644 org.glite.lb.client/src/JobStatus.cpp.T delete mode 100644 org.glite.lb.client/src/Notification.cpp delete mode 100644 org.glite.lb.client/src/ServerConnection.cpp delete mode 100644 org.glite.lb.client/src/args.c.T delete mode 100644 org.glite.lb.client/src/args.h delete mode 100644 org.glite.lb.client/src/connection.c delete mode 100644 org.glite.lb.client/src/connection.h delete mode 100644 org.glite.lb.client/src/consumer.c delete mode 100644 org.glite.lb.client/src/dump.c delete mode 100644 org.glite.lb.client/src/load.c delete mode 100644 org.glite.lb.client/src/logevent.c.T delete mode 100644 org.glite.lb.client/src/notification.c delete mode 100644 org.glite.lb.client/src/prod_proto.c delete mode 100644 org.glite.lb.client/src/prod_proto.h delete mode 100644 org.glite.lb.client/src/producer.c delete mode 100644 org.glite.lb.client/src/purge.c delete mode 100644 org.glite.lb.client/src/uiwrap.c.T delete mode 100644 org.glite.lb.client/test/prod_proto_test.c delete mode 100644 org.glite.lb.client/test/producer_test.cpp delete mode 100644 org.glite.lb.common/.cvsignore delete mode 100644 org.glite.lb.common/LICENSE delete mode 100644 org.glite.lb.common/Makefile delete mode 100755 org.glite.lb.common/build.xml delete mode 100644 org.glite.lb.common/interface/authz.h delete mode 100644 org.glite.lb.common/interface/context-int.h delete mode 100644 org.glite.lb.common/interface/escape.h delete mode 100644 org.glite.lb.common/interface/events_parse.h delete mode 100644 org.glite.lb.common/interface/il_string.h delete mode 100644 org.glite.lb.common/interface/lb_gss.h delete mode 100644 org.glite.lb.common/interface/lb_plain_io.h delete mode 100644 org.glite.lb.common/interface/log_proto.h delete mode 100644 org.glite.lb.common/interface/mini_http.h delete mode 100644 org.glite.lb.common/interface/trio.h delete mode 100644 org.glite.lb.common/interface/ulm_parse.h delete mode 100644 org.glite.lb.common/interface/xml_conversions.h delete mode 100644 org.glite.lb.common/interface/xml_parse.h delete mode 100644 org.glite.lb.common/project/build.properties delete mode 100644 org.glite.lb.common/project/configure.properties.xml delete mode 100755 org.glite.lb.common/project/properties.xml delete mode 100644 org.glite.lb.common/project/tar_exclude delete mode 100644 org.glite.lb.common/project/version.properties delete mode 100644 org.glite.lb.common/src/context.c delete mode 100644 org.glite.lb.common/src/escape.c delete mode 100644 org.glite.lb.common/src/events.c.T delete mode 100644 org.glite.lb.common/src/events_parse.c.T delete mode 100644 org.glite.lb.common/src/il_int.c delete mode 100644 org.glite.lb.common/src/il_log.c delete mode 100644 org.glite.lb.common/src/il_msg.c delete mode 100644 org.glite.lb.common/src/il_string.c delete mode 100644 org.glite.lb.common/src/lb_gss.c delete mode 100644 org.glite.lb.common/src/lb_plain_io.c delete mode 100644 org.glite.lb.common/src/mini_http.c delete mode 100644 org.glite.lb.common/src/notifid.c delete mode 100644 org.glite.lb.common/src/param.c delete mode 100644 org.glite.lb.common/src/query_rec.c delete mode 100644 org.glite.lb.common/src/status.c.T delete mode 100644 org.glite.lb.common/src/strio.c delete mode 100644 org.glite.lb.common/src/strio.h delete mode 100644 org.glite.lb.common/src/trio.c delete mode 100644 org.glite.lb.common/src/triop.h delete mode 100644 org.glite.lb.common/src/ulm_parse.c delete mode 100644 org.glite.lb.common/src/xml_conversions.c delete mode 100644 org.glite.lb.common/src/xml_parse.c.T delete mode 100644 org.glite.lb.common/test/il_int_test.cpp delete mode 100644 org.glite.lb.common/test/il_string_test.cpp delete mode 100644 org.glite.lb.common/test/il_test.cpp delete mode 100644 org.glite.lb.common/test/parse.cpp.T delete mode 100644 org.glite.lb.common/test/test_gss.cpp delete mode 100644 org.glite.lb.logger/.cvsignore delete mode 100644 org.glite.lb.logger/LICENSE delete mode 100644 org.glite.lb.logger/Makefile delete mode 100755 org.glite.lb.logger/build.xml delete mode 100755 org.glite.lb.logger/config/startup delete mode 100644 org.glite.lb.logger/project/build.properties delete mode 100644 org.glite.lb.logger/project/configure.properties.xml delete mode 100755 org.glite.lb.logger/project/properties.xml delete mode 100644 org.glite.lb.logger/project/tar_exclude delete mode 100644 org.glite.lb.logger/project/version.properties delete mode 100644 org.glite.lb.logger/src/event_queue.c delete mode 100644 org.glite.lb.logger/src/event_store.c delete mode 100644 org.glite.lb.logger/src/il_error.c delete mode 100644 org.glite.lb.logger/src/il_error.h delete mode 100644 org.glite.lb.logger/src/il_master.c delete mode 100644 org.glite.lb.logger/src/input_queue_socket.c delete mode 100644 org.glite.lb.logger/src/interlogd.c delete mode 100644 org.glite.lb.logger/src/interlogd.h delete mode 100644 org.glite.lb.logger/src/logd.c delete mode 100644 org.glite.lb.logger/src/logd_proto.c delete mode 100644 org.glite.lb.logger/src/logd_proto.h delete mode 100644 org.glite.lb.logger/src/queue_mgr.c delete mode 100644 org.glite.lb.logger/src/queue_thread.c delete mode 100644 org.glite.lb.logger/src/recover.c delete mode 100644 org.glite.lb.logger/src/send_event.c delete mode 100644 org.glite.lb.logger/src/server_msg.c delete mode 100644 org.glite.lb.logger/test/IlTestBase.cpp delete mode 100644 org.glite.lb.logger/test/IlTestBase.h delete mode 100644 org.glite.lb.logger/test/event_queueTest.cpp delete mode 100644 org.glite.lb.logger/test/event_storeTest.cpp delete mode 100644 org.glite.lb.logger/test/il_test.cpp delete mode 100644 org.glite.lb.logger/test/input_queue_socketTest.cpp delete mode 100644 org.glite.lb.logger/test/ll_test.cpp delete mode 100644 org.glite.lb.logger/test/logd_proto_test.c delete mode 100644 org.glite.lb.logger/test/server_msgTest.cpp delete mode 100644 org.glite.lb.server-bones/.cvsignore delete mode 100644 org.glite.lb.server-bones/Makefile delete mode 100755 org.glite.lb.server-bones/build.xml delete mode 100644 org.glite.lb.server-bones/examples/cnt_example.c delete mode 100644 org.glite.lb.server-bones/examples/srv_example.c delete mode 100644 org.glite.lb.server-bones/interface/srvbones.h delete mode 100644 org.glite.lb.server-bones/project/build.properties delete mode 100644 org.glite.lb.server-bones/project/configure.properties.xml delete mode 100755 org.glite.lb.server-bones/project/properties.xml delete mode 100644 org.glite.lb.server-bones/project/tar_exclude delete mode 100644 org.glite.lb.server-bones/project/version.properties delete mode 100644 org.glite.lb.server-bones/src/srvbones.c delete mode 100644 org.glite.lb.server/.cvsignore delete mode 100644 org.glite.lb.server/LICENSE delete mode 100644 org.glite.lb.server/Makefile delete mode 100755 org.glite.lb.server/build.xml delete mode 100644 org.glite.lb.server/config/glite-lb-dbsetup.sql delete mode 100644 org.glite.lb.server/config/glite-lb-index.conf.template delete mode 100755 org.glite.lb.server/config/startup delete mode 100644 org.glite.lb.server/examples/stdsoap2_2.6.0.c delete mode 100644 org.glite.lb.server/examples/stdsoap2_2.6.2.c delete mode 100644 org.glite.lb.server/examples/stdsoap2_2.7.0c.c delete mode 100644 org.glite.lb.server/examples/stdsoap2_2.7.0d.c delete mode 100644 org.glite.lb.server/examples/ws_getversion.c delete mode 100644 org.glite.lb.server/examples/ws_jobstat.c delete mode 100644 org.glite.lb.server/examples/ws_query_ex.c delete mode 100644 org.glite.lb.server/project/build.properties delete mode 100644 org.glite.lb.server/project/configure.properties.xml delete mode 100755 org.glite.lb.server/project/properties.xml delete mode 100644 org.glite.lb.server/project/tar_exclude delete mode 100644 org.glite.lb.server/project/version.properties delete mode 100644 org.glite.lb.server/src/bkindex.c delete mode 100644 org.glite.lb.server/src/bkserverd.c delete mode 100644 org.glite.lb.server/src/db_store.c delete mode 100644 org.glite.lb.server/src/dump.c delete mode 100644 org.glite.lb.server/src/get_events.c.T delete mode 100644 org.glite.lb.server/src/get_events.h delete mode 100644 org.glite.lb.server/src/il_lbproxy.c delete mode 100644 org.glite.lb.server/src/il_lbproxy.h delete mode 100644 org.glite.lb.server/src/il_notification.c delete mode 100644 org.glite.lb.server/src/il_notification.h delete mode 100644 org.glite.lb.server/src/index.c.T delete mode 100644 org.glite.lb.server/src/index.h delete mode 100644 org.glite.lb.server/src/index_lex.l delete mode 100644 org.glite.lb.server/src/index_parse.y delete mode 100644 org.glite.lb.server/src/jobstat.c delete mode 100644 org.glite.lb.server/src/jobstat.h delete mode 100644 org.glite.lb.server/src/jobstat_supp.c delete mode 100644 org.glite.lb.server/src/lb_authz.c delete mode 100644 org.glite.lb.server/src/lb_authz.h delete mode 100644 org.glite.lb.server/src/lb_html.c delete mode 100644 org.glite.lb.server/src/lb_html.h delete mode 100644 org.glite.lb.server/src/lb_http.c delete mode 100644 org.glite.lb.server/src/lb_http.h delete mode 100644 org.glite.lb.server/src/lb_proto.c delete mode 100644 org.glite.lb.server/src/lb_proto.h delete mode 100644 org.glite.lb.server/src/lb_xml_parse.c.T delete mode 100644 org.glite.lb.server/src/lb_xml_parse.h delete mode 100644 org.glite.lb.server/src/lb_xml_parse_V21.c.T delete mode 100644 org.glite.lb.server/src/lb_xml_parse_V21.h delete mode 100644 org.glite.lb.server/src/lbproxy.c delete mode 100644 org.glite.lb.server/src/lbs_db.c delete mode 100644 org.glite.lb.server/src/lbs_db.h delete mode 100644 org.glite.lb.server/src/load.c delete mode 100644 org.glite.lb.server/src/lock.c delete mode 100644 org.glite.lb.server/src/lock.h delete mode 100644 org.glite.lb.server/src/notif_match.c delete mode 100644 org.glite.lb.server/src/notification.c delete mode 100644 org.glite.lb.server/src/openserver.c delete mode 100644 org.glite.lb.server/src/purge.h delete mode 100644 org.glite.lb.server/src/query.c delete mode 100644 org.glite.lb.server/src/query.h delete mode 100644 org.glite.lb.server/src/request.c delete mode 100644 org.glite.lb.server/src/seqcode.c delete mode 100644 org.glite.lb.server/src/server_state.c delete mode 100644 org.glite.lb.server/src/server_state.h delete mode 100644 org.glite.lb.server/src/srv_purge.c delete mode 100644 org.glite.lb.server/src/store.c.T delete mode 100644 org.glite.lb.server/src/store.h delete mode 100644 org.glite.lb.server/src/stored_master.c delete mode 100644 org.glite.lb.server/src/userjobs.c delete mode 100755 org.glite.lb.server/src/write2rgma.c delete mode 100644 org.glite.lb.server/src/ws_fault.c delete mode 100644 org.glite.lb.server/src/ws_fault.h delete mode 100644 org.glite.lb.server/src/ws_plugin.c delete mode 100644 org.glite.lb.server/src/ws_plugin.h delete mode 100644 org.glite.lb.server/src/ws_query.c delete mode 100644 org.glite.lb.server/src/ws_typemap.dat delete mode 100644 org.glite.lb.server/src/ws_typemap.h delete mode 100644 org.glite.lb.server/src/ws_typeref.c.T delete mode 100644 org.glite.lb.server/src/ws_typeref.h delete mode 100644 org.glite.lb.server/test/oneJob.qry delete mode 100644 org.glite.lb.server/test/test_query_events.cpp delete mode 100644 org.glite.lb.server/test/test_soap_conv.cpp delete mode 100644 org.glite.lb.server/test/test_xml.cpp.T delete mode 100644 org.glite.lb.ws-interface/.Makefile.swp delete mode 100755 org.glite.lb.ws-interface/.cvsignore delete mode 100755 org.glite.lb.ws-interface/LICENSE delete mode 100644 org.glite.lb.ws-interface/Makefile delete mode 100644 org.glite.lb.ws-interface/build.xml delete mode 100755 org.glite.lb.ws-interface/interface/LB.wsdl delete mode 100755 org.glite.lb.ws-interface/project/build.properties delete mode 100644 org.glite.lb.ws-interface/project/configure.properties.xml delete mode 100644 org.glite.lb.ws-interface/project/properties.xml delete mode 100644 org.glite.lb.ws-interface/project/tar_exclude delete mode 100755 org.glite.lb.ws-interface/project/version.properties delete mode 100644 org.glite.lb/.cvsignore delete mode 100644 org.glite.lb/LICENSE delete mode 100755 org.glite.lb/build.xml delete mode 100644 org.glite.lb/project/MultiStruct.pm delete mode 100644 org.glite.lb/project/StructField.pm delete mode 100755 org.glite.lb/project/at3 delete mode 100644 org.glite.lb/project/build.properties delete mode 100644 org.glite.lb/project/dependencies.properties delete mode 100644 org.glite.lb/project/events.T delete mode 100644 org.glite.lb/project/glite.lb.csf.xml delete mode 100755 org.glite.lb/project/properties.xml delete mode 100644 org.glite.lb/project/run-workspace delete mode 100644 org.glite.lb/project/status.T delete mode 100755 org.glite.lb/project/taskdefs.xml delete mode 100644 org.glite.lb/project/types.T delete mode 100644 org.glite.lb/project/version.properties delete mode 100644 org.glite.security.proxyrenewal/.cvsignore delete mode 100644 org.glite.security.proxyrenewal/LICENSE delete mode 100644 org.glite.security.proxyrenewal/Makefile delete mode 100755 org.glite.security.proxyrenewal/build.xml delete mode 100755 org.glite.security.proxyrenewal/config/startup delete mode 100644 org.glite.security.proxyrenewal/interface/renewal.h delete mode 100644 org.glite.security.proxyrenewal/project/build.properties delete mode 100644 org.glite.security.proxyrenewal/project/configure.properties.xml delete mode 100755 org.glite.security.proxyrenewal/project/properties.xml delete mode 100644 org.glite.security.proxyrenewal/project/tar_exclude delete mode 100755 org.glite.security.proxyrenewal/project/taskdefs.xml delete mode 100644 org.glite.security.proxyrenewal/project/version.properties delete mode 100644 org.glite.security.proxyrenewal/src/api.c delete mode 100644 org.glite.security.proxyrenewal/src/client.c delete mode 100644 org.glite.security.proxyrenewal/src/commands.c delete mode 100644 org.glite.security.proxyrenewal/src/common.c delete mode 100644 org.glite.security.proxyrenewal/src/renew.c delete mode 100644 org.glite.security.proxyrenewal/src/renewal_locl.h delete mode 100644 org.glite.security.proxyrenewal/src/renewd.c delete mode 100644 org.glite.security.proxyrenewal/src/renewd_locl.h delete mode 100755 org.glite.wms-utils.jobid/.cvsignore delete mode 100755 org.glite.wms-utils.jobid/LICENSE delete mode 100755 org.glite.wms-utils.jobid/Makefile.am delete mode 100755 org.glite.wms-utils.jobid/bootstrap delete mode 100755 org.glite.wms-utils.jobid/build.xml delete mode 100755 org.glite.wms-utils.jobid/configure.ac delete mode 100755 org.glite.wms-utils.jobid/examples/Makefile.am delete mode 100755 org.glite.wms-utils.jobid/examples/testjobid.c delete mode 100755 org.glite.wms-utils.jobid/interface/Makefile.am delete mode 100755 org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/JobId.h delete mode 100755 org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/JobIdExceptions.h delete mode 100755 org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/cjobid.h delete mode 100755 org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/manipulation.h delete mode 100755 org.glite.wms-utils.jobid/project/build.properties delete mode 100644 org.glite.wms-utils.jobid/project/configure.properties.xml delete mode 100755 org.glite.wms-utils.jobid/project/properties.xml delete mode 100755 org.glite.wms-utils.jobid/project/version.properties delete mode 100755 org.glite.wms-utils.jobid/src/Makefile.am delete mode 100755 org.glite.wms-utils.jobid/src/jobid/JobId.cpp delete mode 100755 org.glite.wms-utils.jobid/src/jobid/JobIdExceptions.cpp delete mode 100755 org.glite.wms-utils.jobid/src/jobid/Makefile.am delete mode 100755 org.glite.wms-utils.jobid/src/jobid/cjobid.c delete mode 100755 org.glite.wms-utils.jobid/src/jobid/manipulation.cpp delete mode 100755 org.glite.wms-utils.jobid/src/jobid/strmd5.c delete mode 100755 org.glite.wms-utils.jobid/src/jobid/strmd5.h delete mode 100644 org.gridsite.core/.cvsignore delete mode 100644 org.gridsite.core/CHANGES delete mode 100644 org.gridsite.core/INSTALL delete mode 100644 org.gridsite.core/LICENSE delete mode 100644 org.gridsite.core/README delete mode 100644 org.gridsite.core/VERSION delete mode 100644 org.gridsite.core/build.xml delete mode 100644 org.gridsite.core/doc/README.htcp-bin delete mode 100644 org.gridsite.core/doc/admin.html delete mode 100644 org.gridsite.core/doc/build-apache2.sh delete mode 100644 org.gridsite.core/doc/config.html delete mode 100644 org.gridsite.core/doc/findproxyfile.1 delete mode 100644 org.gridsite.core/doc/gacl.html delete mode 100644 org.gridsite.core/doc/htcp.1 delete mode 100644 org.gridsite.core/doc/htll.1 delete mode 100644 org.gridsite.core/doc/htls.1 delete mode 100644 org.gridsite.core/doc/htmkdir.1 delete mode 100644 org.gridsite.core/doc/htrm.1 delete mode 100644 org.gridsite.core/doc/httpd-fileserver.conf delete mode 100644 org.gridsite.core/doc/httpd-webserver.conf delete mode 100644 org.gridsite.core/doc/index.html delete mode 100644 org.gridsite.core/doc/install.html delete mode 100644 org.gridsite.core/doc/library.html delete mode 100644 org.gridsite.core/doc/module.html delete mode 100644 org.gridsite.core/doc/urlencode.1 delete mode 100644 org.gridsite.core/doc/user.html delete mode 100644 org.gridsite.core/interface/gridsite-gacl.h delete mode 100644 org.gridsite.core/interface/gridsite.h delete mode 100644 org.gridsite.core/project/build.properties delete mode 100644 org.gridsite.core/project/configure.properties.xml delete mode 100644 org.gridsite.core/project/dependencies.properties delete mode 100644 org.gridsite.core/project/gridsite.core.csf.xml delete mode 100644 org.gridsite.core/project/properties.xml delete mode 100644 org.gridsite.core/project/taskdefs.xml delete mode 100644 org.gridsite.core/project/version.properties delete mode 100644 org.gridsite.core/src/Doxyfile delete mode 100644 org.gridsite.core/src/Makefile delete mode 100644 org.gridsite.core/src/delegation.h delete mode 100644 org.gridsite.core/src/doxygen.css delete mode 100644 org.gridsite.core/src/doxyheader.html delete mode 100644 org.gridsite.core/src/findproxyfile.c delete mode 100644 org.gridsite.core/src/gaclexample.c delete mode 100644 org.gridsite.core/src/gridsite.spec delete mode 100644 org.gridsite.core/src/grst-delegation.c delete mode 100644 org.gridsite.core/src/grst_admin.h delete mode 100644 org.gridsite.core/src/grst_admin_file.c delete mode 100644 org.gridsite.core/src/grst_admin_gacl.c delete mode 100644 org.gridsite.core/src/grst_admin_main.c delete mode 100644 org.gridsite.core/src/grst_gacl.c delete mode 100644 org.gridsite.core/src/grst_http.c delete mode 100644 org.gridsite.core/src/grst_x509.c delete mode 100644 org.gridsite.core/src/htcp delete mode 100644 org.gridsite.core/src/htcp.c delete mode 100644 org.gridsite.core/src/htproxyput.c delete mode 100644 org.gridsite.core/src/mod_gridsite.c delete mode 100644 org.gridsite.core/src/mod_ssl-private.h delete mode 100644 org.gridsite.core/src/proxyput-example.c delete mode 100644 org.gridsite.core/src/real-gridsite-admin.cgi delete mode 100755 org.gridsite.core/src/roffit delete mode 100644 org.gridsite.core/src/urlencode.c diff --git a/org.glite.deployment.lb/.cvsignore b/org.glite.deployment.lb/.cvsignore deleted file mode 100644 index 3a4edf6..0000000 --- a/org.glite.deployment.lb/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -.project diff --git a/org.glite.deployment.lb/build.xml b/org.glite.deployment.lb/build.xml deleted file mode 100644 index 0ceaee9..0000000 --- a/org.glite.deployment.lb/build.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.deployment.lb/config/scripts/glite-lb-config.py b/org.glite.deployment.lb/config/scripts/glite-lb-config.py deleted file mode 100644 index e4c355c..0000000 --- a/org.glite.deployment.lb/config/scripts/glite-lb-config.py +++ /dev/null @@ -1,279 +0,0 @@ -#!/usr/bin/env python -################################################################################ -# -# Copyright (c) Members of the EGEE Collaboration. 2004. -# See http://eu-egee.org/partners/ for details on the copyright holders. -# For license conditions see the license file or http://eu-egee.org/license.html -# -################################################################################ -# glite-lb-config v. 0.2.0 -# -# Post-installation script for configuring the gLite Logging and Bookkeping Server -# Robert Harakaly < robert.harakaly@cern.ch > -# Diana Bosio -# Leanne Guy -# -# Version info: $Id$ -# -# Usage: python glite-lb-config [-c|-v|-h|--help] -# -c print configuration -# -v print version -# -h,--help print usage info -# -# Return codes: 0 - Ok -# 1 - Configuration failed -# -################################################################################ - -import os,string -import sys, posix, getopt,time - -sys.path.append(".") -from gLiteInstallerLib import gLib -import mysql as MySQL - -# Set global variables here -global params # all config values from the XML file - -class glite_lb: - - def __init__(self): - self.mysql = MySQL.Mysql() - self.verbose = 0 - self.version = "0.2.0" - self.name = "glite-lb" - self.friendly_name = "gLite Logging and Bookkeeping" - - #------------------------------------------------------------------------------- - # Banner - #------------------------------------------------------------------------------- - - def banner(self): - - print "\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - print "Configuring the %s" % self.friendly_name - print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" - - #------------------------------------------------------------------------------- - # Copyright - #------------------------------------------------------------------------------- - - def copyright(self): - - print '\nCopyright (c) Members of the EGEE Collaboration. 2004' - print 'See http://eu-egee.org/partners/ for details on the copyright holders' - print 'For license conditions see the license file or http://eu-egee.org/license.html' - - #------------------------------------------------------------------------------- - # Version - #------------------------------------------------------------------------------- - - def showVersion(self): - - print '\n%s-config v. %s\n' % (self.name,self.version) - - #------------------------------------------------------------------------------- - # Usage - #------------------------------------------------------------------------------- - - def usage(self,msg = ""): - - if msg: - print "\n%s" % (msg) - - self.copyright() - self.showVersion() - - print """Usage: \n -Edit the configuration file %s.cfg.xml in -%s/etc.config/templates\n -save it as %s/etc/config/%s.cfg.xml -and run the script as follows\n -python %s-config [OPTION...]""" % (self.name, os.environ['GLITE_LOCATION'], \ - os.environ['GLITE_LOCATION'], self.name, self.name) - - print ' -c, --checkconf print the service configuration' - print ' -v, --version print the version of the configuration script' - print ' -h, --help print this usage information' - print '\n' - - #------------------------------------------------------------------------------- - # All the configuration code goes here - #------------------------------------------------------------------------------- - - def start(self): - self.mysql.start() - os.system('%s/etc/init.d/glite-lb-bkserverd start' % os.environ['GLITE_LOCATION']) - - return 0 - - def stop(self): - os.system('%s/etc/init.d/glite-lb-bkserverd stop' % os.environ['GLITE_LOCATION']) - self.mysql.stop() - - return 0 - - def configure(self): - # Create all directories needed - if params.has_key('dirlist'): - dirlist = string.split(params['dirlist'],',') - for d in dirlist: - glib.check_dir(d,0777) - glib.check_dir(params['GLITE_CERT_DIR']) - - # Create the GLITE_USER if it doesn't exists - print "Creating/Verifying the GLITE_USER account %s" % params['GLITE_USER'] - glib.add_user(params['GLITE_USER'],params['GLITE_USER']) - (uid,gid) = glib.get_user_info(params['GLITE_USER']) - glib.check_dir(os.environ['GLITE_LOCATION_VAR'],0755, uid, gid) - glib.check_dir("/home/%s/.certs" % params['GLITE_USER'],0755, uid, gid) - # Copy certificates - os.system("cp %s %s ~%s/.certs/" % (params['host.certificate.file'], params['host.key.file'], params['GLITE_USER'])) - os.chown(params['lb.certificate.file'], uid,gid) - os.chown(params['lb.key.file'],uid,gid) - - # Create the MySQL database - self.mysql.stop() - time.sleep(5) - self.mysql.start() - - print '#-------------------------------------------------------------------' - print ('Creating MySQL %s database.' % params['lb.database.name']) - print '#-------------------------------------------------------------------' - - os.system('/usr/bin/mysqlaccess %s %s' % (params['lb.database.username'], params['lb.database.name'])) - file = open('/tmp/mysql_ct', 'w') - text = ['CREATE DATABASE %s;\n' % params['lb.database.name'], - 'GRANT ALL PRIVILEGES ON %s.* TO %s@localhost IDENTIFIED BY "";\n' % (params['lb.database.name'],params['lb.database.username']), - 'USE %s;\n' % params['lb.database.name'], - '\. %s/etc/glite-lb-dbsetup.sql\n' % os.environ['GLITE_LOCATION']] - - file.writelines(text) - file.close() - os.system('/usr/bin/mysql < /tmp/mysql_ct') - os.system('/bin/rm /tmp/mysql_ct') - if not os.path.exists('/tmp/mysql.sock'): - os.symlink('/var/lib/mysql/mysql.sock', '/tmp/mysql.sock') - self.mysql.stop() - - return 0 - -#------------------------------------------------------------------------------- -# Set all environment variables -#------------------------------------------------------------------------------- - -def set_env(): - - # gLite - glib.export('GLITE_LOCATION'); - glib.export('GLITE_LOCATION_VAR'); - if not os.path.exists(os.environ['GLITE_LOCATION_VAR']): - os.mkdir(os.environ['GLITE_LOCATION_VAR'],0755) - glib.export('GLITE_LOCATION_LOG'); - if not os.path.exists(os.environ['GLITE_LOCATION_LOG']): - os.mkdir(os.environ['GLITE_LOCATION_LOG'],0755) - glib.export('GLITE_LOCATION_TMP'); - if not os.path.exists(os.environ['GLITE_LOCATION_TMP']): - os.mkdir(os.environ['GLITE_LOCATION_TMP'],0755) - - glib.export('GLITE_HOST_CERT',params['lb.certificate.file']) - glib.export('GLITE_HOST_KEY',params['lb.key.file']) - glib.export('GLITE_USER','gproduct') - glib.export('GLOBUS_LOCATION',params['GLOBUS_LOCATION']) - glib.export('GLITE_CERT_DIR',params['GLITE_CERT_DIR']) - - # bin and lib paths - glib.addEnvPath("PATH","/usr/bin/:%s/bin:%s/externals/bin:%s/bin" % (os.environ['GLOBUS_LOCATION'],os.environ['GLITE_LOCATION'],os.environ['GLITE_LOCATION'])) - glib.addEnvPath("LD_LIBRARY_PATH","/usr/lib:%s/lib:%s/externals/lib:%s/lib" % (os.environ['GLOBUS_LOCATION'], os.environ['GLITE_LOCATION'],os.environ['GLITE_LOCATION'])) - - # Set environment - glib.setUserEnv() - -#------------------------------------------------------------------------------- -# Main program begins here -#------------------------------------------------------------------------------- - -if __name__ == '__main__': - - # Command line opts if any - try: - opts, args = getopt.getopt(sys.argv[1:], 'chv', ['checkconf', 'help', 'version','stop','start']) - except getopt.GetoptError: - usage(msg = "Unknown options(s)") - sys.exit(1) - - # The script must be run as root - if not os.geteuid()==0: - print '"\nThis script must be run as root\n' - sys.exit(1) - - # Get an instance of the library class - glib = gLib() - - # Load parameters - params = {} - if glib.loadConfiguration("%s/../glite-lb.cfg.xml" % glib.getScriptPath(),params): - print "Configuration files not found.\nPlease verify if the configuration files are copied from the templates directory\n" - sys.exit(1) - - verbose = 0 - if params.has_key('glite.installer.verbose'): - if params['glite.installer.verbose'] == "true": - verbose = 1 - glib.verbose = verbose - - # Set up the environment - set_env() - - # Instantiate the service classes - service = glite_lb() - service.verbose = verbose - - # Check cli options - for o, a in opts: - if o in ("-h", "--help"): - service.usage() - sys.exit(0) - if o in ("-v", "--version"): - service.showVersion() - sys.exit(0) - if o in ("-c", "--checkconf"): - service.copyright() - service.showVersion() - glib.print_params(params) - sys.exit(0) - if o == "--stop": - service.stop() - sys.exit(0) - if o == "--start": - service.start() - sys.exit(0) - - # Check certificates - if params.has_key('glite.installer.checkcerts'): - if params['glite.installer.checkcerts'] == "true": - if glib.check_certs(params) != 0: - print "Certificate files are not found\n" - sys.exit(1) - - # Print configuration parameters - if verbose: - glib.print_params(params) - - service.copyright() - service.showVersion() - service.banner() - - # Configure the service - if service.configure() == 0: - print "%s configuration successfully completed\n" % service.friendly_name - else: - print "An error occurred while configuring the %s" % service.friendly_name - sys.exit(1) - - # Start the service - # service.stop() - if service.start() != 0: - print "An error occurred while starting the %s" % service.friendly_name - sys.exit(1) - diff --git a/org.glite.deployment.lb/config/scripts/remove_all_rpms.sh b/org.glite.deployment.lb/config/scripts/remove_all_rpms.sh deleted file mode 100755 index 2835ee1..0000000 --- a/org.glite.deployment.lb/config/scripts/remove_all_rpms.sh +++ /dev/null @@ -1,49 +0,0 @@ - -#!/bin/sh - -rpm -e edg-fetch-crl-1.0.0-EGEE \ -ca_ArmeSFo-0.23-1 \ -ca_ASGCCA-0.23-1 \ -ca_BEGrid-0.23-1 \ -ca_CERN-0.23-1 \ -ca_CESNET-0.23-1 \ -ca_CNRS-0.23-1 \ -ca_CNRS-DataGrid-0.23-1 \ -ca_CNRS-Projets-0.23-1 \ -ca_CyGrid-0.23-1 \ -ca_DOEGrids-0.23-1 \ -ca_DOESG-Root-0.23-1 \ -ca_ESnet-0.23-1 \ -ca_FNAL-0.23-1 \ -ca_FNAL_KCA-0.23-1 \ -ca_GermanGrid-0.23-1 \ -ca_Grid-Ireland-0.23-1 \ -ca_GridCanada-0.23-1 \ -ca_HellasGrid-0.23-1 \ -ca_INFN-0.23-1 \ -ca_IUCC-0.23-1 \ -ca_LIP-0.23-1 \ -ca_NIKHEF-0.23-1 \ -ca_NorduGrid-0.23-1 \ -ca_PK-Grid-0.23-1 \ -ca_PolishGrid-0.23-1 \ -ca_Russia-0.23-1 \ -ca_SlovakGrid-0.23-1 \ -ca_Spain-0.23-1 \ -ca_UKeScience-0.23-1 \ -glite-wms-utils-exception-0.1.0-0 \ -glite-wms-utils-jobid-0.1.0-0 \ -glite-lb-client-interface-0.2.0-0 \ -glite-lb-server-bones-0.0.0-0 \ -glite-lb-common-0.2.0-0 \ -glite-lb-logger-0.2.0-0 \ -glite-lb-server-0.3.0-0 \ -glite-security-proxyrenewal-0.1.0-1 \ -ares-1.1.1-EGEE \ -gpt-VDT1.2.0rh9-1 \ -vdt_globus_essentials-VDT1.2.0rh9-1 \ -perl-Expect.pm-1.01-9 \ -myproxy-1.14-EGEE \ -MySQL-client-4.0.20-0 \ -MySQL-server-4.0.20-0 - diff --git a/org.glite.deployment.lb/config/templates/glite-lb.cfg.xml b/org.glite.deployment.lb/config/templates/glite-lb.cfg.xml deleted file mode 100644 index 7161e14..0000000 --- a/org.glite.deployment.lb/config/templates/glite-lb.cfg.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.glite.deployment.lb/doc/release_notes/release_notes.doc b/org.glite.deployment.lb/doc/release_notes/release_notes.doc deleted file mode 100644 index 5fc59f7ed7fd784df377df43e569a4d21cefc8b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 172032 zcmeF42S60Z_s8crx}egrpNd^TiVYhUus7^ont;+mQL&;i`q!8kO=1#z)WjNlkBYs< z#KgqjjV(5;F&6lL-|p?*?llesewJJPaJxG@_04-TvpYL`{5OZo->)rsg=uV!nVe;1 z+b~Pfc{%pm%9JOHGu9sabeNT$olR$3;h;5W18~Z;y#pn1_lMnV>_8iH#-2N7@S=re zu|e?iHjEWzVS~d4-ysoz=H5 zT(Fqi`P_*=reENc@L!2HJq`UW{e5f2Yt&} zWgK^iWUQ|RW6K9K)(+P{!!K=`zXxKGHk|Johj8$lj$g{{zHb;qFzf(+X*1^61J@0i z#aJ{vo|wbf9vuGz|1K1O#wO(ZTg0bp+lh2RtZa|+SGZ32rEtZYX88*F6t1D;LnyCo z_@kmfo5H(j{!;kck$wvAG_DuIDGN^v;6*s5@)2)BIO220>hSZTNk`DupwVu$0vtY=$WUEGHl`Aw*QT@x9@e^&fcq(^YX z@2+W(lQm?FdRGg_RR3tJj_V%b_v^XbA=?Mf>tKTE*dM3rA^!Z>D4d!|tq_k8rcl2k zK7$@Wo}iuMo6g zAH=^cycz2rjC7Pz+Yhlj`6YMSG|vmintGShF*Pa_o*A=K)iF9YZKe{)eF;Rhi%E%8 zv`dJJiiwX>R8}-gNEk9CGBS~lx6KpQlcXjIR~hSONdB~jZ_TvQq=PD^{VBi=n8*>5@KT$hEcT1k>M0a zvLZ1lVQ5T5q#`sTB8JX{#wuds2PGuMh0>8CG%O)Cg^N?1kjVIyn%qfcED@23k?|3c z@!>I%$-Kjm_=I7Ku+*qzMQD74A|^RGHIm;ARm8?5rzjEz@vh;q3CWQWisYF1@JKGi z#H7ffF$t-vjC(196Owc!2}O|-8XHS_p%_vTLX?qZQ&W-17j{zQpvWXeN`lB=Yd%AX=Rm=6y+5ai@N0n0mLSx#o;=y*f1+j;#N+IR=qj} zg|utkp{=4qbV^EMfVVe)^{~h=ukgsEc(3qi{)~5GX!wxOsK{jR*1olB`TO|z*6~&r zFe2oy@r(@{pgQN399=;nbIx6;zCN{b4An(p{|4!%7{X%Wy_2FNWBqD*$0vj)A&ViM z+ILaq!4skz6cgpim64~97k`acQes@*GL+}&T=d9~PakCH=T+-XWSC=Fpdub) z#zzhdjpb@aLE1r`v2vy2Q;_w;xM)>nGb}FIGc_e9HrX?Bcz7f?VBkvTjVwkEI-?^_ zu3UTzvRsUbR7a@{P6&&MD8v%s;w#M3&>bO4!oG!QG-m7oMLCd*4&?`!>M@CUXs3TX zf-bgV5XL0@D8-5&$aGPvuc903DF&CERmWKLP1`ipC`1^Us8okjh=LfU7>EHS-m+6y ztL`njDtu_9owwXY4o8<4gYRTq@8I2U$Obp1T4T3*6O&L~$cV-vzK9uG=R zM&CRJNi4X$4vk0|5XD6|AW{`wf#yCpF`_)$r*-Mv&XaG)t^9FY#W&yOEsg?xGKvCb zB`@6){W3Qkhbo`^aI8S{sT}bYXg>ADfqaH0!6^Bl>zBt4h5jO@kfE#i=NZ&8C@7x= zs4sM6DK3rcEm5xg^V=3F!=`-s7eu!7hmVXUMkd921`SWdolCF8IOMNZz6%XesAE7b zYx#KA&u7UQi~_l|Z;Lyp@tU_zrT2ohTWO6utzL>|sZomf)VMI*zQZkKt=pXB+%*X| z{kVI-2 zc%z6&+(xH+rg4?&&w!YSMzwu>YgbS>FQ`a6F8LXx>c&>s5Wda8o$i#-q!jPul!Qe5 z2~9!68WEG67#o_FjC=GRFrQpP-;_pYj0$-*3b{ zyx4^B&{+JXdpD?4k+^lG@KoeqcKqupv*TYczp}#x*&{kKUXhd}q-xJ3sjyps|VQoOzB zASpaR(J3-14v(kkSr;B)#lY@GCMDsCQ$A+bpO;(xTK@T#T?$f1cBvjJ;uBI7;n9)d zLy)0Cp{cPc3Q|e#X&#>IDZ-N?kx{NApMQDut)tANZ=L+gBNt=~We!qdJ{8H)38}FW zT>io$VJ#smR9R}HV&Y>`ykJ|oN2mE`I_vu>O(%BpD_dNUY8mjOW*mo7lZ)(l4-HN7 zPKisTCxtLZk>MB!g(jutpQ!wV>gbnm)sYL58n_rd#N`?|?wKq#awM&oK{0&&!xP{n z5*8jjCF3D5Y9SteCh0P$B+#0IKq>F`9TL!wiAxxY=hJ9$!XqP6DJa$R>j=fLn3QN# z2GJw)&_pz~ia|*Uaa<)4yel8O(%{-l(KJ3y5gHy2ON}SmTsK956eXZiB_Y1#gw!Nt zNe~a>6rM6G@0ak8&{C6l^@>ZylWkPZxX}1iSk*K|IG!`dM@I1d7d-hDKkSYT#l^~p z>eBArpqSxMW9g$|>PLwlrF$v52v5vW3{jk+BJh^Z;4#_Llb{xo6J?I(w2Xr;9>Suw6+1I=*!|3rIWpV=9zELavY{ zrdH5I0rV%xM#P3Gga`KdW*2<@lqMWI`ICX#e30#$A<5ia4R2ms6cGvGsZ`T=rJ=!0 zazb1r-|pt4@%9mnw@cTxk{$I^>f*7c}7sgB{M5R4q|6k8^ zGG_kNo6U66cv5G0rW48tH?!Vkrqdfmhr3!jXR7hd0r!mVjb$i$(yv_>;gRZDUxiQ> z>bXvuk)b41t%vfiv~;dhewKrd=lq&+;=uyV{d$wRP8u~MFOiB%MK$N=4QIdQoGjHu z94dh~ne&t9sKoh(spRK)6?ne+mwpbDfMX1KpFWR3)LF+`&y}cn9ZeSx7#!W8Y>d-$; zAvg11ga^0AjIQ!0M$~ojRFwjqiK6Tu6zEJ8eQ~Jr$#>8TG@r^bK!N5{UmVCM&0I0f zxZy^D>bI`+Ym5FFG5Mp7`oo8;OfznTmmW*j=F_B<_j|_8J2*wf^nBIyd{r_> z&-8qidm%dC9@D)|&sXj3<@WaG!e4uPymH;TL-TgsS_E}!-MnkJkf0pj7mtbK-WKP& zF$0qEa=h2z#Hb32zSR}&gF;#c1$PW--?VG%4nbWN&N3G(<&!`~hlCV#{#qo2dnsCT zbC3qbL?#6w_Tbj-f;u#9AEeL-LE)@yfCu2oDPF+GlVfyCtgKpKwoHHmFMIp=deaN* z7!uptx9-x_69;~twQJSG%r%m~9^E|i`+=RCcCOm_SIgS=xNSFkYCs6JKfJ=Z8QE@e0{T! z81?mVZx*&oa$MPSz2w+e)=hFu;flj+?(vD_ctw>7lH=ob&#I4|UAT1dsf%l6XPyiw zm2{QrxTH&T?4Ul3zbe3bTm$QIDmQ1>Xo^AOtjfo-#+5bPD$zP`BzKZI$%$kn$e<16 z5CVFD7vi#hDn7^*ALw_HTy{b1NB@END$~AZ2{>XMHV;|rL9_}~R0P$$*aO9VaKJ4O zRh(a&kzolq-jSKhuvgQj1eP1CBb?(Fc%0FSvCXZq(i|{r!`N$Vnvt1~-?tJlH)k@L zIoVp$@h*V$yeCKiNgx>v1;fC{;4g3roCarrtO#Sapa!T3Jb@Q@eB<$%quW+)n{{;Z z(T`^J@6dl%qodlTr*Mh(bl49&_RPLFYu?5g7S6_;Y-cilIs0AKHJa>atv1zkyL-4q zkMuKBhM@NML}FQj$-*&U_&T zvgm66nn_^rt+!O%1>aP96uzpxQMpj)x?QL}6uUSJGEam&N!BDkH!NeAEEd?nJRFF< z6y(0t3a;xtR&51g2bES3OB@d2)(V8dbQ5f*+00mGanc=TkxZi&)+d9R{HyHeHmmHn zcreQd6pqGbxrtW9m2Q@{ZqgG_5iC@AS>|-I796rECS!k{pUFKcxjjQ9?)0bRNyvpW z?quMzOGyt)OApIP5B*PCGMNPe;dX50u`HB=WELcEZ_ohz2$q6nU^#F>e6E1%gFEmC zbwPa)02+XnU=3IY?wmVxZuy;W?o3FI>=7AEM~ER8n^Af}7D1<08Pb`YZ4GQm`_hAQ zvL(3cRQoEp%Aj3pz*!tvCf?$xeKf8vYgXNiQZKR?iP0of!RR3d3Ok1wa!lE627STRD5ms44ONjvY~xw1B_m>_GCGs(Ah(f3yWZ(^ux z(ti#8Cmr4m_5eS~-XBmMr~_JowxAto4|;)JU=P>}RJtGCGpJ`3QhmNI()}F6b&*#_ zq2=RMQjb;8&|9sRPs3fm)<`du=)cs7LAy!w#XWfKEBLXC+CpfIT_oXaxD|x{_p-{V z%=ttJWv(1z6%}M140)2AJ+VZ8Ui$t<8UBK}$oTeuCT?w+^j|~&Nssq|8jyQUK=Stj zjX+}%2%3WyAP95@TfjE(GuRF)VwB|pDuK$N4!Cpr&i)OHW-OX8<4(%{lVFwj9FzWQ=)YKJ8$$MF9Nt^`FNT>j$zMbMWUK1~l6@o48ms~9 zz_1bn0hSj*zzmUU0e9HP}zDtwq3(MYT0KE zcl{PkdST9%*f7S?h`DcTjI-ogInJXE&$(rhv~AK@90ZyALxv>RD(FwWr}n=F zvS-qN4gDwG-3+#X%iuPsggQ_eP+jl>jX-120tA81U?2{2w_zR(__nrFYkSF11wah8#{cr!4OCHEE&F{sD#dTnok+kf?4dcA4Lo&7(D%5Au( z$~Q04){vDTS$6<}yh)Dlss1ZaVNCk3q5mZB2tc|^dK-s&^q$K9H+-bgB!3P0lWl$t zvOs0X-Wv=7v4HAAJV*eez(lYJ90o_gQIH89g5sF=;sDBkwx9zT2}T2<-#=yIn4x3h zhlY;na%_1Z{*lRtJ-*c8SWfdDV2|l4o%230>xq9BqdB*UX3oB7T}C}W3dc07N;O{! z$C~ql>3UY$C7R{|^R8NRv)<1Be^Y#lHutR|bJvuyAlI{y=~W=H1@YpZeT?`(;vzZd zBEBq8e8BHZ`|mxwR#*4maRKf=aTBIcJLMjvy?jSM)B_V(<%)(nuNBR673RK9rTJg+ zWlj38IseOwWGv_~O2ZHp|O2IZnD+Za`5O#DH?e?c_DM@xpI(`heI5hGf(zgx zxCAbPYv6Bi6Wjv#z?m*B>95ew zRasx$B@v(3va_oGulOn*bJ+CTf4Hpb{{(iN{!-haiW@eZtOsx5b+#&wx_$BO0;Nc& zFI8(MPP10da8XMko2GGqw4Jt zQAwMV?)Cz`K_BovSP3?REnq9y1~R}tZ~*)Uj)N26PjCjD1?Rv`&;$dmHlQ2m0W$yC zxnjp0Z zt)s3ZX{&U=_Gg{7GPmvjyox6M*X-FzOPWSVy7b?I^s^`E1=fP?;2<~zs2&^vC&4Lj z0bB%^z#R}!l56)@Y&$k@=HyY66Z*8Rr%UFNbI=SLgYhFVL2tA)1GSc}((A6$9Pw3# z`Ua0(6Qw->m0i%~qE4Zt*8uB4+Ag*&{K!+wjugIiDDIIL>%fW$GA8+wY}Z1jk}+RD zvG^qYf60OPsyE)3*4^Cn5~!!Aqn>l4gr=2ERzlNCn3E0%g0`SN=m0u`d0;VE4b}jv z7wfvkXD)0lfK^;&ROaxQG!;8PJnKOCBvQ*PN`Nakdn> zRhO7xQH9*P3UbYWJW00SL2mD<{;#ZR(tj=eCq4ZJd<#hSv%q|?82kW!1nav{OA3?OJFYOYbxYU`Wl4iAMdIB2YZ_2uVw$q7T*9jfe&O~8#D(k z0M&(H&>QptQD8Ip85{tIz+rF%l*BFgvY;BM4r+j!z!Tu!Fvf_pznpk%c5+1W>|o_# zW6irQyxp!_>wjgp^Up>bZl8>@%*AzS{n?v@^@EoBz=m2^HNnMaU*p)p04Hb9UBnKVDE|LSWgYJC;_W|HRcs7hTAMv!1 zdn8P^X~pXt(eqzA$BqAM`kLggDSs=n&m{M*APoEkPJ*kTDCA!pH~>e`7&HNapeYdQ zN+0a^1wViv!AkHGSOr#t=ioo!uR!|(>VkTpJ{S)^2CtsneRBE9Ur!EP-g^1T+GS7X zd^$$`FD1NtIHNg-(JjN>aqp1+N_yAj`SmU|-El`y=vJdouH{Q*@3mZ1;qkqF!Ce#{ z{Fb+#A$o!+L`1VrG*^LZY`$9EzlYDj?#q=vX*{m-S%zCTWFD$1EII#dQWPUrhoh>j zF=xe1Sm}e@L{}pfd%Kva!`5tTm22RYCmkpGk*r8A6Hv~oEk(759m#>%;oaEBn>?!N zBRcL7GTfIM5^>NkmnNbXGy5w0fW`TW%+eRj3utVXuFxXs_6Ac1WLS}>j!e8B5Z3JD z*8?hbQng!Jy<0}Tt8e`uxuA=mDp2e2gz3YUe`SA7`4=<1MASPkf3m%k!4yDsU@G_v zoCI>z2XjF6!U|Y}&L9Nz1ie6S&<89AKY&-@HOL060%mW4HlQu&3_?H`&=t%D^T2*^ z02~5`!4cquM|#enBq#++gEC+chyokHMz9%d0b79?o`Ikzz-)jmC<5$2H_#n?3%&!h z!5lCb+yFPhJ#Zg90GXhEB|P5(2_O+XzN-9p`rtP8zth55`ZewV#quWYj;?l0)ml+I zrEcd$tpQ?`x(RJgYeBXoN0QkDq))X;Oupnmb;&!kW0d{>B=7ofrlTZuoO|2szo4h2 zlcawiw*1fMUH!1nNh6@DEKy%OnnBif(98>^Z!DdhbGeSy&uAmzj2gZYs!9*|@%meem z z3Eb>7R!q46LTAw9#(kAmR)`S4bcTNEZV=wBitgX0A{S1_HgeV(^asjk$5`o~Tab-g z?SE6d5dHUUROy!X=S6*eT_Xg&{eMqE_9SPL>4&ZVfptE#_FvFr(pl2a4_p4Kb$ZKN1TvRPTY< zp^*2Dy0a66mlJX|`G>o+`-3Ij*>^zQ(bz2O;#s+Ld&@?4M(PmtrEY=S-~q@4R1Y43 z2B-@SK_Ac;P~8{+27+Z^IamYMf^}d$cm-aAnwV_m3A{lq-~&d0kzgDc4?YGHz%lSE zaIT3b9Ka2@gAyPNgo79`7z_ciU?bQBZh_n24!8^Mfox!h`4IL%0m_37UZQ)rS0A4e z-?)_={33SwW#6vtTh{zAS1M`#2v5{#{U+f~DpP&EiO#CN$fUeVb&UQXtv^EjLb^`X zKh%6ahtSkLJaHV^FN#|uo-R^ok^zhG<0u96M?u;m|?clqnM*ZVHq|J7_a zsm&DH%l&9GJ-o3VB#_h#Nf&;Y*zPBZ58}iJ(c%OBE|SZ{UX0y0r#W9-(`qhP?U||e zRNuf8jR(~I|E(XI{B5XT^fMq?lboA@UZ5}N2L^&r5C<~AZmk8a}J17Av zfu|2|pZ|5ouRB)!I_uZ*D-u@p|FunkSbTWHfdnMHi=_4bglgui_$u7t(!3C>IOOmZ z2GvYkaY&lMF#Zd1(Pg${T0 zq`pV4&EgeI5?P zUa&76!5CWEvp7U2ZMIEcb~8|VDBI%7b(O41U%vn|z?a}FkPR5*PO>)x6@dq+1bo08 zFb~|jkg?+16`!OG>bBxSvkMy1%f%tIRIN{Xtpc=NTH|x2FGkr4{tIxVC3;g~oJBF# zg7I_rn>Wz1JVv|;o0AnqO8MEVhVoNXka1balVn`PS7XliK(Qe8ABe9i)O`c>JX=-I zr_$uk=td?hp*jECob-4;SO9Dwds{$tzz$Rbl|cD? z`aq91f^VU#(@$!Z(hqsoKb)v)b+3#DkDlRf3V3F~RA zzG0|tIn;efjTp4@s^P9buhI*RYNyoc(KS+a63de0=ztke$zq8OH10rrRiW-1Z~tot zne<;v|4C;TgCD^XuoM(S9ViZ{E>rKfl_!{QW}&2^+03L1kf^&+rdsi_X6mPU;GEZ zRNsJkBm2)=|E{>joO`Qj+&zRhYa@)X%<8Xn>9fr0^*_Y-?{qwk;7em8DtGQngSnBc zodL<4WKFVsPxb$5JCpuv=|9Q4ED-e9506sbQ~8hUXp+B{{K-aVfL*``viAj42Rec7 zpa%#CC&6iO2Al=$@kF-+=m`9_Wv;|cOLA&Gs)T?2=XR*zNh+M3l+xnlvv~YPh$Ng-CYTO z0^7kpAgK%SVl9plA4psz2VKOM1&R;&eFOJza6xh9b7~iE_CBO1`u>k(Mu6yA(YzmF zE)e(p?`Bt%{59>r70I0B{RcP!9)Zqy9vuR@f$pFe=nV#dfglvbf%RY~I1G-0U%)Z& z{Lb?WN4Bn>H+}W=JEP-{^gj|8I9glq{2AVsH|nmmUi`NW$m$#M^a`u&(aP)6*+i;& zFgf+Y_1|Tc-Xg(F8~!UYlq$N1s)_-3i}Ieq!-SWG^`oU-icO2GXvUe6DNB zQBy5JUr(d`CwuJ#nU@9CKy^TMpeFDEbwEAP6f^@tAQ-d-?Ld3b3#)O=Z+qr{+hCl9&8Y>^ z-!ka3`x=&)R)NxEqm6Bu(Eh30OJOXdvh>KKwyS08dtE5SOj17v_*U^gg^I^qh- zg9?D^j0dO(>VqKg6_^En087B*8;{TI-?;G0g&R}%hjj_tf2QqY{!nLULDN>M*3+gw zvo1?##Qk)>HEGZ%FZW3hzxG^Ov8B~^)wHzqT?cXMwcL%h`uf`q{p}H4)F~8?VM++H z^MQ;=enl`z?me~t{{2k)uciN_n@hnm@El|T8`J??Ky|?mH~?4R2Hb%M7y=T(7?2Le zf$`ul_!XQ77l3N*|4~@|Kc;ug?1tRx|BTm0hk^eqZPe96)2k)4rZefTO5=0V<@~T$ z#@YkEB!5KZ&cpp*H?fRKz8ArJs{iu`nDk#u|4Bzl=9j=7a2MPI|AFR#SmO(H13f@b z&*4DK^{2afqemX|F* z^o!S<2&`I@d%ekz{(!OiU7(h#gdqEyO4*Yv-&6g66l&6cE&UgC_aNj>`a2i8`ku0mtg7)$_bz*?{o90R`sq2D*{ z%a6Yt{${wo{8vl3Mg3@-dvG=wpg%7y=mM&&5Z zuJipiQHZLqXh`~Vs;_9!S<%(PEQPnf|CfQvo%?o-xsZ(KiR8RNDaT#-{RK#Df#kui zT9t;LUz>i=F zp!%^KtN>5IQ}7bJ0pNmC0Iv#p@9eQ{JJOr&FxBCu;*MlX660Zl#9dq{I9-SJg z{eREpZ$q*ryGu59Cy>bbgVX<5E&1oLkkC8d{*%n99i=vN8u+l~e^g8U@45cVsed#T zdezCHNZ51mA-1z-%xF%md$ph2Rx<4YEKsV6Cz4E+`7h0R;#E4M0249&`Ym zz|$K~FP{4CDF5$Z#?Kk+GY-!Gbi(k#!}|;$+=(~-=zr1o6I`RGIS;{`08aQ)f|EHb z?Hc{MS65csdR+51#c`UM#{+UowU)6`Vn3>Dc(1O)_ZlcXr5n0#%$|>-4j&?VXG-^G z)oq%$sfj+C8NS(IhN$e!>6QO`m1(q|N*V5z>g>suC7l<`{VN=k+`j=N_gR4CJ{OSO=L3n2 zkTm7Pgch5Alf(y!;)DEkkpwM{hTE6nuQ|;F=L(kFqt~K!xBt~iNFFjbVV=3!%=cXX z?MR*r0O>R7uAsN1qaBrc`dVD5l7lB=mz&~)^WuXO;seRFQAq&8Rg-Bbz6c#MsVIV( z++SvK(p|XBT4p2ca=+FmaRu&1S{*34u;M_=F;)^+91OH{b<#Y?EYDkOo^v``3#V{z zfZLS6=?qqaHjVTAvGX%HYJ8p5PI)nT$S!qKa#&h=SVnrNoTM4dLZ8Wl*&u(JjRQV# zV20ulUVktv!kuwi+>i=Mb=IEF%A6K&z=sedE_?_w(X}#0*|8=&+!=&{a1a3^!5}ac z3x)o3hN}xK)WeLcMUoO#%fCD1+ynFlp@8axApham{~SyM zUx4Z0EATZ~4c36QU>(>5HUl%Lxg0#cd;Q|6>nDCaaN@uY!2R8NVx3gf@A;9m)fU=z z2iIs?uV3iAq*}{Vy#Z>f(AwMZy^sdh%j)F5eV|zg8i*v8~7P)2Rpz{kO3q%Ayq6u$rA(pBgn#X;a?zw zwHQa1qCUDSFe#!2KA1l6tl5+Z`Qc2&wroGEvI=}~*fLG4Nnw_ERPB-AiCNA>GbG)( zCdF_Q0uPd=MQBn=O527!HzZ1nDrrTSJ;`zx*bVl8yIXI2rhxk;0m}3 zu7SV7b#MdR1h>F#@DI2H?t**ZK6n5!!9(x}JO)p|Q}7J@3!a1jfJx;4qcYHtKgr?+ zcnMySTtF7c1`O@D3}7BW&?2Gm~$U zM|IGQB+@q5FGjxFTg|Hj-uEm>{ z!|}uar2V(;SBI(N*>cu)SrMw8ZlDW@W-0iW$O4!*{zb7^7K7tR=Ea8LZy0{V@tefr zxxHw~HQw+S3il!S8-=Tq;o6${vRe4(k2UdquwMt~V&FR&p@t&#SS~cWQXQ8k&W5o8 zI` zRf`bTiM2v7GXVGBtOZzODC z3albEnA8X-!Ddne8>zIKR7HKTPu5ciSHH#l`vb{$;a69ef~>C8-+BA1YXTbSIIdae z8+89%Rn6n?VIED@P}29yX>gDqRx=hAFp3*`Bq=SVPz}ja=4>I~g=(1FJesOup;yCX zuBjf%{pGD;9aKMGR7t9i??*MvZ5|818hRFFqf9UJ6l9|;+$zyM(iW z6{Ph{DPU{zX5u2d8O~BM+NN9IX|R`x*iT@?v7ZFDcrc8+d9AjjGzzCGn{!pY^#SF* z@T=`RedFlO8vS7ye^cY0ib@-UoAR_DiAqbiixRnWbkkj3WvM@ET$L^88%J+Tz6-y) ze!zWHUDb6ktSt3-Bl1*D-|jx@o9DOitEb@@A1R-2UsgWf-r!2lw;yrOw=Z+gw>P+I zJ>Q-ve!i_8!oz}mzCECjn%tEgttT(L(x2^ zV0I48*P-S*6+O)X=wl}1AOFBIMp;eYwEA6q?{i%ERrJ4tw0@y)iNM-pq~3*fX6<0< zq<2B-20TCCi0*wFcXMgadyy+sRm<@XXI>gwaa9Y4MO07Pcweeo?sHZ6RqaYaS~V11kZYBTxhHl&Nc(NeY5(F7_?{U*Ro0Gz?QXj-HAr1|t`sOx&KhOtHsdHDY z-j-oP-f~m;RqJU%TC0I?iH;}2R?#e+AdFsVKOBPwFYLwP9NDf~`0I(Ws4>q>cD)CA zD*S3ztstwJr${8p%C|+5G42}*;_)vOO{Vs{A~afzLYLf|HNh`ER7*vbXv79%KNJ-r z4r5DN21RqSfA0c~t)H&fc+7;?cziAS*LYmZ((O%OOL~3BwXEiiO_ViOun@hwqxPm5 z{Gx2UC1h0a#Z>PF83?|cM(Xn+cr!%zZl=0`3d0mEYD57Qf@VeIUZPW}hl3TbeRa!_ z_BmLQ_SG$uqxPx2X$CJ<5A}80!5h#%wYLHe-f)?#laY(mlX4eOu!h?>)BBKU_e}3Y z@^5?!Z*soV??W1%xFCLy(eO-7?e`)19x~rk7KfvMhGs#(5Ba~$YvJ3K54>9Pub6!p z)iUpSE&OWv0Z(tEB?0Koaq%s7eUpcUS9jlz_aY5jPGQDqPA$Zn=ezK$>pT5kWPXTE z`(-VmYQ7yWr2Q}QXsU)eK8VycNYFjw$5`v3`FgHU4UMyq1^r%RepEy1tVmx$Hk?OO zH7xXMD4mKylP_w6x97dc{HTVx&12zL!w-1QIp2qripca{q@njfP1Umyt>l}(BB1%) z%=Ah`elNiH0gu3SRZp77WO~8O*ca;x-+`h(Z{DKGt{TlDvl=s4~ zwuWQWer=2%f4Lh* z4l81O5W|GLy}6@#x6||s^=}ic^ z`V9wD;b^@BrY@Y4#p$a;5g1U>X3hU7|6VSBx%d(pEn;DKE5^(-X<6fS=C+v>g3KI$ zZ0V~|MKbXnJ7(S#31AkxUGdjahLvtuHcnWxaeL{E`s+;taL0v~aEs*5w!=OxUZlWc z9JDw)tzyGi@k|OF+xQS>mD#fx!nFuI{QGyMn)M1U{c%9|r{`S{Wix-Ar#O$%2V_`X z>jlAOGHc?T)|J_(voEvaZGu||GZ|iQiJ+3m-o+fOSzmTYE~~)I9At6_S@t=6eceJX zHs znOtsWF1J7`;W8R-%-q4kvAj=HOQ+7ERuw*S_8m9mwZE_5xOwaLKMx;0e)9C$zt8`BA!BkrJNT=W9|z>e%-mdVZbkW# znGK`NI+$CO_px+r+Sw}fBc}?!JPU%$Gx(z?;SDJ_N1F_v7zV2z4+sxZ?Blnt&)~5-C-3neChtbo-7!2#6S4y>@OP6 z9z1K)%qmT5m-_GS-$4`i+_+VD__J3V!&?9Sx&QRIABI-^y5ClpE}gghxgh%FuX`GN z(q#CKgI`ZuaPC;o7_aG_7j5qG#na$Xvgh|!1;o9K3EKQ`uhGv=J*YjS@8ok2Pu<@+ zKXGjIZ`myH&gxggve}eHFN4Rvu5|PBjB4`S zDVv=>HE8bCkHwds^~+|*1MXzAGTH3v(w7~UAjs!qGpl5?wTtcr%zrJvlFfF_&pPl~ z1D2QgeqS=M_&N=@7At*)o!I(^#?y3?l*bxCL~93ZvKnEFCAI=S6r8@rkk5QJ)H4% zvr?y*jE2jKjxTPzJ^9J4#MEj1YXrQ^YTAAN(?7g#_jVk+-2cX^l|Qd(bN^tOYuU{G z{PW&d|ML8Pe9#=fa(`gdgtj4nDf^>Z%c^=QIjP8(s4E{*RL~E`?op?mQqkt!a>R zCz(E4T}pXfExJ)vd6PcbY+7{2o$X^^6kl=l_27AHiyR)*B4)?ee?7Zaf458N5&J*= z>|S!ovi}^kYxIB1H(pz?ZC1AdA?COLWp?vxK78JN*yM)Y77q{Kd#dF9Wusj-ezGkg zZSu8MR@Y{*e^-C^G@G64)AwX*_cfVrAD_J^YvA!+|6Y;hEY$4PBI zn*DFb2G0*>vvRW%UQTXmW|ggR{zCKeA@v&euz5J?s@tTUWrnwW*=2vpGK z1~fZ)$Lvs%@Wey$O(yRA%_j2yKDlyi)rD8n<}b@^6dRFs>|&FXSst(aHlExbG;=^s-eV4lLO+J3=hw*zx52=+^X2B23?@nFbamLISr(b&S4p{jjn|wzW=SPDw%Z_Wjb#?!iLn6&SJ9g@$D(Q>_i(q}gQCB>-tPD9j{{!ZZDuxYS?%z>O*Wle@#Ek-KfVgg zoW3q3@kF1M)3;YFm$vAm$Hl&1m2tOSl;@wR_ePJo+IW4t7ptcHl6i5*lIOGAZ2Bu@ z#g_YbSA`dIUOQ)Exf8d0r(XBJdiUSDy+3j8+{%oz`ega5-m1#(b#7a_-I$bSW4>Ej zJ8fQ(Dn6qhHCuKdu{A5Vw|4(Bu76qk23PtzaoE7j-riyhgqd{fT=hq&eOuTDOA9h-cx*O7Bmw>`g^ zIsVzmA)n57xz(k8?Dczphi^HsFTDEDhr4U9zmhSvvH8Q#m(J=w?&?VUW>1f=Yi?6t zk<{wi=~LehpY*Kx^VV19I^OC2=cP6tgszL_r4Cwc%5ACh4t!V z>$2H@Wv?|VpUoC8y6rRnQMK>0s*SxJwCUxN+x=}`CS5wL`Wq0m9%4Yu_8GCiWtj1$jXI{URdTD*vA>O+ZiX6DL>Zd40_2A~k zYCm7?{CZPErz;O^Z_O+HWsBcyrrel$HFf$=3#|K^x08Rqqy5N9caLT>5AQvfp8j*` zh0mQMV-v>yCwtx}Yv=tYPpt1`*jHXZ^vjEjUbh?U{cP;Zl&8}sWV2$UszqHXXaCRf z;mK`3?UeP~!~q+ATKC`VsRLavocdyH@654h*wkaW zN7TVlEjLUX@gn@n|7EjJ>{;Gs#=ReY8?|A_^N%u%1h4%)D&xeHwlN>4 zl}#RX;_H{cbZ8vr+xWZvNduf;#bvg=x_P3P|7QdCZ}V%{>C--|hMn6y$f``E(d+xw zoi@gKxc9XSJEtujoP42gpWUT)EI!$zRJWP!7vKE+WpLw(TYJ2oyt71H#emDd$zRtV z`+U}o?;F+_bHbs1^>2o4epU8|)*Vhx>0WQZ>0t*pci)z^`Etzt7SERdc>k1D_0NA= z*M70IZRU3MMce6~u_Ix}qUHkk6{#ncl{ zEu99O{o~9J|9;)faYFqF=gvWC2X+h1TC2S^J|An_JNVa&RpliH#trtXd7{-9GxxMC zxAx^=tNaN^7{#aH{BC*AKhuE`%?-tAH6^Q*sKjh?&N{G0V7yM5O9*n;WTXEyct zWAu%?P0qN)U#ifq*yJYm8wO12@3!T5>Xu~2`S)QM5PbGN?eaXM;Ao9~xJjyd9dxy13(V``uJ_~2iAt5~1e z|77s3DPJvW)c@w;x=rL+4PW)&@kztcD|SqrUpoEEhR4@*4EbXJ?#Aik2DE+U`+Ugv zqr5X$2DnbLtk`8+ufErBj=6s^>%z7kO_$6_SUs`BU*83mo&R(1j9|ZVJ)DX~M!G+n zvd+2c(mQ`XzBHwz<)WYZ_dL9$cd3s{$Gfkp_jlO(MYFHAYqi!Rr24{7SWBB-2QzB_ zlhWg0*p{KSABOA?-f*Q_?^mnNd1N#{xA(@nMNK=UT=UqpE#sfGVe=n)Z#z6~cxcx6 ztr=&(+>@nvIDb#u8unFMZ~Jp&`82yf_L?_6&n7qqUfpqW%9Et2JJTXl2b}8=m-6Md zi#O}|xvuSe{ng%{`=R3Dq<#%sDi{JbI?GrMw#+_2cS z_CRC#`mX^u zb}n1Eqgqt$#XD{V{hV-g*_6HeW6wCZygxqpqhFis-PktB<=Rh0(-%&umfktYnTh#q z&zHBV|8#xn&px3K*L54Qxz**^`p%wZc74C3^gnK|Zu+8gd1y#)my*?2+_#m*Z>&`3 zK6-H>s@|;7s}=pqv(FsVSRE!<@`>s-%GEVoo$!PopQt`>O*5(1aI0*%I?*Sp&szs{ zFM>~02Q#_9%;{t;jPA1e5uWgy&aC+{pT>FK-T4_Dg_Ut?oHS!{{E^X$;rK%K7_I32 zPg-JVj0m_LTX`@GeTF}S{AEY;Gb2`CZOxa=$S5<)&wb}6GwU=mBmHoAnzC5#xbsq( ziN(~JERB=O9e0w-Ot~NxP9%m!peZszByP{(!V5w>Mr}bTrEdCBm%v1``pglxsOB)- zJX4)k@2O6ic1$HufF;lY_e39No3ReeP8EwKjuNn}S{yeCjxi^=$UWpvi>oqcP~Afo z>LF*&ta%$(HlUTvJg$|Ebuvh4WoO=<$p+%?7pBeG!&gn468LMwTH!WsC~mFNTlY~+ zf#up5{L7eaWmY6u#+(*sBIJfFurhODwXMfBupZaEjXUeu#*B3a(YUAFfthjPcHqKo z?(vDvaDBOO%@D3k8m_FUGF&0d?o2L9r@rv~5MFU6M|fs@c!!Wivyv1RWnKtOD1cOJ z)}NUNQvUmM>4bM|+WGg#StsbdrH9P6vRoasoRy)l>*x)hbz&A=_?--fUmM{&GYh2K zTv`t1#W<;n63jxFB^P3d!4T_kAzC6t3u%ZJj!cXbDXDqpwY8Jl+5*27t6JY2A?Y$XlV%9T>8Q)V_?xQ1m`p9|Lp;aW?>wN}f_ zQD?eau%>~JvcJb;7CYrFZpK`36v=&)I~5a6Q=k)_pdqxBAuVngin-6xI2Q~(r0J-% zb!RbwkF(d~*N%EQ+-8R_G=ySx3tAXSp`o=3Mh(5&Gr6)yWFhR>%44Z(#869%Ae5?X zNZ^y~-S|a?QEpaTSoGi}29IPYelw+g2xi>_7qW*)nc7}BaOsRiDiW{+VQ^*PsFn!2*Hjut}bg<-7YaYou#utR+%kiGFhOgOdPpz5)dD)Tf{&53E@hKLZS}@ z(ECELMXXhI8EeDJL28b&HlmbRsw@rpARTic%VmGSnwgz&OsFU`Bg>_&1O7~buqw#> zC1FwN^XZ_l?9pCx0c~+eL_j#>#j2q!d}LlCUqv`MMj@Rfk5t&uFzl0mhTN55GS*Cn zvXgNq@W)<9p1Z;aeYb-I;>>(J7~~{UE|gsbgky$ZbvRb6Iah0F>N3?Cdj94D!#W&> zbvWa!pD2iW%nA85!`I~PRVlGRUFwKXcU^g+*q** z=iwWA2>N5+iUp8Kb7t`8V!%JyTSw*&|662g|662Myp4hX0HllJ56~IEKj*&${C{Pp z_WzZcIjo)|{J0tLOE%Mym4x3!G<8DS6Xk+mcLRROIy$ma@Y~K@?YAACS@H3fFyNQ0 zpd%{{zf~>NeydsteoGqgOSaAtwW`WWZDi?eck@1P;qhC{*RtgrPrEXczZ93F zS&}F&CoB&@TBsS0Q4xvtSEzJD~*ss%)&$= z*-Kg>1r{xgM~&e>?n13zC5UvNnZtyXY)W8%><`4g8}x+wd*f8YLCsq(}9K=s~Gld1fBpiYbLAYr$-hVl%Y8YP)BpO5<>Z zMLknHR>fcmc7WE%*myJanPs?~+w5RD`Bg;tyoyWF4s9zZk>P?wic4y59o7x)$aJ$h zqH?5u4K1)v64z=&%@U*OUP?RGAGukGvQg`(oksarWjzo^7^{X<+Oq1f$`Pn^5vn?; zF6j;|3aMC2xl-ndY9?w6Ymb;HKYV(IAw~Se3~JTfAvtGAPR=@k&Y*uA3l@rVA*>fl zX^&Zmq?B54wT#+Dp`6-t?H0AwHJN7%g{=Jn%p9RRKUM@3n0 zlsSFZ_b}>UCj(M+ z)K_jy!Ht7kp$hTiV6j~s#5zOwL*#=*X(^(keO4fk4ECxv4S`Eusvq z3)=lKrLEx8O#NT#DY+vCOi}|-Q!byF6Ni2-SvQ8B8H4qM)`Lo*GN=Nof|`Jqv-bkt zKn`Wj#)e(kK4FiJXrl@(Jxga$R2paL47IP)Yv~N7QF@lnSZJN4GnQIs>5P@uSvo`c zmWE4rZ^#Zy&)VP&jTxn9={mA$(zA3Og(5vmF;OVev*f#|)>%4(IeQw{(ixJEGz2>1 z0JOLKkSmQ1xQ%~aVNDWZ)+7;TP2n?ZDsg5_CCsd;M42_^lvz_=nKhLVv!)VZ)|~aX zrjlXSltX4sIbzn717^+F9op5EZmM5YXUI*Oe@csXo#C(3yp~c=NJ9{6tMn``Q{NV# z1J$N0eI*4~z2&6NALRw*qM-Z;aaY7XjfalliO*xHW+%XbzgW;TLoOy+I$a3e<%$tOq^?mbk5J1$u*QfKE5-0uF)0pmZt5HiIpo z2n^_KFb6yUNo5#I1_wZJS;ks|S)f@t#0y#gGX-ihr~p1G&)7sT9n1yuz(df#0%HTf zI^d0pQww|y+&oYpzz}c;+y(bQHn6XR$7NtcWyback1CKq@COY+Q_u|b1_Ob6RcJ{y zqz9A*9-v5dSUXS|)CA>gAf3P$)B`1IqBuZxPzyMCqAdg!KviJl1z7_Hs0^IE(bjO8T1D$!B1d2*a!XqC%|3s2z2&??tt!KAgJMw zbc1G~9cWM+c?YdQCs45t@(FxEJy4`B@(Ub*8@LEAft%ni*jx{C1_!|}U~YZL2+Ri? z!G-|*f?ePja11CKFt!XV2d}}xhKwx&G#U8tKsnF>bOfD1XAlO$K?H~dgTPQQ z46Fwmz(%kMYzAAvRT-1;2n};8*Y) zI1YXXe}EI|uxC*X;zrl5I1Kb3+z-{mkxC8Ej zd*D8J05ZWt@CZBxPry^~4Ezh8ga5z_@DjWNuR#{b1~kx-0dw#z4(p(9b6Yz863We* z$rLg@ZsZTIUGZBwlwGv({$xrw{G_WLrT(aO5w>(LE$T4EZm6SlnJPYV6TB+&?Dn0m zFwNQ$>ZLvB)APX6@Sax2=qHOWt@tLe)6$sKC;8H{%`RGx-x z0dHUAd}7k^Lnt??KN=Man`U28>L%4Aa)W)*Stq1!(mW{Lbn2MWEs)Zq+2$zSxTG%7 zXs4BKoL$niXJUVb!c=hME49s1`Wr%{Rb&>iL*rc>JHDC6VWR6}XW zL*8F0^R734hQrjEP9g7k43oydT4nu)VHS2e^QwP_{PFtE6+{mG3Aq9#sM@4qirvyR z+5mFXr|(iXslF@Sbn3g(Es&C0+R zo3za#H-xXV%`x6hT0fQkbkP;G^)JBdMFTJe6)bWhC`yD89lDQz{2aCs1w%-2!oust=9* zbii*`X_MiibVEsswzXFDtX^>A{G_X#-x+^~@?gk~#^DZ=lT)6og`sxJvbCi@BQ*D%YshhMs^Wc_a9;9Kal439q z`t;#YMd$+sp*w#jH&eOrb~Rm9&rEf~R3}Vz!lVym5KOk<1GNPte3})BX}OX)^zZV# zd0~EhVb6#EU(J2b%iMO&IqmP#Ja%EedSTB`H)bxnp}FQXk9ijKO!qwIbSqmX(=(4b z-HQCF`}X2_%z{7V=r|qM5!{w;HBvNwrn}vw=lsUISt#uuxpfAX;FpmLtv+wc*k^cm z;By2!4SXTPA9M1#z-r`SR?AB14`;DxJI%kNZK0N12;HONHf?{MRc=TN!W5^aqsnc8 z;j|!sLRu&fZAAVk?}8hpLYx*FM+t7^ua(-LOzfue$LC!}>9iA-S$UDasZDj18J~Aq znufn}Ir$UC=d3$E-Q~i^$CanppC~>no#_1)7@fpe=7hh@J@#R>aVt?ZJbf%NfA18;Zdg3!wo>VS^KdOTYb$v0EKdycX z{-|Dy>SvDm6Z{z!A1?>4JU#T}PiMJ^?f5^C&hNd z`o1!w1Nm0?o)>KgP%SJ1}WWPS13 z25PoP@W<6_g_U+%gfRKEloaJ%od?5iI>S`PN97VM3R5o1AGzs{5BbyZC(Fs7D84p& z;?tQ_7yrbYtmF(L@Vn&F4?-PaL04f1>z8^u)I!hxo+) z#PR9($ID%uPU)lKRx3y z-DO5arYtkDKcoADNT+z5Q=Zd4K1`i562&L>mz(&+N3=p%W8{Y!1T*UrlBDqtUX{ALJpLm=j9*^lvCnpI$KCwS>d^-J!;uDV_#PLb{JsRU9 zG#LWPn=F+e8iZcaSk7!SpS6akzs#^$44ah zyo_a}vd20wcniHwajYTZfOTA) zux5%2W24=$&XqeTf%T_KGB&jo)@dn?^_j|IeIo_dzQS8Y^Q&R~8LS;t32omz+}E$* z$5-P^jIn;LaKEcH^3aA~%ML-Y z8URZZackHiIILNSbbZ`5BDN)fyPP#)!60)^vH8*;CMwVTl4FN5;-LqT;! znePLgQSLQRXbn*I6;bv@P z7PJE$Ku6FSgn%xfE9eG#fS#Zi=neXUexN@X075}Hhy;T`G#CtqfH)8j62V6x8Ki)r zU>HaPBf)4e2Bd>=;A1cWd;%td{{xf36fhNh20jPV0M!*UlucFa(pqq*K@B;-CfqXo zx|pLpz@EeM{N^8Bn21AOXKBCT!0T%$R;no}VcQc^%+j^oN9|W{^TL;wV)qvJ* ztAl#|4WKpKilKfF2DDz=4ba>LVSvM+8tVIBzybBWF`)I?egG>0t<&}#_`CCKwT;K` zWI$`S{RQOE4_ddaGw2Cu{kFy66`(cT+JMf0)^eK*_5)ha%?bKc641JCgTMwrYrC02 z$7}$t@rG}ivTp&c^L7K=1GL^-{W8#hKx@A30Q&%~{Z_mz@&#!9x9Q+pKl!_;v8cHQ*;ususVdTLyl8eE9X;&fvGbFVf%#+W@Nh^Xsx5!EgQAu&-bj zC=Yu>>#;2bHg);6*v8@aJfL;hde%dJ0Ik8+pgwFHXc>U~gEfHGU2|)IwdDY);j00%kJUSWpg7U&pCAWWUm>%>TD{Ch$>IcN~AaxgjRY9Z+Do&x9o0RUupwCxGJVp;n9aLcx0UkSbbfRn&@NwUxHkYFpcQvAfOwY$>*0h`)1z%{ojAy@qh3A=RdF1UR%|nS4aKtww3?Ts(Ft4>AY+F{P!kP zR|v1sc>pv+OJ7_;INo?_stNU}cbX}mdVl?zQ&Og0H2(bU>#HxV9P#9@YRzZmT;Ong zi1rTL>y5p5?k8_9UqAhwzrXzEj`DwZpH^#f^XlKbIB;)#{3FkPdj6$p&rki!{Mc## zn$c@Vtr>h;{d;pvj}Pd+$w%>3rmCvSd_vX7wYaw?mngqUtVtxK{HA}bT-V0b(9Q{C zYv@aePpT1t!s@ibhqDT+Cl+2ly|7|VA)hO<(ize)J}H5>W&@!wgy3>0M~d6u{G5oj@4 zXf)Y`IvZZ^+F0VpaCMZ0&}$>DRAb0Ze zy5DPgm@VU)yvhy-ehN7j$cyY0An&omfxO0!1o9T!2gpn8i9p_AX99VJEdlZd`%Umm zp8j?q@2xw5ytY09%ayupHX%x zC}31A0h%d{06lv$%7APz1|%{Hrhpf~Ti_EA*Vop3Povq%%V~EY@235LyqXRG@@Co- z$ct$gAn&EAKwe7+0eLGO4dkVC7RY4e8U^H4bOMk!(Lq37M14TsL*D`N8u|=4`*<`# zFrQIpDOd$A)OijX7PvZqb%esT0bEbG9&7+Nf}6oD!12f_PnLTA3Hb2-Y9N+!#L~X) zQ0F$hgj7h5pYl9^0h%wf;Q`tQ&yU9#v^14xW@+MTH`2V-ZgK+cMjE%;jkImG8)@2V zH`1~l@5*X7@~EtKBTvd|H`1!*4@#bs9k0pqmMjf>4|pFu?z1&(wJT}WYFE;z)vlyX zt6fQxR=biGEuTR0bSy8&rvb;qvE$v?@oemPHFi82JKl^PPsWZHW5#l39p)bUE} zcqDeb5zCLr0ibtCd-X%R>Ti1?mIq>KplW~8IMx2-Sy=5)9);EZq-Co8$%C-kpF9Vv z{YkS_`;(_&wLf_X);qoO3@op}@&GLFzxiM&ZE{AST}rD|yOc($b}7%kYM0U^)h?w) z>ito9@Rj#oX^f7yUdKDHJo8E$bUg7MYMs-PLJH^!3W56VbHG(#9e4=H%Wimkj-zI_ z!fE{tdjmJw)b$XD`jo<@A30w;k2dBz`EecQUDLjMZEEyM7{mdCczY;#HeBrToqBa_yq|o648;K6RHHFMp~$ZuPx`AAj2Ins4o_ zZ@qBLL)C8AJmk~GSC`pRMR0UVV?3>Xk*^}HKhVkg{);z$5x?{KJ!`s$&&PO7*+6s2 zQr&!Mu2_Gh#v*p5V(h~q*3}}mF)m1KV;sab#@WQ2PxQou6D)%$+_@06xm(Gnu>#z! zOoZS{K8z*q;@~bWoY;>ea%U6EX&WS#(-vYmZJSY4UrLaeF9l-0lx7xnk1t4Yj}L-- ze9b88<_#>kbBAUWwW@QFSXF0;RdsG=QD=7z5}e%?g0s6eUewkKoJxfa%B{5m zA40bj-4%FDZ1Aa$iKR7+iETz(O-u+9OH6=RVnQ?9>h7ce|#Gv9+lXTbtU_63lH6!QA%EC~8`#AhEPg5KHUSjH15VB}nYu zE)aXSOEZi5XtyB2N4r7r(Qb_v)n1Bm#{EE;X4<7zFXcOCfkAqy2VzV4mf89P%*gma zm91+8G>%Xb^yjJ7n@KtQ0K*e0X4g*<6UZT$l(iyK+t1jInzC&_vpp-1U_LR- z`*eh*l9H22Dk(Ra`2U!mOi`J(Fln0!KJk0B{z>ZO+27oKko zsePobA+_)GHVsn8)~CQEG@L>eokP`UjJb3QRi80C4a;8?;=-sfcMU7Q5525rA4&@P zSj|4>u@R`mhf_)orz8z8A4<~f^7rvb4nirR0kw8vd}YSBtA26sqUy}}e8TpPQcDa_ z?82SlN2;ZPy4OYftLZ_NHmJyk)8O~P$>?i!LEY110ve~p5I7utxK+7sRj!*fW%{yp z6V+R{=G6V5vqLZ6U1b%952P&uVY9^aK&MgH*qzqV<{-1gx_PFT^uZq8Ng51o8txOr zP#Ph9doZnYV$*O}r$cFk^zcs7U})2Dp9Y4~2AAYY{733p$(!3=J7lMbsBoUFA zdlfwR>Wd38yQuDUQ6EXRKad=0^~HstT~zmq88QOaJ=fq^7?GHJ4L!`Fx>wa^6xF@n zMl34J`_}p&LGaMJUhoGeS_2IIt+m9^-&%JJ{jK#q{T}-3ij*Ywx3#7hdR=RSp})1J z8Two6kb@^WLhxlWdM3PybEF+l%gJZ$?ifRG<9rq|$!>_P<&E9SLf?`G^<)TLN)PP$EN77i2j(75r%{n<+j99Bx@R!8p- zMW0P{F57w4@kYFr;<G4B`LQS|H7Ar*>sI26ZqIqGU1 zrK`A46H`qV{|aFuwjt<_f;e`}&Y%vvX{+`6xcs zoRyktZl9fMhURxLy#{nNedlyCQw!6~(4?*=@vLsfH=?`QH?6xlzH<+gGP#FI%hSny6YZ)Hz2wWGgo&TBi9ucDr8 zemY~0*?-zRlkGXhaNP z<9f5jcY_&Nc!OELaD!Rh;YKs~)SJ!C3vV+c7vEu$I^Ai0HsUVxPX13!M!S2>dp++n zJLlhL#>GBhvXUM!sqG&$?~Z%W^iSVnhI$?~S9E{OJk#c9Cb`cO=I&A3%*4gpOhV?9 zrtJk!nV0gnoAh>1n|J2!FmL5OZ&Lg_&DGsrGLNl&$-J@Pcjk2eE2h(sUFPovubTV& zyk;_Hzh+(>{d@C|`EQtA)897Fc6`t59QB@ASoof~Z^1v!X`q*i`xKJW6WDX-jTR+WFQs&vpV6StJF5<7e9(ex$aFZ1ie+QYvJ+ze!O`T;nU zFAZxiKhoEPqxDO|(fIY?rhYM4HV94mI`Gvww(ZdMgd2ctg*JlQfMbV{Hv#)45dH;V z$1Y(F*R}xJBn0frtg%Jbj}C5OU~hy2_zrWkke0Q_5>OMZAjR=e3_A^7CU>T}E7i^{UQD z=y*+BoX6`)i1!BeV8m_RQKi$lyu7oVm%PfX7rTb{w{mYAAM4c-G4~0){#8m&%b+lR zq?INiCduoK^TtL@Gl@J_Tj`4U?{JOj?ID*KRW05soeB_oG$`EyxLm=jYfA#5<{BgW zD~XpfBH~!9j0Hr5NZ6wrkZ=JnLD>=|$0kZ9muInz7o&p8vgR^56*@M7>J_f(xG*3_obd11`?HZx`x zYc7ZcO#*dbR~mAtQq|UKu}DXETF?w?W+gS#&)G!&&$Vi)U02ofsMZ%z+bgVl@@O}@ zyMk&T`I>0Aqi!#w|52T9H2|5uWgXpL(HCwZvAlYtfjttu1YjR25fmflel}i;H=4A z$#11x5AR`3H69hAXE`gC)7^2wn|lyN<#HI3~G8k z#9U4&bIWyv>M3s`)WYPC2$jF83a=R$KPZ_|T3O_uG0{J_sQjFwa{rv7Wkm%QMgF|9 z$|7~5x=%FR;yV&QVcFuM^2##*=xWyO{LS;fVrg+=}aW#vnV&jIFy^7)d9b^h!r9}aqIyQjf<$CK~N z{o{6zWR3_d*{g%pZ*`ptTaQ)=v`U~=0<98gl|ZWmS|!jbfmR8$N}yE&trBRJK&S*F z&Hpv8_U?Lq*G(D6`mVX2`Tx+p_fIA+E-X%Sbj{;6U)Nl8rP6`5Ky!Aj4QMT3E6|e0 z&w{wC1e{%s(eo__+-{upT9-GfX--pP4&j zTHe>^T5*!W1me$w#pu0lP7p5O$qlm)9wo>T>Xx`y#r!SdHRUz@=lfIye)5TT+Os|S*qbF9 zJu+yMMT|8K$Dg`;hS81-7=6y>e+hSMOe#X#PEuP`{Z5qaw z&TKYl=5n^ux<4H+qHC@5LMUW#wjBSXS)66^KOJ9A8PFMS`IE|kmaaFfFO#9DGH(NJ zb^8qBqoK^p*)m^ADat7GHv{F&!e^DFFcnO3Ep5Z{7UKt0<@`m2@-B>$@)l55)e!rM z>Z$6P9$Hx!vYoE7J|3a01yNGgnLN?C_)ncd2@5TKtcdzw$*&PsZO)*t%j8#P6QA)y zJgKSNkF=n2YYVqLV1{tG<<4dHp>k`!qELrIM}O9SU^KMlbI@Qa@m;5$vCPuXEBK|_ zE-C2A+h#7R{qxzHo@e!H*;ZXppE#CywTOnjTf_F=7XQ1F!Gi%=5Y&@NwDfN!^lqy0 z%`NXB)7vWF{SnGrN&Jzn1JkVbnMrHS;x8NBKGGQGJh9NxtZsZvx1N7tz+kD;>gVhF zeD#Mbz#40uw0i@4w2M?5!gZrFn2D+`+!H}I9PMb?wk(W51U zTU)RU3aJIl`K#+EhEsOc1C6bX%b+*?x@2%u3zmU2juLD3RUT*yjtmqwE`zoh;z=vdQJ7qsRyT$*`b#d?MUcxf;=jB;LdM~mQ5C{NB;7;n z#+rYqbre$*N&<2S)iFZpMD8mF^8EP z^;~N#GMbgK_b_V)Vz2(E6T6sMNW=RwxKkrs!@0$fz`FVmxTZ4dQ0UCJzKs2fvDRu) zWL_@|@EF~^cDLksNmTKwnT?xVZC@p@hXq?2isr!b_?Lu*|Rz~YItpY ze{F3G;MLh5aQ3=kxnBSJMeh$d{k?R&XzK4rz)$#`-r-eiel3Mp>4?$9t9yTM@1>Wv z2wv@d%i^fwRqKOp_0{IJuto5CoK;Wrql#Cpzq-lQ=2h$5(bKjL&g(a#jMw1@k?VpM z!0X_E-Zw9bcpZb@=O$N&*OOZSuZ|5%UKH_~O)nrDyl{QM;Z-i9qNN{*%&XmJpgC5>x-VJICe~YcF2{VeBzJvnp?Ek zF-f;{dj`?6&wr%tm^6mEmG`S?$CMeNtY39ICiNd~&o~;(eI)Ie21h9O|FazvuJK&! zLbUX6N6L<=f^Vd&&i9Q_-ZP0m(qmYt9aA>85wf~%xE~b0Z=@Pu-)5=KLg&!-lg{An zB9*yUgfjoX+2J_$T6+7)t^d>}tG&TfzfW@E?ECEHJ7?c2wpQS*3<=H@e#d0A1y9}%ZtANIs z3ZOa5YH$u%1J;6Xf^UIy!Fk|(@NIAbr~=;s-vt+fYH$&_7+eA_1>Xagf$xLM!4JR> z!4=?2Z~*_TR})?X)`4rmb>Moi9^3#nfE&S0;AU_OxD{*!w}IQi9pFdcPH-3aG1vs| z20sD!fP2Ax;C}D`*bE*74}mRUD|i_E6g&bR1&@Kp!Oy_Y!7sos!4qH`_!W2(JO#Fc zr@=Ge*Wg*O1N;X37CZ-@2QPq~KxKc4@MZ8j@Cw)kUInj#-Qacbd+-K$6Z`@E5xfQV zfIophgTH{c!C%2U;BVkv@E-U(_y_nWcpv-={2SDO55R}uBk(c!5BM+m1bhnif_>mK z@HyBI4uD!9rx70D1u-BN#DRE_0QkI-Ndj#^TaXNn0k{`8cW&=>Rr{ei9zBpd_=gCSrjNCz2U7?2-XeFQ2S z3Ge3I8nxXn&}k{#IpHz%e%F2A*T$gwJLVKP0S zEXoh}XhZFF@>kdtI#+Si`{&trX3=XG&;!e!{cw&H@~1eKXP>6#|04JAP)EqI0O^<0 z^G_z!3aDJ;>p3*_=tlmMcpPYI{-QltjgKRakxRMC{l1?4G;%Mtcv6h>Mx=GC>%W1A zA^)Dr+GmrCYf$n-<7W){$3jYF*Wt=!SmXfmpFF{i^f2=4jjol9=!>n9Htgm`ezr$@ zvU9foH*$OM@~Yrj^G^;ZeKZ8!2bZUDg%4~ diff --git a/org.glite.deployment.lb/doc/release_notes/release_notes.html b/org.glite.deployment.lb/doc/release_notes/release_notes.html deleted file mode 100644 index 1db7585..0000000 --- a/org.glite.deployment.lb/doc/release_notes/release_notes.html +++ /dev/null @@ -1,1720 +0,0 @@ - - - - - -gLite LB Server Release Notes - - - - - - - - - - - diff --git a/org.glite.deployment.lb/doc/release_notes/release_notes.pdf b/org.glite.deployment.lb/doc/release_notes/release_notes.pdf deleted file mode 100644 index 353c3a28a37959364d92fe9221a4253f160322af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 34870 zcmc$`1z1(v`Y*ib?(T(j*P=^6x=WHa9O9 zke!25mqpIf*3{6^(!c-AQnX+J1dJCI03}NAtZ!i zYHI@i1`6<>ekh1;j;3Z0EwOW=AhQ1av2g((VnEwpX>6<>r195TuEsckr^Iy~0*?9lQw5_62x4bZax{H$j~{M!78N@?XCNDxPM`{l zw5^#P7;it~PqYO%4MD7CW~`j-Jgg?Brfj_2JiH(?P9q}|ZdNlxRx^;001qz@hpCYn zSi&ZzCZ-@`BQ72@V{UE`E2p6$xP-BgE*PMQPR@po&Od<2ih@W*C9Wueg7_D>f)NTP z`KK+&ncA8=TL9TOK`auM*3PDmEE3j+&ZbXHjqOZK!Ir?r&CQ|;WMcyf2{}1Cni|@G zQ9f;CU|;~7P7M1L7WUR0`6V)Zb5}DYwyELb``-mBPD;FH1ZZ@T;yXoy zr*vxFYTMK9Yc=RIl;LBZ@8Di#F*KWK!C=xw`XIG9S2yl0pkIov}}j=h|Zy) zD=8vKs{L<-NoyEGWwa3!()nr{+saMCJ;2^XuU57TGBN&IJqR{{2tOX9pwnr|87&Y@JPQot?DrQ2|r|a)6ESK6q#V$nj7S$nl_IAjf_0 z1I~NUJrH#N5f$AZMBFzHroa*Wsb9pY*g1oB0AvM|VPa`0YUieXUx5>hW*!i`E{m9> zo&DbuRZN}iTpW$T9I}JK{1=k%-+zce%+A`*QPtki*c1#34Q5hImqpyoSyJ_$H*gh6RdAJ`r2Zz~`^J9|`=FwGx>&?*!DzI! zHD}SVv=y;+vi##+)X>TFp@f>Hjj5A@sjG^ejiIfQDw8x=v6ja2YG6=1IysA37&-zu z*jeNZf5zF^xL8zOjGXU5pyude`bSewOr4A!E$yA{9D(c)Dg!rZ;%woh&3@lC{oB8P zpUd%pihr%i{UGBXssCK!Uu*pS&I#^FS%DxB2zVd6581izfyMeqcptyd`%#h=jJtc? zfJ@zX5kD>CLAU?Cq($wlP5wJM|L70@$8x^s^%rkH`1{4>?=t#75&!+`57Or3dXV<- z-~J(aPH@gID(*|(%NwlM-=%$TKL53}|Gl8u+5R)2AMEq5fChm_>tBR(g9XdR^Cxrn zpuPv^efY0JzpwM}o*yCs=X2fjd@l}G;632ExVRslhd9`?xfj|GL-=I^T;Nn5u;_lI z{>s0vcOSpcz0bLScptv{C#}Dr{-CCxMsZKygEGK8{G#=qwqLy5hxa`H%KH`GQ**Dt zU*+!8@7w&D|GQG}JHr3}N)>UmG_+>=4~E10AN9#`&%VkZ`UG?Gr#ya0@Xz;OUBd%V z@4@;H&+nyw#ed2BS9q@rurwapx|h#S&EET|KXe05`&s6f#(!$0ZhsG1 zAGH08>R;hK0)9O|I<@;c_xid|eW2@i?c9%TVC`tLNQ;Txj}#`rdp{36@cz*S-ZS$r z`ulSPco-8!?+02Y5HAmq3G5bw9U-s-z{bkXq5F`lU}ys#K>qF6V{K^e1mxvmQFS)8 zc?#raW9A02v$BG~euur3sinDvGmwjui{;tRI4g^YlkvS5z{AVNa!|9{5rUv&J?N&HWA%mto5F>!E%9lakqW@G)0-M{u& zKR9LoL$f@;vC7TH^9P_g!BG7PX&^qNm`;9$qtl-n&*FOZPZ9MdUjRne&|P{&k7mtvJf>Ee_)ds%)cn~RPEHNr@0>=QCJ+sm|fLnnqR zc)G0(uDn#&d|q@I{PDR`%)=YnSL=Z`>S$;BCA>>A*ZGpYm$M9pFTdE)sXSwET#Yr0 z*;F%W(h&9>KX6x`6v|YmRk2_Vkt%rmzIAaUR35z;^kjgjraSm%1GdG{sJ+6M?UpR~ z&gNY@bdW^wYxpZObUSQFX+)$Rc=aztDf(=W@{(vG$_WAw!h=euG>|BxS=hzhw1(t> zn1#p0WiSl>t(kfHy*l{mDzLH_)T|326e)3dYf37)Fx&p!vmH{H{LOQwM&S>QFvJ9G zduS5a_(>tl*EKAHS@Olm{n*yr|aG*3ou@pSx;;QIH^k}ABS%dfqabE&i0p< zR=Ub=Rw>Tc_9qA@AJLN?>v8z0Ook3hZ_$p#;EFsCMVsm0q()leH7p`95rGM_eH< z<+3l`+J*EL1xM!~rW>24YYLWT&%~tEGWX#P6`fu*2tHnT5ssqyk!2W`B5*4)^eD0| zXOS(y%W}@emex0A*3|zvu&=#&-l&4xyWp8bbaqUdkp`{nM9 zUFs_qI_gJm1c7!6-c6kZU|%S9IiThs`upn`7f%CNuSgp^?#ww4mns|G>Kv~&c2?(& zsBfk4*~g4bQL$B}{X;3@SrR(V-G>{)f+Z7OJFhG3c`@5*aMl_i zW>^p~W;+~4zi^mM8mtUG_`+W4tso-(Ybv|^- zD-#yHyDVaeor1^%VcWS&9$Jq04W12ts#a?bRyiJ^O-3f5j)ud~nn0x5dk-J5MBPk@ zh(*IW4sZS1CeoqsJ60GJgNW*k{}kX-X@| z_0nmb_vaXfZ!nUWaE~t(&QQmztR#Rh6R>q9b1r+tPxK2{oPyxg=|uJ212gRyUxHls z)zL@KLS=j0-_v49&@Hz@YWEV|cC@AIJmH3mkLaM`tU}8lM2QXQCN{rRgSMl?PsV<# z!0R)sb6o=x!qQPzqYB z#Vwze1dm)f&Gb1J*A(J#`7Zq?VAUVF?_lT0!7}7ni)#?@+D_{3iYnxhjvD)Dyxc|_ z0ggU>rY~mhf8-p4Xk zdAQ*Bo?`J+d6`U>a0nI0E0bMwkK5YHt5jXp**7*vb0D)tlGJe zU&6(>skJAel1;lxIZ|SZ53p*+AI68?uwZD&=NEp@{cJ)c@uN&s%zy(jKU(L&>mw3# z2V){cok5!dSl5s&B=aSP(+a+j^6;FllymZaT+{7%T>U(XEkhEN2#8qO7t8f8-eO%t zFHDhEx!W8khU1MX!v#h+K>5Gau_o6R9ULs!P>6UlTD{#iA6&A5*)9|Y6Z0Z7L8^+s z)mI2NRnwCYiUlo*iRgfylzA{+KZpjt&32Va$rPm$nb)$hy!SHnkb$T#bF0a`+yOLA z16oKrr0Y_N_-;j+u1+DmgP~&UP1m|UI_S8)F)H&Kv?8sQm(WhLTQ%}ZN2=-sRuAZo zJeb&o^%Y@V&aqvIOmb0b1L5;Ut$cPC-G)_wrHFp2dx(T`Im(CrohgC=V^&?h(1q;s z>^bHM9Nvy+&rk~6BKS+c2=}lTXtcS}YV?XxbhVXu>iPRJe}cF}AoJU}Xn#TVGQH*E z$qr;nP3)lq`)cOp0R0Bd%a~|C4jER}*H~2V>00CvE_*Rjf-(6mWn-VEQwBbwN=_=% z;3S$~3kdQ&rM-n`1!OA4?fetY|D5Ch#5s8T;XmMfS4}o@gcZGUL*wE-G5gWviX_iB zo>%_^{Gx*xm+wmRagHdld!iXm%997@17g!_Ff^a zi@Nq3($wy1ZE*LWE{jRS5D%0HE@9qFy=o)&6X zzJYjyEwRs>jZ1-dV;yROk*-;pI~FKxTcW0ZPO-O3f*(N+O@;#lH(Y$c3rnCaaNec1GxkUbN2pbrJ95R>72eR%EKGawbZJgKsQn9tIk&VE(=@n{l(idn5yC z!)D?I6CZS!>b_Pz+$>X=z~=Z0HC9PEe2|@j-YHFhLg)B8AMN}4lhRzMsk%6k`d0ALF<$=-wG08 z!py{ZswtDOT9qHo8j3P&o|RLmW0AYyuYC7D`80IT>mN4=uT)QtgUW{ z`35lRx3P32(0Hk0(~KYb9RE|~=?vPQdJjvRhgu~<;HsYODU4lO6>7m5!FuJLIBsNgO<=>1ojP6r8R`bgHh!(d- zpUi%P)g$>j$_O2qusCq0Hxu{y81ll`42e0lQQwtMzNxN=*Qk(LLD%?x0!b{+7#63{ zYaXnW3Peymj176I%db~tuC0bi2vb{YshMu@JhtWOhm6spk+b7ZLQt|gJq`uSj(nB1 zx)iCNP@;Eud{`$NDG0+)bFj`(aY)Z~x!4O07_E^)c}@@+hho5p*Wu2)C!5zirRE#G zs!ue>R+cl;06#cg!7eRx+T2#*=a3L-^jZyP%ovs4u8Q~e_(BkjKBhe@^DtVAHD@lO z>ExvAq%<4az0?9V1rE;XY#cq^Mz+~A+=lZ<(7l1@2j2Q(l#h*a-7wu6nekX>UJHnr z%M7*hrilhWm9ii=SF{K=G{S}O9ijCwLNQf_$GW8qlYG(4c>$V!mm7Aouw@Ewk2X6$<{gib z^I5H~!a}V@VG4$nP88E6O*sKoVHkWsqKJS0KVkCECAD8}0UP&!#AJ`{3@duWF@swy zDlv*{eiw5PEUi*S9gJZ6>zFzh9kCZn>j(U!N>wqP^1`XC1_P~2jCLRAbc0=!S@rx} zz8XQ}WkwLPNH#S1-HJfFKEjPYinqpm?*XV3K$DVS0=3;tJ~RE|p_lAGxtg zXni7=!4u5fn)1)RoLZKYyxonWE)%Op2-9|R?A`?pygmIudw||L#TF-g{c#Iu#N1th zi!KW%z8&C)-4HjYtfS$YcxtGW7{|9iR;Lh^zh}r7cyyLcMvH?YH?CjDF#LH6Zt8$H zc=lX74J$Rf;KVU%PCKp4#CgE?=4L|6eQ0c{#CS=4WVST+xYgmAh;W!Tmq;O_e?E&y zU!r_)(^eB+8c&ed@jS3>8I&S{Csw}fq{|L+0ceL;IxenH2WnY<<$BvU4sXLLSggf#ZbkeO0;uwhdCPTR&h2H^~pVH6&-Z*^Xl`8vi5 zXxS>EGnM+)Ccodiog9qy*M_rm!iAhwkH@x#Ud!J-hVZu_#qo@Ws)%*gq4o{NaDIQz zi)AnEAMoyjeOYP!y|FZzlrqeIi^NDSWs57+a)58V+@1i@7j z`P>*?i^;$H8P&z&9`dn-w>?QY}r?yVu?hug*U z9ASJK4ydnv{d|gyijfHo?c!Ka{uPVMa*mhUuOI-+K7nul39Wywfc`=&cyZ`|?Zob? z_eFqbk)N*_oGVbXskRM2bqS#|DWzI?X`c+aHRM%GzlhG15^jpkoWarZ6;0c0 zdzz6-22y@c*qD>OWAck{BM|)nNdJ}o8!H&tZyB(Q} zZC9|4xKP|M@FIZ=IC*EFnm`4}`o9x%3RbGT&q%K7lL?*x;q4l)^5Y{fv} ztvrk2hYRg?Qi>tJwj|B40~ZbN+oy`LMhbN7S=7oQyjk6`byAiEA+t=nqIj4%u2?P5 zR*z*^6XNquRK!$Ux#U}}Ooc7T-O`}eJhI5F=u|z&BSVshDx4$PvM~GP6tRbDc&2kQ z5uQMQE~+G`eN@?(n^{3|7%7?&u1Y{c-%ia~vuKZ-ke1f{%mIr5iw5HZkNZolL)*_A zoW1l#%F;r;+Z8RVNBU2zO~e^Z5<*Uz9x;$Wx^I;6sj3frG?i!bIqTK~;T>7UqSVex zmdBj<5%pDJIoMt~$WebJ{%RTE{AHN>WBZwP%yhtzv&Hi6wi)S4BA-~@{^u5O5VQJW zX#Jfr90}v*B^rHp19T;uDnuUjkp>u^MT-8~{{+uJ*Q$TQljFDL$R}cIKaXiV?48~( z+_L=KO5kN@5w&!7QZjWEv$L_cvwhfAVEJ?R|L4B{j{^ulck%z&Z+h6Q|8v@QH+i=R zK$nq_mHpaW@0-2f#oPx(48+3^@bd=&2?Y%%2Oa?t2^|0l0R;sK4FvmE7KAgiR_C#DlQc7AzRZab=#xqSVV-r&|a|_GoPR=ebT;1F~{QLs~gWd#(#Jr7- zi+}h2Lqd8+W>$7iZeD&_c|~PabxmzuYg>CqXIFPm@7IyhvGIw?sp+NVmDRQNjm@p? zqi@G2r)TFEmsbz~s2}Wr|NX(xZ~S0@`GJInhJuE>=LZ7P75qS9K*Nx;!D5Oi!x=hY zJ!1ET#})M6#H9o+Q61g0^uW>ojG@>6TO9qt&>#HVO#_gjAi%JJ z!T<;Zu9-thyqe!(sLE_+mQPaGr!g$mjrWE@2G0di+Q}3(sw-RWEJNJF~nOI zhX+waoNO28ZtP+$uAG}+st{;gt5Z5wjUVgKAJt;p+@SEXn7lw7$3sMWG2?snwToTT zQd!C|H@5*!#VxmE>?GB!7bJ0-7$ubWJfSL{Mud~-a(7icuyuWt+wJV8(nxwW0u*hN z^@1W!w-!fLxn?xgVtk;LKS0>6p(`#jb*BHBC3CcLMzu!Nsl-c&i@hQ~n`=w)>T^x6 zvxx)F7@gpmqlx{-6nh_w!8^d?o#GqUJ3vUrwS>(z?lML+^`VMdg z^2$-Y1EjtbzQDQzOiq|3hxz?pbeiK1FvPcW2OzlvEazS;;~Zu zuxp9ZnG<;l*LDZ+75*O1;0}={u3DLJx{f4R;E=aZJuA5sQY)339zqNF^<;OeE5&c} z=BRMb3A{)}E@ZY?l4e>rD5oqKY-)TK)pnTmH8a9SVtpA?AZI!?av4Z!IlcE;MFdMg zs$K3C)=acUnz|f4tvWG){vfMIH~4uKm>l3t%GK&ZZ^4+2>a9q%@M%v|oG8&`ju$xR zlj7AD-bo=IL0F_71K;(n$kUY5uPj?ym_GTS^`e6M5}Exjl9f9E{_KU;@)%RvYw;uw zGL9;EVhv4`d20um$H;v#g6t5>pLbTsZoDm<_JxmeHeZl!Gu;7p-h%}p{&F4(Ps_cL z+COW*MWU~AxyWNONs!Ooi*Q))*s*EBXboFgU&38P99s$E-#t!eXh_y^?iT-u@tGt?1^PV+}PO)Zwn5wM@MM*o)aPIb{DeXoBYa^)Vc(9eHG}f za{zJ*at}g+UAFWS1c) z{Aj1RcYxC`KAVpkiCFFc(fb@<$*yDsZ_IB(EPO)ruas?$s*{X9bDWi4d|GY_m?!&6 zby%xy-dN+d-e3`<$YAkQz3p`qmv-(gDZ}iX7`Y0MfCj=*&@x_7BZ-^jwQ2{Ulm4VE zpXm4wWH*wreYdS}VB;Wy>6?J1{-U{?$dtT8L2HxS{(0f?Tgn@b%JI+Qn1$!bjCzi# zVLJK5c8CC|qItOI-QTlsK|4OM&U=_EVpXNd#nf?>+WwR%X^Qw87oQpq&BH1dFx^lG z+Y@v@&1{v;fTCK}MbvfMETDYPtyb-(tyUI-yg4lEn2Lfdy`VJZDY|Wq5%Jk`@!On+ zCbC|)dRejFlB8zk?}p_o#>8JuUbD3D6@_cJd=sF;p%9%5by6ky*FAJ5+ zT@{6VIh=3Exk!|$8gu?sv%gzpjD}sB6i7C*rRA~)THZb9)(XH@mV$if_3wLr+D%%( zp0X^loVT;6_lI0g_m4<4Y+m0)^E&ON0c35QdL+1G@az&)arUmYJ;tNaTm351g--_G z`B)WNsUGFD7o*;AjAVZs4pV56P~V8!Q<1b!^;sF)<729BTbNpDJ>xSuANLUd+ywk+ z*W|otQcmjVzA{9t5p+AMJa;2_al8~sCTVL{VH$AQ)IP*TB76{2xi7?g;l4OH&CpgS z{(Y^ZW8mY5nu>%0`}*qKZUIlU-iG|DXM7ko`L;LX2j8uox-@%d!s;$I4qu;nT7{bvZTB6>PhCWgQZbd*||oOtgRbS8Eo zy_Af(^K`VRGE|#i?U*X=;1wdo9l-f`>p)Ncn#4`l#V1TF@(rlQJVQGAiddrRVOY6ev_QDn0POp!h&n3i#_HE<7@Cp1*6AE?ti?{O`-{qdOocUZk zpGNxM0nlF3nJ?17pPg`a!TbiK3hp7vS_ zd|7<{lqyi2OdJ3naPtq@W6KFnV>Z^BobLcjt@$!Bds%}oD;h2w4v{2Ehs~QtPGl|p z+)15Yj>KJmQ4lg>7y8iQsE>VPb11u99mos{*YBv~kW&iPE^?izHiIJ(^eWfoj`YTM zV_BJNjLd!RG^eB8Le!8su0f<8FQ2&)aV;SfSgY|pxRJnyf^TsU>N}^;MZ$WT0E71k z1~2_P*XkS6ENO-Dkf%KQldhfBPwQ^07cKXnoaJZlPr%Vf6qd>73^#&34TwRHtKQFT zOOd-fiw6OE6nqOoGs@Sh%|q4GG^kuL2)q0tCs$!3Sdv)!(_g2u&f`Qe{drBWmBrmV zTYe2|Qf&+oK8RWp1M{>{1O_(GIT%NzqT*X6$x5%sxKj8lMyC3KvF+GF`|7^JU*GO( za78Q+FIyy6L%%EcR1X*GPmNxS7oq&>wZ1Dng=4$$NDeJn7^Ol#L=UfK$fd?roB}RH zjSR$&8j*9jHEW{r<>)2i#onREtwkg04vLS#U{Z?!J<-TZ_T<_tjY;zynY27p?_TUh zf+1pW&I!M+u{Ij`sg9H9n<23of_fW0+`>?|0ylaM0Rmp18Uj;@U%eF=Dp6F4>Sz&q z<*P4y!+v3v_LAkWfDbnamO`~oQ)g|%dw>3Ru1-TFC&sQgP+{!DW73p*ttJT$G7T&= zQ&ar2kTPuA+?~)Wf>w$&MTBvbxqsut|><>bv==8hPSV4o2K8k z-U5$OT4fnfXr${#E6LrFzqUb(%mVx|A1^nIhnzTuHM*O+=+7wFIKQo%-{9iFEmdAS zbBIhY7dT#o4b63PU4jb&H9Y<5$=~N`rn$GSTU4O?ru#}G>2_)!_6RS+SsztwsUP=T zEq;34JkDliR#~QqV^9Cdu-+=0N+81yomIalsZ(aMkRnCGg^Q(7%A!2t_&#jlG72C5 zTKEKV0s71A@?(q|dLT+TEo-Zhd683Tnk}a?Gt?{oWci+YBfH|o-R{kJgq@&N z_Riz-xC>~y%3h$1nE{L*;9GCZOK+ev=ge%_6tB1I%L{4iu%5z}+cTP2MT-VFC1P zG#V8*CJMTjEf{Sp^MitzXV1wZ=7%AkMYhZjx7S6K%{&f!1kd*N!RzqaRly}NZxQ{~ z<*=JS(DUE{ow9L=b;?jsYme>M%lPn{Y%&vrlEAQp=wz5Z8MLfq1@5X3x zlp3kfD2?qKZe=t=3i5!i6ILwqx^o2wzPF6R*NbMz-i^f8P}&G|>&SYG^whK|#G}>y zi;Gnm1bx!F+%_bX7trr?)r5rkt0e_z>!CV4seCqNQs+rt6@gS&18^BB=2mtFT2xZ>DUNeiC5yu(H%*bUd;frPyJJa1MQIMU6C=7gDkI;oz(2Xuh)jJu8Y%t?*Uw=s4R*}fIg*{$f$BdOh@RWfvB~Kul;c&Y> zY^V8~D=Hyx@jD1=BkwmY4$Sn~=vOtkxdXR$Vmv zPR1u>jWj|L*+J)ayZj9$WOgyS(7cTbcI$PhsZsAVXa_G33f@RKs%7mE?_0a z8FJ+jjP8WA#PFxS<#guB zq8Y45mPr~D1aUkRc|5LTd2y#a`W;hQy}8OOH?!EElzX2;Jl>+N7olV6nnE+L6QYrQ zeGCccb{^x`xk4q1MS&g3q8zJ}XwXu(ZJu2teNPKg3!|dj`4kK5$0|l$9J__{K2s~> zttAn}`=;Y0p6qEOw`f1{w3Zf8AF^TofUDxfCZ+88fswagYCnqHAlcanZ)gZ2zH-AY z?!T(8`pN_dD~4|VwyvGncMV`YY9wjA81TBtcBkXUcQ$NnJUu-XdY(1gr8dNUm4e#z z_~7$km-B4mHv@-W_7A1KuRd&37Z>GoZI@~#%N4cz3zIDClUy9TyP4DV#d>7nMs~O5 z$Q7zD?Tyoq!n#!As#@KtV)>X(DuRS3YHEy&A&MvAN|?U^zEvXu*1iH%Do_@D=TDg8 zV&K>hITx1ZZ)OJ(uFh4Lghn!+7AAzgHCZ!o%xJXr9z4;6giM8`UW8yUKuhxFM~C!5 zhinxAy@BfilB~XhEWz#;;T-}9=E5x>B zIwI83lHEwLZyc48anhG8FcU(1hY2fi_QZpRbvF%9Kprs3qUJ*r(6BA>i{kJUQV5~& z^rC`kp{!Dq(id;+1MS0E<=tc`F)yD$u=&4#!U%kdo*3NFUf2%RzS1t+Uf-^X8Ehi{ z?U8uYS84Vb-%;^t(P_!6Fy{{-c@Kr`Xp-*RRcJ?YP1$`QTFiNrFqJ;_0!34L32jj< zs|=sGh-K!9awlyUEgs!StcDtw`s47_btQ(}y;1UQ?`?u@n{6z@@bxE1S*Bk{E7mH= zrw=SrMzSqfHi_$KbVXUxiMDn&$-YL8G^Gn0vf|r@SxAt#H9zZ`?C0sYNI04evsyQ% z=2U%O`62v030J-K*?VcjI(FmtvLEEXh^&*Zi?37Q2CQ|)l$aDe9f#kc-GQ}=?>7yd z+_FZgf7cM?72%a4wp`<|%!{Z%vjH_gH=xVh>as3Vz)rss1SIhTfa(4tU3RmlcpK9v1M`D7?cvv=4WX(S|XD zDK3649*(hCv$3MJV7ZXKkn35v_FSn%pd0f)dEjT?7bau8Pq)5*#Zo?(k&V2Pih z4;o&eM&JQLQ`6&;$F&C5EpzZW@S5!rZ+fH{%P7Bn@9qI(P;=B`lzVt!IAk+<_}oaq zh~DU|Lm=Wbbgau8`&tf@T9cZWG^m}b)1^zk-D%lrC1|Bd!Cpp*YFGZfG_s7fg22Zo zQZmxhQO;t|Y2svEWzA#6V%|}uD5T|>)@Q?(7w8Al(+@BwP6I zDbx4N_nM3hLTaM4JuFkI-~1SLx#$zY5Ny=oqj=ZN-A6{Bjsq0}*9&jj^i5CmiKfq# zm%9J+jBOEjwM&CbipnQ~1-Dg?@{Bw?%6m_G(HMLRdW-o|$*p8Sl9j|ZS!d3bUM^y% zRLSp(WVto5o|fmCNu;DNXd;a<=Ls4uE(xpRh3$97b>`J|*G1QDoVuR|5l*5^2O@=k z47VaY;G_b5&nB>m=T5P9u(q`OpoLp*Ey*ydHSJN>Ut3si+6`hm4%R}Jc-*%{OEtb@8z`j=y8W1G)Uw}Uw$tf~s!=L$D()4PhzOE!Y^ z+z;@q#I1tHZ)=LI=bq@>FI1hjpH81na6hq`92?xX+it37vsqb!uuk<{yq51s96*6Z zwOx>#vz`^;jlEI?WI|})zOVT}`624VO@c+jSfXfRaT0M-aMF3QN%Gf^k3SZrkfemB zT%}s3PNqqwRi#s>$7jH1yvSJ3e45#n#gmnnO_&{;{XNGvXE9eLw>^(LFE5`sKk^gg zCznrK1v&*og-;4=ikOPhigAlWO8_MC?Wv%5rb^LXe_007-pUFQbHsCZwHX=6qH{LaQG@UlvH}AHXx2&}4x6ZUZ zYa4A>ZXf87?da~5=xpl}>1yg0?Ec)t*Hhce(_7ug)mQa}^GjtvXMg1Y*Fe=E_h8Ks z?@-;az;NSN;jb+tPewXNrAPb56vl?f)yF3%bS4%jO(r*|tf!8qUrb-myqblX4Vgoq zi=QW+PhX&0C|=}RY*>1-^krFfd1l3UWoOlC^=8d~9c4X!gKQ&jlYR5^mc-W3w)Xbg zj{VN{Zr~oqUeZ48e#OD#gD;2A4%dzxkM6#O9TObqoPbVRPnAyR&uq@F&qFQHfI^3qG>-UtYfkU&>~?zl-&wt^XTWvHy0$9>fj$r~f73cTarxova;E z55_C-T^N*AcBl7du8P8V@UPvd@D;2Nrk8C|MGcfjpDi=X({oS=-+FBiw-KmhGHqZ& zYZ48C>aR4__0>;zFSBr~=cdXpr>upzMME#I%Ymxch_|Y3fm*OEqK@p()I%?WIH+s~ zW7TBb+4MiEPl6P_2q)ug%w%D+*e1w>4dD4SS?{G?P03mS15@}@h31I___u?W1ceR+ z;z$+!b(+ro_5D?LeD3AC%ZPZ#2O4hs5k~QHCA2HpOI$6N6ZvePBEq;vUq7G|`m?MKkA6!}_u4!owWvyi}GQriOgwKYxpoUM#gg6vZ zX&^;a*^f)(jhmolJDASvGJ1!%=`?fXbCB@PfQiYqlGFq=V6zpnTCkYFnuHKWr zfFvmh;f7@$9(#;7z8K=*GbLCWZa?Y=ftu7Vj|Uts@?lhOT% z7P>)UwQZiCcaOI>a+A`ts*}PrZnst9=w^dgn`BWWm8xTIw>y6Ca_91M*jHcFVbJQq zwCJm(G9Psdgn>Q8HnI*sGEeY%YY6fc%(3n->JA!D6}Hn44r-6utY7pMp61)F=B#Tm zC%$OYEh_*bV)qGH@;SzDu*5fQNZ@jjB!|YP3Bs|y&>N(A&zUmJ;x+8|wiA*|yP$rG z^SqGjCb`me)zfsq(&rK zG}CbqBdW(vOLvi*Ykl@XRr@Eskp(y*LygX55^kar;Ykir2@2hjSe);=v9MR}(M2Hf zj%;oV9W)Kr8)Z;w#~Si`WFJbs`qyNoLpNeYGCZFdwxz@b6m2cL1<`m-X2o!jvVtS1 z#Yl%s73n&({Gtx%OldJtrOxSkK@eU#+QwW7y8v3jtSp0^UgtzZFSp4}cyWgRK@3UrPJzs6J6Ua2Yvmqpc2G&$O zbV2z=7|3F?Lr7md{LdOe^K0qI21sZJK{QzAD;MKp%lI`cSq#jUGcDM@0{qxyM7K{j zmpDID64S!50TUm;@<$CYFSfwv{D3W+$x2gXagg@?4H^-vnMF6wdZOEC6k}@(ioz1c zN!~X$w2~JZ-lUL@am;$7%d(kb0iC^d?H`u$;)aWBG}4Trf>-AqhsnQLE}2jzvz zM~0w&c-zet>|^h^Xv*1O+k}M;_0}=3gIBPrxKXEZY4*CTU@Fd&d4#zC&5w8-e#D^&aE>R-8mkqCc|9GsbRLEOUGWfgQi`ZcXx#e{kvn< zu(R+5HE{ktkKaSUw{a#yQI^O_P(Gr75VPPThv4ILrhh5(jP-FV;+l3Tx1u8gbq5{x z%jKe05-TO)o58)%jf={T4wy_RkW4sFRAR>4m5rfcUG`1aEz5}gq2U}FzOBtgr*WT- zVO_beA3boA(aXvsTUYGTlW%$yAHkhEy;oBRB+-*zY%)Xp4%n*Au80b`ej&RsxCz7O zis!*a`y?fWB!}{di zYW;`V%h?Uxh>u8x8j8#CffDmF#|p>w>Ts^w+@Yu%isBUexXGIbgh$@>dUnEvT-D20 zOI28*{o&7C=EO#%kHUJ|w-J{yqNT024PD~OFWU+y1!6gC_}5*u0ZI6;5^%Y_7An#g zzUo!8kYhHNHRBC@s76Pz-#}efe91A#Y9HBgH*xz&7)Mk!XtpV*Y5TJUI%|HdekF-ClRZ8R?sw|iOs)Jo|( z4RcSzwrg&H`l+q$hH0>44(Qceu-mnkLf1)N{=MMe%YpFI)f z*La(l$3P3d&%&0G-!I{n(?e|bC_;Dx2ddm$9Ont#*Wla<;T}rMLlf=P!T9UDmMBo7 zppQ{ne*9}Kog7T7X&JABi&$Rdg<$^>Ld=`?W|II4bpC#tWE}3tyCI_=CS?y`*^kIwFS7yBX{V zCS|Rr%5++hHfoGCt|(s4$kTY|$rET!O&s({>&q*Wioo$8hg)0DIZ>v39v|0zQ)K=m zTkb&ZEaWVy4tKl>A&xKH?(rHSqw`4l0Ga^}Ztg|<4 zQI=W+duk0_r;!+exTqzhbj=p$kVW^C9OOqs;e1+sJOd$Q=&L6L&Y=o=(^!?)h~*dJFIXC#tx;KA`|@> zQv@U8A}LLa@N+gpgWX_YQfWgo7RaQmGROry7C>~2qCh_4CuAYF7nF}Ld6+_2CKALfjex*1Zc`mOz)GuR(PILRun_*^gG+4 zbPOk)1RZV)kGtModbtg~Y)PxKr5!x-B^T_dgTOwF$j|flvYtj#ddeZKY)rULPGpvd zMf5i=#gSz30v~mpwh+qqT#YQ8H^r!h#PDQqR_ z$YS{MiNmGwyq@f!9W0OOixL$x%atSB)G#1zM4Zden@WKgiZm&Y z1)su4<6bYWcm@>|wM@80dJ+2eizbQ${7&PTo z25fE&-Zd6P0sBwy&MvRz8g36(mdf2P_W7U8y)k?vQZIaEV{w~EoW;pl(Z%8$O*LLe`dCF+Ib>^bbXs#IIqv~BI%<%A1wE}TXx;oydcben|WbTA;31uGoUFan5I z+}y>BS*kSg#U%uC^abjHbm`q_W&K6DH@}VS8x;aMxUkEffVB#KS#F5WoO|=r*Y$_y z^xWG6Bgbyy&kYw&So+f@p?Z$Oa3!-nby&>1Wen&FLX9iTkTa(7T|UTKb_=7UyB4td z*-0Q*Ie7v{7I%`Zj3VulnfS(p+_$I~X3lSDM{3>?jTfapVJ{ZYNa`9pMMFZx2$BWd zP`qvOQY#+U8?PMK#nLkVjP9hT+a56*CGmdKF8~>5E*9UJh@3Wl8D#Tp&t-by2Fl+( z95;2mll@GEfqr{<^p0`>+__uTZ-hliXicG^goX`np%!ZMMMWyymBgy;) zq5UY1QJ{|W^EkJ5g99P_S^#?NK%LAh5_O`SAj6LpxdN{flkoXQ_LW_tW64`TNsi*f z(PDKU9jn~viF0vDVdW4!))wBRZf)~d;f%32%|z5tc_u29W3C|T$auv-cy|2BIXt#? zd{9A3qdlphkf7|qH$dFQ^W_)(^w*<>oIwIb_huKKx%2deEn3Dto^fI8J6w_TAh+q! zBsX*TOu=SBB%Z_hj88Uxg-jHkhNHhG@j*tZ(Sug!Eb0XL?rvQ-X#fj$^9N1Rv8Nqc>nV#&8UWSxrK}H|? zL{xgdXkB`Nr|(>z^5s#~6sk!;UP_rM)zQhDJBAq!Y|G37FAuC8Zt^;|4mRfsbu!K>$6Eh)bAzMQ3)eL-BY!sQS(XFzQP|< zHg?>9g0sayu0Fyvivs$H${tzp&cE6^D{)Uw;Xq}KUC8CzC6(`_Si9~Nocrn*$eD#l z!<4g3C-=x0mi&NLWqGlFxF7|3Nvn8TkXiv|8H4`C+m*TDFGU03`kkWY`pg7lVWZax3;VvKT9vGihNfQYA85Lc%Zm?7k`(iNak^%|qs9#e@pSNE_> z<dSm7h9Y~_x zW8;x&hs0)$q+(K9fNMD-0q>d#9M1bRW|W9@(~KUIW(B=ZTEiw3h{GnCZsaIg$8Crd zDK1QO(il-~8)v($UR&p*&l}BWGhK(Js%Jwr7k4YCV+MQ6%0T224vUXV0{ZHQj9Lek z3Q5`@J_TifltXv&qb8BpQYvx@R5UQShH8#**^c7kPPJc)*xPq?AmL20nO;1&xvI_P zgNr?rXc#2z3hL^>@F&>&)^xFQX(%!mat8U;?~*H62oh>kGP+)2 zy#Aa>K~-37igRAc^ku0;@1%{^g+kz9pC~rPO+Z-iSOU!e(}E03WU+YBLssQ&?JgR% z{*1kRII&>je341L$2aI=Ig+a%NequQGM5n=@my5ez&Y};U;I-A)qcIiFMP2Mn_u## zY2Q>Xt=$&kf2gY?Zz|-@ky-Vwrl>kEVA2{!|1f>PlQ#U_6H>7ESeq zWkVy)YBn~L(^ny9M5x79W7>LquJN@x-NA?B&wfO(tT=90*KF{1dvM*OPBMK76UU>h z!my)A&)PY*26&xaO*T{LQ+x57#qYd^D`?QqG<0%M3t_`AN}~%_UwL#afv73P51Kj zZev@&Cb3>A>6w~Ll40CyTA$EcQ8e#2Y*Se?8!_~5ODg*PJ8}o39D$!{JJb*;&D1_{ z&}2_7arh5xw{*g@r%R=R>>9hsmpoHi@}W|nh^}K>jA8=N(97Fq?i+Z+r%Dq@t*k}B zm97Tx5o3YY76NXN=#aFFWm-F*U^0c28N6&7Q746;H8@=MY%H{v6<_kbY@F(H^CTXx zNJLnXYDln|x;f@Z8n>Ps@uByof8;EN4m&r=)!B|OXei!Pj!3f3UTAdm;AFE`$JJ|# zH2N^fPT(X*S{XB5Ue6!^TjVqbf`5nKC1!k#?&w@S(a84D<0~B*A#hz!ywfM&!{OCh zpXuF#`i3p3ED;|e;$s206eQ~{WIK0H6~)5ydc$euO0M*z54*&t04 zGb}PN{i=+&aTi{_F0fm=7n--5|!Jg>AKnh9_52(i8U+<@ytNb|QKqNkFu4f!k_HwoX1+yalY)vKa)^K@Np8V;eK=Rve7pOi zh${J^)FXTp$vIoC0rexDwn$qG8SdOj+wPdeN0S5>J;+DJBW{SdVc5O1k?7mCCAL!eNEdwMkT}L=4?Vs4cneZ zXC(UdYstDU)1HrA8ACWSw`u+YSQpEx_EHW3#)wHKf&&kaY&*>hxXM-{)(5<&<~?h3 zvp6T=Kj*I1@V))qer_q<^jako%#M1&i9&p?KF+O>2T$E4O5`T{j-)=G`znxxH}hq@ zs)S-57C<8zXC<{*f?_00-KO@*8tMCb&I*g_{_^cR4qh%!7TA_4@ncJ5Rt^BjkEyR= z9`nhecMy1Gdx(*b^8(MP7xu-40y75OpBJ-*ndT*<1O+xNr_yK>4#$U-7S1?@Ig zz0s%+HKB}yJ)+GsPQLvq{)@EK?+)X`aZ~Ocq)XO?NKcC|Jh>u|t9`NVhEU08d5-!y zY}|cRLQn5xXv2M-wQlDI{XNTLuyu*yJ>pI5Q+u&J$?AFk`Pc#<6yj@w1-vjWjuilL zKg9wbF>p)BZiA*ch2LB>AAQiD!)xa@?0%v%Y6xp)@ zy#6F40QD=t6&(ZtWmOyjElI(oCE$L-nlWyZc!^^lWMg5!%WPir?9okVWR%~^{gL*n ztvE1co!M;(N`jx;kl0`z!t&0ne;Rr~YuD+cs;H>?2kWTDK}~quk$wr_FqYb*LH z?&!6eju=YCi-70Y@~MLgskyN)d%!}{g9}MixT+)}p&6cE5Oa-LVX>Am4LR_IXo86b zsojMK$+VmqIb1-?8@4VAOD9~tXI@x3oo{3aeMAuRO|d)iy>2P4V5t+Tu_W%olpkGE ze$AGZ-!9#85E!-MXgH4Vl>cH-9A6qYu-mkU2(KIexa0G)G%^!4ob!`?-(aSmz(~B0 z*+OxXyozA3R+i_RCBe1ojL4k@g#y`p1ILSIPno^ryDaPz%!f`zR<9I&qtd&>GAReP z&=8nH?^RQ+%QJ1lYj*W5iKX^CX*~#&w&V}DIC7K-^d^8$g+OBnP#T78Vm})(*3oaU zZxv?i?OVLZ?ELUJ-6{{acTaezC0YjBnHY_T^8k*8gfizN(+>hz-(~ zSRPMBI5MF?rh7G5+0KVwGG#+Oc%CYp%p{Xyr5m$)9cT^cb9V0GjUU%v1_wT8rPQN+ zuZfnQG|1#8;4I0Uf0)9eQg>5&U3C{MQ^#_LH(lU%LRb!d@Ze%G9jss*Kvy6mzDGT- z3QW~s*}xrjJhqjD44h8}k_+KsjoSr%mIQB<3Od)}@)A3}7ffA1e1WmE)}BV+ji8D? z8}C?|1xwLHeRK)`vBhx-k@XO(WskiUi<3xzesOiurK~?1y!lvP;U!bPMQZtNWtP)C zidSA)mez`q6-pnwPKi|YRIy;So-uXtRF~P3*;58qXU+Cr`+NmN8pHZHNT}zSNqxnL z)pqFK&2d994rWmy8v7pPo3@J+Iu5W$Uw5KrF2<2Zw@58WeWs z)Hk8{pAYjMISpXnJB)USe=a>L&FLjRx`=~ahnif-Uej-d!hzK;u31dNoadn`1dF`! zuX>XxINM&GyANS49r9ZoSkDe;M#A5gHC-hb8_0JY(1B`pI6G~k3&g!s<+zBguz0@Z zd(cc5b!)oTv z5RppqRpZ>=6|v*&`&lvPadf@wP<$*1mXCu?u5D`-+gtJzlvs`pCV6p-YFxRfrothj zyf-7y0%on`xuU$jn!FWrRw;4UgjPA6KNRq1dzzAWq_8LSUfZW4cqx)GL)$C(>y+kk z3x&htoS1B`x1QP?`dwFtTCZ#1D731~GF9vRG5jlP;y`VV4%vP;m6ILj%bBSae8qr> zHPHg}EUk*%4`~yeCYn(>xs#No%onkxxM^56;6cw}R3n7|Aei3OHL|+h1)t8QuSfZI zIQC+2N`~W_2kx$F$MElV9DXLk`F+RXmjvuT(hmRI4;_8aWb%hYM?Vvr{5y9X{`U_Z z{bR-pZdf+#f0B_!TMt57L+Jgrc%Ej>m_D{`npu^gd+Oc@UAR)=Znzp!nP5ys#ba%n zwZpwLecpF5f{yWx1X9E(f&}-0YlmKIWXgty4@+$U#TIcJwiZFSq33RW|yliA>jkdUfj(4H`1<&2i-^|J*OU%oT^e`g|3TUM9ZFBQH5x| zw78~l0&a81Yuq7H3gMp)r^duSg>wnW$gtzcgce>mYlRsO_3oBA>;=Qwp%T6;K$ze= z_HJ;U?(qCd#y8DKif^6Xpnp>8$hBLOI3JW>`s9N%u10Lp`Pw#Qed|f3Ey)aovk-%n? z8&BXsaHd=}E!1R7uS$I9x z0|t994K^F==2e`cGTg`)8q-jm{@g@xd%=xdlVJpjtqGbI@aCS>vtVGbUpF~ zr@J~F%9_&nl8w2#$V6~j!39`&)UU%V1G7V|;Mg{q-y~y43E|Ws6_B&+iyDat`bwHU zH^Mw3&&i?DLu@@R z=X9_6B9|b<<vh&5TSi6~rj-Bn}V?d!?_ zN{x1lWFKTuTd>Hhl3TS@mEBj!x&+ za;myxi8&C{XUx+DO(d4{TH+(R>bE||;n?Q1s!z)?NrFqf1mYoqa;Idm0?$L2C32zQ zY248m8;L9cZGZH-FawY7VJB_Me1lo`{7LK4rh)zbw;@E6Ck<`SM9fW^m~bTL&~1f_ zzBREhgecpIj4B4$1u0Kv#(f;SE(KV*Wl1P@Ju=zkZy$3F*?1A0oD7Q00(2P*mlcv|50|Vj*b2@4loE2b`@jH)q|j&q zb*e+Pg`CHT41ZT|VTI6OI*1yt?A`UuewAdP_I~ZrJXtn;2NE8wqUBgawmGNSdtMXt zqxQZXnuxat?+VzSKgc6Iz2ah%lDzUm&RvIBX`5VSM!euWtTY30)-uqaPXPT zXL2ce6FOyoaUR4~B{D^fl!;{C#ju-s$d;hLH#7`7qIFOlc`L{#{;*NPJDGkcxr5D3 zd-A&I(&glh&E9lYU|4Ybz9YP8No}TjWTIKG8ztt5v=tG3pP_*ZeqKYu1pR90&XKa3 z#35pAHC4TGIa0G*#!Y@M@#1*H1j{BmaYU?{V!T`#@vE5Zq&G5nhNPYnwT;nZmRQF% zolxc!NScE}=CMPEy39RoNxz;re{!HG;+c;DYP8+BQ?#)MR;F)vZn?wWju=td zRVCU3=>eZC@BGBHV!@{)z&2_rcM`nn!`Q{M)Hzbg`_;^pBKF`cP2=hq6>lx#delm> zGcyG7gN(k1OBlla+nEf2djWaQr;l5!12H-o+w$n+%z-5Nm>wG`37P1qkgna(1+S2Z z`7VoaEc~kX(INCa-Z`si;xCh}hy-+-2g7CXgy5Vbmi-ZcQFp`Yc-ZoCl*&1X%0d14 zLk^7g4Edp&p*kzcntnP7$(m8KQ#5Q^fta>so8?yK#wruRs(>%<7zAR3jl$x-1oPyZ zLhR@!tEKHUAGyXJqKepTw=xUzWdx|}rMfE<=)teN3LTsm?2QWqFZ$W#x-C*KULJF_ z=_PO51XIL3M76q7&5e|O=b@Hd)<51`{jMR!>gJn%;^oepi4oDQ4SRL9~0rmmUf7;B3rV&#`7_RG!mG{ z+Bh72qSdW3X>26?Q0e8*9bLnp7IdqhQ4=H#pon+@Y0=&&mFkAS?#lKX#eoCivA$XD)=KlEvZ)?_iUWP$*6ka+c5N!2&ri~BXWx*i|{0G z>q?WV%(_H~->N-xH0oJ@rKod#O^_KuX8%x;%h!DdTZ_rr``jdkCv=z3LQ@l})Av?k z`k1Fb2`G|9-}9YO`xZ8kT6A}D*alp*zJ1a7Y;aFf;Y_L#*lG=$OYilE3q&U;MWmQ8 zMhG1HD*nahXgGd%Y|$=^Jm+1mkAXO9K%|fRb>H4}O(rOHV}&J;s_9t&WhG8{?EPL; zW9N^Y;zQa%vB4!LL|u{luXj@!Gk^@6$>U)qI$B(xX!7ZrH5g*}Jf@Iwy9l|>ancWomEMq` zVHPyyHFCehGM$V9w&h&}aon{rptIBo(szZv#k7^oTAhCRtOQuKQY@w@Vf9>Fd>SQA zpmu%c!Lo+Mlrv*aw#1ND(Kd#$^2A!!PWGgQN!@TxYgMg&_L*Od6TCEl^yzZeeogeG z5^IjVPNAeo;akUQgIf8k5$LSuaHgaT#iSv$jMgEa;$U zydbA8S7k(8Nv2-75M(cNZG2v%?PS&wk0fu7h% z_ew_W#k4w^b)HX_94zg$r==*(8j`f#u>t7481x)=opUzxwb`E6)^Ju7bTkc|)A^#} zC|wVPwD;^!Y)#hRAAIp$#&M4z6|Xmu zA^!uN)<~tRG~vubMuO(^W!tppjV?Rgdcla~1*shOGdwb_9tF>1bq{?IQ}N1?9RJ|h zZc^%Qf_&8($?(!sxKz4eD}R=bC|K-)qHFG|^QHp5CLqs{NRfcca-2T0557DjFuFD5 zeHqv%6n%dz|8lZTn}FSG7MFlm393UTO1$wlbYFQxw3OP_&3U}^EwKqb2>C5;iRMRg zob=2MoDY@ljLApwX`8IH-*Cpl@LE(B$F4Of92e(skZ2@z5YJt4&nBGm2H+ZT12Q8N zu3boS3Rz#hQ5_vE1v9=$$8}b1!!K*#F=y%VLmB1{F#pt$W*Za~WEgLbkC+iaqbg$f zk+op_x%{Upl`z7bVjotjWz%tg4d^ritT-o^nB7{a2 ze5AA0+&uhX*1Y2|6Wi(5i=x-&yPL09YF+i+^!kbfAs;$k^(cMrD~pPd@7?B8E>r_s ze{xe~kCRG?6PE8sd^$GqDuH^OPwXrcMLJnP;nhxz)J;Sy&@hu~D?^Op$pto^ESjp^ zE{jjyuvBxEx9~msrgb({_|`@L`Sm?ef&+K)-L$qnj$0nsa6&`!BhwRJ-t%2rWNHBQ zH?iu{8>QL$gn$Rf_aAG_ZQXLyo!coMC@Z$MQ;7OjPlEMI3&cr_2E2))s~uL~X)+sV zW3SA3lzZ)Z^NgrbEyTW^r}hqStNb4UIKRZP|Be#^{>~@-FL{L$Fjk|L zxg(6*r26DLJm_yJg)m~_KZ6whz+U~%0OMw3`vd>#$GyKa?QiK;FkmDLHw^s74Z~By z*jAuFfPenl&ObwrV06=;C@U_WpX47-7>@2Ym=)}=_#I}&0ZUQ&N0`;0$Und8`VO=D zXZ)W(A&!0^JAe5*m7T#(Fjgk$M|9U8P4P39=?PHsC+_D54D^>rVcKE1El!|=}@_XEvI_3AHBkGjjw{!l8>~#7=EkBQU{FbJZ1D5mShd=xV68*g=b(9o;222Tx zxWQnYHs(-D6Z7X*c0z!?x+Vanm6;Ggn@fpJ$zHqCP=Z*w0pII% zG_&AWmz4gsM%X(cfF%@a&kqE;y1KHua z6Aet^kCs^J{Qj7o6YGygv6@1_Kr0;}h?NcayQbef)e2%q`CYTI3B(yH1aNk?GUMkk z1#y^jbMdh7nDT;HIN6PPSWLKiOj$rC7G}mUh7}v9x%qGU?ElctKPiOWfNA7_Sps&& z4`Y^^Ih&e03IW7S9U&&hP)bQFC#aPzjOI(p&B{he4;#v65LYJ#fUqF&dwc%SzTb@V zhob*clVSb(_cnsv_{B(+uq%EE7>*YPD%F5>oe)6v$q#NR7ps}AEv1&Zqtkc0aj~+q zvcn7k6IOx&R4rae!cu4m0lqWnSU~J7AT|v)HhxZaeohb*8;GBc?HAD>^_u@P(f=oA zP*VEu4FLv!cVuIGB_)1Ih^aFemgiPZ@>eG@W8>j4<23`Z7;|v(v2gMlbF%R9nDMai zadUBU@UgR-al=Lv@Za5cW~RTl*xuRE_Q#koGX_go^T8b2 z*xnvSsx^kf`U?niM3{TQZbGe~w&ub=MjR~l$uAeSR^LYuzpb&|b0L5m3oP5Lv9m1{ zAgp8sb66*c1(Z@7;%G+6Lg@%o2BRGs+CiY^PON4S(_b9c*6Py>HiNMZpTh#P|5C*dk?&Rf{@~w@i63RKPmJ$22LAqu1bg>?lgamgD)S#D z|B?m&W3K<0>tC|Kza;!0@A{9q{v`|iOTz#0uK&Nx1zW)Uw(Nni=!F2Tutm+^q=*Ck zJc$mQy?&pM(o6DxpSyzCK`=%wC;N|SD*!faWdQz|v%;oO|GkvP_h}XVKc6uDS|7xb z{=c49GXQ^EGSL71ib4OkC4)W#15nHvY6+|Ex9Jqa&&8vgqqzkZI&96#1N;5^3kHVf z;^3nEe&_oO#LWi-wg0%JwEL}$hm8ZaH2wbiLm4~huX60{Y~KmFf0AQo2XVm`w0|k% zV26GC{^v4on34aXjN>~5{4a7`Tz{40fT{h*GEQz-um0&-4mNHWUHh+PJl_GIf05() zhcr$OAP_ee`s2q^ JD$-c!{|6!;xkdm0 diff --git a/org.glite.deployment.lb/project/.cvsignore b/org.glite.deployment.lb/project/.cvsignore deleted file mode 100644 index caf4eaa..0000000 --- a/org.glite.deployment.lb/project/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -glite-lb.sdf.xml diff --git a/org.glite.deployment.lb/project/build.properties b/org.glite.deployment.lb/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.deployment.lb/project/glite-lb.sdf.xml.template b/org.glite.deployment.lb/project/glite-lb.sdf.xml.template deleted file mode 100644 index 9fd493f..0000000 --- a/org.glite.deployment.lb/project/glite-lb.sdf.xml.template +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.deployment.lb/project/glite-lb.spec b/org.glite.deployment.lb/project/glite-lb.spec deleted file mode 100644 index cf7c650..0000000 --- a/org.glite.deployment.lb/project/glite-lb.spec +++ /dev/null @@ -1,46 +0,0 @@ -Summary:gLite LB node installation package -Name:glite-lb-config -Version:@MODULE.VERSION@ -Release:@MODULE.BUILD@ -Copyright:Open Source EGEE License -Vendor:EU EGEE project -Group:System/Application -Prefix:/opt/glite -BuildArch:noarch -BuildRoot:%{_builddir}/%{name}-%{version} -Requires: glite-lb-common, glite-lb-logger, glite-lb-server, glite-security-proxyrenewal, glite-lb-client-interface, MySQL-server, MySQL-client, expat, ares,vdt_globus_essentials, glite-wms-utils-jobid, glite-wms-utils-exception, myproxy, perl-Expect.pm - -AutoReqProv:no -Source:glite-lb.tar.gz -%define debug_package %{nil} - -%description -gLite Logging and Bookkeeping node installation package - -%prep - - -%setup -c - -%build - - -%install - - -%clean - -%pre -%post -#echo "post install script" -%preun -%postun -%files -%attr(755,root,root) %{prefix}/etc/config/scripts/glite-lb-config.py -%attr(644,root,root) %{prefix}/etc/config/templates/glite-lb.cfg.xml -%attr(644,root,root) %{prefix}/share/doc/glite-lb/release_notes/release_notes.doc -%attr(644,root,root) %{prefix}/share/doc/glite-lb/release_notes/release_notes.pdf -%attr(644,root,root) %{prefix}/share/doc/glite-lb/release_notes/release_notes.html - -%changelog - diff --git a/org.glite.deployment.lb/project/lxscript-rpm.xsl b/org.glite.deployment.lb/project/lxscript-rpm.xsl deleted file mode 100644 index 79eb3dc..0000000 --- a/org.glite.deployment.lb/project/lxscript-rpm.xsl +++ /dev/null @@ -1,254 +0,0 @@ - - - - - - - - - - - - -#!/bin/sh - -# Copyright (c) Members of the EGEE Collaboration. 2004 -# See http://eu-egee.org/partners/ for details on the copyright holders -# For license conditions see the license file or http://eu-egee.org/license.html - -# glite-lb_installer v. -# -# The glite-lb_installer installs the gLite Logging and Bookkeeping Server -# -# Usage: glite-lb_installer [-u|-v|--help] -# -u uninstall -# -v print version -# --help print script usage info -# Return codes: 0 - Ok -# 1 - if a file could not be downloaded - -############################################################################### - -#Parse the RPMLIST to strip out the RPMS that are already installed -function parseRPMList() -{ - newRPMLIST="" - localRPMLIST=`rpm -qa` - for i in $RPMLIST - do - g=`echo $i | sed -e 's/\.i386\.rpm//g'` - g=`echo $g | sed -e 's/\.noarch\.rpm//g'` - if [ -z "`echo $localRPMLIST | grep $g`" ]; then - newRPMLIST="${newRPMLIST} $i" - else - echo "$i is already installed. It will be skipped." - fi - done - - RPMLIST=$newRPMLIST -} - - -#Downloads and install the module RPMS -function install() -{ - version - echo - echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - echo x Please wait, downloading the gLite Logging and Bookkeeping Server... x - echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - echo - - mkdir -p glite-lb - cd glite-lb - - # Download global dependencies - - - true - - - - - - # Download dependencies RPMS from repository - - - true - - - - # Download RPMS from repository - - - true - - - - - - # Install all RPMS - echo - echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - echo x Please wait, installing the gLite Logging and Bookkeeping Server... x - echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - echo - parseRPMList - rpm -Uvh $RPMLIST - echo - echo Done! - echo - echo For more information refer to the gLite Installation and User Guides or to the gLite web site \(http:\/\/www.glite.org\) - echo Please report problems and comments to the gLite Team at project-eu-egee-middleware-integration-support@cern.ch - - cd .. -} - -############################################################################### -function uninstall() -{ - version - - # Global dependencies - - - false - - - - - - # dependencies RPMS from repository - - - false - - - - # RPMS from repository - - - false - - - - - - # Uninstall all RPMS - echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - echo x Please wait, uninstalling the gLite Logging and Bookkeeping Server... x - echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - echo - rpm -ev $RPMLIST - echo - echo Done! -} - -############################################################################### -function usage() -{ - echo - echo Copyright \(c\) Members of the EGEE Collaboration. 2004 - echo See http://eu-egee.org/partners/ for details on the copyright holders - echo For license conditions see the license file or http://eu-egee.org/license.html - echo - echo glite-lb_installer v. - echo - echo The glite-lb_installer installs the gLite Logging and Bookkeeping Server - echo - echo Usage: glite-lb_installer \[-u\|-v\|--help\] - echo -u uninstall - echo -v print version - echo --help print script usage info - echo - echo Return codes: - echo 0 - Ok - echo 1 - if a file could not be downloaded - echo -} - -############################################################################### -function version -{ - echo - echo Copyright \(c\) Members of the EGEE Collaboration. 2004 - echo See http://eu-egee.org/partners/ for details on the copyright holders - echo For license conditions see the license file or http://eu-egee.org/license.html - echo - echo glite-lb_installer v. - echo -} - - -RPMLIST= - -############################################################################### -# Main - -while getopts uvh opt -do - case $opt in - 'u') uninstall - exit 0 - ;; - 'v') version - exit 0 - ;; - 'h') usage - exit 0 - ;; - esac -done - -install - -exit 0 - - - - - --..rpm - -- - - -wget -N --non-verbose -if [ ! -f "" ] -then - echo - echo ERROR: could not be downloaded! - exit 1 -fi -RPMLIST="$RPMLIST " - - -RPMLIST="$RPMLIST " - - - - - - - --..rpm - -- - - -wget -N --non-verbose /RPMS/ -if [ ! -f "" ] -then - echo - echo ERROR: could not be downloaded! - exit 1 -fi -RPMLIST="$RPMLIST " - - -RPMLIST="$RPMLIST " - - - - - diff --git a/org.glite.deployment.lb/project/lxscript-tgz.xsl b/org.glite.deployment.lb/project/lxscript-tgz.xsl deleted file mode 100644 index 5b55e40..0000000 --- a/org.glite.deployment.lb/project/lxscript-tgz.xsl +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - -#!/bin/sh -# -# glite-lb_tgz_installer -# usage: glite-lb_tgz_installer [-u] -# -u uninstall -# -# glite-lb_tgz_installer installs the gLite Deployment Unit from biniary tarballs -# - -PREFIX=/opt/glite - -############################################################################### -# Download global dependencies - - - -############################################################################### - - -############################################################################### -# Download dependencies RPMS from repository - - - -############################################################################### -# Download RPMS from repository - - - -############################################################################### - - - - - - --..rpm -wget - - - - -_bin.tar.gz -wget i386/tgz/ -tar -xzf $PREFIX - - - diff --git a/org.glite.deployment.lb/project/properties.xml b/org.glite.deployment.lb/project/properties.xml deleted file mode 100644 index 638f02b..0000000 --- a/org.glite.deployment.lb/project/properties.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.deployment.lb/project/quattor-template.xsl b/org.glite.deployment.lb/project/quattor-template.xsl deleted file mode 100644 index e0bd623..0000000 --- a/org.glite.deployment.lb/project/quattor-template.xsl +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - -template pro_software_glite_lb; - -# -# Copyright (c) Members of the EGEE Collaboration. 2004 -# See http://eu-egee.org/partners/ for details on the copyright holders -# For license conditions see the license file or http://eu-egee.org/license.html -# -# glite-lb Quattor template v. -# - -# Global dependencies - - - - - - -# dependencies - - - - -# RPMS - - - - - - - - -"/software/packages"=pkg_repl("","-",""); - - - -"/software/packages"=pkg_repl("","-",""); - - - diff --git a/org.glite.deployment.lb/project/version.properties b/org.glite.deployment.lb/project/version.properties deleted file mode 100644 index 61f3e64..0000000 --- a/org.glite.deployment.lb/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Dec 09 08:14:11 CET 2004 -module.version=0.2.0 -module.build=68 -module.age=1 diff --git a/org.glite.jp.common/.cvsignore b/org.glite.jp.common/.cvsignore deleted file mode 100644 index 3a4edf6..0000000 --- a/org.glite.jp.common/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -.project diff --git a/org.glite.jp.common/Makefile b/org.glite.jp.common/Makefile deleted file mode 100644 index 8626261..0000000 --- a/org.glite.jp.common/Makefile +++ /dev/null @@ -1,85 +0,0 @@ -# defaults -top_srcdir=. -builddir=build -top_builddir=${top_srcdir}/${builddir} -stagedir=. -distdir=. -globalprefix=glite -lbprefix=lb -package=glite-jp-common -version=0.0.0 -PREFIX=/opt/glite - -glite_location=/opt/glite -globus_prefix=/opt/globus -nothrflavour=gcc32 -thrflavour=gcc32pthr -expat_prefix=/opt/expat -ares_prefix=/opt/ares -gsoap_prefix=/software/gsoap-2.6 - -CC=gcc - --include Makefile.inc - - -VPATH=${top_srcdir}/src:${top_srcdir}/test:${top_srcdir}/project:${jpproject} - -GLOBUSINC:= -I${globus_prefix}/include/${nothrflavour} - - -DEBUG:=-g -O0 -CFLAGS:=${DEBUG} -I. -I${top_srcdir}/interface -I${stagedir}/include \ - ${GLOBUSINC} - -LINK:=libtool --mode=link ${CC} ${LDFLAGS} -rpath ${stagedir}/lib -LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} -INSTALL:=libtool --mode=install install -COMPILE:=libtool --mode=compile ${CC} ${CFLAGS} - -HDRS:=types.h context.h strmd5.h - -SRCS:=context.c strmd5.c -OBJS:=${SRCS:.c=.lo} - -commonlib:= libglite_jp_common.la - -default all: compile - -compile: ${commonlib} - -${commonlib}: ${OBJS} - ${LINK} -o $@ ${OBJS} - -check: - -echo nothing yet - -doc: - -stage: compile - $(MAKE) install PREFIX=${stagedir} - -install: - -mkdir -p ${PREFIX}/include/${globalprefix}/${jpprefix} - cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${jpprefix} - -mkdir -p ${PREFIX}/lib - ${INSTALL} -m 755 ${commonlib} ${PREFIX}/lib - -dist: distsrc distbin - -# FIXME: just copied from LB -distsrc: - mkdir -p ${top_srcdir}/${package}-${version} - cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version} - cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version} - rm -rf ${top_srcdir}/${package}-${version} - -distbin: - $(MAKE) install PREFIX=`pwd`/tmpbuilddir${stagedir} - save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir - rm -rf tmpbuilddir - -clean: - -%.lo: %.c - ${COMPILE} -o $@ -c $< diff --git a/org.glite.jp.common/build.xml b/org.glite.jp.common/build.xml deleted file mode 100755 index f20263f..0000000 --- a/org.glite.jp.common/build.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.jp.common/interface/context.h b/org.glite.jp.common/interface/context.h deleted file mode 100644 index 20effb2..0000000 --- a/org.glite.jp.common/interface/context.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __GLITE_JP_CONTEXT -#define __GLITE_JP_CONTEXT - -int glite_jp_init_context(glite_jp_context_t *); -void glite_jp_free_query_rec(glite_jp_query_rec_t *); - -char *glite_jp_peer_name(glite_jp_context_t); -char *glite_jp_error_chain(glite_jp_context_t); - -int glite_jp_stack_error(glite_jp_context_t, const glite_jp_error_t *); -int glite_jp_clear_error(glite_jp_context_t); - -int glite_jp_add_deferred(glite_jp_context_t,int (*)(glite_jp_context_t,void *),void *); -int glite_jp_run_deferred(glite_jp_context_t); - - -#endif diff --git a/org.glite.jp.common/interface/strmd5.h b/org.glite.jp.common/interface/strmd5.h deleted file mode 100755 index c5d76b6..0000000 --- a/org.glite.jp.common/interface/strmd5.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _GLITE_STRMD5_H -#define _GLITE_STRMD5_H - -#ident "$Header$" - -/* Compute MD5 sum of the first argument. - * The sum is returned in the 16-byte array pointed to by 2nd argument - * (if not NULL) - * - * Return value: ASCII string of the sum, i.e. 32 characters [0-9a-f] - * (pointer to static area, changed by subsequent calls) - */ - -char *strmd5(const char *src, unsigned char *dst); - -/** - * Returns: allocated 32bytes long ASCII string with md5 sum - * of the first argument - */ -char *str2md5(const char *src); - -/** - * Returns: allocated 22bytes long ASCII string with md5 sum in base64 - * format of the source argument - */ -char *str2md5base64(const char *src); - -#endif /* _GLITE_STRMD5_H */ diff --git a/org.glite.jp.common/interface/types.h b/org.glite.jp.common/interface/types.h deleted file mode 100644 index 70e8482..0000000 --- a/org.glite.jp.common/interface/types.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef __GLITE_JP_TYPES -#define __GLITE_JP_TYPES - -#include - -typedef struct _glite_jp_error_t { - int code; - char *desc; - char *source; - struct _glite_jp_error_t *reason; -} glite_jp_error_t; - -typedef struct _glite_jp_context { - glite_jp_error_t *error; - int (**deferred_func)(struct _glite_jp_context *,void *); - void **deferred_arg; - void *feeds; - struct soap *other_soap; -} *glite_jp_context_t; - -typedef enum { - GLITE_JP_FILECLASS_UNDEF, - GLITE_JP_FILECLASS_INPUT, - GLITE_JP_FILECLASS_OUTPUT, - GLITE_JP_FILECLASS_LBLOG, - GLITE_JP_FILECLASS_TAGS, - GLITE_JP_FILECLASS__LAST -} glite_jp_fileclass_t; - -typedef struct { - char *name; - int sequence; - time_t timestamp; - int binary; - size_t size; - char *value; -} glite_jp_tagval_t; - -typedef enum { - GLITE_JP_ATTR_UNDEF, - GLITE_JP_ATTR_OWNER, - GLITE_JP_ATTR_TIME, - GLITE_JP_ATTR_TAG, - GLITE_JP_ATTR__LAST -} glite_jp_attrtype_t; - -typedef struct { - glite_jp_attrtype_t type; - char *name; -} glite_jp_attr_t; - -typedef struct { - glite_jp_attr_t attr; - union { - char *s; - int i; - struct timeval time; - glite_jp_tagval_t tag; - } value; -} glite_jp_attrval_t; - - -typedef enum { - GLITE_JP_QUERYOP_UNDEF, - GLITE_JP_QUERYOP_EQUAL, - GLITE_JP_QUERYOP_UNEQUAL, - GLITE_JP_QUERYOP_LESS, - GLITE_JP_QUERYOP_GREATER, - GLITE_JP_QUERYOP_WITHIN, - GLITE_JP_QUERYOP__LAST, -} glite_jp_queryop_t; - -typedef struct { - glite_jp_attr_t attr; - glite_jp_queryop_t op; - union _glite_jp_query_rec_val { - char *s; - int i; - struct timeval time; - } value,value2; -} glite_jp_query_rec_t; - -#endif diff --git a/org.glite.jp.common/project/build.properties b/org.glite.jp.common/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.jp.common/project/configure.properties.xml b/org.glite.jp.common/project/configure.properties.xml deleted file mode 100644 index 5f0ea37..0000000 --- a/org.glite.jp.common/project/configure.properties.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - -top_srcdir=.. -builddir=build -stagedir=${stage.abs.dir} -distdir=${dist.dir} -globalprefix=${global.prefix} -jpprefix=${subsystem.prefix} -package=${module.package.name} -PREFIX=${install.dir} -version=${module.version} -glite_location=${with.glite.location} -globus_prefix=${with.globus.prefix} -expat_prefix=${with.expat.prefix} -gsoap_prefix=${with.gsoap.prefix} -ares_prefix=${with.ares.prefix} -thrflavour=${with.globus.thr.flavor} -nothrflavour=${with.globus.nothr.flavor} -cppunit=${with.cppunit.prefix} -jpproject=${subsystem.project.dir} -project=${component.project.dir} - - - diff --git a/org.glite.jp.common/project/properties.xml b/org.glite.jp.common/project/properties.xml deleted file mode 100755 index b9d669d..0000000 --- a/org.glite.jp.common/project/properties.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.jp.common/project/tar_exclude b/org.glite.jp.common/project/tar_exclude deleted file mode 100644 index e1fcd1a..0000000 --- a/org.glite.jp.common/project/tar_exclude +++ /dev/null @@ -1,10 +0,0 @@ -tar_exclude -CVS -build.xml -build -build.properties -properties.xml -configure.properties.xml -.cvsignore -.project -.cdtproject diff --git a/org.glite.jp.common/project/version.properties b/org.glite.jp.common/project/version.properties deleted file mode 100644 index eaa791a..0000000 --- a/org.glite.jp.common/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Nov 25 20:14:56 CET 2004 -module.version=0.1.0 -module.build=2 -module.age=1 diff --git a/org.glite.jp.common/src/context.c b/org.glite.jp.common/src/context.c deleted file mode 100644 index 016bc59..0000000 --- a/org.glite.jp.common/src/context.c +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include - -#include "types.h" -#include "context.h" - -int glite_jp_init_context(glite_jp_context_t *ctx) -{ - *ctx = calloc(1,sizeof **ctx); -} - -char *glite_jp_peer_name(glite_jp_context_t ctx) -{ - return strdup("unknown"); -} - -char *glite_jp_error_chain(glite_jp_context_t ctx) -{ - char *ret = NULL,indent[300] = ""; - int len = 0,add; - char buf[2000]; - - glite_jp_error_t *ep = ctx->error; - - do { - add = snprintf(buf,sizeof buf,"%s%s: %s (%s)\n", - indent, - ep->source, - strerror(ep->code), - ep->desc ? ep->desc : ""); - ret = realloc(ret,len + add + 1); - strncpy(ret + len,buf,add); ret[len += add] = 0; - strcat(indent," "); - } while (ep = ep->reason); - - return ret; -} - -int glite_jp_stack_error(glite_jp_context_t ctx, const glite_jp_error_t *err) -{ - glite_jp_error_t *reason = ctx->error; - - ctx->error = calloc(1,sizeof *ctx->error); - ctx->error->code = err->code; - ctx->error->desc = err->desc ? strdup(err->desc) : NULL; - ctx->error->source = err->source ? strdup(err->source) : NULL; - ctx->error->reason = reason; - - return err->code; -} - -int glite_jp_clear_error(glite_jp_context_t ctx) -{ - glite_jp_error_t *e = ctx->error, *r; - - while (e) { - r = e->reason; - free(e->source); - free(e->desc); - free(e); - e = r; - } - ctx->error = NULL; - return 0; -} - - -void glite_jp_free_query_rec(glite_jp_query_rec_t *q) -{ - free(q->attr.name); q->attr.name = NULL; - switch (q->attr.type) { - case GLITE_JP_ATTR_OWNER: - case GLITE_JP_ATTR_TAG: - free(q->value.s); q->value.s = NULL; - if (q->op == GLITE_JP_QUERYOP_WITHIN) { - free(q->value2.s); - q->value2.s = NULL; - } - break; - default: break; - } -} - -int glite_jp_attr_copy(glite_jp_attr_t *dst,const glite_jp_attr_t *src) -{ - dst->name = src->name ? strdup(src->name) : NULL; - dst->type = src->type; - return 0; -} - -int glite_jp_queryrec_copy(glite_jp_query_rec_t *dst, const glite_jp_query_rec_t *src) -{ - glite_jp_attr_copy(&dst->attr,&src->attr); - dst->op = src->op; - switch (src->attr.type) { - case GLITE_JP_ATTR_OWNER: - case GLITE_JP_ATTR_TAG: - dst->value.s = strdup(src->value.s); - if (dst->op == GLITE_JP_QUERYOP_WITHIN) - dst->value2.s = strdup(src->value2.s); - break; - case GLITE_JP_ATTR_TIME: - memcpy(&dst->value.time,&src->value.time,sizeof dst->value.time); - if (dst->op == GLITE_JP_QUERYOP_WITHIN) - memcpy(&dst->value2.time,&src->value2.time,sizeof dst->value2.time); - break; - } - return 0; -} - -int glite_jp_run_deferred(glite_jp_context_t ctx) -{ - int i,cnt,ret; - - if (!ctx->deferred_func) return 0; - - glite_jp_clear_error(ctx); - for (cnt=0;ctx->deferred_func[cnt];cnt++); - for (i=0; ideferred_func)(ctx,*ctx->deferred_arg)) { - glite_jp_error_t err; - char desc[100]; - - sprintf(desc,"calling func #%d, %p",i,*ctx->deferred_func); - err.code = ret; - err.desc = desc; - err.source = "glite_jp_run_deferred()"; - - glite_jp_stack_error(ctx,&err); - return ret; - } - else { - memmove(ctx->deferred_func,ctx->deferred_func+1, - (cnt-i) * sizeof *ctx->deferred_func); - memmove(ctx->deferred_arg,ctx->deferred_arg+1, - (cnt-i) * sizeof *ctx->deferred_arg); - } - } - free(ctx->deferred_func); ctx->deferred_func = NULL; - free(ctx->deferred_arg); ctx->deferred_arg = NULL; - return 0; -} - -int glite_jp_add_deferred( - glite_jp_context_t ctx, - int (*func)(glite_jp_context_t, void *), - void *arg -) -{ - int (**v)(glite_jp_context_t, void *) = ctx->deferred_func; - int i; - - for (i=0; v && *v; i++); - - ctx->deferred_func = realloc(ctx->deferred_func, (i+1) * sizeof *ctx->deferred_func); - ctx->deferred_func[i] = func; - ctx->deferred_func[i+1] = NULL; - - ctx->deferred_arg = realloc(ctx->deferred_arg,(i+1) * sizeof *ctx->deferred_arg); - ctx->deferred_arg[i] = arg; - ctx->deferred_arg[i+1] = NULL; - - return 0; -} diff --git a/org.glite.jp.common/src/strmd5.c b/org.glite.jp.common/src/strmd5.c deleted file mode 100755 index 87fd400..0000000 --- a/org.glite.jp.common/src/strmd5.c +++ /dev/null @@ -1,115 +0,0 @@ -#include -#include -#include -#include - -#include "strmd5.h" - -static char mbuf[33]; - -static int base64_encode(const void *enc, int enc_size, char *out, int out_max_size) -{ - static const char* b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; - - unsigned char* enc_buf = (unsigned char*)enc; - int out_size = 0; - unsigned int bits = 0; - unsigned int shift = 0; - - while ( out_size < out_max_size ) { - if ( enc_size>0 ) { - // Shift in byte - bits <<= 8; - bits |= *enc_buf; - shift += 8; - // Next byte - enc_buf++; - enc_size--; - } else if ( shift>0 ) { - // Pad last bits to 6 bits - will end next loop - bits <<= 6 - shift; - shift = 6; - } else { - // Terminate with Mime style '=' - *out = '='; - out_size++; - - return out_size; - } - - // Encode 6 bit segments - while ( shift>=6 ) { - shift -= 6; - *out = b64[ (bits >> shift) & 0x3F ]; - out++; - out_size++; - } - } - - // Output overflow - return -1; -} - -char *strmd5(const char *s, unsigned char *digest) -{ - MD5_CTX md5; - unsigned char d[16]; - int i; - - MD5_Init(&md5); - MD5_Update(&md5,s,strlen(s)); - MD5_Final(d,&md5); - - if (digest) memcpy(digest,d,sizeof(d)); - - for (i=0; i<16; i++) { - int dd = d[i] & 0x0f; - mbuf[2*i+1] = dd<10 ? dd+'0' : dd-10+'a'; - dd = d[i] >> 4; - mbuf[2*i] = dd<10 ? dd+'0' : dd-10+'a'; - } - mbuf[32] = 0; - return (char *) mbuf; -} - -char *str2md5(const char *s) -{ - MD5_CTX md5; - unsigned char d[16]; - char* ret = malloc(33); - int i; - - if (!ret) - return NULL; - - MD5_Init(&md5); - MD5_Update(&md5, s, strlen(s)); - MD5_Final(d, &md5); - - for (i=0; i<16; i++) { - int dd = d[i] & 0x0f; - ret[2*i+1] = dd<10 ? dd+'0' : dd-10+'a'; - dd = d[i] >> 4; - ret[2*i] = dd<10 ? dd+'0' : dd-10+'a'; - } - ret[32] = 0; - return ret; -} - -char *str2md5base64(const char *s) -{ - MD5_CTX md5; - unsigned char d[16]; - char buf[50]; - int l; - - MD5_Init(&md5); - MD5_Update(&md5, s, strlen(s)); - MD5_Final(d, &md5); - - l = base64_encode(d, 16, buf, sizeof(buf) - 1); - if (l < 1) - return NULL; - buf[l - 1] = 0; - return strdup(buf); -} diff --git a/org.glite.jp.index/.cvsignore b/org.glite.jp.index/.cvsignore deleted file mode 100644 index 3a4edf6..0000000 --- a/org.glite.jp.index/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -.project diff --git a/org.glite.jp.index/Makefile b/org.glite.jp.index/Makefile deleted file mode 100644 index 3b893cd..0000000 --- a/org.glite.jp.index/Makefile +++ /dev/null @@ -1,129 +0,0 @@ -# defaults -top_srcdir=. -builddir=build -top_builddir=${top_srcdir}/${builddir} -stagedir=. -distdir=. -globalprefix=glite -lbprefix=lb -package=glite-lb-server -version=0.0.0 -PREFIX=/opt/glite - -glite_location=/opt/glite -globus_prefix=/opt/globus -nothrflavour=gcc32 -thrflavour=gcc32pthr -expat_prefix=/opt/expat -ares_prefix=/opt/ares -gsoap_prefix=/software/gsoap-2.6 - -CC=gcc - --include Makefile.inc - - -VPATH=${top_srcdir}/src:${top_srcdir}/examples:${top_srcdir}/test:${top_srcdir}/project:${jpproject} - -GLOBUS_LIBS:=-L${globus_prefix}/lib \ - -lglobus_common_${nothrflavour} \ - -lglobus_gssapi_gsi_${nothrflavour} - -DEBUG:=-g -O0 -DDEBUG - -CFLAGS:=${DEBUG} -I. -I${gsoap_prefix}/include -I${stagedir}/include -LDFLAGS:=-L${stagedir}/lib - -LINK:=libtool --mode=link ${CC} ${LDFLAGS} -LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} -INSTALL:=libtool --mode=install install - - -daemon:=glite-jp-indexd -example:=jpis-test -soap_prefix:=jpis_ - -SRCS:= simple_server.c soap_ops.c \ - ${soap_prefix}C.c \ - ${soap_prefix}Server.c - -EXA_SRCS:=jpis-test.c ${soap_prefix}C.c ${soap_prefix}Client.c - - -OBJS:=${SRCS:.c=.o} stdsoap2.o -EXA_OBJS:=${EXA_SRCS:.c=.o} stdsoap2.o - -COMMONLIB:=-lglite_jp_common - -default all: compile - -compile: ${daemon} ${example} - -${daemon}: ${OBJS} - ${LINK} -o $@ ${OBJS} ${COMMONLIB} ${GLOBUS_LIBS} - -${example}: ${EXA_OBJS} - ${LINK} -o $@ ${EXA_OBJS} - -JobProvenanceIS.xh: JobProvenanceIS.wsdl JobProvenanceTypes.wsdl typemap.dat - cp ${jpproject}/JobProvenanceTypes.wsdl . - ${gsoap_prefix}/bin/wsdl2h -t ${top_srcdir}/src/typemap.dat -c -o $@ $< - rm -f JobProvenanceTypes.wsdl - -${soap_prefix}C.c ${soap_prefix}H.h: JobProvenanceIS.xh - ${gsoap_prefix}/bin/soapcpp2 -w -c -p ${soap_prefix} JobProvenanceIS.xh - -#$(SOAP_PREFIX)H.h $(SOAP_PREFIX)C.c: LB.xh -# $(GSOAP_BIN_PATH)/soapcpp2 -w -c -p $(SOAP_PREFIX) LB.xh -# -#LB.xh: LB.wsdl typemap.dat -# $(GSOAP_BIN_PATH)/wsdl2h -c -o $@ LB.wsdl -# - - -check: - -echo nothing yet - -doc: - -stage: compile - ${INSTALL} -m 755 ${daemon} ${stagedir}/bin - -dist: distsrc distbin - -# FIXME: just copied from LB -distsrc: - mkdir -p ${top_srcdir}/${package}-${version} - cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version} - cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version} - rm -rf ${top_srcdir}/${package}-${version} - -distbin: - $(MAKE) install PREFIX=`pwd`/tmpbuilddir${stagedir} - save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir - rm -rf tmpbuilddir - -install: - -mkdir -p ${PREFIX}/bin ${PREFIX}/etc ${PREFIX}/etc/init.d - for p in bkserverd bkindex; do \ - ${INSTALL} -m 755 "glite_lb_$$p" "${PREFIX}/bin/glite-lb-$$p"; \ - done - - for f in dbsetup.sql index.conf.template; do \ - ${INSTALL} -m 644 ${top_srcdir}/config/"glite-lb-$$f" ${PREFIX}/etc; \ - done - - ${INSTALL} -m 755 ${top_srcdir}/config/startup ${PREFIX}/etc/init.d/glite-lb-bkserverd - -clean: - -soap_ops.o jpis-test.o simple_server.o: ${soap_prefix}H.h - -# we have no real config.h but have to force gSoap not to use -# linux ftime with broken (aka obsolete) DST information - -stdsoap2.o: ${gsoap_prefix}/devel/stdsoap2.c - test -f config.h || touch config.h - @echo 'The following warning "time_t (de)serialization is not MT safe on this platform" is harmless' - ${CC} -o $@ -c -DHAVE_CONFIG_H ${CFLAGS} ${gsoap_prefix}/devel/stdsoap2.c - diff --git a/org.glite.jp.index/build.xml b/org.glite.jp.index/build.xml deleted file mode 100755 index 547659a..0000000 --- a/org.glite.jp.index/build.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.jp.index/project/JobProvenanceIS.wsdl b/org.glite.jp.index/project/JobProvenanceIS.wsdl deleted file mode 100644 index 26f97a4..0000000 --- a/org.glite.jp.index/project/JobProvenanceIS.wsdl +++ /dev/null @@ -1,531 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Register job with JP primary storage. -Job registration in LB is propagated to JP immediately so that JP is aware of the job, -despite no furhter information is available in it. - -Input: JobId - -Output: N/A - -Faults: GenericJPFault - - - - - - - Initiate upload of of sandbox/dump of job life log from LB. -WM component responsible for job sandbox management and LB server call JP to declare -intention to upload intput/output sandbox and job life log. - -Input: - -uclass: type of the upload - INPUT_SANDBOX, OUTPUT_SANDBOX, JOB_LOG - -commitTimeout: upper limit on time for which JP waits for committing this upload transaction - -contentType: MIME type of the uploaded file - -Output: - -destination: URL where the client should upload the file - -commitBefore: acutual time when the upload transaction times out - -Faults: GenericJPFault - - -Initiate upload of of sandbox/dump of job life log from LB. - - - - - - Confirm upload. -Should be called after a file upload initiaded with StartUpload is finished. - -Input: - -destination: Upload destination URL (to match with the original request) - -Output: - -Faults: GenericJPFault - - - - - - - Record a value of user tag. -JP tags are either standalone or override values of their LB counterparts. -However, JP tag values are still distinguishable those inherited from LB. -JP tags may be either strings or blobs. - -Input: - -jobid: - -tag: structure containing name, timestamp, optional sequence number to order tag values -without relying on timestamps, and string or blob value. - -Output: N/A - -Faults: GenericJPFault - - - - - - - Start feeding JP index server. -Called by the index server to start batch feed, and optionally also subscribe for incremental feed. - -JP index server subscribes with JP primary storage using a query -containing conditions on primary metadata and a list of queryable attributes -of the index server (i.e. data which should be sent to the index server). - -When a matching job record is created or modified within the primary storage -the job record data are sent to the subscribed index server. - -The subscription is soft-state, it expires after certain time unless refreshed by the client explicitely. - -In the batch mode the query has the same form -with additional flag asking for all matching records (i.e.\ not only -arriving afterwards). - -Input: - -destination: where to send the job record data - -attributes: which job record attributes should be sent to the requesting index server - -conditions: list of query conditions. Each conditions has the form Attribute Operator Value, -where Attribute is any of job record attributes and Operator is one of EQUAL, UNEQUAL, LESS, GREATER, WITHIN. - -continuous: flag determining that the query is incremental (not batch) - -Output: - -feedId: unique Id of the feed request, to be used in refresh, cancelation etc. - -expires: when the feed times out. Must be refreshed before this time. - -Faults: GenericJPFault - - - - - - - Extend batch feed subscription (used by index server) - -Input: feedId returned previously by FeedIndex - -Output: the same as for FeedIndex - -Faults: GenericJPFault - - - - - - - Retrieve job record URL's when jobid is known -Used either to bypass JP index server query for this specific case, or after the index server query to -retrieve actual job record. - -Input: jobid - -Output: - -jobLog, inputSandbox, outputSandbox, tags: URL's to components of the job record. - -Faults: GenericJPFault - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Job Provenance Primary Storage service - - - - - - - - - - - - - - - - - - - - - - Store or update information on jobs within the JP index server. -Called directly by the primary storage, used for both batch and incremental feed. - -Input: - -data: list of job record updates. Each contains jobid, list of JP attribute values and user tag values. - -feedDone: flag indicating end of batch feed. (In order to avoid potential problems with buffer allocation -the huge dataset of batch feed is split into reasonable chunks and delivered with more UpdateJobs calls.) - -Output: N/A - -Faults: GenericJPFault - - - - - - - - - Retrieve pointers to job records of jobs matching a query. -Input: conditions - list of lists of query conditions. - Elements of the inner lists refer to a single job attribute, the conditions are or-ed. - Elements of the outer list may refer to different job attributes, they are and-ed. - -Output: - -jobs: list of JobId, PSContact (URL of the primary storage which manges this job) pairs - -Faults: GenericJPFault - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Job Provenance Index service - - - - - - - diff --git a/org.glite.jp.index/project/build.properties b/org.glite.jp.index/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.jp.index/project/configure.properties.xml b/org.glite.jp.index/project/configure.properties.xml deleted file mode 100644 index 72af8f4..0000000 --- a/org.glite.jp.index/project/configure.properties.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - -top_srcdir=.. -builddir=build -stagedir=${stage.abs.dir} -distdir=${dist.dir} -globalprefix=${global.prefix} -lbprefix=${subsystem.prefix} -package=${module.package.name} -PREFIX=${install.dir} -version=${module.version} -glite_location=${with.glite.location} -globus_prefix=${with.globus.prefix} -expat_prefix=${with.expat.prefix} -gsoap_prefix=${with.gsoap.prefix} -ares_prefix=${with.ares.prefix} -thrflavour=${with.globus.thr.flavor} -nothrflavour=${with.globus.nothr.flavor} -cppunit=${with.cppunit.prefix} -jpproject=${subsystem.project.dir} -project=${component.project.dir} - - - diff --git a/org.glite.jp.index/project/properties.xml b/org.glite.jp.index/project/properties.xml deleted file mode 100755 index 5f56392..0000000 --- a/org.glite.jp.index/project/properties.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.jp.index/project/tar_exclude b/org.glite.jp.index/project/tar_exclude deleted file mode 100644 index e1fcd1a..0000000 --- a/org.glite.jp.index/project/tar_exclude +++ /dev/null @@ -1,10 +0,0 @@ -tar_exclude -CVS -build.xml -build -build.properties -properties.xml -configure.properties.xml -.cvsignore -.project -.cdtproject diff --git a/org.glite.jp.index/project/version.properties b/org.glite.jp.index/project/version.properties deleted file mode 100644 index 7911996..0000000 --- a/org.glite.jp.index/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Sun Nov 21 09:03:32 CET 2004 -module.version=0.1.0 -module.build=1 -module.age=1 diff --git a/org.glite.jp.index/src/simple_server.c b/org.glite.jp.index/src/simple_server.c deleted file mode 100644 index ccaa5a7..0000000 --- a/org.glite.jp.index/src/simple_server.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "glite/jp/types.h" -#include "glite/jp/context.h" - -#include "jpis_H.h" - -int main() { - struct soap soap; - int i, m, s; // master and slave sockets - - glite_jp_context_t ctx; - - soap_init(&soap); - glite_jp_init_context(&ctx); - soap.user = (void *) ctx; - - srand48(time(NULL)); /* feed id generation */ - - m = soap_bind(&soap, NULL, 8902, 100); - if (m < 0) - soap_print_fault(&soap, stderr); - else - { - fprintf(stderr, "Socket connection successful: master socket = %d\n", m); - for (i = 1; ; i++) { - s = soap_accept(&soap); - if (s < 0) { - soap_print_fault(&soap, stderr); - break; - } - soap_serve(&soap); // process RPC request - soap_destroy(&soap); // clean up class instances - soap_end(&soap); // clean up everything and close socket - glite_jp_run_deferred(ctx); - } - } - soap_done(&soap); // close master socket - - return 0; -} diff --git a/org.glite.jp.index/src/soap_ops.c b/org.glite.jp.index/src/soap_ops.c deleted file mode 100644 index 5af7352..0000000 --- a/org.glite.jp.index/src/soap_ops.c +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include - -#include "glite/jp/types.h" -#include "glite/jp/context.h" - -#include "jpis_H.h" -#include "JobProvenanceIS.nsmap" - -static struct jptype__GenericJPFaultType *jp2s_error(struct soap *soap, - const glite_jp_error_t *err) -{ - struct jptype__GenericJPFaultType *ret = NULL; - if (err) { - ret = soap_malloc(soap,sizeof *ret); - memset(ret,0,sizeof *ret); - ret->code = err->code; - ret->source = soap_strdup(soap,err->source); - ret->text = soap_strdup(soap,strerror(err->code)); - ret->description = soap_strdup(soap,err->desc); - ret->reason = jp2s_error(soap,err->reason); - } - return ret; -} - -static void err2fault(const glite_jp_context_t ctx,struct soap *soap) -{ - char *et; - struct SOAP_ENV__Detail *detail = soap_malloc(soap,sizeof *detail); - struct _GenericJPFault *f = soap_malloc(soap,sizeof *f); - - - f->jptype__GenericJPFault = jp2s_error(soap,ctx->error); - - detail->__type = SOAP_TYPE__GenericJPFault; - detail->value = f; - detail->__any = NULL; - - soap_receiver_fault(soap,"Oh, shit!",NULL); - if (soap->version == 2) soap->fault->SOAP_ENV__Detail = detail; - else soap->fault->detail = detail; -} - -static void s2jp_tag(const struct jptype__TagValue *stag,glite_jp_tagval_t *jptag) -{ - memset(jptag,0,sizeof *jptag); - jptag->name = strdup(stag->name); - jptag->sequence = stag->sequence ? *stag->sequence : 0; - jptag->timestamp = stag->timestamp ? *stag->timestamp : 0; - if (stag->stringValue) jptag->value = strdup(stag->stringValue); - else if (stag->blobValue) { - jptag->binary = 1; - jptag->size = stag->blobValue->__size; - jptag->value = (char *) stag->blobValue->__ptr; - } -} - -#define CONTEXT_FROM_SOAP(soap,ctx) glite_jp_context_t ctx = (glite_jp_context_t) ((soap)->user) - -SOAP_FMAC5 int SOAP_FMAC6 jpsrv__UpdateJobs( - struct soap *soap, - char *feed_id, - struct jptype__UpdateJobsData *jobs, - enum xsd__boolean done -) -{ - printf("%s items %d jobid %s\n",__FUNCTION__,jobs->__sizejob, - jobs->job[0]->jobid); - return SOAP_OK; -} - -SOAP_FMAC5 int SOAP_FMAC6 jpsrv__QueryJobs( - struct soap *soap, - struct jptype__IndexQuery *query, - struct jpsrv__QueryJobsResponse *resp -) -{ - puts(__FUNCTION__); - return SOAP_OK; -} - diff --git a/org.glite.jp.index/src/typemap.dat b/org.glite.jp.index/src/typemap.dat deleted file mode 100644 index 7032cb2..0000000 --- a/org.glite.jp.index/src/typemap.dat +++ /dev/null @@ -1,2 +0,0 @@ -jpsrv = http://glite.org/wsdl/services/jp -jptype = http://glite.org/wsdl/types/jp diff --git a/org.glite.jp.primary/.cvsignore b/org.glite.jp.primary/.cvsignore deleted file mode 100644 index 3a4edf6..0000000 --- a/org.glite.jp.primary/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -.project diff --git a/org.glite.jp.primary/Makefile b/org.glite.jp.primary/Makefile deleted file mode 100644 index 0db5174..0000000 --- a/org.glite.jp.primary/Makefile +++ /dev/null @@ -1,155 +0,0 @@ -# defaults -top_srcdir=. -builddir=build -top_builddir=${top_srcdir}/${builddir} -stagedir=. -distdir=. -globalprefix=glite -lbprefix=lb -package=glite-lb-server -version=0.0.0 -PREFIX=/opt/glite - -glite_location=/opt/glite -globus_prefix=/opt/globus -nothrflavour=gcc32 -thrflavour=gcc32pthr -expat_prefix=/opt/expat -ares_prefix=/opt/ares -gsoap_prefix=/software/gsoap-2.6 - -CC=gcc - --include Makefile.inc - - -VPATH=${top_srcdir}/src:${top_srcdir}/examples:${top_srcdir}/test:${top_srcdir}/project:${jpproject} - -GLOBUS_LIBS:=-L${globus_prefix}/lib \ - -lglobus_common_${nothrflavour} \ - -lglobus_gssapi_gsi_${nothrflavour} - -DEBUG:=-g -O0 -DDEBUG - -CFLAGS:=${DEBUG} -I. -I${top_srcdir}/src -I${gsoap_prefix}/include -I${stagedir}/include -LDFLAGS:=-L${stagedir}/lib - -LINK:=libtool --mode=link ${CC} ${LDFLAGS} -LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} -INSTALL:=libtool --mode=install install - - -daemon:=glite-jp-primarystoraged -example:=jpps-test -ps_prefix:=jpps_ -is_prefix:=jpis_ - -gsoap_version=`${gsoap_prefix}/bin/soapcpp2 -version 2>&1 | cut -d' ' -f4 | perl -F\\\\. -nae '$$F[2] =~ s/\D*$$//; print $$F[2]+100*$$F[1]+10000*$$F[0]'` - -CFLAGS+=-DGSOAP_VERSION=${gsoap_version} - - -SRCS:= simple_server.c soap_ops.c \ - ftp_backend.c \ - feed.c tags.c\ - is_client.c \ - ${ps_prefix}ServerLib.c \ - ${is_prefix}ClientLib.c jpps_C.c -# env_C.c - -EXA_SRCS:=jpps-test.c ${ps_prefix}C.c ${ps_prefix}Client.c - - -OBJS:=${SRCS:.c=.o} -EXA_OBJS:=${EXA_SRCS:.c=.o} - -COMMONLIB:=-lglite_jp_common -GSOAPLIB:=-L${gsoap_prefix}/lib -lgsoap${GSOAP_DEBUG} - -default all: compile - -compile: ${daemon} ${example} - -${daemon}: ${OBJS} - ${LINK} -o $@ ${OBJS} ${COMMONLIB} ${GSOAPLIB} ${GLOBUS_LIBS} - -${example}: ${EXA_OBJS} - ${LINK} -o $@ ${EXA_OBJS} ${GSOAPLIB} - -JobProvenanceIS.xh JobProvenancePS.xh: %.xh: %.wsdl JobProvenanceTypes.wsdl typemap.dat - cp ${jpproject}/JobProvenanceTypes.wsdl . - ${gsoap_prefix}/bin/wsdl2h -t ${top_srcdir}/src/typemap.dat -c -o $@ $< - rm -f JobProvenanceTypes.wsdl - -${ps_prefix}Client.c ${ps_prefix}ClientLib.c \ -${ps_prefix}Server.c ${ps_prefix}ServerLib.c \ -${ps_prefix}C.c ${ps_prefix}H.h: JobProvenancePS.xh - ${gsoap_prefix}/bin/soapcpp2 -n -w -c -p ${ps_prefix} JobProvenancePS.xh - -${is_prefix}ClientLib.c ${is_prefix}Client.c \ -${is_prefix}C.c ${is_prefix}H.h: JobProvenanceIS.xh - ${gsoap_prefix}/bin/soapcpp2 -n -w -c -p ${is_prefix} JobProvenanceIS.xh - -env_C.c env_Server.c: - touch env.xh - cp ${jpproject}/JobProvenanceTypes.wsdl . - ${gsoap_prefix}/bin/wsdl2h -t ${top_srcdir}/src/typemap.dat -c -o env.xh JobProvenanceTypes.wsdl - rm -f JobProvenanceTypes.wsdl - ${gsoap_prefix}/bin/soapcpp2 -w -c -p env_ env.xh - -#$(SOAP_PREFIX)H.h $(SOAP_PREFIX)C.c: LB.xh -# $(GSOAP_BIN_PATH)/soapcpp2 -w -c -p $(SOAP_PREFIX) LB.xh -# -#LB.xh: LB.wsdl typemap.dat -# $(GSOAP_BIN_PATH)/wsdl2h -c -o $@ LB.wsdl -# - - -simple_server.o: ${is_prefix}H.h ${ps_prefix}H.h - -check: - -echo nothing yet - -doc: - -stage: compile - ${INSTALL} -m 755 ${daemon} ${stagedir}/bin - -dist: distsrc distbin - -# FIXME: just copied from LB -distsrc: - mkdir -p ${top_srcdir}/${package}-${version} - cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version} - cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version} - rm -rf ${top_srcdir}/${package}-${version} - -distbin: - $(MAKE) install PREFIX=`pwd`/tmpbuilddir${stagedir} - save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir - rm -rf tmpbuilddir - -install: - -mkdir -p ${PREFIX}/bin ${PREFIX}/etc ${PREFIX}/etc/init.d - for p in bkserverd bkindex; do \ - ${INSTALL} -m 755 "glite_lb_$$p" "${PREFIX}/bin/glite-lb-$$p"; \ - done - - for f in dbsetup.sql index.conf.template; do \ - ${INSTALL} -m 644 ${top_srcdir}/config/"glite-lb-$$f" ${PREFIX}/etc; \ - done - - ${INSTALL} -m 755 ${top_srcdir}/config/startup ${PREFIX}/etc/init.d/glite-lb-bkserverd - -clean: - -simple_server.o soap_ops.o jpps-test.o: ${ps_prefix}H.h - -# we have no real config.h but have to force gSoap not to use -# linux ftime with broken (aka obsolete) DST information - -stdsoap2.o: ${gsoap_prefix}/devel/stdsoap2.c - test -f config.h || touch config.h - @echo 'The following warning "time_t (de)serialization is not MT safe on this platform" is harmless' - ${CC} -o $@ -c -DWITH_NONAMESPACES -DHAVE_CONFIG_H ${CFLAGS} ${gsoap_prefix}/devel/stdsoap2.c - diff --git a/org.glite.jp.primary/build.xml b/org.glite.jp.primary/build.xml deleted file mode 100755 index 28c0d13..0000000 --- a/org.glite.jp.primary/build.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.jp.primary/examples/jpps-test.c b/org.glite.jp.primary/examples/jpps-test.c deleted file mode 100644 index 8fb2322..0000000 --- a/org.glite.jp.primary/examples/jpps-test.c +++ /dev/null @@ -1,158 +0,0 @@ -#include -#include -#include -#include - -#include "jpps_H.h" -#include "jpps_.nsmap" - -#include "jptype_map.h" - -static void usage(const char *me) -{ - fprintf(stderr,"%s: [-s server-url] operation args \n\n" - " operations are:\n" - " RegisterJob jobid\n" - " StartUpload jobid class(0,1,2) commit_before mimetype\n" - " CommitUpload\n" - " RecordTag\n" - " GetJob jobid\n" - " FeedIndex destination query_number history continuous\n" - ,me); - - exit (EX_USAGE); -} - -static int check_fault(struct soap *soap,int err) { - struct SOAP_ENV__Detail *detail; - struct jptype__GenericJPFaultType *f; - char *reason,indent[200] = " "; - - switch(err) { - case SOAP_OK: puts("OK"); - break; - case SOAP_FAULT: - case SOAP_SVR_FAULT: - if (soap->version == 2) { - detail = soap->fault->SOAP_ENV__Detail; - reason = soap->fault->SOAP_ENV__Reason; - } - else { - detail = soap->fault->detail; - reason = soap->fault->faultstring; - } - fputs(reason,stderr); - putc('\n',stderr); - assert(detail->__type == SOAP_TYPE__GenericJPFault); -#if GSOAP_VERSION >=20700 - f = ((struct _GenericJPFault *) detail->fault) -#else - f = ((struct _GenericJPFault *) detail->value) -#endif - -> jptype__GenericJPFault; - - while (f) { - fprintf(stderr,"%s%s: %s (%s)\n",indent, - f->source,f->text,f->description); - f = f->reason; - strcat(indent," "); - } - return -1; - - default: soap_print_fault(soap,stderr); - return -1; - } - return 0; -} - -static struct jptype__Attribute sample_attr[] = { - { OWNER, NULL }, - { TIME, "submitted" }, - { TAG, "test" }, -}; - -static struct jptype__PrimaryQueryElement sample_query[][5] = { - { - { sample_attr+OWNER, EQUAL, "unknown", NULL }, - { NULL, 0, NULL, NULL } - }, -}; - -int main(int argc,char *argv[]) -{ - char *server = "http://localhost:8901"; - int opt; - struct soap *soap = soap_new(); - - if (argc < 2) usage(argv[0]); - - soap_init(soap); - soap_set_namespaces(soap, jpps__namespaces); - - while ((opt = getopt(argc,argv,"s:")) >= 0) switch (opt) { - case 's': server = optarg; - argv += 2; - break; - case '?': usage(argv[0]); - } - - if (!strcasecmp(argv[1],"RegisterJob")) { - struct jpsrv__RegisterJobResponse r; - - if (argc != 3) usage(argv[0]); - check_fault(soap, - soap_call_jpsrv__RegisterJob(soap,server,"",argv[2],&r)); - } else if (!strcasecmp(argv[1], "StartUpload")) { - struct jpsrv__StartUploadResponse r; - - if (argc != 6) usage(argv[0]); - if (!check_fault(soap, - soap_call_jpsrv__StartUpload(soap, server, "", - argv[2], atoi(argv[3]), atoi(argv[4]), argv[5], &r))) { - printf("Destination: %s\nCommit before: %ld\n", r.destination, (long)r.commitBefore); - } - } else if (!strcasecmp(argv[1],"FeedIndex")) { - struct jpsrv__FeedIndexResponse r; - struct jptype__Attribute *ap[2]; - struct jptype__Attributes attr = { 2, ap }; - struct jptype__PrimaryQueryElement *qp[100]; - struct jptype__PrimaryQuery qry = { 0, qp }; - - int i,j,qi = atoi(argv[3])-1; - - if (argc != 6) usage(argv[0]); - - for (i=0; i - - - - - - - - - - -top_srcdir=.. -builddir=build -stagedir=${stage.abs.dir} -distdir=${dist.dir} -globalprefix=${global.prefix} -lbprefix=${subsystem.prefix} -package=${module.package.name} -PREFIX=${install.dir} -version=${module.version} -glite_location=${with.glite.location} -globus_prefix=${with.globus.prefix} -expat_prefix=${with.expat.prefix} -ares_prefix=${with.ares.prefix} -gsoap_prefix=${with.gsoap.prefix} -thrflavour=${with.globus.thr.flavor} -nothrflavour=${with.globus.nothr.flavor} -cppunit=${with.cppunit.prefix} -jpproject=${subsystem.project.dir} -project=${component.project.dir} - - - diff --git a/org.glite.jp.primary/project/properties.xml b/org.glite.jp.primary/project/properties.xml deleted file mode 100755 index 2149dd4..0000000 --- a/org.glite.jp.primary/project/properties.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.jp.primary/project/tar_exclude b/org.glite.jp.primary/project/tar_exclude deleted file mode 100644 index e1fcd1a..0000000 --- a/org.glite.jp.primary/project/tar_exclude +++ /dev/null @@ -1,10 +0,0 @@ -tar_exclude -CVS -build.xml -build -build.properties -properties.xml -configure.properties.xml -.cvsignore -.project -.cdtproject diff --git a/org.glite.jp.primary/project/version.properties b/org.glite.jp.primary/project/version.properties deleted file mode 100644 index e07f253..0000000 --- a/org.glite.jp.primary/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Nov 25 20:15:06 CET 2004 -module.version=0.1.0 -module.build=2 -module.age=1 diff --git a/org.glite.jp.primary/src/backend.h b/org.glite.jp.primary/src/backend.h deleted file mode 100644 index bb143e9..0000000 --- a/org.glite.jp.primary/src/backend.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef __GLITE_JP_BACKEND -#define __GLITE_JP_BACKEND - -#include -#include - -int glite_jppsbe_init( - glite_jp_context_t ctx, - int *argc, - char *argv[] -); - -int glite_jppsbe_init_slave( - glite_jp_context_t ctx -); - -int glite_jppsbe_register_job( - glite_jp_context_t ctx, - const char *job, - const char *owner -); - -int glite_jppsbe_start_upload( - glite_jp_context_t ctx, - const char *job, - glite_jp_fileclass_t class, - const char *content_type, - char **destination_out, - time_t *commit_before_inout -); - -int glite_jppsbe_commit_upload( - glite_jp_context_t ctx, - const char *destination -); - -int glite_jppsbe_destination_info( - glite_jp_context_t ctx, - const char *destination, - char **job_out, - glite_jp_fileclass_t *class_out -); - -int glite_jppsbe_get_job_url( - glite_jp_context_t ctx, - const char *job, - glite_jp_fileclass_t class, - char **url_out -); - -int glite_jppsbe_open_file( - glite_jp_context_t ctx, - const char *job, - glite_jp_fileclass_t class, - int mode, - void **handle_out -); - -int glite_jppsbe_close_file( - glite_jp_context_t ctx, - void *handle -); - -int glite_jppsbe_pread( - glite_jp_context_t ctx, - void *handle, - void *buf, - size_t nbytes, - off_t offset, - ssize_t *nbytes_ret -); - -int glite_jppsbe_pwrite( - glite_jp_context_t ctx, - void *handle, - void *buf, - size_t nbytes, - off_t offset -); - -int glite_jppsbe_append( - glite_jp_context_t ctx, - void *handle, - void *buf, - size_t nbytes -); - -int glite_jppsbe_get_job_metadata( - glite_jp_context_t ctx, - const char *job, - glite_jp_attrval_t attrs_inout[] -); - -int glite_jppsbe_query( - glite_jp_context_t ctx, - const glite_jp_query_rec_t query[], - const glite_jp_attrval_t metadata[], - int (*callback)( - glite_jp_context_t ctx, - const char *job, - const glite_jp_attrval_t metadata[] - ) -); - -#endif diff --git a/org.glite.jp.primary/src/feed.c b/org.glite.jp.primary/src/feed.c deleted file mode 100644 index 297eb23..0000000 --- a/org.glite.jp.primary/src/feed.c +++ /dev/null @@ -1,264 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "glite/jp/types.h" -#include "glite/jp/strmd5.h" -#include "feed.h" - - -/* - * seconds before feed expires: should be - * XXX: should be configurable, default for real deployment sort of 1 hour - */ -#define FEED_TTL 120 - -static int check_qry_item( - glite_jp_context_t ctx, - const glite_jp_query_rec_t *qry, - const glite_jp_attrval_t *attr -) -{ - int cmp,cmp2; - long scmp,ucmp; - - switch (qry->attr.type) { - case GLITE_JP_ATTR_OWNER: - case GLITE_JP_ATTR_TAG: - cmp = strcmp(attr->value.s,qry->value.s); - break; - case GLITE_JP_ATTR_TIME: - scmp = (ucmp = attr->value.time.tv_usec - qry->value.time.tv_usec) > 0 ? 0 : -1; - ucmp -= 1000000 * scmp; - scmp += attr->value.time.tv_sec - qry->value.time.tv_sec; - cmp = scmp ? scmp : ucmp; - break; - } - switch (qry->op) { - case GLITE_JP_QUERYOP_EQUAL: return !cmp; - case GLITE_JP_QUERYOP_UNEQUAL: return cmp; - case GLITE_JP_QUERYOP_LESS: return cmp < 0; - case GLITE_JP_QUERYOP_GREATER: return cmp > 0; - - case GLITE_JP_QUERYOP_WITHIN: - switch (qry->attr.type) { - case GLITE_JP_ATTR_OWNER: - case GLITE_JP_ATTR_TAG: - cmp2 = strcmp(attr->value.s,qry->value2.s); - break; - case GLITE_JP_ATTR_TIME: - scmp = (ucmp = attr->value.time.tv_usec - qry->value2.time.tv_usec) > 0 ? 0 : -1; - ucmp -= 1000000 * scmp; - scmp += attr->value.time.tv_sec - qry->value2.time.tv_sec; - cmp2 = scmp ? scmp : ucmp; - break; - } - return cmp >= 0 && cmp2 <= 0; - } -} - -/* XXX: limit on query size -- I'm lazy to malloc() */ -#define QUERY_MAX 100 - -static int match_feed( - glite_jp_context_t ctx, - const struct jpfeed *feed, - const char *job, - const glite_jp_attrval_t attrs[] /* XXX: not checked for correctness */ -) -{ - int i; - int attri[GLITE_JP_ATTR__LAST]; - int qi[QUERY_MAX]; - - glite_jp_attrval_t *newattr = NULL; - - glite_jp_clear_error(ctx); - - for (i=0; iqry) { - int j,complete = 1; - - memset(qi,0,sizeof qi); - for (i=0; feed->qry[i].attr.type; i++) { - assert(iqry[i].attr.type]) >=0) { - if (check_qry_item(ctx,feed->qry+i,attrs+j)) - qi[i] = 1; /* matched */ - else return 0; /* can't be satisfied */ - } - else complete = 0; - } - - /* not all attributes in query are known from input - * we have to retrieve job metadata from the backend - */ - if (!complete) { - glite_jp_attrval_t meta[GLITE_JP_ATTR__LAST+1]; - int qai[GLITE_JP_ATTR__LAST]; - - memset(meta,0,sizeof meta); - j=0; - for (i=0; feed->qry[i].attr.type; i++) if (!qi[i]) { - meta[j].attr.type = feed->qry[i].attr.type; - meta[j].attr.name = feed->qry[i].attr.name; - qai[feed->qry[i].attr.type] = i; - j++; - } - - if (glite_jppsbe_get_job_metadata(ctx,job,meta)) { - glite_jp_error_t err; - err.code = EIO; - err.source = __FUNCTION__; - err.desc = "complete query"; - return glite_jp_stack_error(ctx,&err); - } - - for (i=0; j=meta[i].attr.type; i++) - if (!check_qry_item(ctx,feed->qry+qai[j],meta+i)) - return 0; - } - } - - /* matched completely */ - return glite_jpps_single_feed(ctx,feed->destination,job,attrs); - return 0; -} - -int glite_jpps_match_attr( - glite_jp_context_t ctx, - const char *job, - const glite_jp_attrval_t attrs[] -) -{ - struct jpfeed *f = (struct jpfeed *) ctx->feeds; - int i,j; - int attri[GLITE_JP_ATTR__LAST]; - - glite_jp_clear_error(ctx); - - for (i=0; i= GLITE_JP_ATTR__LAST || - attrs[i].attr.type <= 0) - { - glite_jp_error_t err; - err.code = EINVAL; - err.source = __FUNCTION__; - err.desc = "unknown attribute"; - return glite_jp_stack_error(ctx,&err); - } - if (attri[attrs[i].attr.type] >= 0) { - glite_jp_error_t err; - err.code = EINVAL; - err.source = __FUNCTION__; - err.desc = "double attribute change"; - return glite_jp_stack_error(ctx,&err); - } - - attri[attrs[i].attr.type] = i; - } - - for (;f; f = f->next) { - for (i=0; f->attrs[i].type && attri[f->attrs[i].type] == -1; i++); - /* XXX: ignore any errors */ - if (f->attrs[i].type) match_feed(ctx,f,job,attrs); - } - - return glite_jp_clear_error(ctx); -} - -int glite_jpps_match_file( - glite_jp_context_t ctx, - const char *job, - glite_jp_fileclass_t class -) -{ - fprintf(stderr,"%s: \n",__FUNCTION__); - return 0; -} - -int glite_jpps_match_tag( - glite_jp_context_t ctx, - const char *job, - const glite_jp_tagval_t *tag -) -{ - fprintf(stderr,"%s: \n",__FUNCTION__); - return 0; -} - -static char *generate_feedid(void) -{ - char hname[200],buf[1000]; - - gethostname(hname,sizeof hname); - snprintf(buf,sizeof buf,"%s%d%ld",hname,getpid(),lrand48()); - buf[sizeof buf-1] = 0; - return str2md5base64(buf); -} - - -int glite_jpps_run_feed( - glite_jp_context_t ctx, - const char *destination, - const glite_jp_attr_t *attrs, - const glite_jp_query_rec_t *qry, - char **feed_id) -{ - fprintf(stderr,"%s: \n",__FUNCTION__); - return 0; -} - -static int register_feed_deferred(glite_jp_context_t ctx,void *feed) -{ - struct jpfeed *f = feed; - - f->next = ctx->feeds; - ctx->feeds = f; - return 0; -} - -/* FIXME: - * - volatile implementation: should store the registrations in a file - * and recover after restart - * - should communicate the data among all server slaves - */ -int glite_jpps_register_feed( - glite_jp_context_t ctx, - const char *destination, - const glite_jp_attr_t *attrs, - const glite_jp_query_rec_t *qry, - char **feed_id, - time_t *expires) -{ - int i; - struct jpfeed *f = calloc(1,sizeof *f); - - if (!*feed_id) *feed_id = generate_feedid(); - time(expires); *expires += FEED_TTL; - - f->id = strdup(*feed_id); - f->destination = strdup(destination); - f->expires = *expires; - for (i=0; attrs[i].type; i++) { - f->attrs = realloc(f->attrs,(i+2) * sizeof *f->attrs); - glite_jp_attr_copy(f->attrs+i,attrs+i); - memset(f->attrs+i+1,0,sizeof *f->attrs); - } - for (i=0; qry[i].attr.type; i++) { - f->qry = realloc(f->qry,(i+2) * sizeof *f->qry); - glite_jp_queryrec_copy(f->qry+i,qry+i); - memset(f->qry+i+1,0,sizeof *f->qry); - } - - glite_jp_add_deferred(ctx,register_feed_deferred,f); - - return 0; -} - diff --git a/org.glite.jp.primary/src/feed.h b/org.glite.jp.primary/src/feed.h deleted file mode 100644 index 1551a82..0000000 --- a/org.glite.jp.primary/src/feed.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __GLITE_JP_FEED -#define __GLITE_JP_FEED - - -struct jpfeed { - char *id,*destination; - time_t expires; - glite_jp_attr_t *attrs; - glite_jp_query_rec_t *qry; - struct jpfeed *next; -}; - - -int glite_jpps_match_attr(glite_jp_context_t,const char *,const glite_jp_attrval_t[]); -int glite_jpps_match_file(glite_jp_context_t,const char *,glite_jp_fileclass_t); -int glite_jpps_match_tag(glite_jp_context_t,const char *,const glite_jp_tagval_t *); -int glite_jpps_run_feed(glite_jp_context_t,const char *,const glite_jp_attr_t *,const glite_jp_query_rec_t *,char **); -int glite_jpps_register_feed(glite_jp_context_t,const char *,const glite_jp_attr_t *,const glite_jp_query_rec_t *,char **,time_t *); - -#endif - diff --git a/org.glite.jp.primary/src/ftp_backend.c b/org.glite.jp.primary/src/ftp_backend.c deleted file mode 100644 index b598f0a..0000000 --- a/org.glite.jp.primary/src/ftp_backend.c +++ /dev/null @@ -1,1701 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/jp/types.h" -#include "glite/jp/context.h" -#include "glite/jp/strmd5.h" - -#include "tags.h" -#include "backend.h" - -#define UPLOAD_SUFFIX ".upload" -#define LOCK_SUFFIX ".lock" - -struct ftpbe_config { - char *internal_path; - char *external_path; - char *gridmap; - char *logname; -}; - -static struct ftpbe_config *config = NULL; - -struct fhandle_rec { - int fd; - int fd_append; -}; -typedef struct fhandle_rec *fhandle; - -static struct option ftpbe_opts[] = { - { "ftp-internal-path", 1, NULL, 'I' }, - { "ftp-external-path", 1, NULL, 'E' }, - { "ftp-gridmap", 1, NULL, 'G' }, - { NULL, 0, NULL, 0 } -}; - -static struct { - glite_jp_fileclass_t type; - char * fname; - } class_to_fname_tab[] = { - { GLITE_JP_FILECLASS_INPUT, "input" }, - { GLITE_JP_FILECLASS_OUTPUT, "output" }, - { GLITE_JP_FILECLASS_LBLOG, "lblog" }, - { GLITE_JP_FILECLASS_TAGS, "tags" }, - { GLITE_JP_FILECLASS_UNDEF, NULL } - }; - -static char *class_to_fname(glite_jp_fileclass_t type) -{ - int i; - - for (i = 0; class_to_fname_tab[i].type != GLITE_JP_FILECLASS_UNDEF; i++) - if (type == class_to_fname_tab[i].type) - return class_to_fname_tab[i].fname; - - return NULL; -} - -static glite_jp_fileclass_t fname_to_class(char* fname) -{ - int i; - - for (i = 0; class_to_fname_tab[i].type != GLITE_JP_FILECLASS_UNDEF; i++) - if (!strcmp(fname, class_to_fname_tab[i].fname)) - return class_to_fname_tab[i].type; - - return GLITE_JP_FILECLASS_UNDEF; -} - -static int config_check( - glite_jp_context_t ctx, - struct ftpbe_config *config) -{ - return config == NULL || - config->internal_path == NULL || - config->external_path == NULL || - config->gridmap == NULL || - config->logname == NULL; - - /* XXX check reality */ -} - -static int jobid_unique_pathname(glite_jp_context_t ctx, const char *job, - char **unique, char **ju_path, int get_path) -{ - char *p; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - p = strrchr(job, '/'); - if (!p) { - err.code = EINVAL; - err.desc = "Malformed jobid"; - return glite_jp_stack_error(ctx,&err); - } - /* XXX thorough checks */ - if (!(*unique = strdup(p+1))) { - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - if (get_path) { - if (!(*ju_path = strdup(p+1))) { - free(*unique); - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - *(*ju_path + 10) = '\0'; - } - return 0; -} - -static int mkdirpath(const char* path, int prefixlen) -{ - char *wpath, *p; - int goout, ret; - - wpath = strdup(path); - if (!wpath) { - errno = ENOMEM; - return -1; - } - - p = wpath + prefixlen; - goout = 0; - while (!goout) { - while (*p == '/') p++; - while (*p != '/' && *p != '\0') p++; - goout = (*p == '\0'); - *p = '\0'; - ret = mkdir(wpath, S_IRUSR | S_IWUSR | S_IXUSR); - if (ret < 0 && errno != EEXIST) break; - *p = '/'; - } - free(wpath); - return goout ? 0 : ret; -} - -static long regtime_trunc(long tv_sec) -{ - return tv_sec / (86400*7); -} - -static long regtime_ceil(long tv_sec) -{ - return (tv_sec % (86400*7)) ? tv_sec/(86400*7)+1 : tv_sec/(86400*7) ; -} - -/********************************************************************************/ -int glite_jppsbe_init( - glite_jp_context_t ctx, - int *argc, - char *argv[] -) -{ - glite_jp_error_t err; - int opt; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - config = (struct ftpbe_config *) calloc(1, sizeof *config); - if (!config) { - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - - config->logname = getlogin(); - - while ((opt = getopt_long(*argc, argv, "I:E:G:", ftpbe_opts, NULL)) != EOF) { - switch (opt) { - case 'I': config->internal_path = optarg; break; - case 'E': config->external_path = optarg; break; - case 'G': config->gridmap = optarg; break; - default: break; - } - } - - if (config_check(ctx, config)) { - err.code = EINVAL; - err.desc = "Invalid FTP backend configuration"; - return glite_jp_stack_error(ctx,&err); - } - - return 0; -} - -int glite_jppsbe_init_slave( - glite_jp_context_t ctx -) -{ - /* Nothing to do */ -} - -int glite_jppsbe_register_job( - glite_jp_context_t ctx, - const char *job, - const char *owner -) -{ - glite_jp_error_t err; - char *int_dir = NULL; - char *int_fname = NULL; - char *data_dir = NULL; - char *data_fname = NULL; - char *ju = NULL; - char *ju_path = NULL; - char *ownerhash = NULL; - FILE *regfile = NULL; - struct timeval reg_tv; - long reg_tv_trunc; - struct stat statbuf; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - assert(job != NULL); - assert(owner != NULL); - - gettimeofday(®_tv, NULL); - reg_tv_trunc = regtime_trunc(reg_tv.tv_sec); - - if (jobid_unique_pathname(ctx, job, &ju, &ju_path, 1) != 0) { - err.code = ctx->error->code; - err.desc = "Cannot obtain jobid unique path/name"; - return glite_jp_stack_error(ctx,&err); - } - - if (asprintf(&int_dir, "%s/regs/%s", - config->internal_path, ju_path) == -1) { - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - - if (mkdirpath(int_dir, strlen(config->internal_path)) < 0 && - errno != EEXIST) { - free(int_dir); - err.code = errno; - err.desc = "Cannot mkdir jobs's reg directory"; - return glite_jp_stack_error(ctx,&err); - } - free(int_dir); - - if (asprintf(&int_fname, "%s/regs/%s/%s.info", - config->internal_path, ju_path, ju) == -1) { - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - - if (stat(int_fname, &statbuf) < 0) { - if (errno != ENOENT) { - err.code = errno; - err.desc = "Cannot stat jobs's reg info file"; - goto error_out; - } - } else { - err.code = EEXIST; - err.desc = "Job already registered"; - goto error_out; - } - - regfile = fopen(int_fname, "w"); - if (regfile == NULL) { - err.code = errno; - err.desc = "Cannot open jobs's reg info file"; - goto error_out; - } - - ownerhash = str2md5(owner); /* static buffer */ - - if (fprintf(regfile, "%d %ld.%06ld %s %s %d %s\n", 1, - (long)reg_tv.tv_sec, (long)reg_tv.tv_usec, job, - ownerhash, strlen(owner), owner) < 1 || ferror(regfile)) { - fclose(regfile); - err.code = errno; - err.desc = "Cannot write jobs's reg info file"; - goto error_out; - } - if (fclose(regfile) != 0 ) { - err.code = errno; - err.desc = "Cannot close(write) jobs's reg info file"; - goto error_out; - } - - if (asprintf(&data_dir, "%s/data/%s/%d/%s", - config->internal_path, ownerhash, regtime_trunc(reg_tv.tv_sec), ju) == -1) { - err.code = ENOMEM; - goto error_out; - } - if (asprintf(&data_fname, "%s/_info", data_dir) == -1) { - err.code = ENOMEM; - goto error_out; - } - if (mkdirpath(data_dir, strlen(config->internal_path)) < 0 && - errno != EEXIST) { - err.code = errno; - err.desc = "Cannot mkdir jobs's data directory"; - goto error_out; - } - - if (link(int_fname, data_fname) < 0) { - err.code = errno; - err.desc = "Cannot link job's reg and data info files"; - goto error_out; - } - -error_out: - free(int_fname); - free(data_fname); - if (err.code && data_dir) rmdir(data_dir); - free(data_dir); - if (err.code) { - return glite_jp_stack_error(ctx,&err); - } else { - return 0; - } -} - -static int add_to_gridmap(glite_jp_context_t ctx, const char *dn) -{ - FILE *gridmap = NULL; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - gridmap = fopen(config->gridmap, "a"); - if (!gridmap) { - err.code = errno; - err.desc = "Cannot open gridmap file"; - return glite_jp_stack_error(ctx,&err); - } - if (fprintf(gridmap, "\"%s\" %s\n", dn, config->logname) < 6 || - ferror(gridmap)) { - err.code = EIO; - err.desc = "Cannot write to gridmap file"; - fclose(gridmap); - return glite_jp_stack_error(ctx,&err); - } - fclose(gridmap); - return 0; -} - -static int remove_from_gridmap(glite_jp_context_t ctx, const char *dn) -{ - FILE *gridmap = NULL; - char *temp_name = NULL; - FILE *temp_file = NULL; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - /* XXX */ - return 0; -} - -int glite_jppsbe_start_upload( - glite_jp_context_t ctx, - const char *job, - glite_jp_fileclass_t class, - const char *content_type, - char **destination_out, - time_t *commit_before_inout -) -{ - char *int_fname = NULL; - char *lock_fname = NULL; - FILE *lockfile = NULL; - FILE *regfile = NULL; - char *fname = NULL; - char *data_dir = NULL; - char *data_lock = NULL; - char *ju = NULL; - char *ju_path = NULL; - char *peername = NULL; - int info_version; - long reg_time; - char ownerhash[33]; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - assert(job!=NULL); - assert(destination_out!=NULL); - - fname = class_to_fname(class); - assert(fname!=NULL); - - if (jobid_unique_pathname(ctx, job, &ju, &ju_path, 1) != 0) { - err.code = ctx->error->code; - err.desc = "Cannot obtain jobid unique path/name"; - return glite_jp_stack_error(ctx,&err); - } - - peername = glite_jp_peer_name(ctx); - - if (asprintf(&int_fname, "%s/regs/%s/%s.info", - config->internal_path, ju_path, ju) == -1) { - err.code = ENOMEM; - goto error_out; - } - regfile = fopen(int_fname, "r"); - if (regfile == NULL) { - err.code = errno; - if (errno == ENOENT) - err.desc = "Job not registered"; - else - err.desc = "Cannot open jobs's reg info file"; - goto error_out; - } - if (fscanf(regfile, "%d %ld.%*ld %*s %s ", &info_version, - ®_time, ownerhash) < 3 || ferror(regfile)) { - fclose(regfile); - err.code = errno; - err.desc = "Cannot read jobs's reg info file"; - goto error_out; - } - fclose(regfile); - - /* XXX authorization */ - - if (asprintf(&data_dir, "%s/data/%s/%d/%s", - config->internal_path, ownerhash, regtime_trunc(reg_time), ju) == -1) { - err.code = ENOMEM; - goto error_out; - } - - if (asprintf(&lock_fname, "%s/%s" LOCK_SUFFIX, - data_dir, fname) == -1) { - err.code = ENOMEM; - goto error_out; - } - - if (commit_before_inout != NULL) - *commit_before_inout = (time_t) LONG_MAX; /* XXX no timeout enforced */ - - lockfile = fopen(lock_fname, "w"); - if (lockfile == NULL) { - err.code = errno; - err.desc = "Cannot open uploads's lock file"; - goto error_out; - } - - if (fprintf(lockfile, "%ld %d %s\n", (long)*commit_before_inout, - peername ? peername : 0, - peername ? peername : "") < 1 || ferror(regfile)) { - fclose(lockfile); - err.code = errno; - err.desc = "Cannot write upload's lock file"; - goto error_out; - } - if (fclose(lockfile) != 0 ) { - err.code = errno; - err.desc = "Cannot close(write) upload's lock file"; - goto error_out; - } - - if (asprintf(destination_out, "%s/data/%s/%d/%s/%s" UPLOAD_SUFFIX, - config->external_path, ownerhash, regtime_trunc(reg_time), ju, fname) == -1) { - err.code = ENOMEM; - goto error_out; - } - - if (add_to_gridmap(ctx, peername)) { - err.code = EIO; - err.desc = "Cannot add peer DN to ftp server authorization file"; - goto error_out; - } - -error_out: - free(int_fname); - free(data_dir); - if (err.code && data_lock) unlink(data_lock); - free(data_lock); - free(ju); free(ju_path); - if (err.code) { - return glite_jp_stack_error(ctx,&err); - } else { - return 0; - } -} - -int glite_jppsbe_commit_upload( - glite_jp_context_t ctx, - const char *destination -) -{ - size_t dest_len; - size_t suff_len; - size_t extp_len; - long commit_before; - int lockpeerlen; - char *lockpeername = NULL; - char *peername = NULL; - char *dest_rw = NULL; - char *dest_rw_suff = NULL; - char *dest_rw_lock = NULL; - FILE *lockfile = NULL; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - assert(destination != NULL); - - suff_len = strlen(UPLOAD_SUFFIX); - dest_len = strlen(destination); - extp_len = strlen(config->external_path); - - if (dest_len < suff_len || - strcmp(UPLOAD_SUFFIX, destination + (dest_len - suff_len)) || - strncmp(destination, config->external_path, extp_len)) { - err.code = EINVAL; - err.desc = "Forged destination path"; - return glite_jp_stack_error(ctx,&err); - } - - if (asprintf(&dest_rw_suff, "%s%s", config->internal_path, - destination + extp_len) == -1) { - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - dest_rw = strdup(dest_rw_suff); - if (!dest_rw) { - err.code = ENOMEM; - goto error_out; - } - *(dest_rw + (strlen(dest_rw_suff) - suff_len)) = '\0'; - - if (asprintf(&dest_rw_lock, "%s" LOCK_SUFFIX, dest_rw) == -1) { - err.code = ENOMEM; - goto error_out; - } - - lockfile = fopen(dest_rw_lock, "r"); - if (lockfile == NULL) { - err.code = errno; - err.desc = "Cannot open upload's lock file"; - goto error_out; - } - if (fscanf(lockfile, "%ld %d ", &commit_before, &lockpeerlen) < 2 || ferror(lockfile)) { - fclose(lockfile); - err.code = errno; - err.desc = "Cannot read upload's lock file"; - goto error_out; - } - if (lockpeerlen) { - lockpeername = (char*) calloc(1, lockpeerlen+1); - if (!lockpeername) { - err.code = ENOMEM; - goto error_out; - } - if (fgets(lockpeername, lockpeerlen+1, lockfile) == NULL) { - fclose(lockfile); - err.code = errno; - err.desc = "Cannot read upload's lock file"; - goto error_out; - } - } - fclose(lockfile); - - peername = glite_jp_peer_name(ctx); - if (lockpeername && (!peername || strcmp(lockpeername, peername))) { - err.code = EPERM; - err.desc = "Upload started by client of different identity"; - goto error_out; - } - - if (rename(dest_rw_suff, dest_rw) < 0) { - err.code = errno; - err.desc = "Cannot move upload file to the final place"; - goto error_out; - } - - if (unlink(dest_rw_lock) < 0) { - err.code = errno; - err.desc = "Cannot unlink upload's lock file"; - goto error_out; - } - -error_out: - free(dest_rw); - free(dest_rw_suff); - free(dest_rw_lock); - free(peername); - free(lockpeername); - if (err.code) { - return glite_jp_stack_error(ctx,&err); - } else { - return 0; - } -} - -int glite_jppsbe_destination_info( - glite_jp_context_t ctx, - const char *destination, - char **job, - glite_jp_fileclass_t *class -) -{ - size_t dest_len; - size_t suff_len; - size_t extp_len; - char *dest_rw = NULL; - char *dest_rw_suff = NULL; - char *dest_rw_info = NULL; - FILE *infofile = NULL; - char *classname = NULL; - char jobstr[256+1]; - glite_jp_error_t err; - - assert(destination != NULL); - assert(job != NULL); - assert(class != NULL); - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - suff_len = strlen(UPLOAD_SUFFIX); - dest_len = strlen(destination); - extp_len = strlen(config->external_path); - - if (dest_len < suff_len || - strcmp(UPLOAD_SUFFIX, destination + (dest_len - suff_len)) || - strncmp(destination, config->external_path, extp_len)) { - err.code = EINVAL; - err.desc = "Forged destination path"; - return glite_jp_stack_error(ctx,&err); - } - - if (asprintf(&dest_rw_suff, "%s%s", config->internal_path, - destination + extp_len) == -1) { - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - dest_rw = strdup(dest_rw_suff); - if (!dest_rw) { - err.code = ENOMEM; - goto error_out; - } - *(dest_rw + (strlen(dest_rw_suff) - suff_len)) = '\0'; - - classname = strrchr(dest_rw,'/'); - if (classname == NULL) { - err.code = EINVAL; - err.desc = "Forged destination path"; - goto error_out; - } - *classname++ ='\0'; - *class = fname_to_class(classname); - if (!class == GLITE_JP_FILECLASS_UNDEF) { - err.code = EINVAL; - err.desc = "Forged destination path"; - goto error_out; - } - - if (asprintf(&dest_rw_info, "%s/_info", dest_rw) == -1) { - err.code = ENOMEM; - goto error_out; - } - - infofile = fopen(dest_rw_info, "r"); - if (infofile == NULL) { - err.code = errno; - err.desc = "Cannot open _info file"; - goto error_out; - } - if (fscanf(infofile, "%*d %*ld.%*ld %256s ", jobstr) < 1 || ferror(infofile)) { - fclose(infofile); - err.code = errno; - err.desc = "Cannot read _info file"; - goto error_out; - } - *job = strdup(jobstr); - fclose(infofile); - -error_out: - free(dest_rw); - free(dest_rw_suff); - free(dest_rw_info); - if (err.code) { - return glite_jp_stack_error(ctx,&err); - } else { - return 0; - } -} - - -int glite_jppsbe_get_job_url( - glite_jp_context_t ctx, - const char *job, - glite_jp_fileclass_t class, - char **url_out -) -{ - FILE *regfile = NULL; - char *int_fname = NULL; - char *fname = NULL; - char *ju = NULL; - char *ju_path = NULL; - int info_version; - long reg_time; - char ownerhash[33]; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - assert(job!=NULL); - assert(class != GLITE_JP_FILECLASS_UNDEF); - assert(url_out != NULL); - - fname = class_to_fname(class); - assert(fname!=NULL); - - if (jobid_unique_pathname(ctx, job, &ju, &ju_path, 1) != 0) { - err.code = ctx->error->code; - err.desc = "Cannot obtain jobid unique path/name"; - return glite_jp_stack_error(ctx,&err); - } - - if (asprintf(&int_fname, "%s/regs/%s/%s.info", - config->internal_path, ju_path, ju) == -1) { - err.code = ENOMEM; - goto error_out; - } - regfile = fopen(int_fname, "r"); - if (regfile == NULL) { - err.code = errno; - if (errno == ENOENT) - err.desc = "Job not registered"; - else - err.desc = "Cannot open jobs's reg info file"; - goto error_out; - } - if (fscanf(regfile, "%d %ld.%*ld %*s %s", &info_version, - ®_time, ownerhash) < 3 || ferror(regfile)) { - fclose(regfile); - err.code = errno; - err.desc = "Cannot read jobs's reg info file"; - goto error_out; - } - fclose(regfile); - - if (asprintf(url_out, "%s/data/%s/%d/%s/%s", - config->external_path, ownerhash, regtime_trunc(reg_time), ju, fname) == -1) { - err.code = ENOMEM; - goto error_out; - } - -error_out: - free(int_fname); - free(ju); free(ju_path); - if (err.code) { - return glite_jp_stack_error(ctx,&err); - } else { - return 0; - } -} - -static int get_job_fname( - glite_jp_context_t ctx, - const char *job, - glite_jp_fileclass_t class, - char **fname_out -) -{ - FILE *regfile = NULL; - char *fname = NULL; - char *int_fname = NULL; - char *ju = NULL; - char *ju_path = NULL; - int info_version; - long reg_time; - char ownerhash[33]; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - assert(job!=NULL); - assert(class != GLITE_JP_FILECLASS_UNDEF); - assert(fname_out != NULL); - - fname = class_to_fname(class); - assert(fname!=NULL); - - if (jobid_unique_pathname(ctx, job, &ju, &ju_path, 1) != 0) { - err.code = ctx->error->code; - err.desc = "Cannot obtain jobid unique path/name"; - return glite_jp_stack_error(ctx,&err); - } - - if (asprintf(&int_fname, "%s/regs/%s/%s.info", - config->internal_path, ju_path, ju) == -1) { - err.code = ENOMEM; - goto error_out; - } - regfile = fopen(int_fname, "r"); - if (regfile == NULL) { - err.code = errno; - if (errno == ENOENT) - err.desc = "Job not registered"; - else - err.desc = "Cannot open jobs's reg info file"; - goto error_out; - } - if (fscanf(regfile, "%d %ld.%*ld %*s %s", &info_version, - ®_time, ownerhash) < 3 || ferror(regfile)) { - fclose(regfile); - err.code = errno; - err.desc = "Cannot read jobs's reg info file"; - goto error_out; - } - fclose(regfile); - - if (asprintf(fname_out, "%s/data/%s/%d/%s/%s", - config->internal_path, ownerhash, regtime_trunc(reg_time), ju, fname) == -1) { - err.code = ENOMEM; - goto error_out; - } - -error_out: - free(int_fname); - free(ju); free(ju_path); - if (err.code) { - return glite_jp_stack_error(ctx,&err); - } else { - return 0; - } -} - -int glite_jppsbe_open_file( - glite_jp_context_t ctx, - const char *job, - glite_jp_fileclass_t class, - int mode, - void **handle_out -) -{ - fhandle handle = NULL; - char* fname = NULL; - glite_jp_error_t err; - - assert(handle_out != NULL); - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - if (get_job_fname(ctx, job, class, &fname)) { - err.code = ctx->error->code; - err.desc = "Cannot construct internal filename"; - return glite_jp_stack_error(ctx,&err); - } - - handle = (fhandle) calloc(1,sizeof(*handle)); - if (handle == NULL) { - err.code = ENOMEM; - goto error_out; - } - - handle->fd = open(fname, mode, S_IRUSR | S_IWUSR); - if (handle->fd < 0) { - err.code = errno; - err.desc = "Cannot open requested file"; - free(handle); - goto error_out; - } - handle->fd_append = open(fname, mode | O_APPEND, S_IRUSR | S_IWUSR); - if (handle->fd_append < 0) { - err.code = errno; - err.desc = "Cannot open requested file for append"; - close(handle->fd); - free(handle); - goto error_out; - } - *handle_out = (void*) handle; - -error_out: - free(fname); - if (err.code) { - return glite_jp_stack_error(ctx,&err); - } else { - return 0; - } -} - -int glite_jppsbe_close_file( - glite_jp_context_t ctx, - void *handle -) -{ - glite_jp_error_t err; - - assert(handle != NULL); - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - if (close(((fhandle)handle)->fd_append) < 0) { - err.code = errno; - err.desc = "Error closing file descriptor (fd_append)"; - goto error_out; - } - if (close(((fhandle)handle)->fd) < 0) { - err.code = errno; - err.desc = "Error closing file descriptor"; - goto error_out; - } - -error_out: - free(handle); - if (err.code) { - return glite_jp_stack_error(ctx,&err); - } else { - return 0; - } -} - -int glite_jppsbe_pread( - glite_jp_context_t ctx, - void *handle, - void *buf, - size_t nbytes, - off_t offset, - ssize_t *nbytes_ret -) -{ - ssize_t ret; - glite_jp_error_t err; - - assert(handle != NULL); - assert(buf != NULL); - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - if ((ret = pread(((fhandle)handle)->fd, buf, nbytes, offset)) < 0) { - err.code = errno; - err.desc = "Error in pread()"; - return glite_jp_stack_error(ctx,&err); - } - *nbytes_ret = ret; - - return 0; -} - -int glite_jppsbe_pwrite( - glite_jp_context_t ctx, - void *handle, - void *buf, - size_t nbytes, - off_t offset -) -{ - glite_jp_error_t err; - - assert(handle != NULL); - assert(buf != NULL); - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - if (pwrite(((fhandle)handle)->fd, buf, nbytes, offset) < 0) { - err.code = errno; - err.desc = "Error in pwrite()"; - return glite_jp_stack_error(ctx,&err); - } - - return 0; -} - -int glite_jppsbe_append( - glite_jp_context_t ctx, - void *handle, - void *buf, - size_t nbytes -) -{ - glite_jp_error_t err; - - assert(handle != NULL); - assert(buf != NULL); - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - if (write(((fhandle)handle)->fd_append, buf, nbytes) < 0) { - err.code = errno; - err.desc = "Error in write()"; - return glite_jp_stack_error(ctx,&err); - } - - return 0; -} - -static int get_job_info( - glite_jp_context_t ctx, - const char *job, - char **owner, - struct timeval *tv_reg -) -{ - char *ju = NULL; - char *ju_path = NULL; - FILE *regfile = NULL; - long reg_time_sec; - long reg_time_usec; - int ownerlen = 0; - int info_version; - char *int_fname = NULL; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - if (jobid_unique_pathname(ctx, job, &ju, &ju_path, 1) != 0) { - err.code = ctx->error->code; - err.desc = "Cannot obtain jobid unique path/name"; - return glite_jp_stack_error(ctx,&err); - } - - if (asprintf(&int_fname, "%s/regs/%s/%s.info", - config->internal_path, ju_path, ju) == -1) { - err.code = ENOMEM; - goto error_out; - } - regfile = fopen(int_fname, "r"); - if (regfile == NULL) { - err.code = errno; - if (errno == ENOENT) - err.desc = "Job not registered"; - else - err.desc = "Cannot open jobs's reg info file"; - goto error_out; - } - if (fscanf(regfile, "%d %ld.%ld %*s %*s %d ", &info_version, - ®_time_sec, ®_time_usec, &ownerlen) < 4 || ferror(regfile)) { - fclose(regfile); - err.code = errno; - err.desc = "Cannot read jobs's reg info file"; - goto error_out; - } - if (ownerlen) { - *owner = (char *) calloc(1, ownerlen+1); - if (!*owner) { - err.code = ENOMEM; - goto error_out; - } - if (fgets(*owner, ownerlen+1, regfile) == NULL) { - fclose(regfile); - free(*owner); - err.code = errno; - err.desc = "Cannot read jobs's reg info file"; - goto error_out; - } - } - fclose(regfile); - - tv_reg->tv_sec = reg_time_sec; - tv_reg->tv_usec = reg_time_usec; - -error_out: - free(int_fname); - free(ju); - free(ju_path); - if (err.code) { - return glite_jp_stack_error(ctx,&err); - } else { - return 0; - } -} - -static int get_job_info_int( - glite_jp_context_t ctx, - const char *int_fname, - char **jobid, - char **owner, - struct timeval *tv_reg -) -{ - FILE *regfile = NULL; - long reg_time_sec; - long reg_time_usec; - int ownerlen = 0; - int info_version; - char jobid_buf[256]; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - regfile = fopen(int_fname, "r"); - if (regfile == NULL) { - err.code = errno; - err.desc = "Cannot open jobs's reg info file"; - goto error_out; - } - if (fscanf(regfile, "%d %ld.%ld %s %*s %d ", &info_version, - ®_time_sec, ®_time_usec, jobid_buf, &ownerlen) < 5 || ferror(regfile)) { - fclose(regfile); - err.code = errno; - err.desc = "Cannot read jobs's reg info file"; - goto error_out; - } - *jobid = strdup(jobid_buf); - if (ownerlen) { - *owner = (char *) calloc(1, ownerlen+1); - if (!*owner) { - err.code = ENOMEM; - goto error_out; - } - if (fgets(*owner, ownerlen+1, regfile) == NULL) { - fclose(regfile); - free(*owner); - err.code = errno; - err.desc = "Cannot read jobs's reg info file"; - goto error_out; - } - } - fclose(regfile); - - tv_reg->tv_sec = reg_time_sec; - tv_reg->tv_usec = reg_time_usec; - -error_out: - if (err.code) { - return glite_jp_stack_error(ctx,&err); - } else { - return 0; - } -} - -int glite_jppsbe_get_job_metadata( - glite_jp_context_t ctx, - const char *job, - glite_jp_attrval_t attrs_inout[] -) -{ - int got_info = 0; - struct timeval tv_reg; - char *owner = NULL; - int got_tags = 0; - void *tags_handle = NULL; - glite_jp_tagval_t* tags = NULL; - int i,j; - glite_jp_error_t err; - - assert(job != NULL); - assert(attrs_inout != NULL); - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - for (i = 0; attrs_inout[i].attr.type != GLITE_JP_ATTR_UNDEF; i++) { - switch (attrs_inout[i].attr.type) { - case GLITE_JP_ATTR_OWNER: - case GLITE_JP_ATTR_TIME: - if (!got_info) { - if (get_job_info(ctx, job, &owner, &tv_reg)) { - err.code = ctx->error->code; - err.desc = "Cannot retrieve job info"; - goto error_out; - } - got_info = 1; - } - break; - case GLITE_JP_ATTR_TAG: - if (!got_tags) { - if (glite_jppsbe_open_file(ctx, job, GLITE_JP_FILECLASS_TAGS, - O_RDONLY, &tags_handle)) { - err.code = ctx->error->code; - err.desc = "Cannot open tag file"; - goto error_out; - } - if (glite_jpps_tag_readall(ctx, tags_handle, &tags)) { - err.code = ctx->error->code; - err.desc = "Cannot read tags"; - glite_jppsbe_close_file(ctx, tags_handle); - goto error_out; - } - glite_jppsbe_close_file(ctx, tags_handle); - got_tags = 1; - } - break; - default: - err.code = EINVAL; - err.desc = "Invalid attribute type"; - goto error_out; - break; - } - - switch (attrs_inout[i].attr.type) { - case GLITE_JP_ATTR_OWNER: - attrs_inout[i].value.s = strdup(owner); - if (!attrs_inout[i].value.s) { - err.code = ENOMEM; - err.desc = "Cannot copy owner string"; - goto error_out; - } - break; - case GLITE_JP_ATTR_TIME: - attrs_inout[i].value.time = tv_reg; - break; - case GLITE_JP_ATTR_TAG: - for (j = 0; tags[j].name != NULL; j++) { - if (!strcmp(tags[j].name, attrs_inout[i].attr.name)) { - if (glite_jpps_tagval_copy(ctx, &tags[j], - &attrs_inout[i].value.tag)) { - err.code = ENOMEM; - err.desc = "Cannot copy tag value"; - goto error_out; - } - break; - } - } - if (!tags[j].name) attrs_inout[i].value.tag.name = NULL; - break; - default: - break; - } - } - -error_out: - free(owner); - if (tags) for (j = 0; tags[j].name != NULL; j++) { - free(tags[j].name); - free(tags[j].value); - } - free(tags); - - if (err.code) { - while (i > 0) { - i--; - switch (attrs_inout[i].attr.type) { - case GLITE_JP_ATTR_OWNER: - free(attrs_inout[i].value.s); - break; - case GLITE_JP_ATTR_TAG: - free(attrs_inout[i].value.tag.name); - free(attrs_inout[i].value.tag.value); - default: - break; - } - } - return glite_jp_stack_error(ctx,&err); - } else { - return 0; - } -} -static int compare_timeval(struct timeval a, struct timeval b) -{ - if (a.tv_sec < b.tv_sec) return -1; - if (a.tv_sec > b.tv_sec) return 1; - if (a.tv_usec < b.tv_usec) return -1; - if (a.tv_usec > b.tv_usec) return 1; - return 0; -} - -static int query_phase2( - glite_jp_context_t ctx, - const char *ownerhash, - long regtime_tr, - int q_tags, - int md_tags, - const glite_jp_query_rec_t query[], - glite_jp_attrval_t metadata[], - int (*callback)( - glite_jp_context_t ctx, - const char *job, - const glite_jp_attrval_t metadata[] - ) -); - -static int query_phase2( - glite_jp_context_t ctx, - const char *ownerhash, - long regtime_tr, - int q_tags, - int md_tags, - const glite_jp_query_rec_t query[], - glite_jp_attrval_t metadata[], - int (*callback)( - glite_jp_context_t ctx, - const char *job, - const glite_jp_attrval_t metadata[] - ) -) -{ - char *time_dirname = NULL; - DIR *time_dirp = NULL; - struct dirent *jobent; - char *info_fname = NULL; - char *jobid = NULL; - char *owner = NULL; - struct timeval tv_reg; - void *tags_handle = NULL; - int matching; - int i, j; - glite_jp_tagval_t* tags = NULL; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - if (asprintf(&time_dirname, "%s/data/%s/%d", config->internal_path, - ownerhash, regtime_tr) == -1) { - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - time_dirp = opendir(time_dirname); - if (!time_dirp) { - free(time_dirname); - return 0; /* found nothing */ - } - while ((jobent = readdir(time_dirp)) != NULL) { - if (!strcmp(jobent->d_name, ".")) continue; - if (!strcmp(jobent->d_name, "..")) continue; - if (asprintf(&info_fname, "%s/%s/_info", time_dirname, - jobent->d_name) == -1) { - err.code = ENOMEM; - goto error_out; - } - if (get_job_info_int(ctx, info_fname, &jobid, &owner, &tv_reg)) { - err.code = EIO; - err.desc = "Cannot retrieve job info"; - goto error_out; - } - if (q_tags || md_tags) { - if (glite_jppsbe_open_file(ctx, jobid, GLITE_JP_FILECLASS_TAGS, - O_RDONLY, &tags_handle)) { - err.code = ctx->error->code; - err.desc = "Cannot open tag file"; - goto error_out; - } - if (glite_jpps_tag_readall(ctx, tags_handle, &tags)) { - err.code = ctx->error->code; - err.desc = "Cannot read tags"; - glite_jppsbe_close_file(ctx, tags_handle); - goto error_out; - } - glite_jppsbe_close_file(ctx, tags_handle); - tags_handle = NULL; - } - - matching = 1; - for (i = 0; matching && query[i].attr.type != GLITE_JP_ATTR_UNDEF; i++) { - switch (query[i].attr.type) { - case GLITE_JP_ATTR_OWNER: - if (query[i].value.s == NULL || - strcmp(query[i].value.s, owner)) matching = 0; - break; - case GLITE_JP_ATTR_TIME: - switch (query[i].op) { - case GLITE_JP_QUERYOP_EQUAL: - matching = !compare_timeval(tv_reg, query[i].value.time); - break; - case GLITE_JP_QUERYOP_UNEQUAL: - matching = compare_timeval(tv_reg, query[i].value.time); - break; - case GLITE_JP_QUERYOP_LESS: - matching = compare_timeval(tv_reg, query[i].value.time) < 0; - break; - case GLITE_JP_QUERYOP_GREATER: - matching = compare_timeval(tv_reg, query[i].value.time) > 0; - break; - case GLITE_JP_QUERYOP_WITHIN: - matching = compare_timeval(tv_reg, query[i].value.time) >= 0 - && compare_timeval(tv_reg, query[i].value2.time) <= 0; - break; - } - break; - case GLITE_JP_ATTR_TAG: - if (!tags) { - matching = 0; - break; - } - for (j = 0; tags[j].name != NULL; j++) { - if (!strcmp(tags[j].name, query[i].attr.name)) { - switch (query[i].op) { - case GLITE_JP_QUERYOP_EQUAL: - matching = !strcmp(tags[j].value, query[i].value.s); - break; - case GLITE_JP_QUERYOP_UNEQUAL: - matching = strcmp(tags[j].value, query[i].value.s); - break; - case GLITE_JP_QUERYOP_LESS: - matching = strcmp(tags[j].value, query[i].value.s) < 0; - break; - case GLITE_JP_QUERYOP_GREATER: - matching = strcmp(tags[j].value, query[i].value.s) > 0; - break; - case GLITE_JP_QUERYOP_WITHIN: - matching = strcmp(tags[j].value, query[i].value.s) >= 0 \ - && strcmp(tags[j].value, query[i].value2.s) <= 0 ; - break; - default: - break; - } - } - } - break; - default: - break; - } - } - if (!matching) { - free(info_fname); info_fname = NULL; - free(jobid); jobid = NULL; - if (tags) for (j = 0; tags[j].name != NULL; j++) { - free(tags[j].name); - free(tags[j].value); - } - free(tags); tags = NULL; - continue; - } - - for (i = 0; metadata[i].attr.type != GLITE_JP_ATTR_UNDEF; i++) { - switch (metadata[i].attr.type) { - case GLITE_JP_ATTR_OWNER: - metadata[i].value.s = owner; - break; - case GLITE_JP_ATTR_TIME: - metadata[i].value.time = tv_reg; - break; - case GLITE_JP_ATTR_TAG: - for (j = 0; tags[j].name != NULL; j++) { - if (!strcmp(tags[j].name, metadata[i].attr.name)) { - if (glite_jpps_tagval_copy(ctx, &tags[j], - &metadata[i].value.tag)) { - err.code = ENOMEM; - err.desc = "Cannot copy tag value"; - goto error_out; - } - break; - } - } - if (!tags[j].name) { - metadata[i].value.tag.name = NULL; - metadata[i].value.tag.value = NULL; - } - break; - default: - break; - } - } - (*callback)(ctx, jobid, metadata); - free(jobid); jobid = NULL; - while (i > 0) { - i--; - switch (metadata[i].attr.type) { - case GLITE_JP_ATTR_TAG: - free(metadata[i].value.tag.name); - free(metadata[i].value.tag.value); - default: - break; - } - } - } - -error_out: - if (tags) for (j = 0; tags[j].name != NULL; j++) { - free(tags[j].name); - free(tags[j].value); - } - if (tags_handle) glite_jppsbe_close_file(ctx, tags_handle); - free(info_fname); - free(owner); - free(jobid); - closedir(time_dirp); - free(time_dirname); - if (err.code) { - while (i > 0) { - i--; - switch (metadata[i].attr.type) { - case GLITE_JP_ATTR_TAG: - free(metadata[i].value.tag.name); - free(metadata[i].value.tag.value); - default: - break; - } - } - return glite_jp_stack_error(ctx,&err); - } else - return 0; -} - -int glite_jppsbe_query( - glite_jp_context_t ctx, - const glite_jp_query_rec_t query[], - const glite_jp_attrval_t metadata[], - int (*callback)( - glite_jp_context_t ctx, - const char *job, - const glite_jp_attrval_t metadata[] - ) -) -{ - /* XXX clone metadata */ - int i; - char *q_exact_owner = NULL; - char *ownerhash = NULL; - long q_min_time = 0; - long q_max_time = LONG_MAX; - long q_min_time_tr; - long q_max_time_tr; - int q_with_tags = 0; - int md_info = 0; - int md_tags = 0; - char *owner_dirname = NULL; - DIR *owner_dirp = NULL; - struct dirent *ttimeent; - char *data_dirname = NULL; - DIR *data_dirp = NULL; - struct dirent *ownerent; - long ttime = 0; - glite_jp_attrval_t *metadata_templ = NULL; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - for (i = 0; query[i].attr.type != GLITE_JP_ATTR_UNDEF; i++) { - if (query[i].attr.type == GLITE_JP_ATTR_OWNER && query[i].op == GLITE_JP_QUERYOP_EQUAL) { - q_exact_owner = query[i].value.s; - } - if (query[i].attr.type == GLITE_JP_ATTR_TIME) { - switch (query[i].op) { - case GLITE_JP_QUERYOP_EQUAL: - q_min_time = query[i].value.time.tv_sec; - q_max_time = query[i].value.time.tv_sec + 1; - break; - case GLITE_JP_QUERYOP_LESS: - if (q_max_time > query[i].value.time.tv_sec + 1) - q_max_time = query[i].value.time.tv_sec + 1; - break; - case GLITE_JP_QUERYOP_WITHIN: - if (q_max_time > query[i].value2.time.tv_sec + 1) - q_max_time = query[i].value2.time.tv_sec + 1; - /* fallthrough */ - case GLITE_JP_QUERYOP_GREATER: - if (q_min_time < query[i].value.time.tv_sec) - q_min_time = query[i].value.time.tv_sec; - break; - default: - err.code = EINVAL; - err.desc = "Invalid query op"; - return glite_jp_stack_error(ctx,&err); - break; - } - } - if (query[i].attr.type == GLITE_JP_ATTR_TAG) - q_with_tags = 1; - - } - - for (i = 0; metadata[i].attr.type != GLITE_JP_ATTR_UNDEF; i++) { - switch (metadata[i].attr.type) { - case GLITE_JP_ATTR_OWNER: - case GLITE_JP_ATTR_TIME: - md_info = 1; - break; - case GLITE_JP_ATTR_TAG: - md_tags = 1; - break; - default: - err.code = EINVAL; - err.desc = "Invalid attribute type in metadata parameter"; - return glite_jp_stack_error(ctx,&err); - break; - } - } - metadata_templ = (glite_jp_attrval_t *) calloc(i + 1, sizeof(glite_jp_attrval_t)); - if (!metadata_templ) { - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - memcpy(metadata_templ, metadata, (i + 1) * sizeof(glite_jp_attrval_t)); - - q_min_time_tr = regtime_trunc(q_min_time); - q_max_time_tr = regtime_ceil(q_max_time); - - if (q_exact_owner) { - ownerhash = str2md5(q_exact_owner); /* static buffer */ - if (asprintf(&owner_dirname, "%s/data/%s", config->internal_path, ownerhash) == -1) { - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - owner_dirp = opendir(owner_dirname); - free(owner_dirname); - if (!owner_dirp) { - free(metadata_templ); - return 0; /* found nothing */ - } - while ((ttimeent = readdir(owner_dirp)) != NULL) { - if (!strcmp(ttimeent->d_name, ".")) continue; - if (!strcmp(ttimeent->d_name, "..")) continue; - ttime = atol(ttimeent->d_name); - if (ttime >= q_min_time_tr && ttime < q_max_time_tr) { - if (query_phase2(ctx, ownerhash, ttime, q_with_tags, md_tags, - query, metadata_templ, callback)) { - err.code = EIO; - err.desc = "query_phase2() error"; - goto error_out; - } - } - } - } else { /* !q_exact_owner */ - if (asprintf(&data_dirname, "%s/data", config->internal_path) == -1) { - err.code = ENOMEM; - goto error_out; - } - data_dirp = opendir(data_dirname); - if (!data_dirp) { - err.code = EIO; - err.desc = "Cannot open data directory"; - goto error_out; - } - while ((ownerent = readdir(data_dirp)) != NULL) { - if (!strcmp(ownerent->d_name, ".")) continue; - if (!strcmp(ownerent->d_name, "..")) continue; - if (asprintf(&owner_dirname, "%s/data/%s", config->internal_path, - ownerent->d_name) == -1) { - err.code = ENOMEM; - goto error_out; - } - owner_dirp = opendir(owner_dirname); - free(owner_dirname); - if (!owner_dirp) { - err.code = EIO; - err.desc = "Cannot open owner data directory"; - goto error_out; - } - while ((ttimeent = readdir(owner_dirp)) != NULL) { - if (!strcmp(ttimeent->d_name, ".")) continue; - if (!strcmp(ttimeent->d_name, "..")) continue; - ttime = atol(ttimeent->d_name); - if (ttime >= q_min_time_tr && ttime < q_max_time_tr) { - if (query_phase2(ctx, ownerent->d_name, ttime, q_with_tags, md_tags, - query, metadata_templ, callback)) { - err.code = EIO; - err.desc = "query_phase2() error"; - goto error_out; - } - } - } - closedir(owner_dirp); owner_dirp = NULL; - } - closedir(data_dirp); data_dirp = NULL; - } - return 0; - -error_out: - if (owner_dirp) closedir(owner_dirp); - if (data_dirp) closedir(data_dirp); - free(data_dirname); - free(metadata_templ); - return glite_jp_stack_error(ctx,&err); -} - -/* XXX: -- no primary authorization yet -- no concurrency control yet -- partial success in pwrite,append -- "unique" part of jobid is assumed to be unique across bookkeeping servers -- repository versioning not fully implemented yet -*/ diff --git a/org.glite.jp.primary/src/is_client.c b/org.glite.jp.primary/src/is_client.c deleted file mode 100644 index 1d0446a..0000000 --- a/org.glite.jp.primary/src/is_client.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "glite/jp/types.h" - -#include "feed.h" -#include "jpis_H.h" -#include "jpis_.nsmap" - -int glite_jpps_single_feed( - glite_jp_context_t ctx, - const char *destination, - const char *job, - const glite_jp_attrval_t attrs[] -) -{ - /* TODO: really call JP Index server (via interlogger) */ - printf("feed to %s, job %s\n",destination,job); - - if (soap_call_jpsrv__UpdateJobs(ctx->other_soap,destination,"", - /* FIXME: feedId */ "", - /* FIXME: UpdateJobsData */ NULL, - 0, - NULL - )) fprintf(stderr,"UpdateJobs: %s %s\n",ctx->other_soap->fault->faultcode, - ctx->other_soap->fault->faultstring); - - return 0; -} diff --git a/org.glite.jp.primary/src/jptype_map.h b/org.glite.jp.primary/src/jptype_map.h deleted file mode 100644 index 6df0828..0000000 --- a/org.glite.jp.primary/src/jptype_map.h +++ /dev/null @@ -1,16 +0,0 @@ -#if GSOAP_VERSION >= 20700 -#define INPUT_SANDBOX jptype__UploadClass__INPUT_SANDBOX -#define OUTPUT_SANDBOX jptype__UploadClass__OUTPUT_SANDBOX -#define JOB_LOG jptype__UploadClass__JOB_LOG - -#define OWNER jptype__AttributeType__OWNER -#define TIME jptype__AttributeType__TIME -#define TAG jptype__AttributeType__TAG - -#define EQUAL jptype__QueryOp__EQUAL -#define UNEQUAL jptype__QueryOp__UNEQUAL -#define LESS jptype__QueryOp__LESS -#define GREATER jptype__QueryOp__GREATER -#define WITHIN jptype__QueryOp__WITHIN -#endif - diff --git a/org.glite.jp.primary/src/simple_server.c b/org.glite.jp.primary/src/simple_server.c deleted file mode 100644 index 3bbb743..0000000 --- a/org.glite.jp.primary/src/simple_server.c +++ /dev/null @@ -1,59 +0,0 @@ -#include - -#include "glite/jp/types.h" -#include "glite/jp/context.h" - -#include "jpps_H.h" - -extern SOAP_NMAC struct Namespace jpis__namespaces[],jpps__namespaces[]; - -int main(int argc, char *argv[]) { - struct soap soap; - int i, m, s; // master and slave sockets - - glite_jp_context_t ctx; - - soap_init(&soap); - soap_set_namespaces(&soap, jpps__namespaces); - - glite_jp_init_context(&ctx); - - if (glite_jppsbe_init(ctx, &argc, argv)) { - /* XXX log */ - fputs(glite_jp_error_chain(ctx), stderr); - exit(1); - } - - soap.user = (void *) ctx; - - ctx->other_soap = soap_new(); - soap_init(ctx->other_soap); - soap_set_namespaces(ctx->other_soap,jpis__namespaces); - - srand48(time(NULL)); /* feed id generation */ - - m = soap_bind(&soap, NULL, 8901, 100); - if (m < 0) - soap_print_fault(&soap, stderr); - else - { - fprintf(stderr, "Socket connection successful: master socket = %d\n", m); - for (i = 1; ; i++) { - s = soap_accept(&soap); - if (s < 0) { - soap_print_fault(&soap, stderr); - break; - } - jpps__serve(&soap); // process RPC request - soap_destroy(&soap); // clean up class instances - soap_end(&soap); // clean up everything and close socket - glite_jp_run_deferred(ctx); - } - } - soap_done(&soap); // close master socket - - return 0; -} - -/* XXX: we don't use it */ -SOAP_NMAC struct Namespace namespaces[] = { {NULL,NULL} }; diff --git a/org.glite.jp.primary/src/soap_ops.c b/org.glite.jp.primary/src/soap_ops.c deleted file mode 100644 index 1e5534b..0000000 --- a/org.glite.jp.primary/src/soap_ops.c +++ /dev/null @@ -1,374 +0,0 @@ -#include -#include - -#include "glite/jp/types.h" -#include "glite/jp/context.h" - -#include "feed.h" - -#include "jpps_H.h" -/* #include "JobProvenancePS.nsmap" */ -#include "jpps_.nsmap" - -#include "jptype_map.h" - -static struct jptype__GenericJPFaultType *jp2s_error(struct soap *soap, - const glite_jp_error_t *err) -{ - struct jptype__GenericJPFaultType *ret = NULL; - if (err) { - ret = soap_malloc(soap,sizeof *ret); - memset(ret,0,sizeof *ret); - ret->code = err->code; - ret->source = soap_strdup(soap,err->source); - ret->text = soap_strdup(soap,strerror(err->code)); - ret->description = soap_strdup(soap,err->desc); - ret->reason = jp2s_error(soap,err->reason); - } - return ret; -} - -static void err2fault(const glite_jp_context_t ctx,struct soap *soap) -{ - char *et; - struct SOAP_ENV__Detail *detail = soap_malloc(soap,sizeof *detail); - struct _GenericJPFault *f = soap_malloc(soap,sizeof *f); - - - f->jptype__GenericJPFault = jp2s_error(soap,ctx->error); - - detail->__type = SOAP_TYPE__GenericJPFault; -#if GSOAP_VERSION >= 20700 - detail->fault = f; -#else - detail->value = f; -#endif - detail->__any = NULL; - - soap_receiver_fault(soap,"Oh, shit!",NULL); - if (soap->version == 2) soap->fault->SOAP_ENV__Detail = detail; - else soap->fault->detail = detail; -} - -static glite_jp_fileclass_t s2jp_fileclass(enum jptype__UploadClass class) -{ - switch (class) { - case INPUT_SANDBOX: return GLITE_JP_FILECLASS_INPUT; - case OUTPUT_SANDBOX: return GLITE_JP_FILECLASS_OUTPUT; - case JOB_LOG: return GLITE_JP_FILECLASS_LBLOG; - default: return GLITE_JP_FILECLASS_UNDEF; - } -} - -static void s2jp_tag(const struct jptype__TagValue *stag,glite_jp_tagval_t *jptag) -{ - memset(jptag,0,sizeof *jptag); - jptag->name = strdup(stag->name); - jptag->sequence = stag->sequence ? *stag->sequence : 0; - jptag->timestamp = stag->timestamp ? *stag->timestamp : 0; - if (stag->stringValue) jptag->value = strdup(stag->stringValue); - else if (stag->blobValue) { - jptag->binary = 1; - jptag->size = stag->blobValue->__size; - jptag->value = (char *) stag->blobValue->__ptr; - } -} - -#define CONTEXT_FROM_SOAP(soap,ctx) glite_jp_context_t ctx = (glite_jp_context_t) ((soap)->user) - -SOAP_FMAC5 int SOAP_FMAC6 jpsrv__RegisterJob( - struct soap *soap, - char *job, - struct jpsrv__RegisterJobResponse *response) -{ - CONTEXT_FROM_SOAP(soap,ctx); - char *owner = glite_jp_peer_name(ctx); - glite_jp_attrval_t owner_val[2]; - - if (glite_jppsbe_register_job(ctx,job,owner)) { - err2fault(ctx,soap); - free(owner); - return SOAP_FAULT; - } - - owner_val[0].attr.type = GLITE_JP_ATTR_OWNER; - owner_val[0].value.s = owner; - owner_val[1].attr.type = GLITE_JP_ATTR_UNDEF; - -/* XXX: errrors should be ingored but not silently */ - glite_jpps_match_attr(ctx,job,owner_val); - free(owner); - - return SOAP_OK; -} - - -SOAP_FMAC5 int SOAP_FMAC6 jpsrv__StartUpload( - struct soap *soap, - char *job, - enum jptype__UploadClass class, - time_t commit_before, - char *content_type, - struct jpsrv__StartUploadResponse *response) -{ - CONTEXT_FROM_SOAP(soap,ctx); - glite_jp_fileclass_t jclass = s2jp_fileclass(class); - char *destination; - - if (glite_jppsbe_start_upload(ctx,job,jclass,content_type,&destination,&commit_before)) { - err2fault(ctx,soap); - return SOAP_FAULT; - } - - response->destination = soap_strdup(soap,destination); - free(destination); - response->commitBefore = commit_before; - - return SOAP_OK; -} - -SOAP_FMAC5 int SOAP_FMAC6 jpsrv__CommitUpload( - struct soap *soap, - char *destination, - struct jpsrv__CommitUploadResponse *response) -{ - CONTEXT_FROM_SOAP(soap,ctx); - char *job = NULL; - glite_jp_fileclass_t class; - - if (glite_jppsbe_commit_upload(ctx,destination)) { - err2fault(ctx,soap); - return SOAP_FAULT; - } - - /* XXX: should not fail when commit_upload was OK */ - glite_jppsbe_destination_info(ctx,destination,&job,&class); - - /* XXX: ignore errors but don't fail silenty */ - glite_jpps_match_file(ctx,job,class); - - return SOAP_OK; -} - -SOAP_FMAC5 int SOAP_FMAC6 jpsrv__RecordTag( - struct soap *soap, - char *job, - struct jptype__TagValue *tag, - struct jpsrv__RecordTagResponse *response) -{ - CONTEXT_FROM_SOAP(soap,ctx); - void *tagfile; - - glite_jp_tagval_t mytag; - - if (glite_jppsbe_open_file(ctx,job,GLITE_JP_FILECLASS_TAGS, - O_WRONLY|O_CREAT,&tagfile)) - { - err2fault(ctx,soap); - return SOAP_FAULT; - } - - if (glite_jpps_tag_append(ctx,tagfile,&mytag)) { - err2fault(ctx,soap); - glite_jppsbe_close_file(ctx,tagfile); - return SOAP_FAULT; - } - - if (glite_jppsbe_close_file(ctx,tagfile)) { - err2fault(ctx,soap); - return SOAP_FAULT; - } - - /* XXX: ignore errors but don't fail silenty */ - - s2jp_tag(tag,&mytag); - glite_jpps_match_tag(ctx,job,&mytag); - - return SOAP_OK; -} - -static void s2jp_attr(const struct jptype__Attribute *in,glite_jp_attr_t *out) -{ - switch (in->type) { - case OWNER: out->type = GLITE_JP_ATTR_OWNER; break; - case TIME: out->type = GLITE_JP_ATTR_TIME; - out->name = strdup(in->name); - break; - case TAG: out->type = GLITE_JP_ATTR_TAG; - out->name = strdup(in->name); - break; - default: break; - } -} - -static void s2jp_queryval( - const char *in, - glite_jp_attrtype_t type, - union _glite_jp_query_rec_val *out) -{ - switch (type) { - case GLITE_JP_ATTR_OWNER: - case GLITE_JP_ATTR_TAG: - out->s = strdup(in); - break; - case GLITE_JP_ATTR_TIME: - out->time.tv_sec = atoi(in); - break; - } -} - -static void s2jp_query(const struct jptype__PrimaryQueryElement *in, glite_jp_query_rec_t *out) -{ - s2jp_attr(in->attr,&out->attr); - - switch (in->op) { - case EQUAL: out->op = GLITE_JP_QUERYOP_EQUAL; break; - case UNEQUAL: out->op = GLITE_JP_QUERYOP_UNEQUAL; break; - case LESS: out->op = GLITE_JP_QUERYOP_LESS; break; - case GREATER: out->op = GLITE_JP_QUERYOP_GREATER; break; - case WITHIN: - out->op = GLITE_JP_QUERYOP_WITHIN; - s2jp_queryval(in->value2,out->attr.type,&out->value2); - break; - } - - s2jp_queryval(in->value,out->attr.type,&out->value); -} - -SOAP_FMAC5 int SOAP_FMAC6 jpsrv__FeedIndex( - struct soap *soap, - char *destination, - struct jptype__Attributes *attributes, - struct jptype__PrimaryQuery *query, - enum xsd__boolean history, - enum xsd__boolean continuous, - struct jpsrv__FeedIndexResponse *response) -{ - -/* deferred processing: return feed_id to the index server first, - * start feeding it afterwards -- not before the index server actually - * knows feed_id and is ready to accept the feed. - * - * Has to be done within the same server slave, - * passed through the context */ - - CONTEXT_FROM_SOAP(soap,ctx); - char *feed_id = NULL; - time_t expires = 0; - int ret = SOAP_OK; - - glite_jp_attr_t *attrs = calloc(attributes->__sizeitem+1,sizeof *attrs); - glite_jp_query_rec_t *qry = calloc(query->__sizeitem+1,sizeof *qry); - int i; - - glite_jp_clear_error(ctx); - - for (i = 0; i__sizeitem; i++) s2jp_attr(attributes->item[i],attrs+i); - for (i = 0; i__sizeitem; i++) s2jp_query(query->item[i],qry+i); - - if (history) { - if (glite_jpps_run_feed(ctx,destination,attrs,qry,&feed_id)) { - err2fault(ctx,soap); - ret = SOAP_FAULT; - goto cleanup; - } - } - - if (continuous) { - if (glite_jpps_register_feed(ctx,destination,attrs,qry,&feed_id,&expires)) { - err2fault(ctx,soap); - ret = SOAP_FAULT; - goto cleanup; - } - } - - if (!history && !continuous) { - glite_jp_error_t err; - err.code = EINVAL; - err.source = __FUNCTION__; - err.desc = "at least one of and must be true"; - glite_jp_stack_error(ctx,&err); - err2fault(ctx,soap); - ret = SOAP_FAULT; - goto cleanup; - } - - response->expires = expires; - response->feedId = soap_strdup(soap,feed_id); - -cleanup: - free(feed_id); - for (i=0; attrs[i].type; i++) free(attrs[i].name); - free(attrs); - for (i=0; qry[i].attr.type; i++) glite_jp_free_query_rec(qry+i); - free(qry); - - return ret; -} - -SOAP_FMAC5 int SOAP_FMAC6 jpsrv__FeedIndexRefresh( - struct soap *soap, - char *feed_id, - struct jpsrv__FeedIndexRefreshResponse *response) -{ - fprintf(stderr,"%s: not implemented\n",__FUNCTION__); - abort(); -} - -SOAP_FMAC5 int SOAP_FMAC6 jpsrv__GetJob( - struct soap *soap, - char *job, - struct jpsrv__GetJobResponse *response) -{ - CONTEXT_FROM_SOAP(soap,ctx); - char *url; - - struct { - glite_jp_fileclass_t type; - char **url; - char *name; - } tab[] = { - { GLITE_JP_FILECLASS_INPUT, &response->inputSandbox, "input sandbox" }, - { GLITE_JP_FILECLASS_OUTPUT, &response->outputSandbox, "output sandbox" }, - { GLITE_JP_FILECLASS_LBLOG, &response->jobLog, "L&B log" }, - { GLITE_JP_FILECLASS_TAGS, &response->tags, "JP tags" }, - { GLITE_JP_FILECLASS_UNDEF, NULL, NULL } - }; - - int i,gotone = 0; - glite_jp_error_t err; - - for (i=0; tab[i].type; i++) { - glite_jp_clear_error(ctx); - switch (glite_jppsbe_get_job_url(ctx,job,tab[i].type,&url)) { - case 0: *tab[i].url = soap_strdup(soap,url); - free(url); - gotone = 1; - break; - case ENOENT: - *tab[i].url = NULL; - break; - default: - err.code = ctx->error->code; - err.source = "jpsrv__GetJob()"; - err.desc = tab[i].name; - glite_jp_stack_error(ctx,&err); - err2fault(ctx,soap); - glite_jp_clear_error(ctx); - return SOAP_FAULT; - } - } - - if (!gotone) { - glite_jp_clear_error(ctx); - err.code = ENOENT; - err.source = __FUNCTION__; - err.desc = "No file found for this job"; - glite_jp_stack_error(ctx,&err); - err2fault(ctx,soap); - glite_jp_clear_error(ctx); - return SOAP_FAULT; - } - return SOAP_OK; -} - diff --git a/org.glite.jp.primary/src/tags.c b/org.glite.jp.primary/src/tags.c deleted file mode 100644 index 1f11b4d..0000000 --- a/org.glite.jp.primary/src/tags.c +++ /dev/null @@ -1,233 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include "tags.h" -#include "backend.h" - -/* magic name_len value_len binary sequence timestamp */ -#define HEADER "JP#TAG# %05u %012lu %c %05u %012lu#" -#define HEADER_SIZE 48 - -int glite_jpps_tag_append( - glite_jp_context_t ctx, - void *handle, - const glite_jp_tagval_t *tag -) -{ - char hdr[HEADER_SIZE+1]; - glite_jp_error_t err; - - unsigned long vlen = tag->binary ? tag->size : - (tag->value ? strlen(tag->value) : 0); - int nlen; - - memset(&err,0,sizeof err); - err.source = "glite_jpps_tag_append()"; - - if (!tag->name) { - err.code = EINVAL; - err.desc = "tag name"; - return glite_jp_stack_error(ctx,&err); - } - - nlen = strlen(tag->name); - - assert(sprintf(hdr,HEADER,nlen,vlen, - tag->binary ? "B" : "S", - tag->sequence, tag->timestamp) == HEADER_SIZE); - - if (glite_jppsbe_append(ctx,handle,hdr,HEADER_SIZE)) { - err.code = EIO; - err.desc = "write tag header"; - return glite_jp_stack_error(ctx,&err); - } - - if (glite_jppsbe_append(ctx,handle,tag->name,nlen)) { - err.code = EIO; - err.desc = "write tag name"; - return glite_jp_stack_error(ctx,&err); - } - - if (glite_jppsbe_append(ctx,handle,tag->value,vlen)) { - err.code = EIO; - err.desc = "write tag value"; - return glite_jp_stack_error(ctx,&err); - } - - return 0; -} - -int glite_jpps_tagval_copy( - glite_jp_context_t ctx, - glite_jp_tagval_t *from, - glite_jp_tagval_t *to -) -{ - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - to->name = strdup(from->name); - if (!to->name) { - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - to->sequence = from->sequence; - to->timestamp = from->timestamp; - to->binary = from->binary; - to->size = from->size; - to->value = (char *) malloc(to->size); - if (!to->value) { - free(to->name); - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - memcpy(from->value, to->value, to->size); - - return 0; -} - -int glite_jpps_tag_read( - glite_jp_context_t ctx, - void *handle, - off_t offset, - glite_jp_tagval_t *tagvalue, - size_t *shift -) -{ - char hdr[HEADER_SIZE+1]; - unsigned int nlen; - unsigned long vlen; - char binary; - unsigned sequence; - unsigned timestamp; - char * name = NULL; - char * value = NULL; - ssize_t ret; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - hdr[HEADER_SIZE] = '\0'; - if (glite_jppsbe_pread(ctx, handle, hdr, HEADER_SIZE, offset, &ret)) { - err.code = EIO; - err.desc = "Cannot read tag header"; - goto error_out; - } - if (ret == 0) { - err.code = ENOENT; - err.desc = "No more tags in the file"; - goto error_out; - } - /* #define HEADER "JP#TAG# %05u %012lu %c %05u %012lu#" */ - if (sscanf(hdr, HEADER, &nlen, &vlen, &binary, &sequence, ×tamp) < 5) { - err.code = EILSEQ; - err.desc = "Incorrect tag header format"; - goto error_out; - } - name = (char*) malloc(nlen + 1); - if (!name) { - err.code = ENOMEM; - goto error_out; - } - name[nlen] = '\0'; - value = (char*) malloc(vlen + 1); - if (!value) { - err.code = ENOMEM; - goto error_out; - } - value[vlen] = '\0'; - if (glite_jppsbe_pread(ctx, handle, name, nlen, offset + HEADER_SIZE, &ret)) { - err.code = EIO; - err.desc = "Cannot read tag name"; - goto error_out; - } - if (glite_jppsbe_pread(ctx, handle, value, vlen, offset + HEADER_SIZE + nlen, &ret)) { - err.code = EIO; - err.desc = "Cannot read tag value"; - goto error_out; - } - - tagvalue->name = name; - tagvalue->sequence = sequence; - tagvalue->timestamp = timestamp; - tagvalue->binary = (binary == 'B') ? 1 : 0; - tagvalue->size = vlen; - tagvalue->value = value; - - *shift = HEADER_SIZE + nlen + vlen; - - return 0; -error_out: - free(name); - free(value); - return glite_jp_stack_error(ctx,&err); -} - -/* -int glite_jpps_tag_read(glite_jp_context_t, void *, off_t, glite_jp_tagval_t *, size_t); -int glite_jpps_tag_readall(glite_jp_context_t, void *, glite_jp_tagval_t **); -*/ - -int glite_jpps_tag_readall( - glite_jp_context_t ctx, - void *handle, - glite_jp_tagval_t **tags_out -) -{ - glite_jp_tagval_t * tags = NULL; - void * newspace; - int ntags = 0; - int ntagspace = 0; - off_t offset = 0; - int ret; - size_t shift; - glite_jp_error_t err; - - glite_jp_clear_error(ctx); - memset(&err,0,sizeof err); - err.source = __FUNCTION__; - - ntagspace = 1; - tags = (glite_jp_tagval_t *) calloc(ntagspace + 1, sizeof(*tags)); - if (!tags) { - err.code = ENOMEM; - return glite_jp_stack_error(ctx,&err); - } - while (!(ret = glite_jpps_tag_read(ctx, handle, offset, &tags[ntags], &shift))) { - offset += shift; - ntags++; - if (ntagspace <= ntags) { - ntagspace += 1; - newspace = realloc(tags, (ntagspace + 1) * sizeof(*tags)); - if (!newspace) { - err.code = ENOMEM; - goto error_out; - } - tags = (glite_jp_tagval_t *) newspace; - } - } - if (ret == ENOENT) { - *tags_out = tags; - return 0; - } else { - err.code = EIO; - err.desc = "Error reading tag value"; - } - -error_out: - for (; ntags-- ;) { - free(tags[ntags].name); - free(tags[ntags].value); - } - free(tags); - return glite_jp_stack_error(ctx,&err); -} diff --git a/org.glite.jp.primary/src/tags.h b/org.glite.jp.primary/src/tags.h deleted file mode 100644 index 0d8afa8..0000000 --- a/org.glite.jp.primary/src/tags.h +++ /dev/null @@ -1 +0,0 @@ -int glite_jpps_tag_append(glite_jp_context_t,void *,const glite_jp_tagval_t *); diff --git a/org.glite.jp.primary/src/typemap.dat b/org.glite.jp.primary/src/typemap.dat deleted file mode 100644 index 7032cb2..0000000 --- a/org.glite.jp.primary/src/typemap.dat +++ /dev/null @@ -1,2 +0,0 @@ -jpsrv = http://glite.org/wsdl/services/jp -jptype = http://glite.org/wsdl/types/jp diff --git a/org.glite.jp/.cvsignore b/org.glite.jp/.cvsignore deleted file mode 100644 index 3a4edf6..0000000 --- a/org.glite.jp/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -.project diff --git a/org.glite.jp/build.xml b/org.glite.jp/build.xml deleted file mode 100644 index 74ce806..0000000 --- a/org.glite.jp/build.xml +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - - Ant build file to build the GLite Job Provenance Subsystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Preparing directories ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <project name="${subsystem.name}" type="post-subsystem" packageName="${global.prefix}-${subsystem.prefix}"/> - - - - diff --git a/org.glite.jp/project/JobProvenance.wsdl b/org.glite.jp/project/JobProvenance.wsdl deleted file mode 100644 index 26f97a4..0000000 --- a/org.glite.jp/project/JobProvenance.wsdl +++ /dev/null @@ -1,531 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Register job with JP primary storage. -Job registration in LB is propagated to JP immediately so that JP is aware of the job, -despite no furhter information is available in it. - -Input: JobId - -Output: N/A - -Faults: GenericJPFault - - - - - - - Initiate upload of of sandbox/dump of job life log from LB. -WM component responsible for job sandbox management and LB server call JP to declare -intention to upload intput/output sandbox and job life log. - -Input: - -uclass: type of the upload - INPUT_SANDBOX, OUTPUT_SANDBOX, JOB_LOG - -commitTimeout: upper limit on time for which JP waits for committing this upload transaction - -contentType: MIME type of the uploaded file - -Output: - -destination: URL where the client should upload the file - -commitBefore: acutual time when the upload transaction times out - -Faults: GenericJPFault - - -Initiate upload of of sandbox/dump of job life log from LB. - - - - - - Confirm upload. -Should be called after a file upload initiaded with StartUpload is finished. - -Input: - -destination: Upload destination URL (to match with the original request) - -Output: - -Faults: GenericJPFault - - - - - - - Record a value of user tag. -JP tags are either standalone or override values of their LB counterparts. -However, JP tag values are still distinguishable those inherited from LB. -JP tags may be either strings or blobs. - -Input: - -jobid: - -tag: structure containing name, timestamp, optional sequence number to order tag values -without relying on timestamps, and string or blob value. - -Output: N/A - -Faults: GenericJPFault - - - - - - - Start feeding JP index server. -Called by the index server to start batch feed, and optionally also subscribe for incremental feed. - -JP index server subscribes with JP primary storage using a query -containing conditions on primary metadata and a list of queryable attributes -of the index server (i.e. data which should be sent to the index server). - -When a matching job record is created or modified within the primary storage -the job record data are sent to the subscribed index server. - -The subscription is soft-state, it expires after certain time unless refreshed by the client explicitely. - -In the batch mode the query has the same form -with additional flag asking for all matching records (i.e.\ not only -arriving afterwards). - -Input: - -destination: where to send the job record data - -attributes: which job record attributes should be sent to the requesting index server - -conditions: list of query conditions. Each conditions has the form Attribute Operator Value, -where Attribute is any of job record attributes and Operator is one of EQUAL, UNEQUAL, LESS, GREATER, WITHIN. - -continuous: flag determining that the query is incremental (not batch) - -Output: - -feedId: unique Id of the feed request, to be used in refresh, cancelation etc. - -expires: when the feed times out. Must be refreshed before this time. - -Faults: GenericJPFault - - - - - - - Extend batch feed subscription (used by index server) - -Input: feedId returned previously by FeedIndex - -Output: the same as for FeedIndex - -Faults: GenericJPFault - - - - - - - Retrieve job record URL's when jobid is known -Used either to bypass JP index server query for this specific case, or after the index server query to -retrieve actual job record. - -Input: jobid - -Output: - -jobLog, inputSandbox, outputSandbox, tags: URL's to components of the job record. - -Faults: GenericJPFault - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Job Provenance Primary Storage service - - - - - - - - - - - - - - - - - - - - - - Store or update information on jobs within the JP index server. -Called directly by the primary storage, used for both batch and incremental feed. - -Input: - -data: list of job record updates. Each contains jobid, list of JP attribute values and user tag values. - -feedDone: flag indicating end of batch feed. (In order to avoid potential problems with buffer allocation -the huge dataset of batch feed is split into reasonable chunks and delivered with more UpdateJobs calls.) - -Output: N/A - -Faults: GenericJPFault - - - - - - - - - Retrieve pointers to job records of jobs matching a query. -Input: conditions - list of lists of query conditions. - Elements of the inner lists refer to a single job attribute, the conditions are or-ed. - Elements of the outer list may refer to different job attributes, they are and-ed. - -Output: - -jobs: list of JobId, PSContact (URL of the primary storage which manges this job) pairs - -Faults: GenericJPFault - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Job Provenance Index service - - - - - - - diff --git a/org.glite.jp/project/JobProvenanceIS.wsdl b/org.glite.jp/project/JobProvenanceIS.wsdl deleted file mode 100644 index 84c8844..0000000 --- a/org.glite.jp/project/JobProvenanceIS.wsdl +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - Store or update information on jobs within the JP index server. -Called directly by the primary storage, used for both batch and incremental feed. - -Input: - -data: list of job record updates. Each contains jobid, list of JP attribute values and user tag values. - -feedDone: flag indicating end of batch feed. (In order to avoid potential problems with buffer allocation -the huge dataset of batch feed is split into reasonable chunks and delivered with more UpdateJobs calls.) - -Output: N/A - -Faults: GenericJPFault - - - - - - - - - Retrieve pointers to job records of jobs matching a query. -Input: conditions - list of lists of query conditions. - Elements of the inner lists refer to a single job attribute, the conditions are or-ed. - Elements of the outer list may refer to different job attributes, they are and-ed. - -Output: - -jobs: list of JobId, PSContact (URL of the primary storage which manges this job) pairs - -Faults: GenericJPFault - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Job Provenance Index service - - - - - - - diff --git a/org.glite.jp/project/JobProvenancePS.wsdl b/org.glite.jp/project/JobProvenancePS.wsdl deleted file mode 100644 index 7c777dd..0000000 --- a/org.glite.jp/project/JobProvenancePS.wsdl +++ /dev/null @@ -1,307 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Register job with JP primary storage. -Job registration in LB is propagated to JP immediately so that JP is aware of the job, -despite no furhter information is available in it. - -Input: JobId - -Output: N/A - -Faults: GenericJPFault - - - - - - - Initiate upload of of sandbox/dump of job life log from LB. -WM component responsible for job sandbox management and LB server call JP to declare -intention to upload intput/output sandbox and job life log. - -Input: - -uclass: type of the upload - INPUT_SANDBOX, OUTPUT_SANDBOX, JOB_LOG - -commitTimeout: upper limit on time for which JP waits for committing this upload transaction - -contentType: MIME type of the uploaded file - -Output: - -destination: URL where the client should upload the file - -commitBefore: acutual time when the upload transaction times out - -Faults: GenericJPFault - - -Initiate upload of of sandbox/dump of job life log from LB. - - - - - - Confirm upload. -Should be called after a file upload initiaded with StartUpload is finished. - -Input: - -destination: Upload destination URL (to match with the original request) - -Output: - -Faults: GenericJPFault - - - - - - - Record a value of user tag. -JP tags are either standalone or override values of their LB counterparts. -However, JP tag values are still distinguishable those inherited from LB. -JP tags may be either strings or blobs. - -Input: - -jobid: - -tag: structure containing name, timestamp, optional sequence number to order tag values -without relying on timestamps, and string or blob value. - -Output: N/A - -Faults: GenericJPFault - - - - - - - Start feeding JP index server. -Called by the index server to start batch feed, and optionally also subscribe for incremental feed. - -JP index server subscribes with JP primary storage using a query -containing conditions on primary metadata and a list of queryable attributes -of the index server (i.e. data which should be sent to the index server). - -When a matching job record is created or modified within the primary storage -the job record data are sent to the subscribed index server. - -The subscription is soft-state, it expires after certain time unless refreshed by the client explicitely. - -In the batch mode the query has the same form -with additional flag asking for all matching records (i.e.\ not only -arriving afterwards). - -Input: - -destination: where to send the job record data - -attributes: which job record attributes should be sent to the requesting index server - -conditions: list of query conditions. Each conditions has the form Attribute Operator Value, -where Attribute is any of job record attributes and Operator is one of EQUAL, UNEQUAL, LESS, GREATER, WITHIN. - -continuous: flag determining that the query is incremental (not batch) - -Output: - -feedId: unique Id of the feed request, to be used in refresh, cancelation etc. - -expires: when the feed times out. Must be refreshed before this time. - -Faults: GenericJPFault - - - - - - - Extend batch feed subscription (used by index server) - -Input: feedId returned previously by FeedIndex - -Output: the same as for FeedIndex - -Faults: GenericJPFault - - - - - - - Retrieve job record URL's when jobid is known -Used either to bypass JP index server query for this specific case, or after the index server query to -retrieve actual job record. - -Input: jobid - -Output: - -jobLog, inputSandbox, outputSandbox, tags: URL's to components of the job record. - -Faults: GenericJPFault - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Job Provenance Primary Storage service - - - - - diff --git a/org.glite.jp/project/JobProvenanceTypes.wsdl b/org.glite.jp/project/JobProvenanceTypes.wsdl deleted file mode 100644 index e1a6db4..0000000 --- a/org.glite.jp/project/JobProvenanceTypes.wsdl +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.jp/project/JobProvenanceTypes.xsd b/org.glite.jp/project/JobProvenanceTypes.xsd deleted file mode 100644 index 743126f..0000000 --- a/org.glite.jp/project/JobProvenanceTypes.xsd +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.jp/project/build.properties b/org.glite.jp/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.jp/project/dependencies.properties b/org.glite.jp/project/dependencies.properties deleted file mode 100644 index afbbc58..0000000 --- a/org.glite.jp/project/dependencies.properties +++ /dev/null @@ -1,11 +0,0 @@ -################################################################### -# System dependencies -################################################################### - -org.glite.version = HEAD -org.glite.jp.version = HEAD - -# Component dependencies tag = do not remove this line = -org.glite.jp.common.version = HEAD -org.glite.jp.index.version = HEAD -org.glite.jp.primary.version = HEAD diff --git a/org.glite.jp/project/glite.jp.csf.xml b/org.glite.jp/project/glite.jp.csf.xml deleted file mode 100644 index 5189cea..0000000 --- a/org.glite.jp/project/glite.jp.csf.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The org.glite and org.glite.jp modules have been updated, please rerun the configuration file - - - - - The org.glite and org.glite.jp modules have been updated, please rerun the configuration file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.jp/project/properties.xml b/org.glite.jp/project/properties.xml deleted file mode 100755 index 276cf76..0000000 --- a/org.glite.jp/project/properties.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.jp/project/run-workspace b/org.glite.jp/project/run-workspace deleted file mode 100644 index a5d1f54..0000000 --- a/org.glite.jp/project/run-workspace +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -cd ../.. - -cvs co org.glite -cvs co org.glite.jp - -cd org.glite.jp/project -ant -f glite.jp.csf.xml - diff --git a/org.glite.jp/project/taskdefs.xml b/org.glite.jp/project/taskdefs.xml deleted file mode 100755 index c4cc889..0000000 --- a/org.glite.jp/project/taskdefs.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/org.glite.jp/project/version.properties b/org.glite.jp/project/version.properties deleted file mode 100644 index e9fd055..0000000 --- a/org.glite.jp/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Nov 25 20:15:16 CET 2004 -module.version=0.1.0 -module.build=2 -module.age=1 diff --git a/org.glite.lb.client-interface/.cvsignore b/org.glite.lb.client-interface/.cvsignore deleted file mode 100644 index 1df717b..0000000 --- a/org.glite.lb.client-interface/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -.project -.cdtproject \ No newline at end of file diff --git a/org.glite.lb.client-interface/LICENSE b/org.glite.lb.client-interface/LICENSE deleted file mode 100644 index 259a91f..0000000 --- a/org.glite.lb.client-interface/LICENSE +++ /dev/null @@ -1,69 +0,0 @@ -LICENSE file for EGEE Middleware -================================ - -Copyright (c) 2004 on behalf of the EU EGEE Project: -The European Organization for Nuclear Research (CERN), -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Datamat Spa, Italy -Centre National de la Recherche Scientifique (CNRS), France -CS Systeme d'Information (CSSI), France -Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden -Universiteit van Amsterdam (UvA), Netherlands -University of Helsinki (UH.HIP), Finlan -University of Bergen (UiB), Norway -Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. The end-user documentation included with the redistribution, if -any, must include the following acknowledgment: "This product includes -software developed by The EU EGEE Project (http://cern.ch/eu-egee/)." -Alternatively, this acknowledgment may appear in the software itself, if -and wherever such third-party acknowledgments normally appear. - -4. The names EGEE and the EU EGEE Project must not be -used to endorse or promote products derived from this software without -prior written permission. For written permission, please contact -. - -5. You are under no obligation whatsoever to provide anyone with any -bug fixes, patches, or upgrades to the features, functionality or -performance of the Software ("Enhancements") that you may develop over -time; however, if you choose to provide your Enhancements to The EU -EGEE Project, or if you choose to otherwise publish or distribute your -Enhancements, in source code form without contemporaneously requiring -end users of The EU EGEE Proejct to enter into a separate written license -agreement for such Enhancements, then you hereby grant The EU EGEE Project -a non-exclusive, royalty-free perpetual license to install, use, copy, -modify, prepare derivative works, incorporate into the EGEE Middleware -or any other computer software, distribute, and sublicense your -Enhancements or derivative works thereof, in binary and source code -form (if any), whether developed by The EU EGEE Project or third parties. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL PROJECT OR ITS CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This software consists of voluntary contributions made by many -individuals on behalf of the EU EGEE Prject. For more information on The -EU EGEE Project, please see http://cern.ch/eu-egee/. For more information on -EGEE Middleware, please see http://egee-jra1.web.cern.ch/egee-jra1/ - - diff --git a/org.glite.lb.client-interface/Makefile b/org.glite.lb.client-interface/Makefile deleted file mode 100644 index bc7588d..0000000 --- a/org.glite.lb.client-interface/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -# Default values -top_srcdir=. -builddir=build -top_builddir=${top_srcdir}/${builddir} -stagedir=. -distdir=. -globalprefix=glite -lbprefix=lb -package=glite-lb-client-interface -version=0.0.0 -PREFIX=/opt/glite - --include Makefile.inc - -SUFFIXES = .T - -VPATH=${top_srcdir}/interface -AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3 - -STAGETO=include/${globalprefix}/${lbprefix} -STATIC_H=consumer.h context.h dump.h load.h notification.h notifid.h purge.h \ - Notification.h CountRef.h Job.h LoggingExceptions.h ServerConnection.h \ - consumer_fake.h producer_fake.h -GEN_H=events.h jobstat.h producer.h Event.h JobStatus.h interface_version.h - - -generate: ${GEN_H} - -all compile: generate - -check: - @echo No unit test required for interface-only module. - -%.h: %.h.T - rm -f $@ - ${AT3} $< >$@ || rm -f $@ - chmod -w $@ >/dev/null - -interface_version.h: ${top_srcdir}/project/version.properties - echo "#define GLITE_LB_CLIENT_INTERFACE \"${version}\"" >$@ -stage: generate - $(MAKE) install PREFIX=${top_srcdir}/${stagedir} - -dist: distsrc distbin - -distsrc: - mkdir -p ${top_srcdir}/${package}-${version} - cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version} - cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version} - rm -rf ${top_srcdir}/${package}-${version} - -distbin: - $(MAKE) install PREFIX=${top_srcdir}/tmpbuilddir - cd ${top_srcdir}/tmpbuilddir && tar -czf ${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz * - rm -rf ${top_srcdir}/tmpbuilddir - -doc: generate - doxygen C.dox - doxygen CPP.dox - -install: - -mkdir -p ${PREFIX}/${STAGETO} - -mkdir -p ${PREFIX}/share/doc/${package}-${version} - install -m 644 ${GEN_H} ${PREFIX}/${STAGETO} - install -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} - cd ${top_srcdir}/interface && install -m 644 ${STATIC_H} ${PREFIX}/${STAGETO} - -clean: - rm -f *.h - diff --git a/org.glite.lb.client-interface/build.xml b/org.glite.lb.client-interface/build.xml deleted file mode 100755 index f0f6a1a..0000000 --- a/org.glite.lb.client-interface/build.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.client-interface/interface/CountRef.h b/org.glite.lb.client-interface/interface/CountRef.h deleted file mode 100644 index a8f61cf..0000000 --- a/org.glite.lb.client-interface/interface/CountRef.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_COUNTREF_HPP__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_COUNTREF_HPP__ - -#define EWL_BEGIN_NAMESPACE namespace glite { namespace lb { -#define EWL_END_NAMESPACE } } - -EWL_BEGIN_NAMESPACE; - -template -class CountRef { -public: - CountRef(void *); -// CountRef(void *,void (*)(void *)); - - void use(void); - void release(void); - - void *ptr; -private: - int count; -// void (*destroy)(void *); -}; - -template -CountRef::CountRef(void *p) -{ - ptr = p; - count = 1; -} - -template -void CountRef::release(void) -{ - if (--count == 0) { - T::destroyFlesh(ptr); - delete this; - } -} - -template -void CountRef::use(void) -{ - count++; -} - -EWL_END_NAMESPACE; - -#endif diff --git a/org.glite.lb.client-interface/interface/Event.h.T b/org.glite.lb.client-interface/interface/Event.h.T deleted file mode 100644 index 64b4958..0000000 --- a/org.glite.lb.client-interface/interface/Event.h.T +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_EVENT_HPP__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_EVENT_HPP__ - - -#include -#include -#include - -#include "glite/wmsutils/jobid/JobId.h" -#include "glite/lb/CountRef.h" - -#ident "$Header$" - -/** @file Event.h - * @version $Revision$ - */ - -/* -@@@AUTO -*/ -@@@LANG: C++ - -#include "glite/lb/events.h" -#include "glite/lb/notifid.h" - -EWL_BEGIN_NAMESPACE; - -class Event { - friend class Job; - friend class ServerConnection; - friend class CountRef; -public: - /** Event type codes. - * Identify which of the event fields are valid. - */ - - enum Type { - UNDEF = 0, -@@@{ - for my $e ($event->getTypesOrdered) { - my $u = uc $e; - my $c = getTypeComment $event $e; - gen "\t\t$u,\t/**< $c */\n"; - } -@@@} - TYPE_MAX - }; - - /** Event attribute symbolic identifier. */ - enum Attr { -@@@{ - for (sort {$a cmp $b} getAllFields $event) { - my $u = $_; -# $u =~ s/([a-z])([A-Z])/$1_$2/g; - $u = uc $u; - - my $c = "\t/**\n"; - for my $t (sort $event->getFieldOccurence($_)) { - selectType $event $t; - my $cc = getFieldComment $event $_; - $t = 'common' if $t eq '_common_'; - $c .= "\t * $t: $cc\n"; - } - $c .= "\t */\n"; - - gen "$c\t\t$u,\n"; - } -@@@} - ATTR_MAX - }; - -@@@{ - for my $f (getAllFields $event) { - for my $t (getFieldOccurence $event $f) { - my $ff; - my $ut; - my $utf; - if ($t eq '_common_') { - $ff = $f; - $ut = ''; - $utf = ''; - } - else { - selectType $event $t; - selectField $event $f; - $ff = getField $event; - $ut = uc $t . '_'; - $utf = ucfirst $t; - } - if ($ff->{codes}) { - gen qq{ -! enum ${utf}Code \{ -}; - for (@{$ff->{codes}}) { - gen qq{ -! $ut$_->{name}, /**< $_->{comment} */ -}; - } - gen qq{ -! \}; -}; - } - } - } -@@@} - - enum AttrType { INT_T, STRING_T, TIMEVAL_T, PORT_T, LOGSRC_T, JOBID_T, NOTIFID_T }; - - Type type; - - Event(void); - Event(edg_wll_Event *); - Event(const Event &); - ~Event(void); - - - /** Assign new Event to an existing instance. */ - Event & operator= (const Event &); - - /** String representation of the event type */ - const std::string & name(void) const; - - /** Retrieve integer attribute */ - int getValInt(Attr) const; - - /** Retrieve string attribute */ - std::string getValString(Attr) const; - - /** Retrieve time attribute */ - struct timeval getValTime(Attr) const; - - /** Retrieve jobid attribute */ - const glite::wmsutils::jobid::JobId getValJobId(Attr) const; - - /** Attribute name */ - const std::string & getAttrName(Attr) const; - - /** List of attributes and types valid for this instance */ - const std::vector > & getAttrs(void) const; - -private: - static void destroyFlesh(void *); - CountRef *flesh; -}; - -EWL_END_NAMESPACE; - -#endif diff --git a/org.glite.lb.client-interface/interface/Job.h b/org.glite.lb.client-interface/interface/Job.h deleted file mode 100644 index 8f69ed8..0000000 --- a/org.glite.lb.client-interface/interface/Job.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_JOB_HPP__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_JOB_HPP__ - -#ident "$Header$" - -#include "glite/wmsutils/jobid/JobId.h" - -#include "glite/lb/Event.h" -#include "glite/lb/JobStatus.h" -#include "glite/lb/ServerConnection.h" - - -/** - * @file Job.h - * @version $Revision$ - */ - -EWL_BEGIN_NAMESPACE; - -/** L&B job. - * Implementation of L&B job-specific calls. - * Connection to the server is maintained transparently. -*/ - -class Job { -public: - Job(void); - Job(const glite::wmsutils::jobid::JobId &); - ~Job(); - - /** Assign new JobId to an existing instance. - * Connection to server is preserved if possible. - */ - - Job & operator= (const glite::wmsutils::jobid::JobId &); - -/** - * Status retrieval bitmasks. Used ORed as Job::status() argument, - * determine which status fields are actually retrieved. - */ - static const int STAT_CLASSADS; /**< various job description fields */ - static const int STAT_CHILDREN; /**< list of subjob JobId's */ - static const int STAT_CHILDSTAT; /**< apply the flags recursively to subjobs */ - - /** Return job status */ - JobStatus status(int) const; - - /** Return all events corresponding to this job */ - void log(std::vector &) const; - const std::vector log(void) const; - - /** Return last known address of a listener associated to the job. - * \param name name of the listener - * \return hostname and port number - */ - const std::pair queryListener(const std::string & name) const; - - /** Manipulate LB parameters, the same as for edg_wll_Context in C */ - void setParam(edg_wll_ContextParam, int); - void setParam(edg_wll_ContextParam, const std::string); - void setParam(edg_wll_ContextParam, const struct timeval &); - - int getParamInt(edg_wll_ContextParam) const; - std::string getParamString(edg_wll_ContextParam) const; - struct timeval getParamTime(edg_wll_ContextParam) const; - -private: - ServerConnection server; - glite::wmsutils::jobid::JobId jobId; -}; - -EWL_END_NAMESPACE; - -#endif diff --git a/org.glite.lb.client-interface/interface/JobStatus.h.T b/org.glite.lb.client-interface/interface/JobStatus.h.T deleted file mode 100644 index 8b63de1..0000000 --- a/org.glite.lb.client-interface/interface/JobStatus.h.T +++ /dev/null @@ -1,151 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_JOBSTATUS_HPP__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_JOBSTATUS_HPP__ - -/* -@@@AUTO -*/ - -@@@LANG: C++ - -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/JobId.h" - -#include "glite/lb/jobstat.h" -#include "glite/lb/CountRef.h" - -EWL_BEGIN_NAMESPACE; - -/** - * Description of job status. - * The status is computed from a sequence of logged events - */ - - -class JobStatus { - friend class Job; - friend class CountRef; -public: - enum Code { - UNDEF = 0, /**< indicates invalid, i.e. uninitialized instance */ -@@@{ - for my $stat ($status->getTypesOrdered) - { - my $u = uc($stat); - my $c = getTypeComment $status $stat; - gen qq{ -! $u, /**< $c */ -}; - } -@@@} - CODE_MAX - }; - - enum Attr { -@@@{ - selectType $status '_common_'; - for my $u (sort {$a cmp $b} getAllFields $status) { - selectField $status $u; - my $f = getField $status; - $u =~ s/([a-z])([A-Z])/$1_$2/g; - $u = uc $u; - - gen "\t/** $f->{comment} */\n\t\t$u,\n"; - } -@@@} - ATTR_MAX - }; - -@@@{ - selectType $status '_common_'; - for my $n (getAllFields $status) { - selectField $status $n; - my $f = getField $status; - if ($f->{codes}) { - my $n = uc getName $f; - gen qq{ -! enum \{ -}; - for (@{$f->{codes}}) { - gen qq{ -! $n\_$_->{name}, /**< $_->{comment} */ -}; - } - gen qq{ -! \}; -}; - } - } -@@@} - enum AttrType { INT_T, - STRING_T, - TIMEVAL_T, - BOOL_T, - JOBID_T, - INTLIST_T, - STRLIST_T, - TAGLIST_T, - STSLIST_T - }; - - /** Numeric status code */ - Code status; - - /** String representation of the status code */ - const std::string & name(void) const; - - /** Retrieve integer attribute */ - int getValInt(Attr) const; - - /** Retrieve string attribute */ - std::string getValString(Attr) const; - - /** Retrieve time attribute */ - struct timeval getValTime(Attr) const; - - /** Retrieve jobid attribute */ - const glite::wmsutils::jobid::JobId getValJobId(Attr) const; - - /** Retrieve bool attribute */ - bool getValBool(Attr) const; - - /** Retrieve int list attribute */ - const std::vector getValIntList(Attr) const; - - /** Retrieve string list attribute */ - const std::vector getValStringList(Attr) const; - - /** Retrieve tag list attribute */ - const std::vector > getValTagList(Attr) const; - - /** Retrieve job status list attribute */ - const std::vector getValJobStatusList(Attr) const; - - /** Attribute name */ - const std::string& getAttrName(Attr) const; - - /** List of attributes and types valid for this instance */ - const std::vector >& getAttrs(void) const; - - JobStatus(void); - JobStatus(const JobStatus &); - JobStatus & operator=(const JobStatus &); - JobStatus(const edg_wll_JobStat &); - JobStatus & operator=(const edg_wll_JobStat&); - virtual ~JobStatus(); - -protected: - edg_wll_JobStat *c_ptr(void); - -private: - static void destroyFlesh(void *); - CountRef *flesh; -}; - -EWL_END_NAMESPACE; - -#endif - diff --git a/org.glite.lb.client-interface/interface/LoggingExceptions.h b/org.glite.lb.client-interface/interface/LoggingExceptions.h deleted file mode 100644 index 1d22a2e..0000000 --- a/org.glite.lb.client-interface/interface/LoggingExceptions.h +++ /dev/null @@ -1,144 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_LOGGING_EXCEPTIONS_HPP__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_LOGGING_EXCEPTIONS_HPP__ - -#ident "$Header$" - -/** @file LoggingExceptions.h - * @version $Revision$ - */ - -#include "glite/wmsutils/exception/Exception.h" - -#include - -EWL_BEGIN_NAMESPACE; - -class Exception: public glite::wmsutils::exception::Exception { -public: - - /* constructor for mandatory fields */ - Exception(const std::string& source, - int line_number, - const std::string& method, - int code, - const std::string& exception) - : glite::wmsutils::exception::Exception(source, - line_number, - method, - code, - "glite::lb::Exception") - { error_message = exception; }; - - /* constructor for mandatory fields AND exception chain */ - Exception(const std::string& source, - int line_number, - const std::string& method, - int code, - const std::string& exception, - const glite::wmsutils::exception::Exception &exc) - : glite::wmsutils::exception::Exception(source, - line_number, - method, - code, - "glite::lb::Exception") - { error_message = exception + ": " + exc.what(); }; -}; - - -class LoggingException: public Exception { -public: - - /* constructor for mandatory fields */ - LoggingException(const std::string& source, - int line_number, - const std::string& method, - int code, - const std::string& exception) - : Exception(source, line_number, method, code, exception) - {}; - - /* constructor for mandatory fields AND exception chain */ - LoggingException(const std::string& source, - int line_number, - const std::string& method, - int code, - const std::string& exception, - const glite::wmsutils::exception::Exception &exc) - : Exception(source, line_number, method, code, exception) - {}; -}; - - -class OSException: public Exception { -public: - - /* constructor for mandatory fields */ - OSException(const std::string& source, - int line_number, - const std::string& method, - int code, - const std::string& exception) - : Exception(source, - line_number, - method, - code, - exception + ": " + strerror(code)) - {}; - - /* constructor for mandatory fields AND exception chain */ - OSException(const std::string& source, - int line_number, - const std::string& method, - int code, - const std::string& exception, - const glite::wmsutils::exception::Exception &exc) - : Exception(source, - line_number, - method, - code, - exception + ": " + strerror(code)) - {}; -}; - - -#define EXCEPTION_MANDATORY \ - __FILE__, \ - __LINE__, \ - std::string(CLASS_PREFIX) + __FUNCTION__ - -#define STACK_ADD - -/* note: we can use __LINE__ several times in macro, it is expanded into one row */ -#define throw_exception(context, exception) \ -{ STACK_ADD; \ - { \ - char *text, *desc; \ - int code; \ - std::string exc; \ - \ - code = edg_wll_Error((context), &text, &desc); \ - exc = exception; \ - if (text) { \ - exc += ": "; \ - exc += text; \ - } \ - if (desc) { \ - exc += ": "; \ - exc += desc; \ - } \ - free(text); \ - free(desc); \ - throw LoggingException(EXCEPTION_MANDATORY, \ - code, \ - exc); \ - } \ -} - -#define check_result(code, context, desc) \ - if((code)) throw_exception((context), desc) - - - -EWL_END_NAMESPACE; - -#endif diff --git a/org.glite.lb.client-interface/interface/Notification.h b/org.glite.lb.client-interface/interface/Notification.h deleted file mode 100644 index b8e8b27..0000000 --- a/org.glite.lb.client-interface/interface/Notification.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_NOTIFICATION_HPP__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_NOTIFICATION_HPP__ - - -#include "glite/wmsutils/jobid/JobId.h" - -#include "glite/lb/consumer.h" -#include "glite/lb/notification.h" -#include "glite/lb/JobStatus.h" - - -EWL_BEGIN_NAMESPACE; - - -/** Manage LB notifications. - * Simplified API, covers only a subset of C API functinality - */ - -class Notification { -public: - /** Create an empty object - * to be used for new notifications, i.e. with Register() - */ - Notification(); - - /** Create from server,port pair - * to be used for new notifications, i.e. with Register() - * \param host - * \param port - */ - Notification(const std::string,const u_int16_t); - - /** Create from NotifId - * to be used for existing notifications, i.e. with Bind() - * \param notifId - */ - Notification(const std::string); - - ~Notification(); - - std::string getNotifId() const; /**< retrieve NotifId */ - time_t getValid() const; /**< retrieve time until when it is valid */ - int getFd() const; /**< retrieve local listener filedescriptor */ - - /** Add this job to the list. - * Local operation only, Register() has to be called - * to propagate changes to server - */ - void addJob(const glite::wmsutils::jobid::JobId &); - - /** Remove job from the list, local op again. */ - void removeJob(const glite::wmsutils::jobid::JobId &); - - /** Get jobs on the list */ - std::string getJobs(); - - /** Receive notifications on these states */ - void setStates(const std::vector &); - - /** Get states */ - std::string getStates(); - - /** Register (or re-register, i.e. change and extend) - * with the server - */ - void Register(); - - /** Bind to the existing notification at the server - * i.e. change the receiving local address - * \param address_override - */ - void Bind(const std::string); - - /** Receive notification. - * Blocks at most the specified timeout (maybe 0 for local polling). - * \retval 0 OK - * \retval 1 timeout - */ - int receive(glite::lb::JobStatus &,timeval &); - -private: - std::vector jobs; - std::vector states; - - edg_wll_Context ctx; - edg_wll_NotifId notifId; - time_t valid; -}; - - -EWL_END_NAMESPACE; - -#endif diff --git a/org.glite.lb.client-interface/interface/ServerConnection.h b/org.glite.lb.client-interface/interface/ServerConnection.h deleted file mode 100644 index 333d0bd..0000000 --- a/org.glite.lb.client-interface/interface/ServerConnection.h +++ /dev/null @@ -1,306 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_SERVERCONNECTION_HPP__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_SERVERCONNECTION_HPP__ - -#ident "$Header$" - -/** - * @file ServerConnection.h - * @version $Revision$ - */ - -#include -#include - -#include "glite/wmsutils/jobid/JobId.h" - -#include "glite/lb/Event.h" -#include "glite/lb/JobStatus.h" -#include "glite/lb/consumer.h" - -EWL_BEGIN_NAMESPACE; - -/** Auxiliary class to hold an atomic query condition. */ -class QueryRecord { -public: - friend class ServerConnection; - friend edg_wll_QueryRec *convertQueryVector(const std::vector &in); - - /* IMPORTANT: must match lbapi.h */ - enum Attr { - UNDEF=0, /**< Not-defined value, used to terminate lists etc. */ - JOBID, /**< Job Id \see _edg_wll_QueryRec */ - OWNER, /**< Job owner \see _edg_wll_QueryRec */ - STATUS, /**< Current job status */ - LOCATION, /**< Where is the job processed */ - DESTINATION, /**< Destination CE */ - DONECODE, /**< Minor done status (OK,fail,cancel) */ - USERTAG, /**< User tag (not implemented yet) */ - TIME, /**< Timestamp \see _edg_wll_QueryRec */ - LEVEL, /**< Logging level (see "dglog.h") * \see _edg_wll_QueryRec */ - HOST, /**< Where the event was generated */ - SOURCE, /**< Source component */ - INSTANCE, /**< Instance of the source component */ - EVENT_TYPE, /**< Event type \see _edg_wll_QueryRec */ - CHKPT_TAG, /**< Checkpoint tag */ - RESUBMITTED, /**< Job was resubmitted */ - PARENT, /**< Job was resubmitted */ - EXITCODE, /**< Unix exit code */ - }; - - enum Op { - EQUAL=EDG_WLL_QUERY_OP_EQUAL, - LESS=EDG_WLL_QUERY_OP_LESS, - GREATER=EDG_WLL_QUERY_OP_GREATER, - WITHIN=EDG_WLL_QUERY_OP_WITHIN, - UNEQUAL=EDG_WLL_QUERY_OP_UNEQUAL - }; - - QueryRecord(); - - /* copy and assignment */ - QueryRecord(const QueryRecord &); - QueryRecord& operator=(const QueryRecord &); - - /* constructors for simple attribute queries */ - QueryRecord(const Attr, const Op, const std::string &); - QueryRecord(const Attr, const Op, const int); - QueryRecord(const Attr, const Op, const struct timeval &); - QueryRecord(const Attr, const Op, const glite::wmsutils::jobid::JobId&); - /* this one is for attr==TIME and particular state */ - QueryRecord(const Attr, const Op, const int, const struct timeval &); - - /* constructors for WITHIN operator */ - QueryRecord(const Attr, const Op, const std::string &, const std::string &); - QueryRecord(const Attr, const Op, const int, const int); - QueryRecord(const Attr, const Op, const struct timeval &, const struct timeval &); - QueryRecord(const Attr, const Op, const int, const struct timeval &, const struct timeval &); - - /* convenience for user tags */ - QueryRecord(const std::string &, const Op, const std::string &); - QueryRecord(const std::string &, const Op, const std::string &, const std::string &); - - ~QueryRecord(); - - static const std::string AttrName(const Attr) ; - -protected: - - /* conversion to C API type */ - operator edg_wll_QueryRec() const; - -private: - Attr attr; - Op oper; - std::string tag_name; - int state; - std::string string_value; - glite::wmsutils::jobid::JobId jobid_value; - int int_value; - struct timeval timeval_value; - std::string string_value2; - int int_value2; - struct timeval timeval_value2; -}; - - -/** Supported aggregate operations */ -enum AggOp { AGG_MIN=1, AGG_MAX, AGG_COUNT }; - - -/** - * Connection to the L&B server. - * Maintain connection to the server. - * Implement non job-specific API calls - */ - -class ServerConnection { -public: - friend class Job; - - ServerConnection(void); - - /* DEPRECATED: do not use - * connections are now handled automagically inside the implementation - */ - ServerConnection(const std::string &); - - /** Open connection to a given server */ - void open(const std::string &); - - /** Close the current connection */ - void close(void); - - /* END DEPRECATED */ - - /* set & get parameter methods */ - - /* consumer parameter settings */ - void setQueryServer(const std::string&, int); - void setQueryTimeout(int); - - void setX509Proxy(const std::string&); - void setX509Cert(const std::string&, const std::string&); - - std::pair getQueryServer() const; - int getQueryTimeout() const; - - std::string getX509Proxy() const; - std::pair getX509Cert() const; - - /* end of set & get */ - - virtual ~ServerConnection(); - - - /* consumer API */ - - /** Retrieve the set of single indexed attributes. - * outer vector elements correspond to indices - * inner vector elements correspond to index columns - * if .first of the pair is USERTAG, .second is its name - * if .first is TIME, .second is state name - * otherwise .second is meaningless (empty string anyway) - */ - std::vector > > - getIndexedAttrs(void); - - /** Retrieve hard and soft result set size limit */ - std::pair getLimits(void) const; - - /** Set the soft result set size limit */ - void setQueryJobsLimit(int); - void setQueryEventsLimit(int); - - /** Retrieve all events satisfying the query records - * @param job_cond, event_cond - vectors of conditions to be satisfied - * by jobs as a whole or particular events, conditions are ANDed - * @param events vector of returned events - */ - void queryEvents(const std::vector& job_cond, - const std::vector& event_cond, - std::vector&) const; - - const std::vector queryEvents(const std::vector& job_cond, - const std::vector& event_cond) const; - - const std::list queryEventsList(const std::vector& job_cond, - const std::vector& event_cond) const; - - - /** The same as queryEvents but return only an aggregate. - * @param job_cond, event_cond - vectors of conditions to be satisfied - * by jobs as a whole or particular events, conditions are ANDed - * @param op aggregate operator to apply - * @param attr attribute to apply the operation to - */ - std::string queryEventsAggregate(const std::vector& job_cond, - const std::vector& event_cond, - enum AggOp const op, - std::string const attr) const; - - - /** Retrieve all events satisfying the query records - * @param job_cond, event_cond - vectors of vectors of job or event conditions, - * respectively. The inner vectors are logically ANDed, the outer are ORed - * (cond1 AND cond2 AND ...) OR (condN AND ...) - * @param events vector of returned events - */ - void queryEvents(const std::vector >& job_cond, - const std::vector >& event_cond, - std::vector&) const; - - const std::vector - queryEvents(const std::vector >& job_cond, - const std::vector >& event_cond) const; - - - /** Retrieve jobs satisfying the query records, including their states - * @param query vector of Query records that are anded to form the - * query - * @param ids vector of returned job id's - * @param states vector of returned job states - */ - - void queryJobs(const std::vector& query, - std::vector& ids) const; - - const std::vector - queryJobs(const std::vector& query) const; - - - /** Retrieve jobs satisfying the query records, including their states - * @param query vector of Query record vectors that are ORed and ANDed to form the - * query - * @param ids vector of returned job id's - * @param states vector of returned job states - */ - - void queryJobs(const std::vector >& query, - std::vector& ids) const; - - const std::vector - queryJobs(const std::vector >& query) const; - - /** Retrieve jobs satisfying the query records, including status - * information - * @param query vector of Query records that are anded to form the - * query - * @param ids vector of returned job id's - * @param states vector of returned job states - */ - void queryJobStates(const std::vector& query, - int flags, - std::vector & states) const; - const std::vector queryJobStates(const std::vector& query, - int flags) const; - - const std::list queryJobStatesList(const std::vector& query, - int flags) const; - - /** Retrieve jobs satisfying the query records, including status - * information - * @param query vector of Query records that are anded to form the - * query - * @param ids vector of returned job id's - * @param states vector of returned job states - */ - void queryJobStates(const std::vector >& query, - int flags, - std::vector & states) const; - const std::vector - queryJobStates(const std::vector >& query, - int flags) const; - - /** States of all user's jobs. - * Convenience wrapper around queryJobs. - */ - void userJobStates(std::vector& stateList) const; - const std::vector userJobStates() const; - - - /** JobId's of all user's jobs. - * Convenience wrapper around queryJobs. - */ - void userJobs(std::vector &) const; - const std::vector userJobs() const; - - /** Manipulate LB parameters, the same as for edg_wll_Context in C */ - void setParam(edg_wll_ContextParam, int); - void setParam(edg_wll_ContextParam, const std::string); - void setParam(edg_wll_ContextParam, const struct timeval &); - - int getParamInt(edg_wll_ContextParam) const; - std::string getParamString(edg_wll_ContextParam) const; - struct timeval getParamTime(edg_wll_ContextParam) const; - -protected: - - edg_wll_Context getContext(void) const; - -private: - edg_wll_Context context; -}; - -EWL_END_NAMESPACE; - -#endif diff --git a/org.glite.lb.client-interface/interface/consumer.h b/org.glite.lb.client-interface/interface/consumer.h deleted file mode 100644 index 5a8cf96..0000000 --- a/org.glite.lb.client-interface/interface/consumer.h +++ /dev/null @@ -1,387 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_CONSUMER_H__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_CONSUMER_H__ - -/*! - * \file client/consumer.h (lbapi.h originaly) - * \brief L&B consumer API - * - * General rules: - * - functions return 0 on success, nonzero on error, errror details can - * be found via edg_wll_ErrorCode() - * - OUT are ** types, functions malloc()-ate objects and fill in the pointer - * pointed to by the OUT argument - * - returned lists of pointers are NULL-terminated malloc()-ed arrays - * - edg_wll_Query + wrapper terminate arrays with EDG_WLL_EVENT_UNDEF event - * - OUT is NULL if the list is empty - */ - -#ident "$Header$" - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/context.h" -#include "glite/lb/events.h" -#include "glite/lb/jobstat.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - * Predefined types for query attributes - */ -typedef enum _edg_wll_QueryAttr{ - EDG_WLL_QUERY_ATTR_UNDEF=0, /**< Not-defined value, used to terminate lists etc. */ - EDG_WLL_QUERY_ATTR_JOBID, /**< Job Id \see _edg_wll_QueryRec */ - EDG_WLL_QUERY_ATTR_OWNER, /**< Job owner \see _edg_wll_QueryRec */ - EDG_WLL_QUERY_ATTR_STATUS, /**< Current job status */ - EDG_WLL_QUERY_ATTR_LOCATION, /**< Where is the job processed */ - EDG_WLL_QUERY_ATTR_DESTINATION, /**< Destination CE */ - EDG_WLL_QUERY_ATTR_DONECODE, /**< Minor done status (OK,fail,cancel) */ - EDG_WLL_QUERY_ATTR_USERTAG, /**< User tag */ - EDG_WLL_QUERY_ATTR_TIME, /**< Timestamp \see _edg_wll_QueryRec */ - EDG_WLL_QUERY_ATTR_LEVEL, /**< Logging level (see "dglog.h") * \see _edg_wll_QueryRec */ - EDG_WLL_QUERY_ATTR_HOST, /**< Where the event was generated */ - EDG_WLL_QUERY_ATTR_SOURCE, /**< Source component */ - EDG_WLL_QUERY_ATTR_INSTANCE, /**< Instance of the source component */ - EDG_WLL_QUERY_ATTR_EVENT_TYPE, /**< Event type \see _edg_wll_QueryRec */ - EDG_WLL_QUERY_ATTR_CHKPT_TAG, /**< Checkpoint tag */ - EDG_WLL_QUERY_ATTR_RESUBMITTED, /**< Job was resubmitted */ - EDG_WLL_QUERY_ATTR_PARENT, /**< Job was resubmitted */ - EDG_WLL_QUERY_ATTR_EXITCODE, /**< Unix exit code */ - EDG_WLL_QUERY_ATTR__LAST -/* if adding new attribute, add conversion string to common/xml_conversions.c too !! */ -} edg_wll_QueryAttr; - - -/*! - * Predefined types for query operands - */ -typedef enum _edg_wll_QueryOp{ - EDG_WLL_QUERY_OP_EQUAL, /**< attribute is equal to the operand value \see _edg_wll_QueryRec */ - EDG_WLL_QUERY_OP_LESS, /**< attribute is grater than the operand value \see _edg_wll_QueryRec */ - EDG_WLL_QUERY_OP_GREATER, /**< attribute is less than the operand value \see _edg_wll_QueryRec */ - EDG_WLL_QUERY_OP_WITHIN, /**< attribute is in given interval \see _edg_wll_QueryRec */ - EDG_WLL_QUERY_OP_UNEQUAL, /**< attribute is not equal to the operand value \see _edg_wll_QueryRec */ -} edg_wll_QueryOp; - - -/*! - * Single query condition for edg_wll_Query(). - * Those records are composed to form an SQL \a where clause - * when processed at the L&B server - */ -typedef struct _edg_wll_QueryRec { - edg_wll_QueryAttr attr; /**< attribute to query */ - edg_wll_QueryOp op; /**< query operation */ - -/** - * Specification of attribute to query - */ - union { - char * tag; /**< user tag name */ - edg_wll_JobStatCode state; /**< job status code */ - } attr_id; -/** - * Query operand. - * The appropriate type is uniquely defined by the attr member - */ - union edg_wll_QueryVal { - int i; /**< integer query attribute value */ - char *c; /**< character query attribute value */ - struct timeval t; /**< time query attribute value */ - edg_wlc_JobId j; /**< JobId query attribute value */ - } value, value2; -} edg_wll_QueryRec; - -/************************************************ - * API FUNCTION DECLARATIONS * - */ - - -#ifdef CLIENT_SBIN_PROG -extern int edg_wll_http_send_recv( - edg_wll_Context, - char *, const char * const *, char *, - char **,char ***,char ** -); - -extern int http_check_status( - edg_wll_Context, - char *, - char ** -); - -extern int set_server_name_and_port( - edg_wll_Context, - const edg_wll_QueryRec ** -); - -#endif - -/** - * \name Server querying - * - *@{ - */ - -/** - * General query on events. - * Return events satysfying all conditions - * query records represent conditions in the form - * \a attr \a op \a value eg. time > 87654321. - * \see edg_wll_QueryRec - * - * \param context IN: context to work with - * \param job_conditions IN: query conditions (ANDed) on current job status, null (i.e. ATTR_UNDEF) terminated list. NULL means empty list, i.e. always TRUE - * \param event_conditions: conditions on events, null terminated list, NULL means empty list, i.e. always TRUE - * \param events OUT: list of matching events - */ -int edg_wll_QueryEvents( - edg_wll_Context context, - const edg_wll_QueryRec * job_conditions, - const edg_wll_QueryRec * event_conditions, - edg_wll_Event ** events -); - -int edg_wll_QueryEventsExt( - edg_wll_Context context, - const edg_wll_QueryRec ** job_conditions, - const edg_wll_QueryRec ** event_conditions, - edg_wll_Event ** events -); - - -/** - * Query LBProxy and use plain communication - */ -int edg_wll_QueryEventsProxy( - edg_wll_Context context, - const edg_wll_QueryRec * job_conditions, - const edg_wll_QueryRec * event_conditions, - edg_wll_Event ** events -); - -int edg_wll_QueryEventsExtProxy( - edg_wll_Context context, - const edg_wll_QueryRec ** job_conditions, - const edg_wll_QueryRec ** event_conditions, - edg_wll_Event ** events -); - -/** - * General query on jobs. - * Return jobs (and possibly their states) for which an event satisfying the conditions - * exists. - * \see edg_wll_QueryEvents - * \param context IN: context to work with - * \param conditions IN: query records (ANDed), null (i.e. EDG_WLL_ATTR_UNDEF) terminated list - * \param flags IN: additional status fields to retrieve (\see edg_wll_JobStatus) - * \param jobs OUT: list of job ids. May be NULL. - * \param states OUT: list of corresponding states (returned only if not NULL) - */ -int edg_wll_QueryJobs( - edg_wll_Context context, - const edg_wll_QueryRec * conditions, - int flags, - edg_wlc_JobId ** jobs, - edg_wll_JobStat ** states -); - -int edg_wll_QueryJobsExt( - edg_wll_Context context, - const edg_wll_QueryRec ** conditions, - int flags, - edg_wlc_JobId ** jobs, - edg_wll_JobStat ** states -); - - -/** - * Query LBProxy and use plain communication - */ -int edg_wll_QueryJobsProxy( - edg_wll_Context context, - const edg_wll_QueryRec * conditions, - int flags, - edg_wlc_JobId ** jobs, - edg_wll_JobStat ** states -); - -int edg_wll_QueryJobsExtProxy( - edg_wll_Context context, - const edg_wll_QueryRec ** conditions, - int flags, - edg_wlc_JobId ** jobs, - edg_wll_JobStat ** states -); - - -/** - * Bitmasks for edg_wll_JobStatus() flags argument. - * Settings these flags causes the status calls to retrieve additional - * information. - */ -#define EDG_WLL_STAT_CLASSADS 1 /**< various job description fields */ -#define EDG_WLL_STAT_CHILDREN 2 /**< list of subjob JobId's */ -#define EDG_WLL_STAT_CHILDSTAT 4 /**< apply the flags recursively to subjobs */ -/* starting from bit 10 private flags begins - do not add 1024 and more! */ - -/** Return status of a single job. - * \param context IN: context to operate on - * \param jobid IN: query this job - * \param flags IN: specifies optional status fields to retrieve, - * \see EDG_WLL_STAT_CLASSADS, EDG_WLL_STAT_CHILDREN, EDG_WLL_STAT_CHILDSTAT - */ - -int edg_wll_JobStatus( - edg_wll_Context context, - const edg_wlc_JobId jobid, - int flags, - edg_wll_JobStat *status -); - -/** - * Query LBProxy and use plain communication - */ -int edg_wll_JobStatusProxy( - edg_wll_Context context, - const edg_wlc_JobId jobid, - int flags, - edg_wll_JobStat *status -); - -/** - * Return all events related to a single job. - * Convenience wrapper around edg_wll_Query() - * \param context IN: context to work with - * \param jobId IN: job to query - * \param events OUT: list of events - */ - -int edg_wll_JobLog( - edg_wll_Context context, - const edg_wlc_JobId jobId, - edg_wll_Event ** events -); - - -/** - * Query LBProxy and use plain communication - */ -int edg_wll_JobLogProxy( - edg_wll_Context context, - const edg_wlc_JobId jobId, - edg_wll_Event ** events -); - -/** - * All current user's jobs. - * \param context IN: context to work with - * \param jobs OUT: list of the user's jobs - * \param states OUT: list of the jobs' states - */ -int edg_wll_UserJobs( - edg_wll_Context context, - edg_wlc_JobId ** jobs, - edg_wll_JobStat ** states -); - - -/** - * Query LBProxy and use plain communication - */ -int edg_wll_UserJobsProxy( - edg_wll_Context context, - edg_wlc_JobId ** jobs, - edg_wll_JobStat ** states -); - -/** - * Server supported indexed attributes - * \see DataGrid-01-TEN-0125 - * \param context IN: context to work with - * \param attrs OUT: configured indices (each index is an UNDEF-terminated - * array of QueryRec's from which only attr (and attr_id - * eventually) are meaningful - */ -int edg_wll_GetIndexedAttrs( - edg_wll_Context context, - edg_wll_QueryRec ***attrs -); - -/** - * Retrieve limit on query result size (no. of events or jobs). - * FIXME: not implemented. - * \see DataGrid-01-TEN-0125 - * \param context IN: context to work with - * \param limit OUT: server imposed limit - */ -int edg_wll_GetServerLimit( - edg_wll_Context context, - int *limit -); - -/** - * UI port for the job - * \param context IN: context to work with - * \param jobId IN: job to query - * \param name IN: name of the UI-port - * \param host OUT: hostname of port - * \param port OUT: port number - */ -int edg_wll_QueryListener( - edg_wll_Context context, - edg_wlc_JobId jobId, - const char * name, - char ** host, - uint16_t * port -); - - -/** - * Query LBProxy and use plain communication - */ -int edg_wll_QueryListener( - edg_wll_Context context, - edg_wlc_JobId jobId, - const char * name, - char ** host, - uint16_t * port -); - -/** - * Ask LB Proxy server for sequence number - * \param context IN: context to work with - * \param jobId IN: job to query - * \param code OUT: sequence code - */ - - -int edg_wll_QuerySequenceCodeProxy( - edg_wll_Context context, - edg_wlc_JobId jobId, - char ** code -); - -/*@}*/ - -/* - * edg_wll_QueryRec manipulation - */ - -/** Free edg_wll_QueryRec internals, not the structure itself */ -void edg_wll_QueryRecFree(edg_wll_QueryRec *); - - - -/** - * default and maximal query timeout (in seconds) - */ -#define EDG_WLL_QUERY_TIMEOUT_DEFAULT 120 -#define EDG_WLL_QUERY_TIMEOUT_MAX 1800 - -#ifdef __cplusplus -} -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_CLIENT_CONSUMER_H__ */ diff --git a/org.glite.lb.client-interface/interface/consumer_fake.h b/org.glite.lb.client-interface/interface/consumer_fake.h deleted file mode 100644 index c3fc28f..0000000 --- a/org.glite.lb.client-interface/interface/consumer_fake.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * fake implementation of the consumer API - */ - -#ifndef WORKLOAD_LOGGING_CLIENT_CONSUMER_FAKE_H -#define WORKLOAD_LOGGING_CLIENT_CONSUMER_FAKE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "glite/lb/context-int.h" - -typedef int (edg_wll_QueryEvents_cb_f)(edg_wll_Context context, edg_wll_Event **events); -typedef int (edg_wll_QueryListener_cb_f)(edg_wll_Context context, char **host, uint16_t *port); - -int edg_wll_RegisterTestQueryEvents(edg_wll_QueryEvents_cb_f *cb); -int edg_wll_RegisterTestQueryListener(edg_wll_QueryListener_cb_f *cb); -void edg_wll_UnregisterTestQueryEvents(); -void edg_wll_UnregisterTestQueryListener(); - -#ifdef __cplusplus -} -#endif - -#endif /* WORKLOAD_LOGGING_CLIENT_CONSUMER_FAKE_H */ diff --git a/org.glite.lb.client-interface/interface/context.h b/org.glite.lb.client-interface/interface/context.h deleted file mode 100644 index 5f176d5..0000000 --- a/org.glite.lb.client-interface/interface/context.h +++ /dev/null @@ -1,218 +0,0 @@ -#ifndef _EDG_WORKLOAD_LOGGING_CLIENT_CONTEXT_H -#define _EDG_WORKLOAD_LOGGING_CLIENT_CONTEXT_H - -/** - * \file edg/workload/logging/client/context.h - * \brief L&B API common context (publicly visible) and related definitions - */ - -#include "glite/wmsutils/exception/exception_codes.h" -#include "glite/wmsutils/jobid/cjobid.h" - -#ident "$Header$" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Opaque context type */ -typedef struct _edg_wll_Context *edg_wll_Context; - -/** Constants defining the context parameters */ -typedef enum _edg_wll_ContextParam { - EDG_WLL_PARAM_HOST, /**< hostname to appear as event orgin */ - EDG_WLL_PARAM_SOURCE, /**< event source component */ - EDG_WLL_PARAM_INSTANCE, /**< instance of the source component */ - EDG_WLL_PARAM_LEVEL, /**< logging level */ - EDG_WLL_PARAM_DESTINATION, /**< logging destination host */ - EDG_WLL_PARAM_DESTINATION_PORT, /**< logging destination port */ - EDG_WLL_PARAM_LOG_TIMEOUT, /**< logging timeout (asynchronous) */ - EDG_WLL_PARAM_LOG_SYNC_TIMEOUT, /**< logging timeout (synchronous) */ - EDG_WLL_PARAM_QUERY_SERVER, /**< default server name to query */ - EDG_WLL_PARAM_QUERY_SERVER_PORT,/**< default server port to query */ - EDG_WLL_PARAM_QUERY_SERVER_OVERRIDE,/**< host:port parameter setting override even values in jobid (useful for debugging & hacking only) */ - EDG_WLL_PARAM_QUERY_TIMEOUT, /**< query timeout */ - EDG_WLL_PARAM_QUERY_JOBS_LIMIT, /**< maximal query jobs result size */ - EDG_WLL_PARAM_QUERY_EVENTS_LIMIT,/**< maximal query events result size */ - EDG_WLL_PARAM_QUERY_RESULTS, /**< maximal query result size */ - EDG_WLL_PARAM_QUERY_CONNECTIONS,/**< maximal number of open connections in ctx->connPoll */ - EDG_WLL_PARAM_NOTIF_SERVER, /**< default notification server name */ - EDG_WLL_PARAM_NOTIF_SERVER_PORT,/**< default notification server port */ - EDG_WLL_PARAM_NOTIF_TIMEOUT, /**< notif timeout */ - EDG_WLL_PARAM_X509_PROXY, /**< proxy file to use for authentication */ - EDG_WLL_PARAM_X509_KEY, /**< key file to use for authentication */ - EDG_WLL_PARAM_X509_CERT, /**< certificate file to use for authentication */ - EDG_WLL_PARAM_LBPROXY_STORE_SOCK,/**< lbproxy store socket path */ - EDG_WLL_PARAM_LBPROXY_SERVE_SOCK,/**< lbproxy serve socket path */ - EDG_WLL_PARAM_LBPROXY_USER, /**< user credentials when logging to L&B Proxy */ - EDG_WLL_PARAM__LAST, /**< marker, LB internal use only */ -} edg_wll_ContextParam; - -/** sets returned query results */ -typedef enum _edg_wll_QueryResults { - EDG_WLL_QUERYRES_UNDEF, /* uninitialized value */ - EDG_WLL_QUERYRES_NONE, - EDG_WLL_QUERYRES_ALL, - EDG_WLL_QUERYRES_LIMITED, - EDG_WLL_QUERYRES__LAST /* marker, for internal use only */ -} edg_wll_QueryResults; - -/** identification of logging component */ -typedef enum _edg_wll_Source { - EDG_WLL_SOURCE_NONE, /* uninitialized value */ - EDG_WLL_SOURCE_USER_INTERFACE, - EDG_WLL_SOURCE_NETWORK_SERVER, - EDG_WLL_SOURCE_WORKLOAD_MANAGER, - EDG_WLL_SOURCE_BIG_HELPER, - EDG_WLL_SOURCE_JOB_SUBMISSION, - EDG_WLL_SOURCE_LOG_MONITOR, - EDG_WLL_SOURCE_LRMS, - EDG_WLL_SOURCE_APPLICATION, - EDG_WLL_SOURCE__LAST /* marker, for internal use only */ -} edg_wll_Source; - - -/** Allocate an initialize a new context object. - * \param context OUT returned context - * \return 0 on success, ENOMEM if malloc() fails - */ -int edg_wll_InitContext(edg_wll_Context *context); - -/** Destroy and free context object. - * Also performs necessary cleanup (closing connections etc.) - * \param context IN context to free - */ -void edg_wll_FreeContext(edg_wll_Context context); - -/** Set a context parameter. - * \param context INOUT context to work with - * \param param IN parameter to set - * \param ... IN value to set (if NULL or 0, default is used) - * \retval 0 success - * \retval EINVAL param is not a valid parameter, or invalid value - */ -int edg_wll_SetParam( - edg_wll_Context context, - edg_wll_ContextParam param, - ... -); - -struct timeval; /* gcc, shut up! */ - -int edg_wll_SetParamInt(edg_wll_Context,edg_wll_ContextParam,int); -int edg_wll_SetParamString(edg_wll_Context,edg_wll_ContextParam,const char *); -int edg_wll_SetParamTime(edg_wll_Context,edg_wll_ContextParam,const struct timeval *); - -/** Get current parameter value. - * \param context INOUT context to work with - * \param param IN parameter to retrieve - * \param ... OUT pointer to output variable - * \retval 0 success - * \retval EINVAL param is not a valid parameter - */ -int edg_wll_GetParam( - edg_wll_Context context, - edg_wll_ContextParam param, - ... -); - - -/** - * L&B subsystem specific error codes. - * Besides them L&B functions return standard \a errno codes in their usual - * meaning. - */ - -/* XXX: cleanup required */ - -typedef enum _edg_wll_ErrorCode { -/** Base for L&B specific code. Use the constant from common/ */ - EDG_WLL_ERROR_BASE = GLITE_WMS_LOGGING_ERROR_BASE, - EDG_WLL_ERROR_PARSE_BROKEN_ULM, /**< Parsing ULM line into edg_wll_Event structure */ - EDG_WLL_ERROR_PARSE_EVENT_UNDEF, /**< Undefined event name */ - EDG_WLL_ERROR_PARSE_MSG_INCOMPLETE, /**< Incomplete message (missing fields) */ - EDG_WLL_ERROR_PARSE_KEY_DUPLICITY, /**< Duplicate entry in message */ - EDG_WLL_ERROR_PARSE_KEY_MISUSE, /**< Entry not allowed for this message type */ - EDG_WLL_ERROR_PARSE_OK_WITH_EXTRA_FIELDS, /**< Additional, not understood fields found in message. - The rest is OK therefore this is not a true error. */ - EDG_WLL_ERROR_XML_PARSE, /**< Error in parsing XML protocol. */ - EDG_WLL_ERROR_SERVER_RESPONSE, /**< Generic failure on server. See syslog on the server machine for details. */ - EDG_WLL_ERROR_JOBID_FORMAT, /**< Malformed jobid */ - EDG_WLL_ERROR_DB_CALL, /**< Failure of underlying database engine. - See errDesc returned by edg_wll_ErrorCode(). */ - EDG_WLL_ERROR_URL_FORMAT, /**< Malformed URL */ - EDG_WLL_ERROR_MD5_CLASH, /**< MD5 hash same for different strings. Very unlikely :-). */ - EDG_WLL_ERROR_GSS, /**< Generic GSSAPI error. See errDesc returned by edg_wll_Error(). */ - EDG_WLL_ERROR_DNS, /**< DNS resolver error. See errDesc returned by edg_wll_Error(). */ - EDG_WLL_ERROR_NOJOBID, /**< Attmepted call requires calling edg_wll_SetLoggingJob() first. */ - EDG_WLL_ERROR_NOINDEX, /**< Query does not contain any conidion on indexed attribute. */ - EDG_WLL_IL_PROTO, /**< Interlogger to lbserver communication protocol error. */ - EDG_WLL_IL_SYS, /**< Interlogger internal error. */ - EDG_WLL_IL_EVENTS_WAITING, /**< Interlogger still has events pending delivery. */ - EDG_WLL_ERROR_COMPARE_EVENTS, /**< Two compared events differ. */ -} edg_wll_ErrorCode; - -/** - * Retrieve error details on recent API call - * \param context IN: context to work with - * \param errText OUT: standard error text - * (may be NULL - no text returned) - * \param errDesc OUT: additional error description - * (may be NULL - no text returned) - * \return Error code of the recent error - */ - -int edg_wll_Error( - edg_wll_Context context, - char **errText, - char **eddDesc -); - -/** Convert source code to printable string - */ -char * edg_wll_SourceToString(edg_wll_Source src); - -/** Convert name to source code - * \return Matching code or EDG_WLL_SOURCE_NONE - */ -edg_wll_Source edg_wll_StringToSource(const char *name); - -/** Convert Query result code to printable string - */ -char * edg_wll_QResultToString(edg_wll_QueryResults res); - -/** Convert name to Query result code - * \return Matching code or EDG_WLL_SOURCE_NONE - */ -edg_wll_QueryResults edg_wll_StringToQResult(const char *name); - -/** - * type of sequence code (used when setting to the context) - */ -#define EDG_WLL_SEQ_NORMAL 1 -#define EDG_WLL_SEQ_DUPLICATE 11 - -/** - * initial sequence code for BigHelper - */ - -#define EDG_WLL_SEQ_BIGHELPER_INITIAL "UI=2:NS=0:WM=0:BH=1:JSS=0:LM=0:LRMS=0:APP=0" - -/** Retrieve current sequence code from the context */ -char * edg_wll_GetSequenceCode( - const edg_wll_Context context -); - -/** - * retrieve the current logging JobId from the context - */ -int edg_wll_GetLoggingJob( - const edg_wll_Context context, - edg_wlc_JobId *jobid_out -); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/org.glite.lb.client-interface/interface/dump.h b/org.glite.lb.client-interface/interface/dump.h deleted file mode 100644 index 37f9dd7..0000000 --- a/org.glite.lb.client-interface/interface/dump.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_DUMP_H__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_DUMP_H__ - -#ident "$Header$" - -#define EDG_WLL_DUMP_NOW -1 -#define EDG_WLL_DUMP_LAST_START -2 -#define EDG_WLL_DUMP_LAST_END -3 -/* if adding new attribute, add conversion string to common/xml_conversions.c too !! */ - -typedef struct { - time_t from,to; -} edg_wll_DumpRequest; - -typedef struct { - char *server_file; - time_t from,to; -} edg_wll_DumpResult; - -/** Dump events in a given time interval - */ - -int edg_wll_DumpEvents( - edg_wll_Context, - const edg_wll_DumpRequest *, - edg_wll_DumpResult * -); - - -#endif - diff --git a/org.glite.lb.client-interface/interface/events.h.T b/org.glite.lb.client-interface/interface/events.h.T deleted file mode 100644 index e37be1f..0000000 --- a/org.glite.lb.client-interface/interface/events.h.T +++ /dev/null @@ -1,332 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_EVENTS_H__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_EVENTS_H__ - -/** - * \file edg/workload/logging/client/events.h - * \brief contains definition of event type codes for use both by lbapi.h and dglog.h - */ - -#ident "$Header$" -/* -@@@AUTO -*/ -@@@LANG: C - -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/context.h" -#include "glite/lb/notifid.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Predefined type for ULM string - */ -typedef char *edg_wll_LogLine; - - -/** - * \typedef edg_wll_EventCode - * Predefined event types - */ -typedef enum _edg_wll_EventCode { -/** invalid code, e.g. uninitialized variable */ - EDG_WLL_EVENT_UNDEF = 0, -@@@{ -for my $e (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $u = uc $e; - my $c = getTypeComment $event $e; - gen "\tEDG_WLL_EVENT_$u,\t/**< $c */\n"; -} -@@@} - EDG_WLL_EVENT__LAST, /**< last currently supported event code */ -} edg_wll_EventCode; - -/** - * \fn edg_wll_EventCode edg_wll_StringToEvent(char *name) - * \param name a string event name (e.g. "JobTransfer") - * \return corresponding numeric code (edg_wll_EventCode) - * \brief convert a string event name to the corresponding numeric code - */ - -extern edg_wll_EventCode edg_wll_StringToEvent(char *); - -/** - * \fn char *edg_wll_EventToString(edg_wll_EventCode event) - * \param event an event numeric code (edg_wll_EventCode) - * \return corresponding string (e.g. "JobTransfer") - * \brief convert an event numeric code to the corresponding string - */ - -extern char *edg_wll_EventToString(edg_wll_EventCode); - - -/** - * \typedef edg_wll_KeyNameCode - * Predefined ULM key types - */ -typedef enum _edg_wll_KeyNameCode { - UNDEFINED, /**< undefined */ - EDG_WLL_EVNT, /**< event type */ -@@@{ -selectType $event '_common_'; -for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = getName $f 'ULM'; - my $fnu = uc $fn; - my $c = $f->{comment}; - if (hasAlias $f 'ULM') { - gen "\tULM\_$fnu,\t\t/**< $c */\n"; - } else { - gen "\tEDG_WLL\_COMMON\_$fnu,\t\t/**< $c */\n"; - } -} -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fnu = uc $f->{name}; - my $c = $f->{comment}; - gen "\tEDG_WLL\_$tu\_$fnu,\t/**< $c */\n"; - } -} -@@@} - EDG_WLL_INTERNAL_TYPE, /**< internal message type */ -} edg_wll_KeyNameCode; - -/** - * \fn edg_wll_KeyNameCode edg_wll_StringToKeyName(char *name) - * \param name a string ULM key name (e.g. "DG.JOB.TRANSFER.DEST") - * \return corresponding numeric code (edg_wll_KeyNameCode) - * \brief convert a string ULM key name to the corresponding numeric code - */ - -extern edg_wll_KeyNameCode edg_wll_StringToKeyName(char *); - -/** - * \fn char *edg_wll_KeyNameToString(edg_wll_KeyNameCode key) - * \param key a ULM key name numeric code (edg_wll_KeyNameCode) - * \return corresponding string (e.g. "DG.JOB.TRANSFER.DEST") - * \brief convert a ULM key name numeric code to the corresponding string - */ - -extern char *edg_wll_KeyNameToString(edg_wll_KeyNameCode); - - -/** - * Predefined _code_ types and - * related StringTo_code and _code_ToString function prototypes - */ -@@@{ -$indent = "\t"; -selectType $event '_common_'; -for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - if ($f->{codes}) { - my $fn = ucfirst($f->{name}); - my $fnu = uc $fn; - my $c = "${fn}"; # new code - my $enum = "enum edg_wll\_$c"; # new enum name - -# enum - gen qq{ -/** - * \\enum $enum - * $fn codes - */ -$enum \{ -}; - gen $indent."EDG_WLL_${fnu}_UNDEFINED,\t/**< undefined code */ \n"; - for (@{$f->{codes}}) { - gen $indent."EDG_WLL_${fnu}_$_->{name},\t/**< $_->{comment} */ \n"; - } - gen "};\n"; - -# function StringTo: - gen qq{ -/** - * \\fn $enum edg_wll_StringTo${c}(char *name); - * \\param name a string representing $fn code (e.g. \"${$f->{codes}}[1]->{name}\") - * \\return corresponding numeric code ($enum) - * \\brief converts a string $fn code to corresponding numeric code - */ -extern $enum edg_wll_StringTo${c}(char *name); -}; - -# function ToString: - gen qq{ -/** - * \\fn char *edg_wll\_${c}ToString($enum code); - * \\param code a $fn numeric code ($enum) - * \\return corresponding string (e.g. \"${$f->{codes}}[1]->{name}\") - * \\brief converts a $fn numeric code to corresponding string - */ -extern char *edg_wll\_${c}ToString($enum code); -\n}; - } -} -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t . '_'; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - if ($f->{codes}) { - my $fn = ucfirst($f->{name}); - my $c = "$t${fn}"; # new code - my $enum = "enum edg_wll\_$c"; # new enum name - -# enum - gen qq{ -/** - * \\enum $enum - * $fn codes of the $t event - */ -$enum \{ -}; - gen $indent."EDG_WLL_${tu}UNDEFINED,\t/**< undefined code */ \n"; - for (@{$f->{codes}}) { - gen $indent."EDG_WLL_$tu$_->{name},\t/**< $_->{comment} */ \n"; - } - gen "};\n"; - -# function StringTo: - gen qq{ -/** - * \\fn $enum edg_wll_StringTo${c}(char *name); - * \\param name a string representing $t $fn code (e.g. \"${$f->{codes}}[1]->{name}\") - * \\return corresponding numeric code ($enum) - * \\brief converts a string $t $fn code to corresponding numeric code - */ -extern $enum edg_wll_StringTo${c}(char *name); -}; - -# function ToString: - gen qq{ -/** - * \\fn char *edg_wll\_${c}ToString($enum code); - * \\param code a $t $fn numeric code ($enum) - * \\return corresponding string (e.g. \"${$f->{codes}}[1]->{name}\") - * \\brief converts a $t $fn numeric code to corresponding string - */ -extern char *edg_wll\_${c}ToString($enum code); -\n}; - } - } -} -@@@} - - -/** - * common fields of all event types: - */ - -@@@{ -$indent = "\t"; -gen "#define _EDG_WLL_EVENT_COMMON \\\n"; -gen $indent."edg_wll_EventCode\t\ttype;\\\n"; -selectType $event '_common_'; -for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - my $tn = $f->getType; - gen $indent."$tn\t\t$fn;\t\\\n"; -} -gen "\n"; -@@@} - -typedef struct _edg_wll_AnyEvent { -_EDG_WLL_EVENT_COMMON -} edg_wll_AnyEvent; - - -/** - * Event types specific structures: - */ -@@@{ -$indent = "\t"; -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t; - my $s = "edg_wll_${t}Event"; -# typedef struct - gen qq{ -/** -* \\typedef $s -* structure definition for $t event -*/ -typedef struct \_$s \{ -_EDG_WLL_EVENT_COMMON -}; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - my $fnu = ucfirst $fn; - my $c = $f->{comment}; - my $tn; - if ($f->{codes}) { - $tn = "enum edg_wll\_$t${fnu}"; - } else { - $tn = $f->getType; - } - gen $indent."$tn\t$fn;\t/**< $c */\n"; - } - gen "\} $s;\n"; -} -@@@} - -#undef _EDG_WLL_EVENT_COMMON - - -/** - * \union edg_wll_Event - * \brief All event types union - */ -typedef union _edg_wll_Event { - edg_wll_EventCode type; /* it is probably never used */ - edg_wll_AnyEvent any; -@@@{ -$indent = "\t"; -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tl = lcfirst $t; - gen $indent."edg_wll_${t}Event\t${tl};\n"; -} -@@@} -} edg_wll_Event; - - -/** - * Initialise an event structure - * \return pointer to initialised event structure - */ -extern edg_wll_Event *edg_wll_InitEvent(edg_wll_EventCode eventcode); - - -/** - * Free the contents of event structure - * \param IN event structure to be freed - * \warning As event structures are likely to be allocated in arrays, - * the structure itself is not freed. - * Its the responsibility of the caller to call free(event) - * if appropriate. - */ -void edg_wll_FreeEvent( - edg_wll_Event * event -); - - -#ifdef __cplusplus -} -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_CLIENT_EVENTS_H__ */ diff --git a/org.glite.lb.client-interface/interface/jobstat.h.T b/org.glite.lb.client-interface/interface/jobstat.h.T deleted file mode 100644 index 129b61d..0000000 --- a/org.glite.lb.client-interface/interface/jobstat.h.T +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_JOBSTAT_H__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_JOBSTAT_H__ - -/* -@@@AUTO -*/ - -/*! - * \file client/jobstat.h - * \brief edg_wll_JobStat definition and related stuff - */ - -#ident "$Header$" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Miscelaneous job status numeric codes - */ - -@@@{ - for my $n ($status->getAllFieldsOrdered) { -# XXX: we've got only _common_ in jobStatus, no clash possible - my $f = selectField $status $n; - if ($f->{codes}) { - my $n = ucfirst getName $f; - gen qq{ -!enum edg_wll_Stat$n \{ -}; - for (@{$f->{codes}}) { - my $uc = uc $_->{name}; - gen qq{ -! EDG_WLL_STAT_$uc, /**< $_->{comment} */ -}; - } - gen qq{ -!\}; -}; - } - } -@@@} - - -/*! - * - * Job status numeric code - */ - -typedef enum _edg_wll_JobStatCode { -/** Indicates invalid edg_wll_JobStat structure */ - EDG_WLL_JOB_UNDEF = 0, -@@@{ - for my $stat ($status->getTypesOrdered) { - my $u = uc $stat; - my $c = getTypeComment $status $stat; - gen qq{ -! EDG_WLL_JOB_$u, /**< $c */ -}; - } -@@@} - EDG_WLL_NUMBER_OF_STATCODES /**< Number of meaningful status codes */ -} edg_wll_JobStatCode; - -/*! - * - * Pair tag = value. - */ -typedef struct _edg_wll_TagValue { - char * tag; /**< User-specified information tag */ - char * value; /**< Value assigned to user-specified information tag */ -} edg_wll_TagValue; - - -/*! - * - * Description of the job status. - * Returned by the edg_wll_JobStatus() function - */ -typedef struct _edg_wll_JobStat { - edg_wll_JobStatCode state; /**< status code */ -@@@{ - for my $n (getAllFieldsOrdered $status) { - selectField $status $n; - my $f = getField $status; - my $type = getType $f; - my $name = getName $f; - my $fucname = ucfirst $name; - $type = "enum edg_wll_Stat$fucname" if $f->{codes}; - my $comment = getComment $f; - gen qq{ -! $type $name; /**< $comment */ -}; - } -@@@} - -} edg_wll_JobStat; - -/** - * \name edg_wll_JobStat manipulation - */ - -/*@{*/ - -/** - * Initialize empty status structure. - * Fills in the stucture with NULL's or values with no meaning - */ - -extern int edg_wll_InitStatus(edg_wll_JobStat *); - -/** - * Initialize dest structure and copy source status to this destination - */ - -extern edg_wll_JobStat *edg_wll_CpyStatus(const edg_wll_JobStat *,edg_wll_JobStat *); - -/** - * Free status structure contents. - * \warning The structure itself is not freed. - */ -extern void edg_wll_FreeStatus(edg_wll_JobStat *); - -/** - * Convert string job status to numeric code. - */ -extern edg_wll_JobStatCode edg_wll_StringToStat(const char *); - -/** - * Convert numeric job status code to string representation - */ -extern char *edg_wll_StatToString(edg_wll_JobStatCode); - -/*@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_CLIENT_JOBSTAT_H__ */ diff --git a/org.glite.lb.client-interface/interface/load.h b/org.glite.lb.client-interface/interface/load.h deleted file mode 100644 index 5ca8ead..0000000 --- a/org.glite.lb.client-interface/interface/load.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_LOAD_H__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_LOAD_H__ - -#ident "$Header$" - -typedef struct { - char *server_file; -} edg_wll_LoadRequest; - -typedef struct { - char *server_file; - time_t from,to; -} edg_wll_LoadResult; - -/** Load events from a given file into the database - * \retval EPERM operation not permitted - * \retval ENOENT file not found - */ - -int edg_wll_LoadEvents( - edg_wll_Context, - const edg_wll_LoadRequest *, - edg_wll_LoadResult * -); - -#endif - diff --git a/org.glite.lb.client-interface/interface/notification.h b/org.glite.lb.client-interface/interface/notification.h deleted file mode 100644 index a16215d..0000000 --- a/org.glite.lb.client-interface/interface/notification.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_NOTIFICATION_H__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_NOTIFICATION_H__ - -#ident "$Header$" - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/notifid.h" -#include "glite/lb/context.h" -#include "glite/lb/consumer.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * default and maximal notif timeout (in seconds) - */ -#define EDG_WLL_NOTIF_TIMEOUT_DEFAULT 120 -#define EDG_WLL_NOTIF_TIMEOUT_MAX 1800 - - -/** Register for receiving notifications. - * Connects to the server specified by EDG_WLL_NOTIF_SERVER context parameter - * (temporary workaround, should be resolved by registry in future). - * \param conditions: the same conditions as for \see edg_wll_QueryJobsExt. - * currently one or more JOBID's are required. - * Only a single occurence of a specific attribute is allowed - * among ANDed conditions (due to the ability to modify them - * further). - * \param fd = -1 create or reuse the default listening socket (one per context) - * >= 0 non-default listening socket - * \param address_override if not NULL, use this address instead of extracting it - * from the connection (useful when multiple interfaces are present, - * circumventing NAT problems etc.) - * \param valid until when the registration is valid (NULL means no interest in - * the value - * \retval 0 OK - * \retval EINVAL restrictions on conditions are not met - * - */ -int edg_wll_NotifNew( - edg_wll_Context context, - edg_wll_QueryRec const * const *conditions, - int fd, - const char *address_override, - edg_wll_NotifId *id_out, - time_t *valid -); - - -/** Change the receiving local address. - * Report the new address to the server. - * - * \param fd - * \param address_override - * \param valid all same as for \see edg_wll_NotifNew - */ - -int edg_wll_NotifBind( - edg_wll_Context context, - const edg_wll_NotifId id, - int fd, - const char *address_override, - time_t *valid -); - -typedef enum _edg_wll_NotifChangeOp { - EDG_WLL_NOTIF_NOOP = 0, - EDG_WLL_NOTIF_REPLACE, - EDG_WLL_NOTIF_ADD, - EDG_WLL_NOTIF_REMOVE -/* if adding new attribute, add conversion string to common/xml_conversions.c too !! */ -} edg_wll_NotifChangeOp; - -/** Modify the query conditions for this notification. - * - * If op is either EDG_WLL_NOTIF_ADD or EDG_WLL_NOTIF_REMOVE, for the sake - * of uniqueness the original conditions must have contained only a single - * OR-ed row of conditions on the attributes infolved in the change. - * - * \param op action to be taken on existing conditions, - * \see edg_wll_NotifChangeOp - */ -int edg_wll_NotifChange( - edg_wll_Context context, - const edg_wll_NotifId id, - edg_wll_QueryRec const * const * conditions, - edg_wll_NotifChangeOp op -); - -/** Refresh the registration, i.e. extend its validity period. - * \param valid until when the registration is valid (NULL means no interest in - * the value - */ - -int edg_wll_NotifRefresh( - edg_wll_Context context, - const edg_wll_NotifId id, - time_t *valid -); - -/** Drop the registration. - * Server is instructed not to send notifications anymore, pending ones - * are discarded, listening socket is closed, and allocated memory freed. - */ - -int edg_wll_NotifDrop( - edg_wll_Context context, - edg_wll_NotifId *id -); - -/** Receive notification. - * The first incoming notification is returned. - * \param fd receive on this socket (-1 means the default for the context) - * \param timeout wait atmost this time long. (0,0) means polling, NULL waiting - * indefinitely - * - * \retval 0 notification received, state_out contains the current job state - * \retval EAGAIN no notification available, timeout occured - */ - -int edg_wll_NotifReceive( - edg_wll_Context context, - int fd, - const struct timeval *timeout, - edg_wll_JobStat *state_out, - edg_wll_NotifId *id_out -); - - -/** Default socket descriptor where to select(2) for notifications. - * Even if nothing is available for reading freom the socket, - * there may be some data cached so calling \see edg_wll_NotifReceive - * may return notifications immediately. - * - * \retval >=0 socket descriptor - * \retval -1 error, details set in context - */ - -int edg_wll_NotifGetFd( - edg_wll_Context context -); - -/** Close the default local listening socket. - * Useful to force following \see edg_wll_NotifBind to open - * a new one. - */ - -int edg_wll_NotifCloseFd( - edg_wll_Context context -); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/org.glite.lb.client-interface/interface/notifid.h b/org.glite.lb.client-interface/interface/notifid.h deleted file mode 100644 index fc52d01..0000000 --- a/org.glite.lb.client-interface/interface/notifid.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_NOTIFID_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_NOTIFID_H__ - -#ident "$Header$" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Notification handle. - * Refers to a particular registration for receiving notifications. - */ -typedef void *edg_wll_NotifId; - -/** Parse and unparse the Id. */ -int edg_wll_NotifIdParse(const char *,edg_wll_NotifId *); -char* edg_wll_NotifIdUnparse(const edg_wll_NotifId); - -int edg_wll_NotifIdCreate(const char *,int,edg_wll_NotifId *); -void edg_wll_NotifIdFree(edg_wll_NotifId); - -void edg_wll_NotifIdGetServerParts(const edg_wll_NotifId, char **, unsigned int *); -char *edg_wll_NotifIdGetUnique(const edg_wll_NotifId); -int edg_wll_NotifIdSetUnique(edg_wll_NotifId *, const char *); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/org.glite.lb.client-interface/interface/producer.h.T b/org.glite.lb.client-interface/interface/producer.h.T deleted file mode 100644 index 188f25c..0000000 --- a/org.glite.lb.client-interface/interface/producer.h.T +++ /dev/null @@ -1,454 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_PRODUCER_H__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_PRODUCER_H__ - -/** - * \file edg/workload/logging/client/producer.h - * \brief client API for storing data into L&B service - */ - -#ident "$Header$" -/* -@@@AUTO -*/ -@@@LANG: C - -#ifdef __cplusplus -extern "C" { -#endif - -#include "glite/lb/context.h" -#include "glite/lb/events.h" - -/* Event sources: */ - -#if 0 /* obsolete */ -#define EDG_WLL_SOURCE_UI "UserInterface" -#define EDG_WLL_SOURCE_RB "ResourceBroker" -#define EDG_WLL_SOURCE_JSS "JobSubmissionService" /* aka Condor-G */ -#define EDG_WLL_SOURCE_JOBMGR "GlobusJobmanager" -#define EDG_WLL_SOURCE_LRMS "LocalResourceManager" -#define EDG_WLL_SOURCE_APP "Application" - -#define EDG_WLL_SOURCE_NS "NetworkServer" -#define EDG_WLL_SOURCE_WM "WorkloadManager" -#define EDG_WLL_SOURCE_BH "BigHelper" -#define EDG_WLL_SOURCE_LM "LogMonitor" - -#endif - -/* Event formats: */ - -#define EDG_WLL_FORMAT_COMMON "DATE=%s HOST=\"%|Us\" PROG=edg-wms LVL=%s DG.PRIORITY=%d DG.SOURCE=\"%|Us\" DG.SRC_INSTANCE=\"%|Us\" DG.EVNT=\"%s\" DG.JOBID=\"%s\" DG.SEQCODE=\"%|Us\" " -#define EDG_WLL_FORMAT_USER "DG.USER=\"%|Us\" " -@@@{ -# FIXME: -# this is all functional, but doesn't fit to all common fields (eg. USER) -# -#gen "#define EDG_WLL_FORMAT_COMMON\t\""; -#selectType $event '_common_'; -#for ($event->getFieldsOrdered) { -# my $f = selectField $event $_; -# my $fn = getName $f 'ULM'; -# my $fnu = uc $fn; -# if (hasAlias $f 'ULM') { -# gen "$fnu=%s "; -# } else { -# gen "DG\.$fnu="; -# gen $f->toFormatString; -# gen " "; -# } -#} -#gen "\"\n"; -# -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t; - gen "#define EDG_WLL_FORMAT_$tu\t\""; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - my $fnu = uc $fn; - gen "DG.$tu.$fnu=\\\""; - if ($f->{codes}) { - gen "%s"; - } else { - gen $f->toFormatString; - } - gen "\\\" "; - } - gen "\"\n"; -} -@@@} -#define EDG_WLL_FORMAT_NOTIFICATION_COMMON "DATE=%s HOST=\"%|Us\" PROG=edg-wms LVL=%s DG.SOURCE=\"%|Us\" DG.SRC_INSTANCE=\"%|Us\" DG.TYPE=\"notification\" " -#define EDG_WLL_FORMAT_SYSCMPSTAT "DG.SCHED.STATUS=\"%|Us\" " -#define EDG_WLL_FORMAT_SYSCLSTAT "DG.SCHED.NODE=\"%|Us\" DG.SCHED.STATUS=\"%|Us\" " - - -/* edg_wll_LogEvent shortcuts */ -@@@{ -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t; - my $a = "(edg_wll_Context context"; - my $b = "(context,EDG_WLL_EVENT_$tu,EDG_WLL_FORMAT_$tu"; - my $doc = qq{ - * \\param context\tcontext to work with, -}; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->getName; - my $ft; - if ($f->{codes}) { -# $ft = "enum edg_wll\_$t" . ucfirst $fn; - $ft = "char *"; - } else { - $ft = $f->getType; - } - $ft = "const ".$ft; - my $fc = $f->getComment; - $a = $a . ", $ft $fn"; - $b = $b . ", $fn"; - $doc = $doc . " * \\param $fn\t$fc\n"; - } - $a = $a . ")"; - $b = $b . ")"; - gen qq{ -/** - * \\fn int edg_wll_Log$t$a; - * \\brief simple wrapper around edg_wll_LogEvent for event $t} . $doc . qq{ * \\see edg_wll_LogEvent\(\) - */ -}; - gen "\nextern int edg_wll_Log${t}$a;\n"; - gen "\nextern int edg_wll_Log${t}Proxy$a;\n"; -# gen qq{ -#int edg_wll_Log$t$a -#\{ -# return edg_wll_LogEvent$b; -#\}\n -#}; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->getName; - my $ft; - if ($f->{codes}) { -# $ft = "enum edg_wll\_$t" . ucfirst $fn; - $ft = "char *"; - } else { - $ft = $f->getType; - } - my $ftreg = $ft; - $ftreg =~ s/\*/\\\*/g; - $ftreg = "const ".$ftreg; - my $fc = $f->getComment; - if ($f->{codes}) { - for (@{$f->{codes}}) { - my $code = uc $_->{name}; - my $c = $a; - my $d = $b; - my $e = $doc; - $c =~ s/, $ftreg $fn//g; - $d =~ s/$fn/"$code"/g; - $e =~ s/ \* \\param $fn\t$fc\n//g; - gen qq{ -/** - * \\fn int edg_wll_Log$t$code$c; - * \\brief simple wrapper around edg_wll_LogEvent for event $t, $fn $code} . $e . qq{ * \\see edg_wll_LogEvent\(\) - */ -}; - gen "\nextern int edg_wll_Log$t${code}$c;\n"; - gen "\nextern int edg_wll_Log$t${code}Proxy$c;\n"; -# gen qq{ -#int edg_wll_Log$t$code$c -#\{ -# return edg_wll_LogEvent$d; -#\}\n -#}; - } - } - } -} -@@@} - - -/** - * Formats a logging message and sends it asynchronously to local-logger - * \brief generic asynchronous logging function - * \param context INOUT context to work with, - * \param event IN type of the event, - * \param fmt IN printf()-like format string, - * \param ... IN event specific values/data according to fmt, - * \retval 0 successful completition, - * \retval EINVAL bad jobId, unknown event code, or the format string together with the remaining arguments does not form a valid event, - * \retval ENOSPC L&B infrastructure failed to accept the event due to lack of disk space etc., - * \retval ENOMEM failed to allocate memory, - * \retval ECONNREFUSED cannot connect to the specified local logger, - * \retval EAGAIN non blocking return from the call, the event may or may not get logged, - * \retval EDG_WLL_ERROR_NOJOBID logging call attempted without assigning jobId to the context. - */ -extern int edg_wll_LogEvent( - edg_wll_Context context, - edg_wll_EventCode event, - char *fmt, ...); - -/** - * Formats a logging message and sends it synchronously to local-logger - * \brief generic synchronous logging function - * \param context INOUT context to work with, - * \param event IN type of the event, - * \param fmt IN printf()-like format string, - * \param ... IN event specific values/data according to fmt, - * \retval 0 successful completition, - * \retval EINVAL bad jobId, unknown event code, or the format string together with the remaining arguments does not form a valid event, - * \retval ENOSPC L&B infrastructure failed to accept the event due to lack of disk space etc., - * \retval ENOMEM failed to allocate memory, - * \retval ECONNREFUSED cannot connect to the specified local logger, - * \retval EAGAIN non blocking return from the call, the event may or may not get logged, - * \retval EDG_WLL_ERROR_NOJOBID logging call attempted without assigning jobId to the context, - * \retval EPERM the user is not authorized to add events to this job, - * \retval EDG_WLL_ERROR_DB_DUP_KEY exactly the same event has been already stored. - */ -extern int edg_wll_LogEventSync( - edg_wll_Context context, - edg_wll_EventCode event, - char *fmt, ...); - -/** - * Formats a logging message and sends it synchronously to L&B Proxy - * \brief generic synchronous logging function - * \param context INOUT context to work with, - * \param event IN type of the event, - * \param fmt IN printf()-like format string, - * \param ... IN event specific values/data according to fmt, - * \retval 0 successful completition, - * \retval EINVAL bad jobId, unknown event code, or the format string together with the remaining arguments does not form a valid event, - * \retval ENOSPC L&B infrastructure failed to accept the event due to lack of disk space etc., - * \retval ENOMEM failed to allocate memory, - * \retval ECONNREFUSED cannot connect to the specified L&B Proxy - * \retval EAGAIN non blocking return from the call, the event may or may not get logged, - * \retval EDG_WLL_ERROR_NOJOBID logging call attempted without assigning jobId to the context. - */ -extern int edg_wll_LogEventProxy( - edg_wll_Context context, - edg_wll_EventCode event, - char *fmt, ...); - -/** - * Instructs interlogger to to deliver all pending events related to current job - * \brief flush events from interlogger - * \note sort of status query more than a command - * \param context INOUT context to work with, - * \param timeout INOUT wait at most this much time for completition, remaining time on return, - * \retval 0 successful completition, - * \retval EDG_WLL_ERROR_INTERLOG_TIMEOUT the inter-logger did not respond within the timeout, - * \retval EDG_WLL_ERROR_INTERLOG_CONLOST inter-logger lost connection to one or more servers, - * \retval EDG_WLL_ERROR_INTERLOG_AGAIN not all pending events were delivered within the timeout. - */ -extern int edg_wll_LogFlush( - edg_wll_Context context, - struct timeval *timeout); - - -/** - * Instructs interlogger to to deliver all pending events - * \brief flush all events from interlogger - * \note same as edg_wll_LogFlush() for all jobs known to interlogger - * \see edg_wll_LogFlush() - */ -extern int edg_wll_LogFlushAll( - edg_wll_Context context, - struct timeval *timeout); - -/** - * Set a current job for given context. - * \note Should be called before any logging call. - * \param context INOUT context to work with - * \param job IN further logging calls are related to this job - * \param code IN sequence code as obtained from previous component - * \param flags IN flags on code handling (\see API documentation) - */ -extern int edg_wll_SetLoggingJob( - edg_wll_Context context, - const edg_wlc_JobId job, - const char * code, - int flags -); - -/** - * Set a current job for given context. - * \note Should be called before any logging call. - * \param context INOUT context to work with - * \param job IN further logging calls are related to this job - * \param code IN sequence code as obtained from previous component - * \param user IN user credentials - * \param flags IN flags on code handling (\see API documentation) - */ -extern int edg_wll_SetLoggingJobProxy( - edg_wll_Context context, - const edg_wlc_JobId job, - const char * code, - const char * user, - int flags -); - - -/** - * Register job with L&B service. - * Done via logging REGJOB event, may generate subjob id's and create - * the parent-children associations. - * Set the job as current for the context and initialize sequence code. - * - * Partitionable jobs should set num_subjobs=0 initially, - * and re-register when number of subjobs becomes known. - * - * \param type IN EDG_WLL_JOB_SIMPLE, EDG_WLL_JOB_DAG, or EDG_WLL_JOB_PARTITIONABLE - * \param jdl IN user-specified JDL - * \param ns IN network server contact - * \param num_subjobs IN number of subjobs to create - * \param seed IN seed used for subjob id's generator. - * Use non-NULL value to be able to regenerate the set of jobid's - * \param subjobs OUT returned subjob id's - */ - -/* backward compatibility */ -#define EDG_WLL_JOB_SIMPLE EDG_WLL_REGJOB_SIMPLE - -extern int edg_wll_RegisterJob( - edg_wll_Context context, - const edg_wlc_JobId job, - enum edg_wll_RegJobJobtype type, - const char * jdl, - const char * ns, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs -); - -/** - * Synchronous variant of edg_wll_RegisterJob - */ - -extern int edg_wll_RegisterJobSync( - edg_wll_Context context, - const edg_wlc_JobId job, - enum edg_wll_RegJobJobtype type, - const char * jdl, - const char * ns, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs -); - -/** - * Register job with L&B Proxy service. - * Done via logging REGJOB event, may generate subjob id's and create - * the parent-children associations. - * Set the job as current for the context and initialize sequence code. - * - * Partitionable jobs should set num_subjobs=0 initially, - * and re-register when number of subjobs becomes known. - * - * \param type IN EDG_WLL_JOB_SIMPLE, EDG_WLL_JOB_DAG, or EDG_WLL_JOB_PARTITIONABLE - * \param user IN user credentials - * \param jdl IN user-specified JDL - * \param ns IN network server contact - * \param num_subjobs IN number of subjobs to create - * \param seed IN seed used for subjob id's generator. - * Use non-NULL value to be able to regenerate the set of jobid's - * \param subjobs OUT returned subjob id's - */ - -extern int edg_wll_RegisterJobProxy( - edg_wll_Context context, - const edg_wlc_JobId job, - enum edg_wll_RegJobJobtype type, - const char * user, - const char * jdl, - const char * ns, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs -); - - -/** - * Register subjobs in a batch. - * Mainly used to provide JDL's of individual subjobs in a more efficient - * way than logging them one by one. - * \param jdls array of JDL's - * \param subjobs array of jobid's in the same order - */ - -extern int edg_wll_RegisterSubjobs( - edg_wll_Context context, - const edg_wlc_JobId parent, - char const * const * jdls, - const char * ns, - edg_wlc_JobId const * subjobs -); - - -/** - * Generate or regenerate set of subjob ID's. - * Calls the same algorithm used to generate subjob ID's in edg_wll_RegisterJob(). - * Local semantics only, server is not contacted. - */ - -extern int edg_wll_GenerateSubjobIds( - edg_wll_Context context, - const edg_wlc_JobId parent, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs -); - - -enum edg_wll_Permission { - EDG_WLL_PERM_READ = 1, - EDG_WLL_PERM_WRITE = 4, - EDG_WLL_PERM_ADMIN = 8, -}; - -enum edg_wll_PermissionType { - EDG_WLL_PERM_ALLOW, - EDG_WLL_PERM_DENY, -}; - -enum edg_wll_ACLOperation { - EDG_WLL_ACL_ADD, - EDG_WLL_ACL_REMOVE, -}; - -enum edg_wll_UserIdType { - EDG_WLL_USER_SUBJECT, /* X.509 subject name */ - EDG_WLL_USER_VOMS_GROUP, /* VOMS group membership */ -}; - -/** - * Change ACL for given job. - * \param specification of user's credential - * \param user_id_type type of user_id, - * for EDG_WLL_USER_SUBJECT the user_id parameter is expected to be user's subject name - * for EDG_WLL_USER_VOMS_GROUP the user_id is expected to be of the form VO:group specifying required group membersip as managed by VOMS - * \param permission ACL permission to change - * \param permission_type type of given permission (allow or deny operation) - * \param operation operation to perform with ACL (add or remove record) - */ - -extern int edg_wll_ChangeACL( - edg_wll_Context context, - const edg_wlc_JobId job, - const char * user_id, - enum edg_wll_UserIdType user_id_type, - enum edg_wll_Permission permission, - enum edg_wll_PermissionType permission_type, - enum edg_wll_ACLOperation operation -); - - -#ifdef __cplusplus -} -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_CLIENT_PRODUCER_H__ */ diff --git a/org.glite.lb.client-interface/interface/producer_fake.h b/org.glite.lb.client-interface/interface/producer_fake.h deleted file mode 100644 index 69ce184..0000000 --- a/org.glite.lb.client-interface/interface/producer_fake.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * fake implementation of the producer API - */ - -#ifndef WORKLOAD_LOGGING_CLIENT_PRODUCER_FAKE_H -#define WORKLOAD_LOGGING_CLIENT_PRODUCER_FAKE_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef int (edg_wll_Logging_cb_f)(edg_wll_Context context); - -int edg_wll_RegisterTestLogging(edg_wll_Logging_cb_f *cb); -int edg_wll_RegisterTestLoggingProxy(edg_wll_Logging_cb_f *cb); -void edg_wll_UnregisterTestLogging(); -void edg_wll_UnregisterTestLoggingProxy(); - -#ifdef __cplusplus -} -#endif - -#endif /* WORKLOAD_LOGGING_CLIENT_PRODUCER_FAKE_H */ diff --git a/org.glite.lb.client-interface/interface/purge.h b/org.glite.lb.client-interface/interface/purge.h deleted file mode 100644 index 531c903..0000000 --- a/org.glite.lb.client-interface/interface/purge.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_PURGE_H__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_PURGE_H__ - -#ident "$Header$" - -/** Purge or dump request */ -typedef struct _edg_wll_PurgeRequest { - char **jobs; /**< list of jobid's to work on */ - -/** Purge jobs that are in the given states and "untouched" at least for the - * specified interval. - * Currently applicable for CLEARED, ABORTED, CANCELLED and OTHER (catchall). - * The other array members are for future extensions. - * Negative values stand for server defaults. - */ - time_t timeout[EDG_WLL_NUMBER_OF_STATCODES]; -#define EDG_WLL_PURGE_JOBSTAT_OTHER EDG_WLL_JOB_UNDEF - - -/** - * Actions to be taken and information required. - */ - int flags; - -/** no dry run */ -#define EDG_WLL_PURGE_REALLY_PURGE 1 -/** return list of jobid matching the purge/dump criteria */ -#define EDG_WLL_PURGE_LIST_JOBS 2 -/** dump to a file on the sever */ -#define EDG_WLL_PURGE_SERVER_DUMP 4 -/** TODO: stream the dump info to the client */ -#define EDG_WLL_PURGE_CLIENT_DUMP 8 -/* ! when addning new constant, add it also to common/xml_conversions.c ! */ - - -/** private request processing data (for the reentrant functions) */ -/* TODO */ - -} edg_wll_PurgeRequest; - -/** Output data of a purge or dump */ -typedef struct _edg_wll_PurgeResult { - char *server_file; /**< filename of the dump at the server */ - char **jobs; /**< affected jobs */ -/* TODO: output of the streaming interface */ -} edg_wll_PurgeResult; - - -/** Client side purge/dump - * \retval EAGAIN only partial result returned, call repeatedly to get all - * output data - */ -int edg_wll_Purge( - edg_wll_Context ctx, - edg_wll_PurgeRequest *request, - edg_wll_PurgeResult *result -); - -#endif diff --git a/org.glite.lb.client-interface/project/build.properties b/org.glite.lb.client-interface/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.lb.client-interface/project/configure.properties.xml b/org.glite.lb.client-interface/project/configure.properties.xml deleted file mode 100644 index f894934..0000000 --- a/org.glite.lb.client-interface/project/configure.properties.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - -top_srcdir=.. -builddir=build -stagedir=${stage.dir} -distdir=${dist.dir} -package=${module.package.name} -globalprefix=${global.prefix} -lbprefix=${subsystem.prefix} -PREFIX=${install.dir} -version=${module.version} - - -PROJECT_NAME = "Glite LB Client: C - Interface" -PROJECT_NUMBER = ${module.version} -OUTPUT_DIRECTORY = ${component.dir}/doc/C -OPTIMIZE_OUTPUT_FOR_C = YES -INPUT = ./events.h \ - ./jobstat.h \ - ./producer.h \ - ../interface/context.h \ - ../interface/consumer.h -#HAVE_DOT = YES -#CALL_GRAPH = YES - - -PROJECT_NAME = "Glite LB Client: CPP - Interface" -PROJECT_NUMBER = ${module.version} -OUTPUT_DIRECTORY = ${component.dir}/doc/CPP -INPUT = ../build/Event.h \ - ../build/JobStatus.h \ - ../interface/Job.h \ - ../interface/CountRef.h \ - ../interface/LoggingExceptions.h \ - ../interface/ServerConnection.h \ - ../interface/Notification.h -#HAVE_DOT = YES -#CALL_GRAPH = YES - - - diff --git a/org.glite.lb.client-interface/project/properties.xml b/org.glite.lb.client-interface/project/properties.xml deleted file mode 100755 index 31d958b..0000000 --- a/org.glite.lb.client-interface/project/properties.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.client-interface/project/tar_exclude b/org.glite.lb.client-interface/project/tar_exclude deleted file mode 100644 index e1fcd1a..0000000 --- a/org.glite.lb.client-interface/project/tar_exclude +++ /dev/null @@ -1,10 +0,0 @@ -tar_exclude -CVS -build.xml -build -build.properties -properties.xml -configure.properties.xml -.cvsignore -.project -.cdtproject diff --git a/org.glite.lb.client-interface/project/version.properties b/org.glite.lb.client-interface/project/version.properties deleted file mode 100644 index 5bfc329..0000000 --- a/org.glite.lb.client-interface/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Dec 09 04:51:55 CET 2004 -module.version=0.3.1 -module.build=112 -module.age=2 diff --git a/org.glite.lb.client/.cvsignore b/org.glite.lb.client/.cvsignore deleted file mode 100644 index 1df717b..0000000 --- a/org.glite.lb.client/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -.project -.cdtproject \ No newline at end of file diff --git a/org.glite.lb.client/LICENSE b/org.glite.lb.client/LICENSE deleted file mode 100644 index 259a91f..0000000 --- a/org.glite.lb.client/LICENSE +++ /dev/null @@ -1,69 +0,0 @@ -LICENSE file for EGEE Middleware -================================ - -Copyright (c) 2004 on behalf of the EU EGEE Project: -The European Organization for Nuclear Research (CERN), -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Datamat Spa, Italy -Centre National de la Recherche Scientifique (CNRS), France -CS Systeme d'Information (CSSI), France -Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden -Universiteit van Amsterdam (UvA), Netherlands -University of Helsinki (UH.HIP), Finlan -University of Bergen (UiB), Norway -Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. The end-user documentation included with the redistribution, if -any, must include the following acknowledgment: "This product includes -software developed by The EU EGEE Project (http://cern.ch/eu-egee/)." -Alternatively, this acknowledgment may appear in the software itself, if -and wherever such third-party acknowledgments normally appear. - -4. The names EGEE and the EU EGEE Project must not be -used to endorse or promote products derived from this software without -prior written permission. For written permission, please contact -. - -5. You are under no obligation whatsoever to provide anyone with any -bug fixes, patches, or upgrades to the features, functionality or -performance of the Software ("Enhancements") that you may develop over -time; however, if you choose to provide your Enhancements to The EU -EGEE Project, or if you choose to otherwise publish or distribute your -Enhancements, in source code form without contemporaneously requiring -end users of The EU EGEE Proejct to enter into a separate written license -agreement for such Enhancements, then you hereby grant The EU EGEE Project -a non-exclusive, royalty-free perpetual license to install, use, copy, -modify, prepare derivative works, incorporate into the EGEE Middleware -or any other computer software, distribute, and sublicense your -Enhancements or derivative works thereof, in binary and source code -form (if any), whether developed by The EU EGEE Project or third parties. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL PROJECT OR ITS CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This software consists of voluntary contributions made by many -individuals on behalf of the EU EGEE Prject. For more information on The -EU EGEE Project, please see http://cern.ch/eu-egee/. For more information on -EGEE Middleware, please see http://egee-jra1.web.cern.ch/egee-jra1/ - - diff --git a/org.glite.lb.client/Makefile b/org.glite.lb.client/Makefile deleted file mode 100644 index 6fd7a20..0000000 --- a/org.glite.lb.client/Makefile +++ /dev/null @@ -1,272 +0,0 @@ -# Default values -top_srcdir=. -builddir=build -top_builddir=${top_srcdir}/${builddir} -stagedir=. -distdir=. -globalprefix=glite -lbprefix=lb -package=glite-lb-client -version=0.0.0 -PREFIX=/opt/glite - -glite_location=/opt/glite -globus_prefix=/opt/globus -nothrflavour=gcc32 -thrflavour=gcc32pthr -expat_prefix=/opt/expat -ares_prefix=/opt/ares - -CC:=gcc -CXX:=g++ - --include Makefile.inc - - -VPATH=${top_srcdir}/src:${top_srcdir}/test:${top_srcdir}/examples -AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3 -GENSAM=${top_srcdir}/examples/gen_sample_job - -SUFFIXES = .T .l - -l_SRC = \ - chkpt.l \ - cleared.l \ - done.l \ - done_dag.l \ - done_subjob.l \ - ready.l \ - ready_dag.l \ - ready_subjob.l \ - running.l \ - running_dag.l \ - running_subjob.l \ - scheduled.l \ - scheduled_dag.l \ - scheduled_subjob.l \ - submitted.l \ - submitted_dag.l \ - submitted_subjob.l \ - waiting.l \ - waiting_dag.l \ - waiting_subjob.l \ - failed_dag.l \ - failed_subjob.l \ - aborted.l \ - cancelled.l - -sh_PROGS = $(l_SRC:.l=.sh) - - -DEBUG:=-g -O0 -Wall - -GLOBUSINC:= -I${globus_prefix}/include/${nothrflavour} -GLOBUSTHRINC:= -I${globus_prefix}/include/${thrflavour} - -CFLAGS:=${DEBUG} \ - -I${top_srcdir}/src -I${top_srcdir}/interface \ - -I${stagedir}/include \ - -I${glite_location}/include \ - -I${expat_prefix}/include \ - -I${ares_prefix}/include \ - ${COVERAGE_FLAGS} \ - -D_GNU_SOURCE - - -CXXFLAGS:=${CFLAGS} - -GLOBUS_LIBS:=-L${globus_prefix}/lib \ - -lglobus_common_${nothrflavour} \ - -lglobus_gssapi_gsi_${nothrflavour} \ - -GLOBUS_THRLIBS:=-L${globus_prefix}/lib \ - -lglobus_common_${thrflavour} \ - -lglobus_gssapi_gsi_${thrflavour} - -ifneq (${expat_prefix},/usr) - EXPAT_LIBS:=-L${expat_prefix}/lib -endif -EXPAT_LIBS := ${EXPAT_LIBS} -lexpat - -ARES_LIBS:=-L${ares_prefix}/lib \ - -lares - -EXT_LIB:= ${EXPAT_LIBS} \ - ${ARES_LIBS} - -TEST_LIBS:=-L${cppunit_prefix}/lib -lcppunit -TEST_INC:=-I${cppunit_prefix}/include - -LDFLAGS:=-L${stagedir}/lib \ - ${COVERAGE_FLAGS} - -COMPILE:=libtool --mode=compile ${CC} ${CFLAGS} -CXXCOMPILE:=libtool --mode=compile ${CXX} ${CXXFLAGS} -LINK:=libtool --mode=link ${CC} ${LDFLAGS} -LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} -INSTALL:=libtool --mode=install install - -LIBOBJS:=connection.o consumer.o notification.o prod_proto.o \ - producer.o uiwrap.o -FAKELIBOBJS:=consumer_fake.o producer_fake.o - -PLUSOBJS:=Event.o Job.o JobStatus.o Notification.o ServerConnection.o -PUB_HDRS:=CountRef.h Event.h JobJobStatus.h Notification.h ServerConnection.h \ - LoggingExceptions.h - -LIBTHROBJS:=${LIBOBJS:.o=.thr.o} -LIBLOBJS:=${LIBOBJS:.o=.lo} -LIBTHRLOBJS:=${LIBOBJS:.o=.thr.lo} - -PLUSTHROBJS:=${PLUSOBJS:.o=.thr.o} -PLUSLOBJS:=${PLUSOBJS:.o=.lo} -PLUSTHRLOBJS:=${PLUSOBJS:.o=.thr.lo} - -FAKELIBTHROBJS:=${FAKELIBOBJS:.o=.thr.o} -FAKELIBLOBJS:=${FAKELIBOBJS:.o=.lo} -FAKELIBTHRLOBJS:=${FAKELIBOBJS:.o=.thr.lo} - -LIB:=libglite_lb_client_${nothrflavour}.la -THRLIB:=libglite_lb_client_${thrflavour}.la -FAKELIB:=libglite_lb_client_fake_${nothrflavour}.la -FAKETHRLIB:=libglite_lb_client_fake_${thrflavour}.la - -PLUSLIB:=libglite_lb_clientpp_${nothrflavour}.la -THRPLUSLIB:=libglite_lb_clientpp_${thrflavour}.la - -TOOLS:=dump load purge -EXAMPLES:=log_usertag_proxy job_log job_reg feed_shark notify query_ext query_seq_code -FAKE_EXAMPLES:=job_log_fake - -version_info=-version-info `echo ${version} | cut -d. -f1,2 | tr . :` - -${LIB}: ${LIBOBJS} - ${LINK} ${version_info} -o $@ ${LIBLOBJS} -rpath ${glite_location}/lib -lglite_lb_common_${nothrflavour} - -${THRLIB}: ${LIBTHROBJS} - ${LINK} ${version_info} -o $@ ${LIBTHRLOBJS} -rpath ${glite_location}/lib -lglite_lb_common_${thrflavour} - -${FAKELIB}: ${FAKELIBOBJS} - ${LINK} ${version_info} -o $@ ${FAKELIBLOBJS} -rpath ${glite_location}/lib -lglite_lb_common_${nothrflavour} - -${FAKETHRLIB}: ${FAKELIBTHROBJS} - ${LINK} ${version_info} -o $@ ${FAKELIBTHRLOBJS} -rpath ${glite_location}/lib -lglite_lb_common_${thrflavour} - -${PLUSLIB}: ${PLUSOBJS} - ${LINK} ${version_info} -o $@ ${PLUSLOBJS} -rpath ${glite_location}/lib ${LIB} - -${THRPLUSLIB}: ${PLUSTHROBJS} - ${LINK} ${version_info} -o $@ ${PLUSTHRLOBJS} -rpath ${glite_location}/lib ${THRLIB} - -logevent: logevent.o args.o - ${LINK} -o $@ logevent.o args.o ${LIB} ${EXT_LIB} ${GLOBUS_LIBS} - -${TOOLS} ${EXAMPLES}: %: %.o - ${LINK} -o $@ $< ${LIB} ${EXT_LIB} ${GLOBUS_LIBS} - -${FAKE_EXAMPLES}: %: %.o ${FAKELIB} - ${LINK} -o $@ $< ${FAKELIB} ${TEST_LIBS} ${EXT_LIB} ${GLOBUS_LIBS} - -${TOOLS}: ${LIB} - -${FAKE_EXAMPLES:=.o}: %.o: %.cpp - ${COMPILE} ${GLOBUSINC} ${TEST_INC} -c $< -o $@ - -${PLUSOBJS}: %.o: %.cpp - ${CXXCOMPILE} ${GLOBUSINC} -c $< - -${PLUSTHROBJS}: %.thr.o: %.cpp - ${CXXCOMPILE} ${GLOBUSTHRINC} -o $@ -c $< - -${LIBOBJS} ${FAKELIBOBJS}: %.o: %.c - ${COMPILE} ${GLOBUSINC} -c $< - -${LIBTHROBJS} ${FAKELIBTHROBJS}: %.thr.o: %.c - ${COMPILE} ${GLOBUSTHRINC} -o $@ -c $< - -logevent_fake.o: logevent.c - ${COMPILE} ${GLOBUSINC} -c $< -o $@ - -# catches $TOOLS and logevent compilation -%.o: %.c - ${CC} ${CFLAGS} ${GLOBUSINC} -c $< - -%.c: %.c.T - rm -f $@ - ${AT3} $< >$@ || rm -f $@ - chmod -w $@ >/dev/null - -%.cpp: %.cpp.T - rm -f $@ - ${AT3} $< >$@ || rm -f $@ - chmod -w $@ >/dev/null - -%.sh: %.l gen_begin gen_sample_job - rm -f $@ - $(GENSAM) $< >$@ || rm -f $@ - chmod -w,+x $@ > /dev/null - -default: all - - -compile all: check_version ${LIB} ${THRLIB} ${TOOLS} logevent ${PLUSLIB} ${THRPLUSLIB} examples - -examples: ${EXAMPLES} ${sh_PROGS} - -fake: ${FAKE_EXAMPLES} - -check: compile check.producer - -check.producer: producer_test - ./producer_test - -producer_test: producer_test.o prod_proto_test.o - ${LINKXX} -o $@ ${LIB} ${TEST_LIBS} $+ ${EXT_LIB} ${GLOBUS_LIBS} - -producer_test.o: %.o: %.cpp - ${CXX} -c ${CXXFLAGS} ${TEST_INC} $< - -stage: compile ${FAKELIB} ${FAKETHRLIB} - $(MAKE) install PREFIX=${stagedir} - ${INSTALL} -m 644 ${FAKELIB} ${FAKETHRLIB} ${stagedir}/lib - -dist: distsrc distbin - -distsrc: - mkdir -p ${top_srcdir}/${package}-${version} - cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version} - cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version} - rm -rf ${top_srcdir}/${package}-${version} - -distbin: - $(MAKE) install PREFIX=`pwd`/tmpbuilddir${stagedir} - save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir - rm -rf tmpbuilddir - -install: - mkdir -p ${PREFIX}/bin - mkdir -p ${PREFIX}/lib - mkdir -p ${PREFIX}/share/doc/${package}-${version} - ${INSTALL} -m 644 ${LIB} ${THRLIB} ${PLUSLIB} ${THRPLUSLIB} ${PREFIX}/lib - ${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} - mkdir -p ${PREFIX}/examples - for p in ${TOOLS} logevent; do \ - ${INSTALL} -m 755 "$$p" "${PREFIX}/bin/glite-lb-$$p"; \ - done - for p in ${TOOLS} logevent ${EXAMPLES} ${sh_PROGS}; do \ - ${INSTALL} -m 755 "$$p" "${PREFIX}/examples/glite-lb-$$p"; \ - done - -clean: - -check_version: - @perl -ne '/#define GLITE_LB_CLIENT_INTERFACE "(\d+)\.\d+\.\d+"/; \ - $$iface=$$1; \ - $$_="${version}"; /(\d+)\.\d+\.\d+/; \ - if ($$iface != $$1) { \ - print "error: Major version of the interface ($$iface) does not match implementation ($$1)\n" ;\ - exit 1; \ - } \ - ' ${stagedir}/include/glite/lb/interface_version.h - -.PHONY: default all compile examples fake check stage dist distsrc distbin install clean check_version diff --git a/org.glite.lb.client/build.xml b/org.glite.lb.client/build.xml deleted file mode 100755 index df3de71..0000000 --- a/org.glite.lb.client/build.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.client/doc/README-fake b/org.glite.lb.client/doc/README-fake deleted file mode 100644 index 5a751ba..0000000 --- a/org.glite.lb.client/doc/README-fake +++ /dev/null @@ -1,126 +0,0 @@ -Fake library ------------- - -Fake library is a substitute library designed for usage in unit tests of -programs which use L&B. The library implements a subset of L&B client API. -Implemented functions are dummy in the sense that they do not produce any -sideefect and they do not require any running services. - -Main purpose of the library is WMS unit testing, so it should contain all L&B -function calls used in WMS. - -List of implemented functions: - - 1) consumer API - - edg_wll_QueryEvents - edg_wll_QueryListener - edg_wll_JobLog - edg_wll_QuerySequenceCode - - 2) producer API - - edg_wll_Log* (functions for logging all event types) - edg_wll_LogEvent - edg_wll_LogEventSync - edg_wll_LogEventProxy - edg_wll_LogFlush - edg_wll_LogFlushAll - edg_wll_SetLoggingJob - edg_wll_SetLoggingJobProxy - edg_wll_RegisterJobSync - edg_wll_RegisterJob - edg_wll_RegisterSubjob - edg_wll_RegisterSubjobs - edg_wll_ChangeACL - - -Function calls always try to return some meaningful data. However, for testing -purposes a fine control on the returned value is usually required (e.g. to -cover both success and failure of the called function). Therefore the library -enables to set function error codes and/or adjust returned data. This is done -via callbacks. Callbacks are activated right before function end when all -pre-set data are available. - -Callbacks must be registered before using the library call. It is possible to -have only one registered callback for each registration type at once (see -below). Callback registration is global, it IS NOT thread safe. Otherwise -the library is thread safe in the same way as standard L&B library -- -functions may be called by multiple threads simultaneously provided that -more threads do not operate on a single L&B context at the same time. - -The following code fragments represent an example of unit test of a function -calling e.g. edg_wll_LogMatch() - -#include "glite/lb/producer_fake.h" - -int fail_EAGAIN_callback(edg_wll_Context ctx) -{ - return edg_wll_SetError(ctx,EAGAIN,"failure reason"); -} - -unit_test() -{ - /* sucessfull logging, edg_wll_LogMatch() called from - * tested_function() returns OK */ - - tested_function(); - /* check results here */ - - /* failing with EAGAIN */ - edg_wll_RegisterTestLogging(fail_EAGAIN_callback); - tested_function(); - /* check results here */ -} - -The consumer API (QueryEvents, QueryListener) fake implementations -prepare some result set which is returned to the caller. The callback -function may also adjust this set for particular purposes of the unit test. - -List of the callbacks and registering functions: - - 1) cosumer API - - typedef int (edg_wll_QueryEvents_cb_f) - (edg_wll_Context context, edg_wll_Event **events); - typedef int (edg_wll_QueryListener_cb_f) - (edg_wll_Context context, char **host, uint16_t *port); - - int edg_wll_RegisterTestQueryEvents(edg_wll_QueryEvents_cb_f *cb); - int edg_wll_RegisterTestQueryListener(edg_wll_QueryListener_cb_f *cb); - - 2) producer API - - typedef int (edg_wll_Logging_cb_f)(edg_wll_Context context); - - int edg_wll_RegisterTestLogging(edg_wll_Logging_cb_f *cb); - int edg_wll_RegisterTestLoggingProxy(edg_wll_Logging_cb_f *cb); - - -It possible to unregister registered callbacks using following functions: - - void edg_wll_UnregisterTestQueryEvents(); - void edg_wll_UnregisterTestQueryListener(); - void edg_wll_UnregisterTestLogging(); - void edg_wll_UnregisterTestLoggingProxy(); - - -Library name is libglite_lb_client_fake_gcc32dbg[pthr].so. It is built -in the org.glite.lb.client module, staged (so that it is available -for WMS unit tests run during the build process) but currenlty -neither installed nor included in RPM. - -Unit test programs should linked with this library instead of the original -libglite_lb_client_gcc32dbg[pthr].so. You can find examples of fake library -usage in org.glite.lb.client. The Makefile target 'fake' builds these examples. -There is no ant equivalent, hence the following procedure is required: - - cd org.glite.lb.client - ant init - cd build - make fake - - -An example of unit test using the fake library is the file -examples/job_log_fake.cpp. There is showed how to use callbacks and their -registration. diff --git a/org.glite.lb.client/examples/aborted.l b/org.glite.lb.client/examples/aborted.l deleted file mode 100644 index 0f639c8..0000000 --- a/org.glite.lb.client/examples/aborted.l +++ /dev/null @@ -1,2 +0,0 @@ -:ready: --s JobController,-e Abort,--reason "just to test" diff --git a/org.glite.lb.client/examples/cancelled.l b/org.glite.lb.client/examples/cancelled.l deleted file mode 100644 index 1e0cc96..0000000 --- a/org.glite.lb.client/examples/cancelled.l +++ /dev/null @@ -1,2 +0,0 @@ -:running: --s LogMonitor, -e Done, --status_code=CANCELLED, --reason="reason for the change", --exit_code=0 diff --git a/org.glite.lb.client/examples/chkpt.l b/org.glite.lb.client/examples/chkpt.l deleted file mode 100644 index dbd7f23..0000000 --- a/org.glite.lb.client/examples/chkpt.l +++ /dev/null @@ -1,6 +0,0 @@ -# macro definition for DONE state - -:running: --s LRMS, -e Chkpt, --tag=chkpt1, --classad="" --s LRMS, -e Chkpt, --tag=chkpt2, --classad="" --s LogMonitor, -e Done, --status_code=OK, --reason="reason for the change", --exit_code=0 diff --git a/org.glite.lb.client/examples/cleared.l b/org.glite.lb.client/examples/cleared.l deleted file mode 100644 index 8b9f86c..0000000 --- a/org.glite.lb.client/examples/cleared.l +++ /dev/null @@ -1,4 +0,0 @@ -# macro definition for DONE state - -:done: --s LogMonitor, -e Clear, --reason=USER diff --git a/org.glite.lb.client/examples/consumer_fake.c b/org.glite.lb.client/examples/consumer_fake.c deleted file mode 100644 index 060d55d..0000000 --- a/org.glite.lb.client/examples/consumer_fake.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * fake implementation of the consumer API - */ - -#include -#include - -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/consumer_fake.h" - - -#define NUM_EVENTS 3 - - -static edg_wll_QueryEvents_cb_f *QueryEvents_cb = NULL; -static edg_wll_QueryListener_cb_f *QueryListener_cb = NULL; - - -/* register the query callback */ -int edg_wll_RegisterTestQueryEvents(edg_wll_QueryEvents_cb_f *cb) { - if (QueryEvents_cb) return 0; - - QueryEvents_cb = cb; - return 1; -} - - -/* register the listener callback */ -int edg_wll_RegisterTestQueryListener(edg_wll_QueryListener_cb_f *cb) { - if (QueryListener_cb) return 0; - - QueryListener_cb = cb; - return 1; -} - - -/* unregister the query callback */ -void edg_wll_UnregisterTestQueryEvents() { - QueryEvents_cb = NULL; -} - - -/* unregister the listener callback */ -void edg_wll_UnregisterTestQueryListener() { - QueryEvents_cb = NULL; -} - - -/* (belongs to common/src/events.c.T) */ -static void edg_wll_PrepareEvent(edg_wll_EventCode eventcode, edg_wll_Event *event) { - edg_wll_Event *tmpevent; - - // hide not clean code here :-) - tmpevent = edg_wll_InitEvent(eventcode); - memcpy(event, tmpevent, sizeof(edg_wll_Event)); - free(tmpevent); -} - - -/* fake implementation of QueryEvents() */ -int edg_wll_QueryEvents( - edg_wll_Context context, - const edg_wll_QueryRec *job_conditions, - const edg_wll_QueryRec *event_conditions, - edg_wll_Event **events -) { - edg_wll_EventCode event_code; - int i, j, err; - edg_wlc_JobId jobid; - - edg_wll_ResetError(context); - - // determine type of the returned events, ignore _QUERY_OP_*: - // - asked event type for _QUERY_ATTR_EVENT_TYPE - // - _EVENT_CHKPT for other - i = 0; - while (event_conditions[i].attr != EDG_WLL_QUERY_ATTR_UNDEF && (event_conditions[i].attr != EDG_WLL_QUERY_ATTR_EVENT_TYPE)) i++; - if (event_conditions[i].attr == EDG_WLL_QUERY_ATTR_UNDEF) - event_code = EDG_WLL_EVENT_CHKPT; - else - event_code = event_conditions[i].value.i; - - // create events - *events = calloc(NUM_EVENTS + 1, sizeof(edg_wll_Event)); - for (i = 0; i < NUM_EVENTS; i++) { - edg_wll_PrepareEvent(event_code, &(*events)[i]); - } - (*events)[NUM_EVENTS].type = EDG_WLL_EVENT_UNDEF; - - // adjust events according to the query parameters - i = 0; - while (job_conditions[i].attr != EDG_WLL_QUERY_ATTR_UNDEF) { - if (job_conditions[i].attr == EDG_WLL_QUERY_ATTR_JOBID && job_conditions[i].op == EDG_WLL_QUERY_OP_EQUAL) { - jobid = job_conditions[i].value.j; - for (j = 0; j < NUM_EVENTS; j++) { - if ((err = edg_wlc_JobIdDup(jobid, &(*events)[i].any.jobId)) != 0) goto error; - } - break; - } - i++; - } - - // adjusting callback - if (QueryEvents_cb) - QueryEvents_cb(context, events); - - if ((err = edg_wll_Error(context, NULL, NULL)) == 0) return 0; - -error: - i = 0; - while ((*events)[i].type != EDG_WLL_EVENT_UNDEF) { - edg_wll_FreeEvent(&(*events)[i]); - i++; - } - free(*events); - - return edg_wll_SetError(context, err, NULL); -} - - -/* fake implementation of QueryListener() */ -int edg_wll_QueryListener( - edg_wll_Context context, - edg_wlc_JobId jobId, - const char *name, - char **host, - uint16_t *port -) { - edg_wll_ResetError(context); - - if (QueryListener_cb) return QueryListener_cb(context, host, port); - else { - *host = strdup("localhost"); - *port = 12345; - - return edg_wll_Error(context, NULL, NULL); - } -} - - -/* cut'nd pasted from consumer.c */ -int edg_wll_JobLog( - edg_wll_Context ctx, - edg_wlc_JobId job, - edg_wll_Event **eventsOut) -{ - edg_wll_QueryRec j[2], e[2]; - - memset(j,0,sizeof j); - memset(e,0,sizeof e); - - j[0].attr = EDG_WLL_QUERY_ATTR_JOBID; - j[0].op = EDG_WLL_QUERY_OP_EQUAL; - j[0].value.j = job; - - e[0].attr = EDG_WLL_QUERY_ATTR_LEVEL; - e[0].op = EDG_WLL_QUERY_OP_LESS; - e[0].value.i = ctx->p_level + 1; - - return edg_wll_QueryEvents(ctx,j,e,eventsOut); -} diff --git a/org.glite.lb.client/examples/done.l b/org.glite.lb.client/examples/done.l deleted file mode 100644 index def8f34..0000000 --- a/org.glite.lb.client/examples/done.l +++ /dev/null @@ -1,4 +0,0 @@ -# macro definition for DONE state - -:running: --s LogMonitor, -e Done, --status_code=OK, --reason="reason for the change", --exit_code=0 diff --git a/org.glite.lb.client/examples/done_dag.l b/org.glite.lb.client/examples/done_dag.l deleted file mode 100644 index 5ac9033..0000000 --- a/org.glite.lb.client/examples/done_dag.l +++ /dev/null @@ -1,4 +0,0 @@ -# macro definition for DONE state - -:running_dag: --s LogMonitor, -e Done, --status_code=OK, --reason="reason for the change", --exit_code=0 diff --git a/org.glite.lb.client/examples/done_subjob.l b/org.glite.lb.client/examples/done_subjob.l deleted file mode 100644 index 883a367..0000000 --- a/org.glite.lb.client/examples/done_subjob.l +++ /dev/null @@ -1,4 +0,0 @@ -# macro definition for DONE state - -:running_subjob: --s LogMonitor, -e Done, --status_code=OK, --reason="reason for the change", --exit_code=0 diff --git a/org.glite.lb.client/examples/failed_dag.l b/org.glite.lb.client/examples/failed_dag.l deleted file mode 100644 index 023d5af..0000000 --- a/org.glite.lb.client/examples/failed_dag.l +++ /dev/null @@ -1,3 +0,0 @@ -:running_dag: - --s LogMonitor, -e Done, --status_code=Failed, --exit_code=1, --reason=shit diff --git a/org.glite.lb.client/examples/failed_subjob.l b/org.glite.lb.client/examples/failed_subjob.l deleted file mode 100644 index 9e1b6dc..0000000 --- a/org.glite.lb.client/examples/failed_subjob.l +++ /dev/null @@ -1,3 +0,0 @@ -:running_subjob: - --s LogMonitor, -e Done, --status_code=Failed, --exit_code=1, --reason=shit diff --git a/org.glite.lb.client/examples/feed_shark.c b/org.glite.lb.client/examples/feed_shark.c deleted file mode 100644 index 824e781..0000000 --- a/org.glite.lb.client/examples/feed_shark.c +++ /dev/null @@ -1,195 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/lb/notification.h" - -static void usage(const char *); -static void printstat(edg_wll_JobStat, int); - -int main(int argc,char *argv[]) -{ - int o; - edg_wll_Context ctx; - edg_wll_NotifId notif; - time_t valid = 0; - struct timeval timeout; - - edg_wll_InitContext(&ctx); - -/* parse options, reflect them in the LB context */ - while ((o = getopt(argc,argv,"s:")) >= 0) switch (o) { - case 's': { - char *server = strdup(optarg), - *port_s = strchr(server,':'); - - int port; - - if (port_s) { - *port_s = 0; - port = atoi(port_s+1); - } - - edg_wll_SetParam(ctx,EDG_WLL_PARAM_NOTIF_SERVER,server); - if (port_s) edg_wll_SetParam(ctx,EDG_WLL_PARAM_NOTIF_SERVER_PORT,port); - free(server); - } break; - - case '?': usage(argv[0]); exit(EX_USAGE); - } - -/* no notification Id supplied -- create a new one */ - if (argc == optind) { - edg_wll_QueryRec const *empty[] = { NULL }; - char *notif_s; - - if (edg_wll_NotifNew(ctx,empty,-1,NULL,¬if,&valid)) { - char *et,*ed; - - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"edg_wll_NotifNew(): %s (%s)\n",et,ed); - exit(EX_UNAVAILABLE); - } - - notif_s = edg_wll_NotifIdUnparse(notif); - printf("notification registered:\n\tId: %s\n\tExpires: %s", - notif_s,ctime(&valid)); - free(notif_s); - } -/* notification Id supplied -- bind to it */ - else if (argc == optind + 1) { - if (edg_wll_NotifIdParse(argv[optind],¬if)) { - fprintf(stderr,"%s: invalid notification Id\n", - argv[optind]); - exit(EX_DATAERR); - } - - if (edg_wll_NotifBind(ctx,notif,-1,NULL,&valid)) { - char *et,*ed; - - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"edg_wll_NotifBind(): %s (%s)\n",et,ed); - exit(EX_UNAVAILABLE); - } - printf("bound to %s\n\t Expires: %s",argv[optind],ctime(&valid)); - } - else { usage(argv[0]); exit(EX_USAGE); } - -/* main loop */ - while (1) { - edg_wll_JobStat stat; - char *et,*ed; - -/* calculate time left for this notification */ - gettimeofday(&timeout,NULL); - timeout.tv_sec = valid - timeout.tv_sec; - assert(timeout.tv_sec >= 0); /* XXX: hope we are no late */ - -/* half time before notification renewal */ - timeout.tv_sec /= 2; - - switch (edg_wll_NotifReceive(ctx,-1,&timeout,&stat,NULL)) { - case 0: /* OK, got it */ - printstat(stat,0); - edg_wll_FreeStatus(&stat); - break; - case EAGAIN: /* timeout */ - if (edg_wll_NotifRefresh(ctx,notif,&valid)) { - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"edg_wll_NotifRefresh(): %s (%s)\n",et,ed); - exit(EX_UNAVAILABLE); - } - printf("Notification refreshed, expires %s",ctime(&valid)); - break; - default: - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"edg_wll_NotifReceive(): %s (%s)\n",et,ed); - exit(EX_UNAVAILABLE); - } - } -} - - -static void usage(const char *me) -{ - fprintf(stderr,"usage: %s [ -s server[:port] ] [notif_id]\n",me); -} - - - -static void printstat(edg_wll_JobStat stat, int level) -{ - char *s, *j, ind[10]; - int i; - - - for (i=0; i < level; i++) - ind[i]='\t'; - ind[i]='\0'; - - s = edg_wll_StatToString(stat.state); -/* print whole flat structure */ - printf("%sstate : %s\n", ind, s); - printf("%sjobId : %s\n", ind, j = edg_wlc_JobIdUnparse(stat.jobId)); - printf("%sowner : %s\n", ind, stat.owner); - printf("%sjobtype : %s\n", ind, (stat.jobtype ? "DAG" : "SIMPLE") ); - printf("%sparent_job : %s\n", ind, - j = edg_wlc_JobIdUnparse(stat.parent_job)); - if (stat.jobtype) {; - printf("%sseed : %s\n", ind, stat.seed); - printf("%schildren_num : %d\n", ind, stat.children_num); - printf("%schildren :\n", ind); - if (stat.children) - for (i=0; stat.children[i]; i++) - printf("%s\tchildren : %s\n", ind, stat.children[i]); - printf("%schildren_states :\n", ind); - if (stat.children_states) - for (i=0; stat.children_states[i].state; i++) - printstat(stat.children_states[i], level+1); - printf("%schildren_hist :\n",ind); - if (stat.children_hist) - for (i=1; i<=stat.children_hist[0]; i++) - printf("%s%14s %d\n", ind, edg_wll_StatToString(i-1),stat.children_hist[i]); - } - printf("%scondorId : %s\n", ind, stat.condorId); - printf("%sglobusId : %s\n", ind, stat.globusId); - printf("%slocalId : %s\n", ind, stat.localId); - printf("%sjdl : %s\n", ind, stat.jdl); - printf("%smatched_jdl : %s\n", ind, stat.matched_jdl); - printf("%sdestination : %s\n", ind, stat.destination); - printf("%snetwork server : %s\n", ind, stat.network_server); - printf("%scondor_jdl : %s\n", ind, stat.condor_jdl); - printf("%srsl : %s\n", ind, stat.rsl); - printf("%sreason : %s\n", ind, stat.reason); - printf("%slocation : %s\n", ind, stat.location); - printf("%ssubjob_failed : %d\n", ind, stat.subjob_failed); - printf("%sdone_code : %d\n", ind, stat.done_code); - printf("%sexit_code : %d\n", ind, stat.exit_code); - printf("%sresubmitted : %d\n", ind, stat.resubmitted); - printf("%scancelling : %d\n", ind, stat.cancelling); - printf("%scancelReason : %s\n", ind, stat.cancelReason); - printf("%scpuTime : %d\n", ind, stat.cpuTime); - printf("%suser_tags :\n",ind); - if (stat.user_tags) - for (i=0; stat.user_tags[i].tag; i++) printf("%s%14s = \"%s\"\n", ind, - stat.user_tags[i].tag,stat.user_tags[i].value); - printf("%sstateEnterTime : %ld.%06ld\n", ind, stat.stateEnterTime.tv_sec,stat.stateEnterTime.tv_usec); - printf("%sstateEnterTimes : \n",ind); - if (stat.stateEnterTimes) - for (i=1; i<=stat.stateEnterTimes[0]; i++) - printf("%s%14s %s", ind, edg_wll_StatToString(i-1), (stat.stateEnterTimes[i] == 0) ? - " - not available -\n" : ctime((time_t *) &stat.stateEnterTimes[i])); - printf("%slastUpdateTime : %ld.%06ld\n", ind, stat.lastUpdateTime.tv_sec,stat.lastUpdateTime.tv_usec); - printf("%sexpectUpdate : %d\n", ind, stat.expectUpdate); - printf("%sexpectFrom : %s\n", ind, stat.expectFrom); - printf("%sacl : %s\n", ind, stat.acl); - printf("\n"); - - free(j); - free(s); -} diff --git a/org.glite.lb.client/examples/gen_begin b/org.glite.lb.client/examples/gen_begin deleted file mode 100755 index a7565a4..0000000 --- a/org.glite.lb.client/examples/gen_begin +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -# script for generating sample jobs - -if test ! -z "$FAKE"; then - SUFFIX="_fake" -fi -LOGFD=${LOGFD:-2} -LOGEV=glite-lb-logevent${SUFFIX} -JOB_REG=${JOB_REG:-`dirname $0`/glite-lb-job_reg}${SUFFIX} -EDG_JOBID= - -usage() -{ - echo "Usage : $0 [-m bkserver_machine_name][-j job_id]" - exit 4 -} - -# read parameters -while test -n "$1" -do - case "$1" in - "-m") shift; BKSERVER_HOST="$1" ;; - "-j") shift; EDG_JOBID="$1" ;; - "*") usage ;; - esac - shift -done - -test \( -z "$BKSERVER_HOST" \) -a \( -z "$EDG_JOBID" \) && usage - -if [ -z "$EDG_JOBID" ] -then - # initial sequence code & jobid (normaly returned by job_reg) - EDG_JOBID= - SCRIPT=`$JOB_REG -m $BKSERVER_HOST -s UserInterface | tail -n 2` - eval $SCRIPT - test -z "$EDG_JOBID" && exit 4 - echo EDG_JOBID=$EDG_JOBID -else - test -z "$EDG_WL_SEQUENCE" && EDG_WL_SEQUENCE="UI=000003:NS=0000000000:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000" -fi - -send_log_ev() -{ - echo $LOGEV -j "$EDG_JOBID" -c "$EDG_WL_SEQUENCE" "$@" 1>&$LOGFD - EDG_WL_SEQUENCE=`$LOGEV -j $EDG_JOBID -c $EDG_WL_SEQUENCE "$@" 2>/dev/null` - test $? -ne 0 -o -z "$EDG_WL_SEQUENCE" && exit 4 - true -} - diff --git a/org.glite.lb.client/examples/gen_sample_job b/org.glite.lb.client/examples/gen_sample_job deleted file mode 100755 index cc9dfac..0000000 --- a/org.glite.lb.client/examples/gen_sample_job +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/sh - -me=$0 -mydir=`dirname $0`; -export me mydir - - -set -- `getopt n $*` -# test whether it is recursive call - -NESTED="-v nested=0" -while [ $1 != '--' ]; do case $1 in - -n) NESTED="-v nested=1"; shift ;; -esac; done -shift - -awk -F, $NESTED \ -'BEGIN { - if (nested==0) system("cat $mydir/gen_begin"); - OFS = ","; - nlines = 0; -} -/^#/ || /^[ ]*$/ { next; } -{ - source = $2; - - event = $1; - - nline++; -} -# events processing - -/-e Transfer/ { logit(); - next;} - -/-e Accepted/ { if (checkNOP(7) == 0) logit(); - next;} - -/-e Refused/ { if (checkNOP(6) == 0) logit(); - next;} - -/-e EnQueued/ { if (checkNOP(6) == 0) logit(); - next;} - -/-e DeQueued/ { if (checkNOP(4) == 0) logit(); - next;} - -/-e HelperCall/ { if (checkNOP(5) == 0) logit(); - next;} - -/-e HelperReturn/ { if (checkNOP(5) == 0) logit(); - next;} - -/-e Running/ { if (checkNOP(3) == 0) logit(); - next;} - -/-e Resubmission/ { if (checkNOP(5) == 0) logit(); - next;} - -/-e Done/ { if (checkNOP(5) == 0) logit(); - next;} - -/-e Cancel/ { if (checkNOP(4) == 0) logit(); - next;} - -/-e Abort/ { if (checkNOP(3) == 0) logit(); - next;} - -/-e Clear/ { if (checkNOP(3) == 0) logit(); - next;} - -/-e Purge/ { if (checkNOP(2) == 0) logit(); - next;} - -/-e Match/ { if (checkNOP(3) == 0) logit(); - next;} - -/-e Pending/ { if (checkNOP(3) == 0) logit(); - next;} - -/-e RegJob/ { if (checkNOP(7) == 0) logit(); - next;} - -/-e Chkpt/ { if (checkNOP(4) == 0) logit(); - next;} - -/-e Listener/ { if (checkNOP(5) == 0) logit(); - next;} - -/-e CurDescr/ { if (checkNOP(3) == 0) logit(); - next;} - -/-e UserTag/ { if (checkNOP(4) == 0) logit(); - next;} - - -# macro processing - macro name starts and ends with ':' -# in a file gen_MACRONAME.txt is the macro describtion - -/^:.*:$/ {system("$me -n $mydir/"substr($1,2,(length($1) - 2))".l" )} - - -function checkNOP(NOP) -{ - if (NF != NOP) { print nline" : "$2": "NOP" args required ("NF" supplied)" > "/dev/stderr"; return 1 } - else return 0; -} - -function logit() -{ - split($0,f); - - ff = ""; - for (i=1; i<=NF; i++) ff = ff " " f[i]; - - print "send_log_ev" ff; -} -' $1 - diff --git a/org.glite.lb.client/examples/job_log.c b/org.glite.lb.client/examples/job_log.c deleted file mode 100644 index ca1c09e..0000000 --- a/org.glite.lb.client/examples/job_log.c +++ /dev/null @@ -1,142 +0,0 @@ -#ident "$Header$" - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include - -#include "glite/lb/events_parse.h" -#include "glite/lb/consumer.h" -#include "glite/wmsutils/jobid/cjobid.h" -#ifdef USE_CALLBACKS - #include "glite/lb/consumer_fake.h" -#endif - -static void free_events(edg_wll_Event *); - -static void help(const char* n) -{ - fprintf(stderr,"usage: %s [-r repeat] [-d delay] \n", n); - exit(1); -} - -#ifdef USE_CALLBACKS -static int query_events_cb(edg_wll_Context context, edg_wll_Event **events) { - int i; - edg_wll_Event *event; - - i = 0; - while ((event = (*events) + i)->type != EDG_WLL_EVENT_UNDEF) { - event->any.timestamp.tv_sec = (double)rand() / RAND_MAX * 1000000000; - event->any.timestamp.tv_usec = (double)rand() / RAND_MAX * 1000000; - i++; - } - - return 0; -} -#endif - -int main(int argc,char **argv) -{ - edg_wll_Context ctx; - char *errt,*errd; - edg_wll_Event *events; - edg_wlc_JobId job; - int i,opt,delay = 1,count = 0; - - if (argc < 2) - help(argv[0]); - - while ((opt=getopt(argc,argv,"r:d:")) != -1) - switch (opt) { - case 'd': delay = atoi(optarg); break; - case 'r': count = atoi(optarg); break; - default: - help(argv[0]); - } - - edg_wll_InitContext(&ctx); - if (edg_wlc_JobIdParse(argv[optind],&job)) { - fprintf(stderr,"%s: can't parse job ID\n",argv[1]); - return 1; - } - -#ifdef USE_CALLBACKS - edg_wll_RegisterTestQueryEvents(query_events_cb); -#endif - - if ( edg_wll_JobLog(ctx,job,&events) ) - { - if ( edg_wll_Error(ctx, &errt, &errd) != E2BIG ) - goto err; - - fprintf(stderr,"%s: %s (%s)\n",argv[0],errt,errd); - } - - for ( i = 0; events[i].type != EDG_WLL_EVENT_UNDEF; i++ ) - { - char *e = edg_wll_UnparseEvent(ctx,events+i); - fputs(e,stdout); - fputs("\n",stdout); - free(e); - } - - free_events(events); - printf("\nFound %d events\n",i); - - while (count--) { - puts("Sleeping ..."); - sleep(delay); - if (edg_wll_JobLog(ctx,job,&events)) { - edg_wll_Error(ctx,&errt,&errd); - fprintf(stderr,"%s: %s (%s)\n",argv[0],errt,errd); - free(errt); free(errd); errt = errd = NULL; - free_events(events); - } - else puts("OK"); - } - - edg_wlc_JobIdFree(job); - edg_wll_FreeContext(ctx); - -#ifdef USE_CALLBACKS - edg_wll_UnregisterTestQueryEvents(); -#endif - - return 0; - -err: -#ifdef USE_CALLBACKS - edg_wll_UnregisterTestQueryEvents(); -#endif - switch (edg_wll_Error(ctx,&errt,&errd)) { - case 0: break; - case ENOENT: - puts("No events found"); - break; - default: - fprintf(stderr,"%s: %s (%s)\n",argv[0],errt,errd); - return 1; - } - - edg_wlc_JobIdFree(job); - edg_wll_FreeContext(ctx); - - return 0; -} - -static void free_events(edg_wll_Event *events) -{ - int i; - - if (events) { - for (i=0; events[i].type != EDG_WLL_EVENT_UNDEF; i++) edg_wll_FreeEvent(&(events[i])); - edg_wll_FreeEvent(&(events[i])); /* free last line */ - free(events); - events = NULL; - } -} diff --git a/org.glite.lb.client/examples/job_reg.c b/org.glite.lb.client/examples/job_reg.c deleted file mode 100644 index 2106786..0000000 --- a/org.glite.lb.client/examples/job_reg.c +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/producer.h" -#include "glite/lb/events.h" - -extern char *optarg; -extern int opterr,optind; - -static void usage(char *me) -{ - fprintf(stderr,"usage: %s [-m bkserver] [-j dg_jobid] [-s source_id] [-n num_subjobs [-S]]\n", me); -} - -int main(int argc, char *argv[]) -{ - char *src = NULL,*job = NULL,*server = NULL,*seq; - int done = 0,num_subjobs = 0,i; - int reg_subjobs = 0; - edg_wll_Context ctx; - edg_wlc_JobId jobid,*subjobs; - - - edg_wll_InitContext(&ctx); - opterr = 0; - - do { - switch (getopt(argc,argv,"Sj:s:n:m:")) { - case 's': src = (char *) strdup(optarg); break; - case 'j': job = (char *) strdup(optarg); break; - case 'm': server = strdup(optarg); break; - case 'n': num_subjobs = atoi(optarg); break; - case 'S': if (num_subjobs>0) { reg_subjobs = 1; break; } - case '?': usage(argv[0]); exit(EINVAL); - case -1: done = 1; break; - } - } while (!done); - - if (!job && !server) { - fprintf(stderr,"%s: either -m server or -j jobid has to be specified\n",argv[0]); - exit(1); - } - - if (!src) { - fprintf(stderr,"%s: -s required\n",argv[0]); - exit(1); - } - - if (!job) { - char *p = strchr(server,':'); - if (p) *p=0; - edg_wlc_JobIdCreate(server,p?atoi(p+1):0,&jobid); - job = edg_wlc_JobIdUnparse(jobid); - printf("new jobid: %s\n",job); - } - else if ((errno = edg_wlc_JobIdParse(job,&jobid))) { - perror(job); - exit(1); - } - - edg_wll_SetParam(ctx,EDG_WLL_PARAM_SOURCE,edg_wll_StringToSource(src)); - if (edg_wll_RegisterJobSync(ctx,jobid, - num_subjobs?EDG_WLL_REGJOB_DAG:EDG_WLL_REGJOB_SIMPLE, - "blabla", "NNNSSSS", - num_subjobs,NULL,&subjobs)) - { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"edg_wll_RegisterJobSync(%s): %s (%s)\n",job,et,ed); - exit(1); - } - - seq = edg_wll_GetSequenceCode(ctx); - printf("\n%s=\"%s\"\n",num_subjobs?"EDG_WL_DAG_JOBID":"EDG_JOBID",job); - printf("EDG_WL_SEQUENCE=\"%s\"\n",seq); - free(seq); - free(job); - - if (num_subjobs) for (i=0; subjobs[i]; i++) { - char *job_s = edg_wlc_JobIdUnparse(subjobs[i]); - printf("EDG_WL_SUB_JOBID[%d]=\"%s\"\n",i,job_s); - free(job_s); - } - - if (reg_subjobs) { - char ** jdls = (char**) malloc(num_subjobs*sizeof(char*)); - - for (i=0; subjobs[i]; i++) { - asprintf(jdls+i, "JDL of subjob #%d\n", i+1); - } - - if (edg_wll_RegisterSubjobs(ctx, jobid, (const char **) jdls, NULL, subjobs)) { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"edg_wll_RegisterSubjobs: %s (%s)\n", et, ed); - exit(1); - } - - for (i=0; subjobs[i]; i++) free(jdls[i]); - } - - edg_wll_FreeContext(ctx); - - return 0; -} diff --git a/org.glite.lb.client/examples/log_usertag_proxy.c b/org.glite.lb.client/examples/log_usertag_proxy.c deleted file mode 100644 index 7891893..0000000 --- a/org.glite.lb.client/examples/log_usertag_proxy.c +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/notifid.h" -#include "glite/lb/producer.h" -#include "glite/lb/events.h" - - -static struct option opts[] = { - {"help", 0, NULL, 'h'}, - {"sock", 1, NULL, 's'}, - {"jobid", 1, NULL, 'j'}, - {"seq", 1, NULL, 'c'}, - {"name", 1, NULL, 'n'}, - {"value", 1, NULL, 'v'} -}; - -static void usage(char *me) -{ - fprintf(stderr, "usage: %s [option]\n" - "\t-h, --help Shows this screen.\n" - "\t-s, --server LB Proxy socket.\n" - "\t-j, --jobid ID of requested job.\n" - "\t-c, --seq Sequence code.\n" - "\t-n, --name Name of the tag.\n" - "\t-v, --value Value of the tag.\n" - , me); -} - - -int main(int argc, char *argv[]) -{ - edg_wll_Context ctx; - edg_wlc_JobId jobid = NULL; - char *server, *code, *jobid_s, *name, *value; - int opt, err = 0; - - - server = code = jobid_s = name = value = NULL; - while ( (opt = getopt_long(argc, argv, "hs:j:c:n:v:", opts, NULL)) != EOF) - switch (opt) { - case 'h': usage(name); return 0; - case 's': server = strdup(optarg); break; - case 'j': jobid_s = strdup(optarg); break; - case 'c': code = strdup(optarg); break; - case 'n': name = strdup(optarg); break; - case 'v': value = strdup(optarg); break; - case '?': usage(name); return 1; - } - - if ( !jobid_s ) { fprintf(stderr, "JobId not given\n"); return 1; } - if ( !code ) { fprintf(stderr, "Sequence code not given\n"); return 1; } - if ( !server ) { fprintf(stderr, "LB proxy socket not given\n"); return 1; } - if ( !name ) { fprintf(stderr, "Tag name not given\n"); return 1; } - if ( !value ) { fprintf(stderr, "Tag value not given\n"); return 1; } - - if ( (errno = edg_wlc_JobIdParse(jobid_s, &jobid)) ) { perror(jobid_s); return 1; } - - if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { - fprintf(stderr, "Cannot initialize Globus common module\n"); - exit(1); - } - - edg_wll_InitContext(&ctx); - - edg_wll_SetParam(ctx, EDG_WLL_PARAM_SOURCE, EDG_WLL_SOURCE_USER_INTERFACE); - edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_STORE_SOCK, server); - - if (edg_wll_SetLoggingJob(ctx, jobid, code, EDG_WLL_SEQ_NORMAL)) { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"SetLoggingJob(%s,%s): %s (%s)\n",jobid_s,code,et,ed); - exit(1); - } - - err = edg_wll_LogEventProxy(ctx, - EDG_WLL_EVENT_USERTAG, EDG_WLL_FORMAT_USERTAG, - name, value); - - if (err) { - char *et,*ed; - - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"%s: edg_wll_LogEvent*(): %s (%s)\n", - argv[0],et,ed); - free(et); free(ed); - } - - code = edg_wll_GetSequenceCode(ctx); - puts(code); - free(code); - - edg_wll_FreeContext(ctx); - - return err; -} diff --git a/org.glite.lb.client/examples/notify.c b/org.glite.lb.client/examples/notify.c deleted file mode 100644 index 54670f9..0000000 --- a/org.glite.lb.client/examples/notify.c +++ /dev/null @@ -1,363 +0,0 @@ -#include -#include -#include -#include -#include - -#include "glite/lb/context.h" -#include "glite/lb/lb_gss.h" -#include "glite/lb/notification.h" - - -static char *me; - -static char tbuf[256]; - -char *TimeToStr(time_t t) -{ - struct tm *tm = gmtime(&t); - - sprintf(tbuf,"'%4d-%02d-%02d %02d:%02d:%02d'", - tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, - tm->tm_hour,tm->tm_min,tm->tm_sec); - - return tbuf; -} - -static void usage(char *cmd) -{ - if ( !cmd ) - { - printf("usage: %s command [options]\n" - " where commands are:\n" - " new Create new notification reg.\n" - " bind Binds an notification reg. to a client.\n" - " change Changes notification reg. params.\n" - " refresh Enlarge notification reg. validity.\n" - " receive Binds to an existing notif. registration and listen to server.\n" - " test Creates new notif., waits for events and drops notif. after timeout.\n" - " drop Drop the notification reg.\n" - " help Prints this message\n", - me); - } - if ( !cmd || !strcmp(cmd, "new") ) - printf("\n'new' command usage: %s new jobid\n" - " jobid job ID to connect notif. reg. with\n", me); - if ( !cmd || !strcmp(cmd, "bind") ) - printf("\n'bind' command usage: %s bind notifid [fake_addr]\n" - " notifid Notification ID\n" - " fake_addr Fake the client address\n", me); - if ( !cmd || !strcmp(cmd, "change") ) - printf("\n'change' command usage: %s change notifid jobid\n" - " notifid Notification ID.\n" - " jobid Job ID to connect notif. reg. with.\n", me); - if ( !cmd || !strcmp(cmd, "refresh") ) - printf("\n'refresh' command usage: %s refresh notifid\n" - " notifid Notification ID.\n", me); - if ( !cmd || !strcmp(cmd, "receive") ) - printf("\n'receive' command usage: %s receive notifid [-a fake_addr] [-t timeout]\n" - " notifid Notification ID.\n" - " fake_addr Fake the client address.\n" - " timeout Timeout to receive operation in seconds.\n", me); - if ( !cmd || !strcmp(cmd, "test") ) - printf("\n'new' command usage: %s test jobid\n" - " jobid job ID to connect notif. reg. with\n", me); - if ( !cmd || !strcmp(cmd, "drop") ) - printf("\n'drop' command usage: %s drop notifid\n" - " notifid Notification to remove.\n", me); -} - -int main(int argc,char **argv) -{ - edg_wll_Context ctx; - edg_wll_QueryRec **conditions = NULL; - time_t valid; - char *errt, *errd; - struct timeval tout = {220, 0}; - - - - me = argv[0]; - edg_wll_InitContext(&ctx); - - if ( argc < 2 ) { - usage(NULL); goto cleanup; - } - if ( (argc < 2) || !strcmp(argv[1], "help") ) { - usage(NULL); goto cleanup; - } - else if ( !strcmp(argv[1], "test") ) { - edg_wll_NotifId nid = NULL; - edg_wlc_JobId jid = NULL; - edg_wll_JobStat stat; - - if ( (argc < 3) || edg_wlc_JobIdParse(argv[2], &jid) ) { - printf("Job ID parameter not set propperly!\n"); - usage("new"); - goto cleanup; - } - - memset(&stat, 0, sizeof(stat)); - - conditions = (edg_wll_QueryRec **)calloc(2,sizeof(edg_wll_QueryRec *)); - conditions[0] = (edg_wll_QueryRec *)calloc(2,sizeof(edg_wll_QueryRec)); - - conditions[0][0].attr = EDG_WLL_QUERY_ATTR_JOBID; - conditions[0][0].op = EDG_WLL_QUERY_OP_EQUAL; - conditions[0][0].value.j = jid; - - - if ( edg_wll_NotifNew(ctx, - (edg_wll_QueryRec const* const*)conditions, - -1, NULL, - &nid, &valid)) goto err; - - printf("notification ID: %s\nvalid: %s (%ld)\n", - edg_wll_NotifIdUnparse(nid), - TimeToStr(valid), - valid); - - do { - edg_wll_NotifId recv_nid = NULL; - - printf("waiting...\n"); - if ( edg_wll_NotifReceive(ctx, -1, &tout, &stat, &recv_nid) ) { - edg_wll_NotifIdFree(recv_nid); - printf("timeout\n"); - break; - } - - printf("Notification received:\n"); - printf(" - notification ID: %s\n", edg_wll_NotifIdUnparse(recv_nid)); - printf(" - job ID: %s\n", edg_wlc_JobIdUnparse(stat.jobId)); - - if (stat.state != EDG_WLL_JOB_UNDEF) { - printf(" - job status is: %s\n\n", edg_wll_StatToString(stat.state)); - edg_wll_FreeStatus(&stat); - stat.state = EDG_WLL_JOB_UNDEF; - } - if (recv_nid) { edg_wll_NotifIdFree(recv_nid); recv_nid = NULL; } - } while (1); // till timeout.... -err: - if (nid) { - edg_wll_NotifDrop(ctx, nid); - edg_wll_NotifIdFree(nid); - edg_wll_NotifCloseFd(ctx); - } - if (stat.state != EDG_WLL_JOB_UNDEF) edg_wll_FreeStatus(&stat); - if (jid) edg_wlc_JobIdFree(jid); - } - else if ( !strcmp(argv[1], "new") ) - { - edg_wlc_JobId jid; - edg_wll_NotifId id_out; - - if ( (argc < 3) || edg_wlc_JobIdParse(argv[2], &jid) ) { - printf("Job ID parameter not set propperly!\n"); - usage("new"); - goto cleanup; - } - - conditions = (edg_wll_QueryRec **)calloc(2,sizeof(edg_wll_QueryRec *)); - conditions[0] = (edg_wll_QueryRec *)calloc(2,sizeof(edg_wll_QueryRec)); - - conditions[0][0].attr = EDG_WLL_QUERY_ATTR_JOBID; - conditions[0][0].op = EDG_WLL_QUERY_OP_EQUAL; - conditions[0][0].value.j = jid; - - if ( !edg_wll_NotifNew(ctx, - (edg_wll_QueryRec const* const*)conditions, - -1, NULL, &id_out, &valid)) - printf("notification ID: %s\nvalid: %s (%ld)\n", - edg_wll_NotifIdUnparse(id_out), - TimeToStr(valid), - valid); - edg_wll_NotifIdFree(id_out); - edg_wlc_JobIdFree(jid); - } - else if ( !strcmp(argv[1], "bind") ) - { - edg_wll_NotifId nid; - - if ( (argc < 3) || edg_wll_NotifIdParse(argv[2], &nid) ) - { - printf("Notification ID parameter not set propperly!\n"); - usage("bind"); - return 1; - } - if ( !edg_wll_NotifBind(ctx, nid, -1, (argc<4)? NULL: argv[3], &valid) ) - printf("valid until: %s (%ld)\n", TimeToStr(valid), valid); - edg_wll_NotifIdFree(nid); - } - else if ( !strcmp(argv[1], "receive") ) - { - edg_wll_JobStat stat; - edg_wll_NotifId nid = NULL; - char *addr = NULL; - int i; - - if ( (argc < 3) || edg_wll_NotifIdParse(argv[2], &nid) ) - { - printf("Notification ID parameter not set propperly!\n"); - usage("receive"); - return 1; - } - - for ( i = 3; i < argc; i++ ) - { - if ( !strcmp(argv[i], "-t") ) - { - if ( argc < i+1 ) - { - printf("Timeout value not set\n"); - usage("receive"); - return 1; - } - tout.tv_sec = atoi(argv[++i]); - } - else if ( !strcmp(argv[i], "-a") ) - { - if ( argc < i+1 ) - { - printf("Address value not set\n"); - usage("receive"); - return 1; - } - addr = strdup(argv[++i]); - } - else - { - printf("unrecognized option: %s\n", argv[i]); - usage("receive"); - return 1; - } - } - - memset(&stat,0,sizeof stat); - - if ( edg_wll_NotifBind(ctx, nid, -1, addr, &valid) ) - goto receive_err; - - printf("notification is valid until: %s (%ld)\n", TimeToStr(valid), valid); - - do { - edg_wll_NotifId recv_nid = NULL; - - if ( edg_wll_NotifReceive(ctx, -1, &tout, &stat, &recv_nid) ) { - edg_wll_NotifIdFree(recv_nid); - break; - } - - printf("\nnotification ID: %s\n", edg_wll_NotifIdUnparse(recv_nid)); - - if (stat.state != EDG_WLL_JOB_UNDEF) { - printf("Job status is : %s\n", - edg_wll_StatToString(stat.state)); - edg_wll_FreeStatus(&stat); - stat.state = EDG_WLL_JOB_UNDEF; - } - - if (recv_nid) { - edg_wll_NotifIdFree(recv_nid); - recv_nid = NULL; - } - } while (1); // till timeout.... - -receive_err: - if (addr) free(addr); - if (stat.state != EDG_WLL_JOB_UNDEF) edg_wll_FreeStatus(&stat); - if (nid) edg_wll_NotifIdFree(nid); - edg_wll_NotifCloseFd(ctx); - } - else if ( !strcmp(argv[1], "change") ) - { - edg_wlc_JobId jid; - edg_wll_NotifId nid; - - if ( (argc < 3) || edg_wll_NotifIdParse(argv[2], &nid) ) - { - printf("Notification ID parameter not set propperly!\n"); - usage("bind"); - return 1; - } - if ( (argc < 4) || edg_wlc_JobIdParse(argv[3], &jid) ) - { - printf("Job ID parameter not set propperly!\n"); - usage("change"); - goto cleanup; - } - - conditions = (edg_wll_QueryRec **)calloc(3,sizeof(edg_wll_QueryRec *)); - conditions[0] = (edg_wll_QueryRec *)calloc(2,sizeof(edg_wll_QueryRec)); - conditions[1] = (edg_wll_QueryRec *)calloc(3, sizeof(edg_wll_QueryRec)); - - conditions[0][0].attr = EDG_WLL_QUERY_ATTR_JOBID; - conditions[0][0].op = EDG_WLL_QUERY_OP_EQUAL; - conditions[0][0].value.j = jid; - - conditions[1][0].attr = EDG_WLL_QUERY_ATTR_STATUS; - conditions[1][0].op = EDG_WLL_QUERY_OP_EQUAL; - conditions[1][0].value.i = EDG_WLL_JOB_DONE; - - conditions[1][1].attr = EDG_WLL_QUERY_ATTR_STATUS; - conditions[1][1].op = EDG_WLL_QUERY_OP_EQUAL; - conditions[1][1].value.i = EDG_WLL_JOB_RUNNING; - - edg_wll_NotifChange(ctx, nid, - (edg_wll_QueryRec const * const *) conditions, - EDG_WLL_NOTIF_REPLACE); - edg_wlc_JobIdFree(jid); - edg_wll_NotifIdFree(nid); - } - else if ( !strcmp(argv[1], "refresh") ) - { - edg_wll_NotifId nid; - - if ( (argc < 3) || edg_wll_NotifIdParse(argv[2], &nid) ) - { - printf("Notification ID parameter not set propperly!\n"); - usage("bind"); - return 1; - } - if ( !edg_wll_NotifRefresh(ctx, nid, &valid) ) - printf("valid until: %s (%ld)\n", TimeToStr(valid), valid); - edg_wll_NotifIdFree(nid); - } - else if ( !strcmp(argv[1], "drop") ) - { - edg_wll_NotifId nid; - - if ( (argc < 3) || edg_wll_NotifIdParse(argv[2], &nid) ) - { - printf("Notification ID parameter not set propperly!\n"); - usage("bind"); - return 1; - } - edg_wll_NotifDrop(ctx, nid); - edg_wll_NotifIdFree(nid); - } - else - printf("bad acction\n"); - - -cleanup: - - if ( conditions ) - { - /* - for ( i = 0; conditions[i][0].attr; i++ ) - free(conditions[1]); - */ - free(conditions); - } - - edg_wll_NotifCloseFd(ctx); - - if (edg_wll_Error(ctx,&errt,&errd)) - fprintf(stderr, "%s: %s (%s)\n", me, errt, errd); - - edg_wll_FreeContext(ctx); - - - return 0; -} diff --git a/org.glite.lb.client/examples/producer_fake.c b/org.glite.lb.client/examples/producer_fake.c deleted file mode 100644 index 4d2ea58..0000000 --- a/org.glite.lb.client/examples/producer_fake.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * fake implementation of the producer API - */ - -#include "glite/lb/producer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/producer_fake.h" - -#define FAKE_VERSION 1 - -#include "../src/producer.c" - - -static edg_wll_Logging_cb_f *Logging_cb = NULL; -static edg_wll_Logging_cb_f *LoggingProxy_cb = NULL; - - -/* register the logging callback */ -int edg_wll_RegisterTestLogging(edg_wll_Logging_cb_f *cb) { - if (Logging_cb) return 0; - - Logging_cb = cb; - return 1; -} - - -/* register the proxy logging callback */ -int edg_wll_RegisterTestLoggingProxy(edg_wll_Logging_cb_f *cb) { - if (LoggingProxy_cb) return 0; - - LoggingProxy_cb = cb; - return 1; -} - - -/* unregister the logging callback */ -void edg_wll_UnregisterTestLogging() { - Logging_cb = NULL; -} - - -/* unregister the proxy logging callback */ -void edg_wll_UnregisterTestLoggingProxy() { - LoggingProxy_cb = NULL; -} - - -/* "fake" implementation of function sending formated UML string */ -int edg_wll_DoLogEvent(edg_wll_Context context, edg_wll_LogLine logLine) { - if (Logging_cb) - return Logging_cb(context); - else - return edg_wll_Error(context, NULL, NULL); -} - - -/* "fake" implementation of function sending formated ULM string */ -int edg_wll_DoLogEventProxy(edg_wll_Context context, edg_wll_LogLine logline) { - if (Logging_cb) - return Logging_cb(context); - else - return edg_wll_Error(context, NULL, NULL); -} diff --git a/org.glite.lb.client/examples/query_ext.c b/org.glite.lb.client/examples/query_ext.c deleted file mode 100644 index 2e9dacf..0000000 --- a/org.glite.lb.client/examples/query_ext.c +++ /dev/null @@ -1,877 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/consumer.h" - -#define BUFF_LEN 1024 -#define MAX_AND_CONDS 20 - -enum -{ - PQRV_ERR, - PQRV_EOF, - PQRV_EMPTY_LINE, -}; - - -static void printstat(edg_wll_JobStat); -static int cond_parse(edg_wll_QueryRec ***, int); -static void dgerr(edg_wll_Context, char *); -static void free_QueryRec(edg_wll_QueryRec *qr); -static void printconds(edg_wll_QueryRec **); -static time_t StrToTime(char *t); -static char *TimeToStr(time_t t); - -static char *myname; -static FILE *fin; -static char buffer[BUFF_LEN+1], - tmps[500]; -static int query_jobs = 1; -#define query_events (!query_jobs) -static int query_lbproxy = 0; -#define query_bkserver (!query_lbproxy) -static int verbose = 0; - - -static void usage(void) -{ - fprintf(stderr, "Usage: %s [-hvs] [-i file]\n", myname); - fprintf(stderr, " -h show this help\n"); - fprintf(stderr, " -v increase verbosity level\n"); - fprintf(stderr, " -s results described verbosely (query jobs only)\n"); - fprintf(stderr, " -m server name\n"); - fprintf(stderr, " -i file input file (default is stdin)\n\n"); - fprintf(stderr, " -e query events (default is 'query jobs')\n"); - fprintf(stderr, " -P query the L&B Proxy server\n"); - fprintf(stderr, " -p L&B Proxy socket path\n"); - fprintf(stderr, " -r type returned results: limited | all | none\n\n"); - fprintf(stderr, " -J num jobs soft limit\n\n"); - fprintf(stderr, " -E num events soft limit (query events only)\n\n"); -} - -int main(int argc,char *argv[]) -{ - edg_wll_Context ctx; - edg_wll_QueryResults rslts = EDG_WLL_QUERYRES_UNDEF; - edg_wll_QueryRec **jc = NULL, - **ec = NULL; - edg_wll_JobStat *statesOut = NULL; - edg_wlc_JobId *jobsOut = NULL; - edg_wll_Event *eventsOut = NULL; - char *fname = NULL, - *server = NULL, - *proxy_sock = NULL, - *s; - int result = 0, - jobsLimit = 0, - stdisp = 0, - eventsLimit = 0, - i, j, ret, - errCode; - - myname = argv[0]; - ret = 0; - do { - switch ( getopt(argc,argv,"hvsePp:i:m:r:J:E:") ) { - case 'h': usage(); exit(0); - case '?': usage(); exit(EINVAL); - case 'v': verbose = 1; break; - case 'i': fname = strdup(optarg); break; - case 'm': server = strdup(optarg); break; - case 's': stdisp = 1; break; - case 'e': query_jobs = 0; break; - case 'P': query_lbproxy = 1; break; - case 'p': proxy_sock = strdup(optarg); break; - case 'r': - if ( !strcasecmp(optarg, "limited") ) rslts = EDG_WLL_QUERYRES_LIMITED; - else if ( !strcasecmp(optarg, "none") ) rslts = EDG_WLL_QUERYRES_NONE; - else if ( !strcasecmp(optarg, "all") ) rslts = EDG_WLL_QUERYRES_ALL; - else { usage(); exit(EINVAL); } - break; - case 'J': jobsLimit = atoi(optarg); break; - case 'E': eventsLimit = atoi(optarg); break; - case -1: ret = 1; break; - } - } while ( !ret ); - - if ( edg_wll_InitContext(&ctx) ) { - if ( verbose ) fprintf(stderr,"%s: cannot initialize edg_wll_Context\n",myname); - exit(1); - } - - if ( jobsLimit > 0 ) { - edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_JOBS_LIMIT, jobsLimit); - if ( verbose ) printf("Soft query limit for jobs: %d\n", jobsLimit); - } - else if ( verbose ) printf("Soft query limit for jobs not set\n"); - - if ( query_events ) { - if ( eventsLimit > 0 ) { - edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_EVENTS_LIMIT, eventsLimit); - if ( verbose ) printf("Soft query limit for events: %d\n", eventsLimit); - } - else if ( verbose ) printf("Soft query limit for events not set\n"); - } - - if ( rslts != EDG_WLL_QUERYRES_UNDEF ) - edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_RESULTS, rslts); - else - edg_wll_GetParam(ctx, EDG_WLL_PARAM_QUERY_RESULTS, &rslts); - - if ( verbose ) printf("When any limit overflows, the returned result set is: %s\n", - rslts==EDG_WLL_QUERYRES_LIMITED? "limited": - (rslts==EDG_WLL_QUERYRES_ALL? "unlimited": "empty")); - - if ( server ) { - char *p = strchr(server, ':'); - if ( p ) { - edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, atoi(p+1)); - *p = 0; - } - edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER, server); - free(server); - } - - if ( proxy_sock ) { - edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_SERVE_SOCK, proxy_sock); - free(proxy_sock); - } - - if ( fname ) { - fin = fopen(fname, "r"); - if ( !fin ) { - if ( verbose ) fprintf(stderr, "Can't open given input file %s. Using stdin.\n", fname); - fin = stdin; - } - free(fname); - } else { - if ( verbose ) fprintf(stderr, "No input file given. Using stdin.\n"); - fin = stdin; - } - - jobsOut = NULL; - statesOut = NULL; - eventsOut = NULL; - - - do - { - if ( verbose && (fin == stdin) ) printf("Enter job conditions:\n"); - - ret = cond_parse(&jc, 1); - if ( ret == PQRV_ERR ) { result = 1; goto cleanup; } - if ( query_events && (ret != PQRV_EOF) ) { - if ( verbose && (fin == stdin) ) printf("Enter event conditions:\n"); - ret = cond_parse(&ec, 0); - if ( ret == PQRV_ERR ) { result = 1; goto cleanup; } - } - - if ( (ret == PQRV_EOF) && !jc && (query_jobs || (query_events && !ec)) ) break; - - if ( verbose ) { - printf("job conditions list: "); - printconds(jc); - if ( query_events ) { printf("event condition list: "); printconds(ec); } - } - - if ( query_jobs ) { - if ( query_bkserver ) - errCode = edg_wll_QueryJobsExt(ctx, - (const edg_wll_QueryRec **) jc, - 0, &jobsOut, stdisp? &statesOut: NULL); - else - errCode = edg_wll_QueryJobsExtProxy(ctx, - (const edg_wll_QueryRec **) jc, - 0, &jobsOut, stdisp? &statesOut: NULL); - } else { - if ( query_bkserver ) - errCode = edg_wll_QueryEventsExt(ctx, - (const edg_wll_QueryRec **) jc, - (const edg_wll_QueryRec **) ec, - &eventsOut); - else - errCode = edg_wll_QueryEventsExtProxy(ctx, - (const edg_wll_QueryRec **) jc, - (const edg_wll_QueryRec **) ec, - &eventsOut); - } - - if ( errCode ) { - dgerr(ctx, NULL); - if ( (errCode != EPERM) && (errCode != E2BIG) ) goto cycle_cleanup; - } else if ( verbose ) { - if ( query_jobs ) printf("Matched jobs: "); - else printf("Matched events: "); - } - - if ( verbose ) { - if ( (query_jobs && jobsOut && jobsOut[0]) || - (query_events && eventsOut && eventsOut[0].type) ) - putchar('\n'); - else printf("No one matches\n"); - } - - if ( query_jobs && jobsOut && !stdisp ) { - for ( i = 0; jobsOut[i]; i++ ) { - s = edg_wlc_JobIdUnparse(jobsOut[i]); - printf("jobId: %s\n", edg_wlc_JobIdUnparse(jobsOut[i])); - free(s); - edg_wlc_JobIdFree(jobsOut[i]); - } - free(jobsOut); - jobsOut = NULL; - } - if ( query_jobs && statesOut ) { - if ( stdisp ) for ( i = 0; statesOut[i].state; i++ ) printstat(statesOut[i]); - for ( i = 0; statesOut[i].state; i++ ) edg_wll_FreeStatus(&statesOut[i]); - free(statesOut); - statesOut = NULL; - } - if ( query_events && eventsOut ) { - for ( i = 0; eventsOut[i].type; i++ ) { - s = edg_wlc_JobIdUnparse(eventsOut[i].any.jobId); - printf("event: %-11s (jobid %s)\n", edg_wll_EventToString(eventsOut[i].type), s); - free(s); - } - free(eventsOut); - eventsOut = NULL; - } - -cycle_cleanup: - if ( jc ) { - for ( i = 0; jc[i]; i++ ) { - for ( j = 0; jc[i][j].attr; j++ ) free_QueryRec(&jc[i][j]); - free(jc[i]); - } - free(jc); - } - - if ( ec ) { - for ( i = 0; ec[i]; i++ ) { - for ( j = 0; ec[i][j].attr; j++ ) free_QueryRec(&ec[i][j]); - free(ec[i]); - } - free(ec); - } - } while ( ret != PQRV_EOF ); - -cleanup: - if ( fin != stdin ) fclose(fin); - edg_wll_FreeContext(ctx); - - return result; -} - -static void free_QueryRec(edg_wll_QueryRec *qr) -{ - switch ( qr->attr ) - { - case EDG_WLL_QUERY_ATTR_JOBID: - case EDG_WLL_QUERY_ATTR_PARENT: - edg_wlc_JobIdFree(qr->value.j); - break; - - case EDG_WLL_QUERY_ATTR_STATUS: - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_EXITCODE: - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - break; - - case EDG_WLL_QUERY_ATTR_OWNER: - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_DESTINATION: - free(qr->value.c); - break; - - case EDG_WLL_QUERY_ATTR_USERTAG: - free(qr->attr_id.tag); - free(qr->value.c); - break; - - default: - break; - } -} - -#define isop(c) ((c == '=') || (c == '<') || (c == '>') || (c == '@')) - -static char *get_attr_name(char *src, char *dest, int sz) -{ - int i = 0, - ct = 0; - - - while ( (src[i] != '\0') && isblank(src[i]) ) i++; /* skip whitespaces */ - while ( (src[i] != '\n') && (src[i] != '\0') && !isop(src[i]) && !isblank(src[i]) ) - { - if ( ct < sz ) - dest[ct++] = src[i]; - i++; - } - dest[ct] = '\0'; - - return src+i; -} - -static char *get_op(char *src, edg_wll_QueryOp *op) -{ - int i = 0; - - - while ( (src[i] != '\0') && isblank(src[i]) ) i++; /* skip whitespaces */ - - if ( src[i] == '=' ) *op = EDG_WLL_QUERY_OP_EQUAL; - else if ( src[i] == '@' ) *op = EDG_WLL_QUERY_OP_WITHIN; - else if ( src[i] == '>' ) *op = EDG_WLL_QUERY_OP_GREATER; - else if ( src[i] == '<' ) - { - if ( (src[i+1] != '\0') && (src[++i] == '>') ) - *op = EDG_WLL_QUERY_OP_UNEQUAL; - else - *op = EDG_WLL_QUERY_OP_LESS; - } - else return NULL; - - return src+i+1; -} - -static char *get_attr_value(char *src, char *dest, int sz) -{ - int i = 0, - ct = 0; - - - while ( (src[i] != '\0') && isblank(src[i]) ) i++; /* skip whitespaces */ - if ( src[i] == '"' ) - { - i++; - while ( (src[i] != '\n') && (src[i] != '\0') && (src[i] != '"') ) - { - if ( ct < sz ) - dest[ct++] = src[i]; - i++; - } - dest[ct] = '\0'; - if ( src[i] != '"' ) - return NULL; - - return src+i+1; - } - - while ( (src[i] != '\n') && (src[i] != '\0') && (src[i] != ';') && !isblank(src[i]) ) - { - if ( ct < sz ) - dest[ct++] = src[i]; - i++; - } - dest[ct] = '\0'; - - return src+i; -} - -static char *get_job_condition(char *src, edg_wll_QueryRec *cond) -{ - char *s; - - - s = get_attr_name(src, tmps, 500); - - if ( tmps[0] == '\0' ) return NULL; - - if ( !strcmp(tmps, "jobid") ) cond->attr = EDG_WLL_QUERY_ATTR_JOBID; - else if ( !strcmp(tmps, "owner") ) cond->attr = EDG_WLL_QUERY_ATTR_OWNER; - else if ( !strcmp(tmps, "status") ) cond->attr = EDG_WLL_QUERY_ATTR_STATUS; - else if ( !strcmp(tmps, "location") ) cond->attr = EDG_WLL_QUERY_ATTR_LOCATION; - else if ( !strcmp(tmps, "destination") ) cond->attr = EDG_WLL_QUERY_ATTR_DESTINATION; - else if ( !strcmp(tmps, "done_code") ) cond->attr = EDG_WLL_QUERY_ATTR_DONECODE; - else if ( !strcmp(tmps, "exit_code") ) cond->attr = EDG_WLL_QUERY_ATTR_EXITCODE; - else if ( !strcmp(tmps, "parent_job") ) cond->attr = EDG_WLL_QUERY_ATTR_PARENT; - else if ( !strcmp(tmps, "time") ) cond->attr = EDG_WLL_QUERY_ATTR_TIME; - else - { - cond->attr = EDG_WLL_QUERY_ATTR_USERTAG; - cond->attr_id.tag = strdup(tmps); - } - - if ( !(s = get_op(s, &(cond->op))) ) return NULL; - - if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL; - - switch ( cond->attr ) - { - case EDG_WLL_QUERY_ATTR_JOBID: - case EDG_WLL_QUERY_ATTR_PARENT: - if ( edg_wlc_JobIdParse(tmps, &cond->value.j) ) - { - fprintf(stderr,"%s: %s: cannot parse jobId\n", myname, tmps); - return NULL; - } - break; - - case EDG_WLL_QUERY_ATTR_OWNER: - if ( !strcmp("NULL", tmps) ) - cond->value.c = NULL; - else if ( !(cond->value.c = strdup(tmps)) ) - return 0; - break; - - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_DESTINATION: - case EDG_WLL_QUERY_ATTR_USERTAG: - if ( !(cond->value.c = strdup(tmps)) ) - return 0; - break; - - case EDG_WLL_QUERY_ATTR_STATUS: - if ( !strcasecmp(tmps, "Submitted") ) cond->value.i = EDG_WLL_JOB_SUBMITTED; - else if ( !strcasecmp(tmps, "Waiting") ) cond->value.i = EDG_WLL_JOB_WAITING; - else if ( !strcasecmp(tmps, "Ready") ) cond->value.i = EDG_WLL_JOB_READY; - else if ( !strcasecmp(tmps, "Scheduled") ) cond->value.i = EDG_WLL_JOB_SCHEDULED; - else if ( !strcasecmp(tmps, "Running") ) cond->value.i = EDG_WLL_JOB_RUNNING; - else if ( !strcasecmp(tmps, "Done") ) cond->value.i = EDG_WLL_JOB_DONE; - else if ( !strcasecmp(tmps, "Aborted") ) cond->value.i = EDG_WLL_JOB_ABORTED; - else if ( !strcasecmp(tmps, "Cancelled") ) cond->value.i = EDG_WLL_JOB_CANCELLED; - else if ( !strcasecmp(tmps, "Cleared") ) cond->value.i = EDG_WLL_JOB_CLEARED; - else - { - fprintf(stderr,"%s: invalid status value (%s)\n", myname, tmps); - return 0; - } - break; - - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_EXITCODE: - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - cond->value.i = atoi(tmps); - if ( cond->op == EDG_WLL_QUERY_OP_WITHIN ) - { - if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL; - if ( tmps[0] == '\0' ) - { - fprintf(stderr,"%s: second interval boundary not set\n", myname); - return NULL; - } - cond->value2.i = atoi(tmps); - } - break; - - case EDG_WLL_QUERY_ATTR_TIME: - cond->value.t.tv_sec = StrToTime(tmps); - if ( cond->op == EDG_WLL_QUERY_OP_WITHIN ) - { - if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL; - if ( tmps[0] == '\0' ) - { - fprintf(stderr,"%s: second interval boundary not set\n", myname); - return NULL; - } - cond->value2.t.tv_sec = StrToTime(tmps); - } - if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL; - if ( tmps[0] == '\0' ) - { - fprintf(stderr,"%s: time condition must be associated with state condition\n", myname); - return NULL; - } - if ( !strcasecmp(tmps, "Submitted") ) cond->attr_id.state = EDG_WLL_JOB_SUBMITTED; - else if ( !strcasecmp(tmps, "Waiting") ) cond->attr_id.state = EDG_WLL_JOB_WAITING; - else if ( !strcasecmp(tmps, "Ready") ) cond->attr_id.state = EDG_WLL_JOB_READY; - else if ( !strcasecmp(tmps, "Scheduled") ) cond->attr_id.state = EDG_WLL_JOB_SCHEDULED; - else if ( !strcasecmp(tmps, "Running") ) cond->attr_id.state = EDG_WLL_JOB_RUNNING; - else if ( !strcasecmp(tmps, "Done") ) cond->attr_id.state = EDG_WLL_JOB_DONE; - else if ( !strcasecmp(tmps, "Aborted") ) cond->attr_id.state = EDG_WLL_JOB_ABORTED; - else if ( !strcasecmp(tmps, "Cancelled") ) cond->attr_id.state = EDG_WLL_JOB_CANCELLED; - else if ( !strcasecmp(tmps, "Cleared") ) cond->attr_id.state = EDG_WLL_JOB_CLEARED; - else - { - fprintf(stderr,"%s: invalid status value (%s)\n", myname, tmps); - return 0; - } - break; - - default: - break; - } - - while ( isblank(*s) || (*s == ';') ) s++; /* skip whitespaces */ - - return s; -} - -static char *get_event_condition(char *src, edg_wll_QueryRec *cond) -{ - char *s; - - - s = get_attr_name(src, tmps, 500); - - if ( tmps[0] == '\0' ) return NULL; - - if ( !strcmp(tmps, "time") ) cond->attr = EDG_WLL_QUERY_ATTR_TIME; - else if ( !strcmp(tmps, "level") ) cond->attr = EDG_WLL_QUERY_ATTR_LEVEL; - else if ( !strcmp(tmps, "host") ) cond->attr = EDG_WLL_QUERY_ATTR_HOST; - else if ( !strcmp(tmps, "source") ) cond->attr = EDG_WLL_QUERY_ATTR_SOURCE; - else if ( !strcmp(tmps, "instance") ) cond->attr = EDG_WLL_QUERY_ATTR_INSTANCE; - else if ( !strcmp(tmps, "event_type") ) cond->attr = EDG_WLL_QUERY_ATTR_EVENT_TYPE; - else - { - cond->attr = EDG_WLL_QUERY_ATTR_USERTAG; - cond->attr_id.tag = strdup(tmps); - } - - if ( !(s = get_op(s, &(cond->op))) ) return NULL; - - if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL; - - switch ( cond->attr ) - { - case EDG_WLL_QUERY_ATTR_USERTAG: - case EDG_WLL_QUERY_ATTR_HOST: - case EDG_WLL_QUERY_ATTR_INSTANCE: - if ( !(cond->value.c = strdup(tmps)) ) - return 0; - break; - - case EDG_WLL_QUERY_ATTR_SOURCE: - if ( !strcasecmp(tmps, "UserInterface") ) cond->value.i = EDG_WLL_SOURCE_USER_INTERFACE; - else if ( !strcasecmp(tmps, "NetworkServer") ) cond->value.i = EDG_WLL_SOURCE_NETWORK_SERVER; - else if ( !strcasecmp(tmps, "WorkloadManager") ) cond->value.i = EDG_WLL_SOURCE_WORKLOAD_MANAGER; - else if ( !strcasecmp(tmps, "BigHelper") ) cond->value.i = EDG_WLL_SOURCE_BIG_HELPER; - else if ( !strcasecmp(tmps, "JobController") ) cond->value.i = EDG_WLL_SOURCE_JOB_SUBMISSION; - else if ( !strcasecmp(tmps, "LogMonitor") ) cond->value.i = EDG_WLL_SOURCE_LOG_MONITOR; - else if ( !strcasecmp(tmps, "LRMS") ) cond->value.i = EDG_WLL_SOURCE_LRMS; - else if ( !strcasecmp(tmps, "Application") ) cond->value.i = EDG_WLL_SOURCE_APPLICATION; - else - { - fprintf(stderr,"%s: invalid source value (%s)\n", myname, tmps); - return NULL; - } - break; - - case EDG_WLL_QUERY_ATTR_EVENT_TYPE: - case EDG_WLL_QUERY_ATTR_LEVEL: - cond->value.i = atoi(tmps); - if ( cond->op == EDG_WLL_QUERY_OP_WITHIN ) - { - if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL; - if ( tmps[0] == '\0' ) - { - fprintf(stderr,"%s: second interval boundary not set\n", myname); - return NULL; - } - cond->value2.i = atoi(tmps); - } - break; - - case EDG_WLL_QUERY_ATTR_TIME: - cond->value.t.tv_sec = StrToTime(tmps); - if ( cond->op == EDG_WLL_QUERY_OP_WITHIN ) - { - if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL; - if ( tmps[0] == '\0' ) - { - fprintf(stderr,"%s: second interval boundary not set\n", myname); - return NULL; - } - cond->value2.t.tv_sec = StrToTime(tmps); - } - break; - - default: - break; - } - - while ( isblank(*s) || (*s == ';') ) s++; /* skip whitespaces */ - - return s; -} - -static int cond_parse(edg_wll_QueryRec ***pcond, int jobs) -{ - edg_wll_QueryRec **cond = NULL; - int n, - icond, - ret; - char *s; - - - - n = 0; - if ( !(cond = malloc(sizeof(*cond))) ) - { - perror("cond_parse()"); - exit(ENOMEM); - } - - while ( 1 ) - { - if ( !fgets(buffer, BUFF_LEN, fin) ) - { - if ( !feof(fin) ) - { - fprintf(stderr, "parse_query_cond(): file reading error\n"); - exit(EINVAL); - } - - ret = PQRV_EOF; - goto cleanup; - } - - if ( buffer[0] == '\n' ) - { - ret = PQRV_EMPTY_LINE; - goto cleanup; - } - - if ( !(cond[n] = (edg_wll_QueryRec *) malloc(sizeof(edg_wll_QueryRec))) ) - { - perror("cond_parse()"); - exit(ENOMEM); - } - s = buffer; - icond = 0; - while ( 1 ) - { - if ( jobs ) - s = get_job_condition(s, &(cond[n][icond])); - else - s = get_event_condition(s, &(cond[n][icond])); - - if ( !s ) - { - free(cond[n]); - cond[n] = NULL; - ret = PQRV_ERR; - goto cleanup; - } - icond++; - if ( !(cond[n] = realloc(cond[n], (icond+1)*sizeof(edg_wll_QueryRec))) ) - { - perror("cond_parse()"); - exit(ENOMEM); - } - cond[n][icond].attr = EDG_WLL_QUERY_ATTR_UNDEF; - if ( (*s == '\n') || (*s == '\0') ) - break; - } - - n++; - if ( !(cond = realloc(cond, (n+1)*sizeof(*cond))) ) - { - perror("cond_parse()"); - exit(ENOMEM); - } - cond[n] = NULL; - } - -cleanup: - if ( !n ) - { - free(cond); - *pcond = NULL; - } - else - *pcond = cond; - - return ret; -} - -static void printconds(edg_wll_QueryRec **cond) -{ - int i, j; - int any = 0; - char *s; - - - if ( !cond ) - { - printf("empty\n"); - return ; - } - - for ( i = 0; cond[i]; i++ ) - { - if ( cond[i][0].attr ) - { - any = 1; - if ( i ) - printf(" AND ("); - else - printf("("); - } - for ( j = 0; cond[i][j].attr; j++ ) - { - if ( j ) - printf(" OR "); - switch ( cond[i][j].attr ) - { - case EDG_WLL_QUERY_ATTR_JOBID: printf("jobid"); break; - case EDG_WLL_QUERY_ATTR_OWNER: printf("owner"); break; - case EDG_WLL_QUERY_ATTR_STATUS: printf("status"); break; - case EDG_WLL_QUERY_ATTR_LOCATION: printf("location"); break; - case EDG_WLL_QUERY_ATTR_DESTINATION: printf("destination"); break; - case EDG_WLL_QUERY_ATTR_DONECODE: printf("done_code"); break; - case EDG_WLL_QUERY_ATTR_EXITCODE: printf("exit_code"); break; - case EDG_WLL_QUERY_ATTR_PARENT: printf("parent_job"); break; - case EDG_WLL_QUERY_ATTR_RESUBMITTED: printf("resubmitted"); break; - case EDG_WLL_QUERY_ATTR_USERTAG: printf("%s",cond[i][j].attr_id.tag); break; - case EDG_WLL_QUERY_ATTR_TIME: printf("time"); break; - case EDG_WLL_QUERY_ATTR_LEVEL: printf("level"); break; - case EDG_WLL_QUERY_ATTR_HOST: printf("host"); break; - case EDG_WLL_QUERY_ATTR_SOURCE: printf("source"); break; - case EDG_WLL_QUERY_ATTR_INSTANCE: printf("instance"); break; - case EDG_WLL_QUERY_ATTR_EVENT_TYPE: printf("ev_type"); break; - default: break; - } - switch ( cond[i][j].op ) - { - case EDG_WLL_QUERY_OP_EQUAL: printf("="); break; - case EDG_WLL_QUERY_OP_UNEQUAL: printf("<>"); break; - case EDG_WLL_QUERY_OP_LESS: printf("<"); break; - case EDG_WLL_QUERY_OP_GREATER: printf(">"); break; - case EDG_WLL_QUERY_OP_WITHIN: printf("@"); break; - } - switch ( cond[i][j].attr ) - { - case EDG_WLL_QUERY_ATTR_JOBID: - case EDG_WLL_QUERY_ATTR_PARENT: - s = edg_wlc_JobIdUnparse(cond[i][j].value.j); - printf("%s", s); - free(s); - break; - case EDG_WLL_QUERY_ATTR_OWNER: - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_DESTINATION: - case EDG_WLL_QUERY_ATTR_HOST: - case EDG_WLL_QUERY_ATTR_INSTANCE: - case EDG_WLL_QUERY_ATTR_USERTAG: - printf("%s", cond[i][j].value.c); - break; - case EDG_WLL_QUERY_ATTR_STATUS: - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_EXITCODE: - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - case EDG_WLL_QUERY_ATTR_SOURCE: - if ( cond[i][j].op == EDG_WLL_QUERY_OP_WITHIN ) - printf("[%d,%d]", cond[i][j].value.i, cond[i][j].value2.i); - else - printf("%d", cond[i][j].value.i); - break; - case EDG_WLL_QUERY_ATTR_TIME: - if ( cond[i][j].op == EDG_WLL_QUERY_OP_WITHIN ) - { - printf("[%s,", TimeToStr(cond[i][j].value.t.tv_sec)); - printf("%s] & state = %d", TimeToStr(cond[i][j].value2.t.tv_sec), cond[i][j].attr_id.state); - } - else - printf("%s & state = %d", TimeToStr(cond[i][j].value.t.tv_sec), cond[i][j].attr_id.state); - break; - default: - break; - } - } - if ( j ) - printf(")"); - } - if ( any ) printf("\n"); -} - -static void printstat(edg_wll_JobStat stat) -{ - char *s, *j; - - - s = edg_wll_StatToString(stat.state); - printf("STATUS:\t%s\n\n",s); -/* print whole flat structure */ - printf("state : %s\n", s); - printf("jobId : %s\n", j = edg_wlc_JobIdUnparse(stat.jobId)); - printf("owner : %s\n", stat.owner); - printf("jobtype : %d\n", stat.jobtype); - if (stat.jobtype) {; - printf("seed : %s\n", stat.seed); - printf("children_num : %d\n", stat.children_num); -// XXX deal with subjobs (children, children_hist, children_states) - } - printf("condorId : %s\n", stat.condorId); - printf("globusId : %s\n", stat.globusId); - printf("localId : %s\n", stat.localId); - printf("jdl : %s\n", stat.jdl); - printf("matched_jdl : %s\n", stat.matched_jdl); - printf("destination : %s\n", stat.destination); - printf("network server : %s\n", stat.network_server); - printf("condor_jdl : %s\n", stat.condor_jdl); - printf("rsl : %s\n", stat.rsl); - printf("reason : %s\n", stat.reason); - printf("location : %s\n", stat.location); - printf("ce_node : %s\n", stat.ce_node); - printf("subjob_failed : %d\n", stat.subjob_failed); - printf("done_code : %d\n", stat.done_code); - printf("exit_code : %d\n", stat.exit_code); - printf("resubmitted : %d\n", stat.resubmitted); - printf("cancelling : %d\n", stat.cancelling); - printf("cancelReason : %s\n", stat.cancelReason); - printf("cpuTime : %d\n", stat.cpuTime); -// XXX user_tags user_values - printf("stateEnterTime : %ld.%06ld\n", stat.stateEnterTime.tv_sec,stat.stateEnterTime.tv_usec); - printf("lastUpdateTime : %ld.%06ld\n", stat.lastUpdateTime.tv_sec,stat.lastUpdateTime.tv_usec); - printf("expectUpdate : %d\n", stat.expectUpdate); - printf("expectFrom : %s\n", stat.expectFrom); - - free(j); - free(s); -} - -time_t StrToTime(char *t) -{ - struct tm tm; - - memset(&tm,0,sizeof(tm)); - setenv("TZ","UTC",1); - tzset(); - sscanf(t,"%4d-%02d-%02d %02d:%02d:%02d", - &tm.tm_year,&tm.tm_mon,&tm.tm_mday, - &tm.tm_hour,&tm.tm_min,&tm.tm_sec); - tm.tm_year -= 1900; - tm.tm_mon--; - - return mktime(&tm); -} - -static char tbuf[256]; - -char *TimeToStr(time_t t) -{ - struct tm *tm = gmtime(&t); - - sprintf(tbuf,"'%4d-%02d-%02d %02d:%02d:%02d'", - tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, - tm->tm_hour,tm->tm_min,tm->tm_sec); - - return tbuf; -} - -static void dgerr(edg_wll_Context ctx, char *where) -{ - char *errText, - *errDesc; - - - edg_wll_Error(ctx, &errText, &errDesc); - fprintf(stderr, "%s", errText); - if ( where ) - fprintf(stderr, ": %s", where); - if ( errDesc ) - fprintf(stderr, " (%s)\n", errDesc); - else - putc('\n', stderr); - free(errText); - free(errDesc); -} - diff --git a/org.glite.lb.client/examples/query_seq_code.c b/org.glite.lb.client/examples/query_seq_code.c deleted file mode 100644 index 87e342d..0000000 --- a/org.glite.lb.client/examples/query_seq_code.c +++ /dev/null @@ -1,87 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/consumer.h" - - -static struct option opts[] = { - {"help", 0, NULL, 'h'}, - {"sock", 1, NULL, 's'}, - {"jobid", 1, NULL, 'j'}, -}; - -static void usage(char *me) -{ - fprintf(stderr, "usage: %s [option]\n" - "\t-h, --help Shows this screen.\n" - "\t-s, --server LB Proxy socket.\n" - "\t-j, --jobid ID of requested job.\n" - , me); -} - - -int main(int argc, char *argv[]) -{ - edg_wll_Context ctx; - edg_wlc_JobId jobid = NULL; - char *server, *jobid_s, *code; - int opt, err = 0; - - - server = code = jobid_s = NULL; - while ( (opt = getopt_long(argc, argv, "hs:j:c:n:v:", opts, NULL)) != EOF) - switch (opt) { - case 'h': usage(argv[0]); return 0; - case 's': server = strdup(optarg); break; - case 'j': jobid_s = strdup(optarg); break; - case '?': usage(argv[0]); return 1; - } - - if ( !jobid_s ) { fprintf(stderr, "JobId not given\n"); return 1; } - if ( !server ) { fprintf(stderr, "LB proxy socket not given\n"); return 1; } - - if ( (errno = edg_wlc_JobIdParse(jobid_s, &jobid)) ) { perror(jobid_s); return 1; } - - if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { - fprintf(stderr, "Cannot initialize Globus common module\n"); - exit(1); - } - - edg_wll_InitContext(&ctx); - - edg_wll_SetParam(ctx, EDG_WLL_PARAM_SOURCE, EDG_WLL_SOURCE_USER_INTERFACE); - edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_SERVE_SOCK, server); - -/* - if (edg_wll_SetLoggingJob(ctx, jobid, code, EDG_WLL_SEQ_NORMAL)) { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"SetLoggingJob(%s,%s): %s (%s)\n",jobid_s,code,et,ed); - exit(1); - } -*/ - if ( (err = edg_wll_QuerySequenceCodeProxy(ctx, jobid, &code)) ) { - char *et,*ed; - - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"%s: edg_wll_QuerySequenceCodeProxy(): %s (%s)\n", - argv[0],et,ed); - free(et); free(ed); - } - - if ( code ) { - puts(code); - free(code); - } - - edg_wll_FreeContext(ctx); - - return err; -} diff --git a/org.glite.lb.client/examples/ready.l b/org.glite.lb.client/examples/ready.l deleted file mode 100644 index e4d9ac7..0000000 --- a/org.glite.lb.client/examples/ready.l +++ /dev/null @@ -1,18 +0,0 @@ -# macro definition for WAITING state - -:waiting: -# NetworkServer - --s NetworkServer,-e EnQueued, --queue="destination queue", --job="job description in receiver language", --result=OK, --reason="detailed description of transfer" -# -s NetworkServer,-e Transfer,--destination="WorkloadManager",--dest_host="destination hostname",--dest_instance="destination instance",--dest_jobid="job description in receiver language",--result=OK,--reason="detailed description of transfer",--dest_jobid="destination internal jobid" - -# WorkloadManager - --s WorkloadManager,-e DeQueued, --queue="queue name", --local_jobid="new jobId assigned by the receiving component" --s WorkloadManager,-e HelperCall, --helper_name="name of the called component",--helper_params="parameters of the call", --src_role=CALLING -#-s Helper,-e HelperCall, --helper_name="name of the called component",--helper_params="parameters of the call", --src_role=CALLED -#-s Helper,-e HelperReturn, --helper_name="name of the called component",--retval="returned data", --src_role=CALLED --s WorkloadManager,-e Match,--dest_id="Id of the destination CE/queue" --s WorkloadManager,-e HelperReturn, --helper_name="name of the called component",--retval="returned data", --src_role=CALLING --s WorkloadManager,-e EnQueued, --queue="destination queue", --job="job description in receiver language", --result=OK, --reason="detailed description of transfer" - diff --git a/org.glite.lb.client/examples/ready_dag.l b/org.glite.lb.client/examples/ready_dag.l deleted file mode 100644 index aa7deae..0000000 --- a/org.glite.lb.client/examples/ready_dag.l +++ /dev/null @@ -1,13 +0,0 @@ -# macro definition for WAITING state - -:waiting_dag: -# NetworkServer - --s NetworkServer,-e EnQueued, --queue="destination queue", --job="job description in receiver language", --result=OK, --reason="detailed description of transfer" - -# WorkloadManager - --s WorkloadManager,-e DeQueued, --queue="queue name", --local_jobid="new jobId assigned by the receiving component" - --s WorkloadManager,-e EnQueued, --queue="destination queue", --job="job description in receiver language", --result=OK, --reason="detailed description of transfer" - diff --git a/org.glite.lb.client/examples/ready_subjob.l b/org.glite.lb.client/examples/ready_subjob.l deleted file mode 100644 index 3f40632..0000000 --- a/org.glite.lb.client/examples/ready_subjob.l +++ /dev/null @@ -1,8 +0,0 @@ -# macro definition for WAITING state - -:waiting_subjob: -# WorkloadManager - --s WorkloadManager,-e Match,--dest_id="Id of the destination CE/queue" --s WorkloadManager,-e HelperReturn, --helper_name="name of the called component",--retval="returned data", --src_role=CALLING - diff --git a/org.glite.lb.client/examples/running.l b/org.glite.lb.client/examples/running.l deleted file mode 100644 index 12d411a..0000000 --- a/org.glite.lb.client/examples/running.l +++ /dev/null @@ -1,4 +0,0 @@ -# macro definition for RUNNING state - -:scheduled: --s LogMonitor,-e Running,--node"worker node where the executable is run" diff --git a/org.glite.lb.client/examples/running_dag.l b/org.glite.lb.client/examples/running_dag.l deleted file mode 100644 index 74e1efa..0000000 --- a/org.glite.lb.client/examples/running_dag.l +++ /dev/null @@ -1,4 +0,0 @@ -# macro definition for RUNNING state - -:scheduled_dag: --s LogMonitor,-e Running,--node"DAGMan running on server" diff --git a/org.glite.lb.client/examples/running_subjob.l b/org.glite.lb.client/examples/running_subjob.l deleted file mode 100644 index 2069f33..0000000 --- a/org.glite.lb.client/examples/running_subjob.l +++ /dev/null @@ -1,4 +0,0 @@ -# macro definition for RUNNING state - -:scheduled_subjob: --s LogMonitor,-e Running,--node"worker node where the executable is run" diff --git a/org.glite.lb.client/examples/scheduled.l b/org.glite.lb.client/examples/scheduled.l deleted file mode 100644 index 3197309..0000000 --- a/org.glite.lb.client/examples/scheduled.l +++ /dev/null @@ -1,13 +0,0 @@ -# macro definition for SCHEDULED state - -:ready: -# JobSubmition - --s JobController,-e DeQueued, --queue="queue name", --local_jobid="new jobId assigned by the receiving component" --s JobController,-e Transfer,--destination="LRMS",--dest_host="destination hostname",--dest_instance="destination instance",--dest_jobid="job description in receiver language",--result=OK,--reason="detailed description of transfer",--dest_jobid="destination internal jobid" - -# LogMonitor - --s LogMonitor,-e Accepted, --from="JobController", --from_host="sending component hostname", --from_instance="sending component instance", --local_jobid="new jobId (Condor, Globus ...)" --s LogMonitor,-e Transfer,--destination="LRMS",--dest_host="destination hostname",--dest_instance="destination instance",--dest_jobid="job description in receiver language",--result=OK,--reason="detailed description of transfer",--dest_jobid="destination internal jobid" - diff --git a/org.glite.lb.client/examples/scheduled_dag.l b/org.glite.lb.client/examples/scheduled_dag.l deleted file mode 100644 index a90b788..0000000 --- a/org.glite.lb.client/examples/scheduled_dag.l +++ /dev/null @@ -1,12 +0,0 @@ -# macro definition for SCHEDULED state - -:ready_dag: -# JobSubmition - --s JobController,-e DeQueued, --queue="queue name", --local_jobid="new jobId assigned by the receiving component" --s JobController,-e Transfer,--destination="LogMonitor",--dest_host="destination hostname",--dest_instance="destination instance",--dest_jobid="job description in receiver language",--result=START,--reason="detailed description of transfer",--dest_jobid="destination internal jobid" - -# LogMonitor - --s LogMonitor,-e Accepted, --from="JobController", --from_host="sending component hostname", --from_instance="sending component instance", --local_jobid="new jobId (Condor, Globus ...)" - diff --git a/org.glite.lb.client/examples/scheduled_subjob.l b/org.glite.lb.client/examples/scheduled_subjob.l deleted file mode 100644 index f1d3021..0000000 --- a/org.glite.lb.client/examples/scheduled_subjob.l +++ /dev/null @@ -1,7 +0,0 @@ -# macro definition for SCHEDULED state - -:ready_subjob: -# LogMonitor - --s LogMonitor,-e Transfer,--destination="LRMS",--dest_host="destination hostname",--dest_instance="destination instance",--dest_jobid="job description in receiver language",--result=OK,--reason="detailed description of transfer",--dest_jobid="destination internal jobid" - diff --git a/org.glite.lb.client/examples/submitted.l b/org.glite.lb.client/examples/submitted.l deleted file mode 100644 index 932ef55..0000000 --- a/org.glite.lb.client/examples/submitted.l +++ /dev/null @@ -1,5 +0,0 @@ -# macro definition for SUBMITTED state - -# only job registration needed for submitted state -#-p,-s UserInterface,-e Transfer,--destination="NetworkServer",--destination_host="destination hostname",--destination_instance="destination instance",--destination_jobid="job description in receiver language",--result=OK,--reason="detailed description of transfer",--destination_jobid="destination internal jobid" - diff --git a/org.glite.lb.client/examples/submitted_dag.l b/org.glite.lb.client/examples/submitted_dag.l deleted file mode 100644 index 5bcae2f..0000000 --- a/org.glite.lb.client/examples/submitted_dag.l +++ /dev/null @@ -1,4 +0,0 @@ -# macro definition for SUBMITTED state - -# only job registration needed for submitted state - diff --git a/org.glite.lb.client/examples/submitted_subjob.l b/org.glite.lb.client/examples/submitted_subjob.l deleted file mode 100644 index 5bcae2f..0000000 --- a/org.glite.lb.client/examples/submitted_subjob.l +++ /dev/null @@ -1,4 +0,0 @@ -# macro definition for SUBMITTED state - -# only job registration needed for submitted state - diff --git a/org.glite.lb.client/examples/waiting.l b/org.glite.lb.client/examples/waiting.l deleted file mode 100644 index 439a7da..0000000 --- a/org.glite.lb.client/examples/waiting.l +++ /dev/null @@ -1,6 +0,0 @@ -# macro definition for WAITING state - -:submitted: -# NetworkServer - --s NetworkServer,-e Accepted, --from="UserInterface", --from_host="sending component hostname", --from_instance="sending component instance", --local_jobid="new jobId (Condor, Globus ...)" diff --git a/org.glite.lb.client/examples/waiting_dag.l b/org.glite.lb.client/examples/waiting_dag.l deleted file mode 100644 index 01c1d11..0000000 --- a/org.glite.lb.client/examples/waiting_dag.l +++ /dev/null @@ -1,6 +0,0 @@ -# macro definition for WAITING state - -:submitted_dag: -# NetworkServer - --s NetworkServer,-e Accepted, --from="UserInterface", --from_host="sending component hostname", --from_instance="sending component instance", --local_jobid="new jobId (Condor, Globus ...)" diff --git a/org.glite.lb.client/examples/waiting_subjob.l b/org.glite.lb.client/examples/waiting_subjob.l deleted file mode 100644 index 41a2acc..0000000 --- a/org.glite.lb.client/examples/waiting_subjob.l +++ /dev/null @@ -1,6 +0,0 @@ -# macro definition for WAITING state - -:submitted_subjob: -# WorkloadManager - --s WorkloadManager,-e HelperCall, --helper_name="name of the called component",--helper_params="parameters of the call", --src_role=CALLING diff --git a/org.glite.lb.client/project/build.properties b/org.glite.lb.client/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.lb.client/project/configure.properties.xml b/org.glite.lb.client/project/configure.properties.xml deleted file mode 100644 index 17c4c40..0000000 --- a/org.glite.lb.client/project/configure.properties.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - -top_srcdir=.. -builddir=build -stagedir=${stage.abs.dir} -distdir=${dist.dir} -globalprefix=${global.prefix} -lbprefix=${subsystem.prefix} -package=${module.package.name} -PREFIX=${install.dir} -version=${module.version} -glite_location=${with.glite.location} -globus_prefix=${with.globus.prefix} -thrflavour=${with.globus.thr.flavor} -nothrflavour=${with.globus.nothr.flavor} -expat_prefix=${with.expat.prefix} -ares_prefix=${with.ares.prefix} -cppunit_prefix=${with.cppunit.prefix} - - - diff --git a/org.glite.lb.client/project/properties.xml b/org.glite.lb.client/project/properties.xml deleted file mode 100755 index d067cbd..0000000 --- a/org.glite.lb.client/project/properties.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.client/project/tar_exclude b/org.glite.lb.client/project/tar_exclude deleted file mode 100644 index e1fcd1a..0000000 --- a/org.glite.lb.client/project/tar_exclude +++ /dev/null @@ -1,10 +0,0 @@ -tar_exclude -CVS -build.xml -build -build.properties -properties.xml -configure.properties.xml -.cvsignore -.project -.cdtproject diff --git a/org.glite.lb.client/project/version.properties b/org.glite.lb.client/project/version.properties deleted file mode 100644 index 44ccd5f..0000000 --- a/org.glite.lb.client/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Dec 09 04:57:27 CET 2004 -module.version=0.5.0 -module.build=111 -module.age=2 diff --git a/org.glite.lb.client/src/Event.cpp.T b/org.glite.lb.client/src/Event.cpp.T deleted file mode 100644 index 7e32f62..0000000 --- a/org.glite.lb.client/src/Event.cpp.T +++ /dev/null @@ -1,337 +0,0 @@ -/* -@@@AUTO -*/ - -#include -#include -#include -#include - -#include - -#include "glite/wmsutils/jobid/cjobid.h" - -#include "glite/lb/Event.h" -#include "glite/wmsutils/jobid/JobIdExceptions.h" -#include "glite/lb/LoggingExceptions.h" - -#include "glite/lb/consumer.h" -#include "glite/lb/events.h" -#include "glite/lb/notifid.h" - -EWL_BEGIN_NAMESPACE; - -#define CLASS_PREFIX "glite::lb::Event::" - -@@@{ -sub typeswitch { - my $ftype = shift; - my $resc = shift; - local $_; - my %ctype; - $ctype{$_} = 1 while $_ = shift; - - $resc = 'break;' unless $resc; - - gen $indent."switch (attr) {\n"; - selectType $event $ftype; - for (getFields $event) { - my $f = selectField $event $_; - if($ctype{$f->{type}}) { - my $cstr = $ftype eq '_common_' ? 'any' : lcfirst $ftype; - my $cname = getName $f 'C'; - gen "$indent\tcase Event::".uc($f->{name}).": return(cev->$cstr.$cname);\n"; - } elsif (($f->{type} eq "int") && - ($ctype{"string"}) && - $f->{codes}) { - # conversion from int to string (well, enum to string) - my $cstr = $ftype eq '_common_' ? 'any' : lcfirst $ftype; - my $cname = getName $f 'C'; - my $fn = $ftype eq '_common_' ? "" : ucfirst $ftype; - my $c = $fn . ucfirst $f->{name}; - $cast = ($c eq 'Level') ? "(edg_wll_Level)" : ""; - gen "$indent\tcase Event::".uc($f->{name}).": return((const char *)edg_wll_${c}ToString(${cast}cev->$cstr.$cname));\n"; - } elsif (($f->{type} eq "jobid") && - ($ctype{"string"})) { - # conversion from jobid to string - } - } - gen "$indent\tdefault: $resc\n" if $resc; - gen "$indent\}\n"; -} -@@@} - -Event::Event(void) -{ - type = UNDEF; - flesh = 0; -} - - -Event::Event(const Event &in) -{ - type = in.type; - flesh = in.flesh; - if (flesh) flesh->use(); -} - - -Event::Event(edg_wll_Event *in) -{ - type = (Type)in->type; - flesh = new CountRef((void*)in); -} - - -Event::~Event(void) -{ - if (flesh) flesh->release(); -} - - -Event & -Event::operator= (const Event &in) -{ - if (flesh) flesh->release(); - type = in.type; - flesh = in.flesh; - if (flesh) flesh->use(); - - return *this; -} - -int Event::getValInt(Attr attr) const -{ - edg_wll_Event const *cev = (edg_wll_Event *) flesh->ptr; - -@@@{ - $indent = "\t"; - typeswitch '_common_',undef,'int','port','logsrc'; -@@@} - - switch (cev->type) { -@@@{ - $indent = "\t\t"; - for my $t (getTypes $event) { - gen "\t\tcase ".uc($t).":\n"; - typeswitch $t,'goto badattr;','int','port','logsrc'; - } -@@@} - default: - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, EINVAL, - "attribute is not of int type")); - } -badattr: - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, ENOENT, "invalid attribute")); - return -1; /* gcc, shut up! */ -} - -static char const *get_string_val(const edg_wll_Event *cev, Event::Attr attr) -{ -@@@{ - $indent = "\t"; - typeswitch '_common_',undef,'string'; -@@@} - - switch (cev->type) { -@@@{ - $indent = "\t\t"; - for my $t (getTypes $event) { - gen "\t\tcase Event::".uc($t).":\n"; - typeswitch $t,'goto badattr;','string'; - } -@@@} - default: - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, EINVAL, - "attribute is not of string type and can not be converted")); - } -badattr: - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, ENOENT, "invalid attribute")); - return NULL; /* gcc, shut up! */ -} - - -std::string -Event::getValString(Attr attr) const -{ - edg_wll_Event const *cev = (edg_wll_Event *) flesh->ptr; - std::string ret; - - try { - char const *s = get_string_val(cev,attr); - if (s) ret.assign(s); - return ret; - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - - -struct timeval -Event::getValTime(Attr attr) const -{ - edg_wll_Event const *cev = (edg_wll_Event *) flesh->ptr; -@@@{ - $indent = "\t"; - typeswitch '_common_',undef,'timeval'; -@@@} - - /* XXX - * to make things simpler we don't include this here as there are no - * type specific timeval attributes currently - * - * switch (cev->type) { - */ - - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, ENOENT, "invalid attribute")); -} - -static -edg_wlc_JobId -get_val_jobid(edg_wll_Event const *cev, Event::Attr attr) -{ -@@@{ - $indent = "\t"; - typeswitch '_common_', undef,'jobid'; -@@@} - switch (cev->type) { -@@@{ - $indent = "\t\t"; - for my $t (getTypes $event) { - gen "\t\tcase Event::".uc($t).":\n"; - typeswitch $t,'goto badattr;','jobid'; - } -@@@} - default: - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, EINVAL, - "attribute is not of jobid type")); - } -badattr: - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, ENOENT, "invalid attribute")); - return NULL; /* gcc, shut up! */ -} - -const -glite::wmsutils::jobid::JobId -Event::getValJobId(Attr attr) const -{ - edg_wll_Event const *cev = (edg_wll_Event *) flesh->ptr; - try { - edg_wlc_JobId job_id = get_val_jobid(cev,attr); - return(glite::wmsutils::jobid::JobId(job_id)); - } - catch (Exception &e) { - STACK_ADD; - throw; - } - -} - - -static std::string const names[Event::TYPE_MAX] = { - "undefined", -@@@{ - for (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) - { - gen "\t\"$_\",\n"; - } -@@@} -}; - -const std::string & -Event::name(void) const -{ - if (type<0 || type>TYPE_MAX) { - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, EINVAL, "invalid event type")); - } - return names[type]; -} - - -static -std::string const attr_names[Event::ATTR_MAX] = { -@@@{ - for (sort {$a cmp $b} getAllFields $event) { - gen "\t\"$_\",\n"; - } -@@@} -}; - - -const std::string & -Event::getAttrName(Attr attr) const -{ - if (attr<0 || attr>=ATTR_MAX) { - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, EINVAL, "invalid attribute")); - } - return attr_names[attr]; -} - - -typedef std::pair tpair; -static std::vector attrs[Event::TYPE_MAX]; - -#define apush(etype,attr,atype) \ - attrs[etype].push_back(tpair(attr,atype)) - -static bool attrs_inited = false; - -static void init_attrs(void) -{ -@@@{ - for my $t (getTypes $event) { - my $tu = uc $t; - selectType $event '_common_'; - for (getFields $event) { - my $fu = uc $_; - my $f = selectField $event $_; - my $ftu = uc "$f->{type}_T"; - gen "\tapush(Event::$tu,Event::$fu,Event::$ftu);\n"; - } - selectType $event $t; - for (getFields $event) { - my $fu = uc $_; - my $f = selectField $event $_; - my $ftu = uc "$f->{type}_T"; - gen "\tapush(Event::$tu,Event::$fu,Event::$ftu);\n"; - } - } -@@@} -} - -std::vector > const & Event::getAttrs(void) const -{ - if (type<0 || type>=TYPE_MAX) { - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, EINVAL, "invalid event type")); - } - - /* FIXME: thread safety */ - if (!attrs_inited) { - init_attrs(); - attrs_inited = true; - } - - return attrs[type]; -} - - -void -Event::destroyFlesh(void *in) -{ - edg_wll_FreeEvent((edg_wll_Event *) in); - free(in); -} - -EWL_END_NAMESPACE; diff --git a/org.glite.lb.client/src/Job.cpp b/org.glite.lb.client/src/Job.cpp deleted file mode 100644 index 81ddbe4..0000000 --- a/org.glite.lb.client/src/Job.cpp +++ /dev/null @@ -1,209 +0,0 @@ -#ident "$Header$" - -/** - * @file Job.cpp - * @version $Revision$ - */ - - -#include -#include -#include - -#include - -#include "glite/wmsutils/jobid/JobIdExceptions.h" - -#include "glite/lb/Job.h" -#include "glite/lb/LoggingExceptions.h" -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" - -EWL_BEGIN_NAMESPACE; - -#define CLASS_PREFIX "glite::lb::Job::" - -const int Job::STAT_CLASSADS = EDG_WLL_STAT_CLASSADS; -const int Job::STAT_CHILDREN = EDG_WLL_STAT_CHILDREN; -const int Job::STAT_CHILDSTAT = EDG_WLL_STAT_CHILDSTAT; - -Job::Job(void) -{ -} - - -Job::Job(const glite::wmsutils::jobid::JobId &in) -{ - try { - jobId = in; - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - - -Job::~Job(void) -{ -} - - -Job & Job::operator= (const glite::wmsutils::jobid::JobId &in) -{ - try { - jobId = in; - return *this; - } catch (Exception &) { - STACK_ADD; - throw; - } -} - - -JobStatus -Job::status(int flags) const -{ - JobStatus jobStatus; - - try { - edg_wll_JobStat *cstat = jobStatus.c_ptr(); - int ret = edg_wll_JobStatus(server.getContext(), - jobId, // automagically converted by member operator - flags, - cstat); - check_result(ret, - server.getContext(), - "edg_wll_JobStatus"); - -/* XXX the enums match due to automatic generation */ - jobStatus.status = (JobStatus::Code) cstat->state; - - return(jobStatus); - - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - - -void -Job::log(std::vector &eventList) const -{ - edg_wll_Event *events = NULL,*ev; - int result, qresults_param; - char *errstr = NULL; - edg_wll_Context context; - - try { - context = server.getContext(); - result = edg_wll_JobLog(context, jobId, &events); - if (result == E2BIG) { - edg_wll_Error(context, NULL, &errstr); - check_result(edg_wll_GetParam(context, - EDG_WLL_PARAM_QUERY_RESULTS, &qresults_param), - context, - "edg_wll_GetParam(EDG_WLL_PARAM_QUERY_RESULTS)"); - if (qresults_param != EDG_WLL_QUERYRES_LIMITED) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_JobLog"); - } - } else { - check_result(result, context,"edg_wll_JobLog"); - } - - for (int i=0; events[i].type != EDG_WLL_EVENT_UNDEF; i++) { - ev = (edg_wll_Event *) malloc(sizeof *ev); - memcpy(ev,events+i,sizeof *ev); - eventList.push_back(Event(ev)); - } - - free(events); - - if (result) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_JobLog"); - } - } catch (Exception &e) { - if(errstr) free(errstr); - - STACK_ADD; - throw; - } - -} - - -const std::vector -Job::log(void) const -{ - std::vector eventList; - - log(eventList); - return(eventList); -} - - -const std::pair -Job::queryListener(std::string const & name) const -{ - std::string host; - char *c_host = NULL; - uint16_t port; - - try { - int ret = edg_wll_QueryListener(server.getContext(), - jobId, - name.c_str(), - &c_host, - &port); - check_result(ret, - server.getContext(), - "edg_wll_QueryListener"); - - host = c_host; - free(c_host); - return(std::pair(host,port)); - - } catch (Exception &e) { - if(c_host) free(c_host); - STACK_ADD; - throw; - } -} - - -void Job::setParam(edg_wll_ContextParam par, int val) -{ - server.setParam(par,val); -} - -void Job::setParam(edg_wll_ContextParam par, const std::string val) -{ - server.setParam(par,val); -} - -void Job::setParam(edg_wll_ContextParam par, const struct timeval & val) -{ - server.setParam(par,val); -} - - -int Job::getParamInt(edg_wll_ContextParam par) const -{ - return server.getParamInt(par); -} - -std::string Job::getParamString(edg_wll_ContextParam par) const -{ - return server.getParamString(par); -} - -struct timeval Job::getParamTime(edg_wll_ContextParam par) const -{ - return server.getParamTime(par); -} - - - -EWL_END_NAMESPACE; diff --git a/org.glite.lb.client/src/JobStatus.cpp.T b/org.glite.lb.client/src/JobStatus.cpp.T deleted file mode 100644 index df9609b..0000000 --- a/org.glite.lb.client/src/JobStatus.cpp.T +++ /dev/null @@ -1,481 +0,0 @@ -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/JobId.h" - -#include "glite/lb/JobStatus.h" -#include "glite/lb/LoggingExceptions.h" -#include "glite/lb/consumer.h" - - -EWL_BEGIN_NAMESPACE; - -#define CLASS_PREFIX "glite::lb::JobStatus::" - -@@@{ -sub typeswitch { - my ($ftype,$ctype,$resc) = @_; - local $_; - - $resc = "break;" unless $resc; - - gen $indent."switch (attr) {\n"; - selectType $status $ftype; - for (getFields $status) { - my $f = selectField $status $_; - if($f->{type} eq $ctype) { - my $fnu = $f->{name}; - $fnu =~ s/([a-z])([A-Z])/$1_$2/g; - $fnu = uc $fnu; - my $cname = getName $f 'C'; - gen "$indent\tcase JobStatus::$fnu: return cstat->$cname;\n" - }; - # XXX: when there are conversion functions, we may get these as strings as well - #elsif (($f->{type} eq "int") && - # ($ctype eq "string") && - # $f->{codes}) { - # my $fnu = $f->{name}; - # $fnu =~ s/([a-z])([A-Z])/$1_$2/g; - # $fnu = uc $fnu; - # my $cname = getName $f 'C'; - # my $fn = $ftype eq '_common_' ? "" : ucfirst $ftype; - # my $c = $fn . ucfirst $f->{name}; - # $cast = ($c eq 'Level') ? "(edg_wll_Level)" : ""; - # gen "$indent\tcase JobStatus::$fnu: return((const char *)edg_wll_${c}ToString(${cast}cstat->$cname));\n"; } - } - gen "$indent\tdefault: $resc\n" if $resc; - gen "$indent\}\n"; -} -@@@} - -JobStatus::JobStatus(void) -{ - status = UNDEF; - flesh = 0; -} - -JobStatus::JobStatus(const JobStatus & in) -{ - status = in.status; - flesh = in.flesh; - if (flesh) flesh->use(); -} - -JobStatus & -JobStatus::operator=(const JobStatus & in) -{ - if (flesh) flesh->release(); - status = in.status; - flesh = in.flesh; - if (flesh) flesh->use(); - return *this; -} - -JobStatus::JobStatus(const edg_wll_JobStat & in) -{ - status = (Code)in.state; - flesh = new CountRef((void*)&in); -} - -JobStatus & -JobStatus::operator=(const edg_wll_JobStat & in) -{ - if(flesh) - flesh->release(); - status = (Code)in.state; - flesh = new CountRef((void*)&in); - return(*this); -} - -JobStatus::~JobStatus() -{ - if (flesh) flesh->release(); -} - -edg_wll_JobStat * -JobStatus::c_ptr(void) -{ - edg_wll_JobStat *s; - - if(flesh) - return((edg_wll_JobStat*)flesh->ptr); - - s = new edg_wll_JobStat; - // XXX - is it neccessary? new should throw exception itself... - if(!s) throw(Exception(EXCEPTION_MANDATORY, - ENOMEM, - "out of memory allocating c-struct for JobStatus")); - - edg_wll_InitStatus(s); - flesh = new CountRef((void*)s); - return(s); -} - - -static std::string const names[JobStatus::CODE_MAX] = { - "undefined", -@@@{ - for (sort { $status->{order}->{$a} <=> $status->{order}->{$b} } - $status->getTypes) - { - gen "\t\"$_\",\n"; - } -@@@} -}; - -const std::string& JobStatus::name(void) const -{ - if (status<0 || status>=CODE_MAX) { - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - EINVAL, - "status code invalid")); - } - return names[status]; -} - -int JobStatus::getValInt(JobStatus::Attr attr) const -{ - edg_wll_JobStat const *cstat = (edg_wll_JobStat *) flesh->ptr; -@@@{ - $indent = "\t"; - typeswitch '_common_','int'; -@@@} - - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - ENOENT, - "no such attribute")); - return -1; /* make gcc shut up -- never returns */ -} - -bool JobStatus::getValBool(JobStatus::Attr attr) const -{ - edg_wll_JobStat const *cstat = (edg_wll_JobStat *) flesh->ptr; -@@@{ - $indent = "\t"; - typeswitch '_common_','bool'; -@@@} - - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - ENOENT, - "no such attribute")); - return -1; /* make gcc shut up -- never returns */ -} - -static const char * -get_string_val(const edg_wll_JobStat *cstat,JobStatus::Attr attr) -{ -@@@{ - $indent = "\t"; - typeswitch '_common_','string'; -@@@} - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - ENOENT, - "no such attribute")); - return 0; /* make gcc shut up -- never returns */ -} - -std::string -JobStatus::getValString(JobStatus::Attr attr) const -{ - edg_wll_JobStat const *cstat = (edg_wll_JobStat *) flesh->ptr; - std::string ret; - - try{ - const char *s = get_string_val(cstat,attr); - if (s) ret.assign(s); - return ret; - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - - -struct timeval -JobStatus::getValTime(Attr attr) const -{ - edg_wll_JobStat const *cstat = (edg_wll_JobStat *) flesh->ptr; - -@@@{ - $indent = "\t"; - typeswitch '_common_','timeval'; -@@@} - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - ENOENT, - "no such attribute")); -} - - -const -edg_wlc_JobId -get_val_jobid(edg_wll_JobStat const *cstat, JobStatus::Attr attr) -{ -@@@{ - $indent = "\t"; - typeswitch '_common_','jobid'; -@@@} - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - ENOENT, - "no such attribute")); - return 0; /* make gcc shut up -- never returns */ -} - - -const -glite::wmsutils::jobid::JobId -JobStatus::getValJobId(Attr attr) const -{ - edg_wll_JobStat const *cstat = (edg_wll_JobStat *) flesh->ptr; - - try { - edg_wlc_JobId job_id = get_val_jobid(cstat, attr); - return(glite::wmsutils::jobid::JobId(job_id)); - } - catch(Exception &e) { - STACK_ADD; - throw; - } -} - -const -int * -get_val_intlist(edg_wll_JobStat const *cstat, JobStatus::Attr attr) -{ -@@@{ - $indent = "\t"; - typeswitch '_common_','intlist'; -@@@} - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - ENOENT, - "no such attribute")); - return 0; /* make gcc shut up -- never returns */ -} - - -const -std::vector -JobStatus::getValIntList(Attr attr) const -{ - edg_wll_JobStat const *cstat = (edg_wll_JobStat *) flesh->ptr; - - std::vector result; - const int *r; - - try { - r = get_val_intlist(cstat, attr); - if(r) - for(int i = 1; i <= r[0]; i++) - result.push_back(r[i]); - } catch(Exception &e) { - STACK_ADD; - throw; - } - return result; -} - - -char ** const -get_val_stringlist(edg_wll_JobStat const *cstat, JobStatus::Attr attr) -{ -@@@{ - $indent = "\t"; - typeswitch '_common_','strlist'; -@@@} - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - ENOENT, - "no such attribute")); - return 0; /* make gcc shut up -- never returns */ -} - - -const -std::vector -JobStatus::getValStringList(Attr attr) const -{ - edg_wll_JobStat const *cstat = (edg_wll_JobStat *) flesh->ptr; - - std::vector result; - char **r , **p; - - try { - r = (char**)get_val_stringlist(cstat, attr); - if(r) - for(p = r; *p; p++) - result.push_back(std::string(*p)); - } catch(Exception &e) { - STACK_ADD; - throw; - } - return result; -} - - -edg_wll_TagValue * const -get_val_taglist(edg_wll_JobStat const *cstat, JobStatus::Attr attr) -{ -@@@{ - $indent = "\t"; - typeswitch '_common_','taglist'; -@@@} - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - ENOENT, - "no such attribute")); - return 0; /* make gcc shut up -- never returns */ -} - - -const -std::vector > -JobStatus::getValTagList(Attr attr) const -{ - edg_wll_JobStat const *cstat = (edg_wll_JobStat *) flesh->ptr; - - std::vector > result; - edg_wll_TagValue *r , *p; - - try { - r = get_val_taglist(cstat, attr); - if(r) - for(p = r; p->tag ; p++) - result.push_back(std::pair - (std::string(p->tag),std::string(p->value))); - } catch(Exception &e) { - STACK_ADD; - throw; - } - return result; -} - - -const -edg_wll_JobStat * -get_val_stslist(edg_wll_JobStat const *cstat, JobStatus::Attr attr) -{ -@@@{ - $indent = "\t"; - typeswitch '_common_','stslist'; -@@@} - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - ENOENT, - "no such attribute")); - return 0; /* make gcc shut up -- never returns */ -} - - -const -std::vector -JobStatus::getValJobStatusList(Attr attr) const -{ - edg_wll_JobStat const *cstat = (edg_wll_JobStat *) flesh->ptr; - - std::vector result; - const edg_wll_JobStat *r, *p; - - try { - r = get_val_stslist(cstat, attr); - if(r) - for(p=r; p->state != EDG_WLL_JOB_UNDEF; p++) { - edg_wll_JobStat *jsep = new edg_wll_JobStat; - if (!edg_wll_CpyStatus(p,jsep)) { - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - ENOMEM, - "cannot copy edg_wll_JobStat")); - } - result.push_back(JobStatus(*jsep)); - } - } catch(Exception &e) { - STACK_ADD; - throw; - } - return(result); -} - - -static std::string const attr_names[JobStatus::ATTR_MAX] = { -@@@{ - for (sort {$a cmp $b} getAllFields $status) { - gen "\t\"$_\",\n"; - } -@@@} -}; - -const std::string & -JobStatus::getAttrName(JobStatus::Attr attr) const -{ - if (attr<0 || attr>=ATTR_MAX) { - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - ENOENT, - "no such attribute")); - } - - return attr_names[attr]; -} - - -typedef std::pair tpair; -static std::vector attrs; - -static bool attrs_inited = false; - -static void init_attrs(void) -{ -/* XXX: currently only common attributes in JobStatus */ -@@@{ - selectType $status '_common_'; - for (getFields $status) { - my $fu = $_; - my $f = selectField $status $_; - my $ftu = uc "$f->{type}_T"; - $fu =~ s/([a-z])([A-Z])/$1_$2/g; - $fu = uc $fu; - - gen "\tattrs.push_back(tpair(JobStatus::$fu,JobStatus::$ftu));\n"; - } -@@@} -} - - -const std::vector& -JobStatus::getAttrs(void) const -{ - if (status<0 || status>=CODE_MAX) { - STACK_ADD; - throw(Exception(EXCEPTION_MANDATORY, - EINVAL, - "status code invalid")); - } - -/* FIXME: thread safety */ - if (!attrs_inited) { - init_attrs(); - attrs_inited = true; - } - return attrs; -} - -void -JobStatus::destroyFlesh(void *p) -{ - edg_wll_JobStat *stat = (edg_wll_JobStat *) p; - if (stat) { - edg_wll_FreeStatus(stat); - free(stat); - } -} - -EWL_END_NAMESPACE; diff --git a/org.glite.lb.client/src/Notification.cpp b/org.glite.lb.client/src/Notification.cpp deleted file mode 100644 index 0441626..0000000 --- a/org.glite.lb.client/src/Notification.cpp +++ /dev/null @@ -1,340 +0,0 @@ -#ident "$Header$" - -/** - * @file Notification.cpp - * @version $Revision$ - */ - -#include -#include -#include - -#include -#include - -#include "glite/lb/Notification.h" -#include "glite/lb/JobStatus.h" -#include "glite/lb/LoggingExceptions.h" -#include "glite/lb/ServerConnection.h" - -#include "glite/lb/notifid.h" -#include "glite/lb/notification.h" - -EWL_BEGIN_NAMESPACE; - -#define CLASS_PREFIX "glite::lb::Notification::" - -/* external prototypes */ -extern edg_wll_QueryRec ** -convertQueryVectorExt(const std::vector > &); - -extern void -freeQueryRecVector(edg_wll_QueryRec *); - -/* Constructors */ -Notification::Notification(void) -{ - try { - int ret = edg_wll_InitContext(&this->ctx); - check_result(ret,this->ctx,"edg_wll_InitContext"); - this->notifId = NULL; - this->valid = 0; - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - -Notification::Notification(const std::string notifid_str) -{ - try { - char *host; - unsigned int port; - int ret = edg_wll_InitContext(&this->ctx); - check_result(ret,this->ctx,"edg_wll_InitContext"); - ret = edg_wll_NotifIdParse(notifid_str.c_str(),&this->notifId); - check_result(ret,this->ctx,"edg_wll_NotifIdParse"); - edg_wll_NotifIdGetServerParts(this->notifId,&host,&port); - edg_wll_SetParam(this->ctx, EDG_WLL_PARAM_NOTIF_SERVER, host); - edg_wll_SetParam(this->ctx, EDG_WLL_PARAM_NOTIF_SERVER_PORT, port); - free(host); - this->valid = 0; - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - -Notification::Notification(const std::string host,const u_int16_t port) -{ - try { - int ret = edg_wll_InitContext(&ctx); - check_result(ret,ctx,"edg_wll_InitContext"); - edg_wll_SetParam(ctx, EDG_WLL_PARAM_NOTIF_SERVER, host.c_str()); - edg_wll_SetParam(ctx, EDG_WLL_PARAM_NOTIF_SERVER_PORT, port); - this->notifId = NULL; - this->valid = 0; - check_result(ret,ctx,"edg_wll_NotifIdCreate"); - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - -/* Destructor */ -Notification::~Notification(void) -{ - try { - edg_wll_FreeContext(this->ctx); - edg_wll_NotifIdFree(this->notifId); - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - -/* Methods */ -std::string -Notification::getNotifId(void) const -{ - try { - std::string notifid_str; - if (this->notifId != NULL) { - notifid_str = edg_wll_NotifIdUnparse(this->notifId); - return(notifid_str); - } else { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "notifId not known at the moment"); - } - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - -time_t -Notification::getValid(void) const -{ - return(this->valid); -} - -int -Notification::getFd(void) const -{ - try { - int ret = edg_wll_NotifGetFd(this->ctx); - check_result(ret,this->ctx,"edg_wll_NotifGetFd"); - return(ret); - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - -void -Notification::addJob(const glite::wmsutils::jobid::JobId &jobId) -{ - std::vector::iterator it; - - try { - if (this->notifId != NULL) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "adding jobs allowed only before registering"); - } - for( it = jobs.begin(); it != jobs.end(); it++ ) { - if ( (*it).toString() == jobId.toString() ) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "job already exists"); - } - } - jobs.push_back(jobId); - - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - -void -Notification::removeJob(const glite::wmsutils::jobid::JobId &jobId) -{ - std::vector::iterator it; - int removed = 0; - - try { - if (this->notifId != NULL) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "removing jobs allowed only before registering"); - } - for( it = jobs.begin(); it != jobs.end(); it++ ) { - if ( (*it).toString() == jobId.toString() ) { - jobs.erase(it); - removed += 1; -// break; - } - } - } catch (Exception &e) { - STACK_ADD; - throw; - } - - if (removed == 0) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "no job to remove"); - } -} - -/* XXX: obsolete, used only for debugging purposes */ - -std::string -Notification::getJobs(void) -{ - std::vector::iterator it; - std::string ret=""; - - try { - for( it = jobs.begin(); it != jobs.end(); it++ ) { - ret += (*it).toString(); - ret += "\n"; - } - return ret; - - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - -void -Notification::setStates(const std::vector &jobStates) -{ - if (this->notifId != NULL) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "removing jobs allowed only before registering"); - } - states = jobStates; -} - -std::string -Notification::getStates(void) -{ - std::vector::iterator it; - JobStatus js; - std::string ret=""; - - try { - for( it = states.begin(); it != states.end(); it++ ) { - js.status = (*it); - ret += js.name(); - ret += "\n"; - } - return ret; - - } catch (Exception &e) { - STACK_ADD; - throw; - } -} - -void -Notification::Register(void) -{ - int ret = 0; - std::vector::iterator it; - std::vector::iterator its; - std::vector > queryExt; - edg_wll_QueryRec **conditions = NULL; - unsigned i; - - try { - if (this->notifId != NULL) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "registering job allowed only once"); - } - /* fill in the query: */ - std::vector query; - for( it = jobs.begin(); it != jobs.end(); it++ ) { - QueryRecord r0(QueryRecord::JOBID,QueryRecord::EQUAL,*it); - query.push_back(r0); - } - queryExt.push_back(query); - query.clear(); - - for( its = states.begin(); its != states.end(); its++ ) { - QueryRecord r(QueryRecord::STATUS,QueryRecord::EQUAL,*its); - query.push_back(r); - } - queryExt.push_back(query); - - /* convert query to conditions */ - conditions = convertQueryVectorExt(queryExt); - /* register */ - ret = edg_wll_NotifNew(ctx,conditions,-1,NULL,¬ifId,&valid); - check_result(ret,ctx,"edg_wll_NotifNew"); - /* clean */ - if (conditions) { - for( i = 0; conditions[i]; i++ ) { -// FIXME: not working :o( -// freeQueryRecVector(conditions[i]); - delete[] conditions[i]; - } - delete[] conditions; - } - } catch (Exception &e) { - /* clean */ - if (conditions) { - for( i = 0; conditions[i]; i++ ) { -// FIXME: not working :o( -// freeQueryRecVector(conditions[i]); - delete[] conditions[i]; - } - delete[] conditions; - } - STACK_ADD; - throw; - } -} - -void -Notification::Bind(const std::string address_override) -{ - try { - if (this->notifId == NULL) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "binding allowed only for given notifId"); - } - int ret = edg_wll_NotifBind(this->ctx,this->notifId,-1,address_override.c_str(),&this->valid); - check_result(ret,this->ctx,"edg_wll_NotifBind"); - } - catch (Exception &e) { - STACK_ADD; - throw; - } -} - - - - -int Notification::receive(glite::lb::JobStatus &jobStatus,timeval &timeout) -{ - try { - int ret = 0; - edg_wll_JobStat *status = (edg_wll_JobStat *) calloc(1,sizeof(edg_wll_JobStat)); - if (status == NULL) { - STACK_ADD; - throw OSException(EXCEPTION_MANDATORY, ENOMEM, "allocating jobStatus"); - } - ret = edg_wll_NotifReceive(ctx,-1,&timeout,status,¬ifId); - if ( ret == ETIMEDOUT ) - return 1; - check_result(ret,ctx,"edg_wll_NotifReceive"); - jobStatus = JobStatus(*status); - return 0; - } - catch (Exception &e) { - STACK_ADD; - throw; - } -} - -EWL_END_NAMESPACE; diff --git a/org.glite.lb.client/src/ServerConnection.cpp b/org.glite.lb.client/src/ServerConnection.cpp deleted file mode 100644 index 319bd0f..0000000 --- a/org.glite.lb.client/src/ServerConnection.cpp +++ /dev/null @@ -1,1302 +0,0 @@ -//#ident "$Header$" - -/** - * @file ServerConnection.cpp - * @version $Revision$ - */ -#include -#include -#include - -#include -#include -#include - -#include - -#include "glite/wmsutils/jobid/JobId.h" -#include "glite/wmsutils/jobid/JobIdExceptions.h" -#include "glite/lb/context-int.h" -#include "glite/lb/xml_conversions.h" - -#include "glite/lb/ServerConnection.h" -#include "glite/lb/LoggingExceptions.h" - -EWL_BEGIN_NAMESPACE; - -/** - * definitions of QueryRecord class - */ -#define CLASS_PREFIX "glite::lb::QueryRecord::" - - -QueryRecord::QueryRecord(const Attr a, - const Op o, - const std::string & v) - : attr(a), oper(o), state(EDG_WLL_JOB_UNDEF), string_value(v) -{ - switch(a) { - case OWNER: - case LOCATION: - case DESTINATION: - case HOST: - case INSTANCE: - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "invalid value for attribute: " + v); - } -} - - -QueryRecord::QueryRecord(const Attr a, - const Op o, - const int v) - : attr(a), oper(o), state(EDG_WLL_JOB_UNDEF), int_value(v) -{ - switch(a) { - case DONECODE: - case STATUS: - case SOURCE: - case EVENT_TYPE: - case LEVEL: - case EXITCODE: - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "attribute is not of integer type"); - } -} - - -QueryRecord::QueryRecord(const Attr a, - const Op o, - const struct timeval& v) - : attr(a), oper(o), state(EDG_WLL_JOB_UNDEF), timeval_value(v) -{ - switch(a) { - case TIME: - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "attribute is not of timeval type"); - } -} - - -QueryRecord::QueryRecord(const Attr a, - const Op o, - const glite::wmsutils::jobid::JobId& v) - : attr(a), oper(o), state(EDG_WLL_JOB_UNDEF), jobid_value(v) -{ - switch(a) { - case JOBID: - case PARENT: - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "attribute is not of JobId type"); - } -} - - -QueryRecord::QueryRecord(const Attr a, - const Op o, - const int s, - const struct timeval &v) - : attr(a), oper(o), state(s), timeval_value(v) -{ - switch(a) { - case TIME: - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "attribute is not of timeval type"); - } -} - - -QueryRecord::QueryRecord(const Attr a, - const Op o, - const std::string &v1, - const std::string &v2) - : attr(a), oper(o), state(EDG_WLL_JOB_UNDEF), string_value(v1), string_value2(v2) -{ - switch(a) { - case OWNER: - case LOCATION: - case DESTINATION: - case HOST: - case INSTANCE: - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "invalid value for attribute type"); - } - if(o != WITHIN) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "only operator WITHIN allowed with two values"); - } -} - - -QueryRecord::QueryRecord(const Attr a, - const Op o, - const int v1, - const int v2) - : attr(a), oper(o), state(EDG_WLL_JOB_UNDEF), int_value(v1), int_value2(v2) -{ - switch(a) { - case DONECODE: - case STATUS: - case SOURCE: - case EVENT_TYPE: - case LEVEL: - case EXITCODE: - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "attribute is not of integer type"); - } - if(o != WITHIN) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "only operator WITHIN allowed with two values"); - } -} - - -QueryRecord::QueryRecord(const Attr a, - const Op o, - const struct timeval &v1, - const struct timeval &v2) - : attr(a), oper(o), state(EDG_WLL_JOB_UNDEF), timeval_value(v1), timeval_value2(v2) -{ - switch(a) { - case TIME: - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "attribute is not of timeval type"); - } - if(o != WITHIN) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "only operator WITHIN allowed with two values"); - } -} - - -QueryRecord::QueryRecord(const Attr a, - const Op o, - const int s, - const struct timeval &v1, - const struct timeval &v2) - : attr(a), oper(o), state(s), timeval_value(v1), timeval_value2(v2) -{ - switch(a) { - case TIME: - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "attribute is not of timeval type"); - } - if(o != WITHIN) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "only operator WITHIN allowed with two values"); - } -} - - -QueryRecord::QueryRecord(const std::string &tag, - const Op o, - const std::string &val) - : attr(USERTAG), oper(o), tag_name(tag), state(EDG_WLL_JOB_UNDEF), string_value(val) -{ -} - - -QueryRecord::QueryRecord(const std::string &tag, - const Op o, - const std::string &v1, - const std::string &v2) - : attr(USERTAG), oper(o), tag_name(tag), state(EDG_WLL_JOB_UNDEF), - string_value(v1), string_value2(v2) - -{ - if(o != WITHIN) { - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "only operator WITHIN allowed with two values"); - } -} - - -QueryRecord::QueryRecord(const QueryRecord &src) -{ - attr = src.attr; - oper = src.oper; - - switch (attr) { - - case USERTAG: - tag_name = src.tag_name; - - case OWNER: - case LOCATION: - case DESTINATION: - case HOST: - case INSTANCE: - string_value = src.string_value; - if(src.oper == WITHIN) - string_value2 = src.string_value2; - break; - - case DONECODE: - case STATUS: - case SOURCE: - case EVENT_TYPE: - case LEVEL: - case EXITCODE: - int_value = src.int_value; - if(src.oper == WITHIN) - int_value2 = src.int_value2; - break; - - case TIME: - timeval_value = src.timeval_value; - if(src.oper == WITHIN) - timeval_value2 = src.timeval_value2; - state = src.state; - break; - - case JOBID: - jobid_value = src.jobid_value; - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "query attribute not defined"); - } -} - - -QueryRecord::QueryRecord() : attr(UNDEF), oper(EQUAL) -{ -} - - -QueryRecord::~QueryRecord() -{ -} - - -QueryRecord& -QueryRecord::operator=(const QueryRecord &src) -{ - if(this == &src) - return(*this); - - attr = src.attr; - oper = src.oper; - - switch (attr) { - - case USERTAG: - tag_name = src.tag_name; - - case OWNER: - case LOCATION: - case DESTINATION: - case HOST: - case INSTANCE: - string_value = src.string_value; - if(oper == WITHIN) - string_value2 = src.string_value2; - break; - - case DONECODE: - case STATUS: - case SOURCE: - case EVENT_TYPE: - case LEVEL: - case EXITCODE: - int_value = src.int_value; - if(oper == WITHIN) - int_value2 = src.int_value2; - break; - - case TIME: - timeval_value = src.timeval_value; - state = src.state; - if(oper == WITHIN) - timeval_value2 = src.timeval_value2; - break; - - case JOBID: - jobid_value = src.jobid_value; - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "query attribute not defined"); - } - - return *this; -} - - -QueryRecord::operator edg_wll_QueryRec() const -{ - edg_wll_QueryRec out; - - out.attr = edg_wll_QueryAttr(attr); - out.op = edg_wll_QueryOp(oper); - - switch (attr) { - - case USERTAG: - out.attr_id.tag = strdup(tag_name.c_str()); - - case OWNER: - case LOCATION: - case DESTINATION: - case HOST: - case INSTANCE: - out.value.c = strdup(string_value.c_str()); - if(oper == WITHIN) - out.value2.c = strdup(string_value2.c_str()); - break; - - - case DONECODE: - case STATUS: - case SOURCE: - case EVENT_TYPE: - case LEVEL: - case EXITCODE: - out.value.i = int_value; - if(oper == WITHIN) - out.value2.i = int_value2; - break; - - case TIME: - out.value.t = timeval_value; - out.attr_id.state = (edg_wll_JobStatCode)state; - if(oper == WITHIN) - out.value2.t = timeval_value2; - break; - - case JOBID: - out.value.j = jobid_value; - break; - - case UNDEF: - break; - - default: - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, EINVAL, "query attribute not defined"); - } - - return(out); -} - -const std::string QueryRecord::AttrName(const QueryRecord::Attr attr) -{ - char *an = edg_wll_query_attrToString(edg_wll_QueryAttr(attr)); - std::string ret(an); - free(an); - return ret; -} - - -/** - * definitions of ServerConnection class - */ -#undef CLASS_PREFIX -#define CLASS_PREFIX "glite::lb::ServerConnection::" - -ServerConnection::ServerConnection() -{ - int ret; - edg_wll_Context tmp_context; - - if((ret=edg_wll_InitContext(&tmp_context)) < 0) { - STACK_ADD; - throw OSException(EXCEPTION_MANDATORY, ret, "initializing context"); - } - - context = tmp_context; -} - - -ServerConnection::~ServerConnection() -{ - /* no exceptions should be thrown from destructors */ - edg_wll_FreeContext(context); -} - - -/********************/ -/* BEGIN DEPRECATED */ - -ServerConnection::ServerConnection(const std::string &in) -{ - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, 0, "method deprecated"); -} - - -void -ServerConnection::open(const std::string & in) -{ - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, 0, "method deprecated"); -} - - -void -ServerConnection::close(void) -{ - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, 0, "method deprecated"); -} - -/* END DEPRECATED */ -/******************/ - - -void -ServerConnection::setQueryServer(const std::string& server, int port) -{ - check_result(edg_wll_SetParamString(context, - EDG_WLL_PARAM_QUERY_SERVER, - server.c_str()), - context, - "setting query server address"); - check_result(edg_wll_SetParamInt(context, - EDG_WLL_PARAM_QUERY_SERVER_PORT, - port), - context, - "setting query server port"); -} - - -void -ServerConnection::setQueryTimeout(int timeout) -{ - check_result(edg_wll_SetParamInt(context, - EDG_WLL_PARAM_QUERY_TIMEOUT, - timeout), - context, - "setting query timeout"); -} - - -void ServerConnection::setX509Proxy(const std::string& proxy) -{ - check_result(edg_wll_SetParamString(context, - EDG_WLL_PARAM_X509_PROXY, - proxy.c_str()), - context, - "setting X509 proxy"); -} - - -void ServerConnection::setX509Cert(const std::string& cert, const std::string& key) -{ - check_result(edg_wll_SetParamString(context, - EDG_WLL_PARAM_X509_CERT, - cert.c_str()), - context, - "setting X509 certificate"); - check_result(edg_wll_SetParamString(context, - EDG_WLL_PARAM_X509_KEY, - key.c_str()), - context, - "setting X509 key"); -} - - -void -ServerConnection::setQueryEventsLimit(int max) { - check_result(edg_wll_SetParamInt(context, - EDG_WLL_PARAM_QUERY_EVENTS_LIMIT, - max), - context, - "setting query events limit"); -} - -void -ServerConnection::setQueryJobsLimit(int max) { - check_result(edg_wll_SetParamInt(context, - EDG_WLL_PARAM_QUERY_JOBS_LIMIT, - max), - context, - "setting query jobs limit"); -} - - -std::pair -ServerConnection::getQueryServer() const -{ - /* FIXME: not implemented in C API */ - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, 0, "method not implemented"); -} - - -int -ServerConnection::getQueryTimeout() const -{ - /* FIXME: not implemented in C API */ - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, 0, "method not implemented"); -} - - -std::string -ServerConnection::getX509Proxy() const -{ - /* FIXME: not implemented in C API */ - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, 0, "method not implemented"); -} - - -std::pair -ServerConnection::getX509Cert() const -{ - /* FIXME: not implemented in C API */ - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, 0, "method not implemented"); -} - -// static -void freeQueryRecVector(edg_wll_QueryRec *v) -{ - for(; v->attr != EDG_WLL_QUERY_ATTR_UNDEF; v++) - edg_wll_QueryRecFree(v); -} - -std::vector > > -ServerConnection::getIndexedAttrs(void) { - edg_wll_QueryRec **recs; - int i,j; - std::vector > > out; - - check_result(edg_wll_GetIndexedAttrs(context,&recs),context, - "edg_wll_GetIndexedAttrs()"); - - if (!recs) return out; - - for (i=0; recs[i]; i++) { - std::vector > idx; - for (j=0; recs[i][j].attr; j++) { - char *s = strdup(""); - if (recs[i][j].attr == EDG_WLL_QUERY_ATTR_USERTAG) - s = strdup(recs[i][j].attr_id.tag); - else if (recs[i][j].attr == EDG_WLL_QUERY_ATTR_TIME) - s = edg_wll_StatToString(recs[i][j].attr_id.state); - idx.push_back( - std::pair( - QueryRecord::Attr(recs[i][j].attr),s) - ); - free(s); - } - freeQueryRecVector(recs[i]); - out.push_back(idx); - } - free(recs); - return out; -} - - - - -edg_wll_QueryRec * -convertQueryVector(const std::vector &in) -{ - unsigned i; - edg_wll_QueryRec *out = new edg_wll_QueryRec[in.size() + 1]; - QueryRecord empty; - - if(out == NULL) { - STACK_ADD; - throw OSException(EXCEPTION_MANDATORY, ENOMEM, "allocating vector for conversion"); - } - - try { - for(i = 0; i < in.size(); i++) { - out[i] = in[i]; - } - out[i] = empty; - } catch (Exception &e) { - STACK_ADD; - throw; - } - return(out); -} - - -edg_wll_QueryRec ** -convertQueryVectorExt(const std::vector > &in) -{ - unsigned i; - edg_wll_QueryRec **out = new (edg_wll_QueryRec*)[in.size() + 1]; - - if(out == NULL) { - STACK_ADD; - throw OSException(EXCEPTION_MANDATORY, ENOMEM, "allocating vector for conversion"); - } - - try { - for(i = 0; i < in.size(); i++) { - out[i] = convertQueryVector(in[i]); - } - out[i] = NULL; - } catch (Exception &e) { - STACK_ADD; - throw; - } - return(out); -} - -void -ServerConnection::queryEvents(const std::vector& job_cond, - const std::vector& event_cond, - std::vector & eventList) const -{ - edg_wll_QueryRec *job_rec = NULL, *event_rec = NULL; - edg_wll_Event *events = NULL; - unsigned i; - int result, qresults_param; - char *errstr = NULL; - - /* convert input */ - try { - job_rec = convertQueryVector(job_cond); - event_rec = convertQueryVector(event_cond); - - /* do the query */ - - result = edg_wll_QueryEvents(context, job_rec, event_rec, &events); - if (result == E2BIG) { - edg_wll_Error(context, NULL, &errstr); - check_result(edg_wll_GetParam(context, - EDG_WLL_PARAM_QUERY_RESULTS, &qresults_param), - context, - "edg_wll_GetParam(EDG_WLL_PARAM_QUERY_RESULTS)"); - if (qresults_param != EDG_WLL_QUERYRES_LIMITED) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryEvents"); - } - } else { - check_result(result, context,"edg_wll_QueryEvents"); - } - - /* convert output */ - for (i=0; events[i].type != EDG_WLL_EVENT_UNDEF; i++) { - edg_wll_Event *ev = (edg_wll_Event *) malloc(sizeof *ev); - memcpy(ev,events+i,sizeof *ev); - Event e(ev); - - eventList.push_back(e); - } - - if (result) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryEvents"); - } - - free(events); - delete[] job_rec; - delete[] event_rec; - - } catch(Exception &e) { - if(job_rec) delete[] job_rec; - if(event_rec) delete[] event_rec; - if(events) free(events); - if(errstr) free(errstr); - - STACK_ADD; - throw; - } -} - - -const std::vector -ServerConnection::queryEvents(const std::vector& job_cond, - const std::vector& event_cond) const -{ - std::vector eventList; - - queryEvents(job_cond, event_cond,eventList); - return eventList; -} - -const std::list -ServerConnection::queryEventsList(const std::vector& job_cond, - const std::vector& event_cond) const -{ - std::vector events; - - queryEvents(job_cond, event_cond, events); - return std::list(events.begin(),events.end()); -} - -std::string -ServerConnection::queryEventsAggregate(const std::vector& job_cond, - const std::vector& event_cond, - enum AggOp const op, - std::string const attr) const -{ - STACK_ADD; - throw Exception(EXCEPTION_MANDATORY, 0, "method not implemented"); - return ""; // gcc warning; -} - - -void -ServerConnection::queryEvents(const std::vector >& job_cond, - const std::vector >& event_cond, - std::vector& eventList) const -{ - edg_wll_QueryRec **job_rec = NULL, **event_rec = NULL; - edg_wll_Event *events = NULL; - unsigned i; - - /* convert input */ - try { - job_rec = convertQueryVectorExt(job_cond); - event_rec = convertQueryVectorExt(event_cond); - - /* do the query */ - - check_result(edg_wll_QueryEventsExt(context, - (const edg_wll_QueryRec**)job_rec, - (const edg_wll_QueryRec**)event_rec, - &events), - context, - "edg_wll_QueryEvents"); - - /* convert output */ - for (i=0; events[i].type != EDG_WLL_EVENT_UNDEF; i++) { - edg_wll_Event *ev = (edg_wll_Event *) malloc(sizeof *ev); - memcpy(ev,events+i,sizeof *ev); - Event e(ev); - - eventList.push_back(e); - } - - free(events); - - for(i = 0 ; job_rec[i]; i++) delete[] job_rec[i]; - for(i = 0 ; event_rec[i]; i++) delete[] event_rec[i]; - delete[] job_rec; - delete[] event_rec; - - } catch(Exception &e) { - - if(job_rec) { - for(i = 0 ; job_rec[i]; i++) delete[] job_rec[i]; - delete[] job_rec; - } - if(event_rec) { - for(i = 0 ; event_rec[i]; i++) delete[] event_rec[i]; - delete[] event_rec; - } - if(events) free(events); - - STACK_ADD; - throw; - } -} - - -const std::vector -ServerConnection::queryEvents(const std::vector >& job_cond, - const std::vector >& event_cond) const -{ - std::vector eventList; - - queryEvents(job_cond, event_cond,eventList); - return eventList; -} - - -void ServerConnection::queryJobs(const std::vector& query, - std::vector & ids) const -{ - edg_wll_QueryRec *cond = NULL; - edg_wlc_JobId *jobs, *j; - int result, qresults_param; - char *errstr = NULL; - - try { - cond = convertQueryVector(query); - - result = edg_wll_QueryJobs(context, cond, 0, &jobs, NULL); - if (result == E2BIG) { - edg_wll_Error(context, NULL, &errstr); - check_result(edg_wll_GetParam(context, - EDG_WLL_PARAM_QUERY_RESULTS, &qresults_param), - context, - "edg_wll_GetParam(EDG_WLL_PARAM_QUERY_RESULTS)"); - if (qresults_param != EDG_WLL_QUERYRES_LIMITED) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryJobs"); - } - } else { - check_result(result, context,"edg_wll_QueryJobs"); - } - - for(j = jobs; *j; j++) - ids.push_back(glite::wmsutils::jobid::JobId(*j)); - - if (result) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryJobs"); - } - - free(jobs); - freeQueryRecVector(cond); - delete[] cond; - - } catch (Exception &e) { - if(cond) { - freeQueryRecVector(cond); - delete[] cond; - } - if (errstr) free(errstr); - - STACK_ADD; - throw; - } -} - - -const std::vector -ServerConnection::queryJobs(const std::vector& query) const -{ - std::vector jobList; - - queryJobs(query, jobList); - return jobList; -} - - -void -ServerConnection::queryJobs(const std::vector >& query, - std::vector& ids) const -{ - edg_wll_QueryRec **cond = NULL; - edg_wlc_JobId *jobs, *j; - int result, qresults_param; - char *errstr = NULL; - - try { - cond = convertQueryVectorExt(query); - - result = edg_wll_QueryJobsExt(context, (const edg_wll_QueryRec**)cond, - 0, &jobs, NULL); - if (result == E2BIG) { - edg_wll_Error(context, NULL, &errstr); - check_result(edg_wll_GetParam(context, - EDG_WLL_PARAM_QUERY_RESULTS, &qresults_param), - context, - "edg_wll_GetParam(EDG_WLL_PARAM_QUERY_RESULTS)"); - if (qresults_param != EDG_WLL_QUERYRES_LIMITED) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryJobsExt"); - } - } else { - check_result(result, context,"edg_wll_QueryJobsExt"); - } - - for(j = jobs; *j; j++) - ids.push_back(glite::wmsutils::jobid::JobId(*j)); - - if (result) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryJobsExt"); - } - - free(jobs); - { - unsigned i; - - for(i = 0; cond[i]; i++) { - freeQueryRecVector(cond[i]); - delete[] cond[i]; - } - delete[] cond; - } - - } catch (Exception &e) { - unsigned i; - if(cond) { - for(i = 0; cond[i]; i++) { - freeQueryRecVector(cond[i]); - delete[] cond[i]; - } - delete[] cond; - } - if (errstr) free(errstr); - - STACK_ADD; - throw; - } -} - - -const -std::vector -ServerConnection::queryJobs(const std::vector >& query) const -{ - std::vector jobList; - - queryJobs(query, jobList); - return jobList; -} - - -void -ServerConnection::queryJobStates(const std::vector& query, - int flags, - std::vector & states) const -{ - edg_wll_QueryRec *cond = NULL; - edg_wll_JobStat *jobs, *j; - int result, qresults_param; - char *errstr = NULL; - - try { - cond = convertQueryVector(query); - - result = edg_wll_QueryJobs(context, cond, flags, NULL, &jobs); - if (result == E2BIG) { - edg_wll_Error(context, NULL, &errstr); - check_result(edg_wll_GetParam(context, - EDG_WLL_PARAM_QUERY_RESULTS, &qresults_param), - context, - "edg_wll_GetParam(EDG_WLL_PARAM_QUERY_RESULTS)"); - if (qresults_param != EDG_WLL_QUERYRES_LIMITED) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryJobs"); - } - } else { - check_result(result, context,"edg_wll_QueryJobs"); - } - - for(j = jobs; j->state != EDG_WLL_JOB_UNDEF; j++) { - edg_wll_JobStat *jsep = new edg_wll_JobStat; - if (jsep != NULL) { - memcpy(jsep, j, sizeof(*j)); - states.push_back(JobStatus(*jsep)); - } - } - - if (result) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryJobs"); - } - - delete jobs; - - freeQueryRecVector(cond); - delete[] cond; - - } catch (Exception &e) { - if(cond) { - freeQueryRecVector(cond); - delete[] cond; - } - if (errstr) free(errstr); - - STACK_ADD; - throw; - } -} - - -const std::vector -ServerConnection::queryJobStates(const std::vector& query, - int flags) const -{ - std::vector states; - - queryJobStates(query, flags, states); - return(states); -} - -const std::list -ServerConnection::queryJobStatesList(const std::vector& query, - int flags) const -{ - std::vector states; - - queryJobStates(query, flags, states); - return std::list(states.begin(),states.end()); -} - - -void -ServerConnection::queryJobStates(const std::vector >& query, - int flags, - std::vector & states) const -{ - edg_wll_QueryRec **cond = NULL; - edg_wll_JobStat *jobs, *j; - int result, qresults_param; - char *errstr = NULL; - - try { - cond = convertQueryVectorExt(query); - - result = edg_wll_QueryJobsExt(context, (const edg_wll_QueryRec**)cond, - flags, NULL, &jobs); - if (result == E2BIG) { - edg_wll_Error(context, NULL, &errstr); - check_result(edg_wll_GetParam(context, - EDG_WLL_PARAM_QUERY_RESULTS, &qresults_param), - context, - "edg_wll_GetParam(EDG_WLL_PARAM_QUERY_RESULTS)"); - if (qresults_param != EDG_WLL_QUERYRES_LIMITED) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryJobsExt"); - } - } else { - check_result(result, context,"edg_wll_QueryJobsExt"); - } - - for(j = jobs; j->state != EDG_WLL_JOB_UNDEF; j++) { - edg_wll_JobStat *jsep = new edg_wll_JobStat; - if (jsep != NULL) { - memcpy(jsep, j, sizeof(*j)); - states.push_back(JobStatus(*jsep)); - } - } - - if (result) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryJobsExt"); - } - - delete jobs; - - { - unsigned i; - - for(i = 0; cond[i]; i++) { - freeQueryRecVector(cond[i]); - delete[] cond[i]; - } - delete[] cond; - } - - - } catch (Exception &e) { - unsigned i; - if(cond) { - for(i = 0; cond[i]; i++) { - freeQueryRecVector(cond[i]); - delete[] cond[i]; - } - delete[] cond; - } - if (errstr) free(errstr); - - STACK_ADD; - throw; - } -} - - -const std::vector -ServerConnection::queryJobStates(const std::vector >& query, - int flags) const -{ - std::vector states; - - queryJobStates(query, flags, states); - return(states); -} - - -void ServerConnection::userJobs(std::vector & ids) const -{ - edg_wlc_JobId *jobs, *j; - int result, qresults_param; - char *errstr = NULL; - - try { - result = edg_wll_UserJobs(context, &jobs, NULL); - if (result == E2BIG) { - edg_wll_Error(context, NULL, &errstr); - check_result(edg_wll_GetParam(context, - EDG_WLL_PARAM_QUERY_RESULTS, &qresults_param), - context, - "edg_wll_GetParam(EDG_WLL_PARAM_QUERY_RESULTS)"); - if (qresults_param != EDG_WLL_QUERYRES_LIMITED) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_UserJobs"); - } - } else { - check_result(result, context,"edg_wll_UserJobs"); - } - - for(j = jobs; *j; j++) - ids.push_back(glite::wmsutils::jobid::JobId(*j)); - - if (result) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryJobsExt"); - } - - free(jobs); - - } catch (Exception &e) { - if (errstr) free(errstr); - - STACK_ADD; - throw; - } -} - - -const std::vector -ServerConnection::userJobs() const -{ - std::vector jobList; - - userJobs(jobList); - return jobList; -} - - -void -ServerConnection::userJobStates(std::vector & states) const -{ - edg_wll_JobStat *jobs, *j; - int result, qresults_param; - char *errstr = NULL; - - try { - result = edg_wll_UserJobs(context, NULL, &jobs); - if (result == E2BIG) { - edg_wll_Error(context, NULL, &errstr); - check_result(edg_wll_GetParam(context, - EDG_WLL_PARAM_QUERY_RESULTS, &qresults_param), - context, - "edg_wll_GetParam(EDG_WLL_PARAM_QUERY_RESULTS)"); - if (qresults_param != EDG_WLL_QUERYRES_LIMITED) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_UserJobs"); - } - } else { - check_result(result, context,"edg_wll_UserJobs"); - } - - for(j = jobs; j->state != EDG_WLL_JOB_UNDEF; j++) { - edg_wll_JobStat *jsep = new edg_wll_JobStat; - if (jsep != NULL) { - memcpy(jsep, j, sizeof(*j)); - states.push_back(JobStatus(*jsep)); - } - } - - if (result) { - edg_wll_SetError(context, result, errstr); - check_result(result, context,"edg_wll_QueryJobsExt"); - } - - delete jobs; - - } catch (Exception &e) { - if (errstr) free(errstr); - - STACK_ADD; - throw; - } -} - - -const std::vector -ServerConnection::userJobStates() const -{ - std::vector states; - - userJobStates(states); - return(states); -} - - -edg_wll_Context -ServerConnection::getContext(void) const -{ - return(context); -} - - -void ServerConnection::setParam(edg_wll_ContextParam par, int val) -{ - check_result(edg_wll_SetParamInt(context,par,val), - context, - "edg_wll_SetParamInt()"); -} - -void ServerConnection::setParam(edg_wll_ContextParam par, const std::string val) -{ - check_result(edg_wll_SetParamString(context,par,val.c_str()), - context, - "edg_wll_SetParamString()"); -} - -void ServerConnection::setParam(edg_wll_ContextParam par, const struct timeval & val) -{ - check_result(edg_wll_SetParamTime(context,par,&val), - context, - "edg_wll_SetParamTime()"); -} - -int ServerConnection::getParamInt(edg_wll_ContextParam par) const -{ - int ret; - check_result(edg_wll_GetParam(context,par,&ret), - context, - "edg_wll_GetParam()"); - return ret; -} - -std::string ServerConnection::getParamString(edg_wll_ContextParam par) const -{ - char *ret; - std::string out; - - check_result(edg_wll_GetParam(context,par,&ret), - context, - "edg_wll_GetParam()"); - - out = ret; - free(ret); - return out; -} - -struct timeval ServerConnection::getParamTime(edg_wll_ContextParam par) const -{ - struct timeval ret; - check_result(edg_wll_GetParam(context,par,&ret), - context, - "edg_wll_GetParam()"); - return ret; -} - -EWL_END_NAMESPACE; diff --git a/org.glite.lb.client/src/args.c.T b/org.glite.lb.client/src/args.c.T deleted file mode 100644 index 20defdf..0000000 --- a/org.glite.lb.client/src/args.c.T +++ /dev/null @@ -1,533 +0,0 @@ -/* -@@@AUTO -*/ - -@@@LANG: C - -#include "args.h" -#include "glite/lb/events.h" - -#include -#include -#include -#include -#include -#include -#include -#include - - -typedef struct { - int argc; - char** argv; - const char* help; - int idx; - edg_wll_Args list[1000]; - int last; -} opt_ctx_t; - -/* lists of accepted tags */ -@@@{ - gen "static const char * const eventJobCommon\[] = {"; - selectType $event '_common_'; - for (getFieldsOrdered $event) { - my $f = selectField $event $_; - my $fn = $f->{name}; - gen "\"$fn\", "; - } - gen "NULL };\n"; -@@@} -@@@{ - for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - gen "static const char * const event$t\[] = {"; - selectType $event $t; - for (getFieldsOrdered $event) { - my $f = selectField $event $_; - my $fn = $f->{name}; - gen "\"$fn\", " - } - gen "NULL };\n"; - } -@@@} - -static const char * const * const eventTags[] = { - eventJobCommon, -@@@{ - for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - gen "\tevent$t,\n"; - } - gen "\tNULL\n};\n"; -@@@} - -static int read_bool(const edg_wll_Args* o, char* arg, char* par) -{ - int b = 1; - int rs = 0; - - if (par) - { - if (!strcasecmp(par, "off") || !strcmp(par, "0") - || !strcasecmp(par, "false")) - { - b = 0; - rs = 1; - } - else if (!strcasecmp(par, "on") || !strcmp(par, "1") - || !strcasecmp(par, "true")) - { - rs = 1; - } - } - - if (o->value) - *(int*)o->value = b; - return rs; -} - -static void read_double(const edg_wll_Args* o, char* arg, char* par) -{ - double d; - if (!par) - { - printf("Option: %s - missing double/float value\n", arg); - exit(1); - } - d = atof(par); - if (o->min != o->max) - { - if (d < o->min && d > o->max) - { - printf("Option: %s - value: %f out of range <%d, %d>", - arg, d, o->min, o->max); - exit(1); - } - } - if (o->value) - *(double*)o->value = d; -} - -static void read_string(const edg_wll_Args* o, char* arg, char* par) -{ - if (!par) - { - printf("Option: %s - missing string value\n", arg); - exit(1); - } - if (o->value) - { - if (strstr(arg, "-file")) - { - struct stat buf; - int fd = open(par, O_RDONLY); - if (fd >= 0) - { - char* b; - fstat(fd, &buf); - b = (char*) malloc(buf.st_size); - if (b) - { - int p = 0; - printf("Opened & reading %s %lld\n", - par, (long long)buf.st_size); - while (p < buf.st_size) - { - int r = read(fd, b + p, buf.st_size); - if (r < 0) - break; - p += r; - } - - *(char**)o->value = b; - } - close(fd); - } - else - fprintf(stderr, "can't open file: \"%s\" (%s)\n", par, strerror(errno)); - - } - else - *(char**)o->value = strdup(par); - } -} - -static void read_int(const edg_wll_Args* o, char* arg, char* par) -{ - int v = 0; - if (!par) - { - printf("Option: %s - missing integer value\n", arg); - exit(1); - } - sscanf(par, "%i", &v); - if (o->min != o->max) - { - if (v < o->min && v > o->max) - { - printf("Option: %s - value: %d out of range <%d, %d>", - arg, v, o->min, o->max); - exit(1); - } - } - if (o->value) - *(int*)o->value = v; -} - -static void read_uint16(const edg_wll_Args* o, char* arg, char* par) -{ - int v = 0; - if (!par) - { - printf("Option: %s - missing integer value\n", arg); - exit(1); - } - sscanf(par, "%i", &v); - if (o->min != o->max) - { - if (v < o->min && v > o->max) - { - printf("Option: %s - value: %d out of range <%d, %d>", - arg, v, o->min, o->max); - exit(1); - } - } - if (o->value) - *(u_int16_t*)o->value = v; -} - -static void read_event(const edg_wll_Args* o, char* arg, char* par) -{ - edg_wll_EventCode ec = edg_wll_StringToEvent(par); - if (ec == EDG_WLL_EVENT_UNDEF) - { - if (strcmp(par, "help") == 0) - { - // list type - int i; - printf("Available events: extra options\n"); - for (i = EDG_WLL_EVENT_UNDEF + 1; i < EDG_WLL_EVENT__LAST; i++) - { - char* e = edg_wll_EventToString(i); - if (e) - { - int j = 0; - printf(" %s: ", e); - while (eventTags[i][j]) - printf("%s ", eventTags[i][j++]); - fputc('\n', stdout); - - free(e); - } - } - } - else - fprintf(stderr,"ERROR %s unknown event: %s\n", arg, par); - exit(1); - } - if (o->value) - *(edg_wll_EventCode*)o->value = ec; - -} - -static void read_source(const edg_wll_Args* o, char* arg, char* par) -{ - edg_wll_Source s = edg_wll_StringToSource(par); - if (s == EDG_WLL_SOURCE_NONE) - { - if (strcmp(par, "help") == 0) - { - // list type - int i; - printf("Valid sources:\n"); - for (i = EDG_WLL_SOURCE_NONE + 1; i < EDG_WLL_SOURCE__LAST; i++) - { - char* e = edg_wll_SourceToString(i); - if (e) - { - printf(" %s\n", e); - free(e); - } - } - } - else - fprintf(stderr,"ERROR %s unknown source: %s\n", arg, par); - exit(1); - } - if (o->value) - *(edg_wll_Source*)o->value = s; -} - -static void show_help(const edg_wll_Args* o, int prefix) -{ - unsigned max = 0; - char** l = malloc(sizeof(char*) * 1000); - int li = 0; - unsigned i = 0; - - for (i = 0; o[i].type != EDG_WLL_ARGS_NONE; i++) - { - char b[80]; - unsigned len; - if (o[i].type == EDG_WLL_ARGS_HELP) - sprintf(b, " -h --help"); - else - sprintf(b, " %c%s %s%s", - (o[i].oshort && prefix) ? '-' : ' ', - o[i].oshort ? o[i].oshort : " ", - (o[i].olong && prefix) ? "--" : "", - o[i].olong ? o[i].olong : "" - //opt[i].options ? opt[i].options : "", - //o[i].help ? o[i].help : "" - ); - l[li] = strdup(b); - li++; - len = strlen(b); - if (max < len) - max = len; - } - for (i = 0; o[i].type != EDG_WLL_ARGS_NONE; i++) - { - if (!o[i].oshort && !o[i].olong - && o[i].type != EDG_WLL_ARGS_HELP - && o[i].type != EDG_WLL_ARGS_OPTIONS) - continue; - - if (o[i].type != EDG_WLL_ARGS_OPTIONS) - { - unsigned s; - fputs(l[i], stdout); - for (s = strlen(l[i]); s <= max; s++) - fputc(' ', stdout); - if (o[i].type == EDG_WLL_ARGS_HELP) - fputs("this help message", stdout); - } - - if (o[i].value) - { - switch (o[i].type) - { - case EDG_WLL_ARGS_INT: - if (o[i].help) - printf(o[i].help, *(int*)o[i].value, - o[i].min, o[i].max); - break; - case EDG_WLL_ARGS_STRING: - case EDG_WLL_ARGS_SELECTSTRING: - if (o[i].help) - printf(o[i].help, *(const char**)o[i].value); - break; - case EDG_WLL_ARGS_OPTIONS: - show_help((const edg_wll_Args*)o[i].value, prefix); - continue; - default: - if (o[i].help) - fputs(o[i].help, stdout); - break; - } - } - else if (o[i].help) - fputs(o[i].help, stdout); - - fputs("\n", stdout); - } - while (--li>=0) free(l[li]); - free(l); -} -#if 0 -static void parse_suboptions(const Option* o, const char* oname, char* pars, const char* r) -{ - avm::vector arr; - split(arr, pars); - - if (!arr.size() || strcmp(arr[0], "help") == 0) - { - printf("Available options for '%s' (optA=x:optB=...)\n", oname); - show_help(o, false); - exit(0); - } - for (unsigned i = 0; i < arr.size(); i++) - { - char* par = strchr(arr[i], '='); - if (par) - { - *par = 0; - par++; - } - - for (unsigned j = 0; o[j].type != Args::Option::NONE; j++) - { - if ((o[j].oshort && strcmp(o[j].oshort, arr[i]) == 0) - || (o[j].olong && strcmp(o[j].olong, arr[i]) == 0)) - { - switch(o[j].type) - { - case Args::Option::BOOL: - read_bool(&o[j], arr[i], par, r); - break; - case Args::Option::DOUBLE: - read_double(&o[j], arr[i], par, r); - break; - case Args::Option::INT: - read_int(&o[j], arr[i], par, r); - break; - default: - ; - } - } - } - } -} -#endif - -static int findOpt(opt_ctx_t* ctx, int olong) -{ - char* arg = ctx->argv[ctx->idx] + olong + 1; - char* par = strchr(arg, '='); - const edg_wll_Args* o = NULL; - const edg_wll_Args* ol[200]; - int olb = 0; - int ole = 0; - - char* argnofile = strdup(arg); - char* nofile = strstr(argnofile, "-file"); // should be the ending - if (nofile && (nofile - argnofile) > 2) - nofile[0] = 0; - - olong++; - if (par) - { - *par = 0; - par++; - } - else if ((ctx->idx + 1) < ctx->argc) - { - par = ctx->argv[++ctx->idx]; - } - - ol[ole++] = ctx->list; - while (ole > olb) - { - o = ol[olb++]; - for (; o->type != EDG_WLL_ARGS_NONE; o++) - { - //printf("OPTION %d '%s' %d '%s' '%s'\n", o->type, arg, olong, o->oshort, o->olong); - if (o->type == EDG_WLL_ARGS_HELP - && (strcasecmp(arg, "h") == 0 - || strcmp(arg, "?") == 0 - || strcasecmp(arg, "help") == 0)) - break; - if (o->type == EDG_WLL_ARGS_OPTIONS) - { - ol[ole++] = o->value; - continue; - } - - if (olong < 2) - { - if (o->oshort && - (strcmp(arg, o->oshort) == 0 - || strcmp(argnofile, o->oshort) == 0)) - break; - } - else if (o->olong && (strcmp(arg, o->olong) == 0 - || strcmp(argnofile, o->olong) == 0)) - break; - } - if (o->type != EDG_WLL_ARGS_NONE) - break; - } - - switch (o->type) - { - case EDG_WLL_ARGS_NONE: - return -1; - case EDG_WLL_ARGS_BOOL: - if (!read_bool(o, arg, par)) - ctx->idx--; // no argument given - break; - case EDG_WLL_ARGS_DOUBLE: - read_double(o, arg, par); - break; - case EDG_WLL_ARGS_STRING: - read_string(o, arg, par); - break; - case EDG_WLL_ARGS_INT: - read_int(o, arg, par); - break; - case EDG_WLL_ARGS_UINT16: - read_uint16(o, arg, par); - break; - case EDG_WLL_ARGS_EVENT: - read_event(o, arg, par); - break; - case EDG_WLL_ARGS_SOURCE: - read_source(o, arg, par); - break; - case EDG_WLL_ARGS_HELP: - printf("\nUsage: %s %s\n\n", ctx->argv[0], ctx->help); - show_help(ctx->list, 1); - exit(0); - //case EDG_WLL_ARGS_SUBOPTIONS: - //parse_suboptions((const edg_wll_Args*)o->value, arg, par, regname); - default: - printf("FIXME: unhandle option type %d\n", o->type); - break; - } - - if (argnofile) - free(argnofile); - - return 0; -} - -static void addOptions(opt_ctx_t* ctx, const edg_wll_Args* options) -{ - const edg_wll_Args* o = options; - - while (o->type != EDG_WLL_ARGS_NONE) - { - ctx->list[ctx->last++] = *o; - o++; - } -} - -void edg_wll_ParseArgs(int* argc, char** argv, const edg_wll_Args* options, - const char* help) -{ - int sidx = 1; - opt_ctx_t ctx; - - ctx.argc = *argc; - ctx.argv = argv; - ctx.help = help; - ctx.last = 0; - - addOptions(&ctx, options); - - for (ctx.idx = 1; ctx.idx < ctx.argc; ctx.idx++) - { - if (argv[ctx.idx][0] == '-') - { - int olong = (argv[ctx.idx][1] == '-'); - if (olong && argv[ctx.idx][2] == 0) - break; // end of options - //printf("ARG %d %s\n", ctx.idx, argv[ctx.idx]); - if (findOpt(&ctx, olong) == 0) - continue; - } - else if (sidx != ctx.idx) - { - fprintf(stderr,"SIDX %d %d\n", sidx, ctx.idx); - argv[sidx] = argv[ctx.idx]; - } - sidx++; - } - - while (ctx.idx < *argc && sidx != ctx.idx) - { - argv[sidx++] = argv[ctx.idx++]; - } - - *argc = sidx; -} diff --git a/org.glite.lb.client/src/args.h b/org.glite.lb.client/src/args.h deleted file mode 100644 index 6daaf4e..0000000 --- a/org.glite.lb.client/src/args.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_ARGS_H__ - -typedef enum { - EDG_WLL_ARGS_NONE = 0, - EDG_WLL_ARGS_BOOL, - EDG_WLL_ARGS_INT, - EDG_WLL_ARGS_UINT16, - EDG_WLL_ARGS_DOUBLE, - EDG_WLL_ARGS_STRING, - EDG_WLL_ARGS_HELP, - EDG_WLL_ARGS_JOBID, - EDG_WLL_ARGS_NOTIFID, - EDG_WLL_ARGS_SOURCE, - EDG_WLL_ARGS_EVENT, - EDG_WLL_ARGS_OPTIONS, - EDG_WLL_ARGS_SUBOPTIONS, - EDG_WLL_ARGS_SELECTSTRING, -} edg_wll_ArgsCode; - -typedef struct { - edg_wll_ArgsCode type; - const char* oshort; - const char* olong; - const char* help; - void* value; - int min; - int max; -} edg_wll_Args; - -void edg_wll_ParseArgs(int* argc, char** argv, const edg_wll_Args* parray, - const char* help); - -#endif /* __EDG_WORKLOAD_LOGGING_CLIENT_ARGS_H__ */ diff --git a/org.glite.lb.client/src/connection.c b/org.glite.lb.client/src/connection.c deleted file mode 100644 index 173ef47..0000000 --- a/org.glite.lb.client/src/connection.c +++ /dev/null @@ -1,352 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/lb_gss.h" -#include "glite/lb/mini_http.h" - - - -static void CloseConnection(edg_wll_Context ctx, int conn_index) -{ - /* close connection ad free its structures */ - OM_uint32 min_stat; - - edg_wll_gss_close(&ctx->connPool[conn_index].gss, &ctx->p_tmp_timeout); - if (ctx->connPool[conn_index].gsiCred) - gss_release_cred(&min_stat, &ctx->connPool[conn_index].gsiCred); - free(ctx->connPool[conn_index].peerName); - free(ctx->connPool[conn_index].buf); - - memset(ctx->connPool + conn_index, 0, sizeof(edg_wll_ConnPool)); - - /* if deleted conn was not the last one -> there is a 'hole' and then */ - /* 'shake' together connections in pool, no holes are allowed */ - if (conn_index < ctx->connOpened - 1) { - ctx->connPool[conn_index] = ctx->connPool[ctx->connOpened - 1]; - memset(ctx->connPool + ctx->connOpened - 1 , 0, sizeof(edg_wll_ConnPool)); - } - ctx->connOpened--; -} - - - -static int ConnectionIndex(edg_wll_Context ctx, const char *name, int port) -{ - int i; - - for (i=0; iconnOpened;i++) - if (!strcmp(name, ctx->connPool[i].peerName) && - (port == ctx->connPool[i].peerPort)) return i; - - return -1; -} - - - -static int AddConnection(edg_wll_Context ctx, char *name, int port) -{ - int index = ctx->connOpened; - - free(ctx->connPool[index].peerName); // should be empty; just to be sure - ctx->connPool[index].peerName = strdup(ctx->srvName); - ctx->connPool[index].peerPort = ctx->srvPort; - ctx->connOpened++; - - return index; -} - - - -static void ReleaseConnection(edg_wll_Context ctx, char *name, int port) -{ - int i, index = 0; - long min; - - - if (ctx->connOpened == 0) return; /* nothing to release */ - - if (name) { - if ((index = ConnectionIndex(ctx, name, port)) >= 0) - CloseConnection(ctx, index); - } - else { /* free the oldest connection*/ - min = ctx->connPool[0].lastUsed.tv_sec; - for (i=0; iconnOpened; i++) { - if (ctx->connPool[i].lastUsed.tv_sec < min) { - min = ctx->connPool[i].lastUsed.tv_sec; - index = i; - } - } - CloseConnection(ctx, index); - } -} - - - -int edg_wll_close(edg_wll_Context ctx) -{ - edg_wll_ResetError(ctx); - - CloseConnection(ctx, ctx->connToUse); - - return edg_wll_Error(ctx,NULL,NULL); -} - - - -int edg_wll_close_proxy(edg_wll_Context ctx) -{ - edg_wll_plain_close(&ctx->connProxy->conn); - - return edg_wll_Error(ctx, NULL, NULL); -} - - - -int edg_wll_open(edg_wll_Context ctx) -{ - int index; - edg_wll_GssStatus gss_stat; - - - edg_wll_ResetError(ctx); - - if ( (index = ConnectionIndex(ctx, ctx->srvName, ctx->srvPort)) == -1 ) { - /* no such open connection in pool */ - if (ctx->connOpened == ctx->poolSize) - ReleaseConnection(ctx, NULL, 0); - - index = AddConnection(ctx, ctx->srvName, ctx->srvPort); - - } - /* else - there is cached open connection, reuse it */ - - ctx->connToUse = index; - - /* XXX support anonymous connections, perhaps add a flag to the connPool - * struct specifying whether or not this connection shall be authenticated - * to prevent from repeated calls to edg_wll_gss_acquire_cred_gsi() */ - if (!ctx->connPool[index].gsiCred && - edg_wll_gss_acquire_cred_gsi( - ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_cert_filename, - ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_key_filename, - &ctx->connPool[index].gsiCred, NULL, &gss_stat)) { - edg_wll_SetErrorGss(ctx, "failed to load GSI credentials", &gss_stat); - goto err; - } - - if (ctx->connPool[index].gss.context == GSS_C_NO_CONTEXT) { - switch (edg_wll_gss_connect(ctx->connPool[index].gsiCred, - ctx->connPool[index].peerName, ctx->connPool[index].peerPort, - &ctx->p_tmp_timeout,&ctx->connPool[index].gss, - &gss_stat)) { - - case EDG_WLL_GSS_OK: - goto ok; - case EDG_WLL_GSS_ERROR_ERRNO: - edg_wll_SetError(ctx,errno,"edg_wll_gss_connect()"); - break; - case EDG_WLL_GSS_ERROR_GSS: - edg_wll_SetErrorGss(ctx, "failed to authenticate to server", &gss_stat); - break; - case EDG_WLL_GSS_ERROR_HERRNO: - { const char *msg1; - char *msg2; - msg1 = hstrerror(errno); - asprintf(&msg2, "edg_wll_gss_connect(): %s", msg1); - edg_wll_SetError(ctx,EDG_WLL_ERROR_DNS, msg2); - free(msg2); - } - break; - case EDG_WLL_GSS_ERROR_EOF: - edg_wll_SetError(ctx,ECONNREFUSED,"edg_wll_gss_connect():" - " server closed the connection, probably due to overload"); - break; - case EDG_WLL_GSS_ERROR_TIMEOUT: - edg_wll_SetError(ctx,ETIMEDOUT,"edg_wll_gss_connect()"); - break; - } - } - else goto ok; - -err: - /* some error occured; close created connection - * and free all fields in connPool[index] */ - CloseConnection(ctx, index); -ok: - return edg_wll_Error(ctx,NULL,NULL); -} - - - -int edg_wll_open_proxy(edg_wll_Context ctx) -{ - struct sockaddr_un saddr; - int flags; - - - ctx->connProxy->conn.sock = socket(PF_UNIX, SOCK_STREAM, 0); - if (ctx->connProxy->conn.sock < 0) { - edg_wll_SetError(ctx, errno, "socket() error"); - goto err; - } - - memset(&saddr, 0, sizeof(saddr)); - saddr.sun_family = AF_UNIX; - if (!ctx->p_lbproxy_serve_sock) { - edg_wll_SetError(ctx, EINVAL, "Proxy socket path not set!"); - goto err; - } - - if (strlen(ctx->p_lbproxy_serve_sock) > 108) { // UNIX_PATH_MAX (def. in linux/un.h) - // but not defined in sys/un.h - edg_wll_SetError(ctx, EINVAL, "proxy_filename too long!"); - goto err; - } - strcpy(saddr.sun_path, ctx->p_lbproxy_serve_sock); - - if ((flags = fcntl(ctx->connProxy->conn.sock, F_GETFL, 0)) < 0 || - fcntl(ctx->connProxy->conn.sock, F_SETFL, flags | O_NONBLOCK) < 0) { - edg_wll_SetError(ctx, errno, "fcntl()"); - goto err; - } - - if (connect(ctx->connProxy->conn.sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { - edg_wll_SetError(ctx, errno, "connect()"); - goto err; - } - - return edg_wll_Error(ctx,NULL,NULL); - -err: - /* some error occured; close created connection */ - - edg_wll_close_proxy(ctx); - - return edg_wll_Error(ctx,NULL,NULL); -} - - - -/* transform HTTP error code to ours */ -int http_check_status( - edg_wll_Context ctx, - char *response) - -{ - int code,len; - - edg_wll_ResetError(ctx); - sscanf(response,"HTTP/%*f %n%d",&len,&code); - switch (code) { - case HTTP_OK: - break; - /* soft errors - some useful data may be returned too */ - case HTTP_UNAUTH: /* EPERM */ - case HTTP_NOTFOUND: /* ENOENT */ - case HTTP_NOTIMPL: /* ENOSYS */ - case HTTP_UNAVAIL: /* EAGAIN */ - case HTTP_INVALID: /* EINVAL */ - break; - case EDG_WLL_GSS_ERROR_HERRNO: - { const char *msg1; - char *msg2; - msg1 = hstrerror(errno); - asprintf(&msg2, "edg_wll_gss_connect(): %s", msg1); - edg_wll_SetError(ctx,EDG_WLL_ERROR_DNS, msg2); - free(msg2); - } - break; - case HTTP_NOTALLOWED: - edg_wll_SetError(ctx, ENXIO, "Method Not Allowed"); - break; - case HTTP_UNSUPPORTED: - edg_wll_SetError(ctx, ENOTSUP, "Protocol versions incompatible"); - break; - case HTTP_INTERNAL: - /* fall through */ - default: - edg_wll_SetError(ctx,EDG_WLL_ERROR_SERVER_RESPONSE,response+len); - } - return edg_wll_Error(ctx,NULL,NULL); -} - - - -int edg_wll_http_send_recv( - edg_wll_Context ctx, - char *request, - const char * const *req_head, - char *req_body, - char **response, - char ***resp_head, - char **resp_body) -{ - if (edg_wll_open(ctx)) return edg_wll_Error(ctx,NULL,NULL); - - switch (edg_wll_http_send(ctx,request,req_head,req_body)) { - case ENOTCONN: - edg_wll_close(ctx); - if (edg_wll_open(ctx) - || edg_wll_http_send(ctx,request,req_head,req_body)) - return edg_wll_Error(ctx,NULL,NULL); - /* fallthrough */ - case 0: break; - default: return edg_wll_Error(ctx,NULL,NULL); - } - - if (edg_wll_http_recv(ctx,response,resp_head,resp_body) == ENOTCONN) { - edg_wll_close(ctx); - (void) (edg_wll_open(ctx) - || edg_wll_http_send(ctx,request,req_head,req_body) - || edg_wll_http_recv(ctx,response,resp_head,resp_body)); - } - - gettimeofday(&ctx->connPool[ctx->connToUse].lastUsed, NULL); - - return edg_wll_Error(ctx,NULL,NULL); -} - - - -int edg_wll_http_send_recv_proxy( - edg_wll_Context ctx, - char *request, - const char * const *req_head, - char *req_body, - char **response, - char ***resp_head, - char **resp_body) -{ - if (edg_wll_open_proxy(ctx)) return edg_wll_Error(ctx,NULL,NULL); - - switch (edg_wll_http_send_proxy(ctx,request,req_head,req_body)) { - case ENOTCONN: - edg_wll_close_proxy(ctx); - if (edg_wll_open_proxy(ctx) - || edg_wll_http_send_proxy(ctx,request,req_head,req_body)) - return edg_wll_Error(ctx,NULL,NULL); - /* fallthrough */ - case 0: break; - default: return edg_wll_Error(ctx,NULL,NULL); - } - - if (edg_wll_http_recv_proxy(ctx,response,resp_head,resp_body) == ENOTCONN) { - edg_wll_close_proxy(ctx); - (void) (edg_wll_open_proxy(ctx) - || edg_wll_http_send_proxy(ctx,request,req_head,req_body) - || edg_wll_http_recv_proxy(ctx,response,resp_head,resp_body)); - } - - return edg_wll_Error(ctx,NULL,NULL); -} diff --git a/org.glite.lb.client/src/connection.h b/org.glite.lb.client/src/connection.h deleted file mode 100644 index 7de349d..0000000 --- a/org.glite.lb.client/src/connection.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__ - -#ident "$Header" - -int edg_wll_close(edg_wll_Context ctx); -int edg_wll_open(edg_wll_Context ctx); -int edg_wll_http_send_recv(edg_wll_Context, char *, const char * const *, char *, char **, char ***, char **); - -int edg_wll_close_proxy(edg_wll_Context ctx); -int edg_wll_open_proxy(edg_wll_Context ctx); -int edg_wll_http_send_recv_proxy(edg_wll_Context, char *, const char * const *, char *, char **, char ***, char **); - -int http_check_status(edg_wll_Context, char *); - - -#endif /* __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__ */ diff --git a/org.glite.lb.client/src/consumer.c b/org.glite.lb.client/src/consumer.c deleted file mode 100644 index 14059ad..0000000 --- a/org.glite.lb.client/src/consumer.c +++ /dev/null @@ -1,583 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include - -#include - -#include "globus_config.h" - -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/mini_http.h" -#include "glite/lb/xml_parse.h" -#include "glite/lb/xml_conversions.h" - -#include "connection.h" - -static const char* const request_headers[] = { - "Cache-Control: no-cache", - "Accept: application/x-dglb", - "User-Agent: edg_wll_Api/" PROTO_VERSION "/" COMP_PROTO, - "Content-Type: application/x-dglb", - NULL -}; - -int set_server_name_and_port(edg_wll_Context, const edg_wll_QueryRec **); - -int edg_wll_QueryEventsExt( - edg_wll_Context ctx, - const edg_wll_QueryRec **job_conditions, - const edg_wll_QueryRec **event_conditions, - edg_wll_Event **eventsOut) -{ - char *response = NULL, - *message = NULL, - *send_mess = NULL; - - edg_wll_ResetError(ctx); - - if ( edg_wll_QueryEventsRequestToXML(ctx, job_conditions, event_conditions, &send_mess) != 0 ) - { - edg_wll_SetError(ctx , (edg_wll_ErrorCode) EINVAL, "Invalid query record."); - goto err; - } - - ctx->p_tmp_timeout = ctx->p_query_timeout; - - if (ctx->isProxy) { - ctx->isProxy = 0; - if (edg_wll_http_send_recv_proxy(ctx, "POST /queryEvents HTTP/1.1", - request_headers,send_mess, &response,NULL,&message)) - goto err; - } - else { - if (set_server_name_and_port(ctx,job_conditions)) - goto err; // XXX is it fatal?? - - if (edg_wll_http_send_recv(ctx, "POST /queryEvents HTTP/1.1", - request_headers,send_mess, &response,NULL,&message)) - goto err; - } - - if (http_check_status(ctx,response)) - goto err; - - edg_wll_ParseQueryEvents(ctx,message,eventsOut); - -err: - free(response); - free(message); - free(send_mess); - return edg_wll_Error(ctx,NULL,NULL); -} - -int edg_wll_QueryEvents( - edg_wll_Context ctx, - const edg_wll_QueryRec *job_conditions, - const edg_wll_QueryRec *event_conditions, - edg_wll_Event **eventsOut) -{ - edg_wll_QueryRec **jconds = NULL, - **econds = NULL; - int i, - njconds, neconds, - ret; - - if ( job_conditions ) - { - for ( njconds = 0; job_conditions[njconds].attr != EDG_WLL_QUERY_ATTR_UNDEF ; njconds++ ) - ; - jconds = (edg_wll_QueryRec **) calloc(njconds+1, sizeof(edg_wll_QueryRec *)); - for ( i = 0; i < njconds; i++ ) - { - jconds[i] = (edg_wll_QueryRec *) calloc(2, sizeof(edg_wll_QueryRec)); - jconds[i][0] = job_conditions[i]; - } - } - - if ( event_conditions ) - { - for ( neconds = 0; event_conditions[neconds].attr != EDG_WLL_QUERY_ATTR_UNDEF ; neconds++ ) - ; - econds = (edg_wll_QueryRec **) calloc(neconds+1, sizeof(edg_wll_QueryRec *)); - for ( i = 0; i < neconds; i++ ) - { - econds[i] = (edg_wll_QueryRec *) calloc(2, sizeof(edg_wll_QueryRec)); - econds[i][0] = event_conditions[i]; - } - } - - if ( econds && jconds ) - ret = edg_wll_QueryEventsExt(ctx, (const edg_wll_QueryRec **) jconds, - (const edg_wll_QueryRec **) econds, eventsOut); - if ( econds && !jconds ) - ret = edg_wll_QueryEventsExt(ctx, NULL, (const edg_wll_QueryRec **) econds, eventsOut); - if ( !econds && jconds ) - ret = edg_wll_QueryEventsExt(ctx, (const edg_wll_QueryRec **) jconds, NULL, eventsOut); - if ( !econds && !jconds ) - ret = edg_wll_QueryEventsExt(ctx, NULL, NULL, eventsOut); - - if ( jconds ) - { - for ( i = 0; i < njconds ; i++ ) - free(jconds[i]); - free(jconds); - } - if ( econds ) - { - for ( i = 0; i < neconds ; i++ ) - free(econds[i]); - free(econds); - } - - return ret; -} - - -int edg_wll_QueryJobsExt( - edg_wll_Context ctx, - const edg_wll_QueryRec ** conditions, - int flags, - edg_wlc_JobId ** jobsOut, - edg_wll_JobStat ** statesOut) -{ - char *response = NULL, *message = NULL, *send_mess = NULL; - - edg_wll_ResetError(ctx); - - if (!jobsOut) flags |= EDG_WLL_STAT_NO_JOBS; - if (!statesOut) {flags = 0; flags |= EDG_WLL_STAT_NO_STATES;} - if (edg_wll_QueryJobsRequestToXML(ctx, conditions, flags, &send_mess) != 0) { - edg_wll_SetError(ctx , (edg_wll_ErrorCode) EINVAL, "Invalid query record."); - goto err; - } - - ctx->p_tmp_timeout = ctx->p_query_timeout; - - if (ctx->isProxy){ - ctx->isProxy = 0; - if (edg_wll_http_send_recv_proxy(ctx, "POST /queryJobs HTTP/1.1", - request_headers,send_mess,&response,NULL,&message)) - goto err; - } - else { - if (set_server_name_and_port(ctx, conditions)) - goto err; - - if (edg_wll_http_send_recv(ctx, "POST /queryJobs HTTP/1.1", - request_headers,send_mess,&response,NULL,&message)) - goto err; - } - - if (http_check_status(ctx,response)) - goto err; - - edg_wll_ParseQueryJobs(ctx,message,jobsOut,statesOut); - -err: - free(response); - free(message); - free(send_mess); - - return edg_wll_Error(ctx,NULL,NULL); -} - -int edg_wll_QueryJobs( - edg_wll_Context ctx, - const edg_wll_QueryRec * conditions, - int flags, - edg_wlc_JobId ** jobsOut, - edg_wll_JobStat ** statesOut) -{ - edg_wll_QueryRec **conds; - int i, nconds, ret; - - if ( !conditions ) - return edg_wll_QueryJobsExt(ctx, NULL, flags, jobsOut, statesOut); - - for ( nconds = 0; conditions[nconds].attr != EDG_WLL_QUERY_ATTR_UNDEF ; nconds++ ) - ; - conds = (edg_wll_QueryRec **) malloc((nconds+1) * sizeof(edg_wll_QueryRec *)); - conds[nconds] = NULL; - for ( i = 0; i < nconds ; i++ ) - { - conds[i] = (edg_wll_QueryRec *) malloc(2 * sizeof(edg_wll_QueryRec)); - conds[i][0] = conditions[i]; - conds[i][1].attr = EDG_WLL_QUERY_ATTR_UNDEF; - } - - ret = edg_wll_QueryJobsExt(ctx, (const edg_wll_QueryRec **) conds, flags, jobsOut, statesOut); - - for ( i = 0; i < nconds ; i++ ) - free(conds[i]); - free(conds); - - - return ret; -} - - - -int edg_wll_GetIndexedAttrs( - edg_wll_Context ctx, - edg_wll_QueryRec ***attrs) -{ - char *response = NULL, *send_mess = NULL, *message = NULL; - - edg_wll_ResetError(ctx); - - edg_wll_IndexedAttrsRequestToXML(ctx, &send_mess); - - if (set_server_name_and_port(ctx, NULL)) - goto err; - - ctx->p_tmp_timeout = ctx->p_query_timeout; - - if (edg_wll_http_send_recv(ctx, "POST /indexedAttrs HTTP/1.1",request_headers, send_mess, - &response,NULL,&message)) - goto err; - - if (http_check_status(ctx,response)) - goto err; - - edg_wll_ParseIndexedAttrs(ctx,message,attrs); - -err: - free(response); - free(message); - - return edg_wll_Error(ctx,NULL,NULL); -} - - -/* - * wrappers around edg_wll_Query() - */ - -int edg_wll_UserJobs( - edg_wll_Context ctx, - edg_wlc_JobId **jobsOut, - edg_wll_JobStat **statesOut) -{ - edg_wll_QueryRec j[2]; - - memset(j,0,sizeof j); - - j[0].attr = EDG_WLL_QUERY_ATTR_OWNER; - j[0].op = EDG_WLL_QUERY_OP_EQUAL; - j[0].value.c = ctx->peerName; - - return edg_wll_QueryJobs(ctx,j,0,jobsOut,statesOut); -} - -int edg_wll_JobLog( - edg_wll_Context ctx, - edg_wlc_JobId job, - edg_wll_Event **eventsOut) -{ - edg_wll_QueryRec j[2], e[2]; - - memset(j,0,sizeof j); - memset(e,0,sizeof e); - - j[0].attr = EDG_WLL_QUERY_ATTR_JOBID; - j[0].op = EDG_WLL_QUERY_OP_EQUAL; - j[0].value.j = job; - - e[0].attr = EDG_WLL_QUERY_ATTR_LEVEL; - e[0].op = EDG_WLL_QUERY_OP_LESS; - e[0].value.i = ctx->p_level + 1; - - return edg_wll_QueryEvents(ctx,j,e,eventsOut); -} - -int edg_wll_JobStatus( - edg_wll_Context ctx, - edg_wlc_JobId job, - int flags, - edg_wll_JobStat *stat) -{ - edg_wll_QueryRec j[2]; - edg_wll_JobStat *statesOut = NULL; - int ret; - - memset(j,0,sizeof j); - - j[0].attr = EDG_WLL_QUERY_ATTR_JOBID; - j[0].op = EDG_WLL_QUERY_OP_EQUAL; - j[0].value.j = job; - j[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; - - ret = edg_wll_QueryJobs(ctx,j,flags,NULL,&statesOut); - - if (ret) return ret; - - if (statesOut) { - if (statesOut[0].state == EDG_WLL_JOB_UNDEF) { - memcpy(stat, statesOut, sizeof(edg_wll_JobStat)); - free(statesOut); - ret = edg_wll_SetError(ctx , (edg_wll_ErrorCode) ENOENT, "Query returned no result."); - } - else { - /* check wheter there is only one field in status reply */ - assert(statesOut[1].state == EDG_WLL_JOB_UNDEF); - /* copy only 1st status */ - memcpy(stat, statesOut, sizeof(edg_wll_JobStat)); - /* release only array of states, keep all links unfreed for the previous copy */ - free(statesOut); - } - } - - return ret; -} - - - -int edg_wll_QueryListener(edg_wll_Context ctx, edg_wlc_JobId job, const char *name, char** host, uint16_t *port) { - - int i; - edg_wll_Event *events = NULL; - int errCode = 0; - edg_wll_QueryRec jr[2],er[2]; - int found = 0; - - memset(jr,0,sizeof jr); - memset(er,0,sizeof er); - jr[0].attr = EDG_WLL_QUERY_ATTR_JOBID; - jr[0].op = EDG_WLL_QUERY_OP_EQUAL; - jr[0].value.j = job; - - er[0].attr = EDG_WLL_QUERY_ATTR_EVENT_TYPE; - er[0].op = EDG_WLL_QUERY_OP_EQUAL; - er[0].value.i = EDG_WLL_EVENT_LISTENER; - - if (edg_wll_QueryEvents(ctx, jr, er, &events)) { - return edg_wll_Error(ctx, NULL, NULL); - } - - for (i=0; events[i].type != EDG_WLL_EVENT_UNDEF; i++) { - if (!strcmp(name, events[i].listener.svc_name)) { - found = 1; - if (host != NULL) - *host = strdup(events[i].listener.svc_host); - if (port != NULL) - *port = events[i].listener.svc_port; - } - edg_wll_FreeEvent(&events[i]); - } - free(events); - - if (!found) - errCode = ENOENT; - - return edg_wll_SetError(ctx, errCode, NULL); -} - - -int set_server_name_and_port(edg_wll_Context ctx, const edg_wll_QueryRec **job_conditions) -{ - int i = 0, j, - found = 0, - error = 0; - int srvPort = 0, - srvPortTmp; - char *srvName = NULL, - *srvNameTmp; - - - if ( job_conditions ) for ( j = 0; job_conditions[j]; j++ ) - for ( i = 0; (job_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - if ( job_conditions[j][i].attr == EDG_WLL_QUERY_ATTR_JOBID) - { - edg_wlc_JobIdGetServerParts(job_conditions[j][i].value.j,&srvNameTmp,&srvPortTmp); - if ( found ) - { - if ( strcmp(srvName, srvNameTmp) || (srvPort != srvPortTmp) ) - { - free(srvNameTmp); free(srvName); - return edg_wll_SetError(ctx, EINVAL, "Two different servers specifieed in one query"); - } - free(srvNameTmp); - } - else - { - srvName = srvNameTmp; - srvPort = srvPortTmp; - found = 1; - } - } - - if ( found && !ctx->p_query_server_override) - { - if (!ctx->srvName) - { - ctx->srvName = strdup(srvName); - ctx->srvPort = srvPort; - free(srvName); - } - else if (strcmp(srvName, ctx->srvName) || (srvPort != ctx->srvPort)) - { - free(ctx->srvName); - ctx->srvName = strdup(srvName); - ctx->srvPort = srvPort; - free(srvName); - } - } - else if ( !ctx->srvName || !ctx->srvPort ) - { - if (!ctx->p_query_server) - return(edg_wll_SetError(ctx, (edg_wll_ErrorCode) EINVAL, "Hostname of server to query is not set")); - else ctx->srvName = strdup(ctx->p_query_server); - if (!ctx->p_query_server_port) - return(edg_wll_SetError(ctx, (edg_wll_ErrorCode) EINVAL, "Port of server to query is not set")); - else ctx->srvPort = ctx->p_query_server_port; - } - - return(error); -} - -int edg_wll_QuerySequenceCodeProxy(edg_wll_Context ctx, edg_wlc_JobId jobId, char **code) -{ - int error = 0; - char *response = NULL, - *message = NULL, - *send_mess = NULL; - - - ctx->isProxy = 1; - edg_wll_ResetError(ctx); - - if ( edg_wll_QuerySequenceCodeToXML(ctx, jobId, &send_mess) != 0 ) - { - edg_wll_SetError(ctx , (edg_wll_ErrorCode) EINVAL, "Invalid query record."); - goto err; - } - - ctx->p_tmp_timeout = ctx->p_query_timeout; - - error = edg_wll_http_send_recv_proxy(ctx, "POST /querySequenceCode HTTP/1.1", - request_headers, send_mess, &response, NULL, &message); - if ( error != 0 ) - goto err; - - if (http_check_status(ctx,response)) - goto err; - - edg_wll_ParseQuerySequenceCodeResult(ctx,message,code); - -err: - free(response); - free(message); - free(send_mess); - - return edg_wll_Error(ctx,NULL,NULL); -} - - -/****************************************************************** - * Proxy wrappers - */ - - -int edg_wll_QueryEventsExtProxy( - edg_wll_Context ctx, - const edg_wll_QueryRec **job_conditions, - const edg_wll_QueryRec **event_conditions, - edg_wll_Event **eventsOut) -{ - ctx->isProxy = 1; - - return edg_wll_QueryEventsExt(ctx, job_conditions, event_conditions, eventsOut); -} - - - -int edg_wll_QueryEventsProxy( - edg_wll_Context ctx, - const edg_wll_QueryRec *job_conditions, - const edg_wll_QueryRec *event_conditions, - edg_wll_Event **eventsOut) -{ - ctx->isProxy = 1; - - return edg_wll_QueryEvents(ctx, job_conditions, event_conditions, eventsOut); -} - - - -int edg_wll_QueryJobsExtProxy( - edg_wll_Context ctx, - const edg_wll_QueryRec ** conditions, - int flags, - edg_wlc_JobId ** jobsOut, - edg_wll_JobStat ** statesOut) -{ - ctx->isProxy = 1; - - return edg_wll_QueryJobsExt(ctx, conditions, flags, jobsOut, statesOut); -} - - - -int edg_wll_QueryJobsProxy( - edg_wll_Context ctx, - const edg_wll_QueryRec * conditions, - int flags, - edg_wlc_JobId ** jobsOut, - edg_wll_JobStat ** statesOut) -{ - ctx->isProxy = 1; - - return edg_wll_QueryJobs(ctx, conditions, flags, jobsOut, statesOut); -} - - -int edg_wll_UserJobsProxy( - edg_wll_Context ctx, - edg_wlc_JobId **jobsOut, - edg_wll_JobStat **statesOut) -{ - ctx->isProxy = 1; - - return edg_wll_UserJobs(ctx, jobsOut, statesOut); -} - -int edg_wll_JobLogProxy( - edg_wll_Context ctx, - edg_wlc_JobId job, - edg_wll_Event **eventsOut) -{ - ctx->isProxy = 1; - - return edg_wll_JobLog(ctx, job, eventsOut); -} - -int edg_wll_JobStatusProxy( - edg_wll_Context ctx, - edg_wlc_JobId job, - int flags, - edg_wll_JobStat *stat) -{ - ctx->isProxy = 1; - - return edg_wll_JobStatus(ctx, job, flags, stat); -} - - - -int edg_wll_QueryListenerProxy( - edg_wll_Context ctx, - edg_wlc_JobId job, - const char *name, - char** host, - uint16_t *port) -{ - ctx->isProxy = 1; - - return edg_wll_QueryListener(ctx, job, name, host, port); -} diff --git a/org.glite.lb.client/src/dump.c b/org.glite.lb.client/src/dump.c deleted file mode 100644 index f172192..0000000 --- a/org.glite.lb.client/src/dump.c +++ /dev/null @@ -1,230 +0,0 @@ -#ident "$Header$" - - -#include -#include -#include -#include -#include -#include - -#include - -#define CLIENT_SBIN_PROG - -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/dump.h" -#include "glite/lb/ulm_parse.h" -#include "glite/lb/xml_parse.h" -#include "glite/lb/mini_http.h" - - -#define dprintf(x) { if (debug) printf x; } - -static const char rcsid[] = "@(#)$Id$"; - -static int debug=0; - -static void printerr(edg_wll_Context ctx); - -static struct option opts[] = { - { "from", required_argument, NULL, 'f'}, - { "to", required_argument, NULL, 't'}, - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, 'v' }, - { "debug", no_argument, NULL, 'd' }, - { "server", required_argument, NULL, 'm' }, - { NULL, no_argument, NULL, 0 } -}; - -static void usage(char *me) -{ - fprintf(stderr,"usage: %s [option]\n" - " -f, --from YYYYMMDDHHmmss beginning of the time interval for events to be dumped\n" - " -t, --to YYYYMMDDHHmmss end of the time interval for events to be dumped\n" - " -h, --help display this help\n" - " -v, --version display version\n" - " -d, --debug diagnostic output\n" - " -m, --server L&B server machine name\n", - me); -} - -int main(int argc,char *argv[]) -{ - edg_wll_DumpRequest *request; - edg_wll_DumpResult *result; - char *server = NULL; - char date[ULM_DATE_STRING_LENGTH+1]; - - char *me; - int opt; - edg_wll_Context ctx; - - /* initialize request to server defaults */ - request = (edg_wll_DumpRequest *) calloc(1,sizeof(edg_wll_DumpRequest)); - request->from = EDG_WLL_DUMP_LAST_END; - request->to = EDG_WLL_DUMP_NOW; - - /* initialize result */ - result = (edg_wll_DumpResult *) calloc(1,sizeof(edg_wll_DumpResult)); - - me = strrchr(argv[0],'/'); - if (me) me++; else me=argv[0]; - - /* get arguments */ - while ((opt = getopt_long(argc,argv,"f:t:m:dvh",opts,NULL)) != EOF) { - - switch (opt) { - - case 'f': request->from = (time_t) edg_wll_ULMDateToDouble(optarg); break; - case 't': request->to = (time_t) edg_wll_ULMDateToDouble(optarg); break; - case 'm': server = optarg; break; - case 'd': debug = 1; break; - case 'v': fprintf(stdout,"%s:\t%s\n",me,rcsid); exit(0); - case 'h': - case '?': usage(me); return 1; - } - } - - /* Initialize Globus common module */ - dprintf(("Initializing Globus common module...")); - if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { - dprintf(("no.\n")); - fprintf(stderr,"Unable to initialize Globus common module\n"); - } else { - dprintf(("yes.\n")); - } - - /* check request */ - if (debug) { - printf("Dump request:\n"); - if (request->from < 0) { - printf("- from: %ld.\n",request->from); - } else { - if (edg_wll_ULMTimevalToDate(request->from,0,date) != 0) { - fprintf(stderr,"Error parsing 'from' argument.\n"); - goto main_end; - } - printf("- from: %ld (i.e. %s).\n",request->from,date); - } - if (request->to < 0) { - printf("- to: %ld.\n",request->to); - } else { - if (edg_wll_ULMTimevalToDate(request->to,0,date) != 0) { - fprintf(stderr,"Error parsing 'to' argument.\n"); - goto main_end; - } - printf("- to: %ld (i.e. %s).\n",request->to,date); - } - } - - /* initialize context */ - edg_wll_InitContext(&ctx); - if ( server ) - { - char *p = strchr(server, ':'); - if ( p ) - { - edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, atoi(p+1)); - *p = 0; - } - edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER, server); - } - - /* that is the DumpEvents */ - dprintf(("Running the edg_wll_DumpEvents...\n")); - if (edg_wll_DumpEvents(ctx, request, result) != 0) { - fprintf(stderr,"Error running the edg_wll_DumpEvents().\n"); - printerr(ctx); - switch ( edg_wll_Error(ctx, NULL, NULL) ) - { - case ENOENT: - case EPERM: - case EINVAL: - break; - default: - goto main_end; - } - } - - /* examine the result */ - dprintf(("Examining the result of edg_wll_DumpEvents...\n")); - printf("Dump result:\n"); - if (result->server_file) { - printf("- The jobs were dumped to the file '%s' at the server.\n",result->server_file); - } else { - printf("- The jobs were not dumped.\n"); - } - if (edg_wll_ULMTimevalToDate(result->from,0,date) != 0) { - fprintf(stderr,"Error parsing 'from' argument.\n"); - goto main_end; - } - printf("- from: %ld (i.e. %s).\n",result->from,date); - if (edg_wll_ULMTimevalToDate(result->to,0,date) != 0) { - fprintf(stderr,"Error parsing 'to' argument.\n"); - goto main_end; - } - printf("- to: %ld (i.e. %s).\n",result->to,date); - -main_end: - dprintf(("End.\n")); - if (request) free(request); - if (result) free(result); - edg_wll_FreeContext(ctx); - return 0; -} - - -static void printerr(edg_wll_Context ctx) -{ - char *errt,*errd; - - edg_wll_Error(ctx,&errt,&errd); - fprintf(stderr,"%s (%s)\n",errt,errd); -} - - -static const char* const request_headers[] = { - "Cache-Control: no-cache", - "Accept: application/x-dglb", - "User-Agent: edg_wll_Api/" PROTO_VERSION "/" COMP_PROTO, - "Content-Type: application/x-dglb", - NULL -}; - -int edg_wll_DumpEvents( - edg_wll_Context ctx, - const edg_wll_DumpRequest *request, - edg_wll_DumpResult *result) -{ - int error; - char *send_mess, - *response = NULL, - *recv_mess = NULL; - - edg_wll_DumpRequestToXML(ctx, request, &send_mess); - - ctx->p_tmp_timeout = ctx->p_query_timeout; - if (ctx->p_tmp_timeout.tv_sec < 600) ctx->p_tmp_timeout.tv_sec = 600; - - if (set_server_name_and_port(ctx, NULL)) - goto edg_wll_dumpevents_end; - - error = edg_wll_http_send_recv(ctx, - "POST /dumpRequest HTTP/1.1", request_headers, send_mess, - &response, NULL, &recv_mess); - if ( error != 0 ) - goto edg_wll_dumpevents_end; - - if (http_check_status(ctx, response, &recv_mess)) - goto edg_wll_dumpevents_end; - - edg_wll_ParseDumpResult(ctx, recv_mess, result); - -edg_wll_dumpevents_end: - if (response) free(response); - if (recv_mess) free(recv_mess); - if (send_mess) free(send_mess); - return edg_wll_Error(ctx,NULL,NULL); -} diff --git a/org.glite.lb.client/src/load.c b/org.glite.lb.client/src/load.c deleted file mode 100644 index ce18d03..0000000 --- a/org.glite.lb.client/src/load.c +++ /dev/null @@ -1,207 +0,0 @@ -#ident "$Header$" - - -#include -#include -#include -#include -#include -#include - -#include - -#define CLIENT_SBIN_PROG - -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/load.h" -#include "glite/lb/ulm_parse.h" -#include "glite/lb/xml_parse.h" -#include "glite/lb/mini_http.h" - -#define dprintf(x) { if (debug) printf x; } - -static const char rcsid[] = "@(#)$Id$"; - -static int debug=0; - -static void printerr(edg_wll_Context ctx); - -static struct option opts[] = { - { "file", required_argument, NULL, 'f'}, - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, 'v' }, - { "debug", no_argument, NULL, 'd' }, - { "server", required_argument, NULL, 'm' }, - { NULL, no_argument, NULL, 0 } -}; - -static void usage(char *me) -{ - fprintf(stderr,"usage: %s [option]\n" - " -m, --server L&B server machine name\n" - " -f, --file filename file with dumped data to be loaded\n" - " -h, --help display this help\n" - " -v, --version display version\n" - " -d, --debug diagnostic output\n", - me); -} - -int main(int argc,char *argv[]) -{ - edg_wll_LoadRequest *request; - edg_wll_LoadResult *result; - char *server = NULL; - char date[ULM_DATE_STRING_LENGTH+1]; - - char *me; - int opt; - edg_wll_Context ctx; - - /* initialize request to server defaults */ - request = (edg_wll_LoadRequest *) calloc(1,sizeof(edg_wll_LoadRequest)); - request->server_file = NULL; - - /* initialize result */ - result = (edg_wll_LoadResult *) calloc(1,sizeof(edg_wll_LoadResult)); - - me = strrchr(argv[0],'/'); - if (me) me++; else me=argv[0]; - - /* get arguments */ - while ((opt = getopt_long(argc,argv,"f:t:m:dvh",opts,NULL)) != EOF) { - - switch (opt) { - - case 'f': request->server_file = optarg; break; - case 'm': server = optarg; break; - case 'd': debug = 1; break; - case 'v': fprintf(stdout,"%s:\t%s\n",me,rcsid); exit(0); - case 'h': - case '?': usage(me); return 1; - } - } - - /* Initialize Globus common module */ - dprintf(("Initializing Globus common module...")); - if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { - dprintf(("no.\n")); - fprintf(stderr,"Unable to initialize Globus common module\n"); - } else { - dprintf(("yes.\n")); - } - - /* initialize context */ - edg_wll_InitContext(&ctx); - if ( server ) - { - char *p = strchr(server, ':'); - if ( p ) - { - edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, atoi(p+1)); - *p = 0; - } - edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER, server); - } - - /* check request */ - if (debug) { - printf("Load request:\n"); - if (request->server_file) { - printf("- server_file: %s.\n",request->server_file); - } else { - printf("- server_file: not specified.\n"); - } - } - - /* that is the LoadEvents */ - dprintf(("Running the edg_wll_LoadEvents...\n")); - if (edg_wll_LoadEvents(ctx, request, result) != 0) { - fprintf(stderr,"Error running the edg_wll_LoadEvents().\n"); - printerr(ctx); - if ( !result->server_file ) - goto main_end; - } - - /* examine the result */ - dprintf(("Examining the result of edg_wll_LoadEvents...\n")); - printf("Load result:\n"); - if (result->server_file) - printf("- Unloaded events were stored into the server file '%s'.\n", result->server_file); - if (edg_wll_ULMTimevalToDate(result->from,0,date) != 0) { - fprintf(stderr,"Error parsing 'from' argument.\n"); - goto main_end; - } - printf("- from: %ld (i.e. %s).\n",result->from,date); - if (edg_wll_ULMTimevalToDate(result->to,0,date) != 0) { - fprintf(stderr,"Error parsing 'to' argument.\n"); - goto main_end; - } - printf("- to: %ld (i.e. %s).\n",result->to,date); - -main_end: - dprintf(("End.\n")); - if (request) free(request); - if (result) - { - if (result->server_file) - free(result->server_file); - free(result); - } - edg_wll_FreeContext(ctx); - return 0; -} - - -static void printerr(edg_wll_Context ctx) -{ - char *errt,*errd; - - edg_wll_Error(ctx,&errt,&errd); - fprintf(stderr,"%s (%s)\n",errt,errd); -} - - -static const char* const request_headers[] = { - "Cache-Control: no-cache", - "Accept: application/x-dglb", - "User-Agent: edg_wll_Api/" PROTO_VERSION "/" COMP_PROTO, - "Content-Type: application/x-dglb", - NULL -}; - -int edg_wll_LoadEvents( - edg_wll_Context ctx, - const edg_wll_LoadRequest *request, - edg_wll_LoadResult *result) -{ - int error; - char *send_mess, - *response = NULL, - *recv_mess = NULL; - - edg_wll_LoadRequestToXML(ctx, request, &send_mess); - - ctx->p_tmp_timeout = ctx->p_query_timeout; - if (ctx->p_tmp_timeout.tv_sec < 600) ctx->p_tmp_timeout.tv_sec = 600; - - if (set_server_name_and_port(ctx, NULL)) - goto edg_wll_loadevents_end; - - error = edg_wll_http_send_recv(ctx, - "POST /loadRequest HTTP/1.1", request_headers, send_mess, - &response, NULL, &recv_mess); - if ( error != 0 ) - goto edg_wll_loadevents_end; - - if (http_check_status(ctx, response, &recv_mess)) - goto edg_wll_loadevents_end; - - edg_wll_ParseLoadResult(ctx, recv_mess, result); - -edg_wll_loadevents_end: - if (response) free(response); - if (recv_mess) free(recv_mess); - if (send_mess) free(send_mess); - return edg_wll_Error(ctx,NULL,NULL); -} diff --git a/org.glite.lb.client/src/logevent.c.T b/org.glite.lb.client/src/logevent.c.T deleted file mode 100644 index 65133fa..0000000 --- a/org.glite.lb.client/src/logevent.c.T +++ /dev/null @@ -1,287 +0,0 @@ -#ident "$Header$" - -@@@LANG: C -/* -@@@AUTO -*/ - -#include -#include -#include -#include -#include -#include // log -#include // isspace - -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/notifid.h" -#include "glite/lb/producer.h" -#include "glite/lb/events.h" - -#include "args.h" - - //" %s -p -l 100000 -j https://localhost/First_JobIV?localhost:7771 -s UserInterface -e jobAbort DG.JOB.ABORT.REASON=\"oops\"\n\n", - -// undefine to disable support for -l option -#define ENABLE_REASON_LENGTH - -int main(int argc, char *argv[]) -{ - char /* *fmt,*fname = NULL,*/ *fmt_arg=NULL; - char *server = NULL, *code = NULL; - char *ff = NULL, *jobid_s = NULL; - char *src_instance = NULL; - int err = 0/*,i,done = 0,fmtlen*/; - int pri = 0; - char *lbproxy = NULL; - int deb = 0; -#ifdef ENABLE_REASON_LENGTH - int elength = 0; -#endif - edg_wll_Context ctx; - edg_wll_Source src; - edg_wll_EventCode event = EDG_WLL_EVENT_UNDEF; - edg_wlc_JobId jobid = 0; - int (*logev)(edg_wll_Context context, - edg_wll_EventCode event, - char *fmt, ...); - - /* all possible variables */ -@@@{ - my %vars = (); - for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->getName; - my $type = { - "type" => $f->getType, - "defval" => $f->getDefaultNullValue - }; - - $type = { type=>'char *',defval=>'NULL' } if $f->{codes}; - - $vars{$fn} = $type; - } - } - foreach $name ( sort keys %vars ) { - gen qq{\t$vars{$name}->{"type"} $name = $vars{$name}->{"defval"};\n}; - } -@@@} - - /* all possible arguments */ - edg_wll_Args parray[] = { - { EDG_WLL_ARGS_EVENT, "e", "event", "select event type (see -e help)", &event }, - { EDG_WLL_ARGS_BOOL, "p", "priority", "send as priority event", &pri }, - { EDG_WLL_ARGS_STRING, "x", "lbproxy", "send directly to L&B Proxy (not locallogger) with given credentials", &lbproxy }, - { EDG_WLL_ARGS_STRING, "m", "machine", 0, &server }, - { EDG_WLL_ARGS_SOURCE, "s", "source", "event source (see -s help)", &src }, - { EDG_WLL_ARGS_STRING, "i", "source-instance", "event source instance", &src_instance }, - { EDG_WLL_ARGS_STRING, "j", "jobid", "JobId", &jobid_s }, - { EDG_WLL_ARGS_STRING, "c", "sequence", "event sequence code", &code }, - { EDG_WLL_ARGS_BOOL, "d", "debug mode", "enable debug mode", &deb }, -#ifdef ENABLE_REASON_LENGTH - { EDG_WLL_ARGS_INT, "l", "reason-length", "extend 'reason' string to length (debug only)", &elength, 0, 1000000000 }, -#endif -@@@{ - my %typetab = ( - "char *", "EDG_WLL_ARGS_STRING", - "int", "EDG_WLL_ARGS_INT", - "edg_wlc_JobId", "EDG_WLL_ARGS_JOBID", - "edg_wll_NotifId", "EDG_WLL_ARGS_NOTIFID", - "edg_wll_Source", "EDG_WLL_ARGS_SOURCE", - "uint16_t", "EDG_WLL_ARGS_UINT16" - ); - my %vars = (); - for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $ft = $f->{codes} ? 'char *' : $f->getType; - my $fn = $f->getName; - my $fc = $f->getComment; - $namehelp = { "type" => $ft, "help" => $fc }; -# gen qq{ $fn $ft $fc \n}; - $vars{$fn} = $namehelp; - } - } - foreach $name ( sort keys %vars ) { -# gen qq{ $vars{$name} $name \n }; - gen qq{\t \{ $typetab{$vars{$name}->{"type"}}, 0, "$name", "$vars{$name}->{"help"}", &$name \},\n}; - } - -@@@} - { EDG_WLL_ARGS_HELP }, - { EDG_WLL_ARGS_NONE }, - }; - edg_wll_ParseArgs(&argc, argv, parray, - "Usage: %s [-d] [-p] [-x] [-l eventlen] [-j dg_jobid]" - "[-s source_id] -e event [key=value ...]"); - -/* XXX: Obsolete? - if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { - fprintf(stderr, "Cannot initialize Globus common module\n"); - exit(1); - } -*/ - - edg_wll_InitContext(&ctx); - - /* log the event - priority/normal/proxy */ - logev = (pri) ? edg_wll_LogEventSync : edg_wll_LogEvent; - logev = (lbproxy) ? edg_wll_LogEventProxy : logev; - - /* if no job given - generate some */ - if (jobid_s == 0) { - const char* s; - if (!server) { - s = "localhost"; - err = 1; // result fail if used normaly - } else - s = server; - edg_wlc_JobIdCreate(s, 0, &jobid); - jobid_s = edg_wlc_JobIdUnparse(jobid); - fprintf(stderr, "JobId not given: created %s (server: %s)\n",jobid_s, s); - } - else if ((errno = edg_wlc_JobIdParse(jobid_s,&jobid))) { - perror(jobid_s); - exit(1); - } - - if (event == EDG_WLL_EVENT_UNDEF) { - fprintf(stderr,"%s: unknown or unspecified event\n",argv[0]); - exit(1); - } - edg_wll_SetParam(ctx, EDG_WLL_PARAM_SOURCE, src); - if (src_instance) edg_wll_SetParam(ctx, EDG_WLL_PARAM_INSTANCE, src_instance); - edg_wll_SetParam(ctx, EDG_WLL_PARAM_LEVEL, - (deb) ? EDG_WLL_LEVEL_DEBUG : EDG_WLL_LEVEL_SYSTEM); - - if (lbproxy) { - edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_STORE_SOCK, "/tmp/lb_proxy_store.sock"); - edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_SERVE_SOCK, "/tmp/lb_proxy_serve.sock"); - if (edg_wll_SetLoggingJobProxy(ctx,jobid,code,lbproxy,EDG_WLL_SEQ_NORMAL)) { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"SetLoggingJobProxy(%s,%s,%s): %s (%s)\n",jobid_s,code,lbproxy,et,ed); - exit(1); - } - } else { - if (edg_wll_SetLoggingJob(ctx,jobid,code,EDG_WLL_SEQ_NORMAL)) { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"SetLoggingJob(%s,%s): %s (%s)\n",jobid_s,code,et,ed); - exit(1); - } - } - -#ifdef ENABLE_REASON_LENGTH - if (elength > 200000000) { - fprintf(stderr,"%s: usupported reason message length: %d\n", argv[0], elength); - } else if (elength > 0) { - int d; - int i = 0; - reason = realloc(reason, elength + 1); - reason[elength] = 0; - while (i < (elength)) { - if ((i % 20) == 0 && (i + 14) < elength) - i += sprintf(reason + i, "%d", i); - reason[i++] = '.'; - } - // amount of decimal digits + "end=" - d = (int)ceil(log(i)/log(10)) + 5; - if (i > d) - sprintf(reason + i - (int)(d), "end=%d",i); - reason[i] = 0; - } -#endif -#if 0 - if (fname) { - FILE *f = fopen(fname,"r"); - long s; - size_t r; - - fmt = "%s FILE.CONTENT=\"%|Us\" "; - - if (!f) { perror(fname); return 1; } - fseek(f,0L,SEEK_END); - s = ftell(f); rewind(f); - ff = (char *) malloc(s+1); if (!ff) { perror(NULL); return 0; } - r = fread(ff,1,s,f); - printf("%s: read %d\n",fname,r); - ff[s] = 0; - fclose(f); - } - else - fmt = "%s "; -#endif - - //err = edg_wll_LogEvent(ctx, event, fmt, fmt_arg, ff); - - switch (event) - { -@@@{ -$indent = "\t"; - for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - - my $tu = uc $t; - gen $indent."case EDG_WLL_EVENT_$tu :\n"; - - selectType $event $t; - my $argl = ""; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->getName; - my $ft; - -# gen { $fn $f->{codes} }; - if ($f->{codes}) { -# $ft = "enum edg_wll\_$t" . ucfirst $fn; - $ft = "char *"; - } else { - $ft = $f->getType; - } - - $fn = $f->getType()."ToString($fn)" if $ULMasString{$f->{type}}; - - $argl = $argl . ", "; - $argl = $argl . $fn; - } -gen qq{\t //edg_wll_Log$t(); -\t err |= logev(ctx, EDG_WLL_EVENT_$tu, EDG_WLL_FORMAT_${tu}$argl); -\t break; -}; - } -@@@} - default: - fprintf(stderr, "unknown event\n"); - } - - edg_wlc_JobIdFree(jobid); - if (jobid_s) free(jobid_s); // add all strings - - if (err) { - char *et,*ed; - - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"%s: edg_wll_LogEvent*(): %s (%s)\n", - argv[0],et,ed); - free(et); free(ed); - } - - code = edg_wll_GetSequenceCode(ctx); - puts(code); - free(code); - - edg_wll_FreeContext(ctx); - - if (ff) free(ff); - if (fmt_arg) free(fmt_arg); - - return err; -} diff --git a/org.glite.lb.client/src/notification.c b/org.glite.lb.client/src/notification.c deleted file mode 100644 index 4cd2a61..0000000 --- a/org.glite.lb.client/src/notification.c +++ /dev/null @@ -1,937 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include - - -#include "glite/lb/notification.h" -#include "glite/lb/events.h" -#include "glite/lb/log_proto.h" -#include "glite/lb/mini_http.h" -#include "glite/lb/context-int.h" -#include "glite/lb/xml_parse.h" -#include "glite/lb/events_parse.h" -#include "glite/lb/il_string.h" -#include "glite/lb/escape.h" -#include "glite/lb/lb_gss.h" - -#include "connection.h" - -#define CON_QUEUE 10 /* listen() queue limit */ - -/* XXX: moving all request_headers to one file would be nice - */ -static const char* const request_headers[] = { - "Cache-Control: no-cache", - "Accept: application/x-dglb", - "User-Agent: edg_wll_Api/" PROTO_VERSION "/" COMP_PROTO, - "Content-Type: application/x-dglb", - NULL -}; - - - - -/* Decrement timeout - */ -static int decrement_timeout(struct timeval *timeout, struct timeval before, struct timeval after) -{ - if (!timeout) - return(0); // wait indefinitely - - (*timeout).tv_sec = (*timeout).tv_sec - (after.tv_sec - before.tv_sec); - (*timeout).tv_usec = (*timeout).tv_usec - (after.tv_usec - before.tv_usec); - while ( (*timeout).tv_usec < 0) { - (*timeout).tv_sec--; - (*timeout).tv_usec += 1000000; - } - if ( ((*timeout).tv_sec < 0) || (((*timeout).tv_sec == 0) && ((*timeout).tv_usec == 0)) ) return(1); - else return(0); -} - - - -/* Split address to name & port - */ -static void get_name_and_port(const char *address, char **name, int *port) -{ - char *n = NULL, *p; - - n = strdup(address); - p = strchr(n, ':'); - if (p) - { - *port = atoi(p+1); - *p = 0; - } - *name = strdup(n); - free(n); -} - - -static int my_bind(edg_wll_Context ctx, const char *name, int port, int *fd) -{ - struct sockaddr_in a; - socklen_t alen = sizeof(a); - int sock; - - sock = socket(PF_INET,SOCK_STREAM,0); - if (sock<0) - return edg_wll_SetError(ctx, errno, "socket() failed"); - - a.sin_family = AF_INET; - a.sin_port = htons(port); - a.sin_addr.s_addr = name? inet_addr(name): htonl(INADDR_ANY); - -// setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); - if (bind(sock,(struct sockaddr *)&a,alen)) - return edg_wll_SetError(ctx, errno, "bind() failed"); - - - if (listen(sock,CON_QUEUE)) - return edg_wll_SetError(ctx, errno, "listen() failed"); - - *fd = sock; - - return edg_wll_Error(ctx,NULL,NULL); -} - - - -static int set_server_name_and_port(edg_wll_Context ctx) -{ - - if (!ctx->p_notif_server) - return(edg_wll_SetError(ctx, (edg_wll_ErrorCode) EINVAL, - "Hostname of server to notif is not set")); - else { - free(ctx->srvName); - ctx->srvName = strdup(ctx->p_notif_server); - } - if (!ctx->p_notif_server_port) - return(edg_wll_SetError(ctx, (edg_wll_ErrorCode) EINVAL, - "Port of server to notif is not set")); - else ctx->srvPort = ctx->p_notif_server_port; - - return edg_wll_Error(ctx,NULL,NULL); -} - - - -static int get_client_address( - edg_wll_Context ctx, - int fd, - const char *address_override, - char **address) - -{ - struct sockaddr_in a; - socklen_t alen = sizeof(a); - struct hostent *he; - char *name = NULL; - int port = 0; - - - if (address_override) { - struct in_addr in; - - get_name_and_port(address_override, &name, &port); - - if ( (he = gethostbyname((const char *) name)) == NULL) { - edg_wll_SetError(ctx, errno, "gethostbyname() failed"); - goto err; - } - - free(name); - - memmove(&in.s_addr, he->h_addr_list[0], sizeof(in.s_addr)); - name = strdup(inet_ntoa(in)); - - if ( (he = gethostbyname((const char *) name)) == NULL) { - edg_wll_SetError(ctx, errno, "gethostbyname() failed"); - goto err; - } - - /* Test whether open sockket represents the same address as address_override - * if not, close ctx->notifSock and bind to new socket corresponding to - * address_override - */ - if (ctx->notifSock >= 0) { - if (getsockname(ctx->notifSock, (struct sockaddr *) &a, &alen)) - return edg_wll_SetError(ctx, errno, "getsockname() failed"); - - if ( (strcmp(inet_ntoa(a.sin_addr), name)) || (ntohs(a.sin_port) != port) ) { - - if (close(ctx->notifSock)) { - edg_wll_SetError(ctx, errno, "close() failed"); - goto err; - } - ctx->notifSock = -1; - - if (my_bind(ctx, name, port, &(ctx->notifSock))) - goto err; - } - } - else { // create new socket - if (my_bind(ctx, name, port, &(ctx->notifSock))) - goto err; - } - - *address = strdup(address_override); - } - else { // address_override == NULL - - if (fd == -1) { - if (ctx->notifSock == -1) - // create new socket - if (my_bind(ctx, NULL, 0, &(ctx->notifSock))) - goto err; - // else: resue socket - } - else - // used supplied socket - ctx->notifSock = fd; - - if (getsockname(ctx->notifSock,(struct sockaddr *) &a, &alen)) - return edg_wll_SetError(ctx, errno, "getsockname() failed"); - - if (a.sin_addr.s_addr == INADDR_ANY) - asprintf(address,"0.0.0.0:%d", ntohs(a.sin_port)); - else - asprintf(address,"%s:%d", inet_ntoa(a.sin_addr), ntohs(a.sin_port)); - } - -err: - free(name); - - return edg_wll_Error(ctx,NULL,NULL); -} - - - -int edg_wll_NotifNew( - edg_wll_Context ctx, - edg_wll_QueryRec const * const *conditions, - int fd, - const char *address_override, - edg_wll_NotifId *id_out, - time_t *valid) -{ - edg_wll_NotifId notifId = NULL; - char *address = NULL, *send_mess = NULL, - *recv_mess = NULL, *response = NULL; - int ret; - - - edg_wll_ResetError(ctx); - - if ( (ret = set_server_name_and_port(ctx)) ) - goto err; - - if ( (ret = edg_wll_NotifIdCreate(ctx->srvName,ctx->srvPort,¬ifId)) ) - goto err; - - if ( (ret = get_client_address(ctx, fd, address_override, &address)) ) - goto err; - - if ( (ret = edg_wll_NotifRequestToXML(ctx, "New", notifId, address, - EDG_WLL_NOTIF_NOOP, conditions, &send_mess)) ) - goto err; - - ctx->p_tmp_timeout = ctx->p_notif_timeout; - - if ( (ret = edg_wll_http_send_recv(ctx, "POST /notifRequest HTTP/1.1", - request_headers,send_mess, - &response,NULL,&recv_mess)) ) - goto err; - - if ( (ret = http_check_status(ctx,response)) ) - goto err; - - ret = edg_wll_ParseNotifResult(ctx, recv_mess, valid); - - -err: - if (ret != 0) { - if (notifId) edg_wll_NotifIdFree(notifId); - *id_out = NULL; - *valid = -1; - } - else - *id_out = notifId; - - free(address); - free(recv_mess); - free(send_mess); - free(response); - return edg_wll_Error(ctx,NULL,NULL); -} - - - -int edg_wll_NotifBind( - edg_wll_Context ctx, - const edg_wll_NotifId id, - int fd, - const char *address_override, - time_t *valid) -{ - char *address = NULL, *send_mess = NULL, - *recv_mess = NULL, *response = NULL; - - - edg_wll_ResetError(ctx); - - - // if a local listening socket active, close it - if (ctx->notifSock >= 0) { - if (close(ctx->notifSock)) - return edg_wll_SetError(ctx, errno, "close() failed"); - else - ctx->notifSock = -1; - } - - if (set_server_name_and_port(ctx)) - goto err; - - if (get_client_address(ctx, fd, address_override, &address)) - goto err; - - if (edg_wll_NotifRequestToXML(ctx, "Bind", id, address, - EDG_WLL_NOTIF_NOOP, NULL, &send_mess)) - goto err; - - ctx->p_tmp_timeout = ctx->p_notif_timeout; - - if (edg_wll_http_send_recv(ctx, "POST /notifRequest HTTP/1.1", - request_headers,send_mess, - &response,NULL,&recv_mess)) - goto err; - - if (http_check_status(ctx,response)) - goto err; - - edg_wll_ParseNotifResult(ctx, recv_mess, valid); - -err: - free(address); - free(recv_mess); - free(send_mess); - free(response); - return edg_wll_Error(ctx,NULL,NULL); -} - - - -int edg_wll_NotifChange( - edg_wll_Context ctx, - const edg_wll_NotifId id, - edg_wll_QueryRec const * const * conditions, - edg_wll_NotifChangeOp op) -{ - char *send_mess = NULL, *recv_mess = NULL, *response = NULL; - time_t not_used; - - - edg_wll_ResetError(ctx); - - - if (set_server_name_and_port(ctx)) - goto err; - - if (edg_wll_NotifRequestToXML(ctx, "Change", id, NULL, - op, conditions, &send_mess)) - goto err; - - ctx->p_tmp_timeout = ctx->p_notif_timeout; - - if (edg_wll_http_send_recv(ctx, "POST /notifRequest HTTP/1.1", - request_headers,send_mess, - &response,NULL,&recv_mess)) - goto err; - - if (http_check_status(ctx,response)) - goto err; - - edg_wll_ParseNotifResult(ctx, recv_mess, ¬_used); - -err: - free(recv_mess); - free(send_mess); - free(response); - return edg_wll_Error(ctx,NULL,NULL); -} - - - -int edg_wll_NotifRefresh( - edg_wll_Context ctx, - const edg_wll_NotifId id, - time_t *valid) -{ - char *send_mess = NULL, *recv_mess = NULL, *response = NULL; - - - edg_wll_ResetError(ctx); - - - if (set_server_name_and_port(ctx)) - goto err; - - if (edg_wll_NotifRequestToXML(ctx, "Refresh", id, NULL, - EDG_WLL_NOTIF_NOOP, NULL, &send_mess)) - goto err; - - ctx->p_tmp_timeout = ctx->p_notif_timeout; - - if (edg_wll_http_send_recv(ctx, "POST /notifRequest HTTP/1.1", - request_headers,send_mess, - &response,NULL,&recv_mess)) - goto err; - - if (http_check_status(ctx,response)) - goto err; - - edg_wll_ParseNotifResult(ctx, recv_mess, valid); - -err: - free(recv_mess); - free(send_mess); - free(response); - return edg_wll_Error(ctx,NULL,NULL); -} - - - -int edg_wll_NotifDrop( - edg_wll_Context ctx, - edg_wll_NotifId *id) -{ - char *send_mess = NULL, *recv_mess = NULL, *response = NULL; - time_t not_used; - - - edg_wll_ResetError(ctx); - - - if (set_server_name_and_port(ctx)) - goto err; - - if (edg_wll_NotifRequestToXML(ctx, "Drop", id, NULL, - EDG_WLL_NOTIF_NOOP, NULL, &send_mess)) - goto err; - - ctx->p_tmp_timeout = ctx->p_notif_timeout; - - if (edg_wll_http_send_recv(ctx, "POST /notifRequest HTTP/1.1", - request_headers,send_mess, - &response,NULL,&recv_mess)) - goto err; - - if (http_check_status(ctx,response)) - goto err; - - edg_wll_ParseNotifResult(ctx, recv_mess, ¬_used); - -err: - free(recv_mess); - free(send_mess); - free(response); - return edg_wll_Error(ctx,NULL,NULL); -} - - - -static int recv_notif(edg_wll_Context ctx) -{ - int ret, len; - char fbuf[17]; - size_t total; - edg_wll_GssStatus gss_code; - - - if (ctx->connPoolNotif[0].buf) { - free(ctx->connPoolNotif[0].buf); - ctx->connPoolNotif[0].buf = NULL; - } - ctx->connPoolNotif[0].bufUse = 0; - ctx->connPoolNotif[0].bufSize = 0; - - ret = edg_wll_gss_read_full(&ctx->connPoolNotif[0].gss, - fbuf,17, &ctx->p_tmp_timeout,&total, &gss_code); - if (ret < 0) - switch (ret) { - case EDG_WLL_GSS_ERROR_TIMEOUT: - return edg_wll_SetError(ctx,ETIMEDOUT,"read message header"); - case EDG_WLL_GSS_ERROR_EOF: - return edg_wll_SetError(ctx,ENOTCONN,NULL); - case EDG_WLL_GSS_ERROR_GSS: - return edg_wll_SetErrorGss(ctx, "read message header", &gss_code); - default: - return edg_wll_SetError(ctx,EDG_WLL_ERROR_GSS,"read message header"); /* XXX */ - } - - if ((len = atoi(fbuf)) <= 0) { - return edg_wll_SetError(ctx,EINVAL,"message length"); - } - - ctx->connPoolNotif[0].bufSize = len+1; - - ctx->connPoolNotif[0].buf = (char *) malloc( - ctx->connPoolNotif[0].bufSize); - - if (!ctx->connPoolNotif[0].buf) { - return edg_wll_SetError(ctx, ENOMEM, "recv_notif()"); - } - - - ret = edg_wll_gss_read_full(&ctx->connPoolNotif[0].gss, - ctx->connPoolNotif[0].buf, len, - &ctx->p_tmp_timeout,&total, &gss_code); - if (ret < 0) { - free(ctx->connPoolNotif[0].buf); - ctx->connPoolNotif[0].bufUse = 0; - ctx->connPoolNotif[0].bufSize = 0; - return edg_wll_SetError(ctx, - ret == EDG_WLL_GSS_ERROR_TIMEOUT ? - ETIMEDOUT : EDG_WLL_ERROR_GSS, - "read message"); - } - - - ctx->connPoolNotif[0].buf[len] = 0; - ctx->connPoolNotif[0].bufUse = len+1; - - - return edg_wll_Error(ctx,NULL,NULL); -} - - - -static int send_reply(const edg_wll_Context ctx) -{ - int ret, len, err_code, err_code_min = 0, max_len = 256; - char *p, *err_msg = NULL, buf[max_len]; - size_t total; - edg_wll_GssStatus gss_code; - - - err_code = edg_wll_Error(ctx,NULL,&err_msg); - - if (!err_msg) err_msg=strdup("OK"); - - len = 17 + len_int(err_code) + len_int(err_code_min) +len_string(err_msg); - if(len > max_len) { - edg_wll_SetError(ctx,E2BIG,"create_reply()"); - goto err; - } - - snprintf(buf, max_len, "%16d\n", len - 17); - p = buf + 17; - p = put_int(p, err_code); - p = put_int(p, err_code_min); - p = put_string(p, err_msg); - - ret = edg_wll_gss_write_full(&ctx->connPoolNotif[0].gss, - buf,len,&ctx->p_tmp_timeout,&total, &gss_code); - if (ret < 0) { - edg_wll_SetError(ctx, - ret == EDG_WLL_GSS_ERROR_TIMEOUT ? - ETIMEDOUT : EDG_WLL_ERROR_GSS, - "write reply"); - goto err; - } - -err: - free(err_msg); - return edg_wll_Error(ctx,NULL,NULL); -} - - - - -int edg_wll_NotifReceive( - edg_wll_Context ctx, - int fd, - const struct timeval *timeout, - edg_wll_JobStat *state_out, - edg_wll_NotifId *id_out) - -/* pullup from INFN, support multiple messages from interlogger */ -#if 0 -{ - fd_set fds; - struct sockaddr_in a; - int recv_sock, alen; - edg_wll_Event *event = NULL; - struct timeval start_time,check_time,tv; - char *p = NULL, *ucs = NULL, - *event_char = NULL, *jobstat_char = NULL; - int ret; - edg_wll_GssStatus gss_code; - - - edg_wll_ResetError(ctx); - - /* start timer */ - gettimeofday(&start_time,0); - - if (fd == -1) { - if (ctx->notifSock == -1) { - edg_wll_SetError(ctx, EINVAL, "No client socket opened."); - goto err; - } - else { - fd = ctx->notifSock; - } - } - - FD_ZERO(&fds); - FD_SET(fd,&fds); - - tv.tv_sec = timeout->tv_sec; - tv.tv_usec = timeout->tv_usec; - - switch(select(fd+1, &fds, NULL, NULL, &tv)) { - case -1: - edg_wll_SetError(ctx, errno, "select() failed"); - goto err; - case 0: - edg_wll_SetError(ctx, ETIMEDOUT, "select() timeouted"); - goto err; - default: - break; - } - -/* check time */ - gettimeofday(&check_time,0); - if (decrement_timeout(&tv, start_time, check_time)) { - edg_wll_SetError(ctx, ETIMEDOUT, "edg_wll_NotifReceive()"); - goto err; - } - - start_time = check_time; - - alen=sizeof(a); - recv_sock = accept(fd,&a,&alen); - if (recv_sock <0) { - edg_wll_SetError(ctx, errno, "accept() failed"); - goto err; - } - - ret = edg_wll_gss_accept(ctx->connPool[ctx->connToUse].gsiCred, recv_sock, - &tv, &ctx->connPool[ctx->connToUse].gss, &gss_code); - - if (ret) { - edg_wll_SetError(ctx, errno, "GSS authentication failed."); - goto err; - } - -/* check time */ - gettimeofday(&check_time,0); - if (decrement_timeout(&tv, start_time, check_time)) { - edg_wll_SetError(ctx, ETIMEDOUT, "edg_wll_NotifReceive()"); - goto err; - } - - start_time = check_time; - - - ctx->p_tmp_timeout = tv; - - if (recv_notif(ctx)) { - /* error set in recv_notif() */ - goto err; - } - - if (send_reply(ctx)) { - /* error set in send_reply() */ - goto err; - } - - p = ctx->connPool[ctx->connToUse].buf; - p = get_string(p, &ucs); - if (p == NULL) return edg_wll_SetError(ctx,EDG_WLL_IL_PROTO,"reading UCS"); - free(ucs); - - p = get_string(p, &event_char); - if (p == NULL) { - free(ucs); - return edg_wll_SetError(ctx,EDG_WLL_IL_PROTO,"reading event string");; - } - - /****************************************************************/ - /* end of notif-interlogger message exchange */ - /****************************************************************/ - - /* check time */ - gettimeofday(&check_time,0); - if (decrement_timeout(&tv, start_time, check_time)) { - edg_wll_SetError(ctx, ETIMEDOUT, "edg_wll_NotifReceive()"); - goto err; - } - start_time = check_time; - - event = edg_wll_InitEvent(EDG_WLL_EVENT_NOTIFICATION); - if (edg_wll_ParseNotifEvent(ctx, event_char, &event)) { - goto err; - } - - jobstat_char = edg_wll_UnescapeXML((const char *) event->notification.jobstat); - if (jobstat_char == NULL) { - edg_wll_SetError(ctx, EINVAL, "edg_wll_UnescapeXML()"); - goto err; - } - - /* fill in return values - */ - if ( edg_wll_ParseJobStat(ctx, jobstat_char, - strlen(jobstat_char), state_out)) { - goto err; - } - - if ( id_out ) { - *id_out = event->notification.notifId; - event->notification.notifId = NULL; - } - - -err: - if (event) { - edg_wll_FreeEvent(event); - // XXX - konzultovat s honikem; podle meho by to free - // mel delat uz edg_wll_FreeEvent - //free(event); - } - - free(ctx->connPool[ctx->connToUse].buf); - ctx->connPool[ctx->connToUse].buf = NULL; - ctx->connPool[ctx->connToUse].bufUse = 0; - ctx->connPool[ctx->connToUse].bufSize = 0; - - free(event_char); - free(jobstat_char); - - // XXX - // konzultovat s Danem - /* Dan: ??? */ - edg_wll_gss_close(&ctx->connPool[ctx->connToUse].gss, NULL); - - return edg_wll_Error(ctx,NULL,NULL); -} -#endif -/* NotifReceive */ -{ - fd_set fds; - struct sockaddr_in a; - int recv_sock, alen; - edg_wll_Event *event = NULL; - struct timeval start_time,check_time,tv; - char *p = NULL, *ucs = NULL, - *event_char = NULL, *jobstat_char = NULL; - edg_wll_GssStatus gss_code; - - - edg_wll_ResetError(ctx); - - /* start timer */ - gettimeofday(&start_time,0); - - if (fd == -1) { - if (ctx->notifSock == -1) { - edg_wll_SetError(ctx, EINVAL, "No client socket opened."); - goto err; - } - else { - fd = ctx->notifSock; - } - } - - FD_ZERO(&fds); - FD_SET(fd,&fds); - tv.tv_sec = timeout->tv_sec; - tv.tv_usec = timeout->tv_usec; - - -select: - /* XXX - index 0 is used because of absence of connection management */ - /* to use it, support in client/connection.c needed */ - /* it is better to separate it from ctx->connPool, which is used */ - /* for outgouing messages to server */ - /* In future it should be in context, so one could use: */ - /* ctx->connPoolNotif[ctx->connPoolNotifToUse] */ - /* notif_send() & notif_receive() should then migrate to */ - /* client/connection.c and use connPool management f-cions */ - - if (ctx->connPoolNotif[0].gss.context == GSS_C_NO_CONTEXT) - { - int ret; - switch(select(fd+1, &fds, NULL, NULL, &tv)) { - case -1: - edg_wll_SetError(ctx, errno, "select() failed"); - goto err; - case 0: - edg_wll_SetError(ctx, ETIMEDOUT, "select() timeouted"); - goto err; - default: - break; - } - - /* check time */ - gettimeofday(&check_time,0); - if (decrement_timeout(&tv, start_time, check_time)) { - edg_wll_SetError(ctx, ETIMEDOUT, "edg_wll_NotifReceive()"); - goto err; - } - start_time = check_time; - - alen=sizeof(a); - recv_sock = accept(fd,(struct sockaddr *)&a,&alen); - if (recv_sock <0) { - edg_wll_SetError(ctx, errno, "accept() failed"); - goto err; - } - - ret = edg_wll_gss_accept(ctx->connPoolNotif[0].gsiCred, recv_sock, - &tv, &ctx->connPoolNotif[0].gss,&gss_code); - if (ret) { - edg_wll_SetError(ctx, errno, "GSS authentication failed."); - goto err; - } - - /* check time */ - gettimeofday(&check_time,0); - if (decrement_timeout(&tv, start_time, check_time)) { - edg_wll_SetError(ctx, ETIMEDOUT, "edg_wll_NotifReceive()"); - goto err; - } - start_time = check_time; - } - - - ctx->p_tmp_timeout = tv; - - /****************************************************************/ - /* Communication with notif-interlogger */ - /****************************************************************/ - - if (recv_notif(ctx)) { - if (ctx->errCode == ENOTCONN) { - /* other side (interlogger-notif) probably closed connection */ - edg_wll_ResetError(ctx); - - edg_wll_gss_close(&ctx->connPoolNotif[0].gss,NULL); - // buffer is freed in recv_notif() - - goto select; - } - else { - goto err; /* error set in recv_notif() */ - } - } - - if (send_reply(ctx)) { - goto err; /* error set in send_reply() */ - } - - p = ctx->connPoolNotif[0].buf; - p = get_string(p, &ucs); - if (p == NULL) return edg_wll_SetError(ctx,EDG_WLL_IL_PROTO,"reading UCS"); - free(ucs); - - p = get_string(p, &event_char); - if (p == NULL) { - free(ucs); - return edg_wll_SetError(ctx,EDG_WLL_IL_PROTO,"reading event string");; - } - - /****************************************************************/ - /* end of notif-interlogger message exchange */ - /****************************************************************/ - - /* check time */ - gettimeofday(&check_time,0); - if (decrement_timeout(&tv, start_time, check_time)) { - edg_wll_SetError(ctx, ETIMEDOUT, "edg_wll_NotifReceive()"); - goto err; - } - start_time = check_time; - - event = edg_wll_InitEvent(EDG_WLL_EVENT_NOTIFICATION); - if (edg_wll_ParseNotifEvent(ctx, event_char, &event)) { - goto err; - } - - jobstat_char = edg_wll_UnescapeXML((const char *) event->notification.jobstat); - if (jobstat_char == NULL) { - edg_wll_SetError(ctx, EINVAL, "edg_wll_UnescapeXML()"); - goto err; - } - - /* fill in return values - */ - if ( edg_wll_ParseJobStat(ctx, jobstat_char, - strlen(jobstat_char), state_out)) { - goto err; - } - - if (id_out) { - *id_out = event->notification.notifId; - event->notification.notifId = NULL; - } - -err: - if (event) { - edg_wll_FreeEvent(event); - // XXX - konzultovat s honikem; podle meho by to free - // mel delat uz edg_wll_FreeEvent - //free(event); - } - - free(ctx->connPoolNotif[0].buf); - ctx->connPoolNotif[0].buf = NULL; - ctx->connPoolNotif[0].bufUse = 0; - ctx->connPoolNotif[0].bufSize = 0; - - free(event_char); - free(jobstat_char); - - return edg_wll_Error(ctx,NULL,NULL); -} - - -int edg_wll_NotifGetFd( - edg_wll_Context ctx) -{ - if (ctx->notifSock == -1) { - edg_wll_SetError(ctx, EBADF, "Client socket is not opened."); - return -1; - } - - return ctx->notifSock; -} - - -int edg_wll_NotifCloseFd( - edg_wll_Context ctx) -{ - int err; - - if (ctx->notifSock >= 0) { - if (ctx->connPoolNotif[0].gss.context != GSS_C_NO_CONTEXT) { - edg_wll_gss_close(&ctx->connPoolNotif[0].gss, NULL); - } - err = close(ctx->notifSock); - ctx->notifSock = -1; - - if (err) - return edg_wll_SetError(ctx, errno, "close() failed"); - } - - return edg_wll_Error(ctx,NULL,NULL); -} diff --git a/org.glite.lb.client/src/prod_proto.c b/org.glite.lb.client/src/prod_proto.c deleted file mode 100644 index 49a3257..0000000 --- a/org.glite.lb.client/src/prod_proto.c +++ /dev/null @@ -1,303 +0,0 @@ -#ident "$Header$" - -#include "prod_proto.h" -#include "glite/lb/producer.h" -#include "glite/lb/escape.h" -#include "glite/lb/lb_gss.h" -#include "glite/lb/lb_plain_io.h" -#include "glite/lb/il_string.h" - -#include -#include -#include - -/* - *---------------------------------------------------------------------- - * - * edg_wll_log_proto_client - client part of the logging protocol - * used when sending messages to local logger - * - * Returns: 0 if done properly or errno - * - * Calls: - * - * Algorithm: - * - *---------------------------------------------------------------------- - */ -int edg_wll_log_proto_client(edg_wll_Context context, edg_wll_GssConnection *con, edg_wll_LogLine logline/*, int priority,*/) -{ - char header[EDG_WLL_LOG_SOCKET_HEADER_LENGTH+1]; - int err; - int answer; - u_int8_t answer_end[4]; - size_t count; - int size; - u_int8_t size_end[4]; - edg_wll_GssStatus gss_code; - - errno = err = answer = count = 0; - size = strlen(logline)+1; - size_end[0] = size & 0xff; size >>= 8; - size_end[1] = size & 0xff; size >>= 8; - size_end[2] = size & 0xff; size >>= 8; - size_end[3] = size; - size = strlen(logline)+1; - edg_wll_ResetError(context); - - /* send header */ -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Sending socket header...\n"); -#endif - sprintf(header,"%s",EDG_WLL_LOG_SOCKET_HEADER); - header[EDG_WLL_LOG_SOCKET_HEADER_LENGTH]='\0'; - if ((err = edg_wll_gss_write_full(con, header, EDG_WLL_LOG_SOCKET_HEADER_LENGTH, &context->p_tmp_timeout, &count, &gss_code)) < 0) { - answer = edg_wll_log_proto_client_failure(context,err,&gss_code,"send header"); - goto edg_wll_log_proto_client_end; - } - -/* XXX: obsolete -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Sending message priority...\n"); -#endif - count = 0; - if ((err = edg_wll_gss_write_full(con, &priority, sizeof(priority), &context->p_tmp_timeout, &count, &gss_code)) < 0) { - answer = edg_wll_log_proto_client_failure(context,err,&gss_code,"send message priority"); - goto edg_wll_log_proto_client_end; - } -*/ - -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Sending message size...\n"); -#endif - count = 0; - if ((err = edg_wll_gss_write_full(con, size_end, 4, &context->p_tmp_timeout, &count, &gss_code)) < 0) { - answer = edg_wll_log_proto_client_failure(context,err,&gss_code,"send message size"); - goto edg_wll_log_proto_client_end; - } - - /* send message */ -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Sending message to socket...\n"); -#endif - count = 0; - if (( err = edg_wll_gss_write_full(con, logline, size, &context->p_tmp_timeout, &count, &gss_code)) < 0) { - answer = edg_wll_log_proto_client_failure(context,err,&gss_code,"send message"); - goto edg_wll_log_proto_client_end; - } - - /* get answer */ -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Reading answer from server...\n"); -#endif - count = 0; - if ((err = edg_wll_gss_read_full(con, answer_end, 4, &context->p_tmp_timeout, &count, &gss_code)) < 0 ) { - answer = edg_wll_log_proto_client_failure(context,err,&gss_code,"get answer"); -/* FIXME: update the answer (in context?) to EAGAIN or not? - answer = EAGAIN; -*/ - } else { - answer = answer_end[3]; answer <<=8; - answer |= answer_end[2]; answer <<=8; - answer |= answer_end[1]; answer <<=8; - answer |= answer_end[0]; -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Read answer \"%d\"\n",answer); -#endif - edg_wll_SetError(context,answer,"answer read from locallogger"); - } - -edg_wll_log_proto_client_end: - - return edg_wll_Error(context,NULL,NULL); -} - -/* - *---------------------------------------------------------------------- - * - * edg_wll_log_proto_client_failure - handle protocol failures on the client side - * - * Returns: errno - * - *---------------------------------------------------------------------- - */ -int edg_wll_log_proto_client_failure(edg_wll_Context context, int code, edg_wll_GssStatus *gss_code, const char *text) -{ - const char *func="edg_wll_log_proto_client()"; - static char err[256]; - int ret = 0; - char *gss_err; - - edg_wll_ResetError(context); - - if(code>0) - return(0); - - switch(code) { - case EDG_WLL_GSS_ERROR_EOF: - snprintf(err, sizeof(err), "%s: Error %s, EOF occured;", func, text); - ret = edg_wll_SetError(context,ENOTCONN,err); - break; - case EDG_WLL_GSS_ERROR_TIMEOUT: - snprintf(err, sizeof(err), "%s: Error %s, timeout expired;", func, text); - ret = edg_wll_SetError(context,ENOTCONN,err); - break; - case EDG_WLL_GSS_ERROR_ERRNO: // XXX: perror("edg_wll_ssl_read()"); break; - snprintf(err, sizeof(err), "%s: Error %s, system error occured;", func, text); - ret = edg_wll_SetError(context,ENOTCONN,err); - break; - case EDG_WLL_GSS_ERROR_GSS: - snprintf(err, sizeof(err), "%s: Error %s, GSS error occured", func, text); - edg_wll_gss_get_error(gss_code, err, &gss_err); - ret = edg_wll_SetError(context,ENOTCONN,gss_err); - free(gss_err); - break; - default: - break; - } - return ret; -} - -/* - * Read reply from server. - * Returns: -1 - error reading message, - * code > 0 - error code from server - */ -static -int -get_reply(edg_wll_Context context, edg_wll_PlainConnection *conn, char **buf, int *code_min) -{ - char buffer[17]; - char *msg, *p; - int len, code; - - code = 0; - /* get message header */ - len = edg_wll_plain_read_full(conn, buffer, 17, &context->p_tmp_timeout); - if(len < 0) { - edg_wll_SetError(context,LB_PROTO,"get_reply(): error reading message header"); - goto get_reply_end; - } - - buffer[16] = 0; - - sscanf(buffer, "%d", &len); - if(len > MAXLEN) { - edg_wll_SetError(context,LB_PROTO,"get_reply(): error reading message body length"); - goto get_reply_end; - } - - /* allocate room for message body */ - if((msg = malloc(len)) == NULL) { - edg_wll_SetError(context,ENOMEM,"get_reply(): no room for message body"); - goto get_reply_end; - } - - /* read all the data */ - len = edg_wll_plain_read_full(conn, msg, len, &context->p_tmp_timeout); - if(len < 0) { - edg_wll_SetError(context,LB_PROTO,"get_reply(): error reading message body"); - goto get_reply_end; - } - - p = msg; - p = get_int(p, &code); - if(p == NULL) { - edg_wll_SetError(context,LB_PROTO,"get_reply(): error reading result code"); - free(msg); - goto get_reply_end; - } - p = get_int(p, code_min); - if(p == NULL) { - edg_wll_SetError(context,LB_PROTO,"get_reply(): error reading result code minor"); - free(msg); - goto get_reply_end; - } - p = get_string(p, buf); - if(p == NULL) { - if(*buf) { - free(*buf); - *buf = NULL; - } - edg_wll_SetError(context,LB_PROTO,"get_reply(): error reading result string"); - free(msg); - goto get_reply_end; - } - -get_reply_end: - if(msg) free(msg); - return edg_wll_Error(context,NULL,NULL); -} - -/* - *---------------------------------------------------------------------- - * - * edg_wll_log_proto_client_proxy - client part of the logging protocol - * used when sending messages to L&B Proxy - * - * Returns: 0 if done properly or errno - * - * Calls: - * - * Algorithm: - * - *---------------------------------------------------------------------- - */ -int edg_wll_log_proto_client_proxy(edg_wll_Context context, edg_wll_PlainConnection *conn, edg_wll_LogLine logline) -{ - char *p; int len; - char *ucs = "honik6"; - char *buffer,*answer = NULL; - int err; - int code; - int count; - - errno = err = code = count = 0; - edg_wll_ResetError(context); - - /* allocate enough room to hold the message */ - len = 17 + len_string(ucs) + len_string(logline); - if((buffer = malloc(len)) == NULL) { - edg_wll_SetError(context,ENOMEM,"get_reply(): no room for message body"); - goto edg_wll_log_proto_client_proxy_end; - } - p = buffer; - - /* write header */ - sprintf(p, "%16d\n", len - 17); - p += 17; - - /* write rest of the message */ - p = put_string(p, ucs); - p = put_string(p, logline); - - /* send message */ -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Sending message to socket...\n"); -#endif - if (( count = edg_wll_plain_write_full(conn, buffer, len, &context->p_tmp_timeout)) < 0) { - edg_wll_SetError(context,LB_PROTO,"edg_wll_log_proto_client_proxy(): error sending message to socket"); - goto edg_wll_log_proto_client_proxy_end; - } - - /* get answer */ -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Reading answer from server...\n"); -#endif - count = 0; - if ((err = get_reply(context, conn, &answer, &code)) < 0 ) { - edg_wll_SetError(context,LB_PROTO,"edg_wll_log_proto_client_proxy(): error reading answer from L&B proxy server"); - } else { -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Read answer \"%d: %s\"\n",code,answer); -#endif - edg_wll_SetError(context,code,"answer read from L&B proxy server"); - } - -edg_wll_log_proto_client_proxy_end: - - if (buffer) free(buffer); - if (answer) free(answer); - return edg_wll_Error(context,NULL,NULL); -} - diff --git a/org.glite.lb.client/src/prod_proto.h b/org.glite.lb.client/src/prod_proto.h deleted file mode 100644 index 2945cf1..0000000 --- a/org.glite.lb.client/src/prod_proto.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_PROD_PROTO_H__ -#define __EDG_WORKLOAD_LOGGING_CLIENT_PROD_PROTO_H__ - -#ident "$Header$" - -/** - * \file edg/workload/logging/client/prod_proto.h - * \brief client (producer) part of the logging protocol - * \note private - */ - -#ifdef __cplusplus -extern "C" { -#endif - - -#include "glite/lb/log_proto.h" -#include "glite/lb/context-int.h" -#include "glite/lb/lb_gss.h" - -int edg_wll_log_proto_client(edg_wll_Context context, edg_wll_GssConnection *con, edg_wll_LogLine logline/*, int priority,*/); -int edg_wll_log_proto_client_failure(edg_wll_Context context, int code, edg_wll_GssStatus *gss_code, const char *text); -int edg_wll_log_proto_client_proxy(edg_wll_Context context, edg_wll_PlainConnection *conn, edg_wll_LogLine logline); - -#ifdef __cplusplus -} -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_CLIENT_PROD_PROTO_H__ */ diff --git a/org.glite.lb.client/src/producer.c b/org.glite.lb.client/src/producer.c deleted file mode 100644 index b459910..0000000 --- a/org.glite.lb.client/src/producer.c +++ /dev/null @@ -1,940 +0,0 @@ -/** - * \file producer.c - * \author Jan Pospisil - */ - -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/strmd5.h" -#include "glite/lb/consumer.h" -#include "glite/lb/producer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/ulm_parse.h" -#include "glite/lb/trio.h" -#include "glite/lb/lb_gss.h" -#include "glite/lb/lb_plain_io.h" -#include "glite/lb/escape.h" - -#include "prod_proto.h" - -static const char* socket_path="/tmp/lb_proxy_store.sock"; - -#ifdef FAKE_VERSION -int edg_wll_DoLogEvent(edg_wll_Context context, edg_wll_LogLine logline); -int edg_wll_DoLogEventProxy(edg_wll_Context context, edg_wll_LogLine logline); -#else -/** - *---------------------------------------------------------------------- - * Connects to local-logger and sends already formatted ULM string - * \brief helper logging function - * \param context INOUT context to work with, - * \param priority IN priority flag (0 for async, 1 for sync) - * \param logline IN formated ULM string - *---------------------------------------------------------------------- - */ -static int edg_wll_DoLogEvent( - edg_wll_Context context, -/* int priority, */ - edg_wll_LogLine logline) -{ - int ret,answer; - char *my_subject_name = NULL; - edg_wll_GssStatus gss_stat; - edg_wll_GssConnection con; - gss_cred_id_t cred = GSS_C_NO_CREDENTIAL; - OM_uint32 min_stat; - - edg_wll_ResetError(context); - ret = answer = 0; - memset(&con, 0, sizeof(con)); - - /* open an authenticated connection to the local-logger: */ - -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Logging to host %s, port %d\n", - context->p_destination, context->p_dest_port); -#endif - ret = edg_wll_gss_acquire_cred_gsi( - context->p_proxy_filename ? context->p_proxy_filename : context->p_cert_filename, - context->p_proxy_filename ? context->p_proxy_filename : context->p_key_filename, - &cred, &my_subject_name, &gss_stat); - /* Give up if unable to prescribed credentials, otherwise go on anonymously */ - if (ret && context->p_proxy_filename) { - edg_wll_SetErrorGss(context, "failed to load GSI credentials", &gss_stat); - goto edg_wll_DoLogEvent_end; - } - - if (my_subject_name != NULL) { -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Using certificate: %s\n",my_subject_name); -#endif - free(my_subject_name); - } - if ((answer = edg_wll_gss_connect(cred, - context->p_destination, context->p_dest_port, - &context->p_tmp_timeout, &con, &gss_stat)) < 0) { - switch(answer) { - case EDG_WLL_GSS_ERROR_EOF: - edg_wll_SetError(context,ENOTCONN,"edg_wll_gss_connect()"); - break; - case EDG_WLL_GSS_ERROR_TIMEOUT: - edg_wll_SetError(context,ETIMEDOUT,"edg_wll_gss_connect()"); - break; - case EDG_WLL_GSS_ERROR_ERRNO: - edg_wll_SetError(context,errno,"edg_wll_gss_connect()"); - break; - case EDG_WLL_GSS_ERROR_GSS: - edg_wll_SetErrorGss(context, "failed to authenticate to server",&gss_stat); - break; - case EDG_WLL_GSS_ERROR_HERRNO: - { - const char *msg1; - char *msg2; - msg1 = hstrerror(errno); - asprintf(&msg2, "edg_wll_gss_connect(): %s", msg1); - edg_wll_SetError(context,EDG_WLL_ERROR_DNS, msg2); - free(msg2); - } - break; - default: - edg_wll_SetError(context,ECONNREFUSED,"edg_wll_gss_connect(): unknown"); - break; - } - goto edg_wll_DoLogEvent_end; - } - - /* and send the message to the local-logger: */ - - answer = edg_wll_log_proto_client(context,&con,logline/*,priority*/); - - switch(answer) { - case 0: - case EINVAL: - case ENOSPC: - case ENOMEM: - case EDG_WLL_ERROR_GSS: - case EDG_WLL_ERROR_DNS: - case ENOTCONN: - case ECONNREFUSED: - case ETIMEDOUT: - case EAGAIN: - break; - case EDG_WLL_ERROR_PARSE_EVENT_UNDEF: - case EDG_WLL_ERROR_PARSE_MSG_INCOMPLETE: - case EDG_WLL_ERROR_PARSE_KEY_DUPLICITY: - case EDG_WLL_ERROR_PARSE_KEY_MISUSE: -// case EDG_WLL_ERROR_PARSE_OK_WITH_EXTRA_FIELDS: - edg_wll_UpdateError(context,EINVAL,"edg_wll_DoLogEvent(): Error code mapped to EINVAL"); - break; - case EDG_WLL_IL_PROTO: - case EDG_WLL_IL_SYS: - case EDG_WLL_IL_EVENTS_WAITING: - edg_wll_UpdateError(context,EAGAIN,"edg_wll_DoLogEvent(): Error code mapped to EAGAIN"); - break; - - default: - edg_wll_UpdateError(context,EAGAIN,"edg_wll_DoLogEvent(): Error code mapped to EAGAIN"); - break; - } - -edg_wll_DoLogEvent_end: - if (con.context != GSS_C_NO_CONTEXT) - edg_wll_gss_close(&con,&context->p_tmp_timeout); - if (cred != GSS_C_NO_CREDENTIAL) - gss_release_cred(&min_stat, &cred); - - return edg_wll_Error(context, NULL, NULL); -} - -/** - *---------------------------------------------------------------------- - * Connects to L&B Proxy and sends already formatted ULM string - * \brief helper logging function - * \param context INOUT context to work with, - * \param logline IN formated ULM string - *---------------------------------------------------------------------- - */ -static int edg_wll_DoLogEventProxy( - edg_wll_Context context, - edg_wll_LogLine logline) -{ - int answer; - struct sockaddr_un saddr; - int flags; - edg_wll_PlainConnection conn; - - edg_wll_ResetError(context); - answer = 0; - - /* open a connection to the L&B Proxy: */ - -#ifdef EDG_WLL_LOG_STUB - fprintf(stderr,"Logging to L&B Proxy at socket %s\n", - context->p_lbproxy_store_sock? context->p_lbproxy_store_sock: socket_path); -#endif - memset(&conn, 0, sizeof(conn)); - conn.sock = socket(PF_UNIX, SOCK_STREAM, 0); - if (conn.sock < 0) { - edg_wll_SetError(context,answer = errno,"socket() error"); - goto edg_wll_DoLogEventProxy_end; - } - memset(&saddr, 0, sizeof(saddr)); - saddr.sun_family = AF_UNIX; - strcpy(saddr.sun_path, context->p_lbproxy_store_sock? - context->p_lbproxy_store_sock: socket_path); - if ((flags = fcntl(conn.sock, F_GETFL, 0)) < 0 || fcntl(conn.sock, F_SETFL, flags | O_NONBLOCK) < 0) { - edg_wll_SetError(context,answer = errno,"fcntl()"); - close(conn.sock); - goto edg_wll_DoLogEventProxy_end; - } - if (connect(conn.sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { - if(errno != EISCONN) { - edg_wll_SetError(context,answer = errno,"connect()"); - close(conn.sock); - goto edg_wll_DoLogEventProxy_end; - } - } - - - /* and send the message to the L&B Proxy: */ - - answer = edg_wll_log_proto_client_proxy(context,&conn,logline); - - edg_wll_plain_close(&conn); - -edg_wll_DoLogEventProxy_end: - - switch(answer) { - case 0: - case EINVAL: - case ENOSPC: - case ENOMEM: - case EDG_WLL_ERROR_GSS: - case EDG_WLL_ERROR_DNS: - case ENOTCONN: - case ECONNREFUSED: - case ETIMEDOUT: - case EAGAIN: - break; - case EDG_WLL_ERROR_PARSE_EVENT_UNDEF: - case EDG_WLL_ERROR_PARSE_MSG_INCOMPLETE: - case EDG_WLL_ERROR_PARSE_KEY_DUPLICITY: - case EDG_WLL_ERROR_PARSE_KEY_MISUSE: -// case EDG_WLL_ERROR_PARSE_OK_WITH_EXTRA_FIELDS: - edg_wll_UpdateError(context,EINVAL,"edg_wll_DoLogEventProxy(): Error code mapped to EINVAL"); - break; - - default: - edg_wll_UpdateError(context,EAGAIN,"edg_wll_DoLogEventProxy(): Error code mapped to EAGAIN"); - break; - } - - return edg_wll_Error(context, NULL, NULL); -} -#endif /* FAKE_VERSION */ - - -/** - *---------------------------------------------------------------------- - * Formats a logging message and sends it to local-logger - * \brief master logging event function - * \param context INOUT context to work with, - * \param priority IN priority flag (0 for async, 1 for sync) - * \param event IN type of the event, - * \param fmt IN printf()-like format string, - * \param ... IN event specific values/data according to fmt. - *---------------------------------------------------------------------- - */ -static int edg_wll_LogEventMaster( - edg_wll_Context context, - int priority, - edg_wll_EventCode event, - char *fmt, ...) -{ - va_list fmt_args; - int ret,answer; - char *fix,*var; - char *source,*eventName,*lvl, *fullid,*seq; - struct timeval start_time; - char date[ULM_DATE_STRING_LENGTH+1]; - edg_wll_LogLine out; - size_t size; - int i; - - i = errno = size = 0; - seq = fix = var = out = source = eventName = lvl = fullid = NULL; - - edg_wll_ResetError(context); - - /* default return value is "Try Again" */ - answer = ret = EAGAIN; - - /* format the message: */ - va_start(fmt_args,fmt); - - gettimeofday(&start_time,0); - if (edg_wll_ULMTimevalToDate(start_time.tv_sec,start_time.tv_usec,date) != 0) { - edg_wll_SetError(context,ret = EINVAL,"edg_wll_LogEventMaster(): edg_wll_ULMTimevalToDate() error"); - goto edg_wll_logeventmaster_end; - } - source = edg_wll_SourceToString(context->p_source); - lvl = edg_wll_LevelToString(context->p_level); - eventName = edg_wll_EventToString(event); - if (!eventName) { - edg_wll_SetError(context,ret = EINVAL,"edg_wll_LogEventMaster(): event name not specified"); - goto edg_wll_logeventmaster_end; - } - if (!(fullid = edg_wlc_JobIdUnparse(context->p_jobid))) { - edg_wll_SetError(context,ret = EINVAL,"edg_wll_LogEventMaster(): edg_wlc_JobIdUnparse() error"); - goto edg_wll_logeventmaster_end; - } - seq = edg_wll_GetSequenceCode(context); - if (edg_wll_IncSequenceCode(context)) { - ret = EINVAL; - goto edg_wll_logeventmaster_end; - } - if (trio_asprintf(&fix,EDG_WLL_FORMAT_COMMON, - date,context->p_host,lvl,priority, - source,context->p_instance ? context->p_instance : "", - eventName,fullid,seq) == -1) { - edg_wll_SetError(context,ret = ENOMEM,"edg_wll_LogEventMaster(): trio_asprintf() error"); - goto edg_wll_logeventmaster_end; - } - if (trio_vasprintf(&var,fmt,fmt_args) == -1) { - edg_wll_SetError(context,ret = ENOMEM,"edg_wll_LogEventMaster(): trio_vasprintf() error"); - goto edg_wll_logeventmaster_end; - } - if (asprintf(&out,"%s%s\n",fix,var) == -1) { - edg_wll_SetError(context,ret = ENOMEM,"edg_wll_LogEventMaster(): asprintf() error"); - goto edg_wll_logeventmaster_end; - } - size = strlen(out); - - if (priority && (size > EDG_WLL_LOG_SYNC_MAXMSGSIZE)) { - edg_wll_SetError(context,ret = ENOSPC,"edg_wll_LogEventMaster(): Message size too large for synchronous transfer"); - goto edg_wll_logeventmaster_end; - } - -#ifdef EDG_WLL_LOG_STUB -// fprintf(stderr,"edg_wll_LogEvent (%d chars): %s",size,out); -#endif - - context->p_tmp_timeout.tv_sec = 0; - context->p_tmp_timeout.tv_usec = 0; - if (priority) { - context->p_tmp_timeout = context->p_sync_timeout; - } - else { - context->p_tmp_timeout = context->p_log_timeout; - } - - /* and send the message to the local-logger: */ - ret = edg_wll_DoLogEvent(context, /* priority,*/ out); - -edg_wll_logeventmaster_end: - va_end(fmt_args); - if (seq) free(seq); - if (fix) free(fix); - if (var) free(var); - if (out) free(out); - if (source) free(source); - if (lvl) free(lvl); - if (eventName) free(eventName); - if (fullid) free(fullid); - - if (ret) edg_wll_UpdateError(context,0,"Logging library ERROR: "); - - return edg_wll_Error(context,NULL,NULL); -} - -/** - *---------------------------------------------------------------------- - * Formats a logging message and sends it to L&B Proxy - * \brief master proxy logging event function - * \param context INOUT context to work with, - * \param event IN type of the event, - * \param fmt IN printf()-like format string, - * \param ... IN event specific values/data according to fmt. - *---------------------------------------------------------------------- - */ -static int edg_wll_LogEventMasterProxy( - edg_wll_Context context, - edg_wll_EventCode event, - char *fmt, ...) -{ - va_list fmt_args; - int ret,answer; - char *fix,*var,*dguser; - char *source,*eventName,*lvl, *fullid,*seq,*name_esc; - struct timeval start_time; - char date[ULM_DATE_STRING_LENGTH+1]; - edg_wll_LogLine out; - size_t size; - int i; - - i = errno = size = 0; - seq = fix = var = dguser = out = source = eventName = lvl = fullid = NULL; - - edg_wll_ResetError(context); - - /* default return value is "Try Again" */ - answer = ret = EAGAIN; - - /* format the message: */ - va_start(fmt_args,fmt); - - gettimeofday(&start_time,0); - if (edg_wll_ULMTimevalToDate(start_time.tv_sec,start_time.tv_usec,date) != 0) { - edg_wll_SetError(context,ret = EINVAL,"edg_wll_LogEventMasterProxy(): edg_wll_ULMTimevalToDate() error"); - goto edg_wll_logeventmasterproxy_end; - } - source = edg_wll_SourceToString(context->p_source); - lvl = edg_wll_LevelToString(context->p_level); - eventName = edg_wll_EventToString(event); - if (!eventName) { - edg_wll_SetError(context,ret = EINVAL,"edg_wll_LogEventMasterProxy(): event name not specified"); - goto edg_wll_logeventmasterproxy_end; - } - if (!(fullid = edg_wlc_JobIdUnparse(context->p_jobid))) { - edg_wll_SetError(context,ret = EINVAL,"edg_wll_LogEventMasterProxy(): edg_wlc_JobIdUnparse() error"); - goto edg_wll_logeventmasterproxy_end; - } - seq = edg_wll_GetSequenceCode(context); - if (edg_wll_IncSequenceCode(context)) { - ret = EINVAL; - goto edg_wll_logeventmasterproxy_end; - } - if (trio_asprintf(&fix,EDG_WLL_FORMAT_COMMON, - date,context->p_host,lvl,1, - source,context->p_instance ? context->p_instance : "", - eventName,fullid,seq) == -1) { - edg_wll_SetError(context,ret = ENOMEM,"edg_wll_LogEventMasterProxy(): trio_asprintf() error"); - goto edg_wll_logeventmasterproxy_end; - } - if (trio_vasprintf(&var,fmt,fmt_args) == -1) { - edg_wll_SetError(context,ret = ENOMEM,"edg_wll_LogEventMasterProxy(): trio_vasprintf() error"); - goto edg_wll_logeventmasterproxy_end; - } - /* format the DG.USER string */ -/* XXX: put user credentials here probably from context */ - name_esc = edg_wll_LogEscape(context->p_user_lbproxy); - if (asprintf(&dguser,"DG.USER=\"%s\" ",name_esc) == -1) { - edg_wll_SetError(context,ret = ENOMEM,"edg_wll_LogEventMasterProxy(): asprintf() error"); - goto edg_wll_logeventmasterproxy_end; - } - if (asprintf(&out,"%s%s%s\n",dguser,fix,var) == -1) { - edg_wll_SetError(context,ret = ENOMEM,"edg_wll_LogEventMasterProxy(): asprintf() error"); - goto edg_wll_logeventmasterproxy_end; - } - size = strlen(out); - - if (size > EDG_WLL_LOG_SYNC_MAXMSGSIZE) { - edg_wll_SetError(context,ret = ENOSPC,"edg_wll_LogEventMasterProxy(): Message size too large for synchronous transfer"); - goto edg_wll_logeventmasterproxy_end; - } - -#ifdef EDG_WLL_LOG_STUB -// fprintf(stderr,"edg_wll_LogEvent (%d chars): %s",size,out); -#endif - - context->p_tmp_timeout = context->p_sync_timeout; - - /* and send the message to the L&B Proxy: */ - ret = edg_wll_DoLogEventProxy(context, out); - -edg_wll_logeventmasterproxy_end: - va_end(fmt_args); - if (seq) free(seq); - if (fix) free(fix); - if (var) free(var); - if (dguser) free(dguser); - if (out) free(out); - if (source) free(source); - if (lvl) free(lvl); - if (eventName) free(eventName); - if (fullid) free(fullid); - if (name_esc) free(name_esc); - - if (ret) edg_wll_UpdateError(context,0,"Logging library ERROR: "); - - return edg_wll_Error(context,NULL,NULL); -} - -/** - *---------------------------------------------------------------------- - * Formats a logging message and sends it asynchronously to local-logger - * \brief generic asynchronous logging function - *---------------------------------------------------------------------- - */ -int edg_wll_LogEvent( - edg_wll_Context context, - edg_wll_EventCode event, - char *fmt, ...) -{ - int ret=0; - char *list=NULL; - va_list fmt_args; - - edg_wll_ResetError(context); - - va_start(fmt_args,fmt); - if (trio_vasprintf(&list,fmt,fmt_args) == -1) { - edg_wll_SetError(context,ret = ENOMEM,"edg_wll_LogEvent(): trio_vasprintf() error"); - goto edg_wll_logevent_end; - } - - ret=edg_wll_LogEventMaster(context,0,event,"%s",list); - -edg_wll_logevent_end: - va_end(fmt_args); - if (list) free(list); - - if (ret) edg_wll_UpdateError(context,0,"edg_wll_LogEvent(): "); - - return edg_wll_Error(context,NULL,NULL); -} - -/** - *---------------------------------------------------------------------- - * Formats a logging message and sends it synchronously to local-logger - * \brief generic synchronous logging function - * \note simple wrapper around edg_wll_LogEventMaster() - *---------------------------------------------------------------------- - */ -int edg_wll_LogEventSync( - edg_wll_Context context, - edg_wll_EventCode event, - char *fmt, ...) -{ - int ret=0; - char *list=NULL; - va_list fmt_args; - - edg_wll_ResetError(context); - - va_start(fmt_args,fmt); - if (trio_vasprintf(&list,fmt,fmt_args) == -1) { - edg_wll_SetError(context,ret = ENOMEM,"edg_wll_LogEventSync(): trio_vasprintf() error"); - goto edg_wll_logeventsync_end; - } - - ret=edg_wll_LogEventMaster(context,1,event,"%s",list); - -edg_wll_logeventsync_end: - va_end(fmt_args); - if (list) free(list); - - if (ret) edg_wll_UpdateError(context,0,"edg_wll_LogEventSync(): "); - - return edg_wll_Error(context,NULL,NULL); -} - -/** - *---------------------------------------------------------------------- - * Formats a logging message and sends it synchronously to L&B Proxy - * \brief generic synchronous logging function - *---------------------------------------------------------------------- - */ -int edg_wll_LogEventProxy( - edg_wll_Context context, - edg_wll_EventCode event, - char *fmt, ...) -{ - int ret=0; - char *list=NULL; - va_list fmt_args; - - edg_wll_ResetError(context); - - va_start(fmt_args,fmt); - if (trio_vasprintf(&list,fmt,fmt_args) == -1) { - edg_wll_SetError(context,ret = ENOMEM,"edg_wll_LogEventProxy(): trio_vasprintf() error"); - goto edg_wll_logevent_end; - } - - ret=edg_wll_LogEventMasterProxy(context,event,"%s",list); - -edg_wll_logevent_end: - va_end(fmt_args); - if (list) free(list); - - if (ret) edg_wll_UpdateError(context,0,"edg_wll_LogEventProxy(): "); - - return edg_wll_Error(context,NULL,NULL); -} - - -/** - *----------------------------------------------------------------------- - * Instructs interlogger to to deliver all pending events related to current job - * \brief flush events from interlogger - * \note simple wrapper around edg_wll_LogEventMaster() - *----------------------------------------------------------------------- - */ -int edg_wll_LogFlush( - edg_wll_Context context, - struct timeval *timeout) -{ - int ret = 0; - edg_wll_LogLine out = NULL; - char *fullid; - char date[ULM_DATE_STRING_LENGTH+1]; - struct timeval start_time; - - fullid = NULL; - - edg_wll_ResetError(context); - - gettimeofday(&start_time, 0); - if (edg_wll_ULMTimevalToDate(start_time.tv_sec, start_time.tv_usec, date) != 0) { - edg_wll_SetError(context,ret = EINVAL,"edg_wll_ULMTimevalToDate()"); - goto edg_wll_logflush_end; - } - if (!(fullid = edg_wlc_JobIdUnparse(context->p_jobid))) { - ret = edg_wll_SetError(context,EINVAL,"edg_wlc_JobIdUnparse()"); - goto edg_wll_logflush_end; - } - - if (trio_asprintf(&out, "DATE=%s HOST=\"%|Us\" PROG=internal LVL=system DG.PRIORITY=1 DG.TYPE=\"command\" DG.COMMAND=\"flush\" DG.TIMEOUT=\"%d\" DG.JOBID=\"%s\"\n", - date, context->p_host, (timeout ? timeout->tv_sec : context->p_sync_timeout.tv_sec), fullid) == -1) { - edg_wll_SetError(context,ret = EINVAL,"trio_asprintf"); - goto edg_wll_logflush_end; - } - - if (timeout) - context->p_tmp_timeout = *timeout; - else - context->p_tmp_timeout = context->p_sync_timeout; - - ret = edg_wll_DoLogEvent(context, /* 1,*/ out); - -edg_wll_logflush_end: - if(out) free(out); - if(fullid) free(fullid); - - if (ret) edg_wll_UpdateError(context,0,"edg_wll_LogFlush(): "); - - return edg_wll_Error(context,NULL,NULL); -} - -/** - *----------------------------------------------------------------------- - * Instructs interlogger to to deliver all pending events - * \brief flush all events from interlogger - *----------------------------------------------------------------------- - */ -int edg_wll_LogFlushAll( - edg_wll_Context context, - struct timeval *timeout) -{ - int ret = 0; - edg_wll_LogLine out = NULL; - char date[ULM_DATE_STRING_LENGTH+1]; - struct timeval start_time; - - edg_wll_ResetError(context); - - gettimeofday(&start_time, 0); - if (edg_wll_ULMTimevalToDate(start_time.tv_sec, start_time.tv_usec, date) != 0) { - edg_wll_SetError(context,ret = EINVAL,"edg_wll_ULMTimevalToDate()"); - goto edg_wll_logflushall_end; - } - - if (trio_asprintf(&out, "DATE=%s HOST=\"%|Us\" PROG=internal LVL=system DG.PRIORITY=1 DG.TYPE=\"command\" DG.COMMAND=\"flush\" DG.TIMEOUT=\"%d\"\n", - date, context->p_host, (timeout ? timeout->tv_sec : context->p_sync_timeout.tv_sec)) == -1) { - edg_wll_SetError(context,ret = ENOMEM,"trio_asprintf"); - goto edg_wll_logflushall_end; - } - - if (timeout) - context->p_tmp_timeout = *timeout; - else - context->p_tmp_timeout = context->p_sync_timeout; - - ret = edg_wll_DoLogEvent(context, /* 1,*/ out); - -edg_wll_logflushall_end: - if(out) free(out); - - if (ret) edg_wll_UpdateError(context,0,"edg_wll_LogFlushAll(): "); - - return edg_wll_Error(context,NULL,NULL); -} - -/** - *----------------------------------------------------------------------- - * Set a current job for given context. - * \note Should be called before any logging call. - *----------------------------------------------------------------------- - */ -int edg_wll_SetLoggingJob( - edg_wll_Context context, - const edg_wlc_JobId job, - const char *code, - int flags) -{ - int err; - - edg_wll_ResetError(context); - - if (!job) return edg_wll_SetError(context,EINVAL,"jobid is null"); - - edg_wlc_JobIdFree(context->p_jobid); - if ((err = edg_wlc_JobIdDup(job,&context->p_jobid))) - edg_wll_SetError(context,err,"edg_wll_SetLoggingJob(): edg_wlc_JobIdDup() error"); - - else { - if (!edg_wll_SetSequenceCode(context,code,flags)) - edg_wll_IncSequenceCode(context); - } - - return edg_wll_Error(context,NULL,NULL); -} - -/** - *----------------------------------------------------------------------- - * Set a current job for given context. - * \note Should be called before any logging call. - *----------------------------------------------------------------------- - */ -int edg_wll_SetLoggingJobProxy( - edg_wll_Context context, - const edg_wlc_JobId job, - const char *code, - const char *user, - int flags) -{ - int err; - char *code_loc = NULL; - - edg_wll_ResetError(context); - - if (!job) return edg_wll_SetError(context,EINVAL,"jobid is null"); - - edg_wlc_JobIdFree(context->p_jobid); - if ((err = edg_wlc_JobIdDup(job,&context->p_jobid))) { - edg_wll_SetError(context,err,"edg_wll_SetLoggingJob(): edg_wlc_JobIdDup() error"); - goto edg_wll_setloggingjobproxy_end; - } - - /* add user credentials to context */ - edg_wll_SetParamString(context, EDG_WLL_PARAM_LBPROXY_USER, user); - - /* query LBProxyServer for sequence code if not user-suplied */ -/* FIXME: doesn't work yet - if (!code) { - edg_wll_QuerySequenceCodeProxy(context, job, &code_loc); - goto edg_wll_setloggingjobproxy_end; - } else { - code_loc = strdup(code); - } - - if (!edg_wll_SetSequenceCode(context,code_loc,flags)) */ { - edg_wll_IncSequenceCode(context); - } - -edg_wll_setloggingjobproxy_end: - if (code_loc) free(code_loc); - return edg_wll_Error(context,NULL,NULL); -} - -/** - *----------------------------------------------------------------------- - * Register job with L&B service. - *----------------------------------------------------------------------- - */ -static int edg_wll_RegisterJobMaster( - edg_wll_Context context, - int pri, - const edg_wlc_JobId job, - enum edg_wll_RegJobJobtype type, - const char * jdl, - const char * ns, - edg_wlc_JobId parent, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs) -{ - char *type_s = NULL,*intseed = NULL, *seq = NULL; - char *parent_s = NULL; - int err = 0; - - edg_wll_ResetError(context); - - intseed = seed ? strdup(seed) : - str2md5base64(seq = edg_wll_GetSequenceCode(context)); - - free(seq); - - type_s = edg_wll_RegJobJobtypeToString(type); - if (!type_s) return edg_wll_SetError(context,EINVAL,"edg_wll_RegisterJobMaster(): no jobtype specified"); - - if ((type == EDG_WLL_REGJOB_DAG || type == EDG_WLL_REGJOB_PARTITIONED) - && num_subjobs > 0) - err = edg_wll_GenerateSubjobIds(context,job, - num_subjobs,intseed,subjobs); - - parent_s = parent ? edg_wlc_JobIdUnparse(parent) : strdup(""); - - if (err == 0 && - edg_wll_SetLoggingJob(context,job,NULL,EDG_WLL_SEQ_NORMAL) == 0) - edg_wll_LogEventMaster(context,pri, - EDG_WLL_EVENT_REGJOB,EDG_WLL_FORMAT_REGJOB, - (char *)jdl,ns,parent_s,type_s,num_subjobs,intseed); - - free(type_s); free(intseed); free(parent_s); - return edg_wll_Error(context,NULL,NULL); -} - -/** - *----------------------------------------------------------------------- - * Register job with L&B Proxy service. - *----------------------------------------------------------------------- - */ -static int edg_wll_RegisterJobMasterProxy( - edg_wll_Context context, - const edg_wlc_JobId job, - enum edg_wll_RegJobJobtype type, - const char * user, - const char * jdl, - const char * ns, - edg_wlc_JobId parent, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs) -{ - char *type_s = NULL,*intseed = NULL, *seq = NULL; - char *parent_s = NULL; - int err = 0; - - edg_wll_ResetError(context); - - intseed = seed ? strdup(seed) : - str2md5base64(seq = edg_wll_GetSequenceCode(context)); - - free(seq); - - type_s = edg_wll_RegJobJobtypeToString(type); - if (!type_s) return edg_wll_SetError(context,EINVAL,"edg_wll_RegisterJobMaster(): no jobtype specified"); - - if ((type == EDG_WLL_REGJOB_DAG || type == EDG_WLL_REGJOB_PARTITIONED) - && num_subjobs > 0) - err = edg_wll_GenerateSubjobIds(context,job, - num_subjobs,intseed,subjobs); - - parent_s = parent ? edg_wlc_JobIdUnparse(parent) : strdup(""); - - if (err == 0 && - edg_wll_SetLoggingJobProxy(context,job,NULL,user,EDG_WLL_SEQ_NORMAL) == 0) - edg_wll_LogEventMasterProxy(context, - EDG_WLL_EVENT_REGJOB,EDG_WLL_FORMAT_REGJOB, - (char *)jdl,ns,parent_s,type_s,num_subjobs,intseed); - - free(type_s); free(intseed); free(parent_s); - return edg_wll_Error(context,NULL,NULL); -} - -int edg_wll_RegisterJobSync( - edg_wll_Context context, - const edg_wlc_JobId job, - enum edg_wll_RegJobJobtype type, - const char * jdl, - const char * ns, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs) -{ - return edg_wll_RegisterJobMaster(context,1,job,type,jdl,ns, NULL, num_subjobs,seed,subjobs); -} - -int edg_wll_RegisterJob( - edg_wll_Context context, - const edg_wlc_JobId job, - enum edg_wll_RegJobJobtype type, - const char * jdl, - const char * ns, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs) -{ - return edg_wll_RegisterJobMaster(context,0,job,type,jdl,ns, NULL, num_subjobs,seed,subjobs); -} - -int edg_wll_RegisterSubjob( - edg_wll_Context context, - const edg_wlc_JobId job, - enum edg_wll_RegJobJobtype type, - const char * jdl, - const char * ns, - edg_wlc_JobId parent, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs) -{ - return edg_wll_RegisterJobMaster(context,0,job,type,jdl,ns, parent, num_subjobs,seed,subjobs); -} - -int edg_wll_RegisterSubjobs(edg_wll_Context ctx,const edg_wlc_JobId parent, - char const * const * jdls, const char * ns, edg_wlc_JobId const * subjobs) -{ - char const * const *pjdl; - edg_wlc_JobId const *psubjob; - edg_wlc_JobId oldctxjob; - char * oldctxseq; - - if (edg_wll_GetLoggingJob(ctx, &oldctxjob)) return edg_wll_Error(ctx, NULL, NULL); - oldctxseq = edg_wll_GetSequenceCode(ctx); - - pjdl = jdls; - psubjob = subjobs; - - while (*pjdl != NULL) { - if (edg_wll_RegisterSubjob(ctx, *psubjob, EDG_WLL_REGJOB_SIMPLE, *pjdl, - ns, parent, 0, NULL, NULL) != 0) break; - pjdl++; psubjob++; - } - - edg_wll_SetLoggingJob(ctx, oldctxjob, oldctxseq, EDG_WLL_SEQ_NORMAL); - - return edg_wll_Error(ctx, NULL, NULL); -} - -int edg_wll_RegisterJobProxy( - edg_wll_Context context, - const edg_wlc_JobId job, - enum edg_wll_RegJobJobtype type, - const char * user, - const char * jdl, - const char * ns, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs) -{ - return edg_wll_RegisterJobMasterProxy(context,job,type,user,jdl,ns, NULL, num_subjobs,seed,subjobs); -} - -int edg_wll_ChangeACL( - edg_wll_Context ctx, - const edg_wlc_JobId jobid, - const char *user_id, - enum edg_wll_UserIdType user_id_type, - enum edg_wll_Permission permission, - enum edg_wll_PermissionType permission_type, - enum edg_wll_ACLOperation operation) -{ - if ( edg_wll_SetLoggingJob(ctx, jobid, NULL, EDG_WLL_SEQ_NORMAL) == 0 ) - edg_wll_LogEventMaster(ctx, 1, EDG_WLL_EVENT_CHANGEACL, EDG_WLL_FORMAT_CHANGEACL, - user_id, user_id_type, permission, permission_type, operation); - - - return edg_wll_Error(ctx,NULL,NULL); -} diff --git a/org.glite.lb.client/src/purge.c b/org.glite.lb.client/src/purge.c deleted file mode 100644 index 3c0f934..0000000 --- a/org.glite.lb.client/src/purge.c +++ /dev/null @@ -1,389 +0,0 @@ -#ident "$Header$" - - -#include -#include -#include -#include -#include -#include - -#include - -#define CLIENT_SBIN_PROG - -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/purge.h" -#include "glite/lb/xml_parse.h" -#include "glite/lb/mini_http.h" - - -#define dprintf(x) { if (debug) printf x; } - -#define free_jobs(jobs) { \ - if (jobs) { \ - int i; \ - for ( i = 0; jobs[i]; i++ ) \ - free(jobs[i]); \ - free(jobs); \ - } \ -} - -static const char rcsid[] = "@(#)$Id$"; - -static int debug=0; -static char *file; - -static int read_jobIds(const char *file, char ***jobs_out); -static int get_timeout(const char *arg, int *timeout); -static void printerr(edg_wll_Context ctx); - -static struct option opts[] = { - { "aborted", required_argument, NULL, 'a'}, - { "cleared", required_argument, NULL, 'c'}, - { "cancelled", required_argument, NULL, 'n'}, - { "other", required_argument, NULL, 'o'}, - { "dry-run", no_argument, NULL, 'r'}, - { "jobs", required_argument, NULL, 'j'}, - { "return-list", no_argument, NULL, 'l'}, - { "server-dump", no_argument, NULL, 's'}, - { "client-dump", no_argument, NULL, 'i'}, - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, 'v' }, - { "debug", no_argument, NULL, 'd' }, - { "server", required_argument, NULL, 'm' }, - { NULL, no_argument, NULL, 0 } -}; - -static void usage(char *me) -{ - fprintf(stderr,"usage: %s [option]\n" - " -a, --aborted NNN[smhd] purge ABORTED jobs older than NNN secs/mins/hours/days\n" - " -c, --cleared NNN[smhd] purge CLEARED jobs older than given time\n" - " -n, --cancelled NNN[smhd] purge CANCELLED jobs older than given time\n" - " -o, --other NNN[smhd] purge OTHER jobs older than given time\n" - " -r, --dry-run do not really purge\n" - " -j, --jobs input file with jobIds of jobs to purge\n" - " -l, --return-list return list of jobid matching the purge/dump criteria\n" - " -s, --server-dump dump jobs into any server file\n" - " -i, --client-dump receive stream of dumped jobs\n" - " -h, --help display this help\n" - " -v, --version display version\n" - " -d, --debug diagnostic output\n" - " -m, --server L&B server machine name\n", - me); -} - -int main(int argc,char *argv[]) -{ - edg_wll_PurgeRequest *request; - edg_wll_PurgeResult *result; - int i, timeout; - char *server = NULL; - - char *me; - int opt; - edg_wll_Context ctx; - - /* initialize request to server defaults */ - request = (edg_wll_PurgeRequest *) calloc(1,sizeof(edg_wll_PurgeRequest)); - request->jobs = NULL; - for (i=0; i < EDG_WLL_NUMBER_OF_STATCODES; i++) { - request->timeout[i]=-1; - } - request->flags = EDG_WLL_PURGE_REALLY_PURGE; - - /* initialize result */ - result = (edg_wll_PurgeResult *) calloc(1,sizeof(edg_wll_PurgeResult)); - - me = strrchr(argv[0],'/'); - if (me) me++; else me=argv[0]; - - /* get arguments */ - while ((opt = getopt_long(argc,argv,"a:c:n:o:j:m:rlsidhv",opts,NULL)) != EOF) { - timeout=-1; - - switch (opt) { - - case 'a': - if ((get_timeout(optarg,&timeout) != 0 )) { - printf("Wrong usage of timeout argument.\n"); - usage(me); - return 1; - } - if (timeout >= 0) { - request->timeout[EDG_WLL_JOB_ABORTED]=timeout; - } - break; - - case 'c': - if (get_timeout(optarg,&timeout) != 0 ) { - printf("Wrong usage of timeout argument.\n"); - usage(me); - return 1; - } - if (timeout >= 0) { - request->timeout[EDG_WLL_JOB_CLEARED]=timeout; - } - break; - - case 'n': - if (get_timeout(optarg,&timeout) != 0 ) { - printf("Wrong usage of timeout argument.\n"); - usage(me); - return 1; - } - if (timeout >= 0) { - request->timeout[EDG_WLL_JOB_CANCELLED]=timeout; - } - break; - case 'o': - if (get_timeout(optarg,&timeout) != 0 ) { - printf("Wrong usage of timeout argument.\n"); - usage(me); - return 1; - } - if (timeout >= 0) request->timeout[EDG_WLL_PURGE_JOBSTAT_OTHER]= timeout; - break; - - case 'm': server = optarg; break; - case 'j': file = optarg; break; - case 'r': request->flags &= (~EDG_WLL_PURGE_REALLY_PURGE); break; - case 'l': request->flags |= EDG_WLL_PURGE_LIST_JOBS; break; - case 's': request->flags |= EDG_WLL_PURGE_SERVER_DUMP; break; - case 'i': request->flags |= EDG_WLL_PURGE_CLIENT_DUMP; break; - case 'd': debug = 1; break; - case 'v': fprintf(stdout,"%s:\t%s\n",me,rcsid); exit(0); - case 'h': - case '?': usage(me); return 1; - } - } - - /* Initialize Globus common module */ - dprintf(("Initializing Globus common module...")); - if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { - dprintf(("no.\n")); - fprintf(stderr,"Unable to initialize Globus common module\n"); - } else { - dprintf(("yes.\n")); - } - - /* initialize context */ - edg_wll_InitContext(&ctx); - - /* read the jobIds from file, if wanted */ - if (file) { - char **jobs=NULL; - dprintf(("Reading jobIds form file \'%s\'...",file)); - if (read_jobIds(file,&jobs) != 0) { - dprintf(("no.\n")); - fprintf(stderr,"Unable to read jobIds from file \'%s\'\n",file); - goto main_end; - } else { - dprintf(("yes.\n")); - } - request->jobs = jobs; - } - - /* check request */ - if (debug) { - printf("Purge request:\n"); - printf("- flags: %d\n",request->flags); - printf("- %d timeouts:\n",EDG_WLL_NUMBER_OF_STATCODES); - for (i=0; i < EDG_WLL_NUMBER_OF_STATCODES; i++) { - char *stat=edg_wll_StatToString(i); - printf("\t%s: %ld\n",stat,request->timeout[i]); - if (stat) free(stat); - } - printf("- list of jobs:\n"); - if (!request->jobs) { - printf("Not specified.\n"); - } else { - for ( i = 0; request->jobs[i]; i++ ) - printf("%s\n", request->jobs[i]); - } - } - - if ( server ) - { - char *p = strchr(server, ':'); - if ( p ) - { - edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, atoi(p+1)); - *p = 0; - } - edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER, server); - } - - /* that is the Purge */ - dprintf(("Running the edg_wll_Purge...\n")); - if (edg_wll_Purge(ctx, request, result) != 0) { - fprintf(stderr,"Error running the edg_wll_Purge().\n"); - printerr(ctx); - switch ( edg_wll_Error(ctx, NULL, NULL) ) - { - case ENOENT: - case EPERM: - case EINVAL: - break; - default: - goto main_end; - } - } - - /* examine the result */ - dprintf(("Examining the result of edg_wll_Purge...\n")); - if (result->server_file) { - printf("Server dump: %s\n",result->server_file); - } else { - printf("The jobs were not dumped.\n"); - } - if (request->flags & EDG_WLL_PURGE_LIST_JOBS) { - printf("The following jobs %s purged:\n", - request->flags & EDG_WLL_PURGE_REALLY_PURGE ? "were" : "would be"); - if (!result->jobs) printf("None.\n"); - else { - int i; - for ( i = 0; result->jobs[i]; i++ ) - printf("%s\n",result->jobs[i]); - } - } - -main_end: - dprintf(("End.\n")); - if (request) - { - free_jobs(request->jobs); - free(request); - } - if (result) free(result); - edg_wll_FreeContext(ctx); - return 0; -} - - -static void printerr(edg_wll_Context ctx) -{ - char *errt,*errd; - - edg_wll_Error(ctx,&errt,&errd); - fprintf(stderr,"%s (%s)\n",errt,errd); -} - - -static int read_jobIds(const char *file, char ***jobs_out) -{ - FILE *jobIds = fopen(file,"r"); - char buf[256]; - char **jobs; - int cnt = 0; - - jobs = NULL; - - - if (!jobIds) { - perror(file); - return 1; - } - - while ( 1 ) { - char *nl; - if ( !fgets(buf,sizeof buf,jobIds) ) - { - if (feof(jobIds)) - break; - - free_jobs(jobs); - fprintf(stderr, "Error reading file\n"); - return 1; - } - nl = strchr(buf,'\n'); - if (nl) *nl = 0; - /* TODO: check if it is really jobId, e.g. by edg_wlc_JobIdParse() */ - - if ( !(jobs = realloc(jobs, (cnt+2)*sizeof(*jobs))) ) - { - perror("cond_parse()"); - return(1); - } - jobs[cnt++] = strdup(buf); - } - jobs[cnt] = NULL; - - fclose(jobIds); - *jobs_out = jobs; - - return 0; -} - -static int get_timeout(const char *arg, int *timeout) -{ - int t = -1; - char tunit = '\0'; - - if (sscanf(arg,"%d%c",&t,&tunit) > 0) { - if (tunit) { - switch (tunit) { - case 'd': t *= 86400; break; // 24*60*60 - case 'h': t *= 3600; break; // 60*60 - case 'm': t *= 60; break; - case 's': break; - default: fprintf(stderr,"Allowed time units are s,m,h,d\n"); - return -1; - } - } - } - if (t < 0) return -1; - *timeout = t; - return 0; -} - -static const char* const request_headers[] = { - "Cache-Control: no-cache", - "Accept: application/x-dglb", - "User-Agent: edg_wll_Api/" PROTO_VERSION "/" COMP_PROTO, - "Content-Type: application/x-dglb", - NULL -}; - -int edg_wll_Purge( - edg_wll_Context ctx, - edg_wll_PurgeRequest *request, - edg_wll_PurgeResult *result) -{ - char *send_mess, - *response = NULL, - *recv_mess = NULL; - - edg_wll_ResetError(ctx); - - if (request->flags & EDG_WLL_PURGE_CLIENT_DUMP) - return edg_wll_SetError(ctx,ENOSYS,"client dump"); - - if (edg_wll_PurgeRequestToXML(ctx, request, &send_mess)) - goto edg_wll_purge_end; - - ctx->p_tmp_timeout = ctx->p_query_timeout; - if (ctx->p_tmp_timeout.tv_sec < 600) ctx->p_tmp_timeout.tv_sec = 600; - - if (set_server_name_and_port(ctx, NULL)) - goto edg_wll_purge_end; - - if (edg_wll_http_send_recv(ctx, - "POST /purgeRequest HTTP/1.1", request_headers, send_mess, - &response, NULL, &recv_mess)) - goto edg_wll_purge_end; - - if (http_check_status(ctx, response, &recv_mess)) - goto edg_wll_purge_end; - - if (edg_wll_ParsePurgeResult(ctx, recv_mess, result)) - goto edg_wll_purge_end; - -edg_wll_purge_end: - if (response) free(response); - if (recv_mess) free(recv_mess); - if (send_mess) free(send_mess); - return edg_wll_Error(ctx,NULL,NULL); -} diff --git a/org.glite.lb.client/src/uiwrap.c.T b/org.glite.lb.client/src/uiwrap.c.T deleted file mode 100644 index 8ad66e0..0000000 --- a/org.glite.lb.client/src/uiwrap.c.T +++ /dev/null @@ -1,116 +0,0 @@ -#ident "$Header$" -/* -@@@AUTO -*/ -@@@LANG: C - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/producer.h" - -@@@{ -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t; - my $a = "(edg_wll_Context context"; - my $b = "(context,EDG_WLL_EVENT_$tu,EDG_WLL_FORMAT_$tu"; - my $decl = ""; - my $free = ""; - my $doc = qq{ - * \\param context\tcontext to work with, -}; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->getName; - my $ft; - my $bfn = $fn; - if ($f->{codes}) { -# $ft = "enum edg_wll\_$t" . ucfirst $fn; - $ft = "char *"; - } else { - $ft = $f->getType; - } - if ($ULMasString{$f->{type}}) { - $decl .= "\tchar *s_$fn = ".$f->getType()."ToString($fn);\n"; - $free .= "\tfree(s_$fn);\n"; - $bfn = "s_$fn"; - } - $ft = "const ".$ft; - my $fc = $f->getComment; - $a = $a . ", $ft $fn"; - $b = $b . ", $bfn"; - $doc = $doc . " * \\param $fn\t$fc\n"; - } - $a = $a . ")"; - $b = $b . ")"; - - gen qq{ -/*! - * \\fn int edg_wll_Log$t$a; - * \\brief simple wrapper around edg_wll_LogEvent for event $t} . $doc . qq{ * \\see edg_wll_LogEvent\(\) - */ -}; -# gen "\nextern int edg_wll_Log$t$a;\n\n"; - gen qq{ -int edg_wll_Log$t$a -\{ -$decl - return edg_wll_LogEvent$b; -\}\n -}; - gen qq{ -int edg_wll_Log${t}Proxy$a -\{ -$decl - return edg_wll_LogEventProxy$b; -\}\n -}; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->getName; - my $ft; - if ($f->{codes}) { -# $ft = "enum edg_wll\_$t" . ucfirst $fn; - $ft = "char *"; - } else { - $ft = $f->getType; - } - my $ftreg = $ft; - $ftreg =~ s/\*/\\\*/g; - $ftreg = "const ".$ftreg; - my $fc = $f->getComment; - if ($f->{codes}) { - for (@{$f->{codes}}) { - my $code = uc $_->{name}; - my $c = $a; - my $d = $b; - my $e = $doc; - $c =~ s/, $ftreg $fn//g; - $d =~ s/$fn/"$code"/g; - $e =~ s/ \* \\param $fn\t$fc\n//g; - gen qq{ -/*! - * \\fn int edg_wll_Log$t$code$c; - * \\brief simple wrapper around edg_wll_LogEvent for event $t, $fn $code} . $e . qq{ * \\see edg_wll_LogEvent\(\) - */ -}; -# gen "\nextern int edg_wll_Log$t$code$c;\n\n"; - gen qq{ -int edg_wll_Log$t$code$c -\{ -$decl - return edg_wll_LogEvent$d; -\}\n -}; - gen qq{ -int edg_wll_Log$t${code}Proxy$c -\{ -$decl - return edg_wll_LogEventProxy$d; -\}\n -}; - } - } - } -} -@@@} diff --git a/org.glite.lb.client/test/prod_proto_test.c b/org.glite.lb.client/test/prod_proto_test.c deleted file mode 100644 index e0214fe..0000000 --- a/org.glite.lb.client/test/prod_proto_test.c +++ /dev/null @@ -1,33 +0,0 @@ -#define edg_wll_gss_read_full(a,b,c,d,e,f) test_edg_wll_gss_read_full(a,b,c,d,e,f) -#define edg_wll_gss_write_full(a,b,c,d,e,f) test_edg_wll_gss_write_full(a,b,c,d,e,f) -#define edg_wll_GssConnection int - -#include "prod_proto.h" -#include "glite/lb/producer.h" -#include "glite/lb/escape.h" -#include "glite/lb/lb_gss.h" - -int -test_edg_wll_gss_read_full(int *fd, - void *buf, - size_t bufsize, - struct timeval *timeout, - size_t *total, - edg_wll_GssStatus *code) -{ - return(0); -} - -int -test_edg_wll_gss_write_full(int *fd, - const void *buf, - size_t bufsize, - struct timeval *timeout, - size_t *total, - edg_wll_GssStatus *code) -{ - *total = write(*fd, buf, bufsize); - return(*total < 0 ? *total : 0); -} - -#include "prod_proto.c" diff --git a/org.glite.lb.client/test/producer_test.cpp b/org.glite.lb.client/test/producer_test.cpp deleted file mode 100644 index b717b85..0000000 --- a/org.glite.lb.client/test/producer_test.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -extern "C" { -int edg_wll_log_proto_client(int *,char *,char *,int,int); -} - -class ProducerTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(ProducerTest); - CPPUNIT_TEST(testProtoClient); - CPPUNIT_TEST_SUITE_END(); - -public: - - void setUp() { - pipe(pd); - } - - void tearDown() { - close(pd[0]); - close(pd[1]); - } - - void testProtoClient() { - int ret=0; - CPPUNIT_ASSERT( ret == 0 ); - } - -private: - int pd[2]; - - int log_proto_server(int con, char *logline) { - } -}; - - -CPPUNIT_TEST_SUITE_REGISTRATION( ProducerTest ); - -int -main (int ac,const char *av[]) -{ - CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - CppUnit::TextUi::TestRunner runner; - - runner.addTest(suite); - return runner.run() ? 0 : 1; -} diff --git a/org.glite.lb.common/.cvsignore b/org.glite.lb.common/.cvsignore deleted file mode 100644 index 1df717b..0000000 --- a/org.glite.lb.common/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -.project -.cdtproject \ No newline at end of file diff --git a/org.glite.lb.common/LICENSE b/org.glite.lb.common/LICENSE deleted file mode 100644 index 259a91f..0000000 --- a/org.glite.lb.common/LICENSE +++ /dev/null @@ -1,69 +0,0 @@ -LICENSE file for EGEE Middleware -================================ - -Copyright (c) 2004 on behalf of the EU EGEE Project: -The European Organization for Nuclear Research (CERN), -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Datamat Spa, Italy -Centre National de la Recherche Scientifique (CNRS), France -CS Systeme d'Information (CSSI), France -Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden -Universiteit van Amsterdam (UvA), Netherlands -University of Helsinki (UH.HIP), Finlan -University of Bergen (UiB), Norway -Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. The end-user documentation included with the redistribution, if -any, must include the following acknowledgment: "This product includes -software developed by The EU EGEE Project (http://cern.ch/eu-egee/)." -Alternatively, this acknowledgment may appear in the software itself, if -and wherever such third-party acknowledgments normally appear. - -4. The names EGEE and the EU EGEE Project must not be -used to endorse or promote products derived from this software without -prior written permission. For written permission, please contact -. - -5. You are under no obligation whatsoever to provide anyone with any -bug fixes, patches, or upgrades to the features, functionality or -performance of the Software ("Enhancements") that you may develop over -time; however, if you choose to provide your Enhancements to The EU -EGEE Project, or if you choose to otherwise publish or distribute your -Enhancements, in source code form without contemporaneously requiring -end users of The EU EGEE Proejct to enter into a separate written license -agreement for such Enhancements, then you hereby grant The EU EGEE Project -a non-exclusive, royalty-free perpetual license to install, use, copy, -modify, prepare derivative works, incorporate into the EGEE Middleware -or any other computer software, distribute, and sublicense your -Enhancements or derivative works thereof, in binary and source code -form (if any), whether developed by The EU EGEE Project or third parties. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL PROJECT OR ITS CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This software consists of voluntary contributions made by many -individuals on behalf of the EU EGEE Prject. For more information on The -EU EGEE Project, please see http://cern.ch/eu-egee/. For more information on -EGEE Middleware, please see http://egee-jra1.web.cern.ch/egee-jra1/ - - diff --git a/org.glite.lb.common/Makefile b/org.glite.lb.common/Makefile deleted file mode 100644 index d4424be..0000000 --- a/org.glite.lb.common/Makefile +++ /dev/null @@ -1,217 +0,0 @@ -# Default values -top_srcdir=. -builddir=build -top_builddir=${top_srcdir}/${builddir} -stagedir=. -distdir=. -globalprefix=glite -lbprefix=lb -package=glite-lb-common -version=0.0.0 -PREFIX=/opt/glite - -glite_location=/opt/glite -globus_prefix=/opt/globus -nothrflavour=gcc32 -thrflavour=gcc32pthr -expat_prefix=/opt/expat -ares_prefix=/opt/ares - --include Makefile.inc --include ../Makefile.inc - -VPATH=${top_srcdir}/src:${top_srcdir}/test -AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3 - - -SUFFIXES = .T - -CC=gcc - -DEBUG:=-g -O0 -Wall -GLOBUSINC:= -I${globus_prefix}/include/${nothrflavour} -GLOBUSTHRINC:= -I${globus_prefix}/include/${thrflavour} - -CFLAGS:=${DEBUG} -I${top_srcdir}/src -I${top_srcdir}/interface \ - -I${stagedir}/include \ - -I${glite_location}/include \ - -I${expat_prefix}/include \ - -I${ares_prefix}/include \ - ${COVERAGE_FLAGS} \ - -D_GNU_SOURCE \ - -DDATAGRID_EXTENSION - -# We must follow major version changes of org.glite.lb.client-interface due to -# binary compatibility. However, we may live a life of our own, changing our -# major version more frequently. This variable specifies how many steps ahead -# we are. - -VERSION_AHEAD=1 - -GLOBUS_LIBS:=-L${globus_prefix}/lib \ - -lglobus_common_${nothrflavour} \ - -lglobus_gssapi_gsi_${nothrflavour} \ - -GLITE_LIBS:=-L${glite_location}/lib - -ifneq (${expat_prefix},/usr) - EXPAT_LIBS:=-L${expat_prefix}/lib -endif -EXPAT_LIBS:=${EXPAT_LIBS} -lexpat - -ARES_LIBS:=-L${ares_prefix}/lib -lares -LDFLAGS:=-L${stagedir}/lib \ - ${COVERAGE_FLAGS} - -EXT_LIBS:= ${EXPAT_LIBS} ${ARES_LIBS} ${GLOBUS_LIBS} - -# breaks linking when not installed in /opt, /home/dimeglio etc. -# ${GLITE_LIBS} \ -# ${GLOBUS_LIBS} \ -# ${EXPAT_LIBS} \ -# ${ARES_LIBS} \ - -TEST_LIBS:=-L${cppunit}/lib -lcppunit -TEST_INC:=-I${cppunit}/include - -COMPILE:=libtool --mode=compile ${CC} ${CFLAGS} -LINK:=libtool --mode=link ${CC} -rpath ${stagedir}/lib ${LDFLAGS} -LINKXX:=libtool --mode=link ${CXX} -rpath ${stagedir}/lib ${LDFLAGS} -INSTALL:=libtool --mode=install install - -OBJS:=lb_gss.o lb_plain_io.o escape.o events.o mini_http.o query_rec.o \ - status.o xml_conversions.o xml_parse.o ulm_parse.o param.o \ - events_parse.o il_string.o il_int.o notifid.o \ - il_log.o il_msg.o context.o trio.o strio.o -LOBJS:=${OBJS:.o=.lo} - -THROBJS:=${OBJS:.o=.thr.o} -THRLOBJS:=${OBJS:.o=.thr.lo} - -HDRS:=context-int.h lb_gss.h lb_plain_io.h mini_http.h authz.h xml_parse.h \ - xml_conversions.h log_proto.h events_parse.h il_string.h escape.h \ - ulm_parse.h trio.h - -STATICLIB:=libglite_lb_common_${nothrflavour}.a -THRSTATICLIB:=libglite_lb_common_${thrflavour}.a -LTLIB:=libglite_lb_common_${nothrflavour}.la -THRLTLIB:=libglite_lb_common_${thrflavour}.la - -default: all - -all compile: check_version ${STATICLIB} ${LTLIB} ${THRSTATICLIB} ${THRLTLIB} - -version_info=-version-info `echo ${version} | cut -d. -f1,2 | tr . :` - -${STATICLIB}: ${OBJS} - ar crv $@ ${OBJS} - ranlib $@ - -${THRSTATICLIB}: ${THROBJS} - ar crv $@ ${THROBJS} - ranlib $@ - -${LTLIB}: ${OBJS} - ${LINK} ${version_info} -o $@ ${LOBJS} \ - -lglite_wmsutils_cjobid \ - -lm - -${THRLTLIB}: ${THROBJS} - ${LINK} ${version_info} -o $@ ${THRLOBJS} \ - -lglite_wmsutils_cjobid \ - -lm - -stage: compile - $(MAKE) install PREFIX=${stagedir} DOSTAGE=yes - -check: compile check.parse check.gss check.il - -check.parse: test_parse - echo "XXX: nyk -> fixed build interrupt :)" - # ./test_parse - -test_parse: parse.cpp - ${CXX} -c ${CFLAGS} ${TEST_INC} $< - ${LINKXX} -o test_parse parse.o ${LTLIB} ${TEST_LIBS} ${EXT_LIBS} - -check.gss: test_gss - # ./test_gss - echo test_gss not run automatically util we have got some credentials - -check.il: il_test - ./il_test - -test_gss: test_gss.o - ${LINKXX} -o $@ test_gss.o ${LTLIB} ${TEST_LIBS} ${EXT_LIBS} - -il_test: il_test.o il_int_test.o il_string_test.o - ${LINKXX} -o $@ $+ ${LTLIB} ${TEST_LIBS} ${EXT_LIBS} - -test_coverage: - -mkdir coverage - cd coverage && $(MAKE) -f ../Makefile top_srcdir=../../ COVERAGE_FLAGS="-fprofile-arcs -ftest-coverage" check - cd coverage && for i in ${OBJS}; do gcov -o .libs/ $$i ; done - -dist: distsrc distbin - -distsrc: - mkdir -p ${top_srcdir}/${package}-${version} - cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version} - cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version} - rm -rf ${top_srcdir}/${package}-${version} - -distbin: - $(MAKE) install PREFIX=`pwd`/tmpbuilddir${stagedir} - save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir - rm -rf tmpbuilddir - -install: - mkdir -p ${PREFIX}/lib - mkdir -p ${PREFIX}/share/doc/${package}-${version} - ${INSTALL} -m 644 ${LTLIB} ${THRLTLIB} ${PREFIX}/lib - ${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} - if [ x${DOSTAGE} = xyes ]; then \ - mkdir -p ${PREFIX}/include/${globalprefix}/${lbprefix} ; \ - (cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbprefix}) ; \ - install -m 644 ${STATICLIB} ${THRSTATICLIB} ${PREFIX}/lib; \ - fi - -clean: - - -%.o: %.c - ${COMPILE} ${GLOBUSINC} -c $< - -test_gss.o: %.o: %.cpp - ${CXX} -c ${CFLAGS} ${GLOBUSINC} ${TEST_INC} $< - -il_int_test.o il_string_test.o il_test.o: %.o: %.cpp - ${CXX} -c ${CFLAGS} ${TEST_INC} $< - -%.thr.o: %.c - ${COMPILE} ${GLOBUSTHRINC} -o $@ -c $< - -%.h: %.h.T - rm -f $@ - ${AT3} $< >$@ || rm -f $@ - chmod -w $@ >/dev/null - -%.c: %.c.T - rm -f $@ - ${AT3} $< >$@ || rm -f $@ - chmod -w $@ >/dev/null - -%.cpp: %.cpp.T - rm -f $@ - ${AT3} $< >$@ || rm -f $@ - chmod -w $@ >/dev/null - -check_version: - @perl -ne '/#define GLITE_LB_CLIENT_INTERFACE "(\d+)\.\d+\.\d+"/; \ - $$iface=$$1; \ - $$_="${version}"; /(\d+)\.\d+\.\d+/; \ - if ($$iface + ${VERSION_AHEAD} != $$1) { \ - print "error: Major version of the interface ($$iface+${VERSION_AHEAD}) does not match implementation ($$1)\n" ;\ - exit 1; \ - } \ - ' ${stagedir}/include/glite/lb/interface_version.h diff --git a/org.glite.lb.common/build.xml b/org.glite.lb.common/build.xml deleted file mode 100755 index d2997c8..0000000 --- a/org.glite.lb.common/build.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.common/interface/authz.h b/org.glite.lb.common/interface/authz.h deleted file mode 100644 index ccb02ad..0000000 --- a/org.glite.lb.common/interface/authz.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _LB_AUTHZ_H -#define _LB_AUTHZ_H - -#ident "$Header$" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _edg_wll_VomsGroup { - char *vo; - char *name; -} edg_wll_VomsGroup; - -typedef struct _edg_wll_VomsGroups { - size_t len; - edg_wll_VomsGroup *val; -} edg_wll_VomsGroups; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/org.glite.lb.common/interface/context-int.h b/org.glite.lb.common/interface/context-int.h deleted file mode 100644 index 0852e33..0000000 --- a/org.glite.lb.common/interface/context-int.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_CONTEXT_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_CONTEXT_H__ - -#ident "$Header$" - -#include "glite/lb/consumer.h" -#include "lb_gss.h" -#include "lb_plain_io.h" -#include "authz.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _edg_wll_SeqCode { - unsigned int c[EDG_WLL_SOURCE__LAST]; -} edg_wll_SeqCode; - - - -/* non-gsi one-element analogy of connPool for L&B Proxy server */ -typedef struct _edg_wll_ConnProxy { - edg_wll_PlainConnection conn; - char *buf; - size_t bufSize; - size_t bufUse; -} edg_wll_ConnProxy; - - - -typedef struct _edg_wll_ConnPool { -/* address and port where we are connected to */ - char *peerName; - unsigned int peerPort; - -/* http(s) stream */ - gss_cred_id_t gsiCred; - edg_wll_GssConnection gss; - char *buf; - int bufUse,bufSize; - -/* timestamp of usage of this entry in ctx.connPool */ - struct timeval lastUsed; -} edg_wll_ConnPool; - - - -struct _edg_wll_Context { -/* Error handling */ - int errCode; /* recent error code */ - char *errDesc; /* additional error description */ - -/* server part */ - - void *mysql; - edg_wll_ConnPool *connPool; - edg_wll_ConnPool *connPoolNotif; /* hold _one_ connection from notif-interlogger */ - edg_wll_ConnProxy *connProxy; /* holds one plain connection */ - - int semaphores,semset; - edg_wll_QueryRec **job_index; - void *job_index_cols; - - time_t peerProxyValidity; - char *peerName; - edg_wll_VomsGroups vomsGroups; - int allowAnonymous; - int noAuth; /* if set, you can obtain info about events */ - /* and jobs not belonging to you */ - int noIndex; /* don't enforce indices */ - int rgma_export; - int strict_locking; /* lock jobs for storing event too */ - - int is_V21; /* true if old (V21) request arrived */ - int isProxy; /* LBProxy */ - -/* server limits */ - int softLimit; - int hardJobsLimit; - int hardEventsLimit; - - time_t notifDuration; - -/* purge and dump files storage */ - char *dumpStorage; - char *purgeStorage; - -/* flag for function store_event - * if set then event are loaded from dump file - */ - int event_load; - -/* address and port we are listening at */ - char *srvName; - unsigned int srvPort; - -/* pool of connections from client */ - int poolSize; - int connOpened; /* number of opened connections */ - int connToUse; /* index of connection that will * - * be used by low-level f-cions */ - // XXX similar variables will be needed for connPoolNotif - - -/* other client stuff */ - int notifSock; /* default client socket * - * for receiving notifications */ - -/* user settable parameters */ - char *p_host; - edg_wll_Source p_source; - char *p_instance; - enum edg_wll_Level p_level; - char *p_destination; - int p_dest_port; - char *p_lbproxy_store_sock; - char *p_lbproxy_serve_sock; - char *p_user_lbproxy; - struct timeval p_log_timeout,p_sync_timeout,p_query_timeout, p_notif_timeout, p_tmp_timeout; - char *p_query_server; - int p_query_server_port; - int p_query_server_override; - int p_query_events_limit; - int p_query_jobs_limit; - edg_wll_QueryResults p_query_results; - char *p_notif_server; - int p_notif_server_port; - char *p_proxy_filename; - char *p_cert_filename; - char *p_key_filename; - time_t purge_timeout[EDG_WLL_NUMBER_OF_STATCODES]; -/* producer part */ - edg_wlc_JobId p_jobid; - edg_wll_SeqCode p_seqcode; -}; - -/* to be used internally: set, update and and clear the error information in - * context, the desc string (if provided) is strdup()-ed - * - * all return the error code for convenience (usage in return statement) */ - - -extern int edg_wll_SetError( - edg_wll_Context, /* context */ - int, /* error code */ - const char * /* error description */ -); - -extern int edg_wll_SetErrorGss( - edg_wll_Context, - const char *, - edg_wll_GssStatus * -); - -/** update errDesc and errCode */ -extern int edg_wll_UpdateError( - edg_wll_Context, /* context */ - int, /* error code */ - const char * /* error description */ -); - -/** set errCode to 0, free errDesc */ -extern int edg_wll_ResetError(edg_wll_Context); - -/** retrieve standard error text wrt. code - * !! does not allocate memory */ -extern const char *edg_wll_GetErrorText(int); - -extern int edg_wll_ContextReopen(edg_wll_Context); - -extern int edg_wll_SetSequenceCode(edg_wll_Context, const char *, int); -extern int edg_wll_IncSequenceCode(edg_wll_Context ctx); - - -#ifdef __cplusplus -} -#endif -#endif /* __EDG_WORKLOAD_LOGGING_COMMON_CONTEXT_H__ */ diff --git a/org.glite.lb.common/interface/escape.h b/org.glite.lb.common/interface/escape.h deleted file mode 100644 index 4cf54c0..0000000 --- a/org.glite.lb.common/interface/escape.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_ESCAPE_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_ESCAPE_H__ -/*! - * \file Client/escape.h - * \brief Prototypes for Client/escape.c - */ - -#ident "$Header$" - - -/*! - * \fn char *edg_wll_LogEscape(const char *str) - * \param str a string to escape - * \return new (allocated) escaped string - * \brief in given string (ULM) escape all ULM_QM, ULM_BS and ULM_LF by ULM_BS - */ - -char *edg_wll_LogEscape(const char *); - - -/*! - * \fn char *edg_wll_LogUnescape(const char *str) - * \param str a string to unescape - * \return new (allocated) unescaped string - * \brief in given string (ULM) unescape all escaped ULM_QM, ULM_BS and ULM_LF - */ - -char *edg_wll_LogUnescape(const char *); - - -/*! - * \fn char *edg_wll_EscapeXML(const char *str); - * \param str a string to escape - * \return new (allocated) escaped string - * \brief in given string (XML) escape all unwanted characters - */ - -char *edg_wll_EscapeXML(const char *); - - -/*! - * \fn char *edg_wll_UnescapeXML(const char *str) - * \param str a string to unescape - * \return new (allocated) unescaped string - * \brief in given string (XML) unescape all escaped characters - */ - -char *edg_wll_UnescapeXML(const char *); - - -/*! - * \fn char *edg_wll_EscapeSQL(const char *str) - * \param str a string to escape - * \return new (allocated) escaped string - * \briefin given string (SQL) escape all unwanted characters - */ - -char *edg_wll_EscapeSQL(const char *); - -#endif /* __EDG_WORKLOAD_LOGGING_COMMON_ESCAPE_H__ */ diff --git a/org.glite.lb.common/interface/events_parse.h b/org.glite.lb.common/interface/events_parse.h deleted file mode 100644 index 155d7ac..0000000 --- a/org.glite.lb.common/interface/events_parse.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_EVENTS_PARSE_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_EVENTS_PARSE_H__ - -#ident "$Header$" - -#include "glite/lb/events.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Parse a ULM line into a edg_wll_Event structure - * \param context IN: context to work with - * \param logline IN: ULM string to parse - * \param event OUT: parsed event - * (may be NULL - syntax checking with no output) - */ -extern edg_wll_ErrorCode edg_wll_ParseEvent( - edg_wll_Context context, - edg_wll_LogLine logline, - edg_wll_Event ** event -); - -/** - * Generate ULM line from edg_wll_Event structure - * \param context IN: context to work with - * \param event IN: event to unparse - */ -extern edg_wll_LogLine edg_wll_UnparseEvent( - edg_wll_Context context, - edg_wll_Event * event -); - -/** - * Check event for completness. - * Auxiliary function, checks whether all required fields of - * the event type are present. - * \param context IN: context to work with - * \param event IN: event to check - */ -extern edg_wll_ErrorCode edg_wll_CheckEvent( - edg_wll_Context context, - edg_wll_Event * event -); - -/** - * Compare two event structures - * Auxiliary function, compares all fields of two event structure - * \param context IN: context to work with - * \param e1 IN: first event to compare - * \param e2 IN: second event to compare - */ -extern edg_wll_ErrorCode edg_wll_CompareEvents( - edg_wll_Context context, - const edg_wll_Event *e1, - const edg_wll_Event *e2 -); - - -/** - * Parse "only" jobId from ULM message - * \param logline IN: ULM string to parse - * \return jobId string - */ -extern char *edg_wll_GetJobId(edg_wll_LogLine logline); - -/** - * Parse a special Notification ULM line into a edg_wll_Event structure - * \param context IN: context to work with - * \param logline IN: ULM string to parse - * \param event OUT: parsed event - * (may be NULL - syntax checking with no output) - */ -extern edg_wll_ErrorCode edg_wll_ParseNotifEvent( - edg_wll_Context context, - edg_wll_LogLine logline, - edg_wll_Event ** event -); - -/** - * Generate a special Notification ULM line from edg_wll_Event structure - * \param context IN: context to work with - * \param event IN: event to unparse - */ -extern edg_wll_LogLine edg_wll_UnparseNotifEvent( - edg_wll_Context context, - edg_wll_Event * event -); - -#ifdef __cplusplus -} -#endif - - -#endif /* __EDG_WORKLOAD_LOGGING_COMMON_EVENTS_PARSE_H__ */ diff --git a/org.glite.lb.common/interface/il_string.h b/org.glite.lb.common/interface/il_string.h deleted file mode 100644 index db480f7..0000000 --- a/org.glite.lb.common/interface/il_string.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef NET_STRING_H -#define NET_STRING_H - -#ident "$Header$" - -#define MAXLEN 1024 - -char *put_int(char *p, int d); -char *_put_int(char *p, int d); -char *put_string(char *p, char *s); - -char *get_int(char *p, int *d); -char *_get_int(char *p, int *d); -char *get_string(char *p, char **s); - -int len_string(char *s); -int len_int(int d); - -enum { - LB_OK = 0, - LB_NOMEM = 200, - LB_PROTO = 400, - LB_AUTH = 500, - LB_PERM = 600, - LB_DBERR = 700, - LB_SYS = 800, - LB_TIME = 900 -}; - -#endif diff --git a/org.glite.lb.common/interface/lb_gss.h b/org.glite.lb.common/interface/lb_gss.h deleted file mode 100644 index 047b718..0000000 --- a/org.glite.lb.common/interface/lb_gss.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_LB_GSS_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_LB_GSS_H__ - -#ident "$Header$" - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - EDG_WLL_GSS_OK = 0, /* no GSS errors */ - EDG_WLL_GSS_ERROR_GSS = -1, /* GSS specific error, call edg_wll_get_gss_error() for details */ - EDG_WLL_GSS_ERROR_TIMEOUT = -2, /* Timeout */ - EDG_WLL_GSS_ERROR_EOF = -3, /* EOF occured */ - EDG_WLL_GSS_ERROR_ERRNO = -4, /* System error. See errno */ - EDG_WLL_GSS_ERROR_HERRNO = -5 /* Resolver error. See h_errno */ -}; - -typedef struct _edg_wll_GssConnection { - gss_ctx_id_t context; - int sock; - char buffer[BUFSIZ]; - size_t bufsize; -} edg_wll_GssConnection; - -typedef struct _edg_wll_GssStatus { - OM_uint32 major_status; - OM_uint32 minor_status; -} edg_wll_GssStatus; - -/* XXX Support anonymous connections. Are we able/required to support - * anonymous servers as well. */ - -int -edg_wll_gss_acquire_cred_gsi(char *cert_file, - char *key_file, - gss_cred_id_t *cred, - char **name, - edg_wll_GssStatus* gss_code); - -int -edg_wll_gss_connect(gss_cred_id_t cred, - char const *hostname, - int port, - struct timeval *timeout, - edg_wll_GssConnection *connection, - edg_wll_GssStatus* gss_code); - -int -edg_wll_gss_accept(gss_cred_id_t cred, - int sock, - struct timeval *timeout, - edg_wll_GssConnection *connection, - edg_wll_GssStatus* gss_code); - -int -edg_wll_gss_read(edg_wll_GssConnection *connection, - void *buf, - size_t bufsize, - struct timeval *timeout, - edg_wll_GssStatus* gss_code); - -int -edg_wll_gss_write(edg_wll_GssConnection *connection, - const void *buf, - size_t bufsize, - struct timeval *timeout, - edg_wll_GssStatus* gss_code); - -int -edg_wll_gss_read_full(edg_wll_GssConnection *connection, - void *buf, - size_t bufsize, - struct timeval *timeout, - size_t *total, - edg_wll_GssStatus* gss_code); - -int -edg_wll_gss_write_full(edg_wll_GssConnection *connection, - const void *buf, - size_t bufsize, - struct timeval *timeout, - size_t *total, - edg_wll_GssStatus* gss_code); - -int -edg_wll_gss_watch_creds(const char * proxy_file, - time_t * proxy_mtime); - -int -edg_wll_gss_get_error(edg_wll_GssStatus* gss_code, - const char *prefix, - char **errmsg); - -int -edg_wll_gss_close(edg_wll_GssConnection *connection, - struct timeval *timeout); - -int -edg_wll_gss_reject(int sock); - -int -edg_wll_gss_oid_equal(const gss_OID a, - const gss_OID b); - -/* -int -edg_wll_gss_get_name(gss_cred_id_t cred, char **name); -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_COMMON_LB_GSS_H__ */ diff --git a/org.glite.lb.common/interface/lb_plain_io.h b/org.glite.lb.common/interface/lb_plain_io.h deleted file mode 100644 index d423bbc..0000000 --- a/org.glite.lb.common/interface/lb_plain_io.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_LB_PLAIN_IO_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_LB_PLAIN_IO_H__ - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _edg_wll_PlainConnection { - int sock; - char *buf; - size_t bufSize; - size_t bufUse; -} edg_wll_PlainConnection; - - -int edg_wll_plain_accept( - int sock, - edg_wll_PlainConnection *conn); - -int edg_wll_plain_close( - edg_wll_PlainConnection *conn); - -int edg_wll_plain_read( - edg_wll_PlainConnection *conn, - void *outbuf, - size_t outbufsz, - struct timeval *timeout); - -int edg_wll_plain_read_full( - edg_wll_PlainConnection *conn, - void *outbuf, - size_t outbufsz, - struct timeval *timeout); - -int edg_wll_plain_write_full( - edg_wll_PlainConnection *conn, - const void *buf, - size_t bufsz, - struct timeval *timeout); - -#ifdef __cplusplus -} -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_COMMON_LB_PLAIN_IO_H__ */ diff --git a/org.glite.lb.common/interface/log_proto.h b/org.glite.lb.common/interface/log_proto.h deleted file mode 100644 index a2a59a8..0000000 --- a/org.glite.lb.common/interface/log_proto.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_LOG_PROTO_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_LOG_PROTO_H__ - -#ident "$Header$" - -/** - * \file edg/workload/logging/common/log_proto.h - * \brief common part of the logging protocol - * \note private - */ - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * default (noauth) user name - */ -/** default user */ -#define EDG_WLL_LOG_USER_DEFAULT "anonymous" - - -/** - * default prefix for names of log files - */ -/** default prefix */ -#define EDG_WLL_LOG_PREFIX_DEFAULT "/tmp/dglogd.log" - - -/** - * default local-logger Socket header - */ -/** header text */ -#define EDG_WLL_LOG_SOCKET_HEADER "DGLOG" -/** header length */ -#define EDG_WLL_LOG_SOCKET_HEADER_LENGTH 5 - - -/** - * default local-logger destination - */ -/** host */ -#define EDG_WLL_LOG_HOST_DEFAULT "localhost" -/** port */ -#define EDG_WLL_LOG_PORT_DEFAULT 9002 - - -/** - * default and maximal logging timeout (in seconds) - */ -#define EDG_WLL_LOG_TIMEOUT_DEFAULT 120 -#define EDG_WLL_LOG_TIMEOUT_MAX 1800 -#define EDG_WLL_LOG_SYNC_TIMEOUT_DEFAULT 120 -#define EDG_WLL_LOG_SYNC_TIMEOUT_MAX 1800 - - -/** - * maximal message size for sync logging - */ -/** max message size in bytes */ -// unlimited for tests! -#define EDG_WLL_LOG_SYNC_MAXMSGSIZE 102400000 - - -/** - * default maximal number of simultaneously open connections from one client - */ -#define EDG_WLL_LOG_CONNECTIONS_DEFAULT 4 - - -#ifdef __cplusplus -} -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_COMMON_LOG_PROTO_H__ */ diff --git a/org.glite.lb.common/interface/mini_http.h b/org.glite.lb.common/interface/mini_http.h deleted file mode 100644 index 2b846f3..0000000 --- a/org.glite.lb.common/interface/mini_http.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_MINI_HTTP_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_MINI_HTTP_H__ - -#ident "$Header$" - -#include "glite/lb/consumer.h" - -/* XXX: not a good place for the folowing #def's but we ain't got better currently */ -/** protocol version */ -#define PROTO_VERSION "3.0" -#define PROTO_VERSION_V21 "2.1" -/** backward protocol compatibility */ -/* version separated by comma */ -/* e.g. "1.0,1.2,1.3" */ -#define COMP_PROTO "3.0" -#define COMP_PROTO_V21 "2.0,2.1" - - -/* subset of HTTP codes we return */ -#define HTTP_OK 200 -#define HTTP_BADREQ 400 -#define HTTP_UNAUTH 401 -#define HTTP_NOTFOUND 404 -#define HTTP_NOTALLOWED 405 -#define HTTP_UNSUPPORTED 415 -#define HTTP_INTERNAL 500 -#define HTTP_NOTIMPL 501 -#define HTTP_UNAVAIL 503 -#define HTTP_INVALID 579 - -extern edg_wll_ErrorCode edg_wll_http_recv( - edg_wll_Context, /* INOUT: context */ - char **, /* OUT: first line */ - char ***, /* OUT: null terminated array of headers */ - char ** /* OUT: message body */ -); - -extern edg_wll_ErrorCode edg_wll_http_send( - edg_wll_Context, /* INOUT: context */ - const char *, /* IN: first line */ - char const * const *, /* IN: headers */ - const char * /* IN: message body */ -); - -extern edg_wll_ErrorCode edg_wll_http_recv_proxy( - edg_wll_Context, /* INOUT: context */ - char **, /* OUT: first line */ - char ***, /* OUT: null terminated array of headers */ - char ** /* OUT: message body */ -); - -extern edg_wll_ErrorCode edg_wll_http_send_proxy( - edg_wll_Context, /* INOUT: context */ - const char *, /* IN: first line */ - char const * const *, /* IN: headers */ - const char * /* IN: message body */ -); - -#endif /* __EDG_WORKLOAD_LOGGING_COMMON_MINI_HTTP_H__ */ diff --git a/org.glite.lb.common/interface/trio.h b/org.glite.lb.common/interface/trio.h deleted file mode 100644 index 04f133c..0000000 --- a/org.glite.lb.common/interface/trio.h +++ /dev/null @@ -1,187 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 1998 Bjorn Reese and Daniel Stenberg. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************/ - -#ifndef TRIO_TRIO_H -#define TRIO_TRIO_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* make utility and C++ compiler in Windows NT fails to find this symbol */ -#if defined(WIN32) && !defined(isascii) -# define isascii ((unsigned)(x) < 0x80) -#endif - -/* - * Error codes. - * - * Remember to add a textual description to trio_strerror. - */ -enum { - TRIO_EOF = 1, - TRIO_EINVAL = 2, - TRIO_ETOOMANY = 3, - TRIO_EDBLREF = 4, - TRIO_EGAP = 5, - TRIO_ENOMEM = 6, - TRIO_ERANGE = 7 -}; - -/* Error macros */ -#define TRIO_ERROR_CODE(x) ((-(x)) & 0x00FF) -#define TRIO_ERROR_POSITION(x) ((-(x)) >> 8) -#define TRIO_ERROR_NAME(x) trio_strerror(x) - -const char *trio_strerror(int); - -/************************************************************************* - * Print Functions - */ - -int trio_printf(const char *format, ...); -int trio_vprintf(const char *format, va_list args); -int trio_printfv(const char *format, void **args); - -int trio_fprintf(FILE *file, const char *format, ...); -int trio_vfprintf(FILE *file, const char *format, va_list args); -int trio_fprintfv(FILE *file, const char *format, void **args); - -int trio_dprintf(int fd, const char *format, ...); -int trio_vdprintf(int fd, const char *format, va_list args); -int trio_dprintfv(int fd, const char *format, void **args); - -/* trio_sprintf(target, format, ...) - * trio_snprintf(target, maxsize, format, ...) - * - * Build 'target' according to 'format' and succesive - * arguments. This is equal to the sprintf() and - * snprintf() functions. - */ -int trio_sprintf(char *buffer, const char *format, ...); -int trio_vsprintf(char *buffer, const char *format, va_list args); -int trio_sprintfv(char *buffer, const char *format, void **args); - -int trio_snprintf(char *buffer, size_t max, const char *format, ...); -int trio_vsnprintf(char *buffer, size_t bufferSize, const char *format, - va_list args); -int trio_snprintfv(char *buffer, size_t bufferSize, const char *format, - void **args); - -int trio_snprintfcat(char *buffer, size_t max, const char *format, ...); -int trio_vsnprintfcat(char *buffer, size_t bufferSize, const char *format, - va_list args); - -char *trio_aprintf(const char *format, ...); -char *trio_vaprintf(const char *format, va_list args); - -int trio_asprintf(char **ret, const char *format, ...); -int trio_vasprintf(char **ret, const char *format, va_list args); - -/************************************************************************* - * Scan Functions - */ -int trio_scanf(const char *format, ...); -int trio_vscanf(const char *format, va_list args); -int trio_scanfv(const char *format, void **args); - -int trio_fscanf(FILE *file, const char *format, ...); -int trio_vfscanf(FILE *file, const char *format, va_list args); -int trio_fscanfv(FILE *file, const char *format, void **args); - -int trio_dscanf(int fd, const char *format, ...); -int trio_vdscanf(int fd, const char *format, va_list args); -int trio_dscanfv(int fd, const char *format, void **args); - -int trio_sscanf(const char *buffer, const char *format, ...); -int trio_vsscanf(const char *buffer, const char *format, va_list args); -int trio_sscanfv(const char *buffer, const char *format, void **args); - -/************************************************************************* - * Renaming - */ -#ifdef TRIO_REPLACE_STDIO -/* Replace the functions */ -#ifndef HAVE_PRINTF -# define printf trio_printf -#endif -#ifndef HAVE_VPRINTF -# define vprintf trio_vprintf -#endif -#ifndef HAVE_FPRINTF -# define fprintf trio_fprintf -#endif -#ifndef HAVE_VFPRINTF -# define vfprintf trio_vfprintf -#endif -#ifndef HAVE_SPRINTF -# define sprintf trio_sprintf -#endif -#ifndef HAVE_VSPRINTF -# define vsprintf trio_vsprintf -#endif -#ifndef HAVE_SNPRINTF -# define snprintf trio_snprintf -#endif -#ifndef HAVE_VSNPRINTF -# define vsnprintf trio_vsnprintf -#endif -#ifndef HAVE_SCANF -# define scanf trio_scanf -#endif -#ifndef HAVE_VSCANF -# define vscanf trio_vscanf -#endif -#ifndef HAVE_FSCANF -# define fscanf trio_fscanf -#endif -#ifndef HAVE_VFSCANF -# define vfscanf trio_vfscanf -#endif -#ifndef HAVE_SSCANF -# define sscanf trio_sscanf -#endif -#ifndef HAVE_VSSCANF -# define vsscanf trio_vsscanf -#endif -/* These aren't stdio functions, but we make them look similar */ -#define dprintf trio_dprintf -#define vdprintf trio_vdprintf -#define aprintf trio_aprintf -#define vaprintf trio_vaprintf -#define asprintf trio_asprintf -#define vasprintf trio_vasprintf -#define dscanf trio_dscanf -#define vdscanf trio_vdscanf -#endif - -/* strio compatible names */ -#define StrScan trio_sscanf -#define StrFormat trio_sprintf -#define StrFormatMax trio_snprintf -#define StrFormatAlloc trio_aprintf -#define StrFormatAppendMax trio_snprintfcat - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* TRIO_TRIO_H */ diff --git a/org.glite.lb.common/interface/ulm_parse.h b/org.glite.lb.common/interface/ulm_parse.h deleted file mode 100644 index ee7d85c..0000000 --- a/org.glite.lb.common/interface/ulm_parse.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_ULM_PARSE_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_ULM_PARSE_H__ - -#ident "$Header$" - -#include /* for ULCconvertDate */ -#include - -/*========= DATA =====================================================*/ - -#define ULM_DATE_STRING_LENGTH 21 -#define ULM_FIELDS_MAX 100 /* max number of fields */ -#define ULM_PARSE_OK 0 -#define ULM_PARSE_ERROR -1 - -#define ULM_EQ '=' -#define ULM_QM '"' -#define ULM_BS '\\' -#define ULM_SP ' ' -#define ULM_TB '\t' -#define ULM_LF '\n' - -typedef char *LogLine; - -typedef struct _edg_wll_ULMFields { - LogLine raw; - int *names; - int *vals; - int num; -} edg_wll_ULMFields , *p_edg_wll_ULMFields; - -/*========= FUNCTIONS ================================================*/ - -#define EDG_WLL_ULM_CLEAR_FIELDS(x) { if (x) { if (x->vals) free(x->vals); if (x->names) free(x->names); x->num=0; } } - -extern p_edg_wll_ULMFields edg_wll_ULMNewParseTable( LogLine ); -extern void edg_wll_ULMFreeParseTable(p_edg_wll_ULMFields ); - -extern int edg_wll_ULMProcessParseTable( p_edg_wll_ULMFields ); -extern char * edg_wll_ULMGetNameAt( p_edg_wll_ULMFields, int ); -extern char * edg_wll_ULMGetValueAt ( p_edg_wll_ULMFields, int ); - -extern double edg_wll_ULMDateToDouble( const char *s ); -void edg_wll_ULMDateToTimeval( const char *s, struct timeval *tv ); -extern int edg_wll_ULMTimevalToDate( long sec, long usec, char *dstr ); - -#endif /* __EDG_WORKLOAD_LOGGING_COMMON_ULM_PARSE_H__ */ diff --git a/org.glite.lb.common/interface/xml_conversions.h b/org.glite.lb.common/interface/xml_conversions.h deleted file mode 100644 index 7d289ab..0000000 --- a/org.glite.lb.common/interface/xml_conversions.h +++ /dev/null @@ -1,136 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_XML_CONVERSIONS_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_XML_CONVERSIONS_H__ - -#ident "$Header$" - -#include "glite/lb/events.h" -#include "glite/lb/consumer.h" -#include "glite/lb/purge.h" -#include "glite/lb/dump.h" -#include "glite/lb/load.h" -#include "glite/lb/notification.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define EDG_WLL_STAT_NO_JOBS 1024 /* private flags for edg_wll_QueryJobs */ -#define EDG_WLL_STAT_NO_STATES 2048 - -enum edg_wll_QueryType { - EDG_WLL_QUERY_TYPE_UNDEF, - EDG_WLL_QUERY_TYPE_JOB_CONDITION, - EDG_WLL_QUERY_TYPE_EVENT_CONDITION, -}; - -typedef struct _edg_wll_XML_ctx { - edg_wll_Context ctx; - XML_Parser p; - char *message_body; /* copy of pointer to data to be parsed */ - edg_wll_EventCode eventCode; /* code of processed event */ - int position; /* row index in the result list */ - /* always should mean 'where to write' */ - int position2; /* used only for event_conditions */ - int max_index; /* used in IntList */ - int row; /* row index in QueryRec job_conditions */ - int row2; /* row index in QueryRec event_conditions */ - int level; /* level of XML tags nesting */ - char element[50]; /* name of actual XML tag */ - char *char_buf; /* for storing 'between tags' data */ - int char_buf_len; - char *XML_tag; /* for handling *ListOut's tag comparisons */ - char *XML_tag2; - edg_wll_QueryRec **job_conditions; /* temporal results */ - edg_wll_QueryRec **event_conditions; - enum edg_wll_QueryType type; - edg_wll_QueryRec **conditions; - int flags; - edg_wlc_JobId *jobsOutGlobal; - edg_wll_Event *eventsOutGlobal; - edg_wll_JobStat *jobStatGlobal; - edg_wll_JobStat jobStatSingleGlobal; - char **strListGlobal; - int *intListGlobal; - int (*tagToIndex)(); - char *(*indexToTag)(); - edg_wll_TagValue *tagListGlobal; - edg_wll_JobStat *stsListGlobal; - edg_wll_PurgeRequest purgeRequestGlobal; - edg_wll_PurgeResult purgeResultGlobal; - edg_wll_DumpRequest dumpRequestGlobal; - edg_wll_DumpResult dumpResultGlobal; - edg_wll_LoadRequest loadRequestGlobal; - edg_wll_LoadResult loadResultGlobal; - edg_wll_QueryRec **attrsGlobal; - char *notifFunction; - char *notifClientAddress; - edg_wll_NotifId notifId; - edg_wll_NotifChangeOp notifChangeOp; - time_t notifValidity; - edg_wlc_JobId jobId; - char *source; - char *seqCode; - int errCode; - int bound; /* marks 2nd value of within operator */ - char *errDesc; - long stat_begin; /* begin of jobStat tag */ - long jobQueryRec_begin; /* begin of orJobConditions tag */ - char *errtxt; /* variable for cummulating error messages */ - char *warntxt; /* variable for cummulating warning messages */ -} edg_wll_XML_ctx; - -void edg_wll_initXMLCtx(edg_wll_XML_ctx *c); -void edg_wll_freeXMLCtx(edg_wll_XML_ctx *c); -void edg_wll_freeBuf(edg_wll_XML_ctx *c); - - -#define edg_wll_add_bool_to_XMLBody edg_wll_add_int_to_XMLBody -#define edg_wll_add_port_to_XMLBody edg_wll_add_uint16_t_to_XMLBody -#define edg_wll_from_string_to_bool edg_wll_from_string_to_uint16_t -#define edg_wll_from_string_to_port edg_wll_from_string_to_int - -void edg_wll_add_string_to_XMLBody(char **body, const char *toAdd, const char *tag, const char *null); -void edg_wll_add_tagged_string_to_XMLBody(char **body, const char *toAdd, const char *tag, const char *name, const char *tag2, const char *null); -void edg_wll_add_int_to_XMLBody(char **body, const int toAdd, const char *tag, const int null); -void edg_wll_add_timeval_to_XMLBody(char **body, struct timeval toAdd, const char *tag, const struct timeval null); -void edg_wll_add_jobid_to_XMLBody(char **body, edg_wlc_JobId toAdd, const char *tag, const void *null); -void edg_wll_add_notifid_to_XMLBody(char **body, edg_wll_NotifId toAdd, const char *tag, const void *null); -void edg_wll_add_edg_wll_JobStatCode_to_XMLBody(char **body, edg_wll_JobStatCode toAdd, const char *tag, const edg_wll_JobStatCode null); -void edg_wll_add_edg_wll_EventCode_to_XMLBody(char **body, edg_wll_EventCode toAdd, const char *tag, const edg_wll_EventCode null); -void edg_wll_add_time_t_to_XMLBody(char **body, const time_t toAdd, const char *tag, const time_t null); -void edg_wll_add_tagged_time_t_to_XMLBody(char **body, const time_t toAdd, const char *tag, const char *name, const char *tag2, const time_t null); -void edg_wll_add_uint16_t_to_XMLBody(char **body, const uint16_t toAdd, const char *tag, const uint16_t null); -void edg_wll_add_logsrc_to_XMLBody(char **body, const edg_wll_Source toAdd, const char *tag, const edg_wll_Source null); -void edg_wll_add_intlist_to_XMLBody(char **body, const int *toAdd, const char *tag, char *(*indexToTag)(), const char *indent, const int from, const int to); -void edg_wll_add_strlist_to_XMLBody(char **body, char * const *toAdd, const char *tag, const char *subTag, const char *indent, const char *null); -void edg_wll_add_taglist_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const char *subTag, const char *indent, const char *subTag2, const char *null); -void edg_wll_add_time_t_list_to_XMLBody(char **body, const time_t *toAdd, const char *tag, char *(*indexToTag)(), const char *indent, const int from, const int to); -char *edg_wll_from_string_to_string(edg_wll_XML_ctx *XMLCtx); -edg_wlc_JobId edg_wll_from_string_to_jobid(edg_wll_XML_ctx *XMLCtx); -edg_wll_NotifId edg_wll_from_string_to_notifid(edg_wll_XML_ctx *XMLCtx); -edg_wll_JobStatCode edg_wll_from_string_to_edg_wll_JobStatCode(edg_wll_XML_ctx *XMLCtx); -int edg_wll_from_string_to_int(edg_wll_XML_ctx *XMLCtx); -long edg_wll_from_string_to_long(edg_wll_XML_ctx *XMLCtx); -uint16_t edg_wll_from_string_to_uint16_t(edg_wll_XML_ctx *XMLCtx); -struct timeval edg_wll_from_string_to_timeval(edg_wll_XML_ctx *XMLCtx); -time_t edg_wll_from_string_to_time_t(edg_wll_XML_ctx *XMLCtx); -edg_wll_Source edg_wll_from_string_to_logsrc(edg_wll_XML_ctx *XMLCtx); - -char *edg_wll_stat_flags_to_string(int flags); -int edg_wll_string_to_stat_flags(char *cflags); -char *edg_wll_purge_flags_to_string(int flags); -int edg_wll_string_to_purge_flags(char *cflags); -int edg_wll_StringToDumpConst(const char *name); -char *edg_wll_DumpConstToString(int dumpConst); -int edg_wll_StringTodone_code(const char *name); -char *edg_wll_done_codeToString(int done_codeConst); -edg_wll_QueryAttr edg_wll_StringToquery_attr(const char *name); -char *edg_wll_query_attrToString(edg_wll_QueryAttr query_attrConst); -edg_wll_NotifChangeOp edg_wll_StringToNotifChangeOp(const char *name); -char *edg_wll_NotifChangeOpToString(edg_wll_NotifChangeOp notifChangeOpConst); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_COMMON_XML_CONVERSIONS_H__ */ diff --git a/org.glite.lb.common/interface/xml_parse.h b/org.glite.lb.common/interface/xml_parse.h deleted file mode 100644 index a08d788..0000000 --- a/org.glite.lb.common/interface/xml_parse.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_XML_PARSE_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_XML_PARSE_H__ - -#ident "$Header$" - -#include "glite/lb/purge.h" -#include "glite/lb/dump.h" -#include "glite/lb/load.h" -#include "glite/lb/producer.h" -#include "glite/lb/notification.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/* function for parsing XML responses from server */ - -extern edg_wll_ErrorCode edg_wll_ParseQueryEvents(edg_wll_Context, char *, edg_wll_Event **); - -extern edg_wll_ErrorCode edg_wll_ParseQueryJobs(edg_wll_Context, char *, edg_wlc_JobId **, edg_wll_JobStat **); - -extern edg_wll_ErrorCode edg_wll_ParseUserJobs(edg_wll_Context, char *, edg_wlc_JobId **); - -extern edg_wll_ErrorCode edg_wll_ParseJobStat(edg_wll_Context ctx, char *messageBody, long len, edg_wll_JobStat *stat); - -extern edg_wll_ErrorCode edg_wll_ParseStrList(edg_wll_Context ctx, char *messageBody, long len, char *tag, char *tag2, char ***strListOut); - -extern edg_wll_ErrorCode edg_wll_ParseIntList(edg_wll_Context ctx, char *messageBody, long len, char *tag, int (*tagToIndex)(), int **intListOut); - -extern edg_wll_ErrorCode edg_wll_ParseTagList(edg_wll_Context ctx, char *messageBody, long len, char *tag, char *tag2, edg_wll_TagValue **tagListOut); - -extern edg_wll_ErrorCode edg_wll_ParseStsList(edg_wll_Context ctx, char *messageBody, long len, char *tag, char *tag2, edg_wll_JobStat **stsListOut); - -extern edg_wll_ErrorCode edg_wll_ParsePurgeResult(edg_wll_Context ctx, char *messageBody, edg_wll_PurgeResult *result); - -extern edg_wll_ErrorCode edg_wll_ParseDumpResult(edg_wll_Context ctx, char *messageBody, edg_wll_DumpResult *result); - -extern edg_wll_ErrorCode edg_wll_ParseLoadResult(edg_wll_Context ctx, char *messageBody, edg_wll_LoadResult *result); - -extern edg_wll_ErrorCode edg_wll_ParseIndexedAttrs(edg_wll_Context ctx, char *messageBody, edg_wll_QueryRec ***attrs); - -extern edg_wll_ErrorCode edg_wll_ParseNotifResult(edg_wll_Context ctx, char *messageBody, time_t *validity); - -extern edg_wll_ErrorCode edg_wll_ParseQuerySequenceCodeResult(edg_wll_Context ctx, char *messageBody, char **seqCode); - -extern int edg_wll_QueryEventsRequestToXML(edg_wll_Context ctx, const edg_wll_QueryRec **job_conditions, const edg_wll_QueryRec **event_conditions, char **send_mess); - -extern int edg_wll_JobQueryRecToXML(edg_wll_Context ctx, edg_wll_QueryRec const * const *conditions, char **send_mess); - -extern int edg_wll_QueryJobsRequestToXML(edg_wll_Context ctx, const edg_wll_QueryRec **conditions, int flags, char **send_mess); - -extern int edg_wll_PurgeRequestToXML(edg_wll_Context ctx, const edg_wll_PurgeRequest *request, char **message); - -extern int edg_wll_DumpRequestToXML(edg_wll_Context ctx, const edg_wll_DumpRequest *request, char **message); - -extern int edg_wll_LoadRequestToXML(edg_wll_Context ctx, const edg_wll_LoadRequest *request, char **message); - -extern int edg_wll_IndexedAttrsRequestToXML(edg_wll_Context ctx, char **message); - -extern int edg_wll_NotifRequestToXML( edg_wll_Context ctx, const char *function, const edg_wll_NotifId notifId, const char *address, edg_wll_NotifChangeOp op, edg_wll_QueryRec const * const *conditions, char **message); - -extern int edg_wll_QuerySequenceCodeToXML(edg_wll_Context ctx, edg_wlc_JobId jobId, char **message); - - -#ifdef __cplusplus -} -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_COMMON_XML_PARSE_H__ */ diff --git a/org.glite.lb.common/project/build.properties b/org.glite.lb.common/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.lb.common/project/configure.properties.xml b/org.glite.lb.common/project/configure.properties.xml deleted file mode 100644 index 911dfcf..0000000 --- a/org.glite.lb.common/project/configure.properties.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - -top_srcdir=.. -builddir=build -stagedir=${stage.abs.dir} -distdir=${dist.dir} -globalprefix=${global.prefix} -lbprefix=${subsystem.prefix} -package=${module.package.name} -PREFIX=${install.dir} -version=${module.version} -glite_location=${with.glite.location} -globus_prefix=${with.globus.prefix} -expat_prefix=${with.expat.prefix} -ares_prefix=${with.ares.prefix} -thrflavour=${with.globus.thr.flavor} -nothrflavour=${with.globus.nothr.flavor} -cppunit=${with.cppunit.prefix} - - - diff --git a/org.glite.lb.common/project/properties.xml b/org.glite.lb.common/project/properties.xml deleted file mode 100755 index 7b04062..0000000 --- a/org.glite.lb.common/project/properties.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.common/project/tar_exclude b/org.glite.lb.common/project/tar_exclude deleted file mode 100644 index e1fcd1a..0000000 --- a/org.glite.lb.common/project/tar_exclude +++ /dev/null @@ -1,10 +0,0 @@ -tar_exclude -CVS -build.xml -build -build.properties -properties.xml -configure.properties.xml -.cvsignore -.project -.cdtproject diff --git a/org.glite.lb.common/project/version.properties b/org.glite.lb.common/project/version.properties deleted file mode 100644 index 3816e37..0000000 --- a/org.glite.lb.common/project/version.properties +++ /dev/null @@ -1,3 +0,0 @@ -module.version=1.0.0 -module.build=110 -module.age=2 diff --git a/org.glite.lb.common/src/context.c b/org.glite.lb.common/src/context.c deleted file mode 100644 index e58270f..0000000 --- a/org.glite.lb.common/src/context.c +++ /dev/null @@ -1,436 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include - -#include - -#include "glite/wmsutils/jobid/strmd5.h" -#include "glite/wmsutils/jobid/cjobid.h" -#include "context-int.h" -#include "glite/lb/producer.h" - -static void free_voms_groups(edg_wll_VomsGroups *); - -int edg_wll_InitContext(edg_wll_Context *ctx) -{ - int i; - edg_wll_Context out = (edg_wll_Context) malloc(sizeof(*out)); - - if (!out) return ENOMEM; - memset(out,0,sizeof(*out)); - assert(out->errDesc == NULL); - - out->allowAnonymous = 1; - out->notifSock = -1; - - /* XXX */ - for (i=0; iconnPool = (edg_wll_ConnPool *) calloc(out->poolSize, sizeof(edg_wll_ConnPool)); - out->connPoolNotif = (edg_wll_ConnPool *) calloc(1, sizeof(edg_wll_ConnPool)); - out->connProxy = (edg_wll_ConnPool *) calloc(1, sizeof(edg_wll_ConnProxy)); - out->connProxy->conn.sock = -1; - - *ctx = out; - return 0; -} - -void edg_wll_FreeContext(edg_wll_Context ctx) -{ - struct timeval close_timeout = {0, 50000}; - OM_uint32 min_stat; - - if (!ctx) return; - - if (ctx->errDesc) free(ctx->errDesc); - if (ctx->connPool) { - int i; - - for (i=0; ipoolSize; i++) { - if (ctx->connPool[i].peerName) free(ctx->connPool[i].peerName); - edg_wll_gss_close(&ctx->connPool[i].gss,&close_timeout); - if (ctx->connPool[i].gsiCred) - gss_release_cred(&min_stat, &ctx->connPool[i].gsiCred); - if (ctx->connPool[i].buf) free(ctx->connPool[i].buf); - } - free(ctx->connPool); - } - if ( ctx->connProxy ) { - if ( ctx->connProxy->buf ) free(ctx->connProxy->buf); - edg_wll_plain_close(&ctx->connProxy->conn); - free(ctx->connProxy); - } - if (ctx->notifSock >=0) close(ctx->notifSock); - if (ctx->srvName) free(ctx->srvName); - if (ctx->peerName) free(ctx->peerName); - if (ctx->vomsGroups.len) free_voms_groups(&ctx->vomsGroups); - if (ctx->dumpStorage) free(ctx->dumpStorage); - if (ctx->purgeStorage) free(ctx->purgeStorage); - - if (ctx->p_jobid) edg_wlc_JobIdFree(ctx->p_jobid); - if (ctx->p_host) free(ctx->p_host); - if (ctx->p_instance) free(ctx->p_instance); - if (ctx->p_destination) free(ctx->p_destination); - if (ctx->p_user_lbproxy) free(ctx->p_user_lbproxy); - if (ctx->p_query_server) free(ctx->p_query_server); - if (ctx->p_notif_server) free(ctx->p_notif_server); - if (ctx->p_proxy_filename) free(ctx->p_proxy_filename); - if (ctx->p_cert_filename) free(ctx->p_cert_filename); - if (ctx->p_key_filename) free(ctx->p_key_filename); - - /* do not free (references only) - * ctx->job_index - * ctx->job_index_cols - * ctx->mysql */ - - free(ctx); -} - -static const char* const errTexts[] = { - /* standard error strings should appear here */ - "Broken ULM", - "Undefined event", - "Message incomplete", - "Duplicate ULM key", - "Misuse of ULM key", - "Warning: extra ULM fields", - "XML Parse error", - "Server response error", - "Bad JobId format", - "Database call failed", - "Bad URL format", - "MD5 key clash", - "GSSAPI Error", - "DNS resolver error", - "No JobId specified in context", - "No indexed condition in query", - "Interlogger protocol error", - "Interlogger internal error", - "Interlogger has events pending", - "Compared events differ", -}; - -const char *edg_wll_GetErrorText(int code) { - return code ? - (code <= EDG_WLL_ERROR_BASE ? - strerror(code) : - errTexts[code - EDG_WLL_ERROR_BASE - 1] - ) : - NULL; -} - -int edg_wll_Error(edg_wll_Context ctx, char **errText, char **errDesc) -{ - char *text = NULL,*desc = NULL; - const char* et = edg_wll_GetErrorText(ctx->errCode); - - if (et) { - text = strdup(et); - if (ctx->errDesc) desc = (char *) strdup(ctx->errDesc); - } - - if (errText) *errText = text; else free(text); - if (errDesc) *errDesc = desc; else free(desc); - return ctx->errCode; -} - -int edg_wll_ResetError(edg_wll_Context ctx) -{ - if (ctx->errDesc) free(ctx->errDesc); - ctx->errDesc = NULL; - ctx->errCode = 0; - - return ctx->errCode; -} - -int edg_wll_SetError(edg_wll_Context ctx,int code,const char *desc) -{ - edg_wll_ResetError(ctx); - if (code) { - ctx->errCode = code; - if (desc) ctx->errDesc = (char *) strdup(desc); - } - - return ctx->errCode; -} - - -int edg_wll_UpdateError(edg_wll_Context ctx,int code,const char *desc) -{ - char *new_desc=NULL; - char *old_desc=NULL; - const char* err_text = edg_wll_GetErrorText(ctx->errCode); - - /* first fill in the old_desc */ - if (ctx->errCode) { - if (ctx->errDesc) { - if ((err_text)) // && (code) && (code <> ctx->errCode)) - asprintf(&old_desc,"%s;; %s",err_text,ctx->errDesc); - else - old_desc = (char *) strdup(ctx->errDesc); - } else { - old_desc = (char *) strdup(err_text); - } - } else { - if (ctx->errDesc) old_desc = (char *) strdup(ctx->errDesc); - } - if (ctx->errDesc) free(ctx->errDesc); - - /* update errDesc */ - if (old_desc) { - if (desc) { - asprintf(&new_desc,"%s;; %s",desc,old_desc); - ctx->errDesc = (char *) strdup(new_desc); - } else { - ctx->errDesc = (char *) strdup(old_desc); - } - } else { - if (desc) ctx->errDesc = (char *) strdup(desc); - } - - /* update errCode */ - if (code) { - ctx->errCode = code; - } - - if (new_desc) free(new_desc); - if (old_desc) free(old_desc); - - return ctx->errCode; -} - -static const char* const srcNames[] = { - "Undefined", - "UserInterface", - "NetworkServer", - "WorkloadManager", - "BigHelper", - "JobController", - "LogMonitor", - "LRMS", - "Application", -}; - -edg_wll_Source edg_wll_StringToSource(const char *name) -{ - int i; - - for (i=1; i= EDG_WLL_SOURCE__LAST) return NULL; - return strdup(srcNames[src]); -} - -static const char* const queryResultNames[] = { - "Undefined", - "None", - "All", - "Limited" -}; - -edg_wll_QueryResults edg_wll_StringToQResult(const char *name) -{ - int i; - - for (i=1; i= EDG_WLL_QUERYRES__LAST) - return NULL; - - return strdup(queryResultNames[res]); -} - - -char *edg_wll_GetSequenceCode(const edg_wll_Context ctx) -{ - unsigned int *c; - char *ret = NULL; - - c = &ctx->p_seqcode.c[0]; - asprintf(&ret, "UI=%06d:NS=%010d:WM=%06d:BH=%010d:JSS=%06d" - ":LM=%06d:LRMS=%06d:APP=%06d", - c[EDG_WLL_SOURCE_USER_INTERFACE], - c[EDG_WLL_SOURCE_NETWORK_SERVER], - c[EDG_WLL_SOURCE_WORKLOAD_MANAGER], - c[EDG_WLL_SOURCE_BIG_HELPER], - c[EDG_WLL_SOURCE_JOB_SUBMISSION], - c[EDG_WLL_SOURCE_LOG_MONITOR], - c[EDG_WLL_SOURCE_LRMS], - c[EDG_WLL_SOURCE_APPLICATION]); - return ret; -} - -int edg_wll_SetSequenceCode(edg_wll_Context ctx, - const char * seqcode_str, int seq_type) -{ - int res; - unsigned int *c; - int duplicate = 0; - - edg_wll_ResetError(ctx); - - if (seq_type == EDG_WLL_SEQ_DUPLICATE) { - duplicate = 1; - } else if (seq_type != EDG_WLL_SEQ_NORMAL) - return edg_wll_SetError(ctx, EINVAL, - "edg_wll_SetSequenceCode(): unrecognized value of seq_type parameter"); - - if (!seqcode_str) { - memset(&ctx->p_seqcode,0,sizeof ctx->p_seqcode); - return 0; - } - - c = &ctx->p_seqcode.c[0]; - res = sscanf(seqcode_str, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d", - &c[EDG_WLL_SOURCE_USER_INTERFACE], - &c[EDG_WLL_SOURCE_NETWORK_SERVER], - &c[EDG_WLL_SOURCE_WORKLOAD_MANAGER], - &c[EDG_WLL_SOURCE_BIG_HELPER], - &c[EDG_WLL_SOURCE_JOB_SUBMISSION], - &c[EDG_WLL_SOURCE_LOG_MONITOR], - &c[EDG_WLL_SOURCE_LRMS], - &c[EDG_WLL_SOURCE_APPLICATION]); - - assert(EDG_WLL_SOURCE__LAST == 9); - if (res != EDG_WLL_SOURCE__LAST-1) - return edg_wll_SetError(ctx, EINVAL, "edg_wll_SetSequenceCode(): syntax error in sequence code"); - - if (duplicate) { - if (ctx->p_source <= EDG_WLL_SOURCE_NONE || ctx->p_source >= EDG_WLL_SOURCE__LAST) - return edg_wll_SetError(ctx,EINVAL,"edg_wll_SetSequenceCode(): context param: source missing"); - c[ctx->p_source] = time(NULL); - } - - return edg_wll_Error(ctx, NULL, NULL); -} - -int edg_wll_IncSequenceCode(edg_wll_Context ctx) -{ - edg_wll_ResetError(ctx); - - if (ctx->p_source <= EDG_WLL_SOURCE_NONE || ctx->p_source >= EDG_WLL_SOURCE__LAST) - return edg_wll_SetError(ctx,EINVAL,"edg_wll_IncSequenceCode(): context param: source missing"); - - ctx->p_seqcode.c[ctx->p_source]++; - - return edg_wll_Error(ctx, NULL, NULL); -} - -int edg_wll_GetLoggingJob(const edg_wll_Context ctx,edg_wlc_JobId *out) -{ - return edg_wlc_JobIdDup(ctx->p_jobid,out); -} - -int edg_wll_GenerateSubjobIds( - edg_wll_Context ctx, - const edg_wlc_JobId parent, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs) -{ - int subjob, ret; - char *p_unique, *p_bkserver, *intseed; - char *unhashed, *hashed; - unsigned int p_port; - edg_wlc_JobId *retjobs; - - - if (num_subjobs < 1) - return edg_wll_SetError(ctx, EINVAL, - "edg_wll_GenerateSubjobIds(): num_subjobs < 1"); - if (seed == NULL) - intseed = edg_wll_GetSequenceCode(ctx); - else - intseed = strdup(seed); - - p_unique = edg_wlc_JobIdGetUnique(parent); - edg_wlc_JobIdGetServerParts(parent, &p_bkserver, &p_port); - - retjobs = calloc(num_subjobs+1, sizeof(edg_wlc_JobId)); - - if (p_unique == NULL || - intseed == NULL || - p_bkserver == NULL || - retjobs == NULL) - return edg_wll_SetError(ctx, ENOMEM, NULL); - - for (subjob = 0; subjob < num_subjobs; subjob++) { - - asprintf(&unhashed, "%s,%s,%d", p_unique, intseed, subjob); - if (unhashed == NULL) { - edg_wll_SetError(ctx, ENOMEM, "edg_wll_GenerateSubjobIds(): asprintf() error"); - goto handle_error; - } - - hashed = str2md5base64(unhashed); - free(unhashed); - if (hashed == NULL) { - edg_wll_SetError(ctx, ENOMEM, "edg_wll_GenerateSubjobIds(): str2md5base64() error"); - goto handle_error; - } - - ret = edg_wlc_JobIdRecreate(p_bkserver, p_port, hashed, &retjobs[subjob]); - free(hashed); - if (ret != 0) { - edg_wll_SetError(ctx, ret, "edg_wll_GenerateSubjobIds(): edg_wlc_JobIdRecreate() error"); - goto handle_error; - } - } - - free(intseed); - free(p_unique); - free(p_bkserver); - - *subjobs = retjobs; - return 0; - - handle_error: - free(intseed); - free(p_unique); - free(p_bkserver); - for ( subjob-- ;subjob >= 0; subjob--) - edg_wlc_JobIdFree(retjobs[subjob]); - return edg_wll_Error(ctx, NULL, NULL); -} - -static void -free_voms_groups(edg_wll_VomsGroups *groups) -{ - size_t len; - - if (groups == NULL) - return; - - for (len = 0; len < groups->len; len++) { - if (groups->val[len].vo) - free(groups->val[len].vo); - if (groups->val[len].name) - free(groups->val[len].name); - } -} - -int edg_wll_SetErrorGss(edg_wll_Context ctx, const char *desc, edg_wll_GssStatus *gss_code) -{ - char *err_msg; - - edg_wll_gss_get_error(gss_code, desc, &err_msg); - edg_wll_SetError(ctx,EDG_WLL_ERROR_GSS, err_msg); - free(err_msg); - return ctx->errCode; -} diff --git a/org.glite.lb.common/src/escape.c b/org.glite.lb.common/src/escape.c deleted file mode 100644 index 8ace584..0000000 --- a/org.glite.lb.common/src/escape.c +++ /dev/null @@ -1,221 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include - -#include "ulm_parse.h" -#include "escape.h" - -/* - *---------------------------------------------------------------------- - * - * \fn char *edg_wll_LogEscape(const char *str) - * \param str a string to escape - * \return new (allocated) escaped string - * \brief in given string escape all ULM_QM, ULM_BS and ULM_LF by ULM_BS - * - * Calls: malloc, strlen - * - * Algorithm: array lookup - * - the new string will be allocated - * - *---------------------------------------------------------------------- - */ - -char *edg_wll_LogEscape(const char *str) -{ -unsigned int i,j; -size_t size; -char *ret; - -if (str == NULL) return NULL; -if ((size = strlen(str)) == 0) return strdup(""); - -ret = (char*) malloc(1+2*size*sizeof(char)); - -j = 0; -for (i=0; i',"gt" }, - { '&',"amp" }, - { '"',"quot" }, - { '\'',"apos" }, - { 0, NULL } -}; - -#define XML_ESCAPE_SET "<>&\"'" - -char *edg_wll_EscapeXML(const char *in) -{ - const char* tmp_in; - char *out; - int cnt,i,j,k; - - if (!in) return NULL; - - for (cnt = 0, tmp_in = in; *tmp_in != '\0'; ++tmp_in) { - if (strchr(XML_ESCAPE_SET, *tmp_in) || - (*tmp_in & 0x7f) < 0x20 /* control character */ || - (*tmp_in == '%')) cnt++; - } - - out = malloc(strlen(in)+1+cnt*5); - - for (i=j=0; in[i]; i++) { - for (k=0; xml_etab[k].c && xml_etab[k].c != in[i]; k++); - if (xml_etab[k].c) { - int l; - - out[j++] = '&'; - memcpy(out+j,xml_etab[k].e,l=strlen(xml_etab[k].e)); - j += l; - out[j++] = ';'; - } else if ((in[i] & 0x7f) < 0x20 || in[i] == '%') { - sprintf(out+j, "%%%02x", (unsigned char)in[i]); - j+=3; - } else { - out[j++] = in[i]; - } - } - out[j] = 0; - return out; -} - -char *edg_wll_UnescapeXML(const char *in) -{ - char *out; - int i,j,k; - char xtmp[3]; - unsigned char origchar; - - if (!in) return NULL; - out = malloc(strlen(in)+1); - - for (i=j=0; in[i]; j++) if (in[i] == '&') { - char *s = strchr(in+i,';'); - if (s) { - int l = s-in-i+1; - for (k=0; xml_etab[k].c && strncasecmp(in+i+1,xml_etab[k].e,l-2); k++); - if (xml_etab[k].c) { - out[j] = xml_etab[k].c; - i += l; - } else out[j] = in[i++]; - } else out[j] = in[i++]; - } else if (in[i] == '%') { - if (isxdigit(xtmp[0]=in[i+1]) && isxdigit(xtmp[1]=in[i+2])) { - xtmp[2] = '\0'; - origchar = (unsigned char) strtol(xtmp, NULL, 16); - if ((origchar & 0x7f) < 0x20 || origchar == '%') { - out[j] = origchar; - i += 3; - } else out[j] = in[i++]; - } else out[j] = in[i++]; - } else { - out[j] = in[i++]; - } - out[j] = 0; - return out; -} - -char *edg_wll_EscapeSQL(const char *in) -{ - const char* tmp_in; - char *out = NULL; - int i,j,cnt; - - if (!in) return NULL; - - for (cnt = 0, tmp_in = in; (tmp_in = strchr(tmp_in,'\'')) != NULL; ++tmp_in) { - ++cnt; - } - for (tmp_in = in; (tmp_in = strchr(tmp_in,'\\')) != NULL; ++tmp_in) { - ++cnt; - } - - out = malloc(strlen(in)+1+cnt); - - for (i=j=0; in[i]; i++) { - if (in[i] == '\\') out[j++] = '\\'; - if (in[i] == '\'') out[j++] = '\''; - out[j++] = in[i]; - } - out[j] = 0; - - return out; -} diff --git a/org.glite.lb.common/src/events.c.T b/org.glite.lb.common/src/events.c.T deleted file mode 100644 index 3d0861a..0000000 --- a/org.glite.lb.common/src/events.c.T +++ /dev/null @@ -1,350 +0,0 @@ -#ident "$Header$" -/* -@@@AUTO -*/ -@@@LANG: C - -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/producer.h" -#include "ulm_parse.h" - -static const struct timeval null_timeval = {0,0}; - -/** - * Predefined event types names - */ -static const char *eventNames[] = { - "Undefined", -@@@{ -for my $e (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - gen "\t\"$e\",\n"; -} -@@@} - "SysCmpStat", - "SysClStat", -}; - -/** - * \fn edg_wll_EventCode edg_wll_StringToEvent(char *name) - * \param name a string event name (e.g. "JobTransfer") - * \return corresponding numeric code (edg_wll_EventCode) - * \brief convert a string event name to the corresponding numeric code - * Calls: strcasecmp - * Algorithm: array lookup - */ -edg_wll_EventCode edg_wll_StringToEvent(char *name) -{ - unsigned int i; - - for (i=1; i= sizeof(eventNames)/sizeof(eventNames[0])) return NULL; - return strdup(eventNames[event]); -} - - -/** - * Predefined ULM key types names - */ -static const char *keyNames[] = { - "Undefined", - "DG.EVNT", -@@@{ -selectType $event '_common_'; -for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = getName $f 'ULM'; - my $fnu = uc $fn; - my $c = $f->{comment}; - if (hasAlias $f 'ULM') { - gen "\t\"$fnu\",\n"; - } else { - gen "\t\"DG.$fnu\",\n"; - } -} -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fnu = uc $f->{name}; - gen "\t\"DG.$tu.$fnu\",\n"; - } -} -@@@} - "DG.TYPE", -}; - -/* - * \fn edg_wll_KeyNameCode edg_wll_StringToKeyName(char *name) - * \param name a string ULM key name (e.g. "DG.JOB.TRANSFER.DEST") - * \return corresponding numeric code (edg_wll_KeyNameCode) - * \brief convert a string ULM key name to the corresponding numeric code - * Calls: strcasecmp - * Algorithm: array lookup - */ -edg_wll_KeyNameCode edg_wll_StringToKeyName(char *name) -{ - unsigned int i; - - for (i=1; i= sizeof(keyNames)/sizeof(keyNames[0])) return NULL; - return strdup(keyNames[key]); -} - - -/** - * Predefined _code_ types names and - * related StringTo_code and _code_ToString function implementations - */ -@@@{ -$indent = "\t"; -selectType $event '_common_'; -for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - if ($f->{codes}) { - my $fn = ucfirst($f->{name}); - my $fnu = uc $fn; - my $c = "${fn}"; # code - my $enum = "enum edg_wll\_$c"; # enum name - my $char = "edg_wll\_${fn}Names"; # char name -# static const char: - gen qq{ -/** - * Predefined code names for $c - */ -static const char \*${char}\[\] = \{ -}; - gen $indent."\"UNDEFINED\",\n"; - for (@{$f->{codes}}) { - gen $indent."\"$_->{name}\",\n"; - } - gen "}; \n"; - -# function StringTo: - gen qq{ -/** - * \\fn $enum edg_wll_StringTo${c}(char *name) - * Calls: strcasecmp - * Algorithm: array lookup - */ -$enum edg_wll_StringTo${c}(char *name) -\{ - unsigned int i; - - for (i=1; i= sizeof($char)/sizeof(${char}\[0\])) return NULL; - return strdup(${char}\[code\]); - -\} -\n\n}; - } -} -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t . '_'; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - if ($f->{codes}) { - my $fn = ucfirst($f->{name}); - my $c = "$t${fn}"; # code - my $enum = "enum edg_wll\_$c"; # enum name - my $char = "edg_wll\_$t${fn}Names"; # char name -# static const char: - gen qq{ -/** - * Predefined code names for $c - */ -static const char \*${char}\[\] = \{ -}; - gen $indent."\"UNDEFINED\",\n"; - for (@{$f->{codes}}) { - gen $indent."\"$_->{name}\",\n"; - } - gen "}; \n"; - -# function StringTo: - gen qq{ -/** - * \\fn $enum edg_wll_StringTo${c}(char *name) - * Calls: strcasecmp - * Algorithm: array lookup - */ -$enum edg_wll_StringTo${c}(char *name) -\{ - unsigned int i; - - for (i=1; i= sizeof($char)/sizeof(${char}\[0\])) return NULL; - return strdup(${char}\[code\]); - -\} -\n\n}; - } - } -} -@@@} - -/** - * Initialise an event structure - * \return pointer to initialised event structure - */ -edg_wll_Event *edg_wll_InitEvent( - edg_wll_EventCode eventcode /* eventcode IN */ -) -{ -edg_wll_Event *event; - -/* allocate memory for 'event' (edg_wll_Event); use calloc to also clean it */ -/* FIXME: what if calloc fails? should be checked somehow -> nomem etc. */ - event = (edg_wll_Event *) calloc(1,sizeof(edg_wll_Event)); - event->type = eventcode; -/* initialize common fields */ -@@@{ -$indent = "\t"; -selectType $event '_common_'; -for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->getName; - my $fd = $f->getDefaultNullValue; - gen $indent."event->any.$fn = $fd;\n" -} -@@@} -/* initialize dependent fields */ -switch (eventcode) { -@@@{ -$indent = " "; -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t; - my $tl = lcfirst $t; - gen $indent."case EDG_WLL_EVENT_$tu : \n"; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->getName; - my $fd = $f->getDefaultNullValue; - gen $indent."\tevent->$tl.$fn = $fd;\n" - } - gen $indent.$indent."break;\n"; -} -@@@} - case EDG_WLL_EVENT_UNDEF : - default : - break; -} -return event; -} - -/** - * edg_wll_FreeEvent - * \brief free memory allocated for edg_wll_Event internal fields - * Calls: free - */ -void edg_wll_FreeEvent( - edg_wll_Event *event /* event IN */ -) -{ -edg_wll_EventCode eventcode=event->type; - -/* free the common fields */ - if (event->any.jobId) edg_wlc_JobIdFree(event->any.jobId); -@@@{ -$indent = "\t"; -selectType $event '_common_'; -for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - my $ft = $f->{type}; - if ($ft eq 'string') { - gen $indent."if (event->any.$fn) free(event->any.$fn);\n" - } -} -@@@} - -/* free the rest */ -switch (eventcode) { -@@@{ -$indent = " "; -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t; - my $tl = lcfirst $t; - gen $indent."case EDG_WLL_EVENT_$tu :\n"; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - my $ft = $f->{type}; - if ($ft eq 'string') { - gen $indent."\tif (event->$tl.$fn) free(event->$tl.$fn);\n" - } - } - gen $indent.$indent."break;\n" -} -@@@} - case EDG_WLL_EVENT_UNDEF : - default: - break; -} - -} diff --git a/org.glite.lb.common/src/events_parse.c.T b/org.glite.lb.common/src/events_parse.c.T deleted file mode 100644 index 36f2d83..0000000 --- a/org.glite.lb.common/src/events_parse.c.T +++ /dev/null @@ -1,782 +0,0 @@ -#ident "$Header$" -/* -@@@AUTO -*/ -@@@LANG: C - -#include -#include -#include -#include - -#include "glite/lb/events.h" -#include "glite/lb/producer.h" -#include "events_parse.h" -#include "ulm_parse.h" -#include "context-int.h" -#include "escape.h" -#include "glite/wmsutils/jobid/cjobid.h" - -#include "trio.h" - -static const struct timeval null_timeval = {0,0}; - -/* -- Internal function prototype -- */ -char *my_edg_wll_ULMGetValueAt( p_edg_wll_ULMFields, int ); - -/** - * edg_wll_ParseEvent - parse ULM message to internal structures - * Calls: calloc, free, sprintf, strdup - * edg_wll_ULMNewParseTable, edg_wll_ULMFreeParseTable, edg_wll_ULMProcessParseTable, - * edg_wll_ULMGetNameAt, my_edg_wll_ULMGetValueAt, edg_wll_ULMDateToTimeval (edg_wll_ULMDateToDouble), - * edg_wll_StringToEvent, edg_wll_StringToKeyName, edg_wll_StringToLevel, edg_wlc_jobid_tParse, - * edg_wll_EventToString, edg_wll_KeyNameToString, edg_wll_SetError (or edg_wll_ResetError) - * Algorithm: break ULM string into fields and then according the event type - * fill in the proper structures - */ - -#define DUPLICITY { \ - char *k = edg_wll_KeyNameToString(keycode); \ - sprintf(err_desc,"Key %s already exists.", k); \ - free(k); \ - ret=edg_wll_SetError(context,EDG_WLL_ERROR_PARSE_KEY_DUPLICITY,err_desc); \ - goto end; } - -#define MISUSE { \ - char *e = edg_wll_EventToString(eventcode); \ - char *k = edg_wll_KeyNameToString(keycode); \ - sprintf(err_desc,"Key %s schouldn't be used for event type %s.", k,e); \ - free(e); \ - free(k); \ - ret=edg_wll_SetError(context,EDG_WLL_ERROR_PARSE_KEY_MISUSE,err_desc); \ - goto end; } - -edg_wll_ErrorCode edg_wll_ParseEvent( - edg_wll_Context context, /* context IN */ - edg_wll_LogLine logline, /* logline IN: ULM string to parse */ - edg_wll_Event **event /* event OUT: parsed event - (may be NULL - syntax checking with no output */ -) -{ -int i; -int extra=0; /* number of extra unknown key=value pairs */ -char err_desc[128]; /* error description for use in edg_wll_SetError */ -char *value=NULL; -p_edg_wll_ULMFields table = edg_wll_ULMNewParseTable(logline); -edg_wll_KeyNameCode keycode=UNDEFINED; -edg_wll_EventCode eventcode=EDG_WLL_EVENT_UNDEF; -edg_wll_ErrorCode ret; -edg_wll_Event *this=NULL; - -/* break ULM string into fields */ -if ( edg_wll_ULMProcessParseTable(table) != 0 ) { - ret=edg_wll_SetError(context,EDG_WLL_ERROR_PARSE_BROKEN_ULM,"ULM parse error"); - goto end; -} - -/* determine the event type */ -for (i=0; inum; i++) { - keycode=edg_wll_StringToKeyName(edg_wll_ULMGetNameAt(table,i)); - if ( keycode == EDG_WLL_EVNT ) { - value=my_edg_wll_ULMGetValueAt(table,i); - eventcode=edg_wll_StringToEvent(value); - free(value); - value=NULL; - break; - } -} -if ( eventcode == EDG_WLL_EVENT_UNDEF ) { - ret=edg_wll_SetError(context,EDG_WLL_ERROR_PARSE_EVENT_UNDEF,"Unknown or missing event type"); - goto end; -} -/* allocate memory for 'this' (edg_wll_Event) */ -// XXX: this = (edg_wll_Event *) calloc(1,sizeof(edg_wll_Event)); -this = edg_wll_InitEvent(eventcode); - -/* go through all fields and fill in the edg_wll_Event union - * in each step check for key duplicity and key name misuse - */ -for (i=0; inum; i++) { - keycode=edg_wll_StringToKeyName(edg_wll_ULMGetNameAt(table,i)); - value=my_edg_wll_ULMGetValueAt(table,i); - switch (keycode) { - case EDG_WLL_EVNT : - if (this->any.type != edg_wll_StringToEvent(value)) DUPLICITY - break; -@@@{ -$indent = " "; -selectType $event '_common_'; -for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = getName $f; - my $fnu = uc getName $f 'ULM'; - if (hasAlias $f 'ULM') { - gen $indent."case ULM\_$fnu :\n"; - } else { - gen $indent."case EDG_WLL\_COMMON\_$fnu :\n"; - } - gen "\tif ("; - gen $f->isnotNULL("this->any.$fn"); - gen ") DUPLICITY \n"; - gen "\t"; - if ($f->{codes}) { - my $c = ucfirst(${fn}); - gen "this->any.$fn = edg_wll_StringTo${c}(value);"; - } else { - gen $f->fromString('value',"this->any.$fn"); - } - gen "\n".$indent.$indent."break;\n"; -} -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t; - my $tl = lcfirst $t; - my $misuse = "if (eventcode != EDG_WLL_EVENT_$tu ) MISUSE"; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - my $fnu = uc $fn; - gen $indent."case EDG_WLL\_$tu\_$fnu :\n"; - gen "\tif ("; - gen $f->isnotNULL("this->$tl.$fn"); - gen ") DUPLICITY\n"; - gen "\t$misuse\n"; - if ($f->{codes}) { - my $c = "$t".ucfirst(${fn}); - gen "\tthis->$tl.$fn = edg_wll_StringTo${c}(value);"; - } else { - gen "\t"; - gen $f->fromString('value',"this->$tl.$fn"); - } - gen "\n".$indent.$indent."break;\n"; - } -} -@@@} - - case UNDEFINED : - case EDG_WLL_INTERNAL_TYPE : - break; - - default : - extra++; - break; - } - free(value); - value=NULL; -} - -/* now check if all required fields are present */ -ret=edg_wll_CheckEvent(context,this); -if (ret) { goto end; } - -/* parse is OK, only extra fields could occur */ -if (extra) { - sprintf(err_desc,"There are %d extra fields in the logline.",extra); - ret=edg_wll_SetError(context,EDG_WLL_ERROR_PARSE_OK_WITH_EXTRA_FIELDS,err_desc); } -else { ret=edg_wll_ResetError(context); } - -end: - /* finally (if wanted) "return" pointer to the filled edg_wll_Event union - NOTE: a pointer (to half-filled structure) is returned even if an error occured ! */ - if (event != NULL) { - *event = this; } - /* This also means, that the memory must be freed by edg_wll_FreeEvent() somewhere else */ - else { - edg_wll_FreeEvent(this); - free(this); - } - - edg_wll_ULMFreeParseTable(table); - return ret; -} - -/** - * edg_wll_UnparseEvent - unparse ULM message from internal structures - * Calls: malloc, free, strlen, strcmp, asprintf, trio_asprintf - * edg_wll_ULMTimevalToDate, - * edg_wll_EventToString, edg_wll_KeyNameToString, edg_wll_LevelToString, - * edg_wlc_jobid_tUnparse, - * Algorithm: format values from internal structures into a ULM string - */ -#define NOMEM { if (logline) free(logline); logline = NULL; edg_wll_SetError(context,ENOMEM,NULL); goto clean; } - -edg_wll_LogLine edg_wll_UnparseEvent( /* logline OUT */ - edg_wll_Context context, /* context IN */ - edg_wll_Event *event /* event IN */ -) -{ -edg_wll_LogLine logline; -edg_wll_EventCode eventcode=event->type; -char *date, *common, *user, *var, *e, *l, *j, *s; -edg_wll_Event nonulls; - -logline = date = common = user = var = NULL; - -/* FIXME: after EDG_WLL_FORMAT_COMMON automatic generation automate this code as well */ -/* format the common fields */ -date=(char *) malloc(1+ULM_DATE_STRING_LENGTH*sizeof(char)); -edg_wll_ULMTimevalToDate(event->any.timestamp.tv_sec, event->any.timestamp.tv_usec, date); - -memcpy(&nonulls,event,sizeof nonulls); -@@@{ - selectType $event '_common_'; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - gen "if (!nonulls.any.$fn) nonulls.any.$fn = \"\";\n" - if $f->{type} eq 'string'; - } -@@@} - -e = edg_wll_EventToString(eventcode); -l = edg_wll_LevelToString(event->any.level); -j = edg_wlc_JobIdUnparse(event->any.jobId); -s = edg_wll_SourceToString(event->any.source); -if (trio_asprintf(&common,EDG_WLL_FORMAT_COMMON, \ - date, event->any.host, l, event->any.priority, s, nonulls.any.src_instance, \ - e, j, nonulls.any.seqcode) == -1) { - if (e) free(e); - if (l) free(l); - if (j) free(j); - if (s) free(s); - NOMEM -} -if (e) free(e); -if (l) free(l); -if (j) free(j); -if (s) free(s); - -if (trio_asprintf(&user,EDG_WLL_FORMAT_USER, event->any.user) == -1) NOMEM - -/* format the rest of the logline */ -switch (eventcode) { -@@@{ -$indent = " "; -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t; - my $tl = lcfirst $t; - my $free = ""; - gen $indent."case EDG_WLL_EVENT_$tu :\n"; - gen "\t\{"; - selectType $event $t; -# if there are some _code_, convert them from string: - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - my $fnu = ucfirst $fn; - if ($f->{codes}) { - gen "\tchar \*$fn\_code = edg_wll\_$t${fnu}ToString(event->$tl.$fn);\n"; - $free = $free . "free($fn\_code); "; - } - if ($f->{type} eq 'jobid') { - gen "\tchar \*$fn\_str = edg_wlc_JobIdUnparse(event->$tl.$fn);\n"; - $free .= "free($fn\_str); "; - } - if ($f->{type} eq 'notifid') { - gen "\tchar \*$fn\_str = edg_wll_NotifIdUnparse(event->$tl.$fn);\n"; - $free .= "free($fn\_str); "; - } - if ($ULMasString{$f->{type}}) { - gen "\tchar \*$fn\_str = ".$f->getType()."ToString(event->$tl.$fn);\n"; - $free .= "free($fn\_str); "; - } - } - - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - - gen "\t\tif (!nonulls.$tl.$fn) nonulls.$tl.$fn = \"\";\n" - if $f->{type} eq 'string'; - } - gen "\tif (trio_asprintf(&var,EDG_WLL_FORMAT_$tu"; -# now format remaining parapteres for trio_asprintf: - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - if ($f->{codes}) { - gen ",$fn\_code"; - } - elsif ($f->{type} eq 'jobid' || $f->{type} eq 'notifid' || $ULMasString{$f->{type}}) { - gen ",$fn\_str?$fn\_str:\"\""; - } else { - gen ",nonulls.$tl.$fn"; - } - } - gen ") == -1 ) \{\n"; - gen "\t".$indent.$free."NOMEM \}\n"; - if ($free) { gen "\t$free\n"; } - gen "\t\}\n"; - gen $indent.$indent."break;\n"; -} -@@@} - case EDG_WLL_EVENT_UNDEF : - default : - break; -} - -/* put it all together (inc. the ending LF) */ -if (trio_asprintf(&logline,"%s%s%s\n",common,user,var) == -1) NOMEM - -clean: - if (date) free(date); - if (common) free(common); - if (user) free(user); - if (var) free(var); - return logline; -} - - -/** - * edg_wll_CheckEvent - check internal structures if all required fields are present - * Calls: free, sprintf, strcmp - * edg_wll_KeyNameToString, edg_wll_SetError (or edg_wll_ResetError) - * Algorithm: - */ -#define MISSING(m_key) { \ - char *k = edg_wll_KeyNameToString(m_key); \ - sprintf(err_desc,"Message incomplete, missing key %s.", k); \ - free(k); \ - ret=edg_wll_SetError(context,EDG_WLL_ERROR_PARSE_MSG_INCOMPLETE,err_desc); \ - goto end; } - -edg_wll_ErrorCode edg_wll_CheckEvent( - edg_wll_Context context, /* context IN */ - edg_wll_Event *event /* event IN */ -) -{ -char err_desc[128]; /* error description for use in edg_wll_SetError */ -edg_wll_EventCode eventcode=EDG_WLL_EVENT_UNDEF; -edg_wll_ErrorCode ret; - -eventcode=event->type; -if ( eventcode == EDG_WLL_EVENT_UNDEF ) { - ret=edg_wll_SetError(context,EDG_WLL_ERROR_PARSE_EVENT_UNDEF,"Unknown or missing event type"); - goto end; -} - -/* -FIXME: -? if (!event->any.user) MISSING(EDG_WLL_USER) - cannot use in edg_wll_LogEvent(), where is no DG.USER -*/ - -@@@{ - $indent = " "; - selectType $event '_common_'; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - next if $f->{optional}; - if (!$f->{codes}) { - if (!$f->hasAlias('ULM')) { - my $fu = uc $fn; - gen "\tif (". $f->isNULL("event->any.$fn") .") MISSING(EDG_WLL\_COMMON\_$fu)\n"; - } else { - my $fa = $f->getName('ULM'); - my $fu = uc $fa; - gen "\tif (". $f->isNULL("event->any.$fn") .") MISSING(ULM\_$fu)\n"; - } - } - } -@@@} - -switch (eventcode) { -@@@{ -$indent = " "; -for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - my $tu = uc $t; - my $tl = lcfirst $t; - gen $indent."case EDG_WLL_EVENT_$tu :\n"; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - next if $f->{optional}; - if (!$f->{codes}) { - my $fn = $f->{name}; - my $fu = uc $fn; - my $ft = $f->{type}; - gen "\tif (". $f->isNULL("event->$tl.$fn") .") MISSING(EDG_WLL\_$tu\_$fu)\n"; - } - } - gen $indent.$indent."break;\n"; -} -@@@} - - case EDG_WLL_EVENT_UNDEF : - default: - ret=edg_wll_SetError(context,EDG_WLL_ERROR_PARSE_EVENT_UNDEF,"Unknown or missing event type"); - goto end; - break; -}; -ret=edg_wll_ResetError(context); - -end: - return ret; -} - -/** - * edg_wll_CompareEvents - compare two event structures - * Calls: - * Algorithm: - */ -edg_wll_ErrorCode edg_wll_CompareEvents( - edg_wll_Context context, /* context IN */ - const edg_wll_Event *e1, /* event 1 IN */ - const edg_wll_Event *e2 /* event 2 IN */ -) -{ - if (e1->any.type != e2->any.type) return edg_wll_SetError(context,EDG_WLL_ERROR_COMPARE_EVENTS,"Different event types"); -@@@{ - selectType $event '_common_'; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = getName $f; - my $ft = $f->{type}; - - my $a = "e1->any.$fn"; - my $b = "e2->any.$fn"; - - gen "\tif (!(".eval($main::compare{C}->{$ft}).")) return edg_wll_SetError(context,EDG_WLL_ERROR_COMPARE_EVENTS,\"Different $fn\");\n"; - } - - gen "\tswitch(e1->any.type) {\n"; - for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) - { - my $tu = uc $t; - my $tl = lcfirst $t; - - selectType $event $t; - gen "\t\tcase EDG_WLL_EVENT\_$tu :\n"; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - my $ft = $f->{type}; - - my $a = "e1->$tl.$fn"; - my $b = "e2->$tl.$fn"; - - gen "\t\t\tif (!(".eval($main::compare{C}->{$ft}).")) return edg_wll_SetError(context,EDG_WLL_ERROR_COMPARE_EVENTS,\"Different $fn\");\n"; - } - gen "\t\tbreak;\n"; - } -@@@} - default: return edg_wll_SetError(context,EDG_WLL_ERROR_COMPARE_EVENTS,"Unknown difference"); - } /* switch */ - return edg_wll_ResetError(context); -} - - -/** - * my_edg_wll_ULMGetValueAt - get value at index, but also - * - remove surrounding quotes if any - * - and unescape the string - * - the new string will be allocated (by edg_wll_LogUnescape) - * Calls: edg_wll_ULMGetValueAt, edg_wll_LogUnescape, calloc and strncpy or strdup - */ -char *my_edg_wll_ULMGetValueAt( p_edg_wll_ULMFields table, int index ) -{ -char *str = edg_wll_ULMGetValueAt( table, index); -size_t len = strlen(str); -char *ret,*first,*last,*tmp; - -first = last = str; -last += len - 1; - -/* remove surrounding quotes */ -if ((*first == ULM_QM) && (*last == ULM_QM)) { - /* be careful with doppel_ULM_QM */ - if (len > 2) { - tmp = (char *) calloc (1,(len-1)*sizeof(char)); - strncpy(tmp,first+1,len-2); - tmp[len-2] = '\0'; - } - else { - tmp = strdup(""); - } -} -else tmp = strdup(str); - -if (len > 2) { - ret = edg_wll_LogUnescape(tmp); - if (tmp) free(tmp); -} -else ret = tmp; - -return ret; -} - - -/** - * edg_wll_GetJobId - parse jobId from ULM message - * Returns: edg_wlc_jobid_t string or NULL - * Calls: edg_wll_ULMNewParseTable, edg_wll_ULMFreeParseTable, edg_wll_ULMProcessParseTable, - * edg_wll_ULMGetNameAt, my_edg_wll_ULMGetValueAt, edg_wlc_jobid_tParse, strdup - * Algorithm: break ULM string into fields and then look for jobId - */ -char *edg_wll_GetJobId(edg_wll_LogLine logline) -{ -p_edg_wll_ULMFields table = edg_wll_ULMNewParseTable(logline); -int i; -char *ret=NULL,*fullid=NULL; -edg_wll_KeyNameCode keycode=UNDEFINED; -edg_wlc_JobId jobId = NULL; - -/* break ULM string into fields */ -if ( edg_wll_ULMProcessParseTable(table) != 0 ) goto clean; - -/* look for jobId */ -for (i=0; inum; i++) { - keycode=edg_wll_StringToKeyName(edg_wll_ULMGetNameAt(table,i)); - if ( keycode == EDG_WLL_COMMON_JOBID ) { fullid=my_edg_wll_ULMGetValueAt(table,i); break; } -} -if ( fullid == NULL ) goto clean; - -if (edg_wlc_JobIdParse(fullid, &jobId)) goto clean; - -ret = strdup(fullid); - -clean: - if (fullid) free(fullid); - if (jobId) edg_wlc_JobIdFree(jobId); - edg_wll_ULMFreeParseTable(table); - return ret; -} - -/** - * Parse a special Notification ULM line into a edg_wll_Event structure - * \param context IN: context to work with - * \param logline IN: ULM string to parse - * \param event OUT: parsed event - * (may be NULL - syntax checking with no output) - */ -edg_wll_ErrorCode edg_wll_ParseNotifEvent( - edg_wll_Context context, - edg_wll_LogLine logline, - edg_wll_Event ** event -) -{ -int i; -int extra=0; /* number of extra unknown key=value pairs */ -char err_desc[128]; /* error description for use in edg_wll_SetError */ -char *value=NULL; -p_edg_wll_ULMFields table = edg_wll_ULMNewParseTable(logline); -edg_wll_KeyNameCode keycode=UNDEFINED; -const edg_wll_EventCode eventcode=EDG_WLL_EVENT_NOTIFICATION; -edg_wll_ErrorCode ret; -edg_wll_Event *this=NULL; - -/* break ULM string into fields */ -if ( edg_wll_ULMProcessParseTable(table) != 0 ) { - ret=edg_wll_SetError(context,EDG_WLL_ERROR_PARSE_BROKEN_ULM,"ULM parse error"); - goto end; -} - -/* allocate memory for 'this' (edg_wll_Event) */ -this = edg_wll_InitEvent(eventcode); - -/* go through all fields and fill in the edg_wll_Event union - * in each step check for key duplicity and key name misuse - */ -for (i=0; inum; i++) { - keycode=edg_wll_StringToKeyName(edg_wll_ULMGetNameAt(table,i)); - value=my_edg_wll_ULMGetValueAt(table,i); - switch (keycode) { - case EDG_WLL_EVNT : - if (this->any.type != edg_wll_StringToEvent(value)) DUPLICITY - break; - case ULM_DATE : - if (!((this->any.timestamp).tv_sec == (null_timeval).tv_sec && (this->any.timestamp).tv_usec == (null_timeval).tv_usec)) DUPLICITY - edg_wll_ULMDateToTimeval(value,&this->any.timestamp); - break; - case ULM_ARR_DATE : - if (!((this->any.arrived).tv_sec == (null_timeval).tv_sec && (this->any.arrived).tv_usec == (null_timeval).tv_usec)) DUPLICITY - edg_wll_ULMDateToTimeval(value,&this->any.arrived); - break; - case ULM_HOST : - if (!(((this->any.host) == NULL && (NULL) == NULL) || ((this->any.host)&&(NULL)&& !strcmp(this->any.host,NULL)))) DUPLICITY - this->any.host = strdup(value); - break; - case ULM_LVL : - if (!((this->any.level == 0))) DUPLICITY - this->any.level = edg_wll_StringToLevel(value); - break; - case EDG_WLL_COMMON_SOURCE : - if (!((this->any.source) == (EDG_WLL_SOURCE_NONE))) DUPLICITY - this->any.source = edg_wll_StringToSource(value); - break; - case EDG_WLL_COMMON_SRC_INSTANCE : - if (!(((this->any.src_instance) == NULL && (NULL) == NULL) || ((this->any.src_instance)&&(NULL)&& !strcmp(this->any.src_instance,NULL)))) DUPLICITY - this->any.src_instance = strdup(value); - break; -@@@{ - $indent = " "; - my $t = 'Notification'; - my $tu = uc $t; - my $tl = lcfirst $t; - my $misuse = "if (eventcode != EDG_WLL_EVENT_$tu ) MISUSE"; - selectType $event $t; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - my $fnu = uc $fn; - gen $indent."case EDG_WLL\_$tu\_$fnu :\n"; - gen "\tif ("; - gen $f->isnotNULL("this->$tl.$fn"); - gen ") DUPLICITY\n"; - gen "\t$misuse\n"; - if ($f->{codes}) { - my $c = "$t".ucfirst(${fn}); - gen "\tthis->$tl.$fn = edg_wll_StringTo${c}(value);"; - } else { - gen "\t"; - gen $f->fromString('value',"this->$tl.$fn"); - } - gen "\n".$indent.$indent."break;\n"; - } -@@@} - - case UNDEFINED : - case EDG_WLL_INTERNAL_TYPE : - break; - - default : - extra++; - break; - } - free(value); - value=NULL; -} - -/* parse is OK, only extra fields could occur */ -if (extra) { - sprintf(err_desc,"There are %d extra fields in the logline.",extra); - ret=edg_wll_SetError(context,EDG_WLL_ERROR_PARSE_OK_WITH_EXTRA_FIELDS,err_desc); } -else { ret=edg_wll_ResetError(context); } - -end: - /* finally (if wanted) "return" pointer to the filled edg_wll_Event union - NOTE: a pointer (to half-filled structure) is returned even if an error occured ! */ - if (event != NULL) { - *event = this; } - /* This also means, that the memory must be freed by edg_wll_FreeEvent() somewhere else */ - else { - edg_wll_FreeEvent(this); - free(this); - } - - edg_wll_ULMFreeParseTable(table); - return ret; -} - -/** - * Generate a special Notification ULM line from edg_wll_Event structure - * \param context IN: context to work with - * \param event IN: event to unparse - */ -edg_wll_LogLine edg_wll_UnparseNotifEvent( - edg_wll_Context context, - edg_wll_Event * event -) -{ -edg_wll_LogLine logline; -char *date, *common, *var, *l, *s; -edg_wll_Event nonulls; - -logline = date = common = var = l = s = NULL; - -/* format the common fields */ -date=(char *) malloc(1+ULM_DATE_STRING_LENGTH*sizeof(char)); -edg_wll_ULMTimevalToDate(event->any.timestamp.tv_sec, event->any.timestamp.tv_usec, date); - -memcpy(&nonulls,event,sizeof nonulls); -if (!nonulls.any.host) nonulls.any.host = ""; -if (!nonulls.any.src_instance) nonulls.any.src_instance = ""; - -l = edg_wll_LevelToString(event->any.level); -s = edg_wll_SourceToString(event->any.source); -if (trio_asprintf(&common,EDG_WLL_FORMAT_NOTIFICATION_COMMON, \ - date, event->any.host, l, s, nonulls.any.src_instance) == -1) { - if (l) free(l); - if (s) free(s); - NOMEM - } -if (l) free(l); -if (s) free(s); - -// n = edg_wlc_NotifIdUnparse(event->notification.notifId); - -/* format the rest of the logline */ -@@@{ -$indent = " "; - my $t = 'Notification'; - my $tu = uc $t; - my $tl = lcfirst $t; - my $free = ""; -## gen $indent."case EDG_WLL_EVENT_$tu :\n"; - gen "\t\{"; - selectType $event $t; -# if there are some _code_, convert them from string: - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - my $fnu = ucfirst $fn; - if ($f->{codes}) { - gen "\tchar \*$fn\_code = edg_wll\_$t${fnu}ToString(event->$tl.$fn);\n"; - $free = $free . "free($fn\_code); "; - } - if ($f->{type} eq 'jobid') { - gen "\tchar \*$fn\_str = edg_wlc_JobIdUnparse(event->$tl.$fn);\n"; - $free .= "free($fn\_str); "; - } - if ($f->{type} eq 'notifid') { - gen "\tchar \*$fn\_str = edg_wll_NotifIdUnparse(event->$tl.$fn);\n"; - $free .= "free($fn\_str); "; - } - if ($ULMasString{$f->{type}}) { - gen "\tchar \*$fn\_str = ".$f->getType()."ToString(event->$tl.$fn);\n"; - $free .= "free($fn\_str); "; - } - } - - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - - gen "\t\tif (!nonulls.$tl.$fn) nonulls.$tl.$fn = \"\";\n" - if $f->{type} eq 'string'; - } - gen "\tif (trio_asprintf(&var,EDG_WLL_FORMAT_$tu"; -# now format remaining parapteres for trio_asprintf: - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - if ($f->{codes}) { - gen ",$fn\_code"; - } - elsif ($f->{type} eq 'jobid' || $f->{type} eq 'notifid' || $ULMasString{$f->{type}}) { - gen ",$fn\_str?$fn\_str:\"\""; - } else { - gen ",nonulls.$tl.$fn"; - } - } - gen ") == -1 ) \{\n"; - gen "\t".$indent.$free."NOMEM \}\n"; - if ($free) { gen "\t$free\n"; } - gen "\t\}\n"; -## gen $indent.$indent."break;\n"; -@@@} - -/* put it all together (inc. the ending LF) */ -if (trio_asprintf(&logline,"%s%s\n",common,var) == -1) NOMEM - -clean: - if (date) free(date); - if (common) free(common); - if (var) free(var); - return logline; -} - diff --git a/org.glite.lb.common/src/il_int.c b/org.glite.lb.common/src/il_int.c deleted file mode 100644 index 7d4bdf5..0000000 --- a/org.glite.lb.common/src/il_int.c +++ /dev/null @@ -1,69 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include - -#include "il_string.h" - -char * -_put_int(char *p, int d) -{ - char buf[32]; - int len; - - assert( p != NULL ); - - snprintf(buf, sizeof(buf), "%d", d); - len = strlen(buf); - strncpy(p, buf, len); - return(p + len); -} - - -char * -put_int(char *p, int d) -{ - assert( p != NULL ); - - p = _put_int(p, d); - *p++ = '\n'; - return(p); -} - - -char * -_get_int(char *p, int *d) -{ - char *end; - - assert( p != NULL ); - assert( d != NULL ); - - *d = strtol(p, &end, 10); - return(end); -} - - -char * -get_int(char *p, int *d) -{ - assert( p != NULL ); - assert( d != NULL ); - - p = _get_int(p, d); - if(*p != '\n') - return(NULL); - else - return(p + 1); -} - - -int -len_int(int d) -{ - char buffer[256]; - - return(put_int(buffer, d) - buffer); -} diff --git a/org.glite.lb.common/src/il_log.c b/org.glite.lb.common/src/il_log.c deleted file mode 100644 index 11170c5..0000000 --- a/org.glite.lb.common/src/il_log.c +++ /dev/null @@ -1,32 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include - -int log_level; - -int -il_log(int level, char *fmt, ...) -{ - char *err_text; - va_list fmt_args; - - va_start(fmt_args, fmt); - vasprintf(&err_text, fmt, fmt_args); - va_end(fmt_args); - - if(level <= log_level) - fprintf(stderr, err_text); - - if(level <= LOG_ERR) { - openlog("edg-wl-interlogd", LOG_PID | LOG_CONS, LOG_DAEMON); - syslog(level, "%s", err_text); - closelog(); - } - - if(err_text) free(err_text); - - return(0); -} diff --git a/org.glite.lb.common/src/il_msg.c b/org.glite.lb.common/src/il_msg.c deleted file mode 100644 index 30997f6..0000000 --- a/org.glite.lb.common/src/il_msg.c +++ /dev/null @@ -1,53 +0,0 @@ -#ident "$Header$" - -#include "il_string.h" - -#include -#include -#include - -int -receive_msg(int sd, char **ucs, char **event) -{ - char buffer[17]; - char *p, *q, *msg; - int len; - - len = read(sd, buffer, 17); - - if(buffer[16] != '\n') { - printf("Error in header!\n"); - goto err; - } - - sscanf(buffer, "%d", &len); - if(len > MAXLEN) { - printf("Message too long!\n"); - goto err; - } - p = msg = malloc(len+1); - if(p == NULL) { - printf("Error allocating %d bytes\n", len+1); - goto err; - } - - read(sd, p, len); - p[len] = 0; - - if((q = get_string(p, ucs)) == NULL) { - printf("Protocol error at %s\n", p); - goto err; - } - p = q; - if((q = get_string(p, event)) == NULL) { - printf("Protocol error at %s\n", p); - goto err; - } - - free(msg); - return(0); - - err: - - return(-1); -} diff --git a/org.glite.lb.common/src/il_string.c b/org.glite.lb.common/src/il_string.c deleted file mode 100644 index 2c4034d..0000000 --- a/org.glite.lb.common/src/il_string.c +++ /dev/null @@ -1,61 +0,0 @@ -#ident "$Header$" - -#include -#include -#include - -#include "il_string.h" - -char * -put_string(char *p, char *s) -{ - int len = strlen(s); - - assert( p != NULL ); - - p = _put_int(p, len); - *p++ = ' '; - strncpy(p, s, len); - p += len; - *p++ = '\n'; - return(p); -} - - -int -len_string(char *s) -{ - int len, slen; - - assert( s != NULL ); - - slen = strlen(s); - len = len_int(slen); - - return(len + slen + 1); -} - - -char * -get_string(char *p, char **s) -{ - int len; - - assert( p != NULL ); - - *s = NULL; - - p = _get_int(p, &len); - if(*p != ' ') - return(NULL); - else - { - *s = malloc(len + 1); - if(*s == NULL) - return(NULL); - strncpy(*s, ++p, len); - (*s)[len] = '\0'; - p += len; - return( *p++ == '\n' ? p : NULL ); - } -} diff --git a/org.glite.lb.common/src/lb_gss.c b/org.glite.lb.common/src/lb_gss.c deleted file mode 100644 index a9de75f..0000000 --- a/org.glite.lb.common/src/lb_gss.c +++ /dev/null @@ -1,981 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "lb_gss.h" - -#define tv_sub(a,b) {\ - (a).tv_usec -= (b).tv_usec;\ - (a).tv_sec -= (b).tv_sec;\ - if ((a).tv_usec < 0) {\ - (a).tv_sec--;\ - (a).tv_usec += 1000000;\ - }\ -} - -struct asyn_result { - struct hostent *ent; - int err; -}; - -static int decrement_timeout(struct timeval *timeout, struct timeval before, struct timeval after) -{ - (*timeout).tv_sec = (*timeout).tv_sec - (after.tv_sec - before.tv_sec); - (*timeout).tv_usec = (*timeout).tv_usec - (after.tv_usec - before.tv_usec); - while ( (*timeout).tv_usec < 0) { - (*timeout).tv_sec--; - (*timeout).tv_usec += 1000000; - } - if ( ((*timeout).tv_sec < 0) || (((*timeout).tv_sec == 0) && ((*timeout).tv_usec == 0)) ) return(1); - else return(0); -} - -/* ares callback handler for ares_gethostbyname() */ -static void callback_handler(void *arg, int status, struct hostent *h) { - struct asyn_result *arp = (struct asyn_result *) arg; - - switch (status) { - case ARES_SUCCESS: - if (h && h->h_addr_list[0]) { - arp->ent->h_addr_list = - (char **) malloc(2 * sizeof(char *)); - if (arp->ent->h_addr_list == NULL) { - arp->err = NETDB_INTERNAL; - break; - } - arp->ent->h_addr_list[0] = - malloc(sizeof(struct in_addr)); - if (arp->ent->h_addr_list[0] == NULL) { - free(arp->ent->h_addr_list); - arp->err = NETDB_INTERNAL; - break; - } - memcpy(arp->ent->h_addr_list[0], h->h_addr_list[0], - sizeof(struct in_addr)); - arp->ent->h_addr_list[1] = NULL; - arp->err = NETDB_SUCCESS; - } else { - arp->err = NO_DATA; - } - break; - case ARES_EBADNAME: - case ARES_ENOTFOUND: - arp->err = HOST_NOT_FOUND; - break; - case ARES_ENOTIMP: - arp->err = NO_RECOVERY; - break; - case ARES_ENOMEM: - case ARES_EDESTRUCTION: - default: - arp->err = NETDB_INTERNAL; - break; - } -} - -static void free_hostent(struct hostent *h){ - int i; - - if (h) { - if (h->h_name) free(h->h_name); - if (h->h_aliases) { - for (i=0; h->h_aliases[i]; i++) free(h->h_aliases[i]); - free(h->h_aliases); - } - if (h->h_addr_list) { - for (i=0; h->h_addr_list[i]; i++) free(h->h_addr_list[i]); - free(h->h_addr_list); - } - free(h); - } -} - -static int asyn_gethostbyname(char **addrOut, char const *name, struct timeval *timeout) { - struct asyn_result ar; - ares_channel channel; - int nfds; - fd_set readers, writers; - struct timeval tv, *tvp; - struct timeval start_time,check_time; - -/* start timer */ - gettimeofday(&start_time,0); - -/* ares init */ - if ( ares_init(&channel) != ARES_SUCCESS ) return(NETDB_INTERNAL); - ar.ent = (struct hostent *) calloc (sizeof(*ar.ent),1); - -/* query DNS server asynchronously */ - ares_gethostbyname(channel, name, AF_INET, callback_handler, - (void *) &ar); - -/* wait for result */ - while (1) { - FD_ZERO(&readers); - FD_ZERO(&writers); - nfds = ares_fds(channel, &readers, &writers); - if (nfds == 0) - break; - - gettimeofday(&check_time,0); - if (decrement_timeout(timeout, start_time, check_time)) { - ares_destroy(channel); - free_hostent(ar.ent); - return(TRY_AGAIN); - } - start_time = check_time; - - tvp = ares_timeout(channel, timeout, &tv); - - switch ( select(nfds, &readers, &writers, NULL, tvp) ) { - case -1: if (errno != EINTR) { - ares_destroy(channel); - free_hostent(ar.ent); - return NETDB_INTERNAL; - } else - continue; - case 0: - FD_ZERO(&readers); - FD_ZERO(&writers); - /* fallthrough */ - default: ares_process(channel, &readers, &writers); - } - } - - ares_destroy(channel); - - if (ar.err == NETDB_SUCCESS) { - *addrOut = malloc(sizeof(struct in_addr)); - memcpy(*addrOut,ar.ent->h_addr_list[0], sizeof(struct in_addr)); - free_hostent(ar.ent); - } - return(ar.err); -} - -static int -do_connect(int *s, char const *hostname, int port, struct timeval *timeout) -{ - int sock; - struct timeval before,after,to; - struct sockaddr_in a; - int sock_err; - socklen_t err_len; - char *addr; - int h_errno; - - sock = socket(AF_INET, SOCK_STREAM, 0); - if (sock < 0) return EDG_WLL_GSS_ERROR_ERRNO; - - if (timeout) { - int flags = fcntl(sock, F_GETFL, 0); - if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) - return EDG_WLL_GSS_ERROR_ERRNO; - gettimeofday(&before,NULL); - } - - if (timeout) { - switch (h_errno = asyn_gethostbyname(&addr, hostname, timeout)) { - case NETDB_SUCCESS: - memset(&a,0,sizeof a); - a.sin_family = AF_INET; - memcpy(&a.sin_addr.s_addr,addr,sizeof a.sin_addr.s_addr); - a.sin_port = htons(port); - free(addr); - break; - case TRY_AGAIN: - close(sock); - return EDG_WLL_GSS_ERROR_TIMEOUT; - case NETDB_INTERNAL: - /* fall through */ - default: - close(sock); - /* h_errno may be thread safe with Linux pthread libs, - * but such an assumption is not portable - */ - errno = h_errno; - return EDG_WLL_GSS_ERROR_HERRNO; - } - } else { - struct hostent *hp; - - hp = gethostbyname(hostname); - if (hp == NULL) { - close(sock); - errno = h_errno; - return EDG_WLL_GSS_ERROR_HERRNO; - } - - memset(&a,0,sizeof a); - a.sin_family = AF_INET; - memcpy(&a.sin_addr.s_addr, hp->h_addr_list[0], sizeof(a.sin_addr.s_addr)); - a.sin_port = htons(port); - } - - if (connect(sock,(struct sockaddr *) &a,sizeof a) < 0) { - if (timeout && errno == EINPROGRESS) { - fd_set fds; - FD_ZERO(&fds); - FD_SET(sock,&fds); - memcpy(&to,timeout,sizeof to); - gettimeofday(&before,NULL); - switch (select(sock+1,NULL,&fds,NULL,&to)) { - case -1: close(sock); - return EDG_WLL_GSS_ERROR_ERRNO; - case 0: close(sock); - return EDG_WLL_GSS_ERROR_TIMEOUT; - } - gettimeofday(&after,NULL); - tv_sub(after,before); - tv_sub(*timeout,after); - - err_len = sizeof sock_err; - if (getsockopt(sock,SOL_SOCKET,SO_ERROR,&sock_err,&err_len)) { - close(sock); - return EDG_WLL_GSS_ERROR_ERRNO; - } - if (sock_err) { - close(sock); - errno = sock_err; - return EDG_WLL_GSS_ERROR_ERRNO; - } - } - else { - close(sock); - return EDG_WLL_GSS_ERROR_ERRNO; - } - } - - *s = sock; - return 0; -} - -static int -send_token(int sock, void *token, size_t token_length, struct timeval *to) -{ - size_t num_written = 0; - ssize_t count; - fd_set fds; - struct timeval timeout,before,after; - int ret; - - if (to) { - memcpy(&timeout,to,sizeof(timeout)); - gettimeofday(&before,NULL); - } - - - ret = 0; - while(num_written < token_length) { - FD_ZERO(&fds); - FD_SET(sock,&fds); - switch (select(sock+1, NULL, &fds, NULL, to ? &timeout : NULL)) { - case 0: ret = EDG_WLL_GSS_ERROR_TIMEOUT; - goto end; - break; - case -1: ret = EDG_WLL_GSS_ERROR_ERRNO; - goto end; - break; - } - - count = write(sock, ((char *)token) + num_written, - token_length - num_written); - if(count < 0) { - if(errno == EINTR) - continue; - else { - ret = EDG_WLL_GSS_ERROR_ERRNO; - goto end; - } - } - num_written += count; - } - -end: - if (to) { - gettimeofday(&after,NULL); - tv_sub(after,before); - tv_sub(*to,after); - if (to->tv_sec < 0) { - to->tv_sec = 0; - to->tv_usec = 0; - } - } - - return ret; -} - -static int -recv_token(int sock, void **token, size_t *token_length, struct timeval *to) -{ - ssize_t count; - char buf[4098]; - char *t = NULL; - char *tmp; - size_t tl = 0; - fd_set fds; - struct timeval timeout,before,after; - int ret; - - if (to) { - memcpy(&timeout,to,sizeof(timeout)); - gettimeofday(&before,NULL); - } - - ret = 0; - do { - FD_ZERO(&fds); - FD_SET(sock,&fds); - switch (select(sock+1, &fds, NULL, NULL, to ? &timeout : NULL)) { - case 0: - ret = EDG_WLL_GSS_ERROR_TIMEOUT; - goto end; - break; - case -1: - ret = EDG_WLL_GSS_ERROR_ERRNO; - goto end; - break; - } - - count = read(sock, buf, sizeof(buf)); - if (count < 0) { - if (errno == EINTR) - continue; - else { - ret = EDG_WLL_GSS_ERROR_ERRNO; - goto end; - } - } - if (count == 0 && tl == 0 && errno == 0) - return EDG_WLL_GSS_ERROR_EOF; - tmp=realloc(t, tl + count); - if (tmp == NULL) { - errno = ENOMEM; - return EDG_WLL_GSS_ERROR_ERRNO; - } - t = tmp; - memcpy(t + tl, buf, count); - tl += count; - } while (count == sizeof(buf)); - -end: - if (to) { - gettimeofday(&after,NULL); - tv_sub(after,before); - tv_sub(*to,after); - if (to->tv_sec < 0) { - to->tv_sec = 0; - to->tv_usec = 0; - } - } - - if (ret == 0) { - *token = t; - *token_length = tl; - } else - free(t); - - return ret; -} - -static int -create_proxy(char *cert_file, char *key_file, char **proxy_file) -{ - char buf[4096]; - int in, out; - char *name = NULL; - int ret, len; - - *proxy_file = NULL; - - asprintf(&name, "%s/%d.lb.XXXXXX", P_tmpdir, getpid()); - - out = mkstemp(name); - if (out < 0) - return EDG_WLL_GSS_ERROR_ERRNO; - - in = open(cert_file, O_RDONLY); - if (in < 0) { - ret = EDG_WLL_GSS_ERROR_ERRNO; - goto end; - } - while ((ret = read(in, buf, sizeof(buf))) > 0) { - len = write(out, buf, ret); - if (len != ret) { - ret = -1; - break; - } - } - close(in); - if (ret < 0) { - ret = EDG_WLL_GSS_ERROR_ERRNO; - goto end; - } - - in = open(key_file, O_RDONLY); - if (in < 0) { - ret = EDG_WLL_GSS_ERROR_ERRNO; - goto end; - } - while ((ret = read(in, buf, sizeof(buf))) > 0) { - len = write(out, buf, ret); - if (len != ret) { - ret = -1; - break; - } - } - close(in); - if (ret < 0) { - ret = EDG_WLL_GSS_ERROR_ERRNO; - goto end; - } - - ret = 0; - *proxy_file = name; - -end: - close(out); - if (ret) { - unlink(name); - free(name); - } - - return ret; -} - -static int -destroy_proxy(char *proxy_file) -{ - /* XXX we should erase the contents safely (i.e. overwrite with 0's) */ - unlink(proxy_file); - return 0; -} - -int -edg_wll_gss_acquire_cred_gsi(char *cert_file, char *key_file, gss_cred_id_t *cred, - char **name, edg_wll_GssStatus* gss_code) -{ - OM_uint32 major_status = 0, minor_status, minor_status2; - gss_cred_id_t gss_cred = GSS_C_NO_CREDENTIAL; - gss_buffer_desc buffer = GSS_C_EMPTY_BUFFER; - gss_name_t gss_name = GSS_C_NO_NAME; - OM_uint32 lifetime; - char *proxy_file = NULL; - int ret; - - if ((cert_file == NULL && key_file != NULL) || - (cert_file != NULL && key_file == NULL)) - return EINVAL; - - if (cert_file == NULL) { - major_status = gss_acquire_cred(&minor_status, GSS_C_NO_NAME, 0, - GSS_C_NO_OID_SET, GSS_C_BOTH, - &gss_cred, NULL, NULL); - if (GSS_ERROR(major_status)) { - ret = EDG_WLL_GSS_ERROR_GSS; - goto end; - } - } else { - proxy_file = cert_file; - if (strcmp(cert_file, key_file) != 0 && - (ret = create_proxy(cert_file, key_file, &proxy_file))) { - proxy_file = NULL; - goto end; - } - - asprintf((char**)&buffer.value, "X509_USER_PROXY=%s", proxy_file); - if (buffer.value == NULL) { - errno = ENOMEM; - ret = EDG_WLL_GSS_ERROR_ERRNO; - goto end; - } - buffer.length = strlen(proxy_file); - - major_status = gss_import_cred(&minor_status, &gss_cred, GSS_C_NO_OID, 1, - &buffer, 0, NULL); - free(buffer.value); - if (GSS_ERROR(major_status)) { - ret = EDG_WLL_GSS_ERROR_GSS; - goto end; - } - } - - /* gss_import_cred() doesn't check validity of credential loaded, so let's - * verify it now */ - major_status = gss_inquire_cred(&minor_status, gss_cred, &gss_name, - &lifetime, NULL, NULL); - if (GSS_ERROR(major_status)) { - ret = EDG_WLL_GSS_ERROR_GSS; - goto end; - } - - /* Must cast to time_t since OM_uint32 is unsinged and hence we couldn't - * detect negative values. */ - if ((time_t) lifetime <= 0) { - major_status = GSS_S_CREDENTIALS_EXPIRED; - minor_status = 0; /* XXX */ - ret = EDG_WLL_GSS_ERROR_GSS; - goto end; - } - - if (name) { - major_status = gss_display_name(&minor_status, gss_name, &buffer, NULL); - if (GSS_ERROR(major_status)) { - ret = EDG_WLL_GSS_ERROR_GSS; - goto end; - } - *name = buffer.value; - memset(&buffer, 0, sizeof(buffer)); - } - - *cred = gss_cred; - gss_cred = GSS_C_NO_CREDENTIAL; - ret = 0; - -end: - if (cert_file && key_file && proxy_file && strcmp(cert_file, key_file) != 0) { - destroy_proxy(proxy_file); - free(proxy_file); - } - - if (gss_name != GSS_C_NO_NAME) - gss_release_name(&minor_status2, &gss_name); - - if (gss_cred != GSS_C_NO_CREDENTIAL) - gss_release_cred(&minor_status2, &gss_cred); - - if (GSS_ERROR(major_status)) { - if (gss_code) { - gss_code->major_status = major_status; - gss_code->minor_status = minor_status; - } - ret = EDG_WLL_GSS_ERROR_GSS; - } - - return ret; -} - -int -edg_wll_gss_connect(gss_cred_id_t cred, char const *hostname, int port, - struct timeval *timeout, edg_wll_GssConnection *connection, - edg_wll_GssStatus* gss_code) -{ - int sock, ret; - OM_uint32 maj_stat, min_stat, min_stat2, req_flags; - int context_established = 0; - gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER; - gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; - gss_name_t server = GSS_C_NO_NAME; - gss_ctx_id_t context = GSS_C_NO_CONTEXT; - char *servername = NULL; - - maj_stat = min_stat = min_stat2 = req_flags = 0; - - /* GSI specific */ - req_flags = GSS_C_GLOBUS_SSL_COMPATIBLE; - - ret = do_connect(&sock, hostname, port, timeout); - if (ret) - return ret; - - /* XXX find appropriate fqdn */ - asprintf (&servername, "host@%s", hostname); - if (servername == NULL) { - errno = ENOMEM; - ret = EDG_WLL_GSS_ERROR_ERRNO; - goto end; - } - input_token.value = servername; - input_token.length = strlen(servername) + 1; - - maj_stat = gss_import_name(&min_stat, &input_token, - GSS_C_NT_HOSTBASED_SERVICE, &server); - if (GSS_ERROR(maj_stat)) { - ret = EDG_WLL_GSS_ERROR_GSS; - goto end; - } - - free(servername); - memset(&input_token, 0, sizeof(input_token)); - - /* XXX if cred == GSS_C_NO_CREDENTIAL set the ANONYMOUS flag */ - - /* XXX prepsat na do {} while (maj_stat == CONT) a osetrit chyby*/ - while (!context_established) { - /* XXX verify ret_flags match what was requested */ - maj_stat = gss_init_sec_context(&min_stat, cred, &context, - GSS_C_NO_NAME, GSS_C_NO_OID, - req_flags | GSS_C_MUTUAL_FLAG, - 0, GSS_C_NO_CHANNEL_BINDINGS, - &input_token, NULL, &output_token, - NULL, NULL); - if (input_token.length > 0) { - free(input_token.value); - input_token.length = 0; - } - - if (output_token.length != 0) { - ret = send_token(sock, output_token.value, output_token.length, timeout); - gss_release_buffer(&min_stat2, &output_token); - if (ret) - goto end; - } - - if (GSS_ERROR(maj_stat)) { - if (context != GSS_C_NO_CONTEXT) { - /* XXX send closing token to the friend */ - gss_delete_sec_context(&min_stat2, &context, GSS_C_NO_BUFFER); - context = GSS_C_NO_CONTEXT; - } - ret = EDG_WLL_GSS_ERROR_GSS; - goto end; - } - - if(maj_stat & GSS_S_CONTINUE_NEEDED) { - ret = recv_token(sock, &input_token.value, &input_token.length, timeout); - if (ret) - goto end; - } else - context_established = 1; - } - - /* XXX check ret_flags matches to what was requested */ - - memset(connection, 0, sizeof(*connection)); - connection->sock = sock; - connection->context = context; - servername = NULL; - ret = 0; - -end: - if (ret == EDG_WLL_GSS_ERROR_GSS && gss_code) { - gss_code->major_status = maj_stat; - gss_code->minor_status = min_stat; - } - if (server != GSS_C_NO_NAME) - gss_release_name(&min_stat2, &server); - if (servername == NULL) - free(servername); - if (ret) - close(sock); - - return ret; -} - -int -edg_wll_gss_accept(gss_cred_id_t cred, int sock, struct timeval *timeout, - edg_wll_GssConnection *connection, edg_wll_GssStatus* gss_code) -{ - OM_uint32 maj_stat, min_stat, min_stat2; - OM_uint32 ret_flags = 0; - gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER; - gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; - gss_name_t client_name = GSS_C_NO_NAME; - gss_ctx_id_t context = GSS_C_NO_CONTEXT; - int ret; - - maj_stat = min_stat = min_stat2 = 0; - - /* GSI specific */ - ret_flags = GSS_C_GLOBUS_SSL_COMPATIBLE; - - do { - ret = recv_token(sock, &input_token.value, &input_token.length, timeout); - if (ret) - goto end; - - maj_stat = gss_accept_sec_context(&min_stat, &context, - cred, &input_token, - GSS_C_NO_CHANNEL_BINDINGS, - &client_name, NULL, &output_token, - &ret_flags, NULL, NULL); - if (input_token.length > 0) { - free(input_token.value); - input_token.length = 0; - } - - if (output_token.length) { - ret = send_token(sock, output_token.value, output_token.length, timeout); - gss_release_buffer(&min_stat2, &output_token); - if (ret) - goto end; - } - } while(maj_stat & GSS_S_CONTINUE_NEEDED); - - if (GSS_ERROR(maj_stat)) { - if (context != GSS_C_NO_CONTEXT) { - /* XXX send closing token to the friend */ - gss_delete_sec_context(&min_stat2, &context, GSS_C_NO_BUFFER); - context = GSS_C_NO_CONTEXT; - } - ret = EDG_WLL_GSS_ERROR_GSS; - goto end; - } - - maj_stat = gss_display_name(&min_stat, client_name, &output_token, NULL); - if (GSS_ERROR(maj_stat)) { - /* XXX close context ??? */ - ret = EDG_WLL_GSS_ERROR_GSS; - goto end; - } - - memset(connection, 0, sizeof(*connection)); - connection->sock = sock; - connection->context = context; - memset(&output_token, 0, sizeof(output_token.value)); - ret = 0; - -end: - if (ret == EDG_WLL_GSS_ERROR_GSS && gss_code) { - gss_code->major_status = maj_stat; - gss_code->minor_status = min_stat; - } - if (client_name != GSS_C_NO_NAME) - gss_release_name(&min_stat2, &client_name); - - return ret; -} - -int -edg_wll_gss_write(edg_wll_GssConnection *connection, const void *buf, size_t bufsize, - struct timeval *timeout, edg_wll_GssStatus* gss_code) -{ - OM_uint32 maj_stat, min_stat; - gss_buffer_desc input_token; - gss_buffer_desc output_token; - int ret; - - input_token.value = (void*)buf; - input_token.length = bufsize; - - maj_stat = gss_wrap (&min_stat, connection->context, 0, GSS_C_QOP_DEFAULT, - &input_token, NULL, &output_token); - if (GSS_ERROR(maj_stat)) { - if (gss_code) { - gss_code->minor_status = min_stat; - gss_code->major_status = maj_stat; - } - - return EDG_WLL_GSS_ERROR_GSS; - } - - ret = send_token(connection->sock, output_token.value, output_token.length, - timeout); - gss_release_buffer(&min_stat, &output_token); - - return ret; -} - - -int -edg_wll_gss_read(edg_wll_GssConnection *connection, void *buf, size_t bufsize, - struct timeval *timeout, edg_wll_GssStatus* gss_code) -{ - OM_uint32 maj_stat, min_stat; - gss_buffer_desc input_token; - gss_buffer_desc output_token; - int ret, i; - - if (connection->bufsize > 0) { - size_t len; - - len = (connection->bufsize < bufsize) ? connection->bufsize : bufsize; - memcpy(buf, connection->buffer, len); - connection->bufsize -= len; - if (connection->bufsize > 0) { - for (i = 0; i < sizeof(connection->buffer) - len; i++) - connection->buffer[i] = connection->buffer[i+len]; - } - - return len; - } - - do { - ret = recv_token(connection->sock, &input_token.value, &input_token.length, - timeout); - if (ret) - /* XXX cleanup */ - return ret; - - maj_stat = gss_unwrap(&min_stat, connection->context, &input_token, - &output_token, NULL, NULL); - if (GSS_ERROR(maj_stat)) { - /* XXX cleanup */ - return EDG_WLL_GSS_ERROR_GSS; - } - } while (maj_stat == 0 && output_token.length == 0 && output_token.value == NULL); - - if (output_token.length > bufsize) { - if (output_token.length - bufsize > sizeof(connection->buffer)) - return EINVAL; - connection->bufsize = output_token.length - bufsize; - memcpy(connection->buffer, output_token.value + bufsize, connection->bufsize); - output_token.length = bufsize; - } - memcpy(buf, output_token.value, output_token.length); - - return output_token.length; -} - -int -edg_wll_gss_read_full(edg_wll_GssConnection *connection, void *buf, - size_t bufsize, struct timeval *timeout, size_t *total, - edg_wll_GssStatus* gss_code) -{ - int len,i; - *total = 0; - - if (connection->bufsize > 0) { - size_t len; - - - len = (connection->bufsize < bufsize) ? connection->bufsize : bufsize; - memcpy(buf, connection->buffer, len); - connection->bufsize -= len; - if (connection->bufsize > 0) { - for (i = 0; i < sizeof(connection->buffer) - len; i++) - connection->buffer[i] = connection->buffer[i+len]; - } - *total = len; - } - - while (*total < bufsize) { - len = edg_wll_gss_read(connection, buf+*total, bufsize-*total, - timeout, gss_code); - if (len < 0) return len; - *total += len; - } - - return 0; -} - -int -edg_wll_gss_write_full(edg_wll_GssConnection *connection, const void *buf, - size_t bufsize, struct timeval *timeout, size_t *total, - edg_wll_GssStatus* gss_code) -{ - return edg_wll_gss_write(connection, buf, bufsize, timeout, gss_code); -} - -/* XXX: I'm afraid the contents of stuct stat is somewhat OS dependent */ -int -edg_wll_gss_watch_creds(const char *proxy_file, time_t *proxy_mtime) -{ - struct stat pstat; - int reload = 0; - - if (!proxy_file) return 0; - if (stat(proxy_file,&pstat)) return -1; - - if (!*proxy_mtime) *proxy_mtime = pstat.st_mtime; - - if (*proxy_mtime != pstat.st_mtime) { - *proxy_mtime = pstat.st_mtime; - reload = 1; - } - - return reload; -} - -int -edg_wll_gss_close(edg_wll_GssConnection *con, struct timeval *timeout) -{ - OM_uint32 min_stat; - - /* XXX if timeout is NULL use value of 120 secs */ - - if (con->context != GSS_C_NO_CONTEXT) { - gss_delete_sec_context(&min_stat, &con->context, GSS_C_NO_BUFFER); - /* XXX send the buffer (if any) to the peer. GSSAPI specs doesn't - * recommend sending it, though */ - - /* XXX can socket be open even if context == GSS_C_NO_CONTEXT) ? */ - /* XXX ensure that edg_wll_GssConnection is created with sock set to -1 */ - if (con->sock >= 0) - close(con->sock); - } - memset(con, 0, sizeof(*con)); - con->context = GSS_C_NO_CONTEXT; - con->sock = -1; - return 0; -} - -int -edg_wll_gss_get_error(edg_wll_GssStatus *gss_err, const char *prefix, char **msg) -{ - OM_uint32 maj_stat, min_stat; - OM_uint32 msg_ctx = 0; - gss_buffer_desc maj_status_string = GSS_C_EMPTY_BUFFER; - gss_buffer_desc min_status_string = GSS_C_EMPTY_BUFFER; - char *str = NULL; - char *line, *tmp; - - str = strdup(prefix); - do { - maj_stat = gss_display_status(&min_stat, gss_err->major_status, - GSS_C_GSS_CODE, GSS_C_NO_OID, - &msg_ctx, &maj_status_string); - if (GSS_ERROR(maj_stat)) - break; - - maj_stat = gss_display_status(&min_stat, gss_err->minor_status, - GSS_C_MECH_CODE, GSS_C_NULL_OID, - &msg_ctx, &min_status_string); - if (GSS_ERROR(maj_stat)) { - gss_release_buffer(&min_stat, &maj_status_string); - break; - } - - asprintf(&line, ": %s (%s)", (char *)maj_status_string.value, - (char *)min_status_string.value); - gss_release_buffer(&min_stat, &maj_status_string); - gss_release_buffer(&min_stat, &min_status_string); - - tmp = realloc(str, strlen(str) + strlen(line) + 1); - if (tmp == NULL) { - /* abort() ? */ - free(line); - free(str); - str = "WARNING: Not enough memory to produce error message"; - break; - } - str = tmp; - strcat(str, line); - free(line); - } while (!GSS_ERROR(maj_stat) && msg_ctx != 0); - - *msg = str; - return 0; -} - -int -edg_wll_gss_oid_equal(const gss_OID a, const gss_OID b) -{ - if (a == b) - return 1; - else { - if (a == GSS_C_NO_OID || b == GSS_C_NO_OID || a->length != b->length) - return 0; - else - return (memcmp(a->elements, b->elements, a->length) == 0); - } -} - -int -edg_wll_gss_reject(int sock) -{ - /* XXX is it possible to cut & paste edg_wll_ssl_reject() ? */ - return 0; -} diff --git a/org.glite.lb.common/src/lb_plain_io.c b/org.glite.lb.common/src/lb_plain_io.c deleted file mode 100644 index f197c9b..0000000 --- a/org.glite.lb.common/src/lb_plain_io.c +++ /dev/null @@ -1,208 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "lb_plain_io.h" - -#define tv_sub(a,b) {\ - (a).tv_usec -= (b).tv_usec;\ - (a).tv_sec -= (b).tv_sec;\ - if ((a).tv_usec < 0) {\ - (a).tv_sec--;\ - (a).tv_usec += 1000000;\ - }\ -} - -#define bufshift(conn, shift) { \ - memmove((conn)->buf, (conn)->buf+(shift), (conn)->bufUse-(shift)); \ - (conn)->bufUse -= (shift); \ -} - -int edg_wll_plain_connect( - char const *hostname, - int port, - struct timeval *to, - edg_wll_PlainConnection *conn) -{ - return 0; -} - -int edg_wll_plain_accept( - int sock, - edg_wll_PlainConnection *conn) -{ - /* Do not free the buffer here - just reuse the memmory - */ - conn->bufUse = 0; - conn->sock = sock; - return 0; -} - -int edg_wll_plain_close(edg_wll_PlainConnection *conn) -{ - errno = 0; - if ( conn->buf ) free(conn->buf); - if ( conn->sock > -1 ) close(conn->sock); - memset(conn, 0, sizeof(*conn)); - conn->sock = -1; - - return errno? -1: 0; -} - -int edg_wll_plain_read( - edg_wll_PlainConnection *conn, - void *outbuf, - size_t outbufsz, - struct timeval *to) -{ - int ct, toread = 0; - fd_set fds; - struct timeval timeout, before, after; - - - if ( conn->bufSize == 0 ) { - if ( !(conn->buf = malloc(BUFSIZ)) ) return -1; - conn->bufSize = BUFSIZ; - conn->bufUse = 0; - } - - if ( to ) { - memcpy(&timeout, to, sizeof(timeout)); - gettimeofday(&before, NULL); - } - - errno = 0; - - if ( conn->bufUse > 0 ) goto cleanup; - - toread = 0; - do { - FD_ZERO(&fds); - FD_SET(conn->sock, &fds); - switch (select(conn->sock+1, &fds, NULL, NULL, to ? &timeout : NULL)) { - case 0: errno = ETIMEDOUT; goto cleanup; break; - case -1: goto cleanup; break; - } - - if ( conn->bufUse == conn->bufSize ) { - char *tmp = realloc(conn->buf, conn->bufSize+BUFSIZ); - if ( !tmp ) return -1; - conn->buf = tmp; - conn->bufSize += BUFSIZ; - } - toread = conn->bufSize - conn->bufUse; - if ( (ct = read(conn->sock, conn->buf+conn->bufUse, toread)) < 0 ) { - if ( errno == EINTR ) continue; - goto cleanup; - } - - if ( ct == 0 && conn->bufUse == 0 && errno == 0 ) { - errno = ENOTCONN; - goto cleanup; - } - - conn->bufUse += ct; - } while ( ct == toread ); - - -cleanup: - if ( to ) { - gettimeofday(&after, NULL); - tv_sub(after, before); - tv_sub(*to, after); - if ( to->tv_sec < 0 ) to->tv_sec = to->tv_usec = 0; - } - - if ( errno ) return -1; - - if ( conn->bufUse > 0 ) { - size_t len = (conn->bufUse < outbufsz) ? conn->bufUse : outbufsz; - memcpy(outbuf, conn->buf, len); - outbufsz = len; - bufshift(conn, len); - return len; - } - - return 0; -} - - -int edg_wll_plain_read_full( - edg_wll_PlainConnection *conn, - void *outbuf, - size_t outbufsz, - struct timeval *to) -{ - size_t total = 0; - - - if ( conn->bufUse > 0 ) { - size_t len = (conn->bufUse < outbufsz) ? conn->bufUse : outbufsz; - memcpy(outbuf, conn->buf, len); - outbufsz = len; - bufshift(conn, len); - total += len; - } - - while ( total < outbufsz ) { - int ct = edg_wll_plain_read(conn, outbuf+total, outbufsz-total, to); - if ( ct < 0) return ct; - total += ct; - } - - return total; -} - -int edg_wll_plain_write_full( - edg_wll_PlainConnection *conn, - const void *buf, - size_t bufsz, - struct timeval *to) -{ - size_t written = 0; - int ct = -1; - fd_set fds; - struct timeval timeout, before, after; - - - if ( to ) { - memcpy(&timeout, to, sizeof(timeout)); - gettimeofday(&before, NULL); - } - - errno = 0; - while ( written < bufsz ) { - FD_ZERO(&fds); - FD_SET(conn->sock, &fds); - - switch ( select(conn->sock+1, NULL, &fds, NULL, to? &timeout: NULL) ) { - case 0: errno = ETIMEDOUT; goto end; break; - case -1: goto end; break; - } - if ( (ct=write(conn->sock, ((char*)buf)+written, bufsz-written)) < 0 ) { - if ( errno == EINTR ) { errno = 0; continue; } - else goto end; - } - written += ct; - } - -end: - if ( to ) { - gettimeofday(&after, NULL); - tv_sub(after, before); - tv_sub(*to, after); - if (to->tv_sec < 0) to->tv_sec = to->tv_usec = 0; - } - - return (errno)? -1: written; -} diff --git a/org.glite.lb.common/src/mini_http.c b/org.glite.lb.common/src/mini_http.c deleted file mode 100644 index 7e86628..0000000 --- a/org.glite.lb.common/src/mini_http.c +++ /dev/null @@ -1,373 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "globus_config.h" - -#include "mini_http.h" -#include "lb_gss.h" -#include "lb_plain_io.h" -#include "context-int.h" - -#define min(x,y) ((x) < (y) ? (x) : (y)) -#define CONTENT_LENGTH "Content-Length:" - -edg_wll_ErrorCode edg_wll_http_recv(edg_wll_Context ctx,char **firstOut,char ***hdrOut,char **bodyOut) -{ - char **hdr = NULL,*first = NULL,*body = NULL; - enum { FIRST, HEAD, BODY, DONE } pstat = FIRST; - int len, nhdr = 0,rdmore = 0,clen = 0,blen = 0; - int sock; - edg_wll_GssStatus gss_code; - -#define bshift(shift) {\ - memmove(ctx->connPool[ctx->connToUse].buf,ctx->connPool[ctx->connToUse].buf+(shift),ctx->connPool[ctx->connToUse].bufUse-(shift));\ - ctx->connPool[ctx->connToUse].bufUse -= (shift);\ -} - edg_wll_ResetError(ctx); - - if (ctx->connPool[ctx->connToUse].gss.context != GSS_C_NO_CONTEXT) - sock = ctx->connPool[ctx->connToUse].gss.sock; - else { - edg_wll_SetError(ctx,ENOTCONN,NULL); - goto error; - } - - if (!ctx->connPool[ctx->connToUse].buf) ctx->connPool[ctx->connToUse].buf = malloc(ctx->connPool[ctx->connToUse].bufSize = BUFSIZ); - - do { - len = edg_wll_gss_read(&ctx->connPool[ctx->connToUse].gss, - ctx->connPool[ctx->connToUse].buf+ctx->connPool[ctx->connToUse].bufUse,ctx->connPool[ctx->connToUse].bufSize-ctx->connPool[ctx->connToUse].bufUse,&ctx->p_tmp_timeout, &gss_code); - - switch (len) { - case EDG_WLL_GSS_OK: - break; - case EDG_WLL_GSS_ERROR_GSS: - edg_wll_SetErrorGss(ctx, "receving HTTP request", &gss_code); - goto error; - case EDG_WLL_GSS_ERROR_ERRNO: - edg_wll_SetError(ctx,errno,"edg_wll_gss_read()"); - goto error; - case EDG_WLL_GSS_ERROR_TIMEOUT: - edg_wll_SetError(ctx,ETIMEDOUT,NULL); - goto error; - case EDG_WLL_GSS_ERROR_EOF: - edg_wll_SetError(ctx,ENOTCONN,NULL); - goto error; - /* default: fallthrough */ - } - - - ctx->connPool[ctx->connToUse].bufUse += len; - rdmore = 0; - - while (!rdmore && pstat != DONE) switch (pstat) { - char *cr; - - case FIRST: - if ((cr = memchr(ctx->connPool[ctx->connToUse].buf,'\r',ctx->connPool[ctx->connToUse].bufUse)) && - ctx->connPool[ctx->connToUse].bufUse >= cr-ctx->connPool[ctx->connToUse].buf+2 && cr[1] == '\n') - { - *cr = 0; - first = strdup(ctx->connPool[ctx->connToUse].buf); - bshift(cr-ctx->connPool[ctx->connToUse].buf+2); - pstat = HEAD; - } else rdmore = 1; - break; - case HEAD: - if ((cr = memchr(ctx->connPool[ctx->connToUse].buf,'\r',ctx->connPool[ctx->connToUse].bufUse)) && - ctx->connPool[ctx->connToUse].bufUse >= cr-ctx->connPool[ctx->connToUse].buf+2 && cr[1] == '\n') - { - if (cr == ctx->connPool[ctx->connToUse].buf) { - bshift(2); - pstat = clen ? BODY : DONE; - if (clen) body = malloc(clen+1); - break; - } - - *cr = 0; - hdr = realloc(hdr,(nhdr+2) * sizeof(*hdr)); - hdr[nhdr] = strdup(ctx->connPool[ctx->connToUse].buf); - hdr[++nhdr] = NULL; - - if (!strncasecmp(ctx->connPool[ctx->connToUse].buf,CONTENT_LENGTH,sizeof(CONTENT_LENGTH)-1)) - clen = atoi(ctx->connPool[ctx->connToUse].buf+sizeof(CONTENT_LENGTH)-1); - - bshift(cr-ctx->connPool[ctx->connToUse].buf+2); - } else rdmore = 1; - break; - case BODY: - if (ctx->connPool[ctx->connToUse].bufUse) { - int m = min(ctx->connPool[ctx->connToUse].bufUse,clen-blen); - memcpy(body+blen,ctx->connPool[ctx->connToUse].buf,m); - blen += m; - bshift(m); - } - rdmore = 1; - if (blen == clen) { - pstat = DONE; - body[blen] = 0; - } - break; - default: - break; - } - } while (pstat != DONE); - -error: - if (edg_wll_Error(ctx,NULL,NULL)) { - if (hdr) { - char **h; - for (h = hdr; *h; h++) free(*h); - free(hdr); - } - free(first); - free(body); - } else { - if (firstOut) *firstOut = first; else free(first); - if (hdrOut) *hdrOut = hdr; - else if (hdr) { - char **h; - for (h = hdr; *h; h++) free(*h); - free(hdr); - } - if (bodyOut) *bodyOut = body; else free(body); - } - - return edg_wll_Error(ctx,NULL,NULL); - -#undef bshift -} - -edg_wll_ErrorCode edg_wll_http_recv_proxy(edg_wll_Context ctx,char **firstOut,char ***hdrOut,char **bodyOut) -{ - char **hdr = NULL,*first = NULL,*body = NULL; - enum { FIRST, HEAD, BODY, DONE } pstat = FIRST; - int len, nhdr = 0,rdmore = 0,clen = 0,blen = 0; - -#define bshift(shift) {\ - memmove(ctx->connProxy->buf,\ - ctx->connProxy->buf+(shift),\ - ctx->connProxy->bufUse-(shift));\ - ctx->connProxy->bufUse -= (shift);\ -} - edg_wll_ResetError(ctx); - - if ( !ctx->connProxy->buf ) { - ctx->connProxy->bufSize = BUFSIZ; - ctx->connProxy->bufUse = 0; - ctx->connProxy->buf = malloc(BUFSIZ); - } - - do { - len = edg_wll_plain_read(&ctx->connProxy->conn, - ctx->connProxy->buf+ctx->connProxy->bufUse, - ctx->connProxy->bufSize-ctx->connProxy->bufUse, - &ctx->p_tmp_timeout); - if ( len < 0 ) { - edg_wll_SetError(ctx, errno, "edg_wll_plain_read()"); - goto error; - } - - ctx->connProxy->bufUse += len; - rdmore = 0; - - while (!rdmore && pstat != DONE) switch (pstat) { - char *cr; - - case FIRST: - if ((cr = memchr(ctx->connProxy->buf,'\r',ctx->connProxy->bufUse)) && - ctx->connProxy->bufUse >= cr-ctx->connProxy->buf+2 && cr[1] == '\n') - { - *cr = 0; - first = strdup(ctx->connProxy->buf); - bshift(cr-ctx->connProxy->buf+2); - pstat = HEAD; - } else rdmore = 1; - break; - case HEAD: - if ((cr = memchr(ctx->connProxy->buf,'\r',ctx->connProxy->bufUse)) && - ctx->connProxy->bufUse >= cr-ctx->connProxy->buf+2 && cr[1] == '\n') - { - if (cr == ctx->connProxy->buf) { - bshift(2); - pstat = clen ? BODY : DONE; - if (clen) body = malloc(clen+1); - break; - } - - *cr = 0; - hdr = realloc(hdr,(nhdr+2) * sizeof(*hdr)); - hdr[nhdr] = strdup(ctx->connProxy->buf); - hdr[++nhdr] = NULL; - - if (!strncasecmp(ctx->connProxy->buf,CONTENT_LENGTH,sizeof(CONTENT_LENGTH)-1)) - clen = atoi(ctx->connProxy->buf+sizeof(CONTENT_LENGTH)-1); - - bshift(cr-ctx->connProxy->buf+2); - } else rdmore = 1; - break; - case BODY: - if (ctx->connProxy->bufUse) { - int m = min(ctx->connProxy->bufUse,clen-blen); - memcpy(body+blen,ctx->connProxy->buf,m); - blen += m; - bshift(m); - } - rdmore = 1; - if (blen == clen) { - pstat = DONE; - body[blen] = 0; - } - break; - default: - break; - } - } while (pstat != DONE); - -error: - if (edg_wll_Error(ctx,NULL,NULL)) { - if (hdr) { - char **h; - for (h = hdr; *h; h++) free(*h); - free(hdr); - } - free(first); - free(body); - } else { - if (firstOut) *firstOut = first; else free(first); - if (hdrOut) *hdrOut = hdr; - else if (hdr) { - char **h; - for (h = hdr; *h; h++) free(*h); - free(hdr); - } - if (bodyOut) *bodyOut = body; else free(body); - } - - return edg_wll_Error(ctx,NULL,NULL); - -#undef bshift -} - -static int real_write(edg_wll_Context ctx, edg_wll_GssConnection *con,const char *data,int len) -{ - size_t total = 0; - struct sigaction sa,osa; - edg_wll_GssStatus gss_code; - int ret; - - memset(&sa,0,sizeof(sa)); assert(sa.sa_handler == NULL); - sa.sa_handler = SIG_IGN; - sigaction(SIGPIPE,&sa,&osa); - - ret = edg_wll_gss_write_full(con, (void*)data, len, &ctx->p_tmp_timeout, - &total, &gss_code); - sigaction(SIGPIPE,&osa,NULL); - - switch(ret) { - case EDG_WLL_GSS_OK: - return 0; - case EDG_WLL_GSS_ERROR_EOF: - errno = ENOTCONN; - return -1; - case EDG_WLL_GSS_ERROR_TIMEOUT: - errno = ETIMEDOUT; - return -1; - case EDG_WLL_GSS_ERROR_ERRNO: - if (errno == EPIPE) errno = ENOTCONN; - return -1; - case EDG_WLL_GSS_ERROR_GSS: - errno = EDG_WLL_ERROR_GSS; - return -1; - default: - /* XXX DK: */ - errno = ENOTCONN; - return -1; - } -} - -edg_wll_ErrorCode edg_wll_http_send(edg_wll_Context ctx,const char *first,const char * const *head,const char *body) -{ - const char* const *h; - int len = 0, blen; - - edg_wll_ResetError(ctx); - - if (ctx->connPool[ctx->connToUse].gss.context == GSS_C_NO_CONTEXT) - return edg_wll_SetError(ctx,ENOTCONN,NULL); - - if (real_write(ctx,&ctx->connPool[ctx->connToUse].gss,first,strlen(first)) < 0 || - real_write(ctx,&ctx->connPool[ctx->connToUse].gss,"\r\n",2) < 0) - return edg_wll_SetError(ctx,errno,"edg_wll_http_send()"); - - if (head) for (h=head; *h; h++) - if (real_write(ctx,&ctx->connPool[ctx->connToUse].gss,*h,strlen(*h)) < 0 || - real_write(ctx,&ctx->connPool[ctx->connToUse].gss,"\r\n",2) < 0) - return edg_wll_SetError(ctx,errno,"edg_wll_http_send()"); - - if (body) { - char buf[100]; - - len = strlen(body); - blen = sprintf(buf,CONTENT_LENGTH " %d\r\n",len); - if (real_write(ctx,&ctx->connPool[ctx->connToUse].gss,buf,blen) < 0) - return edg_wll_SetError(ctx,errno,"edg_wll_http_send()"); - } - - if (real_write(ctx,&ctx->connPool[ctx->connToUse].gss,"\r\n",2) < 0) - return edg_wll_SetError(ctx,errno,"edg_wll_http_send()"); - if (body && real_write(ctx,&ctx->connPool[ctx->connToUse].gss,body,len) < 0) - return edg_wll_SetError(ctx,errno,"edg_wll_http_send()"); - - return edg_wll_Error(ctx,NULL,NULL); -} - -edg_wll_ErrorCode edg_wll_http_send_proxy(edg_wll_Context ctx, const char *first, const char * const *head, const char *body) -{ - const char* const *h; - int len = 0, blen; - - - edg_wll_ResetError(ctx); - - if ( edg_wll_plain_write_full(&ctx->connProxy->conn, - first, strlen(first), &ctx->p_tmp_timeout) < 0 - || edg_wll_plain_write_full(&ctx->connProxy->conn, - "\r\n", 2, &ctx->p_tmp_timeout) < 0 ) - return edg_wll_SetError(ctx, errno, "edg_wll_http_send()"); - - if ( head ) for ( h = head; *h; h++ ) - if ( edg_wll_plain_write_full(&ctx->connProxy->conn, - *h, strlen(*h), &ctx->p_tmp_timeout) < 0 - || edg_wll_plain_write_full(&ctx->connProxy->conn, - "\r\n", 2, &ctx->p_tmp_timeout) < 0 ) - return edg_wll_SetError(ctx, errno, "edg_wll_http_send()"); - - if ( body ) { - char buf[100]; - - len = strlen(body); - blen = sprintf(buf, CONTENT_LENGTH " %d\r\n",len); - if (edg_wll_plain_write_full(&ctx->connProxy->conn, - buf, blen, &ctx->p_tmp_timeout) < 0) - return edg_wll_SetError(ctx, errno, "edg_wll_http_send()"); - } - - if ( edg_wll_plain_write_full(&ctx->connProxy->conn, - "\r\n", 2, &ctx->p_tmp_timeout) < 0) - return edg_wll_SetError(ctx, errno, "edg_wll_http_send()"); - if ( body && edg_wll_plain_write_full(&ctx->connProxy->conn, - body, len, &ctx->p_tmp_timeout) < 0) - return edg_wll_SetError(ctx, errno, "edg_wll_http_send()"); - - return edg_wll_Error(ctx,NULL,NULL); -} diff --git a/org.glite.lb.common/src/notifid.c b/org.glite.lb.common/src/notifid.c deleted file mode 100644 index 8a1d5fe..0000000 --- a/org.glite.lb.common/src/notifid.c +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/notifid.h" - -int edg_wll_NotifIdParse(const char *s,edg_wll_NotifId *n) -{ - edg_wlc_JobId j; - int ret = edg_wlc_JobIdParse(s,&j); - - if (!ret) *n = (edg_wll_NotifId) j; - return ret; -} - -char* edg_wll_NotifIdUnparse(const edg_wll_NotifId n) -{ - return edg_wlc_JobIdUnparse((edg_wlc_JobId) n); -} - -int edg_wll_NotifIdCreate(const char *server,int port,edg_wll_NotifId *n) -{ - edg_wlc_JobId j,j2; - int ret = edg_wlc_JobIdCreate(server,port,&j); - char *u,*u2; - - if (!ret) { - u = edg_wlc_JobIdGetUnique(j); - asprintf(&u2,"NOTIF:%s",u); - free(u); - ret = edg_wlc_JobIdRecreate(server,port,u2,&j2); - free(u2); - edg_wlc_JobIdFree(j); - if (!ret) *n = (edg_wll_NotifId) j2; - } - - return ret; -} - -int edg_wll_NotifIdSetUnique(edg_wll_NotifId *n, const char *un) -{ - char *aux, *srv; - int ret; - unsigned int port; - - - asprintf(&aux, "NOTIF:%s", un); - if ( !aux ) - return -1; - - edg_wll_NotifIdGetServerParts(*((edg_wlc_JobId *)n), &srv, &port); - ret = edg_wlc_JobIdRecreate(srv, port, aux, (edg_wlc_JobId *)n); - free(aux); - free(srv); - - return ret; -} - -void edg_wll_NotifIdFree(edg_wll_NotifId n) -{ - edg_wlc_JobIdFree((edg_wlc_JobId) n); -} - -void edg_wll_NotifIdGetServerParts(const edg_wll_NotifId notifId, char **srvName, unsigned int *srvPort) -{ - edg_wlc_JobIdGetServerParts((edg_wlc_JobId) notifId, srvName, srvPort); -} - -char* edg_wll_NotifIdGetUnique(const edg_wll_NotifId notifid) -{ - char *id = edg_wlc_JobIdGetUnique((edg_wlc_JobId)notifid); - - if ( id ) - { - char *s = strchr(id, ':'); - - if ( s ) - { - char *ret = strdup(s+1); - free(id); - return ret; - } - } - - free(id); - return NULL; -} diff --git a/org.glite.lb.common/src/param.c b/org.glite.lb.common/src/param.c deleted file mode 100644 index f4a6df0..0000000 --- a/org.glite.lb.common/src/param.c +++ /dev/null @@ -1,458 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/producer.h" -#include "glite/lb/notification.h" -#include "context-int.h" -#include "log_proto.h" - - -/* XXX: must match edg_wll_ContextParam */ -static const char *myenv[] = { - "GLOBUS_HOSTNAME", - NULL, - NULL, - NULL, - "EDG_WL_LOG_DESTINATION", - "EDG_WL_LOG_DESTINATION", - "EDG_WL_LOG_TIMEOUT", - "EDG_WL_LOG_SYNC_TIMEOUT", - "EDG_WL_QUERY_SERVER", - "EDG_WL_QUERY_SERVER", - "EDG_WL_QUERY_SERVER_OVERRIDE", - "EDG_WL_QUERY_TIMEOUT", - "EDG_WL_QUERY_JOBS_LIMIT", - "EDG_WL_QUERY_EVENTS_LIMIT", - "EDG_WL_QUERY_RESULTS", - "EDG_WL_QUERY_CONNECTIONS", - "EDG_WL_NOTIF_SERVER", - "EDG_WL_NOTIF_SERVER", - "EDG_WL_NOTIF_TIMEOUT", -/* don't care about X509_USER_*, GSI looks at them anyway */ - NULL, - NULL, - NULL, - "EDG_WL_LBPROXY_STORE_SOCK", - "EDG_WL_LBPROXY_SERVE_SOCK", - "EDG_WL_LBPROXY_USER", -}; - -/* XXX: does not parse URL, just hostname[:port] */ - -static int extract_port(edg_wll_ContextParam param,int dflt) -{ - char *p = NULL,*s = NULL; - if (myenv[param]) { - s = getenv(myenv[param]); - if (s) p = strchr(s,':'); - } - return p ? atoi(p+1) : dflt; -} - -static int extract_num(edg_wll_ContextParam param,int dflt) -{ - if (myenv[param]) { - char *s = getenv(myenv[param]); - if (s) return(atoi(s)); - } - return dflt; -} - -static char *extract_host(edg_wll_ContextParam param,const char *dflt) -{ - char *p,*s = NULL; - - if (myenv[param]) s = getenv(myenv[param]); - if (!s && !dflt) return NULL; - s = strdup(s?s:dflt), - p = strchr(s,':'); - if (p) *p = 0; - return s; -} - -static void extract_time(edg_wll_ContextParam param,double dflt,struct timeval *t) -{ - char *s = NULL; - double d; - - if (myenv[param]) s = getenv(myenv[param]); - d = s ? atof(s) : dflt; - t->tv_sec = (long) d; - t->tv_usec = (long) ((d-t->tv_sec)*1e6); -} - -static char *extract_split(edg_wll_ContextParam param,char by,int index) -{ - int i; - char *s,*e; - - if (!myenv[param]) return NULL; - if (!(s = getenv(myenv[param]))) return NULL; - for (i=0; ip_host); - ctx->p_host = val ? strdup(val) : extract_host(param,hn); - break; - case EDG_WLL_PARAM_INSTANCE: - free(ctx->p_instance); - ctx->p_instance = val ? strdup(val) : extract_split(param,'/',1); - break; - case EDG_WLL_PARAM_DESTINATION: - free(ctx->p_destination); - ctx->p_destination = val ? strdup(val) : extract_host(param,EDG_WLL_LOG_HOST_DEFAULT); - break; - case EDG_WLL_PARAM_QUERY_SERVER: - free(ctx->p_query_server); - ctx->p_query_server = val ? strdup(val) : extract_host(param,NULL); - break; - case EDG_WLL_PARAM_NOTIF_SERVER: - free(ctx->p_notif_server); - ctx->p_notif_server = val ? strdup(val) : extract_host(param,NULL); - break; - case EDG_WLL_PARAM_X509_PROXY: - free(ctx->p_proxy_filename); - ctx->p_proxy_filename = val ? strdup(val) : NULL; - break; - case EDG_WLL_PARAM_X509_KEY: - free(ctx->p_key_filename); - ctx->p_key_filename = val ? strdup(val) : NULL; - break; - case EDG_WLL_PARAM_X509_CERT: - free(ctx->p_cert_filename); - ctx->p_cert_filename = val ? strdup(val) : NULL; - break; - case EDG_WLL_PARAM_QUERY_SERVER_OVERRIDE: - if (!val) val = getenv(myenv[param]); - if (!val) val = "no"; - ctx->p_query_server_override = !strcasecmp(val,"yes"); - break; - case EDG_WLL_PARAM_LBPROXY_STORE_SOCK: - free(ctx->p_lbproxy_store_sock); - ctx->p_lbproxy_store_sock = val ? strdup(val): NULL; - break; - case EDG_WLL_PARAM_LBPROXY_SERVE_SOCK: - free(ctx->p_lbproxy_serve_sock); - ctx->p_lbproxy_serve_sock = val ? strdup(val): NULL; - break; - case EDG_WLL_PARAM_LBPROXY_USER: - free(ctx->p_user_lbproxy); - ctx->p_user_lbproxy = val ? strdup(val) : NULL; - break; - default: - return edg_wll_SetError(ctx,EINVAL,"unknown parameter"); - } - return edg_wll_ResetError(ctx); -} - -int edg_wll_SetParamInt(edg_wll_Context ctx,edg_wll_ContextParam param,int val) -{ - switch (param) { - case EDG_WLL_PARAM_LEVEL: - ctx->p_level = val ? val : EDG_WLL_LEVEL_SYSTEM; - break; - case EDG_WLL_PARAM_DESTINATION_PORT: - ctx->p_dest_port = val ? val : extract_port(param,EDG_WLL_LOG_PORT_DEFAULT); - break; - case EDG_WLL_PARAM_QUERY_SERVER_PORT: - ctx->p_query_server_port = val ? val : - extract_port(param,GLITE_WMSC_JOBID_DEFAULT_PORT);; - break; - case EDG_WLL_PARAM_NOTIF_SERVER_PORT: - ctx->p_notif_server_port = val ? val : - extract_port(param,0);; - // XXX: when default port is known, put it here - break; - case EDG_WLL_PARAM_QUERY_JOBS_LIMIT: - ctx->p_query_jobs_limit = val ? val : - extract_num(param,0); - break; - case EDG_WLL_PARAM_QUERY_EVENTS_LIMIT: - ctx->p_query_events_limit = val ? val : - extract_num(param,0); - break; - case EDG_WLL_PARAM_QUERY_RESULTS: - if (val) { - if (val <= EDG_WLL_QUERYRES_UNDEF || val >= EDG_WLL_QUERYRES__LAST) - return edg_wll_SetError(ctx,EINVAL,"Query result parameter value out of range"); - - ctx->p_query_results = val; - } - else { - char *s = extract_split(param,'/',0); - if (s) { - val = edg_wll_StringToQResult(s); - if (!val) return edg_wll_SetError(ctx,EINVAL,"can't parse query result parameter name"); - ctx->p_query_results = val; - free(s); - } - return edg_wll_SetError(ctx,EINVAL,"can't parse query result parameter name"); - } - break; - case EDG_WLL_PARAM_QUERY_CONNECTIONS: - { - char *s = getenv(myenv[param]); - - if (!val && s) val = atoi(s); - ctx->poolSize = val ? val : EDG_WLL_LOG_CONNECTIONS_DEFAULT; - } - break; - case EDG_WLL_PARAM_SOURCE: - if (val) { - if (val <= EDG_WLL_SOURCE_NONE || val >= EDG_WLL_SOURCE__LAST) - return edg_wll_SetError(ctx,EINVAL,"Source out of range"); - - ctx->p_source = val; - } - else { - char *s = extract_split(param,'/',0); - if (s) { - val = edg_wll_StringToSource(s); - if (!val) return edg_wll_SetError(ctx,EINVAL,"can't parse source name"); - ctx->p_source = val; - free(s); - } - return edg_wll_SetError(ctx,EINVAL,"can't parse source name"); - } - break; - default: - return edg_wll_SetError(ctx,EINVAL,"unknown parameter"); - } - return edg_wll_ResetError(ctx); -} - -int edg_wll_SetParamTime(edg_wll_Context ctx,edg_wll_ContextParam param,const struct timeval *val) -{ - switch (param) { - case EDG_WLL_PARAM_LOG_TIMEOUT: -/* XXX: check also if val is not grater than EDG_WLL_LOG_TIMEOUT_MAX */ - if (val) memcpy(&ctx->p_log_timeout,val,sizeof *val); - else extract_time(param,EDG_WLL_LOG_TIMEOUT_DEFAULT,&ctx->p_log_timeout); - break; - case EDG_WLL_PARAM_LOG_SYNC_TIMEOUT: -/* XXX: check also if val is not grater than EDG_WLL_LOG_SYNC_TIMEOUT_MAX */ - if (val) memcpy(&ctx->p_sync_timeout,val,sizeof *val); - else extract_time(param,EDG_WLL_LOG_SYNC_TIMEOUT_DEFAULT,&ctx->p_sync_timeout); - break; - case EDG_WLL_PARAM_QUERY_TIMEOUT: -/* XXX: check also if val is not grater than EDG_WLL_QUERY_TIMEOUT_MAX */ - if (val) memcpy(&ctx->p_query_timeout,val,sizeof *val); - else extract_time(param,EDG_WLL_QUERY_TIMEOUT_DEFAULT,&ctx->p_query_timeout); - break; - case EDG_WLL_PARAM_NOTIF_TIMEOUT: -/* XXX: check also if val is not grater than EDG_WLL_NOTIF_TIMEOUT_MAX */ - if (val) memcpy(&ctx->p_notif_timeout,val,sizeof *val); - else extract_time(param,EDG_WLL_NOTIF_TIMEOUT_DEFAULT,&ctx->p_notif_timeout); - break; - default: - return edg_wll_SetError(ctx,EINVAL,"unknown parameter"); - } - return edg_wll_ResetError(ctx); -} - -int edg_wll_SetParam(edg_wll_Context ctx,edg_wll_ContextParam param,...) -{ - va_list ap; - - va_start(ap,param); - switch (param) { - case EDG_WLL_PARAM_LEVEL: - case EDG_WLL_PARAM_DESTINATION_PORT: - case EDG_WLL_PARAM_QUERY_SERVER_PORT: - case EDG_WLL_PARAM_NOTIF_SERVER_PORT: - case EDG_WLL_PARAM_QUERY_JOBS_LIMIT: - case EDG_WLL_PARAM_QUERY_EVENTS_LIMIT: - case EDG_WLL_PARAM_QUERY_RESULTS: - case EDG_WLL_PARAM_QUERY_CONNECTIONS: - case EDG_WLL_PARAM_SOURCE: - return edg_wll_SetParamInt(ctx,param,va_arg(ap,int)); - case EDG_WLL_PARAM_HOST: - case EDG_WLL_PARAM_INSTANCE: - case EDG_WLL_PARAM_DESTINATION: - case EDG_WLL_PARAM_QUERY_SERVER: - case EDG_WLL_PARAM_NOTIF_SERVER: - case EDG_WLL_PARAM_QUERY_SERVER_OVERRIDE: - case EDG_WLL_PARAM_X509_PROXY: - case EDG_WLL_PARAM_X509_KEY: - case EDG_WLL_PARAM_X509_CERT: - case EDG_WLL_PARAM_LBPROXY_STORE_SOCK: - case EDG_WLL_PARAM_LBPROXY_SERVE_SOCK: - case EDG_WLL_PARAM_LBPROXY_USER: - return edg_wll_SetParamString(ctx,param,va_arg(ap,char *)); - case EDG_WLL_PARAM_LOG_TIMEOUT: - case EDG_WLL_PARAM_LOG_SYNC_TIMEOUT: - case EDG_WLL_PARAM_QUERY_TIMEOUT: - case EDG_WLL_PARAM_NOTIF_TIMEOUT: - return edg_wll_SetParamTime(ctx,param,va_arg(ap,struct timeval *)); - default: - return edg_wll_SetError(ctx,EINVAL,"unknown parameter"); - } -} - -int edg_wll_GetParam(edg_wll_Context ctx,edg_wll_ContextParam param,...) -{ - va_list ap; - int *p_int; - char **p_string; - struct timeval *p_tv; - - edg_wll_ResetError(ctx); - - va_start(ap,param); - switch (param) { - case EDG_WLL_PARAM_LEVEL: - p_int = va_arg(ap, int *); - *p_int = ctx->p_level; - break; - case EDG_WLL_PARAM_DESTINATION_PORT: - p_int = va_arg(ap, int *); - *p_int = ctx->p_dest_port; - break; - case EDG_WLL_PARAM_QUERY_SERVER_PORT: - p_int = va_arg(ap, int *); - *p_int = ctx->p_query_server_port; - break; - case EDG_WLL_PARAM_NOTIF_SERVER_PORT: - p_int = va_arg(ap, int *); - *p_int = ctx->p_notif_server_port; - break; - case EDG_WLL_PARAM_QUERY_JOBS_LIMIT: - p_int = va_arg(ap, int *); - *p_int = ctx->p_query_jobs_limit; - break; - case EDG_WLL_PARAM_QUERY_EVENTS_LIMIT: - p_int = va_arg(ap, int *); - *p_int = ctx->p_query_events_limit; - break; - case EDG_WLL_PARAM_QUERY_RESULTS: - p_int = va_arg(ap, int *); - *p_int = ctx->p_query_results; - break; - case EDG_WLL_PARAM_QUERY_CONNECTIONS: - p_int = va_arg(ap, int *); - *p_int = ctx->poolSize; - break; - case EDG_WLL_PARAM_SOURCE: - p_int = va_arg(ap, int *); - *p_int = ctx->p_source; - break; - -#define estrdup(x) ((x) ? strdup(x) : x) - - case EDG_WLL_PARAM_HOST: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_host); - break; - case EDG_WLL_PARAM_INSTANCE: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_instance); - break; - case EDG_WLL_PARAM_DESTINATION: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_destination); - break; - case EDG_WLL_PARAM_QUERY_SERVER: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_query_server); - break; - case EDG_WLL_PARAM_NOTIF_SERVER: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_notif_server); - break; - case EDG_WLL_PARAM_QUERY_SERVER_OVERRIDE: - p_string = va_arg(ap, char **); - *p_string = strdup(ctx->p_query_server_override ? "yes" : "no"); - break; - case EDG_WLL_PARAM_X509_PROXY: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_proxy_filename); - break; - case EDG_WLL_PARAM_X509_KEY: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_key_filename); - break; - case EDG_WLL_PARAM_X509_CERT: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_cert_filename); - break; - case EDG_WLL_PARAM_LBPROXY_STORE_SOCK: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_lbproxy_store_sock); - break; - case EDG_WLL_PARAM_LBPROXY_SERVE_SOCK: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_lbproxy_serve_sock); - break; - case EDG_WLL_PARAM_LBPROXY_USER: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_user_lbproxy); - break; - case EDG_WLL_PARAM_LOG_TIMEOUT: - p_tv = va_arg(ap,struct timeval *); - *p_tv = ctx->p_log_timeout; - break; - case EDG_WLL_PARAM_LOG_SYNC_TIMEOUT: - p_tv = va_arg(ap,struct timeval *); - *p_tv = ctx->p_sync_timeout; - break; - case EDG_WLL_PARAM_QUERY_TIMEOUT: - p_tv = va_arg(ap,struct timeval *); - *p_tv = ctx->p_query_timeout; - break; - case EDG_WLL_PARAM_NOTIF_TIMEOUT: - p_tv = va_arg(ap,struct timeval *); - *p_tv = ctx->p_notif_timeout; - break; - - default: - return edg_wll_SetError(ctx, EINVAL, "unknown parameter"); - break; - } - va_end(ap); - return edg_wll_Error(ctx, NULL, NULL); -} - -#if 0 -/* only for reference */ -edg_wll_ErrorCode edg_wll_SetLoggingParams(edg_wll_Context ctx, - const char *jobid, - const char *service, - const char *hostname, - const char *instance, - enum edg_wll_Level level, - const char *proxy_filename, - const char *cert_filename, - const char *key_filename) -{ - edg_wll_ResetError(ctx); - - if (jobid != NULL) ctx->p_jobid = strdup(jobid); - if (service != NULL) ctx->p_service = strdup(service); - if (hostname != NULL) ctx->p_hostname = strdup(hostname); - if (instance != NULL) ctx->p_instance = strdup(instance); - - ctx->p_level = level; - - if (proxy_filename != NULL) ctx->p_proxy_filename = strdup(proxy_filename); - if (cert_filename != NULL) ctx->p_cert_filename = strdup(cert_filename); - if (key_filename != NULL) ctx->p_key_filename = strdup(key_filename); - - return edg_wll_Error(ctx, NULL, NULL); -} -#endif diff --git a/org.glite.lb.common/src/query_rec.c b/org.glite.lb.common/src/query_rec.c deleted file mode 100644 index 6abeb4f..0000000 --- a/org.glite.lb.common/src/query_rec.c +++ /dev/null @@ -1,50 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/consumer.h" - -/* - * edg_wll_QueryRec manipulation routines - */ - -void edg_wll_QueryRecFree(edg_wll_QueryRec *prec) -{ - if (prec == NULL) { - fprintf(stderr, "Error: edg_wll_QueryRecFree called with NULL parameter\n"); - return; - } - switch (prec->attr) { - case EDG_WLL_QUERY_ATTR_USERTAG: - free(prec->attr_id.tag); - case EDG_WLL_QUERY_ATTR_OWNER: - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_DESTINATION: - case EDG_WLL_QUERY_ATTR_HOST: - case EDG_WLL_QUERY_ATTR_INSTANCE: - if ( prec->value.c ) free(prec->value.c); - break; - case EDG_WLL_QUERY_ATTR_JOBID: - case EDG_WLL_QUERY_ATTR_PARENT: - edg_wlc_JobIdFree(prec->value.j); - break; - case EDG_WLL_QUERY_ATTR_STATUS: - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_LEVEL: - case EDG_WLL_QUERY_ATTR_SOURCE: - case EDG_WLL_QUERY_ATTR_EVENT_TYPE: - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - case EDG_WLL_QUERY_ATTR_TIME: - /* do nothing */ - break; - default: - fprintf(stderr,"Error(edg_wll_QueryRecFree): unknown edg_wll_QueryRec.attr=%d\n", prec->attr); - break; - } -} - diff --git a/org.glite.lb.common/src/status.c.T b/org.glite.lb.common/src/status.c.T deleted file mode 100644 index 301c96b..0000000 --- a/org.glite.lb.common/src/status.c.T +++ /dev/null @@ -1,172 +0,0 @@ -#ident "$Header$" - -#include -#include - -#include "glite/lb/consumer.h" - -static const struct timeval null_timeval = {0,0}; - - -void edg_wll_FreeStatus(edg_wll_JobStat *stat) -{ - if (stat) { - int i; - -@@@{ - selectType $status '_common_'; - for (getFieldsOrdered $status) { - my $f = selectField $status $_; - my $ft = $f->{type}; - if ($ft eq 'jobid') { - gen "\tedg_wlc_JobIdFree(stat->$_);\n"; - } - if ($ft eq 'string') { - gen "\tif (stat->$_ != NULL ) \tfree(stat->$_);\n"; - } - if ($ft eq 'intlist') { - gen "\tif (stat->$_ != NULL ) \tfree(stat->$_);\n"; - } - if ($ft eq 'strlist') { - gen "\tif (stat->$_ != NULL ) {\n"; - gen "\t\tfor (i=0; stat->$_\[i]; i++)\n"; - gen "\t\t\tfree(stat->$_\[i]);\n"; - gen "\t\tfree(stat->$_);\n"; - gen "\t}\n"; - } - if ($ft eq 'taglist') { - gen "\tif (stat->$_ != NULL ) {\n"; - gen "\t\tfor (i=0; stat->$_\[i].tag; i++) {\n"; - gen "\t\t\tfree(stat->$_\[i].tag);\n"; - gen "\t\t\tfree(stat->$_\[i].value);\n"; - gen "\t\t}\n"; - gen "\t\tfree(stat->$_);\n"; - gen "\t}\n"; - } - if ($ft eq 'stslist') { - gen "\tif (stat->$_ != NULL ) {\n"; - gen "\t\tfor (i=0; stat->$_\[i].state; i++)\n"; - gen "\t\t\tedg_wll_FreeStatus(&stat->$_\[i]);\n"; - gen "\t\tfree(stat->$_);\n"; - gen "\t}\n"; - } - - } -@@@} - - } -} - -edg_wll_JobStat *edg_wll_CpyStatus(const edg_wll_JobStat *src, edg_wll_JobStat *dest) -{ - int i; - - - if ( !src || !dest ) - return NULL; - - edg_wll_InitStatus(dest); - dest->state = src->state; -@@@{ - selectType $status '_common_'; - for (getFieldsOrdered $status) { - my $f = selectField $status $_; - my $ft = $f->{type}; - if ($ft eq 'jobid') { - gen "\tif ( edg_wlc_JobIdDup(src->$_, &(dest->$_)) ) goto err;\n"; - } - if ($ft eq 'string') { - gen "\tif ( src->$_ != NULL )\n"; - gen "\t\tif ( !(dest->$_ = strdup(src->$_)) ) goto err;\n"; - } - if ($ft eq 'intlist') { - gen "\tif ( src->$_ != NULL )\n\t{\n"; - gen "\t\ti = 1 + src->$_\[0];\n"; - gen "\t\tif ( !(dest->$_ = malloc(sizeof(*src->$_)*i)) ) goto err;\n"; - gen "\t\tmemcpy(dest->$_,src->$_,sizeof(*src->$_)*i);\n\t}\n"; - } - if ($ft eq 'strlist') { - gen "\tif ( src->$_ != NULL )\n\t{\n"; - gen "\t\tfor ( i = 0; src->$_\[i]; i++ ) ;\n"; - gen "\t\tif ( !(dest->$_ = malloc(sizeof(*src->$_)*(i+1))) ) goto err;\n"; - gen "\t\tfor ( i = 0; src->$_\[i]; i++ )\n"; - gen "\t\t\tif ( !(dest->$_\[i] = strdup(src->$_\[i])) ) goto err;\n"; - gen "\t\tdest->$_\[i] = NULL;\n\t}\n"; - } - if ($ft eq 'stslist') { - gen "\tif ( src->$_ != NULL )\n\t{\n"; - gen "\t\tfor ( i = 0; src->$_\[i].state; i++ ) ;\n"; - gen "\t\tif ( !(dest->$_ = malloc(sizeof(*src->$_)*(i+1))) ) goto err;\n"; - gen "\t\tfor ( i = 0; src->$_\[i].state; i++ )\n"; - gen "\t\t\tif ( !edg_wll_CpyStatus(&src->$_\[i], &dest->$_\[i]) ) goto err;\n"; - gen "\t\tdest->$_\[i].state = EDG_WLL_JOB_UNDEF;\n\t}\n"; - } - if (($ft eq 'bool') or ($ft eq 'timeval') or ($ft eq 'logsrc') - or ($ft eq 'port') or ($ft eq 'level') or ($ft eq 'int')) { - gen "\tdest->$_ = src->$_;\n"; - } - if ($ft eq 'taglist') { - gen qq{ -! if (src->$_ != NULL) \{ -! for (i=0; src->$_\[i].tag; i++); -! dest->$_ = malloc(sizeof(*src->$_)*(i+1)); -! for (i=0; src->$_\[i].tag; i++) \{ -! dest->$_\[i].tag = strdup(src->$_\[i].tag); -! dest->$_\[i].value = strdup(src->$_\[i].value); -! \} -! dest->$_\[i].tag = NULL; -! \} - }; - } - } -@@@} - - return dest; - -err: - edg_wll_FreeStatus(dest); - return NULL; -} - - -int edg_wll_InitStatus(edg_wll_JobStat *stat) -{ - if (!stat) return -1; - - stat->state = EDG_WLL_JOB_UNDEF; - -@@@{ - selectType $status '_common_'; - for (getFieldsOrdered $status) { - my $f = selectField $status $_; - gen "\tstat->$_ = $f->{null};\n" - } -@@@} - - return 0; -} - -static const char * const statNames[] = { - "Undefined", -@@@{ - for (getTypesOrdered $status) { - gen "\t\"$_\",\n"; - } -@@@} -}; - -edg_wll_JobStatCode edg_wll_StringToStat(const char *name) - -{ - unsigned int i; - - for (i=0; i= sizeof(statNames)/sizeof(statNames[0])) return (char *) NULL; - return strdup(statNames[statCode]); -} diff --git a/org.glite.lb.common/src/strio.c b/org.glite.lb.common/src/strio.c deleted file mode 100644 index f1ab5b8..0000000 --- a/org.glite.lb.common/src/strio.c +++ /dev/null @@ -1,581 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 1998 Bjorn Reese and Daniel Stenberg. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************/ - -/* - * TODO - * - StrToLongDouble - */ - -static const char rcsid[] = "@(#)$Id$"; - -#if defined(unix) || defined(__xlC__) || defined(__QNX__) -# define PLATFORM_UNIX -#elif defined(WIN32) || defined(_WIN32) -# define PLATFORM_WIN32 -#elif defined(AMIGA) && defined(__GNUC__) -# define PLATFORM_UNIX -#endif - -#if defined(__STDC__) && (__STDC_VERSION__ >= 199901L) -# define TRIO_C99 -#endif - -#include "strio.h" -#include -#include -#include -#include -#include -#include -#ifndef DEBUG -# define NDEBUG -#endif -#include - -#ifndef NULL -# define NULL 0 -#endif -#define NIL ((char)0) -#ifndef FALSE -# define FALSE (1 == 0) -# define TRUE (! FALSE) -#endif - -#define VALID(x) (NULL != (x)) -#define INVALID(x) (NULL == (x)) - -#if defined(PLATFORM_UNIX) -# define USE_STRCASECMP -# define USE_STRNCASECMP -# define USE_STRERROR -# if defined(__QNX__) -# define strcasecmp(x,y) stricmp(x,y) -# define strncasecmp(x,y,n) strnicmp(x,y,n) -# endif -#elif defined(PLATFORM_WIN32) -# define USE_STRCASECMP -# define strcasecmp(x,y) strcmpi(x,y) -#endif - -/************************************************************************* - * StrAppendMax - */ -char *StrAppendMax(char *target, size_t max, const char *source) -{ - assert(VALID(target)); - assert(VALID(source)); - assert(max > 0); - - max -= StrLength(target) + 1; - return (max > 0) ? strncat(target, source, max) : target; -} - -/************************************************************************* - * StrCopyMax - */ -char *StrCopyMax(char *target, size_t max, const char *source) -{ - assert(VALID(target)); - assert(VALID(source)); - assert(max > 0); /* Includes != 0 */ - - target = strncpy(target, source, max - 1); - target[max - 1] = (char)0; - return target; -} - -/************************************************************************* - * StrDuplicate - */ -char *StrDuplicate(const char *source) -{ - char *target; - - assert(VALID(source)); - - target = StrAlloc(StrLength(source) + 1); - if (target) - { - StrCopy(target, source); - } - return target; -} - -/************************************************************************* - * StrDuplicateMax - */ -char *StrDuplicateMax(const char *source, size_t max) -{ - char *target; - size_t len; - - assert(VALID(source)); - assert(max > 0); - - /* Make room for string plus a terminating zero */ - len = StrLength(source) + 1; - if (len > max) - { - len = max; - } - target = StrAlloc(len); - if (target) - { - StrCopyMax(target, len, source); - } - return target; -} - -/************************************************************************* - * StrEqual - */ -int StrEqual(const char *first, const char *second) -{ - assert(VALID(first)); - assert(VALID(second)); - - if (VALID(first) && VALID(second)) - { -#if defined(USE_STRCASECMP) - return (0 == strcasecmp(first, second)); -#else - while ((*first != NIL) && (*second != NIL)) - { - if (toupper(*first) != toupper(*second)) - { - break; - } - first++; - second++; - } - return ((*first == NIL) && (*second == NIL)); -#endif - } - return FALSE; -} - -/************************************************************************* - * StrEqualCase - */ -int StrEqualCase(const char *first, const char *second) -{ - assert(VALID(first)); - assert(VALID(second)); - - if (VALID(first) && VALID(second)) - { - return (0 == strcmp(first, second)); - } - return FALSE; -} - -/************************************************************************* - * StrEqualCaseMax - */ -int StrEqualCaseMax(const char *first, size_t max, const char *second) -{ - assert(VALID(first)); - assert(VALID(second)); - - if (VALID(first) && VALID(second)) - { - return (0 == strncmp(first, second, max)); - } - return FALSE; -} - -/************************************************************************* - * StrEqualLocale - */ -int StrEqualLocale(const char *first, const char *second) -{ - assert(VALID(first)); - assert(VALID(second)); - -#if defined(LC_COLLATE) - return (strcoll(first, second) == 0); -#else - return StrEqual(first, second); -#endif -} - -/************************************************************************* - * StrEqualMax - */ -int StrEqualMax(const char *first, size_t max, const char *second) -{ - assert(VALID(first)); - assert(VALID(second)); - - if (VALID(first) && VALID(second)) - { -#if defined(USE_STRNCASECMP) - return (0 == strncasecmp(first, second, max)); -#else - /* Not adequately tested yet */ - size_t cnt = 0; - while ((*first != NIL) && (*second != NIL) && (cnt <= max)) - { - if (toupper(*first) != toupper(*second)) - { - break; - } - first++; - second++; - cnt++; - } - return ((cnt == max) || ((*first == NIL) && (*second == NIL))); -#endif - } - return FALSE; -} - -/************************************************************************* - * StrError - */ -const char *StrError(int errorNumber) -{ -#if defined(USE_STRERROR) - return strerror(errorNumber); -#else - return "unknown"; -#endif -} - -/************************************************************************* - * StrFormatDate - */ -size_t StrFormatDateMax(char *target, - size_t max, - const char *format, - const struct tm *datetime) -{ - assert(VALID(target)); - assert(VALID(format)); - assert(VALID(datetime)); - assert(max > 0); - - return strftime(target, max, format, datetime); -} - -/************************************************************************* - * StrHash - */ -unsigned long StrHash(const char *string, int type) -{ - unsigned long value = 0L; - char ch; - - assert(VALID(string)); - - switch (type) - { - case STRIO_HASH_PLAIN: - while ( (ch = *string++) != NIL ) - { - value *= 31; - value += (unsigned long)ch; - } - break; - default: - assert(FALSE); - break; - } - return value; -} - -/************************************************************************* - * StrMatch - */ -int StrMatch(char *string, char *pattern) -{ - assert(VALID(string)); - assert(VALID(pattern)); - - for (; ('*' != *pattern); ++pattern, ++string) - { - if (NIL == *string) - { - return (NIL == *pattern); - } - if ((toupper((int)*string) != toupper((int)*pattern)) - && ('?' != *pattern)) - { - return FALSE; - } - } - /* two-line patch to prevent *too* much recursiveness: */ - while ('*' == pattern[1]) - pattern++; - - do - { - if ( StrMatch(string, &pattern[1]) ) - { - return TRUE; - } - } - while (*string++); - - return FALSE; -} - -/************************************************************************* - * StrMatchCase - */ -int StrMatchCase(char *string, char *pattern) -{ - assert(VALID(string)); - assert(VALID(pattern)); - - for (; ('*' != *pattern); ++pattern, ++string) - { - if (NIL == *string) - { - return (NIL == *pattern); - } - if ((*string != *pattern) - && ('?' != *pattern)) - { - return FALSE; - } - } - /* two-line patch to prevent *too* much recursiveness: */ - while ('*' == pattern[1]) - pattern++; - - do - { - if ( StrMatchCase(string, &pattern[1]) ) - { - return TRUE; - } - } - while (*string++); - - return FALSE; -} - -/************************************************************************* - * StrSpanFunction - * - * Untested - */ -size_t StrSpanFunction(char *source, int (*Function)(int)) -{ - size_t count = 0; - - assert(VALID(source)); - assert(VALID(Function)); - - while (*source != NIL) - { - if (Function(*source)) - break; /* while */ - source++; - count++; - } - return count; -} - -/************************************************************************* - * StrSubstringMax - */ -char *StrSubstringMax(const char *string, size_t max, const char *find) -{ - size_t count; - size_t size; - char *result = NULL; - - assert(VALID(string)); - assert(VALID(find)); - - size = StrLength(find); - if (size <= max) - { - for (count = 0; count <= max - size; count++) - { - if (StrEqualMax(find, size, &string[count])) - { - result = (char *)&string[count]; - break; - } - } - } - return result; -} - -/************************************************************************* - * StrToDouble - * - * double ::= [ ] - * ( | - * | - * ) - * [ [ ] ] - * number ::= 1*( ) - * digit ::= ( '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ) - * exponential ::= ( 'e' | 'E' ) - * sign ::= ( '-' | '+' ) - * decimal_point ::= '.' - */ -double StrToDouble(const char *source, const char **endp) -{ -#if defined(TRIO_C99) - return strtod(source, endp); -#else - /* Preliminary code */ - int isNegative = FALSE; - int isExponentNegative = FALSE; - unsigned long integer = 0; - unsigned long fraction = 0; - unsigned long fracdiv = 1; - unsigned long exponent = 0; - double value = 0.0; - - /* First try hex-floats */ - if ((source[0] == '0') && ((source[1] == 'x') || (source[1] == 'X'))) - { - source += 2; - while (isxdigit((int)*source)) - { - integer *= 16; - integer += (isdigit((int)*source) - ? (*source - '0') - : 10 + (toupper((int)*source) - 'A')); - source++; - } - if (*source == '.') - { - source++; - while (isxdigit((int)*source)) - { - fraction *= 16; - fraction += (isdigit((int)*source) - ? (*source - '0') - : 10 + (toupper((int)*source) - 'A')); - fracdiv *= 16; - source++; - } - if ((*source == 'p') || (*source == 'P')) - { - source++; - if ((*source == '+') || (*source == '-')) - { - isExponentNegative = (*source == '-'); - source++; - } - while (isdigit((int)*source)) - { - exponent *= 10; - exponent += (*source - '0'); - source++; - } - } - } - } - else /* Then try normal decimal floats */ - { - isNegative = (*source == '-'); - /* Skip sign */ - if ((*source == '+') || (*source == '-')) - source++; - - /* Integer part */ - while (isdigit((int)*source)) - { - integer *= 10; - integer += (*source - '0'); - source++; - } - - if (*source == '.') - { - source++; /* skip decimal point */ - while (isdigit((int)*source)) - { - fraction *= 10; - fraction += (*source - '0'); - fracdiv *= 10; - source++; - } - } - if ((*source == 'e') || (*source == 'E')) - { - source++; /* Skip exponential indicator */ - isExponentNegative = (*source == '-'); - if ((*source == '+') || (*source == '-')) - source++; - while (isdigit((int)*source)) - { - exponent *= 10; - exponent += (*source - '0'); - source++; - } - } - } - - value = (double)integer; - if (fraction != 0) - { - value += (double)fraction / (double)fracdiv; - } - if (exponent != 0) - { - if (isExponentNegative) - value /= pow((double)10, (double)exponent); - else - value *= pow((double)10, (double)exponent); - } - if (isNegative) - value = -value; - - if (endp) - *endp = source; - return value; -#endif -} - -/************************************************************************* - * StrToFloat - */ -float StrToFloat(const char *source, const char **endp) -{ -#if defined(TRIO_C99) - return strtof(source, endp); -#else - return (float)StrToDouble(source, endp); -#endif -} - -/************************************************************************* - * StrToUpper - */ -int StrToUpper(char *target) -{ - int i = 0; - - assert(VALID(target)); - - while (NIL != *target) - { - *target = toupper((int)*target); - target++; - i++; - } - return i; -} diff --git a/org.glite.lb.common/src/strio.h b/org.glite.lb.common/src/strio.h deleted file mode 100644 index 68845a3..0000000 --- a/org.glite.lb.common/src/strio.h +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 1998 Bjorn Reese and Daniel Stenberg. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************/ - -#ifndef TRIO_STRIO_H -#define TRIO_STRIO_H - -#if !(defined(DEBUG) || defined(NDEBUG)) -# define NDEBUG -#endif -#include -#include -#include -#include - -#ifndef STRIO_MALLOC -# define STRIO_MALLOC(n) malloc(n) -#endif -#ifndef STRIO_FREE -# define STRIO_FREE(x) free(x) -#endif - -/* - * StrAppend(target, source) - * StrAppendMax(target, maxsize, source) - * - * Append 'source' to 'target' - * - * target = StrAlloc(size) - * - * Allocate a new string - * - * StrContains(target, substring) - * - * Find out if the string 'substring' is - * contained in the string 'target' - * - * StrCopy(target, source) - * StrCopyMax(target, maxsize, source) - * - * Copy 'source' to 'target' - * - * target = StrDuplicate(source) - * target = StrDuplicateMax(source, maxsize) - * - * Allocate and copy 'source' to 'target' - * - * StrEqual(first, second) - * StrEqualMax(first, maxsize, second) - * - * Compare if 'first' is equal to 'second'. - * Case-independent. - * - * StrEqualCase(first, second) - * StrEqualCaseMax(first, maxsize, second) - * - * Compare if 'first' is equal to 'second' - * Case-dependent. Please note that the use of the - * word 'case' has the opposite meaning as that of - * strcasecmp(). - * - * StrFormat(target, format, ...) - * StrFormatMax(target, maxsize, format, ...) - * - * Build 'target' according to 'format' and succesive - * arguments. This is equal to the sprintf() and - * snprintf() functions. - * - * StrFormatDate(target, format, ...) - * - * StrFree(target) - * - * De-allocates a string - * - * StrHash(string, type) - * - * Calculates the hash value of 'string' based on the - * 'type'. - * - * StrIndex(target, character) - * StrIndexLast(target, character) - * - * Find the first/last occurrence of 'character' in - * 'target' - * - * StrLength(target) - * - * Return the length of 'target' - * - * StrMatch(string, pattern) - * StrMatchCase(string, pattern) - * - * Find 'pattern' within 'string'. 'pattern' may contain - * wildcards such as * (asterics) and ? (question mark) - * which matches zero or more characters and exactly - * on character respectively - * - * StrScan(source, format, ...) - * - * Equal to sscanf() - * - * StrSubstring(target, substring) - * - * Find the first occurrence of the string 'substring' - * within the string 'target' - * - * StrTokenize(target, list) - * - * Split 'target' into the first token delimited by - * one of the characters in 'list'. If 'target' is - * NULL then next token will be returned. - * - * StrToUpper(target) - * - * Convert all lower case characters in 'target' into - * upper case characters. - */ - -enum { - STRIO_HASH_NONE = 0, - STRIO_HASH_PLAIN, - STRIO_HASH_TWOSIGNED -}; - -#if !defined(DEBUG) || defined(__DECC) -#define StrAlloc(n) (char *)STRIO_MALLOC(n) -#define StrAppend(x,y) strcat((x), (y)) -#define StrContains(x,y) (0 != strstr((x), (y))) -#define StrCopy(x,y) strcpy((x), (y)) -#define StrIndex(x,y) strchr((x), (y)) -#define StrIndexLast(x,y) strrchr((x), (y)) -#define StrFree(x) STRIO_FREE(x) -#define StrLength(x) strlen((x)) -#define StrSubstring(x,y) strstr((x), (y)) -#define StrTokenize(x,y) strtok((x), (y)) -#define StrToLong(x,y,n) strtol((x), (y), (n)) -#define StrToUnsignedLong(x,y,n) strtoul((x), (y), (n)) -#else /* DEBUG */ - /* - * To be able to use these macros everywhere, including in - * if() sentences, the assertions are put first in a comma - * seperated list. - * - * Unfortunately the DECC compiler does not seem to like this - * so it will use the un-asserted functions above for the - * debugging case too. - */ -#define StrAlloc(n) \ - (assert((n) > 0),\ - (char *)STRIO_MALLOC(n)) -#define StrAppend(x,y) \ - (assert((x) != NULL),\ - assert((y) != NULL),\ - strcat((x), (y))) -#define StrContains(x,y) \ - (assert((x) != NULL),\ - assert((y) != NULL),\ - (0 != strstr((x), (y)))) -#define StrCopy(x,y) \ - (assert((x) != NULL),\ - assert((y) != NULL),\ - strcpy((x), (y))) -#define StrIndex(x,c) \ - (assert((x) != NULL),\ - strchr((x), (c))) -#define StrIndexLast(x,c) \ - (assert((x) != NULL),\ - strrchr((x), (c))) -#define StrFree(x) \ - (assert((x) != NULL),\ - STRIO_FREE(x)) -#define StrLength(x) \ - (assert((x) != NULL),\ - strlen((x))) -#define StrSubstring(x,y) \ - (assert((x) != NULL),\ - assert((y) != NULL),\ - strstr((x), (y))) -#define StrTokenize(x,y) \ - (assert((y) != NULL),\ - strtok((x), (y))) -#define StrToLong(x,y,n) \ - (assert((x) != NULL),\ - assert((y) != NULL),\ - assert((n) >= 2 && (n) <= 36),\ - strtol((x), (y), (n))) -#define StrToUnsignedLong(x,y,n) \ - (assert((x) != NULL),\ - assert((y) != NULL),\ - assert((n) >= 2 && (n) <= 36),\ - strtoul((x), (y), (n))) -#endif /* DEBUG */ - -char *StrAppendMax(char *target, size_t max, const char *source); -char *StrCopyMax(char *target, size_t max, const char *source); -char *StrDuplicate(const char *source); -char *StrDuplicateMax(const char *source, size_t max); -int StrEqual(const char *first, const char *second); -int StrEqualCase(const char *first, const char *second); -int StrEqualCaseMax(const char *first, size_t max, const char *second); -int StrEqualLocale(const char *first, const char *second); -int StrEqualMax(const char *first, size_t max, const char *second); -const char *StrError(int); -size_t StrFormatDateMax(char *target, size_t max, const char *format, const struct tm *datetime); -unsigned long StrHash(const char *string, int type); -int StrMatch(char *string, char *pattern); -int StrMatchCase(char *string, char *pattern); -size_t StrSpanFunction(char *source, int (*Function)(int)); -char *StrSubstringMax(const char *string, size_t max, const char *find); -float StrToFloat(const char *source, const char **target); -double StrToDouble(const char *source, const char **target); -int StrToUpper(char *target); - -#endif /* TRIO_STRIO_H */ diff --git a/org.glite.lb.common/src/trio.c b/org.glite.lb.common/src/trio.c deleted file mode 100644 index d46736e..0000000 --- a/org.glite.lb.common/src/trio.c +++ /dev/null @@ -1,5708 +0,0 @@ - -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 1998 Bjorn Reese and Daniel Stenberg. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************* - * - * A note to trio contributors: - * - * Avoid heap allocation at all costs to ensure that the trio functions - * are async-safe. The exceptions are the printf/fprintf functions, which - * uses fputc, and the asprintf functions and the modifier, which - * by design are required to allocate form the heap. - * - ************************************************************************/ - -/* - * TODO: - * - Scan is probably too permissive about its modifiers. - * - C escapes in %#[] ? - * - C99 support has not been properly tested. - * - Multibyte characters (done for format parsing, except scan groups) - * - Complex numbers? (C99 _Complex) - * - Boolean values? (C99 _Bool) - * - C99 NaN(n-char-sequence) missing - * - Should we support the GNU %a alloc modifier? GNU has an ugly hack - * for %a, because C99 used %a for other purposes. If specified as - * %as or %a[ it is interpreted as the alloc modifier, otherwise as - * the C99 hex-float. This means that you cannot scan %as as a hex-float - * immediately followed by an 's'. - * - Scanning of collating symbols. - */ - -static const char rcsid[] = "@(#)$Id$"; - -/************************************************************************* - * Trio include files - */ -#include "trio.h" -#include "triop.h" -#include "strio.h" - -#ifdef DATAGRID_EXTENSION -#include "glite/lb/events.h" -#include "escape.h" -//#include "edg/workload/thirdparty/trio/events.h" -#endif - -/* - * Encode the error code and the position. This is decoded - * with TRIO_ERROR_CODE and TRIO_ERROR_POSITION. - */ -#if TRIO_ERRORS -# define TRIO_ERROR_RETURN(x,y) (- ((x) + ((y) << 8))) -#else -# define TRIO_ERROR_RETURN(x,y) (-1) -#endif - - -/************************************************************************* - * Platform and compiler support detection - */ -#if defined(unix) || defined(__xlC__) || defined(_AIX) || defined(__QNX__) -# define PLATFORM_UNIX -#elif defined(AMIGA) && defined(__GNUC__) -# define PLATFORM_UNIX -#elif defined(WIN32) || defined(_WIN32) || defined(_MSC_VER) -# define PLATFORM_WIN32 -# define TRIO_MSVC_5 1100 -#endif - -#if defined(__STDC__) && defined(__STDC_VERSION__) -# if (__STDC_VERSION__ >= 199409L) -# define TRIO_COMPILER_SUPPORTS_ISO94 -# endif -# if (__STDC_VERSION__ >= 199901L) -# define TRIO_COMPILER_SUPPORTS_C99 -# endif -#endif - -#if defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED) -# define TRIO_COMPILER_SUPPORTS_UNIX98 -#endif - -#if defined(__STDC_ISO_10646__) || defined(MB_LEN_MAX) || defined(USE_MULTIBYTE) || TRIO_WIDECHAR -# define TRIO_COMPILER_SUPPORTS_MULTIBYTE -# if !defined(MB_LEN_MAX) -# define MB_LEN_MAX 6 -# endif -#endif - - -/************************************************************************* - * Generic definitions - */ - -#if !(defined(DEBUG) || defined(NDEBUG)) -# define NDEBUG -#endif -#include -#include -#if !defined(TRIO_COMPILER_SUPPORTS_C99) && !defined(isblank) -# define isblank(x) (((x)==32) || ((x)==9)) -#endif -#include -#include -#include -#include -#include -#include - -#ifndef NULL -# define NULL 0 -#endif -#define NIL ((char)0) -#ifndef FALSE -# define FALSE (1 == 0) -# define TRUE (! FALSE) -#endif -#define BOOLEAN_T int - -/* mincore() can be used for debugging purposes */ -#define VALID(x) (NULL != (x)) - -/* xlC crashes on log10(0) */ -#define guarded_log10(x) (((x) == 0.0) ? -HUGE_VAL : log10(x)) -#define guarded_log16(x) (guarded_log10(x) / log10(16.0)) - - -/************************************************************************* - * Platform specific definitions - */ -#if defined(PLATFORM_UNIX) -# include -# include -# include -# define USE_LOCALE -#endif /* PLATFORM_UNIX */ -#if defined(PLATFORM_WIN32) -# include -# define read _read -# define write _write -#endif /* PLATFORM_WIN32 */ - -#if TRIO_WIDECHAR -# if defined(TRIO_COMPILER_SUPPORTS_ISO94) -# include -# include -# else -typedef char wchar_t; -typedef int wint_t; -# define WEOF EOF -# define iswalnum(x) isalnum(x) -# define iswalpha(x) isalpha(x) -# define iswblank(x) isblank(x) -# define iswcntrl(x) iscntrl(x) -# define iswdigit(x) isdigit(x) -# define iswgraph(x) isgraph(x) -# define iswlower(x) islower(x) -# define iswprint(x) isprint(x) -# define iswpunct(x) ispunct(x) -# define iswspace(x) isspace(x) -# define iswupper(x) isupper(x) -# define iswxdigit(x) isxdigit(x) -# endif -#endif - - -/************************************************************************* - * Compiler dependent definitions - */ - -/* Support for long long */ -#ifndef __cplusplus -# if !defined(USE_LONGLONG) -# if defined(__GNUC__) && !defined(__STRICT_ANSI__) -# define USE_LONGLONG -# elif defined(__SUNPRO_C) -# define USE_LONGLONG -# elif defined(_LONG_LONG) || defined(_LONGLONG) -# define USE_LONGLONG -# endif -# endif -#endif - -/* The extra long numbers */ -#if defined(USE_LONGLONG) -typedef signed long long int trio_longlong_t; -typedef unsigned long long int trio_ulonglong_t; -#elif defined(_MSC_VER) -# if (_MSC_VER >= TRIO_MSVC_5) -typedef signed __int64 trio_longlong_t; -typedef unsigned __int64 trio_ulonglong_t; -# else -typedef signed long int trio_longlong_t; -typedef unsigned long int trio_ulonglong_t; -# endif -#else -typedef signed long int trio_longlong_t; -typedef unsigned long int trio_ulonglong_t; -#endif - -/* Maximal and fixed integer types */ -#if defined(TRIO_COMPILER_SUPPORTS_C99) -# include -typedef intmax_t trio_intmax_t; -typedef uintmax_t trio_uintmax_t; -typedef int8_t trio_int8_t; -typedef int16_t trio_int16_t; -typedef int32_t trio_int32_t; -typedef int64_t trio_int64_t; -#elif defined(TRIO_COMPILER_SUPPORTS_UNIX98) -# include -typedef intmax_t trio_intmax_t; -typedef uintmax_t trio_uintmax_t; -typedef int8_t trio_int8_t; -typedef int16_t trio_int16_t; -typedef int32_t trio_int32_t; -typedef int64_t trio_int64_t; -#elif defined(_MSC_VER) && (_MSC_VER >= TRIO_MSVC_5) -typedef trio_longlong_t trio_intmax_t; -typedef trio_ulonglong_t trio_uintmax_t; -typedef __int8 trio_int8_t; -typedef __int16 trio_int16_t; -typedef __int32 trio_int32_t; -typedef __int64 trio_int64_t; -#else -typedef trio_longlong_t trio_intmax_t; -typedef trio_ulonglong_t trio_uintmax_t; -# if defined(TRIO_INT8_T) -typedef TRIO_INT8_T trio_int8_t; -# else -typedef signed char trio_int8_t; -# endif -# if defined(TRIO_INT16_T) -typedef TRIO_INT16_T trio_int16_t; -# else -typedef signed short trio_int16_t; -# endif -# if defined(TRIO_INT32_T) -typedef TRIO_INT32_T trio_int32_t; -# else -typedef signed int trio_int32_t; -# endif -# if defined(TRIO_INT64_T) -typedef TRIO_INT64_T trio_int64_t; -# else -typedef trio_longlong_t trio_int64_t; -# endif -#endif - - -/************************************************************************* - * Internal definitions - */ - -/* Long double sizes */ -#ifdef LDBL_DIG -# define MAX_MANTISSA_DIGITS LDBL_DIG -# define MAX_EXPONENT_DIGITS 4 -#else -# define MAX_MANTISSA_DIGITS DBL_DIG -# define MAX_EXPONENT_DIGITS 3 -#endif - -/* The maximal number of digits is for base 2 */ -#define MAX_CHARS_IN(x) (sizeof(x) * CHAR_BIT) -/* The width of a pointer. The number of bits in a hex digit is 4 */ -#define POINTER_WIDTH ((sizeof("0x") - 1) + sizeof(void *) * CHAR_BIT / 4) - -/* Infinite and Not-A-Number for floating-point */ -#define INFINITE_LOWER "inf" -#define INFINITE_UPPER "INF" -#define LONG_INFINITE_LOWER "infinite" -#define LONG_INFINITE_UPPER "INFINITE" -#define NAN_LOWER "nan" -#define NAN_UPPER "NAN" - -/* Various constants */ -enum { - TYPE_PRINT = 1, - TYPE_SCAN = 2, - - /* Flags. Use maximum 32 */ - FLAGS_NEW = 0, - FLAGS_STICKY = 1, - FLAGS_SPACE = 2 * FLAGS_STICKY, - FLAGS_SHOWSIGN = 2 * FLAGS_SPACE, - FLAGS_LEFTADJUST = 2 * FLAGS_SHOWSIGN, - FLAGS_ALTERNATIVE = 2 * FLAGS_LEFTADJUST, - FLAGS_SHORT = 2 * FLAGS_ALTERNATIVE, - FLAGS_SHORTSHORT = 2 * FLAGS_SHORT, - FLAGS_LONG = 2 * FLAGS_SHORTSHORT, - FLAGS_QUAD = 2 * FLAGS_LONG, - FLAGS_LONGDOUBLE = 2 * FLAGS_QUAD, - FLAGS_SIZE_T = 2 * FLAGS_LONGDOUBLE, - FLAGS_PTRDIFF_T = 2 * FLAGS_SIZE_T, - FLAGS_INTMAX_T = 2 * FLAGS_PTRDIFF_T, - FLAGS_NILPADDING = 2 * FLAGS_INTMAX_T, - FLAGS_UNSIGNED = 2 * FLAGS_NILPADDING, - FLAGS_UPPER = 2 * FLAGS_UNSIGNED, - FLAGS_WIDTH = 2 * FLAGS_UPPER, - FLAGS_WIDTH_PARAMETER = 2 * FLAGS_WIDTH, - FLAGS_PRECISION = 2 * FLAGS_WIDTH_PARAMETER, - FLAGS_PRECISION_PARAMETER = 2 * FLAGS_PRECISION, - FLAGS_BASE = 2 * FLAGS_PRECISION_PARAMETER, - FLAGS_BASE_PARAMETER = 2 * FLAGS_BASE, - FLAGS_FLOAT_E = 2 * FLAGS_BASE_PARAMETER, - FLAGS_FLOAT_G = 2 * FLAGS_FLOAT_E, - FLAGS_QUOTE = 2 * FLAGS_FLOAT_G, - FLAGS_WIDECHAR = 2 * FLAGS_QUOTE, - FLAGS_ALLOC = 2 * FLAGS_WIDECHAR, - FLAGS_IGNORE = 2 * FLAGS_ALLOC, - FLAGS_IGNORE_PARAMETER = 2 * FLAGS_IGNORE, - FLAGS_VARSIZE_PARAMETER = 2 * FLAGS_IGNORE_PARAMETER, - FLAGS_FIXED_SIZE = 2 * FLAGS_VARSIZE_PARAMETER, - /* Reused flags */ - FLAGS_EXCLUDE = FLAGS_SHORT, - FLAGS_USER_DEFINED = FLAGS_IGNORE, - /* Compounded flags */ - FLAGS_ALL_VARSIZES = FLAGS_LONG | FLAGS_QUAD | FLAGS_INTMAX_T | FLAGS_PTRDIFF_T | FLAGS_SIZE_T, - FLAGS_ALL_SIZES = FLAGS_ALL_VARSIZES | FLAGS_SHORTSHORT | FLAGS_SHORT, - - NO_POSITION = -1, - NO_WIDTH = 0, - NO_PRECISION = -1, - NO_SIZE = -1, - - NO_BASE = -1, - MIN_BASE = 2, - MAX_BASE = 36, - BASE_BINARY = 2, - BASE_OCTAL = 8, - BASE_DECIMAL = 10, - BASE_HEX = 16, - - /* Maximal number of allowed parameters */ - MAX_PARAMETERS = 64, - /* Maximal number of characters in class */ - MAX_CHARACTER_CLASS = UCHAR_MAX, - - /* Maximal string lengths for user-defined specifiers */ - MAX_USER_NAME = 64, - MAX_USER_DATA = 256, - - /* Maximal length of locale separator strings */ - MAX_LOCALE_SEPARATOR_LENGTH = MB_LEN_MAX, - /* Maximal number of integers in grouping */ - MAX_LOCALE_GROUPS = 64 -}; - -#define NO_GROUPING ((int)CHAR_MAX) - -/* Fundamental formatting parameter types */ -#define FORMAT_UNKNOWN 0 -#define FORMAT_INT 1 -#define FORMAT_DOUBLE 2 -#define FORMAT_CHAR 3 -#define FORMAT_STRING 4 -#define FORMAT_POINTER 5 -#define FORMAT_COUNT 6 -#define FORMAT_PARAMETER 7 -#define FORMAT_GROUP 8 -#if TRIO_GNU -# define FORMAT_ERRNO 9 -#endif -#if TRIO_EXTENSION -# define FORMAT_USER_DEFINED 10 -#endif - -/* Character constants */ -#define CHAR_IDENTIFIER '%' -#define CHAR_BACKSLASH '\\' -#define CHAR_QUOTE '\"' -#define CHAR_ADJUST ' ' - -/* Character class expressions */ -#define CLASS_ALNUM ":alnum:" -#define CLASS_ALPHA ":alpha:" -#define CLASS_CNTRL ":cntrl:" -#define CLASS_DIGIT ":digit:" -#define CLASS_GRAPH ":graph:" -#define CLASS_LOWER ":lower:" -#define CLASS_PRINT ":print:" -#define CLASS_PUNCT ":punct:" -#define CLASS_SPACE ":space:" -#define CLASS_UPPER ":upper:" -#define CLASS_XDIGIT ":xdigit:" - -/* - * SPECIFIERS: - * - * - * a Hex-float - * A Hex-float - * c Character - * C Widechar character (wint_t) - * d Decimal - * e Float - * E Float - * F Float - * F Float - * g Float - * G Float - * i Integer - * m Error message - * n Count - * o Octal - * p Pointer - * s String - * S Widechar string (wchar_t *) - * u Unsigned - * x Hex - * X Hex - * [] Group - * <> User-defined - * - * Reserved: - * - * D Binary Coded Decimal %D(length,precision) (OS/390) - */ -#define SPECIFIER_CHAR 'c' -#define SPECIFIER_STRING 's' -#define SPECIFIER_DECIMAL 'd' -#define SPECIFIER_INTEGER 'i' -#define SPECIFIER_UNSIGNED 'u' -#define SPECIFIER_OCTAL 'o' -#define SPECIFIER_HEX 'x' -#define SPECIFIER_HEX_UPPER 'X' -#define SPECIFIER_FLOAT_E 'e' -#define SPECIFIER_FLOAT_E_UPPER 'E' -#define SPECIFIER_FLOAT_F 'f' -#define SPECIFIER_FLOAT_F_UPPER 'F' -#define SPECIFIER_FLOAT_G 'g' -#define SPECIFIER_FLOAT_G_UPPER 'G' -#define SPECIFIER_POINTER 'p' -#define SPECIFIER_GROUP '[' -#define SPECIFIER_UNGROUP ']' -#define SPECIFIER_COUNT 'n' -#if TRIO_UNIX98 -# define SPECIFIER_CHAR_UPPER 'C' -# define SPECIFIER_STRING_UPPER 'S' -#endif -#if TRIO_C99 -# define SPECIFIER_HEXFLOAT 'a' -# define SPECIFIER_HEXFLOAT_UPPER 'A' -#endif -#if TRIO_GNU -# define SPECIFIER_ERRNO 'm' -#endif -#if TRIO_EXTENSION -# define SPECIFIER_BINARY 'b' -# define SPECIFIER_BINARY_UPPER 'B' -# define SPECIFIER_USER_DEFINED_BEGIN '<' -# define SPECIFIER_USER_DEFINED_END '>' -# define SPECIFIER_USER_DEFINED_SEPARATOR ':' -#endif - -/* - * QUALIFIERS: - * - * - * Numbers = d,i,o,u,x,X - * Float = a,A,e,E,f,F,g,G - * String = s - * Char = c - * - * - * 9$ Position - * Use the 9th parameter. 9 can be any number between 1 and - * the maximal argument - * - * 9 Width - * Set width to 9. 9 can be any number, but must not be postfixed - * by '$' - * - * h Short - * Numbers: - * (unsigned) short int - * - * hh Short short - * Numbers: - * (unsigned) char - * - * l Long - * Numbers: - * (unsigned) long int - * String: - * as the S specifier - * Char: - * as the C specifier - * - * ll Long Long - * Numbers: - * (unsigned) long long int - * - * L Long Double - * Float - * long double - * - * # Alternative - * Float: - * Decimal-point is always present - * String: - * non-printable characters are handled as \number - * - * Spacing - * - * + Sign - * - * - Alignment - * - * . Precision - * - * * Parameter - * print: use parameter - * scan: no parameter (ignore) - * - * q Quad - * - * Z size_t - * - * w Widechar - * - * ' Thousands/quote - * Numbers: - * Integer part grouped in thousands - * Binary numbers: - * Number grouped in nibbles (4 bits) - * String: - * Quoted string - * - * j intmax_t - * t prtdiff_t - * z size_t - * - * ! Sticky - * @ Parameter (for both print and scan) - * - * I n-bit Integer - * Numbers: - * The following options exists - * I8 = 8-bit integer - * I16 = 16-bit integer - * I32 = 32-bit integer - * I64 = 64-bit integer - */ -#define QUALIFIER_POSITION '$' -#define QUALIFIER_SHORT 'h' -#define QUALIFIER_LONG 'l' -#define QUALIFIER_LONG_UPPER 'L' -#define QUALIFIER_ALTERNATIVE '#' -#define QUALIFIER_SPACE ' ' -#define QUALIFIER_PLUS '+' -#define QUALIFIER_MINUS '-' -#define QUALIFIER_DOT '.' -#define QUALIFIER_STAR '*' -#define QUALIFIER_CIRCUMFLEX '^' -#if TRIO_C99 -# define QUALIFIER_SIZE_T 'z' -# define QUALIFIER_PTRDIFF_T 't' -# define QUALIFIER_INTMAX_T 'j' -#endif -#if TRIO_BSD || TRIO_GNU -# define QUALIFIER_QUAD 'q' -#endif -#if TRIO_GNU -# define QUALIFIER_SIZE_T_UPPER 'Z' -#endif -#if TRIO_MISC -# define QUALIFIER_WIDECHAR 'w' -#endif -#if TRIO_MICROSOFT -# define QUALIFIER_FIXED_SIZE 'I' -#endif -#if TRIO_EXTENSION -# define QUALIFIER_QUOTE '\'' -# define QUALIFIER_STICKY '!' -# define QUALIFIER_VARSIZE '&' /* This should remain undocumented */ -# define QUALIFIER_PARAM '@' /* Experimental */ -# define QUALIFIER_COLON ':' /* For scanlists */ -# define QUALIFIER_EQUAL '=' /* For scanlists */ -#endif -#if DATAGRID_EXTENSION -# define QUALIFIER_ESCAPE '|' -#endif - - -/************************************************************************* - * Internal structures - */ - -/* Parameters */ -typedef struct { - int type; - unsigned long flags; - int width; - int precision; - int base; - int varsize; -#ifdef QUALIFIER_ESCAPE - enum dg_escape { ESCAPE_NONE, ESCAPE_ULM, ESCAPE_XML, ESCAPE_SQL } escape; -#endif - int indexAfterSpecifier; - union { - char *string; -#if TRIO_WIDECHAR - wchar_t *wstring; -#endif - void *pointer; - union { - trio_uintmax_t as_signed; - trio_intmax_t as_unsigned; - } number; - double doubleNumber; - double *doublePointer; - long double longdoubleNumber; - long double *longdoublePointer; - int errorNumber; - } data; - /* For the user-defined specifier */ - char user_name[MAX_USER_NAME]; - char user_data[MAX_USER_DATA]; -} parameter_T; - -/* General trio "class" */ -typedef struct _trio_T { - void *location; - void (*OutStream)(struct _trio_T *, int); - void (*InStream)(struct _trio_T *, int *); - /* - * The number of characters that would have been written/read if - * there had been sufficient space. - */ - int processed; - /* - * The number of characters that are actually written/read. - * Processed and committed with only differ for the *nprintf - * and *nscanf functions. - */ - int committed; - int max; - int current; -} trio_T; - -/* References (for user-defined callbacks) */ -typedef struct _reference_T { - trio_T *data; - parameter_T *parameter; -} reference_T; - -/* Registered entries (for user-defined callbacks) */ -typedef struct _userdef_T { - struct _userdef_T *next; - trio_callback_t callback; - char *name; -} userdef_T; - - -/************************************************************************* - * Internal variables - */ - -static const char null[] = "(nil)"; - -#if defined(USE_LOCALE) -static struct lconv *internalLocaleValues = NULL; -#endif - -/* - * UNIX98 says "in a locale where the radix character is not defined, - * the radix character defaults to a period (.)" - */ -static char internalDecimalPoint[MAX_LOCALE_SEPARATOR_LENGTH + 1] = "."; -static char internalThousandSeparator[MAX_LOCALE_SEPARATOR_LENGTH + 1] = ","; -static char internalGrouping[MAX_LOCALE_GROUPS] = { (char)NO_GROUPING }; - -static const char internalDigitsLower[] = "0123456789abcdefghijklmnopqrstuvwxyz"; -static const char internalDigitsUpper[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -static BOOLEAN_T internalDigitsUnconverted = TRUE; -static int internalDigitArray[128]; -#if TRIO_EXTENSION -static BOOLEAN_T internalCollationUnconverted = TRUE; -static char internalCollationArray[MAX_CHARACTER_CLASS][MAX_CHARACTER_CLASS]; -#endif - -static volatile trio_callback_t internalEnterCriticalRegion = NULL; -static volatile trio_callback_t internalLeaveCriticalRegion = NULL; -static userdef_T *internalUserDef = NULL; - - -/************************************************************************* - * trio_strerror [public] - */ -const char *trio_strerror(int errorcode) -{ - /* Textual versions of the error codes */ - switch (TRIO_ERROR_CODE(errorcode)) - { - case TRIO_EOF: - return "End of file"; - case TRIO_EINVAL: - return "Invalid argument"; - case TRIO_ETOOMANY: - return "Too many arguments"; - case TRIO_EDBLREF: - return "Double reference"; - case TRIO_EGAP: - return "Reference gap"; - case TRIO_ENOMEM: - return "Out of memory"; - case TRIO_ERANGE: - return "Invalid range"; - default: - return "Unknown"; - } -} - -/************************************************************************* - * TrioIsQualifier [private] - * - * Description: - * Remember to add all new qualifiers to this function. - * QUALIFIER_POSITION must not be added. - */ -static BOOLEAN_T -TrioIsQualifier(const char ch) -{ - /* QUALIFIER_POSITION is not included */ - switch (ch) - { - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case QUALIFIER_PLUS: - case QUALIFIER_MINUS: - case QUALIFIER_SPACE: - case QUALIFIER_DOT: - case QUALIFIER_STAR: - case QUALIFIER_ALTERNATIVE: - case QUALIFIER_SHORT: - case QUALIFIER_LONG: - case QUALIFIER_LONG_UPPER: - case QUALIFIER_CIRCUMFLEX: -#if defined(QUALIFIER_SIZE_T) - case QUALIFIER_SIZE_T: -#endif -#if defined(QUALIFIER_PTRDIFF_T) - case QUALIFIER_PTRDIFF_T: -#endif -#if defined(QUALIFIER_INTMAX_T) - case QUALIFIER_INTMAX_T: -#endif -#if defined(QUALIFIER_QUAD) - case QUALIFIER_QUAD: -#endif -#if defined(QUALIFIER_SIZE_T_UPPER) - case QUALIFIER_SIZE_T_UPPER: -#endif -#if defined(QUALIFIER_WIDECHAR) - case QUALIFIER_WIDECHAR: -#endif -#if defined(QUALIFIER_QUOTE) - case QUALIFIER_QUOTE: -#endif -#if defined(QUALIFIER_STICKY) - case QUALIFIER_STICKY: -#endif -#if defined(QUALIFIER_VARSIZE) - case QUALIFIER_VARSIZE: -#endif -#if defined(QUALIFIER_PARAM) - case QUALIFIER_PARAM: -#endif -#if defined(QUALIFIER_FIXED_SIZE) - case QUALIFIER_FIXED_SIZE: -#endif -#ifdef QUALIFIER_ESCAPE - case QUALIFIER_ESCAPE: -#endif - return TRUE; - default: - return FALSE; - } -} - -/************************************************************************* - * TrioGenerateNan [private] - * - * Calculating NaN portably is difficult. Some compilers will emit - * warnings about divide by zero, and others will simply fail to - * generate a NaN. - */ -static double -TrioGenerateNaN(void) -{ -#if defined(TRIO_COMPILER_SUPPORTS_C99) - return nan(NULL); -#elif defined(DBL_QNAN) - return DBL_QNAN; -#elif defined(PLATFORM_UNIX) - double value; - void (*signal_handler)(int); - - signal_handler = signal(SIGFPE, SIG_IGN); - value = 0.0 / 0.0; - signal(SIGFPE, signal_handler); - return value; -#else - return 0.0 / 0.0; -#endif -} - -/************************************************************************* - * TrioIsNan [private] - */ -static int -TrioIsNan(double number) -{ -#ifdef isnan - /* C99 defines isnan() as a macro */ - return isnan(number); -#else - double integral, fraction; - - return (/* NaN is the only number which does not compare to itself */ - (number != number) || - /* Fallback solution if NaN compares to NaN */ - ((number != 0.0) && - (fraction = modf(number, &integral), - integral == fraction))); -#endif -} - -/************************************************************************* - * TrioIsInfinite [private] - */ -static int -TrioIsInfinite(double number) -{ -#ifdef isinf - /* C99 defines isinf() as a macro */ - return isinf(number); -#else - return ((number == HUGE_VAL) ? 1 : ((number == -HUGE_VAL) ? -1 : 0)); -#endif -} - -/************************************************************************* - * TrioSetLocale [private] - */ -#if defined(USE_LOCALE) -static void -TrioSetLocale(void) -{ - internalLocaleValues = (struct lconv *)localeconv(); - if (internalLocaleValues) - { - if ((internalLocaleValues->decimal_point) && - (internalLocaleValues->decimal_point[0] != NIL)) - { - StrCopyMax(internalDecimalPoint, - sizeof(internalDecimalPoint), - internalLocaleValues->decimal_point); - } - if ((internalLocaleValues->thousands_sep) && - (internalLocaleValues->thousands_sep[0] != NIL)) - { - StrCopyMax(internalThousandSeparator, - sizeof(internalThousandSeparator), - internalLocaleValues->thousands_sep); - } - if ((internalLocaleValues->grouping) && - (internalLocaleValues->grouping[0] != NIL)) - { - StrCopyMax(internalGrouping, - sizeof(internalGrouping), - internalLocaleValues->grouping); - } - } -} -#endif /* defined(USE_LOCALE) */ - -/************************************************************************* - * TrioGetPosition [private] - * - * Get the %n$ position. - */ -static int -TrioGetPosition(const char *format, - int *indexPointer) -{ - char *tmpformat; - int number = 0; - int index = *indexPointer; - - number = (int)StrToLong(&format[index], &tmpformat, BASE_DECIMAL); - index = (int)(tmpformat - format); - if ((number != 0) && (QUALIFIER_POSITION == format[index++])) - { - *indexPointer = index; - /* - * number is decreased by 1, because n$ starts from 1, whereas - * the array it is indexing starts from 0. - */ - return number - 1; - } - return NO_POSITION; -} - -/************************************************************************* - * TrioFindNamespace [private] - * - * Find registered user-defined specifier. - * The prev argument is used for optimisation only. - */ -static userdef_T * -TrioFindNamespace(const char *name, userdef_T **prev) -{ - userdef_T *def; - - if (internalEnterCriticalRegion) - (void)internalEnterCriticalRegion(NULL); - - for (def = internalUserDef; def; def = def->next) - { - /* Case-sensitive string comparison */ - if (StrEqualCase(def->name, name)) - break; - - if (prev) - *prev = def; - } - - if (internalLeaveCriticalRegion) - (void)internalLeaveCriticalRegion(NULL); - - return def; -} - -/************************************************************************* - * TrioPreprocess [private] - * - * Description: - * Parse the format string - */ -static int -TrioPreprocess(int type, - const char *format, - parameter_T *parameters, - va_list arglist, - void **argarray) -{ -#if TRIO_ERRORS - /* Count the number of times a parameter is referenced */ - unsigned short usedEntries[MAX_PARAMETERS]; -#endif - /* Parameter counters */ - int parameterPosition; - int currentParam; - int maxParam = -1; - /* Utility variables */ - unsigned long flags; - int width; - int precision; - int varsize; -#ifdef QUALIFIER_ESCAPE - enum dg_escape escape; -#endif - int base; - int index; /* Index into formatting string */ - int dots; /* Count number of dots in modifier part */ - BOOLEAN_T positional; /* Does the specifier have a positional? */ - BOOLEAN_T got_sticky = FALSE; /* Are there any sticky modifiers at all? */ - /* - * indices specifies the order in which the parameters must be - * read from the va_args (this is necessary to handle positionals) - */ - int indices[MAX_PARAMETERS]; - int pos = 0; - /* Various variables */ - char ch; -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - int charlen; -#endif - int i = -1; - int num; - char *tmpformat; - - -#if TRIO_ERRORS - /* - * The 'parameters' array is not initialized, but we need to - * know which entries we have used. - */ - memset(usedEntries, 0, sizeof(usedEntries)); -#endif - - index = 0; - parameterPosition = 0; -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - mblen(NULL, 0); -#endif - - while (format[index]) - { -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - if (! isascii(format[index])) - { - /* - * Multibyte characters cannot be legal specifiers or - * modifiers, so we skip over them. - */ - charlen = mblen(&format[index], MB_LEN_MAX); - index += (charlen > 0) ? charlen : 1; - continue; /* while */ - } -#endif /* TRIO_COMPILER_SUPPORTS_MULTIBYTE */ - if (CHAR_IDENTIFIER == format[index++]) - { - if (CHAR_IDENTIFIER == format[index]) - { - index++; - continue; /* while */ - } - - flags = FLAGS_NEW; - dots = 0; - currentParam = TrioGetPosition(format, &index); - positional = (NO_POSITION != currentParam); - if (!positional) - { - /* We have no positional, get the next counter */ - currentParam = parameterPosition; - } - if(currentParam >= MAX_PARAMETERS) - { - /* Bail out completely to make the error more obvious */ - return TRIO_ERROR_RETURN(TRIO_ETOOMANY, index); - } - - if (currentParam > maxParam) - maxParam = currentParam; - - /* Default values */ - width = NO_WIDTH; - precision = NO_PRECISION; - base = NO_BASE; - varsize = NO_SIZE; -#ifdef QUALIFIER_ESCAPE - escape = ESCAPE_NONE; -#endif - - while (TrioIsQualifier(format[index])) - { - ch = format[index++]; - - switch (ch) - { - case QUALIFIER_SPACE: - flags |= FLAGS_SPACE; - break; - - case QUALIFIER_PLUS: - flags |= FLAGS_SHOWSIGN; - break; - - case QUALIFIER_MINUS: - flags |= FLAGS_LEFTADJUST; - flags &= ~FLAGS_NILPADDING; - break; - - case QUALIFIER_ALTERNATIVE: - flags |= FLAGS_ALTERNATIVE; - break; - - case QUALIFIER_DOT: - if (dots == 0) /* Precision */ - { - dots++; - - /* Skip if no precision */ - if (QUALIFIER_DOT == format[index]) - break; - - /* After the first dot we have the precision */ - flags |= FLAGS_PRECISION; - if ((QUALIFIER_STAR == format[index]) || - (QUALIFIER_PARAM == format[index])) - { - index++; - flags |= FLAGS_PRECISION_PARAMETER; - - precision = TrioGetPosition(format, &index); - if (precision == NO_POSITION) - { - parameterPosition++; - if (positional) - precision = parameterPosition; - else - { - precision = currentParam; - currentParam = precision + 1; - } - } - else - { - if (! positional) - currentParam = precision + 1; - if (width > maxParam) - maxParam = precision; - } - if (currentParam > maxParam) - maxParam = currentParam; - } - else - { - precision = StrToLong(&format[index], &tmpformat, BASE_DECIMAL); - index = (int)(tmpformat - format); - } - } - else if (dots == 1) /* Base */ - { - dots++; - - /* After the second dot we have the base */ - flags |= FLAGS_BASE; - if ((QUALIFIER_STAR == format[index]) || - (QUALIFIER_PARAM == format[index])) - { - index++; - flags |= FLAGS_BASE_PARAMETER; - base = TrioGetPosition(format, &index); - if (base == NO_POSITION) - { - parameterPosition++; - if (positional) - base = parameterPosition; - else - { - base = currentParam; - currentParam = base + 1; - } - } - else - { - if (! positional) - currentParam = base + 1; - if (base > maxParam) - maxParam = base; - } - if (currentParam > maxParam) - maxParam = currentParam; - } - else - { - base = StrToLong(&format[index], &tmpformat, BASE_DECIMAL); - if (base > MAX_BASE) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - index = (int)(tmpformat - format); - } - } - else - { - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - break; /* QUALIFIER_DOT */ - - case QUALIFIER_PARAM: - type = TYPE_PRINT; - /* FALLTHROUGH */ - case QUALIFIER_STAR: - /* This has different meanings for print and scan */ - if (TYPE_PRINT == type) - { - /* Read with from parameter */ - flags |= (FLAGS_WIDTH | FLAGS_WIDTH_PARAMETER); - width = TrioGetPosition(format, &index); - if (width == NO_POSITION) - { - parameterPosition++; - if (positional) - width = parameterPosition; - else - { - width = currentParam; - currentParam = width + 1; - } - } - else - { - if (! positional) - currentParam = width + 1; - if (width > maxParam) - maxParam = width; - } - if (currentParam > maxParam) - maxParam = currentParam; - } - else - { - /* Scan, but do not store result */ - flags |= FLAGS_IGNORE; - } - - break; /* QUALIFIER_STAR */ - - case '0': - if (! (flags & FLAGS_LEFTADJUST)) - flags |= FLAGS_NILPADDING; - /* FALLTHROUGH */ - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - flags |= FLAGS_WIDTH; - /* &format[index - 1] is used to "rewind" the read - * character from format - */ - width = StrToLong(&format[index - 1], &tmpformat, BASE_DECIMAL); - index = (int)(tmpformat - format); - break; - - case QUALIFIER_SHORT: - if (flags & FLAGS_SHORTSHORT) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - else if (flags & FLAGS_SHORT) - flags |= FLAGS_SHORTSHORT; - else - flags |= FLAGS_SHORT; - break; - - case QUALIFIER_LONG: - if (flags & FLAGS_QUAD) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - else if (flags & FLAGS_LONG) - flags |= FLAGS_QUAD; - else - flags |= FLAGS_LONG; - break; - - case QUALIFIER_LONG_UPPER: - flags |= FLAGS_LONGDOUBLE; - break; - -#if defined(QUALIFIER_SIZE_T) - case QUALIFIER_SIZE_T: - flags |= FLAGS_SIZE_T; - /* Modify flags for later truncation of number */ - if (sizeof(size_t) == sizeof(trio_ulonglong_t)) - flags |= FLAGS_QUAD; - else if (sizeof(size_t) == sizeof(long)) - flags |= FLAGS_LONG; - break; -#endif - -#if defined(QUALIFIER_PTRDIFF_T) - case QUALIFIER_PTRDIFF_T: - flags |= FLAGS_PTRDIFF_T; - if (sizeof(ptrdiff_t) == sizeof(trio_ulonglong_t)) - flags |= FLAGS_QUAD; - else if (sizeof(ptrdiff_t) == sizeof(long)) - flags |= FLAGS_LONG; - break; -#endif - -#if defined(QUALIFIER_INTMAX_T) - case QUALIFIER_INTMAX_T: - flags |= FLAGS_INTMAX_T; - if (sizeof(trio_intmax_t) == sizeof(trio_ulonglong_t)) - flags |= FLAGS_QUAD; - else if (sizeof(trio_intmax_t) == sizeof(long)) - flags |= FLAGS_LONG; - break; -#endif - -#if defined(QUALIFIER_QUAD) - case QUALIFIER_QUAD: - flags |= FLAGS_QUAD; - break; -#endif - -#if defined(QUALIFIER_FIXED_SIZE) - case QUALIFIER_FIXED_SIZE: - if (flags & FLAGS_FIXED_SIZE) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - - if (flags & (FLAGS_ALL_SIZES | FLAGS_LONGDOUBLE | - FLAGS_WIDECHAR | FLAGS_VARSIZE_PARAMETER)) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - - if ((format[index] == '6') && - (format[index + 1] == '4')) - { - varsize = sizeof(trio_int64_t); - index += 2; - } - else if ((format[index] == '3') && - (format[index + 1] == '2')) - { - varsize = sizeof(trio_int32_t); - index += 2; - } - else if ((format[index] == '1') && - (format[index + 1] == '6')) - { - varsize = sizeof(trio_int16_t); - index += 2; - } - else if (format[index] == '8') - { - varsize = sizeof(trio_int8_t); - index++; - } - else - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - - flags |= FLAGS_FIXED_SIZE; - break; -#endif - -#ifdef QUALIFIER_ESCAPE - case QUALIFIER_ESCAPE: - switch (format[index++]) { - case 'U': escape = ESCAPE_ULM; break; - case 'X': escape = ESCAPE_XML; break; - case 'S': escape = ESCAPE_SQL; break; - default: return TRIO_ERROR_RETURN(TRIO_EINVAL,index); - } - break; -#endif - - -#if defined(QUALIFIER_WIDECHAR) - case QUALIFIER_WIDECHAR: - flags |= FLAGS_WIDECHAR; - break; -#endif - -#if defined(QUALIFIER_SIZE_T_UPPER) - case QUALIFIER_SIZE_T_UPPER: - break; -#endif - -#if defined(QUALIFIER_QUOTE) - case QUALIFIER_QUOTE: - flags |= FLAGS_QUOTE; - break; -#endif - -#if defined(QUALIFIER_STICKY) - case QUALIFIER_STICKY: - flags |= FLAGS_STICKY; - got_sticky = TRUE; - break; -#endif - -#if defined(QUALIFIER_VARSIZE) - case QUALIFIER_VARSIZE: - flags |= FLAGS_VARSIZE_PARAMETER; - parameterPosition++; - if (positional) - varsize = parameterPosition; - else - { - varsize = currentParam; - currentParam = varsize + 1; - } - if (currentParam > maxParam) - maxParam = currentParam; - break; -#endif - - default: - /* Bail out completely to make the error more obvious */ - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - } /* while qualifier */ - - /* - * Parameters only need the type and value. The value is - * read later. - */ - if (flags & FLAGS_WIDTH_PARAMETER) - { -#if TRIO_ERRORS - usedEntries[width] += 1; -#endif - parameters[pos].type = FORMAT_PARAMETER; - indices[width] = pos; - width = pos++; - } - if (flags & FLAGS_PRECISION_PARAMETER) - { -#if TRIO_ERRORS - usedEntries[precision] += 1; -#endif - parameters[pos].type = FORMAT_PARAMETER; - indices[precision] = pos; - precision = pos++; - } - if (flags & FLAGS_BASE_PARAMETER) - { -#if TRIO_ERRORS - usedEntries[base] += 1; -#endif - parameters[pos].type = FORMAT_PARAMETER; - indices[base] = pos; - base = pos++; - } - if (flags & FLAGS_VARSIZE_PARAMETER) - { -#if TRIO_ERRORS - usedEntries[varsize] += 1; -#endif - parameters[pos].type = FORMAT_PARAMETER; - indices[varsize] = pos; - varsize = pos++; - } - - indices[currentParam] = pos; - - switch (format[index++]) - { -#if defined(SPECIFIER_CHAR_UPPER) - case SPECIFIER_CHAR_UPPER: - flags |= FLAGS_WIDECHAR; - /* FALLTHROUGH */ -#endif - case SPECIFIER_CHAR: - if (flags & FLAGS_LONG) - flags |= FLAGS_WIDECHAR; - else if (flags & FLAGS_SHORT) - flags &= ~FLAGS_WIDECHAR; - parameters[pos].type = FORMAT_CHAR; - break; - -#if defined(SPECIFIER_STRING_UPPER) - case SPECIFIER_STRING_UPPER: - flags |= FLAGS_WIDECHAR; - /* FALLTHROUGH */ -#endif - case SPECIFIER_STRING: - if (flags & FLAGS_LONG) - flags |= FLAGS_WIDECHAR; - else if (flags & FLAGS_SHORT) - flags &= ~FLAGS_WIDECHAR; - parameters[pos].type = FORMAT_STRING; - break; - - - case SPECIFIER_GROUP: - if (TYPE_SCAN == type) - { - int depth = 1; - parameters[pos].type = FORMAT_GROUP; - if (format[index] == QUALIFIER_CIRCUMFLEX) - index++; - if (format[index] == SPECIFIER_UNGROUP) - index++; - if (format[index] == QUALIFIER_MINUS) - index++; - /* Skip nested brackets */ - while (format[index] != NIL) - { - if (format[index] == SPECIFIER_GROUP) - { - depth++; - } - else if (format[index] == SPECIFIER_UNGROUP) - { - if (--depth <= 0) - { - index++; - break; - } - } - index++; - } - } - break; - - case SPECIFIER_INTEGER: - parameters[pos].type = FORMAT_INT; - break; - - case SPECIFIER_UNSIGNED: - flags |= FLAGS_UNSIGNED; - parameters[pos].type = FORMAT_INT; - break; - - case SPECIFIER_DECIMAL: - /* Disable base modifier */ - flags &= ~FLAGS_BASE_PARAMETER; - base = BASE_DECIMAL; - parameters[pos].type = FORMAT_INT; - break; - - case SPECIFIER_OCTAL: - flags &= ~FLAGS_BASE_PARAMETER; - base = BASE_OCTAL; - parameters[pos].type = FORMAT_INT; - break; - -#if defined(SPECIFIER_BINARY) - case SPECIFIER_BINARY_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ - case SPECIFIER_BINARY: - flags |= FLAGS_NILPADDING; - flags &= ~FLAGS_BASE_PARAMETER; - base = BASE_BINARY; - parameters[pos].type = FORMAT_INT; - break; -#endif - - case SPECIFIER_HEX_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ - case SPECIFIER_HEX: - flags |= FLAGS_UNSIGNED; - flags &= ~FLAGS_BASE_PARAMETER; - base = BASE_HEX; - parameters[pos].type = FORMAT_INT; - break; - - case SPECIFIER_FLOAT_E_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ - case SPECIFIER_FLOAT_E: - flags |= FLAGS_FLOAT_E; - parameters[pos].type = FORMAT_DOUBLE; - break; - - case SPECIFIER_FLOAT_G_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ - case SPECIFIER_FLOAT_G: - flags |= FLAGS_FLOAT_G; - parameters[pos].type = FORMAT_DOUBLE; - break; - - case SPECIFIER_FLOAT_F_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ - case SPECIFIER_FLOAT_F: - parameters[pos].type = FORMAT_DOUBLE; - break; - - case SPECIFIER_POINTER: - parameters[pos].type = FORMAT_POINTER; - break; - - case SPECIFIER_COUNT: - parameters[pos].type = FORMAT_COUNT; - break; - -#if defined(SPECIFIER_HEXFLOAT) -# if defined(SPECIFIER_HEXFLOAT_UPPER) - case SPECIFIER_HEXFLOAT_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ -# endif - case SPECIFIER_HEXFLOAT: - base = BASE_HEX; - parameters[pos].type = FORMAT_DOUBLE; - break; -#endif - -#if defined(FORMAT_ERRNO) - case SPECIFIER_ERRNO: - parameters[pos].type = FORMAT_ERRNO; - break; -#endif - -#if defined(SPECIFIER_USER_DEFINED_BEGIN) - case SPECIFIER_USER_DEFINED_BEGIN: - { - unsigned int max; - int without_namespace = TRUE; - - parameters[pos].type = FORMAT_USER_DEFINED; - parameters[pos].user_name[0] = NIL; - tmpformat = (char *)&format[index]; - - while ((ch = format[index])) - { - index++; - if (ch == SPECIFIER_USER_DEFINED_END) - { - if (without_namespace) - { - /* We must get the handle first */ - parameters[pos].type = FORMAT_PARAMETER; - parameters[pos].indexAfterSpecifier = index; - parameters[pos].flags = FLAGS_USER_DEFINED; - /* Adjust parameters for insertion of new one */ - pos++; -# if TRIO_ERRORS - usedEntries[currentParam] += 1; -# endif - parameters[pos].type = FORMAT_USER_DEFINED; - currentParam++; - indices[currentParam] = pos; - if (currentParam > maxParam) - maxParam = currentParam; - } - /* Copy the user data */ - max = (unsigned int)(&format[index] - tmpformat); - if (max > MAX_USER_DATA) - max = MAX_USER_DATA; - StrCopyMax(parameters[pos].user_data, - max, - tmpformat); - break; /* while */ - } - if (ch == SPECIFIER_USER_DEFINED_SEPARATOR) - { - without_namespace = FALSE; - /* Copy the namespace for later looking-up */ - max = (int)(&format[index] - tmpformat); - if (max > MAX_USER_NAME) - max = MAX_USER_NAME; - StrCopyMax(parameters[pos].user_name, - max, - tmpformat); - tmpformat = (char *)&format[index]; - } - } - if (ch != SPECIFIER_USER_DEFINED_END) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - break; -#endif /* defined(SPECIFIER_USER_DEFINED_BEGIN) */ - - default: - /* Bail out completely to make the error more obvious */ - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - -#if TRIO_ERRORS - /* Count the number of times this entry has been used */ - usedEntries[currentParam] += 1; -#endif - - /* Find last sticky parameters */ - if (got_sticky && !(flags & FLAGS_STICKY)) - { - for (i = pos - 1; i >= 0; i--) - { - if (parameters[i].type == FORMAT_PARAMETER) - continue; - if ((parameters[i].flags & FLAGS_STICKY) && - (parameters[i].type == parameters[pos].type)) - { - /* Do not overwrite current qualifiers */ - flags |= (parameters[i].flags & (unsigned long)~FLAGS_STICKY); - if (width == NO_WIDTH) - width = parameters[i].width; - if (precision == NO_PRECISION) - precision = parameters[i].precision; - if (base == NO_BASE) - base = parameters[i].base; - break; - } - } - } - - parameters[pos].indexAfterSpecifier = index; - parameters[pos].flags = flags; - parameters[pos].width = width; - parameters[pos].precision = precision; - parameters[pos].base = (base == NO_BASE) ? BASE_DECIMAL : base; - parameters[pos].varsize = varsize; -#ifdef QUALIFIER_ESCAPE - parameters[pos].escape = escape; -#endif - pos++; - - if (! positional) - parameterPosition++; - - } /* if identifier */ - - } /* while format characters left */ - - for (num = 0; num <= maxParam; num++) - { -#if TRIO_ERRORS - if (usedEntries[num] != 1) - { - if (usedEntries[num] == 0) /* gap detected */ - return TRIO_ERROR_RETURN(TRIO_EGAP, num); - else /* double references detected */ - return TRIO_ERROR_RETURN(TRIO_EDBLREF, num); - } -#endif - - i = indices[num]; - - /* - * FORMAT_PARAMETERS are only present if they must be read, - * so it makes no sense to check the ignore flag (besides, - * the flags variable is not set for that particular type) - */ - if ((parameters[i].type != FORMAT_PARAMETER) && - (parameters[i].flags & FLAGS_IGNORE)) - continue; /* for all arguments */ - - /* - * The stack arguments are read according to ANSI C89 - * default argument promotions: - * - * char = int - * short = int - * unsigned char = unsigned int - * unsigned short = unsigned int - * float = double - * - * In addition to the ANSI C89 these types are read (the - * default argument promotions of C99 has not been - * considered yet) - * - * long long - * long double - * size_t - * ptrdiff_t - * intmax_t - */ - switch (parameters[i].type) - { - case FORMAT_GROUP: - case FORMAT_STRING: -#if TRIO_WIDECHAR - if (flags & FLAGS_WIDECHAR) - { - parameters[i].data.wstring = (argarray == NULL) - ? va_arg(arglist, wchar_t *) - : (wchar_t *)(argarray[num]); - } - else -#endif - { - parameters[i].data.string = (argarray == NULL) - ? va_arg(arglist, char *) - : (char *)(argarray[num]); - } - break; - - case FORMAT_POINTER: - case FORMAT_COUNT: - case FORMAT_USER_DEFINED: - case FORMAT_UNKNOWN: - parameters[i].data.pointer = (argarray == NULL) - ? va_arg(arglist, void *) - : argarray[num]; - break; - - case FORMAT_CHAR: - case FORMAT_INT: - if (TYPE_SCAN == type) - { - if (argarray == NULL) - parameters[i].data.pointer = - (trio_uintmax_t *)va_arg(arglist, void *); - else - { - if (parameters[i].type == FORMAT_CHAR) - parameters[i].data.pointer = - (trio_uintmax_t *)((char *)argarray[num]); - else if (parameters[i].flags & FLAGS_SHORT) - parameters[i].data.pointer = - (trio_uintmax_t *)((short *)argarray[num]); - else - parameters[i].data.pointer = - (trio_uintmax_t *)((int *)argarray[num]); - } - } - else - { -#if defined(QUALIFIER_VARSIZE) || defined(QUALIFIER_FIXED_SIZE) - if ((parameters[i].flags & FLAGS_VARSIZE_PARAMETER) || - (parameters[i].flags & FLAGS_FIXED_SIZE)) - { - if (parameters[i].flags & FLAGS_VARSIZE_PARAMETER) - { - /* - * Variable sizes are mapped onto the fixed sizes, in - * accordance with integer promotion. - * - * Please note that this may not be portable, as we - * only guess the size, not the layout of the numbers. - * For example, if int is little-endian, and long is - * big-endian, then this will fail. - */ - varsize = (int)parameters[parameters[i].varsize].data.number.as_unsigned; - } - else - { - /* Used for the I modifiers */ - varsize = parameters[i].varsize; - } - parameters[i].flags &= ~FLAGS_ALL_VARSIZES; - - if (varsize <= (int)sizeof(int)) - ; - else if (varsize <= (int)sizeof(long)) - parameters[i].flags |= FLAGS_LONG; -#if defined(QUALIFIER_INTMAX_T) - else if (varsize <= (int)sizeof(trio_longlong_t)) - parameters[i].flags |= FLAGS_QUAD; - else - parameters[i].flags |= FLAGS_INTMAX_T; -#else - else - parameters[i].flags |= FLAGS_QUAD; -#endif - } -#endif /* defined(QUALIFIER_VARSIZE) */ -#if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) - if (parameters[i].flags & FLAGS_SIZE_T) - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(arglist, size_t) - : (trio_uintmax_t)(*((size_t *)argarray[num])); - else -#endif -#if defined(QUALIFIER_PTRDIFF_T) - if (parameters[i].flags & FLAGS_PTRDIFF_T) - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(arglist, ptrdiff_t) - : (trio_uintmax_t)(*((ptrdiff_t *)argarray[num])); - else -#endif -#if defined(QUALIFIER_INTMAX_T) - if (parameters[i].flags & FLAGS_INTMAX_T) - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(arglist, trio_intmax_t) - : (trio_uintmax_t)(*((trio_intmax_t *)argarray[num])); - else -#endif - if (parameters[i].flags & FLAGS_QUAD) - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(arglist, trio_ulonglong_t) - : (trio_uintmax_t)(*((trio_ulonglong_t *)argarray[num])); - else if (parameters[i].flags & FLAGS_LONG) - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(arglist, long) - : (trio_uintmax_t)(*((long *)argarray[num])); - else - { - if (argarray == NULL) - parameters[i].data.number.as_unsigned = (trio_uintmax_t)va_arg(arglist, int); - else - { - if (parameters[i].type == FORMAT_CHAR) - parameters[i].data.number.as_unsigned = (trio_uintmax_t)(*((char *)argarray[num])); - else if (parameters[i].flags & FLAGS_SHORT) - parameters[i].data.number.as_unsigned = (trio_uintmax_t)(*((short *)argarray[num])); - else - parameters[i].data.number.as_unsigned = (trio_uintmax_t)(*((int *)argarray[num])); - } - } - } - break; - - case FORMAT_PARAMETER: - /* - * The parameter for the user-defined specifier is a pointer, - * whereas the rest (width, precision, base) uses an integer. - */ - if (parameters[i].flags & FLAGS_USER_DEFINED) - parameters[i].data.pointer = (argarray == NULL) - ? va_arg(arglist, void *) - : argarray[num]; - else - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(arglist, int) - : (trio_uintmax_t)(*((int *)argarray[num])); - break; - - case FORMAT_DOUBLE: - if (TYPE_SCAN == type) - { - if (parameters[i].flags & FLAGS_LONG) - parameters[i].data.longdoublePointer = (argarray == NULL) - ? va_arg(arglist, long double *) - : (long double *)((long double *)argarray[num]); - else - { - if (argarray == NULL) - parameters[i].data.doublePointer = - va_arg(arglist, double *); - else - { - if (parameters[i].flags & FLAGS_SHORT) - parameters[i].data.doublePointer = - (double *)((float *)argarray[num]); - else - parameters[i].data.doublePointer = - (double *)((double *)argarray[num]); - } - } - } - else - { - if (parameters[i].flags & FLAGS_LONG) - parameters[i].data.longdoubleNumber = (argarray == NULL) - ? va_arg(arglist, long double) - : (long double)(*((long double *)argarray[num])); - else - { - if (argarray == NULL) - parameters[i].data.longdoubleNumber = (long double)va_arg(arglist, double); - else - { - if (parameters[i].flags & FLAGS_SHORT) - parameters[i].data.longdoubleNumber = (long double)(*((float *)argarray[num])); - else - parameters[i].data.longdoubleNumber = (long double)(long double)(*((double *)argarray[num])); - } - } - } - break; - -#if defined(FORMAT_ERRNO) - case FORMAT_ERRNO: - parameters[i].data.errorNumber = errno; - break; -#endif - - default: - break; - } - } /* for all specifiers */ - return num; -} - - -/************************************************************************* - * - * @FORMATTING - * - ************************************************************************/ - - -/************************************************************************* - * TrioWriteNumber [private] - * - * Description: - * Output a number. - * The complexity of this function is a result of the complexity - * of the dependencies of the flags. - */ -static void -TrioWriteNumber(trio_T *self, - trio_uintmax_t number, - unsigned long flags, - int width, - int precision, - int base) -{ - BOOLEAN_T isNegative; - char buffer[MAX_CHARS_IN(trio_uintmax_t) * (1 + MAX_LOCALE_SEPARATOR_LENGTH) + 1]; - char *bufferend; - char *pointer; - const char *digits; - int i; - int length; - char *p; - int charsPerThousand; - int groupingIndex; - int count; - - assert(VALID(self)); - assert(VALID(self->OutStream)); - assert((base >= MIN_BASE && base <= MAX_BASE) || (base == NO_BASE)); - - digits = (flags & FLAGS_UPPER) ? internalDigitsUpper : internalDigitsLower; - - isNegative = (flags & FLAGS_UNSIGNED) - ? FALSE - : ((trio_intmax_t)number < 0); - if (isNegative) - number = -number; - - if (flags & FLAGS_QUAD) - number &= (trio_ulonglong_t)-1; - else if (flags & FLAGS_LONG) - number &= (unsigned long)-1; - else - number &= (unsigned int)-1; - - /* Build number */ - pointer = bufferend = &buffer[sizeof(buffer) - 1]; - *pointer-- = NIL; - charsPerThousand = (int)internalGrouping[0]; - groupingIndex = 1; - for (i = 1; i < (int)sizeof(buffer); i++) - { - *pointer-- = digits[number % base]; - number /= base; - if (number == 0) - break; - - if ((flags & FLAGS_QUOTE) - && (charsPerThousand != NO_GROUPING) - && (i % charsPerThousand == 0)) - { - /* - * We are building the number from the least significant - * to the most significant digit, so we have to copy the - * thousand separator backwards - */ - length = StrLength(internalThousandSeparator); - if (((int)(pointer - buffer) - length) > 0) - { - p = &internalThousandSeparator[length - 1]; - while (length-- > 0) - *pointer-- = *p--; - } - - /* Advance to next grouping number */ - switch (internalGrouping[groupingIndex]) - { - case CHAR_MAX: /* Disable grouping */ - charsPerThousand = NO_GROUPING; - break; - case 0: /* Repeat last group */ - break; - default: - charsPerThousand = (int)internalGrouping[groupingIndex++]; - break; - } - } - } - - /* Adjust width */ - width -= (bufferend - pointer) - 1; - - /* Adjust precision */ - if (NO_PRECISION != precision) - { - precision -= (bufferend - pointer) - 1; - if (precision < 0) - precision = 0; - flags |= FLAGS_NILPADDING; - } - - /* Adjust width further */ - if (isNegative || (flags & FLAGS_SHOWSIGN) || (flags & FLAGS_SPACE)) - width--; - if (flags & FLAGS_ALTERNATIVE) - { - switch (base) - { - case BASE_BINARY: - case BASE_HEX: - width -= 2; - break; - case BASE_OCTAL: - width--; - break; - default: - break; - } - } - - /* Output prefixes spaces if needed */ - if (! ((flags & FLAGS_LEFTADJUST) || - ((flags & FLAGS_NILPADDING) && (precision == NO_PRECISION)))) - { - count = (precision == NO_PRECISION) ? 0 : precision; - while (width-- > count) - self->OutStream(self, CHAR_ADJUST); - } - - /* width has been adjusted for signs and alternatives */ - if (isNegative) - self->OutStream(self, '-'); - else if (flags & FLAGS_SHOWSIGN) - self->OutStream(self, '+'); - else if (flags & FLAGS_SPACE) - self->OutStream(self, ' '); - - if (flags & FLAGS_ALTERNATIVE) - { - switch (base) - { - case BASE_BINARY: - self->OutStream(self, '0'); - self->OutStream(self, (flags & FLAGS_UPPER) ? 'B' : 'b'); - break; - - case BASE_OCTAL: - self->OutStream(self, '0'); - break; - - case BASE_HEX: - self->OutStream(self, '0'); - self->OutStream(self, (flags & FLAGS_UPPER) ? 'X' : 'x'); - break; - - default: - break; - } /* switch base */ - } - - /* Output prefixed zero padding if needed */ - if (flags & FLAGS_NILPADDING) - { - if (precision == NO_PRECISION) - precision = width; - while (precision-- > 0) - { - self->OutStream(self, '0'); - width--; - } - } - - /* Output the number itself */ - while (*(++pointer)) - { - self->OutStream(self, *pointer); - } - - /* Output trailing spaces if needed */ - if (flags & FLAGS_LEFTADJUST) - { - while (width-- > 0) - self->OutStream(self, CHAR_ADJUST); - } -} - -/************************************************************************* - * TrioWriteStringCharacter [private] - * - * Description: - * Output a single character of a string - */ -static void -TrioWriteStringCharacter(trio_T *self, - int ch, - unsigned long flags) -{ - if (flags & FLAGS_ALTERNATIVE) - { - if (! (isprint(ch) || isspace(ch))) - { - /* - * Non-printable characters are converted to C escapes or - * \number, if no C escape exists. - */ - self->OutStream(self, CHAR_BACKSLASH); - switch (ch) - { - case '\007': self->OutStream(self, 'a'); break; - case '\b': self->OutStream(self, 'b'); break; - case '\f': self->OutStream(self, 'f'); break; - case '\n': self->OutStream(self, 'n'); break; - case '\r': self->OutStream(self, 'r'); break; - case '\t': self->OutStream(self, 't'); break; - case '\v': self->OutStream(self, 'v'); break; - case '\\': self->OutStream(self, '\\'); break; - default: - self->OutStream(self, 'x'); - TrioWriteNumber(self, (trio_intmax_t)ch, - FLAGS_UNSIGNED | FLAGS_NILPADDING, - 2, 2, BASE_HEX); - break; - } - } - else if (ch == CHAR_BACKSLASH) - { - self->OutStream(self, CHAR_BACKSLASH); - self->OutStream(self, CHAR_BACKSLASH); - } - else - { - self->OutStream(self, ch); - } - } - else - { - self->OutStream(self, ch); - } -} - -/************************************************************************* - * TrioWriteString [private] - * - * Description: - * Output a string - */ -static void -TrioWriteString(trio_T *self, - const char *string, - unsigned long flags, - int width, - int precision) -{ - int length; - int ch; - - assert(VALID(self)); - assert(VALID(self->OutStream)); - - if (string == NULL) - { - string = null; - length = sizeof(null) - 1; - /* Disable quoting for the null pointer */ - flags &= (~FLAGS_QUOTE); - width = 0; - } - else - { - length = StrLength(string); - } - if ((NO_PRECISION != precision) && - (precision < length)) - { - length = precision; - } - width -= length; - - if (flags & FLAGS_QUOTE) - self->OutStream(self, CHAR_QUOTE); - - if (! (flags & FLAGS_LEFTADJUST)) - { - while (width-- > 0) - self->OutStream(self, CHAR_ADJUST); - } - - while (length-- > 0) - { - /* The ctype parameters must be an unsigned char (or EOF) */ - ch = (int)((unsigned char)(*string++)); - TrioWriteStringCharacter(self, ch, flags); - } - - if (flags & FLAGS_LEFTADJUST) - { - while (width-- > 0) - self->OutStream(self, CHAR_ADJUST); - } - if (flags & FLAGS_QUOTE) - self->OutStream(self, CHAR_QUOTE); -} - -/************************************************************************* - * TrioWriteWideStringCharacter [private] - * - * Description: - * Output a wide string as a multi-byte sequence - */ -#if TRIO_WIDECHAR -static int -TrioWriteWideStringCharacter(trio_T *self, - wchar_t wch, - unsigned long flags, - int width) -{ - int size; - int i; - int ch; - char *string; - char buffer[MB_LEN_MAX + 1]; - - if (width == NO_WIDTH) - width = sizeof(buffer); - - size = wctomb(buffer, wch); - if ((size <= 0) || (size > width) || (buffer[0] == NIL)) - return 0; - - string = buffer; - i = size; - while ((width >= i) && (width-- > 0) && (i-- > 0)) - { - /* The ctype parameters must be an unsigned char (or EOF) */ - ch = (int)((unsigned char)(*string++)); - TrioWriteStringCharacter(self, ch, flags); - } - return size; -} -#endif /* TRIO_WIDECHAR */ - -/************************************************************************* - * TrioWriteString [private] - * - * Description: - * Output a wide character string as a multi-byte string - */ -#if TRIO_WIDECHAR -static void -TrioWriteWideString(trio_T *self, - const wchar_t *wstring, - unsigned long flags, - int width, - int precision) -{ - int length; - int size; - - assert(VALID(self)); - assert(VALID(self->OutStream)); - -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - mblen(NULL, 0); -#endif - - if (wstring == NULL) - { - TrioWriteString(self, NULL, flags, width, precision); - return; - } - - if (NO_PRECISION == precision) - { - length = INT_MAX; - } - else - { - length = precision; - width -= length; - } - - if (flags & FLAGS_QUOTE) - self->OutStream(self, CHAR_QUOTE); - - if (! (flags & FLAGS_LEFTADJUST)) - { - while (width-- > 0) - self->OutStream(self, CHAR_ADJUST); - } - - while (length > 0) - { - size = TrioWriteWideStringCharacter(self, *wstring++, flags, length); - if (size == 0) - break; /* while */ - length -= size; - } - - if (flags & FLAGS_LEFTADJUST) - { - while (width-- > 0) - self->OutStream(self, CHAR_ADJUST); - } - if (flags & FLAGS_QUOTE) - self->OutStream(self, CHAR_QUOTE); -} -#endif /* TRIO_WIDECHAR */ - -/************************************************************************* - * TrioWriteDouble [private] - */ -static void -TrioWriteDouble(trio_T *self, - long double longdoubleNumber, - unsigned long flags, - int width, - int precision, - int base) -{ - int charsPerThousand; - int length; - double number; - double workNumber; - int integerDigits; - int fractionDigits; - int exponentDigits; - int expectedWidth; - int exponent; - unsigned int uExponent = 0; - double dblBase; - BOOLEAN_T isNegative; - BOOLEAN_T isExponentNegative = FALSE; - BOOLEAN_T isHex; - const char *digits; - char numberBuffer[MAX_MANTISSA_DIGITS - * (1 + MAX_LOCALE_SEPARATOR_LENGTH) + 1]; - char *numberPointer; - char exponentBuffer[MAX_EXPONENT_DIGITS + 1]; - char *exponentPointer = NULL; - int groupingIndex; - char *work; - int i; - BOOLEAN_T onlyzero; - int zeroes = 0; - - assert(VALID(self)); - assert(VALID(self->OutStream)); - assert(base == BASE_DECIMAL || base == BASE_HEX); - - number = (double)longdoubleNumber; - - /* Look for infinite numbers and non-a-number first */ - switch (TrioIsInfinite(number)) - { - case 1: - /* Positive infinity */ - TrioWriteString(self, - (flags & FLAGS_UPPER) - ? INFINITE_UPPER - : INFINITE_LOWER, - flags, width, precision); - return; - - case -1: - /* Negative infinity */ - TrioWriteString(self, - (flags & FLAGS_UPPER) - ? "-" INFINITE_UPPER - : "-" INFINITE_LOWER, - flags, width, precision); - return; - - default: - /* Finitude */ - break; - } - if (TrioIsNan(number)) - { - TrioWriteString(self, - (flags & FLAGS_UPPER) - ? NAN_UPPER - : NAN_LOWER, - flags, width, precision); - return; - } - - /* Normal numbers */ - digits = (flags & FLAGS_UPPER) ? internalDigitsUpper : internalDigitsLower; - isHex = (base == BASE_HEX); - dblBase = (double)base; - - if (precision == NO_PRECISION) - precision = FLT_DIG; - - isNegative = (number < 0.0); - if (isNegative) - number = -number; - - if ((flags & FLAGS_FLOAT_G) || isHex) - { - if (precision == 0) - precision = 1; - - if ((number < 1.0e-4) || (number > pow(10.0, (double)precision))) - { - /* Use scientific notation */ - flags |= FLAGS_FLOAT_E; - } - else if (number < 1.0) - { - /* - * Use normal notation. If the integer part of the number is - * zero, then adjust the precision to include leading fractional - * zeros. - */ - workNumber = fabs(guarded_log10(number)); - if (workNumber - floor(workNumber) < 0.001) - workNumber--; - zeroes = (int)floor(workNumber); - } - } - - if (flags & FLAGS_FLOAT_E) - { - /* Scale the number */ - workNumber = guarded_log10(number); - if (workNumber == -HUGE_VAL) - { - exponent = 0; - /* Undo setting */ - if (flags & FLAGS_FLOAT_G) - flags &= ~FLAGS_FLOAT_E; - } - else - { - exponent = (int)floor(workNumber); - number /= pow(10.0, (double)exponent); - isExponentNegative = (exponent < 0); - uExponent = (isExponentNegative) ? -exponent : exponent; - /* No thousand separators */ - flags &= ~FLAGS_QUOTE; - } - } - - /* - * Truncated number. - * - * precision is number of significant digits for FLOAT_G - * and number of fractional digits for others - */ - integerDigits = (floor(number) > DBL_EPSILON) - ? 1 + (int)guarded_log10(floor(number)) - : 1; - fractionDigits = ((flags & FLAGS_FLOAT_G) && (zeroes == 0)) - ? precision - integerDigits - : zeroes + precision; - - number = floor(0.5 + number * pow(dblBase, (double)fractionDigits)); - workNumber = (isHex - ? guarded_log16(0.5 + number) - : guarded_log10(0.5 + number)); - if ((int)workNumber + 1 > integerDigits + fractionDigits) - { - if (flags & FLAGS_FLOAT_E) - { - /* Adjust if number was rounded up one digit (ie. 0.99 to 1.00) */ - exponent--; - uExponent -= (isExponentNegative) ? 1 : -1; - number /= dblBase; - } - else - { - /* Adjust if number was rounded up one digit (ie. 99 to 100) */ - integerDigits++; - } - } - - /* Build the fraction part */ - numberPointer = &numberBuffer[sizeof(numberBuffer) - 1]; - *numberPointer = NIL; - onlyzero = TRUE; - for (i = 0; i < fractionDigits; i++) - { - *(--numberPointer) = digits[(int)fmod(number, dblBase)]; - number = floor(number / dblBase); - - if ((flags & FLAGS_FLOAT_G) && !(flags & FLAGS_ALTERNATIVE)) - { - /* Prune trailing zeroes */ - if (numberPointer[0] != digits[0]) - onlyzero = FALSE; - else if (onlyzero && (numberPointer[0] == digits[0])) - numberPointer++; - } - else - onlyzero = FALSE; - } - - /* Insert decimal point */ - if ((flags & FLAGS_ALTERNATIVE) || ((fractionDigits > 0) && !onlyzero)) - { - i = StrLength(internalDecimalPoint); - while (i> 0) - { - *(--numberPointer) = internalDecimalPoint[--i]; - } - } - /* Insert the integer part and thousand separators */ - charsPerThousand = (int)internalGrouping[0]; - groupingIndex = 1; - for (i = 1; i < integerDigits + 1; i++) - { - *(--numberPointer) = digits[(int)fmod(number, dblBase)]; - number = floor(number / dblBase); - if (number < DBL_EPSILON) - break; - - if ((i > 0) - && ((flags & (FLAGS_FLOAT_E | FLAGS_QUOTE)) == FLAGS_QUOTE) - && (charsPerThousand != NO_GROUPING) - && (i % charsPerThousand == 0)) - { - /* - * We are building the number from the least significant - * to the most significant digit, so we have to copy the - * thousand separator backwards - */ - length = StrLength(internalThousandSeparator); - integerDigits += length; - if (((int)(numberPointer - numberBuffer) - length) > 0) - { - work = &internalThousandSeparator[length - 1]; - while (length-- > 0) - *(--numberPointer) = *work--; - } - - /* Advance to next grouping number */ - if (charsPerThousand != NO_GROUPING) - { - switch (internalGrouping[groupingIndex]) - { - case CHAR_MAX: /* Disable grouping */ - charsPerThousand = NO_GROUPING; - break; - case 0: /* Repeat last group */ - break; - default: - charsPerThousand = (int)internalGrouping[groupingIndex++]; - break; - } - } - } - } - - /* Build the exponent */ - exponentDigits = 0; - if (flags & FLAGS_FLOAT_E) - { - exponentPointer = &exponentBuffer[sizeof(exponentBuffer) - 1]; - *exponentPointer-- = NIL; - do { - *exponentPointer-- = digits[uExponent % base]; - uExponent /= base; - exponentDigits++; - } while (uExponent); - } - - /* - * Calculate expected width. - * sign + integer part + thousands separators + decimal point - * + fraction + exponent - */ - expectedWidth = StrLength(numberPointer); - if (isNegative || (flags & FLAGS_SHOWSIGN)) - expectedWidth += sizeof("-") - 1; - if (exponentDigits > 0) - expectedWidth += exponentDigits + - ((exponentDigits > 1) ? sizeof("E+") : sizeof("E+0")) - 1; - if (isHex) - expectedWidth += sizeof("0X") - 1; - - /* Output prefixing */ - if (flags & FLAGS_NILPADDING) - { - /* Leading zeros must be after sign */ - if (isNegative) - self->OutStream(self, '-'); - else if (flags & FLAGS_SHOWSIGN) - self->OutStream(self, '+'); - if (isHex) - { - self->OutStream(self, '0'); - self->OutStream(self, (flags & FLAGS_UPPER) ? 'X' : 'x'); - } - if (!(flags & FLAGS_LEFTADJUST)) - { - for (i = expectedWidth; i < width; i++) - { - self->OutStream(self, '0'); - } - } - } - else - { - /* Leading spaces must be before sign */ - if (!(flags & FLAGS_LEFTADJUST)) - { - for (i = expectedWidth; i < width; i++) - { - self->OutStream(self, CHAR_ADJUST); - } - } - if (isNegative) - self->OutStream(self, '-'); - else if (flags & FLAGS_SHOWSIGN) - self->OutStream(self, '+'); - if (isHex) - { - self->OutStream(self, '0'); - self->OutStream(self, (flags & FLAGS_UPPER) ? 'X' : 'x'); - } - } - /* Output number */ - for (i = 0; numberPointer[i]; i++) - { - self->OutStream(self, numberPointer[i]); - } - /* Output exponent */ - if (exponentDigits > 0) - { - self->OutStream(self, - isHex - ? ((flags & FLAGS_UPPER) ? 'P' : 'p') - : ((flags & FLAGS_UPPER) ? 'E' : 'e')); - self->OutStream(self, (isExponentNegative) ? '-' : '+'); - - /* The exponent must contain at least two digits */ - if (exponentDigits == 1) - self->OutStream(self, '0'); - - for (i = 0; i < exponentDigits; i++) - { - self->OutStream(self, exponentPointer[i + 1]); - } - } - /* Output trailing spaces */ - if (flags & FLAGS_LEFTADJUST) - { - for (i = expectedWidth; i < width; i++) - { - self->OutStream(self, CHAR_ADJUST); - } - } -} - -/************************************************************************* - * TrioFormatProcess [private] - */ -static int -TrioFormatProcess(trio_T *data, - const char *format, - parameter_T *parameters) - -{ -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - int charlen; -#endif - int i; - const char *string; - void *pointer; - unsigned long flags; - int width; - int precision; - int base; - int index; - - index = 0; - i = 0; -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - mblen(NULL, 0); -#endif - - while (format[index]) - { -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - if (! isascii(format[index])) - { - charlen = mblen(&format[index], MB_LEN_MAX); - while (charlen-- > 0) - { - data->OutStream(data, format[index++]); - } - continue; /* while */ - } -#endif /* TRIO_COMPILER_SUPPORTS_MULTIBYTE */ - if (CHAR_IDENTIFIER == format[index]) - { - if (CHAR_IDENTIFIER == format[index + 1]) - { - data->OutStream(data, CHAR_IDENTIFIER); - index += 2; - } - else - { - /* Skip the parameter entries */ - while (parameters[i].type == FORMAT_PARAMETER) - i++; - - flags = parameters[i].flags; - - /* Find width */ - width = parameters[i].width; - if (flags & FLAGS_WIDTH_PARAMETER) - { - /* Get width from parameter list */ - width = (int)parameters[width].data.number.as_signed; - } - - /* Find precision */ - if (flags & FLAGS_PRECISION) - { - precision = parameters[i].precision; - if (flags & FLAGS_PRECISION_PARAMETER) - { - /* Get precision from parameter list */ - precision = (int)parameters[precision].data.number.as_signed; - } - } - else - { - precision = NO_PRECISION; - } - - /* Find base */ - base = parameters[i].base; - if (flags & FLAGS_BASE_PARAMETER) - { - /* Get base from parameter list */ - base = (int)parameters[base].data.number.as_signed; - } - - switch (parameters[i].type) - { - case FORMAT_CHAR: - if (flags & FLAGS_QUOTE) - data->OutStream(data, CHAR_QUOTE); - if (! (flags & FLAGS_LEFTADJUST)) - { - while (--width > 0) - data->OutStream(data, CHAR_ADJUST); - } -#if TRIO_WIDECHAR - if (flags & FLAGS_WIDECHAR) - { - TrioWriteWideStringCharacter(data, - (wchar_t)parameters[i].data.number.as_signed, - flags, - NO_WIDTH); - } - else -#endif - TrioWriteStringCharacter(data, - (int)parameters[i].data.number.as_signed, - flags); - - if (flags & FLAGS_LEFTADJUST) - { - while(--width > 0) - data->OutStream(data, CHAR_ADJUST); - } - if (flags & FLAGS_QUOTE) - data->OutStream(data, CHAR_QUOTE); - - break; /* FORMAT_CHAR */ - - case FORMAT_INT: - if (base == NO_BASE) - base = BASE_DECIMAL; - - TrioWriteNumber(data, - parameters[i].data.number.as_signed, - flags, - width, - precision, - base); - - break; /* FORMAT_INT */ - - case FORMAT_DOUBLE: - TrioWriteDouble(data, - parameters[i].data.longdoubleNumber, - flags, - width, - precision, - base); - break; /* FORMAT_DOUBLE */ - - case FORMAT_STRING: -#if TRIO_WIDECHAR - if (flags & FLAGS_WIDECHAR) - { - TrioWriteWideString(data, - parameters[i].data.wstring, - flags, - width, - precision); - } - else -#endif -#ifdef QUALIFIER_ESCAPE - { - char *s = NULL; - static const char* empty = "(null)"; - switch (parameters[i].escape) - { - case ESCAPE_ULM: - s = edg_wll_LogEscape(parameters[i].data.string); - break; - case ESCAPE_XML: - s = edg_wll_EscapeXML(parameters[i].data.string); - break; - case ESCAPE_SQL: - s = edg_wll_EscapeSQL(parameters[i].data.string); - break; - case ESCAPE_NONE: - s = strdup(parameters[i].data.string ? parameters[i].data.string : empty); - break; - } - TrioWriteString(data,s,flags,width,precision); - free(s); - } -#else - { - TrioWriteString(data, - parameters[i].data.string, - flags, - width, - precision); - } -#endif - break; /* FORMAT_STRING */ - - case FORMAT_POINTER: - { - reference_T reference; - - reference.data = data; - reference.parameter = ¶meters[i]; - trio_print_pointer(&reference, parameters[i].data.pointer); - } - break; /* FORMAT_POINTER */ - - case FORMAT_COUNT: - pointer = parameters[i].data.pointer; - if (NULL != pointer) - { - /* - * C99 paragraph 7.19.6.1.8 says "the number of - * characters written to the output stream so far by - * this call", which is data->committed - */ -#if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) - if (flags & FLAGS_SIZE_T) - *(size_t *)pointer = (size_t)data->committed; - else -#endif -#if defined(QUALIFIER_PTRDIFF_T) - if (flags & FLAGS_PTRDIFF_T) - *(ptrdiff_t *)pointer = (ptrdiff_t)data->committed; - else -#endif -#if defined(QUALIFIER_INTMAX_T) - if (flags & FLAGS_INTMAX_T) - *(trio_intmax_t *)pointer = (trio_intmax_t)data->committed; - else -#endif - if (flags & FLAGS_QUAD) - { - *(trio_ulonglong_t *)pointer = (trio_ulonglong_t)data->committed; - } - else if (flags & FLAGS_LONG) - { - *(long int *)pointer = (long int)data->committed; - } - else if (flags & FLAGS_SHORT) - { - *(short int *)pointer = (short int)data->committed; - } - else - { - *(int *)pointer = (int)data->committed; - } - } - break; /* FORMAT_COUNT */ - - case FORMAT_PARAMETER: - break; /* FORMAT_PARAMETER */ - -#if defined(FORMAT_ERRNO) - case FORMAT_ERRNO: - string = StrError(parameters[i].data.errorNumber); - if (string) - { - TrioWriteString(data, - string, - flags, - width, - precision); - } - else - { - data->OutStream(data, '#'); - TrioWriteNumber(data, - (trio_intmax_t)parameters[i].data.errorNumber, - flags, - width, - precision, - BASE_DECIMAL); - } - break; /* FORMAT_ERRNO */ -#endif /* defined(FORMAT_ERRNO) */ - -#if defined(FORMAT_USER_DEFINED) - case FORMAT_USER_DEFINED: - { - reference_T reference; - userdef_T *def = NULL; - - if (parameters[i].user_name[0] == NIL) - { - /* Use handle */ - if ((i > 0) || - (parameters[i - 1].type == FORMAT_PARAMETER)) - def = (userdef_T *)parameters[i - 1].data.pointer; - } - else - { - /* Look up namespace */ - def = TrioFindNamespace(parameters[i].user_name, NULL); - } - if (def) { - reference.data = data; - reference.parameter = ¶meters[i]; - def->callback(&reference); - } - } - break; -#endif /* defined(FORMAT_USER_DEFINED) */ - - default: - break; - } /* switch parameter type */ - - /* Prepare for next */ - index = parameters[i].indexAfterSpecifier; - i++; - } - } - else /* not identifier */ - { - data->OutStream(data, format[index++]); - } - } - return data->processed; -} - -/************************************************************************* - * TrioFormatRef [private] - */ -static int -TrioFormatRef(reference_T *reference, - const char *format, - va_list arglist, - void **argarray) -{ - int status; - parameter_T parameters[MAX_PARAMETERS]; - - status = TrioPreprocess(TYPE_PRINT, format, parameters, arglist, argarray); - if (status < 0) - return status; - - return TrioFormatProcess(reference->data, format, parameters); -} - -/************************************************************************* - * TrioFormat [private] - * - * Description: - * This is the main engine for formatting output - */ -static int -TrioFormat(void *destination, - size_t destinationSize, - void (*OutStream)(trio_T *, int), - const char *format, - va_list arglist, - void **argarray) -{ - int status; - trio_T data; - parameter_T parameters[MAX_PARAMETERS]; - - assert(VALID(OutStream)); - assert(VALID(format)); - - memset(&data, 0, sizeof(data)); - data.OutStream = OutStream; - data.location = destination; - data.max = destinationSize; - -#if defined(USE_LOCALE) - if (NULL == internalLocaleValues) - { - TrioSetLocale(); - } -#endif - - status = TrioPreprocess(TYPE_PRINT, format, parameters, arglist, argarray); - if (status < 0) - return status; - - return TrioFormatProcess(&data, format, parameters); -} - -/************************************************************************* - * TrioOutStreamFile [private] - */ -static void -TrioOutStreamFile(trio_T *self, - int output) -{ - FILE *file = (FILE *)self->location; - - assert(VALID(self)); - assert(VALID(file)); - - self->processed++; - self->committed++; - (void)fputc(output, file); -} - -/************************************************************************* - * TrioOutStreamFileDescriptor [private] - */ -static void -TrioOutStreamFileDescriptor(trio_T *self, - int output) -{ - int fd = *((int *)self->location); - char ch; - - assert(VALID(self)); - - ch = (char)output; - (void)write(fd, &ch, sizeof(char)); - self->processed++; - self->committed++; -} - -/************************************************************************* - * TrioOutStreamString [private] - */ -static void -TrioOutStreamString(trio_T *self, - int output) -{ - char **buffer = (char **)self->location; - - assert(VALID(self)); - assert(VALID(buffer)); - - **buffer = (char)output; - (*buffer)++; - self->processed++; - self->committed++; -} - -/************************************************************************* - * TrioOutStreamStringMax [private] - */ -static void -TrioOutStreamStringMax(trio_T *self, - int output) -{ - char **buffer; - - assert(VALID(self)); - buffer = (char **)self->location; - assert(VALID(buffer)); - - if (self->processed < self->max) - { - **buffer = (char)output; - (*buffer)++; - self->committed++; - } - self->processed++; -} - -/************************************************************************* - * TrioOutStreamStringDynamic [private] - */ -#define DYNAMIC_START_SIZE 32 -struct dynamicBuffer { - char *buffer; - size_t length; - size_t allocated; -}; - -static void -TrioOutStreamStringDynamic(trio_T *self, - int output) -{ - struct dynamicBuffer *infop; - - assert(VALID(self)); - assert(VALID(self->location)); - - infop = (struct dynamicBuffer *)self->location; - - if (infop->buffer == NULL) - { - /* Start with a reasonable size */ - infop->buffer = (char *)TRIO_MALLOC(DYNAMIC_START_SIZE); - if (infop->buffer == NULL) - return; /* fail */ - - infop->allocated = DYNAMIC_START_SIZE; - self->processed = 0; - self->committed = 0; - } - else if (self->committed + sizeof(NIL) >= infop->allocated) - { - char *newptr; - - /* Allocate increasing chunks */ - newptr = (char *)TRIO_REALLOC(infop->buffer, infop->allocated * 2); - - if (newptr == NULL) - return; - - infop->buffer = newptr; - infop->allocated *= 2; - } - - infop->buffer[self->committed] = (char)output; - self->committed++; - self->processed++; - - infop->length = self->committed; -} - -/************************************************************************* - * printf - */ -int -trio_printf(const char *format, - ...) -{ - int status; - va_list args; - - assert(VALID(format)); - - va_start(args, format); - status = TrioFormat(stdout, 0, TrioOutStreamFile, format, args, NULL); - va_end(args); - return status; -} - -int -trio_vprintf(const char *format, - va_list args) -{ - assert(VALID(format)); - - return TrioFormat(stdout, 0, TrioOutStreamFile, format, args, NULL); -} - -#ifdef __GNUC__ -#define UNUSED_VAR __attribute__((unused)) -#else -#define UNUSED_VAR -#endif - -static void shutup_unitialized(va_list *dummy UNUSED_VAR) { -} - -int -trio_printfv(const char *format, - void ** args) -{ - va_list dummy; - shutup_unitialized(&dummy); - - assert(VALID(format)); - - return TrioFormat(stdout, 0, TrioOutStreamFile, format, dummy, args); -} - -/************************************************************************* - * fprintf - */ -int -trio_fprintf(FILE *file, - const char *format, - ...) -{ - int status; - va_list args; - - assert(VALID(file)); - assert(VALID(format)); - - va_start(args, format); - status = TrioFormat(file, 0, TrioOutStreamFile, format, args, NULL); - va_end(args); - return status; -} - -int -trio_vfprintf(FILE *file, - const char *format, - va_list args) -{ - assert(VALID(file)); - assert(VALID(format)); - - return TrioFormat(file, 0, TrioOutStreamFile, format, args, NULL); -} - -int -trio_fprintfv(FILE *file, - const char *format, - void ** args) -{ - va_list dummy; - shutup_unitialized(&dummy); - - assert(VALID(file)); - assert(VALID(format)); - - return TrioFormat(file, 0, TrioOutStreamFile, format, dummy, args); -} - -/************************************************************************* - * dprintf - */ -int -trio_dprintf(int fd, - const char *format, - ...) -{ - int status; - va_list args; - - assert(VALID(format)); - - va_start(args, format); - status = TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, args, NULL); - va_end(args); - return status; -} - -int -trio_vdprintf(int fd, - const char *format, - va_list args) -{ - assert(VALID(format)); - - return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, args, NULL); -} - -int -trio_dprintfv(int fd, - const char *format, - void **args) -{ - va_list dummy; - shutup_unitialized(&dummy); - - assert(VALID(format)); - - return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, dummy, args); -} - -/************************************************************************* - * sprintf - */ -int -trio_sprintf(char *buffer, - const char *format, - ...) -{ - int status; - va_list args; - - assert(VALID(buffer)); - assert(VALID(format)); - - va_start(args, format); - status = TrioFormat(&buffer, 0, TrioOutStreamString, format, args, NULL); - *buffer = NIL; /* Terminate with NIL character */ - va_end(args); - return status; -} - -int -trio_vsprintf(char *buffer, - const char *format, - va_list args) -{ - int status; - - assert(VALID(buffer)); - assert(VALID(format)); - - status = TrioFormat(&buffer, 0, TrioOutStreamString, format, args, NULL); - *buffer = NIL; - return status; -} - -int -trio_sprintfv(char *buffer, - const char *format, - void **args) -{ - int status; - va_list dummy; - shutup_unitialized(&dummy); - - assert(VALID(buffer)); - assert(VALID(format)); - - status = TrioFormat(&buffer, 0, TrioOutStreamString, format, dummy, args); - *buffer = NIL; - return status; -} - -/************************************************************************* - * snprintf - */ -int -trio_snprintf(char *buffer, - size_t bufferSize, - const char *format, - ...) -{ - int status; - va_list args; - - assert(VALID(buffer)); - assert(VALID(format)); - - va_start(args, format); - status = TrioFormat(&buffer, bufferSize > 0 ? bufferSize - 1 : 0, - TrioOutStreamStringMax, format, args, NULL); - if (bufferSize > 0) - *buffer = NIL; - va_end(args); - return status; -} - -int -trio_vsnprintf(char *buffer, - size_t bufferSize, - const char *format, - va_list args) -{ - int status; - - assert(VALID(buffer)); - assert(VALID(format)); - - status = TrioFormat(&buffer, bufferSize > 0 ? bufferSize - 1 : 0, - TrioOutStreamStringMax, format, args, NULL); - if (bufferSize > 0) - *buffer = NIL; - return status; -} - -int -trio_snprintfv(char *buffer, - size_t bufferSize, - const char *format, - void **args) -{ - int status; - va_list dummy; - shutup_unitialized(&dummy); - - assert(VALID(buffer)); - assert(VALID(format)); - - status = TrioFormat(&buffer, bufferSize > 0 ? bufferSize - 1 : 0, - TrioOutStreamStringMax, format, dummy, args); - if (bufferSize > 0) - *buffer = NIL; - return status; -} - -/************************************************************************* - * snprintfcat - * Appends the new string to the buffer string overwriting the '\0' - * character at the end of buffer. - */ -int -trio_snprintfcat(char *buffer, - size_t bufferSize, - const char *format, - ...) -{ - int status; - va_list args; - size_t buf_len; - - va_start(args, format); - - assert(VALID(buffer)); - assert(VALID(format)); - - buf_len = strlen(buffer); - buffer = &buffer[buf_len]; - - status = TrioFormat(&buffer, bufferSize - 1 - buf_len, - TrioOutStreamStringMax, format, args, NULL); - va_end(args); - *buffer = NIL; - return status; -} - -int -trio_vsnprintfcat(char *buffer, - size_t bufferSize, - const char *format, - va_list args) -{ - int status; - size_t buf_len; - assert(VALID(buffer)); - assert(VALID(format)); - - buf_len = strlen(buffer); - buffer = &buffer[buf_len]; - status = TrioFormat(&buffer, bufferSize - 1 - buf_len, - TrioOutStreamStringMax, format, args, NULL); - *buffer = NIL; - return status; -} - -/************************************************************************* - * trio_aprintf - */ - -/* Deprecated */ -char * -trio_aprintf(const char *format, - ...) -{ - va_list args; - struct dynamicBuffer info; - - assert(VALID(format)); - - info.buffer = NULL; - info.length = 0; - info.allocated = 0; - - va_start(args, format); - (void)TrioFormat(&info, 0, TrioOutStreamStringDynamic, format, args, NULL); - va_end(args); - if (info.length) { - info.buffer[info.length] = NIL; /* we terminate this with a zero byte */ - return info.buffer; - } - else - return NULL; -} - -/* Deprecated */ -char * -trio_vaprintf(const char *format, - va_list args) -{ - struct dynamicBuffer info; - - assert(VALID(format)); - - info.buffer = NULL; - info.length = 0; - info.allocated = 0; - - (void)TrioFormat(&info, 0, TrioOutStreamStringDynamic, format, args, NULL); - if (info.length) { - info.buffer[info.length] = NIL; /* we terminate this with a zero byte */ - return info.buffer; - } - else - return NULL; -} - -int -trio_asprintf(char **result, - const char *format, - ...) -{ - va_list args; - int status; - struct dynamicBuffer info; - - assert(VALID(format)); - - info.buffer = NULL; - info.length = 0; - info.allocated = 0; - - va_start(args, format); - status = TrioFormat(&info, 0, TrioOutStreamStringDynamic, format, args, NULL); - va_end(args); - if (status < 0) { - *result = NULL; - return status; - } - if (info.length == 0) { - /* - * If the length is zero, no characters have been written and therefore - * no memory has been allocated, but we must to allocate and return an - * empty string. - */ - info.buffer = (char *)TRIO_MALLOC(sizeof(char)); - if (info.buffer == NULL) { - *result = NULL; - return TRIO_ERROR_RETURN(TRIO_ENOMEM, 0); - } - } - info.buffer[info.length] = NIL; /* we terminate this with a zero byte */ - *result = info.buffer; - - return status; -} - -int -trio_vasprintf(char **result, - const char *format, - va_list args) -{ - int status; - struct dynamicBuffer info; - - assert(VALID(format)); - - info.buffer = NULL; - info.length = 0; - info.allocated = 0; - - status = TrioFormat(&info, 0, TrioOutStreamStringDynamic, format, args, NULL); - if (status < 0) { - *result = NULL; - return status; - } - if (info.length == 0) { - info.buffer = (char *)TRIO_MALLOC(sizeof(char)); - if (info.buffer == NULL) { - *result = NULL; - return TRIO_ERROR_RETURN(TRIO_ENOMEM, 0); - } - } - info.buffer[info.length] = NIL; /* we terminate this with a zero byte */ - *result = info.buffer; - - return status; -} - - -/************************************************************************* - * - * @CALLBACK - * - ************************************************************************/ - - -/************************************************************************* - * trio_register [public] - */ -void * -trio_register(trio_callback_t callback, - const char *name) -{ - userdef_T *def; - userdef_T *prev = NULL; - - if (callback == NULL) - return NULL; - - if (name) - { - /* Handle built-in namespaces */ - if (name[0] == ':') - { - if (StrEqual(name, ":enter")) - { - internalEnterCriticalRegion = callback; - } - else if (StrEqual(name, ":leave")) - { - internalLeaveCriticalRegion = callback; - } - return NULL; - } - - /* Bail out if namespace is too long */ - if (StrLength(name) >= MAX_USER_NAME) - return NULL; - - /* Bail out if namespace already is registered */ - def = TrioFindNamespace(name, &prev); - if (def) - return NULL; - } - - def = (userdef_T *)TRIO_MALLOC(sizeof(userdef_T)); - if (def) - { - if (internalEnterCriticalRegion) - (void)internalEnterCriticalRegion(NULL); - - if (name) - { - /* Link into internal list */ - if (prev == NULL) - internalUserDef = def; - else - prev->next = def; - } - /* Initialize */ - def->callback = callback; - def->name = (name == NULL) - ? NULL - : StrDuplicate(name); - def->next = NULL; - - if (internalLeaveCriticalRegion) - (void)internalLeaveCriticalRegion(NULL); - } - return def; -} - -/************************************************************************* - * trio_unregister [public] - */ -void -trio_unregister(void *handle) -{ - userdef_T *self = (userdef_T *)handle; - userdef_T *def; - userdef_T *prev = NULL; - - assert(VALID(self)); - - if (self->name) - { - def = TrioFindNamespace(self->name, &prev); - if (def) - { - if (internalEnterCriticalRegion) - (void)internalEnterCriticalRegion(NULL); - - if (prev == NULL) - internalUserDef = NULL; - else - prev->next = def->next; - - if (internalLeaveCriticalRegion) - (void)internalLeaveCriticalRegion(NULL); - } - StrFree(self->name); - } - TRIO_FREE(self); -} - -/************************************************************************* - * trio_get_format [public] - */ -const char * -trio_get_format(void *ref) -{ - assert(((reference_T *)ref)->parameter->type == FORMAT_USER_DEFINED); - - return (((reference_T *)ref)->parameter->user_data); -} - -/************************************************************************* - * trio_get_argument [public] - */ -void * -trio_get_argument(void *ref) -{ - assert(((reference_T *)ref)->parameter->type == FORMAT_USER_DEFINED); - - return ((reference_T *)ref)->parameter->data.pointer; -} - -/************************************************************************* - * trio_get_width / trio_set_width [public] - */ -int -trio_get_width(void *ref) -{ - return ((reference_T *)ref)->parameter->width; -} - -void -trio_set_width(void *ref, - int width) -{ - ((reference_T *)ref)->parameter->width = width; -} - -/************************************************************************* - * trio_get_precision / trio_set_precision [public] - */ -int -trio_get_precision(void *ref) -{ - return (((reference_T *)ref)->parameter->precision); -} - -void -trio_set_precision(void *ref, - int precision) -{ - ((reference_T *)ref)->parameter->precision = precision; -} - -/************************************************************************* - * trio_get_base / trio_set_base [public] - */ -int -trio_get_base(void *ref) -{ - return (((reference_T *)ref)->parameter->base); -} - -void -trio_set_base(void *ref, - int base) -{ - ((reference_T *)ref)->parameter->base = base; -} - -/************************************************************************* - * trio_get_long / trio_set_long [public] - */ -int -trio_get_long(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_LONG); -} - -void -trio_set_long(void *ref, - int is_long) -{ - if (is_long) - ((reference_T *)ref)->parameter->flags |= FLAGS_LONG; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_LONG; -} - -/************************************************************************* - * trio_get_longlong / trio_set_longlong [public] - */ -int -trio_get_longlong(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_QUAD); -} - -void -trio_set_longlong(void *ref, - int is_longlong) -{ - if (is_longlong) - ((reference_T *)ref)->parameter->flags |= FLAGS_QUAD; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_QUAD; -} - -/************************************************************************* - * trio_get_longdouble / trio_set_longdouble [public] - */ -int -trio_get_longdouble(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_LONGDOUBLE); -} - -void -trio_set_longdouble(void *ref, - int is_longdouble) -{ - if (is_longdouble) - ((reference_T *)ref)->parameter->flags |= FLAGS_LONGDOUBLE; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_LONGDOUBLE; -} - -/************************************************************************* - * trio_get_short / trio_set_short [public] - */ -int -trio_get_short(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_SHORT); -} - -void -trio_set_short(void *ref, - int is_short) -{ - if (is_short) - ((reference_T *)ref)->parameter->flags |= FLAGS_SHORT; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_SHORT; -} - -/************************************************************************* - * trio_get_shortshort / trio_set_shortshort [public] - */ -int -trio_get_shortshort(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_SHORTSHORT); -} - -void -trio_set_shortshort(void *ref, - int is_shortshort) -{ - if (is_shortshort) - ((reference_T *)ref)->parameter->flags |= FLAGS_SHORTSHORT; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_SHORTSHORT; -} - -/************************************************************************* - * trio_get_alternative / trio_set_alternative [public] - */ -int -trio_get_alternative(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_ALTERNATIVE); -} - -void -trio_set_alternative(void *ref, - int is_alternative) -{ - if (is_alternative) - ((reference_T *)ref)->parameter->flags |= FLAGS_ALTERNATIVE; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_ALTERNATIVE; -} - -/************************************************************************* - * trio_get_alignment / trio_set_alignment [public] - */ -int -trio_get_alignment(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_LEFTADJUST); -} - -void -trio_set_alignment(void *ref, - int is_leftaligned) -{ - if (is_leftaligned) - ((reference_T *)ref)->parameter->flags |= FLAGS_LEFTADJUST; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_LEFTADJUST; -} - -/************************************************************************* - * trio_get_spacing /trio_set_spacing [public] - */ -int -trio_get_spacing(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_SPACE); -} - -void -trio_set_spacing(void *ref, - int is_space) -{ - if (is_space) - ((reference_T *)ref)->parameter->flags |= FLAGS_SPACE; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_SPACE; -} - -/************************************************************************* - * trio_get_sign / trio_set_sign [public] - */ -int -trio_get_sign(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_SHOWSIGN); -} - -void -trio_set_sign(void *ref, - int is_sign) -{ - if (is_sign) - ((reference_T *)ref)->parameter->flags |= FLAGS_SHOWSIGN; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_SHOWSIGN; -} - -/************************************************************************* - * trio_get_padding / trio_set_padding [public] - */ -int -trio_get_padding(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_NILPADDING); -} - -void -trio_set_padding(void *ref, - int is_padding) -{ - if (is_padding) - ((reference_T *)ref)->parameter->flags |= FLAGS_NILPADDING; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_NILPADDING; -} - -/************************************************************************* - * trio_get_quote / trio_set_quote [public] - */ -int -trio_get_quote(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_QUOTE); -} - -void -trio_set_quote(void *ref, - int is_quote) -{ - if (is_quote) - ((reference_T *)ref)->parameter->flags |= FLAGS_QUOTE; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_QUOTE; -} - -/************************************************************************* - * trio_get_upper / trio_set_upper [public] - */ -int -trio_get_upper(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_UPPER); -} - -void -trio_set_upper(void *ref, - int is_upper) -{ - if (is_upper) - ((reference_T *)ref)->parameter->flags |= FLAGS_UPPER; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_UPPER; -} - -/************************************************************************* - * trio_get_largest / trio_set_largest [public] - */ -#if TRIO_C99 -int -trio_get_largest(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_INTMAX_T); -} - -void -trio_set_largest(void *ref, - int is_largest) -{ - if (is_largest) - ((reference_T *)ref)->parameter->flags |= FLAGS_INTMAX_T; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_INTMAX_T; -} -#endif - -/************************************************************************* - * trio_get_ptrdiff / trio_set_ptrdiff [public] - */ -int -trio_get_ptrdiff(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_PTRDIFF_T); -} - -void -trio_set_ptrdiff(void *ref, - int is_ptrdiff) -{ - if (is_ptrdiff) - ((reference_T *)ref)->parameter->flags |= FLAGS_PTRDIFF_T; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_PTRDIFF_T; -} - -/************************************************************************* - * trio_get_size / trio_set_size [public] - */ -#if TRIO_C99 -int -trio_get_size(void *ref) -{ - return (((reference_T *)ref)->parameter->flags & FLAGS_SIZE_T); -} - -void -trio_set_size(void *ref, - int is_size) -{ - if (is_size) - ((reference_T *)ref)->parameter->flags |= FLAGS_SIZE_T; - else - ((reference_T *)ref)->parameter->flags &= ~FLAGS_SIZE_T; -} -#endif - -/************************************************************************* - * trio_print_int [public] - */ -void -trio_print_int(void *ref, - int number) -{ - reference_T *self = (reference_T *)ref; - - TrioWriteNumber(self->data, - (trio_intmax_t)number, - self->parameter->flags, - self->parameter->width, - self->parameter->precision, - self->parameter->base); -} - -/************************************************************************* - * trio_print_uint [public] - */ -void -trio_print_uint(void *ref, - unsigned int number) -{ - reference_T *self = (reference_T *)ref; - - TrioWriteNumber(self->data, - (trio_intmax_t)number, - self->parameter->flags | FLAGS_UNSIGNED, - self->parameter->width, - self->parameter->precision, - self->parameter->base); -} - -/************************************************************************* - * trio_print_double [public] - */ -void -trio_print_double(void *ref, - double number) -{ - reference_T *self = (reference_T *)ref; - - TrioWriteDouble(self->data, - number, - self->parameter->flags, - self->parameter->width, - self->parameter->precision, - self->parameter->base); -} - -/************************************************************************* - * trio_print_string [public] - */ -void -trio_print_string(void *ref, - char *string) -{ - reference_T *self = (reference_T *)ref; - - TrioWriteString(self->data, - string, - self->parameter->flags, - self->parameter->width, - self->parameter->precision); -} - -/************************************************************************* - * trio_print_pointer [public] - */ -void -trio_print_pointer(void *ref, - void *pointer) -{ - reference_T *self = (reference_T *)ref; - unsigned long flags; - trio_uintmax_t number; - - if (NULL == pointer) - { - const char *string = null; - while (*string) - self->data->OutStream(self->data, *string++); - } - else - { - /* - * The subtraction of the null pointer is a workaround - * to avoid a compiler warning. The performance overhead - * is negligible (and likely to be removed by an - * optimising compiler). The (char *) casting is done - * to please ANSI C++. - */ - number = (trio_uintmax_t)((char *)pointer - (char *)0); - /* Shrink to size of pointer */ - number &= (trio_uintmax_t)-1; - flags = self->parameter->flags; - flags |= (FLAGS_UNSIGNED | FLAGS_ALTERNATIVE | - FLAGS_NILPADDING); - TrioWriteNumber(self->data, - (trio_intmax_t)number, - flags, - POINTER_WIDTH, - NO_PRECISION, - BASE_HEX); - } -} - -/************************************************************************* - * trio_print_ref [public] - */ -int -trio_print_ref(void *ref, - const char *format, - ...) -{ - int status; - va_list arglist; - - assert(VALID(format)); - - va_start(arglist, format); - status = TrioFormatRef((reference_T *)ref, format, arglist, NULL); - va_end(arglist); - return status; -} - -/************************************************************************* - * trio_vprint_ref [public] - */ -int -trio_vprint_ref(void *ref, - const char *format, - va_list arglist) -{ - assert(VALID(format)); - - return TrioFormatRef((reference_T *)ref, format, arglist, NULL); -} - -/************************************************************************* - * trio_printv_ref [public] - */ -int -trio_printv_ref(void *ref, - const char *format, - void **argarray) -{ - va_list dummy; - shutup_unitialized(&dummy); - - assert(VALID(format)); - - return TrioFormatRef((reference_T *)ref, format, dummy, argarray); -} - - -/************************************************************************* - * - * @SCANNING - * - ************************************************************************/ - - -/************************************************************************* - * TrioSkipWhitespaces [private] - */ -static int -TrioSkipWhitespaces(trio_T *self) -{ - int ch; - - ch = self->current; - while (isspace(ch)) - { - self->InStream(self, &ch); - } - return ch; -} - -/************************************************************************* - * TrioGetCollation [private] - */ -#if TRIO_EXTENSION -static void -TrioGetCollation() -{ - int i; - int j; - int k; - char first[2]; - char second[2]; - - /* This is computational expensive */ - first[1] = NIL; - second[1] = NIL; - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - { - k = 0; - first[0] = (char)i; - for (j = 0; j < MAX_CHARACTER_CLASS; j++) - { - second[0] = (char)j; - if (StrEqualLocale(first, second)) - internalCollationArray[i][k++] = (char)j; - } - internalCollationArray[i][k] = NIL; - } -} -#endif - -/************************************************************************* - * TrioGetCharacterClass [private] - * - * FIXME: - * multibyte - */ -static int -TrioGetCharacterClass(const char *format, - int *indexPointer, - unsigned long *flagsPointer, - int *characterclass) -{ - int index = *indexPointer; - int i; - char ch; - char range_begin; - char range_end; - - *flagsPointer &= ~FLAGS_EXCLUDE; - - if (format[index] == QUALIFIER_CIRCUMFLEX) - { - *flagsPointer |= FLAGS_EXCLUDE; - index++; - } - /* - * If the ungroup character is at the beginning of the scanlist, - * it will be part of the class, and a second ungroup character - * must follow to end the group. - */ - if (format[index] == SPECIFIER_UNGROUP) - { - characterclass[(int)SPECIFIER_UNGROUP]++; - index++; - } - /* - * Minus is used to specify ranges. To include minus in the class, - * it must be at the beginning of the list - */ - if (format[index] == QUALIFIER_MINUS) - { - characterclass[(int)QUALIFIER_MINUS]++; - index++; - } - /* Collect characters */ - for (ch = format[index]; - (ch != SPECIFIER_UNGROUP) && (ch != NIL); - ch = format[++index]) - { - switch (ch) - { - case QUALIFIER_MINUS: /* Scanlist ranges */ - - /* - * Both C99 and UNIX98 describes ranges as implementation- - * defined. - * - * We support the following behaviour (although this may - * change as we become wiser) - * - only increasing ranges, ie. [a-b] but not [b-a] - * - transitive ranges, ie. [a-b-c] == [a-c] - * - trailing minus, ie. [a-] is interpreted as an 'a' - * and a '-' - * - duplicates (although we can easily convert these - * into errors) - */ - range_begin = format[index - 1]; - range_end = format[++index]; - if (range_end == SPECIFIER_UNGROUP) - { - /* Trailing minus is included */ - characterclass[(int)ch]++; - ch = range_end; - break; /* for */ - } - if (range_end == NIL) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - if (range_begin > range_end) - return TRIO_ERROR_RETURN(TRIO_ERANGE, index); - - for (i = (int)range_begin; i <= (int)range_end; i++) - characterclass[i]++; - - ch = range_end; - break; - -#if TRIO_EXTENSION - - case SPECIFIER_GROUP: - - switch (format[index + 1]) - { - case QUALIFIER_DOT: /* Collating symbol */ - /* - * FIXME: This will be easier to implement when multibyte - * characters have been implemented. Until now, we ignore - * this feature. - */ - for (i = index + 2; ; i++) - { - if (format[i] == NIL) - /* Error in syntax */ - return -1; - else if (format[i] == QUALIFIER_DOT) - break; /* for */ - } - if (format[++i] != SPECIFIER_UNGROUP) - return -1; - - index = i; - break; - - case QUALIFIER_EQUAL: /* Equivalence class expressions */ - { - unsigned int j; - unsigned int k; - - if (internalCollationUnconverted) - { - /* Lazy evalutation of collation array */ - TrioGetCollation(); - internalCollationUnconverted = FALSE; - } - for (i = index + 2; ; i++) - { - if (format[i] == NIL) - /* Error in syntax */ - return -1; - else if (format[i] == QUALIFIER_EQUAL) - break; /* for */ - else - { - /* Mark any equivalent character */ - k = (unsigned int)format[i]; - for (j = 0; internalCollationArray[k][j] != NIL; j++) - characterclass[(int)internalCollationArray[k][j]]++; - } - } - if (format[++i] != SPECIFIER_UNGROUP) - return -1; - - index = i; - } - break; - - case QUALIFIER_COLON: /* Character class expressions */ - - if (StrEqualMax(CLASS_ALNUM, sizeof(CLASS_ALNUM) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isalnum(i)) - characterclass[i]++; - index += sizeof(CLASS_ALNUM) - 1; - } - else if (StrEqualMax(CLASS_ALPHA, sizeof(CLASS_ALPHA) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isalpha(i)) - characterclass[i]++; - index += sizeof(CLASS_ALPHA) - 1; - } - else if (StrEqualMax(CLASS_CNTRL, sizeof(CLASS_CNTRL) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (iscntrl(i)) - characterclass[i]++; - index += sizeof(CLASS_CNTRL) - 1; - } - else if (StrEqualMax(CLASS_DIGIT, sizeof(CLASS_DIGIT) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isdigit(i)) - characterclass[i]++; - index += sizeof(CLASS_DIGIT) - 1; - } - else if (StrEqualMax(CLASS_GRAPH, sizeof(CLASS_GRAPH) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isgraph(i)) - characterclass[i]++; - index += sizeof(CLASS_GRAPH) - 1; - } - else if (StrEqualMax(CLASS_LOWER, sizeof(CLASS_LOWER) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (islower(i)) - characterclass[i]++; - index += sizeof(CLASS_LOWER) - 1; - } - else if (StrEqualMax(CLASS_PRINT, sizeof(CLASS_PRINT) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isprint(i)) - characterclass[i]++; - index += sizeof(CLASS_PRINT) - 1; - } - else if (StrEqualMax(CLASS_PUNCT, sizeof(CLASS_PUNCT) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (ispunct(i)) - characterclass[i]++; - index += sizeof(CLASS_PUNCT) - 1; - } - else if (StrEqualMax(CLASS_SPACE, sizeof(CLASS_SPACE) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isspace(i)) - characterclass[i]++; - index += sizeof(CLASS_SPACE) - 1; - } - else if (StrEqualMax(CLASS_UPPER, sizeof(CLASS_UPPER) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isupper(i)) - characterclass[i]++; - index += sizeof(CLASS_UPPER) - 1; - } - else if (StrEqualMax(CLASS_XDIGIT, sizeof(CLASS_XDIGIT) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isxdigit(i)) - characterclass[i]++; - index += sizeof(CLASS_XDIGIT) - 1; - } - else - { - characterclass[(int)ch]++; - } - break; - - default: - characterclass[(int)ch]++; - break; - } - break; - -#endif /* TRIO_EXTENSION */ - - default: - characterclass[(int)ch]++; - break; - } - } - return 0; -} - -/************************************************************************* - * TrioReadNumber [private] - * - * We implement our own number conversion in preference of strtol and - * strtoul, because we must handle 'long long' and thousand separators. - */ -static BOOLEAN_T -TrioReadNumber(trio_T *self, - trio_uintmax_t *target, - unsigned long flags, - int width, - int base) -{ - trio_uintmax_t number = 0; - int digit; - int count; - BOOLEAN_T isNegative = FALSE; - int j; - - assert(VALID(self)); - assert(VALID(self->InStream)); - assert((base >= MIN_BASE && base <= MAX_BASE) || (base == NO_BASE)); - - if (internalDigitsUnconverted) - { - /* Lazy evaluation of digits array */ - memset(internalDigitArray, -1, sizeof(internalDigitArray)); - for (j = 0; j < (int)sizeof(internalDigitsLower) - 1; j++) - { - internalDigitArray[(int)internalDigitsLower[j]] = j; - internalDigitArray[(int)internalDigitsUpper[j]] = j; - } - internalDigitsUnconverted = FALSE; - } - - TrioSkipWhitespaces(self); - - if (!(flags & FLAGS_UNSIGNED)) - { - /* Leading sign */ - if (self->current == '+') - { - self->InStream(self, NULL); - } - else if (self->current == '-') - { - self->InStream(self, NULL); - isNegative = TRUE; - } - } - - count = self->processed; - - if (flags & FLAGS_ALTERNATIVE) - { - switch (base) - { - case NO_BASE: - case BASE_OCTAL: - case BASE_HEX: - case BASE_BINARY: - if (self->current == '0') - { - self->InStream(self, NULL); - if (self->current) - { - if ((base == BASE_HEX) && - (toupper(self->current) == 'X')) - { - self->InStream(self, NULL); - } - else if ((base == BASE_BINARY) && - (toupper(self->current) == 'B')) - { - self->InStream(self, NULL); - } - } - } - else - return FALSE; - break; - default: - break; - } - } - - while (((width == NO_WIDTH) || (self->processed - count < width)) && - (! ((self->current == EOF) || isspace(self->current)))) - { - if (isascii(self->current)) - { - digit = internalDigitArray[self->current]; - /* Abort if digit is not allowed in the specified base */ - if ((digit == -1) || (digit >= base)) - break; - } - else if (flags & FLAGS_QUOTE) - { - /* Compare with thousands separator */ - for (j = 0; internalThousandSeparator[j] && self->current; j++) - { - if (internalThousandSeparator[j] != self->current) - break; - - self->InStream(self, NULL); - } - if (internalThousandSeparator[j]) - break; /* Mismatch */ - else - continue; /* Match */ - } - else - break; - - number *= base; - number += digit; - - self->InStream(self, NULL); - } - - /* Was anything read at all? */ - if (self->processed == count) - return FALSE; - - if (target) - *target = (isNegative) ? -number : number; - return TRUE; -} - -/************************************************************************* - * TrioReadChar [private] - */ -static int -TrioReadChar(trio_T *self, - char *target, - unsigned long flags, - int width) -{ - int i; - char ch; - trio_uintmax_t number; - - assert(VALID(self)); - assert(VALID(self->InStream)); - - for (i = 0; - (self->current != EOF) && (i < width); - i++) - { - ch = (char)self->current; - self->InStream(self, NULL); - if ((flags & FLAGS_ALTERNATIVE) && (ch == CHAR_BACKSLASH)) - { - switch (self->current) - { - case '\\': ch = '\\'; break; - case 'a': ch = '\007'; break; - case 'b': ch = '\b'; break; - case 'f': ch = '\f'; break; - case 'n': ch = '\n'; break; - case 'r': ch = '\r'; break; - case 't': ch = '\t'; break; - case 'v': ch = '\v'; break; - default: - if (isdigit(self->current)) - { - /* Read octal number */ - if (!TrioReadNumber(self, &number, 0, 3, BASE_OCTAL)) - return 0; - ch = (char)number; - } - else if (toupper(self->current) == 'X') - { - /* Read hexadecimal number */ - self->InStream(self, NULL); - if (!TrioReadNumber(self, &number, 0, 2, BASE_HEX)) - return 0; - ch = (char)number; - } - else - { - ch = (char)self->current; - } - break; - } - } - - if (target) - target[i] = ch; - } - return i + 1; -} - -/************************************************************************* - * TrioReadString [private] - */ -static BOOLEAN_T -TrioReadString(trio_T *self, - char *target, - unsigned long flags, - int width) -{ - int i; - - assert(VALID(self)); - assert(VALID(self->InStream)); - - TrioSkipWhitespaces(self); - - /* - * Continue until end of string is reached, a whitespace is encountered, - * or width is exceeded - */ - for (i = 0; - ((width == NO_WIDTH) || (i < width)) && - (! ((self->current == EOF) || isspace(self->current))); - i++) - { - if (TrioReadChar(self, &target[i], flags, 1) == 0) - break; /* for */ - } - if (target) - target[i] = NIL; - return TRUE; -} - -/************************************************************************* - * TrioReadWideChar [private] - */ -#if TRIO_WIDECHAR -static int -TrioReadWideChar(trio_T *self, - wchar_t *target, - unsigned long flags, - int width) -{ - int i; - int j; - int size; - int amount = 0; - wchar_t wch; - char buffer[MB_LEN_MAX + 1]; - - assert(VALID(self)); - assert(VALID(self->InStream)); - - for (i = 0; - (self->current != EOF) && (i < width); - i++) - { - if (isascii(self->current)) - { - if (TrioReadChar(self, buffer, flags, 1) == 0) - return 0; - buffer[1] = NIL; - } - else - { - /* - * Collect a multibyte character, by enlarging buffer until - * it contains a fully legal multibyte character, or the - * buffer is full. - */ - j = 0; - do - { - buffer[j++] = (char)self->current; - buffer[j] = NIL; - self->InStream(self, NULL); - } - while ((j < (int)sizeof(buffer)) && (mblen(buffer, (size_t)j) != j)); - } - if (target) - { - size = mbtowc(&wch, buffer, sizeof(buffer)); - if (size > 0) - target[i] = wch; - } - amount += size; - self->InStream(self, NULL); - } - return amount; -} -#endif /* TRIO_WIDECHAR */ - -/************************************************************************* - * TrioReadWideString [private] - */ -#if TRIO_WIDECHAR -static BOOLEAN_T -TrioReadWideString(trio_T *self, - wchar_t *target, - unsigned long flags, - int width) -{ - int i; - int size; - - assert(VALID(self)); - assert(VALID(self->InStream)); - - TrioSkipWhitespaces(self); - -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - mblen(NULL, 0); -#endif - - /* - * Continue until end of string is reached, a whitespace is encountered, - * or width is exceeded - */ - for (i = 0; - ((width == NO_WIDTH) || (i < width)) && - (! ((self->current == EOF) || isspace(self->current))); - ) - { - size = TrioReadWideChar(self, &target[i], flags, 1); - if (size == 0) - break; /* for */ - - i += size; - } - if (target) - target[i] = L'\0'; - return TRUE; -} -#endif /* TRIO_WIDECHAR */ - -/************************************************************************* - * TrioReadGroup [private] - * - * FIXME: characterclass does not work with multibyte characters - */ -static BOOLEAN_T -TrioReadGroup(trio_T *self, - char *target, - int *characterclass, - unsigned long flags, - int width) -{ - int ch; - int i; - - assert(VALID(self)); - assert(VALID(self->InStream)); - - ch = self->current; - for (i = 0; - ((width == NO_WIDTH) || (i < width)) && - (! ((ch == EOF) || - (((flags & FLAGS_EXCLUDE) != 0) ^ (characterclass[ch] == 0)))); - i++) - { - if (target) - target[i] = (char)ch; - self->InStream(self, &ch); - } - - if (target) - target[i] = NIL; - return TRUE; -} - -/************************************************************************* - * TrioReadDouble [private] - * - * FIXME: - * add long double - */ -static BOOLEAN_T -TrioReadDouble(trio_T *self, - double *target, - unsigned long flags, - int width) -{ - int ch; - char doubleString[512] = ""; - int index = 0; - int start; - int j; - BOOLEAN_T isHex = FALSE; - - if ((width == NO_WIDTH) || (width > (int)sizeof(doubleString) - 1)) - width = sizeof(doubleString) - 1; - - TrioSkipWhitespaces(self); - - /* - * Read entire double number from stream. StrToDouble requires a - * string as input, but InStream can be anything, so we have to - * collect all characters. - */ - ch = self->current; - if ((ch == '+') || (ch == '-')) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - width--; - } - - start = index; - switch (ch) - { - case 'n': - case 'N': - /* Not-a-number */ - if (index != 0) - break; - /* FALLTHROUGH */ - case 'i': - case 'I': - /* Infinity */ - while (isalpha(ch) && (index - start < width)) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - doubleString[index] = NIL; - - /* Case insensitive string comparison */ - if (StrEqual(&doubleString[start], INFINITE_UPPER) || - StrEqual(&doubleString[start], LONG_INFINITE_UPPER)) - { - *target = ((start == 1 && doubleString[0] == '-')) - ? -HUGE_VAL - : HUGE_VAL; - return TRUE; - } - if (StrEqual(doubleString, NAN_LOWER)) - { - /* NaN must not have a preceeding + nor - */ - *target = TrioGenerateNaN(); - return TRUE; - } - return FALSE; - - default: - break; - } - - if (ch == '0') - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - if (toupper(ch) == 'X') - { - isHex = TRUE; - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - } - while ((ch != EOF) && (index - start < width)) - { - /* Integer part */ - if (isHex ? isxdigit(ch) : isdigit(ch)) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - else if (flags & FLAGS_QUOTE) - { - /* Compare with thousands separator */ - for (j = 0; internalThousandSeparator[j] && self->current; j++) - { - if (internalThousandSeparator[j] != self->current) - break; - - self->InStream(self, &ch); - } - if (internalThousandSeparator[j]) - break; /* Mismatch */ - else - continue; /* Match */ - } - else - break; /* while */ - } - if (ch == '.') - { - /* Decimal part */ - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - while ((isHex ? isxdigit(ch) : isdigit(ch)) && - (index - start < width)) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - if (isHex ? (toupper(ch) == 'P') : (toupper(ch) == 'E')) - { - /* Exponent */ - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - if ((ch == '+') || (ch == '-')) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - while ((isHex ? isxdigit(ch) : isdigit(ch)) && - (index - start < width)) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - } - } - - if ((index == start) || (*doubleString == NIL)) - return FALSE; - - if (flags & FLAGS_LONGDOUBLE) -/* *longdoublePointer = StrToLongDouble()*/ - return FALSE; /* FIXME: Remove when long double is implemented */ - else - { - *target = StrToDouble(doubleString, NULL); - } - return TRUE; -} - -/************************************************************************* - * TrioReadPointer [private] - */ -static BOOLEAN_T -TrioReadPointer(trio_T *self, - void **target, - unsigned long flags) -{ - trio_uintmax_t number; - char buffer[sizeof(null)]; - - flags |= (FLAGS_UNSIGNED | FLAGS_ALTERNATIVE | FLAGS_NILPADDING); - - if (TrioReadNumber(self, - &number, - flags, - POINTER_WIDTH, - BASE_HEX)) - { - /* - * The strange assignment of number is a workaround for a compiler - * warning - */ - if (target) - *target = (char *)0 + number; - return TRUE; - } - else if (TrioReadString(self, - (flags & FLAGS_IGNORE) - ? NULL - : buffer, - 0, - sizeof(null) - 1)) - { - if (StrEqualCase(buffer, null)) - { - if (target) - *target = NULL; - return TRUE; - } - } - return FALSE; -} - -/************************************************************************* - * TrioScan [private] - */ -static int -TrioScan(const void *source, - size_t sourceSize, - void (*InStream)(trio_T *, int *), - const char *format, - va_list arglist, - void **argarray) -{ -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - int charlen; -#endif - int status; - int assignment; - parameter_T parameters[MAX_PARAMETERS]; - trio_T internalData; - trio_T *data; - int ch; -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - int cnt; -#endif - int index; /* Index of format string */ - int i; /* Index of current parameter */ - unsigned long flags; - int width; - int base; - void *pointer; - - assert(VALID(InStream)); - assert(VALID(format)); - - memset(&internalData, 0, sizeof(internalData)); - data = &internalData; - data->InStream = InStream; - data->location = (void *)source; - data->max = sourceSize; - -#if defined(USE_LOCALE) - if (NULL == internalLocaleValues) - { - TrioSetLocale(); - } -#endif - - status = TrioPreprocess(TYPE_SCAN, format, parameters, arglist, argarray); - if (status < 0) - return status; - - assignment = 0; - i = 0; - index = 0; - data->InStream(data, &ch); - -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - mblen(NULL, 0); -#endif - - while (format[index]) - { -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - if (! isascii(format[index])) - { - charlen = mblen(&format[index], MB_LEN_MAX); - /* Compare multibyte characters in format string */ - for (cnt = 0; cnt < charlen - 1; cnt++) - { - if (ch != format[index + cnt]) - { - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - data->InStream(data, &ch); - } - continue; /* while */ - } -#endif /* TRIO_COMPILER_SUPPORTS_MULTIBYTE */ - if (EOF == ch) - return EOF; - - if (CHAR_IDENTIFIER == format[index]) - { - if (CHAR_IDENTIFIER == format[index + 1]) - { - /* Two % in format matches one % in input stream */ - if (CHAR_IDENTIFIER == ch) - { - data->InStream(data, &ch); - index += 2; - continue; /* while format chars left */ - } - else - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - - /* Skip the parameter entries */ - while (parameters[i].type == FORMAT_PARAMETER) - i++; - - flags = parameters[i].flags; - /* Find width */ - width = parameters[i].width; - if (flags & FLAGS_WIDTH_PARAMETER) - { - /* Get width from parameter list */ - width = (int)parameters[width].data.number.as_signed; - } - /* Find base */ - base = parameters[i].base; - if (flags & FLAGS_BASE_PARAMETER) - { - /* Get base from parameter list */ - base = (int)parameters[base].data.number.as_signed; - } - - switch (parameters[i].type) - { - case FORMAT_INT: - { - trio_uintmax_t number; - - if (0 == base) - base = BASE_DECIMAL; - - if (!TrioReadNumber(data, - &number, - flags, - width, - base)) - return assignment; - assignment++; - - if (!(flags & FLAGS_IGNORE)) - { - pointer = parameters[i].data.pointer; -#if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) - if (flags & FLAGS_SIZE_T) - *(size_t *)pointer = (size_t)number; - else -#endif -#if defined(QUALIFIER_PTRDIFF_T) - if (flags & FLAGS_PTRDIFF_T) - *(ptrdiff_t *)pointer = (ptrdiff_t)number; - else -#endif -#if defined(QUALIFIER_INTMAX_T) - if (flags & FLAGS_INTMAX_T) - *(trio_intmax_t *)pointer = (trio_intmax_t)number; - else -#endif - if (flags & FLAGS_QUAD) - *(trio_ulonglong_t *)pointer = (trio_ulonglong_t)number; - else if (flags & FLAGS_LONG) - *(long int *)pointer = (long int)number; - else if (flags & FLAGS_SHORT) - *(short int *)pointer = (short int)number; - else - *(int *)pointer = (int)number; - } - } - break; /* FORMAT_INT */ - - case FORMAT_STRING: -#if TRIO_WIDECHAR - if (flags & FLAGS_WIDECHAR) - { - if (!TrioReadWideString(data, - (flags & FLAGS_IGNORE) - ? NULL - : parameters[i].data.wstring, - flags, - width)) - return assignment; - } - else -#endif - { - if (!TrioReadString(data, - (flags & FLAGS_IGNORE) - ? NULL - : parameters[i].data.string, - flags, - width)) - return assignment; - } - assignment++; - break; /* FORMAT_STRING */ - - case FORMAT_DOUBLE: - if (!TrioReadDouble(data, - (flags & FLAGS_IGNORE) - ? NULL - : parameters[i].data.doublePointer, - flags, - width)) - return assignment; - assignment++; - break; /* FORMAT_DOUBLE */ - - case FORMAT_GROUP: - { - int characterclass[MAX_CHARACTER_CLASS + 1]; - int rc; - - /* Skip over modifiers */ - while (format[index] != SPECIFIER_GROUP) - { - index++; - } - /* Skip over group specifier */ - index++; - - memset(characterclass, 0, sizeof(characterclass)); - rc = TrioGetCharacterClass(format, - &index, - &flags, - characterclass); - if (rc < 0) - return rc; - - if (!TrioReadGroup(data, - (flags & FLAGS_IGNORE) - ? NULL - : parameters[i].data.string, - characterclass, - flags, - parameters[i].width)) - return assignment; - assignment++; - } - break; /* FORMAT_GROUP */ - - case FORMAT_COUNT: - pointer = parameters[i].data.pointer; - if (NULL != pointer) - { -#if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) - if (flags & FLAGS_SIZE_T) - *(size_t *)pointer = (size_t)data->committed; - else -#endif -#if defined(QUALIFIER_PTRDIFF_T) - if (flags & FLAGS_PTRDIFF_T) - *(ptrdiff_t *)pointer = (ptrdiff_t)data->committed; - else -#endif -#if defined(QUALIFIER_INTMAX_T) - if (flags & FLAGS_INTMAX_T) - *(trio_intmax_t *)pointer = (trio_intmax_t)data->committed; - else -#endif - if (flags & FLAGS_QUAD) - { - *(trio_ulonglong_t *)pointer = (trio_ulonglong_t)data->committed; - } - else if (flags & FLAGS_LONG) - { - *(long int *)pointer = (long int)data->committed; - } - else if (flags & FLAGS_SHORT) - { - *(short int *)pointer = (short int)data->committed; - } - else - { - *(int *)pointer = (int)data->committed; - } - } - break; /* FORMAT_COUNT */ - - case FORMAT_CHAR: -#if TRIO_WIDECHAR - if (flags & FLAGS_WIDECHAR) - { - if (TrioReadWideChar(data, - (flags & FLAGS_IGNORE) - ? NULL - : parameters[i].data.wstring, - flags, - (width == NO_WIDTH) ? 1 : width) > 0) - return assignment; - } - else -#endif - { - if (TrioReadChar(data, - (flags & FLAGS_IGNORE) - ? NULL - : parameters[i].data.string, - flags, - (width == NO_WIDTH) ? 1 : width) > 0) - return assignment; - } - assignment++; - break; /* FORMAT_CHAR */ - - case FORMAT_POINTER: - if (!TrioReadPointer(data, - (flags & FLAGS_IGNORE) - ? NULL - : (void **)parameters[i].data.pointer, - flags)) - return assignment; - assignment++; - break; /* FORMAT_POINTER */ - - case FORMAT_PARAMETER: - break; /* FORMAT_PARAMETER */ - - default: - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - ch = data->current; - index = parameters[i].indexAfterSpecifier; - i++; - } - else /* Not an % identifier */ - { - if (isspace((int)format[index])) - { - /* Whitespaces may match any amount of whitespaces */ - ch = TrioSkipWhitespaces(data); - } - else if (ch == format[index]) - { - data->InStream(data, &ch); - } - else - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - - index++; - } - } - return assignment; -} - -/************************************************************************* - * TrioInStreamFile [private] - */ -static void -TrioInStreamFile(trio_T *self, - int *intPointer) -{ - FILE *file = (FILE *)self->location; - - assert(VALID(self)); - assert(VALID(file)); - - self->current = fgetc(file); - self->processed++; - self->committed++; - - if (VALID(intPointer)) - { - *intPointer = self->current; - } -} - -/************************************************************************* - * TrioInStreamFileDescriptor [private] - */ -static void -TrioInStreamFileDescriptor(trio_T *self, - int *intPointer) -{ - int fd = *((int *)self->location); - int size; - unsigned char input; - - assert(VALID(self)); - - size = read(fd, &input, sizeof(char)); - self->current = (size == 0) ? EOF : input; - self->processed++; - self->committed++; - - if (VALID(intPointer)) - { - *intPointer = self->current; - } -} - -/************************************************************************* - * TrioInStreamString [private] - */ -static void -TrioInStreamString(trio_T *self, - int *intPointer) -{ - unsigned char **buffer; - - assert(VALID(self)); - assert(VALID(self->InStream)); - assert(VALID(self->location)); - - buffer = (unsigned char **)self->location; - self->current = (*buffer)[0]; - if (self->current == NIL) - self->current = EOF; - (*buffer)++; - self->processed++; - self->committed++; - - if (VALID(intPointer)) - { - *intPointer = self->current; - } -} - -/************************************************************************* - * scanf - */ -int -trio_scanf(const char *format, - ...) -{ - int status; - va_list args; - - assert(VALID(format)); - - va_start(args, format); - status = TrioScan(stdin, 0, TrioInStreamFile, format, args, NULL); - va_end(args); - return status; -} - -int -trio_vscanf(const char *format, - va_list args) -{ - assert(VALID(format)); - - return TrioScan(stdin, 0, TrioInStreamFile, format, args, NULL); -} - -int -trio_scanfv(const char *format, - void **args) -{ - va_list dummy; - shutup_unitialized(&dummy); - - assert(VALID(format)); - - return TrioScan(stdin, 0, TrioInStreamFile, format, dummy, args); -} - -/************************************************************************* - * fscanf - */ -int -trio_fscanf(FILE *file, - const char *format, - ...) -{ - int status; - va_list args; - - assert(VALID(file)); - assert(VALID(format)); - - va_start(args, format); - status = TrioScan(file, 0, TrioInStreamFile, format, args, NULL); - va_end(args); - return status; -} - -int -trio_vfscanf(FILE *file, - const char *format, - va_list args) -{ - assert(VALID(file)); - assert(VALID(format)); - - return TrioScan(file, 0, TrioInStreamFile, format, args, NULL); -} - -int -trio_fscanfv(FILE *file, - const char *format, - void **args) -{ - va_list dummy; - shutup_unitialized(&dummy); - - assert(VALID(file)); - assert(VALID(format)); - - return TrioScan(file, 0, TrioInStreamFile, format, dummy, args); -} - -/************************************************************************* - * dscanf - */ -int -trio_dscanf(int fd, - const char *format, - ...) -{ - int status; - va_list args; - - assert(VALID(format)); - - va_start(args, format); - status = TrioScan(&fd, 0, TrioInStreamFileDescriptor, format, args, NULL); - va_end(args); - return status; -} - -int -trio_vdscanf(int fd, - const char *format, - va_list args) -{ - assert(VALID(format)); - - return TrioScan(&fd, 0, TrioInStreamFileDescriptor, format, args, NULL); -} - -int -trio_dscanfv(int fd, - const char *format, - void **args) -{ - va_list dummy; - shutup_unitialized(&dummy); - - assert(VALID(format)); - - return TrioScan(&fd, 0, TrioInStreamFileDescriptor, format, dummy, args); -} - -/************************************************************************* - * sscanf - */ -int -trio_sscanf(const char *buffer, - const char *format, - ...) -{ - int status; - va_list args; - - assert(VALID(buffer)); - assert(VALID(format)); - - va_start(args, format); - status = TrioScan(&buffer, 0, TrioInStreamString, format, args, NULL); - va_end(args); - return status; -} - -int -trio_vsscanf(const char *buffer, - const char *format, - va_list args) -{ - assert(VALID(buffer)); - assert(VALID(format)); - - return TrioScan(&buffer, 0, TrioInStreamString, format, args, NULL); -} - -int -trio_sscanfv(const char *buffer, - const char *format, - void **args) -{ - va_list dummy; - shutup_unitialized(&dummy); - - assert(VALID(buffer)); - assert(VALID(format)); - - return TrioScan(&buffer, 0, TrioInStreamString, format, dummy, args); -} - diff --git a/org.glite.lb.common/src/triop.h b/org.glite.lb.common/src/triop.h deleted file mode 100644 index ca49fab..0000000 --- a/org.glite.lb.common/src/triop.h +++ /dev/null @@ -1,138 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 2000 Bjorn Reese and Daniel Stenberg. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************ - * - * Private functions, types, etc. used for callback functions. - * - * The ref pointer is an opaque type and should remain as such. - * Private data must only be accessible through the getter and - * setter functions. - * - ************************************************************************/ - -#ifndef TRIO_TRIOP_H -#define TRIO_TRIOP_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef TRIO_C99 -# define TRIO_C99 1 -#endif -#ifndef TRIO_BSD -# define TRIO_BSD 1 -#endif -#ifndef TRIO_GNU -# define TRIO_GNU 1 -#endif -#ifndef TRIO_MISC -# define TRIO_MISC 1 -#endif -#ifndef TRIO_UNIX98 -# define TRIO_UNIX98 1 -#endif -#ifndef TRIO_MICROSOFT -# define TRIO_MICROSOFT 1 -#endif -#ifndef TRIO_EXTENSION -# define TRIO_EXTENSION 1 -#endif -#ifndef TRIO_WIDECHAR -# define TRIO_WIDECHAR 0 -#endif -#ifndef TRIO_ERRORS -# define TRIO_ERRORS 1 -#endif - -#ifndef TRIO_MALLOC -# define TRIO_MALLOC(n) malloc(n) -#endif -#ifndef TRIO_REALLOC -# define TRIO_REALLOC(x,n) realloc((x),(n)) -#endif -#ifndef TRIO_FREE -# define TRIO_FREE(x) free(x) -#endif - -typedef int (*trio_callback_t)(void *ref); - -void *trio_register(trio_callback_t callback, const char *name); -void trio_unregister(void *handle); - -const char *trio_get_format(void *ref); -void *trio_get_argument(void *ref); - -/* Modifiers */ -int trio_get_width(void *ref); -void trio_set_width(void *ref, int width); -int trio_get_precision(void *ref); -void trio_set_precision(void *ref, int precision); -int trio_get_base(void *ref); -void trio_set_base(void *ref, int base); -int trio_get_padding(void *ref); -void trio_set_padding(void *ref, int is_padding); -int trio_get_short(void *ref); /* h */ -void trio_set_shortshort(void *ref, int is_shortshort); -int trio_get_shortshort(void *ref); /* hh */ -void trio_set_short(void *ref, int is_short); -int trio_get_long(void *ref); /* l */ -void trio_set_long(void *ref, int is_long); -int trio_get_longlong(void *ref); /* ll */ -void trio_set_longlong(void *ref, int is_longlong); -int trio_get_longdouble(void *ref); /* L */ -void trio_set_longdouble(void *ref, int is_longdouble); -int trio_get_alternative(void *ref); /* # */ -void trio_set_alternative(void *ref, int is_alternative); -int trio_get_alignment(void *ref); /* - */ -void trio_set_alignment(void *ref, int is_leftaligned); -int trio_get_spacing(void *ref); /* (space) */ -void trio_set_spacing(void *ref, int is_space); -int trio_get_sign(void *ref); /* + */ -void trio_set_sign(void *ref, int is_showsign); -int trio_get_quote(void *ref); /* ' */ -void trio_set_quote(void *ref, int is_quote); -int trio_get_upper(void *ref); -void trio_set_upper(void *ref, int is_upper); -#if TRIO_C99 -int trio_get_largest(void *ref); /* j */ -void trio_set_largest(void *ref, int is_largest); -int trio_get_ptrdiff(void *ref); /* t */ -void trio_set_ptrdiff(void *ref, int is_ptrdiff); -int trio_get_size(void *ref); /* z / Z */ -void trio_set_size(void *ref, int is_size); -#endif - -/* Printing */ -int trio_print_ref(void *ref, const char *format, ...); -int trio_vprint_ref(void *ref, const char *format, va_list args); -int trio_printv_ref(void *ref, const char *format, void **args); - -void trio_print_int(void *ref, int number); -void trio_print_uint(void *ref, unsigned int number); -/* void trio_print_long(void *ref, long number); */ -/* void trio_print_ulong(void *ref, unsigned long number); */ -void trio_print_double(void *ref, double number); -void trio_print_string(void *ref, char *string); -void trio_print_pointer(void *ref, void *pointer); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* TRIO_TRIOP_H */ diff --git a/org.glite.lb.common/src/ulm_parse.c b/org.glite.lb.common/src/ulm_parse.c deleted file mode 100644 index 2525a3e..0000000 --- a/org.glite.lb.common/src/ulm_parse.c +++ /dev/null @@ -1,410 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include - -/*========= DATA =====================================================*/ - -#include "ulm_parse.h" - -/*========= FUNCTIONS ================================================*/ - -/* -- Internal function prototype -- */ -void edg_wll_ULMSplitDate( const char *s, - unsigned int *year, - unsigned int *mon, - unsigned int *day, - unsigned int *hour, - unsigned int *min, - unsigned int *sec, - unsigned long *usec ); -int edg_wll_ULMisalphaext( int c); - -/* - *---------------------------------------------------------------------- - * - * edg_wll_ULMNewParseTable -- Allocate memory for new parse table - * - * Calls: malloc, strdup - * - * Algorithm: - * - *---------------------------------------------------------------------- - */ -p_edg_wll_ULMFields edg_wll_ULMNewParseTable(LogLine logline) -{ - p_edg_wll_ULMFields this = (p_edg_wll_ULMFields) calloc(1,sizeof(edg_wll_ULMFields)); - LogLine ln = logline; - - /* Strip leading spaces */ - for ( ; *ln && isblank(*ln); ln++ ); - - this->names = NULL; - this->vals = NULL; - this->num = 0; - this->raw = strdup(ln); - - return this; -} - -/* - *---------------------------------------------------------------------- - * - * edg_wll_ULMFreeParseTable -- Free memory allocated for parse table - * - * Calls: free - * - * Algorithm: - * - *---------------------------------------------------------------------- - */ -void edg_wll_ULMFreeParseTable(p_edg_wll_ULMFields this) -{ - EDG_WLL_ULM_CLEAR_FIELDS(this); - if (this->raw) free(this->raw); - if (this) free(this); -} - - -/* - *---------------------------------------------------------------------- - * - * edg_wll_ULMProcessParseTable -- Break UML message into fields. - * - * Calls: strchr, strrchr - * - * Algorithm: - * LogLine is of the ULM form as described in draft-abela-ulm-05. - * - the ULM_EQ symbol separates name,value pairs - * - quote marks must be taken into account - * 1. count ULM_EQ and ULM_SP symbols, - * 2. allocate the integer arrays 'names' and 'vals' which hold - * the indices of subsequent name and value strings, - * 3. the original raw data will be peppered with \0's so that raw[index] - * will give the proper string if index is in names[] or vals[] - * - * The actual algorithm to get these indices is a simple array lookup. - * - * The following illegal formats are caught: - * 1. no name=value pairs - * 2. space or tab next to delimiter - * 3. logline starts or ends with delimiter - * 4. no spaces between successive delimiters - * 5. illegal character after ending ULM_QM - * - *---------------------------------------------------------------------- - */ -int edg_wll_ULMProcessParseTable(p_edg_wll_ULMFields this) -{ - char *func = "edg_wll_ULMProcessParseTable"; - char *eq; - int i,j; - int eqCnt,qmCnt,spCnt; - int iArrayEQ[ULM_FIELDS_MAX]; - int iArraySP[ULM_FIELDS_MAX]; - size_t size; - - if ( (this == NULL) || (this->raw == NULL) || (*this->raw == '\0')) { - fprintf(stderr,"%s: PARSE ERROR: Nothing to parse.\n",func); - return ULM_PARSE_ERROR; - } - - /* Init data */ - EDG_WLL_ULM_CLEAR_FIELDS(this); - - for (i=0; iraw); - - /* Count number of ULM_EQ and ULM_SP - * and replace all ULM_LF by nul characters */ - for (i=0; i< (int)size; i++) { - switch (this->raw[i]) { - case ULM_SP : - case ULM_TB : - if (qmCnt == 0) { iArraySP[spCnt] = i; spCnt++; } - break; - case ULM_EQ : - if (i==0) { - fprintf(stderr,"%s: PARSE ERROR: '%c' at the beginning of log line.\n", func, ULM_EQ); - return ULM_PARSE_ERROR; - } - if (qmCnt == 0) { - if (isblank(this->raw[i-1]) || (!edg_wll_ULMisalphaext(this->raw[i-1]))) { - fprintf(stderr,"%s: PARSE ERROR: Disallowed character ('%c') or space before delimiter '%c'.\n", - func,this->raw[i-1],ULM_EQ); - return ULM_PARSE_ERROR; - } - if (isblank(this->raw[i+1]) || ((!edg_wll_ULMisalphaext(this->raw[i-1])) && (this->raw[i+1] != ULM_QM ))) { - fprintf(stderr,"%s: PARSE ERROR: Disallowed character ('%c') or space after delimiter '%c'.\n", - func,this->raw[i+1],ULM_EQ); - return ULM_PARSE_ERROR; - } - iArrayEQ[eqCnt] = i; - eqCnt++; - } - break; - case ULM_LF : - if (qmCnt == 0) { this->raw[i] = '\0'; } - break; - case ULM_QM : - if (this->raw[i-1] != ULM_BS) { - if (qmCnt == 0) qmCnt++; - else qmCnt--; - } - if ((qmCnt == 0) && (!isspace(this->raw[i+1]) && (this->raw[i+1] != '\0'))) { - fprintf(stderr,"%s: PARSE ERROR: Disallowed character ('%c') after ending '%c'at i=%d size=%lu char=%d.\n", - func,this->raw[i+1],ULM_QM,i,(unsigned long)size,this->raw[i+1]); - for (j=0; j<=i; j++) fputc(this->raw[j],stderr); - fputc(ULM_LF,stderr); - return ULM_PARSE_ERROR; - } - break; - default : - break; - } /* switch */ - } /* for */ - - if (eqCnt == 0) { - fprintf(stderr,"%s: PARSE ERROR: No '%c' in line \"%s\"\n",func,ULM_EQ,this->raw); - return ULM_PARSE_ERROR; - } - - if (this->raw[0] == ULM_EQ) { - fprintf(stderr,"%s: PARSE ERROR: Need at least 1 letter for the first field name.\n",func); - return ULM_PARSE_ERROR; - } - - if (qmCnt != 0) { - fprintf(stderr,"%s: PARSE ERROR: Last quoted value did not finish.\n",func); - return ULM_PARSE_ERROR; - } - - /* Allocate names, vals arrays */ - this->names = (int *) malloc(eqCnt*sizeof(int)); - this->vals = (int *) malloc(eqCnt*sizeof(int)); - - this->names[0] = (int)(0); - this->vals[0] = (int)(iArrayEQ[0] + 1); - - /* - * Main loop - */ - for (i=1; iraw[iArrayEQ[i]]; - j = 1; - while (edg_wll_ULMisalphaext(*(eq-j))) { - j++; - } - if (isblank(*(eq-j))) { - this->names[i] = (int)(iArrayEQ[i] - j + 1); - this->vals[i] = (int)(iArrayEQ[i] + 1); - } - else { - fprintf(stderr,"%s: PARSE ERROR: Disallowed character '%c' for field name \ -(e.g. no space between successive delimiters).\n",func,*(eq-j)); - return ULM_PARSE_ERROR; - } - } /* for */ - - /* Replace delimiters and intervening whitespace by nul characters */ - for (i=0; iraw[iArrayEQ[i]] = '\0'; - for (i=0; iraw[iArraySP[i]] = '\0'; - - this->num = eqCnt; - - /* Debug dump of parsed fields */ -// for( i=0; iraw+this->names[i],this->raw+this->vals[i]); - - return ULM_PARSE_OK; -} - -/* - *--------------------------------------------------------------------------- - * edg_wll_ULMisalphaext - test if the character is an ALPHAEXT as described in - * draft-abela-ulm-05 - *--------------------------------------------------------------------------- - */ -int edg_wll_ULMisalphaext( int c) { - - return (isalnum(c) || (c == '.') || (c == '-') || c == '_'); -} - -/* - *---------------------------------------------------------------------- - * - * edg_wll_ULMGetNameAt -- Get name at index. - * - * Calls: - * - * Algorithm: array lookup - * - *---------------------------------------------------------------------- - */ -char *edg_wll_ULMGetNameAt( p_edg_wll_ULMFields this, int index ) -{ - if ( index < 0 || index > this->num ) - return NULL; - return (char *)&(this->raw[this->names[index]]); -} - -/* - *---------------------------------------------------------------------- - * - * edg_wll_ULMGetValueAt -- Get value at index - * - * Calls: - * - * Algorithm: array lookup - * - *---------------------------------------------------------------------- - */ -char *edg_wll_ULMGetValueAt( p_edg_wll_ULMFields this, int index ) -{ - if ( index < 0 || index > this->num ) - return NULL; - return (char *)&(this->raw[this->vals[index]]); -} - -/* - *--------------------------------------------------------------------------- - * edg_wll_ULMDateToDouble -- Calculate date in sec. since 1/1/1970 from string. - * Algorithm borrowed from linux kernel source code, - * i.e. Linus Torvalds, who in turn credits it to Gauss. - * - * PRE: Input is properly formatted, non-null, need _not_ be null-terminated. - * IN : String in format YYYYMMDDHHmmss.uuuuuu - * YYYY = 4 digit year - * MM = 2 digit month (1..12) - * DD = 2 digit day of month (1..31) - * HH = 2 digit hour of day ( 0..23 ) - * mm = 2 digit minute of hour ( 0..59 ) - * ss = 2 digit second of minute ( 0..59 ) - * uuuuuu= 1..6 digit microsecond of second ( 0..999999 ) - * OUT: Number of seconds, and fraction accurate to at most microseconds, - * elapsed since 1/1/1970 (GMT). - * - * edg_wll_ULMDateToTimeval -- the same, except it returns timeval - *--------------------------------------------------------------------------- - */ -double edg_wll_ULMDateToDouble( const char *s ) -{ - unsigned int year, mon, day, hour, min, sec=0; - unsigned long usec=0L; - - edg_wll_ULMSplitDate( s, &year, &mon, &day, &hour, &min, &sec, &usec ); - - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return (double) - ( ( ( ( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec /* seconds */ - ) + (double)( usec / 1E6 ); /* microseconds */ -} - -void edg_wll_ULMDateToTimeval( const char *s, struct timeval *tv ) -{ - unsigned int year, mon, day, hour, min, sec=0; - unsigned long usec=0L; - - edg_wll_ULMSplitDate( s, &year, &mon, &day, &hour, &min, &sec, &usec ); - - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - tv->tv_sec = (long) - ( ( ( ( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec /* seconds */ - ); - tv->tv_usec = usec; /* microseconds */ -} - -/* - *--------------------------------------------------------------------------- - * edg_wll_ULMSplitDate -- Efficiently break date into parsed component parts. - *--------------------------------------------------------------------------- - */ -#define DIG(x) ((int)((x)-'0')) -void edg_wll_ULMSplitDate( const char *s, - unsigned int *year, - unsigned int *mon, - unsigned int *day, - unsigned int *hour, - unsigned int *min, - unsigned int *sec, - unsigned long *usec ) -{ - *year = DIG(s[0]) * 1000 + DIG(s[1]) * 100 + DIG(s[2]) * 10 + DIG(s[3]); - *mon = DIG(s[4]) * 10 + DIG(s[5]); - *day = DIG(s[6]) * 10 + DIG(s[7]); - *hour = DIG(s[8]) * 10 + DIG(s[9]); - *min = DIG(s[10]) * 10 + DIG(s[11]); - *sec = DIG(s[12]) * 10 + DIG(s[13]); - if ( s[14] == '.' ) *usec = atol(s+15); -} -#undef DIG - -/* - *--------------------------------------------------------------------------- - * edg_wll_ULMTimevalToDate -- Take a seconds, microseconds argument and convert it - * to a date string that edg_wll_ULMDateToDouble could parse. - * - * CALL: gmtime, strftime - * - * PRE : seconds, usec >= 0 , usec < 1000000 (checked) - * date string has DATE_STRING_LENGTH+1 bytes allocated (not checked) - * IN : seconds, useconds - * OUT : date string 'dstr'. - * RTRN: 0=OK, other=FAILURE - * POST: This is the inverse of edg_wll_ULMDateToDouble, i.e. - * edg_wll_ULMDateToDouble( edg_wll_ULMTimevalToDate( sec, usec ) ) = sec.usec - *--------------------------------------------------------------------------- - */ -int edg_wll_ULMTimevalToDate( long sec, long usec, char *dstr ) -{ - char *func = "edg_wll_ULMTimevalToDate"; - struct tm *tp; - int len; - - if ( sec < 0 || usec < 0 || usec > 999999 ) - return 1; - - tp = gmtime( (const time_t *) &sec ); - if ( tp == NULL ) - return 1; - - len = strftime( dstr, - ULM_DATE_STRING_LENGTH+1-7, - "%Y%m%d%H%M%S", - tp ); - if ( len != ULM_DATE_STRING_LENGTH-7 ) { - fprintf(stderr,"%s: bad strftime() return value: %d\n",func, len); - return 1; - } - - sprintf( dstr + ULM_DATE_STRING_LENGTH-7, ".%06ld", usec ); - - return 0; -} - diff --git a/org.glite.lb.common/src/xml_conversions.c b/org.glite.lb.common/src/xml_conversions.c deleted file mode 100644 index 515a6d6..0000000 --- a/org.glite.lb.common/src/xml_conversions.c +++ /dev/null @@ -1,840 +0,0 @@ -#ident "$Header$" - -#include -#include - -#include "trio.h" - -#include "xml_conversions.h" - - - -static const struct timeval null_timeval = {0,0}; - - -/************************************************************************/ -/* Context manipulation functions */ - - -void edg_wll_initXMLCtx(edg_wll_XML_ctx *c) { - c->ctx = NULL; - c->p = NULL; - c->message_body = NULL; - c->eventCode = EDG_WLL_EVENT_UNDEF; - c->position = 0; - c->position2 = 0; - c->max_index = -1; - c->row = 0; - c->row2 = 0; - c->level = 0; - memset(&(c->element), 0, sizeof(c->element)); - c->char_buf = NULL; - c->char_buf_len = 0; - c->XML_tag = NULL; - c->XML_tag2 = NULL; - c->job_conditions = NULL; - c->event_conditions = NULL; - c->type = EDG_WLL_QUERY_TYPE_UNDEF; - c->conditions = NULL; - c->flags = 0; - c->jobsOutGlobal = NULL; - c->eventsOutGlobal = NULL; - c->jobStatGlobal = NULL; - memset(&(c->jobStatSingleGlobal),0,sizeof(c->jobStatSingleGlobal)); - c->strListGlobal = NULL; - c->intListGlobal = NULL; - c->indexToTag = NULL; - c->tagToIndex = NULL; - c->tagListGlobal = NULL; - c->stsListGlobal = NULL; - memset(&(c->purgeRequestGlobal),0,sizeof(c->purgeRequestGlobal)); - memset(&(c->purgeResultGlobal),0,sizeof(c->purgeResultGlobal)); - memset(&(c->dumpRequestGlobal),0,sizeof(c->dumpRequestGlobal)); - memset(&(c->dumpResultGlobal),0,sizeof(c->dumpResultGlobal)); - memset(&(c->loadRequestGlobal),0,sizeof(c->loadRequestGlobal)); - memset(&(c->loadResultGlobal),0,sizeof(c->loadResultGlobal)); - c->notifFunction = NULL; - c->notifClientAddress = NULL; - c->notifId = NULL; - c->notifChangeOp = EDG_WLL_NOTIF_NOOP; - c->notifValidity = -1; - c->jobId = NULL; - c->source = NULL; - c->seqCode = NULL; - c->attrsGlobal = NULL; - c->errCode = 0; - c->bound = 0; - c->errDesc = NULL; - c->stat_begin = 0; - c->jobQueryRec_begin = 0; - c->errtxt = NULL; - c->warntxt = NULL; -} - - -void edg_wll_freeXMLCtx(edg_wll_XML_ctx *c) { - if (c->char_buf) free(c->char_buf); - if (c->errtxt) free(c->errtxt); - if (c->warntxt) free(c->warntxt); - if (c->XML_tag) free(c->XML_tag); - if (c->XML_tag2) free(c->XML_tag2); -} - - -void edg_wll_freeBuf(edg_wll_XML_ctx *c) { - free(c->char_buf); - c->char_buf = NULL; - c->char_buf_len = 0; -} - - - -/************************************************************************/ -/* type to XML conversion functions */ - - -/* edg_wll_add_string_to_XMLBody(&body, eventsOut[i].jobMatch.destination, "destination", NULL) */ - -void edg_wll_add_string_to_XMLBody(char **body, const char *toAdd, const char *tag, const char *null) -{ - if ( toAdd != null ) { - char *newBody; - - trio_asprintf(&newBody,"%s\t\t\t<%s>%|Xs\r\n", *body, tag, toAdd, tag); - - free(*body); - *body = newBody; - } -} - -void edg_wll_add_tagged_string_to_XMLBody(char **body, const char *toAdd, const char *tag, - const char *name, const char *tag2, const char *null) -{ - if ( toAdd != null ) { - char *newBody; - - trio_asprintf(&newBody,"%s\t\t\t<%s %s=\"%|Xs\">%|Xs\r\n", - *body, tag, tag2, name, toAdd, tag); - - free(*body); - *body = newBody; - } -} - -/* edg_wll_add_int_to_XMLBody(&body, eventsOut[i].jobMatch.code, "code", 0) */ - -void edg_wll_add_int_to_XMLBody(char **body, const int toAdd, const char *tag, const int null) -{ - if (toAdd != null) { - char *newBody; - - trio_asprintf(&newBody,"%s\t\t\t<%s>%|Xd\r\n", *body, tag, toAdd, tag); - - free(*body); - *body = newBody; - } -} - - -/* edg_wll_add_timeval_to_XMLBody(&body, eventsOut[i].any.tv, "timestamp", -1) */ - -void edg_wll_add_timeval_to_XMLBody(char **body, struct timeval toAdd, const char *tag, const struct timeval null) -{ - - if (toAdd.tv_sec != null.tv_sec || toAdd.tv_usec != null.tv_usec) { - char *newBody; - - trio_asprintf(&newBody,"%s\t\t\t<%s>%ld.%06ld\r\n", - *body, tag, toAdd.tv_sec, toAdd.tv_usec, tag); - - free(*body); - *body = newBody; - } -} - - -/* edg_wll_add_jobid_to_XMLBody(&body, eventsOut[i].any.jobId, "jobId", NULL) */ - -void edg_wll_add_jobid_to_XMLBody(char **body, edg_wlc_JobId toAdd, const char *tag, const void *null) -{ - if (toAdd != (edg_wlc_JobId) null) { - char *newBody, *pom; - - trio_asprintf(&newBody,"%s\t\t\t<%s>%|Xs\r\n", - *body, tag, pom = edg_wlc_JobIdUnparse(toAdd), tag); - - free(*body); - free(pom); - *body = newBody; - } -} - - -void edg_wll_add_notifid_to_XMLBody(char **body, edg_wll_NotifId toAdd, const char *tag, const void *null) -{ - if (toAdd != (edg_wll_NotifId) null) { - char *newBody, *pom; - - trio_asprintf(&newBody,"%s\t\t\t<%s>%|Xs\r\n", - *body, tag, pom = edg_wll_NotifIdUnparse(toAdd), tag); - - free(*body); - free(pom); - *body = newBody; - } -} - - -/* edg_wll_add_edg_wll_JobStatCode_to_XMLBody(&body, eventsOut[i].any.jobId, "jobId", EDG_WLL_JOB_UNDEF) */ - -void edg_wll_add_edg_wll_JobStatCode_to_XMLBody(char **body, edg_wll_JobStatCode toAdd, const char *tag, const edg_wll_JobStatCode null) -{ - if (toAdd != null) { - char *newBody, *pom; - - trio_asprintf(&newBody,"%s\t\t\t<%s>%|Xs\r\n", - *body, tag, pom = edg_wll_StatToString(toAdd), tag); - - free(*body); - free(pom); - *body = newBody; - } -} - -void edg_wll_add_edg_wll_EventCode_to_XMLBody(char **body, edg_wll_EventCode toAdd, const char *tag, const edg_wll_EventCode null) -{ - char *newBody, *pom; - - if (toAdd != null) { - trio_asprintf(&newBody,"%s\t\t\t<%s>%|Xs\r\n", - *body, tag, pom = edg_wll_EventToString(toAdd), tag); - - free(*body); - free(pom); - *body = newBody; - } -} - - -void edg_wll_add_time_t_to_XMLBody(char **body, const time_t toAdd, const char *tag, const time_t null) -{ - if (toAdd != null) { - char *newBody; - - trio_asprintf(&newBody,"%s\t\t\t<%s>%|Xld\r\n", *body, tag, toAdd, tag); - - free(*body); - *body = newBody; - } -} - - -void edg_wll_add_tagged_time_t_to_XMLBody(char **body, const time_t toAdd, const char *tag, - const char *name, const char *tag2, const time_t null) -{ - if ( toAdd != null ) { - char *newBody; - - trio_asprintf(&newBody,"%s\t\t\t<%s %s=\"%|Xs\">%|Xld\r\n", - *body, tag, tag2, name, toAdd, tag); - - free(*body); - *body = newBody; - } -} - - -void edg_wll_add_uint16_t_to_XMLBody(char **body, const uint16_t toAdd, const char *tag, const uint16_t null) -{ - if (toAdd != null) { - char *newBody; - - trio_asprintf(&newBody,"%s\t\t\t<%s>%|Xu\r\n", *body, tag, toAdd, tag); - - free(*body); - *body = newBody; - } -} - - -void edg_wll_add_logsrc_to_XMLBody(char **body, const edg_wll_Source toAdd, const char *tag, const edg_wll_Source null) -{ - if (toAdd != null) { - char *newBody, *pom; - - trio_asprintf(&newBody,"%s\t\t\t<%s>%|Xs\r\n", - *body, tag, pom = edg_wll_SourceToString(toAdd), tag); - - free(*body); - free(pom); - *body = newBody; - } -} - -void edg_wll_add_strlist_to_XMLBody(char **body, char * const *toAdd, const char *tag, const char *subTag, const char *indent, const char *null) -{ - char *pomA, *pomB, *newBody; - char **list = NULL; - int i = 0, len, tot_len = 0; - int *len_list = NULL; - - - if (!toAdd) return; - - while (toAdd[i] != null) { - len = trio_asprintf(&pomA,"%s\t<%s>%|Xs\r\n", - indent,subTag,toAdd[i],subTag); - - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - pomA = NULL; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + 1); - pomB = pomA; - - i = 0; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - *pomB = '\0'; - free(list); - free(len_list); - - asprintf(&newBody,"%s%s<%s>\r\n%s%s\r\n", *body, indent, tag, pomA, indent, tag); - free(*body); - free(pomA); - *body = newBody; -} - -void edg_wll_add_intlist_to_XMLBody(char **body, const int *toAdd, const char *tag, char *(*indexToTag)(), const char *indent, const int from, const int to) -{ - char *pomA, *pomB, *newBody; - char **list = NULL; - int i, len, tot_len = 0; - int *len_list = NULL; - - - i = from; - while (i <= to) { - len = trio_asprintf(&pomA,"%s\t<%s>%|Xd\r\n", - indent, indexToTag(i-1),toAdd[i],indexToTag(i-1)); - - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - pomA = NULL; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + 1); - pomB = pomA; - - i = from; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - *pomB = '\0'; - free(list); - free(len_list); - - asprintf(&newBody,"%s%s<%s>\r\n%s%s\r\n", *body, indent, tag, pomA, indent, tag); - free(*body); - free(pomA); - *body = newBody; -} - - -void edg_wll_add_taglist_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const char *subTag, const char *subTag2, const char *indent, const char *null) -{ - char *pomA, *pomB, *newBody; - char **list = NULL; - int i = 0, len, tot_len = 0; - int *len_list = NULL; - - - while (toAdd && (toAdd[i].tag != null) ) { - len = trio_asprintf(&pomA,"%s\t<%s %s=\"%|Xs\">%|Xs\r\n", - indent,subTag,subTag2,toAdd[i].tag,toAdd[i].value,subTag); - - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - pomA = NULL; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + 1); - pomB = pomA; - - i = 0; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - *pomB = '\0'; - free(list); - free(len_list); - - asprintf(&newBody,"%s%s<%s>\r\n%s%s\r\n", *body, indent, tag, pomA, indent, tag); - free(*body); - free(pomA); - *body = newBody; -} - - -void edg_wll_add_time_t_list_to_XMLBody(char **body, const time_t *toAdd, const char *tag, char *(*indexToTag)(), const char *indent, const int from, const int to) -{ - char *pomA, *pomB, *newBody; - char **list = NULL; - int i, len, tot_len = 0; - int *len_list = NULL; - - - i = from; - while (i < to) { - len = trio_asprintf(&pomA,"%s\t<%s>%|Xld\r\n", - indent, indexToTag(i),toAdd[i],indexToTag(i)); - - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - pomA = NULL; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + 1); - pomB = pomA; - - i = 0; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - *pomB = '\0'; - free(list); - free(len_list); - - asprintf(&newBody,"%s%s<%s>\r\n%s%s\r\n", *body, indent, tag, pomA, indent, tag); - free(*body); - free(pomA); - *body = newBody; -} - - -// void edg_wll_add_stslist_to_XMLBody(char **body, const edg_wll_JobStat *toAdd, const char *tag, const char *UNUSED_subTag, const int null) -// in lbserver/lb_xml_parse.c.T - -/************************************************************************/ -/* string to type conversion functions */ - - -/* XMLCtx->eventsOutGlobal[XMLCtx->position].any.prog = edg_wll_from_string_to_string(XMLCtx); */ -char *edg_wll_from_string_to_string(edg_wll_XML_ctx *XMLCtx) -{ - return(XMLCtx->char_buf); -} - - -/* XMLCtx->eventsOutGlobal[XMLCtx->position].any.jobId = edg_wll_from_string_to_dgJobId(XMLCtx); */ -edg_wlc_JobId edg_wll_from_string_to_jobid(edg_wll_XML_ctx *XMLCtx) -{ - edg_wlc_JobId out; - - edg_wlc_JobIdParse(XMLCtx->char_buf, &out); - edg_wll_freeBuf(XMLCtx); - - return(out); -} - - - -edg_wll_NotifId edg_wll_from_string_to_notifid(edg_wll_XML_ctx *XMLCtx) -{ - edg_wll_NotifId out; - - edg_wll_NotifIdParse(XMLCtx->char_buf, &out); - edg_wll_freeBuf(XMLCtx); - - return(out); -} - - - -edg_wll_JobStatCode edg_wll_from_string_to_edg_wll_JobStatCode(edg_wll_XML_ctx *XMLCtx) -{ - edg_wll_JobStatCode out; - - out = edg_wll_StringToStat(XMLCtx->char_buf); - edg_wll_freeBuf(XMLCtx); - - return(out); -} - - - - -/* XMLCtx->eventsOutGlobal[XMLCtx->position].jobClear.clearReason = - edg_wll_from_string_to_int(XMLCtx); */ -int edg_wll_from_string_to_int(edg_wll_XML_ctx *XMLCtx) -{ - int out; - - out = atoi(XMLCtx->char_buf); - edg_wll_freeBuf(XMLCtx); - - return(out); -} - - -long edg_wll_from_string_to_long(edg_wll_XML_ctx *XMLCtx) -{ - long out; - - out = atol(XMLCtx->char_buf); - edg_wll_freeBuf(XMLCtx); - - return(out); -} - - -uint16_t edg_wll_from_string_to_uint16_t(edg_wll_XML_ctx *XMLCtx) -{ - return( (uint16_t) edg_wll_from_string_to_int(XMLCtx) ); -} - - -struct timeval edg_wll_from_string_to_timeval(edg_wll_XML_ctx *XMLCtx) -{ - struct timeval out; - char *needle, *nil; - - out.tv_sec = strtol(XMLCtx->char_buf, &needle, 10); - out.tv_usec = strtol(needle+1, &nil, 10); - edg_wll_freeBuf(XMLCtx); - - return(out); -} - - -time_t edg_wll_from_string_to_time_t(edg_wll_XML_ctx *XMLCtx) -{ - return( (time_t) edg_wll_from_string_to_long(XMLCtx) ); -} - - -edg_wll_Source edg_wll_from_string_to_logsrc(edg_wll_XML_ctx *XMLCtx) -{ - edg_wll_Source out = edg_wll_StringToSource(XMLCtx->char_buf); - - edg_wll_freeBuf(XMLCtx); - return(out); -} - - - -/************************************************************************/ -/* various conversion functions */ - - -char *edg_wll_stat_flags_to_string(int flags) -{ - char *cflags = NULL, *temp_cflags = NULL; - - - if (flags & EDG_WLL_STAT_CLASSADS) asprintf(&cflags,"%s","classadd"); - if (flags & EDG_WLL_STAT_CHILDREN) { - if (cflags) { - asprintf(&temp_cflags,"%s+%s",cflags,"children"); - free(cflags); - cflags=temp_cflags; - } - else asprintf(&cflags,"%s","children"); - } - if (flags & EDG_WLL_STAT_CHILDSTAT) { - if (cflags) { - asprintf(&temp_cflags,"%s+%s",cflags,"childstat"); - free(cflags); - cflags=temp_cflags; - } - else asprintf(&cflags,"%s","childstat"); - } - if (flags & EDG_WLL_STAT_NO_JOBS) { - if (cflags) { - asprintf(&temp_cflags,"%s+%s",cflags,"no_jobs"); - free(cflags); - cflags=temp_cflags; - } - else asprintf(&cflags,"%s","no_jobs"); - } - if (flags & EDG_WLL_STAT_NO_STATES) { - if (cflags) { - asprintf(&temp_cflags,"%s+%s",cflags,"no_states"); - free(cflags); - cflags=temp_cflags; - } - else asprintf(&cflags,"%s","no_states"); - } - - if (!cflags) cflags = strdup(""); - - return(cflags); -} - - -int edg_wll_string_to_stat_flags(char *cflags) -{ - int flags = 0; - char *sflag, *last; - - if (cflags == NULL) return 0; - - sflag = strtok_r(cflags, "+", &last); - while (sflag != NULL) { - if (!strcmp(sflag,"classadd")) flags = flags | EDG_WLL_STAT_CLASSADS; - if (!strcmp(sflag,"children")) flags = flags | EDG_WLL_STAT_CHILDREN; - if (!strcmp(sflag,"childstat")) flags = flags | EDG_WLL_STAT_CHILDSTAT; - if (!strcmp(sflag,"no_jobs")) flags = flags | EDG_WLL_STAT_NO_JOBS; - if (!strcmp(sflag,"no_states")) flags = flags | EDG_WLL_STAT_NO_STATES; - sflag = strtok_r(NULL, "+", &last); - } - - return(flags); -} - - -char *edg_wll_purge_flags_to_string(int flags) -{ - char *cflags = NULL, *temp_cflags = NULL; - - - if (flags & EDG_WLL_PURGE_REALLY_PURGE) asprintf(&cflags,"%s","really_purge"); - if (flags & EDG_WLL_PURGE_LIST_JOBS) { - if (cflags) { - asprintf(&temp_cflags,"%s+%s",cflags,"list_jobs"); - free(cflags); - cflags=temp_cflags; - } - else asprintf(&cflags,"%s","list_jobs"); - } - if (flags & EDG_WLL_PURGE_SERVER_DUMP) { - if (cflags) { - asprintf(&temp_cflags,"%s+%s",cflags,"server_dump"); - free(cflags); - cflags=temp_cflags; - } - else asprintf(&cflags,"%s","server_dump"); - } - if (flags & EDG_WLL_PURGE_CLIENT_DUMP) { - if (cflags) { - asprintf(&temp_cflags,"%s+%s",cflags,"client_dump"); - free(cflags); - cflags=temp_cflags; - } - else asprintf(&cflags,"%s","client_dump"); - } - - if (!cflags) cflags = strdup(""); - - return(cflags); -} - - -int edg_wll_string_to_purge_flags(char *cflags) -{ - int flags = 0; - char *sflag, *last; - - if (cflags == NULL) return 0; - - sflag = strtok_r(cflags, "+", &last); - while (sflag != NULL) { - if (!strcmp(sflag,"really_purge")) flags = flags | EDG_WLL_PURGE_REALLY_PURGE; - if (!strcmp(sflag,"list_jobs")) flags = flags | EDG_WLL_PURGE_LIST_JOBS; - if (!strcmp(sflag,"server_dump")) flags = flags | EDG_WLL_PURGE_SERVER_DUMP; - if (!strcmp(sflag,"client_dump")) flags = flags | EDG_WLL_PURGE_CLIENT_DUMP; - sflag = strtok_r(NULL, "+", &last); - } - - return(flags); -} - - -/* Functions for conversion of DUMP constants */ - -static const char * const dumpConsts[] = { - "EDG_WLL_DUMP_NOW", - "EDG_WLL_DUMP_LAST_START", - "EDG_WLL_DUMP_LAST_END", -}; - -int edg_wll_StringToDumpConst(const char *name) - -{ - int i; - - for (i=0; i= 0 || -(dumpConst) > sizeof(dumpConsts)/sizeof(dumpConsts[0])) return (char *) NULL; - return strdup(dumpConsts[-(dumpConst+1)]); -} - - - -/* Functions for conversion of DONE CODE */ - -static const char * const done_codeConsts[] = { - "DONE_CODE_OK", - "DONE_CODE_FAILED", - "DONE_CODE_CANCELLED", -}; - -int edg_wll_StringTodone_code(const char *name) - -{ - int i; - - for (i=0; i sizeof(done_codeConsts)/sizeof(done_codeConsts[0])) return (char *) NULL; - return strdup(done_codeConsts[done_codeConst]); -} - - - -/* Functions for conversion of QUERY ATTRIBUTES */ - -static const char * const query_attrConsts[] = { - "EDG_WLL_QUERY_ATTR_UNDEF", - "EDG_WLL_QUERY_ATTR_JOBID", - "EDG_WLL_QUERY_ATTR_OWNER", - "EDG_WLL_QUERY_ATTR_STATUS", - "EDG_WLL_QUERY_ATTR_LOCATION", - "EDG_WLL_QUERY_ATTR_DESTINATION", - "EDG_WLL_QUERY_ATTR_DONECODE", - "EDG_WLL_QUERY_ATTR_USERTAG", - "EDG_WLL_QUERY_ATTR_TIME", - "EDG_WLL_QUERY_ATTR_LEVEL", - "EDG_WLL_QUERY_ATTR_HOST", - "EDG_WLL_QUERY_ATTR_SOURCE", - "EDG_WLL_QUERY_ATTR_INSTANCE", - "EDG_WLL_QUERY_ATTR_EVENT_TYPE", - "EDG_WLL_QUERY_ATTR_CHKPT_TAG", - "EDG_WLL_QUERY_ATTR_RESUBMITTED", - "EDG_WLL_QUERY_ATTR_PARENT", - "EDG_WLL_QUERY_ATTR_EXITCODE", - "EDG_WLL_QUERY_ATTR__LAST", -}; - -edg_wll_QueryAttr edg_wll_StringToquery_attr(const char *name) - -{ - int i; - - for (i=0; i sizeof(query_attrConsts)/sizeof(query_attrConsts[0])) return (char *) NULL; - return strdup(query_attrConsts[(int) query_attrConst]); -} - - - -/* Functions for conversion of NOTIFICATION CHANGE OPERATORS */ - -static const char * const notifChangeOpConsts[] = { - "EDG_WLL_NOTIF_NOOP", - "EDG_WLL_NOTIF_REPLACE", - "EDG_WLL_NOTIF_ADD", - "EDG_WLL_NOTIF_REMOVE", -}; - - - -edg_wll_NotifChangeOp edg_wll_StringToNotifChangeOp(const char *name) -{ - int i; - - for (i=0; i sizeof(notifChangeOpConsts)/sizeof(notifChangeOpConsts[0])) return (char *) NULL; - return strdup(notifChangeOpConsts[(int) notifChangeOpConst]); -} - diff --git a/org.glite.lb.common/src/xml_parse.c.T b/org.glite.lb.common/src/xml_parse.c.T deleted file mode 100644 index 0b7464f..0000000 --- a/org.glite.lb.common/src/xml_parse.c.T +++ /dev/null @@ -1,2746 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include - -#include // Expat header file - -#include "globus_config.h" - -#include "trio.h" -#include "glite/lb/producer.h" -#include "glite/wmsutils/jobid/cjobid.h" - -#include "escape.h" -#include "context-int.h" -#include "xml_parse.h" -#include "xml_conversions.h" - - -#ifdef __GNUC__ -#define UNUSED_VAR __attribute__((unused)) -#else -#define UNUSED_VAR -#endif - -#define QUERY_EVENTS_REQUEST_BEGIN "\r\n" -#define QUERY_EVENTS_OREC_BEGIN "\t\t\r\n" -#define QUERY_EVENTS_OREC_END "\t\t\r\n" -#define QUERY_EVENTS_ORJC_BEGIN "\t\t\r\n" -#define QUERY_EVENTS_ORJC_END "\t\t\r\n" -#define QUERY_JOBS_REQUEST_BEGIN "\r\n" -#define QUERY_JOBS_OR_BEGIN "\t\t\r\n" -#define QUERY_JOBS_OR_END "\t\t\r\n" -#define PURGE_REQUEST_BEGIN "\r\n" -#define PURGE_REQUEST_END "\r\n" -#define DUMP_REQUEST_BEGIN "\r\n" -#define DUMP_REQUEST_END "\r\n" -#define LOAD_REQUEST_BEGIN "\r\n" -#define LOAD_REQUEST_END "\r\n" -#define INDEXED_ATTRS_REQUEST_BEGIN "\r\n" -#define INDEXED_ATTRS_REQUEST_END "\r\n" -#define NOTIF_REQUEST_BEGIN "\r\n" -#define QUERY_SEQUENCE_CODE_REQUEST_BEGIN "\r\n" -#define QUERY_SEQUENCE_CODE_REQUEST_END "\r\n" - - -/* lists of accepted tags */ -static const char * const jobStatTags[] = { -@@@{ - selectType $status '_common_'; - for (getFieldsOrdered $status) { - gen "\t\"$_\",\n"; - } -@@@} - NULL -}; - - -@@@{ - gen "static const char * const eventJobCommon\[] = {"; - selectType $event '_common_'; - for (getFieldsOrdered $event) { - my $f = selectField $event $_; - my $fn = $f->{name}; - gen "\"$fn\", "; - } - gen "NULL };\n"; -@@@} -@@@{ - for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - gen "static const char * const event$t\[] = {"; - selectType $event $t; - for (getFieldsOrdered $event) { - my $f = selectField $event $_; - my $fn = $f->{name}; - gen "\"$fn\", " - } - gen "NULL };\n"; - } -@@@} - - - -static const char * const * const eventTags[] = { - eventJobCommon, -@@@{ - for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) { - gen "\tevent$t,\n"; - } - gen "\tNULL\n};\n"; -@@@} - - - -/* used when error unrecoverable*/ -#define unexpError() {\ - char *e;\ -\ - if (XMLCtx->errtxt) {\ - asprintf(&e,"%s\nunexpected <%s> at line %d",XMLCtx->errtxt,\ - XMLCtx->element,XML_GetCurrentLineNumber(XMLCtx->p));\ - free(XMLCtx->errtxt);\ - } else asprintf(&e,"unexpected <%s> at line %d",\ - XMLCtx->element,XML_GetCurrentLineNumber(XMLCtx->p));\ - XMLCtx->errtxt = e;\ -} - - - -static void emptyCall(void){ -} - -/* used when error recoverable */ -// XXX quadratic complexity - problematic when lots of errors in long outputs (10.000's) -#define unexpWarning() {\ - char *e;\ -\ -emptyCall(); \ - if (XMLCtx->warntxt) {\ - asprintf(&e,"%s\nunexpected <%s> at line %d",XMLCtx->warntxt,\ - XMLCtx->element,XML_GetCurrentLineNumber(XMLCtx->p));\ - free(XMLCtx->warntxt);\ - } else asprintf(&e,"unexpected <%s> at line %d",\ - XMLCtx->element,XML_GetCurrentLineNumber(XMLCtx->p));\ - XMLCtx->warntxt = e;\ -} - - - - -static void startQueryJobs(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - if (XMLCtx->char_buf) edg_wll_freeBuf(XMLCtx); - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0 : if (strcmp("edg_wll_QueryJobsResult", el)) { unexpError() break;} - if (attr[0] && attr[1] && attr[2] && attr[3]) { - if (strcmp(attr[0],"code")) { unexpError() break;} - else XMLCtx->errCode = atoi(attr[1]); - - if (strcmp(attr[2],"desc")) { unexpError() break;} - else XMLCtx->errDesc = strdup(attr[3]); - } - break; - - case 1 : if (strcmp("edg_wll_Job", el)) unexpError() - break; - - case 2 : if (!strcmp("jobId", el)) { - /* allocates space only for pointers to structures edg_wlc_jobid_t */ - /* space for structures allocate characterUserJobs */ - XMLCtx->jobsOutGlobal = realloc(XMLCtx->jobsOutGlobal, - (XMLCtx->position+1)*sizeof(*XMLCtx->jobsOutGlobal)); - if (!XMLCtx->jobsOutGlobal) { edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); unexpError() return; } - XMLCtx->jobsOutGlobal[XMLCtx->position] = NULL; - } - else if (!strcmp("jobStat", el)) { - XMLCtx->stat_begin = XML_GetCurrentByteIndex(XMLCtx->p); - XMLCtx->jobStatGlobal = (edg_wll_JobStat *) realloc(XMLCtx->jobStatGlobal, - (XMLCtx->position2+1)*sizeof(*XMLCtx->jobStatGlobal)); - - } - else unexpWarning() - break; - - // XXX ?? this may be usefull with status - case 3 : /* fall through */ - case 4 : /* do not check xml tags, try to be faul-tolerant */ - /* if tag not found during unparsing, xmlMalformed flag is set */ - break; - - default: if (!XMLCtx->stat_begin) unexpWarning() - break; - } - - XMLCtx->level++; -} - - - -static void startQueryEvents(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - if (XMLCtx->char_buf) edg_wll_freeBuf(XMLCtx); - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0 : if (strcmp("edg_wll_QueryEventsResult", el)) { unexpError() break;} - if (attr[0] && attr[1] && attr[2] && attr[3]) { - if (strcmp(attr[0],"code")) { unexpError() break;} - else XMLCtx->errCode = atoi(attr[1]); - - if (strcmp(attr[2],"desc")) { unexpError() break;} - else XMLCtx->errDesc = strdup(attr[3]); - } - - break; - - case 1 : if (strcmp("edg_wll_Event", el)) unexpError() - else { - XMLCtx->position++; - - if (!attr[0] || !attr[1]) { unexpError() break;} - if (strcmp(attr[0],"name")) { unexpError() break;} - if ( (XMLCtx->eventCode = edg_wll_StringToEvent((char *) attr[1])) - == EDG_WLL_EVENT_UNDEF ) { unexpError() break;} - XMLCtx->eventsOutGlobal = realloc(XMLCtx->eventsOutGlobal, - (XMLCtx->position+1)*sizeof(*XMLCtx->eventsOutGlobal)); - if (!XMLCtx->eventsOutGlobal) { edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); unexpError() return; } - memset(&(XMLCtx->eventsOutGlobal)[XMLCtx->position],0,sizeof(*XMLCtx->eventsOutGlobal)); - XMLCtx->eventsOutGlobal[XMLCtx->position].any.type = XMLCtx->eventCode; - } - break; - - case 2 : /* do not check xml tags, try to be faul-tolerant */ - /* if tag not found during unparsing, xmlMalformed flag is set */ - break; - - default: unexpWarning() - break; - } - - XMLCtx->level++; -} - - - - -static void startUserJobs(void *data, const char *el, const char **attr UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - if (XMLCtx->char_buf) edg_wll_freeBuf(XMLCtx); - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0 : if (strcmp("edg_wll_UserJobs", el)) { unexpError() break;} - if (attr[0] && attr[1] && attr[2] && attr[3]) { - if (strcmp(attr[0],"code")) { unexpError() break;} - else XMLCtx->errCode = atoi(attr[1]); - - if (strcmp(attr[2],"desc")) { unexpError() break;} - else XMLCtx->errDesc = strdup(attr[3]); - } - break; - - case 1 : if (strcmp("jobId", el)) unexpError() - else { - /* allocates space only for pointers to structures edg_wlc_jobid_t */ - /* space for structures allocate endUserJobs */ - XMLCtx->jobsOutGlobal = realloc(XMLCtx->jobsOutGlobal, - (XMLCtx->position+1)*sizeof(XMLCtx->jobsOutGlobal)); - if (!XMLCtx->jobsOutGlobal) { edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); unexpError() return; } - XMLCtx->jobsOutGlobal[XMLCtx->position] = NULL; - } - break; - - - default: unexpWarning() - break; - } - - XMLCtx->level++; -} - - - -static void startJobStatus(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - edg_wll_JobStatCode statusCode; /* code of status in process */ - - - if (XMLCtx->char_buf) edg_wll_freeBuf(XMLCtx); - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0 : if (strcmp("jobStat", el)) { unexpError() break;} - if (!attr[0] || !attr[1]) { unexpError() break;} - if (strcmp(attr[0],"name")) { unexpError() break;} - - if ( (statusCode = edg_wll_StringToStat(attr[1])) - == (edg_wll_JobStatCode)-1 ) - /* status unknown, but try to get as much as possible */ - unexpWarning() - else { - if (edg_wll_InitStatus(&XMLCtx->jobStatSingleGlobal)) - { edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); unexpError() return; } - XMLCtx->jobStatSingleGlobal.state = statusCode; - } - - if (attr[2] && attr[3] && attr[4] && attr[5]) { - if (strcmp(attr[2],"code")) { unexpError() break;} - else XMLCtx->errCode = atoi(attr[3]); - - if (strcmp(attr[4],"desc")) { unexpError() break;} - else XMLCtx->errDesc = strdup(attr[5]); - } - break; - - case 1 : if (!strcmp("user_tags", el) || !strcmp("user_values", el) - || !strcmp("children_hist", el) || !strcmp("stateEnterTimes", el) - || !strcmp("children_states", el) || !strcmp("children", el)) { - XMLCtx->stat_begin = XML_GetCurrentByteIndex(XMLCtx->p); - } - break; - - case 2 : /* fall through */ - case 3 : /* fall through */ - case 4 : /* do not check xml tags, try to be faul-tolerant */ - /* if tag not found during unparsing, xmlMalformed flag is set */ - break; - - - default: unexpWarning() - break; - } - - XMLCtx->level++; -} - - -static void startStrList(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - if (XMLCtx->char_buf) edg_wll_freeBuf(XMLCtx); - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0 : if (strcmp(XMLCtx->XML_tag, el)) unexpError() - break; - - case 1 : if (!strcmp(XMLCtx->XML_tag2, el)) { - XMLCtx->strListGlobal = realloc(XMLCtx->strListGlobal, - (XMLCtx->position+1)*sizeof(*XMLCtx->strListGlobal)); - if (!XMLCtx->strListGlobal) { edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); unexpError() return; } - XMLCtx->strListGlobal[XMLCtx->position] = NULL; - - } - break; - - default: unexpWarning() - break; - } - - XMLCtx->level++; -} - - - -static void startIntList(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - int index = 0; - - - if (XMLCtx->char_buf) edg_wll_freeBuf(XMLCtx); - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0 : if (strcmp(XMLCtx->XML_tag, el)) unexpError() - break; - - case 1 : if ( (index = XMLCtx->tagToIndex(el)) >= 0 ) { - if (index > XMLCtx->max_index) { - XMLCtx->max_index = index; - /* leave zeros' possition for array length */ - XMLCtx->intListGlobal = realloc(XMLCtx->intListGlobal, - (XMLCtx->max_index+2)*sizeof(*XMLCtx->intListGlobal)); - if (!XMLCtx->intListGlobal) {edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); unexpError() return; } - XMLCtx->intListGlobal[XMLCtx->max_index+1] = 0; - } - - } - break; - - default: unexpWarning() - break; - } - - XMLCtx->level++; -} - - -static void startTagList(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - if (XMLCtx->char_buf) edg_wll_freeBuf(XMLCtx); - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0 : if (strcmp(XMLCtx->XML_tag, el)) unexpError() - break; - - case 1 : if (!attr[0] || !attr[1]) { unexpError() break;} - if (strcmp(attr[0],"name")) { unexpError() break;} - - if (!strcmp(XMLCtx->XML_tag2, el)) { - XMLCtx->tagListGlobal = realloc(XMLCtx->tagListGlobal, - (XMLCtx->position+1)*sizeof(*XMLCtx->tagListGlobal)); - if (!XMLCtx->tagListGlobal) { edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); unexpError() return; } - XMLCtx->tagListGlobal[XMLCtx->position].tag = strdup(attr[1]); - XMLCtx->stat_begin = XML_GetCurrentByteIndex(XMLCtx->p); - } - break; - - default: unexpWarning() - break; - } - - XMLCtx->level++; -} - - -static void startStsList(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - if (XMLCtx->char_buf) edg_wll_freeBuf(XMLCtx); - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0 : if (strcmp(XMLCtx->XML_tag, el)) unexpError() - break; - - case 1 : if (!strcmp(XMLCtx->XML_tag2, el)) { - XMLCtx->stsListGlobal = realloc(XMLCtx->stsListGlobal, - (XMLCtx->position+1)*sizeof(*XMLCtx->stsListGlobal)); - if (!XMLCtx->stsListGlobal) { edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); unexpError() return; } - // edg_wll_InitStatus(&XMLCtx->stsListGlobal[XMLCtx->position]); - // initialized in startJobStatus(); - - XMLCtx->stat_begin = XML_GetCurrentByteIndex(XMLCtx->p); - } - break; - - case 2 : /* fall through */ - case 3 : /* fall through */ - case 4 : /* fall through */ - case 5 : /* do not check xml tags ut to depth 5 */ - /* will be checked later */ - break; - - default: unexpWarning() - break; - } - - XMLCtx->level++; -} - - - -static void startPurgeResult(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - int i; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_PurgeResult")) { unexpError() break;} - for ( i = 0; attr[i] && attr[i+1]; i += 2 ) { - if (!strcmp(attr[i],"code")) - XMLCtx->errCode = atoi(attr[i+1]); - else if (!strcmp(attr[i],"desc")) - XMLCtx->errDesc = strdup(attr[i+1]); - else { unexpError() } - } - break; - case 1: if (strcasecmp(el,"jobs") && strcasecmp(el,"server_file")) unexpWarning() - break; - case 2: if (!strcasecmp(el,"jobId")) { - XMLCtx->purgeResultGlobal.jobs = realloc(XMLCtx->purgeResultGlobal.jobs, - (XMLCtx->position+2) * sizeof(XMLCtx->purgeResultGlobal.jobs)); - - if (!XMLCtx->purgeResultGlobal.jobs) { - edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); - unexpError() return; - } - XMLCtx->purgeResultGlobal.jobs[XMLCtx->position+1] = NULL; - } - else - unexpWarning() - break; - default: unexpWarning() - break; - } - XMLCtx->level++; -} - - - -static void startDumpResult(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - int i; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_DumpResult")) { unexpError() break;} - for ( i = 0; attr[i] && attr[i+1]; i += 2 ) { - if (!strcmp(attr[i],"code")) - XMLCtx->errCode = atoi(attr[i+1]); - else if (!strcmp(attr[i],"desc")) - XMLCtx->errDesc = strdup(attr[i+1]); - else { unexpError() } - } - break; - case 1: if (strcasecmp(el,"from") && strcasecmp(el,"to") - && strcasecmp(el,"server_file")) unexpWarning() - break; - default: unexpWarning() - break; - } - XMLCtx->level++; -} - - - -static void startLoadResult(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - int i; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_LoadResult")) { unexpError() break;} - for ( i = 0; attr[i] && attr[i+1]; i += 2 ) { - if (!strcmp(attr[i],"code")) - XMLCtx->errCode = atoi(attr[i+1]); - else if (!strcmp(attr[i],"desc")) - XMLCtx->errDesc = strdup(attr[i+1]); - else { unexpError() } - } - break; - case 1: if (strcasecmp(el,"from") && strcasecmp(el,"to") - && strcasecmp(el,"server_file")) unexpWarning() - break; - default: unexpWarning() - break; - } - XMLCtx->level++; -} - - - -static void startIndexedAttrs(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - int i; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_GetIndexedAttributesResult")) { unexpError() break;} - for ( i = 0; attr[i] && attr[i+1]; i += 2 ) { - if (!strcmp(attr[i],"code")) - XMLCtx->errCode = atoi(attr[i+1]); - else if (!strcmp(attr[i],"desc")) - XMLCtx->errDesc = strdup(attr[i+1]); - else { unexpError() } - } - break; - case 1: if (!strcasecmp(el,"index")) { - XMLCtx->attrsGlobal = realloc(XMLCtx->attrsGlobal, - (XMLCtx->position+2)*sizeof(*XMLCtx->attrsGlobal)); - if (!XMLCtx->attrsGlobal) { - edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); - unexpError() - return; - } - XMLCtx->attrsGlobal[XMLCtx->position] = NULL; - XMLCtx->attrsGlobal[XMLCtx->position+1] = NULL; - } - else - unexpWarning() - break; - case 2: if (!strcasecmp(el,"QueryRec")) { - XMLCtx->attrsGlobal[XMLCtx->position] = - realloc(XMLCtx->attrsGlobal[XMLCtx->position], - (XMLCtx->position2+2)*sizeof(**XMLCtx->attrsGlobal)); - if (!XMLCtx->attrsGlobal[XMLCtx->position]) { - edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); - unexpError() - return; - } - memset(&(XMLCtx->attrsGlobal[XMLCtx->position][XMLCtx->position2]), 0, - 2*sizeof(**XMLCtx->attrsGlobal)); - } - else - unexpWarning() - break; - case 3: if (strcasecmp(el,"attribute") && strcasecmp(el,"state") && - strcasecmp(el,"name")) unexpWarning() - break; - default: unexpWarning() - break; - } - XMLCtx->level++; -} - - - -static void startNotifResult(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - int i; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_NotifResult")) { unexpError() break;} - for ( i = 0; attr[i] && attr[i+1]; i += 2 ) { - if (!strcmp(attr[i],"code")) - XMLCtx->errCode = atoi(attr[i+1]); - else if (!strcmp(attr[i],"desc")) - XMLCtx->errDesc = strdup(attr[i+1]); - else { unexpError() } - } - break; - case 1: if (strcasecmp(el,"validity")) unexpWarning() - break; - default: unexpWarning() - break; - } - XMLCtx->level++; -} - - - -static void startQuerySequenceCodeResult(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - int i; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_QuerySequenceCodeResult")) { unexpError() break;} - for ( i = 0; attr[i] && attr[i+1]; i += 2 ) { - if (!strcmp(attr[i],"code")) - XMLCtx->errCode = atoi(attr[i+1]); - else if (!strcmp(attr[i],"desc")) - XMLCtx->errDesc = strdup(attr[i+1]); - else { unexpError() } - } - break; - case 1: if (strcasecmp(el,"sequence_code")) unexpWarning() - break; - default: unexpWarning() - break; - } - XMLCtx->level++; -} - - - -static void char_handler(void *data, const char *s, int len) -{ - edg_wll_XML_ctx *XMLCtx = data; - int i, found = -1, temp_len1; - char *temp_s, *temp_s1; - - - /* if date are only spaces, t\, \r, \n ... don't bother with them */ - for (i=0; ichar_buf_len) - XMLCtx->char_buf = realloc(XMLCtx->char_buf,XMLCtx->char_buf_len+temp_len1 + 1); - else - XMLCtx->char_buf = (char *) malloc(temp_len1 + 1); - - memcpy(XMLCtx->char_buf+XMLCtx->char_buf_len,temp_s1,temp_len1 + 1); - XMLCtx->char_buf_len += temp_len1; - free(temp_s1); - free(temp_s); -} - - - -static void endQueryJobs(void *data, const char *el) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - switch (XMLCtx->level) { - case 3 : - if (!strcmp(XMLCtx->element,"jobId")) { - XMLCtx->jobsOutGlobal[XMLCtx->position] = - edg_wll_from_string_to_jobid(XMLCtx); - XMLCtx->position++; - } - else if (!strcmp(el,"jobStat")) { - long len = (XML_GetCurrentByteIndex(XMLCtx->p) + XML_GetCurrentByteCount(XMLCtx->p)) - - XMLCtx->stat_begin; - - edg_wll_ParseJobStat(XMLCtx->ctx, XMLCtx->message_body + XMLCtx->stat_begin, len, - &XMLCtx->jobStatGlobal[XMLCtx->position2]); - XMLCtx->position2++; - XMLCtx->stat_begin = 0; - } - else { - /* tag was not found -> either missing in previous code or unknown */ - unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - default: - if (XMLCtx->char_buf) { -// unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - memset(&(XMLCtx->element), 0, sizeof(XMLCtx->element)); - XMLCtx->level--; -} - - -static void endQueryEvents(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - switch (XMLCtx->level) { - case 3: -@@@{ - my $i = 1; - my $bi = "\t "; - for my $t (sort {$a cmp $b} getAllFields $event) { - if ($i == 1) - { gen "$bi if (!strcmp(XMLCtx->element,\"$t\"))\n"; } - else - { gen "$bi else if (!strcmp(XMLCtx->element,\"$t\"))\n"; } - $i++; - my @fo = sort $event->getFieldOccurence($t); - if ($#fo == 0) { - selectType $event $fo[0]; - my $f = selectField $event $t; - my $ft = $f->{type}; - $fo[0] = $fo[0] eq '_common_' ? 'any' : lcfirst $fo[0]; - gen "$bi XMLCtx->eventsOutGlobal[XMLCtx->position].$fo[0].$t =\n"; - gen "$bi \tedg_wll_from_string_to_$ft(XMLCtx);\n"; - } - else { - gen "\t switch (XMLCtx->eventsOutGlobal[XMLCtx->position].any.type) {\n"; - for (@fo) { - selectType $event $_; - my $f = selectField $event $t; - my $ft = $f->{type}; - $t = 'any' if $_ eq '_common_'; - my $u = uc $_; - $_ = lcfirst $_; - gen "$bi case EDG_WLL_EVENT_$u :\n"; - gen "$bi \t XMLCtx->eventsOutGlobal[XMLCtx->position].$_.$t =\n"; - gen "$bi \t edg_wll_from_string_to_$ft(XMLCtx);\n"; - gen "$bi \t break;\n"; - - } - gen "$bi default : { unexpWarning() edg_wll_freeBuf(XMLCtx); } \n"; - gen "$bi }\n"; - } - } -@@@} - - else { - /* tag was not found -> either missing in previous code or unknown */ - unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - default: - if (XMLCtx->char_buf) { - unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - memset(&(XMLCtx->element), 0, sizeof(XMLCtx->element)); - XMLCtx->level--; - -} - - - -// XXX: endUserJobs should be unusable soon, delete it -static void endUserJobs(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - int i; - - - switch (XMLCtx->level) { - case 2 : - if (!strcmp(XMLCtx->element,"jobId")) { - XMLCtx->jobsOutGlobal[XMLCtx->position] = - edg_wll_from_string_to_jobid(XMLCtx); - XMLCtx->position++; - } - else { - /* tag was not found -> either missing in previous code or unknown */ - unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - default: - /* only level 2 tags should contain text fields */ - for (i=0; i < XMLCtx->char_buf_len; i++) - if (!isspace(XMLCtx->char_buf[i])) unexpWarning() - edg_wll_freeBuf(XMLCtx); - break; - } - - memset(&(XMLCtx->element), 0, sizeof(XMLCtx->element)); - // if ( !strcmp(XMLCtx->element,"jobId") ) XMLCtx->position++; - // uncomment this if you want to remove XMLCtx->position++; 5 lines above - // it should be useful in case of automatic generation - XMLCtx->level--; -} - - - -static void endJobStat(void *data, const char *el) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - switch (XMLCtx->level) { - case 2 : - -@@@{ - my $i = 1; - my $bi = "\t "; - selectType $status '_common_'; - for my $t (getFieldsOrdered $status) { - my $f = selectField $status $t; - my $ft = $f->{type}; - next if defined($f->{special}) && $f->{special} eq 'XMLstructured'; - if ($i == 1) - { gen "$bi if (!strcmp(XMLCtx->element,\"$t\"))\n"; } - else - { gen "$bi else if (!strcmp(XMLCtx->element,\"$t\"))\n"; } - $i++; - gen "$bi XMLCtx->jobStatSingleGlobal.$t =\n"; - gen "$bi edg_wll_from_string_to_$ft(XMLCtx);\n"; - } -@@@} - else if (!strcmp(el,"children_hist")) { - long len = (XML_GetCurrentByteIndex(XMLCtx->p) + XML_GetCurrentByteCount(XMLCtx->p)) - - XMLCtx->stat_begin; - - edg_wll_ParseIntList(XMLCtx->ctx, XMLCtx->message_body + XMLCtx->stat_begin, len, - "children_hist",(int (*)()) edg_wll_StringToStat, &XMLCtx->jobStatSingleGlobal.children_hist); - XMLCtx->stat_begin = 0; - } - else if (!strcmp(el,"children")) { - long len = (XML_GetCurrentByteIndex(XMLCtx->p) + XML_GetCurrentByteCount(XMLCtx->p)) - - XMLCtx->stat_begin; - - edg_wll_ParseStrList(XMLCtx->ctx, XMLCtx->message_body + XMLCtx->stat_begin, len, - "children", "jobId", &XMLCtx->jobStatSingleGlobal.children); - XMLCtx->stat_begin = 0; - } - else if (!strcmp(el,"children_states")) { - long len = (XML_GetCurrentByteIndex(XMLCtx->p) + XML_GetCurrentByteCount(XMLCtx->p)) - - XMLCtx->stat_begin; - - edg_wll_ParseStsList(XMLCtx->ctx, XMLCtx->message_body + XMLCtx->stat_begin, len, - "children_states", "jobStat", &XMLCtx->jobStatSingleGlobal.children_states); - XMLCtx->stat_begin = 0; - } - else if (!strcmp(el,"user_tags")) { - long len = (XML_GetCurrentByteIndex(XMLCtx->p) + XML_GetCurrentByteCount(XMLCtx->p)) - - XMLCtx->stat_begin; - - edg_wll_ParseTagList(XMLCtx->ctx, XMLCtx->message_body + XMLCtx->stat_begin, len, - "user_tags", "tag", &XMLCtx->jobStatSingleGlobal.user_tags); - XMLCtx->stat_begin = 0; - } - else if (!strcmp(el,"stateEnterTimes")) { - long len = (XML_GetCurrentByteIndex(XMLCtx->p) + XML_GetCurrentByteCount(XMLCtx->p)) - - XMLCtx->stat_begin; - - edg_wll_ParseIntList(XMLCtx->ctx, XMLCtx->message_body + XMLCtx->stat_begin, len, - "stateEnterTimes",(int (*)()) edg_wll_StringToStat, &XMLCtx->jobStatSingleGlobal.stateEnterTimes); - XMLCtx->stat_begin = 0; - } - else { - /* tag was not found -> either missing in previous code or unknown */ - unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - default: - if (XMLCtx->char_buf) { -// unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - memset(&(XMLCtx->element), 0, sizeof(XMLCtx->element)); - XMLCtx->level--; -} - - - -static void endStrList(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - switch (XMLCtx->level) { - case 2 : - if (!strcmp(XMLCtx->element,XMLCtx->XML_tag2)) { - XMLCtx->strListGlobal[XMLCtx->position] = - edg_wll_from_string_to_string(XMLCtx); - XMLCtx->position++; - } - else { - /* tag was not found -> either missing in previous code or unknown */ - unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - default: - if (XMLCtx->char_buf) { -// unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - memset(&(XMLCtx->element), 0, sizeof(XMLCtx->element)); - XMLCtx->level--; -} - - - -static void endIntList(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - int index; - - - switch (XMLCtx->level) { - case 2 : - if ((index = XMLCtx->tagToIndex(XMLCtx->element)) >= 0 ) { - XMLCtx->intListGlobal[index+1] = - edg_wll_from_string_to_int(XMLCtx); - } - else { - /* tag was not found -> either missing in previous code or unknown */ - unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - default: - if (XMLCtx->char_buf) { -// unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - memset(&(XMLCtx->element), 0, sizeof(XMLCtx->element)); - XMLCtx->level--; -} - - -static void endTagList(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - switch (XMLCtx->level) { - case 2 : - if (!strcmp(XMLCtx->element,XMLCtx->XML_tag2)) { - XMLCtx->tagListGlobal[XMLCtx->position].value = - edg_wll_from_string_to_string(XMLCtx); - XMLCtx->position++; - } - else { - /* tag was not found -> either missing in previous code or unknown */ - unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - default: - if (XMLCtx->char_buf) { -// unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - memset(&(XMLCtx->element), 0, sizeof(XMLCtx->element)); - XMLCtx->level--; -} - - -static void endStsList(void *data, const char *el) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - switch (XMLCtx->level) { - case 2 : - if (!strcmp(el,XMLCtx->XML_tag2)) { - long len = (XML_GetCurrentByteIndex(XMLCtx->p) + XML_GetCurrentByteCount(XMLCtx->p)) - - XMLCtx->stat_begin; - - edg_wll_ParseJobStat(XMLCtx->ctx, XMLCtx->message_body + XMLCtx->stat_begin, len, - &XMLCtx->stsListGlobal[XMLCtx->position]); - XMLCtx->stat_begin = 0; - XMLCtx->position++; - } - else { - /* tag was not found -> either missing in previous code or unknown */ - unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - default: - if (XMLCtx->char_buf) { -// unexpWarning() - edg_wll_freeBuf(XMLCtx); - } - break; - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - memset(&(XMLCtx->element), 0, sizeof(XMLCtx->element)); - XMLCtx->level--; -} - - - - -static void endPurgeResult(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - char *e; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"server_file")) - XMLCtx->purgeResultGlobal.server_file = edg_wll_from_string_to_string(XMLCtx); - } - else if (XMLCtx->level == 3) { - if (!strcmp(XMLCtx->element,"jobId")) { - if ( (XMLCtx->purgeResultGlobal.jobs[XMLCtx->position++] = - edg_wll_from_string_to_string(XMLCtx)) == NULL ) - { - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid JobId at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid JobId at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - } - } - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - - -static void endDumpResult(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"server_file")) - XMLCtx->dumpResultGlobal.server_file = edg_wll_from_string_to_string(XMLCtx); - else if (!strcmp(XMLCtx->element,"from")) { - if (isdigit(XMLCtx->char_buf[0])) - XMLCtx->dumpResultGlobal.from = edg_wll_from_string_to_time_t(XMLCtx); - else - XMLCtx->dumpResultGlobal.from = edg_wll_StringToDumpConst(XMLCtx->char_buf); - } - else if (!strcmp(XMLCtx->element,"to")) { - if (isdigit(XMLCtx->char_buf[0])) - XMLCtx->dumpResultGlobal.to = edg_wll_from_string_to_time_t(XMLCtx); - else - XMLCtx->dumpResultGlobal.to = edg_wll_StringToDumpConst(XMLCtx->char_buf); - } - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - - -static void endLoadResult(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"server_file")) - XMLCtx->loadResultGlobal.server_file = edg_wll_from_string_to_string(XMLCtx); - else if (!strcmp(XMLCtx->element,"from")) - XMLCtx->loadResultGlobal.from = edg_wll_from_string_to_time_t(XMLCtx); - else if (!strcmp(XMLCtx->element,"to")) - XMLCtx->loadResultGlobal.to = edg_wll_from_string_to_time_t(XMLCtx); - - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - - -static void endIndexedAttrs(void *data, const char *el) -{ - edg_wll_XML_ctx *XMLCtx = data; - - if (XMLCtx->level == 2) { - if (!strcmp(el,"index")) - XMLCtx->position++; - XMLCtx->position2 = 0; - } - if (XMLCtx->level == 3) { - if (!strcmp(el,"QueryRec")) - XMLCtx->position2++; - } - if (XMLCtx->level == 4) { - if (!strcmp(XMLCtx->element,"attribute")) { - XMLCtx->attrsGlobal[XMLCtx->position][XMLCtx->position2].attr = - edg_wll_StringToquery_attr(edg_wll_from_string_to_string(XMLCtx)); - } - else if (!strcmp(XMLCtx->element,"state")) { - XMLCtx->attrsGlobal[XMLCtx->position][XMLCtx->position2].attr_id.state = - edg_wll_StringToStat(edg_wll_from_string_to_string(XMLCtx)); - } - else if (!strcmp(XMLCtx->element,"name")) { - XMLCtx->attrsGlobal[XMLCtx->position][XMLCtx->position2].attr_id.tag = - edg_wll_from_string_to_string(XMLCtx); - } - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - -static void endNotifResult(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"validity")) - XMLCtx->notifValidity = edg_wll_from_string_to_time_t(XMLCtx); - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - - -static void endQuerySequenceCodeResult(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"sequence_code")) - XMLCtx->seqCode = edg_wll_from_string_to_string(XMLCtx); - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - - - - -#undef unexpError -#undef unexpWarning - - - -edg_wll_ErrorCode edg_wll_ParseQueryJobs(edg_wll_Context ctx, char *messageBody, edg_wlc_JobId **jobsOut, edg_wll_JobStat **statesOut) -{ - int i; - edg_wll_XML_ctx XMLCtx; - edg_wll_ErrorCode errorCode = 0; - XML_Char *encoding = "ISO-8859-1"; - - - edg_wll_initXMLCtx(&XMLCtx); - edg_wll_ResetError(ctx); - XMLCtx.message_body = messageBody; - XMLCtx.ctx = ctx; - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startQueryJobs, endQueryJobs); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - /* parse messageBody */ - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "XML parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - if ((errorCode = edg_wll_Error(ctx,NULL,NULL))) { - for (i=0; ierrDesc = XMLCtx.errDesc; - ctx->errCode = XMLCtx.errCode; - } - - - /* print all warning if corresponding env variable is set */ - if (XMLCtx.warntxt && getenv("EDG_WLL_XML_WARNINGS")) { - - fprintf(stderr,"----------------------------------------------------\n"); - fprintf(stderr,"%s\n\n",XMLCtx.warntxt); - fprintf(stderr,"%s\n",messageBody); - fprintf(stderr,"----------------------------------------------------\n"); - } - - /* free parser */ - XML_ParserFree(XMLCtx.p); - - edg_wll_freeXMLCtx(&XMLCtx); - return errorCode; -} - - - -edg_wll_ErrorCode edg_wll_ParseQueryEvents(edg_wll_Context ctx, char *messageBody, edg_wll_Event **eventsOut) -{ - int i; - edg_wll_XML_ctx XMLCtx; - edg_wll_ErrorCode errorCode = 0; - XML_Char *encoding = "ISO-8859-1"; - - - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.position = -1; - edg_wll_ResetError(ctx); - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startQueryEvents, endQueryEvents); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - /* parse messageBody */ - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - - asprintf(&errorMessage, "XML parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - if ((errorCode = edg_wll_Error(ctx,NULL,NULL))) { - *eventsOut = NULL; - for (i=0; i<= XMLCtx.position; i++) edg_wll_FreeEvent( &((XMLCtx.eventsOutGlobal)[i]) ); - free(XMLCtx.eventsOutGlobal); - XMLCtx.eventsOutGlobal = NULL; - - if (XMLCtx.errDesc) { - free(XMLCtx.errDesc); - XMLCtx.errDesc = NULL; - XMLCtx.errCode = 0; - } - } - else { - /* malloc-ate one more row for NULL list termination */ - XMLCtx.eventsOutGlobal = realloc(XMLCtx.eventsOutGlobal, - (++XMLCtx.position+1)*sizeof(*XMLCtx.eventsOutGlobal)); - if (!XMLCtx.eventsOutGlobal) { - errorCode = (edg_wll_ErrorCode) ENOMEM; - *eventsOut = NULL; - } - else { - /* last event in list is EDG_WLL_EVENT_UNDEF for end-of-list detection */ - memset(&XMLCtx.eventsOutGlobal[XMLCtx.position],0,sizeof(*XMLCtx.eventsOutGlobal)); - XMLCtx.eventsOutGlobal[XMLCtx.position].any.type = EDG_WLL_EVENT_UNDEF; - - /* return results */ - *eventsOut = XMLCtx.eventsOutGlobal; - XMLCtx.eventsOutGlobal = NULL; - } - } - - if (XMLCtx.errDesc || XMLCtx.errCode) { - ctx->errDesc = XMLCtx.errDesc; - ctx->errCode = XMLCtx.errCode; - } - - /* print all warning if corresponding env variable is set */ - if (XMLCtx.warntxt && getenv("EDG_WLL_XML_WARNINGS")) { - fprintf(stderr,"------------------------edg_wll_ParseQueryEvents----------------------------\n"); - fprintf(stderr,"%s\n\n",XMLCtx.warntxt); - fprintf(stderr,"%s\n",messageBody); - fprintf(stderr,"----------------------------------------------------\n"); - } - - /* free parser */ - XML_ParserFree(XMLCtx.p); - - edg_wll_freeXMLCtx(&XMLCtx); - return errorCode; -} - - - - -edg_wll_ErrorCode edg_wll_ParseUserJobs(edg_wll_Context ctx, char *messageBody, edg_wlc_JobId **jobsOut) -{ - int i; - edg_wll_XML_ctx XMLCtx; - edg_wll_ErrorCode errorCode = 0; - XML_Char *encoding = "ISO-8859-1"; - - - edg_wll_initXMLCtx(&XMLCtx); - edg_wll_ResetError(ctx); - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startUserJobs, endUserJobs); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - /* parse messageBody */ - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - - asprintf(&errorMessage, "XML parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - *jobsOut = NULL; - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - if ((errorCode = edg_wll_Error(ctx,NULL,NULL))) { - *jobsOut = NULL; - for (i=0; ierrDesc = XMLCtx.errDesc; - ctx->errCode = XMLCtx.errCode; - } - - /* print all warning if corresponding env variable is set */ - if (XMLCtx.warntxt && getenv("EDG_WLL_XML_WARNINGS")) { - fprintf(stderr,"----------------------------------------------------\n"); - fprintf(stderr,"%s\n\n",XMLCtx.warntxt); - fprintf(stderr,"%s\n",messageBody); - fprintf(stderr,"----------------------------------------------------\n"); - } - - /* free parser */ - XML_ParserFree(XMLCtx.p); - - edg_wll_freeXMLCtx(&XMLCtx); - return errorCode; -} - - - -/* parse dump result from client */ -edg_wll_ErrorCode edg_wll_ParseDumpResult(edg_wll_Context ctx, char *messageBody, edg_wll_DumpResult *result) -{ - edg_wll_XML_ctx XMLCtx; - edg_wll_ErrorCode errorCode; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_ResetError(ctx); - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startDumpResult, endDumpResult); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((errorCode = edg_wll_Error(ctx,NULL,NULL))) { - free(XMLCtx.dumpResultGlobal.server_file); - memset(result,0,sizeof(*result)); - } else { - memcpy(result, &XMLCtx.dumpResultGlobal, sizeof(XMLCtx.dumpResultGlobal)); - } - - if (XMLCtx.errDesc || XMLCtx.errCode) { - ctx->errDesc = XMLCtx.errDesc; - ctx->errCode = XMLCtx.errCode; - } - - /* print all warning if corresponding env variable is set */ - if (XMLCtx.warntxt && getenv("EDG_WLL_XML_WARNINGS")) { - fprintf(stderr,"----------------------------------------------------\n"); - fprintf(stderr,"%s\n\n",XMLCtx.warntxt); - fprintf(stderr,"%s\n",messageBody); - fprintf(stderr,"----------------------------------------------------\n"); - } - - /* free parser */ - XML_ParserFree(XMLCtx.p); - - edg_wll_freeXMLCtx(&XMLCtx); - return errorCode; -} - - - -/* parse load result from client */ -edg_wll_ErrorCode edg_wll_ParseLoadResult(edg_wll_Context ctx, char *messageBody, edg_wll_LoadResult *result) -{ - edg_wll_XML_ctx XMLCtx; - edg_wll_ErrorCode errorCode; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_ResetError(ctx); - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startLoadResult, endLoadResult); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((errorCode = edg_wll_Error(ctx,NULL,NULL))) { - free(XMLCtx.loadResultGlobal.server_file); - memset(result,0,sizeof(*result)); - } else { - memcpy(result, &XMLCtx.loadResultGlobal, sizeof(XMLCtx.loadResultGlobal)); - } - - if (XMLCtx.errDesc || XMLCtx.errCode) { - ctx->errDesc = XMLCtx.errDesc; - ctx->errCode = XMLCtx.errCode; - } - - /* print all warning if corresponding env variable is set */ - if (XMLCtx.warntxt && getenv("EDG_WLL_XML_WARNINGS")) { - fprintf(stderr,"----------------------------------------------------\n"); - fprintf(stderr,"%s\n\n",XMLCtx.warntxt); - fprintf(stderr,"%s\n",messageBody); - fprintf(stderr,"----------------------------------------------------\n"); - } - - /* free parser */ - XML_ParserFree(XMLCtx.p); - - edg_wll_freeXMLCtx(&XMLCtx); - return errorCode; -} - - - -edg_wll_ErrorCode edg_wll_ParseIndexedAttrs(edg_wll_Context ctx, char *messageBody, edg_wll_QueryRec ***attrs) -{ - edg_wll_XML_ctx XMLCtx; - edg_wll_ErrorCode errorCode; - XML_Char *encoding = "ISO-8859-1"; - - - edg_wll_initXMLCtx(&XMLCtx); - edg_wll_ResetError(ctx); - XMLCtx.message_body = messageBody; - XMLCtx.ctx = ctx; - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startIndexedAttrs, endIndexedAttrs); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - /* parse messageBody */ - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - if ((errorCode = edg_wll_Error(ctx,NULL,NULL))) { - if (XMLCtx.attrsGlobal) { - int i,j; - - for (i=0; XMLCtx.attrsGlobal[i]; i++) { - for (j=0; XMLCtx.attrsGlobal[i][j].attr != EDG_WLL_QUERY_ATTR_UNDEF; j++) { - if (XMLCtx.attrsGlobal[i][j].attr == EDG_WLL_QUERY_ATTR_USERTAG) - free(XMLCtx.attrsGlobal[i][j].attr_id.tag); - } - free(XMLCtx.attrsGlobal[i]); - } - free(XMLCtx.attrsGlobal); - XMLCtx.attrsGlobal = NULL; - } - XMLCtx.position = 0; - XMLCtx.position2 = 0; - } - - /* return results */ - *attrs = XMLCtx.attrsGlobal; - - if (XMLCtx.errDesc || XMLCtx.errCode) { - ctx->errDesc = XMLCtx.errDesc; - ctx->errCode = XMLCtx.errCode; - } - - /* print all warning if corresponding env variable is set */ - if (XMLCtx.warntxt && getenv("EDG_WLL_XML_WARNINGS")) { - fprintf(stderr,"----------------------------------------------------\n"); - fprintf(stderr,"%s\n\n",XMLCtx.warntxt); - fprintf(stderr,"%s\n",messageBody); - fprintf(stderr,"----------------------------------------------------\n"); - } - - /* free parser */ - XML_ParserFree(XMLCtx.p); - - edg_wll_freeXMLCtx(&XMLCtx); - return errorCode; -} - - - -/* parse notification result from client */ -edg_wll_ErrorCode edg_wll_ParseNotifResult(edg_wll_Context ctx, char *messageBody, time_t *validity) -{ - edg_wll_XML_ctx XMLCtx; - edg_wll_ErrorCode errorCode; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_ResetError(ctx); - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startNotifResult, endNotifResult); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((errorCode = edg_wll_Error(ctx,NULL,NULL))) { - *validity = -1; - } else { - *validity = XMLCtx.notifValidity; - } - - if (XMLCtx.errDesc || XMLCtx.errCode) { - ctx->errDesc = XMLCtx.errDesc; - ctx->errCode = XMLCtx.errCode; - } - - /* print all warning if corresponding env variable is set */ - if (XMLCtx.warntxt && getenv("EDG_WLL_XML_WARNINGS")) { - fprintf(stderr,"----------------------------------------------------\n"); - fprintf(stderr,"%s\n\n",XMLCtx.warntxt); - fprintf(stderr,"%s\n",messageBody); - fprintf(stderr,"----------------------------------------------------\n"); - } - - /* free parser */ - XML_ParserFree(XMLCtx.p); - - edg_wll_freeXMLCtx(&XMLCtx); - return errorCode; -} - - - -/* parse sequence code result from server */ -edg_wll_ErrorCode edg_wll_ParseQuerySequenceCodeResult(edg_wll_Context ctx, char *messageBody, char **seqCode) -{ - edg_wll_XML_ctx XMLCtx; - edg_wll_ErrorCode errorCode; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_ResetError(ctx); - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startQuerySequenceCodeResult, endQuerySequenceCodeResult); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((errorCode = edg_wll_Error(ctx,NULL,NULL))) { - free(XMLCtx.seqCode); - *seqCode = NULL; - } else { - *seqCode = XMLCtx.seqCode; - } - - if (XMLCtx.errDesc || XMLCtx.errCode) { - ctx->errDesc = XMLCtx.errDesc; - ctx->errCode = XMLCtx.errCode; - } - - /* print all warning if corresponding env variable is set */ - if (XMLCtx.warntxt && getenv("EDG_WLL_XML_WARNINGS")) { - fprintf(stderr,"----------------------------------------------------\n"); - fprintf(stderr,"%s\n\n",XMLCtx.warntxt); - fprintf(stderr,"%s\n",messageBody); - fprintf(stderr,"----------------------------------------------------\n"); - } - - /* free parser */ - XML_ParserFree(XMLCtx.p); - - edg_wll_freeXMLCtx(&XMLCtx); - return errorCode; -} - - - - -/* construct Message-Body of Request-Line for edg_wll_QueryJobs */ -int edg_wll_JobQueryRecToXML( - edg_wll_Context ctx, - edg_wll_QueryRec const * const *conditions, - char **message) -{ - char *pomA, *pomB, *pomC; - int i = 0, len, tot_len = 0, nconditions, row = 0; - int *len_list; - char **list; - - - pomC = strdup(""); - - while (conditions && conditions[row]) { - - pomA = pomB = NULL; - - for (i=0; conditions[row][i].attr != EDG_WLL_QUERY_ATTR_UNDEF ; i++); - nconditions = i; - - list = (char **) malloc ((nconditions) * sizeof(*list)); - len_list = (int *) malloc ((nconditions) * sizeof(*len_list)); - - i=0; - while (i < nconditions) { - const char *pomOp; - char *pomValue; - - asprintf(&pomValue,"%s",""); - - switch (conditions[row][i].attr) { - /* job specific conditions */ - case EDG_WLL_QUERY_ATTR_JOBID: - edg_wll_add_jobid_to_XMLBody(&pomValue, conditions[row][i].value.j, "jobId", NULL); - break; - case EDG_WLL_QUERY_ATTR_TIME: - if (conditions[row][i].op == EDG_WLL_QUERY_OP_WITHIN) { - edg_wll_add_tagged_time_t_to_XMLBody(&pomValue, conditions[row][i].value.t.tv_sec, "time", edg_wll_StatToString(conditions[row][i].attr_id.state), "state", -1); - edg_wll_add_tagged_time_t_to_XMLBody(&pomValue, conditions[row][i].value2.t.tv_sec, "time", edg_wll_StatToString(conditions[row][i].attr_id.state), "state", -1); - } - else - edg_wll_add_tagged_time_t_to_XMLBody(&pomValue, conditions[row][i].value.t.tv_sec, "time", edg_wll_StatToString(conditions[row][i].attr_id.state), "state", -1); - break; - - case EDG_WLL_QUERY_ATTR_PARENT: - edg_wll_add_jobid_to_XMLBody(&pomValue, conditions[row][i].value.j, "parent_job", NULL); - break; - case EDG_WLL_QUERY_ATTR_OWNER: - edg_wll_add_string_to_XMLBody(&pomValue, (conditions[row][i].value.c) ? conditions[row][i].value.c : - "NULL", "owner", NULL); - break; - case EDG_WLL_QUERY_ATTR_STATUS: - edg_wll_add_edg_wll_JobStatCode_to_XMLBody(&pomValue, conditions[row][i].value.i, "status", EDG_WLL_JOB_UNDEF); - if (conditions[row][i].op == EDG_WLL_QUERY_OP_WITHIN) - edg_wll_add_edg_wll_JobStatCode_to_XMLBody(&pomValue, conditions[row][i].value2.i, "status", EDG_WLL_JOB_UNDEF); - break; - case EDG_WLL_QUERY_ATTR_LOCATION: - edg_wll_add_string_to_XMLBody(&pomValue, conditions[row][i].value.c, "location", NULL); - break; - case EDG_WLL_QUERY_ATTR_DESTINATION: - edg_wll_add_string_to_XMLBody(&pomValue, conditions[row][i].value.c, "destination", NULL); - break; - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - edg_wll_add_int_to_XMLBody(&pomValue, conditions[row][i].value.i, "resubmitted", -1); - if (conditions[row][i].op == EDG_WLL_QUERY_OP_WITHIN) - edg_wll_add_int_to_XMLBody(&pomValue, conditions[row][i].value2.i, "resubmitted", -1); - break; - case EDG_WLL_QUERY_ATTR_DONECODE: - edg_wll_add_int_to_XMLBody(&pomValue, conditions[row][i].value.i, "donecode", -1); - if (conditions[row][i].op == EDG_WLL_QUERY_OP_WITHIN) - edg_wll_add_int_to_XMLBody(&pomValue, conditions[row][i].value2.i, "donecode", -1); - break; - case EDG_WLL_QUERY_ATTR_EXITCODE: - edg_wll_add_int_to_XMLBody(&pomValue, conditions[row][i].value.i, "exitcode", -1); - if (conditions[row][i].op == EDG_WLL_QUERY_OP_WITHIN) - edg_wll_add_int_to_XMLBody(&pomValue, conditions[row][i].value2.i, "exitcode", -1); - break; - /* common conditions */ - case EDG_WLL_QUERY_ATTR_USERTAG: - edg_wll_add_tagged_string_to_XMLBody(&pomValue, conditions[row][i].value.c, "usertag", conditions[row][i].attr_id.tag, "name", NULL); - break; - default: - free(pomValue); - return -1; - } - switch (conditions[row][i].op) { - case EDG_WLL_QUERY_OP_EQUAL: pomOp = "equal"; break; - case EDG_WLL_QUERY_OP_LESS: pomOp = "less"; break; - case EDG_WLL_QUERY_OP_GREATER: pomOp = "greater"; break; - case EDG_WLL_QUERY_OP_WITHIN: pomOp = "within"; break; - case EDG_WLL_QUERY_OP_UNEQUAL: pomOp = "unequal"; break; - default: - return -1; - } - - len = asprintf(&list[i],"\t\t\t<%s>\n\t\t%s\t\t\t\r\n", - pomOp,pomValue,pomOp); - tot_len += len; - len_list[i] = len; - - free(pomValue); - - i++; - } - - - pomA = (char *) malloc(tot_len * sizeof(char) + - sizeof(QUERY_JOBS_OR_BEGIN) + sizeof(QUERY_JOBS_OR_END) - 1); - - memcpy(pomA, QUERY_JOBS_OR_BEGIN, sizeof(QUERY_JOBS_OR_BEGIN)); - pomB = pomA + sizeof(QUERY_JOBS_OR_BEGIN) - 1; - - for (i=0; i < nconditions; i++) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - free(list[i]); - } - free(list); - free(len_list); - - strcpy(pomB, QUERY_JOBS_OR_END); - asprintf(message,"%s%s", pomC, pomA); - free(pomA); - free(pomC); - pomC = *message; - *message = NULL; - - row++; - } - - - asprintf(message,"%s", pomC); - - free(pomC); - - return 0; -} - - - - -/* construct Message-Body of Request-Line for edg_wll_QueryEvents */ -int edg_wll_QueryEventsRequestToXML( - edg_wll_Context ctx, - const edg_wll_QueryRec **job_conditions, - const edg_wll_QueryRec **event_conditions, - char **message) -{ - char *pomA, *pomB, *pomC; - int i = 0, len, tot_len = 0, row = 0; - int nevent_conditions; - char **list; - int *len_list; - - - edg_wll_JobQueryRecToXML(ctx, job_conditions, &pomC); - - row = 0; - while(event_conditions && event_conditions[row]) { - - pomA = pomB = NULL; - - for (i=0; event_conditions[row][i].attr != EDG_WLL_QUERY_ATTR_UNDEF ; i++); - nevent_conditions = i; - - list = (char **) malloc ((nevent_conditions) * sizeof(*list)); - len_list = (int *) malloc ((nevent_conditions) * sizeof(*len_list)); - - i=0; - while (i < nevent_conditions) { - const char *pomOp; - char *pomValue; - - asprintf(&pomValue,"%s",""); - - switch (event_conditions[row][i].attr) { - /* event specific conditions */ - case EDG_WLL_QUERY_ATTR_TIME: - if (event_conditions[row][i].op == EDG_WLL_QUERY_OP_WITHIN) { - edg_wll_add_tagged_time_t_to_XMLBody(&pomValue, event_conditions[row][i].value.t.tv_sec, "time", edg_wll_StatToString(event_conditions[row][i].attr_id.state), "state", -1); - edg_wll_add_tagged_time_t_to_XMLBody(&pomValue, event_conditions[row][i].value2.t.tv_sec, "time", edg_wll_StatToString(event_conditions[row][i].attr_id.state), "state", -1); - } - else - edg_wll_add_tagged_time_t_to_XMLBody(&pomValue, event_conditions[row][i].value.t.tv_sec, "time", edg_wll_StatToString(event_conditions[row][i].attr_id.state), "state", -1); - break; - case EDG_WLL_QUERY_ATTR_LEVEL: - edg_wll_add_int_to_XMLBody(&pomValue, event_conditions[row][i].value.i, "level", -1); - if (event_conditions[row][i].op == EDG_WLL_QUERY_OP_WITHIN) - edg_wll_add_int_to_XMLBody(&pomValue, event_conditions[row][i].value2.i, "level", -1); - break; - case EDG_WLL_QUERY_ATTR_HOST: - edg_wll_add_string_to_XMLBody(&pomValue, event_conditions[row][i].value.c, "host", NULL); - break; - case EDG_WLL_QUERY_ATTR_SOURCE: - edg_wll_add_int_to_XMLBody(&pomValue, event_conditions[row][i].value.i, "source", -1); - break; - case EDG_WLL_QUERY_ATTR_INSTANCE: - edg_wll_add_string_to_XMLBody(&pomValue, event_conditions[row][i].value.c, "instance", NULL); - break; - case EDG_WLL_QUERY_ATTR_EVENT_TYPE: - edg_wll_add_int_to_XMLBody(&pomValue, event_conditions[row][i].value.i, "type", EDG_WLL_EVENT_UNDEF); - if (event_conditions[row][i].op == EDG_WLL_QUERY_OP_WITHIN) - edg_wll_add_int_to_XMLBody(&pomValue, event_conditions[row][i].value2.i, "type", EDG_WLL_EVENT_UNDEF); - break; - /* common conditions */ - case EDG_WLL_QUERY_ATTR_USERTAG: - edg_wll_add_tagged_string_to_XMLBody(&pomValue, event_conditions[row][i].value.c, "usertag", event_conditions[row][i].attr_id.tag, "name", NULL); - break; - default: - free(pomValue); - return -1; - } - switch (event_conditions[row][i].op) { - case EDG_WLL_QUERY_OP_EQUAL: pomOp = "equal"; break; - case EDG_WLL_QUERY_OP_LESS: pomOp = "less"; break; - case EDG_WLL_QUERY_OP_GREATER: pomOp = "greater"; break; - case EDG_WLL_QUERY_OP_WITHIN: pomOp = "within"; break; - case EDG_WLL_QUERY_OP_UNEQUAL: pomOp = "unequal"; break; - default: - return -1; - } - - len = asprintf(&list[i],"\t\t\t<%s>\n\t\t%s\t\t\t\r\n", - pomOp,pomValue,pomOp); - - tot_len += len; - len_list[i] = len; - - free(pomValue); - - i++; - } - - pomA = (char *) malloc(tot_len * sizeof(char) + - sizeof(QUERY_EVENTS_OREC_BEGIN) + sizeof(QUERY_EVENTS_OREC_END) - 1); - - memcpy(pomA, QUERY_EVENTS_OREC_BEGIN, sizeof(QUERY_EVENTS_OREC_BEGIN)); - pomB = pomA + sizeof(QUERY_EVENTS_OREC_BEGIN) - 1; - - for (i=0; i < nevent_conditions; i++) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - free(list[i]); - } - free(list); - free(len_list); - - strcpy(pomB, QUERY_EVENTS_OREC_END); - asprintf(message,"%s%s", pomC, pomA); - free(pomA); - free(pomC); - pomC = *message; - *message = NULL; - - row++; - } - - asprintf(message,"%s softLimit=\"%d\" queryRes=\"%d\">\r\n\t\r\n%s%s", - QUERY_EVENTS_REQUEST_BEGIN, - ctx->p_query_events_limit, ctx->p_query_results, - pomC, QUERY_EVENTS_REQUEST_END); - - free(pomC); - - return 0; -} - - - -/* construct Message-Body of Request-Line for edg_wll_QueryJobs */ -int edg_wll_QueryJobsRequestToXML( - edg_wll_Context ctx, - const edg_wll_QueryRec **conditions, - int flags, - char **message) -{ - char *pomC, *cflags; - - - edg_wll_JobQueryRecToXML(ctx, conditions, &pomC); - - asprintf(message, - "%s softLimit=\"%d\" queryRes=\"%d\">\r\n\t%s\r\n\t\r\n%s%s", - QUERY_JOBS_REQUEST_BEGIN, - ctx->p_query_jobs_limit, ctx->p_query_results, - cflags = edg_wll_stat_flags_to_string(flags), pomC, QUERY_JOBS_REQUEST_END); - - free(cflags); - free(pomC); - - return 0; -} - - -/* construct Message-Body of Request-Line for edg_wll_Purge */ -int edg_wll_PurgeRequestToXML( - edg_wll_Context ctx, - const edg_wll_PurgeRequest *request, - char **message) -{ - char *pomA, *pomB, *pomC; - - - if (!request) { *message = NULL; return(-1); } - - pomA = strdup(""); - if (request->jobs) edg_wll_add_strlist_to_XMLBody(&pomA, request->jobs, "jobs", - "jobId", "\t", NULL); - - /* print timeout for all status codes */ - pomB = strdup(""); - edg_wll_add_time_t_list_to_XMLBody(&pomB, request->timeout, "timeout", edg_wll_StatToString, "\t", - 0, EDG_WLL_NUMBER_OF_STATCODES); - - trio_asprintf(&pomC,"%s%s%s\t%|Xs\r\n%s", - PURGE_REQUEST_BEGIN,pomA,pomB,edg_wll_purge_flags_to_string(request->flags), - PURGE_REQUEST_END); - - free(pomA); - free(pomB); - - - *message = pomC; - - return 0; -} - - - -/* construct Message-Body of Request-Line for edg_wll_Dump */ -int edg_wll_DumpRequestToXML( - edg_wll_Context ctx, - const edg_wll_DumpRequest *request, - char **message) -{ - char *pomA, *pomB; - - - if (!request) { *message = NULL; return(-1); } - - pomA = strdup(""); - if (request->from < 0) - edg_wll_add_string_to_XMLBody(&pomA, - edg_wll_DumpConstToString(request->from), "from", NULL); - else - edg_wll_add_time_t_to_XMLBody(&pomA, request->from, "from", 0); - if (request->to < 0) - edg_wll_add_string_to_XMLBody(&pomA, - edg_wll_DumpConstToString(request->to), "to", NULL); - else - edg_wll_add_time_t_to_XMLBody(&pomA, request->to, "to", 0); - - trio_asprintf(&pomB,"%s%s%s", - DUMP_REQUEST_BEGIN,pomA,DUMP_REQUEST_END); - - free(pomA); - - - *message = pomB; - - return 0; -} - - - -/* construct Message-Body of Request-Line for edg_wll_Load */ -int edg_wll_LoadRequestToXML( - edg_wll_Context ctx, - const edg_wll_LoadRequest *request, - char **message) -{ - char *pomA, *pomB; - - - if (!request) { *message = NULL; return(-1); } - - pomA = strdup(""); - edg_wll_add_string_to_XMLBody(&pomA, request->server_file, "server_file", 0); - - trio_asprintf(&pomB,"%s%s%s", - LOAD_REQUEST_BEGIN,pomA,LOAD_REQUEST_END); - - free(pomA); - - - *message = pomB; - - return 0; -} - - - -/* construct Message-Body of Request-Line for edg_wll_IndexedAttrs */ -int edg_wll_IndexedAttrsRequestToXML( - edg_wll_Context ctx, - char **message) -{ - char *pomB; - - - trio_asprintf(&pomB,"%s%s", - INDEXED_ATTRS_REQUEST_BEGIN,INDEXED_ATTRS_REQUEST_END); - - *message = pomB; - - return 0; -} - - -/* construct Message-Body of Request-Line for edg_wll_Notif* functions */ -int edg_wll_NotifRequestToXML( - edg_wll_Context ctx, - const char *function, - const edg_wll_NotifId notifId, - const char *address, - edg_wll_NotifChangeOp op, - edg_wll_QueryRec const * const *conditions, - char **message) -{ - char *pomA=NULL, *pomB=NULL, *pomC=NULL; - - - pomA = strdup(""); - edg_wll_add_string_to_XMLBody(&pomA, edg_wll_NotifIdUnparse(notifId), "notifId", NULL); - edg_wll_add_string_to_XMLBody(&pomA, address, "clientAddress", NULL); - edg_wll_add_string_to_XMLBody(&pomA, edg_wll_NotifChangeOpToString(op), "notifChangeOp", NULL); - if (conditions && conditions[0] && conditions[0][0].attr != EDG_WLL_QUERY_ATTR_UNDEF) - edg_wll_JobQueryRecToXML(ctx, conditions, &pomB); - - - if (pomB) - trio_asprintf(&pomC,"%s function=\"%s\">\r\n%s\t\r\n%s\t\r\n%s", - NOTIF_REQUEST_BEGIN,function,pomA,pomB,NOTIF_REQUEST_END); - else - trio_asprintf(&pomC,"%s function=\"%s\">\r\n%s%s", - NOTIF_REQUEST_BEGIN,function,pomA,NOTIF_REQUEST_END); - - - free(pomA); - free(pomB); - *message = pomC; - - return 0; -} - - -/* construct Message-Body of Request-Line for edg_wll_QuerySequeceCode function */ -int edg_wll_QuerySequenceCodeToXML( - edg_wll_Context ctx, - edg_wlc_JobId jobId, - char **message) -{ - char *pomA=NULL, *pomC=NULL; - - - pomA = strdup(""); - edg_wll_add_jobid_to_XMLBody(&pomA, jobId, "jobId", NULL); - edg_wll_add_string_to_XMLBody(&pomA, edg_wll_SourceToString(ctx->p_source), "source", NULL); - - trio_asprintf(&pomC,"%s%s%s", - QUERY_SEQUENCE_CODE_REQUEST_BEGIN,pomA,QUERY_SEQUENCE_CODE_REQUEST_END); - - - free(pomA); - *message = pomC; - - return 0; -} diff --git a/org.glite.lb.common/test/il_int_test.cpp b/org.glite.lb.common/test/il_int_test.cpp deleted file mode 100644 index f00b4c6..0000000 --- a/org.glite.lb.common/test/il_int_test.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include - - -extern "C" { -#include "il_string.h" -} - -class IlIntTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( IlIntTest ); - CPPUNIT_TEST( testPutInt ); - CPPUNIT_TEST( testGetInt ); - CPPUNIT_TEST( testLenInt ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() { - } - - void tearDown() { - } - - void testPutInt() { - put_int(buffer, 17); - CPPUNIT_ASSERT(!strcmp(buffer, "17\n")); - } - - void testGetInt() { - int d; - get_int("17\n", &d); - CPPUNIT_ASSERT(d == 17); - CPPUNIT_ASSERT(get_int("17 \n", &d) == NULL); - } - - void testLenInt() { - CPPUNIT_ASSERT(3 == len_int(17)); - } - -protected: - char buffer[255]; -}; - -CPPUNIT_TEST_SUITE_REGISTRATION( IlIntTest ) ; - diff --git a/org.glite.lb.common/test/il_string_test.cpp b/org.glite.lb.common/test/il_string_test.cpp deleted file mode 100644 index 2f03a94..0000000 --- a/org.glite.lb.common/test/il_string_test.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include - -extern "C" { -#include "il_string.h" -} - -class IlStringTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( IlStringTest ); - CPPUNIT_TEST( testPutString ); - CPPUNIT_TEST( testGetString ); - CPPUNIT_TEST( testLenString ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() { - } - - void tearDown() { - } - - void testPutString() { - put_string(buffer, "ahoj"); - CPPUNIT_ASSERT( !strncmp(buffer,"4 ahoj\n",7) ); - } - - void testGetString() { - char *s; - get_string("4 ahoj\n", &s); - CPPUNIT_ASSERT( s != NULL ); - CPPUNIT_ASSERT( !strcmp(s, "ahoj") ); - CPPUNIT_ASSERT( s[4] == 0 ); - free(s); - } - - void testLenString() { - int d = len_string("ahoj"); - CPPUNIT_ASSERT( d == 7); - } - -private: - char buffer[255]; -}; - -CPPUNIT_TEST_SUITE_REGISTRATION( IlStringTest ); diff --git a/org.glite.lb.common/test/il_test.cpp b/org.glite.lb.common/test/il_test.cpp deleted file mode 100644 index 794c0a0..0000000 --- a/org.glite.lb.common/test/il_test.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - - -int main(int argc, char *argv[]) -{ - CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - CppUnit::TextTestRunner runner; - - runner.addTest(suite); - runner.setOutputter(CppUnit::CompilerOutputter::defaultOutputter(&runner.result(), std::cerr)); - - return runner.run() ? 0 : 1; -} diff --git a/org.glite.lb.common/test/parse.cpp.T b/org.glite.lb.common/test/parse.cpp.T deleted file mode 100644 index face531..0000000 --- a/org.glite.lb.common/test/parse.cpp.T +++ /dev/null @@ -1,150 +0,0 @@ -#include - -#include -#include -#include -#include - - -#include -#include "events_parse.h" - -class EventParseTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(EventParseTest); - CPPUNIT_TEST(regJob); -/* -@@@{ - for my $e ($event->getTypesOrdered) { - my $u = lcfirst $e; - my $c = getTypeComment $event $e; - gen "\tCPPUNIT_TEST($u);\n"; - } -@@@} -*/ - CPPUNIT_TEST_SUITE_END(); - -public: - void regJob(); -/* -@@@{ - for my $e ($event->getTypesOrdered) { - my $u = lcfirst $e; - my $c = getTypeComment $event $e; - gen "\tvoid $u();\n"; - } -@@@} -*/ - -}; - -void EventParseTest::regJob() -{ - edg_wll_Context ctx; - edg_wll_Event *e1,*e2; - char *line,*et,*ed; - - edg_wll_InitContext(&ctx); - e1 = edg_wll_InitEvent(EDG_WLL_EVENT_REGJOB); - - e1->regJob.jdl = strdup("very long job = \"blabla\" \\\\ \n hugh\t;"); - e1->regJob.ns = strdup("ns address"); - e1->regJob.jobtype = EDG_WLL_REGJOB_SIMPLE; - e1->regJob.seed = strdup(""); - - gettimeofday(&e1->any.timestamp,NULL); - - e1->any.host = strdup("some.host"); - e1->any.level = 7; - e1->any.priority = 0; - edg_wlc_JobIdParse("https://some.host:1234/x67qr549qc",&e1->any.jobId); - e1->any.seqcode = EDG_WLL_SEQ_BIGHELPER_INITIAL; - e1->any.user = strdup("/O=Grid/CN=This User"); - e1->any.source = EDG_WLL_SOURCE_USER_INTERFACE; - e1->any.src_instance = strdup(""); - - line = edg_wll_UnparseEvent(ctx,e1); - std::cerr << line << std::endl; - - if (!line) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_UnparseEvent():") + et + " " + ed, line); - } - - if (edg_wll_ParseEvent(ctx,line,&e2)) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_ParseEvent():") + et + " " + ed, 0); - } - - if ((edg_wll_CompareEvents(ctx,e1,e2))) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_CompareEvents():") + et + " " + ed, 0); - } -} - -/* -@@@{ - for my $e ($event->getTypesOrdered) { - my $l = lcfirst $e; - my $u = uc $e; - my $c = getTypeComment $event $e; - gen " -void EventParseTest::$l(){ - edg_wll_Context ctx; - edg_wll_Event *e1,*e2; - char *line,*et,*ed; - - edg_wll_InitContext(&ctx); - e1 = edg_wll_InitEvent(EDG_WLL_EVENT_$u); -"; - - selectType $event '_common_'; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = getName $f; - my $value = getDefaultTestValue $f; - if (!$f->{codes}) { - if (!$f->hasAlias('ULM')) { - my $fu = uc $fn; - gen "\te1->any.$fn = $value;\n"; -# gen "\tif (". $f->isNULL("e1->any.$fn") .") MISSING(EDG_WLL\_COMMON\_$fu)\n"; - } else { - my $fa = $f->getName('ULM'); - my $fu = uc $fa; -# gen "\tif (". $f->isNULL("e1->any.$fn") .") MISSING(ULM\_$fu)\n"; - } - } - } - gen ' - if (!line) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_UnparseEvent():") + et + " " + ed, line); - } - - if (edg_wll_ParseEvent(ctx,line,&e2)) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_ParseEvent():") + et + " " + ed, 0); - } - - if ((edg_wll_CompareEvents(ctx,e1,e2))) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_CompareEvents():") + et + " " + ed, 0); - } -} - -'; - - } -@@@} -*/ - -CPPUNIT_TEST_SUITE_REGISTRATION( EventParseTest ); - -int main (int ac,const char *av[]) -{ - CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - CppUnit::TextUi::TestRunner runner; - - runner.addTest(suite); - return runner.run() ? 0 : 1; -} diff --git a/org.glite.lb.common/test/test_gss.cpp b/org.glite.lb.common/test/test_gss.cpp deleted file mode 100644 index d6df484..0000000 --- a/org.glite.lb.common/test/test_gss.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include -#include -#include - - -#include -#include -#include -#include - - -#include "lb_gss.h" - -class GSSTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(GSSTest); - CPPUNIT_TEST(echo); - CPPUNIT_TEST(errorTest); - CPPUNIT_TEST_SUITE_END(); - -public: - void echo(); - void errorTest(); - - void setUp(); - -private: - gss_cred_id_t my_cred; - char * my_subject; - int sock, port; - struct timeval timeout; - - void replier(); - -}; - - -void GSSTest::replier() { - edg_wll_GssConnection conn; - edg_wll_GssStatus stat; - struct sockaddr_in a; - socklen_t alen = sizeof(a); - int s, len; - char buf[100]; - - - if ( (s = accept(sock, (struct sockaddr *) &a, &alen)) < 0 ) exit(1); - - if ( edg_wll_gss_accept(my_cred, s, &timeout, &conn, &stat) ) exit(1); - - while ( (len = edg_wll_gss_read(&conn, buf, sizeof(buf), &timeout, &stat)) >= 0 ) { - if ( edg_wll_gss_write(&conn, buf, len, &timeout, &stat) ) exit(1); - } - - exit(0); -} - - -void GSSTest::setUp(void) { - pid_t pid; - edg_wll_GssStatus stat; - struct sockaddr_in a; - socklen_t alen = sizeof(a); - char * cred_file = NULL; - char * key_file = NULL; - - timeout.tv_sec = 10; - timeout.tv_usec = 0; - - key_file = cred_file = getenv("X509_USER_PROXY"); - CPPUNIT_ASSERT_MESSAGE("credential file", cred_file); - - if (edg_wll_gss_acquire_cred_gsi(cred_file, key_file, &my_cred, &my_subject, &stat)) - CPPUNIT_ASSERT_MESSAGE("gss_acquire_cred", 0); - - sock = socket(PF_INET,SOCK_STREAM,0); - CPPUNIT_ASSERT_MESSAGE("socket()", sock >= 0); - - a.sin_family = AF_INET; - a.sin_port = 0; - a.sin_addr.s_addr = INADDR_ANY; - - if (bind(sock,(struct sockaddr *) &a,sizeof(a))) { - CPPUNIT_ASSERT_MESSAGE("bind()", 0); - } - - if (listen(sock,1)) { - CPPUNIT_ASSERT_MESSAGE("listen()", 0); - } - - getsockname(sock,(struct sockaddr *) &a,&alen); - port = ntohs(a.sin_port); - - if ( !(pid = fork()) ) replier(); - else close(sock); -} - - - -void GSSTest::echo() -{ - edg_wll_GssConnection conn; - edg_wll_GssStatus stat; - size_t total; - int err; - char buf[] = "f843fejwfanczn nc4*&686%$$&^(*)*#$@WSH"; - char buf2[100]; - - - err = edg_wll_gss_connect(my_cred, "localhost", port, &timeout, &conn, &stat); - CPPUNIT_ASSERT_MESSAGE("edg_wll_gss_connect()", !err); - - err = edg_wll_gss_write(&conn, buf, strlen(buf)+1, &timeout, &stat); - CPPUNIT_ASSERT_MESSAGE("edg_wll_gss_write()", !err); - - err = edg_wll_gss_read_full(&conn, buf2, strlen(buf)+1, &timeout, &total, &stat); - CPPUNIT_ASSERT_MESSAGE("edg_wll_gss_read_full()", !err); - - CPPUNIT_ASSERT(strlen(buf)+1 == total && !strcmp(buf,buf2) ); - - edg_wll_gss_close(&conn, &timeout); - -} - - -void GSSTest::errorTest() -{ - edg_wll_GssConnection conn; - edg_wll_GssStatus stat; - int err; - char * msg = NULL; - - - err = edg_wll_gss_connect(my_cred, "xxx.porno.net", port, &timeout, &conn, &stat); - if (err) edg_wll_gss_get_error(&stat, "gss_connect()", &msg); - CPPUNIT_ASSERT_MESSAGE("edg_wll_gss_get_error()", msg); -} - - -CPPUNIT_TEST_SUITE_REGISTRATION( GSSTest ); - -int main (int ac,const char *av[]) -{ - CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - CppUnit::TextUi::TestRunner runner; - - runner.addTest(suite); - return runner.run() ? 0 : 1; -} diff --git a/org.glite.lb.logger/.cvsignore b/org.glite.lb.logger/.cvsignore deleted file mode 100644 index 1df717b..0000000 --- a/org.glite.lb.logger/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -.project -.cdtproject \ No newline at end of file diff --git a/org.glite.lb.logger/LICENSE b/org.glite.lb.logger/LICENSE deleted file mode 100644 index 259a91f..0000000 --- a/org.glite.lb.logger/LICENSE +++ /dev/null @@ -1,69 +0,0 @@ -LICENSE file for EGEE Middleware -================================ - -Copyright (c) 2004 on behalf of the EU EGEE Project: -The European Organization for Nuclear Research (CERN), -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Datamat Spa, Italy -Centre National de la Recherche Scientifique (CNRS), France -CS Systeme d'Information (CSSI), France -Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden -Universiteit van Amsterdam (UvA), Netherlands -University of Helsinki (UH.HIP), Finlan -University of Bergen (UiB), Norway -Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. The end-user documentation included with the redistribution, if -any, must include the following acknowledgment: "This product includes -software developed by The EU EGEE Project (http://cern.ch/eu-egee/)." -Alternatively, this acknowledgment may appear in the software itself, if -and wherever such third-party acknowledgments normally appear. - -4. The names EGEE and the EU EGEE Project must not be -used to endorse or promote products derived from this software without -prior written permission. For written permission, please contact -. - -5. You are under no obligation whatsoever to provide anyone with any -bug fixes, patches, or upgrades to the features, functionality or -performance of the Software ("Enhancements") that you may develop over -time; however, if you choose to provide your Enhancements to The EU -EGEE Project, or if you choose to otherwise publish or distribute your -Enhancements, in source code form without contemporaneously requiring -end users of The EU EGEE Proejct to enter into a separate written license -agreement for such Enhancements, then you hereby grant The EU EGEE Project -a non-exclusive, royalty-free perpetual license to install, use, copy, -modify, prepare derivative works, incorporate into the EGEE Middleware -or any other computer software, distribute, and sublicense your -Enhancements or derivative works thereof, in binary and source code -form (if any), whether developed by The EU EGEE Project or third parties. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL PROJECT OR ITS CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This software consists of voluntary contributions made by many -individuals on behalf of the EU EGEE Prject. For more information on The -EU EGEE Project, please see http://cern.ch/eu-egee/. For more information on -EGEE Middleware, please see http://egee-jra1.web.cern.ch/egee-jra1/ - - diff --git a/org.glite.lb.logger/Makefile b/org.glite.lb.logger/Makefile deleted file mode 100644 index eeed980..0000000 --- a/org.glite.lb.logger/Makefile +++ /dev/null @@ -1,166 +0,0 @@ -# defaults -top_srcdir=. -builddir=build -top_builddir=${top_srcdir}/${builddir} -stagedir=. -distdir=. -globalprefix=glite -lbprefix=lb -package=glite-lb-client -version=0.0.0 -PREFIX=/opt/glite - -glite_location=/opt/glite -globus_prefix=/opt/globus -nothrflavour=gcc32 -thrflavour=gcc32pthr -expat_prefix=/opt/expat -ares_prefix=/opt/ares - --include Makefile.inc - -CC=gcc - -VPATH:=${top_srcdir}/src:${top_srcdir}/test - -VERSION=-DVERSION=\"GLite-${version}\" - -SUFFIXES=.no - -GLOBUSINC=-I${globus_prefix}/include/${nothrflavour} - -GLOBUSTHRINC=-I${globus_prefix}/include/${thrflavour} - -DEBUG:=-g -O0 -CFLAGS:=${DEBUG} \ - -I${stagedir}/include -I${top_srcdir}/src \ - -D_GNU_SOURCE \ - ${COVERAGE_FLAGS} \ - ${VERSION} - -LDFLAGS:=-L${stagedir}/lib \ - ${COVERAGE_FLAGS} -LINK:=libtool --mode=link ${CC} ${LDFLAGS} -LINKXX:=libtool --mode=link ${CXX} -rpath ${stagedir}/lib ${LDFLAGS} -INSTALL:=libtool --mode=install install - -GLOBUS_LIBS:= -L${globus_prefix}/lib \ - -lglobus_common_${nothrflavour} \ - -lglobus_gssapi_gsi_${nothrflavour} - -GLOBUS_THRLIBS:= -L${globus_prefix}/lib \ - -lglobus_common_${thrflavour} \ - -lglobus_gssapi_gsi_${thrflavour} - -ifneq (${expat_prefix},/usr) - EXPAT_LIBS:=-L${expat_prefix}/lib -endif -EXPAT_LIBS:=${EXPAT_LIBS} -lexpat - -EXT_LIBS:= -L${ares_prefix}/lib -lares ${EXPAT_LIBS} - -COMMON_LIB:=-lglite_lb_common - -TEST_LIBS:=-L${cppunit_prefix}/lib -lcppunit -TEST_INC:=-I${cppunit_prefix}/include - -LOGD_OBJS:= logd_proto.o logd.o - -INTERLOG_OBJS:=il_error.o input_queue_socket.o \ - recover.o send_event.o \ - event_queue.o event_store.o il_master.o interlogd.o \ - queue_mgr.o server_msg.o queue_thread.o - -INTERLOG_NOBJS:=${INTERLOG_OBJS:.o=.no} - -INTERLOG_TEST_OBJS:= \ - il_error.o \ - server_msg.o \ - server_msgTest.o \ - queue_thread.o \ - event_store.o \ - event_storeTest.o \ - queue_mgr.o \ - il_master.o \ - input_queue_socket.o \ - input_queue_socketTest.o \ - send_event.o \ - event_queue.o \ - event_queueTest.o \ - IlTestBase.o \ - il_test.o - -glite_lb_logd: ${LOGD_OBJS} - ${LINK} -o $@ ${LOGD_OBJS} ${COMMON_LIB}_${nothrflavour} ${EXT_LIBS} ${GLOBUS_LIBS} - -glite_lb_interlogd: ${INTERLOG_OBJS} - ${LINK} -o $@ ${INTERLOG_OBJS} \ - ${COMMON_LIB}_${thrflavour} ${EXT_LIBS} ${GLOBUS_THRLIBS} -lpthread - -glite_lb_notif_interlogd: ${INTERLOG_NOBJS} - ${LINK} -o $@ ${INTERLOG_NOBJS} \ - ${COMMON_LIB}_${thrflavour} ${EXT_LIBS} ${GLOBUS_THRLIBS} -lpthread - -default: all - -all compile: glite_lb_logd glite_lb_interlogd glite_lb_notif_interlogd - -stage: compile - $(MAKE) install PREFIX=${stagedir} DOSTAGE=yes - -check: -# do nothing until test/ is really added to CVS -# check.ll check.il - -#check.ll: logd_proto_test.o ll_test.o -# ${LINKXX} -o $@ ${COMMON_LIB}_${nothrflavour} ${EXT_LIBS} ${GLOBUS_LIBS} ${TEST_LIBS} $+ -# ./check.ll - -check.ll: - -echo commented out -- fix needed - -check.il: ${INTERLOG_TEST_OBJS} - ${LINKXX} -o $@ ${COMMON_LIB}_${thrflavour} ${EXT_LIBS} ${GLOBUS_THRLIBS} ${TEST_LIBS} -lpthread $+ - -dist: distsrc distbin - -distsrc: - mkdir -p ${top_srcdir}/${package}-${version} - cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version} - cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version} - rm -rf ${top_srcdir}/${package}-${version} - -distbin: - $(MAKE) install PREFIX=`pwd`/tmpbuilddir${stagedir} - save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir - rm -rf tmpbuilddir - -install: - -mkdir -p ${PREFIX}/bin - -mkdir -p ${PREFIX}/etc/init.d - -mkdir -p ${PREFIX}/share/doc/${package}-${version} - ${INSTALL} -m 755 glite_lb_logd ${PREFIX}/bin/glite-lb-logd - ${INSTALL} -m 755 glite_lb_interlogd ${PREFIX}/bin/glite-lb-interlogd - if [ x${DOSTAGE} = xyes ]; then \ - ${INSTALL} -m 755 glite_lb_notif_interlogd ${PREFIX}/bin/glite-lb-notif-interlogd; \ - fi - ${INSTALL} -m 755 ${top_srcdir}/config/startup ${PREFIX}/etc/init.d/glite-lb-locallogger - ${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} - -%.no: %.c - ${CC} ${CFLAGS} ${GLOBUSTHRINC} -DIL_NOTIFICATIONS -c $< -o $@ - -${INTERLOG_OBJS}: %.o: %.c - ${CC} ${CFLAGS} ${GLOBUSTHRINC} -c $< -o $@ - -${LOGD_OBJS}: %.o: %.c - ${CC} ${CFLAGS} ${GLOBUSINC} -c $< -o $@ - -logd_proto_test.o: %.o: %.c - ${CC} ${CFLAGS} ${GLOBUSINC} -c $< -o $@ - -ll_test.o: %.o: %.cpp - ${CXX} ${CFLAGS} ${TEST_INC} -c $< -o $@ - -il_test.o IlTestBase.o server_msgTest.o event_queueTest.o input_queue_socketTest.o event_storeTest.o: %.o: %.cpp - ${CXX} ${CFLAGS} ${GLOBUSTHRINC} ${TEST_INC} -c $< -o $@ diff --git a/org.glite.lb.logger/build.xml b/org.glite.lb.logger/build.xml deleted file mode 100755 index 293f6d5..0000000 --- a/org.glite.lb.logger/build.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.logger/config/startup b/org.glite.lb.logger/config/startup deleted file mode 100755 index 0d1e095..0000000 --- a/org.glite.lb.logger/config/startup +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh - -GLITE_LOCATION=${GLITE_LOCATION:-/opt/glite} -GLITE_LOCATION_VAR=${GLITE_LOCATION_VAR:-$GLITE_LOCATION/var} - -[ -f /etc/glite.conf ] && . /etc/glite.conf -[ -f $GLITE_LOCATION/etc/glite-wms.conf ] && . $GLITE_LOCATION/etc/glite-wms.conf - -[ -f $GLITE_LOCATION/etc/lb.conf ] && . $GLITE_LOCATION/etc/lb.conf -[ -f $GLITE_LOCATION_VAR/etc/lb.conf ] && . $GLITE_LOCATION_VAR/etc/lb.conf - -[ -f $HOME/.glite.conf ] && . $HOME/.glite.conf - -unset creds port - -start() -{ - if test -z "$GLITE_USER" ;then - echo 'Error: GLITE_USER is not set' - echo FAILED - return 1 - fi - - [ -n "$GLITE_HOST_CERT" -a -n "$GLITE_HOST_KEY" ] && - creds="-c $GLITE_HOST_CERT -k $GLITE_HOST_KEY" - - if test -z "$creds"; then - if su - $GLITE_USER -c "test -r /etc/grid-security/hostkey.pem -a -r /etc/grid-security/hostcert.pem"; then - echo "$0: WARNING: /etc/grid-security/hostkey.pem readable by $GLITE_USER" - creds="-c /etc/grid-security/hostcert.pem -k /etc/grid-security/hostkey.pem" - fi - fi - - [ -z "$creds" ] && echo $0: WARNING: No credentials specified. Using default lookup which is dangerous. >&2 - - [ -n "$GLITE_LB_LOGGER_PORT" ] && port="-p $GLITE_LB_LOGGER_PORT" - - echo -n Starting glite-lb-logd ... - (cd /tmp && ls -f /tmp |fgrep ^dglogd_sock_ |xargs rm -f) - su - $GLITE_USER -c "$GLITE_LOCATION/bin/glite-lb-logd \ - $creds $port" && echo " done" || echo " FAILED" - - echo -n Starting glite-lb-interlogd ... - su - $GLITE_USER -c "$GLITE_LOCATION/bin/glite-lb-interlogd \ - $creds" && echo " done" || echo " FAILED" -} - -stop() -{ - echo -n Stopping glite-lb-logd ... - killall glite-lb-logd - echo " done" - echo -n Stopping glite-lb-interlogd ... - killall glite-lb-interlogd - echo " done" -} - -status() -{ - if netstat -an --inet | grep "^tcp .* 0.0.0.0:${GLITE_LB_LOGGER_PORT:-9002} .*LISTEN" >/dev/null 2>&1 ;then - echo glite-lb-logd running - else - echo glite-lb-logd not running - return 1 - fi - if netstat -an --unix | grep "^unix .* LISTEN.* /tmp/interlogger.sock$" >/dev/null 2>&1 ;then - echo glite-lb-interlogd running - else - echo glite-lb-interlogd not running - return 1 - fi -} - -case x$1 in - xstart) start;; - xstop) stop;; - xrestart) stop; start;; - xstatus) status;; - x*) echo usage: $0 start,stop,restart,status >&2 - exit 1;; -esac diff --git a/org.glite.lb.logger/project/build.properties b/org.glite.lb.logger/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.lb.logger/project/configure.properties.xml b/org.glite.lb.logger/project/configure.properties.xml deleted file mode 100644 index 0e51395..0000000 --- a/org.glite.lb.logger/project/configure.properties.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - -top_srcdir=.. -builddir=build -stagedir=${stage.abs.dir} -distdir=${dist.dir} -globalprefix=${global.prefix} -lbprefix=${subsystem.prefix} -package=${module.package.name} -PREFIX=${install.dir} -version=${module.version} -glite_location=${with.glite.location} -globus_prefix=${with.globus.prefix} -thrflavour=${with.globus.thr.flavor} -nothrflavour=${with.globus.nothr.flavor} -expat_prefix=${with.expat.prefix} -ares_prefix=${with.ares.prefix} -cppunit_prefix=${with.cppunit.prefix} - - - diff --git a/org.glite.lb.logger/project/properties.xml b/org.glite.lb.logger/project/properties.xml deleted file mode 100755 index 44827cf..0000000 --- a/org.glite.lb.logger/project/properties.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.logger/project/tar_exclude b/org.glite.lb.logger/project/tar_exclude deleted file mode 100644 index e1fcd1a..0000000 --- a/org.glite.lb.logger/project/tar_exclude +++ /dev/null @@ -1,10 +0,0 @@ -tar_exclude -CVS -build.xml -build -build.properties -properties.xml -configure.properties.xml -.cvsignore -.project -.cdtproject diff --git a/org.glite.lb.logger/project/version.properties b/org.glite.lb.logger/project/version.properties deleted file mode 100644 index d3be5bb..0000000 --- a/org.glite.lb.logger/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Dec 09 05:02:51 CET 2004 -module.version=0.5.0 -module.build=111 -module.age=3 diff --git a/org.glite.lb.logger/src/event_queue.c b/org.glite.lb.logger/src/event_queue.c deleted file mode 100644 index d311a1a..0000000 --- a/org.glite.lb.logger/src/event_queue.c +++ /dev/null @@ -1,314 +0,0 @@ -#ident "$Header$" - -/* - * - general queue handling routines (insert, get) - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" - -#include "interlogd.h" - -struct event_queue_msg { - struct server_msg *msg; - struct event_queue_msg *prev; -}; - -struct event_queue * -event_queue_create(char *server_name) -{ - struct event_queue *eq; - char *p; - - p = strchr(server_name, ':'); - - if(p) - *p++ = 0; - - if((eq = malloc(sizeof(*eq))) == NULL) { - set_error(IL_NOMEM, ENOMEM, "event_queue_create: error allocating event queue"); - return(NULL); - } - - memset(eq, 0, sizeof(*eq)); - - eq->dest_name = strdup(server_name); - - if(p) - *(p-1) = ':'; - -#if defined(IL_NOTIFICATIONS) - eq->dest_port = atoi(p); -#else - eq->dest_port = p ? atoi(p)+1 : GLITE_WMSC_JOBID_DEFAULT_PORT+1; -#endif - /* create all necessary locks */ - if(pthread_rwlock_init(&eq->update_lock, NULL)) { - set_error(IL_SYS, errno, "event_queue_create: error creating update lock"); - free(eq); - return(NULL); - } - if(pthread_mutex_init(&eq->cond_lock, NULL)) { - set_error(IL_SYS, errno, "event_queue_create: error creating cond mutex"); - free(eq); - return(NULL); - } - if(pthread_cond_init(&eq->ready_cond, NULL)) { - set_error(IL_SYS, errno, "event_queue_create: error creating cond variable"); - free(eq); - return(NULL); - } - -#if defined(INTERLOGD_HANDLE_CMD) && defined(INTERLOGD_FLUSH) - if(pthread_cond_init(&eq->flush_cond, NULL)) { - set_error(IL_SYS, errno, "event_queue_create: error creating cond variable"); - free(eq); - return(NULL); - } -#endif - - return(eq); -} - - -int -event_queue_free(struct event_queue *eq) -{ - assert(eq != NULL); - - if(!event_queue_empty(eq)) - return(-1); - - if(eq->thread_id) - pthread_cancel(eq->thread_id); - - - pthread_rwlock_destroy(&eq->update_lock); - pthread_mutex_destroy(&eq->cond_lock); - pthread_cond_destroy(&eq->ready_cond); -#if defined(INTERLOGD_HANDLE_CMD) && defined(INTERLOGD_FLUSH) - pthread_cond_destroy(&eq->flush_cond); -#endif - free(eq); - - return(0); -} - - -int -event_queue_empty(struct event_queue *eq) -{ - int ret; - - assert(eq != NULL); - - event_queue_lock_ro(eq); - ret = eq->head == NULL; - event_queue_unlock(eq); - - return(ret); -} - - -int -event_queue_insert(struct event_queue *eq, struct server_msg *msg) -{ - struct event_queue_msg *el; -#if defined(INTERLOGD_EMS) - struct event_queue_msg *tail; -#endif - - assert(eq != NULL); - - if((el = malloc(sizeof(*el))) == NULL) - return(set_error(IL_NOMEM, ENOMEM, "event_queue_insert: not enough room for queue element")); - - el->msg = server_msg_copy(msg); - if(el->msg == NULL) { - free(el); - return(-1); - }; - - /* this is critical section */ - event_queue_lock(eq); -#if defined(INTERLOGD_EMS) - if(server_msg_is_priority(msg)) { - /* priority messages go first */ - tail = eq->tail_ems; - if(tail) { - el->prev = tail->prev; - tail->prev = el; - if (tail == eq->tail) - eq->tail = el; - } else { - el->prev = eq->head; - eq->head = el; - if(eq->tail == NULL) - eq->tail = el; - } - eq->tail_ems = el; - } else -#endif - { - /* normal messages */ - if(eq->tail) - eq->tail->prev = el; - else - eq->head = el; - eq->tail = el; - el->prev = NULL; - } -#if defined(INTERLOGD_EMS) - /* if we are inserting message between mark_prev and mark_this, - we have to adjust mark_prev accordingly */ - if(eq->mark_this && (el->prev == eq->mark_this)) - eq->mark_prev = el; -#endif - event_queue_unlock(eq); - /* end of critical section */ - - return(0); -} - - -int -event_queue_get(struct event_queue *eq, struct server_msg **msg) -{ - struct event_queue_msg *el; - - assert(eq != NULL); - assert(msg != NULL); - - event_queue_lock_ro(eq); - el = eq->head; -#if defined(INTERLOGD_EMS) - /* this message is marked for removal, it is first on the queue */ - eq->mark_this = el; - eq->mark_prev = NULL; -#endif - event_queue_unlock(eq); - - if(el == NULL) - return(-1); - - *msg = el->msg; - - return(0); -} - - -int -event_queue_remove(struct event_queue *eq) -{ - struct event_queue_msg *el; -#if defined(INTERLOGD_EMS) - struct event_queue_msg *prev; -#endif - - assert(eq != NULL); - - /* this is critical section */ - event_queue_lock(eq); -#if defined(INTERLOGD_EMS) - el = eq->mark_this; - prev = eq->mark_prev; - - if(el == NULL) { - event_queue_unlock(eq); - return(-1); - } - - if(prev == NULL) { - /* removing from head of the queue */ - eq->head = el->prev; - } else { - /* removing from middle of the queue */ - prev->prev = el->prev; - } - if(el == eq->tail) { - /* we are removing the last message */ - eq->tail = NULL; - } - if(el == eq->tail_ems) { - /* we are removing last priority message */ - eq->tail_ems = NULL; - } - - eq->mark_this = NULL; - eq->mark_prev = NULL; -#else - el = eq->head; - if(el == NULL) { - event_queue_unlock(eq); - return(-1); - } - eq->head = el->prev; - if(el == eq->tail) { - eq->tail = NULL; - } -#endif - event_queue_unlock(eq); - /* end of critical section */ - - server_msg_free(el->msg); - free(el); - - return(0); -} - -#if defined(IL_NOTIFICATIONS) - -int -event_queue_move_events(struct event_queue *eq_s, struct event_queue *eq_d, char *notif_id) -{ - struct event_queue_msg *p, **source_prev, **dest_tail; - - assert(eq_s != NULL); - assert(notif_id != NULL); - - event_queue_lock(eq_s); - if(eq_d) { - event_queue_lock(eq_d); - /* dest tail is set to point to the last (NULL) pointer in the list */ - dest_tail = (eq_d->head == NULL) ? &(eq_d->head) : &(eq_d->tail->prev); - } - source_prev = &(eq_s->head); - p = *source_prev; - eq_s->tail = NULL; - while(p) { - if(strcmp(p->msg->job_id_s, notif_id) == 0) { - il_log(LOG_DEBUG, " moving event with notif id %s from %s:%d to %s:%d\n", - notif_id, eq_s->dest_name,eq_s->dest_port, eq_d ? eq_d->dest_name : "trash",eq_d ? eq_d->dest_port : -1); - /* remove the message from the source list */ - *source_prev = p->prev; - if(eq_d) { - /* append the message at the end of destination list */ - p->prev = NULL; - *dest_tail = p; - dest_tail = &(p->prev); - eq_d->tail = p; - } else { - /* free the message */ - server_msg_free(p->msg); - free(p); - } - } else { - /* message stays */ - source_prev = &(p->prev); - eq_s->tail = p; - } - p = *source_prev; - } - if(eq_d) event_queue_unlock(eq_d); - event_queue_unlock(eq_s); - return(0); -} - -#endif diff --git a/org.glite.lb.logger/src/event_store.c b/org.glite.lb.logger/src/event_store.c deleted file mode 100644 index 295b2f0..0000000 --- a/org.glite.lb.logger/src/event_store.c +++ /dev/null @@ -1,1025 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include - -#include "glite/lb/consumer.h" -#include "glite/lb/events_parse.h" - -#include "interlogd.h" - -#ifdef __GNUC__ -#define UNUSED_VAR __attribute__((unused)) -#else -#define UNUSED_VAR -#endif - -static char *file_prefix = NULL; - - -struct event_store_list { - struct event_store *es; - struct event_store_list *next; -}; - - -static struct event_store_list *store_list; -static pthread_rwlock_t store_list_lock = PTHREAD_RWLOCK_INITIALIZER; - - -/* ---------------- - * helper functions - * ---------------- - */ -static -char * -jobid2eventfile(IL_EVENT_ID_T job_id) -{ - char *buffer; - char *hash; - - if(job_id) { - hash = IL_EVENT_GET_UNIQUE(job_id); - asprintf(&buffer, "%s.%s", file_prefix, hash); - free(hash); - } else - asprintf(&buffer, "%s.default", file_prefix); - - return(buffer); -} - - -static -char * -jobid2controlfile(IL_EVENT_ID_T job_id) -{ - char buffer[256]; - char *hash; - - if(job_id) { - hash = IL_EVENT_GET_UNIQUE(job_id); - snprintf(buffer, 256, "%s.%s.ctl", file_prefix, hash); - free(hash); - } else - snprintf(buffer, 256, "%s.default.ctl", file_prefix); - - return(strdup(buffer)); -} - - -static -char * -read_event_string(FILE *file) -{ - char *buffer, *p, *n; - int len, c; - - buffer=malloc(1024); - if(buffer == NULL) { - set_error(IL_NOMEM, ENOMEM, "read_event_string: no room for event"); - return(NULL); - } - p = buffer; - len = 1024; - - while((c=fgetc(file)) != EOF) { - - /* we have to have free room for one byte */ - /* if(len - (p - buffer) < 1) */ - if(p - buffer >= len) { - n = realloc(buffer, len + 8192); - if(n == NULL) { - free(buffer); - set_error(IL_NOMEM, ENOMEM, "read_event_string: no room for event"); - return(NULL); - } - p = p - buffer + n; - buffer = n; - len += 8192; - } - - if(c == EVENT_SEPARATOR) { - *p++ = 0; - break; - } else - *p++ = (char) c; - } - - if(c != EVENT_SEPARATOR) { - free(buffer); - return(NULL); - } - - return(buffer); -} - - - -/* ------------------------------ - * event_store 'member' functions - * ------------------------------ - */ -static -int -event_store_free(struct event_store *es) -{ - assert(es != NULL); - - if(es->job_id_s) free(es->job_id_s); - if(es->event_file_name) free(es->event_file_name); - if(es->control_file_name) free(es->control_file_name); - pthread_rwlock_destroy(&es->use_lock); - pthread_rwlock_destroy(&es->update_lock); - free(es); - - return(0); -} - - -static -struct event_store * -event_store_create(char *job_id_s) -{ - struct event_store *es; - IL_EVENT_ID_T job_id; - - es = malloc(sizeof(*es)); - if(es == NULL) { - set_error(IL_NOMEM, ENOMEM, "event_store_create: error allocating room for structure"); - return(NULL); - } - - memset(es, 0, sizeof(*es)); - - il_log(LOG_DEBUG, " creating event store for id %s\n", job_id_s); - - job_id = NULL; - if(strcmp(job_id_s, "default") && IL_EVENT_ID_PARSE(job_id_s, &job_id)) { - set_error(IL_LBAPI, EDG_WLL_ERROR_PARSE_BROKEN_ULM, "event_store_create: error parsing id"); - free(es); - return(NULL); - } - - es->job_id_s = strdup(job_id_s); - es->event_file_name = jobid2eventfile(job_id); - es->control_file_name = jobid2controlfile(job_id); - IL_EVENT_ID_FREE(job_id); - - if(pthread_rwlock_init(&es->update_lock, NULL)) - abort(); - if(pthread_rwlock_init(&es->use_lock, NULL)) - abort(); - - return(es); -} - - -static -int -event_store_lock_ro(struct event_store *es) -{ - assert(es != NULL); - - if(pthread_rwlock_rdlock(&es->update_lock)) - abort(); - - return(0); -} - - -static -int -event_store_lock(struct event_store *es) -{ - assert(es != NULL); - - if(pthread_rwlock_wrlock(&es->update_lock)) - abort(); - - return(0); -} - - -static -int -event_store_unlock(struct event_store *es) -{ - assert(es != NULL); - - if(pthread_rwlock_unlock(&es->update_lock)) - abort(); - return(0); -} - - -static -int -event_store_read_ctl(struct event_store *es) -{ - FILE *ctl_file; - - assert(es != NULL); - - event_store_lock(es); - if((ctl_file = fopen(es->control_file_name, "r")) == NULL) { - /* no control file, new event file */ - es->last_committed_ls = 0; - es->last_committed_bs = 0; - } else { - /* read last seen and last committed counts */ - fscanf(ctl_file, "%*s\n%ld\n%ld\n", - &es->last_committed_ls, - &es->last_committed_bs); - fclose(ctl_file); - } - event_store_unlock(es); - - return(0); -} - - -static -int -event_store_write_ctl(struct event_store *es) -{ - FILE *ctl; - - assert(es != NULL); - - ctl = fopen(es->control_file_name, "w"); - if(ctl == NULL) { - set_error(IL_SYS, errno, "event_store_write_ctl: error opening control file"); - return(-1); - } - - if(fprintf(ctl, "%s\n%ld\n%ld\n", - es->job_id_s, - es->last_committed_ls, - es->last_committed_bs) < 0) { - set_error(IL_SYS, errno, "event_store_write_ctl: error writing control record"); - return(-1); - } - - if(fclose(ctl) < 0) { - set_error(IL_SYS, errno, "event_store_write_ctl: error closing control file"); - return(-1); - } - - return(0); -} - - -/* - * event_store_recover() - * - recover after restart or catch up when events missing in IPC - * - if offset > 0, read everything behind it - * - if offset == 0, read everything behind min(last_committed_bs, last_committed_es) - */ -int -event_store_recover(struct event_store *es) -{ - struct event_queue *eq_l = NULL, *eq_b, *eq_b_new; - struct server_msg *msg; - char *event_s; - int fd, ret; - long last; - FILE *ef; - struct flock efl; - char err_msg[128]; - - assert(es != NULL); - -#if defined(IL_NOTIFICATIONS) - eq_b = queue_list_get(es->dest); -#else - /* find bookkepping server queue */ - eq_b = queue_list_get(es->job_id_s); -#endif - if(eq_b == NULL) - return(-1); - -#if !defined(IL_NOTIFICATIONS) - /* get log server queue */ - eq_l = queue_list_get(NULL); -#endif - - event_store_lock(es); - - il_log(LOG_DEBUG, " reading events from %s\n", es->event_file_name); - - /* open event file */ - ef = fopen(es->event_file_name, "r"); - if(ef == NULL) { - snprintf(err_msg, sizeof(err_msg), - "event_store_recover: error opening event file %s", - es->event_file_name); - set_error(IL_SYS, errno, err_msg); - event_store_unlock(es); - return(-1); - } - - /* lock the file for reading (we should not read while dglogd is writing) */ - fd = fileno(ef); - efl.l_type = F_RDLCK; - efl.l_whence = SEEK_SET; - efl.l_start = 0; - efl.l_len = 0; - if(fcntl(fd, F_SETLKW, &efl) < 0) { - snprintf(err_msg, sizeof(err_msg), - "event_store_recover: error locking event file %s", - es->event_file_name); - set_error(IL_SYS, errno, err_msg); - event_store_unlock(es); - fclose(ef); - return(-1); - } - - /* get the position in file to be sought */ - if(es->offset) - last = es->offset; - else { -#if !defined(IL_NOTIFICATIONS) - if(eq_b == eq_l) - last = es->last_committed_ls; - else -#endif - /* last = min(ls, bs) */ - last = (es->last_committed_bs < es->last_committed_ls) ? es->last_committed_bs : es->last_committed_ls; - } - - il_log(LOG_DEBUG, " setting starting file position to %ld\n", last); - il_log(LOG_DEBUG, " bytes sent to logging server: %d\n", es->last_committed_ls); - il_log(LOG_DEBUG, " bytes sent to bookkeeping server: %d\n", es->last_committed_bs); - - /* skip all committed or already enqueued events */ - if(fseek(ef, last, SEEK_SET) < 0) { - set_error(IL_SYS, errno, "event_store_recover: error setting position for read"); - event_store_unlock(es); - fclose(ef); - return(-1); - } - - /* enqueue all remaining events */ - ret = 1; - msg = NULL; - while((event_s=read_event_string(ef)) != NULL) { - - /* last holds the starting position of event_s in file */ - il_log(LOG_DEBUG, " reading event at %ld\n", last); - - /* break from now on means there was some error */ - ret = -1; - - /* create message for server */ - msg = server_msg_create(event_s, last); - free(event_s); - if(msg == NULL) { - break; - } - msg->es = es; - - /* first enqueue to the LS */ - if(!bs_only && (last >= es->last_committed_ls)) { - - il_log(LOG_DEBUG, " queueing event at %ld to logging server\n", last); - -#if !defined(IL_NOTIFICATIONS) - if(enqueue_msg(eq_l, msg) < 0) - break; -#endif - } - -#ifdef IL_NOTIFICATIONS - eq_b_new = queue_list_get(msg->dest); - if (eq_b_new != eq_b) { - free(es->dest); - es->dest = strdup(msg->dest); - eq_b = eq_b_new; - } -#endif - - /* now enqueue to the BS, if neccessary */ - if((eq_b != eq_l) && - (last >= es->last_committed_bs)) { - - il_log(LOG_DEBUG, " queueing event at %ld to bookkeeping server\n", last); - - if(enqueue_msg(eq_b, msg) < 0) - break; - } - server_msg_free(msg); - msg = NULL; - - /* now last is also the offset behind the last successfully queued event */ - last = ftell(ef); - - /* ret == 0 means EOF or incomplete event found */ - ret = 0; - - } /* while */ - - /* due to this little assignment we had to lock the event_store for writing */ - es->offset = last; - il_log(LOG_DEBUG, " event store offset set to %ld\n", last); - - if(msg) - server_msg_free(msg); - - fclose(ef); - il_log(LOG_DEBUG, " finished reading events with %d\n", ret); - - event_store_unlock(es); - return(ret); -} - - -/* - * event_store_sync() - * - check the position of event and fill holes from file - * - return 1 if the event is new, - * 0 if it was seen before, - * -1 if there was an error - */ -int -event_store_sync(struct event_store *es, long offset) -{ - int ret; - - assert(es != NULL); - - event_store_lock_ro(es); - if(es->offset == offset) - /* we are up to date */ - ret = 1; - else if(es->offset > offset) - /* we have already seen this event */ - ret = 0; - else { - /* es->offset < offset, i.e. we have missed some events */ - event_store_unlock(es); - ret = event_store_recover(es); - /* XXX possible room for intervention by another thread - is there - * any other thread messing with us? - * 1) After recover() es->offset is set at the end of file. - * 2) es->offset is set only by recover() and next(). - * 3) Additional recover can not do much harm. - * 4) And next() is only called by the same thread as sync(). - * => no one is messing with us right now */ - event_store_lock_ro(es); - if(ret < 0) - ret = -1; - else - /* somehow we suppose that now es->offset >= offset */ - /* in fact it must be es->offset > offset, anything else would be weird */ - ret = (es->offset > offset) ? 0 : 1; - } - event_store_unlock(es); - return(ret); -} - - -int -event_store_next(struct event_store *es, int len) -{ - assert(es != NULL); - - event_store_lock(es); - es->offset += len; - event_store_unlock(es); - - return(0); -} - - -/* - * event_store_commit() - * - */ -int -event_store_commit(struct event_store *es, int len, int ls) -{ - assert(es != NULL); - - event_store_lock(es); - - if(ls) - es->last_committed_ls += len; - else { - es->last_committed_bs += len; - if (bs_only) es->last_committed_ls += len; - } - - if(event_store_write_ctl(es) < 0) { - event_store_unlock(es); - return(-1); - } - - event_store_unlock(es); - - - return(0); -} - - -/* - * event_store_clean() - * - remove the event files (event and ctl), if they are not needed anymore - * - returns 0 if event_store is in use, 1 if it was removed and -1 on error - * - * Q: How do we know that we can safely remove the files? - * A: When all events from file have been committed both by LS and BS. - */ -static -int -event_store_clean(struct event_store *es) -{ - long last; - int fd; - FILE *ef; - struct flock efl; - - assert(es != NULL); - - /* prevent sender threads from updating */ - event_store_lock(es); - - il_log(LOG_DEBUG, " trying to cleanup event store %s\n", es->job_id_s); - il_log(LOG_DEBUG, " bytes sent to logging server: %d\n", es->last_committed_ls); - il_log(LOG_DEBUG, " bytes sent to bookkeeping server: %d\n", es->last_committed_bs); - - /* preliminary check to avoid opening event file */ - /* if the positions differ, some events still have to be sent */ - if(es->last_committed_ls != es->last_committed_bs) { - event_store_unlock(es); - il_log(LOG_DEBUG, " not all events sent, cleanup aborted\n"); - return(0); - } - - /* the file can only be removed when all the events were succesfully sent - (ie. committed both by LS and BS */ - /* That also implies that the event queues are 'empty' at the moment. */ - ef = fopen(es->event_file_name, "r+"); - if(ef == NULL) { - /* if we can not open the event store, it is an error and the struct should be removed */ - /* XXX - is it true? */ - event_store_unlock(es); - il_log(LOG_ERR, " event_store_clean: error opening event file: %s\n", strerror(errno)); - return(1); - } - - fd = fileno(ef); - - /* prevent local-logger from writing into event file */ - efl.l_type = F_WRLCK; - efl.l_whence = SEEK_SET; - efl.l_start = 0; - efl.l_len = 0; - if(fcntl(fd, F_SETLK, &efl) < 0) { - il_log(LOG_DEBUG, " could not lock event file, cleanup aborted\n"); - fclose(ef); - event_store_unlock(es); - if(errno != EACCES && - errno != EAGAIN) { - set_error(IL_SYS, errno, "event_store_clean: error locking event file"); - return(-1); - } - return(0); - } - - /* now the file should not contain partially written event, so it is safe - to get offset behind last event by seeking the end of file */ - if(fseek(ef, 0, SEEK_END) < 0) { - set_error(IL_SYS, errno, "event_store_clean: error seeking the end of file"); - event_store_unlock(es); - fclose(ef); - return(-1); - } - - last = ftell(ef); - il_log(LOG_DEBUG, " total bytes in file: %d\n", last); - - if(es->last_committed_ls < last) { - fclose(ef); - event_store_unlock(es); - il_log(LOG_DEBUG, " events still waiting in queue, cleanup aborted\n"); - return(0); - } else if( es->last_committed_ls > last) { - il_log(LOG_WARNING, " warning: event file seems to shrink!\n"); - } - - /* now we are sure that all events were sent and the event queues are empty */ - il_log(LOG_INFO, " removing event file %s\n", es->event_file_name); - - /* remove the event file */ - unlink(es->event_file_name); - unlink(es->control_file_name); - - /* clear the counters */ - es->last_committed_ls = 0; - es->last_committed_bs = 0; - es->offset = 0; - - /* unlock the event_store even if it is going to be removed */ - event_store_unlock(es); - - /* close the event file (that unlocks it as well) */ - fclose(ef); - - /* indicate that it is safe to remove this event_store */ - return(1); -} - - - -/* -------------------------------- - * event store management functions - * -------------------------------- - */ -struct event_store * -event_store_find(char *job_id_s) -{ - struct event_store_list *q, *p; - struct event_store *es; - - if(pthread_rwlock_wrlock(&store_list_lock)) { - abort(); - } - - es = NULL; - - q = NULL; - p = store_list; - - while(p) { - if(strcmp(p->es->job_id_s, job_id_s) == 0) { - es = p->es; - if(pthread_rwlock_rdlock(&es->use_lock)) - abort(); - if(pthread_rwlock_unlock(&store_list_lock)) - abort(); - return(es); - } - - q = p; - p = p->next; - } - - es = event_store_create(job_id_s); - if(es == NULL) { - if(pthread_rwlock_unlock(&store_list_lock)) - abort(); - return(NULL); - } - - p = malloc(sizeof(*p)); - if(p == NULL) { - set_error(IL_NOMEM, ENOMEM, "event_store_find: no room for new event store"); - if(pthread_rwlock_unlock(&store_list_lock)) - abort(); - return(NULL); - } - - p->next = store_list; - store_list = p; - - p->es = es; - - if(pthread_rwlock_rdlock(&es->use_lock)) - abort(); - - if(pthread_rwlock_unlock(&store_list_lock)) - abort(); - - return(es); -} - - -int -event_store_release(struct event_store *es) -{ - assert(es != NULL); - - if(pthread_rwlock_unlock(&es->use_lock)) - abort(); - il_log(LOG_DEBUG, " released lock on %s\n", es->job_id_s); - return(0); -} - - -static -int -event_store_from_file(char *filename) -{ - struct event_store *es; - FILE *event_file; - char *event_s, *job_id_s = NULL; - int ret; -#if defined(IL_NOTIFICATIONS) - edg_wll_Event *notif_event; - edg_wll_Context context; - char *dest_name = NULL; - - edg_wll_InitContext(&context); -#endif - - il_log(LOG_INFO, " attaching to event file: %s\n", filename); - - event_file = fopen(filename, "r"); - if(event_file == NULL) { - set_error(IL_SYS, errno, "event_store_from_file: error opening event file"); - return(-1); - } - event_s = read_event_string(event_file); - fclose(event_file); - if(event_s == NULL) - return(0); - -#if defined(IL_NOTIFICATIONS) - if((ret=edg_wll_ParseNotifEvent(context, event_s, ¬if_event))) { - set_error(IL_LBAPI, ret, "event_store_from_file: could not parse event"); - ret = -1; - goto out; - } - if(notif_event->notification.notifId == NULL) { - set_error(IL_LBAPI, EDG_WLL_ERROR_PARSE_BROKEN_ULM, - "event_store_from_file: parse error - no notif id"); - ret = -1; - goto out; - } - if((job_id_s = edg_wll_NotifIdUnparse(notif_event->notification.notifId)) == NULL) { - set_error(IL_SYS, ENOMEM, "event_store_from_file: could not copy id"); - ret = -1; - goto out; - } - if(notif_event->notification.dest_host && - (strlen(notif_event->notification.dest_host) > 0)) { - asprintf(&dest_name, "%s:%d", notif_event->notification.dest_host, notif_event->notification.dest_port); - } - -#else - job_id_s = edg_wll_GetJobId(event_s); -#endif - il_log(LOG_DEBUG, " event id: '%s'\n", job_id_s); - if(job_id_s == NULL) { - il_log(LOG_NOTICE, " skipping file, could not parse event\n"); - ret = 0; - goto out; - } - - es=event_store_find(job_id_s); - - if(es == NULL) { - ret = -1; - goto out; - } - -#if defined(IL_NOTIFICATIONS) - es->dest = dest_name; -#endif - - if((es->last_committed_ls == 0) && - (es->last_committed_bs == 0) && - (es->offset == 0)) { - ret = event_store_read_ctl(es); - } else - ret = 0; - - event_store_release(es); - -out: -#if defined(IL_NOTIFICATIONS) - if(notif_event) { - edg_wll_FreeEvent(notif_event); - free(notif_event); - } -#endif - if(event_s) free(event_s); - if(job_id_s) free(job_id_s); - return(ret); -} - - -int -event_store_init(char *prefix) -{ - if(file_prefix == NULL) { - file_prefix = strdup(prefix); - store_list = NULL; - } - - /* read directory and get a list of event files */ - { - int len; - - char *p, *dir; - DIR *event_dir; - struct dirent *entry; - - - /* get directory name */ - p = strrchr(file_prefix, '/'); - if(p == NULL) { - dir = strdup("."); - p = ""; - len = 0; - } else { - *p = '\0'; - dir = strdup(file_prefix); - *p++ = '/'; - len = strlen(p); - } - - event_dir = opendir(dir); - if(event_dir == NULL) { - free(dir); - set_error(IL_SYS, errno, "event_store_init: error opening event directory"); - return(-1); - } - - while((entry=readdir(event_dir))) { - char *s; - - /* skip all files that do not match prefix */ - if(strncmp(entry->d_name, p, len) != 0) - continue; - - /* skip all control files */ - if((s=strstr(entry->d_name, ".ctl")) != NULL && - s[4] == '\0') - continue; - - s = malloc(strlen(dir) + strlen(entry->d_name) + 2); - if(s == NULL) { - free(dir); - set_error(IL_NOMEM, ENOMEM, "event_store_init: no room for file name"); - return(-1); - } - - *s = '\0'; - strcat(s, dir); - strcat(s, "/"); - strcat(s, entry->d_name); - - if(event_store_from_file(s) < 0) { - free(dir); - free(s); - closedir(event_dir); - return(-1); - } - - free(s); - } - closedir(event_dir); - free(dir); - } - - return(0); -} - - -int -event_store_recover_all() -{ - struct event_store_list *sl; - - - if(pthread_rwlock_rdlock(&store_list_lock)) - abort(); - - /* recover all event stores */ - sl = store_list; - while(sl != NULL) { - - /* recover this event store */ - /* no need to lock use_lock in event_store, the store_list_lock is in place */ - if(event_store_recover(sl->es) < 0) { - il_log(LOG_ERR, " error recovering event store %s:\n %s\n", sl->es->event_file_name, error_get_msg()); - clear_error(); - } - sl = sl->next; - } - - if(pthread_rwlock_unlock(&store_list_lock)) - abort(); - - return(0); -} - - -#if 0 -int -event_store_remove(struct event_store *es) -{ - struct event_store_list *p, **q; - - assert(es != NULL); - - switch(event_store_clean(es)) { - case 0: - il_log(LOG_DEBUG, " event store not removed, still used\n"); - return(0); - - case 1: - if(pthread_rwlock_wrlock(&store_list_lock) < 0) { - set_error(IL_SYS, errno, " event_store_remove: error locking event store list"); - return(-1); - } - - p = store_list; - q = &store_list; - - while(p) { - if(p->es == es) { - (*q) = p->next; - event_store_free(es); - free(p); - break; - } - q = &(p->next); - p = p->next; - } - - if(pthread_rwlock_unlock(&store_list_lock) < 0) { - set_error(IL_SYS, errno, " event_store_remove: error unlocking event store list"); - return(-1); - } - return(1); - - default: - return(-1); - } - /* not reached */ - return(0); -} -#endif - -int -event_store_cleanup() -{ - struct event_store_list *sl; - struct event_store_list *slnext; - struct event_store_list **prev; - - /* try to remove event files */ - - if(pthread_rwlock_wrlock(&store_list_lock)) - abort(); - - sl = store_list; - prev = &store_list; - - while(sl != NULL) { - int ret; - - slnext = sl->next; - - /* one event store at time */ - ret = pthread_rwlock_trywrlock(&sl->es->use_lock); - if(ret == EBUSY) { - il_log(LOG_DEBUG, " event_store %s is in use by another thread\n", - sl->es->job_id_s); - sl = slnext; - continue; - } else if (ret < 0) - abort(); - - switch(event_store_clean(sl->es)) { - - case 1: - /* remove this event store */ - (*prev) = slnext; - event_store_free(sl->es); - free(sl); - break; - - case -1: - il_log(LOG_ERR, " error removing event store %s (file %s):\n %s\n", - sl->es->job_id_s, sl->es->event_file_name, error_get_msg()); - event_store_release(sl->es); - clear_error(); - /* go on to the next */ - - default: - event_store_release(sl->es); - prev = &(sl->next); - break; - } - - sl = slnext; - } - - if(pthread_rwlock_unlock(&store_list_lock)) - abort(); - - return(0); -} - diff --git a/org.glite.lb.logger/src/il_error.c b/org.glite.lb.logger/src/il_error.c deleted file mode 100644 index 6a9083a..0000000 --- a/org.glite.lb.logger/src/il_error.c +++ /dev/null @@ -1,184 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include - -/* XXX DK: */ -#include // SSL header file - -#include "glite/lb/lb_gss.h" - -#include "il_error.h" - - -extern int log_level; - -static pthread_key_t err_key; - -static int IL_ERR_MSG_LEN = 128; - -static -void -error_key_delete(void *err) -{ - free(err); -} - -static -void -error_key_create() -{ - pthread_key_create(&err_key, error_key_delete); -} - -static -struct error_inf * -error_get_err () -{ - struct error_inf *err; - - /* get thread specific error structure */ - err = (struct error_inf *)pthread_getspecific(err_key); - assert(err != NULL); - - return(err); -} - -int -init_errors(int level) -{ - static pthread_once_t error_once = PTHREAD_ONCE_INIT; - struct error_inf *err; - - /* create the key for thread specific error only once */ - pthread_once(&error_once, error_key_create); - - /* there is no thread error yet, try to create one */ - if((err = (struct error_inf *)malloc(sizeof(*err)))) { - /* allocation successfull, make it thread specific data */ - if(pthread_setspecific(err_key, err)) { - free(err); - return(-1); - } - } else - return(-1); - - err->code_maj = 0; - err->code_min = 0; - err->msg = malloc(IL_ERR_MSG_LEN + 1); - if(err->msg == NULL) - return(-1); - - if(level) - log_level = level; - - return(0); -} - -int -set_error(int code, long minor, char *msg) -{ - struct error_inf *err; - - err = error_get_err(); - - err->code_maj = code; - err->code_min = minor; - - switch(code) { - - case IL_SYS: - snprintf(err->msg, IL_ERR_MSG_LEN, "%s: %s", msg, strerror(err->code_min)); - break; - - case IL_HOST: - snprintf(err->msg, IL_ERR_MSG_LEN, "%s: %s", msg, hstrerror(err->code_min)); - break; - - /* XXX DK: je tahle hodnota k necemu potreba? */ - case IL_AUTH: - snprintf(err->msg, IL_ERR_MSG_LEN, "%s: %s", msg, ERR_error_string(err->code_min, NULL)); - break; - - case IL_DGGSS: - switch(err->code_min) { - - case EDG_WLL_GSS_ERROR_GSS: - snprintf(err->msg, IL_ERR_MSG_LEN, "%s", msg); - break; - - case EDG_WLL_GSS_ERROR_TIMEOUT: - snprintf(err->msg, IL_ERR_MSG_LEN, "%s: Timeout in GSS connection.", msg); - break; - - case EDG_WLL_GSS_ERROR_EOF: - snprintf(err->msg, IL_ERR_MSG_LEN, "%s: Connection lost.", msg); - break; - - case EDG_WLL_GSS_ERROR_ERRNO: - snprintf(err->msg, IL_ERR_MSG_LEN, "%s: %s", msg, strerror(errno)); - break; - - case EDG_WLL_GSS_ERROR_HERRNO: - snprintf(err->msg, IL_ERR_MSG_LEN, "%s: %s", msg, hstrerror(errno)); - break; - } - - default: - strncpy(err->msg, msg, IL_ERR_MSG_LEN); - } - - return(code); -} - - -int -clear_error() { - struct error_inf *err; - - err = error_get_err(); - - err->code_maj = IL_OK; - err->code_min = 0; - *(err->msg) = 0; - - return(0); -} - - -int -error_get_maj() -{ - struct error_inf *err; - - err = error_get_err(); - - return(err->code_maj); -} - - -long -error_get_min() -{ - struct error_inf *err; - - err = error_get_err(); - - return(err->code_min); -} - - -char * -error_get_msg() -{ - struct error_inf *err; - - err = error_get_err(); - - return(err->msg); -} diff --git a/org.glite.lb.logger/src/il_error.h b/org.glite.lb.logger/src/il_error.h deleted file mode 100644 index 120e7ed..0000000 --- a/org.glite.lb.logger/src/il_error.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef IL_ERROR_H -#define IL_ERROR_H - -#ident "$Header$" - -#include - -enum err_code_maj { /* minor = */ - IL_OK, /* 0 */ - IL_SYS, /* errno */ - IL_NOMEM, /* ENOMEM */ - IL_AUTH, /* 0 (SSL error) */ - IL_PROTO, /* LB_* */ - IL_LBAPI, /* dgLBErrCode */ - IL_DGGSS, /* EDG_WLL_GSS_* */ - IL_HOST /* h_errno */ -}; - -struct error_inf { - int code_maj; - long code_min; - char *msg; -}; - -int init_errors(int); -int set_error(int, long, char *); -int clear_error(); -int error_get_maj(); -long error_get_min(); -char *error_get_msg(); - -int il_log(int, char *, ...); - -#endif diff --git a/org.glite.lb.logger/src/il_master.c b/org.glite.lb.logger/src/il_master.c deleted file mode 100644 index f6414c9..0000000 --- a/org.glite.lb.logger/src/il_master.c +++ /dev/null @@ -1,419 +0,0 @@ -#ident "$Header$" - -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/context.h" -#include "glite/lb/events_parse.h" -#include "glite/lb/il_string.h" - -#include "interlogd.h" - -int -enqueue_msg(struct event_queue *eq, struct server_msg *msg) -{ -#if defined(IL_NOTIFICATIONS) - struct event_queue *eq_known; - - /* now we have a new event with possibly changed destination, - so check for the already known destination and possibly move - events from the original output queue to a new one */ - eq_known = notifid_map_get_dest(msg->job_id_s); - if(eq != eq_known) { - /* client has changed delivery address for this notification */ - if(notifid_map_set_dest(msg->job_id_s, eq) < 0) - return(-1); - /* move all events with this notif_id from eq_known to eq */ - if(eq_known != NULL) - event_queue_move_events(eq_known, eq, msg->job_id_s); - } -#endif - - /* fire thread to take care of this queue */ - if(event_queue_create_thread(eq) < 0) - return(-1); - -#if defined(IL_NOTIFICATIONS) - /* if there are no data to send, do not send anything - (messsage was just to change the delivery address) */ - if(msg->len == 0) - return(0); - -#endif - /* avoid losing signal to thread */ - event_queue_cond_lock(eq); - - /* insert new event */ - if(event_queue_insert(eq, msg) < 0) - return(-1); - - /* signal thread that we have a new message */ - event_queue_signal(eq); - - /* allow thread to continue */ - event_queue_cond_unlock(eq); - - return(0); -} - - -#if defined(INTERLOGD_HANDLE_CMD) && defined(INTERLOGD_FLUSH) -pthread_mutex_t flush_lock = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t flush_cond = PTHREAD_COND_INITIALIZER; -#endif /* INTERLOGD_FLUSH */ - -#ifdef INTERLOGD_HANDLE_CMD -static -int -parse_cmd(char *event, char **job_id_s, long *receipt, int *timeout) -{ - char *token, *r; - int ret; - - if(strstr(event, "DG.TYPE=\"command\"") == NULL) - return(-1); - - *job_id_s = NULL; - *timeout = 0; - *receipt = 0; - ret = 0; - - for(token = strtok(event, " "); token != NULL; token = strtok(NULL, " ")) { - r = index(token, '='); - if(r == NULL) { - ret = -1; - continue; - } - if(strncmp(token, "DG.COMMAND", r - token) == 0) { -#if defined(INTERLOGD_FLUSH) - if(strcmp(++r, "\"flush\"")) { -#endif - il_log(LOG_WARNING, " command %s not implemented\n", r); - ret = -1; - continue; -#if defined(INTERLOGD_FLUSH) - } -#endif - } else if(strncmp(token, "DG.JOBID", r - token) == 0) { - char *p; - - r += 2; /* skip =" */ - p = index(r, '"'); - if(p == NULL) { ret = -1; continue; } - *job_id_s = strndup(r, p-r); - - } else if(strncmp(token, "DG.TIMEOUT", r - token) == 0) { - sscanf(++r, "\"%d\"", timeout); - } else if(strncmp(token, "DG.LLLID", r - token) == 0) { - sscanf(++r, "%ld", receipt); - } - - } - return(0); -} - - -/* return value: - * 0 - not command - * 1 - success - * -1 - failure - */ - -static -int -handle_cmd(char *event, long offset) -{ - char *job_id_s; - struct event_queue *eq; - int num_replies, num_threads = 0; - int timeout, result; - long receipt; - struct timespec endtime; - struct timeval tv; - - /* parse command */ - if(parse_cmd(event, &job_id_s, &receipt, &timeout) < 0) - return(0); - -#if defined(INTERLOGD_FLUSH) - il_log(LOG_DEBUG, " received FLUSH command\n"); - - /* catchup with all neccessary event files */ - if(job_id_s) { - struct event_store *es = event_store_find(job_id_s); - - if(es == NULL) { - goto cmd_error; - } - result = event_store_recover(es); - /* NOTE: if flush had been stored in file, there would have been - no need to lock the event_store at all */ - event_store_release(es); - if(result < 0) { - il_log(LOG_ERR, " error trying to catch up with event file: %s\n", - error_get_msg()); - clear_error(); - } - } else - /* this call does not fail :-) */ - event_store_recover_all(); - - il_log(LOG_DEBUG, " alerting threads to report status\n"); - - /* prevent threads from reporting too early */ - if(pthread_mutex_lock(&flush_lock) < 0) { - /*** this error is considered too serious to allow the program run anymore! - set_error(IL_SYS, errno, "pthread_mutex_lock: error locking flush lock"); - goto cmd_error; - */ - abort(); - } - - /* wake up all threads */ - if(job_id_s) { - /* find appropriate queue */ - eq = queue_list_get(job_id_s); - if(eq == NULL) goto cmd_error; - if(!event_queue_empty(eq) && !queue_list_is_log(eq)) { - num_threads++; - event_queue_cond_lock(eq); - eq->flushing = 1; - event_queue_wakeup(eq); - event_queue_cond_unlock(eq); - } - } else { - /* iterate over event queues */ - for(eq=queue_list_first(); eq != NULL; eq=queue_list_next()) { - if(!event_queue_empty(eq) && !queue_list_is_log(eq)) { - num_threads++; - event_queue_cond_lock(eq); - eq->flushing = 1; - event_queue_wakeup(eq); - event_queue_cond_unlock(eq); - } - } - } - if(!bs_only) { - eq = queue_list_get(NULL); - if(eq == NULL) goto cmd_error; - if(!event_queue_empty(eq)) { - num_threads++; - event_queue_cond_lock(eq); - eq->flushing = 1; - event_queue_wakeup(eq); - event_queue_cond_unlock(eq); - } - } - - /* wait for thread replies */ - num_replies = 0; - result = 1; - gettimeofday(&tv, NULL); - endtime.tv_sec = tv.tv_sec + timeout; - endtime.tv_nsec = 1000 * tv.tv_usec; - while(num_replies < num_threads) { - int ret; - if((ret=pthread_cond_timedwait(&flush_cond, &flush_lock, &endtime)) < 0) { - il_log(LOG_ERR, " error waiting for thread reply: %s\n", strerror(errno)); - result = (ret == ETIMEDOUT) ? 0 : -1; - break; - } - - /* collect results from reporting threads */ - if(job_id_s) { - /* find appropriate queue */ - eq = queue_list_get(job_id_s); - if(eq == NULL) goto cmd_error; - if(!queue_list_is_log(eq)) { - event_queue_cond_lock(eq); - if(eq->flushing == 2) { - eq->flushing = 0; - num_replies++; - result = ((result == 1) || (eq->flush_result < 0)) ? - eq->flush_result : result; - } - event_queue_cond_unlock(eq); - } - } else { - /* iterate over event queues */ - for(eq=queue_list_first(); eq != NULL; eq=queue_list_next()) { - if(!queue_list_is_log(eq)) { - event_queue_cond_lock(eq); - if(eq->flushing == 2) { - eq->flushing = 0; - num_replies++; - il_log(LOG_DEBUG, " thread reply: %d\n", eq->flush_result); - result = ((result == 1) || (eq->flush_result < 0)) ? - eq->flush_result : result; - } - event_queue_cond_unlock(eq); - } - } - } - if(!bs_only) { - eq = queue_list_get(NULL); - if(eq == NULL) goto cmd_error; - event_queue_cond_lock(eq); - if(eq->flushing == 2) { - eq->flushing = 0; - num_replies++; - result = ((result == 1) || (eq->flush_result < 0)) ? - eq->flush_result : result; - } - event_queue_cond_unlock(eq); - } - } - - /* prevent deadlock in next flush */ - if(pthread_mutex_unlock(&flush_lock) < 0) - abort(); - - - /* report back to local logger */ - switch(result) { - case 1: - result = 0; break; - case 0: - result = EDG_WLL_IL_EVENTS_WAITING; break; - default: - result = EDG_WLL_IL_SYS; break; - } - if(job_id_s) free(job_id_s); - result = send_confirmation(receipt, result); - if(result <= 0) - il_log(LOG_ERR, "handle_cmd: error sending status: %s\n", error_get_msg()); - return(1); - - -cmd_error: - if(job_id_s) free(job_id_s); - return(-1); -#else - return(0); -#endif /* INTERLOGD_FLUSH */ -} -#endif /* INTERLOGD_HANDLE_CMD */ - - -static -int -handle_msg(char *event, long offset) -{ - struct server_msg *msg = NULL; -#if !defined(IL_NOTIFICATIONS) - struct event_queue *eq_l; -#endif - struct event_queue *eq_s; - struct event_store *es; - - int ret; - - /* convert event to message for server */ - if((msg = server_msg_create(event, offset)) == NULL) { - il_log(LOG_ERR, " handle_msg: error parsing event '%s':\n %s\n", event, error_get_msg()); - return(0); - } - - /* sync event store with IPC (if neccessary) - * This MUST be called before inserting event into output queue! */ - if((es = event_store_find(msg->job_id_s)) == NULL) - return(-1); - msg->es = es; - - ret = event_store_sync(es, offset); - il_log(LOG_DEBUG, " syncing event store at %d with event at %d, result %d\n", es->offset, offset, ret); - if(ret < 0) { - il_log(LOG_ERR, " handle_msg: error syncing event store:\n %s\n", error_get_msg()); - event_store_release(es); - return(0); - } else if(ret == 0) { - /* we have seen this event already */ - server_msg_free(msg); - event_store_release(es); - return(1); - } - - /* find apropriate queue for this event */ -#if defined(IL_NOTIFICATIONS) - eq_s = queue_list_get(msg->dest); -#else - eq_s = queue_list_get(msg->job_id_s); -#endif - if(eq_s == NULL) { - il_log(LOG_ERR, " handle_msg: apropriate queue not found: %s\n", error_get_msg()); - clear_error(); - } else { - if(enqueue_msg(eq_s, msg) < 0) - goto err; - } - -#if !defined(IL_NOTIFICATIONS) - eq_l = queue_list_get(NULL); - if(!bs_only && eq_l != eq_s) { - /* send to default queue (logging server) as well */ - if(enqueue_msg(eq_l, msg) < 0) - goto err; - } -#endif - - /* if there was no error, set the next expected event offset */ - event_store_next(es, msg->ev_len); - /* allow cleanup thread to check on this event_store */ - event_store_release(es); - - /* free the message */ - server_msg_free(msg); - return(1); - -err: - event_store_release(es); - server_msg_free(msg); - return(-1); -} - - - -int -loop() -{ - /* receive events */ - while(1) { - char *msg; - long offset; - int ret; - - clear_error(); - if((ret = input_queue_get(&msg, &offset, INPUT_TIMEOUT)) < 0) - { - if(error_get_maj() == IL_PROTO) { - il_log(LOG_DEBUG, " premature EOF while receiving event\n"); - /* problems with socket input, try to catch up from files */ - event_store_recover_all(); - continue; - } else - return(-1); - } - else if(ret == 0) { - continue; - } - -#ifdef INTERLOGD_HANDLE_CMD - ret = handle_cmd(msg, offset); - if(ret == 0) -#endif - ret = handle_msg(msg, offset); - free(msg); - if(ret < 0) - switch (error_get_maj()) { - case IL_SYS: - case IL_NOMEM: - return (ret); - break; - default: - il_log(LOG_ERR, "Error: %s\n", error_get_msg()); - break; - } - } /* while */ -} diff --git a/org.glite.lb.logger/src/input_queue_socket.c b/org.glite.lb.logger/src/input_queue_socket.c deleted file mode 100644 index f183319..0000000 --- a/org.glite.lb.logger/src/input_queue_socket.c +++ /dev/null @@ -1,207 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include - -#include "interlogd.h" - - -static const int SOCK_QUEUE_MAX = 50; -extern char *socket_path; - -static int sock; -static int accepted; - -int -input_queue_attach() -{ - struct sockaddr_un saddr; - - if((sock=socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { - set_error(IL_SYS, errno, "input_queue_attach: error creating socket"); - return(-1); - } - - memset(&saddr, 0, sizeof(saddr)); - saddr.sun_family = AF_UNIX; - strcpy(saddr.sun_path, socket_path); - - /* test for the presence of the socket and another instance - of interlogger listening */ - if(connect(sock, (struct sockaddr *)&saddr, sizeof(saddr.sun_path)) < 0) { - if(errno == ECONNREFUSED) { - /* socket present, but no one at the other end; remove it */ - il_log(LOG_WARNING, " removing stale input socket %s\n", socket_path); - unlink(socket_path); - } - /* ignore other errors for now */ - } else { - /* connection was successful, so bail out - there is - another interlogger running */ - set_error(IL_SYS, EADDRINUSE, "input_queue_attach: another instance of interlogger is running"); - return(-1); - } - - if(bind(sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { - set_error(IL_SYS, errno, "input_queue_attach: error binding socket"); - return(-1); - } - - if (listen(sock, SOCK_QUEUE_MAX)) { - set_error(IL_SYS, errno, "input_queue_attach: error listening on socket"); - return -1; - } - - return(0); -} - -void input_queue_detach() -{ - if (sock >= 0) - close(sock); - unlink(socket_path); -} - - -static -char * -read_event(int sock, long *offset) -{ - char *buffer, *p, *n; - int len, alen; - char buf[256]; - - /* receive offset */ - len = recv(sock, offset, sizeof(*offset), MSG_NOSIGNAL); - if(len < sizeof(*offset)) { - set_error(IL_PROTO, errno, "read_event: error reading offset"); - return(NULL); - } - - /* receive event string */ - buffer=malloc(1024); - if(buffer == NULL) { - set_error(IL_NOMEM, ENOMEM, "read_event: no room for event"); - return(NULL); - } - p = buffer; - - alen = 1024; - while((len=recv(sock, buf, sizeof(buf), MSG_PEEK | MSG_NOSIGNAL)) > 0) { - int i; - - /* we have to be prepared for sizeof(buf) bytes */ - if(alen - (p - buffer) < (int)sizeof(buf)) { - alen += 8192; - n = realloc(buffer, alen); - if(n == NULL) { - free(buffer); - set_error(IL_NOMEM, ENOMEM, "read_event: no room for event"); - return(NULL); - } - p = p - buffer + n; - buffer = n; - } - - /* copy all relevant bytes from buffer */ - for(i=0; (i < len) && (buf[i] != EVENT_SEPARATOR); i++) - *p++ = buf[i]; - - /* remove the data from queue */ - if(i > 0) - if(recv(sock, buf, i, MSG_NOSIGNAL) != i) { - set_error(IL_SYS, errno, "read_event: error reading data"); - free(buffer); - return(NULL); - } - if(i < len) - /* the event is complete */ - break; - } - - /* terminate buffer */ - *p = 0; - - if(len < 0) { - set_error(IL_SYS, errno, "read_event: error reading data"); - free(buffer); - return(NULL); - } - - /* if len == 0, we have not encountered EVENT_SEPARATOR and thus the event is not complete */ - if(len == 0) { - set_error(IL_PROTO, errno, "read_event: error reading data - premature EOF"); - free(buffer); - return(NULL); - } - - /* this is probably not necessary at all: - either len <=0, which was covered before, - or 0 <= i < len => p > buffer; - I would say this condition can not be satisfied. - */ - if(p == buffer) { - set_error(IL_PROTO, errno, "read_event: error reading data - no data received"); - free(buffer); - return(NULL); - } - - return(buffer); -} - - -/* - * Returns: -1 on error, 0 if no message available, message length otherwise - * - */ -int -input_queue_get(char **buffer, long *offset, int timeout) -{ - fd_set fds; - struct timeval tv; - int msg_len; - - assert(buffer != NULL); - - FD_ZERO(&fds); - FD_SET(sock, &fds); - - tv.tv_sec = timeout; - tv.tv_usec = 0; - - msg_len = select(sock + 1, &fds, NULL, NULL, timeout >= 0 ? &tv : NULL); - switch(msg_len) { - - case 0: /* timeout */ - return(0); - - case -1: /* error */ - set_error(IL_SYS, errno, "input_queue_get: error waiting for event"); - return(-1); - - default: - break; - } - - if((accepted=accept(sock, NULL, NULL)) < 0) { - set_error(IL_SYS, errno, "input_queue_get: error accepting connection"); - return(-1); - } - - *buffer = read_event(accepted, offset); - close(accepted); - - if(*buffer == NULL) { - if(error_get_maj() != IL_OK) - return(-1); - else - return(0); - } - - return(strlen(*buffer)); -} diff --git a/org.glite.lb.logger/src/interlogd.c b/org.glite.lb.logger/src/interlogd.c deleted file mode 100644 index dba2f0d..0000000 --- a/org.glite.lb.logger/src/interlogd.c +++ /dev/null @@ -1,279 +0,0 @@ -#ident "$Header$" - -/* - interlogger - collect events from local-logger and send them to logging and bookkeeping servers - -*/ -#include -#include -#include -#include - -#include - -#include "interlogd.h" -#include "glite/lb/consumer.h" -#include "glite/lb/lb_gss.h" - -#define EXIT_FAILURE 1 -#if defined(IL_NOTIFICATIONS) -#define DEFAULT_PREFIX "/tmp/notif_events" -#define DEFAULT_SOCKET "/tmp/notif_interlogger.sock" -#else -#define DEFAULT_PREFIX "/tmp/dglogd.log" -#define DEFAULT_SOCKET "/tmp/interlogger.sock" -#endif - - -/* The name the program was run with, stripped of any leading path. */ -char *program_name; -static int killflg = 0; - -int TIMEOUT = DEFAULT_TIMEOUT; - -gss_cred_id_t cred_handle = GSS_C_NO_CREDENTIAL; -pthread_mutex_t cred_handle_lock = PTHREAD_MUTEX_INITIALIZER; - -time_t key_mtime = 0, cert_mtime = 0; - -static void usage (int status) -{ - printf("%s - \n" - " collect events from local-logger and send them to logging and bookkeeping servers\n" - "Usage: %s [OPTION]... [FILE]...\n" - "Options:\n" - " -h, --help display this help and exit\n" - " -V, --version output version information and exit\n" - " -d, --debug do not run as daemon\n" - " -v, --verbose print extensive debug output\n" - " -f, --file-prefix path and prefix for event files\n" - " -c, --cert location of server certificate\n" - " -k, --key location of server private key\n" - " -C, --CAdir directory containing CA certificates\n" - " -b, --book send events to bookkeeping server only\n" - " -l, --log-server specify address of log server\n" - " -s, --socket non-default path of local socket\n" - , program_name, program_name); - exit(status); -} - - -/* Option flags and variables */ -static int debug; -static int verbose = 0; -char *file_prefix = DEFAULT_PREFIX; -int bs_only = 0; - -char *cert_file = NULL; -char *key_file = NULL; -char *CAcert_dir = NULL; -char *log_server = NULL; -char *socket_path = DEFAULT_SOCKET; - -static struct option const long_options[] = -{ - {"help", no_argument, 0, 'h'}, - {"version", no_argument, 0, 'V'}, - {"verbose", no_argument, 0, 'v'}, - {"debug", no_argument, 0, 'd'}, - {"file-prefix", required_argument, 0, 'f'}, - {"cert", required_argument, 0, 'c'}, - {"key", required_argument, 0, 'k'}, - {"book", no_argument, 0, 'b'}, - {"CAdir", required_argument, 0, 'C'}, - {"log-server", required_argument, 0, 'l'}, - {"socket", required_argument, 0, 's'}, - {NULL, 0, NULL, 0} -}; - - - -/* Set all the option flags according to the switches specified. - Return the index of the first non-option argument. */ -static int -decode_switches (int argc, char **argv) -{ - int c; - - debug = 0; - - while ((c = getopt_long (argc, argv, - "f:" /* file prefix */ - "h" /* help */ - "V" /* version */ - "v" /* verbose */ - "c:" /* certificate */ - "k:" /* key */ - "C:" /* CA dir */ - "b" /* only bookeeping */ - "l:" /* log server */ - "d" /* debug */ - "s:", /* socket */ - long_options, (int *) 0)) != EOF) - { - switch (c) - { - case 'V': - printf ("interlogger %s\n", VERSION); - exit (0); - - case 'v': - verbose = 1; - break; - - case 'h': - usage (0); - - case 'd': - debug = 1; - break; - - case 'f': - file_prefix = strdup(optarg); - break; - - case 'c': - cert_file = strdup(optarg); - break; - - case 'k': - key_file = strdup(optarg); - break; - - case 'b': - bs_only = 1; - break; - - case 'l': - log_server = strdup(optarg); - break; - - case 'C': - CAcert_dir = strdup(optarg); - break; - - case 's': - socket_path = strdup(optarg); - break; - - default: - usage (EXIT_FAILURE); - } - } - - return optind; -} - - -void handle_signal(int num) { - il_log(LOG_DEBUG, "Received signal %d\n", num); - killflg++; -} - -int -main (int argc, char **argv) -{ - int i; - char *p; - edg_wll_GssStatus gss_stat; - int ret; - - program_name = argv[0]; - - setlinebuf(stdout); - setlinebuf(stderr); - - i = decode_switches (argc, argv); - - if ((p = getenv("EDG_WL_INTERLOG_TIMEOUT"))) TIMEOUT = atoi(p); - - /* force -b if we do not have log server */ - if(log_server == NULL) { - log_server = strdup(DEFAULT_LOG_SERVER); - bs_only = 1; - } - - if(init_errors(verbose ? LOG_DEBUG : LOG_WARNING)) { - fprintf(stderr, "Failed to initialize error message subsys. Exiting.\n"); - exit(EXIT_FAILURE); - } - - if (signal(SIGPIPE, handle_signal) == SIG_ERR - || signal(SIGABRT, handle_signal) == SIG_ERR - || signal(SIGTERM, handle_signal) == SIG_ERR - || signal(SIGINT, handle_signal) == SIG_ERR) { - perror("signal"); - exit(EXIT_FAILURE); - } - - il_log(LOG_INFO, "Initializing input queue...\n"); - if(input_queue_attach() < 0) { - il_log(LOG_CRIT, "Failed to initialize input queue: %s\n", error_get_msg()); - exit(EXIT_FAILURE); - } - - /* initialize output queues */ - il_log(LOG_INFO, "Initializing event queues...\n"); - if(queue_list_init(log_server) < 0) { - il_log(LOG_CRIT, "Failed to initialize output event queues: %s\n", error_get_msg()); - exit(EXIT_FAILURE); - } - - if (CAcert_dir) - setenv("X509_CERT_DIR", CAcert_dir, 1); - - edg_wll_gss_watch_creds(cert_file,&cert_mtime); - ret = edg_wll_gss_acquire_cred_gsi(cert_file, key_file, &cred_handle, NULL, &gss_stat); - if (ret) { - char *gss_err = NULL; - char *str; - - if (ret == EDG_WLL_GSS_ERROR_GSS) - edg_wll_gss_get_error(&gss_stat, "edg_wll_gss_acquire_cred_gsi()", &gss_err); - asprintf(&str, "Failed to load GSI credential: %s\n", - (gss_err) ? gss_err : "edg_wll_gss_acquire_cred_gsi() failed"); - il_log(LOG_CRIT, str); - free(str); - if (gss_err) - free(gss_err); - exit(EXIT_FAILURE); - } - - if(!debug && - (daemon(0,0) < 0)) { - perror("daemon"); - exit(EXIT_FAILURE); - } - - if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { - il_log(LOG_CRIT, "Failed to initialize Globus common module\n"); - exit(EXIT_FAILURE); - } - - /* find all unsent events waiting in files */ - { - pthread_t rid; - - il_log(LOG_INFO, "Starting recovery thread...\n"); - if(pthread_create(&rid, NULL, recover_thread, NULL) < 0) { - il_log(LOG_CRIT, "Failed to start recovery thread: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - pthread_detach(rid); - } - - il_log(LOG_INFO, "Entering main loop...\n"); - - /* do the work */ - if(loop() < 0) { - il_log(LOG_CRIT, "Fatal error: %s\n", error_get_msg()); - if (killflg) { - input_queue_detach(); - exit(EXIT_FAILURE); - } - } - il_log(LOG_INFO, "Done!\n"); - input_queue_detach(); - - exit (0); -} diff --git a/org.glite.lb.logger/src/interlogd.h b/org.glite.lb.logger/src/interlogd.h deleted file mode 100644 index 3c96828..0000000 --- a/org.glite.lb.logger/src/interlogd.h +++ /dev/null @@ -1,205 +0,0 @@ -#ifndef INTERLOGGER_P_H -#define INTERLOGGER_P_H - -#ident "$Header$" - -#include "il_error.h" -#include "glite/lb/lb_gss.h" - -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include -#ifdef HAVE_DMALLOC_H -#include -#endif - -#define INTERLOGD_HANDLE_CMD -#define INTERLOGD_FLUSH -#define INTERLOGD_EMS - -#define DEFAULT_USER "michal" -#define DEFAULT_LOG_SERVER "localhost" -#define DEFAULT_TIMEOUT 60 - -#if defined(IL_NOTIFICATIONS) - -#include "glite/lb/notifid.h" - -#undef INTERLOGD_HANDLE_CMD -#undef INTERLOGD_FLUSH -#undef INTERLOGD_EMS -#define IL_EVENT_ID_T edg_wll_NotifId -#define IL_EVENT_GET_UNIQUE(a) edg_wll_NotifIdGetUnique((a)) -#define IL_EVENT_ID_FREE(a) edg_wll_NotifIdFree((a)) -#define IL_EVENT_ID_PARSE(a,b) edg_wll_NotifIdParse((a),(b)) - -#else - -#define INTERLOGD_HANDLE_CMD -#define INTERLOGD_FLUSH -#define INTERLOGD_EMS -#define IL_EVENT_ID_T edg_wlc_JobId -#define IL_EVENT_GET_UNIQUE(a) edg_wlc_JobIdGetUnique((a)) -#define IL_EVENT_ID_FREE(a) edg_wlc_JobIdFree((a)) -#define IL_EVENT_ID_PARSE(a,b) edg_wlc_JobIdParse((a),(b)) - -#endif - - -#define EVENT_SEPARATOR '\n' - -// #define TIMEOUT 5 -extern int TIMEOUT; -#define INPUT_TIMEOUT (60) - - -extern gss_cred_id_t cred_handle; -extern pthread_mutex_t cred_handle_lock; -extern char *cert_file; -extern char *key_file; -extern char *CAcert_dir; -extern int bs_only; - - -/* shared data for thread communication */ -#ifdef INTERLOGD_FLUSH -extern pthread_mutex_t flush_lock; -extern pthread_cond_t flush_cond; -#endif - -struct event_store { - char *event_file_name; /* file with events from local logger */ - char *control_file_name; /* file with control information */ - char *job_id_s; /* string form of the job id */ - long last_committed_bs; /* offset behind event that was last committed by BS */ - long last_committed_ls; /* -"- LS */ - long offset; /* expected file position of next event */ - int recovering; /* flag for recovery mode */ - pthread_rwlock_t update_lock; /* lock to prevent simultaneous updates */ - pthread_rwlock_t use_lock; /* lock to prevent struct deallocation */ -#if defined(IL_NOTIFICATIONS) - char *dest; /* host:port destination */ -#endif -}; - - -struct server_msg { - char *job_id_s; /* necessary for commit */ - long offset; /* just for printing more information to debug */ - char *msg; - int len; - int ev_len; - struct event_store *es; /* cache for corresponding event store */ - long receipt_to; /* receiver (long local-logger id - LLLID) of delivery confirmation (for priority messages) */ -#if defined(IL_NOTIFICATIONS) - char *dest_name; - int dest_port; - char *dest; -#endif -}; - - -struct event_queue { - edg_wll_GssConnection gss; /* GSS connection */ - char *dest_name; - int dest_port; - int timeout; /* queue timeout */ - struct event_queue_msg *tail; /* last message in the queue */ - struct event_queue_msg *head; /* first message in the queue */ -#if defined(INTERLOGD_EMS) - struct event_queue_msg *tail_ems; /* last priority message in the queue (or NULL) */ - struct event_queue_msg *mark_this; /* mark message for removal */ - struct event_queue_msg *mark_prev; /* predecessor of the marked message */ -#endif - pthread_t thread_id; /* id of associated thread */ - pthread_rwlock_t update_lock; /* mutex for queue updates */ - pthread_mutex_t cond_lock; /* mutex for condition variable */ - pthread_cond_t ready_cond; /* condition variable for message arrival */ -#if defined(INTERLOGD_HANDLE_CMD) && defined(INTERLOGD_FLUSH) - int flushing; - int flush_result; /* result of flush operation */ - pthread_cond_t flush_cond; /* condition variable for flush operation */ -#endif -}; - - -/* server msg methods */ -struct server_msg *server_msg_create(char *, long); -struct server_msg *server_msg_copy(struct server_msg *); -int server_msg_init(struct server_msg *, char *); -#if defined(INTERLOGD_EMS) -int server_msg_is_priority(struct server_msg *); -#endif -int server_msg_free(struct server_msg *); - -/* general event queue methods */ -struct event_queue *event_queue_create(char *); -int event_queue_free(struct event_queue *); -int event_queue_empty(struct event_queue *); -int event_queue_insert(struct event_queue *, struct server_msg *); -int event_queue_get(struct event_queue *, struct server_msg **); -int event_queue_remove(struct event_queue *); -int event_queue_enqueue(struct event_queue *, char *); -/* helper */ -int enqueue_msg(struct event_queue *, struct server_msg *); - -/* protocol event queue methods */ -int event_queue_connect(struct event_queue *); -int event_queue_send(struct event_queue *); -int event_queue_close(struct event_queue *); -int send_confirmation(long, int); - -/* thread event queue methods */ -int event_queue_create_thread(struct event_queue *); -int event_queue_lock(struct event_queue *); -int event_queue_unlock(struct event_queue *); -int event_queue_lock_ro(struct event_queue *); -int event_queue_signal(struct event_queue *); -int event_queue_wait(struct event_queue *, int); -int event_queue_sleep(struct event_queue *); -int event_queue_wakeup(struct event_queue *); -int event_queue_cond_lock(struct event_queue *); -int event_queue_cond_unlock(struct event_queue *); - -/* input queue */ -int input_queue_attach(); -void input_queue_detach(); -int input_queue_get(char **, long *, int); - -/* queue management functions */ -int queue_list_init(char *); -struct event_queue *queue_list_get(char *); -struct event_queue *queue_list_first(); -struct event_queue *queue_list_next(); -int queue_list_is_log(struct event_queue *); - -#if defined(IL_NOTIFICATIONS) -struct event_queue *notifid_map_get_dest(const char *); -int notifid_map_set_dest(const char *, struct event_queue *); -int event_queue_move_events(struct event_queue *, struct event_queue *, char *); -#endif - -/* event store functions */ -int event_store_init(char *); -int event_store_cleanup(); -int event_store_recover_all(void); -struct event_store *event_store_find(char *); -int event_store_sync(struct event_store *, long); -int event_store_next(struct event_store *, int); -int event_store_commit(struct event_store *, int, int); -int event_store_recover(struct event_store *); -int event_store_release(struct event_store *); -/* int event_store_remove(struct event_store *); */ - -/* master main loop */ -int loop(); - -/* recover thread */ -void *recover_thread(void*); - -#endif diff --git a/org.glite.lb.logger/src/logd.c b/org.glite.lb.logger/src/logd.c deleted file mode 100644 index f291a81..0000000 --- a/org.glite.lb.logger/src/logd.c +++ /dev/null @@ -1,436 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "logd_proto.h" -#include "glite/lb/consumer.h" -#include "glite/lb/lb_gss.h" - -static const char rcsid[] = "@(#)$Id$"; -static int verbose = 0; -static int debug = 0; -static int port = EDG_WLL_LOG_PORT_DEFAULT; -static char *prefix = EDG_WLL_LOG_PREFIX_DEFAULT; -static char *cert_file = NULL; -static char *key_file = NULL; -static char *CAcert_dir = NULL; -static int noAuth = 0; -static int noIPC = 0; -static int noParse = 0; - -#define DEFAULT_SOCKET "/tmp/interlogger.sock" -char *socket_path = DEFAULT_SOCKET; - -extern int confirm_sock; -extern char confirm_sock_name[256]; - -static struct option const long_options[] = { - { "help", no_argument, 0, 'h' }, - { "version", no_argument, 0, 'V' }, - { "verbose", no_argument, 0, 'v' }, - { "debug", no_argument, 0, 'd' }, - { "port", required_argument, 0, 'p' }, - { "file-prefix", required_argument, 0, 'f' }, - { "cert", required_argument, 0, 'c' }, - { "key", required_argument, 0, 'k' }, - { "CAdir", required_argument, 0, 'C' }, - { "socket",required_argument, 0, 's' }, - { "noAuth", no_argument, 0, 'x' }, - { "noIPC", no_argument, 0, 'y' }, - { "noParse", no_argument, 0, 'z' }, - { NULL, 0, NULL, 0} -}; - -/* - *---------------------------------------------------------------------- - * - * usage - print usage - * - *---------------------------------------------------------------------- - */ - -static void -usage(char *program_name) { - fprintf(stdout,"%s\n" - "- collect events from logging API calls,\n" - "- save them to files and\n" - "- send them to inter-logger\n\n" - "Usage: %s [option]\n" - "-h, --help display this help and exit\n" - "-V, --version output version information and exit\n" - "-d, --debug do not run as daemon\n" - "-v, --verbose print extensive debug output\n" - "-p, --port port to listen\n" - "-f, --file-prefix path and prefix for event files\n" - "-c, --cert location of server certificate\n" - "-k, --key location of server private key\n" - "-C, --CAdir directory containing CA certificates\n" - "-s, --socket socket to send messages (NOT IMPLEMENTED YET)\n" - "--noAuth do not check caller's identity\n" - "--noIPC do not send messages to inter-logger\n" - "--noParse do not parse messages for correctness\n", - program_name,program_name); -} - -static sighandler_t mysignal(int num,sighandler_t handler) -{ - struct sigaction sa,osa; - - memset(&sa,0,sizeof(sa)); - sa.sa_handler = handler; - sa.sa_flags = SA_RESTART; - return sigaction(num,&sa,&osa) ? SIG_ERR : osa.sa_handler; -} - -/* - *---------------------------------------------------------------------- - * - * handle_signal - - * USR1 - increase the verbosity of the program - * USR2 - decrease the verbosity of the program - * - *---------------------------------------------------------------------- - */ -void handle_signal(int num) { - if (num != SIGCHLD) edg_wll_ll_log(LOG_NOTICE,"Received signal %d\n", num); - switch (num) { - case SIGUSR1: - if (edg_wll_ll_log_level < LOG_DEBUG) edg_wll_ll_log_level++; - edg_wll_ll_log(LOG_NOTICE,"Logging level is now %d\n", edg_wll_ll_log_level); - break; - case SIGUSR2: - if (edg_wll_ll_log_level > LOG_EMERG) edg_wll_ll_log_level--; - edg_wll_ll_log(LOG_NOTICE,"Logging level is now %d\n", edg_wll_ll_log_level); - break; - case SIGPIPE: - edg_wll_ll_log(LOG_NOTICE,"Broken pipe, lost communication channel.\n"); - break; - case SIGCHLD: - while (wait3(NULL,WNOHANG,NULL) > 0); - break; - case SIGINT: - case SIGTERM: - case SIGQUIT: - if (confirm_sock) { - edg_wll_ll_log(LOG_NOTICE,"Closing confirmation socket.\n"); - close(confirm_sock); - unlink(confirm_sock_name); - } - exit(1); - break; - default: break; - } -} - -/* - *---------------------------------------------------------------------- - * - * doit - do all the dirty work - * - *---------------------------------------------------------------------- - */ -static int -doit(int socket, gss_cred_id_t cred_handle, char *file_name_prefix, int noipc, int noparse) -{ - char *subject; - int ret; - struct timeval timeout = {10,0}; - edg_wll_GssConnection con; - edg_wll_GssStatus gss_stat; - gss_buffer_desc gss_token = GSS_C_EMPTY_BUFFER; - gss_name_t client_name = GSS_C_NO_NAME; - OM_uint32 min_stat; - gss_OID name_type = GSS_C_NO_OID; - - /* authentication */ - edg_wll_ll_log(LOG_INFO,"Processing authentication:\n"); -// FIXME - put here some meaningfull value of timeout + do somthing if timeouted - ret = edg_wll_gss_accept(cred_handle,socket,&timeout,&con, &gss_stat); - if (ret) { - edg_wll_ll_log(LOG_ERR,"edg_wll_gss_accept() failed\n"); - return(-1); - } - - gss_stat.major_status = gss_inquire_context(&gss_stat.minor_status, con.context, - &client_name, NULL, NULL, NULL, NULL, - NULL, NULL); - if (GSS_ERROR(gss_stat.major_status)) { - char *gss_err; - edg_wll_gss_get_error(&gss_stat, "Cannot read client identification", &gss_err); - edg_wll_ll_log(LOG_WARNING, "%s\n", gss_err); - free(gss_err); - } else { - gss_stat.major_status = gss_display_name(&gss_stat.minor_status, client_name, - &gss_token, &name_type); - if (GSS_ERROR(gss_stat.major_status)) { - char *gss_err; - edg_wll_gss_get_error(&gss_stat, "Cannot process client identification", &gss_err); - edg_wll_ll_log(LOG_WARNING, "%s\n", gss_err); - free(gss_err); - } - } - - if (GSS_ERROR(gss_stat.major_status) || - edg_wll_gss_oid_equal(name_type, GSS_C_NT_ANONYMOUS)) { - edg_wll_ll_log(LOG_INFO," User not authenticated, setting as \"%s\". \n",EDG_WLL_LOG_USER_DEFAULT); - subject=strdup(EDG_WLL_LOG_USER_DEFAULT); - } else { - edg_wll_ll_log(LOG_INFO," User successfully authenticated as:\n"); - edg_wll_ll_log(LOG_INFO, " %s\n", (char *)gss_token.value); - subject=gss_token.value; - memset(&gss_token.value, 0, sizeof(gss_token.value)); - } - - ret = edg_wll_log_proto_server(&con,subject,file_name_prefix,noipc,noparse); - - edg_wll_gss_close(&con, NULL); - if (subject) free(subject); - if (gss_token.length) - gss_release_buffer(&min_stat, &gss_token); - if (client_name != GSS_C_NO_NAME) - gss_release_name(&min_stat, &client_name); - return ret; -} - -/* - *---------------------------------------------------------------------- - * - * Main - - * - *---------------------------------------------------------------------- - */ -int main(int argc, char *argv[]) -{ - int ret; - int childpid; - int opt; - - int listener_fd; - int client_fd; - struct sockaddr_in client_addr; - int client_addr_len; - - char *my_subject_name = NULL; - - time_t cert_mtime = 0, key_mtime = 0; - OM_uint32 min_stat; - edg_wll_GssStatus gss_stat; - gss_cred_id_t cred = GSS_C_NO_CREDENTIAL; - - - setlinebuf(stdout); - setlinebuf(stderr); - - /* welcome */ - fprintf(stdout,"\ -This is LocalLogger, part of Workload Management System in EU DataGrid.\ -Copyright (c) 2002 CERN, INFN and CESNET on behalf of the EU DataGrid.\n"); - - /* get arguments */ - while ((opt = getopt_long(argc,argv, - "h" /* help */ - "V" /* version */ - "v" /* verbose */ - "d" /* debug */ - "p:" /* port */ - "f:" /* file prefix */ - "c:" /* certificate */ - "k:" /* key */ - "C:" /* CA dir */ - "s:" /* socket */ - "x" /* noAuth */ - "y" /* noIPC */ - "z", /* noParse */ - long_options, (int *) 0)) != EOF) { - - switch (opt) { - case 'V': fprintf(stdout,"%s:\t%s\n",argv[0],rcsid); exit(0); - case 'v': verbose = 1; break; - case 'd': debug = 1; break; - case 'p': port = atoi(optarg); break; - case 'f': prefix = optarg; break; - case 'c': cert_file = optarg; break; - case 'k': key_file = optarg; break; - case 'C': CAcert_dir = optarg; break; - case 's': socket_path = optarg; break; - case 'x': noAuth = 1; break; - case 'y': noIPC = 1; break; - case 'z': noParse = 1; break; - case 'h': - default: - usage(argv[0]); exit(0); - } - } - edg_wll_ll_log_init(verbose ? LOG_DEBUG : LOG_INFO); - edg_wll_ll_log(LOG_INFO,"Initializing...\n"); - - /* check noParse */ - edg_wll_ll_log(LOG_INFO,"Parse messages for correctness..."); - if (noParse) { - edg_wll_ll_log(LOG_INFO,"no.\n"); - } else { - edg_wll_ll_log(LOG_INFO,"yes.\n"); - } - - /* check noIPC */ - edg_wll_ll_log(LOG_INFO,"Send messages also to inter-logger..."); - if (noIPC) { - edg_wll_ll_log(LOG_INFO,"no.\n"); - } else { - edg_wll_ll_log(LOG_INFO,"yes.\n"); - } - - /* check prefix correctness */ -/* XXX: check probably also write permisions */ - edg_wll_ll_log(LOG_INFO,"Store messages with the filename prefix \"%s\"...",prefix); - if (strlen(prefix) > FILENAME_MAX - 34) { - edg_wll_ll_log(LOG_INFO,"no.\n"); - edg_wll_ll_log(LOG_CRIT,"Too long prefix for file names, would not be able to write to log files. Exiting.\n"); - exit(1); - } else { - edg_wll_ll_log(LOG_INFO,"yes.\n"); - } - - if (CAcert_dir) - setenv("X509_CERT_DIR", CAcert_dir, 1); - - /* initialize Globus common module */ - edg_wll_ll_log(LOG_INFO,"Initializing Globus common module..."); - if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { - edg_wll_ll_log(LOG_NOTICE,"no.\n"); - edg_wll_ll_log(LOG_CRIT, "Failed to initialize Globus common module. Exiting.\n"); - exit(1); - } else { - edg_wll_ll_log(LOG_INFO,"yes.\n"); - } - - /* initialize signal handling */ - if (mysignal(SIGUSR1, handle_signal) == SIG_ERR) { perror("signal"); exit(1); } - if (mysignal(SIGUSR2, handle_signal) == SIG_ERR) { perror("signal"); exit(1); } - if (mysignal(SIGPIPE, handle_signal) == SIG_ERR) { perror("signal"); exit(1); } - if (mysignal(SIGHUP, SIG_DFL) == SIG_ERR) { perror("signal"); exit(1); } - if (mysignal(SIGINT, handle_signal) == SIG_ERR) { perror("signal"); exit(1); } - if (mysignal(SIGQUIT, handle_signal) == SIG_ERR) { perror("signal"); exit(1); } - if (mysignal(SIGTERM, handle_signal) == SIG_ERR) { perror("signal"); exit(1); } - if (mysignal(SIGCHLD, handle_signal) == SIG_ERR) { perror("signal"); exit(1); } - - edg_wll_gss_watch_creds(cert_file,&cert_mtime); - /* XXX DK: support noAuth */ - ret = edg_wll_gss_acquire_cred_gsi(cert_file, key_file, &cred, &my_subject_name, - &gss_stat); - if (ret) { - /* XXX DK: call edg_wll_gss_get_error() */ - edg_wll_ll_log(LOG_CRIT, "Failed to get GSI credentials. Exiting.\n"); - exit(1); - } - - if (my_subject_name!=NULL) { - edg_wll_ll_log(LOG_INFO," server running with certificate: %s\n",my_subject_name); - free(my_subject_name); - } else if (noAuth) { - edg_wll_ll_log(LOG_INFO," running without certificate\n"); -#if 0 - /* XXX DK: */ - } else { - edg_wll_ll_log(LOG_CRIT,"No server credential found. Exiting.\n"); - exit(1); -#endif - } - - /* do listen */ - edg_wll_ll_log(LOG_INFO,"Listening on port %d\n",port); - listener_fd = do_listen(port); - if (listener_fd == -1) { - edg_wll_ll_log(LOG_CRIT,"Failed to listen on port %d\n",port); - gss_release_cred(&min_stat, &cred); - exit(-1); - } - - client_addr_len = sizeof(client_addr); - bzero((char *) &client_addr, client_addr_len); - - /* daemonize */ - edg_wll_ll_log(LOG_INFO,"Running as daemon..."); - if (debug) { - edg_wll_ll_log(LOG_NOTICE,"no.\n"); - } - else if (daemon(0,0) < 0) { - edg_wll_ll_log(LOG_CRIT,"Failed to run as daemon. Exiting.\n"); - perror("daemon"); - exit(1); - } - else { - edg_wll_ll_log(LOG_INFO,"yes.\n"); - } - - /* - * Main loop - */ - while (1) { - edg_wll_ll_log(LOG_INFO,"Accepting incomming connections...\n"); - client_fd = accept(listener_fd, (struct sockaddr *) &client_addr, - &client_addr_len); - if (client_fd < 0) { - close(listener_fd); - edg_wll_ll_log(LOG_CRIT,"Failed to accept incomming connections\n"); - perror("accept"); - gss_release_cred(&min_stat, &cred); - exit(-1); - } - - switch (edg_wll_gss_watch_creds(cert_file,&cert_mtime)) { - gss_cred_id_t newcred; - case 0: break; - case 1: - ret = edg_wll_gss_acquire_cred_gsi(cert_file,key_file,&newcred,NULL,&gss_stat); - if (ret) { - edg_wll_ll_log(LOG_WARNING, "Reloading credentials failed, continue with older\n"); - } else { - edg_wll_ll_log(LOG_INFO, "Reloading credentials\n"); - gss_release_cred(&min_stat, &cred); - cred = newcred; - } - break; - case -1: - edg_wll_ll_log(LOG_WARNING, "edg_wll_gss_watch_creds failed\n"); - break; - } - - /* FORK - change next line if fork() is not needed (for debugging for - * example - */ -#if 1 - if ((childpid = fork()) < 0) { - perror("fork()"); - close(client_fd); - } - if (childpid == 0) { - ret=doit(client_fd,cred,prefix,noIPC,noParse); - close(client_fd); - goto end; - } - if (childpid > 0) { - close(client_fd); - } -#else - ret=doit(client_fd,cred,prefix,noIPC,noParse); - close(client_fd); -#endif - } /* while */ - -end: - close(listener_fd); - gss_release_cred(&min_stat, &cred); - exit(ret); -} diff --git a/org.glite.lb.logger/src/logd_proto.c b/org.glite.lb.logger/src/logd_proto.c deleted file mode 100644 index 463266a..0000000 --- a/org.glite.lb.logger/src/logd_proto.c +++ /dev/null @@ -1,866 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "logd_proto.h" -#include "glite/lb/context-int.h" -#include "glite/lb/escape.h" -#include "glite/lb/events_parse.h" - -static const int one = 1; - -extern char* socket_path; - -int edg_wll_ll_log_level; - -#define tv_sub(a,b) {\ - (a).tv_usec -= (b).tv_usec;\ - (a).tv_sec -= (b).tv_sec;\ - if ((a).tv_usec < 0) {\ - (a).tv_sec--;\ - (a).tv_usec += 1000000;\ - }\ -} - -/* - *---------------------------------------------------------------------- - * - * send_answer_back - - * - *---------------------------------------------------------------------- - */ -static int send_answer_back(edg_wll_GssConnection *con, int answer, struct timeval *timeout) { - size_t count = 0; - int err = 0; - int ans = answer; - u_int8_t ans_end[4]; - edg_wll_GssStatus gss_stat; - - edg_wll_ll_log(LOG_INFO,"Sending answer \"%d\" back to client...",answer); - ans_end[0] = ans & 0xff; ans >>= 8; - ans_end[1] = ans & 0xff; ans >>= 8; - ans_end[2] = ans & 0xff; ans >>= 8; - ans_end[3] = ans; - if ((err = edg_wll_gss_write_full(con,ans_end,4,timeout,&count, &gss_stat)) < 0 ) { - edg_wll_ll_log(LOG_INFO,"error.\n"); - return edg_wll_log_proto_server_failure(err,&gss_stat,"Error sending answer"); - } else { - edg_wll_ll_log(LOG_INFO,"o.k.\n"); - return 0; - } -} - -/* - *---------------------------------------------------------------------- - * - * wait_for_confirmation - - * - * Args: timeout - number of seconds to wait, 0 => wait indefinitely - * - * Returns: 1 => OK, *code contains error code sent by interlogger - * 0 => timeout expired before anything interesting happened - * -1 => some error (see errno for details) - * - *---------------------------------------------------------------------- - */ -int confirm_sock; -char confirm_sock_name[256]; - -static -int init_confirmation() -{ - struct sockaddr_un saddr; - - /* create socket */ - if((confirm_sock=socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { - edg_wll_ll_log(LOG_ERR,"init_confirmation(): error creating socket\n"); - SYSTEM_ERROR("socket"); - return(-1); - } - - /* set the socket parameters */ - memset(&saddr, 0, sizeof(saddr)); - saddr.sun_family = AF_UNIX; - strcpy(saddr.sun_path, confirm_sock_name); - - /* bind the socket */ - if(bind(confirm_sock, (struct sockaddr *)&saddr, sizeof(saddr.sun_path)) < 0) { - edg_wll_ll_log(LOG_ERR,"init_confirmation(): error binding socket\n"); - SYSTEM_ERROR("bind"); - close(confirm_sock); - unlink(confirm_sock_name); - return(-1); - } - - /* and listen */ - if(listen(confirm_sock, 5) < 0) { - edg_wll_ll_log(LOG_ERR,"init_confirmation(): error listening on socket\n"); - SYSTEM_ERROR("listen"); - close(confirm_sock); - unlink(confirm_sock_name); - return(-1); - } - - return(0); -} - - -int wait_for_confirmation(struct timeval *timeout, int *code) -{ - fd_set fds; - struct timeval to,before,after; - int ret = 0, tmp = 0; - - *code = 0; - - FD_ZERO(&fds); - FD_SET(confirm_sock, &fds); - - /* set timeout */ - if (timeout) { - memcpy(&to,timeout,sizeof to); - gettimeofday(&before,NULL); - } - - /* wait for confirmation at most timeout seconds */ - if ((tmp=select(confirm_sock+1, &fds, NULL, NULL, timeout?&to:NULL)) < 0) { - edg_wll_ll_log(LOG_ERR,"wait_for_confirmation(): error selecting socket\n"); - SYSTEM_ERROR("select"); - ret = -1; - } else { - if (tmp == 0) - ret = 0; - else { - int nsd = accept(confirm_sock, NULL, NULL); - ret = 1; - if(nsd < 0) { - edg_wll_ll_log(LOG_ERR,"wait_for_confirmation(): error accepting a connection on a socket\n"); - SYSTEM_ERROR("accept"); - ret = -1; - } else { - if(recv(nsd, code, sizeof(*code), MSG_NOSIGNAL) < 0) { - edg_wll_ll_log(LOG_ERR,"wait_for_confirmation(): error receiving a message from a socket\n"); - SYSTEM_ERROR("recv"); - ret = -1; - } - close(nsd); - } - } - } - close(confirm_sock); - unlink(confirm_sock_name); - if (timeout) { - gettimeofday(&after,NULL); - tv_sub(after,before); - tv_sub(*timeout,after); - if (timeout->tv_sec < 0) { - timeout->tv_sec = 0; - timeout->tv_usec = 0; - } - } - return ret; -} - -/* - *---------------------------------------------------------------------- - * - * do_listen - listen on given port - * - * Returns: socket handle or -1 if something fails - * - * Calls: socket, bind, listen - * - * Algorithm: - * - *---------------------------------------------------------------------- - */ -int do_listen(int port) -{ - int ret; - int sock; - struct sockaddr_in my_addr; - - memset(&my_addr, 0, sizeof(my_addr)); - my_addr.sin_family = AF_INET; - my_addr.sin_addr.s_addr = INADDR_ANY; - my_addr.sin_port = htons(port); - - sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (sock == -1) { - edg_wll_ll_log(LOG_ERR,"do_listen(): error creating socket\n"); - SYSTEM_ERROR("socket"); - return -1; - } - - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); - ret = bind(sock, (struct sockaddr *)&my_addr, sizeof(my_addr)); - if (ret == -1) { - edg_wll_ll_log(LOG_ERR,"do_listen(): error binding socket\n"); - SYSTEM_ERROR("bind"); - return -1; - } - - ret = listen(sock, 5); - if (ret == -1) { - edg_wll_ll_log(LOG_ERR,"do_listen(): error listening on socket\n"); - SYSTEM_ERROR("listen"); - close(sock); - return -1; - } - - return sock; -} - -/*! - *---------------------------------------------------------------------- - * Write to socket - * Needn't write entire buffer. Timeout is applicable only for non-blocking - * connections - * \param sock IN: connection to work with - * \param buf IN: buffer - * \param bufsize IN: max size to write - * \param timeout INOUT: max time allowed for operation, remaining time on return - * \retval bytes written (>0) on success - * \retval -1 on write error - *---------------------------------------------------------------------- - */ -static ssize_t edg_wll_socket_write(int sock,const void *buf,size_t bufsize,struct timeval *timeout) -{ - ssize_t len = 0, ret = 0; - fd_set fds; - struct timeval to,before,after; - - if (timeout) { - memcpy(&to,timeout,sizeof to); - gettimeofday(&before,NULL); - } - len = write(sock,buf,bufsize); - while (len <= 0) { - FD_ZERO(&fds); - FD_SET(sock,&fds); - if ((ret=select(sock+1,&fds,NULL,NULL,timeout?&to:NULL)) < 0) { - edg_wll_ll_log(LOG_ERR,"edg_wll_socket_write(): error selecting socket\n"); - SYSTEM_ERROR("select"); - break; - } - len = write(sock,buf,bufsize); - } - if (timeout) { - gettimeofday(&after,NULL); - tv_sub(after,before); - tv_sub(*timeout,after); - if (timeout->tv_sec < 0) { - timeout->tv_sec = 0; - timeout->tv_usec = 0; - } - } - return len; -} - -/*! - *---------------------------------------------------------------------- - * Write specified amount of data to socket - * Attempts to call edg_wll_socket_write() untill the entire request is satisfied - * (or times out). - * \param sock IN: connection to work with - * \param buf IN: buffer - * \param bufsize IN: max size to write - * \param timeout INOUT: max time allowed for operation, remaining time on return - * \param total OUT: bytes actually written - * \retval bytes written (>0) on success - * \retval -1 on write error - *---------------------------------------------------------------------- - */ -static ssize_t edg_wll_socket_write_full(int sock,void *buf,size_t bufsize,struct timeval *timeout,ssize_t *total) -{ - ssize_t len; - *total = 0; - - while (*total < bufsize) { - len = edg_wll_socket_write(sock,buf+*total,bufsize-*total,timeout); - if (len < 0) return len; - *total += len; - } - return 0; -} - -/* - *---------------------------------------------------------------------- - * - * edg_wll_log_proto_server - handle incoming data - * - * Returns: 0 if done properly or errno - * - * Calls: - * - * Algorithm: - * - *---------------------------------------------------------------------- - */ -int edg_wll_log_proto_server(edg_wll_GssConnection *con, char *name, char *prefix, int noipc, int noparse) -{ - char *buf,*dglllid,*dguser,*jobId,*name_esc; - char header[EDG_WLL_LOG_SOCKET_HEADER_LENGTH+1]; - char outfilename[FILENAME_MAX]; - size_t count; - int count_total,size; - u_int8_t size_end[4]; - size_t msg_size,dglllid_size,dguser_size; - int i,answer,answer_sent; - int msg_sock; - char *msg,*msg_begin; - FILE *outfile; - int filedesc,filelock_status,flags; - long filepos; - struct flock filelock; - int priority; - long lllid; - int unique; - struct timeval timeout; - int err; - edg_wll_Context context; - edg_wll_Event *event; - edg_wll_GssStatus gss_stat; - - errno = i = answer = answer_sent = size = msg_size = dglllid_size = dguser_size = count = count_total = msg_sock = filedesc = filelock_status = /* priority */ unique = err = 0; - buf = dglllid = dguser = jobId = name_esc = msg = msg_begin = NULL; - event = NULL; - if (EDG_WLL_LOG_TIMEOUT_MAX > EDG_WLL_LOG_SYNC_TIMEOUT_MAX) timeout.tv_sec = EDG_WLL_LOG_TIMEOUT_MAX; - else timeout.tv_sec = EDG_WLL_LOG_SYNC_TIMEOUT_MAX; - timeout.tv_usec = 0; - if (edg_wll_InitContext(&context) != 0) { - edg_wll_ll_log(LOG_ERR,"edg_wll_InitContex(): error.\n"); - answer = ENOMEM; - goto edg_wll_log_proto_server_end; - } - if (edg_wll_ResetError(context) != 0) { - edg_wll_ll_log(LOG_ERR,"edg_wll_ResetError(): error.\n"); - answer = ENOMEM; - goto edg_wll_log_proto_server_end; - } - - /* look for the unique unused long local-logger id (LLLID) */ - lllid = 1000*getpid(); - for (i=0; (i<1000)&&(!unique); i++) { - lllid += i; - snprintf(confirm_sock_name, sizeof(confirm_sock_name), "/tmp/dglogd_sock_%ld", lllid); - if ((filedesc = open(confirm_sock_name,O_CREAT)) == -1) { - if (errno == EEXIST) { - edg_wll_ll_log(LOG_WARNING,"Warning: LLLID %ld already in use.\n",lllid); - } else { - SYSTEM_ERROR("open"); - } - } else { - unique = 1; - close(filedesc); filedesc = 0; - unlink(confirm_sock_name); - } - } - if (!unique) { - edg_wll_ll_log(LOG_ERR,"Cannot determine the unique long local-logger id (LLLID)!\n",lllid); - return EAGAIN; - } - edg_wll_ll_log(LOG_INFO,"Long local-logger id (LLLID): %ld\n",lllid); - - /* receive socket header */ - edg_wll_ll_log(LOG_INFO,"Reading socket header..."); - memset(header, 0, EDG_WLL_LOG_SOCKET_HEADER_LENGTH+1); - if ((err = edg_wll_gss_read_full(con, header, EDG_WLL_LOG_SOCKET_HEADER_LENGTH, &timeout, &count, &gss_stat)) < 0) { - edg_wll_ll_log(LOG_INFO,"error.\n"); - answer = edg_wll_log_proto_server_failure(err,&gss_stat,"Error receiving header"); - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_INFO,"o.k.\n"); - } - edg_wll_ll_log(LOG_DEBUG,"Checking socket header..."); - header[EDG_WLL_LOG_SOCKET_HEADER_LENGTH] = '\0'; - if (strncmp(header,EDG_WLL_LOG_SOCKET_HEADER,EDG_WLL_LOG_SOCKET_HEADER_LENGTH)) { - /* not the proper socket header text */ - edg_wll_ll_log(LOG_DEBUG,"error.\n"); - edg_wll_ll_log(LOG_ERR,"edg_wll_log_proto_server(): invalid socket header\n"); - edg_wll_ll_log(LOG_DEBUG,"edg_wll_log_proto_server(): read header '%s' instead of '%s'\n", - header,EDG_WLL_LOG_SOCKET_HEADER); - answer = EINVAL; - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - } - -/* - edg_wll_ll_log(LOG_DEBUG,"Reading message priority..."); - count = 0; - if ((err = edg_wll_gss_read_full(con, &priority, sizeof(priority), &timeout, &count, &gss_stat)) < 0) { - edg_wll_ll_log(LOG_DEBUG,"error.\n"); - answer = edg_wll_log_proto_server_failure(err,&gss_stat,"Error receiving message priority"); - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - } -*/ - - edg_wll_ll_log(LOG_DEBUG,"Reading message size..."); - count = 0; - if ((err = edg_wll_gss_read_full(con, size_end, 4, &timeout, &count,&gss_stat)) < 0) { - edg_wll_ll_log(LOG_DEBUG,"error.\n"); - answer = edg_wll_log_proto_server_failure(err,&gss_stat,"Error receiving message size"); - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - } - size = size_end[3]; size <<=8; - size |= size_end[2]; size <<=8; - size |= size_end[1]; size <<=8; - size |= size_end[0]; - edg_wll_ll_log(LOG_DEBUG,"Checking message size..."); - if (size <= 0) { - edg_wll_ll_log(LOG_DEBUG,"error.\n"); - /* probably wrong size in the header or nothing to read */ - edg_wll_ll_log(LOG_ERR,"edg_wll_log_proto_server(): invalid size read from socket header\n"); - edg_wll_ll_log(LOG_DEBUG,"Read size '%d'.\n",size); - answer = EINVAL; - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - edg_wll_ll_log(LOG_DEBUG,"- Size read from header: %d bytes.\n",size); - } - - /* format the DG.LLLID string */ - if (asprintf(&dglllid,"DG.LLLID=%ld ",lllid) == -1) { - edg_wll_ll_log(LOG_ERR,"edg_wll_log_proto_server(): nomem for DG.LLLID\n"); - SYSTEM_ERROR("asprintf"); - answer = ENOMEM; - goto edg_wll_log_proto_server_end; - } - dglllid_size = strlen(dglllid); - - /* format the DG.USER string */ - name_esc = edg_wll_LogEscape(name); - if (asprintf(&dguser,"DG.USER=\"%s\" ",name_esc) == -1) { - edg_wll_ll_log(LOG_ERR,"edg_wll_log_proto_server(): nomem for DG.USER\n"); - SYSTEM_ERROR("asprintf"); - answer = ENOMEM; - goto edg_wll_log_proto_server_end; - } - dguser_size = strlen(dguser); - - /* allocate enough memory for all data */ - msg_size = dglllid_size + dguser_size + size + 1; - if ((msg = malloc(msg_size)) == NULL) { - edg_wll_ll_log(LOG_ERR,"edg_wll_log_proto_server(): out of memory for allocating message\n"); - SYSTEM_ERROR("malloc"); - answer = ENOMEM; - goto edg_wll_log_proto_server_end; - } - strncpy(msg,dglllid,dglllid_size); - msg_begin = msg + dglllid_size; // this is the "official" beginning of the message - strncpy(msg_begin,dguser,dguser_size); - - /* receive message */ - edg_wll_ll_log(LOG_INFO,"Reading message from socket..."); - buf = msg_begin + dguser_size; - count = 0; - if ((err = edg_wll_gss_read_full(con, buf, size, &timeout, &count, &gss_stat)) < 0) { - edg_wll_ll_log(LOG_INFO,"error.\n"); - answer = edg_wll_log_proto_server_failure(err,&gss_stat,"Error receiving message"); - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_INFO,"o.k.\n"); - } - - if (buf[count] != '\0') buf[count] = '\0'; - - /* parse message and get jobId and priority from it */ - if (!noparse && strstr(msg, "DG.TYPE=\"command\"") == NULL) { - edg_wll_ll_log(LOG_INFO,"Parsing message for correctness..."); - if (edg_wll_ParseEvent(context,msg_begin,&event) != 0) { - edg_wll_ll_log(LOG_INFO,"error.\n"); - edg_wll_ll_log(LOG_ERR,"edg_wll_log_proto_server(): edg_wll_ParseEvent error\n"); - edg_wll_ll_log(LOG_ERR,"edg_wll_ParseEvent(): %s\n",context->errDesc); - answer = edg_wll_Error(context,NULL,NULL); - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_INFO,"o.k.\n"); - } - edg_wll_ll_log(LOG_DEBUG,"Getting jobId from message..."); - jobId = edg_wlc_JobIdGetUnique(event->any.jobId); - priority = event->any.priority; - edg_wll_FreeEvent(event); - event->any.priority = priority; - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - } else { -/* FIXME: what if edg_wll_InitEvent fails? should be checked somehow -> nomem etc. */ - event = edg_wll_InitEvent(EDG_WLL_EVENT_UNDEF); -/* XXX: - event = calloc(1,sizeof(*event)); - if(event == NULL) { - edg_wll_ll_log(LOG_ERR, "out of memory\n"); - answer = ENOMEM; - goto edg_wll_log_proto_server_end; - } -*/ - -/* XXX: obsolete, logd now doesn't need jobId for 'command' messages, - * it will be probably needed for writing 'command' messages to some files - edg_wll_ll_log(LOG_DEBUG,"Getting jobId from message..."); - jobId = edg_wll_GetJobId(msg); - if (!jobId || edg_wlc_JobIdParse(jobId,&j)) { - edg_wll_ll_log(LOG_DEBUG,"error.\n"); - edg_wll_ll_log(LOG_ERR,"ParseJobId(%s)\n",jobId?jobId:"NULL"); - answer = EINVAL; - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - } - free(jobId); - jobId = edg_wlc_JobIdGetUnique(j); - edg_wlc_JobIdFree(j); -*/ - -/* FIXME: get the priority from message some better way */ - if (strstr(msg, "DG.PRIORITY=1") != NULL) - event->any.priority = 1; - else event->any.priority = 0; - } - - - /* if not command, save message to file */ - if(strstr(msg, "DG.TYPE=\"command\"") == NULL) { - /* compose the name of the log file */ -// edg_wll_ll_log(LOG_DEBUG,"Composing filename from prefix \"%s\" and jobId \"%s\"...",prefix,jobId); - count = strlen(prefix); - strncpy(outfilename,prefix,count); count_total=count; - strncpy(outfilename+count_total,".",1); count_total+=1; count=strlen(jobId); - strncpy(outfilename+count_total,jobId,count); count_total+=count; - outfilename[count_total]='\0'; -// edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - edg_wll_ll_log(LOG_INFO,"Writing message to \"%s\"...",outfilename); - - i = 0; -open_event_file: - /* fopen and properly handle the filelock */ - if ((outfile = fopen(outfilename,"a")) == NULL) { - edg_wll_ll_log(LOG_INFO,"error.\n"); - SYSTEM_ERROR("fopen"); - answer = errno; - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_INFO,"."); - } - if ((filedesc = fileno(outfile)) == -1) { - edg_wll_ll_log(LOG_INFO,"error.\n"); - SYSTEM_ERROR("fileno"); - answer = errno; - fclose(outfile); - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_INFO,"."); - } - filelock.l_type = F_WRLCK; - filelock.l_whence = SEEK_SET; - filelock.l_start = 0; - filelock.l_len = 0; - if ((filelock_status=fcntl(filedesc,F_SETLK,&filelock) < 0) && (i < FCNTL_ATTEMPTS)) { - fclose(outfile); - edg_wll_ll_log(LOG_DEBUG,"\nWaiting %d seconds for filelock to open...\n",FCNTL_TIMEOUT); - sleep(FCNTL_TIMEOUT); - i++; - goto open_event_file; - } - if (filelock_status < 0) { - edg_wll_ll_log(LOG_INFO,"error.\n"); - SYSTEM_ERROR("fcntl"); - answer = errno; - fclose(outfile); - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_INFO,"."); - } - if (fseek(outfile, 0, SEEK_END) == -1) { - SYSTEM_ERROR("fseek"); - answer = errno; - fclose(outfile); - goto edg_wll_log_proto_server_end; - } - if ((filepos=ftell(outfile)) == -1) { - SYSTEM_ERROR("ftell"); - answer = errno; - fclose(outfile); - goto edg_wll_log_proto_server_end; - } - /* write, flush and sync */ - if (fputs(msg,outfile) == EOF) { - edg_wll_ll_log(LOG_INFO,"error.\n"); - SYSTEM_ERROR("fputs"); - answer = errno; - fclose(outfile); - goto edg_wll_log_proto_server_end; - } - if (fflush(outfile) == EOF) { - edg_wll_ll_log(LOG_INFO,"error.\n"); - SYSTEM_ERROR("fflush"); - answer = errno; - fclose(outfile); - goto edg_wll_log_proto_server_end; - } - if (fsync(filedesc) < 0) { /* synchronize */ - edg_wll_ll_log(LOG_INFO,"error.\n"); - SYSTEM_ERROR("fsync"); - answer = errno; - fclose(outfile); - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_INFO,"o.k.\n"); - } - /* close and unlock */ - fclose(outfile); - } else { - filepos = 0; - } - - - /* if not priority send now the answer back to client */ - if (!event->any.priority) { - if (!send_answer_back(con,answer,&timeout)) { - answer_sent = 1; - } - } - - /* send message via IPC (UNIX socket) */ - if (!noipc) { - struct sockaddr_un saddr; - edg_wll_ll_log(LOG_INFO,"The message will be send via IPC (UNIX socket):\n"); - - /* initialize socket */ - edg_wll_ll_log(LOG_DEBUG,"Initializing UNIX socket...\n"); - - edg_wll_ll_log(LOG_DEBUG,"- Getting UNIX socket descriptor..."); - msg_sock = socket(PF_UNIX, SOCK_STREAM, 0); - if(msg_sock < 0) { - edg_wll_ll_log(LOG_DEBUG,"error.\n"); - SYSTEM_ERROR("socket"); - answer = errno; - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - } - - edg_wll_ll_log(LOG_DEBUG,"- Setting UNIX socket parameters..."); - memset(&saddr, 0, sizeof(saddr)); - saddr.sun_family = AF_UNIX; - strcpy(saddr.sun_path, socket_path); - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - - edg_wll_ll_log(LOG_DEBUG,"-- adding O_NONBLOCK to socket parameters..."); - if ((flags = fcntl(msg_sock, F_GETFL, 0)) < 0 || - fcntl(msg_sock, F_SETFL, flags | O_NONBLOCK) < 0) { - edg_wll_ll_log(LOG_DEBUG,"error.\n"); - SYSTEM_ERROR("fcntl"); - answer = errno; - close(msg_sock); - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - } - - /* for priority messages initialize also another socket for confirmation */ - if (event->any.priority) { - edg_wll_ll_log(LOG_DEBUG,"- Initializing 2nd UNIX socket for priority messages confirmation..."); - if(init_confirmation() < 0) { - edg_wll_ll_log(LOG_DEBUG,"error.\n"); - answer = errno; - goto edg_wll_log_proto_server_end; - } else { - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - } - } - - edg_wll_ll_log(LOG_DEBUG,"Connecting to UNIX socket..."); - for (i=0; i < CONNECT_ATTEMPTS; i++) { - if(connect(msg_sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { - if ((errno == EAGAIN) || (errno == ETIMEDOUT)) { - edg_wll_ll_log(LOG_DEBUG,"."); - sleep(CONNECT_TIMEOUT); - continue; - } else if (errno == EISCONN) { - edg_wll_ll_log(LOG_DEBUG,"warning.\n"); - edg_wll_ll_log(LOG_ERR,"The socket is already connected!\n"); - break; - } else { - edg_wll_ll_log(LOG_DEBUG,"error.\n"); - SYSTEM_ERROR("connect"); - answer = errno; - close(msg_sock); - goto edg_wll_log_proto_server_end_1; - } - } else { - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - break; - } - } - - edg_wll_ll_log(LOG_DEBUG,"Sending via IPC the message position %ld (%d bytes)...", filepos, sizeof(filepos)); - count = 0; - if (edg_wll_socket_write_full(msg_sock, &filepos, sizeof(filepos), &timeout, &count) < 0) { - edg_wll_ll_log(LOG_DEBUG,"error.\n"); - edg_wll_ll_log(LOG_ERR,"edg_wll_socket_write_full(): error,\n"); - answer = errno; - close(msg_sock); - goto edg_wll_log_proto_server_end_1; - } else { - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - } - - edg_wll_ll_log(LOG_DEBUG,"Sending via IPC the message itself (%d bytes)...",msg_size); - if (edg_wll_socket_write_full(msg_sock, msg, msg_size, &timeout, &count) < 0) { - edg_wll_ll_log(LOG_DEBUG,"error.\n"); - edg_wll_ll_log(LOG_ERR,"edg_wll_socket_write_full(): error."); - answer = errno; - close(msg_sock); - goto edg_wll_log_proto_server_end_1; - } else { - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - } - - close(msg_sock); - - if (event->any.priority) { - edg_wll_ll_log(LOG_INFO,"Waiting for confirmation..."); - if ((count = wait_for_confirmation(&timeout, &answer)) < 0) { - edg_wll_ll_log(LOG_INFO,"error.\n"); - edg_wll_ll_log(LOG_ERR,"wait_for_confirmation(): error.\n"); - answer = errno; - } else { - edg_wll_ll_log(LOG_INFO,"o.k.\n"); - if (count == 0) { - edg_wll_ll_log(LOG_DEBUG,"Waking up, timeout expired.\n"); - answer = EAGAIN; - } else { - edg_wll_ll_log(LOG_DEBUG,"Confirmation received, waking up.\n"); - } - } - } - } else { - edg_wll_ll_log(LOG_NOTICE,"Not sending via IPC.\n"); - } - -edg_wll_log_proto_server_end: - /* if not sent already, send the answer back to client */ - if (!answer_sent) { - answer = send_answer_back(con,answer,&timeout); - } - /* clean */ - edg_wll_FreeContext(context); - if (name_esc) free(name_esc); - if (dglllid) free(dglllid); - if (dguser) free(dguser); - if (jobId) free(jobId); - if (msg) free(msg); - if (event) free(event); - - edg_wll_ll_log(LOG_INFO,"Done.\n"); - - return answer; - -edg_wll_log_proto_server_end_1: - if (event->any.priority) { - close(confirm_sock); - unlink(confirm_sock_name); - } - goto edg_wll_log_proto_server_end; -} - -/* - *---------------------------------------------------------------------- - * - * edg_wll_log_proto_server_failure - handle protocol failures on the server side - * - * Returns: errno - * - *---------------------------------------------------------------------- - */ -int edg_wll_log_proto_server_failure(int code, edg_wll_GssStatus *gss_code, const char *text) -{ - const char *func = "edg_wll_log_proto_server()"; - int ret = 0; - - if(code>0) { - return(0); - } - switch(code) { - case EDG_WLL_GSS_ERROR_EOF: - edg_wll_ll_log(LOG_ERR,"%s: %s, EOF occured\n", func, text); - ret = EAGAIN; - break; - case EDG_WLL_GSS_ERROR_TIMEOUT: - edg_wll_ll_log(LOG_ERR,"%s: %s, timeout expired\n", func, text); - ret = EAGAIN; - break; - /* XXX DK: co tenhle break??: */ - case EDG_WLL_GSS_ERROR_ERRNO: perror("edg_wll_gss_read()"); break; - edg_wll_ll_log(LOG_ERR,"%s: %s, system error occured\n", func, text); - ret = EAGAIN; - break; - case EDG_WLL_GSS_ERROR_GSS: - { - char *gss_err; - - edg_wll_gss_get_error(gss_code, "GSS error occured", &gss_err); - edg_wll_ll_log(LOG_ERR,"%s: %s, %s\n", func, text, gss_err); - free(gss_err); - ret = EAGAIN; - break; - } - default: - edg_wll_ll_log(LOG_ERR,"%s: %s, unknown error occured\n"); - break; - } - return ret; -} - -/* - *---------------------------------------------------------------------- - * - * edg_wll_ll_log_init - initialize the logging level - * - *---------------------------------------------------------------------- - */ -void edg_wll_ll_log_init(int level) { - edg_wll_ll_log_level = level; -} - -/* - *---------------------------------------------------------------------- - * - * edg_wll_ll_log - print to stderr according to logging level - * serious messages are also written to syslog - * - *---------------------------------------------------------------------- - */ -void edg_wll_ll_log(int level, const char *fmt, ...) { - char *err_text; - va_list fmt_args; - - va_start(fmt_args, fmt); - vasprintf(&err_text, fmt, fmt_args); - va_end(fmt_args); - - if(level <= edg_wll_ll_log_level) - fprintf(stderr, "[%d] %s", (int) getpid(), err_text); - if(level <= LOG_ERR) { - openlog("edg-wl-logd", LOG_PID | LOG_CONS, LOG_DAEMON); - syslog(level, "%s", err_text); - closelog(); - } - - if(err_text) free(err_text); - - return; -} diff --git a/org.glite.lb.logger/src/logd_proto.h b/org.glite.lb.logger/src/logd_proto.h deleted file mode 100644 index b8e167e..0000000 --- a/org.glite.lb.logger/src/logd_proto.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_LOCALLOGGER_LOGD_PROTO_H__ -#define __EDG_WORKLOAD_LOGGING_LOCALLOGGER_LOGD_PROTO_H__ - -#ident "$Header$" - -/** - * \file edg/workload/logging/locallogger/logd_proto.h - * \brief server part of the logging protocol - * \note private - */ - -#ifdef __cplusplus -extern "C" { -#endif - - -#include - -#include "glite/lb/log_proto.h" -#include "glite/lb/lb_gss.h" - -int edg_wll_log_proto_server(edg_wll_GssConnection *con, char *name, char *prefix, int noipc, int noparse); -int edg_wll_log_proto_server_failure(int code, edg_wll_GssStatus *gss_code, const char *text); - -#define SYSTEM_ERROR(my_err) { \ - if (errno !=0 ) \ - edg_wll_ll_log(LOG_ERR,"%s: %s\n",my_err,strerror(errno)); \ - else \ - edg_wll_ll_log(LOG_ERR,"%s\n",my_err); } - -/* locallogger daemon error handling */ - -extern int edg_wll_ll_log_level; -void edg_wll_ll_log_init(int level); -void edg_wll_ll_log(int level, const char *fmt, ...); - - -/* fcntl defaults */ - -#define FCNTL_ATTEMPTS 5 -#define FCNTL_TIMEOUT 1 - - -/* connect defaults */ - -#define CONNECT_ATTEMPTS 50 -#define CONNECT_TIMEOUT 10 - - -/* locallogger daemon listen and connect functions prototypes */ - -int do_listen(int port); -int do_connect(char *hostname, int port); - - -#ifdef __cplusplus -} -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_LOCALLOGGER_LOGD_PROTO_H__ */ diff --git a/org.glite.lb.logger/src/queue_mgr.c b/org.glite.lb.logger/src/queue_mgr.c deleted file mode 100644 index abae1f3..0000000 --- a/org.glite.lb.logger/src/queue_mgr.c +++ /dev/null @@ -1,244 +0,0 @@ -#ident "$Header$" - -#include -#include -#include - -#include "glite/lb/consumer.h" - -#include "interlogd.h" - -struct queue_list { - struct event_queue *queue; - char *dest; - struct queue_list *next; -}; - -static struct event_queue *log_queue; -static struct queue_list *queues; - - -static -int -queue_list_create() -{ - queues = NULL; - - return(0); -} - - -static -int -queue_list_find(struct queue_list *ql, const char *dest, struct queue_list **el, struct queue_list **prev) -{ - struct queue_list *q, *p; - - assert(el != NULL); - - *el = NULL; - if(prev) - *prev = NULL; - - if(ql == NULL) - return(0); - - q = NULL; - p = ql; - - while(p) { - if(strcmp(p->dest, dest) == 0) { - *el = p; - if(prev) - *prev = q; - return(1); - } - - q = p; - p = p->next; - }; - - return(0); -} - - -static -int -queue_list_add(struct queue_list **ql, const char *dest, struct event_queue *eq) -{ - struct queue_list *el; - - assert(dest != NULL); - assert(eq != NULL); - assert(ql != NULL); - - el = malloc(sizeof(*el)); - if(el == NULL) { - set_error(IL_NOMEM, ENOMEM, "queue_list_add: not enough room for new queue"); - return(-1); - } - - el->dest = strdup(dest); - if(el->dest == NULL) { - free(el); - set_error(IL_NOMEM, ENOMEM, "queue_list_add: not enough memory for new queue"); - return(-1); - } - el->queue = eq; - el->next = queues; - *ql = el; - return 0; -} - - -/* -static -int -queue_list_remove(struct queue_list *el, struct queue_list *prev) -{ - assert(el != NULL); - - if(prev) - prev->next = el->next; - else - queues = el->next; - - free(el); - return(1); -} -*/ - - -#if !defined(IL_NOTIFICATIONS) -static -char * -jobid2dest(edg_wlc_JobId jobid) -{ - char *server_name,*out; - unsigned int server_port; - - if (!jobid) { - set_error(IL_PROTO, EDG_WLL_ERROR_PARSE_BROKEN_ULM, "jobid2dest: invalid job id"); - return(NULL); - } - edg_wlc_JobIdGetServerParts(jobid,&server_name,&server_port); - - asprintf(&out,"%s:%d",server_name,server_port); - free(server_name); - if(!out) - set_error(IL_SYS, ENOMEM, "jobid2dest: error creating server name"); - return(out); -} -#endif - -struct event_queue * -queue_list_get(char *job_id_s) -{ - char *dest; - struct queue_list *q; - struct event_queue *eq; -#if !defined(IL_NOTIFICATIONS) - IL_EVENT_ID_T job_id; - - if(job_id_s == NULL || strcmp(job_id_s, "default") == 0) - return(log_queue); - - if(edg_wlc_JobIdParse(job_id_s, &job_id)) { - set_error(IL_LBAPI, EDG_WLL_ERROR_PARSE_BROKEN_ULM, "queue_list_get: invalid job id"); - return(NULL); - } - - dest = jobid2dest(job_id); - edg_wlc_JobIdFree(job_id); -#else - dest = job_id_s; -#endif - - if(dest == NULL) - return(NULL); - - if(queue_list_find(queues, dest, &q, NULL)) { -#if !defined(IL_NOTIFICATIONS) - free(dest); -#endif - return(q->queue); - } else { - eq = event_queue_create(dest); - if(eq) - queue_list_add(&queues, dest, eq); -#if !defined(IL_NOTIFICATIONS) - free(dest); -#endif - return(eq); - } -} - - -int -queue_list_is_log(struct event_queue *eq) -{ - return(eq == queue_list_get(NULL)); -} - - -int -queue_list_init(char *ls) -{ -#if !defined(IL_NOTIFICATIONS) - /* create queue for log server */ - log_queue = event_queue_create(ls); - if(log_queue == NULL) - return(-1); -#endif - - return(queue_list_create()); -} - - -static struct queue_list *current; - - -struct event_queue * -queue_list_first() -{ - current = queues; - return(current ? current->queue : NULL); -} - - -struct event_queue * -queue_list_next() -{ - current = current ? current->next : NULL; - return(current ? current->queue : NULL); -} - -#if defined(IL_NOTIFICATIONS) - -static struct queue_list *notifid_map = NULL; - -struct event_queue * -notifid_map_get_dest(const char * notif_id) -{ - struct queue_list *q = NULL; - - queue_list_find(notifid_map, notif_id, &q, NULL); - return(q ? q->queue : NULL); -} - - -/* returns 1 if mapping was changed, 0 if new one had to be created, -1 on error */ -int -notifid_map_set_dest(const char *notif_id, struct event_queue *eq) -{ - struct queue_list *q; - - if(queue_list_find(notifid_map, notif_id, &q, NULL)) { - q->queue = eq; - return(1); - } else { - return(queue_list_add(¬ifid_map, notif_id, eq)); - } -} - -#endif diff --git a/org.glite.lb.logger/src/queue_thread.c b/org.glite.lb.logger/src/queue_thread.c deleted file mode 100644 index 5eeff30..0000000 --- a/org.glite.lb.logger/src/queue_thread.c +++ /dev/null @@ -1,357 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include - -#include "interlogd.h" - -static -void -queue_thread_cleanup(void *q) -{ - struct event_queue *eq = (struct event_queue *)q; - - il_log(LOG_WARNING, "thread %d exits\n", eq->thread_id); - - /* unlock all held locks */ - /* FIXME: check that the thread always exits when holding these locks; - unlock them at appropriate places if this condition is not met - event_queue_unlock(eq); - event_queue_cond_unlock(eq); - */ - - /* clear thread id */ - eq->thread_id = 0; -} - - -static -void * -queue_thread(void *q) -{ - struct event_queue *eq = (struct event_queue *)q; - int ret, exit, flushing; - - if(init_errors(0) < 0) { - il_log(LOG_ERR, "Error initializing thread specific data, exiting!"); - pthread_exit(NULL); - } - - pthread_cleanup_push(queue_thread_cleanup, q); - - event_queue_cond_lock(eq); - - exit = 0; - while(!exit) { - - clear_error(); - - /* if there are no events, wait for them */ - ret = 0; - while (event_queue_empty(eq) -#if defined(INTERLOGD_HANDLE_CMD) && defined(INTERLOGD_FLUSH) - && ((flushing=eq->flushing) != 1) -#endif - ) { - ret = event_queue_wait(eq, 0); - if(ret < 0) { - /* error waiting */ - il_log(LOG_ERR, "queue_thread: %s\n", error_get_msg()); - event_queue_cond_unlock(eq); - pthread_exit((void*)-1); - } - } /* END while(empty) */ - - il_log(LOG_DEBUG, " attempting delivery to %s:%d\n", eq->dest_name, eq->dest_port); - - /* allow other threads to signal us, ie. insert new events while - * we are sending or request flush operation - */ - event_queue_cond_unlock(eq); - - /* connect to server */ - if((ret=event_queue_connect(eq)) == 0) { - /* not connected */ - if(error_get_maj() != IL_OK) - il_log(LOG_ERR, "queue_thread: %s\n", error_get_msg()); -#if defined(IL_NOTIFICATIONS) - il_log(LOG_INFO, " could not connect to client %s, waiting for retry\n", eq->dest_name); -#else - il_log(LOG_INFO, " could not connect to bookkeeping server %s, waiting for retry\n", eq->dest_name); -#endif - } else { - /* connected, send events */ - switch(ret=event_queue_send(eq)) { - - case 0: - /* there was an error and we still have events to send */ - if(error_get_maj() != IL_OK) - il_log(LOG_ERR, "queue_thread: %s\n", error_get_msg()); - il_log(LOG_DEBUG, " events still waiting\n"); - break; - - case 1: - /* hey, we are done for now */ - il_log(LOG_DEBUG, " all events for %s sent\n", eq->dest_name); - break; - - default: - /* internal error */ - il_log(LOG_ERR, "queue_thread: %s\n", error_get_msg()); - exit = 1; - break; - - } /* switch */ - - /* we are done for now anyway, so close the queue */ - event_queue_close(eq); - } - -#if defined(INTERLOGD_HANDLE_CMD) && defined(INTERLOGD_FLUSH) - if(pthread_mutex_lock(&flush_lock) < 0) - abort(); - event_queue_cond_lock(eq); - - /* Check if we are flushing and if we are, report status to master */ - if(flushing == 1) { - il_log(LOG_DEBUG, " flushing mode detected, reporting status\n"); - /* 0 - events waiting, 1 - events sent, < 0 - some error */ - eq->flush_result = ret; - eq->flushing = 2; - if(pthread_cond_signal(&flush_cond) < 0) - abort(); - } - if(pthread_mutex_unlock(&flush_lock) < 0) - abort(); -#else - event_queue_cond_lock(eq); -#endif - - /* if there was some error with server, sleep for a while */ - /* iff !event_queue_empty() */ - if(ret == 0) - event_queue_sleep(eq); - - if(exit) { - /* we have to clean up before exiting */ - event_queue_cond_unlock(eq); - } - - } /* while */ - - pthread_cleanup_pop(1); - - return(eq); -} - - -int -event_queue_create_thread(struct event_queue *eq) -{ - assert(eq != NULL); - - /* if there is a thread already, just return */ - if(eq->thread_id > 0) - return(0); - - /* create the thread itself */ - if(pthread_create(&eq->thread_id, NULL, queue_thread, eq) < 0) { - eq->thread_id = 0; - set_error(IL_SYS, errno, "event_queue_create_thread: error creating new thread"); - return(-1); - } - - /* the thread is never going to be joined */ - pthread_detach(eq->thread_id); - - return(1); -} - - - -int -event_queue_lock(struct event_queue *eq) -{ - assert(eq != NULL); - - if(pthread_rwlock_wrlock(&eq->update_lock)) { - /*** abort instead, this is too serious - set_error(IL_SYS, errno, "event_queue_lock: error acquiring write lock"); - return(-1); - */ - abort(); - } - - return(0); -} - - -int -event_queue_lock_ro(struct event_queue *eq) -{ - assert(eq != NULL); - - if(pthread_rwlock_rdlock(&eq->update_lock)) { - /*** abort instead, this is too serious - set_error(IL_SYS, errno, "event_queue_lock_ro: error acquiring read lock"); - return(-1); - */ - abort(); - } - - return(0); -} - - -int -event_queue_unlock(struct event_queue *eq) -{ - assert(eq != NULL); - - if(pthread_rwlock_unlock(&eq->update_lock)) { - /*** abort instead, this is too serious - set_error(IL_SYS, errno, "event_queue_unlock: error releasing lock"); - return(-1); - */ - abort(); - } - - return(0); -} - - -int -event_queue_signal(struct event_queue *eq) -{ - assert(eq != NULL); - - if(pthread_cond_signal(&eq->ready_cond)) { - /*** abort instead, this is too serious - set_error(IL_SYS, errno, "event_queue_signal: error signaling queue thread"); - return(-1); - */ - abort(); - } - return(0); -} - - -int -event_queue_wait(struct event_queue *eq, int timeout) -{ - assert(eq != NULL); - - if(timeout) { - struct timespec endtime; - int ret = 0; - - endtime.tv_sec = time(NULL) + timeout; - endtime.tv_nsec = 0; - - if((ret=pthread_cond_timedwait(&eq->ready_cond, &eq->cond_lock, &endtime))) { - if(ret == ETIMEDOUT) - return(1); - /*** abort instead, this is too serious - set_error(IL_SYS, errno, "event_queue_wait: error waiting on condition variable"); - return(-1); - */ - abort(); - } - } else { - if(pthread_cond_wait(&eq->ready_cond, &eq->cond_lock)) { - /*** abort instead, this is too serious - set_error(IL_SYS, errno, "event_queue_wait: error waiting on condition variable"); - return(-1); - */ - abort(); - } - } - return(0); -} - - -int event_queue_sleep(struct event_queue *eq) -{ -#if defined(INTERLOGD_HANDLE_CMD) && defined(INTERLOGD_FLUSH) - struct timespec ts; - struct timeval tv; - int ret; - - assert(eq != NULL); - - gettimeofday(&tv, NULL); - ts.tv_sec = tv.tv_sec + eq->timeout; - ts.tv_nsec = 1000 * tv.tv_usec; - if((ret=pthread_cond_timedwait(&eq->flush_cond, &eq->cond_lock, &ts)) < 0) { - if(ret != ETIMEDOUT) { - /*** abort instead, this is too serious - set_error(IL_SYS, errno, "event_queue_sleep: error waiting on condition"); - return(-1); - */ - abort(); - } - } -#else - sleep(eq->timeout); -#endif - return(0); -} - - -#if defined(INTERLOGD_HANDLE_CMD) -int event_queue_wakeup(struct event_queue *eq) -{ - assert(eq != NULL); - - if(pthread_cond_signal(&eq->ready_cond)) { - /** - set_error(IL_SYS, errno, "event_queue_wakeup: error signaling queue thread"); - return(-1); - */ - abort(); - } -#if defined(INTERLOGD_FLUSH) - if(pthread_cond_signal(&eq->flush_cond)) { - /** - set_error(IL_SYS, errno, "event_queue_wakeup: error signaling queue thread"); - return(-1); - */ - abort(); - } -#endif - return(0); -} -#endif - -int event_queue_cond_lock(struct event_queue *eq) -{ - assert(eq != NULL); - - if(pthread_mutex_lock(&eq->cond_lock)) { - /** - set_error(IL_SYS, errno, "event_queue_cond_lock: error locking condition mutex"); - return(-1); - */ - abort(); - } - - return(0); -} - - -int event_queue_cond_unlock(struct event_queue *eq) -{ - assert(eq != NULL); - - if(pthread_mutex_unlock(&eq->cond_lock)) { - /** - set_error(IL_SYS, errno, "event_queue_cond_unlock: error locking condition mutex"); - return(-1); - */ - abort(); - } - - return(0); -} diff --git a/org.glite.lb.logger/src/recover.c b/org.glite.lb.logger/src/recover.c deleted file mode 100644 index ed31186..0000000 --- a/org.glite.lb.logger/src/recover.c +++ /dev/null @@ -1,55 +0,0 @@ -#ident "$Header$" - -#include -#include -#include - -#include "interlogd.h" - -extern char *file_prefix; - -extern time_t cert_mtime, key_mtime; - -void * -recover_thread(void *q) -{ - if(init_errors(0) < 0) { - il_log(LOG_ERR, "Error initializing thread specific data, exiting!"); - pthread_exit(NULL); - } - - while(1) { - il_log(LOG_INFO, "Looking up event files...\n"); - if(event_store_init(file_prefix) < 0) { - il_log(LOG_ERR, "recover_thread: %s\n", error_get_msg()); - exit(1); - } - if(event_store_recover_all() < 0) { - il_log(LOG_ERR, "recover_thread: %s\n", error_get_msg()); - exit(1); - } - if(event_store_cleanup() < 0) { - il_log(LOG_ERR, "recover_thread: %s\n", error_get_msg()); - exit(1); - } - il_log(LOG_INFO, "Checking for new certificate...\n"); - if(pthread_mutex_lock(&cred_handle_lock) < 0) - abort(); - if (edg_wll_gss_watch_creds(cert_file, &cert_mtime) > 0) { - gss_cred_id_t new_cred_handle = GSS_C_NO_CREDENTIAL; - OM_uint32 min_stat; - int ret; - - ret = edg_wll_gss_acquire_cred_gsi(cert_file,key_file, - &new_cred_handle, NULL, NULL); - if (new_cred_handle != GSS_C_NO_CREDENTIAL) { - gss_release_cred(&min_stat, &cred_handle); - cred_handle = new_cred_handle; - il_log(LOG_INFO, "New certificate found and deployed.\n"); - } - } - if(pthread_mutex_unlock(&cred_handle_lock) < 0) - abort(); - sleep(INPUT_TIMEOUT); - } -} diff --git a/org.glite.lb.logger/src/send_event.c b/org.glite.lb.logger/src/send_event.c deleted file mode 100644 index 5d8958f..0000000 --- a/org.glite.lb.logger/src/send_event.c +++ /dev/null @@ -1,328 +0,0 @@ -#ident "$Header$" - -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include -#include -#include -#include - - -/* - * - L/B server protocol handling routines - */ - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/il_string.h" -#include "glite/lb/context.h" - -#include "interlogd.h" - -#if defined(INTERLOGD_EMS) || (defined(INTERLOGD_HANDLE_CMD) && defined(INTERLOGD_FLUSH)) -/* - * Send confirmation to client. - * - */ -int -send_confirmation(long lllid, int code) -{ - struct sockaddr_un saddr; - char sname[256]; - int sock, ret; - - if((sock=socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { - set_error(IL_SYS, errno, "send_confirmation: error creating socket"); - return(-1); - } - - if(fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { - set_error(IL_SYS, errno, "send_confirmation: error setting socket options"); - return(-1); - } - - ret = 0; - memset(&saddr, 0, sizeof(saddr)); - saddr.sun_family = AF_UNIX; - snprintf(sname, sizeof(sname), "/tmp/dglogd_sock_%ld", lllid); - strcpy(saddr.sun_path, sname); - if(connect(sock, (struct sockaddr *)&saddr, sizeof(saddr.sun_path)) < 0) { - set_error(IL_SYS, errno, "send_confirmation: error connecting socket"); - goto out; - } - - if(send(sock, &code, sizeof(code), MSG_NOSIGNAL) < 0) { - set_error(IL_SYS, errno, "send_confirmation: error sending data"); - goto out; - } - ret = 1; - - il_log(LOG_DEBUG, " sent code %d back to client\n", code); - - out: - close(sock); - return(ret); -} - - -static -int -confirm_msg(struct server_msg *msg, int code, int code_min) -{ - switch(code) { - case LB_OK: - code_min = 0; - break; - case LB_DBERR: - /* code_min already contains apropriate error code */ - break; - case LB_PROTO: - code_min = EDG_WLL_IL_PROTO; - break; - default: - code_min = EDG_WLL_IL_SYS; - break; - } - - return(send_confirmation(msg->receipt_to, code_min)); -} -#endif - - -/* - * Read reply from server. - * Returns: -1 - error reading message, - * code > 0 - error code from server - */ -static -int -get_reply(struct event_queue *eq, char **buf, int *code_min) -{ - char buffer[17]; - char *msg, *p; - int inlen, code; - size_t len, l; - edg_wll_GssConnection *gss; - struct timeval tv; - edg_wll_GssStatus gss_stat; - - gss = &eq->gss; - - /* get message header */ - tv.tv_sec = TIMEOUT; - tv.tv_usec = 0; - code = edg_wll_gss_read_full(gss, buffer, 17, &tv, &len, &gss_stat); - if(code < 0) { - char *gss_err = NULL; - - if (code == EDG_WLL_GSS_ERROR_GSS) - edg_wll_gss_get_error(&gss_stat, "get_reply (header)", &gss_err); - set_error(IL_DGGSS, code, - (code == EDG_WLL_GSS_ERROR_GSS) ? gss_err : "get_reply (header)"); - if (gss_err) free(gss_err); - return(-1); - } - - buffer[16] = 0; - - sscanf(buffer, "%d", &inlen); - if(inlen < 0 || inlen > MAXLEN) { - set_error(IL_PROTO, LB_NOMEM, "get_reply: error reading reply length"); - return(-1); - } - len = (size_t) inlen; - - /* allocate room for message body */ - if((msg = malloc(len)) == NULL) { - set_error(IL_NOMEM, ENOMEM, "get_reply: no room for message body"); - return(-1); - } - - /* read all the data */ - tv.tv_sec = TIMEOUT; - tv.tv_usec = 0; - code = edg_wll_gss_read_full(gss, msg, len, &tv, &l, &gss_stat); - if(code < 0) { - char *gss_err = NULL; - - if (code == EDG_WLL_GSS_ERROR_GSS) - edg_wll_gss_get_error(&gss_stat, "get_reply (body)", &gss_err); - set_error(IL_DGGSS, code, - (code == EDG_WLL_GSS_ERROR_GSS) ? gss_err : "get_reply (body)"); - if (gss_err) free(gss_err); - return(-1); - } - - p = msg; - p = get_int(p, &code); - if(p == NULL) { - set_error(IL_PROTO, LB_PROTO, "get_reply: error receiving result code"); - free(msg); - return(-1); - } - p = get_int(p, code_min); - if(p == NULL) { - set_error(IL_PROTO, LB_PROTO, "get_reply: error receiving result code minor"); - free(msg); - return(-1); - } - p = get_string(p, buf); - if(p == NULL) { - if(*buf) { - free(*buf); - *buf = NULL; - } - free(msg); - set_error(IL_PROTO, LB_PROTO, "get_reply: error receiving result string"); - return(-1); - } - free(msg); - return(code); -} - - - -/* - * Returns: 0 - not connected, timeout set, 1 - OK - */ -int -event_queue_connect(struct event_queue *eq) -{ - int ret; - struct timeval tv; - edg_wll_GssStatus gss_stat; - - assert(eq != NULL); - - if(eq->gss.context == GSS_C_NO_CONTEXT) { - - tv.tv_sec = TIMEOUT; - tv.tv_usec = 0; - if(pthread_mutex_lock(&cred_handle_lock) < 0) - abort(); - il_log(LOG_DEBUG, " trying to connect to %s:%d\n", eq->dest_name, eq->dest_port); - ret = edg_wll_gss_connect(cred_handle, eq->dest_name, eq->dest_port, &tv, &eq->gss, &gss_stat); - if(pthread_mutex_unlock(&cred_handle_lock) < 0) - abort(); - if(ret < 0) { - char *gss_err = NULL; - - if (ret == EDG_WLL_GSS_ERROR_GSS) - edg_wll_gss_get_error(&gss_stat, "event_queue_connect: edg_wll_gss_connect", &gss_err); - set_error(IL_DGGSS, ret, - (ret == EDG_WLL_GSS_ERROR_GSS) ? gss_err : "event_queue_connect: edg_wll_gss_connect"); - if (gss_err) free(gss_err); - eq->gss.context = GSS_C_NO_CONTEXT; - eq->timeout = TIMEOUT; - return(0); - } - } - - return(1); -} - - -int -event_queue_close(struct event_queue *eq) -{ - assert(eq != NULL); - - if(eq->gss.context != GSS_C_NO_CONTEXT) { - edg_wll_gss_close(&eq->gss, NULL); - eq->gss.context = GSS_C_NO_CONTEXT; - } - return(0); -} - - -/* - * Send all events from the queue. - * Returns: -1 - system error, 0 - not send, 1 - queue empty - */ -int -event_queue_send(struct event_queue *eq) -{ - assert(eq != NULL); - - if(eq->gss.context == GSS_C_NO_CONTEXT) - return(0); - - /* feed the server with events */ - while (!event_queue_empty(eq)) { - struct server_msg *msg; - char *rep; - int ret, code, code_min; - size_t bytes_sent; - struct timeval tv; - edg_wll_GssStatus gss_stat; - - clear_error(); - - if(event_queue_get(eq, &msg) < 0) - return(-1); - - il_log(LOG_DEBUG, " trying to deliver event at offset %d for job %s\n", msg->offset, msg->job_id_s); - - tv.tv_sec = TIMEOUT; - tv.tv_usec = 0; - ret = edg_wll_gss_write_full(&eq->gss, msg->msg, msg->len, &tv, &bytes_sent, &gss_stat); - if(ret < 0) { - eq->timeout = TIMEOUT; - return(0); - } - - if((code = get_reply(eq, &rep, &code_min)) < 0) { - /* could not get the reply properly, so try again later */ - il_log(LOG_ERR, " error reading server %s reply:\n %s\n", eq->dest_name, error_get_msg()); - eq->timeout = TIMEOUT; - return(0); - } - - il_log(LOG_DEBUG, " event sent, server %s replied with %d, %s\n", eq->dest_name, code, rep); - free(rep); - - /* the reply is back here */ - switch(code) { - - /* NOT USED: case LB_TIME: */ - case LB_NOMEM: - /* NOT USED: case LB_SYS: */ - /* NOT USED: case LB_AUTH: */ - /* non fatal errors (for us) */ - eq->timeout = TIMEOUT; - return(0); - - case LB_OK: - /* event succesfully delivered */ - - default: /* LB_DBERR, LB_PROTO */ - /* the event was not accepted by the server */ - /* update the event pointer */ - if(event_store_commit(msg->es, msg->ev_len, queue_list_is_log(eq)) < 0) - /* failure committing message, this is bad */ - return(-1); - /* if we have just delivered priority message from the queue, send confirmation */ - ret = 1; -#if defined(INTERLOGD_EMS) - if(server_msg_is_priority(msg) && - ((ret=confirm_msg(msg, code, code_min)) < 0)) - return(ret); -#endif - - if((ret == 0) && - (error_get_maj() != IL_OK)) - il_log(LOG_ERR, "send_event: %s\n", error_get_msg()); - - event_queue_remove(eq); - break; - - } /* switch */ - } /* while */ - - return(1); - -} /* send_events */ - - diff --git a/org.glite.lb.logger/src/server_msg.c b/org.glite.lb.logger/src/server_msg.c deleted file mode 100644 index aa7e75c..0000000 --- a/org.glite.lb.logger/src/server_msg.c +++ /dev/null @@ -1,217 +0,0 @@ -#ident "$Header$" - -#include -#include -#include - -#include "interlogd.h" -#include "glite/lb/il_string.h" -#include "glite/lb/events_parse.h" -#include "glite/lb/consumer.h" -#include "glite/lb/context.h" - -static -int -create_msg(char *event, char **buffer, long *receipt) -{ - char *p; int len; - char *ucs = "michal"; - - *receipt = 0; - -#if defined(INTERLOGD_EMS) - /* find DG.LLLID */ - if(strncmp(event, "DG.LLLID",8) == 0 || - strncmp(event, "DG.LLPID",8) == 0) { /* 8 == strlen("DG.LLLID") */ - - /* skip the key */ - event += 9; /* 9 = strlen("DG.LLLID=") */ - *receipt = atol(event); - p = strchr(event, ' '); - if(!p) { - set_error(IL_LBAPI, EDG_WLL_ERROR_PARSE_BROKEN_ULM, - "create_msg: error parsing locallogger PID"); - return(-1); - } - /* skip the value */ - event = p + 1; - - /* find DG.PRIORITY */ - p = strstr(event, "DG.PRIORITY"); - if(p) { - int n; - - p += 12; /* skip the key and = */ - if((n = atoi(p)) == 0) { - /* normal asynchronous message */ - *receipt = 0; - } - } else { - /* could not find priority key */ - *receipt = 0; - } - - } else { - /* could not find local logger PID, confirmation can not be sent */ - *receipt = 0; - } -#endif - - /* allocate enough room to hold the message */ - len = 17 + len_string(ucs) + len_string(event); - if((*buffer = malloc(len)) == NULL) { - set_error(IL_NOMEM, ENOMEM, "create_msg: out of memory allocating message"); - return(-1); - } - - p = *buffer; - - /* write header */ - sprintf(p, "%16d\n", len - 17); - p += 17; - - /* write rest of the message */ - p = put_string(p, ucs); - p = put_string(p, event); - - return(p - *buffer); - -} - - -struct server_msg * -server_msg_create(char *event, long offset) -{ - struct server_msg *msg; - - msg = malloc(sizeof(*msg)); - if(msg == NULL) { - set_error(IL_NOMEM, ENOMEM, "server_msg_create: out of memory allocating message"); - return(NULL); - } - - if(server_msg_init(msg, event) < 0) { - server_msg_free(msg); - return(NULL); - } - msg->offset = offset; - - return(msg); -} - - -struct server_msg * -server_msg_copy(struct server_msg *src) -{ - struct server_msg *msg; - - msg = malloc(sizeof(*msg)); - if(msg == NULL) { - set_error(IL_NOMEM, ENOMEM, "server_msg_copy: out of memory allocating message"); - return(NULL); - } - - msg->msg = malloc(src->len); - if(msg->msg == NULL) { - set_error(IL_NOMEM, ENOMEM, "server_msg_copy: out of memory allocating server message"); - server_msg_free(msg); - return(NULL); - } - msg->len = src->len; - memcpy(msg->msg, src->msg, src->len); - - msg->job_id_s = strdup(src->job_id_s); - msg->ev_len = src->ev_len; - msg->es = src->es; - msg->receipt_to = src->receipt_to; - msg->offset = src->offset; -#if defined(IL_NOTIFICATIONS) - msg->dest_name = strdup(src->dest_name); - msg->dest_port = src->dest_port; - msg->dest = strdup(src->dest); -#endif - return(msg); -} - - -int -server_msg_init(struct server_msg *msg, char *event) -{ -#if defined(IL_NOTIFICATIONS) - edg_wll_Context context; - edg_wll_Event *notif_event; - int ret; -#endif - - assert(msg != NULL); - - memset(msg, 0, sizeof(*msg)); - - -#if defined(IL_NOTIFICATIONS) - edg_wll_InitContext(&context); - - /* parse the notification event */ - if((ret=edg_wll_ParseNotifEvent(context, event, ¬if_event))) { - set_error(IL_LBAPI, ret, "server_msg_init: error parsing notification event"); - return(-1); - } - /* FIXME: check for allocation error */ - if(notif_event->notification.dest_host && - (strlen(notif_event->notification.dest_host) > 0)) { - msg->dest_name = strdup(notif_event->notification.dest_host); - msg->dest_port = notif_event->notification.dest_port; - asprintf(&msg->dest, "%s:%d", msg->dest_name, msg->dest_port); - } - msg->job_id_s = edg_wll_NotifIdUnparse(notif_event->notification.notifId); - if(notif_event->notification.jobstat && - (strlen(notif_event->notification.jobstat) > 0)) { - msg->len = create_msg(event, &msg->msg, &msg->receipt_to); - } - edg_wll_FreeEvent(notif_event); - free(notif_event); - if(msg->len < 0) { - return(-1); - } -#else - msg->len = create_msg(event, &msg->msg, &msg->receipt_to); - if(msg->len < 0) { - return(-1); - } - msg->job_id_s = edg_wll_GetJobId(event); -#endif - /* remember to add event separator to the length */ - msg->ev_len = strlen(event) + 1; - - if(msg->job_id_s == NULL) { - set_error(IL_LBAPI, EDG_WLL_ERROR_PARSE_BROKEN_ULM, "server_msg_init: error getting id"); - return(-1); - } - - return(0); -} - - -int -server_msg_is_priority(struct server_msg *msg) -{ - assert(msg != NULL); - - return(msg->receipt_to != 0); -} - - -int -server_msg_free(struct server_msg *msg) -{ - assert(msg != NULL); - - if(msg->msg) free(msg->msg); - if(msg->job_id_s) free(msg->job_id_s); -#if defined(IL_NOTIFICATIONS) - if(msg->dest_name) free(msg->dest_name); - if(msg->dest) free(msg->dest); -#endif - free(msg); - return 0; -} diff --git a/org.glite.lb.logger/test/IlTestBase.cpp b/org.glite.lb.logger/test/IlTestBase.cpp deleted file mode 100644 index a6b4624..0000000 --- a/org.glite.lb.logger/test/IlTestBase.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "IlTestBase.h" - -#include - -const char *IlTestBase::msg = "DATE=20040831150159.702224 HOST=\"some.host\" PROG=edg-wms LVL=USAGE DG.PRIORITY=0 DG.SOURCE=\"UserInterface\" DG.SRC_INSTANCE=\"\" DG.EVNT=\"RegJob\" DG.JOBID=\"https://some.host:1234/x67qr549qc\" DG.SEQCODE=\"UI=2:NS=0:WM=0:BH=1:JSS=0:LM=0:LRMS=0:APP=0\" DG.USER=\"/C=CZ/O=Cesnet/CN=Michal Vocu\" DG.REGJOB.JDL=\"\" DG.REGJOB.NS=\"ns address\" DG.REGJOB.PARENT=\"\" DG.REGJOB.JOBTYPE=\"SIMPLE\" DG.REGJOB.NSUBJOBS=\"0\" DG.REGJOB.SEED=\"\""; - -const char *IlTestBase::msg_enc = " 429\n6 michal\n415 DATE=20040831150159.702224 HOST=\"some.host\" PROG=edg-wms LVL=USAGE DG.PRIORITY=0 DG.SOURCE=\"UserInterface\" DG.SRC_INSTANCE=\"\" DG.EVNT=\"RegJob\" DG.JOBID=\"https://some.host:1234/x67qr549qc\" DG.SEQCODE=\"UI=2:NS=0:WM=0:BH=1:JSS=0:LM=0:LRMS=0:APP=0\" DG.USER=\"/C=CZ/O=Cesnet/CN=Michal Vocu\" DG.REGJOB.JDL=\"\" DG.REGJOB.NS=\"ns address\" DG.REGJOB.PARENT=\"\" DG.REGJOB.JOBTYPE=\"SIMPLE\" DG.REGJOB.NSUBJOBS=\"0\" DG.REGJOB.SEED=\"\"\n"; - -const struct server_msg IlTestBase::smsg = { - "https://some.host:1234/x67qr549qc", - (char*)IlTestBase::msg_enc, - strlen(IlTestBase::msg_enc), - strlen(IlTestBase::msg) + 1, - NULL -}; diff --git a/org.glite.lb.logger/test/IlTestBase.h b/org.glite.lb.logger/test/IlTestBase.h deleted file mode 100644 index 69bf347..0000000 --- a/org.glite.lb.logger/test/IlTestBase.h +++ /dev/null @@ -1,10 +0,0 @@ -extern "C" { -#include "interlogd.h" -} - -class IlTestBase { -public: - static const char *msg; - static const char *msg_enc; - static const struct server_msg smsg; -}; diff --git a/org.glite.lb.logger/test/event_queueTest.cpp b/org.glite.lb.logger/test/event_queueTest.cpp deleted file mode 100644 index 86a6be1..0000000 --- a/org.glite.lb.logger/test/event_queueTest.cpp +++ /dev/null @@ -1,145 +0,0 @@ -#include - -#include "IlTestBase.h" - -extern "C" { -struct event_queue_msg { - struct server_msg *msg; - struct event_queue_msg *prev; -}; -} - -#include -using namespace std; - -class event_queueTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( event_queueTest ); - CPPUNIT_TEST( testEventQueueCreate ); - CPPUNIT_TEST( testEventQueueInsert ); - CPPUNIT_TEST( testEventQueueGet ); - CPPUNIT_TEST( testEventQueueRemove ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() { - server = strdup("localhost:8080"); - eq = event_queue_create(server); - free(server); - } - - void tearDown() { - struct event_queue_msg *mp; - struct server_msg *m; - - for(mp = eq->head; mp != NULL; ) { - struct event_queue_msg *mq; - - server_msg_free(mp->msg); - mq = mp; - mp = mp->prev; - free(mq); - } - eq->head = NULL; - event_queue_free(eq); - } - - void testEventQueueCreate() { - CPPUNIT_ASSERT( eq != NULL ); - CPPUNIT_ASSERT_EQUAL( string(eq->dest_name), string("localhost") ); - CPPUNIT_ASSERT_EQUAL( eq->dest_port, 8081 ); - CPPUNIT_ASSERT( eq->tail == NULL ); - CPPUNIT_ASSERT( eq->head == NULL ); - CPPUNIT_ASSERT( eq->tail_ems == NULL ); - CPPUNIT_ASSERT( eq->mark_this == NULL ); - CPPUNIT_ASSERT( eq->mark_prev == NULL ); - CPPUNIT_ASSERT( eq->thread_id == 0 ); - CPPUNIT_ASSERT( eq->flushing == 0 ); - CPPUNIT_ASSERT( eq->flush_result == 0 ); - } - - void testEventQueueInsert() { - struct event_queue_msg *mp; - struct server_msg *m; - - doSomeInserts(); - mp = eq->head; - m = mp->msg; - CPPUNIT_ASSERT_EQUAL( string(m->job_id_s), string("2") ); - CPPUNIT_ASSERT_EQUAL( mp, eq->tail_ems ); - mp = mp->prev; - m = mp->msg; - CPPUNIT_ASSERT_EQUAL( string(m->job_id_s), string("1") ); - mp = mp->prev; - m = mp->msg; - CPPUNIT_ASSERT_EQUAL( string(m->job_id_s), string("3") ); - CPPUNIT_ASSERT_EQUAL( mp, eq->tail ); - CPPUNIT_ASSERT( mp->prev == NULL ); - } - - void testEventQueueGet() { - struct event_queue_msg *mp; - struct server_msg *m,sm; - int ret; - - doSomeInserts(); - mp = eq->head; - eq->head = mp->prev; - eq->tail_ems = NULL; - server_msg_free(mp->msg); - free(mp); - ret = event_queue_get(eq, &m); - CPPUNIT_ASSERT( ret == 0 ); - CPPUNIT_ASSERT( eq->mark_this == eq->head ); - CPPUNIT_ASSERT( eq->mark_prev == NULL ); - CPPUNIT_ASSERT_EQUAL( string("1"), string(m->job_id_s) ); - sm = IlTestBase::smsg; - sm.job_id_s = "4"; - sm.receipt_to = 1; - ret = event_queue_insert(eq, &sm); - CPPUNIT_ASSERT( ret == 0 ); - CPPUNIT_ASSERT( eq->mark_prev == eq->head ); - CPPUNIT_ASSERT( eq->mark_this == eq->head->prev ); - ret = event_queue_insert(eq, &sm); - CPPUNIT_ASSERT( ret == 0 ); - CPPUNIT_ASSERT( eq->mark_prev == eq->head->prev ); - CPPUNIT_ASSERT( eq->mark_this == eq->head->prev->prev ); - } - - void testEventQueueRemove() { - struct event_queue_msg *mp; - struct server_msg *m,sm; - int ret; - - doSomeInserts(); - ret = event_queue_get(eq, &m); - mp = eq->mark_this->prev; - sm = IlTestBase::smsg; - sm.job_id_s = "4"; - sm.receipt_to = 1; - event_queue_insert(eq, &sm); - ret = event_queue_remove(eq); - CPPUNIT_ASSERT( eq->head->prev == mp ); - CPPUNIT_ASSERT( eq->mark_this == NULL ); - CPPUNIT_ASSERT( eq->mark_prev == NULL ); - } - -protected: - char *server; - struct event_queue *eq; - - void doSomeInserts() { - struct server_msg m = IlTestBase::smsg; - - m.job_id_s = "1"; - event_queue_insert(eq, &m); - m.receipt_to = 1; - m.job_id_s = "2"; - event_queue_insert(eq, &m); - m.job_id_s = "3"; - m.receipt_to = 0; - event_queue_insert(eq, &m); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION( event_queueTest ); diff --git a/org.glite.lb.logger/test/event_storeTest.cpp b/org.glite.lb.logger/test/event_storeTest.cpp deleted file mode 100644 index 8364cf4..0000000 --- a/org.glite.lb.logger/test/event_storeTest.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include - -#include "IlTestBase.h" - -class event_storeTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( event_storeTest ); - CPPUNIT_TEST( event_store_recoverTest ); - CPPUNIT_TEST( event_store_syncTest ); - CPPUNIT_TEST( event_store_nextTest ); - CPPUNIT_TEST( event_store_commitTest ); - CPPUNIT_TEST( event_store_cleanTest ); - CPPUNIT_TEST( event_store_findTest ); - CPPUNIT_TEST( event_store_releaseTest ); - CPPUNIT_TEST( event_store_initTest ); - CPPUNIT_TEST( event_store_recover_allTest ); - CPPUNIT_TEST( event_store_cleanupTest ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() { - } - - void tearDown() { - } - - void event_store_recoverTest() { - } - - void event_store_syncTest() { - } - - void event_store_nextTest() { - } - - void event_store_commitTest() { - } - - void event_store_cleanTest() { - } - - void event_store_findTest() { - } - - void event_store_releaseTest() { - } - - void event_store_initTest() { - } - - void event_store_recover_allTest() { - } - - void event_store_cleanupTest() { - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION( event_storeTest ); diff --git a/org.glite.lb.logger/test/il_test.cpp b/org.glite.lb.logger/test/il_test.cpp deleted file mode 100644 index 1bafb04..0000000 --- a/org.glite.lb.logger/test/il_test.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include - -extern "C" { -#include -#include "glite/wmsutils/tls/ssl_helpers/ssl_inits.h" -#include "glite/wmsutils/tls/ssl_helpers/ssl_pthreads.h" -#include "interlogd.h" -#include "glite/lb/consumer.h" -#include "glite/lb/lb_gss.h" -} - -#if defined(IL_NOTIFICATIONS) -#define DEFAULT_PREFIX "/tmp/notif_events" -#define DEFAULT_SOCKET "/tmp/notif_interlogger.sock" -#else -#define DEFAULT_PREFIX "/tmp/dglogd.log" -#define DEFAULT_SOCKET "/tmp/interlogger.sock" -#endif - -int TIMEOUT = DEFAULT_TIMEOUT; - -gss_cred_id_t cred_handle = GSS_C_NO_CREDENTIAL; -pthread_mutex_t cred_handle_lock = PTHREAD_MUTEX_INITIALIZER; - -char *file_prefix = DEFAULT_PREFIX; -int bs_only = 0; - -char *cert_file = NULL; -char *key_file = NULL; -char *CAcert_dir = NULL; -char *log_server = NULL; -char *socket_path = DEFAULT_SOCKET; - - -int -main (int ac,const char *av[]) -{ - CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - CppUnit::TextUi::TestRunner runner; - - runner.addTest(suite); - return runner.run() ? 0 : 1; -} diff --git a/org.glite.lb.logger/test/input_queue_socketTest.cpp b/org.glite.lb.logger/test/input_queue_socketTest.cpp deleted file mode 100644 index d29e2cc..0000000 --- a/org.glite.lb.logger/test/input_queue_socketTest.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include - -#include "IlTestBase.h" - -extern "C" { -#include -#include -#include - -#include "interlogd.h" - - extern char *socket_path; -} - -#include -using namespace std; - -class input_queue_socketTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( input_queue_socketTest ); - CPPUNIT_TEST( input_queue_getTest ); - CPPUNIT_TEST_SUITE_END(); - -public: - - void setUp() { - struct sockaddr_un saddr; - int sock; - long offset = 0; - - int ret = input_queue_attach(); - CPPUNIT_ASSERT(ret == 0); - - sock=socket(PF_UNIX, SOCK_STREAM, 0); - CPPUNIT_ASSERT(sock >= 0); - - memset(&saddr, 0, sizeof(saddr)); - saddr.sun_family = AF_UNIX; - strcpy(saddr.sun_path, socket_path); - ret = connect(sock, (struct sockaddr *)&saddr, sizeof(saddr.sun_path)); - CPPUNIT_ASSERT(ret >= 0); - - ret = write(sock, &offset, sizeof(offset)); - CPPUNIT_ASSERT( ret == sizeof(offset) ); - ret = write(sock, IlTestBase::msg, strlen(IlTestBase::msg)); - CPPUNIT_ASSERT( ret == strlen(IlTestBase::msg) ); - ret = write(sock, "\n", 1); - CPPUNIT_ASSERT( ret == 1 ); - } - - void tearDown() { - input_queue_detach(); - } - - - void input_queue_getTest() { - char *event; - long offset; - int ret; - - ret = input_queue_get(&event, &offset, 10); - CPPUNIT_ASSERT( ret >= 0 ); - CPPUNIT_ASSERT_EQUAL( 0L, offset ); - CPPUNIT_ASSERT_EQUAL( string(IlTestBase::msg), string(event) ); - free(event); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(input_queue_socketTest); diff --git a/org.glite.lb.logger/test/ll_test.cpp b/org.glite.lb.logger/test/ll_test.cpp deleted file mode 100644 index 1e8dce6..0000000 --- a/org.glite.lb.logger/test/ll_test.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -extern "C" { -#define DEFAULT_SOCKET "/tmp/interlogger.sock" -char *socket_path = DEFAULT_SOCKET; -int edg_wll_log_proto_server(int *,char *,char *,int,int); -void edg_wll_ll_log_init(int); -} - -class LLTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(LLTest); - CPPUNIT_TEST(testProtoServer); - CPPUNIT_TEST_SUITE_END(); - -public: - - void setUp() { - char *msg = "DATE=20040831150159.702224 HOST=\"some.host\" PROG=edg-wms LVL=USAGE DG.PRIORITY=0 DG.SOURCE=\"UserInterface\" DG.SRC_INSTANCE=\"\" DG.EVNT=\"RegJob\" DG.JOBID=\"https://some.host:1234/x67qr549qc\" DG.SEQCODE=\"UI=2:NS=0:WM=0:BH=1:JSS=0:LM=0:LRMS=0:APP=0\" DG.REGJOB.JDL=\"\" DG.REGJOB.NS=\"ns address\" DG.REGJOB.PARENT=\"\" DG.REGJOB.JOBTYPE=\"SIMPLE\" DG.REGJOB.NSUBJOBS=\"0\" DG.REGJOB.SEED=\"\""; - pipe(pd); - log_proto_client(pd[1], msg); - input_queue_attach(); - } - - void tearDown() { - close(pd[0]); - close(pd[1]); - input_queue_detach(); - } - - void testProtoServer() { - int ret; - edg_wll_ll_log_init(255); - ret = edg_wll_log_proto_server(&pd[0], - "michal", - "/tmp/dglogd.log", - 0, - 0); - CPPUNIT_ASSERT( ret == 0 ); - } - -private: - int pd[2]; - - int log_proto_client(int con, char *logline) { - char header[32]; - int err; - int size; - u_int8_t size_end[4]; - - err = 0; - size = strlen(logline)+1; - size_end[0] = size & 0xff; size >>= 8; - size_end[1] = size & 0xff; size >>= 8; - size_end[2] = size & 0xff; size >>= 8; - size_end[3] = size; - size = strlen(logline)+1; - - err = write(con, "DGLOG", 5); - CPPUNIT_ASSERT(err == 5); - err = write(con, size_end, 4); - CPPUNIT_ASSERT(err == 4); - err = write(con, logline, size); - CPPUNIT_ASSERT( err == size ); -} - - int sock; - int accepted; - -int -input_queue_attach() -{ - struct sockaddr_un saddr; - - CPPUNIT_ASSERT((sock=socket(PF_UNIX, SOCK_STREAM, 0)) >= 0); - - memset(&saddr, 0, sizeof(saddr)); - saddr.sun_family = AF_UNIX; - strcpy(saddr.sun_path, socket_path); - - CPPUNIT_ASSERT(bind(sock, (struct sockaddr *)&saddr, sizeof(saddr)) >= 0); - CPPUNIT_ASSERT(listen(sock, 5) >= 0 ); - return(0); -} - -void input_queue_detach() -{ - if (sock >= 0) - close(sock); - unlink(socket_path); -} - -}; - - -CPPUNIT_TEST_SUITE_REGISTRATION( LLTest ); - -int -main (int ac,const char *av[]) -{ - CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - CppUnit::TextUi::TestRunner runner; - - runner.addTest(suite); - return runner.run() ? 0 : 1; -} diff --git a/org.glite.lb.logger/test/logd_proto_test.c b/org.glite.lb.logger/test/logd_proto_test.c deleted file mode 100644 index 9ee0b44..0000000 --- a/org.glite.lb.logger/test/logd_proto_test.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define edg_wll_gss_read_full(a,b,c,d,e,f) test_edg_wll_gss_read_full(a,b,c,d,e,f) -#define edg_wll_gss_write_full(a,b,c,d,e,f) test_edg_wll_gss_write_full(a,b,c,d,e,f) -#define edg_wll_GssConnection int - -#include "logd_proto.h" -#include "glite/lb/context-int.h" -#include "glite/lb/escape.h" -#include "glite/lb/events_parse.h" - -int -test_edg_wll_gss_read_full(int *fd, - void *buf, - size_t bufsize, - struct timeval *timeout, - size_t *total, - edg_wll_GssStatus *code) -{ - *total = read(*fd, buf, bufsize); - return(*total < 0 ? *total : 0); -} - -int -test_edg_wll_gss_write_full(int *fd, - const void *buf, - size_t bufsize, - struct timeval *timeout, - size_t *total, - edg_wll_GssStatus *code) -{ - return(0); -} - -#include "logd_proto.c" diff --git a/org.glite.lb.logger/test/server_msgTest.cpp b/org.glite.lb.logger/test/server_msgTest.cpp deleted file mode 100644 index e669ea1..0000000 --- a/org.glite.lb.logger/test/server_msgTest.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include - -#include "IlTestBase.h" - -#include - -using namespace std; - -class server_msgTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(server_msgTest); - CPPUNIT_TEST( server_msg_createTest ); - CPPUNIT_TEST( server_msg_copyTest ); - CPPUNIT_TEST_SUITE_END(); - -public: - - void setUp() { - msg = server_msg_create((char *)IlTestBase::msg); - } - - void tearDown() { - server_msg_free(msg); - } - - void server_msg_createTest() { - CPPUNIT_ASSERT( msg != NULL ); - CPPUNIT_ASSERT_EQUAL( string(msg->job_id_s), string(IlTestBase::smsg.job_id_s) ); - CPPUNIT_ASSERT_EQUAL( string(msg->msg), string(IlTestBase::smsg.msg) ); - CPPUNIT_ASSERT_EQUAL( msg->len, IlTestBase::smsg.len ); - CPPUNIT_ASSERT_EQUAL( msg->ev_len, IlTestBase::smsg.ev_len ); - CPPUNIT_ASSERT_EQUAL( msg->es, IlTestBase::smsg.es ); - CPPUNIT_ASSERT( !server_msg_is_priority(msg) ); - } - - void server_msg_copyTest() { - struct server_msg *msg2; - - msg2 = server_msg_copy(msg); - CPPUNIT_ASSERT( msg2 != NULL ); - CPPUNIT_ASSERT( msg2 != msg ); - CPPUNIT_ASSERT_EQUAL( string(msg->job_id_s), string(msg2->job_id_s) ); - CPPUNIT_ASSERT( msg->job_id_s != msg2->job_id_s); - CPPUNIT_ASSERT_EQUAL( string(msg->msg), string(msg2->msg) ); - CPPUNIT_ASSERT( msg->msg != msg2->msg ); - CPPUNIT_ASSERT_EQUAL( msg->len, msg2->len ); - CPPUNIT_ASSERT_EQUAL( msg->ev_len, msg2->ev_len ); - CPPUNIT_ASSERT_EQUAL( msg->es, msg2->es ); - server_msg_free(msg2); - } - -private: - struct server_msg *msg; -}; - - -CPPUNIT_TEST_SUITE_REGISTRATION(server_msgTest); diff --git a/org.glite.lb.server-bones/.cvsignore b/org.glite.lb.server-bones/.cvsignore deleted file mode 100644 index 3a4edf6..0000000 --- a/org.glite.lb.server-bones/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -.project diff --git a/org.glite.lb.server-bones/Makefile b/org.glite.lb.server-bones/Makefile deleted file mode 100644 index 926a6df..0000000 --- a/org.glite.lb.server-bones/Makefile +++ /dev/null @@ -1,91 +0,0 @@ -# defaults -top_srcdir=. -builddir=build -top_builddir=${top_srcdir}/${builddir} -stagedir=. -distdir=. -globalprefix=glite -lbprefix=lb -package=glite-lb-server-bones -version=0.0.1 -PREFIX=/opt/glite - -glite_location=/opt/glite -globus_prefix=/opt/globus -nothrflavour=gcc32 -thrflavour=gcc32pthr -expat_prefix=/opt/expat -ares_prefix=/opt/ares - -CC=gcc - --include Makefile.inc - -VPATH=${top_srcdir}/src:${top_srcdir}/examples - -DEBUG:=-g -O0 -Wall -CFLAGS:= ${DEBUG} -I${top_srcdir}/interface - -COMPILE:=libtool --mode=compile ${CC} ${CFLAGS} -LINK:=libtool --mode=link ${CC} -rpath ${stagedir}/lib ${LDFLAGS} -INSTALL:=libtool --mode=install install - -STATICLIB:=libglite_lb_server_bones.a -LTLIB:=libglite_lb_server_bones.la - -OBJS:=srvbones.o -LOBJS:=${OBJS:.o=.lo} - -HDRS:=srvbones.h - -default all: compile - -compile: ${STATICLIB} ${LTLIB} example - -${STATICLIB}: ${OBJS} - ar crv $@ ${OBJS} - ranlib $@ - -${LTLIB}: ${LOBJS} - ${LINK} -o $@ ${LOBJS} - -stage: compile - $(MAKE) install PREFIX=${stagedir} - -check: - -echo "No unit tests so far." - -example: srv_example cnt_example - -srv_example: srv_example.o - ${LINK} -o $@ ${LTLIB} srv_example.o - -cnt_example: cnt_example.o - ${LINK} -o $@ cnt_example.o - -doc: - -dist: distsrc distbin - -distsrc: - mkdir -p ${top_srcdir}/${package}-${version} - cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version} - cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version} - rm -rf ${top_srcdir}/${package}-${version} - -distbin: - $(MAKE) install PREFIX=`pwd`/tmpbuilddir${stagedir} - save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir - rm -rf tmpbuilddir - -install: - mkdir -p ${PREFIX}/include/${globalprefix}/${lbprefix} - mkdir -p ${PREFIX}/lib - ${INSTALL} -m 644 ${STATICLIB} ${PREFIX}/lib - ${INSTALL} -m 644 ${LTLIB} ${PREFIX}/lib - cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbprefix} - -clean: - -%.o: %.c - ${COMPILE} -c $< diff --git a/org.glite.lb.server-bones/build.xml b/org.glite.lb.server-bones/build.xml deleted file mode 100755 index 9f9f459..0000000 --- a/org.glite.lb.server-bones/build.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.server-bones/examples/cnt_example.c b/org.glite.lb.server-bones/examples/cnt_example.c deleted file mode 100644 index 5f73a23..0000000 --- a/org.glite.lb.server-bones/examples/cnt_example.c +++ /dev/null @@ -1,175 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef dprintf -#define dprintf(x) { if (debug) printf x; fflush(stdout); } -#endif - -#define DEF_MSG "Test message\n" -#define DEF_PORT 9999 - -static struct option opts[] = { - { "help", no_argument, NULL, 'h'}, - { "debug", no_argument, NULL, 'd'}, - { "msg", required_argument, NULL, 'm'}, - { "port", required_argument, NULL, 'p'}, -}; - -int debug = 0; -int port = DEF_PORT; -char *msg = NULL; - -static int writen(int fd, char *ptr, int nbytes); -static int readln(int fd, char *out); - -static void usage(char *me) -{ - fprintf(stderr, - "usage: %s [option]\n" - " -h, --help print this screen\n" - " -d, --debug prints debug messages\n" - " -m, --msg message to send\n" - " -p, --port service port\n", me); -} - - -int main(int argc, char **argv) -{ - struct sockaddr_in addr; - char buff[512], - *me; - int opt, - sock, - n; - - - me = strrchr(argv[0], '/'); - if ( me ) me++; else me = argv[0]; - while ( (opt = getopt_long(argc, argv,"p:m:hd", opts, NULL)) != EOF ) - { - switch ( opt ) - { - case 'm': - msg = strdup(optarg); - break; - case 'p': - port = atoi(optarg); - break; - case 'd': debug = 1; break; - case 'h': usage(me); return 0; - case '?': usage(me); return 1; - } - } - - bzero((char *) &addr, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = inet_addr("127.0.0.1"); - addr.sin_port = htons(port); - if ( (sock = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) - { - perror("socket"); - exit(1); - } - if ( connect(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0 ) - { - perror("connect"); - exit(1); - } - n = strlen(msg? msg: DEF_MSG); - if ( writen(sock, msg? msg: DEF_MSG, n) != n ) - { - dprintf(("error writing message\n")); - exit(1); - } - printf("reply: "); fflush(stdout); - n = readln(sock, buff); - if ( n < 0 ) - { - perror("read() reply error"); - return 1; - } - writen(0, buff, n); - close(sock); - - return 0; -} - -int writen(int fd, char *ptr, int nbytes) -{ - int nleft, nwritten; - - nleft = nbytes; - dprintf(("start writing %d bytes\n", nbytes)); - while ( nleft > 0 ) - { - nwritten = write(fd, ptr, nleft); - dprintf(("written %d bytes", nwritten)); - if ( nwritten <= 0 ) - return (nwritten); - - nleft -= nwritten; - ptr += nwritten; - dprintf((" (left %d bytes)\n", nleft)); - } - - dprintf(("written %d bytes (return: %d)\n", nwritten, nbytes - nleft)); - return (nbytes - nleft); -} - -#define BUFFER_SZ 512 - -int readln(int fd, char *out) -{ - static char buffer[BUFFER_SZ]; - static char *buffer_end = buffer; - int n; - - - dprintf(("reading line\n")); - while ( 1 ) { - if ( buffer_end - buffer ) { - /* buffer contains data - */ - char *endl; - - dprintf(("nonempty buffer\n")); - if ( (endl = memchr(buffer, '\n', buffer_end-buffer)) ) { - int linesz = endl-buffer+1; - - dprintf(("using buffer data\n")); - memcpy(out, buffer, linesz); - if ( endl+1 != buffer_end ) - memmove(buffer, endl+1, buffer_end-endl-1); - buffer_end -= linesz; - return linesz; - } - } - dprintf(("reading...\n")); - n = read(fd, buffer_end, BUFFER_SZ-(buffer_end-buffer)); - if ( n < 0 ) { - if ( errno == EAGAIN ) continue; - dprintf(("reading error\n")); - return n; - } - else if ( n == 0 ) { - int ret = buffer_end-buffer; - dprintf(("end of reading - returning %d bytes\n", ret)); - memcpy(out, buffer, ret); - buffer_end = buffer; - return ret; - } - - dprintf(("read %d bytes\n", n)); - buffer_end += n; - } - - return 0; -} diff --git a/org.glite.lb.server-bones/examples/srv_example.c b/org.glite.lb.server-bones/examples/srv_example.c deleted file mode 100644 index e897bc5..0000000 --- a/org.glite.lb.server-bones/examples/srv_example.c +++ /dev/null @@ -1,199 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "srvbones.h" - -#ifndef dprintf -#define dprintf(x) { if (debug) printf x; fflush(stdout); } -#endif - -#define sizofa(a) (sizeof(a)/sizeof((a)[0])) - -int debug = 1; - -static int writen(int fd, char *ptr, int nbytes); -static int readln(int fd, char *out, int nbytes); -static int echo(int, void *); -static int upper_echo(int, void *); - -#define ECHO_PORT 9999 -#define UPPER_ECHO_PORT 9998 - -#define SRV_ECHO 0 -#define SRV_UPPER_ECHO 1 - -static struct glite_srvbones_service service_table[] = { - { "Echo Service", -1, NULL, echo, NULL, NULL }, - { "Upper Echo Service", -1, NULL, upper_echo, NULL, NULL } -}; - -int main(void) -{ - struct sockaddr_in myaddr; - - - if ( ((service_table[SRV_ECHO].conn = socket(AF_INET, SOCK_STREAM, 0)) == -1) - || ((service_table[SRV_UPPER_ECHO].conn = socket(AF_INET, SOCK_STREAM, 0)) == -1) ) - { - perror("socket"); - exit(1); - } - - bzero((char *) &myaddr, sizeof(myaddr)); - myaddr.sin_family = AF_INET; - myaddr.sin_addr.s_addr = htonl(INADDR_ANY); - myaddr.sin_port = htons(ECHO_PORT); - if ( bind(service_table[SRV_ECHO].conn, (struct sockaddr *)&myaddr, sizeof(myaddr)) == -1 ) - { - perror("bind"); - exit(1); - } - bzero((char *) &myaddr, sizeof(myaddr)); - myaddr.sin_family = AF_INET; - myaddr.sin_addr.s_addr = htonl(INADDR_ANY); - myaddr.sin_port = htons(UPPER_ECHO_PORT); - if ( bind(service_table[SRV_UPPER_ECHO].conn, (struct sockaddr *)&myaddr, sizeof(myaddr)) == -1 ) - { - perror("bind"); - exit(1); - } - - if ( listen(service_table[SRV_ECHO].conn, 10) - || listen(service_table[SRV_UPPER_ECHO].conn, 10) ) - { - perror("listen()"); - exit(1); - } - - glite_srvbones_run(NULL, service_table, sizofa(service_table), 1); - - - return 0; -} - -int upper_echo(int fd, void *data) -{ - int n, i; - char line[80]; - - n = readln(fd, line, 80); - if ( n < 0 ) - { - perror("read() message"); - return n; - } - else if ( n == 0 ) - return 0; - - for ( i = 0; i < n; i++ ) - line[i] = toupper(line[i]); - - if ( writen(fd, line, n) != n ) - { - perror("write() message back"); - return -1; - } - - return 0; -} - -int echo(int fd, void *data) -{ - int n; - char line[80]; - - n = readln(fd, line, 80); - dprintf(("%d bytes read\n", n)); - if ( n < 0 ) - { - perror("read() message"); - return n; - } - else if ( n == 0 ) - return 0; - - if ( writen(fd, line, n) != n ) - { - perror("write() message back"); - return -1; - } - - return 0; -} - -int writen(int fd, char *ptr, int nbytes) -{ - int nleft, nwritten; - - nleft = nbytes; - dprintf(("start writing %d bytes\n", nbytes)); - while ( nleft > 0 ) { - nwritten = write(fd, ptr, nleft); - dprintf(("written %d bytes", nwritten)); - if ( nwritten <= 0 ) - return (nwritten); - - nleft -= nwritten; - ptr += nwritten; - dprintf((" (left %d bytes)\n", nleft)); - } - - dprintf(("written %d bytes (return: %d)\n", nwritten, nbytes - nleft)); - return (nbytes - nleft); -} - -#define BUFFER_SZ 512 - -int readln(int fd, char *out, int nbytes) -{ - static char buffer[BUFFER_SZ]; - static char *buffer_end = buffer; - int n; - - - dprintf(("reading line\n")); - while ( 1 ) { - if ( buffer_end - buffer ) { - /* buffer contains data - */ - char *endl; - - dprintf(("nonempty buffer\n")); - if ( (endl = memchr(buffer, '\n', buffer_end-buffer)) ) { - int linesz = endl-buffer+1; - - memcpy(out, buffer, linesz); - if ( endl+1 != buffer_end ) memmove(buffer, endl+1, buffer_end-endl-1); - buffer_end -= linesz; - return linesz; - } - } - - dprintf(("reding...\n")); - n = read(fd, buffer_end, BUFFER_SZ-(buffer_end-buffer)); - if ( n < 0 ) { - if ( errno == EAGAIN ) n = 0; - else return n; - } - if ( n == 0 ) { - int ret = buffer_end-buffer; - dprintf(("end of reading - returning %d bytes\n", ret)); - memcpy(out, buffer, ret); - buffer_end = buffer; - return ret; - } - dprintf(("read %d bytes\n", n)); - - buffer_end += n; - } - - return 0; -} diff --git a/org.glite.lb.server-bones/interface/srvbones.h b/org.glite.lb.server-bones/interface/srvbones.h deleted file mode 100644 index 1fb87ed..0000000 --- a/org.glite.lb.server-bones/interface/srvbones.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef __ORG_GLITE_LB_SERVER_BONES_BONES_H__ -#define __ORG_GLITE_LB_SERVER_BONES_BONES_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum _glite_srvbones_param_t { - GLITE_SBPARAM_SLAVES_CT, /* default number of slaves */ - GLITE_SBPARAM_SLAVE_OVERLOAD, /* queue items per slave */ - GLITE_SBPARAM_SLAVE_CONNS_MAX, /* commit suicide after that many */ - /* connections */ - GLITE_SBPARAM_CLNT_TIMEOUT, /* keep idle connection that many */ - /* seconds */ - GLITE_SBPARAM_TOTAL_CLNT_TIMEOUT, /* client may ask one slave multiple */ - /* times but only limited time to */ - /* avoid DoS attacks */ -} glite_srvbones_param_t; - -typedef int (*slave_data_init_hnd)(void **); - -struct glite_srvbones_service { - char *id; - int conn; - int (*on_new_conn_hnd)(int conn, struct timeval start, void *clnt_data); - int (*on_accept_hnd)(int conn, void *clnt_data); - int (*on_reject_hnd)(int conn); - int (*on_disconnect_hnd)(int conn, void *clnt_data); -}; - -extern int glite_srvbones_set_param(glite_srvbones_param_t param, ...); -/* - * slaves_ct - forked slaves count - * slave_data_init_hnd - callback initializing client data on every slave - */ -extern int glite_srvbones_run( - slave_data_init_hnd slave_data_init, - struct glite_srvbones_service *service_table, - size_t table_sz, - int dbg); - -#ifdef __cplusplus -} -#endif - -#endif /* __ORG_GLITE_LB_SERVER_BONES_BONES_H__ */ diff --git a/org.glite.lb.server-bones/project/build.properties b/org.glite.lb.server-bones/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.lb.server-bones/project/configure.properties.xml b/org.glite.lb.server-bones/project/configure.properties.xml deleted file mode 100644 index 335c3cf..0000000 --- a/org.glite.lb.server-bones/project/configure.properties.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - -top_srcdir=.. -builddir=build -stagedir=${stage.abs.dir} -distdir=${dist.dir} -globalprefix=${global.prefix} -lbprefix=${subsystem.prefix} -package=${module.package.name} -PREFIX=${install.dir} -version=${module.version} -glite_location=${with.glite.location} -globus_prefix=${with.globus.prefix} -thrflavour=${with.globus.thr.flavor} -nothrflavour=${with.globus.nothr.flavor} -expat_prefix=${with.expat.prefix} -ares_prefix=${with.ares.prefix} -mysql_prefix=${with.mysql.prefix} - - - diff --git a/org.glite.lb.server-bones/project/properties.xml b/org.glite.lb.server-bones/project/properties.xml deleted file mode 100755 index fd20cb9..0000000 --- a/org.glite.lb.server-bones/project/properties.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.server-bones/project/tar_exclude b/org.glite.lb.server-bones/project/tar_exclude deleted file mode 100644 index b3133e4..0000000 --- a/org.glite.lb.server-bones/project/tar_exclude +++ /dev/null @@ -1,10 +0,0 @@ -tar_exclude -CVS -build.xml -build -build.properties -properties.xml -configure-options.xml -.cvsignore -.project -.cdtproject diff --git a/org.glite.lb.server-bones/project/version.properties b/org.glite.lb.server-bones/project/version.properties deleted file mode 100644 index 649422b..0000000 --- a/org.glite.lb.server-bones/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Dec 09 05:01:11 CET 2004 -module.version=0.1.0 -module.build=69 -module.age=1 diff --git a/org.glite.lb.server-bones/src/srvbones.c b/org.glite.lb.server-bones/src/srvbones.c deleted file mode 100644 index 8c69534..0000000 --- a/org.glite.lb.server-bones/src/srvbones.c +++ /dev/null @@ -1,602 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "srvbones.h" - -#define SLAVES_CT 5 /* default number of slaves */ -#define SLAVE_OVERLOAD 10 /* queue items per slave */ -#define SLAVE_CONNS_MAX 500 /* commit suicide after that many connections */ -#define SLAVE_CHECK_SIGNALS 2 /* how often to check signals while waiting for recv_mesg */ -#define CLNT_TIMEOUT 10 /* keep idle connection that many seconds */ -#define TOTAL_CLNT_TIMEOUT 60 /* one client may ask one slave multiple times */ - /* but only limited time to avoid DoS attacks */ - -#ifndef dprintf -#define dprintf(x) { if (debug) printf x; } -#endif - - -static int running = 0; -static int debug = 0; -static volatile int die = 0, - child_died = 0; -static unsigned long clnt_dispatched = 0, - clnt_accepted = 0; - -static struct glite_srvbones_service *services; -static int services_ct; - -static int set_slaves_ct = SLAVES_CT; -static int set_slave_overload = SLAVE_OVERLOAD; -static int set_slave_conns_max = SLAVE_CONNS_MAX; -static struct timeval set_clnt_to = {CLNT_TIMEOUT, 0}; -static struct timeval set_total_clnt_to = {TOTAL_CLNT_TIMEOUT, 0}; - - -static int dispatchit(int, int, int); -static int do_sendmsg(int, int, unsigned long, int); -static int do_recvmsg(int, int *, unsigned long *, int *); -static int check_timeout(struct timeval *, struct timeval, struct timeval); -static void catchsig(int); -static void catch_chld(int sig); -static int slave(int (*)(void **), int); - -static void glite_srvbones_set_slaves_ct(int); -static void glite_srvbones_set_slave_overload(int); -static void glite_srvbones_set_slave_conns_max(int); -static void glite_srvbones_set_clnt_to(struct timeval *); -static void glite_srvbones_set_total_clnt_to(struct timeval *); - - -int glite_srvbones_set_param(glite_srvbones_param_t param, ...) -{ - va_list ap; - - if ( running ) { - dprintf(("Attempting to set srv-bones parameter on running server")); - return -1; - } - - va_start(ap, param); - switch ( param ) { - case GLITE_SBPARAM_SLAVES_CT: - glite_srvbones_set_slaves_ct(va_arg(ap,int)); break; - case GLITE_SBPARAM_SLAVE_OVERLOAD: - glite_srvbones_set_slave_overload(va_arg(ap,int)); break; - case GLITE_SBPARAM_SLAVE_CONNS_MAX: - glite_srvbones_set_slave_conns_max(va_arg(ap,int)); break; - case GLITE_SBPARAM_CLNT_TIMEOUT: - glite_srvbones_set_clnt_to(va_arg(ap,struct timeval *)); break; - case GLITE_SBPARAM_TOTAL_CLNT_TIMEOUT: - glite_srvbones_set_total_clnt_to(va_arg(ap,struct timeval *)); break; - } - va_end(ap); - - return 0; -} - -int glite_srvbones_run( - slave_data_init_hnd slave_data_init, - struct glite_srvbones_service *service_table, - size_t table_sz, - int dbg) -{ - struct sigaction sa; - sigset_t sset; - int sock_slave[2], i; - - - assert(service_table); - assert(table_sz > 0); - - services = service_table; - services_ct = table_sz; - debug = dbg; - - setlinebuf(stdout); - setlinebuf(stderr); - dprintf(("Master pid %d\n", getpid())); - - if ( socketpair(AF_UNIX, SOCK_STREAM, 0, sock_slave) ) - { - perror("socketpair()"); - return 1; - } - - memset(&sa, 0, sizeof(sa)); assert(sa.sa_handler == NULL); - sa.sa_handler = catchsig; - sigaction(SIGINT, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); - - sa.sa_handler = catch_chld; - sigaction(SIGCHLD, &sa, NULL); - - sa.sa_handler = SIG_IGN; - sigaction(SIGUSR1, &sa, NULL); - - sigemptyset(&sset); - sigaddset(&sset, SIGCHLD); - sigaddset(&sset, SIGTERM); - sigaddset(&sset, SIGINT); - sigprocmask(SIG_BLOCK, &sset, NULL); - - for ( i = 0; i < set_slaves_ct; i++ ) - slave(slave_data_init, sock_slave[1]); - - while ( !die ) - { - fd_set fds; - int ret, mx; - - - FD_ZERO(&fds); - FD_SET(sock_slave[0], &fds); - for ( i = 0, mx = sock_slave[0]; i < services_ct; i++ ) - { - FD_SET(services[i].conn, &fds); - if ( mx < services[i].conn ) mx = services[i].conn; - } - - sigprocmask(SIG_UNBLOCK, &sset, NULL); - ret = select(mx+1, &fds, NULL, NULL, NULL); - sigprocmask(SIG_BLOCK, &sset, NULL); - - if ( ret == -1 && errno != EINTR ) - { - if ( debug ) perror("select()"); - else syslog(LOG_CRIT,"select(): %m"); - - return 1; - } - - if ( child_died ) - { - int pid; - - while ( (pid = waitpid(-1, NULL, WNOHANG)) > 0 ) - { - if ( !die ) - { - int newpid = slave(slave_data_init, sock_slave[1]); - dprintf(("[master] Servus mortuus [%d] miraculo resurrexit [%d]\n", pid, newpid)); - } - } - child_died = 0; - continue; - } - - if ( die ) continue; - - - if (FD_ISSET(sock_slave[0],&fds)) { - /* slave accepted a request - */ - unsigned long a; - - if ( (recv(sock_slave[0], &a, sizeof(a), MSG_WAITALL) == sizeof(a)) - && (a <= clnt_dispatched) - && (a > clnt_accepted || clnt_accepted > clnt_dispatched) ) - clnt_accepted = a; - } - - for ( i = 0; i < services_ct; i++ ) - if ( FD_ISSET(services[i].conn, &fds) - && dispatchit(sock_slave[0], services[i].conn ,i) ) - /* Be carefull!!! - * This must break this for cykle but start the - * while (!die) master cykle from the top also - */ - break; - } - - dprintf(("[master] Terminating on signal %d\n", die)); - if (!debug) syslog(LOG_INFO, "Terminating on signal %d\n", die); - kill(0, die); - - return 0; -} - -static int dispatchit(int sock_slave, int sock, int sidx) -{ - struct sockaddr_in a; - unsigned char *pom; - int conn, - alen, ret; - - - alen = sizeof(a); - if ( (conn = accept(sock, (struct sockaddr *)&a, &alen)) < 0 ) - { - if (debug) - { - perror("accept()"); - return 1; - } - else - { - syslog(LOG_ERR, "accept(): %m"); - sleep(5); - return -1; - } - } - - getpeername(conn, (struct sockaddr *)&a, &alen); - pom = (char *) &a.sin_addr.s_addr; - dprintf(("[master] %s connection from %d.%d.%d.%d:%d\n", - services[sidx].id? services[sidx].id: "", - (int)pom[0], (int)pom[1], (int)pom[2], (int)pom[3], - ntohs(a.sin_port))); - - ret = 0; - if ( ( clnt_dispatched < clnt_accepted /* wraparound */ - || clnt_dispatched - clnt_accepted < set_slaves_ct * set_slave_overload) - && !(ret = do_sendmsg(sock_slave, conn, clnt_dispatched++, sidx)) ) - { - /* all done - */ - dprintf(("[master] Dispatched %lu, last known served %lu\n", - clnt_dispatched-1, clnt_accepted)); - } - else - { - services[sidx].on_reject_hnd(conn); - dprintf(("[master] Reject due to overload\n")); - } - - close(conn); - if (ret) - { - perror("sendmsg()"); - if ( !debug ) syslog(LOG_ERR, "sendmsg(): %m"); - } - - - return 0; -} - - -static int slave(slave_data_init_hnd data_init_hnd, int sock) -{ - sigset_t sset; - struct sigaction sa; - struct timeval client_done, - client_start; - void *clnt_data = NULL; - int conn = -1, - srv = -1, - conn_cnt = 0, - sockflags, - h_errno, - pid, i; - - - - if ( (pid = fork()) ) return pid; - - srandom(getpid()+time(NULL)); - - for ( i = 0; i < services_ct; i++ ) - close(services[i].conn); - - sigemptyset(&sset); - sigaddset(&sset, SIGTERM); - sigaddset(&sset, SIGINT); - sigaddset(&sset, SIGUSR1); - - memset(&sa, 0, sizeof(sa)); - sa.sa_handler = catchsig; - sigaction(SIGUSR1, &sa, NULL); - - if ( (sockflags = fcntl(sock, F_GETFL, 0)) < 0 - || fcntl(sock, F_SETFL, sockflags | O_NONBLOCK) < 0 ) - { - dprintf(("[%d] fcntl(master_sock): %s\n", getpid(), strerror(errno))); - if ( !debug ) syslog(LOG_CRIT, "fcntl(master_sock): %m"); - exit(1); - } - - if ( data_init_hnd && data_init_hnd(&clnt_data) ) - /* - * XXX: what if the error remains and master will start new slave - * again and again? - */ - exit(1); - - while ( !die && (conn_cnt < set_slave_conns_max || conn >= 0) ) - { - fd_set fds; - int max = sock, - connflags, - newconn = -1, - newsrv = -1, - kick_client = 0; - unsigned long seq; - struct timeval check_to = { SLAVE_CHECK_SIGNALS, 0}, - total_to = set_total_clnt_to, - client_to = set_clnt_to, - now; - - - FD_ZERO(&fds); - FD_SET(sock, &fds); - if ( conn >= 0 ) FD_SET(conn, &fds); - if ( conn > sock ) max = conn; - - sigprocmask(SIG_UNBLOCK, &sset, NULL); - switch ( select(max+1, &fds, NULL, NULL, &check_to) ) - { - case -1: - if ( errno != EINTR ) - { - dprintf(("[%d] select(): %s\n", getpid(), strerror(errno))); - if ( !debug ) syslog(LOG_CRIT, "select(): %m"); - exit(1); - } - continue; - - case 0: - if ( conn < 0 ) continue; - - default: - break; - } - sigprocmask(SIG_BLOCK, &sset, NULL); - - gettimeofday(&now,NULL); - if ( conn >= 0 - && ( check_timeout(&client_to, client_done, now) - || check_timeout(&total_to, client_start, now)) ) - kick_client = 1; - - if ( conn >= 0 && !kick_client && FD_ISSET(conn, &fds) ) - { - /* - * serve the request - */ - int rv; - - dprintf(("[%d] incoming request\n", getpid())); - if ( !services[srv].on_accept_hnd ) - { - dprintf(("[%d] request handler for '%s' service not set\n", getpid(), services[srv].id)); - kick_client = 1; - continue; - } - - if ( (rv = services[srv].on_accept_hnd(conn, clnt_data)) > 0 ) - { - /* expected FATAL error -> close connection and contiue - */ - close(conn); - conn = -1; - continue; - } - else if ( rv < 0 ) - /* unknown error -> clasified as FATAL -> kill slave - */ - exit(1); - - dprintf(("[%d] request done\n", getpid())); - gettimeofday(&client_done, NULL); - continue; - } - - if ( FD_ISSET(sock, &fds) && conn_cnt < set_slave_conns_max ) - { - if ( conn >= 0 ) usleep(100000 + 1000 * (random() % 200)); - if ( do_recvmsg(sock, &newconn, &seq, &newsrv) ) switch ( errno ) - { - case EINTR: /* XXX: signals are blocked */ - case EAGAIN: - continue; - default: dprintf(("[%d] recvmsg(): %s\n", getpid(), strerror(errno))); - if (!debug) syslog(LOG_CRIT,"recvmsg(): %m\n"); - exit(1); - } - kick_client = 1; - } - - if ( kick_client && conn >= 0 ) - { - if ( services[srv].on_disconnect_hnd ) - services[srv].on_disconnect_hnd(conn, clnt_data); - close(conn); - conn = -1; - srv = -1; - dprintf(("[%d] Idle connection closed\n", getpid())); - } - - if ( newconn >= 0 ) - { - conn = newconn; - srv = newsrv; - gettimeofday(&client_start, NULL); - client_done.tv_sec = client_start.tv_sec; - client_done.tv_usec = client_start.tv_usec; - - switch ( send(sock, &seq, sizeof(seq), 0) ) - { - case -1: - if (debug) perror("send()"); - else syslog(LOG_CRIT, "send(): %m\n"); - exit(1); - - case sizeof(seq): - break; - - default: dprintf(("[%d] send(): incomplete message\n", getpid())); - exit(1); - } - - conn_cnt++; - dprintf(("[%d] serving %s connection %lu\n", getpid(), - services[srv].id? services[srv].id: "", seq)); - - connflags = fcntl(conn, F_GETFL, 0); - if ( fcntl(conn, F_SETFL, connflags | O_NONBLOCK) < 0 ) - { - dprintf(("[%d] can't set O_NONBLOCK mode (%s), closing.\n", getpid(), strerror(errno))); - if ( !debug ) syslog(LOG_ERR, "can't set O_NONBLOCK mode (%s), closing.\n", strerror(errno)); - close(conn); - conn = srv = -1; - continue; - } - - if ( services[srv].on_new_conn_hnd - && services[srv].on_new_conn_hnd(conn, client_start, clnt_data) ) - { - dprintf(("[%d] Connection not estabilished.\n", getpid())); - if ( !debug ) syslog(LOG_ERR, "Connection not estabilished.\n"); - close(conn); - conn = srv = -1; - continue; - } - } - } - - if ( die ) - { - dprintf(("[%d] Terminating on signal %d\n", getpid(), die)); - if ( !debug ) syslog(LOG_INFO, "Terminating on signal %d", die); - } - dprintf(("[%d] Terminating after %d connections\n", getpid(), conn_cnt)); - if ( !debug ) syslog(LOG_INFO, "Terminating after %d connections", conn_cnt); - - - exit(0); -} - -static void catchsig(int sig) -{ - die = sig; -} - -static void catch_chld(int sig) -{ - child_died = 1; -} - -static int check_timeout(struct timeval *timeout, struct timeval before, struct timeval after) -{ - return (timeout->tv_usec <= after.tv_usec - before.tv_usec) ? - (timeout->tv_sec <= after.tv_sec - before.tv_sec) : - (timeout->tv_sec < after.tv_sec - before.tv_sec); -} - -#define MSG_BUFSIZ 30 - -/* - * send socket sock through socket to_sock - */ -static int do_sendmsg(int to_sock, int sock, unsigned long clnt_dispatched, int srv) -{ - struct msghdr msg = {0}; - struct cmsghdr *cmsg; - struct iovec sendiov; - int myfds, /* file descriptors to pass. */ - *fdptr; - char buf[CMSG_SPACE(sizeof myfds)]; /* ancillary data buffer */ - char sendbuf[MSG_BUFSIZ]; /* to store unsigned int + \0 */ - - - snprintf(sendbuf, sizeof(sendbuf), "%u %lu", srv, clnt_dispatched); - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = &sendiov; - msg.msg_iovlen = 1; - sendiov.iov_base = sendbuf; - sendiov.iov_len = sizeof(sendbuf); - - msg.msg_control = buf; - msg.msg_controllen = sizeof buf; - - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(sizeof(int)); - fdptr = (int *)CMSG_DATA(cmsg); - *fdptr = sock; - - msg.msg_controllen = cmsg->cmsg_len; - /* send fd to server-slave to do rest of communication */ - if (sendmsg(to_sock, &msg, 0) < 0) - return 1; - - return 0; -} - - -/* receive socket sock through socket from_sock */ -static int do_recvmsg(int from_sock, int *sock, unsigned long *clnt_accepted,int *srv) -{ - struct msghdr msg = {0}; - struct cmsghdr *cmsg; - struct iovec recviov; - int myfds; /* file descriptors to pass. */ - char buf[CMSG_SPACE(sizeof(myfds))]; /* ancillary data buffer */ - char recvbuf[MSG_BUFSIZ]; - - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = &recviov; - msg.msg_iovlen = 1; - recviov.iov_base = recvbuf; - recviov.iov_len = sizeof(recvbuf); - - msg.msg_control = buf; - msg.msg_controllen = sizeof buf; - - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(sizeof(int)); - msg.msg_controllen = cmsg->cmsg_len; - - if (recvmsg(from_sock, &msg, 0) < 0) - return 1; - - *sock = *((int *)CMSG_DATA(cmsg)); - sscanf(recvbuf, "%u %lu", srv, clnt_accepted); - - return 0; -} - -static void glite_srvbones_set_slaves_ct(int n) -{ - set_slaves_ct = (n == -1)? SLAVES_CT: n; -} - -static void glite_srvbones_set_slave_overload(int n) -{ - set_slave_overload = (n == -1)? SLAVE_OVERLOAD: n; -} - -static void glite_srvbones_set_slave_conns_max(int n) -{ - set_slave_conns_max = (n == -1)? SLAVE_CONNS_MAX: n; -} - -static void glite_srvbones_set_clnt_to(struct timeval *t) -{ - set_clnt_to = t? (struct timeval){CLNT_TIMEOUT, 0}: *t; -} - -static void glite_srvbones_set_total_clnt_to(struct timeval *t) -{ - set_total_clnt_to = t? (struct timeval){TOTAL_CLNT_TIMEOUT, 0}: *t; -} diff --git a/org.glite.lb.server/.cvsignore b/org.glite.lb.server/.cvsignore deleted file mode 100644 index 1df717b..0000000 --- a/org.glite.lb.server/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -.project -.cdtproject \ No newline at end of file diff --git a/org.glite.lb.server/LICENSE b/org.glite.lb.server/LICENSE deleted file mode 100644 index 259a91f..0000000 --- a/org.glite.lb.server/LICENSE +++ /dev/null @@ -1,69 +0,0 @@ -LICENSE file for EGEE Middleware -================================ - -Copyright (c) 2004 on behalf of the EU EGEE Project: -The European Organization for Nuclear Research (CERN), -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Datamat Spa, Italy -Centre National de la Recherche Scientifique (CNRS), France -CS Systeme d'Information (CSSI), France -Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden -Universiteit van Amsterdam (UvA), Netherlands -University of Helsinki (UH.HIP), Finlan -University of Bergen (UiB), Norway -Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. The end-user documentation included with the redistribution, if -any, must include the following acknowledgment: "This product includes -software developed by The EU EGEE Project (http://cern.ch/eu-egee/)." -Alternatively, this acknowledgment may appear in the software itself, if -and wherever such third-party acknowledgments normally appear. - -4. The names EGEE and the EU EGEE Project must not be -used to endorse or promote products derived from this software without -prior written permission. For written permission, please contact -. - -5. You are under no obligation whatsoever to provide anyone with any -bug fixes, patches, or upgrades to the features, functionality or -performance of the Software ("Enhancements") that you may develop over -time; however, if you choose to provide your Enhancements to The EU -EGEE Project, or if you choose to otherwise publish or distribute your -Enhancements, in source code form without contemporaneously requiring -end users of The EU EGEE Proejct to enter into a separate written license -agreement for such Enhancements, then you hereby grant The EU EGEE Project -a non-exclusive, royalty-free perpetual license to install, use, copy, -modify, prepare derivative works, incorporate into the EGEE Middleware -or any other computer software, distribute, and sublicense your -Enhancements or derivative works thereof, in binary and source code -form (if any), whether developed by The EU EGEE Project or third parties. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL PROJECT OR ITS CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This software consists of voluntary contributions made by many -individuals on behalf of the EU EGEE Prject. For more information on The -EU EGEE Project, please see http://cern.ch/eu-egee/. For more information on -EGEE Middleware, please see http://egee-jra1.web.cern.ch/egee-jra1/ - - diff --git a/org.glite.lb.server/Makefile b/org.glite.lb.server/Makefile deleted file mode 100644 index ac6cd76..0000000 --- a/org.glite.lb.server/Makefile +++ /dev/null @@ -1,268 +0,0 @@ -# defaults -top_srcdir=. -builddir=build -top_builddir=${top_srcdir}/${builddir} -stagedir=. -distdir=. -globalprefix=glite -lbprefix=lb -package=glite-lb-server -version=0.2.0 -PREFIX=/opt/glite - -glite_location=/opt/glite -globus_prefix=/opt/globus -nothrflavour=gcc32 -thrflavour=gcc32pthr -expat_prefix=/opt/expat -ares_prefix=/opt/ares -gsoap_prefix=/opt/gsoap - --include Makefile.inc --include ../Makefile.inc - -GLITE_LB_SERVER_WITH_WS=yes - -ifeq ($(GLITE_LB_SERVER_WITH_WS),yes) - gsoap_version=`${gsoap_prefix}/bin/soapcpp2 -version 2>&1 | cut -d' ' -f4 | perl -F\\\\. -nae '$$F[2] =~ s/\D*$$//; print $$F[2]+100*$$F[1]+10000*$$F[0]'` - WS_CFLAGS=-DGLITE_LB_SERVER_WITH_WS -DGSOAP_VERSION=${gsoap_version} - STDSOAP2C=${top_srcdir}/examples/stdsoap2_`${gsoap_prefix}/bin/soapcpp2 -version 2>&1 | cut -d' ' -f4`c -else - WS_CFLAGS= - STDSOAP2C= -endif - -CC=gcc - -GSOAP_FILES_PREFIX:= bk_ws_ - -YACC=bison -y -CC=gcc - -VPATH=${top_srcdir}/src:${top_srcdir}/test:${top_srcdir}/examples:${top_srcdir}/project -AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3 - -TEST_LIBS:=-L${cppunit}/lib -lcppunit -TEST_INC:=-I${cppunit}/include - -SUFFIXES = .T - -DEBUG:=-g -O0 -Wall -# not yet -# -I${voms}/include \ -# -I${gacl}/include \ -# -I/usr/include/libxml2 \ - -# -DNO_VOMS -DNO_GACL to be removed when voms/gridsite are available -CFLAGS:= -DNO_VOMS -DNO_GACL \ - ${WS_CFLAGS} ${DEBUG} \ - -DVERSION=\"${version}\" \ - -I${stagedir}/include -I${top_srcdir}/src -I. \ - -I${expat_prefix}/include \ - -I${ares_prefix}/include \ - -I${gsoap_prefix}/include \ - ${COVERAGE_FLAGS} \ - -I${mysql_prefix}/include -I${mysql_prefix}/include/mysql \ - -I${globus_prefix}/include/${nothrflavour} \ - -I${gridsite_prefix}/include -I${globus_prefix}/include/${nothrflavour}/openssl \ - -D_GNU_SOURCE - - -TEST_LIBS:=-L${cppunit}/lib -lcppunit -TEST_INC:=-I${cppunit}/include - -LINK:=libtool --mode=link ${CC} ${LDFLAGS} -LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} -INSTALL:=libtool --mode=install install -LINKXX:=libtool --mode=link ${CXX} -rpath ${stagedir}/lib ${LDFLAGS} - -GLOBUS_LIBS:= -L${globus_prefix}/lib \ - -lglobus_common_${nothrflavour} \ - -lglobus_gssapi_gsi_${nothrflavour} \ - -ifneq (${mysql_prefix},/usr) - myslqlib := -L${mysql_prefix}/lib -endif - -ifneq (${expat_prefix},/usr) - expatlib := -L${expat_prefix}/lib -endif - -EXT_LIBS:= -L${ares_prefix}/lib -lares \ - ${myslqlib} -lmysqlclient -lz\ - ${expatlib} -lexpat \ - ${GLOBUS_LIBS} - -GSOAP_LIBS:= -L${gsoap_prefix}/lib -lgsoap - -SRVBONES_LIB:= -L${stagedir}/lib -lglite_lb_server_bones - -COMMON_LIB:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour} - -LB_PROXY_COMMON_LIB:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour} - -ifeq ($(GLITE_LB_SERVER_WITH_WS),yes) - SERVER_SOAP_OBJS:=${GSOAP_FILES_PREFIX}C.o ${GSOAP_FILES_PREFIX}Server.o \ - ws_plugin.o ws_query.o ws_fault.o ws_typeref.o - SERVER_WS_LIBS=${GSOAP_LIBS} -else - SERVER_SOAP_OBJS= - SERVER_WS_LIBS= -endif - -LB_PROXY_OBJS:= lbproxy.o il_lbproxy.o get_events.o index.o jobstat.o seqcode.o \ - jobstat_supp.o write2rgma.o lbs_db.o lb_html.o lb_http.o lb_proto.o \ - lb_xml_parse.o lb_xml_parse_V21.o \ - lock.o openserver.o query.o userjobs.o db_store.o request.o store.o \ - stored_master.o srv_purge.o server_state.o dump.o lb_authz.o load.o \ - notification.o il_notification.o notif_match.o - -SERVER_OBJS:= bkserverd.o il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o \ - seqcode.o write2rgma.o lbs_db.o lb_html.o lb_http.o lb_proto.o lb_xml_parse.o \ - lb_xml_parse_V21.o \ - lock.o openserver.o query.o userjobs.o db_store.o request.o store.o \ - stored_master.o srv_purge.o server_state.o dump.o lb_authz.o load.o \ - notification.o il_notification.o notif_match.o - -INDEX_OBJS:= index.o index_parse.o jobstat_supp.o lbs_db.o openserver.o \ - jobstat.o query.o lock.o get_events.o write2rgma.o index_lex.o \ - lb_authz.o store.o bkindex.o - -WS_CLIENT_OBJS:= stdsoap2_patched.o test_ws_plugin.o $(GSOAP_FILES_PREFIX)C.o $(GSOAP_FILES_PREFIX)Client.o ws_fault.o ws_typeref.o -WS_CLIENT_LIBS:= -L${stagedir}/lib -lglite_lb_client_${nothrflavour} - - -glite_lb_proxy: ${LB_PROXY_OBJS} - ${LINK} -o $@ ${LB_PROXY_OBJS} ${COMMON_LIB} ${SRVBONES_LIB} ${EXT_LIBS} - -glite_lb_bkserverd: ${SERVER_OBJS} ${SERVER_SOAP_OBJS} - ${LINK} -o $@ ${SERVER_OBJS} ${SERVER_SOAP_OBJS} ${COMMON_LIB} ${SRVBONES_LIB} ${EXT_LIBS} ${SERVER_WS_LIBS} - -glite_lb_bkindex: ${INDEX_OBJS} - ${LINK} -o $@ ${INDEX_OBJS} ${COMMON_LIB} ${EXT_LIBS} - -default all: compile - -compile: glite_lb_bkserverd glite_lb_bkindex glite_lb_proxy - -check: compile test.xml test.query - -echo check.query not complete yet - -test_coverage: - -mkdir coverage - cd coverage && $(MAKE) -f ../Makefile top_srcdir=../../ COVERAGE_FLAGS="-fprofile-arcs -ftest-coverage" check - cd coverage && for i in `echo ${INDEX_OBJS} ${SERVER_OBJS} | tr ' ' '\012' | sort -u`; do gcov $$i ; done - -lb_xml_parse.c: lb_xml_parse.c.T - rm -f $@ - ${AT3} $< >$@ || rm -f $@ - chmod -w $@ >/dev/null - -${GSOAP_FILES_PREFIX}H.h ${GSOAP_FILES_PREFIX}C.c ${GSOAP_FILES_PREFIX}Server.c ${GSOAP_FILES_PREFIX}Client.c ${GSOAP_FILES_PREFIX}ServerLib.c ${GSOAP_FILES_PREFIX}ClientLib.c LoggingAndBookkeeping.nsmap: LB.xh - ${gsoap_prefix}/bin/soapcpp2 -w -c -p ${GSOAP_FILES_PREFIX} LB.xh - -LB.xh: ws_typemap.dat - ${gsoap_prefix}/bin/wsdl2h -c -t ${top_srcdir}/src/ws_typemap.dat -o $@ ${stagedir}/interface/LB.wsdl - -test.xml: test_xml - ./test_xml - -test_xml: test_xml.cpp - ${CXX} -c ${CFLAGS} ${TEST_INC} $< - ${LINKXX} -o $@ test_xml.o lb_xml_parse.o ${COMMON_LIB} ${TEST_LIBS} ${EXT_LIBS} - -test.query: test_query_events - ./test_query_events - -query_events_objs:=`echo ${SERVER_OBJS} | sed 's/lbs_db\.o//;s/bkserverd\.o//'` - -test_query_events: test_query_events.o - ${LINKXX} -o $@ test_query_events.o ${query_events_objs} \ - ${TEST_LIBS} ${COMMON_LIB} ${EXT_LIBS} - -test.soapconv: test_soap_conv - ./test_soap_conv - -test_soap_conv: test_soap_conv.cpp ${WS_CLIENT_OBJS} - ${CXX} -c ${CFLAGS} ${TEST_INC} $< - ${LINKXX} -o $@ test_soap_conv.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS} ${COMMON_LIB} ${TEST_LIBS} - -examples: ws_getversion ws_jobstat ws_query_ex - -ws_getversion: ws_getversion.o ${WS_CLIENT_OBJS} - ${LINK} -o $@ ws_getversion.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS} ${EXT_LIBS} - -ws_jobstat: ws_jobstat.o ${WS_CLIENT_OBJS} - ${LINK} -o $@ ws_jobstat.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS} ${EXT_LIBS} - -ws_query_ex: ws_query_ex.o ${WS_CLIENT_OBJS} - ${LINK} -o $@ ws_query_ex.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS} ${EXT_LIBS} - -ws_query_ext: ws_query_ext.o ${WS_CLIENT_OBJS} - ${LINK} -o $@ ws_query_ext.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS} ${EXT_LIBS} - -stdsoap2_patched.o: - ${CC} ${CFLAGS} -c -o $@ ${STDSOAP2C} - -test_ws_plugin.o: ws_plugin.c - ${CC} ${CFLAGS} -DPLUGIN_TEST -c -o $@ ${top_srcdir}/src/ws_plugin.c - -doc: - -stage: compile - $(MAKE) install PREFIX=${stagedir} DOSTAGE=yes - -dist: distsrc distbin - -distsrc: - mkdir -p ${top_srcdir}/${package}-${version} - cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version} - cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version} - rm -rf ${top_srcdir}/${package}-${version} - -distbin: - $(MAKE) install PREFIX=`pwd`/tmpbuilddir${stagedir} - save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir - rm -rf tmpbuilddir - -install: - -mkdir -p ${PREFIX}/bin ${PREFIX}/etc ${PREFIX}/etc/init.d - -mkdir -p ${PREFIX}/share/doc/${package}-${version} - ${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} - for p in bkserverd bkindex; do \ - ${INSTALL} -m 755 "glite_lb_$$p" "${PREFIX}/bin/glite-lb-$$p"; \ - done - - for f in dbsetup.sql index.conf.template; do \ - ${INSTALL} -m 644 ${top_srcdir}/config/"glite-lb-$$f" ${PREFIX}/etc; \ - done - - ${INSTALL} -m 755 ${top_srcdir}/config/startup ${PREFIX}/etc/init.d/glite-lb-bkserverd - - if [ x${DOSTAGE} != xyes ]; then \ - ${INSTALL} -m 755 ${stagedir}/bin/glite-lb-notif-interlogd ${PREFIX}/bin; \ - fi - -clean: - -%.c: %.c.T - rm -f $@ - ${AT3} $< >$@ || rm -f $@ - chmod -w $@ >/dev/null - -%.o: %.y - ${YACC} -d ${YFLAGS} $< - mv y.tab.c $*.c - mv y.tab.h $*.h - ${CC} -c ${CFLAGS} $*.c - rm $*.c - -%.cpp: %.cpp.T - rm -f $@ - ${AT3} $< >$@ || rm -f $@ - chmod -w $@ >/dev/null - - -test_query_events.o: %.o: %.cpp - ${CXX} -c ${CFLAGS} ${GLOBUSINC} ${TEST_INC} $< - diff --git a/org.glite.lb.server/build.xml b/org.glite.lb.server/build.xml deleted file mode 100755 index 011bf74..0000000 --- a/org.glite.lb.server/build.xml +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.server/config/glite-lb-dbsetup.sql b/org.glite.lb.server/config/glite-lb-dbsetup.sql deleted file mode 100644 index af04974..0000000 --- a/org.glite.lb.server/config/glite-lb-dbsetup.sql +++ /dev/null @@ -1,112 +0,0 @@ -create table jobs ( - jobid char(32) binary not null, - dg_jobid varchar(255) binary not null, - userid char(32) binary not null, - aclid char(32) binary null, - - primary key (jobid), - unique (dg_jobid), - index (userid) -); - -create table users ( - userid char(32) binary not null, - cert_subj varchar(255) binary not null, - - primary key (userid), - unique (cert_subj) -); - -create table events ( - jobid char(32) binary not null, - event int not null, - code int not null, - prog varchar(255) binary not null, - host varchar(255) binary not null, - time_stamp datetime not null, - userid char(32) binary null, - usec int null, - level int null, - - arrived datetime not null, - - - primary key (jobid,event), - index (time_stamp), - index (host), - index (arrived) -); - -create table short_fields ( - jobid char(32) binary not null, - event int not null, - name varchar(200) binary not null, - value varchar(255) binary null, - - primary key (jobid,event,name) -); - -create table long_fields ( - jobid char(32) binary not null, - event int not null, - name varchar(200) binary not null, - value mediumblob null, - - primary key (jobid,event,name) -); - -create table states ( - jobid char(32) binary not null, - status int not null, - seq int not null, - int_status mediumblob not null, - version varchar(32) not null, - parent_job varchar(32) binary not null, - - primary key (jobid), - index (parent_job) - -); - -create table status_tags ( - jobid char(32) binary not null, - seq int not null, - name varchar(200) binary not null, - value varchar(255) binary null, - - primary key (jobid,seq,name) -); - -create table server_state ( - prefix varchar(100) not null, - name varchar(100) binary not null, - value varchar(255) binary not null, - - primary key (prefix,name) -); - -create table acls ( - aclid char(32) binary not null, - value mediumblob not null, - refcnt int not null, - - primary key (aclid) -); - -create table notif_registrations ( - notifid char(32) binary not null, - destination varchar(200) not null, - valid datetime not null, - userid char(32) binary not null, - conditions mediumblob not null, - - primary key (notifid) -); - -create table notif_jobs ( - notifid char(32) binary not null, - jobid char(32) binary not null, - - primary key (notifid,jobid), - index (jobid) -); diff --git a/org.glite.lb.server/config/glite-lb-index.conf.template b/org.glite.lb.server/config/glite-lb-index.conf.template deleted file mode 100644 index 594681b..0000000 --- a/org.glite.lb.server/config/glite-lb-index.conf.template +++ /dev/null @@ -1,7 +0,0 @@ -[ - JobIndices = { - [ type = "system"; name = "owner" ], - [ type = "system"; name = "location" ], - [ type = "system"; name = "destination" ] - } -] diff --git a/org.glite.lb.server/config/startup b/org.glite.lb.server/config/startup deleted file mode 100755 index 10b1a6d..0000000 --- a/org.glite.lb.server/config/startup +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/sh - -GLITE_LOCATION=${GLITE_LOCATION:-/opt/glite} -GLITE_LOCATION_VAR=${GLITE_LOCATION_VAR:-${GLITE_LOCATION}/var} - -[ -f /etc/glite.conf ] && . /etc/glite.conf -[ -f $GLITE_LOCATION/etc/glite-wms.conf ] && . $GLITE_LOCATION/etc/glite-wms.conf - -[ -f $GLITE_LOCATION/etc/lb.conf ] && . $GLITE_LOCATION/etc/lb.conf -[ -f $GLITE_LOCATION_VAR/etc/lb.conf ] && . $GLITE_LOCATION_VAR/etc/lb.conf - -[ -f $HOME/.glite.conf ] && . $HOME/.glite.conf - -[ -n "$GLITE_LB_SERVER_PIDFILE" ] && pidfile=$GLITE_LB_SERVER_PIDFILE || - pidfile=$GLITE_LOCATION_VAR/glite-lb-bkserverd.pid - -unset creds port - -start() -{ - if test -z "$GLITE_USER" ;then - echo 'Error: GLITE_USER is not set' - echo FAILED - return 1 - fi - - [ -n "$GLITE_HOST_CERT" -a -n "$GLITE_HOST_KEY" ] && - creds="-c $GLITE_HOST_CERT -k $GLITE_HOST_KEY" - - if test -z "$creds"; then - if su - $GLITE_USER -c "test -r /etc/grid-security/hostkey.pem -a -r /etc/grid-security/hostcert.pem"; then - echo "$0: WARNING: /etc/grid-security/hostkey.pem readable by $GLITE_USER" - creds="-c /etc/grid-security/hostcert.pem -k /etc/grid-security/hostkey.pem" - fi - fi - - - [ -z "$creds" ] && echo $0: WARNING: No credentials specified. Using default lookup which is dangerous. >&2 - - [ -n "$GLITE_LB_SERVER_PORT" ] && port="-p $GLITE_LB_SERVER_PORT" - - echo -n Starting glite-lb-bkserver ... - su - $GLITE_USER -c "$GLITE_LOCATION/bin/glite-lb-bkserverd \ - --notif-il-sock=/tmp/glite-lb-notif.sock \ - --notif-il-fprefix=/var/tmp/glite-lb-notif \ - $creds -i $pidfile $port" && echo " done" || echo " FAILED" - - echo -n Starting glite-lb-notif-interlogd ... - su - $GLITE_USER -c "$GLITE_LOCATION/bin/glite-lb-notif-interlogd \ - -f /var/tmp/glite-lb-notif -s /tmp/glite-lb-notif.sock \ - $creds" && echo " done" || echo " FAILED" -} - -stop() -{ - echo -n Stopping glite-lb-interlogd ... - killall glite-lb-notif-interlogd - echo done - if [ -f $pidfile ]; then - pid=`cat $pidfile` - kill $pid - echo -n Stopping glite-lb-bkserverd \($pid\) ... - try=0 - while ps p $pid >/dev/null 2>&1; do - sleep 1; - try=`expr $try + 1` - if [ $try = 20 ]; then - echo " giving up after $try retries" - return 1 - fi - done - echo " done" - rm -f $pidfile - else - echo $pidfile does not exist - glite-lb-bkserverd not running? >&2 - return 1 - fi -} - -status() -{ - if netstat -an --unix | grep "^unix .* LISTEN.* /tmp/glite-lb-notif.sock$" >/dev/null 2>&1 ;then - echo glite-lb-notif-interlogd running - else - echo glite-lb-notif-interlogd not running - return 1 - fi - - if [ -f $pidfile ]; then - pid=`cat $pidfile` - if ps p $pid >/dev/null 2>&1; then - echo glite-lb-bkserverd running as $pid - return 0 - fi - fi - - echo glite-lb-bkserverd not running - return 1 -} - -case x$1 in - xstart) start;; - xstop) stop;; - xrestart) stop; start;; - xstatus) status;; - x*) echo usage: $0 start,stop,restart,status >&2 - exit 1;; -esac diff --git a/org.glite.lb.server/examples/stdsoap2_2.6.0.c b/org.glite.lb.server/examples/stdsoap2_2.6.0.c deleted file mode 100644 index b4d6102..0000000 --- a/org.glite.lb.server/examples/stdsoap2_2.6.0.c +++ /dev/null @@ -1,10775 +0,0 @@ -/* - -stdsoap2.c[pp] 2.6.0 - -Runtime environment. - -gSOAP XML Web services tools -Copyright (C) 2000-2004, Robert van Engelen, Genivia, Inc. All Rights Reserved. - -Contributors: - -Wind River Systems, Inc., for the following additions (marked WR[...]): - - vxWorks compatible - - Support for IPv6. - --------------------------------------------------------------------------------- -gSOAP public license. - -The contents of this file are subject to the gSOAP Public License Version 1.3 -(the "License"); you may not use this file except in compliance with the -License. You may obtain a copy of the License at -http://www.cs.fsu.edu/~engelen/soaplicense.html -Software distributed under the License is distributed on an "AS IS" basis, -WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -for the specific language governing rights and limitations under the License. - -The Initial Developer of the Original Code is Robert A. van Engelen. -Copyright (C) 2000-2004 Robert A. van Engelen, Genivia inc. All Rights Reserved. --------------------------------------------------------------------------------- -GPL license. - -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 the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -Author contact information: -engelen@genivia.com / engelen@acm.org --------------------------------------------------------------------------------- - -Installation note: - -Win32 build needs winsock.dll (Visual C++ "wsock32.lib") -To do this in Visual C++ 6.0, go to "Project", "settings", select the "Link" -tab (the project file needs to be selected in the file view) and add -"wsock32.lib" to the "Object/library modules" entry - -*/ - -#include "stdsoap2.h" - -#ifdef __cplusplus -SOAP_SOURCE_STAMP("@(#) stdsoap2.cpp ver 2.6.0 2004-03-28 12:00:00 GMT") -extern "C" { -#else -SOAP_SOURCE_STAMP("@(#) stdsoap2.c ver 2.6.0 2004-03-28 12:00:00 GMT") -#endif - -/* EOF=-1 */ -#define LT (wchar)(-2) /* XML character '<' */ -#define TT (wchar)(-3) /* XML character '' */ -#define QT (wchar)(-5) /* XML character '"' */ -#define AP (wchar)(-6) /* XML character ''' */ - -#define soap_blank(c) ((c) >= 0 && (c) <= 32) -#define soap_notblank(c) ((c) > 32) -#define soap_hash_ptr(p) (((unsigned long)(p) >> 3) & (SOAP_PTRHASH - 1)) - -static int soap_isxdigit(int); -static wchar soap_char(struct soap*); -static wchar soap_getchunkchar(struct soap*); -static void soap_update_ptrs(struct soap*, char*, char*, long); -static int soap_has_copies(struct soap*, char*, char*); -static struct soap_ilist *soap_hlookup(struct soap*, const char*); -static void soap_init_iht(struct soap*); -static void soap_free_iht(struct soap*); -static void soap_init_pht(struct soap*); -static void soap_free_pht(struct soap*); -static int soap_set_error(struct soap*, const char*, const char*, const char*, int); -static int soap_copy_fault(struct soap*, const char*, const char*, const char*); -static int soap_getattrval(struct soap*, char*, size_t, wchar); -static void soap_set_local_namespaces(struct soap*); -static size_t soap_begin_dime(struct soap*); -static int soap_isnumeric(struct soap*, const char*); -static void *fplugin(struct soap*, const char*); - -#ifndef WITH_LEAN -static time_t soap_timegm(struct tm*); -static void soap_init_logs(struct soap*); -static void soap_close_logfile(struct soap*, int); -static void soap_set_logfile(struct soap*, int, const char*); -#endif - -#ifndef WITH_LEANER -static int soap_putdimefield(struct soap*, const char*, size_t); -static char *soap_getdimefield(struct soap*, size_t); -#endif - -#ifdef WITH_GZIP -static int soap_getgzipheader(struct soap*); -#endif - -#ifdef WITH_OPENSSL -static int ssl_auth_init(struct soap*); -static int ssl_verify_callback(int, X509_STORE_CTX*); -static int ssl_password(char*, int, int, void *); -/* This callback is included for future references. It should not be deleted -static DH *ssl_tmp_dh(SSL*, int, int); -*/ -#endif - -static const char *soap_strerror(struct soap*); -static const char *tcp_error(struct soap*); -static const char *http_error(struct soap*, int); -static int http_post(struct soap*, const char*, const char*, int, const char*, const char*, size_t); -static int http_get(struct soap*); -static int http_post_header(struct soap*, const char*, const char*); -static int http_response(struct soap*, int, size_t); -static int http_parse(struct soap*); -static int http_parse_header(struct soap*, const char*, const char*); -static int tcp_connect(struct soap*, const char*, const char*, int); -static int tcp_accept(struct soap*, int, struct sockaddr*, int*); -static int tcp_disconnect(struct soap*); -static int fsend(struct soap*, const char*, size_t); -static size_t frecv(struct soap*, char*, size_t); - -/* WR[ */ -#ifdef VXWORKS -static int vx_nonblocking = TRUE; /* ioctl argument */ -#endif -/* ]WR */ - -#ifndef PALM_2 -static const char soap_env1[42] = "http://schemas.xmlsoap.org/soap/envelope/"; -static const char soap_enc1[42] = "http://schemas.xmlsoap.org/soap/encoding/"; -static const char soap_env2[40] = "http://www.w3.org/2003/05/soap-envelope"; -static const char soap_enc2[40] = "http://www.w3.org/2003/05/soap-encoding"; -static const char soap_rpc[35] = "http://www.w3.org/2003/05/soap-rpc"; -#endif - -#ifndef PALM_1 -const struct soap_double_nan soap_double_nan = {0xFFFFFFFF, 0xFFFFFFFF}; -static const char soap_base64o[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char soap_base64i[81] = "\76XXX\77\64\65\66\67\70\71\72\73\74\75XXXXXXX\00\01\02\03\04\05\06\07\10\11\12\13\14\15\16\17\20\21\22\23\24\25\26\27\30\31XXXXXX\32\33\34\35\36\37\40\41\42\43\44\45\46\47\50\51\52\53\54\55\56\57\60\61\62\63"; -#endif - -static const char soap_padding[3] = "\0\0"; -#define SOAP_STR_PADDING (soap_padding) -#define SOAP_STR_EOS (soap_padding) - -#ifndef WITH_LEAN -static const struct soap_code_map html_entity_codes[] = /* entities for XHTML parsing */ -{ { 160, "nbsp" }, - { 161, "iexcl" }, - { 162, "cent" }, - { 163, "pound" }, - { 164, "curren" }, - { 165, "yen" }, - { 166, "brvbar" }, - { 167, "sect" }, - { 168, "uml" }, - { 169, "copy" }, - { 170, "ordf" }, - { 171, "laquo" }, - { 172, "not" }, - { 173, "shy" }, - { 174, "reg" }, - { 175, "macr" }, - { 176, "deg" }, - { 177, "plusmn" }, - { 178, "sup2" }, - { 179, "sup3" }, - { 180, "acute" }, - { 181, "micro" }, - { 182, "para" }, - { 183, "middot" }, - { 184, "cedil" }, - { 185, "sup1" }, - { 186, "ordm" }, - { 187, "raquo" }, - { 188, "frac14" }, - { 189, "frac12" }, - { 190, "frac34" }, - { 191, "iquest" }, - { 192, "Agrave" }, - { 193, "Aacute" }, - { 194, "Acirc" }, - { 195, "Atilde" }, - { 196, "Auml" }, - { 197, "Aring" }, - { 198, "AElig" }, - { 199, "Ccedil" }, - { 200, "Egrave" }, - { 201, "Eacute" }, - { 202, "Ecirc" }, - { 203, "Euml" }, - { 204, "Igrave" }, - { 205, "Iacute" }, - { 206, "Icirc" }, - { 207, "Iuml" }, - { 208, "ETH" }, - { 209, "Ntilde" }, - { 210, "Ograve" }, - { 211, "Oacute" }, - { 212, "Ocirc" }, - { 213, "Otilde" }, - { 214, "Ouml" }, - { 215, "times" }, - { 216, "Oslash" }, - { 217, "Ugrave" }, - { 218, "Uacute" }, - { 219, "Ucirc" }, - { 220, "Uuml" }, - { 221, "Yacute" }, - { 222, "THORN" }, - { 223, "szlig" }, - { 224, "agrave" }, - { 225, "aacute" }, - { 226, "acirc" }, - { 227, "atilde" }, - { 228, "auml" }, - { 229, "aring" }, - { 230, "aelig" }, - { 231, "ccedil" }, - { 232, "egrave" }, - { 233, "eacute" }, - { 234, "ecirc" }, - { 235, "euml" }, - { 236, "igrave" }, - { 237, "iacute" }, - { 238, "icirc" }, - { 239, "iuml" }, - { 240, "eth" }, - { 241, "ntilde" }, - { 242, "ograve" }, - { 243, "oacute" }, - { 244, "ocirc" }, - { 245, "otilde" }, - { 246, "ouml" }, - { 247, "divide" }, - { 248, "oslash" }, - { 249, "ugrave" }, - { 250, "uacute" }, - { 251, "ucirc" }, - { 252, "uuml" }, - { 253, "yacute" }, - { 254, "thorn" }, - { 255, "yuml" }, - { 0, NULL } -}; -#endif - -#ifndef WITH_LEAN -static const struct soap_code_map h_error_codes[] = -{ -#ifdef HOST_NOT_FOUND - { HOST_NOT_FOUND, "Host not found" }, -#endif -#ifdef TRY_AGAIN - { TRY_AGAIN, "Try Again" }, -#endif -#ifdef NO_RECOVERY - { NO_RECOVERY, "No Recovery" }, -#endif -#ifdef NO_DATA - { NO_DATA, "No Data" }, -#endif -#ifdef NO_ADDRESS - { NO_ADDRESS, "No Address" }, -#endif - { 0, NULL } -}; -#endif - -#ifndef WITH_LEAN -static const struct soap_code_map h_http_error_codes[] = -{ { 201, "Created" }, - { 202, "Accepted" }, - { 203, "Non-Authoritative Information" }, - { 204, "No Content" }, - { 205, "Reset Content" }, - { 206, "Partial Content" }, - { 300, "Multiple Choices" }, - { 301, "Moved Permanently" }, - { 302, "Found" }, - { 303, "See Other" }, - { 304, "Not Modified" }, - { 305, "Use Proxy" }, - { 307, "Temporary Redirect" }, - { 400, "Bad Request" }, - { 401, "Unauthorized" }, - { 402, "Payment Required" }, - { 403, "Forbidden" }, - { 404, "Not Found" }, - { 405, "Method Not Allowed" }, - { 406, "Not Acceptable" }, - { 407, "Proxy Authentication Required" }, - { 408, "Request Time-out" }, - { 409, "Conflict" }, - { 410, "Gone" }, - { 411, "Length Required" }, - { 412, "Precondition Failed" }, - { 413, "Request Entity Too Large" }, - { 414, "Request-URI Too Large" }, - { 415, "Unsupported Media Type" }, - { 416, "Requested range not satisfiable" }, - { 417, "Expectation Failed" }, - { 500, "Internal Server Error" }, - { 501, "Not Implemented" }, - { 502, "Bad Gateway" }, - { 503, "Service Unavailable" }, - { 504, "Gateway Time-out" }, - { 505, "HTTP Version not supported" }, - { 0, NULL } -}; -#endif - -#ifdef WITH_OPENSSL -static const struct soap_code_map h_ssl_error_codes[] = -{ -#define _SSL_ERROR(e) { e, #e } - _SSL_ERROR(SSL_ERROR_SSL), - _SSL_ERROR(SSL_ERROR_ZERO_RETURN), - _SSL_ERROR(SSL_ERROR_WANT_READ), - _SSL_ERROR(SSL_ERROR_WANT_WRITE), - _SSL_ERROR(SSL_ERROR_WANT_CONNECT), - _SSL_ERROR(SSL_ERROR_WANT_X509_LOOKUP), - _SSL_ERROR(SSL_ERROR_SYSCALL), - { 0, NULL } -}; -#endif - -#ifdef WIN32 -static int tcp_done = 0; -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -fsend(struct soap *soap, const char *s, size_t n) -{ register int nwritten; -#if defined(__cplusplus) && !defined(UNDER_CE) - if (soap->os) - { soap->os->write(s, n); - if (soap->os->good()) - return SOAP_OK; - return SOAP_EOF; - } -#endif - while (n) - { if (soap_valid_socket(soap->socket)) - { -#ifndef WITH_LEAN - if (soap->send_timeout) - { struct timeval timeout; - fd_set fd; - if (soap->send_timeout > 0) - { timeout.tv_sec = soap->send_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->send_timeout/1000000; - timeout.tv_usec = -soap->send_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - for (;;) - { register int r = select((SOAP_SOCKET)(soap->socket + 1), NULL, &fd, &fd, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - return SOAP_EOF; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - } - } -#endif -#ifdef WITH_OPENSSL - if (soap->ssl) - nwritten = SSL_write(soap->ssl, s, n); - else -#endif -#ifndef PALM - nwritten = send((SOAP_SOCKET)soap->socket, s, n, soap->socket_flags); -#else - nwritten = send((SOAP_SOCKET)soap->socket, (void*)s, n, soap->socket_flags); -#endif - if (nwritten <= 0) - { -#ifdef WITH_OPENSSL - int err; - if (soap->ssl && (err = SSL_get_error(soap->ssl, nwritten)) != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - return SOAP_EOF; -#endif - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EWOULDBLOCK && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - nwritten = 0; /* and call write() again */ - } - } - else - { -#ifdef WITH_FASTCGI - nwritten = fwrite((void*)s, 1, n, stdout); - fflush(stdout); -#else -#ifdef UNDER_CE - nwritten = fwrite(s, 1, n, soap->sendfd); -#else -/* WR[ */ -#ifdef VXWORKS -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - { - httpBlockPut(soap->rpmreqid, s, n); - nwritten = n; - } - else - { - nwritten = fwrite(s, sizeof(char), n, fdopen(soap->sendfd, "w")); - } -#else - nwritten = fwrite(s, sizeof(char), n, fdopen(soap->sendfd, "w")); -#endif /* WMW_RPM_IO */ -#else -/* ]WR */ - nwritten = write((SOAP_SOCKET)soap->sendfd, s, n); -/* WR[ */ -#endif -/* ]WR */ -#endif -#endif - if (nwritten <= 0) - { if (soap_errno != SOAP_EINTR && soap_errno != SOAP_EWOULDBLOCK && soap_errno != SOAP_EAGAIN) - { soap->errnum = soap_errno; - return SOAP_EOF; - } - nwritten = 0; /* and call write() again */ - } - } - n -= nwritten; - s += nwritten; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_flush_raw(struct soap *soap, const char *s, size_t n) -{ -#ifndef WITH_LEAN - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - { char *t; - if (!(t = (char*)soap_push_block(soap, n))) - return soap->error = SOAP_EOM; - memcpy(t, s, n); - return SOAP_OK; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { char t[16]; - sprintf(t, "\r\n%lX\r\n" + (soap->chunksize ? 0 : 2), (unsigned long)n); - DBGMSG(SENT, t, strlen(t)); - if ((soap->error = soap->fsend(soap, t, strlen(t)))) - return soap->error; - soap->chunksize += n; - } -#endif - DBGMSG(SENT, s, n); - return soap->error = soap->fsend(soap, s, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_flush(struct soap *soap) -{ if (soap->bufidx) - { -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { soap->d_stream.next_in = (Byte*)soap->buf; - soap->d_stream.avail_in = (unsigned int)soap->bufidx; -#ifdef WITH_GZIP - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->bufidx); -#endif - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating %u bytes\n", soap->d_stream.avail_in)); - if (deflate(&soap->d_stream, Z_NO_FLUSH) != Z_OK) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to deflate: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - return soap->error = SOAP_ZLIB_ERROR; - } - if (!soap->d_stream.avail_out) - { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN)) - return soap->error; - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - } - } while (soap->d_stream.avail_in); - } - else -#endif - if (soap_flush_raw(soap, soap->buf, soap->bufidx)) - return soap->error; - soap->bufidx = 0; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send_raw(struct soap *soap, const char *s, size_t n) -{ if (!n) - return SOAP_OK; - if (soap->mode & SOAP_IO_LENGTH) - { soap->count += n; - if (soap->fprepare) - return soap->fprepare(soap, s, n); - return SOAP_OK; - } - if (soap->mode & SOAP_IO) - { register size_t i = SOAP_BUFLEN - soap->bufidx; - while (n >= i) - { memcpy(soap->buf + soap->bufidx, s, i); - soap->bufidx = SOAP_BUFLEN; - if (soap_flush(soap)) - return soap->error; - s += i; - n -= i; - i = SOAP_BUFLEN; - } - memcpy(soap->buf + soap->bufidx, s, n); - soap->bufidx += n; - return SOAP_OK; - } - return soap_flush_raw(soap, s, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send(struct soap *soap, const char *s) -{ if (s) - return soap_send_raw(soap, s, strlen(s)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static size_t -frecv(struct soap *soap, char *s, size_t n) -{ register int r; - soap->errnum = 0; -#if defined(__cplusplus) && !defined(UNDER_CE) - if (soap->is) - { if (soap->is->good()) - return soap->is->read(s, n).gcount(); - return 0; - } -#endif - if (soap_valid_socket(soap->socket)) - { for (;;) - { -#ifndef WITH_LEAN - struct timeval timeout; - fd_set fd; - if (soap->recv_timeout) - { if (soap->recv_timeout > 0) - { timeout.tv_sec = soap->recv_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->recv_timeout/1000000; - timeout.tv_usec = -soap->recv_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - for (;;) - { r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r > 0) - break; - if (r == 0) - return 0; - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return 0; - } - } - } -#endif -#ifdef WITH_OPENSSL - if (soap->ssl) - { int err; - r = SSL_read(soap->ssl, s, n); - if ((err = SSL_get_error(soap->ssl, r)) == SSL_ERROR_NONE) - return (size_t)r; - if (err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - return 0; - } - else -#endif - { r = recv((SOAP_SOCKET)soap->socket, s, n, soap->socket_flags); - if (r >= 0) - return (size_t)r; - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - return 0; - } - } -#ifndef WITH_LEAN - { struct timeval timeout; - fd_set fd; - timeout.tv_sec = 0; - timeout.tv_usec = 10000; - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r < 0 && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return 0; - } - } -#endif - } - } -#ifdef WITH_FASTCGI - return fread(s, 1, n, stdin); -#else -#ifdef UNDER_CE - return fread(s, 1, n, soap->recvfd); -#else -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - { - r = httpBlockRead(soap->rpmreqid, s, n); - } - else - { - r = read(soap->recvfd, s, n); - } - if (r >= 0) - { - return r; - } - return 0; -#else -/* ]WR */ - r = read((SOAP_SOCKET)soap->recvfd, s, n); - if (r >= 0) - return (size_t)r; - soap->errnum = soap_errno; - return 0; -/* WR[ */ -#endif -/* ]WR */ -#endif -#endif -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static wchar -soap_getchunkchar(struct soap *soap) -{ if (soap->bufidx < soap->buflen) - return soap->buf[soap->bufidx++]; - soap->bufidx = 0; - soap->buflen = soap->chunkbuflen = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)soap->buflen)); - DBGMSG(RECV, soap->buf, soap->buflen); - if (soap->buflen) - return soap->buf[soap->bufidx++]; - return EOF; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_isxdigit(int c) -{ switch (c) - { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - return 1; - } - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_raw(struct soap *soap) -{ register size_t ret; -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { if (soap->d_stream.next_out == Z_NULL) - return EOF; - if (soap->d_stream.avail_in || !soap->d_stream.avail_out) - { register int r; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflating\n")); - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - r = inflate(&soap->d_stream, Z_NO_FLUSH); - if (r == Z_OK || r == Z_STREAM_END) - { soap->bufidx = 0; - soap->buflen = SOAP_BUFLEN - soap->d_stream.avail_out; - if (soap->zlib_in == SOAP_ZLIB_GZIP) - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->buflen); - if (r == Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_in = (float)soap->d_stream.total_in / (float)soap->d_stream.total_out; - soap->d_stream.next_out = Z_NULL; - } - if (soap->buflen) - { soap->count += soap->buflen; - return SOAP_OK; - } - } - else if (r != Z_BUF_ERROR) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate error: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - soap->d_stream.next_out = Z_NULL; - return EOF; - } - } -zlib_again: - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK && !soap->chunksize) - { memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN); - soap->buflen = soap->z_buflen; - } - } -#endif - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) /* read HTTP chunked transfer */ - { -chunk_again: - if (soap->chunksize) - { soap->buflen = ret = soap->frecv(soap, soap->buf, soap->chunksize > SOAP_BUFLEN ? SOAP_BUFLEN : soap->chunksize); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk: read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - soap->bufidx = 0; - soap->chunksize -= ret; - } - else - { register wchar c; - char tmp[8], *t; - t = tmp; - if (!soap->chunkbuflen) - { soap->chunkbuflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - soap->bufidx = 0; - if (!ret) - return EOF; - } - else - soap->bufidx = soap->buflen; - soap->buflen = soap->chunkbuflen; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk size (%u %u)\n", (unsigned int)soap->bufidx, (unsigned int)soap->buflen)); - while (!soap_isxdigit((int)(c = soap_getchunkchar(soap)))) - if ((int)c == EOF) - return EOF; - do - *t++ = (char)c; - while (soap_isxdigit((int)(c = soap_getchunkchar(soap))) && t - tmp < 7); - while ((int)c != EOF && c != '\n') - c = soap_getchunkchar(soap); - if ((int)c == EOF) - return EOF; - *t = '\0'; - soap->chunksize = soap_strtoul(tmp, &t, 16); - if (!soap->chunksize) - { soap->chunkbuflen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of chunked message\n")); - while ((int)c != EOF && c != '\n') - c = soap_getchunkchar(soap); - return EOF; - } - soap->buflen = soap->bufidx + soap->chunksize; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving buf len to %u (%u %s)\n", (unsigned int)soap->buflen, (unsigned int)soap->bufidx, tmp)); - if (soap->buflen > soap->chunkbuflen) - { soap->buflen = soap->chunkbuflen; - soap->chunksize -= soap->buflen - soap->bufidx; - soap->chunkbuflen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Passed end of buffer for chunked HTTP (%lu bytes left)\n", (unsigned long)(soap->buflen - soap->bufidx))); - } - else if (soap->chunkbuflen) - soap->chunksize = 0; - ret = soap->buflen - soap->bufidx; - if (!ret) - goto chunk_again; - } - } - else - { soap->bufidx = 0; - soap->buflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - } -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { int r; - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = (unsigned int)ret; - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - r = inflate(&soap->d_stream, Z_NO_FLUSH); - if (r == Z_OK || r == Z_STREAM_END) - { soap->bufidx = 0; - soap->z_buflen = soap->buflen; - soap->buflen = ret = SOAP_BUFLEN - soap->d_stream.avail_out; - if (soap->zlib_in == SOAP_ZLIB_GZIP) - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->buflen); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %u bytes\n", (unsigned int)ret)); - if (!ret) - goto zlib_again; - if (r == Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_in = (float)soap->d_stream.total_in / (float)soap->d_stream.total_out; - soap->d_stream.next_out = Z_NULL; - } - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to inflate: (%d) %s\n", r, soap->d_stream.msg?soap->d_stream.msg:"")); - soap->d_stream.next_out = Z_NULL; - return EOF; - } - } -#endif - soap->count += ret; - return !ret; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv(struct soap *soap) -{ -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - { if (soap->dime_buflen) - { char *s; - int i; - unsigned char tmp[12]; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME hdr for chunked DIME is in buffer\n")); - soap->count += soap->dime_buflen - soap->buflen; - soap->buflen = soap->dime_buflen; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Skip padding (%ld bytes)\n", -(long)soap->dime_size&3)); - for (i = -(long)soap->dime_size&3; i > 0; i--) - { soap->bufidx++; - if (soap->bufidx >= soap->buflen) - if (soap_recv_raw(soap)) - return EOF; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME hdr for next chunk\n")); - s = (char*)tmp; - for (i = 12; i > 0; i--) - { *s++ = soap->buf[soap->bufidx++]; - if (soap->bufidx >= soap->buflen) - if (soap_recv_raw(soap)) - return EOF; - } - soap->dime_flags = tmp[0] & 0x7; - soap->dime_size = ((size_t)tmp[8] << 24) | ((size_t)tmp[9] << 16) | ((size_t)tmp[10] << 8) | ((size_t)tmp[11]); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME chunk (%u bytes)\n", (unsigned int)soap->dime_size)); - if (soap->dime_flags & SOAP_DIME_CF) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "More chunking\n")); - soap->dime_chunksize = soap->dime_size; - if (soap->buflen - soap->bufidx >= soap->dime_size) - { soap->dime_buflen = soap->buflen; - soap->buflen = soap->bufidx + soap->dime_chunksize; - } - else - soap->dime_chunksize -= soap->buflen - soap->bufidx; - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Last chunk\n")); - soap->dime_buflen = 0; - soap->dime_chunksize = 0; - } - soap->count = soap->buflen - soap->bufidx; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%u bytes remaining\n", (unsigned int)soap->count)); - return SOAP_OK; - } - if (soap->dime_chunksize) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get next DIME hdr for chunked DIME (%u bytes chunk)\n", (unsigned int)soap->dime_chunksize)); - if (soap_recv_raw(soap)) - return EOF; - if (soap->buflen - soap->bufidx >= soap->dime_chunksize) - { soap->dime_buflen = soap->buflen; - soap->count -= soap->buflen - soap->bufidx - soap->dime_chunksize; - soap->buflen = soap->bufidx + soap->dime_chunksize; - } - else - soap->dime_chunksize -= soap->buflen - soap->bufidx; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%lu bytes remaining, count=%u\n", (unsigned long)(soap->buflen-soap->bufidx), (unsigned int)soap->count)); - return SOAP_OK; - } - } -#endif - return soap_recv_raw(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -wchar -SOAP_FMAC2 -soap_getchar(struct soap *soap) -{ register wchar c; - if (soap->ahead) - { c = soap->ahead; - soap->ahead = 0; - return c; - } - return soap_get1(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const struct soap_code_map* -SOAP_FMAC2 -soap_code(const struct soap_code_map *map, const char *str) -{ while (map->string) - { if (!strcmp(str, map->string)) - return map; - map++; - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_int_code(const struct soap_code_map *map, const char *str, long other) -{ while (map->string) - { if (!strcmp(str, map->string)) - return map->code; - map++; - } - return other; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_str_code(const struct soap_code_map *map, long code) -{ while (map->code != code && map->string) - map++; - return map->string; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static wchar -soap_char(struct soap *soap) -{ char tmp[8]; - register int i; - register wchar c; - register char *s = tmp; - for (i = 0; i < 7; i++) - { c = soap_get1(soap); - if (c == ';' || (int)c == EOF) - break; - *s++ = (char)c; - } - *s = '\0'; - if (*tmp == '#') - { if (tmp[1] == 'x' || tmp[1] == 'X') - return soap_strtol(tmp + 2, NULL, 16); - return atol(tmp + 1); - } - if (!strcmp(tmp, "lt")) - return '<'; - if (!strcmp(tmp, "gt")) - return '>'; - if (!strcmp(tmp, "amp")) - return '&'; - if (!strcmp(tmp, "quot")) - return '"'; - if (!strcmp(tmp, "apos")) - return '\''; -#ifndef WITH_LEAN - return (wchar)soap_int_code(html_entity_codes, tmp, 127); -#else - return 127; /* use this to represent unknown code */ -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -wchar -SOAP_FMAC2 -soap_get(struct soap *soap) -{ register wchar c; - c = soap->ahead; - if (c) - soap->ahead = 0; - else - c = soap_get1(soap); - for (;;) - { if (soap->cdata) - { if (c == ']') - { c = soap_get1(soap); - if (c == ']') - { soap->cdata = 0; - soap_get1(soap); /* skip > */ - c = soap_get1(soap); - } - else - { soap_revget1(soap); - return ']'; - } - } - else - return c; - } - switch (c) - { case '<': - do c = soap_get1(soap); - while (soap_blank(c)); - if (c == '!' || c == '?' || c == '%') - { if (c == '!') - { c = soap_get1(soap); - if (c == '[') - { do c = soap_get1(soap); - while ((int)c != EOF && c != '['); - if ((int)c == EOF) - break; - soap->cdata = 1; - c = soap_get1(soap); - continue; - } - if (c == '-' && (c = soap_get1(soap)) == '-') - { do - { c = soap_get1(soap); - if (c == '-' && (c = soap_get1(soap)) == '-') - break; - } while ((int)c != EOF); - } - } - while ((int)c != EOF && c != '>') - c = soap_get1(soap); - if ((int)c == EOF) - break; - c = soap_get1(soap); - continue; - } - if (c == '/') - return TT; - soap_revget1(soap); - return LT; - case '>': - return GT; - case '"': - return QT; - case '\'': - return AP; - case '&': - return soap_char(soap) | 0x80000000; - } - break; - } - return c; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -wchar -SOAP_FMAC2 -soap_advance(struct soap *soap) -{ register wchar c; - while ((int)((c = soap_get(soap)) != EOF) && c != LT && c != TT) - ; - return c; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -wchar -SOAP_FMAC2 -soap_skip(struct soap *soap) -{ register wchar c; - do c = soap_get(soap); - while (soap_blank(c)); - return c; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_move(struct soap *soap, long n) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving %ld bytes forward\n", (long)n)); - for (; n > 0; n--) - if ((int)soap_getchar(soap) == EOF) - return SOAP_EOF; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_tell(struct soap *soap) -{ return soap->count - soap->buflen + soap->bufidx - (soap->ahead != 0); -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pututf8(struct soap *soap, register unsigned long c) -{ char tmp[16]; - if (c > 0 && c < 0x80) - { *tmp = (char)c; - return soap_send_raw(soap, tmp, 1); - } -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { register char *t = tmp; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - *t = '\0'; - } - else -#endif - sprintf(tmp, "&#%lu;", c); - return soap_send(soap, tmp); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -wchar -SOAP_FMAC2 -soap_getutf8(struct soap *soap) -{ register wchar c, c1, c2, c3, c4; - c = soap_get(soap); - if (c < 0x80) - return c; - c1 = soap_get(soap); - if (c1 < 0x80) - { soap_unget(soap, c1); - return c; - } - c1 &= 0x3F; - if (c < 0xE0) - return ((wchar)(c & 0x1F) << 6) | c1; - c2 = (wchar)soap_get1(soap) & 0x3F; - if (c < 0xF0) - return ((wchar)(c & 0x0F) << 12) | (c1 << 6) | c2; - c3 = (wchar)soap_get1(soap) & 0x3F; - if (c < 0xF8) - return ((wchar)(c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3; - c4 = (wchar)soap_get1(soap) & 0x3F; - if (c < 0xFC) - return ((wchar)(c & 0x03) << 24) | (c1 << 18) | (c2 << 12) | (c3 << 6) | c4; - return ((wchar)(c & 0x01) << 30) | (c1 << 24) | (c2 << 18) | (c3 << 12) | (c4 << 6) | (wchar)(soap_get1(soap) & 0x3F); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_puthex(struct soap *soap, const unsigned char *s, int n) -{ /* TODO: serialize to DOM (as an option) using new soap_s2hex() */ - char d[2]; - register int i; - for (i = 0; i < n; i++) - { register int m = *s++; - d[0] = (char)((m >> 4) + (m > 159 ? '7' : '0')); - m &= 0x0F; - d[1] = (char)(m + (m > 9 ? '7' : '0')); - if (soap_send_raw(soap, d, 2)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -unsigned char* -SOAP_FMAC2 -soap_gethex(struct soap *soap, int *n) -{ register wchar c; - if (soap_new_block(soap)) - return NULL; - for (;;) - { register int i; - register char *s = (char*)soap_push_block(soap, SOAP_BLKLEN); - if (!s) - { soap_end_block(soap); - if (n) - *n = 0; - return NULL; - } - for (i = 0; i < SOAP_BLKLEN; i++) - { register char d1, d2; - c = soap_get(soap); - if (soap_isxdigit(c)) - { d1 = (char)c; - c = soap_get(soap); - if (soap_isxdigit(c)) - d2 = (char)c; - else - { soap_end_block(soap); - soap->error = SOAP_TYPE; - if (n) - *n = 0; - return NULL; - } - } - else - { unsigned char *p; - soap_unget(soap, c); - if (n) - *n = (int)soap_size_block(soap, i); - p = (unsigned char*)soap_save_block(soap, NULL); - return p; - } - *s++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0'); - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putbase64(struct soap *soap, const unsigned char *s, int n) -{ register int i; - register unsigned long m; - char d[4]; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->data = (char*)soap_malloc(soap, (n + 2) / 3 * 4 + 1); - return soap_s2base64(soap, s, soap->dom->data, n); - } -#endif - if (!s) - return SOAP_OK; - for (; n > 2; n -= 3, s += 3) - { m = ((unsigned long)((unsigned char*)s)[0] << 16) | ((unsigned long)((unsigned char*)s)[1] << 8) | (unsigned long)((unsigned char*)s)[2]; - for (i = 4; i > 0; m >>= 6) - d[--i] = soap_base64o[m & 0x3F]; - if (soap_send_raw(soap, d, 4)) - return soap->error; - } - if (n > 0) - { m = 0; - for (i = 0; i < n; i++) - m = (m << 8) | *s++; - for (; i < 3; i++) - m <<= 8; - for (i++; i > 0; m >>= 6) - d[--i] = soap_base64o[m & 0x3F]; - for (i = 3; i > n; i--) - d[i] = '='; - if (soap_send_raw(soap, d, 4)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -unsigned char* -SOAP_FMAC2 -soap_getbase64(struct soap *soap, int *n, int malloc_flag) -{ register wchar c; - if (soap_new_block(soap)) - return NULL; - for (;;) - { register int i; - register char *s = (char*)soap_push_block(soap, 3*SOAP_BLKLEN); /* must be multiple of 3 */ - if (!s) - { soap_end_block(soap); - if (n) - *n = 0; - return NULL; - } - for (i = 0; i < SOAP_BLKLEN; i++) - { register unsigned long m = 0; - register int j = 0; - while (j < 4) - { c = soap_get(soap); - if (c == '=' || c < 0) - { unsigned char *p; - i *= 3; - switch (j) - { case 2: - *s++ = (char)((m >> 4) & 0xFF); - i++; - break; - case 3: - *s++ = (char)((m >> 10) & 0xFF); - *s++ = (char)((m >> 2) & 0xFF); - i += 2; - } - if (n) - *n = (int)soap_size_block(soap, i); - p = (unsigned char*)soap_save_block(soap, NULL); - if (c >= 0) - { while ((int)((c = soap_get(soap)) != EOF) && c != LT && c != TT) - ; - } - soap_unget(soap, c); - return p; - } - c -= '+'; - if (c >= 0 && c <= 79) - { m = (m << 6) + soap_base64i[c]; - j++; - } - } - *s++ = (char)((m >> 16) & 0xFF); - *s++ = (char)((m >> 8) & 0xFF); - *s++ = (char)(m & 0xFF); - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_strdup(struct soap *soap, const char *s) -{ char *t = NULL; - if (s && (t = (char*)soap_malloc(soap, strlen(s) + 1))) - strcpy(t, s); - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_new_block(struct soap *soap) -{ struct soap_blist *p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New block sequence (prev=%p)\n", soap->blist)); - if (!(p = (struct soap_blist*)SOAP_MALLOC(sizeof(struct soap_blist)))) - return SOAP_EOM; - p->next = soap->blist; - p->ptr = NULL; - p->size = 0; - soap->blist = p; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_push_block(struct soap *soap, size_t n) -{ char *p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push block of %u bytes (%u bytes total)\n", (unsigned int)n, (unsigned int)soap->blist->size)); - if (!(p = (char*)SOAP_MALLOC(n + sizeof(char*) + sizeof(size_t)))) - { soap->error = SOAP_EOM; - return NULL; - } - *(char**)p = soap->blist->ptr; - *(size_t*)(p + sizeof(char*)) = n; - soap->blist->ptr = p; - soap->blist->size += n; - return p + sizeof(char*) + sizeof(size_t); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_pop_block(struct soap *soap) -{ char *p; - if (!soap->blist->ptr) - return; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pop block\n")); - p = soap->blist->ptr; - soap->blist->size -= *(size_t*)(p + sizeof(char*)); - soap->blist->ptr = *(char**)p; - SOAP_FREE(p); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_update_ptrs(struct soap *soap, char *start, char *end, long offset) -{ int i; - register struct soap_ilist *ip; - register void *p, **q; - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr && (char*)ip->ptr >= start && (char*)ip->ptr < end) - ip->ptr = (char*)ip->ptr + offset; - for (q = &ip->link; q; q = (void**)p) - { p = *q; - if (p && (char*)p >= start && (char*)p < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Link update id='%s' %p\n", ip->id, p)); - *q = (char*)p + offset; - } - } - for (q = &ip->copy; q; q = (void**)p) - { p = *q; - if (p && (char*)p >= start && (char*)p < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy update id='%s' %p\n", ip->id, p)); - *q = (char*)p + offset; - } - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_has_copies(struct soap *soap, register char *start, register char *end) -{ int i; - register struct soap_ilist *ip; - register char *p; - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - for (p = (char*)ip->copy; p; p = *(char**)p) - if (p >= start && p < end) - return SOAP_ERR; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_resolve(struct soap *soap) -{ int i, flag1 = 0, flag2; - register struct soap_ilist *ip; - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr) - soap_resolve_ptr(ip); - else if (*ip->id == '#') - flag1 = 1; - } - do - { flag2 = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data\n")); - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - if (ip->copy && ip->ptr && ip->size) - if (!soap_has_copies(soap, (char*)ip->ptr, (char*)ip->ptr + ip->size)) - { register void *p, **q = (void**)ip->copy; - DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing copy chain to resolve id='%s'\n", ip->id)); - ip->copy = NULL; - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... copy %p -> %p (%u bytes)\n", ip->ptr, q, (unsigned int)ip->size)); - p = *q; - memcpy(q, ip->ptr, ip->size); - q = (void**)p; - } while (q); - flag2 = 1; - } - } while (flag2); - if (flag1) - return soap->error = SOAP_MISSING_ID; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_resolve_ptr(struct soap_ilist *ip) -{ register void *p, **q, *r; - q = (void**)ip->link; - ip->link = NULL; - r = ip->ptr; - while (q) - { p = *q; - *q = r; - q = (void**)p; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_size_block(struct soap *soap, size_t n) -{ if (soap->blist->ptr) - { soap->blist->size -= *(size_t*)(soap->blist->ptr + sizeof(char*)) - n; - *(size_t*)(soap->blist->ptr + sizeof(char*)) = n; - } - return soap->blist->size; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_first_block(struct soap *soap) -{ char *p, *q, *r; - p = soap->blist->ptr; - if (!p) - return NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "First block\n")); - r = NULL; - do - { q = *(char**)p; - *(char**)p = r; - r = p; - p = q; - } while (p); - soap->blist->ptr = r; - return r + sizeof(char*) + sizeof(size_t); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_next_block(struct soap *soap) -{ char *p; - p = soap->blist->ptr; - if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Next block\n")); - soap->blist->ptr = *(char**)p; - SOAP_FREE(p); - if (soap->blist->ptr) - return soap->blist->ptr + sizeof(char*) + sizeof(size_t); - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_block_size(struct soap *soap) -{ return *(size_t*)(soap->blist->ptr + sizeof(char*)); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_end_block(struct soap *soap) -{ struct soap_blist *bp; - char *p, *q; - bp = soap->blist; - if (bp) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of block sequence, free all remaining blocks\n")); - for (p = bp->ptr; p; p = q) - { q = *(char**)p; - SOAP_FREE(p); - } - soap->blist = bp->next; - SOAP_FREE(bp); - } - DBGLOG(TEST, if (soap->blist) SOAP_MESSAGE(fdebug, "Restore previous block sequence\n")); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_save_block(struct soap *soap, char *p) -{ register size_t n; - register char *q, *s; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Save all blocks in contiguous memory space of %u bytes (%p->%p)\n", (unsigned int)soap->blist->size, soap->blist->ptr, p)); - if (soap->blist->size) - { if (!p) - p = (char*)soap_malloc(soap, soap->blist->size); - if (p) - for (s = p, q = soap_first_block(soap); q; q = soap_next_block(soap)) - { n = soap_block_size(soap); - soap_update_ptrs(soap, q, q + n, (long)s - (long)q); /* pointers s and q may or may not be related */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy %u bytes from %p to %p\n", (unsigned int)n, q, s)); - memcpy(s, q, n); - s += n; - } - else - soap->error = SOAP_EOM; - } - soap_end_block(soap); - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_store_block(struct soap *soap, char *p) -{ p = soap_save_block(soap, p); - if (!soap->blist) - { struct soap_ilist *ip; - int i; - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - if (ip->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolve link chain to point to %p\n", ip->ptr)); - soap_resolve_ptr(ip); - } - } - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsize(struct soap *soap, const char *type, int size) -{ return soap_putsizes(soap, type, &size, 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsizes(struct soap *soap, const char *type, const int *size, int dim) -{ return soap_putsizesoffsets(soap, type, size, NULL, dim); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsizesoffsets(struct soap *soap, const char *type, const int *size, const int *offset, int dim) -{ int i; - if (!type) - return NULL; - if (soap->version == 2) - { sprintf(soap->type, "%s[%d", type, size[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), " %d", size[i]); - } - else - { if (offset) - { sprintf(soap->type, "%s[%d", type, size[0] + offset[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), ",%d", size[i] + offset[i]); - } - else - { sprintf(soap->type, "%s[%d", type, size[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), ",%d", size[i]); - } - strcat(soap->type, "]"); - } - return soap->type; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putoffset(struct soap *soap, int offset) -{ return soap_putoffsets(soap, &offset, 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putoffsets(struct soap *soap, const int *offset, int dim) -{ register int i; - sprintf(soap->arrayOffset, "[%d", offset[0]); - for (i = 1; i < dim; i++) - sprintf(soap->arrayOffset + strlen(soap->arrayOffset), ",%d", offset[i]); - strcat(soap->arrayOffset, "]"); - return soap->arrayOffset; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_size(const int *size, int dim) -{ register int i, n = size[0]; - for (i = 1; i < dim; i++) - n *= size[i]; - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getoffsets(const char *attr, const int *size, int *offset, int dim) -{ register int i, j = 0; - if (offset) - for (i = 0; i < dim && attr && *attr; i++) - { attr++; - j *= size[i]; - j += offset[i] = (int)atol(attr); - attr = strchr(attr, ','); - } - else - for (i = 0; i < dim && attr && *attr; i++) - { attr++; - j *= size[i]; - j += (int)atol(attr); - attr = strchr(attr, ','); - } - return j; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getsize(const char *attr1, const char *attr2, int *j) -{ register int n, k; - char *s; - *j = 0; - if (!*attr1) - return -1; - n = 1; - do - { attr1++; - k = (int)soap_strtol(attr1, &s, 10); - n *= k; - if (k < 0 || n > SOAP_MAXARRAYSIZE || s == attr1) - return -1; - attr1 = strchr(s, ','); - if (!attr1) - attr1 = strchr(s, ' '); - if (attr2 && *attr2) - { attr2++; - *j *= k; - k = (int)soap_strtol(attr2, &s, 10); - *j += k; - if (k < 0) - return -1; - attr2 = s; - } - } while (attr1 && *attr1 != ']'); - return n - *j; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getsizes(const char *attr, int *size, int dim) -{ register int i, k, n; - if (!*attr) - return -1; - i = strlen(attr); - n = 1; - do - { for (i = i-1; i >= 0; i--) - if (attr[i] == '[' || attr[i] == ',' || attr[i] == ' ') - break; - k = (int)atol(attr + i + 1); - n *= size[--dim] = k; - if (k < 0 || n > SOAP_MAXARRAYSIZE) - return -1; - } while (i >= 0 && attr[i] != '['); - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getposition(const char *attr, int *pos) -{ register int i, n; - if (!*attr) - return -1; - n = 0; - i = 1; - do - { pos[n++] = (int)atol(attr + i); - while (attr[i] && attr[i] != ',' && attr[i] != ']') - i++; - if (attr[i] == ',') - i++; - } while (n < SOAP_MAXDIMS && attr[i] && attr[i] != ']'); - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_push_namespace(struct soap *soap, const char *id, const char *ns) -{ register struct soap_nlist *np; - register struct Namespace *p; - np = (struct soap_nlist*)SOAP_MALLOC(sizeof(struct soap_nlist) + strlen(id)); - if (!np) - return soap->error = SOAP_EOM; - np->next = soap->nlist; - soap->nlist = np; - strcpy(np->id, id); - np->level = soap->level; - np->index = -1; - np->ns = NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push namespace binding (level=%u) '%s' '%s'\n", soap->level, id, ns)); - p = soap->local_namespaces; - if (p) - { register short i; - for (i = 0; p->id; p++, i++) - { if (p->ns) - if (!soap_tag_cmp(ns, p->ns)) - break; - if (p->in) - if (!soap_tag_cmp(ns, p->in)) - { if (p->out) - SOAP_FREE(p->out); - if ((p->out = (char*)SOAP_MALLOC(strlen(ns) + 1))) - strcpy(p->out, ns); - if (i == 0) - { if (!strcmp(ns, soap_env1)) - { soap->version = 1; /* and make sure we use SOAP 1.1 */ - if (p->out) - SOAP_FREE(p[1].out); - if ((p[1].out = (char*)SOAP_MALLOC(sizeof(soap_enc1)))) - strcpy(p[1].out, soap_enc1); - } - else - { soap->version = 2; /* and make sure we use SOAP 1.2 */ - if (p[1].out) - SOAP_FREE(p[1].out); - if ((p[1].out = (char*)SOAP_MALLOC(sizeof(soap_enc2)))) - strcpy(p[1].out, soap_enc2); - } - } - break; - } - } - if (p && p->id) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push OK ('%s' matches '%s' in namespace table)\n", id, p->id)); - np->index = i; - } - } - if (!p || !p->id) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push NOT OK: no match found for '%s' in namespace mapping table (added to stack anyway)\n", ns)); - np->ns = (char*)SOAP_MALLOC(strlen(ns) + 1); - if (!np->ns) - return soap->error = SOAP_EOM; - strcpy(np->ns, ns); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_push_default_namespace(struct soap *soap, const char *id, int n) -{ register struct soap_nlist *np = soap->nlist; - while (np && np->index >= -1) - np = np->next; - if (np && (!strncmp(np->id, id, n) && !np->id[n])) - return SOAP_OK; - np = (struct soap_nlist*)SOAP_MALLOC(sizeof(struct soap_nlist) + n); - if (!np) - return soap->error = SOAP_EOM; - np->next = soap->nlist; - soap->nlist = np; - strncpy(np->id, id, n); - np->id[n] = '\0'; - np->level = soap->level; - np->index = -2; - np->ns = NULL; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_pop_namespace(struct soap *soap) -{ register struct soap_nlist *np; - while (soap->nlist && soap->nlist->level >= soap->level) - { np = soap->nlist->next; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Popped namespace binding (level=%u) '%s'\n", soap->level, soap->nlist->id)); - if (soap->nlist->ns) - SOAP_FREE(soap->nlist->ns); - SOAP_FREE(soap->nlist); - soap->nlist = np; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_namespace(struct soap *soap, const char *id1, const char *id2, int n1, int n2) -{ register struct soap_nlist *np = soap->nlist; - while (np && (np->index == -2 || (strncmp(np->id, id1, n1) || np->id[n1]))) - np = np->next; - if (np) - { if (np->index < 0 || (np->index >= 0 && soap->local_namespaces[np->index].id && (strncmp(soap->local_namespaces[np->index].id, id2, n2) || soap->local_namespaces[np->index].id[n2]))) - return SOAP_NAMESPACE; - return SOAP_OK; - } - if (n1 == 3 && n1 == n2 && !strcmp(id1, "xml") && !strcmp(id1, id2)) - return SOAP_OK; - return SOAP_SYNTAX_ERROR; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_default_namespace(struct soap *soap) -{ register struct soap_nlist *np = soap->nlist; - while (np && np->index >= -1) - np = np->next; - if (np) - return np->id; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_tag_cmp(register const char *s, register const char *t) -{ for (; *s && *s != '"'; s++, t++) - if (tolower(*s) != tolower(*t)) - if (*t != '-') - { if (*t != '*') - return 1; - if (*++t) - { register int c = tolower(*t); - for (; *s && *s != '"'; s++) - { if (tolower(*s) == c) - if (!soap_tag_cmp(s + 1, t + 1)) - return 0; - } - break; - } - else - return 0; - } - if (*t == '*' && !t[1]) - return 0; - return *t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_tag(struct soap *soap, const char *tag1, const char *tag2) -{ register const char *s, *t; - if (!tag1 || !tag2 || !*tag2) - return SOAP_OK; - s = strchr(tag1, ':'); - t = strchr(tag2, ':'); - if (t) - { if (s) - { if (SOAP_STRCMP(s + 1, t + 1)) - return SOAP_TAG_MISMATCH; - if (t != tag2 && soap_match_namespace(soap, tag1, tag2, s - tag1, t - tag2)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); - return SOAP_TAG_MISMATCH; - } - } - else if (SOAP_STRCMP(tag1, t + 1)) - return SOAP_TAG_MISMATCH; - else if (t != tag2 && soap_match_namespace(soap, tag1, tag2, 0, t - tag2)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); - return SOAP_TAG_MISMATCH; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags and (default) namespaces match: '%s' '%s'\n", tag1, tag2)); - return SOAP_OK; - } - if (s) - { if (((soap->mode & SOAP_XML_STRICT) && soap->part != SOAP_IN_HEADER && soap->encodingStyle)) - return SOAP_TAG_MISMATCH; - if (SOAP_STRCMP(s + 1, tag2)) - return SOAP_TAG_MISMATCH; - if (!soap->encodingStyle) - { t = soap_default_namespace(soap); - if (!t || soap_match_namespace(soap, tag1, t, s - tag1, strlen(t))) - return SOAP_TAG_MISMATCH; - } - } - else if (SOAP_STRCMP(tag1, tag2)) - return SOAP_TAG_MISMATCH; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags match: '%s' '%s'\n", tag1, tag2)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_array(struct soap *soap, const char *type) -{ if (*soap->arrayType) - if (soap_match_tag(soap, soap->arrayType, type) - && soap_match_tag(soap, soap->arrayType, "xsd:anyType") - && soap_match_tag(soap, soap->arrayType, "xsd:ur-type") - ) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array type mismatch: '%s' '%s'\n", soap->arrayType, type)); - return SOAP_TAG_MISMATCH; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ - -#ifdef WITH_OPENSSL -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_server_context(struct soap *soap, unsigned short flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *dhfile, const char *randfile, const char *sid) -{ int err; - soap->keyfile = keyfile; - soap->password = password; - soap->cafile = cafile; - soap->capath = capath; - if (dhfile) - { soap->dhfile = dhfile; - soap->rsa = 0; - } - else - { soap->dhfile = NULL; - soap->rsa = 1; - } - soap->randfile = randfile; - soap->require_client_auth = (flags & SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION); - if (!(err = soap->fsslauth(soap))) - if (sid) - SSL_CTX_set_session_id_context(soap->ctx, (unsigned char*)sid, strlen(sid)); - return err; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_client_context(struct soap *soap, unsigned short flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *randfile) -{ soap->keyfile = keyfile; - soap->password = password; - soap->cafile = cafile; - soap->capath = capath; - soap->dhfile = NULL; - soap->rsa = 0; - soap->randfile = randfile; - soap->require_server_auth = (flags & SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION); - return soap->fsslauth(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -ssl_init() -{ static int done = 0; - if (!done) - { done = 1; - SSL_library_init(); -#ifndef WITH_LEAN - SSL_load_error_strings(); -#endif - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char * -ssl_error(struct soap *soap, int ret) -{ int err = SSL_get_error(soap->ssl, ret); - const char *msg = soap_str_code(h_ssl_error_codes, err); - if (msg) - strcpy(soap->msgbuf, msg); - else - return ERR_error_string(err, soap->msgbuf); - if (ERR_peek_error()) - { unsigned long r; - strcat(soap->msgbuf, "\n"); - while ((r = ERR_get_error())) - ERR_error_string_n(r, soap->msgbuf + strlen(soap->msgbuf), sizeof(soap->msgbuf) - strlen(soap->msgbuf)); - } - else - { switch (ret) - { case 0: - strcpy(soap->msgbuf, "EOF was observed that violates the protocol. The client probably provided invalid authentication information."); - break; - case -1: - sprintf(soap->msgbuf, "Error observed by underlying BIO: %s", strerror(errno)); - break; - } - } - return soap->msgbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_password(char *buf, int num, int rwflag, void *userdata) -{ if (num < (int)strlen((char*)userdata) + 1) - return 0; - return strlen(strcpy(buf, (char*)userdata)); -} -#endif - -/******************************************************************************/ -/* This callback is included for future references. It should not be deleted -#ifndef PALM_1 -static DH * -ssl_tmp_dh(SSL *ssl, int is_export, int keylength) -{ static DH *dh512 = NULL; - static DH *dh1024 = NULL; - DH *dh; - switch (keylength) - { case 512: - if (!dh512) - { BIO *bio = BIO_new_file("dh512.pem", "r"); - if (bio) - { dh512 = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - return dh512; - } - } - else - return dh512; - default: - if (!dh1024) - { BIO *bio = BIO_new_file("dh1024.pem", "r"); - if (bio) - { dh1024 = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - } - } - dh = dh1024; - } - return dh; -} -#endif -*/ -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_auth_init(struct soap *soap) -{ ssl_init(); - if (!soap->ctx) - if (!(soap->ctx = SSL_CTX_new(SSLv23_method()))) - return soap_set_receiver_error(soap, "SSL error", "Can't setup context", SOAP_SSL_ERROR); - if (soap->randfile) - { if (!RAND_load_file(soap->randfile, -1)) - return soap_set_receiver_error(soap, "SSL error", "Can't load randomness", SOAP_SSL_ERROR); - } - else if (!RAND_load_file("/dev/random", 1024)) - { int r; -#ifdef HAVE_RAND_R - unsigned int s = (unsigned int)time(NULL); -#endif - RAND_seed(soap->buf, sizeof(soap->buf)); - while (!RAND_status()) - { -#ifdef HAVE_RAND_R - r = rand_r(&s); -#else - r = rand(); -#endif - RAND_seed(&r, sizeof(int)); - } - } - if (soap->cafile || soap->capath) - if (!SSL_CTX_load_verify_locations(soap->ctx, soap->cafile, soap->capath)) - return soap_set_receiver_error(soap, "SSL error", "Can't read CA file and/or directory", SOAP_SSL_ERROR); - if (!SSL_CTX_set_default_verify_paths(soap->ctx)) - return soap_set_receiver_error(soap, "SSL error", "Can't read default CA file and/or directory", SOAP_SSL_ERROR); - if (soap->keyfile) - { if (!SSL_CTX_use_certificate_chain_file(soap->ctx, soap->keyfile)) - return soap_set_receiver_error(soap, "SSL error", "Can't read certificate key file", SOAP_SSL_ERROR); - if (soap->password) - { SSL_CTX_set_default_passwd_cb_userdata(soap->ctx, (void*)soap->password); - SSL_CTX_set_default_passwd_cb(soap->ctx, ssl_password); - if (!SSL_CTX_use_PrivateKey_file(soap->ctx, soap->keyfile, SSL_FILETYPE_PEM)) - return soap_set_receiver_error(soap, "SSL error", "Can't read key file", SOAP_SSL_ERROR); - } - } - if (soap->rsa) - { RSA *rsa = RSA_generate_key(512, RSA_F4, NULL, NULL); - if (!SSL_CTX_set_tmp_rsa(soap->ctx, rsa)) - { if (rsa) - RSA_free(rsa); - return soap_set_receiver_error(soap, "SSL error", "Can't set RSA key", SOAP_SSL_ERROR); - } - RSA_free(rsa); - } - else if (soap->dhfile) - { DH *dh = 0; - BIO *bio; - bio = BIO_new_file(soap->dhfile, "r"); - if (!bio) - return soap_set_receiver_error(soap, "SSL error", "Can't read DH file", SOAP_SSL_ERROR); - dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - if (SSL_CTX_set_tmp_dh(soap->ctx, dh) < 0) - { if (dh) - DH_free(dh); - return soap_set_receiver_error(soap, "SSL error", "Can't set DH parameters", SOAP_SSL_ERROR); - } - DH_free(dh); - } - SSL_CTX_set_options(soap->ctx, SSL_OP_ALL | SSL_OP_NO_SSLv2); - SSL_CTX_set_verify(soap->ctx, soap->require_client_auth ? (SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT) : soap->require_server_auth ? SSL_VERIFY_PEER : SSL_VERIFY_NONE, soap->fsslverify); -#if (OPENSSL_VERSION_NUMBER < 0x00905100L) - SSL_CTX_set_verify_depth(soap->ctx, 1); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_verify_callback(int ok, X509_STORE_CTX *store) -{ -#ifdef SOAP_DEBUG - if (!ok) - { char data[256]; - X509 *cert = X509_STORE_CTX_get_current_cert(store); - fprintf(stderr, "SSL Verify error with certificate at depth %d: %s\n", X509_STORE_CTX_get_error_depth(store), X509_verify_cert_error_string(X509_STORE_CTX_get_error(store))); - X509_NAME_oneline(X509_get_issuer_name(cert), data, sizeof(data)); - fprintf(stderr, "certificate issuer %s\n", data); - X509_NAME_oneline(X509_get_subject_name(cert), data, sizeof(data)); - fprintf(stderr, "certificate subject %s\n", data); - } -#endif - return ok; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_accept(struct soap *soap) -{ int i, r; - if (!soap_valid_socket(soap->socket)) - return soap_set_receiver_error(soap, "SSL error", "No socket in soap_ssl_accept()", SOAP_SSL_ERROR); - if (!soap->ssl) - { soap->ssl = SSL_new(soap->ctx); - if (!soap->ssl) - return soap_set_receiver_error(soap, "SSL error", "SSL_new() failed in soap_ssl_accept()", SOAP_SSL_ERROR); - } - else - SSL_clear(soap->ssl); - soap->imode |= SOAP_ENC_SSL; - soap->omode |= SOAP_ENC_SSL; -#ifdef WIN32 - u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &nonblocking); -#else - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)|O_NONBLOCK); -#endif - soap->bio = BIO_new_socket((SOAP_SOCKET)soap->socket, BIO_NOCLOSE); - SSL_set_bio(soap->ssl, soap->bio, soap->bio); - i = 100; - while ((r = SSL_accept(soap->ssl)) <= 0) - { int err = SSL_get_error(soap->ssl, r); - if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) - { struct timeval timeout; - fd_set fd; - if (i-- <= 0) - break; - timeout.tv_sec = 0; - timeout.tv_usec = 100000; - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r < 0 && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - } - else - { soap->errnum = err; - break; - } - } -#ifdef WIN32 - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &blocking); - } -#else - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)&~O_NONBLOCK); -#endif - if (r <= 0) - { soap_set_receiver_error(soap, ssl_error(soap, r), "SSL_accept() failed in soap_ssl_accept()", SOAP_SSL_ERROR); - soap_closesock(soap); - return SOAP_SSL_ERROR; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#endif /* WITH_OPENSSL */ - -/******************************************************************************/ -#ifndef PALM_1 -static int -tcp_init(struct soap *soap) -{ soap->errmode = 1; -#ifdef WIN32 - if (tcp_done) - return 0; - tcp_done = 1; - { WSADATA w; - if (WSAStartup(MAKEWORD(1, 1), &w)) - { tcp_done = 0; - return -1; - } - } -#endif -#ifdef PALM - errno = 0; - h_errno = 0; - AppNetRefnum = 0; - NetUInit(); - AppNetTimeout = 10000; - NetLibOpen(AppNetRefnum, &h_errno); -#endif - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_done(struct soap *soap) -{ -#ifndef WITH_LEAN - int i; -#endif - soap_free(soap); - while (soap->clist) - { struct soap_clist *p = soap->clist->next; - SOAP_FREE(soap->clist); - soap->clist = p; - } - soap->keep_alive = 0; /* to force close the socket */ - soap_closesock(soap); -#ifdef WITH_COOKIES - soap_free_cookies(soap); -#endif - while (soap->plugins) - { register struct soap_plugin *p = soap->plugins->next; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Removing plugin '%s'\n", soap->plugins->id)); - if (soap->plugins->fcopy || !soap->copy) - soap->plugins->fdelete(soap, soap->plugins); - SOAP_FREE(soap->plugins); - soap->plugins = p; - } - soap->fplugin = fplugin; - soap->fpost = http_post; - soap->fget = http_get; - soap->fposthdr = http_post_header; - soap->fresponse = http_response; - soap->fparse = http_parse; - soap->fparsehdr = http_parse_header; -#ifndef MAC_CARBON - soap->faccept = tcp_accept; - soap->fopen = tcp_connect; - soap->fclose = tcp_disconnect; - soap->fsend = fsend; - soap->frecv = frecv; -#endif - soap->fprepare = NULL; - soap->fignore = NULL; -#ifdef WITH_OPENSSL - if (soap->session) - { SSL_SESSION_free(soap->session); - soap->session = NULL; - } -#endif - if (!soap->copy) - { if (soap_valid_socket(soap->master)) - { closesocket((SOAP_SOCKET)soap->master); - soap->master = SOAP_INVALID_SOCKET; - } -#ifdef WITH_OPENSSL - if (soap->ctx) - { SSL_CTX_free(soap->ctx); - soap->ctx = NULL; - } -#endif - } -#ifndef WITH_LEAN - for (i = 0; i < SOAP_MAXLOGS; i++) - { soap_close_logfile(soap, i); - if (soap->logfile[i]) - { SOAP_FREE((void*)soap->logfile[i]); - soap->logfile[i] = NULL; - } - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_cleanup(struct soap *soap) -{ soap_done(soap); -#ifdef WIN32 - if (!tcp_done) - return; - tcp_done = 0; - WSACleanup(); -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -tcp_error(struct soap *soap) -{ register const char *msg = NULL; - switch (soap->errmode) - { case 0: - msg = soap_strerror(soap); - break; - case 1: - msg = "WSAStartup failed"; - break; - case 2: - { -#ifndef WITH_LEAN - msg = soap_str_code(h_error_codes, soap->errnum); - if (!msg) -#endif - { sprintf(soap->msgbuf, "TCP error %d", soap->errnum); - msg = soap->msgbuf; - } - } - } - return msg; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -http_error(struct soap *soap, int status) -{ register const char *msg = NULL; -#ifndef WITH_LEAN - msg = soap_str_code(h_http_error_codes, status); - if (!msg) -#endif - { sprintf(soap->msgbuf, "HTTP error %d", status); - msg = soap->msgbuf; - } - return msg; -} -#endif - -/******************************************************************************/ -/* WR[ */ -#ifndef WITH_IPV6 -/* ]WR */ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -soap_gethost(struct soap *soap, const char *addr, struct in_addr *inaddr) -{ unsigned long iadd; - struct hostent hostent, *host = &hostent; -/* WR[ */ -#ifdef VXWORKS - int hostint; - char * addrcopy = (char*)malloc(strlen(addr) + 1); /*copy of addr. */ - /* inet_addr(), and hostGetByName() expect "char *"; addr is a "const char *". */ - strncpy(addrcopy, addr, strlen(addr)+1); - iadd = inet_addr(addrcopy); -#else -/* ]WR */ -#if defined(_AIXVERSION_431) || defined(TRU64) - struct hostent_data ht_data; -#endif - iadd = inet_addr(addr); -/* WR[ */ -#endif -/* ]WR */ - if ((int)iadd != -1) - { memcpy(inaddr, &iadd, sizeof(iadd)); -/* WR[ */ -#ifdef VXWORKS - free(addrcopy); -#endif -/* ]WR */ - return 0; - } -#if defined(__GLIBC__) - if (gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &host, &soap->errnum) < 0) - host = NULL; -#elif defined(_AIXVERSION_431) || defined(TRU64) - memset(&ht_data, 0, sizeof(ht_data)); - if (gethostbyname_r(addr, &hostent, &ht_data) < 0) - { host = NULL; - soap->errnum = h_errno; - } -#elif defined(HAVE_GETHOSTBYNAME_R) - host = gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &soap->errnum); -/* WR[ */ -#elif defined(VXWORKS) - /* If the DNS resolver library resolvLib has been configured in the vxWorks - * image, a query for the host IP address is sent to the DNS server, if the - * name was not found in the local host table. */ - hostint = hostGetByName(addrcopy); - if (hostint == ERROR) - { - host = NULL; - soap->errnum = soap_errno; - } - free(addrcopy); /*free() is placed after the error checking to assure that - * errno captured is that from hostGetByName() */ -/* ]WR */ -#else - if (!(host = gethostbyname(addr))) - soap->errnum = h_errno; -#endif - if (!host) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Host name not found\n")); - return -1; - } -/* WR[ */ -#ifdef VXWORKS - inaddr->s_addr = hostint; -#else -/* ]WR */ - memcpy(inaddr, host->h_addr, host->h_length); -/* WR[ */ -#endif -/* ]WR */ - return 0; -} -#endif -#endif -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_connect(struct soap *soap, const char *endpoint, const char *host, int port) -{ struct sockaddr_in sockaddr; -/* WR[ */ -#ifdef WITH_IPV6 - struct addrinfo *addrinfo; - struct addrinfo hints; - struct addrinfo resaddr; - struct sockaddr_storage addrstorage; - int err; -#endif /* WITH_IPV6 */ -/* ]WR */ - register int fd; -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - if (soap_valid_socket(soap->socket)) - closesocket((SOAP_SOCKET)soap->socket); - soap->socket = SOAP_INVALID_SOCKET; - if (tcp_init(soap)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP initialization failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - soap->errmode = 0; -/* WR[ */ -#ifdef WITH_IPV6 - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - soap->errmode = 2; - if (soap->proxy_host) - err = getaddrinfo(soap->proxy_host, soap_int2s(soap, soap->proxy_port), &hints, &addrinfo); - else - err = getaddrinfo(host, soap_int2s(soap, port), &hints, &addrinfo); - if (addrinfo) - { resaddr = *addrinfo; - addrstorage = *((struct sockaddr_storage *) addrinfo->ai_addr); - resaddr.ai_addr = (struct sockaddr *) &addrstorage; - freeaddrinfo(addrinfo); - } - if (err) - { soap_set_sender_error(soap, gai_strerror(err), - "TCP getaddrinfo on proxy host failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - fd = (int)socket(resaddr.ai_family, resaddr.ai_socktype, resaddr.ai_protocol); /* modified to use fd */ - soap->errmode = 0; -#else /* WITH_IPV6 */ -/* ]WR */ - fd = (int)socket(AF_INET, SOCK_STREAM, 0); -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - if (fd < 0) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP socket failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } -#ifndef WITH_LEAN - if (soap->connect_flags & SO_LINGER) - { struct linger linger; - memset(&linger, 0, sizeof(struct linger)); - linger.l_onoff = 1; - linger.l_linger = 0; - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_LINGER failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - } - if ((soap->connect_flags & ~SO_LINGER) && setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, soap->connect_flags & ~SO_LINGER, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)fd, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } -#endif -#endif -/* WR[ */ -#ifndef WITH_IPV6 -/* ]WR */ - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin_family = AF_INET; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Open socket %d to host='%s'\n", fd, host)); - soap->errmode = 2; - if (soap->proxy_host) - { if (soap_gethost(soap, soap->proxy_host, &sockaddr.sin_addr)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP get proxy host by name failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - sockaddr.sin_port = htons((short)soap->proxy_port); - } - else - { if (soap_gethost(soap, host, &sockaddr.sin_addr)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP get host by name failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - sockaddr.sin_port = htons((short)port); - } - soap->errmode = 0; -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifndef WITH_LEAN - if (soap->connect_timeout) -#if defined(WIN32) - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &nonblocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { - vx_nonblocking = TRUE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)|O_NONBLOCK); -#endif - else -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { - vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - for (;;) - { -/* WR[ */ -#ifdef WITH_IPV6 - if (connect((SOAP_SOCKET)fd, resaddr.ai_addr, resaddr.ai_addrlen)) /* modified to use fd */ -#else /* WITH_IPV6 */ - if (connect((SOAP_SOCKET)fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr))) -#endif /* WITH_IPV6 */ -/* ]WR */ - { -#ifndef WITH_LEAN - if (soap->connect_timeout && (soap_socket_errno == SOAP_EINPROGRESS || soap_socket_errno == SOAP_EWOULDBLOCK)) - { struct timeval timeout; -#if defined(SOCKLEN_T) - SOCKLEN_T n = sizeof(struct sockaddr_in); -#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) - socklen_t n = sizeof(struct sockaddr_in); -#elif defined(WIN32) || defined(__APPLE__) || defined(HP_UX) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) - int n = sizeof(struct sockaddr_in); -#else - size_t n = sizeof(struct sockaddr_in); -#endif - fd_set fds; - if (soap->connect_timeout > 0) - { timeout.tv_sec = soap->connect_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->connect_timeout/1000000; - timeout.tv_usec = -soap->connect_timeout%1000000; - } - FD_ZERO(&fds); - FD_SET((SOAP_SOCKET)fd, &fds); - for (;;) - { int r = select((SOAP_SOCKET)(fd + 1), NULL, &fds, NULL, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect timeout\n")); - soap_set_sender_error(soap, "Timeout", "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - } - n = sizeof(soap->errnum); - if (!getsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_ERROR, (char*)&soap->errnum, &n) && !soap->errnum) - break; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - else -#endif - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - } - else - break; - } -#ifndef WITH_LEAN - if (soap->connect_timeout) -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { - vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - soap->socket = fd; -#ifdef WITH_OPENSSL - soap->imode &= ~SOAP_ENC_SSL; - soap->omode &= ~SOAP_ENC_SSL; - if (!strncmp(endpoint, "https:", 6)) - { int r; - if (soap->proxy_host) - { unsigned int k = soap->omode; /* make sure we only parse HTTP */ - size_t n = soap->count; /* save the content length */ - soap->omode &= ~0xFF; /* mask IO and ENC */ - soap->omode |= SOAP_IO_BUFFER; - soap_begin_send(soap); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connecting to proxy server\n")); - sprintf(soap->tmpbuf, "CONNECT %s:%d HTTP/%s", host, port, soap->http_version); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return -1; -#ifndef WITH_LEAN - if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((soap->error = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) - return soap->error; - } -#endif - if ((soap->error = soap->fposthdr(soap, NULL, NULL)) - || soap_end_send(soap)) - return -1; - soap->omode = k; - k = soap->imode; - soap->imode &= ~0xFF; /* mask IO and ENC */ - if (soap_begin_recv(soap)) - return -1; - soap->imode = k; - soap->count = n; - soap_begin_send(soap); - } - if (!soap->ctx && (soap->error = soap->fsslauth(soap))) - { soap_set_sender_error(soap, "SSL error", "SSL authentication failed in tcp_connect(): check password, key file, and ca file.", SOAP_SSL_ERROR); - return -1; - } - soap->ssl = SSL_new(soap->ctx); - if (!soap->ssl) - { soap->error = SOAP_SSL_ERROR; - return -1; - } - if (soap->session) - { if (!strcmp(soap->session_host, host) && soap->session_port == port) - SSL_set_session(soap->ssl, soap->session); - SSL_SESSION_free(soap->session); - soap->session = NULL; - } - soap->imode |= SOAP_ENC_SSL; - soap->omode |= SOAP_ENC_SSL; - soap->bio = BIO_new_socket((SOAP_SOCKET)fd, BIO_NOCLOSE); - SSL_set_bio(soap->ssl, soap->bio, soap->bio); -#ifndef WITH_LEAN - if (soap->connect_timeout) -#ifdef WIN32 - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &nonblocking); - } -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)|O_NONBLOCK); -#endif -#endif - for (;;) - { if ((r = SSL_connect(soap->ssl)) <= 0) - { int err = SSL_get_error(soap->ssl, r); - if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - { soap_set_sender_error(soap, ssl_error(soap, r), "SSL connect failed in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - if (soap->connect_timeout) - { struct timeval timeout; - fd_set fds; - if (soap->connect_timeout > 0) - { timeout.tv_sec = soap->connect_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->connect_timeout/1000000; - timeout.tv_usec = -soap->connect_timeout%1000000; - } - FD_ZERO(&fds); - FD_SET((SOAP_SOCKET)(soap->socket), &fds); - for (;;) - { int r = select((SOAP_SOCKET)(soap->socket + 1), &fds, NULL, &fds, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect timeout\n")); - soap_set_sender_error(soap, "Timeout", "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - } - continue; - } - } - break; - } -#ifndef WITH_LEAN - if (soap->connect_timeout) -#ifdef WIN32 - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - if (soap->require_server_auth) - { X509 *peer; - int err; - if ((err = SSL_get_verify_result(soap->ssl)) != X509_V_OK) - { soap_set_sender_error(soap, X509_verify_cert_error_string(err), "SSL certificate cannot be verified in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - peer = SSL_get_peer_certificate(soap->ssl); - if (!peer) - { soap_set_sender_error(soap, "SSL error", "No SSL certificate was presented by the peer in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - X509_NAME_get_text_by_NID(X509_get_subject_name(peer), NID_commonName, soap->msgbuf, sizeof(soap->msgbuf)); - X509_free(peer); - if (soap_tag_cmp(soap->msgbuf, host)) - { soap_set_sender_error(soap, "SSL error", "SSL certificate host name mismatch in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - } - } -#endif - return fd; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_bind(struct soap *soap, const char *host, int port, int backlog) -{ struct sockaddr_in sockaddr; -/* WR[ */ -#ifdef WITH_IPV6 - struct addrinfo *addrinfo; - struct addrinfo hints; - struct addrinfo resaddr; - struct sockaddr_storage addrstorage; - int err; -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - if (soap_valid_socket(soap->master)) - { closesocket((SOAP_SOCKET)soap->master); - soap->master = SOAP_INVALID_SOCKET; - } - soap->socket = SOAP_INVALID_SOCKET; - soap->errmode = 1; - if (tcp_init(soap)) - { soap_set_receiver_error(soap, tcp_error(soap), "TCP init failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#ifdef WITH_IPV6 - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; - soap->errmode = 2; - if (host) - err = getaddrinfo(host, soap_int2s(soap, port), &hints, &addrinfo); - else - err = getaddrinfo(NULL, soap_int2s(soap, port), &hints, &addrinfo); - if (NULL != addrinfo) - { - resaddr = *addrinfo; - addrstorage = *((struct sockaddr_storage *) addrinfo->ai_addr); - resaddr.ai_addr = (struct sockaddr *) &addrstorage; - freeaddrinfo(addrinfo); - } - if (err) - { soap_set_receiver_error(soap, gai_strerror(err), "TCP getaddrinfo failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - soap->errmode = 0; - if ((soap->master = socket(resaddr.ai_family, resaddr.ai_socktype, resaddr.ai_protocol)) < 0) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP socket failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#else /* WITH_IPV6 */ -/* ]WR */ - soap->errmode = 0; - if ((soap->master = (int)socket(AF_INET, SOCK_STREAM, 0)) < 0) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP socket failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifndef WITH_LEAN - if (soap->bind_flags && setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, soap->bind_flags, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)soap->master, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#endif -#endif -/* WR[ */ -#ifdef WITH_IPV6 - soap->errmode = 0; - if (bind(soap->master, resaddr.ai_addr, resaddr.ai_addrlen) || listen(soap->master, backlog)) - { - soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n")); - soap_closesock(soap); - soap_set_receiver_error(soap, tcp_error(soap), "TCP bind failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#else /* WITH_IPV6 */ -/* ]WR */ - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin_family = AF_INET; - soap->errmode = 2; - if (host) - { if (soap_gethost(soap, host, &sockaddr.sin_addr)) - { soap_set_receiver_error(soap, tcp_error(soap), "TCP get host by name failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - } - else - sockaddr.sin_addr.s_addr = htonl(INADDR_ANY); - sockaddr.sin_port = htons((short)port); - soap->errmode = 0; - if (bind((SOAP_SOCKET)soap->master, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) || listen((SOAP_SOCKET)soap->master, backlog)) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n")); - soap_closesock(soap); - soap_set_receiver_error(soap, tcp_error(soap), "TCP bind failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifdef WITH_OPENSSL - if (!soap->ctx && (soap->error = soap->fsslauth(soap))) - return -1; -#endif - return soap->master; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_poll(struct soap *soap) -{ -#ifndef WITH_LEAN - struct timeval timeout; - fd_set sfd,rfd; - int r; - timeout.tv_sec = 0; - timeout.tv_usec = 0; - FD_ZERO(&rfd); - FD_ZERO(&sfd); - if (soap->socket >= 0) - { FD_SET(soap->socket, &rfd); - FD_SET(soap->socket, &sfd); - r = select(soap->socket + 1, &rfd, &sfd, NULL, &timeout); - } - else if (soap->master >= 0) - { FD_SET(soap->master, &rfd); - r = select(soap->master + 1, &rfd, &sfd, NULL, &timeout); - } - else - { FD_SET(soap->sendfd, &sfd); - FD_SET(soap->recvfd, &rfd); - r = select((soap->sendfd > soap->recvfd ? soap->sendfd : soap->recvfd) + 1, &rfd, &sfd, NULL, &timeout); - } - if (r > 0) - { -#ifdef WITH_OPENSSL - if (soap->ssl) - { if ((soap->socket >= 0) && FD_ISSET(soap->socket, &rfd)) - { char buf = '\0'; - if (SSL_peek(soap->ssl, &buf, 1) <= 0) - return SOAP_EOF; - } - } -#endif - return SOAP_OK; - } - if (r < 0 && (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "select failed in soap_poll()", SOAP_TCP_ERROR); - return soap->error = SOAP_TCP_ERROR; - } - else - soap->errnum = soap_errno; - return SOAP_EOF; -#else - return SOAP_OK; -#endif -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_accept(struct soap *soap, int s, struct sockaddr *a, int *n) -{ -#if defined(SOCKLEN_T) - return (int)accept((SOAP_SOCKET)s, a, (SOCKLEN_T*)n); -#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) - return (int)accept((SOAP_SOCKET)s, a, (socklen_t*)n); -#elif defined(WIN32) || defined(__APPLE__) || defined(HP_UX) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) - return (int)accept((SOAP_SOCKET)s, a, n); -#else - return (int)accept((SOAP_SOCKET)s, a, (size_t*)n); -#endif -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_accept(struct soap *soap) -{ -/* WR[ */ -#ifdef WITH_IPV6 - struct sockaddr_storage sockaddr; -#else /* WITH_IPV6 */ -/* ]WR */ - struct sockaddr_in sockaddr; -/* WR[ */ -#endif -/* ]WR */ - int n = (int)sizeof(struct sockaddr); -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - memset(&sockaddr, 0, sizeof(sockaddr)); - soap->socket = SOAP_INVALID_SOCKET; - soap->errmode = 0; - if (soap_valid_socket(soap->master)) - { for (;;) - { -#ifndef WITH_LEAN - if (soap->accept_timeout) - { struct timeval timeout; - fd_set fd; - if (soap->accept_timeout > 0) - { timeout.tv_sec = soap->accept_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->accept_timeout/1000000; - timeout.tv_usec = -soap->accept_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->master, &fd); - for (;;) - { int r = select((SOAP_SOCKET)(soap->master + 1), &fd, &fd, NULL, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - soap_set_receiver_error(soap, "Timeout", "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - soap_closesock(soap); - soap_set_sender_error(soap, tcp_error(soap), "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } -#if defined(WIN32) - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &nonblocking); - } -#elif defined(VXWORKS) - { vx_nonblocking = TRUE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - } -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)|O_NONBLOCK); -#endif - } - else -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { - vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)&~O_NONBLOCK); -#endif -#endif - if ((soap->socket = soap->faccept(soap, soap->master, (struct sockaddr*)&sockaddr, &n)) >= 0) - { -/* WR[ */ -#ifdef WITH_IPV6 -/* Use soap->host to store the numeric form of the remote host */ - getnameinfo((struct sockaddr*)&sockaddr, n, soap->host, sizeof(soap->host), NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV); - soap->ip = 0; /* info stored in soap->host */ - soap->port = 0; /* info stored in soap->host */ -#else /* WITH_IPV6 */ -/* ]WR */ - soap->ip = ntohl(sockaddr.sin_addr.s_addr); - soap->port = (int)ntohs(sockaddr.sin_port); -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - soap->keep_alive = ((soap->imode & SOAP_IO_KEEPALIVE) != 0); -#ifndef WITH_LEAN - if (soap->accept_flags & SO_LINGER) - { struct linger linger; - memset(&linger, 0, sizeof(struct linger)); - linger.l_onoff = 1; - linger.l_linger = 0; - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_LINGER failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } - if ((soap->accept_flags & ~SO_LINGER) && setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, soap->accept_flags & ~SO_LINGER, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)soap->socket, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -#endif -#endif - if (soap->accept_timeout) - { -#if defined(WIN32) - u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &blocking); - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &blocking); -/* WR[ */ -#elif defined(VXWORKS) - vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - ioctl((SOAP_SOCKET)soap->socket, FIONBIO, (int)(&vx_nonblocking)); -/* ]WR */ -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)&~O_NONBLOCK); - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)&~O_NONBLOCK); -#endif - } - return soap->socket; - } - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } - } - else - { soap_set_receiver_error(soap, tcp_error(soap), "TCP no master socket in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_disconnect(struct soap *soap) -{ -#ifdef WITH_OPENSSL - if (soap->ssl) - { int r, s = 0; - if (soap->session) - SSL_SESSION_free(soap->session); - if (*soap->host) - { soap->session = SSL_get1_session(soap->ssl); - if (soap->session) - { strcpy(soap->session_host, soap->host); - soap->session_port = soap->port; - } - } - r = SSL_shutdown(soap->ssl); - if (r != 1) - { s = ERR_get_error(); - if (s) - { if (soap_valid_socket(soap->socket)) - { shutdown((SOAP_SOCKET)soap->socket, 1); - soap->socket = SOAP_INVALID_SOCKET; - } - r = SSL_shutdown(soap->ssl); - } - } - DBGLOG(TEST, if (s) SOAP_MESSAGE(fdebug, "Shutdown failed: %d\n", SSL_get_error(soap->ssl, r))); - SSL_free(soap->ssl); - soap->ssl = NULL; - if (s) - return SOAP_SSL_ERROR; - ERR_remove_state(0); - } -#endif - if (soap_valid_socket(soap->socket)) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Closing socket %d\n", soap->socket)); - shutdown((SOAP_SOCKET)soap->socket, 2); - closesocket((SOAP_SOCKET)soap->socket); - soap->socket = SOAP_INVALID_SOCKET; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_closesock(struct soap *soap) -{ register int status = soap->error; -#ifndef MAC_CARBON - if (status == SOAP_EOF || !soap->keep_alive) - { if ((soap->error = soap->fclose(soap))) - return soap->error; - soap->socket = SOAP_INVALID_SOCKET; - } -#endif -#ifdef WITH_ZLIB - if (soap->zlib_state == SOAP_ZLIB_DEFLATE) - deflateEnd(&soap->d_stream); - else if (soap->zlib_state == SOAP_ZLIB_INFLATE) - inflateEnd(&soap->d_stream); - soap->zlib_state = SOAP_ZLIB_NONE; -#endif - return soap->error = status; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_hash(register const char *s) -{ register int h = 0; - while (*s) - h += *s++ & 0x1F; - return h % SOAP_IDHASH; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_init_pht(struct soap *soap) -{ register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing pointer hashtable\n")); - for (i = 0; i < SOAP_PTRHASH; i++) - soap->pht[i] = NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new() -{ struct soap *soap = (struct soap*)SOAP_MALLOC(sizeof(struct soap)); - if (soap) - soap_init(soap); - return soap; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new1(int mode) -{ return soap_new2(mode, mode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new2(int imode, int omode) -{ struct soap *soap = (struct soap*)SOAP_MALLOC(sizeof(struct soap)); - if (soap) - soap_init2(soap, imode, omode); - return soap; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static void -soap_free_pht(struct soap *soap) -{ register struct soap_plist *pp, *next; - register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free pointer hashtable\n")); - for (i = 0; i < SOAP_PTRHASH; i++) - { for (pp = soap->pht[i]; pp; pp = next) - { next = pp->next; - SOAP_FREE(pp); - } - soap->pht[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_embed_element(struct soap *soap, const void *p, const char *tag, int type) -{ register int i; - struct soap_plist *pp; - if (soap->version != 1) - soap->encoding = 1; - if ((i = soap_pointer_lookup(soap, p, type, &pp))) - { if (soap_is_embedded(soap, pp) || soap_is_single(soap, pp)) - return 0; - soap_set_embedded(soap, pp); - } - return i; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_embed_array(struct soap *soap, const void *p, const struct soap_array *a, int n, const char *tag, int type) -{ register int i; - struct soap_plist *pp; - if (soap->version != 1) - soap->encoding = 1; - if ((i = soap_array_pointer_lookup(soap, p, a, n, type, &pp))) - { if (soap_is_embedded(soap, pp) || soap_is_single(soap, pp)) - return 0; - soap_set_embedded(soap, pp); - } - return i; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pointer_lookup(struct soap *soap, const void *p, int type, struct soap_plist **ppp) -{ register struct soap_plist *pp; - *ppp = NULL; - if (p) - for (pp = soap->pht[soap_hash_ptr(p)]; pp; pp = pp->next) - if (pp->ptr == p && pp->type == type) - { *ppp = pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup location=%p type=%d id=%d\n", p, type, pp->id)); - return pp->id; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup location=%p type=%d: not found\n", p, type)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_pointer_lookup(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp) -{ struct soap_plist *pp; - *ppp = NULL; - if (!p || !a->__ptr) - return 0; - for (pp = soap->pht[soap_hash_ptr(a->__ptr)]; pp; pp = pp->next) - if (pp->type == type && pp->array && pp->array->__ptr == a->__ptr && pp->array->__size == n) - { *ppp = pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d id=%d\n", a->__ptr, type, pp->id)); - return pp->id; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d: not found\n", a->__ptr, type)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pointer_enter(struct soap *soap, const void *p, int type, struct soap_plist **ppp) -{ register struct soap_plist *pp; - if (!p) - { *ppp = NULL; - return 0; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enter location=%p type=%d id=%lu\n", p, type, soap->idnum+1)); - *ppp = pp = (struct soap_plist*)SOAP_MALLOC(sizeof(struct soap_plist)); - if (pp) - { register int h = soap_hash_ptr(p); - pp->next = soap->pht[h]; - pp->type = type; - if ((soap->mode & SOAP_XML_TREE) || soap->part == SOAP_IN_HEADER) - { pp->mark1 = 0; - pp->mark2 = 0; - } - else - { pp->mark1 = 1; - pp->mark2 = 1; - } - pp->ptr = p; - pp->array = NULL; - soap->pht[h] = pp; - return pp->id = ++soap->idnum; - } - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_pointer_enter(struct soap *soap, const void *p, const struct soap_array *a, int type, struct soap_plist **ppp) -{ struct soap_plist *pp; - *ppp = NULL; - if (!p || !a->__ptr) - return 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array enter location=%p size=%d type=%d id=%lu\n", a->__ptr, a->__size, type, soap->idnum+1)); - *ppp = pp = (struct soap_plist*)SOAP_MALLOC(sizeof(struct soap_plist)); - if (pp) - { register int h = soap_hash_ptr(a->__ptr); - pp->next = soap->pht[h]; - pp->type = type; - if ((soap->mode & SOAP_XML_TREE) || soap->part == SOAP_IN_HEADER) - { pp->mark1 = 0; - pp->mark2 = 0; - } - else - { pp->mark1 = 1; - pp->mark2 = 1; - } - pp->ptr = p; - pp->array = a; - soap->pht[h] = pp; - return pp->id = ++soap->idnum; - } - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_begin_count(struct soap *soap) -{ soap_clr_attr(soap); - soap_set_local_namespaces(soap); - if (soap->mode & SOAP_ENC_DIME) - soap->mode = soap->omode | SOAP_IO_LENGTH | SOAP_ENC_DIME; - else - { soap->mode = soap->omode; - if (((soap->mode & (SOAP_IO_STORE | SOAP_IO_CHUNK)) || (soap->mode & SOAP_ENC_XML)) && !soap->fprepare) - soap->mode &= ~SOAP_IO_LENGTH; - else - soap->mode |= SOAP_IO_LENGTH; - } - if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH) - { if (!(soap->mode & SOAP_ENC_DIME)) - soap->mode &= ~SOAP_IO_LENGTH; - if (soap->mode & SOAP_ENC_XML) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - soap->count = 0; - soap->ns = 0; - soap->null = 0; - soap->position = 0; - soap->mustUnderstand = 0; - soap->encoding = 0; - soap->part = SOAP_BEGIN; - soap->idnum = 0; - soap->dime_count = 0; /* count # of attachments */ - soap->dime_size = 0; /* accumulate total size of attachments */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin count phase (socket=%d mode=%hd count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count)); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_begin_send(struct soap *soap) -{ soap_clr_attr(soap); - soap_set_local_namespaces(soap); - soap->mode = (soap->omode & ~SOAP_IO_LENGTH) | (soap->mode & SOAP_ENC_DIME); - if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH) - { if (soap->mode & SOAP_ENC_XML) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_FLUSH && soap_valid_socket(soap->socket)) - { if (soap->count || (soap->mode & SOAP_ENC_XML)) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - soap_new_block(soap); - if (!(soap->mode & SOAP_IO_KEEPALIVE)) - soap->keep_alive = 0; -#ifdef WIN32 -#ifndef UNDER_CE -#ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket)) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */ -#ifdef __BORLANDC__ - setmode((SOAP_SOCKET)soap->sendfd, O_BINARY); -#else - _setmode((SOAP_SOCKET)soap->sendfd, _O_BINARY); -#endif -#endif -#endif -#endif - if (soap->mode & SOAP_IO) - { soap->bufidx = 0; - soap->buflen = 0; - } - soap->chunksize = 0; - soap->ns = 0; - soap->null = 0; - soap->position = 0; - soap->mustUnderstand = 0; - soap->encoding = 0; - soap->part = SOAP_BEGIN; - soap->idnum = 0; - soap->level = 0; -#ifdef WITH_ZLIB - soap->z_ratio_out = 1.0; - if ((soap->mode & SOAP_ENC_ZLIB) && soap->zlib_state != SOAP_ZLIB_DEFLATE) - { -#ifdef WITH_GZIP - memcpy(soap->z_buf, "\37\213\10\0\0\0\0\0\0\377", 10); - soap->d_stream.next_out = (Byte*)soap->z_buf + 10; - soap->d_stream.avail_out = SOAP_BUFLEN - 10; - soap->z_crc = crc32(0L, NULL, 0); - if (deflateInit2(&soap->d_stream, soap->z_level, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK) -#else - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - if (deflateInit(&soap->d_stream, soap->z_level) != Z_OK) -#endif - return soap->error = SOAP_ZLIB_ERROR; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflate initialized\n")); - soap->zlib_state = SOAP_ZLIB_DEFLATE; - } -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin send phase (socket=%d mode=%hd count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_embedded(struct soap *soap, const void *p, int t) -{ struct soap_plist *pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded %p type=%d\n", p, t)); - if (soap_pointer_lookup(soap, p, t, &pp)) - { pp->mark1 = 1; - pp->mark2 = 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded %p type=%d set to %d\n", p, t, (int)pp->mark1)); - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_reference(struct soap *soap, const void *p, int t) -{ register int i; - struct soap_plist *pp; - if (!p) - return 1; - i = soap_pointer_lookup(soap, p, t, &pp); - if (i) - { if (pp->mark1 == 0) - { pp->mark1 = 2; - pp->mark2 = 2; - } - } - else - { soap_pointer_enter(soap, p, t, &pp); - pp->mark1 = 0; - pp->mark2 = 0; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reference %p type = %d (%d %d)\n", p, t, (int)pp->mark1, (int)pp->mark2)); - return pp->mark1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_reference(struct soap *soap, const void *p, const struct soap_array *a, int n, int t) -{ register int i; - struct soap_plist *pp; - if (!p) - return 1; - i = soap_array_pointer_lookup(soap, p, a, n, t, &pp); - if (i) - { if (pp->mark1 == 0) - { pp->mark1 = 2; - pp->mark2 = 2; - } - } - else if (!soap_array_pointer_enter(soap, p, a, t, &pp)) - return 1; - pp->mark1 = 0; - pp->mark2 = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array reference %p ptr=%p size=%d type = %d (%d %d)\n", p, a->__ptr, n, t, (int)pp->mark1, (int)pp->mark2)); - return pp->mark1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_embedded_id(struct soap *soap, int id, const void *p, int t) -{ struct soap_plist *pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id %p type=%d id=%d\n", p, t, id)); - if (soap->version == 1 && soap->encodingStyle && !(soap->mode & (SOAP_XML_TREE | SOAP_XML_GRAPH)) && soap->part != SOAP_IN_HEADER) - { if (id < 0) - { id = soap_pointer_lookup(soap, p, t, &pp); - if (id > 0 && pp) - { if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 2; - else - pp->mark2 = 2; - } - return -1; - } - return id; - } - if (id < 0) - id = soap_pointer_lookup(soap, p, t, &pp); - else - soap_pointer_lookup(soap, p, t, &pp); - if (id > 0 && pp) - { if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 1; - else - pp->mark2 = 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id id=%d %p type=%d = (%d %d)\n", id, p, t, (int)pp->mark1, (int)pp->mark2)); - } - return id; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_is_embedded(struct soap *soap, struct soap_plist *pp) -{ if (!pp) - return 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Is embedded? %d %d\n", (int)pp->mark1, (int)pp->mark2)); - if (soap->version == 1 && soap->encodingStyle && !(soap->mode & (SOAP_XML_TREE | SOAP_XML_GRAPH)) && soap->part != SOAP_IN_HEADER) - { if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 != 0; - return pp->mark2 != 0; - } - if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 == 1; - return pp->mark2 == 1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_is_single(struct soap *soap, struct soap_plist *pp) -{ if ((soap->mode & SOAP_XML_TREE) || soap->part == SOAP_IN_HEADER) - return 1; - if (!pp) - return 0; - if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 == 0; - return pp->mark2 == 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_is_multi(struct soap *soap, struct soap_plist *pp) -{ if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 == 2; - return pp->mark2 == 2; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_embedded(struct soap *soap, struct soap_plist *pp) -{ if (!pp) - return; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 1; - else - pp->mark2 = 1; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_attached(struct soap *soap, struct soap_plist *pp, const char *id, const char *type, const char *options, size_t size) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set attached id='%s' type='%s'\n", id?id:"", type?type:"")); - if (soap->mode & SOAP_IO_LENGTH) - { if (pp->mark1 != 3) - { pp->mark1 = 3; - soap->dime_count++; /* one more attachment found */ - soap->dime_size += 12; /* increase total size (DIME fields) */ - if (id) - soap->dime_size += (strlen(id)+3)&(~3); - if (type) - soap->dime_size += (strlen(type)+3)&(~3); - if (options) - soap->dime_size += 4 + (((((unsigned char)options[2] << 8 | (unsigned char)options[3]))+3)&(~3)); - soap->dime_size += (size+3)&(~3); - } - } - else if (pp->mark2 != 3) - pp->mark2 = 3; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_init_iht(struct soap *soap) -{ register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing ID hashtable\n")); - for (i = 0; i < SOAP_IDHASH; i++) - soap->iht[i] = NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static void -soap_free_iht(struct soap *soap) -{ register int i; - register struct soap_ilist *ip, *p; - register struct soap_clist *cp, *q; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free ID hashtable\n")); - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = p) - { for (cp = ip->clist; cp; cp = q) - { q = cp->next; - SOAP_FREE(cp); - } - p = ip->next; - SOAP_FREE(ip); - } - soap->iht[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static struct soap_ilist * -soap_hlookup(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - for (ip = soap->iht[soap_hash(id)]; ip; ip = ip->next) - if (!strcmp(ip->id, id)) - return ip; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_ilist * -SOAP_FMAC2 -soap_lookup(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - ip = soap_hlookup(soap, id); -#ifndef WITH_LEANER - if (!ip && *id != '#' && !strchr(id, ':')) /* try content id "cid:" with DIME attachments */ - { char cid[SOAP_TAGLEN]; - strcpy(cid, "cid:"); - strncat(cid + 4, id, sizeof(cid) - 5); - cid[sizeof(cid) - 1] = '\0'; - ip = soap_hlookup(soap, cid); - } -#endif - return ip; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_ilist * -SOAP_FMAC2 -soap_enter(struct soap *soap, const char *id) -{ register int h; - register struct soap_ilist *ip; - ip = (struct soap_ilist*)SOAP_MALLOC(sizeof(struct soap_ilist) + strlen(id)); - if (ip) - { h = soap_hash(id); - strcpy(ip->id, id); - ip->next = soap->iht[h]; - soap->iht[h] = ip; - return ip; - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_malloc(struct soap *soap, size_t n) -{ register char *p; - if (!n) - return NULL; - if (!soap) - return SOAP_MALLOC(n); - n += (-(long)n) & 7; - if (!(p = (char*)SOAP_MALLOC(n + sizeof(void*) + sizeof(size_t)))) - { soap->error = SOAP_EOM; - return NULL; - } - /* keep chain of alloced cells for later destruction */ - soap->alloced = 1; - *(void**)(p + n) = soap->alist; - *(size_t*)(p + n + sizeof(void*)) = n; - soap->alist = p + n; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Malloc %u bytes at location %p\n", (unsigned int)n, p)); - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_dealloc(struct soap *soap, void *p) -{ if (!soap) - return; - if (p) - { register char **q; - for (q = (char**)&soap->alist; *q; q = *(char***)q) - { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*)))) - { *q = **(char***)q; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Freed data at %p\n", p)); - SOAP_FREE(p); - return; - } - } - soap_delete(soap, p); - } - else - { register char *q; - while (soap->alist) - { q = (char*)soap->alist; - soap->alist = *(void**)q; - q -= *(size_t*)(q + sizeof(void*)); - if (q == (char*)soap->fault) - soap->fault = NULL; /* this was deallocated */ - else if (q == (char*)soap->header) - soap->header = NULL; /* this was deallocated */ - SOAP_FREE(q); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Dealloc all data done\n")); - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_delete(struct soap *soap, void *p) -{ register struct soap_clist **cp = &soap->clist; - if (p) - { while (*cp) - { if (p == (*cp)->ptr) - { register struct soap_clist *q = *cp; - *cp = q->next; - q->fdelete(q); - SOAP_FREE(q); - return; - } - cp = &(*cp)->next; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not dealloc data %p: address not in list\n", p)); - } - else - { while (*cp) - { register struct soap_clist *q = *cp; - *cp = q->next; - if (q->ptr == (void*)soap->fault) - soap->fault = NULL; /* this was deallocated */ - else if (q->ptr == (void*)soap->header) - soap->header = NULL; /* this was deallocated */ - q->fdelete(q); - SOAP_FREE(q); - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_clist * -SOAP_FMAC2 -soap_link(struct soap *soap, void *p, int t, int n, void (*fdelete)(struct soap_clist*)) -{ register struct soap_clist *cp; - if ((cp = (struct soap_clist*)SOAP_MALLOC(sizeof(struct soap_clist)))) - { cp->next = soap->clist; - cp->type = t; - cp->size = n; - cp->ptr = p; - cp->fdelete = fdelete; - soap->clist = cp; - } - return cp; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_unlink(struct soap *soap, const void *p) -{ register char **q; - register struct soap_clist **cp; - if (!soap || !p) - return; - for (q = (char**)&soap->alist; *q; q = *(char***)q) - { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*)))) - { *q = **(char***)q; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked data %p\n", p)); - return; - } - } - for (cp = &soap->clist; *cp; cp = &(*cp)->next) - { if (p == (*cp)->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked class instance %p\n", p)); - q = (char**)*cp; - *cp = (*cp)->next; - SOAP_FREE(q); - return; - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_lookup_type(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - if (*id) - { ip = soap_lookup(soap, id); - if (ip) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup id='%s' type=%d\n", id, ip->type)); - return ip->type; - } - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "lookup type id='%s' NOT FOUND! Need to get it from xsi:type\n", id)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_lookup(struct soap *soap, const char *id, void **p, int t, size_t n, unsigned int k) -{ struct soap_ilist *ip; - void *q; - if (*id == '\0') - return p; - soap->alloced = 0; - if (!p) - p = (void**)soap_malloc(soap, sizeof(void*)); - ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */ - if (!ip) - { ip = soap_enter(soap, id); /* new hash table entry for string id */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding first href='%s' %p (%u bytes)\n", id, p, (unsigned int)n)); - ip->type = t; - ip->size = n; - ip->link = p; - ip->copy = NULL; - ip->clist = NULL; - ip->ptr = NULL; - ip->level = k; - *p = NULL; - } - else if (!soap->blist && ip->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolved href='%s' type='%d' (%u bytes)\n", id, t, (unsigned int)n)); - if (ip->type != t) - { soap->error = SOAP_HREF; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Object mismatch: id's type='%d' href's type='%d'\n", ip->type, t)); - return NULL; - } - while (ip->level < k) - { q = soap_malloc(soap, sizeof(void*)); - *p = q; - p = (void**)q; - k--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - *p = ip->ptr; - } - else if (ip->level > k) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving level %u pointers to href='%s'\n", ip->level, id)); - while (ip->level > k) - { void *s, **r = &ip->link; - q = ip->link; - while (q) - { *r = soap_malloc(soap, sizeof(void*)); - s = *(void**)q; - *(void**)q = *r; - r = *(void***)q; - q = s; - } - *r = NULL; - ip->size = n; - ip->copy = NULL; - ip->level = ip->level - 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - q = ip->link; - ip->link = p; - *p = q; - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarded href='%s' (%u bytes)\n", id, (unsigned int)n)); - while (ip->level < k) - { q = soap_malloc(soap, sizeof(void*)); - *p = q; - p = (void**)q; - k--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - q = ip->link; - ip->link = p; - *p = q; - } - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_forward(struct soap *soap, const char *href, void *p, int t, size_t n) -{ struct soap_ilist *ip; - if (!p || !*href) - return p; - ip = soap_lookup(soap, soap->href); /* lookup pointer to hash table entry for string id */ - if (!ip) - { if (n >= sizeof(void*)) - { ip = soap_enter(soap, href); /* new hash table entry for string id */ - ip->type = t; - ip->size = n; - ip->link = NULL; - ip->copy = p; - ip->clist = NULL; - *(void**)p = NULL; - ip->ptr = NULL; - ip->level = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding first copying address %p for type %d href='%s'\n", p, t, href)); - return p; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding problem: copying location %p too small (%u) for href='%s'\n", p, (unsigned int)n, href)); - soap->error = SOAP_HREF; - return NULL; - } - else if (ip->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying value from location %p to location %p to resolve href='%s'\n", ip->ptr, p, href)); - memcpy(p, ip->ptr, n); - } - else if (n >= sizeof(void*)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding copying address %p for type %d href='%s' (prev in chain = %p)\n", p, t, href, ip->copy)); - *(void**)p = ip->copy; - ip->copy = p; - return p; - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding problem: copying location %p too small (%u) for href='%s'\n", p, (unsigned int)n, href)); - soap->error = SOAP_HREF; /* href to object too small to hold pointer */ - return NULL; - } - return ip->ptr; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, int k) -{ struct soap_ilist *ip; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Enter id='%s' type=%d loc=%p size=%d level=%d\n", id, t, p, (int)n, k)); - soap->alloced = 0; - if (*id == '\0') - { if (!p) - return soap_malloc(soap, n); - else - return p; - } - ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */ - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Lookup entry id='%s'\n", id)); - if (!ip) - { ip = soap_enter(soap, id); /* new hash table entry for string id */ - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "New entry id='%s' type=%d size=%u\n", id, t, (unsigned int)n)); - ip->type = t; - ip->size = n; - ip->link = NULL; - ip->copy = NULL; - ip->clist = NULL; - if (!p) - p = soap_malloc(soap, n); - ip->ptr = p; - ip->level = k; - } - else if (ip->ptr) /* storage address was forwarded */ - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Multiply defined id='%s'\n", id)); - if (p) - { soap->error = SOAP_MULTI_ID; - return NULL; - } - } - else - { if (!p) - p = soap_malloc(soap, n); - ip->ptr = p; - if (!soap->blist) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolve link chain to point to %p\n", ip->ptr)); - soap_resolve_ptr(ip); - } - } - return ip->ptr; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_end_send(struct soap *soap) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End send\n")); - if (soap->mode & SOAP_IO) /* need to flush the remaining data in buffer */ - { if (soap_flush(soap)) -#ifdef WITH_ZLIB - { if (soap->mode & SOAP_ENC_ZLIB && soap->zlib_state == SOAP_ZLIB_DEFLATE) - { soap->zlib_state = SOAP_ZLIB_NONE; - deflateEnd(&soap->d_stream); - } - return soap->error; - } -#else - return soap->error; -#endif -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { int r; - soap->d_stream.avail_in = 0; - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating remainder\n")); - r = deflate(&soap->d_stream, Z_FINISH); - if (soap->d_stream.avail_out != SOAP_BUFLEN) - { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN - soap->d_stream.avail_out)) - { soap->zlib_state = SOAP_ZLIB_NONE; - deflateEnd(&soap->d_stream); - return soap->error; - } - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - } - } while (r == Z_OK); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_out = (float)soap->d_stream.total_out / (float)soap->d_stream.total_in; - soap->mode &= ~SOAP_ENC_ZLIB; - soap->zlib_state = SOAP_ZLIB_NONE; - if (deflateEnd(&soap->d_stream) != Z_OK || r != Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to end deflate: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - return soap->error = SOAP_ZLIB_ERROR; - } -#ifdef WITH_GZIP - soap->z_buf[0] = soap->z_crc & 0xFF; - soap->z_buf[1] = (soap->z_crc >> 8) & 0xFF; - soap->z_buf[2] = (soap->z_crc >> 16) & 0xFF; - soap->z_buf[3] = (soap->z_crc >> 24) & 0xFF; - soap->z_buf[4] = soap->d_stream.total_in & 0xFF; - soap->z_buf[5] = (soap->d_stream.total_in >> 8) & 0xFF; - soap->z_buf[6] = (soap->d_stream.total_in >> 16) & 0xFF; - soap->z_buf[7] = (soap->d_stream.total_in >> 24) & 0xFF; - if (soap_flush_raw(soap, soap->z_buf, 8)) - return soap->error; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip crc32=%lu\n", soap->z_crc)); -#endif - } -#endif -#ifndef WITH_LEAN - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - { char *p; - if (!(soap->mode & SOAP_ENC_XML)) - { soap->mode--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending buffered message of length %u\n", (unsigned int)soap->blist->size)); - if (soap->status >= SOAP_POST) - soap->error = soap->fpost(soap, soap->endpoint, soap->host, soap->port, soap->path, soap->action, soap->blist->size); - else if (soap->status != SOAP_STOP) - soap->error = soap->fresponse(soap, soap->status, soap->blist->size); - if (soap->error || soap_flush(soap)) - return soap->error; - soap->mode++; - } - for (p = soap_first_block(soap); p; p = soap_next_block(soap)) - { DBGMSG(SENT, p, soap_block_size(soap)); - if ((soap->error = soap->fsend(soap, p, soap_block_size(soap)))) - { soap_end_block(soap); - return soap->error; - } - } - soap_end_block(soap); - } - else if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { DBGMSG(SENT, "\r\n0\r\n\r\n", 7); - if ((soap->error = soap->fsend(soap, "\r\n0\r\n\r\n", 7))) - return soap->error; - } -#endif - } -#ifdef WITH_OPENSSL - if (!soap->ssl && soap_valid_socket(soap->socket) && !soap->keep_alive) - shutdown((SOAP_SOCKET)soap->socket, 1); /* Send TCP FIN */ -#else - if (soap_valid_socket(soap->socket) && !soap->keep_alive) - shutdown((SOAP_SOCKET)soap->socket, 1); /* Send TCP FIN */ -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of send message ok\n")); - soap->part = SOAP_END; - soap->count = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_end_recv(struct soap *soap) -{ soap->part = SOAP_END; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "End of receive message ok\n")); -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { soap->mode &= ~SOAP_ENC_ZLIB; - memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN); - soap->bufidx = (char*)soap->d_stream.next_in - soap->z_buf; - soap->buflen = soap->z_buflen; - soap->zlib_state = SOAP_ZLIB_NONE; - if (inflateEnd(&soap->d_stream) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; -#ifdef WITH_GZIP - if (soap->zlib_in == SOAP_ZLIB_GZIP) - { wchar c; - short i; - for (i = 0; i < 8; i++) - { if ((int)(c = soap_getchar(soap)) == EOF) - return soap->error = SOAP_EOF; - soap->z_buf[i] = (char)c; - } - if (soap->z_crc != ((unsigned char)soap->z_buf[0] | (unsigned long)((unsigned char)soap->z_buf[1] << 8) | (unsigned long)((unsigned char)soap->z_buf[2] << 16) | (unsigned long)((unsigned char)soap->z_buf[3] << 24))) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: crc check failed, message corrupted? (crc32=%lu)\n", soap->z_crc)); - return soap->error = SOAP_ZLIB_ERROR; - } - if (soap->d_stream.total_out != ((unsigned char)soap->z_buf[4] | (unsigned long)((unsigned char)soap->z_buf[5] << 8) | (unsigned long)((unsigned char)soap->z_buf[6] << 16) | (unsigned long)((unsigned char)soap->z_buf[7] << 24))) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: incorrect message length\n")); - return soap->error = SOAP_ZLIB_ERROR; - } - } -#endif - } -#endif - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - while ((int)soap_getchar(soap) != EOF) /* advance to last chunk */ - ; - if (soap->fdisconnect) - if ((soap->error = soap->fdisconnect(soap))) - return soap->error; - return soap_resolve(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_free(struct soap *soap) -{ register struct soap_nlist *np; - register struct soap_attribute *tp; - register struct Namespace *ns; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free namespace stack\n")); - while (soap->nlist) - { np = soap->nlist->next; - if (soap->nlist->ns) - SOAP_FREE(soap->nlist->ns); - SOAP_FREE(soap->nlist); - soap->nlist = np; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free any remaining temp blocks\n")); - while (soap->blist) - soap_end_block(soap); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free attributes\n")); - while (soap->attributes) - { tp = soap->attributes->next; - if (soap->attributes->value) - SOAP_FREE(soap->attributes->value); - SOAP_FREE(soap->attributes); - soap->attributes = tp; - } - soap_free_pht(soap); - soap_free_iht(soap); - ns = soap->local_namespaces; - if (ns) - { for (; ns->id; ns++) - { if (ns->out) - { SOAP_FREE(ns->out); - if (soap->encodingStyle == ns->out) - soap->encodingStyle = SOAP_STR_EOS; - ns->out = NULL; - } - if (soap->encodingStyle == ns->ns) - soap->encodingStyle = SOAP_STR_EOS; - } - SOAP_FREE(soap->local_namespaces); - soap->local_namespaces = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static void -soap_init_logs(struct soap *soap) -{ int i; - for (i = 0; i < SOAP_MAXLOGS; i++) - { soap->logfile[i] = NULL; - soap->fdebug[i] = NULL; - } -#ifdef SOAP_DEBUG - soap_set_recv_logfile(soap, "RECV.log"); - soap_set_sent_logfile(soap, "SENT.log"); - soap_set_test_logfile(soap, "TEST.log"); -#endif -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_open_logfile(struct soap *soap, int i) -{ if (soap->logfile[i]) - soap->fdebug[i] = fopen(soap->logfile[i], i < 2 ? "ab" : "a"); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static void -soap_close_logfile(struct soap *soap, int i) -{ if (soap->fdebug[i]) - { fclose(soap->fdebug[i]); - soap->fdebug[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_close_logfiles(struct soap *soap) -{ int i; - for (i = 0; i < SOAP_MAXLOGS; i++) - soap_close_logfile(soap, i); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static void -soap_set_logfile(struct soap *soap, int i, const char *logfile) -{ char *s = NULL; - soap_close_logfile(soap, i); - if (soap->logfile[i]) - SOAP_FREE((void*)soap->logfile[i]); - if (logfile) - if ((s = (char*)SOAP_MALLOC(strlen(logfile) + 1))) - strcpy(s, logfile); - soap->logfile[i] = s; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_recv_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_RECV, logfile); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_sent_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_SENT, logfile); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_test_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_TEST, logfile); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_copy(struct soap *soap) -{ return soap_copy_context((struct soap*)SOAP_MALLOC(sizeof(struct soap)), soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_copy_context(struct soap *copy, struct soap *soap) -{ if (copy) - { register struct soap_plugin *p; - memcpy(copy, soap, sizeof(struct soap)); - copy->copy = 1; - copy->user = NULL; - copy->userid = NULL; - copy->passwd = NULL; - copy->nlist = NULL; - copy->blist = NULL; - copy->clist = NULL; - copy->alist = NULL; - copy->attributes = NULL; - copy->local_namespaces = NULL; - soap_set_local_namespaces(copy); - soap_init_iht(copy); - soap_init_pht(copy); - copy->header = NULL; - copy->fault = NULL; - copy->action = NULL; - *copy->host = '\0'; -#ifndef WITH_LEAN -#ifdef WITH_COOKIES - copy->cookies = soap_copy_cookies(soap); -#else - copy->cookies = NULL; -#endif - soap_init_logs(copy); -#endif - copy->plugins = NULL; - for (p = soap->plugins; p; p = p->next) - { register struct soap_plugin *q = (struct soap_plugin*)SOAP_MALLOC(sizeof(struct soap_plugin)); - if (!q) - return NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying plugin '%s'\n", p->id)); - *q = *p; - if (p->fcopy && (soap->error = p->fcopy(soap, q, p))) - { SOAP_FREE(q); - return NULL; - } - q->next = copy->plugins; - copy->plugins = q; - } - } - else - soap->error = SOAP_EOM; - return copy; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init(struct soap *soap) -{ soap->version = 1; /* default SOAP 1.1 */ - soap_imode(soap, SOAP_IO_DEFAULT); - soap_omode(soap, SOAP_IO_DEFAULT); - soap->copy = 0; - soap->plugins = NULL; - soap->user = NULL; - soap->userid = NULL; - soap->passwd = NULL; - soap->fpost = http_post; - soap->fget = http_get; - soap->fposthdr = http_post_header; - soap->fresponse = http_response; - soap->fparse = http_parse; - soap->fparsehdr = http_parse_header; - soap->fconnect = NULL; - soap->fdisconnect = NULL; -#ifndef MAC_CARBON - soap->faccept = tcp_accept; - soap->fopen = tcp_connect; - soap->fclose = tcp_disconnect; - soap->fsend = fsend; - soap->frecv = frecv; -#endif - soap->fprepare = NULL; - soap->fignore = NULL; - soap->fplugin = fplugin; - soap->fdimereadopen = NULL; - soap->fdimewriteopen = NULL; - soap->fdimereadclose = NULL; - soap->fdimewriteclose = NULL; - soap->fdimeread = NULL; - soap->fdimewrite = NULL; - soap->float_format = "%.9G"; /* .9G preserves single FP precision, but is not very efficient */ - soap->double_format = "%.18G"; /* .18G preserves double FP precision, but is not very efficient */ - soap->dime_id_format = "cid:id%d"; /* default DIME id format */ - soap->http_version = "1.1"; - soap->encodingStyle = SOAP_STR_EOS; - soap->actor = NULL; - soap->max_keep_alive = SOAP_MAXKEEPALIVE; - soap->keep_alive = 0; - soap->recv_timeout = 0; - soap->send_timeout = 0; - soap->connect_timeout = 0; - soap->accept_timeout = 0; - soap->socket_flags = 0; - soap->connect_flags = 0; - soap->bind_flags = 0; - soap->accept_flags = 0; - soap->ip = 0; -#ifndef WITH_NONAMESPACES - soap->namespaces = namespaces; -#else - soap->namespaces = NULL; -#endif - soap->local_namespaces = NULL; - soap->nlist = NULL; - soap->blist = NULL; - soap->clist = NULL; - soap->alist = NULL; - soap->attributes = NULL; - soap->header = NULL; - soap->fault = NULL; - soap->master = SOAP_INVALID_SOCKET; - soap->socket = SOAP_INVALID_SOCKET; - soap->os = NULL; - soap->is = NULL; - soap->dom = NULL; -#ifndef UNDER_CE - soap->recvfd = 0; - soap->sendfd = 1; -#else - soap->recvfd = stdin; - soap->sendfd = stdout; -#endif - soap->host[0] = '\0'; - soap->port = 0; - soap->action = NULL; - soap->proxy_host = NULL; - soap->proxy_port = 8080; - soap->proxy_userid = NULL; - soap->proxy_passwd = NULL; -#ifdef WITH_OPENSSL - soap->fsslauth = ssl_auth_init; - soap->fsslverify = ssl_verify_callback; - soap->bio = NULL; - soap->ssl = NULL; - soap->ctx = NULL; - soap->require_server_auth = 0; - soap->require_client_auth = 0; - soap->rsa = 0; - soap->keyfile = NULL; - soap->password = NULL; - soap->dhfile = NULL; - soap->cafile = NULL; - soap->capath = NULL; - soap->randfile = NULL; - soap->session = NULL; -#endif -#ifdef WITH_ZLIB - soap->zlib_state = SOAP_ZLIB_NONE; - soap->zlib_in = SOAP_ZLIB_NONE; - soap->zlib_out = SOAP_ZLIB_NONE; - soap->d_stream.zalloc = NULL; - soap->d_stream.zfree = NULL; - soap->d_stream.opaque = NULL; - soap->z_level = 6; -#endif -#ifndef WITH_LEAN - soap->cookies = NULL; - soap->cookie_domain = NULL; - soap->cookie_path = NULL; - soap->cookie_max = 32; - soap_init_logs(soap); -#endif -/* WR[ */ -#ifdef WMW_RPM_IO - soap->rpmreqid = NULL; -#endif /* WMW_RPM_IO */ -/* ]WR */ - soap_init_iht(soap); - soap_init_pht(soap); - soap_begin(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init1(struct soap *soap, int mode) -{ soap_init2(soap, mode, mode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init2(struct soap *soap, int imode, int omode) -{ soap_init(soap); - soap_imode(soap, imode); - soap_omode(soap, omode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_begin(struct soap *soap) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing\n")); - if (!soap->keep_alive) - { soap->buflen = 0; - soap->bufidx = 0; - } - soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0); - soap->null = 0; - soap->position = 0; - soap->encoding = 0; - soap->mustUnderstand = 0; - soap->mode = 0; - soap->ns = 0; - soap->part = SOAP_BEGIN; - soap->alloced = 0; - soap->count = 0; - soap->length = 0; - soap->cdata = 0; - soap->error = SOAP_OK; - soap->peeked = 0; - soap->ahead = 0; - soap->idnum = 0; - soap->level = 0; - soap->endpoint[0] = '\0'; - soap->dime_chunksize = 0; - soap->dime_buflen = 0; - soap->dot_net_bug = 0; - soap_free(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_end(struct soap *soap) -{ register struct soap_clist *cp; - soap_free(soap); - soap_dealloc(soap, NULL); - while (soap->clist) - { cp = soap->clist->next; - SOAP_FREE(soap->clist); - soap->clist = cp; - } - soap_closesock(soap); -#ifndef WITH_LEAN - soap_close_logfiles(soap); -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_namespaces(struct soap *soap, struct Namespace *p) -{ struct Namespace *ns = soap->local_namespaces; - struct soap_nlist *np, *nq, *nr; - unsigned int level = soap->level; - soap->namespaces = p; - soap->local_namespaces = NULL; - soap_set_local_namespaces(soap); - /* reverse the list */ - np = soap->nlist; - soap->nlist = NULL; - if (np) - { nq = np->next; - np->next = NULL; - while (nq) - { nr = nq->next; - nq->next = np; - np = nq; - nq = nr; - } - } - while (np) - { soap->level = np->level; /* preserve element nesting level */ - if (np->ns) - { if (soap_push_namespace(soap, np->id, np->ns)) - return soap->error; - } - else if (np->index >= 0 && ns) - { if (ns[np->index].out) - { if (soap_push_namespace(soap, np->id, ns[np->index].out)) - return soap->error; - } - else if (soap_push_namespace(soap, np->id, ns[np->index].ns)) - return soap->error; - } - if (np->ns) - SOAP_FREE(np->ns); - nq = np; - np = np->next; - SOAP_FREE(nq); - } - if (ns) - { int i; - for (i = 0; ns[i].id; i++) - { if (ns[i].out) - { SOAP_FREE(ns[i].out); - ns[i].out = NULL; - } - } - SOAP_FREE(ns); - } - soap->level = level; /* restore level */ - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static void -soap_set_local_namespaces(struct soap *soap) -{ if (soap->namespaces && !soap->local_namespaces) - { register struct Namespace *ns; - register size_t n = 1; - for (ns = soap->namespaces; ns->id; ns++) - n++; - if (n > 3) - { n *= sizeof(struct Namespace); - ns = (struct Namespace*)SOAP_MALLOC(n); - if (ns) - { memcpy(ns, soap->namespaces, n); - ns[0].id = "SOAP-ENV"; - ns[1].id = "SOAP-ENC"; - ns[2].id = "xsi"; - if (ns[0].ns) - { if (!strcmp(ns[0].ns, soap_env1)) - soap->version = 1; - else - soap->version = 2; - } - soap->local_namespaces = ns; - } - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element(struct soap *soap, const char *tag, int id, const char *type) -{ struct Namespace *ns = soap->local_namespaces; - register const char *s; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element begin tag='%s' id='%d' type='%s'\n", tag, id, type?type:"")); -/**/ -#ifdef WITH_DOM - if (soap->mode & SOAP_XML_DOM) - { register struct soap_dom_element *p, *e = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element)); - e->next = NULL; - e->prnt = soap->dom; - e->nstr = NULL; - e->name = soap_strdup(soap, tag); /* check EOM? */ - e->data = NULL; - e->type = 0; - e->node = NULL; - e->elts = NULL; - e->atts = NULL; - if (soap->dom) - { p = soap->dom->elts; - if (p) - { while (p->next) - p = p->next; - p->next = e; - } - else - soap->dom->elts = e; - } - soap->dom = e; - } - else -#endif -{ - soap->level++; - if (!soap->ns && !(soap->mode & SOAP_XML_CANONICAL)) - if (soap_send(soap, "")) - return soap->error; - if (soap_send_raw(soap, "<", 1)) - return soap->error; - s = tag; - if (ns && soap->part != SOAP_IN_ENVELOPE && (soap->part == SOAP_IN_HEADER || !soap->encodingStyle)) - { register const char *t = strchr(s, ':'); - if (t) - { s = t + 1; - for (ns++; ns->id; ns++) - { if ((ns->out || ns->ns) && !strncmp(ns->id, tag, t - tag) && !ns->id[t - tag]) - { if (soap_send(soap, s) || soap_attribute(soap, "xmlns", ns->out ? ns->out : ns->ns)) - return soap->error; - s = NULL; - break; - } - } - } - } - if (s) - if (soap_send(soap, tag)) - return soap->error; -} -/**/ - if (!soap->ns) - { for (ns = soap->local_namespaces; ns && ns->id; ns++) - { if (*ns->id && (ns->out || ns->ns)) - { sprintf(soap->tmpbuf, "xmlns:%s", ns->id); - if (soap_attribute(soap, soap->tmpbuf, ns->out ? ns->out : ns->ns)) - return soap->error; - } - } - soap->ns = 1; - } - if (id > 0) - { sprintf(soap->tmpbuf, "_%d", id); - if (soap_attribute(soap, "id", soap->tmpbuf)) - return soap->error; - } - if (type && *type) - { if (soap_attribute(soap, "xsi:type", type)) - return soap->error; - } - if (soap->null && soap->position > 0) - { int i; - sprintf(soap->tmpbuf, "[%d", soap->positions[0]); - for (i = 1; i < soap->position; i++) - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), ",%d", soap->positions[i]); - strcat(soap->tmpbuf, "]"); - if (soap_attribute(soap, "SOAP-ENC:position", soap->tmpbuf)) - return soap->error; - } - if (soap->mustUnderstand) - { if (soap->actor && *soap->actor) - { if (soap_attribute(soap, soap->version == 2 ? "SOAP-ENV:role" : "SOAP-ENV:actor", soap->actor)) - return soap->error; - } - if (soap_attribute(soap, "SOAP-ENV:mustUnderstand", soap->version == 2 ? "true" : "1")) - return soap->error; - soap->mustUnderstand = 0; - } - if (soap->encoding) - { if (soap->encodingStyle) - { if (!*soap->encodingStyle && soap->local_namespaces) - { if (soap->local_namespaces[1].out) - soap->encodingStyle = soap->local_namespaces[1].out; - else - soap->encodingStyle = soap->local_namespaces[1].ns; - } - if (soap_attribute(soap, "SOAP-ENV:encodingStyle", soap->encodingStyle)) - return soap->error; - } - soap->encoding = 0; - } - soap->null = 0; - soap->position = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_begin_out(struct soap *soap, const char *tag, int id, const char *type) -{ if (*tag == '-') - return SOAP_OK; - if (soap_element(soap, tag, id, type)) - return soap->error; - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRRCHR -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_strrchr(const char *s, int t) -{ register char *r = NULL; - while (*s) - if (*s++ == t) - r = (char*)s - 1; - return r; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRTOL -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_strtol(const char *s, char **t, int b) -{ register long n = 0; - register int c; - while (*s > 0 && *s <= 32) - s++; - if (b == 10) - { short neg = 0; - if (*s == '-') - { s++; - neg = 1; - } - else if (*s == '+') - s++; - while ((c = *s) && c >= '0' && c <= '9') - { if (n > 214748364) - break; - n *= 10; - n += c - '0'; - s++; - } - if (neg) - n = -n; - } - else /* b == 16 and value is always positive */ - { while ((c = *s)) - { if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'F') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'f') - c -= 'a' - 10; - if (n > 0x07FFFFFF) - break; - n <<= 4; - n += c; - s++; - } - } - if (t) - *t = (char*)s; - return n; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRTOUL -SOAP_FMAC1 -unsigned long -SOAP_FMAC2 -soap_strtoul(const char *s, char **t, int b) -{ unsigned long n = 0; - register int c; - while (*s > 0 && *s <= 32) - s++; - if (b == 10) - { if (*s == '+') - s++; - while ((c = *s) && c >= '0' && c <= '9') - { if (n > 429496729) - break; - n *= 10; - n += c - '0'; - s++; - } - } - else /* b == 16 */ - { while ((c = *s)) - { if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'F') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'f') - c -= 'a' - 10; - if (n > 0x0FFFFFFF) - break; - n <<= 4; - n += c; - s++; - } - } - if (t) - *t = (char*)s; - return n; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_begin_out(struct soap *soap, const char *tag, int id, const char *type, const char *offset) -{ if (soap_element(soap, tag, id, "SOAP-ENC:Array")) - return soap->error; - if (soap->version == 2) - { const char *s; - s = soap_strrchr(type, '['); - if ((size_t)(s - type) < sizeof(soap->tmpbuf)) - { strncpy(soap->tmpbuf, type, s - type); - soap->tmpbuf[s - type] = '\0'; - if (type && *type && (soap_attribute(soap, "SOAP-ENC:itemType", soap->tmpbuf))) - return soap->error; - if (s && (soap_attribute(soap, "SOAP-ENC:arraySize", s + 1))) - return soap->error; - } - } - else - { if (offset && (soap_attribute(soap, "SOAP-ENC:offset", offset))) - return soap->error; - if (type && *type && (soap_attribute(soap, "SOAP-ENC:arrayType", type))) - return soap->error; - } - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_start_end_out(struct soap *soap, const char *tag) -{ register struct soap_attribute *tp; -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible) - { register struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); - a->next = soap->dom->atts; - a->nstr = NULL; - a->name = soap_strdup(soap, tp->name); /* check EOM */ - a->data = soap_strdup(soap, tp->value); /* check EOM */ - a->wide = NULL; - soap->dom->atts = a; - tp->visible = 0; - } - } - return SOAP_OK; - } -#endif -/**/ - for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible) - { if (soap_send_raw(soap, " ", 1) - || soap_send(soap, tp->name)) - return soap->error; - if (tp->visible == 2 && tp->value) - if (soap_send_raw(soap, "=\"", 2) - || soap_string_out(soap, tp->value, 1) - || soap_send_raw(soap, "\"", 1)) - return soap->error; - tp->visible = 0; - } - } - if (tag) - { soap->level--; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { if (soap_send_raw(soap, ">", 1) - || soap_element_end_out(soap, tag)) - return soap->error; - return SOAP_OK; - } -#endif - return soap_send_raw(soap, "/>", 2); - } - return soap_send_raw(soap, ">", 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_end_out(struct soap *soap, const char *tag) -{ if (*tag == '-') - return SOAP_OK; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element ending tag='%s'\n", tag)); -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { if (soap->dom->prnt) - soap->dom = soap->dom->prnt; - return SOAP_OK; - } -#endif -/**/ - if (soap->part != SOAP_IN_ENVELOPE && (soap->part == SOAP_IN_HEADER || !soap->encodingStyle) && soap->local_namespaces) - { const char *s = strchr(tag, ':'); - if (s && strncmp(tag, "SOAP-ENV", s - tag)) - tag = s + 1; - } - soap->level--; - if (soap_send_raw(soap, "", 1)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_ref(struct soap *soap, const char *tag, int id, int href) -{ int n = 0; - if (soap_element(soap, tag, id, NULL)) - return soap->error; - if (soap->version == 2) - n = 1; - sprintf(soap->tmpbuf, "#_%d", href); - if (soap_attribute(soap, "href" + n, soap->tmpbuf + n) - || soap_element_start_end_out(soap, tag)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_href(struct soap *soap, const char *tag, int id, const char *href) -{ if (soap_element(soap, tag, id, NULL) - || soap_attribute(soap, "href", href) - || soap_element_start_end_out(soap, tag)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_null(struct soap *soap, const char *tag, int id, const char *type) -{ struct soap_attribute *tp; - for (tp = soap->attributes; tp; tp = tp->next) - if (tp->visible) - break; - if (tp || (soap->version == 2 && soap->position > 0) || id > 0 || (soap->mode & SOAP_XML_NIL)) - { if (soap_element(soap, tag, id, type)) - return soap->error; - if (soap->part != SOAP_IN_HEADER && soap->encodingStyle) - if (soap_attribute(soap, "xsi:nil", "true")) - return soap->error; - return soap_element_start_end_out(soap, tag); - } - soap->null = 1; - soap->position = 0; - soap->mustUnderstand = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_result(struct soap *soap, const char *tag) -{ if (soap->version == 2 && soap->encodingStyle) - if (soap_element(soap, "SOAP-RPC:result", 0, NULL) - || soap_attribute(soap, "xmlns:SOAP-RPC", soap_rpc) - || soap_element_start_end_out(soap, NULL) - || soap_string_out(soap, tag, 0) - || soap_element_end_out(soap, "SOAP-RPC:result")) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_attribute(struct soap *soap, const char *name, const char *value) -{ -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { register struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); - a->next = soap->dom->atts; - a->nstr = NULL; - a->name = soap_strdup(soap, name); /* check EOM */ - a->data = soap_strdup(soap, value); /* check EOM */ - a->wide = NULL; - soap->dom->atts = a; - return SOAP_OK; - } -#endif -/**/ -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { if (soap_set_attr(soap, name, value)) - return soap->error; - } - else -#endif - { if (soap_send_raw(soap, " ", 1) - || soap_send(soap, name)) - return soap->error; - if (value) - if (soap_send_raw(soap, "=\"", 2) - || soap_string_out(soap, value, 1) - || soap_send_raw(soap, "\"", 1)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_begin_in(struct soap *soap, const char *tag) -{ if (tag && *tag == '-') - return SOAP_OK; - if (!soap_peek_element(soap)) - { if (soap->other) - return soap->error = SOAP_TAG_MISMATCH; - if (!(soap->error = soap_match_tag(soap, soap->tag, tag))) - { if (tag && !soap->encodingStyle) - { const char *s = strchr(tag, ':'); - if (s) - soap_push_default_namespace(soap, tag, s - tag); - } - soap->peeked = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:"" )); - if (soap->body) - soap->level++; - } - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_end_in(struct soap *soap, const char *tag) -{ register wchar c; - register char *s; - register const char *t; - if (tag && *tag == '-') - return SOAP_OK; - soap->level--; - soap_pop_namespace(soap); - if (soap->peeked) - { if (*soap->tag == '\0') - { soap->peeked = 0; - soap->error = SOAP_OK; - } - else - return soap->error = SOAP_SYNTAX_ERROR; - } - else - { while (((c = soap_get(soap)) != TT)) - { if ((int)c == EOF) - return soap->error = SOAP_EOF; - if (c == LT) - return soap->error = SOAP_SYNTAX_ERROR; - } - } - s = soap->tag; - do c = soap_get(soap); - while (soap_blank(c)); - do - { *s++ = (char)c; - c = soap_get(soap); - } while (soap_notblank(c)); - *s = '\0'; - if ((int)c == EOF) - return soap->error = SOAP_EOF; - while (soap_blank(c)) - c = soap_get(soap); - if (c != GT) - return soap->error = SOAP_SYNTAX_ERROR; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:"")); - if (!tag) - return SOAP_OK; - if ((s = strchr(soap->tag, ':'))) - s++; - else - s = soap->tag; - if ((t = strchr(tag, ':'))) - t++; - else - t = tag; - if (!SOAP_STRCMP(s, t)) - return SOAP_OK; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element does not match\n")); - return soap->error = SOAP_SYNTAX_ERROR; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_attribute * -SOAP_FMAC2 -soap_attr(struct soap *soap, const char *name) -{ register struct soap_attribute *tp; - for (tp = soap->attributes; tp; tp = tp->next) - if (!soap_match_tag(soap, tp->name, name)) - return tp; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char * -SOAP_FMAC2 -soap_attr_value(struct soap *soap, const char *name) -{ register struct soap_attribute *tp = soap_attr(soap, name); - if (tp && tp->visible == 2) - return tp->value; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_attr(struct soap *soap, const char *name, const char *value) -{ register struct soap_attribute *tp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set attribute %s='%s'\n", name, value?value:"")); - for (tp = soap->attributes; tp; tp = tp->next) - if (!strcmp(tp->name, name)) - break; - if (!tp) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute %s\n", name)); - if (!(tp = (struct soap_attribute*)SOAP_MALLOC(sizeof(struct soap_attribute) + strlen(name)))) - return soap->error = SOAP_EOM; - tp->ns = NULL; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { struct soap_attribute **tpp = &soap->attributes; - const char *s = strchr(name, ':'); - if (!strncmp(name, "xmlns", 5)) - { for (; *tpp; tpp = &(*tpp)->next) - if (strncmp((*tpp)->name, "xmlns", 5) || strcmp((*tpp)->name + 5, name + 5) > 0) - break; - } - else if (!s) - { for (; *tpp; tpp = &(*tpp)->next) - if (strncmp((*tpp)->name, "xmlns", 5) && ((*tpp)->ns || strcmp((*tpp)->name, name) > 0)) - break; - } - else - { int k; - for (; *tpp; tpp = &(*tpp)->next) - { if (!strncmp((*tpp)->name, "xmlns:", 6) && !strncmp((*tpp)->name + 6, name, s - name) && !(*tpp)->name[6 + s - name]) - { if (!tp->ns) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Canonicalization: prefix %s=%p(%s)\n", name, (*tpp)->ns, (*tpp)->ns)); - tp->ns = (*tpp)->ns; - } - } - else if (strncmp((*tpp)->name, "xmlns", 5) && (*tpp)->ns && tp->ns && ((k = strcmp((*tpp)->ns, tp->ns)) > 0 || (!k && strcmp((*tpp)->name, name) > 0))) - break; - } - } - tp->next = *tpp; - *tpp = tp; - } - else -#endif - { tp->next = soap->attributes; - soap->attributes = tp; - } - strcpy(tp->name, name); - tp->value = NULL; - } - else if (value && tp->value && tp->size <= strlen(value)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free attribute value of %s (free %p)\n", name, tp->value)); - SOAP_FREE(tp->value); - tp->value = NULL; - tp->ns = NULL; - } - if (value) - { if (!tp->value) - { tp->size = strlen(value) + 1; - if (!(tp->value = (char*)SOAP_MALLOC(tp->size))) - return soap->error = SOAP_EOM; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute value of %s (%p)\n", tp->name, tp->value)); - } - strcpy(tp->value, value); - if (!strncmp(tp->name, "xmlns:", 6)) - tp->ns = tp->value; - tp->visible = 2; - } - else - tp->visible = 1; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_attr(struct soap *soap) -{ register struct soap_attribute *tp; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { while (soap->attributes) - { tp = soap->attributes->next; - SOAP_FREE(soap->attributes->value); - SOAP_FREE(soap->attributes); - soap->attributes = tp; - } - } - else -#endif - { for (tp = soap->attributes; tp; tp = tp->next) - tp->visible = 0; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static int -soap_getattrval(struct soap *soap, char *s, size_t n, wchar d) -{ size_t i; - wchar c; - for (i = 0; i < n; i++) - { c = soap_getutf8(soap); - switch (c) - { - case TT: - *s++ = '<'; - soap_unget(soap, '/'); - break; - case LT: - *s++ = '<'; - break; - case GT: - if (d == ' ') - { soap_unget(soap, c); - *s = '\0'; - return SOAP_OK; - } - *s++ = '>'; - break; - case QT: - if (c == d) - { *s = '\0'; - return SOAP_OK; - } - *s++ = '"'; - break; - case AP: - if (c == d) - { *s = '\0'; - return SOAP_OK; - } - *s++ = '\''; - break; - case '\t': - case '\n': - case '\r': - case ' ': - case '/': - if (d == ' ') - { soap_unget(soap, c); - *s = '\0'; - return SOAP_OK; - } - default: - if ((int)c == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - } - return soap->error = SOAP_EOM; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_peek_element(struct soap *soap) -{ struct soap_attribute *tp; - const char *t; - register char *s; - register wchar c; - register int i; - if (soap->peeked) - { if (*soap->tag == '\0') - return soap->error = SOAP_NO_TAG; - return SOAP_OK; - } - soap->peeked = 1; - for (;;) - { while (((c = soap_get(soap)) != LT) && c != TT) - { if ((int)c == EOF) - return soap->error = SOAP_EOF; - } - if (c == TT) - { *soap->tag = '\0'; - return soap->error = SOAP_NO_TAG; /* ending tag found */ - } - s = soap->tag; - do c = soap_get(soap); - while (soap_blank(c)); - i = sizeof(soap->tag); - while (c != '/' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - while (soap_blank(c)) - c = soap_get(soap); - *s = '\0'; - if (*soap->tag != '?') - break; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "XML PI <%s?>\n", soap->tag)); - while ((int)c != EOF && c != GT && c != '?') - { s = soap->tmpbuf; - i = sizeof(soap->tmpbuf) - 2; - while (c != '=' && c != GT && c != '?' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - while (soap_blank(c)) - c = soap_get(soap); - if (c == '=') - { *s++ = '='; - do c = soap_get(soap); - while (soap_blank(c)); - if (c != QT && c != AP) - { soap_unget(soap, c); - c = ' '; /* blank delimiter */ - } - if (soap_getattrval(soap, s, i, c) == SOAP_EOM) - while (soap_getattrval(soap, soap->tmpbuf, sizeof(soap->tmpbuf), c) == SOAP_EOM) - ; - else if (!strcmp(soap->tag, "?xml") && (!soap_tag_cmp(soap->tmpbuf, "encoding=iso-8859-1") || !soap_tag_cmp(soap->tmpbuf, "encoding=latin1"))) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "XML latin1 encoding\n")); - soap->mode |= SOAP_C_LATIN; - } - } - do c = soap_get(soap); - while (soap_blank(c)); - } - } - soap->id[0] = '\0'; - soap->href[0] = '\0'; - soap->type[0] = '\0'; - soap->arrayType[0] = '\0'; - soap->arraySize[0] = '\0'; - soap->arrayOffset[0] = '\0'; - soap->other = 0; - soap->root = -1; - soap->position = 0; - soap->null = 0; - soap->mustUnderstand = 0; - soap_clr_attr(soap); - soap_pop_namespace(soap); - while ((int)c != EOF && c != GT && c != '/') - { s = soap->tmpbuf; - i = sizeof(soap->tmpbuf); - while (c != '=' && c != '/' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - *s = '\0'; - if (i == sizeof(soap->tmpbuf)) - return soap->error = SOAP_SYNTAX_ERROR; - if (!strncmp(soap->tmpbuf, "xmlns:", 6)) - { soap->tmpbuf[5] = '\0'; - t = soap->tmpbuf + 6; - } - else if (!strcmp(soap->tmpbuf, "xmlns")) - t = SOAP_STR_EOS; - else - t = NULL; - tp = soap_attr(soap, soap->tmpbuf); - if (!tp) - { tp = (struct soap_attribute*)SOAP_MALLOC(sizeof(struct soap_attribute) + strlen(soap->tmpbuf)); - if (!tp) - return soap->error = SOAP_EOM; - strcpy(tp->name, soap->tmpbuf); - tp->value = NULL; - tp->size = 0; - tp->next = soap->attributes; - soap->attributes = tp; - } - while (soap_blank(c)) - c = soap_get(soap); - if (c == '=') - { do c = soap_get(soap); - while (soap_blank(c)); - if (c != QT && c != AP) - { soap_unget(soap, c); - c = ' '; /* blank delimiter */ - } - if (soap_getattrval(soap, tp->value, tp->size, c)) - { size_t size; - if (soap->error == SOAP_EOM) - soap->error = SOAP_OK; - else - return soap->error; - if (soap_new_block(soap)) - return soap->error; - for (;;) - { if (!(s = (char*)soap_push_block(soap, SOAP_BLKLEN))) - return soap->error; - if (soap_getattrval(soap, s, SOAP_BLKLEN, c)) - { if (soap->error == SOAP_EOM) - soap->error = SOAP_OK; - else - return soap->error; - } - else - break; - } - size = tp->size + soap->blist->size; - if (!(s = (char*)SOAP_MALLOC(size))) - return soap->error = SOAP_EOM; - soap_save_block(soap, s + tp->size); - if (tp->value) - { memcpy(s, tp->value, tp->size); - SOAP_FREE(tp->value); - } - tp->value = s; - tp->size = size; - } - do c = soap_get(soap); - while (soap_blank(c)); - tp->visible = 2; /* seen this attribute w/ value */ - } - else - tp->visible = 1; /* seen this attribute w/o value */ - if (t && tp->value) - { if (soap_push_namespace(soap, t, tp->value)) - return soap->error; - tp->visible = 0; - } - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible && tp->value) - { if (!strcmp(tp->name, "id")) - { if (soap->part != SOAP_IN_HEADER || !soap->dot_net_bug) - { *soap->id = '#'; - strncpy(soap->id + 1, tp->value, sizeof(soap->id) - 2); - } - } - else if (!strcmp(tp->name, "href")) - strncpy(soap->href, tp->value, sizeof(soap->href) - 1); - else if (soap->version == 2 && !strcmp(tp->name, "ref")) - { *soap->href = '#'; - strncpy(soap->href + 1, tp->value, sizeof(soap->href) - 2); - } - else if (!soap_match_tag(soap, tp->name, "xsi:type")) - strncpy(soap->type, tp->value, sizeof(soap->type) - 1); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:arrayType")) - { s = soap_strrchr(tp->value, '['); - if (s && (size_t)(s - tp->value) < sizeof(soap->arrayType)) - { strncpy(soap->arrayType, tp->value, s - tp->value); - soap->arrayType[s - tp->value] = '\0'; - strncpy(soap->arraySize, s, sizeof(soap->arraySize) - 1); - } - else - strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType) - 1); - } - else if (soap->version == 2 && !soap_match_tag(soap, tp->name, "SOAP-ENC:itemType")) - strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType) - 1); - else if (soap->version == 2 && !soap_match_tag(soap, tp->name, "SOAP-ENC:arraySize")) - strncpy(soap->arraySize, tp->value, sizeof(soap->arraySize) - 1); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:offset")) - strncpy(soap->arrayOffset, tp->value, sizeof(soap->arrayOffset)); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:position")) - soap->position = soap_getposition(tp->value, soap->positions); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:root")) - soap->root = ((!strcmp(tp->value, "1") || !strcmp(tp->value, "true"))); - else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:actor") - || !soap_match_tag(soap, tp->name, "SOAP-ENV:role")) - { if ((!soap->actor || strcmp(soap->actor, tp->value)) - && strcmp(tp->value, "http://schemas.xmlsoap.org/soap/actor/next") - && strcmp(tp->value, "http://www.w3.org/2003/05/soap-envelope/role/next")) - soap->other = 1; - } - else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:mustUnderstand") - && (!strcmp(tp->value, "1") || !strcmp(tp->value, "true"))) - soap->mustUnderstand = 1; - else if ((!soap_match_tag(soap, tp->name, "xsi:null") - || !soap_match_tag(soap, tp->name, "xsi:nil")) - && (!strcmp(tp->value, "1") - || !strcmp(tp->value, "true"))) - soap->null = 1; - } - } - if (!(soap->body = (c != '/'))) - do c = soap_get(soap); - while (soap_blank(c)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_retry(struct soap *soap) -{ soap->peeked = 1; - soap->error = SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_revert(struct soap *soap) -{ soap->peeked = 1; - if (soap->body) - soap->level--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reverting last element (level=%u)\n", soap->level)); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_string_out(struct soap *soap, const char *s, int flag) -{ register const char *t; - register wchar c; - register wchar mask = 0x80000000; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->data = soap_strdup(soap, s); /* check EOM */ - return SOAP_OK; - } -#endif - if (soap->mode & SOAP_C_UTFSTRING) - mask = 0; - t = s; - while ((c = *t++)) - { switch (c) - { - case 9: - if (flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - } - break; - case 10: - if (flag || !(soap->mode & SOAP_XML_CANONICAL)) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - } - break; - case 13: - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - break; - case '&': - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&", 5)) - return soap->error; - s = t; - break; - case '<': - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "<", 4)) - return soap->error; - s = t; - break; - case '>': - if (!flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, ">", 4)) - return soap->error; - s = t; - } - break; - case '"': - if (flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, """, 6)) - return soap->error; - s = t; - } - break; - default: - if (c & mask) - { if (soap_send_raw(soap, s, t - s - 1) || soap_pututf8(soap, (unsigned char)c)) - return soap->error; - s = t; - } - } - } - return soap_send_raw(soap, s, t - s - 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_string_in(struct soap *soap, int flag) -{ register char *s; - char *t = NULL; - register int i, n = 0; - register wchar c; - char buf[8]; - if (soap_new_block(soap)) - return NULL; -#ifdef WITH_CDATA - if (!flag) - { register int state = 0; /* 0 = normal, 1 = CDATA, 2 = comment, 3 = PI */ - for (;;) - { if (!(s = (char*)soap_push_block(soap, SOAP_BLKLEN))) - return NULL; - for (i = 0; i < SOAP_BLKLEN; i++) - { if (t) - { *s++ = *t++; - if (!*t) - t = NULL; - continue; - } - c = soap_getchar(soap); - if ((int)c == EOF) - goto end; - if (c >= 0x80 && !(soap->mode & SOAP_C_LATIN)) - { soap_unget(soap, c); - c = soap_getutf8(soap); - if (soap->mode & SOAP_C_UTFSTRING) - { if ((c & 0x80000000) && c >= -0x7FFFFF80 && c < AP) - { c &= 0x7FFFFFFF; - t = buf; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - *t = '\0'; - t = buf; - *s++ = *t++; - continue; - } - } - } - switch (state) - { case 1: - if (c == ']') - state = 4; - *s++ = c; - continue; - case 2: - if (c == '-') - state = 6; - *s++ = c; - continue; - case 3: - if (c == '?') - state = 8; - *s++ = c; - continue; - /* CDATA */ - case 4: - if (c == ']') - state = 5; - else - state = 1; - *s++ = c; - continue; - case 5: - if (c == '>') - state = 0; - else - state = 1; - *s++ = c; - continue; - /* comment */ - case 6: - if (c == '-') - state = 7; - else - state = 2; - *s++ = c; - continue; - case 7: - if (c == '>') - state = 0; - else - state = 2; - *s++ = c; - continue; - /* PI */ - case 8: - if (c == '>') - state = 0; - else - state = 3; - *s++ = c; - continue; - } - switch (c) - { - case '/': - if (n > 0) - { c = soap_get1(soap); - if (c == '>') - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<': - c = soap_get1(soap); - if (c == '/') - { if (n == 0) - { c = TT; - goto end; - } - n--; - } - else if (c == '!') - { c = soap_get1(soap); - if (c == '[') - { do c = soap_get1(soap); - while ((int)c != EOF && c != '['); - if ((int)c == EOF) - goto end; - t = (char*)"![CDATA["; - state = 1; - } - else if (c == '-') - { if ((c = soap_get1(soap)) == '-') - state = 2; - t = (char*)"!-"; - soap_unget(soap, c); - } - else - { t = (char*)"!"; - soap_unget(soap, c); - } - *s++ = '<'; - break; - } - else if (c == '?') - state = 3; - else - n++; - soap_unget(soap, c); - *s++ = '<'; - break; - case '>': - *s++ = '>'; - break; - case '"': - *s++ = '"'; - break; - default: - *s++ = (char)(c & 0xFF); - } - } - } - } -#endif - for (;;) - { if (!(s = (char*)soap_push_block(soap, SOAP_BLKLEN))) - return NULL; - for (i = 0; i < SOAP_BLKLEN; i++) - { if (t) - { *s++ = *t++; - if (!*t) - t = NULL; - continue; - } - if (soap->mode & SOAP_C_UTFSTRING) - { if (((c = soap_get(soap)) & 0x80000000) && c >= -0x7FFFFF80 && c < AP) - { c &= 0x7FFFFFFF; - t = buf; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - *t = '\0'; - t = buf; - *s++ = *t++; - continue; - } - } - else if (soap->mode & SOAP_C_LATIN) - c = soap_get(soap); - else - c = soap_getutf8(soap); - switch (c) - { - case TT: - if (n == 0) - goto end; - n--; - *s++ = '<'; - soap_unget(soap, '/'); - break; - case LT: - n++; - *s++ = '<'; - break; - case GT: - *s++ = '>'; - break; - case QT: - *s++ = '"'; - break; - case AP: - *s++ = '\''; - break; - case '/': - if (n > 0) - { c = soap_get(soap); - if (c == GT) - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<': - if (flag) - *s++ = '<'; - else - { *s++ = '&'; - t = (char*)"lt;"; - } - break; - case '>': - if (flag) - *s++ = '>'; - else - { *s++ = '&'; - t = (char*)"gt;"; - } - break; - case '"': - if (flag) - *s++ = '"'; - else - { *s++ = '&'; - t = (char*)"quot;"; - } - break; - default: - if ((int)c == EOF) - goto end; - *s++ = (char)(c & 0xFF); - } - } - } -end: - soap_unget(soap, c); - *s = '\0'; - soap_size_block(soap, i+1); - t = soap_save_block(soap, NULL); - if (flag == 2) - if (soap_s2QName(soap, t, &t)) - return NULL; - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_wstring_out(struct soap *soap, const wchar_t *s, int flag) -{ const char *t; - char tmp; - register wchar c; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->wide = NULL; /* soap_malloc() ??? */ - return SOAP_OK; - } -#endif - while ((c = *s++)) - { switch (c) - { - case 9: - if (flag) - t = " "; - else - t = "\t"; - break; - case 10: - if (flag || !(soap->mode & SOAP_XML_CANONICAL)) - t = " "; - else - t = "\n"; - break; - case 13: - t = " "; - break; - case '&': - t = "&"; - break; - case '<': - t = "<"; - break; - case '>': - if (flag) - t = ">"; - else - t = ">"; - break; - case '"': - if (flag) - t = """; - else - t = "\""; - break; - default: - if (c > 0 && c < 0x80) - { tmp = (char)c; - if (soap_send_raw(soap, &tmp, 1)) - return soap->error; - } - else if (soap_pututf8(soap, (unsigned long)c)) - return soap->error; - continue; - } - if (soap_send(soap, t)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t * -SOAP_FMAC2 -soap_wstring_in(struct soap *soap, int flag) -{ wchar_t *s; - register int i, n = 0; - register wchar c; - const char *t = NULL; - if (soap_new_block(soap)) - return NULL; - for (;;) - { if (!(s = (wchar_t*)soap_push_block(soap, sizeof(wchar_t)*SOAP_BLKLEN))) - return NULL; - for (i = 0; i < SOAP_BLKLEN; i++) - { if (t) - { *s++ = (wchar_t)*t++; - if (!*t) - t = NULL; - continue; - } - if (soap->mode & SOAP_C_LATIN) - c = soap_get(soap); - else - c = soap_getutf8(soap); - switch (c) - { - case TT: - if (n == 0) - goto end; - n--; - *s++ = '<'; - soap_unget(soap, '/'); - break; - case LT: - n++; - *s++ = '<'; - break; - case GT: - *s++ = '>'; - break; - case QT: - *s++ = '"'; - break; - case AP: - *s++ = '\''; - break; - case '/': - if (n > 0) - { c = soap_getutf8(soap); - if (c == GT) - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<': - if (flag) - *s++ = (wchar)'<'; - else - { *s++ = (wchar)'&'; - t = "lt;"; - } - break; - case '>': - if (flag) - *s++ = (wchar)'>'; - else - { *s++ = (wchar)'&'; - t = "gt;"; - } - break; - case '"': - if (flag) - *s++ = (wchar)'"'; - else - { *s++ = (wchar)'&'; - t = "quot;"; - } - break; - default: - if ((int)c == EOF) - goto end; - *s++ = (wchar_t)c & 0x7FFFFFFF; - } - } - } -end: - soap_unget(soap, c); - *s = '\0'; - soap_size_block(soap, sizeof(wchar_t) * (i + 1)); - return (wchar_t*)soap_save_block(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_int2s(struct soap *soap, int n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outint(struct soap *soap, const char *tag, int id, const int *p, const char *type, int n) -{ long m = (long)*p; - return soap_outlong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2int(struct soap *soap, const char *s, int *p) -{ if (s) - { char *r; - *p = (int)soap_strtol(s, &r, 10); - if (*r) - return soap->error = SOAP_TYPE; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int * -SOAP_FMAC2 -soap_inint(struct soap *soap, const char *tag, int *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - if (soap->body && !*soap->href) - { p = (int*)soap_id_enter(soap, soap->id, p, t, sizeof(int), 0); - if (!p || soap_s2int(soap, soap_value(soap), p)) - return NULL; - } - else - p = (int*)soap_id_forward(soap, soap->href, p, t, sizeof(int)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_long2s(struct soap *soap, long n) -{ sprintf(soap->tmpbuf, "%ld", n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outlong(struct soap *soap, const char *tag, int id, const long *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_long2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2long(struct soap *soap, const char *s, long *p) -{ if (s) - { char *r; - *p = soap_strtol(s, &r, 10); - if (*r) - return soap->error = SOAP_TYPE; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -long * -SOAP_FMAC2 -soap_inlong(struct soap *soap, const char *tag, long *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - if (soap->body && !*soap->href) - { p = (long*)soap_id_enter(soap, soap->id, p, t, sizeof(long), 0); - if (!p || soap_s2long(soap, soap_value(soap), p)) - return NULL; - } - else - p = (long*)soap_id_forward(soap, soap->href, p, t, sizeof(long)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_LONG642s(struct soap *soap, LONG64 n) -{ sprintf(soap->tmpbuf, SOAP_LONG_FORMAT, n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outLONG64(struct soap *soap, const char *tag, int id, const LONG64 *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_LONG642s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2LONG64(struct soap *soap, const char *s, LONG64 *p) -{ if (s && sscanf(s, SOAP_LONG_FORMAT, p) != 1) - return soap->error = SOAP_TYPE; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -LONG64 * -SOAP_FMAC2 -soap_inLONG64(struct soap *soap, const char *tag, LONG64 *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":integer") - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":negativeInteger") - && soap_match_tag(soap, soap->type, ":nonPositiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":long") - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - if (soap->body && !*soap->href) - { p = (LONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(LONG64), 0); - if (!p || soap_s2LONG64(soap, soap_value(soap), p)) - return NULL; - } - else - p = (LONG64*)soap_id_forward(soap, soap->href, p, t, sizeof(LONG64)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_byte2s(struct soap *soap, char n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outbyte(struct soap *soap, const char *tag, int id, const char *p, const char *type, int n) -{ long m = (long)*p; - return soap_outlong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2byte(struct soap *soap, const char *s, char *p) -{ if (s) - { long n; - char *r; - n = soap_strtol(s, &r, 10); - if (*r || n < -128 || n > 127) - return soap->error = SOAP_TYPE; - *p = (char)n; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_inbyte(struct soap *soap, const char *tag, char *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - if (soap->body && !*soap->href) - { p = (char*)soap_id_enter(soap, soap->id, p, t, sizeof(char), 0); - if (!p || soap_s2byte(soap, soap_value(soap), p)) - return NULL; - } - else - p = (char*)soap_id_forward(soap, soap->href, p, t, sizeof(char)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_short2s(struct soap *soap, short n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outshort(struct soap *soap, const char *tag, int id, const short *p, const char *type, int n) -{ long m = (long)*p; - return soap_outlong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2short(struct soap *soap, const char *s, short *p) -{ if (s) - { long n; - char *r; - n = soap_strtol(s, &r, 10); - if (*r || n < -32768 || n > 32767) - return soap->error = SOAP_TYPE; - *p = (char)n; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -short * -SOAP_FMAC2 -soap_inshort(struct soap *soap, const char *tag, short *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - if (soap->body && !*soap->href) - { p = (short*)soap_id_enter(soap, soap->id, p, t, sizeof(short), 0); - if (!p || soap_s2short(soap, soap_value(soap), p)) - return NULL; - } - else - p = (short*)soap_id_forward(soap, soap->href, p, t, sizeof(short)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_float2s(struct soap *soap, float n) -{ const char *s; - if (isnan(n)) - s = "NaN"; - else if (n >= FLT_PINFTY) - s = "INF"; - else if (n <= FLT_NINFTY) - s = "-INF"; - else - { sprintf(soap->tmpbuf, soap->float_format, n); - s = soap->tmpbuf; - } - return s; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outfloat(struct soap *soap, const char *tag, int id, const float *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_float2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2float(struct soap *soap, const char *s, float *p) -{ if (s) - { if (!soap_tag_cmp(s, "INF")) - *p = FLT_PINFTY; - else if (!soap_tag_cmp(s, "+INF")) - *p = FLT_PINFTY; - else if (!soap_tag_cmp(s, "-INF")) - *p = FLT_NINFTY; - else if (!soap_tag_cmp(s, "NaN")) - *p = FLT_NAN; - else - { -#ifdef HAVE_STRTOD - char *r; - *p = (float)strtod(s, &r); - if (*r) -#endif - if (sscanf(s, soap->float_format, p) != 1) - return soap->error = SOAP_TYPE; - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static int soap_isnumeric(struct soap *soap, const char *type) -{ if (soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":float") - && soap_match_tag(soap, soap->type, ":double") - && soap_match_tag(soap, soap->type, ":decimal") - && soap_match_tag(soap, soap->type, ":integer") - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":negativeInteger") - && soap_match_tag(soap, soap->type, ":nonPositiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":long") - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte") - && soap_match_tag(soap, soap->type, ":unsignedLong") - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return SOAP_ERR; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -float * -SOAP_FMAC2 -soap_infloat(struct soap *soap, const char *tag, float *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type != '\0' && soap_isnumeric(soap, type)) - return NULL; - if (soap->body && !*soap->href) - { p = (float*)soap_id_enter(soap, soap->id, p, t, sizeof(float), 0); - if (!p || soap_s2float(soap, soap_value(soap), p)) - return NULL; - } - else - p = (float*)soap_id_forward(soap, soap->href, p, t, sizeof(float)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_double2s(struct soap *soap, double n) -{ const char *s; - if (isnan(n)) - s = "NaN"; - else if (n >= DBL_PINFTY) - s = "INF"; - else if (n <= DBL_NINFTY) - s = "-INF"; - else - { sprintf(soap->tmpbuf, soap->double_format, n); - s = soap->tmpbuf; - } - return s; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outdouble(struct soap *soap, const char *tag, int id, const double *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_double2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2double(struct soap *soap, const char *s, double *p) -{ if (s) - { if (!soap_tag_cmp(s, "INF")) - *p = DBL_PINFTY; - else if (!soap_tag_cmp(s, "+INF")) - *p = DBL_PINFTY; - else if (!soap_tag_cmp(s, "-INF")) - *p = DBL_NINFTY; - else if (!soap_tag_cmp(s, "NaN")) - *p = DBL_NAN; - else - { -#ifdef HAVE_STRTOD - char *r; - *p = strtod(s, &r); - if (*r) -#endif - if (sscanf(s, soap->double_format, p) != 1) - return soap->error = SOAP_TYPE; - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -double * -SOAP_FMAC2 -soap_indouble(struct soap *soap, const char *tag, double *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type != '\0' && soap_isnumeric(soap, type)) - return NULL; - if (soap->body && !*soap->href) - { p = (double*)soap_id_enter(soap, soap->id, p, t, sizeof(double), 0); - if (!p || soap_s2double(soap, soap_value(soap), p)) - return NULL; - } - else - p = (double*)soap_id_forward(soap, soap->href, p, t, sizeof(double)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedByte2s(struct soap *soap, unsigned char n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedByte(struct soap *soap, const char *tag, int id, const unsigned char *p, const char *type, int n) -{ unsigned long m = (unsigned long)*p; - return soap_outunsignedLong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedByte(struct soap *soap, const char *s, unsigned char *p) -{ if (s) - { unsigned long n; - char *r; - n = soap_strtoul(s, &r, 10); - if (*r || n > 255) - return soap->error = SOAP_TYPE; - *p = (unsigned char)n; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned char * -SOAP_FMAC2 -soap_inunsignedByte(struct soap *soap, const char *tag, unsigned char *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - if (soap->body && !*soap->href) - { p = (unsigned char*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned char), 0); - if (!p || soap_s2unsignedByte(soap, soap_value(soap), p)) - return NULL; - } - else - p = (unsigned char*)soap_id_forward(soap, soap->href, p, t, sizeof(unsigned char)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedShort2s(struct soap *soap, unsigned short n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedShort(struct soap *soap, const char *tag, int id, const unsigned short *p, const char *type, int n) -{ unsigned long m = (unsigned long)*p; - return soap_outunsignedLong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedShort(struct soap *soap, const char *s, unsigned short *p) -{ if (s) - { unsigned long n; - char *r; - n = soap_strtoul(s, &r, 10); - if (*r || n > 65535) - return soap->error = SOAP_TYPE; - *p = (unsigned short)n; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -unsigned short * -SOAP_FMAC2 -soap_inunsignedShort(struct soap *soap, const char *tag, unsigned short *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - if (soap->body && !*soap->href) - { p = (unsigned short*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned short), 0); - if (!p || soap_s2unsignedShort(soap, soap_value(soap), p)) - return NULL; - } - else - p = (unsigned short*)soap_id_forward(soap, soap->href, p, t, sizeof(unsigned short)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedInt2s(struct soap *soap, unsigned int n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedInt(struct soap *soap, const char *tag, int id, const unsigned int *p, const char *type, int n) -{ unsigned long m = (unsigned long)*p; - return soap_outunsignedLong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedInt(struct soap *soap, const char *s, unsigned int *p) -{ if (s) - { char *r; - *p = (unsigned int)soap_strtoul(s, &r, 10); - if (*r) - return soap->error = SOAP_TYPE; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned int * -SOAP_FMAC2 -soap_inunsignedInt(struct soap *soap, const char *tag, unsigned int *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - if (soap->body && !*soap->href) - { p = (unsigned int*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned int), 0); - if (!p || soap_s2unsignedInt(soap, soap_value(soap), p)) - return NULL; - } - else - p = (unsigned int*)soap_id_forward(soap, soap->href, p, t, sizeof(unsigned int)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedLong2s(struct soap *soap, unsigned long n) -{ sprintf(soap->tmpbuf, "%lu", n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedLong(struct soap *soap, const char *tag, int id, const unsigned long *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_unsignedLong2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedLong(struct soap *soap, const char *s, unsigned long *p) -{ if (s) - { char *r; - *p = soap_strtoul(s, &r, 10); - if (*r) - return soap->error = SOAP_TYPE; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned long * -SOAP_FMAC2 -soap_inunsignedLong(struct soap *soap, const char *tag, unsigned long *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - if (soap->body && !*soap->href) - { p = (unsigned long*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned long), 0); - if (!p || soap_s2unsignedLong(soap, soap_value(soap), p)) - return NULL; - } - else - p = (unsigned long*)soap_id_forward(soap, soap->href, p, t, sizeof(unsigned long)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_ULONG642s(struct soap *soap, ULONG64 n) -{ sprintf(soap->tmpbuf, SOAP_ULONG_FORMAT, n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outULONG64(struct soap *soap, const char *tag, int id, const ULONG64 *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_ULONG642s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2ULONG64(struct soap *soap, const char *s, ULONG64 *p) -{ if (s && sscanf(s, SOAP_ULONG_FORMAT, p) != 1) - return soap->error = SOAP_TYPE; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -ULONG64 * -SOAP_FMAC2 -soap_inULONG64(struct soap *soap, const char *tag, ULONG64 *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":unsignedLong") - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - if (soap->body && !*soap->href) - { p = (ULONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(ULONG64), 0); - if (!p || soap_s2ULONG64(soap, soap_value(soap), p)) - return NULL; - } - else - p = (ULONG64*)soap_id_forward(soap, soap->href, p, t, sizeof(ULONG64)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2string(struct soap *soap, const char *s, char **t) -{ *t = NULL; - if (s && !(*t = soap_strdup(soap, s))) - return soap->error = SOAP_EOM; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2QName(struct soap *soap, const char *s, char **t) -{ if (s) - { struct soap_nlist *np = soap->nlist; - const char *p = strchr(s, ':'); - if (p) - { int n = p - s; - while (np && (np->index == -2 || strncmp(np->id, s, n) || np->id[n])) - np = np->next; - p++; - } - else - { while (np && *np->id) - np = np->next; - p = s; - } - if (np) - { if (np->index >= 0 && soap->local_namespaces) - { const char *q = soap->local_namespaces[np->index].id; - if (q) - { if ((*t = (char*)soap_malloc(soap, strlen(p) + strlen(q) + 2))) - sprintf(*t, "%s:%s", q, p); - return SOAP_OK; - } - } - if (np->ns) - { if ((*t = (char*)soap_malloc(soap, strlen(p) + strlen(np->ns) + 4))) - sprintf(*t, "\"%s\":%s", np->ns, p); - return SOAP_OK; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Namespace prefix of '%s' not defined (index=%d, URI=%s)\n", s, np->index, np->ns?np->ns:"")); - return soap->error = SOAP_NAMESPACE; - } - if (soap->mode & SOAP_XML_STRICT) - return soap->error = SOAP_NAMESPACE; - *t = soap_strdup(soap, s); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_QName2s(struct soap *soap, const char *s) -{ struct Namespace *p; - char *t; - int i; - if (!s || *s != '"') - return s; - s++; - if ((p = soap->local_namespaces)) - { for (i = 0; p->id; p++, i++) - { if (p->ns) - if (!soap_tag_cmp(s, p->ns)) - break; - if (p->in) - if (!soap_tag_cmp(s, p->in)) - break; - } - if (p && p->id) - { s = strchr(s, '"'); - if (s) - { t = (char*)soap_malloc(soap, strlen(p->id) + strlen(s)); - strcpy(t, p->id); - strcat(t, s + 1); - return t; - } - } - } - t = (char*)strchr(s, '"'); - if (t) - i = t - s; - else - i = 0; - t = soap_strdup(soap, s); - t[i] = '\0'; - sprintf(soap->tmpbuf, "xmlns:_%lu", soap->idnum++); - soap_set_attr(soap, soap->tmpbuf, t); - s = strchr(s, '"'); - if (s) - { t = (char*)soap_malloc(soap, strlen(soap->tmpbuf) + strlen(s) - 6); - strcpy(t, soap->tmpbuf + 6); - strcat(t, s + 1); - } - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outstring(struct soap *soap, const char *tag, int id, char *const*p, const char *type, int n) -{ if (!*p) - { if (soap_element_null(soap, tag, id, type)) - return soap->error; - } - else - { struct soap_plist *pp; - int i = soap_pointer_lookup(soap, *p, n, &pp); - if (id > 0) - { if (i) - { if (soap_element_begin_out(soap, tag, id, type) || soap_string_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - soap_set_embedded(soap, pp); - } - else - { i = soap_pointer_enter(soap, *p, n, &pp); - if (soap_element_begin_out(soap, tag, id, type) || soap_string_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 0; - else - pp->mark2 = 0; - } - } - else if (i) - { if (soap_is_embedded(soap, pp)) - { if (soap_element_ref(soap, tag, 0, i)) - return soap->error; - } - else if (soap_is_single(soap, pp)) - { if (soap_element_begin_out(soap, tag, 0, type) || soap_string_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - } - else - { if (soap_element_begin_out(soap, tag, i, type) || soap_string_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - soap_set_embedded(soap, pp); - } - } - else - { soap_pointer_enter(soap, *p, n, &pp); - if (soap_element_begin_out(soap, tag, id, type) || soap_string_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 0; - else - pp->mark2 = 0; - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char ** -SOAP_FMAC2 -soap_instring(struct soap *soap, const char *tag, char **p, const char *type, int t, int flag) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { p = (char**)soap_id_enter(soap, soap->id, p, t, sizeof(char**), 0); - if (p) - *p = NULL; - } - else if (soap->body && !*soap->href) - { if (soap_match_tag(soap, soap->type, "PointerTostring") == 0) - { p = (char**)soap_id_enter(soap, soap->id, p, t, sizeof(char**), 0); - p = (char**)soap_instring(soap, "string", p, type, t, flag); - } - else - { if (!p) - if ((p = (char**)soap_id_enter(soap, SOAP_STR_EOS, p, t, sizeof(char**), 0)) == NULL) - return NULL; - *p = (char*)soap_id_enter(soap, soap->id, soap_string_in(soap, flag), t, 0, 0); - } - } - else - p = (char**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(char*), 0); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outwstring(struct soap *soap, const char *tag, int id, wchar_t *const*p, const char *type, int n) -{ if (!*p) - { if (soap_element_null(soap, tag, id, type)) - return soap->error; - } - else - { struct soap_plist *pp; - int i = soap_pointer_lookup(soap, *p, n, &pp); - if (id > 0) - { if (i) - { if (soap_element_begin_out(soap, tag, id, type) || soap_wstring_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - soap_set_embedded(soap, pp); - } - else - { i = soap_pointer_enter(soap, *p, n, &pp); - if (soap_element_begin_out(soap, tag, id, type) || soap_wstring_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 0; - else - pp->mark2 = 0; - } - } - else if (i) - { if (soap_is_embedded(soap, pp)) - { if (soap_element_ref(soap, tag, 0, i)) - return soap->error; - } - else if (soap_is_single(soap, pp)) - { if (soap_element_begin_out(soap, tag, 0, type) || soap_wstring_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - } - else - { if (soap_element_begin_out(soap, tag, i, type) || soap_wstring_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - soap_set_embedded(soap, pp); - } - } - else - { if (soap_element_begin_out(soap, tag, id, type) || soap_wstring_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 0; - else - pp->mark2 = 0; - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t ** -SOAP_FMAC2 -soap_inwstring(struct soap *soap, const char *tag, wchar_t **p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { p = (wchar_t**)soap_id_enter(soap, soap->id, p, t, sizeof(wchar_t**), 0); - if (p) - *p = NULL; - } - else if (soap->body && !*soap->href) - { if (soap_match_tag(soap, soap->type, "PointerTostring") == 0) - p = (wchar_t**)soap_inwstring(soap, "string", (wchar_t**)soap_id_enter(soap, soap->id, p, t, sizeof(wchar_t**), 0), type, t); - else - { if (!p) - if (!(p = (wchar_t**)soap_id_enter(soap, SOAP_STR_EOS, p, t, sizeof(wchar_t**), 0))) - return NULL; - *p = (wchar_t*)soap_id_enter(soap, soap->id, soap_wstring_in(soap, 1), t, 0, 0); - } - } - else - p = (wchar_t**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(wchar_t*), 0); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static time_t -soap_timegm(struct tm *T) -{ -#if defined(HAVE_TIMEGM) - return timegm(T); -#elif defined(HAVE_GETTIMEOFDAY) - struct timezone t; - gettimeofday(NULL, &t); /* doesn't work properly on Solaris */ - T->tm_min -= t.tz_minuteswest; - T->tm_isdst = (t.tz_dsttime != 0); - return mktime(T); -/* WR[ */ - /* The following define was added for VxWorks*/ -#elif defined(HAVE_MKTIME) - /* FOR VXWORKS: - vxWorks does not seem to have any variable representation of time zones, but - timezone information can be set in INSTALL_DIR/target/h/private/timeP.h header - file, by setting the ZONEBUFFER define. The ZONEBUFFER define follows this - format: - - name_of_zone:<(unused)>:time_in_minutes_from_UTC:daylight_start:daylight_end - - To calculate local time, the value of time_in_minutes_from_UTC is subtracted - from UTC; time_in_minutes_from_UTC must be positive. Daylight information is - expressed as mmddhh (month-day-hour), for example: - - UTC::0:040102:100102 - - */ - return mktime(T); -/* ]WR */ -#elif defined(HAVE_FTIME) - struct timeb t; - t.timezone = 0; - t.dstflag = -1; - ftime(&t); - T->tm_min -= t.timezone; - T->tm_isdst = t.dstflag; /* doesn't work properly on Solaris */ - return mktime(T); -#else -#warning "time_t (de)serialization is not MT safe on this platform" - time_t t; - char *tz = getenv("TZ"); - putenv("TZ=UTC"); - tzset(); - t = mktime(T); - if (tz) - { char tmp[16]; - strcpy(tmp, "TZ="); - strncat(tmp, tz, 12); - tmp[15] = '\0'; - putenv(tmp); - } - else - putenv("TZ="); - tzset(); - return t; -#endif -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_dateTime2s(struct soap *soap, time_t n) -{ struct tm T; - struct tm *pT = &T; -#if defined(HAVE_GMTIME_R) - if (gmtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PGMTIME_R) - if (gmtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -#elif defined(HAVE_PGMTIME) - if (gmtime(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -/* ]WR */ -#elif defined(HAVE_GMTIME) - if ((pT = gmtime(&n))) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -#elif defined(HAVE_GETTIMEOFDAY) - struct timezone t; -#if defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - { gettimeofday(NULL, &t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.tz_minuteswest/60-(t.tz_dsttime!=0), abs(t.tz_minuteswest)%60); - } -#else - if ((pT = localtime(&n))) - { gettimeofday(NULL, &t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.tz_minuteswest/60-(t.tz_dsttime!=0), abs(t.tz_minuteswest)%60); - } -#endif -#elif defined(HAVE_FTIME) - struct timeb t; -#if defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - { ftime(&t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60-(t.dstflag!=0), abs(t.timezone)%60); - } -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PLOCALTIME_R) - if (localtime_r(&n, pT)) - { strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf+strlen(soap->tmpbuf), "%+03d:%02d", t.timezone/60, abs(t.timezone)%60); - } -/* ]WR */ -#else - if ((pT = localtime(&n))) - { ftime(&t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60-(t.dstflag!=0), abs(t.timezone)%60); - } -#endif -#elif defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PLOCALTIME_R) - if (localtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -/* ]WR */ -#else - if ((pT = localtime(&n))) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -#endif - else - strcpy(soap->tmpbuf, "1969-12-31T23:59:59Z"); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outdateTime(struct soap *soap, const char *tag, int id, const time_t *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_dateTime2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2dateTime(struct soap *soap, const char *s, time_t *p) -{ if (s) - { struct tm T; - char zone[16]; - memset(&T, 0, sizeof(struct tm)); - zone[sizeof(zone)-1] = '\0'; - sscanf(s, "%d-%d-%dT%d:%d:%d%15s", &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec, zone); - if (T.tm_year == 1) - T.tm_year = 70; - else - T.tm_year -= 1900; - T.tm_mon--; - if (*zone) - { if (*zone == '.') - { for (s = zone + 1; *s; s++) - if (*s < '0' || *s > '9') - break; - } - else - s = zone; - if (*s != 'Z') - { int h = 0, m = 0; - sscanf(s, "%d:%d", &h, &m); - T.tm_hour -= h; - if (h >= 0) - T.tm_min -= m; - else - T.tm_min += m; - } - *p = soap_timegm(&T); - } - else - *p = mktime(&T); /* no time zone: suppose it is localtime? */ - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -time_t * -SOAP_FMAC2 -soap_indateTime(struct soap *soap, const char *tag, time_t *p, const char * type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":dateTime")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - if (soap->body && !*soap->href) - { p = (time_t*)soap_id_enter(soap, soap->id, p, t, sizeof(time_t), 0); - if (!p || soap_s2dateTime(soap, soap_value(soap), p)) - return NULL; - } - else - p = (time_t*)soap_id_forward(soap, soap->href, p, t, sizeof(time_t)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outliteral(struct soap *soap, const char *tag, char *const*p) -{ int i; - const char *t = NULL; - if (tag && *tag != '-') - { if ((t = strchr(tag, ':'))) - { strncpy(soap->tmpbuf, tag, t-tag); - soap->tmpbuf[t-tag] = '\0'; - for (i = 0; soap->local_namespaces[i].id; i++) - if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id)) - break; - t++; - sprintf(soap->tmpbuf, "<%s xmlns=\"%s\">", t, soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS); - } - else - { t = tag; - sprintf(soap->tmpbuf, "<%s>", tag); - } - if (soap_send(soap, soap->tmpbuf)) - return soap->error; - } - if (p && *p) - { if (soap_send(soap, *p)) - return soap->error; - } - if (t) - { sprintf(soap->tmpbuf, "", t); - return soap_send(soap, soap->tmpbuf); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char ** -SOAP_FMAC2 -soap_inliteral(struct soap *soap, const char *tag, char **p) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (!p) - if (!(p = (char**)soap_malloc(soap, sizeof(char*)))) - return NULL; - if (soap->null) - *p = NULL; - else if (soap->body) - *p = soap_string_in(soap, 0); - else - *p = NULL; - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outwliteral(struct soap *soap, const char *tag, wchar_t *const*p) -{ int i; - const char *t = NULL; - wchar_t c; - const wchar_t *s; - if (tag && *tag != '-') - { if (tag && (t = strchr(tag, ':'))) - { strncpy(soap->tmpbuf, tag, t-tag); - soap->tmpbuf[t-tag] = '\0'; - for (i = 0; soap->local_namespaces[i].id; i++) - if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id)) - break; - t++; - sprintf(soap->tmpbuf, "<%s xmlns=\"%s\">", t, soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS); - } - else - { t = tag; - sprintf(soap->tmpbuf, "<%s>", tag); - } - if (soap_send(soap, soap->tmpbuf)) - return soap->error; - } - if (p) - { s = *p; - while ((c = *s++)) - if (soap_pututf8(soap, (unsigned char)c)) - return soap->error; - } - if (t) - { sprintf(soap->tmpbuf, "", t); - return soap_send(soap, soap->tmpbuf); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t ** -SOAP_FMAC2 -soap_inwliteral(struct soap *soap, const char *tag, wchar_t **p) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (!p) - if (!(p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*)))) - return NULL; - if (soap->null) - *p = NULL; - else if (soap->body) - *p = soap_wstring_in(soap, 0); - else - *p = NULL; - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_value(struct soap *soap) -{ size_t i; - wchar c = 0; - char *s; - s = soap->tmpbuf; - for (i = 0; i < sizeof(soap->tmpbuf) - 1; i++) - { c = soap_get(soap); - if (c == TT || (int)c == EOF || soap_blank(c)) - break; - *s++ = (char)c; - } - if ((int)c == EOF || c == TT) - soap_unget(soap, c); - *s = '\0'; - return soap->tmpbuf; /* return non-null pointer */ -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getline(struct soap *soap, char *s, int len) -{ int i = len; - wchar c = 0; - for (;;) - { while (--i > 0) - { c = soap_getchar(soap); - if (c == '\r' || c == '\n' || (int)c == EOF) - break; - *s++ = (char)c; - } - *s = '\0'; - while (c != '\n' && (int)c != EOF) - c = soap_getchar(soap); - if ((int)c == EOF) - return SOAP_EOF; - if (i+1 == len) /* empty line: end of HTTP header */ - break; - c = soap_unget(soap, soap_getchar(soap)); - if (c != ' ' && c != '\t') /* HTTP line continuation? */ - break; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static size_t -soap_begin_dime(struct soap *soap) -{ -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - { size_t count; - sprintf(soap->id, soap->dime_id_format, 0); - soap->dime_id = soap->id; - if (soap->local_namespaces) - { if (soap->local_namespaces[0].out) - soap->dime_type = (char*)soap->local_namespaces[0].out; - else - soap->dime_type = (char*)soap->local_namespaces[0].ns; - } - soap->dime_options = NULL; - count = soap->dime_size + 12 + ((soap->count+3)&(~3)) + ((strlen(soap->dime_id)+3)&(~3)) + ((strlen(soap->dime_type)+3)&(~3)); - soap->dime_size = soap->count; - if (soap->dime_count) - soap->dime_flags = SOAP_DIME_MB | SOAP_DIME_ABSURI; - else - soap->dime_flags = SOAP_DIME_MB | SOAP_DIME_ME | SOAP_DIME_ABSURI; - return count; - } -#endif - return soap->count; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static int -soap_putdimefield(struct soap *soap, const char *s, size_t n) -{ if (soap_send_raw(soap, s, n)) - return soap->error; - return soap_send_raw(soap, SOAP_STR_PADDING, -(long)n&3); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_dime_option(struct soap *soap, unsigned short type, const char *option) -{ size_t n; - char *s = NULL; - if (option) - { n = strlen(option); - s = (char*)soap_malloc(soap, n + 5); - if (s) - { s[0] = type >> 8; - s[1] = type & 0xFF; - s[2] = n >> 8; - s[3] = n & 0xFF; - strcpy(s + 4, option); - } - } - return s; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putdimehdr(struct soap *soap) -{ unsigned char tmp[12]; - size_t optlen = 0, idlen = 0, typelen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Put DIME header id='%s'\n", soap->dime_id?soap->dime_id:"")); - if (soap->dime_options) - optlen = (((unsigned char)soap->dime_options[2] << 8) | ((unsigned char)soap->dime_options[3])) + 4; - if (soap->dime_id) - idlen = strlen(soap->dime_id); - if (soap->dime_type) - typelen = strlen(soap->dime_type); - tmp[0] = SOAP_DIME_VERSION | (soap->dime_flags & 0x7); - tmp[1] = soap->dime_flags & 0xF0; - tmp[2] = optlen >> 8; - tmp[3] = optlen & 0xFF; - tmp[4] = idlen >> 8; - tmp[5] = idlen & 0xFF; - tmp[6] = typelen >> 8; - tmp[7] = typelen & 0xFF; - tmp[8] = soap->dime_size >> 24; - tmp[9] = (soap->dime_size >> 16) & 0xFF; - tmp[10] = (soap->dime_size >> 8) & 0xFF; - tmp[11] = soap->dime_size & 0xFF; - if (soap_send_raw(soap, (char*)tmp, 12) - || soap_putdimefield(soap, soap->dime_options, optlen) - || soap_putdimefield(soap, soap->dime_id, idlen) - || soap_putdimefield(soap, soap->dime_type, typelen)) - return soap->error; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putdime(struct soap *soap, int i, char *id, char *type, char *options, void *ptr, size_t size) -{ void *h; - if (id) - soap->dime_id = id; - else - { sprintf(soap->id, soap->dime_id_format, i); - soap->dime_id = soap->id; - } - soap->dime_type = type; - soap->dime_options = options; - soap->dime_size = size; - soap->dime_flags = SOAP_DIME_VERSION | SOAP_DIME_MEDIA; - if (soap->fdimereadopen && ((h = soap->fdimereadopen(soap, (void*)ptr, soap->dime_id, type, options)) || soap->error)) - { size_t n; - if (!h) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadopen failed\n")); - return soap->error; - } - if (!size && ((soap->mode & SOAP_ENC_XML) || (soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_IO) == SOAP_IO_STORE)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked streaming DIME\n")); - n = sizeof(soap->tmpbuf); - do - { size = soap->fdimeread(soap, h, soap->tmpbuf, n); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread returned %lu bytes\n", (unsigned long)size)); - if (size == n) - soap->dime_flags |= SOAP_DIME_CF; - else - { soap->dime_flags &= ~SOAP_DIME_CF; - if (--soap->dime_count == 0) - soap->dime_flags |= SOAP_DIME_ME; - } - soap->dime_size = size; - if (soap_putdimehdr(soap) - || soap_send_raw(soap, soap->tmpbuf, size) - || soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime_size&3)) - break; - if (soap->dime_id) - { soap->dime_flags &= ~(SOAP_DIME_MB | SOAP_DIME_MEDIA); - soap->dime_id = NULL; - soap->dime_type = NULL; - soap->dime_options = NULL; - } - } while (size >= n); - } - else - { if (--soap->dime_count == 0) - soap->dime_flags |= SOAP_DIME_ME; - if (soap_putdimehdr(soap)) - return soap->error; - do - { if (size < sizeof(soap->tmpbuf)) - n = size; - else - n = sizeof(soap->tmpbuf); - if (!(n = soap->fdimeread(soap, h, soap->tmpbuf, n))) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread failed: insufficient data (%lu bytes remaining from %lu bytes)\n", (unsigned long)size, (unsigned long)soap->dime_size)); - soap->error = SOAP_EOF; - break; - } - if (soap_send_raw(soap, soap->tmpbuf, n)) - break; - size -= n; - } while (size); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n")); - soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime_size&3); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n")); - if (soap->fdimereadclose) - soap->fdimereadclose(soap, h); - return soap->error; - } - if (--soap->dime_count == 0) - soap->dime_flags |= SOAP_DIME_ME; - if (soap_putdimehdr(soap)) - return soap->error; - return soap_putdimefield(soap, (char*)ptr, size); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static char * -soap_getdimefield(struct soap *soap, size_t n) -{ register wchar c; - register int i; - register char *s; - char *p = NULL; - if (n) - { p = (char*)soap_malloc(soap, n + 1); - if (p) - { s = p; - for (i = n; i > 0; i--) - { if ((int)(c = soap_get1(soap)) == EOF) - { soap->error = SOAP_EOF; - return NULL; - } - *s++ = (char)c; - } - *s = '\0'; - if ((soap->error = soap_move(soap, -(long)n&3))) - return NULL; - } - else - soap->error = SOAP_EOM; - } - return p; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getdimehdr(struct soap *soap) -{ register wchar c; - register char *s; - register int i; - unsigned char tmp[12]; - size_t optlen, idlen, typelen; - if (!(soap->mode & SOAP_ENC_DIME)) - return soap->error = SOAP_EOD; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME header\n")); - if (soap->dime_buflen || soap->dime_chunksize) - { if (soap_move(soap, (long)(soap->dime_size - soap_tell(soap)))) - return soap->error = SOAP_EOF; - soap_unget(soap, soap_getchar(soap)); /* skip padding and get hdr */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... From chunked\n")); - return SOAP_OK; - } - s = (char*)tmp; - for (i = 12; i > 0; i--) - { if ((int)(c = soap_getchar(soap)) == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - if ((tmp[0] & 0xF8) != SOAP_DIME_VERSION) - return soap->error = SOAP_DIME_MISMATCH; - soap->dime_flags = (tmp[0] & 0x7) | (tmp[1] & 0xF0); - optlen = (tmp[2] << 8) | tmp[3]; - idlen = (tmp[4] << 8) | tmp[5]; - typelen = (tmp[6] << 8) | tmp[7]; - soap->dime_size = (tmp[8] << 24) | (tmp[9] << 16) | (tmp[10] << 8) | tmp[11]; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME size=%u flags=0x%X\n", (unsigned int)soap->dime_size, soap->dime_flags)); - if (!(soap->dime_options = soap_getdimefield(soap, optlen)) && soap->error) - return soap->error; - if (!(soap->dime_id = soap_getdimefield(soap, idlen)) && soap->error) - return soap->error; - if (!(soap->dime_type = soap_getdimefield(soap, typelen)) && soap->error) - return soap->error; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME id=%s, type=%s, options=%s\n", soap->dime_id?soap->dime_id:"", soap->dime_type?soap->dime_type:"", soap->dime_options?soap->dime_options+4:"")); - if (soap->dime_flags & SOAP_DIME_ME) - soap->mode &= ~SOAP_ENC_DIME; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getdime(struct soap *soap) -{ if (soap_getdimehdr(soap)) - return soap->error; - if (soap->fdimewriteopen && ((soap->dime_ptr = (char*)soap->fdimewriteopen(soap, soap->dime_id, soap->dime_type, soap->dime_options)) || soap->error)) - { char *id, *type, *options; - size_t size, n; - if (!soap->dime_ptr) - return soap->error; - id = soap->dime_id; - type = soap->dime_type; - options = soap->dime_options; - for (;;) - { size = soap->dime_size; - for (;;) - { n = soap->buflen - soap->bufidx; - if (size < n) - n = size; - if ((soap->error = soap->fdimewrite(soap, (void*)soap->dime_ptr, soap->buf + soap->bufidx, n))) - break; - size -= n; - if (!size) - { soap->bufidx += n; - break; - } - if (soap_recv(soap)) - { soap->error = SOAP_EOF; - goto end; - } - } - if (soap_move(soap, -(long)soap->dime_size&3)) - { soap->error = SOAP_EOF; - break; - } - if (!(soap->dime_flags & SOAP_DIME_CF)) - break; - if (soap_getdimehdr(soap)) - break; - } -end: - if (soap->fdimewriteclose) - soap->fdimewriteclose(soap, (void*)soap->dime_ptr); - soap->dime_size = 0; - soap->dime_id = id; - soap->dime_type = type; - soap->dime_options = options; - } - else if (soap->dime_flags & SOAP_DIME_CF) - { char *id, *type, *options; - register wchar c; - register char *s; - register int i; - id = soap->dime_id; - type = soap->dime_type; - options = soap->dime_options; - if (soap_new_block(soap)) - return SOAP_EOM; - for (;;) - { s = (char*)soap_push_block(soap, soap->dime_size); - if (!s) - return soap->error = SOAP_EOM; - for (i = soap->dime_size; i > 0; i--) - { if ((int)(c = soap_get1(soap)) == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - if (soap_move(soap, -(long)soap->dime_size&3)) - return soap->error = SOAP_EOF; - if (!(soap->dime_flags & SOAP_DIME_CF)) - break; - if (soap_getdimehdr(soap)) - return soap->error; - } - soap->dime_size = soap->blist->size++; /* allocate one more for '\0' */ - if (!(soap->dime_ptr = soap_save_block(soap, NULL))) - return soap->error; - soap->dime_ptr[soap->dime_size] = '\0'; /* make 0-terminated to enable string-based attachments */ - soap->dime_id = id; - soap->dime_type = type; - soap->dime_options = options; - } - else - soap->dime_ptr = soap_getdimefield(soap, soap->dime_size); - return soap->error; -} -#endif -#endif - -/******************************************************************************/ - -#ifdef WITH_COOKIES -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_encode_cookie(const char *s, char *t, int len) -{ register int c; - register int n = len; - while ((c = *s++) && --n > 0) - { if (c > ' ' && c < 128 && c != ';' && c != ',') - *t++ = c; - else if (n > 2) - { *t++ = '%'; - *t++ = (c >> 4) + (c > 159 ? '7' : '0'); - c &= 0xF; - *t++ = c + (c > 9 ? '7' : '0'); - n -= 2; - } - else - break; - } - *t = '\0'; - return len - n; -} - -/******************************************************************************/ -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_decode_cookie(char *buf, int len, const char *val) -{ const char *s; - char *t; - for (s = val; *s; s++) - if (*s != ' ' && *s != '=') - break; - if (*s == '"') - { t = buf; - s++; - while (*s && *s != '"' && --len) - *t++ = *s++; - *t = '\0'; - do s++; - while (*s && *s != ';' && *s != '='); - } - else - { t = buf; - while (*s && *s != ';' && *s != '=' && --len) - switch (*s) - { case ' ': - s++; - break; - case '%': - *t++ = ((s[1] >= 'A' ? (s[1] & 0x7) + 9 : s[1] - '0') << 4) - + (s[2] >= 'A' ? (s[2] & 0x7) + 9 : s[2] - '0'); - s += 3; - break; - default: - *t++ = *s++; - } - *t = '\0'; - } - return s; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_cookie(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - size_t n; - if (!domain) - domain = soap->cookie_domain; - if (!path) - path = soap->cookie_path; - if (*path == '/') - path++; - n = strlen(path); - for (p = soap->cookies; p; p = p->next) - if (!strcmp(p->name, name) - && domain - && p->domain - && !strcmp(p->domain, domain) - && !strncmp(p->path, path, n)) - break; - return p; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_set_cookie(struct soap *soap, const char *name, const char *value, const char *domain, const char *path) -{ struct soap_cookie **p, *q; - int n; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set cookie: %s=%s domain=%s path=%s\n", name, value?value:"", domain?domain:"", path?path:"")); - if (!domain) - domain = soap->cookie_domain; - if (!path) - path = soap->cookie_path; - if (!path) - { soap_set_receiver_error(soap, "Cookie path not set", NULL, SOAP_HTTP_ERROR); - return NULL; - } - if (*path == '/') - path++; - q = soap_cookie(soap, name, domain, path); - if (!q) - { if ((q = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - { if ((q->name = (char*)SOAP_MALLOC(strlen(name)+1))) - strcpy(q->name, name); - q->value = NULL; - q->domain = NULL; - q->path = NULL; - q->expire = -1; - q->version = 0; - q->secure = 0; - q->env = 0; - q->modified = 0; - for (p = &soap->cookies, n = soap->cookie_max; *p && n; p = &(*p)->next, n--) - if (!strcmp((*p)->name, name) && (*p)->path && strcmp((*p)->path, path) < 0) - break; - if (n) - { q->next = *p; - *p = q; - } - else - { SOAP_FREE(q->name); - SOAP_FREE(q); - q = NULL; - } - } - } - else - q->modified = 1; - if (q) - { if (q->value) - { SOAP_FREE(q->value); - q->value = NULL; - } - if (q->domain) - { SOAP_FREE(q->domain); - q->domain = NULL; - } - if (q->path) - { SOAP_FREE(q->path); - q->path = NULL; - } - if (value && *value && (q->value = (char*)SOAP_MALLOC(strlen(value)+1))) - strcpy(q->value, value); - if (domain && *domain && (q->domain = (char*)SOAP_MALLOC(strlen(domain)+1))) - strcpy(q->domain, domain); - if (path && *path && (q->path = (char*)SOAP_MALLOC(strlen(path)+1))) - strcpy(q->path, path); - q->session = 1; - } - return q; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_cookie(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie **p, *q; - if (!domain) - domain = soap->cookie_domain; - if (!domain) - { soap_set_receiver_error(soap, "Cookie domain not set", SOAP_STR_EOS, SOAP_HTTP_ERROR); - return; - } - if (!path) - path = soap->cookie_path; - if (!path) - { soap_set_receiver_error(soap, "Cookie path not set", SOAP_STR_EOS, SOAP_HTTP_ERROR); - return; - } - if (*path == '/') - path++; - for (p = &soap->cookies, q = *p; q; q = *p) - if (!strcmp(q->name, name) && !strcmp(q->domain, domain) && !strncmp(q->path, path, strlen(q->path))) - { if (q->value) - SOAP_FREE(q->value); - if (q->domain) - SOAP_FREE(q->domain); - if (q->path) - SOAP_FREE(q->path); - *p = q->next; - SOAP_FREE(q); - } - else - p = &q->next; -} - -/******************************************************************************/ -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_cookie_value(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - return p->value; - return NULL; -} - -/******************************************************************************/ -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_cookie_expire(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - return p->expire; - return -1; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_cookie_expire(struct soap *soap, const char *name, long expire, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->expire = expire; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->session = 1; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_clr_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->session = 0; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putsetcookies(struct soap *soap) -{ struct soap_cookie *p; - char *s, tmp[4096]; - const char *t; - for (p = soap->cookies; p; p = p->next) - if (p->modified || !p->env) - { s = tmp; - if (p->name) - s += soap_encode_cookie(p->name, s, tmp-s+4064); - if (p->value) - { *s++ = '='; - s += soap_encode_cookie(p->value, s, tmp-s+4064); - } - if (p->domain && (int)strlen(p->domain) < tmp-s+4064) - sprintf(s, ";Domain=%s", p->domain); - else if (soap->cookie_domain && (int)strlen(soap->cookie_domain) < tmp-s+4064) - sprintf(s, ";Domain=%s", soap->cookie_domain); - strcpy(s, ";Path=/"); - if (p->path) - t = p->path; - else - t = soap->cookie_path; - if (t) - { if (*t == '/') - t++; - if ((int)strlen(t) < tmp-s+4064) - strcat(s, t); - } - s += strlen(s); - if (p->version > 0) - { sprintf(s, ";Version=%u", p->version); - s += strlen(s); - } - if (p->expire >= 0) - { sprintf(s, ";Max-Age=%ld", p->expire); - s += strlen(s); - } - if (p->secure) - strcpy(s, ";Secure"); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set-Cookie: %s\n", tmp)); - if (soap->fposthdr(soap, "Set-Cookie", tmp)) - return soap->error; - } - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putcookies(struct soap *soap, const char *domain, const char *path, int secure) -{ struct soap_cookie **p, *q; - unsigned int version = 0; - time_t now = time(NULL); - char *s, tmp[4096]; - p = &soap->cookies; - while ((q = *p)) - { if (q->expire && now > q->expire) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie %s expired\n", q->name)); - SOAP_FREE(q->name); - if (q->value) - SOAP_FREE(q->value); - if (q->domain) - SOAP_FREE(q->domain); - if (q->path) - SOAP_FREE(q->path); - *p = q->next; - SOAP_FREE(q); - } - else if ((!q->domain || !strcmp(q->domain, domain)) - && (!q->path || !strncmp(q->path, path, strlen(q->path))) - && (!q->secure || secure)) - { s = tmp; - if (q->version != version) - { sprintf(s, "$Version=%u;", q->version); - version = q->version; - } - if (q->name) - s += soap_encode_cookie(q->name, s, tmp-s+4080); - if (q->value) - { *s++ = '='; - s += soap_encode_cookie(q->value, s, tmp-s+4080); - } - if (q->path && (int)strlen(q->path) < tmp-s+4080) - { sprintf(s, ";$Path=/%s", q->path); - s += strlen(s); - } - if (q->domain && (int)strlen(q->domain) < tmp-s+4080) - sprintf(s, ";$Domain=%s", q->domain); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie: %s\n", tmp)); - if (soap->fposthdr(soap, "Cookie", tmp)) - return soap->error; - p = &q->next; - } - else - p = &q->next; - } - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_getcookies(struct soap *soap, const char *val) -{ struct soap_cookie *p = NULL, *q; - const char *s; - char *t, tmp[4096]; /* cookie size is up to 4096 bytes [RFC2109] */ - char *domain = NULL; - char *path = NULL; - unsigned int version = 0; - time_t now = time(NULL); - if (!val) - return; - s = val; - while (*s) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (!soap_tag_cmp(tmp, "$Version")) - { if ((s = soap_decode_cookie(tmp, sizeof(tmp), s))) - { if (p) - p->version = (int)atol(tmp); - else - version = (int)atol(tmp); - } - } - else if (!soap_tag_cmp(tmp, "$Path")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (*tmp) - { if ((t = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(t, tmp); - } - else - t = NULL; - if (p) - { if (p->path) - SOAP_FREE(p->path); - p->path = t; - } - else - { if (path) - SOAP_FREE(path); - path = t; - } - } - else if (!soap_tag_cmp(tmp, "$Domain")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (*tmp) - { if ((t = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(t, tmp); - } - else - t = NULL; - if (p) - { if (p->domain) - SOAP_FREE(p->domain); - p->domain = t; - } - else - { if (domain) - SOAP_FREE(domain); - domain = t; - } - } - else if (p && !soap_tag_cmp(tmp, "Path")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (p->path) - SOAP_FREE(p->path); - if (*tmp) - { if ((p->path = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(p->path, tmp); - } - else - p->path = NULL; - } - else if (p && !soap_tag_cmp(tmp, "Domain")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (p->domain) - SOAP_FREE(p->domain); - if (*tmp) - { if ((p->domain = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(p->domain, tmp); - } - else - p->domain = NULL; - } - else if (p && !soap_tag_cmp(tmp, "Version")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - p->version = (unsigned int)atol(tmp); - } - else if (p && !soap_tag_cmp(tmp, "Max-Age")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - p->expire = now + atol(tmp); - } - else if (p && !soap_tag_cmp(tmp, "Expires")) - { struct tm T; - char a[3]; - static const char mns[] = "anebarprayunulugepctovec"; - s = soap_decode_cookie(tmp, sizeof(tmp), s); - memset(&T, 0, sizeof(struct tm)); - a[0] = tmp[4]; - a[1] = tmp[5]; - a[2] = '\0'; - T.tm_mday = (int)atol(a); - a[0] = tmp[8]; - a[1] = tmp[9]; - T.tm_mon = (strstr(mns, a) - mns) / 2; - a[0] = tmp[11]; - a[1] = tmp[12]; - T.tm_year = 100 + (int)atol(a); - a[0] = tmp[13]; - a[1] = tmp[14]; - T.tm_hour = (int)atol(a); - a[0] = tmp[16]; - a[1] = tmp[17]; - T.tm_min = (int)atol(a); - a[0] = tmp[19]; - a[1] = tmp[20]; - T.tm_sec = (int)atol(a); - p->expire = soap_timegm(&T); - } - else if (p && !soap_tag_cmp(tmp, "Secure")) - p->secure = 1; - else - { if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"", p->domain?p->domain:"", p->path?p->path:"", p->expire, p->secure)); - if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) - { q->version = p->version; - q->expire = p->expire; - q->secure = p->secure; - q->env = 1; - } - if (p->name) - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } - if ((p = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - { p->name = (char*)SOAP_MALLOC(strlen(tmp)+1); - strcpy(p->name, tmp); - s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (*tmp) - { p->value = (char*)SOAP_MALLOC(strlen(tmp)+1); - strcpy(p->value, tmp); - } - else - p->value = NULL; - p->domain = domain; - p->path = path; - p->expire = 0; - p->secure = 0; - p->version = version; - } - } - if (*s == ';') - s++; - } - if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"", p->domain?p->domain:"", p->path?p->path:"", p->expire, p->secure)); - if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) - { q->version = p->version; - q->expire = p->expire; - q->secure = p->secure; - } - if (p->name) - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } - if (domain) - SOAP_FREE(domain); - if (path) - SOAP_FREE(path); -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getenv_cookies(struct soap *soap) -{ struct soap_cookie *p; - const char *s; - char key[4096], val[4096]; /* cookie size is up to 4096 bytes [RFC2109] */ - if (!(s = getenv("HTTP_COOKIE"))) - return SOAP_ERR; - do - { s = soap_decode_cookie(key, sizeof(key), s); - s = soap_decode_cookie(val, sizeof(val), s); - p = soap_set_cookie(soap, key, val, NULL, NULL); - if (p) - p->env = 1; - if (*s == ';') - s++; - } while (*s); - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_copy_cookies(struct soap *soap) -{ struct soap_cookie *p, **q, *r; - q = &r; - for (p = soap->cookies; p; p = p->next) - { if (!(*q = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - return r; - **q = *p; - if (p->name) - { if (((*q)->name = (char*)SOAP_MALLOC(strlen(p->name)+1))) - strcpy((*q)->name, p->name); - } - if (p->value) - { if (((*q)->value = (char*)SOAP_MALLOC(strlen(p->value)+1))) - strcpy((*q)->value, p->value); - } - if (p->domain) - { if (((*q)->domain = (char*)SOAP_MALLOC(strlen(p->domain)+1))) - strcpy((*q)->domain, p->domain); - } - if (p->path) - { if (((*q)->path = (char*)SOAP_MALLOC(strlen(p->path)+1))) - strcpy((*q)->path, p->path); - } - q = &(*q)->next; - } - *q = NULL; - return r; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_free_cookies(struct soap *soap) -{ struct soap_cookie *p; - for (p = soap->cookies; p; p = soap->cookies) - { soap->cookies = p->next; - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } -} - -/******************************************************************************/ -#endif /* WITH_COOKIES */ - -/******************************************************************************/ -#ifdef WITH_GZIP -#ifndef PALM_2 -static int -soap_getgzipheader(struct soap *soap) -{ int i; - wchar c, f = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get gzip header\n")); - for (i = 0; i < 9; i++) - { if ((int)(c = soap_get1(soap) == EOF)) - return soap->error = SOAP_EOF; - if (i == 2) - f = c; - } - if (f & 0x04) /* FEXTRA */ - { for (i = soap_get1(soap) | (soap_get1(soap) << 8); i; i--) - if ((int)soap_get1(soap) == EOF) - return soap->error = SOAP_EOF; - } - if (f & 0x08) /* FNAME */ - do - c = soap_get1(soap); - while (c && (int)c != EOF); - if ((int)c != EOF && (f & 0x10)) /* FCOMMENT */ - do - c = soap_get1(soap); - while (c && (int)f != EOF); - if ((int)c != EOF && (f & 0x01)) /* FHCRC */ - { if ((int)(c = soap_get1(soap)) != EOF) - c = soap_get1(soap); - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_begin_recv(struct soap *soap) -{ wchar c; - soap_set_local_namespaces(soap); - soap_free_iht(soap); - if ((soap->imode & SOAP_IO) == SOAP_IO_CHUNK) - soap->omode |= SOAP_IO_CHUNK; - soap->imode &= ~SOAP_IO; - soap->mode = soap->imode; - if (!soap->keep_alive) - { soap->buflen = 0; - soap->bufidx = 0; - } - if (!(soap->mode & SOAP_IO_KEEPALIVE)) - soap->keep_alive = 0; - soap->ahead = 0; - soap->peeked = 0; - soap->level = 0; - soap->part = SOAP_BEGIN; - soap->alloced = 0; - soap->count = 0; - soap->length = 0; - soap->cdata = 0; - *soap->endpoint = '\0'; - soap->userid = NULL; - soap->passwd = NULL; - soap->action = NULL; - soap->dime_chunksize = 0; - soap->dime_buflen = 0; -#ifdef WIN32 -#ifndef UNDER_CE -#ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket)) -#ifdef __BORLANDC__ - setmode((SOAP_SOCKET)soap->recvfd, O_BINARY); -#else - _setmode((SOAP_SOCKET)soap->recvfd, _O_BINARY); -#endif -#endif -#endif -#endif -#ifdef WITH_ZLIB - soap->mode &= ~SOAP_ENC_ZLIB; - soap->zlib_in = SOAP_ZLIB_NONE; - soap->zlib_out = SOAP_ZLIB_NONE; - soap->d_stream.next_in = Z_NULL; - soap->d_stream.avail_in = 0; - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - soap->z_ratio_in = 1.0; -#endif - c = soap_getchar(soap); - if ((c & 0xFFFC) == (SOAP_DIME_VERSION | SOAP_DIME_MB) && (soap_get0(soap) & 0xFFF0) == 0x20) - soap->mode |= SOAP_ENC_DIME; -#ifdef WITH_GZIP - else if (c == 0x1F) - { if (soap_getgzipheader(soap)) - return soap->error; - if (inflateInit2(&soap->d_stream, -MAX_WBITS) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - soap->mode |= SOAP_ENC_ZLIB; - soap->zlib_in = SOAP_ZLIB_GZIP; - soap->z_crc = crc32(0L, NULL, 0); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n")); - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - /* should not chunk over plain transport, so why bother to check? */ - /* if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) */ - /* soap->z_buflen = soap->bufidx; */ - /* else */ - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = soap->buflen - soap->bufidx; - soap->z_buflen = soap->buflen; - soap->buflen = soap->bufidx; - } -#endif - else - { if (c == 0xEF && !(soap->mode & SOAP_C_LATIN)) - { soap_unget(soap, c); - c = soap_getutf8(soap); - if (c == 0xFEFF) - c = soap_getchar(soap); - } - while (soap_blank(c)) - c = soap_getchar(soap); - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - soap_unget(soap, c); - if (c != '<' && !(soap->mode & (SOAP_ENC_DIME | SOAP_ENC_ZLIB))) - { soap->mode &= ~SOAP_IO; - if ((soap->error = soap->fparse(soap))) - { if (soap->error == 307) /* HTTP redirect */ - { soap_getline(soap, soap->endpoint, sizeof(soap->endpoint)); - soap->keep_alive = 0; /* force close when soap_closesock() */ - } - return soap->error; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { soap->chunkbuflen = soap->buflen; - soap->buflen = soap->bufidx; - soap->chunksize = 0; - } -#ifdef WITH_ZLIB - if (soap->zlib_in) - { /* fparse should not use soap_unget */ -#ifdef WITH_GZIP - c = soap_get1(soap); - if (c == 0x1F) - { if (soap_getgzipheader(soap)) - return soap->error; - if (inflateInit2(&soap->d_stream, -MAX_WBITS) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - soap->z_crc = crc32(0L, NULL, 0); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n")); - } - else - { soap_revget1(soap); -#else - { -#endif - if (inflateInit(&soap->d_stream) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate initialized\n")); - } - soap->mode |= SOAP_ENC_ZLIB; - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = soap->buflen - soap->bufidx; - soap->z_buflen = soap->buflen; - soap->buflen = soap->bufidx; - } -#endif - } -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - { if (soap_getdimehdr(soap)) - return soap->error; - if (soap->dime_flags & SOAP_DIME_CF) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked DIME SOAP message\n")); - soap->dime_chunksize = soap->dime_size; - if (soap->buflen - soap->bufidx >= soap->dime_chunksize) - { soap->dime_buflen = soap->buflen; - soap->buflen = soap->bufidx + soap->dime_chunksize; - } - else - soap->dime_chunksize -= soap->buflen - soap->bufidx; - } - soap->count = soap->buflen - soap->bufidx; - } -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_parse(struct soap *soap) -{ char header[SOAP_HDRLEN], *s; - unsigned short g = 0, k; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Waiting for response...\n")); - *soap->endpoint = '\0'; - soap->length = 0; - do - { if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf))) - return SOAP_EOF; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP status: %s\n", soap->msgbuf)); - for (;;) - { if (soap_getline(soap, header, SOAP_HDRLEN)) - return SOAP_EOF; - if (!*header) - break; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP header: %s\n", header)); - s = strchr(header, ':'); - if (s) - { *s = '\0'; - do s++; - while (*s && *s <= 32); - if ((soap->error = soap->fparsehdr(soap, header, s))) - return soap->error; - } - } - if ((s = strchr(soap->msgbuf, ' '))) - k = (unsigned short)soap_strtoul(s, NULL, 10); - else - k = 0; - } while (k == 100); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Finished HTTP header parsing\n")); - s = strstr(soap->msgbuf, "HTTP/"); - if (s && s[7] != '1') - { if (soap->keep_alive == 1) - soap->keep_alive = 0; - if (k == 0 && (soap->omode & SOAP_IO) == SOAP_IO_CHUNK) /* k == 0 for HTTP request */ - { soap->imode |= SOAP_IO_CHUNK; - soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_STORE; - } - } - if (soap->keep_alive < 0) - soap->keep_alive = 1; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Keep alive connection = %d\n", soap->keep_alive)); - if (s && (((g = !strncmp(soap->msgbuf, "GET ", 4))) || !strncmp(soap->msgbuf, "POST ", 5))) - { size_t m = strlen(soap->endpoint); - size_t n = m + (s - soap->msgbuf) - 5 - (!g); - if (n >= sizeof(soap->endpoint)) - n = sizeof(soap->endpoint) - 1; - strncpy(soap->path, soap->msgbuf + 4 + (!g), n - m); - soap->path[n - m] = '\0'; - strcat(soap->endpoint, soap->path); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Target endpoint='%s'\n", soap->endpoint)); - if (g) - { soap->error = soap->fget(soap); - if (soap->error == SOAP_OK) - soap->error = SOAP_STOP; /* prevents further processing */ - return soap->error; - } - return SOAP_OK; - } - if (k == 0 || (k >= 200 && k <= 299) || k == 400 || k == 500) - return SOAP_OK; - return soap_set_receiver_error(soap, "HTTP error", soap->msgbuf, k); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_parse_header(struct soap *soap, const char *key, const char *val) -{ if (!soap_tag_cmp(key, "Host")) - { -#ifdef WITH_OPENSSL - if (soap->imode & SOAP_ENC_SSL) - strcpy(soap->endpoint, "https://"); - else -#endif - strcpy(soap->endpoint, "http://"); - strncat(soap->endpoint, val, sizeof(soap->endpoint) - 8); - soap->endpoint[sizeof(soap->endpoint) - 1] = '\0'; - } - else if (!soap_tag_cmp(key, "Content-Type")) - { if (!soap_tag_cmp(val, "*application/dime*")) - soap->mode |= SOAP_ENC_DIME; - } - else if (!soap_tag_cmp(key, "Content-Length")) - soap->length = soap_strtoul(val, NULL, 10); - else if (!soap_tag_cmp(key, "Content-Encoding")) - { if (!soap_tag_cmp(val, "deflate*")) -#ifdef WITH_ZLIB - soap->zlib_in = SOAP_ZLIB_DEFLATE; -#else - return SOAP_ZLIB_ERROR; -#endif - else if (!soap_tag_cmp(val, "gzip*")) -#ifdef WITH_GZIP - soap->zlib_in = SOAP_ZLIB_GZIP; -#else - return SOAP_ZLIB_ERROR; -#endif - } -#ifdef WITH_ZLIB - else if (!soap_tag_cmp(key, "Accept-Encoding")) - { -#ifdef WITH_GZIP - if (strchr(val, '*') || !soap_tag_cmp(val, "*gzip*")) - soap->zlib_out = SOAP_ZLIB_GZIP; - else -#endif - if (strchr(val, '*') || !soap_tag_cmp(val, "*deflate*")) - soap->zlib_out = SOAP_ZLIB_DEFLATE; - else - soap->zlib_out = SOAP_ZLIB_NONE; - } -#endif - else if (!soap_tag_cmp(key, "Transfer-Encoding")) - { soap->mode &= ~SOAP_IO; - if (!soap_tag_cmp(val, "chunked*")) - soap->mode |= SOAP_IO_CHUNK; - } - else if (!soap_tag_cmp(key, "Connection")) - { if (!soap_tag_cmp(val, "keep-alive*")) - soap->keep_alive = -soap->keep_alive; - else if (!soap_tag_cmp(val, "close*")) - soap->keep_alive = 0; - } -#ifndef WITH_LEAN - else if (!soap_tag_cmp(key, "Authorization")) - { if (!soap_tag_cmp(val, "basic *")) - { size_t n; - char *s; - soap_base642s(soap, val + 6, soap->tmpbuf, sizeof(soap->tmpbuf) - 1, &n); - soap->tmpbuf[n] = '\0'; - if ((s = strchr(soap->tmpbuf, ':'))) - { *s = '\0'; - soap->userid = soap_strdup(soap, soap->tmpbuf); - soap->passwd = soap_strdup(soap, s + 1); - } - } - } -#endif - else if (!soap_tag_cmp(key, "SOAPAction")) - { if (val[0] && val[1]) - { soap->action = soap_strdup(soap, val + 1); - soap->action[strlen(soap->action) - 1] = '\0'; - } - } -/* [ Deal with .NET bug (invalid XML id-ref) */ - else if (!soap_tag_cmp(key, "Server")) - { if (!soap_tag_cmp(val, "Microsoft-IIS*")) - soap->dot_net_bug = 1; - } - else if (!soap_tag_cmp(key, "User-Agent")) - { if (!soap_tag_cmp(val, "*.NET CLR*") || !soap_tag_cmp(val, "*MS Web Services Client Protocol*")) - soap->dot_net_bug = 1; - } -/* ] */ -#ifdef WITH_COOKIES - else if (!soap_tag_cmp(key, "Cookie") || !soap_tag_cmp(key, "Set-Cookie")) - soap_getcookies(soap, val); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_begin_out(struct soap *soap) -{ soap->part = SOAP_IN_ENVELOPE; - return soap_element_begin_out(soap, "SOAP-ENV:Envelope", 0, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_end_out(struct soap *soap) -{ if (soap_element_end_out(soap, "SOAP-ENV:Envelope")) - return soap->error; - soap->part = SOAP_END_ENVELOPE; -#ifndef WITH_LEANER - if (!(soap->mode & SOAP_IO_LENGTH) && (soap->mode & SOAP_ENC_DIME)) - return soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->count&3); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_begin_in(struct soap *soap) -{ soap->part = SOAP_IN_ENVELOPE; - if (soap_element_begin_in(soap, "SOAP-ENV:Envelope")) - return soap->error = SOAP_VERSIONMISMATCH; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_end_in(struct soap *soap) -{ if (soap_element_end_in(soap, "SOAP-ENV:Envelope")) - return soap->error; - soap->part = SOAP_END_ENVELOPE; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_begin_out(struct soap *soap) -{ soap->part = SOAP_IN_BODY; - if (soap->version == 1) - soap->encoding = 1; - if (soap_element(soap, "SOAP-ENV:Body", 0, NULL)) - return soap->error; - if (soap_attribute(soap, "id", "_0")) - return soap->error; - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_end_out(struct soap *soap) -{ if (soap_element_end_out(soap, "SOAP-ENV:Body")) - return soap->error; - soap->part = SOAP_IN_BODY; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_begin_in(struct soap *soap) -{ soap->part = SOAP_IN_BODY; - return soap_element_begin_in(soap, "SOAP-ENV:Body"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_end_in(struct soap *soap) -{ if (soap_element_end_in(soap, "SOAP-ENV:Body")) - return soap->error; - soap->part = SOAP_END_BODY; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_header(struct soap *soap) -{ if (soap_getheader(soap) && soap->error == SOAP_TAG_MISMATCH) - soap->error = SOAP_OK; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_endpoint(struct soap *soap, const char *endpoint) -{ register const char *s; - register size_t i, n; - *soap->endpoint = '\0'; - *soap->host = '\0'; - *soap->path = '\0'; - soap->port = 80; - if (!endpoint || !*endpoint) - return; -#ifdef WITH_OPENSSL - if (!strncmp(endpoint, "https:", 6)) - soap->port = 443; -#endif - strncpy(soap->endpoint, endpoint, sizeof(soap->endpoint) - 1); - s = strchr(endpoint, ':'); - if (s && s[1] == '/' && s[2] == '/') - s += 3; - else - s = endpoint; - n = strlen(s); - if (n >= sizeof(soap->host)) - n = sizeof(soap->host) - 1; -/* WR[ */ -#ifdef WITH_IPV6 - if ('[' == s[0]) - { - s++; - for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (']' == s[i]) - { - s++; - break; - } - } - } - else - { - for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (s[i] == '/' || s[i] == ':') - break; - } - } -#else /* WITH_IPV6 */ -/* ]WR */ - for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (s[i] == '/' || s[i] == ':') - break; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - soap->host[i] = '\0'; - if (s[i] == ':') - { soap->port = (int)atol(s + i + 1); - for (i++; i < n; i++) - if (s[i] == '/') - break; - } - if (s[i]) - { strncpy(soap->path, s + i + 1, sizeof(soap->path)); - soap->path[sizeof(soap->path) - 1] = '\0'; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_connect(struct soap *soap, const char *endpoint, const char *action) -{ return soap_connect_command(soap, SOAP_POST, endpoint, action); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_connect_command(struct soap *soap, int http_command, const char *endpoint, const char *action) -{ char host[sizeof(soap->host)]; - int port; - size_t count; - strcpy(host, soap->host); /* save to compare */ - port = soap->port; /* save to compare */ - soap_set_endpoint(soap, endpoint); - if (action) - soap->action = soap_strdup(soap, action); - if (soap->fconnect) - { - if ((soap->error = soap->fconnect(soap, endpoint, soap->host, soap->port))) - return soap->error; - } - else if (*soap->host) - { soap->status = http_command; - if (!soap_valid_socket(soap->socket) || strcmp(soap->host, host) || soap->port != port) - { soap->keep_alive = 0; /* force close */ - soap_closesock(soap); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Connect to host='%s' path='%s' port=%d\n", soap->host, soap->path, soap->port)); - soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port); - if (soap->error) - return soap->error; - soap->keep_alive = ((soap->omode & SOAP_IO_KEEPALIVE) != 0); - } - else if (!soap->keep_alive || soap_poll(soap)) - { soap->keep_alive = 0; /* force close */ - soap_closesock(soap); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Reconnect to host='%s' path='%s' port=%d\n", soap->host, soap->path, soap->port)); - soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port); - if (soap->error) - return soap->error; - } - } - count = soap_begin_dime(soap); - if (soap_begin_send(soap)) - return soap->error; - if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML) && endpoint) - { unsigned int k = soap->mode; - soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB); - if ((k & SOAP_IO) != SOAP_IO_FLUSH) - soap->mode |= SOAP_IO_BUFFER; - if ((soap->error = soap->fpost(soap, endpoint, soap->host, soap->port, soap->path, action, count))) - return soap->error; - if ((k & SOAP_IO) == SOAP_IO_CHUNK) - { if (soap_flush(soap)) - return soap->error; - } - soap->mode = k; - } - if (http_command != SOAP_POST) - return soap_end_send(soap); -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - return soap_putdimehdr(soap); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2base64(struct soap *soap, const unsigned char *s, char *t, size_t n) -{ register size_t i; - register unsigned long m; - if (!t) - return SOAP_EOM; - t[0] = '\0'; - if (!s) - return SOAP_OK; - for (; n > 2; n -= 3, s += 3) - { m = ((unsigned long)((unsigned char*)s)[0] << 16) | ((unsigned long)((unsigned char*)s)[1] << 8) | (unsigned long)((unsigned char*)s)[2]; - for (i = 4; i > 0; m >>= 6) - t[--i] = soap_base64o[m & 0x3F]; - t += 4; - } - t[0] = '\0'; - if (n > 0) - { m = 0; - for (i = 0; i < n; i++) - m = (m << 8) | *s++; - for (; i < 3; i++) - m <<= 8; - for (i++; i > 0; m >>= 6) - t[--i] = soap_base64o[m & 0x3F]; - for (i = 3; i > n; i--) - t[i] = '='; - t[4] = '\0'; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_base642s(struct soap *soap, const char *s, char *t, size_t l, size_t *n) -{ register int i, j, c; - register unsigned long m; - char *p = t; - if (n) - *n = 0; - for (;;) - { for (i = 0; i < SOAP_BLKLEN; i++) - { m = 0; - j = 0; - while (j < 4) - { c = *s++; - if (c == '=' || !c) - { i *= 3; - switch (j) - { case 2: - *t++ = (char)((m >> 4) & 0xFF); - i++; - break; - case 3: - *t++ = (char)((m >> 10) & 0xFF); - *t++ = (char)((m >> 2) & 0xFF); - i += 2; - } - if (n) - *n += i; - return p; - } - c -= '+'; - if (c >= 0 && c <= 79) - { m = (m << 6) + soap_base64i[c]; - j++; - } - } - *t++ = (char)((m >> 16) & 0xFF); - *t++ = (char)((m >> 8) & 0xFF); - *t++ = (char)(m & 0xFF); - if (l < 3) - { if (n) - *n += i; - return p; - } - l -= 3; - } - if (n) - *n += 3 * SOAP_BLKLEN; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_puthttphdr(struct soap *soap, int status, size_t count) -{ const char *s; - if (status == SOAP_FILE) - s = soap->http_content; - else if (status == SOAP_HTML) - s = "text/html; charset=utf-8"; - else if (soap->mode & SOAP_ENC_DIME) - s = "application/dime"; - else if (soap->version == 2) - s = "application/soap+xml; charset=utf-8"; - else - s = "text/xml; charset=utf-8"; - soap->error = soap->fposthdr(soap, "Content-Type", s); - if (soap->error) - return soap->error; -#ifdef WITH_ZLIB - if (soap->omode & SOAP_ENC_ZLIB) -#ifdef WITH_GZIP - soap->error = soap->fposthdr(soap, "Content-Encoding", "gzip"); -#else - soap->error = soap->fposthdr(soap, "Content-Encoding", "deflate"); -#endif -#endif - if ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK) - soap->error = soap->fposthdr(soap, "Transfer-Encoding", "chunked"); - else if (count > 0) - { sprintf(soap->tmpbuf, "%lu", (unsigned long)count); - soap->error = soap->fposthdr(soap, "Content-Length", soap->tmpbuf); - } - if (soap->error) - return soap->error; - return soap->error = soap->fposthdr(soap, "Connection", soap->keep_alive ? "keep-alive" : "close"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_get(struct soap *soap) -{ return SOAP_GET_METHOD; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_post(struct soap *soap, const char *endpoint, const char *host, int port, const char *path, const char *action, size_t count) -{ const char *s; - if (soap->status == SOAP_GET) - { s = "GET"; - count = 0; - } - else - s = "POST"; -#ifndef PALM - if (!endpoint || (strncmp(endpoint, "http:", 5) && strncmp(endpoint, "https:", 6) && strncmp(endpoint, "httpg:", 6))) -#else - if (!endpoint || (strncmp(endpoint, "http:", 5) && strncmp(endpoint, "https:", 6) && strncmp(endpoint, "httpg:", 6)) && strncmp(endpoint, "_beam:", 6) && strncmp(endpoint, "_local:", 7) && strncmp(endpoint, "_btobex:", 8)) -#endif - return SOAP_OK; - if (soap->proxy_host) - sprintf(soap->tmpbuf, "%s %s HTTP/%s", s, endpoint, soap->http_version); - else - sprintf(soap->tmpbuf, "%s /%s HTTP/%s", s, path, soap->http_version); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return soap->error; - if (port != 80) - sprintf(soap->tmpbuf, "%s:%d", host, port); - else - strcpy(soap->tmpbuf, host); - if ((soap->error = soap->fposthdr(soap, "Host", soap->tmpbuf)) - || (soap->error = soap->fposthdr(soap, "User-Agent", "gSOAP/2.6")) - || (soap->error = soap_puthttphdr(soap, SOAP_OK, count))) - return soap->error; -#ifdef WITH_ZLIB -#ifdef WITH_GZIP - if ((soap->error = soap->fposthdr(soap, "Accept-Encoding", "gzip, deflate"))) -#else - if ((soap->error = soap->fposthdr(soap, "Accept-Encoding", "deflate"))) -#endif - return soap->error; -#endif -#ifndef WITH_LEAN - if (soap->userid && soap->passwd && strlen(soap->userid) + strlen(soap->passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->userid, soap->passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((soap->error = soap->fposthdr(soap, "Authorization", soap->tmpbuf))) - return soap->error; - } - if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((soap->error = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) - return soap->error; - } -#endif -#ifdef WITH_COOKIES -#ifdef WITH_OPENSSL - if (soap_putcookies(soap, host, path, soap->ssl != NULL)) - return soap->error; -#else - if (soap_putcookies(soap, host, path, 0)) - return soap->error; -#endif -#endif - if (action) - { sprintf(soap->tmpbuf, "\"%s\"", action); - if ((soap->error = soap->fposthdr(soap, "SOAPAction", soap->tmpbuf))) - return soap->error; - } - return soap->error = soap->fposthdr(soap, NULL, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_post_header(struct soap *soap, const char *key, const char *val) -{ if (key) - { if (soap_send(soap, key)) - return soap->error; - if (val && (soap_send(soap, ": ") || soap_send(soap, val))) - return soap->error; - } - return soap_send(soap, "\r\n"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_response(struct soap *soap, int status, size_t count) -{ -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - { - httpOutputEnable(soap->rpmreqid); - } -#endif /* WMW_RPM_IO */ -/* ]WR */ - if (!status || status == SOAP_HTML || status == SOAP_FILE) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "OK 200\n")); -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ -#else -/* ]WR */ - if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */ -/* WR[ */ -#endif /* WMW_RPM_IO */ -/* ]WR */ - { sprintf(soap->tmpbuf, "HTTP/%s 200 OK", soap->http_version); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return soap->error; - } - else if ((soap->error = soap->fposthdr(soap, "Status", "200 OK"))) - return soap->error; - } - else if (status > 200 && status < 600) - { sprintf(soap->tmpbuf, "HTTP/%s %d %s", soap->http_version, status, http_error(soap, status)); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return soap->error; - if (status == 401) - if ((soap->error = soap->fposthdr(soap, "WWW-Authenticate", "Basic realm=\"gSOAP Service\""))) - return soap->error; - } - else - { const char *s = *soap_faultcode(soap); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error\n")); - if (soap->version == 2 && !strcmp(s, "SOAP-ENV:Sender")) - s = "400 Bad Request"; - else - s = "500 Internal Server Error"; -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ -#else -/* ]WR */ - if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */ -/* WR[ */ -#endif /* WMW_RPM_IO */ -/* ]WR */ - { sprintf(soap->tmpbuf, "HTTP/%s %s", soap->http_version, s); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return soap->error; - } - else if ((soap->error = soap->fposthdr(soap, "Status", s))) - return soap->error; - } - if ((soap->error = soap->fposthdr(soap, "Server", "gSOAP/2.6")) - || (soap->error = soap_puthttphdr(soap, status, count))) - return soap->error; -#ifdef WITH_COOKIES - if (soap_putsetcookies(soap)) - return soap->error; -#endif - return soap->error = soap->fposthdr(soap, NULL, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_response(struct soap *soap, int status) -{ register size_t count; - if (!(soap->omode & (SOAP_ENC_XML | SOAP_IO_STORE /* this tests for chunking too */)) - && (status == SOAP_HTML || status == SOAP_FILE)) - { soap->omode &= ~SOAP_IO; - soap->omode |= SOAP_IO_STORE; - } - soap->status = status; - count = soap_begin_dime(soap); - if (soap_begin_send(soap)) - return soap->error; - if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML)) - { register int n = soap->mode; - soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB); - if ((n & SOAP_IO) != SOAP_IO_FLUSH) - soap->mode |= SOAP_IO_BUFFER; - if ((soap->error = soap->fresponse(soap, status, count))) - return soap->error; - if ((n & SOAP_IO) == SOAP_IO_CHUNK) - { if (soap_flush(soap)) - return soap->error; - } - soap->mode = n; - } -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - return soap_putdimehdr(soap); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_fault(struct soap *soap) -{ const char **c = soap_faultcode(soap); - const char **s = soap_faultstring(soap); - if (!*c) - { if (soap->version == 2) - *c = "SOAP-ENV:Sender"; - else - *c = "SOAP-ENV:Client"; - } - if (*s) - return; - switch (soap->error) - { case SOAP_CLI_FAULT: - *s = "Client fault"; - break; - case SOAP_SVR_FAULT: - *s = "Server fault"; - break; - case SOAP_TAG_MISMATCH: - sprintf(soap->msgbuf, "Tag mismatch: element '%s' does not correspond to expected element", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_TYPE: - sprintf(soap->msgbuf, "Data type '%s' mismatch in element '%s'", soap->type, soap->tag); - *s = soap->msgbuf; - break; - case SOAP_SYNTAX_ERROR: - *s = "XML syntax error"; - break; - case SOAP_NO_TAG: - *s = "No XML element tag found"; - break; - case SOAP_MUSTUNDERSTAND: - *c = "SOAP-ENV:MustUnderstand"; - sprintf(soap->msgbuf, "The data in element '%s' must be understood but cannot be handled", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_VERSIONMISMATCH: - *c = "SOAP-ENV:VersionMismatch"; - *s = "SOAP version mismatch or invalid SOAP message"; - break; - case SOAP_DATAENCODINGUNKNOWN: - *c = "SOAP-ENV:DataEncodingUnknown"; - *s = "Unsupported SOAP data encoding"; - break; - case SOAP_DIME_MISMATCH: - *s = "DIME version mismatch"; - break; - case SOAP_NAMESPACE: - sprintf(soap->msgbuf, "Namespace URI mismatch in element '%s'", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_OBJ_MISMATCH: - *s = "Object mismatch"; - break; - case SOAP_FATAL_ERROR: - *s = "Fatal error"; - break; - case SOAP_NO_METHOD: - sprintf(soap->msgbuf, "Method '%s' not implemented", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_GET_METHOD: - *s = "HTTP GET method not implemented"; - break; - case SOAP_EOM: - *s = "Out of memory"; - break; - case SOAP_IOB: - *s = "Array index out of bounds"; - break; - case SOAP_NULL: - sprintf(soap->msgbuf, "Cannot create nilable object for type '%s' in element '%s'", soap->type, soap->tag); - *s = soap->msgbuf; - break; - case SOAP_MULTI_ID: - *s = "Non-unique id attribute"; - break; - case SOAP_MISSING_ID: - *s = "Missing id: referenced data is missing or had to be ignored"; - break; - case SOAP_HREF: - *s = "Invalid XML: object reference with href attribute is incompatible with actual object referred to"; - break; - case SOAP_FAULT: - break; - case SOAP_TCP_ERROR: - *s = tcp_error(soap); - break; - case SOAP_HTTP_ERROR: - *s = "HTTP error"; - break; - case SOAP_SSL_ERROR: - *s = "SSL error"; - break; - case SOAP_PLUGIN_ERROR: - *s = "Plugin registry error"; - break; - case SOAP_DIME_ERROR: - *s = "DIME error"; - break; - case SOAP_ZLIB_ERROR: -#ifdef WITH_ZLIB - sprintf(soap->msgbuf, "Zlib/gzip error: '%s'", soap->d_stream.msg?soap->d_stream.msg:""); - *s = soap->msgbuf; -#else - *s = "Zlib not installed for required message (de)compression"; -#endif - break; - case SOAP_EOD: - *s = "End of DIME error"; - break; - case SOAP_REQUIRED: - *s = "Validation failure: XML attribute required"; - break; - case SOAP_OCCURS: - *s = "Validation failure: XML element occurs count"; - break; - case SOAP_EOF: - sprintf(soap->msgbuf, "End of file or no input: '%s'", soap_strerror(soap)); - *s = soap->msgbuf; - break; - default: - if (soap->error > 200 && soap->error < 600) - { sprintf(soap->msgbuf, "HTTP Error: '%s'", http_error(soap, soap->error)); - *s = soap->msgbuf; - } - else - *s = "Unknown error code"; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send_fault(struct soap *soap) -{ register int status = soap->error; - if (status == SOAP_STOP) - return status; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Sending back fault struct for error code %d\n", soap->error)); - soap->keep_alive = 0; /* to terminate connection */ - soap_set_fault(soap); - if ((status != SOAP_EOF || (!soap->recv_timeout && !soap->send_timeout)) && soap_poll(soap) == SOAP_OK) - { soap->error = SOAP_OK; - soap_serializeheader(soap); - soap_serializefault(soap); - soap_begin_count(soap); - if (soap->mode & SOAP_IO_LENGTH) - { soap_envelope_begin_out(soap); - soap_putheader(soap); - soap_body_begin_out(soap); - soap_putfault(soap); - soap_body_end_out(soap); - soap_envelope_end_out(soap); - } - if (soap_response(soap, status) - || soap_envelope_begin_out(soap) - || soap_putheader(soap) - || soap_body_begin_out(soap) - || soap_putfault(soap) - || soap_body_end_out(soap) - || soap_envelope_end_out(soap)) - return soap_closesock(soap); - soap_end_send(soap); - } - soap_closesock(soap); - return soap->error = status; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_fault(struct soap *soap) -{ register int status = soap->error; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Receiving SOAP Fault\n")); - soap->error = SOAP_OK; - if (soap_getfault(soap)) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Error: soap_get_soapfault() failed. Is this a SOAP message at all?\n")); - *soap_faultcode(soap) = (soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client"); - soap->error = status; - soap_set_fault(soap); - } - else - { register const char *s = *soap_faultcode(soap); - if (!soap_match_tag(soap, s, "SOAP-ENV:Server") || !soap_match_tag(soap, s, "SOAP-ENV:Receiver")) - status = SOAP_SVR_FAULT; - else if (!soap_match_tag(soap, s, "SOAP-ENV:Client") || !soap_match_tag(soap, s, "SOAP-ENV:Sender")) - status = SOAP_CLI_FAULT; - else if (!soap_match_tag(soap, s, "SOAP-ENV:MustUnderstand")) - status = SOAP_MUSTUNDERSTAND; - else if (!soap_match_tag(soap, s, "SOAP-ENV:VersionMismatch")) - status = SOAP_VERSIONMISMATCH; - else - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Fault code %s\n", s)); - status = SOAP_FAULT; - } - if (soap_body_end_in(soap) - || soap_envelope_end_in(soap) - || soap_end_recv(soap)) - return soap_closesock(soap); - soap->error = status; - } - return soap_closesock(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -soap_strerror(struct soap *soap) -{ int err = soap->errnum; - if (!err) - err = soap_errno; - if (err) - { -#ifndef UNDER_CE - return strerror(err); -#else - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, 0, (LPTSTR)&soap->werrorstr, 256, NULL); - wcstombs(soap->errorstr, soap->werrorstr, 256); - return soap->errorstr; -#endif - } - return "Operation interrupted or timed out"; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_set_error(struct soap *soap, const char *faultcode, const char *faultstring, const char *faultdetail, int soaperror) -{ *soap_faultcode(soap) = faultcode; - *soap_faultstring(soap) = faultstring; - if (faultdetail && *faultdetail) - { register const char **s = soap_faultdetail(soap); - if (s) - *s = faultdetail; - } - return soap->error = soaperror; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_sender_error(struct soap *soap, const char *faultstring, const char *faultdetail, int soaperror) -{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", faultstring, faultdetail, soaperror); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_receiver_error(struct soap *soap, const char *faultstring, const char *faultdetail, int soaperror) -{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", faultstring, faultdetail, soaperror); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_copy_fault(struct soap *soap, const char *faultcode, const char *faultstring, const char *faultdetail) -{ char *s = NULL, *t = NULL; - if (faultstring) - s = soap_strdup(soap, faultstring); - if (faultdetail) - t = soap_strdup(soap, faultdetail); - return soap_set_error(soap, faultcode, s, t, SOAP_FAULT); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_sender_fault(struct soap *soap, const char *faultstring, const char *faultdetail) -{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", faultstring, faultdetail); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_receiver_fault(struct soap *soap, const char *faultstring, const char *faultdetail) -{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", faultstring, faultdetail); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_print_fault(struct soap *soap, FILE *fd) -{ if (soap->error) - { const char **s; - if (!*soap_faultcode(soap)) - soap_set_fault(soap); - fprintf(fd, "SOAP FAULT: %s\n\"%s\"\n", *soap_faultcode(soap), *soap_faultstring(soap)); - s = soap_faultdetail(soap); - if (s && *s) - fprintf(fd, "Detail: %s\n", *s); - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_print_fault_location(struct soap *soap, FILE *fd) -{ -#ifndef WITH_LEAN - int c; - if (soap->error && soap->buflen > 0) - { if (soap->bufidx == 0) - soap->bufidx = 1; - c = soap->buf[soap->bufidx - 1]; - soap->buf[soap->bufidx - 1] = '\0'; - soap->buf[soap->buflen - 1] = '\0'; - if (soap->bufidx < soap->buflen) - fprintf(fd, "%s%c\n** HERE **\n%s\n", soap->buf, c, soap->buf + soap->bufidx); - else - fprintf(fd, "%s%c\n** HERE **\n", soap->buf, c); - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_register_plugin_arg(struct soap *soap, int (*fcreate)(struct soap*, struct soap_plugin*, void*), void *arg) -{ register struct soap_plugin *p; - register int r; - if (!(p = (struct soap_plugin*)SOAP_MALLOC(sizeof(struct soap_plugin)))) - return soap->error = SOAP_EOM; - p->id = NULL; - p->data = NULL; - p->fcopy = NULL; - p->fdelete = NULL; - r = fcreate(soap, p, arg); - if (!r && p->fdelete) - { p->next = soap->plugins; - soap->plugins = p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Registered '%s' plugin\n", p->id)); - return SOAP_OK; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not register plugin '%s': plugin returned error %d (or fdelete callback not set)\n", p->id?p->id:"?", r)); - SOAP_FREE(p); - return r; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void * -fplugin(struct soap *soap, const char *id) -{ register struct soap_plugin *p; - for (p = soap->plugins; p; p = p->next) - if (p->id == id || !strcmp(p->id, id)) - return p->data; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void * -SOAP_FMAC2 -soap_lookup_plugin(struct soap *soap, const char *id) -{ return soap->fplugin(soap, id); -} -#endif - -/******************************************************************************/ -#ifdef __cplusplus -} -#endif - diff --git a/org.glite.lb.server/examples/stdsoap2_2.6.2.c b/org.glite.lb.server/examples/stdsoap2_2.6.2.c deleted file mode 100644 index 78c4872..0000000 --- a/org.glite.lb.server/examples/stdsoap2_2.6.2.c +++ /dev/null @@ -1,11020 +0,0 @@ -/* - -stdsoap2.c[pp] 2.6.2 - -Runtime environment. - -gSOAP XML Web services tools -Copyright (C) 2000-2004, Robert van Engelen, Genivia, Inc. All Rights Reserved. - -Contributors: - -Wind River Systems, Inc., for the following additions (marked WR[...]): - - vxWorks compatible - - Support for IPv6. - --------------------------------------------------------------------------------- -gSOAP public license. - -The contents of this file are subject to the gSOAP Public License Version 1.3 -(the "License"); you may not use this file except in compliance with the -License. You may obtain a copy of the License at -http://www.cs.fsu.edu/~engelen/soaplicense.html -Software distributed under the License is distributed on an "AS IS" basis, -WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -for the specific language governing rights and limitations under the License. - -The Initial Developer of the Original Code is Robert A. van Engelen. -Copyright (C) 2000-2004 Robert A. van Engelen, Genivia inc. All Rights Reserved. --------------------------------------------------------------------------------- -GPL license. - -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 the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -Author contact information: -engelen@genivia.com / engelen@acm.org --------------------------------------------------------------------------------- - -Installation note: - -Win32 build needs winsock.dll (Visual C++ "wsock32.lib") -To do this in Visual C++ 6.0, go to "Project", "settings", select the "Link" -tab (the project file needs to be selected in the file view) and add -"wsock32.lib" to the "Object/library modules" entry - -*/ - -#include "stdsoap2.h" - -#ifdef __cplusplus -SOAP_SOURCE_STAMP("@(#) stdsoap2.cpp ver 2.6.2 2004-06-12 12:00:00 GMT") -extern "C" { -#else -SOAP_SOURCE_STAMP("@(#) stdsoap2.c ver 2.6.2 2004-06-12 12:00:00 GMT") -#endif - -/* 8bit character representing unknown/nonrepresentable character data (not supported by current locale) */ -#ifndef SOAP_UNKNOWN_CHAR -#define SOAP_UNKNOWN_CHAR (127) -#endif - -/* EOF=-1 */ -#define LT (wchar)(-2) /* XML character '<' */ -#define TT (wchar)(-3) /* XML character '' */ -#define QT (wchar)(-5) /* XML character '"' */ -#define AP (wchar)(-6) /* XML character ''' */ - -#define soap_blank(c) ((c) >= 0 && (c) <= 32) -#define soap_notblank(c) ((c) > 32) -#define soap_hash_ptr(p) (((unsigned long)(p) >> 3) & (SOAP_PTRHASH - 1)) - -static int soap_isxdigit(int); -static wchar soap_char(struct soap*); -static wchar soap_getchunkchar(struct soap*); -static void soap_update_ptrs(struct soap*, char*, char*, long); -static int soap_has_copies(struct soap*, char*, char*); -static struct soap_ilist *soap_hlookup(struct soap*, const char*); -static void soap_init_iht(struct soap*); -static void soap_free_iht(struct soap*); -static void soap_init_pht(struct soap*); -static void soap_free_pht(struct soap*); -static int soap_set_error(struct soap*, const char*, const char*, const char*, int); -static int soap_copy_fault(struct soap*, const char*, const char*, const char*); -static int soap_getattrval(struct soap*, char*, size_t, wchar); -static void soap_set_local_namespaces(struct soap*); -static size_t soap_begin_dime(struct soap*); -static int soap_isnumeric(struct soap*, const char*); -static void *fplugin(struct soap*, const char*); - -#ifndef WITH_LEAN -static time_t soap_timegm(struct tm*); -static void soap_init_logs(struct soap*); -static void soap_close_logfile(struct soap*, int); -static void soap_set_logfile(struct soap*, int, const char*); -#endif - -#ifdef WITH_FAST -/* Use look-aside buffers */ -static int soap_append_lab(struct soap*, const char*, size_t); -#endif - -#ifndef WITH_LEANER -static int soap_putdimefield(struct soap*, const char*, size_t); -static char *soap_getdimefield(struct soap*, size_t); -#endif - -#ifdef WITH_GZIP -static int soap_getgzipheader(struct soap*); -#endif - -#ifdef WITH_OPENSSL -static int ssl_auth_init(struct soap*); -static int ssl_verify_callback(int, X509_STORE_CTX*); -static int ssl_password(char*, int, int, void *); -/* This callback is included for future references. It should not be deleted -static DH *ssl_tmp_dh(SSL*, int, int); -*/ -#endif - -static const char *soap_strerror(struct soap*); -static const char *tcp_error(struct soap*); -static const char *http_error(struct soap*, int); -static int http_post(struct soap*, const char*, const char*, int, const char*, const char*, size_t); -static int http_get(struct soap*); -static int http_post_header(struct soap*, const char*, const char*); -static int http_response(struct soap*, int, size_t); -static int http_parse(struct soap*); -static int http_parse_header(struct soap*, const char*, const char*); -static int tcp_connect(struct soap*, const char*, const char*, int); -static int tcp_accept(struct soap*, int, struct sockaddr*, int*); -static int tcp_disconnect(struct soap*); -static int fsend(struct soap*, const char*, size_t); -static size_t frecv(struct soap*, char*, size_t); - -/* WR[ */ -#ifdef VXWORKS -static int vx_nonblocking = TRUE; /* ioctl argument */ -#endif -/* ]WR */ - -#ifndef PALM_2 -static const char soap_env1[42] = "http://schemas.xmlsoap.org/soap/envelope/"; -static const char soap_enc1[42] = "http://schemas.xmlsoap.org/soap/encoding/"; -static const char soap_env2[40] = "http://www.w3.org/2003/05/soap-envelope"; -static const char soap_enc2[40] = "http://www.w3.org/2003/05/soap-encoding"; -static const char soap_rpc[35] = "http://www.w3.org/2003/05/soap-rpc"; -#endif - -#ifndef PALM_1 -const struct soap_double_nan soap_double_nan = {0xFFFFFFFF, 0xFFFFFFFF}; -static const char soap_base64o[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char soap_base64i[81] = "\76XXX\77\64\65\66\67\70\71\72\73\74\75XXXXXXX\00\01\02\03\04\05\06\07\10\11\12\13\14\15\16\17\20\21\22\23\24\25\26\27\30\31XXXXXX\32\33\34\35\36\37\40\41\42\43\44\45\46\47\50\51\52\53\54\55\56\57\60\61\62\63"; -#endif - -static const char soap_padding[3] = "\0\0"; -#define SOAP_STR_PADDING (soap_padding) -#define SOAP_STR_EOS (soap_padding) - -#ifndef WITH_LEAN -static const struct soap_code_map html_entity_codes[] = /* entities for XHTML parsing */ -{ { 160, "nbsp" }, - { 161, "iexcl" }, - { 162, "cent" }, - { 163, "pound" }, - { 164, "curren" }, - { 165, "yen" }, - { 166, "brvbar" }, - { 167, "sect" }, - { 168, "uml" }, - { 169, "copy" }, - { 170, "ordf" }, - { 171, "laquo" }, - { 172, "not" }, - { 173, "shy" }, - { 174, "reg" }, - { 175, "macr" }, - { 176, "deg" }, - { 177, "plusmn" }, - { 178, "sup2" }, - { 179, "sup3" }, - { 180, "acute" }, - { 181, "micro" }, - { 182, "para" }, - { 183, "middot" }, - { 184, "cedil" }, - { 185, "sup1" }, - { 186, "ordm" }, - { 187, "raquo" }, - { 188, "frac14" }, - { 189, "frac12" }, - { 190, "frac34" }, - { 191, "iquest" }, - { 192, "Agrave" }, - { 193, "Aacute" }, - { 194, "Acirc" }, - { 195, "Atilde" }, - { 196, "Auml" }, - { 197, "Aring" }, - { 198, "AElig" }, - { 199, "Ccedil" }, - { 200, "Egrave" }, - { 201, "Eacute" }, - { 202, "Ecirc" }, - { 203, "Euml" }, - { 204, "Igrave" }, - { 205, "Iacute" }, - { 206, "Icirc" }, - { 207, "Iuml" }, - { 208, "ETH" }, - { 209, "Ntilde" }, - { 210, "Ograve" }, - { 211, "Oacute" }, - { 212, "Ocirc" }, - { 213, "Otilde" }, - { 214, "Ouml" }, - { 215, "times" }, - { 216, "Oslash" }, - { 217, "Ugrave" }, - { 218, "Uacute" }, - { 219, "Ucirc" }, - { 220, "Uuml" }, - { 221, "Yacute" }, - { 222, "THORN" }, - { 223, "szlig" }, - { 224, "agrave" }, - { 225, "aacute" }, - { 226, "acirc" }, - { 227, "atilde" }, - { 228, "auml" }, - { 229, "aring" }, - { 230, "aelig" }, - { 231, "ccedil" }, - { 232, "egrave" }, - { 233, "eacute" }, - { 234, "ecirc" }, - { 235, "euml" }, - { 236, "igrave" }, - { 237, "iacute" }, - { 238, "icirc" }, - { 239, "iuml" }, - { 240, "eth" }, - { 241, "ntilde" }, - { 242, "ograve" }, - { 243, "oacute" }, - { 244, "ocirc" }, - { 245, "otilde" }, - { 246, "ouml" }, - { 247, "divide" }, - { 248, "oslash" }, - { 249, "ugrave" }, - { 250, "uacute" }, - { 251, "ucirc" }, - { 252, "uuml" }, - { 253, "yacute" }, - { 254, "thorn" }, - { 255, "yuml" }, - { 0, NULL } -}; -#endif - -#ifndef WITH_LEAN -static const struct soap_code_map h_error_codes[] = -{ -#ifdef HOST_NOT_FOUND - { HOST_NOT_FOUND, "Host not found" }, -#endif -#ifdef TRY_AGAIN - { TRY_AGAIN, "Try Again" }, -#endif -#ifdef NO_RECOVERY - { NO_RECOVERY, "No Recovery" }, -#endif -#ifdef NO_DATA - { NO_DATA, "No Data" }, -#endif -#ifdef NO_ADDRESS - { NO_ADDRESS, "No Address" }, -#endif - { 0, NULL } -}; -#endif - -#ifndef WITH_LEAN -static const struct soap_code_map h_http_error_codes[] = -{ { 201, "Created" }, - { 202, "Accepted" }, - { 203, "Non-Authoritative Information" }, - { 204, "No Content" }, - { 205, "Reset Content" }, - { 206, "Partial Content" }, - { 300, "Multiple Choices" }, - { 301, "Moved Permanently" }, - { 302, "Found" }, - { 303, "See Other" }, - { 304, "Not Modified" }, - { 305, "Use Proxy" }, - { 307, "Temporary Redirect" }, - { 400, "Bad Request" }, - { 401, "Unauthorized" }, - { 402, "Payment Required" }, - { 403, "Forbidden" }, - { 404, "Not Found" }, - { 405, "Method Not Allowed" }, - { 406, "Not Acceptable" }, - { 407, "Proxy Authentication Required" }, - { 408, "Request Time-out" }, - { 409, "Conflict" }, - { 410, "Gone" }, - { 411, "Length Required" }, - { 412, "Precondition Failed" }, - { 413, "Request Entity Too Large" }, - { 414, "Request-URI Too Large" }, - { 415, "Unsupported Media Type" }, - { 416, "Requested range not satisfiable" }, - { 417, "Expectation Failed" }, - { 500, "Internal Server Error" }, - { 501, "Not Implemented" }, - { 502, "Bad Gateway" }, - { 503, "Service Unavailable" }, - { 504, "Gateway Time-out" }, - { 505, "HTTP Version not supported" }, - { 0, NULL } -}; -#endif - -#ifdef WITH_OPENSSL -static const struct soap_code_map h_ssl_error_codes[] = -{ -#define _SSL_ERROR(e) { e, #e } - _SSL_ERROR(SSL_ERROR_SSL), - _SSL_ERROR(SSL_ERROR_ZERO_RETURN), - _SSL_ERROR(SSL_ERROR_WANT_READ), - _SSL_ERROR(SSL_ERROR_WANT_WRITE), - _SSL_ERROR(SSL_ERROR_WANT_CONNECT), - _SSL_ERROR(SSL_ERROR_WANT_X509_LOOKUP), - _SSL_ERROR(SSL_ERROR_SYSCALL), - { 0, NULL } -}; -#endif - -#ifdef WIN32 -static int tcp_done = 0; -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -fsend(struct soap *soap, const char *s, size_t n) -{ register int nwritten; -#if defined(__cplusplus) && !defined(UNDER_CE) - if (soap->os) - { soap->os->write(s, n); - if (soap->os->good()) - return SOAP_OK; - return SOAP_EOF; - } -#endif - while (n) - { if (soap_valid_socket(soap->socket)) - { -#ifndef WITH_LEAN - if (soap->send_timeout) - { struct timeval timeout; - fd_set fd; - if (soap->send_timeout > 0) - { timeout.tv_sec = soap->send_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->send_timeout/1000000; - timeout.tv_usec = -soap->send_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - for (;;) - { register int r = select((SOAP_SOCKET)(soap->socket + 1), NULL, &fd, &fd, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - return SOAP_EOF; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - } - } -#endif -#ifdef WITH_OPENSSL - if (soap->ssl) - nwritten = SSL_write(soap->ssl, s, n); - else -#endif -#ifndef PALM - nwritten = send((SOAP_SOCKET)soap->socket, s, n, soap->socket_flags); -#else - nwritten = send((SOAP_SOCKET)soap->socket, (void*)s, n, soap->socket_flags); -#endif - if (nwritten <= 0) - { -#ifdef WITH_OPENSSL - int err; - if (soap->ssl && (err = SSL_get_error(soap->ssl, nwritten)) != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - return SOAP_EOF; -#endif - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EWOULDBLOCK && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - nwritten = 0; /* and call write() again */ - } - } - else - { -#ifdef WITH_FASTCGI - nwritten = fwrite((void*)s, 1, n, stdout); - fflush(stdout); -#else -#ifdef UNDER_CE - nwritten = fwrite(s, 1, n, soap->sendfd); -#else -/* WR[ */ -#ifdef VXWORKS -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - { - httpBlockPut(soap->rpmreqid, s, n); - nwritten = n; - } - else - { - nwritten = fwrite(s, sizeof(char), n, fdopen(soap->sendfd, "w")); - } -#else - nwritten = fwrite(s, sizeof(char), n, fdopen(soap->sendfd, "w")); -#endif /* WMW_RPM_IO */ -#else -/* ]WR */ - nwritten = write((SOAP_SOCKET)soap->sendfd, s, n); -/* WR[ */ -#endif -/* ]WR */ -#endif -#endif - if (nwritten <= 0) - { if (soap_errno != SOAP_EINTR && soap_errno != SOAP_EWOULDBLOCK && soap_errno != SOAP_EAGAIN) - { soap->errnum = soap_errno; - return SOAP_EOF; - } - nwritten = 0; /* and call write() again */ - } - } - n -= nwritten; - s += nwritten; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_flush_raw(struct soap *soap, const char *s, size_t n) -{ -#ifndef WITH_LEAN - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - { char *t; - if (!(t = (char*)soap_push_block(soap, n))) - return soap->error = SOAP_EOM; - memcpy(t, s, n); - return SOAP_OK; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { char t[16]; - sprintf(t, "\r\n%lX\r\n" + (soap->chunksize ? 0 : 2), (unsigned long)n); - DBGMSG(SENT, t, strlen(t)); - if ((soap->error = soap->fsend(soap, t, strlen(t)))) - return soap->error; - soap->chunksize += n; - } -#endif - DBGMSG(SENT, s, n); - return soap->error = soap->fsend(soap, s, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_flush(struct soap *soap) -{ if (soap->bufidx) - { -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { soap->d_stream.next_in = (Byte*)soap->buf; - soap->d_stream.avail_in = (unsigned int)soap->bufidx; -#ifdef WITH_GZIP - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->bufidx); -#endif - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating %u bytes\n", soap->d_stream.avail_in)); - if (deflate(&soap->d_stream, Z_NO_FLUSH) != Z_OK) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to deflate: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - return soap->error = SOAP_ZLIB_ERROR; - } - if (!soap->d_stream.avail_out) - { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN)) - return soap->error; - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - } - } while (soap->d_stream.avail_in); - } - else -#endif - if (soap_flush_raw(soap, soap->buf, soap->bufidx)) - return soap->error; - soap->bufidx = 0; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send_raw(struct soap *soap, const char *s, size_t n) -{ if (!n) - return SOAP_OK; - if (soap->mode & SOAP_IO_LENGTH) - { soap->count += n; - if (soap->fprepare) - return soap->fprepare(soap, s, n); - return SOAP_OK; - } - if (soap->mode & SOAP_IO) - { register size_t i = SOAP_BUFLEN - soap->bufidx; - while (n >= i) - { memcpy(soap->buf + soap->bufidx, s, i); - soap->bufidx = SOAP_BUFLEN; - if (soap_flush(soap)) - return soap->error; - s += i; - n -= i; - i = SOAP_BUFLEN; - } - memcpy(soap->buf + soap->bufidx, s, n); - soap->bufidx += n; - return SOAP_OK; - } - return soap_flush_raw(soap, s, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send(struct soap *soap, const char *s) -{ if (s) - return soap_send_raw(soap, s, strlen(s)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static size_t -frecv(struct soap *soap, char *s, size_t n) -{ register int r; - soap->errnum = 0; -#if defined(__cplusplus) && !defined(UNDER_CE) - if (soap->is) - { if (soap->is->good()) - return soap->is->read(s, n).gcount(); - return 0; - } -#endif - if (soap_valid_socket(soap->socket)) - { for (;;) - { -#ifndef WITH_LEAN - struct timeval timeout; - fd_set fd; - if (soap->recv_timeout) - { if (soap->recv_timeout > 0) - { timeout.tv_sec = soap->recv_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->recv_timeout/1000000; - timeout.tv_usec = -soap->recv_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - for (;;) - { r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r > 0) - break; - if (r == 0) - return 0; - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return 0; - } - } - } -#endif -#ifdef WITH_OPENSSL - if (soap->ssl) - { int err; - r = SSL_read(soap->ssl, s, n); - if ((err = SSL_get_error(soap->ssl, r)) == SSL_ERROR_NONE) - return (size_t)r; - if (err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - return 0; - } - else -#endif - { r = recv((SOAP_SOCKET)soap->socket, s, n, soap->socket_flags); - if (r >= 0) - return (size_t)r; - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - return 0; - } - } -#ifndef WITH_LEAN - { struct timeval timeout; - fd_set fd; - timeout.tv_sec = 0; - timeout.tv_usec = 10000; - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r < 0 && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return 0; - } - } -#endif - } - } -#ifdef WITH_FASTCGI - return fread(s, 1, n, stdin); -#else -#ifdef UNDER_CE - return fread(s, 1, n, soap->recvfd); -#else -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - { - r = httpBlockRead(soap->rpmreqid, s, n); - } - else - { - r = read(soap->recvfd, s, n); - } - if (r >= 0) - { - return r; - } - return 0; -#else -/* ]WR */ - r = read((SOAP_SOCKET)soap->recvfd, s, n); - if (r >= 0) - return (size_t)r; - soap->errnum = soap_errno; - return 0; -/* WR[ */ -#endif -/* ]WR */ -#endif -#endif -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static wchar -soap_getchunkchar(struct soap *soap) -{ if (soap->bufidx < soap->buflen) - return soap->buf[soap->bufidx++]; - soap->bufidx = 0; - soap->buflen = soap->chunkbuflen = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)soap->buflen)); - DBGMSG(RECV, soap->buf, soap->buflen); - if (soap->buflen) - return soap->buf[soap->bufidx++]; - return EOF; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_isxdigit(int c) -{ switch (c) - { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - return 1; - } - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_raw(struct soap *soap) -{ register size_t ret; -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { if (soap->d_stream.next_out == Z_NULL) - return EOF; - if (soap->d_stream.avail_in || !soap->d_stream.avail_out) - { register int r; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflating\n")); - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - r = inflate(&soap->d_stream, Z_NO_FLUSH); - if (r == Z_OK || r == Z_STREAM_END) - { soap->bufidx = 0; - soap->buflen = SOAP_BUFLEN - soap->d_stream.avail_out; - if (soap->zlib_in == SOAP_ZLIB_GZIP) - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->buflen); - if (r == Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_in = (float)soap->d_stream.total_in / (float)soap->d_stream.total_out; - soap->d_stream.next_out = Z_NULL; - } - if (soap->buflen) - { soap->count += soap->buflen; - return SOAP_OK; - } - } - else if (r != Z_BUF_ERROR) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate error: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - soap->d_stream.next_out = Z_NULL; - return EOF; - } - } -zlib_again: - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK && !soap->chunksize) - { memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN); - soap->buflen = soap->z_buflen; - } - } -#endif - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) /* read HTTP chunked transfer */ - { -chunk_again: - if (soap->chunksize) - { soap->buflen = ret = soap->frecv(soap, soap->buf, soap->chunksize > SOAP_BUFLEN ? SOAP_BUFLEN : soap->chunksize); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk: read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - soap->bufidx = 0; - soap->chunksize -= ret; - } - else - { register wchar c; - char tmp[8], *t; - t = tmp; - if (!soap->chunkbuflen) - { soap->chunkbuflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - soap->bufidx = 0; - if (!ret) - return EOF; - } - else - soap->bufidx = soap->buflen; - soap->buflen = soap->chunkbuflen; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk size (%u %u)\n", (unsigned int)soap->bufidx, (unsigned int)soap->buflen)); - while (!soap_isxdigit((int)(c = soap_getchunkchar(soap)))) - if ((int)c == EOF) - return EOF; - do - *t++ = (char)c; - while (soap_isxdigit((int)(c = soap_getchunkchar(soap))) && t - tmp < 7); - while ((int)c != EOF && c != '\n') - c = soap_getchunkchar(soap); - if ((int)c == EOF) - return EOF; - *t = '\0'; - soap->chunksize = soap_strtoul(tmp, &t, 16); - if (!soap->chunksize) - { soap->chunkbuflen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of chunked message\n")); - while ((int)c != EOF && c != '\n') - c = soap_getchunkchar(soap); - return EOF; - } - soap->buflen = soap->bufidx + soap->chunksize; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving buf len to %u (%u %s)\n", (unsigned int)soap->buflen, (unsigned int)soap->bufidx, tmp)); - if (soap->buflen > soap->chunkbuflen) - { soap->buflen = soap->chunkbuflen; - soap->chunksize -= soap->buflen - soap->bufidx; - soap->chunkbuflen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Passed end of buffer for chunked HTTP (%lu bytes left)\n", (unsigned long)(soap->buflen - soap->bufidx))); - } - else if (soap->chunkbuflen) - soap->chunksize = 0; - ret = soap->buflen - soap->bufidx; - if (!ret) - goto chunk_again; - } - } - else - { soap->bufidx = 0; - soap->buflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - } -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { int r; - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = (unsigned int)ret; - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - r = inflate(&soap->d_stream, Z_NO_FLUSH); - if (r == Z_OK || r == Z_STREAM_END) - { soap->bufidx = 0; - soap->z_buflen = soap->buflen; - soap->buflen = ret = SOAP_BUFLEN - soap->d_stream.avail_out; - if (soap->zlib_in == SOAP_ZLIB_GZIP) - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->buflen); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %u bytes\n", (unsigned int)ret)); - if (!ret) - goto zlib_again; - if (r == Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_in = (float)soap->d_stream.total_in / (float)soap->d_stream.total_out; - soap->d_stream.next_out = Z_NULL; - } - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to inflate: (%d) %s\n", r, soap->d_stream.msg?soap->d_stream.msg:"")); - soap->d_stream.next_out = Z_NULL; - return EOF; - } - } -#endif - soap->count += ret; - return !ret; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv(struct soap *soap) -{ -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - { if (soap->dime_buflen) - { char *s; - int i; - unsigned char tmp[12]; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME hdr for chunked DIME is in buffer\n")); - soap->count += soap->dime_buflen - soap->buflen; - soap->buflen = soap->dime_buflen; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Skip padding (%ld bytes)\n", -(long)soap->dime_size&3)); - for (i = -(long)soap->dime_size&3; i > 0; i--) - { soap->bufidx++; - if (soap->bufidx >= soap->buflen) - if (soap_recv_raw(soap)) - return EOF; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME hdr for next chunk\n")); - s = (char*)tmp; - for (i = 12; i > 0; i--) - { *s++ = soap->buf[soap->bufidx++]; - if (soap->bufidx >= soap->buflen) - if (soap_recv_raw(soap)) - return EOF; - } - soap->dime_flags = tmp[0] & 0x7; - soap->dime_size = ((size_t)tmp[8] << 24) | ((size_t)tmp[9] << 16) | ((size_t)tmp[10] << 8) | ((size_t)tmp[11]); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME chunk (%u bytes)\n", (unsigned int)soap->dime_size)); - if (soap->dime_flags & SOAP_DIME_CF) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "More chunking\n")); - soap->dime_chunksize = soap->dime_size; - if (soap->buflen - soap->bufidx >= soap->dime_size) - { soap->dime_buflen = soap->buflen; - soap->buflen = soap->bufidx + soap->dime_chunksize; - } - else - soap->dime_chunksize -= soap->buflen - soap->bufidx; - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Last chunk\n")); - soap->dime_buflen = 0; - soap->dime_chunksize = 0; - } - soap->count = soap->buflen - soap->bufidx; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%u bytes remaining\n", (unsigned int)soap->count)); - return SOAP_OK; - } - if (soap->dime_chunksize) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get next DIME hdr for chunked DIME (%u bytes chunk)\n", (unsigned int)soap->dime_chunksize)); - if (soap_recv_raw(soap)) - return EOF; - if (soap->buflen - soap->bufidx >= soap->dime_chunksize) - { soap->dime_buflen = soap->buflen; - soap->count -= soap->buflen - soap->bufidx - soap->dime_chunksize; - soap->buflen = soap->bufidx + soap->dime_chunksize; - } - else - soap->dime_chunksize -= soap->buflen - soap->bufidx; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%lu bytes remaining, count=%u\n", (unsigned long)(soap->buflen-soap->bufidx), (unsigned int)soap->count)); - return SOAP_OK; - } - } -#endif - return soap_recv_raw(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -wchar -SOAP_FMAC2 -soap_getchar(struct soap *soap) -{ register wchar c; - if (soap->ahead) - { c = soap->ahead; - soap->ahead = 0; - return c; - } - return soap_get1(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const struct soap_code_map* -SOAP_FMAC2 -soap_code(const struct soap_code_map *map, const char *str) -{ while (map->string) - { if (!strcmp(str, map->string)) - return map; - map++; - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_int_code(const struct soap_code_map *map, const char *str, long other) -{ while (map->string) - { if (!strcmp(str, map->string)) - return map->code; - map++; - } - return other; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_str_code(const struct soap_code_map *map, long code) -{ while (map->code != code && map->string) - map++; - return map->string; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static wchar -soap_char(struct soap *soap) -{ char tmp[8]; - register int i; - register wchar c; - register char *s = tmp; - for (i = 0; i < 7; i++) - { c = soap_get1(soap); - if (c == ';' || (int)c == EOF) - break; - *s++ = (char)c; - } - *s = '\0'; - if (*tmp == '#') - { if (tmp[1] == 'x' || tmp[1] == 'X') - return soap_strtol(tmp + 2, NULL, 16); - return atol(tmp + 1); - } - if (!strcmp(tmp, "lt")) - return '<'; - if (!strcmp(tmp, "gt")) - return '>'; - if (!strcmp(tmp, "amp")) - return '&'; - if (!strcmp(tmp, "quot")) - return '"'; - if (!strcmp(tmp, "apos")) - return '\''; -#ifndef WITH_LEAN - return (wchar)soap_int_code(html_entity_codes, tmp, 127); -#else - return SOAP_UNKNOWN_CHAR; /* use this to represent unknown code */ -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -wchar -SOAP_FMAC2 -soap_get(struct soap *soap) -{ register wchar c; - c = soap->ahead; - if (c) - soap->ahead = 0; - else - c = soap_get1(soap); - for (;;) - { if (soap->cdata) - { if (c == ']') - { c = soap_get1(soap); - if (c == ']') - { soap->cdata = 0; - soap_get1(soap); /* skip > */ - c = soap_get1(soap); - } - else - { soap_revget1(soap); - return ']'; - } - } - else - return c; - } - switch (c) - { case '<': - do c = soap_get1(soap); - while (soap_blank(c)); - if (c == '!' || c == '?' || c == '%') - { if (c == '!') - { c = soap_get1(soap); - if (c == '[') - { do c = soap_get1(soap); - while ((int)c != EOF && c != '['); - if ((int)c == EOF) - break; - soap->cdata = 1; - c = soap_get1(soap); - continue; - } - if (c == '-' && (c = soap_get1(soap)) == '-') - { do - { c = soap_get1(soap); - if (c == '-' && (c = soap_get1(soap)) == '-') - break; - } while ((int)c != EOF); - } - } - while ((int)c != EOF && c != '>') - c = soap_get1(soap); - if ((int)c == EOF) - break; - c = soap_get1(soap); - continue; - } - if (c == '/') - return TT; - soap_revget1(soap); - return LT; - case '>': - return GT; - case '"': - return QT; - case '\'': - return AP; - case '&': - return soap_char(soap) | 0x80000000; - } - break; - } - return c; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -wchar -SOAP_FMAC2 -soap_advance(struct soap *soap) -{ register wchar c; - while ((int)((c = soap_get(soap)) != EOF) && c != LT && c != TT) - ; - return c; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -wchar -SOAP_FMAC2 -soap_skip(struct soap *soap) -{ register wchar c; - do c = soap_get(soap); - while (soap_blank(c)); - return c; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_move(struct soap *soap, long n) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving %ld bytes forward\n", (long)n)); - for (; n > 0; n--) - if ((int)soap_getchar(soap) == EOF) - return SOAP_EOF; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_tell(struct soap *soap) -{ return soap->count - soap->buflen + soap->bufidx - (soap->ahead != 0); -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pututf8(struct soap *soap, register unsigned long c) -{ char tmp[16]; - if (c > 0 && c < 0x80) - { *tmp = (char)c; - return soap_send_raw(soap, tmp, 1); - } -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { register char *t = tmp; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - *t = '\0'; - } - else -#endif - sprintf(tmp, "&#%lu;", c); - return soap_send(soap, tmp); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -wchar -SOAP_FMAC2 -soap_getutf8(struct soap *soap) -{ register wchar c, c1, c2, c3, c4; - c = soap_get(soap); - if (c < 0x80) - return c; - c1 = soap_get(soap); - if (c1 < 0x80) - { soap_unget(soap, c1); - return c; - } - c1 &= 0x3F; - if (c < 0xE0) - return ((wchar)(c & 0x1F) << 6) | c1; - c2 = (wchar)soap_get1(soap) & 0x3F; - if (c < 0xF0) - return ((wchar)(c & 0x0F) << 12) | (c1 << 6) | c2; - c3 = (wchar)soap_get1(soap) & 0x3F; - if (c < 0xF8) - return ((wchar)(c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3; - c4 = (wchar)soap_get1(soap) & 0x3F; - if (c < 0xFC) - return ((wchar)(c & 0x03) << 24) | (c1 << 18) | (c2 << 12) | (c3 << 6) | c4; - return ((wchar)(c & 0x01) << 30) | (c1 << 24) | (c2 << 18) | (c3 << 12) | (c4 << 6) | (wchar)(soap_get1(soap) & 0x3F); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_puthex(struct soap *soap, const unsigned char *s, int n) -{ /* TODO: serialize to DOM (as an option) using new soap_s2hex() */ - char d[2]; - register int i; - for (i = 0; i < n; i++) - { register int m = *s++; - d[0] = (char)((m >> 4) + (m > 159 ? '7' : '0')); - m &= 0x0F; - d[1] = (char)(m + (m > 9 ? '7' : '0')); - if (soap_send_raw(soap, d, 2)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -unsigned char* -SOAP_FMAC2 -soap_gethex(struct soap *soap, int *n) -{ -#ifdef WITH_FAST - soap->labidx = 0; - for (;;) - { register char *s; - register int i, k; - if (soap_append_lab(soap, NULL, 0)) - return NULL; - s = soap->labbuf + soap->labidx; - k = soap->lablen - soap->labidx; - soap->labidx = soap->lablen; - for (i = 0; i < k; i++) - { register char d1, d2; - register wchar c; - c = soap_get(soap); - if (soap_isxdigit(c)) - { d1 = (char)c; - c = soap_get(soap); - if (soap_isxdigit(c)) - d2 = (char)c; - else - { soap->error = SOAP_TYPE; - return NULL; - } - } - else - { unsigned char *p; - soap_unget(soap, c); - if (n) - *n = (int)(soap->lablen - k + i); - p = (unsigned char*)soap_malloc(soap, soap->lablen - k + i); - if (p) - memcpy(p, soap->labbuf, soap->lablen - k + i); - return p; - } - *s++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0'); - } - } -#else - if (soap_new_block(soap)) - return NULL; - for (;;) - { register int i; - register char *s = (char*)soap_push_block(soap, SOAP_BLKLEN); - if (!s) - { soap_end_block(soap); - return NULL; - } - for (i = 0; i < SOAP_BLKLEN; i++) - { register char d1, d2; - register wchar c = soap_get(soap); - if (soap_isxdigit(c)) - { d1 = (char)c; - c = soap_get(soap); - if (soap_isxdigit(c)) - d2 = (char)c; - else - { soap_end_block(soap); - soap->error = SOAP_TYPE; - return NULL; - } - } - else - { unsigned char *p; - soap_unget(soap, c); - if (n) - *n = soap_size_block(soap, i); - p = (unsigned char*)soap_save_block(soap, NULL); - return p; - } - *s++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0'); - } - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putbase64(struct soap *soap, const unsigned char *s, int n) -{ register int i; - register unsigned long m; - char d[4]; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->data = (char*)soap_malloc(soap, (n + 2) / 3 * 4 + 1); - return soap_s2base64(soap, s, soap->dom->data, n); - } -#endif - if (!s) - return SOAP_OK; - for (; n > 2; n -= 3, s += 3) - { m = ((unsigned long)((unsigned char*)s)[0] << 16) | ((unsigned long)((unsigned char*)s)[1] << 8) | (unsigned long)((unsigned char*)s)[2]; - for (i = 4; i > 0; m >>= 6) - d[--i] = soap_base64o[m & 0x3F]; - if (soap_send_raw(soap, d, 4)) - return soap->error; - } - if (n > 0) - { m = 0; - for (i = 0; i < n; i++) - m = (m << 8) | *s++; - for (; i < 3; i++) - m <<= 8; - for (i++; i > 0; m >>= 6) - d[--i] = soap_base64o[m & 0x3F]; - for (i = 3; i > n; i--) - d[i] = '='; - if (soap_send_raw(soap, d, 4)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -unsigned char* -SOAP_FMAC2 -soap_getbase64(struct soap *soap, int *n, int malloc_flag) -{ -#ifdef WITH_FAST - soap->labidx = 0; - for (;;) - { register int i, k; - register char *s; - if (soap_append_lab(soap, NULL, 2)) - return NULL; - s = soap->labbuf + soap->labidx; - k = 3 * ((soap->lablen - soap->labidx) / 3); - soap->labidx = 3 * (soap->lablen / 3); - if (!s) - return NULL; - for (i = 0; i < k; i += 3) - { register unsigned long m = 0; - register int j = 0; - do - { register wchar c = soap_get(soap); - if (c == '=' || c < 0) - { unsigned char *p; - switch (j) - { case 2: - *s++ = (char)((m >> 4) & 0xFF); - i++; - break; - case 3: - *s++ = (char)((m >> 10) & 0xFF); - *s++ = (char)((m >> 2) & 0xFF); - i += 2; - } - if (n) - *n = (int)(soap->lablen - k + i); - p = (unsigned char*)soap_malloc(soap, soap->lablen - k + i); - if (p) - memcpy(p, soap->labbuf, soap->lablen - k + i); - if (c >= 0) - { while ((int)((c = soap_get(soap)) != EOF) && c != LT && c != TT) - ; - } - soap_unget(soap, c); - return p; - } - c -= '+'; - if (c >= 0 && c <= 79) - { m = (m << 6) + soap_base64i[c]; - j++; - } - } while (j < 4); - *s++ = (char)((m >> 16) & 0xFF); - *s++ = (char)((m >> 8) & 0xFF); - *s++ = (char)(m & 0xFF); - } - } -#else - if (soap_new_block(soap)) - return NULL; - for (;;) - { register int i; - register char *s = (char*)soap_push_block(soap, 3 * SOAP_BLKLEN); /* must be multiple of 3 */ - if (!s) - { soap_end_block(soap); - return NULL; - } - for (i = 0; i < SOAP_BLKLEN; i++) - { register unsigned long m = 0; - register int j = 0; - do - { register wchar c = soap_get(soap); - if (c == '=' || c < 0) - { unsigned char *p; - i *= 3; - switch (j) - { case 2: - *s++ = (char)((m >> 4) & 0xFF); - i++; - break; - case 3: - *s++ = (char)((m >> 10) & 0xFF); - *s++ = (char)((m >> 2) & 0xFF); - i += 2; - } - if (n) - *n = (int)soap_size_block(soap, i); - p = (unsigned char*)soap_save_block(soap, NULL); - if (c >= 0) - { while ((int)((c = soap_get(soap)) != EOF) && c != LT && c != TT) - ; - } - soap_unget(soap, c); - return p; - } - c -= '+'; - if (c >= 0 && c <= 79) - { m = (m << 6) + soap_base64i[c]; - j++; - } - } while (j < 4); - *s++ = (char)((m >> 16) & 0xFF); - *s++ = (char)((m >> 8) & 0xFF); - *s++ = (char)(m & 0xFF); - } - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_strdup(struct soap *soap, const char *s) -{ char *t = NULL; - if (s && (t = (char*)soap_malloc(soap, strlen(s) + 1))) - strcpy(t, s); - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_new_block(struct soap *soap) -{ struct soap_blist *p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New block sequence (prev=%p)\n", soap->blist)); - if (!(p = (struct soap_blist*)SOAP_MALLOC(sizeof(struct soap_blist)))) - return SOAP_EOM; - p->next = soap->blist; - p->ptr = NULL; - p->size = 0; - soap->blist = p; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_push_block(struct soap *soap, size_t n) -{ char *p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push block of %u bytes (%u bytes total)\n", (unsigned int)n, (unsigned int)soap->blist->size)); - if (!(p = (char*)SOAP_MALLOC(n + sizeof(char*) + sizeof(size_t)))) - { soap->error = SOAP_EOM; - return NULL; - } - *(char**)p = soap->blist->ptr; - *(size_t*)(p + sizeof(char*)) = n; - soap->blist->ptr = p; - soap->blist->size += n; - return p + sizeof(char*) + sizeof(size_t); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_pop_block(struct soap *soap) -{ char *p; - if (!soap->blist->ptr) - return; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pop block\n")); - p = soap->blist->ptr; - soap->blist->size -= *(size_t*)(p + sizeof(char*)); - soap->blist->ptr = *(char**)p; - SOAP_FREE(p); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_update_ptrs(struct soap *soap, char *start, char *end, long offset) -{ int i; - register struct soap_ilist *ip; - register void *p, **q; - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr && (char*)ip->ptr >= start && (char*)ip->ptr < end) - ip->ptr = (char*)ip->ptr + offset; - for (q = &ip->link; q; q = (void**)p) - { p = *q; - if (p && (char*)p >= start && (char*)p < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Link update id='%s' %p\n", ip->id, p)); - *q = (char*)p + offset; - } - } - for (q = &ip->copy; q; q = (void**)p) - { p = *q; - if (p && (char*)p >= start && (char*)p < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy update id='%s' %p\n", ip->id, p)); - *q = (char*)p + offset; - } - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_has_copies(struct soap *soap, register char *start, register char *end) -{ int i; - register struct soap_ilist *ip; - register char *p; - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - for (p = (char*)ip->copy; p; p = *(char**)p) - if (p >= start && p < end) - return SOAP_ERR; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_resolve(struct soap *soap) -{ register int i; - register struct soap_ilist *ip; - short flag1 = 0, flag2; - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr) - soap_resolve_ptr(ip); - else if (*ip->id == '#') - flag1 = 1; - } - do - { flag2 = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data\n")); - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - if (ip->copy && ip->ptr && ip->size) - if (!soap_has_copies(soap, (char*)ip->ptr, (char*)ip->ptr + ip->size)) - { register void *p, **q = (void**)ip->copy; - DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing copy chain to resolve id='%s'\n", ip->id)); - ip->copy = NULL; - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... copy %p -> %p (%u bytes)\n", ip->ptr, q, (unsigned int)ip->size)); - p = *q; - memcpy(q, ip->ptr, ip->size); - q = (void**)p; - } while (q); - flag2 = 1; - } - } while (flag2); - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - { register struct soap_flist *fp; - for (fp = ip->flist; fp; fp = fp->next) - if (fp->finsert) - { unsigned int k = fp->level; - void *p = ip->ptr; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded container data type=%d location=%p level=%u,%u\n", fp->type, fp->ptr, ip->level, fp->level)); - while (ip->level < k) - { void **q = (void**)soap_malloc(soap, sizeof(void*)); - if (!q) - return SOAP_EOM; - *q = p; - p = (void*)q; - k--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - fp->finsert(soap, fp->type, fp->ptr, p); - } - } - if (flag1) - return soap->error = SOAP_MISSING_ID; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_resolve_ptr(struct soap_ilist *ip) -{ register void *p, **q, *r; - q = (void**)ip->link; - ip->link = NULL; - r = ip->ptr; - while (q) - { p = *q; - *q = r; - q = (void**)p; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_size_block(struct soap *soap, size_t n) -{ if (soap->blist->ptr) - { soap->blist->size -= *(size_t*)(soap->blist->ptr + sizeof(char*)) - n; - *(size_t*)(soap->blist->ptr + sizeof(char*)) = n; - } - return soap->blist->size; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_first_block(struct soap *soap) -{ char *p, *q, *r; - p = soap->blist->ptr; - if (!p) - return NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "First block\n")); - r = NULL; - do - { q = *(char**)p; - *(char**)p = r; - r = p; - p = q; - } while (p); - soap->blist->ptr = r; - return r + sizeof(char*) + sizeof(size_t); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_next_block(struct soap *soap) -{ char *p; - p = soap->blist->ptr; - if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Next block\n")); - soap->blist->ptr = *(char**)p; - SOAP_FREE(p); - if (soap->blist->ptr) - return soap->blist->ptr + sizeof(char*) + sizeof(size_t); - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_block_size(struct soap *soap) -{ return *(size_t*)(soap->blist->ptr + sizeof(char*)); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_end_block(struct soap *soap) -{ struct soap_blist *bp; - char *p, *q; - bp = soap->blist; - if (bp) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of block sequence, free all remaining blocks\n")); - for (p = bp->ptr; p; p = q) - { q = *(char**)p; - SOAP_FREE(p); - } - soap->blist = bp->next; - SOAP_FREE(bp); - } - DBGLOG(TEST, if (soap->blist) SOAP_MESSAGE(fdebug, "Restore previous block sequence\n")); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_save_block(struct soap *soap, char *p) -{ register size_t n; - register char *q, *s; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Save all blocks in contiguous memory space of %u bytes (%p->%p)\n", (unsigned int)soap->blist->size, soap->blist->ptr, p)); - if (soap->blist->size) - { if (!p) - p = (char*)soap_malloc(soap, soap->blist->size); - if (p) - for (s = p, q = soap_first_block(soap); q; q = soap_next_block(soap)) - { n = soap_block_size(soap); - soap_update_ptrs(soap, q, q + n, (long)s - (long)q); /* pointers s and q may or may not be related */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy %u bytes from %p to %p\n", (unsigned int)n, q, s)); - memcpy(s, q, n); - s += n; - } - else - soap->error = SOAP_EOM; - } - soap_end_block(soap); - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_store_block(struct soap *soap, char *p) -{ p = soap_save_block(soap, p); - if (!soap->blist) - { struct soap_ilist *ip; - int i; - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - if (ip->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolve link chain to point to %p\n", ip->ptr)); - soap_resolve_ptr(ip); - } - } - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsize(struct soap *soap, const char *type, int size) -{ return soap_putsizes(soap, type, &size, 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsizes(struct soap *soap, const char *type, const int *size, int dim) -{ return soap_putsizesoffsets(soap, type, size, NULL, dim); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsizesoffsets(struct soap *soap, const char *type, const int *size, const int *offset, int dim) -{ int i; - if (!type) - return NULL; - if (soap->version == 2) - { sprintf(soap->type, "%s[%d", type, size[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), " %d", size[i]); - } - else - { if (offset) - { sprintf(soap->type, "%s[%d", type, size[0] + offset[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), ",%d", size[i] + offset[i]); - } - else - { sprintf(soap->type, "%s[%d", type, size[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), ",%d", size[i]); - } - strcat(soap->type, "]"); - } - return soap->type; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putoffset(struct soap *soap, int offset) -{ return soap_putoffsets(soap, &offset, 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putoffsets(struct soap *soap, const int *offset, int dim) -{ register int i; - sprintf(soap->arrayOffset, "[%d", offset[0]); - for (i = 1; i < dim; i++) - sprintf(soap->arrayOffset + strlen(soap->arrayOffset), ",%d", offset[i]); - strcat(soap->arrayOffset, "]"); - return soap->arrayOffset; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_size(const int *size, int dim) -{ register int i, n = size[0]; - for (i = 1; i < dim; i++) - n *= size[i]; - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getoffsets(const char *attr, const int *size, int *offset, int dim) -{ register int i, j = 0; - if (offset) - for (i = 0; i < dim && attr && *attr; i++) - { attr++; - j *= size[i]; - j += offset[i] = (int)atol(attr); - attr = strchr(attr, ','); - } - else - for (i = 0; i < dim && attr && *attr; i++) - { attr++; - j *= size[i]; - j += (int)atol(attr); - attr = strchr(attr, ','); - } - return j; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getsize(const char *attr1, const char *attr2, int *j) -{ register int n, k; - char *s; - *j = 0; - if (!*attr1) - return -1; - n = 1; - do - { attr1++; - k = (int)soap_strtol(attr1, &s, 10); - n *= k; - if (k < 0 || n > SOAP_MAXARRAYSIZE || s == attr1) - return -1; - attr1 = strchr(s, ','); - if (!attr1) - attr1 = strchr(s, ' '); - if (attr2 && *attr2) - { attr2++; - *j *= k; - k = (int)soap_strtol(attr2, &s, 10); - *j += k; - if (k < 0) - return -1; - attr2 = s; - } - } while (attr1 && *attr1 != ']'); - return n - *j; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getsizes(const char *attr, int *size, int dim) -{ register int i, k, n; - if (!*attr) - return -1; - i = strlen(attr); - n = 1; - do - { for (i = i-1; i >= 0; i--) - if (attr[i] == '[' || attr[i] == ',' || attr[i] == ' ') - break; - k = (int)atol(attr + i + 1); - n *= size[--dim] = k; - if (k < 0 || n > SOAP_MAXARRAYSIZE) - return -1; - } while (i >= 0 && attr[i] != '['); - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getposition(const char *attr, int *pos) -{ register int i, n; - if (!*attr) - return -1; - n = 0; - i = 1; - do - { pos[n++] = (int)atol(attr + i); - while (attr[i] && attr[i] != ',' && attr[i] != ']') - i++; - if (attr[i] == ',') - i++; - } while (n < SOAP_MAXDIMS && attr[i] && attr[i] != ']'); - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_push_namespace(struct soap *soap, const char *id, const char *ns) -{ register struct soap_nlist *np; - register struct Namespace *p; - np = (struct soap_nlist*)SOAP_MALLOC(sizeof(struct soap_nlist) + strlen(id)); - if (!np) - return soap->error = SOAP_EOM; - np->next = soap->nlist; - soap->nlist = np; - strcpy(np->id, id); - np->level = soap->level; - np->index = -1; - np->ns = NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push namespace binding (level=%u) '%s' '%s'\n", soap->level, id, ns)); - p = soap->local_namespaces; - if (p) - { register short i = 0; - if (!strcmp(ns, soap_env1)) - soap->version = 1; /* make sure we use SOAP 1.1 */ - else if (!strcmp(ns, soap_env2)) - soap->version = 2; /* make sure we use SOAP 1.2 */ - else - { for (; p->id; p++, i++) - { if (p->ns) - if (!strcmp(ns, p->ns)) - break; - if (p->in) - if (!soap_tag_cmp(ns, p->in)) - { if (p->out) - SOAP_FREE(p->out); - if ((p->out = (char*)SOAP_MALLOC(strlen(ns) + 1))) - strcpy(p->out, ns); - break; - } - } - } - if (i == 0 && (!p->ns || strcmp(ns, p->ns))) - { if (p[0].out) - SOAP_FREE(p[0].out); - if ((p[0].out = (char*)SOAP_MALLOC(strlen(ns) + 1))) - strcpy(p[0].out, ns); - if (p[1].out) - SOAP_FREE(p[1].out); - if (soap->version == 1) - { if ((p[1].out = (char*)SOAP_MALLOC(sizeof(soap_enc1)))) - strcpy(p[1].out, soap_enc1); - } - else if ((p[1].out = (char*)SOAP_MALLOC(sizeof(soap_enc2)))) - strcpy(p[1].out, soap_enc2); - } - if (p && p->id) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push OK ('%s' matches '%s' in namespace table)\n", id, p->id)); - np->index = i; - } - } - if (!p || !p->id) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push NOT OK: no match found for '%s' in namespace mapping table (added to stack anyway)\n", ns)); - np->ns = (char*)SOAP_MALLOC(strlen(ns) + 1); - if (!np->ns) - return soap->error = SOAP_EOM; - strcpy(np->ns, ns); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_push_default_namespace(struct soap *soap, const char *id, int n) -{ register struct soap_nlist *np = soap->nlist; - while (np && np->index >= -1) - np = np->next; - if (np && (!strncmp(np->id, id, n) && !np->id[n])) - return SOAP_OK; - np = (struct soap_nlist*)SOAP_MALLOC(sizeof(struct soap_nlist) + n); - if (!np) - return soap->error = SOAP_EOM; - np->next = soap->nlist; - soap->nlist = np; - strncpy(np->id, id, n); - np->id[n] = '\0'; - np->level = soap->level; - np->index = -2; - np->ns = NULL; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_pop_namespace(struct soap *soap) -{ register struct soap_nlist *np; - while (soap->nlist && soap->nlist->level >= soap->level) - { np = soap->nlist->next; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Popped namespace binding (level=%u) '%s'\n", soap->level, soap->nlist->id)); - if (soap->nlist->ns) - SOAP_FREE(soap->nlist->ns); - SOAP_FREE(soap->nlist); - soap->nlist = np; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_namespace(struct soap *soap, const char *id1, const char *id2, int n1, int n2) -{ register struct soap_nlist *np = soap->nlist; - while (np && (np->index == -2 || (strncmp(np->id, id1, n1) || np->id[n1]))) - np = np->next; - if (np) - { if (np->index < 0 || (np->index >= 0 && soap->local_namespaces[np->index].id && (strncmp(soap->local_namespaces[np->index].id, id2, n2) || soap->local_namespaces[np->index].id[n2]))) - return SOAP_NAMESPACE; - return SOAP_OK; - } - if (n1 == 3 && n1 == n2 && !strcmp(id1, "xml") && !strcmp(id1, id2)) - return SOAP_OK; - return SOAP_SYNTAX_ERROR; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_default_namespace(struct soap *soap) -{ register struct soap_nlist *np = soap->nlist; - while (np && np->index >= -1) - np = np->next; - if (np) - return np->id; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_tag_cmp(register const char *s, register const char *t) -{ for (; *s && *s != '"'; s++, t++) - if (tolower(*s) != tolower(*t)) - if (*t != '-') - { if (*t != '*') - return 1; - if (*++t) - { register int c = tolower(*t); - for (; *s && *s != '"'; s++) - { if (tolower(*s) == c) - if (!soap_tag_cmp(s + 1, t + 1)) - return 0; - } - break; - } - else - return 0; - } - if (*t == '*' && !t[1]) - return 0; - return *t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_tag(struct soap *soap, const char *tag1, const char *tag2) -{ register const char *s, *t; - if (!tag1 || !tag2 || !*tag2) - return SOAP_OK; - s = strchr(tag1, ':'); - t = strchr(tag2, ':'); - if (t) - { if (s) - { if (SOAP_STRCMP(s + 1, t + 1)) - return SOAP_TAG_MISMATCH; - if (t != tag2 && soap_match_namespace(soap, tag1, tag2, s - tag1, t - tag2)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); - return SOAP_TAG_MISMATCH; - } - } - else if (SOAP_STRCMP(tag1, t + 1)) - return SOAP_TAG_MISMATCH; - else if (t != tag2 && soap_match_namespace(soap, tag1, tag2, 0, t - tag2)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); - return SOAP_TAG_MISMATCH; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags and (default) namespaces match: '%s' '%s'\n", tag1, tag2)); - return SOAP_OK; - } - if (s) - { if (((soap->mode & SOAP_XML_STRICT) && soap->part != SOAP_IN_HEADER && soap->encodingStyle)) - return SOAP_TAG_MISMATCH; - if (SOAP_STRCMP(s + 1, tag2)) - return SOAP_TAG_MISMATCH; - if (!soap->encodingStyle) - { t = soap_default_namespace(soap); - if (!t || soap_match_namespace(soap, tag1, t, s - tag1, strlen(t))) - return SOAP_TAG_MISMATCH; - } - } - else if (SOAP_STRCMP(tag1, tag2)) - return SOAP_TAG_MISMATCH; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags match: '%s' '%s'\n", tag1, tag2)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_array(struct soap *soap, const char *type) -{ if (*soap->arrayType) - if (soap_match_tag(soap, soap->arrayType, type) - && soap_match_tag(soap, soap->arrayType, "xsd:anyType") - && soap_match_tag(soap, soap->arrayType, "xsd:ur-type") - ) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array type mismatch: '%s' '%s'\n", soap->arrayType, type)); - return SOAP_TAG_MISMATCH; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ - -#ifdef WITH_OPENSSL -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_server_context(struct soap *soap, unsigned short flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *dhfile, const char *randfile, const char *sid) -{ int err; - soap->keyfile = keyfile; - soap->password = password; - soap->cafile = cafile; - soap->capath = capath; - if (dhfile) - { soap->dhfile = dhfile; - soap->rsa = 0; - } - else - { soap->dhfile = NULL; - soap->rsa = 1; - } - soap->randfile = randfile; - soap->require_client_auth = (flags & SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION); - if (!(err = soap->fsslauth(soap))) - if (sid) - SSL_CTX_set_session_id_context(soap->ctx, (unsigned char*)sid, strlen(sid)); - return err; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_client_context(struct soap *soap, unsigned short flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *randfile) -{ soap->keyfile = keyfile; - soap->password = password; - soap->cafile = cafile; - soap->capath = capath; - soap->dhfile = NULL; - soap->rsa = 0; - soap->randfile = randfile; - soap->require_server_auth = (flags & SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION); - return soap->fsslauth(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -ssl_init() -{ static int done = 0; - if (!done) - { done = 1; - SSL_library_init(); -#ifndef WITH_LEAN - SSL_load_error_strings(); -#endif - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char * -ssl_error(struct soap *soap, int ret) -{ int err = SSL_get_error(soap->ssl, ret); - const char *msg = soap_str_code(h_ssl_error_codes, err); - if (msg) - strcpy(soap->msgbuf, msg); - else - return ERR_error_string(err, soap->msgbuf); - if (ERR_peek_error()) - { unsigned long r; - strcat(soap->msgbuf, "\n"); - while ((r = ERR_get_error())) - ERR_error_string_n(r, soap->msgbuf + strlen(soap->msgbuf), sizeof(soap->msgbuf) - strlen(soap->msgbuf)); - } - else - { switch (ret) - { case 0: - strcpy(soap->msgbuf, "EOF was observed that violates the protocol. The client probably provided invalid authentication information."); - break; - case -1: - sprintf(soap->msgbuf, "Error observed by underlying BIO: %s", strerror(errno)); - break; - } - } - return soap->msgbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_password(char *buf, int num, int rwflag, void *userdata) -{ if (num < (int)strlen((char*)userdata) + 1) - return 0; - return strlen(strcpy(buf, (char*)userdata)); -} -#endif - -/******************************************************************************/ -/* This callback is included for future references. It should not be deleted -#ifndef PALM_1 -static DH * -ssl_tmp_dh(SSL *ssl, int is_export, int keylength) -{ static DH *dh512 = NULL; - static DH *dh1024 = NULL; - DH *dh; - switch (keylength) - { case 512: - if (!dh512) - { BIO *bio = BIO_new_file("dh512.pem", "r"); - if (bio) - { dh512 = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - return dh512; - } - } - else - return dh512; - default: - if (!dh1024) - { BIO *bio = BIO_new_file("dh1024.pem", "r"); - if (bio) - { dh1024 = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - } - } - dh = dh1024; - } - return dh; -} -#endif -*/ -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_auth_init(struct soap *soap) -{ ssl_init(); - if (!soap->ctx) - if (!(soap->ctx = SSL_CTX_new(SSLv23_method()))) - return soap_set_receiver_error(soap, "SSL error", "Can't setup context", SOAP_SSL_ERROR); - if (soap->randfile) - { if (!RAND_load_file(soap->randfile, -1)) - return soap_set_receiver_error(soap, "SSL error", "Can't load randomness", SOAP_SSL_ERROR); - } - else if (!RAND_load_file("/dev/urandom", 1024)) - { int r; -#ifdef HAVE_RAND_R - unsigned int s = (unsigned int)time(NULL); -#endif - RAND_seed(soap->buf, sizeof(soap->buf)); - while (!RAND_status()) - { -#ifdef HAVE_RAND_R - r = rand_r(&s); -#else - r = rand(); -#endif - RAND_seed(&r, sizeof(int)); - } - } - if (soap->cafile || soap->capath) - if (!SSL_CTX_load_verify_locations(soap->ctx, soap->cafile, soap->capath)) - return soap_set_receiver_error(soap, "SSL error", "Can't read CA file and/or directory", SOAP_SSL_ERROR); - if (!SSL_CTX_set_default_verify_paths(soap->ctx)) - return soap_set_receiver_error(soap, "SSL error", "Can't read default CA file and/or directory", SOAP_SSL_ERROR); - if (soap->keyfile) - { if (!SSL_CTX_use_certificate_chain_file(soap->ctx, soap->keyfile)) - return soap_set_receiver_error(soap, "SSL error", "Can't read certificate key file", SOAP_SSL_ERROR); - if (soap->password) - { SSL_CTX_set_default_passwd_cb_userdata(soap->ctx, (void*)soap->password); - SSL_CTX_set_default_passwd_cb(soap->ctx, ssl_password); - if (!SSL_CTX_use_PrivateKey_file(soap->ctx, soap->keyfile, SSL_FILETYPE_PEM)) - return soap_set_receiver_error(soap, "SSL error", "Can't read key file", SOAP_SSL_ERROR); - } - } - if (soap->rsa) - { RSA *rsa = RSA_generate_key(512, RSA_F4, NULL, NULL); - if (!SSL_CTX_set_tmp_rsa(soap->ctx, rsa)) - { if (rsa) - RSA_free(rsa); - return soap_set_receiver_error(soap, "SSL error", "Can't set RSA key", SOAP_SSL_ERROR); - } - RSA_free(rsa); - } - else if (soap->dhfile) - { DH *dh = 0; - BIO *bio; - bio = BIO_new_file(soap->dhfile, "r"); - if (!bio) - return soap_set_receiver_error(soap, "SSL error", "Can't read DH file", SOAP_SSL_ERROR); - dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - if (SSL_CTX_set_tmp_dh(soap->ctx, dh) < 0) - { if (dh) - DH_free(dh); - return soap_set_receiver_error(soap, "SSL error", "Can't set DH parameters", SOAP_SSL_ERROR); - } - DH_free(dh); - } - SSL_CTX_set_options(soap->ctx, SSL_OP_ALL | SSL_OP_NO_SSLv2); - SSL_CTX_set_verify(soap->ctx, soap->require_client_auth ? (SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT) : soap->require_server_auth ? SSL_VERIFY_PEER : SSL_VERIFY_NONE, soap->fsslverify); -#if (OPENSSL_VERSION_NUMBER < 0x00905100L) - SSL_CTX_set_verify_depth(soap->ctx, 1); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_verify_callback(int ok, X509_STORE_CTX *store) -{ -#ifdef SOAP_DEBUG - if (!ok) - { char data[256]; - X509 *cert = X509_STORE_CTX_get_current_cert(store); - fprintf(stderr, "SSL Verify error with certificate at depth %d: %s\n", X509_STORE_CTX_get_error_depth(store), X509_verify_cert_error_string(X509_STORE_CTX_get_error(store))); - X509_NAME_oneline(X509_get_issuer_name(cert), data, sizeof(data)); - fprintf(stderr, "certificate issuer %s\n", data); - X509_NAME_oneline(X509_get_subject_name(cert), data, sizeof(data)); - fprintf(stderr, "certificate subject %s\n", data); - } -#endif - return ok; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_accept(struct soap *soap) -{ int i, r; - if (!soap_valid_socket(soap->socket)) - return soap_set_receiver_error(soap, "SSL error", "No socket in soap_ssl_accept()", SOAP_SSL_ERROR); - if (!soap->ssl) - { soap->ssl = SSL_new(soap->ctx); - if (!soap->ssl) - return soap_set_receiver_error(soap, "SSL error", "SSL_new() failed in soap_ssl_accept()", SOAP_SSL_ERROR); - } - else - SSL_clear(soap->ssl); - soap->imode |= SOAP_ENC_SSL; - soap->omode |= SOAP_ENC_SSL; -#ifdef WIN32 - u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &nonblocking); -#else - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)|O_NONBLOCK); -#endif - soap->bio = BIO_new_socket((SOAP_SOCKET)soap->socket, BIO_NOCLOSE); - SSL_set_bio(soap->ssl, soap->bio, soap->bio); - i = 100; - while ((r = SSL_accept(soap->ssl)) <= 0) - { int err = SSL_get_error(soap->ssl, r); - if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) - { struct timeval timeout; - fd_set fd; - if (i-- <= 0) - break; - timeout.tv_sec = 0; - timeout.tv_usec = 100000; - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r < 0 && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - } - else - { soap->errnum = err; - break; - } - } -#ifdef WIN32 - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &blocking); - } -#else - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)&~O_NONBLOCK); -#endif - if (r <= 0) - { soap_set_receiver_error(soap, ssl_error(soap, r), "SSL_accept() failed in soap_ssl_accept()", SOAP_SSL_ERROR); - soap_closesock(soap); - return SOAP_SSL_ERROR; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#endif /* WITH_OPENSSL */ - -/******************************************************************************/ -#ifndef PALM_1 -static int -tcp_init(struct soap *soap) -{ soap->errmode = 1; -#ifdef WIN32 - if (tcp_done) - return 0; - else - { WSADATA w; - if (WSAStartup(MAKEWORD(1, 1), &w)) - return -1; - tcp_done = 1; - } -#endif -#ifdef PALM - errno = 0; - h_errno = 0; - AppNetRefnum = 0; - NetUInit(); - AppNetTimeout = 10000; - NetLibOpen(AppNetRefnum, &h_errno); -#endif - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_done(struct soap *soap) -{ -#ifndef WITH_LEAN - int i; -#endif - soap_free(soap); - while (soap->clist) - { struct soap_clist *p = soap->clist->next; - SOAP_FREE(soap->clist); - soap->clist = p; - } - soap->keep_alive = 0; /* to force close the socket */ - soap_closesock(soap); -#ifdef WITH_COOKIES - soap_free_cookies(soap); -#endif - while (soap->plugins) - { register struct soap_plugin *p = soap->plugins->next; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Removing plugin '%s'\n", soap->plugins->id)); - if (soap->plugins->fcopy || !soap->copy) - soap->plugins->fdelete(soap, soap->plugins); - SOAP_FREE(soap->plugins); - soap->plugins = p; - } - soap->fplugin = fplugin; - soap->fpost = http_post; - soap->fget = http_get; - soap->fposthdr = http_post_header; - soap->fresponse = http_response; - soap->fparse = http_parse; - soap->fparsehdr = http_parse_header; -#ifndef MAC_CARBON - soap->faccept = tcp_accept; - soap->fopen = tcp_connect; - soap->fclose = tcp_disconnect; - soap->fsend = fsend; - soap->frecv = frecv; -#endif - soap->fprepare = NULL; - soap->fignore = NULL; -#ifdef WITH_OPENSSL - if (soap->session) - { SSL_SESSION_free(soap->session); - soap->session = NULL; - } -#endif - if (!soap->copy) - { if (soap_valid_socket(soap->master)) - { closesocket((SOAP_SOCKET)soap->master); - soap->master = SOAP_INVALID_SOCKET; - } -#ifdef WITH_OPENSSL - if (soap->ctx) - { SSL_CTX_free(soap->ctx); - soap->ctx = NULL; - } -#endif - } -#ifndef WITH_LEAN - for (i = 0; i < SOAP_MAXLOGS; i++) - { soap_close_logfile(soap, i); - if (soap->logfile[i]) - { SOAP_FREE((void*)soap->logfile[i]); - soap->logfile[i] = NULL; - } - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_cleanup(struct soap *soap) -{ soap_done(soap); -#ifdef WIN32 - if (!tcp_done) - return; - tcp_done = 0; - WSACleanup(); -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -tcp_error(struct soap *soap) -{ register const char *msg = NULL; - switch (soap->errmode) - { case 0: - msg = soap_strerror(soap); - break; - case 1: - msg = "WSAStartup failed"; - break; - case 2: - { -#ifndef WITH_LEAN - msg = soap_str_code(h_error_codes, soap->errnum); - if (!msg) -#endif - { sprintf(soap->msgbuf, "TCP error %d", soap->errnum); - msg = soap->msgbuf; - } - } - } - return msg; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -http_error(struct soap *soap, int status) -{ register const char *msg = NULL; -#ifndef WITH_LEAN - msg = soap_str_code(h_http_error_codes, status); - if (!msg) -#endif - { sprintf(soap->msgbuf, "HTTP error %d", status); - msg = soap->msgbuf; - } - return msg; -} -#endif - -/******************************************************************************/ -/* WR[ */ -#ifndef WITH_IPV6 -/* ]WR */ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -soap_gethost(struct soap *soap, const char *addr, struct in_addr *inaddr) -{ unsigned long iadd; - struct hostent hostent, *host = &hostent; -/* WR[ */ -#ifdef VXWORKS - int hostint; - char * addrcopy = (char*)malloc(strlen(addr) + 1); /*copy of addr. */ - /* inet_addr(), and hostGetByName() expect "char *"; addr is a "const char *". */ - strncpy(addrcopy, addr, strlen(addr)+1); - iadd = inet_addr(addrcopy); -#else -/* ]WR */ -#if defined(_AIXVERSION_431) || defined(TRU64) - struct hostent_data ht_data; -#endif - iadd = inet_addr(addr); -/* WR[ */ -#endif -/* ]WR */ - if ((int)iadd != -1) - { memcpy(inaddr, &iadd, sizeof(iadd)); -/* WR[ */ -#ifdef VXWORKS - free(addrcopy); -#endif -/* ]WR */ - return 0; - } -#if defined(__GLIBC__) - if (gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &host, &soap->errnum) < 0) - host = NULL; -#elif defined(_AIXVERSION_431) || defined(TRU64) - memset(&ht_data, 0, sizeof(ht_data)); - if (gethostbyname_r(addr, &hostent, &ht_data) < 0) - { host = NULL; - soap->errnum = h_errno; - } -#elif defined(HAVE_GETHOSTBYNAME_R) - host = gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &soap->errnum); -/* WR[ */ -#elif defined(VXWORKS) - /* If the DNS resolver library resolvLib has been configured in the vxWorks - * image, a query for the host IP address is sent to the DNS server, if the - * name was not found in the local host table. */ - hostint = hostGetByName(addrcopy); - if (hostint == ERROR) - { - host = NULL; - soap->errnum = soap_errno; - } - free(addrcopy); /*free() is placed after the error checking to assure that - * errno captured is that from hostGetByName() */ -/* ]WR */ -#else - if (!(host = gethostbyname(addr))) - soap->errnum = h_errno; -#endif - if (!host) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Host name not found\n")); - return -1; - } -/* WR[ */ -#ifdef VXWORKS - inaddr->s_addr = hostint; -#else -/* ]WR */ - memcpy(inaddr, host->h_addr, host->h_length); -/* WR[ */ -#endif -/* ]WR */ - return 0; -} -#endif -#endif -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_connect(struct soap *soap, const char *endpoint, const char *host, int port) -{ struct sockaddr_in sockaddr; -/* WR[ */ -#ifdef WITH_IPV6 - struct addrinfo *addrinfo; - struct addrinfo hints; - struct addrinfo resaddr; - struct sockaddr_storage addrstorage; - int err; -#endif /* WITH_IPV6 */ -/* ]WR */ - register int fd; -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - if (soap_valid_socket(soap->socket)) - closesocket((SOAP_SOCKET)soap->socket); - soap->socket = SOAP_INVALID_SOCKET; - if (tcp_init(soap)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP initialization failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - soap->errmode = 0; -/* WR[ */ -#ifdef WITH_IPV6 - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - soap->errmode = 2; - if (soap->proxy_host) - err = getaddrinfo(soap->proxy_host, soap_int2s(soap, soap->proxy_port), &hints, &addrinfo); - else - err = getaddrinfo(host, soap_int2s(soap, port), &hints, &addrinfo); - if (addrinfo) - { resaddr = *addrinfo; - addrstorage = *((struct sockaddr_storage *) addrinfo->ai_addr); - resaddr.ai_addr = (struct sockaddr *) &addrstorage; - freeaddrinfo(addrinfo); - } - if (err) - { soap_set_sender_error(soap, gai_strerror(err), - "TCP getaddrinfo on proxy host failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - fd = (int)socket(resaddr.ai_family, resaddr.ai_socktype, resaddr.ai_protocol); /* modified to use fd */ - soap->errmode = 0; -#else /* WITH_IPV6 */ -/* ]WR */ - fd = (int)socket(AF_INET, SOCK_STREAM, 0); -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - if (fd < 0) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP socket failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } -#ifndef WITH_LEAN - if (soap->connect_flags & SO_LINGER) - { struct linger linger; - memset(&linger, 0, sizeof(struct linger)); - linger.l_onoff = 1; - linger.l_linger = 0; - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_LINGER failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - } - if ((soap->connect_flags & ~SO_LINGER) && setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, soap->connect_flags & ~SO_LINGER, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)fd, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } -#endif -#endif -/* WR[ */ -#ifndef WITH_IPV6 -/* ]WR */ - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin_family = AF_INET; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Open socket %d to host='%s'\n", fd, host)); - soap->errmode = 2; - if (soap->proxy_host) - { if (soap_gethost(soap, soap->proxy_host, &sockaddr.sin_addr)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP get proxy host by name failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - sockaddr.sin_port = htons((short)soap->proxy_port); - } - else - { if (soap_gethost(soap, host, &sockaddr.sin_addr)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP get host by name failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - sockaddr.sin_port = htons((short)port); - } - soap->errmode = 0; -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifndef WITH_LEAN - if (soap->connect_timeout) -#if defined(WIN32) - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &nonblocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { - vx_nonblocking = TRUE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)|O_NONBLOCK); -#endif - else -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { - vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - for (;;) - { -/* WR[ */ -#ifdef WITH_IPV6 - if (connect((SOAP_SOCKET)fd, resaddr.ai_addr, resaddr.ai_addrlen)) /* modified to use fd */ -#else /* WITH_IPV6 */ - if (connect((SOAP_SOCKET)fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr))) -#endif /* WITH_IPV6 */ -/* ]WR */ - { -#ifndef WITH_LEAN - if (soap->connect_timeout && (soap_socket_errno == SOAP_EINPROGRESS || soap_socket_errno == SOAP_EWOULDBLOCK)) - { struct timeval timeout; -#if defined(SOCKLEN_T) - SOCKLEN_T n = sizeof(struct sockaddr_in); -#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) - socklen_t n = sizeof(struct sockaddr_in); -#elif defined(WIN32) || defined(__APPLE__) || defined(HP_UX) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) - int n = sizeof(struct sockaddr_in); -#else - size_t n = sizeof(struct sockaddr_in); -#endif - fd_set fds; - if (soap->connect_timeout > 0) - { timeout.tv_sec = soap->connect_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->connect_timeout/1000000; - timeout.tv_usec = -soap->connect_timeout%1000000; - } - FD_ZERO(&fds); - FD_SET((SOAP_SOCKET)fd, &fds); - for (;;) - { int r = select((SOAP_SOCKET)(fd + 1), NULL, &fds, NULL, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect timeout\n")); - soap_set_sender_error(soap, "Timeout", "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - } - n = sizeof(soap->errnum); - if (!getsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_ERROR, (char*)&soap->errnum, &n) && !soap->errnum) - break; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - else -#endif - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - closesocket((SOAP_SOCKET)fd); - return -1; - } - } - else - break; - } -#ifndef WITH_LEAN - if (soap->connect_timeout) -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { - vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - soap->socket = fd; -#ifdef WITH_OPENSSL - soap->imode &= ~SOAP_ENC_SSL; - soap->omode &= ~SOAP_ENC_SSL; - if (!strncmp(endpoint, "https:", 6)) - { int r; - if (soap->proxy_host) - { unsigned int k = soap->omode; /* make sure we only parse HTTP */ - size_t n = soap->count; /* save the content length */ - soap->omode &= ~0xFF; /* mask IO and ENC */ - soap->omode |= SOAP_IO_BUFFER; - soap_begin_send(soap); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connecting to proxy server\n")); - sprintf(soap->tmpbuf, "CONNECT %s:%d HTTP/%s", host, port, soap->http_version); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return -1; -#ifndef WITH_LEAN - if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((soap->error = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) - return soap->error; - } -#endif - if ((soap->error = soap->fposthdr(soap, NULL, NULL)) - || soap_flush(soap)) - return -1; - soap->omode = k; - k = soap->imode; - soap->imode &= ~0xFF; /* mask IO and ENC */ - if (soap_begin_recv(soap)) - return -1; - soap->imode = k; - soap->count = n; - soap_begin_send(soap); - } - if (!soap->ctx && (soap->error = soap->fsslauth(soap))) - { soap_set_sender_error(soap, "SSL error", "SSL authentication failed in tcp_connect(): check password, key file, and ca file.", SOAP_SSL_ERROR); - return -1; - } - soap->ssl = SSL_new(soap->ctx); - if (!soap->ssl) - { soap->error = SOAP_SSL_ERROR; - return -1; - } - if (soap->session) - { if (!strcmp(soap->session_host, host) && soap->session_port == port) - SSL_set_session(soap->ssl, soap->session); - SSL_SESSION_free(soap->session); - soap->session = NULL; - } - soap->imode |= SOAP_ENC_SSL; - soap->omode |= SOAP_ENC_SSL; - soap->bio = BIO_new_socket((SOAP_SOCKET)fd, BIO_NOCLOSE); - SSL_set_bio(soap->ssl, soap->bio, soap->bio); -#ifndef WITH_LEAN - if (soap->connect_timeout) -#ifdef WIN32 - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &nonblocking); - } -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)|O_NONBLOCK); -#endif -#endif - for (;;) - { if ((r = SSL_connect(soap->ssl)) <= 0) - { int err = SSL_get_error(soap->ssl, r); - if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - { soap_set_sender_error(soap, ssl_error(soap, r), "SSL connect failed in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - if (soap->connect_timeout) - { struct timeval timeout; - fd_set fds; - if (soap->connect_timeout > 0) - { timeout.tv_sec = soap->connect_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->connect_timeout/1000000; - timeout.tv_usec = -soap->connect_timeout%1000000; - } - FD_ZERO(&fds); - FD_SET((SOAP_SOCKET)(soap->socket), &fds); - for (;;) - { int r = select((SOAP_SOCKET)(soap->socket + 1), &fds, NULL, &fds, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect timeout\n")); - soap_set_sender_error(soap, "Timeout", "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - } - continue; - } - } - break; - } -#ifndef WITH_LEAN - if (soap->connect_timeout) -#ifdef WIN32 - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - if (soap->require_server_auth) - { X509 *peer; - int err; - if ((err = SSL_get_verify_result(soap->ssl)) != X509_V_OK) - { soap_set_sender_error(soap, X509_verify_cert_error_string(err), "SSL certificate cannot be verified in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - peer = SSL_get_peer_certificate(soap->ssl); - if (!peer) - { soap_set_sender_error(soap, "SSL error", "No SSL certificate was presented by the peer in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - X509_NAME_get_text_by_NID(X509_get_subject_name(peer), NID_commonName, soap->msgbuf, sizeof(soap->msgbuf)); - X509_free(peer); - if (soap_tag_cmp(soap->msgbuf, host)) - { soap_set_sender_error(soap, "SSL error", "SSL certificate host name mismatch in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - } - } -#endif - return fd; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_bind(struct soap *soap, const char *host, int port, int backlog) -{ struct sockaddr_in sockaddr; -/* WR[ */ -#ifdef WITH_IPV6 - struct addrinfo *addrinfo; - struct addrinfo hints; - struct addrinfo resaddr; - struct sockaddr_storage addrstorage; - int err; -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - if (soap_valid_socket(soap->master)) - { closesocket((SOAP_SOCKET)soap->master); - soap->master = SOAP_INVALID_SOCKET; - } - soap->socket = SOAP_INVALID_SOCKET; - soap->errmode = 1; - if (tcp_init(soap)) - { soap_set_receiver_error(soap, tcp_error(soap), "TCP init failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#ifdef WITH_IPV6 - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; - soap->errmode = 2; - if (host) - err = getaddrinfo(host, soap_int2s(soap, port), &hints, &addrinfo); - else - err = getaddrinfo(NULL, soap_int2s(soap, port), &hints, &addrinfo); - if (NULL != addrinfo) - { - resaddr = *addrinfo; - addrstorage = *((struct sockaddr_storage *) addrinfo->ai_addr); - resaddr.ai_addr = (struct sockaddr *) &addrstorage; - freeaddrinfo(addrinfo); - } - if (err) - { soap_set_receiver_error(soap, gai_strerror(err), "TCP getaddrinfo failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - soap->errmode = 0; - if ((soap->master = socket(resaddr.ai_family, resaddr.ai_socktype, resaddr.ai_protocol)) < 0) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP socket failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#else /* WITH_IPV6 */ -/* ]WR */ - soap->errmode = 0; - if ((soap->master = (int)socket(AF_INET, SOCK_STREAM, 0)) < 0) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP socket failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifndef WITH_LEAN - if (soap->bind_flags && setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, soap->bind_flags, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)soap->master, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#endif -#endif -/* WR[ */ -#ifdef WITH_IPV6 - soap->errmode = 0; - if (bind(soap->master, resaddr.ai_addr, resaddr.ai_addrlen) || listen(soap->master, backlog)) - { - soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n")); - soap_closesock(soap); - soap_set_receiver_error(soap, tcp_error(soap), "TCP bind failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#else /* WITH_IPV6 */ -/* ]WR */ - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin_family = AF_INET; - soap->errmode = 2; - if (host) - { if (soap_gethost(soap, host, &sockaddr.sin_addr)) - { soap_set_receiver_error(soap, tcp_error(soap), "TCP get host by name failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - } - else - sockaddr.sin_addr.s_addr = htonl(INADDR_ANY); - sockaddr.sin_port = htons((short)port); - soap->errmode = 0; - if (bind((SOAP_SOCKET)soap->master, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) || listen((SOAP_SOCKET)soap->master, backlog)) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n")); - soap_closesock(soap); - soap_set_receiver_error(soap, tcp_error(soap), "TCP bind failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifdef WITH_OPENSSL - if (!soap->ctx && (soap->error = soap->fsslauth(soap))) - return -1; -#endif - return soap->master; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_poll(struct soap *soap) -{ -#ifndef WITH_LEAN - struct timeval timeout; - fd_set sfd,rfd; - int r; - timeout.tv_sec = 0; - timeout.tv_usec = 0; - FD_ZERO(&rfd); - FD_ZERO(&sfd); - if (soap->socket >= 0) - { FD_SET(soap->socket, &rfd); - FD_SET(soap->socket, &sfd); - r = select(soap->socket + 1, &rfd, &sfd, NULL, &timeout); - } - else if (soap->master >= 0) - { FD_SET(soap->master, &rfd); - r = select(soap->master + 1, &rfd, &sfd, NULL, &timeout); - } - else - { FD_SET(soap->sendfd, &sfd); - FD_SET(soap->recvfd, &rfd); - r = select((soap->sendfd > soap->recvfd ? soap->sendfd : soap->recvfd) + 1, &rfd, &sfd, NULL, &timeout); - } - if (r > 0) - { -#ifdef WITH_OPENSSL - if (soap->ssl) - { if ((soap->socket >= 0) && FD_ISSET(soap->socket, &rfd)) - { char buf = '\0'; - if (SSL_peek(soap->ssl, &buf, 1) <= 0) - return SOAP_EOF; - } - } -#endif - return SOAP_OK; - } - if (r < 0 && (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "select failed in soap_poll()", SOAP_TCP_ERROR); - return soap->error = SOAP_TCP_ERROR; - } - else - soap->errnum = soap_errno; - return SOAP_EOF; -#else - return SOAP_OK; -#endif -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_accept(struct soap *soap, int s, struct sockaddr *a, int *n) -{ -#if defined(SOCKLEN_T) - return (int)accept((SOAP_SOCKET)s, a, (SOCKLEN_T*)n); -#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) - return (int)accept((SOAP_SOCKET)s, a, (socklen_t*)n); -#elif defined(WIN32) || defined(__APPLE__) || defined(HP_UX) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) - return (int)accept((SOAP_SOCKET)s, a, n); -#else - return (int)accept((SOAP_SOCKET)s, a, (size_t*)n); -#endif -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_accept(struct soap *soap) -{ -/* WR[ */ -#ifdef WITH_IPV6 - struct sockaddr_storage sockaddr; -#else /* WITH_IPV6 */ -/* ]WR */ - struct sockaddr_in sockaddr; -/* WR[ */ -#endif -/* ]WR */ - int n = (int)sizeof(struct sockaddr); -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - memset(&sockaddr, 0, sizeof(sockaddr)); - soap->socket = SOAP_INVALID_SOCKET; - soap->errmode = 0; - if (soap_valid_socket(soap->master)) - { for (;;) - { -#ifndef WITH_LEAN - if (soap->accept_timeout) - { struct timeval timeout; - fd_set fd; - if (soap->accept_timeout > 0) - { timeout.tv_sec = soap->accept_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->accept_timeout/1000000; - timeout.tv_usec = -soap->accept_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->master, &fd); - for (;;) - { int r = select((SOAP_SOCKET)(soap->master + 1), &fd, &fd, NULL, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - soap_set_receiver_error(soap, "Timeout", "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - soap_closesock(soap); - soap_set_sender_error(soap, tcp_error(soap), "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } -#if defined(WIN32) - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &nonblocking); - } -#elif defined(VXWORKS) - { vx_nonblocking = TRUE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - } -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)|O_NONBLOCK); -#endif - } - else -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { - vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)&~O_NONBLOCK); -#endif -#endif - if ((soap->socket = soap->faccept(soap, soap->master, (struct sockaddr*)&sockaddr, &n)) >= 0) - { -/* WR[ */ -#ifdef WITH_IPV6 -/* Use soap->host to store the numeric form of the remote host */ - getnameinfo((struct sockaddr*)&sockaddr, n, soap->host, sizeof(soap->host), NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV); - soap->ip = 0; /* info stored in soap->host */ - soap->port = 0; /* info stored in soap->host */ -#else /* WITH_IPV6 */ -/* ]WR */ - soap->ip = ntohl(sockaddr.sin_addr.s_addr); - soap->port = (int)ntohs(sockaddr.sin_port); -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - soap->keep_alive = ((soap->imode & SOAP_IO_KEEPALIVE) != 0); -#ifndef WITH_LEAN - if (soap->accept_flags & SO_LINGER) - { struct linger linger; - memset(&linger, 0, sizeof(struct linger)); - linger.l_onoff = 1; - linger.l_linger = 0; - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_LINGER failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } - if ((soap->accept_flags & ~SO_LINGER) && setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, soap->accept_flags & ~SO_LINGER, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)soap->socket, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -#endif -#endif - if (soap->accept_timeout) - { -#if defined(WIN32) - u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &blocking); - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &blocking); -/* WR[ */ -#elif defined(VXWORKS) - vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - ioctl((SOAP_SOCKET)soap->socket, FIONBIO, (int)(&vx_nonblocking)); -/* ]WR */ -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)&~O_NONBLOCK); - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)&~O_NONBLOCK); -#endif - } - return soap->socket; - } - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } - } - else - { soap_set_receiver_error(soap, tcp_error(soap), "TCP no master socket in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_disconnect(struct soap *soap) -{ -#ifdef WITH_OPENSSL - if (soap->ssl) - { int r, s = 0; - if (soap->session) - SSL_SESSION_free(soap->session); - if (*soap->host) - { soap->session = SSL_get1_session(soap->ssl); - if (soap->session) - { strcpy(soap->session_host, soap->host); - soap->session_port = soap->port; - } - } - r = SSL_shutdown(soap->ssl); - if (r != 1) - { s = ERR_get_error(); - if (s) - { if (soap_valid_socket(soap->socket)) - { shutdown((SOAP_SOCKET)soap->socket, 1); - soap->socket = SOAP_INVALID_SOCKET; - } - r = SSL_shutdown(soap->ssl); - } - } - DBGLOG(TEST, if (s) SOAP_MESSAGE(fdebug, "Shutdown failed: %d\n", SSL_get_error(soap->ssl, r))); - SSL_free(soap->ssl); - soap->ssl = NULL; - if (s) - return SOAP_SSL_ERROR; - ERR_remove_state(0); - } -#endif - if (soap_valid_socket(soap->socket)) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Closing socket %d\n", soap->socket)); - shutdown((SOAP_SOCKET)soap->socket, 2); - closesocket((SOAP_SOCKET)soap->socket); - soap->socket = SOAP_INVALID_SOCKET; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_closesock(struct soap *soap) -{ register int status = soap->error; -#ifndef MAC_CARBON - if (status == SOAP_EOF || !soap->keep_alive) - { if ((soap->error = soap->fclose(soap))) - return soap->error; - soap->socket = SOAP_INVALID_SOCKET; - } -#endif -#ifdef WITH_ZLIB - if (soap->zlib_state == SOAP_ZLIB_DEFLATE) - deflateEnd(&soap->d_stream); - else if (soap->zlib_state == SOAP_ZLIB_INFLATE) - inflateEnd(&soap->d_stream); - soap->zlib_state = SOAP_ZLIB_NONE; -#endif - return soap->error = status; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_hash(register const char *s) -{ register int h = 0; - while (*s) - h += *s++ & 0x1F; - return h % SOAP_IDHASH; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_init_pht(struct soap *soap) -{ register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing pointer hashtable\n")); - for (i = 0; i < SOAP_PTRHASH; i++) - soap->pht[i] = NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new() -{ struct soap *soap = (struct soap*)SOAP_MALLOC(sizeof(struct soap)); - if (soap) - soap_init(soap); - return soap; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new1(int mode) -{ return soap_new2(mode, mode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new2(int imode, int omode) -{ struct soap *soap = (struct soap*)SOAP_MALLOC(sizeof(struct soap)); - if (soap) - soap_init2(soap, imode, omode); - return soap; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static void -soap_free_pht(struct soap *soap) -{ register struct soap_plist *pp, *next; - register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free pointer hashtable\n")); - for (i = 0; i < SOAP_PTRHASH; i++) - { for (pp = soap->pht[i]; pp; pp = next) - { next = pp->next; - SOAP_FREE(pp); - } - soap->pht[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_embed_element(struct soap *soap, const void *p, const char *tag, int type) -{ register int i; - struct soap_plist *pp; - if (soap->version != 1) - soap->encoding = 1; - if ((i = soap_pointer_lookup(soap, p, type, &pp))) - { if (soap_is_embedded(soap, pp) || soap_is_single(soap, pp)) - return 0; - soap_set_embedded(soap, pp); - } - return i; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_embed_array(struct soap *soap, const void *p, const struct soap_array *a, int n, const char *tag, int type) -{ register int i; - struct soap_plist *pp; - if (soap->version != 1) - soap->encoding = 1; - if ((i = soap_array_pointer_lookup(soap, p, a, n, type, &pp))) - { if (soap_is_embedded(soap, pp) || soap_is_single(soap, pp)) - return 0; - soap_set_embedded(soap, pp); - } - return i; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pointer_lookup(struct soap *soap, const void *p, int type, struct soap_plist **ppp) -{ register struct soap_plist *pp; - *ppp = NULL; - if (p) - for (pp = soap->pht[soap_hash_ptr(p)]; pp; pp = pp->next) - if (pp->ptr == p && pp->type == type) - { *ppp = pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup location=%p type=%d id=%d\n", p, type, pp->id)); - return pp->id; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup location=%p type=%d: not found\n", p, type)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_pointer_lookup(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp) -{ struct soap_plist *pp; - *ppp = NULL; - if (!p || !a->__ptr) - return 0; - for (pp = soap->pht[soap_hash_ptr(a->__ptr)]; pp; pp = pp->next) - if (pp->type == type && pp->array && pp->array->__ptr == a->__ptr && pp->array->__size == n) - { *ppp = pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d id=%d\n", a->__ptr, type, pp->id)); - return pp->id; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d: not found\n", a->__ptr, type)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pointer_enter(struct soap *soap, const void *p, int type, struct soap_plist **ppp) -{ register struct soap_plist *pp; - if (!p) - { *ppp = NULL; - return 0; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enter location=%p type=%d id=%lu\n", p, type, soap->idnum+1)); - *ppp = pp = (struct soap_plist*)SOAP_MALLOC(sizeof(struct soap_plist)); - if (pp) - { register int h = soap_hash_ptr(p); - pp->next = soap->pht[h]; - pp->type = type; - if ((soap->mode & SOAP_XML_TREE) || soap->part == SOAP_IN_HEADER) - { pp->mark1 = 0; - pp->mark2 = 0; - } - else - { pp->mark1 = 1; - pp->mark2 = 1; - } - pp->ptr = p; - pp->array = NULL; - soap->pht[h] = pp; - return pp->id = ++soap->idnum; - } - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_pointer_enter(struct soap *soap, const void *p, const struct soap_array *a, int type, struct soap_plist **ppp) -{ struct soap_plist *pp; - *ppp = NULL; - if (!p || !a->__ptr) - return 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array enter location=%p size=%d type=%d id=%lu\n", a->__ptr, a->__size, type, soap->idnum+1)); - *ppp = pp = (struct soap_plist*)SOAP_MALLOC(sizeof(struct soap_plist)); - if (pp) - { register int h = soap_hash_ptr(a->__ptr); - pp->next = soap->pht[h]; - pp->type = type; - if ((soap->mode & SOAP_XML_TREE) || soap->part == SOAP_IN_HEADER) - { pp->mark1 = 0; - pp->mark2 = 0; - } - else - { pp->mark1 = 1; - pp->mark2 = 1; - } - pp->ptr = p; - pp->array = a; - soap->pht[h] = pp; - return pp->id = ++soap->idnum; - } - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_begin_count(struct soap *soap) -{ soap_clr_attr(soap); - soap_set_local_namespaces(soap); - if (soap->mode & SOAP_ENC_DIME) - soap->mode = soap->omode | SOAP_IO_LENGTH | SOAP_ENC_DIME; - else - { soap->mode = soap->omode; - if (((soap->mode & (SOAP_IO_STORE | SOAP_IO_CHUNK)) || (soap->mode & SOAP_ENC_XML)) && !soap->fprepare) - soap->mode &= ~SOAP_IO_LENGTH; - else - soap->mode |= SOAP_IO_LENGTH; - } - if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH) - { if (!(soap->mode & SOAP_ENC_DIME)) - soap->mode &= ~SOAP_IO_LENGTH; - if (soap->mode & SOAP_ENC_XML) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - soap->count = 0; - soap->ns = 0; - soap->null = 0; - soap->position = 0; - soap->mustUnderstand = 0; - soap->encoding = 0; - soap->part = SOAP_BEGIN; - soap->idnum = 0; - soap->dime_count = 0; /* count # of attachments */ - soap->dime_size = 0; /* accumulate total size of attachments */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin count phase (socket=%d mode=%hd count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count)); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_begin_send(struct soap *soap) -{ soap_clr_attr(soap); - soap_set_local_namespaces(soap); - soap->mode = (soap->omode & ~SOAP_IO_LENGTH) | (soap->mode & SOAP_ENC_DIME); - if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH) - { if (soap->mode & SOAP_ENC_XML) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_FLUSH && soap_valid_socket(soap->socket)) - { if (soap->count || (soap->mode & SOAP_ENC_XML)) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - soap_new_block(soap); - if (!(soap->mode & SOAP_IO_KEEPALIVE)) - soap->keep_alive = 0; -#ifdef WIN32 -#ifndef UNDER_CE -#ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket)) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */ -#ifdef __BORLANDC__ - setmode((SOAP_SOCKET)soap->sendfd, O_BINARY); -#else - _setmode((SOAP_SOCKET)soap->sendfd, _O_BINARY); -#endif -#endif -#endif -#endif - if (soap->mode & SOAP_IO) - { soap->bufidx = 0; - soap->buflen = 0; - } - soap->chunksize = 0; - soap->ns = 0; - soap->null = 0; - soap->position = 0; - soap->mustUnderstand = 0; - soap->encoding = 0; - soap->part = SOAP_BEGIN; - soap->idnum = 0; - soap->level = 0; -#ifdef WITH_ZLIB - soap->z_ratio_out = 1.0; - if ((soap->mode & SOAP_ENC_ZLIB) && soap->zlib_state != SOAP_ZLIB_DEFLATE) - { -#ifdef WITH_GZIP - memcpy(soap->z_buf, "\37\213\10\0\0\0\0\0\0\377", 10); - soap->d_stream.next_out = (Byte*)soap->z_buf + 10; - soap->d_stream.avail_out = SOAP_BUFLEN - 10; - soap->z_crc = crc32(0L, NULL, 0); - if (deflateInit2(&soap->d_stream, soap->z_level, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK) -#else - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - if (deflateInit(&soap->d_stream, soap->z_level) != Z_OK) -#endif - return soap->error = SOAP_ZLIB_ERROR; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflate initialized\n")); - soap->zlib_state = SOAP_ZLIB_DEFLATE; - } -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin send phase (socket=%d mode=%hd count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_embedded(struct soap *soap, const void *p, int t) -{ struct soap_plist *pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded %p type=%d\n", p, t)); - if (soap_pointer_lookup(soap, p, t, &pp)) - { pp->mark1 = 1; - pp->mark2 = 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded %p type=%d set to %d\n", p, t, (int)pp->mark1)); - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_reference(struct soap *soap, const void *p, int t) -{ register int i; - struct soap_plist *pp; - if (!p) - return 1; - i = soap_pointer_lookup(soap, p, t, &pp); - if (i) - { if (pp->mark1 == 0) - { pp->mark1 = 2; - pp->mark2 = 2; - } - } - else - { soap_pointer_enter(soap, p, t, &pp); - pp->mark1 = 0; - pp->mark2 = 0; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reference %p type = %d (%d %d)\n", p, t, (int)pp->mark1, (int)pp->mark2)); - return pp->mark1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_reference(struct soap *soap, const void *p, const struct soap_array *a, int n, int t) -{ register int i; - struct soap_plist *pp; - if (!p) - return 1; - i = soap_array_pointer_lookup(soap, p, a, n, t, &pp); - if (i) - { if (pp->mark1 == 0) - { pp->mark1 = 2; - pp->mark2 = 2; - } - } - else if (!soap_array_pointer_enter(soap, p, a, t, &pp)) - return 1; - pp->mark1 = 0; - pp->mark2 = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array reference %p ptr=%p size=%d type = %d (%d %d)\n", p, a->__ptr, n, t, (int)pp->mark1, (int)pp->mark2)); - return pp->mark1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_embedded_id(struct soap *soap, int id, const void *p, int t) -{ struct soap_plist *pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id %p type=%d id=%d\n", p, t, id)); - if (soap->version == 1 && soap->encodingStyle && !(soap->mode & (SOAP_XML_TREE | SOAP_XML_GRAPH)) && soap->part != SOAP_IN_HEADER) - { if (id < 0) - { id = soap_pointer_lookup(soap, p, t, &pp); - if (id > 0 && pp) - { if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 2; - else - pp->mark2 = 2; - } - return -1; - } - return id; - } - if (id < 0) - id = soap_pointer_lookup(soap, p, t, &pp); - else - soap_pointer_lookup(soap, p, t, &pp); - if (id > 0 && pp) - { if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 1; - else - pp->mark2 = 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id id=%d %p type=%d = (%d %d)\n", id, p, t, (int)pp->mark1, (int)pp->mark2)); - } - return id; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_is_embedded(struct soap *soap, struct soap_plist *pp) -{ if (!pp) - return 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Is embedded? %d %d\n", (int)pp->mark1, (int)pp->mark2)); - if (soap->version == 1 && soap->encodingStyle && !(soap->mode & (SOAP_XML_TREE | SOAP_XML_GRAPH)) && soap->part != SOAP_IN_HEADER) - { if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 != 0; - return pp->mark2 != 0; - } - if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 == 1; - return pp->mark2 == 1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_is_single(struct soap *soap, struct soap_plist *pp) -{ if ((soap->mode & SOAP_XML_TREE) || soap->part == SOAP_IN_HEADER) - return 1; - if (!pp) - return 0; - if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 == 0; - return pp->mark2 == 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_is_multi(struct soap *soap, struct soap_plist *pp) -{ if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 == 2; - return pp->mark2 == 2; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_embedded(struct soap *soap, struct soap_plist *pp) -{ if (!pp) - return; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 1; - else - pp->mark2 = 1; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_attached(struct soap *soap, struct soap_plist *pp, const char *id, const char *type, const char *options, size_t size) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set attached id='%s' type='%s'\n", id?id:"", type?type:"")); - if (soap->mode & SOAP_IO_LENGTH) - { if (pp->mark1 != 3) - { pp->mark1 = 3; - soap->dime_count++; /* one more attachment found */ - soap->dime_size += 12; /* increase total size (DIME fields) */ - if (id) - soap->dime_size += (strlen(id)+3)&(~3); - if (type) - soap->dime_size += (strlen(type)+3)&(~3); - if (options) - soap->dime_size += 4 + (((((unsigned char)options[2] << 8 | (unsigned char)options[3]))+3)&(~3)); - soap->dime_size += (size+3)&(~3); - } - } - else if (pp->mark2 != 3) - pp->mark2 = 3; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_init_iht(struct soap *soap) -{ register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing ID hashtable\n")); - for (i = 0; i < SOAP_IDHASH; i++) - soap->iht[i] = NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static void -soap_free_iht(struct soap *soap) -{ register int i; - register struct soap_ilist *ip, *p; - register struct soap_flist *fp, *q; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free ID hashtable\n")); - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = p) - { for (fp = ip->flist; fp; fp = q) - { q = fp->next; - SOAP_FREE(fp); - } - p = ip->next; - SOAP_FREE(ip); - } - soap->iht[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static struct soap_ilist * -soap_hlookup(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - for (ip = soap->iht[soap_hash(id)]; ip; ip = ip->next) - if (!strcmp(ip->id, id)) - return ip; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_ilist * -SOAP_FMAC2 -soap_lookup(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - ip = soap_hlookup(soap, id); -#ifndef WITH_LEANER - if (!ip && *id != '#' && !strchr(id, ':')) /* try content id "cid:" with DIME attachments */ - { char cid[SOAP_TAGLEN]; - strcpy(cid, "cid:"); - strncat(cid + 4, id, sizeof(cid) - 5); - cid[sizeof(cid) - 1] = '\0'; - ip = soap_hlookup(soap, cid); - } -#endif - return ip; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_ilist * -SOAP_FMAC2 -soap_enter(struct soap *soap, const char *id) -{ register int h; - register struct soap_ilist *ip; - ip = (struct soap_ilist*)SOAP_MALLOC(sizeof(struct soap_ilist) + strlen(id)); - if (ip) - { h = soap_hash(id); - strcpy(ip->id, id); - ip->next = soap->iht[h]; - soap->iht[h] = ip; - return ip; - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_malloc(struct soap *soap, size_t n) -{ register char *p; - if (!n) - return NULL; - if (!soap) - return SOAP_MALLOC(n); - n += (-(long)n) & 7; - if (!(p = (char*)SOAP_MALLOC(n + sizeof(void*) + sizeof(size_t)))) - { soap->error = SOAP_EOM; - return NULL; - } - /* keep chain of alloced cells for later destruction */ - soap->alloced = 1; - *(void**)(p + n) = soap->alist; - *(size_t*)(p + n + sizeof(void*)) = n; - soap->alist = p + n; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Malloc %u bytes at location %p\n", (unsigned int)n, p)); - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_dealloc(struct soap *soap, void *p) -{ if (!soap) - return; - if (p) - { register char **q; - for (q = (char**)&soap->alist; *q; q = *(char***)q) - { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*)))) - { *q = **(char***)q; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Freed data at %p\n", p)); - SOAP_FREE(p); - return; - } - } - soap_delete(soap, p); - } - else - { register char *q; - while (soap->alist) - { q = (char*)soap->alist; - soap->alist = *(void**)q; - q -= *(size_t*)(q + sizeof(void*)); - if (q == (char*)soap->fault) - soap->fault = NULL; /* this was deallocated */ - else if (q == (char*)soap->header) - soap->header = NULL; /* this was deallocated */ - SOAP_FREE(q); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Dealloc all data done\n")); - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_delete(struct soap *soap, void *p) -{ register struct soap_clist **cp = &soap->clist; - if (p) - { while (*cp) - { if (p == (*cp)->ptr) - { register struct soap_clist *q = *cp; - *cp = q->next; - q->fdelete(q); - SOAP_FREE(q); - return; - } - cp = &(*cp)->next; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not dealloc data %p: address not in list\n", p)); - } - else - { while (*cp) - { register struct soap_clist *q = *cp; - *cp = q->next; - if (q->ptr == (void*)soap->fault) - soap->fault = NULL; /* this was deallocated */ - else if (q->ptr == (void*)soap->header) - soap->header = NULL; /* this was deallocated */ - q->fdelete(q); - SOAP_FREE(q); - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_clist * -SOAP_FMAC2 -soap_link(struct soap *soap, void *p, int t, int n, void (*fdelete)(struct soap_clist*)) -{ register struct soap_clist *cp; - if ((cp = (struct soap_clist*)SOAP_MALLOC(sizeof(struct soap_clist)))) - { cp->next = soap->clist; - cp->type = t; - cp->size = n; - cp->ptr = p; - cp->fdelete = fdelete; - soap->clist = cp; - } - return cp; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_unlink(struct soap *soap, const void *p) -{ register char **q; - register struct soap_clist **cp; - if (!soap || !p) - return; - for (q = (char**)&soap->alist; *q; q = *(char***)q) - { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*)))) - { *q = **(char***)q; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked data %p\n", p)); - return; - } - } - for (cp = &soap->clist; *cp; cp = &(*cp)->next) - { if (p == (*cp)->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked class instance %p\n", p)); - q = (char**)*cp; - *cp = (*cp)->next; - SOAP_FREE(q); - return; - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_lookup_type(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - if (*id) - { ip = soap_lookup(soap, id); - if (ip) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup id='%s' type=%d\n", id, ip->type)); - return ip->type; - } - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "lookup type id='%s' NOT FOUND! Need to get it from xsi:type\n", id)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_lookup(struct soap *soap, const char *id, void **p, int t, size_t n, unsigned int k) -{ struct soap_ilist *ip; - void **q; - if (*id == '\0') - return p; - soap->alloced = 0; - if (!p) - p = (void**)soap_malloc(soap, sizeof(void*)); - ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */ - if (!ip) - { ip = soap_enter(soap, id); /* new hash table entry for string id */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding first href='%s' %p (%u bytes)\n", id, p, (unsigned int)n)); - ip->type = t; - ip->size = n; - ip->link = p; - ip->copy = NULL; - ip->flist = NULL; - ip->ptr = NULL; - ip->level = k; - *p = NULL; - } - else if (!soap->blist && ip->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolved href='%s' type='%d' (%u bytes)\n", id, t, (unsigned int)n)); - if (ip->type != t) - { soap->error = SOAP_HREF; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Object mismatch: id's type='%d' href's type='%d'\n", ip->type, t)); - return NULL; - } - while (ip->level < k) - { q = (void**)soap_malloc(soap, sizeof(void*)); - if (!q) - return NULL; - *p = (void*)q; - p = q; - k--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - *p = ip->ptr; - } - else if (ip->level > k) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving level %u pointers to href='%s'\n", ip->level, id)); - while (ip->level > k) - { void *s, **r = &ip->link; - q = (void**)ip->link; - while (q) - { *r = (void*)soap_malloc(soap, sizeof(void*)); - s = *q; - *q = *r; - r = *(void***)q; - q = (void**)s; - } - *r = NULL; - ip->size = n; - ip->copy = NULL; - ip->level = ip->level - 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - q = (void**)ip->link; - ip->link = p; - *p = (void*)q; - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarded href='%s' (%u bytes)\n", id, (unsigned int)n)); - while (ip->level < k) - { q = (void**)soap_malloc(soap, sizeof(void*)); - *p = q; - p = q; - k--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - q = (void**)ip->link; - ip->link = p; - *p = (void*)q; - } - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_forward(struct soap *soap, const char *href, void *p, int t, size_t n) -{ struct soap_ilist *ip; - if (!p || !*href) - return p; - ip = soap_lookup(soap, soap->href); /* lookup pointer to hash table entry for string id */ - if (!ip) - { if (n >= sizeof(void*)) - { ip = soap_enter(soap, href); /* new hash table entry for string id */ - ip->type = t; - ip->size = n; - ip->link = NULL; - ip->copy = p; - ip->flist = NULL; - *(void**)p = NULL; - ip->ptr = NULL; - ip->level = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding first copying address %p for type %d href='%s'\n", p, t, href)); - return p; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding problem: copying location %p too small (%u) for href='%s'\n", p, (unsigned int)n, href)); - soap->error = SOAP_HREF; - return NULL; - } - else if (ip->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying value from location %p to location %p to resolve href='%s'\n", ip->ptr, p, href)); - memcpy(p, ip->ptr, n); - } - else if (n >= sizeof(void*)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding copying address %p for type %d href='%s' (prev in chain = %p)\n", p, t, href, ip->copy)); - *(void**)p = ip->copy; - ip->copy = p; - return p; - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding problem: copying location %p too small (%u) for href='%s'\n", p, (unsigned int)n, href)); - soap->error = SOAP_HREF; /* href to object too small to hold pointer */ - return NULL; - } - return ip->ptr; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, int k) -{ struct soap_ilist *ip; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Enter id='%s' type=%d loc=%p size=%d level=%d\n", id, t, p, (int)n, k)); - soap->alloced = 0; - if (*id == '\0') - { if (!p) - return soap_malloc(soap, n); - else - return p; - } - ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */ - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Lookup entry id='%s'\n", id)); - if (!ip) - { ip = soap_enter(soap, id); /* new hash table entry for string id */ - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "New entry id='%s' type=%d size=%u\n", id, t, (unsigned int)n)); - ip->type = t; - ip->size = n; - ip->link = NULL; - ip->copy = NULL; - ip->flist = NULL; - if (!p) - p = soap_malloc(soap, n); - ip->ptr = p; - ip->level = k; - } - else if (ip->ptr) /* storage address was forwarded */ - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Multiply defined id='%s'\n", id)); - if (p) - { soap->error = SOAP_MULTI_ID; - return NULL; - } - } - else - { if (!p) - p = soap_malloc(soap, n); - ip->ptr = p; - if (!soap->blist) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolve link chain to point to %p\n", ip->ptr)); - soap_resolve_ptr(ip); - } - } - return ip->ptr; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_end_send(struct soap *soap) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End send\n")); - if (soap->mode & SOAP_IO) /* need to flush the remaining data in buffer */ - { if (soap_flush(soap)) -#ifdef WITH_ZLIB - { if (soap->mode & SOAP_ENC_ZLIB && soap->zlib_state == SOAP_ZLIB_DEFLATE) - { soap->zlib_state = SOAP_ZLIB_NONE; - deflateEnd(&soap->d_stream); - } - return soap->error; - } -#else - return soap->error; -#endif -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { int r; - soap->d_stream.avail_in = 0; - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating remainder\n")); - r = deflate(&soap->d_stream, Z_FINISH); - if (soap->d_stream.avail_out != SOAP_BUFLEN) - { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN - soap->d_stream.avail_out)) - { soap->zlib_state = SOAP_ZLIB_NONE; - deflateEnd(&soap->d_stream); - return soap->error; - } - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - } - } while (r == Z_OK); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_out = (float)soap->d_stream.total_out / (float)soap->d_stream.total_in; - soap->mode &= ~SOAP_ENC_ZLIB; - soap->zlib_state = SOAP_ZLIB_NONE; - if (deflateEnd(&soap->d_stream) != Z_OK || r != Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to end deflate: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - return soap->error = SOAP_ZLIB_ERROR; - } -#ifdef WITH_GZIP - soap->z_buf[0] = soap->z_crc & 0xFF; - soap->z_buf[1] = (soap->z_crc >> 8) & 0xFF; - soap->z_buf[2] = (soap->z_crc >> 16) & 0xFF; - soap->z_buf[3] = (soap->z_crc >> 24) & 0xFF; - soap->z_buf[4] = soap->d_stream.total_in & 0xFF; - soap->z_buf[5] = (soap->d_stream.total_in >> 8) & 0xFF; - soap->z_buf[6] = (soap->d_stream.total_in >> 16) & 0xFF; - soap->z_buf[7] = (soap->d_stream.total_in >> 24) & 0xFF; - if (soap_flush_raw(soap, soap->z_buf, 8)) - return soap->error; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip crc32=%lu\n", soap->z_crc)); -#endif - } -#endif -#ifndef WITH_LEAN - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - { char *p; - if (!(soap->mode & SOAP_ENC_XML)) - { soap->mode--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending buffered message of length %u\n", (unsigned int)soap->blist->size)); - if (soap->status >= SOAP_POST) - soap->error = soap->fpost(soap, soap->endpoint, soap->host, soap->port, soap->path, soap->action, soap->blist->size); - else if (soap->status != SOAP_STOP) - soap->error = soap->fresponse(soap, soap->status, soap->blist->size); - if (soap->error || soap_flush(soap)) - return soap->error; - soap->mode++; - } - for (p = soap_first_block(soap); p; p = soap_next_block(soap)) - { DBGMSG(SENT, p, soap_block_size(soap)); - if ((soap->error = soap->fsend(soap, p, soap_block_size(soap)))) - { soap_end_block(soap); - return soap->error; - } - } - soap_end_block(soap); - } - else if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { DBGMSG(SENT, "\r\n0\r\n\r\n", 7); - if ((soap->error = soap->fsend(soap, "\r\n0\r\n\r\n", 7))) - return soap->error; - } -#endif - } -#ifdef WITH_OPENSSL - if (!soap->ssl && soap_valid_socket(soap->socket) && !soap->keep_alive) - shutdown((SOAP_SOCKET)soap->socket, 1); /* Send TCP FIN */ -#else - if (soap_valid_socket(soap->socket) && !soap->keep_alive) - shutdown((SOAP_SOCKET)soap->socket, 1); /* Send TCP FIN */ -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of send message ok\n")); - soap->part = SOAP_END; - soap->count = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_end_recv(struct soap *soap) -{ soap->part = SOAP_END; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "End of receive message ok\n")); -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { soap->mode &= ~SOAP_ENC_ZLIB; - memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN); - soap->bufidx = (char*)soap->d_stream.next_in - soap->z_buf; - soap->buflen = soap->z_buflen; - soap->zlib_state = SOAP_ZLIB_NONE; - if (inflateEnd(&soap->d_stream) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; -#ifdef WITH_GZIP - if (soap->zlib_in == SOAP_ZLIB_GZIP) - { wchar c; - short i; - for (i = 0; i < 8; i++) - { if ((int)(c = soap_getchar(soap)) == EOF) - return soap->error = SOAP_EOF; - soap->z_buf[i] = (char)c; - } - if (soap->z_crc != ((unsigned char)soap->z_buf[0] | (unsigned long)((unsigned char)soap->z_buf[1] << 8) | (unsigned long)((unsigned char)soap->z_buf[2] << 16) | (unsigned long)((unsigned char)soap->z_buf[3] << 24))) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: crc check failed, message corrupted? (crc32=%lu)\n", soap->z_crc)); - return soap->error = SOAP_ZLIB_ERROR; - } - if (soap->d_stream.total_out != ((unsigned char)soap->z_buf[4] | (unsigned long)((unsigned char)soap->z_buf[5] << 8) | (unsigned long)((unsigned char)soap->z_buf[6] << 16) | (unsigned long)((unsigned char)soap->z_buf[7] << 24))) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: incorrect message length\n")); - return soap->error = SOAP_ZLIB_ERROR; - } - } -#endif - } -#endif - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - while ((int)soap_getchar(soap) != EOF) /* advance to last chunk */ - ; - if (soap->fdisconnect) - if ((soap->error = soap->fdisconnect(soap))) - return soap->error; - return soap_resolve(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_free(struct soap *soap) -{ register struct soap_nlist *np; - register struct soap_attribute *tp; - register struct Namespace *ns; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free namespace stack\n")); - while (soap->nlist) - { np = soap->nlist->next; - if (soap->nlist->ns) - SOAP_FREE(soap->nlist->ns); - SOAP_FREE(soap->nlist); - soap->nlist = np; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free any remaining temp blocks\n")); - while (soap->blist) - soap_end_block(soap); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free attributes\n")); - while (soap->attributes) - { tp = soap->attributes->next; - if (soap->attributes->value) - SOAP_FREE(soap->attributes->value); - SOAP_FREE(soap->attributes); - soap->attributes = tp; - } - if (soap->labbuf) - SOAP_FREE(soap->labbuf); - soap->labbuf = NULL; - soap->lablen = 0; - soap->labidx = 0; - soap_free_pht(soap); - soap_free_iht(soap); - ns = soap->local_namespaces; - if (ns) - { for (; ns->id; ns++) - { if (ns->out) - { SOAP_FREE(ns->out); - if (soap->encodingStyle == ns->out) - soap->encodingStyle = SOAP_STR_EOS; - ns->out = NULL; - } - if (soap->encodingStyle == ns->ns) - soap->encodingStyle = SOAP_STR_EOS; - } - SOAP_FREE(soap->local_namespaces); - soap->local_namespaces = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static void -soap_init_logs(struct soap *soap) -{ int i; - for (i = 0; i < SOAP_MAXLOGS; i++) - { soap->logfile[i] = NULL; - soap->fdebug[i] = NULL; - } -#ifdef SOAP_DEBUG - soap_set_recv_logfile(soap, "RECV.log"); - soap_set_sent_logfile(soap, "SENT.log"); - soap_set_test_logfile(soap, "TEST.log"); -#endif -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_open_logfile(struct soap *soap, int i) -{ if (soap->logfile[i]) - soap->fdebug[i] = fopen(soap->logfile[i], i < 2 ? "ab" : "a"); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static void -soap_close_logfile(struct soap *soap, int i) -{ if (soap->fdebug[i]) - { fclose(soap->fdebug[i]); - soap->fdebug[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_close_logfiles(struct soap *soap) -{ int i; - for (i = 0; i < SOAP_MAXLOGS; i++) - soap_close_logfile(soap, i); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static void -soap_set_logfile(struct soap *soap, int i, const char *logfile) -{ char *s = NULL; - soap_close_logfile(soap, i); - if (soap->logfile[i]) - SOAP_FREE((void*)soap->logfile[i]); - if (logfile) - if ((s = (char*)SOAP_MALLOC(strlen(logfile) + 1))) - strcpy(s, logfile); - soap->logfile[i] = s; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_recv_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_RECV, logfile); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_sent_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_SENT, logfile); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_test_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_TEST, logfile); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_copy(struct soap *soap) -{ return soap_copy_context((struct soap*)SOAP_MALLOC(sizeof(struct soap)), soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_copy_context(struct soap *copy, struct soap *soap) -{ if (copy) - { register struct soap_plugin *p; - memcpy(copy, soap, sizeof(struct soap)); - copy->copy = 1; - copy->user = NULL; - copy->userid = NULL; - copy->passwd = NULL; - copy->nlist = NULL; - copy->blist = NULL; - copy->clist = NULL; - copy->alist = NULL; - copy->attributes = NULL; - copy->local_namespaces = NULL; - soap_set_local_namespaces(copy); - soap_init_iht(copy); - soap_init_pht(copy); - copy->header = NULL; - copy->fault = NULL; - copy->action = NULL; - *copy->host = '\0'; -#ifndef WITH_LEAN -#ifdef WITH_COOKIES - copy->cookies = soap_copy_cookies(soap); -#else - copy->cookies = NULL; -#endif - soap_init_logs(copy); -#endif - copy->plugins = NULL; - for (p = soap->plugins; p; p = p->next) - { register struct soap_plugin *q = (struct soap_plugin*)SOAP_MALLOC(sizeof(struct soap_plugin)); - if (!q) - return NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying plugin '%s'\n", p->id)); - *q = *p; - if (p->fcopy && (soap->error = p->fcopy(soap, q, p))) - { SOAP_FREE(q); - return NULL; - } - q->next = copy->plugins; - copy->plugins = q; - } - } - else - soap->error = SOAP_EOM; - return copy; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init(struct soap *soap) -{ soap->version = 1; /* default SOAP 1.1 */ - soap_imode(soap, SOAP_IO_DEFAULT); - soap_omode(soap, SOAP_IO_DEFAULT); - soap->copy = 0; - soap->plugins = NULL; - soap->user = NULL; - soap->userid = NULL; - soap->passwd = NULL; - soap->fpost = http_post; - soap->fget = http_get; - soap->fposthdr = http_post_header; - soap->fresponse = http_response; - soap->fparse = http_parse; - soap->fparsehdr = http_parse_header; - soap->fconnect = NULL; - soap->fdisconnect = NULL; -#ifndef MAC_CARBON - soap->faccept = tcp_accept; - soap->fopen = tcp_connect; - soap->fclose = tcp_disconnect; - soap->fsend = fsend; - soap->frecv = frecv; -#endif - soap->fprepare = NULL; - soap->fignore = NULL; - soap->fplugin = fplugin; - soap->fdimereadopen = NULL; - soap->fdimewriteopen = NULL; - soap->fdimereadclose = NULL; - soap->fdimewriteclose = NULL; - soap->fdimeread = NULL; - soap->fdimewrite = NULL; - soap->float_format = "%.8g"; /* .8 preserves single FP precision as much as possible, but might not be very efficient */ - soap->double_format = "%.17lg"; /* .17 preserves double FP precision as much as possible, but might not be very efficient */ - soap->dime_id_format = "cid:id%d"; /* default DIME id format */ - soap->http_version = "1.1"; - soap->encodingStyle = SOAP_STR_EOS; - soap->actor = NULL; - soap->max_keep_alive = SOAP_MAXKEEPALIVE; - soap->keep_alive = 0; - soap->recv_timeout = 0; - soap->send_timeout = 0; - soap->connect_timeout = 0; - soap->accept_timeout = 0; - soap->socket_flags = 0; - soap->connect_flags = 0; - soap->bind_flags = 0; - soap->accept_flags = 0; - soap->ip = 0; - soap->labbuf = NULL; - soap->lablen = 0; - soap->labidx = 0; -#ifndef WITH_NONAMESPACES - soap->namespaces = namespaces; -#else - soap->namespaces = NULL; -#endif - soap->local_namespaces = NULL; - soap->nlist = NULL; - soap->blist = NULL; - soap->clist = NULL; - soap->alist = NULL; - soap->attributes = NULL; - soap->header = NULL; - soap->fault = NULL; - soap->master = SOAP_INVALID_SOCKET; - soap->socket = SOAP_INVALID_SOCKET; - soap->os = NULL; - soap->is = NULL; - soap->dom = NULL; -#ifndef UNDER_CE - soap->recvfd = 0; - soap->sendfd = 1; -#else - soap->recvfd = stdin; - soap->sendfd = stdout; -#endif - soap->host[0] = '\0'; - soap->port = 0; - soap->action = NULL; - soap->proxy_host = NULL; - soap->proxy_port = 8080; - soap->proxy_userid = NULL; - soap->proxy_passwd = NULL; -#ifdef WITH_OPENSSL - soap->fsslauth = ssl_auth_init; - soap->fsslverify = ssl_verify_callback; - soap->bio = NULL; - soap->ssl = NULL; - soap->ctx = NULL; - soap->require_server_auth = 0; - soap->require_client_auth = 0; - soap->rsa = 0; - soap->keyfile = NULL; - soap->password = NULL; - soap->dhfile = NULL; - soap->cafile = NULL; - soap->capath = NULL; - soap->randfile = NULL; - soap->session = NULL; -#endif -#ifdef WITH_ZLIB - soap->zlib_state = SOAP_ZLIB_NONE; - soap->zlib_in = SOAP_ZLIB_NONE; - soap->zlib_out = SOAP_ZLIB_NONE; - soap->d_stream.zalloc = NULL; - soap->d_stream.zfree = NULL; - soap->d_stream.opaque = NULL; - soap->z_level = 6; -#endif -#ifndef WITH_LEAN - soap->cookies = NULL; - soap->cookie_domain = NULL; - soap->cookie_path = NULL; - soap->cookie_max = 32; - soap_init_logs(soap); -#endif -/* WR[ */ -#ifdef WMW_RPM_IO - soap->rpmreqid = NULL; -#endif /* WMW_RPM_IO */ -/* ]WR */ - soap_init_iht(soap); - soap_init_pht(soap); - soap_begin(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init1(struct soap *soap, int mode) -{ soap_init2(soap, mode, mode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init2(struct soap *soap, int imode, int omode) -{ soap_init(soap); - soap_imode(soap, imode); - soap_omode(soap, omode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_begin(struct soap *soap) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing\n")); - if (!soap->keep_alive) - { soap->buflen = 0; - soap->bufidx = 0; - } - soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0); - soap->null = 0; - soap->position = 0; - soap->encoding = 0; - soap->mustUnderstand = 0; - soap->mode = 0; - soap->ns = 0; - soap->part = SOAP_BEGIN; - soap->alloced = 0; - soap->count = 0; - soap->length = 0; - soap->cdata = 0; - soap->error = SOAP_OK; - soap->peeked = 0; - soap->ahead = 0; - soap->idnum = 0; - soap->level = 0; - soap->endpoint[0] = '\0'; - soap->dime_chunksize = 0; - soap->dime_buflen = 0; - soap->dot_net_bug = 0; - soap_free(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_end(struct soap *soap) -{ register struct soap_clist *cp; - soap_free(soap); - soap_dealloc(soap, NULL); - while (soap->clist) - { cp = soap->clist->next; - SOAP_FREE(soap->clist); - soap->clist = cp; - } - soap_closesock(soap); -#ifndef WITH_LEAN - soap_close_logfiles(soap); -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_namespaces(struct soap *soap, struct Namespace *p) -{ struct Namespace *ns = soap->local_namespaces; - struct soap_nlist *np, *nq, *nr; - unsigned int level = soap->level; - soap->namespaces = p; - soap->local_namespaces = NULL; - soap_set_local_namespaces(soap); - /* reverse the list */ - np = soap->nlist; - soap->nlist = NULL; - if (np) - { nq = np->next; - np->next = NULL; - while (nq) - { nr = nq->next; - nq->next = np; - np = nq; - nq = nr; - } - } - while (np) - { soap->level = np->level; /* preserve element nesting level */ - if (np->ns) - { if (soap_push_namespace(soap, np->id, np->ns)) - return soap->error; - } - else if (np->index >= 0 && ns) - { if (ns[np->index].out) - { if (soap_push_namespace(soap, np->id, ns[np->index].out)) - return soap->error; - } - else if (soap_push_namespace(soap, np->id, ns[np->index].ns)) - return soap->error; - } - if (np->ns) - SOAP_FREE(np->ns); - nq = np; - np = np->next; - SOAP_FREE(nq); - } - if (ns) - { int i; - for (i = 0; ns[i].id; i++) - { if (ns[i].out) - { SOAP_FREE(ns[i].out); - ns[i].out = NULL; - } - } - SOAP_FREE(ns); - } - soap->level = level; /* restore level */ - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static void -soap_set_local_namespaces(struct soap *soap) -{ if (soap->namespaces && !soap->local_namespaces) - { register struct Namespace *ns; - register size_t n = 1; - for (ns = soap->namespaces; ns->id; ns++) - n++; - if (n > 3) - { n *= sizeof(struct Namespace); - ns = (struct Namespace*)SOAP_MALLOC(n); - if (ns) - { memcpy(ns, soap->namespaces, n); - ns[0].id = "SOAP-ENV"; - ns[1].id = "SOAP-ENC"; - ns[2].id = "xsi"; - if (ns[0].ns) - { if (!strcmp(ns[0].ns, soap_env1)) - soap->version = 1; - else - soap->version = 2; - } - soap->local_namespaces = ns; - } - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element(struct soap *soap, const char *tag, int id, const char *type) -{ struct Namespace *ns = soap->local_namespaces; - register const char *s; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element begin tag='%s' id='%d' type='%s'\n", tag, id, type?type:"")); -/**/ -#ifdef WITH_DOM - if (soap->mode & SOAP_XML_DOM) - { register struct soap_dom_element *p, *e = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element)); - e->next = NULL; - e->prnt = soap->dom; - e->nstr = NULL; - e->name = soap_strdup(soap, tag); /* check EOM? */ - e->data = NULL; - e->type = 0; - e->node = NULL; - e->elts = NULL; - e->atts = NULL; - if (soap->dom) - { p = soap->dom->elts; - if (p) - { while (p->next) - p = p->next; - p->next = e; - } - else - soap->dom->elts = e; - } - soap->dom = e; - } - else -#endif -{ - soap->level++; - if (!soap->ns && !(soap->mode & SOAP_XML_CANONICAL)) - if (soap_send(soap, "")) - return soap->error; - if (soap_send_raw(soap, "<", 1)) - return soap->error; - s = tag; - if (ns && soap->part != SOAP_IN_ENVELOPE && (soap->part == SOAP_IN_HEADER || !soap->encodingStyle)) - { register const char *t = strchr(s, ':'); - if (t) - { s = t + 1; - for (ns++; ns->id; ns++) - { if ((ns->out || ns->ns) && !strncmp(ns->id, tag, t - tag) && !ns->id[t - tag]) - { if (soap_send(soap, s) || soap_attribute(soap, "xmlns", ns->out ? ns->out : ns->ns)) - return soap->error; - s = NULL; - break; - } - } - } - } - if (s) - if (soap_send(soap, tag)) - return soap->error; -} -/**/ - if (!soap->ns) - { for (ns = soap->local_namespaces; ns && ns->id; ns++) - { if (*ns->id && (ns->out || ns->ns)) - { sprintf(soap->tmpbuf, "xmlns:%s", ns->id); - if (soap_attribute(soap, soap->tmpbuf, ns->out ? ns->out : ns->ns)) - return soap->error; - } - } - soap->ns = 1; - } - if (id > 0) - { sprintf(soap->tmpbuf, "_%d", id); - if (soap_attribute(soap, "id", soap->tmpbuf)) - return soap->error; - } - if (type && *type) - { if (soap_attribute(soap, "xsi:type", type)) - return soap->error; - } - if (soap->null && soap->position > 0) - { int i; - sprintf(soap->tmpbuf, "[%d", soap->positions[0]); - for (i = 1; i < soap->position; i++) - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), ",%d", soap->positions[i]); - strcat(soap->tmpbuf, "]"); - if (soap_attribute(soap, "SOAP-ENC:position", soap->tmpbuf)) - return soap->error; - } - if (soap->mustUnderstand) - { if (soap->actor && *soap->actor) - { if (soap_attribute(soap, soap->version == 2 ? "SOAP-ENV:role" : "SOAP-ENV:actor", soap->actor)) - return soap->error; - } - if (soap_attribute(soap, "SOAP-ENV:mustUnderstand", soap->version == 2 ? "true" : "1")) - return soap->error; - soap->mustUnderstand = 0; - } - if (soap->encoding) - { if (soap->encodingStyle) - { if (!*soap->encodingStyle && soap->local_namespaces) - { if (soap->local_namespaces[1].out) - soap->encodingStyle = soap->local_namespaces[1].out; - else - soap->encodingStyle = soap->local_namespaces[1].ns; - } - if (soap_attribute(soap, "SOAP-ENV:encodingStyle", soap->encodingStyle)) - return soap->error; - } - soap->encoding = 0; - } - soap->null = 0; - soap->position = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_begin_out(struct soap *soap, const char *tag, int id, const char *type) -{ if (*tag == '-') - return SOAP_OK; - if (soap_element(soap, tag, id, type)) - return soap->error; - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRRCHR -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_strrchr(const char *s, int t) -{ register char *r = NULL; - while (*s) - if (*s++ == t) - r = (char*)s - 1; - return r; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRTOL -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_strtol(const char *s, char **t, int b) -{ register long n = 0; - register int c; - while (*s > 0 && *s <= 32) - s++; - if (b == 10) - { short neg = 0; - if (*s == '-') - { s++; - neg = 1; - } - else if (*s == '+') - s++; - while ((c = *s) && c >= '0' && c <= '9') - { if (n > 214748364) - break; - n *= 10; - n += c - '0'; - s++; - } - if (neg) - n = -n; - } - else /* b == 16 and value is always positive */ - { while ((c = *s)) - { if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'F') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'f') - c -= 'a' - 10; - if (n > 0x07FFFFFF) - break; - n <<= 4; - n += c; - s++; - } - } - if (t) - *t = (char*)s; - return n; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRTOUL -SOAP_FMAC1 -unsigned long -SOAP_FMAC2 -soap_strtoul(const char *s, char **t, int b) -{ unsigned long n = 0; - register int c; - while (*s > 0 && *s <= 32) - s++; - if (b == 10) - { if (*s == '+') - s++; - while ((c = *s) && c >= '0' && c <= '9') - { if (n > 429496729) - break; - n *= 10; - n += c - '0'; - s++; - } - } - else /* b == 16 */ - { while ((c = *s)) - { if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'F') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'f') - c -= 'a' - 10; - if (n > 0x0FFFFFFF) - break; - n <<= 4; - n += c; - s++; - } - } - if (t) - *t = (char*)s; - return n; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_begin_out(struct soap *soap, const char *tag, int id, const char *type, const char *offset) -{ if (soap_element(soap, tag, id, "SOAP-ENC:Array")) - return soap->error; - if (soap->version == 2) - { const char *s; - s = soap_strrchr(type, '['); - if ((size_t)(s - type) < sizeof(soap->tmpbuf)) - { strncpy(soap->tmpbuf, type, s - type); - soap->tmpbuf[s - type] = '\0'; - if (type && *type && (soap_attribute(soap, "SOAP-ENC:itemType", soap->tmpbuf))) - return soap->error; - if (s && (soap_attribute(soap, "SOAP-ENC:arraySize", s + 1))) - return soap->error; - } - } - else - { if (offset && (soap_attribute(soap, "SOAP-ENC:offset", offset))) - return soap->error; - if (type && *type && (soap_attribute(soap, "SOAP-ENC:arrayType", type))) - return soap->error; - } - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_start_end_out(struct soap *soap, const char *tag) -{ register struct soap_attribute *tp; -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible) - { register struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); - a->next = soap->dom->atts; - a->nstr = NULL; - a->name = soap_strdup(soap, tp->name); /* check EOM */ - a->data = soap_strdup(soap, tp->value); /* check EOM */ - a->wide = NULL; - soap->dom->atts = a; - tp->visible = 0; - } - } - return SOAP_OK; - } -#endif -/**/ - for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible) - { if (soap_send_raw(soap, " ", 1) - || soap_send(soap, tp->name)) - return soap->error; - if (tp->visible == 2 && tp->value) - if (soap_send_raw(soap, "=\"", 2) - || soap_string_out(soap, tp->value, 1) - || soap_send_raw(soap, "\"", 1)) - return soap->error; - tp->visible = 0; - } - } - if (tag) - { soap->level--; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { if (soap_send_raw(soap, ">", 1) - || soap_element_end_out(soap, tag)) - return soap->error; - return SOAP_OK; - } -#endif - return soap_send_raw(soap, "/>", 2); - } - return soap_send_raw(soap, ">", 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_end_out(struct soap *soap, const char *tag) -{ if (*tag == '-') - return SOAP_OK; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element ending tag='%s'\n", tag)); -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { if (soap->dom->prnt) - soap->dom = soap->dom->prnt; - return SOAP_OK; - } -#endif -/**/ - if (soap->part != SOAP_IN_ENVELOPE && (soap->part == SOAP_IN_HEADER || !soap->encodingStyle) && soap->local_namespaces) - { const char *s = strchr(tag, ':'); - if (s && strncmp(tag, "SOAP-ENV", s - tag)) - tag = s + 1; - } - soap->level--; - if (soap_send_raw(soap, "", 1)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_ref(struct soap *soap, const char *tag, int id, int href) -{ int n = 0; - if (soap_element(soap, tag, id, NULL)) - return soap->error; - if (soap->version == 2) - n = 1; - sprintf(soap->tmpbuf, "#_%d", href); - if (soap_attribute(soap, "href" + n, soap->tmpbuf + n) - || soap_element_start_end_out(soap, tag)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_href(struct soap *soap, const char *tag, int id, const char *href) -{ if (soap_element(soap, tag, id, NULL) - || soap_attribute(soap, "href", href) - || soap_element_start_end_out(soap, tag)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_null(struct soap *soap, const char *tag, int id, const char *type) -{ struct soap_attribute *tp; - for (tp = soap->attributes; tp; tp = tp->next) - if (tp->visible) - break; - if (tp || (soap->version == 2 && soap->position > 0) || id > 0 || (soap->mode & SOAP_XML_NIL)) - { if (soap_element(soap, tag, id, type)) - return soap->error; - if (soap->part != SOAP_IN_HEADER && soap->encodingStyle) - if (soap_attribute(soap, "xsi:nil", "true")) - return soap->error; - return soap_element_start_end_out(soap, tag); - } - soap->null = 1; - soap->position = 0; - soap->mustUnderstand = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_result(struct soap *soap, const char *tag) -{ if (soap->version == 2 && soap->encodingStyle) - if (soap_element(soap, "SOAP-RPC:result", 0, NULL) - || soap_attribute(soap, "xmlns:SOAP-RPC", soap_rpc) - || soap_element_start_end_out(soap, NULL) - || soap_string_out(soap, tag, 0) - || soap_element_end_out(soap, "SOAP-RPC:result")) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_attribute(struct soap *soap, const char *name, const char *value) -{ -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { register struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); - a->next = soap->dom->atts; - a->nstr = NULL; - a->name = soap_strdup(soap, name); /* check EOM */ - a->data = soap_strdup(soap, value); /* check EOM */ - a->wide = NULL; - soap->dom->atts = a; - return SOAP_OK; - } -#endif -/**/ -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { if (soap_set_attr(soap, name, value)) - return soap->error; - } - else -#endif - { if (soap_send_raw(soap, " ", 1) - || soap_send(soap, name)) - return soap->error; - if (value) - if (soap_send_raw(soap, "=\"", 2) - || soap_string_out(soap, value, 1) - || soap_send_raw(soap, "\"", 1)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_begin_in(struct soap *soap, const char *tag) -{ if (tag && *tag == '-') - return SOAP_OK; - if (!soap_peek_element(soap)) - { if (soap->other) - return soap->error = SOAP_TAG_MISMATCH; - if (!(soap->error = soap_match_tag(soap, soap->tag, tag))) - { if (tag && !soap->encodingStyle) - { const char *s = strchr(tag, ':'); - if (s) - soap_push_default_namespace(soap, tag, s - tag); - } - soap->peeked = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:"" )); - if (soap->body) - soap->level++; - } - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_end_in(struct soap *soap, const char *tag) -{ register wchar c; - register char *s; - register const char *t; - if (tag && *tag == '-') - return SOAP_OK; - soap->level--; - soap_pop_namespace(soap); - if (soap->peeked) - { if (*soap->tag == '\0') - { soap->peeked = 0; - soap->error = SOAP_OK; - } - else - return soap->error = SOAP_SYNTAX_ERROR; - } - else - { while (((c = soap_get(soap)) != TT)) - { if ((int)c == EOF) - return soap->error = SOAP_EOF; - if (c == LT) - return soap->error = SOAP_SYNTAX_ERROR; - } - } - s = soap->tag; - do c = soap_get(soap); - while (soap_blank(c)); - do - { *s++ = (char)c; - c = soap_get(soap); - } while (soap_notblank(c)); - *s = '\0'; - if ((int)c == EOF) - return soap->error = SOAP_EOF; - while (soap_blank(c)) - c = soap_get(soap); - if (c != GT) - return soap->error = SOAP_SYNTAX_ERROR; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:"")); - if (!tag) - return SOAP_OK; - if ((s = strchr(soap->tag, ':'))) - s++; - else - s = soap->tag; - if ((t = strchr(tag, ':'))) - t++; - else - t = tag; - if (!SOAP_STRCMP(s, t)) - return SOAP_OK; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element does not match\n")); - return soap->error = SOAP_SYNTAX_ERROR; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_attribute * -SOAP_FMAC2 -soap_attr(struct soap *soap, const char *name) -{ register struct soap_attribute *tp; - for (tp = soap->attributes; tp; tp = tp->next) - if (!soap_match_tag(soap, tp->name, name)) - return tp; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char * -SOAP_FMAC2 -soap_attr_value(struct soap *soap, const char *name) -{ register struct soap_attribute *tp = soap_attr(soap, name); - if (tp && tp->visible == 2) - return tp->value; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_attr(struct soap *soap, const char *name, const char *value) -{ register struct soap_attribute *tp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set attribute %s='%s'\n", name, value?value:"")); - for (tp = soap->attributes; tp; tp = tp->next) - if (!strcmp(tp->name, name)) - break; - if (!tp) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute %s\n", name)); - if (!(tp = (struct soap_attribute*)SOAP_MALLOC(sizeof(struct soap_attribute) + strlen(name)))) - return soap->error = SOAP_EOM; - tp->ns = NULL; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { struct soap_attribute **tpp = &soap->attributes; - const char *s = strchr(name, ':'); - if (!strncmp(name, "xmlns", 5)) - { for (; *tpp; tpp = &(*tpp)->next) - if (strncmp((*tpp)->name, "xmlns", 5) || strcmp((*tpp)->name + 5, name + 5) > 0) - break; - } - else if (!s) - { for (; *tpp; tpp = &(*tpp)->next) - if (strncmp((*tpp)->name, "xmlns", 5) && ((*tpp)->ns || strcmp((*tpp)->name, name) > 0)) - break; - } - else - { int k; - for (; *tpp; tpp = &(*tpp)->next) - { if (!strncmp((*tpp)->name, "xmlns:", 6) && !strncmp((*tpp)->name + 6, name, s - name) && !(*tpp)->name[6 + s - name]) - { if (!tp->ns) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Canonicalization: prefix %s=%p(%s)\n", name, (*tpp)->ns, (*tpp)->ns)); - tp->ns = (*tpp)->ns; - } - } - else if (strncmp((*tpp)->name, "xmlns", 5) && (*tpp)->ns && tp->ns && ((k = strcmp((*tpp)->ns, tp->ns)) > 0 || (!k && strcmp((*tpp)->name, name) > 0))) - break; - } - } - tp->next = *tpp; - *tpp = tp; - } - else -#endif - { tp->next = soap->attributes; - soap->attributes = tp; - } - strcpy(tp->name, name); - tp->value = NULL; - } - else if (value && tp->value && tp->size <= strlen(value)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free attribute value of %s (free %p)\n", name, tp->value)); - SOAP_FREE(tp->value); - tp->value = NULL; - tp->ns = NULL; - } - if (value) - { if (!tp->value) - { tp->size = strlen(value) + 1; - if (!(tp->value = (char*)SOAP_MALLOC(tp->size))) - return soap->error = SOAP_EOM; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute value of %s (%p)\n", tp->name, tp->value)); - } - strcpy(tp->value, value); - if (!strncmp(tp->name, "xmlns:", 6)) - tp->ns = tp->value; - tp->visible = 2; - } - else - tp->visible = 1; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_attr(struct soap *soap) -{ register struct soap_attribute *tp; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { while (soap->attributes) - { tp = soap->attributes->next; - SOAP_FREE(soap->attributes->value); - SOAP_FREE(soap->attributes); - soap->attributes = tp; - } - } - else -#endif - { for (tp = soap->attributes; tp; tp = tp->next) - tp->visible = 0; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static int -soap_getattrval(struct soap *soap, char *s, size_t n, wchar d) -{ size_t i; - wchar c; - for (i = 0; i < n; i++) - { c = soap_getutf8(soap); - switch (c) - { - case TT: - *s++ = '<'; - soap_unget(soap, '/'); - break; - case LT: - *s++ = '<'; - break; - case GT: - if (d == ' ') - { soap_unget(soap, c); - *s = '\0'; - return SOAP_OK; - } - *s++ = '>'; - break; - case QT: - if (c == d) - { *s = '\0'; - return SOAP_OK; - } - *s++ = '"'; - break; - case AP: - if (c == d) - { *s = '\0'; - return SOAP_OK; - } - *s++ = '\''; - break; - case '\t': - case '\n': - case '\r': - case ' ': - case '/': - if (d == ' ') - { soap_unget(soap, c); - *s = '\0'; - return SOAP_OK; - } - default: - if ((int)c == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - } - return soap->error = SOAP_EOM; -} -#endif - -/******************************************************************************/ -#ifdef WITH_FAST -#ifndef PALM_2 -static int -soap_append_lab(struct soap *soap, const char *s, size_t n) -{ if (soap->labidx + n >= soap->lablen) - { register char *t = soap->labbuf; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enlarging look-aside buffer to append data, old size=%lu", (unsigned long)soap->lablen)); - if (soap->lablen == 0) - soap->lablen = SOAP_LABLEN; - while (soap->labidx + n >= soap->lablen) - soap->lablen <<= 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, ", new size=%lu\n", (unsigned long)soap->lablen)); - soap->labbuf = (char*)SOAP_MALLOC(soap->lablen); - if (!soap->labbuf) - { if (t) - free(t); - return soap->error = SOAP_EOM; - } - if (t && soap->labidx) - { memcpy(soap->labbuf, t, soap->labidx); - free(t); - } - } - if (s) - { memcpy(soap->labbuf + soap->labidx, s, n); - soap->labidx += n; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_peek_element(struct soap *soap) -{ struct soap_attribute *tp; - const char *t; - register char *s; - register wchar c; - register int i; - if (soap->peeked) - { if (*soap->tag == '\0') - return soap->error = SOAP_NO_TAG; - return SOAP_OK; - } - soap->peeked = 1; - for (;;) - { while (((c = soap_get(soap)) != LT) && c != TT) - { if ((int)c == EOF) - return soap->error = SOAP_EOF; - } - if (c == TT) - { *soap->tag = '\0'; - return soap->error = SOAP_NO_TAG; /* ending tag found */ - } - s = soap->tag; - do c = soap_get(soap); - while (soap_blank(c)); - i = sizeof(soap->tag); - while (c != '/' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - while (soap_blank(c)) - c = soap_get(soap); - *s = '\0'; - if (*soap->tag != '?') - break; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "XML PI <%s?>\n", soap->tag)); - while ((int)c != EOF && c != GT && c != '?') - { s = soap->tmpbuf; - i = sizeof(soap->tmpbuf) - 2; - while (c != '=' && c != GT && c != '?' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - while (soap_blank(c)) - c = soap_get(soap); - if (c == '=') - { *s++ = '='; - do c = soap_get(soap); - while (soap_blank(c)); - if (c != QT && c != AP) - { soap_unget(soap, c); - c = ' '; /* blank delimiter */ - } - if (soap_getattrval(soap, s, i, c) == SOAP_EOM) - while (soap_getattrval(soap, soap->tmpbuf, sizeof(soap->tmpbuf), c) == SOAP_EOM) - ; - else if (!strcmp(soap->tag, "?xml") && (!soap_tag_cmp(soap->tmpbuf, "encoding=iso-8859-1") || !soap_tag_cmp(soap->tmpbuf, "encoding=latin1"))) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "XML latin1 encoding\n")); - soap->mode |= SOAP_C_LATIN; - } - } - do c = soap_get(soap); - while (soap_blank(c)); - } - } - soap->id[0] = '\0'; - soap->href[0] = '\0'; - soap->type[0] = '\0'; - soap->arrayType[0] = '\0'; - soap->arraySize[0] = '\0'; - soap->arrayOffset[0] = '\0'; - soap->other = 0; - soap->root = -1; - soap->position = 0; - soap->null = 0; - soap->mustUnderstand = 0; - soap_clr_attr(soap); - soap_pop_namespace(soap); - while ((int)c != EOF && c != GT && c != '/') - { s = soap->tmpbuf; - i = sizeof(soap->tmpbuf); - while (c != '=' && c != '/' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - *s = '\0'; - if (i == sizeof(soap->tmpbuf)) - return soap->error = SOAP_SYNTAX_ERROR; - if (!strncmp(soap->tmpbuf, "xmlns:", 6)) - { soap->tmpbuf[5] = '\0'; - t = soap->tmpbuf + 6; - } - else if (!strcmp(soap->tmpbuf, "xmlns")) - t = SOAP_STR_EOS; - else - t = NULL; - tp = soap_attr(soap, soap->tmpbuf); - if (!tp) - { tp = (struct soap_attribute*)SOAP_MALLOC(sizeof(struct soap_attribute) + strlen(soap->tmpbuf)); - if (!tp) - return soap->error = SOAP_EOM; - strcpy(tp->name, soap->tmpbuf); - tp->value = NULL; - tp->size = 0; - tp->next = soap->attributes; - soap->attributes = tp; - } - while (soap_blank(c)) - c = soap_get(soap); - if (c == '=') - { do c = soap_get(soap); - while (soap_blank(c)); - if (c != QT && c != AP) - { soap_unget(soap, c); - c = ' '; /* blank delimiter */ - } - if (soap_getattrval(soap, tp->value, tp->size, c)) - { -#ifdef WITH_FAST - if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - soap->labidx = 0; - if (soap_append_lab(soap, tp->value, tp->size)) - return soap->error; - SOAP_FREE(tp->value); - for (;;) - { if (soap_getattrval(soap, soap->labbuf + soap->labidx, soap->lablen - soap->labidx, c)) - { if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - soap->labidx = soap->lablen; - if (soap_append_lab(soap, NULL, 0)) - return soap->error; - } - else - break; - } - tp->size = soap->lablen; - if (!(tp->value = (char*)SOAP_MALLOC(tp->size))) - return soap->error = SOAP_EOM; - memcpy(tp->value, soap->labbuf, soap->lablen); -#else - size_t n; - if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - if (soap_new_block(soap)) - return soap->error; - for (;;) - { if (!(s = (char*)soap_push_block(soap, SOAP_BLKLEN))) - return soap->error; - if (soap_getattrval(soap, s, SOAP_BLKLEN, c)) - { if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - } - else - break; - } - n = tp->size + soap->blist->size; - if (!(s = (char*)SOAP_MALLOC(n))) - return soap->error = SOAP_EOM; - if (tp->value) - { memcpy(s, tp->value, tp->size); - SOAP_FREE(tp->value); - } - soap_save_block(soap, s + tp->size); - tp->value = s; - tp->size = n; -#endif - } - do c = soap_get(soap); - while (soap_blank(c)); - tp->visible = 2; /* seen this attribute w/ value */ - } - else - tp->visible = 1; /* seen this attribute w/o value */ - if (t && tp->value) - { if (soap_push_namespace(soap, t, tp->value)) - return soap->error; - tp->visible = 0; - } - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible && tp->value) - { if (!strcmp(tp->name, "id")) - { if (soap->part != SOAP_IN_HEADER || !soap->dot_net_bug) - { *soap->id = '#'; - strncpy(soap->id + 1, tp->value, sizeof(soap->id) - 2); - } - } - else if (soap->version == 1 && !strcmp(tp->name, "href")) - strncpy(soap->href, tp->value, sizeof(soap->href) - 1); - else if (soap->version == 2 && !strcmp(tp->name, "ref")) - { *soap->href = '#'; - strncpy(soap->href + 1, tp->value, sizeof(soap->href) - 2); - } - else if (!soap_match_tag(soap, tp->name, "xsi:type")) - strncpy(soap->type, tp->value, sizeof(soap->type) - 1); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:arrayType")) - { s = soap_strrchr(tp->value, '['); - if (s && (size_t)(s - tp->value) < sizeof(soap->arrayType)) - { strncpy(soap->arrayType, tp->value, s - tp->value); - soap->arrayType[s - tp->value] = '\0'; - strncpy(soap->arraySize, s, sizeof(soap->arraySize) - 1); - } - else - strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType) - 1); - } - else if (soap->version == 2 && !soap_match_tag(soap, tp->name, "SOAP-ENC:itemType")) - strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType) - 1); - else if (soap->version == 2 && !soap_match_tag(soap, tp->name, "SOAP-ENC:arraySize")) - strncpy(soap->arraySize, tp->value, sizeof(soap->arraySize) - 1); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:offset")) - strncpy(soap->arrayOffset, tp->value, sizeof(soap->arrayOffset)); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:position")) - soap->position = soap_getposition(tp->value, soap->positions); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:root")) - soap->root = ((!strcmp(tp->value, "1") || !strcmp(tp->value, "true"))); - else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:actor") - || !soap_match_tag(soap, tp->name, "SOAP-ENV:role")) - { if ((!soap->actor || strcmp(soap->actor, tp->value)) - && strcmp(tp->value, "http://schemas.xmlsoap.org/soap/actor/next") - && strcmp(tp->value, "http://www.w3.org/2003/05/soap-envelope/role/next")) - soap->other = 1; - } - else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:mustUnderstand") - && (!strcmp(tp->value, "1") || !strcmp(tp->value, "true"))) - soap->mustUnderstand = 1; - else if ((!soap_match_tag(soap, tp->name, "xsi:null") - || !soap_match_tag(soap, tp->name, "xsi:nil")) - && (!strcmp(tp->value, "1") - || !strcmp(tp->value, "true"))) - soap->null = 1; - } - } - if (!(soap->body = (c != '/'))) - do c = soap_get(soap); - while (soap_blank(c)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_retry(struct soap *soap) -{ soap->peeked = 1; - soap->error = SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_revert(struct soap *soap) -{ soap->peeked = 1; - if (soap->body) - soap->level--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reverting last element (level=%u)\n", soap->level)); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_string_out(struct soap *soap, const char *s, int flag) -{ register const char *t; - register wchar c; - register wchar mask = 0x80000000; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->data = soap_strdup(soap, s); /* check EOM */ - return SOAP_OK; - } -#endif - if (soap->mode & SOAP_C_UTFSTRING) - mask = 0; - t = s; - while ((c = *t++)) - { switch (c) - { - case 9: - if (flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - } - break; - case 10: - if (flag || !(soap->mode & SOAP_XML_CANONICAL)) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - } - break; - case 13: - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - break; - case '&': - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&", 5)) - return soap->error; - s = t; - break; - case '<': - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "<", 4)) - return soap->error; - s = t; - break; - case '>': - if (!flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, ">", 4)) - return soap->error; - s = t; - } - break; - case '"': - if (flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, """, 6)) - return soap->error; - s = t; - } - break; - default: -#ifdef HAVE_MBTOWC - if (soap->mode & SOAP_C_MBSTRING) - { wchar_t wc; - register int m = mbtowc(&wc, t - 1, MB_CUR_MAX); - if (m > 0 && wc != c) - { if (soap_send_raw(soap, s, t - s - 1) || soap_pututf8(soap, wc)) - return soap->error; - s = t + m - 1; - continue; - } - } -#endif - if (c & mask) - { if (soap_send_raw(soap, s, t - s - 1) || soap_pututf8(soap, (unsigned char)c)) - return soap->error; - s = t; - } - } - } - return soap_send_raw(soap, s, t - s - 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_string_in(struct soap *soap, int flag) -{ register char *s; - char *t = NULL; - register size_t i; - register int n = 0; - register int m = 0; - register wchar c; -#ifdef HAVE_WCTOMB - char buf[MB_LEN_MAX > 8 ? MB_LEN_MAX : 8]; -#else - char buf[8]; -#endif -#ifdef WITH_CDATA - if (!flag) - { register int state = 0; -#ifdef WITH_FAST - soap->labidx = 0; /* use look-aside buffer */ -#else - if (soap_new_block(soap)) - return NULL; -#endif - for (;;) - { -#ifdef WITH_FAST - register size_t k; - if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ - return NULL; - s = soap->labbuf + soap->labidx; /* space to populate */ - k = soap->lablen - soap->labidx; /* number of bytes available */ - soap->labidx = soap->lablen; /* claim this space */ -#else - register size_t k = SOAP_BLKLEN; - if (!(s = (char*)soap_push_block(soap, k))) - return NULL; -#endif - for (i = 0; i < k; i++) - { if (m > 0) - { *s++ = *t++; /* copy multibyte characters */ - m--; - continue; - } - c = soap_getchar(soap); - if ((int)c == EOF) - goto end; - if (c >= 0x80 && !(soap->mode & SOAP_C_LATIN)) - { soap_unget(soap, c); - c = soap_getutf8(soap); - if (soap->mode & SOAP_C_UTFSTRING) - { if ((c & 0x80000000) && c >= -0x7FFFFF80 && c < AP) - { c &= 0x7FFFFFFF; - t = buf; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - m = (int)(t - buf) - 1; - t = buf; - *s++ = *t++; - continue; - } - } - } - switch (state) - { case 1: - if (c == ']') - state = 4; - *s++ = c; - continue; - case 2: - if (c == '-') - state = 6; - *s++ = c; - continue; - case 3: - if (c == '?') - state = 8; - *s++ = c; - continue; - /* CDATA */ - case 4: - if (c == ']') - state = 5; - else - state = 1; - *s++ = c; - continue; - case 5: - if (c == '>') - state = 0; - else - state = 1; - *s++ = c; - continue; - /* comment */ - case 6: - if (c == '-') - state = 7; - else - state = 2; - *s++ = c; - continue; - case 7: - if (c == '>') - state = 0; - else - state = 2; - *s++ = c; - continue; - /* PI */ - case 8: - if (c == '>') - state = 0; - else - state = 3; - *s++ = c; - continue; - } - switch (c) - { - case '/': - if (n > 0) - { c = soap_get1(soap); - if (c == '>') - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<': - c = soap_get1(soap); - if (c == '/') - { if (n == 0) - { c = TT; - goto end; - } - n--; - } - else if (c == '!') - { c = soap_get1(soap); - if (c == '[') - { do c = soap_get1(soap); - while ((int)c != EOF && c != '['); - if ((int)c == EOF) - goto end; - t = (char*)"![CDATA["; - state = 1; - } - else if (c == '-') - { if ((c = soap_get1(soap)) == '-') - state = 2; - t = (char*)"!-"; - soap_unget(soap, c); - } - else - { t = (char*)"!"; - soap_unget(soap, c); - } - *s++ = '<'; - break; - } - else if (c == '?') - state = 3; - else - n++; - soap_unget(soap, c); - *s++ = '<'; - break; - case '>': - *s++ = '>'; - break; - case '"': - *s++ = '"'; - break; - default: -#ifdef HAVE_WCTOMB - if (soap->mode & SOAP_C_MBSTRING) - { m = wctomb(buf, c & 0x7FFFFFFF); - if (m >= 1) - { t = buf; - *s++ = *t++; - m--; - } - else - *s++ = SOAP_UNKNOWN_CHAR; - } - else -#endif - *s++ = (char)(c & 0xFF); - } - } - } - } -#endif -#ifdef WITH_FAST - soap->labidx = 0; /* use look-aside buffer */ -#else - if (soap_new_block(soap)) - return NULL; -#endif - for (;;) - { -#ifdef WITH_FAST - register size_t k; - if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ - return NULL; - s = soap->labbuf + soap->labidx; /* space to populate */ - k = soap->lablen - soap->labidx; /* number of bytes available */ - soap->labidx = soap->lablen; /* claim this space */ -#else - register size_t k = SOAP_BLKLEN; - if (!(s = (char*)soap_push_block(soap, k))) - return NULL; -#endif - for (i = 0; i < k; i++) - { if (m > 0) - { *s++ = *t++; /* copy multibyte characters */ - m--; - continue; - } - if (soap->mode & SOAP_C_UTFSTRING) - { if (((c = soap_get(soap)) & 0x80000000) && c >= -0x7FFFFF80 && c < AP) - { c &= 0x7FFFFFFF; - t = buf; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - m = (int)(t - buf) - 1; - t = buf; - *s++ = *t++; - continue; - } - } - else if (soap->mode & SOAP_C_LATIN) - c = soap_get(soap); - else - c = soap_getutf8(soap); - switch (c) - { - case TT: - if (n == 0) - goto end; - n--; - *s++ = '<'; - soap_unget(soap, '/'); - break; - case LT: - n++; - *s++ = '<'; - break; - case GT: - *s++ = '>'; - break; - case QT: - *s++ = '"'; - break; - case AP: - *s++ = '\''; - break; - case '/': - if (n > 0) - { c = soap_get(soap); - if (c == GT) - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<': - if (flag) - *s++ = '<'; - else - { *s++ = '&'; - t = (char*)"lt;"; - } - break; - case '>': - if (flag) - *s++ = '>'; - else - { *s++ = '&'; - t = (char*)"gt;"; - } - break; - case '"': - if (flag) - *s++ = '"'; - else - { *s++ = '&'; - t = (char*)"quot;"; - } - break; - default: - if ((int)c == EOF) - goto end; -#ifdef HAVE_WCTOMB - if (soap->mode & SOAP_C_MBSTRING) - { m = wctomb(buf, c & 0x7FFFFFFF); - if (m >= 1) - { t = buf; - *s++ = *t++; - m--; - } - else - *s++ = SOAP_UNKNOWN_CHAR; - } - else -#endif - *s++ = (char)(c & 0xFF); - } - } - } -end: - soap_unget(soap, c); - *s = '\0'; -#ifdef WITH_FAST - t = soap_strdup(soap, soap->labbuf); -#else - soap_size_block(soap, i+1); - t = soap_save_block(soap, NULL); -#endif - if (flag == 2) - if (soap_s2QName(soap, t, &t)) - return NULL; - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_wstring_out(struct soap *soap, const wchar_t *s, int flag) -{ const char *t; - char tmp; - register wchar c; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->wide = NULL; /* soap_malloc() ??? */ - return SOAP_OK; - } -#endif - while ((c = *s++)) - { switch (c) - { - case 9: - if (flag) - t = " "; - else - t = "\t"; - break; - case 10: - if (flag || !(soap->mode & SOAP_XML_CANONICAL)) - t = " "; - else - t = "\n"; - break; - case 13: - t = " "; - break; - case '&': - t = "&"; - break; - case '<': - t = "<"; - break; - case '>': - if (flag) - t = ">"; - else - t = ">"; - break; - case '"': - if (flag) - t = """; - else - t = "\""; - break; - default: - if (c > 0 && c < 0x80) - { tmp = (char)c; - if (soap_send_raw(soap, &tmp, 1)) - return soap->error; - } - else if (soap_pututf8(soap, (unsigned long)c)) - return soap->error; - continue; - } - if (soap_send(soap, t)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t * -SOAP_FMAC2 -soap_wstring_in(struct soap *soap, int flag) -{ wchar_t *s; - register int i, n = 0; - register wchar c; - const char *t = NULL; - if (soap_new_block(soap)) - return NULL; - for (;;) - { if (!(s = (wchar_t*)soap_push_block(soap, sizeof(wchar_t)*SOAP_BLKLEN))) - return NULL; - for (i = 0; i < SOAP_BLKLEN; i++) - { if (t) - { *s++ = (wchar_t)*t++; - if (!*t) - t = NULL; - continue; - } - if (soap->mode & SOAP_C_LATIN) - c = soap_get(soap); - else - c = soap_getutf8(soap); - switch (c) - { - case TT: - if (n == 0) - goto end; - n--; - *s++ = '<'; - soap_unget(soap, '/'); - break; - case LT: - n++; - *s++ = '<'; - break; - case GT: - *s++ = '>'; - break; - case QT: - *s++ = '"'; - break; - case AP: - *s++ = '\''; - break; - case '/': - if (n > 0) - { c = soap_getutf8(soap); - if (c == GT) - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<': - if (flag) - *s++ = (wchar)'<'; - else - { *s++ = (wchar)'&'; - t = "lt;"; - } - break; - case '>': - if (flag) - *s++ = (wchar)'>'; - else - { *s++ = (wchar)'&'; - t = "gt;"; - } - break; - case '"': - if (flag) - *s++ = (wchar)'"'; - else - { *s++ = (wchar)'&'; - t = "quot;"; - } - break; - default: - if ((int)c == EOF) - goto end; - *s++ = (wchar_t)c & 0x7FFFFFFF; - } - } - } -end: - soap_unget(soap, c); - *s = '\0'; - soap_size_block(soap, sizeof(wchar_t) * (i + 1)); - return (wchar_t*)soap_save_block(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_int2s(struct soap *soap, int n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outint(struct soap *soap, const char *tag, int id, const int *p, const char *type, int n) -{ long m = (long)*p; - return soap_outlong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2int(struct soap *soap, const char *s, int *p) -{ if (s) - { char *r; - *p = (int)soap_strtol(s, &r, 10); - if (*r) - return soap->error = SOAP_TYPE; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int * -SOAP_FMAC2 -soap_inint(struct soap *soap, const char *tag, int *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (int*)soap_id_enter(soap, soap->id, p, t, sizeof(int), 0); - if (p && soap->body && !*soap->href) - soap_s2int(soap, soap_value(soap), p); - else - p = (int*)soap_id_forward(soap, soap->href, p, t, sizeof(int)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_long2s(struct soap *soap, long n) -{ sprintf(soap->tmpbuf, "%ld", n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outlong(struct soap *soap, const char *tag, int id, const long *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_long2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2long(struct soap *soap, const char *s, long *p) -{ if (s) - { char *r; - *p = soap_strtol(s, &r, 10); - if (*r) - return soap->error = SOAP_TYPE; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -long * -SOAP_FMAC2 -soap_inlong(struct soap *soap, const char *tag, long *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (long*)soap_id_enter(soap, soap->id, p, t, sizeof(long), 0); - if (p && soap->body && !*soap->href) - soap_s2long(soap, soap_value(soap), p); - else - p = (long*)soap_id_forward(soap, soap->href, p, t, sizeof(long)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_LONG642s(struct soap *soap, LONG64 n) -{ sprintf(soap->tmpbuf, SOAP_LONG_FORMAT, n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outLONG64(struct soap *soap, const char *tag, int id, const LONG64 *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_LONG642s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2LONG64(struct soap *soap, const char *s, LONG64 *p) -{ if (s && sscanf(s, SOAP_LONG_FORMAT, p) != 1) - return soap->error = SOAP_TYPE; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -LONG64 * -SOAP_FMAC2 -soap_inLONG64(struct soap *soap, const char *tag, LONG64 *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":integer") - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":negativeInteger") - && soap_match_tag(soap, soap->type, ":nonPositiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":long") - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (LONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(LONG64), 0); - if (soap->body && !*soap->href) - soap_s2LONG64(soap, soap_value(soap), p); - else - p = (LONG64*)soap_id_forward(soap, soap->href, p, t, sizeof(LONG64)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_byte2s(struct soap *soap, char n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outbyte(struct soap *soap, const char *tag, int id, const char *p, const char *type, int n) -{ long m = (long)*p; - return soap_outlong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2byte(struct soap *soap, const char *s, char *p) -{ if (s) - { long n; - char *r; - n = soap_strtol(s, &r, 10); - if (*r || n < -128 || n > 127) - return soap->error = SOAP_TYPE; - *p = (char)n; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_inbyte(struct soap *soap, const char *tag, char *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (char*)soap_id_enter(soap, soap->id, p, t, sizeof(char), 0); - if (soap->body && !*soap->href) - soap_s2byte(soap, soap_value(soap), p); - else - p = (char*)soap_id_forward(soap, soap->href, p, t, sizeof(char)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_short2s(struct soap *soap, short n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outshort(struct soap *soap, const char *tag, int id, const short *p, const char *type, int n) -{ long m = (long)*p; - return soap_outlong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2short(struct soap *soap, const char *s, short *p) -{ if (s) - { long n; - char *r; - n = soap_strtol(s, &r, 10); - if (*r || n < -32768 || n > 32767) - return soap->error = SOAP_TYPE; - *p = (char)n; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -short * -SOAP_FMAC2 -soap_inshort(struct soap *soap, const char *tag, short *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (short*)soap_id_enter(soap, soap->id, p, t, sizeof(short), 0); - if (soap->body && !*soap->href) - soap_s2short(soap, soap_value(soap), p); - else - p = (short*)soap_id_forward(soap, soap->href, p, t, sizeof(short)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_float2s(struct soap *soap, float n) -{ const char *s; - if (isnan(n)) - s = "NaN"; - else if (n >= FLT_PINFTY) - s = "INF"; - else if (n <= FLT_NINFTY) - s = "-INF"; - else - { sprintf(soap->tmpbuf, soap->float_format, n); - s = soap->tmpbuf; - } - return s; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outfloat(struct soap *soap, const char *tag, int id, const float *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_float2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2float(struct soap *soap, const char *s, float *p) -{ if (s) - { if (!soap_tag_cmp(s, "INF")) - *p = FLT_PINFTY; - else if (!soap_tag_cmp(s, "+INF")) - *p = FLT_PINFTY; - else if (!soap_tag_cmp(s, "-INF")) - *p = FLT_NINFTY; - else if (!soap_tag_cmp(s, "NaN")) - *p = FLT_NAN; - else - { -#ifdef HAVE_STRTOD - char *r; - *p = (float)strtod(s, &r); - if (*r) -#endif - if (sscanf(s, soap->float_format, p) != 1) - return soap->error = SOAP_TYPE; - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static int soap_isnumeric(struct soap *soap, const char *type) -{ if (soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":float") - && soap_match_tag(soap, soap->type, ":double") - && soap_match_tag(soap, soap->type, ":decimal") - && soap_match_tag(soap, soap->type, ":integer") - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":negativeInteger") - && soap_match_tag(soap, soap->type, ":nonPositiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":long") - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte") - && soap_match_tag(soap, soap->type, ":unsignedLong") - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return SOAP_ERR; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -float * -SOAP_FMAC2 -soap_infloat(struct soap *soap, const char *tag, float *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type != '\0' && soap_isnumeric(soap, type)) - return NULL; - p = (float*)soap_id_enter(soap, soap->id, p, t, sizeof(float), 0); - if (soap->body && !*soap->href) - soap_s2float(soap, soap_value(soap), p); - else - p = (float*)soap_id_forward(soap, soap->href, p, t, sizeof(float)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_double2s(struct soap *soap, double n) -{ const char *s; - if (isnan(n)) - s = "NaN"; - else if (n >= DBL_PINFTY) - s = "INF"; - else if (n <= DBL_NINFTY) - s = "-INF"; - else - { sprintf(soap->tmpbuf, soap->double_format, n); - s = soap->tmpbuf; - } - return s; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outdouble(struct soap *soap, const char *tag, int id, const double *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_double2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2double(struct soap *soap, const char *s, double *p) -{ if (s) - { if (!soap_tag_cmp(s, "INF")) - *p = DBL_PINFTY; - else if (!soap_tag_cmp(s, "+INF")) - *p = DBL_PINFTY; - else if (!soap_tag_cmp(s, "-INF")) - *p = DBL_NINFTY; - else if (!soap_tag_cmp(s, "NaN")) - *p = DBL_NAN; - else - { -#ifdef HAVE_STRTOD - char *r; - *p = strtod(s, &r); - if (*r) -#endif - if (sscanf(s, soap->double_format, p) != 1) - return soap->error = SOAP_TYPE; - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -double * -SOAP_FMAC2 -soap_indouble(struct soap *soap, const char *tag, double *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type != '\0' && soap_isnumeric(soap, type)) - return NULL; - p = (double*)soap_id_enter(soap, soap->id, p, t, sizeof(double), 0); - if (soap->body && !*soap->href) - soap_s2double(soap, soap_value(soap), p); - else - p = (double*)soap_id_forward(soap, soap->href, p, t, sizeof(double)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedByte2s(struct soap *soap, unsigned char n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedByte(struct soap *soap, const char *tag, int id, const unsigned char *p, const char *type, int n) -{ unsigned long m = (unsigned long)*p; - return soap_outunsignedLong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedByte(struct soap *soap, const char *s, unsigned char *p) -{ if (s) - { unsigned long n; - char *r; - n = soap_strtoul(s, &r, 10); - if (*r || n > 255) - return soap->error = SOAP_TYPE; - *p = (unsigned char)n; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned char * -SOAP_FMAC2 -soap_inunsignedByte(struct soap *soap, const char *tag, unsigned char *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (unsigned char*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned char), 0); - if (soap->body && !*soap->href) - soap_s2unsignedByte(soap, soap_value(soap), p); - else - p = (unsigned char*)soap_id_forward(soap, soap->href, p, t, sizeof(unsigned char)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedShort2s(struct soap *soap, unsigned short n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedShort(struct soap *soap, const char *tag, int id, const unsigned short *p, const char *type, int n) -{ unsigned long m = (unsigned long)*p; - return soap_outunsignedLong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedShort(struct soap *soap, const char *s, unsigned short *p) -{ if (s) - { unsigned long n; - char *r; - n = soap_strtoul(s, &r, 10); - if (*r || n > 65535) - return soap->error = SOAP_TYPE; - *p = (unsigned short)n; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -unsigned short * -SOAP_FMAC2 -soap_inunsignedShort(struct soap *soap, const char *tag, unsigned short *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (unsigned short*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned short), 0); - if (soap->body && !*soap->href) - soap_s2unsignedShort(soap, soap_value(soap), p); - else - p = (unsigned short*)soap_id_forward(soap, soap->href, p, t, sizeof(unsigned short)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedInt2s(struct soap *soap, unsigned int n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedInt(struct soap *soap, const char *tag, int id, const unsigned int *p, const char *type, int n) -{ unsigned long m = (unsigned long)*p; - return soap_outunsignedLong(soap, tag, id, &m, type, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedInt(struct soap *soap, const char *s, unsigned int *p) -{ if (s) - { char *r; - *p = (unsigned int)soap_strtoul(s, &r, 10); - if (*r) - return soap->error = SOAP_TYPE; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned int * -SOAP_FMAC2 -soap_inunsignedInt(struct soap *soap, const char *tag, unsigned int *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (unsigned int*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned int), 0); - if (soap->body && !*soap->href) - soap_s2unsignedInt(soap, soap_value(soap), p); - else - p = (unsigned int*)soap_id_forward(soap, soap->href, p, t, sizeof(unsigned int)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedLong2s(struct soap *soap, unsigned long n) -{ sprintf(soap->tmpbuf, "%lu", n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedLong(struct soap *soap, const char *tag, int id, const unsigned long *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_unsignedLong2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedLong(struct soap *soap, const char *s, unsigned long *p) -{ if (s) - { char *r; - *p = soap_strtoul(s, &r, 10); - if (*r) - return soap->error = SOAP_TYPE; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned long * -SOAP_FMAC2 -soap_inunsignedLong(struct soap *soap, const char *tag, unsigned long *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (unsigned long*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned long), 0); - if (soap->body && !*soap->href) - soap_s2unsignedLong(soap, soap_value(soap), p); - else - p = (unsigned long*)soap_id_forward(soap, soap->href, p, t, sizeof(unsigned long)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_ULONG642s(struct soap *soap, ULONG64 n) -{ sprintf(soap->tmpbuf, SOAP_ULONG_FORMAT, n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outULONG64(struct soap *soap, const char *tag, int id, const ULONG64 *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_ULONG642s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2ULONG64(struct soap *soap, const char *s, ULONG64 *p) -{ if (s && sscanf(s, SOAP_ULONG_FORMAT, p) != 1) - return soap->error = SOAP_TYPE; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -ULONG64 * -SOAP_FMAC2 -soap_inULONG64(struct soap *soap, const char *tag, ULONG64 *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":unsignedLong") - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (ULONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(ULONG64), 0); - if (soap->body && !*soap->href) - soap_s2ULONG64(soap, soap_value(soap), p); - else - p = (ULONG64*)soap_id_forward(soap, soap->href, p, t, sizeof(ULONG64)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2string(struct soap *soap, const char *s, char **t) -{ *t = NULL; - if (s && !(*t = soap_strdup(soap, s))) - return soap->error = SOAP_EOM; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2QName(struct soap *soap, const char *s, char **t) -{ if (s) - { struct soap_nlist *np = soap->nlist; - const char *p = strchr(s, ':'); - if (p) - { int n = p - s; - while (np && (np->index == -2 || strncmp(np->id, s, n) || np->id[n])) - np = np->next; - p++; - } - else - { while (np && *np->id) - np = np->next; - p = s; - } - if (np) - { if (np->index >= 0 && soap->local_namespaces) - { const char *q = soap->local_namespaces[np->index].id; - if (q) - { if ((*t = (char*)soap_malloc(soap, strlen(p) + strlen(q) + 2))) - sprintf(*t, "%s:%s", q, p); - return SOAP_OK; - } - } - if (np->ns) - { if ((*t = (char*)soap_malloc(soap, strlen(p) + strlen(np->ns) + 4))) - sprintf(*t, "\"%s\":%s", np->ns, p); - return SOAP_OK; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Namespace prefix of '%s' not defined (index=%d, URI=%s)\n", s, np->index, np->ns?np->ns:"")); - return soap->error = SOAP_NAMESPACE; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Namespace prefix of '%s' not defined, assuming empty namespace\n", s)); - if ((*t = (char*)soap_malloc(soap, strlen(p) + 4))) - sprintf(*t, "\"\":%s", p); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_QName2s(struct soap *soap, const char *s) -{ struct Namespace *p; - char *t; - int n; - if (!s || *s != '"') - return s; - s++; - if ((p = soap->local_namespaces)) - { for (; p->id; p++) - { if (p->ns) - if (!soap_tag_cmp(s, p->ns)) - break; - if (p->in) - if (!soap_tag_cmp(s, p->in)) - break; - } - if (p && p->id) - { s = strchr(s, '"'); - if (s) - { t = (char*)soap_malloc(soap, strlen(p->id) + strlen(s)); - strcpy(t, p->id); - strcat(t, s + 1); - return t; - } - } - } - t = (char*)strchr(s, '"'); - if (t) - n = t - s; - else - n = 0; - t = soap_strdup(soap, s); - t[n] = '\0'; - sprintf(soap->tmpbuf, "xmlns:_%lu", soap->idnum++); - soap_set_attr(soap, soap->tmpbuf, t); - s = strchr(s, '"'); - if (s) - { t = (char*)soap_malloc(soap, strlen(soap->tmpbuf) + strlen(s) - 6); - strcpy(t, soap->tmpbuf + 6); - strcat(t, s + 1); - } - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outstring(struct soap *soap, const char *tag, int id, char *const*p, const char *type, int n) -{ if (!*p) - { if (soap_element_null(soap, tag, id, type)) - return soap->error; - } - else - { struct soap_plist *pp; - int i = soap_pointer_lookup(soap, *p, n, &pp); - if (id > 0) - { if (i) - { if (soap_element_begin_out(soap, tag, id, type) || soap_string_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - soap_set_embedded(soap, pp); - } - else - { i = soap_pointer_enter(soap, *p, n, &pp); - if (soap_element_begin_out(soap, tag, id, type) || soap_string_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 0; - else - pp->mark2 = 0; - } - } - else if (i) - { if (soap_is_embedded(soap, pp)) - { if (soap_element_ref(soap, tag, 0, i)) - return soap->error; - } - else if (soap_is_single(soap, pp)) - { if (soap_element_begin_out(soap, tag, 0, type) || soap_string_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - } - else - { if (soap_element_begin_out(soap, tag, i, type) || soap_string_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - soap_set_embedded(soap, pp); - } - } - else - { soap_pointer_enter(soap, *p, n, &pp); - if (soap_element_begin_out(soap, tag, id, type) || soap_string_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 0; - else - pp->mark2 = 0; - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char ** -SOAP_FMAC2 -soap_instring(struct soap *soap, const char *tag, char **p, const char *type, int t, int flag) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { p = (char**)soap_id_enter(soap, soap->id, p, t, sizeof(char**), 0); - if (p) - *p = NULL; - } - else if (soap->body && !*soap->href) - { if (soap_match_tag(soap, soap->type, "PointerTostring") == 0) - { p = (char**)soap_id_enter(soap, soap->id, p, t, sizeof(char**), 0); - p = (char**)soap_instring(soap, "string", p, type, t, flag); - } - else - { if (!p) - if ((p = (char**)soap_id_enter(soap, SOAP_STR_EOS, p, t, sizeof(char**), 0)) == NULL) - return NULL; - *p = (char*)soap_id_enter(soap, soap->id, soap_string_in(soap, flag), t, 0, 0); - } - } - else - p = (char**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(char*), 0); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outwstring(struct soap *soap, const char *tag, int id, wchar_t *const*p, const char *type, int n) -{ if (!*p) - { if (soap_element_null(soap, tag, id, type)) - return soap->error; - } - else - { struct soap_plist *pp; - int i = soap_pointer_lookup(soap, *p, n, &pp); - if (id > 0) - { if (i) - { if (soap_element_begin_out(soap, tag, id, type) || soap_wstring_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - soap_set_embedded(soap, pp); - } - else - { i = soap_pointer_enter(soap, *p, n, &pp); - if (soap_element_begin_out(soap, tag, id, type) || soap_wstring_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 0; - else - pp->mark2 = 0; - } - } - else if (i) - { if (soap_is_embedded(soap, pp)) - { if (soap_element_ref(soap, tag, 0, i)) - return soap->error; - } - else if (soap_is_single(soap, pp)) - { if (soap_element_begin_out(soap, tag, 0, type) || soap_wstring_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - } - else - { if (soap_element_begin_out(soap, tag, i, type) || soap_wstring_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - soap_set_embedded(soap, pp); - } - } - else - { if (soap_element_begin_out(soap, tag, id, type) || soap_wstring_out(soap, *p, 0) || soap_element_end_out(soap, tag)) - return soap->error; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 0; - else - pp->mark2 = 0; - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t ** -SOAP_FMAC2 -soap_inwstring(struct soap *soap, const char *tag, wchar_t **p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { p = (wchar_t**)soap_id_enter(soap, soap->id, p, t, sizeof(wchar_t**), 0); - if (p) - *p = NULL; - } - else if (soap->body && !*soap->href) - { if (soap_match_tag(soap, soap->type, "PointerTostring") == 0) - p = (wchar_t**)soap_inwstring(soap, "string", (wchar_t**)soap_id_enter(soap, soap->id, p, t, sizeof(wchar_t**), 0), type, t); - else - { if (!p) - if (!(p = (wchar_t**)soap_id_enter(soap, SOAP_STR_EOS, p, t, sizeof(wchar_t**), 0))) - return NULL; - *p = (wchar_t*)soap_id_enter(soap, soap->id, soap_wstring_in(soap, 1), t, 0, 0); - } - } - else - p = (wchar_t**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(wchar_t*), 0); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static time_t -soap_timegm(struct tm *T) -{ -#if defined(HAVE_TIMEGM) - return timegm(T); -#elif defined(HAVE_GETTIMEOFDAY) - struct timezone t; - struct timeval tv; - gettimeofday(&tv, &t); /* doesn't work properly on Solaris */ - T->tm_min -= t.tz_minuteswest; - T->tm_isdst = (t.tz_dsttime != 0); - return mktime(T); -/* WR[ */ - /* The following define was added for VxWorks*/ -#elif defined(HAVE_MKTIME) - /* FOR VXWORKS: - vxWorks does not seem to have any variable representation of time zones, but - timezone information can be set in INSTALL_DIR/target/h/private/timeP.h header - file, by setting the ZONEBUFFER define. The ZONEBUFFER define follows this - format: - - name_of_zone:<(unused)>:time_in_minutes_from_UTC:daylight_start:daylight_end - - To calculate local time, the value of time_in_minutes_from_UTC is subtracted - from UTC; time_in_minutes_from_UTC must be positive. Daylight information is - expressed as mmddhh (month-day-hour), for example: - - UTC::0:040102:100102 - - */ - return mktime(T); -/* ]WR */ -#elif defined(HAVE_FTIME) - struct timeb t; - t.timezone = 0; - t.dstflag = -1; - ftime(&t); - T->tm_min -= t.timezone; - T->tm_isdst = t.dstflag; /* doesn't work properly on Solaris */ - return mktime(T); -#else -#warning "time_t (de)serialization is not MT safe on this platform" - time_t t; - char *tz = getenv("TZ"); - putenv("TZ=UTC"); - tzset(); - t = mktime(T); - if (tz) - { char tmp[16]; - strcpy(tmp, "TZ="); - strncat(tmp, tz, 12); - tmp[15] = '\0'; - putenv(tmp); - } - else - putenv("TZ="); - tzset(); - return t; -#endif -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_dateTime2s(struct soap *soap, time_t n) -{ struct tm T; - struct tm *pT = &T; -#if defined(HAVE_GMTIME_R) - if (gmtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PGMTIME_R) - if (gmtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -#elif defined(HAVE_PGMTIME) - if (gmtime(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -/* ]WR */ -#elif defined(HAVE_GMTIME) - if ((pT = gmtime(&n))) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -#elif defined(HAVE_GETTIMEOFDAY) - struct timezone t; -#if defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - { struct timeval tv; - gettimeofday(&tv, &t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.tz_minuteswest/60-(t.tz_dsttime!=0), abs(t.tz_minuteswest)%60); - } -#else - if ((pT = localtime(&n))) - { struct timeval tv; - gettimeofday(&tv, &t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.tz_minuteswest/60-(t.tz_dsttime!=0), abs(t.tz_minuteswest)%60); - } -#endif -#elif defined(HAVE_FTIME) - struct timeb t; -#if defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - { ftime(&t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60-(t.dstflag!=0), abs(t.timezone)%60); - } -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PLOCALTIME_R) - if (localtime_r(&n, pT)) - { strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf+strlen(soap->tmpbuf), "%+03d:%02d", t.timezone/60, abs(t.timezone)%60); - } -/* ]WR */ -#else - if ((pT = localtime(&n))) - { ftime(&t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60-(t.dstflag!=0), abs(t.timezone)%60); - } -#endif -#elif defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PLOCALTIME_R) - if (localtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -/* ]WR */ -#else - if ((pT = localtime(&n))) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -#endif - else - strcpy(soap->tmpbuf, "1969-12-31T23:59:59Z"); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outdateTime(struct soap *soap, const char *tag, int id, const time_t *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_dateTime2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2dateTime(struct soap *soap, const char *s, time_t *p) -{ if (s) - { struct tm T; - char zone[16]; - memset(&T, 0, sizeof(struct tm)); - zone[sizeof(zone)-1] = '\0'; - sscanf(s, "%d-%d-%dT%d:%d:%d%15s", &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec, zone); - if (T.tm_year == 1) - T.tm_year = 70; - else - T.tm_year -= 1900; - T.tm_mon--; - if (*zone) - { if (*zone == '.') - { for (s = zone + 1; *s; s++) - if (*s < '0' || *s > '9') - break; - } - else - s = zone; - if (*s != 'Z') - { int h = 0, m = 0; - sscanf(s, "%d:%d", &h, &m); - T.tm_hour -= h; - if (h >= 0) - T.tm_min -= m; - else - T.tm_min += m; - } - *p = soap_timegm(&T); - } - else - *p = mktime(&T); /* no time zone: suppose it is localtime? */ - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -time_t * -SOAP_FMAC2 -soap_indateTime(struct soap *soap, const char *tag, time_t *p, const char * type, int t) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (soap->null) - { if (soap->mode & SOAP_XML_NIL) - { soap->error = SOAP_NULL; - return NULL; - } - return p; - } - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":dateTime")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (time_t*)soap_id_enter(soap, soap->id, p, t, sizeof(time_t), 0); - if (soap->body && !*soap->href) - soap_s2dateTime(soap, soap_value(soap), p); - else - p = (time_t*)soap_id_forward(soap, soap->href, p, t, sizeof(time_t)); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outliteral(struct soap *soap, const char *tag, char *const*p) -{ int i; - const char *t = NULL; - if (tag && *tag != '-') - { if ((t = strchr(tag, ':'))) - { strncpy(soap->tmpbuf, tag, t-tag); - soap->tmpbuf[t-tag] = '\0'; - for (i = 0; soap->local_namespaces[i].id; i++) - if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id)) - break; - t++; - sprintf(soap->tmpbuf, "<%s xmlns=\"%s\">", t, soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS); - } - else - { t = tag; - sprintf(soap->tmpbuf, "<%s>", tag); - } - if (soap_send(soap, soap->tmpbuf)) - return soap->error; - } - if (p && *p) - { if (soap_send(soap, *p)) - return soap->error; - } - if (t) - { sprintf(soap->tmpbuf, "", t); - return soap_send(soap, soap->tmpbuf); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char ** -SOAP_FMAC2 -soap_inliteral(struct soap *soap, const char *tag, char **p) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (!p) - if (!(p = (char**)soap_malloc(soap, sizeof(char*)))) - return NULL; - if (soap->null) - *p = NULL; - else if (soap->body) - *p = soap_string_in(soap, 0); - else - *p = NULL; - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outwliteral(struct soap *soap, const char *tag, wchar_t *const*p) -{ int i; - const char *t = NULL; - wchar_t c; - const wchar_t *s; - if (tag && *tag != '-') - { if (tag && (t = strchr(tag, ':'))) - { strncpy(soap->tmpbuf, tag, t-tag); - soap->tmpbuf[t-tag] = '\0'; - for (i = 0; soap->local_namespaces[i].id; i++) - if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id)) - break; - t++; - sprintf(soap->tmpbuf, "<%s xmlns=\"%s\">", t, soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS); - } - else - { t = tag; - sprintf(soap->tmpbuf, "<%s>", tag); - } - if (soap_send(soap, soap->tmpbuf)) - return soap->error; - } - if (p) - { s = *p; - while ((c = *s++)) - if (soap_pututf8(soap, (unsigned char)c)) - return soap->error; - } - if (t) - { sprintf(soap->tmpbuf, "", t); - return soap_send(soap, soap->tmpbuf); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t ** -SOAP_FMAC2 -soap_inwliteral(struct soap *soap, const char *tag, wchar_t **p) -{ if (soap_element_begin_in(soap, tag)) - return NULL; - if (!p) - if (!(p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*)))) - return NULL; - if (soap->null) - *p = NULL; - else if (soap->body) - *p = soap_wstring_in(soap, 0); - else - *p = NULL; - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_value(struct soap *soap) -{ size_t i; - wchar c = 0; - char *s; - s = soap->tmpbuf; - for (i = 0; i < sizeof(soap->tmpbuf) - 1; i++) - { c = soap_get(soap); - if (c == TT || (int)c == EOF || soap_blank(c)) - break; - *s++ = (char)c; - } - if ((int)c == EOF || c == TT) - soap_unget(soap, c); - *s = '\0'; - return soap->tmpbuf; /* return non-null pointer */ -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getline(struct soap *soap, char *s, int len) -{ int i = len; - wchar c = 0; - for (;;) - { while (--i > 0) - { c = soap_getchar(soap); - if (c == '\r' || c == '\n' || (int)c == EOF) - break; - *s++ = (char)c; - } - *s = '\0'; - while (c != '\n' && (int)c != EOF) - c = soap_getchar(soap); - if ((int)c == EOF) - return SOAP_EOF; - if (i+1 == len) /* empty line: end of HTTP header */ - break; - c = soap_unget(soap, soap_getchar(soap)); - if (c != ' ' && c != '\t') /* HTTP line continuation? */ - break; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static size_t -soap_begin_dime(struct soap *soap) -{ -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - { size_t count; - sprintf(soap->id, soap->dime_id_format, 0); - soap->dime_id = soap->id; - if (soap->local_namespaces) - { if (soap->local_namespaces[0].out) - soap->dime_type = (char*)soap->local_namespaces[0].out; - else - soap->dime_type = (char*)soap->local_namespaces[0].ns; - } - soap->dime_options = NULL; - count = soap->dime_size + 12 + ((soap->count+3)&(~3)) + ((strlen(soap->dime_id)+3)&(~3)) + ((strlen(soap->dime_type)+3)&(~3)); - soap->dime_size = soap->count; - if (soap->dime_count) - soap->dime_flags = SOAP_DIME_MB | SOAP_DIME_ABSURI; - else - soap->dime_flags = SOAP_DIME_MB | SOAP_DIME_ME | SOAP_DIME_ABSURI; - return count; - } -#endif - return soap->count; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static int -soap_putdimefield(struct soap *soap, const char *s, size_t n) -{ if (soap_send_raw(soap, s, n)) - return soap->error; - return soap_send_raw(soap, SOAP_STR_PADDING, -(long)n&3); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_dime_option(struct soap *soap, unsigned short type, const char *option) -{ size_t n; - char *s = NULL; - if (option) - { n = strlen(option); - s = (char*)soap_malloc(soap, n + 5); - if (s) - { s[0] = type >> 8; - s[1] = type & 0xFF; - s[2] = n >> 8; - s[3] = n & 0xFF; - strcpy(s + 4, option); - } - } - return s; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putdimehdr(struct soap *soap) -{ unsigned char tmp[12]; - size_t optlen = 0, idlen = 0, typelen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Put DIME header id='%s'\n", soap->dime_id?soap->dime_id:"")); - if (soap->dime_options) - optlen = (((unsigned char)soap->dime_options[2] << 8) | ((unsigned char)soap->dime_options[3])) + 4; - if (soap->dime_id) - idlen = strlen(soap->dime_id); - if (soap->dime_type) - typelen = strlen(soap->dime_type); - tmp[0] = SOAP_DIME_VERSION | (soap->dime_flags & 0x7); - tmp[1] = soap->dime_flags & 0xF0; - tmp[2] = optlen >> 8; - tmp[3] = optlen & 0xFF; - tmp[4] = idlen >> 8; - tmp[5] = idlen & 0xFF; - tmp[6] = typelen >> 8; - tmp[7] = typelen & 0xFF; - tmp[8] = soap->dime_size >> 24; - tmp[9] = (soap->dime_size >> 16) & 0xFF; - tmp[10] = (soap->dime_size >> 8) & 0xFF; - tmp[11] = soap->dime_size & 0xFF; - if (soap_send_raw(soap, (char*)tmp, 12) - || soap_putdimefield(soap, soap->dime_options, optlen) - || soap_putdimefield(soap, soap->dime_id, idlen) - || soap_putdimefield(soap, soap->dime_type, typelen)) - return soap->error; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putdime(struct soap *soap, int i, char *id, char *type, char *options, void *ptr, size_t size) -{ void *h; - if (id) - soap->dime_id = id; - else - { sprintf(soap->id, soap->dime_id_format, i); - soap->dime_id = soap->id; - } - soap->dime_type = type; - soap->dime_options = options; - soap->dime_size = size; - soap->dime_flags = SOAP_DIME_VERSION | SOAP_DIME_MEDIA; - if (soap->fdimereadopen && ((h = soap->fdimereadopen(soap, (void*)ptr, soap->dime_id, type, options)) || soap->error)) - { size_t n; - if (!h) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadopen failed\n")); - return soap->error; - } - if (!size && ((soap->mode & SOAP_ENC_XML) || (soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_IO) == SOAP_IO_STORE)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked streaming DIME\n")); - n = sizeof(soap->tmpbuf); - do - { size = soap->fdimeread(soap, h, soap->tmpbuf, n); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread returned %lu bytes\n", (unsigned long)size)); - if (size == n) - soap->dime_flags |= SOAP_DIME_CF; - else - { soap->dime_flags &= ~SOAP_DIME_CF; - if (--soap->dime_count == 0) - soap->dime_flags |= SOAP_DIME_ME; - } - soap->dime_size = size; - if (soap_putdimehdr(soap) - || soap_send_raw(soap, soap->tmpbuf, size) - || soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime_size&3)) - break; - if (soap->dime_id) - { soap->dime_flags &= ~(SOAP_DIME_MB | SOAP_DIME_MEDIA); - soap->dime_id = NULL; - soap->dime_type = NULL; - soap->dime_options = NULL; - } - } while (size >= n); - } - else - { if (--soap->dime_count == 0) - soap->dime_flags |= SOAP_DIME_ME; - if (soap_putdimehdr(soap)) - return soap->error; - do - { if (size < sizeof(soap->tmpbuf)) - n = size; - else - n = sizeof(soap->tmpbuf); - if (!(n = soap->fdimeread(soap, h, soap->tmpbuf, n))) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread failed: insufficient data (%lu bytes remaining from %lu bytes)\n", (unsigned long)size, (unsigned long)soap->dime_size)); - soap->error = SOAP_EOF; - break; - } - if (soap_send_raw(soap, soap->tmpbuf, n)) - break; - size -= n; - } while (size); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n")); - soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime_size&3); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n")); - if (soap->fdimereadclose) - soap->fdimereadclose(soap, h); - return soap->error; - } - if (--soap->dime_count == 0) - soap->dime_flags |= SOAP_DIME_ME; - if (soap_putdimehdr(soap)) - return soap->error; - return soap_putdimefield(soap, (char*)ptr, size); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static char * -soap_getdimefield(struct soap *soap, size_t n) -{ register wchar c; - register int i; - register char *s; - char *p = NULL; - if (n) - { p = (char*)soap_malloc(soap, n + 1); - if (p) - { s = p; - for (i = n; i > 0; i--) - { if ((int)(c = soap_get1(soap)) == EOF) - { soap->error = SOAP_EOF; - return NULL; - } - *s++ = (char)c; - } - *s = '\0'; - if ((soap->error = soap_move(soap, -(long)n&3))) - return NULL; - } - else - soap->error = SOAP_EOM; - } - return p; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getdimehdr(struct soap *soap) -{ register wchar c; - register char *s; - register int i; - unsigned char tmp[12]; - size_t optlen, idlen, typelen; - if (!(soap->mode & SOAP_ENC_DIME)) - return soap->error = SOAP_EOD; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME header\n")); - if (soap->dime_buflen || soap->dime_chunksize) - { if (soap_move(soap, (long)(soap->dime_size - soap_tell(soap)))) - return soap->error = SOAP_EOF; - soap_unget(soap, soap_getchar(soap)); /* skip padding and get hdr */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... From chunked\n")); - return SOAP_OK; - } - s = (char*)tmp; - for (i = 12; i > 0; i--) - { if ((int)(c = soap_getchar(soap)) == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - if ((tmp[0] & 0xF8) != SOAP_DIME_VERSION) - return soap->error = SOAP_DIME_MISMATCH; - soap->dime_flags = (tmp[0] & 0x7) | (tmp[1] & 0xF0); - optlen = (tmp[2] << 8) | tmp[3]; - idlen = (tmp[4] << 8) | tmp[5]; - typelen = (tmp[6] << 8) | tmp[7]; - soap->dime_size = (tmp[8] << 24) | (tmp[9] << 16) | (tmp[10] << 8) | tmp[11]; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME size=%u flags=0x%X\n", (unsigned int)soap->dime_size, soap->dime_flags)); - if (!(soap->dime_options = soap_getdimefield(soap, optlen)) && soap->error) - return soap->error; - if (!(soap->dime_id = soap_getdimefield(soap, idlen)) && soap->error) - return soap->error; - if (!(soap->dime_type = soap_getdimefield(soap, typelen)) && soap->error) - return soap->error; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME id=%s, type=%s, options=%s\n", soap->dime_id?soap->dime_id:"", soap->dime_type?soap->dime_type:"", soap->dime_options?soap->dime_options+4:"")); - if (soap->dime_flags & SOAP_DIME_ME) - soap->mode &= ~SOAP_ENC_DIME; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getdime(struct soap *soap) -{ if (soap_getdimehdr(soap)) - return soap->error; - if (soap->fdimewriteopen && ((soap->dime_ptr = (char*)soap->fdimewriteopen(soap, soap->dime_id, soap->dime_type, soap->dime_options)) || soap->error)) - { char *id, *type, *options; - size_t size, n; - if (!soap->dime_ptr) - return soap->error; - id = soap->dime_id; - type = soap->dime_type; - options = soap->dime_options; - for (;;) - { size = soap->dime_size; - for (;;) - { n = soap->buflen - soap->bufidx; - if (size < n) - n = size; - if ((soap->error = soap->fdimewrite(soap, (void*)soap->dime_ptr, soap->buf + soap->bufidx, n))) - break; - size -= n; - if (!size) - { soap->bufidx += n; - break; - } - if (soap_recv(soap)) - { soap->error = SOAP_EOF; - goto end; - } - } - if (soap_move(soap, -(long)soap->dime_size&3)) - { soap->error = SOAP_EOF; - break; - } - if (!(soap->dime_flags & SOAP_DIME_CF)) - break; - if (soap_getdimehdr(soap)) - break; - } -end: - if (soap->fdimewriteclose) - soap->fdimewriteclose(soap, (void*)soap->dime_ptr); - soap->dime_size = 0; - soap->dime_id = id; - soap->dime_type = type; - soap->dime_options = options; - } - else if (soap->dime_flags & SOAP_DIME_CF) - { char *id, *type, *options; - register wchar c; - register char *s; - register int i; - id = soap->dime_id; - type = soap->dime_type; - options = soap->dime_options; - if (soap_new_block(soap)) - return SOAP_EOM; - for (;;) - { s = (char*)soap_push_block(soap, soap->dime_size); - if (!s) - return soap->error = SOAP_EOM; - for (i = soap->dime_size; i > 0; i--) - { if ((int)(c = soap_get1(soap)) == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - if (soap_move(soap, -(long)soap->dime_size&3)) - return soap->error = SOAP_EOF; - if (!(soap->dime_flags & SOAP_DIME_CF)) - break; - if (soap_getdimehdr(soap)) - return soap->error; - } - soap->dime_size = soap->blist->size++; /* allocate one more for '\0' */ - if (!(soap->dime_ptr = soap_save_block(soap, NULL))) - return soap->error; - soap->dime_ptr[soap->dime_size] = '\0'; /* make 0-terminated to enable string-based attachments */ - soap->dime_id = id; - soap->dime_type = type; - soap->dime_options = options; - } - else - soap->dime_ptr = soap_getdimefield(soap, soap->dime_size); - return soap->error; -} -#endif -#endif - -/******************************************************************************/ - -#ifdef WITH_COOKIES -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_encode_cookie(const char *s, char *t, int len) -{ register int c; - register int n = len; - while ((c = *s++) && --n > 0) - { if (c > ' ' && c < 128 && c != ';' && c != ',') - *t++ = c; - else if (n > 2) - { *t++ = '%'; - *t++ = (c >> 4) + (c > 159 ? '7' : '0'); - c &= 0xF; - *t++ = c + (c > 9 ? '7' : '0'); - n -= 2; - } - else - break; - } - *t = '\0'; - return len - n; -} - -/******************************************************************************/ -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_decode_cookie(char *buf, int len, const char *val) -{ const char *s; - char *t; - for (s = val; *s; s++) - if (*s != ' ' && *s != '=') - break; - if (*s == '"') - { t = buf; - s++; - while (*s && *s != '"' && --len) - *t++ = *s++; - *t = '\0'; - do s++; - while (*s && *s != ';' && *s != '='); - } - else - { t = buf; - while (*s && *s != ';' && *s != '=' && --len) - switch (*s) - { case ' ': - s++; - break; - case '%': - *t++ = ((s[1] >= 'A' ? (s[1] & 0x7) + 9 : s[1] - '0') << 4) - + (s[2] >= 'A' ? (s[2] & 0x7) + 9 : s[2] - '0'); - s += 3; - break; - default: - *t++ = *s++; - } - *t = '\0'; - } - return s; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_cookie(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - size_t n; - if (!domain) - domain = soap->cookie_domain; - if (!path) - path = soap->cookie_path; - if (*path == '/') - path++; - n = strlen(path); - for (p = soap->cookies; p; p = p->next) - if (!strcmp(p->name, name) - && domain - && p->domain - && !strcmp(p->domain, domain) - && !strncmp(p->path, path, n)) - break; - return p; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_set_cookie(struct soap *soap, const char *name, const char *value, const char *domain, const char *path) -{ struct soap_cookie **p, *q; - int n; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set cookie: %s=%s domain=%s path=%s\n", name, value?value:"", domain?domain:"", path?path:"")); - if (!domain) - domain = soap->cookie_domain; - if (!path) - path = soap->cookie_path; - if (!path) - { soap_set_receiver_error(soap, "Cookie path not set", NULL, SOAP_HTTP_ERROR); - return NULL; - } - if (*path == '/') - path++; - q = soap_cookie(soap, name, domain, path); - if (!q) - { if ((q = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - { if ((q->name = (char*)SOAP_MALLOC(strlen(name)+1))) - strcpy(q->name, name); - q->value = NULL; - q->domain = NULL; - q->path = NULL; - q->expire = -1; - q->version = 0; - q->secure = 0; - q->env = 0; - q->modified = 0; - for (p = &soap->cookies, n = soap->cookie_max; *p && n; p = &(*p)->next, n--) - if (!strcmp((*p)->name, name) && (*p)->path && strcmp((*p)->path, path) < 0) - break; - if (n) - { q->next = *p; - *p = q; - } - else - { SOAP_FREE(q->name); - SOAP_FREE(q); - q = NULL; - } - } - } - else - q->modified = 1; - if (q) - { if (q->value) - { SOAP_FREE(q->value); - q->value = NULL; - } - if (q->domain) - { SOAP_FREE(q->domain); - q->domain = NULL; - } - if (q->path) - { SOAP_FREE(q->path); - q->path = NULL; - } - if (value && *value && (q->value = (char*)SOAP_MALLOC(strlen(value)+1))) - strcpy(q->value, value); - if (domain && *domain && (q->domain = (char*)SOAP_MALLOC(strlen(domain)+1))) - strcpy(q->domain, domain); - if (path && *path && (q->path = (char*)SOAP_MALLOC(strlen(path)+1))) - strcpy(q->path, path); - q->session = 1; - } - return q; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_cookie(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie **p, *q; - if (!domain) - domain = soap->cookie_domain; - if (!domain) - { soap_set_receiver_error(soap, "Cookie domain not set", SOAP_STR_EOS, SOAP_HTTP_ERROR); - return; - } - if (!path) - path = soap->cookie_path; - if (!path) - { soap_set_receiver_error(soap, "Cookie path not set", SOAP_STR_EOS, SOAP_HTTP_ERROR); - return; - } - if (*path == '/') - path++; - for (p = &soap->cookies, q = *p; q; q = *p) - if (!strcmp(q->name, name) && !strcmp(q->domain, domain) && !strncmp(q->path, path, strlen(q->path))) - { if (q->value) - SOAP_FREE(q->value); - if (q->domain) - SOAP_FREE(q->domain); - if (q->path) - SOAP_FREE(q->path); - *p = q->next; - SOAP_FREE(q); - } - else - p = &q->next; -} - -/******************************************************************************/ -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_cookie_value(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - return p->value; - return NULL; -} - -/******************************************************************************/ -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_cookie_expire(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - return p->expire; - return -1; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_cookie_expire(struct soap *soap, const char *name, long expire, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->expire = expire; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->session = 1; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_clr_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->session = 0; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putsetcookies(struct soap *soap) -{ struct soap_cookie *p; - char *s, tmp[4096]; - const char *t; - for (p = soap->cookies; p; p = p->next) - if (p->modified || !p->env) - { s = tmp; - if (p->name) - s += soap_encode_cookie(p->name, s, tmp-s+4064); - if (p->value) - { *s++ = '='; - s += soap_encode_cookie(p->value, s, tmp-s+4064); - } - if (p->domain && (int)strlen(p->domain) < tmp-s+4064) - sprintf(s, ";Domain=%s", p->domain); - else if (soap->cookie_domain && (int)strlen(soap->cookie_domain) < tmp-s+4064) - sprintf(s, ";Domain=%s", soap->cookie_domain); - strcpy(s, ";Path=/"); - if (p->path) - t = p->path; - else - t = soap->cookie_path; - if (t) - { if (*t == '/') - t++; - if ((int)strlen(t) < tmp-s+4064) - strcat(s, t); - } - s += strlen(s); - if (p->version > 0) - { sprintf(s, ";Version=%u", p->version); - s += strlen(s); - } - if (p->expire >= 0) - { sprintf(s, ";Max-Age=%ld", p->expire); - s += strlen(s); - } - if (p->secure) - strcpy(s, ";Secure"); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set-Cookie: %s\n", tmp)); - if (soap->fposthdr(soap, "Set-Cookie", tmp)) - return soap->error; - } - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putcookies(struct soap *soap, const char *domain, const char *path, int secure) -{ struct soap_cookie **p, *q; - unsigned int version = 0; - time_t now = time(NULL); - char *s, tmp[4096]; - p = &soap->cookies; - while ((q = *p)) - { if (q->expire && now > q->expire) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie %s expired\n", q->name)); - SOAP_FREE(q->name); - if (q->value) - SOAP_FREE(q->value); - if (q->domain) - SOAP_FREE(q->domain); - if (q->path) - SOAP_FREE(q->path); - *p = q->next; - SOAP_FREE(q); - } - else if ((!q->domain || !strcmp(q->domain, domain)) - && (!q->path || !strncmp(q->path, path, strlen(q->path))) - && (!q->secure || secure)) - { s = tmp; - if (q->version != version) - { sprintf(s, "$Version=%u;", q->version); - version = q->version; - } - if (q->name) - s += soap_encode_cookie(q->name, s, tmp-s+4080); - if (q->value) - { *s++ = '='; - s += soap_encode_cookie(q->value, s, tmp-s+4080); - } - if (q->path && (int)strlen(q->path) < tmp-s+4080) - { sprintf(s, ";$Path=/%s", q->path); - s += strlen(s); - } - if (q->domain && (int)strlen(q->domain) < tmp-s+4080) - sprintf(s, ";$Domain=%s", q->domain); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie: %s\n", tmp)); - if (soap->fposthdr(soap, "Cookie", tmp)) - return soap->error; - p = &q->next; - } - else - p = &q->next; - } - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_getcookies(struct soap *soap, const char *val) -{ struct soap_cookie *p = NULL, *q; - const char *s; - char *t, tmp[4096]; /* cookie size is up to 4096 bytes [RFC2109] */ - char *domain = NULL; - char *path = NULL; - unsigned int version = 0; - time_t now = time(NULL); - if (!val) - return; - s = val; - while (*s) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (!soap_tag_cmp(tmp, "$Version")) - { if ((s = soap_decode_cookie(tmp, sizeof(tmp), s))) - { if (p) - p->version = (int)atol(tmp); - else - version = (int)atol(tmp); - } - } - else if (!soap_tag_cmp(tmp, "$Path")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (*tmp) - { if ((t = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(t, tmp); - } - else - t = NULL; - if (p) - { if (p->path) - SOAP_FREE(p->path); - p->path = t; - } - else - { if (path) - SOAP_FREE(path); - path = t; - } - } - else if (!soap_tag_cmp(tmp, "$Domain")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (*tmp) - { if ((t = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(t, tmp); - } - else - t = NULL; - if (p) - { if (p->domain) - SOAP_FREE(p->domain); - p->domain = t; - } - else - { if (domain) - SOAP_FREE(domain); - domain = t; - } - } - else if (p && !soap_tag_cmp(tmp, "Path")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (p->path) - SOAP_FREE(p->path); - if (*tmp) - { if ((p->path = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(p->path, tmp); - } - else - p->path = NULL; - } - else if (p && !soap_tag_cmp(tmp, "Domain")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (p->domain) - SOAP_FREE(p->domain); - if (*tmp) - { if ((p->domain = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(p->domain, tmp); - } - else - p->domain = NULL; - } - else if (p && !soap_tag_cmp(tmp, "Version")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - p->version = (unsigned int)atol(tmp); - } - else if (p && !soap_tag_cmp(tmp, "Max-Age")) - { s = soap_decode_cookie(tmp, sizeof(tmp), s); - p->expire = now + atol(tmp); - } - else if (p && !soap_tag_cmp(tmp, "Expires")) - { struct tm T; - char a[3]; - static const char mns[] = "anebarprayunulugepctovec"; - s = soap_decode_cookie(tmp, sizeof(tmp), s); - memset(&T, 0, sizeof(struct tm)); - a[0] = tmp[4]; - a[1] = tmp[5]; - a[2] = '\0'; - T.tm_mday = (int)atol(a); - a[0] = tmp[8]; - a[1] = tmp[9]; - T.tm_mon = (strstr(mns, a) - mns) / 2; - a[0] = tmp[11]; - a[1] = tmp[12]; - T.tm_year = 100 + (int)atol(a); - a[0] = tmp[13]; - a[1] = tmp[14]; - T.tm_hour = (int)atol(a); - a[0] = tmp[16]; - a[1] = tmp[17]; - T.tm_min = (int)atol(a); - a[0] = tmp[19]; - a[1] = tmp[20]; - T.tm_sec = (int)atol(a); - p->expire = soap_timegm(&T); - } - else if (p && !soap_tag_cmp(tmp, "Secure")) - p->secure = 1; - else - { if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"", p->domain?p->domain:"", p->path?p->path:"", p->expire, p->secure)); - if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) - { q->version = p->version; - q->expire = p->expire; - q->secure = p->secure; - q->env = 1; - } - if (p->name) - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } - if ((p = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - { p->name = (char*)SOAP_MALLOC(strlen(tmp)+1); - strcpy(p->name, tmp); - s = soap_decode_cookie(tmp, sizeof(tmp), s); - if (*tmp) - { p->value = (char*)SOAP_MALLOC(strlen(tmp)+1); - strcpy(p->value, tmp); - } - else - p->value = NULL; - p->domain = domain; - p->path = path; - p->expire = 0; - p->secure = 0; - p->version = version; - } - } - if (*s == ';') - s++; - } - if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"", p->domain?p->domain:"", p->path?p->path:"", p->expire, p->secure)); - if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) - { q->version = p->version; - q->expire = p->expire; - q->secure = p->secure; - } - if (p->name) - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } - if (domain) - SOAP_FREE(domain); - if (path) - SOAP_FREE(path); -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getenv_cookies(struct soap *soap) -{ struct soap_cookie *p; - const char *s; - char key[4096], val[4096]; /* cookie size is up to 4096 bytes [RFC2109] */ - if (!(s = getenv("HTTP_COOKIE"))) - return SOAP_ERR; - do - { s = soap_decode_cookie(key, sizeof(key), s); - s = soap_decode_cookie(val, sizeof(val), s); - p = soap_set_cookie(soap, key, val, NULL, NULL); - if (p) - p->env = 1; - if (*s == ';') - s++; - } while (*s); - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_copy_cookies(struct soap *soap) -{ struct soap_cookie *p, **q, *r; - q = &r; - for (p = soap->cookies; p; p = p->next) - { if (!(*q = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - return r; - **q = *p; - if (p->name) - { if (((*q)->name = (char*)SOAP_MALLOC(strlen(p->name)+1))) - strcpy((*q)->name, p->name); - } - if (p->value) - { if (((*q)->value = (char*)SOAP_MALLOC(strlen(p->value)+1))) - strcpy((*q)->value, p->value); - } - if (p->domain) - { if (((*q)->domain = (char*)SOAP_MALLOC(strlen(p->domain)+1))) - strcpy((*q)->domain, p->domain); - } - if (p->path) - { if (((*q)->path = (char*)SOAP_MALLOC(strlen(p->path)+1))) - strcpy((*q)->path, p->path); - } - q = &(*q)->next; - } - *q = NULL; - return r; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_free_cookies(struct soap *soap) -{ struct soap_cookie *p; - for (p = soap->cookies; p; p = soap->cookies) - { soap->cookies = p->next; - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } -} - -/******************************************************************************/ -#endif /* WITH_COOKIES */ - -/******************************************************************************/ -#ifdef WITH_GZIP -#ifndef PALM_2 -static int -soap_getgzipheader(struct soap *soap) -{ int i; - wchar c, f = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get gzip header\n")); - for (i = 0; i < 9; i++) - { if ((int)(c = soap_get1(soap) == EOF)) - return soap->error = SOAP_EOF; - if (i == 2) - f = c; - } - if (f & 0x04) /* FEXTRA */ - { for (i = soap_get1(soap) | (soap_get1(soap) << 8); i; i--) - if ((int)soap_get1(soap) == EOF) - return soap->error = SOAP_EOF; - } - if (f & 0x08) /* FNAME */ - do - c = soap_get1(soap); - while (c && (int)c != EOF); - if ((int)c != EOF && (f & 0x10)) /* FCOMMENT */ - do - c = soap_get1(soap); - while (c && (int)f != EOF); - if ((int)c != EOF && (f & 0x01)) /* FHCRC */ - { if ((int)(c = soap_get1(soap)) != EOF) - c = soap_get1(soap); - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_begin_recv(struct soap *soap) -{ wchar c; - soap_set_local_namespaces(soap); - soap->version = 0; /* don't assume we're parsing SOAP content by default */ - soap_free_iht(soap); - if ((soap->imode & SOAP_IO) == SOAP_IO_CHUNK) - soap->omode |= SOAP_IO_CHUNK; - soap->imode &= ~SOAP_IO; - soap->mode = soap->imode; - if (!soap->keep_alive) - { soap->buflen = 0; - soap->bufidx = 0; - } - if (!(soap->mode & SOAP_IO_KEEPALIVE)) - soap->keep_alive = 0; - soap->ahead = 0; - soap->peeked = 0; - soap->level = 0; - soap->part = SOAP_BEGIN; - soap->alloced = 0; - soap->count = 0; - soap->length = 0; - soap->cdata = 0; - *soap->endpoint = '\0'; - soap->userid = NULL; - soap->passwd = NULL; - soap->action = NULL; - soap->dime_chunksize = 0; - soap->dime_buflen = 0; -#ifdef WIN32 -#ifndef UNDER_CE -#ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket)) -#ifdef __BORLANDC__ - setmode((SOAP_SOCKET)soap->recvfd, O_BINARY); -#else - _setmode((SOAP_SOCKET)soap->recvfd, _O_BINARY); -#endif -#endif -#endif -#endif -#ifdef WITH_ZLIB - soap->mode &= ~SOAP_ENC_ZLIB; - soap->zlib_in = SOAP_ZLIB_NONE; - soap->zlib_out = SOAP_ZLIB_NONE; - soap->d_stream.next_in = Z_NULL; - soap->d_stream.avail_in = 0; - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - soap->z_ratio_in = 1.0; -#endif - c = soap_getchar(soap); - if ((c & 0xFFFC) == (SOAP_DIME_VERSION | SOAP_DIME_MB) && (soap_get0(soap) & 0xFFF0) == 0x20) - soap->mode |= SOAP_ENC_DIME; -#ifdef WITH_GZIP - else if (c == 0x1F) - { if (soap_getgzipheader(soap)) - return soap->error; - if (inflateInit2(&soap->d_stream, -MAX_WBITS) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - soap->mode |= SOAP_ENC_ZLIB; - soap->zlib_in = SOAP_ZLIB_GZIP; - soap->z_crc = crc32(0L, NULL, 0); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n")); - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - /* should not chunk over plain transport, so why bother to check? */ - /* if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) */ - /* soap->z_buflen = soap->bufidx; */ - /* else */ - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = soap->buflen - soap->bufidx; - soap->z_buflen = soap->buflen; - soap->buflen = soap->bufidx; - } -#endif - else - { if (c == 0xEF && !(soap->mode & SOAP_C_LATIN)) - { soap_unget(soap, c); - c = soap_getutf8(soap); - if (c == 0xFEFF) - c = soap_getchar(soap); - } - while (soap_blank(c)) - c = soap_getchar(soap); - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - soap_unget(soap, c); - if (c != '<' && !(soap->mode & (SOAP_ENC_DIME | SOAP_ENC_ZLIB))) - { soap->mode &= ~SOAP_IO; - if ((soap->error = soap->fparse(soap))) - { if (soap->error == 307) /* HTTP redirect */ - { soap_getline(soap, soap->endpoint, sizeof(soap->endpoint)); - soap->keep_alive = 0; /* force close when soap_closesock() */ - } - return soap->error; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { soap->chunkbuflen = soap->buflen; - soap->buflen = soap->bufidx; - soap->chunksize = 0; - } -#ifdef WITH_ZLIB - if (soap->zlib_in) - { /* fparse should not use soap_unget */ -#ifdef WITH_GZIP - c = soap_get1(soap); - if (c == 0x1F) - { if (soap_getgzipheader(soap)) - return soap->error; - if (inflateInit2(&soap->d_stream, -MAX_WBITS) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - soap->z_crc = crc32(0L, NULL, 0); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n")); - } - else - { soap_revget1(soap); -#else - { -#endif - if (inflateInit(&soap->d_stream) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate initialized\n")); - } - soap->mode |= SOAP_ENC_ZLIB; - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = soap->buflen - soap->bufidx; - soap->z_buflen = soap->buflen; - soap->buflen = soap->bufidx; - } -#endif - } -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - { if (soap_getdimehdr(soap)) - return soap->error; - if (soap->dime_flags & SOAP_DIME_CF) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked DIME SOAP message\n")); - soap->dime_chunksize = soap->dime_size; - if (soap->buflen - soap->bufidx >= soap->dime_chunksize) - { soap->dime_buflen = soap->buflen; - soap->buflen = soap->bufidx + soap->dime_chunksize; - } - else - soap->dime_chunksize -= soap->buflen - soap->bufidx; - } - soap->count = soap->buflen - soap->bufidx; - } -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_parse(struct soap *soap) -{ char header[SOAP_HDRLEN], *s; - unsigned short g = 0, k; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Waiting for response...\n")); - *soap->endpoint = '\0'; - soap->length = 0; - do - { if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf))) - return SOAP_EOF; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP status: %s\n", soap->msgbuf)); - for (;;) - { if (soap_getline(soap, header, SOAP_HDRLEN)) - return SOAP_EOF; - if (!*header) - break; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP header: %s\n", header)); - s = strchr(header, ':'); - if (s) - { *s = '\0'; - do s++; - while (*s && *s <= 32); - if ((soap->error = soap->fparsehdr(soap, header, s))) - return soap->error; - } - } - if ((s = strchr(soap->msgbuf, ' '))) - k = (unsigned short)soap_strtoul(s, NULL, 10); - else - k = 0; - } while (k == 100); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Finished HTTP header parsing\n")); - s = strstr(soap->msgbuf, "HTTP/"); - if (s && s[7] != '1') - { if (soap->keep_alive == 1) - soap->keep_alive = 0; - if (k == 0 && (soap->omode & SOAP_IO) == SOAP_IO_CHUNK) /* k == 0 for HTTP request */ - { soap->imode |= SOAP_IO_CHUNK; - soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_STORE; - } - } - if (soap->keep_alive < 0) - soap->keep_alive = 1; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Keep alive connection = %d\n", soap->keep_alive)); - if (s && (((g = !strncmp(soap->msgbuf, "GET ", 4))) || !strncmp(soap->msgbuf, "POST ", 5))) - { size_t m = strlen(soap->endpoint); - size_t n = m + (s - soap->msgbuf) - 5 - (!g); - if (n >= sizeof(soap->endpoint)) - n = sizeof(soap->endpoint) - 1; - strncpy(soap->path, soap->msgbuf + 4 + (!g), n - m); - soap->path[n - m] = '\0'; - strcat(soap->endpoint, soap->path); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Target endpoint='%s'\n", soap->endpoint)); - if (g) - { soap->error = soap->fget(soap); - if (soap->error == SOAP_OK) - soap->error = SOAP_STOP; /* prevents further processing */ - return soap->error; - } - return SOAP_OK; - } - if (k == 0 || (k >= 200 && k <= 299) || k == 400 || k == 500) - return SOAP_OK; - return soap_set_receiver_error(soap, "HTTP error", soap->msgbuf, k); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_parse_header(struct soap *soap, const char *key, const char *val) -{ if (!soap_tag_cmp(key, "Host")) - { -#ifdef WITH_OPENSSL - if (soap->imode & SOAP_ENC_SSL) - strcpy(soap->endpoint, "https://"); - else -#endif - strcpy(soap->endpoint, "http://"); - strncat(soap->endpoint, val, sizeof(soap->endpoint) - 8); - soap->endpoint[sizeof(soap->endpoint) - 1] = '\0'; - } - else if (!soap_tag_cmp(key, "Content-Type")) - { if (!soap_tag_cmp(val, "*application/dime*")) - soap->mode |= SOAP_ENC_DIME; - } - else if (!soap_tag_cmp(key, "Content-Length")) - soap->length = soap_strtoul(val, NULL, 10); - else if (!soap_tag_cmp(key, "Content-Encoding")) - { if (!soap_tag_cmp(val, "deflate*")) -#ifdef WITH_ZLIB - soap->zlib_in = SOAP_ZLIB_DEFLATE; -#else - return SOAP_ZLIB_ERROR; -#endif - else if (!soap_tag_cmp(val, "gzip*")) -#ifdef WITH_GZIP - soap->zlib_in = SOAP_ZLIB_GZIP; -#else - return SOAP_ZLIB_ERROR; -#endif - } -#ifdef WITH_ZLIB - else if (!soap_tag_cmp(key, "Accept-Encoding")) - { -#ifdef WITH_GZIP - if (strchr(val, '*') || !soap_tag_cmp(val, "*gzip*")) - soap->zlib_out = SOAP_ZLIB_GZIP; - else -#endif - if (strchr(val, '*') || !soap_tag_cmp(val, "*deflate*")) - soap->zlib_out = SOAP_ZLIB_DEFLATE; - else - soap->zlib_out = SOAP_ZLIB_NONE; - } -#endif - else if (!soap_tag_cmp(key, "Transfer-Encoding")) - { soap->mode &= ~SOAP_IO; - if (!soap_tag_cmp(val, "chunked*")) - soap->mode |= SOAP_IO_CHUNK; - } - else if (!soap_tag_cmp(key, "Connection")) - { if (!soap_tag_cmp(val, "keep-alive*")) - soap->keep_alive = -soap->keep_alive; - else if (!soap_tag_cmp(val, "close*")) - soap->keep_alive = 0; - } -#ifndef WITH_LEAN - else if (!soap_tag_cmp(key, "Authorization")) - { if (!soap_tag_cmp(val, "basic *")) - { size_t n; - char *s; - soap_base642s(soap, val + 6, soap->tmpbuf, sizeof(soap->tmpbuf) - 1, &n); - soap->tmpbuf[n] = '\0'; - if ((s = strchr(soap->tmpbuf, ':'))) - { *s = '\0'; - soap->userid = soap_strdup(soap, soap->tmpbuf); - soap->passwd = soap_strdup(soap, s + 1); - } - } - } -#endif - else if (!soap_tag_cmp(key, "SOAPAction")) - { if (val[0] && val[1]) - { soap->action = soap_strdup(soap, val + 1); - soap->action[strlen(soap->action) - 1] = '\0'; - } - } -/* [ Deal with .NET bug (invalid XML id-ref) */ - else if (!soap_tag_cmp(key, "Server")) - { if (!soap_tag_cmp(val, "Microsoft-IIS*")) - soap->dot_net_bug = 1; - } - else if (!soap_tag_cmp(key, "User-Agent")) - { if (!soap_tag_cmp(val, "*.NET CLR*") || !soap_tag_cmp(val, "*MS Web Services Client Protocol*")) - soap->dot_net_bug = 1; - } -/* ] */ -#ifdef WITH_COOKIES - else if (!soap_tag_cmp(key, "Cookie") || !soap_tag_cmp(key, "Set-Cookie")) - soap_getcookies(soap, val); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_begin_out(struct soap *soap) -{ soap->part = SOAP_IN_ENVELOPE; - return soap_element_begin_out(soap, "SOAP-ENV:Envelope", 0, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_end_out(struct soap *soap) -{ if (soap_element_end_out(soap, "SOAP-ENV:Envelope")) - return soap->error; - soap->part = SOAP_END_ENVELOPE; -#ifndef WITH_LEANER - if (!(soap->mode & SOAP_IO_LENGTH) && (soap->mode & SOAP_ENC_DIME)) - return soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->count&3); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_begin_in(struct soap *soap) -{ soap->part = SOAP_IN_ENVELOPE; - if (soap_element_begin_in(soap, "SOAP-ENV:Envelope")) - return soap->error = SOAP_VERSIONMISMATCH; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_end_in(struct soap *soap) -{ if (soap_element_end_in(soap, "SOAP-ENV:Envelope")) - return soap->error; - soap->part = SOAP_END_ENVELOPE; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_begin_out(struct soap *soap) -{ soap->part = SOAP_IN_BODY; - if (soap->version == 1) - soap->encoding = 1; - if (soap_element(soap, "SOAP-ENV:Body", 0, NULL)) - return soap->error; - if (soap_attribute(soap, "id", "_0")) - return soap->error; - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_end_out(struct soap *soap) -{ if (soap_element_end_out(soap, "SOAP-ENV:Body")) - return soap->error; - soap->part = SOAP_IN_BODY; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_begin_in(struct soap *soap) -{ soap->part = SOAP_IN_BODY; - return soap_element_begin_in(soap, "SOAP-ENV:Body"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_end_in(struct soap *soap) -{ if (soap_element_end_in(soap, "SOAP-ENV:Body")) - return soap->error; - soap->part = SOAP_END_BODY; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_header(struct soap *soap) -{ if (soap_getheader(soap) && soap->error == SOAP_TAG_MISMATCH) - soap->error = SOAP_OK; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_endpoint(struct soap *soap, const char *endpoint) -{ register const char *s; - register size_t i, n; - *soap->endpoint = '\0'; - *soap->host = '\0'; - *soap->path = '\0'; - soap->port = 80; - if (!endpoint || !*endpoint) - return; -#ifdef WITH_OPENSSL - if (!strncmp(endpoint, "https:", 6)) - soap->port = 443; -#endif - strncpy(soap->endpoint, endpoint, sizeof(soap->endpoint) - 1); - s = strchr(endpoint, ':'); - if (s && s[1] == '/' && s[2] == '/') - s += 3; - else - s = endpoint; - n = strlen(s); - if (n >= sizeof(soap->host)) - n = sizeof(soap->host) - 1; -/* WR[ */ -#ifdef WITH_IPV6 - if ('[' == s[0]) - { - s++; - for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (']' == s[i]) - { - s++; - break; - } - } - } - else - { - for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (s[i] == '/' || s[i] == ':') - break; - } - } -#else /* WITH_IPV6 */ -/* ]WR */ - for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (s[i] == '/' || s[i] == ':') - break; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - soap->host[i] = '\0'; - if (s[i] == ':') - { soap->port = (int)atol(s + i + 1); - for (i++; i < n; i++) - if (s[i] == '/') - break; - } - if (s[i]) - { strncpy(soap->path, s + i + 1, sizeof(soap->path)); - soap->path[sizeof(soap->path) - 1] = '\0'; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_connect(struct soap *soap, const char *endpoint, const char *action) -{ return soap_connect_command(soap, SOAP_POST, endpoint, action); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_connect_command(struct soap *soap, int http_command, const char *endpoint, const char *action) -{ char host[sizeof(soap->host)]; - int port; - size_t count; - strcpy(host, soap->host); /* save to compare */ - port = soap->port; /* save to compare */ - soap_set_endpoint(soap, endpoint); - if (action) - soap->action = soap_strdup(soap, action); - if (soap->fconnect) - { - if ((soap->error = soap->fconnect(soap, endpoint, soap->host, soap->port))) - return soap->error; - } - else if (*soap->host) - { soap->status = http_command; - if (!soap_valid_socket(soap->socket) || strcmp(soap->host, host) || soap->port != port) - { soap->keep_alive = 0; /* force close */ - soap_closesock(soap); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Connect to host='%s' path='%s' port=%d\n", soap->host, soap->path, soap->port)); - soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port); - if (soap->error) - return soap->error; - soap->keep_alive = ((soap->omode & SOAP_IO_KEEPALIVE) != 0); - } - else if (!soap->keep_alive || soap_poll(soap)) - { soap->keep_alive = 0; /* force close */ - soap_closesock(soap); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Reconnect to host='%s' path='%s' port=%d\n", soap->host, soap->path, soap->port)); - soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port); - if (soap->error) - return soap->error; - } - } - count = soap_begin_dime(soap); - if (soap_begin_send(soap)) - return soap->error; - if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML) && endpoint) - { unsigned int k = soap->mode; - soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB); - if ((k & SOAP_IO) != SOAP_IO_FLUSH) - soap->mode |= SOAP_IO_BUFFER; - if ((soap->error = soap->fpost(soap, endpoint, soap->host, soap->port, soap->path, action, count))) - return soap->error; - if ((k & SOAP_IO) == SOAP_IO_CHUNK) - { if (soap_flush(soap)) - return soap->error; - } - soap->mode = k; - } - if (http_command != SOAP_POST) - return soap_end_send(soap); -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - return soap_putdimehdr(soap); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2base64(struct soap *soap, const unsigned char *s, char *t, size_t n) -{ register size_t i; - register unsigned long m; - if (!t) - return SOAP_EOM; - t[0] = '\0'; - if (!s) - return SOAP_OK; - for (; n > 2; n -= 3, s += 3) - { m = ((unsigned long)((unsigned char*)s)[0] << 16) | ((unsigned long)((unsigned char*)s)[1] << 8) | (unsigned long)((unsigned char*)s)[2]; - for (i = 4; i > 0; m >>= 6) - t[--i] = soap_base64o[m & 0x3F]; - t += 4; - } - t[0] = '\0'; - if (n > 0) - { m = 0; - for (i = 0; i < n; i++) - m = (m << 8) | *s++; - for (; i < 3; i++) - m <<= 8; - for (i++; i > 0; m >>= 6) - t[--i] = soap_base64o[m & 0x3F]; - for (i = 3; i > n; i--) - t[i] = '='; - t[4] = '\0'; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_base642s(struct soap *soap, const char *s, char *t, size_t l, size_t *n) -{ register int i, j, c; - register unsigned long m; - char *p = t; - if (n) - *n = 0; - for (;;) - { for (i = 0; i < SOAP_BLKLEN; i++) - { m = 0; - j = 0; - while (j < 4) - { c = *s++; - if (c == '=' || !c) - { i *= 3; - switch (j) - { case 2: - *t++ = (char)((m >> 4) & 0xFF); - i++; - break; - case 3: - *t++ = (char)((m >> 10) & 0xFF); - *t++ = (char)((m >> 2) & 0xFF); - i += 2; - } - if (n) - *n += i; - return p; - } - c -= '+'; - if (c >= 0 && c <= 79) - { m = (m << 6) + soap_base64i[c]; - j++; - } - } - *t++ = (char)((m >> 16) & 0xFF); - *t++ = (char)((m >> 8) & 0xFF); - *t++ = (char)(m & 0xFF); - if (l < 3) - { if (n) - *n += i; - return p; - } - l -= 3; - } - if (n) - *n += 3 * SOAP_BLKLEN; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_puthttphdr(struct soap *soap, int status, size_t count) -{ const char *s; - if (status == SOAP_FILE) - s = soap->http_content; - else if (status == SOAP_HTML) - s = "text/html; charset=utf-8"; - else if (soap->mode & SOAP_ENC_DIME) - s = "application/dime"; - else if (soap->version == 2) - s = "application/soap+xml; charset=utf-8"; - else - s = "text/xml; charset=utf-8"; - soap->error = soap->fposthdr(soap, "Content-Type", s); - if (soap->error) - return soap->error; -#ifdef WITH_ZLIB - if (soap->omode & SOAP_ENC_ZLIB) -#ifdef WITH_GZIP - soap->error = soap->fposthdr(soap, "Content-Encoding", "gzip"); -#else - soap->error = soap->fposthdr(soap, "Content-Encoding", "deflate"); -#endif -#endif - if ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK) - soap->error = soap->fposthdr(soap, "Transfer-Encoding", "chunked"); - else if (count > 0) - { sprintf(soap->tmpbuf, "%lu", (unsigned long)count); - soap->error = soap->fposthdr(soap, "Content-Length", soap->tmpbuf); - } - if (soap->error) - return soap->error; - return soap->error = soap->fposthdr(soap, "Connection", soap->keep_alive ? "keep-alive" : "close"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_get(struct soap *soap) -{ return SOAP_GET_METHOD; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_post(struct soap *soap, const char *endpoint, const char *host, int port, const char *path, const char *action, size_t count) -{ const char *s; - if (soap->status == SOAP_GET) - { s = "GET"; - count = 0; - } - else - s = "POST"; -#ifndef PALM - if (!endpoint || (strncmp(endpoint, "http:", 5) && strncmp(endpoint, "https:", 6) && strncmp(endpoint, "httpg:", 6))) -#else - if (!endpoint || (strncmp(endpoint, "http:", 5) && strncmp(endpoint, "https:", 6) && strncmp(endpoint, "httpg:", 6)) && strncmp(endpoint, "_beam:", 6) && strncmp(endpoint, "_local:", 7) && strncmp(endpoint, "_btobex:", 8)) -#endif - return SOAP_OK; - if (soap->proxy_host) - sprintf(soap->tmpbuf, "%s %s HTTP/%s", s, endpoint, soap->http_version); - else - sprintf(soap->tmpbuf, "%s /%s HTTP/%s", s, path, soap->http_version); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return soap->error; - if (port != 80) - sprintf(soap->tmpbuf, "%s:%d", host, port); - else - strcpy(soap->tmpbuf, host); - if ((soap->error = soap->fposthdr(soap, "Host", soap->tmpbuf)) - || (soap->error = soap->fposthdr(soap, "User-Agent", "gSOAP/2.6")) - || (soap->error = soap_puthttphdr(soap, SOAP_OK, count))) - return soap->error; -#ifdef WITH_ZLIB -#ifdef WITH_GZIP - if ((soap->error = soap->fposthdr(soap, "Accept-Encoding", "gzip, deflate"))) -#else - if ((soap->error = soap->fposthdr(soap, "Accept-Encoding", "deflate"))) -#endif - return soap->error; -#endif -#ifndef WITH_LEAN - if (soap->userid && soap->passwd && strlen(soap->userid) + strlen(soap->passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->userid, soap->passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((soap->error = soap->fposthdr(soap, "Authorization", soap->tmpbuf))) - return soap->error; - } - if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((soap->error = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) - return soap->error; - } -#endif -#ifdef WITH_COOKIES -#ifdef WITH_OPENSSL - if (soap_putcookies(soap, host, path, soap->ssl != NULL)) - return soap->error; -#else - if (soap_putcookies(soap, host, path, 0)) - return soap->error; -#endif -#endif - if (action) - { sprintf(soap->tmpbuf, "\"%s\"", action); - if ((soap->error = soap->fposthdr(soap, "SOAPAction", soap->tmpbuf))) - return soap->error; - } - return soap->error = soap->fposthdr(soap, NULL, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_post_header(struct soap *soap, const char *key, const char *val) -{ if (key) - { if (soap_send(soap, key)) - return soap->error; - if (val && (soap_send(soap, ": ") || soap_send(soap, val))) - return soap->error; - } - return soap_send(soap, "\r\n"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_response(struct soap *soap, int status, size_t count) -{ -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - { - httpOutputEnable(soap->rpmreqid); - } -#endif /* WMW_RPM_IO */ -/* ]WR */ - if (!status || status == SOAP_HTML || status == SOAP_FILE) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "OK 200\n")); -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ -#else -/* ]WR */ - if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */ -/* WR[ */ -#endif /* WMW_RPM_IO */ -/* ]WR */ - { sprintf(soap->tmpbuf, "HTTP/%s 200 OK", soap->http_version); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return soap->error; - } - else if ((soap->error = soap->fposthdr(soap, "Status", "200 OK"))) - return soap->error; - } - else if (status > 200 && status < 600) - { sprintf(soap->tmpbuf, "HTTP/%s %d %s", soap->http_version, status, http_error(soap, status)); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return soap->error; - if (status == 401) - if ((soap->error = soap->fposthdr(soap, "WWW-Authenticate", "Basic realm=\"gSOAP Service\""))) - return soap->error; - } - else - { const char *s = *soap_faultcode(soap); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error\n")); - if (soap->version == 2 && !strcmp(s, "SOAP-ENV:Sender")) - s = "400 Bad Request"; - else - s = "500 Internal Server Error"; -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ -#else -/* ]WR */ - if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */ -/* WR[ */ -#endif /* WMW_RPM_IO */ -/* ]WR */ - { sprintf(soap->tmpbuf, "HTTP/%s %s", soap->http_version, s); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return soap->error; - } - else if ((soap->error = soap->fposthdr(soap, "Status", s))) - return soap->error; - } - if ((soap->error = soap->fposthdr(soap, "Server", "gSOAP/2.6")) - || (soap->error = soap_puthttphdr(soap, status, count))) - return soap->error; -#ifdef WITH_COOKIES - if (soap_putsetcookies(soap)) - return soap->error; -#endif - return soap->error = soap->fposthdr(soap, NULL, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_response(struct soap *soap, int status) -{ register size_t count; - if (!(soap->omode & (SOAP_ENC_XML | SOAP_IO_STORE /* this tests for chunking too */)) - && (status == SOAP_HTML || status == SOAP_FILE)) - { soap->omode &= ~SOAP_IO; - soap->omode |= SOAP_IO_STORE; - } - soap->status = status; - count = soap_begin_dime(soap); - if (soap_begin_send(soap)) - return soap->error; - if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML)) - { register int n = soap->mode; - soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB); - if ((n & SOAP_IO) != SOAP_IO_FLUSH) - soap->mode |= SOAP_IO_BUFFER; - if ((soap->error = soap->fresponse(soap, status, count))) - return soap->error; - if ((n & SOAP_IO) == SOAP_IO_CHUNK) - { if (soap_flush(soap)) - return soap->error; - } - soap->mode = n; - } -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - return soap_putdimehdr(soap); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_fault(struct soap *soap) -{ const char **c = soap_faultcode(soap); - const char **s = soap_faultstring(soap); - if (!*c) - { if (soap->version == 2) - *c = "SOAP-ENV:Sender"; - else - *c = "SOAP-ENV:Client"; - } - if (*s) - return; - switch (soap->error) - { case SOAP_CLI_FAULT: - *s = "Client fault"; - break; - case SOAP_SVR_FAULT: - *s = "Server fault"; - break; - case SOAP_TAG_MISMATCH: - sprintf(soap->msgbuf, "Tag mismatch: element '%s' does not correspond to expected element", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_TYPE: - sprintf(soap->msgbuf, "Data type '%s' mismatch in element '%s'", soap->type, soap->tag); - *s = soap->msgbuf; - break; - case SOAP_SYNTAX_ERROR: - *s = "XML syntax error"; - break; - case SOAP_NO_TAG: - *s = "No XML element tag found"; - break; - case SOAP_MUSTUNDERSTAND: - *c = "SOAP-ENV:MustUnderstand"; - sprintf(soap->msgbuf, "The data in element '%s' must be understood but cannot be handled", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_VERSIONMISMATCH: - *c = "SOAP-ENV:VersionMismatch"; - *s = "SOAP version mismatch or invalid SOAP message"; - break; - case SOAP_DATAENCODINGUNKNOWN: - *c = "SOAP-ENV:DataEncodingUnknown"; - *s = "Unsupported SOAP data encoding"; - break; - case SOAP_DIME_MISMATCH: - *s = "DIME version mismatch"; - break; - case SOAP_NAMESPACE: - sprintf(soap->msgbuf, "Namespace URI mismatch in element '%s'", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_OBJ_MISMATCH: - *s = "Object mismatch"; - break; - case SOAP_FATAL_ERROR: - *s = "Fatal error"; - break; - case SOAP_NO_METHOD: - sprintf(soap->msgbuf, "Method '%s' not implemented", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_GET_METHOD: - *s = "HTTP GET method not implemented"; - break; - case SOAP_EOM: - *s = "Out of memory"; - break; - case SOAP_IOB: - *s = "Array index out of bounds"; - break; - case SOAP_NULL: - sprintf(soap->msgbuf, "Cannot create nilable object for type '%s' in element '%s'", soap->type, soap->tag); - *s = soap->msgbuf; - break; - case SOAP_MULTI_ID: - *s = "Non-unique id attribute"; - break; - case SOAP_MISSING_ID: - *s = "Missing id: referenced data is missing or had to be ignored"; - break; - case SOAP_HREF: - *s = "Invalid XML: object reference with href attribute is incompatible with actual object referred to"; - break; - case SOAP_FAULT: - break; - case SOAP_TCP_ERROR: - *s = tcp_error(soap); - break; - case SOAP_HTTP_ERROR: - *s = "HTTP error"; - break; - case SOAP_SSL_ERROR: - *s = "SSL error"; - break; - case SOAP_PLUGIN_ERROR: - *s = "Plugin registry error"; - break; - case SOAP_DIME_ERROR: - *s = "DIME error"; - break; - case SOAP_ZLIB_ERROR: -#ifdef WITH_ZLIB - sprintf(soap->msgbuf, "Zlib/gzip error: '%s'", soap->d_stream.msg?soap->d_stream.msg:""); - *s = soap->msgbuf; -#else - *s = "Zlib not installed for required message (de)compression"; -#endif - break; - case SOAP_EOD: - *s = "End of DIME error"; - break; - case SOAP_REQUIRED: - *s = "Validation failure: XML attribute required"; - break; - case SOAP_OCCURS: - *s = "Validation failure: XML element occurs count"; - break; - case SOAP_EOF: - sprintf(soap->msgbuf, "End of file or no input: '%s'", soap_strerror(soap)); - *s = soap->msgbuf; - break; - default: - if (soap->error > 200 && soap->error < 600) - { sprintf(soap->msgbuf, "HTTP Error: '%s'", http_error(soap, soap->error)); - *s = soap->msgbuf; - } - else - *s = "Unknown error code"; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send_fault(struct soap *soap) -{ register int status = soap->error; - if (status == SOAP_STOP) - return status; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Sending back fault struct for error code %d\n", soap->error)); - soap->keep_alive = 0; /* to terminate connection */ - soap_set_fault(soap); - if ((status != SOAP_EOF || (!soap->recv_timeout && !soap->send_timeout)) && soap_poll(soap) == SOAP_OK) - { soap->error = SOAP_OK; - soap_serializeheader(soap); - soap_serializefault(soap); - soap_begin_count(soap); - if (soap->mode & SOAP_IO_LENGTH) - { soap_envelope_begin_out(soap); - soap_putheader(soap); - soap_body_begin_out(soap); - soap_putfault(soap); - soap_body_end_out(soap); - soap_envelope_end_out(soap); - } - if (soap_response(soap, status) - || soap_envelope_begin_out(soap) - || soap_putheader(soap) - || soap_body_begin_out(soap) - || soap_putfault(soap) - || soap_body_end_out(soap) - || soap_envelope_end_out(soap)) - return soap_closesock(soap); - soap_end_send(soap); - } - soap_closesock(soap); - return soap->error = status; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_fault(struct soap *soap) -{ register int status = soap->error; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Receiving SOAP Fault\n")); - soap->error = SOAP_OK; - if (soap_getfault(soap)) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Error: soap_get_soapfault() failed. Is this a SOAP message at all?\n")); - *soap_faultcode(soap) = (soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client"); - soap->error = status; - soap_set_fault(soap); - } - else - { register const char *s = *soap_faultcode(soap); - if (!soap_match_tag(soap, s, "SOAP-ENV:Server") || !soap_match_tag(soap, s, "SOAP-ENV:Receiver")) - status = SOAP_SVR_FAULT; - else if (!soap_match_tag(soap, s, "SOAP-ENV:Client") || !soap_match_tag(soap, s, "SOAP-ENV:Sender")) - status = SOAP_CLI_FAULT; - else if (!soap_match_tag(soap, s, "SOAP-ENV:MustUnderstand")) - status = SOAP_MUSTUNDERSTAND; - else if (!soap_match_tag(soap, s, "SOAP-ENV:VersionMismatch")) - status = SOAP_VERSIONMISMATCH; - else - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Fault code %s\n", s)); - status = SOAP_FAULT; - } - if (soap_body_end_in(soap) - || soap_envelope_end_in(soap) - || soap_end_recv(soap)) - return soap_closesock(soap); - soap->error = status; - } - return soap_closesock(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -soap_strerror(struct soap *soap) -{ int err = soap->errnum; - if (!err) - err = soap_errno; - if (err) - { -#ifndef UNDER_CE - return strerror(err); -#else - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, 0, (LPTSTR)&soap->werrorstr, 256, NULL); - wcstombs(soap->errorstr, soap->werrorstr, 256); - return soap->errorstr; -#endif - } - return "Operation interrupted or timed out"; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_set_error(struct soap *soap, const char *faultcode, const char *faultstring, const char *faultdetail, int soaperror) -{ *soap_faultcode(soap) = faultcode; - *soap_faultstring(soap) = faultstring; - if (faultdetail && *faultdetail) - { register const char **s = soap_faultdetail(soap); - if (s) - *s = faultdetail; - } - return soap->error = soaperror; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_sender_error(struct soap *soap, const char *faultstring, const char *faultdetail, int soaperror) -{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", faultstring, faultdetail, soaperror); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_receiver_error(struct soap *soap, const char *faultstring, const char *faultdetail, int soaperror) -{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", faultstring, faultdetail, soaperror); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_copy_fault(struct soap *soap, const char *faultcode, const char *faultstring, const char *faultdetail) -{ char *s = NULL, *t = NULL; - if (faultstring) - s = soap_strdup(soap, faultstring); - if (faultdetail) - t = soap_strdup(soap, faultdetail); - return soap_set_error(soap, faultcode, s, t, SOAP_FAULT); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_sender_fault(struct soap *soap, const char *faultstring, const char *faultdetail) -{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", faultstring, faultdetail); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_receiver_fault(struct soap *soap, const char *faultstring, const char *faultdetail) -{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", faultstring, faultdetail); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_print_fault(struct soap *soap, FILE *fd) -{ if (soap->error) - { const char **s; - if (!*soap_faultcode(soap)) - soap_set_fault(soap); - fprintf(fd, "SOAP FAULT: %s\n\"%s\"\n", *soap_faultcode(soap), *soap_faultstring(soap)); - s = soap_faultdetail(soap); - if (s && *s) - fprintf(fd, "Detail: %s\n", *s); - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_print_fault_location(struct soap *soap, FILE *fd) -{ -#ifndef WITH_LEAN - int c; - if (soap->error && soap->buflen > 0) - { if (soap->bufidx == 0) - soap->bufidx = 1; - c = soap->buf[soap->bufidx - 1]; - soap->buf[soap->bufidx - 1] = '\0'; - soap->buf[soap->buflen - 1] = '\0'; - if (soap->bufidx < soap->buflen) - fprintf(fd, "%s%c\n** HERE **\n%s\n", soap->buf, c, soap->buf + soap->bufidx); - else - fprintf(fd, "%s%c\n** HERE **\n", soap->buf, c); - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_register_plugin_arg(struct soap *soap, int (*fcreate)(struct soap*, struct soap_plugin*, void*), void *arg) -{ register struct soap_plugin *p; - register int r; - if (!(p = (struct soap_plugin*)SOAP_MALLOC(sizeof(struct soap_plugin)))) - return soap->error = SOAP_EOM; - p->id = NULL; - p->data = NULL; - p->fcopy = NULL; - p->fdelete = NULL; - r = fcreate(soap, p, arg); - if (!r && p->fdelete) - { p->next = soap->plugins; - soap->plugins = p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Registered '%s' plugin\n", p->id)); - return SOAP_OK; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not register plugin '%s': plugin returned error %d (or fdelete callback not set)\n", p->id?p->id:"?", r)); - SOAP_FREE(p); - return r; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void * -fplugin(struct soap *soap, const char *id) -{ register struct soap_plugin *p; - for (p = soap->plugins; p; p = p->next) - if (p->id == id || !strcmp(p->id, id)) - return p->data; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void * -SOAP_FMAC2 -soap_lookup_plugin(struct soap *soap, const char *id) -{ return soap->fplugin(soap, id); -} -#endif - -/******************************************************************************/ -#ifdef __cplusplus -} -#endif - diff --git a/org.glite.lb.server/examples/stdsoap2_2.7.0c.c b/org.glite.lb.server/examples/stdsoap2_2.7.0c.c deleted file mode 100644 index 2f97766..0000000 --- a/org.glite.lb.server/examples/stdsoap2_2.7.0c.c +++ /dev/null @@ -1,11629 +0,0 @@ -/* - -stdsoap2.c[pp] 2.7.0c - -Runtime environment. - -gSOAP XML Web services tools -Copyright (C) 2000-2004, Robert van Engelen, Genivia, Inc., All Rights Reserved. - -Contributors: - -Wind River Systems, Inc., for the following additions (marked WR[...]): - - vxWorks compatible - - Support for IPv6. - --------------------------------------------------------------------------------- -gSOAP public license. - -The contents of this file are subject to the gSOAP Public License Version 1.3 -(the "License"); you may not use this file except in compliance with the -License. You may obtain a copy of the License at -http://www.cs.fsu.edu/~engelen/soaplicense.html -Software distributed under the License is distributed on an "AS IS" basis, -WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -for the specific language governing rights and limitations under the License. - -The Initial Developer of the Original Code is Robert A. van Engelen. -Copyright (C) 2000-2004, Robert van Engelen, Genivia, Inc., All Rights Reserved. --------------------------------------------------------------------------------- -GPL license. - -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 the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -Author contact information: -engelen@genivia.com / engelen@acm.org --------------------------------------------------------------------------------- - -Installation note: - -Win32 build needs winsock.dll (Visual C++ "wsock32.lib") -To do this in Visual C++ 6.0, go to "Project", "settings", select the "Link" -tab (the project file needs to be selected in the file view) and add -"wsock32.lib" to the "Object/library modules" entry - -On Mac OS X with gcc (GCC) 3.1 20020420 (prerelease) you MUST compile with --fstack_check when using -O2 because gcc 3.1 has a bug that smashes the stack -when locally allocated data exceeds 64K. - -*/ - -#include "stdsoap2.h" - -#ifdef __cplusplus -SOAP_SOURCE_STAMP("@(#) stdsoap2.cpp ver 2.7.0c 2004-09-27 12:00:00 GMT") -extern "C" { -#else -SOAP_SOURCE_STAMP("@(#) stdsoap2.c ver 2.7.0c 2004-09-27 12:00:00 GMT") -#endif - -/* 8bit character representing unknown/nonrepresentable character data (e.g. not supported by current locale) */ -#ifndef SOAP_UNKNOWN_CHAR -#define SOAP_UNKNOWN_CHAR (127) -#endif - -/* EOF=-1 */ -#define SOAP_LT (soap_wchar)(-2) /* XML character '<' */ -#define SOAP_TT (soap_wchar)(-3) /* XML character '' */ -#define SOAP_QT (soap_wchar)(-5) /* XML character '"' */ -#define SOAP_AP (soap_wchar)(-6) /* XML character ''' */ - -#define soap_blank(c) ((c) >= 0 && (c) <= 32) -#define soap_notblank(c) ((c) > 32) -#define soap_hash_ptr(p) (((unsigned long)(p) >> 3) & (SOAP_PTRHASH - 1)) - -static int soap_isxdigit(int); -static soap_wchar soap_char(struct soap*); -static soap_wchar soap_getchunkchar(struct soap*); -static void soap_update_ptrs(struct soap*, char*, char*, long); -static int soap_has_copies(struct soap*, const char*, const char*); -static struct soap_ilist *soap_hlookup(struct soap*, const char*); -static void soap_init_iht(struct soap*); -static void soap_free_iht(struct soap*); -static void soap_init_pht(struct soap*); -static void soap_free_pht(struct soap*); -static int soap_set_error(struct soap*, const char*, const char*, const char*, int); -static const char *soap_set_validation_fault(struct soap*, const char*, const char*); -static int soap_copy_fault(struct soap*, const char*, const char*, const char*); -static int soap_getattrval(struct soap*, char*, size_t, soap_wchar); -static void soap_set_local_namespaces(struct soap*); -static int soap_isnumeric(struct soap*, const char*); -static void *fplugin(struct soap*, const char*); -static const char *soap_decode(char*, size_t, const char*, const char*); - -#ifndef WITH_LEAN -static time_t soap_timegm(struct tm*); -#endif - -#ifdef SOAP_DEBUG -static void soap_init_logs(struct soap*); -static void soap_close_logfile(struct soap*, int); -static void soap_set_logfile(struct soap*, int, const char*); -#endif - -#ifdef WITH_FAST -static int soap_append_lab(struct soap*, const char*, size_t); -#endif - -#ifndef WITH_LEANER -static struct soap_multipart *soap_new_multipart(struct soap*, struct soap_multipart**, struct soap_multipart**, char*, size_t); -static int soap_putdimefield(struct soap*, const char*, size_t); -static char *soap_getdimefield(struct soap*, size_t); -static void soap_select_mime_boundary(struct soap*); -static int soap_valid_mime_boundary(struct soap*); -#endif - -#ifdef WITH_GZIP -static int soap_getgziphdr(struct soap*); -#endif - -#ifdef WITH_OPENSSL -static int ssl_auth_init(struct soap*); -static int ssl_verify_callback(int, X509_STORE_CTX*); -static int ssl_password(char*, int, int, void *); -/* This callback is included for future references. It should not be deleted -static DH *ssl_tmp_dh(SSL*, int, int); -*/ -#endif - -static const char *soap_strerror(struct soap*); -static const char *tcp_error(struct soap*); -static const char *http_error(struct soap*, int); -static int http_post(struct soap*, const char*, const char*, int, const char*, const char*, size_t); -static int http_get(struct soap*); -static int http_send_header(struct soap*, const char*); -static int http_post_header(struct soap*, const char*, const char*); -static int http_response(struct soap*, int, size_t); -static int http_parse(struct soap*); -static int http_parse_header(struct soap*, const char*, const char*); -#ifndef MAC_CARBON -static int tcp_gethost(struct soap*, const char *addr, struct in_addr *inaddr); -static int tcp_connect(struct soap*, const char *endpoint, const char *host, int port); -static int tcp_accept(struct soap*, int, struct sockaddr*, int*); -static int tcp_disconnect(struct soap*); -static int tcp_closesocket(struct soap*, SOAP_SOCKET); -static int tcp_shutdownsocket(struct soap*, SOAP_SOCKET, int); -static int fsend(struct soap*, const char*, size_t); -static size_t frecv(struct soap*, char*, size_t); -#endif - -/* WR[ */ -#ifdef VXWORKS -static int vx_nonblocking = TRUE; /* ioctl argument */ -#endif -/* ]WR */ - -#ifndef PALM_2 -static const char soap_env1[42] = "http://schemas.xmlsoap.org/soap/envelope/"; -static const char soap_enc1[42] = "http://schemas.xmlsoap.org/soap/encoding/"; -static const char soap_env2[40] = "http://www.w3.org/2003/05/soap-envelope"; -static const char soap_enc2[40] = "http://www.w3.org/2003/05/soap-encoding"; -static const char soap_rpc[35] = "http://www.w3.org/2003/05/soap-rpc"; -#endif - -#ifndef PALM_1 -const struct soap_double_nan soap_double_nan = {0xFFFFFFFF, 0xFFFFFFFF}; -static const char soap_base64o[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char soap_base64i[81] = "\76XXX\77\64\65\66\67\70\71\72\73\74\75XXXXXXX\00\01\02\03\04\05\06\07\10\11\12\13\14\15\16\17\20\21\22\23\24\25\26\27\30\31XXXXXX\32\33\34\35\36\37\40\41\42\43\44\45\46\47\50\51\52\53\54\55\56\57\60\61\62\63"; -#endif - -static const char soap_padding[3] = "\0\0"; -#define SOAP_STR_PADDING (soap_padding) -#define SOAP_STR_EOS (soap_padding) - -#ifndef WITH_LEAN -static const struct soap_code_map html_entity_codes[] = /* entities for XHTML parsing */ -{ { 160, "nbsp" }, - { 161, "iexcl" }, - { 162, "cent" }, - { 163, "pound" }, - { 164, "curren" }, - { 165, "yen" }, - { 166, "brvbar" }, - { 167, "sect" }, - { 168, "uml" }, - { 169, "copy" }, - { 170, "ordf" }, - { 171, "laquo" }, - { 172, "not" }, - { 173, "shy" }, - { 174, "reg" }, - { 175, "macr" }, - { 176, "deg" }, - { 177, "plusmn" }, - { 178, "sup2" }, - { 179, "sup3" }, - { 180, "acute" }, - { 181, "micro" }, - { 182, "para" }, - { 183, "middot" }, - { 184, "cedil" }, - { 185, "sup1" }, - { 186, "ordm" }, - { 187, "raquo" }, - { 188, "frac14" }, - { 189, "frac12" }, - { 190, "frac34" }, - { 191, "iquest" }, - { 192, "Agrave" }, - { 193, "Aacute" }, - { 194, "Acirc" }, - { 195, "Atilde" }, - { 196, "Auml" }, - { 197, "Aring" }, - { 198, "AElig" }, - { 199, "Ccedil" }, - { 200, "Egrave" }, - { 201, "Eacute" }, - { 202, "Ecirc" }, - { 203, "Euml" }, - { 204, "Igrave" }, - { 205, "Iacute" }, - { 206, "Icirc" }, - { 207, "Iuml" }, - { 208, "ETH" }, - { 209, "Ntilde" }, - { 210, "Ograve" }, - { 211, "Oacute" }, - { 212, "Ocirc" }, - { 213, "Otilde" }, - { 214, "Ouml" }, - { 215, "times" }, - { 216, "Oslash" }, - { 217, "Ugrave" }, - { 218, "Uacute" }, - { 219, "Ucirc" }, - { 220, "Uuml" }, - { 221, "Yacute" }, - { 222, "THORN" }, - { 223, "szlig" }, - { 224, "agrave" }, - { 225, "aacute" }, - { 226, "acirc" }, - { 227, "atilde" }, - { 228, "auml" }, - { 229, "aring" }, - { 230, "aelig" }, - { 231, "ccedil" }, - { 232, "egrave" }, - { 233, "eacute" }, - { 234, "ecirc" }, - { 235, "euml" }, - { 236, "igrave" }, - { 237, "iacute" }, - { 238, "icirc" }, - { 239, "iuml" }, - { 240, "eth" }, - { 241, "ntilde" }, - { 242, "ograve" }, - { 243, "oacute" }, - { 244, "ocirc" }, - { 245, "otilde" }, - { 246, "ouml" }, - { 247, "divide" }, - { 248, "oslash" }, - { 249, "ugrave" }, - { 250, "uacute" }, - { 251, "ucirc" }, - { 252, "uuml" }, - { 253, "yacute" }, - { 254, "thorn" }, - { 255, "yuml" }, - { 0, NULL } -}; -#endif - -#ifndef WITH_LEAN -static const struct soap_code_map h_error_codes[] = -{ -#ifdef HOST_NOT_FOUND - { HOST_NOT_FOUND, "Host not found" }, -#endif -#ifdef TRY_AGAIN - { TRY_AGAIN, "Try Again" }, -#endif -#ifdef NO_RECOVERY - { NO_RECOVERY, "No Recovery" }, -#endif -#ifdef NO_DATA - { NO_DATA, "No Data" }, -#endif -#ifdef NO_ADDRESS - { NO_ADDRESS, "No Address" }, -#endif - { 0, NULL } -}; -#endif - -#ifndef WITH_LEAN -static const struct soap_code_map h_http_error_codes[] = -{ { 201, "Created" }, - { 202, "Accepted" }, - { 203, "Non-Authoritative Information" }, - { 204, "No Content" }, - { 205, "Reset Content" }, - { 206, "Partial Content" }, - { 300, "Multiple Choices" }, - { 301, "Moved Permanently" }, - { 302, "Found" }, - { 303, "See Other" }, - { 304, "Not Modified" }, - { 305, "Use Proxy" }, - { 307, "Temporary Redirect" }, - { 400, "Bad Request" }, - { 401, "Unauthorized" }, - { 402, "Payment Required" }, - { 403, "Forbidden" }, - { 404, "Not Found" }, - { 405, "Method Not Allowed" }, - { 406, "Not Acceptable" }, - { 407, "Proxy Authentication Required" }, - { 408, "Request Time-out" }, - { 409, "Conflict" }, - { 410, "Gone" }, - { 411, "Length Required" }, - { 412, "Precondition Failed" }, - { 413, "Request Entity Too Large" }, - { 414, "Request-URI Too Large" }, - { 415, "Unsupported Media Type" }, - { 416, "Requested range not satisfiable" }, - { 417, "Expectation Failed" }, - { 500, "Internal Server Error" }, - { 501, "Not Implemented" }, - { 502, "Bad Gateway" }, - { 503, "Service Unavailable" }, - { 504, "Gateway Time-out" }, - { 505, "HTTP Version not supported" }, - { 0, NULL } -}; -#endif - -#ifdef WITH_OPENSSL -static const struct soap_code_map h_ssl_error_codes[] = -{ -#define _SSL_ERROR(e) { e, #e } - _SSL_ERROR(SSL_ERROR_SSL), - _SSL_ERROR(SSL_ERROR_ZERO_RETURN), - _SSL_ERROR(SSL_ERROR_WANT_READ), - _SSL_ERROR(SSL_ERROR_WANT_WRITE), - _SSL_ERROR(SSL_ERROR_WANT_CONNECT), - _SSL_ERROR(SSL_ERROR_WANT_X509_LOOKUP), - _SSL_ERROR(SSL_ERROR_SYSCALL), - { 0, NULL } -}; -#endif - -#ifndef WITH_LEANER -static const struct soap_code_map mime_codes[] = -{ { SOAP_MIME_7BIT, "7bit" }, - { SOAP_MIME_8BIT, "8bit" }, - { SOAP_MIME_BINARY, "binary" }, - { SOAP_MIME_QUOTED_PRINTABLE, "quoted-printable" }, - { SOAP_MIME_BASE64, "base64" }, - { SOAP_MIME_IETF_TOKEN, "ietf-token" }, - { SOAP_MIME_X_TOKEN, "x-token" }, - { 0, NULL } -}; -#endif - -#ifdef WIN32 -static int tcp_done = 0; -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -fsend(struct soap *soap, const char *s, size_t n) -{ register int nwritten; -#if defined(__cplusplus) && !defined(UNDER_CE) - if (soap->os) - { soap->os->write(s, n); - if (soap->os->good()) - return SOAP_OK; - return SOAP_EOF; - } -#endif - while (n) - { if (soap_valid_socket(soap->socket)) - { -#ifndef WITH_LEAN - if (soap->send_timeout) - { struct timeval timeout; - fd_set fd; - if (soap->send_timeout > 0) - { timeout.tv_sec = soap->send_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->send_timeout/1000000; - timeout.tv_usec = -soap->send_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - for (;;) - { register int r = select((SOAP_SOCKET)(soap->socket + 1), NULL, &fd, &fd, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - return SOAP_EOF; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - } - } -#endif -#ifdef WITH_OPENSSL - if (soap->ssl) - nwritten = SSL_write(soap->ssl, s, n); - else -#endif -#ifndef PALM - nwritten = send((SOAP_SOCKET)soap->socket, s, n, soap->socket_flags); -#else - nwritten = send((SOAP_SOCKET)soap->socket, (void*)s, n, soap->socket_flags); -#endif - if (nwritten <= 0) - { -#ifdef WITH_OPENSSL - int err; - if (soap->ssl && (err = SSL_get_error(soap->ssl, nwritten)) != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - return SOAP_EOF; -#endif - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EWOULDBLOCK && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - nwritten = 0; /* and call write() again */ - } - } - else - { -#ifdef WITH_FASTCGI - nwritten = fwrite((void*)s, 1, n, stdout); - fflush(stdout); -#else -#ifdef UNDER_CE - nwritten = fwrite(s, 1, n, soap->sendfd); -#else -/* WR[ */ -#ifdef VXWORKS -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - { - httpBlockPut(soap->rpmreqid, s, n); - nwritten = n; - } - else - { - nwritten = fwrite(s, sizeof(char), n, fdopen(soap->sendfd, "w")); - } -#else - nwritten = fwrite(s, sizeof(char), n, fdopen(soap->sendfd, "w")); -#endif /* WMW_RPM_IO */ -#else -/* ]WR */ - nwritten = write((SOAP_SOCKET)soap->sendfd, s, n); -/* WR[ */ -#endif -/* ]WR */ -#endif -#endif - if (nwritten <= 0) - { if (soap_errno != SOAP_EINTR && soap_errno != SOAP_EWOULDBLOCK && soap_errno != SOAP_EAGAIN) - { soap->errnum = soap_errno; - return SOAP_EOF; - } - nwritten = 0; /* and call write() again */ - } - } - n -= nwritten; - s += nwritten; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_flush_raw(struct soap *soap, const char *s, size_t n) -{ if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - { register char *t; - if (!(t = (char*)soap_push_block(soap, n))) - return soap->error = SOAP_EOM; - memcpy(t, s, n); - if (soap->fpreparesend) - return soap->fpreparesend(soap, s, n); - return SOAP_OK; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { char t[16]; - sprintf(t, "\r\n%lX\r\n" + (soap->chunksize ? 0 : 2), (unsigned long)n); - DBGMSG(SENT, t, strlen(t)); - if ((soap->error = soap->fsend(soap, t, strlen(t)))) - return soap->error; - soap->chunksize += n; - } - DBGMSG(SENT, s, n); - return soap->error = soap->fsend(soap, s, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_flush(struct soap *soap) -{ if (soap->bufidx) - { -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { soap->d_stream.next_in = (Byte*)soap->buf; - soap->d_stream.avail_in = (unsigned int)soap->bufidx; -#ifdef WITH_GZIP - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->bufidx); -#endif - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating %u bytes\n", soap->d_stream.avail_in)); - if (deflate(&soap->d_stream, Z_NO_FLUSH) != Z_OK) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to deflate: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - return soap->error = SOAP_ZLIB_ERROR; - } - if (!soap->d_stream.avail_out) - { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN)) - return soap->error; - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - } - } while (soap->d_stream.avail_in); - } - else -#endif - if (soap_flush_raw(soap, soap->buf, soap->bufidx)) - return soap->error; - soap->bufidx = 0; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send_raw(struct soap *soap, const char *s, size_t n) -{ if (!n) - return SOAP_OK; - if (soap->mode & SOAP_IO_LENGTH) - { soap->count += n; - if (soap->fpreparesend && (soap->mode & SOAP_IO) != SOAP_IO_STORE) - return soap->fpreparesend(soap, s, n); - return SOAP_OK; - } - if (soap->mode & SOAP_IO) - { register size_t i = SOAP_BUFLEN - soap->bufidx; - while (n >= i) - { memcpy(soap->buf + soap->bufidx, s, i); - soap->bufidx = SOAP_BUFLEN; - if (soap_flush(soap)) - return soap->error; - s += i; - n -= i; - i = SOAP_BUFLEN; - } - memcpy(soap->buf + soap->bufidx, s, n); - soap->bufidx += n; - return SOAP_OK; - } - return soap_flush_raw(soap, s, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send(struct soap *soap, const char *s) -{ if (s) - return soap_send_raw(soap, s, strlen(s)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send2(struct soap *soap, const char *s1, const char *s2) -{ if (soap_send(soap, s1)) - return soap->error; - return soap_send(soap, s2); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send3(struct soap *soap, const char *s1, const char *s2, const char *s3) -{ if (soap_send(soap, s1) - || soap_send(soap, s2)) - return soap->error; - return soap_send(soap, s3); -} -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static size_t -frecv(struct soap *soap, char *s, size_t n) -{ register int r; - soap->errnum = 0; -#if defined(__cplusplus) && !defined(UNDER_CE) - if (soap->is) - { if (soap->is->good()) - return soap->is->read(s, n).gcount(); - return 0; - } -#endif - if (soap_valid_socket(soap->socket)) - { for (;;) - { -#ifndef WITH_LEAN - struct timeval timeout; - fd_set fd; - if (soap->recv_timeout) - { if (soap->recv_timeout > 0) - { timeout.tv_sec = soap->recv_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->recv_timeout/1000000; - timeout.tv_usec = -soap->recv_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - for (;;) - { r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r > 0) - break; - if (r == 0) - return 0; - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return 0; - } - } - } -#endif -#ifdef WITH_OPENSSL - if (soap->ssl) - { int err; - r = SSL_read(soap->ssl, s, n); - if ((err = SSL_get_error(soap->ssl, r)) == SSL_ERROR_NONE) - return (size_t)r; - if (err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - return 0; - } - else -#endif - { r = recv((SOAP_SOCKET)soap->socket, s, n, soap->socket_flags); - if (r >= 0) - return (size_t)r; - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - return 0; - } - } -#ifndef WITH_LEAN - { struct timeval timeout; - fd_set fd; - timeout.tv_sec = 0; - timeout.tv_usec = 10000; - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r < 0 && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return 0; - } - } -#endif - } - } -#ifdef WITH_FASTCGI - return fread(s, 1, n, stdin); -#else -#ifdef UNDER_CE - return fread(s, 1, n, soap->recvfd); -#else -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - r = httpBlockRead(soap->rpmreqid, s, n); - else - r = read(soap->recvfd, s, n); - if (r >= 0) - return r; - return 0; -#else -/* ]WR */ - r = read((SOAP_SOCKET)soap->recvfd, s, n); - if (r >= 0) - return (size_t)r; - soap->errnum = soap_errno; - return 0; -/* WR[ */ -#endif -/* ]WR */ -#endif -#endif -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static soap_wchar -soap_getchunkchar(struct soap *soap) -{ if (soap->bufidx < soap->buflen) - return soap->buf[soap->bufidx++]; - soap->bufidx = 0; - soap->buflen = soap->chunkbuflen = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)soap->buflen)); - DBGMSG(RECV, soap->buf, soap->buflen); - if (soap->buflen) - return soap->buf[soap->bufidx++]; - return EOF; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_isxdigit(int c) -{ switch (c) - { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - return 1; - } - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_raw(struct soap *soap) -{ register size_t ret; -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { if (soap->d_stream.next_out == Z_NULL) - return EOF; - if (soap->d_stream.avail_in || !soap->d_stream.avail_out) - { register int r; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflating\n")); - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - r = inflate(&soap->d_stream, Z_NO_FLUSH); - if (r == Z_OK || r == Z_STREAM_END) - { soap->bufidx = 0; - soap->buflen = SOAP_BUFLEN - soap->d_stream.avail_out; - if (soap->zlib_in == SOAP_ZLIB_GZIP) - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->buflen); - if (r == Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_in = (float)soap->d_stream.total_in / (float)soap->d_stream.total_out; - soap->d_stream.next_out = Z_NULL; - } - if (soap->buflen) - { soap->count += soap->buflen; - return SOAP_OK; - } - } - else if (r != Z_BUF_ERROR) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate error: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - soap->d_stream.next_out = Z_NULL; - return EOF; - } - } -zlib_again: - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK && !soap->chunksize) - { memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN); - soap->buflen = soap->z_buflen; - } - } -#endif - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) /* read HTTP chunked transfer */ - { -chunk_again: - if (soap->chunksize) - { soap->buflen = ret = soap->frecv(soap, soap->buf, soap->chunksize > SOAP_BUFLEN ? SOAP_BUFLEN : soap->chunksize); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk: read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - soap->bufidx = 0; - soap->chunksize -= ret; - } - else - { register soap_wchar c; - char *t, tmp[8]; - t = tmp; - if (!soap->chunkbuflen) - { soap->chunkbuflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - soap->bufidx = 0; - if (!ret) - return EOF; - } - else - soap->bufidx = soap->buflen; - soap->buflen = soap->chunkbuflen; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk size (%u %u)\n", (unsigned int)soap->bufidx, (unsigned int)soap->buflen)); - while (!soap_isxdigit((int)(c = soap_getchunkchar(soap)))) - if ((int)c == EOF) - return EOF; - do - *t++ = (char)c; - while (soap_isxdigit((int)(c = soap_getchunkchar(soap))) && t - tmp < 7); - while ((int)c != EOF && c != '\n') - c = soap_getchunkchar(soap); - if ((int)c == EOF) - return EOF; - *t = '\0'; - soap->chunksize = soap_strtoul(tmp, &t, 16); - if (!soap->chunksize) - { soap->chunkbuflen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of chunked message\n")); - while ((int)c != EOF && c != '\n') - c = soap_getchunkchar(soap); - return EOF; - } - soap->buflen = soap->bufidx + soap->chunksize; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving buf len to %u (%u %s)\n", (unsigned int)soap->buflen, (unsigned int)soap->bufidx, tmp)); - if (soap->buflen > soap->chunkbuflen) - { soap->buflen = soap->chunkbuflen; - soap->chunksize -= soap->buflen - soap->bufidx; - soap->chunkbuflen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Passed end of buffer for chunked HTTP (%lu bytes left)\n", (unsigned long)(soap->buflen - soap->bufidx))); - } - else if (soap->chunkbuflen) - soap->chunksize = 0; - ret = soap->buflen - soap->bufidx; - if (!ret) - goto chunk_again; - } - } - else - { soap->bufidx = 0; - soap->buflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - } - if (soap->fpreparerecv && (soap->error = soap->fpreparerecv(soap, soap->buf, ret))) - return soap->error; -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { register int r; - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = (unsigned int)ret; - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - r = inflate(&soap->d_stream, Z_NO_FLUSH); - if (r == Z_OK || r == Z_STREAM_END) - { soap->bufidx = 0; - soap->z_buflen = soap->buflen; - soap->buflen = ret = SOAP_BUFLEN - soap->d_stream.avail_out; - if (soap->zlib_in == SOAP_ZLIB_GZIP) - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->buflen); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %u bytes\n", (unsigned int)ret)); - if (!ret) - goto zlib_again; - if (r == Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_in = (float)soap->d_stream.total_in / (float)soap->d_stream.total_out; - soap->d_stream.next_out = Z_NULL; - } - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to inflate: (%d) %s\n", r, soap->d_stream.msg?soap->d_stream.msg:"")); - soap->d_stream.next_out = Z_NULL; - return EOF; - } - } -#endif - soap->count += ret; - return !ret; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv(struct soap *soap) -{ -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - { if (soap->dime.buflen) - { char *s; - int i; - unsigned char tmp[12]; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME hdr for chunked DIME is in buffer\n")); - soap->count += soap->dime.buflen - soap->buflen; - soap->buflen = soap->dime.buflen; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Skip padding (%ld bytes)\n", -(long)soap->dime.size&3)); - for (i = -(long)soap->dime.size&3; i > 0; i--) - { soap->bufidx++; - if (soap->bufidx >= soap->buflen) - if (soap_recv_raw(soap)) - return EOF; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME hdr for next chunk\n")); - s = (char*)tmp; - for (i = 12; i > 0; i--) - { *s++ = soap->buf[soap->bufidx++]; - if (soap->bufidx >= soap->buflen) - if (soap_recv_raw(soap)) - return EOF; - } - soap->dime.flags = tmp[0] & 0x7; - soap->dime.size = ((size_t)tmp[8] << 24) | ((size_t)tmp[9] << 16) | ((size_t)tmp[10] << 8) | ((size_t)tmp[11]); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME chunk (%u bytes)\n", (unsigned int)soap->dime.size)); - if (soap->dime.flags & SOAP_DIME_CF) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "More chunking\n")); - soap->dime.chunksize = soap->dime.size; - if (soap->buflen - soap->bufidx >= soap->dime.size) - { soap->dime.buflen = soap->buflen; - soap->buflen = soap->bufidx + soap->dime.chunksize; - } - else - soap->dime.chunksize -= soap->buflen - soap->bufidx; - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Last chunk\n")); - soap->dime.buflen = 0; - soap->dime.chunksize = 0; - } - soap->count = soap->buflen - soap->bufidx; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%u bytes remaining\n", (unsigned int)soap->count)); - return SOAP_OK; - } - if (soap->dime.chunksize) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get next DIME hdr for chunked DIME (%u bytes chunk)\n", (unsigned int)soap->dime.chunksize)); - if (soap_recv_raw(soap)) - return EOF; - if (soap->buflen - soap->bufidx >= soap->dime.chunksize) - { soap->dime.buflen = soap->buflen; - soap->count -= soap->buflen - soap->bufidx - soap->dime.chunksize; - soap->buflen = soap->bufidx + soap->dime.chunksize; - } - else - soap->dime.chunksize -= soap->buflen - soap->bufidx; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%lu bytes remaining, count=%u\n", (unsigned long)(soap->buflen-soap->bufidx), (unsigned int)soap->count)); - return SOAP_OK; - } - } -#endif - return soap_recv_raw(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -soap_wchar -SOAP_FMAC2 -soap_getchar(struct soap *soap) -{ register soap_wchar c; - if (soap->ahead) - { c = soap->ahead; - soap->ahead = 0; - return c; - } - return soap_get1(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const struct soap_code_map* -SOAP_FMAC2 -soap_code(const struct soap_code_map *map, const char *str) -{ while (map->string) - { if (!strcmp(str, map->string)) /* case sensitive */ - return map; - map++; - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_int_code(const struct soap_code_map *map, const char *str, long other) -{ while (map->string) - { if (!soap_tag_cmp(str, map->string)) /* case insensitive */ - return map->code; - map++; - } - return other; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_str_code(const struct soap_code_map *map, long code) -{ while (map->code != code && map->string) - map++; - return map->string; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static soap_wchar -soap_char(struct soap *soap) -{ char tmp[8]; - register int i; - register soap_wchar c; - register char *s = tmp; - for (i = 0; i < 7; i++) - { c = soap_get1(soap); - if (c == ';' || (int)c == EOF) - break; - *s++ = (char)c; - } - *s = '\0'; - if (*tmp == '#') - { if (tmp[1] == 'x' || tmp[1] == 'X') - return soap_strtol(tmp + 2, NULL, 16); - return atol(tmp + 1); - } - if (!strcmp(tmp, "lt")) - return '<'; - if (!strcmp(tmp, "gt")) - return '>'; - if (!strcmp(tmp, "amp")) - return '&'; - if (!strcmp(tmp, "quot")) - return '"'; - if (!strcmp(tmp, "apos")) - return '\''; -#ifndef WITH_LEAN - return (soap_wchar)soap_int_code(html_entity_codes, tmp, SOAP_UNKNOWN_CHAR); -#else - return SOAP_UNKNOWN_CHAR; /* use this to represent unknown code */ -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -soap_wchar -SOAP_FMAC2 -soap_get(struct soap *soap) -{ register soap_wchar c; - c = soap->ahead; - if (c) - soap->ahead = 0; - else - c = soap_get1(soap); - for (;;) - { if (soap->cdata) - { if (c == ']') - { c = soap_get1(soap); - if (c == ']') - { soap->cdata = 0; - soap_get1(soap); /* skip > */ - c = soap_get1(soap); - } - else - { soap_revget1(soap); - return ']'; - } - } - else - return c; - } - switch (c) - { case '<': - do c = soap_get1(soap); - while (soap_blank(c)); - if (c == '!' || c == '?' || c == '%') - { if (c == '!') - { c = soap_get1(soap); - if (c == '[') - { do c = soap_get1(soap); - while ((int)c != EOF && c != '['); - if ((int)c == EOF) - break; - soap->cdata = 1; - c = soap_get1(soap); - continue; - } - if (c == '-' && (c = soap_get1(soap)) == '-') - { do - { c = soap_get1(soap); - if (c == '-' && (c = soap_get1(soap)) == '-') - break; - } while ((int)c != EOF); - } - } - while ((int)c != EOF && c != '>') - c = soap_get1(soap); - if ((int)c == EOF) - break; - c = soap_get1(soap); - continue; - } - if (c == '/') - return SOAP_TT; - soap_revget1(soap); - return SOAP_LT; - case '>': - return SOAP_GT; - case '"': - return SOAP_QT; - case '\'': - return SOAP_AP; - case '&': - return soap_char(soap) | 0x80000000; - } - break; - } - return c; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -soap_wchar -SOAP_FMAC2 -soap_advance(struct soap *soap) -{ register soap_wchar c; - while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT) - ; - return c; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -soap_wchar -SOAP_FMAC2 -soap_skip(struct soap *soap) -{ register soap_wchar c; - do c = soap_get(soap); - while (soap_blank(c)); - return c; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_move(struct soap *soap, long n) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving %ld bytes forward\n", (long)n)); - for (; n > 0; n--) - if ((int)soap_getchar(soap) == EOF) - return SOAP_EOF; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_tell(struct soap *soap) -{ return soap->count - soap->buflen + soap->bufidx - (soap->ahead != 0); -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pututf8(struct soap *soap, register unsigned long c) -{ char tmp[16]; - if (c > 0 && c < 0x80) - { *tmp = (char)c; - return soap_send_raw(soap, tmp, 1); - } -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { register char *t = tmp; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - *t = '\0'; - } - else -#endif - sprintf(tmp, "&#%lu;", c); - return soap_send(soap, tmp); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -soap_wchar -SOAP_FMAC2 -soap_getutf8(struct soap *soap) -{ register soap_wchar c, c1, c2, c3, c4; - c = soap_get(soap); - if (c < 0x80 || (soap->mode & SOAP_ENC_LATIN)) - return c; - c1 = soap_get(soap); - if (c1 < 0x80) - { soap_unget(soap, c1); - return c; - } - c1 &= 0x3F; - if (c < 0xE0) - return ((soap_wchar)(c & 0x1F) << 6) | c1; - c2 = (soap_wchar)soap_get1(soap) & 0x3F; - if (c < 0xF0) - return ((soap_wchar)(c & 0x0F) << 12) | (c1 << 6) | c2; - c3 = (soap_wchar)soap_get1(soap) & 0x3F; - if (c < 0xF8) - return ((soap_wchar)(c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3; - c4 = (soap_wchar)soap_get1(soap) & 0x3F; - if (c < 0xFC) - return ((soap_wchar)(c & 0x03) << 24) | (c1 << 18) | (c2 << 12) | (c3 << 6) | c4; - return ((soap_wchar)(c & 0x01) << 30) | (c1 << 24) | (c2 << 18) | (c3 << 12) | (c4 << 6) | (soap_wchar)(soap_get1(soap) & 0x3F); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_puthex(struct soap *soap, const unsigned char *s, int n) -{ /* TODO: serialize to DOM (as an option) using new soap_s2hex() */ - char d[2]; - register int i; - for (i = 0; i < n; i++) - { register int m = *s++; - d[0] = (char)((m >> 4) + (m > 159 ? '7' : '0')); - m &= 0x0F; - d[1] = (char)(m + (m > 9 ? '7' : '0')); - if (soap_send_raw(soap, d, 2)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -unsigned char* -SOAP_FMAC2 -soap_gethex(struct soap *soap, int *n) -{ -#ifdef WITH_FAST - soap->labidx = 0; - for (;;) - { register char *s; - register int i, k; - if (soap_append_lab(soap, NULL, 0)) - return NULL; - s = soap->labbuf + soap->labidx; - k = soap->lablen - soap->labidx; - soap->labidx = soap->lablen; - for (i = 0; i < k; i++) - { register char d1, d2; - register soap_wchar c; - c = soap_get(soap); - if (soap_isxdigit(c)) - { d1 = (char)c; - c = soap_get(soap); - if (soap_isxdigit(c)) - d2 = (char)c; - else - { soap->error = SOAP_TYPE; - return NULL; - } - } - else - { unsigned char *p; - soap_unget(soap, c); - if (n) - *n = (int)(soap->lablen - k + i); - p = (unsigned char*)soap_malloc(soap, soap->lablen - k + i); - if (p) - memcpy(p, soap->labbuf, soap->lablen - k + i); - return p; - } - *s++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0'); - } - } -#else - if (soap_new_block(soap)) - return NULL; - for (;;) - { register int i; - register char *s = (char*)soap_push_block(soap, SOAP_BLKLEN); - if (!s) - { soap_end_block(soap); - return NULL; - } - for (i = 0; i < SOAP_BLKLEN; i++) - { register char d1, d2; - register soap_wchar c = soap_get(soap); - if (soap_isxdigit(c)) - { d1 = (char)c; - c = soap_get(soap); - if (soap_isxdigit(c)) - d2 = (char)c; - else - { soap_end_block(soap); - soap->error = SOAP_TYPE; - return NULL; - } - } - else - { unsigned char *p; - soap_unget(soap, c); - if (n) - *n = soap_size_block(soap, i); - p = (unsigned char*)soap_save_block(soap, NULL, 0); - return p; - } - *s++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0'); - } - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putbase64(struct soap *soap, const unsigned char *s, int n) -{ register int i; - register unsigned long m; - char d[4]; - if (!s) - return SOAP_OK; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { if (!(soap->dom->data = soap_s2base64(soap, s, soap->dom->data, n))) - return soap->error; - return SOAP_OK; - } -#endif - for (; n > 2; n -= 3, s += 3) - { m = s[0]; - m = (m << 8) | s[1]; - m = (m << 8) | s[2]; - for (i = 4; i > 0; m >>= 6) - d[--i] = soap_base64o[m & 0x3F]; - if (soap_send_raw(soap, d, 4)) - return soap->error; - } - if (n > 0) - { m = 0; - for (i = 0; i < n; i++) - m = (m << 8) | *s++; - for (; i < 3; i++) - m <<= 8; - for (i++; i > 0; m >>= 6) - d[--i] = soap_base64o[m & 0x3F]; - for (i = 3; i > n; i--) - d[i] = '='; - if (soap_send_raw(soap, d, 4)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -unsigned char* -SOAP_FMAC2 -soap_getbase64(struct soap *soap, int *n, int malloc_flag) -{ -#ifdef WITH_FAST - soap->labidx = 0; - for (;;) - { register int i, k; - register char *s; - if (soap_append_lab(soap, NULL, 2)) - return NULL; - s = soap->labbuf + soap->labidx; - k = 3 * ((soap->lablen - soap->labidx) / 3); - soap->labidx = 3 * (soap->lablen / 3); - if (!s) - return NULL; - for (i = 0; i < k; i += 3) - { register unsigned long m = 0; - register int j = 0; - do - { register soap_wchar c = soap_get(soap); - if (c == '=' || c < 0) - { unsigned char *p; - switch (j) - { case 2: - *s++ = (char)((m >> 4) & 0xFF); - i++; - break; - case 3: - *s++ = (char)((m >> 10) & 0xFF); - *s++ = (char)((m >> 2) & 0xFF); - i += 2; - } - if (n) - *n = (int)(soap->lablen - k + i); - p = (unsigned char*)soap_malloc(soap, soap->lablen - k + i); - if (p) - memcpy(p, soap->labbuf, soap->lablen - k + i); - if (c >= 0) - { while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT) - ; - } - soap_unget(soap, c); - return p; - } - c -= '+'; - if (c >= 0 && c <= 79) - { m = (m << 6) + soap_base64i[c]; - j++; - } - } while (j < 4); - *s++ = (char)((m >> 16) & 0xFF); - *s++ = (char)((m >> 8) & 0xFF); - *s++ = (char)(m & 0xFF); - } - } -#else - if (soap_new_block(soap)) - return NULL; - for (;;) - { register int i; - register char *s = (char*)soap_push_block(soap, 3 * SOAP_BLKLEN); /* must be multiple of 3 */ - if (!s) - { soap_end_block(soap); - return NULL; - } - for (i = 0; i < SOAP_BLKLEN; i++) - { register unsigned long m = 0; - register int j = 0; - do - { register soap_wchar c = soap_get(soap); - if (c == '=' || c < 0) - { unsigned char *p; - i *= 3; - switch (j) - { case 2: - *s++ = (char)((m >> 4) & 0xFF); - i++; - break; - case 3: - *s++ = (char)((m >> 10) & 0xFF); - *s++ = (char)((m >> 2) & 0xFF); - i += 2; - } - if (n) - *n = (int)soap_size_block(soap, i); - p = (unsigned char*)soap_save_block(soap, NULL, 0); - if (c >= 0) - { while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT) - ; - } - soap_unget(soap, c); - return p; - } - c -= '+'; - if (c >= 0 && c <= 79) - { m = (m << 6) + soap_base64i[c]; - j++; - } - } while (j < 4); - *s++ = (char)((m >> 16) & 0xFF); - *s++ = (char)((m >> 8) & 0xFF); - *s++ = (char)(m & 0xFF); - } - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_strdup(struct soap *soap, const char *s) -{ char *t = NULL; - if (s && (t = (char*)soap_malloc(soap, strlen(s) + 1))) - strcpy(t, s); - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_new_block(struct soap *soap) -{ struct soap_blist *p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New block sequence (prev=%p)\n", soap->blist)); - if (!(p = (struct soap_blist*)SOAP_MALLOC(sizeof(struct soap_blist)))) - return SOAP_EOM; - p->next = soap->blist; - p->ptr = NULL; - p->size = 0; - soap->blist = p; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_push_block(struct soap *soap, size_t n) -{ char *p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push block of %u bytes (%u bytes total)\n", (unsigned int)n, (unsigned int)soap->blist->size + (unsigned int)n)); - if (!(p = (char*)SOAP_MALLOC(n + sizeof(char*) + sizeof(size_t)))) - { soap->error = SOAP_EOM; - return NULL; - } - *(char**)p = soap->blist->ptr; - *(size_t*)(p + sizeof(char*)) = n; - soap->blist->ptr = p; - soap->blist->size += n; - return p + sizeof(char*) + sizeof(size_t); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_pop_block(struct soap *soap) -{ char *p; - if (!soap->blist->ptr) - return; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pop block\n")); - p = soap->blist->ptr; - soap->blist->size -= *(size_t*)(p + sizeof(char*)); - soap->blist->ptr = *(char**)p; - SOAP_FREE(p); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_update_ptrs(struct soap *soap, char *start, char *end, long offset) -{ int i; - register struct soap_ilist *ip; - register struct soap_flist *fp; - register void *p, **q; - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr && (char*)ip->ptr >= start && (char*)ip->ptr < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update id='%s' %p -> %p\n", ip->id, ip->ptr, (char*)ip->ptr + offset)); - ip->ptr = (char*)ip->ptr + offset; - } - for (q = &ip->link; q; q = (void**)p) - { p = *q; - if (p && (char*)p >= start && (char*)p < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Link update id='%s' %p\n", ip->id, p)); - *q = (char*)p + offset; - } - } - for (q = &ip->copy; q; q = (void**)p) - { p = *q; - if (p && (char*)p >= start && (char*)p < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy chain update id='%s' %p\n", ip->id, p)); - *q = (char*)p + offset; - } - } - for (fp = ip->flist; fp; fp = fp->next) - { if ((char*)fp->ptr >= start && (char*)fp->ptr < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy list update id='%s' %p\n", ip->id, fp)); - fp->ptr = (char*)fp->ptr + offset; - } - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_has_copies(struct soap *soap, register const char *start, register const char *end) -{ register int i; - register struct soap_ilist *ip; - register struct soap_flist *fp; - register const char *p; - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) - { for (p = (const char*)ip->copy; p; p = *(const char**)p) - if (p >= start && p < end) - return SOAP_ERR; - for (fp = ip->flist; fp; fp = fp->next) - if ((const char*)fp->ptr >= start && (const char*)fp->ptr < end) - return SOAP_ERR; - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_resolve(struct soap *soap) -{ register int i; - register struct soap_ilist *ip; - register struct soap_flist *fp; - short flag; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data\n")); - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr) - { register void *p, **q, *r; - q = (void**)ip->link; - ip->link = NULL; - r = ip->ptr; - DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing link chain to resolve id='%s'\n", ip->id)); - while (q) - { p = *q; - *q = r; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "... link %p -> %p\n", q, r)); - q = (void**)p; - } - } - else if (*ip->id == '#') - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Missing data for id='%s'\n", ip->id)); - strcpy(soap->id, ip->id + 1); - return soap->error = SOAP_MISSING_ID; - } - } - } - do - { flag = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution phase\n")); - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr && !soap_has_copies(soap, (const char*)ip->ptr, (const char*)ip->ptr + ip->size)) - { if (ip->copy) - { register void *p, **q = (void**)ip->copy; - DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing copy chain to resolve id='%s'\n", ip->id)); - ip->copy = NULL; - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... copy %p -> %p (%u bytes)\n", ip->ptr, q, (unsigned int)ip->size)); - p = *q; - memcpy(q, ip->ptr, ip->size); - q = (void**)p; - } while (q); - flag = 1; - } - for (fp = ip->flist; fp; fp = ip->flist) - { register unsigned int k = fp->level; - register void *p = ip->ptr; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data type=%d location=%p level=%u,%u id='%s'\n", ip->type, p, ip->level, fp->level, ip->id)); - while (ip->level < k) - { register void **q = (void**)soap_malloc(soap, sizeof(void*)); - if (!q) - return soap->error; - *q = p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level, new location=%p holds=%p...\n", q, *q)); - p = (void*)q; - k--; - } - if (fp->fcopy) - fp->fcopy(soap, ip->type, fp->type, fp->ptr, p, ip->size); - else - soap_fcopy(soap, ip->type, fp->type, fp->ptr, p, ip->size); - ip->flist = fp->next; - SOAP_FREE(fp); - flag = 1; - } - } - } - } - } while (flag); -#ifdef SOAP_DEBUG - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->copy || ip->flist) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution error: forwarded data for id='%s' could not be propagated, please report this problem to the developers\n", ip->id)); - } - } - } -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution done\n")); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_size_block(struct soap *soap, size_t n) -{ if (soap->blist->ptr) - { soap->blist->size -= *(size_t*)(soap->blist->ptr + sizeof(char*)) - n; - *(size_t*)(soap->blist->ptr + sizeof(char*)) = n; - } - return soap->blist->size; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_first_block(struct soap *soap) -{ char *p, *q, *r; - p = soap->blist->ptr; - if (!p) - return NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "First block\n")); - r = NULL; - do - { q = *(char**)p; - *(char**)p = r; - r = p; - p = q; - } while (p); - soap->blist->ptr = r; - return r + sizeof(char*) + sizeof(size_t); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_next_block(struct soap *soap) -{ char *p; - p = soap->blist->ptr; - if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Next block\n")); - soap->blist->ptr = *(char**)p; - SOAP_FREE(p); - if (soap->blist->ptr) - return soap->blist->ptr + sizeof(char*) + sizeof(size_t); - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_block_size(struct soap *soap) -{ return *(size_t*)(soap->blist->ptr + sizeof(char*)); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_end_block(struct soap *soap) -{ struct soap_blist *bp; - char *p, *q; - bp = soap->blist; - if (bp) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of block sequence, free all remaining blocks\n")); - for (p = bp->ptr; p; p = q) - { q = *(char**)p; - SOAP_FREE(p); - } - soap->blist = bp->next; - SOAP_FREE(bp); - } - DBGLOG(TEST, if (soap->blist) SOAP_MESSAGE(fdebug, "Restore previous block sequence\n")); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_save_block(struct soap *soap, char *p, int flag) -{ register size_t n; - register char *q, *s; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Save all blocks in contiguous memory space of %u bytes (%p->%p)\n", (unsigned int)soap->blist->size, soap->blist->ptr, p)); - if (soap->blist->size) - { if (!p) - p = (char*)soap_malloc(soap, soap->blist->size); - if (p) - { for (s = p, q = soap_first_block(soap); q; q = soap_next_block(soap)) - { n = soap_block_size(soap); - if (flag) - soap_update_ptrs(soap, q, q + n, (long)s - (long)q); /* pointers s and q may or may not be related */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy %u bytes from %p to %p\n", (unsigned int)n, q, s)); - memcpy(s, q, n); - s += n; - } - } - else - soap->error = SOAP_EOM; - } - soap_end_block(soap); - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsize(struct soap *soap, const char *type, int size) -{ return soap_putsizes(soap, type, &size, 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsizes(struct soap *soap, const char *type, const int *size, int dim) -{ return soap_putsizesoffsets(soap, type, size, NULL, dim); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsizesoffsets(struct soap *soap, const char *type, const int *size, const int *offset, int dim) -{ int i; - if (!type) - return NULL; - if (soap->version == 2) - { sprintf(soap->type, "%s[%d", type, size[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), " %d", size[i]); - } - else - { if (offset) - { sprintf(soap->type, "%s[%d", type, size[0] + offset[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), ",%d", size[i] + offset[i]); - } - else - { sprintf(soap->type, "%s[%d", type, size[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), ",%d", size[i]); - } - strcat(soap->type, "]"); - } - return soap->type; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putoffset(struct soap *soap, int offset) -{ return soap_putoffsets(soap, &offset, 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putoffsets(struct soap *soap, const int *offset, int dim) -{ register int i; - sprintf(soap->arrayOffset, "[%d", offset[0]); - for (i = 1; i < dim; i++) - sprintf(soap->arrayOffset + strlen(soap->arrayOffset), ",%d", offset[i]); - strcat(soap->arrayOffset, "]"); - return soap->arrayOffset; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_size(const int *size, int dim) -{ register int i, n = size[0]; - for (i = 1; i < dim; i++) - n *= size[i]; - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getoffsets(const char *attr, const int *size, int *offset, int dim) -{ register int i, j = 0; - if (offset) - for (i = 0; i < dim && attr && *attr; i++) - { attr++; - j *= size[i]; - j += offset[i] = (int)atol(attr); - attr = strchr(attr, ','); - } - else - for (i = 0; i < dim && attr && *attr; i++) - { attr++; - j *= size[i]; - j += (int)atol(attr); - attr = strchr(attr, ','); - } - return j; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getsize(const char *attr1, const char *attr2, int *j) -{ register int n, k; - char *s; - *j = 0; - if (!*attr1) - return -1; - n = 1; - do - { attr1++; - k = (int)soap_strtol(attr1, &s, 10); - n *= k; - if (k < 0 || n > SOAP_MAXARRAYSIZE || s == attr1) - return -1; - attr1 = strchr(s, ','); - if (!attr1) - attr1 = strchr(s, ' '); - if (attr2 && *attr2) - { attr2++; - *j *= k; - k = (int)soap_strtol(attr2, &s, 10); - *j += k; - if (k < 0) - return -1; - attr2 = s; - } - } while (attr1 && *attr1 != ']'); - return n - *j; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getsizes(const char *attr, int *size, int dim) -{ register int i, k, n; - if (!*attr) - return -1; - i = strlen(attr); - n = 1; - do - { for (i = i-1; i >= 0; i--) - if (attr[i] == '[' || attr[i] == ',' || attr[i] == ' ') - break; - k = (int)atol(attr + i + 1); - n *= size[--dim] = k; - if (k < 0 || n > SOAP_MAXARRAYSIZE) - return -1; - } while (i >= 0 && attr[i] != '['); - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getposition(const char *attr, int *pos) -{ register int i, n; - if (!*attr) - return -1; - n = 0; - i = 1; - do - { pos[n++] = (int)atol(attr + i); - while (attr[i] && attr[i] != ',' && attr[i] != ']') - i++; - if (attr[i] == ',') - i++; - } while (n < SOAP_MAXDIMS && attr[i] && attr[i] != ']'); - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_push_namespace(struct soap *soap, const char *id, const char *ns) -{ register struct soap_nlist *np; - register struct Namespace *p; - np = (struct soap_nlist*)SOAP_MALLOC(sizeof(struct soap_nlist) + strlen(id)); - if (!np) - return soap->error = SOAP_EOM; - np->next = soap->nlist; - soap->nlist = np; - strcpy(np->id, id); - np->level = soap->level; - np->index = -1; - np->ns = NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push namespace binding (level=%u) '%s' '%s'\n", soap->level, id, ns)); - p = soap->local_namespaces; - if (p) - { register short i = 0; - for (; p->id; p++, i++) - { if (p->ns && !strcmp(ns, p->ns)) - { if (p->out) - { SOAP_FREE(p->out); - p->out = NULL; - } - break; - } - if (p->out) - { if (!SOAP_STRCMP(ns, p->out)) - break; - } - else if (p->in) - { if (!soap_tag_cmp(ns, p->in)) - { if ((p->out = (char*)SOAP_MALLOC(strlen(ns) + 1))) - strcpy(p->out, ns); - break; - } - } - } - if (p && p->id) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push OK ('%s' matches '%s' in namespace table)\n", id, p->id)); - np->index = i; - } - } - if (!p || !p->id) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push NOT OK: no match found for '%s' in namespace mapping table (added to stack anyway)\n", ns)); - np->ns = (char*)SOAP_MALLOC(strlen(ns) + 1); - if (!np->ns) - return soap->error = SOAP_EOM; - strcpy(np->ns, ns); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_pop_namespace(struct soap *soap) -{ register struct soap_nlist *np; - while (soap->nlist && soap->nlist->level >= soap->level) - { np = soap->nlist->next; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Popped namespace binding (level=%u) '%s'\n", soap->level, soap->nlist->id)); - if (soap->nlist->ns) - SOAP_FREE(soap->nlist->ns); - SOAP_FREE(soap->nlist); - soap->nlist = np; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_namespace(struct soap *soap, const char *id1, const char *id2, int n1, int n2) -{ register struct soap_nlist *np = soap->nlist; - while (np && (strncmp(np->id, id1, n1) || np->id[n1])) - np = np->next; - if (np) - { if (np->index < 0 || (np->index >= 0 && soap->local_namespaces[np->index].id && (strncmp(soap->local_namespaces[np->index].id, id2, n2) || soap->local_namespaces[np->index].id[n2]))) - return SOAP_NAMESPACE; - return SOAP_OK; - } - if (n1 == 3 && n1 == n2 && !strcmp(id1, "xml") && !strcmp(id1, id2)) - return SOAP_OK; - return SOAP_SYNTAX_ERROR; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_default_namespace(struct soap *soap) -{ register struct soap_nlist *np = soap->nlist; - while (np && np->index >= -1) - np = np->next; - if (np) - return np->id; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_tag_cmp(register const char *s, register const char *t) -{ for (; *s && *s != '"'; s++, t++) - if (tolower(*s) != tolower(*t)) - if (*t != '-') - { if (*t != '*') - return 1; - if (*++t) - { register int c = tolower(*t); - for (; *s && *s != '"'; s++) - { if (tolower(*s) == c) - if (!soap_tag_cmp(s + 1, t + 1)) - return 0; - } - break; - } - else - return 0; - } - if (*t == '*' && !t[1]) - return 0; - return *t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_tag(struct soap *soap, const char *tag1, const char *tag2) -{ register const char *s, *t; - if (!tag1 || !tag2 || !*tag2) - return SOAP_OK; - s = strchr(tag1, ':'); - t = strchr(tag2, ':'); - if (t) - { if (s) - { if (t[1] && SOAP_STRCMP(s + 1, t + 1)) - return SOAP_TAG_MISMATCH; - if (t != tag2 && soap_match_namespace(soap, tag1, tag2, s - tag1, t - tag2)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); - return SOAP_TAG_MISMATCH; - } - } - else if (SOAP_STRCMP(tag1, t + 1)) - return SOAP_TAG_MISMATCH; - else if (t != tag2 && soap_match_namespace(soap, tag1, tag2, 0, t - tag2)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); - return SOAP_TAG_MISMATCH; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags and (default) namespaces match: '%s' '%s'\n", tag1, tag2)); - return SOAP_OK; - } - if (s) - { if (SOAP_STRCMP(s + 1, tag2)) - return SOAP_TAG_MISMATCH; - if (!soap->encodingStyle) - { t = soap_default_namespace(soap); - if (!t || soap_match_namespace(soap, tag1, t, s - tag1, strlen(t))) - return SOAP_TAG_MISMATCH; - } - } - else if (SOAP_STRCMP(tag1, tag2)) - return SOAP_TAG_MISMATCH; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags match: '%s' '%s'\n", tag1, tag2)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_array(struct soap *soap, const char *type) -{ if (*soap->arrayType) - if (soap_match_tag(soap, soap->arrayType, type) - && soap_match_tag(soap, soap->arrayType, "xsd:anyType") - && soap_match_tag(soap, soap->arrayType, "xsd:ur-type") - ) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array type mismatch: '%s' '%s'\n", soap->arrayType, type)); - return SOAP_TAG_MISMATCH; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ - -#ifdef WITH_OPENSSL -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_server_context(struct soap *soap, unsigned short flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *dhfile, const char *randfile, const char *sid) -{ int err; - soap->keyfile = keyfile; - soap->password = password; - soap->cafile = cafile; - soap->capath = capath; - if (dhfile) - { soap->dhfile = dhfile; - soap->rsa = 0; - } - else - { soap->dhfile = NULL; - soap->rsa = 1; - } - soap->randfile = randfile; - soap->require_client_auth = (flags & SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION); - if (!(err = soap->fsslauth(soap))) - if (sid) - SSL_CTX_set_session_id_context(soap->ctx, (unsigned char*)sid, strlen(sid)); - return err; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_client_context(struct soap *soap, unsigned short flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *randfile) -{ soap->keyfile = keyfile; - soap->password = password; - soap->cafile = cafile; - soap->capath = capath; - soap->dhfile = NULL; - soap->rsa = 0; - soap->randfile = randfile; - soap->require_server_auth = (flags & SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION); - return soap->fsslauth(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -ssl_init() -{ static int done = 0; - if (!done) - { done = 1; - SSL_library_init(); -#ifndef WITH_LEAN - SSL_load_error_strings(); -#endif - if (!RAND_load_file("/dev/urandom", 1024)) - { int r; -#ifdef HAVE_RAND_R - unsigned int s = (unsigned int)time(NULL); -#endif - char buf[SOAP_BUFLEN]; - RAND_seed(buf, sizeof(buf)); - while (!RAND_status()) - { -#ifdef HAVE_RAND_R - r = rand_r(&s); -#else - r = rand(); -#endif - RAND_seed(&r, sizeof(int)); - } - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char * -ssl_error(struct soap *soap, int ret) -{ int err = SSL_get_error(soap->ssl, ret); - const char *msg = soap_str_code(h_ssl_error_codes, err); - if (msg) - strcpy(soap->msgbuf, msg); - else - return ERR_error_string(err, soap->msgbuf); - if (ERR_peek_error()) - { unsigned long r; - strcat(soap->msgbuf, "\n"); - while ((r = ERR_get_error())) - ERR_error_string_n(r, soap->msgbuf + strlen(soap->msgbuf), sizeof(soap->msgbuf) - strlen(soap->msgbuf)); - } - else - { switch (ret) - { case 0: - strcpy(soap->msgbuf, "EOF was observed that violates the protocol. The client probably provided invalid authentication information."); - break; - case -1: - sprintf(soap->msgbuf, "Error observed by underlying BIO: %s", strerror(errno)); - break; - } - } - return soap->msgbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_password(char *buf, int num, int rwflag, void *userdata) -{ if (num < (int)strlen((char*)userdata) + 1) - return 0; - return strlen(strcpy(buf, (char*)userdata)); -} -#endif - -/******************************************************************************/ -/* This callback is included for future references. It should not be deleted -#ifndef PALM_1 -static DH * -ssl_tmp_dh(SSL *ssl, int is_export, int keylength) -{ static DH *dh512 = NULL; - static DH *dh1024 = NULL; - DH *dh; - switch (keylength) - { case 512: - if (!dh512) - { BIO *bio = BIO_new_file("dh512.pem", "r"); - if (bio) - { dh512 = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - return dh512; - } - } - else - return dh512; - default: - if (!dh1024) - { BIO *bio = BIO_new_file("dh1024.pem", "r"); - if (bio) - { dh1024 = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - } - } - dh = dh1024; - } - return dh; -} -#endif -*/ -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_auth_init(struct soap *soap) -{ ssl_init(); - if (!soap->ctx) - if (!(soap->ctx = SSL_CTX_new(SSLv23_method()))) - return soap_set_receiver_error(soap, "SSL error", "Can't setup context", SOAP_SSL_ERROR); - if (soap->randfile) - { if (!RAND_load_file(soap->randfile, -1)) - return soap_set_receiver_error(soap, "SSL error", "Can't load randomness", SOAP_SSL_ERROR); - } - if (soap->cafile || soap->capath) - if (!SSL_CTX_load_verify_locations(soap->ctx, soap->cafile, soap->capath)) - return soap_set_receiver_error(soap, "SSL error", "Can't read CA file and/or directory", SOAP_SSL_ERROR); - if (!SSL_CTX_set_default_verify_paths(soap->ctx)) - return soap_set_receiver_error(soap, "SSL error", "Can't read default CA file and/or directory", SOAP_SSL_ERROR); - if (soap->keyfile) - { if (!SSL_CTX_use_certificate_chain_file(soap->ctx, soap->keyfile)) - return soap_set_receiver_error(soap, "SSL error", "Can't read certificate key file", SOAP_SSL_ERROR); - if (soap->password) - { SSL_CTX_set_default_passwd_cb_userdata(soap->ctx, (void*)soap->password); - SSL_CTX_set_default_passwd_cb(soap->ctx, ssl_password); - if (!SSL_CTX_use_PrivateKey_file(soap->ctx, soap->keyfile, SSL_FILETYPE_PEM)) - return soap_set_receiver_error(soap, "SSL error", "Can't read key file", SOAP_SSL_ERROR); - } - } - if (soap->rsa) - { RSA *rsa = RSA_generate_key(512, RSA_F4, NULL, NULL); - if (!SSL_CTX_set_tmp_rsa(soap->ctx, rsa)) - { if (rsa) - RSA_free(rsa); - return soap_set_receiver_error(soap, "SSL error", "Can't set RSA key", SOAP_SSL_ERROR); - } - RSA_free(rsa); - } - else if (soap->dhfile) - { DH *dh = 0; - BIO *bio; - bio = BIO_new_file(soap->dhfile, "r"); - if (!bio) - return soap_set_receiver_error(soap, "SSL error", "Can't read DH file", SOAP_SSL_ERROR); - dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - if (SSL_CTX_set_tmp_dh(soap->ctx, dh) < 0) - { if (dh) - DH_free(dh); - return soap_set_receiver_error(soap, "SSL error", "Can't set DH parameters", SOAP_SSL_ERROR); - } - DH_free(dh); - } - SSL_CTX_set_options(soap->ctx, SSL_OP_ALL | SSL_OP_NO_SSLv2); - SSL_CTX_set_verify(soap->ctx, soap->require_client_auth ? (SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT) : soap->require_server_auth ? SSL_VERIFY_PEER : SSL_VERIFY_NONE, soap->fsslverify); -#if (OPENSSL_VERSION_NUMBER < 0x00905100L) - SSL_CTX_set_verify_depth(soap->ctx, 1); -#else - SSL_CTX_set_verify_depth(soap->ctx, 9); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_verify_callback(int ok, X509_STORE_CTX *store) -{ -#ifdef SOAP_DEBUG - if (!ok) - { char data[256]; - X509 *cert = X509_STORE_CTX_get_current_cert(store); - fprintf(stderr, "SSL Verify error with certificate at depth %d: %s\n", X509_STORE_CTX_get_error_depth(store), X509_verify_cert_error_string(X509_STORE_CTX_get_error(store))); - X509_NAME_oneline(X509_get_issuer_name(cert), data, sizeof(data)); - fprintf(stderr, "certificate issuer %s\n", data); - X509_NAME_oneline(X509_get_subject_name(cert), data, sizeof(data)); - fprintf(stderr, "certificate subject %s\n", data); - } -#endif - /* return 1 to always continue, but unsafe progress will be terminated by SSL */ - return ok; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_accept(struct soap *soap) -{ int i, r; - if (!soap_valid_socket(soap->socket)) - return soap_set_receiver_error(soap, "SSL error", "No socket in soap_ssl_accept()", SOAP_SSL_ERROR); - if (!soap->ssl) - { soap->ssl = SSL_new(soap->ctx); - if (!soap->ssl) - return soap_set_receiver_error(soap, "SSL error", "SSL_new() failed in soap_ssl_accept()", SOAP_SSL_ERROR); - } - else - SSL_clear(soap->ssl); - soap->imode |= SOAP_ENC_SSL; - soap->omode |= SOAP_ENC_SSL; -#ifdef WIN32 - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &nonblocking); - } -#else - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)|O_NONBLOCK); -#endif - soap->bio = BIO_new_socket((SOAP_SOCKET)soap->socket, BIO_NOCLOSE); - SSL_set_bio(soap->ssl, soap->bio, soap->bio); - i = 100; /* 100 * 0.1 ms retries */ - while ((r = SSL_accept(soap->ssl)) <= 0) - { int err = SSL_get_error(soap->ssl, r); - if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) - { struct timeval timeout; - fd_set fd; - if (i-- <= 0) - break; - timeout.tv_sec = 0; - timeout.tv_usec = 100000; - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r < 0 && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - } - else - { soap->errnum = err; - break; - } - } -#ifdef WIN32 - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &blocking); - } -#else - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)&~O_NONBLOCK); -#endif - if (r <= 0) - { soap_set_receiver_error(soap, ssl_error(soap, r), "SSL_accept() failed in soap_ssl_accept()", SOAP_SSL_ERROR); - soap_closesock(soap); - return SOAP_SSL_ERROR; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#endif /* WITH_OPENSSL */ - -/******************************************************************************/ -#ifndef PALM_1 -static int -tcp_init(struct soap *soap) -{ soap->errmode = 1; -#ifdef WIN32 - if (tcp_done) - return 0; - else - { WSADATA w; - if (WSAStartup(MAKEWORD(1, 1), &w)) - return -1; - tcp_done = 1; - } -#endif -#ifdef PALM - errno = 0; - h_errno = 0; - AppNetRefnum = 0; - NetUInit(); - AppNetTimeout = 10000; - NetLibOpen(AppNetRefnum, &h_errno); -#endif - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_done(struct soap *soap) -{ -#ifdef SOAP_DEBUG - int i; -#endif - soap_free(soap); - while (soap->clist) - { struct soap_clist *p = soap->clist->next; - SOAP_FREE(soap->clist); - soap->clist = p; - } - soap->keep_alive = 0; /* to force close the socket */ - soap_closesock(soap); -#ifdef WITH_COOKIES - soap_free_cookies(soap); -#endif - while (soap->plugins) - { register struct soap_plugin *p = soap->plugins->next; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Removing plugin '%s'\n", soap->plugins->id)); - if (soap->plugins->fcopy || !soap->copy) - soap->plugins->fdelete(soap, soap->plugins); - SOAP_FREE(soap->plugins); - soap->plugins = p; - } - soap->fplugin = fplugin; - soap->fpost = http_post; - soap->fget = http_get; - soap->fposthdr = http_post_header; - soap->fresponse = http_response; - soap->fparse = http_parse; - soap->fparsehdr = http_parse_header; -#ifndef MAC_CARBON -#ifndef WITH_IPV6 - soap->fresolve = tcp_gethost; -#else - soap->fresolve = NULL; -#endif - soap->faccept = tcp_accept; - soap->fopen = tcp_connect; - soap->fclose = tcp_disconnect; - soap->fclosesocket = tcp_closesocket; - soap->fshutdownsocket = tcp_shutdownsocket; - soap->fsend = fsend; - soap->frecv = frecv; - soap->fpoll = soap_poll; -#else - soap->fpoll = NULL; -#endif - soap->fprepareinit = NULL; - soap->fpreparesend = NULL; - soap->fpreparerecv = NULL; - soap->fignore = NULL; - soap->fserveloop = NULL; -#ifdef WITH_OPENSSL - if (soap->session) - { SSL_SESSION_free(soap->session); - soap->session = NULL; - } -#endif - if (!soap->copy) - { if (soap_valid_socket(soap->master)) - { soap->fclosesocket(soap, (SOAP_SOCKET)soap->master); - soap->master = SOAP_INVALID_SOCKET; - } -#ifdef WITH_OPENSSL - if (soap->ctx) - { SSL_CTX_free(soap->ctx); - soap->ctx = NULL; - } -#endif - } -#ifdef SOAP_DEBUG - for (i = 0; i < SOAP_MAXLOGS; i++) - { soap_close_logfile(soap, i); - if (soap->logfile[i]) - { SOAP_FREE((void*)soap->logfile[i]); - soap->logfile[i] = NULL; - } - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_cleanup(struct soap *soap) -{ soap_done(soap); -#ifdef WIN32 - if (!tcp_done) - return; - tcp_done = 0; - WSACleanup(); -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -tcp_error(struct soap *soap) -{ register const char *msg = NULL; - switch (soap->errmode) - { case 0: - msg = soap_strerror(soap); - break; - case 1: - msg = "WSAStartup failed"; - break; - case 2: - { -#ifndef WITH_LEAN - msg = soap_str_code(h_error_codes, soap->errnum); - if (!msg) -#endif - { sprintf(soap->msgbuf, "TCP error %d", soap->errnum); - msg = soap->msgbuf; - } - } - } - return msg; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -http_error(struct soap *soap, int status) -{ register const char *msg = NULL; -#ifndef WITH_LEAN - msg = soap_str_code(h_http_error_codes, status); - if (!msg) -#endif - { sprintf(soap->msgbuf, "HTTP error %d", status); - msg = soap->msgbuf; - } - return msg; -} -#endif - -/******************************************************************************/ -/* WR[ */ -#ifndef WITH_IPV6 -/* ]WR */ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_gethost(struct soap *soap, const char *addr, struct in_addr *inaddr) -{ unsigned long iadd; - struct hostent hostent, *host = &hostent; -/* WR[ */ -#ifdef VXWORKS - int hostint; - char *addrcopy = (char*)malloc(strlen(addr) + 1); /*copy of addr. */ - /* inet_addr(), and hostGetByName() expect "char *"; addr is a "const char *". */ - strncpy(addrcopy, addr, strlen(addr)+1); - iadd = inet_addr(addrcopy); -#else -/* ]WR */ -#if defined(_AIXVERSION_431) || defined(TRU64) - struct hostent_data ht_data; -#endif - iadd = inet_addr(addr); -/* WR[ */ -#endif -/* ]WR */ - if ((int)iadd != -1) - { memcpy(inaddr, &iadd, sizeof(iadd)); -/* WR[ */ -#ifdef VXWORKS - free(addrcopy); -#endif -/* ]WR */ - return SOAP_OK; - } -#if defined(__GLIBC__) - if (gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &host, &soap->errnum) < 0) - host = NULL; -#elif defined(_AIXVERSION_431) || defined(TRU64) - memset((void*)&ht_data, 0, sizeof(ht_data)); - if (gethostbyname_r(addr, &hostent, &ht_data) < 0) - { host = NULL; - soap->errnum = h_errno; - } -#elif defined(HAVE_GETHOSTBYNAME_R) - host = gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &soap->errnum); -/* WR[ */ -#elif defined(VXWORKS) - /* If the DNS resolver library resolvLib has been configured in the vxWorks - * image, a query for the host IP address is sent to the DNS server, if the - * name was not found in the local host table. */ - hostint = hostGetByName(addrcopy); - if (hostint == ERROR) - { host = NULL; - soap->errnum = soap_errno; - } - free(addrcopy); /*free() is placed after the error checking to assure that - * errno captured is that from hostGetByName() */ -/* ]WR */ -#else - if (!(host = gethostbyname(addr))) - soap->errnum = h_errno; -#endif - if (!host) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Host name not found\n")); - return SOAP_ERR; - } -/* WR[ */ -#ifdef VXWORKS - inaddr->s_addr = hostint; -#else -/* ]WR */ - memcpy(inaddr, host->h_addr, host->h_length); -/* WR[ */ -#endif -/* ]WR */ - return SOAP_OK; -} -#endif -#endif -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_connect(struct soap *soap, const char *endpoint, const char *host, int port) -{ struct sockaddr_in sockaddr; -/* WR[ */ -#ifdef WITH_IPV6 - struct addrinfo *addrinfo; - struct addrinfo hints; - struct addrinfo resaddr; - struct sockaddr_storage addrstorage; - int err; -#endif /* WITH_IPV6 */ -/* ]WR */ - register int fd; -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - if (soap_valid_socket(soap->socket)) - soap->fclosesocket(soap, (SOAP_SOCKET)soap->socket); - soap->socket = SOAP_INVALID_SOCKET; - if (tcp_init(soap)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP initialization failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - soap->errmode = 0; -/* WR[ */ -#ifdef WITH_IPV6 - memset((void*)&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - soap->errmode = 2; - if (soap->proxy_host) - err = getaddrinfo(soap->proxy_host, soap_int2s(soap, soap->proxy_port), &hints, &addrinfo); - else - err = getaddrinfo(host, soap_int2s(soap, port), &hints, &addrinfo); - if (addrinfo) - { resaddr = *addrinfo; - addrstorage = *((struct sockaddr_storage *) addrinfo->ai_addr); - resaddr.ai_addr = (struct sockaddr *) &addrstorage; - freeaddrinfo(addrinfo); - } - if (err) - { soap_set_sender_error(soap, gai_strerror(err), - "TCP getaddrinfo on proxy host failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - fd = (int)socket(resaddr.ai_family, resaddr.ai_socktype, resaddr.ai_protocol); /* modified to use fd */ - soap->errmode = 0; -#else /* WITH_IPV6 */ -/* ]WR */ - fd = (int)socket(AF_INET, SOCK_STREAM, 0); -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - if (fd < 0) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP socket failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } -#ifdef SOCKET_CLOSE_ON_EXEC -#ifdef WIN32 -#ifndef UNDER_CE - SetHandleInformation((HANDLE)fd, HANDLE_FLAG_INHERIT, 0); -#endif -#else - fcntl (fd, F_SETFD, 1); -#endif -#endif -#ifndef WITH_LEAN - if (soap->connect_flags & SO_LINGER) - { struct linger linger; - memset((void*)&linger, 0, sizeof(linger)); - linger.l_onoff = 1; - linger.l_linger = 0; - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_LINGER failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - } - if ((soap->connect_flags & ~SO_LINGER) && setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, soap->connect_flags & ~SO_LINGER, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)fd, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } -#endif -#endif -/* WR[ */ -#ifndef WITH_IPV6 -/* ]WR */ - memset((void*)&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin_family = AF_INET; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Open socket %d to host='%s'\n", fd, host)); - soap->errmode = 2; - if (soap->proxy_host) - { if (soap->fresolve(soap, soap->proxy_host, &sockaddr.sin_addr)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP get proxy host by name failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - sockaddr.sin_port = htons((short)soap->proxy_port); - } - else - { if (soap->fresolve(soap, host, &sockaddr.sin_addr)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP get host by name failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - sockaddr.sin_port = htons((short)port); - } - soap->errmode = 0; -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifndef WITH_LEAN - if (soap->connect_timeout) -#if defined(WIN32) - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &nonblocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { vx_nonblocking = TRUE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)|O_NONBLOCK); -#endif - else -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - for (;;) - { -/* WR[ */ -#ifdef WITH_IPV6 - if (connect((SOAP_SOCKET)fd, resaddr.ai_addr, resaddr.ai_addrlen)) /* modified to use fd */ -#else /* WITH_IPV6 */ - if (connect((SOAP_SOCKET)fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr))) -#endif /* WITH_IPV6 */ -/* ]WR */ - { -#ifndef WITH_LEAN - if (soap->connect_timeout && (soap_socket_errno == SOAP_EINPROGRESS || soap_socket_errno == SOAP_EWOULDBLOCK)) - { struct timeval timeout; -#if defined(SOCKLEN_T) - SOCKLEN_T n = sizeof(struct sockaddr_in); -#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) - socklen_t n = sizeof(struct sockaddr_in); -#elif defined(WIN32) || defined(__APPLE__) || defined(HP_UX) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) - int n = sizeof(struct sockaddr_in); -#else - size_t n = sizeof(struct sockaddr_in); -#endif - fd_set fds; - if (soap->connect_timeout > 0) - { timeout.tv_sec = soap->connect_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->connect_timeout/1000000; - timeout.tv_usec = -soap->connect_timeout%1000000; - } - FD_ZERO(&fds); - FD_SET((SOAP_SOCKET)fd, &fds); - for (;;) - { int r = select((SOAP_SOCKET)(fd + 1), NULL, &fds, NULL, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect timeout\n")); - soap_set_sender_error(soap, "Timeout", "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - } - n = sizeof(soap->errnum); - if (!getsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_ERROR, (char*)&soap->errnum, &n) && !soap->errnum) - break; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - else -#endif - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - } - else - break; - } -#ifndef WITH_LEAN - if (soap->connect_timeout) -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - soap->socket = fd; -#ifdef WITH_OPENSSL - soap->imode &= ~SOAP_ENC_SSL; - soap->omode &= ~SOAP_ENC_SSL; - if (!strncmp(endpoint, "https:", 6)) - { int r; - if (soap->proxy_host) - { unsigned int k = soap->omode; /* make sure we only parse HTTP */ - size_t n = soap->count; /* save the content length */ - soap->omode &= ~0xFF; /* mask IO and ENC */ - soap->omode |= SOAP_IO_BUFFER; - soap_begin_send(soap); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connecting to proxy server\n")); - sprintf(soap->tmpbuf, "CONNECT %s:%d HTTP/%s", host, port, soap->http_version); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return -1; -#ifndef WITH_LEAN - if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((soap->error = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) - return soap->error; - } -#endif - if ((soap->error = soap->fposthdr(soap, NULL, NULL)) - || soap_flush(soap)) - return -1; - soap->omode = k; - k = soap->imode; - soap->imode &= ~0xFF; /* mask IO and ENC */ - if (soap_begin_recv(soap)) - return -1; - soap->imode = k; - soap->count = n; - soap_begin_send(soap); - } - if (!soap->ctx && (soap->error = soap->fsslauth(soap))) - { soap_set_sender_error(soap, "SSL error", "SSL authentication failed in tcp_connect(): check password, key file, and ca file.", SOAP_SSL_ERROR); - return -1; - } - soap->ssl = SSL_new(soap->ctx); - if (!soap->ssl) - { soap->error = SOAP_SSL_ERROR; - return -1; - } - if (soap->session) - { if (!strcmp(soap->session_host, host) && soap->session_port == port) - SSL_set_session(soap->ssl, soap->session); - SSL_SESSION_free(soap->session); - soap->session = NULL; - } - soap->imode |= SOAP_ENC_SSL; - soap->omode |= SOAP_ENC_SSL; - soap->bio = BIO_new_socket((SOAP_SOCKET)fd, BIO_NOCLOSE); - SSL_set_bio(soap->ssl, soap->bio, soap->bio); -#ifndef WITH_LEAN - if (soap->connect_timeout) -#ifdef WIN32 - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &nonblocking); - } -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)|O_NONBLOCK); -#endif -#endif - for (;;) - { if ((r = SSL_connect(soap->ssl)) <= 0) - { int err = SSL_get_error(soap->ssl, r); - if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - { soap_set_sender_error(soap, ssl_error(soap, r), "SSL connect failed in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - if (soap->connect_timeout) - { struct timeval timeout; - fd_set fds; - if (soap->connect_timeout > 0) - { timeout.tv_sec = soap->connect_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->connect_timeout/1000000; - timeout.tv_usec = -soap->connect_timeout%1000000; - } - FD_ZERO(&fds); - FD_SET((SOAP_SOCKET)(soap->socket), &fds); - for (;;) - { int r = select((SOAP_SOCKET)(soap->socket + 1), &fds, NULL, &fds, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect timeout\n")); - soap_set_sender_error(soap, "Timeout", "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - } - continue; - } - } - break; - } -#ifndef WITH_LEAN - if (soap->connect_timeout) -#ifdef WIN32 - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - if (soap->require_server_auth) - { X509 *peer; - int err; - if ((err = SSL_get_verify_result(soap->ssl)) != X509_V_OK) - { soap_set_sender_error(soap, X509_verify_cert_error_string(err), "SSL certificate cannot be verified in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - peer = SSL_get_peer_certificate(soap->ssl); - if (!peer) - { soap_set_sender_error(soap, "SSL error", "No SSL certificate was presented by the peer in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - X509_NAME_get_text_by_NID(X509_get_subject_name(peer), NID_commonName, soap->msgbuf, sizeof(soap->msgbuf)); - X509_free(peer); - if (soap_tag_cmp(soap->msgbuf, host)) - { soap_set_sender_error(soap, "SSL error", "SSL certificate host name mismatch in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - } - } -#endif - return fd; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_bind(struct soap *soap, const char *host, int port, int backlog) -{ struct sockaddr_in sockaddr; -/* WR[ */ -#ifdef WITH_IPV6 - struct addrinfo *addrinfo; - struct addrinfo hints; - struct addrinfo resaddr; - struct sockaddr_storage addrstorage; - int err; -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - if (soap_valid_socket(soap->master)) - { soap->fclosesocket(soap, (SOAP_SOCKET)soap->master); - soap->master = SOAP_INVALID_SOCKET; - } - soap->socket = SOAP_INVALID_SOCKET; - soap->errmode = 1; - if (tcp_init(soap)) - { soap_set_receiver_error(soap, tcp_error(soap), "TCP init failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#ifdef WITH_IPV6 - memset((void*)&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; - soap->errmode = 2; - if (host) - err = getaddrinfo(host, soap_int2s(soap, port), &hints, &addrinfo); - else - err = getaddrinfo(NULL, soap_int2s(soap, port), &hints, &addrinfo); - if (NULL != addrinfo) - { - resaddr = *addrinfo; - addrstorage = *((struct sockaddr_storage *) addrinfo->ai_addr); - resaddr.ai_addr = (struct sockaddr *) &addrstorage; - freeaddrinfo(addrinfo); - } - if (err) - { soap_set_receiver_error(soap, gai_strerror(err), "TCP getaddrinfo failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - soap->errmode = 0; - if ((soap->master = socket(resaddr.ai_family, resaddr.ai_socktype, resaddr.ai_protocol)) < 0) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP socket failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#else /* WITH_IPV6 */ -/* ]WR */ - soap->errmode = 0; - if ((soap->master = (int)socket(AF_INET, SOCK_STREAM, 0)) < 0) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP socket failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifdef SOCKET_CLOSE_ON_EXEC -#ifdef WIN32 -#ifndef UNDER_CE - SetHandleInformation((HANDLE)soap->master, HANDLE_FLAG_INHERIT, 0); -#endif -#else - fcntl (soap->master, F_SETFD, 1); -#endif -#endif -#ifndef WITH_LEAN - if (soap->bind_flags && setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, soap->bind_flags, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)soap->master, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#endif -#endif -/* WR[ */ -#ifdef WITH_IPV6 - soap->errmode = 0; - if (bind(soap->master, resaddr.ai_addr, resaddr.ai_addrlen) || listen(soap->master, backlog)) - { - soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n")); - soap_closesock(soap); - soap_set_receiver_error(soap, tcp_error(soap), "TCP bind failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#else /* WITH_IPV6 */ -/* ]WR */ - memset((void*)&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin_family = AF_INET; - soap->errmode = 2; - if (host) - { if (soap->fresolve(soap, host, &sockaddr.sin_addr)) - { soap_set_receiver_error(soap, tcp_error(soap), "TCP get host by name failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - } - else - sockaddr.sin_addr.s_addr = htonl(INADDR_ANY); - sockaddr.sin_port = htons((short)port); - soap->errmode = 0; - if (bind((SOAP_SOCKET)soap->master, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) || listen((SOAP_SOCKET)soap->master, backlog)) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n")); - soap_closesock(soap); - soap_set_receiver_error(soap, tcp_error(soap), "TCP bind failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifdef WITH_OPENSSL - if (!soap->ctx && (soap->error = soap->fsslauth(soap))) - return -1; -#endif - return soap->master; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_poll(struct soap *soap) -{ -#ifndef WITH_LEAN - struct timeval timeout; - fd_set sfd,rfd; - int r; - timeout.tv_sec = 0; - timeout.tv_usec = 0; - FD_ZERO(&rfd); - FD_ZERO(&sfd); - if (soap->socket >= 0) - { FD_SET(soap->socket, &rfd); - FD_SET(soap->socket, &sfd); - r = select(soap->socket + 1, &rfd, &sfd, NULL, &timeout); - } - else if (soap->master >= 0) - { FD_SET(soap->master, &rfd); - r = select(soap->master + 1, &rfd, &sfd, NULL, &timeout); - } - else - { FD_SET(soap->sendfd, &sfd); - FD_SET(soap->recvfd, &rfd); - r = select((soap->sendfd > soap->recvfd ? soap->sendfd : soap->recvfd) + 1, &rfd, &sfd, NULL, &timeout); - } - if (r > 0) - { -#ifdef WITH_OPENSSL - if (soap->ssl) - { if ((soap->socket >= 0) && FD_ISSET(soap->socket, &rfd)) - { char buf = '\0'; - if (SSL_peek(soap->ssl, &buf, 1) <= 0) - return SOAP_EOF; - } - } -#endif - return SOAP_OK; - } - if (r < 0 && (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "select failed in soap_poll()", SOAP_TCP_ERROR); - return soap->error = SOAP_TCP_ERROR; - } - else - soap->errnum = soap_errno; - return SOAP_EOF; -#else - return SOAP_OK; -#endif -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_accept(struct soap *soap, int s, struct sockaddr *a, int *n) -{ int fd; -#if defined(SOCKLEN_T) - fd = (int)accept((SOAP_SOCKET)s, a, (SOCKLEN_T*)n); -#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) - fd = (int)accept((SOAP_SOCKET)s, a, (socklen_t*)n); -#elif defined(WIN32) || defined(__APPLE__) || defined(HP_UX) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) - fd = (int)accept((SOAP_SOCKET)s, a, n); -#else - fd = (int)accept((SOAP_SOCKET)s, a, (size_t*)n); -#endif -#ifdef SOCKET_CLOSE_ON_EXEC -#ifdef WIN32 -#ifndef UNDER_CE - SetHandleInformation((HANDLE)fd, HANDLE_FLAG_INHERIT, 0); -#endif -#else - fcntl(fd, F_SETFD, FD_CLOEXEC); -#endif -#endif - return fd; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_accept(struct soap *soap) -{ -/* WR[ */ -#ifdef WITH_IPV6 - struct sockaddr_storage sockaddr; -#else /* WITH_IPV6 */ -/* ]WR */ - struct sockaddr_in sockaddr; -/* WR[ */ -#endif -/* ]WR */ - int n = (int)sizeof(struct sockaddr); -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - soap->error = SOAP_OK; - memset((void*)&sockaddr, 0, sizeof(sockaddr)); - soap->socket = SOAP_INVALID_SOCKET; - soap->errmode = 0; - if (soap_valid_socket(soap->master)) - { for (;;) - { -#ifndef WITH_LEAN - if (soap->accept_timeout) - { struct timeval timeout; - fd_set fd; - if (soap->accept_timeout > 0) - { timeout.tv_sec = soap->accept_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->accept_timeout/1000000; - timeout.tv_usec = -soap->accept_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->master, &fd); - for (;;) - { int r = select((SOAP_SOCKET)(soap->master + 1), &fd, &fd, NULL, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - soap_set_receiver_error(soap, "Timeout", "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - soap_closesock(soap); - soap_set_sender_error(soap, tcp_error(soap), "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } -#if defined(WIN32) - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &nonblocking); - } -#elif defined(VXWORKS) - { vx_nonblocking = TRUE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - } -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)|O_NONBLOCK); -#endif - } - else -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)&~O_NONBLOCK); -#endif -#endif - if ((soap->socket = soap->faccept(soap, soap->master, (struct sockaddr*)&sockaddr, &n)) >= 0) - { -/* WR[ */ -#ifdef WITH_IPV6 -/* Use soap->host to store the numeric form of the remote host */ - getnameinfo((struct sockaddr*)&sockaddr, n, soap->host, sizeof(soap->host), NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV); - soap->ip = 0; /* info stored in soap->host */ - soap->port = 0; /* info stored in soap->host */ -#else /* WITH_IPV6 */ -/* ]WR */ - soap->ip = ntohl(sockaddr.sin_addr.s_addr); - soap->port = (int)ntohs(sockaddr.sin_port); -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - soap->keep_alive = ((soap->imode & SOAP_IO_KEEPALIVE) != 0); -#ifndef WITH_LEAN - if (soap->accept_flags & SO_LINGER) - { struct linger linger; - memset((void*)&linger, 0, sizeof(linger)); - linger.l_onoff = 1; - linger.l_linger = 0; - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_LINGER failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } - if ((soap->accept_flags & ~SO_LINGER) && setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, soap->accept_flags & ~SO_LINGER, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)soap->socket, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -#endif -#endif - if (soap->accept_timeout) - { -#if defined(WIN32) - u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &blocking); - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &blocking); -/* WR[ */ -#elif defined(VXWORKS) - vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - ioctl((SOAP_SOCKET)soap->socket, FIONBIO, (int)(&vx_nonblocking)); -/* ]WR */ -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)&~O_NONBLOCK); - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)&~O_NONBLOCK); -#endif - } - return soap->socket; - } - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } - } - else - { soap_set_receiver_error(soap, tcp_error(soap), "TCP no master socket in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_disconnect(struct soap *soap) -{ -#ifdef WITH_OPENSSL - if (soap->ssl) - { int r, s = 0; - if (soap->session) - SSL_SESSION_free(soap->session); - if (*soap->host) - { soap->session = SSL_get1_session(soap->ssl); - if (soap->session) - { strcpy(soap->session_host, soap->host); - soap->session_port = soap->port; - } - } - r = SSL_shutdown(soap->ssl); - if (r != 1) - { s = ERR_get_error(); - if (s) - { if (soap_valid_socket(soap->socket)) - { soap->fshutdownsocket(soap, (SOAP_SOCKET)soap->socket, 1); - soap->socket = SOAP_INVALID_SOCKET; - } - r = SSL_shutdown(soap->ssl); - } - } - DBGLOG(TEST, if (s) SOAP_MESSAGE(fdebug, "Shutdown failed: %d\n", SSL_get_error(soap->ssl, r))); - SSL_free(soap->ssl); - soap->ssl = NULL; - if (s) - return SOAP_SSL_ERROR; - ERR_remove_state(0); - } -#endif - if (soap_valid_socket(soap->socket)) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Closing socket %d\n", soap->socket)); - soap->fshutdownsocket(soap, (SOAP_SOCKET)soap->socket, 2); - soap->fclosesocket(soap, (SOAP_SOCKET)soap->socket); - soap->socket = SOAP_INVALID_SOCKET; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_closesocket(struct soap *soap, SOAP_SOCKET fd) -{ return closesocket(fd); -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_shutdownsocket(struct soap *soap, SOAP_SOCKET fd, int how) -{ return shutdown(fd, how); -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_closesock(struct soap *soap) -{ register int status = soap->error; -#ifndef MAC_CARBON - if (status == SOAP_EOF || status == SOAP_TCP_ERROR || status == SOAP_SSL_ERROR || !soap->keep_alive) - { if ((soap->error = soap->fclose(soap))) - return soap->error; - soap->socket = SOAP_INVALID_SOCKET; - } -#endif -#ifdef WITH_ZLIB - if (soap->zlib_state == SOAP_ZLIB_DEFLATE) - deflateEnd(&soap->d_stream); - else if (soap->zlib_state == SOAP_ZLIB_INFLATE) - inflateEnd(&soap->d_stream); - soap->zlib_state = SOAP_ZLIB_NONE; -#endif - return soap->error = status; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_hash(register const char *s) -{ register size_t h = 0; - while (*s) - h = 65599*h + *s++; - return h % SOAP_IDHASH; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_init_pht(struct soap *soap) -{ register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing pointer hashtable\n")); - for (i = 0; i < (int)SOAP_PTRHASH; i++) - soap->pht[i] = NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new() -{ struct soap *soap = (struct soap*)SOAP_MALLOC(sizeof(struct soap)); - if (soap) - soap_init(soap); - return soap; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new1(int mode) -{ return soap_new2(mode, mode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new2(int imode, int omode) -{ struct soap *soap = (struct soap*)SOAP_MALLOC(sizeof(struct soap)); - if (soap) - soap_init2(soap, imode, omode); - return soap; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static void -soap_free_pht(struct soap *soap) -{ register struct soap_plist *pp, *next; - register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free pointer hashtable\n")); - for (i = 0; i < (int)SOAP_PTRHASH; i++) - { for (pp = soap->pht[i]; pp; pp = next) - { next = pp->next; - SOAP_FREE(pp); - } - soap->pht[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_embed(struct soap *soap, const void *p, const struct soap_array *a, int n, const char *tag, int type) -{ register int i; - struct soap_plist *pp; - if (soap->version != 1) - soap->encoding = 1; - if (a) - i = soap_array_pointer_lookup(soap, p, a, n, type, &pp); - else - i = soap_pointer_lookup(soap, p, type, &pp); - if (i) - { if (soap_is_embedded(soap, pp) - || soap_is_single(soap, pp)) - return 0; - soap_set_embedded(soap, pp); - } - return i; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pointer_lookup(struct soap *soap, const void *p, int type, struct soap_plist **ppp) -{ register struct soap_plist *pp; - *ppp = NULL; - if (p) - for (pp = soap->pht[soap_hash_ptr(p)]; pp; pp = pp->next) - if (pp->ptr == p && pp->type == type) - { *ppp = pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup location=%p type=%d id=%d\n", p, type, pp->id)); - return pp->id; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup location=%p type=%d: not found\n", p, type)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pointer_enter(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp) -{ register int h; - register struct soap_plist *pp = *ppp = (struct soap_plist*)SOAP_MALLOC(sizeof(struct soap_plist)); - if (!pp) - return 0; - if (a) - h = soap_hash_ptr(a->__ptr); - else - h = soap_hash_ptr(p); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pointer enter location=%p array=%p size=%d dim=%d type=%d id=%lu\n", p, a?a->__ptr:NULL, a?a->__size:0, n, type, soap->idnum+1)); - pp->next = soap->pht[h]; - pp->type = type; - pp->mark1 = 0; - pp->mark2 = 0; - pp->ptr = p; - pp->array = a; - soap->pht[h] = pp; - pp->id = ++soap->idnum; - return pp->id; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_pointer_lookup(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp) -{ register struct soap_plist *pp; - *ppp = NULL; - if (!p || !a->__ptr) - return 0; - for (pp = soap->pht[soap_hash_ptr(a->__ptr)]; pp; pp = pp->next) - { if (pp->type == type && pp->array && pp->array->__ptr == a->__ptr) - { register int i; - for (i = 0; i < n; i++) - if (((const int*)&pp->array->__size)[i] != ((const int*)&a->__size)[i]) - break; - if (i == n) - { *ppp = pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d id=%d\n", a->__ptr, type, pp->id)); - return pp->id; - } - } - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d: not found\n", a->__ptr, type)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_begin_count(struct soap *soap) -{ soap_clr_attr(soap); - soap_set_local_namespaces(soap); -#ifndef WITH_LEANER - if ((soap->mode & SOAP_ENC_DIME) || (soap->omode & SOAP_ENC_DIME)) - soap->mode = soap->omode | SOAP_IO_LENGTH | SOAP_ENC_DIME; - else -#endif - { soap->mode = soap->omode; - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE - || (((soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_ENC_XML)) && !soap->fpreparesend)) - soap->mode &= ~SOAP_IO_LENGTH; - else - soap->mode |= SOAP_IO_LENGTH; - } - if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH) - { if (!(soap->mode & SOAP_ENC_DIME)) - soap->mode &= ~SOAP_IO_LENGTH; - if (soap->mode & SOAP_ENC_XML) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - if (!soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH)) - soap->mode |= SOAP_XML_TREE; -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_MIME) - soap_select_mime_boundary(soap); - soap->dime.list = soap->dime.last; /* keep track of last DIME attachment */ -#endif - soap->count = 0; - soap->ns = 0; - soap->null = 0; - soap->position = 0; - soap->mustUnderstand = 0; - soap->encoding = 0; - soap->part = SOAP_BEGIN; - soap->idnum = 0; - soap->dime.count = 0; /* count # of attachments */ - soap->dime.size = 0; /* accumulate total size of attachments */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin count phase (socket=%d mode=%x count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count)); - if (soap->fprepareinit && (soap->mode & SOAP_IO) != SOAP_IO_STORE) - soap->fprepareinit(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_begin_send(struct soap *soap) -{ soap->error = SOAP_OK; - soap_clr_attr(soap); - soap_set_local_namespaces(soap); - soap->mode = (soap->omode & ~SOAP_IO_LENGTH) | (soap->mode & SOAP_ENC_DIME); - if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH) - { if (soap->mode & SOAP_ENC_XML) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_FLUSH && soap_valid_socket(soap->socket)) - { if (soap->count || (soap->mode & SOAP_ENC_XML)) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - soap_new_block(soap); - if (!(soap->mode & SOAP_IO_KEEPALIVE)) - soap->keep_alive = 0; - if (!soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH)) - soap->mode |= SOAP_XML_TREE; -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_MIME) - soap_select_mime_boundary(soap); -#endif -#ifdef WIN32 -#ifndef UNDER_CE -#ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket)) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */ -#ifdef __BORLANDC__ - setmode((SOAP_SOCKET)soap->sendfd, O_BINARY); -#else - _setmode((SOAP_SOCKET)soap->sendfd, _O_BINARY); -#endif -#endif -#endif -#endif - if (soap->mode & SOAP_IO) - { soap->bufidx = 0; - soap->buflen = 0; - } - soap->chunksize = 0; - soap->ns = 0; - soap->null = 0; - soap->position = 0; - soap->mustUnderstand = 0; - soap->encoding = 0; - soap->part = SOAP_BEGIN; - soap->idnum = 0; - soap->level = 0; -#ifdef WITH_ZLIB - soap->z_ratio_out = 1.0; - if ((soap->mode & SOAP_ENC_ZLIB) && soap->zlib_state != SOAP_ZLIB_DEFLATE) - { -#ifdef WITH_GZIP - memcpy(soap->z_buf, "\37\213\10\0\0\0\0\0\0\377", 10); - soap->d_stream.next_out = (Byte*)soap->z_buf + 10; - soap->d_stream.avail_out = SOAP_BUFLEN - 10; - soap->z_crc = crc32(0L, NULL, 0); - if (deflateInit2(&soap->d_stream, soap->z_level, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK) -#else - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - if (deflateInit(&soap->d_stream, soap->z_level) != Z_OK) -#endif - return soap->error = SOAP_ZLIB_ERROR; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflate initialized\n")); - soap->zlib_state = SOAP_ZLIB_DEFLATE; - } -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin send phase (socket=%d mode=%x count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count)); - if (soap->fprepareinit && (soap->mode & SOAP_IO) == SOAP_IO_STORE) - soap->fprepareinit(soap); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_embedded(struct soap *soap, const void *p, int t) -{ struct soap_plist *pp; - if (soap_pointer_lookup(soap, p, t, &pp)) - { pp->mark1 = 1; - pp->mark2 = 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded %p type=%d mark set to 1\n", p, t)); - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_reference(struct soap *soap, const void *p, int t) -{ struct soap_plist *pp; - if (!p || (soap->mode & SOAP_XML_TREE)) - return 1; - if (soap_pointer_lookup(soap, p, t, &pp)) - { if (pp->mark1 == 0) - { pp->mark1 = 2; - pp->mark2 = 2; - } - } - else if (soap_pointer_enter(soap, p, NULL, 0, t, &pp)) - { pp->mark1 = 0; - pp->mark2 = 0; - } - else - return 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reference %p type=%d (%d %d)\n", p, t, (int)pp->mark1, (int)pp->mark2)); - return pp->mark1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_reference(struct soap *soap, const void *p, const struct soap_array *a, int n, int t) -{ register int i; - struct soap_plist *pp; - if (!p) - return 1; - i = soap_array_pointer_lookup(soap, p, a, n, t, &pp); - if (i) - { if (pp->mark1 == 0) - { pp->mark1 = 2; - pp->mark2 = 2; - } - } - else if (!soap_pointer_enter(soap, p, a, n, t, &pp)) - return 1; - else - { pp->mark1 = 0; - pp->mark2 = 0; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array reference %p ptr=%p dim=%d type=%d (%d %d)\n", p, a->__ptr, n, t, (int)pp->mark1, (int)pp->mark2)); - return pp->mark1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_embedded_id(struct soap *soap, int id, const void *p, int t) -{ struct soap_plist *pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id %p type=%d id=%d\n", p, t, id)); - if (soap->mode & SOAP_XML_TREE) - return id; - if (soap->version == 1 && soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH) && soap->part != SOAP_IN_HEADER) - { if (id < 0) - { id = soap_pointer_lookup(soap, p, t, &pp); - if (id) - { if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 2; - else - pp->mark2 = 2; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id multiref id=%d %p type=%d = (%d %d)\n", id, p, t, (int)pp->mark1, (int)pp->mark2)); - } - return -1; - } - return id; - } - if (id < 0) - id = soap_pointer_lookup(soap, p, t, &pp); - else if (id && !soap_pointer_lookup(soap, p, t, &pp)) - return 0; - if (id && pp) - { if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 1; - else - pp->mark2 = 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id embedded ref id=%d %p type=%d = (%d %d)\n", id, p, t, (int)pp->mark1, (int)pp->mark2)); - } - return id; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_is_embedded(struct soap *soap, struct soap_plist *pp) -{ if (!pp) - return 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Is embedded? %d %d\n", (int)pp->mark1, (int)pp->mark2)); - if (soap->version == 1 && soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH) && soap->part != SOAP_IN_HEADER) - { if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 != 0; - return pp->mark2 != 0; - } - if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 == 1; - return pp->mark2 == 1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_is_single(struct soap *soap, struct soap_plist *pp) -{ if (soap->part == SOAP_IN_HEADER) - return 1; - if (!pp) - return 0; - if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 == 0; - return pp->mark2 == 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_embedded(struct soap *soap, struct soap_plist *pp) -{ if (!pp) - return; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 1; - else - pp->mark2 = 1; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_dime(struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, const char *aid, const char *atype, const char *aoptions, int n, const char *type, int t) -{ struct soap_plist *pp; - if (!p || !a->__ptr || (!aid && !atype)) - return soap_element_id(soap, tag, id, p, a, n, type, t); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attachment tag='%s' id='%s' (%d) type='%s'\n", tag, aid?aid:"", id, atype?atype:"")); - if (id < 0) - id = soap_array_pointer_lookup(soap, p, a, n, t, &pp); - if (!aid) - { sprintf(soap->tmpbuf, soap->dime_id_format, id); - aid = soap_strdup(soap, soap->tmpbuf); - } - if (soap_element_href(soap, tag, 0, "href", aid)) - return soap->error; - if (soap->mode & SOAP_IO_LENGTH) - { if (pp->mark1 != 3) - { struct soap_multipart *content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, (char*)a->__ptr, a->__size); - if (!content) - return soap->error = SOAP_EOM; - content->id = aid; - content->type = atype; - content->options = aoptions; - pp->mark1 = 3; - } - } - else - pp->mark2 = 3; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_init_iht(struct soap *soap) -{ register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing ID hashtable\n")); - for (i = 0; i < SOAP_IDHASH; i++) - soap->iht[i] = NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static void -soap_free_iht(struct soap *soap) -{ register int i; - register struct soap_ilist *ip, *p; - register struct soap_flist *fp, *fq; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free ID hashtable\n")); - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = p) - { for (fp = ip->flist; fp; fp = fq) - { fq = fp->next; - SOAP_FREE(fp); - } - p = ip->next; - SOAP_FREE(ip); - } - soap->iht[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static struct soap_ilist * -soap_hlookup(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - for (ip = soap->iht[soap_hash(id)]; ip; ip = ip->next) - if (!strcmp(ip->id, id)) - return ip; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_ilist * -SOAP_FMAC2 -soap_lookup(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - ip = soap_hlookup(soap, id); -#ifndef WITH_LEANER - if (!ip && *id != '#' && !strchr(id, ':')) /* try content id "cid:" with DIME attachments */ - { char cid[SOAP_TAGLEN]; - strcpy(cid, "cid:"); - strncat(cid + 4, id, sizeof(cid) - 5); - cid[sizeof(cid) - 1] = '\0'; - ip = soap_hlookup(soap, cid); - } -#endif - return ip; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_ilist * -SOAP_FMAC2 -soap_enter(struct soap *soap, const char *id) -{ register size_t h; - register struct soap_ilist *ip; - ip = (struct soap_ilist*)SOAP_MALLOC(sizeof(struct soap_ilist) + strlen(id)); - if (ip) - { h = soap_hash(id); - strcpy(ip->id, id); - ip->next = soap->iht[h]; - soap->iht[h] = ip; - return ip; - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_malloc(struct soap *soap, size_t n) -{ register char *p; - if (!n) - return NULL; - if (!soap) - return SOAP_MALLOC(n); - n += (-(long)n) & 7; - if (!(p = (char*)SOAP_MALLOC(n + sizeof(void*) + sizeof(size_t)))) - { soap->error = SOAP_EOM; - return NULL; - } - /* keep chain of alloced cells for later destruction */ - soap->alloced = 1; - *(void**)(p + n) = soap->alist; - *(size_t*)(p + n + sizeof(void*)) = n; - soap->alist = p + n; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Malloc %u bytes at location %p\n", (unsigned int)n, p)); - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_dealloc(struct soap *soap, void *p) -{ if (!soap) - return; - if (p) - { register char **q; - for (q = (char**)&soap->alist; *q; q = *(char***)q) - { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*)))) - { *q = **(char***)q; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Freed data at %p\n", p)); - SOAP_FREE(p); - return; - } - } - soap_delete(soap, p); - } - else - { register char *q; - while (soap->alist) - { q = (char*)soap->alist; - soap->alist = *(void**)q; - q -= *(size_t*)(q + sizeof(void*)); - SOAP_FREE(q); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Dealloc all data done\n")); - } - /* we must assume these were deallocated: */ - soap->action = NULL; - soap->fault = NULL; - soap->header = NULL; - soap->authrealm = NULL; -#ifndef WITH_LEANER - soap_clr_mime(soap); -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_delete(struct soap *soap, void *p) -{ register struct soap_clist **cp = &soap->clist; - if (p) - { while (*cp) - { if (p == (*cp)->ptr) - { register struct soap_clist *q = *cp; - *cp = q->next; - q->fdelete(q); - SOAP_FREE(q); - return; - } - cp = &(*cp)->next; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not dealloc data %p: address not in list\n", p)); - } - else - { while (*cp) - { register struct soap_clist *q = *cp; - *cp = q->next; - if (q->ptr == (void*)soap->fault) - soap->fault = NULL; /* this was deallocated */ - else if (q->ptr == (void*)soap->header) - soap->header = NULL; /* this was deallocated */ - q->fdelete(q); - SOAP_FREE(q); - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_clist * -SOAP_FMAC2 -soap_link(struct soap *soap, void *p, int t, int n, void (*fdelete)(struct soap_clist*)) -{ register struct soap_clist *cp; - if ((cp = (struct soap_clist*)SOAP_MALLOC(sizeof(struct soap_clist)))) - { cp->next = soap->clist; - cp->type = t; - cp->size = n; - cp->ptr = p; - cp->fdelete = fdelete; - soap->clist = cp; - } - return cp; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_unlink(struct soap *soap, const void *p) -{ register char **q; - register struct soap_clist **cp; - if (!soap || !p) - return; - for (q = (char**)&soap->alist; *q; q = *(char***)q) - { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*)))) - { *q = **(char***)q; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked data %p\n", p)); - return; - } - } - for (cp = &soap->clist; *cp; cp = &(*cp)->next) - { if (p == (*cp)->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked class instance %p\n", p)); - q = (char**)*cp; - *cp = (*cp)->next; - SOAP_FREE(q); - return; - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_lookup_type(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - if (id && *id) - { ip = soap_lookup(soap, id); - if (ip) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup id='%s' type=%d\n", id, ip->type)); - return ip->type; - } - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "lookup type id='%s' NOT FOUND! Need to get it from xsi:type\n", id)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_lookup(struct soap *soap, const char *id, void **p, int t, size_t n, unsigned int k) -{ struct soap_ilist *ip; - void **q; - if (!id || !*id) - return p; - soap->alloced = 0; - if (!p) - p = (void**)soap_malloc(soap, sizeof(void*)); - ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */ - if (!ip) - { ip = soap_enter(soap, id); /* new hash table entry for string id */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding first href='%s' type=%d %p (%u bytes)\n", id, t, p, (unsigned int)n)); - ip->type = t; - ip->size = n; - ip->link = p; - ip->copy = NULL; - ip->flist = NULL; - ip->ptr = NULL; - ip->level = k; - *p = NULL; - } - else if (ip->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolved href='%s' type=%d location=%p (%u bytes)\n", id, t, ip->ptr, (unsigned int)n)); - if (ip->type != t) - { strcpy(soap->id, id); - soap->error = SOAP_HREF; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility: id type=%d href type=%d\n", ip->type, t)); - return NULL; - } - while (ip->level < k) - { q = (void**)soap_malloc(soap, sizeof(void*)); - if (!q) - return NULL; - *p = (void*)q; - p = q; - k--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - *p = ip->ptr; - } - else if (ip->level > k) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving level %u pointers to href='%s'\n", ip->level, id)); - while (ip->level > k) - { void *s, **r = &ip->link; - q = (void**)ip->link; - while (q) - { *r = (void*)soap_malloc(soap, sizeof(void*)); - s = *q; - *q = *r; - r = (void**)*r; - q = (void**)s; - } - *r = NULL; - ip->size = n; - ip->copy = NULL; - ip->level = ip->level - 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - q = (void**)ip->link; - ip->link = p; - *p = (void*)q; - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarded href='%s' type=%d location=%p (%u bytes)\n", id, t, p, (unsigned int)n)); - while (ip->level < k) - { q = (void**)soap_malloc(soap, sizeof(void*)); - *p = q; - p = q; - k--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - q = (void**)ip->link; - ip->link = p; - *p = (void*)q; - } - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_forward(struct soap *soap, const char *href, void *p, int st, int tt, size_t n, unsigned int k, void (*fcopy)(struct soap*, int, int, void*, const void*, size_t)) -{ struct soap_ilist *ip; - if (!p || !href || !*href) - return p; - ip = soap_lookup(soap, href); /* lookup pointer to hash table entry for string id */ - if (!ip) - { ip = soap_enter(soap, href); /* new hash table entry for string id */ - ip->type = st; - ip->size = n; - ip->link = NULL; - ip->copy = NULL; - ip->ptr = NULL; - ip->level = 0; - ip->flist = NULL; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "New entry href='%s' type=%d size=%lu level=%d location=%p\n", href, st, (unsigned long)n, k, p)); - } - else if (ip->type != st || (ip->level == k && ip->size != n)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility id='%s' expect type=%d size=%lu level=%u got type=%d size=%lu\n", href, ip->type, (unsigned long)ip->size, k, st, (unsigned long)n)); - strcpy(soap->id, href); - soap->error = SOAP_HREF; - return NULL; - } - if (fcopy || n < sizeof(void*) || *href != '#') - { register struct soap_flist *fp = (struct soap_flist*)SOAP_MALLOC(sizeof(struct soap_flist)); - if (!fp) - { soap->error = SOAP_EOM; - return NULL; - } - fp->next = ip->flist; - fp->type = tt; - fp->ptr = p; - fp->level = k; - if (fcopy) - fp->fcopy = fcopy; - else - fp->fcopy = soap_fcopy; - ip->flist = fp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding type=%d (target type=%d) size=%lu location=%p level=%u href='%s'\n", st, tt, (unsigned long)n, p, k, href)); - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding copying address %p for type=%d href='%s'\n", p, st, href)); - *(void**)p = ip->copy; - ip->copy = p; - } - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, unsigned int k, const char *type, const char *arrayType, void *(*finstantiate)(struct soap*, int, const char*, const char*, size_t*)) -{ struct soap_ilist *ip; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Enter id='%s' type=%d loc=%p size=%lu level=%u\n", id, t, p, (unsigned long)n, k)); - soap->alloced = 0; - if (!p) - { if (finstantiate) - p = finstantiate(soap, t, type, arrayType, &n); - else - p = soap_malloc(soap, n); - if (p) - soap->alloced = 1; - } - if (!id || !*id) - return p; - ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */ - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Lookup entry id='%s for location=%p'\n", id, p)); - if (!ip) - { ip = soap_enter(soap, id); /* new hash table entry for string id */ - ip->type = t; - ip->link = NULL; - ip->copy = NULL; - ip->flist = NULL; - ip->size = n; - ip->ptr = p; - ip->level = k; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "New entry id='%s' type=%d size=%lu level=%u location=%p\n", id, t, (unsigned long)n, k, p)); - } - else if ((ip->type != t || (ip->level == k && ip->size != n)) && (ip->copy || ip->flist)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility id='%s' expect type=%d size=%lu level=%u got type=%d size=%lu\n", id, ip->type, (unsigned long)ip->size, k, t, (unsigned long)n)); - strcpy(soap->id, id); - soap->error = SOAP_HREF; - return NULL; - } - else if (ip->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Multiply defined id='%s'\n", id)); - strcpy(soap->id, id); - soap->error = SOAP_MULTI_ID; - return NULL; - } - else - { ip->size = n; - ip->ptr = p; - ip->level = k; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update entry id='%s' type=%d location=%p size=%lu level=%u\n", id, t, p, n, k)); - } - return ip->ptr; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_fcopy(struct soap *soap, int st, int tt, void *p, const void *q, size_t n) -{ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Copying data type=%d (target type=%d) %p -> %p (%lu bytes)\n", st, tt, q, p, (unsigned long)n)); - memcpy(p, q, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_end_send(struct soap *soap) -{ -#ifndef WITH_LEANER - if (soap->dime.list) - { /* SOAP body referenced attachments must appear first */ - soap->dime.last->next = soap->dime.first; - soap->dime.first = soap->dime.list->next; - soap->dime.list->next = NULL; - soap->dime.last = soap->dime.list; - } - if (soap_putdime(soap) || soap_putmime(soap)) - return soap->error; - soap->mime.list = NULL; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->dime.list = NULL; - soap->dime.first = NULL; - soap->dime.last = NULL; -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End send\n")); - if (soap->mode & SOAP_IO) /* need to flush the remaining data in buffer */ - { if (soap_flush(soap)) -#ifdef WITH_ZLIB - { if (soap->mode & SOAP_ENC_ZLIB && soap->zlib_state == SOAP_ZLIB_DEFLATE) - { soap->zlib_state = SOAP_ZLIB_NONE; - deflateEnd(&soap->d_stream); - } - return soap->error; - } -#else - return soap->error; -#endif -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { int r; - soap->d_stream.avail_in = 0; - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating remainder\n")); - r = deflate(&soap->d_stream, Z_FINISH); - if (soap->d_stream.avail_out != SOAP_BUFLEN) - { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN - soap->d_stream.avail_out)) - { soap->zlib_state = SOAP_ZLIB_NONE; - deflateEnd(&soap->d_stream); - return soap->error; - } - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - } - } while (r == Z_OK); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_out = (float)soap->d_stream.total_out / (float)soap->d_stream.total_in; - soap->mode &= ~SOAP_ENC_ZLIB; - soap->zlib_state = SOAP_ZLIB_NONE; - if (deflateEnd(&soap->d_stream) != Z_OK || r != Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to end deflate: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - return soap->error = SOAP_ZLIB_ERROR; - } -#ifdef WITH_GZIP - soap->z_buf[0] = soap->z_crc & 0xFF; - soap->z_buf[1] = (soap->z_crc >> 8) & 0xFF; - soap->z_buf[2] = (soap->z_crc >> 16) & 0xFF; - soap->z_buf[3] = (soap->z_crc >> 24) & 0xFF; - soap->z_buf[4] = soap->d_stream.total_in & 0xFF; - soap->z_buf[5] = (soap->d_stream.total_in >> 8) & 0xFF; - soap->z_buf[6] = (soap->d_stream.total_in >> 16) & 0xFF; - soap->z_buf[7] = (soap->d_stream.total_in >> 24) & 0xFF; - if (soap_flush_raw(soap, soap->z_buf, 8)) - return soap->error; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip crc32=%lu\n", (unsigned long)soap->z_crc)); -#endif - } -#endif - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - { char *p; - if (!(soap->mode & SOAP_ENC_XML)) - { soap->mode--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending buffered message of length %u\n", (unsigned int)soap->blist->size)); - if (soap->status >= SOAP_POST) - soap->error = soap->fpost(soap, soap->endpoint, soap->host, soap->port, soap->path, soap->action, soap->blist->size); - else if (soap->status != SOAP_STOP) - soap->error = soap->fresponse(soap, soap->status, soap->blist->size); - if (soap->error || soap_flush(soap)) - return soap->error; - soap->mode++; - } - for (p = soap_first_block(soap); p; p = soap_next_block(soap)) - { DBGMSG(SENT, p, soap_block_size(soap)); - if ((soap->error = soap->fsend(soap, p, soap_block_size(soap)))) - { soap_end_block(soap); - return soap->error; - } - } - soap_end_block(soap); - } - else if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { DBGMSG(SENT, "\r\n0\r\n\r\n", 7); - if ((soap->error = soap->fsend(soap, "\r\n0\r\n\r\n", 7))) - return soap->error; - } - } -#ifdef WITH_OPENSSL - if (!soap->ssl && soap_valid_socket(soap->socket) && !soap->keep_alive) - soap->fshutdownsocket(soap, (SOAP_SOCKET)soap->socket, 1); /* Send TCP FIN */ -#else - if (soap_valid_socket(soap->socket) && !soap->keep_alive) - soap->fshutdownsocket(soap, (SOAP_SOCKET)soap->socket, 1); /* Send TCP FIN */ -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of send message ok\n")); - soap->part = SOAP_END; - soap->count = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_end_recv(struct soap *soap) -{ soap->part = SOAP_END; -#ifndef WITH_LEANER - if ((soap->mode & SOAP_ENC_MIME) && soap_getmime(soap)) - return soap->error; - soap->mime.list = soap->mime.first; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->dime.list = soap->dime.first; - soap->dime.first = NULL; - soap->dime.last = NULL; -#endif - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "End of receive message ok\n")); -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { soap->mode &= ~SOAP_ENC_ZLIB; - memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN); - soap->bufidx = (char*)soap->d_stream.next_in - soap->z_buf; - soap->buflen = soap->z_buflen; - soap->zlib_state = SOAP_ZLIB_NONE; - if (inflateEnd(&soap->d_stream) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; -#ifdef WITH_GZIP - if (soap->zlib_in == SOAP_ZLIB_GZIP) - { soap_wchar c; - short i; - for (i = 0; i < 8; i++) - { if ((int)(c = soap_getchar(soap)) == EOF) - return soap->error = SOAP_EOF; - soap->z_buf[i] = (char)c; - } - if (soap->z_crc != ((uLong)(unsigned char)soap->z_buf[0] | ((uLong)(unsigned char)soap->z_buf[1] << 8) | ((uLong)(unsigned char)soap->z_buf[2] << 16) | ((uLong)(unsigned char)soap->z_buf[3] << 24))) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: crc check failed, message corrupted? (crc32=%lu)\n", (unsigned long)soap->z_crc)); - return soap->error = SOAP_ZLIB_ERROR; - } - if (soap->d_stream.total_out != ((uLong)(unsigned char)soap->z_buf[4] | ((uLong)(unsigned char)soap->z_buf[5] << 8) | ((uLong)(unsigned char)soap->z_buf[6] << 16) | ((uLong)(unsigned char)soap->z_buf[7] << 24))) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: incorrect message length\n")); - return soap->error = SOAP_ZLIB_ERROR; - } - } -#endif - } -#endif - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - while ((int)soap_getchar(soap) != EOF) /* advance to last chunk */ - ; - if (soap->fdisconnect && (soap->error = soap->fdisconnect(soap))) - return soap->error; - return soap_resolve(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_free(struct soap *soap) -{ register struct soap_nlist *np; - register struct soap_attribute *tp; - register struct Namespace *ns; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free namespace stack\n")); - while (soap->nlist) - { np = soap->nlist->next; - if (soap->nlist->ns) - SOAP_FREE(soap->nlist->ns); - SOAP_FREE(soap->nlist); - soap->nlist = np; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free any remaining temp blocks\n")); - while (soap->blist) - soap_end_block(soap); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free attributes\n")); - while (soap->attributes) - { tp = soap->attributes->next; - if (soap->attributes->value) - SOAP_FREE(soap->attributes->value); - SOAP_FREE(soap->attributes); - soap->attributes = tp; - } -#ifdef WITH_FAST - if (soap->labbuf) - SOAP_FREE(soap->labbuf); - soap->labbuf = NULL; - soap->lablen = 0; - soap->labidx = 0; -#endif - soap_free_pht(soap); - soap_free_iht(soap); - ns = soap->local_namespaces; - if (ns) - { for (; ns->id; ns++) - { if (ns->out) - { SOAP_FREE(ns->out); - if (soap->encodingStyle == ns->out) - soap->encodingStyle = SOAP_STR_EOS; - ns->out = NULL; - } - if (soap->encodingStyle == ns->ns) - soap->encodingStyle = SOAP_STR_EOS; - } - SOAP_FREE(soap->local_namespaces); - soap->local_namespaces = NULL; - } -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -static void -soap_init_logs(struct soap *soap) -{ int i; - for (i = 0; i < SOAP_MAXLOGS; i++) - { soap->logfile[i] = NULL; - soap->fdebug[i] = NULL; - } - soap_set_recv_logfile(soap, "RECV.log"); - soap_set_sent_logfile(soap, "SENT.log"); - soap_set_test_logfile(soap, "TEST.log"); -} -#endif - -/******************************************************************************/ -#if !defined(WITH_LEAN) || defined(SOAP_DEBUG) -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_open_logfile(struct soap *soap, int i) -{ if (soap->logfile[i]) - soap->fdebug[i] = fopen(soap->logfile[i], i < 2 ? "ab" : "a"); -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -static void -soap_close_logfile(struct soap *soap, int i) -{ if (soap->fdebug[i]) - { fclose(soap->fdebug[i]); - soap->fdebug[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_close_logfiles(struct soap *soap) -{ int i; - for (i = 0; i < SOAP_MAXLOGS; i++) - soap_close_logfile(soap, i); -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -static void -soap_set_logfile(struct soap *soap, int i, const char *logfile) -{ char *s = NULL; - soap_close_logfile(soap, i); - if (soap->logfile[i]) - SOAP_FREE((void*)soap->logfile[i]); - if (logfile) - if ((s = (char*)SOAP_MALLOC(strlen(logfile) + 1))) - strcpy(s, logfile); - soap->logfile[i] = s; -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_recv_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_RECV, logfile); -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_sent_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_SENT, logfile); -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_test_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_TEST, logfile); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_copy(struct soap *soap) -{ return soap_copy_context((struct soap*)SOAP_MALLOC(sizeof(struct soap)), soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_copy_context(struct soap *copy, struct soap *soap) -{ if (copy) - { register struct soap_plugin *p; - memcpy(copy, soap, sizeof(struct soap)); - copy->copy = 1; - copy->user = NULL; - copy->userid = NULL; - copy->passwd = NULL; - copy->nlist = NULL; - copy->blist = NULL; - copy->clist = NULL; - copy->alist = NULL; - copy->attributes = NULL; - copy->local_namespaces = NULL; - soap_set_local_namespaces(copy); - soap_init_iht(copy); - soap_init_pht(copy); - copy->header = NULL; - copy->fault = NULL; - copy->action = NULL; - *copy->host = '\0'; -#ifndef WITH_LEAN -#ifdef WITH_COOKIES - copy->cookies = soap_copy_cookies(soap); -#else - copy->cookies = NULL; -#endif -#endif -#ifdef SOAP_DEBUG - soap_init_logs(copy); -#endif - copy->plugins = NULL; - for (p = soap->plugins; p; p = p->next) - { register struct soap_plugin *q = (struct soap_plugin*)SOAP_MALLOC(sizeof(struct soap_plugin)); - if (!q) - return NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying plugin '%s'\n", p->id)); - *q = *p; - if (p->fcopy && (soap->error = p->fcopy(soap, q, p))) - { SOAP_FREE(q); - return NULL; - } - q->next = copy->plugins; - copy->plugins = q; - } - } - else - soap->error = SOAP_EOM; - return copy; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init(struct soap *soap) -{ soap->version = 0; - soap_imode(soap, SOAP_IO_DEFAULT); - soap_omode(soap, SOAP_IO_DEFAULT); - soap->copy = 0; - soap->plugins = NULL; - soap->user = NULL; - soap->userid = NULL; - soap->passwd = NULL; - soap->fpost = http_post; - soap->fget = http_get; - soap->fposthdr = http_post_header; - soap->fresponse = http_response; - soap->fparse = http_parse; - soap->fparsehdr = http_parse_header; - soap->fconnect = NULL; - soap->fdisconnect = NULL; -#ifndef MAC_CARBON -#ifndef WITH_IPV6 - soap->fresolve = tcp_gethost; -#else - soap->fresolve = NULL; -#endif - soap->faccept = tcp_accept; - soap->fopen = tcp_connect; - soap->fclose = tcp_disconnect; - soap->fclosesocket = tcp_closesocket; - soap->fshutdownsocket = tcp_shutdownsocket; - soap->fsend = fsend; - soap->frecv = frecv; - soap->fpoll = soap_poll; -#else - soap->fpoll = NULL; -#endif - soap->fprepareinit = NULL; - soap->fpreparesend = NULL; - soap->fpreparerecv = NULL; - soap->fignore = NULL; - soap->fserveloop = NULL; - soap->fplugin = fplugin; - soap->fdimereadopen = NULL; - soap->fdimewriteopen = NULL; - soap->fdimereadclose = NULL; - soap->fdimewriteclose = NULL; - soap->fdimeread = NULL; - soap->fdimewrite = NULL; - soap->float_format = "%.8g"; /* .8 preserves single FP precision as much as possible, but might not be very efficient */ - soap->double_format = "%.17lg"; /* .17 preserves double FP precision as much as possible, but might not be very efficient */ - soap->dime_id_format = "cid:id%d"; /* default DIME id format */ - soap->http_version = "1.1"; - soap->actor = NULL; - soap->max_keep_alive = SOAP_MAXKEEPALIVE; - soap->keep_alive = 0; - soap->recv_timeout = 0; - soap->send_timeout = 0; - soap->connect_timeout = 0; - soap->accept_timeout = 0; - soap->socket_flags = 0; - soap->connect_flags = 0; - soap->bind_flags = 0; - soap->accept_flags = 0; - soap->ip = 0; - soap->labbuf = NULL; - soap->lablen = 0; - soap->labidx = 0; - soap->encodingStyle = SOAP_STR_EOS; -#ifndef WITH_NONAMESPACES - soap->namespaces = namespaces; -#else - soap->namespaces = NULL; -#endif - soap->local_namespaces = NULL; - soap->nlist = NULL; - soap->blist = NULL; - soap->clist = NULL; - soap->alist = NULL; - soap->attributes = NULL; - soap->header = NULL; - soap->fault = NULL; - soap->master = SOAP_INVALID_SOCKET; - soap->socket = SOAP_INVALID_SOCKET; - soap->os = NULL; - soap->is = NULL; - soap->dom = NULL; - soap->dime.list = NULL; - soap->dime.first = NULL; - soap->dime.last = NULL; - soap->mime.list = NULL; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->mime.boundary = NULL; - soap->mime.start = NULL; -#ifndef UNDER_CE - soap->recvfd = 0; - soap->sendfd = 1; -#else - soap->recvfd = stdin; - soap->sendfd = stdout; -#endif - soap->host[0] = '\0'; - soap->port = 0; - soap->action = NULL; - soap->proxy_host = NULL; - soap->proxy_port = 8080; - soap->proxy_userid = NULL; - soap->proxy_passwd = NULL; - soap->authrealm = NULL; - soap->prolog = NULL; -#ifdef WITH_OPENSSL - soap->fsslauth = ssl_auth_init; - soap->fsslverify = ssl_verify_callback; - soap->bio = NULL; - soap->ssl = NULL; - soap->ctx = NULL; - soap->require_server_auth = 0; - soap->require_client_auth = 0; - soap->rsa = 0; - soap->keyfile = NULL; - soap->password = NULL; - soap->dhfile = NULL; - soap->cafile = NULL; - soap->capath = NULL; - soap->randfile = NULL; - soap->session = NULL; -#endif -#ifdef WITH_ZLIB - soap->zlib_state = SOAP_ZLIB_NONE; - soap->zlib_in = SOAP_ZLIB_NONE; - soap->zlib_out = SOAP_ZLIB_NONE; - soap->d_stream.zalloc = NULL; - soap->d_stream.zfree = NULL; - soap->d_stream.opaque = NULL; - soap->z_level = 6; -#endif -#ifndef WITH_LEAN - soap->cookies = NULL; - soap->cookie_domain = NULL; - soap->cookie_path = NULL; - soap->cookie_max = 32; -#endif -#ifdef SOAP_DEBUG - soap_init_logs(soap); -#endif -/* WR[ */ -#ifdef WMW_RPM_IO - soap->rpmreqid = NULL; -#endif /* WMW_RPM_IO */ -/* ]WR */ - soap_init_iht(soap); - soap_init_pht(soap); - soap_begin(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init1(struct soap *soap, int mode) -{ soap_init2(soap, mode, mode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init2(struct soap *soap, int imode, int omode) -{ soap_init(soap); - soap_imode(soap, imode); - soap_omode(soap, omode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_begin(struct soap *soap) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing\n")); - if (!soap->keep_alive) - { soap->buflen = 0; - soap->bufidx = 0; - } - soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0); - soap->null = 0; - soap->position = 0; - soap->encoding = 0; - soap->mustUnderstand = 0; - soap->mode = 0; - soap->ns = 0; - soap->part = SOAP_BEGIN; - soap->alloced = 0; - soap->count = 0; - soap->length = 0; - soap->cdata = 0; - soap->error = SOAP_OK; - soap->peeked = 0; - soap->ahead = 0; - soap->idnum = 0; - soap->level = 0; - soap->endpoint[0] = '\0'; - soap->dime.chunksize = 0; - soap->dime.buflen = 0; - soap_free(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_end(struct soap *soap) -{ register struct soap_clist *cp; - soap_free(soap); - soap_dealloc(soap, NULL); - while (soap->clist) - { cp = soap->clist->next; - SOAP_FREE(soap->clist); - soap->clist = cp; - } - soap_closesock(soap); -#ifdef SOAP_DEBUG - soap_close_logfiles(soap); -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_namespaces(struct soap *soap, struct Namespace *p) -{ struct Namespace *ns = soap->local_namespaces; - struct soap_nlist *np, *nq, *nr; - unsigned int level = soap->level; - soap->namespaces = p; - soap->local_namespaces = NULL; - soap_set_local_namespaces(soap); - /* reverse the list */ - np = soap->nlist; - soap->nlist = NULL; - if (np) - { nq = np->next; - np->next = NULL; - while (nq) - { nr = nq->next; - nq->next = np; - np = nq; - nq = nr; - } - } - while (np) - { soap->level = np->level; /* preserve element nesting level */ - if (np->ns) - { if (soap_push_namespace(soap, np->id, np->ns)) - return soap->error; - } - else if (np->index >= 0 && ns) - { if (ns[np->index].out) - { if (soap_push_namespace(soap, np->id, ns[np->index].out)) - return soap->error; - } - else if (soap_push_namespace(soap, np->id, ns[np->index].ns)) - return soap->error; - } - if (np->ns) - SOAP_FREE(np->ns); - nq = np; - np = np->next; - SOAP_FREE(nq); - } - if (ns) - { int i; - for (i = 0; ns[i].id; i++) - { if (ns[i].out) - { SOAP_FREE(ns[i].out); - ns[i].out = NULL; - } - } - SOAP_FREE(ns); - } - soap->level = level; /* restore level */ - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static void -soap_set_local_namespaces(struct soap *soap) -{ if (soap->namespaces && !soap->local_namespaces) - { register const struct Namespace *ns1; - register struct Namespace *ns2; - register size_t n = 1; - for (ns1 = soap->namespaces; ns1->id; ns1++) - n++; - if (n > 3) - { n *= sizeof(struct Namespace); - ns2 = (struct Namespace*)SOAP_MALLOC(n); - if (ns2) - { memcpy(ns2, soap->namespaces, n); - ns2[0].id = "SOAP-ENV"; - ns2[1].id = "SOAP-ENC"; - ns2[2].id = "xsi"; - if (ns2[0].ns) - { if (!strcmp(ns2[0].ns, soap_env1)) - soap->version = 1; - else - soap->version = 2; - } - soap->local_namespaces = ns2; - } - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element(struct soap *soap, const char *tag, int id, const char *type) -{ struct Namespace *ns = soap->local_namespaces; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element begin tag='%s' id='%d' type='%s'\n", tag, id, type?type:"")); -/**/ -#ifdef WITH_DOM - if (soap->mode & SOAP_XML_DOM) - { register struct soap_dom_element *p, *e = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element)); - e->next = NULL; - e->prnt = soap->dom; - e->nstr = NULL; - e->name = soap_strdup(soap, tag); /* check EOM? */ - e->data = NULL; - e->type = 0; - e->node = NULL; - e->elts = NULL; - e->atts = NULL; - if (soap->dom) - { p = soap->dom->elts; - if (p) - { while (p->next) - p = p->next; - p->next = e; - } - else - soap->dom->elts = e; - } - soap->dom = e; - } - else -#endif -{ - soap->level++; - if (!soap->ns && !(soap->mode & SOAP_XML_CANONICAL)) - if (soap_send(soap, soap->prolog ? soap->prolog : "")) - return soap->error; - if (soap_send_raw(soap, "<", 1) - || soap_send(soap, tag)) - return soap->error; -} -/**/ - if (!soap->ns) - { for (ns = soap->local_namespaces; ns && ns->id; ns++) - { if (*ns->id && (ns->out || ns->ns)) - { sprintf(soap->tmpbuf, "xmlns:%s", ns->id); - if (soap_attribute(soap, soap->tmpbuf, ns->out ? ns->out : ns->ns)) - return soap->error; - } - } - soap->ns = 1; - } - if (id > 0) - { sprintf(soap->tmpbuf, "_%d", id); - if (soap_attribute(soap, "id", soap->tmpbuf)) - return soap->error; - } - if (type && *type) - { if (soap_attribute(soap, "xsi:type", type)) - return soap->error; - } - if (soap->null && soap->position > 0) - { int i; - sprintf(soap->tmpbuf, "[%d", soap->positions[0]); - for (i = 1; i < soap->position; i++) - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), ",%d", soap->positions[i]); - strcat(soap->tmpbuf, "]"); - if (soap_attribute(soap, "SOAP-ENC:position", soap->tmpbuf)) - return soap->error; - } - if (soap->mustUnderstand) - { if (soap->actor && *soap->actor) - { if (soap_attribute(soap, soap->version == 2 ? "SOAP-ENV:role" : "SOAP-ENV:actor", soap->actor)) - return soap->error; - } - if (soap_attribute(soap, "SOAP-ENV:mustUnderstand", soap->version == 2 ? "true" : "1")) - return soap->error; - soap->mustUnderstand = 0; - } - if (soap->encoding) - { if (soap->encodingStyle && soap->local_namespaces) - { if (!*soap->encodingStyle) - { if (soap->local_namespaces[1].out) - soap->encodingStyle = soap->local_namespaces[1].out; - else - soap->encodingStyle = soap->local_namespaces[1].ns; - } - if (soap_attribute(soap, "SOAP-ENV:encodingStyle", soap->encodingStyle)) - return soap->error; - } - soap->encoding = 0; - } - soap->null = 0; - soap->position = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_begin_out(struct soap *soap, const char *tag, int id, const char *type) -{ if (*tag == '-') - return SOAP_OK; - if (soap_element(soap, tag, id, type)) - return soap->error; - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRRCHR -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_strrchr(const char *s, int t) -{ register char *r = NULL; - while (*s) - if (*s++ == t) - r = (char*)s - 1; - return r; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRTOL -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_strtol(const char *s, char **t, int b) -{ register long n = 0; - register int c; - while (*s > 0 && *s <= 32) - s++; - if (b == 10) - { short neg = 0; - if (*s == '-') - { s++; - neg = 1; - } - else if (*s == '+') - s++; - while ((c = *s) && c >= '0' && c <= '9') - { if (n > 214748364) - break; - n *= 10; - n += c - '0'; - s++; - } - if (neg) - n = -n; - } - else /* b == 16 and value is always positive */ - { while ((c = *s)) - { if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'F') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'f') - c -= 'a' - 10; - if (n > 0x07FFFFFF) - break; - n <<= 4; - n += c; - s++; - } - } - if (t) - *t = (char*)s; - return n; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRTOUL -SOAP_FMAC1 -unsigned long -SOAP_FMAC2 -soap_strtoul(const char *s, char **t, int b) -{ unsigned long n = 0; - register int c; - while (*s > 0 && *s <= 32) - s++; - if (b == 10) - { if (*s == '+') - s++; - while ((c = *s) && c >= '0' && c <= '9') - { if (n > 429496729) - break; - n *= 10; - n += c - '0'; - s++; - } - } - else /* b == 16 */ - { while ((c = *s)) - { if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'F') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'f') - c -= 'a' - 10; - if (n > 0x0FFFFFFF) - break; - n <<= 4; - n += c; - s++; - } - } - if (t) - *t = (char*)s; - return n; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_begin_out(struct soap *soap, const char *tag, int id, const char *type, const char *offset) -{ if (soap_element(soap, tag, id, "SOAP-ENC:Array")) - return soap->error; - if (soap->version == 2) - { const char *s; - s = soap_strrchr(type, '['); - if ((size_t)(s - type) < sizeof(soap->tmpbuf)) - { strncpy(soap->tmpbuf, type, s - type); - soap->tmpbuf[s - type] = '\0'; - if (type && *type && (soap_attribute(soap, "SOAP-ENC:itemType", soap->tmpbuf))) - return soap->error; - if (s && (soap_attribute(soap, "SOAP-ENC:arraySize", s + 1))) - return soap->error; - } - } - else - { if (offset && (soap_attribute(soap, "SOAP-ENC:offset", offset))) - return soap->error; - if (type && *type && (soap_attribute(soap, "SOAP-ENC:arrayType", type))) - return soap->error; - } - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_start_end_out(struct soap *soap, const char *tag) -{ register struct soap_attribute *tp; -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible) - { register struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); - a->next = soap->dom->atts; - a->nstr = NULL; - a->name = soap_strdup(soap, tp->name); /* check EOM */ - a->data = soap_strdup(soap, tp->value); /* check EOM */ - a->wide = NULL; - soap->dom->atts = a; - tp->visible = 0; - } - } - return SOAP_OK; - } -#endif -/**/ - for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible) - { if (soap_send2(soap, " ", tp->name)) - return soap->error; - if (tp->visible == 2 && tp->value) - if (soap_send_raw(soap, "=\"", 2) - || soap_string_out(soap, tp->value, 1) - || soap_send_raw(soap, "\"", 1)) - return soap->error; - tp->visible = 0; - } - } - if (tag) - { soap->level--; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { if (soap_send_raw(soap, ">", 1) - || soap_element_end_out(soap, tag)) - return soap->error; - return SOAP_OK; - } -#endif - return soap_send_raw(soap, "/>", 2); - } - return soap_send_raw(soap, ">", 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_end_out(struct soap *soap, const char *tag) -{ if (*tag == '-') - return SOAP_OK; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element ending tag='%s'\n", tag)); -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { if (soap->dom->prnt) - soap->dom = soap->dom->prnt; - return SOAP_OK; - } -#endif -/**/ - soap->level--; - if (soap_send_raw(soap, "error; - return soap_send_raw(soap, ">", 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_ref(struct soap *soap, const char *tag, int id, int href) -{ register int n = 0; - if (soap->version == 2) - n = 1; - sprintf(soap->href, "#_%d", href); - return soap_element_href(soap, tag, id, "href" + n, soap->href + n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_href(struct soap *soap, const char *tag, int id, const char *ref, const char *val) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element '%s' reference %s='%s'\n", tag, ref, val)); - if (soap_element(soap, tag, id, NULL) - || soap_attribute(soap, ref, val) - || soap_element_start_end_out(soap, tag)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_null(struct soap *soap, const char *tag, int id, const char *type) -{ struct soap_attribute *tp; - for (tp = soap->attributes; tp; tp = tp->next) - if (tp->visible) - break; - if (tp || (soap->version == 2 && soap->position > 0) || id > 0 || (soap->mode & SOAP_XML_NIL)) - { if (soap_element(soap, tag, id, type)) - return soap->error; - if (soap->part != SOAP_IN_HEADER && soap->encodingStyle) - if (soap_attribute(soap, "xsi:nil", "true")) - return soap->error; - return soap_element_start_end_out(soap, tag); - } - soap->null = 1; - soap->position = 0; - soap->mustUnderstand = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_id(struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, int n, const char *type, int t) -{ struct soap_plist *pp; - if (!p) - { soap_element_null(soap, tag, id, type); - return -1; - } - if (soap->mode & SOAP_XML_TREE) - return 0; - if (id < 0) - { if (a) - id = soap_array_pointer_lookup(soap, p, a, n, t, &pp); - else - id = soap_pointer_lookup(soap, p, t, &pp); - if (id) - { if (soap_is_embedded(soap, pp)) - { soap_element_ref(soap, tag, 0, id); - return -1; - } - if (soap_is_single(soap, pp)) - return 0; - soap_set_embedded(soap, pp); - } - } - return id; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_result(struct soap *soap, const char *tag) -{ if (soap->version == 2 && soap->encodingStyle) - if (soap_element(soap, "SOAP-RPC:result", 0, NULL) - || soap_attribute(soap, "xmlns:SOAP-RPC", soap_rpc) - || soap_element_start_end_out(soap, NULL) - || soap_string_out(soap, tag, 0) - || soap_element_end_out(soap, "SOAP-RPC:result")) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_attribute(struct soap *soap, const char *name, const char *value) -{ -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { register struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); - a->next = soap->dom->atts; - a->nstr = NULL; - a->name = soap_strdup(soap, name); /* check EOM */ - a->data = soap_strdup(soap, value); /* check EOM */ - a->wide = NULL; - soap->dom->atts = a; - return SOAP_OK; - } -#endif -/**/ -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { if (soap_set_attr(soap, name, value)) - return soap->error; - } - else -#endif - { if (soap_send2(soap, " ", name)) - return soap->error; - if (value) - if (soap_send_raw(soap, "=\"", 2) - || soap_string_out(soap, value, 1) - || soap_send_raw(soap, "\"", 1)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_begin_in(struct soap *soap, const char *tag, int nillable) -{ if (!soap_peek_element(soap)) - { if (soap->other) - return soap->error = SOAP_TAG_MISMATCH; - if (tag && *tag == '-') - return SOAP_OK; - if (!(soap->error = soap_match_tag(soap, soap->tag, tag))) - { soap->peeked = 0; - if (soap->body) - soap->level++; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:"" )); - if (!nillable && soap->null && (soap->mode & SOAP_XML_STRICT)) - return soap->error = SOAP_NULL; - } - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_end_in(struct soap *soap, const char *tag) -{ register soap_wchar c; - register char *s; - register const char *t; - if (tag && *tag == '-') - return SOAP_OK; - soap->level--; - soap_pop_namespace(soap); - if (soap->peeked) - { if (*soap->tag == '\0') - { soap->peeked = 0; - if (soap->error == SOAP_NO_TAG || soap->error == SOAP_TAG_END) - soap->error = SOAP_OK; - } - else - return soap->error = SOAP_TAG_END; - } - else - { while (((c = soap_get(soap)) != SOAP_TT)) - { if ((int)c == EOF) - return soap->error = SOAP_EOF; - if (c == SOAP_LT) - return soap->error = SOAP_TAG_END; - } - } - s = soap->tag; - do c = soap_get(soap); - while (soap_blank(c)); - do - { *s++ = (char)c; - c = soap_get(soap); - } while (soap_notblank(c)); - *s = '\0'; - if ((int)c == EOF) - return soap->error = SOAP_EOF; - while (soap_blank(c)) - c = soap_get(soap); - if (c != SOAP_GT) - return soap->error = SOAP_SYNTAX_ERROR; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:"")); - if (!tag) - return SOAP_OK; - if ((s = strchr(soap->tag, ':'))) - s++; - else - s = soap->tag; - if ((t = strchr(tag, ':'))) - t++; - else - t = tag; - if (!SOAP_STRCMP(s, t)) - return SOAP_OK; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element tag name does not match\n")); - return soap->error = SOAP_SYNTAX_ERROR; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char * -SOAP_FMAC2 -soap_attr_value(struct soap *soap, const char *name, int flag) -{ register struct soap_attribute *tp; - for (tp = soap->attributes; tp; tp = tp->next) - if (!soap_match_tag(soap, tp->name, name)) - break; - if (tp && tp->visible == 2) - { if (flag == 2 && (soap->mode & SOAP_XML_STRICT)) - soap->error = SOAP_PROHIBITED; - else - return tp->value; - } - else if (flag == 1 && (soap->mode & SOAP_XML_STRICT)) - soap->error = SOAP_REQUIRED; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_attr(struct soap *soap, const char *name, const char *value) -{ register struct soap_attribute *tp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set attribute %s='%s'\n", name, value?value:"")); - for (tp = soap->attributes; tp; tp = tp->next) - if (!strcmp(tp->name, name)) - break; - if (!tp) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute %s\n", name)); - if (!(tp = (struct soap_attribute*)SOAP_MALLOC(sizeof(struct soap_attribute) + strlen(name)))) - return soap->error = SOAP_EOM; - tp->ns = NULL; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { struct soap_attribute **tpp = &soap->attributes; - const char *s = strchr(name, ':'); - if (!strncmp(name, "xmlns", 5)) - { for (; *tpp; tpp = &(*tpp)->next) - if (strncmp((*tpp)->name, "xmlns", 5) || strcmp((*tpp)->name + 5, name + 5) > 0) - break; - } - else if (!s) - { for (; *tpp; tpp = &(*tpp)->next) - if (strncmp((*tpp)->name, "xmlns", 5) && ((*tpp)->ns || strcmp((*tpp)->name, name) > 0)) - break; - } - else - { int k; - for (; *tpp; tpp = &(*tpp)->next) - { if (!strncmp((*tpp)->name, "xmlns:", 6) && !strncmp((*tpp)->name + 6, name, s - name) && !(*tpp)->name[6 + s - name]) - { if (!tp->ns) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Canonicalization: prefix %s=%p(%s)\n", name, (*tpp)->ns, (*tpp)->ns)); - tp->ns = (*tpp)->ns; - } - } - else if (strncmp((*tpp)->name, "xmlns", 5) && (*tpp)->ns && tp->ns && ((k = strcmp((*tpp)->ns, tp->ns)) > 0 || (!k && strcmp((*tpp)->name, name) > 0))) - break; - } - } - tp->next = *tpp; - *tpp = tp; - } - else -#endif - { tp->next = soap->attributes; - soap->attributes = tp; - } - strcpy(tp->name, name); - tp->value = NULL; - } - else if (value && tp->value && tp->size <= strlen(value)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free attribute value of %s (free %p)\n", name, tp->value)); - SOAP_FREE(tp->value); - tp->value = NULL; - tp->ns = NULL; - } - if (value) - { if (!tp->value) - { tp->size = strlen(value) + 1; - if (!(tp->value = (char*)SOAP_MALLOC(tp->size))) - return soap->error = SOAP_EOM; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute value of %s (%p)\n", tp->name, tp->value)); - } - strcpy(tp->value, value); - if (!strncmp(tp->name, "xmlns:", 6)) - tp->ns = tp->value; - tp->visible = 2; - } - else - tp->visible = 1; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_attr(struct soap *soap) -{ register struct soap_attribute *tp; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { while (soap->attributes) - { tp = soap->attributes->next; - SOAP_FREE(soap->attributes->value); - SOAP_FREE(soap->attributes); - soap->attributes = tp; - } - } - else -#endif - { for (tp = soap->attributes; tp; tp = tp->next) - tp->visible = 0; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static int -soap_getattrval(struct soap *soap, char *s, size_t n, soap_wchar d) -{ size_t i; - soap_wchar c; - for (i = 0; i < n; i++) - { c = soap_getutf8(soap); - switch (c) - { - case SOAP_TT: - *s++ = '<'; - soap_unget(soap, '/'); - break; - case SOAP_LT: - *s++ = '<'; - break; - case SOAP_GT: - if (d == ' ') - { soap_unget(soap, c); - *s = '\0'; - return SOAP_OK; - } - *s++ = '>'; - break; - case SOAP_QT: - if (c == d) - { *s = '\0'; - return SOAP_OK; - } - *s++ = '"'; - break; - case SOAP_AP: - if (c == d) - { *s = '\0'; - return SOAP_OK; - } - *s++ = '\''; - break; - case '\t': - case '\n': - case '\r': - case ' ': - case '/': - if (d == ' ') - { soap_unget(soap, c); - *s = '\0'; - return SOAP_OK; - } - default: - if ((int)c == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - } - return soap->error = SOAP_EOM; -} -#endif - -/******************************************************************************/ -#ifdef WITH_FAST -#ifndef PALM_2 -static int -soap_append_lab(struct soap *soap, const char *s, size_t n) -{ if (soap->labidx + n >= soap->lablen) - { register char *t = soap->labbuf; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enlarging look-aside buffer to append data, old size=%lu", (unsigned long)soap->lablen)); - if (soap->lablen == 0) - soap->lablen = SOAP_LABLEN; - while (soap->labidx + n >= soap->lablen) - soap->lablen <<= 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, ", new size=%lu\n", (unsigned long)soap->lablen)); - soap->labbuf = (char*)SOAP_MALLOC(soap->lablen); - if (!soap->labbuf) - { if (t) - free(t); - return soap->error = SOAP_EOM; - } - if (t && soap->labidx) - { memcpy(soap->labbuf, t, soap->labidx); - free(t); - } - } - if (s) - { memcpy(soap->labbuf + soap->labidx, s, n); - soap->labidx += n; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_peek_element(struct soap *soap) -{ register struct soap_attribute *tp; - const char *t; - register char *s; - register soap_wchar c; - register int i; - if (soap->error == SOAP_NO_TAG || soap->error == SOAP_TAG_END || soap->error == SOAP_TAG_MISMATCH) - soap->error = SOAP_OK; /* retry */ - if (soap->peeked) - { if (*soap->tag == '\0') - return soap->error = SOAP_NO_TAG; - return SOAP_OK; - } - soap->peeked = 1; - for (;;) - { while (((c = soap_getutf8(soap)) != SOAP_LT) && c != SOAP_TT) - { if ((int)c == EOF) - return soap->error = SOAP_EOF; - } - if (c == SOAP_TT) - { *soap->tag = '\0'; - return soap->error = SOAP_NO_TAG; /* ending tag found */ - } - s = soap->tag; - do c = soap_get(soap); - while (soap_blank(c)); - i = sizeof(soap->tag); - while (c != '/' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - while (soap_blank(c)) - c = soap_get(soap); - *s = '\0'; - if (*soap->tag != '?') - break; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "XML PI <%s?>\n", soap->tag)); - while ((int)c != EOF && c != SOAP_GT && c != '?') - { s = soap->tmpbuf; - i = sizeof(soap->tmpbuf) - 2; - while (c != '=' && c != SOAP_GT && c != '?' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - while (soap_blank(c)) - c = soap_get(soap); - if (c == '=') - { *s++ = '='; - do c = soap_get(soap); - while (soap_blank(c)); - if (c != SOAP_QT && c != SOAP_AP) - { soap_unget(soap, c); - c = ' '; /* blank delimiter */ - } - if (soap_getattrval(soap, s, i, c) == SOAP_EOM) - while (soap_getattrval(soap, soap->tmpbuf, sizeof(soap->tmpbuf), c) == SOAP_EOM) - ; - else if (!strcmp(soap->tag, "?xml") && (!soap_tag_cmp(soap->tmpbuf, "encoding=iso-8859-1") || !soap_tag_cmp(soap->tmpbuf, "encoding=latin1"))) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "XML latin1 encoding\n")); - soap->mode |= SOAP_ENC_LATIN; - } - } - do c = soap_get(soap); - while (soap_blank(c)); - } - } - soap->id[0] = '\0'; - soap->href[0] = '\0'; - soap->type[0] = '\0'; - soap->arrayType[0] = '\0'; - soap->arraySize[0] = '\0'; - soap->arrayOffset[0] = '\0'; - soap->other = 0; - soap->root = -1; - soap->position = 0; - soap->null = 0; - soap->mustUnderstand = 0; - soap_clr_attr(soap); - while ((int)c != EOF && c != SOAP_GT && c != '/') - { s = soap->tmpbuf; - i = sizeof(soap->tmpbuf); - while (c != '=' && c != '/' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - *s = '\0'; - if (i == sizeof(soap->tmpbuf)) - return soap->error = SOAP_SYNTAX_ERROR; - if (!strncmp(soap->tmpbuf, "xmlns:", 6)) - { soap->tmpbuf[5] = '\0'; - t = soap->tmpbuf + 6; - } - else if (!strcmp(soap->tmpbuf, "xmlns")) - t = SOAP_STR_EOS; - else - t = NULL; - for (tp = soap->attributes; tp; tp = tp->next) - if (!SOAP_STRCMP(tp->name, soap->tmpbuf)) - break; - if (!tp) - { tp = (struct soap_attribute*)SOAP_MALLOC(sizeof(struct soap_attribute) + strlen(soap->tmpbuf)); - if (!tp) - return soap->error = SOAP_EOM; - strcpy(tp->name, soap->tmpbuf); - tp->value = NULL; - tp->size = 0; - tp->next = soap->attributes; - soap->attributes = tp; - } - while (soap_blank(c)) - c = soap_get(soap); - if (c == '=') - { do c = soap_get(soap); - while (soap_blank(c)); - if (c != SOAP_QT && c != SOAP_AP) - { soap_unget(soap, c); - c = ' '; /* blank delimiter */ - } - if (soap_getattrval(soap, tp->value, tp->size, c)) - { -#ifdef WITH_FAST - if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - soap->labidx = 0; - if (soap_append_lab(soap, tp->value, tp->size)) - return soap->error; - SOAP_FREE(tp->value); - for (;;) - { if (soap_getattrval(soap, soap->labbuf + soap->labidx, soap->lablen - soap->labidx, c)) - { if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - soap->labidx = soap->lablen; - if (soap_append_lab(soap, NULL, 0)) - return soap->error; - } - else - break; - } - tp->size = soap->lablen; - if (!(tp->value = (char*)SOAP_MALLOC(tp->size))) - return soap->error = SOAP_EOM; - memcpy(tp->value, soap->labbuf, soap->lablen); -#else - size_t n; - if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - if (soap_new_block(soap)) - return soap->error; - for (;;) - { if (!(s = (char*)soap_push_block(soap, SOAP_BLKLEN))) - return soap->error; - if (soap_getattrval(soap, s, SOAP_BLKLEN, c)) - { if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - } - else - break; - } - n = tp->size + soap->blist->size; - if (!(s = (char*)SOAP_MALLOC(n))) - return soap->error = SOAP_EOM; - if (tp->value) - { memcpy(s, tp->value, tp->size); - SOAP_FREE(tp->value); - } - soap_save_block(soap, s + tp->size, 0); - tp->value = s; - tp->size = n; -#endif - } - do c = soap_get(soap); - while (soap_blank(c)); - tp->visible = 2; /* seen this attribute w/ value */ - } - else - tp->visible = 1; /* seen this attribute w/o value */ - if (t && tp->value) - { if (soap_push_namespace(soap, t, tp->value)) - return soap->error; - tp->visible = 0; - } - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible && tp->value) - { if (!strcmp(tp->name, "id")) - { *soap->id = '#'; - strncpy(soap->id + 1, tp->value, sizeof(soap->id) - 2); - soap->id[sizeof(soap->id)-1] = '\0'; - } - else if (!strcmp(tp->name, "href")) - { strncpy(soap->href, tp->value, sizeof(soap->href) - 1); - soap->href[sizeof(soap->href)-1] = '\0'; - } - else if ((soap->version == 2 || (soap->mode & SOAP_XML_GRAPH)) && !strcmp(tp->name, "ref")) - { *soap->href = '#'; - strncpy(soap->href + 1, tp->value, sizeof(soap->href) - 2); - soap->href[sizeof(soap->href)-1] = '\0'; - } - else if (!soap_match_tag(soap, tp->name, "xsi:type")) - { strncpy(soap->type, tp->value, sizeof(soap->type) - 1); - soap->type[sizeof(soap->type)-1] = '\0'; - } - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:arrayType")) - { s = soap_strrchr(tp->value, '['); - if (s && (size_t)(s - tp->value) < sizeof(soap->arrayType)) - { strncpy(soap->arrayType, tp->value, s - tp->value); - soap->arrayType[s - tp->value] = '\0'; - strncpy(soap->arraySize, s, sizeof(soap->arraySize) - 1); - } - else - strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType) - 1); - soap->arraySize[sizeof(soap->arrayType)-1] = '\0'; - soap->arrayType[sizeof(soap->arrayType)-1] = '\0'; - } - else if (soap->version == 2 && !soap_match_tag(soap, tp->name, "SOAP-ENC:itemType")) - strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType) - 1); - else if (soap->version == 2 && !soap_match_tag(soap, tp->name, "SOAP-ENC:arraySize")) - strncpy(soap->arraySize, tp->value, sizeof(soap->arraySize) - 1); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:offset")) - strncpy(soap->arrayOffset, tp->value, sizeof(soap->arrayOffset)); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:position")) - soap->position = soap_getposition(tp->value, soap->positions); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:root")) - soap->root = ((!strcmp(tp->value, "1") || !strcmp(tp->value, "true"))); - else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:actor") - || !soap_match_tag(soap, tp->name, "SOAP-ENV:role")) - { if ((!soap->actor || strcmp(soap->actor, tp->value)) - && strcmp(tp->value, "http://schemas.xmlsoap.org/soap/actor/next") - && strcmp(tp->value, "http://www.w3.org/2003/05/soap-envelope/role/next")) - soap->other = 1; - } - else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:mustUnderstand") - && (!strcmp(tp->value, "1") || !strcmp(tp->value, "true"))) - soap->mustUnderstand = 1; - else if ((!soap_match_tag(soap, tp->name, "xsi:null") - || !soap_match_tag(soap, tp->name, "xsi:nil")) - && (!strcmp(tp->value, "1") - || !strcmp(tp->value, "true"))) - soap->null = 1; - } - } - if (!(soap->body = (c != '/'))) - do c = soap_get(soap); - while (soap_blank(c)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_retry(struct soap *soap) -{ soap->peeked = 1; - soap->error = SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_revert(struct soap *soap) -{ if (!soap->peeked) - { soap->peeked = 1; - if (soap->body) - soap->level--; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reverting last element (level=%u)\n", soap->level)); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_string_out(struct soap *soap, const char *s, int flag) -{ register const char *t; - register soap_wchar c; - register soap_wchar mask = 0x80000000; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->data = soap_strdup(soap, s); /* check EOM */ - return SOAP_OK; - } -#endif - if (soap->mode & SOAP_C_UTFSTRING) - mask = 0; - t = s; - while ((c = *t++)) - { switch (c) - { - case 9: - if (flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - } - break; - case 10: - if (flag || !(soap->mode & SOAP_XML_CANONICAL)) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - } - break; - case 13: - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - break; - case '&': - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&", 5)) - return soap->error; - s = t; - break; - case '<': - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "<", 4)) - return soap->error; - s = t; - break; - case '>': - if (!flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, ">", 4)) - return soap->error; - s = t; - } - break; - case '"': - if (flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, """, 6)) - return soap->error; - s = t; - } - break; - default: -#ifdef HAVE_MBTOWC - if (soap->mode & SOAP_C_MBSTRING) - { wchar_t wc; - register int m = mbtowc(&wc, t - 1, MB_CUR_MAX); - if (m > 0 && wc != c) - { if (soap_send_raw(soap, s, t - s - 1) || soap_pututf8(soap, wc)) - return soap->error; - s = t + m - 1; - continue; - } - } -#endif - if (c & mask) - { if (soap_send_raw(soap, s, t - s - 1) || soap_pututf8(soap, (unsigned char)c)) - return soap->error; - s = t; - } - } - } - return soap_send_raw(soap, s, t - s - 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) -{ register char *s; - char *t = NULL; - register size_t i; - register long l = 0; - register int n = 0; - register int m = 0; - register soap_wchar c; -#ifdef HAVE_WCTOMB - char buf[MB_LEN_MAX > 8 ? MB_LEN_MAX : 8]; -#else - char buf[8]; -#endif -#ifdef WITH_CDATA - if (!flag) - { register int state = 0; -#ifdef WITH_FAST - soap->labidx = 0; /* use look-aside buffer */ -#else - if (soap_new_block(soap)) - return NULL; -#endif - for (;;) - { -#ifdef WITH_FAST - register size_t k; - if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ - return NULL; - s = soap->labbuf + soap->labidx; /* space to populate */ - k = soap->lablen - soap->labidx; /* number of bytes available */ - soap->labidx = soap->lablen; /* claim this space */ -#else - register size_t k = SOAP_BLKLEN; - if (!(s = (char*)soap_push_block(soap, k))) - return NULL; -#endif - for (i = 0; i < k; i++) - { if (m > 0) - { *s++ = *t++; /* copy multibyte characters */ - m--; - continue; - } - c = soap_getchar(soap); - if ((int)c == EOF) - goto end; - if (c >= 0x80 && !(soap->mode & SOAP_ENC_LATIN)) - { soap_unget(soap, c); - c = soap_getutf8(soap); - if (soap->mode & SOAP_C_UTFSTRING) - { if ((c & 0x80000000) && c >= -0x7FFFFF80 && c < SOAP_AP) - { c &= 0x7FFFFFFF; - t = buf; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - m = (int)(t - buf) - 1; - t = buf; - *s++ = *t++; - continue; - } - } - } - switch (state) - { case 1: - if (c == ']') - state = 4; - *s++ = c; - continue; - case 2: - if (c == '-') - state = 6; - *s++ = c; - continue; - case 3: - if (c == '?') - state = 8; - *s++ = c; - continue; - /* CDATA */ - case 4: - if (c == ']') - state = 5; - else - state = 1; - *s++ = c; - continue; - case 5: - if (c == '>') - state = 0; - else - state = 1; - *s++ = c; - continue; - /* comment */ - case 6: - if (c == '-') - state = 7; - else - state = 2; - *s++ = c; - continue; - case 7: - if (c == '>') - state = 0; - else - state = 2; - *s++ = c; - continue; - /* PI */ - case 8: - if (c == '>') - state = 0; - else - state = 3; - *s++ = c; - continue; - } - switch (c) - { - case '/': - if (n > 0) - { c = soap_get1(soap); - if (c == '>') - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<': - c = soap_get1(soap); - if (c == '/') - { if (n == 0) - { c = SOAP_TT; - goto end; - } - n--; - } - else if (c == '!') - { c = soap_get1(soap); - if (c == '[') - { do c = soap_get1(soap); - while ((int)c != EOF && c != '['); - if ((int)c == EOF) - goto end; - t = (char*)"![CDATA["; - m = 8; - state = 1; - } - else if (c == '-') - { if ((c = soap_get1(soap)) == '-') - state = 2; - t = (char*)"!-"; - m = 2; - soap_unget(soap, c); - } - else - { t = (char*)"!"; - m = 1; - soap_unget(soap, c); - } - *s++ = '<'; - break; - } - else if (c == '?') - state = 3; - else - n++; - soap_unget(soap, c); - *s++ = '<'; - break; - case '>': - *s++ = '>'; - break; - case '"': - *s++ = '"'; - break; - default: -#ifdef HAVE_WCTOMB - if (soap->mode & SOAP_C_MBSTRING) - { m = wctomb(buf, c & 0x7FFFFFFF); - if (m >= 1) - { t = buf; - *s++ = *t++; - m--; - } - else - *s++ = SOAP_UNKNOWN_CHAR; - } - else -#endif - *s++ = (char)(c & 0xFF); - } - l++; - if ((soap->mode & SOAP_XML_STRICT) && maxlen >= 0 && l > maxlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); - soap->error = SOAP_LENGTH; - return NULL; - } - } - } - } -#endif -#ifdef WITH_FAST - soap->labidx = 0; /* use look-aside buffer */ -#else - if (soap_new_block(soap)) - return NULL; -#endif - for (;;) - { -#ifdef WITH_FAST - register size_t k; - if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ - return NULL; - s = soap->labbuf + soap->labidx; /* space to populate */ - k = soap->lablen - soap->labidx; /* number of bytes available */ - soap->labidx = soap->lablen; /* claim this space */ -#else - register size_t k = SOAP_BLKLEN; - if (!(s = (char*)soap_push_block(soap, k))) - return NULL; -#endif - for (i = 0; i < k; i++) - { if (m > 0) - { *s++ = *t++; /* copy multibyte characters */ - m--; - continue; - } - if (soap->mode & SOAP_C_UTFSTRING) - { if (((c = soap_get(soap)) & 0x80000000) && c >= -0x7FFFFF80 && c < SOAP_AP) - { c &= 0x7FFFFFFF; - t = buf; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - m = (int)(t - buf) - 1; - t = buf; - *s++ = *t++; - continue; - } - } - else - c = soap_getutf8(soap); - switch (c) - { - case SOAP_TT: - if (n == 0) - goto end; - n--; - *s++ = '<'; - t = (char*)"/"; - m = 1; - break; - case SOAP_LT: - n++; - *s++ = '<'; - break; - case SOAP_GT: - *s++ = '>'; - break; - case SOAP_QT: - *s++ = '"'; - break; - case SOAP_AP: - *s++ = '\''; - break; - case '/': - if (n > 0) - { c = soap_get(soap); - if (c == SOAP_GT) - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<' | 0x80000000: - if (flag) - *s++ = '<'; - else - { *s++ = '&'; - t = (char*)"lt;"; - m = 3; - } - break; - case '>' | 0x80000000: - if (flag) - *s++ = '>'; - else - { *s++ = '&'; - t = (char*)"gt;"; - m = 3; - } - break; - case '"' | 0x80000000: - if (flag) - *s++ = '"'; - else - { *s++ = '&'; - t = (char*)"quot;"; - m = 5; - } - break; - case '\'' | 0x80000000: - if (flag) - *s++ = '\''; - else - { *s++ = '&'; - t = (char*)"apos;"; - m = 5; - } - break; - default: - if ((int)c == EOF) - goto end; -#ifdef HAVE_WCTOMB - if (soap->mode & SOAP_C_MBSTRING) - { m = wctomb(buf, c & 0x7FFFFFFF); - if (m >= 1) - { t = buf; - *s++ = *t++; - m--; - } - else - *s++ = SOAP_UNKNOWN_CHAR; - } - else -#endif - *s++ = (char)(c & 0xFF); - } - l++; - if ((soap->mode & SOAP_XML_STRICT) && maxlen >= 0 && l > maxlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); - soap->error = SOAP_LENGTH; - return NULL; - } - } - } -end: - soap_unget(soap, c); - *s = '\0'; -#ifdef WITH_FAST - t = soap_strdup(soap, soap->labbuf); -#else - soap_size_block(soap, i+1); - t = soap_save_block(soap, NULL, 0); -#endif - if ((soap->mode & SOAP_XML_STRICT) && l < minlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too short: %ld chars, minlen=%ld\n", l, minlen)); - soap->error = SOAP_LENGTH; - return NULL; - } - if (flag == 2) - if (soap_s2QName(soap, t, &t)) - return NULL; - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_wstring_out(struct soap *soap, const wchar_t *s, int flag) -{ const char *t; - char tmp; - register soap_wchar c; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->wide = NULL; /* soap_malloc() ??? */ - return SOAP_OK; - } -#endif - while ((c = *s++)) - { switch (c) - { - case 9: - if (flag) - t = " "; - else - t = "\t"; - break; - case 10: - if (flag || !(soap->mode & SOAP_XML_CANONICAL)) - t = " "; - else - t = "\n"; - break; - case 13: - t = " "; - break; - case '&': - t = "&"; - break; - case '<': - t = "<"; - break; - case '>': - if (flag) - t = ">"; - else - t = ">"; - break; - case '"': - if (flag) - t = """; - else - t = "\""; - break; - default: - if (c > 0 && c < 0x80) - { tmp = (char)c; - if (soap_send_raw(soap, &tmp, 1)) - return soap->error; - } - else if (soap_pututf8(soap, (unsigned long)c)) - return soap->error; - continue; - } - if (soap_send(soap, t)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t * -SOAP_FMAC2 -soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen) -{ wchar_t *s; - register int i, n = 0; - register long l = 0; - register soap_wchar c; - const char *t = NULL; - if (soap_new_block(soap)) - return NULL; - for (;;) - { if (!(s = (wchar_t*)soap_push_block(soap, sizeof(wchar_t)*SOAP_BLKLEN))) - return NULL; - for (i = 0; i < SOAP_BLKLEN; i++) - { if (t) - { *s++ = (wchar_t)*t++; - if (!*t) - t = NULL; - continue; - } - c = soap_getutf8(soap); - switch (c) - { - case SOAP_TT: - if (n == 0) - goto end; - n--; - *s++ = '<'; - soap_unget(soap, '/'); - break; - case SOAP_LT: - n++; - *s++ = '<'; - break; - case SOAP_GT: - *s++ = '>'; - break; - case SOAP_QT: - *s++ = '"'; - break; - case SOAP_AP: - *s++ = '\''; - break; - case '/': - if (n > 0) - { c = soap_getutf8(soap); - if (c == SOAP_GT) - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<': - if (flag) - *s++ = (soap_wchar)'<'; - else - { *s++ = (soap_wchar)'&'; - t = "lt;"; - } - break; - case '>': - if (flag) - *s++ = (soap_wchar)'>'; - else - { *s++ = (soap_wchar)'&'; - t = "gt;"; - } - break; - case '"': - if (flag) - *s++ = (soap_wchar)'"'; - else - { *s++ = (soap_wchar)'&'; - t = "quot;"; - } - break; - default: - if ((int)c == EOF) - goto end; - *s++ = (wchar_t)c & 0x7FFFFFFF; - } - l++; - if ((soap->mode & SOAP_XML_STRICT) && maxlen >= 0 && l > maxlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); - soap->error = SOAP_LENGTH; - return NULL; - } - } - } -end: - soap_unget(soap, c); - *s = '\0'; - soap_size_block(soap, sizeof(wchar_t) * (i + 1)); - if ((soap->mode & SOAP_XML_STRICT) && l < minlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too short: %ld chars, minlen=%ld\n", l, minlen)); - soap->error = SOAP_LENGTH; - return NULL; - } - return (wchar_t*)soap_save_block(soap, NULL, 0); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_int2s(struct soap *soap, int n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outint(struct soap *soap, const char *tag, int id, const int *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_long2s(soap, (long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2int(struct soap *soap, const char *s, int *p) -{ if (s) - { char *r; - *p = (int)soap_strtol(s, &r, 10); - if (*r) - soap->error = SOAP_TYPE; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int * -SOAP_FMAC2 -soap_inint(struct soap *soap, const char *tag, int *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (int*)soap_id_enter(soap, soap->id, p, t, sizeof(int), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2int(soap, soap_value(soap), p)) - return NULL; - } - p = (int*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(int), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_long2s(struct soap *soap, long n) -{ sprintf(soap->tmpbuf, "%ld", n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outlong(struct soap *soap, const char *tag, int id, const long *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_long2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2long(struct soap *soap, const char *s, long *p) -{ if (s) - { char *r; - *p = soap_strtol(s, &r, 10); - if (*r) - soap->error = SOAP_TYPE; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -long * -SOAP_FMAC2 -soap_inlong(struct soap *soap, const char *tag, long *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (long*)soap_id_enter(soap, soap->id, p, t, sizeof(long), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2long(soap, soap_value(soap), p)) - return NULL; - } - p = (long*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(long), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_LONG642s(struct soap *soap, LONG64 n) -{ sprintf(soap->tmpbuf, SOAP_LONG_FORMAT, n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outLONG64(struct soap *soap, const char *tag, int id, const LONG64 *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_LONG642s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2LONG64(struct soap *soap, const char *s, LONG64 *p) -{ if (s && sscanf(s, SOAP_LONG_FORMAT, p) != 1) - soap->error = SOAP_TYPE; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -LONG64 * -SOAP_FMAC2 -soap_inLONG64(struct soap *soap, const char *tag, LONG64 *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":integer") - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":negativeInteger") - && soap_match_tag(soap, soap->type, ":nonPositiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":long") - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (LONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(LONG64), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2LONG64(soap, soap_value(soap), p)) - return NULL; - } - p = (LONG64*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(LONG64), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_byte2s(struct soap *soap, char n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outbyte(struct soap *soap, const char *tag, int id, const char *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_long2s(soap, (long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2byte(struct soap *soap, const char *s, char *p) -{ if (s) - { long n; - char *r; - n = soap_strtol(s, &r, 10); - if (*r || n < -128 || n > 127) - soap->error = SOAP_TYPE; - *p = (char)n; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_inbyte(struct soap *soap, const char *tag, char *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (char*)soap_id_enter(soap, soap->id, p, t, sizeof(char), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2byte(soap, soap_value(soap), p)) - return NULL; - } - p = (char*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(char), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_short2s(struct soap *soap, short n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outshort(struct soap *soap, const char *tag, int id, const short *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_long2s(soap, (long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2short(struct soap *soap, const char *s, short *p) -{ if (s) - { long n; - char *r; - n = soap_strtol(s, &r, 10); - if (*r || n < -32768 || n > 32767) - soap->error = SOAP_TYPE; - *p = (short)n; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -short * -SOAP_FMAC2 -soap_inshort(struct soap *soap, const char *tag, short *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (short*)soap_id_enter(soap, soap->id, p, t, sizeof(short), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2short(soap, soap_value(soap), p)) - return NULL; - } - p = (short*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(short), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_float2s(struct soap *soap, float n) -{ const char *s; - if (isnan(n)) - s = "NaN"; - else if (n >= FLT_PINFTY) - s = "INF"; - else if (n <= FLT_NINFTY) - s = "-INF"; - else - { sprintf(soap->tmpbuf, soap->float_format, n); - s = soap->tmpbuf; - } - return s; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outfloat(struct soap *soap, const char *tag, int id, const float *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_float2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2float(struct soap *soap, const char *s, float *p) -{ if (s) - { if (!soap_tag_cmp(s, "INF")) - *p = FLT_PINFTY; - else if (!soap_tag_cmp(s, "+INF")) - *p = FLT_PINFTY; - else if (!soap_tag_cmp(s, "-INF")) - *p = FLT_NINFTY; - else if (!soap_tag_cmp(s, "NaN")) - *p = FLT_NAN; - else - { -#ifdef HAVE_STRTOD - char *r; - *p = (float)strtod(s, &r); - if (*r) -#endif - if (sscanf(s, soap->float_format, p) != 1) - soap->error = SOAP_TYPE; - } - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static int soap_isnumeric(struct soap *soap, const char *type) -{ if (soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":float") - && soap_match_tag(soap, soap->type, ":double") - && soap_match_tag(soap, soap->type, ":decimal") - && soap_match_tag(soap, soap->type, ":integer") - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":negativeInteger") - && soap_match_tag(soap, soap->type, ":nonPositiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":long") - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte") - && soap_match_tag(soap, soap->type, ":unsignedLong") - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return SOAP_ERR; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -float * -SOAP_FMAC2 -soap_infloat(struct soap *soap, const char *tag, float *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type != '\0' && soap_isnumeric(soap, type)) - return NULL; - p = (float*)soap_id_enter(soap, soap->id, p, t, sizeof(float), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2float(soap, soap_value(soap), p)) - return NULL; - } - p = (float*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(float), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_double2s(struct soap *soap, double n) -{ const char *s; - if (isnan(n)) - s = "NaN"; - else if (n >= DBL_PINFTY) - s = "INF"; - else if (n <= DBL_NINFTY) - s = "-INF"; - else - { sprintf(soap->tmpbuf, soap->double_format, n); - s = soap->tmpbuf; - } - return s; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outdouble(struct soap *soap, const char *tag, int id, const double *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_double2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2double(struct soap *soap, const char *s, double *p) -{ if (s) - { if (!soap_tag_cmp(s, "INF")) - *p = DBL_PINFTY; - else if (!soap_tag_cmp(s, "+INF")) - *p = DBL_PINFTY; - else if (!soap_tag_cmp(s, "-INF")) - *p = DBL_NINFTY; - else if (!soap_tag_cmp(s, "NaN")) - *p = DBL_NAN; - else - { -#ifdef HAVE_STRTOD - char *r; - *p = strtod(s, &r); - if (*r) -#endif - if (sscanf(s, soap->double_format, p) != 1) - soap->error = SOAP_TYPE; - } - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -double * -SOAP_FMAC2 -soap_indouble(struct soap *soap, const char *tag, double *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type != '\0' && soap_isnumeric(soap, type)) - return NULL; - p = (double*)soap_id_enter(soap, soap->id, p, t, sizeof(double), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2double(soap, soap_value(soap), p)) - return NULL; - } - p = (double*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(double), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedByte2s(struct soap *soap, unsigned char n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedByte(struct soap *soap, const char *tag, int id, const unsigned char *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_unsignedLong2s(soap, (unsigned long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedByte(struct soap *soap, const char *s, unsigned char *p) -{ if (s) - { unsigned long n; - char *r; - n = soap_strtoul(s, &r, 10); - if (*r || n > 255) - soap->error = SOAP_TYPE; - *p = (unsigned char)n; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned char * -SOAP_FMAC2 -soap_inunsignedByte(struct soap *soap, const char *tag, unsigned char *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (unsigned char*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned char), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2unsignedByte(soap, soap_value(soap), p)) - return NULL; - } - p = (unsigned char*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(unsigned char), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedShort2s(struct soap *soap, unsigned short n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedShort(struct soap *soap, const char *tag, int id, const unsigned short *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_unsignedLong2s(soap, (unsigned long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedShort(struct soap *soap, const char *s, unsigned short *p) -{ if (s) - { unsigned long n; - char *r; - n = soap_strtoul(s, &r, 10); - if (*r || n > 65535) - soap->error = SOAP_TYPE; - *p = (unsigned short)n; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -unsigned short * -SOAP_FMAC2 -soap_inunsignedShort(struct soap *soap, const char *tag, unsigned short *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (unsigned short*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned short), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2unsignedShort(soap, soap_value(soap), p)) - return NULL; - } - p = (unsigned short*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(unsigned short), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedInt2s(struct soap *soap, unsigned int n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedInt(struct soap *soap, const char *tag, int id, const unsigned int *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_unsignedLong2s(soap, (unsigned long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedInt(struct soap *soap, const char *s, unsigned int *p) -{ if (s) - { char *r; - *p = (unsigned int)soap_strtoul(s, &r, 10); - if (*r) - soap->error = SOAP_TYPE; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned int * -SOAP_FMAC2 -soap_inunsignedInt(struct soap *soap, const char *tag, unsigned int *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (unsigned int*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned int), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2unsignedInt(soap, soap_value(soap), p)) - return NULL; - } - p = (unsigned int*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(unsigned int), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedLong2s(struct soap *soap, unsigned long n) -{ sprintf(soap->tmpbuf, "%lu", n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedLong(struct soap *soap, const char *tag, int id, const unsigned long *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_unsignedLong2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedLong(struct soap *soap, const char *s, unsigned long *p) -{ if (s) - { char *r; - *p = soap_strtoul(s, &r, 10); - if (*r) - soap->error = SOAP_TYPE; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned long * -SOAP_FMAC2 -soap_inunsignedLong(struct soap *soap, const char *tag, unsigned long *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (unsigned long*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned long), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2unsignedLong(soap, soap_value(soap), p)) - return NULL; - } - p = (unsigned long*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(unsigned long), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_ULONG642s(struct soap *soap, ULONG64 n) -{ sprintf(soap->tmpbuf, SOAP_ULONG_FORMAT, n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outULONG64(struct soap *soap, const char *tag, int id, const ULONG64 *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_ULONG642s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2ULONG64(struct soap *soap, const char *s, ULONG64 *p) -{ if (s && sscanf(s, SOAP_ULONG_FORMAT, p) != 1) - soap->error = SOAP_TYPE; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -ULONG64 * -SOAP_FMAC2 -soap_inULONG64(struct soap *soap, const char *tag, ULONG64 *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":unsignedLong") - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (ULONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(ULONG64), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2ULONG64(soap, soap_value(soap), p)) - return NULL; - } - p = (ULONG64*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(ULONG64), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2string(struct soap *soap, const char *s, char **t) -{ *t = NULL; - if (s && !(*t = soap_strdup(soap, s))) - soap->error = SOAP_EOM; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2QName(struct soap *soap, const char *s, char **t) -{ if (s) - { struct soap_nlist *np; - const char *p; - if (!strncmp(s, "xml:", 4)) - { *t = soap_strdup(soap, s); - return SOAP_OK; - } - np = soap->nlist; - p = strchr(s, ':'); - if (p) - { register int n = p - s; - while (np && (strncmp(np->id, s, n) || np->id[n])) - np = np->next; - p++; - } - else - { while (np && *np->id) - np = np->next; - p = s; - } - if (np) - { if (np->index >= 0 && soap->local_namespaces) - { register const char *q = soap->local_namespaces[np->index].id; - if (q) - { if ((*t = (char*)soap_malloc(soap, strlen(p) + strlen(q) + 2))) - sprintf(*t, "%s:%s", q, p); - return SOAP_OK; - } - } - if (np->ns) - { if ((*t = (char*)soap_malloc(soap, strlen(p) + strlen(np->ns) + 4))) - sprintf(*t, "\"%s\":%s", np->ns, p); - return SOAP_OK; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Namespace prefix of '%s' not defined (index=%d, URI=%s)\n", s, np->index, np->ns?np->ns:"")); - return soap->error = SOAP_NAMESPACE; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Namespace prefix of '%s' not defined, assuming empty namespace\n", s)); - if ((*t = (char*)soap_malloc(soap, strlen(p) + 4))) - sprintf(*t, "\"\":%s", p); - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_QName2s(struct soap *soap, const char *s) -{ struct Namespace *p; - char *t; - int n; - if (!s || *s != '"') - return s; - s++; - if ((p = soap->local_namespaces)) - { for (; p->id; p++) - { if (p->ns) - if (!soap_tag_cmp(s, p->ns)) - break; - if (p->in) - if (!soap_tag_cmp(s, p->in)) - break; - } - if (p && p->id) - { s = strchr(s, '"'); - if (s) - { t = (char*)soap_malloc(soap, strlen(p->id) + strlen(s)); - strcpy(t, p->id); - strcat(t, s + 1); - return t; - } - } - } - t = (char*)strchr(s, '"'); - if (t) - n = t - s; - else - n = 0; - t = soap_strdup(soap, s); - t[n] = '\0'; - sprintf(soap->tmpbuf, "xmlns:_%lu", soap->idnum++); - soap_set_attr(soap, soap->tmpbuf, t); - s = strchr(s, '"'); - if (s) - { t = (char*)soap_malloc(soap, strlen(soap->tmpbuf) + strlen(s) - 6); - strcpy(t, soap->tmpbuf + 6); - strcat(t, s + 1); - } - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outstring(struct soap *soap, const char *tag, int id, char *const*p, const char *type, int n) -{ id = soap_element_id(soap, tag, id, *p, NULL, 0, type, n); - if (id < 0 - || soap_element_begin_out(soap, tag, id, type) - || soap_string_out(soap, *p, 0) - || soap_element_end_out(soap, tag)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char ** -SOAP_FMAC2 -soap_instring(struct soap *soap, const char *tag, char **p, const char *type, int t, int flag, long minlen, long maxlen) -{ if (soap_element_begin_in(soap, tag, 1)) - return NULL; - if (!p) - if (!(p = (char**)soap_malloc(soap, sizeof(char*)))) - return NULL; - if (soap->body) - { *p = soap_string_in(soap, flag, minlen, maxlen); - if (!*p || !(char*)soap_id_enter(soap, soap->id, *p, t, sizeof(char*), 0, NULL, NULL, NULL)) - return NULL; - } - else - *p = NULL; - p = (char**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(char**), 0); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outwstring(struct soap *soap, const char *tag, int id, wchar_t *const*p, const char *type, int n) -{ id = soap_element_id(soap, tag, id, *p, NULL, 0, type, n); - if (id < 0 - || soap_element_begin_out(soap, tag, id, type) - || soap_wstring_out(soap, *p, 0) - || soap_element_end_out(soap, tag)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t ** -SOAP_FMAC2 -soap_inwstring(struct soap *soap, const char *tag, wchar_t **p, const char *type, int t, long minlen, long maxlen) -{ if (soap_element_begin_in(soap, tag, 1)) - return NULL; - if (!p) - if (!(p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*)))) - return NULL; - if (soap->body) - { *p = soap_wstring_in(soap, 1, minlen, maxlen); - if (!*p || !(wchar_t*)soap_id_enter(soap, soap->id, *p, t, sizeof(wchar_t*), 0, NULL, NULL, NULL)) - return NULL; - } - else - *p = NULL; - p = (wchar_t**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(wchar_t**), 0); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static time_t -soap_timegm(struct tm *T) -{ -#if defined(HAVE_TIMEGM) - return timegm(T); -#elif defined(HAVE_GETTIMEOFDAY) - struct timezone t; - struct timeval tv; - memset((void*)&t, 0, sizeof(t)); - gettimeofday(&tv, &t); - T->tm_min -= t.tz_minuteswest - (t.tz_dsttime != 0)*60; - T->tm_isdst = 0; - return mktime(T); -/* WR[ */ - /* The following define was added for VxWorks*/ -#elif defined(HAVE_MKTIME) - /* FOR VXWORKS: - vxWorks does not seem to have any variable representation of time zones, but - timezone information can be set in INSTALL_DIR/target/h/private/timeP.h header - file, by setting the ZONEBUFFER define. The ZONEBUFFER define follows this - format: - name_of_zone:<(unused)>:time_in_minutes_from_UTC:daylight_start:daylight_end - To calculate local time, the value of time_in_minutes_from_UTC is subtracted - from UTC; time_in_minutes_from_UTC must be positive. Daylight information is - expressed as mmddhh (month-day-hour), for example: - UTC::0:040102:100102 - */ - return mktime(T); -/* ]WR */ -#elif defined(HAVE_FTIME) - struct timeb t; - memset((void*)&t, 0, sizeof(t)); - t.timezone = 0; - t.dstflag = -1; - ftime(&t); - T->tm_min -= t.timezone - (t.dstflag != 0)*60; - T->tm_isdst = 0; - return mktime(T); -#else -#warning "time_t (de)serialization is not MT safe on this platform" - time_t t; - char *tz = getenv("TZ"); - putenv("TZ=UTC"); - tzset(); - t = mktime(T); - if (tz) - { char tmp[16]; - strcpy(tmp, "TZ="); - strncat(tmp, tz, 12); - tmp[15] = '\0'; - putenv(tmp); - } - else - putenv("TZ="); - tzset(); - return t; -#endif -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_dateTime2s(struct soap *soap, time_t n) -{ struct tm T; - struct tm *pT = &T; -#if defined(HAVE_GMTIME_R) - if (gmtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PGMTIME_R) - if (gmtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -#elif defined(HAVE_PGMTIME) - if (gmtime(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -/* ]WR */ -#elif defined(HAVE_GMTIME) - if ((pT = gmtime(&n))) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -#elif defined(HAVE_GETTIMEOFDAY) - struct timezone tz; - memset((void*)&tz, 0, sizeof(tz)); -#if defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - { struct timeval tv; - gettimeofday(&tv, &tz); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -tz.tz_minuteswest/60+(tz.tz_dsttime!=0), abs(tz.tz_minuteswest)%60); - } -#else - if ((pT = localtime(&n))) - { struct timeval tv; - gettimeofday(&tv, &tz); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -tz.tz_minuteswest/60+(tz.tz_dsttime!=0), abs(tz.tz_minuteswest)%60); - } -#endif -#elif defined(HAVE_FTIME) - struct timeb t; - memset((void*)&t, 0, sizeof(t)); -#if defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - { ftime(&t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60+(t.dstflag!=0), abs(t.timezone)%60); - } -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PLOCALTIME_R) - if (localtime_r(&n, pT)) - { strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf+strlen(soap->tmpbuf), "%+03d:%02d", t.timezone/60, abs(t.timezone)%60); - } -/* ]WR */ -#else - if ((pT = localtime(&n))) - { ftime(&t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60+(t.dstflag!=0), abs(t.timezone)%60); - } -#endif -#elif defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PLOCALTIME_R) - if (localtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -/* ]WR */ -#else - if ((pT = localtime(&n))) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -#endif - else - strcpy(soap->tmpbuf, "1969-12-31T23:59:59Z"); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outdateTime(struct soap *soap, const char *tag, int id, const time_t *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_dateTime2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2dateTime(struct soap *soap, const char *s, time_t *p) -{ if (s) - { struct tm T; - char zone[16]; - memset((void*)&T, 0, sizeof(T)); - zone[sizeof(zone)-1] = '\0'; - sscanf(s, "%d-%d-%dT%d:%d:%d%15s", &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec, zone); - if (T.tm_year == 1) - T.tm_year = 70; - else - T.tm_year -= 1900; - T.tm_mon--; - if (*zone) - { if (*zone == '.') - { for (s = zone + 1; *s; s++) - if (*s < '0' || *s > '9') - break; - } - else - s = zone; - if (*s != 'Z') - { int h = 0, m = 0; - sscanf(s, "%d:%d", &h, &m); - T.tm_hour -= h; - if (h >= 0) - T.tm_min -= m; - else - T.tm_min += m; - } - *p = soap_timegm(&T); - } - else - *p = mktime(&T); /* no time zone: suppose it is localtime? */ - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -time_t * -SOAP_FMAC2 -soap_indateTime(struct soap *soap, const char *tag, time_t *p, const char * type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":dateTime")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (time_t*)soap_id_enter(soap, soap->id, p, t, sizeof(time_t), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2dateTime(soap, soap_value(soap), p)) - return NULL; - } - p = (time_t*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(time_t), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outliteral(struct soap *soap, const char *tag, char *const*p) -{ int i; - const char *t = NULL; - if (tag && *tag != '-') - { if ((t = strchr(tag, ':'))) - { strncpy(soap->tmpbuf, tag, t-tag); - soap->tmpbuf[t-tag] = '\0'; - for (i = 0; soap->local_namespaces[i].id; i++) - if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id)) - break; - t++; - sprintf(soap->tmpbuf, "<%s xmlns=\"%s\">", t, soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS); - } - else - { t = tag; - sprintf(soap->tmpbuf, "<%s>", tag); - } - if (soap_send(soap, soap->tmpbuf)) - return soap->error; - } - if (p && *p) - { if (soap_send(soap, *p)) - return soap->error; - } - if (t) - { sprintf(soap->tmpbuf, "", t); - return soap_send(soap, soap->tmpbuf); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char ** -SOAP_FMAC2 -soap_inliteral(struct soap *soap, const char *tag, char **p) -{ if (soap_element_begin_in(soap, tag, 1)) - return NULL; - if (!p) - if (!(p = (char**)soap_malloc(soap, sizeof(char*)))) - return NULL; - if (soap->null) - *p = NULL; - else if (soap->body) - *p = soap_string_in(soap, 0, -1, -1); - else - *p = NULL; - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outwliteral(struct soap *soap, const char *tag, wchar_t *const*p) -{ int i; - const char *t = NULL; - wchar_t c; - const wchar_t *s; - if (tag && *tag != '-') - { if (tag && (t = strchr(tag, ':'))) - { strncpy(soap->tmpbuf, tag, t-tag); - soap->tmpbuf[t-tag] = '\0'; - for (i = 0; soap->local_namespaces[i].id; i++) - if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id)) - break; - t++; - sprintf(soap->tmpbuf, "<%s xmlns=\"%s\">", t, soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS); - } - else - { t = tag; - sprintf(soap->tmpbuf, "<%s>", tag); - } - if (soap_send(soap, soap->tmpbuf)) - return soap->error; - } - if (p) - { s = *p; - while ((c = *s++)) - if (soap_pututf8(soap, (unsigned char)c)) - return soap->error; - } - if (t) - { sprintf(soap->tmpbuf, "", t); - return soap_send(soap, soap->tmpbuf); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t ** -SOAP_FMAC2 -soap_inwliteral(struct soap *soap, const char *tag, wchar_t **p) -{ if (soap_element_begin_in(soap, tag, 1)) - return NULL; - if (!p) - if (!(p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*)))) - return NULL; - if (soap->null) - *p = NULL; - else if (soap->body) - *p = soap_wstring_in(soap, 0, -1, -1); - else - *p = NULL; - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char * -SOAP_FMAC2 -soap_value(struct soap *soap) -{ size_t i; - soap_wchar c = 0; - char *s = soap->tmpbuf; - if (!soap->body) - return SOAP_STR_EOS; - for (i = 0; i < sizeof(soap->tmpbuf) - 1; i++) - { c = soap_get(soap); - if (c == SOAP_TT || (int)c == EOF || soap_blank(c)) - break; - *s++ = (char)c; - } - if ((int)c == EOF || c == SOAP_TT) - soap_unget(soap, c); - *s = '\0'; - return soap->tmpbuf; /* return non-null pointer */ -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getline(struct soap *soap, char *s, int len) -{ int i = len; - soap_wchar c = 0; - for (;;) - { while (--i > 0) - { c = soap_getchar(soap); - if (c == '\r') - break; - if ((int)c == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - c = soap_getchar(soap); - if (c == '\n') - { *s = '\0'; - if (i+1 == len) /* empty line: end of HTTP header */ - break; - c = soap_unget(soap, soap_getchar(soap)); - if (c != ' ' && c != '\t') /* HTTP line continuation? */ - break; - } - else if ((int)c == EOF) - return soap->error = SOAP_EOF; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static size_t -soap_count_attachments(struct soap *soap) -{ -#ifndef WITH_LEANER - register struct soap_multipart *content; - register size_t count = soap->count; - if (soap->mode & SOAP_ENC_DIME) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the size of DIME attachments\n")); - for (content = soap->dime.first; content; content = content->next) - { count += 12 + ((content->size+3)&(~3)); - if (content->id) - count += ((strlen(content->id)+3)&(~3)); - if (content->type) - count += ((strlen(content->type)+3)&(~3)); - if (content->options) - count += ((((unsigned char)content->options[2] << 8) | ((unsigned char)content->options[3]))+7)&(~3); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Size of DIME attachment %lu bytes\n", content->size)); - } - } - if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary) - { register size_t n = strlen(soap->mime.boundary); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the size of MIME attachments\n")); - for (content = soap->mime.first; content; content = content->next) - { register const char *s; - /* count \r\n--boundary\r\n */ - count += 6 + n; - /* count Content-Type: ...\r\n */ - if (content->type) - count += 16 + strlen(content->type); - s = soap_str_code(mime_codes, content->encoding); - /* count Content-Transfer-Encoding: ...\r\n */ - if (s) - count += 29 + strlen(s); - /* count Content-ID: ...\r\n */ - if (content->id) - count += 14 + strlen(content->id); - /* count Content-Location: ...\r\n */ - if (content->location) - count += 20 + strlen(content->location); - /* count Content-Description: ...\r\n */ - if (content->description) - count += 23 + strlen(content->location); - /* count \r\n...content */ - count += 2 + content->size; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Size of MIME attachment %lu bytes\n", content->size)); - } - /* count \r\n--boundary--\r\n */ - count += 8 + n; - } - return count; -#else - return soap->count; -#endif -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static int -soap_putdimefield(struct soap *soap, const char *s, size_t n) -{ if (soap_send_raw(soap, s, n)) - return soap->error; - return soap_send_raw(soap, SOAP_STR_PADDING, -(long)n&3); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_dime_option(struct soap *soap, unsigned short optype, const char *option) -{ size_t n; - char *s = NULL; - if (option) - { n = strlen(option); - s = (char*)soap_malloc(soap, n + 5); - if (s) - { s[0] = optype >> 8; - s[1] = optype & 0xFF; - s[2] = n >> 8; - s[3] = n & 0xFF; - strcpy(s + 4, option); - } - } - return s; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putdimehdr(struct soap *soap) -{ unsigned char tmp[12]; - size_t optlen = 0, idlen = 0, typelen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Put DIME header id='%s'\n", soap->dime.id?soap->dime.id:"")); - if (soap->dime.options) - optlen = (((unsigned char)soap->dime.options[2] << 8) | ((unsigned char)soap->dime.options[3])) + 4; - if (soap->dime.id) - idlen = strlen(soap->dime.id); - if (soap->dime.type) - typelen = strlen(soap->dime.type); - tmp[0] = SOAP_DIME_VERSION | (soap->dime.flags & 0x7); - tmp[1] = soap->dime.flags & 0xF0; - tmp[2] = optlen >> 8; - tmp[3] = optlen & 0xFF; - tmp[4] = idlen >> 8; - tmp[5] = idlen & 0xFF; - tmp[6] = typelen >> 8; - tmp[7] = typelen & 0xFF; - tmp[8] = soap->dime.size >> 24; - tmp[9] = (soap->dime.size >> 16) & 0xFF; - tmp[10] = (soap->dime.size >> 8) & 0xFF; - tmp[11] = soap->dime.size & 0xFF; - if (soap_send_raw(soap, (char*)tmp, 12) - || soap_putdimefield(soap, soap->dime.options, optlen) - || soap_putdimefield(soap, soap->dime.id, idlen) - || soap_putdimefield(soap, soap->dime.type, typelen)) - return soap->error; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putdime(struct soap *soap) -{ struct soap_multipart *content; - if (!(soap->mode & SOAP_ENC_DIME)) - return SOAP_OK; - for (content = soap->dime.first; content; content = content->next) - { void *handle; - soap->dime.size = content->size; - soap->dime.id = content->id; - soap->dime.type = content->type; - soap->dime.options = content->options; - soap->dime.flags = SOAP_DIME_VERSION | SOAP_DIME_MEDIA; - if (soap->fdimereadopen && ((handle = soap->fdimereadopen(soap, (void*)content->ptr, content->id, content->type, content->options)) || soap->error)) - { size_t size = content->size; - if (!handle) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadopen failed\n")); - return soap->error; - } - if (!content->size && ((soap->mode & SOAP_ENC_XML) || (soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_IO) == SOAP_IO_STORE)) - { size_t chunksize = sizeof(soap->tmpbuf); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked streaming DIME\n")); - do - { size = soap->fdimeread(soap, handle, soap->tmpbuf, chunksize); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread returned %lu bytes\n", (unsigned long)size)); - if (size < chunksize) - { soap->dime.flags &= ~SOAP_DIME_CF; - if (!content->next) - soap->dime.flags |= SOAP_DIME_ME; - } - else - soap->dime.flags |= SOAP_DIME_CF; - soap->dime.size = size; - if (soap_putdimehdr(soap) - || soap_putdimefield(soap, soap->tmpbuf, size)) - break; - if (soap->dime.id) - { soap->dime.flags &= ~(SOAP_DIME_MB | SOAP_DIME_MEDIA); - soap->dime.id = NULL; - soap->dime.type = NULL; - soap->dime.options = NULL; - } - } while (size >= chunksize); - } - else - { if (!content->next) - soap->dime.flags |= SOAP_DIME_ME; - if (soap_putdimehdr(soap)) - return soap->error; - do - { size_t bufsize; - if (size < sizeof(soap->tmpbuf)) - bufsize = size; - else - bufsize = sizeof(soap->tmpbuf); - if (!(bufsize = soap->fdimeread(soap, handle, soap->tmpbuf, bufsize))) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread failed: insufficient data (%lu bytes remaining from %lu bytes)\n", (unsigned long)size, (unsigned long)soap->dime.size)); - soap->error = SOAP_EOF; - break; - } - if (soap_send_raw(soap, soap->tmpbuf, bufsize)) - break; - size -= bufsize; - } while (size); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n")); - soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime.size&3); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n")); - if (soap->fdimereadclose) - soap->fdimereadclose(soap, handle); - } - else - { if (!content->next) - soap->dime.flags |= SOAP_DIME_ME; - if (soap_putdimehdr(soap) - || soap_putdimefield(soap, (char*)content->ptr, content->size)) - return soap->error; - } - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static char * -soap_getdimefield(struct soap *soap, size_t n) -{ register soap_wchar c; - register int i; - register char *s; - char *p = NULL; - if (n) - { p = (char*)soap_malloc(soap, n + 1); - if (p) - { s = p; - for (i = n; i > 0; i--) - { if ((int)(c = soap_get1(soap)) == EOF) - { soap->error = SOAP_EOF; - return NULL; - } - *s++ = (char)c; - } - *s = '\0'; - if ((soap->error = soap_move(soap, -(long)n&3))) - return NULL; - } - else - soap->error = SOAP_EOM; - } - return p; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getdimehdr(struct soap *soap) -{ register soap_wchar c; - register char *s; - register int i; - unsigned char tmp[12]; - size_t optlen, idlen, typelen; - if (!(soap->mode & SOAP_ENC_DIME)) - return soap->error = SOAP_DIME_END; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME header\n")); - if (soap->dime.buflen || soap->dime.chunksize) - { if (soap_move(soap, (long)(soap->dime.size - soap_tell(soap)))) - return soap->error = SOAP_EOF; - soap_unget(soap, soap_getchar(soap)); /* skip padding and get hdr */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... From chunked\n")); - return SOAP_OK; - } - s = (char*)tmp; - for (i = 12; i > 0; i--) - { if ((int)(c = soap_getchar(soap)) == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - if ((tmp[0] & 0xF8) != SOAP_DIME_VERSION) - return soap->error = SOAP_DIME_MISMATCH; - soap->dime.flags = (tmp[0] & 0x7) | (tmp[1] & 0xF0); - optlen = (tmp[2] << 8) | tmp[3]; - idlen = (tmp[4] << 8) | tmp[5]; - typelen = (tmp[6] << 8) | tmp[7]; - soap->dime.size = (tmp[8] << 24) | (tmp[9] << 16) | (tmp[10] << 8) | tmp[11]; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME size=%lu flags=0x%X\n", (unsigned long)soap->dime.size, soap->dime.flags)); - if (!(soap->dime.options = soap_getdimefield(soap, optlen)) && soap->error) - return soap->error; - if (!(soap->dime.id = soap_getdimefield(soap, idlen)) && soap->error) - return soap->error; - if (!(soap->dime.type = soap_getdimefield(soap, typelen)) && soap->error) - return soap->error; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME id=%s, type=%s, options=%s\n", soap->dime.id?soap->dime.id:"", soap->dime.type?soap->dime.type:"", soap->dime.options?soap->dime.options+4:"")); - if (soap->dime.flags & SOAP_DIME_ME) - soap->mode &= ~SOAP_ENC_DIME; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getdime(struct soap *soap) -{ struct soap_multipart *content; - if (soap_getdimehdr(soap)) - return soap->error; - if (soap->fdimewriteopen && ((soap->dime.ptr = (char*)soap->fdimewriteopen(soap, soap->dime.id, soap->dime.type, soap->dime.options)) || soap->error)) - { const char *id, *type, *options; - size_t size, n; - if (!soap->dime.ptr) - return soap->error; - id = soap->dime.id; - type = soap->dime.type; - options = soap->dime.options; - for (;;) - { size = soap->dime.size; - for (;;) - { n = soap->buflen - soap->bufidx; - if (size < n) - n = size; - if ((soap->error = soap->fdimewrite(soap, (void*)soap->dime.ptr, soap->buf + soap->bufidx, n))) - break; - size -= n; - if (!size) - { soap->bufidx += n; - break; - } - if (soap_recv(soap)) - { soap->error = SOAP_EOF; - goto end; - } - } - if (soap_move(soap, -(long)soap->dime.size&3)) - { soap->error = SOAP_EOF; - break; - } - if (!(soap->dime.flags & SOAP_DIME_CF)) - break; - if (soap_getdimehdr(soap)) - break; - } -end: - if (soap->fdimewriteclose) - soap->fdimewriteclose(soap, (void*)soap->dime.ptr); - soap->dime.size = 0; - soap->dime.id = id; - soap->dime.type = type; - soap->dime.options = options; - } - else if (soap->dime.flags & SOAP_DIME_CF) - { const char *id, *type, *options; - register soap_wchar c; - register char *s; - register int i; - id = soap->dime.id; - type = soap->dime.type; - options = soap->dime.options; - if (soap_new_block(soap)) - return SOAP_EOM; - for (;;) - { s = (char*)soap_push_block(soap, soap->dime.size); - if (!s) - return soap->error = SOAP_EOM; - for (i = soap->dime.size; i > 0; i--) - { if ((int)(c = soap_get1(soap)) == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - if (soap_move(soap, -(long)soap->dime.size&3)) - return soap->error = SOAP_EOF; - if (!(soap->dime.flags & SOAP_DIME_CF)) - break; - if (soap_getdimehdr(soap)) - return soap->error; - } - soap->dime.size = soap->blist->size++; /* allocate one more for '\0' */ - if (!(soap->dime.ptr = soap_save_block(soap, NULL, 0))) - return soap->error; - soap->dime.ptr[soap->dime.size] = '\0'; /* force 0-terminated */ - soap->dime.id = id; - soap->dime.type = type; - soap->dime.options = options; - } - else - soap->dime.ptr = soap_getdimefield(soap, soap->dime.size); - content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, soap->dime.ptr, soap->dime.size); - if (!content) - return soap->error = SOAP_EOM; - content->id = soap->dime.id; - content->type = soap->dime.type; - content->options = soap->dime.options; - return soap->error; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getmimehdr(struct soap *soap) -{ struct soap_multipart *content; - do - { if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf))) - return soap->error; - } - while (!*soap->msgbuf); - if (soap->msgbuf[0] == '-' && soap->msgbuf[1] == '-') - { char *s = soap->msgbuf + strlen(soap->msgbuf) - 1; - /* remove white space */ - while (soap_blank(*s)) - s--; - s[1] = '\0'; - if (soap->mime.boundary) - { if (strcmp(soap->msgbuf + 2, soap->mime.boundary)) - return soap->error = SOAP_MIME_ERROR; - } - else - soap->mime.boundary = soap_strdup(soap, soap->msgbuf + 2); - if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf))) - return soap->error; - } - if (soap_set_mime_attachment(soap, NULL, 0, SOAP_MIME_NONE, NULL, NULL, NULL, NULL)) - return soap->error = SOAP_EOM; - content = soap->mime.last; - for (;;) - { register char *key = soap->msgbuf; - register char *val; - if (!*key) - break; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "MIME header: %s\n", key)); - val = strchr(soap->msgbuf, ':'); - if (val) - { *val = '\0'; - do val++; - while (*val && *val <= 32); - if (!soap_tag_cmp(key, "Content-ID")) - content->id = soap_strdup(soap, val); - else if (!soap_tag_cmp(key, "Content-Location")) - content->location = soap_strdup(soap, val); - else if (!soap_tag_cmp(key, "Content-Type")) - content->type = soap_strdup(soap, val); - else if (!soap_tag_cmp(key, "Content-Description")) - content->description = soap_strdup(soap, val); - else if (!soap_tag_cmp(key, "Content-Transfer-Encoding")) - content->encoding = (enum soap_mime_encoding)soap_int_code(mime_codes, val, (long)SOAP_MIME_NONE); - } - if (soap_getline(soap, key, sizeof(soap->msgbuf))) - return soap->error; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getmime(struct soap *soap) -{ register char c; - for (;;) - { register size_t i, m = 0; - register char *s; - struct soap_multipart *content = soap->mime.last; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Parsing MIME content id=%s type=%s\n", content->id?content->id:"", content->type?content->type:"")); - if (soap_new_block(soap)) - return soap->error = SOAP_EOM; - for (;;) - { register char *t = NULL; - if (!(s = (char*)soap_push_block(soap, SOAP_BLKLEN))) - return soap->error = SOAP_EOM; - for (i = 0; i < SOAP_BLKLEN; i++) - { if (m > 0) - { *s++ = *t++; - m--; - } - else - { c = soap_get1(soap); - if ((int)c == EOF) - return soap->error = SOAP_EOF; - if (c == '\r') - { t = soap->tmpbuf; - strcpy(t, "\n--"); - strncat(t, soap->mime.boundary, sizeof(soap->tmpbuf)-3); - t[sizeof(soap->tmpbuf)-1] = '\0'; - do c = soap_get1(soap); - while ((char)c == *t++); - if ((int)c == EOF) - return soap->error = SOAP_EOF; - if (!*--t) - goto end; - *t = (char)c; - m = t - soap->tmpbuf + 1; - t = soap->tmpbuf; - c = '\r'; - } - *s++ = (char)c; - } - } - } -end: - *s = '\0'; /* force 0-terminated */ - content->size = soap_size_block(soap, i+1)-1; - content->ptr = soap_save_block(soap, NULL, 0); - if (c == '-' && (int)soap_get1(soap) == '-') - break; - while (c != '\r' && (int)c != EOF && soap_blank(c)) - c = soap_get1(soap); - if (c != '\r' || (int)soap_get1(soap) != '\n') - return soap->error = SOAP_MIME_ERROR; - if (soap_getmimehdr(soap)) - return soap->error; - } - do c = soap_get1(soap); - while ((int)c != EOF && c != '\r'); - if ((int)c == EOF) - return soap->error = SOAP_EOF; - if (soap_get1(soap) != '\n') - return soap->error = SOAP_MIME_ERROR; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putmimehdr(struct soap *soap, struct soap_multipart *content) -{ const char *s; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "MIME attachment type=%s\n", content->type?content->type:"")); - if (soap_send3(soap, "\r\n--", soap->mime.boundary, "\r\n")) - return soap->error; - if (content->type && soap_send3(soap, "Content-Type: ", content->type, "\r\n")) - return soap->error; - s = soap_str_code(mime_codes, content->encoding); - if (s && soap_send3(soap, "Content-Transfer-Encoding: ", s, "\r\n")) - return soap->error; - if (content->id && soap_send3(soap, "Content-ID: ", content->id, "\r\n")) - return soap->error; - if (content->location && soap_send3(soap, "Content-Location: ", content->location, "\r\n")) - return soap->error; - if (content->description && soap_send3(soap, "Content-Description: ", content->description, "\r\n")) - return soap->error; - return soap_send_raw(soap, "\r\n", 2); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putmime(struct soap *soap) -{ struct soap_multipart *content; - if (!(soap->mode & SOAP_ENC_MIME) || !soap->mime.boundary) - return SOAP_OK; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending MIME attachments\n")); - for (content = soap->mime.first; content; content = content->next) - if (soap_putmimehdr(soap, content) - || soap_send_raw(soap, content->ptr, content->size)) - return soap->error; - return soap_send3(soap, "\r\n--", soap->mime.boundary, "--\r\n"); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_dime(struct soap *soap) -{ soap->omode |= SOAP_ENC_DIME; - soap->dime.first = NULL; - soap->dime.last = NULL; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_mime(struct soap *soap, const char *boundary, const char *start) -{ soap->omode |= SOAP_ENC_MIME; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->mime.boundary = soap_strdup(soap, boundary); - soap->mime.start = soap_strdup(soap, start); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_dime(struct soap *soap) -{ soap->omode &= ~SOAP_ENC_DIME; - soap->dime.first = NULL; - soap->dime.last = NULL; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_mime(struct soap *soap) -{ soap->omode &= ~SOAP_ENC_MIME; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->mime.boundary = NULL; - soap->mime.start = NULL; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static struct soap_multipart* -soap_new_multipart(struct soap *soap, struct soap_multipart **first, struct soap_multipart **last, char *ptr, size_t size) -{ struct soap_multipart *content; - content = (struct soap_multipart*)soap_malloc(soap, sizeof(struct soap_multipart)); - if (content) - { content->next = NULL; - content->ptr = ptr; - content->size = size; - content->id = NULL; - content->type = NULL; - content->options = NULL; - content->encoding = SOAP_MIME_NONE; - content->location = NULL; - content->description = NULL; - if (!*first) - *first = content; - if (*last) - (*last)->next = content; - *last = content; - } - return content; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_dime_attachment(struct soap *soap, char *ptr, size_t size, const char *type, const char *id, unsigned short optype, const char *option) -{ struct soap_multipart *content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, ptr, size); - if (!content) - return SOAP_EOM; - content->id = soap_strdup(soap, id); - content->type = soap_strdup(soap, type); - content->options = soap_dime_option(soap, optype, option); - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_mime_attachment(struct soap *soap, char *ptr, size_t size, enum soap_mime_encoding encoding, const char *type, const char *id, const char *location, const char *description) -{ struct soap_multipart *content = soap_new_multipart(soap, &soap->mime.first, &soap->mime.last, ptr, size); - if (!content) - return SOAP_EOM; - content->id = soap_strdup(soap, id); - content->type = soap_strdup(soap, type); - content->encoding = encoding; - content->location = soap_strdup(soap, location); - content->description = soap_strdup(soap, description); - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -struct soap_multipart* -SOAP_FMAC2 -soap_next_multipart(struct soap_multipart *content) -{ if (content) - return content->next; - return NULL; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static void -soap_select_mime_boundary(struct soap *soap) -{ while (!soap->mime.boundary || soap_valid_mime_boundary(soap)) - { char *s = soap->mime.boundary; - size_t n = 0; - if (s) - n = strlen(s); - if (n < 16) - { n = 72; - s = soap->mime.boundary = (char*)soap_malloc(soap, n); - if (!s) - return; - } - strcpy(s, "<>"); - s += 2; - n -= 4; - while (n) - { *s++ = soap_base64o[rand()&0x3F]; - n--; - } - *s = '\0'; - strcat(s, "<>"); - } - if (!soap->mime.start) - soap->mime.start = ""; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static int -soap_valid_mime_boundary(struct soap *soap) -{ register struct soap_multipart *content; - register size_t k = strlen(soap->mime.boundary); - for (content = soap->mime.first; content; content = content->next) - { if (content->ptr && content->size >= k) - { register const char *p = (const char*)content->ptr; - register size_t i; - for (i = 0; i < content->size - k; i++, p++) - if (!strncmp(p, soap->mime.boundary, k)) - return SOAP_ERR; - } - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ - -#ifdef WITH_COOKIES -/******************************************************************************/ -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_encode_cookie(const char *s, char *t, size_t len) -{ register int c; - register size_t n = len; - while ((c = *s++) && --n > 0) - { if (c > ' ' && c < 128 && c != ';' && c != ',') - *t++ = c; - else if (n > 2) - { *t++ = '%'; - *t++ = (c >> 4) + (c > 159 ? '7' : '0'); - c &= 0xF; - *t++ = c + (c > 9 ? '7' : '0'); - n -= 2; - } - else - break; - } - *t = '\0'; - return len - n; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_cookie(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - size_t n; - if (!domain) - domain = soap->cookie_domain; - if (!path) - path = soap->cookie_path; - if (*path == '/') - path++; - n = strlen(path); - for (p = soap->cookies; p; p = p->next) - if (!strcmp(p->name, name) - && domain - && p->domain - && !strcmp(p->domain, domain) - && !strncmp(p->path, path, n)) - break; - return p; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_set_cookie(struct soap *soap, const char *name, const char *value, const char *domain, const char *path) -{ struct soap_cookie **p, *q; - int n; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set cookie: %s=%s domain=%s path=%s\n", name, value?value:"", domain?domain:"", path?path:"")); - if (!domain) - domain = soap->cookie_domain; - if (!path) - path = soap->cookie_path; - if (!path) - { soap_set_receiver_error(soap, "Cookie path not set", NULL, SOAP_HTTP_ERROR); - return NULL; - } - if (*path == '/') - path++; - q = soap_cookie(soap, name, domain, path); - if (!q) - { if ((q = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - { if ((q->name = (char*)SOAP_MALLOC(strlen(name)+1))) - strcpy(q->name, name); - q->value = NULL; - q->domain = NULL; - q->path = NULL; - q->expire = -1; - q->version = 0; - q->secure = 0; - q->env = 0; - q->modified = 0; - for (p = &soap->cookies, n = soap->cookie_max; *p && n; p = &(*p)->next, n--) - if (!strcmp((*p)->name, name) && (*p)->path && strcmp((*p)->path, path) < 0) - break; - if (n) - { q->next = *p; - *p = q; - } - else - { SOAP_FREE(q->name); - SOAP_FREE(q); - q = NULL; - } - } - } - else - q->modified = 1; - if (q) - { if (q->value) - { SOAP_FREE(q->value); - q->value = NULL; - } - if (q->domain) - { SOAP_FREE(q->domain); - q->domain = NULL; - } - if (q->path) - { SOAP_FREE(q->path); - q->path = NULL; - } - if (value && *value && (q->value = (char*)SOAP_MALLOC(strlen(value)+1))) - strcpy(q->value, value); - if (domain && *domain && (q->domain = (char*)SOAP_MALLOC(strlen(domain)+1))) - strcpy(q->domain, domain); - if (path && *path && (q->path = (char*)SOAP_MALLOC(strlen(path)+1))) - strcpy(q->path, path); - q->session = 1; - } - return q; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_cookie(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie **p, *q; - if (!domain) - domain = soap->cookie_domain; - if (!domain) - { soap_set_receiver_error(soap, "Cookie domain not set", SOAP_STR_EOS, SOAP_HTTP_ERROR); - return; - } - if (!path) - path = soap->cookie_path; - if (!path) - { soap_set_receiver_error(soap, "Cookie path not set", SOAP_STR_EOS, SOAP_HTTP_ERROR); - return; - } - if (*path == '/') - path++; - for (p = &soap->cookies, q = *p; q; q = *p) - if (!strcmp(q->name, name) && !strcmp(q->domain, domain) && !strncmp(q->path, path, strlen(q->path))) - { if (q->value) - SOAP_FREE(q->value); - if (q->domain) - SOAP_FREE(q->domain); - if (q->path) - SOAP_FREE(q->path); - *p = q->next; - SOAP_FREE(q); - } - else - p = &q->next; -} - -/******************************************************************************/ -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_cookie_value(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - return p->value; - return NULL; -} - -/******************************************************************************/ -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_cookie_expire(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - return p->expire; - return -1; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_cookie_expire(struct soap *soap, const char *name, long expire, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->expire = expire; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->session = 1; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_clr_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->session = 0; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putsetcookies(struct soap *soap) -{ struct soap_cookie *p; - char *s, tmp[4096]; - const char *t; - for (p = soap->cookies; p; p = p->next) - { if (p->modified || !p->env) - { s = tmp; - if (p->name) - s += soap_encode_cookie(p->name, s, tmp-s+4064); - if (p->value && *p->value) - { *s++ = '='; - s += soap_encode_cookie(p->value, s, tmp-s+4064); - } - if (p->domain && (int)strlen(p->domain) < tmp-s+4064) - sprintf(s, ";Domain=%s", p->domain); - else if (soap->cookie_domain && (int)strlen(soap->cookie_domain) < tmp-s+4064) - sprintf(s, ";Domain=%s", soap->cookie_domain); - strcat(s, ";Path=/"); - if (p->path) - t = p->path; - else - t = soap->cookie_path; - if (t) - { if (*t == '/') - t++; - if ((int)strlen(t) < tmp-s+4064) - strcat(s, t); - } - s += strlen(s); - if (p->version > 0) - sprintf(s, ";Version=%u", p->version); - if (p->expire >= 0) - sprintf(s, ";Max-Age=%ld", p->expire); - if (p->secure) - strcat(s, ";Secure"); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set-Cookie: %s\n", tmp)); - if (soap->fposthdr(soap, "Set-Cookie", tmp)) - return soap->error; - } - } - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putcookies(struct soap *soap, const char *domain, const char *path, int secure) -{ struct soap_cookie **p, *q; - unsigned int version = 0; - time_t now = time(NULL); - char *s, tmp[4096]; - p = &soap->cookies; - while ((q = *p)) - { if (q->expire && now > q->expire) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie %s expired\n", q->name)); - SOAP_FREE(q->name); - if (q->value) - SOAP_FREE(q->value); - if (q->domain) - SOAP_FREE(q->domain); - if (q->path) - SOAP_FREE(q->path); - *p = q->next; - SOAP_FREE(q); - } - else if ((!q->domain || !strcmp(q->domain, domain)) - && (!q->path || !strncmp(q->path, path, strlen(q->path))) - && (!q->secure || secure)) - { s = tmp; - if (q->version != version) - { sprintf(s, "$Version=%u;", q->version); - version = q->version; - } - if (q->name) - s += soap_encode_cookie(q->name, s, tmp-s+4080); - if (q->value && *q->value) - { *s++ = '='; - s += soap_encode_cookie(q->value, s, tmp-s+4080); - } - if (q->path && (int)strlen(q->path) < tmp-s+4080) - { sprintf(s, ";$Path=/%s", q->path); - s += strlen(s); - } - if (q->domain && (int)strlen(q->domain) < tmp-s+4080) - sprintf(s, ";$Domain=%s", q->domain); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie: %s\n", tmp)); - if (soap->fposthdr(soap, "Cookie", tmp)) - return soap->error; - p = &q->next; - } - else - p = &q->next; - } - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_getcookies(struct soap *soap, const char *val) -{ struct soap_cookie *p = NULL, *q; - const char *s; - char *t, tmp[4096]; /* cookie size is up to 4096 bytes [RFC2109] */ - char *domain = NULL; - char *path = NULL; - unsigned int version = 0; - time_t now = time(NULL); - if (!val) - return; - s = val; - while (*s) - { s = soap_decode_key(tmp, sizeof(tmp), s); - if (!soap_tag_cmp(tmp, "$Version")) - { if ((s = soap_decode_val(tmp, sizeof(tmp), s))) - { if (p) - p->version = (int)atol(tmp); - else - version = (int)atol(tmp); - } - } - else if (!soap_tag_cmp(tmp, "$Path")) - { s = soap_decode_val(tmp, sizeof(tmp), s); - if (*tmp) - { if ((t = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(t, tmp); - } - else - t = NULL; - if (p) - { if (p->path) - SOAP_FREE(p->path); - p->path = t; - } - else - { if (path) - SOAP_FREE(path); - path = t; - } - } - else if (!soap_tag_cmp(tmp, "$Domain")) - { s = soap_decode_val(tmp, sizeof(tmp), s); - if (*tmp) - { if ((t = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(t, tmp); - } - else - t = NULL; - if (p) - { if (p->domain) - SOAP_FREE(p->domain); - p->domain = t; - } - else - { if (domain) - SOAP_FREE(domain); - domain = t; - } - } - else if (p && !soap_tag_cmp(tmp, "Path")) - { if (p->path) - SOAP_FREE(p->path); - s = soap_decode_val(tmp, sizeof(tmp), s); - if (*tmp) - { if ((p->path = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(p->path, tmp); - } - else - p->path = NULL; - } - else if (p && !soap_tag_cmp(tmp, "Domain")) - { if (p->domain) - SOAP_FREE(p->domain); - s = soap_decode_val(tmp, sizeof(tmp), s); - if (*tmp) - { if ((p->domain = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(p->domain, tmp); - } - else - p->domain = NULL; - } - else if (p && !soap_tag_cmp(tmp, "Version")) - { s = soap_decode_val(tmp, sizeof(tmp), s); - p->version = (unsigned int)atol(tmp); - } - else if (p && !soap_tag_cmp(tmp, "Max-Age")) - { s = soap_decode_val(tmp, sizeof(tmp), s); - p->expire = now + atol(tmp); - } - else if (p && !soap_tag_cmp(tmp, "Expires")) - { struct tm T; - char a[3]; - static const char mns[] = "anebarprayunulugepctovec"; - s = soap_decode_val(tmp, sizeof(tmp), s); - if (strlen(tmp) > 20) - { memset((void*)&T, 0, sizeof(T)); - a[0] = tmp[4]; - a[1] = tmp[5]; - a[2] = '\0'; - T.tm_mday = (int)atol(a); - a[0] = tmp[8]; - a[1] = tmp[9]; - T.tm_mon = (strstr(mns, a) - mns) / 2; - a[0] = tmp[11]; - a[1] = tmp[12]; - T.tm_year = 100 + (int)atol(a); - a[0] = tmp[13]; - a[1] = tmp[14]; - T.tm_hour = (int)atol(a); - a[0] = tmp[16]; - a[1] = tmp[17]; - T.tm_min = (int)atol(a); - a[0] = tmp[19]; - a[1] = tmp[20]; - T.tm_sec = (int)atol(a); - p->expire = soap_timegm(&T); - } - } - else if (p && !soap_tag_cmp(tmp, "Secure")) - p->secure = 1; - else - { if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"", p->domain?p->domain:"", p->path?p->path:"", p->expire, p->secure)); - if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) - { q->version = p->version; - q->expire = p->expire; - q->secure = p->secure; - q->env = 1; - } - if (p->name) - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } - if ((p = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - { p->name = (char*)SOAP_MALLOC(strlen(tmp)+1); - strcpy(p->name, tmp); - s = soap_decode_val(tmp, sizeof(tmp), s); - if (*tmp) - { p->value = (char*)SOAP_MALLOC(strlen(tmp)+1); - strcpy(p->value, tmp); - } - else - p->value = NULL; - p->domain = domain; - p->path = path; - p->expire = 0; - p->secure = 0; - p->version = version; - } - } - } - if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"", p->domain?p->domain:"", p->path?p->path:"", p->expire, p->secure)); - if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) - { q->version = p->version; - q->expire = p->expire; - q->secure = p->secure; - } - if (p->name) - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } - if (domain) - SOAP_FREE(domain); - if (path) - SOAP_FREE(path); -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getenv_cookies(struct soap *soap) -{ struct soap_cookie *p; - const char *s; - char key[4096], val[4096]; /* cookie size is up to 4096 bytes [RFC2109] */ - if (!(s = getenv("HTTP_COOKIE"))) - return SOAP_ERR; - do - { s = soap_decode_key(key, sizeof(key), s); - s = soap_decode_val(val, sizeof(val), s); - p = soap_set_cookie(soap, key, val, NULL, NULL); - if (p) - p->env = 1; - } while (*s); - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_copy_cookies(struct soap *soap) -{ struct soap_cookie *p, **q, *r; - q = &r; - for (p = soap->cookies; p; p = p->next) - { if (!(*q = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - return r; - **q = *p; - if (p->name) - { if (((*q)->name = (char*)SOAP_MALLOC(strlen(p->name)+1))) - strcpy((*q)->name, p->name); - } - if (p->value) - { if (((*q)->value = (char*)SOAP_MALLOC(strlen(p->value)+1))) - strcpy((*q)->value, p->value); - } - if (p->domain) - { if (((*q)->domain = (char*)SOAP_MALLOC(strlen(p->domain)+1))) - strcpy((*q)->domain, p->domain); - } - if (p->path) - { if (((*q)->path = (char*)SOAP_MALLOC(strlen(p->path)+1))) - strcpy((*q)->path, p->path); - } - q = &(*q)->next; - } - *q = NULL; - return r; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_free_cookies(struct soap *soap) -{ struct soap_cookie *p; - for (p = soap->cookies; p; p = soap->cookies) - { soap->cookies = p->next; - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } -} - -/******************************************************************************/ -#endif /* WITH_COOKIES */ - -/******************************************************************************/ -#ifdef WITH_GZIP -#ifndef PALM_2 -static int -soap_getgziphdr(struct soap *soap) -{ int i; - soap_wchar c, f = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get gzip header\n")); - for (i = 0; i < 9; i++) - { if ((int)(c = soap_get1(soap) == EOF)) - return soap->error = SOAP_EOF; - if (i == 2) - f = c; - } - if (f & 0x04) /* FEXTRA */ - { for (i = soap_get1(soap) | (soap_get1(soap) << 8); i; i--) - if ((int)soap_get1(soap) == EOF) - return soap->error = SOAP_EOF; - } - if (f & 0x08) /* FNAME */ - do - c = soap_get1(soap); - while (c && (int)c != EOF); - if ((int)c != EOF && (f & 0x10)) /* FCOMMENT */ - do - c = soap_get1(soap); - while (c && (int)f != EOF); - if ((int)c != EOF && (f & 0x01)) /* FHCRC */ - { if ((int)(c = soap_get1(soap)) != EOF) - c = soap_get1(soap); - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_begin_recv(struct soap *soap) -{ soap_wchar c; - soap->error = SOAP_OK; - soap_free(soap); - soap_set_local_namespaces(soap); - soap->version = 0; /* don't assume we're parsing SOAP content by default */ - soap_free_iht(soap); - if ((soap->imode & SOAP_IO) == SOAP_IO_CHUNK) - soap->omode |= SOAP_IO_CHUNK; - soap->imode &= ~SOAP_IO; - soap->mode = soap->imode; - if (!soap->keep_alive) - { soap->buflen = 0; - soap->bufidx = 0; - } - if (!(soap->mode & SOAP_IO_KEEPALIVE)) - soap->keep_alive = 0; - soap->ahead = 0; - soap->peeked = 0; - soap->level = 0; - soap->part = SOAP_BEGIN; - soap->alloced = 0; - soap->count = 0; - soap->length = 0; - soap->cdata = 0; - *soap->endpoint = '\0'; - soap->userid = NULL; - soap->passwd = NULL; - soap->action = NULL; - soap->authrealm = NULL; - soap->dime.chunksize = 0; - soap->dime.buflen = 0; - soap->dime.list = NULL; - soap->dime.first = NULL; - soap->dime.last = NULL; - soap->mime.list = NULL; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->mime.boundary = NULL; - soap->mime.start = NULL; -#ifdef WIN32 -#ifndef UNDER_CE -#ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket)) -#ifdef __BORLANDC__ - setmode((SOAP_SOCKET)soap->recvfd, O_BINARY); -#else - _setmode((SOAP_SOCKET)soap->recvfd, _O_BINARY); -#endif -#endif -#endif -#endif -#ifdef WITH_ZLIB - soap->mode &= ~SOAP_ENC_ZLIB; - soap->zlib_in = SOAP_ZLIB_NONE; - soap->zlib_out = SOAP_ZLIB_NONE; - soap->d_stream.next_in = Z_NULL; - soap->d_stream.avail_in = 0; - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - soap->z_ratio_in = 1.0; - if (soap->fprepareinit) - soap->fprepareinit(soap); -#endif - c = soap_getchar(soap); -#ifdef WITH_GZIP - if (c == 0x1F) - { if (soap_getgziphdr(soap)) - return soap->error; - if (inflateInit2(&soap->d_stream, -MAX_WBITS) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - soap->mode |= SOAP_ENC_ZLIB; - soap->zlib_in = SOAP_ZLIB_GZIP; - soap->z_crc = crc32(0L, NULL, 0); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n")); - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - /* should not chunk over plain transport, so why bother to check? */ - /* if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) */ - /* soap->z_buflen = soap->bufidx; */ - /* else */ - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = soap->buflen - soap->bufidx; - soap->z_buflen = soap->buflen; - soap->buflen = soap->bufidx; - c = soap_getchar(soap); - } -#endif - if (c == '-' && soap_get0(soap) == '-') - soap->mode |= SOAP_ENC_MIME; - else if ((c & 0xFFFC) == (SOAP_DIME_VERSION | SOAP_DIME_MB) && (soap_get0(soap) & 0xFFF0) == 0x20) - soap->mode |= SOAP_ENC_DIME; - else - { while (soap_blank(c)) - c = soap_getchar(soap); - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - soap_unget(soap, c); - if (c != '<' && !(soap->mode & (SOAP_ENC_DIME | SOAP_ENC_ZLIB))) - { soap->mode &= ~SOAP_IO; - if ((soap->error = soap->fparse(soap))) - { soap->keep_alive = 0; /* force close later */ - return soap->error; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { soap->chunkbuflen = soap->buflen; - soap->buflen = soap->bufidx; - soap->chunksize = 0; - } - else if (soap->fpreparerecv && soap->buflen != soap->bufidx) - soap->fpreparerecv(soap, soap->buf + soap->bufidx, soap->buflen - soap->bufidx); -#ifdef WITH_ZLIB - if (soap->zlib_in) - { /* fparse should not use soap_unget to push back last char */ -#ifdef WITH_GZIP - c = soap_get1(soap); - if (c == 0x1F) - { if (soap_getgziphdr(soap)) - return soap->error; - if (inflateInit2(&soap->d_stream, -MAX_WBITS) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - soap->z_crc = crc32(0L, NULL, 0); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n")); - } - else - { soap_revget1(soap); -#else - { -#endif - if (inflateInit(&soap->d_stream) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate initialized\n")); - } - soap->mode |= SOAP_ENC_ZLIB; - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = soap->buflen - soap->bufidx; - soap->z_buflen = soap->buflen; - soap->buflen = soap->bufidx; - } -#endif - } -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_MIME) - { if (soap_getmimehdr(soap)) - return soap->error; - if (soap_get_header_attribute(soap, soap->mime.first->type, "application/dime")) - soap->mode |= SOAP_ENC_DIME; - } - if (soap->mode & SOAP_ENC_DIME) - { if (soap_getdimehdr(soap)) - return soap->error; - if (soap->dime.flags & SOAP_DIME_CF) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked DIME SOAP message\n")); - soap->dime.chunksize = soap->dime.size; - if (soap->buflen - soap->bufidx >= soap->dime.chunksize) - { soap->dime.buflen = soap->buflen; - soap->buflen = soap->bufidx + soap->dime.chunksize; - } - else - soap->dime.chunksize -= soap->buflen - soap->bufidx; - } - soap->count = soap->buflen - soap->bufidx; - } -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_parse(struct soap *soap) -{ char header[SOAP_HDRLEN], *s; - unsigned short g = 0, k; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Waiting for response...\n")); - *soap->endpoint = '\0'; - soap->length = 0; - do - { if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf))) - return soap->error; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP status: %s\n", soap->msgbuf)); - for (;;) - { if (soap_getline(soap, header, SOAP_HDRLEN)) - return soap->error; - if (!*header) - break; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP header: %s\n", header)); - s = strchr(header, ':'); - if (s) - { *s = '\0'; - do s++; - while (*s && *s <= 32); - if ((soap->error = soap->fparsehdr(soap, header, s))) - return soap->error; - } - } - if ((s = strchr(soap->msgbuf, ' '))) - k = (unsigned short)soap_strtoul(s, NULL, 10); - else - k = 0; - } while (k == 100); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Finished HTTP header parsing\n")); - s = strstr(soap->msgbuf, "HTTP/"); - if (s && s[7] != '1') - { if (soap->keep_alive == 1) - soap->keep_alive = 0; - if (k == 0 && (soap->omode & SOAP_IO) == SOAP_IO_CHUNK) /* k == 0 for HTTP request */ - { soap->imode |= SOAP_IO_CHUNK; - soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_STORE; - } - } - if (soap->keep_alive < 0) - soap->keep_alive = 1; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Keep alive connection = %d\n", soap->keep_alive)); - if (s && (((g = !strncmp(soap->msgbuf, "GET ", 4))) || !strncmp(soap->msgbuf, "POST ", 5))) - { size_t m = strlen(soap->endpoint); - size_t n = m + (s - soap->msgbuf) - 5 - (!g); - if (n >= sizeof(soap->endpoint)) - n = sizeof(soap->endpoint) - 1; - strncpy(soap->path, soap->msgbuf + 4 + (!g), n - m); - soap->path[n - m] = '\0'; - strcat(soap->endpoint, soap->path); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Target endpoint='%s'\n", soap->endpoint)); - if (g) - { soap->error = soap->fget(soap); - if (soap->error == SOAP_OK) - soap->error = SOAP_STOP; /* prevents further processing */ - return soap->error; - } - return SOAP_OK; - } - if (k == 0 || (k >= 200 && k <= 299) || k == 400 || k == 500) - return SOAP_OK; - return soap_set_receiver_error(soap, "HTTP error", soap->msgbuf, k); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_parse_header(struct soap *soap, const char *key, const char *val) -{ if (!soap_tag_cmp(key, "Host")) - { -#ifdef WITH_OPENSSL - if (soap->imode & SOAP_ENC_SSL) - strcpy(soap->endpoint, "https://"); - else -#endif - strcpy(soap->endpoint, "http://"); - strncat(soap->endpoint, val, sizeof(soap->endpoint) - 8); - soap->endpoint[sizeof(soap->endpoint) - 1] = '\0'; - } -#ifndef WITH_LEANER - else if (!soap_tag_cmp(key, "Content-Type")) - { if (soap_get_header_attribute(soap, val, "application/dime")) - soap->mode |= SOAP_ENC_DIME; - else if (soap_get_header_attribute(soap, val, "multipart/related")) - { soap->mime.boundary = soap_strdup(soap, soap_get_header_attribute(soap, val, "boundary")); - soap->mime.start = soap_strdup(soap, soap_get_header_attribute(soap, val, "start")); - soap->mode |= SOAP_ENC_MIME; - } - } -#endif - else if (!soap_tag_cmp(key, "Content-Length")) - soap->length = soap_strtoul(val, NULL, 10); - else if (!soap_tag_cmp(key, "Content-Encoding")) - { if (!soap_tag_cmp(val, "deflate")) -#ifdef WITH_ZLIB - soap->zlib_in = SOAP_ZLIB_DEFLATE; -#else - return SOAP_ZLIB_ERROR; -#endif - else if (!soap_tag_cmp(val, "gzip")) -#ifdef WITH_GZIP - soap->zlib_in = SOAP_ZLIB_GZIP; -#else - return SOAP_ZLIB_ERROR; -#endif - } -#ifdef WITH_ZLIB - else if (!soap_tag_cmp(key, "Accept-Encoding")) - { -#ifdef WITH_GZIP - if (strchr(val, '*') || soap_get_header_attribute(soap, val, "gzip")) - soap->zlib_out = SOAP_ZLIB_GZIP; - else -#endif - if (strchr(val, '*') || soap_get_header_attribute(soap, val, "deflate")) - soap->zlib_out = SOAP_ZLIB_DEFLATE; - else - soap->zlib_out = SOAP_ZLIB_NONE; - } -#endif - else if (!soap_tag_cmp(key, "Transfer-Encoding")) - { soap->mode &= ~SOAP_IO; - if (!soap_tag_cmp(val, "chunked")) - soap->mode |= SOAP_IO_CHUNK; - } - else if (!soap_tag_cmp(key, "Connection")) - { if (!soap_tag_cmp(val, "keep-alive")) - soap->keep_alive = -soap->keep_alive; - else if (!soap_tag_cmp(val, "close")) - soap->keep_alive = 0; - } -#ifndef WITH_LEAN - else if (!soap_tag_cmp(key, "Authorization")) - { if (!soap_tag_cmp(val, "Basic *")) - { size_t n; - char *s; - soap_base642s(soap, val + 6, soap->tmpbuf, sizeof(soap->tmpbuf) - 1, &n); - soap->tmpbuf[n] = '\0'; - if ((s = strchr(soap->tmpbuf, ':'))) - { *s = '\0'; - soap->userid = soap_strdup(soap, soap->tmpbuf); - soap->passwd = soap_strdup(soap, s + 1); - } - } - } -#endif - else if (!soap_tag_cmp(key, "SOAPAction")) - { if (val[0] && val[1]) - { soap->action = soap_strdup(soap, val + 1); - soap->action[strlen(soap->action) - 1] = '\0'; - } - } - else if (!soap_tag_cmp(key, "Location")) - { strncpy(soap->endpoint, val, sizeof(soap->endpoint)); - soap->endpoint[sizeof(soap->endpoint) - 1] = '\0'; - } - else if (!soap_tag_cmp(key, "WWW-Authenticate")) - soap->authrealm = soap_strdup(soap, soap_get_header_attribute(soap, val+6, "realm")); - else if (!soap_tag_cmp(key, "Expect")) - { if (!soap_tag_cmp(val, "100-continue")) - { if ((soap->error = soap->fposthdr(soap, "HTTP/1.1 100 Continue", NULL))) - return soap->error; - if ((soap->error = soap->fposthdr(soap, NULL, NULL))) - return soap->error; - } - } -#ifdef WITH_COOKIES - else if (!soap_tag_cmp(key, "Cookie") || !soap_tag_cmp(key, "Set-Cookie")) - soap_getcookies(soap, val); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_get_header_attribute(struct soap *soap, const char *line, const char *key) -{ register const char *s = line; - if (s) - { while (*s) - { register short flag; - s = soap_decode_key(soap->tmpbuf, sizeof(soap->tmpbuf), s); - flag = soap_tag_cmp(soap->tmpbuf, key); - s = soap_decode_val(soap->tmpbuf, sizeof(soap->tmpbuf), s); - if (!flag) - return soap->tmpbuf; - } - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_decode_key(char *buf, size_t len, const char *val) -{ return soap_decode(buf, len, val, "=,;"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_decode_val(char *buf, size_t len, const char *val) -{ if (*val != '=') - { *buf = '\0'; - return val; - } - return soap_decode(buf, len, val + 1, ",;"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -soap_decode(char *buf, size_t len, const char *val, const char *sep) -{ const char *s; - char *t = buf; - for (s = val; *s; s++) - if (*s != ' ' && *s != '\t' && !strchr(sep, *s)) - break; - if (*s == '"') - { s++; - while (*s && *s != '"' && --len) - *t++ = *s++; - } - else - { while (soap_notblank(*s) && !strchr(sep, *s) && --len) - { if (*s == '%') - { *t++ = ((s[1] >= 'A' ? (s[1] & 0x7) + 9 : s[1] - '0') << 4) - + (s[2] >= 'A' ? (s[2] & 0x7) + 9 : s[2] - '0'); - s += 3; - } - else - *t++ = *s++; - } - } - *t = '\0'; - while (*s && !strchr(sep, *s)) - s++; - return s; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_begin_out(struct soap *soap) -{ -#ifndef WITH_LEANER - size_t n = 0; - if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary && soap->mime.start) - { const char *s; - if (soap->mode & SOAP_ENC_DIME) - s = "application/dime"; - else if (soap->version == 2) - s = "application/soap+xml; charset=utf-8"; - else - s = "text/xml; charset=utf-8"; - sprintf(soap->tmpbuf, "--%s\r\nContent-Type: %s\r\nContent-Transfer-Encoding: binary\r\nContent-ID: %s\r\n\r\n", soap->mime.boundary, s, soap->mime.start); - n = strlen(soap->tmpbuf); - if (soap_send_raw(soap, soap->tmpbuf, n)) - return soap->error; - } - if (soap->mode & SOAP_IO_LENGTH) - soap->dime.size = soap->count; /* DIME in MIME correction */ - if (!(soap->mode & SOAP_IO_LENGTH) && (soap->mode & SOAP_ENC_DIME)) - { if (soap_putdimehdr(soap)) - return soap->error; - } -#endif - soap->part = SOAP_IN_ENVELOPE; - return soap_element_begin_out(soap, "SOAP-ENV:Envelope", 0, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_end_out(struct soap *soap) -{ if (soap_element_end_out(soap, "SOAP-ENV:Envelope")) - return soap->error; -#ifndef WITH_LEANER - if ((soap->mode & SOAP_IO_LENGTH) && (soap->mode & SOAP_ENC_DIME)) - { soap->dime.size = soap->count - soap->dime.size; /* DIME in MIME correction */ - sprintf(soap->id, soap->dime_id_format, 0); - soap->dime.id = soap->id; - if (soap->local_namespaces) - { if (soap->local_namespaces[0].out) - soap->dime.type = (char*)soap->local_namespaces[0].out; - else - soap->dime.type = (char*)soap->local_namespaces[0].ns; - } - soap->dime.options = NULL; - soap->dime.flags = SOAP_DIME_MB | SOAP_DIME_ABSURI; - if (!soap->dime.first) - soap->dime.flags |= SOAP_DIME_ME; - soap->count += 12 + ((strlen(soap->dime.id)+3)&(~3)) + ((strlen(soap->dime.type)+3)&(~3)); - } - if (soap->mode & SOAP_ENC_DIME) - return soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime.size&3); -#endif - soap->part = SOAP_END_ENVELOPE; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_begin_in(struct soap *soap) -{ register struct Namespace *p; - soap->part = SOAP_IN_ENVELOPE; - if (soap_element_begin_in(soap, "SOAP-ENV:Envelope", 0)) - return soap->error = SOAP_VERSIONMISMATCH; - p = soap->local_namespaces; - if (p) - { const char *ns = p[0].out; - if (!ns) - ns = p[0].ns; - if (!strcmp(ns, soap_env1)) - { soap->version = 1; /* make sure we use SOAP 1.1 */ - if (p[1].out) - SOAP_FREE(p[1].out); - if ((p[1].out = (char*)SOAP_MALLOC(sizeof(soap_enc1)))) - strcpy(p[1].out, soap_enc1); - } - else if (!strcmp(ns, soap_env2)) - { soap->version = 2; /* make sure we use SOAP 1.2 */ - if (p[1].out) - SOAP_FREE(p[1].out); - if ((p[1].out = (char*)SOAP_MALLOC(sizeof(soap_enc2)))) - strcpy(p[1].out, soap_enc2); - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_end_in(struct soap *soap) -{ if (soap_element_end_in(soap, "SOAP-ENV:Envelope")) - return soap->error; - soap->part = SOAP_END_ENVELOPE; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_begin_out(struct soap *soap) -{ soap->part = SOAP_IN_BODY; - if (soap->version == 1) - soap->encoding = 1; - if (soap_element(soap, "SOAP-ENV:Body", 0, NULL)) - return soap->error; - if ((soap->mode & SOAP_XML_SEC) && soap_attribute(soap, "id", "_0")) - return soap->error; - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_end_out(struct soap *soap) -{ if (soap_element_end_out(soap, "SOAP-ENV:Body")) - return soap->error; - soap->part = SOAP_IN_BODY; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_begin_in(struct soap *soap) -{ soap->part = SOAP_IN_BODY; - return soap_element_begin_in(soap, "SOAP-ENV:Body", 0); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_end_in(struct soap *soap) -{ if (soap_element_end_in(soap, "SOAP-ENV:Body")) - return soap->error; - soap->part = SOAP_END_BODY; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_header(struct soap *soap) -{ if (soap_getheader(soap) && soap->error == SOAP_TAG_MISMATCH) - soap->error = SOAP_OK; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_endpoint(struct soap *soap, const char *endpoint) -{ register const char *s; - register size_t i, n; - *soap->endpoint = '\0'; - *soap->host = '\0'; - *soap->path = '\0'; - soap->port = 80; - if (!endpoint || !*endpoint) - return; -#ifdef WITH_OPENSSL - if (!strncmp(endpoint, "https:", 6)) - soap->port = 443; -#endif - strncpy(soap->endpoint, endpoint, sizeof(soap->endpoint) - 1); - s = strchr(endpoint, ':'); - if (s && s[1] == '/' && s[2] == '/') - s += 3; - else - s = endpoint; - n = strlen(s); - if (n >= sizeof(soap->host)) - n = sizeof(soap->host) - 1; -/* WR[ */ -#ifdef WITH_IPV6 - if ('[' == s[0]) - { - s++; - for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (']' == s[i]) - { - s++; - break; - } - } - } - else - { - for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (s[i] == '/' || s[i] == ':') - break; - } - } -#else /* WITH_IPV6 */ -/* ]WR */ - for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (s[i] == '/' || s[i] == ':') - break; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - soap->host[i] = '\0'; - if (s[i] == ':') - { soap->port = (int)atol(s + i + 1); - for (i++; i < n; i++) - if (s[i] == '/') - break; - } - if (s[i]) - { strncpy(soap->path, s + i + 1, sizeof(soap->path)); - soap->path[sizeof(soap->path) - 1] = '\0'; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_connect(struct soap *soap, const char *endpoint, const char *action) -{ return soap_connect_command(soap, SOAP_POST, endpoint, action); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_connect_command(struct soap *soap, int http_command, const char *endpoint, const char *action) -{ char host[sizeof(soap->host)]; - int port; - size_t count; - soap->error = SOAP_OK; - strcpy(host, soap->host); /* save to compare */ - port = soap->port; /* save to compare */ - soap_set_endpoint(soap, endpoint); - if (action) - soap->action = soap_strdup(soap, action); - if (soap->fconnect) - { - if ((soap->error = soap->fconnect(soap, endpoint, soap->host, soap->port))) - return soap->error; - } - else if (*soap->host) - { soap->status = http_command; - if (!soap_valid_socket(soap->socket) || strcmp(soap->host, host) || soap->port != port) - { soap->keep_alive = 0; /* force close */ - soap_closesock(soap); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Connect to host='%s' path='%s' port=%d\n", soap->host, soap->path, soap->port)); - soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port); - if (soap->error) - return soap->error; - soap->keep_alive = ((soap->omode & SOAP_IO_KEEPALIVE) != 0); - } - else if (!soap->keep_alive || !soap->fpoll || soap->fpoll(soap)) - { soap->keep_alive = 0; /* force close */ - soap_closesock(soap); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Reconnect to host='%s' path='%s' port=%d\n", soap->host, soap->path, soap->port)); - soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port); - if (soap->error) - return soap->error; - } - } - if (soap_begin_send(soap)) - return soap->error; - count = soap_count_attachments(soap); - if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML) && endpoint) - { unsigned int k = soap->mode; - soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB); - if ((k & SOAP_IO) != SOAP_IO_FLUSH) - soap->mode |= SOAP_IO_BUFFER; - if ((soap->error = soap->fpost(soap, endpoint, soap->host, soap->port, soap->path, action, count))) - return soap->error; - if ((k & SOAP_IO) == SOAP_IO_CHUNK) - { if (soap_flush(soap)) - return soap->error; - } - soap->mode = k; - } - if (http_command != SOAP_POST) - return soap_end_send(soap); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_s2base64(struct soap *soap, const unsigned char *s, char *t, size_t n) -{ register size_t i; - register unsigned long m; - register char *p; - if (!t) - t = (char*)soap_malloc(soap, (n + 2) / 3 * 4 + 1); - if (!t) - { soap->error = SOAP_EOM; - return NULL; - } - p = t; - t[0] = '\0'; - if (!s) - return p; - for (; n > 2; n -= 3, s += 3) - { m = s[0]; - m = (m << 8) | s[1]; - m = (m << 8) | s[2]; - for (i = 4; i > 0; m >>= 6) - t[--i] = soap_base64o[m & 0x3F]; - t += 4; - } - t[0] = '\0'; - if (n > 0) - { m = 0; - for (i = 0; i < n; i++) - m = (m << 8) | *s++; - for (; i < 3; i++) - m <<= 8; - for (i++; i > 0; m >>= 6) - t[--i] = soap_base64o[m & 0x3F]; - for (i = 3; i > n; i--) - t[i] = '='; - t[4] = '\0'; - } - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_base642s(struct soap *soap, const char *s, char *t, size_t l, size_t *n) -{ register int i, j, c; - register unsigned long m; - char *p = t; - if (n) - *n = 0; - for (;;) - { for (i = 0; i < SOAP_BLKLEN; i++) - { m = 0; - j = 0; - while (j < 4) - { c = *s++; - if (c == '=' || !c) - { i *= 3; - switch (j) - { case 2: - *t++ = (char)((m >> 4) & 0xFF); - i++; - break; - case 3: - *t++ = (char)((m >> 10) & 0xFF); - *t++ = (char)((m >> 2) & 0xFF); - i += 2; - } - if (n) - *n += i; - return p; - } - c -= '+'; - if (c >= 0 && c <= 79) - { m = (m << 6) + soap_base64i[c]; - j++; - } - } - *t++ = (char)((m >> 16) & 0xFF); - *t++ = (char)((m >> 8) & 0xFF); - *t++ = (char)(m & 0xFF); - if (l < 3) - { if (n) - *n += i; - return p; - } - l -= 3; - } - if (n) - *n += 3 * SOAP_BLKLEN; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_puthttphdr(struct soap *soap, int status, size_t count) -{ register const char *s; - register int err; - if (status == SOAP_FILE) - s = soap->http_content; - else if (status == SOAP_HTML) - s = "text/html; charset=utf-8"; -#ifndef WITH_LEANER - else if (soap->mode & SOAP_ENC_DIME) - s = "application/dime"; -#endif - else if (soap->version == 2) - s = "application/soap+xml; charset=utf-8"; - else - s = "text/xml; charset=utf-8"; -#ifndef WITH_LEANER - if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary && soap->mime.start && soap->status != SOAP_GET) - { sprintf(soap->tmpbuf, "multipart/related; boundary=\"%s\"; type=%s; start=\"%s\"", soap->mime.boundary, s, soap->mime.start); - s = soap->tmpbuf; - } -#endif - if ((err = soap->fposthdr(soap, "Content-Type", s))) - return err; -#ifdef WITH_ZLIB - if (soap->omode & SOAP_ENC_ZLIB) - { -#ifdef WITH_GZIP - err = soap->fposthdr(soap, "Content-Encoding", "gzip"); -#else - err = soap->fposthdr(soap, "Content-Encoding", "deflate"); -#endif - if (err) - return err; - } -#endif - if ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK) - err = soap->fposthdr(soap, "Transfer-Encoding", "chunked"); - else if (count > 0) - { sprintf(soap->tmpbuf, "%lu", (unsigned long)count); - err = soap->fposthdr(soap, "Content-Length", soap->tmpbuf); - } - if (err) - return err; - return soap->fposthdr(soap, "Connection", soap->keep_alive ? "keep-alive" : "close"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_get(struct soap *soap) -{ return SOAP_GET_METHOD; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_post(struct soap *soap, const char *endpoint, const char *host, int port, const char *path, const char *action, size_t count) -{ register const char *s; - register int err; - if (soap->status == SOAP_GET) - { s = "GET"; - count = 0; - } - else - s = "POST"; -#ifndef PALM - if (!endpoint || (strncmp(endpoint, "http:", 5) && strncmp(endpoint, "https:", 6) && strncmp(endpoint, "httpg:", 6))) -#else - if (!endpoint || (strncmp(endpoint, "http:", 5) && strncmp(endpoint, "https:", 6) && strncmp(endpoint, "httpg:", 6)) && strncmp(endpoint, "_beam:", 6) && strncmp(endpoint, "_local:", 7) && strncmp(endpoint, "_btobex:", 8)) -#endif - return SOAP_OK; - if (soap->proxy_host && strncmp(endpoint, "https:", 6)) - sprintf(soap->tmpbuf, "%s %s HTTP/%s", s, endpoint, soap->http_version); - else - sprintf(soap->tmpbuf, "%s /%s HTTP/%s", s, path, soap->http_version); - if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return err; - if (port != 80) - sprintf(soap->tmpbuf, "%s:%d", host, port); - else - strcpy(soap->tmpbuf, host); - if ((err = soap->fposthdr(soap, "Host", soap->tmpbuf)) - || (err = soap->fposthdr(soap, "User-Agent", "gSOAP/2.7")) - || (err = soap_puthttphdr(soap, SOAP_OK, count))) - return err; -#ifdef WITH_ZLIB -#ifdef WITH_GZIP - if ((err = soap->fposthdr(soap, "Accept-Encoding", "gzip, deflate"))) -#else - if ((err = soap->fposthdr(soap, "Accept-Encoding", "deflate"))) -#endif - return err; -#endif -#ifndef WITH_LEAN - if (soap->userid && soap->passwd && strlen(soap->userid) + strlen(soap->passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->userid, soap->passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((err = soap->fposthdr(soap, "Authorization", soap->tmpbuf))) - return err; - } - if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((err = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) - return err; - } -#endif -#ifdef WITH_COOKIES -#ifdef WITH_OPENSSL - if (soap_putcookies(soap, host, path, soap->ssl != NULL)) - return soap->error; -#else - if (soap_putcookies(soap, host, path, 0)) - return soap->error; -#endif -#endif - if (action && soap->version == 1) - { sprintf(soap->tmpbuf, "\"%s\"", action); - if ((err = soap->fposthdr(soap, "SOAPAction", soap->tmpbuf))) - return err; - } - return soap->fposthdr(soap, NULL, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_send_header(struct soap *soap, const char *s) -{ register const char *t; - do - { t = strchr(s, '\n'); /* disallow \n in HTTP headers */ - if (!t) - t = s + strlen(s); - if (soap_send_raw(soap, s, t - s)) - return soap->error; - s = t + 1; - } while (*t); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_post_header(struct soap *soap, const char *key, const char *val) -{ if (key) - { if (http_send_header(soap, key)) - return soap->error; - if (val && (soap_send_raw(soap, ": ", 2) || http_send_header(soap, val))) - return soap->error; - } - return soap_send_raw(soap, "\r\n", 2); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_response(struct soap *soap, int status, size_t count) -{ register int err; -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - { - httpOutputEnable(soap->rpmreqid); - } -#endif /* WMW_RPM_IO */ -/* ]WR */ - if (!status || status == SOAP_HTML || status == SOAP_FILE) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "OK 200\n")); -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ -#else -/* ]WR */ - if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */ -/* WR[ */ -#endif /* WMW_RPM_IO */ -/* ]WR */ - { sprintf(soap->tmpbuf, "HTTP/%s 200 OK", soap->http_version); - if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return err; - } - else if ((err = soap->fposthdr(soap, "Status", "200 OK"))) - return err; - } - else if (status > 200 && status < 600) - { sprintf(soap->tmpbuf, "HTTP/%s %d %s", soap->http_version, status, http_error(soap, status)); - if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return err; - if (status == 401) - { sprintf(soap->tmpbuf, "Basic realm=\"%s\"", soap->authrealm ? soap->authrealm : "gSOAP Web Service"); - if ((err = soap->fposthdr(soap, "WWW-Authenticate", soap->tmpbuf))) - return err; - } - else if ((status >= 301 && status <= 303) || status == 307) - { if ((err = soap->fposthdr(soap, "Location", soap->endpoint))) - return err; - } - } - else - { const char *s = *soap_faultcode(soap); - if (soap->version == 2 && !strcmp(s, "SOAP-ENV:Sender")) - s = "400 Bad Request"; - else - s = "500 Internal Server Error"; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error %s (status=%d)\n", s, status)); -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ -#else -/* ]WR */ - if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */ -/* WR[ */ -#endif /* WMW_RPM_IO */ -/* ]WR */ - { sprintf(soap->tmpbuf, "HTTP/%s %s", soap->http_version, s); - if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return err; - } - else if ((err = soap->fposthdr(soap, "Status", s))) - return err; - } - if ((err = soap->fposthdr(soap, "Server", "gSOAP/2.7")) - || (err = soap_puthttphdr(soap, status, count))) - return err; -#ifdef WITH_COOKIES - if (soap_putsetcookies(soap)) - return soap->error; -#endif - return soap->fposthdr(soap, NULL, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_response(struct soap *soap, int status) -{ register size_t count; - if (!(soap->omode & (SOAP_ENC_XML | SOAP_IO_STORE /* this tests for chunking too */)) - && (status == SOAP_HTML || status == SOAP_FILE)) - { soap->omode &= ~SOAP_IO; - soap->omode |= SOAP_IO_STORE; - } - soap->status = status; - count = soap_count_attachments(soap); - if (soap_begin_send(soap)) - return soap->error; - if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML)) - { register int n = soap->mode; - soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB); - if ((n & SOAP_IO) != SOAP_IO_FLUSH) - soap->mode |= SOAP_IO_BUFFER; - if ((soap->error = soap->fresponse(soap, status, count))) - return soap->error; - if ((n & SOAP_IO) == SOAP_IO_CHUNK) - { if (soap_flush(soap)) - return soap->error; - } - soap->mode = n; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -soap_set_validation_fault(struct soap *soap, const char *s, const char *t) -{ sprintf(soap->msgbuf, "Validation constraint violation: %s%s in element <%s>", s, t?t:SOAP_STR_EOS, soap->tag); - return soap->msgbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_fault(struct soap *soap) -{ const char **c = soap_faultcode(soap); - const char **s = soap_faultstring(soap); - if (!*c) - { if (soap->version == 2) - *c = "SOAP-ENV:Sender"; - else - *c = "SOAP-ENV:Client"; - } - if (*s) - return; - switch (soap->error) - { case SOAP_CLI_FAULT: - *s = "Client fault"; - break; - case SOAP_SVR_FAULT: - *s = "Server fault"; - break; - case SOAP_TAG_MISMATCH: - *s = soap_set_validation_fault(soap, "tag name or namespace mismatch", NULL); - break; - case SOAP_TAG_END: - *s = soap_set_validation_fault(soap, "incorrect end tag", NULL); - break; - case SOAP_TYPE: - *s = soap_set_validation_fault(soap, "data type mismatch ", soap->type); - break; - case SOAP_SYNTAX_ERROR: - *s = "Well-formedness constraint violation"; - break; - case SOAP_NO_TAG: - *s = "No XML element tag found"; - break; - case SOAP_MUSTUNDERSTAND: - *c = "SOAP-ENV:MustUnderstand"; - sprintf(soap->msgbuf, "The data in element '%s' must be understood but cannot be handled", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_VERSIONMISMATCH: - *c = "SOAP-ENV:VersionMismatch"; - *s = "SOAP version mismatch or invalid SOAP message"; - break; - case SOAP_DATAENCODINGUNKNOWN: - *c = "SOAP-ENV:DataEncodingUnknown"; - *s = "Unsupported SOAP data encoding"; - break; - case SOAP_NAMESPACE: - *s = soap_set_validation_fault(soap, "namespace mismatch", NULL); - break; - case SOAP_FATAL_ERROR: - *s = "Fatal error"; - break; - case SOAP_NO_METHOD: - sprintf(soap->msgbuf, "Method '%s' not implemented: method name or namespace not recognized", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_GET_METHOD: - *s = "HTTP GET method not implemented"; - break; - case SOAP_EOM: - *s = "Out of memory"; - break; - case SOAP_IOB: - *s = "Array index out of bounds"; - break; - case SOAP_NULL: - *s = soap_set_validation_fault(soap, "nil not allowed", NULL); - break; - case SOAP_MULTI_ID: - *s = soap_set_validation_fault(soap, "multiple definitions of id ", soap->id); - break; - case SOAP_MISSING_ID: - *s = soap_set_validation_fault(soap, "missing id for ref ", soap->id); - break; - case SOAP_HREF: - *s = soap_set_validation_fault(soap, "incompatible object ref ", soap->id); - break; - case SOAP_FAULT: - break; - case SOAP_TCP_ERROR: - *s = tcp_error(soap); - break; - case SOAP_HTTP_ERROR: - *s = "HTTP error"; - break; - case SOAP_SSL_ERROR: - *s = "SSL error"; - break; - case SOAP_PLUGIN_ERROR: - *s = "Plugin registry error"; - break; - case SOAP_DIME_MISMATCH: - *s = "DIME version/transmission error"; - break; - case SOAP_DIME_END: - *s = "End of DIME error"; - break; - case SOAP_DIME_ERROR: - *s = "DIME format error"; - break; - case SOAP_MIME_ERROR: - *s = "MIME format error"; - break; - case SOAP_ZLIB_ERROR: -#ifdef WITH_ZLIB - sprintf(soap->msgbuf, "Zlib/gzip error: '%s'", soap->d_stream.msg?soap->d_stream.msg:""); - *s = soap->msgbuf; -#else - *s = "Zlib not installed for required message (de)compression"; -#endif - break; - case SOAP_REQUIRED: - *s = soap_set_validation_fault(soap, "missing required attribute", NULL); - break; - case SOAP_PROHIBITED: - *s = soap_set_validation_fault(soap, "prohibited attribute present", NULL); - break; - case SOAP_OCCURS: - *s = soap_set_validation_fault(soap, "a min/maxOccurs violation was detected", NULL); - break; - case SOAP_LENGTH: - *s = soap_set_validation_fault(soap, "content length violation", NULL); - break; - case SOAP_EOF: - sprintf(soap->msgbuf, "End of file or no input: '%s'", soap_strerror(soap)); - *s = soap->msgbuf; - break; - default: - if (soap->error > 200 && soap->error < 600) - { sprintf(soap->msgbuf, "HTTP Error: '%s'", http_error(soap, soap->error)); - *s = soap->msgbuf; - } - else - *s = "Unknown error code"; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send_fault(struct soap *soap) -{ register int status = soap->error; - if (status == SOAP_STOP) - return status; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Sending back fault struct for error code %d\n", soap->error)); - soap->keep_alive = 0; /* to terminate connection */ - soap_set_fault(soap); - if ((status != SOAP_EOF || (!soap->recv_timeout && !soap->send_timeout)) && (!soap->fpoll || soap->fpoll(soap) == SOAP_OK)) - { soap->error = SOAP_OK; - soap_serializeheader(soap); - soap_serializefault(soap); - soap_begin_count(soap); - if (soap->mode & SOAP_IO_LENGTH) - { soap_envelope_begin_out(soap); - soap_putheader(soap); - soap_body_begin_out(soap); - soap_putfault(soap); - soap_body_end_out(soap); - soap_envelope_end_out(soap); - } - if (soap_response(soap, status) - || soap_envelope_begin_out(soap) - || soap_putheader(soap) - || soap_body_begin_out(soap) - || soap_putfault(soap) - || soap_body_end_out(soap) - || soap_envelope_end_out(soap)) - return soap_closesock(soap); - soap_end_send(soap); - } - soap->error = status; - return soap_closesock(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_fault(struct soap *soap) -{ register int status = soap->error; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Receiving SOAP Fault\n")); - soap->error = SOAP_OK; - if (soap_getfault(soap)) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Error: soap_get_soapfault() failed. Is this a SOAP message at all?\n")); - *soap_faultcode(soap) = (soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client"); - soap->error = status; - soap_set_fault(soap); - } - else - { register const char *s = *soap_faultcode(soap); - if (!soap_match_tag(soap, s, "SOAP-ENV:Server") || !soap_match_tag(soap, s, "SOAP-ENV:Receiver")) - status = SOAP_SVR_FAULT; - else if (!soap_match_tag(soap, s, "SOAP-ENV:Client") || !soap_match_tag(soap, s, "SOAP-ENV:Sender")) - status = SOAP_CLI_FAULT; - else if (!soap_match_tag(soap, s, "SOAP-ENV:MustUnderstand")) - status = SOAP_MUSTUNDERSTAND; - else if (!soap_match_tag(soap, s, "SOAP-ENV:VersionMismatch")) - status = SOAP_VERSIONMISMATCH; - else - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Fault code %s\n", s)); - status = SOAP_FAULT; - } - if (soap_body_end_in(soap) - || soap_envelope_end_in(soap) - || soap_end_recv(soap)) - return soap_closesock(soap); - soap->error = status; - } - return soap_closesock(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -soap_strerror(struct soap *soap) -{ int err = soap->errnum; - if (!err) - err = soap_errno; - if (err) - { -#ifndef UNDER_CE - return strerror(err); -#else - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, 0, (LPTSTR)&soap->werrorstr, sizeof(soap->werrorstr), NULL); - wcstombs(soap->errorstr, soap->werrorstr, sizeof(soap->errorstr)); - return soap->errorstr; -#endif - } - return "Operation interrupted or timed out"; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_set_error(struct soap *soap, const char *faultcode, const char *faultstring, const char *faultdetail, int soaperror) -{ *soap_faultcode(soap) = faultcode; - *soap_faultstring(soap) = faultstring; - if (faultdetail && *faultdetail) - { register const char **s = soap_faultdetail(soap); - if (s) - *s = faultdetail; - } - return soap->error = soaperror; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_sender_error(struct soap *soap, const char *faultstring, const char *faultdetail, int soaperror) -{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", faultstring, faultdetail, soaperror); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_receiver_error(struct soap *soap, const char *faultstring, const char *faultdetail, int soaperror) -{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", faultstring, faultdetail, soaperror); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_copy_fault(struct soap *soap, const char *faultcode, const char *faultstring, const char *faultdetail) -{ char *s = NULL, *t = NULL; - if (faultstring) - s = soap_strdup(soap, faultstring); - if (faultdetail) - t = soap_strdup(soap, faultdetail); - return soap_set_error(soap, faultcode, s, t, SOAP_FAULT); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_sender_fault(struct soap *soap, const char *faultstring, const char *faultdetail) -{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", faultstring, faultdetail); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_receiver_fault(struct soap *soap, const char *faultstring, const char *faultdetail) -{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", faultstring, faultdetail); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_print_fault(struct soap *soap, FILE *fd) -{ if (soap->error) - { const char **s; - if (!*soap_faultcode(soap)) - soap_set_fault(soap); - fprintf(fd, "SOAP FAULT: %s\n\"%s\"\n", *soap_faultcode(soap), *soap_faultstring(soap)); - s = soap_faultdetail(soap); - if (s && *s) - fprintf(fd, "Detail: %s\n", *s); - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_print_fault_location(struct soap *soap, FILE *fd) -{ -#ifndef WITH_LEAN - int c; - if (soap->error && soap->buflen > 0) - { if (soap->bufidx == 0) - soap->bufidx = 1; - c = soap->buf[soap->bufidx - 1]; - soap->buf[soap->bufidx - 1] = '\0'; - if (soap->buflen - soap->bufidx > 1024) - soap->buf[soap->bufidx + 1024] = '\0'; - else - soap->buf[soap->buflen - 1] = '\0'; - fprintf(fd, "%s%c\n** HERE **\n", soap->buf, c); - if (soap->bufidx < soap->buflen) - fprintf(fd, "%s\n", soap->buf + soap->bufidx); - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_register_plugin_arg(struct soap *soap, int (*fcreate)(struct soap*, struct soap_plugin*, void*), void *arg) -{ register struct soap_plugin *p; - register int r; - if (!(p = (struct soap_plugin*)SOAP_MALLOC(sizeof(struct soap_plugin)))) - return soap->error = SOAP_EOM; - p->id = NULL; - p->data = NULL; - p->fcopy = NULL; - p->fdelete = NULL; - r = fcreate(soap, p, arg); - if (!r && p->fdelete) - { p->next = soap->plugins; - soap->plugins = p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Registered '%s' plugin\n", p->id)); - return SOAP_OK; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not register plugin '%s': plugin returned error %d (or fdelete callback not set)\n", p->id?p->id:"?", r)); - SOAP_FREE(p); - return r; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void * -fplugin(struct soap *soap, const char *id) -{ register struct soap_plugin *p; - for (p = soap->plugins; p; p = p->next) - if (p->id == id || !strcmp(p->id, id)) - return p->data; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void * -SOAP_FMAC2 -soap_lookup_plugin(struct soap *soap, const char *id) -{ return soap->fplugin(soap, id); -} -#endif - -/******************************************************************************/ -#ifdef __cplusplus -} -#endif - diff --git a/org.glite.lb.server/examples/stdsoap2_2.7.0d.c b/org.glite.lb.server/examples/stdsoap2_2.7.0d.c deleted file mode 100644 index fab9eee..0000000 --- a/org.glite.lb.server/examples/stdsoap2_2.7.0d.c +++ /dev/null @@ -1,11692 +0,0 @@ -/* - -stdsoap2.c[pp] 2.7.0d - -Runtime environment. - -gSOAP XML Web services tools -Copyright (C) 2000-2004, Robert van Engelen, Genivia, Inc., All Rights Reserved. - -Contributors: - -Wind River Systems, Inc., for the following additions (marked WR[...]): - - vxWorks compatible - - Support for IPv6. - --------------------------------------------------------------------------------- -gSOAP public license. - -The contents of this file are subject to the gSOAP Public License Version 1.3 -(the "License"); you may not use this file except in compliance with the -License. You may obtain a copy of the License at -http://www.cs.fsu.edu/~engelen/soaplicense.html -Software distributed under the License is distributed on an "AS IS" basis, -WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -for the specific language governing rights and limitations under the License. - -The Initial Developer of the Original Code is Robert A. van Engelen. -Copyright (C) 2000-2004, Robert van Engelen, Genivia, Inc., All Rights Reserved. --------------------------------------------------------------------------------- -GPL license. - -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 the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -Author contact information: -engelen@genivia.com / engelen@acm.org --------------------------------------------------------------------------------- - -Installation note: - -Win32 build needs winsock.dll (Visual C++ "wsock32.lib") -To do this in Visual C++ 6.0, go to "Project", "settings", select the "Link" -tab (the project file needs to be selected in the file view) and add -"wsock32.lib" to the "Object/library modules" entry - -On Mac OS X with gcc (GCC) 3.1 20020420 (prerelease) you MUST compile with --fstack_check when using -O2 because gcc 3.1 has a bug that smashes the stack -when locally allocated data exceeds 64K. - -*/ - -#include "stdsoap2.h" - -#ifdef __cplusplus -SOAP_SOURCE_STAMP("@(#) stdsoap2.cpp ver 2.7.0c 2004-09-27 12:00:00 GMT") -extern "C" { -#else -SOAP_SOURCE_STAMP("@(#) stdsoap2.c ver 2.7.0c 2004-09-27 12:00:00 GMT") -#endif - -/* 8bit character representing unknown/nonrepresentable character data (e.g. not supported by current locale) */ -#ifndef SOAP_UNKNOWN_CHAR -#define SOAP_UNKNOWN_CHAR (127) -#endif - -/* EOF=-1 */ -#define SOAP_LT (soap_wchar)(-2) /* XML character '<' */ -#define SOAP_TT (soap_wchar)(-3) /* XML character '' */ -#define SOAP_QT (soap_wchar)(-5) /* XML character '"' */ -#define SOAP_AP (soap_wchar)(-6) /* XML character ''' */ - -#define soap_blank(c) ((c) >= 0 && (c) <= 32) -#define soap_notblank(c) ((c) > 32) -#define soap_hash_ptr(p) (((unsigned long)(p) >> 3) & (SOAP_PTRHASH - 1)) - -static int soap_isxdigit(int); -static soap_wchar soap_char(struct soap*); -static soap_wchar soap_getchunkchar(struct soap*); -static void soap_update_ptrs(struct soap*, char*, char*, long); -static int soap_has_copies(struct soap*, const char*, const char*); -static struct soap_ilist *soap_hlookup(struct soap*, const char*); -static void soap_init_iht(struct soap*); -static void soap_free_iht(struct soap*); -static void soap_init_pht(struct soap*); -static void soap_free_pht(struct soap*); -static int soap_set_error(struct soap*, const char*, const char*, const char*, int); -static const char *soap_set_validation_fault(struct soap*, const char*, const char*); -static int soap_copy_fault(struct soap*, const char*, const char*, const char*); -static int soap_getattrval(struct soap*, char*, size_t, soap_wchar); -static void soap_set_local_namespaces(struct soap*); -static int soap_isnumeric(struct soap*, const char*); -static void *fplugin(struct soap*, const char*); -static const char *soap_decode(char*, size_t, const char*, const char*); - -#ifndef WITH_LEAN -static time_t soap_timegm(struct tm*); -#endif - -#ifdef SOAP_DEBUG -static void soap_init_logs(struct soap*); -static void soap_close_logfile(struct soap*, int); -static void soap_set_logfile(struct soap*, int, const char*); -#endif - -#ifdef WITH_FAST -static int soap_append_lab(struct soap*, const char*, size_t); -#endif - -#ifndef WITH_LEANER -static struct soap_multipart *soap_new_multipart(struct soap*, struct soap_multipart**, struct soap_multipart**, char*, size_t); -static int soap_putdimefield(struct soap*, const char*, size_t); -static char *soap_getdimefield(struct soap*, size_t); -static void soap_select_mime_boundary(struct soap*); -static int soap_valid_mime_boundary(struct soap*); -#endif - -#ifdef WITH_GZIP -static int soap_getgziphdr(struct soap*); -#endif - -#ifdef WITH_OPENSSL -static int ssl_auth_init(struct soap*); -static int ssl_verify_callback(int, X509_STORE_CTX*); -static int ssl_password(char*, int, int, void *); -static const char *ssl_error(struct soap*, int); -/* This callback is included for future references. It should not be deleted -static DH *ssl_tmp_dh(SSL*, int, int); -*/ -#endif - -static const char *soap_strerror(struct soap*); -static const char *tcp_error(struct soap*); -static const char *http_error(struct soap*, int); -static int http_post(struct soap*, const char*, const char*, int, const char*, const char*, size_t); -static int http_get(struct soap*); -static int http_send_header(struct soap*, const char*); -static int http_post_header(struct soap*, const char*, const char*); -static int http_response(struct soap*, int, size_t); -static int http_parse(struct soap*); -static int http_parse_header(struct soap*, const char*, const char*); -#ifndef MAC_CARBON -static int tcp_gethost(struct soap*, const char *addr, struct in_addr *inaddr); -static int tcp_connect(struct soap*, const char *endpoint, const char *host, int port); -static int tcp_accept(struct soap*, int, struct sockaddr*, int*); -static int tcp_disconnect(struct soap*); -static int tcp_closesocket(struct soap*, SOAP_SOCKET); -static int tcp_shutdownsocket(struct soap*, SOAP_SOCKET, int); -static int fsend(struct soap*, const char*, size_t); -static size_t frecv(struct soap*, char*, size_t); -#endif - -/* WR[ */ -#ifdef VXWORKS -static int vx_nonblocking = TRUE; /* ioctl argument */ -#endif -/* ]WR */ - -#if defined(PALM) && !defined(PALM_2) -unsigned short errno; -#endif - -#ifndef PALM_1 -static const char soap_env1[42] = "http://schemas.xmlsoap.org/soap/envelope/"; -static const char soap_enc1[42] = "http://schemas.xmlsoap.org/soap/encoding/"; -static const char soap_env2[40] = "http://www.w3.org/2003/05/soap-envelope"; -static const char soap_enc2[40] = "http://www.w3.org/2003/05/soap-encoding"; -static const char soap_rpc[35] = "http://www.w3.org/2003/05/soap-rpc"; -#endif - -#ifndef PALM_1 -const struct soap_double_nan soap_double_nan = {0xFFFFFFFF, 0xFFFFFFFF}; -static const char soap_base64o[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char soap_base64i[81] = "\76XXX\77\64\65\66\67\70\71\72\73\74\75XXXXXXX\00\01\02\03\04\05\06\07\10\11\12\13\14\15\16\17\20\21\22\23\24\25\26\27\30\31XXXXXX\32\33\34\35\36\37\40\41\42\43\44\45\46\47\50\51\52\53\54\55\56\57\60\61\62\63"; -#endif - -static const char soap_padding[3] = "\0\0"; -#define SOAP_STR_PADDING (soap_padding) -#define SOAP_STR_EOS (soap_padding) - -#ifndef WITH_LEAN -static const struct soap_code_map html_entity_codes[] = /* entities for XHTML parsing */ -{ { 160, "nbsp" }, - { 161, "iexcl" }, - { 162, "cent" }, - { 163, "pound" }, - { 164, "curren" }, - { 165, "yen" }, - { 166, "brvbar" }, - { 167, "sect" }, - { 168, "uml" }, - { 169, "copy" }, - { 170, "ordf" }, - { 171, "laquo" }, - { 172, "not" }, - { 173, "shy" }, - { 174, "reg" }, - { 175, "macr" }, - { 176, "deg" }, - { 177, "plusmn" }, - { 178, "sup2" }, - { 179, "sup3" }, - { 180, "acute" }, - { 181, "micro" }, - { 182, "para" }, - { 183, "middot" }, - { 184, "cedil" }, - { 185, "sup1" }, - { 186, "ordm" }, - { 187, "raquo" }, - { 188, "frac14" }, - { 189, "frac12" }, - { 190, "frac34" }, - { 191, "iquest" }, - { 192, "Agrave" }, - { 193, "Aacute" }, - { 194, "Acirc" }, - { 195, "Atilde" }, - { 196, "Auml" }, - { 197, "Aring" }, - { 198, "AElig" }, - { 199, "Ccedil" }, - { 200, "Egrave" }, - { 201, "Eacute" }, - { 202, "Ecirc" }, - { 203, "Euml" }, - { 204, "Igrave" }, - { 205, "Iacute" }, - { 206, "Icirc" }, - { 207, "Iuml" }, - { 208, "ETH" }, - { 209, "Ntilde" }, - { 210, "Ograve" }, - { 211, "Oacute" }, - { 212, "Ocirc" }, - { 213, "Otilde" }, - { 214, "Ouml" }, - { 215, "times" }, - { 216, "Oslash" }, - { 217, "Ugrave" }, - { 218, "Uacute" }, - { 219, "Ucirc" }, - { 220, "Uuml" }, - { 221, "Yacute" }, - { 222, "THORN" }, - { 223, "szlig" }, - { 224, "agrave" }, - { 225, "aacute" }, - { 226, "acirc" }, - { 227, "atilde" }, - { 228, "auml" }, - { 229, "aring" }, - { 230, "aelig" }, - { 231, "ccedil" }, - { 232, "egrave" }, - { 233, "eacute" }, - { 234, "ecirc" }, - { 235, "euml" }, - { 236, "igrave" }, - { 237, "iacute" }, - { 238, "icirc" }, - { 239, "iuml" }, - { 240, "eth" }, - { 241, "ntilde" }, - { 242, "ograve" }, - { 243, "oacute" }, - { 244, "ocirc" }, - { 245, "otilde" }, - { 246, "ouml" }, - { 247, "divide" }, - { 248, "oslash" }, - { 249, "ugrave" }, - { 250, "uacute" }, - { 251, "ucirc" }, - { 252, "uuml" }, - { 253, "yacute" }, - { 254, "thorn" }, - { 255, "yuml" }, - { 0, NULL } -}; -#endif - -#ifndef WITH_LEAN -static const struct soap_code_map h_error_codes[] = -{ -#ifdef HOST_NOT_FOUND - { HOST_NOT_FOUND, "Host not found" }, -#endif -#ifdef TRY_AGAIN - { TRY_AGAIN, "Try Again" }, -#endif -#ifdef NO_RECOVERY - { NO_RECOVERY, "No Recovery" }, -#endif -#ifdef NO_DATA - { NO_DATA, "No Data" }, -#endif -#ifdef NO_ADDRESS - { NO_ADDRESS, "No Address" }, -#endif - { 0, NULL } -}; -#endif - -#ifndef WITH_LEAN -static const struct soap_code_map h_http_error_codes[] = -{ { 201, "Created" }, - { 202, "Accepted" }, - { 203, "Non-Authoritative Information" }, - { 204, "No Content" }, - { 205, "Reset Content" }, - { 206, "Partial Content" }, - { 300, "Multiple Choices" }, - { 301, "Moved Permanently" }, - { 302, "Found" }, - { 303, "See Other" }, - { 304, "Not Modified" }, - { 305, "Use Proxy" }, - { 307, "Temporary Redirect" }, - { 400, "Bad Request" }, - { 401, "Unauthorized" }, - { 402, "Payment Required" }, - { 403, "Forbidden" }, - { 404, "Not Found" }, - { 405, "Method Not Allowed" }, - { 406, "Not Acceptable" }, - { 407, "Proxy Authentication Required" }, - { 408, "Request Time-out" }, - { 409, "Conflict" }, - { 410, "Gone" }, - { 411, "Length Required" }, - { 412, "Precondition Failed" }, - { 413, "Request Entity Too Large" }, - { 414, "Request-URI Too Large" }, - { 415, "Unsupported Media Type" }, - { 416, "Requested range not satisfiable" }, - { 417, "Expectation Failed" }, - { 500, "Internal Server Error" }, - { 501, "Not Implemented" }, - { 502, "Bad Gateway" }, - { 503, "Service Unavailable" }, - { 504, "Gateway Time-out" }, - { 505, "HTTP Version not supported" }, - { 0, NULL } -}; -#endif - -#ifdef WITH_OPENSSL -static const struct soap_code_map h_ssl_error_codes[] = -{ -#define _SSL_ERROR(e) { e, #e } - _SSL_ERROR(SSL_ERROR_SSL), - _SSL_ERROR(SSL_ERROR_ZERO_RETURN), - _SSL_ERROR(SSL_ERROR_WANT_READ), - _SSL_ERROR(SSL_ERROR_WANT_WRITE), - _SSL_ERROR(SSL_ERROR_WANT_CONNECT), - _SSL_ERROR(SSL_ERROR_WANT_X509_LOOKUP), - _SSL_ERROR(SSL_ERROR_SYSCALL), - { 0, NULL } -}; -#endif - -#ifndef WITH_LEANER -static const struct soap_code_map mime_codes[] = -{ { SOAP_MIME_7BIT, "7bit" }, - { SOAP_MIME_8BIT, "8bit" }, - { SOAP_MIME_BINARY, "binary" }, - { SOAP_MIME_QUOTED_PRINTABLE, "quoted-printable" }, - { SOAP_MIME_BASE64, "base64" }, - { SOAP_MIME_IETF_TOKEN, "ietf-token" }, - { SOAP_MIME_X_TOKEN, "x-token" }, - { 0, NULL } -}; -#endif - -#ifdef WIN32 -static int tcp_done = 0; -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -fsend(struct soap *soap, const char *s, size_t n) -{ register int nwritten; -#if defined(__cplusplus) && !defined(WITH_LEAN) - if (soap->os) - { soap->os->write(s, n); - if (soap->os->good()) - return SOAP_OK; - return SOAP_EOF; - } -#endif - while (n) - { if (soap_valid_socket(soap->socket)) - { -#ifndef WITH_LEAN - if (soap->send_timeout) - { struct timeval timeout; - fd_set fd; - if (soap->send_timeout > 0) - { timeout.tv_sec = soap->send_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->send_timeout/1000000; - timeout.tv_usec = -soap->send_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - for (;;) - { register int r = select((SOAP_SOCKET)(soap->socket + 1), NULL, &fd, &fd, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - return SOAP_EOF; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - } - } -#endif -#ifdef WITH_OPENSSL - if (soap->ssl) - nwritten = SSL_write(soap->ssl, s, n); - else -#endif -#ifndef PALM - nwritten = send((SOAP_SOCKET)soap->socket, s, n, soap->socket_flags); -#else - nwritten = send((SOAP_SOCKET)soap->socket, (void*)s, n, soap->socket_flags); -#endif - if (nwritten <= 0) - { -#ifdef WITH_OPENSSL - int err; - if (soap->ssl && (err = SSL_get_error(soap->ssl, nwritten)) != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - return SOAP_EOF; -#endif - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EWOULDBLOCK && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - nwritten = 0; /* and call write() again */ - } - } - else - { -#ifdef WITH_FASTCGI - nwritten = fwrite((void*)s, 1, n, stdout); - fflush(stdout); -#else -#ifdef UNDER_CE - nwritten = fwrite(s, 1, n, soap->sendfd); -#else -/* WR[ */ -#ifdef VXWORKS -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - { - httpBlockPut(soap->rpmreqid, s, n); - nwritten = n; - } - else - { - nwritten = fwrite(s, sizeof(char), n, fdopen(soap->sendfd, "w")); - } -#else - nwritten = fwrite(s, sizeof(char), n, fdopen(soap->sendfd, "w")); -#endif /* WMW_RPM_IO */ -#else -/* ]WR */ - nwritten = write((SOAP_SOCKET)soap->sendfd, s, n); -/* WR[ */ -#endif -/* ]WR */ -#endif -#endif - if (nwritten <= 0) - { if (soap_errno != SOAP_EINTR && soap_errno != SOAP_EWOULDBLOCK && soap_errno != SOAP_EAGAIN) - { soap->errnum = soap_errno; - return SOAP_EOF; - } - nwritten = 0; /* and call write() again */ - } - } - n -= nwritten; - s += nwritten; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_flush_raw(struct soap *soap, const char *s, size_t n) -{ if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - { register char *t; - if (!(t = (char*)soap_push_block(soap, n))) - return soap->error = SOAP_EOM; - memcpy(t, s, n); - if (soap->fpreparesend) - return soap->fpreparesend(soap, s, n); - return SOAP_OK; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { char t[16]; - sprintf(t, "\r\n%lX\r\n" + (soap->chunksize ? 0 : 2), (unsigned long)n); - DBGMSG(SENT, t, strlen(t)); - if ((soap->error = soap->fsend(soap, t, strlen(t)))) - return soap->error; - soap->chunksize += n; - } - DBGMSG(SENT, s, n); - return soap->error = soap->fsend(soap, s, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_flush(struct soap *soap) -{ if (soap->bufidx) - { -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { soap->d_stream.next_in = (Byte*)soap->buf; - soap->d_stream.avail_in = (unsigned int)soap->bufidx; -#ifdef WITH_GZIP - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->bufidx); -#endif - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating %u bytes\n", soap->d_stream.avail_in)); - if (deflate(&soap->d_stream, Z_NO_FLUSH) != Z_OK) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to deflate: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - return soap->error = SOAP_ZLIB_ERROR; - } - if (!soap->d_stream.avail_out) - { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN)) - return soap->error; - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - } - } while (soap->d_stream.avail_in); - } - else -#endif - if (soap_flush_raw(soap, soap->buf, soap->bufidx)) - return soap->error; - soap->bufidx = 0; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send_raw(struct soap *soap, const char *s, size_t n) -{ if (!n) - return SOAP_OK; - if (soap->mode & SOAP_IO_LENGTH) - { soap->count += n; - if (soap->fpreparesend && (soap->mode & SOAP_IO) != SOAP_IO_STORE) - return soap->fpreparesend(soap, s, n); - return SOAP_OK; - } - if (soap->mode & SOAP_IO) - { register size_t i = SOAP_BUFLEN - soap->bufidx; - while (n >= i) - { memcpy(soap->buf + soap->bufidx, s, i); - soap->bufidx = SOAP_BUFLEN; - if (soap_flush(soap)) - return soap->error; - s += i; - n -= i; - i = SOAP_BUFLEN; - } - memcpy(soap->buf + soap->bufidx, s, n); - soap->bufidx += n; - return SOAP_OK; - } - return soap_flush_raw(soap, s, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send(struct soap *soap, const char *s) -{ if (s) - return soap_send_raw(soap, s, strlen(s)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send2(struct soap *soap, const char *s1, const char *s2) -{ if (soap_send(soap, s1)) - return soap->error; - return soap_send(soap, s2); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send3(struct soap *soap, const char *s1, const char *s2, const char *s3) -{ if (soap_send(soap, s1) - || soap_send(soap, s2)) - return soap->error; - return soap_send(soap, s3); -} -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static size_t -frecv(struct soap *soap, char *s, size_t n) -{ register int r; - soap->errnum = 0; -#if defined(__cplusplus) && !defined(WITH_LEAN) - if (soap->is) - { if (soap->is->good()) - return soap->is->read(s, n).gcount(); - return 0; - } -#endif - if (soap_valid_socket(soap->socket)) - { for (;;) - { -#ifndef WITH_LEAN - struct timeval timeout; - fd_set fd; - if (soap->recv_timeout) - { if (soap->recv_timeout > 0) - { timeout.tv_sec = soap->recv_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->recv_timeout/1000000; - timeout.tv_usec = -soap->recv_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - for (;;) - { r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r > 0) - break; - if (r == 0) - return 0; - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return 0; - } - } - } -#endif -#ifdef WITH_OPENSSL - if (soap->ssl) - { int err; - r = SSL_read(soap->ssl, s, n); - if ((err = SSL_get_error(soap->ssl, r)) == SSL_ERROR_NONE) - return (size_t)r; - if (err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - return 0; - } - else -#endif - { r = recv((SOAP_SOCKET)soap->socket, s, n, soap->socket_flags); - if (r >= 0) - return (size_t)r; - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - return 0; - } - } -#ifndef WITH_LEAN - { struct timeval timeout; - fd_set fd; - timeout.tv_sec = 0; - timeout.tv_usec = 10000; - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r < 0 && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return 0; - } - } -#endif - } - } -#ifdef WITH_FASTCGI - return fread(s, 1, n, stdin); -#else -#ifdef UNDER_CE - return fread(s, 1, n, soap->recvfd); -#else -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - r = httpBlockRead(soap->rpmreqid, s, n); - else - r = read(soap->recvfd, s, n); - if (r >= 0) - return r; - return 0; -#else -/* ]WR */ - r = read((SOAP_SOCKET)soap->recvfd, s, n); - if (r >= 0) - return (size_t)r; - soap->errnum = soap_errno; - return 0; -/* WR[ */ -#endif -/* ]WR */ -#endif -#endif -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static soap_wchar -soap_getchunkchar(struct soap *soap) -{ if (soap->bufidx < soap->buflen) - return soap->buf[soap->bufidx++]; - soap->bufidx = 0; - soap->buflen = soap->chunkbuflen = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)soap->buflen)); - DBGMSG(RECV, soap->buf, soap->buflen); - if (soap->buflen) - return soap->buf[soap->bufidx++]; - return EOF; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_isxdigit(int c) -{ switch (c) - { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - return 1; - } - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_raw(struct soap *soap) -{ register size_t ret; -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { if (soap->d_stream.next_out == Z_NULL) - return EOF; - if (soap->d_stream.avail_in || !soap->d_stream.avail_out) - { register int r; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflating\n")); - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - r = inflate(&soap->d_stream, Z_NO_FLUSH); - if (r == Z_OK || r == Z_STREAM_END) - { soap->bufidx = 0; - soap->buflen = SOAP_BUFLEN - soap->d_stream.avail_out; - if (soap->zlib_in == SOAP_ZLIB_GZIP) - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->buflen); - if (r == Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_in = (float)soap->d_stream.total_in / (float)soap->d_stream.total_out; - soap->d_stream.next_out = Z_NULL; - } - if (soap->buflen) - { soap->count += soap->buflen; - return SOAP_OK; - } - } - else if (r != Z_BUF_ERROR) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate error: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - soap->d_stream.next_out = Z_NULL; - return EOF; - } - } -zlib_again: - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK && !soap->chunksize) - { memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN); - soap->buflen = soap->z_buflen; - } - } -#endif - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) /* read HTTP chunked transfer */ - { -chunk_again: - if (soap->chunksize) - { soap->buflen = ret = soap->frecv(soap, soap->buf, soap->chunksize > SOAP_BUFLEN ? SOAP_BUFLEN : soap->chunksize); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk: read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - soap->bufidx = 0; - soap->chunksize -= ret; - } - else - { register soap_wchar c; - char *t, tmp[8]; - t = tmp; - if (!soap->chunkbuflen) - { soap->chunkbuflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - soap->bufidx = 0; - if (!ret) - return EOF; - } - else - soap->bufidx = soap->buflen; - soap->buflen = soap->chunkbuflen; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk size (%u %u)\n", (unsigned int)soap->bufidx, (unsigned int)soap->buflen)); - while (!soap_isxdigit((int)(c = soap_getchunkchar(soap)))) - if ((int)c == EOF) - return EOF; - do - *t++ = (char)c; - while (soap_isxdigit((int)(c = soap_getchunkchar(soap))) && t - tmp < 7); - while ((int)c != EOF && c != '\n') - c = soap_getchunkchar(soap); - if ((int)c == EOF) - return EOF; - *t = '\0'; - soap->chunksize = soap_strtoul(tmp, &t, 16); - if (!soap->chunksize) - { soap->chunkbuflen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of chunked message\n")); - while ((int)c != EOF && c != '\n') - c = soap_getchunkchar(soap); - return EOF; - } - soap->buflen = soap->bufidx + soap->chunksize; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving buf len to %u (%u %s)\n", (unsigned int)soap->buflen, (unsigned int)soap->bufidx, tmp)); - if (soap->buflen > soap->chunkbuflen) - { soap->buflen = soap->chunkbuflen; - soap->chunksize -= soap->buflen - soap->bufidx; - soap->chunkbuflen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Passed end of buffer for chunked HTTP (%lu bytes left)\n", (unsigned long)(soap->buflen - soap->bufidx))); - } - else if (soap->chunkbuflen) - soap->chunksize = 0; - ret = soap->buflen - soap->bufidx; - if (!ret) - goto chunk_again; - } - } - else - { soap->bufidx = 0; - soap->buflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes\n", (unsigned int)ret)); - DBGMSG(RECV, soap->buf, ret); - } - if (soap->fpreparerecv && (soap->error = soap->fpreparerecv(soap, soap->buf, ret))) - return soap->error; -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { register int r; - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = (unsigned int)ret; - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - r = inflate(&soap->d_stream, Z_NO_FLUSH); - if (r == Z_OK || r == Z_STREAM_END) - { soap->bufidx = 0; - soap->z_buflen = soap->buflen; - soap->buflen = ret = SOAP_BUFLEN - soap->d_stream.avail_out; - if (soap->zlib_in == SOAP_ZLIB_GZIP) - soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->buflen); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %u bytes\n", (unsigned int)ret)); - if (!ret) - goto zlib_again; - if (r == Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_in = (float)soap->d_stream.total_in / (float)soap->d_stream.total_out; - soap->d_stream.next_out = Z_NULL; - } - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to inflate: (%d) %s\n", r, soap->d_stream.msg?soap->d_stream.msg:"")); - soap->d_stream.next_out = Z_NULL; - return EOF; - } - } -#endif - soap->count += ret; - return !ret; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv(struct soap *soap) -{ -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_DIME) - { if (soap->dime.buflen) - { char *s; - int i; - unsigned char tmp[12]; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME hdr for chunked DIME is in buffer\n")); - soap->count += soap->dime.buflen - soap->buflen; - soap->buflen = soap->dime.buflen; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Skip padding (%ld bytes)\n", -(long)soap->dime.size&3)); - for (i = -(long)soap->dime.size&3; i > 0; i--) - { soap->bufidx++; - if (soap->bufidx >= soap->buflen) - if (soap_recv_raw(soap)) - return EOF; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME hdr for next chunk\n")); - s = (char*)tmp; - for (i = 12; i > 0; i--) - { *s++ = soap->buf[soap->bufidx++]; - if (soap->bufidx >= soap->buflen) - if (soap_recv_raw(soap)) - return EOF; - } - soap->dime.flags = tmp[0] & 0x7; - soap->dime.size = ((size_t)tmp[8] << 24) | ((size_t)tmp[9] << 16) | ((size_t)tmp[10] << 8) | ((size_t)tmp[11]); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME chunk (%u bytes)\n", (unsigned int)soap->dime.size)); - if (soap->dime.flags & SOAP_DIME_CF) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "More chunking\n")); - soap->dime.chunksize = soap->dime.size; - if (soap->buflen - soap->bufidx >= soap->dime.size) - { soap->dime.buflen = soap->buflen; - soap->buflen = soap->bufidx + soap->dime.chunksize; - } - else - soap->dime.chunksize -= soap->buflen - soap->bufidx; - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Last chunk\n")); - soap->dime.buflen = 0; - soap->dime.chunksize = 0; - } - soap->count = soap->buflen - soap->bufidx; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%u bytes remaining\n", (unsigned int)soap->count)); - return SOAP_OK; - } - if (soap->dime.chunksize) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get next DIME hdr for chunked DIME (%u bytes chunk)\n", (unsigned int)soap->dime.chunksize)); - if (soap_recv_raw(soap)) - return EOF; - if (soap->buflen - soap->bufidx >= soap->dime.chunksize) - { soap->dime.buflen = soap->buflen; - soap->count -= soap->buflen - soap->bufidx - soap->dime.chunksize; - soap->buflen = soap->bufidx + soap->dime.chunksize; - } - else - soap->dime.chunksize -= soap->buflen - soap->bufidx; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%lu bytes remaining, count=%u\n", (unsigned long)(soap->buflen-soap->bufidx), (unsigned int)soap->count)); - return SOAP_OK; - } - } -#endif - return soap_recv_raw(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -soap_wchar -SOAP_FMAC2 -soap_getchar(struct soap *soap) -{ register soap_wchar c; - if (soap->ahead) - { c = soap->ahead; - soap->ahead = 0; - return c; - } - return soap_get1(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const struct soap_code_map* -SOAP_FMAC2 -soap_code(const struct soap_code_map *map, const char *str) -{ while (map->string) - { if (!strcmp(str, map->string)) /* case sensitive */ - return map; - map++; - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_int_code(const struct soap_code_map *map, const char *str, long other) -{ while (map->string) - { if (!soap_tag_cmp(str, map->string)) /* case insensitive */ - return map->code; - map++; - } - return other; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_str_code(const struct soap_code_map *map, long code) -{ while (map->code != code && map->string) - map++; - return map->string; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static soap_wchar -soap_char(struct soap *soap) -{ char tmp[8]; - register int i; - register soap_wchar c; - register char *s = tmp; - for (i = 0; i < 7; i++) - { c = soap_get1(soap); - if (c == ';' || (int)c == EOF) - break; - *s++ = (char)c; - } - *s = '\0'; - if (*tmp == '#') - { if (tmp[1] == 'x' || tmp[1] == 'X') - return soap_strtol(tmp + 2, NULL, 16); - return atol(tmp + 1); - } - if (!strcmp(tmp, "lt")) - return '<'; - if (!strcmp(tmp, "gt")) - return '>'; - if (!strcmp(tmp, "amp")) - return '&'; - if (!strcmp(tmp, "quot")) - return '"'; - if (!strcmp(tmp, "apos")) - return '\''; -#ifndef WITH_LEAN - return (soap_wchar)soap_int_code(html_entity_codes, tmp, SOAP_UNKNOWN_CHAR); -#else - return SOAP_UNKNOWN_CHAR; /* use this to represent unknown code */ -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -soap_wchar -SOAP_FMAC2 -soap_get(struct soap *soap) -{ register soap_wchar c; - c = soap->ahead; - if (c) - soap->ahead = 0; - else - c = soap_get1(soap); - for (;;) - { if (soap->cdata) - { if (c == ']') - { c = soap_get1(soap); - if (c == ']') - { soap->cdata = 0; - soap_get1(soap); /* skip > */ - c = soap_get1(soap); - } - else - { soap_revget1(soap); - return ']'; - } - } - else - return c; - } - switch (c) - { case '<': - do c = soap_get1(soap); - while (soap_blank(c)); - if (c == '!' || c == '?' || c == '%') - { if (c == '!') - { c = soap_get1(soap); - if (c == '[') - { do c = soap_get1(soap); - while ((int)c != EOF && c != '['); - if ((int)c == EOF) - break; - soap->cdata = 1; - c = soap_get1(soap); - continue; - } - if (c == '-' && (c = soap_get1(soap)) == '-') - { do - { c = soap_get1(soap); - if (c == '-' && (c = soap_get1(soap)) == '-') - break; - } while ((int)c != EOF); - } - } - while ((int)c != EOF && c != '>') - c = soap_get1(soap); - if ((int)c == EOF) - break; - c = soap_get1(soap); - continue; - } - if (c == '/') - return SOAP_TT; - soap_revget1(soap); - return SOAP_LT; - case '>': - return SOAP_GT; - case '"': - return SOAP_QT; - case '\'': - return SOAP_AP; - case '&': - return soap_char(soap) | 0x80000000; - } - break; - } - return c; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -soap_wchar -SOAP_FMAC2 -soap_advance(struct soap *soap) -{ register soap_wchar c; - while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT) - ; - return c; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -soap_wchar -SOAP_FMAC2 -soap_skip(struct soap *soap) -{ register soap_wchar c; - do c = soap_get(soap); - while (soap_blank(c)); - return c; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_move(struct soap *soap, long n) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving %ld bytes forward\n", (long)n)); - for (; n > 0; n--) - if ((int)soap_getchar(soap) == EOF) - return SOAP_EOF; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_tell(struct soap *soap) -{ return soap->count - soap->buflen + soap->bufidx - (soap->ahead != 0); -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pututf8(struct soap *soap, register unsigned long c) -{ char tmp[16]; - if (c > 0 && c < 0x80) - { *tmp = (char)c; - return soap_send_raw(soap, tmp, 1); - } -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { register char *t = tmp; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - *t = '\0'; - } - else -#endif - sprintf(tmp, "&#%lu;", c); - return soap_send(soap, tmp); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -soap_wchar -SOAP_FMAC2 -soap_getutf8(struct soap *soap) -{ register soap_wchar c, c1, c2, c3, c4; - c = soap_get(soap); - if (c < 0x80 || (soap->mode & SOAP_ENC_LATIN)) - return c; - c1 = soap_get(soap); - if (c1 < 0x80) - { soap_unget(soap, c1); - return c; - } - c1 &= 0x3F; - if (c < 0xE0) - return ((soap_wchar)(c & 0x1F) << 6) | c1; - c2 = (soap_wchar)soap_get1(soap) & 0x3F; - if (c < 0xF0) - return ((soap_wchar)(c & 0x0F) << 12) | (c1 << 6) | c2; - c3 = (soap_wchar)soap_get1(soap) & 0x3F; - if (c < 0xF8) - return ((soap_wchar)(c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3; - c4 = (soap_wchar)soap_get1(soap) & 0x3F; - if (c < 0xFC) - return ((soap_wchar)(c & 0x03) << 24) | (c1 << 18) | (c2 << 12) | (c3 << 6) | c4; - return ((soap_wchar)(c & 0x01) << 30) | (c1 << 24) | (c2 << 18) | (c3 << 12) | (c4 << 6) | (soap_wchar)(soap_get1(soap) & 0x3F); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_puthex(struct soap *soap, const unsigned char *s, int n) -{ /* TODO: serialize to DOM (as an option) using new soap_s2hex() */ - char d[2]; - register int i; - for (i = 0; i < n; i++) - { register int m = *s++; - d[0] = (char)((m >> 4) + (m > 159 ? '7' : '0')); - m &= 0x0F; - d[1] = (char)(m + (m > 9 ? '7' : '0')); - if (soap_send_raw(soap, d, 2)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -unsigned char* -SOAP_FMAC2 -soap_gethex(struct soap *soap, int *n) -{ -#ifdef WITH_FAST - soap->labidx = 0; - for (;;) - { register char *s; - register int i, k; - if (soap_append_lab(soap, NULL, 0)) - return NULL; - s = soap->labbuf + soap->labidx; - k = soap->lablen - soap->labidx; - soap->labidx = soap->lablen; - for (i = 0; i < k; i++) - { register char d1, d2; - register soap_wchar c; - c = soap_get(soap); - if (soap_isxdigit(c)) - { d1 = (char)c; - c = soap_get(soap); - if (soap_isxdigit(c)) - d2 = (char)c; - else - { soap->error = SOAP_TYPE; - return NULL; - } - } - else - { unsigned char *p; - soap_unget(soap, c); - if (n) - *n = (int)(soap->lablen - k + i); - p = (unsigned char*)soap_malloc(soap, soap->lablen - k + i); - if (p) - memcpy(p, soap->labbuf, soap->lablen - k + i); - return p; - } - *s++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0'); - } - } -#else - if (soap_new_block(soap)) - return NULL; - for (;;) - { register int i; - register char *s = (char*)soap_push_block(soap, SOAP_BLKLEN); - if (!s) - { soap_end_block(soap); - return NULL; - } - for (i = 0; i < SOAP_BLKLEN; i++) - { register char d1, d2; - register soap_wchar c = soap_get(soap); - if (soap_isxdigit(c)) - { d1 = (char)c; - c = soap_get(soap); - if (soap_isxdigit(c)) - d2 = (char)c; - else - { soap_end_block(soap); - soap->error = SOAP_TYPE; - return NULL; - } - } - else - { unsigned char *p; - soap_unget(soap, c); - if (n) - *n = soap_size_block(soap, i); - p = (unsigned char*)soap_save_block(soap, NULL, 0); - return p; - } - *s++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0'); - } - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putbase64(struct soap *soap, const unsigned char *s, int n) -{ register int i; - register unsigned long m; - char d[4]; - if (!s) - return SOAP_OK; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { if (!(soap->dom->data = soap_s2base64(soap, s, soap->dom->data, n))) - return soap->error; - return SOAP_OK; - } -#endif - for (; n > 2; n -= 3, s += 3) - { m = s[0]; - m = (m << 8) | s[1]; - m = (m << 8) | s[2]; - for (i = 4; i > 0; m >>= 6) - d[--i] = soap_base64o[m & 0x3F]; - if (soap_send_raw(soap, d, 4)) - return soap->error; - } - if (n > 0) - { m = 0; - for (i = 0; i < n; i++) - m = (m << 8) | *s++; - for (; i < 3; i++) - m <<= 8; - for (i++; i > 0; m >>= 6) - d[--i] = soap_base64o[m & 0x3F]; - for (i = 3; i > n; i--) - d[i] = '='; - if (soap_send_raw(soap, d, 4)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -unsigned char* -SOAP_FMAC2 -soap_getbase64(struct soap *soap, int *n, int malloc_flag) -{ -#ifdef WITH_FAST - soap->labidx = 0; - for (;;) - { register int i, k; - register char *s; - if (soap_append_lab(soap, NULL, 2)) - return NULL; - s = soap->labbuf + soap->labidx; - k = 3 * ((soap->lablen - soap->labidx) / 3); - soap->labidx = 3 * (soap->lablen / 3); - if (!s) - return NULL; - for (i = 0; i < k; i += 3) - { register unsigned long m = 0; - register int j = 0; - do - { register soap_wchar c = soap_get(soap); - if (c == '=' || c < 0) - { unsigned char *p; - switch (j) - { case 2: - *s++ = (char)((m >> 4) & 0xFF); - i++; - break; - case 3: - *s++ = (char)((m >> 10) & 0xFF); - *s++ = (char)((m >> 2) & 0xFF); - i += 2; - } - if (n) - *n = (int)(soap->lablen - k + i); - p = (unsigned char*)soap_malloc(soap, soap->lablen - k + i); - if (p) - memcpy(p, soap->labbuf, soap->lablen - k + i); - if (c >= 0) - { while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT) - ; - } - soap_unget(soap, c); - return p; - } - c -= '+'; - if (c >= 0 && c <= 79) - { m = (m << 6) + soap_base64i[c]; - j++; - } - } while (j < 4); - *s++ = (char)((m >> 16) & 0xFF); - *s++ = (char)((m >> 8) & 0xFF); - *s++ = (char)(m & 0xFF); - } - } -#else - if (soap_new_block(soap)) - return NULL; - for (;;) - { register int i; - register char *s = (char*)soap_push_block(soap, 3 * SOAP_BLKLEN); /* must be multiple of 3 */ - if (!s) - { soap_end_block(soap); - return NULL; - } - for (i = 0; i < SOAP_BLKLEN; i++) - { register unsigned long m = 0; - register int j = 0; - do - { register soap_wchar c = soap_get(soap); - if (c == '=' || c < 0) - { unsigned char *p; - i *= 3; - switch (j) - { case 2: - *s++ = (char)((m >> 4) & 0xFF); - i++; - break; - case 3: - *s++ = (char)((m >> 10) & 0xFF); - *s++ = (char)((m >> 2) & 0xFF); - i += 2; - } - if (n) - *n = (int)soap_size_block(soap, i); - p = (unsigned char*)soap_save_block(soap, NULL, 0); - if (c >= 0) - { while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT) - ; - } - soap_unget(soap, c); - return p; - } - c -= '+'; - if (c >= 0 && c <= 79) - { m = (m << 6) + soap_base64i[c]; - j++; - } - } while (j < 4); - *s++ = (char)((m >> 16) & 0xFF); - *s++ = (char)((m >> 8) & 0xFF); - *s++ = (char)(m & 0xFF); - } - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_strdup(struct soap *soap, const char *s) -{ char *t = NULL; - if (s && (t = (char*)soap_malloc(soap, strlen(s) + 1))) - strcpy(t, s); - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_new_block(struct soap *soap) -{ struct soap_blist *p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New block sequence (prev=%p)\n", soap->blist)); - if (!(p = (struct soap_blist*)SOAP_MALLOC(sizeof(struct soap_blist)))) - return SOAP_EOM; - p->next = soap->blist; - p->ptr = NULL; - p->size = 0; - soap->blist = p; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_push_block(struct soap *soap, size_t n) -{ char *p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push block of %u bytes (%u bytes total)\n", (unsigned int)n, (unsigned int)soap->blist->size + (unsigned int)n)); - if (!(p = (char*)SOAP_MALLOC(n + sizeof(char*) + sizeof(size_t)))) - { soap->error = SOAP_EOM; - return NULL; - } - *(char**)p = soap->blist->ptr; - *(size_t*)(p + sizeof(char*)) = n; - soap->blist->ptr = p; - soap->blist->size += n; - return p + sizeof(char*) + sizeof(size_t); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_pop_block(struct soap *soap) -{ char *p; - if (!soap->blist->ptr) - return; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pop block\n")); - p = soap->blist->ptr; - soap->blist->size -= *(size_t*)(p + sizeof(char*)); - soap->blist->ptr = *(char**)p; - SOAP_FREE(p); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_update_ptrs(struct soap *soap, char *start, char *end, long offset) -{ int i; - register struct soap_ilist *ip; - register struct soap_flist *fp; - register void *p, **q; - for (i = 0; i < SOAP_IDHASH; i++) - for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr && (char*)ip->ptr >= start && (char*)ip->ptr < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update id='%s' %p -> %p\n", ip->id, ip->ptr, (char*)ip->ptr + offset)); - ip->ptr = (char*)ip->ptr + offset; - } - for (q = &ip->link; q; q = (void**)p) - { p = *q; - if (p && (char*)p >= start && (char*)p < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Link update id='%s' %p\n", ip->id, p)); - *q = (char*)p + offset; - } - } - for (q = &ip->copy; q; q = (void**)p) - { p = *q; - if (p && (char*)p >= start && (char*)p < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy chain update id='%s' %p\n", ip->id, p)); - *q = (char*)p + offset; - } - } - for (fp = ip->flist; fp; fp = fp->next) - { if ((char*)fp->ptr >= start && (char*)fp->ptr < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy list update id='%s' %p\n", ip->id, fp)); - fp->ptr = (char*)fp->ptr + offset; - } - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -soap_has_copies(struct soap *soap, register const char *start, register const char *end) -{ register int i; - register struct soap_ilist *ip; - register struct soap_flist *fp; - register const char *p; - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) - { for (p = (const char*)ip->copy; p; p = *(const char**)p) - if (p >= start && p < end) - return SOAP_ERR; - for (fp = ip->flist; fp; fp = fp->next) - if ((const char*)fp->ptr >= start && (const char*)fp->ptr < end) - return SOAP_ERR; - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_resolve(struct soap *soap) -{ register int i; - register struct soap_ilist *ip; - register struct soap_flist *fp; - short flag; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data\n")); - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr) - { register void *p, **q, *r; - q = (void**)ip->link; - ip->link = NULL; - r = ip->ptr; - DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing link chain to resolve id='%s'\n", ip->id)); - while (q) - { p = *q; - *q = r; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "... link %p -> %p\n", q, r)); - q = (void**)p; - } - } - else if (*ip->id == '#') - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Missing data for id='%s'\n", ip->id)); - strcpy(soap->id, ip->id + 1); - return soap->error = SOAP_MISSING_ID; - } - } - } - do - { flag = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution phase\n")); - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr && !soap_has_copies(soap, (const char*)ip->ptr, (const char*)ip->ptr + ip->size)) - { if (ip->copy) - { register void *p, **q = (void**)ip->copy; - DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing copy chain to resolve id='%s'\n", ip->id)); - ip->copy = NULL; - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... copy %p -> %p (%u bytes)\n", ip->ptr, q, (unsigned int)ip->size)); - p = *q; - memcpy(q, ip->ptr, ip->size); - q = (void**)p; - } while (q); - flag = 1; - } - for (fp = ip->flist; fp; fp = ip->flist) - { register unsigned int k = fp->level; - register void *p = ip->ptr; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data type=%d location=%p level=%u,%u id='%s'\n", ip->type, p, ip->level, fp->level, ip->id)); - while (ip->level < k) - { register void **q = (void**)soap_malloc(soap, sizeof(void*)); - if (!q) - return soap->error; - *q = p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level, new location=%p holds=%p...\n", q, *q)); - p = (void*)q; - k--; - } - if (fp->fcopy) - fp->fcopy(soap, ip->type, fp->type, fp->ptr, p, ip->size); - else - soap_fcopy(soap, ip->type, fp->type, fp->ptr, p, ip->size); - ip->flist = fp->next; - SOAP_FREE(fp); - flag = 1; - } - } - } - } - } while (flag); -#ifdef SOAP_DEBUG - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->copy || ip->flist) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution error: forwarded data for id='%s' could not be propagated, please report this problem to the developers\n", ip->id)); - } - } - } -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution done\n")); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_size_block(struct soap *soap, size_t n) -{ if (soap->blist->ptr) - { soap->blist->size -= *(size_t*)(soap->blist->ptr + sizeof(char*)) - n; - *(size_t*)(soap->blist->ptr + sizeof(char*)) = n; - } - return soap->blist->size; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_first_block(struct soap *soap) -{ char *p, *q, *r; - p = soap->blist->ptr; - if (!p) - return NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "First block\n")); - r = NULL; - do - { q = *(char**)p; - *(char**)p = r; - r = p; - p = q; - } while (p); - soap->blist->ptr = r; - return r + sizeof(char*) + sizeof(size_t); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_next_block(struct soap *soap) -{ char *p; - p = soap->blist->ptr; - if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Next block\n")); - soap->blist->ptr = *(char**)p; - SOAP_FREE(p); - if (soap->blist->ptr) - return soap->blist->ptr + sizeof(char*) + sizeof(size_t); - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_block_size(struct soap *soap) -{ return *(size_t*)(soap->blist->ptr + sizeof(char*)); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_end_block(struct soap *soap) -{ struct soap_blist *bp; - char *p, *q; - bp = soap->blist; - if (bp) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of block sequence, free all remaining blocks\n")); - for (p = bp->ptr; p; p = q) - { q = *(char**)p; - SOAP_FREE(p); - } - soap->blist = bp->next; - SOAP_FREE(bp); - } - DBGLOG(TEST, if (soap->blist) SOAP_MESSAGE(fdebug, "Restore previous block sequence\n")); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_save_block(struct soap *soap, char *p, int flag) -{ register size_t n; - register char *q, *s; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Save all blocks in contiguous memory space of %u bytes (%p->%p)\n", (unsigned int)soap->blist->size, soap->blist->ptr, p)); - if (soap->blist->size) - { if (!p) - p = (char*)soap_malloc(soap, soap->blist->size); - if (p) - { for (s = p, q = soap_first_block(soap); q; q = soap_next_block(soap)) - { n = soap_block_size(soap); - if (flag) - soap_update_ptrs(soap, q, q + n, (long)s - (long)q); /* pointers s and q may or may not be related */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy %u bytes from %p to %p\n", (unsigned int)n, q, s)); - memcpy(s, q, n); - s += n; - } - } - else - soap->error = SOAP_EOM; - } - soap_end_block(soap); - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsize(struct soap *soap, const char *type, int size) -{ return soap_putsizes(soap, type, &size, 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsizes(struct soap *soap, const char *type, const int *size, int dim) -{ return soap_putsizesoffsets(soap, type, size, NULL, dim); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsizesoffsets(struct soap *soap, const char *type, const int *size, const int *offset, int dim) -{ int i; - if (!type) - return NULL; - if (soap->version == 2) - { sprintf(soap->type, "%s[%d", type, size[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), " %d", size[i]); - } - else - { if (offset) - { sprintf(soap->type, "%s[%d", type, size[0] + offset[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), ",%d", size[i] + offset[i]); - } - else - { sprintf(soap->type, "%s[%d", type, size[0]); - for (i = 1; i < dim; i++) - sprintf(soap->type + strlen(soap->type), ",%d", size[i]); - } - strcat(soap->type, "]"); - } - return soap->type; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putoffset(struct soap *soap, int offset) -{ return soap_putoffsets(soap, &offset, 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putoffsets(struct soap *soap, const int *offset, int dim) -{ register int i; - sprintf(soap->arrayOffset, "[%d", offset[0]); - for (i = 1; i < dim; i++) - sprintf(soap->arrayOffset + strlen(soap->arrayOffset), ",%d", offset[i]); - strcat(soap->arrayOffset, "]"); - return soap->arrayOffset; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_size(const int *size, int dim) -{ register int i, n = size[0]; - for (i = 1; i < dim; i++) - n *= size[i]; - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getoffsets(const char *attr, const int *size, int *offset, int dim) -{ register int i, j = 0; - if (offset) - for (i = 0; i < dim && attr && *attr; i++) - { attr++; - j *= size[i]; - j += offset[i] = (int)atol(attr); - attr = strchr(attr, ','); - } - else - for (i = 0; i < dim && attr && *attr; i++) - { attr++; - j *= size[i]; - j += (int)atol(attr); - attr = strchr(attr, ','); - } - return j; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getsize(const char *attr1, const char *attr2, int *j) -{ register int n, k; - char *s; - *j = 0; - if (!*attr1) - return -1; - n = 1; - do - { attr1++; - k = (int)soap_strtol(attr1, &s, 10); - n *= k; - if (k < 0 || n > SOAP_MAXARRAYSIZE || s == attr1) - return -1; - attr1 = strchr(s, ','); - if (!attr1) - attr1 = strchr(s, ' '); - if (attr2 && *attr2) - { attr2++; - *j *= k; - k = (int)soap_strtol(attr2, &s, 10); - *j += k; - if (k < 0) - return -1; - attr2 = s; - } - } while (attr1 && *attr1 != ']'); - return n - *j; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getsizes(const char *attr, int *size, int dim) -{ register int i, k, n; - if (!*attr) - return -1; - i = strlen(attr); - n = 1; - do - { for (i = i-1; i >= 0; i--) - if (attr[i] == '[' || attr[i] == ',' || attr[i] == ' ') - break; - k = (int)atol(attr + i + 1); - n *= size[--dim] = k; - if (k < 0 || n > SOAP_MAXARRAYSIZE) - return -1; - } while (i >= 0 && attr[i] != '['); - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getposition(const char *attr, int *pos) -{ register int i, n; - if (!*attr) - return -1; - n = 0; - i = 1; - do - { pos[n++] = (int)atol(attr + i); - while (attr[i] && attr[i] != ',' && attr[i] != ']') - i++; - if (attr[i] == ',') - i++; - } while (n < SOAP_MAXDIMS && attr[i] && attr[i] != ']'); - return n; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_push_namespace(struct soap *soap, const char *id, const char *ns) -{ register struct soap_nlist *np; - register struct Namespace *p; - np = (struct soap_nlist*)SOAP_MALLOC(sizeof(struct soap_nlist) + strlen(id)); - if (!np) - return soap->error = SOAP_EOM; - np->next = soap->nlist; - soap->nlist = np; - strcpy(np->id, id); - np->level = soap->level; - np->index = -1; - np->ns = NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push namespace binding (level=%u) '%s' '%s'\n", soap->level, id, ns)); - p = soap->local_namespaces; - if (p) - { register short i = 0; - for (; p->id; p++, i++) - { if (p->ns && !strcmp(ns, p->ns)) - { if (p->out) - { SOAP_FREE(p->out); - p->out = NULL; - } - break; - } - if (p->out) - { if (!SOAP_STRCMP(ns, p->out)) - break; - } - else if (p->in) - { if (!soap_tag_cmp(ns, p->in)) - { if ((p->out = (char*)SOAP_MALLOC(strlen(ns) + 1))) - strcpy(p->out, ns); - break; - } - } - } - if (p && p->id) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push OK ('%s' matches '%s' in namespace table)\n", id, p->id)); - np->index = i; - } - } - if (!p || !p->id) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push NOT OK: no match found for '%s' in namespace mapping table (added to stack anyway)\n", ns)); - np->ns = (char*)SOAP_MALLOC(strlen(ns) + 1); - if (!np->ns) - return soap->error = SOAP_EOM; - strcpy(np->ns, ns); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_pop_namespace(struct soap *soap) -{ register struct soap_nlist *np; - while (soap->nlist && soap->nlist->level >= soap->level) - { np = soap->nlist->next; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Popped namespace binding (level=%u) '%s'\n", soap->level, soap->nlist->id)); - if (soap->nlist->ns) - SOAP_FREE(soap->nlist->ns); - SOAP_FREE(soap->nlist); - soap->nlist = np; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_namespace(struct soap *soap, const char *id1, const char *id2, int n1, int n2) -{ register struct soap_nlist *np = soap->nlist; - while (np && (strncmp(np->id, id1, n1) || np->id[n1])) - np = np->next; - if (np) - { if (np->index < 0 || (np->index >= 0 && soap->local_namespaces[np->index].id && (strncmp(soap->local_namespaces[np->index].id, id2, n2) || soap->local_namespaces[np->index].id[n2]))) - return SOAP_NAMESPACE; - return SOAP_OK; - } - if (n1 == 3 && n1 == n2 && !strcmp(id1, "xml") && !strcmp(id1, id2)) - return SOAP_OK; - return SOAP_SYNTAX_ERROR; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_tag_cmp(const char *s, const char *t) -{ for (;;) - { register int c1 = *s; - register int c2 = *t; - if (!c1 || c1 == '"') - break; - if (c2 != '-') - { if (c1 != c2) - { if (c1 >= 'A' && c1 <= 'Z') - c1 += 'a' - 'A'; - if (c2 >= 'A' && c2 <= 'Z') - c2 += 'a' - 'A'; - } - if (c1 != c2) - { if (c2 != '*') - return 1; - c2 = *++t; - if (!c2) - return 0; - if (c2 >= 'A' && c2 <= 'Z') - c2 += 'a' - 'A'; - for (;;) - { c1 = *s; - if (!c1 || c1 == '"') - break; - if (c1 >= 'A' && c1 <= 'Z') - c1 += 'a' - 'A'; - if (c1 == c2) - if (!soap_tag_cmp(s + 1, t + 1)) - return 0; - s++; - } - break; - } - } - s++; - t++; - } - if (*t == '*' && !t[1]) - return 0; - return *t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_tag(struct soap *soap, const char *tag1, const char *tag2) -{ register const char *s, *t; - if (!tag1 || !tag2 || !*tag2) - return SOAP_OK; - s = strchr(tag1, ':'); - t = strchr(tag2, ':'); - if (t) - { if (s) - { if (t[1] && SOAP_STRCMP(s + 1, t + 1)) - return SOAP_TAG_MISMATCH; - if (t != tag2 && soap_match_namespace(soap, tag1, tag2, s - tag1, t - tag2)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); - return SOAP_TAG_MISMATCH; - } - } - else if (SOAP_STRCMP(tag1, t + 1)) - return SOAP_TAG_MISMATCH; - else if (t != tag2 && soap_match_namespace(soap, tag1, tag2, 0, t - tag2)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); - return SOAP_TAG_MISMATCH; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags and (default) namespaces match: '%s' '%s'\n", tag1, tag2)); - return SOAP_OK; - } - if (s) - { if (SOAP_STRCMP(s + 1, tag2)) - return SOAP_TAG_MISMATCH; - } - else if (SOAP_STRCMP(tag1, tag2)) - return SOAP_TAG_MISMATCH; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags match: '%s' '%s'\n", tag1, tag2)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_match_array(struct soap *soap, const char *type) -{ if (*soap->arrayType) - if (soap_match_tag(soap, soap->arrayType, type) - && soap_match_tag(soap, soap->arrayType, "xsd:anyType") - && soap_match_tag(soap, soap->arrayType, "xsd:ur-type") - ) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array type mismatch: '%s' '%s'\n", soap->arrayType, type)); - return SOAP_TAG_MISMATCH; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ - -#ifdef WITH_OPENSSL -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_server_context(struct soap *soap, unsigned short flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *dhfile, const char *randfile, const char *sid) -{ int err; - soap->keyfile = keyfile; - soap->password = password; - soap->cafile = cafile; - soap->capath = capath; - if (dhfile) - { soap->dhfile = dhfile; - soap->rsa = 0; - } - else - { soap->dhfile = NULL; - soap->rsa = 1; - } - soap->randfile = randfile; - soap->require_client_auth = (flags & SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION); - if (!(err = soap->fsslauth(soap))) - if (sid) - SSL_CTX_set_session_id_context(soap->ctx, (unsigned char*)sid, strlen(sid)); - return err; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_client_context(struct soap *soap, unsigned short flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *randfile) -{ soap->keyfile = keyfile; - soap->password = password; - soap->cafile = cafile; - soap->capath = capath; - soap->dhfile = NULL; - soap->rsa = 0; - soap->randfile = randfile; - soap->require_server_auth = (flags & SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION); - return soap->fsslauth(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static void -ssl_init() -{ static int done = 0; - if (!done) - { done = 1; - SSL_library_init(); -#ifndef WITH_LEAN - SSL_load_error_strings(); -#endif - if (!RAND_load_file("/dev/urandom", 1024)) - { int r; -#ifdef HAVE_RAND_R - unsigned int s = (unsigned int)time(NULL); -#endif - char buf[SOAP_BUFLEN]; - RAND_seed(buf, sizeof(buf)); - while (!RAND_status()) - { -#ifdef HAVE_RAND_R - r = rand_r(&s); -#else - r = rand(); -#endif - RAND_seed(&r, sizeof(int)); - } - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char * -ssl_error(struct soap *soap, int ret) -{ int err = SSL_get_error(soap->ssl, ret); - const char *msg = soap_str_code(h_ssl_error_codes, err); - if (msg) - strcpy(soap->msgbuf, msg); - else - return ERR_error_string(err, soap->msgbuf); - if (ERR_peek_error()) - { unsigned long r; - strcat(soap->msgbuf, "\n"); - while ((r = ERR_get_error())) - ERR_error_string_n(r, soap->msgbuf + strlen(soap->msgbuf), sizeof(soap->msgbuf) - strlen(soap->msgbuf)); - } - else - { switch (ret) - { case 0: - strcpy(soap->msgbuf, "EOF was observed that violates the protocol. The client probably provided invalid authentication information."); - break; - case -1: - sprintf(soap->msgbuf, "Error observed by underlying BIO: %s", strerror(errno)); - break; - } - } - return soap->msgbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_password(char *buf, int num, int rwflag, void *userdata) -{ if (num < (int)strlen((char*)userdata) + 1) - return 0; - return strlen(strcpy(buf, (char*)userdata)); -} -#endif - -/******************************************************************************/ -/* This callback is included for future references. It should not be deleted -#ifndef PALM_2 -static DH * -ssl_tmp_dh(SSL *ssl, int is_export, int keylength) -{ static DH *dh512 = NULL; - static DH *dh1024 = NULL; - DH *dh; - switch (keylength) - { case 512: - if (!dh512) - { BIO *bio = BIO_new_file("dh512.pem", "r"); - if (bio) - { dh512 = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - return dh512; - } - } - else - return dh512; - default: - if (!dh1024) - { BIO *bio = BIO_new_file("dh1024.pem", "r"); - if (bio) - { dh1024 = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - } - } - dh = dh1024; - } - return dh; -} -#endif -*/ -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_auth_init(struct soap *soap) -{ ssl_init(); - if (!soap->ctx) - if (!(soap->ctx = SSL_CTX_new(SSLv23_method()))) - return soap_set_receiver_error(soap, "SSL error", "Can't setup context", SOAP_SSL_ERROR); - if (soap->randfile) - { if (!RAND_load_file(soap->randfile, -1)) - return soap_set_receiver_error(soap, "SSL error", "Can't load randomness", SOAP_SSL_ERROR); - } - if (soap->cafile || soap->capath) - if (!SSL_CTX_load_verify_locations(soap->ctx, soap->cafile, soap->capath)) - return soap_set_receiver_error(soap, "SSL error", "Can't read CA file and/or directory", SOAP_SSL_ERROR); - if (!SSL_CTX_set_default_verify_paths(soap->ctx)) - return soap_set_receiver_error(soap, "SSL error", "Can't read default CA file and/or directory", SOAP_SSL_ERROR); - if (soap->keyfile) - { if (!SSL_CTX_use_certificate_chain_file(soap->ctx, soap->keyfile)) - return soap_set_receiver_error(soap, "SSL error", "Can't read certificate key file", SOAP_SSL_ERROR); - if (soap->password) - { SSL_CTX_set_default_passwd_cb_userdata(soap->ctx, (void*)soap->password); - SSL_CTX_set_default_passwd_cb(soap->ctx, ssl_password); - if (!SSL_CTX_use_PrivateKey_file(soap->ctx, soap->keyfile, SSL_FILETYPE_PEM)) - return soap_set_receiver_error(soap, "SSL error", "Can't read key file", SOAP_SSL_ERROR); - } - } - if (soap->rsa) - { RSA *rsa = RSA_generate_key(512, RSA_F4, NULL, NULL); - if (!SSL_CTX_set_tmp_rsa(soap->ctx, rsa)) - { if (rsa) - RSA_free(rsa); - return soap_set_receiver_error(soap, "SSL error", "Can't set RSA key", SOAP_SSL_ERROR); - } - RSA_free(rsa); - } - else if (soap->dhfile) - { DH *dh = 0; - BIO *bio; - bio = BIO_new_file(soap->dhfile, "r"); - if (!bio) - return soap_set_receiver_error(soap, "SSL error", "Can't read DH file", SOAP_SSL_ERROR); - dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); - BIO_free(bio); - if (SSL_CTX_set_tmp_dh(soap->ctx, dh) < 0) - { if (dh) - DH_free(dh); - return soap_set_receiver_error(soap, "SSL error", "Can't set DH parameters", SOAP_SSL_ERROR); - } - DH_free(dh); - } - SSL_CTX_set_options(soap->ctx, SSL_OP_ALL | SSL_OP_NO_SSLv2); - SSL_CTX_set_verify(soap->ctx, soap->require_client_auth ? (SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT) : soap->require_server_auth ? SSL_VERIFY_PEER : SSL_VERIFY_NONE, soap->fsslverify); -#if (OPENSSL_VERSION_NUMBER < 0x00905100L) - SSL_CTX_set_verify_depth(soap->ctx, 1); -#else - SSL_CTX_set_verify_depth(soap->ctx, 9); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -ssl_verify_callback(int ok, X509_STORE_CTX *store) -{ -#ifdef SOAP_DEBUG - if (!ok) - { char data[256]; - X509 *cert = X509_STORE_CTX_get_current_cert(store); - fprintf(stderr, "SSL Verify error with certificate at depth %d: %s\n", X509_STORE_CTX_get_error_depth(store), X509_verify_cert_error_string(X509_STORE_CTX_get_error(store))); - X509_NAME_oneline(X509_get_issuer_name(cert), data, sizeof(data)); - fprintf(stderr, "certificate issuer %s\n", data); - X509_NAME_oneline(X509_get_subject_name(cert), data, sizeof(data)); - fprintf(stderr, "certificate subject %s\n", data); - } -#endif - /* return 1 to always continue, but unsafe progress will be terminated by SSL */ - return ok; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_ssl_accept(struct soap *soap) -{ int i, r; - if (!soap_valid_socket(soap->socket)) - return soap_set_receiver_error(soap, "SSL error", "No socket in soap_ssl_accept()", SOAP_SSL_ERROR); - if (!soap->ssl) - { soap->ssl = SSL_new(soap->ctx); - if (!soap->ssl) - return soap_set_receiver_error(soap, "SSL error", "SSL_new() failed in soap_ssl_accept()", SOAP_SSL_ERROR); - } - else - SSL_clear(soap->ssl); - soap->imode |= SOAP_ENC_SSL; - soap->omode |= SOAP_ENC_SSL; -#ifdef WIN32 - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &nonblocking); - } -#else - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)|O_NONBLOCK); -#endif - soap->bio = BIO_new_socket((SOAP_SOCKET)soap->socket, BIO_NOCLOSE); - SSL_set_bio(soap->ssl, soap->bio, soap->bio); - i = 100; /* 100 * 0.1 ms retries */ - while ((r = SSL_accept(soap->ssl)) <= 0) - { int err = SSL_get_error(soap->ssl, r); - if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) - { struct timeval timeout; - fd_set fd; - if (i-- <= 0) - break; - timeout.tv_sec = 0; - timeout.tv_usec = 100000; - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->socket, &fd); - r = select((SOAP_SOCKET)(soap->socket + 1), &fd, NULL, &fd, &timeout); - if (r < 0 && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - return SOAP_EOF; - } - } - else - { soap->errnum = err; - break; - } - } -#ifdef WIN32 - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &blocking); - } -#else - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)&~O_NONBLOCK); -#endif - if (r <= 0) - { soap_set_receiver_error(soap, ssl_error(soap, r), "SSL_accept() failed in soap_ssl_accept()", SOAP_SSL_ERROR); - soap_closesock(soap); - return SOAP_SSL_ERROR; - } - if (soap->require_client_auth) - { X509 *peer; - int err; - if ((err = SSL_get_verify_result(soap->ssl)) != X509_V_OK) - { soap_closesock(soap); - return soap_set_sender_error(soap, X509_verify_cert_error_string(err), "SSL certificate presented by peer cannot be verified in soap_ssl_accept()", SOAP_SSL_ERROR); - } - peer = SSL_get_peer_certificate(soap->ssl); - if (!peer) - { soap_closesock(soap); - return soap_set_sender_error(soap, "SSL error", "No SSL certificate was presented by the peer in soap_ssl_accept()", SOAP_SSL_ERROR); - } - X509_free(peer); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#endif /* WITH_OPENSSL */ - -/******************************************************************************/ -#ifndef PALM_1 -static int -tcp_init(struct soap *soap) -{ soap->errmode = 1; -#ifdef WIN32 - if (tcp_done) - return 0; - else - { WSADATA w; - if (WSAStartup(MAKEWORD(1, 1), &w)) - return -1; - tcp_done = 1; - } -#endif - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_done(struct soap *soap) -{ -#ifdef SOAP_DEBUG - int i; -#endif - soap_free(soap); - while (soap->clist) - { struct soap_clist *p = soap->clist->next; - SOAP_FREE(soap->clist); - soap->clist = p; - } - soap->keep_alive = 0; /* to force close the socket */ - soap_closesock(soap); -#ifdef WITH_COOKIES - soap_free_cookies(soap); -#endif - while (soap->plugins) - { register struct soap_plugin *p = soap->plugins->next; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Removing plugin '%s'\n", soap->plugins->id)); - if (soap->plugins->fcopy || !soap->copy) - soap->plugins->fdelete(soap, soap->plugins); - SOAP_FREE(soap->plugins); - soap->plugins = p; - } - soap->fplugin = fplugin; - soap->fpost = http_post; - soap->fget = http_get; - soap->fposthdr = http_post_header; - soap->fresponse = http_response; - soap->fparse = http_parse; - soap->fparsehdr = http_parse_header; -#ifndef MAC_CARBON -#ifndef WITH_IPV6 - soap->fresolve = tcp_gethost; -#else - soap->fresolve = NULL; -#endif - soap->faccept = tcp_accept; - soap->fopen = tcp_connect; - soap->fclose = tcp_disconnect; - soap->fclosesocket = tcp_closesocket; - soap->fshutdownsocket = tcp_shutdownsocket; - soap->fsend = fsend; - soap->frecv = frecv; - soap->fpoll = soap_poll; -#else - soap->fpoll = NULL; -#endif - soap->fprepareinit = NULL; - soap->fpreparesend = NULL; - soap->fpreparerecv = NULL; - soap->fignore = NULL; - soap->fserveloop = NULL; -#ifdef WITH_OPENSSL - if (soap->session) - { SSL_SESSION_free(soap->session); - soap->session = NULL; - } -#endif - if (!soap->copy) - { if (soap_valid_socket(soap->master)) - { soap->fclosesocket(soap, (SOAP_SOCKET)soap->master); - soap->master = SOAP_INVALID_SOCKET; - } -#ifdef WITH_OPENSSL - if (soap->ctx) - { SSL_CTX_free(soap->ctx); - soap->ctx = NULL; - } -#endif - } -#ifdef SOAP_DEBUG - for (i = 0; i < SOAP_MAXLOGS; i++) - { soap_close_logfile(soap, i); - if (soap->logfile[i]) - { SOAP_FREE((void*)soap->logfile[i]); - soap->logfile[i] = NULL; - } - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_cleanup(struct soap *soap) -{ soap_done(soap); -#ifdef WIN32 - if (!tcp_done) - return; - tcp_done = 0; - WSACleanup(); -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -tcp_error(struct soap *soap) -{ register const char *msg = NULL; - switch (soap->errmode) - { case 0: - msg = soap_strerror(soap); - break; - case 1: - msg = "WSAStartup failed"; - break; - case 2: - { -#ifndef WITH_LEAN - msg = soap_str_code(h_error_codes, soap->errnum); - if (!msg) -#endif - { sprintf(soap->msgbuf, "TCP error %d", soap->errnum); - msg = soap->msgbuf; - } - } - } - return msg; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -http_error(struct soap *soap, int status) -{ register const char *msg = NULL; -#ifndef WITH_LEAN - msg = soap_str_code(h_http_error_codes, status); - if (!msg) -#endif - { sprintf(soap->msgbuf, "HTTP error %d", status); - msg = soap->msgbuf; - } - return msg; -} -#endif - -/******************************************************************************/ -/* WR[ */ -#ifndef WITH_IPV6 -/* ]WR */ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_gethost(struct soap *soap, const char *addr, struct in_addr *inaddr) -{ unsigned long iadd; - struct hostent hostent, *host = &hostent; -/* WR[ */ -#ifdef VXWORKS - int hostint; - char *addrcopy = (char*)malloc(strlen(addr) + 1); /*copy of addr. */ - /* inet_addr(), and hostGetByName() expect "char *"; addr is a "const char *". */ - strncpy(addrcopy, addr, strlen(addr)+1); - iadd = inet_addr(addrcopy); -#else -/* ]WR */ -#if defined(_AIXVERSION_431) || defined(TRU64) - struct hostent_data ht_data; -#endif - iadd = inet_addr(addr); -/* WR[ */ -#endif -/* ]WR */ - if ((int)iadd != -1) - { memcpy(inaddr, &iadd, sizeof(iadd)); -/* WR[ */ -#ifdef VXWORKS - free(addrcopy); -#endif -/* ]WR */ - return SOAP_OK; - } -#if defined(__GLIBC__) - if (gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &host, &soap->errnum) < 0) - host = NULL; -#elif defined(_AIXVERSION_431) || defined(TRU64) - memset((void*)&ht_data, 0, sizeof(ht_data)); - if (gethostbyname_r(addr, &hostent, &ht_data) < 0) - { host = NULL; - soap->errnum = h_errno; - } -#elif defined(HAVE_GETHOSTBYNAME_R) - host = gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &soap->errnum); -/* WR[ */ -#elif defined(VXWORKS) - /* If the DNS resolver library resolvLib has been configured in the vxWorks - * image, a query for the host IP address is sent to the DNS server, if the - * name was not found in the local host table. */ - hostint = hostGetByName(addrcopy); - if (hostint == ERROR) - { host = NULL; - soap->errnum = soap_errno; - } - free(addrcopy); /*free() is placed after the error checking to assure that - * errno captured is that from hostGetByName() */ -/* ]WR */ -#else - if (!(host = gethostbyname(addr))) - soap->errnum = h_errno; -#endif - if (!host) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Host name not found\n")); - return SOAP_ERR; - } -/* WR[ */ -#ifdef VXWORKS - inaddr->s_addr = hostint; -#else -/* ]WR */ - memcpy(inaddr, host->h_addr, host->h_length); -/* WR[ */ -#endif -/* ]WR */ - return SOAP_OK; -} -#endif -#endif -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_connect(struct soap *soap, const char *endpoint, const char *host, int port) -{ struct sockaddr_in sockaddr; -/* WR[ */ -#ifdef WITH_IPV6 - struct addrinfo *addrinfo; - struct addrinfo hints; - struct addrinfo resaddr; - struct sockaddr_storage addrstorage; - int err; -#endif /* WITH_IPV6 */ -/* ]WR */ - register int fd; -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - if (soap_valid_socket(soap->socket)) - soap->fclosesocket(soap, (SOAP_SOCKET)soap->socket); - soap->socket = SOAP_INVALID_SOCKET; - if (tcp_init(soap)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP initialization failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - soap->errmode = 0; -/* WR[ */ -#ifdef WITH_IPV6 - memset((void*)&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - soap->errmode = 2; - if (soap->proxy_host) - err = getaddrinfo(soap->proxy_host, soap_int2s(soap, soap->proxy_port), &hints, &addrinfo); - else - err = getaddrinfo(host, soap_int2s(soap, port), &hints, &addrinfo); - if (addrinfo) - { resaddr = *addrinfo; - addrstorage = *((struct sockaddr_storage*)addrinfo->ai_addr); - resaddr.ai_addr = (struct sockaddr*)&addrstorage; - freeaddrinfo(addrinfo); - } - if (err) - { soap_set_sender_error(soap, gai_strerror(err), - "TCP getaddrinfo on proxy host failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - fd = (int)socket(resaddr.ai_family, resaddr.ai_socktype, resaddr.ai_protocol); /* modified to use fd */ - soap->errmode = 0; -#else /* WITH_IPV6 */ -/* ]WR */ - fd = (int)socket(AF_INET, SOCK_STREAM, 0); -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - if (fd < 0) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP socket failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } -#ifdef SOCKET_CLOSE_ON_EXEC -#ifdef WIN32 -#ifndef UNDER_CE - SetHandleInformation((HANDLE)fd, HANDLE_FLAG_INHERIT, 0); -#endif -#else - fcntl (fd, F_SETFD, 1); -#endif -#endif -#ifndef WITH_LEAN - if (soap->connect_flags & SO_LINGER) - { struct linger linger; - memset((void*)&linger, 0, sizeof(linger)); - linger.l_onoff = 1; - linger.l_linger = 0; - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_LINGER failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - } - if ((soap->connect_flags & ~SO_LINGER) && setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, soap->connect_flags & ~SO_LINGER, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - if (setsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)fd, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_sender_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } -#endif -#endif -/* WR[ */ -#ifndef WITH_IPV6 -/* ]WR */ - memset((void*)&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin_family = AF_INET; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Open socket %d to host='%s'\n", fd, host)); - soap->errmode = 2; - if (soap->proxy_host) - { if (soap->fresolve(soap, soap->proxy_host, &sockaddr.sin_addr)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP get proxy host by name failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - sockaddr.sin_port = htons((short)soap->proxy_port); - } - else - { if (soap->fresolve(soap, host, &sockaddr.sin_addr)) - { soap_set_sender_error(soap, tcp_error(soap), "TCP get host by name failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - sockaddr.sin_port = htons((short)port); - } - soap->errmode = 0; -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifndef WITH_LEAN - if (soap->connect_timeout) -#if defined(WIN32) - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &nonblocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { vx_nonblocking = TRUE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)|O_NONBLOCK); -#endif - else -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - for (;;) - { -/* WR[ */ -#ifdef WITH_IPV6 - if (connect((SOAP_SOCKET)fd, resaddr.ai_addr, resaddr.ai_addrlen)) /* modified to use fd */ -#else /* WITH_IPV6 */ - if (connect((SOAP_SOCKET)fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr))) -#endif /* WITH_IPV6 */ -/* ]WR */ - { -#ifndef WITH_LEAN - if (soap->connect_timeout && (soap_socket_errno == SOAP_EINPROGRESS || soap_socket_errno == SOAP_EWOULDBLOCK)) - { struct timeval timeout; -#if defined(SOCKLEN_T) - SOCKLEN_T n = sizeof(struct sockaddr_in); -#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) - socklen_t n = sizeof(struct sockaddr_in); -#elif defined(WIN32) || defined(__APPLE__) || defined(HP_UX) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) - int n = sizeof(struct sockaddr_in); -#else - size_t n = sizeof(struct sockaddr_in); -#endif - fd_set fds; - if (soap->connect_timeout > 0) - { timeout.tv_sec = soap->connect_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->connect_timeout/1000000; - timeout.tv_usec = -soap->connect_timeout%1000000; - } - FD_ZERO(&fds); - FD_SET((SOAP_SOCKET)fd, &fds); - for (;;) - { int r = select((SOAP_SOCKET)(fd + 1), NULL, &fds, NULL, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect timeout\n")); - soap_set_sender_error(soap, "Timeout", "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - } - n = sizeof(soap->errnum); - if (!getsockopt((SOAP_SOCKET)fd, SOL_SOCKET, SO_ERROR, (char*)&soap->errnum, &n) && !soap->errnum) - break; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - else -#endif - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - soap->fclosesocket(soap, (SOAP_SOCKET)fd); - return -1; - } - } - else - break; - } -#ifndef WITH_LEAN - if (soap->connect_timeout) -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)fd, FIONBIO, (int)(&vx_nonblocking)); /* modified to use fd */ - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - soap->socket = fd; -#ifdef WITH_OPENSSL - soap->imode &= ~SOAP_ENC_SSL; - soap->omode &= ~SOAP_ENC_SSL; - if (!strncmp(endpoint, "https:", 6)) - { int r; - if (soap->proxy_host) - { unsigned int k = soap->omode; /* make sure we only parse HTTP */ - size_t n = soap->count; /* save the content length */ - soap->omode &= ~0xFF; /* mask IO and ENC */ - soap->omode |= SOAP_IO_BUFFER; - soap_begin_send(soap); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connecting to proxy server\n")); - sprintf(soap->tmpbuf, "CONNECT %s:%d HTTP/%s", host, port, soap->http_version); - if ((soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return -1; -#ifndef WITH_LEAN - if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((soap->error = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) - return soap->error; - } -#endif - if ((soap->error = soap->fposthdr(soap, NULL, NULL)) - || soap_flush(soap)) - return -1; - soap->omode = k; - k = soap->imode; - soap->imode &= ~0xFF; /* mask IO and ENC */ - if (soap_begin_recv(soap)) - return -1; - soap->imode = k; - soap->count = n; - soap_begin_send(soap); - } - if (!soap->ctx && (soap->error = soap->fsslauth(soap))) - { soap_set_sender_error(soap, "SSL error", "SSL authentication failed in tcp_connect(): check password, key file, and ca file.", SOAP_SSL_ERROR); - return -1; - } - soap->ssl = SSL_new(soap->ctx); - if (!soap->ssl) - { soap->error = SOAP_SSL_ERROR; - return -1; - } - if (soap->session) - { if (!strcmp(soap->session_host, host) && soap->session_port == port) - SSL_set_session(soap->ssl, soap->session); - SSL_SESSION_free(soap->session); - soap->session = NULL; - } - soap->imode |= SOAP_ENC_SSL; - soap->omode |= SOAP_ENC_SSL; - soap->bio = BIO_new_socket((SOAP_SOCKET)fd, BIO_NOCLOSE); - SSL_set_bio(soap->ssl, soap->bio, soap->bio); -#ifndef WITH_LEAN - if (soap->connect_timeout) -#ifdef WIN32 - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &nonblocking); - } -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)|O_NONBLOCK); -#endif -#endif - for (;;) - { if ((r = SSL_connect(soap->ssl)) <= 0) - { int err = SSL_get_error(soap->ssl, r); - if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) - { soap_set_sender_error(soap, ssl_error(soap, r), "SSL connect failed in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - if (soap->connect_timeout) - { struct timeval timeout; - fd_set fds; - if (soap->connect_timeout > 0) - { timeout.tv_sec = soap->connect_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->connect_timeout/1000000; - timeout.tv_usec = -soap->connect_timeout%1000000; - } - FD_ZERO(&fds); - FD_SET((SOAP_SOCKET)(soap->socket), &fds); - for (;;) - { int r = select((SOAP_SOCKET)(soap->socket + 1), &fds, NULL, &fds, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect timeout\n")); - soap_set_sender_error(soap, "Timeout", "TCP connect failed in tcp_connect()", SOAP_TCP_ERROR); - return -1; - } - } - continue; - } - } - break; - } -#ifndef WITH_LEAN - if (soap->connect_timeout) -#ifdef WIN32 - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)fd, FIONBIO, &blocking); - } -#else - fcntl((SOAP_SOCKET)fd, F_SETFL, fcntl((SOAP_SOCKET)fd, F_GETFL)&~O_NONBLOCK); -#endif -#endif - if (soap->require_server_auth) - { X509 *peer; - int err; - if ((err = SSL_get_verify_result(soap->ssl)) != X509_V_OK) - { soap_set_sender_error(soap, X509_verify_cert_error_string(err), "SSL certificate presented by peer cannot be verified in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - peer = SSL_get_peer_certificate(soap->ssl); - if (!peer) - { soap_set_sender_error(soap, "SSL error", "No SSL certificate was presented by the peer in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - X509_NAME_get_text_by_NID(X509_get_subject_name(peer), NID_commonName, soap->msgbuf, sizeof(soap->msgbuf)); - X509_free(peer); - if (soap_tag_cmp(soap->msgbuf, host)) - { soap_set_sender_error(soap, "SSL error", "SSL certificate host name mismatch in tcp_connect()", SOAP_SSL_ERROR); - return -1; - } - } - } -#endif - return fd; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_bind(struct soap *soap, const char *host, int port, int backlog) -{ struct sockaddr_in sockaddr; -/* WR[ */ -#ifdef WITH_IPV6 - struct addrinfo *addrinfo; - struct addrinfo hints; - struct addrinfo resaddr; - struct sockaddr_storage addrstorage; - int err; -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - if (soap_valid_socket(soap->master)) - { soap->fclosesocket(soap, (SOAP_SOCKET)soap->master); - soap->master = SOAP_INVALID_SOCKET; - } - soap->socket = SOAP_INVALID_SOCKET; - soap->errmode = 1; - if (tcp_init(soap)) - { soap_set_receiver_error(soap, tcp_error(soap), "TCP init failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#ifdef WITH_IPV6 - memset((void*)&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; - soap->errmode = 2; - if (host) - err = getaddrinfo(host, soap_int2s(soap, port), &hints, &addrinfo); - else - err = getaddrinfo(NULL, soap_int2s(soap, port), &hints, &addrinfo); - if (NULL != addrinfo) - { - resaddr = *addrinfo; - addrstorage = *((struct sockaddr_storage *) addrinfo->ai_addr); - resaddr.ai_addr = (struct sockaddr *) &addrstorage; - freeaddrinfo(addrinfo); - } - if (err) - { soap_set_receiver_error(soap, gai_strerror(err), "TCP getaddrinfo failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - soap->errmode = 0; - if ((soap->master = socket(resaddr.ai_family, resaddr.ai_socktype, resaddr.ai_protocol)) < 0) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP socket failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#else /* WITH_IPV6 */ -/* ]WR */ - soap->errmode = 0; - if ((soap->master = (int)socket(AF_INET, SOCK_STREAM, 0)) < 0) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP socket failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifdef SOCKET_CLOSE_ON_EXEC -#ifdef WIN32 -#ifndef UNDER_CE - SetHandleInformation((HANDLE)soap->master, HANDLE_FLAG_INHERIT, 0); -#endif -#else - fcntl (soap->master, F_SETFD, 1); -#endif -#endif -#ifndef WITH_LEAN - if (soap->bind_flags && setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, soap->bind_flags, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->master, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)soap->master, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#endif -#endif -/* WR[ */ -#ifdef WITH_IPV6 - soap->errmode = 0; - if (bind(soap->master, resaddr.ai_addr, resaddr.ai_addrlen) || listen(soap->master, backlog)) - { - soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n")); - soap_closesock(soap); - soap_set_receiver_error(soap, tcp_error(soap), "TCP bind failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -#else /* WITH_IPV6 */ -/* ]WR */ - memset((void*)&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin_family = AF_INET; - soap->errmode = 2; - if (host) - { if (soap->fresolve(soap, host, &sockaddr.sin_addr)) - { soap_set_receiver_error(soap, tcp_error(soap), "TCP get host by name failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } - } - else - sockaddr.sin_addr.s_addr = htonl(INADDR_ANY); - sockaddr.sin_port = htons((short)port); - soap->errmode = 0; - if (bind((SOAP_SOCKET)soap->master, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) || listen((SOAP_SOCKET)soap->master, backlog)) - { soap->errnum = soap_socket_errno; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n")); - soap_closesock(soap); - soap_set_receiver_error(soap, tcp_error(soap), "TCP bind failed in soap_bind()", SOAP_TCP_ERROR); - return -1; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ -#ifdef WITH_OPENSSL - if (!soap->ctx && (soap->error = soap->fsslauth(soap))) - return -1; -#endif - return soap->master; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_poll(struct soap *soap) -{ -#ifndef WITH_LEAN - struct timeval timeout; - fd_set sfd,rfd; - int r; - timeout.tv_sec = 0; - timeout.tv_usec = 0; - FD_ZERO(&rfd); - FD_ZERO(&sfd); - if (soap->socket >= 0) - { FD_SET(soap->socket, &rfd); - FD_SET(soap->socket, &sfd); - r = select(soap->socket + 1, &rfd, &sfd, NULL, &timeout); - } - else if (soap->master >= 0) - { FD_SET(soap->master, &rfd); - r = select(soap->master + 1, &rfd, &sfd, NULL, &timeout); - } - else - { FD_SET(soap->sendfd, &sfd); - FD_SET(soap->recvfd, &rfd); - r = select((soap->sendfd > soap->recvfd ? soap->sendfd : soap->recvfd) + 1, &rfd, &sfd, NULL, &timeout); - } - if (r > 0) - { -#ifdef WITH_OPENSSL - if (soap->ssl) - { if ((soap->socket >= 0) && FD_ISSET(soap->socket, &rfd)) - { char buf = '\0'; - if (SSL_peek(soap->ssl, &buf, 1) <= 0) - return SOAP_EOF; - } - } -#endif - return SOAP_OK; - } - if (r < 0 && (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) && soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "select failed in soap_poll()", SOAP_TCP_ERROR); - return soap->error = SOAP_TCP_ERROR; - } - else - soap->errnum = soap_errno; - return SOAP_EOF; -#else - return SOAP_OK; -#endif -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_accept(struct soap *soap, int s, struct sockaddr *a, int *n) -{ int fd; -#if defined(SOCKLEN_T) - fd = (int)accept((SOAP_SOCKET)s, a, (SOCKLEN_T*)n); -#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) - fd = (int)accept((SOAP_SOCKET)s, a, (socklen_t*)n); -#elif defined(WIN32) || defined(__APPLE__) || defined(HP_UX) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) - fd = (int)accept((SOAP_SOCKET)s, a, n); -#else - fd = (int)accept((SOAP_SOCKET)s, a, (size_t*)n); -#endif -#ifdef SOCKET_CLOSE_ON_EXEC -#ifdef WIN32 -#ifndef UNDER_CE - SetHandleInformation((HANDLE)fd, HANDLE_FLAG_INHERIT, 0); -#endif -#else - fcntl(fd, F_SETFD, FD_CLOEXEC); -#endif -#endif - return fd; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_accept(struct soap *soap) -{ -/* WR[ */ -#ifdef WITH_IPV6 - struct sockaddr_storage sockaddr; -#else /* WITH_IPV6 */ -/* ]WR */ - struct sockaddr_in sockaddr; -/* WR[ */ -#endif -/* ]WR */ - int n = (int)sizeof(sockaddr); -#ifndef WITH_LEAN - int len = SOAP_BUFLEN; - int set = 1; -#endif - soap->error = SOAP_OK; - memset((void*)&sockaddr, 0, sizeof(sockaddr)); - soap->socket = SOAP_INVALID_SOCKET; - soap->errmode = 0; - if (soap_valid_socket(soap->master)) - { for (;;) - { -#ifndef WITH_LEAN - if (soap->accept_timeout) - { struct timeval timeout; - fd_set fd; - if (soap->accept_timeout > 0) - { timeout.tv_sec = soap->accept_timeout; - timeout.tv_usec = 0; - } - else - { timeout.tv_sec = -soap->accept_timeout/1000000; - timeout.tv_usec = -soap->accept_timeout%1000000; - } - FD_ZERO(&fd); - FD_SET((SOAP_SOCKET)soap->master, &fd); - for (;;) - { int r = select((SOAP_SOCKET)(soap->master + 1), &fd, &fd, NULL, &timeout); - if (r > 0) - break; - if (!r) - { soap->errnum = 0; - soap_set_receiver_error(soap, "Timeout", "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (soap_socket_errno != SOAP_EINTR) - { soap->errnum = soap_socket_errno; - soap_closesock(soap); - soap_set_sender_error(soap, tcp_error(soap), "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } -#if defined(WIN32) - { u_long nonblocking = 1; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &nonblocking); - } -#elif defined(VXWORKS) - { vx_nonblocking = TRUE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - } -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)|O_NONBLOCK); -#endif - } - else -#if defined(WIN32) - { u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &blocking); - } -/* WR[ */ -#elif defined(VXWORKS) - { vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - } -/* ]WR */ -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)&~O_NONBLOCK); -#endif -#endif - if ((soap->socket = soap->faccept(soap, soap->master, (struct sockaddr*)&sockaddr, &n)) >= 0) - { -/* WR[ */ -#ifdef WITH_IPV6 -/* Use soap->host to store the numeric form of the remote host */ - getnameinfo((struct sockaddr*)&sockaddr, n, soap->host, sizeof(soap->host), NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept socket %d from %s\n", soap->socket, soap->host)); - soap->ip = 0; /* info stored in soap->host */ - soap->port = 0; /* info stored in soap->host */ -#else /* WITH_IPV6 */ -/* ]WR */ - soap->ip = ntohl(sockaddr.sin_addr.s_addr); - soap->port = (int)ntohs(sockaddr.sin_port); /* does not return port number on some systems */ - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept socket %d at port %d from IP %d.%d.%d.%d\n", soap->socket, soap->port, (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF)); -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - soap->keep_alive = ((soap->imode & SOAP_IO_KEEPALIVE) != 0); -#ifndef WITH_LEAN - if (soap->accept_flags & SO_LINGER) - { struct linger linger; - memset((void*)&linger, 0, sizeof(linger)); - linger.l_onoff = 1; - linger.l_linger = 0; - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_LINGER failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } - if ((soap->accept_flags & ~SO_LINGER) && setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, soap->accept_flags & ~SO_LINGER, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (soap->keep_alive && setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_KEEPALIVE failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_SNDBUF failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - if (setsockopt((SOAP_SOCKET)soap->socket, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt SO_RCVBUF failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -#ifdef TCP_NODELAY - if (setsockopt((SOAP_SOCKET)soap->socket, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP setsockopt TCP_NODELAY failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -#endif -#endif - if (soap->accept_timeout) - { -#if defined(WIN32) - u_long blocking = 0; - ioctlsocket((SOAP_SOCKET)soap->master, FIONBIO, &blocking); - ioctlsocket((SOAP_SOCKET)soap->socket, FIONBIO, &blocking); -/* WR[ */ -#elif defined(VXWORKS) - vx_nonblocking = FALSE; - ioctl((SOAP_SOCKET)soap->master, FIONBIO, (int)(&vx_nonblocking)); - ioctl((SOAP_SOCKET)soap->socket, FIONBIO, (int)(&vx_nonblocking)); -/* ]WR */ -#elif defined(PALM) - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL,0)&~O_NONBLOCK); - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL,0)&~O_NONBLOCK); -#elif defined(SYMBIAN) - long blocking = 0; - ioctl((SOAP_SOCKET)soap->master, 0/*FIONBIO*/, &blocking); -#else - fcntl((SOAP_SOCKET)soap->master, F_SETFL, fcntl((SOAP_SOCKET)soap->master, F_GETFL)&~O_NONBLOCK); - fcntl((SOAP_SOCKET)soap->socket, F_SETFL, fcntl((SOAP_SOCKET)soap->socket, F_GETFL)&~O_NONBLOCK); -#endif - } - return soap->socket; - } - if (soap_socket_errno != SOAP_EINTR && soap_socket_errno != SOAP_EAGAIN) - { soap->errnum = soap_socket_errno; - soap_set_receiver_error(soap, tcp_error(soap), "TCP accept failed in soap_accept()", SOAP_TCP_ERROR); - return -1; - } - } - } - else - { soap_set_receiver_error(soap, tcp_error(soap), "TCP no master socket in soap_accept()", SOAP_TCP_ERROR); - return -1; - } -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_disconnect(struct soap *soap) -{ -#ifdef WITH_OPENSSL - if (soap->ssl) - { int r, s = 0; - if (soap->session) - SSL_SESSION_free(soap->session); - if (*soap->host) - { soap->session = SSL_get1_session(soap->ssl); - if (soap->session) - { strcpy(soap->session_host, soap->host); - soap->session_port = soap->port; - } - } - r = SSL_shutdown(soap->ssl); - if (r != 1) - { s = ERR_get_error(); - if (s) - { if (soap_valid_socket(soap->socket)) - { soap->fshutdownsocket(soap, (SOAP_SOCKET)soap->socket, 1); - soap->socket = SOAP_INVALID_SOCKET; - } - r = SSL_shutdown(soap->ssl); - } - } - DBGLOG(TEST, if (s) SOAP_MESSAGE(fdebug, "Shutdown failed: %d\n", SSL_get_error(soap->ssl, r))); - SSL_free(soap->ssl); - soap->ssl = NULL; - if (s) - return SOAP_SSL_ERROR; - ERR_remove_state(0); - } -#endif - if (soap_valid_socket(soap->socket)) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Closing socket %d\n", soap->socket)); - soap->fshutdownsocket(soap, (SOAP_SOCKET)soap->socket, 2); - soap->fclosesocket(soap, (SOAP_SOCKET)soap->socket); - soap->socket = SOAP_INVALID_SOCKET; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_closesocket(struct soap *soap, SOAP_SOCKET fd) -{ return closesocket(fd); -} -#endif -#endif - -/******************************************************************************/ -#ifndef MAC_CARBON -#ifndef PALM_1 -static int -tcp_shutdownsocket(struct soap *soap, SOAP_SOCKET fd, int how) -{ return shutdown(fd, how); -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_closesock(struct soap *soap) -{ register int status = soap->error; -#ifndef MAC_CARBON - if (status == SOAP_EOF || status == SOAP_TCP_ERROR || status == SOAP_SSL_ERROR || !soap->keep_alive) - { if ((soap->error = soap->fclose(soap))) - return soap->error; - soap->socket = SOAP_INVALID_SOCKET; - } -#endif -#ifdef WITH_ZLIB - if (soap->zlib_state == SOAP_ZLIB_DEFLATE) - deflateEnd(&soap->d_stream); - else if (soap->zlib_state == SOAP_ZLIB_INFLATE) - inflateEnd(&soap->d_stream); - soap->zlib_state = SOAP_ZLIB_NONE; -#endif - return soap->error = status; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_hash(register const char *s) -{ register size_t h = 0; - while (*s) - h = 65599*h + *s++; - return h % SOAP_IDHASH; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_init_pht(struct soap *soap) -{ register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing pointer hashtable\n")); - for (i = 0; i < (int)SOAP_PTRHASH; i++) - soap->pht[i] = NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new() -{ struct soap *soap = (struct soap*)SOAP_MALLOC(sizeof(struct soap)); - if (soap) - soap_init(soap); - return soap; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new1(int mode) -{ return soap_new2(mode, mode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_new2(int imode, int omode) -{ struct soap *soap = (struct soap*)SOAP_MALLOC(sizeof(struct soap)); - if (soap) - soap_init2(soap, imode, omode); - return soap; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_free_pht(struct soap *soap) -{ register struct soap_plist *pp, *next; - register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free pointer hashtable\n")); - for (i = 0; i < (int)SOAP_PTRHASH; i++) - { for (pp = soap->pht[i]; pp; pp = next) - { next = pp->next; - SOAP_FREE(pp); - } - soap->pht[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_embed(struct soap *soap, const void *p, const struct soap_array *a, int n, const char *tag, int type) -{ register int i; - struct soap_plist *pp; - if (soap->version != 1) - soap->encoding = 1; - if (a) - i = soap_array_pointer_lookup(soap, p, a, n, type, &pp); - else - i = soap_pointer_lookup(soap, p, type, &pp); - if (i) - { if (soap_is_embedded(soap, pp) - || soap_is_single(soap, pp)) - return 0; - soap_set_embedded(soap, pp); - } - return i; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pointer_lookup(struct soap *soap, const void *p, int type, struct soap_plist **ppp) -{ register struct soap_plist *pp; - *ppp = NULL; - if (p) - for (pp = soap->pht[soap_hash_ptr(p)]; pp; pp = pp->next) - if (pp->ptr == p && pp->type == type) - { *ppp = pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup location=%p type=%d id=%d\n", p, type, pp->id)); - return pp->id; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup location=%p type=%d: not found\n", p, type)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_pointer_enter(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp) -{ register int h; - register struct soap_plist *pp = *ppp = (struct soap_plist*)SOAP_MALLOC(sizeof(struct soap_plist)); - if (!pp) - return 0; - if (a) - h = soap_hash_ptr(a->__ptr); - else - h = soap_hash_ptr(p); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pointer enter location=%p array=%p size=%d dim=%d type=%d id=%lu\n", p, a?a->__ptr:NULL, a?a->__size:0, n, type, soap->idnum+1)); - pp->next = soap->pht[h]; - pp->type = type; - pp->mark1 = 0; - pp->mark2 = 0; - pp->ptr = p; - pp->array = a; - soap->pht[h] = pp; - pp->id = ++soap->idnum; - return pp->id; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_pointer_lookup(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp) -{ register struct soap_plist *pp; - *ppp = NULL; - if (!p || !a->__ptr) - return 0; - for (pp = soap->pht[soap_hash_ptr(a->__ptr)]; pp; pp = pp->next) - { if (pp->type == type && pp->array && pp->array->__ptr == a->__ptr) - { register int i; - for (i = 0; i < n; i++) - if (((const int*)&pp->array->__size)[i] != ((const int*)&a->__size)[i]) - break; - if (i == n) - { *ppp = pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d id=%d\n", a->__ptr, type, pp->id)); - return pp->id; - } - } - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d: not found\n", a->__ptr, type)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_begin_count(struct soap *soap) -{ soap_clr_attr(soap); - soap_set_local_namespaces(soap); -#ifndef WITH_LEANER - if ((soap->mode & SOAP_ENC_DIME) || (soap->omode & SOAP_ENC_DIME)) - soap->mode = soap->omode | SOAP_IO_LENGTH | SOAP_ENC_DIME; - else -#endif - { soap->mode = soap->omode; - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE - || (((soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_ENC_XML)) && !soap->fpreparesend)) - soap->mode &= ~SOAP_IO_LENGTH; - else - soap->mode |= SOAP_IO_LENGTH; - } - if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH) - { if (!(soap->mode & SOAP_ENC_DIME)) - soap->mode &= ~SOAP_IO_LENGTH; - if (soap->mode & SOAP_ENC_XML) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - if (!soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH)) - soap->mode |= SOAP_XML_TREE; -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_MIME) - soap_select_mime_boundary(soap); - soap->dime.list = soap->dime.last; /* keep track of last DIME attachment */ -#endif - soap->count = 0; - soap->ns = 0; - soap->null = 0; - soap->position = 0; - soap->mustUnderstand = 0; - soap->encoding = 0; - soap->part = SOAP_BEGIN; - soap->idnum = 0; - soap->dime.count = 0; /* count # of attachments */ - soap->dime.size = 0; /* accumulate total size of attachments */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin count phase (socket=%d mode=%x count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count)); - if (soap->fprepareinit && (soap->mode & SOAP_IO) != SOAP_IO_STORE) - soap->fprepareinit(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_begin_send(struct soap *soap) -{ soap->error = SOAP_OK; - soap_clr_attr(soap); - soap_set_local_namespaces(soap); - soap->mode = (soap->omode & ~SOAP_IO_LENGTH) | (soap->mode & SOAP_ENC_DIME); - if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH) - { if (soap->mode & SOAP_ENC_XML) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_FLUSH && soap_valid_socket(soap->socket)) - { if (soap->count || (soap->mode & SOAP_ENC_XML)) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - soap_new_block(soap); - if (!(soap->mode & SOAP_IO_KEEPALIVE)) - soap->keep_alive = 0; - if (!soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH)) - soap->mode |= SOAP_XML_TREE; -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_MIME) - soap_select_mime_boundary(soap); -#endif -#ifdef WIN32 -#ifndef UNDER_CE -#ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket)) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */ -#ifdef __BORLANDC__ - setmode((SOAP_SOCKET)soap->sendfd, O_BINARY); -#else - _setmode((SOAP_SOCKET)soap->sendfd, _O_BINARY); -#endif -#endif -#endif -#endif - if (soap->mode & SOAP_IO) - { soap->bufidx = 0; - soap->buflen = 0; - } - soap->chunksize = 0; - soap->ns = 0; - soap->null = 0; - soap->position = 0; - soap->mustUnderstand = 0; - soap->encoding = 0; - soap->part = SOAP_BEGIN; - soap->idnum = 0; - soap->level = 0; -#ifdef WITH_ZLIB - soap->z_ratio_out = 1.0; - if ((soap->mode & SOAP_ENC_ZLIB) && soap->zlib_state != SOAP_ZLIB_DEFLATE) - { -#ifdef WITH_GZIP - memcpy(soap->z_buf, "\37\213\10\0\0\0\0\0\0\377", 10); - soap->d_stream.next_out = (Byte*)soap->z_buf + 10; - soap->d_stream.avail_out = SOAP_BUFLEN - 10; - soap->z_crc = crc32(0L, NULL, 0); - if (deflateInit2(&soap->d_stream, soap->z_level, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK) -#else - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - if (deflateInit(&soap->d_stream, soap->z_level) != Z_OK) -#endif - return soap->error = SOAP_ZLIB_ERROR; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflate initialized\n")); - soap->zlib_state = SOAP_ZLIB_DEFLATE; - } -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin send phase (socket=%d mode=%x count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count)); - if (soap->fprepareinit && (soap->mode & SOAP_IO) == SOAP_IO_STORE) - soap->fprepareinit(soap); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_embedded(struct soap *soap, const void *p, int t) -{ struct soap_plist *pp; - if (soap_pointer_lookup(soap, p, t, &pp)) - { pp->mark1 = 1; - pp->mark2 = 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded %p type=%d mark set to 1\n", p, t)); - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_reference(struct soap *soap, const void *p, int t) -{ struct soap_plist *pp; - if (!p || (soap->mode & SOAP_XML_TREE)) - return 1; - if (soap_pointer_lookup(soap, p, t, &pp)) - { if (pp->mark1 == 0) - { pp->mark1 = 2; - pp->mark2 = 2; - } - } - else if (soap_pointer_enter(soap, p, NULL, 0, t, &pp)) - { pp->mark1 = 0; - pp->mark2 = 0; - } - else - return 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reference %p type=%d (%d %d)\n", p, t, (int)pp->mark1, (int)pp->mark2)); - return pp->mark1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_reference(struct soap *soap, const void *p, const struct soap_array *a, int n, int t) -{ register int i; - struct soap_plist *pp; - if (!p) - return 1; - i = soap_array_pointer_lookup(soap, p, a, n, t, &pp); - if (i) - { if (pp->mark1 == 0) - { pp->mark1 = 2; - pp->mark2 = 2; - } - } - else if (!soap_pointer_enter(soap, p, a, n, t, &pp)) - return 1; - else - { pp->mark1 = 0; - pp->mark2 = 0; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array reference %p ptr=%p dim=%d type=%d (%d %d)\n", p, a->__ptr, n, t, (int)pp->mark1, (int)pp->mark2)); - return pp->mark1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_embedded_id(struct soap *soap, int id, const void *p, int t) -{ struct soap_plist *pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id %p type=%d id=%d\n", p, t, id)); - if (soap->mode & SOAP_XML_TREE) - return id; - if (soap->version == 1 && soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH) && soap->part != SOAP_IN_HEADER) - { if (id < 0) - { id = soap_pointer_lookup(soap, p, t, &pp); - if (id) - { if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 2; - else - pp->mark2 = 2; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id multiref id=%d %p type=%d = (%d %d)\n", id, p, t, (int)pp->mark1, (int)pp->mark2)); - } - return -1; - } - return id; - } - if (id < 0) - id = soap_pointer_lookup(soap, p, t, &pp); - else if (id && !soap_pointer_lookup(soap, p, t, &pp)) - return 0; - if (id && pp) - { if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 1; - else - pp->mark2 = 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id embedded ref id=%d %p type=%d = (%d %d)\n", id, p, t, (int)pp->mark1, (int)pp->mark2)); - } - return id; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_is_embedded(struct soap *soap, struct soap_plist *pp) -{ if (!pp) - return 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Is embedded? %d %d\n", (int)pp->mark1, (int)pp->mark2)); - if (soap->version == 1 && soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH) && soap->part != SOAP_IN_HEADER) - { if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 != 0; - return pp->mark2 != 0; - } - if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 == 1; - return pp->mark2 == 1; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_is_single(struct soap *soap, struct soap_plist *pp) -{ if (soap->part == SOAP_IN_HEADER) - return 1; - if (!pp) - return 0; - if (soap->mode & SOAP_IO_LENGTH) - return pp->mark1 == 0; - return pp->mark2 == 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_embedded(struct soap *soap, struct soap_plist *pp) -{ if (!pp) - return; - if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 1; - else - pp->mark2 = 1; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_dime(struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, const char *aid, const char *atype, const char *aoptions, int n, const char *type, int t) -{ struct soap_plist *pp; - if (!p || !a->__ptr || (!aid && !atype)) - return soap_element_id(soap, tag, id, p, a, n, type, t); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attachment tag='%s' id='%s' (%d) type='%s'\n", tag, aid?aid:"", id, atype?atype:"")); - if (id < 0) - id = soap_array_pointer_lookup(soap, p, a, n, t, &pp); - if (!aid) - { sprintf(soap->tmpbuf, soap->dime_id_format, id); - aid = soap_strdup(soap, soap->tmpbuf); - } - if (soap_element_href(soap, tag, 0, "href", aid)) - return soap->error; - if (soap->mode & SOAP_IO_LENGTH) - { if (pp->mark1 != 3) - { struct soap_multipart *content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, (char*)a->__ptr, a->__size); - if (!content) - return soap->error = SOAP_EOM; - content->id = aid; - content->type = atype; - content->options = aoptions; - pp->mark1 = 3; - } - } - else - pp->mark2 = 3; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_init_iht(struct soap *soap) -{ register int i; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing ID hashtable\n")); - for (i = 0; i < SOAP_IDHASH; i++) - soap->iht[i] = NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_free_iht(struct soap *soap) -{ register int i; - register struct soap_ilist *ip, *p; - register struct soap_flist *fp, *fq; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free ID hashtable\n")); - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = p) - { for (fp = ip->flist; fp; fp = fq) - { fq = fp->next; - SOAP_FREE(fp); - } - p = ip->next; - SOAP_FREE(ip); - } - soap->iht[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static struct soap_ilist * -soap_hlookup(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - for (ip = soap->iht[soap_hash(id)]; ip; ip = ip->next) - if (!strcmp(ip->id, id)) - return ip; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_ilist * -SOAP_FMAC2 -soap_lookup(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - ip = soap_hlookup(soap, id); -#ifndef WITH_LEANER - if (!ip && *id != '#' && !strchr(id, ':')) /* try content id "cid:" with DIME attachments */ - { char cid[SOAP_TAGLEN]; - strcpy(cid, "cid:"); - strncat(cid + 4, id, sizeof(cid) - 5); - cid[sizeof(cid) - 1] = '\0'; - ip = soap_hlookup(soap, cid); - } -#endif - return ip; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_ilist * -SOAP_FMAC2 -soap_enter(struct soap *soap, const char *id) -{ register size_t h; - register struct soap_ilist *ip; - ip = (struct soap_ilist*)SOAP_MALLOC(sizeof(struct soap_ilist) + strlen(id)); - if (ip) - { h = soap_hash(id); - strcpy(ip->id, id); - ip->next = soap->iht[h]; - soap->iht[h] = ip; - return ip; - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_malloc(struct soap *soap, size_t n) -{ register char *p; - if (!n) - return NULL; - if (!soap) - return SOAP_MALLOC(n); - n += (-(long)n) & 7; - if (!(p = (char*)SOAP_MALLOC(n + sizeof(void*) + sizeof(size_t)))) - { soap->error = SOAP_EOM; - return NULL; - } - /* keep chain of alloced cells for later destruction */ - soap->alloced = 1; - *(void**)(p + n) = soap->alist; - *(size_t*)(p + n + sizeof(void*)) = n; - soap->alist = p + n; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Malloc %u bytes at location %p\n", (unsigned int)n, p)); - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_dealloc(struct soap *soap, void *p) -{ if (!soap) - return; - if (p) - { register char **q; - for (q = (char**)&soap->alist; *q; q = *(char***)q) - { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*)))) - { *q = **(char***)q; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Freed data at %p\n", p)); - SOAP_FREE(p); - return; - } - } - soap_delete(soap, p); - } - else - { register char *q; - while (soap->alist) - { q = (char*)soap->alist; - soap->alist = *(void**)q; - q -= *(size_t*)(q + sizeof(void*)); - SOAP_FREE(q); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Dealloc all data done\n")); - } - /* we must assume these were deallocated: */ - soap->action = NULL; - soap->fault = NULL; - soap->header = NULL; - soap->authrealm = NULL; -#ifndef WITH_LEANER - soap_clr_mime(soap); -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_delete(struct soap *soap, void *p) -{ register struct soap_clist **cp = &soap->clist; - if (p) - { while (*cp) - { if (p == (*cp)->ptr) - { register struct soap_clist *q = *cp; - *cp = q->next; - q->fdelete(q); - SOAP_FREE(q); - return; - } - cp = &(*cp)->next; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not dealloc data %p: address not in list\n", p)); - } - else - { while (*cp) - { register struct soap_clist *q = *cp; - *cp = q->next; - if (q->ptr == (void*)soap->fault) - soap->fault = NULL; /* this was deallocated */ - else if (q->ptr == (void*)soap->header) - soap->header = NULL; /* this was deallocated */ - q->fdelete(q); - SOAP_FREE(q); - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -struct soap_clist * -SOAP_FMAC2 -soap_link(struct soap *soap, void *p, int t, int n, void (*fdelete)(struct soap_clist*)) -{ register struct soap_clist *cp; - if ((cp = (struct soap_clist*)SOAP_MALLOC(sizeof(struct soap_clist)))) - { cp->next = soap->clist; - cp->type = t; - cp->size = n; - cp->ptr = p; - cp->fdelete = fdelete; - soap->clist = cp; - } - return cp; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_unlink(struct soap *soap, const void *p) -{ register char **q; - register struct soap_clist **cp; - if (!soap || !p) - return; - for (q = (char**)&soap->alist; *q; q = *(char***)q) - { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*)))) - { *q = **(char***)q; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked data %p\n", p)); - return; - } - } - for (cp = &soap->clist; *cp; cp = &(*cp)->next) - { if (p == (*cp)->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked class instance %p\n", p)); - q = (char**)*cp; - *cp = (*cp)->next; - SOAP_FREE(q); - return; - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_lookup_type(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; - if (id && *id) - { ip = soap_lookup(soap, id); - if (ip) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup id='%s' type=%d\n", id, ip->type)); - return ip->type; - } - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "lookup type id='%s' NOT FOUND! Need to get it from xsi:type\n", id)); - return 0; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_lookup(struct soap *soap, const char *id, void **p, int t, size_t n, unsigned int k) -{ struct soap_ilist *ip; - void **q; - if (!id || !*id) - return p; - soap->alloced = 0; - if (!p) - p = (void**)soap_malloc(soap, sizeof(void*)); - ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */ - if (!ip) - { ip = soap_enter(soap, id); /* new hash table entry for string id */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding first href='%s' type=%d %p (%u bytes)\n", id, t, p, (unsigned int)n)); - ip->type = t; - ip->size = n; - ip->link = p; - ip->copy = NULL; - ip->flist = NULL; - ip->ptr = NULL; - ip->level = k; - *p = NULL; - } - else if (ip->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolved href='%s' type=%d location=%p (%u bytes)\n", id, t, ip->ptr, (unsigned int)n)); - if (ip->type != t) - { strcpy(soap->id, id); - soap->error = SOAP_HREF; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility: id type=%d href type=%d\n", ip->type, t)); - return NULL; - } - while (ip->level < k) - { q = (void**)soap_malloc(soap, sizeof(void*)); - if (!q) - return NULL; - *p = (void*)q; - p = q; - k--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - *p = ip->ptr; - } - else if (ip->level > k) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving level %u pointers to href='%s'\n", ip->level, id)); - while (ip->level > k) - { void *s, **r = &ip->link; - q = (void**)ip->link; - while (q) - { *r = (void*)soap_malloc(soap, sizeof(void*)); - s = *q; - *q = *r; - r = (void**)*r; - q = (void**)s; - } - *r = NULL; - ip->size = n; - ip->copy = NULL; - ip->level = ip->level - 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - q = (void**)ip->link; - ip->link = p; - *p = (void*)q; - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarded href='%s' type=%d location=%p (%u bytes)\n", id, t, p, (unsigned int)n)); - while (ip->level < k) - { q = (void**)soap_malloc(soap, sizeof(void*)); - *p = q; - p = q; - k--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); - } - q = (void**)ip->link; - ip->link = p; - *p = (void*)q; - } - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_forward(struct soap *soap, const char *href, void *p, int st, int tt, size_t n, unsigned int k, void (*fcopy)(struct soap*, int, int, void*, const void*, size_t)) -{ struct soap_ilist *ip; - if (!p || !href || !*href) - return p; - ip = soap_lookup(soap, href); /* lookup pointer to hash table entry for string id */ - if (!ip) - { ip = soap_enter(soap, href); /* new hash table entry for string id */ - ip->type = st; - ip->size = n; - ip->link = NULL; - ip->copy = NULL; - ip->ptr = NULL; - ip->level = 0; - ip->flist = NULL; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "New entry href='%s' type=%d size=%lu level=%d location=%p\n", href, st, (unsigned long)n, k, p)); - } - else if (ip->type != st || (ip->level == k && ip->size != n)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility id='%s' expect type=%d size=%lu level=%u got type=%d size=%lu\n", href, ip->type, (unsigned long)ip->size, k, st, (unsigned long)n)); - strcpy(soap->id, href); - soap->error = SOAP_HREF; - return NULL; - } - if (fcopy || n < sizeof(void*) || *href != '#') - { register struct soap_flist *fp = (struct soap_flist*)SOAP_MALLOC(sizeof(struct soap_flist)); - if (!fp) - { soap->error = SOAP_EOM; - return NULL; - } - fp->next = ip->flist; - fp->type = tt; - fp->ptr = p; - fp->level = k; - if (fcopy) - fp->fcopy = fcopy; - else - fp->fcopy = soap_fcopy; - ip->flist = fp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding type=%d (target type=%d) size=%lu location=%p level=%u href='%s'\n", st, tt, (unsigned long)n, p, k, href)); - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding copying address %p for type=%d href='%s'\n", p, st, href)); - *(void**)p = ip->copy; - ip->copy = p; - } - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void* -SOAP_FMAC2 -soap_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, unsigned int k, const char *type, const char *arrayType, void *(*finstantiate)(struct soap*, int, const char*, const char*, size_t*)) -{ struct soap_ilist *ip; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Enter id='%s' type=%d loc=%p size=%lu level=%u\n", id, t, p, (unsigned long)n, k)); - soap->alloced = 0; - if (!p) - { if (finstantiate) - p = finstantiate(soap, t, type, arrayType, &n); - else - p = soap_malloc(soap, n); - if (p) - soap->alloced = 1; - } - if (!id || !*id) - return p; - ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */ - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Lookup entry id='%s for location=%p'\n", id, p)); - if (!ip) - { ip = soap_enter(soap, id); /* new hash table entry for string id */ - ip->type = t; - ip->link = NULL; - ip->copy = NULL; - ip->flist = NULL; - ip->size = n; - ip->ptr = p; - ip->level = k; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "New entry id='%s' type=%d size=%lu level=%u location=%p\n", id, t, (unsigned long)n, k, p)); - } - else if ((ip->type != t || (ip->level == k && ip->size != n)) && (ip->copy || ip->flist)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility id='%s' expect type=%d size=%lu level=%u got type=%d size=%lu\n", id, ip->type, (unsigned long)ip->size, k, t, (unsigned long)n)); - strcpy(soap->id, id); - soap->error = SOAP_HREF; - return NULL; - } - else if (ip->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Multiply defined id='%s'\n", id)); - strcpy(soap->id, id); - soap->error = SOAP_MULTI_ID; - return NULL; - } - else - { ip->size = n; - ip->ptr = p; - ip->level = k; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update entry id='%s' type=%d location=%p size=%lu level=%u\n", id, t, p, (unsigned long)n, k)); - } - return ip->ptr; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_fcopy(struct soap *soap, int st, int tt, void *p, const void *q, size_t n) -{ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Copying data type=%d (target type=%d) %p -> %p (%lu bytes)\n", st, tt, q, p, (unsigned long)n)); - memcpy(p, q, n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_end_send(struct soap *soap) -{ -#ifndef WITH_LEANER - if (soap->dime.list) - { /* SOAP body referenced attachments must appear first */ - soap->dime.last->next = soap->dime.first; - soap->dime.first = soap->dime.list->next; - soap->dime.list->next = NULL; - soap->dime.last = soap->dime.list; - } - if (soap_putdime(soap) || soap_putmime(soap)) - return soap->error; - soap->mime.list = NULL; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->dime.list = NULL; - soap->dime.first = NULL; - soap->dime.last = NULL; -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End send\n")); - if (soap->mode & SOAP_IO) /* need to flush the remaining data in buffer */ - { if (soap_flush(soap)) -#ifdef WITH_ZLIB - { if (soap->mode & SOAP_ENC_ZLIB && soap->zlib_state == SOAP_ZLIB_DEFLATE) - { soap->zlib_state = SOAP_ZLIB_NONE; - deflateEnd(&soap->d_stream); - } - return soap->error; - } -#else - return soap->error; -#endif -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { int r; - soap->d_stream.avail_in = 0; - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating remainder\n")); - r = deflate(&soap->d_stream, Z_FINISH); - if (soap->d_stream.avail_out != SOAP_BUFLEN) - { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN - soap->d_stream.avail_out)) - { soap->zlib_state = SOAP_ZLIB_NONE; - deflateEnd(&soap->d_stream); - return soap->error; - } - soap->d_stream.next_out = (Byte*)soap->z_buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - } - } while (r == Z_OK); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflated %lu->%lu bytes\n", soap->d_stream.total_in, soap->d_stream.total_out)); - soap->z_ratio_out = (float)soap->d_stream.total_out / (float)soap->d_stream.total_in; - soap->mode &= ~SOAP_ENC_ZLIB; - soap->zlib_state = SOAP_ZLIB_NONE; - if (deflateEnd(&soap->d_stream) != Z_OK || r != Z_STREAM_END) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to end deflate: %s\n", soap->d_stream.msg?soap->d_stream.msg:"")); - return soap->error = SOAP_ZLIB_ERROR; - } -#ifdef WITH_GZIP - soap->z_buf[0] = soap->z_crc & 0xFF; - soap->z_buf[1] = (soap->z_crc >> 8) & 0xFF; - soap->z_buf[2] = (soap->z_crc >> 16) & 0xFF; - soap->z_buf[3] = (soap->z_crc >> 24) & 0xFF; - soap->z_buf[4] = soap->d_stream.total_in & 0xFF; - soap->z_buf[5] = (soap->d_stream.total_in >> 8) & 0xFF; - soap->z_buf[6] = (soap->d_stream.total_in >> 16) & 0xFF; - soap->z_buf[7] = (soap->d_stream.total_in >> 24) & 0xFF; - if (soap_flush_raw(soap, soap->z_buf, 8)) - return soap->error; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip crc32=%lu\n", (unsigned long)soap->z_crc)); -#endif - } -#endif - if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - { char *p; - if (!(soap->mode & SOAP_ENC_XML)) - { soap->mode--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending buffered message of length %u\n", (unsigned int)soap->blist->size)); - if (soap->status >= SOAP_POST) - soap->error = soap->fpost(soap, soap->endpoint, soap->host, soap->port, soap->path, soap->action, soap->blist->size); - else if (soap->status != SOAP_STOP) - soap->error = soap->fresponse(soap, soap->status, soap->blist->size); - if (soap->error || soap_flush(soap)) - return soap->error; - soap->mode++; - } - for (p = soap_first_block(soap); p; p = soap_next_block(soap)) - { DBGMSG(SENT, p, soap_block_size(soap)); - if ((soap->error = soap->fsend(soap, p, soap_block_size(soap)))) - { soap_end_block(soap); - return soap->error; - } - } - soap_end_block(soap); - } - else if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { DBGMSG(SENT, "\r\n0\r\n\r\n", 7); - if ((soap->error = soap->fsend(soap, "\r\n0\r\n\r\n", 7))) - return soap->error; - } - } -#ifdef WITH_OPENSSL - if (!soap->ssl && soap_valid_socket(soap->socket) && !soap->keep_alive) - soap->fshutdownsocket(soap, (SOAP_SOCKET)soap->socket, 1); /* Send TCP FIN */ -#else - if (soap_valid_socket(soap->socket) && !soap->keep_alive) - soap->fshutdownsocket(soap, (SOAP_SOCKET)soap->socket, 1); /* Send TCP FIN */ -#endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of send message ok\n")); - soap->part = SOAP_END; - soap->count = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_end_recv(struct soap *soap) -{ soap->part = SOAP_END; -#ifndef WITH_LEANER - if ((soap->mode & SOAP_ENC_MIME) && soap_getmime(soap)) - return soap->error; - soap->mime.list = soap->mime.first; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->dime.list = soap->dime.first; - soap->dime.first = NULL; - soap->dime.last = NULL; -#endif - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "End of receive message ok\n")); -#ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) - { soap->mode &= ~SOAP_ENC_ZLIB; - memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN); - soap->bufidx = (char*)soap->d_stream.next_in - soap->z_buf; - soap->buflen = soap->z_buflen; - soap->zlib_state = SOAP_ZLIB_NONE; - if (inflateEnd(&soap->d_stream) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; -#ifdef WITH_GZIP - if (soap->zlib_in == SOAP_ZLIB_GZIP) - { soap_wchar c; - short i; - for (i = 0; i < 8; i++) - { if ((int)(c = soap_getchar(soap)) == EOF) - return soap->error = SOAP_EOF; - soap->z_buf[i] = (char)c; - } - if (soap->z_crc != ((uLong)(unsigned char)soap->z_buf[0] | ((uLong)(unsigned char)soap->z_buf[1] << 8) | ((uLong)(unsigned char)soap->z_buf[2] << 16) | ((uLong)(unsigned char)soap->z_buf[3] << 24))) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: crc check failed, message corrupted? (crc32=%lu)\n", (unsigned long)soap->z_crc)); - return soap->error = SOAP_ZLIB_ERROR; - } - if (soap->d_stream.total_out != ((uLong)(unsigned char)soap->z_buf[4] | ((uLong)(unsigned char)soap->z_buf[5] << 8) | ((uLong)(unsigned char)soap->z_buf[6] << 16) | ((uLong)(unsigned char)soap->z_buf[7] << 24))) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: incorrect message length\n")); - return soap->error = SOAP_ZLIB_ERROR; - } - } -#endif - } -#endif - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - while ((int)soap_getchar(soap) != EOF) /* advance to last chunk */ - ; - if (soap->fdisconnect && (soap->error = soap->fdisconnect(soap))) - return soap->error; - return soap_resolve(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_free(struct soap *soap) -{ register struct soap_nlist *np; - register struct soap_attribute *tp; - register struct Namespace *ns; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free namespace stack\n")); - while (soap->nlist) - { np = soap->nlist->next; - if (soap->nlist->ns) - SOAP_FREE(soap->nlist->ns); - SOAP_FREE(soap->nlist); - soap->nlist = np; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free any remaining temp blocks\n")); - while (soap->blist) - soap_end_block(soap); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free attributes\n")); - while (soap->attributes) - { tp = soap->attributes->next; - if (soap->attributes->value) - SOAP_FREE(soap->attributes->value); - SOAP_FREE(soap->attributes); - soap->attributes = tp; - } -#ifdef WITH_FAST - if (soap->labbuf) - SOAP_FREE(soap->labbuf); - soap->labbuf = NULL; - soap->lablen = 0; - soap->labidx = 0; -#endif - soap_free_pht(soap); - soap_free_iht(soap); - ns = soap->local_namespaces; - if (ns) - { for (; ns->id; ns++) - { if (ns->out) - { SOAP_FREE(ns->out); - if (soap->encodingStyle == ns->out) - soap->encodingStyle = SOAP_STR_EOS; - ns->out = NULL; - } - if (soap->encodingStyle == ns->ns) - soap->encodingStyle = SOAP_STR_EOS; - } - SOAP_FREE(soap->local_namespaces); - soap->local_namespaces = NULL; - } -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -static void -soap_init_logs(struct soap *soap) -{ int i; - for (i = 0; i < SOAP_MAXLOGS; i++) - { soap->logfile[i] = NULL; - soap->fdebug[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#if !defined(WITH_LEAN) || defined(SOAP_DEBUG) -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_open_logfile(struct soap *soap, int i) -{ if (soap->logfile[i]) - soap->fdebug[i] = fopen(soap->logfile[i], i < 2 ? "ab" : "a"); -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -static void -soap_close_logfile(struct soap *soap, int i) -{ if (soap->fdebug[i]) - { fclose(soap->fdebug[i]); - soap->fdebug[i] = NULL; - } -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_close_logfiles(struct soap *soap) -{ int i; - for (i = 0; i < SOAP_MAXLOGS; i++) - soap_close_logfile(soap, i); -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -static void -soap_set_logfile(struct soap *soap, int i, const char *logfile) -{ char *s = NULL; - soap_close_logfile(soap, i); - if (soap->logfile[i]) - SOAP_FREE((void*)soap->logfile[i]); - if (logfile) - if ((s = (char*)SOAP_MALLOC(strlen(logfile) + 1))) - strcpy(s, logfile); - soap->logfile[i] = s; -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_recv_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_RECV, logfile); -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_sent_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_SENT, logfile); -} -#endif - -/******************************************************************************/ -#ifdef SOAP_DEBUG -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_test_logfile(struct soap *soap, const char *logfile) -{ soap_set_logfile(soap, SOAP_INDEX_TEST, logfile); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_copy(struct soap *soap) -{ return soap_copy_context((struct soap*)SOAP_MALLOC(sizeof(struct soap)), soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -struct soap* -SOAP_FMAC2 -soap_copy_context(struct soap *copy, struct soap *soap) -{ if (copy) - { register struct soap_plugin *p; - memcpy(copy, soap, sizeof(struct soap)); - copy->copy = 1; - copy->user = NULL; - copy->userid = NULL; - copy->passwd = NULL; - copy->nlist = NULL; - copy->blist = NULL; - copy->clist = NULL; - copy->alist = NULL; - copy->attributes = NULL; - copy->local_namespaces = NULL; - soap_set_local_namespaces(copy); - soap_init_iht(copy); - soap_init_pht(copy); - copy->header = NULL; - copy->fault = NULL; - copy->action = NULL; - *copy->host = '\0'; -#ifndef WITH_LEAN -#ifdef WITH_COOKIES - copy->cookies = soap_copy_cookies(soap); -#else - copy->cookies = NULL; -#endif -#endif -#ifdef SOAP_DEBUG - soap_init_logs(copy); - soap_set_recv_logfile(copy, "RECV.log"); - soap_set_sent_logfile(copy, "SENT.log"); - soap_set_test_logfile(copy, "TEST.log"); -#endif - copy->plugins = NULL; - for (p = soap->plugins; p; p = p->next) - { register struct soap_plugin *q = (struct soap_plugin*)SOAP_MALLOC(sizeof(struct soap_plugin)); - if (!q) - return NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying plugin '%s'\n", p->id)); - *q = *p; - if (p->fcopy && (soap->error = p->fcopy(soap, q, p))) - { SOAP_FREE(q); - return NULL; - } - q->next = copy->plugins; - copy->plugins = q; - } - } - else - soap->error = SOAP_EOM; - return copy; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init(struct soap *soap) -{ soap->version = 0; - soap_imode(soap, SOAP_IO_DEFAULT); - soap_omode(soap, SOAP_IO_DEFAULT); - soap->copy = 0; - soap->plugins = NULL; - soap->user = NULL; - soap->userid = NULL; - soap->passwd = NULL; - soap->fpost = http_post; - soap->fget = http_get; - soap->fposthdr = http_post_header; - soap->fresponse = http_response; - soap->fparse = http_parse; - soap->fparsehdr = http_parse_header; - soap->fconnect = NULL; - soap->fdisconnect = NULL; -#ifndef MAC_CARBON -#ifndef WITH_IPV6 - soap->fresolve = tcp_gethost; -#else - soap->fresolve = NULL; -#endif - soap->faccept = tcp_accept; - soap->fopen = tcp_connect; - soap->fclose = tcp_disconnect; - soap->fclosesocket = tcp_closesocket; - soap->fshutdownsocket = tcp_shutdownsocket; - soap->fsend = fsend; - soap->frecv = frecv; - soap->fpoll = soap_poll; -#else - soap->fpoll = NULL; -#endif - soap->fprepareinit = NULL; - soap->fpreparesend = NULL; - soap->fpreparerecv = NULL; - soap->fignore = NULL; - soap->fserveloop = NULL; - soap->fplugin = fplugin; - soap->fdimereadopen = NULL; - soap->fdimewriteopen = NULL; - soap->fdimereadclose = NULL; - soap->fdimewriteclose = NULL; - soap->fdimeread = NULL; - soap->fdimewrite = NULL; - soap->float_format = "%.8g"; /* .8 preserves single FP precision as much as possible, but might not be very efficient */ - soap->double_format = "%.17lg"; /* .17 preserves double FP precision as much as possible, but might not be very efficient */ - soap->dime_id_format = "cid:id%d"; /* default DIME id format */ - soap->http_version = "1.1"; - soap->actor = NULL; - soap->max_keep_alive = SOAP_MAXKEEPALIVE; - soap->keep_alive = 0; - soap->recv_timeout = 0; - soap->send_timeout = 0; - soap->connect_timeout = 0; - soap->accept_timeout = 0; - soap->socket_flags = 0; - soap->connect_flags = 0; - soap->bind_flags = 0; - soap->accept_flags = 0; - soap->ip = 0; - soap->labbuf = NULL; - soap->lablen = 0; - soap->labidx = 0; - soap->encodingStyle = SOAP_STR_EOS; -#ifndef WITH_NONAMESPACES - soap->namespaces = namespaces; -#else - soap->namespaces = NULL; -#endif - soap->local_namespaces = NULL; - soap->nlist = NULL; - soap->blist = NULL; - soap->clist = NULL; - soap->alist = NULL; - soap->attributes = NULL; - soap->header = NULL; - soap->fault = NULL; - soap->master = SOAP_INVALID_SOCKET; - soap->socket = SOAP_INVALID_SOCKET; - soap->os = NULL; - soap->is = NULL; - soap->dom = NULL; - soap->dime.list = NULL; - soap->dime.first = NULL; - soap->dime.last = NULL; - soap->mime.list = NULL; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->mime.boundary = NULL; - soap->mime.start = NULL; -#ifndef UNDER_CE - soap->recvfd = 0; - soap->sendfd = 1; -#else - soap->recvfd = stdin; - soap->sendfd = stdout; -#endif - soap->host[0] = '\0'; - soap->port = 0; - soap->action = NULL; - soap->proxy_host = NULL; - soap->proxy_port = 8080; - soap->proxy_userid = NULL; - soap->proxy_passwd = NULL; - soap->authrealm = NULL; - soap->prolog = NULL; -#ifdef WITH_OPENSSL - soap->fsslauth = ssl_auth_init; - soap->fsslverify = ssl_verify_callback; - soap->bio = NULL; - soap->ssl = NULL; - soap->ctx = NULL; - soap->require_server_auth = 0; - soap->require_client_auth = 0; - soap->rsa = 0; - soap->keyfile = NULL; - soap->password = NULL; - soap->dhfile = NULL; - soap->cafile = NULL; - soap->capath = NULL; - soap->randfile = NULL; - soap->session = NULL; -#endif -#ifdef WITH_ZLIB - soap->zlib_state = SOAP_ZLIB_NONE; - soap->zlib_in = SOAP_ZLIB_NONE; - soap->zlib_out = SOAP_ZLIB_NONE; - soap->d_stream.zalloc = NULL; - soap->d_stream.zfree = NULL; - soap->d_stream.opaque = NULL; - soap->z_level = 6; -#endif -#ifndef WITH_LEAN - soap->cookies = NULL; - soap->cookie_domain = NULL; - soap->cookie_path = NULL; - soap->cookie_max = 32; -#endif -#ifdef SOAP_DEBUG - soap_init_logs(soap); - soap_set_recv_logfile(soap, "RECV.log"); - soap_set_sent_logfile(soap, "SENT.log"); - soap_set_test_logfile(soap, NULL); -#endif -/* WR[ */ -#ifdef WMW_RPM_IO - soap->rpmreqid = NULL; -#endif /* WMW_RPM_IO */ -/* ]WR */ -#ifdef PALM - palmNetLibOpen(); -#endif - soap_init_iht(soap); - soap_init_pht(soap); - soap_begin(soap); -#ifdef SOAP_DEBUG - soap_set_test_logfile(soap, "TEST.log"); -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init1(struct soap *soap, int mode) -{ soap_init2(soap, mode, mode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_init2(struct soap *soap, int imode, int omode) -{ soap_init(soap); - soap_imode(soap, imode); - soap_omode(soap, omode); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_begin(struct soap *soap) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing\n")); - if (!soap->keep_alive) - { soap->buflen = 0; - soap->bufidx = 0; - } - soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0); - soap->null = 0; - soap->position = 0; - soap->encoding = 0; - soap->mustUnderstand = 0; - soap->mode = 0; - soap->ns = 0; - soap->part = SOAP_BEGIN; - soap->alloced = 0; - soap->count = 0; - soap->length = 0; - soap->cdata = 0; - soap->error = SOAP_OK; - soap->peeked = 0; - soap->ahead = 0; - soap->idnum = 0; - soap->level = 0; - soap->endpoint[0] = '\0'; - soap->dime.chunksize = 0; - soap->dime.buflen = 0; - soap_free(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_end(struct soap *soap) -{ register struct soap_clist *cp; - soap_free(soap); - soap_dealloc(soap, NULL); - while (soap->clist) - { cp = soap->clist->next; - SOAP_FREE(soap->clist); - soap->clist = cp; - } - soap_closesock(soap); -#ifdef SOAP_DEBUG - soap_close_logfiles(soap); -#endif -#ifdef PALM - palmNetLibClose(); -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_namespaces(struct soap *soap, struct Namespace *p) -{ struct Namespace *ns = soap->local_namespaces; - struct soap_nlist *np, *nq, *nr; - unsigned int level = soap->level; - soap->namespaces = p; - soap->local_namespaces = NULL; - soap_set_local_namespaces(soap); - /* reverse the list */ - np = soap->nlist; - soap->nlist = NULL; - if (np) - { nq = np->next; - np->next = NULL; - while (nq) - { nr = nq->next; - nq->next = np; - np = nq; - nq = nr; - } - } - while (np) - { soap->level = np->level; /* preserve element nesting level */ - if (np->ns) - { if (soap_push_namespace(soap, np->id, np->ns)) - return soap->error; - } - else if (np->index >= 0 && ns) - { if (ns[np->index].out) - { if (soap_push_namespace(soap, np->id, ns[np->index].out)) - return soap->error; - } - else if (soap_push_namespace(soap, np->id, ns[np->index].ns)) - return soap->error; - } - if (np->ns) - SOAP_FREE(np->ns); - nq = np; - np = np->next; - SOAP_FREE(nq); - } - if (ns) - { int i; - for (i = 0; ns[i].id; i++) - { if (ns[i].out) - { SOAP_FREE(ns[i].out); - ns[i].out = NULL; - } - } - SOAP_FREE(ns); - } - soap->level = level; /* restore level */ - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void -soap_set_local_namespaces(struct soap *soap) -{ if (soap->namespaces && !soap->local_namespaces) - { register const struct Namespace *ns1; - register struct Namespace *ns2; - register size_t n = 1; - for (ns1 = soap->namespaces; ns1->id; ns1++) - n++; - if (n > 3) - { n *= sizeof(struct Namespace); - ns2 = (struct Namespace*)SOAP_MALLOC(n); - if (ns2) - { memcpy(ns2, soap->namespaces, n); - ns2[0].id = "SOAP-ENV"; - ns2[1].id = "SOAP-ENC"; - ns2[2].id = "xsi"; - if (ns2[0].ns) - { if (!strcmp(ns2[0].ns, soap_env1)) - soap->version = 1; - else - soap->version = 2; - } - soap->local_namespaces = ns2; - } - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element(struct soap *soap, const char *tag, int id, const char *type) -{ struct Namespace *ns = soap->local_namespaces; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element begin tag='%s' id='%d' type='%s'\n", tag, id, type?type:"")); -/**/ -#ifdef WITH_DOM - if (soap->mode & SOAP_XML_DOM) - { register struct soap_dom_element *p, *e = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element)); - e->next = NULL; - e->prnt = soap->dom; - e->nstr = NULL; - e->name = soap_strdup(soap, tag); /* check EOM? */ - e->data = NULL; - e->type = 0; - e->node = NULL; - e->elts = NULL; - e->atts = NULL; - if (soap->dom) - { p = soap->dom->elts; - if (p) - { while (p->next) - p = p->next; - p->next = e; - } - else - soap->dom->elts = e; - } - soap->dom = e; - } - else -#endif -{ - soap->level++; - if (!soap->ns && !(soap->mode & SOAP_XML_CANONICAL)) - if (soap_send(soap, soap->prolog ? soap->prolog : "")) - return soap->error; - if (soap_send_raw(soap, "<", 1) - || soap_send(soap, tag)) - return soap->error; -} -/**/ - if (!soap->ns) - { for (ns = soap->local_namespaces; ns && ns->id; ns++) - { if (*ns->id && (ns->out || ns->ns)) - { sprintf(soap->tmpbuf, "xmlns:%s", ns->id); - if (soap_attribute(soap, soap->tmpbuf, ns->out ? ns->out : ns->ns)) - return soap->error; - } - } - soap->ns = 1; - } - if (id > 0) - { sprintf(soap->tmpbuf, "_%d", id); - if (soap_attribute(soap, "id", soap->tmpbuf)) - return soap->error; - } - if (type && *type) - { if (soap_attribute(soap, "xsi:type", type)) - return soap->error; - } - if (soap->null && soap->position > 0) - { int i; - sprintf(soap->tmpbuf, "[%d", soap->positions[0]); - for (i = 1; i < soap->position; i++) - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), ",%d", soap->positions[i]); - strcat(soap->tmpbuf, "]"); - if (soap_attribute(soap, "SOAP-ENC:position", soap->tmpbuf)) - return soap->error; - } - if (soap->mustUnderstand) - { if (soap->actor && *soap->actor) - { if (soap_attribute(soap, soap->version == 2 ? "SOAP-ENV:role" : "SOAP-ENV:actor", soap->actor)) - return soap->error; - } - if (soap_attribute(soap, "SOAP-ENV:mustUnderstand", soap->version == 2 ? "true" : "1")) - return soap->error; - soap->mustUnderstand = 0; - } - if (soap->encoding) - { if (soap->encodingStyle && soap->local_namespaces) - { if (!*soap->encodingStyle) - { if (soap->local_namespaces[1].out) - soap->encodingStyle = soap->local_namespaces[1].out; - else - soap->encodingStyle = soap->local_namespaces[1].ns; - } - if (soap_attribute(soap, "SOAP-ENV:encodingStyle", soap->encodingStyle)) - return soap->error; - } - soap->encoding = 0; - } - soap->null = 0; - soap->position = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_begin_out(struct soap *soap, const char *tag, int id, const char *type) -{ if (*tag == '-') - return SOAP_OK; - if (soap_element(soap, tag, id, type)) - return soap->error; - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRRCHR -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_strrchr(const char *s, int t) -{ register char *r = NULL; - while (*s) - if (*s++ == t) - r = (char*)s - 1; - return r; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRTOL -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_strtol(const char *s, char **t, int b) -{ register long n = 0; - register int c; - while (*s > 0 && *s <= 32) - s++; - if (b == 10) - { short neg = 0; - if (*s == '-') - { s++; - neg = 1; - } - else if (*s == '+') - s++; - while ((c = *s) && c >= '0' && c <= '9') - { if (n > 214748364) - break; - n *= 10; - n += c - '0'; - s++; - } - if (neg) - n = -n; - } - else /* b == 16 and value is always positive */ - { while ((c = *s)) - { if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'F') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'f') - c -= 'a' - 10; - if (n > 0x07FFFFFF) - break; - n <<= 4; - n += c; - s++; - } - } - if (t) - *t = (char*)s; - return n; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -#ifndef HAVE_STRTOUL -SOAP_FMAC1 -unsigned long -SOAP_FMAC2 -soap_strtoul(const char *s, char **t, int b) -{ unsigned long n = 0; - register int c; - while (*s > 0 && *s <= 32) - s++; - if (b == 10) - { if (*s == '+') - s++; - while ((c = *s) && c >= '0' && c <= '9') - { if (n > 429496729) - break; - n *= 10; - n += c - '0'; - s++; - } - } - else /* b == 16 */ - { while ((c = *s)) - { if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'F') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'f') - c -= 'a' - 10; - if (n > 0x0FFFFFFF) - break; - n <<= 4; - n += c; - s++; - } - } - if (t) - *t = (char*)s; - return n; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_array_begin_out(struct soap *soap, const char *tag, int id, const char *type, const char *offset) -{ if (soap_element(soap, tag, id, "SOAP-ENC:Array")) - return soap->error; - if (soap->version == 2) - { const char *s; - s = soap_strrchr(type, '['); - if ((size_t)(s - type) < sizeof(soap->tmpbuf)) - { strncpy(soap->tmpbuf, type, s - type); - soap->tmpbuf[s - type] = '\0'; - if (type && *type && (soap_attribute(soap, "SOAP-ENC:itemType", soap->tmpbuf))) - return soap->error; - if (s && (soap_attribute(soap, "SOAP-ENC:arraySize", s + 1))) - return soap->error; - } - } - else - { if (offset && (soap_attribute(soap, "SOAP-ENC:offset", offset))) - return soap->error; - if (type && *type && (soap_attribute(soap, "SOAP-ENC:arrayType", type))) - return soap->error; - } - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_start_end_out(struct soap *soap, const char *tag) -{ register struct soap_attribute *tp; -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible) - { register struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); - a->next = soap->dom->atts; - a->nstr = NULL; - a->name = soap_strdup(soap, tp->name); /* check EOM */ - a->data = soap_strdup(soap, tp->value); /* check EOM */ - a->wide = NULL; - soap->dom->atts = a; - tp->visible = 0; - } - } - return SOAP_OK; - } -#endif -/**/ - for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible) - { if (soap_send2(soap, " ", tp->name)) - return soap->error; - if (tp->visible == 2 && tp->value) - if (soap_send_raw(soap, "=\"", 2) - || soap_string_out(soap, tp->value, 1) - || soap_send_raw(soap, "\"", 1)) - return soap->error; - tp->visible = 0; - } - } - if (tag) - { soap->level--; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { if (soap_send_raw(soap, ">", 1) - || soap_element_end_out(soap, tag)) - return soap->error; - return SOAP_OK; - } -#endif - return soap_send_raw(soap, "/>", 2); - } - return soap_send_raw(soap, ">", 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_end_out(struct soap *soap, const char *tag) -{ if (*tag == '-') - return SOAP_OK; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element ending tag='%s'\n", tag)); -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { if (soap->dom->prnt) - soap->dom = soap->dom->prnt; - return SOAP_OK; - } -#endif -/**/ - soap->level--; - if (soap_send_raw(soap, "error; - return soap_send_raw(soap, ">", 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_ref(struct soap *soap, const char *tag, int id, int href) -{ register int n = 0; - if (soap->version == 2) - n = 1; - sprintf(soap->href, "#_%d", href); - return soap_element_href(soap, tag, id, "href" + n, soap->href + n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_href(struct soap *soap, const char *tag, int id, const char *ref, const char *val) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element '%s' reference %s='%s'\n", tag, ref, val)); - if (soap_element(soap, tag, id, NULL) - || soap_attribute(soap, ref, val) - || soap_element_start_end_out(soap, tag)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_null(struct soap *soap, const char *tag, int id, const char *type) -{ struct soap_attribute *tp; - for (tp = soap->attributes; tp; tp = tp->next) - if (tp->visible) - break; - if (tp || (soap->version == 2 && soap->position > 0) || id > 0 || (soap->mode & SOAP_XML_NIL)) - { if (soap_element(soap, tag, id, type)) - return soap->error; - if (soap->part != SOAP_IN_HEADER && soap->encodingStyle) - if (soap_attribute(soap, "xsi:nil", "true")) - return soap->error; - return soap_element_start_end_out(soap, tag); - } - soap->null = 1; - soap->position = 0; - soap->mustUnderstand = 0; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_id(struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, int n, const char *type, int t) -{ struct soap_plist *pp; - if (!p || (a && !a->__ptr)) - { soap_element_null(soap, tag, id, type); - return -1; - } - if (soap->mode & SOAP_XML_TREE) - return 0; - if (id < 0) - { if (a) - id = soap_array_pointer_lookup(soap, p, a, n, t, &pp); - else - id = soap_pointer_lookup(soap, p, t, &pp); - if (id) - { if (soap_is_embedded(soap, pp)) - { soap_element_ref(soap, tag, 0, id); - return -1; - } - if (soap_is_single(soap, pp)) - return 0; - soap_set_embedded(soap, pp); - } - } - return id; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_result(struct soap *soap, const char *tag) -{ if (soap->version == 2 && soap->encodingStyle) - if (soap_element(soap, "SOAP-RPC:result", 0, NULL) - || soap_attribute(soap, "xmlns:SOAP-RPC", soap_rpc) - || soap_element_start_end_out(soap, NULL) - || soap_string_out(soap, tag, 0) - || soap_element_end_out(soap, "SOAP-RPC:result")) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_attribute(struct soap *soap, const char *name, const char *value) -{ -/**/ -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { register struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); - a->next = soap->dom->atts; - a->nstr = NULL; - a->name = soap_strdup(soap, name); /* check EOM */ - a->data = soap_strdup(soap, value); /* check EOM */ - a->wide = NULL; - soap->dom->atts = a; - return SOAP_OK; - } -#endif -/**/ -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { if (soap_set_attr(soap, name, value)) - return soap->error; - } - else -#endif - { if (soap_send2(soap, " ", name)) - return soap->error; - if (value) - if (soap_send_raw(soap, "=\"", 2) - || soap_string_out(soap, value, 1) - || soap_send_raw(soap, "\"", 1)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_begin_in(struct soap *soap, const char *tag, int nillable) -{ if (!soap_peek_element(soap)) - { if (soap->other) - return soap->error = SOAP_TAG_MISMATCH; - if (tag && *tag == '-') - return SOAP_OK; - if (!(soap->error = soap_match_tag(soap, soap->tag, tag))) - { soap->peeked = 0; - if (soap->body) - soap->level++; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:"" )); - if (!nillable && soap->null && (soap->mode & SOAP_XML_STRICT)) - return soap->error = SOAP_NULL; - } - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_element_end_in(struct soap *soap, const char *tag) -{ register soap_wchar c; - register char *s; - register const char *t; - if (tag && *tag == '-') - return SOAP_OK; - soap->level--; - soap_pop_namespace(soap); - if (soap->peeked) - { if (*soap->tag == '\0') - { soap->peeked = 0; - if (soap->error == SOAP_NO_TAG || soap->error == SOAP_TAG_END) - soap->error = SOAP_OK; - } - else - return soap->error = SOAP_TAG_END; - } - else - { while (((c = soap_get(soap)) != SOAP_TT)) - { if ((int)c == EOF) - return soap->error = SOAP_EOF; - if (c == SOAP_LT) - return soap->error = SOAP_TAG_END; - } - } - s = soap->tag; - do c = soap_get(soap); - while (soap_blank(c)); - do - { *s++ = (char)c; - c = soap_get(soap); - } while (soap_notblank(c)); - *s = '\0'; - if ((int)c == EOF) - return soap->error = SOAP_EOF; - while (soap_blank(c)) - c = soap_get(soap); - if (c != SOAP_GT) - return soap->error = SOAP_SYNTAX_ERROR; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:"")); - if (!tag) - return SOAP_OK; - if ((s = strchr(soap->tag, ':'))) - s++; - else - s = soap->tag; - if ((t = strchr(tag, ':'))) - t++; - else - t = tag; - if (!SOAP_STRCMP(s, t)) - return SOAP_OK; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element tag name does not match\n")); - return soap->error = SOAP_SYNTAX_ERROR; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char * -SOAP_FMAC2 -soap_attr_value(struct soap *soap, const char *name, int flag) -{ register struct soap_attribute *tp; - for (tp = soap->attributes; tp; tp = tp->next) - if (!soap_match_tag(soap, tp->name, name)) - break; - if (tp && tp->visible == 2) - { if (flag == 2 && (soap->mode & SOAP_XML_STRICT)) - soap->error = SOAP_PROHIBITED; - else - return tp->value; - } - else if (flag == 1 && (soap->mode & SOAP_XML_STRICT)) - soap->error = SOAP_REQUIRED; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_attr(struct soap *soap, const char *name, const char *value) -{ register struct soap_attribute *tp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set attribute %s='%s'\n", name, value?value:"")); - for (tp = soap->attributes; tp; tp = tp->next) - if (!strcmp(tp->name, name)) - break; - if (!tp) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute %s\n", name)); - if (!(tp = (struct soap_attribute*)SOAP_MALLOC(sizeof(struct soap_attribute) + strlen(name)))) - return soap->error = SOAP_EOM; - tp->ns = NULL; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { struct soap_attribute **tpp = &soap->attributes; - const char *s = strchr(name, ':'); - if (!strncmp(name, "xmlns", 5)) - { for (; *tpp; tpp = &(*tpp)->next) - if (strncmp((*tpp)->name, "xmlns", 5) || strcmp((*tpp)->name + 5, name + 5) > 0) - break; - } - else if (!s) - { for (; *tpp; tpp = &(*tpp)->next) - if (strncmp((*tpp)->name, "xmlns", 5) && ((*tpp)->ns || strcmp((*tpp)->name, name) > 0)) - break; - } - else - { int k; - for (; *tpp; tpp = &(*tpp)->next) - { if (!strncmp((*tpp)->name, "xmlns:", 6) && !strncmp((*tpp)->name + 6, name, s - name) && !(*tpp)->name[6 + s - name]) - { if (!tp->ns) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Canonicalization: prefix %s=%p(%s)\n", name, (*tpp)->ns, (*tpp)->ns)); - tp->ns = (*tpp)->ns; - } - } - else if (strncmp((*tpp)->name, "xmlns", 5) && (*tpp)->ns && tp->ns && ((k = strcmp((*tpp)->ns, tp->ns)) > 0 || (!k && strcmp((*tpp)->name, name) > 0))) - break; - } - } - tp->next = *tpp; - *tpp = tp; - } - else -#endif - { tp->next = soap->attributes; - soap->attributes = tp; - } - strcpy(tp->name, name); - tp->value = NULL; - } - else if (value && tp->value && tp->size <= strlen(value)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free attribute value of %s (free %p)\n", name, tp->value)); - SOAP_FREE(tp->value); - tp->value = NULL; - tp->ns = NULL; - } - if (value) - { if (!tp->value) - { tp->size = strlen(value) + 1; - if (!(tp->value = (char*)SOAP_MALLOC(tp->size))) - return soap->error = SOAP_EOM; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute value of %s (%p)\n", tp->name, tp->value)); - } - strcpy(tp->value, value); - if (!strncmp(tp->name, "xmlns:", 6)) - tp->ns = tp->value; - tp->visible = 2; - } - else - tp->visible = 1; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_attr(struct soap *soap) -{ register struct soap_attribute *tp; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - { while (soap->attributes) - { tp = soap->attributes->next; - SOAP_FREE(soap->attributes->value); - SOAP_FREE(soap->attributes); - soap->attributes = tp; - } - } - else -#endif - { for (tp = soap->attributes; tp; tp = tp->next) - tp->visible = 0; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static int -soap_getattrval(struct soap *soap, char *s, size_t n, soap_wchar d) -{ size_t i; - soap_wchar c; - for (i = 0; i < n; i++) - { c = soap_getutf8(soap); - switch (c) - { - case SOAP_TT: - *s++ = '<'; - soap_unget(soap, '/'); - break; - case SOAP_LT: - *s++ = '<'; - break; - case SOAP_GT: - if (d == ' ') - { soap_unget(soap, c); - *s = '\0'; - return SOAP_OK; - } - *s++ = '>'; - break; - case SOAP_QT: - if (c == d) - { *s = '\0'; - return SOAP_OK; - } - *s++ = '"'; - break; - case SOAP_AP: - if (c == d) - { *s = '\0'; - return SOAP_OK; - } - *s++ = '\''; - break; - case '\t': - case '\n': - case '\r': - case ' ': - case '/': - if (d == ' ') - { soap_unget(soap, c); - *s = '\0'; - return SOAP_OK; - } - default: - if ((int)c == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - } - return soap->error = SOAP_EOM; -} -#endif - -/******************************************************************************/ -#ifdef WITH_FAST -#ifndef PALM_2 -static int -soap_append_lab(struct soap *soap, const char *s, size_t n) -{ if (soap->labidx + n >= soap->lablen) - { register char *t = soap->labbuf; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enlarging look-aside buffer to append data, old size=%lu", (unsigned long)soap->lablen)); - if (soap->lablen == 0) - soap->lablen = SOAP_LABLEN; - while (soap->labidx + n >= soap->lablen) - soap->lablen <<= 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, ", new size=%lu\n", (unsigned long)soap->lablen)); - soap->labbuf = (char*)SOAP_MALLOC(soap->lablen); - if (!soap->labbuf) - { if (t) - free(t); - return soap->error = SOAP_EOM; - } - if (t && soap->labidx) - { memcpy(soap->labbuf, t, soap->labidx); - free(t); - } - } - if (s) - { memcpy(soap->labbuf + soap->labidx, s, n); - soap->labidx += n; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_peek_element(struct soap *soap) -{ register struct soap_attribute *tp; - const char *t; - register char *s; - register soap_wchar c; - register int i; - if (soap->error == SOAP_NO_TAG || soap->error == SOAP_TAG_END || soap->error == SOAP_TAG_MISMATCH) - soap->error = SOAP_OK; /* retry */ - if (soap->peeked) - { if (*soap->tag == '\0') - return soap->error = SOAP_NO_TAG; - return SOAP_OK; - } - soap->peeked = 1; - for (;;) - { while (((c = soap_getutf8(soap)) != SOAP_LT) && c != SOAP_TT) - { if ((int)c == EOF) - return soap->error = SOAP_EOF; - } - if (c == SOAP_TT) - { *soap->tag = '\0'; - return soap->error = SOAP_NO_TAG; /* ending tag found */ - } - s = soap->tag; - do c = soap_get(soap); - while (soap_blank(c)); - i = sizeof(soap->tag); - while (c != '/' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - while (soap_blank(c)) - c = soap_get(soap); - *s = '\0'; - if (*soap->tag != '?') - break; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "XML PI <%s?>\n", soap->tag)); - while ((int)c != EOF && c != SOAP_GT && c != '?') - { s = soap->tmpbuf; - i = sizeof(soap->tmpbuf) - 2; - while (c != '=' && c != SOAP_GT && c != '?' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - while (soap_blank(c)) - c = soap_get(soap); - if (c == '=') - { *s++ = '='; - do c = soap_get(soap); - while (soap_blank(c)); - if (c != SOAP_QT && c != SOAP_AP) - { soap_unget(soap, c); - c = ' '; /* blank delimiter */ - } - if (soap_getattrval(soap, s, i, c) == SOAP_EOM) - while (soap_getattrval(soap, soap->tmpbuf, sizeof(soap->tmpbuf), c) == SOAP_EOM) - ; - else if (!strcmp(soap->tag, "?xml") && (!soap_tag_cmp(soap->tmpbuf, "encoding=iso-8859-1") || !soap_tag_cmp(soap->tmpbuf, "encoding=latin1"))) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "XML latin1 encoding\n")); - soap->mode |= SOAP_ENC_LATIN; - } - } - do c = soap_get(soap); - while (soap_blank(c)); - } - } - soap->id[0] = '\0'; - soap->href[0] = '\0'; - soap->type[0] = '\0'; - soap->arrayType[0] = '\0'; - soap->arraySize[0] = '\0'; - soap->arrayOffset[0] = '\0'; - soap->other = 0; - soap->root = -1; - soap->position = 0; - soap->null = 0; - soap->mustUnderstand = 0; - soap_clr_attr(soap); - while ((int)c != EOF && c != SOAP_GT && c != '/') - { s = soap->tmpbuf; - i = sizeof(soap->tmpbuf); - while (c != '=' && c != '/' && soap_notblank(c)) - { if (--i > 0) - *s++ = (char)c; - c = soap_get(soap); - } - *s = '\0'; - if (i == sizeof(soap->tmpbuf)) - return soap->error = SOAP_SYNTAX_ERROR; - if (!strncmp(soap->tmpbuf, "xmlns:", 6)) - { soap->tmpbuf[5] = '\0'; - t = soap->tmpbuf + 6; - } - else if (!strcmp(soap->tmpbuf, "xmlns")) - t = SOAP_STR_EOS; - else - t = NULL; - for (tp = soap->attributes; tp; tp = tp->next) - if (!SOAP_STRCMP(tp->name, soap->tmpbuf)) - break; - if (!tp) - { tp = (struct soap_attribute*)SOAP_MALLOC(sizeof(struct soap_attribute) + strlen(soap->tmpbuf)); - if (!tp) - return soap->error = SOAP_EOM; - strcpy(tp->name, soap->tmpbuf); - tp->value = NULL; - tp->size = 0; - tp->next = soap->attributes; - soap->attributes = tp; - } - while (soap_blank(c)) - c = soap_get(soap); - if (c == '=') - { do c = soap_get(soap); - while (soap_blank(c)); - if (c != SOAP_QT && c != SOAP_AP) - { soap_unget(soap, c); - c = ' '; /* blank delimiter */ - } - if (soap_getattrval(soap, tp->value, tp->size, c)) - { -#ifdef WITH_FAST - if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - soap->labidx = 0; - if (soap_append_lab(soap, tp->value, tp->size)) - return soap->error; - SOAP_FREE(tp->value); - for (;;) - { if (soap_getattrval(soap, soap->labbuf + soap->labidx, soap->lablen - soap->labidx, c)) - { if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - soap->labidx = soap->lablen; - if (soap_append_lab(soap, NULL, 0)) - return soap->error; - } - else - break; - } - tp->size = soap->lablen; - if (!(tp->value = (char*)SOAP_MALLOC(tp->size))) - return soap->error = SOAP_EOM; - memcpy(tp->value, soap->labbuf, soap->lablen); -#else - size_t n; - if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - if (soap_new_block(soap)) - return soap->error; - for (;;) - { if (!(s = (char*)soap_push_block(soap, SOAP_BLKLEN))) - return soap->error; - if (soap_getattrval(soap, s, SOAP_BLKLEN, c)) - { if (soap->error != SOAP_EOM) - return soap->error; - soap->error = SOAP_OK; - } - else - break; - } - n = tp->size + soap->blist->size; - if (!(s = (char*)SOAP_MALLOC(n))) - return soap->error = SOAP_EOM; - if (tp->value) - { memcpy(s, tp->value, tp->size); - SOAP_FREE(tp->value); - } - soap_save_block(soap, s + tp->size, 0); - tp->value = s; - tp->size = n; -#endif - } - do c = soap_get(soap); - while (soap_blank(c)); - tp->visible = 2; /* seen this attribute w/ value */ - } - else - tp->visible = 1; /* seen this attribute w/o value */ - if (t && tp->value) - { if (soap_push_namespace(soap, t, tp->value)) - return soap->error; - tp->visible = 0; - } - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible && tp->value) - { if (!strcmp(tp->name, "id")) - { *soap->id = '#'; - strncpy(soap->id + 1, tp->value, sizeof(soap->id) - 2); - soap->id[sizeof(soap->id)-1] = '\0'; - } - else if (!strcmp(tp->name, "href")) - { strncpy(soap->href, tp->value, sizeof(soap->href) - 1); - soap->href[sizeof(soap->href)-1] = '\0'; - } - else if ((soap->version == 2 || (soap->mode & SOAP_XML_GRAPH)) && !strcmp(tp->name, "ref")) - { *soap->href = '#'; - strncpy(soap->href + 1, tp->value, sizeof(soap->href) - 2); - soap->href[sizeof(soap->href)-1] = '\0'; - } - else if (!soap_match_tag(soap, tp->name, "xsi:type")) - { strncpy(soap->type, tp->value, sizeof(soap->type) - 1); - soap->type[sizeof(soap->type)-1] = '\0'; - } - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:arrayType")) - { s = soap_strrchr(tp->value, '['); - if (s && (size_t)(s - tp->value) < sizeof(soap->arrayType)) - { strncpy(soap->arrayType, tp->value, s - tp->value); - soap->arrayType[s - tp->value] = '\0'; - strncpy(soap->arraySize, s, sizeof(soap->arraySize) - 1); - } - else - strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType) - 1); - soap->arraySize[sizeof(soap->arrayType)-1] = '\0'; - soap->arrayType[sizeof(soap->arrayType)-1] = '\0'; - } - else if (soap->version == 2 && !soap_match_tag(soap, tp->name, "SOAP-ENC:itemType")) - strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType) - 1); - else if (soap->version == 2 && !soap_match_tag(soap, tp->name, "SOAP-ENC:arraySize")) - strncpy(soap->arraySize, tp->value, sizeof(soap->arraySize) - 1); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:offset")) - strncpy(soap->arrayOffset, tp->value, sizeof(soap->arrayOffset)); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:position")) - soap->position = soap_getposition(tp->value, soap->positions); - else if (soap->version == 1 && !soap_match_tag(soap, tp->name, "SOAP-ENC:root")) - soap->root = ((!strcmp(tp->value, "1") || !strcmp(tp->value, "true"))); - else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:actor") - || !soap_match_tag(soap, tp->name, "SOAP-ENV:role")) - { if ((!soap->actor || strcmp(soap->actor, tp->value)) - && strcmp(tp->value, "http://schemas.xmlsoap.org/soap/actor/next") - && strcmp(tp->value, "http://www.w3.org/2003/05/soap-envelope/role/next")) - soap->other = 1; - } - else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:mustUnderstand") - && (!strcmp(tp->value, "1") || !strcmp(tp->value, "true"))) - soap->mustUnderstand = 1; - else if ((!soap_match_tag(soap, tp->name, "xsi:null") - || !soap_match_tag(soap, tp->name, "xsi:nil")) - && (!strcmp(tp->value, "1") - || !strcmp(tp->value, "true"))) - soap->null = 1; - } - } - if (!(soap->body = (c != '/'))) - do c = soap_get(soap); - while (soap_blank(c)); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_retry(struct soap *soap) -{ soap->peeked = 1; - soap->error = SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_revert(struct soap *soap) -{ if (!soap->peeked) - { soap->peeked = 1; - if (soap->body) - soap->level--; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reverting last element (level=%u)\n", soap->level)); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_string_out(struct soap *soap, const char *s, int flag) -{ register const char *t; - register soap_wchar c; - register soap_wchar mask = 0x80000000; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->data = soap_strdup(soap, s); /* check EOM */ - return SOAP_OK; - } -#endif - if (soap->mode & SOAP_C_UTFSTRING) - mask = 0; - t = s; - while ((c = *t++)) - { switch (c) - { - case 9: - if (flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - } - break; - case 10: - if (flag || !(soap->mode & SOAP_XML_CANONICAL)) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - } - break; - case 13: - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, " ", 5)) - return soap->error; - s = t; - break; - case '&': - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&", 5)) - return soap->error; - s = t; - break; - case '<': - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "<", 4)) - return soap->error; - s = t; - break; - case '>': - if (!flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, ">", 4)) - return soap->error; - s = t; - } - break; - case '"': - if (flag) - { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, """, 6)) - return soap->error; - s = t; - } - break; - default: -#ifdef HAVE_MBTOWC - if (soap->mode & SOAP_C_MBSTRING) - { wchar_t wc; - register int m = mbtowc(&wc, t - 1, MB_CUR_MAX); - if (m > 0 && wc != c) - { if (soap_send_raw(soap, s, t - s - 1) || soap_pututf8(soap, wc)) - return soap->error; - s = t + m - 1; - continue; - } - } -#endif - if (c & mask) - { if (soap_send_raw(soap, s, t - s - 1) || soap_pututf8(soap, (unsigned char)c)) - return soap->error; - s = t; - } - } - } - return soap_send_raw(soap, s, t - s - 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) -{ register char *s; - char *t = NULL; - register size_t i; - register long l = 0; - register int n = 0; - register int m = 0; - register soap_wchar c; -#ifdef HAVE_WCTOMB - char buf[MB_LEN_MAX > 8 ? MB_LEN_MAX : 8]; -#else - char buf[8]; -#endif -#ifdef WITH_CDATA - if (!flag) - { register int state = 0; -#ifdef WITH_FAST - soap->labidx = 0; /* use look-aside buffer */ -#else - if (soap_new_block(soap)) - return NULL; -#endif - for (;;) - { -#ifdef WITH_FAST - register size_t k; - if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ - return NULL; - s = soap->labbuf + soap->labidx; /* space to populate */ - k = soap->lablen - soap->labidx; /* number of bytes available */ - soap->labidx = soap->lablen; /* claim this space */ -#else - register size_t k = SOAP_BLKLEN; - if (!(s = (char*)soap_push_block(soap, k))) - return NULL; -#endif - for (i = 0; i < k; i++) - { if (m > 0) - { *s++ = *t++; /* copy multibyte characters */ - m--; - continue; - } - c = soap_getchar(soap); - if ((int)c == EOF) - goto end; - if (c >= 0x80 && !(soap->mode & SOAP_ENC_LATIN)) - { soap_unget(soap, c); - c = soap_getutf8(soap); - if (soap->mode & SOAP_C_UTFSTRING) - { if ((c & 0x80000000) && c >= -0x7FFFFF80 && c < SOAP_AP) - { c &= 0x7FFFFFFF; - t = buf; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - m = (int)(t - buf) - 1; - t = buf; - *s++ = *t++; - continue; - } - } - } - switch (state) - { case 1: - if (c == ']') - state = 4; - *s++ = c; - continue; - case 2: - if (c == '-') - state = 6; - *s++ = c; - continue; - case 3: - if (c == '?') - state = 8; - *s++ = c; - continue; - /* CDATA */ - case 4: - if (c == ']') - state = 5; - else - state = 1; - *s++ = c; - continue; - case 5: - if (c == '>') - state = 0; - else - state = 1; - *s++ = c; - continue; - /* comment */ - case 6: - if (c == '-') - state = 7; - else - state = 2; - *s++ = c; - continue; - case 7: - if (c == '>') - state = 0; - else - state = 2; - *s++ = c; - continue; - /* PI */ - case 8: - if (c == '>') - state = 0; - else - state = 3; - *s++ = c; - continue; - } - switch (c) - { - case '/': - if (n > 0) - { c = soap_getchar(soap); - if (c == '>') - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<': - c = soap_getchar(soap); - if (c == '/') - { if (n == 0) - { c = SOAP_TT; - goto end; - } - n--; - } - else if (c == '!') - { c = soap_getchar(soap); - if (c == '[') - { do c = soap_getchar(soap); - while ((int)c != EOF && c != '['); - if ((int)c == EOF) - goto end; - t = (char*)"![CDATA["; - m = 8; - state = 1; - } - else if (c == '-') - { if ((c = soap_getchar(soap)) == '-') - state = 2; - t = (char*)"!-"; - m = 2; - soap_unget(soap, c); - } - else - { t = (char*)"!"; - m = 1; - soap_unget(soap, c); - } - *s++ = '<'; - break; - } - else if (c == '?') - state = 3; - else - n++; - soap_unget(soap, c); - *s++ = '<'; - break; - case '>': - *s++ = '>'; - break; - case '"': - *s++ = '"'; - break; - default: -#ifdef HAVE_WCTOMB - if (soap->mode & SOAP_C_MBSTRING) - { m = wctomb(buf, c & 0x7FFFFFFF); - if (m >= 1) - { t = buf; - *s++ = *t++; - m--; - } - else - *s++ = SOAP_UNKNOWN_CHAR; - } - else -#endif - *s++ = (char)(c & 0xFF); - } - l++; - if ((soap->mode & SOAP_XML_STRICT) && maxlen >= 0 && l > maxlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); - soap->error = SOAP_LENGTH; - return NULL; - } - } - } - } -#endif -#ifdef WITH_FAST - soap->labidx = 0; /* use look-aside buffer */ -#else - if (soap_new_block(soap)) - return NULL; -#endif - for (;;) - { -#ifdef WITH_FAST - register size_t k; - if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ - return NULL; - s = soap->labbuf + soap->labidx; /* space to populate */ - k = soap->lablen - soap->labidx; /* number of bytes available */ - soap->labidx = soap->lablen; /* claim this space */ -#else - register size_t k = SOAP_BLKLEN; - if (!(s = (char*)soap_push_block(soap, k))) - return NULL; -#endif - for (i = 0; i < k; i++) - { if (m > 0) - { *s++ = *t++; /* copy multibyte characters */ - m--; - continue; - } - if (soap->mode & SOAP_C_UTFSTRING) - { if (((c = soap_get(soap)) & 0x80000000) && c >= -0x7FFFFF80 && c < SOAP_AP) - { c &= 0x7FFFFFFF; - t = buf; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); - else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); - else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); - else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); - } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); - } - *t++ = (char)(0x80 | (c & 0x3F)); - m = (int)(t - buf) - 1; - t = buf; - *s++ = *t++; - continue; - } - } - else - c = soap_getutf8(soap); - switch (c) - { - case SOAP_TT: - if (n == 0) - goto end; - n--; - *s++ = '<'; - t = (char*)"/"; - m = 1; - break; - case SOAP_LT: - n++; - *s++ = '<'; - break; - case SOAP_GT: - *s++ = '>'; - break; - case SOAP_QT: - *s++ = '"'; - break; - case SOAP_AP: - *s++ = '\''; - break; - case '/': - if (n > 0) - { c = soap_get(soap); - if (c == SOAP_GT) - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<' | 0x80000000: - if (flag) - *s++ = '<'; - else - { *s++ = '&'; - t = (char*)"lt;"; - m = 3; - } - break; - case '>' | 0x80000000: - if (flag) - *s++ = '>'; - else - { *s++ = '&'; - t = (char*)"gt;"; - m = 3; - } - break; - case '"' | 0x80000000: - if (flag) - *s++ = '"'; - else - { *s++ = '&'; - t = (char*)"quot;"; - m = 5; - } - break; - case '\'' | 0x80000000: - if (flag) - *s++ = '\''; - else - { *s++ = '&'; - t = (char*)"apos;"; - m = 5; - } - break; - default: - if ((int)c == EOF) - goto end; -#ifdef HAVE_WCTOMB - if (soap->mode & SOAP_C_MBSTRING) - { m = wctomb(buf, c & 0x7FFFFFFF); - if (m >= 1) - { t = buf; - *s++ = *t++; - m--; - } - else - *s++ = SOAP_UNKNOWN_CHAR; - } - else -#endif - *s++ = (char)(c & 0xFF); - } - l++; - if ((soap->mode & SOAP_XML_STRICT) && maxlen >= 0 && l > maxlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); - soap->error = SOAP_LENGTH; - return NULL; - } - } - } -end: - soap_unget(soap, c); - *s = '\0'; -#ifdef WITH_FAST - t = soap_strdup(soap, soap->labbuf); -#else - soap_size_block(soap, i+1); - t = soap_save_block(soap, NULL, 0); -#endif - if ((soap->mode & SOAP_XML_STRICT) && l < minlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too short: %ld chars, minlen=%ld\n", l, minlen)); - soap->error = SOAP_LENGTH; - return NULL; - } - if (flag == 2) - if (soap_s2QName(soap, t, &t)) - return NULL; - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_wstring_out(struct soap *soap, const wchar_t *s, int flag) -{ const char *t; - char tmp; - register soap_wchar c; -#ifdef WITH_DOM - if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->wide = NULL; /* soap_malloc() ??? */ - return SOAP_OK; - } -#endif - while ((c = *s++)) - { switch (c) - { - case 9: - if (flag) - t = " "; - else - t = "\t"; - break; - case 10: - if (flag || !(soap->mode & SOAP_XML_CANONICAL)) - t = " "; - else - t = "\n"; - break; - case 13: - t = " "; - break; - case '&': - t = "&"; - break; - case '<': - t = "<"; - break; - case '>': - if (flag) - t = ">"; - else - t = ">"; - break; - case '"': - if (flag) - t = """; - else - t = "\""; - break; - default: - if (c > 0 && c < 0x80) - { tmp = (char)c; - if (soap_send_raw(soap, &tmp, 1)) - return soap->error; - } - else if (soap_pututf8(soap, (unsigned long)c)) - return soap->error; - continue; - } - if (soap_send(soap, t)) - return soap->error; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t * -SOAP_FMAC2 -soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen) -{ wchar_t *s; - register int i, n = 0; - register long l = 0; - register soap_wchar c; - const char *t = NULL; - if (soap_new_block(soap)) - return NULL; - for (;;) - { if (!(s = (wchar_t*)soap_push_block(soap, sizeof(wchar_t)*SOAP_BLKLEN))) - return NULL; - for (i = 0; i < SOAP_BLKLEN; i++) - { if (t) - { *s++ = (wchar_t)*t++; - if (!*t) - t = NULL; - continue; - } - c = soap_getutf8(soap); - switch (c) - { - case SOAP_TT: - if (n == 0) - goto end; - n--; - *s++ = '<'; - soap_unget(soap, '/'); - break; - case SOAP_LT: - n++; - *s++ = '<'; - break; - case SOAP_GT: - *s++ = '>'; - break; - case SOAP_QT: - *s++ = '"'; - break; - case SOAP_AP: - *s++ = '\''; - break; - case '/': - if (n > 0) - { c = soap_getutf8(soap); - if (c == SOAP_GT) - n--; - soap_unget(soap, c); - } - *s++ = '/'; - break; - case '<': - if (flag) - *s++ = (soap_wchar)'<'; - else - { *s++ = (soap_wchar)'&'; - t = "lt;"; - } - break; - case '>': - if (flag) - *s++ = (soap_wchar)'>'; - else - { *s++ = (soap_wchar)'&'; - t = "gt;"; - } - break; - case '"': - if (flag) - *s++ = (soap_wchar)'"'; - else - { *s++ = (soap_wchar)'&'; - t = "quot;"; - } - break; - default: - if ((int)c == EOF) - goto end; - *s++ = (wchar_t)c & 0x7FFFFFFF; - } - l++; - if ((soap->mode & SOAP_XML_STRICT) && maxlen >= 0 && l > maxlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); - soap->error = SOAP_LENGTH; - return NULL; - } - } - } -end: - soap_unget(soap, c); - *s = '\0'; - soap_size_block(soap, sizeof(wchar_t) * (i + 1)); - if ((soap->mode & SOAP_XML_STRICT) && l < minlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too short: %ld chars, minlen=%ld\n", l, minlen)); - soap->error = SOAP_LENGTH; - return NULL; - } - return (wchar_t*)soap_save_block(soap, NULL, 0); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_int2s(struct soap *soap, int n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outint(struct soap *soap, const char *tag, int id, const int *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_long2s(soap, (long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2int(struct soap *soap, const char *s, int *p) -{ if (s) - { char *r; - *p = (int)soap_strtol(s, &r, 10); - if (*r) - soap->error = SOAP_TYPE; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int * -SOAP_FMAC2 -soap_inint(struct soap *soap, const char *tag, int *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; -#ifndef WITH_LEAN - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } -#endif - p = (int*)soap_id_enter(soap, soap->id, p, t, sizeof(int), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2int(soap, soap_value(soap), p)) - return NULL; - } - p = (int*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(int), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_long2s(struct soap *soap, long n) -{ sprintf(soap->tmpbuf, "%ld", n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outlong(struct soap *soap, const char *tag, int id, const long *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_long2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2long(struct soap *soap, const char *s, long *p) -{ if (s) - { char *r; - *p = soap_strtol(s, &r, 10); - if (*r) - soap->error = SOAP_TYPE; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -long * -SOAP_FMAC2 -soap_inlong(struct soap *soap, const char *tag, long *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; -#ifndef WITH_LEAN - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } -#endif - p = (long*)soap_id_enter(soap, soap->id, p, t, sizeof(long), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2long(soap, soap_value(soap), p)) - return NULL; - } - p = (long*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(long), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_LONG642s(struct soap *soap, LONG64 n) -{ sprintf(soap->tmpbuf, SOAP_LONG_FORMAT, n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outLONG64(struct soap *soap, const char *tag, int id, const LONG64 *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_LONG642s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2LONG64(struct soap *soap, const char *s, LONG64 *p) -{ if (s && sscanf(s, SOAP_LONG_FORMAT, p) != 1) - soap->error = SOAP_TYPE; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -LONG64 * -SOAP_FMAC2 -soap_inLONG64(struct soap *soap, const char *tag, LONG64 *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; -#ifndef WITH_LEAN - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":integer") - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":negativeInteger") - && soap_match_tag(soap, soap->type, ":nonPositiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":long") - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } -#endif - p = (LONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(LONG64), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2LONG64(soap, soap_value(soap), p)) - return NULL; - } - p = (LONG64*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(LONG64), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_byte2s(struct soap *soap, char n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outbyte(struct soap *soap, const char *tag, int id, const char *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_long2s(soap, (long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2byte(struct soap *soap, const char *s, char *p) -{ if (s) - { long n; - char *r; - n = soap_strtol(s, &r, 10); - if (*r || n < -128 || n > 127) - soap->error = SOAP_TYPE; - *p = (char)n; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_inbyte(struct soap *soap, const char *tag, char *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; -#ifndef WITH_LEAN - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } -#endif - p = (char*)soap_id_enter(soap, soap->id, p, t, sizeof(char), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2byte(soap, soap_value(soap), p)) - return NULL; - } - p = (char*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(char), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_short2s(struct soap *soap, short n) -{ return soap_long2s(soap, (long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outshort(struct soap *soap, const char *tag, int id, const short *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_long2s(soap, (long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2short(struct soap *soap, const char *s, short *p) -{ if (s) - { long n; - char *r; - n = soap_strtol(s, &r, 10); - if (*r || n < -32768 || n > 32767) - soap->error = SOAP_TYPE; - *p = (short)n; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -short * -SOAP_FMAC2 -soap_inshort(struct soap *soap, const char *tag, short *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; -#ifndef WITH_LEAN - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } -#endif - p = (short*)soap_id_enter(soap, soap->id, p, t, sizeof(short), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2short(soap, soap_value(soap), p)) - return NULL; - } - p = (short*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(short), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_float2s(struct soap *soap, float n) -{ const char *s; - if (soap_isnan((double)n)) - s = "NaN"; - else if (soap_ispinff(n)) - s = "INF"; - else if (soap_isninff(n)) - s = "-INF"; - else - { sprintf(soap->tmpbuf, soap->float_format, n); - s = soap->tmpbuf; - } - return s; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outfloat(struct soap *soap, const char *tag, int id, const float *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_float2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2float(struct soap *soap, const char *s, float *p) -{ if (s) - { if (!soap_tag_cmp(s, "INF")) - *p = FLT_PINFTY; - else if (!soap_tag_cmp(s, "+INF")) - *p = FLT_PINFTY; - else if (!soap_tag_cmp(s, "-INF")) - *p = FLT_NINFTY; - else if (!soap_tag_cmp(s, "NaN")) - *p = FLT_NAN; - else - { -#ifdef HAVE_STRTOD - char *r; - *p = (float)strtod(s, &r); - if (*r) -#endif -#ifdef HAVE_SSCANF - if (sscanf(s, soap->float_format, p) != 1) - soap->error = SOAP_TYPE; -#else - soap->error = SOAP_TYPE; -#endif - } - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static int soap_isnumeric(struct soap *soap, const char *type) -{ if (soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":float") - && soap_match_tag(soap, soap->type, ":double") - && soap_match_tag(soap, soap->type, ":decimal") - && soap_match_tag(soap, soap->type, ":integer") - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":negativeInteger") - && soap_match_tag(soap, soap->type, ":nonPositiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":long") - && soap_match_tag(soap, soap->type, ":int") - && soap_match_tag(soap, soap->type, ":short") - && soap_match_tag(soap, soap->type, ":byte") - && soap_match_tag(soap, soap->type, ":unsignedLong") - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return SOAP_ERR; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -float * -SOAP_FMAC2 -soap_infloat(struct soap *soap, const char *tag, float *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; -#ifndef WITH_LEAN - if (*soap->type != '\0' && soap_isnumeric(soap, type)) - return NULL; -#endif - p = (float*)soap_id_enter(soap, soap->id, p, t, sizeof(float), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2float(soap, soap_value(soap), p)) - return NULL; - } - p = (float*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(float), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_double2s(struct soap *soap, double n) -{ const char *s; - if (soap_isnan(n)) - s = "NaN"; - else if (soap_ispinfd(n)) - s = "INF"; - else if (soap_isninfd(n)) - s = "-INF"; - else - { sprintf(soap->tmpbuf, soap->double_format, n); - s = soap->tmpbuf; - } - return s; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outdouble(struct soap *soap, const char *tag, int id, const double *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_double2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2double(struct soap *soap, const char *s, double *p) -{ if (s) - { if (!soap_tag_cmp(s, "INF")) - *p = DBL_PINFTY; - else if (!soap_tag_cmp(s, "+INF")) - *p = DBL_PINFTY; - else if (!soap_tag_cmp(s, "-INF")) - *p = DBL_NINFTY; - else if (!soap_tag_cmp(s, "NaN")) - *p = DBL_NAN; - else - { -#ifdef HAVE_STRTOD - char *r; - *p = strtod(s, &r); - if (*r) -#endif -#ifdef HAVE_SSCANF - if (sscanf(s, soap->double_format, p) != 1) - soap->error = SOAP_TYPE; -#else - soap->error = SOAP_TYPE; -#endif - } - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -double * -SOAP_FMAC2 -soap_indouble(struct soap *soap, const char *tag, double *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; -#ifndef WITH_LEAN - if (*soap->type != '\0' && soap_isnumeric(soap, type)) - return NULL; -#endif - p = (double*)soap_id_enter(soap, soap->id, p, t, sizeof(double), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2double(soap, soap_value(soap), p)) - return NULL; - } - p = (double*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(double), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedByte2s(struct soap *soap, unsigned char n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedByte(struct soap *soap, const char *tag, int id, const unsigned char *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_unsignedLong2s(soap, (unsigned long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedByte(struct soap *soap, const char *s, unsigned char *p) -{ if (s) - { unsigned long n; - char *r; - n = soap_strtoul(s, &r, 10); - if (*r || n > 255) - soap->error = SOAP_TYPE; - *p = (unsigned char)n; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned char * -SOAP_FMAC2 -soap_inunsignedByte(struct soap *soap, const char *tag, unsigned char *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; -#ifndef WITH_LEAN - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } -#endif - p = (unsigned char*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned char), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2unsignedByte(soap, soap_value(soap), p)) - return NULL; - } - p = (unsigned char*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(unsigned char), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedShort2s(struct soap *soap, unsigned short n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedShort(struct soap *soap, const char *tag, int id, const unsigned short *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_unsignedLong2s(soap, (unsigned long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedShort(struct soap *soap, const char *s, unsigned short *p) -{ if (s) - { unsigned long n; - char *r; - n = soap_strtoul(s, &r, 10); - if (*r || n > 65535) - soap->error = SOAP_TYPE; - *p = (unsigned short)n; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -unsigned short * -SOAP_FMAC2 -soap_inunsignedShort(struct soap *soap, const char *tag, unsigned short *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; -#ifndef WITH_LEAN - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } -#endif - p = (unsigned short*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned short), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2unsignedShort(soap, soap_value(soap), p)) - return NULL; - } - p = (unsigned short*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(unsigned short), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedInt2s(struct soap *soap, unsigned int n) -{ return soap_unsignedLong2s(soap, (unsigned long)n); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedInt(struct soap *soap, const char *tag, int id, const unsigned int *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_unsignedLong2s(soap, (unsigned long)*p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedInt(struct soap *soap, const char *s, unsigned int *p) -{ if (s) - { char *r; - *p = (unsigned int)soap_strtoul(s, &r, 10); - if (*r) - soap->error = SOAP_TYPE; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned int * -SOAP_FMAC2 -soap_inunsignedInt(struct soap *soap, const char *tag, unsigned int *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; -#ifndef WITH_LEAN - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } -#endif - p = (unsigned int*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned int), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2unsignedInt(soap, soap_value(soap), p)) - return NULL; - } - p = (unsigned int*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(unsigned int), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_unsignedLong2s(struct soap *soap, unsigned long n) -{ sprintf(soap->tmpbuf, "%lu", n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outunsignedLong(struct soap *soap, const char *tag, int id, const unsigned long *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_unsignedLong2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2unsignedLong(struct soap *soap, const char *s, unsigned long *p) -{ if (s) - { char *r; - *p = soap_strtoul(s, &r, 10); - if (*r) - soap->error = SOAP_TYPE; - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -unsigned long * -SOAP_FMAC2 -soap_inunsignedLong(struct soap *soap, const char *tag, unsigned long *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; -#ifndef WITH_LEAN - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } -#endif - p = (unsigned long*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned long), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2unsignedLong(soap, soap_value(soap), p)) - return NULL; - } - p = (unsigned long*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(unsigned long), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_ULONG642s(struct soap *soap, ULONG64 n) -{ sprintf(soap->tmpbuf, SOAP_ULONG_FORMAT, n); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outULONG64(struct soap *soap, const char *tag, int id, const ULONG64 *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_ULONG642s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2ULONG64(struct soap *soap, const char *s, ULONG64 *p) -{ if (s && sscanf(s, SOAP_ULONG_FORMAT, p) != 1) - soap->error = SOAP_TYPE; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -ULONG64 * -SOAP_FMAC2 -soap_inULONG64(struct soap *soap, const char *tag, ULONG64 *p, const char *type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":positiveInteger") - && soap_match_tag(soap, soap->type, ":nonNegativeInteger") - && soap_match_tag(soap, soap->type, ":unsignedLong") - && soap_match_tag(soap, soap->type, ":unsignedInt") - && soap_match_tag(soap, soap->type, ":unsignedShort") - && soap_match_tag(soap, soap->type, ":unsignedByte")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (ULONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(ULONG64), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2ULONG64(soap, soap_value(soap), p)) - return NULL; - } - p = (ULONG64*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(ULONG64), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2string(struct soap *soap, const char *s, char **t) -{ *t = NULL; - if (s && !(*t = soap_strdup(soap, s))) - soap->error = SOAP_EOM; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2QName(struct soap *soap, const char *s, char **t) -{ if (s) - { struct soap_nlist *np; - const char *p; - if (!strncmp(s, "xml:", 4)) - { *t = soap_strdup(soap, s); - return SOAP_OK; - } - np = soap->nlist; - p = strchr(s, ':'); - if (p) - { register int n = p - s; - while (np && (strncmp(np->id, s, n) || np->id[n])) - np = np->next; - p++; - } - else - { while (np && *np->id) - np = np->next; - p = s; - } - if (np) - { if (np->index >= 0 && soap->local_namespaces) - { register const char *q = soap->local_namespaces[np->index].id; - if (q) - { if ((*t = (char*)soap_malloc(soap, strlen(p) + strlen(q) + 2))) - sprintf(*t, "%s:%s", q, p); - return SOAP_OK; - } - } - if (np->ns) - { if ((*t = (char*)soap_malloc(soap, strlen(p) + strlen(np->ns) + 4))) - sprintf(*t, "\"%s\":%s", np->ns, p); - return SOAP_OK; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Namespace prefix of '%s' not defined (index=%d, URI=%s)\n", s, np->index, np->ns?np->ns:"")); - return soap->error = SOAP_NAMESPACE; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Namespace prefix of '%s' not defined, assuming empty namespace\n", s)); - if ((*t = (char*)soap_malloc(soap, strlen(p) + 4))) - sprintf(*t, "\"\":%s", p); - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_QName2s(struct soap *soap, const char *s) -{ struct Namespace *p; - char *t; - int n; - if (!s || *s != '"') - return s; - s++; - if ((p = soap->local_namespaces)) - { for (; p->id; p++) - { if (p->ns) - if (!soap_tag_cmp(s, p->ns)) - break; - if (p->in) - if (!soap_tag_cmp(s, p->in)) - break; - } - if (p && p->id) - { s = strchr(s, '"'); - if (s) - { t = (char*)soap_malloc(soap, strlen(p->id) + strlen(s)); - strcpy(t, p->id); - strcat(t, s + 1); - return t; - } - } - } - t = (char*)strchr(s, '"'); - if (t) - n = t - s; - else - n = 0; - t = soap_strdup(soap, s); - t[n] = '\0'; - sprintf(soap->tmpbuf, "xmlns:_%lu", soap->idnum++); - soap_set_attr(soap, soap->tmpbuf, t); - s = strchr(s, '"'); - if (s) - { t = (char*)soap_malloc(soap, strlen(soap->tmpbuf) + strlen(s) - 6); - strcpy(t, soap->tmpbuf + 6); - strcat(t, s + 1); - } - return t; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outstring(struct soap *soap, const char *tag, int id, char *const*p, const char *type, int n) -{ id = soap_element_id(soap, tag, id, *p, NULL, 0, type, n); - if (id < 0 - || soap_element_begin_out(soap, tag, id, type) - || soap_string_out(soap, *p, 0) - || soap_element_end_out(soap, tag)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char ** -SOAP_FMAC2 -soap_instring(struct soap *soap, const char *tag, char **p, const char *type, int t, int flag, long minlen, long maxlen) -{ if (soap_element_begin_in(soap, tag, 1)) - return NULL; - if (!p) - if (!(p = (char**)soap_malloc(soap, sizeof(char*)))) - return NULL; - if (soap->body) - { *p = soap_string_in(soap, flag, minlen, maxlen); - if (!*p || !(char*)soap_id_enter(soap, soap->id, *p, t, sizeof(char*), 0, NULL, NULL, NULL)) - return NULL; - } - else - *p = NULL; - p = (char**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(char**), 0); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outwstring(struct soap *soap, const char *tag, int id, wchar_t *const*p, const char *type, int n) -{ id = soap_element_id(soap, tag, id, *p, NULL, 0, type, n); - if (id < 0 - || soap_element_begin_out(soap, tag, id, type) - || soap_wstring_out(soap, *p, 0) - || soap_element_end_out(soap, tag)) - return soap->error; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t ** -SOAP_FMAC2 -soap_inwstring(struct soap *soap, const char *tag, wchar_t **p, const char *type, int t, long minlen, long maxlen) -{ if (soap_element_begin_in(soap, tag, 1)) - return NULL; - if (!p) - if (!(p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*)))) - return NULL; - if (soap->body) - { *p = soap_wstring_in(soap, 1, minlen, maxlen); - if (!*p || !(wchar_t*)soap_id_enter(soap, soap->id, *p, t, sizeof(wchar_t*), 0, NULL, NULL, NULL)) - return NULL; - } - else - *p = NULL; - p = (wchar_t**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(wchar_t**), 0); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static time_t -soap_timegm(struct tm *T) -{ -#if defined(HAVE_TIMEGM) - return timegm(T); -#elif defined(HAVE_GETTIMEOFDAY) - struct timezone t; - struct timeval tv; - memset((void*)&t, 0, sizeof(t)); - gettimeofday(&tv, &t); - T->tm_min -= t.tz_minuteswest - (t.tz_dsttime != 0)*60; - T->tm_isdst = 0; - return mktime(T); -/* WR[ */ - /* The following define was added for VxWorks*/ -#elif defined(HAVE_MKTIME) - /* FOR VXWORKS: - vxWorks does not seem to have any variable representation of time zones, but - timezone information can be set in INSTALL_DIR/target/h/private/timeP.h header - file, by setting the ZONEBUFFER define. The ZONEBUFFER define follows this - format: - name_of_zone:<(unused)>:time_in_minutes_from_UTC:daylight_start:daylight_end - To calculate local time, the value of time_in_minutes_from_UTC is subtracted - from UTC; time_in_minutes_from_UTC must be positive. Daylight information is - expressed as mmddhh (month-day-hour), for example: - UTC::0:040102:100102 - */ - return mktime(T); -/* ]WR */ -#elif defined(HAVE_FTIME) - struct timeb t; - memset((void*)&t, 0, sizeof(t)); - t.timezone = 0; - t.dstflag = -1; - ftime(&t); - T->tm_min -= t.timezone - (t.dstflag != 0)*60; - T->tm_isdst = 0; - return mktime(T); -#else -#warning "time_t (de)serialization is not MT safe on this platform" - time_t t; - char *tz = getenv("TZ"); - putenv("TZ=UTC"); - tzset(); - t = mktime(T); - if (tz) - { char tmp[16]; - strcpy(tmp, "TZ="); - strncat(tmp, tz, 12); - tmp[15] = '\0'; - putenv(tmp); - } - else - putenv("TZ="); - tzset(); - return t; -#endif -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_dateTime2s(struct soap *soap, time_t n) -{ struct tm T; - struct tm *pT = &T; -#if defined(HAVE_GMTIME_R) - if (gmtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PGMTIME_R) - if (gmtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -#elif defined(HAVE_PGMTIME) - if (gmtime(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -/* ]WR */ -#elif defined(HAVE_GMTIME) - if ((pT = gmtime(&n))) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -#elif defined(HAVE_GETTIMEOFDAY) - struct timezone tz; - memset((void*)&tz, 0, sizeof(tz)); -#if defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - { struct timeval tv; - gettimeofday(&tv, &tz); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -tz.tz_minuteswest/60+(tz.tz_dsttime!=0), abs(tz.tz_minuteswest)%60); - } -#else - if ((pT = localtime(&n))) - { struct timeval tv; - gettimeofday(&tv, &tz); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -tz.tz_minuteswest/60+(tz.tz_dsttime!=0), abs(tz.tz_minuteswest)%60); - } -#endif -#elif defined(HAVE_FTIME) - struct timeb t; - memset((void*)&t, 0, sizeof(t)); -#if defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - { ftime(&t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60+(t.dstflag!=0), abs(t.timezone)%60); - } -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PLOCALTIME_R) - if (localtime_r(&n, pT)) - { strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf+strlen(soap->tmpbuf), "%+03d:%02d", t.timezone/60, abs(t.timezone)%60); - } -/* ]WR */ -#else - if ((pT = localtime(&n))) - { ftime(&t); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60+(t.dstflag!=0), abs(t.timezone)%60); - } -#endif -#elif defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -/* WR[ */ - /* The following defines were added for VxWorks*/ -#elif defined(HAVE_PLOCALTIME_R) - if (localtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -/* ]WR */ -#else - if ((pT = localtime(&n))) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -#endif - else - strcpy(soap->tmpbuf, "1969-12-31T23:59:59Z"); - return soap->tmpbuf; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outdateTime(struct soap *soap, const char *tag, int id, const time_t *p, const char *type, int n) -{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type) - || soap_string_out(soap, soap_dateTime2s(soap, *p), 0)) - return soap->error; - return soap_element_end_out(soap, tag); -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_s2dateTime(struct soap *soap, const char *s, time_t *p) -{ if (s) - { struct tm T; - char zone[16]; - memset((void*)&T, 0, sizeof(T)); - zone[sizeof(zone)-1] = '\0'; - sscanf(s, "%d-%d-%dT%d:%d:%d%15s", &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec, zone); - if (T.tm_year == 1) - T.tm_year = 70; - else - T.tm_year -= 1900; - T.tm_mon--; - if (*zone) - { if (*zone == '.') - { for (s = zone + 1; *s; s++) - if (*s < '0' || *s > '9') - break; - } - else - s = zone; - if (*s != 'Z') - { int h = 0, m = 0; - sscanf(s, "%d:%d", &h, &m); - T.tm_hour -= h; - if (h >= 0) - T.tm_min -= m; - else - T.tm_min += m; - } - *p = soap_timegm(&T); - } - else - *p = mktime(&T); /* no time zone: suppose it is localtime? */ - } - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -time_t * -SOAP_FMAC2 -soap_indateTime(struct soap *soap, const char *tag, time_t *p, const char * type, int t) -{ if (soap_element_begin_in(soap, tag, 0)) - return NULL; - if (*soap->type - && soap_match_tag(soap, soap->type, type) - && soap_match_tag(soap, soap->type, ":dateTime")) - { soap->error = SOAP_TYPE; - soap_revert(soap); - return NULL; - } - p = (time_t*)soap_id_enter(soap, soap->id, p, t, sizeof(time_t), 0, NULL, NULL, NULL); - if (p) - { if (soap_s2dateTime(soap, soap_value(soap), p)) - return NULL; - } - p = (time_t*)soap_id_forward(soap, soap->href, p, t, 0, sizeof(time_t), 0, NULL); - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outliteral(struct soap *soap, const char *tag, char *const*p) -{ int i; - const char *t = NULL; - if (tag && *tag != '-') - { if ((t = strchr(tag, ':'))) - { strncpy(soap->tmpbuf, tag, t-tag); - soap->tmpbuf[t-tag] = '\0'; - for (i = 0; soap->local_namespaces[i].id; i++) - if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id)) - break; - t++; - sprintf(soap->tmpbuf, "<%s xmlns=\"%s\">", t, soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS); - } - else - { t = tag; - sprintf(soap->tmpbuf, "<%s>", tag); - } - if (soap_send(soap, soap->tmpbuf)) - return soap->error; - } - if (p && *p) - { if (soap_send(soap, *p)) - return soap->error; - } - if (t) - { sprintf(soap->tmpbuf, "", t); - return soap_send(soap, soap->tmpbuf); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char ** -SOAP_FMAC2 -soap_inliteral(struct soap *soap, const char *tag, char **p) -{ if (soap_element_begin_in(soap, tag, 1)) - return NULL; - if (!p) - if (!(p = (char**)soap_malloc(soap, sizeof(char*)))) - return NULL; - if (soap->null) - *p = NULL; - else if (soap->body) - *p = soap_string_in(soap, 0, -1, -1); - else - *p = NULL; - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_outwliteral(struct soap *soap, const char *tag, wchar_t *const*p) -{ int i; - const char *t = NULL; - wchar_t c; - const wchar_t *s; - if (tag && *tag != '-') - { if (tag && (t = strchr(tag, ':'))) - { strncpy(soap->tmpbuf, tag, t-tag); - soap->tmpbuf[t-tag] = '\0'; - for (i = 0; soap->local_namespaces[i].id; i++) - if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id)) - break; - t++; - sprintf(soap->tmpbuf, "<%s xmlns=\"%s\">", t, soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS); - } - else - { t = tag; - sprintf(soap->tmpbuf, "<%s>", tag); - } - if (soap_send(soap, soap->tmpbuf)) - return soap->error; - } - if (p) - { s = *p; - while ((c = *s++)) - if (soap_pututf8(soap, (unsigned char)c)) - return soap->error; - } - if (t) - { sprintf(soap->tmpbuf, "", t); - return soap_send(soap, soap->tmpbuf); - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -wchar_t ** -SOAP_FMAC2 -soap_inwliteral(struct soap *soap, const char *tag, wchar_t **p) -{ if (soap_element_begin_in(soap, tag, 1)) - return NULL; - if (!p) - if (!(p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*)))) - return NULL; - if (soap->null) - *p = NULL; - else if (soap->body) - *p = soap_wstring_in(soap, 0, -1, -1); - else - *p = NULL; - if (soap->body && soap_element_end_in(soap, tag)) - return NULL; - return p; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -const char * -SOAP_FMAC2 -soap_value(struct soap *soap) -{ size_t i; - soap_wchar c = 0; - char *s = soap->tmpbuf; - if (!soap->body) - return SOAP_STR_EOS; - for (i = 0; i < sizeof(soap->tmpbuf) - 1; i++) - { c = soap_get(soap); - if (c == SOAP_TT || (int)c == EOF || soap_blank(c)) - break; - *s++ = (char)c; - } - if ((int)c == EOF || c == SOAP_TT) - soap_unget(soap, c); - *s = '\0'; - return soap->tmpbuf; /* return non-null pointer */ -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getline(struct soap *soap, char *s, int len) -{ int i = len; - soap_wchar c = 0; - for (;;) - { while (--i > 0) - { c = soap_getchar(soap); - if (c == '\r') - break; - if ((int)c == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - c = soap_getchar(soap); - if (c == '\n') - { *s = '\0'; - if (i+1 == len) /* empty line: end of HTTP header */ - break; - c = soap_unget(soap, soap_getchar(soap)); - if (c != ' ' && c != '\t') /* HTTP line continuation? */ - break; - } - else if ((int)c == EOF) - return soap->error = SOAP_EOF; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static size_t -soap_count_attachments(struct soap *soap) -{ -#ifndef WITH_LEANER - register struct soap_multipart *content; - register size_t count = soap->count; - if (soap->mode & SOAP_ENC_DIME) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the size of DIME attachments\n")); - for (content = soap->dime.first; content; content = content->next) - { count += 12 + ((content->size+3)&(~3)); - if (content->id) - count += ((strlen(content->id)+3)&(~3)); - if (content->type) - count += ((strlen(content->type)+3)&(~3)); - if (content->options) - count += ((((unsigned char)content->options[2] << 8) | ((unsigned char)content->options[3]))+7)&(~3); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Size of DIME attachment %lu bytes\n", (unsigned long)content->size)); - } - } - if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary) - { register size_t n = strlen(soap->mime.boundary); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the size of MIME attachments\n")); - for (content = soap->mime.first; content; content = content->next) - { register const char *s; - /* count \r\n--boundary\r\n */ - count += 6 + n; - /* count Content-Type: ...\r\n */ - if (content->type) - count += 16 + strlen(content->type); - s = soap_str_code(mime_codes, content->encoding); - /* count Content-Transfer-Encoding: ...\r\n */ - if (s) - count += 29 + strlen(s); - /* count Content-ID: ...\r\n */ - if (content->id) - count += 14 + strlen(content->id); - /* count Content-Location: ...\r\n */ - if (content->location) - count += 20 + strlen(content->location); - /* count Content-Description: ...\r\n */ - if (content->description) - count += 23 + strlen(content->location); - /* count \r\n...content */ - count += 2 + content->size; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Size of MIME attachment %lu bytes\n", (unsigned long)content->size)); - } - /* count \r\n--boundary--\r\n */ - count += 8 + n; - } - return count; -#else - return soap->count; -#endif -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static int -soap_putdimefield(struct soap *soap, const char *s, size_t n) -{ if (soap_send_raw(soap, s, n)) - return soap->error; - return soap_send_raw(soap, SOAP_STR_PADDING, -(long)n&3); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_dime_option(struct soap *soap, unsigned short optype, const char *option) -{ size_t n; - char *s = NULL; - if (option) - { n = strlen(option); - s = (char*)soap_malloc(soap, n + 5); - if (s) - { s[0] = optype >> 8; - s[1] = optype & 0xFF; - s[2] = n >> 8; - s[3] = n & 0xFF; - strcpy(s + 4, option); - } - } - return s; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putdimehdr(struct soap *soap) -{ unsigned char tmp[12]; - size_t optlen = 0, idlen = 0, typelen = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Put DIME header id='%s'\n", soap->dime.id?soap->dime.id:"")); - if (soap->dime.options) - optlen = (((unsigned char)soap->dime.options[2] << 8) | ((unsigned char)soap->dime.options[3])) + 4; - if (soap->dime.id) - idlen = strlen(soap->dime.id); - if (soap->dime.type) - typelen = strlen(soap->dime.type); - tmp[0] = SOAP_DIME_VERSION | (soap->dime.flags & 0x7); - tmp[1] = soap->dime.flags & 0xF0; - tmp[2] = optlen >> 8; - tmp[3] = optlen & 0xFF; - tmp[4] = idlen >> 8; - tmp[5] = idlen & 0xFF; - tmp[6] = typelen >> 8; - tmp[7] = typelen & 0xFF; - tmp[8] = soap->dime.size >> 24; - tmp[9] = (soap->dime.size >> 16) & 0xFF; - tmp[10] = (soap->dime.size >> 8) & 0xFF; - tmp[11] = soap->dime.size & 0xFF; - if (soap_send_raw(soap, (char*)tmp, 12) - || soap_putdimefield(soap, soap->dime.options, optlen) - || soap_putdimefield(soap, soap->dime.id, idlen) - || soap_putdimefield(soap, soap->dime.type, typelen)) - return soap->error; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putdime(struct soap *soap) -{ struct soap_multipart *content; - if (!(soap->mode & SOAP_ENC_DIME)) - return SOAP_OK; - for (content = soap->dime.first; content; content = content->next) - { void *handle; - soap->dime.size = content->size; - soap->dime.id = content->id; - soap->dime.type = content->type; - soap->dime.options = content->options; - soap->dime.flags = SOAP_DIME_VERSION | SOAP_DIME_MEDIA; - if (soap->fdimereadopen && ((handle = soap->fdimereadopen(soap, (void*)content->ptr, content->id, content->type, content->options)) || soap->error)) - { size_t size = content->size; - if (!handle) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadopen failed\n")); - return soap->error; - } - if (!content->size && ((soap->mode & SOAP_ENC_XML) || (soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_IO) == SOAP_IO_STORE)) - { size_t chunksize = sizeof(soap->tmpbuf); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked streaming DIME\n")); - do - { size = soap->fdimeread(soap, handle, soap->tmpbuf, chunksize); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread returned %lu bytes\n", (unsigned long)size)); - if (size < chunksize) - { soap->dime.flags &= ~SOAP_DIME_CF; - if (!content->next) - soap->dime.flags |= SOAP_DIME_ME; - } - else - soap->dime.flags |= SOAP_DIME_CF; - soap->dime.size = size; - if (soap_putdimehdr(soap) - || soap_putdimefield(soap, soap->tmpbuf, size)) - break; - if (soap->dime.id) - { soap->dime.flags &= ~(SOAP_DIME_MB | SOAP_DIME_MEDIA); - soap->dime.id = NULL; - soap->dime.type = NULL; - soap->dime.options = NULL; - } - } while (size >= chunksize); - } - else - { if (!content->next) - soap->dime.flags |= SOAP_DIME_ME; - if (soap_putdimehdr(soap)) - return soap->error; - do - { size_t bufsize; - if (size < sizeof(soap->tmpbuf)) - bufsize = size; - else - bufsize = sizeof(soap->tmpbuf); - if (!(bufsize = soap->fdimeread(soap, handle, soap->tmpbuf, bufsize))) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread failed: insufficient data (%lu bytes remaining from %lu bytes)\n", (unsigned long)size, (unsigned long)soap->dime.size)); - soap->error = SOAP_EOF; - break; - } - if (soap_send_raw(soap, soap->tmpbuf, bufsize)) - break; - size -= bufsize; - } while (size); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n")); - soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime.size&3); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n")); - if (soap->fdimereadclose) - soap->fdimereadclose(soap, handle); - } - else - { if (!content->next) - soap->dime.flags |= SOAP_DIME_ME; - if (soap_putdimehdr(soap) - || soap_putdimefield(soap, (char*)content->ptr, content->size)) - return soap->error; - } - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static char * -soap_getdimefield(struct soap *soap, size_t n) -{ register soap_wchar c; - register int i; - register char *s; - char *p = NULL; - if (n) - { p = (char*)soap_malloc(soap, n + 1); - if (p) - { s = p; - for (i = n; i > 0; i--) - { if ((int)(c = soap_get1(soap)) == EOF) - { soap->error = SOAP_EOF; - return NULL; - } - *s++ = (char)c; - } - *s = '\0'; - if ((soap->error = soap_move(soap, -(long)n&3))) - return NULL; - } - else - soap->error = SOAP_EOM; - } - return p; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getdimehdr(struct soap *soap) -{ register soap_wchar c; - register char *s; - register int i; - unsigned char tmp[12]; - size_t optlen, idlen, typelen; - if (!(soap->mode & SOAP_ENC_DIME)) - return soap->error = SOAP_DIME_END; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME header\n")); - if (soap->dime.buflen || soap->dime.chunksize) - { if (soap_move(soap, (long)(soap->dime.size - soap_tell(soap)))) - return soap->error = SOAP_EOF; - soap_unget(soap, soap_getchar(soap)); /* skip padding and get hdr */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... From chunked\n")); - return SOAP_OK; - } - s = (char*)tmp; - for (i = 12; i > 0; i--) - { if ((int)(c = soap_getchar(soap)) == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - if ((tmp[0] & 0xF8) != SOAP_DIME_VERSION) - return soap->error = SOAP_DIME_MISMATCH; - soap->dime.flags = (tmp[0] & 0x7) | (tmp[1] & 0xF0); - optlen = (tmp[2] << 8) | tmp[3]; - idlen = (tmp[4] << 8) | tmp[5]; - typelen = (tmp[6] << 8) | tmp[7]; - soap->dime.size = (tmp[8] << 24) | (tmp[9] << 16) | (tmp[10] << 8) | tmp[11]; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME size=%lu flags=0x%X\n", (unsigned long)soap->dime.size, soap->dime.flags)); - if (!(soap->dime.options = soap_getdimefield(soap, optlen)) && soap->error) - return soap->error; - if (!(soap->dime.id = soap_getdimefield(soap, idlen)) && soap->error) - return soap->error; - if (!(soap->dime.type = soap_getdimefield(soap, typelen)) && soap->error) - return soap->error; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME id=%s, type=%s, options=%s\n", soap->dime.id?soap->dime.id:"", soap->dime.type?soap->dime.type:"", soap->dime.options?soap->dime.options+4:"")); - if (soap->dime.flags & SOAP_DIME_ME) - soap->mode &= ~SOAP_ENC_DIME; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getdime(struct soap *soap) -{ struct soap_multipart *content; - if (soap_getdimehdr(soap)) - return soap->error; - if (soap->fdimewriteopen && ((soap->dime.ptr = (char*)soap->fdimewriteopen(soap, soap->dime.id, soap->dime.type, soap->dime.options)) || soap->error)) - { const char *id, *type, *options; - size_t size, n; - if (!soap->dime.ptr) - return soap->error; - id = soap->dime.id; - type = soap->dime.type; - options = soap->dime.options; - for (;;) - { size = soap->dime.size; - for (;;) - { n = soap->buflen - soap->bufidx; - if (size < n) - n = size; - if ((soap->error = soap->fdimewrite(soap, (void*)soap->dime.ptr, soap->buf + soap->bufidx, n))) - break; - size -= n; - if (!size) - { soap->bufidx += n; - break; - } - if (soap_recv(soap)) - { soap->error = SOAP_EOF; - goto end; - } - } - if (soap_move(soap, -(long)soap->dime.size&3)) - { soap->error = SOAP_EOF; - break; - } - if (!(soap->dime.flags & SOAP_DIME_CF)) - break; - if (soap_getdimehdr(soap)) - break; - } -end: - if (soap->fdimewriteclose) - soap->fdimewriteclose(soap, (void*)soap->dime.ptr); - soap->dime.size = 0; - soap->dime.id = id; - soap->dime.type = type; - soap->dime.options = options; - } - else if (soap->dime.flags & SOAP_DIME_CF) - { const char *id, *type, *options; - register soap_wchar c; - register char *s; - register int i; - id = soap->dime.id; - type = soap->dime.type; - options = soap->dime.options; - if (soap_new_block(soap)) - return SOAP_EOM; - for (;;) - { s = (char*)soap_push_block(soap, soap->dime.size); - if (!s) - return soap->error = SOAP_EOM; - for (i = soap->dime.size; i > 0; i--) - { if ((int)(c = soap_get1(soap)) == EOF) - return soap->error = SOAP_EOF; - *s++ = (char)c; - } - if (soap_move(soap, -(long)soap->dime.size&3)) - return soap->error = SOAP_EOF; - if (!(soap->dime.flags & SOAP_DIME_CF)) - break; - if (soap_getdimehdr(soap)) - return soap->error; - } - soap->dime.size = soap->blist->size++; /* allocate one more for '\0' */ - if (!(soap->dime.ptr = soap_save_block(soap, NULL, 0))) - return soap->error; - soap->dime.ptr[soap->dime.size] = '\0'; /* force 0-terminated */ - soap->dime.id = id; - soap->dime.type = type; - soap->dime.options = options; - } - else - soap->dime.ptr = soap_getdimefield(soap, soap->dime.size); - content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, soap->dime.ptr, soap->dime.size); - if (!content) - return soap->error = SOAP_EOM; - content->id = soap->dime.id; - content->type = soap->dime.type; - content->options = soap->dime.options; - return soap->error; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getmimehdr(struct soap *soap) -{ struct soap_multipart *content; - do - { if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf))) - return soap->error; - } - while (!*soap->msgbuf); - if (soap->msgbuf[0] == '-' && soap->msgbuf[1] == '-') - { char *s = soap->msgbuf + strlen(soap->msgbuf) - 1; - /* remove white space */ - while (soap_blank(*s)) - s--; - s[1] = '\0'; - if (soap->mime.boundary) - { if (strcmp(soap->msgbuf + 2, soap->mime.boundary)) - return soap->error = SOAP_MIME_ERROR; - } - else - soap->mime.boundary = soap_strdup(soap, soap->msgbuf + 2); - if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf))) - return soap->error; - } - if (soap_set_mime_attachment(soap, NULL, 0, SOAP_MIME_NONE, NULL, NULL, NULL, NULL)) - return soap->error = SOAP_EOM; - content = soap->mime.last; - for (;;) - { register char *key = soap->msgbuf; - register char *val; - if (!*key) - break; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "MIME header: %s\n", key)); - val = strchr(soap->msgbuf, ':'); - if (val) - { *val = '\0'; - do val++; - while (*val && *val <= 32); - if (!soap_tag_cmp(key, "Content-ID")) - content->id = soap_strdup(soap, val); - else if (!soap_tag_cmp(key, "Content-Location")) - content->location = soap_strdup(soap, val); - else if (!soap_tag_cmp(key, "Content-Type")) - content->type = soap_strdup(soap, val); - else if (!soap_tag_cmp(key, "Content-Description")) - content->description = soap_strdup(soap, val); - else if (!soap_tag_cmp(key, "Content-Transfer-Encoding")) - content->encoding = (enum soap_mime_encoding)soap_int_code(mime_codes, val, (long)SOAP_MIME_NONE); - } - if (soap_getline(soap, key, sizeof(soap->msgbuf))) - return soap->error; - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getmime(struct soap *soap) -{ register soap_wchar c; - if (!soap->mime.last) - return SOAP_OK; - for (;;) - { register size_t i, m = 0; - register char *s; - struct soap_multipart *content = soap->mime.last; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Parsing MIME content id=%s type=%s\n", content->id?content->id:"", content->type?content->type:"")); - if (soap_new_block(soap)) - return soap->error = SOAP_EOM; - for (;;) - { register char *t = NULL; - if (!(s = (char*)soap_push_block(soap, SOAP_BLKLEN))) - return soap->error = SOAP_EOM; - for (i = 0; i < SOAP_BLKLEN; i++) - { if (m > 0) - { *s++ = *t++; - m--; - } - else - { c = soap_get1(soap); - if ((int)c == EOF) - return soap->error = SOAP_EOF; - if (c == '\r') - { t = soap->tmpbuf; - strcpy(t, "\n--"); - strncat(t, soap->mime.boundary, sizeof(soap->tmpbuf)-3); - t[sizeof(soap->tmpbuf)-1] = '\0'; - do c = soap_getchar(soap); - while (c == *t++); - if ((int)c == EOF) - return soap->error = SOAP_EOF; - if (!*--t) - goto end; - *t = (char)c; - m = t - soap->tmpbuf + 1; - t = soap->tmpbuf; - c = '\r'; - } - *s++ = (char)c; - } - } - } -end: - *s = '\0'; /* force 0-terminated */ - content->size = soap_size_block(soap, i+1)-1; - content->ptr = soap_save_block(soap, NULL, 0); - if (c == '-' && soap_getchar(soap) == '-') - break; - while (c != '\r' && (int)c != EOF && soap_blank(c)) - c = soap_getchar(soap); - if (c != '\r' || soap_getchar(soap) != '\n') - return soap->error = SOAP_MIME_ERROR; - if (soap_getmimehdr(soap)) - return soap->error; - } - do c = soap_getchar(soap); - while ((int)c != EOF && c != '\r'); - if ((int)c == EOF) - return soap->error = SOAP_EOF; - if (soap_getchar(soap) != '\n') - return soap->error = SOAP_MIME_ERROR; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putmimehdr(struct soap *soap, struct soap_multipart *content) -{ const char *s; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "MIME attachment type=%s\n", content->type?content->type:"")); - if (soap_send3(soap, "\r\n--", soap->mime.boundary, "\r\n")) - return soap->error; - if (content->type && soap_send3(soap, "Content-Type: ", content->type, "\r\n")) - return soap->error; - s = soap_str_code(mime_codes, content->encoding); - if (s && soap_send3(soap, "Content-Transfer-Encoding: ", s, "\r\n")) - return soap->error; - if (content->id && soap_send3(soap, "Content-ID: ", content->id, "\r\n")) - return soap->error; - if (content->location && soap_send3(soap, "Content-Location: ", content->location, "\r\n")) - return soap->error; - if (content->description && soap_send3(soap, "Content-Description: ", content->description, "\r\n")) - return soap->error; - return soap_send_raw(soap, "\r\n", 2); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putmime(struct soap *soap) -{ struct soap_multipart *content; - if (!(soap->mode & SOAP_ENC_MIME) || !soap->mime.boundary) - return SOAP_OK; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending MIME attachments\n")); - for (content = soap->mime.first; content; content = content->next) - if (soap_putmimehdr(soap, content) - || soap_send_raw(soap, content->ptr, content->size)) - return soap->error; - return soap_send3(soap, "\r\n--", soap->mime.boundary, "--\r\n"); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_dime(struct soap *soap) -{ soap->omode |= SOAP_ENC_DIME; - soap->dime.first = NULL; - soap->dime.last = NULL; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_mime(struct soap *soap, const char *boundary, const char *start) -{ soap->omode |= SOAP_ENC_MIME; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->mime.boundary = soap_strdup(soap, boundary); - soap->mime.start = soap_strdup(soap, start); -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_dime(struct soap *soap) -{ soap->omode &= ~SOAP_ENC_DIME; - soap->dime.first = NULL; - soap->dime.last = NULL; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_mime(struct soap *soap) -{ soap->omode &= ~SOAP_ENC_MIME; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->mime.boundary = NULL; - soap->mime.start = NULL; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static struct soap_multipart* -soap_new_multipart(struct soap *soap, struct soap_multipart **first, struct soap_multipart **last, char *ptr, size_t size) -{ struct soap_multipart *content; - content = (struct soap_multipart*)soap_malloc(soap, sizeof(struct soap_multipart)); - if (content) - { content->next = NULL; - content->ptr = ptr; - content->size = size; - content->id = NULL; - content->type = NULL; - content->options = NULL; - content->encoding = SOAP_MIME_NONE; - content->location = NULL; - content->description = NULL; - if (!*first) - *first = content; - if (*last) - (*last)->next = content; - *last = content; - } - return content; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_dime_attachment(struct soap *soap, char *ptr, size_t size, const char *type, const char *id, unsigned short optype, const char *option) -{ struct soap_multipart *content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, ptr, size); - if (!content) - return SOAP_EOM; - content->id = soap_strdup(soap, id); - content->type = soap_strdup(soap, type); - content->options = soap_dime_option(soap, optype, option); - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_mime_attachment(struct soap *soap, char *ptr, size_t size, enum soap_mime_encoding encoding, const char *type, const char *id, const char *location, const char *description) -{ struct soap_multipart *content = soap_new_multipart(soap, &soap->mime.first, &soap->mime.last, ptr, size); - if (!content) - return SOAP_EOM; - content->id = soap_strdup(soap, id); - content->type = soap_strdup(soap, type); - content->encoding = encoding; - content->location = soap_strdup(soap, location); - content->description = soap_strdup(soap, description); - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -SOAP_FMAC1 -struct soap_multipart* -SOAP_FMAC2 -soap_next_multipart(struct soap_multipart *content) -{ if (content) - return content->next; - return NULL; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static void -soap_select_mime_boundary(struct soap *soap) -{ while (!soap->mime.boundary || soap_valid_mime_boundary(soap)) - { register char *s = soap->mime.boundary; - register size_t n = 0; - if (s) - n = strlen(s); - if (n < 16) - { n = 72; - s = soap->mime.boundary = (char*)soap_malloc(soap, n); - if (!s) - return; - } - strcpy(s, "<>"); - s += 2; - n -= 4; - while (n) - { *s++ = soap_base64o[rand()&0x3F]; - n--; - } - *s = '\0'; - strcat(s, "<>"); - } - if (!soap->mime.start) - soap->mime.start = ""; -} -#endif -#endif - -/******************************************************************************/ -#ifndef WITH_LEANER -#ifndef PALM_1 -static int -soap_valid_mime_boundary(struct soap *soap) -{ register struct soap_multipart *content; - register size_t k = strlen(soap->mime.boundary); - for (content = soap->mime.first; content; content = content->next) - { if (content->ptr && content->size >= k) - { register const char *p = (const char*)content->ptr; - register size_t i; - for (i = 0; i < content->size - k; i++, p++) - if (!strncmp(p, soap->mime.boundary, k)) - return SOAP_ERR; - } - } - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ - -#ifdef WITH_COOKIES -/******************************************************************************/ -SOAP_FMAC1 -size_t -SOAP_FMAC2 -soap_encode_cookie(const char *s, char *t, size_t len) -{ register int c; - register size_t n = len; - while ((c = *s++) && --n > 0) - { if (c > ' ' && c < 128 && c != ';' && c != ',') - *t++ = c; - else if (n > 2) - { *t++ = '%'; - *t++ = (c >> 4) + (c > 159 ? '7' : '0'); - c &= 0xF; - *t++ = c + (c > 9 ? '7' : '0'); - n -= 2; - } - else - break; - } - *t = '\0'; - return len - n; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_cookie(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - size_t n; - if (!domain) - domain = soap->cookie_domain; - if (!path) - path = soap->cookie_path; - if (*path == '/') - path++; - n = strlen(path); - for (p = soap->cookies; p; p = p->next) - if (!strcmp(p->name, name) - && domain - && p->domain - && !strcmp(p->domain, domain) - && !strncmp(p->path, path, n)) - break; - return p; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_set_cookie(struct soap *soap, const char *name, const char *value, const char *domain, const char *path) -{ struct soap_cookie **p, *q; - int n; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set cookie: %s=%s domain=%s path=%s\n", name, value?value:"", domain?domain:"", path?path:"")); - if (!domain) - domain = soap->cookie_domain; - if (!path) - path = soap->cookie_path; - if (!path) - { soap_set_receiver_error(soap, "Cookie path not set", NULL, SOAP_HTTP_ERROR); - return NULL; - } - if (*path == '/') - path++; - q = soap_cookie(soap, name, domain, path); - if (!q) - { if ((q = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - { if ((q->name = (char*)SOAP_MALLOC(strlen(name)+1))) - strcpy(q->name, name); - q->value = NULL; - q->domain = NULL; - q->path = NULL; - q->expire = -1; - q->version = 0; - q->secure = 0; - q->env = 0; - q->modified = 0; - for (p = &soap->cookies, n = soap->cookie_max; *p && n; p = &(*p)->next, n--) - if (!strcmp((*p)->name, name) && (*p)->path && strcmp((*p)->path, path) < 0) - break; - if (n) - { q->next = *p; - *p = q; - } - else - { SOAP_FREE(q->name); - SOAP_FREE(q); - q = NULL; - } - } - } - else - q->modified = 1; - if (q) - { if (q->value) - { SOAP_FREE(q->value); - q->value = NULL; - } - if (q->domain) - { SOAP_FREE(q->domain); - q->domain = NULL; - } - if (q->path) - { SOAP_FREE(q->path); - q->path = NULL; - } - if (value && *value && (q->value = (char*)SOAP_MALLOC(strlen(value)+1))) - strcpy(q->value, value); - if (domain && *domain && (q->domain = (char*)SOAP_MALLOC(strlen(domain)+1))) - strcpy(q->domain, domain); - if (path && *path && (q->path = (char*)SOAP_MALLOC(strlen(path)+1))) - strcpy(q->path, path); - q->session = 1; - } - return q; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_clr_cookie(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie **p, *q; - if (!domain) - domain = soap->cookie_domain; - if (!domain) - { soap_set_receiver_error(soap, "Cookie domain not set", SOAP_STR_EOS, SOAP_HTTP_ERROR); - return; - } - if (!path) - path = soap->cookie_path; - if (!path) - { soap_set_receiver_error(soap, "Cookie path not set", SOAP_STR_EOS, SOAP_HTTP_ERROR); - return; - } - if (*path == '/') - path++; - for (p = &soap->cookies, q = *p; q; q = *p) - if (!strcmp(q->name, name) && !strcmp(q->domain, domain) && !strncmp(q->path, path, strlen(q->path))) - { if (q->value) - SOAP_FREE(q->value); - if (q->domain) - SOAP_FREE(q->domain); - if (q->path) - SOAP_FREE(q->path); - *p = q->next; - SOAP_FREE(q); - } - else - p = &q->next; -} - -/******************************************************************************/ -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_cookie_value(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - return p->value; - return NULL; -} - -/******************************************************************************/ -SOAP_FMAC1 -long -SOAP_FMAC2 -soap_cookie_expire(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - return p->expire; - return -1; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_cookie_expire(struct soap *soap, const char *name, long expire, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->expire = expire; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->session = 1; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_clr_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path) -{ struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) - { p->session = 0; - p->modified = 1; - return SOAP_OK; - } - return SOAP_ERR; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putsetcookies(struct soap *soap) -{ struct soap_cookie *p; - char *s, tmp[4096]; - const char *t; - for (p = soap->cookies; p; p = p->next) - { if (p->modified || !p->env) - { s = tmp; - if (p->name) - s += soap_encode_cookie(p->name, s, tmp-s+4064); - if (p->value && *p->value) - { *s++ = '='; - s += soap_encode_cookie(p->value, s, tmp-s+4064); - } - if (p->domain && (int)strlen(p->domain) < tmp-s+4064) - sprintf(s, ";Domain=%s", p->domain); - else if (soap->cookie_domain && (int)strlen(soap->cookie_domain) < tmp-s+4064) - sprintf(s, ";Domain=%s", soap->cookie_domain); - strcat(s, ";Path=/"); - if (p->path) - t = p->path; - else - t = soap->cookie_path; - if (t) - { if (*t == '/') - t++; - if ((int)strlen(t) < tmp-s+4064) - strcat(s, t); - } - s += strlen(s); - if (p->version > 0) - sprintf(s, ";Version=%u", p->version); - if (p->expire >= 0) - sprintf(s, ";Max-Age=%ld", p->expire); - if (p->secure) - strcat(s, ";Secure"); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set-Cookie: %s\n", tmp)); - if (soap->fposthdr(soap, "Set-Cookie", tmp)) - return soap->error; - } - } - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_putcookies(struct soap *soap, const char *domain, const char *path, int secure) -{ struct soap_cookie **p, *q; - unsigned int version = 0; - time_t now = time(NULL); - char *s, tmp[4096]; - p = &soap->cookies; - while ((q = *p)) - { if (q->expire && now > q->expire) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie %s expired\n", q->name)); - SOAP_FREE(q->name); - if (q->value) - SOAP_FREE(q->value); - if (q->domain) - SOAP_FREE(q->domain); - if (q->path) - SOAP_FREE(q->path); - *p = q->next; - SOAP_FREE(q); - } - else if ((!q->domain || !strcmp(q->domain, domain)) - && (!q->path || !strncmp(q->path, path, strlen(q->path))) - && (!q->secure || secure)) - { s = tmp; - if (q->version != version) - { sprintf(s, "$Version=%u;", q->version); - version = q->version; - } - if (q->name) - s += soap_encode_cookie(q->name, s, tmp-s+4080); - if (q->value && *q->value) - { *s++ = '='; - s += soap_encode_cookie(q->value, s, tmp-s+4080); - } - if (q->path && (int)strlen(q->path) < tmp-s+4080) - { sprintf(s, ";$Path=/%s", q->path); - s += strlen(s); - } - if (q->domain && (int)strlen(q->domain) < tmp-s+4080) - sprintf(s, ";$Domain=%s", q->domain); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie: %s\n", tmp)); - if (soap->fposthdr(soap, "Cookie", tmp)) - return soap->error; - p = &q->next; - } - else - p = &q->next; - } - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_getcookies(struct soap *soap, const char *val) -{ struct soap_cookie *p = NULL, *q; - const char *s; - char *t, tmp[4096]; /* cookie size is up to 4096 bytes [RFC2109] */ - char *domain = NULL; - char *path = NULL; - unsigned int version = 0; - time_t now = time(NULL); - if (!val) - return; - s = val; - while (*s) - { s = soap_decode_key(tmp, sizeof(tmp), s); - if (!soap_tag_cmp(tmp, "$Version")) - { if ((s = soap_decode_val(tmp, sizeof(tmp), s))) - { if (p) - p->version = (int)atol(tmp); - else - version = (int)atol(tmp); - } - } - else if (!soap_tag_cmp(tmp, "$Path")) - { s = soap_decode_val(tmp, sizeof(tmp), s); - if (*tmp) - { if ((t = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(t, tmp); - } - else - t = NULL; - if (p) - { if (p->path) - SOAP_FREE(p->path); - p->path = t; - } - else - { if (path) - SOAP_FREE(path); - path = t; - } - } - else if (!soap_tag_cmp(tmp, "$Domain")) - { s = soap_decode_val(tmp, sizeof(tmp), s); - if (*tmp) - { if ((t = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(t, tmp); - } - else - t = NULL; - if (p) - { if (p->domain) - SOAP_FREE(p->domain); - p->domain = t; - } - else - { if (domain) - SOAP_FREE(domain); - domain = t; - } - } - else if (p && !soap_tag_cmp(tmp, "Path")) - { if (p->path) - SOAP_FREE(p->path); - s = soap_decode_val(tmp, sizeof(tmp), s); - if (*tmp) - { if ((p->path = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(p->path, tmp); - } - else - p->path = NULL; - } - else if (p && !soap_tag_cmp(tmp, "Domain")) - { if (p->domain) - SOAP_FREE(p->domain); - s = soap_decode_val(tmp, sizeof(tmp), s); - if (*tmp) - { if ((p->domain = (char*)SOAP_MALLOC(strlen(tmp)+1))) - strcpy(p->domain, tmp); - } - else - p->domain = NULL; - } - else if (p && !soap_tag_cmp(tmp, "Version")) - { s = soap_decode_val(tmp, sizeof(tmp), s); - p->version = (unsigned int)atol(tmp); - } - else if (p && !soap_tag_cmp(tmp, "Max-Age")) - { s = soap_decode_val(tmp, sizeof(tmp), s); - p->expire = now + atol(tmp); - } - else if (p && !soap_tag_cmp(tmp, "Expires")) - { struct tm T; - char a[3]; - static const char mns[] = "anebarprayunulugepctovec"; - s = soap_decode_val(tmp, sizeof(tmp), s); - if (strlen(tmp) > 20) - { memset((void*)&T, 0, sizeof(T)); - a[0] = tmp[4]; - a[1] = tmp[5]; - a[2] = '\0'; - T.tm_mday = (int)atol(a); - a[0] = tmp[8]; - a[1] = tmp[9]; - T.tm_mon = (strstr(mns, a) - mns) / 2; - a[0] = tmp[11]; - a[1] = tmp[12]; - T.tm_year = 100 + (int)atol(a); - a[0] = tmp[13]; - a[1] = tmp[14]; - T.tm_hour = (int)atol(a); - a[0] = tmp[16]; - a[1] = tmp[17]; - T.tm_min = (int)atol(a); - a[0] = tmp[19]; - a[1] = tmp[20]; - T.tm_sec = (int)atol(a); - p->expire = soap_timegm(&T); - } - } - else if (p && !soap_tag_cmp(tmp, "Secure")) - p->secure = 1; - else - { if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"", p->domain?p->domain:"", p->path?p->path:"", p->expire, p->secure)); - if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) - { q->version = p->version; - q->expire = p->expire; - q->secure = p->secure; - q->env = 1; - } - if (p->name) - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } - if ((p = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - { p->name = (char*)SOAP_MALLOC(strlen(tmp)+1); - strcpy(p->name, tmp); - s = soap_decode_val(tmp, sizeof(tmp), s); - if (*tmp) - { p->value = (char*)SOAP_MALLOC(strlen(tmp)+1); - strcpy(p->value, tmp); - } - else - p->value = NULL; - p->domain = domain; - p->path = path; - p->expire = 0; - p->secure = 0; - p->version = version; - } - } - } - if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"", p->domain?p->domain:"", p->path?p->path:"", p->expire, p->secure)); - if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) - { q->version = p->version; - q->expire = p->expire; - q->secure = p->secure; - } - if (p->name) - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } - if (domain) - SOAP_FREE(domain); - if (path) - SOAP_FREE(path); -} - -/******************************************************************************/ -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getenv_cookies(struct soap *soap) -{ struct soap_cookie *p; - const char *s; - char key[4096], val[4096]; /* cookie size is up to 4096 bytes [RFC2109] */ - if (!(s = getenv("HTTP_COOKIE"))) - return SOAP_ERR; - do - { s = soap_decode_key(key, sizeof(key), s); - s = soap_decode_val(val, sizeof(val), s); - p = soap_set_cookie(soap, key, val, NULL, NULL); - if (p) - p->env = 1; - } while (*s); - return SOAP_OK; -} - -/******************************************************************************/ -SOAP_FMAC1 -struct soap_cookie* -SOAP_FMAC2 -soap_copy_cookies(struct soap *soap) -{ struct soap_cookie *p, **q, *r; - q = &r; - for (p = soap->cookies; p; p = p->next) - { if (!(*q = (struct soap_cookie*)SOAP_MALLOC(sizeof(struct soap_cookie)))) - return r; - **q = *p; - if (p->name) - { if (((*q)->name = (char*)SOAP_MALLOC(strlen(p->name)+1))) - strcpy((*q)->name, p->name); - } - if (p->value) - { if (((*q)->value = (char*)SOAP_MALLOC(strlen(p->value)+1))) - strcpy((*q)->value, p->value); - } - if (p->domain) - { if (((*q)->domain = (char*)SOAP_MALLOC(strlen(p->domain)+1))) - strcpy((*q)->domain, p->domain); - } - if (p->path) - { if (((*q)->path = (char*)SOAP_MALLOC(strlen(p->path)+1))) - strcpy((*q)->path, p->path); - } - q = &(*q)->next; - } - *q = NULL; - return r; -} - -/******************************************************************************/ -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_free_cookies(struct soap *soap) -{ struct soap_cookie *p; - for (p = soap->cookies; p; p = soap->cookies) - { soap->cookies = p->next; - SOAP_FREE(p->name); - if (p->value) - SOAP_FREE(p->value); - if (p->domain) - SOAP_FREE(p->domain); - if (p->path) - SOAP_FREE(p->path); - SOAP_FREE(p); - } -} - -/******************************************************************************/ -#endif /* WITH_COOKIES */ - -/******************************************************************************/ -#ifdef WITH_GZIP -#ifndef PALM_1 -static int -soap_getgziphdr(struct soap *soap) -{ int i; - soap_wchar c, f = 0; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get gzip header\n")); - for (i = 0; i < 9; i++) - { if ((int)(c = soap_get1(soap) == EOF)) - return soap->error = SOAP_EOF; - if (i == 2) - f = c; - } - if (f & 0x04) /* FEXTRA */ - { for (i = soap_get1(soap) | (soap_get1(soap) << 8); i; i--) - if ((int)soap_get1(soap) == EOF) - return soap->error = SOAP_EOF; - } - if (f & 0x08) /* FNAME */ - do - c = soap_get1(soap); - while (c && (int)c != EOF); - if ((int)c != EOF && (f & 0x10)) /* FCOMMENT */ - do - c = soap_get1(soap); - while (c && (int)f != EOF); - if ((int)c != EOF && (f & 0x01)) /* FHCRC */ - { if ((int)(c = soap_get1(soap)) != EOF) - c = soap_get1(soap); - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - return SOAP_OK; -} -#endif -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_begin_recv(struct soap *soap) -{ soap_wchar c; - soap->error = SOAP_OK; - soap_free(soap); - soap_set_local_namespaces(soap); - soap->version = 0; /* don't assume we're parsing SOAP content by default */ - soap_free_iht(soap); - if ((soap->imode & SOAP_IO) == SOAP_IO_CHUNK) - soap->omode |= SOAP_IO_CHUNK; - soap->imode &= ~SOAP_IO; - soap->mode = soap->imode; - if (!soap->keep_alive) - { soap->buflen = 0; - soap->bufidx = 0; - } - if (!(soap->mode & SOAP_IO_KEEPALIVE)) - soap->keep_alive = 0; - soap->ahead = 0; - soap->peeked = 0; - soap->level = 0; - soap->part = SOAP_BEGIN; - soap->alloced = 0; - soap->count = 0; - soap->length = 0; - soap->cdata = 0; - *soap->endpoint = '\0'; - soap->userid = NULL; - soap->passwd = NULL; - soap->action = NULL; - soap->authrealm = NULL; - soap->dime.chunksize = 0; - soap->dime.buflen = 0; - soap->dime.list = NULL; - soap->dime.first = NULL; - soap->dime.last = NULL; - soap->mime.list = NULL; - soap->mime.first = NULL; - soap->mime.last = NULL; - soap->mime.boundary = NULL; - soap->mime.start = NULL; -#ifdef WIN32 -#ifndef UNDER_CE -#ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket)) -#ifdef __BORLANDC__ - setmode((SOAP_SOCKET)soap->recvfd, O_BINARY); -#else - _setmode((SOAP_SOCKET)soap->recvfd, _O_BINARY); -#endif -#endif -#endif -#endif -#ifdef WITH_ZLIB - soap->mode &= ~SOAP_ENC_ZLIB; - soap->zlib_in = SOAP_ZLIB_NONE; - soap->zlib_out = SOAP_ZLIB_NONE; - soap->d_stream.next_in = Z_NULL; - soap->d_stream.avail_in = 0; - soap->d_stream.next_out = (Byte*)soap->buf; - soap->d_stream.avail_out = SOAP_BUFLEN; - soap->z_ratio_in = 1.0; - if (soap->fprepareinit) - soap->fprepareinit(soap); -#endif - c = soap_getchar(soap); -#ifdef WITH_GZIP - if (c == 0x1F) - { if (soap_getgziphdr(soap)) - return soap->error; - if (inflateInit2(&soap->d_stream, -MAX_WBITS) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - soap->mode |= SOAP_ENC_ZLIB; - soap->zlib_in = SOAP_ZLIB_GZIP; - soap->z_crc = crc32(0L, NULL, 0); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n")); - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - /* should not chunk over plain transport, so why bother to check? */ - /* if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) */ - /* soap->z_buflen = soap->bufidx; */ - /* else */ - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = soap->buflen - soap->bufidx; - soap->z_buflen = soap->buflen; - soap->buflen = soap->bufidx; - c = soap_getchar(soap); - } -#endif - if (c == '-' && soap_get0(soap) == '-') - soap->mode |= SOAP_ENC_MIME; - else if ((c & 0xFFFC) == (SOAP_DIME_VERSION | SOAP_DIME_MB) && (soap_get0(soap) & 0xFFF0) == 0x20) - soap->mode |= SOAP_ENC_DIME; - else - { while (soap_blank(c)) - c = soap_getchar(soap); - } - if ((int)c == EOF) - return soap->error = SOAP_EOF; - soap_unget(soap, c); - if (c != '<' && !(soap->mode & (SOAP_ENC_DIME | SOAP_ENC_ZLIB))) - { soap->mode &= ~SOAP_IO; - if ((soap->error = soap->fparse(soap))) - { soap->keep_alive = 0; /* force close later */ - return soap->error; - } - if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { soap->chunkbuflen = soap->buflen; - soap->buflen = soap->bufidx; - soap->chunksize = 0; - } - else if (soap->fpreparerecv && soap->buflen != soap->bufidx) - soap->fpreparerecv(soap, soap->buf + soap->bufidx, soap->buflen - soap->bufidx); -#ifdef WITH_ZLIB - if (soap->zlib_in) - { /* fparse should not use soap_unget to push back last char */ -#ifdef WITH_GZIP - c = soap_get1(soap); - if (c == 0x1F) - { if (soap_getgziphdr(soap)) - return soap->error; - if (inflateInit2(&soap->d_stream, -MAX_WBITS) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - soap->z_crc = crc32(0L, NULL, 0); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n")); - } - else - { soap_revget1(soap); -#else - { -#endif - if (inflateInit(&soap->d_stream) != Z_OK) - return soap->error = SOAP_ZLIB_ERROR; - soap->zlib_state = SOAP_ZLIB_INFLATE; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate initialized\n")); - } - soap->mode |= SOAP_ENC_ZLIB; - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); - soap->d_stream.next_in = (Byte*)(soap->z_buf + soap->bufidx); - soap->d_stream.avail_in = soap->buflen - soap->bufidx; - soap->z_buflen = soap->buflen; - soap->buflen = soap->bufidx; - } -#endif - } -#ifndef WITH_LEANER - if (soap->mode & SOAP_ENC_MIME) - { if (soap_getmimehdr(soap)) - return soap->error; - if (soap_get_header_attribute(soap, soap->mime.first->type, "application/dime")) - soap->mode |= SOAP_ENC_DIME; - } - if (soap->mode & SOAP_ENC_DIME) - { if (soap_getdimehdr(soap)) - return soap->error; - if (soap->dime.flags & SOAP_DIME_CF) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked DIME SOAP message\n")); - soap->dime.chunksize = soap->dime.size; - if (soap->buflen - soap->bufidx >= soap->dime.chunksize) - { soap->dime.buflen = soap->buflen; - soap->buflen = soap->bufidx + soap->dime.chunksize; - } - else - soap->dime.chunksize -= soap->buflen - soap->bufidx; - } - soap->count = soap->buflen - soap->bufidx; - } -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_parse(struct soap *soap) -{ char header[SOAP_HDRLEN], *s; - unsigned short g = 0, k; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Waiting for response...\n")); - *soap->endpoint = '\0'; - soap->length = 0; - do - { if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf))) - return soap->error; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP status: %s\n", soap->msgbuf)); - for (;;) - { if (soap_getline(soap, header, SOAP_HDRLEN)) - return soap->error; - if (!*header) - break; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP header: %s\n", header)); - s = strchr(header, ':'); - if (s) - { *s = '\0'; - do s++; - while (*s && *s <= 32); - if ((soap->error = soap->fparsehdr(soap, header, s))) - return soap->error; - } - } - if ((s = strchr(soap->msgbuf, ' '))) - k = (unsigned short)soap_strtoul(s, NULL, 10); - else - k = 0; - } while (k == 100); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Finished HTTP header parsing\n")); - s = strstr(soap->msgbuf, "HTTP/"); - if (s && s[7] != '1') - { if (soap->keep_alive == 1) - soap->keep_alive = 0; - if (k == 0 && (soap->omode & SOAP_IO) == SOAP_IO_CHUNK) /* k == 0 for HTTP request */ - { soap->imode |= SOAP_IO_CHUNK; - soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_STORE; - } - } - if (soap->keep_alive < 0) - soap->keep_alive = 1; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Keep alive connection = %d\n", soap->keep_alive)); - if (s && (((g = !strncmp(soap->msgbuf, "GET ", 4))) || !strncmp(soap->msgbuf, "POST ", 5))) - { size_t m = strlen(soap->endpoint); - size_t n = m + (s - soap->msgbuf) - 5 - (!g); - if (n >= sizeof(soap->endpoint)) - n = sizeof(soap->endpoint) - 1; - strncpy(soap->path, soap->msgbuf + 4 + (!g), n - m); - soap->path[n - m] = '\0'; - strcat(soap->endpoint, soap->path); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Target endpoint='%s'\n", soap->endpoint)); - if (g) - { soap->error = soap->fget(soap); - if (soap->error == SOAP_OK) - soap->error = SOAP_STOP; /* prevents further processing */ - return soap->error; - } - return SOAP_OK; - } - if (k == 0 || (k >= 200 && k <= 299) || k == 400 || k == 500) - return SOAP_OK; - return soap_set_receiver_error(soap, "HTTP error", soap->msgbuf, k); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_parse_header(struct soap *soap, const char *key, const char *val) -{ if (!soap_tag_cmp(key, "Host")) - { -#ifdef WITH_OPENSSL - if (soap->imode & SOAP_ENC_SSL) - strcpy(soap->endpoint, "https://"); - else -#endif - strcpy(soap->endpoint, "http://"); - strncat(soap->endpoint, val, sizeof(soap->endpoint) - 8); - soap->endpoint[sizeof(soap->endpoint) - 1] = '\0'; - } -#ifndef WITH_LEANER - else if (!soap_tag_cmp(key, "Content-Type")) - { if (soap_get_header_attribute(soap, val, "application/dime")) - soap->mode |= SOAP_ENC_DIME; - else if (soap_get_header_attribute(soap, val, "multipart/related")) - { soap->mime.boundary = soap_strdup(soap, soap_get_header_attribute(soap, val, "boundary")); - soap->mime.start = soap_strdup(soap, soap_get_header_attribute(soap, val, "start")); - soap->mode |= SOAP_ENC_MIME; - } - } -#endif - else if (!soap_tag_cmp(key, "Content-Length")) - soap->length = soap_strtoul(val, NULL, 10); - else if (!soap_tag_cmp(key, "Content-Encoding")) - { if (!soap_tag_cmp(val, "deflate")) -#ifdef WITH_ZLIB - soap->zlib_in = SOAP_ZLIB_DEFLATE; -#else - return SOAP_ZLIB_ERROR; -#endif - else if (!soap_tag_cmp(val, "gzip")) -#ifdef WITH_GZIP - soap->zlib_in = SOAP_ZLIB_GZIP; -#else - return SOAP_ZLIB_ERROR; -#endif - } -#ifdef WITH_ZLIB - else if (!soap_tag_cmp(key, "Accept-Encoding")) - { -#ifdef WITH_GZIP - if (strchr(val, '*') || soap_get_header_attribute(soap, val, "gzip")) - soap->zlib_out = SOAP_ZLIB_GZIP; - else -#endif - if (strchr(val, '*') || soap_get_header_attribute(soap, val, "deflate")) - soap->zlib_out = SOAP_ZLIB_DEFLATE; - else - soap->zlib_out = SOAP_ZLIB_NONE; - } -#endif - else if (!soap_tag_cmp(key, "Transfer-Encoding")) - { soap->mode &= ~SOAP_IO; - if (!soap_tag_cmp(val, "chunked")) - soap->mode |= SOAP_IO_CHUNK; - } - else if (!soap_tag_cmp(key, "Connection")) - { if (!soap_tag_cmp(val, "keep-alive")) - soap->keep_alive = -soap->keep_alive; - else if (!soap_tag_cmp(val, "close")) - soap->keep_alive = 0; - } -#ifndef WITH_LEAN - else if (!soap_tag_cmp(key, "Authorization")) - { if (!soap_tag_cmp(val, "Basic *")) - { size_t n; - char *s; - soap_base642s(soap, val + 6, soap->tmpbuf, sizeof(soap->tmpbuf) - 1, &n); - soap->tmpbuf[n] = '\0'; - if ((s = strchr(soap->tmpbuf, ':'))) - { *s = '\0'; - soap->userid = soap_strdup(soap, soap->tmpbuf); - soap->passwd = soap_strdup(soap, s + 1); - } - } - } - else if (!soap_tag_cmp(key, "WWW-Authenticate")) - soap->authrealm = soap_strdup(soap, soap_get_header_attribute(soap, val+6, "realm")); - else if (!soap_tag_cmp(key, "Expect")) - { if (!soap_tag_cmp(val, "100-continue")) - { if ((soap->error = soap->fposthdr(soap, "HTTP/1.1 100 Continue", NULL)) - || (soap->error = soap->fposthdr(soap, NULL, NULL))) - return soap->error; - } - } -#endif - else if (!soap_tag_cmp(key, "SOAPAction")) - { if (val[0] && val[1]) - { soap->action = soap_strdup(soap, val + 1); - soap->action[strlen(soap->action) - 1] = '\0'; - } - } - else if (!soap_tag_cmp(key, "Location")) - { strncpy(soap->endpoint, val, sizeof(soap->endpoint)); - soap->endpoint[sizeof(soap->endpoint) - 1] = '\0'; - } -#ifdef WITH_COOKIES - else if (!soap_tag_cmp(key, "Cookie") || !soap_tag_cmp(key, "Set-Cookie")) - soap_getcookies(soap, val); -#endif - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_get_header_attribute(struct soap *soap, const char *line, const char *key) -{ register const char *s = line; - if (s) - { while (*s) - { register short flag; - s = soap_decode_key(soap->tmpbuf, sizeof(soap->tmpbuf), s); - flag = soap_tag_cmp(soap->tmpbuf, key); - s = soap_decode_val(soap->tmpbuf, sizeof(soap->tmpbuf), s); - if (!flag) - return soap->tmpbuf; - } - } - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_decode_key(char *buf, size_t len, const char *val) -{ return soap_decode(buf, len, val, "=,;"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_decode_val(char *buf, size_t len, const char *val) -{ if (*val != '=') - { *buf = '\0'; - return val; - } - return soap_decode(buf, len, val + 1, ",;"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -soap_decode(char *buf, size_t len, const char *val, const char *sep) -{ const char *s; - char *t = buf; - for (s = val; *s; s++) - if (*s != ' ' && *s != '\t' && !strchr(sep, *s)) - break; - if (*s == '"') - { s++; - while (*s && *s != '"' && --len) - *t++ = *s++; - } - else - { while (soap_notblank(*s) && !strchr(sep, *s) && --len) - { if (*s == '%') - { *t++ = ((s[1] >= 'A' ? (s[1] & 0x7) + 9 : s[1] - '0') << 4) - + (s[2] >= 'A' ? (s[2] & 0x7) + 9 : s[2] - '0'); - s += 3; - } - else - *t++ = *s++; - } - } - *t = '\0'; - while (*s && !strchr(sep, *s)) - s++; - return s; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_begin_out(struct soap *soap) -{ -#ifndef WITH_LEANER - size_t n = 0; - if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary && soap->mime.start) - { const char *s; - if (soap->mode & SOAP_ENC_DIME) - s = "application/dime"; - else if (soap->version == 2) - s = "application/soap+xml; charset=utf-8"; - else - s = "text/xml; charset=utf-8"; - sprintf(soap->tmpbuf, "--%s\r\nContent-Type: %s\r\nContent-Transfer-Encoding: binary\r\nContent-ID: %s\r\n\r\n", soap->mime.boundary, s, soap->mime.start); - n = strlen(soap->tmpbuf); - if (soap_send_raw(soap, soap->tmpbuf, n)) - return soap->error; - } - if (soap->mode & SOAP_IO_LENGTH) - soap->dime.size = soap->count; /* DIME in MIME correction */ - if (!(soap->mode & SOAP_IO_LENGTH) && (soap->mode & SOAP_ENC_DIME)) - { if (soap_putdimehdr(soap)) - return soap->error; - } -#endif - soap->part = SOAP_IN_ENVELOPE; - return soap_element_begin_out(soap, "SOAP-ENV:Envelope", 0, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_end_out(struct soap *soap) -{ if (soap_element_end_out(soap, "SOAP-ENV:Envelope")) - return soap->error; -#ifndef WITH_LEANER - if ((soap->mode & SOAP_IO_LENGTH) && (soap->mode & SOAP_ENC_DIME)) - { soap->dime.size = soap->count - soap->dime.size; /* DIME in MIME correction */ - sprintf(soap->id, soap->dime_id_format, 0); - soap->dime.id = soap->id; - if (soap->local_namespaces) - { if (soap->local_namespaces[0].out) - soap->dime.type = (char*)soap->local_namespaces[0].out; - else - soap->dime.type = (char*)soap->local_namespaces[0].ns; - } - soap->dime.options = NULL; - soap->dime.flags = SOAP_DIME_MB | SOAP_DIME_ABSURI; - if (!soap->dime.first) - soap->dime.flags |= SOAP_DIME_ME; - soap->count += 12 + ((strlen(soap->dime.id)+3)&(~3)) + ((strlen(soap->dime.type)+3)&(~3)); - } - if (soap->mode & SOAP_ENC_DIME) - return soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime.size&3); -#endif - soap->part = SOAP_END_ENVELOPE; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_begin_in(struct soap *soap) -{ register struct Namespace *p; - soap->part = SOAP_IN_ENVELOPE; - if (soap_element_begin_in(soap, "SOAP-ENV:Envelope", 0)) - return soap->error = SOAP_VERSIONMISMATCH; - p = soap->local_namespaces; - if (p) - { const char *ns = p[0].out; - if (!ns) - ns = p[0].ns; - if (!strcmp(ns, soap_env1)) - { soap->version = 1; /* make sure we use SOAP 1.1 */ - if (p[1].out) - SOAP_FREE(p[1].out); - if ((p[1].out = (char*)SOAP_MALLOC(sizeof(soap_enc1)))) - strcpy(p[1].out, soap_enc1); - } - else if (!strcmp(ns, soap_env2)) - { soap->version = 2; /* make sure we use SOAP 1.2 */ - if (p[1].out) - SOAP_FREE(p[1].out); - if ((p[1].out = (char*)SOAP_MALLOC(sizeof(soap_enc2)))) - strcpy(p[1].out, soap_enc2); - } - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_envelope_end_in(struct soap *soap) -{ if (soap_element_end_in(soap, "SOAP-ENV:Envelope")) - return soap->error; - soap->part = SOAP_END_ENVELOPE; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_begin_out(struct soap *soap) -{ soap->part = SOAP_IN_BODY; - if (soap->version == 1) - soap->encoding = 1; - if (soap_element(soap, "SOAP-ENV:Body", 0, NULL)) - return soap->error; - if ((soap->mode & SOAP_XML_SEC) && soap_attribute(soap, "id", "_0")) - return soap->error; - return soap_element_start_end_out(soap, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_end_out(struct soap *soap) -{ if (soap_element_end_out(soap, "SOAP-ENV:Body")) - return soap->error; - soap->part = SOAP_IN_BODY; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_begin_in(struct soap *soap) -{ soap->part = SOAP_IN_BODY; - return soap_element_begin_in(soap, "SOAP-ENV:Body", 0); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_body_end_in(struct soap *soap) -{ if (soap_element_end_in(soap, "SOAP-ENV:Body")) - return soap->error; - soap->part = SOAP_END_BODY; - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_header(struct soap *soap) -{ if (soap_getheader(soap) && soap->error == SOAP_TAG_MISMATCH) - soap->error = SOAP_OK; - return soap->error; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_endpoint(struct soap *soap, const char *endpoint) -{ register const char *s; - register size_t i, n; - *soap->endpoint = '\0'; - *soap->host = '\0'; - *soap->path = '\0'; - soap->port = 80; - if (!endpoint || !*endpoint) - return; -#ifdef WITH_OPENSSL - if (!strncmp(endpoint, "https:", 6)) - soap->port = 443; -#endif - strncpy(soap->endpoint, endpoint, sizeof(soap->endpoint) - 1); - s = strchr(endpoint, ':'); - if (s && s[1] == '/' && s[2] == '/') - s += 3; - else - s = endpoint; - n = strlen(s); - if (n >= sizeof(soap->host)) - n = sizeof(soap->host) - 1; -/* WR[ */ -#ifdef WITH_IPV6 - if ('[' == s[0]) - { s++; - for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (']' == s[i]) - { - s++; - break; - } - } - } - else - { for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (s[i] == '/' || s[i] == ':') - break; - } - } -#else /* WITH_IPV6 */ -/* ]WR */ - for (i = 0; i < n; i++) - { soap->host[i] = s[i]; - if (s[i] == '/' || s[i] == ':') - break; - } -/* WR[ */ -#endif /* WITH_IPV6 */ -/* ]WR */ - soap->host[i] = '\0'; - if (s[i] == ':') - { soap->port = (int)atol(s + i + 1); - for (i++; i < n; i++) - if (s[i] == '/') - break; - } - if (s[i]) - { strncpy(soap->path, s + i + 1, sizeof(soap->path)); - soap->path[sizeof(soap->path) - 1] = '\0'; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_connect(struct soap *soap, const char *endpoint, const char *action) -{ return soap_connect_command(soap, SOAP_POST, endpoint, action); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_connect_command(struct soap *soap, int http_command, const char *endpoint, const char *action) -{ char host[sizeof(soap->host)]; - int port; - size_t count; - soap->error = SOAP_OK; - strcpy(host, soap->host); /* save to compare */ - port = soap->port; /* save to compare */ - soap_set_endpoint(soap, endpoint); - if (action) - soap->action = soap_strdup(soap, action); - if (soap->fconnect) - { - if ((soap->error = soap->fconnect(soap, endpoint, soap->host, soap->port))) - return soap->error; - } - else if (*soap->host) - { soap->status = http_command; - if (!soap_valid_socket(soap->socket) || strcmp(soap->host, host) || soap->port != port) - { soap->keep_alive = 0; /* force close */ - soap_closesock(soap); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Connect to host='%s' path='%s' port=%d\n", soap->host, soap->path, soap->port)); - soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port); - if (soap->error) - return soap->error; - soap->keep_alive = ((soap->omode & SOAP_IO_KEEPALIVE) != 0); - } - else if (!soap->keep_alive || !soap->fpoll || soap->fpoll(soap)) - { soap->keep_alive = 0; /* force close */ - soap_closesock(soap); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Reconnect to host='%s' path='%s' port=%d\n", soap->host, soap->path, soap->port)); - soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port); - if (soap->error) - return soap->error; - } - } - if (soap_begin_send(soap)) - return soap->error; - count = soap_count_attachments(soap); - if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML) && endpoint) - { unsigned int k = soap->mode; - soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB); - if ((k & SOAP_IO) != SOAP_IO_FLUSH) - soap->mode |= SOAP_IO_BUFFER; - if ((soap->error = soap->fpost(soap, endpoint, soap->host, soap->port, soap->path, action, count))) - return soap->error; - if ((k & SOAP_IO) == SOAP_IO_CHUNK) - { if (soap_flush(soap)) - return soap->error; - } - soap->mode = k; - } - if (http_command != SOAP_POST) - return soap_end_send(soap); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -char* -SOAP_FMAC2 -soap_s2base64(struct soap *soap, const unsigned char *s, char *t, size_t n) -{ register size_t i; - register unsigned long m; - register char *p; - if (!t) - t = (char*)soap_malloc(soap, (n + 2) / 3 * 4 + 1); - if (!t) - { soap->error = SOAP_EOM; - return NULL; - } - p = t; - t[0] = '\0'; - if (!s) - return p; - for (; n > 2; n -= 3, s += 3) - { m = s[0]; - m = (m << 8) | s[1]; - m = (m << 8) | s[2]; - for (i = 4; i > 0; m >>= 6) - t[--i] = soap_base64o[m & 0x3F]; - t += 4; - } - t[0] = '\0'; - if (n > 0) - { m = 0; - for (i = 0; i < n; i++) - m = (m << 8) | *s++; - for (; i < 3; i++) - m <<= 8; - for (i++; i > 0; m >>= 6) - t[--i] = soap_base64o[m & 0x3F]; - for (i = 3; i > n; i--) - t[i] = '='; - t[4] = '\0'; - } - return p; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -SOAP_FMAC1 -const char* -SOAP_FMAC2 -soap_base642s(struct soap *soap, const char *s, char *t, size_t l, size_t *n) -{ register int i, j, c; - register unsigned long m; - char *p = t; - if (n) - *n = 0; - for (;;) - { for (i = 0; i < SOAP_BLKLEN; i++) - { m = 0; - j = 0; - while (j < 4) - { c = *s++; - if (c == '=' || !c) - { i *= 3; - switch (j) - { case 2: - *t++ = (char)((m >> 4) & 0xFF); - i++; - break; - case 3: - *t++ = (char)((m >> 10) & 0xFF); - *t++ = (char)((m >> 2) & 0xFF); - i += 2; - } - if (n) - *n += i; - return p; - } - c -= '+'; - if (c >= 0 && c <= 79) - { m = (m << 6) + soap_base64i[c]; - j++; - } - } - *t++ = (char)((m >> 16) & 0xFF); - *t++ = (char)((m >> 8) & 0xFF); - *t++ = (char)(m & 0xFF); - if (l < 3) - { if (n) - *n += i; - return p; - } - l -= 3; - } - if (n) - *n += 3 * SOAP_BLKLEN; - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_puthttphdr(struct soap *soap, int status, size_t count) -{ register const char *s; - register int err; - if (status == SOAP_FILE) - s = soap->http_content; - else if (status == SOAP_HTML) - s = "text/html; charset=utf-8"; -#ifndef WITH_LEANER - else if (soap->mode & SOAP_ENC_DIME) - s = "application/dime"; -#endif - else if (soap->version == 2) - s = "application/soap+xml; charset=utf-8"; - else - s = "text/xml; charset=utf-8"; -#ifndef WITH_LEANER - if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary && soap->mime.start && soap->status != SOAP_GET) - { sprintf(soap->tmpbuf, "multipart/related; boundary=\"%s\"; type=%s; start=\"%s\"", soap->mime.boundary, s, soap->mime.start); - s = soap->tmpbuf; - } -#endif - if ((err = soap->fposthdr(soap, "Content-Type", s))) - return err; -#ifdef WITH_ZLIB - if (soap->omode & SOAP_ENC_ZLIB) - { -#ifdef WITH_GZIP - err = soap->fposthdr(soap, "Content-Encoding", "gzip"); -#else - err = soap->fposthdr(soap, "Content-Encoding", "deflate"); -#endif - if (err) - return err; - } -#endif - if ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK) - err = soap->fposthdr(soap, "Transfer-Encoding", "chunked"); - else if (count > 0) - { sprintf(soap->tmpbuf, "%lu", (unsigned long)count); - err = soap->fposthdr(soap, "Content-Length", soap->tmpbuf); - } - if (err) - return err; - return soap->fposthdr(soap, "Connection", soap->keep_alive ? "keep-alive" : "close"); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_get(struct soap *soap) -{ return SOAP_GET_METHOD; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_post(struct soap *soap, const char *endpoint, const char *host, int port, const char *path, const char *action, size_t count) -{ register const char *s; - register int err; - if (soap->status == SOAP_GET) - { s = "GET"; - count = 0; - } - else - s = "POST"; -#ifdef PALM - if (!endpoint || (strncmp(endpoint, "http:", 5) && strncmp(endpoint, "https:", 6) && strncmp(endpoint, "httpg:", 6)) && strncmp(endpoint, "_beam:", 6) && strncmp(endpoint, "_local:", 7) && strncmp(endpoint, "_btobex:", 8)) -#else - if (!endpoint || (strncmp(endpoint, "http:", 5) && strncmp(endpoint, "https:", 6) && strncmp(endpoint, "httpg:", 6))) -#endif - return SOAP_OK; - if (soap->proxy_host && strncmp(endpoint, "https:", 6)) - sprintf(soap->tmpbuf, "%s %s HTTP/%s", s, endpoint, soap->http_version); - else - sprintf(soap->tmpbuf, "%s /%s HTTP/%s", s, path, soap->http_version); - if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return err; - if (port != 80) - sprintf(soap->tmpbuf, "%s:%d", host, port); - else - strcpy(soap->tmpbuf, host); - if ((err = soap->fposthdr(soap, "Host", soap->tmpbuf)) - || (err = soap->fposthdr(soap, "User-Agent", "gSOAP/2.7")) - || (err = soap_puthttphdr(soap, SOAP_OK, count))) - return err; -#ifdef WITH_ZLIB -#ifdef WITH_GZIP - if ((err = soap->fposthdr(soap, "Accept-Encoding", "gzip, deflate"))) -#else - if ((err = soap->fposthdr(soap, "Accept-Encoding", "deflate"))) -#endif - return err; -#endif -#ifndef WITH_LEAN - if (soap->userid && soap->passwd && strlen(soap->userid) + strlen(soap->passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->userid, soap->passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((err = soap->fposthdr(soap, "Authorization", soap->tmpbuf))) - return err; - } - if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761) - { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); - strcpy(soap->tmpbuf, "Basic "); - soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, strlen(soap->tmpbuf + 262)); - if ((err = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) - return err; - } -#endif -#ifdef WITH_COOKIES -#ifdef WITH_OPENSSL - if (soap_putcookies(soap, host, path, soap->ssl != NULL)) - return soap->error; -#else - if (soap_putcookies(soap, host, path, 0)) - return soap->error; -#endif -#endif - if (action && soap->version == 1) - { sprintf(soap->tmpbuf, "\"%s\"", action); - if ((err = soap->fposthdr(soap, "SOAPAction", soap->tmpbuf))) - return err; - } - return soap->fposthdr(soap, NULL, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_send_header(struct soap *soap, const char *s) -{ register const char *t; - do - { t = strchr(s, '\n'); /* disallow \n in HTTP headers */ - if (!t) - t = s + strlen(s); - if (soap_send_raw(soap, s, t - s)) - return soap->error; - s = t + 1; - } while (*t); - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_post_header(struct soap *soap, const char *key, const char *val) -{ if (key) - { if (http_send_header(soap, key)) - return soap->error; - if (val && (soap_send_raw(soap, ": ", 2) || http_send_header(soap, val))) - return soap->error; - } - return soap_send_raw(soap, "\r\n", 2); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static int -http_response(struct soap *soap, int status, size_t count) -{ register int err; -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid) - httpOutputEnable(soap->rpmreqid); -#endif /* WMW_RPM_IO */ -/* ]WR */ - if (!status || status == SOAP_HTML || status == SOAP_FILE) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "OK 200\n")); -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ -#else -/* ]WR */ - if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */ -/* WR[ */ -#endif /* WMW_RPM_IO */ -/* ]WR */ - { sprintf(soap->tmpbuf, "HTTP/%s 200 OK", soap->http_version); - if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return err; - } - else if ((err = soap->fposthdr(soap, "Status", "200 OK"))) - return err; - } - else if (status > 200 && status < 600) - { sprintf(soap->tmpbuf, "HTTP/%s %d %s", soap->http_version, status, http_error(soap, status)); - if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return err; - if (status == 401) - { sprintf(soap->tmpbuf, "Basic realm=\"%s\"", soap->authrealm ? soap->authrealm : "gSOAP Web Service"); - if ((err = soap->fposthdr(soap, "WWW-Authenticate", soap->tmpbuf))) - return err; - } - else if ((status >= 301 && status <= 303) || status == 307) - { if ((err = soap->fposthdr(soap, "Location", soap->endpoint))) - return err; - } - } - else - { const char *s = *soap_faultcode(soap); - if (soap->version == 2 && !strcmp(s, "SOAP-ENV:Sender")) - s = "400 Bad Request"; - else - s = "500 Internal Server Error"; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error %s (status=%d)\n", s, status)); -/* WR[ */ -#ifdef WMW_RPM_IO - if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ -#else -/* ]WR */ - if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */ -/* WR[ */ -#endif /* WMW_RPM_IO */ -/* ]WR */ - { sprintf(soap->tmpbuf, "HTTP/%s %s", soap->http_version, s); - if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) - return err; - } - else if ((err = soap->fposthdr(soap, "Status", s))) - return err; - } - if ((err = soap->fposthdr(soap, "Server", "gSOAP/2.7")) - || (err = soap_puthttphdr(soap, status, count))) - return err; -#ifdef WITH_COOKIES - if (soap_putsetcookies(soap)) - return soap->error; -#endif - return soap->fposthdr(soap, NULL, NULL); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_response(struct soap *soap, int status) -{ register size_t count; - if (!(soap->omode & (SOAP_ENC_XML | SOAP_IO_STORE /* this tests for chunking too */)) - && (status == SOAP_HTML || status == SOAP_FILE)) - { soap->omode &= ~SOAP_IO; - soap->omode |= SOAP_IO_STORE; - } - soap->status = status; - count = soap_count_attachments(soap); - if (soap_begin_send(soap)) - return soap->error; - if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML)) - { register int n = soap->mode; - soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB); - if ((n & SOAP_IO) != SOAP_IO_FLUSH) - soap->mode |= SOAP_IO_BUFFER; - if ((soap->error = soap->fresponse(soap, status, count))) - return soap->error; - if ((n & SOAP_IO) == SOAP_IO_CHUNK) - { if (soap_flush(soap)) - return soap->error; - } - soap->mode = n; - } - return SOAP_OK; -} -#endif - -/******************************************************************************/ -#ifndef WITH_LEAN -static const char* -soap_set_validation_fault(struct soap *soap, const char *s, const char *t) -{ sprintf(soap->msgbuf, "Validation constraint violation: %s%s in element <%s>", s, t?t:SOAP_STR_EOS, soap->tag); - return soap->msgbuf; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_set_fault(struct soap *soap) -{ const char **c = soap_faultcode(soap); - const char **s = soap_faultstring(soap); - if (!*c) - { if (soap->version == 2) - *c = "SOAP-ENV:Sender"; - else - *c = "SOAP-ENV:Client"; - } - if (*s) - return; - switch (soap->error) - { -#ifndef WITH_LEAN - case SOAP_CLI_FAULT: - *s = "Client fault"; - break; - case SOAP_SVR_FAULT: - *s = "Server fault"; - break; - case SOAP_TAG_MISMATCH: - *s = soap_set_validation_fault(soap, "tag name or namespace mismatch", NULL); - break; - case SOAP_TAG_END: - *s = soap_set_validation_fault(soap, "incorrect end tag", NULL); - break; - case SOAP_TYPE: - *s = soap_set_validation_fault(soap, "data type mismatch ", soap->type); - break; - case SOAP_SYNTAX_ERROR: - *s = "Well-formedness constraint violation"; - break; - case SOAP_NO_TAG: - *s = "No XML element tag found"; - break; - case SOAP_MUSTUNDERSTAND: - *c = "SOAP-ENV:MustUnderstand"; - sprintf(soap->msgbuf, "The data in element '%s' must be understood but cannot be handled", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_VERSIONMISMATCH: - *c = "SOAP-ENV:VersionMismatch"; - *s = "SOAP version mismatch or invalid SOAP message"; - break; - case SOAP_DATAENCODINGUNKNOWN: - *c = "SOAP-ENV:DataEncodingUnknown"; - *s = "Unsupported SOAP data encoding"; - break; - case SOAP_NAMESPACE: - *s = soap_set_validation_fault(soap, "namespace mismatch", NULL); - break; - case SOAP_FATAL_ERROR: - *s = "Fatal error"; - break; - case SOAP_NO_METHOD: - sprintf(soap->msgbuf, "Method '%s' not implemented: method name or namespace not recognized", soap->tag); - *s = soap->msgbuf; - break; - case SOAP_GET_METHOD: - *s = "HTTP GET method not implemented"; - break; - case SOAP_EOM: - *s = "Out of memory"; - break; - case SOAP_IOB: - *s = "Array index out of bounds"; - break; - case SOAP_NULL: - *s = soap_set_validation_fault(soap, "nil not allowed", NULL); - break; - case SOAP_MULTI_ID: - *s = soap_set_validation_fault(soap, "multiple definitions of id ", soap->id); - break; - case SOAP_MISSING_ID: - *s = soap_set_validation_fault(soap, "missing id for ref ", soap->id); - break; - case SOAP_HREF: - *s = soap_set_validation_fault(soap, "incompatible object ref ", soap->id); - break; - case SOAP_FAULT: - break; - case SOAP_TCP_ERROR: - *s = tcp_error(soap); - break; - case SOAP_HTTP_ERROR: - *s = "HTTP error"; - break; - case SOAP_SSL_ERROR: - *s = "SSL error"; - break; - case SOAP_PLUGIN_ERROR: - *s = "Plugin registry error"; - break; - case SOAP_DIME_MISMATCH: - *s = "DIME version/transmission error"; - break; - case SOAP_DIME_END: - *s = "End of DIME error"; - break; - case SOAP_DIME_ERROR: - *s = "DIME format error"; - break; - case SOAP_MIME_ERROR: - *s = "MIME format error"; - break; - case SOAP_ZLIB_ERROR: -#ifdef WITH_ZLIB - sprintf(soap->msgbuf, "Zlib/gzip error: '%s'", soap->d_stream.msg?soap->d_stream.msg:""); - *s = soap->msgbuf; -#else - *s = "Zlib not installed for required message (de)compression"; -#endif - break; - case SOAP_REQUIRED: - *s = soap_set_validation_fault(soap, "missing required attribute", NULL); - break; - case SOAP_PROHIBITED: - *s = soap_set_validation_fault(soap, "prohibited attribute present", NULL); - break; - case SOAP_OCCURS: - *s = soap_set_validation_fault(soap, "a min/maxOccurs violation was detected", NULL); - break; - case SOAP_LENGTH: - *s = soap_set_validation_fault(soap, "content length violation", NULL); - break; -#endif - case SOAP_EOF: - sprintf(soap->msgbuf, "End of file or no input: '%s'", soap_strerror(soap)); - *s = soap->msgbuf; - break; - default: - if (soap->error > 200 && soap->error < 600) - { sprintf(soap->msgbuf, "HTTP Error: '%s'", http_error(soap, soap->error)); - *s = soap->msgbuf; - } - else - { sprintf(soap->msgbuf, "Error code %d", soap->error); - *s = soap->msgbuf; - } - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_send_fault(struct soap *soap) -{ register int status = soap->error; - if (status == SOAP_STOP) - return status; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Sending back fault struct for error code %d\n", soap->error)); - soap->keep_alive = 0; /* to terminate connection */ - soap_set_fault(soap); - if ((status != SOAP_EOF || (!soap->recv_timeout && !soap->send_timeout)) && (!soap->fpoll || soap->fpoll(soap) == SOAP_OK)) - { soap->error = SOAP_OK; - soap_serializeheader(soap); - soap_serializefault(soap); - soap_begin_count(soap); - if (soap->mode & SOAP_IO_LENGTH) - { soap_envelope_begin_out(soap); - soap_putheader(soap); - soap_body_begin_out(soap); - soap_putfault(soap); - soap_body_end_out(soap); - soap_envelope_end_out(soap); - } - if (soap_response(soap, status) - || soap_envelope_begin_out(soap) - || soap_putheader(soap) - || soap_body_begin_out(soap) - || soap_putfault(soap) - || soap_body_end_out(soap) - || soap_envelope_end_out(soap)) - return soap_closesock(soap); - soap_end_send(soap); - } - soap->error = status; - return soap_closesock(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_recv_fault(struct soap *soap) -{ register int status = soap->error; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Receiving SOAP Fault\n")); - soap->error = SOAP_OK; - if (soap_getfault(soap)) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Error: soap_get_soapfault() failed. Is this a SOAP message at all?\n")); - *soap_faultcode(soap) = (soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client"); - soap->error = status; - soap_set_fault(soap); - } - else - { register const char *s = *soap_faultcode(soap); - if (!soap_match_tag(soap, s, "SOAP-ENV:Server") || !soap_match_tag(soap, s, "SOAP-ENV:Receiver")) - status = SOAP_SVR_FAULT; - else if (!soap_match_tag(soap, s, "SOAP-ENV:Client") || !soap_match_tag(soap, s, "SOAP-ENV:Sender")) - status = SOAP_CLI_FAULT; - else if (!soap_match_tag(soap, s, "SOAP-ENV:MustUnderstand")) - status = SOAP_MUSTUNDERSTAND; - else if (!soap_match_tag(soap, s, "SOAP-ENV:VersionMismatch")) - status = SOAP_VERSIONMISMATCH; - else - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Fault code %s\n", s)); - status = SOAP_FAULT; - } - if (soap_body_end_in(soap) - || soap_envelope_end_in(soap) - || soap_end_recv(soap)) - return soap_closesock(soap); - soap->error = status; - } - return soap_closesock(soap); -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static const char* -soap_strerror(struct soap *soap) -{ int err = soap->errnum; - if (!err) - err = soap_errno; - if (err) - { -#ifndef UNDER_CE - return strerror(err); -#else - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, 0, (LPTSTR)&soap->werrorstr, sizeof(soap->werrorstr), NULL); - wcstombs(soap->errorstr, soap->werrorstr, sizeof(soap->errorstr)); - return soap->errorstr; -#endif - } - return "Operation interrupted or timed out"; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static int -soap_set_error(struct soap *soap, const char *faultcode, const char *faultstring, const char *faultdetail, int soaperror) -{ *soap_faultcode(soap) = faultcode; - *soap_faultstring(soap) = faultstring; - if (faultdetail && *faultdetail) - { register const char **s = soap_faultdetail(soap); - if (s) - *s = faultdetail; - } - return soap->error = soaperror; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_sender_error(struct soap *soap, const char *faultstring, const char *faultdetail, int soaperror) -{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", faultstring, faultdetail, soaperror); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_set_receiver_error(struct soap *soap, const char *faultstring, const char *faultdetail, int soaperror) -{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", faultstring, faultdetail, soaperror); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -static int -soap_copy_fault(struct soap *soap, const char *faultcode, const char *faultstring, const char *faultdetail) -{ char *s = NULL, *t = NULL; - if (faultstring) - s = soap_strdup(soap, faultstring); - if (faultdetail) - t = soap_strdup(soap, faultdetail); - return soap_set_error(soap, faultcode, s, t, SOAP_FAULT); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_sender_fault(struct soap *soap, const char *faultstring, const char *faultdetail) -{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", faultstring, faultdetail); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_receiver_fault(struct soap *soap, const char *faultstring, const char *faultdetail) -{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", faultstring, faultdetail); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_print_fault(struct soap *soap, FILE *fd) -{ if (soap->error) - { const char **s; - if (!*soap_faultcode(soap)) - soap_set_fault(soap); - fprintf(fd, "SOAP FAULT: %s\n\"%s\"\n", *soap_faultcode(soap), *soap_faultstring(soap)); - s = soap_faultdetail(soap); - if (s && *s) - fprintf(fd, "Detail: %s\n", *s); - } -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -void -SOAP_FMAC2 -soap_print_fault_location(struct soap *soap, FILE *fd) -{ -#ifndef WITH_LEAN - int c; - if (soap->error && soap->buflen > 0) - { if (soap->bufidx == 0) - soap->bufidx = 1; - c = soap->buf[soap->bufidx - 1]; - soap->buf[soap->bufidx - 1] = '\0'; - if (soap->buflen - soap->bufidx > 1024) - soap->buf[soap->bufidx + 1024] = '\0'; - else - soap->buf[soap->buflen - 1] = '\0'; - fprintf(fd, "%s%c\n** HERE **\n", soap->buf, c); - if (soap->bufidx < soap->buflen) - fprintf(fd, "%s\n", soap->buf + soap->bufidx); - } -#endif -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_register_plugin_arg(struct soap *soap, int (*fcreate)(struct soap*, struct soap_plugin*, void*), void *arg) -{ register struct soap_plugin *p; - register int r; - if (!(p = (struct soap_plugin*)SOAP_MALLOC(sizeof(struct soap_plugin)))) - return soap->error = SOAP_EOM; - p->id = NULL; - p->data = NULL; - p->fcopy = NULL; - p->fdelete = NULL; - r = fcreate(soap, p, arg); - if (!r && p->fdelete) - { p->next = soap->plugins; - soap->plugins = p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Registered '%s' plugin\n", p->id)); - return SOAP_OK; - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not register plugin '%s': plugin returned error %d (or fdelete callback not set)\n", p->id?p->id:"?", r)); - SOAP_FREE(p); - return r; -} -#endif - -/******************************************************************************/ -#ifndef PALM_1 -static void * -fplugin(struct soap *soap, const char *id) -{ register struct soap_plugin *p; - for (p = soap->plugins; p; p = p->next) - if (p->id == id || !strcmp(p->id, id)) - return p->data; - return NULL; -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -void * -SOAP_FMAC2 -soap_lookup_plugin(struct soap *soap, const char *id) -{ return soap->fplugin(soap, id); -} -#endif - -/******************************************************************************/ -#ifdef __cplusplus -} -#endif - diff --git a/org.glite.lb.server/examples/ws_getversion.c b/org.glite.lb.server/examples/ws_getversion.c deleted file mode 100644 index 89bea11..0000000 --- a/org.glite.lb.server/examples/ws_getversion.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include - -#include "glite/lb/consumer.h" - -#include "ws_plugin.h" -#include "bk_ws_H.h" - -static struct option opts[] = { - {"help", 0, NULL, 'h'}, - {"server", 1, NULL, 'm'}, -}; - -static void usage(char *me) -{ - fprintf(stderr,"usage: %s [option]\n" - "\t-h, --help Shows this screen.\n" - "\t-m, --server BK server address:port.\n" - , me); -} - -static void printstat(edg_wll_JobStat stat, int level); - -int main(int argc,char** argv) -{ - edg_wll_Context ctx; - struct soap *mydlo = soap_new(); - struct edgwll2__GetVersionResponse out; - int opt, err; - char *server = "http://localhost:8999/", - *name = NULL; - - - name = strrchr(argv[0],'/'); - if (name) name++; else name = argv[0]; - - while ((opt = getopt_long(argc, argv, "hm:", opts, NULL)) != EOF) switch (opt) - { - case 'h': usage(name); return 0; - case 'm': server = strdup(optarg); break; - case '?': usage(name); return 1; - } - - edg_wll_InitContext(&ctx); - - if ( soap_register_plugin_arg(mydlo, edg_wll_ws_plugin, (void *)ctx) ) - { - soap_print_fault(mydlo, stderr); - return 1; - } - - switch (err = soap_call_edgwll2__GetVersion(mydlo, server, "", &out)) - { - case SOAP_OK: printf("Server version: %s\n", out.version); break; - case SOAP_FAULT: - default: printf("???\n"); - } - - return 0; -} diff --git a/org.glite.lb.server/examples/ws_jobstat.c b/org.glite.lb.server/examples/ws_jobstat.c deleted file mode 100644 index 0b64399..0000000 --- a/org.glite.lb.server/examples/ws_jobstat.c +++ /dev/null @@ -1,161 +0,0 @@ -#include -#include - -#include "glite/lb/consumer.h" - -#include "ws_plugin.h" -#include "bk_ws_H.h" - -static struct option opts[] = { - {"help", 0, NULL, 'h'}, - {"server", 1, NULL, 'm'}, - {"jobid", 1, NULL, 'j'} -}; - -static void usage(char *me) -{ - fprintf(stderr,"usage: %s [option]\n" - "\t-h, --help Shows this screen.\n" - "\t-m, --server BK server address:port.\n" - "\t-j, --jobid ID of requested job.\n" - , me); -} - -static void printstat(edg_wll_JobStat stat, int level); - -int main(int argc,char** argv) -{ - edg_wll_Context ctx; - struct soap *mydlo = soap_new(); - struct edgwll2__JobStatusResponse out; - int opt, err; - char *server = "http://localhost:8999/", - *jobid = NULL, - *name = NULL; - - - name = strrchr(argv[0],'/'); - if (name) name++; else name = argv[0]; - - while ((opt = getopt_long(argc, argv, "hm:j:", opts, NULL)) != EOF) switch (opt) - { - case 'h': usage(name); return 0; - case 'm': server = strdup(optarg); break; - case 'j': jobid = strdup(optarg); break; - case '?': usage(name); return 1; - } - - if ( !jobid ) - { - printf("jobid should be given\n"); - usage(name); - return 1; - } - - edg_wll_InitContext(&ctx); - - if ( soap_register_plugin_arg(mydlo, edg_wll_ws_plugin, (void *)ctx) ) - { - soap_print_fault(mydlo, stderr); - return 1; - } - - switch (err = soap_call_edgwll2__JobStatus(mydlo, server, "", jobid,0,&out)) - { - case SOAP_OK: - { - edg_wll_JobStat s; - - edg_wll_SoapToStatus(mydlo,out.status,&s); - printstat(s, 0); - } - break; - case SOAP_FAULT: - case SOAP_SVR_FAULT: - { - char *et,*ed; - - edg_wll_FaultToErr(mydlo,ctx); - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"%s: %s (%s)\n",argv[0],et,ed); - exit(1); - } - default: - fprintf(stderr,"err = %d\n",err); - soap_print_fault(mydlo,stderr); - } - - return 0; -} - -static void printstat(edg_wll_JobStat stat, int level) -{ - char *s, *j, ind[10]; - int i; - - - for (i=0; i < level; i++) - ind[i]='\t'; - ind[i]='\0'; - - s = edg_wll_StatToString(stat.state); -/* print whole flat structure */ - printf("%sstate : %s\n", ind, s); - printf("%sjobId : %s\n", ind, j = edg_wlc_JobIdUnparse(stat.jobId)); - printf("%sowner : %s\n", ind, stat.owner); - printf("%sjobtype : %s\n", ind, (stat.jobtype ? "DAG" : "SIMPLE") ); - printf("%sparent_job : %s\n", ind, - j = edg_wlc_JobIdUnparse(stat.parent_job)); - if (stat.jobtype) {; - printf("%sseed : %s\n", ind, stat.seed); - printf("%schildren_num : %d\n", ind, stat.children_num); - printf("%schildren :\n", ind); - if (stat.children) - for (i=0; stat.children[i]; i++) - printf("%s\tchildren : %s\n", ind, stat.children[i]); - printf("%schildren_states :\n", ind); - if (stat.children_states) - for (i=0; stat.children_states[i].state; i++) - printstat(stat.children_states[i], level+1); - printf("%schildren_hist :\n",ind); - if (stat.children_hist) - for (i=1; i<=stat.children_hist[0]; i++) - printf("%s%14s %d\n", ind, edg_wll_StatToString(i-1),stat.children_hist[i]); - } - printf("%scondorId : %s\n", ind, stat.condorId); - printf("%sglobusId : %s\n", ind, stat.globusId); - printf("%slocalId : %s\n", ind, stat.localId); - printf("%sjdl : %s\n", ind, stat.jdl); - printf("%smatched_jdl : %s\n", ind, stat.matched_jdl); - printf("%sdestination : %s\n", ind, stat.destination); - printf("%snetwork server : %s\n", ind, stat.network_server); - printf("%scondor_jdl : %s\n", ind, stat.condor_jdl); - printf("%srsl : %s\n", ind, stat.rsl); - printf("%sreason : %s\n", ind, stat.reason); - printf("%slocation : %s\n", ind, stat.location); - printf("%ssubjob_failed : %d\n", ind, stat.subjob_failed); - printf("%sdone_code : %d\n", ind, stat.done_code); - printf("%sexit_code : %d\n", ind, stat.exit_code); - printf("%sresubmitted : %d\n", ind, stat.resubmitted); - printf("%scancelling : %d\n", ind, stat.cancelling); - printf("%scancelReason : %s\n", ind, stat.cancelReason); - printf("%scpuTime : %d\n", ind, stat.cpuTime); - printf("%suser_tags :\n",ind); - if (stat.user_tags) - for (i=0; stat.user_tags[i].tag; i++) printf("%s%14s = \"%s\"\n", ind, - stat.user_tags[i].tag,stat.user_tags[i].value); - printf("%sstateEnterTime : %ld.%06ld\n", ind, stat.stateEnterTime.tv_sec,stat.stateEnterTime.tv_usec); - printf("%sstateEnterTimes : \n",ind); - if (stat.stateEnterTimes) - for (i=1; i<=stat.stateEnterTimes[0]; i++) - printf("%s%14s %s", ind, edg_wll_StatToString(i-1), (stat.stateEnterTimes[i] == 0) ? - " - not available -\n" : ctime((time_t *) &stat.stateEnterTimes[i])); - printf("%slastUpdateTime : %ld.%06ld\n", ind, stat.lastUpdateTime.tv_sec,stat.lastUpdateTime.tv_usec); - printf("%sexpectUpdate : %d\n", ind, stat.expectUpdate); - printf("%sexpectFrom : %s\n", ind, stat.expectFrom); - printf("%sacl : %s\n", ind, stat.acl); - printf("\n"); - - free(j); - free(s); -} diff --git a/org.glite.lb.server/examples/ws_query_ex.c b/org.glite.lb.server/examples/ws_query_ex.c deleted file mode 100644 index a08fe33..0000000 --- a/org.glite.lb.server/examples/ws_query_ex.c +++ /dev/null @@ -1,182 +0,0 @@ -#include -#include - -#include "glite/lb/consumer.h" - -#include "ws_plugin.h" -#include "bk_ws_H.h" - -#include "ws_typeref.h" - - -static struct option opts[] = { - {"help", 0, NULL, 'h'}, - {"server", 1, NULL, 'm'} -}; - -static void usage(char *me) -{ - fprintf(stderr,"usage: %s [option]\n" - "\t-h, --help Shows this screen.\n" - "\t-m, --server BK server address:port.\n" - , me); -} - -static void printstat(edg_wll_JobStat stat, int level); - -int main(int argc,char** argv) -{ - edg_wll_Context ctx; - edg_wll_QueryRec **conditions = NULL; - struct soap *soap = soap_new(); - struct edgwll__QueryConditions *jconds = NULL; - struct edgwll__JobStatFlags flags; - struct edgwll2__QueryJobsResponse out; - int opt, err; - char *server = "http://localhost:8999/", - *name = NULL; - - - name = strrchr(argv[0],'/'); - if (name) name++; else name = argv[0]; - - while ((opt = getopt_long(argc, argv, "hm:", opts, NULL)) != EOF) switch (opt) - { - case 'h': usage(name); return 0; - case 'm': server = strdup(optarg); break; - case '?': usage(name); return 1; - } - - edg_wll_InitContext(&ctx); - - if ( soap_register_plugin_arg(soap, edg_wll_ws_plugin, (void *)ctx) ) - { - soap_print_fault(soap, stderr); - return 1; - } - - conditions = (edg_wll_QueryRec **)calloc(3,sizeof(edg_wll_QueryRec *)); - - conditions[0] = (edg_wll_QueryRec *)calloc(2,sizeof(edg_wll_QueryRec)); - conditions[0][0].attr = EDG_WLL_QUERY_ATTR_STATUS; - conditions[0][0].op = EDG_WLL_QUERY_OP_UNEQUAL; - conditions[0][0].value.i = EDG_WLL_JOB_DONE; - - conditions[1] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - conditions[1][0].attr = EDG_WLL_QUERY_ATTR_OWNER; - conditions[1][0].op = EDG_WLL_QUERY_OP_EQUAL; - conditions[1][0].value.c = NULL; - - if ( edg_wll_QueryCondsExtToSoap(soap, (const edg_wll_QueryRec **)conditions, &jconds) - || edg_wll_JobStatFlagsToSoap(soap, 0, &flags) ) { - char *et,*ed; - - fprintf(stderr, "%s: soap types conversion error...\n", argv[0]); - edg_wll_FaultToErr(soap, ctx); - edg_wll_Error(ctx, &et, &ed); - fprintf(stderr, "%s: %s (%s)\n", argv[0], et, ed); - exit(1); - } - - err = soap_call_edgwll2__QueryJobs(soap, server, "", jconds, &flags, &out); - switch ( err ) { - case SOAP_OK: { - int i; - - printf("Query succesfull...\n"); - printf("%-65s%s\n\n", "jobid", "state"); - for ( i = 0; i < out.jobs->__sizejobs; i++ ) { - char *s = edg_wll_StatToString(out.states->states[i]->state); - printf("%-65s%s\n", out.jobs->jobs[i], s); - free(s); - } - } - break; - case SOAP_FAULT: - case SOAP_SVR_FAULT: { - char *et,*ed; - - edg_wll_FaultToErr(soap, ctx); - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"%s: %s (%s)\n",argv[0],et,ed); - exit(1); - } - default: - fprintf(stderr,"err = %d\n",err); - soap_print_fault(soap,stderr); - } - - return 0; -} - -static void printstat(edg_wll_JobStat stat, int level) -{ - char *s, *j, ind[10]; - int i; - - - for (i=0; i < level; i++) - ind[i]='\t'; - ind[i]='\0'; - - s = edg_wll_StatToString(stat.state); -/* print whole flat structure */ - printf("%sstate : %s\n", ind, s); - printf("%sjobId : %s\n", ind, j = edg_wlc_JobIdUnparse(stat.jobId)); - printf("%sowner : %s\n", ind, stat.owner); - printf("%sjobtype : %s\n", ind, (stat.jobtype ? "DAG" : "SIMPLE") ); - printf("%sparent_job : %s\n", ind, - j = edg_wlc_JobIdUnparse(stat.parent_job)); - if (stat.jobtype) {; - printf("%sseed : %s\n", ind, stat.seed); - printf("%schildren_num : %d\n", ind, stat.children_num); - printf("%schildren :\n", ind); - if (stat.children) - for (i=0; stat.children[i]; i++) - printf("%s\tchildren : %s\n", ind, stat.children[i]); - printf("%schildren_states :\n", ind); - if (stat.children_states) - for (i=0; stat.children_states[i].state; i++) - printstat(stat.children_states[i], level+1); - printf("%schildren_hist :\n",ind); - if (stat.children_hist) - for (i=1; i<=stat.children_hist[0]; i++) - printf("%s%14s %d\n", ind, edg_wll_StatToString(i-1),stat.children_hist[i]); - } - printf("%scondorId : %s\n", ind, stat.condorId); - printf("%sglobusId : %s\n", ind, stat.globusId); - printf("%slocalId : %s\n", ind, stat.localId); - printf("%sjdl : %s\n", ind, stat.jdl); - printf("%smatched_jdl : %s\n", ind, stat.matched_jdl); - printf("%sdestination : %s\n", ind, stat.destination); - printf("%snetwork server : %s\n", ind, stat.network_server); - printf("%scondor_jdl : %s\n", ind, stat.condor_jdl); - printf("%srsl : %s\n", ind, stat.rsl); - printf("%sreason : %s\n", ind, stat.reason); - printf("%slocation : %s\n", ind, stat.location); - printf("%ssubjob_failed : %d\n", ind, stat.subjob_failed); - printf("%sdone_code : %d\n", ind, stat.done_code); - printf("%sexit_code : %d\n", ind, stat.exit_code); - printf("%sresubmitted : %d\n", ind, stat.resubmitted); - printf("%scancelling : %d\n", ind, stat.cancelling); - printf("%scancelReason : %s\n", ind, stat.cancelReason); - printf("%scpuTime : %d\n", ind, stat.cpuTime); - printf("%suser_tags :\n",ind); - if (stat.user_tags) - for (i=0; stat.user_tags[i].tag; i++) printf("%s%14s = \"%s\"\n", ind, - stat.user_tags[i].tag,stat.user_tags[i].value); - printf("%sstateEnterTime : %ld.%06ld\n", ind, stat.stateEnterTime.tv_sec,stat.stateEnterTime.tv_usec); - printf("%sstateEnterTimes : \n",ind); - if (stat.stateEnterTimes) - for (i=1; i<=stat.stateEnterTimes[0]; i++) - printf("%s%14s %s", ind, edg_wll_StatToString(i-1), (stat.stateEnterTimes[i] == 0) ? - " - not available -\n" : ctime((time_t *) &stat.stateEnterTimes[i])); - printf("%slastUpdateTime : %ld.%06ld\n", ind, stat.lastUpdateTime.tv_sec,stat.lastUpdateTime.tv_usec); - printf("%sexpectUpdate : %d\n", ind, stat.expectUpdate); - printf("%sexpectFrom : %s\n", ind, stat.expectFrom); - printf("%sacl : %s\n", ind, stat.acl); - printf("\n"); - - free(j); - free(s); -} diff --git a/org.glite.lb.server/project/build.properties b/org.glite.lb.server/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.lb.server/project/configure.properties.xml b/org.glite.lb.server/project/configure.properties.xml deleted file mode 100644 index cbf186d..0000000 --- a/org.glite.lb.server/project/configure.properties.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - -top_srcdir=.. -builddir=build -stagedir=${stage.abs.dir} -distdir=${dist.dir} -globalprefix=${global.prefix} -lbprefix=${subsystem.prefix} -package=${module.package.name} -PREFIX=${install.dir} -version=${module.version} -glite_location=${with.glite.location} -globus_prefix=${with.globus.prefix} -thrflavour=${with.globus.thr.flavor} -nothrflavour=${with.globus.nothr.flavor} -expat_prefix=${with.expat.prefix} -ares_prefix=${with.ares.prefix} -mysql_prefix=${with.mysql.prefix} -cppunit=${with.cppunit.prefix} -gridsite_prefix=${with.gridsite.prefix} -gsoap_prefix=${with.gsoap.prefix} - - - diff --git a/org.glite.lb.server/project/properties.xml b/org.glite.lb.server/project/properties.xml deleted file mode 100755 index 781ad01..0000000 --- a/org.glite.lb.server/project/properties.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.glite.lb.server/project/tar_exclude b/org.glite.lb.server/project/tar_exclude deleted file mode 100644 index b3133e4..0000000 --- a/org.glite.lb.server/project/tar_exclude +++ /dev/null @@ -1,10 +0,0 @@ -tar_exclude -CVS -build.xml -build -build.properties -properties.xml -configure-options.xml -.cvsignore -.project -.cdtproject diff --git a/org.glite.lb.server/project/version.properties b/org.glite.lb.server/project/version.properties deleted file mode 100644 index 9ec71f2..0000000 --- a/org.glite.lb.server/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Dec 09 05:04:50 CET 2004 -module.version=0.7.0 -module.build=112 -module.age=4 diff --git a/org.glite.lb.server/src/bkindex.c b/org.glite.lb.server/src/bkindex.c deleted file mode 100644 index fe8014e..0000000 --- a/org.glite.lb.server/src/bkindex.c +++ /dev/null @@ -1,305 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/strmd5.h" -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" -#include "index.h" -#include "lbs_db.h" -#include "jobstat.h" - -static struct option opts[] = { - { "mysql",1,NULL,'m' }, - { "remove",0,NULL,'R' }, - { "really",0,NULL,'r' }, - { "dump",0,NULL,'d' }, - { "verbose",0,NULL,'v' }, - { NULL, 0, NULL, 0 } -}; - -static void usage(const char *); -static void do_exit(edg_wll_Context,int); -static char *col_list(const edg_wll_QueryRec *); -static char *db_col_type(const edg_wll_QueryRec *); - -/* XXX: don't bother with malloc() of arrays that are tiny in real life */ -#define CI_MAX 200 - -int debug; - -int main(int argc,char **argv) -{ - int opt; - char *dbstring = getenv("LBDB"); - char *fname = "-"; - int dump = 0, really = 0, verbose = 0, remove_all = 0; - edg_wll_Context ctx; - edg_wll_QueryRec **old_indices,**new_indices; - edg_wll_QueryRec *new_columns[CI_MAX],*old_columns[CI_MAX]; - int add_columns[CI_MAX],drop_columns[CI_MAX]; - int add_indices[CI_MAX],drop_indices[CI_MAX]; - edg_wll_IColumnRec *added_icols; - int nadd_icols; - char **index_names; - int i,j,k; - int nnew,nold,nadd,ndrop; - char *stmt; - - for (i=0; i= 0; i++) { - if (verbose) { - char *n = col_list(old_indices[drop_indices[i]]); - printf("\t%s(%s) ... ",index_names[drop_indices[i]],n); fflush(stdout); - free(n); - } - if (really) { - asprintf(&stmt,"alter table states drop index `%s`",index_names[drop_indices[i]]); - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) do_exit(ctx,EX_SOFTWARE); - free(stmt); - } - if (verbose) puts(really ? "done" : ""); - } - - if (verbose) puts("Dropping columns ..."); - for (i=0; iattr == EDG_WLL_QUERY_ATTR_USERTAG) - added_icols[nadd_icols].qrec.attr_id.tag = - strdup(new_columns[i]->attr_id.tag); - nadd_icols++; - free(cname); - } - } - - if (nadd_icols) { - added_icols[nadd_icols].qrec.attr = EDG_WLL_QUERY_ATTR_UNDEF; - added_icols[nadd_icols].colname = NULL; - if (verbose) puts("Refreshing data ..."); - if (really && edg_wll_RefreshIColumns(ctx, (void*) added_icols)) do_exit(ctx,EX_SOFTWARE); - } - else if (verbose) puts("No data refresh required"); - - for (nadd_icols--; nadd_icols >= 0; nadd_icols--) - edg_wll_FreeIColumnRec(&added_icols[nadd_icols]); - free(added_icols); - - if (verbose) puts("Creating indices ..."); - for (i=0; add_indices[i] >= 0; i++) { - char *l = col_list(new_indices[add_indices[i]]); - char *n = str2md5base64(l); - if (verbose) { printf("\t%s(%s) ... ",n,l); fflush(stdout); } - if (really) { - asprintf(&stmt,"create index `%s` on states(%s)",n,l); - free(n); free(l); - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) do_exit(ctx,EX_SOFTWARE); - free(stmt); - } - if (verbose) puts(really ? "done" : ""); - } - - return 0; -} - -static char *col_list(const edg_wll_QueryRec *ind) -{ - char *ret,*aux,size[50] = ""; - int j; - - aux = edg_wll_QueryRecToColumn(ind); - if (ind->value.i) sprintf(size,"(%d)",ind->value.i); - asprintf(&ret,"`%s`%s",aux,size); - free(aux); - - for (j=1; ind[j].attr; j++) { - char *n = edg_wll_QueryRecToColumn(ind+j),size[50] = ""; - if (ind[j].value.i) sprintf(size,"(%d)",ind[j].value.i); - aux = ret; - asprintf(&ret,"%s,`%s`%s",aux,n,size); - free(n); free(aux); - } - return ret; -} - -static char *db_col_type(const edg_wll_QueryRec *r) -{ - switch (r->attr) { - case EDG_WLL_QUERY_ATTR_OWNER: - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_DESTINATION: - case EDG_WLL_QUERY_ATTR_USERTAG: - case EDG_WLL_QUERY_ATTR_HOST: - case EDG_WLL_QUERY_ATTR_CHKPT_TAG: - return "char(250) binary null"; - - case EDG_WLL_QUERY_ATTR_TIME: - return "datetime null"; - default: - return NULL; - } -} - -static void do_exit(edg_wll_Context ctx,int code) -{ - char *et,*ed; - - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"edg-bkindex: %s (%s)\n",et,ed); - exit(code); -} - -static void usage(const char *me) -{ - fprintf(stderr,"usage: %s [file]\n" - " -m,--mysql use non-default database connection\n" - " -r,--really really perform reindexing\n" - " -R,--remove remove all indexes from server\n" - " -d,--dump dump current setup\n" - " -v,--verbose increase verbosity (2 levels)\n" - "\n -r and -d are mutually exlusive\n" - "\n -r and -R are mutually exlusive\n" - " [file] is applicable only without -d and -R\n", - me); -} diff --git a/org.glite.lb.server/src/bkserverd.c b/org.glite.lb.server/src/bkserverd.c deleted file mode 100644 index caa56f4..0000000 --- a/org.glite.lb.server/src/bkserverd.c +++ /dev/null @@ -1,1368 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef GLITE_LB_SERVER_WITH_WS -#include -int soap_serve(struct soap*); -#endif /* GLITE_LB_SERVER_WITH_WS */ - -#include "glite/lb/srvbones.h" -#include "glite/lb/consumer.h" -#include "glite/lb/purge.h" -#include "glite/lb/context.h" -#include "glite/lb/mini_http.h" -#include "glite/lb/context-int.h" -#include "glite/lb/lb_gss.h" - -#include "lb_http.h" -#include "lb_proto.h" -#include "index.h" -#include "lbs_db.h" -#include "lb_authz.h" -#include "il_notification.h" - -#ifdef GLITE_LB_SERVER_WITH_WS -#include "ws_plugin.h" -#endif /* GLITE_LB_SERVER_WITH_WS */ - -extern int edg_wll_StoreProto(edg_wll_Context ctx); -extern edg_wll_ErrorCode edg_wll_Open(edg_wll_Context ctx, char *cs); -extern edg_wll_ErrorCode edg_wll_Close(edg_wll_Context); - - - - -#define CON_QUEUE 20 /* accept() */ -#define SLAVE_OVERLOAD 10 /* queue items per slave */ -#define CLNT_TIMEOUT 10 /* keep idle connection that many seconds */ -#define TOTAL_CLNT_TIMEOUT 60 /* one client may ask one slave multiple times */ - /* but only limited time to avoid DoS attacks */ -#define CLNT_REJECT_TIMEOUT 100000 /* time limit for client rejection in !usec! */ -#define DNS_TIMEOUT 5 /* how long wait for DNS lookup */ -#define SLAVE_CONNS_MAX 500 /* commit suicide after that many connections */ -#define MASTER_TIMEOUT 30 /* maximal time of one-round of master network communication */ -#define SLAVE_TIMEOUT 30 /* maximal time of one-round of slave network communication */ - -#ifndef EDG_PURGE_STORAGE -#define EDG_PURGE_STORAGE "/tmp/purge" -#endif - -#ifndef EDG_DUMP_STORAGE -#define EDG_DUMP_STORAGE "/tmp/dump" -#endif - -/* file to store pid and generate semaphores key */ -#ifndef EDG_BKSERVERD_PIDFILE -#define EDG_BKSERVERD_PIDFILE "/var/run/edg-bkserverd.pid" -#endif - -#ifndef dprintf -#define dprintf(x) { if (debug) printf x; } -#endif - -#define sizofa(a) (sizeof(a)/sizeof((a)[0])) - - -int debug = 0; -int rgma_export = 0; -static const int one = 1; -static int noAuth = 0; -static int noIndex = 0; -static int strict_locking = 0; -static int hardJobsLimit = 0; -static int hardEventsLimit = 0; -static int hardRespSizeLimit = 0; -static char *dbstring = NULL,*fake_host = NULL; -static int fake_port = 0; -static char **super_users = NULL; -static int slaves = 10, - semaphores = -1, - semset; -static char *purgeStorage = EDG_PURGE_STORAGE; -static char *dumpStorage = EDG_DUMP_STORAGE; - - -static time_t purge_timeout[EDG_WLL_NUMBER_OF_STATCODES]; -static time_t notif_duration = 60*60*24*7; - -static gss_cred_id_t mycred = GSS_C_NO_CREDENTIAL; -time_t cert_mtime = 0; -char *cadir = NULL, - *vomsdir = NULL, - *server_key = NULL, - *server_cert = NULL; - - -static struct option opts[] = { - {"cert", 1, NULL, 'c'}, - {"key", 1, NULL, 'k'}, - {"CAdir", 1, NULL, 'C'}, - {"VOMSdir", 1, NULL, 'V'}, - {"port", 1, NULL, 'p'}, -#ifdef GLITE_LB_SERVER_WITH_WS - {"wsport", 1, NULL, 'w'}, -#endif /* GLITE_LB_SERVER_WITH_WS */ - {"address", 1, NULL, 'a'}, - {"debug", 0, NULL, 'd'}, - {"rgmaexport", 0, NULL, 'r'}, - {"mysql", 1, NULL, 'm'}, - {"noauth", 0, NULL, 'n'}, - {"slaves", 1, NULL, 's'}, - {"semaphores", 1, NULL, 'l'}, - {"pidfile", 1, NULL, 'i'}, - {"purge-prefix", 1, NULL, 'S'}, - {"dump-prefix", 1, NULL, 'D'}, - {"super-user", 1, NULL, 'R'}, - {"super-users-file", 1, NULL,'F'}, - {"no-index", 1, NULL, 'x'}, - {"strict-locking",0, NULL, 'P'}, - {"limits", 1, NULL, 'L'}, - {"notif-dur", 1, NULL, 'N'}, - {"notif-il-sock", 1, NULL, 'X'}, - {"notif-il-fprefix", 1, NULL, 'Y'}, - {NULL,0,NULL,0} -}; - -#ifdef GLITE_LB_SERVER_WITH_WS -static const char *get_opt_string = "a:c:k:C:V:p:w:drm:ns:l:L:N:i:S:D:X:Y:"; -#else -static const char *get_opt_string = "a:c:k:C:V:p:drm:ns:l:L:N:i:S:D:X:Y:"; -#endif /* GLITE_LB_SERVER_WITH_WS */ - -static void usage(char *me) -{ - fprintf(stderr,"usage: %s [option]\n" - "\t-a, --address\t use this server address (may be faked for debugging)\n" - "\t-k, --key\t private key file\n" - "\t-c, --cert\t certificate file\n" - "\t-C, --CAdir\t trusted certificates directory\n" - "\t-V, --VOMSdir\t trusted VOMS servers certificates directory\n" - "\t-p, --port\t port to listen\n" -#ifdef GLITE_LB_SERVER_WITH_WS - "\t-w, --wsport\t port to serve the web services requests\n" -#endif /* GLITE_LB_SERVER_WITH_WS */ - "\t-m, --mysql\t database connect string\n" - "\t-d, --debug\t don't run as daemon, additional diagnostics\n" - "\t-r, --rgmaexport write state info to RGMA interface\n" - "\t-n, --noauth\t don't check user identity with result owner\n" - "\t-s, --slaves\t number of slave servers to fork\n" - "\t-l, --semaphores number of semaphores (job locks) to use\n" - "\t-i, --pidfile\t file to store master pid\n" - "\t-L, --limits\t query limits numbers in format \"events_limit:jobs_limit:size_limit\"\n" - "\t-N, --notif-dur\t Maximal duration of notification registrations in hours\n" - "\t-S, --purge-prefix\t purge files full-path prefix\n" - "\t-D, --dump-prefix\t dump files full-path prefix\n" - "\t--super-user\t user allowed to bypass authorization and indexing\n" - "\t--super-users-file\t the same but read the subjects from a file\n" - "\t--no-index=1\t don't enforce indices for superusers\n" - "\t =2\t don't enforce indices at all\n" - "\t--strict-locking=1\t lock jobs also on storing events (may be slow)\n" - "\t--notif-il-sock\t socket to send notifications\n" - "\t--notif-il-fprefix\t file prefix for notifications\n" - ,me); -} - -static void wait_for_open(edg_wll_Context,const char *); -static int decrement_timeout(struct timeval *, struct timeval, struct timeval); -static int read_roots(const char *); -static int asyn_gethostbyaddr(char **, const char *, int, int, struct timeval *); -static int amIroot(const char *); -static int parse_limits(char *, int *, int *, int *); -static int check_mkdir(const char *); - - -/* - * SERVER BONES structures and handlers - */ -int bk_clnt_data_init(void **); - - /* - * Serve & Store handlers - */ -int bk_clnt_reject(int); -int bk_handle_connection(int, struct timeval, void *); -int bk_accept_serve(int, void *); -int bk_accept_store(int, void *); -int bk_clnt_disconnect(int, void *); - -#ifdef GLITE_LB_SERVER_WITH_WS - /* - * WS handlers - */ -int bk_handle_ws_connection(int, struct timeval, void *); -int bk_accept_ws(int, void *); -int bk_ws_clnt_reject(int); -int bk_ws_clnt_disconnect(int, void *); -#endif /*GLITE_LB_SERVER_WITH_WS */ - -#define SRV_SERVE 0 -#define SRV_STORE 1 -#ifdef GLITE_LB_SERVER_WITH_WS -#define SRV_WS 2 -#endif /* GLITE_LB_SERVER_WITH_WS */ -static struct glite_srvbones_service service_table[] = { - { "serve", -1, bk_handle_connection, bk_accept_serve, bk_clnt_reject, bk_clnt_disconnect }, - { "store", -1, bk_handle_connection, bk_accept_store, bk_clnt_reject, bk_clnt_disconnect }, -#ifdef GLITE_LB_SERVER_WITH_WS - { "WS", -1, bk_handle_ws_connection, bk_accept_ws, bk_ws_clnt_reject, bk_ws_clnt_disconnect } -#endif /* GLITE_LB_SERVER_WITH_WS */ -}; - -struct clnt_data_t { - edg_wll_Context ctx; -#ifdef GLITE_LB_SERVER_WITH_WS - struct soap *soap; -#endif /* GLITE_LB_SERVER_WITH_WS */ - void *mysql; - edg_wll_QueryRec **job_index; - edg_wll_IColumnRec *job_index_cols; -}; - - - -int main(int argc, char *argv[]) -{ - int fd, i; - struct sockaddr_in a; - char *mysubj = NULL; - int opt; - char pidfile[PATH_MAX] = EDG_BKSERVERD_PIDFILE, - *port, - *name; -#ifdef GLITE_LB_SERVER_WITH_WS - char *ws_port; -#endif /* GLITE_LB_SERVER_WITH_WS */ - FILE *fpid; - key_t semkey; - edg_wll_Context ctx; - OM_uint32 min_stat; - edg_wll_GssStatus gss_code; - struct timeval to; - - - - name = strrchr(argv[0],'/'); - if (name) name++; else name = argv[0]; - - asprintf(&port, "%d", GLITE_WMSC_JOBID_DEFAULT_PORT); -#ifdef GLITE_LB_SERVER_WITH_WS - asprintf(&ws_port, "%d", GLITE_WMSC_JOBID_DEFAULT_PORT+3); -#endif /* GLITE_LB_SERVER_WITH_WS */ - server_cert = server_key = cadir = vomsdir = NULL; - -/* no magic here: 1 month, 3 and 7 days */ - purge_timeout[EDG_WLL_PURGE_JOBSTAT_OTHER] = 60*60*24*31; - purge_timeout[EDG_WLL_JOB_CLEARED] = 60*60*24*3; - purge_timeout[EDG_WLL_JOB_ABORTED] = 60*60*24*7; - purge_timeout[EDG_WLL_JOB_CANCELLED] = 60*60*24*7; - -/* no magic here: 1 month, 3 and 7 days */ - purge_timeout[EDG_WLL_PURGE_JOBSTAT_OTHER] = 60*60*24*31; - purge_timeout[EDG_WLL_JOB_CLEARED] = 60*60*24*3; - purge_timeout[EDG_WLL_JOB_ABORTED] = 60*60*24*7; - purge_timeout[EDG_WLL_JOB_CANCELLED] = 60*60*24*7; - -/* no magic here: 1 month, 3 and 7 days */ - purge_timeout[EDG_WLL_PURGE_JOBSTAT_OTHER] = 60*60*24*31; - purge_timeout[EDG_WLL_JOB_CLEARED] = 60*60*24*3; - purge_timeout[EDG_WLL_JOB_ABORTED] = 60*60*24*7; - purge_timeout[EDG_WLL_JOB_CANCELLED] = 60*60*24*7; - - if (geteuid()) snprintf(pidfile,sizeof pidfile,"%s/edg-bkserverd.pid", - getenv("HOME")); - - while ((opt = getopt_long(argc,argv,get_opt_string,opts,NULL)) != EOF) switch (opt) { - case 'a': fake_host = strdup(optarg); break; - case 'c': server_cert = optarg; break; - case 'k': server_key = optarg; break; - case 'C': cadir = optarg; break; - case 'V': vomsdir = optarg; break; - case 'p': free(port); port = strdup(optarg); break; -#ifdef GLITE_LB_SERVER_WITH_WS - case 'w': free(ws_port); ws_port = strdup(optarg); break; -#endif /* GLITE_LB_SERVER_WITH_WS */ - case 'd': debug = 1; break; - case 'r': rgma_export = 1; break; - case 'm': dbstring = optarg; break; - case 'n': noAuth = 1; break; - case 's': slaves = atoi(optarg); break; - case 'l': semaphores = atoi(optarg); break; - case 'S': purgeStorage = optarg; break; - case 'D': dumpStorage = optarg; break; - case 'L': - if ( !parse_limits(optarg, &hardJobsLimit, &hardEventsLimit, &hardRespSizeLimit) ) - { - usage(name); - return 1; - } - break; - case 'N': notif_duration = atoi(optarg) * (60*60); break; - case 'X': notif_ilog_socket_path = strdup(optarg); break; - case 'Y': notif_ilog_file_prefix = strdup(optarg); break; - case 'i': strcpy(pidfile,optarg); break; - case 'R': if (super_users) { - fprintf(stderr,"%s: super-users already defined, second occurence ignored\n", - argv[0]); - break; - } - super_users = malloc(2 * sizeof super_users[0]); - super_users[0] = optarg; - super_users[1] = NULL; - break; - case 'F': if (super_users) { - fprintf(stderr,"%s: super-users already defined, second occurence ignored\n", - argv[0]); - break; - } - if (read_roots(optarg)) return 1; - break; - case 'x': noIndex = atoi(optarg); - if (noIndex < 0 || noIndex > 2) { usage(name); return 1; } - break; - case 'P': strict_locking = 1; - break; - case '?': usage(name); return 1; - } - - if ( optind < argc ) { usage(name); return 1; } - - setlinebuf(stdout); - setlinebuf(stderr); - - fpid = fopen(pidfile,"r"); - if ( fpid ) - { - int opid = -1; - - if ( fscanf(fpid,"%d",&opid) == 1 ) - { - if ( !kill(opid,0) ) - { - fprintf(stderr,"%s: another instance running, pid = %d\n",argv[0],opid); - return 1; - } - else if (errno != ESRCH) { perror("kill()"); return 1; } - } - fclose(fpid); - } else if (errno != ENOENT) { perror(pidfile); return 1; } - - fpid = fopen(pidfile, "w"); - if (!fpid) { perror(pidfile); return 1; } - fprintf(fpid, "%d", getpid()); - fclose(fpid); - - semkey = ftok(pidfile,0); - - if (!debug) for (fd=3; fd= 0) semctl(semset, 0, IPC_RMID); - semset = semget(semkey, semaphores, IPC_CREAT | 0600); - if (semset < 0) { perror("semget()"); return 1; } - dprintf(("Using %d semaphores, set id %d\n",semaphores,semset)); - for (i=0; imysql = ctx->mysql; - - if ( edg_wll_QueryJobIndices(ctx, &job_index, NULL) ) - { - char *et, *ed; - - edg_wll_Error(ctx,&et,&ed); - dprintf(("[%d]: query_job_indices(): %s: %s, no custom indices available\n",getpid(),et,ed)); - if (!debug) syslog(LOG_ERR,"[%d]: query_job_indices(): %s: %s, no custom indices available\n",getpid(),et,ed); - free(et); - free(ed); - } - edg_wll_FreeContext(ctx); - cdata->job_index = job_index; - - if ( job_index ) - { - int i,j, k, maxncol, ncol; - - ncol = maxncol = 0; - for ( i = 0; job_index[i]; i++ ) - for ( j = 0; job_index[i][j].attr; j++ ) - maxncol++; - - job_index_cols = calloc(maxncol+1, sizeof(edg_wll_IColumnRec)); - for ( i = 0; job_index[i]; i++ ) - { - for ( j = 0; job_index[i][j].attr; j++) - { - for ( k = 0; - k < ncol && edg_wll_CmpColumn(&job_index_cols[k].qrec, &job_index[i][j]); - k++); - - if ( k == ncol) - { - job_index_cols[ncol].qrec = job_index[i][j]; - if ( job_index[i][j].attr == EDG_WLL_QUERY_ATTR_USERTAG ) - { - job_index_cols[ncol].qrec.attr_id.tag = - strdup(job_index[i][j].attr_id.tag); - } - job_index_cols[ncol].colname = - edg_wll_QueryRecToColumn(&job_index_cols[ncol].qrec); - ncol++; - } - } - } - job_index_cols[ncol].qrec.attr = EDG_WLL_QUERY_ATTR_UNDEF; - job_index_cols[ncol].colname = NULL; - cdata->job_index_cols = job_index_cols; - } - - *data = cdata; - return 0; -} - - -/* - * Creates context (initializes it from global vatiables and data given - * from server_bones) - * gets the connection info - * and accepts the gss connection - */ -int bk_handle_connection(int conn, struct timeval client_start, void *data) -{ - struct clnt_data_t *cdata = (struct clnt_data_t *)data; - edg_wll_Context ctx; - gss_name_t client_name = GSS_C_NO_NAME; - gss_buffer_desc token = GSS_C_EMPTY_BUFFER; - gss_cred_id_t newcred = GSS_C_NO_CREDENTIAL; - edg_wll_GssStatus gss_code; - OM_uint32 min_stat, - maj_stat; - struct timeval dns_to = {DNS_TIMEOUT, 0}, - total_to = { TOTAL_CLNT_TIMEOUT,0 }, - now; - struct sockaddr_in a; - int alen; - char *server_name = NULL, - *name = NULL; - int h_errno; - - - - switch ( edg_wll_gss_watch_creds(server_cert, &cert_mtime) ) { - case 0: break; - case 1: - if ( !edg_wll_gss_acquire_cred_gsi(server_cert, server_key, &newcred, NULL, &gss_code) ) { - dprintf(("[%d] reloading credentials\n", getpid())); - gss_release_cred(&min_stat, &mycred); - mycred = newcred; - } else { dprintf(("[%d] reloading credentials failed\n", getpid())); } - break; - case -1: dprintf(("[%d] edg_wll_gss_watch_creds failed\n", getpid())); break; - } - - if ( edg_wll_InitContext(&ctx) ) - { - fprintf(stderr, "Couldn't create context"); - return -1; - } - cdata->ctx = ctx; - - /* Shared structures (pointers) - */ - ctx->mysql = cdata->mysql; - ctx->job_index_cols = cdata->job_index_cols; - ctx->job_index = cdata->job_index; - - /* set globals - */ - ctx->notifDuration = notif_duration; - ctx->purgeStorage = strdup(purgeStorage); - ctx->dumpStorage = strdup(dumpStorage); - ctx->hardJobsLimit = hardJobsLimit; - ctx->hardEventsLimit = hardEventsLimit; - ctx->semset = semset; - ctx->semaphores = semaphores; - if ( noAuth ) ctx->noAuth = 1; - ctx->rgma_export = rgma_export; - memcpy(ctx->purge_timeout, purge_timeout, sizeof(ctx->purge_timeout)); - - ctx->p_tmp_timeout.tv_sec = SLAVE_TIMEOUT; - ctx->p_tmp_timeout.tv_usec = 0; - if ( total_to.tv_sec < ctx->p_tmp_timeout.tv_sec ) - { - ctx->p_tmp_timeout.tv_sec = total_to.tv_sec; - ctx->p_tmp_timeout.tv_usec = total_to.tv_usec; - } - - ctx->poolSize = 1; - ctx->connPool = calloc(1, sizeof(edg_wll_ConnPool)); - ctx->connToUse = 0; - - alen = sizeof(a); - getpeername(conn, (struct sockaddr *)&a, &alen); - ctx->connPool[ctx->connToUse].peerName = strdup(inet_ntoa(a.sin_addr)); - ctx->connPool[ctx->connToUse].peerPort = ntohs(a.sin_port); - - /* not a critical operation, do not waste all SLAVE_TIMEOUT */ - h_errno = asyn_gethostbyaddr(&name, (char *)&a.sin_addr.s_addr,sizeof(a.sin_addr.s_addr), AF_INET, &dns_to); - switch ( h_errno ) - { - case NETDB_SUCCESS: - if (name) dprintf(("[%d] connection from %s:%d (%s)\n", - getpid(), inet_ntoa(a.sin_addr), ntohs(a.sin_port), name)); - free(ctx->connPool[ctx->connToUse].peerName); - ctx->connPool[ctx->connToUse].peerName = name; - name = NULL; - break; - - default: - if (debug) fprintf(stderr, "gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno)); - dprintf(("[%d] connection from %s:%d\n", getpid(), inet_ntoa(a.sin_addr), ntohs(a.sin_port))); - break; - } - - gettimeofday(&now,0); - if ( decrement_timeout(&ctx->p_tmp_timeout, client_start, now) ) - { - if (debug) fprintf(stderr, "gethostbyaddr() timeout"); - else syslog(LOG_ERR, "gethostbyaddr(): timeout"); - free(name); - - return -1; - } - - if (fake_host) - { - ctx->srvName = strdup(fake_host); - ctx->srvPort = fake_port; - } - else - { - alen = sizeof(a); - getsockname(conn,(struct sockaddr *) &a,&alen); - - dns_to.tv_sec = DNS_TIMEOUT; - dns_to.tv_usec = 0; - h_errno = asyn_gethostbyaddr(&name, - (char *) &a.sin_addr.s_addr,sizeof(a.sin_addr.s_addr), - AF_INET,&dns_to); - - switch ( h_errno ) - { - case NETDB_SUCCESS: - ctx->srvName = name; - if ( server_name != NULL ) - { - if ( strcmp(name, server_name)) - { - if (debug) fprintf(stderr, "different server endpoint names (%s,%s)," - " check DNS PTR records\n", name, server_name); - else syslog(LOG_ERR,"different server endpoint names (%s,%s)," - " check DNS PTR records\n", name, server_name); - } - } - else server_name = strdup(name); - break; - - default: - if ( debug ) - fprintf(stderr, "gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno)); - else - syslog(LOG_ERR,"gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno)); - if ( server_name != NULL ) - ctx->srvName = strdup(server_name); - break; - } - ctx->srvPort = ntohs(a.sin_port); - } - - if ( edg_wll_gss_accept(mycred, conn, &ctx->p_tmp_timeout, &ctx->connPool[ctx->connToUse].gss, &gss_code) ) - { - dprintf(("[%d] Client authentication failed, closing.\n", getpid())); - if (!debug) syslog(LOG_ERR, "Client authentication failed"); - edg_wll_FreeContext(ctx); - return 1; - } - - maj_stat = gss_inquire_context(&min_stat, ctx->connPool[ctx->connToUse].gss.context, - &client_name, NULL, NULL, NULL, NULL, NULL, NULL); - if ( !GSS_ERROR(maj_stat) ) - maj_stat = gss_display_name(&min_stat, client_name, &token, NULL); - - if ( !GSS_ERROR(maj_stat) ) - { - if (ctx->peerName) free(ctx->peerName); - ctx->peerName = (char *)token.value; - memset(&token, 0, sizeof(token)); - /* XXX DK: pujde pouzit lifetime z inquire_context()? - * - ctx->peerProxyValidity = ASN1_UTCTIME_mktime(X509_get_notAfter(peer)); - */ - - dprintf(("[%d] client DN: %s\n",getpid(),ctx->peerName)); - } - else - /* XXX DK: Check if the ANONYMOUS flag is set ? - */ - dprintf(("[%d] annonymous client\n",getpid())); - - if ( client_name != GSS_C_NO_NAME ) - gss_release_name(&min_stat, &client_name); - if ( token.value ) - gss_release_buffer(&min_stat, &token); - - edg_wll_SetVomsGroups(ctx, &ctx->connPool[ctx->connToUse].gss, server_cert, server_key, vomsdir, cadir); - if (debug && ctx->vomsGroups.len > 0) - { - int i; - - dprintf(("[%d] client's VOMS groups:\n",getpid())); - for ( i = 0; i < ctx->vomsGroups.len; i++ ) - dprintf(("\t%s:%s\n", ctx->vomsGroups.val[i].vo, ctx->vomsGroups.val[i].name)); - } - - /* used also to reset start_time after edg_wll_ssl_accept! */ - /* gettimeofday(&start_time,0); */ - - ctx->noAuth = noAuth || amIroot(ctx->peerName); - switch ( noIndex ) - { - case 0: ctx->noIndex = 0; break; - case 1: ctx->noIndex = amIroot(ctx->peerName); break; - case 2: ctx->noIndex = 1; break; - } - ctx->strict_locking = strict_locking; - - - return 0; -} - -#ifdef GLITE_LB_SERVER_WITH_WS -int bk_handle_ws_connection(int conn, struct timeval client_start, void *data) -{ - struct clnt_data_t *cdata = (struct clnt_data_t *) data; - struct soap *soap; - int rv; - - - if ( !(soap = soap_new()) ) - { - fprintf(stderr, "Couldn't create soap environment"); - return -1; - } - - if ( (rv = bk_handle_connection(conn, client_start, data)) ) - { - soap_destroy(soap); - return rv; - } - - cdata->soap = soap; - - soap_init(soap); - soap_set_namespaces(soap, namespaces); - soap_register_plugin_arg(soap, edg_wll_ws_plugin, cdata->ctx); - - - return 0; -} -#endif /* GLITE_LB_SERVER_WITH_WS */ - -int bk_accept_store(int conn, void *cdata) -{ - edg_wll_Context ctx = ((struct clnt_data_t *) cdata)->ctx; - - /* - * serve the request - */ - if ( edg_wll_StoreProto(ctx) ) - { - char *errt, *errd; - - - errt = errd = NULL; - switch ( edg_wll_Error(ctx, &errt, &errd) ) - { - case ETIMEDOUT: - case EDG_WLL_ERROR_GSS: - case EPIPE: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if (!debug) syslog(LOG_ERR,"%s (%s)", errt, errd); - /* fallthrough - */ - case ENOTCONN: - edg_wll_gss_close(&ctx->connPool[ctx->connToUse].gss, NULL); - edg_wll_FreeContext(ctx); - ctx = NULL; - free(errt); free(errd); - dprintf(("[%d] Connection closed\n", getpid())); - /* - * "recoverable" error - return (>0) - */ - return 1; - break; - - case ENOENT: - case EINVAL: - case EPERM: - case EEXIST: - case EDG_WLL_ERROR_NOINDEX: - case E2BIG: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if ( !debug ) syslog(LOG_ERR,"%s (%s)", errt, errd); - /* - * no action for non-fatal errors - */ - break; - - default: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if (!debug) syslog(LOG_CRIT,"%s (%s)",errt,errd); - /* - * unknown error - do rather return (<0) (slave will be killed) - */ - return -1; - } - free(errt); free(errd); - } - - return 0; -} - -int bk_accept_serve(int conn, void *cdata) -{ - edg_wll_Context ctx = ((struct clnt_data_t *) cdata)->ctx; - - /* - * serve the request - */ - if ( edg_wll_ServerHTTP(ctx) ) - { - char *errt, *errd; - - - errt = errd = NULL; - switch ( edg_wll_Error(ctx, &errt, &errd) ) - { - case ETIMEDOUT: - case EDG_WLL_ERROR_GSS: - case EPIPE: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if (!debug) syslog(LOG_ERR,"%s (%s)", errt, errd); - /* fallthrough - */ - case ENOTCONN: - edg_wll_gss_close(&ctx->connPool[ctx->connToUse].gss, NULL); - edg_wll_FreeContext(ctx); - ctx = NULL; - free(errt); free(errd); - dprintf(("[%d] Connection closed\n", getpid())); - /* - * "recoverable" error - return (>0) - */ - return 1; - break; - - case ENOENT: - case EINVAL: - case EPERM: - case EEXIST: - case EDG_WLL_ERROR_NOINDEX: - case E2BIG: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if ( !debug ) syslog(LOG_ERR,"%s (%s)", errt, errd); - /* - * no action for non-fatal errors - */ - break; - - default: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if (!debug) syslog(LOG_CRIT,"%s (%s)",errt,errd); - /* - * unknown error - do rather return (<0) (slave will be killed) - */ - return -1; - } - free(errt); free(errd); - } - - return 0; -} - - -#ifdef GLITE_LB_SERVER_WITH_WS -int bk_accept_ws(int conn, void *cdata) -{ - struct soap *soap = ((struct clnt_data_t *) cdata)->soap; - edg_wll_Context ctx = ((struct clnt_data_t *) cdata)->ctx; - - - /* XXX: Is it neccessary? - * - * BEWARE: gSoap is trying to handle this connection -> closes the - * socket after then query is served (or something like that :) - * - soap->socket = conn; - */ - if ( soap_serve(soap) ) - { - char *errt, *errd; - - - errt = errd = NULL; - switch ( edg_wll_Error(ctx, &errt, &errd) ) - { - case ETIMEDOUT: - case EDG_WLL_ERROR_GSS: - case EPIPE: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if (!debug) syslog(LOG_ERR,"%s (%s)", errt, errd); - /* fallthrough - */ - case ENOTCONN: - edg_wll_gss_close(&ctx->connPool[ctx->connToUse].gss, NULL); - edg_wll_FreeContext(ctx); - ctx = NULL; - free(errt); free(errd); - dprintf(("[%d] Connection closed\n", getpid())); - /* - * "recoverable" error - return (>0) - */ - return 1; - break; - - case ENOENT: - case EINVAL: - case EPERM: - case EEXIST: - case EDG_WLL_ERROR_NOINDEX: - case E2BIG: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if ( !debug ) syslog(LOG_ERR,"%s (%s)", errt, errd); - /* - * no action for non-fatal errors - */ - break; - - default: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if (!debug) syslog(LOG_CRIT,"%s (%s)",errt,errd); - /* - * unknown error - do rather return (<0) (slave will be killed) - */ - return -1; - } - free(errt); free(errd); - return 1; - } - - return 0; -} -#endif /* GLITE_LB_SERVER_WITH_WS */ - - -int bk_clnt_disconnect(int conn, void *cdata) -{ - edg_wll_Context ctx = ((struct clnt_data_t *) cdata)->ctx; - - - if ( ctx->connPool[ctx->connToUse].gss.context != GSS_C_NO_CONTEXT) - { - struct timeval to = { 0, CLNT_REJECT_TIMEOUT }; - - edg_wll_gss_close(&ctx->connPool[ctx->connToUse].gss, &to); - } - edg_wll_FreeContext(ctx); - - return 0; -} - -#ifdef GLITE_LB_SERVER_WITH_WS -int bk_ws_clnt_disconnect(int conn, void *cdata) -{ - int rv; - - - if ( (rv = bk_clnt_disconnect(conn, cdata)) ) - return rv; - - soap_destroy(((struct clnt_data_t *)cdata)->soap); - - return 0; -} -#endif /* GLITE_LB_SERVER_WITH_WS */ - -int bk_clnt_reject(int conn) -{ - int flags = fcntl(conn, F_GETFL, 0); - - if ( fcntl(conn, F_SETFL, flags | O_NONBLOCK) < 0 ) - return 1; - - edg_wll_gss_reject(conn); - - return 0; -} - -#ifdef GLITE_LB_SERVER_WITH_WS -int bk_ws_clnt_reject(int conn) -{ - return bk_clnt_reject(conn); -} -#endif /* GLITE_LB_SERVER_WITH_WS */ - - -static void wait_for_open(edg_wll_Context ctx, const char *dbstring) -{ - char *dbfail_string1, *dbfail_string2; - - dbfail_string1 = dbfail_string2 = NULL; - - while (edg_wll_Open(ctx, (char *) dbstring)) { - char *errt,*errd; - - if (dbfail_string1) free(dbfail_string1); - edg_wll_Error(ctx,&errt,&errd); - asprintf(&dbfail_string1,"%s (%s)\n",errt,errd); - if (dbfail_string1 != NULL) { - if (dbfail_string2 == NULL || strcmp(dbfail_string1,dbfail_string2)) { - if (dbfail_string2) free(dbfail_string2); - dbfail_string2 = dbfail_string1; - dbfail_string1 = NULL; - dprintf(("[%d]: %s\nStill trying ...\n",getpid(),dbfail_string2)); - if (!debug) syslog(LOG_ERR,dbfail_string2); - } - } - sleep(5); - } - - if (dbfail_string1) free(dbfail_string1); - if (dbfail_string2 != NULL) { - free(dbfail_string2); - dprintf(("[%d]: DB connection established\n",getpid())); - if (!debug) syslog(LOG_INFO,"DB connection established\n"); - } -} - -static void free_hostent(struct hostent *h){ - int i; - - if (h) { - if (h->h_name) free(h->h_name); - if (h->h_aliases) { - for (i=0; h->h_aliases[i]; i++) free(h->h_aliases[i]); - free(h->h_aliases); - } - if (h->h_addr_list) { - for (i=0; h->h_addr_list[i]; i++) free(h->h_addr_list[i]); - free(h->h_addr_list); - } - free(h); - } -} - -struct asyn_result { - struct hostent *ent; - int err; -}; - -/* ares callback handler for ares_gethostbyaddr() */ -static void callback_handler(void *arg, int status, struct hostent *h) -{ - struct asyn_result *arp = (struct asyn_result *) arg; - - switch (status) { - case ARES_SUCCESS: - if (h && h->h_name) { - arp->ent->h_name = strdup(h->h_name); - if (arp->ent->h_name == NULL) { - arp->err = NETDB_INTERNAL; - } else { - arp->err = NETDB_SUCCESS; - } - } else { - arp->err = NO_DATA; - } - break; - case ARES_EBADNAME: - case ARES_ENOTFOUND: - arp->err = HOST_NOT_FOUND; - break; - case ARES_ENOTIMP: - arp->err = NO_RECOVERY; - break; - case ARES_ENOMEM: - case ARES_EDESTRUCTION: - default: - arp->err = NETDB_INTERNAL; - break; - } -} - -static int asyn_gethostbyaddr(char **name, const char *addr,int len, int type, struct timeval *timeout) -{ - struct asyn_result ar; - ares_channel channel; - int nfds; - fd_set readers, writers; - struct timeval tv, *tvp; - struct timeval start_time,check_time; - - -/* start timer */ - gettimeofday(&start_time,0); - -/* ares init */ - if ( ares_init(&channel) != ARES_SUCCESS ) return(NETDB_INTERNAL); - ar.ent = (struct hostent *) malloc (sizeof(*ar.ent)); - memset((void *) ar.ent, 0, sizeof(*ar.ent)); - -/* query DNS server asynchronously */ - ares_gethostbyaddr(channel, addr, len, type, callback_handler, (void *) &ar); - -/* wait for result */ - while (1) { - FD_ZERO(&readers); - FD_ZERO(&writers); - nfds = ares_fds(channel, &readers, &writers); - if (nfds == 0) - break; - - gettimeofday(&check_time,0); - if (decrement_timeout(timeout, start_time, check_time)) { - ares_destroy(channel); - free_hostent(ar.ent); - return(TRY_AGAIN); - } - start_time = check_time; - - tvp = ares_timeout(channel, timeout, &tv); - - switch ( select(nfds, &readers, &writers, NULL, tvp) ) { - case -1: if (errno != EINTR) { - ares_destroy(channel); - free_hostent(ar.ent); - return NETDB_INTERNAL; - } else - continue; - case 0: - FD_ZERO(&readers); - FD_ZERO(&writers); - /* fallthrough */ - default : ares_process(channel, &readers, &writers); - } - - } - - - ares_destroy(channel); - - if (ar.err == NETDB_SUCCESS) { - *name = strdup(ar.ent->h_name); - free_hostent(ar.ent); - } - return (ar.err); -} - -static int read_roots(const char *file) -{ - FILE *roots = fopen(file,"r"); - char buf[BUFSIZ]; - int cnt = 0; - - if (!roots) { - perror(file); - return 1; - } - - while (!feof(roots)) { - char *nl; - fgets(buf,sizeof buf,roots); - nl = strchr(buf,'\n'); - if (nl) *nl = 0; - - super_users = realloc(super_users, (cnt+1) * sizeof super_users[0]); - super_users[cnt] = strdup(buf); - super_users[++cnt] = NULL; - } - - fclose(roots); - - return 0; -} - -static int amIroot(const char *subj) -{ - int i; - - if (!subj) return 0; - for (i=0; super_users && super_users[i]; i++) - if (strcmp(subj,super_users[i]) == 0) return 1; - - return 0; -} - -static int parse_limits(char *opt, int *j_limit, int *e_limit, int *size_limit) -{ - return (sscanf(opt, "%d:%d:%d", j_limit, e_limit, size_limit) == 3); -} - -static int check_mkdir(const char *dir) -{ - struct stat sbuf; - - if ( stat(dir, &sbuf) ) - { - if ( errno == ENOENT ) - { - if ( mkdir(dir, S_IRWXU) ) - { - dprintf(("[%d] %s: %s\n", getpid(), dir, strerror(errno))); - if (!debug) syslog(LOG_CRIT, "%s: %m", dir); - return 1; - } - } - else - { - dprintf(("[%d] %s: %s\n", getpid(), dir, strerror(errno))); - if (!debug) syslog(LOG_CRIT, "%s: %m", dir); - return 1; - } - } - else if (S_ISDIR(sbuf.st_mode)) return 0; - else { - dprintf(("[%d] %s: not a directory\n", getpid(),dir)); - if (!debug) syslog(LOG_CRIT,"%s: not a directory",dir); - return 1; - } - - return 0; -} - -static int decrement_timeout(struct timeval *timeout, struct timeval before, struct timeval after) -{ - (*timeout).tv_sec = (*timeout).tv_sec - (after.tv_sec - before.tv_sec); - (*timeout).tv_usec = (*timeout).tv_usec - (after.tv_usec - before.tv_usec); - while ( (*timeout).tv_usec < 0) { - (*timeout).tv_sec--; - (*timeout).tv_usec += 1000000; - } - if ( ((*timeout).tv_sec < 0) || (((*timeout).tv_sec == 0) && ((*timeout).tv_usec == 0)) ) return(1); - else return(0); -} - diff --git a/org.glite.lb.server/src/db_store.c b/org.glite.lb.server/src/db_store.c deleted file mode 100644 index 8ff5fb5..0000000 --- a/org.glite.lb.server/src/db_store.c +++ /dev/null @@ -1,98 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include - -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/events_parse.h" -#include "store.h" -#include "lbs_db.h" -#include "lock.h" -#include "il_lbproxy.h" - -extern int debug; - -/* XXX */ -#define use_db 1 - -extern int edg_wll_NotifMatch(edg_wll_Context, const edg_wll_JobStat *); - -int -db_store(edg_wll_Context ctx,char *ucs, char *event) -{ - edg_wll_Event *ev; - int seq; - int err; - edg_wll_JobStat newstat; - - ev = NULL; - - edg_wll_ResetError(ctx); - memset(&newstat,0,sizeof newstat); - - if(edg_wll_ParseEvent(ctx, event, &ev)) - goto err; - - /* XXX: if event type is user tag, convert the tag name to lowercase! - * (not sure whether to convert a value too is reasonable - * or keep it 'case sensitive') - */ - if ( ev->any.type == EDG_WLL_EVENT_USERTAG ) - { - int i; - for ( i = 0; ev->userTag.name[i] != '\0'; i++ ) - ev->userTag.name[i] = tolower(ev->userTag.name[i]); - } - - if(ev->any.user == NULL) - ev->any.user = strdup(ucs); - - if(use_db) { - if (ctx->strict_locking && edg_wll_LockJob(ctx,ev->any.jobId)) goto err; - if(edg_wll_StoreEvent(ctx, ev,&seq)) - goto err; - } - - if (debug) { fputs(event,stderr); fputc('\n',stderr); } - - if (!ctx->strict_locking && edg_wll_LockJob(ctx,ev->any.jobId)) goto err; - - if ( ev->any.type == EDG_WLL_EVENT_CHANGEACL ) - err = edg_wll_UpdateACL(ctx, ev->any.jobId, - ev->changeACL.user_id, ev->changeACL.user_id_type, - ev->changeACL.permission, ev->changeACL.permission_type, - ev->changeACL.operation); - else - err = edg_wll_StepIntState(ctx,ev->any.jobId, ev, seq, ctx->isProxy? NULL: &newstat); - - if (edg_wll_UnlockJob(ctx,ev->any.jobId)) goto err; - if (err) goto err; - - if ( ctx->isProxy ) { - /* - * send event to the proper BK server - */ - if ( ev->any.type != EDG_WLL_EVENT_REGJOB - && edg_wll_EventSendProxy(ctx, ev->any.jobId, event) ) goto err; - } else if ( newstat.state ) { - edg_wll_NotifMatch(ctx, &newstat); - edg_wll_FreeStatus(&newstat); - } - - edg_wll_FreeEvent(ev); - free(ev); - - return(0); - - err: - if(ev) { - edg_wll_FreeEvent(ev); - free(ev); - } - - return edg_wll_Error(ctx,NULL,NULL); -} - diff --git a/org.glite.lb.server/src/dump.c b/org.glite.lb.server/src/dump.c deleted file mode 100644 index 67ae95b..0000000 --- a/org.glite.lb.server/src/dump.c +++ /dev/null @@ -1,192 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include - -#include "glite/lb/trio.h" -#include "glite/wmsutils/jobid/cjobid.h" - -#include "glite/lb/context-int.h" -#include "glite/lb/events_parse.h" -#include "glite/lb/ulm_parse.h" -#include "glite/lb/purge.h" -#include "glite/lb/purge.h" -#include "glite/lb/dump.h" - -#include "lbs_db.h" -#include "query.h" -#include "get_events.h" -#include "server_state.h" -#include "purge.h" - -static int handle_specials(edg_wll_Context,time_t *); - -#define sizofa(a) (sizeof(a)/sizeof((a)[0])) - -int edg_wll_DumpEvents(edg_wll_Context ctx,const edg_wll_DumpRequest *req,edg_wll_DumpResult *result) -{ - char *from_s, *to_s, *stmt, *time_s; - char *tmpfname; - time_t start,end; - edg_wll_Stmt q = NULL; - char *res[10]; - int event; - edg_wll_Event e; - int ret,dump = 2; /* TODO: manage dump file */ - time_t from = req->from,to = req->to; - - from_s = to_s = stmt = NULL; - memset(res,0,sizeof res); - memset(&e,0,sizeof e); - - time(&start); - edg_wll_ResetError(ctx); - - if ( (dump = edg_wll_CreateTmpDumpFile(ctx, &tmpfname)) == -1 ) - return edg_wll_Error(ctx, NULL, NULL); - - if (handle_specials(ctx,&from) || handle_specials(ctx,&to)) - { - unlink(tmpfname); - return edg_wll_Error(ctx,NULL,NULL); - } - - from_s = strdup(edg_wll_TimeToDB(from)); - to_s = strdup(edg_wll_TimeToDB(to)); - - trio_asprintf(&stmt, - "select event,dg_jobid,code,prog,host,u.cert_subj,time_stamp,usec,level,arrived " - "from events e,users u,jobs j " - "where u.userid=e.userid " - "and j.jobid = e.jobid " - "and j.dg_jobid like 'https://%|Ss:%d%%' " - "and arrived > '%|Ss' and arrived <= '%|Ss' " - "order by arrived", - ctx->srvName,ctx->srvPort, - from_s,to_s); - - if (edg_wll_ExecStmt(ctx,stmt,&q) < 0) goto clean; - - while ((ret = edg_wll_FetchRow(q,res)) > 0) { - assert(ret == sizofa(res)); - event = atoi(res[0]); free(res[0]); res[0] = NULL; - - if (convert_event_head(ctx,res+1,&e) - || edg_wll_get_event_flesh(ctx,event,&e)) - { - char *et,*ed; - int i; - - /* Most likely sort of internal inconsistency. - * Must not be fatal -- just complain - */ - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"%s event %d: %s (%s)\n",res[1],event,et,ed); - syslog(LOG_WARNING,"%s event %d: %s (%s)",res[1],event,et,ed); - free(et); free(ed); - for (i=0; ifrom = from; - result->to = to; - - edg_wll_CreateDumpFileFromTmp(ctx, tmpfname, &(result->server_file)); - unlink(tmpfname); - -clean: - edg_wll_FreeEvent(&e); - edg_wll_FreeStmt(&q); - - free(stmt); - free(from_s); - free(to_s); - return edg_wll_Error(ctx,NULL,NULL); -} - -static int handle_specials(edg_wll_Context ctx,time_t *t) -{ - char *time_s; - int ret; - - edg_wll_ResetError(ctx); - switch (*t) { - case EDG_WLL_DUMP_NOW: - time(t); - return 0; - case EDG_WLL_DUMP_LAST_START: - case EDG_WLL_DUMP_LAST_END: - switch (ret = edg_wll_GetServerState(ctx, - *t == EDG_WLL_DUMP_LAST_START ? - EDG_WLL_STATE_DUMP_START: - EDG_WLL_STATE_DUMP_END, - &time_s)) - { - case ENOENT: *t = 0; - edg_wll_ResetError(ctx); - break; - case 0: *t = edg_wll_DBToTime(time_s); - assert(*t >= 0); - break; - default: break; - } - break; - default: if (*t < 0) return edg_wll_SetError(ctx,EINVAL,"special time limit unrecognized"); - } - return edg_wll_Error(ctx,NULL,NULL); -} - - diff --git a/org.glite.lb.server/src/get_events.c.T b/org.glite.lb.server/src/get_events.c.T deleted file mode 100644 index a4b2f6e..0000000 --- a/org.glite.lb.server/src/get_events.c.T +++ /dev/null @@ -1,157 +0,0 @@ -#ident "$Header$" - -/* -@@@AUTO -*/ -@@@LANG: C - -/* Helper functions for getting events from the LB database * - * XXX: lots of stuff still hadcoded: - * there's mapping db.columns <-> union event fields - */ - -#include -#include -#include -#include -#include -#include - -#include "get_events.h" -#include "glite/lb/context-int.h" -#include "glite/lb/trio.h" -#include "glite/lb/events_parse.h" - -static void edg_wll_set_event_field(edg_wll_Event *,char *,char *); -static void edg_wll_set_event_field_warn(edg_wll_Event *,char *,char *); - -int edg_wll_get_event_flesh(edg_wll_Context ctx,int n,edg_wll_Event *e) -{ - char *jobid = edg_wlc_JobIdGetUnique(e->any.jobId), - *q = NULL,*nameval[2]; - edg_wll_Stmt sh; - int ret,t; - const char *tables[] = { "short_fields","long_fields" }; - - edg_wll_ResetError(ctx); - - for (t=0; t<=1; t++) { - trio_asprintf(&q,"select name,value from %s " - "where jobid = '%|Ss' and event = %d ", - tables[t],jobid,n); - - if ((ret=edg_wll_ExecStmt(ctx,q,&sh)) < 0) goto cleanup; - - while ((ret=edg_wll_FetchRow(sh,nameval)) > 0) { - edg_wll_set_event_field(e,nameval[0],nameval[1]); - free(nameval[0]); - /* XXX: nameval[1] freed in edg_wll_set_event_field - * if necessary - */ - } - - if (ret<0) goto cleanup; - edg_wll_FreeStmt(&sh); - free(q); q=NULL; - } - - ret=edg_wll_CheckEvent(ctx,e); - -cleanup: - if (sh) edg_wll_FreeStmt(&sh); - free(jobid); - free(q); - - if (ret) { edg_wll_FreeEvent(e); memset(e,0,sizeof *e); } - return ret; -} - - -/* print/log warning for database inconsistency */ - -static void edg_wll_set_event_field_warn( - edg_wll_Event *event, - char *name, - char *value) -{ - char *e = edg_wll_EventToString(event->any.type); - - fprintf(stderr, "edg_wll_set_event_field: bad field:" - "code=\"%s\" name=\"%s\" value=\"%s\"\n", - e, name, value); - free(e); - /* XXX edg_wll_Log */ -} - -/* set event structure field */ - -static void edg_wll_set_event_field( - edg_wll_Event *event, - char *name, - char *value) -{ -/* XXX: where's the best place to hande it? */ - if (!strcasecmp(name,"SRC_INSTANCE")) { - event->any.src_instance = value; - return; - } - -/* XXX: handled separately, should go to event_head one day */ - if (!strcasecmp(name,"SEQCODE")) { - event->any.seqcode = value; - return; - } - -@@@{ - for my $n (getAllFieldsOrdered $event) { - my @occ = getFieldOccurence $event $n; - next if $#occ == 0 && $occ[0] eq '_common_'; - selectType $event $occ[0]; - my $f = selectField $event $n; - my $name = getName $f; - my $lcname = lc $name; - gen qq{ -! if (!strcasecmp(name,"$lcname")) \{ -! switch (event->any.type) \{ -}; - for (@occ) { - next if $_ eq '_common_'; - selectType $event $_; - $f = selectField $event $n; - my $fucname = ucfirst $n; - my $uctype = uc $_; - my $flctype = lcfirst $_; - my $frs = $f->{codes} ? - "event->$flctype.$name = edg_wll_StringTo$_${fucname}(value);" : - fromString $f 'value',"event->$flctype.$name"; - gen qq{ -! case EDG_WLL_EVENT_$uctype: $frs break; -}; - } - gen qq{ -! default: edg_wll_set_event_field_warn(event,name,value); break; -! \} /* switch */ -! free(value); -! return; -! \} -}; - } -@@@} - - edg_wll_set_event_field_warn(event,name,value); - free(value); - return; -} - - -int compare_events_by_tv(const void *a, const void *b) -{ - const edg_wll_Event *e = (edg_wll_Event *)a; - const edg_wll_Event *f = (edg_wll_Event *)b; - - if (e->any.timestamp.tv_sec < f->any.timestamp.tv_sec) return -1; - if (e->any.timestamp.tv_sec > f->any.timestamp.tv_sec) return 1; - if (e->any.timestamp.tv_usec < f->any.timestamp.tv_usec) return -1; - if (e->any.timestamp.tv_usec > f->any.timestamp.tv_usec) return 1; - return 0; -} diff --git a/org.glite.lb.server/src/get_events.h b/org.glite.lb.server/src/get_events.h deleted file mode 100644 index cfa07c1..0000000 --- a/org.glite.lb.server/src/get_events.h +++ /dev/null @@ -1,32 +0,0 @@ -#ident "$Header$" - -/* Internal functions for getting event sets from the LB database */ -#include "lbs_db.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if 0 /* rel 1 */ -char *edg_wll_jobid_to_user( edg_wll_Context, char *); -void edg_wll_set_event_field_warn( edg_wll_Event *, char *, char *); -void edg_wll_set_event_field( edg_wll_Event *, char *, char *); -int edg_wll_get_events_restricted( edg_wll_Context, edg_wlc_JobId, char *, int, int, char *, edg_wll_Event **); -#define edg_wll_get_events(ctx,job,md5,emin,emax,ret) \ - edg_wll_get_events_restricted((ctx),(job),(md5),(emin),(emax),NULL,(ret)) -int edg_wll_last_event( edg_wll_Context, char *); -int compare_events_by_tv(const void *, const void *); -#endif - -int edg_wll_get_event_flesh(edg_wll_Context,int,edg_wll_Event *); -int edg_wll_QueryEventsServer(edg_wll_Context,int,const edg_wll_QueryRec **,const edg_wll_QueryRec **,edg_wll_Event **); - -int edg_wll_QueryJobsServer(edg_wll_Context, const edg_wll_QueryRec **, int, edg_wlc_JobId **, edg_wll_JobStat **); - -void edg_wll_SortEvents(edg_wll_Event *); -int edg_wll_compare_seq(const char *, const char *); - -#ifdef __cplusplus -} -#endif - diff --git a/org.glite.lb.server/src/il_lbproxy.c b/org.glite.lb.server/src/il_lbproxy.c deleted file mode 100644 index 0d768f6..0000000 --- a/org.glite.lb.server/src/il_lbproxy.c +++ /dev/null @@ -1,168 +0,0 @@ -/** - * il_lbproxy.c - * - implementation of IL API calls for LB proxy - * - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/lb/context-int.h" -#include "glite/lb/events_parse.h" -#include "glite/lb/escape.h" -#include "glite/lb/log_proto.h" -#include "glite/lb/lb_plain_io.h" - -#include "il_lbproxy.h" -#include "lb_xml_parse.h" - - - -#define FCNTL_ATTEMPTS 5 -#define FCNTL_TIMEOUT 1 -#define FILE_PREFIX "/tmp/lbproxy_events" -#define DEFAULT_SOCKET "/tmp/lbproxy_interlogger.sock" - -char *lbproxy_ilog_socket_path = DEFAULT_SOCKET; -char *lbproxy_ilog_file_prefix = FILE_PREFIX; - -#define tv_sub(a,b) {\ - (a).tv_usec -= (b).tv_usec;\ - (a).tv_sec -= (b).tv_sec;\ - if ((a).tv_usec < 0) {\ - (a).tv_sec--;\ - (a).tv_usec += 1000000;\ - }\ -} - -static int event_save_to_file_proxy( - edg_wll_Context ctx, - const char *event_file, - const char *ulm_data, - long *filepos) -{ - FILE *outfile; - struct flock filelock; - int filedesc, - i, filelock_status=-1; - - - for( i = 0; i < FCNTL_ATTEMPTS; i++ ) { - /* fopen and properly handle the filelock */ - if ( (outfile = fopen(event_file, "a")) == NULL ) { - edg_wll_SetError(ctx, errno, "fopen()"); - goto out; - } - if ( (filedesc = fileno(outfile)) == -1 ) { - edg_wll_SetError(ctx, errno, "fileno()"); - goto out1; - } - filelock.l_type = F_WRLCK; - filelock.l_whence = SEEK_SET; - filelock.l_start = 0; - filelock.l_len = 0; - filelock_status=fcntl(filedesc, F_SETLK, &filelock); - if(filelock_status < 0) { - switch(errno) { - case EAGAIN: - case EACCES: - case EINTR: - /* lock is held by someone else */ - sleep(FCNTL_TIMEOUT); - break; - default: - /* other error */ - edg_wll_SetError(ctx, errno, "fcntl()"); - goto out1; - } - } else { - /* lock acquired, break out of the loop */ - break; - } - } - if (fseek(outfile, 0, SEEK_END) == -1) { edg_wll_SetError(ctx, errno, "fseek()"); goto out1; } - if ((*filepos=ftell(outfile)) == -1) { edg_wll_SetError(ctx, errno, "ftell()"); goto out1; } - if (fputs(ulm_data, outfile) == EOF) { edg_wll_SetError(ctx, errno, "fputs()"); goto out1; } - if (fflush(outfile) == EOF) { edg_wll_SetError(ctx, errno, "fflush()"); goto out1; } - if (fsync(filedesc) < 0) { edg_wll_SetError(ctx, errno, "fsync()"); goto out1; } - -out1: - fclose(outfile); - -out: - return edg_wll_Error(ctx, NULL, NULL)? - edg_wll_UpdateError(ctx, 0, "event_save_to_file_proxy()"): 0; -} - - -static int event_send_socket_proxy( - edg_wll_Context ctx, - long filepos, - const char *ulm_data) -{ - edg_wll_PlainConnection conn; - struct sockaddr_un saddr; - int flags; - struct timeval timeout; - - - timeout.tv_sec = EDG_WLL_LOG_TIMEOUT_MAX; - timeout.tv_usec = 0; - - if ( (conn.sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0 ) - edg_wll_SetError(ctx, errno, "socket()"); - - memset(&saddr, 0, sizeof(saddr)); - saddr.sun_family = AF_UNIX; - strcpy(saddr.sun_path, lbproxy_ilog_socket_path); - - if ( (flags = fcntl(conn.sock, F_GETFL, 0)) < 0 - || fcntl(conn.sock, F_SETFL, flags | O_NONBLOCK) < 0) { - edg_wll_SetError(ctx, errno, "fcntl()"); - goto out; - } - - if ( connect(conn.sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { - if(errno != EISCONN) { edg_wll_SetError(ctx, errno, "connect()"); goto out; } - } - - if ( edg_wll_plain_write_full(&conn, &filepos, sizeof(filepos), &timeout) < 0 - || edg_wll_plain_write_full(&conn, (void*)ulm_data, strlen(ulm_data), &timeout) < 0 ) { - edg_wll_SetError(ctx, errno, "edg_wll_plain_write_full()"); - goto out; - } - -out: - close(conn.sock); - return edg_wll_Error(ctx, NULL, NULL)? - edg_wll_UpdateError(ctx, 0, "event_send_socket_proxy()"): 0; -} - - -int edg_wll_EventSendProxy(edg_wll_Context ctx, const edg_wlc_JobId jobid, const char *event) -{ - long filepos; - char *jobid_s, *event_file = NULL; - - - edg_wll_ResetError(ctx); - jobid_s = edg_wlc_JobIdGetUnique(jobid); - if ( !jobid_s ) { edg_wll_SetError(ctx, ENOMEM, "edg_wlc_JobIdGetUnique()"); goto out; } - - asprintf(&event_file, "%s.%s", lbproxy_ilog_file_prefix, jobid_s); - if ( !event_file ) { edg_wll_SetError(ctx, ENOMEM, "asprintf()"); goto out; } - - if ( event_save_to_file_proxy(ctx, event_file, event, &filepos) - || event_send_socket_proxy(ctx, filepos, event) ) goto out; - -out: - if ( jobid_s ) free(jobid_s); - if ( event_file ) free(event_file); - - return edg_wll_Error(ctx, NULL, NULL)? edg_wll_UpdateError(ctx, 0, "edg_wll_EventSendProxy()"): 0; -} diff --git a/org.glite.lb.server/src/il_lbproxy.h b/org.glite.lb.server/src/il_lbproxy.h deleted file mode 100644 index 4107304..0000000 --- a/org.glite.lb.server/src/il_lbproxy.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef IL_LBPROXY_H -#define IL_LBPROXY_H - -#ifdef __cplusplus -#extern "C" { -#endif - -extern char *lbproxy_ilog_socket_path; -extern char *lbproxy_ilog_file_prefix; - -int edg_wll_EventSendProxy(edg_wll_Context ctx, const edg_wlc_JobId jobid, const char *event); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/org.glite.lb.server/src/il_notification.c b/org.glite.lb.server/src/il_notification.c deleted file mode 100644 index bccc008..0000000 --- a/org.glite.lb.server/src/il_notification.c +++ /dev/null @@ -1,388 +0,0 @@ -/** - * il_notification.c - * - implementation of IL API calls for notifications - * - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/lb/context-int.h" -#include "glite/lb/notifid.h" -#include "glite/lb/events_parse.h" -#include "glite/lb/escape.h" -#include "glite/lb/log_proto.h" - -#include "il_notification.h" -#include "lb_xml_parse.h" - - - -#define FCNTL_ATTEMPTS 5 -#define FCNTL_TIMEOUT 1 -#define FILE_PREFIX "/tmp/notif_events" -#define DEFAULT_SOCKET "/tmp/notif_interlogger.sock" - -char *notif_ilog_socket_path = DEFAULT_SOCKET; -char *notif_ilog_file_prefix = FILE_PREFIX; - -#define tv_sub(a,b) {\ - (a).tv_usec -= (b).tv_usec;\ - (a).tv_sec -= (b).tv_sec;\ - if ((a).tv_usec < 0) {\ - (a).tv_sec--;\ - (a).tv_usec += 1000000;\ - }\ -} - -static -int -notif_create_ulm( - edg_wll_Context context, - edg_wll_NotifId reg_id, - const char *host, - const uint16_t port, - const char *owner, - const char *notif_data, - char **ulm_data, - char **reg_id_s) -{ - int ret; - edg_wll_Event *event=NULL; - - *ulm_data = NULL; - *reg_id_s = NULL; - - event = edg_wll_InitEvent(EDG_WLL_EVENT_NOTIFICATION); - - gettimeofday(&event->any.timestamp,0); - if (context->p_host) event->any.host = strdup(context->p_host); - event->any.level = context->p_level; - event->any.source = context->p_source; - if (context->p_instance) event->notification.src_instance = strdup(context->p_instance); - event->notification.notifId = reg_id; - if (owner) event->notification.owner = strdup(owner); - if (host) event->notification.dest_host = strdup(host); - event->notification.dest_port = port; - if (notif_data) event->notification.jobstat = strdup(notif_data); - - if ((*ulm_data = edg_wll_UnparseNotifEvent(context,event)) == NULL) { - edg_wll_SetError(context, ret = ENOMEM, "edg_wll_UnparseNotifEvent()"); - goto out; - } - - if((*reg_id_s = edg_wll_NotifIdGetUnique(reg_id)) == NULL) { - edg_wll_SetError(context, ret = ENOMEM, "edg_wll_NotifIdGetUnique()"); - goto out; - } - - ret = 0; - -out: - if(event) { - edg_wll_FreeEvent(event); - free(event); - } - if(ret) edg_wll_UpdateError(context, ret, "notif_create_ulm()"); - return(ret); -} - - -static -int -notif_save_to_file(edg_wll_Context context, - const char *event_file, - const char *ulm_data, - long *filepos) -{ - int ret; - FILE *outfile; - int filedesc; - struct flock filelock; - int i, filelock_status=-1; - - for(i=0; i < FCNTL_ATTEMPTS; i++) { - /* fopen and properly handle the filelock */ - if ((outfile = fopen(event_file,"a")) == NULL) { - edg_wll_SetError(context, ret = errno, "fopen()"); - goto out; - } - if ((filedesc = fileno(outfile)) == -1) { - edg_wll_SetError(context, ret = errno, "fileno()"); - goto out1; - } - filelock.l_type = F_WRLCK; - filelock.l_whence = SEEK_SET; - filelock.l_start = 0; - filelock.l_len = 0; - filelock_status=fcntl(filedesc, F_SETLK, &filelock); - if(filelock_status < 0) { - switch(errno) { - case EAGAIN: - case EACCES: - case EINTR: - /* lock is held by someone else */ - sleep(FCNTL_TIMEOUT); - break; - default: - /* other error */ - edg_wll_SetError(context, ret=errno, "fcntl()"); - goto out1; - } - } else { - /* lock acquired, break out of the loop */ - break; - } - } - if (fseek(outfile, 0, SEEK_END) == -1) { - edg_wll_SetError(context, ret = errno, "fseek()"); - goto out1; - } - if ((*filepos=ftell(outfile)) == -1) { - edg_wll_SetError(context, ret = errno, "ftell()"); - goto out1; - } - /* write, flush and sync */ - if (fputs(ulm_data, outfile) == EOF) { - edg_wll_SetError(context, ret = errno, "fputs()"); - goto out1; - } - if (fflush(outfile) == EOF) { - edg_wll_SetError(context, ret = errno, "fflush()"); - goto out1; - } - if (fsync(filedesc) < 0) { /* synchronize */ - edg_wll_SetError(context, ret = errno, "fsync()"); - goto out1; - } - - ret = 0; -out1: - /* close and unlock */ - fclose(outfile); -out: - if(ret) edg_wll_UpdateError(context, ret, "notif_save_to_file()"); - return(ret); -} - - -static -ssize_t -socket_write_full(edg_wll_Context context, - int sock, - void *buf, - size_t bufsize, - struct timeval *timeout, - ssize_t *total) -{ - int ret = 0; - ssize_t len; - - *total = 0; - while (bufsize > 0) { - - fd_set fds; - struct timeval to,before,after; - - if (timeout) { - memcpy(&to, timeout, sizeof(to)); - gettimeofday(&before, NULL); - } - - len = write(sock, buf, bufsize); - while (len <= 0) { - FD_ZERO(&fds); - FD_SET(sock, &fds); - if (select(sock+1, &fds, NULL, NULL, timeout ? &to : NULL) < 0) { - edg_wll_SetError(context, ret = errno, "select()"); - goto out; - } - len = write(sock, buf, bufsize); - } - if (timeout) { - gettimeofday(&after,NULL); - tv_sub(after, before); - tv_sub(*timeout,after); - if (timeout->tv_sec < 0) { - timeout->tv_sec = 0; - timeout->tv_usec = 0; - } - } - - if (len < 0) { - edg_wll_SetError(context, ret = errno, "write()"); - goto out; - } - - bufsize -= len; - buf += len; - *total += len; - } - - ret = 0; -out: - if(ret) edg_wll_UpdateError(context, ret, "socket_write_full()"); - return ret; -} - - -static -int -notif_send_socket(edg_wll_Context context, - long filepos, - const char *ulm_data) -{ - int ret; - struct sockaddr_un saddr; - int msg_sock, flags; - size_t count; - struct timeval timeout; - - timeout.tv_sec = EDG_WLL_LOG_TIMEOUT_MAX; - timeout.tv_usec = 0; - - msg_sock = socket(PF_UNIX, SOCK_STREAM, 0); - if(msg_sock < 0) { - edg_wll_SetError(context, ret = errno, "socket()"); - goto out; - } - - memset(&saddr, 0, sizeof(saddr)); - saddr.sun_family = AF_UNIX; - strcpy(saddr.sun_path, notif_ilog_socket_path); - - if ((flags = fcntl(msg_sock, F_GETFL, 0)) < 0 || - fcntl(msg_sock, F_SETFL, flags | O_NONBLOCK) < 0) { - edg_wll_SetError(context, ret = errno, "fcntl()"); - goto out1; - } - - if(connect(msg_sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { - if(errno != EISCONN) { - edg_wll_SetError(context, ret = errno, "connect()"); - goto out1; - } - } - - if (socket_write_full(context, msg_sock, &filepos, sizeof(filepos), &timeout, &count) < 0) { - ret = errno; - goto out1; - } - - if (socket_write_full(context, msg_sock, (void*)ulm_data, strlen(ulm_data), &timeout, &count) < 0) { - ret = errno; - goto out1; - } - - ret = 0; - -out1: - close(msg_sock); -out: - if(ret) edg_wll_UpdateError(context, ret, "notif_send_socket()"); - return(ret); -} - - -int -edg_wll_NotifSend(edg_wll_Context context, - edg_wll_NotifId reg_id, - const char *host, - int port, - const char *owner, - const char *notif_data) -{ - int ret; - long filepos; - char *ulm_data, *reg_id_s, *event_file; - - if((ret=notif_create_ulm(context, - reg_id, - host, - port, - owner, - notif_data, - &ulm_data, - ®_id_s))) { - goto out; - } - - asprintf(&event_file, "%s.%s", notif_ilog_file_prefix, reg_id_s); - if(event_file == NULL) { - edg_wll_SetError(context, ret=ENOMEM, "asprintf()"); - goto out; - } - - if((ret=notif_save_to_file(context, - event_file, - ulm_data, - &filepos))) { - goto out; - } - - if((ret=notif_send_socket(context, - filepos, - ulm_data))) { - goto out; - } - ret = 0; - -out: - if(ulm_data) free(ulm_data); - if(reg_id_s) free(reg_id_s); - if(ret) edg_wll_UpdateError(context, ret, "edg_wll_NotifSend()"); - return(ret); -} - - -int -edg_wll_NotifJobStatus(edg_wll_Context context, - edg_wll_NotifId reg_id, - const char *host, - int port, - const char *owner, - const edg_wll_JobStat notif_job_stat) -{ - int ret=0; - char *xml_data, *xml_esc_data=NULL; - - if(edg_wll_JobStatusToXML(context, notif_job_stat, &xml_data)) - goto out; - - if((xml_esc_data = edg_wll_EscapeXML(xml_data)) == NULL) { - edg_wll_SetError(context, ret=ENOMEM, "edg_wll_EscapeXML()"); - goto out; - } - - ret=edg_wll_NotifSend(context, reg_id, host, port, owner, xml_esc_data); - -out: - if(xml_data) free(xml_data); - if(xml_esc_data) free(xml_esc_data); - if(ret) edg_wll_UpdateError(context, ret, "edg_wll_NotifJobStatus()"); - return(ret); -} - - -int -edg_wll_NotifChangeDestination(edg_wll_Context context, - edg_wll_NotifId reg_id, - const char *host, - int port) -{ - return(edg_wll_NotifSend(context, reg_id, host, port, "", "")); -} - - -int -edg_wll_NotifCancelRegId(edg_wll_Context context, - edg_wll_NotifId reg_id) -{ - return(edg_wll_NotifSend(context, reg_id, NULL, 0, "", "")); -} - diff --git a/org.glite.lb.server/src/il_notification.h b/org.glite.lb.server/src/il_notification.h deleted file mode 100644 index 52487c4..0000000 --- a/org.glite.lb.server/src/il_notification.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef IL_NOTIFICATION_H -#define IL_NOTIFICATION_H - -/* needed for the edg_wll_NotifId */ -#include "glite/lb/notification.h" -/* import the edg_wll_JobStat structure */ -#include "glite/lb/jobstat.h" - -#ifdef __cplusplus -#extern "C" { -#endif - -extern char *notif_ilog_socket_path; -extern char *notif_ilog_file_prefix; - -/** Send ULM notification string to interlogger. - * Stores notification to file according to registration id and send it - * to interlogger using local socket. - * \param reg_id registration id - * \param host,port address to deliver the notification to. - * If NULL, it means no further notifications will - * follow (the client has unregistered). It always - * overrides previous values (ie. changes the - * reg_id->client address mapping in interlogger). - * \param owner DN of the registration owner, this will be verified - * against client's certificate - * \param notif_data ULM formatted notification string, may be NULL, - * if there is nothing to be sent to client. - * \retval 0 OK - * \retval EINVAL bad jobId, unknown event code, or the format - * string together with the remaining arguments - * does not form a valid event - * \retval ENOSPC unable to accept the event due to lack of disk - * space etc. - * \retval ENOMEM failed to allocate memory - * \retval EAGAIN non blocking return from the call, the event - * did not come through socket, but is backed up - * in file - */ -int -edg_wll_NotifSend(edg_wll_Context context, - edg_wll_NotifId reg_id, - const char *host, - int port, - const char *owner, - const char *notif_data); - - -/** Send job status notification. - * Creates ULM notification string and sends it using - * edg_wll_NotifSend(). The job status is encoded into XML and escaped - * before inclusion into ULM. - * \param reg_id registration id - * \param host,port address to deliver the notification to. - * \param owner DN of the registration owner, this will be verified - * against client's certificate - * \param notif_job_stat structure describing job status - * \see edg_wll_NotifSend() - */ -int -edg_wll_NotifJobStatus(edg_wll_Context context, - edg_wll_NotifId reg_id, - const char *host, - int port, - const char *owner, - const edg_wll_JobStat notif_job_stat); - - -/** Change address for notification delivery. - * Creates ULM string and uses edg_wll_NotifSend() to pass it - * to interlogger. - * \param reg_id registration id - * \param host,port new delivery address - * \see edg_wll_NotifSend() - */ -int -edg_wll_NotifChangeDestination(edg_wll_Context context, - edg_wll_NotifId reg_id, - const char *host, - int port); - -/** Cancel registration. - * Creates ULM string and uses edg_wll_NotifSend() to pass it to - * interlogger. - * \param reg_id registration id - */ -int -edg_wll_NotifCancelRegId(edg_wll_Context context, - edg_wll_NotifId reg_id); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/org.glite.lb.server/src/index.c.T b/org.glite.lb.server/src/index.c.T deleted file mode 100644 index b3cbd18..0000000 --- a/org.glite.lb.server/src/index.c.T +++ /dev/null @@ -1,227 +0,0 @@ -#include -#include -#include -#include - -#include "glite/lb/context-int.h" -#include "lbs_db.h" -#include "index.h" - -extern int debug; - -#define const_len(c) (sizeof((c))-1) - -/* TODO: - - better error recovery (skip unrecognised indices etc.) - - leaks memory on errors -*/ - -int edg_wll_QueryJobIndices(edg_wll_Context ctx,edg_wll_QueryRec *** index_out,char ***keys_out) -{ - edg_wll_QueryRec **idx = NULL; - edg_wll_Stmt stmt = NULL; - - int i,j,ret; - - static const char *built_in_indices[] = { - "PRIMARY", - "parent_job", - NULL - }; - -/* XXX: "show index from" columns. Matches at least MySQL 4.0.11 */ - - char *showcol[12]; - int Key_name,Seq_in_index,Column_name,Sub_part; - - char **keys = NULL; - int *cols = NULL; - char **col_names = NULL; - - int nkeys = 0; - - Key_name = Seq_in_index = Column_name = Sub_part = -1; - - if (edg_wll_ExecStmt(ctx,"show index from states",&stmt)<0) - return edg_wll_Error(ctx,NULL,NULL); - - while ((ret = edg_wll_FetchRow(stmt,showcol))) { - if (ret < 0) return edg_wll_Error(ctx,NULL,NULL); - assert(ret <= sizeof showcol/sizeof showcol[0]); - - if (!col_names) { - col_names = malloc(ret * sizeof col_names[0]); - edg_wll_QueryColumns(stmt,col_names); - for (i=0; i= 0 && Seq_in_index >= 0 && - Column_name >= 0 && Sub_part >= 0); - - } - - - for (j=0; built_in_indices[j]; j++) { - if (strcasecmp(showcol[Key_name],built_in_indices[j]) == 0) { - for (i=0; iattr != r2->attr) return 1; - switch (r1->attr) { - case EDG_WLL_QUERY_ATTR_USERTAG: - return strcasecmp(r1->attr_id.tag,r2->attr_id.tag); - case EDG_WLL_QUERY_ATTR_TIME: - return r1->attr_id.state != r2->attr_id.state; - default: - return 0; - } -} - -static struct { - const char *name; - edg_wll_QueryAttr attr; -} std_attrs[] = -{ -@@@{ - for my $n ($status->getAllFieldsOrdered) { - my $f = selectField $status $n; - next unless $f->{index}; - my $u = uc getName $f; - gen "\t{ \"$n\", EDG_WLL_QUERY_ATTR_$u },\n"; - } -@@@} - { NULL, }, -}; - -int edg_wll_ColumnToQueryRec(const char *col_name,edg_wll_QueryRec *rec) -{ - int i; - - memset(rec,0,sizeof *rec); - if (strncasecmp(col_name,STD_PREFIX,const_len(STD_PREFIX)) == 0) { - for (i=0; std_attrs[i].name - && strcasecmp(std_attrs[i].name,col_name+const_len(STD_PREFIX)); i++); - - if (std_attrs[i].name) rec->attr = std_attrs[i].attr; - } - else if (strncasecmp(col_name,TIME_PREFIX,const_len(TIME_PREFIX)) == 0) { - rec->attr_id.state = edg_wll_StringToStat(col_name+const_len(TIME_PREFIX)); - if (rec->attr_id.state != (edg_wll_JobStatCode) -1) rec->attr = EDG_WLL_QUERY_ATTR_TIME; - } - else if (strncasecmp(col_name,USR_PREFIX,const_len(USR_PREFIX)) == 0) { - rec->attr = EDG_WLL_QUERY_ATTR_USERTAG; - rec->attr_id.tag = strdup(col_name+const_len(USR_PREFIX)); - rec->value.c = NULL; - } - - return !rec->attr; -} - -char * edg_wll_QueryRecToColumn(const edg_wll_QueryRec *rec) -{ - char col[100] = ""; - - if (rec->attr == EDG_WLL_QUERY_ATTR_USERTAG) { - strcpy(col,USR_PREFIX); - strcat(col,rec->attr_id.tag); - } - else if (rec->attr == EDG_WLL_QUERY_ATTR_TIME) { - char *s = edg_wll_StatToString(rec->attr_id.state); - - if (s) { - strcpy(col,TIME_PREFIX); - strcat(col,s); - free(s); - } - } - else { - int i; - for (i=0; std_attrs[i].name && std_attrs[i].attr != rec->attr; i++); - if (std_attrs[i].name) { - strcpy(col,STD_PREFIX); - strcat(col,std_attrs[i].name); - } - } - - return col[0] ? strdup(col) : NULL; -} - -char * edg_wll_QueryRecToColumnExt(const edg_wll_QueryRec *rec) -{ - char *intern = edg_wll_QueryRecToColumn(rec), - *out; - - if (!intern) return NULL; - - switch (rec->attr) { - case EDG_WLL_QUERY_ATTR_USERTAG: - out = strdup(intern+const_len(USR_PREFIX)); - break; - case EDG_WLL_QUERY_ATTR_TIME: - out = strdup(intern+const_len(TIME_PREFIX)); - break; - default: - out = strdup(intern+const_len(STD_PREFIX)); - break; - } - free(intern); - return out; -} - -void edg_wll_FreeIColumnRec(edg_wll_IColumnRec *icrp) -{ - if (icrp->qrec.attr == EDG_WLL_QUERY_ATTR_USERTAG) - free(icrp->qrec.attr_id.tag); - free(icrp->colname); -} - diff --git a/org.glite.lb.server/src/index.h b/org.glite.lb.server/src/index.h deleted file mode 100644 index 2e585f2..0000000 --- a/org.glite.lb.server/src/index.h +++ /dev/null @@ -1,27 +0,0 @@ - -int edg_wll_QueryJobIndices(edg_wll_Context,edg_wll_QueryRec ***,char ***); -int edg_wll_ColumnToQueryRec(const char *,edg_wll_QueryRec *); -char * edg_wll_QueryRecToColumn(const edg_wll_QueryRec *); -char * edg_wll_QueryRecToColumnExt(const edg_wll_QueryRec *); - -int edg_wll_ParseIndexConfig(edg_wll_Context,const char *,edg_wll_QueryRec ***); -int edg_wll_DumpIndexConfig(edg_wll_Context,const char *,edg_wll_QueryRec * const *); - -int edg_wll_CmpColumn(const edg_wll_QueryRec *,const edg_wll_QueryRec *); - -typedef struct _edg_wll_IColumnRec { - edg_wll_QueryRec qrec; - char * colname; -} edg_wll_IColumnRec; - -void edg_wll_FreeIColumnRec(edg_wll_IColumnRec *); - -int yylex(); - -extern int lex_int; -extern char *lex_out; -extern int lex_line; - -#define STD_PREFIX "STD_" -#define USR_PREFIX "USR_" -#define TIME_PREFIX "TIME_" diff --git a/org.glite.lb.server/src/index_lex.l b/org.glite.lb.server/src/index_lex.l deleted file mode 100644 index fa552a1..0000000 --- a/org.glite.lb.server/src/index_lex.l +++ /dev/null @@ -1,47 +0,0 @@ -%{ -#ident "$Header$" - -#include - -#include "glite/lb/context-int.h" -#include "index_parse.h" -#include "index.h" - -char *lex_out; -int lex_int; -int lex_line; - -int yywrap(void) { return 1; } - -#define YY_NO_UNPUT - -%} - - -delim [ \t] -ws {delim}+ -string \"[^\"\n]*\" -digit [0-9] -int {digit}+ - -%% -{ws} {} - -JobIndices return JOB_INDICES; -type return TYPE; -name return NAME; -prefixlen return PREFIX; -{int} { - lex_int = atoi(yytext); - return INT; - } -{string} { - int len; - lex_out = malloc(len = strlen(yytext)-1); - strncpy(lex_out,yytext+1,len-1); - lex_out[len-1] = 0; - return STRING; - } -\n lex_line++; -. return *yytext; - diff --git a/org.glite.lb.server/src/index_parse.y b/org.glite.lb.server/src/index_parse.y deleted file mode 100644 index 4c9265b..0000000 --- a/org.glite.lb.server/src/index_parse.y +++ /dev/null @@ -1,242 +0,0 @@ -%{ -#ident "$Header$" - - -#include -#include - -#include "glite/lb/context-int.h" - -#include "lbs_db.h" -#include "index.h" - -#define yyerror(x) {} - -#define YYDEBUG 1 - -#define ATTR_TYPE_SYSTEM "system" -#define ATTR_TYPE_USER "user" -#define ATTR_TYPE_TIME "time" - -static edg_wll_Context parse_ctx; -static const char *parse_fname; - -#define bailout(msg) \ -{ \ - char *buf; \ - \ - asprintf(&buf,"%s:%d: %s",parse_fname,lex_line,(msg)); \ - edg_wll_SetError(parse_ctx,EINVAL,buf); \ - free(buf); \ - YYABORT; \ -} - -extern FILE *yyin; - -edg_wll_QueryRec **indices_out; - -%} - -%term JOB_INDICES -%term STRING -%term INT -%term TYPE -%term NAME -%term PREFIX - -%union -{ - char *s; - int i; - edg_wll_QueryRec qr; - edg_wll_QueryRec *qrl; - edg_wll_QueryRec **qrll; - struct elem_attr { - int attr; - char *val; - } attr; -} - -%type string -%type int -%type job_index_elem -%type job_index job_index_elem_list -%type job_index_list job_indices; -%type elem_attr opt_elem_attr - -%% - -config : '[' job_indices soft_semicolon ']' { indices_out = $2; } - ; - -job_indices : JOB_INDICES '=' '{' job_index_list soft_comma '}' { $$ = $4; } - ; - -job_index_list : job_index { $$ = calloc(2,sizeof (*$$)); *$$ = $1; } - | job_index_list ',' job_index -{ - int i; - for (i=0; $1[i]; i++); - $$ = realloc($1,(i+2) * sizeof *$1); - $$[i] = $3; - $$[i+1] = NULL; -} - ; - -job_index : job_index_elem { $$ = calloc(2,sizeof (*$$)); memcpy($$,&$1,sizeof $1); } - | '{' job_index_elem_list '}' { $$ = $2; } - ; - -job_index_elem_list : job_index_elem { $$ = calloc(2,sizeof (*$$)); memcpy($$,&$1,sizeof $1); } - | job_index_elem_list ',' job_index_elem -{ - int i; - for (i=0; $1[i].attr; i++); - $$ = realloc($1,(i+2) * sizeof *$1); - memcpy($$+i,&$3,sizeof $3); - memset($$+i+1,0,sizeof *$$); -} - ; - -job_index_elem : '[' elem_attr ';' elem_attr opt_elem_attr ']' -{ - char *name = $2.attr == NAME ? $2.val : - $4.attr == NAME ? $4.val : - $5.attr == NAME ? $5.val : NULL, - *type = $2.attr == TYPE ? $2.val : - $4.attr == TYPE ? $4.val : - $5.attr == TYPE ? $5.val : NULL; - int prefix = $2.attr == PREFIX ? (int) $2.val : - $4.attr == PREFIX ? (int) $4.val : - $5.attr == PREFIX ? (int) $5.val : 0; - - - if (!name) bailout("`name' required"); - if (!type) bailout("`type' required"); - - if (strcasecmp(type,ATTR_TYPE_SYSTEM) == 0) { - char *name2; - asprintf(&name2,STD_PREFIX "%s",name); - if (edg_wll_ColumnToQueryRec(name2,&$$)) bailout("unknown attribute"); - free(name2); - free(name); - } - else if (strcasecmp(type,ATTR_TYPE_USER) == 0) { - $$.attr = EDG_WLL_QUERY_ATTR_USERTAG; - $$.attr_id.tag = name; - } - else if (strcasecmp(type,ATTR_TYPE_TIME) == 0) { - char *name2; - if (prefix) bailout("PREFIXLEN is not valid with time attributes"); - asprintf(&name2,TIME_PREFIX "%s",name); - if (edg_wll_ColumnToQueryRec(name2,&$$)) bailout("unknown attribute"); - free(name2); - free(name); - } - else bailout("unknown attr type"); - - $$.value.i = prefix; -} - ; - -elem_attr : TYPE '=' string { $$.attr = TYPE; $$.val = $3; } - | NAME '=' string { $$.attr = NAME; $$.val = $3; } - | PREFIX '=' int { $$.attr = PREFIX; $$.val = (char *) $3; } - ; - -opt_elem_attr : { $$.attr = 0; $$.val = NULL; } - | ';' elem_attr { $$ = $2; } - ; - -string : STRING { $$ = lex_out; lex_out = NULL; } - ; - -int : INT { $$ = lex_int; } - ; - -soft_semicolon : - | ';' - ; - -soft_comma : - | ',' - ; - - -%% - - -/* XXX: uses static variables -- non thread-safe */ - -int edg_wll_ParseIndexConfig(edg_wll_Context ctx,const char *fname,edg_wll_QueryRec ***out) -{ - yyin = strcmp(fname,"-") ? fopen(fname,"r") : stdin; - lex_line = 1; - - if (!yyin) return edg_wll_SetError(ctx,errno,fname); - - parse_ctx = ctx; - parse_fname = fname; - edg_wll_ResetError(ctx); - - /* yydebug = 1; */ - if (yyparse() && !edg_wll_Error(ctx,NULL,NULL)) { - char buf[100]; - if (yyin != stdin) fclose(yyin); - sprintf(buf,"%s:%d: parse error",fname,lex_line); - return edg_wll_SetError(ctx,EINVAL,buf); - } - if (yyin != stdin) fclose(yyin); - - if (!edg_wll_Error(ctx,NULL,NULL)) *out = indices_out; - indices_out = NULL; /* XXX: memory leak on error but who cares? */ - return edg_wll_Error(ctx,NULL,NULL); -} - -int edg_wll_DumpIndexConfig(edg_wll_Context ctx,const char *fname,edg_wll_QueryRec * const *idx) -{ - int haveit = 0; - - FILE *f = strcmp(fname,"-") ? fopen(fname,"w") : stdout; - - if (!f) return edg_wll_SetError(ctx,errno,fname); - if (idx && *idx) { haveit = 1; fputs("[\n\tJobIndices = {\n",f); } - - while (idx && *idx) { - const edg_wll_QueryRec *i; - int multi = (*idx)[1].attr; - - fputs(multi ? "\t\t{\n" : "\t\t",f); - - for (i=*idx; i->attr; i++) { - char *cn = edg_wll_QueryRecToColumnExt(i); - char prefix[100] = ""; - char *type; - - switch (i->attr) { - case EDG_WLL_QUERY_ATTR_USERTAG: type = ATTR_TYPE_USER; break; - case EDG_WLL_QUERY_ATTR_TIME: type = ATTR_TYPE_TIME; break; - default: type = ATTR_TYPE_SYSTEM; break; - } - - if (i->value.i) sprintf(prefix,"; prefixlen = %d ",i->value.i); - if (multi) fputs("\t\t\t",f); - fprintf(f,"[ type = \"%s\"; name = \"%s\" %s]",type,cn,prefix); - if (multi) fputs(i[1].attr ? ",\n" : "\n",f); - free(cn); - } - - if (multi) fputs("\t\t}",f); - fputs(idx[1] ? ",\n" : "\n",f); - - idx++; - } - - if (haveit) { - fputs("\t}\n]\n",f); - return edg_wll_ResetError(ctx); - } - else return edg_wll_SetError(ctx,ENOENT,"no indices"); -} - - diff --git a/org.glite.lb.server/src/jobstat.c b/org.glite.lb.server/src/jobstat.c deleted file mode 100644 index a5dbc56..0000000 --- a/org.glite.lb.server/src/jobstat.c +++ /dev/null @@ -1,1250 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/lb/producer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/trio.h" - -#include "get_events.h" -#include "store.h" -#include "lock.h" -#include "index.h" -#include "jobstat.h" -#include "lb_authz.h" - - -extern int debug; - -#define DAG_ENABLE 1 - -#ifndef dprintf -#define dprintf(x) { if (debug) printf x; } -#endif - -/* TBD: share in whole logging or workload */ -#ifdef __GNUC__ -#define UNUSED_VAR __attribute__((unused)) -#else -#define UNUSED_VAR -#endif - -#define RET_FAIL 0 -#define RET_OK 1 -#define RET_FATAL RET_FAIL -#define RET_SOON 2 -#define RET_LATE 3 -#define RET_BADSEQ 4 -#define RET_SUSPECT 5 -#define RET_IGNORE 6 -#define RET_INTERNAL 100 - -#define rep(a,b) { free(a); a = (b == NULL) ? NULL : strdup(b); } -#define mov(a,b) { free(a); a = b; b = NULL; } - -static void warn (const char* format, ...) UNUSED_VAR ; -static char *job_owner(edg_wll_Context,char *); -static char* location_string(const char*, const char*, const char*); -static int add_stringlist(char ***, const char *) UNUSED_VAR; -static int add_taglist(edg_wll_TagValue **, const char *, const char *); - - -int edg_wll_intJobStatus(edg_wll_Context, const edg_wlc_JobId, int, intJobStat *, int); -edg_wll_ErrorCode edg_wll_StoreIntState(edg_wll_Context, intJobStat *, int); -edg_wll_ErrorCode edg_wll_LoadIntState(edg_wll_Context , edg_wlc_JobId , int, intJobStat **); - -int js_enable_store = 1; - -/* - * Basic manipulations with the internal representation of job state - */ - -static void init_intJobStat(intJobStat *p) -{ - memset(p, 0, sizeof(intJobStat)); - p->pub.jobtype = EDG_WLL_STAT_SIMPLE; - p->pub.children_hist = (int*) calloc(1+EDG_WLL_NUMBER_OF_STATCODES, sizeof(int)); - p->pub.children_hist[0] = EDG_WLL_NUMBER_OF_STATCODES; - p->pub.stateEnterTimes = (int*) calloc(1+EDG_WLL_NUMBER_OF_STATCODES, sizeof(int)); - p->pub.stateEnterTimes[0] = EDG_WLL_NUMBER_OF_STATCODES; - /* TBD: generate */ -} - -static void destroy_intJobStat_extension(intJobStat *p) -{ - free(p->last_seqcode); p->last_seqcode = NULL; - free(p->last_cancel_seqcode); p->last_cancel_seqcode = NULL; - p->wontresub = 0; -} - -void destroy_intJobStat(intJobStat *p) -{ - edg_wll_FreeStatus(&p->pub); - destroy_intJobStat_extension(p); - memset(p, 0, sizeof(intJobStat)); -} - -#if 0 -static int eval_expect_update(intJobStat *, int *, char **); -#endif - -static int processEvent(intJobStat *, edg_wll_Event *, int, int, char **); - -static char* matched_substr(char *, regmatch_t) UNUSED_VAR; - -static char* matched_substr(char *in, regmatch_t match) -{ - int len; - char *s; - - len = match.rm_eo - match.rm_so; - s = calloc(1, len + 1); - if (s != NULL) { - strncpy(s, in + (int)match.rm_so, len); - } - - return s; -} - - -int edg_wll_JobStatus( - edg_wll_Context ctx, - const edg_wlc_JobId job, - int flags, - edg_wll_JobStat *stat) -{ - -/* Local variables */ - char *string_jobid; - char *md5_jobid; - - intJobStat jobstat; - intJobStat *ijsp; - int intErr = 0; - int lockErr; - edg_wll_Acl acl = NULL; -#if DAG_ENABLE - char *stmt = NULL; -#endif - - edg_wll_ResetError(ctx); - - string_jobid = edg_wlc_JobIdUnparse(job); - if (string_jobid == NULL || stat == NULL) - return edg_wll_SetError(ctx,EINVAL, NULL); - md5_jobid = edg_wlc_JobIdGetUnique(job); - - if ( !(jobstat.pub.owner = job_owner(ctx,md5_jobid)) ) { - free(md5_jobid); - free(string_jobid); - return edg_wll_Error(ctx,NULL,NULL); - } - - intErr = edg_wll_GetACL(ctx, job, &acl); - if (intErr) { - free(md5_jobid); - free(string_jobid); - return edg_wll_Error(ctx,NULL,NULL); - } - - /* authorization check */ - if ( !(ctx->noAuth) && - (!(ctx->peerName) || strcmp(ctx->peerName, jobstat.pub.owner))) { - intErr = (acl == NULL) || edg_wll_CheckACL(ctx, acl, EDG_WLL_PERM_READ); - if (intErr) { - free(string_jobid); - free(md5_jobid); - free(jobstat.pub.owner); jobstat.pub.owner = NULL; - if (acl) { - edg_wll_FreeAcl(acl); - return edg_wll_Error(ctx, NULL, NULL); - } else { - return edg_wll_SetError(ctx,EPERM, "not owner, no ACL is set"); - } - } - } - - intErr = edg_wll_LoadIntState(ctx, job, -1 /*all events*/, &ijsp); - if (!intErr) { - *stat = ijsp->pub; - destroy_intJobStat_extension(ijsp); - free(ijsp); - - } else { - lockErr = edg_wll_LockJob(ctx,job); - intErr = edg_wll_intJobStatus(ctx, job, flags,&jobstat, js_enable_store && !lockErr); - if (!lockErr) { - edg_wll_UnlockJob(ctx,job); - } - - *stat = jobstat.pub; - if (intErr) edg_wll_FreeStatus(&jobstat.pub); - destroy_intJobStat_extension(&jobstat); - } - - if (intErr) { - free(string_jobid); - free(md5_jobid); - if (acl) edg_wll_FreeAcl(acl); - return edg_wll_Error(ctx, NULL, NULL); - } - - if (acl) { - stat->acl = strdup(acl->string); - edg_wll_FreeAcl(acl); - } - - if ((flags & EDG_WLL_STAT_CLASSADS) == 0) { - char *null = NULL; - - mov(stat->jdl, null); - mov(stat->matched_jdl, null); - mov(stat->condor_jdl, null); - mov(stat->rsl, null); - } - -#if DAG_ENABLE - if (stat->jobtype == EDG_WLL_STAT_DAG) { - if (1) { - char *out[2]; - edg_wll_Stmt sh; - int num_sub, num_f; - - if (stat->children_hist == NULL) { - stat->children_hist = (int*) calloc(1+EDG_WLL_NUMBER_OF_STATCODES, sizeof(int)); - stat->children_hist[0] = EDG_WLL_NUMBER_OF_STATCODES; - } - if ((flags & EDG_WLL_STAT_CHILDREN) == 0) { - trio_asprintf(&stmt, "SELECT status FROM states " - "WHERE parent_job='%|Ss' AND version='%|Ss'", - md5_jobid, INTSTAT_VERSION); - out[1] = NULL; - } else { - trio_asprintf(&stmt, "SELECT s.status,j.dg_jobid FROM states s,jobs j " - "WHERE s.parent_job='%|Ss' AND s.version='%|Ss' AND s.jobid=j.jobid", - md5_jobid, INTSTAT_VERSION); - } - if (stmt != NULL) { - num_sub = edg_wll_ExecStmt(ctx, stmt, &sh); - if (num_sub >=0 ) { - while ((num_f = edg_wll_FetchRow(sh, out)) == 1 - || (num_f == 2)) { - num_f = atoi(out[0]); - if (num_f > EDG_WLL_JOB_UNDEF && num_f < EDG_WLL_NUMBER_OF_STATCODES) - stat->children_hist[num_f+1]++; - if (out[1] !=NULL) add_stringlist(&stat->children, out[1]); - free(out[0]); free(out[1]); - } - edg_wll_FreeStmt(&sh); - } - free(stmt); - } else goto dag_enomem; - } - if (flags & EDG_WLL_STAT_CHILDSTAT) { - char *stat_str, *s_out; - edg_wll_Stmt sh; - int num_sub, num_f, i; - intJobStat *js; - - trio_asprintf(&stmt, "SELECT int_status FROM states WHERE parent_job='%|Ss'" - " AND version='%|Ss'", - md5_jobid, INTSTAT_VERSION); - if (stmt != NULL) { - num_sub = edg_wll_ExecStmt(ctx, stmt, &sh); - if (num_sub >=0 ) { - i = 0; - stat->children_states = calloc(num_sub+1, sizeof(edg_wll_JobStat)); - if (stat->children_states == NULL) { - edg_wll_FreeStmt(&sh); - goto dag_enomem; - } - while ((num_f = edg_wll_FetchRow(sh, &stat_str)) == 1 - && i < num_sub) { - js = dec_intJobStat(stat_str, &s_out); - if (s_out != NULL && js != NULL) { - stat->children_states[i] = js->pub; - destroy_intJobStat_extension(js); - free(js); - i++; - } - free(stat_str); - } - edg_wll_FreeStmt(&sh); - } - free(stmt); - } else goto dag_enomem; - } - } -#endif - free(string_jobid); - free(md5_jobid); - return edg_wll_Error(ctx, NULL, NULL); - -#if DAG_ENABLE -dag_enomem: - free(string_jobid); - free(md5_jobid); - edg_wll_FreeStatus(stat); - free(stmt); - return edg_wll_SetError(ctx, ENOMEM, NULL); -#endif -} - -int edg_wll_intJobStatus( - edg_wll_Context ctx, - const edg_wlc_JobId job, - int flags, - intJobStat *intstat, - int update_db) -{ - -/* Local variables */ - char *string_jobid; - char *md5_jobid; - - int num_events; - edg_wll_Event *events = NULL; - - int i, intErr = 0; - int res; - int be_strict = 0; - char *errstring = NULL; - - edg_wll_QueryRec jqr[2]; - edg_wll_QueryRec **jqra; - -/* Processing */ - edg_wll_ResetError(ctx); - init_intJobStat(intstat); - - string_jobid = edg_wlc_JobIdUnparse(job); - if (string_jobid == NULL || intstat == NULL) - return edg_wll_SetError(ctx,EINVAL, NULL); - - /* can be already filled by public edg_wll_JobStat() */ - if (intstat->pub.owner == NULL) { - md5_jobid = edg_wlc_JobIdGetUnique(job); - if ( !(intstat->pub.owner = job_owner(ctx,md5_jobid)) ) { - free(md5_jobid); - free(string_jobid); - return edg_wll_Error(ctx,NULL,NULL); - } - free(md5_jobid); - } - - jqr[0].attr = EDG_WLL_QUERY_ATTR_JOBID; - jqr[0].op = EDG_WLL_QUERY_OP_EQUAL; - jqr[0].value.j = job; - jqr[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; - - jqra = (edg_wll_QueryRec **) malloc (2 * sizeof(edg_wll_QueryRec **)); - jqra[0] = jqr; - jqra[1] = NULL; - - if (edg_wll_QueryEventsServer(ctx,1, (const edg_wll_QueryRec **)jqra, NULL, &events)) { - free(string_jobid); - free(jqra); - return edg_wll_Error(ctx, NULL, NULL); - } - free(jqra); - - for (num_events = 0; events[num_events].type != EDG_WLL_EVENT_UNDEF; - num_events++); - - if (num_events == 0) { - free(string_jobid); - return edg_wll_SetError(ctx,ENOENT,NULL); - } - - edg_wll_SortEvents(events); - - for (i = 0; i < num_events; i++) { - res = processEvent(intstat, &events[i], i, be_strict, &errstring); - if (res == RET_FATAL || res == RET_INTERNAL) { /* !strict */ - intErr = 1; break; - } - } - if (intstat->pub.state == EDG_WLL_JOB_UNDEF) { - intstat->pub.state = EDG_WLL_JOB_UNKNOWN; - } - - free(string_jobid); - - for (i=0; i < num_events ; i++) edg_wll_FreeEvent(&events[i]); - free(events); - - - if (intErr) { - destroy_intJobStat(intstat); - return edg_wll_SetError(ctx, EDG_WLL_ERROR_SERVER_RESPONSE, NULL); - } else { - /* XXX intstat->pub.expectUpdate = eval_expect_update(intstat, &intstat->pub.expectFrom); */ - intErr = edg_wlc_JobIdDup(job, &intstat->pub.jobId); - if (!intErr) { - if (update_db) { - int tsq = num_events - 1; - edg_wll_StoreIntState(ctx, intstat, tsq); - /* recheck - * intJobStat *reread; - * edg_wll_LoadIntState(ctx, job, tsq, &reread); - * destroy_intJobStat(reread); - */ - } - } - return edg_wll_SetError(ctx, intErr, NULL); - } - -} - -static int badEvent(intJobStat *js UNUSED_VAR, edg_wll_Event *e, int ev_seq UNUSED_VAR) -{ - char *str; - - str = edg_wll_EventToString(e->any.type); - fprintf(stderr, "edg_wll_JobStatus: bad event: type %d (%s)\n", - e->any.type, (str == NULL) ? "unknown" : str); - free(str); - return RET_FATAL; -} - -#define USABLE(res,strict) ((res) == RET_OK || ( (res) == RET_SOON && !strict)) -#define USABLE_DATA(res,strict) ((res) == RET_OK || ( (res) != RET_FATAL && !strict)) -#define LRMS_STATE(state) ((state) == EDG_WLL_JOB_RUNNING || (state) == EDG_WLL_JOB_DONE) - - -static int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring) -{ - - edg_wll_JobStatCode old_state = js->pub.state; - edg_wll_JobStatCode new_state = EDG_WLL_JOB_UNKNOWN; - int res = RET_OK; - - if (old_state == EDG_WLL_JOB_ABORTED || - old_state == EDG_WLL_JOB_CANCELLED || - old_state == EDG_WLL_JOB_CLEARED) { - res = RET_LATE; - } - - if (js->last_seqcode != NULL && - edg_wll_compare_seq(e->any.seqcode, js->last_seqcode) < 0) { - res = RET_LATE; - } - - switch (e->any.type) { - case EDG_WLL_EVENT_TRANSFER: - if (e->transfer.result == EDG_WLL_TRANSFER_OK) { - switch (e->transfer.source) { - case EDG_WLL_SOURCE_USER_INTERFACE: - new_state = EDG_WLL_JOB_WAITING; break; - case EDG_WLL_SOURCE_JOB_SUBMISSION: - /* if (LRMS_STATE(old_state)) res = RET_LATE; */ - new_state = EDG_WLL_JOB_READY; break; - case EDG_WLL_SOURCE_LOG_MONITOR: - if (LRMS_STATE(old_state)) { - js->pub.stateEnterTimes[1 + EDG_WLL_JOB_SCHEDULED] = - e->any.timestamp.tv_sec; - res = RET_LATE; - } - new_state = EDG_WLL_JOB_SCHEDULED; break; - default: - goto bad_event; break; - } - } else if (e->transfer.result == EDG_WLL_TRANSFER_FAIL) { - /* transfer failed */ - switch (e->transfer.source) { - case EDG_WLL_SOURCE_USER_INTERFACE: - new_state = EDG_WLL_JOB_SUBMITTED; break; - case EDG_WLL_SOURCE_JOB_SUBMISSION: - if (LRMS_STATE(old_state)) res = RET_LATE; - new_state = EDG_WLL_JOB_READY; break; - case EDG_WLL_SOURCE_LOG_MONITOR: - if (LRMS_STATE(old_state)) res = RET_LATE; - new_state = EDG_WLL_JOB_READY; break; - default: - goto bad_event; break; - } - } else { - /* e->transfer.result == EDG_WLL_TRANSFER_START */ - res = RET_IGNORE; - } - if (USABLE(res, strict)) { - js->pub.state = new_state; - rep(js->pub.reason, e->transfer.reason); - - free(js->pub.location); - if (e->transfer.result == EDG_WLL_TRANSFER_OK) { - js->pub.location = location_string( - edg_wll_SourceToString(e->transfer.destination), - e->transfer.dest_host, - e->transfer.dest_instance); - } else { - js->pub.location = location_string( - edg_wll_SourceToString(e->transfer.source), - e->transfer.host, - e->transfer.src_instance); - } - } - if (USABLE_DATA(res, strict)) { - switch (e->transfer.source) { - case EDG_WLL_SOURCE_USER_INTERFACE: - rep(js->pub.jdl, e->transfer.job); break; - case EDG_WLL_SOURCE_JOB_SUBMISSION: - rep(js->pub.condor_jdl, e->transfer.job); break; - case EDG_WLL_SOURCE_LOG_MONITOR: - rep(js->pub.rsl, e->transfer.job); break; - default: - goto bad_event; break; - - } - } - break; - case EDG_WLL_EVENT_ACCEPTED: - switch (e->accepted.source) { - case EDG_WLL_SOURCE_NETWORK_SERVER: - new_state = EDG_WLL_JOB_WAITING; break; - case EDG_WLL_SOURCE_LOG_MONITOR: - if (LRMS_STATE(old_state)) res = RET_LATE; - new_state = EDG_WLL_JOB_READY; break; - case EDG_WLL_SOURCE_LRMS: - new_state = EDG_WLL_JOB_SCHEDULED; break; - default: - goto bad_event; break; - } - if (USABLE(res, strict)) { - js->pub.state = new_state; - free(js->pub.location); - js->pub.location = location_string( - edg_wll_SourceToString(e->accepted.source), - e->accepted.host, - e->accepted.src_instance); - } - if (USABLE_DATA(res, strict)) { - switch (e->accepted.source) { - case EDG_WLL_SOURCE_NETWORK_SERVER: - break; /* no WM id */ - case EDG_WLL_SOURCE_LOG_MONITOR: - rep(js->pub.condorId, e->accepted.local_jobid); break; - case EDG_WLL_SOURCE_LRMS: - /* XXX localId */ - rep(js->pub.globusId, e->accepted.local_jobid); break; - default: - goto bad_event; break; - } - } - break; - case EDG_WLL_EVENT_REFUSED: - switch (e->refused.source) { - case EDG_WLL_SOURCE_NETWORK_SERVER: - new_state = EDG_WLL_JOB_SUBMITTED; break; - case EDG_WLL_SOURCE_LOG_MONITOR: - new_state = EDG_WLL_JOB_READY; break; - case EDG_WLL_SOURCE_LRMS: - new_state = EDG_WLL_JOB_READY; break; - default: - goto bad_event; break; - } - if (USABLE(res, strict)) { - js->pub.state = new_state; - rep(js->pub.reason, e->refused.reason); - - free(js->pub.location); - js->pub.location = location_string( - edg_wll_SourceToString(e->refused.from), - e->refused.from_host, - e->refused.from_instance); - } - break; - case EDG_WLL_EVENT_ENQUEUED: - if (e->enQueued.result == EDG_WLL_ENQUEUED_OK) { - switch (e->enQueued.source) { - case EDG_WLL_SOURCE_NETWORK_SERVER: - new_state = EDG_WLL_JOB_WAITING; break; - case EDG_WLL_SOURCE_WORKLOAD_MANAGER: - if (LRMS_STATE(old_state)) res = RET_LATE; - new_state = EDG_WLL_JOB_READY; break; - case EDG_WLL_SOURCE_LOG_MONITOR: - new_state = EDG_WLL_JOB_WAITING; break; - default: - goto bad_event; break; - } - } else if (e->enQueued.result == EDG_WLL_ENQUEUED_FAIL) { - switch (e->enQueued.source) { - case EDG_WLL_SOURCE_NETWORK_SERVER: - new_state = EDG_WLL_JOB_WAITING; break; - case EDG_WLL_SOURCE_WORKLOAD_MANAGER: - new_state = EDG_WLL_JOB_WAITING; break; - case EDG_WLL_SOURCE_LOG_MONITOR: - new_state = old_state; break; - default: - goto bad_event; break; - } - } else { - /* e->enQueued.result == EDG_WLL_ENQUEUED_START */ - res = RET_IGNORE; - } - if (USABLE(res, strict)) { - js->pub.state = new_state; - rep(js->pub.reason, e->enQueued.reason); - - free(js->pub.location); - if (e->enQueued.result == EDG_WLL_ENQUEUED_OK) { - js->pub.location = location_string( - e->enQueued.queue, - e->enQueued.host, - e->enQueued.src_instance); - if (e->enQueued.source == EDG_WLL_SOURCE_LOG_MONITOR) - js->pub.resubmitted = 1; - } else { - js->pub.location = location_string( - edg_wll_SourceToString(e->enQueued.source), - e->enQueued.host, - e->enQueued.src_instance); - } - } - if (USABLE_DATA(res, strict)) { - switch (e->enQueued.source) { - case EDG_WLL_SOURCE_NETWORK_SERVER: - rep(js->pub.jdl, e->enQueued.job); break; - case EDG_WLL_SOURCE_WORKLOAD_MANAGER: - rep(js->pub.matched_jdl, e->enQueued.job); break; - case EDG_WLL_SOURCE_LOG_MONITOR: - /* no interim JDL here */ - break; - default: - goto bad_event; break; - } - } - break; - case EDG_WLL_EVENT_DEQUEUED: - switch (e->deQueued.source) { - case EDG_WLL_SOURCE_WORKLOAD_MANAGER: - new_state = EDG_WLL_JOB_WAITING; break; - case EDG_WLL_SOURCE_JOB_SUBMISSION: - if (LRMS_STATE(old_state)) res = RET_LATE; - new_state = EDG_WLL_JOB_READY; break; - default: - goto bad_event; break; - } - if (USABLE(res, strict)) { - js->pub.state = new_state; - free(js->pub.location); - js->pub.location = location_string( - edg_wll_SourceToString(e->deQueued.source), - e->deQueued.host, - e->deQueued.src_instance); - } - if (USABLE_DATA(res, strict)) { - /* no WM/JSS local jobid */ - } - break; - case EDG_WLL_EVENT_HELPERCALL: - if (USABLE(res, strict)) { - js->pub.state = EDG_WLL_JOB_WAITING; - free(js->pub.location); - js->pub.location = location_string( - e->helperCall.helper_name, - e->helperCall.host, - e->helperCall.src_instance); - /* roles and params used only for debugging */ - } - break; - case EDG_WLL_EVENT_HELPERRETURN: - if (USABLE(res, strict)) { - js->pub.state = EDG_WLL_JOB_WAITING; - free(js->pub.location); - js->pub.location = location_string( - edg_wll_SourceToString(EDG_WLL_SOURCE_WORKLOAD_MANAGER), - e->helperReturn.host, - e->helperReturn.src_instance); - /* roles and retvals used only for debugging */ - } - break; - case EDG_WLL_EVENT_RUNNING: - if (USABLE(res, strict)) { - js->pub.state = EDG_WLL_JOB_RUNNING; - free(js->pub.location); - js->pub.location = location_string( - edg_wll_SourceToString(EDG_WLL_SOURCE_LRMS), - "worknode", - e->running.node); - } - if (USABLE_DATA(res, strict)) { - rep(js->pub.ce_node, e->running.node); - } - break; - case EDG_WLL_EVENT_RESUBMISSION: - if (USABLE(res, strict)) { - if (e->resubmission.result == EDG_WLL_RESUBMISSION_WONTRESUB) { - rep(js->pub.reason, e->resubmission.reason); - } - } - if (USABLE_DATA(res, strict)) { - if (e->resubmission.result == EDG_WLL_RESUBMISSION_WONTRESUB) { - js->wontresub = 1; - } - } - break; - case EDG_WLL_EVENT_DONE: - if (e->any.source == EDG_WLL_SOURCE_LRMS) { - /* Done from JobWrapper is not sufficient for transition - * to DONE state according its current definition */ - break; - } - if (USABLE(res, strict)) { - js->pub.state = EDG_WLL_JOB_DONE; - rep(js->pub.reason, e->done.reason); - switch (e->done.status_code) { - case EDG_WLL_DONE_CANCELLED: - js->pub.state = EDG_WLL_JOB_CANCELLED; - case EDG_WLL_DONE_OK: - rep(js->pub.location, "none"); break; - default: - free(js->pub.location); - js->pub.location = location_string( - edg_wll_SourceToString(e->done.source), - e->done.host, - e->done.src_instance); - } - } - if (USABLE_DATA(res, strict)) { - switch (e->done.status_code) { - case EDG_WLL_DONE_OK: - js->pub.exit_code = e->done.exit_code; - js->pub.done_code = EDG_WLL_STAT_OK; break; - case EDG_WLL_DONE_CANCELLED: - js->pub.exit_code = 0; - js->pub.done_code = EDG_WLL_STAT_CANCELLED; break; - case EDG_WLL_DONE_FAILED: - js->pub.exit_code = 0; - js->pub.done_code = EDG_WLL_STAT_FAILED; break; - default: - goto bad_event; break; - } - } - break; - case EDG_WLL_EVENT_CANCEL: - if (js->last_cancel_seqcode != NULL && - edg_wll_compare_seq(e->any.seqcode, js->last_cancel_seqcode) < 0) { - res = RET_LATE; - } - if (USABLE(res, strict)) { - switch (e->cancel.status_code) { - case EDG_WLL_CANCEL_REQ: - js->pub.cancelling = 1; break; - case EDG_WLL_CANCEL_DONE: - js->pub.state = EDG_WLL_JOB_CANCELLED; - rep(js->pub.reason, e->cancel.reason); - rep(js->last_seqcode, e->any.seqcode); - rep(js->pub.location, "none"); - /* fall though */ - case EDG_WLL_CANCEL_ABORT: - js->pub.cancelling = 0; break; - default: - /* do nothing */ - break; - - } - } - if (USABLE_DATA(res, strict)) { - rep(js->pub.cancelReason, e->cancel.reason); - } - break; - case EDG_WLL_EVENT_ABORT: - if (USABLE(res, strict)) { - js->pub.state = EDG_WLL_JOB_ABORTED; - rep(js->pub.reason, e->abort.reason); - rep(js->pub.location, "none"); - } - break; - - case EDG_WLL_EVENT_CLEAR: - if (USABLE(res, strict)) { - js->pub.state = EDG_WLL_JOB_CLEARED; - rep(js->pub.location, "none"); - switch (e->clear.reason) { - case EDG_WLL_CLEAR_USER: - rep(js->pub.reason, "user retrieved output sandbox"); - break; - case EDG_WLL_CLEAR_TIMEOUT: - rep(js->pub.reason, "timed out, resource purge forced"); - break; - case EDG_WLL_CLEAR_NOOUTPUT: - rep(js->pub.reason, "no output was generated"); - break; - default: - goto bad_event; break; - - } - } - break; - case EDG_WLL_EVENT_PURGE: - /* ignore, meta-information only */ - break; - case EDG_WLL_EVENT_MATCH: - if (USABLE(res, strict)) { - js->pub.state = EDG_WLL_JOB_WAITING; - js->pub.location = location_string( - edg_wll_SourceToString(EDG_WLL_SOURCE_WORKLOAD_MANAGER), - e->match.host, - e->match.src_instance); - } - if (USABLE_DATA(res, strict)) { - rep(js->pub.destination, e->match.dest_id); - } - break; - case EDG_WLL_EVENT_PENDING: - if (USABLE(res, strict)) { - js->pub.state = EDG_WLL_JOB_WAITING; - rep(js->pub.reason, e->pending.reason); - js->pub.location = location_string( - edg_wll_SourceToString(EDG_WLL_SOURCE_WORKLOAD_MANAGER), - e->match.host, - e->match.src_instance); - } - break; - case EDG_WLL_EVENT_REGJOB: - if (USABLE(res, strict)) { - js->pub.state = EDG_WLL_JOB_SUBMITTED; - } - if (USABLE_DATA(res, strict)) { - rep(js->pub.jdl, e->regJob.jdl); - edg_wlc_JobIdFree(js->pub.parent_job); - edg_wlc_JobIdDup(e->regJob.parent, - &js->pub.parent_job); - rep(js->pub.network_server, e->regJob.ns); - js->pub.children_num = e->regJob.nsubjobs; - if (e->regJob.jobtype == EDG_WLL_REGJOB_DAG - || e->regJob.jobtype == EDG_WLL_REGJOB_PARTITIONED) { - js->pub.jobtype = EDG_WLL_STAT_DAG; - } - rep(js->pub.seed, e->regJob.seed); - } - break; - case EDG_WLL_EVENT_USERTAG: - if (USABLE_DATA(res, strict)) { - if (e->userTag.name != NULL && e->userTag.value != NULL) { - add_taglist(&js->pub.user_tags, - e->userTag.name, e->userTag.value); - } else { - goto bad_event; - } - } - break; - case EDG_WLL_EVENT_LISTENER: - /* ignore, listener port is not part of job status */ - break; - case EDG_WLL_EVENT_CURDESCR: - case EDG_WLL_EVENT_CHKPT: - case EDG_WLL_EVENT_CHANGEACL: - /* ignore, only for event log */ - break; - - default: - goto bad_event; - break; - } - - if (USABLE(res,strict)) { - js->pub.lastUpdateTime = e->any.timestamp; - if (old_state != js->pub.state) { - js->pub.stateEnterTime = js->pub.lastUpdateTime; - js->pub.stateEnterTimes[1 + js->pub.state] - = (int)js->pub.lastUpdateTime.tv_sec; - } - } - - if (USABLE_DATA(res,strict)) { - if (e->any.source == EDG_WLL_SOURCE_NETWORK_SERVER && - js->pub.network_server == NULL) { - char *inst; - inst = e->any.src_instance; - asprintf(&js->pub.network_server, "%s%s%s", - e->any.host, - inst != NULL ? ":" : " ", - inst != NULL ? inst : ""); - } - } - - if (e->any.type == EDG_WLL_EVENT_CANCEL) { - rep(js->last_cancel_seqcode, e->any.seqcode); - } else { - rep(js->last_seqcode, e->any.seqcode); - } - - return res; - -bad_event: - badEvent(js,e,ev_seq); - return RET_SUSPECT; -} - -/* - * Helper for warning printouts - */ - -static void warn(const char* format, ...) -{ - va_list l; - va_start(l, format); - - /* - fprintf(stderr, "Warning: "); - vfprintf(stderr, format, l); - fputc('\n', stderr); - */ - - va_end(l); -} - -static char *job_owner(edg_wll_Context ctx,char *md5_jobid) -{ - char *stmt = NULL,*out = NULL; - edg_wll_Stmt sh; - int f = -1; - - edg_wll_ResetError(ctx); - trio_asprintf(&stmt,"select cert_subj from users,jobs " - "where users.userid = jobs.userid " - "and jobs.jobid = '%|Ss'",md5_jobid); - - if (stmt==NULL) { - edg_wll_SetError(ctx,ENOMEM, NULL); - return NULL; - } - if (edg_wll_ExecStmt(ctx,stmt,&sh) >= 0) { - f=edg_wll_FetchRow(sh,&out); - if (f == 0) { - if (out) free(out); - out = NULL; - edg_wll_SetError(ctx,ENOENT,md5_jobid); - } - } - edg_wll_FreeStmt(&sh); - free(stmt); - - return out; -} - - -#if 0 -/* XXX went_through went out */ -static int eval_expect_update(intJobStat *js, int* went_through, char **expect_from) -{ - int em = 0; - int ft = 0; /* fall through following tests */ - - if (ft || (went_through[ EDG_WLL_JOB_OUTPUTREADY ] && !js->done_failed)) ft = 1; - if (ft || (went_through[ EDG_WLL_JOB_DONE ] && !js->done_failed)) ft = 1; - if (ft || went_through[ EDG_WLL_JOB_CHECKPOINTED ]) ft = 1; - if (ft || went_through[ EDG_WLL_JOB_RUNNING ]) { - if (js->pub.node == NULL) em |= EXPECT_MASK_JOBMGR; - ft = 1; - } - if (ft || went_through[ EDG_WLL_JOB_SCHEDULED ]) { - if (js->pub.jssId == NULL) em |= EXPECT_MASK_JSS; - if (js->pub.rsl == NULL) em |= EXPECT_MASK_JSS; - if (js->pub.globusId == NULL) em |= EXPECT_MASK_JOBMGR; - if (js->pub.localId == NULL) em |= EXPECT_MASK_JOBMGR; - if (js->pub.jss_jdl == NULL) em |= EXPECT_MASK_RB; - ft = 1; - } - if (ft || went_through[ EDG_WLL_JOB_READY ]) { - if (js->pub.destination == NULL) em |= EXPECT_MASK_RB; - ft = 1; - } - if (ft || went_through[ EDG_WLL_JOB_SUBMITTED ]) { - if (js->pub.jdl == NULL) em |= EXPECT_MASK_UI; - ft = 1; - } - - if (em == 0) - *expect_from = NULL; - else { - asprintf(expect_from, "%s%s%s%s%s%s%s", - (em & EXPECT_MASK_UI ) ? EDG_WLL_SOURCE_UI : "", - (em & EXPECT_MASK_UI ) ? " " : "", - (em & EXPECT_MASK_RB ) ? EDG_WLL_SOURCE_RB : "", - (em & EXPECT_MASK_RB ) ? " " : "", - (em & EXPECT_MASK_JSS ) ? EDG_WLL_SOURCE_JSS : "", - (em & EXPECT_MASK_JSS ) ? " " : "", - (em & EXPECT_MASK_JOBMGR ) ? EDG_WLL_SOURCE_JOBMGR : "" - ); - } - - return (em == 0) ? 0 : 1; -} -#endif - -static char* location_string(const char *source, const char *host, const char *instance) -{ - char *ret; - asprintf(&ret, "%s/%s/%s", source, host, instance); - return ret; -} - -static int add_stringlist(char ***lptr, const char *new_item) -{ - char **itptr; - int i; - - if (*lptr == NULL) { - itptr = (char **) malloc(2*sizeof(char *)); - itptr[0] = strdup(new_item); - itptr[1] = NULL; - *lptr = itptr; - return 1; - } else { - for (i = 0, itptr = *lptr; itptr[i] != NULL; i++); - itptr = (char **) realloc(*lptr, (i+2)*sizeof(char *)); - if (itptr != NULL) { - itptr[i] = strdup(new_item); - itptr[i+1] = NULL; - *lptr = itptr; - return 1; - } else { - return 0; - } - } -} - -static int add_taglist(edg_wll_TagValue **lptr, const char *new_item, const char *new_item2) -{ - edg_wll_TagValue *itptr; - int i; - - if (*lptr == NULL) { - itptr = (edg_wll_TagValue *) calloc(2,sizeof(edg_wll_TagValue)); - itptr[0].tag = strdup(new_item); - itptr[0].value = strdup(new_item2); - *lptr = itptr; - return 1; - } else { - for (i = 0, itptr = *lptr; itptr[i].tag != NULL; i++) - if ( !strcasecmp(itptr[i].tag, new_item) ) - { - free(itptr[i].value); - itptr[i].value = strdup(new_item2); - return 1; - } - itptr = (edg_wll_TagValue *) realloc(*lptr, (i+2)*sizeof(edg_wll_TagValue)); - if (itptr != NULL) { - itptr[i].tag = strdup(new_item); - itptr[i].value = strdup(new_item2); - itptr[i+1].tag = NULL; - itptr[i+1].value = NULL; - *lptr = itptr; - return 1; - } else { - return 0; - } - } -} - -/* XXX more thorough malloc, calloc, and asprintf failure handling */ -/* XXX indexes in {short,long}_fields */ -/* XXX strict mode */ -/* XXX caching */ - -/* - * Store current job state to states and status_tags DB tables. - * Should be called with the job locked. - */ - -edg_wll_ErrorCode edg_wll_StoreIntState(edg_wll_Context ctx, - intJobStat *stat, - int seq) -{ - char *jobid_md5, *stat_enc, *parent_md5 = NULL; - char *stmt; - edg_wll_TagValue *tagp; - int update; - int dbret; - char *icnames, *icvalues; - - update = (seq > 0); - jobid_md5 = edg_wlc_JobIdGetUnique(stat->pub.jobId); - stat_enc = enc_intJobStat(strdup(""), stat); - - tagp = stat->pub.user_tags; - if (tagp) { - while ((*tagp).tag != NULL) { - trio_asprintf(&stmt, "insert into status_tags" - "(jobid,seq,name,value) values " - "('%|Ss',%d,'%|Ss','%|Ss')", - jobid_md5, seq, (*tagp).tag, (*tagp).value); - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) { - if (EEXIST == edg_wll_Error(ctx, NULL, NULL)) { - /* XXX: this should not happen */ - edg_wll_ResetError(ctx); - tagp++; - continue; - } - else - goto cleanup; - } - tagp++; - } - } - - parent_md5 = edg_wlc_JobIdGetUnique(stat->pub.parent_job); - if (parent_md5 == NULL) parent_md5 = strdup("*no parent job*"); - - - edg_wll_IColumnsSQLPart(ctx, ctx->job_index_cols, stat, 0, NULL, &icvalues); - - trio_asprintf(&stmt, - "update states set " - "status=%d,seq=%d,int_status='%|Ss',version='%|Ss'" - ",parent_job='%|Ss'%s " - "where jobid='%|Ss'", - stat->pub.state, seq, stat_enc, INTSTAT_VERSION, - parent_md5, icvalues, - jobid_md5); - free(icvalues); - - if ((dbret = edg_wll_ExecStmt(ctx,stmt,NULL)) < 0) goto cleanup; - - if (dbret == 0) { - edg_wll_IColumnsSQLPart(ctx, ctx->job_index_cols, stat, 1, &icnames, &icvalues); - trio_asprintf(&stmt, - "insert into states" - "(jobid,status,seq,int_status,version" - ",parent_job%s) " - "values ('%|Ss',%d,%d,'%|Ss','%|Ss','%|Ss'%s)", - icnames, - jobid_md5, stat->pub.state, seq, stat_enc, - INTSTAT_VERSION, parent_md5, icvalues); - free(icnames); free(icvalues); - - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) goto cleanup; - } - - if (update) { - trio_asprintf(&stmt, "delete from states " - "where jobid ='%|Ss' and ( seq<%d or version !='%|Ss')", - jobid_md5, seq, INTSTAT_VERSION); - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) goto cleanup; - } - if (update) { - trio_asprintf(&stmt, "delete from status_tags " - "where jobid ='%|Ss' and seq<%d", jobid_md5, seq); - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) goto cleanup; - } - - if (ctx->rgma_export) write2rgma_status(&stat->pub); - -cleanup: - free(stmt); - free(jobid_md5); free(stat_enc); - free(parent_md5); - return edg_wll_Error(ctx,NULL,NULL); -} - -/* - * Retrieve stored job state from states and status_tags DB tables. - * Should be called with the job locked. - */ - -edg_wll_ErrorCode edg_wll_LoadIntState(edg_wll_Context ctx, - edg_wlc_JobId jobid, - int seq, - intJobStat **stat) -{ - char *jobid_md5; - char *stmt; - edg_wll_Stmt sh; - char *res, *res_rest; - int nstates; - - edg_wll_ResetError(ctx); - jobid_md5 = edg_wlc_JobIdGetUnique(jobid); - - if (seq == -1) { - /* any sequence number */ - trio_asprintf(&stmt, - "select int_status from states " - "where jobid='%|Ss' and version='%|Ss'", - jobid_md5, INTSTAT_VERSION); - } else { - trio_asprintf(&stmt, - "select int_status from states " - "where jobid='%|Ss' and seq='%d' and version='%|Ss'", - jobid_md5, seq, INTSTAT_VERSION); - } - - if (stmt == NULL) { - return edg_wll_SetError(ctx, ENOMEM, NULL); - } - - if ((nstates = edg_wll_ExecStmt(ctx,stmt,&sh)) < 0) goto cleanup; - if (nstates == 0) { - edg_wll_SetError(ctx,ENOENT,"no state in DB"); - goto cleanup; - } - if (edg_wll_FetchRow(sh,&res) < 0) goto cleanup; - - *stat = dec_intJobStat(res, &res_rest); - if (res_rest == NULL) { - edg_wll_SetError(ctx, EDG_WLL_ERROR_DB_CALL, - "error decoding DB intJobStatus"); - } - - free(res); -cleanup: - free(jobid_md5); - free(stmt); edg_wll_FreeStmt(&sh); - return edg_wll_Error(ctx,NULL,NULL); -} - -/* - * update stored state according to the new event - * (must be called with the job locked) - */ - -edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx, - edg_wlc_JobId job, - edg_wll_Event *e, - int seq, - edg_wll_JobStat *stat_out) -{ - intJobStat *ijsp; - int intErr = 0; - int flags = 0; - int res; - int be_strict = 0; - char *errstring = NULL; - intJobStat jobstat; - - if (seq != 0) { - intErr = edg_wll_LoadIntState(ctx, job, seq - 1, &ijsp); - } - if (seq != 0 && !intErr) { - res = processEvent(ijsp, e, seq, be_strict, &errstring); - if (res == RET_FATAL || res == RET_INTERNAL) { /* !strict */ - return edg_wll_SetError(ctx, EINVAL, errstring); - } - edg_wll_StoreIntState(ctx, ijsp, seq); - if (stat_out) { - memcpy(stat_out,&ijsp->pub,sizeof *stat_out); - destroy_intJobStat_extension(ijsp); - } - else destroy_intJobStat(ijsp); - free(ijsp); - } else { - edg_wll_intJobStatus(ctx, job, flags,&jobstat, js_enable_store); - if (stat_out) { - memcpy(stat_out,&jobstat.pub,sizeof *stat_out); - destroy_intJobStat_extension(&jobstat); - } - else destroy_intJobStat(&jobstat); - } - return edg_wll_Error(ctx, NULL, NULL); -} diff --git a/org.glite.lb.server/src/jobstat.h b/org.glite.lb.server/src/jobstat.h deleted file mode 100644 index 1b17c7b..0000000 --- a/org.glite.lb.server/src/jobstat.h +++ /dev/null @@ -1,30 +0,0 @@ -/* $Header$ */ - -/* - * Internal representation of job state - * (includes edg_wll_JobStat API structure) - */ - -#define INTSTAT_VERSION "release-2.0" - - -typedef struct _intJobStat { - edg_wll_JobStat pub; - int wontresub; - char *last_seqcode; - char *last_cancel_seqcode; - -/* int expect_mask; */ - } intJobStat; - -void destroy_intJobStat(intJobStat *); - -edg_wll_ErrorCode edg_wll_IColumnsSQLPart(edg_wll_Context, void *, intJobStat *, int , char **, char **); -edg_wll_ErrorCode edg_wll_RefreshIColumns(edg_wll_Context, void *); -int edg_wll_intJobStatus( edg_wll_Context, const edg_wlc_JobId, int, intJobStat *, int); - -intJobStat* dec_intJobStat(char *, char **); -char *enc_intJobStat(char *, intJobStat* ); - -void write2rgma_status(edg_wll_JobStat *); - diff --git a/org.glite.lb.server/src/jobstat_supp.c b/org.glite.lb.server/src/jobstat_supp.c deleted file mode 100644 index b8f607d..0000000 --- a/org.glite.lb.server/src/jobstat_supp.c +++ /dev/null @@ -1,669 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/producer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/trio.h" - -#include "store.h" -#include "index.h" -#include "jobstat.h" -#include "lbs_db.h" -#include "get_events.h" - - -extern int debug; -#ifndef dprintf -#define dprintf(x) { if (debug) printf x; } -#endif - - -/* TBD: share in whole logging or workload */ -#ifdef __GNUC__ -#define UNUSED_VAR __attribute__((unused)) -#else -#define UNUSED_VAR -#endif - -static char* enc_strlist(char *, char **) UNUSED_VAR; -static char **dec_strlist(char *, char **) UNUSED_VAR; - -/* - * string encoding routines for safe DB store - */ - -static char *enc_string(char *old, char *item) -{ - char *out; - if (item == NULL) { - asprintf(&out,"%s-1 ", old); - } else { - asprintf(&out,"%s%ld %s",old, (long)strlen(item), item); - } - free(old); - return out; -} - -static char *dec_string(char *in, char **rest) -{ - int scret; - long len = -1; - char *out; - - scret = sscanf(in, "%ld", &len); - if (scret < 1) { - *rest = NULL; - return NULL; - } - if (len == -1) { - out = NULL; - *rest = strchr(in, ' ') ? strchr(in, ' ') + 1 : NULL; - } else { - in = strchr(in, ' ') ? strchr(in, ' ') + 1 : NULL; - out = (char *)malloc(len+1); - if (out) { - memcpy(out, in, len); - *(out+len) = '\0'; - } - *rest = in+len; - } - return out; -} - -static char *enc_int(char *old, int item) -{ - char *out; - asprintf(&out,"%s%d ", old, item); - free(old); - return out; -} - -static int dec_int(char* in, char **rest) -{ - int scret; - int out; - - scret = sscanf(in, "%d", &out); - if (scret == 1) { - *rest = strchr(in, ' ') ? strchr(in, ' ') + 1 : NULL; - } else { - out = 0; - *rest = in; - } - return out; -} - -static char* enc_jobid(char *old, edg_wlc_JobId item) -{ - char *str; - char *out; - - str = edg_wlc_JobIdUnparse(item); - out = enc_string(old, str); - free(str); - return out; -} -static edg_wlc_JobId dec_jobid(char *in, char **rest) -{ - char *str; - edg_wlc_JobId jobid; - - str = dec_string(in, rest); - if (str == NULL) return NULL; - edg_wlc_JobIdParse(str, &jobid); - free(str); - return jobid; -} - -static char* enc_strlist(char *old, char **item) -{ - char *ret; - - if (item == NULL) { - asprintf(&ret,"%s-1 ", old); - free(old); - return ret; - } else { - asprintf(&ret,"%s1 ",old); - free(old); - if (ret == NULL) return ret; - } - do { - ret = enc_string(ret, *item); - } while (*(item++) != NULL); - return ret; -} - -static char **dec_strlist(char *in, char **rest) -{ - char **out; - int len = -1; - char *tmp_in, *tmp_ret; - int scret; - - scret = sscanf(in, "%d", &len); - if (scret < 1) { - *rest = NULL; - return NULL; - } - if (len == -1) { - *rest = strchr(in, ' ') ? strchr(in, ' ') + 1 : NULL; - return NULL; - } - - len = 0; - tmp_in = in = strchr(in, ' ') + 1 ; - do { - tmp_ret = dec_string(tmp_in, &tmp_in); - len++; - } while (tmp_ret != NULL); - - out = (char**) malloc(len*sizeof(char*)); - - if (out) { - len = 0; - tmp_in = in; - do { - out[len] = dec_string(tmp_in, &tmp_in); - } while (out[len++] != NULL); - } - *rest = tmp_in; - return out; -} - -static char* enc_taglist(char *old, edg_wll_TagValue *item) -{ - char *ret; - - if (item == NULL) { - asprintf(&ret,"%s-1 ", old); - free(old); - return ret; - } else { - asprintf(&ret,"%s1 ",old); - free(old); - if (ret == NULL) return ret; - } - do { - ret = enc_string(ret, (*item).tag); - ret = enc_string(ret, (*item).value); - } while ((*(item++)).tag != NULL); - return ret; -} - -static edg_wll_TagValue *dec_taglist(char *in, char **rest) -{ - edg_wll_TagValue *out; - int len = -1; - char *tmp_in, *tmp_ret, *tmp_ret2; - int scret; - - scret = sscanf(in, "%d", &len); - if (scret < 1) { - *rest = NULL; - return NULL; - } - if (len == -1) { - *rest = strchr(in, ' ') ? strchr(in, ' ') + 1 : NULL; - return NULL; - } - - len = 0; - tmp_in = in = strchr(in, ' ') + 1 ; - do { - tmp_ret2 = dec_string(tmp_in, &tmp_in); - if (!tmp_in) { *rest = tmp_in; return NULL; } - tmp_ret = dec_string(tmp_in, &tmp_in); - if (!tmp_in) { *rest = tmp_in; return NULL; } - len++; - } while (tmp_ret2 != NULL); - - out = (edg_wll_TagValue *) malloc(len*sizeof(edg_wll_TagValue)); - - if (out) { - len = 0; - tmp_in = in; - - do { - out[len].tag = dec_string(tmp_in, &tmp_in); - out[len].value = dec_string(tmp_in, &tmp_in); - } while (out[len++].tag != NULL); - *rest = tmp_in; - } - else - *rest = 0; - - return out; -} - -static char *enc_intlist(char *old, int *item) -{ - int len; - char *ret; - - if (item == NULL) { - asprintf(&ret,"%s-1 ", old); - free(old); - return ret; - } else { - asprintf(&ret,"%s1 ",old); - free(old); - if (ret == NULL) return ret; - } - len = *item; item++; - ret = enc_int(ret, len); - for (; len > 0 ; len--, item++) { - ret = enc_int(ret, *item); - } - - return ret; -} - -static int *dec_intlist(char *in, char **rest) -{ - int len = -1; - int *out, *ptr; - char *tmp_in; - int scret; - - scret = sscanf(in, "%d", &len); - if (scret < 1) { - *rest = NULL; - return NULL; - } - tmp_in = strchr(in, ' ') ? strchr(in, ' ') + 1 : NULL; - if (len == -1 || tmp_in == NULL) { - *rest = tmp_in; - return NULL; - } - - len = dec_int(tmp_in, &tmp_in); - out = (int *)malloc( (len+1) *sizeof(int)); - if (out) { - *out = len; - ptr = out+1; - while (len) { - *ptr = dec_int(tmp_in, &tmp_in); - len--; ptr++; - } - } - *rest = tmp_in; - return out; -} - -static char* enc_timeval(char *old, struct timeval item) -{ - char *ret; - - ret = enc_int(old, (int)item.tv_sec); - if (ret) { - ret = enc_int(ret, (int)item.tv_usec); - } - return ret; -} - -static struct timeval dec_timeval(char *in, char **rest) -{ - struct timeval t; - char *tmp_in; - - t.tv_sec = dec_int(in, &tmp_in); - if (tmp_in != NULL) t.tv_usec = dec_int(tmp_in, &tmp_in); - *rest = tmp_in; - return t; -} - -static char *enc_JobStat(char *old, edg_wll_JobStat* stat) -{ - char *ret; - - ret = enc_int(old, stat->state); - if (ret) ret = enc_jobid(ret, stat->jobId); - if (ret) ret = enc_string(ret, stat->owner); - if (ret) ret = enc_int(ret, stat->jobtype); - if (ret) ret = enc_jobid(ret, stat->parent_job); - if (ret) ret = enc_string(ret, stat->seed); - if (ret) ret = enc_int(ret, stat->children_num); - /* children data are not stored in DB */ - if (ret) ret = enc_string(ret, stat->condorId); - if (ret) ret = enc_string(ret, stat->globusId); - if (ret) ret = enc_string(ret, stat->localId); - if (ret) ret = enc_string(ret, stat->jdl); - if (ret) ret = enc_string(ret, stat->matched_jdl); - if (ret) ret = enc_string(ret, stat->destination); - if (ret) ret = enc_string(ret, stat->condor_jdl); - if (ret) ret = enc_string(ret, stat->rsl); - if (ret) ret = enc_string(ret, stat->reason); - if (ret) ret = enc_string(ret, stat->location); - if (ret) ret = enc_string(ret, stat->ce_node); - if (ret) ret = enc_string(ret, stat->network_server); - if (ret) ret = enc_int(ret, stat->subjob_failed); - if (ret) ret = enc_int(ret, stat->done_code); - if (ret) ret = enc_int(ret, stat->exit_code); - if (ret) ret = enc_int(ret, stat->resubmitted); - if (ret) ret = enc_int(ret, stat->cancelling); - if (ret) ret = enc_string(ret, stat->cancelReason); - if (ret) ret = enc_int(ret, stat->cpuTime); - if (ret) ret = enc_taglist(ret, stat->user_tags); - if (ret) ret = enc_timeval(ret, stat->stateEnterTime); - if (ret) ret = enc_intlist(ret, stat->stateEnterTimes); - if (ret) ret = enc_timeval(ret, stat->lastUpdateTime); - if (ret) ret = enc_int(ret, stat->expectUpdate); - if (ret) ret = enc_string(ret, stat->expectFrom); - - return ret; -} -static edg_wll_JobStat* dec_JobStat(char *in, char **rest) -{ - char *tmp_in; - edg_wll_JobStat *stat; - - stat = (edg_wll_JobStat *) calloc(1,sizeof(edg_wll_JobStat)); - if (!stat) return stat; - - tmp_in = in; - stat->state = dec_int(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->jobId = dec_jobid(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->owner = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->jobtype = dec_int(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->parent_job = dec_jobid(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->seed = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->children_num = dec_int(tmp_in, &tmp_in); - /* children data are not stored in DB */ - if (tmp_in != NULL) stat->condorId = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->globusId = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->localId = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->jdl = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->matched_jdl = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->destination = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->condor_jdl = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->rsl = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->reason = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->location = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->ce_node = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->network_server = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->subjob_failed = dec_int(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->done_code = dec_int(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->exit_code = dec_int(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->resubmitted = dec_int(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->cancelling = dec_int(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->cancelReason = dec_string(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->cpuTime = dec_int(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->user_tags = dec_taglist(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->stateEnterTime = dec_timeval(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->stateEnterTimes = dec_intlist(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->lastUpdateTime = dec_timeval(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->expectUpdate = dec_int(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->expectFrom = dec_string(tmp_in, &tmp_in); - - *rest = tmp_in; - return stat; -} - -char *enc_intJobStat(char *old, intJobStat* stat) -{ - char *ret; - - ret = enc_JobStat(old, &stat->pub); - if (ret) ret = enc_int(ret, stat->wontresub); - if (ret) ret = enc_string(ret, stat->last_seqcode); - if (ret) ret = enc_string(ret, stat->last_cancel_seqcode); - return ret; -} - -intJobStat* dec_intJobStat(char *in, char **rest) -{ - edg_wll_JobStat *pubstat; - intJobStat *stat = 0; - char *tmp_in; - - pubstat = dec_JobStat(in, &tmp_in); - if (tmp_in != NULL) { - stat = (intJobStat *)calloc(1,sizeof(intJobStat)); - } - if (stat != NULL) { - stat->pub = *pubstat; - free(pubstat); - stat->wontresub = dec_int(tmp_in, &tmp_in); - if (tmp_in != NULL) { - stat->last_seqcode = dec_string(tmp_in, &tmp_in); - } - if (tmp_in != NULL) { - stat->last_cancel_seqcode = dec_string(tmp_in, &tmp_in); - } - } else if (tmp_in != NULL) { - edg_wll_FreeStatus(pubstat); - free(pubstat); - } - - *rest = tmp_in; - return stat; -} - -/* - * Compute part of SQL command used for indexed state table columns - */ - -edg_wll_ErrorCode edg_wll_IColumnsSQLPart(edg_wll_Context ctx, - void *job_index_cols_v, - intJobStat *stat, - int is_insert, - char **names_out, - char **values_out) -{ - int i; - char *names, *values; - char *data; - char *tmp; - edg_wll_IColumnRec *job_index_cols = (edg_wll_IColumnRec *)job_index_cols_v; - - edg_wll_ResetError(ctx); - - if (is_insert) names = strdup(""); else names = NULL; - values = strdup(""); - - if (job_index_cols != NULL) - for (i=0; job_index_cols[i].colname; i++) { - data = NULL; - switch (job_index_cols[i].qrec.attr) { - case EDG_WLL_QUERY_ATTR_OWNER: - if (stat->pub.owner) - trio_asprintf(&data, "'%|Ss'", stat->pub.owner); - else data = strdup("''"); - break; - case EDG_WLL_QUERY_ATTR_LOCATION: - if (stat->pub.location) - trio_asprintf(&data, "'%|Ss'", stat->pub.location); - else data = strdup("''"); - break; - case EDG_WLL_QUERY_ATTR_DESTINATION: - if (stat->pub.destination) - trio_asprintf(&data, "'%|Ss'", stat->pub.destination); - else data = strdup("''"); - break; - case EDG_WLL_QUERY_ATTR_DONECODE: - asprintf(&data, "%d", stat->pub.done_code); - break; - case EDG_WLL_QUERY_ATTR_USERTAG: - if (stat->pub.user_tags) { - int k; - for (k=0; stat->pub.user_tags[k].tag && - strcmp(stat->pub.user_tags[k].tag,job_index_cols[i].qrec.attr_id.tag); - k++); - if (stat->pub.user_tags[k].tag != NULL) { - trio_asprintf(&data, "'%|Ss'", stat->pub.user_tags[k].value); - } else data = strdup("''"); - } else data = strdup("''"); - break; - case EDG_WLL_QUERY_ATTR_TIME: - if (stat->pub.stateEnterTimes) - data = strdup(edg_wll_TimeToDB(stat->pub.stateEnterTimes[ - job_index_cols[i].qrec.attr_id.state+1])); - else data = strdup("0"); - break; - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - asprintf(&data, "%d", stat->pub.resubmitted); - break; - - /* XXX add more attributes when defined */ - default: - /* do not use */ - break; - } - - if (!data) continue; - - if (is_insert) { - asprintf(&tmp, "%s,`%s`", names, job_index_cols[i].colname); - free(names); names = tmp; - asprintf(&tmp, "%s,%s", values, data); - free(values); values = tmp; - } else { - /* update */ - asprintf(&tmp, "%s,`%s`=%s", values, job_index_cols[i].colname, data); - free(values); values = tmp; - } - free(data); - } - - if (is_insert) *names_out = names; - *values_out = values; - - return edg_wll_Error(ctx, NULL, NULL); -} - - -/* - * Set values of index columns in state table (after index reconfiguration) - */ - -edg_wll_ErrorCode edg_wll_RefreshIColumns(edg_wll_Context ctx, void *job_index_cols) { - - edg_wll_Stmt sh, sh2; - int njobs, ret = -1; - intJobStat *stat; - edg_wlc_JobId jobid; - char *res[5]; - char *rest; - char *icvalues, *stmt; - int i; - - edg_wll_ResetError(ctx); - if (!job_index_cols) return 0; - - if ((njobs = edg_wll_ExecStmt(ctx, "select s.jobid,s.int_status,s.seq,s.version,j.dg_jobid" - " from states s, jobs j where s.jobid=j.jobid",&sh)) < 0) { - edg_wll_FreeStmt(&sh); - return edg_wll_Error(ctx, NULL, NULL); - } - while ((ret=edg_wll_FetchRow(sh,res)) >0) { - if (strcmp(res[3], INTSTAT_VERSION)) { - stat = NULL; - if (!edg_wlc_JobIdParse(res[4], &jobid)) { - if ((stat = malloc(sizeof(intJobStat))) != NULL) { - if (edg_wll_intJobStatus(ctx, jobid, 0, stat, 1)) { - free(stat); - stat = NULL; - } - } - edg_wlc_JobIdFree(jobid); - } - } else { - stat = dec_intJobStat(res[1], &rest); - if (rest == NULL) stat = NULL; - } - if (stat == NULL) { - edg_wll_FreeStmt(&sh); - return edg_wll_SetError(ctx, EDG_WLL_ERROR_SERVER_RESPONSE, - "cannot decode int_status from states DB table"); - } - - edg_wll_IColumnsSQLPart(ctx, job_index_cols, stat, 0, NULL, &icvalues); - trio_asprintf(&stmt, "update states set seq=%s%s where jobid='%|Ss'", res[2], icvalues, res[0]); - ret = edg_wll_ExecStmt(ctx, stmt, &sh2); - edg_wll_FreeStmt(&sh2); - - for (i = 0; i < 5; i++) free(res[i]); - destroy_intJobStat(stat); free(stat); - free(stmt); free(icvalues); - - if (ret < 0) return edg_wll_Error(ctx, NULL, NULL); - - } - edg_wll_FreeStmt(&sh); - return edg_wll_Error(ctx, NULL, NULL); -} - - -int edg_wll_compare_seq(const char *a, const char *b) -{ - unsigned int c[EDG_WLL_SOURCE__LAST]; - unsigned int d[EDG_WLL_SOURCE__LAST]; - int res, i; - - assert(EDG_WLL_SOURCE__LAST == 9); - - res = sscanf(a, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d", - &c[EDG_WLL_SOURCE_USER_INTERFACE], - &c[EDG_WLL_SOURCE_NETWORK_SERVER], - &c[EDG_WLL_SOURCE_WORKLOAD_MANAGER], - &c[EDG_WLL_SOURCE_BIG_HELPER], - &c[EDG_WLL_SOURCE_JOB_SUBMISSION], - &c[EDG_WLL_SOURCE_LOG_MONITOR], - &c[EDG_WLL_SOURCE_LRMS], - &c[EDG_WLL_SOURCE_APPLICATION]); - if (res != EDG_WLL_SOURCE__LAST-1) { - syslog(LOG_ERR, "unparsable sequence code %s\n", a); - dprintf(( "unparsable sequence code %s\n", a)); - return -1; - } - - res = sscanf(b, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d", - &d[EDG_WLL_SOURCE_USER_INTERFACE], - &d[EDG_WLL_SOURCE_NETWORK_SERVER], - &d[EDG_WLL_SOURCE_WORKLOAD_MANAGER], - &d[EDG_WLL_SOURCE_BIG_HELPER], - &d[EDG_WLL_SOURCE_JOB_SUBMISSION], - &d[EDG_WLL_SOURCE_LOG_MONITOR], - &d[EDG_WLL_SOURCE_LRMS], - &d[EDG_WLL_SOURCE_APPLICATION]); - if (res != EDG_WLL_SOURCE__LAST-1) { - syslog(LOG_ERR, "unparsable sequence code %s\n", b); - dprintf(( "unparsable sequence code %s\n", b)); - return 1; - } - - for (i = EDG_WLL_SOURCE_USER_INTERFACE ; i < EDG_WLL_SOURCE__LAST; i++) { - if (c[i] < d[i]) return -1; - if (c[i] > d[i]) return 1; - } - - return 0; -} - -static int compare_events_by_seq(const void *a, const void *b) -{ - const edg_wll_Event *e = (edg_wll_Event *)a; - const edg_wll_Event *f = (edg_wll_Event *)b; - - return edg_wll_compare_seq(e->any.seqcode, f->any.seqcode); -} - -void edg_wll_SortEvents(edg_wll_Event *e) -{ - int n; - - if (!e) return; - for (n=0; e[n].type; n++); - qsort(e,n,sizeof *e,compare_events_by_seq); -} diff --git a/org.glite.lb.server/src/lb_authz.c b/org.glite.lb.server/src/lb_authz.c deleted file mode 100644 index cd9920c..0000000 --- a/org.glite.lb.server/src/lb_authz.c +++ /dev/null @@ -1,933 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include - -#include "glite/lb/context-int.h" -#include "lb_authz.h" - -#ifndef NO_VOMS - -#include -#include -#undef WITHOUT_TRIO - -#include "glite/security/voms/voms_apic.h" -#include "glite/wmsutils/jobid/strmd5.h" -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/producer.h" -#include "glite/lb/trio.h" -#include "lbs_db.h" - -/* XXX should be defined in gridsite-gacl.h */ -GRSTgaclEntry *GACLparseEntry(xmlNodePtr cur); - -static int -add_groups(edg_wll_Context ctx, struct voms *voms_cert, char *vo_name, - edg_wll_VomsGroups *groups) -{ - struct data **voms_data; - edg_wll_VomsGroup *tmp = NULL; - - if (voms_cert->type != TYPE_STD) { - edg_wll_SetError(ctx, EINVAL, "not supported VOMS certificate type"); - return EINVAL; - } - - for (voms_data = voms_cert->std; voms_data && *voms_data; voms_data++) { - if ((*voms_data)->group && *(*voms_data)->group) { - tmp = realloc(groups->val, (groups->len + 1) * sizeof(*groups->val)); - if (tmp == NULL) - return ENOMEM; - groups->val = tmp; - groups->val[groups->len].vo = strdup(vo_name); - groups->val[groups->len].name = strdup((*voms_data)->group); - groups->len++; - } - } - return 0; -} - -static int -get_groups(edg_wll_Context ctx, struct vomsdata *voms_info, - edg_wll_VomsGroups *res_groups) -{ - struct voms **voms_cert = NULL; - edg_wll_VomsGroups groups; - int ret; - - memset(&groups, 0, sizeof(groups)); - - for (voms_cert = voms_info->data; voms_cert && *voms_cert; voms_cert++) { - if ((*voms_cert)->voname) { - ret = add_groups(ctx, *voms_cert, (*voms_cert)->voname, &groups); - if (ret) { - edg_wll_FreeVomsGroups(&groups); - return ret; - } - } - } - - res_groups->len = groups.len; - res_groups->val = groups.val; - return 0; -} - -static int -get_peer_cred(edg_wll_GssConnection *gss, char *server_cert, char *server_key, STACK_OF(X509) **chain, X509 **cert) -{ - OM_uint32 maj_stat, min_stat; - gss_buffer_desc buffer = GSS_C_EMPTY_BUFFER; - BIO *bio = NULL; - SSL_SESSION *session = NULL; - unsigned char int_buffer[4]; - long length; - int ret, index; - STACK_OF(X509) *cert_chain = NULL; - X509 *peer_cert = NULL; - X509 *p_cert; - - maj_stat = gss_export_sec_context(&min_stat, &gss->context, &buffer); - if (GSS_ERROR(maj_stat)) - return -1; /* XXX */ - - { - /* The GSSAPI specs requires gss_export_sec_context() to destroy the - * context after exporting. So we have to resurrect the context here by - * importing from just generated buffer. gss_import_sec_context() must be - * able to read valid credential before it loads the exported context - * so we set the environment temporarily to point to the ones used by - * the server. - * - * I'm eagerly waiting for adaptations in the VOMS API to avoid these - * hacks */ - - char *orig_cert = NULL, *orig_key = NULL; - - orig_cert = getenv("X509_USER_CERT"); - orig_key = getenv("X509_USER_KEY"); - - if (server_cert) - setenv("X509_USER_CERT", server_cert, 1); - if (server_key) - setenv("X509_USER_KEY", server_key, 1); - - maj_stat = gss_import_sec_context(&min_stat, &buffer, &gss->context); - - if (orig_cert) - setenv("X509_USER_CERT", orig_cert, 1); - else - unsetenv("X509_USER_CERT"); - - if (orig_key) - setenv("X509_USER_KEY", orig_key, 1); - else - unsetenv("X509_USER_KEY"); - - if (GSS_ERROR(maj_stat)) { - ret = -1; - goto end; - } - } - - bio = BIO_new(BIO_s_mem()); - if (bio == NULL) { - ret = -1; - goto end; - } - - /* Store exported context to memory, skipping the version number and and cred_usage fields */ - BIO_write(bio, buffer.value + 8 , buffer.length - 8); - - /* decode the session data in order to skip at the start of the cert chain */ - session = d2i_SSL_SESSION_bio(bio, NULL); - if (session == NULL) { - ret = -1; /* XXX */ - goto end; - } - if (session->peer) - peer_cert = X509_dup(session->peer); - - SSL_SESSION_free(session); - - BIO_read(bio, (char *) int_buffer, 4); - length = (((size_t) int_buffer[0]) << 24) & 0xffff; - length |= (((size_t) int_buffer[1]) << 16) & 0xffff; - length |= (((size_t) int_buffer[2]) << 8) & 0xffff; - length |= (((size_t) int_buffer[3]) ) & 0xffff; - - if (length == 0) { - ret = 0; - goto end; - } - - cert_chain = sk_X509_new_null(); - for(index = 0; index < length; index++) { - p_cert = d2i_X509_bio(bio, NULL); - if (p_cert == NULL) { - ret = -1; /* XXX */ - sk_X509_pop_free(cert_chain, X509_free); - goto end; - } - - sk_X509_push(cert_chain, p_cert); - } - - *chain = cert_chain; - *cert = peer_cert; - peer_cert = NULL; - ret = 0; - -end: - if (peer_cert) - X509_free(peer_cert); - gss_release_buffer(&min_stat, &buffer); - - return ret; -} - -int -edg_wll_SetVomsGroups(edg_wll_Context ctx, edg_wll_GssConnection *gss, char *server_cert, char *server_key, char *voms_dir, char *ca_dir) -{ - STACK_OF(X509) *p_chain = NULL; - X509 *cert = NULL; - int ret; - int err = 0; - struct vomsdata *voms_info = NULL; - - /* XXX DK: correct cleanup ?? */ - memset (&ctx->vomsGroups, 0, sizeof(ctx->vomsGroups)); - edg_wll_ResetError(ctx); - - ret = get_peer_cred(gss, server_cert, server_key, &p_chain, &cert); - if (ret) { - ret = 0; - goto end; - } - - /* exit if peer's credentials are not available */ - if (p_chain == NULL || cert == NULL) { - ret = 0; - goto end; - } - - /* uses X509_CERT_DIR and X509_VOMS_DIR vars */ - voms_info = VOMS_Init(voms_dir, ca_dir); - if (voms_info == NULL) { - edg_wll_SetError(ctx, errno, "failed to initialize VOMS structures"); - ret = -1; /* XXX VOMS Error */ - goto end; - } - - ret = VOMS_Retrieve(cert, p_chain, RECURSE_CHAIN, voms_info, &err); - if (ret == 0) { - if (err == VERR_NOEXT) - /* XXX DK: - edg_wll_SetError(ctx, EINVAL, "no client VOMS certificates found"); - */ - ret = 0; - else { - edg_wll_SetError(ctx, -1, "failed to retrieve VOMS info"); - ret = -1; /* XXX VOMS Error */ - } - goto end; - } - - ret = get_groups(ctx, voms_info, &ctx->vomsGroups); - -end: - if (voms_info) - VOMS_Destroy(voms_info); - if (cert) - X509_free(cert); - - return ret; -} - -void -edg_wll_FreeVomsGroups(edg_wll_VomsGroups *groups) -{ - size_t len; - - if (groups == NULL) - return; - - for (len = 0; len < groups->len; len++) { - if (groups->val[len].vo) - free(groups->val[len].vo); - if (groups->val[len].name) - free(groups->val[len].name); - } -} - -#else /* NO_VOMS */ - -int -edg_wll_SetVomsGroups(edg_wll_Context ctx, edg_wll_GssConnection *gss, char *server_cert, - char *server_key, char *voms_dir, char *ca_dir) -{ - return 0; -} - -void edg_wll_FreeVomsGroups(edg_wll_VomsGroups *groups) {} - -#endif - - -#if !defined(NO_VOMS) && !defined(NO_GACL) - -static int -parse_creds(edg_wll_VomsGroups *groups, char *subject, GRSTgaclUser **gacl_user) -{ - GRSTgaclCred *cred = NULL; - GRSTgaclUser *user = NULL; - int ret; - int i; - - GRSTgaclInit(); - - cred = GRSTgaclCredNew("person"); - if (cred == NULL) - return ENOMEM; - - if (!GRSTgaclCredAddValue(cred, "dn", subject)) { - ret = EINVAL; /* GACL_ERR */ - goto fail; - } - - user = GRSTgaclUserNew(cred); - if (user == NULL) { - ret = ENOMEM; - goto fail; - } - cred = NULL; /* GACLnewUser() doesn't copy content, just store the pointer */ - - for (i = 0; i < groups->len; i++) { - cred = GRSTgaclCredNew("voms-cred"); - if (cred == NULL) { - ret = ENOMEM; - goto fail; - } - if (!GRSTgaclCredAddValue(cred, "vo", groups->val[i].vo) || - !GRSTgaclCredAddValue(cred, "group", groups->val[i].name)) { - ret = EINVAL; /* GACL_ERR */ - goto fail; - } - if (!GRSTgaclUserAddCred(user, cred)) { - ret = EINVAL; /* GACL_ERR */ - goto fail; - } - cred = NULL; - /* GACLuserAddCred() doesn't copy content, just store the pointer. Cred - * mustn't be free()ed */ - } - - *gacl_user = user; - - return 0; - -fail: - if (cred) - /* XXX GRSTgaclCredFree(cred); */ - ; - if (user) - /* XXX GRSTgaclUserFree(user); */ - ; - - return ret; -} - -static int -cmp_gacl_names(GRSTgaclNamevalue *n1, GRSTgaclNamevalue *n2) -{ - if (n1 == NULL && n2 == NULL) - return 1; - - for ( ; n1; n1 = (GRSTgaclNamevalue *)n1->next, n2 = (GRSTgaclNamevalue *) n2->next) { - if (n2 == NULL) - return 0; - if (strcmp(n1->name, n2->name) != 0 || - strcmp(n1->value, n2->value) != 0) - return 0; - } - - return (n2 == NULL); -} - -static int -cmp_gacl_creds(GRSTgaclCred *c1, GRSTgaclCred *c2) -{ - if (strcmp(c1->type, c2->type) != 0) - return 0; - - return cmp_gacl_names(c1->firstname, c2->firstname); - /* we support only "simple" entries containing only one credential (DN or - * VOMS group */ -} - -static int -addEntry(GRSTgaclAcl *acl, GRSTgaclEntry *entry) -{ - GRSTgaclEntry *cur = NULL; - - - if ( acl == NULL ) - return EINVAL; - - if ( acl->firstentry == NULL ) - return (GRSTgaclAclAddEntry(acl, entry) == 0) ? -1 /* GACL_ERR */ : 0; - - for ( cur = acl->firstentry; cur; cur = cur->next ) - if ( cmp_gacl_creds(cur->firstcred, entry->firstcred) - && cur->allowed == entry->allowed - && cur->denied == entry->denied ) - return EEXIST; - - return (GRSTgaclAclAddEntry(acl, entry) == 0) ? -1 /* GACL_ERR */ : 0; -} - -static int -delEntry(GRSTgaclAcl *acl, GRSTgaclEntry *entry) -{ - GRSTgaclEntry *cur = NULL, *prev = NULL; - int found = 0; - - if (acl == NULL || acl->firstentry == NULL) - return EINVAL; - - cur = acl->firstentry; - while (cur) { - if (cmp_gacl_creds(cur->firstcred, entry->firstcred) && - cur->allowed == entry->allowed && - cur->denied == entry->denied) { - if (prev) - prev->next = cur->next; - else - acl->firstentry = cur->next; - /* XXX GRSTgaclEntryFree(cur); */ - found = 1; - break; - } - prev = cur; - cur = cur->next; - } - - return (found) ? 0 : -1 /* NOT_FOUND */; -} - -static int -create_cred(char *userid, int user_type, GRSTgaclCred **cred) -{ - GRSTgaclCred *c = NULL; - char *group = NULL; - - if (user_type == EDG_WLL_USER_SUBJECT) { - c = GRSTgaclCredNew("person"); - if (c == NULL) - return ENOMEM; - if (!GRSTgaclCredAddValue(c, "dn", userid)) { - /* XXX GRSTgaclCredFree(c); */ - return -1; /* GACL_ERR */ - } - } else if(user_type == EDG_WLL_USER_VOMS_GROUP) { - c = GRSTgaclCredNew("voms-cred"); - if (c == NULL) - return ENOMEM; - group = strchr(userid, ':'); - if ( !group ) - return EINVAL; - *group++ = '\0'; - if (!GRSTgaclCredAddValue(c, "vo", userid) || - !GRSTgaclCredAddValue(c, "group", group)) { - /* XXX GRSTgaclCredFree(c); */ - return -1; /* GACL_ERR */ - } - } else - return EINVAL; - - *cred = c; - - return 0; -} - -static int -change_acl(GRSTgaclAcl *acl, GRSTgaclEntry *entry, int operation) - /* creds, permission, permission_type */ -{ - if (operation == EDG_WLL_ACL_ADD) - return addEntry(acl, entry); - - if (operation == EDG_WLL_ACL_REMOVE) - return delEntry(acl, entry); - - return -1; -} - -static int -edg_wll_change_acl(edg_wll_Acl acl, char *user_id, int user_id_type, - int permission, int perm_type, int operation) -{ - GRSTgaclCred *cred = NULL; - GRSTgaclEntry *entry = NULL; - int ret; - - GRSTgaclInit(); - - if (acl == NULL || acl->value == NULL) - return EINVAL; - - ret = create_cred(user_id, user_id_type, &cred); - if (ret) - return ret; - - entry = GRSTgaclEntryNew(); - if (entry == NULL) { - ret = ENOMEM; - goto end; - } - - if (!GRSTgaclEntryAddCred(entry, cred)) { - ret = -1; /* GACLErr */ - goto end; - } - - if (perm_type == EDG_WLL_PERM_ALLOW) - GRSTgaclEntryAllowPerm(entry, permission); - else if (perm_type == EDG_WLL_PERM_DENY) - GRSTgaclEntryDenyPerm(entry, permission); - else { - ret = EINVAL; - goto end; - } - - ret = change_acl(acl->value, entry, operation); - if (ret) - { -/* XXX: mem leak? - GRSTgaclEntryFree(entry); -*/ - goto end; - } - - if (acl->string) free(acl->string); - ret = edg_wll_EncodeACL(acl->value, &acl->string); - -end: - - return ret; -} - -int -edg_wll_CheckACL(edg_wll_Context ctx, edg_wll_Acl acl, int requested_perm) -{ - int ret; - GRSTgaclUser *user = NULL; - unsigned int perm; - - if (acl == NULL || acl->value == NULL) - return edg_wll_SetError(ctx,EINVAL,"CheckACL"); - - if (!ctx->peerName) return edg_wll_SetError(ctx,EPERM,"CheckACL"); - - ret = parse_creds(&ctx->vomsGroups, ctx->peerName, &user); - if (ret) { - return edg_wll_SetError(ctx,ret,"parse_creds()"); - } - - perm = GRSTgaclAclTestUser(acl->value, user); - - /* XXX GRSTgaclUserFree(user); */ - - if (perm & requested_perm) return edg_wll_ResetError(ctx); - else return edg_wll_SetError(ctx,EPERM,"CheckACL"); -} - -int -edg_wll_EncodeACL(GRSTgaclAcl *acl, char **str) -{ - int tmp_fd, ret; - FILE *fd = NULL; - char filename[16]; - char line[4096]; - char *buf = NULL; - size_t buf_len = 0; - char *p; - - snprintf(filename, sizeof(filename), "/tmp/XXXXXX"); - tmp_fd = mkstemp(filename); - if (tmp_fd == -1) - return errno; - - fd = fdopen(tmp_fd, "r"); - - ret = GRSTgaclAclSave(acl, filename); - unlink(filename); - if (ret == 0) { - ret = -1; /* GACL_ERR */ - goto end; - } - - buf_len = 1024; - buf = calloc(buf_len, 1); - if (buf == NULL) { - ret = ENOMEM; - goto end; - } - - while (fgets(line, sizeof(line), fd) != NULL) { - p = strchr(line, '\n'); - if (p) - *p = '\0'; - - if (strlen(buf) + strlen(line) > buf_len) { - char *tmp; - - tmp = realloc(buf, buf_len + 1024); - if (tmp == NULL) { - ret = ENOMEM; - goto end; - } - buf = tmp; - buf_len += 1024; - } - - strcat(buf, line); - } - - *str = buf; - ret = 0; - -end: - fclose(fd); - return ret; -} - -int -edg_wll_DecodeACL(char *buf, GRSTgaclAcl **result_acl) -{ - /* Got from GACLloadAcl() available from GACL API */ - xmlDocPtr doc; - xmlNodePtr cur; - GRSTgaclAcl *acl; - GRSTgaclEntry *entry; - - doc = xmlParseMemory(buf, strlen(buf)); - if (doc == NULL) return EINVAL; - - cur = xmlDocGetRootElement(doc); - - if (xmlStrcmp(cur->name, (const xmlChar *) "gacl")) - { - free(doc); - free(cur); - return EINVAL; - } - - cur = cur->xmlChildrenNode; - - acl = GRSTgaclAclNew(); - - while (cur != NULL) - { - /* - if (cur->type == XML_TEXT_NODE && cur->content == '\n') { - cur=cur->next; - continue; - } - */ - entry = GACLparseEntry(cur); - if (entry == NULL) - { - /* XXX GRSTgaclAclFree(acl); */ - xmlFreeDoc(doc); - return EINVAL; - } - - GRSTgaclAclAddEntry(acl, entry); - - cur=cur->next; - } - - xmlFreeDoc(doc); - *result_acl = acl; - return 0; -} - -int -edg_wll_InitAcl(edg_wll_Acl *acl) -{ - edg_wll_Acl tmp; - - tmp = malloc(sizeof(*tmp)); - if ( !tmp ) - return ENOMEM; - - tmp->value = GRSTgaclAclNew(); - tmp->string = NULL; - *acl = tmp; - return 0; -} - -void -edg_wll_FreeAcl(edg_wll_Acl acl) -{ - /* XXX if ( acl->value ) GRSTgaclAclFree(acl->value); */ - if ( acl->string ) free(acl->string); - free(acl); -} - -int -edg_wll_HandleCounterACL(edg_wll_Context ctx, edg_wll_Acl acl, - char *aclid, int incr) -{ - char *q1 = NULL, - *q2 = NULL; - - edg_wll_ResetError(ctx); - - if ( incr > 0 ) - { - trio_asprintf(&q1, - "insert into acls(aclid,value,refcnt) " - "values ('%|Ss','%|Ss',%d)", - aclid, acl->string, incr); - - for ( ; ; ) - { - if ( edg_wll_ExecStmt(ctx, q1, NULL) > 0 ) - goto end; - - if ( edg_wll_Error(ctx,NULL,NULL) != EEXIST ) - goto end; - - /* - * row allready in DB - */ - if ( !q2 ) trio_asprintf(&q2, - "update acls set refcnt = refcnt+%d " - "where aclid = '%|Ss'", - incr, aclid); - if ( edg_wll_ExecStmt(ctx, q2, NULL) < 0 ) - continue; - - goto end; - } - } - else if (incr < 0) - { - trio_asprintf(&q1, - "update acls set refcnt = refcnt-%d " - "where aclid='%|Ss' and refcnt>=%d", - -incr, aclid, -incr); - - if ( edg_wll_ExecStmt(ctx, q1, NULL) > 0 ) - { - trio_asprintf(&q2, - "delete from acls " - "where aclid='%|Ss' and refcnt=0", - aclid); - edg_wll_ExecStmt(ctx, q2, NULL); - } - else - { - fprintf(stderr, "ACL with ID: %s has invalid reference count\n", aclid); - syslog(LOG_WARNING, "ACL with ID: %s has invalid reference count\n", aclid); - } - } - - -end: - if ( q1 ) free(q1); - if ( q2 ) free(q2); - - return edg_wll_Error(ctx, NULL, NULL); -} - -int -edg_wll_UpdateACL(edg_wll_Context ctx, edg_wlc_JobId job, - char *user_id, int user_id_type, - int permission, int perm_type, int operation) -{ - char *md5_jobid; - edg_wll_Acl acl = NULL; - int ret; - char *stmt = NULL; - char *new_aclid = NULL, *old_aclid = NULL; - int updated; - - edg_wll_ResetError(ctx); - - md5_jobid = edg_wlc_JobIdGetUnique(job); - - do { - if (acl) - { - edg_wll_FreeAcl(acl); - acl = NULL; - } - if (old_aclid) - { - free(old_aclid); - old_aclid = NULL; - } - if (new_aclid) - { - free(new_aclid); - new_aclid = NULL; - } - - if ( (ret = edg_wll_GetACL(ctx, job, &acl)) ) - goto end; - if ( !acl && (ret = edg_wll_InitAcl(&acl)) ) - goto end; - - old_aclid = acl->string? strdup(strmd5(acl->string, NULL)): NULL; - - ret = edg_wll_change_acl(acl, user_id, user_id_type, - permission, perm_type, operation); - if (ret) - { - if ( ret == EEXIST ) - /* - * adding allready set entry - * only upgrade the counter - */ - ret = edg_wll_HandleCounterACL(ctx, acl, new_aclid, 1); - - goto end; - } - - new_aclid = strdup(strmd5(acl->string, NULL)); - - /* store new ACL or increment its counter if already present in db */ - ret = edg_wll_HandleCounterACL(ctx, acl, new_aclid, 1); - if (ret) - goto end; - - if ( old_aclid ) - trio_asprintf(&stmt, - "update jobs set aclid='%|Ss' where jobid='%|Ss' and aclid='%|Ss'", - new_aclid, md5_jobid, old_aclid); - else - trio_asprintf(&stmt, - "update jobs set aclid='%|Ss' where jobid='%|Ss' and ISNULL(aclid)", - new_aclid, md5_jobid); - updated = edg_wll_ExecStmt(ctx, stmt, NULL); - free(stmt); stmt = NULL; - - if (updated > 0) - /* decrement reference counter of the old ACL, and possibly remove - * whole ACL if the counter becames zero */ - ret = edg_wll_HandleCounterACL(ctx, NULL, old_aclid, -1); - else - /* We failed to store new ACL to db, most likely because the ACL has - * been changed. Decrement counter of new ACL set before trying - * updating */ - ret = edg_wll_HandleCounterACL(ctx, NULL, new_aclid, -1); - } while (updated <= 0); - -end: - free(md5_jobid); - if (acl) - edg_wll_FreeAcl(acl); - if (new_aclid) - free(new_aclid); - if (old_aclid) - free(old_aclid); - - return ret; -} - -int edg_wll_GetACL(edg_wll_Context ctx, edg_wlc_JobId jobid, edg_wll_Acl *acl) -{ - char *q = NULL; - char *acl_id = NULL; - char *acl_str = NULL; - edg_wll_Stmt stmt = NULL; - int ret; - GRSTgaclAcl *gacl = NULL; - char *jobstr = edg_wlc_JobIdGetUnique(jobid); - - if (jobid == NULL || jobstr == NULL) - return edg_wll_SetError(ctx,EINVAL,"edg_wll_GetACL()"); - - edg_wll_ResetError(ctx); - - trio_asprintf(&q, - "select aclid from jobs where jobid = '%|Ss'", jobstr); - - if (edg_wll_ExecStmt(ctx, q, &stmt) < 0 || - edg_wll_FetchRow(stmt, &acl_id) < 0) { - goto end; - } - edg_wll_FreeStmt(&stmt); stmt = NULL; - free(q); q = NULL; - - if (acl_id == NULL || *acl_id == '\0') { - *acl = NULL; - return 0; - } - - trio_asprintf(&q, - "select value from acls where aclid = '%|Ss'", acl_id); - if (edg_wll_ExecStmt(ctx, q, &stmt) < 0 || - edg_wll_FetchRow(stmt, &acl_str) < 0) { - goto end; - } - - ret = edg_wll_DecodeACL(acl_str, &gacl); - if (ret) { - edg_wll_SetError(ctx, EINVAL, "encoding ACL"); - goto end; - } - - *acl = calloc(1, sizeof(**acl)); - if (*acl == NULL) { - ret = ENOMEM; - edg_wll_SetError(ctx, ENOMEM, "not enough memory"); - goto end; - } - - (*acl)->value = gacl; - (*acl)->string = acl_str; - gacl = NULL; acl_str = NULL; - ret = 0; - -end: - if (q) free(q); - if (stmt) edg_wll_FreeStmt(&stmt); - if (acl_id) free(acl_id); - if (acl_str) free(acl_str); - /* XXX if (gacl) GRSTgaclAclFree(gacl); */ - if (jobstr) free(jobstr); - - return edg_wll_Error(ctx, NULL, NULL); -} - -#else /* VOMS & GACL */ - - -int edg_wll_CheckACL(edg_wll_Context ctx, edg_wll_Acl acl, int requested_perm) { return EPERM; } - -#ifndef NO_GACL -int edg_wll_EncodeACL(GRSTgaclAcl *acl, char **str) { return 0; } -int edg_wll_DecodeACL(char *buf, GRSTgaclAcl **result_acl) { return 0; } -#else -int edg_wll_EncodeACL(void *acl, char **str) { return 0; } -int edg_wll_DecodeACL(char *buf, void **result_acl) { return 0; } -#endif - -int edg_wll_InitAcl(edg_wll_Acl *acl) { return 0; } -void edg_wll_FreeAcl(edg_wll_Acl acl) { } -int edg_wll_HandleCounterACL(edg_wll_Context ctx, edg_wll_Acl acl, - char *aclid, int incr) { return 0; } -int edg_wll_UpdateACL(edg_wll_Context ctx, edg_wlc_JobId job, - char *user_id, int user_id_type, - int permission, int perm_type, int operation) { return 0; } -int edg_wll_GetACL(edg_wll_Context ctx, edg_wlc_JobId jobid, edg_wll_Acl *acl) { return 0; } - - -#endif - diff --git a/org.glite.lb.server/src/lb_authz.h b/org.glite.lb.server/src/lb_authz.h deleted file mode 100644 index 137dd57..0000000 --- a/org.glite.lb.server/src/lb_authz.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef LB_AUTHZ_H -#define LB_AUTHZ_H - -#ifndef NO_GACL -#include -#endif - -typedef struct _edg_wll_Acl { -#ifndef NO_GACL - GRSTgaclAcl *value; -#else - void *value; /* XXX */ -#endif - char *string; -} _edg_wll_Acl; -typedef struct _edg_wll_Acl *edg_wll_Acl; - -# ifndef NO_GACL - -extern int -edg_wll_DecodeACL(char *, GRSTgaclAcl **); - -extern int -edg_wll_EncodeACL(GRSTgaclAcl *, char **); - -#else - -extern int -edg_wll_DecodeACL(char *, void **); - -extern int -edg_wll_EncodeACL(void *, char **); - -#endif /* NO_GACL */ - -/* we have NO_VOMS||NO_GACL placeholders for following routines */ - -extern int -edg_wll_InitAcl(edg_wll_Acl *); - -extern void -edg_wll_FreeAcl(edg_wll_Acl); - -extern int -edg_wll_UpdateACL(edg_wll_Context, edg_wlc_JobId, char *, int, int, int, int); - -extern int -edg_wll_CheckACL(edg_wll_Context, edg_wll_Acl, int); - -extern int -edg_wll_GetACL(edg_wll_Context, edg_wlc_JobId, edg_wll_Acl *); - -extern int -edg_wll_SetVomsGroups(edg_wll_Context, edg_wll_GssConnection *, char *, char *, char *, char *); - -extern void -edg_wll_FreeVomsGroups(edg_wll_VomsGroups *); - -#endif diff --git a/org.glite.lb.server/src/lb_html.c b/org.glite.lb.server/src/lb_html.c deleted file mode 100644 index e91a3ba..0000000 --- a/org.glite.lb.server/src/lb_html.c +++ /dev/null @@ -1,146 +0,0 @@ -#ident "$Header$" - -#include "lb_html.h" -#include "lb_proto.h" - -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" - -#include -#include -#include - -#ifdef __GNUC__ -#define UNUSED_VAR __attribute__((unused)) -#else -#define UNUSED_VAR -#endif - -int edg_wll_QueryToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_Event *eventsOut UNUSED_VAR, char **message UNUSED_VAR) -{ -/* not implemented yet */ - return -1; -} - -/* construct Message-Body of Response-Line for edg_wll_UserJobs */ -int edg_wll_UserJobsToHTML(edg_wll_Context ctx, edg_wlc_JobId *jobsOut, char **message) -{ - char *pomA, *pomB; - int i = 0; - - /* head */ - pomB = strdup(""); - - while (jobsOut[i]) { - char *chid = edg_wlc_JobIdUnparse(jobsOut[i]); - - asprintf(&pomA,"%s\t\t
  • %s\r\n", - pomB, chid,chid); - - free(chid); - free(pomB); - pomB = pomA; - i++; - } - - asprintf(&pomA, "\r\n\t\r\n" - "

    User jobs

    \r\n" - "User subject: %s

    " - "

      %s
    " - "\t\r\n",ctx->peerName,pomB); - free(pomB); - - *message = pomA; - - return 0; -} - - -/* construct Message-Body of Response-Line for edg_wll_JobStatus */ -int edg_wll_JobStatusToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobStat stat, char **message) -{ - char *pomA, *pomB; - char *chid,*chstat; - char *jdl,*rsl; - - jdl = strdup(""); - rsl = strdup(""); - - pomB = strdup(""); - - chid = edg_wlc_JobIdUnparse(stat.jobId); - -#define TR(name,type,field) \ - if (field) { \ - asprintf(&pomA,"%s" name ":" \ - "" type "",pomB,(field)); \ - free(pomB); \ - pomB = pomA; \ - } - - TR("Status","%s",(chstat = edg_wll_StatToString(stat.state))); - free(chstat); - TR("owner","%s",stat.owner); - TR("Condor Id","%s",stat.condorId); - TR("Globus Id","%s",stat.globusId); - TR("Local Id","%s",stat.localId); - TR("Reason","%s",stat.reason); - if ( (stat.stateEnterTime.tv_sec) || (stat.stateEnterTime.tv_usec) ) { - time_t time = stat.stateEnterTime.tv_sec; - TR("State entered","%s",ctime(&time)); - } - if ( (stat.lastUpdateTime.tv_sec) || (stat.lastUpdateTime.tv_usec) ) { - time_t time = stat.lastUpdateTime.tv_sec; - TR("Last update","%s",ctime(&time)); - } - TR("Expect update","%s",stat.expectUpdate ? "YES" : "NO"); - TR("Expect update from","%s",stat.expectFrom); - TR("Location","%s",stat.location); - TR("Destination","%s",stat.destination); - TR("Cancelling","%s",stat.cancelling>0 ? "YES" : "NO"); - if (stat.cancelReason != NULL) { - TR("Cancel reason","%s",stat.cancelReason); - } - TR("CPU time","%d",stat.cpuTime); - - - TR("Done code","%d",stat.done_code); - TR("Exit code","%d",stat.exit_code); - - if (stat.jdl) asprintf(&jdl,"

    Job description

    \r\n" - "
    %s
    \r\n",stat.jdl); - - if (stat.rsl) asprintf(&rsl,"

    RSL

    \r\n" - "
    %s
    \r\n",stat.rsl); - - - asprintf(&pomA, "\r\n\t\r\n" - "

    %s

    \r\n" - "%s
    " - "%s%s" - "\t\r\n", - chid,pomB,jdl,rsl); - free(pomB); - - *message = pomA; - - free(chid); - free(jdl); - free(rsl); - return 0; -} - -char *edg_wll_ErrorToHTML(edg_wll_Context ctx,int code) -{ - char *out,*et,*ed; - char *msg = edg_wll_HTTPErrorMessage(code); - edg_wll_ErrorCode e; - - e = edg_wll_Error(ctx,&et,&ed); - asprintf(&out,"Error\n" - "

    %s

    \n" - "%d: %s (%s)",msg,e,et,ed); - - free(et); free(ed); - return out; -} diff --git a/org.glite.lb.server/src/lb_html.h b/org.glite.lb.server/src/lb_html.h deleted file mode 100644 index 1cac83f..0000000 --- a/org.glite.lb.server/src/lb_html.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _LB_HTML -#define _LB_HTML - -#ident "$Header$" - -#include "glite/lb/consumer.h" - -int edg_wll_QueryToHTML(edg_wll_Context,edg_wll_Event *,char **); -int edg_wll_JobStatusToHTML(edg_wll_Context, edg_wll_JobStat, char **); -int edg_wll_UserJobsToHTML(edg_wll_Context, edg_wlc_JobId *, char **); -char *edg_wll_ErrorToHTML(edg_wll_Context,int); - -#endif diff --git a/org.glite.lb.server/src/lb_http.c b/org.glite.lb.server/src/lb_http.c deleted file mode 100644 index efe0c41..0000000 --- a/org.glite.lb.server/src/lb_http.c +++ /dev/null @@ -1,59 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include - -#include "glite/lb/consumer.h" -#include "glite/lb/mini_http.h" -#include "glite/lb/context-int.h" - -#include "lb_http.h" -#include "lb_proto.h" - -#define dprintf(x) printf x - - -int edg_wll_ServerHTTP(edg_wll_Context ctx) -{ - char **hdr = NULL,*req = NULL,*body = NULL, - **hdrOut = NULL, *resp = NULL, *bodyOut = NULL, - *err_desc = NULL; - edg_wll_ErrorCode err = 0; - - - if ( ctx->isProxy ) err = edg_wll_http_recv_proxy(ctx,&req,&hdr,&body); - else err = edg_wll_http_recv(ctx,&req,&hdr,&body); - - dprintf(("[%d] %s\n",getpid(),req)); - if (body) dprintf(("\n%s\n\n",body)); - - if (!err) { - if ((err = edg_wll_Proto(ctx,req,hdr,body,&resp,&hdrOut,&bodyOut))) - edg_wll_Error(ctx,NULL,&err_desc); - - if (resp) { - if ( ctx->isProxy ) - edg_wll_http_send_proxy(ctx,resp,(char const * const *)hdrOut,bodyOut); - else - edg_wll_http_send(ctx,resp,(char const * const *)hdrOut,bodyOut); - } - } - - free(req); - free(resp); - if (hdr) { - char **h; - for (h = hdr; *h; h++) free(*h); - free(hdr); - } - // hdrOut are static - free(body); - free(bodyOut); - - if (err != edg_wll_Error(ctx,NULL,NULL)) edg_wll_SetError(ctx,err,err_desc); - free(err_desc); - return err; -} diff --git a/org.glite.lb.server/src/lb_http.h b/org.glite.lb.server/src/lb_http.h deleted file mode 100644 index 76bb883..0000000 --- a/org.glite.lb.server/src/lb_http.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _LB_HTTP_H -#define _LB_HTTP_H - -#ident "$Header$" - -#include - -#include "glite/lb/consumer.h" - -int edg_wll_ServerHTTP(edg_wll_Context); -int edg_wll_ServerHTTPProxy(edg_wll_Context); - -#endif diff --git a/org.glite.lb.server/src/lb_proto.c b/org.glite.lb.server/src/lb_proto.c deleted file mode 100644 index e1709b7..0000000 --- a/org.glite.lb.server/src/lb_proto.c +++ /dev/null @@ -1,841 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include - -#include - -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/mini_http.h" -#include "glite/lb/xml_conversions.h" -#include "glite/lb/dump.h" -#include "glite/lb/load.h" -#include "glite/lb/purge.h" - -#include "lb_proto.h" -#include "lb_html.h" -#include "get_events.h" -#include "purge.h" -#include "lb_xml_parse.h" -#include "lb_xml_parse_V21.h" - - -#define METHOD_GET "GET " -#define METHOD_POST "POST " - -#define KEY_QUERY_JOBS "/queryJobs " -#define KEY_QUERY_EVENTS "/queryEvents " -#define KEY_PURGE_REQUEST "/purgeRequest " -#define KEY_DUMP_REQUEST "/dumpRequest " -#define KEY_LOAD_REQUEST "/loadRequest " -#define KEY_INDEXED_ATTRS "/indexedAttrs " -#define KEY_NOTIF_REQUEST "/notifRequest " -#define KEY_QUERY_SEQUENCE_CODE "/querySequenceCode " -#define KEY_HTTP "HTTP/1.1" - - -#define KEY_ACCEPT "Accept:" -#define KEY_APP "application/x-dglb" -#define KEY_AGENT "User-Agent" - - -const char* const response_headers[] = { - "Cache-Control: no-cache", - "Accept: application/x-dglb", - "User-Agent: edg_wll_Server/" PROTO_VERSION "/" COMP_PROTO, - "Content-Type: application/x-dglb", - NULL -}; - -extern int edg_wll_NotifNewServer(edg_wll_Context, - edg_wll_QueryRec const * const *, char const *, - const edg_wll_NotifId, time_t *); -extern int edg_wll_NotifBindServer(edg_wll_Context, - const edg_wll_NotifId, const char *, time_t *); -extern int edg_wll_NotifChangeServer(edg_wll_Context, - const edg_wll_NotifId, edg_wll_QueryRec const * const *, - edg_wll_NotifChangeOp); -extern int edg_wll_NotifRefreshServer(edg_wll_Context, - const edg_wll_NotifId, time_t *); -extern int edg_wll_NotifDropServer(edg_wll_Context, edg_wll_NotifId *); - - - -char *edg_wll_HTTPErrorMessage(int errCode) -{ - char *msg; - - switch (errCode) { - case HTTP_OK: msg = "OK"; break; - case HTTP_BADREQ: msg = "Bad Request"; break; - case HTTP_UNAUTH: msg = "Unauthorized"; break; - case HTTP_NOTFOUND: msg = "Not Found"; break; - case HTTP_NOTALLOWED: msg = "Method Not Allowed"; break; - case HTTP_UNSUPPORTED: msg = "Unsupported Media Type"; break; - case HTTP_NOTIMPL: msg = "Not Implemented"; break; - case HTTP_INTERNAL: msg = "Internal Server Error"; break; - case HTTP_UNAVAIL: msg = "Service Unavailable"; break; - case HTTP_INVALID: msg = "Invalid Data"; break; - default: msg = "Unknown error"; break; - } - - return msg; -} - - -/* returns non-zero if old style (V21) protocols incompatible */ -static int is_protocol_incompatibleV21(char *user_agent) -{ - char *version, *comp_proto, *needle; - double v, c, my_v = strtod(PROTO_VERSION_V21, (char **) NULL), my_c; - - - /* get version od the other side */ - if ((version = strstr(user_agent,"/")) == NULL) return(-1); - else v = strtod(++version, &needle); - - /* sent the other side list of compatible protocols? */ - if ( needle[0] == '\0' ) return(-2); - - /* test compatibility if server newer*/ - if (my_v > v) { - comp_proto=COMP_PROTO_V21; - do { - my_c = strtod(comp_proto, &needle); - if (my_c == v) return(0); - comp_proto = needle + 1; - } while (needle[0] != '\0'); - return(1); - } - - /* test compatibility if server is older */ - else if (my_v < v) { - do { - comp_proto = needle + 1; - c = strtod(comp_proto, &needle); - if (my_v == c) return(0); - } while (needle[0] != '\0'); - return(1); - } - - /* version match */ - return(0); -} - - -/* returns non-zero if protocols incompatible */ -static int is_protocol_incompatible(char *user_agent) -{ - char *version, *comp_proto, *needle; - double v, c, my_v = strtod(PROTO_VERSION, (char **) NULL), my_c; - - - /* get version od the other side */ - if ((version = strstr(user_agent,"/")) == NULL) return(-1); - else v = strtod(++version, &needle); - - /* sent the other side list of compatible protocols? */ - if ( needle[0] == '\0' ) return(-2); - - /* test compatibility if server newer*/ - if (my_v > v) { - comp_proto=COMP_PROTO; - do { - my_c = strtod(comp_proto, &needle); - if (my_c == v) return(0); - comp_proto = needle + 1; - } while (needle[0] != '\0'); - return(1); - } - - /* test compatibility if server is older */ - else if (my_v < v) { - do { - comp_proto = needle + 1; - c = strtod(comp_proto, &needle); - if (my_v == c) return(0); - } while (needle[0] != '\0'); - return(1); - } - - /* version match */ - return(0); -} - - -static int outputHTML(char **headers) -{ - int i; - - if (!headers) return 0; - - for (i=0; headers[i]; i++) - if (!strncmp(headers[i], KEY_ACCEPT, sizeof(KEY_ACCEPT) - 1)) { - if (strstr(headers[i],KEY_APP)) - return 0; /* message sent by edg_wll_Api */ - else - return 1; /* message sent by other application */ - } - return 1; - -} - - - - -edg_wll_ErrorCode edg_wll_ProtoV21(edg_wll_Context ctx, - char *request,char **headers,char *messageBody, - char **response,char ***headersOut,char **bodyOut) -{ - char *requestPTR, *message = NULL; - int ret = HTTP_OK; - int html = outputHTML(headers); - int i; - - edg_wll_ResetError(ctx); - - for (i=0; headers[i]; i++) /* find line with version number in headers */ - if ( strstr(headers[i], KEY_AGENT) ) break; - - if (headers[i] == NULL) { ret = HTTP_BADREQ; goto errV21; } /* if not present */ - switch (is_protocol_incompatibleV21(headers[i])) { - case 0 : /* protocols compatible */ - ctx->is_V21 = 1; - break; - case -1 : /* malformed 'User Agent:' line */ - ret = HTTP_BADREQ; - goto errV21; - break; - case -2 : /* version of one protocol unknown */ - /* fallthrough */ - case 1 : /* protocols incompatible */ - /* fallthrough */ - default : ret = HTTP_UNSUPPORTED; - edg_wll_SetError(ctx,ENOTSUP,"Protocol versions are incompatible."); - goto errV21; - break; - } - - -/* GET */ - if (!strncmp(request, METHOD_GET, sizeof(METHOD_GET)-1)) { - // Not supported - ret = HTTP_BADREQ; -/* POST */ - } else if (!strncmp(request,METHOD_POST,sizeof(METHOD_POST)-1)) { - - requestPTR = request + sizeof(METHOD_POST)-1; - - if (!strncmp(requestPTR,KEY_QUERY_EVENTS,sizeof(KEY_QUERY_EVENTS)-1)) { - edg_wll_Event *eventsOut = NULL; - edg_wll_QueryRec **job_conditions = NULL, **event_conditions = NULL; - int i,j; - - if (parseQueryEventsRequestV21(ctx, messageBody, &job_conditions, &event_conditions)) - ret = HTTP_BADREQ; - - else { - int fatal = 0; - - switch (edg_wll_QueryEventsServer(ctx,ctx->noAuth, - (const edg_wll_QueryRec **)job_conditions, - (const edg_wll_QueryRec **)event_conditions, &eventsOut)) { - - case 0: if (html) ret = HTTP_NOTIMPL; - else ret = HTTP_OK; - break; - case ENOENT: ret = HTTP_NOTFOUND; break; - case EPERM : ret = HTTP_UNAUTH; break; - case EDG_WLL_ERROR_NOINDEX: ret = HTTP_UNAUTH; break; - case ENOMEM: fatal = 1; ret = HTTP_INTERNAL; break; - default: ret = HTTP_INTERNAL; break; - } - /* glue errors (if eny) to XML responce */ - if (!html && !fatal) - if (edg_wll_QueryEventsToXMLV21(ctx, eventsOut, &message)) - ret = HTTP_INTERNAL; - } - - if (job_conditions) { - for (j = 0; job_conditions[j]; j++) { - for (i = 0 ; (job_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&job_conditions[j][i]); - free(job_conditions[j]); - } - free(job_conditions); - } - - if (event_conditions) { - for (j = 0; event_conditions[j]; j++) { - for (i = 0 ; (event_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&event_conditions[j][i]); - free(event_conditions[j]); - } - free(event_conditions); - } - - if (eventsOut != NULL) { - for (i=0; eventsOut[i].type != EDG_WLL_EVENT_UNDEF; i++) - edg_wll_FreeEvent(&(eventsOut[i])); - edg_wll_FreeEvent(&(eventsOut[i])); /* free last line */ - free(eventsOut); - } - } - else if (!strncmp(requestPTR,KEY_QUERY_JOBS,sizeof(KEY_QUERY_JOBS)-1)) { - edg_wlc_JobId *jobsOut = NULL; - edg_wll_JobStat *statesOut = NULL; - edg_wll_QueryRec **conditions = NULL; - int i,j, flags = 0; - - if (parseQueryJobsRequestV21(ctx, messageBody, &conditions, &flags)) - ret = HTTP_BADREQ; - - else { - int fatal = 0, - retCode; - - if (flags & EDG_WLL_STAT_NO_JOBS) { - flags -= EDG_WLL_STAT_NO_JOBS; - jobsOut = NULL; - if (flags & EDG_WLL_STAT_NO_STATES) { - flags -= EDG_WLL_STAT_NO_STATES; - statesOut = NULL; - retCode = edg_wll_QueryJobsServer(ctx, (const edg_wll_QueryRec **)conditions, flags, NULL, NULL); - } - else - retCode = edg_wll_QueryJobsServer(ctx, (const edg_wll_QueryRec **)conditions, flags, NULL, &statesOut); - } - else { - if (flags & EDG_WLL_STAT_NO_STATES) { - flags -= EDG_WLL_STAT_NO_STATES; - statesOut = NULL; - retCode = edg_wll_QueryJobsServer(ctx, (const edg_wll_QueryRec **)conditions, flags, &jobsOut, NULL); - } - else - retCode = edg_wll_QueryJobsServer(ctx, (const edg_wll_QueryRec **)conditions, flags, &jobsOut, &statesOut); - } - - switch ( retCode ) { - // case EPERM : ret = HTTP_UNAUTH; - // /* soft-error fall through */ - case 0: if (html) ret = HTTP_NOTIMPL; - else ret = HTTP_OK; - - break; - case ENOENT: ret = HTTP_NOTFOUND; break; - case EPERM: ret = HTTP_UNAUTH; break; - case EDG_WLL_ERROR_NOINDEX: ret = HTTP_UNAUTH; break; - case ENOMEM: fatal = 1; ret = HTTP_INTERNAL; break; - default: ret = HTTP_INTERNAL; break; - } - if (!html && !fatal) - if (edg_wll_QueryJobsToXMLV21(ctx, jobsOut, statesOut, &message)) - ret = HTTP_INTERNAL; - } - - if (conditions) { - for (j = 0; conditions[j]; j++) { - for (i = 0; (conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&conditions[j][i]); - free(conditions[j]); - } - free(conditions); - } - - if (jobsOut) { - for (i=0; jobsOut[i]; i++) edg_wlc_JobIdFree(jobsOut[i]); - free(jobsOut); - } - if (statesOut) { - for (i=0; statesOut[i].state != EDG_WLL_JOB_UNDEF; i++) - edg_wll_FreeStatus(&(statesOut[i])); - edg_wll_FreeStatus(&(statesOut[i])); /* free last line */ - free(statesOut); - } - } - /* POST [something else]: not understood */ - else ret = HTTP_BADREQ; - -/* other HTTP methods */ - } else ret = HTTP_NOTALLOWED; - -errV21: asprintf(response,"HTTP/1.1 %d %s",ret,edg_wll_HTTPErrorMessage(ret)); - *headersOut = (char **) response_headers; - if ((ret != HTTP_OK) && html) - *bodyOut = edg_wll_ErrorToHTML(ctx,ret); - else - *bodyOut = message; - - return edg_wll_Error(ctx,NULL,NULL); -} - - - -edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx, - char *request,char **headers,char *messageBody, - char **response,char ***headersOut,char **bodyOut) -{ - char *requestPTR, *message = NULL; - int ret = HTTP_OK; - int html = outputHTML(headers); - int i; - - edg_wll_ResetError(ctx); - - for (i=0; headers[i]; i++) /* find line with version number in headers */ - if ( strstr(headers[i], KEY_AGENT) ) break; - - if (headers[i] == NULL) { ret = HTTP_BADREQ; goto err; } /* if not present */ - switch (is_protocol_incompatible(headers[i])) { - case 0 : /* protocols compatible */ - ctx->is_V21 = 0; - break; - case -1 : /* malformed 'User Agent:' line */ - ret = HTTP_BADREQ; - goto err; - break; - case 1 : /* protocols incompatible */ - /* try old (V21) version compatibility */ - edg_wll_ProtoV21(ctx, request, headers, messageBody, - response, headersOut, bodyOut); - - /* and propagate errors or results */ - return edg_wll_Error(ctx,NULL,NULL); - break; - case -2 : /* version of one protocol unknown */ - /* fallthrough */ - default : ret = HTTP_UNSUPPORTED; - edg_wll_SetError(ctx,ENOTSUP,"Protocol versions are incompatible."); - goto err; - break; - } - - -/* GET */ - if (!strncmp(request, METHOD_GET, sizeof(METHOD_GET)-1)) { - - requestPTR = request + sizeof(METHOD_GET)-1; - - - /* GET /: Current User Jobs */ - if (requestPTR[0]=='/' && (requestPTR[1]==' ' || requestPTR[1]=='?')) { - edg_wlc_JobId *jobsOut = NULL; - int i, flags; - - flags = (requestPTR[1]=='?') ? edg_wll_string_to_stat_flags(requestPTR + 2) : 0; - -// FIXME: edg_wll_UserJobs should take flags as parameter - if (!ctx->peerName) { - edg_wll_SetError(ctx,EPERM,"Operation not permitted."); - ret = HTTP_UNAUTH; - } - switch (edg_wll_UserJobs(ctx,&jobsOut,NULL)) { - case 0: if (html) edg_wll_UserJobsToHTML(ctx, jobsOut, &message); - else ret = HTTP_OK; - break; - case ENOENT: ret = HTTP_NOTFOUND; break; - default: ret = HTTP_INTERNAL; break; - } - if (!html && (ret != HTTP_INTERNAL)) - if (edg_wll_UserJobsToXML(ctx, jobsOut, &message)) - ret = HTTP_INTERNAL; - - if (jobsOut) { - for (i=0; jobsOut[i]; i++) edg_wlc_JobIdFree(jobsOut[i]); - free(jobsOut); - } - } - - /* GET /[jobId]: Job Status */ - else if (*requestPTR=='/') { - edg_wlc_JobId jobId = NULL; - char *pom1,*fullid = NULL; - edg_wll_JobStat stat; - char *pomCopy; - - if (ctx->srvName == NULL) { - edg_wll_SetError(ctx, EDG_WLL_ERROR_SERVER_RESPONSE, - "no server name on GET /jobid"); - ret = HTTP_INTERNAL; - goto err; - } - memset(&stat,0,sizeof(stat)); - pomCopy = strdup(requestPTR + 1); - for (pom1=pomCopy; *pom1 && !isspace(*pom1); pom1++); - *pom1 = 0; - - asprintf(&fullid,GLITE_WMSC_JOBID_PROTO_PREFIX"%s:%u/%s",ctx->srvName,ctx->srvPort,pomCopy); - free(pomCopy); - - if (edg_wlc_JobIdParse(fullid, &jobId)) { - edg_wll_SetError(ctx,EDG_WLL_ERROR_JOBID_FORMAT,fullid); - ret = HTTP_BADREQ; - } - else switch (edg_wll_JobStatus(ctx,jobId,0,&stat)) { - case 0: if (html) edg_wll_JobStatusToHTML(ctx,stat,&message); - else ret = HTTP_OK; - break; - case ENOENT: ret = HTTP_NOTFOUND; break; - case EINVAL: ret = HTTP_INVALID; break; - case EPERM : ret = HTTP_UNAUTH; break; - default: ret = HTTP_INTERNAL; break; - } - if (!html && (ret != HTTP_INTERNAL)) - if (edg_wll_JobStatusToXML(ctx,stat,&message)) - ret = HTTP_INTERNAL; - - free(fullid); - edg_wlc_JobIdFree(jobId); - edg_wll_FreeStatus(&stat); - - /* GET [something else]: not understood */ - } else ret = HTTP_BADREQ; - -/* POST */ - } else if (!strncmp(request,METHOD_POST,sizeof(METHOD_POST)-1)) { - - requestPTR = request + sizeof(METHOD_POST)-1; - - if (!strncmp(requestPTR,KEY_QUERY_EVENTS,sizeof(KEY_QUERY_EVENTS)-1)) { - edg_wll_Event *eventsOut = NULL; - edg_wll_QueryRec **job_conditions = NULL, **event_conditions = NULL; - int i,j; - - if (parseQueryEventsRequest(ctx, messageBody, &job_conditions, &event_conditions)) - ret = HTTP_BADREQ; - - else { - int fatal = 0; - - switch (edg_wll_QueryEventsServer(ctx,ctx->noAuth, - (const edg_wll_QueryRec **)job_conditions, - (const edg_wll_QueryRec **)event_conditions, &eventsOut)) { - - case 0: if (html) ret = HTTP_NOTIMPL; - else ret = HTTP_OK; - break; - case ENOENT: ret = HTTP_NOTFOUND; break; - case EPERM : ret = HTTP_UNAUTH; break; - case E2BIG: ret = HTTP_UNAUTH; break; - case EINVAL: ret = HTTP_UNAUTH; break; - case EDG_WLL_ERROR_NOINDEX: ret = HTTP_UNAUTH; break; - case ENOMEM: fatal = 1; ret = HTTP_INTERNAL; break; - default: ret = HTTP_INTERNAL; break; - } - /* glue errors (if eny) to XML responce */ - if (!html && !fatal) - if (edg_wll_QueryEventsToXML(ctx, eventsOut, &message)) - ret = HTTP_INTERNAL; - } - - if (job_conditions) { - for (j = 0; job_conditions[j]; j++) { - for (i = 0 ; (job_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&job_conditions[j][i]); - free(job_conditions[j]); - } - free(job_conditions); - } - - if (event_conditions) { - for (j = 0; event_conditions[j]; j++) { - for (i = 0 ; (event_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&event_conditions[j][i]); - free(event_conditions[j]); - } - free(event_conditions); - } - - if (eventsOut != NULL) { - for (i=0; eventsOut[i].type != EDG_WLL_EVENT_UNDEF; i++) - edg_wll_FreeEvent(&(eventsOut[i])); - edg_wll_FreeEvent(&(eventsOut[i])); /* free last line */ - free(eventsOut); - } - } - else if (!strncmp(requestPTR,KEY_QUERY_JOBS,sizeof(KEY_QUERY_JOBS)-1)) { - edg_wlc_JobId *jobsOut = NULL; - edg_wll_JobStat *statesOut = NULL; - edg_wll_QueryRec **conditions = NULL; - int i,j, flags = 0; - - if (parseQueryJobsRequest(ctx, messageBody, &conditions, &flags)) - ret = HTTP_BADREQ; - - else { - int fatal = 0, - retCode; - - if (flags & EDG_WLL_STAT_NO_JOBS) { - flags -= EDG_WLL_STAT_NO_JOBS; - jobsOut = NULL; - if (flags & EDG_WLL_STAT_NO_STATES) { - flags -= EDG_WLL_STAT_NO_STATES; - statesOut = NULL; - retCode = edg_wll_QueryJobsServer(ctx, (const edg_wll_QueryRec **)conditions, flags, NULL, NULL); - } - else - retCode = edg_wll_QueryJobsServer(ctx, (const edg_wll_QueryRec **)conditions, flags, NULL, &statesOut); - } - else { - if (flags & EDG_WLL_STAT_NO_STATES) { - flags -= EDG_WLL_STAT_NO_STATES; - statesOut = NULL; - retCode = edg_wll_QueryJobsServer(ctx, (const edg_wll_QueryRec **)conditions, flags, &jobsOut, NULL); - } - else - retCode = edg_wll_QueryJobsServer(ctx, (const edg_wll_QueryRec **)conditions, flags, &jobsOut, &statesOut); - } - - switch ( retCode ) { - // case EPERM : ret = HTTP_UNAUTH; - // /* soft-error fall through */ - case 0: if (html) ret = HTTP_NOTIMPL; - else ret = HTTP_OK; - - break; - case ENOENT: ret = HTTP_NOTFOUND; break; - case EPERM: ret = HTTP_UNAUTH; break; - case E2BIG: ret = HTTP_UNAUTH; break; - case EINVAL: ret = HTTP_UNAUTH; break; - case EDG_WLL_ERROR_NOINDEX: ret = HTTP_UNAUTH; break; - case ENOMEM: fatal = 1; ret = HTTP_INTERNAL; break; - default: ret = HTTP_INTERNAL; break; - } - if (!html && !fatal) - if (edg_wll_QueryJobsToXML(ctx, jobsOut, statesOut, &message)) - ret = HTTP_INTERNAL; - } - - if (conditions) { - for (j = 0; conditions[j]; j++) { - for (i = 0; (conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&conditions[j][i]); - free(conditions[j]); - } - free(conditions); - } - - if (jobsOut) { - for (i=0; jobsOut[i]; i++) edg_wlc_JobIdFree(jobsOut[i]); - free(jobsOut); - } - if (statesOut) { - for (i=0; statesOut[i].state != EDG_WLL_JOB_UNDEF; i++) - edg_wll_FreeStatus(&(statesOut[i])); - edg_wll_FreeStatus(&(statesOut[i])); /* free last line */ - free(statesOut); - } - } - else if (!strncmp(requestPTR,KEY_PURGE_REQUEST,sizeof(KEY_PURGE_REQUEST)-1)) { - edg_wll_PurgeRequest request; - - ctx->p_tmp_timeout.tv_sec = 86400; - - if ( !parsePurgeRequest(ctx,messageBody,(int (*)()) edg_wll_StringToStat,&request) ) - edg_wll_PurgeServer(ctx, (const edg_wll_PurgeRequest *)&request); - - if ( request.jobs ) - { - int i; - for ( i = 0; request.jobs[i]; i++ ) - free(request.jobs[i]); - free(request.jobs); - } - - /* - * response allready sent from edg_wll_PurgeServer() - return NULL results - */ - *response = NULL; - *headersOut = NULL; - *bodyOut = NULL; - return edg_wll_Error(ctx,NULL,NULL); - } - else if (!strncmp(requestPTR,KEY_DUMP_REQUEST,sizeof(KEY_DUMP_REQUEST)-1)) { - edg_wll_DumpRequest request; - edg_wll_DumpResult result; - - ctx->p_tmp_timeout.tv_sec = 86400; - - memset(&request,0,sizeof(request)); - memset(&result,0,sizeof(result)); - - if (parseDumpRequest(ctx, messageBody, &request)) - ret = HTTP_BADREQ; - else { - int fatal = 0; - - switch (edg_wll_DumpEvents(ctx,(const edg_wll_DumpRequest *) &request, &result)) { - case 0: if (html) ret = HTTP_NOTIMPL; - else ret = HTTP_OK; - break; - case ENOENT: ret = HTTP_NOTFOUND; break; - case EPERM : ret = HTTP_UNAUTH; break; - case EDG_WLL_ERROR_NOINDEX: ret = HTTP_UNAUTH; break; - case ENOMEM: fatal = 1; ret = HTTP_INTERNAL; break; - default: ret = HTTP_INTERNAL; break; - } - /* glue errors (if eny) to XML responce */ - if (!html && !fatal) - if (edg_wll_DumpResultToXML(ctx, &result, &message)) - ret = HTTP_INTERNAL; - } - - free(result.server_file); - } - else if (!strncmp(requestPTR,KEY_LOAD_REQUEST,sizeof(KEY_LOAD_REQUEST)-1)) { - edg_wll_LoadRequest request; - edg_wll_LoadResult result; - - ctx->p_tmp_timeout.tv_sec = 86400; - - memset(&request,0,sizeof(request)); - memset(&result,0,sizeof(result)); - - if (parseLoadRequest(ctx, messageBody, &request)) - ret = HTTP_BADREQ; - else { - int fatal = 0; - - switch (edg_wll_LoadEvents(ctx,(const edg_wll_LoadRequest *) &request, &result)) { - case 0: if (html) ret = HTTP_NOTIMPL; - else ret = HTTP_OK; - break; - case EEXIST: ret = HTTP_OK; break; - case EINVAL: ret = HTTP_INVALID; break; - case ENOENT: ret = HTTP_NOTFOUND; break; - case EPERM : ret = HTTP_UNAUTH; break; - case EDG_WLL_ERROR_NOINDEX: ret = HTTP_UNAUTH; break; - case ENOMEM: fatal = 1; ret = HTTP_INTERNAL; break; - default: ret = HTTP_INTERNAL; break; - } - /* glue errors (if eny) to XML responce */ - if (!html && !fatal) - if (edg_wll_LoadResultToXML(ctx, &result, &message)) - ret = HTTP_INTERNAL; - } - - free(result.server_file); - } - else if (!strncmp(requestPTR,KEY_INDEXED_ATTRS,sizeof(KEY_INDEXED_ATTRS)-1)) { - if (!html) - if (edg_wll_IndexedAttrsToXML(ctx, &message)) - ret = HTTP_INTERNAL; - } - else if (!strncmp(requestPTR,KEY_NOTIF_REQUEST,sizeof(KEY_NOTIF_REQUEST)-1)) { - char *function, *address; - edg_wll_NotifId notifId; - edg_wll_NotifChangeOp op; - edg_wll_QueryRec **conditions; - time_t validity = -1; - int i,j; - - - if (parseNotifRequest(ctx, messageBody, &function, ¬ifId, - &address, &op, &conditions)) - ret = HTTP_BADREQ; - else { - int fatal = 0, err = 0; - - // XXX presne poradi parametru zatim neni znamo - // navratove chyby nejsou zname, nutno predelat dle aktualni situace - if (!strcmp(function,"New")) - err = edg_wll_NotifNewServer(ctx, - (edg_wll_QueryRec const * const *)conditions, - address, notifId, &validity); - else if (!strcmp(function,"Bind")) - err = edg_wll_NotifBindServer(ctx, notifId, address, &validity); - else if (!strcmp(function,"Change")) - err = edg_wll_NotifChangeServer(ctx, notifId, - (edg_wll_QueryRec const * const *)conditions, op); - else if (!strcmp(function,"Refresh")) - err = edg_wll_NotifRefreshServer(ctx, notifId, &validity); - else if (!strcmp(function,"Drop")) - err = edg_wll_NotifDropServer(ctx, notifId); - - switch (err) { - case 0: if (html) ret = HTTP_NOTIMPL; - else ret = HTTP_OK; - break; - case EEXIST: ret = HTTP_OK; break; - case EINVAL: ret = HTTP_INVALID; break; - case ENOENT: ret = HTTP_NOTFOUND; break; - case EPERM : ret = HTTP_UNAUTH; break; - case EDG_WLL_ERROR_NOINDEX: ret = HTTP_UNAUTH; break; - case ENOMEM: fatal = 1; ret = HTTP_INTERNAL; break; - default: ret = HTTP_INTERNAL; break; - } - /* glue errors (if eny) to XML responce */ - if (!html && !fatal) - if (edg_wll_NotifResultToXML(ctx, validity, &message)) - ret = HTTP_INTERNAL; - } - - free(function); - free(address); - edg_wll_NotifIdFree(notifId); - if (conditions) { - for (j = 0; conditions[j]; j++) { - for (i = 0; (conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&conditions[j][i]); - free(conditions[j]); - } - free(conditions); - } - } - else if (!strncmp(requestPTR,KEY_QUERY_SEQUENCE_CODE,sizeof(KEY_QUERY_SEQUENCE_CODE)-1)) { - char *source; - char *seqCode; - edg_wlc_JobId jobId; - - - if (parseQuerySequenceCodeRequest(ctx, messageBody, &jobId, &source)) - ret = HTTP_BADREQ; - else { - int fatal = 0; - - switch (edg_wll_QuerySequenceCodeServer(ctx, jobId, source, &seqCode)) { - case 0: if (html) ret = HTTP_NOTIMPL; - else ret = HTTP_OK; - break; - case EEXIST: ret = HTTP_OK; break; - case EINVAL: ret = HTTP_INVALID; break; - case ENOENT: ret = HTTP_NOTFOUND; break; - case EPERM : ret = HTTP_UNAUTH; break; - case EDG_WLL_ERROR_NOINDEX: ret = HTTP_UNAUTH; break; - case ENOMEM: fatal = 1; ret = HTTP_INTERNAL; break; - default: ret = HTTP_INTERNAL; break; - } - - /* glue errors (if eny) to XML responce */ - if (!html && !fatal) - if (edg_wll_QuerySequenceCodeResultToXML(ctx, seqCode, &message)) - ret = HTTP_INTERNAL; - } - - free(source); - free(seqCode); - edg_wlc_JobIdFree(jobId); - - } - - - /* POST [something else]: not understood */ - else ret = HTTP_BADREQ; - -/* other HTTP methods */ - } else ret = HTTP_NOTALLOWED; - -err: asprintf(response,"HTTP/1.1 %d %s",ret,edg_wll_HTTPErrorMessage(ret)); - *headersOut = (char **) response_headers; - if ((ret != HTTP_OK) && html) - *bodyOut = edg_wll_ErrorToHTML(ctx,ret); - else - *bodyOut = message; - - return edg_wll_Error(ctx,NULL,NULL); -} diff --git a/org.glite.lb.server/src/lb_proto.h b/org.glite.lb.server/src/lb_proto.h deleted file mode 100644 index aea3957..0000000 --- a/org.glite.lb.server/src/lb_proto.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _LB_PROTO_H -#define _LB_PROTO_H - -#ident "$Header$" - -#include "glite/lb/consumer.h" - -extern const char* const response_headers[]; - -/* Handle a single request of the LB server protocol - * returns a complete response string (may contain a formatted error - * message) - * or NULL on fatal error*/ - -extern edg_wll_ErrorCode edg_wll_Proto( - edg_wll_Context, /* INOUT: context */ - char *, /* IN: HTTP request line */ - char **, /* IN: HTTP message headers */ - char *, /* IN: HTTP message body */ - char **, /* OUT: HTTP response line */ - char ***, /* OUT: HTTP response headers */ - char ** /* OUT: HTTP response body */ -); - -extern char *edg_wll_HTTPErrorMessage(int); - -#endif diff --git a/org.glite.lb.server/src/lb_xml_parse.c.T b/org.glite.lb.server/src/lb_xml_parse.c.T deleted file mode 100644 index 6732a04..0000000 --- a/org.glite.lb.server/src/lb_xml_parse.c.T +++ /dev/null @@ -1,1854 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" - -#include "glite/lb/consumer.h" -#include "glite/lb/escape.h" -#include "glite/lb/context-int.h" -#include "glite/lb/trio.h" -#include "glite/lb/xml_conversions.h" - -#include "glite/lb/purge.h" -#include "glite/lb/dump.h" -#include "glite/lb/load.h" - -#include "lb_xml_parse.h" - -#ifdef __GNUC__ -#define UNUSED_VAR __attribute__((unused)) -#else -#define UNUSED_VAR -#endif - -#define QUERY_EVENTS_BEGIN "\r\n" -#define QUERY_JOBS_BEGIN "\r\n" -#define PURGE_RESULT_BEGIN "\r\n" -#define DUMP_RESULT_BEGIN "\r\n" -#define LOAD_RESULT_BEGIN "\r\n" -#define INDEXED_ATTRS_BEGIN "\r\n" -#define NOTIF_RESULT_BEGIN "\r\n" -#define QUERY_SEQUENCE_CODE_RESULT_BEGIN "\r\n" - - -// XXX will be redundant soon -#define USERJOBS_BEGIN "\r\n" - - -static char *ops[] = { "equal","less","greater","within","unequal" }, - *attrs[] = { "jobid","owner","status","location","destination", - "donecode","usertag","time","level","host","source", - "instance","type","chkpt_tag", "resubmitted", "parent_job", "exitcode" }; - -static const struct timeval null_timeval = {0,0}; - -#define unexp() {\ - char *e;\ -\ - if (XMLCtx->errtxt) {\ - asprintf(&e,"%s\nunexpected <%s> at line %d",XMLCtx->errtxt,\ - el,XML_GetCurrentLineNumber(XMLCtx->p));\ - free(XMLCtx->errtxt);\ - } else asprintf(&e,"unexpected <%s> at line %d",\ - el,XML_GetCurrentLineNumber(XMLCtx->p));\ - XMLCtx->errtxt = e;\ -} - - - -static void startJobQueryRec(void *data, const char *el, const char **attr) -{ - unsigned int i; - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"and")) unexp() - break; - case 1: if (strcasecmp(el,"orJobConditions")) unexp() - else { - XMLCtx->position = -1; - XMLCtx->job_conditions = realloc(XMLCtx->job_conditions, - (++XMLCtx->row+2)*sizeof(*XMLCtx->job_conditions)); - XMLCtx->job_conditions[XMLCtx->row] = NULL; - XMLCtx->job_conditions[XMLCtx->row+1] = NULL; - } - break; - case 2: - for (i=0; ijob_conditions) break; - - /* malloc also terminator and set it to 0 (= EDG_WLL_QUERY_ATTR_UNDEF) */ - XMLCtx->job_conditions[XMLCtx->row] = realloc(XMLCtx->job_conditions[XMLCtx->row], - (++XMLCtx->position+2)*sizeof(**XMLCtx->job_conditions)); - memset(&XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position],0,2*sizeof(**XMLCtx->job_conditions)); - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].op = i; - XMLCtx->bound = 0; - } - break; - case 3: for (i=0; ijob_conditions) break; - if (!XMLCtx->job_conditions[XMLCtx->row]) break; - - if ( (i+1) == EDG_WLL_QUERY_ATTR_USERTAG) { - if (!attr[0] || !attr[1]) { unexp() break;} - if (strcmp(attr[0],"name")) { unexp() break;} - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.tag = strdup(attr[1]); - } - else if ( (i+1) == EDG_WLL_QUERY_ATTR_TIME) { - if (!attr[0] || !attr[1]) { unexp() break;} - if (attr[0] && strcmp(attr[0],"state")) { unexp() break;} - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.state = edg_wll_StringToStat(attr[1]); - } - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr = i+1; - } - break; - default: unexp(); break; - } - XMLCtx->level++; -} - - - -static void startQueryJobsRequest(void *data, const char *el, const char **attr) -{ - unsigned int i; - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_QueryJobsRequest")) { unexp() break; } - for ( i = 0; attr[i] && attr[i+1]; i += 2 ) - { - if ( !strcmp(attr[i],"softLimit") ) - XMLCtx->ctx->softLimit = atoi(attr[i+1]); - else if ( !strcmp(attr[i],"queryRes") ) - XMLCtx->ctx->p_query_results = atoi(attr[i+1]); - else { unexp() break; } - } - break; - case 1: if (!strcasecmp(el,"and")) { - XMLCtx->jobQueryRec_begin = XML_GetCurrentByteIndex(XMLCtx->p); - break; - } - else if (!strcasecmp(el,"flags")) break; - else unexp() - break; - case 2: /* fall through */ - case 3: /* do not check xml tags, processed in startJobQueryRec */ - case 4: break; - default: unexp(); break; - } - XMLCtx->level++; -} - - -static void startQueryEventsRequest(void *data, const char *el, const char **attr UNUSED_VAR) -{ - unsigned int i; - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_QueryEventsRequest")) { unexp() break; } - for ( i = 0; attr[i] && attr[i+1]; i += 2 ) - { - if ( !strcmp(attr[i],"softLimit") ) - XMLCtx->ctx->softLimit = atoi(attr[i+1]); - else if ( !strcmp(attr[i],"queryRes") ) - XMLCtx->ctx->p_query_results = atoi(attr[i+1]); - else { unexp() break; } - } - break; - case 1: if (strcasecmp(el,"and")) unexp() - break; - case 2: if (!strcasecmp(el,"orJobConditions")) { - XMLCtx->type = EDG_WLL_QUERY_TYPE_JOB_CONDITION; - XMLCtx->position = -1; - XMLCtx->job_conditions = realloc(XMLCtx->job_conditions, - (++XMLCtx->row+2)*sizeof(*XMLCtx->job_conditions)); - XMLCtx->job_conditions[XMLCtx->row] = NULL; - XMLCtx->job_conditions[XMLCtx->row+1] = NULL; - - } - else if (!strcasecmp(el,"orEventConditions")) { - XMLCtx->type = EDG_WLL_QUERY_TYPE_EVENT_CONDITION; - XMLCtx->position2 = -1; - XMLCtx->event_conditions = realloc(XMLCtx->event_conditions, - (++XMLCtx->row2+2)*sizeof(*XMLCtx->event_conditions)); - XMLCtx->event_conditions[XMLCtx->row2] = NULL; - XMLCtx->event_conditions[XMLCtx->row2+1] = NULL; - } - else unexp() - break; - case 3: - for (i=0; itype == EDG_WLL_QUERY_TYPE_JOB_CONDITION) { - if (!XMLCtx->job_conditions) break; - - /* malloc also terminator and set it to 0 (= EDG_WLL_QUERY_ATTR_UNDEF) */ - XMLCtx->job_conditions[XMLCtx->row] = realloc(XMLCtx->job_conditions[XMLCtx->row], - (++XMLCtx->position+2)*sizeof(**XMLCtx->job_conditions)); - memset(&XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position],0,2*sizeof(**XMLCtx->job_conditions)); - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].op = i; - XMLCtx->bound = 0; - } - else if (XMLCtx->type == EDG_WLL_QUERY_TYPE_EVENT_CONDITION) { - if (!XMLCtx->event_conditions) break; - /* malloc also terminator and set it to 0 (= EDG_WLL_QUERY_ATTR_UNDEF) */ - XMLCtx->event_conditions[XMLCtx->row2] = realloc(XMLCtx->event_conditions[XMLCtx->row2], - (++XMLCtx->position2+2)*sizeof(**XMLCtx->event_conditions)); - memset(&XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2],0,2*sizeof(**XMLCtx->event_conditions)); - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].op = i; - XMLCtx->bound = 0; - } - - break; - case 4: for (i=0; itype == EDG_WLL_QUERY_TYPE_JOB_CONDITION) { - if (!XMLCtx->job_conditions[XMLCtx->row]) break; - if ( (i+1) == EDG_WLL_QUERY_ATTR_USERTAG) { - if (!attr[0] || !attr[1]) { unexp() break;} - if (attr[0] && strcmp(attr[0],"name")) { unexp() break;} - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.tag = strdup(attr[1]); - } - else if ( (i+1) == EDG_WLL_QUERY_ATTR_TIME) { - if (!attr[0] || !attr[1]) { unexp() break;} - if (attr[0] && strcmp(attr[0],"state")) { unexp() break;} - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.state = edg_wll_StringToStat(attr[1]); - printf("\nchecking time attr\n%s = %s (%d)\n\n", attr[0], attr[1], edg_wll_StringToStat(attr[1])); - } - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr = i+1; - } - else if (XMLCtx->type == EDG_WLL_QUERY_TYPE_EVENT_CONDITION) { - if (!XMLCtx->event_conditions[XMLCtx->row2]) break; - if ( (i+1) == EDG_WLL_QUERY_ATTR_USERTAG) { - if (!attr[0] || !attr[1]) { unexp() break;} - if (attr[0] && strcmp(attr[0],"name")) { unexp() break;} - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position].attr_id.tag = strdup(attr[1]); - } - else if ( (i+1) == EDG_WLL_QUERY_ATTR_TIME) { - if (!attr[0] || !attr[1]) { unexp() break;} - if (attr[0] && strcmp(attr[0],"state")) { unexp() break;} - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position].attr_id.state = edg_wll_StringToStat(attr[1]); - } - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].attr = i+1; - } - break; - default: unexp(); break; - } - XMLCtx->level++; -} - - - -static void startPurgeRequest(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_PurgeRequest")) unexp() - break; - case 1: if (strcasecmp(el,"jobs") && strcasecmp(el,"timeout") - && strcasecmp(el,"flags")) unexp() - else - XMLCtx->position = 0; - break; - case 2: if (!strcasecmp(el,"jobId")) { - XMLCtx->purgeRequestGlobal.jobs = realloc(XMLCtx->purgeRequestGlobal.jobs, - (XMLCtx->position+2) * sizeof(XMLCtx->purgeRequestGlobal.jobs)); - - if (!XMLCtx->purgeRequestGlobal.jobs) { - edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); - unexp() return; - } - XMLCtx->purgeRequestGlobal.jobs[XMLCtx->position+1] = NULL; - } - else if (XMLCtx->tagToIndex(el) >= 0 ) { - /* static array, no need to initialize & allocate anything */ - } - else - unexp() - break; - default: unexp() - break; - } - XMLCtx->level++; -} - - -static void startDumpRequest(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_DumpRequest")) unexp() - break; - case 1: if (strcasecmp(el,"from") && strcasecmp(el,"to")) unexp() - break; - default: unexp() - break; - } - XMLCtx->level++; -} - - - -static void startLoadRequest(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_LoadRequest")) unexp() - break; - case 1: if (strcasecmp(el,"server_file")) unexp() - break; - default: unexp() - break; - } - XMLCtx->level++; -} - - - -static void startNotifRequest(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (!strcasecmp(el,"edg_wll_NotifRequest") && attr[0] && attr[1]) { - if (strcmp(attr[0],"function")) { unexp() break;} - else XMLCtx->notifFunction = strdup(attr[1]); - } - else unexp() - break; - case 1: if (!strcasecmp(el,"and")) { - XMLCtx->jobQueryRec_begin = XML_GetCurrentByteIndex(XMLCtx->p); - } - else if ( (strcasecmp(el,"notifId")) && (strcasecmp(el,"clientAddress")) && - (strcasecmp(el,"notifChangeOp")) ) unexp() - break; - case 2: /* fall through */ - case 3: /* do not check xml tags, processed in startJobQueryRec */ - case 4: break; - default: unexp() - break; - } - XMLCtx->level++; -} - - - -static void startQuerySequenceCodeRequest(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_QuerySequenceCodeRequest")) unexp() - break; - case 1: if ( (strcasecmp(el,"jobId")) && (strcasecmp(el,"source")) ) unexp() - break; - default: unexp() - break; - } - XMLCtx->level++; -} - -#undef unexp - - -static void char_handler(void *data, const char *s, int len) -{ - edg_wll_XML_ctx *XMLCtx = data; - int i, found = -1, temp_len1; - char *temp_s, *temp_s1; - - - /* if date are only spaces, t\, \r, \n ... don't bother with them */ - for (i=0; ichar_buf_len) XMLCtx->char_buf = - realloc(XMLCtx->char_buf,XMLCtx->char_buf_len+temp_len1 + 1); - else XMLCtx->char_buf = malloc(temp_len1 + 1); - - memcpy(XMLCtx->char_buf+XMLCtx->char_buf_len,temp_s1,temp_len1 + 1); - XMLCtx->char_buf_len += temp_len1; - free(temp_s1); - free(temp_s); -} - - - -static void endJobQueryRec(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - char *e; - - - if (XMLCtx->level == 4 && - XMLCtx->job_conditions != NULL && - XMLCtx->job_conditions[XMLCtx->row] != NULL) { - switch (XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr) { - case EDG_WLL_QUERY_ATTR_JOBID: - case EDG_WLL_QUERY_ATTR_PARENT: - if ( (XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.j = - edg_wll_from_string_to_jobid(XMLCtx)) == NULL ) - { - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid JobId at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid JobId at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - } - break; - case EDG_WLL_QUERY_ATTR_OWNER: - // XXX - this is way how to pass NULL, user will be extracted from ssl partner later - if (XMLCtx->char_buf != NULL && !strcmp(XMLCtx->char_buf,"NULL")) { - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.c = NULL; - break; - } - else /* fall through */ - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_DESTINATION: - case EDG_WLL_QUERY_ATTR_USERTAG: - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.c = - edg_wll_from_string_to_string(XMLCtx); - break; - case EDG_WLL_QUERY_ATTR_STATUS: - if ( !XMLCtx->bound ) - { - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.i = - edg_wll_from_string_to_edg_wll_JobStatCode(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value2.i = - edg_wll_from_string_to_edg_wll_JobStatCode(XMLCtx); - - break; - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_EXITCODE: - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - if ( !XMLCtx->bound ) - { - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.i = - edg_wll_from_string_to_int(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value2.i = - edg_wll_from_string_to_int(XMLCtx); - - break; - case EDG_WLL_QUERY_ATTR_TIME: - if ( !XMLCtx->bound ) - { - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value2.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - break; - default: - edg_wll_freeBuf(XMLCtx); - XMLCtx->level--; - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid attribute type at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid attribute type at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - break; - } - } - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - - -static void endQueryJobsRequest(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"flags") && XMLCtx->char_buf) { - // XXX: check if it works - XMLCtx->flags = edg_wll_string_to_stat_flags(XMLCtx->char_buf); - } - else if (!strcmp(el,"and")) { - long len = (XML_GetCurrentByteIndex(XMLCtx->p) + XML_GetCurrentByteCount(XMLCtx->p)) - - XMLCtx->jobQueryRec_begin; - - parseJobQueryRec(XMLCtx->ctx, XMLCtx->message_body + XMLCtx->jobQueryRec_begin, len, - &XMLCtx->job_conditions); - } - } - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - -static void endQueryEventsRequest(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - char *e; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"orJobConditions")) { - /* make end-of-row */ - XMLCtx->job_conditions[XMLCtx->row] = realloc(XMLCtx->job_conditions[XMLCtx->row], - (++XMLCtx->position+1)*sizeof(**XMLCtx->job_conditions)); - memset(&XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position],0,sizeof(**XMLCtx->job_conditions)); - } - else if (!strcmp(XMLCtx->element,"orEventConditions")) { - /* make end-of-row */ - XMLCtx->event_conditions[XMLCtx->row2] = realloc(XMLCtx->event_conditions[XMLCtx->row2], - (++XMLCtx->position2+1)*sizeof(**XMLCtx->event_conditions)); - memset(&XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2],0,sizeof(**XMLCtx->event_conditions)); - } - } - else if (XMLCtx->level == 5) { - if (XMLCtx->type == EDG_WLL_QUERY_TYPE_JOB_CONDITION && - XMLCtx->job_conditions != NULL && - XMLCtx->job_conditions[XMLCtx->row] !=NULL) { - switch (XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr) { - case EDG_WLL_QUERY_ATTR_JOBID: - case EDG_WLL_QUERY_ATTR_PARENT: - if ( (XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.j = - edg_wll_from_string_to_jobid(XMLCtx)) == NULL ) - { - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid JobId at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid JobId at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - } - break; - case EDG_WLL_QUERY_ATTR_OWNER: - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_DESTINATION: - case EDG_WLL_QUERY_ATTR_USERTAG: - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.c = - edg_wll_from_string_to_string(XMLCtx); - break; - case EDG_WLL_QUERY_ATTR_STATUS: - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_EXITCODE: - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - if ( !XMLCtx->bound ) - { - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.i = - edg_wll_from_string_to_int(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value2.i = - edg_wll_from_string_to_int(XMLCtx); - break; - case EDG_WLL_QUERY_ATTR_TIME: - if ( !XMLCtx->bound ) - { - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value2.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - break; - default: - edg_wll_freeBuf(XMLCtx); - XMLCtx->level--; - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid attribute type at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid attribute type at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - break; - } - } - else if (XMLCtx->type == EDG_WLL_QUERY_TYPE_EVENT_CONDITION && - XMLCtx->event_conditions != NULL && - XMLCtx->event_conditions[XMLCtx->row2] != NULL) { - switch (XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].attr) { - case EDG_WLL_QUERY_ATTR_TIME: - if ( !XMLCtx->bound ) - { - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].value.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].value2.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - break; - case EDG_WLL_QUERY_ATTR_LEVEL: - case EDG_WLL_QUERY_ATTR_SOURCE: - case EDG_WLL_QUERY_ATTR_EVENT_TYPE: - if ( !XMLCtx->bound ) - { - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].value.i = - edg_wll_from_string_to_int(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].value2.i = - edg_wll_from_string_to_int(XMLCtx); - break; - case EDG_WLL_QUERY_ATTR_HOST: - case EDG_WLL_QUERY_ATTR_INSTANCE: - case EDG_WLL_QUERY_ATTR_USERTAG: - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].value.c = - edg_wll_from_string_to_string(XMLCtx); - break; - default: - edg_wll_freeBuf(XMLCtx); - XMLCtx->level--; - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid attribute type at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid attribute type at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - break; - } - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - } - XMLCtx->level--; -} - - -static void endPurgeRequest(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - char *e; - int index; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"flags")) - XMLCtx->purgeRequestGlobal.flags = edg_wll_string_to_purge_flags(XMLCtx->char_buf); - } - else if (XMLCtx->level == 3) { - if (!strcmp(XMLCtx->element,"jobId") && XMLCtx->purgeRequestGlobal.jobs != NULL) { - if ( (XMLCtx->purgeRequestGlobal.jobs[XMLCtx->position++] = - edg_wll_from_string_to_string(XMLCtx)) == NULL ) - { - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid JobId at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid JobId at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - } - } - else if ( ((index = XMLCtx->tagToIndex(XMLCtx->element)) >= 0 ) && XMLCtx->char_buf ) { - XMLCtx->purgeRequestGlobal.timeout[index] = - edg_wll_from_string_to_time_t(XMLCtx); - } - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - -static void endDumpRequest(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"from")) { - if (isdigit(XMLCtx->char_buf[0])) - XMLCtx->dumpRequestGlobal.from = edg_wll_from_string_to_time_t(XMLCtx); - else - XMLCtx->dumpRequestGlobal.from = edg_wll_StringToDumpConst(XMLCtx->char_buf); - } - else if (!strcmp(XMLCtx->element,"to")) { - if (isdigit(XMLCtx->char_buf[0])) - XMLCtx->dumpRequestGlobal.to = edg_wll_from_string_to_time_t(XMLCtx); - else - XMLCtx->dumpRequestGlobal.to = edg_wll_StringToDumpConst(XMLCtx->char_buf); - } - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - - -static void endLoadRequest(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"server_file")) - XMLCtx->loadRequestGlobal.server_file = edg_wll_from_string_to_string(XMLCtx); - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - - -static void endNotifRequest(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - char *pom; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"notifId")) { - pom = edg_wll_from_string_to_string(XMLCtx); - edg_wll_NotifIdParse(pom, &XMLCtx->notifId); - free(pom); - } - else if (!strcmp(XMLCtx->element,"clientAddress")) { - XMLCtx->notifClientAddress = edg_wll_from_string_to_string(XMLCtx); - } - else if (!strcmp(XMLCtx->element,"notifChangeOp")) { - pom = edg_wll_from_string_to_string(XMLCtx); - XMLCtx->notifChangeOp = edg_wll_StringToNotifChangeOp(pom); - free(pom); - } - else if (!strcmp(el,"and")) { - long len = (XML_GetCurrentByteIndex(XMLCtx->p) + XML_GetCurrentByteCount(XMLCtx->p)) - - XMLCtx->jobQueryRec_begin; - - parseJobQueryRec(XMLCtx->ctx, XMLCtx->message_body + XMLCtx->jobQueryRec_begin, len, - &XMLCtx->job_conditions); - } - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - - -static void endQuerySequenceCodeRequest(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"jobId")) { - XMLCtx->jobId = edg_wll_from_string_to_jobid(XMLCtx); - } - else if (!strcmp(XMLCtx->element,"source")) { - XMLCtx->source = edg_wll_from_string_to_string(XMLCtx); - } - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - - - -int parseJobQueryRec(edg_wll_Context ctx, const char *messageBody, long len, edg_wll_QueryRec ***conditions) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.row = -1; - XMLCtx.ctx = ctx; - edg_wll_ResetError(ctx); - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startJobQueryRec, endJobQueryRec); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, len, 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) { - int i,j; - - if (XMLCtx.job_conditions) { - for (j = 0; XMLCtx.job_conditions[j]; j++) { - for (i = 0; (XMLCtx.job_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&XMLCtx.job_conditions[j][i]); - free(XMLCtx.job_conditions[j]); - } - free(XMLCtx.job_conditions); - } - - /* empty list terminators */ - conditions[0] = NULL; - } else { - *conditions = XMLCtx.job_conditions; - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - - -/* parse queryJobs request from client */ -int parseQueryJobsRequest(edg_wll_Context ctx, char *messageBody, edg_wll_QueryRec ***conditions, int *flags) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - XMLCtx.message_body = messageBody; - XMLCtx.position = 0; - edg_wll_ResetError(ctx); - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startQueryJobsRequest, endQueryJobsRequest); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) { - int i,j; - - if (XMLCtx.job_conditions) { - for (j = 0; XMLCtx.job_conditions[j]; j++) { - for (i = 0; (XMLCtx.job_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&XMLCtx.job_conditions[j][i]); - free(XMLCtx.job_conditions[j]); - } - free(XMLCtx.job_conditions); - } - - /* empty list terminators */ - conditions[0] = NULL; - *flags = 0; - } else { - *conditions = XMLCtx.job_conditions; - *flags = XMLCtx.flags; - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - - -/* parse queryEvents request from client */ -int parseQueryEventsRequest(edg_wll_Context ctx, char *messageBody, edg_wll_QueryRec ***job_conditions, edg_wll_QueryRec ***event_conditions) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.row = -1; - XMLCtx.row2 = -1; - XMLCtx.ctx = ctx; - edg_wll_ResetError(ctx); - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startQueryEventsRequest, endQueryEventsRequest); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) { - int i,j; - - if (XMLCtx.job_conditions) { - for (j = 0; XMLCtx.job_conditions[j]; j++) { - for (i = 0 ; (XMLCtx.job_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&XMLCtx.job_conditions[j][i]); - free(XMLCtx.job_conditions[j]); - } - free(XMLCtx.job_conditions); - } - if (XMLCtx.event_conditions) { - for (j = 0; XMLCtx.event_conditions[j]; j++) { - for (i = 0 ; (XMLCtx.event_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&XMLCtx.event_conditions[j][i]); - free(XMLCtx.event_conditions[j]); - } - free(XMLCtx.event_conditions); - } - - /* empty list terminators */ - job_conditions[0] = NULL; - event_conditions[0] = NULL; - } else { - *job_conditions = XMLCtx.job_conditions; - *event_conditions = XMLCtx.event_conditions; - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - - - -/* parse purge request from client */ -int parsePurgeRequest(edg_wll_Context ctx, char *messageBody, int (*tagToIndex)(), edg_wll_PurgeRequest *request) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - edg_wll_ResetError(ctx); - XMLCtx.tagToIndex = tagToIndex; - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startPurgeRequest, endPurgeRequest); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) { - int i; - - if (XMLCtx.purgeRequestGlobal.jobs) { - for (i=0; XMLCtx.purgeRequestGlobal.jobs[i]; i++) - free(XMLCtx.purgeRequestGlobal.jobs[i]); - free(XMLCtx.purgeRequestGlobal.jobs); - } - memset(request,0,sizeof(*request)); - - } else { - memcpy(request, &XMLCtx.purgeRequestGlobal, sizeof(XMLCtx.purgeRequestGlobal)); - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - - - -/* parse dump request from client */ -int parseDumpRequest(edg_wll_Context ctx, char *messageBody, edg_wll_DumpRequest *request) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - edg_wll_ResetError(ctx); - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startDumpRequest, endDumpRequest); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) - memset(request,0,sizeof(*request)); - - else { - memcpy(request, &XMLCtx.dumpRequestGlobal, sizeof(XMLCtx.dumpRequestGlobal)); - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - -/* parse load request from client */ -int parseLoadRequest(edg_wll_Context ctx, char *messageBody, edg_wll_LoadRequest *request) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - edg_wll_ResetError(ctx); - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startLoadRequest, endLoadRequest); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) - memset(request,0,sizeof(*request)); - - else { - memcpy(request, &XMLCtx.loadRequestGlobal, sizeof(XMLCtx.loadRequestGlobal)); - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - - - -/* parse Notif request from client */ -int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, edg_wll_NotifId *notifId, char **address, edg_wll_NotifChangeOp *op, edg_wll_QueryRec ***conditions) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - - /* returns emty variables as default; only some variables will be filled in */ - /* depending on vaule of XMLCtx.notifFunction */ - *function = NULL; - *notifId = NULL; - *address = NULL; - *op = EDG_WLL_NOTIF_NOOP; - *conditions = NULL; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - XMLCtx.message_body = messageBody; - edg_wll_ResetError(ctx); - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startNotifRequest, endNotifRequest); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) { - int i,j; - - if (XMLCtx.job_conditions) { - for (j = 0; XMLCtx.job_conditions[j]; j++) { - for (i = 0; (XMLCtx.job_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&XMLCtx.job_conditions[j][i]); - free(XMLCtx.job_conditions[j]); - } - free(XMLCtx.job_conditions); - } - free(XMLCtx.notifFunction); - edg_wll_NotifIdFree(&XMLCtx.notifId); - free(XMLCtx.notifClientAddress); - - *function = NULL; - *notifId = NULL; - *address = NULL; - *op = EDG_WLL_NOTIF_NOOP; - *conditions = NULL; - } else { - *function = XMLCtx.notifFunction; - *notifId = XMLCtx.notifId; - *address = XMLCtx.notifClientAddress; - *op = XMLCtx.notifChangeOp; - *conditions = XMLCtx.job_conditions; - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - - - -/* parse Sequence Code request from client */ -int parseQuerySequenceCodeRequest(edg_wll_Context ctx, char *messageBody, edg_wlc_JobId *jobId, char **source) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - edg_wll_ResetError(ctx); - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startQuerySequenceCodeRequest, endQuerySequenceCodeRequest); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) { - if (XMLCtx.jobId) - edg_wlc_JobIdFree(XMLCtx.jobId); - - *jobId = NULL; - *source = NULL; - } - else { - *jobId = XMLCtx.jobId; - *source = XMLCtx.source; - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - - - - -int edg_wll_QueryEventsToXML(edg_wll_Context ctx, edg_wll_Event *eventsOut, char **message) -{ - char *pomA, *pomB; - char **list = NULL; - int i = 0, len, tot_len = 0; - int *len_list = NULL; - - - while (eventsOut && eventsOut[i].any.type != EDG_WLL_EVENT_UNDEF) { - pomB = edg_wll_EventToString(eventsOut[i].any.type); - trio_asprintf(&pomA," \r\n", pomB); - free(pomB); - pomB = pomA; - - -@@@{ - selectType $event '_common_'; - for (getFieldsOrdered $event) { - my $f = selectField $event $_; - my $ft = $f->{type}; - my $n = $f->{null}; - gen "\tedg_wll_add_$ft\_to_XMLBody(&pomB, eventsOut[i].any.$_, \"$_\", $n);\n"; - } - - gen "\tswitch (eventsOut[i].any.type) {\n"; - for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } getTypes $event) { - if ($t ne 'any') { - selectType $event $t; - my $u = uc $t; - gen "\t case EDG_WLL_EVENT_$u :\n"; - for (getFieldsOrdered $event) { - my $f = selectField $event $_; - my $ft = $f->{type}; - my $n = $f->{null}; - $t = lcfirst $t; - gen "\t\tedg_wll_add_$ft\_to_XMLBody(&pomB, eventsOut[i].$t.$_, \"$_\", $n);\n"; - } - gen "\t\tbreak;\n"; - } - } - gen "\t default : break;\n"; - gen "\t}\n"; -@@@} - - - - len = asprintf(&pomA,"%s \r\n", pomB); - free(pomB); - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* test errors */ - if (ctx->errDesc || ctx->errCode) - len = trio_asprintf(&pomB," code=\"%d\" desc=\"%|Xs\">\r\n",ctx->errCode,ctx->errDesc); - else - len = asprintf(&pomB,">\r\n"); - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + - sizeof(QUERY_EVENTS_BEGIN) + len + sizeof(QUERY_EVENTS_END) - 1); - - memcpy(pomA, QUERY_EVENTS_BEGIN, sizeof(QUERY_EVENTS_BEGIN)); - memcpy(pomA + sizeof(QUERY_EVENTS_BEGIN) - 1, pomB, len); - free(pomB); - pomB = pomA + sizeof(QUERY_EVENTS_BEGIN) + len - 1; - - i = 0; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - - strcpy(pomB, QUERY_EVENTS_END); - - - free(list); - free(len_list); - - - *message = pomA; - - return 0; -} - -int edg_wll_QueryJobsToXML(edg_wll_Context ctx, edg_wlc_JobId *jobsIn, edg_wll_JobStat *statesIn, char **message) -{ - char *pomA, *pomB, *pomC; - char **list = NULL; - int i = 0, len, tot_len = 0, nres = 0; - int *len_list = NULL; - - - if (jobsIn) for (nres = 0; jobsIn[nres]; nres++); - else if (statesIn) for (nres = 0; statesIn[nres].state; nres++); - - while (i < nres) { - trio_asprintf(&pomA,"\t\r\n"); - pomB = pomA; - - if (jobsIn) { - trio_asprintf(&pomA,"%s\t\t%|Xs\r\n", - pomB, pomC=edg_wlc_JobIdUnparse(jobsIn[i])); - free(pomC); - free(pomB); - pomB = pomA; - } - - if (statesIn) { - edg_wll_JobStatusToXML(ctx, statesIn[i], &pomC); - trio_asprintf(&pomA,"%s\t\t%s",pomB,pomC); - } - else { - pomC = edg_wll_StatToString(EDG_WLL_JOB_UNKNOWN); - trio_asprintf(&pomA,"%s\t\t\r\n\r\n\t\t\r\n", - pomB, pomC); - } - - free(pomB); - free(pomC); - pomB = pomA; - - - len = asprintf(&pomA,"%s\t\r\n", pomB); - free(pomB); - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* test errors */ - if (ctx->errDesc || ctx->errCode) - len = trio_asprintf(&pomB," code=\"%d\" desc=\"%|Xs\">\r\n",ctx->errCode,ctx->errDesc); - else - len = asprintf(&pomB,">\r\n"); - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + - sizeof(QUERY_JOBS_BEGIN) + len + sizeof(QUERY_JOBS_END) - 1); - - memcpy(pomA, QUERY_JOBS_BEGIN, sizeof(QUERY_JOBS_BEGIN)); - memcpy((pomA + sizeof(QUERY_JOBS_BEGIN) - 1), pomB, len); - free(pomB); - pomB = pomA + sizeof(QUERY_JOBS_BEGIN) + len - 1; - - i = 0; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - - strcpy(pomB, QUERY_JOBS_END); - - - free(list); - free(len_list); - - - *message = pomA; - - return 0; -} - -/* construct Message-Body of Response-Line for edg_wll_UserJobs */ -int edg_wll_UserJobsToXML(edg_wll_Context ctx, edg_wlc_JobId *jobsOut, char **message) -{ - char *pomA, *pomB; - char **list = NULL; - int i = 0, len, tot_len = 0; - int *len_list = NULL; - - - while (jobsOut[i]) { - len = trio_asprintf(&pomA," %|Xs\r\n", - pomB=edg_wlc_JobIdUnparse(jobsOut[i])); - - free(pomB); - - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - pomA = NULL; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* test errors */ - if (ctx->errDesc || ctx->errCode) - len = trio_asprintf(&pomB," code=\"%d\" desc=\"%|Xs\">\r\n",ctx->errCode,ctx->errDesc); - else - len = asprintf(&pomB,">\r\n"); - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + - sizeof(USERJOBS_BEGIN) + len + sizeof(USERJOBS_END) - 1); - - memcpy(pomA, USERJOBS_BEGIN, sizeof(USERJOBS_BEGIN)); - memcpy((pomA + sizeof(USERJOBS_BEGIN) - 1), pomB, len); - free(pomB); - pomB = pomA + sizeof(USERJOBS_BEGIN) + len - 1; - - i = 0; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - - strcpy(pomB, USERJOBS_END); - - - free(list); - free(len_list); - - - *message = pomA; - - return 0; -} - -static void edg_wll_add_stslist_to_XMLBody(edg_wll_Context ctx, char **body, const edg_wll_JobStat *toAdd, const char *tag, const char *UNUSED_subTag, const int null) -{ - char *pomA, *pomB, *newBody; - char **list = NULL; - int i = 0, len, tot_len = 0; - int *len_list = NULL; - - - while (toAdd[i].state != null) { - edg_wll_JobStatusToXML(ctx, toAdd[i], &pomA); - len = strlen(pomA); - - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - pomA = NULL; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + 1); - pomB = pomA; - - i = 0; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - *pomB = '\0'; - free(list); - free(len_list); - - asprintf(&newBody,"%s\t\t\t<%s>\r\n%s\t\t\t\r\n", *body, tag, pomA, tag); - free(*body); - free(pomA); - *body = newBody; -} - - - -/* construct Message-Body of Response-Line for edg_wll_JobStatus */ -int edg_wll_JobStatusToXML(edg_wll_Context ctx, edg_wll_JobStat stat, char **message) -{ - char *pomA, *pomB, *pomC; - - - pomB = strdup(""); - -@@@{ - selectType $status '_common_'; - for (getFieldsOrdered $status) { - my $f = selectField $status $_; - next if defined($f->{special}) && $f->{special} eq 'XMLstructured'; - my $ft = $f->{type}; - my $n = $f->{null}; - gen "edg_wll_add_$ft\_to_XMLBody(&pomB, stat.$_, \"$_\", $n);\n"; - } -@@@} - if (stat.children) edg_wll_add_strlist_to_XMLBody(&pomB, stat.children, "children", "jobId", "\t\t\t", NULL); - if (stat.children_hist) edg_wll_add_intlist_to_XMLBody(&pomB, stat.children_hist, "children_hist", edg_wll_StatToString, "\t\t\t", 1, stat.children_hist[0]); - if (stat.children_states) edg_wll_add_stslist_to_XMLBody(ctx, &pomB, stat.children_states, "children_states", "", EDG_WLL_JOB_UNDEF); - if (stat.user_tags) edg_wll_add_taglist_to_XMLBody(&pomB, stat.user_tags, "user_tags", "tag", "name", "\t\t\t", NULL); - if (stat.stateEnterTimes) edg_wll_add_intlist_to_XMLBody(&pomB, stat.stateEnterTimes, "stateEnterTimes", edg_wll_StatToString, "\t\t\t",1, stat.stateEnterTimes[0]); - - pomC = edg_wll_StatToString(stat.state); - - if (ctx->errDesc || ctx->errCode) - trio_asprintf(&pomA,"\r\n%s", - pomC, ctx->errCode,ctx->errDesc, pomB); - else - trio_asprintf(&pomA,"\r\n%s", - pomC, pomB); - - free(pomB); - free(pomC); - - *message = pomA; - - return 0; -} - - - -/* construct Message-Body of Request-Line for edg_wll_Purge */ -int edg_wll_PurgeResultToXML( - edg_wll_Context ctx, - edg_wll_PurgeResult *result, - char **message) -{ - char *pomA, *pomB; - - - if (!result) { *message = NULL; return(-1); } - - pomA = strdup(""); - edg_wll_add_strlist_to_XMLBody(&pomA, result->jobs, "jobs", "jobId", "\t", NULL); - edg_wll_add_string_to_XMLBody(&pomA, result->server_file, "server_file", NULL); - - if (ctx->errDesc || ctx->errCode) - trio_asprintf(&pomB,"%s code=\"%d\" desc=\"%|Xs\">\r\n%s%s", - PURGE_RESULT_BEGIN, ctx->errCode, ctx->errDesc, pomA, PURGE_RESULT_END); - else - trio_asprintf(&pomB,"%s>\r\n%s%s", PURGE_RESULT_BEGIN, pomA, PURGE_RESULT_END); - free(pomA); - - *message = pomB; - return 0; -} - - - -/* construct Message-Body of Request-Line for edg_wll_Dump */ -int edg_wll_DumpResultToXML( - edg_wll_Context ctx, - edg_wll_DumpResult *result, - char **message) -{ - char *pomA, *pomB; - - - if (!result) { *message = NULL; return(-1); } - - pomA = strdup(""); - edg_wll_add_string_to_XMLBody(&pomA, result->server_file, "server_file", NULL); - if (result->from < 0) - edg_wll_add_string_to_XMLBody(&pomA, - edg_wll_DumpConstToString(result->from), "from", NULL); - else - edg_wll_add_time_t_to_XMLBody(&pomA, result->from, "from", 0); - if (result->to < 0) - edg_wll_add_string_to_XMLBody(&pomA, - edg_wll_DumpConstToString(result->to), "to", NULL); - else - edg_wll_add_time_t_to_XMLBody(&pomA, result->to, "to", 0); - - if (ctx->errDesc || ctx->errCode) - trio_asprintf(&pomB,"%s code=\"%d\" desc=\"%|Xs\">\r\n%s%s", - DUMP_RESULT_BEGIN, ctx->errCode, ctx->errDesc, pomA, DUMP_RESULT_END); - else - trio_asprintf(&pomB,"%s>\r\n%s%s", DUMP_RESULT_BEGIN, pomA, DUMP_RESULT_END); - free(pomA); - - *message = pomB; - return 0; -} - - -/* construct Message-Body of Request-Line for edg_wll_Load */ -int edg_wll_LoadResultToXML( - edg_wll_Context ctx, - edg_wll_LoadResult *result, - char **message) -{ - char *pomA, *pomB; - - - if (!result) { *message = NULL; return(-1); } - - pomA = strdup(""); - edg_wll_add_string_to_XMLBody(&pomA, result->server_file, "server_file", NULL); - edg_wll_add_time_t_to_XMLBody(&pomA, result->from, "from", 0); - edg_wll_add_time_t_to_XMLBody(&pomA, result->to, "to", 0); - - if (ctx->errDesc || ctx->errCode) - trio_asprintf(&pomB,"%s code=\"%d\" desc=\"%|Xs\">\r\n%s%s", - LOAD_RESULT_BEGIN, ctx->errCode, ctx->errDesc, pomA, LOAD_RESULT_END); - else - trio_asprintf(&pomB,"%s>\r\n%s%s", LOAD_RESULT_BEGIN, pomA, LOAD_RESULT_END); - free(pomA); - - *message = pomB; - return 0; -} - - -/* construct Message-Body of Request-Line for edg_wll_GetIndexedAttrs */ -int edg_wll_IndexedAttrsToXML( - edg_wll_Context ctx, - char **message) -{ - int i,j; - char *pomA, *pomB; - - pomA = strdup(""); - if (ctx->job_index) { - for (i=0; ctx->job_index[i]; i++) { - asprintf(&pomB, "%s\t%s\r\n",pomA,""); - free(pomA); - pomA = pomB; - - for (j=0; ctx->job_index[i][j].attr != EDG_WLL_QUERY_ATTR_UNDEF; j++) { - asprintf(&pomB, "%s\t\t%s\r\n",pomA,""); - free(pomA); - pomA = pomB; - - edg_wll_add_string_to_XMLBody(&pomA, - edg_wll_query_attrToString(ctx->job_index[i][j].attr), - "attribute", NULL); - - if (ctx->job_index[i][j].attr == EDG_WLL_QUERY_ATTR_TIME) - edg_wll_add_string_to_XMLBody(&pomA, - edg_wll_StatToString(ctx->job_index[i][j].attr_id.state), - "state", NULL); - - if (ctx->job_index[i][j].attr == EDG_WLL_QUERY_ATTR_USERTAG) - edg_wll_add_string_to_XMLBody(&pomA, - ctx->job_index[i][j].attr_id.tag, - "name", NULL); - - asprintf(&pomB, "%s\t\t%s\r\n",pomA,""); - free(pomA); - pomA = pomB; - } - - asprintf(&pomB, "%s\t%s\r\n",pomA,""); - free(pomA); - pomA = pomB; - } - } - - if (ctx->errDesc || ctx->errCode) - trio_asprintf(&pomB,"%s code=\"%d\" desc=\"%|Xs\">\r\n%s%s", - INDEXED_ATTRS_BEGIN, ctx->errCode, ctx->errDesc, pomA, INDEXED_ATTRS_END); - else - trio_asprintf(&pomB,"%s>\r\n%s%s", INDEXED_ATTRS_BEGIN, pomA, INDEXED_ATTRS_END); - free(pomA); - - - *message = pomB; - return 0; -} - - - -/* construct Message-Body of Request-Line for edg_wll_Notif */ -int edg_wll_NotifResultToXML( - edg_wll_Context ctx, - time_t validity, - char **message) -{ - char *pomA, *pomB; - - - pomA = strdup(""); - edg_wll_add_time_t_to_XMLBody(&pomA, validity, "validity", -1); - - if (ctx->errDesc || ctx->errCode) - trio_asprintf(&pomB,"%s code=\"%d\" desc=\"%|Xs\">\r\n%s%s", - NOTIF_RESULT_BEGIN, ctx->errCode, ctx->errDesc, pomA, NOTIF_RESULT_END); - else - trio_asprintf(&pomB,"%s>\r\n%s%s", NOTIF_RESULT_BEGIN, pomA, NOTIF_RESULT_END); - free(pomA); - - *message = pomB; - return 0; -} - - - -/* construct Message-Body of Request-Line for edg_wll_Notif */ -int edg_wll_QuerySequenceCodeResultToXML( - edg_wll_Context ctx, - char *seqCode, - char **message) -{ - char *pomA, *pomB; - - - pomA = strdup(""); - edg_wll_add_string_to_XMLBody(&pomA, seqCode, "sequence_code", NULL); - - if (ctx->errDesc || ctx->errCode) - trio_asprintf(&pomB,"%s code=\"%d\" desc=\"%|Xs\">\r\n%s%s", - QUERY_SEQUENCE_CODE_RESULT_BEGIN, ctx->errCode, - ctx->errDesc, pomA, QUERY_SEQUENCE_CODE_RESULT_END); - else - trio_asprintf(&pomB,"%s>\r\n%s%s", QUERY_SEQUENCE_CODE_RESULT_BEGIN, - pomA, QUERY_SEQUENCE_CODE_RESULT_END); - free(pomA); - - *message = pomB; - return 0; -} - - diff --git a/org.glite.lb.server/src/lb_xml_parse.h b/org.glite.lb.server/src/lb_xml_parse.h deleted file mode 100644 index 539223e..0000000 --- a/org.glite.lb.server/src/lb_xml_parse.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _LB_XML_PARSE_H -#define _LB_XML_PARSE_H - -#ident "$Header$" - -#include "glite/lb/consumer.h" -#include "glite/lb/notification.h" -#include "glite/lb/purge.h" -#include "glite/lb/dump.h" -#include "glite/lb/load.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* function for parsing/unparsing XML requests from client */ - -int parseJobQueryRec(edg_wll_Context ctx, const char *messageBody, long len, edg_wll_QueryRec ***conditions); -int parseQueryJobsRequest(edg_wll_Context ctx, char *messageBody, edg_wll_QueryRec ***conditions, int *flags); -int parseQueryEventsRequest(edg_wll_Context ctx, char *messageBody, edg_wll_QueryRec ***job_conditions, edg_wll_QueryRec ***event_conditions); -int parsePurgeRequest(edg_wll_Context ctx, char *messageBody, int (*tagToIndex)(), edg_wll_PurgeRequest *request); -int parseDumpRequest(edg_wll_Context ctx, char *messageBody, edg_wll_DumpRequest *request); -int parseLoadRequest(edg_wll_Context ctx, char *messageBody, edg_wll_LoadRequest *request); -int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, edg_wll_NotifId *notifId, char **address, edg_wll_NotifChangeOp *op, edg_wll_QueryRec ***conditions); -int parseQuerySequenceCodeRequest(edg_wll_Context ctx, char *messageBody, edg_wlc_JobId *jobId, char **source); -int edg_wll_QueryEventsToXML(edg_wll_Context, edg_wll_Event *, char **); -int edg_wll_QueryJobsToXML(edg_wll_Context, edg_wlc_JobId *, edg_wll_JobStat *, char **); -int edg_wll_JobStatusToXML(edg_wll_Context, edg_wll_JobStat, char **); -int edg_wll_UserJobsToXML(edg_wll_Context, edg_wlc_JobId *, char **); -int edg_wll_PurgeResultToXML(edg_wll_Context ctx, edg_wll_PurgeResult *result, char **message); -int edg_wll_DumpResultToXML(edg_wll_Context ctx, edg_wll_DumpResult *result, char **message); -int edg_wll_LoadResultToXML(edg_wll_Context ctx, edg_wll_LoadResult *result, char **message); -int edg_wll_IndexedAttrsToXML(edg_wll_Context ctx, char **message); -int edg_wll_NotifResultToXML(edg_wll_Context ctx, time_t validity, char **message); -int edg_wll_QuerySequenceCodeResultToXML(edg_wll_Context ctx, char *source, char **message); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/org.glite.lb.server/src/lb_xml_parse_V21.c.T b/org.glite.lb.server/src/lb_xml_parse_V21.c.T deleted file mode 100644 index c3e3233..0000000 --- a/org.glite.lb.server/src/lb_xml_parse_V21.c.T +++ /dev/null @@ -1,1239 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" - -#include "glite/lb/consumer.h" -#include "glite/lb/escape.h" -#include "glite/lb/context-int.h" -#include "glite/lb/trio.h" -#include "glite/lb/xml_conversions.h" - -#include "glite/lb/purge.h" -#include "glite/lb/dump.h" - -#include "lb_xml_parse_V21.h" - -#ifdef __GNUC__ -#define UNUSED_VAR __attribute__((unused)) -#else -#define UNUSED_VAR -#endif - -#define QUERY_EVENTS_BEGIN "\r\n" -#define QUERY_JOBS_BEGIN "\r\n" -#define PURGE_RESULT_BEGIN "\r\n" -#define DUMP_RESULT_BEGIN "\r\n" - -// XXX will be redundant soon -#define USERJOBS_BEGIN "\r\n" - - -static char *ops[] = { "equal","less","greater","within" }, - *attrs[] = { "jobid","owner","status","location","destination", - "donecode","usertag","time","level","host","source", - "instance","type","chkpt_tag", "resubmitted", "parent_job", "exitcode" }; - -static const struct timeval null_timeval = {0,0}; - -#define unexp() {\ - char *e;\ -\ - if (XMLCtx->errtxt) {\ - asprintf(&e,"%s\nunexpected <%s> at line %d",XMLCtx->errtxt,\ - el,XML_GetCurrentLineNumber(XMLCtx->p));\ - free(XMLCtx->errtxt);\ - } else asprintf(&e,"unexpected <%s> at line %d",\ - el,XML_GetCurrentLineNumber(XMLCtx->p));\ - XMLCtx->errtxt = e;\ -} - - -/* Dummy function, returns only const string "el"; just for compatibility */ -static char *return_string_el(edg_wll_JobStatCode statCode) { - return("el"); -} - - -static void startQueryJobsRequest(void *data, const char *el, const char **attr) -{ - unsigned int i; - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_QueryJobsRequest")) { unexp() break; } - for ( i = 0; attr[i] && attr[i+1]; i += 2 ) - { - if ( !strcmp(attr[i],"softLimit") ) - XMLCtx->ctx->softLimit = atoi(attr[i+1]); - else if ( !strcmp(attr[i],"queryRes") ) - XMLCtx->ctx->p_query_results = atoi(attr[i+1]); - else { unexp() break; } - } - break; - case 1: if (strcasecmp(el,"and") && strcasecmp(el,"flags")) unexp() - break; - case 2: if (strcasecmp(el,"or")) unexp() - else { - XMLCtx->position = -1; - XMLCtx->conditions = realloc(XMLCtx->conditions, - (++XMLCtx->row+2)*sizeof(*XMLCtx->conditions)); - XMLCtx->conditions[XMLCtx->row] = NULL; - XMLCtx->conditions[XMLCtx->row+1] = NULL; - } - break; - case 3: - for (i=0; iconditions[XMLCtx->row] = realloc(XMLCtx->conditions[XMLCtx->row], - (++XMLCtx->position+2)*sizeof(**XMLCtx->conditions)); - memset(&XMLCtx->conditions[XMLCtx->row][XMLCtx->position],0,2*sizeof(**XMLCtx->conditions)); - XMLCtx->conditions[XMLCtx->row][XMLCtx->position].op = i; - XMLCtx->bound = 0; - } - break; - case 4: for (i=0; iconditions[XMLCtx->row][XMLCtx->position].attr_id.tag = strdup(attr[1]); - } - else if ( (i+1) == EDG_WLL_QUERY_ATTR_TIME) { - if (!attr[0] || !attr[1]) { unexp() break;} - if (attr[0] && strcmp(attr[0],"state")) { unexp() break;} - XMLCtx->conditions[XMLCtx->row][XMLCtx->position].attr_id.state = edg_wll_StringToStat(attr[1]); - } - XMLCtx->conditions[XMLCtx->row][XMLCtx->position].attr = i+1; - } - break; - default: unexp(); break; - } - XMLCtx->level++; -} - - -static void startQueryEventsRequest(void *data, const char *el, const char **attr UNUSED_VAR) -{ - unsigned int i; - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_QueryEventsRequest")) { unexp() break; } - for ( i = 0; attr[i] && attr[i+1]; i += 2 ) - { - if ( !strcmp(attr[i],"softLimit") ) - XMLCtx->ctx->softLimit = atoi(attr[i+1]); - else if ( !strcmp(attr[i],"queryRes") ) - XMLCtx->ctx->p_query_results = atoi(attr[i+1]); - else { unexp() break; } - } - break; - case 1: if (strcasecmp(el,"and")) unexp() - break; - case 2: if (!strcasecmp(el,"orJobConditions")) { - XMLCtx->type = EDG_WLL_QUERY_TYPE_JOB_CONDITION; - XMLCtx->position = -1; - XMLCtx->job_conditions = realloc(XMLCtx->job_conditions, - (++XMLCtx->row+2)*sizeof(*XMLCtx->job_conditions)); - XMLCtx->job_conditions[XMLCtx->row] = NULL; - XMLCtx->job_conditions[XMLCtx->row+1] = NULL; - - } - else if (!strcasecmp(el,"orEventConditions")) { - XMLCtx->type = EDG_WLL_QUERY_TYPE_EVENT_CONDITION; - XMLCtx->position2 = -1; - XMLCtx->event_conditions = realloc(XMLCtx->event_conditions, - (++XMLCtx->row2+2)*sizeof(*XMLCtx->event_conditions)); - XMLCtx->event_conditions[XMLCtx->row2] = NULL; - XMLCtx->event_conditions[XMLCtx->row2+1] = NULL; - } - else unexp() - break; - case 3: - for (i=0; itype == EDG_WLL_QUERY_TYPE_JOB_CONDITION) { - /* malloc also terminator and set it to 0 (= EDG_WLL_QUERY_ATTR_UNDEF) */ - XMLCtx->job_conditions[XMLCtx->row] = realloc(XMLCtx->job_conditions[XMLCtx->row], - (++XMLCtx->position+2)*sizeof(**XMLCtx->job_conditions)); - memset(&XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position],0,2*sizeof(**XMLCtx->job_conditions)); - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].op = i; - XMLCtx->bound = 0; - } - else if (XMLCtx->type == EDG_WLL_QUERY_TYPE_EVENT_CONDITION) { - /* malloc also terminator and set it to 0 (= EDG_WLL_QUERY_ATTR_UNDEF) */ - XMLCtx->event_conditions[XMLCtx->row2] = realloc(XMLCtx->event_conditions[XMLCtx->row2], - (++XMLCtx->position2+2)*sizeof(**XMLCtx->event_conditions)); - memset(&XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2],0,2*sizeof(**XMLCtx->event_conditions)); - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].op = i; - XMLCtx->bound = 0; - } - - break; - case 4: for (i=0; itype == EDG_WLL_QUERY_TYPE_JOB_CONDITION) { - if ( (i+1) == EDG_WLL_QUERY_ATTR_USERTAG) { - if (!attr[0] || !attr[1]) { unexp() break;} - if (attr[0] && strcmp(attr[0],"name")) { unexp() break;} - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.tag = strdup(attr[1]); - } - else if ( (i+1) == EDG_WLL_QUERY_ATTR_TIME) { - if (!attr[0] || !attr[1]) { unexp() break;} - if (attr[0] && strcmp(attr[0],"state")) { unexp() break;} - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.state = edg_wll_StringToStat(attr[1]); - printf("\nchecking time attr\n%s = %s (%d)\n\n", attr[0], attr[1], edg_wll_StringToStat(attr[1])); - } - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr = i+1; - } - else if (XMLCtx->type == EDG_WLL_QUERY_TYPE_EVENT_CONDITION) { - if ( (i+1) == EDG_WLL_QUERY_ATTR_USERTAG) { - if (!attr[0] || !attr[1]) { unexp() break;} - if (attr[0] && strcmp(attr[0],"name")) { unexp() break;} - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position].attr_id.tag = strdup(attr[1]); - } - else if ( (i+1) == EDG_WLL_QUERY_ATTR_TIME) { - if (!attr[0] || !attr[1]) { unexp() break;} - if (attr[0] && strcmp(attr[0],"state")) { unexp() break;} - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position].attr_id.state = edg_wll_StringToStat(attr[1]); - } - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].attr = i+1; - } - break; - default: unexp(); break; - } - XMLCtx->level++; -} - - - -static void startPurgeRequest(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_PurgeRequest")) unexp() - break; - case 1: if (strcasecmp(el,"jobs") && strcasecmp(el,"timeout") - && strcasecmp(el,"flags")) unexp() - else - XMLCtx->position = 0; - break; - case 2: if (!strcasecmp(el,"jobId")) { - XMLCtx->purgeRequestGlobal.jobs = realloc(XMLCtx->purgeRequestGlobal.jobs, - (XMLCtx->position+2) * sizeof(XMLCtx->purgeRequestGlobal.jobs)); - - if (!XMLCtx->purgeRequestGlobal.jobs) { - edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); - unexp() return; - } - XMLCtx->purgeRequestGlobal.jobs[XMLCtx->position+1] = NULL; - } - else if (!strcasecmp(el,"time")) { - /* static array, no need to initialize & allocate anything */ - } - else - unexp() - break; - default: unexp() - break; - } - XMLCtx->level++; -} - - -static void startDumpRequest(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_DumpRequest")) unexp() - break; - case 1: if (strcasecmp(el,"from") && strcasecmp(el,"to")) unexp() - break; - default: unexp() - break; - } - XMLCtx->level++; -} - -#undef unexp - - -static void char_handler(void *data, const char *s, int len) -{ - edg_wll_XML_ctx *XMLCtx = data; - int i, found = -1, temp_len1; - char *temp_s, *temp_s1; - - - /* if date are only spaces, t\, \r, \n ... don't bother with them */ - for (i=0; ichar_buf_len) XMLCtx->char_buf = - realloc(XMLCtx->char_buf,XMLCtx->char_buf_len+temp_len1 + 1); - else XMLCtx->char_buf = malloc(temp_len1 + 1); - - memcpy(XMLCtx->char_buf+XMLCtx->char_buf_len,temp_s1,temp_len1 + 1); - XMLCtx->char_buf_len += temp_len1; - free(temp_s1); - free(temp_s); -} - - - -static void endQueryJobsRequest(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - char *e; - - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"flags") && XMLCtx->char_buf) { -// XXX: check if it works - XMLCtx->flags = edg_wll_string_to_stat_flags(XMLCtx->char_buf); - } - } - else if (XMLCtx->level == 5) { - switch (XMLCtx->conditions[XMLCtx->row][XMLCtx->position].attr) { - case EDG_WLL_QUERY_ATTR_JOBID: - case EDG_WLL_QUERY_ATTR_PARENT: - if ( (XMLCtx->conditions[XMLCtx->row][XMLCtx->position].value.j = - edg_wll_from_string_to_jobid(XMLCtx)) == NULL ) - { - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid JobId at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid JobId at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - } - break; - case EDG_WLL_QUERY_ATTR_OWNER: - // XXX - this is way how to pass NULL, user will be extracted from ssl partner later - if (XMLCtx->char_buf != NULL && !strcmp(XMLCtx->char_buf,"NULL")) { - XMLCtx->conditions[XMLCtx->row][XMLCtx->position].value.c = NULL; - break; - } - else /* fall through */ - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_DESTINATION: - case EDG_WLL_QUERY_ATTR_USERTAG: - XMLCtx->conditions[XMLCtx->row][XMLCtx->position].value.c = - edg_wll_from_string_to_string(XMLCtx); - break; - case EDG_WLL_QUERY_ATTR_STATUS: - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_EXITCODE: - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - if ( !XMLCtx->bound ) - { - XMLCtx->conditions[XMLCtx->row][XMLCtx->position].value.i = - edg_wll_from_string_to_int(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->conditions[XMLCtx->row][XMLCtx->position].value2.i = - edg_wll_from_string_to_int(XMLCtx); - - break; - case EDG_WLL_QUERY_ATTR_TIME: - if ( !XMLCtx->bound ) - { - XMLCtx->conditions[XMLCtx->row][XMLCtx->position].value.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->conditions[XMLCtx->row][XMLCtx->position].value2.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - break; - default: - edg_wll_freeBuf(XMLCtx); - XMLCtx->level--; - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid attribute type at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid attribute type at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - break; - } - } - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - -static void endQueryEventsRequest(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - char *e; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"orJobConditions")) { - /* make end-of-row */ - XMLCtx->job_conditions[XMLCtx->row] = realloc(XMLCtx->job_conditions[XMLCtx->row], - (++XMLCtx->position+1)*sizeof(**XMLCtx->job_conditions)); - memset(&XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position],0,sizeof(**XMLCtx->job_conditions)); - } - else if (!strcmp(XMLCtx->element,"orEventConditions")) { - /* make end-of-row */ - XMLCtx->event_conditions[XMLCtx->row2] = realloc(XMLCtx->event_conditions[XMLCtx->row2], - (++XMLCtx->position2+1)*sizeof(**XMLCtx->event_conditions)); - memset(&XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2],0,sizeof(**XMLCtx->event_conditions)); - } - } - else if (XMLCtx->level == 5) { - if (XMLCtx->type == EDG_WLL_QUERY_TYPE_JOB_CONDITION) { - switch (XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr) { - case EDG_WLL_QUERY_ATTR_JOBID: - case EDG_WLL_QUERY_ATTR_PARENT: - if ( (XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.j = - edg_wll_from_string_to_jobid(XMLCtx)) == NULL ) - { - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid JobId at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid JobId at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - } - break; - case EDG_WLL_QUERY_ATTR_OWNER: - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_DESTINATION: - case EDG_WLL_QUERY_ATTR_USERTAG: - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.c = - edg_wll_from_string_to_string(XMLCtx); - break; - case EDG_WLL_QUERY_ATTR_STATUS: - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_EXITCODE: - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - if ( !XMLCtx->bound ) - { - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.i = - edg_wll_from_string_to_int(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value2.i = - edg_wll_from_string_to_int(XMLCtx); - break; - case EDG_WLL_QUERY_ATTR_TIME: - if ( !XMLCtx->bound ) - { - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value2.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - break; - default: - edg_wll_freeBuf(XMLCtx); - XMLCtx->level--; - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid attribute type at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid attribute type at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - break; - } - } - else if (XMLCtx->type == EDG_WLL_QUERY_TYPE_EVENT_CONDITION) { - switch (XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].attr) { - case EDG_WLL_QUERY_ATTR_TIME: - if ( !XMLCtx->bound ) - { - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].value.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].value2.t.tv_sec = - edg_wll_from_string_to_time_t(XMLCtx); - break; - case EDG_WLL_QUERY_ATTR_LEVEL: - case EDG_WLL_QUERY_ATTR_SOURCE: - case EDG_WLL_QUERY_ATTR_EVENT_TYPE: - if ( !XMLCtx->bound ) - { - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].value.i = - edg_wll_from_string_to_int(XMLCtx); - XMLCtx->bound++; - } - else - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].value2.i = - edg_wll_from_string_to_int(XMLCtx); - break; - case EDG_WLL_QUERY_ATTR_HOST: - case EDG_WLL_QUERY_ATTR_INSTANCE: - case EDG_WLL_QUERY_ATTR_USERTAG: - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].value.c = - edg_wll_from_string_to_string(XMLCtx); - break; - default: - edg_wll_freeBuf(XMLCtx); - XMLCtx->level--; - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid attribute type at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid attribute type at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - break; - } - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - } - XMLCtx->level--; -} - - -static void endPurgeRequest(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - char *e; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"flags")) - XMLCtx->purgeRequestGlobal.flags = edg_wll_from_string_to_int(XMLCtx); - } - else if (XMLCtx->level == 3) { - if (!strcmp(XMLCtx->element,"jobId")) { - if ( (XMLCtx->purgeRequestGlobal.jobs[XMLCtx->position++] = - edg_wll_from_string_to_string(XMLCtx)) == NULL ) - { - if (XMLCtx->errtxt) { - asprintf(&e,"%s\n%s: invalid JobId at line %d", - XMLCtx->errtxt, XMLCtx->char_buf, - XML_GetCurrentLineNumber(XMLCtx->p)); - free(XMLCtx->errtxt); - } else asprintf(&e,"%s: invalid JobId at line %d", - XMLCtx->char_buf,XML_GetCurrentLineNumber(XMLCtx->p)); - XMLCtx->errtxt = e; - } - } - else if (!strcmp(XMLCtx->element,"time") && XMLCtx->char_buf) { - XMLCtx->purgeRequestGlobal.timeout[XMLCtx->position++] = - edg_wll_from_string_to_time_t(XMLCtx); - } - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - -static void endDumpRequest(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"from")) - XMLCtx->dumpRequestGlobal.from = edg_wll_from_string_to_time_t(XMLCtx); - else if (!strcmp(XMLCtx->element,"to")) - XMLCtx->dumpRequestGlobal.to = edg_wll_from_string_to_time_t(XMLCtx); - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - -/* parse queryJobs request from client */ -int parseQueryJobsRequestV21(edg_wll_Context ctx, char *messageBody, edg_wll_QueryRec ***conditions, int *flags) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.row = -1; - XMLCtx.ctx = ctx; - edg_wll_ResetError(ctx); - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startQueryJobsRequest, endQueryJobsRequest); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) { - int i,j; - - if (XMLCtx.conditions) { - for (j = 0; XMLCtx.conditions[j]; j++) { - for (i = 0; (XMLCtx.conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&XMLCtx.conditions[j][i]); - free(XMLCtx.conditions[j]); - } - free(XMLCtx.conditions); - } - - /* empty list terminators */ - conditions[0] = NULL; - *flags = 0; - } else { - *conditions = XMLCtx.conditions; - *flags = XMLCtx.flags; - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - - -/* parse queryEvents request from client */ -int parseQueryEventsRequestV21(edg_wll_Context ctx, char *messageBody, edg_wll_QueryRec ***job_conditions, edg_wll_QueryRec ***event_conditions) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.row = -1; - XMLCtx.row2 = -1; - XMLCtx.ctx = ctx; - edg_wll_ResetError(ctx); - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startQueryEventsRequest, endQueryEventsRequest); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) { - int i,j; - - if (XMLCtx.job_conditions) { - for (j = 0; XMLCtx.job_conditions[j]; j++) { - for (i = 0 ; (XMLCtx.job_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&XMLCtx.job_conditions[j][i]); - free(XMLCtx.job_conditions[j]); - } - free(XMLCtx.job_conditions); - } - if (XMLCtx.event_conditions) { - for (j = 0; XMLCtx.event_conditions[j]; j++) { - for (i = 0 ; (XMLCtx.event_conditions[j][i].attr != EDG_WLL_QUERY_ATTR_UNDEF); i++ ) - edg_wll_QueryRecFree(&XMLCtx.event_conditions[j][i]); - free(XMLCtx.event_conditions[j]); - } - free(XMLCtx.event_conditions); - } - - /* empty list terminators */ - job_conditions[0] = NULL; - event_conditions[0] = NULL; - } else { - *job_conditions = XMLCtx.job_conditions; - *event_conditions = XMLCtx.event_conditions; - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - - - -/* parse purge request from client */ -int parsePurgeRequestV21(edg_wll_Context ctx, char *messageBody, edg_wll_PurgeRequest *request) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - edg_wll_ResetError(ctx); - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startPurgeRequest, endPurgeRequest); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) { - int i; - - if (XMLCtx.purgeRequestGlobal.jobs) { - for (i=0; XMLCtx.purgeRequestGlobal.jobs[i]; i++) - free(XMLCtx.purgeRequestGlobal.jobs[i]); - free(XMLCtx.purgeRequestGlobal.jobs); - } - memset(request,0,sizeof(*request)); - - } else { - memcpy(request, &XMLCtx.purgeRequestGlobal, sizeof(XMLCtx.purgeRequestGlobal)); - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - - - -/* parse dump request from client */ -int parseDumpRequestV21(edg_wll_Context ctx, char *messageBody, edg_wll_DumpRequest *request) -{ - int ret; - edg_wll_XML_ctx XMLCtx; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - edg_wll_ResetError(ctx); - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startDumpRequest, endDumpRequest); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((ret = edg_wll_Error(ctx,NULL,NULL))) - memset(request,0,sizeof(*request)); - - else { - memcpy(request, &XMLCtx.dumpRequestGlobal, sizeof(XMLCtx.dumpRequestGlobal)); - } - - - XML_ParserFree(XMLCtx.p); - edg_wll_freeXMLCtx(&XMLCtx); - return ret; -} - - - -int edg_wll_QueryEventsToXMLV21(edg_wll_Context ctx UNUSED_VAR, edg_wll_Event *eventsOut, char **message) -{ - char *pomA, *pomB; - char **list = NULL; - int i = 0, len, tot_len = 0; - int *len_list = NULL; - - - while (eventsOut && eventsOut[i].any.type != EDG_WLL_EVENT_UNDEF) { - pomB = edg_wll_EventToString(eventsOut[i].any.type); - trio_asprintf(&pomA," \r\n", pomB); - free(pomB); - pomB = pomA; - - -@@@{ - selectType $event '_common_'; - for (getFieldsOrdered $event) { - my $f = selectField $event $_; - my $ft = $f->{type}; - my $n = $f->{null}; - gen "\tedg_wll_add_$ft\_to_XMLBody(&pomB, eventsOut[i].any.$_, \"$_\", $n);\n"; - } - - gen "\tswitch (eventsOut[i].any.type) {\n"; - for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } getTypes $event) { - if ($t ne 'any') { - selectType $event $t; - my $u = uc $t; - gen "\t case EDG_WLL_EVENT_$u :\n"; - for (getFieldsOrdered $event) { - my $f = selectField $event $_; - my $ft = $f->{type}; - my $n = $f->{null}; - $t = lcfirst $t; - gen "\t\tedg_wll_add_$ft\_to_XMLBody(&pomB, eventsOut[i].$t.$_, \"$_\", $n);\n"; - } - gen "\t\tbreak;\n"; - } - } - gen "\t default : break;\n"; - gen "\t}\n"; -@@@} - - - - len = asprintf(&pomA,"%s \r\n", pomB); - free(pomB); - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* test errors */ - if (ctx->errDesc || ctx->errCode) - len = trio_asprintf(&pomB," code=\"%d\" desc=\"%|Xs\">\r\n",ctx->errCode,ctx->errDesc); - else - len = asprintf(&pomB,">\r\n"); - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + - sizeof(QUERY_EVENTS_BEGIN) + len + sizeof(QUERY_EVENTS_END) - 1); - - memcpy(pomA, QUERY_EVENTS_BEGIN, sizeof(QUERY_EVENTS_BEGIN)); - memcpy(pomA + sizeof(QUERY_EVENTS_BEGIN) - 1, pomB, len); - free(pomB); - pomB = pomA + sizeof(QUERY_EVENTS_BEGIN) + len - 1; - - i = 0; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - - strcpy(pomB, QUERY_EVENTS_END); - - - free(list); - free(len_list); - - - *message = pomA; - - return 0; -} - -int edg_wll_QueryJobsToXMLV21(edg_wll_Context ctx, edg_wlc_JobId *jobsIn, edg_wll_JobStat *statesIn, char **message) -{ - char *pomA, *pomB, *pomC; - char **list = NULL; - int i = 0, len, tot_len = 0, nres = 0; - int *len_list = NULL; - - - if (jobsIn) for (nres = 0; jobsIn[nres]; nres++); - else if (statesIn) for (nres = 0; statesIn[nres].state; nres++); - - while (i < nres) { - trio_asprintf(&pomA,"\t\r\n"); - pomB = pomA; - - if (jobsIn) { - trio_asprintf(&pomA,"%s\t\t%|Xs\r\n", - pomB, pomC=edg_wlc_JobIdUnparse(jobsIn[i])); - free(pomC); - free(pomB); - pomB = pomA; - } - - if (statesIn) { - edg_wll_JobStatusToXMLV21(ctx, statesIn[i], &pomC); - trio_asprintf(&pomA,"%s\t\t%s",pomB,pomC); - } - else { - pomC = edg_wll_StatToString(EDG_WLL_JOB_UNKNOWN); - trio_asprintf(&pomA,"%s\t\t\r\n\r\n\t\t\r\n", - pomB, pomC); - } - - free(pomB); - free(pomC); - pomB = pomA; - - - len = asprintf(&pomA,"%s\t\r\n", pomB); - free(pomB); - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* test errors */ - if (ctx->errDesc || ctx->errCode) - len = trio_asprintf(&pomB," code=\"%d\" desc=\"%|Xs\">\r\n",ctx->errCode,ctx->errDesc); - else - len = asprintf(&pomB,">\r\n"); - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + - sizeof(QUERY_JOBS_BEGIN) + len + sizeof(QUERY_JOBS_END) - 1); - - memcpy(pomA, QUERY_JOBS_BEGIN, sizeof(QUERY_JOBS_BEGIN)); - memcpy((pomA + sizeof(QUERY_JOBS_BEGIN) - 1), pomB, len); - free(pomB); - pomB = pomA + sizeof(QUERY_JOBS_BEGIN) + len - 1; - - i = 0; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - - strcpy(pomB, QUERY_JOBS_END); - - - free(list); - free(len_list); - - - *message = pomA; - - return 0; -} - -/* construct Message-Body of Response-Line for edg_wll_UserJobs */ -int edg_wll_UserJobsToXMLV21(edg_wll_Context ctx UNUSED_VAR, edg_wlc_JobId *jobsOut, char **message) -{ - char *pomA, *pomB; - char **list = NULL; - int i = 0, len, tot_len = 0; - int *len_list = NULL; - - - while (jobsOut[i]) { - len = trio_asprintf(&pomA," %|Xs\r\n", - pomB=edg_wlc_JobIdUnparse(jobsOut[i])); - - free(pomB); - - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - pomA = NULL; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* test errors */ - if (ctx->errDesc || ctx->errCode) - len = trio_asprintf(&pomB," code=\"%d\" desc=\"%|Xs\">\r\n",ctx->errCode,ctx->errDesc); - else - len = asprintf(&pomB,">\r\n"); - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + - sizeof(USERJOBS_BEGIN) + len + sizeof(USERJOBS_END) - 1); - - memcpy(pomA, USERJOBS_BEGIN, sizeof(USERJOBS_BEGIN)); - memcpy((pomA + sizeof(USERJOBS_BEGIN) - 1), pomB, len); - free(pomB); - pomB = pomA + sizeof(USERJOBS_BEGIN) + len - 1; - - i = 0; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - - strcpy(pomB, USERJOBS_END); - - - free(list); - free(len_list); - - - *message = pomA; - - return 0; -} - -static void edg_wll_add_stslist_to_XMLBodyV21(edg_wll_Context ctx, char **body, const edg_wll_JobStat *toAdd, const char *tag, const char *UNUSED_subTag, const int null) -{ - char *pomA, *pomB, *newBody; - char **list = NULL; - int i = 0, len, tot_len = 0; - int *len_list = NULL; - - - while (toAdd[i].state != null) { - edg_wll_JobStatusToXMLV21(ctx, toAdd[i], &pomA); - len = strlen(pomA); - - i++; - tot_len += len; - - list = (char **) realloc(list, i * sizeof(*list)); - list[i-1] = pomA; - pomA = NULL; - len_list = (int *) realloc(len_list, i * sizeof(*len_list)); - len_list[i-1] = len; - } - - /* list termination */ - list = (char **) realloc(list, (i+1) * sizeof(*list)); - list[i] = NULL; - - /* glueing all list fields together & freeing the list */ - pomA = (char *) malloc(tot_len * sizeof(char) + 1); - pomB = pomA; - - i = 0; - while (list[i]) { - memcpy(pomB, list[i], len_list[i] ); - pomB += len_list[i]; - - /* freeing the list */ - free(list[i]); - - i++; - } - *pomB = '\0'; - free(list); - free(len_list); - - asprintf(&newBody,"%s\t\t\t<%s>\r\n%s\t\t\t\r\n", *body, tag, pomA, tag); - free(*body); - free(pomA); - *body = newBody; -} - - -/* construct Message-Body of Response-Line for edg_wll_JobStatus */ -int edg_wll_JobStatusToXMLV21(edg_wll_Context ctx, edg_wll_JobStat stat, char **message) -{ - char *pomA, *pomB, *pomC; - - - pomB = strdup(""); - -@@@{ - selectType $status '_common_'; - for (getFieldsOrdered $status) { - my $f = selectField $status $_; - next if defined($f->{special}) && $f->{special} eq 'XMLstructured'; - my $ft = $f->{type}; - my $n = $f->{null}; - gen "edg_wll_add_$ft\_to_XMLBody(&pomB, stat.$_, \"$_\", $n);\n"; - } -@@@} - if (stat.children) edg_wll_add_strlist_to_XMLBody(&pomB, stat.children, "children", "jobId", "\t\t\t", NULL); - if (stat.children_hist) edg_wll_add_intlist_to_XMLBody(&pomB, stat.children_hist, "children_hist", return_string_el, "\t\t\t", 1, stat.children_hist[0]); - if (stat.children_states) edg_wll_add_stslist_to_XMLBodyV21(ctx, &pomB, stat.children_states, "children_states", "", EDG_WLL_JOB_UNDEF); - if (stat.user_tags) edg_wll_add_taglist_to_XMLBody(&pomB, stat.user_tags, "user_tags", "tag", "name", "\t\t\t", NULL); - if (stat.stateEnterTimes) edg_wll_add_intlist_to_XMLBody(&pomB, stat.stateEnterTimes, "stateEnterTimes", return_string_el, "\t\t\t",1, stat.stateEnterTimes[0]); - - pomC = edg_wll_StatToString(stat.state); - - if (ctx->errDesc || ctx->errCode) - trio_asprintf(&pomA,"\r\n%s", - pomC, ctx->errCode,ctx->errDesc, pomB); - else - trio_asprintf(&pomA,"\r\n%s", - pomC, pomB); - - free(pomB); - free(pomC); - - *message = pomA; - - return 0; -} - - - -/* construct Message-Body of Request-Line for edg_wll_Purge */ -int edg_wll_PurgeResultToXMLV21( - edg_wll_Context ctx, - edg_wll_PurgeResult *result, - char **message) -{ - char *pomA, *pomB; - - - if (!result) { *message = NULL; return(-1); } - - pomA = strdup(""); - edg_wll_add_strlist_to_XMLBody(&pomA, result->jobs, "jobs", "jobId", "\t", NULL); - edg_wll_add_string_to_XMLBody(&pomA, result->server_file, "server_file", NULL); - - if (ctx->errDesc || ctx->errCode) - trio_asprintf(&pomA,"%s code=\"%d\" desc=\"%|Xs\">\r\n%s%s", - PURGE_RESULT_BEGIN, ctx->errCode, ctx->errDesc, pomA, PURGE_RESULT_END); - else - trio_asprintf(&pomB,"%s>\r\n%s%s", PURGE_RESULT_BEGIN, pomA, PURGE_RESULT_END); - free(pomA); - - *message = pomB; - return 0; -} - - - -/* construct Message-Body of Request-Line for edg_wll_Dump */ -int edg_wll_DumpResultToXMLV21( - edg_wll_Context ctx, - edg_wll_DumpResult *result, - char **message) -{ - char *pomA, *pomB; - - - if (!result) { *message = NULL; return(-1); } - - pomA = strdup(""); - edg_wll_add_string_to_XMLBody(&pomA, result->server_file, "server_file", NULL); - edg_wll_add_time_t_to_XMLBody(&pomA, result->from, "from", 0); - edg_wll_add_time_t_to_XMLBody(&pomA, result->to, "to", 0); - - if (ctx->errDesc || ctx->errCode) - trio_asprintf(&pomB,"%s code=\"%d\" desc=\"%|Xs\">\r\n%s%s", - DUMP_RESULT_BEGIN, ctx->errCode, ctx->errDesc, pomA, DUMP_RESULT_END); - else - trio_asprintf(&pomB,"%s>\r\n%s%s", DUMP_RESULT_BEGIN, pomA, DUMP_RESULT_END); - free(pomA); - - *message = pomB; - return 0; -} diff --git a/org.glite.lb.server/src/lb_xml_parse_V21.h b/org.glite.lb.server/src/lb_xml_parse_V21.h deleted file mode 100644 index ea731dc..0000000 --- a/org.glite.lb.server/src/lb_xml_parse_V21.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _LB_XML_PARSE_H_V21 -#define _LB_XML_PARSE_H_V21 - -#ident "$Header$" - -#include "glite/lb/consumer.h" - -/* function for parsing/unparsing XML requests from client */ - -int parseQueryJobsRequestV21(edg_wll_Context ctx, char *messageBody, edg_wll_QueryRec ***conditions, int *flags); -int parseQueryEventsRequestV21(edg_wll_Context ctx, char *messageBody, edg_wll_QueryRec ***job_conditions, edg_wll_QueryRec ***event_conditions); -int parsePurgeRequestV21(edg_wll_Context ctx, char *messageBody, edg_wll_PurgeRequest *request); -int parseDumpRequestV21(edg_wll_Context ctx, char *messageBody, edg_wll_DumpRequest *request); -int edg_wll_QueryEventsToXMLV21(edg_wll_Context, edg_wll_Event *, char **); -int edg_wll_QueryJobsToXMLV21(edg_wll_Context, edg_wlc_JobId *, edg_wll_JobStat *, char **); -int edg_wll_JobStatusToXMLV21(edg_wll_Context, edg_wll_JobStat, char **); -int edg_wll_UserJobsToXMLV21(edg_wll_Context, edg_wlc_JobId *, char **); -int edg_wll_PurgeResultToXMLV21(edg_wll_Context ctx, edg_wll_PurgeResult *result, char **message); -int edg_wll_DumpResultToXMLV21(edg_wll_Context ctx, edg_wll_DumpResult *result, char **message); - -#endif diff --git a/org.glite.lb.server/src/lbproxy.c b/org.glite.lb.server/src/lbproxy.c deleted file mode 100644 index 345f814..0000000 --- a/org.glite.lb.server/src/lbproxy.c +++ /dev/null @@ -1,543 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/lb/srvbones.h" -#include "glite/lb/context.h" -#include "glite/lb/context-int.h" - -#include "il_lbproxy.h" -#include "lb_http.h" -#include "lbs_db.h" - - -extern edg_wll_ErrorCode edg_wll_Open(edg_wll_Context ctx, char *cs); -extern edg_wll_ErrorCode edg_wll_Close(edg_wll_Context); -extern int edg_wll_StoreProtoProxy(edg_wll_Context ctx); - -#define DEFAULTCS "lbserver/@localhost:lbserver20" -/* -#define DEFAULTCS "lbserver/@localhost:lbproxy" -*/ - -#define CON_QUEUE 20 /* accept() */ -#define SLAVE_OVERLOAD 10 /* queue items per slave */ -#define CLNT_TIMEOUT 10 /* keep idle connection that many seconds */ -#define TOTAL_CLNT_TIMEOUT 60 /* one client may ask one slave multiple times */ - /* but only limited time to avoid DoS attacks */ -#define CLNT_REJECT_TIMEOUT 100000 /* time limit for client rejection in !usec! */ -#define DNS_TIMEOUT 5 /* how long wait for DNS lookup */ -#define SLAVE_CONNS_MAX 500 /* commit suicide after that many connections */ -#define MASTER_TIMEOUT 30 /* maximal time of one-round of master network communication */ -#define SLAVE_TIMEOUT 30 /* maximal time of one-round of slave network communication */ - -/* file to store pid and generate semaphores key - */ -#ifndef GLITE_LBPROXY_PIDFILE -#define GLITE_LBPROXY_PIDFILE "/var/run/glite-lbproxy.pid" -#endif - -#ifndef GLITE_LBPROXY_SOCK_PREFIX -#define GLITE_LBPROXY_SOCK_PREFIX "/tmp/lb_proxy_" -#endif - -#ifndef dprintf -#define dprintf(x) { if (debug) printf x; } -#endif - -#define sizofa(a) (sizeof(a)/sizeof((a)[0])) - - -int debug = 0; -static const int one = 1; -static char *dbstring = NULL; -static char sock_store[PATH_MAX], - sock_serve[PATH_MAX]; -static int slaves = 10, - semaphores = -1, - semset; - - -static struct option opts[] = { - {"port", 1, NULL, 'p'}, - {"debug", 0, NULL, 'd'}, - {"mysql", 1, NULL, 'm'}, - {"slaves", 1, NULL, 's'}, - {"semaphores", 1, NULL, 'l'}, - {"pidfile", 1, NULL, 'i'}, - {"proxy-il-sock", 1, NULL, 'X'}, - {"proxy-il-fprefix", 1, NULL, 'Y'}, - {NULL,0,NULL,0} -}; - -static const char *get_opt_string = "p:dm:s:l:i:X:Y:"; - -static void usage(char *me) -{ - fprintf(stderr,"usage: %s [option]\n" - "\t-p, --sock\t path-name to the local socket\n" - "\t-m, --mysql\t database connect string\n" - "\t-d, --debug\t don't run as daemon, additional diagnostics\n" - "\t-s, --slaves\t number of slave servers to fork\n" - "\t-l, --semaphores number of semaphores (job locks) to use\n" - "\t-i, --pidfile\t file to store master pid\n" - "\t--proxy-il-sock\t socket to send events to\n" - "\t--proxy-il-fprefix\t file prefix for events\n" - ,me); -} - -static void wait_for_open(edg_wll_Context,const char *); - - -/* - * SERVER BONES structures and handlers - */ -int clnt_data_init(void **); - - /* - * Serve & Store handlers - */ -int clnt_reject(int); -int handle_conn(int, struct timeval, void *); -int accept_serve(int, void *); -int accept_store(int, void *); -int clnt_disconnect(int, void *); - -#define SRV_SERVE 0 -#define SRV_STORE 1 -static struct glite_srvbones_service service_table[] = { - { "serve", -1, handle_conn, accept_serve, clnt_reject, clnt_disconnect }, - { "store", -1, handle_conn, accept_store, clnt_reject, clnt_disconnect }, -}; - -struct clnt_data_t { - edg_wll_Context ctx; - void *mysql; -}; - - - -int main(int argc, char *argv[]) -{ - int i; - struct sockaddr_un a; - int opt; - char pidfile[PATH_MAX] = GLITE_LBPROXY_PIDFILE, - socket_path_prefix[PATH_MAX] = GLITE_LBPROXY_SOCK_PREFIX, - *name; - FILE *fpid; - key_t semkey; - edg_wll_Context ctx; - struct timeval to; - - - - name = strrchr(argv[0],'/'); - if (name) name++; else name = argv[0]; - - if (geteuid()) snprintf(pidfile,sizeof pidfile,"%s/glite_lb_proxy.pid", getenv("HOME")); - - while ((opt = getopt_long(argc, argv, get_opt_string, opts, NULL)) != EOF) switch (opt) { - case 'p': strcpy(socket_path_prefix, optarg); break; - case 'd': debug = 1; break; - case 'm': dbstring = optarg; break; - case 's': slaves = atoi(optarg); break; - case 'l': semaphores = atoi(optarg); break; - case 'X': lbproxy_ilog_socket_path = strdup(optarg); break; - case 'Y': lbproxy_ilog_file_prefix = strdup(optarg); break; - case 'i': strcpy(pidfile, optarg); break; - case '?': usage(name); return 1; - } - - if ( optind < argc ) { usage(name); return 1; } - - setlinebuf(stdout); - setlinebuf(stderr); - - fpid = fopen(pidfile,"r"); - if ( fpid ) { - int opid = -1; - - if ( fscanf(fpid,"%d",&opid) == 1 ) { - if ( !kill(opid,0) ) { - fprintf(stderr,"%s: another instance running, pid = %d\n",argv[0],opid); - return 1; - } - else if (errno != ESRCH) { perror("kill()"); return 1; } - } - fclose(fpid); - } else if (errno != ENOENT) { perror(pidfile); return 1; } - - fpid = fopen(pidfile, "w"); - if ( !fpid ) { perror(pidfile); return 1; } - fprintf(fpid, "%d", getpid()); - fclose(fpid); - - semkey = ftok(pidfile,0); - - if ( semaphores == -1 ) semaphores = slaves; - semset = semget(semkey, 0, 0); - if ( semset >= 0 ) semctl(semset, 0, IPC_RMID); - semset = semget(semkey, semaphores, IPC_CREAT | 0600); - if ( semset < 0 ) { perror("semget()"); return 1; } - dprintf(("Using %d semaphores, set id %d\n", semaphores, semset)); - for ( i = 0; i < semaphores; i++ ) { - struct sembuf s; - - s.sem_num = i; s.sem_op = 1; s.sem_flg = 0; - if (semop(semset,&s,1) == -1) { perror("semop()"); return 1; } - } - - service_table[SRV_SERVE].conn = socket(PF_UNIX, SOCK_STREAM, 0); - if ( service_table[SRV_SERVE].conn < 0 ) { perror("socket()"); return 1; } - memset(&a, 0, sizeof(a)); - a.sun_family = AF_UNIX; - sprintf(sock_serve, "%s%s", socket_path_prefix, "serve.sock"); - strcpy(a.sun_path, sock_serve); - - if( connect(service_table[SRV_SERVE].conn, (struct sockaddr *)&a, sizeof(a.sun_path)) < 0) { - if( errno == ECONNREFUSED ) { - dprintf(("removing stale input socket %s\n", sock_serve)); - unlink(sock_serve); - } - } else { perror("another instance of lb-proxy is running"); return 1; } - - if ( bind(service_table[SRV_SERVE].conn, (struct sockaddr *) &a, sizeof(a)) < 0 ) { - char buf[100]; - - snprintf(buf, sizeof(buf), "bind(%s)", sock_serve); - perror(buf); - return 1; - } - - if ( listen(service_table[SRV_SERVE].conn, CON_QUEUE) ) { perror("listen()"); return 1; } - - service_table[SRV_STORE].conn = socket(PF_UNIX, SOCK_STREAM, 0); - if ( service_table[SRV_STORE].conn < 0 ) { perror("socket()"); return 1; } - memset(&a, 0, sizeof(a)); - a.sun_family = AF_UNIX; - sprintf(sock_store, "%s%s", socket_path_prefix, "store.sock"); - strcpy(a.sun_path, sock_store); - - if( connect(service_table[SRV_STORE].conn, (struct sockaddr *)&a, sizeof(a.sun_path)) < 0) { - if( errno == ECONNREFUSED ) { - dprintf(("removing stale input socket %s\n", sock_store)); - unlink(sock_store); - } - } else { perror("another instance of lb-proxy is running"); return 1; } - - if ( bind(service_table[SRV_STORE].conn, (struct sockaddr *) &a, sizeof(a))) { - char buf[100]; - - snprintf(buf, sizeof(buf), "bind(%s)", sock_store); - perror(buf); - return 1; - } - if ( listen(service_table[SRV_STORE].conn, CON_QUEUE) ) { perror("listen()"); return 1; } - - dprintf(("Listening at %s, %s ...\n", sock_store, sock_serve)); - - if (!dbstring) dbstring = getenv("LBPROXYDB"); - if (!dbstring) dbstring = DEFAULTCS; - - - /* Just check the database and let it be. The slaves do the job. */ - /* XXX: InitContextProxy() !!! - * edg_wll_InitContext(&ctx) causes segfault - */ - if ( !(ctx = (edg_wll_Context) malloc(sizeof(*ctx))) ) { - perror("InitContext()"); - return -1; - } - memset(ctx, 0, sizeof(*ctx)); - wait_for_open(ctx, dbstring); - if (edg_wll_DBCheckVersion(ctx)) { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - - fprintf(stderr,"%s: open database: %s (%s)\n",argv[0],et,ed); - return 1; - } - edg_wll_Close(ctx); - edg_wll_FreeContext(ctx); - - if ( !debug ) { - if ( daemon(1,0) == -1 ) { perror("deamon()"); exit(1); } - - fpid = fopen(pidfile,"w"); - if ( !fpid ) { perror(pidfile); return 1; } - fprintf(fpid, "%d", getpid()); - fclose(fpid); - openlog(name, LOG_PID, LOG_DAEMON); - } else { setpgid(0, getpid()); } - - - glite_srvbones_set_param(GLITE_SBPARAM_SLAVES_CT, slaves); - glite_srvbones_set_param(GLITE_SBPARAM_SLAVE_OVERLOAD, SLAVE_OVERLOAD); - glite_srvbones_set_param(GLITE_SBPARAM_SLAVE_CONNS_MAX, SLAVE_CONNS_MAX); - to = (struct timeval){CLNT_TIMEOUT, 0}; - glite_srvbones_set_param(GLITE_SBPARAM_CLNT_TIMEOUT, &to); - to = (struct timeval){TOTAL_CLNT_TIMEOUT, 0}; - glite_srvbones_set_param(GLITE_SBPARAM_TOTAL_CLNT_TIMEOUT, &to); - - glite_srvbones_run(clnt_data_init, service_table, sizofa(service_table), debug); - - - semctl(semset, 0, IPC_RMID, 0); - unlink(pidfile); - for ( i = 0; i < sizofa(service_table); i++ ) - if ( service_table[i].conn >= 0 ) close(service_table[i].conn); - unlink(sock_serve); - unlink(sock_store); - - - return 0; -} - - -int clnt_data_init(void **data) -{ - edg_wll_Context ctx; - struct clnt_data_t *cdata; - - - if ( !(cdata = calloc(1, sizeof(*cdata))) ) - return -1; - - if ( !(ctx = (edg_wll_Context) malloc(sizeof(*ctx))) ) { free(cdata); return -1; } - memset(ctx, 0, sizeof(*ctx)); - - dprintf(("[%d] opening database ...\n", getpid())); - wait_for_open(ctx, dbstring); - cdata->mysql = ctx->mysql; - edg_wll_FreeContext(ctx); - - *data = cdata; - return 0; -} - - -int handle_conn(int conn, struct timeval client_start, void *data) -{ - struct clnt_data_t *cdata = (struct clnt_data_t *)data; - edg_wll_Context ctx; - struct timeval total_to = { TOTAL_CLNT_TIMEOUT,0 }; - char buf[300]; - - - if ( !(ctx = (edg_wll_Context) calloc(1, sizeof(*ctx))) ) { - fprintf(stderr, "Couldn't create context"); - return -1; - } - cdata->ctx = ctx; - - /* Shared structures (pointers) - */ - ctx->mysql = cdata->mysql; - - /* set globals - */ - ctx->allowAnonymous = 1; - ctx->isProxy = 1; - ctx->noAuth = 1; - ctx->noIndex = 1; - ctx->semset = semset; - ctx->semaphores = semaphores; - - ctx->p_tmp_timeout.tv_sec = SLAVE_TIMEOUT; - ctx->p_tmp_timeout.tv_usec = 0; - if ( total_to.tv_sec < ctx->p_tmp_timeout.tv_sec ) { - ctx->p_tmp_timeout.tv_sec = total_to.tv_sec; - ctx->p_tmp_timeout.tv_usec = total_to.tv_usec; - } - - ctx->connProxy = (edg_wll_ConnProxy *) calloc(1, sizeof(edg_wll_ConnProxy)); - if ( !ctx->connProxy ) { - perror("calloc"); - edg_wll_FreeContext(ctx); - - return -1; - } - - if ( edg_wll_plain_accept(conn, &ctx->connProxy->conn) ) { - perror("accept"); - edg_wll_FreeContext(ctx); - - return -1; - } - - - return 0; -} - - -int accept_store(int conn, void *cdata) -{ - edg_wll_Context ctx = ((struct clnt_data_t *) cdata)->ctx; - - if ( edg_wll_StoreProtoProxy(ctx) ) { - char *errt, *errd; - - errt = errd = NULL; - switch ( edg_wll_Error(ctx, &errt, &errd) ) { - case ETIMEDOUT: - case EPIPE: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if (!debug) syslog(LOG_ERR,"%s (%s)", errt, errd); - /* fallthrough - */ - case ENOTCONN: - edg_wll_FreeContext(ctx); - ctx = NULL; - free(errt); free(errd); - dprintf(("[%d] Connection closed\n", getpid())); - return 1; - break; - - case ENOENT: - case EINVAL: - case EPERM: - case EEXIST: - case EDG_WLL_ERROR_NOINDEX: - case E2BIG: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if ( !debug ) syslog(LOG_ERR, "%s (%s)", errt, errd); - break; - - default: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if ( !debug ) syslog(LOG_CRIT, "%s (%s)", errt, errd); - return -1; - } - free(errt); free(errd); - } - - return 0; -} - -int accept_serve(int conn, void *cdata) -{ - edg_wll_Context ctx = ((struct clnt_data_t *) cdata)->ctx; - - /* - * serve the request - */ - if ( edg_wll_ServerHTTP(ctx) ) { - char *errt, *errd; - - - errt = errd = NULL; - switch ( edg_wll_Error(ctx, &errt, &errd) ) { - case ETIMEDOUT: - case EPIPE: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if (!debug) syslog(LOG_ERR,"%s (%s)", errt, errd); - /* fallthrough - */ - case ENOTCONN: - edg_wll_FreeContext(ctx); - ctx = NULL; - free(errt); free(errd); - dprintf(("[%d] Connection closed\n", getpid())); - /* - * "recoverable" error - return (>0) - */ - return 1; - break; - - case ENOENT: - case EINVAL: - case EPERM: - case EEXIST: - case EDG_WLL_ERROR_NOINDEX: - case E2BIG: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if ( !debug ) syslog(LOG_ERR,"%s (%s)", errt, errd); - /* - * no action for non-fatal errors - */ - break; - - default: - dprintf(("[%d] %s (%s)\n", getpid(), errt, errd)); - if (!debug) syslog(LOG_CRIT,"%s (%s)",errt,errd); - /* - * unknown error - do rather return (<0) (slave will be killed) - */ - return -1; - } - free(errt); free(errd); - } - - return 0; -} - - -int clnt_disconnect(int conn, void *cdata) -{ - edg_wll_Context ctx = ((struct clnt_data_t *) cdata)->ctx; - - edg_wll_FreeContext(ctx); - - return 0; -} - -int clnt_reject(int conn) -{ - return 0; -} - -static void wait_for_open(edg_wll_Context ctx, const char *dbstring) -{ - char *dbfail_string1, *dbfail_string2; - - dbfail_string1 = dbfail_string2 = NULL; - - while (edg_wll_Open(ctx, (char *) dbstring)) { - char *errt,*errd; - - if (dbfail_string1) free(dbfail_string1); - edg_wll_Error(ctx,&errt,&errd); - asprintf(&dbfail_string1,"%s (%s)\n",errt,errd); - if (dbfail_string1 != NULL) { - if (dbfail_string2 == NULL || strcmp(dbfail_string1,dbfail_string2)) { - if (dbfail_string2) free(dbfail_string2); - dbfail_string2 = dbfail_string1; - dbfail_string1 = NULL; - dprintf(("[%d]: %s\nStill trying ...\n",getpid(),dbfail_string2)); - if (!debug) syslog(LOG_ERR,dbfail_string2); - } - } - sleep(5); - } - - if (dbfail_string1) free(dbfail_string1); - if (dbfail_string2 != NULL) { - free(dbfail_string2); - dprintf(("[%d]: DB connection established\n",getpid())); - if (!debug) syslog(LOG_INFO,"DB connection established\n"); - } -} diff --git a/org.glite.lb.server/src/lbs_db.c b/org.glite.lb.server/src/lbs_db.c deleted file mode 100644 index a54f133..0000000 --- a/org.glite.lb.server/src/lbs_db.c +++ /dev/null @@ -1,224 +0,0 @@ -#ident "$Header$" - -#include "mysql.h" // MySql header file -#include "mysqld_error.h" -#include "errmsg.h" - -#include -#include -#include -#include -#include -#include - -#include "lbs_db.h" -#include "glite/lb/context-int.h" - - -#define DEFAULTCS "lbserver/@localhost:lbserver20" - -#define my_err() edg_wll_SetError(ctx,EDG_WLL_ERROR_DB_CALL,mysql_error((MYSQL *) ctx->mysql)) - -struct _edg_wll_Stmt { - MYSQL_RES *result; - edg_wll_Context ctx; -}; - -edg_wll_ErrorCode edg_wll_DBConnect(edg_wll_Context ctx,char *cs) -{ - char *buf = NULL; - char *host,*user,*pw,*db; - char *slash,*at,*colon; - - if (!cs) cs = DEFAULTCS; - - if (!(ctx->mysql = (void *) mysql_init(NULL))) - return edg_wll_SetError(ctx,ENOMEM,NULL); - - mysql_options(ctx->mysql, MYSQL_READ_DEFAULT_FILE, "my"); - - host = user = pw = db = NULL; - - buf = strdup(cs); - slash = strchr(buf,'/'); - at = strrchr(buf,'@'); - colon = strrchr(buf,':'); - - if (!slash || !at || !colon) { - free(buf); - return edg_wll_SetError(ctx,EINVAL,"DB connect string"); - } - - *slash = *at = *colon = 0; - host = at+1; - user = buf; - pw = slash+1; - db = colon+1; - - /* ljocha: CLIENT_FOUND_ROWS added to make authorization check - * working in update_notif(). - * Hope it does not break anything else */ - if (!mysql_real_connect((MYSQL *) ctx->mysql,host,user,pw,db,0,NULL,CLIENT_FOUND_ROWS)) { - free(buf); - return my_err(); - } - - free(buf); - return edg_wll_ResetError(ctx); -} - -void edg_wll_DBClose(edg_wll_Context ctx) -{ - mysql_close((MYSQL *) ctx->mysql); - ctx->mysql = NULL; -} - -int edg_wll_ExecStmt(edg_wll_Context ctx,char *txt,edg_wll_Stmt *stmt) -{ - int err; - int retry_nr = 0; - int do_reconnect = 0; - - edg_wll_ResetError(ctx); - - if (stmt) { - *stmt = NULL; - } - - while (retry_nr == 0 || do_reconnect) { - do_reconnect = 0; - if (mysql_query((MYSQL *) ctx->mysql,txt)) { - /* error occured */ - switch (err = mysql_errno((MYSQL *) ctx->mysql)) { - case 0: - break; - case ER_DUP_ENTRY: - edg_wll_SetError(ctx,EEXIST,mysql_error((MYSQL *) ctx->mysql)); - return -1; - break; - case CR_SERVER_LOST: - if (retry_nr <= 0) - do_reconnect = 1; - break; - default: - my_err(); - return -1; - break; - } - } - retry_nr++; - } - - if (stmt) { - *stmt = malloc(sizeof(**stmt)); - if (!*stmt) { - edg_wll_SetError(ctx,ENOMEM,NULL); - return -1; - } - memset(*stmt,0,sizeof(**stmt)); - (**stmt).ctx = ctx; - (**stmt).result = mysql_store_result((MYSQL *) ctx->mysql); - if (!(**stmt).result) { - if (mysql_errno((MYSQL *) ctx->mysql)) { - my_err(); - return -1; - } - } - } else { - MYSQL_RES *r = mysql_store_result((MYSQL *) ctx->mysql); - mysql_free_result(r); - } - - return mysql_affected_rows((MYSQL *) ctx->mysql); -} - -int edg_wll_FetchRow(edg_wll_Stmt stmt,char **res) -{ - MYSQL_ROW row; - edg_wll_Context ctx = stmt->ctx; - int nr,i; - unsigned long *len; - - edg_wll_ResetError(ctx); - - if (!stmt->result) return 0; - - if (!(row = mysql_fetch_row(stmt->result))) { - if (mysql_errno((MYSQL *) ctx->mysql)) { - my_err(); - return -1; - } else return 0; - } - - nr = mysql_num_fields(stmt->result); - len = mysql_fetch_lengths(stmt->result); - for (i=0; iresult))) cols[i++] = f->name; - return i == 0; -} - -void edg_wll_FreeStmt(edg_wll_Stmt *stmt) -{ - if (*stmt) { - if ((**stmt).result) mysql_free_result((**stmt).result); - free(*stmt); - *stmt = NULL; - } -} - - -char *edg_wll_TimeToDB(time_t t) -{ - struct tm *tm = gmtime(&t); - char tbuf[256]; - - sprintf(tbuf,"'%4d-%02d-%02d %02d:%02d:%02d'",tm->tm_year+1900,tm->tm_mon+1, - tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec); - - return strdup(tbuf); -} - -time_t edg_wll_DBToTime(char *t) -{ - struct tm tm; - - memset(&tm,0,sizeof(tm)); - setenv("TZ","UTC",1); tzset(); - sscanf(t,"%4d-%02d-%02d %02d:%02d:%02d", - &tm.tm_year,&tm.tm_mon,&tm.tm_mday, - &tm.tm_hour,&tm.tm_min,&tm.tm_sec); - tm.tm_year -= 1900; - tm.tm_mon--; - - return mktime(&tm); -} - -int edg_wll_DBCheckVersion(edg_wll_Context ctx) -{ - MYSQL *m = (MYSQL *) ctx->mysql; - const char *ver_s = mysql_get_server_info(m); - int major,minor,sub,version; - - if (!ver_s || 3 != sscanf(ver_s,"%d.%d.%d",&major,&minor,&sub)) - return edg_wll_SetError(ctx,EINVAL,"retreiving MySQL version"); - - version = 10000*major + 100*minor + sub; - - if (version < EDG_WLL_MYSQL_VERSION) { - char msg[300]; - - snprintf(msg,sizeof msg,"Your MySQL version is %d. At least %d required.",version,EDG_WLL_MYSQL_VERSION); - return edg_wll_SetError(ctx,EINVAL,msg); - } - - return edg_wll_ResetError(ctx); -} diff --git a/org.glite.lb.server/src/lbs_db.h b/org.glite.lb.server/src/lbs_db.h deleted file mode 100644 index 3d7a344..0000000 --- a/org.glite.lb.server/src/lbs_db.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef _LBS_DB_H -#define _LBS_DB_H - -#ident "$Header$" - -#include -#include - -#include "glite/lb/consumer.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define EDG_WLL_MYSQL_VERSION 40001 - -typedef struct _edg_wll_Stmt *edg_wll_Stmt; - -edg_wll_ErrorCode edg_wll_DBConnect( - edg_wll_Context, /* INOUT: */ - char * /* IN: connect string user/password@host:database */ -); - -void edg_wll_DBClose(edg_wll_Context); - - -/* Parse and execute SQL statement. Returns number of rows selected, created - * or affected by update, or -1 on error */ - -int edg_wll_ExecStmt( - edg_wll_Context, /* INOUT: */ - char *, /* IN: SQL statement */ - edg_wll_Stmt * /* OUT: statement handle. Usable for select only */ -); - - -/* Fetch next row of select statement. - * All columns are returned as fresh allocated strings - * - * return values: - * >0 - number of fields of the retrieved row - * 0 - no more rows - * -1 - error - * - * Errors are stored in context passed to previous edg_wll_ExecStmt() */ - -int edg_wll_FetchRow( - edg_wll_Stmt, /* IN: statement */ - char ** /* OUT: array of fetched values. - * As number of columns is fixed and known, - * expects allocated array of pointers here */ -); - -/* Retrieve column names of a query statement */ - -int edg_wll_QueryColumns( - edg_wll_Stmt, /* IN: statement */ - char ** /* OUT: result set column names. Expects allocated array. */ -); - -/* Free the statement structure */ - -void edg_wll_FreeStmt( - edg_wll_Stmt * /* INOUT: statement */ -); - - -/* convert time_t into database-specific time string - * returns pointer to static area that is changed by subsequent calls */ -char *edg_wll_TimeToDB(time_t); -time_t edg_wll_DBToTime(char *); - -extern edg_wll_ErrorCode edg_wll_Open(edg_wll_Context ctx, char *cs); - -/** - * Check database version. - */ -int edg_wll_DBCheckVersion(edg_wll_Context); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/org.glite.lb.server/src/load.c b/org.glite.lb.server/src/load.c deleted file mode 100644 index 0f08964..0000000 --- a/org.glite.lb.server/src/load.c +++ /dev/null @@ -1,210 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/lb/trio.h" - -#include "glite/lb/context-int.h" -#include "glite/lb/events_parse.h" -#include "glite/lb/ulm_parse.h" -#include "glite/lb/purge.h" -#include "glite/lb/purge.h" -#include "glite/lb/events.h" -#include "glite/lb/dump.h" -#include "glite/lb/load.h" - -#include "store.h" -#include "purge.h" -#include "lbs_db.h" -#include "query.h" -#include "get_events.h" -#include "server_state.h" - - -static int read_line(char **buff, int fd); - -int edg_wll_LoadEvents(edg_wll_Context ctx,const edg_wll_LoadRequest *req,edg_wll_LoadResult *result) -{ - int fd, - reject_fd = -1, - readret, i; - char *line = NULL, - buff[30]; - edg_wll_Event *event; - edg_wlc_JobId jobid = NULL; - - - edg_wll_ResetError(ctx); - - if ( !req->server_file ) - return edg_wll_SetError(ctx, EINVAL, "Server file is not specified for load"); - - if ( (fd = open(req->server_file, O_RDONLY)) == -1 ) - return edg_wll_SetError(ctx, errno, "Server can not open the file"); - - memset(result,0,sizeof(*result)); - i = 0; - while ( 1 ) - { - /* Read one line - */ - if ( (readret = read_line(&line, fd)) == -1 ) - return edg_wll_SetError(ctx, errno, "reading dump file"); - - if ( readret == 0 ) - break; - - i++; - if ( sscanf(line, "DG.ARRIVED=%s %*s", buff) != 1 - || edg_wll_ParseEvent(ctx, line, &event) ) - { - char errs[100]; - sprintf(errs, "Error parsing event at line %d", i); - if ( !edg_wll_Error(ctx,NULL,NULL) ) - edg_wll_SetError(ctx, EINVAL, errs); - fprintf(stderr, errs); - continue; - } - edg_wll_ULMDateToTimeval(buff, &(event->any.arrived)); - - if ( i == 1 ) - { - result->from = event->any.arrived.tv_sec; - result->to = event->any.arrived.tv_sec; - } - ctx->event_load = 1; - if ( edg_wll_StoreEvent(ctx, event, NULL) ) - { - int len = strlen(line), - total = 0, - written; - - fprintf(stderr, "Can't store event\n"); - if ( reject_fd == -1 ) - { - char *s, *s1; - - if ( result->server_file != NULL ) - goto cycle_clean; - - s1 = strdup(req->server_file); - s = strrchr(s1, '/'); - if ( s ) - { - *s = '\0'; - reject_fd = edg_wll_CreateFileStorage(ctx,FILE_TYPE_LOAD,s1,&(result->server_file)); - } - else - reject_fd = edg_wll_CreateFileStorage(ctx,FILE_TYPE_LOAD,NULL,&(result->server_file)); - if ( reject_fd == -1 ) - goto cycle_clean; - printf("New reject file %s created\n", result->server_file); - free(s1); - } - /* Save the line into "reject_file" - */ - while (total != len) { - written = write(reject_fd, line+total, len-total); - if (written < 0 && errno != EAGAIN) { - edg_wll_SetError(ctx, errno, "writing load reject file"); - free(line); - break; - } - total += written; - } - write(reject_fd,"\n",1); - } - else - { - result->to = event->any.arrived.tv_sec; - if ( jobid ) - { - char *md5_jobid = edg_wlc_JobIdGetUnique(jobid); - - if ( strcmp(md5_jobid, edg_wlc_JobIdGetUnique(event->any.jobId)) ) - { - edg_wll_JobStat st; - - edg_wll_JobStatus(ctx, jobid, 0, &st); - edg_wll_FreeStatus(&st); - - edg_wlc_JobIdFree(jobid); - edg_wlc_JobIdDup(event->any.jobId, &jobid); - } - free(md5_jobid); - } - else - edg_wlc_JobIdDup(event->any.jobId, &jobid); - } - - -cycle_clean: - ctx->event_load = 0; - edg_wll_FreeEvent(event); - } - - if ( jobid ) - { - edg_wll_JobStat st; - - edg_wll_JobStatus(ctx, jobid, 0, &st); - edg_wll_FreeStatus(&st); - edg_wlc_JobIdFree(jobid); - } - - if ( reject_fd != -1 ) - close(reject_fd); - - return edg_wll_Error(ctx,NULL,NULL); -} - -#define BUFFSZ 1024 - -static int read_line(char **buff, int fd) -{ - int ct, i; - - - if ( *buff == NULL ) - { - *buff = malloc(BUFFSZ); - if ( *buff == NULL ) - return -1; - } - - i = 0; - while ( 1 ) - { - if ( (ct = read(fd, (*buff)+i, 1)) == -1 ) - return -1; - - if ( ct == 0 ) - return 0; - - if ( (*buff)[i] == '\n' ) - { - (*buff)[i--] = '\0'; - while ( (i != -1) && isspace((*buff)[i]) ) i--; - if ( i == -1 ) - { - /** empty line - */ - i = 0; - continue; - } - else - return 1; - } - - i++; - } -} diff --git a/org.glite.lb.server/src/lock.c b/org.glite.lb.server/src/lock.c deleted file mode 100644 index 70a817f..0000000 --- a/org.glite.lb.server/src/lock.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/context-int.h" -#include "lock.h" - - -int edg_wll_LockUnlockJob(const edg_wll_Context ctx,const edg_wlc_JobId job,int lock) -{ - struct sembuf s; - char *un = edg_wlc_JobIdGetUnique(job); - int n,i; - static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; - - if (!un) return edg_wll_SetError(ctx,EINVAL,"jobid"); - - for (n=0; nsemaphores,lock); - - s.sem_num = n % ctx->semaphores; - s.sem_op = lock; - s.sem_flg = SEM_UNDO; - - if (semop(ctx->semset,&s,1)) return edg_wll_SetError(ctx,errno,"edg_wll_LockUnlockJob()"); - return edg_wll_ResetError(ctx); -} diff --git a/org.glite.lb.server/src/lock.h b/org.glite.lb.server/src/lock.h deleted file mode 100644 index c67ec6d..0000000 --- a/org.glite.lb.server/src/lock.h +++ /dev/null @@ -1,4 +0,0 @@ -#define edg_wll_LockJob(ctx,job) edg_wll_LockUnlockJob((ctx),(job),-1) -#define edg_wll_UnlockJob(ctx,job) edg_wll_LockUnlockJob((ctx),(job),1) - -int edg_wll_LockUnlockJob(const edg_wll_Context,const edg_wlc_JobId,int); diff --git a/org.glite.lb.server/src/notif_match.c b/org.glite.lb.server/src/notif_match.c deleted file mode 100644 index 7b23e73..0000000 --- a/org.glite.lb.server/src/notif_match.c +++ /dev/null @@ -1,166 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include - -#include "glite/lb/producer.h" -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/trio.h" - -#include "lbs_db.h" -#include "lb_authz.h" -#include "lb_xml_parse.h" -#include "query.h" -#include "il_notification.h" - -static int notif_match_conditions(edg_wll_Context,const edg_wll_JobStat *,const char *); -static int notif_check_acl(edg_wll_Context,const edg_wll_JobStat *,const char *); - -int edg_wll_NotifExpired(edg_wll_Context,const char *); - -int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *stat) -{ - edg_wll_NotifId nid = NULL; - char *jobq,*ju = NULL,*jobc[5]; - edg_wll_Stmt jobs = NULL; - int ret,i; - time_t now = time(NULL); - - edg_wll_ResetError(ctx); - - if ( (ret = edg_wll_NotifIdCreate(ctx->srvName, ctx->srvPort, &nid)) ) - { - edg_wll_SetError(ctx, ret, "edg_wll_NotifMatch()"); - goto err; - } - trio_asprintf(&jobq, - "select distinct n.notifid,n.destination,n.valid,u.cert_subj,n.conditions " - "from notif_jobs j,users u,notif_registrations n " - "where j.notifid=n.notifid and n.userid=u.userid " - " and (j.jobid = '%|Ss' or j.jobid = '%|Ss')", - ju = edg_wlc_JobIdGetUnique(stat->jobId),NOTIF_ALL_JOBS); - - free(ju); - - if (edg_wll_ExecStmt(ctx,jobq,&jobs) < 0) goto err; - - while ((ret = edg_wll_FetchRow(jobs,jobc)) > 0) { - if (now > edg_wll_DBToTime(jobc[2])) - edg_wll_NotifExpired(ctx,jobc[0]); - else if (notif_match_conditions(ctx,stat,jobc[4]) && - notif_check_acl(ctx,stat,jobc[3])) - { - char *dest, *aux; - int port; - - fprintf(stderr,"NOTIFY: %s, job %s\n",jobc[0], - ju = edg_wlc_JobIdGetUnique(stat->jobId)); - free(ju); - - dest = strdup(jobc[1]); - if ( !(aux = strchr(dest, ':')) ) - { - edg_wll_SetError(ctx, EINVAL, "Can't parse notification destination"); - free(dest); - for (i=0; ip_instance = strdup(""); - if ( edg_wll_NotifJobStatus(ctx, nid, dest, port, jobc[3], *stat) ) - { - free(dest); - for (i=0; inoAuth || strcmp(stat->owner,recip) == 0) return 1; - - ret = edg_wll_DecodeACL(stat->acl,&gacl); - if (ret) { - edg_wll_SetError(ctx,EINVAL,"decoding ACL"); - return 0; - } - - acl->string = stat->acl; - acl->value = gacl; - - ret = edg_wll_CheckACL(ctx, acl, EDG_WLL_PERM_READ); - - acl->string = NULL; - edg_wll_FreeAcl(acl); - - return !ret; -} diff --git a/org.glite.lb.server/src/notification.c b/org.glite.lb.server/src/notification.c deleted file mode 100644 index 79caeb7..0000000 --- a/org.glite.lb.server/src/notification.c +++ /dev/null @@ -1,660 +0,0 @@ -#ident "$Header" - -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/strmd5.h" -#include "glite/lb/trio.h" -#include "glite/lb/context-int.h" -#include "glite/lb/xml_parse.h" -#include "glite/lb/notification.h" -#include "il_notification.h" -#include "lbs_db.h" -#include "query.h" - - -static char *get_user(edg_wll_Context ctx, int create); -static int check_notif_request(edg_wll_Context, const edg_wll_NotifId, char **); -static int split_cond_list(edg_wll_Context, edg_wll_QueryRec const * const *, - edg_wll_QueryRec ***, char ***); -static int update_notif(edg_wll_Context, const edg_wll_NotifId, - const char *, const char *, const char *); - - -int edg_wll_NotifNewServer( - edg_wll_Context ctx, - edg_wll_QueryRec const * const *conditions, - char const *address_override, - const edg_wll_NotifId nid, - time_t *valid) -{ - int i; - char *q = NULL, - *nid_s = NULL, - *time_s = NULL, - *addr_s = NULL, - *xml_conds = NULL, - *owner = NULL, - **jobs = NULL; - edg_wll_QueryRec **nconds = NULL; - - - /* Format notification ID - */ - if ( !(nid_s = edg_wll_NotifIdGetUnique(nid)) ) - goto cleanup; - - /* Get notification owner - */ - if ( !(owner = get_user(ctx, 1)) ) - goto cleanup; - - /* Format conditions - * - separate all jobids - * - format new condition list without jobids - */ - if ( split_cond_list(ctx, conditions, &nconds, &jobs) ) - goto cleanup; - - /* - * encode new cond. list into a XML string - */ - if ( edg_wll_JobQueryRecToXML(ctx, (edg_wll_QueryRec const * const *) nconds, &xml_conds) ) - { - /* XXX: edg_wll_JobQueryRecToXML() do not set errors in context! - * can't get propper error number :( - */ - edg_wll_SetError(ctx, errno, "Can't encode data into xml"); - goto cleanup; - } - - /* Format time of validity - */ - *valid = time(NULL); - if ( ctx->peerProxyValidity - && (ctx->peerProxyValidity - *valid) < ctx->notifDuration ) - *valid = ctx->peerProxyValidity; - else - *valid += ctx->notifDuration; - - if ( !(time_s = strdup(edg_wll_TimeToDB(*valid))) ) - { - edg_wll_SetError(ctx, errno, NULL); - goto cleanup; - } - time_s[strlen(time_s)-1] = 0; - - /* Format the address - */ - if ( address_override ) - { - char *aux; - - if ( !(aux = strchr(address_override, ':')) ) - { - edg_wll_SetError(ctx, EINVAL, "Addres overrirde not in format host:port"); - goto cleanup; - } - if ( !strncmp(address_override, "0.0.0.0", aux-address_override) ) - trio_asprintf(&addr_s, "%s:%s", ctx->connPool[ctx->connToUse].peerName, aux+1); - } - - /* Format DB insert statement - */ - trio_asprintf(&q, - "insert into notif_registrations(notifid,destination,valid,userid,conditions) " - "values ('%|Ss','%|Ss','%|Ss','%|Ss', '%|Ss')", - nid_s, addr_s? addr_s: address_override, time_s+1, owner, xml_conds); - - if ( edg_wll_ExecStmt(ctx, q, NULL) < 0 ) - goto cleanup; - - if (jobs) for ( i = 0; jobs[i]; i++ ) - { - free(q); - trio_asprintf(&q, - "insert into notif_jobs(notifid,jobid) values ('%|Ss','%|Ss')", - nid_s, jobs[i]); - if ( edg_wll_ExecStmt(ctx, q, NULL) < 0 ) - { - /* XXX: Remove uncoplete registration? - * Which error has to be returned? - */ - free(q); - trio_asprintf(&q, "delete from notif_jobs where notifid='%|Ss'", nid_s); - edg_wll_ExecStmt(ctx, q, NULL); - free(q); - trio_asprintf(&q, "delete from notif_registrations where notifid='%|Ss'", nid_s); - edg_wll_ExecStmt(ctx, q, NULL); - goto cleanup; - } - } - else { - trio_asprintf(&q,"insert into notif_jobs(notifid,jobid) values ('%|Ss','%|Ss')", - nid_s,NOTIF_ALL_JOBS); - if ( edg_wll_ExecStmt(ctx, q, NULL) < 0 ) goto cleanup; - - } - - -cleanup: - if ( q ) free(q); - if ( nid_s ) free(nid_s); - if ( time_s ) free(time_s); - if ( addr_s ) free(addr_s); - if ( xml_conds ) free(xml_conds); - if ( owner ) free(owner); - if ( jobs ) - { - for ( i = 0; jobs[i]; i++ ) - free(jobs[i]); - free(jobs); - } - if ( nconds ) free(nconds); - - return edg_wll_Error(ctx, NULL, NULL); -} - - -int edg_wll_NotifBindServer( - edg_wll_Context ctx, - const edg_wll_NotifId nid, - const char *address_override, - time_t *valid) -{ - char *time_s = NULL, - *addr_s = NULL; - - - if ( !address_override ) - { - edg_wll_SetError(ctx, EINVAL, "Address parameter not given"); - goto cleanup; - } - - if ( check_notif_request(ctx, nid, NULL) ) - goto cleanup; - - /* Format time of validity - */ - *valid = time(NULL); - if ( ctx->peerProxyValidity - && (ctx->peerProxyValidity - *valid) < ctx->notifDuration ) - *valid = ctx->peerProxyValidity; - else - *valid += ctx->notifDuration; - - if ( !(time_s = strdup(edg_wll_TimeToDB(*valid))) ) - { - edg_wll_SetError(ctx, errno, "Formating validity time"); - goto cleanup; - } - time_s[strlen(time_s)-1] = 0; - - /* Format the address - */ - if ( address_override ) - { - char *aux; - - if ( !(aux = strchr(address_override, ':')) ) - { - edg_wll_SetError(ctx, EINVAL, "Addres overrirde not in format host:port"); - goto cleanup; - } - if ( !strncmp(address_override, "0.0.0.0", aux-address_override) ) - trio_asprintf(&addr_s, "%s:%s", ctx->connPool[ctx->connToUse].peerName, aux+1); - } - - - update_notif(ctx, nid, NULL, addr_s? addr_s: address_override, (const char *)(time_s+1)); - -cleanup: - if ( time_s ) free(time_s); - if ( addr_s ) free(addr_s); - - return edg_wll_Error(ctx, NULL, NULL); -} - - -int edg_wll_NotifChangeServer( - edg_wll_Context ctx, - const edg_wll_NotifId nid, - edg_wll_QueryRec const * const *conditions, - edg_wll_NotifChangeOp op) -{ - int i; - char *q = NULL, - *nid_s = NULL, - *xml_conds = NULL, - **jobs = NULL; - edg_wll_QueryRec **nconds = NULL; - - - /* Format notification ID - */ - if ( !(nid_s = edg_wll_NotifIdGetUnique(nid)) ) - goto cleanup; - - if ( check_notif_request(ctx, nid, NULL) ) - goto cleanup; - - switch ( op ) - { - case EDG_WLL_NOTIF_REPLACE: - /* Format conditions - * - separate all jobids - * - format new condition list without jobids - */ - if ( split_cond_list(ctx, conditions, &nconds, &jobs) ) - goto cleanup; - - /* - * encode new cond. list into a XML string - */ - if ( edg_wll_JobQueryRecToXML(ctx, (edg_wll_QueryRec const * const *) nconds, &xml_conds) ) - { - /* XXX: edg_wll_JobQueryRecToXML() do not set errors in context! - * can't get propper error number :( - */ - edg_wll_SetError(ctx, errno, "Can't encode data into xml"); - goto cleanup; - } - - /* Format DB insert statement - */ - if ( update_notif(ctx, nid, xml_conds, NULL, NULL) ) - goto cleanup; - - if ( jobs ) - { - /* Format DB insert statement - */ - trio_asprintf(&q, "delete from notif_jobs where notifid='%|Ss'", nid_s); - if ( edg_wll_ExecStmt(ctx, q, NULL) < 0 ) - goto cleanup; - - for ( i = 0; jobs[i]; i++ ) - { - free(q); - trio_asprintf(&q, - "insert into notif_jobs(notifid,jobid) values ('%|Ss','%|Ss')", - nid_s, jobs[i]); - if ( edg_wll_ExecStmt(ctx, q, NULL) < 0 ) - { - /* XXX: Remove uncoplete registration? - * Which error has to be returned? - */ - free(q); - trio_asprintf(&q, "delete from notif_jobs where notifid='%|Ss'", nid_s); - edg_wll_ExecStmt(ctx, q, NULL); - free(q); - trio_asprintf(&q,"delete from notif_registrations where notifid='%|Ss'", nid_s); - edg_wll_ExecStmt(ctx, q, NULL); - goto cleanup; - } - } - } - break; - - case EDG_WLL_NOTIF_ADD: - break; - case EDG_WLL_NOTIF_REMOVE: - break; - default: - break; - } - -cleanup: - if ( q ) free(q); - if ( xml_conds ) free(xml_conds); - if ( nid_s ) free(nid_s); - if ( jobs ) - { - for ( i = 0; jobs[i]; i++ ) - free(jobs[i]); - free(jobs); - } - if ( nconds ) free(nconds); - - return edg_wll_Error(ctx, NULL, NULL); -} - -int edg_wll_NotifRefreshServer( - edg_wll_Context ctx, - const edg_wll_NotifId nid, - time_t *valid) -{ - char *time_s = NULL; - - - if ( check_notif_request(ctx, nid, NULL) ) - goto cleanup; - - /* Format time of validity - */ - *valid = time(NULL); - if ( ctx->peerProxyValidity - && (ctx->peerProxyValidity - *valid) < ctx->notifDuration ) - *valid = ctx->peerProxyValidity; - else - *valid += ctx->notifDuration; - - if ( !(time_s = strdup(edg_wll_TimeToDB(*valid))) ) - { - edg_wll_SetError(ctx, errno, "Formating validity time"); - goto cleanup; - } - time_s[strlen(time_s)-1] = 0; - - update_notif(ctx, nid, NULL, NULL, time_s+1); - -cleanup: - if ( time_s ) free(time_s); - - return edg_wll_Error(ctx, NULL, NULL); -} - -int edg_wll_NotifDropServer( - edg_wll_Context ctx, - edg_wll_NotifId *nid) -{ - char *nid_s = NULL, - *stmt; - int ret; - - - if ( check_notif_request(ctx, nid, NULL) ) - goto cleanup; - - if ( !(nid_s = edg_wll_NotifIdGetUnique(nid)) ) - goto cleanup; - - trio_asprintf(&stmt, "delete from notif_registrations where notifid='%|Ss'", nid_s); - if ( (ret = edg_wll_ExecStmt(ctx, stmt, NULL)) < 0 ) - goto cleanup; - free(stmt); - trio_asprintf(&stmt, "delete from notif_jobs where notifid='%|Ss'", nid_s); - edg_wll_ExecStmt(ctx, stmt, NULL); - edg_wll_NotifCancelRegId(ctx, nid); - -cleanup: - if ( nid_s ) free(nid_s); - if ( stmt ) free(stmt); - - return edg_wll_Error(ctx, NULL, NULL); -} - - -static char *get_user(edg_wll_Context ctx, int create) -{ - edg_wll_Stmt stmt = NULL; - char *userid = NULL, - *q = NULL; - int ret; - - - if ( !ctx->peerName ) - { - edg_wll_SetError(ctx, EPERM, "Annonymous access not allowed"); - goto cleanup; - } - trio_asprintf(&q, "select userid from users where cert_subj='%|Ss'", ctx->peerName); - if ( edg_wll_ExecStmt(ctx, q, &stmt) < 0 ) - goto cleanup; - - /* returned value: - * 0 no user find - continue only when 'create' parameter is set - * >0 user found - return selected value - * <0 SQL error - */ - if ( ((ret = edg_wll_FetchRow(stmt, &userid)) != 0) || !create ) - goto cleanup; - - if ( !(userid = strdup(strmd5(ctx->peerName, NULL))) ) - { - edg_wll_SetError(ctx, errno, "Creating user ID"); - goto cleanup; - } - free(q); - trio_asprintf(&q, "insert into users(userid,cert_subj) values ('%|Ss','%|Ss')", - userid, ctx->peerName); - if ( edg_wll_ExecStmt(ctx, q, NULL) < 0 ) - { - if ( edg_wll_Error(ctx,NULL,NULL) != EEXIST ) - { - free(userid); - userid = NULL; - } - else - edg_wll_ResetError(ctx); - } - -cleanup: - if ( q ) free(q); - if ( stmt ) edg_wll_FreeStmt(&stmt); - - return userid; -} - - -static int check_notif_request( - edg_wll_Context ctx, - const edg_wll_NotifId nid, - char **owner) -{ - char *nid_s = NULL, - *stmt, *user; - int ret; - - - if ( !(user = get_user(ctx, 0)) ) - { - if ( !edg_wll_Error(ctx, NULL, NULL) ) - edg_wll_SetError(ctx, EPERM, "Unknown user"); - - return edg_wll_Error(ctx, NULL, NULL); - } - - if ( !(nid_s = edg_wll_NotifIdGetUnique(nid)) ) - goto cleanup; - - trio_asprintf(&stmt, - "select notifid from notif_registrations " - "where notifid='%|Ss' and userid='%|Ss'", - nid_s, user); - - if ( (ret = edg_wll_ExecStmt(ctx, stmt, NULL)) < 0 ) - goto cleanup; - if ( ret == 0 ) - { - free(stmt); - trio_asprintf(&stmt, - "select notifid from notif_registrations where notifid='%|Ss'", nid_s); - ret = edg_wll_ExecStmt(ctx, stmt, NULL); - if ( ret == 0 ) - edg_wll_SetError(ctx, ENOENT, "Unknown notification ID"); - else if ( ret > 0 ) - edg_wll_SetError(ctx, EPERM, "Only owner could access the notification"); - } - -cleanup: - if ( !edg_wll_Error(ctx, NULL, NULL) && owner ) - *owner = user; - else - free(user); - if ( nid_s ) free(nid_s); - if ( stmt ) free(stmt); - - return edg_wll_Error(ctx, NULL, NULL); -} - - - /* Format conditions - * - first of all separate all jobids - * - then format new condition list without jobids and encode it into an XML string - */ -static int split_cond_list( - edg_wll_Context ctx, - edg_wll_QueryRec const * const *conditions, - edg_wll_QueryRec ***nconds_out, - char ***jobs_out) -{ - edg_wll_QueryRec **nconds = NULL; - char **jobs = NULL; - int i, j, jobs_ct, nconds_ct; - - - if ( !conditions || !conditions[0] ) { - if (ctx->noAuth) nconds_ct = jobs_ct = 0; - else return edg_wll_SetError(ctx, EINVAL, "Empty condition list"); - } - else for ( nconds_ct = jobs_ct = i = 0; conditions[i]; i++ ) { - if ( conditions[i][0].attr && conditions[i][0].attr != EDG_WLL_QUERY_ATTR_JOBID ) - nconds_ct++; - for ( j = 0; conditions[i][j].attr; j++ ) - if ( conditions[i][j].attr == EDG_WLL_QUERY_ATTR_JOBID ) - jobs_ct++; - } - - if ( jobs_out && jobs_ct ) - if ( !(jobs = calloc(jobs_ct+1, sizeof(char *))) ) - { - edg_wll_SetError(ctx, errno, NULL); - goto cleanup; - } - - if ( nconds_out && nconds_ct ) - if ( !(nconds = calloc(nconds_ct+1, sizeof(edg_wll_QueryRec *))) ) - { - edg_wll_SetError(ctx, errno, NULL); - goto cleanup; - } - - if ( jobs ) for ( jobs_ct = i = 0; conditions[i]; i++ ) - for ( j = 0; conditions[i][j].attr; j++ ) - if ( conditions[i][j].attr == EDG_WLL_QUERY_ATTR_JOBID ) - if ( !(jobs[jobs_ct++] = edg_wlc_JobIdGetUnique(conditions[i][j].value.j)) ) - { - edg_wll_SetError(ctx, errno, NULL); - goto cleanup; - } - - if ( nconds ) for ( nconds_ct = i = 0; conditions[i]; i++ ) - if ( conditions[i][0].attr && conditions[i][0].attr != EDG_WLL_QUERY_ATTR_JOBID ) - /* !!! DO NOT DEALLOCATE this arrays (it is not neccessary to allocate new - * mem - it's used only once and only for xml parsing - */ - nconds[nconds_ct++] = (edg_wll_QueryRec *) (conditions[i]); - - if ( jobs_out ) { *jobs_out = jobs; jobs = NULL; } - if ( nconds_out ) { *nconds_out = nconds; nconds = NULL; } - -cleanup: - if ( nconds ) free(nconds); - if ( jobs ) - { - for ( i = 0; jobs[i]; i++ ) - free(jobs[i]); - free(jobs); - } - - return edg_wll_Error(ctx, NULL, NULL); -} - - -static int update_notif( - edg_wll_Context ctx, - const edg_wll_NotifId nid, - const char *conds, - const char *dest, - const char *valid) -{ - char *nid_s = NULL, - *host = NULL, - *stmt, *aux; - int ret, port; - - - if ( !(nid_s = edg_wll_NotifIdGetUnique(nid)) ) - goto cleanup; - - /* Format SQL update string - * (Only the owner could update the notification registration) - */ - if ( !(stmt = strdup("update notif_registrations set")) ) - { - edg_wll_SetError(ctx, errno, "updating notification records"); - goto cleanup; - } - if ( dest ) - { - host = strchr(dest, ':'); - port = atoi(host+1); - if ( !(host = strndup(dest, host-dest)) ) - { - edg_wll_SetError(ctx, errno, "updating notification records"); - goto cleanup; - } - trio_asprintf(&aux, "%s destination='%|Ss'", stmt, dest); - free(stmt); - stmt = aux; - } - if ( valid ) - { - trio_asprintf(&aux, "%s %svalid='%|Ss'", stmt, dest? ",": "", valid); - free(stmt); - stmt = aux; - } - if ( conds ) - { - trio_asprintf(&aux, "%s %sconditions='%|Ss'", - stmt, (dest||valid)? ",": "", conds); - free(stmt); - stmt = aux; - } - trio_asprintf(&aux, "%s where notifid='%|Ss'", stmt, nid_s); - free(stmt); - stmt = aux; - - if ( (ret = edg_wll_ExecStmt(ctx, stmt, NULL)) < 0 ) - goto cleanup; - if ( ret == 0 ) - { - free(stmt); - trio_asprintf(&stmt, - "select notifid from notif_registrations where notifid='%|Ss'", nid_s); - ret = edg_wll_ExecStmt(ctx, stmt, NULL); - if ( ret == 0 ) - edg_wll_SetError(ctx, ENOENT, "Unknown notification ID"); - /* - * XXX: Be happy? - * May be: Rows matched: 1 Changed: 0 Warnings: 0 :-) - else if ( ret > 0 ) - edg_wll_SetError(ctx, EPERM, "Updating notification records"); - */ - } - - if ( host ) { - printf("edg_wll_NotifChangeDestination(ctx, %s, %s, %d)\n", - nid_s? nid_s: "nid", host, port); - if ( edg_wll_NotifChangeDestination(ctx, nid, host, port) ) { - char *errt, *errd; - - edg_wll_Error(ctx, &errt, &errd); - printf("edg_wll_NotifChangeDestination(): %s (%s)\n", errt, errd); - free(errt); - free(errd); - } - } - - -cleanup: - if ( nid_s ) free(nid_s); - if ( stmt ) free(stmt); - if ( host ) free(host); - - return edg_wll_Error(ctx, NULL, NULL); -} diff --git a/org.glite.lb.server/src/openserver.c b/org.glite.lb.server/src/openserver.c deleted file mode 100644 index 44c7854..0000000 --- a/org.glite.lb.server/src/openserver.c +++ /dev/null @@ -1,18 +0,0 @@ -#ident "$Header$" - -#include - -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" - -#include "lbs_db.h" - -edg_wll_ErrorCode edg_wll_Open(edg_wll_Context ctx, char *cs) -{ - return edg_wll_DBConnect(ctx,cs) ? edg_wll_Error(ctx,NULL,NULL) : 0; -} - -edg_wll_ErrorCode edg_wll_Close(edg_wll_Context ctx) -{ - return edg_wll_ResetError(ctx); -} diff --git a/org.glite.lb.server/src/purge.h b/org.glite.lb.server/src/purge.h deleted file mode 100644 index 8841e12..0000000 --- a/org.glite.lb.server/src/purge.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_COMMON_PURGE_H__ -#define __EDG_WORKLOAD_LOGGING_COMMON_PURGE_H__ - -/** Server side implementation - * besides output to the SSL stream (in the context) it may produce - * the server-side dump files - */ -int edg_wll_PurgeServer( - edg_wll_Context ctx, - const edg_wll_PurgeRequest *request -); - -#define FILE_TYPE_ANY "" -#define FILE_TYPE_PURGE "purge" -#define FILE_TYPE_DUMP "dump" -#define FILE_TYPE_LOAD "load" - -extern int edg_wll_CreateTmpFileStorage( - edg_wll_Context ctx, - char *prefix, - char **fname -); - -extern int edg_wll_CreateFileStorageFromTmp( - edg_wll_Context ctx, - char *tmp_type, - char *file_type, - char **fname -); - -extern int edg_wll_CreateFileStorage( - edg_wll_Context ctx, - char *file_type, - char *prefix, - char **fname -); - -#define edg_wll_CreateTmpDumpFile(ctx, f) edg_wll_CreateTmpFileStorage(ctx,ctx->dumpStorage,f) -#define edg_wll_CreateTmpPurgeFile(ctx, f) edg_wll_CreateTmpFileStorage(ctx,ctx->purgeStorage,f) - -#define edg_wll_CreateDumpFileFromTmp(ctx, f, f2) \ - edg_wll_CreateFileStorageFromTmp(ctx, f, FILE_TYPE_DUMP, f2) -#define edg_wll_CreatePurgeFileFromTmp(ctx, f, f2) \ - edg_wll_CreateFileStorageFromTmp(ctx, f, FILE_TYPE_PURGE, f2) - -#define edg_wll_CreateDumpFile(ctx, f) edg_wll_CreateFileStorage(ctx,FILE_TYPE_DUMP,NULL,f) -#define edg_wll_CreatePurgeFile(ctx, f) edg_wll_CreateFileStorage(ctx,FILE_TYPE_PURGE,NULL,f) - -#endif diff --git a/org.glite.lb.server/src/query.c b/org.glite.lb.server/src/query.c deleted file mode 100644 index 1f23f5c..0000000 --- a/org.glite.lb.server/src/query.c +++ /dev/null @@ -1,1414 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/strmd5.h" - -#include "glite/lb/consumer.h" -#include "glite/lb/producer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/trio.h" - - -#include "get_events.h" -#include "index.h" -#include "query.h" -#include "store.h" -#include "lb_authz.h" - -#define FL_SEL_STATUS 1 -#define FL_SEL_TAGS (1<<1) -#define FL_SEL_JOB (1<<2) - - -static int check_event_query_index(edg_wll_Context,const edg_wll_QueryRec **,const edg_wll_QueryRec **); -static int check_job_query_index(edg_wll_Context, const edg_wll_QueryRec **); -static char *jc_to_head_where(edg_wll_Context, const edg_wll_QueryRec **, int *); -static char *ec_to_head_where(edg_wll_Context, const edg_wll_QueryRec **); -static int match_flesh_conditions(const edg_wll_Event *,const edg_wll_QueryRec **); -static int check_strict_jobid_cond(edg_wll_Context, const edg_wll_QueryRec **); - -static int cmp_string(const char *,edg_wll_QueryOp,const char *); -static int is_all_query(const edg_wll_QueryRec **); - - - -#define sizofa(a) (sizeof(a)/sizeof((a)[0])) - -int edg_wll_QueryEventsServer( - edg_wll_Context ctx, - int noAuth, - const edg_wll_QueryRec **job_conditions, - const edg_wll_QueryRec **event_conditions, - edg_wll_Event **events) -{ - char *job_where = NULL, - *event_where = NULL, - *qbase = NULL, - *q = NULL, - *res[11]; - edg_wll_Event *out = NULL; - edg_wll_Stmt sh = NULL; - int i = 0, - ret = 0, - offset = 0, limit = 0, - limit_loop = 1, - eperm = 0; - - - edg_wll_ResetError(ctx); - - if ( (ctx->p_query_results == EDG_WLL_QUERYRES_ALL) && - (!job_conditions || !job_conditions[0] || job_conditions[1] || - (job_conditions[0][0].attr != EDG_WLL_QUERY_ATTR_JOBID) || - (job_conditions[0][1].attr != EDG_WLL_QUERY_ATTR_UNDEF)) ) - { - edg_wll_SetError(ctx, EINVAL, "Invalid parameter EDG_WLL_PARAM_QUERY_RESULTS"); - goto cleanup; - } - - if ((!ctx->noIndex && check_event_query_index(ctx,job_conditions,event_conditions)) || - check_strict_jobid_cond(ctx,job_conditions) || - check_strict_jobid_cond(ctx,event_conditions)) - goto cleanup; - - if (event_conditions && *event_conditions && (*event_conditions)->attr && - !(event_where = ec_to_head_where(ctx,event_conditions))) - goto cleanup; - - if ( job_conditions && *job_conditions && (*job_conditions)->attr && - !(job_where = jc_to_head_where(ctx, job_conditions, &i)) ) - goto cleanup; - -/* XXX: similar query in srv_purge.c ! They has to match due to common - * convert_event_head() called on the result - */ - trio_asprintf(&qbase,"SELECT e.event,j.userid,j.dg_jobid,e.code," - "e.prog,e.host,u.cert_subj,e.time_stamp,e.usec,e.level,e.arrived " - "FROM events e,users u,jobs j%s " - "WHERE %se.jobid=j.jobid AND e.userid=u.userid AND e.code != %d " - "%s %s %s %s", - i & FL_SEL_STATUS ? ",states s" : "", - i & FL_SEL_STATUS ? "s.jobid=j.jobid AND " : "", - EDG_WLL_EVENT_UNDEF, - job_where ? "AND" : "", - job_where ? job_where : "", - event_where ? "AND" : "", - event_where ? event_where : ""); - - if ( ctx->softLimit ) - { - if ( ctx->hardEventsLimit ) - limit = ctx->softLimit < ctx->hardEventsLimit? ctx->softLimit: ctx->hardEventsLimit; - else - limit = ctx->softLimit; - } - else if ( ctx->hardEventsLimit ) - limit = ctx->hardEventsLimit; - else - limit = 0; - - i = 0; - out = calloc(1, sizeof(*out)); - do - { - if ( limit ) - trio_asprintf(&q, "%s LIMIT %d, %d", qbase, offset, limit); - else if ( !q ) - q = qbase; - -// printf("\nquery: %s\n\n", q); - ret = edg_wll_ExecStmt(ctx, q, &sh); - if ( limit ) - free(q); - if ( ret < 0 ) - { - edg_wll_FreeStmt(&sh); - goto cleanup; - } - if ( ret == 0 ) - { - limit_loop = 0; - goto limit_cycle_cleanup; - } - if ( !limit || (ret < limit) ) - limit_loop = 0; - - offset += ret; - while ( (ret = edg_wll_FetchRow(sh, res)) == sizofa(res) ) - { - int n = atoi(res[0]); - free(res[0]); - - if ( convert_event_head(ctx, res+2, out+i) || edg_wll_get_event_flesh(ctx, n, out+i) ) - { - free(res[1]); - memset(out+i, 0, sizeof(*out)); - edg_wll_FreeStmt(&sh); - goto cleanup; - } - - if ( !match_flesh_conditions(out+i,event_conditions) || check_strict_jobid(ctx,out[i].any.jobId) ) - { - edg_wll_FreeEvent(out+i); - edg_wll_ResetError(ctx); /* check_strict_jobid() sets it */ - goto fetch_cycle_cleanup; - } - - if ( !noAuth ) - { - if (!ctx->peerName || strcmp(res[1],strmd5(ctx->peerName,NULL))) { - edg_wll_Acl acl = NULL; - char *jobid = NULL; - - ret = edg_wll_GetACL(ctx, out[i].any.jobId, &acl); - free(jobid); - if (ret || acl == NULL) { - eperm = 1; - edg_wll_FreeEvent(out+i); - edg_wll_ResetError(ctx); /* XXX: should be reported somewhere at least in debug mode */ - goto fetch_cycle_cleanup; - } - - ret = edg_wll_CheckACL(ctx, acl, EDG_WLL_PERM_READ); - edg_wll_FreeAcl(acl); - if (ret) { - eperm = 1; - edg_wll_FreeEvent(out+i); - edg_wll_ResetError(ctx); /* XXX: should be reported somewhere at least in debug mode */ - goto fetch_cycle_cleanup; - } - } - } - - if ( (ctx->p_query_results != EDG_WLL_QUERYRES_ALL) && limit && (i+1 > limit) ) - { - free(res[1]); - memset(out+i, 0, sizeof(*out)); - edg_wll_SetError(ctx, E2BIG, "Query result size limit exceeded"); - if ( ctx->p_query_results == EDG_WLL_QUERYRES_LIMITED ) - { - limit_loop = 0; - goto limit_cycle_cleanup; - } - goto cleanup; - } - - i++; - out = (edg_wll_Event *) realloc(out, (i+1) * sizeof(*out)); - -fetch_cycle_cleanup: - memset(out+i, 0, sizeof(*out)); - free(res[1]); - } -limit_cycle_cleanup: - edg_wll_FreeStmt(&sh); - } while ( limit_loop ); - - if ( i == 0 && eperm ) - edg_wll_SetError(ctx, EPERM, "matching events found but authorization failed"); - else if ( i == 0 ) - edg_wll_SetError(ctx, ENOENT, "no matching events found"); - else - { - edg_wll_SortEvents(out); - *events = out; - out = NULL; - } - -cleanup: - if ( out ) - { - for ( i = 0; out[i].type; i++ ) - edg_wll_FreeEvent(out+i); - free(out); - } - free(qbase); - free(job_where); - free(event_where); - - return edg_wll_Error(ctx,NULL,NULL); -} - -int edg_wll_QueryJobsServer( - edg_wll_Context ctx, - const edg_wll_QueryRec **conditions, - int flags, - edg_wlc_JobId **jobs, - edg_wll_JobStat **states) -{ - char *job_where = NULL, - *state_where = NULL, - *tags_where = NULL, - *q = NULL, - *qbase = NULL, - *res[3]; - edg_wlc_JobId *jobs_out = NULL; - edg_wll_JobStat *states_out = NULL; - edg_wll_Stmt sh; - int i = 0, - ret = 0, - eperm = 0, - limit = 0, offset = 0, - limit_loop = 1; - - - memset(res,0,sizeof res); - edg_wll_ResetError(ctx); - - if ( !conditions ) - { - edg_wll_SetError(ctx, EINVAL, "empty condition list"); - goto cleanup; - } - - if ( (ctx->p_query_results == EDG_WLL_QUERYRES_ALL) && - (!conditions[0] || conditions[1] || - (conditions[0][0].attr != EDG_WLL_QUERY_ATTR_OWNER) || - (conditions[0][1].attr != EDG_WLL_QUERY_ATTR_UNDEF)) ) - { - edg_wll_SetError(ctx, EINVAL, "Invalid parameter EDG_WLL_PARAM_QUERY_RESULTS"); - goto cleanup; - } - - if ( (!ctx->noIndex && check_job_query_index(ctx, conditions)) || check_strict_jobid_cond(ctx,conditions)) - goto cleanup; - - if ( !(job_where = jc_to_head_where(ctx, conditions, &i)) ) - goto cleanup; - - if ( (i & FL_SEL_STATUS) ) - trio_asprintf(&qbase,"SELECT DISTINCT j.dg_jobid,j.userid " - "FROM jobs j, states s WHERE j.jobid=s.jobid AND %s", job_where); - else - trio_asprintf(&qbase,"SELECT DISTINCT j.dg_jobid,j.userid " - "FROM jobs j WHERE %s", job_where); - - if ( ctx->softLimit ) - { - if ( ctx->hardJobsLimit ) - limit = ctx->softLimit < ctx->hardJobsLimit? ctx->softLimit: ctx->hardJobsLimit; - else - limit = ctx->softLimit; - } - else if ( ctx->hardJobsLimit ) - limit = ctx->hardJobsLimit; - else - limit = 0; - - jobs_out = calloc(1, sizeof(*jobs_out)); - states_out = calloc(1, sizeof(*states_out)); - i = 0; - do - { - if ( limit ) - trio_asprintf(&q, "%s LIMIT %d, %d", qbase, offset, limit); - else if ( !q ) - q = qbase; - -// printf("\nquery: %s\n\n", q); - ret = edg_wll_ExecStmt(ctx, q, &sh); - if ( limit ) - free(q); - if ( ret < 0 ) - { - edg_wll_FreeStmt(&sh); - goto cleanup; - } - if ( ret == 0 ) - { - limit_loop = 0; - goto limit_cycle_cleanup; - } - if ( !limit || (ret < limit) ) - limit_loop = 0; - - offset += ret; - while ( (ret=edg_wll_FetchRow(sh,res)) > 0 ) - { - if ( (ret = edg_wlc_JobIdParse(res[0], jobs_out+i)) ) - { /* unlikely to happen, internal inconsistency */ - char buf[200]; - snprintf(buf,sizeof buf,"JobIdParse(%s)",res[0]); - edg_wll_SetError(ctx,ret,buf); - free(res[0]); free(res[1]); free(res[2]); - jobs_out[i] = NULL; - goto cleanup; - } - - if ( check_strict_jobid(ctx, jobs_out[i]) ) - { - edg_wlc_JobIdFree(jobs_out[i]); - goto fetch_cycle_cleanup; - } - - if ( edg_wll_JobStatus(ctx, jobs_out[i], flags, &states_out[i]) ) - { - edg_wlc_JobIdFree(jobs_out[i]); - if (edg_wll_Error(ctx,NULL,NULL) == EPERM) eperm = 1; - goto fetch_cycle_cleanup; - } - - if ( !match_status(ctx, states_out+i, conditions) ) - { - edg_wlc_JobIdFree(jobs_out[i]); - edg_wll_FreeStatus(states_out+i); - edg_wll_ResetError(ctx); /* check_strict_jobid() sets it */ - goto fetch_cycle_cleanup; - } - -#if 0 - if ( !ctx->noAuth && (!ctx->peerName || strcmp(res[1], strmd5(ctx->peerName, NULL))) ) - { - eperm = 1; - edg_wlc_JobIdFree(jobs_out[i]); - edg_wll_FreeStatus(states_out+i); - goto fetch_cycle_cleanup; - } -#endif - - if ( (ctx->p_query_results != EDG_WLL_QUERYRES_ALL) && limit && (i+1 > limit) ) - { - edg_wll_SetError(ctx, E2BIG, "Query result size limit exceeded"); - free(res[0]); free(res[1]); free(res[2]); - memset(states_out+i, 0, sizeof(*states_out)); - jobs_out[i] = NULL; - if ( ctx->p_query_results == EDG_WLL_QUERYRES_LIMITED ) - { - limit_loop = 0; - goto limit_cycle_cleanup; - } - goto cleanup; - } - - i++; - jobs_out = (edg_wlc_JobId *) realloc(jobs_out, (i+1) * sizeof(*jobs_out)); - states_out = (edg_wll_JobStat *) realloc(states_out, (i+1) * sizeof(*states_out)); - -fetch_cycle_cleanup: - free(res[0]); free(res[1]); free(res[2]); - memset(states_out+i, 0, sizeof(*states_out)); - jobs_out[i] = NULL; - } -limit_cycle_cleanup: - edg_wll_FreeStmt(&sh); - } while ( limit_loop ); - - if ( eperm && !*jobs_out ) - edg_wll_SetError(ctx, EPERM, "matching jobs found but authorization failed"); - - if ( i && (ret == 0) ) - { - if ( states ) - { - *states = states_out; - states_out = NULL; - } - if ( jobs ) - { - *jobs = jobs_out; - jobs_out = NULL; - } - } - - -cleanup: - free(qbase); - free(state_where); - free(tags_where); - free(job_where); - - if (jobs_out) - { - for ( i = 0; jobs_out[i]; i++ ) - edg_wlc_JobIdFree(jobs_out[i]); - free(jobs_out); - } - - if (states_out) - { - for (i=0; states_out[i].state; i++) edg_wll_FreeStatus(states_out+i); - free(states_out); - } - - return edg_wll_Error(ctx,NULL,NULL); -} - - -static int check_event_query_index(edg_wll_Context ctx,const edg_wll_QueryRec **jc,const edg_wll_QueryRec **ec) -{ - int i, j; - - if (check_job_query_index(ctx,jc) == 0) return 0; - edg_wll_ResetError(ctx); - - if (ec && *ec) for (i=0; ec[i]; i++) for (j=0; ec[i][j].attr; j++) switch (ec[i][j].attr) { - case EDG_WLL_QUERY_ATTR_TIME: - return 0; - default: break; - } - return edg_wll_SetError(ctx,EDG_WLL_ERROR_NOINDEX, - is_all_query(jc) ? "\"-all\" queries denied by server configuration" : NULL); -} - -static int check_job_query_index(edg_wll_Context ctx, const edg_wll_QueryRec **jc) -{ - int i, j, jj; - - - edg_wll_ResetError(ctx); - - if ( !jc || !*jc ) - return edg_wll_SetError(ctx,EDG_WLL_ERROR_NOINDEX,"unrestricted queries unsupported"); - - /* - * First check presense of jobid - Primary key - */ - for ( i = 0; jc[i]; i++ ) for ( j = 0; jc[i][j].attr; j++ ) - if ( jc[i][j].attr == EDG_WLL_QUERY_ATTR_JOBID ) return 0; - - if ( !ctx->job_index ) - return edg_wll_SetError(ctx, EDG_WLL_ERROR_NOINDEX, "no indices configured: jobid required in query"); - - for ( j = 0; ctx->job_index[j]; j++ ) - { - if ( !ctx->job_index[j][0].attr ) - continue; - - if ( ctx->job_index[j][1].attr ) - { - /* - * check multi comlumn indexes - */ - for ( jj = 0; ctx->job_index[j][jj].attr; jj++ ) - { - for ( i = 0; jc[i]; i++ ) - if ( !edg_wll_CmpColumn(&ctx->job_index[j][jj], &jc[i][0]) ) break; - if ( !jc[i] ) - break; - } - if ( !ctx->job_index[j][jj].attr ) - return 0; - } - else - for ( i = 0; jc[i]; i++ ) - if ( !edg_wll_CmpColumn(&ctx->job_index[j][0], &jc[i][0]) ) return 0; - } - - return edg_wll_SetError(ctx,EDG_WLL_ERROR_NOINDEX, - is_all_query(jc) ? "\"-all\" queries denied by server configuration" : NULL); -} - -#define opToString(op) \ - ((op) == EDG_WLL_QUERY_OP_EQUAL ? "=" : \ - ((op) == EDG_WLL_QUERY_OP_UNEQUAL ? "!=" : \ - ((op) == EDG_WLL_QUERY_OP_LESS ? "<" : ">" ))) - -static char *ec_to_head_where(edg_wll_Context ctx,const edg_wll_QueryRec **ec) -{ - int n, ct, m; - char msg[100], - *out, - *aux, - *conds, *retconds, - *dbt; - - - /* - * check correctness only - */ - for ( ct = m = 0; ec[m]; m++ ) - { - for ( n = 0; ec[m][n].attr; n++ ) switch ( ec[m][n].attr ) - { - case EDG_WLL_QUERY_ATTR_HOST: - if ( ec[m][n].op != EDG_WLL_QUERY_OP_EQUAL && ec[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) - { - edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with host attr"); - return NULL; - } - ct++; - break; - - case EDG_WLL_QUERY_ATTR_SOURCE: - if ( ec[m][n].op != EDG_WLL_QUERY_OP_EQUAL && ec[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) - { - edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with host attr"); - return NULL; - } - ct++; - break; - - case EDG_WLL_QUERY_ATTR_USERTAG: - if ( ec[m][n].op != EDG_WLL_QUERY_OP_EQUAL && ec[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) - { - edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with usertag attr"); - return NULL; - } - ct++; - break; - - case EDG_WLL_QUERY_ATTR_INSTANCE: - if ( ec[m][n].op != EDG_WLL_QUERY_OP_EQUAL && ec[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) - { - edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with instance attr"); - return NULL; - } - ct++; - break; - - case EDG_WLL_QUERY_ATTR_EVENT_TYPE: - case EDG_WLL_QUERY_ATTR_LEVEL: - /* - * Any op allowed - but be careful - */ - case EDG_WLL_QUERY_ATTR_TIME: - /* any operator allowed */ - ct++; - break; - - default: - sprintf(msg, "ec_to_head_where(): attr=%d unsupported", ec[m][n].attr); - edg_wll_SetError(ctx, EINVAL, msg); - return NULL; - } - } - - if ( ct == 0 ) - { - edg_wll_SetError(ctx,EINVAL,"ec_to_head_where(): empty conditions"); - return NULL; - } - - conds = retconds = NULL; - for ( m = 0; ec[m]; m++ ) - { - /* - * conditions captured by match_flesh_conditions() have to be skipped here. - * with all conditions in same "or clause" - */ - for ( n = 0; ec[m][n].attr; n++ ) - if ( (ec[m][n].attr == EDG_WLL_QUERY_ATTR_USERTAG) - || (ec[m][n].attr == EDG_WLL_QUERY_ATTR_INSTANCE) ) - break; - if ( ec[m][n].attr ) - continue; - - for ( n = 0; ec[m][n].attr; n++ ) switch ( ec[m][n].attr ) - { - case EDG_WLL_QUERY_ATTR_TIME: - dbt = edg_wll_TimeToDB(ec[m][n].value.t.tv_sec); - if ( conds ) - { - if ( ec[m][n].op == EDG_WLL_QUERY_OP_WITHIN ) - { - trio_asprintf(&aux, "%s", dbt); - dbt = edg_wll_TimeToDB(ec[m][n].value2.t.tv_sec); - trio_asprintf(&out, "%s OR (e.time_stamp >= %s AND e.time_stamp <= %s)", conds, aux, dbt); - free(aux); - } - else - trio_asprintf(&out, "%s OR e.time_stamp %s %s", conds, opToString(ec[m][n].op), dbt); - free(conds); - conds = out; - } - else if ( ec[m][n].op == EDG_WLL_QUERY_OP_WITHIN ) - { - trio_asprintf(&aux, "%s", dbt); - dbt = edg_wll_TimeToDB(ec[m][n].value2.t.tv_sec); - trio_asprintf(&conds, "(e.time_stamp >= %s AND e.time_stamp <= %s)", aux, dbt); - free(aux); - } - else - trio_asprintf(&conds, "e.time_stamp %s %s", opToString(ec[m][n].op), dbt); - break; - - case EDG_WLL_QUERY_ATTR_LEVEL: - if ( conds ) - { - if ( ec[m][n].op == EDG_WLL_QUERY_OP_WITHIN ) - trio_asprintf(&out, "%s OR (e.level >= %d AND e.level <= %d)", conds, ec[m][n].value.i, ec[m][n].value2.i); - else - trio_asprintf(&out, "%s OR e.level %s %d", conds, opToString(ec[m][n].op), ec[m][n].value.i); - free(conds); conds = out; - } - else - if ( ec[m][n].op == EDG_WLL_QUERY_OP_WITHIN ) - trio_asprintf(&conds, "(e.level >= %d AND e.level <= %d)", ec[m][n].value.i, ec[m][n].value2.i); - else - trio_asprintf(&conds, "e.level %s %d", opToString(ec[m][n].op), ec[m][n].value.i); - break; - - case EDG_WLL_QUERY_ATTR_SOURCE: - aux = edg_wll_SourceToString(ec[m][n].value.i); - if ( conds ) - { - trio_asprintf(&out, "%s OR e.prog %s '%|Ss'", conds, opToString(ec[m][n].op), aux); - free(conds); conds = out; - } - else - trio_asprintf(&conds, "e.prog %s '%|Ss'", opToString(ec[m][n].op), aux); - free(aux); - break; - - case EDG_WLL_QUERY_ATTR_HOST: - if ( conds ) - { - trio_asprintf(&out, "%s OR e.host %s '%|Ss'", conds, opToString(ec[m][n].op), ec[m][n].value.c); - free(conds); conds = out; - } - else - trio_asprintf(&conds, "e.host %s '%|Ss'", opToString(ec[m][n].op), ec[m][n].value.c); - break; - - case EDG_WLL_QUERY_ATTR_EVENT_TYPE: - if ( conds ) - { - if ( ec[m][n].op == EDG_WLL_QUERY_OP_WITHIN ) - trio_asprintf(&out, "%s OR (e.code >= %d AND e.code <= %d)", conds, ec[m][n].value.i, ec[m][n].value2.i); - else - trio_asprintf(&out, "%s OR e.code %s %d", conds, opToString(ec[m][n].op), ec[m][n].value.i); - free(conds); conds = out; - } - else - if ( ec[m][n].op == EDG_WLL_QUERY_OP_WITHIN ) - trio_asprintf(&conds, "(e.code >= %d AND e.code <= %d)", ec[m][n].value.i, ec[m][n].value2.i); - else - trio_asprintf(&conds, "e.code %s %d", opToString(ec[m][n].op), ec[m][n].value.i); - break; - - default: - return NULL; - } - - if ( !conds ) - continue; - - if ( retconds ) - { - trio_asprintf(&out, "%s AND (%s)", retconds, conds); - free(retconds); retconds = out; - free(conds); conds = NULL; - } - else - { - trio_asprintf(&retconds, "(%s)", conds); - free(conds); conds = NULL; - } - } - - return retconds; -} - -static int is_indexed(const edg_wll_QueryRec *cond, const edg_wll_Context ctx) -{ - int i, j; - - if ( !(ctx->job_index) ) - return 0; - - for ( i = 0; ctx->job_index[i]; i++ ) for ( j = 0; ctx->job_index[i][j].attr; j++ ) - if ( !edg_wll_CmpColumn(&ctx->job_index[i][j], cond) ) return 1; - - return 0; -} - -/* - * use where_flags to recognize which table to jois in SQL select - * - */ -static char *jc_to_head_where( - edg_wll_Context ctx, - const edg_wll_QueryRec **jc, - int *where_flags) -{ - int ct, n, m; - char *aux, - *tmps, - *dbt, - *cname = NULL, - msg[100]; - char *conds, *retconds; - - - retconds = conds = NULL; - - /* - * check correctness only - */ - for ( ct = m = 0; jc[m]; m++ ) for ( n = 0; jc[m][n].attr; n++ ) - { - if ( (jc[m][0].attr != jc[m][n].attr) - || ( (jc[m][n].attr == EDG_WLL_QUERY_ATTR_USERTAG) - && strcmp(jc[m][0].attr_id.tag, jc[m][n].attr_id.tag)) ) - { - edg_wll_SetError(ctx, EINVAL, "only same attribute types supported in 'or' expressions"); - return NULL; - } - - switch ( jc[m][n].attr ) - { - case EDG_WLL_QUERY_ATTR_JOBID: - ct++; - if ( jc[m][n].op != EDG_WLL_QUERY_OP_EQUAL && jc[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) - { - edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with jobid"); - return NULL; - } - break; - - case EDG_WLL_QUERY_ATTR_OWNER: - ct++; - if ( jc[m][n].op != EDG_WLL_QUERY_OP_EQUAL && jc[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) - { - edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with job owner"); - return NULL; - } - break; - - case EDG_WLL_QUERY_ATTR_LOCATION: - ct++; - if ( jc[m][n].op != EDG_WLL_QUERY_OP_EQUAL && jc[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) - { - edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with job location"); - return NULL; - } - break; - - case EDG_WLL_QUERY_ATTR_DESTINATION: - ct++; - if ( jc[m][n].op != EDG_WLL_QUERY_OP_EQUAL && jc[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) - { - edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with job destinations"); - return NULL; - } - break; - - case EDG_WLL_QUERY_ATTR_PARENT: - ct++; - if ( jc[m][n].op != EDG_WLL_QUERY_OP_EQUAL && jc[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) - { - edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with job parent"); - return NULL; - } - break; - - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - ct++; - if ( jc[m][n].op != EDG_WLL_QUERY_OP_EQUAL && jc[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) - { - edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with resubmitted attr"); - return NULL; - } - break; - - case EDG_WLL_QUERY_ATTR_TIME: - if ( jc[m][n].attr_id.state == EDG_WLL_JOB_UNDEF ) - { - edg_wll_SetError(ctx, EINVAL, "Time attribut have to be associated with status specification"); - return NULL; - } - ct++; - break; - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_EXITCODE: - case EDG_WLL_QUERY_ATTR_STATUS: - ct++; - break; - - case EDG_WLL_QUERY_ATTR_USERTAG: - ct++; - break; - - default: - sprintf(msg, "jc_to_head_where(): attr=%d unsupported", jc[m][n].attr); - edg_wll_SetError(ctx, EINVAL, msg); - return NULL; - } - } - - if ( ct == 0 ) - { - edg_wll_SetError(ctx, EINVAL, "jc_to_head_where(): empty conditions"); - return NULL; - } - - /* - * Now process conversion - */ - for ( m = 0; jc[m]; m++ ) - { - for ( n = 0; jc[m][n].attr; n++ ) switch (jc[m][n].attr) - { - case EDG_WLL_QUERY_ATTR_TIME: - if ( (!ctx->isProxy && !is_indexed(&(jc[m][n]), ctx)) - || !(cname = edg_wll_QueryRecToColumn(&(jc[m][n]))) ) - break; - - *where_flags |= FL_SEL_STATUS; - - dbt = edg_wll_TimeToDB(jc[m][n].value.t.tv_sec); - if ( conds ) - { - if ( jc[m][n].op == EDG_WLL_QUERY_OP_WITHIN ) - { - trio_asprintf(&aux, "%s", dbt); - dbt = edg_wll_TimeToDB(jc[m][n].value2.t.tv_sec); - trio_asprintf(&tmps, "%s OR (s.%s >= %s AND s.%s <= %s)", conds, cname, aux, cname, dbt); - free(aux); - } - else - trio_asprintf(&tmps, "%s OR s.%s %s s.%s", conds, cname, opToString(jc[m][n].op), dbt); - - free(conds); - conds = tmps; - } - else if ( jc[m][n].op == EDG_WLL_QUERY_OP_WITHIN ) - { - trio_asprintf(&aux, "%s", dbt); - dbt = edg_wll_TimeToDB(jc[m][n].value2.t.tv_sec); - trio_asprintf(&conds, "(%s >= s.%s AND s.%s <= %s)", cname, aux, cname, dbt); - free(aux); - } - else - trio_asprintf(&conds, "s.%s %s %s", cname, opToString(jc[m][n].op), dbt); - - free(cname); - break; - - case EDG_WLL_QUERY_ATTR_JOBID: - *where_flags |= FL_SEL_JOB; - aux = edg_wlc_JobIdGetUnique(jc[m][n].value.j); - if ( conds ) - { - trio_asprintf(&tmps, "%s OR j.jobid%s'%|Ss'", conds, opToString(jc[m][n].op), aux); - free(conds); conds = tmps; - } - else - trio_asprintf(&conds, "j.jobid%s'%|Ss'", opToString(jc[m][n].op), aux); - free(aux); - break; - - case EDG_WLL_QUERY_ATTR_PARENT: - if ( (!ctx->isProxy && !is_indexed(&(jc[m][n]), ctx)) - || !(cname = edg_wll_QueryRecToColumn(&(jc[m][n]))) ) - break; - - *where_flags |= FL_SEL_STATUS; - aux = edg_wlc_JobIdGetUnique(jc[m][n].value.j); - if ( conds ) - { - trio_asprintf(&tmps, "%s OR s.%s%s'%|Ss'", conds, cname, opToString(jc[m][n].op), aux); - free(conds); conds = tmps; - } - else - trio_asprintf(&conds, "s.%s%s'%|Ss'", cname, opToString(jc[m][n].op), aux); - free(aux); - break; - - case EDG_WLL_QUERY_ATTR_OWNER: - if ( (!ctx->isProxy && !is_indexed(&(jc[m][n]), ctx)) - || !(cname = edg_wll_QueryRecToColumn(&(jc[m][n]))) ) - break; - - if ( !jc[m][n].value.c && !ctx->peerName ) - { - edg_wll_SetError(ctx, EPERM, "jc_to_head_where(): ctx->peerName empty"); - free(cname); free(conds); free(retconds); - return NULL; - } - - *where_flags |= FL_SEL_STATUS; - if ( conds ) - { - if ( jc[m][n].value.c ) - trio_asprintf(&tmps, "%s OR s.%s%s'%|Ss'", conds, cname, opToString(jc[m][n].op), jc[m][n].value.c); - else - trio_asprintf(&tmps, "%s OR s.%s%s'%|Ss'", conds, cname, opToString(jc[m][n].op), ctx->peerName); - free(conds); conds = tmps; - } - else - { - if ( jc[m][n].value.c ) - trio_asprintf(&conds, "s.%s%s'%|Ss'", cname, opToString(jc[m][n].op), jc[m][n].value.c); - else - trio_asprintf(&conds, "s.%s%s'%|Ss'", cname, opToString(jc[m][n].op), ctx->peerName); - } - break; - - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_EXITCODE: - case EDG_WLL_QUERY_ATTR_STATUS: - if ( (!ctx->isProxy && !is_indexed(&(jc[m][n]), ctx)) - || !(cname = edg_wll_QueryRecToColumn(&(jc[m][n]))) ) - break; - - *where_flags |= FL_SEL_STATUS; - if ( conds ) - { - if ( jc[m][n].op == EDG_WLL_QUERY_OP_WITHIN ) - trio_asprintf(&tmps, "%s OR (s.%s >= %d AND s.%s <= %d)", conds, cname, jc[m][n].value.i, cname, jc[m][n].value2.i); - else - trio_asprintf(&tmps, "%s OR s.%s %s %d", conds, cname, opToString(jc[m][n].op), jc[m][n].value.i); - free(conds); conds = tmps; - } - else - if ( jc[m][n].op == EDG_WLL_QUERY_OP_WITHIN ) - trio_asprintf(&conds, "(s.%s >= %d AND s.%s <= %d)", cname, jc[m][n].value.i, cname, jc[m][n].value2.i); - else - trio_asprintf(&conds, "s.%s %s %d", cname, opToString(jc[m][n].op),jc[m][n].value.i); - - free(cname); - break; - - case EDG_WLL_QUERY_ATTR_DESTINATION: - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - case EDG_WLL_QUERY_ATTR_USERTAG: - if ( (!ctx->isProxy && !is_indexed(&(jc[m][n]), ctx)) - || !(cname = edg_wll_QueryRecToColumn(&(jc[m][n]))) ) - break; - - *where_flags |= FL_SEL_STATUS; - if ( conds ) - { - trio_asprintf(&tmps, "%s OR s.%s%s'%s'", conds, cname, opToString(jc[m][n].op), jc[m][n].value.c); - free(conds); conds = tmps; - } - else - trio_asprintf(&conds, "s.%s%s'%s'", cname, opToString(jc[m][n].op), jc[m][n].value.c); - - free(cname); - break; - - default: - /* this may never occure, but keep compiler happy */ - break; - } - - if ( !conds ) continue; - - if ( retconds ) - { - trio_asprintf(&tmps, "%s AND (%s)", retconds, conds); - free(retconds); retconds = tmps; - free(conds); conds = NULL; - } - else - { - trio_asprintf(&retconds, "(%s)", conds); - free(conds); conds = NULL; - } - } - - return retconds; -} - - -static int match_flesh_conditions(const edg_wll_Event *e,const edg_wll_QueryRec **ec) -{ - int i, j; - - - if ( !ec ) - return 1; - - for ( i = 0; ec[i]; i++ ) - { - j = 0; - while ( (ec[i][j].attr) - && (ec[i][j].attr != EDG_WLL_QUERY_ATTR_USERTAG) - && (ec[i][j].attr != EDG_WLL_QUERY_ATTR_INSTANCE) ) j++; - if ( !ec[i][j].attr ) - continue; - - for ( j = 0; ec[i][j].attr; j++ ) - { - if ( ec[i][j].attr == EDG_WLL_QUERY_ATTR_TIME ) - { - if ( ((ec[i][j].op == EDG_WLL_QUERY_OP_EQUAL) && (e->any.timestamp.tv_sec == ec[i][j].value.t.tv_sec)) - || ((ec[i][j].op == EDG_WLL_QUERY_OP_LESS) && (e->any.timestamp.tv_sec < ec[i][j].value.t.tv_sec)) - || ((ec[i][j].op == EDG_WLL_QUERY_OP_GREATER) && (e->any.timestamp.tv_sec < ec[i][j].value.t.tv_sec)) - || ( (ec[i][j].op == EDG_WLL_QUERY_OP_WITHIN) - && (e->any.timestamp.tv_sec >= ec[i][j].value.t.tv_sec) - && (e->any.timestamp.tv_sec <= ec[i][j].value2.t.tv_sec)) ) - break; - } - else if ( ec[i][j].attr == EDG_WLL_QUERY_ATTR_SOURCE ) - { - if ( e->any.source == EDG_WLL_SOURCE_NONE ) - continue; - if ( ((ec[i][j].op == EDG_WLL_QUERY_OP_EQUAL) && (e->any.source == ec[i][j].value.i)) - || ((ec[i][j].op == EDG_WLL_QUERY_OP_LESS) && (e->any.source < ec[i][j].value.i)) - || ((ec[i][j].op == EDG_WLL_QUERY_OP_GREATER) && (e->any.source < ec[i][j].value.i)) - || ( (ec[i][j].op == EDG_WLL_QUERY_OP_WITHIN) - && (e->any.source >= ec[i][j].value.i) - && (e->any.source <= ec[i][j].value2.i)) ) - break; - } - else if ( ec[i][j].attr == EDG_WLL_QUERY_ATTR_LEVEL ) - { - if ( ((ec[i][j].op == EDG_WLL_QUERY_OP_EQUAL) && (e->any.level == ec[i][j].value.i)) - || ((ec[i][j].op == EDG_WLL_QUERY_OP_LESS) && (e->any.level < ec[i][j].value.i)) - || ((ec[i][j].op == EDG_WLL_QUERY_OP_GREATER) && (e->any.level < ec[i][j].value.i)) - || ( (ec[i][j].op == EDG_WLL_QUERY_OP_WITHIN) - && (e->any.level >= ec[i][j].value.i) - && (e->any.level <= ec[i][j].value2.i)) ) - break; - } - else if ( ec[i][j].attr == EDG_WLL_QUERY_ATTR_HOST ) - { - if ( !strcmp(ec[i][j].value.c, e->any.host) ) - break; - } - else if ( ec[i][j].attr == EDG_WLL_QUERY_ATTR_EVENT_TYPE ) - { - if ( e->any.type == ec[i][j].value.i ) - break; - } - else if ( ec[i][j].attr == EDG_WLL_QUERY_ATTR_USERTAG ) - { - if ( !strcmp(ec[i][j].attr_id.tag,e->userTag.name) - && cmp_string(e->userTag.value,ec[i][j].op,ec[i][j].value.c)) - break; - } - else if ( ec[i][j].attr == EDG_WLL_QUERY_ATTR_INSTANCE ) - { - if ( e->any.src_instance - && cmp_string(ec[i][j].value.c, ec[i][j].op, e->any.src_instance) ) - break; - } - } - if ( !ec[i][j].attr ) - /* - * No condition in "or" clause is valid - */ - return 0; - } - - return 1; -} - -/* XXX: has to match exactly the main query in edg_wll_QueryEvents - * and similar one in srv_purge.c - */ -int convert_event_head(edg_wll_Context ctx,char **f,edg_wll_Event *e) -{ - int ret,i; - - memset(e,0,sizeof *e); - edg_wll_ResetError(ctx); - - - if ((ret=edg_wlc_JobIdParse(f[0],&e->any.jobId))) { - edg_wll_SetError(ctx,-ret,"edg_wlc_JobIdParse()"); - goto err; - } - - e->type = atoi(f[1]); - free(f[1]); f[1] = NULL; - - e->any.source = edg_wll_StringToSource(f[2]); - free(f[2]); f[2] = NULL; - - e->any.host = f[3]; - f[3] = NULL; - - e->any.user = f[4]; - f[4] = NULL; - - e->any.timestamp.tv_sec = edg_wll_DBToTime(f[5]); - free(f[5]); f[5] = NULL; - - e->any.timestamp.tv_usec = atoi(f[6]); - free(f[6]); f[6] = NULL; - - e->any.level = atoi(f[7]); - free(f[7]); f[7] = NULL; - - e->any.arrived.tv_sec = edg_wll_DBToTime(f[8]); - e->any.arrived.tv_usec = 0; - free(f[8]); f[8] = NULL; - - return 0; - -err: - edg_wll_FreeEvent(e); - memset(e,0,sizeof *e); - for (i=0; i<9; i++) free(f[i]); - return edg_wll_Error(ctx,NULL,NULL); -} - - - -/* FIXME: other op's, ORed conditions */ -int match_status(edg_wll_Context ctx, const edg_wll_JobStat *stat, const edg_wll_QueryRec **conds) -{ - int i, j, n; - char *s, *s1; - - - if ( !conds ) return 1; - - for ( i = 0; conds[i]; i++ ) - { - for ( j = 0; conds[i][j].attr; j++ ) - { - if ( is_indexed(&(conds[i][j]), ctx) ) goto or_satisfied; - - switch ( conds[i][j].attr ) - { - case EDG_WLL_QUERY_ATTR_STATUS: - switch ( conds[i][j].op ) - { - case EDG_WLL_QUERY_OP_EQUAL: - if ( conds[i][j].value.i == stat->state ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_UNEQUAL: - if ( conds[i][j].value.i != stat->state ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_LESS: - if ( conds[i][j].value.i > stat->state ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_GREATER: - if ( conds[i][j].value.i < stat->state ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_WITHIN: - if ( conds[i][j].value.i <= stat->state - && conds[i][j].value2.i >= stat->state ) goto or_satisfied; - break; - } - break; - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - if ( conds[i][j].op == EDG_WLL_QUERY_OP_EQUAL ) { - if ( conds[i][j].value.i == stat->resubmitted ) goto or_satisfied; - } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) - if ( conds[i][j].value.i != stat->resubmitted ) goto or_satisfied; - break; - case EDG_WLL_QUERY_ATTR_DONECODE: - switch ( conds[i][j].op ) - { - case EDG_WLL_QUERY_OP_EQUAL: - if ( conds[i][j].value.i == stat->done_code ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_UNEQUAL: - if ( conds[i][j].value.i != stat->done_code ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_LESS: - if ( conds[i][j].value.i > stat->done_code ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_GREATER: - if ( conds[i][j].value.i < stat->done_code ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_WITHIN: - if ( conds[i][j].value.i <= stat->done_code - && conds[i][j].value2.i >= stat->done_code ) goto or_satisfied; - break; - } - break; - case EDG_WLL_QUERY_ATTR_EXITCODE: - switch ( conds[i][j].op ) - { - case EDG_WLL_QUERY_OP_EQUAL: - if ( conds[i][j].value.i == stat->exit_code ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_UNEQUAL: - if ( conds[i][j].value.i != stat->exit_code ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_LESS: - if ( conds[i][j].value.i > stat->exit_code ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_GREATER: - if ( conds[i][j].value.i < stat->exit_code ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_WITHIN: - if ( conds[i][j].value.i <= stat->exit_code - && conds[i][j].value2.i >= stat->exit_code ) goto or_satisfied; - break; - } - break; - case EDG_WLL_QUERY_ATTR_OWNER: - if (stat->owner) { - if (conds[i][j].value.c) { - if (!strcmp(conds[i][j].value.c, stat->owner) ) { - if ( conds[i][j].op == EDG_WLL_QUERY_OP_EQUAL ) goto or_satisfied; - } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied; - } else if (ctx->peerName) { - if (!strcmp(ctx->peerName, stat->owner) ) { - if ( conds[i][j].op == EDG_WLL_QUERY_OP_EQUAL ) goto or_satisfied; - } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied; - } - } - break; - case EDG_WLL_QUERY_ATTR_LOCATION: - if ( stat->location ) - { - if ( !strcmp(conds[i][j].value.c, stat->location) ) { - if ( conds[i][j].op == EDG_WLL_QUERY_OP_EQUAL ) goto or_satisfied; - } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied; - } - break; - case EDG_WLL_QUERY_ATTR_DESTINATION: - if ( stat->destination ) - { - if ( !strcmp(conds[i][j].value.c, stat->destination) ) { - if ( conds[i][j].op == EDG_WLL_QUERY_OP_EQUAL ) goto or_satisfied; - } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied; - } - break; - case EDG_WLL_QUERY_ATTR_JOBID: - if ( !stat->jobId ) - break; - s = edg_wlc_JobIdUnparse(stat->jobId); - s1 = edg_wlc_JobIdUnparse(conds[i][j].value.j); - if ( s && s1 ) - { - int r = strcmp(s1, s); - free(s); free(s1); - if ( !r ) { - if ( conds[i][j].op == EDG_WLL_QUERY_OP_EQUAL ) goto or_satisfied; - } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied; - } - break; - case EDG_WLL_QUERY_ATTR_PARENT: - if ( !stat->parent_job ) - break; - s = edg_wlc_JobIdUnparse(stat->parent_job); - s1 = edg_wlc_JobIdUnparse(conds[i][j].value.j); - if ( s && s1 ) - { - int r = strcmp(s1, s); - free(s); free(s1); - if ( !r ) { - if ( conds[i][j].op == EDG_WLL_QUERY_OP_EQUAL ) goto or_satisfied; - } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied; - } - break; - case EDG_WLL_QUERY_ATTR_USERTAG: - if ( !stat->user_tags ) - { - if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) - goto or_satisfied; - - break; - } - for ( n = 0; stat->user_tags[n].tag; n++ ) - if ( !strcasecmp(conds[i][j].attr_id.tag, stat->user_tags[n].tag) ) - { - if ( !strcmp(conds[i][j].value.c, stat->user_tags[n].value) ) { - if ( conds[i][j].op == EDG_WLL_QUERY_OP_EQUAL ) goto or_satisfied; - } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied; - - break; - } - if ( !stat->user_tags[n].tag && conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) - goto or_satisfied; - break; - case EDG_WLL_QUERY_ATTR_TIME: - if ( !stat->stateEnterTimes || !stat->stateEnterTimes[1+conds[i][j].attr_id.state] ) - break; - switch ( conds[i][j].op ) - { - case EDG_WLL_QUERY_OP_EQUAL: - if ( conds[i][j].value.t.tv_sec == stat->stateEnterTimes[1+conds[i][j].attr_id.state] ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_UNEQUAL: - if ( conds[i][j].value.t.tv_sec != stat->stateEnterTimes[1+conds[i][j].attr_id.state] ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_LESS: - if ( conds[i][j].value.t.tv_sec > stat->stateEnterTimes[1+conds[i][j].attr_id.state] ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_GREATER: - if ( conds[i][j].value.t.tv_sec < stat->stateEnterTimes[1+conds[i][j].attr_id.state] ) goto or_satisfied; - break; - case EDG_WLL_QUERY_OP_WITHIN: - if ( conds[i][j].value.t.tv_sec <= stat->stateEnterTimes[1+conds[i][j].attr_id.state] - && conds[i][j].value2.t.tv_sec >= stat->stateEnterTimes[1+conds[i][j].attr_id.state] ) goto or_satisfied; - break; - } - break; - default: - break; - } - } - - /* - * No one condition in "or clause satisfied - */ - return 0; - -or_satisfied: - // just for escaping from nested cycles - ; /* prevent compiler to complain */ - } - - return 1; -} - -static int cmp_string(const char *s1,edg_wll_QueryOp op,const char *s2) -{ - switch (op) { - case EDG_WLL_QUERY_OP_EQUAL: return !strcmp(s1,s2); - case EDG_WLL_QUERY_OP_LESS: return strcmp(s1,s2)<0; - case EDG_WLL_QUERY_OP_GREATER: return strcmp(s1,s2)>0; - default: return 0; - } - return 0; -} - - -int check_strict_jobid(edg_wll_Context ctx, const edg_wlc_JobId job) -{ - char *job_host; - unsigned int job_port; - - edg_wll_ResetError(ctx); - - /* Allow all jobids when server name is not set. */ - if (ctx->srvName == NULL) return edg_wll_Error(ctx,NULL,NULL); - - edg_wlc_JobIdGetServerParts(job,&job_host,&job_port); - - if (strcasecmp(job_host,ctx->srvName) || job_port != ctx->srvPort) - { - char *jobid,msg[300]; - - jobid = edg_wlc_JobIdUnparse(job); - snprintf(msg,sizeof msg,"%s: does not match server address",jobid); - msg[sizeof msg - 1] = 0; - edg_wll_SetError(ctx,EINVAL,msg); - free(jobid); - } - - free(job_host); - return edg_wll_Error(ctx,NULL,NULL); -} - -static int check_strict_jobid_cond(edg_wll_Context ctx, const edg_wll_QueryRec **cond) -{ - int i,j,ret; - - if (!cond) return edg_wll_ResetError(ctx); - for (i=0; cond[i]; i++) for (j=0; cond[i][j].attr; j++) - if (cond[i][j].attr == EDG_WLL_QUERY_ATTR_JOBID && - (ret = check_strict_jobid(ctx,cond[i][j].value.j))) - return ret; - - return 0; -} - -static int is_all_query(const edg_wll_QueryRec **jc) -{ - if (!jc || !*jc) return 1; - - if (jc[0][0].attr == EDG_WLL_QUERY_ATTR_OWNER && - jc[0][0].op == EDG_WLL_QUERY_OP_EQUAL && - !jc[0][1].attr && !jc[1]) return 1; - - return 0; -} diff --git a/org.glite.lb.server/src/query.h b/org.glite.lb.server/src/query.h deleted file mode 100644 index fe9c9e8..0000000 --- a/org.glite.lb.server/src/query.h +++ /dev/null @@ -1,5 +0,0 @@ -int convert_event_head(edg_wll_Context,char **,edg_wll_Event *); -int check_strict_jobid(edg_wll_Context, const edg_wlc_JobId); -int match_status(edg_wll_Context, const edg_wll_JobStat *stat,const edg_wll_QueryRec **conditions); - -#define NOTIF_ALL_JOBS "all_jobs" diff --git a/org.glite.lb.server/src/request.c b/org.glite.lb.server/src/request.c deleted file mode 100644 index 0424043..0000000 --- a/org.glite.lb.server/src/request.c +++ /dev/null @@ -1,96 +0,0 @@ -#ident "$Header$" - -#include -#include -#include - -#include "glite/lb/il_string.h" -#include "glite/lb/context-int.h" - -#include "store.h" - -#ifdef __GNUC__ -#define UNUSED_VAR __attribute__((unused)) -#else -#define UNUSED_VAR -#endif - -int -handle_request(edg_wll_Context ctx,char *buf, int len UNUSED_VAR) -{ - char *p = buf; - char *event, *ucs; - int ret; - - edg_wll_ResetError(ctx); - - p = get_string(p, &ucs); - if(p == NULL) return edg_wll_SetError(ctx,EDG_WLL_IL_PROTO,"reading UCS"); - - p = get_string(p, &event); - if(p == NULL) { - edg_wll_SetError(ctx,EDG_WLL_IL_PROTO,"reading event string"); - if(ucs) free(ucs); - return EDG_WLL_IL_PROTO; - } - - ret = db_store(ctx,ucs, event); - - if(ucs) - free(ucs); - if(event) - free(event); - - return(ret); -} - - -int -create_reply(const edg_wll_Context ctx,char *buf, int max_len) -{ - int len, err_code, err_code_min; - char *p; - char *err_msg; - - err_code_min = 0; - - switch(edg_wll_Error(ctx,NULL,&err_msg)) { - - case 0: - err_code = LB_OK; - break; - - case ENOMEM: - err_code = LB_NOMEM; - break; - - case EDG_WLL_IL_PROTO: - err_code = LB_PROTO; - break; - - default: - err_code = LB_DBERR; - err_code_min = edg_wll_Error(ctx,NULL,NULL); - break; - - } - - if (!err_msg) err_msg=strdup("OK"); - - len = 17 + len_int(err_code) + len_int(err_code_min) + len_string(err_msg); - if(len > max_len) { - free(err_msg); - return(0); - } - - snprintf(buf, max_len, "%16d\n", len - 17); - p = buf + 17; - p = put_int(p, err_code); - p = put_int(p, err_code_min); - p = put_string(p, err_msg); - free(err_msg); - - return(len); -} - - diff --git a/org.glite.lb.server/src/seqcode.c b/org.glite.lb.server/src/seqcode.c deleted file mode 100644 index 584e43e..0000000 --- a/org.glite.lb.server/src/seqcode.c +++ /dev/null @@ -1,63 +0,0 @@ -#include - -#include "glite/lb/context-int.h" -#include "glite/lb/trio.h" - -#include "get_events.h" -#include "store.h" -#include "lock.h" -#include "jobstat.h" -/* -#include "lb_authz.h" -*/ - - - -int edg_wll_QuerySequenceCodeServer(edg_wll_Context ctx, edg_wlc_JobId jobid, const char *source, char **seqcode) -{ - edg_wll_Stmt sh; - intJobStat *istat = NULL; - char *jobid_md5 = NULL, - *stmt = NULL, - *res = NULL, - *res_rest = NULL; - int nstates; - - - edg_wll_ResetError(ctx); - jobid_md5 = edg_wlc_JobIdGetUnique(jobid); - - trio_asprintf(&stmt, - "select int_status from states " - "where jobid='%|Ss' and version='%|Ss'", - jobid_md5, INTSTAT_VERSION); - - if ( stmt == NULL ) return edg_wll_SetError(ctx, ENOMEM, NULL); - - if ( (nstates = edg_wll_ExecStmt(ctx, stmt, &sh)) < 0 ) goto cleanup; - if ( nstates == 0 ) { - edg_wll_SetError(ctx, ENOENT, "no state in DB"); - goto cleanup; - } - if ( edg_wll_FetchRow(sh, &res) < 0 ) goto cleanup; - - istat = dec_intJobStat(res, &res_rest); - if ( res_rest && istat ) { - *seqcode = istat->last_seqcode; - istat->last_seqcode = NULL; - } - else edg_wll_SetError(ctx, EDG_WLL_ERROR_DB_CALL, - "error decoding DB intJobStatus"); - -cleanup: - free(res); - free(jobid_md5); - free(stmt); - edg_wll_FreeStmt(&sh); - if ( istat ) { - destroy_intJobStat(istat); - free(istat); - } - - return edg_wll_Error(ctx, NULL, NULL); -} diff --git a/org.glite.lb.server/src/server_state.c b/org.glite.lb.server/src/server_state.c deleted file mode 100644 index d2bf8f0..0000000 --- a/org.glite.lb.server/src/server_state.c +++ /dev/null @@ -1,54 +0,0 @@ -#ident "$Header$" - -#include "glite/lb/trio.h" -#include "glite/lb/context-int.h" - -#include "lbs_db.h" -#include "server_state.h" - -int edg_wll_GetServerState(edg_wll_Context ctx,const char *name,char **val) -{ - char *stmt = NULL; - edg_wll_Stmt q = NULL; - - - trio_asprintf(&stmt,"select value from server_state " - "where prefix = 'https://%|Ss:%d' and name = '%|Ss'", - ctx->srvName,ctx->srvPort,name); - - switch (edg_wll_ExecStmt(ctx,stmt,&q)) { - case 0: edg_wll_SetError(ctx,ENOENT,name); break; - case -1: break; - default: edg_wll_FetchRow(q,val); break; - } - - edg_wll_FreeStmt(&q); - free(stmt); - return edg_wll_Error(ctx,NULL,NULL); -} - -int edg_wll_SetServerState(edg_wll_Context ctx,const char *name,const char *val) -{ - char *stmt = NULL; - - trio_asprintf(&stmt,"insert into server_state (prefix,name,value) " - "values ('https://%|Ss:%d','%|Ss','%|Ss')", - ctx->srvName,ctx->srvPort,name,val); - - switch(edg_wll_ExecStmt(ctx,stmt,NULL)) { - case 1: break; - case -1: if (edg_wll_Error(ctx,NULL,NULL) == EEXIST) { - free(stmt); - trio_asprintf(&stmt,"update server_state set value = '%|Ss' " - "where prefix = 'https://%|Ss:%d' " - "and name = '%|Ss'", - val,ctx->srvName,ctx->srvPort,name); - edg_wll_ExecStmt(ctx,stmt,NULL); - } - break; - - default: abort(); - } - free(stmt); - return edg_wll_Error(ctx,NULL,NULL); -} diff --git a/org.glite.lb.server/src/server_state.h b/org.glite.lb.server/src/server_state.h deleted file mode 100644 index 029fb7c..0000000 --- a/org.glite.lb.server/src/server_state.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _EDG_WORKLOAD_LOGGING_LBSERVER_H_ -#define EDG_WLL_STATE_DUMP_START "StartDump" -#define EDG_WLL_STATE_DUMP_END "EndDump" - -#ident "$Header$" - -int edg_wll_GetServerState(edg_wll_Context,const char *,char **); -int edg_wll_SetServerState(edg_wll_Context,const char *,const char *); - -#endif diff --git a/org.glite.lb.server/src/srv_purge.c b/org.glite.lb.server/src/srv_purge.c deleted file mode 100644 index 58a843d..0000000 --- a/org.glite.lb.server/src/srv_purge.c +++ /dev/null @@ -1,562 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" - -#include "glite/lb/trio.h" -#include "glite/lb/context-int.h" -#include "glite/lb/events_parse.h" -#include "glite/lb/mini_http.h" -#include "glite/lb/ulm_parse.h" - -#include "lb_html.h" -#include "lb_proto.h" -#include "store.h" -#include "lock.h" -#include "lbs_db.h" -#include "query.h" -#include "get_events.h" -#include "glite/lb/purge.h" -#include "glite/lb/load.h" -#include "glite/lb/dump.h" -#include "purge.h" -#include "lb_xml_parse.h" - - -#define DUMP_FILE_STORAGE "/tmp/" - -#define sizofa(a) (sizeof(a)/sizeof((a)[0])) - -static const char* const resp_headers[] = { - "Cache-Control: no-cache", - "Accept: application/x-dglb", - "User-Agent: edg_wll_Server/" PROTO_VERSION "/" COMP_PROTO, - "Content-Type: application/x-dglb", - NULL -}; - -static int purge_one(edg_wll_Context ctx,const edg_wlc_JobId,int,int); - -int edg_wll_CreateTmpFileStorage(edg_wll_Context ctx, char *prefix, char **fname) -{ - char fname_buf[1024]; - struct timeval tv; - int retfd; - - - while ( 1 ) - { - gettimeofday(&tv, NULL); - snprintf(fname_buf, 1024, "%s/%ld_%ld", prefix, tv.tv_sec, tv.tv_usec); - - if ( (retfd = open(fname_buf, O_WRONLY|O_CREAT|O_EXCL|O_APPEND,0600)) == -1 ) - { - if ( errno != EEXIST ) - { - char buff[100]; - - sprintf(buff, "couldn't create temporary server file"); - return edg_wll_SetError(ctx, errno, buff); - } - } - else - break; - } - - *fname = strdup(fname_buf); - - return retfd; -} - -int edg_wll_CreateFileStorageFromTmp(edg_wll_Context ctx, char *old_file, char *file_type, char **fname) -{ - char fname_buf[1024], - fname_prefix[1024], - stimebuf[100]; - char *stmp; - struct timeval tv; - int retfd; - - - if ( (stmp = strrchr(old_file, '/')) ) - { - strncpy(fname_prefix, old_file, stmp - old_file); - fname_prefix[stmp - old_file] = '\0'; - } - - while ( 1 ) - { - gettimeofday(&tv, NULL); - edg_wll_ULMTimevalToDate(tv.tv_sec, tv.tv_usec, stimebuf); - snprintf(fname_buf, 1024, "%s/%s_%s", fname_prefix, file_type, stimebuf); - - if ( !link(old_file, fname_buf) ) - break; - - if ( errno != EEXIST ) - { - char buff[100]; - - sprintf(buff, "couldn't create server %s file", file_type); - return edg_wll_SetError(ctx, errno, buff); - } - } - - *fname = strdup(fname_buf); - - return retfd; -} - -int edg_wll_CreateFileStorage(edg_wll_Context ctx, char *file_type, char *prefix, char **fname) -{ - char fname_buf[1024], - stimebuf[100]; - struct timeval tv; - int retfd; - - if ( *fname ) - { - snprintf(fname_buf, 1024, "%s/%s", prefix? prefix: "", *fname); - if ( (retfd = open(*fname, O_WRONLY|O_CREAT|O_EXCL|O_APPEND,0600)) == -1 ) - { - char buff[100]; - if ( errno == EEXIST ) - sprintf(buff, "Server file %s exist", fname_buf); - else - sprintf(buff, "Server couldn't create file %s", fname_buf); - edg_wll_SetError(ctx, errno, buff); - - return -1; - } - if ( prefix ) - { - free(*fname); - *fname = strdup(fname_buf); - } - - return retfd; - } - - while ( 1 ) - { - gettimeofday(&tv, NULL); - edg_wll_ULMTimevalToDate(tv.tv_sec, tv.tv_usec, stimebuf); - if ( !prefix ) - { - if ( strcmp(file_type,FILE_TYPE_PURGE) == 0 ) - prefix = ctx->purgeStorage; - else if ( strcmp(file_type,FILE_TYPE_DUMP) == 0 ) - prefix = ctx->dumpStorage; - else - prefix = ""; - } - snprintf(fname_buf, 1024, "%s/%s_%s", prefix, file_type, stimebuf); - - if ( (retfd = open(fname_buf, O_WRONLY|O_CREAT|O_EXCL|O_APPEND,0600)) == -1 ) - { - if ( errno != EEXIST ) - { - char buff[100]; - - sprintf(buff, "couldn't create server %s file", file_type); - edg_wll_SetError(ctx, errno, buff); - - return -1; - } - } - else - break; - } - - *fname = strdup(fname_buf); - - return retfd; -} - -int edg_wll_PurgeServer(edg_wll_Context ctx,const edg_wll_PurgeRequest *request) -{ - int i,parse = 0,dumpfile = -1; - edg_wlc_JobId job; - char *message = NULL, *response = NULL; - char *tmpfname; - int naffected_jobs = 0; - edg_wll_PurgeResult result; - int ret = HTTP_OK; - - - if (!ctx->noAuth) { - edg_wll_SetError(ctx,EPERM,"only superusers may purge"); - goto abort; - } - - edg_wll_ResetError(ctx); - memset(&result, 0, sizeof(edg_wll_PurgeResult)); - - - if ( (request->flags & EDG_WLL_PURGE_SERVER_DUMP) && - ((dumpfile = edg_wll_CreateTmpPurgeFile(ctx, &tmpfname)) == -1 ) ) - return edg_wll_Error(ctx, NULL, NULL); - - if (request->flags&EDG_WLL_PURGE_REALLY_PURGE) { - edg_wll_DumpRequest req = { - EDG_WLL_DUMP_LAST_END, EDG_WLL_DUMP_NOW - }; - edg_wll_DumpResult res; - - if (edg_wll_DumpEvents(ctx,&req,&res)) - { - if ( request->flags & EDG_WLL_PURGE_SERVER_DUMP ) - unlink(tmpfname); - return edg_wll_Error(ctx, NULL, NULL); - } - } - - if (request->jobs) for (i=0; request->jobs[i]; i++) { - if (edg_wlc_JobIdParse(request->jobs[i],&job)) { - fprintf(stderr,"%s: parse error\n",request->jobs[i]); - parse = 1; - } - else { - if (check_strict_jobid(ctx,job)) { - fprintf(stderr,"%s: not my job\n",request->jobs[i]); - parse = 1; - } - else { - switch (purge_one(ctx,job,dumpfile,request->flags&EDG_WLL_PURGE_REALLY_PURGE)) { - case 0: if (request->flags & EDG_WLL_PURGE_LIST_JOBS) { - result.jobs = realloc(result.jobs,(naffected_jobs+2) * sizeof(*result.jobs)); - result.jobs[naffected_jobs] = strdup(request->jobs[i]); - result.jobs[naffected_jobs+1] = NULL; - } - naffected_jobs++; - break; - case ENOENT: parse = 1; - edg_wll_ResetError(ctx); - break; - default: goto abort; - } - - } - edg_wlc_JobIdFree(job); - } - } - else { - edg_wll_Stmt s; - char *job_s; - int res; - time_t timeout[EDG_WLL_NUMBER_OF_STATCODES], - now = time(NULL); - - for (i=0; itimeout[i] < 0 ? ctx->purge_timeout[i] : request->timeout[i]; - - if (edg_wll_ExecStmt(ctx,"select dg_jobid from jobs",&s) < 0) goto abort; - while ((res = edg_wll_FetchRow(s,&job_s)) > 0) { - if (edg_wlc_JobIdParse(job_s,&job)) { - fprintf(stderr,"%s: parse error (internal inconsistency !)\n",job_s); - parse = 1; - } - else { - edg_wll_JobStat stat; - - if (check_strict_jobid(ctx,job)) { - edg_wlc_JobIdFree(job); - free(job_s); - parse = 1; - continue; - } - - memset(&stat,0,sizeof stat); - if (edg_wll_JobStatus(ctx,job,0,&stat)) goto abort; /* XXX: memory leak */ - - switch (stat.state) { - case EDG_WLL_JOB_CLEARED: - case EDG_WLL_JOB_ABORTED: - case EDG_WLL_JOB_CANCELLED: - i = stat.state; - break; - default: - i = EDG_WLL_PURGE_JOBSTAT_OTHER; - } - - if (now-stat.lastUpdateTime.tv_sec > timeout[i] && !check_strict_jobid(ctx,job)) - { - if (purge_one(ctx,job,dumpfile,request->flags&EDG_WLL_PURGE_REALLY_PURGE)) - goto abort; - - /* XXX: change with the streaming interface */ - if (request->flags & EDG_WLL_PURGE_LIST_JOBS) { - result.jobs = realloc(result.jobs,(naffected_jobs+2) * sizeof(*result.jobs)); - result.jobs[naffected_jobs] = job_s; - result.jobs[naffected_jobs+1] = NULL; - job_s = NULL; - } - naffected_jobs++; - } - - edg_wlc_JobIdFree(job); - edg_wll_FreeStatus(&stat); - free(job_s); - } - } - edg_wll_FreeStmt(&s); -abort: - // just for escaping from nested cycles - ; /* prevent compiler to complain */ - } - - if (parse && !edg_wll_Error(ctx,NULL,NULL)) - { - if ( naffected_jobs ) - edg_wll_SetError(ctx,EINVAL,"Invalid JobId(s) but other jobs purged"); - else - edg_wll_SetError(ctx,EINVAL,"Invalid JobId(s)"); - } - - switch ( edg_wll_Error(ctx,NULL,NULL) ) - { - case 0: - ret = HTTP_OK; - break; - case EINVAL: - ret = HTTP_INVALID; - break; - case EPERM: - ret = HTTP_UNAUTH; - break; - - /* fatal errors */ - case ENOMEM: - /* fall through */ - default: - ret = HTTP_INTERNAL; - break; - } - - if (ret != HTTP_INTERNAL) { - if ( request->flags & EDG_WLL_PURGE_SERVER_DUMP ) - { - edg_wll_CreatePurgeFileFromTmp(ctx, tmpfname, &(result.server_file)); - unlink(tmpfname); - } - - if ( edg_wll_PurgeResultToXML(ctx, &result, &message) ) - ret = HTTP_INTERNAL; - else - printf("%s", message); - } - - if ( result.server_file ) - free(result.server_file); - if ( result.jobs ) - { - for ( i = 0; result.jobs[i]; i++ ) - free(result.jobs[i]); - free(result.jobs); - } - - asprintf(&response, "HTTP/1.1 %d %s", ret, edg_wll_HTTPErrorMessage(ret)); - - edg_wll_http_send(ctx, response, resp_headers, message); - - return edg_wll_Error(ctx,NULL,NULL); -} - -static void unlock_and_check(edg_wll_Context ctx,edg_wlc_JobId job) -{ - char *job_s,*et,*ed; - - if (edg_wll_UnlockJob(ctx,job)) { - job_s = edg_wlc_JobIdUnparse(job); - - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"%s: edg_wll_UnlockJob(): %s (%s) -- expect bogus things\n", - job_s,et,ed); - syslog(LOG_CRIT,"%s: edg_wll_UnlockJob(): %s (%s) -- expect bogus things", - job_s,et,ed); - free(et); free(ed); free(job_s); - } -} - - -int purge_one(edg_wll_Context ctx,const edg_wlc_JobId job,int dump, int purge) -{ - char *dbjob; - char *stmt = NULL; - edg_wll_Stmt q; - int ret,dumped = 0; - - edg_wll_ResetError(ctx); - if ( !purge && dump < 0 ) return 0; - - dbjob = edg_wlc_JobIdGetUnique(job); /* XXX: strict jobid already checked */ - if (edg_wll_LockJob(ctx,job)) goto clean; - - if ( purge ) - { - trio_asprintf(&stmt,"delete from jobs where jobid = '%|Ss'",dbjob); - ret = edg_wll_ExecStmt(ctx,stmt,NULL); - if (ret <= 0) { - unlock_and_check(ctx,job); - if (ret == 0) { - fprintf(stderr,"%s: no such job\n",dbjob); - edg_wll_SetError(ctx,ENOENT,dbjob); - } - goto clean; - } - free(stmt); stmt = NULL; - - trio_asprintf(&stmt,"delete from states where jobid = '%|Ss'",dbjob); - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) { - unlock_and_check(ctx,job); - goto clean; - } - free(stmt); stmt = NULL; - -/* Why on earth ? - trio_asprintf(&stmt,"delete from states where jobid = '%|Ss'",dbjob); - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) { - unlock_and_check(ctx,job); - goto clean; - } - free(stmt); stmt = NULL; -*/ - - } - - if (!ctx->strict_locking) unlock_and_check(ctx,job); - - if ( purge ) - { - trio_asprintf(&stmt,"delete from status_tags where jobid = '%|Ss'",dbjob); - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) goto unlock; - free(stmt); stmt = NULL; - } - - if (dump >= 0) - trio_asprintf(&stmt, - "select event,code,prog,host,u.cert_subj,time_stamp,usec,level,arrived " - "from events e,users u " - "where e.jobid='%|Ss' " - "and u.userid=e.userid " - "order by event", dbjob); - else - trio_asprintf(&stmt,"select event from events " - "where jobid='%|Ss' " - "order by event", dbjob); - -/* check for events repeatedly -- new one may have arrived in the meantime */ - while ((ret = edg_wll_ExecStmt(ctx,stmt,&q)) > 0) { - char *res[9]; - - dumped = 1; - while ((ret = edg_wll_FetchRow(q,res)) > 0) { - int event; - - event = atoi(res[0]); - free(res[0]); res[0] = NULL; - - if (dump >= 0) { - edg_wll_Event e; - - assert(ret == 9); - res[0] = edg_wlc_JobIdUnparse(job); - if (convert_event_head(ctx,res,&e) || edg_wll_get_event_flesh(ctx,event,&e)) - { - char *et,*ed; - int i; - - /* Most likely sort of internal inconsistency. - * Must not be fatal -- just complain - */ - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"%s event %d: %s (%s)\n",dbjob,event,et,ed); - syslog(LOG_WARNING,"%s event %d: %s (%s)",dbjob,event,et,ed); - free(et); free(ed); - for (i=0; istrict_locking) unlock_and_check(ctx,job); - fprintf(stderr,"%s: no events, i.e. no such job or internal inconsistency\n",dbjob); - edg_wll_SetError(ctx,ENOENT,dbjob); - goto clean; - } - -unlock: - if (ctx->strict_locking) unlock_and_check(ctx,job); - -clean: - free(dbjob); - free(stmt); - return edg_wll_Error(ctx,NULL,NULL); -} diff --git a/org.glite.lb.server/src/store.c.T b/org.glite.lb.server/src/store.c.T deleted file mode 100644 index 47a894f..0000000 --- a/org.glite.lb.server/src/store.c.T +++ /dev/null @@ -1,565 +0,0 @@ -#ident "$Header$" - -/* - -@@@AUTO - - * XXX: still lots of hardcoded stuff - * there's mapping db.column <-> event struct field - */ - -@@@LANG: C - -#include -#include -#include -#include -#include -#include - -#include - -#include "glite/wmsutils/jobid/strmd5.h" - -#include "glite/lb/events_parse.h" -#include "glite/lb/context-int.h" -#include "glite/lb/producer.h" -#include "glite/lb/log_proto.h" /* for EDG_WLL_LOG_USER_DEFAULT */ -#include "glite/lb/trio.h" - -#include "store.h" -#include "get_events.h" -#include "lbs_db.h" -#include "lock.h" -#include "lb_authz.h" - -static int store_user(edg_wll_Context,const char *,const char *); -static int store_job(edg_wll_Context,const edg_wlc_JobId,const char *); -static int store_flesh(edg_wll_Context,edg_wll_Event *,char *,int); -static int store_seq(edg_wll_Context,edg_wll_Event *,int); -static int check_dup(edg_wll_Context,edg_wll_Event *); -static int check_auth(edg_wll_Context,edg_wll_Event *e); -static int register_subjobs(edg_wll_Context,const edg_wll_RegJobEvent *); - -void edg_wll_StoreAnonymous(edg_wll_Context ctx,int anon) { - ctx->allowAnonymous = anon; -} - -int edg_wll_StoreEvent(edg_wll_Context ctx,edg_wll_Event *e,int *seq) -{ - edg_wll_ErrorCode err = 0; - char *userid = NULL,*jobid,*stmt; - char *select_max,*ssrc; - edg_wll_Stmt sh = NULL; - int next = 0xDEAD; - char *now_s = NULL; - - ssrc = jobid = stmt = select_max = NULL; - - if ( ctx->event_load ) - now_s = strdup(edg_wll_TimeToDB(e->any.arrived.tv_sec)); - else - now_s = strdup(edg_wll_TimeToDB(time(NULL))); - edg_wll_ResetError(ctx); - switch (err = check_auth(ctx,e)) { - case 0: break; - case ENOENT: goto clean; - case EPERM: - if (!ctx->noAuth) goto clean; - edg_wll_ResetError(ctx); - break; - default: goto clean; - } - if ((err = check_dup(ctx,e))) goto clean; - - userid = strdup(strmd5(e->any.user,NULL)); - -/* make sure user record is there */ - if ((err = store_user(ctx,userid,e->any.user))) goto clean; - - jobid = edg_wlc_JobIdGetUnique(e->any.jobId); - -/* only REGJOB events determine job owner now */ - if (e->type == EDG_WLL_EVENT_REGJOB && - (err = store_job(ctx,e->any.jobId,userid))) goto clean; - - -/* obtain next event sequence number */ - trio_asprintf(&select_max, - "select max(event) from events " - "where jobid = '%|Ss'",jobid); - - ssrc = edg_wll_SourceToString(e->any.source); - -/* try to insert (someone else may be doing the same) */ - while (1) { - char *max; - - if (edg_wll_ExecStmt(ctx,select_max,&sh) < 0 || - edg_wll_FetchRow(sh,&max) < 0) - { - err = edg_wll_Error(ctx,NULL,NULL); - goto clean; - } - edg_wll_FreeStmt(&sh); - - next = max && *max ? atoi(max)+1 : 0; - - /* store an UNDEF event first in order to prevent race condition - * with readers */ - trio_asprintf(&stmt, - "insert into events(jobid,event,code,prog,host,time_stamp,usec,arrived,level,userid) " - "values ('%|Ss',%d,%d,'%|Ss','%|Ss',%s,%d,'%|Ss',%d,'%|Ss')", - jobid,next,EDG_WLL_EVENT_UNDEF,ssrc,e->any.host, - edg_wll_TimeToDB(e->any.timestamp.tv_sec),e->any.timestamp.tv_usec, - now_s, e->any.level,userid); - - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) { - if ((err = edg_wll_Error(ctx,NULL,NULL)) != EEXIST) - goto clean; - } else break; /* successful insert */ - - /* we were late -- try once again */ - free(stmt); - } - - free(stmt); - if ((err = store_seq(ctx,e,next)) || - (err = store_flesh(ctx,e,jobid,next))) { - /* attempt to cleanup, ignore new errors */ - char *desc; - edg_wll_ErrorCode oerr = edg_wll_Error(ctx,NULL,&desc); - - edg_wll_delete_event(ctx,jobid,next); - edg_wll_SetError(ctx,oerr,desc); - free(desc); - } - else { - /* emulate commit, i.e. swith to a real event type to make - * the record valid */ - trio_asprintf(&stmt, - "update events set code=%d " - "where jobid='%|Ss' and event=%d", - (int) e->any.type,jobid,next); - switch (edg_wll_ExecStmt(ctx,stmt,NULL)) { - case 0: if (ctx->strict_locking) - err = edg_wll_SetError(ctx,ENOENT,"event disappeared on store while strict locking"); - /* purge in progres: drop the garbage, ignore errors */ - else { - edg_wll_delete_event(ctx,jobid,next); - err = edg_wll_SetError(ctx,ENOENT,"job being purged"); - } - break; - case 1: if (ctx->strict_locking) err = 0; - else { - /* check whether the job is still there to prevent garbage - * left while there is a concurrent purge - */ - free(stmt); - trio_asprintf(&stmt, - "select 'x' from jobs where jobid='%|Ss'", - jobid); - switch (edg_wll_ExecStmt(ctx,stmt,NULL)) { - case 1: break; - case 0: /* purge in progres */ - edg_wll_delete_event(ctx,jobid,next); - err = edg_wll_SetError(ctx,ENOENT,"job being purged"); - break; - default: err = edg_wll_SetError(ctx,EDG_WLL_ERROR_DB_CALL, - "more job records, what is that?"); - break; - } - } - break; - case -1: err = edg_wll_Error(ctx,NULL,NULL); - break; - - default: err = edg_wll_SetError(ctx,EDG_WLL_ERROR_DB_CALL, - "more event records, what is that?"); - break; - } - } - - if (err == 0 && - e->any.type == EDG_WLL_EVENT_REGJOB && - (e->regJob.jobtype == EDG_WLL_REGJOB_DAG || - e->regJob.jobtype == EDG_WLL_REGJOB_PARTITIONED) && - e->regJob.nsubjobs > 0) err = register_subjobs(ctx,&e->regJob); - - -clean: - free(now_s); - free(userid); - free(jobid); - free(stmt); - free(ssrc); - free(select_max); - if (sh) edg_wll_FreeStmt(&sh); - if (!err && seq) *seq = next; - return err; -} - -static int store_user(edg_wll_Context ctx,const char *userid,const char *subj) -{ - char *stmt; - - trio_asprintf(&stmt,"insert into users(userid,cert_subj) " - "values ('%|Ss','%|Ss')",userid,subj); - - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) { - if (edg_wll_Error(ctx,NULL,NULL) == EEXIST) - edg_wll_ResetError(ctx); - } - - free(stmt); - return edg_wll_Error(ctx,NULL,NULL); -} - -static int store_job(edg_wll_Context ctx,const edg_wlc_JobId job,const char *userid) -{ - char *jobstr = edg_wlc_JobIdUnparse(job); - char *jobid = edg_wlc_JobIdGetUnique(job); - char *stmt; - -/* debug Duplicate key on index: Duplicate entry '(nil)' for key 1 - */ - if (jobid == NULL || jobstr == NULL) - return edg_wll_SetError(ctx,EINVAL,"store_job()"); - - edg_wll_ResetError(ctx); - trio_asprintf(&stmt,"insert into jobs(jobid,dg_jobid,userid) " - "values ('%|Ss','%|Ss','%|Ss')",jobid,jobstr,userid); - - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) { - if (edg_wll_Error(ctx,NULL,NULL) == EEXIST) - edg_wll_ResetError(ctx); - } - free(stmt); - free(jobstr); - free(jobid); - return edg_wll_Error(ctx,NULL,NULL); -} - -/* - * XXX: store it in SHORT_FIELDS for now despite it should go to dedicated - * column in EVENTS. - * - * don't want to change the database structure now, will be done anyway - * soon - */ -static int store_seq(edg_wll_Context ctx,edg_wll_Event *e,int no) -{ - int ret; - char *stmt; - char *jobid = edg_wlc_JobIdGetUnique(e->any.jobId); - - edg_wll_ResetError(ctx); - trio_asprintf(&stmt,"insert into short_fields(jobid,event,name,value) " - "values ('%|Ss',%d,'SEQCODE','%|Ss')", - jobid,no,e->any.seqcode); - - ret = edg_wll_ExecStmt(ctx,stmt,NULL); - free(stmt); - free(jobid); - - return ret>=0 ? 0 : edg_wll_Error(ctx,NULL,NULL); -} - -#define SHORT_LEN 255 /* short_fiels.value db column lenght */ - -static int store_flesh(edg_wll_Context ctx,edg_wll_Event *e,char *jobid,int no) -{ - struct { - char *key; - char *val; - } f[20]; - - char *stmt; - unsigned int i; - int err = 0; - - edg_wll_ResetError(ctx); - memset(f,0,sizeof(f)); assert(f[0].key == NULL); - - switch (e->type) { -@@@{ - for my $type (getTypesOrdered $event) { - next if $type eq '_common_'; - selectType $event $type; - my $uctype = uc $type; - my $flctype = lcfirst $type; - gen qq{ -! case EDG_WLL_EVENT_$uctype: -}; - my $idx = 0; - for (getFieldsOrdered $event) { - my $f = selectField $event $_; - my $name = getName $f; - my $ucname = uc $name; - my $fucname = ucfirst $name; - my $tos = $f->{codes} ? - "f[$idx].val = edg_wll\_$type${fucname}ToString(e->$flctype.$name);" : - toString $f "e->$flctype.$name","f[$idx].val"; - gen qq{ -! f[$idx].key = "$ucname"; -! $tos -}; - $idx++; - } - gen qq{ -! assert($idxany.src_instance); - if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) err = edg_wll_Error(ctx,NULL,NULL); - free(stmt); - - return err; -} - -static int check_dup(edg_wll_Context ctx,edg_wll_Event *e) -{ - int i,dup_detected = 0; - int err; - char *es,*es2; - edg_wll_QueryRec jc[2],ec[2]; - edg_wll_QueryRec **jca, **eca; - edg_wll_Event *e2; - - edg_wll_ResetError(ctx); - - jc[0].attr = EDG_WLL_QUERY_ATTR_JOBID; - jc[0].value.j = e->any.jobId; - jc[0].op = EDG_WLL_QUERY_OP_EQUAL; - jc[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; - - ec[0].attr = EDG_WLL_QUERY_ATTR_TIME; - memcpy(&ec[0].value.t,&e->any.timestamp,sizeof(struct timeval)); - ec[0].op = EDG_WLL_QUERY_OP_EQUAL; - ec[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; - - jca = (edg_wll_QueryRec **) malloc (2 * sizeof(edg_wll_QueryRec **)); - eca = (edg_wll_QueryRec **) malloc (2 * sizeof(edg_wll_QueryRec **)); - jca[0] = jc; - jca[1] = NULL; - eca[0] = ec; - eca[1] = NULL; - - err = edg_wll_QueryEventsServer(ctx,1,(const edg_wll_QueryRec **)jca, - (const edg_wll_QueryRec **)eca,&e2); - switch (err) { - case 0: /* continue normally */ - break; - case ENOENT: - free(jca); - free(eca); - return edg_wll_ResetError(ctx); - break; - default: - free(jca); - free(eca); - return edg_wll_Error(ctx,NULL,NULL); - break; - } - - es = edg_wll_UnparseEvent(ctx,e); - assert(es); - - for (i=0;e2[i].type && !dup_detected;i++) { - /* Ignore priority */ - e2[i].any.priority = e->any.priority; - es2 = edg_wll_UnparseEvent(ctx,e2+i); - assert(es2); - if (!strcmp(es,es2)) { - dup_detected = 1; - edg_wll_SetError(ctx,EEXIST,"duplicate event"); - } - free(es2); - } - - free(jca); - free(eca); - free(es); - for (i=0; e2[i].type; i++) edg_wll_FreeEvent(e2+i); - free(e2); - return edg_wll_Error(ctx,NULL,NULL); -} - -static int check_auth(edg_wll_Context ctx,edg_wll_Event *e) -{ - char *jobid = edg_wlc_JobIdGetUnique(e->any.jobId); - char *q = NULL,*owner = NULL; - edg_wll_Stmt stmt = NULL; - char *user; - - edg_wll_ResetError(ctx); - - if (e->type == EDG_WLL_EVENT_REGJOB) - return strcmp(e->any.user,EDG_WLL_LOG_USER_DEFAULT) ? - 0 : edg_wll_SetError(ctx,EPERM,"can't register jobs anonymously"); - - trio_asprintf(&q,"select userid from jobs where jobid='%|Ss'",jobid); - - if (edg_wll_ExecStmt(ctx,q,&stmt) < 0 - || edg_wll_FetchRow(stmt,&owner) < 0 - ) goto clean; - - if (!owner) { - edg_wll_SetError(ctx,ENOENT,"job not registered"); - goto clean; - } - - switch (e->any.source) { - case EDG_WLL_SOURCE_USER_INTERFACE: - case EDG_WLL_SOURCE_LRMS: - case EDG_WLL_SOURCE_APPLICATION: - user = strmd5(e->any.user,NULL); - if (strcmp(owner,user)) edg_wll_SetError(ctx,EPERM,"check_auth()"); - break; - default: - /* XXX: just don't allow anonymous */ - if (!strcmp(e->any.user,EDG_WLL_LOG_USER_DEFAULT)) - edg_wll_SetError(ctx,EPERM,"check_auth()"); - break; - } - - -clean: - if (stmt) edg_wll_FreeStmt(&stmt); - free(q); - free(owner); - return edg_wll_Error(ctx,NULL,NULL); -} - -static int register_subjobs(edg_wll_Context ctx,const edg_wll_RegJobEvent *e) -{ - int i,err; - edg_wlc_JobId *subjobs; - struct timeval now; - - edg_wll_ResetError(ctx); - if (e->nsubjobs == 0) return 0; - if (e->nsubjobs < 0) return edg_wll_SetError(ctx,EINVAL,"negative number of subjobs"); - - if ((err = edg_wll_GenerateSubjobIds(ctx,e->jobId,e->nsubjobs,e->seed,&subjobs))) - return err; - - gettimeofday(&now,NULL); - - for (i=0; insubjobs; i++) { - edg_wll_Event e2; - int seq; - char *et,*ed,*job_s; - - memset(&e2,0,sizeof e2); - e2.type = EDG_WLL_EVENT_REGJOB; - e2.any.jobId = subjobs[i]; subjobs[i] = NULL; - memcpy(&e2.regJob.timestamp,&now,sizeof now); - e2.any.host = strdup(ctx->srvName); - e2.any.level = e->level; - e2.any.priority = e->priority; - e2.any.seqcode = NULL; /* XXX: I'm not sure :-( */ - e2.any.user = strdup(e->user); - e2.any.source = e->source; - e2.regJob.ns = strdup(e->ns); - edg_wlc_JobIdDup(e->jobId,&e2.regJob.parent); - e2.regJob.jobtype = EDG_WLL_REGJOB_SIMPLE; - e2.regJob.jdl = strdup(""); - - switch (edg_wll_StoreEvent(ctx,&e2,&seq)) { - - case 0: break; - /* maybe some non-ignorable errors should be handled here */ - - default: - edg_wll_Error(ctx,&et,&ed); - job_s = edg_wlc_JobIdUnparse(e2.any.jobId); - fprintf(stderr,"register subjob %s: %s (%s)\n",job_s,et,ed); - syslog(LOG_ERR,"register subjob %s: %s (%s)",job_s,et,ed); - free(job_s); free(et); free(ed); - edg_wll_FreeEvent(&e2); - edg_wll_ResetError(ctx); - continue; - } - - if (edg_wll_LockJob(ctx,e2.any.jobId)) { - job_s = edg_wlc_JobIdUnparse(e2.any.jobId); - fprintf(stderr,"lock job %s: %s (%s)\n",job_s,et,ed); - syslog(LOG_ERR,"lock job %s: %s (%s)",job_s,et,ed); - free(job_s); free(et); free(ed); - edg_wll_FreeEvent(&e2); - edg_wll_ResetError(ctx); - continue; - } - - if ((err = edg_wll_StepIntState(ctx,e2.any.jobId,&e2,seq,NULL))) - edg_wll_Error(ctx,&et,&ed); - - edg_wll_UnlockJob(ctx,e2.any.jobId); - edg_wll_ResetError(ctx); - - if (err) { - job_s = edg_wlc_JobIdUnparse(e2.any.jobId); - fprintf(stderr,"%s: %s (%s)\n",job_s,et,ed); - syslog(LOG_ERR,"%s: %s (%s)",job_s,et,ed); - free(job_s); free(et); free(ed); - edg_wll_ResetError(ctx); - } - - edg_wll_FreeEvent(&e2); - } - - return edg_wll_Error(ctx,NULL,NULL); -} - -int edg_wll_delete_event(edg_wll_Context ctx,const char *jobid,int event) -{ - char *stmt; - -/* The order of tables is important to prevent another process calling - * StoreEvent() to get our event number and mess up the fields together. - * - * XXX: best effort: more or less ignore errors - * - */ - - trio_asprintf(&stmt, - "delete from short_fields where jobid='%|Ss' and event=%d", - jobid,event); - edg_wll_ExecStmt(ctx,stmt,NULL); - free(stmt); - - trio_asprintf(&stmt, - "delete from long_fields where jobid='%|Ss' and event=%d", - jobid,event); - edg_wll_ExecStmt(ctx,stmt,NULL); - free(stmt); - - trio_asprintf(&stmt, - "delete from events where jobid='%|Ss' and event=%d", - jobid,event); - edg_wll_ExecStmt(ctx,stmt,NULL); - free (stmt); - - return edg_wll_Error(ctx,NULL,NULL); -} diff --git a/org.glite.lb.server/src/store.h b/org.glite.lb.server/src/store.h deleted file mode 100644 index ff62047..0000000 --- a/org.glite.lb.server/src/store.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _LBS_STORE_H -#define _LBS_STORE_H - -#ident "$Header$" - -#include "glite/lb/consumer.h" -#include "lb_authz.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* store an event into the LB database */ - -int edg_wll_StoreEvent( - edg_wll_Context, /* INOUT */ - edg_wll_Event *, /* IN */ - int * -); - -void edg_wll_StoreAnonymous( - edg_wll_Context, /* INOUT */ - int /* IN (boolean) */ -); - -/* update stored job state according to new event */ - -edg_wll_ErrorCode edg_wll_StepIntState( - edg_wll_Context, /* INOUT */ - edg_wlc_JobId, /* IN */ - edg_wll_Event *, /* IN */ - int, /* IN */ - edg_wll_JobStat * -); - -int db_store(edg_wll_Context,char *,char *); -int handle_request(edg_wll_Context,char *, int); -int create_reply(const edg_wll_Context,char *,int); - -int edg_wll_delete_event(edg_wll_Context,const char *, int); - - -#define USER_UNKNOWN "unknown" - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/org.glite.lb.server/src/stored_master.c b/org.glite.lb.server/src/stored_master.c deleted file mode 100644 index bfc2f8d..0000000 --- a/org.glite.lb.server/src/stored_master.c +++ /dev/null @@ -1,94 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include - -#include "glite/lb/il_string.h" -#include "glite/lb/lb_gss.h" -#include "glite/lb/lb_plain_io.h" -#include "glite/lb/context-int.h" - -#include "store.h" - -int edg_wll_StoreProto(edg_wll_Context ctx) -{ - char fbuf[256],*buf; - int len,ret; - size_t total; - edg_wll_GssStatus gss_code; - - edg_wll_ResetError(ctx); - if ((ret=edg_wll_gss_read_full(&ctx->connPool[ctx->connToUse].gss,fbuf,17,&ctx->p_tmp_timeout,&total,&gss_code)) < 0) switch (ret) { - case EDG_WLL_GSS_ERROR_TIMEOUT: return edg_wll_SetError(ctx,ETIMEDOUT,"read message header"); - case EDG_WLL_GSS_ERROR_EOF: return edg_wll_SetError(ctx,ENOTCONN,NULL); - default: return edg_wll_SetError(ctx,EDG_WLL_ERROR_GSS,"read message header"); - } - - if ((len = atoi(fbuf)) <= 0) return edg_wll_SetError(ctx,EINVAL,"message length"); - - buf = malloc(len+1); - - if ((ret=edg_wll_gss_read_full(&ctx->connPool[ctx->connToUse].gss,buf,len,&ctx->p_tmp_timeout,&total,&gss_code)) < 0) { - free(buf); - return edg_wll_SetError(ctx, - ret == EDG_WLL_GSS_ERROR_TIMEOUT ? - ETIMEDOUT : EDG_WLL_ERROR_GSS, - "read message"); - } - - - buf[len] = 0; - - handle_request(ctx,buf,len); - free(buf); - - if ((len = create_reply(ctx,fbuf,sizeof fbuf))) { - if ((ret = edg_wll_gss_write_full(&ctx->connPool[ctx->connToUse].gss,fbuf,len,&ctx->p_tmp_timeout,&total,&gss_code)) < 0) - edg_wll_SetError(ctx, - ret == EDG_WLL_GSS_ERROR_TIMEOUT ? - ETIMEDOUT : EDG_WLL_ERROR_GSS, - "write reply"); - } - else edg_wll_SetError(ctx,E2BIG,"create_reply()"); - - return edg_wll_Error(ctx,NULL,NULL); -} - -int edg_wll_StoreProtoProxy(edg_wll_Context ctx) -{ - char fbuf[256], *buf; - int len, ret; - - - edg_wll_ResetError(ctx); - ret = edg_wll_plain_read_full(&ctx->connProxy->conn, fbuf, 17, &ctx->p_tmp_timeout); - if ( ret < 0 ) return edg_wll_SetError(ctx, errno, "StoreProtoProxy() - reading data"); - - len = atoi(fbuf); - if ( len <= 0 ) return edg_wll_SetError(ctx, EINVAL, "message length"); - - buf = malloc(len+1); - if ( !buf ) return edg_wll_SetError(ctx, errno, "StoreProtoProxy()"); - - if ( edg_wll_plain_read_full(&ctx->connProxy->conn, buf, len, &ctx->p_tmp_timeout) < 0) { - free(buf); - return edg_wll_SetError(ctx, errno, "StoreProtoProxy() - reading data"); - } - - buf[len] = 0; - handle_request(ctx, buf, len); - free(buf); - - if ( (len = create_reply(ctx, fbuf, sizeof fbuf)) ) { - if ( edg_wll_plain_write_full(&ctx->connProxy->conn, fbuf, len, &ctx->p_tmp_timeout) < 0 ) - return edg_wll_SetError(ctx, errno, "StoreProtoProxy() - sending reply"); - } - else edg_wll_SetError(ctx, E2BIG, "create_reply()"); - - return edg_wll_Error(ctx, NULL, NULL); -} diff --git a/org.glite.lb.server/src/userjobs.c b/org.glite.lb.server/src/userjobs.c deleted file mode 100644 index 66448f0..0000000 --- a/org.glite.lb.server/src/userjobs.c +++ /dev/null @@ -1,77 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/wmsutils/jobid/strmd5.h" -#include "glite/lb/context-int.h" -#include "glite/lb/trio.h" - -#include "lbs_db.h" - -int edg_wll_UserJobs( - edg_wll_Context ctx, - edg_wlc_JobId **jobs, - edg_wll_JobStat **states) -{ - char *userid = strmd5(ctx->peerName,NULL),*stmt = NULL, - *res = NULL; - int njobs = 0,ret,i; - edg_wlc_JobId *out = NULL; - edg_wll_Stmt sth = NULL; - edg_wll_ErrorCode err = 0; - - edg_wll_ResetError(ctx); - - trio_asprintf(&stmt,"select cert_subj from users where userid = '%|Ss'",userid); - - switch (edg_wll_ExecStmt(ctx,stmt,&sth)) { - case 0: edg_wll_SetError(ctx,ENOENT,ctx->peerName); - case -1: goto err; - default: - if (edg_wll_FetchRow(sth,&res) < 0) goto err; - if (strcmp(ctx->peerName,res)) { - edg_wll_SetError(ctx,EDG_WLL_ERROR_MD5_CLASH,ctx->peerName); - goto err; - } - } - - edg_wll_FreeStmt(&sth); - free(stmt); stmt = NULL; - free(res); res = NULL; - - trio_asprintf(&stmt,"select dg_jobid from jobs where userid = '%|Ss'",userid); - switch (njobs = edg_wll_ExecStmt(ctx,stmt,&sth)) { - case 0: edg_wll_SetError(ctx,ENOENT,ctx->peerName); - case -1: goto err; - } - - out = malloc(sizeof(*out)*(njobs+1)); - memset(out,0,sizeof(*out)*(njobs+1)); - - for (i=0; (ret = edg_wll_FetchRow(sth,&res)); i++) { - if (ret < 0) goto err; - if ((ret = edg_wlc_JobIdParse(res,out+i))) { - edg_wll_SetError(ctx,errno,res); - goto err; - } - free(res); res = NULL; - } - -err: - free(res); - free(stmt); - edg_wll_FreeStmt(&sth); - if ((err = edg_wll_Error(ctx,NULL,NULL))) { - if (out) { - for (i=0; i -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "glite/lb/trio.h" -#include "glite/lb/producer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/jobstat.h" - -#include "get_events.h" -#include "store.h" -#include "lock.h" -#include "index.h" -#include "jobstat.h" - -static int rgma_fd = -1; -static int rgma_sock = -1; -static struct sockaddr_un rgma_saddr; - -static void write2rgma_sql(char *sqlstat) -{ - - char *rgma_fname; - int slen; - int sysret; - struct iovec iov[2]; - - assert(sqlstat != NULL); - - if (rgma_fd == -1) { - rgma_fname = getenv("EDG_WL_RGMA_FILE"); - if (rgma_fname == NULL) return; - - rgma_fd = open(rgma_fname, O_WRONLY|O_CREAT|O_APPEND, 0777); - if (rgma_fd == -1) return; - } - - slen = strlen(sqlstat); - iov[0].iov_base = &slen; - iov[0].iov_len = sizeof(slen); - iov[1].iov_base = sqlstat; - iov[1].iov_len = slen + 1; - if ((sysret = flock(rgma_fd, LOCK_SH)) != -1) { - sysret = writev(rgma_fd, iov, 2); - flock(rgma_fd, LOCK_UN); - } - - if (sysret == -1) return; - - if (rgma_sock == -1) { - rgma_fname = getenv("EDG_WL_RGMA_SOCK"); - if (rgma_fname == NULL) return; - - if ((strlen(rgma_fname) + 1) > sizeof(rgma_saddr.sun_path)) - return ; - - rgma_sock = socket(PF_UNIX, SOCK_DGRAM,0); - if (rgma_sock == -1) return; - - memset(&rgma_saddr, sizeof(rgma_saddr), 0); - rgma_saddr.sun_family = PF_UNIX; - strcpy(rgma_saddr.sun_path, rgma_fname); - } - - sendto(rgma_sock, &slen, 1, 0, - (struct sockaddr*) &rgma_saddr, SUN_LEN(&rgma_saddr)); - - return; -} - -void write2rgma_status(edg_wll_JobStat *stat) -{ - char *stmt = NULL; - char *string_jobid, *string_stat, *string_server; - - string_jobid = edg_wlc_JobIdUnparse(stat->jobId); - string_stat = edg_wll_StatToString(stat->state); - string_server = edg_wlc_JobIdGetServer(stat->jobId); - - trio_asprintf(&stmt, "INSERT INTO JobStatusRaw VALUES ('%|Ss','%s','%|Ss','%|Ss', '%d%03d')", - string_jobid, string_stat, stat->owner, string_server, - stat->stateEnterTime.tv_sec, stat->stateEnterTime.tv_usec/1000); - - if (stmt) write2rgma_sql(stmt); - - free(string_jobid); - free(string_stat); - free(string_server); - free(stmt); -} - -#ifdef TEST -int main(int argc, char* argv[]) -{ - setenv("EDG_WL_RGMA_FILE", "/tmp/rgma_statefile", 1); - setenv("EDG_WL_RGMA_SOCK", "/tmp/rgma_statesock", 1); - - write2rgma_sql("INSERT INTO JobStatusRaw VALUES ('Job_id9','CLEARED','Owner','BKServer', '1050024158210')"); - return 0; -} -#endif diff --git a/org.glite.lb.server/src/ws_fault.c b/org.glite.lb.server/src/ws_fault.c deleted file mode 100644 index 74ef683..0000000 --- a/org.glite.lb.server/src/ws_fault.c +++ /dev/null @@ -1,65 +0,0 @@ -#include - -#include "glite/lb/context-int.h" - -#include "bk_ws_H.h" -#include "bk_ws_Stub.h" - - -void edg_wll_ErrToFault(const edg_wll_Context ctx,struct soap *soap) -{ - char *et,*ed; - struct SOAP_ENV__Detail *detail = soap_malloc(soap,sizeof *detail); - struct _GenericLBFault *f = soap_malloc(soap,sizeof *f); - - - f->edgwll__GenericLBFault = soap_malloc(soap,sizeof *f->edgwll__GenericLBFault); - - f->edgwll__GenericLBFault->code = edg_wll_Error(ctx,&et,&ed); - f->edgwll__GenericLBFault->text = soap_malloc(soap,strlen(et)+1); - strcpy(f->edgwll__GenericLBFault->text,et); - free(et); - f->edgwll__GenericLBFault->description = soap_malloc(soap,strlen(ed)+1); - strcpy(f->edgwll__GenericLBFault->description,ed); - free(ed); - - detail->__type = SOAP_TYPE__GenericLBFault; -#if GSOAP_VERSION >= 20700 - detail->fault = f; -#else - detail->value = f; -#endif - detail->__any = NULL; - - soap_receiver_fault(soap,"shit",NULL); - if (soap->version == 2) soap->fault->SOAP_ENV__Detail = detail; - else soap->fault->detail = detail; -} - - -void edg_wll_FaultToErr(const struct soap *soap,edg_wll_Context ctx) -{ - struct SOAP_ENV__Detail *detail = soap->version == 2 ? - soap->fault->SOAP_ENV__Detail : soap->fault->detail; - - struct edgwll__GenericLBFaultType *f; - - if (detail->__type == SOAP_TYPE__GenericLBFault) { -#if GSOAP_VERSION >= 20700 - f = ((struct _GenericLBFault *) detail->fault) - ->edgwll__GenericLBFault; -#else - f = ((struct _GenericLBFault *) detail->value) - ->edgwll__GenericLBFault; -#endif - edg_wll_SetError(ctx,f->code,f->description); - } - else { - char *s; - - asprintf(&s,"SOAP: %s", soap->version == 2 ? - soap->fault->SOAP_ENV__Reason : soap->fault->faultstring); - edg_wll_SetError(ctx,EINVAL,s); - free(s); - } -} diff --git a/org.glite.lb.server/src/ws_fault.h b/org.glite.lb.server/src/ws_fault.h deleted file mode 100644 index 70870cd..0000000 --- a/org.glite.lb.server/src/ws_fault.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_LBSERVER_WS_FAULT_H__ -#define __EDG_WORKLOAD_LOGGING_LBSERVER_WS_FAULT_H__ - -extern void edg_wll_ErrToFault(const edg_wll_Context, struct soap *); -extern void edg_wll_FaultToErr(const struct soap *, edg_wll_Context); - -#endif /* __EDG_WORKLOAD_LOGGING_LBSERVER_WS_FAULT_H__ */ diff --git a/org.glite.lb.server/src/ws_plugin.c b/org.glite.lb.server/src/ws_plugin.c deleted file mode 100644 index 926c26b..0000000 --- a/org.glite.lb.server/src/ws_plugin.c +++ /dev/null @@ -1,191 +0,0 @@ -#include -#include -#include -#include - -#include "glite/lb/lb_gss.h" -#include "glite/lb/context-int.h" - -#ifdef PLUGIN_TEST -extern int edg_wll_open(edg_wll_Context); -#endif - -#include "ws_plugin.h" - -#include "LoggingAndBookkeeping.nsmap" - -#ifdef WS_PLUGIN_DEBUG -# define pdprintf(s) printf s -#else -# define pdprintf(s) -#endif - -static const char plugin_id[] = PLUGIN_ID; - -#ifdef PLUGIN_TEST -static int edg_wll_ws_connect(struct soap *, const char *, const char *, int); -#endif -static void edg_wll_ws_delete(struct soap *, struct soap_plugin *); -static size_t edg_wll_ws_recv(struct soap *, char *, size_t); -static int edg_wll_ws_send(struct soap *, const char *, size_t); - - -int edg_wll_ws_plugin(struct soap *soap, struct soap_plugin *p, void *arg) -{ - /* The parametr (edg_wll_Context) must be given! */ - assert(arg != NULL); - - p->id = plugin_id; - p->data = arg; - p->fdelete = edg_wll_ws_delete; - -#ifdef PLUGIN_TEST - soap->fconnect = edg_wll_ws_connect; -#endif - soap->fsend = edg_wll_ws_send; - soap->frecv = edg_wll_ws_recv; - - return SOAP_OK; -} - -#ifdef PLUGIN_TEST -int edg_wll_ws_connect(struct soap *soap, const char *endpoint, - const char *host, int port) -{ - edg_wll_Context ctx = (edg_wll_Context)soap_lookup_plugin(soap, plugin_id); - - - ctx->srvName = strdup(host); - ctx->srvPort = port; - ctx->p_tmp_timeout = ctx->p_query_timeout; - if ( edg_wll_open(ctx) ) - return edg_wll_Error(ctx, NULL, NULL); - - soap->socket = 2; - - return SOAP_OK; -} -#endif - -static void edg_wll_ws_delete(struct soap *soap, struct soap_plugin *p) -{ - /* - * Keep silly gSOAP happy - */ -} - - -size_t edg_wll_ws_recv(struct soap *soap, char *buf, size_t bufsz) -{ - edg_wll_Context ctx = (edg_wll_Context)soap_lookup_plugin(soap, plugin_id); - edg_wll_GssStatus gss_code; - int len; - - - edg_wll_ResetError(ctx); - if ( ctx->connPool[ctx->connToUse].gss.context == GSS_C_NO_CONTEXT ) - { - edg_wll_SetError(ctx, ENOTCONN, NULL); - soap->errnum = ENOTCONN; - return 0; - } - - len = edg_wll_gss_read(&ctx->connPool[ctx->connToUse].gss, - buf, bufsz, &ctx->p_tmp_timeout, &gss_code); - - switch ( len ) - { - case EDG_WLL_GSS_OK: - break; - - case EDG_WLL_GSS_ERROR_GSS: - edg_wll_SetErrorGss(ctx, "receving WS request", &gss_code); - soap->errnum = ENOTCONN; - return 0; - - case EDG_WLL_GSS_ERROR_ERRNO: - edg_wll_SetError(ctx, errno, "edg_wll_gss_read()"); - soap->errnum = errno; - return 0; - - case EDG_WLL_GSS_ERROR_TIMEOUT: - edg_wll_SetError(ctx, ETIMEDOUT, NULL); - soap->errnum = ETIMEDOUT; - return 0; - - case EDG_WLL_GSS_ERROR_EOF: - edg_wll_SetError(ctx, ENOTCONN, NULL); - soap->errnum = ENOTCONN; - return 0; - - /* default: fallthrough */ - } - - pdprintf(("\nWS received:\n%s\n\n", buf)); - return len; -} - -static int edg_wll_ws_send(struct soap *soap, const char *buf, size_t bufsz) -{ - edg_wll_Context ctx = (edg_wll_Context) soap_lookup_plugin(soap, plugin_id); - edg_wll_GssStatus gss_code; - struct sigaction sa, osa; - size_t total = 0; - int ret; - - - edg_wll_ResetError(ctx); - - if ( ctx->connPool[ctx->connToUse].gss.context == GSS_C_NO_CONTEXT ) - { - edg_wll_SetError(ctx, ENOTCONN, NULL); - soap->errnum = ENOTCONN; - return SOAP_EOF; - } - - memset(&sa, 0, sizeof(sa)); - assert(sa.sa_handler == NULL); - sa.sa_handler = SIG_IGN; - sigaction(SIGPIPE, &sa, &osa); - - ret = edg_wll_gss_write_full(&ctx->connPool[ctx->connToUse].gss, - (void*)buf, bufsz, - &ctx->p_tmp_timeout, - &total, &gss_code); - - sigaction(SIGPIPE, &osa, NULL); - - switch ( ret ) - { - case EDG_WLL_GSS_OK: - pdprintf(("\nWS sent:\n%s\n\n", buf)); - break; - - case EDG_WLL_GSS_ERROR_TIMEOUT: - edg_wll_SetError(ctx, ETIMEDOUT, "edg_wll_ws_send()"); - soap->errnum = ETIMEDOUT; - return SOAP_EOF; - - case EDG_WLL_GSS_ERROR_ERRNO: - if ( errno == EPIPE ) - { - edg_wll_SetError(ctx, ENOTCONN, "edg_wll_ws_send()"); - soap->errnum = ENOTCONN; - } - else - { - edg_wll_SetError(ctx, errno, "edg_wll_ws_send()"); - soap->errnum = errno; - } - return SOAP_EOF; - - case EDG_WLL_GSS_ERROR_GSS: - case EDG_WLL_GSS_ERROR_EOF: - default: - edg_wll_SetError(ctx, ENOTCONN, "edg_wll_ws_send()"); - soap->errnum = ENOTCONN; - return SOAP_EOF; - } - - return SOAP_OK; -} diff --git a/org.glite.lb.server/src/ws_plugin.h b/org.glite.lb.server/src/ws_plugin.h deleted file mode 100644 index 9b691be..0000000 --- a/org.glite.lb.server/src/ws_plugin.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_LBSERVER_WS_PLUGIN_H__ -#define __EDG_WORKLOAD_LOGGING_LBSERVER_WS_PLUGIN_H__ - -#define PLUGIN_ID "GLITE_WS_PLUGIN" - -int edg_wll_ws_plugin(struct soap *, struct soap_plugin *, void *); - -#endif /* __EDG_WORKLOAD_LOGGING_LBSERVER_WS_PLUGIN_H__ */ diff --git a/org.glite.lb.server/src/ws_query.c b/org.glite.lb.server/src/ws_query.c deleted file mode 100644 index b59fcf6..0000000 --- a/org.glite.lb.server/src/ws_query.c +++ /dev/null @@ -1,117 +0,0 @@ -#include - -#include "glite/lb/context-int.h" -#include "glite/lb/consumer.h" - -#include "jobstat.h" -#include "query.h" -#include "ws_plugin.h" -#include "bk_ws_H.h" -#include "get_events.h" -#include "ws_fault.h" -#include "ws_typeref.h" - - -int edgwll2__GetVersion( - struct soap *soap, - struct edgwll2__GetVersionResponse *out) -{ - out->version = strdup(VERSION); - - return SOAP_OK; -} - -int edgwll2__JobStatus( - struct soap *soap, - char *jobid, - struct edgwll__JobStatFlags *flags, - struct edgwll2__JobStatusResponse *out) -{ - edg_wll_Context ctx = (edg_wll_Context) soap_lookup_plugin(soap, PLUGIN_ID); - edg_wlc_JobId j; - edg_wll_JobStat s; - - - if ( edg_wlc_JobIdParse(jobid, &j) ) - { - edg_wll_SetError(ctx, EINVAL, jobid); - edg_wll_ErrToFault(ctx, soap); - return SOAP_FAULT; - } - - if ( edg_wll_JobStatus(ctx, j, 0, &s) ) - { - edg_wll_ErrToFault(ctx, soap); - return SOAP_FAULT; - } - - edg_wll_StatusToSoap(soap, &s, &(out->status)); - - return SOAP_OK; -} - -int edgwll2__QueryJobs( - struct soap *soap, - struct edgwll__QueryConditions *conditions, - struct edgwll__JobStatFlags *flags, - struct edgwll2__QueryJobsResponse *out) -{ - edg_wll_Context ctx = (edg_wll_Context) soap_lookup_plugin(soap, PLUGIN_ID); - edg_wlc_JobId *jobsOut = NULL; - edg_wll_JobStat *statesOut = NULL; - edg_wll_QueryRec **qr = NULL; - int fl, - i, j, - ret = SOAP_FAULT; - - - out->states = soap_malloc(soap, sizeof(*out->states)); - out->jobs = soap_malloc(soap, sizeof(*out->jobs)); - if ( !out->states || !out->jobs ) goto cleanup; - memset(out->states, 0, sizeof(*(out->states))); - memset(out->jobs, 0, sizeof(*(out->jobs))); - - edg_wll_ResetError(ctx); - edg_wll_SoapToJobStatFlags(flags, &fl); - if ( edg_wll_SoapToQueryCondsExt(conditions, &qr) ) { - edg_wll_SetError(ctx, ENOMEM, "Couldn't create internal structures"); - goto cleanup; - } - if ( edg_wll_QueryJobsServer(ctx, (const edg_wll_QueryRec **)qr, fl, - &jobsOut, &statesOut) ) goto cleanup; - if ( edg_wll_JobsQueryResToSoap(soap, jobsOut, statesOut, out) ) goto cleanup; - ret = SOAP_OK; - -cleanup: - if ( qr ) { - for ( i = 0; qr[i]; i++ ) { - for ( j = 0; qr[i][j].attr; j++ ) - edg_wll_QueryRecFree(&qr[i][j]); - free(qr[i]); - } - free(qr); - } - if ( jobsOut ) { - for ( i = 0; jobsOut[i]; i++ ) - edg_wlc_JobIdFree(jobsOut[i]); - free(jobsOut); - } - if ( statesOut ) { - for ( i = 0; statesOut[i].state; i++ ) - edg_wll_FreeStatus(&statesOut[i]); - free(statesOut); - } - if ( ret == SOAP_FAULT ) edg_wll_ErrToFault(ctx, soap); - - return ret; -} - -int edgwll2__UserJobs( - struct soap *soap, - struct edgwll2__UserJobsResponse *out) -{ - out->jobs = NULL; - out->states = NULL; - - return SOAP_OK; -} diff --git a/org.glite.lb.server/src/ws_typemap.dat b/org.glite.lb.server/src/ws_typemap.dat deleted file mode 100644 index c79474a..0000000 --- a/org.glite.lb.server/src/ws_typemap.dat +++ /dev/null @@ -1,2 +0,0 @@ -edgwll = http://glite.org/wsdl/types/lb -edgwll = http://glite.org/wsdl/services/lb diff --git a/org.glite.lb.server/src/ws_typemap.h b/org.glite.lb.server/src/ws_typemap.h deleted file mode 100644 index 10f1442..0000000 --- a/org.glite.lb.server/src/ws_typemap.h +++ /dev/null @@ -1,52 +0,0 @@ -#if GSOAP_VERSION >= 20700 - -#define UNDEF edgwll__QueryAttr__UNDEF - -#define JOBID edgwll__QueryAttr__JOBID -#define OWNER edgwll__QueryAttr__OWNER -#define STATUS edgwll__QueryAttr__STATUS -#define LOCATION edgwll__QueryAttr__LOCATION -#define DESTINATION edgwll__QueryAttr__DESTINATION -#define DONECODE edgwll__QueryAttr__DONECODE -#define USERTAG edgwll__QueryAttr__USERTAG -#define TIME edgwll__QueryAttr__TIME -#define LEVEL edgwll__QueryAttr__LEVEL -#define HOST edgwll__QueryAttr__HOST -#define SOURCE edgwll__QueryAttr__SOURCE -#define INSTANCE edgwll__QueryAttr__INSTANCE -#define EVENT_TYPE edgwll__QueryAttr__EVENT_TYPE -#define CHKPT_TAG edgwll__QueryAttr__CHKPT_TAG -#define RESUBMITTED edgwll__QueryAttr__RESUBMITTED -#define PARENT edgwll__QueryAttr__PARENT -#define EXITCODE edgwll__QueryAttr__EXITCODE - -#define EQUAL edgwll__QueryOp__EQUAL -#define UNEQUAL edgwll__QueryOp__UNEQUAL -#define LESS edgwll__QueryOp__LESS -#define GREATER edgwll__QueryOp__GREATER -#define WITHIN edgwll__QueryOp__WITHIN - -#define SUBMITTED edgwll__JobStatCode__SUBMITTED -#define WAITING edgwll__JobStatCode__WAITING -#define READY edgwll__JobStatCode__READY -#define SCHEDULED edgwll__JobStatCode__SCHEDULED -#define RUNNING edgwll__JobStatCode__RUNNING -#define DONE edgwll__JobStatCode__DONE -#define CLEARED edgwll__JobStatCode__CLEARED -#define ABORTED edgwll__JobStatCode__ABORTED -#define CANCELLED edgwll__JobStatCode__CANCELLED -#define UNKNOWN edgwll__JobStatCode__UNKNOWN -#define PURGED edgwll__JobStatCode__PURGED - -#define SIMPLE edgwll__StatJobType__SIMPLE -#define DAG edgwll__StatJobType__DAG - -#define OK edgwll__StatDoneCode__OK -#define FAILED edgwll__StatDoneCode__FAILED -#define CANCELLED_ edgwll__StatDoneCode__CANCELLED - -#define CLASSADS edgwll__JobStatFlag__CLASSADS -#define CHILDREN edgwll__JobStatFlag__CHILDREN -#define CHILDSTAT edgwll__JobStatFlag__CHILDSTAT - -#endif diff --git a/org.glite.lb.server/src/ws_typeref.c.T b/org.glite.lb.server/src/ws_typeref.c.T deleted file mode 100644 index 2fb439d..0000000 --- a/org.glite.lb.server/src/ws_typeref.c.T +++ /dev/null @@ -1,522 +0,0 @@ -#include -#include -#include -#include - -#include "bk_ws_H.h" -#include "ws_typemap.h" - -#include "glite/lb/consumer.h" -/* XXX: references only, src and dest share pointers */ - -void edg_wll_JobStatCodeToSoap(edg_wll_JobStatCode in, enum edgwll__JobStatCode *out) -{ - switch ( in ) - { - case EDG_WLL_JOB_UNDEF: *out = UNDEF; break; -@@@{ - for my $stat ($status->getTypesOrdered) { - my $u = uc $stat; - my $c = getTypeComment $status $stat; - gen qq{ -! case EDG_WLL_JOB_$u: *out = $u; break; /**< $c */ -}; - } -@@@} - } -} - -void edg_wll_SoapToJobStatCode(enum edgwll__JobStatCode in, edg_wll_JobStatCode *out) -{ - switch ( in ) - { - case UNDEF: *out = EDG_WLL_JOB_UNDEF; break; -@@@{ - for my $stat ($status->getTypesOrdered) { - my $u = uc $stat; - my $c = getTypeComment $status $stat; - gen qq{ -! case $u: *out = EDG_WLL_JOB_$u; break; /**< $c */ -}; - } -@@@} - } -} - -int edg_wll_StatusToSoap(struct soap *soap,edg_wll_JobStat const *src,struct edgwll__JobStat **dest) -{ - int i; - struct edgwll__JobStat *js; - - if ( !(js = soap_malloc(soap, sizeof(*js))) ) return SOAP_FAULT; - memset(js, 0, sizeof(*js)); - edg_wll_JobStatCodeToSoap(src->state, &(js->state)); -@@@{ - selectType $status '_common_'; - for (getFieldsOrdered $status) { - my $f = selectField $status $_; - my $ft = $f->{type}; - my $usuc = $_; - $usuc = $1.uc($2).$3 while ($usuc =~ /([^_]*)_([a-z])(.*)/); - if ($ft eq 'jobid') { - gen "\tjs->$usuc = edg_wlc_JobIdUnparse(src->$_);\n"; - } - elsif ($ft eq 'strlist') { - gen "\tfor (i=0; src->$_ && src->$_\[i]; i++);\n"; - gen "\tjs->__size$usuc = i;\n"; - gen "\tjs->$usuc = src->$_;\n"; - } elsif ($ft eq 'intlist') { - gen "\tjs->__size$usuc = src->$_ ? src->$_\[0] : 0;\n"; - gen "\tjs->$usuc = src->$_ ? src->$_ + 1 : NULL;\n"; - } elsif ($ft eq 'stslist' || $ft eq 'taglist') { -# FIXME - gen "\tjs->__size$usuc = 0;\n"; - gen "\tjs->$usuc = NULL;\n"; - } elsif ($ft eq 'timeval') { - gen "\tjs->$usuc = soap_malloc(soap,sizeof *js->$usuc);\n"; - gen "\tjs->$usuc->tvSec = src->$_.tv_sec;\n"; - gen "\tjs->$usuc->tvUsec = src->$_.tv_usec;\n"; - } - else { gen "\tjs->$usuc = src->$_;\n"; } - } -@@@} - - *dest = js; - return SOAP_OK; -} - -void edg_wll_SoapToStatus(struct soap *soap,struct edgwll__JobStat const *src,edg_wll_JobStat *dest) -{ - memset(dest,0,sizeof *dest); - edg_wll_SoapToJobStatCode(src->state, &(dest->state)); - -@@@{ - selectType $status '_common_'; - for (getFieldsOrdered $status) { - my $f = selectField $status $_; - my $ft = $f->{type}; - my $usuc = $_; - $usuc = $1.uc($2).$3 while ($usuc =~ /([^_]*)_([a-z])(.*)/); - - if ($ft eq 'jobid') { - gen "\tif (src->$usuc) edg_wlc_JobIdParse(src->$usuc,&dest->$_);\n"; - } elsif ($ft eq 'strlist') { - gen "\tsoap_unlink(soap,src->$usuc);\n"; - gen "\tdest->$_ = realloc(src->$usuc,sizeof(*dest->$_) * (src->__size$usuc + 1));\n"; - gen "\tdest->$_\[src->__size$usuc] = NULL;\n"; - } elsif ($ft eq 'intlist') { - gen "\tsoap_unlink(soap,src->$usuc);\n"; - gen "\tdest->$_ = realloc(src->$usuc,sizeof(*dest->$_) * (src->__size$usuc + 1));\n"; - gen "\tmemmove(dest->$_ + 1,dest->$_,sizeof(*dest->$_) * (src->__size$usuc));\n"; - gen "\tdest->$_\[0] = src->__size$usuc;\n"; - } elsif ($ft eq 'stslist' || $ft eq 'taglist') { -# FIXME - gen "\tdest->$_ = NULL;\n"; - } elsif ($ft eq 'timeval') { - gen "\tdest->$_.tv_sec = src->$usuc->tvSec;\n"; - gen "\tdest->$_.tv_usec = src->$usuc->tvUsec;\n"; - } elsif ($ft eq 'string') { - gen "\tdest->$_ = src->$usuc;\n"; - gen "\tsoap_unlink(soap,src->$usuc);\n"; - } else { - gen "\tdest->$_ = src->$usuc;\n"; -} -} -@@@} -} - -void edg_wll_SoapToJobStatFlags(const struct edgwll__JobStatFlags *in, int *out) -{ - int i; - - assert(in); assert(out); - *out = 0; - for ( i = 0; i < in->__sizeflag; i++ ) switch ( in->flag[i] ) - { - case CLASSADS: *out |= EDG_WLL_STAT_CLASSADS; break; - case CHILDREN: *out |= EDG_WLL_STAT_CHILDREN; break; - case CHILDSTAT: *out |= EDG_WLL_STAT_CHILDSTAT; break; - } -} - -int edg_wll_JobStatFlagsToSoap(struct soap *soap, const int in, struct edgwll__JobStatFlags *out) -{ - int i = 0; - - assert(out); - memset(out, 0, sizeof(*out)); - if ( in & EDG_WLL_STAT_CLASSADS ) out->__sizeflag++; - if ( in & EDG_WLL_STAT_CHILDREN ) out->__sizeflag++; - if ( in & EDG_WLL_STAT_CHILDSTAT ) out->__sizeflag++; - if ( !out->__sizeflag ) return SOAP_OK; - out->flag = soap_malloc(soap, sizeof(*(out->flag))*out->__sizeflag); - if ( !out->flag ) return SOAP_FAULT; - - if ( in & EDG_WLL_STAT_CLASSADS ) out->flag[i++] = CLASSADS; - if ( in & EDG_WLL_STAT_CHILDREN ) out->flag[i++] = CHILDREN; - if ( in & EDG_WLL_STAT_CHILDSTAT ) out->flag[i++] = CHILDSTAT; - - return SOAP_OK; -} - -void edg_wll_SoapToAttr(const enum edgwll__QueryAttr in, edg_wll_QueryAttr *out) -{ - switch ( in ) - { - case UNDEF: *out = EDG_WLL_QUERY_ATTR_UNDEF; break; - case JOBID: *out = EDG_WLL_QUERY_ATTR_JOBID; break; - case OWNER: *out = EDG_WLL_QUERY_ATTR_OWNER; break; - case STATUS: *out = EDG_WLL_QUERY_ATTR_STATUS; break; - case LOCATION: *out = EDG_WLL_QUERY_ATTR_LOCATION; break; - case DESTINATION: *out = EDG_WLL_QUERY_ATTR_DESTINATION; break; - case DONECODE: *out = EDG_WLL_QUERY_ATTR_DONECODE; break; - case USERTAG: *out = EDG_WLL_QUERY_ATTR_USERTAG; break; - case TIME: *out = EDG_WLL_QUERY_ATTR_TIME; break; - case LEVEL: *out = EDG_WLL_QUERY_ATTR_LEVEL; break; - case HOST: *out = EDG_WLL_QUERY_ATTR_HOST; break; - case SOURCE: *out = EDG_WLL_QUERY_ATTR_SOURCE; break; - case INSTANCE: *out = EDG_WLL_QUERY_ATTR_INSTANCE; break; - case EVENT_TYPE: *out = EDG_WLL_QUERY_ATTR_EVENT_TYPE; break; - case CHKPT_TAG: *out = EDG_WLL_QUERY_ATTR_CHKPT_TAG; break; - case RESUBMITTED: *out = EDG_WLL_QUERY_ATTR_RESUBMITTED; break; - case PARENT: *out = EDG_WLL_QUERY_ATTR_PARENT; break; - case EXITCODE: *out = EDG_WLL_QUERY_ATTR_EXITCODE; break; - default: *out = in; break; - } -} - -void edg_wll_AttrToSoap(const edg_wll_QueryAttr in, enum edgwll__QueryAttr *out) -{ - switch ( in ) - { - case EDG_WLL_QUERY_ATTR_UNDEF: *out = UNDEF; break; - case EDG_WLL_QUERY_ATTR_JOBID: *out = JOBID; break; - case EDG_WLL_QUERY_ATTR_OWNER: *out = OWNER; break; - case EDG_WLL_QUERY_ATTR_STATUS: *out = STATUS; break; - case EDG_WLL_QUERY_ATTR_LOCATION: *out = LOCATION; break; - case EDG_WLL_QUERY_ATTR_DESTINATION: *out = DESTINATION; break; - case EDG_WLL_QUERY_ATTR_DONECODE: *out = DONECODE; break; - case EDG_WLL_QUERY_ATTR_USERTAG: *out = USERTAG; break; - case EDG_WLL_QUERY_ATTR_TIME: *out = TIME; break; - case EDG_WLL_QUERY_ATTR_LEVEL: *out = LEVEL; break; - case EDG_WLL_QUERY_ATTR_HOST: *out = HOST; break; - case EDG_WLL_QUERY_ATTR_SOURCE: *out = SOURCE; break; - case EDG_WLL_QUERY_ATTR_INSTANCE: *out = INSTANCE; break; - case EDG_WLL_QUERY_ATTR_EVENT_TYPE: *out = EVENT_TYPE; break; - case EDG_WLL_QUERY_ATTR_CHKPT_TAG: *out = CHKPT_TAG; break; - case EDG_WLL_QUERY_ATTR_RESUBMITTED: *out = RESUBMITTED; break; - case EDG_WLL_QUERY_ATTR_PARENT: *out = PARENT; break; - case EDG_WLL_QUERY_ATTR_EXITCODE: *out = EXITCODE; break; - default: *out = in; break; - } -} - -void edg_wll_SoapToQueryOp(const enum edgwll__QueryOp in, edg_wll_QueryOp *out) -{ - switch ( in ) - { - case EQUAL: *out = EDG_WLL_QUERY_OP_EQUAL; break; - case LESS: *out = EDG_WLL_QUERY_OP_LESS; break; - case GREATER: *out = EDG_WLL_QUERY_OP_GREATER; break; - case WITHIN: *out = EDG_WLL_QUERY_OP_WITHIN; break; - default: *out = in; break; - } -} - -void edg_wll_QueryOpToSoap(const edg_wll_QueryOp in, enum edgwll__QueryOp *out) -{ - switch ( in ) - { - case EDG_WLL_QUERY_OP_EQUAL: *out = EQUAL; break; - case EDG_WLL_QUERY_OP_LESS: *out = LESS; break; - case EDG_WLL_QUERY_OP_GREATER: *out = GREATER; break; - case EDG_WLL_QUERY_OP_WITHIN: *out = WITHIN; break; - default: *out = in; break; - } -} - -int edg_wll_SoapToQueryVal( - const edg_wll_QueryAttr attr, - const struct edgwll__QueryRecValue *in, - union edg_wll_QueryVal *out) -{ - assert(in); assert(out); - if ( in->c ) { - if ( attr == EDG_WLL_QUERY_ATTR_JOBID || attr == EDG_WLL_QUERY_ATTR_PARENT ) { - if ( edg_wlc_JobIdParse(in->c, &(out->j)) ) return -1; - } else { - if ( !(out->c = strdup(in->c)) ) return -1; - } - } - else if ( in->t ) { - out->t.tv_sec = in->t->tvSec; - out->t.tv_usec = in->t->tvUsec; - } - else if ( in->i ) out->i = *(in->i); - - return 0; -} - -int edg_wll_QueryValToSoap( - struct soap *soap, - const edg_wll_QueryAttr attr, - const union edg_wll_QueryVal *in, - struct edgwll__QueryRecValue *out) -{ - assert(in); assert(out); - memset(out, 0, sizeof(*out)); - switch ( attr ) { - case EDG_WLL_QUERY_ATTR_USERTAG: - case EDG_WLL_QUERY_ATTR_OWNER: - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_DESTINATION: - case EDG_WLL_QUERY_ATTR_HOST: - case EDG_WLL_QUERY_ATTR_INSTANCE: - if ( in->c && !(out->c = soap_strdup(soap, in->c)) ) return SOAP_FAULT; - break; - case EDG_WLL_QUERY_ATTR_JOBID: - case EDG_WLL_QUERY_ATTR_PARENT: { - char *s = edg_wlc_JobIdUnparse(in->j); - out->c = soap_strdup(soap, s); - free(s); - if ( !out->c ) return SOAP_FAULT; - } - break; - case EDG_WLL_QUERY_ATTR_TIME: - out->t = soap_malloc(soap, sizeof(*(out->t))); - if ( !out->t ) return SOAP_FAULT; - out->t->tvSec = in->t.tv_sec; - out->t->tvUsec = in->t.tv_usec; - break; - case EDG_WLL_QUERY_ATTR_STATUS: - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_LEVEL: - case EDG_WLL_QUERY_ATTR_SOURCE: - case EDG_WLL_QUERY_ATTR_EVENT_TYPE: - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - default: - out->i = soap_malloc(soap, sizeof(*(out->i))); - if ( !out->i ) return SOAP_FAULT; - *(out->i) = in->i; - break; - } - - return SOAP_OK; -} - -int edg_wll_SoapToQueryRec( - const enum edgwll__QueryAttr attr, - const struct edgwll__QueryRec *in, - edg_wll_QueryRec *out) -{ - assert(attr); assert(in); assert(out); - memset(out, 0, sizeof(*out)); - edg_wll_SoapToAttr(attr, &out->attr); - switch ( out->attr ) - { - case EDG_WLL_QUERY_ATTR_TIME: - edg_wll_SoapToJobStatCode(*(in->attrid->state), &(out->attr_id.state)); - break; - case EDG_WLL_QUERY_ATTR_USERTAG: - out->attr_id.tag = strdup(in->attrid->tag); - break; - default: - break; - } - edg_wll_SoapToQueryOp(in->op, &(out->op)); - switch ( out->op ) - { - case EDG_WLL_QUERY_OP_WITHIN: - if ( edg_wll_SoapToQueryVal(out->attr, in->value2, &(out->value2)) ) goto err; - default: - if ( edg_wll_SoapToQueryVal(out->attr, in->value1, &(out->value)) ) goto err; - break; - } - - return 0; -err: - edg_wll_QueryRecFree(out); - return -1; -} - -int edg_wll_QueryRecToSoap( - struct soap *soap, - const edg_wll_QueryRec *in, - struct edgwll__QueryRec **out) -{ - struct edgwll__QueryRec *qr; - - - assert(in); assert(out); - if ( !(qr = soap_malloc(soap, sizeof(*qr))) ) return SOAP_FAULT; - memset(qr, 0, sizeof(*qr)); - if ( !in ) goto ret; - edg_wll_QueryOpToSoap(in->op, &(qr->op)); - if ( in->attr == EDG_WLL_QUERY_ATTR_TIME - || in->attr == EDG_WLL_QUERY_ATTR_USERTAG ) { - if ( !(qr->attrid = soap_malloc(soap, sizeof(*(qr->attrid)))) ) return SOAP_FAULT; - memset(qr->attrid, 0, sizeof(*(qr->attrid))); - if ( in->attr == EDG_WLL_QUERY_ATTR_TIME ) { - qr->attrid->state = soap_malloc(soap, sizeof(*(qr->attrid->state))); - if ( !qr->attrid->state ) return SOAP_FAULT; - edg_wll_JobStatCodeToSoap(in->attr_id.state, qr->attrid->state); - } - else { - qr->attrid->tag = soap_strdup(soap, in->attr_id.tag); - if ( !qr->attrid->tag ) return SOAP_FAULT; - } - } - switch ( in->op ) { - case EDG_WLL_QUERY_OP_WITHIN: - if ( !(qr->value2 = soap_malloc(soap, sizeof(*(qr->value2)))) ) return SOAP_FAULT; - if ( edg_wll_QueryValToSoap(soap, in->attr, &(in->value2), qr->value2) ) return SOAP_FAULT; - default: - if ( !(qr->value1 = soap_malloc(soap, sizeof(*(qr->value1)))) ) return SOAP_FAULT; - if ( edg_wll_QueryValToSoap(soap, in->attr, &(in->value), qr->value1) ) return SOAP_FAULT; - break; - } - -ret: - *out = qr; - return SOAP_OK; -} - -int edg_wll_SoapToQueryConds(const struct edgwll__QueryCondition *in, edg_wll_QueryRec **out) -{ - int i; - edg_wll_QueryRec *qr; - - - assert(in); assert(out); - if ( !(qr = calloc(in->__sizerecords+1, sizeof(*qr))) ) goto err; - for ( i = 0; i < in->__sizerecords; i++ ) - if ( edg_wll_SoapToQueryRec(in->attr, in->records[i], qr+i) ) goto err; - *out = qr; - return 0; - -err: - if ( qr ) { - for ( i = 0; qr[i].attr; i++ ) edg_wll_QueryRecFree(qr+i); - free(qr); - } - return -1; -} - -int edg_wll_QueryCondsToSoap( - struct soap *soap, - const edg_wll_QueryRec *in, - struct edgwll__QueryCondition **out) -{ - int i; - struct edgwll__QueryCondition *qc; - - - assert(out); - if ( !(qc = soap_malloc(soap, sizeof(*qc))) ) return SOAP_FAULT; - memset(qc, 0, sizeof(*qc)); - if ( !in ) goto ret; - while ( in[qc->__sizerecords].attr ) qc->__sizerecords++; - if ( !qc->__sizerecords ) goto ret; - qc->records = soap_malloc(soap, sizeof(*(qc->records))*qc->__sizerecords); - if ( !qc->records ) return SOAP_FAULT; - edg_wll_AttrToSoap(in[0].attr, &(qc->attr)); - for ( i = 0; in[i].attr; i++ ) - if ( edg_wll_QueryRecToSoap(soap, in+i, qc->records+i) ) - return SOAP_FAULT; - -ret: - *out = qc; - return SOAP_OK; -} - -int edg_wll_SoapToQueryCondsExt(const struct edgwll__QueryConditions *in, edg_wll_QueryRec ***out) -{ - int i; - edg_wll_QueryRec **qr; - - - assert(in); assert(out); - if ( !(qr = calloc(in->__sizecondition+1, sizeof(*qr))) ) return -1; - for ( i = 0; i < in->__sizecondition; i++ ) - if ( edg_wll_SoapToQueryConds(in->condition[i], qr+i) ) goto err; - - *out = qr; - return 0; - -err: - if ( qr ) { - int j; - for ( i = 0; qr[i]; i++ ) - { - for ( j = 0; qr[i][j].attr; j++ ) edg_wll_QueryRecFree(qr[i]); - free(qr[i]); - } - free(qr); - } - return -1; -} - -int edg_wll_QueryCondsExtToSoap( - struct soap *soap, - const edg_wll_QueryRec **in, - struct edgwll__QueryConditions **out) -{ - int i; - struct edgwll__QueryConditions *qc; - - - assert(out); - if ( !(qc = soap_malloc(soap, sizeof(*qc))) ) return SOAP_FAULT; - memset(qc, 0, sizeof(*qc)); - if ( !in ) goto ret; - while ( in[qc->__sizecondition] ) qc->__sizecondition++; - if ( !qc->__sizecondition ) goto ret; - qc->condition = soap_malloc(soap, sizeof(*(qc->condition))*qc->__sizecondition); - if ( !qc->condition ) return SOAP_FAULT; - for ( i = 0; in[i]; i++ ) - if ( edg_wll_QueryCondsToSoap(soap, in[i], qc->condition+i) ) - return SOAP_FAULT; - -ret: - *out = qc; - return SOAP_OK; -} - -int edg_wll_JobsQueryResToSoap( - struct soap *soap, - const edg_wlc_JobId *jobs, - const edg_wll_JobStat *states, - struct edgwll2__QueryJobsResponse *out) -{ - int i; - - - assert(out); assert(out->states); assert(out->jobs); - memset(out->jobs, 0, sizeof(*(out->jobs))); - memset(out->states, 0, sizeof(*(out->states))); - - if ( jobs ) { - for ( i = 0; jobs[i]; i++ ) ; - out->jobs->jobs = soap_malloc(soap, sizeof(*(out->jobs->jobs))*i); - if ( !out->jobs->jobs ) return SOAP_FAULT; - out->jobs->__sizejobs = i; - for ( i = 0; jobs[i]; i++ ) { - char *s; - if ( !(s = edg_wlc_JobIdUnparse(jobs[i])) ) return SOAP_FAULT; - if ( !(out->jobs->jobs[i] = soap_strdup(soap, s)) ) return SOAP_FAULT; - free(s); - } - } - if ( states ) { - for ( i = 0; states[i].state; i++ ) ; - out->states->states = soap_malloc(soap, sizeof(*(out->states->states))*i); - if ( !out->states->states ) return SOAP_FAULT; - out->states->__sizestates = i; - - for ( i = 0; states[i].state; i++ ) - if ( edg_wll_StatusToSoap(soap, states+i, out->states->states+i) ) - return SOAP_FAULT; - } - - return SOAP_OK; -} diff --git a/org.glite.lb.server/src/ws_typeref.h b/org.glite.lb.server/src/ws_typeref.h deleted file mode 100644 index 3202547..0000000 --- a/org.glite.lb.server/src/ws_typeref.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __EDG_WORKLOAD_LOGGING_LBSERVER_WS_TYPEREF_H__ -#define __EDG_WORKLOAD_LOGGING_LBSERVER_WS_TYPEREF_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -extern void edg_wll_JobStatCodeToSoap(edg_wll_JobStatCode, enum edgwll__JobStatCode *); -extern void edg_wll_SoapToJobStatCode(enum edgwll__JobStatCode, edg_wll_JobStatCode *); - -extern void edg_wll_StatusToSoap(struct soap *, edg_wll_JobStat const *, struct edgwll__JobStat **); -extern void edg_wll_SoapToStatus(struct soap *, struct edgwll__JobStat const *, edg_wll_JobStat **); - -extern void edg_wll_SoapToJobStatFlags(const struct edgwll__JobStatFlags *, int *); -extern int edg_wll_JobStatFlagsToSoap(struct soap *, const int, struct edgwll__JobStatFlags *); - -extern void edg_wll_SoapToAttr(const enum edgwll__QueryAttr, edg_wll_QueryAttr *); -extern void edg_wll_AttrToSoap(const edg_wll_QueryAttr, enum edgwll__QueryAttr *); - -extern void edg_wll_SoapToQueryOp( - const enum edgwll__QueryOp, - edg_wll_QueryOp *); -extern void edg_wll_QueryOpToSoap( - const edg_wll_QueryOp, - enum edgwll__QueryOp *); - -extern int edg_wll_SoapToQueryVal( - const edg_wll_QueryAttr, - const struct edgwll__QueryRecValue *, - union edg_wll_QueryVal *); -extern int edg_wll_QueryValToSoap(struct soap *, - const edg_wll_QueryAttr, - const union edg_wll_QueryVal *, - struct edgwll__QueryRecValue *); - -extern int edg_wll_SoapToQueryRec( - const enum edgwll__QueryAttr, - const struct edgwll__QueryRec *, - edg_wll_QueryRec *); -extern int edg_wll_QueryRecToSoap(struct soap *, - const edg_wll_QueryRec *, - struct edgwll__QueryRec *); - - -extern int edg_wll_SoapToQueryConds( - const struct edgwll__QueryCondition *, - edg_wll_QueryRec **); -extern int edg_wll_QueryCondsToSoap(struct soap *, - const edg_wll_QueryRec *, - struct edgwll__QueryCondition **); - -extern int edg_wll_SoapToQueryCondsExt( - const struct edgwll__QueryConditions *, - edg_wll_QueryRec ***); -extern int edg_wll_QueryCondsExtToSoap(struct soap *, - const edg_wll_QueryRec **, - struct edgwll__QueryConditions **); - -extern int edg_wll_JobsQueryResToSoap(struct soap *, - edg_wlc_JobId *, - edg_wll_JobStat *, - struct edgwll2__QueryJobsResponse *); - -#ifdef __cplusplus -} -#endif - -#endif /* __EDG_WORKLOAD_LOGGING_LBSERVER_WS_TYPEREF_H__ */ diff --git a/org.glite.lb.server/test/oneJob.qry b/org.glite.lb.server/test/oneJob.qry deleted file mode 100644 index d419ce8..0000000 --- a/org.glite.lb.server/test/oneJob.qry +++ /dev/null @@ -1,24 +0,0 @@ -SELECT e.event,j.userid,j.dg_jobid,e.code,e.prog,e.host,u.cert_subj,e.time_stamp,e.usec,e.level,e.arrived FROM events e,users u,jobs j WHERE e.jobid=j.jobid AND e.userid=u.userid AND e.code != 0 AND (j.jobid='WrCEKje9QTXFiSOZuPMLtw') -0 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 17 UserInterface lhun.ics.muni.cz anonymous 2003-08-07 11:08:40 432100 8 2003-08-07 11:08:40 -1 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 2 NetworkServer lhun.ics.muni.cz anonymous 2003-08-07 11:09:05 664600 8 2003-08-07 11:09:05 - -select name,value from short_fields where jobid = 'WrCEKje9QTXFiSOZuPMLtw' and event = 0 -JDL x -JOBTYPE SIMPLE -NS NNNSSSS -NSUBJOBS 0 -PARENT https://lhun.ics.muni.cz:4850/Qt7utj80miXexi7bkxyhnA -SEQCODE (nil) -SRC_INSTANCE (nil) - -select name,value from long_fields where jobid = 'WrCEKje9QTXFiSOZuPMLtw' and event = 0 - -select name,value from short_fields where jobid = 'WrCEKje9QTXFiSOZuPMLtw' and event = 1 -FROM UserInterface -FROM_HOST sending component hostname -FROM_INSTANCE sending component instance -LOCAL_JOBID new jobId (Condor Globus ...) -SEQCODE UI=000002:NS=0000000001:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000 -SRC_INSTANCE - -select name,value from long_fields where jobid = 'WrCEKje9QTXFiSOZuPMLtw' and event = 1 diff --git a/org.glite.lb.server/test/test_query_events.cpp b/org.glite.lb.server/test/test_query_events.cpp deleted file mode 100644 index bf356f4..0000000 --- a/org.glite.lb.server/test/test_query_events.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include - -#include -#include -#include -#include - -#include -#include - -#include "lbs_db.h" -#include "get_events.h" - -using namespace std; - -static const char *test_dir; - -class QueryEventsTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(QueryEventsTest); - CPPUNIT_TEST(oneJob); - CPPUNIT_TEST_SUITE_END(); - -private: - edg_wll_Context ctx; - - ifstream qry_file; - - vector > > queries; - -public: - void oneJob(); - int ExecStmt(const char *, edg_wll_Stmt *); - - void setUp() { - edg_wll_InitContext(&ctx); - ctx->mysql = (void *) this; /* XXX */ - } - -}; - -void QueryEventsTest::oneJob() -{ - edg_wll_QueryRec job[2]; - const edg_wll_QueryRec *jobs[2] = { job,NULL} ; - edg_wll_Event *events; - - job[0].attr = EDG_WLL_QUERY_ATTR_JOBID; - job[0].op = EDG_WLL_QUERY_OP_EQUAL ; - edg_wlc_JobIdParse("https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw", - &job[0].value.j); - job[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; - - string file(test_dir); - file += "/oneJob.qry"; - qry_file.open(file.c_str()); - - while (!qry_file.eof()) { - string query,line; - vector rows; - - getline(qry_file,query); - cout << "read: " << query < >(query,rows)); - } - - qry_file.close(); - - CPPUNIT_ASSERT(!edg_wll_QueryEventsServer(ctx,1,jobs,NULL,&events)); -} - -int QueryEventsTest::ExecStmt(const char *qry, edg_wll_Stmt *stmt_out) -{ - vector > >::iterator stmt = queries.begin(); - - for (; stmt != queries.end(); stmt++) { - const char *q = stmt->first.c_str(); - - /* XXX: there some spaces at the end of qry */ - if (!strncmp(q,qry,strlen(q))) break; - } - - if (stmt == queries.end()) { - cerr << "query not found" << endl; - CPPUNIT_ASSERT(0); - } - vector::iterator *rows = new vector::iterator(stmt->second.begin()); - - *stmt_out = (edg_wll_Stmt) rows; - return stmt->second.size()-1; -} - -extern "C" { - -int edg_wll_ExecStmt(edg_wll_Context ctx,char *qry,edg_wll_Stmt *stmt) -{ - cout << "edg_wll_ExecStmt: " << qry << endl; - - class QueryEventsTest *tst = (class QueryEventsTest *)(ctx->mysql); - return tst->ExecStmt(qry, stmt); -} - -int edg_wll_FetchRow(edg_wll_Stmt stmt, char **cols) -{ - vector::iterator *rows = (vector::iterator *) stmt; - char *row,*p,i=0; - - if (**rows == "END") return 0; - row = strdup((*rows)->c_str()); - (*rows)++; - for (p = strtok(row,"\t"); p; p = strtok(NULL,"\t")) - cols[i++] = strdup(p); - - return i; -} - -void edg_wll_FreeStmt(edg_wll_Stmt *) {} - -int debug; - -int edg_wll_QueryColumns(edg_wll_Stmt stmt, char**cols) {} -char *edg_wll_TimeToDB(long t) {} - -time_t edg_wll_DBToTime(char *c) {} -edg_wll_ErrorCode edg_wll_DBConnect(edg_wll_Context ctx, char*str) {} - - - - -} - -CPPUNIT_TEST_SUITE_REGISTRATION(QueryEventsTest); - -int main (int ac,const char *av[]) -{ - CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - CppUnit::TextUi::TestRunner runner; - - test_dir = ac >= 2 ? av[1] : "../test"; - - runner.addTest(suite); - return runner.run() ? 0 : 1; -} diff --git a/org.glite.lb.server/test/test_soap_conv.cpp b/org.glite.lb.server/test/test_soap_conv.cpp deleted file mode 100644 index f57d744..0000000 --- a/org.glite.lb.server/test/test_soap_conv.cpp +++ /dev/null @@ -1,319 +0,0 @@ -#include -#include - -#include -#include -#include -#include - -#include - -#include "bk_ws_H.h" -#include "ws_typeref.h" - -using namespace std; - -class SoapConvTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(SoapConvTest); - CPPUNIT_TEST(Conditions); - CPPUNIT_TEST(States); - CPPUNIT_TEST_SUITE_END(); - -private: - struct soap *soap; - edg_wll_QueryRec **stdConds; - edg_wll_JobStat stdStat; - - int stdRecCmp(edg_wll_QueryRec &, edg_wll_QueryRec &); - int stdCondsCmp(edg_wll_QueryRec **, edg_wll_QueryRec **); - int soapRecCmp(struct edgwll__QueryRec &, struct edgwll__QueryRec &); - int soapCondsCmp(struct edgwll__QueryConditions &, struct edgwll__QueryConditions &); - -public: - void setUp(); - - void Conditions(); - void States(); -}; - -void SoapConvTest::setUp() -{ - soap = soap_new(); - - stdConds = (edg_wll_QueryRec **)calloc(17, sizeof(edg_wll_QueryRec *)); - - stdConds[0] = (edg_wll_QueryRec *)calloc(4, sizeof(edg_wll_QueryRec)); - stdConds[0][0].attr = EDG_WLL_QUERY_ATTR_STATUS; - stdConds[0][0].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[0][0].value.i = EDG_WLL_JOB_DONE; - stdConds[0][1].attr = EDG_WLL_QUERY_ATTR_STATUS; - stdConds[0][1].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[0][1].value.i = EDG_WLL_JOB_RUNNING; - stdConds[0][2].attr = EDG_WLL_QUERY_ATTR_STATUS; - stdConds[0][2].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[0][2].value.i = EDG_WLL_JOB_CANCELLED; - - stdConds[1] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[1][0].attr = EDG_WLL_QUERY_ATTR_OWNER; - stdConds[1][0].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[1][0].value.c = NULL; - - stdConds[2] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[2][0].attr = EDG_WLL_QUERY_ATTR_JOBID; - stdConds[2][0].op = EDG_WLL_QUERY_OP_EQUAL; - edg_wlc_JobIdCreate("my.server.org", 9000, &(stdConds[2][0].value.j)); - - stdConds[3] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[3][0].attr = EDG_WLL_QUERY_ATTR_LOCATION; - stdConds[3][0].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[3][0].value.c = strdup("my_location"); - - stdConds[4] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[4][0].attr = EDG_WLL_QUERY_ATTR_DESTINATION; - stdConds[4][0].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[4][0].value.c = strdup("my_destination"); - - stdConds[5] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[5][0].attr = EDG_WLL_QUERY_ATTR_DONECODE; - stdConds[5][0].op = EDG_WLL_QUERY_OP_GREATER; - stdConds[5][0].value.i = 1; - - stdConds[6] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[6][0].attr = EDG_WLL_QUERY_ATTR_USERTAG; - stdConds[6][0].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[6][0].attr_id.tag = strdup("color"); - stdConds[6][0].value.c = strdup("red"); - - stdConds[7] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[7][0].attr = EDG_WLL_QUERY_ATTR_TIME; - stdConds[7][0].op = EDG_WLL_QUERY_OP_WITHIN; - stdConds[7][0].value.t = (struct timeval){10, 1}; - stdConds[7][0].value2.t = (struct timeval){20, 1}; - - stdConds[8] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[8][0].attr = EDG_WLL_QUERY_ATTR_LEVEL; - stdConds[8][0].op = EDG_WLL_QUERY_OP_WITHIN; - stdConds[8][0].value.i = 10; - stdConds[8][0].value2.i = 20; - - stdConds[9] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[9][0].attr = EDG_WLL_QUERY_ATTR_HOST; - stdConds[9][0].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[9][0].value.c = strdup("any.host"); - - stdConds[10] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[10][0].attr = EDG_WLL_QUERY_ATTR_SOURCE; - stdConds[10][0].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[10][0].value.i = 2; - - stdConds[11] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[11][0].attr = EDG_WLL_QUERY_ATTR_INSTANCE; - stdConds[11][0].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[11][0].value.c = strdup("any.instance"); - - stdConds[12] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[12][0].attr = EDG_WLL_QUERY_ATTR_EVENT_TYPE; - stdConds[12][0].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[12][0].value.i = 1; - - stdConds[13] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[13][0].attr = EDG_WLL_QUERY_ATTR_RESUBMITTED; - stdConds[13][0].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[13][0].value.c = strdup("where"); - - stdConds[14] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[14][0].attr = EDG_WLL_QUERY_ATTR_PARENT; - stdConds[14][0].op = EDG_WLL_QUERY_OP_EQUAL; - edg_wlc_JobIdCreate("my.server.org", 8000, &(stdConds[14][0].value.j)); - - stdConds[15] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[15][0].attr = EDG_WLL_QUERY_ATTR_EXITCODE; - stdConds[15][0].op = EDG_WLL_QUERY_OP_LESS; - stdConds[15][0].value.i = 255; -/* - * XXX: what is that for? - stdConds[13] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec)); - stdConds[13][0].attr = EDG_WLL_QUERY_ATTR_CHKPT_TAG; - stdConds[13][0].op = EDG_WLL_QUERY_OP_EQUAL; - stdConds[13][0].value.i = 1; -*/ -} - -int SoapConvTest::stdCondsCmp(edg_wll_QueryRec **c1, edg_wll_QueryRec **c2) -{ - int i, j; - - - if ( (c1 && !c2) || (!c1 && c2) ) return 1; - if ( c1 ) for ( i = 0; c1[i]; i++ ) { - if ( !c2[i] ) return 2; - for ( j = 0; c1[i][j].attr; j++ ) { - if ( !c2[i][j].attr ) return 3; - if ( stdRecCmp(c1[i][j], c2[i][j]) ) return 4; - } - if ( c2[i][j].attr ) return 3; - } - if ( c2[i] ) return 2; - - return 0; -} - -int SoapConvTest::stdRecCmp(edg_wll_QueryRec &qr1, edg_wll_QueryRec &qr2) -{ - if ( qr1.attr != qr2.attr ) return 1; - if ( qr1.op != qr2.op ) return 1; - switch ( qr1.attr) { - case EDG_WLL_QUERY_ATTR_USERTAG: - if ( strcmp(qr1.attr_id.tag, qr2.attr_id.tag) ) return 1; - case EDG_WLL_QUERY_ATTR_OWNER: - case EDG_WLL_QUERY_ATTR_LOCATION: - case EDG_WLL_QUERY_ATTR_DESTINATION: - case EDG_WLL_QUERY_ATTR_HOST: - case EDG_WLL_QUERY_ATTR_INSTANCE: - if ( (qr1.value.c && !qr2.value.c) || (!qr1.value.c && qr2.value.c) ) return 1; - if ( qr1.value.c && qr2.value.c && strcmp(qr1.value.c, qr2.value.c) ) return 1; - break; - case EDG_WLL_QUERY_ATTR_JOBID: - case EDG_WLL_QUERY_ATTR_PARENT: { - char *s1, *s2; - int rv; - - s1 = edg_wlc_JobIdUnparse(qr1.value.j); - s2 = edg_wlc_JobIdUnparse(qr2.value.j); - if ( !s1 || !s2 ) rv = 1; - else rv = strcmp(s1, s2); - free(s1); free(s2); - return rv; - } - break; - case EDG_WLL_QUERY_ATTR_STATUS: - case EDG_WLL_QUERY_ATTR_DONECODE: - case EDG_WLL_QUERY_ATTR_LEVEL: - case EDG_WLL_QUERY_ATTR_SOURCE: - case EDG_WLL_QUERY_ATTR_EVENT_TYPE: - case EDG_WLL_QUERY_ATTR_RESUBMITTED: - case EDG_WLL_QUERY_ATTR_EXITCODE: - if ( (qr1.value.i != qr2.value.i) - || (qr1.op == EDG_WLL_QUERY_OP_WITHIN && qr1.value2.i != qr2.value2.i) ) - return 1; - break; - case EDG_WLL_QUERY_ATTR_TIME: - if ( (qr1.value.t.tv_sec != qr2.value.t.tv_sec - || qr1.value.t.tv_usec != qr2.value.t.tv_usec) - || (qr1.op == EDG_WLL_QUERY_OP_WITHIN - && (qr1.value2.t.tv_sec != qr2.value2.t.tv_sec - || qr1.value2.t.tv_usec != qr2.value2.t.tv_usec)) ) - return 1; - break; - /* - * XXX: what about EDG_WLL_QUERY_ATTR_CHKPT_TAG ??? - */ - default: - return 1; - } - - return 0; -} - -int SoapConvTest::soapCondsCmp(struct edgwll__QueryConditions &qc1, struct edgwll__QueryConditions &qc2) -{ - int i, j; - - - if ( qc1.__sizecondition != qc2.__sizecondition ) return 1; - if ( (qc1.condition && !qc2.condition) || (!qc1.condition && qc2.condition) ) - for ( i = 0; i < qc1.__sizecondition; i++ ) { - if ( qc1.condition[i]->attr != qc2.condition[i]->attr ) return 2; - if ( qc1.condition[i]->__sizerecords != qc2.condition[i]->__sizerecords ) return 3; - for ( j = 0; j < qc1.condition[i]->__sizerecords; j++ ) - if ( soapRecCmp(*(qc1.condition[i]->records[j]), - *(qc2.condition[i]->records[j])) ) return 4; - } - - return 0; -} - -int SoapConvTest::soapRecCmp(struct edgwll__QueryRec &qr1, struct edgwll__QueryRec &qr2) -{ - if ( qr1.op != qr2.op ) return 1; - if ( (qr1.attrid->tag && !qr2.attrid->tag) - || (!qr1.attrid->tag && qr2.attrid->tag) - || (qr1.attrid->tag && strcmp(qr1.attrid->tag, qr2.attrid->tag)) ) return 2; - if ( (qr1.attrid->state && !qr2.attrid->state) - || (!qr1.attrid->state && qr2.attrid->state) - || (qr1.attrid->state && (qr1.attrid->state != qr2.attrid->state)) ) return 3; - - if ( (qr1.value1 && !qr2.value1) - || (!qr1.value1 && qr2.value1) ) return 3; - if ( qr1.value1 ) { - if ( (qr1.value1->i && !qr2.value1->i) - || (!qr1.value1->i && qr2.value1->i) - || (qr1.value1->i && qr1.value1->i != qr2.value1->i) ) - return 4; - if ( (qr1.value1->c && !qr2.value1->c) - || (!qr1.value1->c && qr2.value1->c) - || (qr1.value1->c && strcmp(qr1.value1->c,qr2.value1->c)) ) - return 4; - if ( (qr1.value1->t && !qr2.value1->t) - || (!qr1.value1->t && qr2.value1->t) - || (qr1.value1->t && memcmp(qr1.value1->t,qr2.value1->t,sizeof(*qr2.value1->t))) ) - return 4; - } - - if ( (qr1.value2 && !qr2.value2) - || (!qr1.value2 && qr2.value2) ) return 3; - if ( qr1.value2 ) { - if ( (qr1.value2->i && !qr2.value2->i) - || (!qr1.value2->i && qr2.value2->i) - || (qr1.value2->i && qr1.value2->i != qr2.value2->i) ) - return 4; - if ( (qr1.value2->c && !qr2.value2->c) - || (!qr1.value2->c && qr2.value2->c) - || (qr1.value2->c && strcmp(qr1.value2->c,qr2.value2->c)) ) - return 4; - if ( (qr1.value2->t && !qr2.value2->t) - || (!qr1.value2->t && qr2.value2->t) - || (qr1.value2->t && memcmp(qr1.value2->t,qr2.value2->t,sizeof(*qr2.value2->t))) ) - return 4; - } - - - return 0; -} - -void SoapConvTest::Conditions() -{ - struct edgwll__QueryConditions *soapConds, *soapConds2; - edg_wll_QueryRec **stdConds2; - int ret; - - ret = edg_wll_QueryCondsExtToSoap(soap, (const edg_wll_QueryRec**)stdConds, &soapConds); - CPPUNIT_ASSERT_MESSAGE("edg_wll_QueryCondsExtToSoap()", ret == SOAP_OK); - ret = edg_wll_SoapToQueryCondsExt(soapConds, &stdConds2); - CPPUNIT_ASSERT_MESSAGE("edg_wll_SoapToQueryCondsExt()", !ret); - - CPPUNIT_ASSERT_MESSAGE("Converted std results differs", !stdCondsCmp(stdConds, stdConds2)); - - ret = edg_wll_QueryCondsExtToSoap(soap, (const edg_wll_QueryRec**)stdConds2, &soapConds2); - CPPUNIT_ASSERT_MESSAGE("edg_wll_QueryCondsExtToSoap()", ret == SOAP_OK); - - CPPUNIT_ASSERT_MESSAGE("Converted soap results differs", !soapCondsCmp(*soapConds, *soapConds2)); -} - -void SoapConvTest::States() -{ - struct edgwll__JobStat *soapStat; - edg_wll_JobStat stdStat2; -} - -CPPUNIT_TEST_SUITE_REGISTRATION(SoapConvTest); - -int main (int ac,const char *av[]) -{ - CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - CppUnit::TextUi::TestRunner runner; - - runner.addTest(suite); - return runner.run() ? 0 : 1; -} diff --git a/org.glite.lb.server/test/test_xml.cpp.T b/org.glite.lb.server/test/test_xml.cpp.T deleted file mode 100644 index d52cd61..0000000 --- a/org.glite.lb.server/test/test_xml.cpp.T +++ /dev/null @@ -1,212 +0,0 @@ -#include - -#include -#include -#include -#include - - -#include -#include "lb_xml_parse.h" -#include - -class XMLParseTest: public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(XMLParseTest); - CPPUNIT_TEST(protoEventTest); - CPPUNIT_TEST(protoStatusTest); - CPPUNIT_TEST_SUITE_END(); - -public: - void protoEventTest(); - void protoStatusTest(); - - -}; - -static char * compare_events(const edg_wll_Event *e1, const edg_wll_Event *e2) -{ - if (e1->any.type != e2->any.type) return "type"; -@@@{ - selectType $event '_common_'; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = getName $f; - my $ft = $f->{type}; - - my $a = "e1->any.$fn"; - my $b = "e2->any.$fn"; - - gen "\tif (!(".eval($main::compare{C}->{$ft}).")) return \"$fn\";\n"; - } - - gen "\tswitch(e1->any.type) {\n"; - for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } - $event->getTypes) - { - my $tu = uc $t; - my $tl = lcfirst $t; - - selectType $event $t; - gen "\t\tcase EDG_WLL_EVENT\_$tu :\n"; - for ($event->getFieldsOrdered) { - my $f = selectField $event $_; - my $fn = $f->{name}; - my $ft = $f->{type}; - - my $a = "e1->$tl.$fn"; - my $b = "e2->$tl.$fn"; - - gen "\t\t\tif (!(".eval($main::compare{C}->{$ft}).")) return \"$fn\";\n"; - } - gen "\t\tbreak;\n"; - } -@@@} - default: return "default"; - } /* switch */ - return NULL; -} - -static char * compare_states(const edg_wll_JobStat s1, const edg_wll_JobStat s2) -{ -@@@{ - selectType $status '_common_'; - for (getFieldsOrdered $status) { - my $f = selectField $status $_; - my $fn = getName $f; - my $ft = $f->{type}; - - my $a = "s1.$fn"; - my $b = "s2.$fn"; - - if ($ft eq 'intlist') { - gen "\tif ( (s1.$_ != NULL) && (s2.$_ == NULL) || (s1.$_ == NULL) && (s2.$_ != NULL) ) return \"$fn\";\n"; - } - elsif ($ft eq 'strlist') { - } - elsif ($ft eq 'taglist') { - } - elsif ($ft eq 'stslist') { - } - else { - gen "\tif (!(".eval($main::compare{C}->{$ft}).")) return \"$fn\";\n"; - } - } -@@@} - return NULL; -} - -void XMLParseTest::protoEventTest() -{ - edg_wll_Context ctx; - edg_wll_Event *e1, *e2; - char *message, *et, *ed; - - edg_wll_InitContext(&ctx); - e1 = (edg_wll_Event *) calloc(2,sizeof *e1); - e1->any.type = EDG_WLL_EVENT_REGJOB; - - e1->regJob.jdl = strdup("very long job = \"blabla\" \\\\ \n hugh\t;"); - e1->regJob.ns = strdup("ns address"); - e1->regJob.jobtype = EDG_WLL_REGJOB_SIMPLE; - e1->regJob.seed = strdup("1234"); - - gettimeofday(&e1->any.timestamp,NULL); - - e1->any.host = strdup("some.host"); - e1->any.level = 7; - e1->any.priority = 0; - edg_wlc_JobIdParse("https://some.host:1234/x67qr549qc",&e1->any.jobId); - e1->any.seqcode = EDG_WLL_SEQ_BIGHELPER_INITIAL; - e1->any.user = strdup("/O=Grid/CN=This User"); - e1->any.source = EDG_WLL_SOURCE_USER_INTERFACE; - e1->any.src_instance = strdup("UI"); - - if (edg_wll_QueryEventsToXML(ctx, e1, &message)) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("QueryEventsToXML():") + et + " " + ed, 0); - } - - CPPUNIT_ASSERT_MESSAGE("message: ", message); - - if (edg_wll_ParseQueryEvents(ctx, message, &e2)) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("ParseQueryEvents():") + et + " " + ed, 0); - } - - if ((et = compare_events(e1,e2))) { - CPPUNIT_ASSERT_MESSAGE(std::string("compare_events():") + et, 0); - } -} - -void XMLParseTest::protoStatusTest() -{ - edg_wll_Context ctx; - edg_wll_JobStat s1, s2; - char *message, *et, *ed; - const struct timeval some_timeval = {14,12}; - - - edg_wll_InitContext(&ctx); - edg_wll_InitStatus(&s1); - - s1.state = EDG_WLL_JOB_SUBMITTED; - edg_wlc_JobIdParse("https://some.host:1234/x67qr549qc",&s1.jobId); - s1.owner = strdup("/O=Grid/CN=This User"); - s1.jobtype = EDG_WLL_STAT_SIMPLE; - s1.seed = strdup("4321"); - s1.condorId = strdup("condorId"); - s1.globusId = strdup("globusId"); - s1.localId = strdup("localId"); - s1.jdl = strdup("jdl"); - s1.matched_jdl = strdup("matched_jdl"); - s1.destination = strdup("destination"); - s1.condor_jdl = strdup("condor_jdl"); - s1.rsl = strdup("rsl"); - s1.reason = strdup("reason"); - s1.location = strdup("location"); - s1.ce_node = strdup("ce_node"); - s1.network_server = strdup("network_server"); - s1.subjob_failed = 1; - s1.done_code = EDG_WLL_STAT_FAILED; - s1.exit_code = 123; - s1.resubmitted = 1; - s1.cancelling = 1; - s1.cancelReason = strdup("cancelReason"); - s1.cpuTime = 10; - s1.stateEnterTime = some_timeval; - s1.lastUpdateTime = some_timeval; - s1.expectUpdate = 20; - s1.expectFrom = strdup("expectFrom"); - s1.acl = strdup("acl"); - - if (edg_wll_JobStatusToXML(ctx, s1, &message)) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("QueryEventsToXML():") + et + " " + ed, 0); - } - - CPPUNIT_ASSERT_MESSAGE("message: ", message); - - if (edg_wll_ParseJobStat(ctx, message, (long) strlen(message), &s2)) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("ParseJobStat():") + et + " " + ed, 0); - } - - if ((et = compare_states(s1,s2))) { - CPPUNIT_ASSERT_MESSAGE(std::string("compare_states():") + et, 0); - } - - - -} - -CPPUNIT_TEST_SUITE_REGISTRATION(XMLParseTest); - -int main (int ac,const char *av[]) -{ - CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - CppUnit::TextUi::TestRunner runner; - - runner.addTest(suite); - return runner.run() ? 0 : 1; -} diff --git a/org.glite.lb.ws-interface/.Makefile.swp b/org.glite.lb.ws-interface/.Makefile.swp deleted file mode 100644 index 15a25d6416ea369d578b3b53c31d08733434e2d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&u`;I6vy8pBnUs21#X;%G+MzT+wE>uiAWZ-yP*x6w!3L}K^0Qvj3LJL*l|8fPgC}wEO}5I3ffGZcx7CIE|A!bkQOqt;W%(u{|?y-uu3p zIW(^|f3v>Mmds0p>m1QHe|)<9-p^?+=_SHgTC{?wW2O(LY?*JxhSy6()ONVA)}1}k_N16G zkAAHc&mKr5gX&UCT`;@E zOOuaMIK3)SiMyK_A6V%cS*>kv4ycqZ({U2=W*ha(wT-P> zZfM+fB4N1!hmp|Xdrn6TjLP9{5yf86gFVCF!(L!Uc&~$UPG&wvVXN;+ z7c&=Z%UrA4n27`T_`$S|%AxDUNxF{b%U5g9kG44*YHLp( z2)UU_S%(RAaHyl@L=1(Ko{VNHf>V6P$u#oWFvLEWeODOmDDdqt3T_FWScqshYk;VQ zDV;v&lnbkk&6WD<#%8l-mkWoLRWBYgqlrUwmgU@9$uGM?gQxJ-^be8iU>(; rbEwJiR%KzdlcwCQ9F7_WG`h3X8ye>h*5=q1(RTVWVYeOG7cu<}0Tiz2 diff --git a/org.glite.lb.ws-interface/.cvsignore b/org.glite.lb.ws-interface/.cvsignore deleted file mode 100755 index 1df717b..0000000 --- a/org.glite.lb.ws-interface/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -.project -.cdtproject \ No newline at end of file diff --git a/org.glite.lb.ws-interface/LICENSE b/org.glite.lb.ws-interface/LICENSE deleted file mode 100755 index 01b973b..0000000 --- a/org.glite.lb.ws-interface/LICENSE +++ /dev/null @@ -1,69 +0,0 @@ -LICENSE file for EGEE Middleware -================================ - -Copyright (c) 2004 on behalf of the EU EGEE Project: -The European Organization for Nuclear Research (CERN), -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Datamat Spa, Italy -Centre National de la Recherche Scientifique (CNRS), France -CS Systeme d'Information (CSSI), France -Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden -Universiteit van Amsterdam (UvA), Netherlands -University of Helsinki (UH.HIP), Finlan -University of Bergen (UiB), Norway -Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. The end-user documentation included with the redistribution, if -any, must include the following acknowledgment: "This product includes -software developed by The EU EGEE Project (http://cern.ch/eu-egee/)." -Alternatively, this acknowledgment may appear in the software itself, if -and wherever such third-party acknowledgments normally appear. - -4. The names EGEE and the EU EGEE Project must not be -used to endorse or promote products derived from this software without -prior written permission. For written permission, please contact -. - -5. You are under no obligation whatsoever to provide anyone with any -bug fixes, patches, or upgrades to the features, functionality or -performance of the Software ("Enhancements") that you may develop over -time; however, if you choose to provide your Enhancements to The EU -EGEE Project, or if you choose to otherwise publish or distribute your -Enhancements, in source code form without contemporaneously requiring -end users of The EU EGEE Proejct to enter into a separate written license -agreement for such Enhancements, then you hereby grant The EU EGEE Project -a non-exclusive, royalty-free perpetual license to install, use, copy, -modify, prepare derivative works, incorporate into the EGEE Middleware -or any other computer software, distribute, and sublicense your -Enhancements or derivative works thereof, in binary and source code -form (if any), whether developed by The EU EGEE Project or third parties. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL PROJECT OR ITS CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This software consists of voluntary contributions made by many -individuals on behalf of the EU EGEE Prject. For more information on The -EU EGEE Project, please see http://cern.ch/eu-egee/. For more information on -EGEE Middleware, please see http://egee-jra1.web.cern.ch/egee-jra1/ - - diff --git a/org.glite.lb.ws-interface/Makefile b/org.glite.lb.ws-interface/Makefile deleted file mode 100644 index 051fdeb..0000000 --- a/org.glite.lb.ws-interface/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -# Default values -top_srcdir=. -builddir=build -top_builddir=${top_srcdir}/${builddir} -stagedir=. -distdir=. -globalprefix=glite -lbprefix=lb -package=glite-lb-ws-interface -version=0.0.0 -PREFIX=/opt/glite - --include Makefile.inc - -VPATH=${top_srcdir}/interface -STAGETO=interface - -WSDL=LB.wsdl - -all compile: - -check: - @echo No unit test required for interface-only module. - -stage: - $(MAKE) install PREFIX=${stagedir} - -dist: distsrc distbin - -distsrc: - mkdir -p ${top_srcdir}/${package}-${version} - cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version} - cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version} - rm -rf ${top_srcdir}/${package}-${version} - -distbin: - $(MAKE) install PREFIX=${top_srcdir}/tmpbuilddir - cd ${top_srcdir}/tmpbuilddir && tar -czf ${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz * - rm -rf ${top_srcdir}/tmpbuilddir - -install: - -mkdir -p ${PREFIX}/${STAGETO} - -mkdir -p ${PREFIX}/share/doc/${package}-${version} - install -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} - cd ${top_srcdir}/interface && install -m 644 ${WSDL} ${PREFIX}/${STAGETO} - -clean: - rm -f *.h - diff --git a/org.glite.lb.ws-interface/build.xml b/org.glite.lb.ws-interface/build.xml deleted file mode 100644 index b412fb1..0000000 --- a/org.glite.lb.ws-interface/build.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.ws-interface/interface/LB.wsdl b/org.glite.lb.ws-interface/interface/LB.wsdl deleted file mode 100755 index dfbce26..0000000 --- a/org.glite.lb.ws-interface/interface/LB.wsdl +++ /dev/null @@ -1,358 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Query the version of LB servere - -Input: no input - -Output: Version of LB server - -Faults: GenericLBFault - - - - - - - Retrieve state of a single job. - -Given a job id queries LB for detailed state of the job. - - -Input: - -jobid: Id of the job - -flags: Which fields of the job state should be retrieved: zero or more of CLASSADS, CHILDREN, CHILDSTAT - -Output: state of the job - -Faults: GenericLBFault - - - - - - - Query for jobs satisfying set of conditions. - -Intput: - -conditions: list of lists of query conditions. - Elements of the inner lists refer to a single job attribute, the conditions are or-ed. - Elements of the outer list may refer to different job attributes, they are and-ed. - -flags: Which fields of the job state should be retrieved: see JobStatus - -Output: list of mathching jobs, including their states - -Faults: GenericLBFault - - - - - - - Query all jobs of the current user. - -Input: no input - -Output: list of all user's jobs, including their states - -Faults: GenericLBFault - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Logging and Bookkeeping service - - - - - diff --git a/org.glite.lb.ws-interface/project/build.properties b/org.glite.lb.ws-interface/project/build.properties deleted file mode 100755 index e69de29..0000000 diff --git a/org.glite.lb.ws-interface/project/configure.properties.xml b/org.glite.lb.ws-interface/project/configure.properties.xml deleted file mode 100644 index 563b7bd..0000000 --- a/org.glite.lb.ws-interface/project/configure.properties.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - -top_srcdir=.. -builddir=build -stagedir=${stage.abs.dir} -distdir=${dist.dir} -globalprefix=${global.prefix} -lbprefix=${subsystem.prefix} -package=${module.package.name} -PREFIX=${install.dir} -version=${module.version} -glite_location=${with.glite.location} - - - diff --git a/org.glite.lb.ws-interface/project/properties.xml b/org.glite.lb.ws-interface/project/properties.xml deleted file mode 100644 index 736515e..0000000 --- a/org.glite.lb.ws-interface/project/properties.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb.ws-interface/project/tar_exclude b/org.glite.lb.ws-interface/project/tar_exclude deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.lb.ws-interface/project/version.properties b/org.glite.lb.ws-interface/project/version.properties deleted file mode 100755 index d74a1c4..0000000 --- a/org.glite.lb.ws-interface/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Dec 09 04:53:34 CET 2004 -module.version=0.1.0 -module.build=12 -module.age=0 diff --git a/org.glite.lb/.cvsignore b/org.glite.lb/.cvsignore deleted file mode 100644 index 1df717b..0000000 --- a/org.glite.lb/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -.project -.cdtproject \ No newline at end of file diff --git a/org.glite.lb/LICENSE b/org.glite.lb/LICENSE deleted file mode 100644 index 259a91f..0000000 --- a/org.glite.lb/LICENSE +++ /dev/null @@ -1,69 +0,0 @@ -LICENSE file for EGEE Middleware -================================ - -Copyright (c) 2004 on behalf of the EU EGEE Project: -The European Organization for Nuclear Research (CERN), -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Datamat Spa, Italy -Centre National de la Recherche Scientifique (CNRS), France -CS Systeme d'Information (CSSI), France -Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden -Universiteit van Amsterdam (UvA), Netherlands -University of Helsinki (UH.HIP), Finlan -University of Bergen (UiB), Norway -Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. The end-user documentation included with the redistribution, if -any, must include the following acknowledgment: "This product includes -software developed by The EU EGEE Project (http://cern.ch/eu-egee/)." -Alternatively, this acknowledgment may appear in the software itself, if -and wherever such third-party acknowledgments normally appear. - -4. The names EGEE and the EU EGEE Project must not be -used to endorse or promote products derived from this software without -prior written permission. For written permission, please contact -. - -5. You are under no obligation whatsoever to provide anyone with any -bug fixes, patches, or upgrades to the features, functionality or -performance of the Software ("Enhancements") that you may develop over -time; however, if you choose to provide your Enhancements to The EU -EGEE Project, or if you choose to otherwise publish or distribute your -Enhancements, in source code form without contemporaneously requiring -end users of The EU EGEE Proejct to enter into a separate written license -agreement for such Enhancements, then you hereby grant The EU EGEE Project -a non-exclusive, royalty-free perpetual license to install, use, copy, -modify, prepare derivative works, incorporate into the EGEE Middleware -or any other computer software, distribute, and sublicense your -Enhancements or derivative works thereof, in binary and source code -form (if any), whether developed by The EU EGEE Project or third parties. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL PROJECT OR ITS CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This software consists of voluntary contributions made by many -individuals on behalf of the EU EGEE Prject. For more information on The -EU EGEE Project, please see http://cern.ch/eu-egee/. For more information on -EGEE Middleware, please see http://egee-jra1.web.cern.ch/egee-jra1/ - - diff --git a/org.glite.lb/build.xml b/org.glite.lb/build.xml deleted file mode 100755 index 2ded065..0000000 --- a/org.glite.lb/build.xml +++ /dev/null @@ -1,393 +0,0 @@ - - - - - - - Ant build file to build the GLite Logging and Bookkeping Subsystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Preparing directories ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <project name="${subsystem.name}" type="post-subsystem" packageName="${global.prefix}-${subsystem.prefix}"/> - - - - diff --git a/org.glite.lb/project/MultiStruct.pm b/org.glite.lb/project/MultiStruct.pm deleted file mode 100644 index 9cd847c..0000000 --- a/org.glite.lb/project/MultiStruct.pm +++ /dev/null @@ -1,191 +0,0 @@ -package MultiStruct; - -use StructField; - -sub new { - shift; - my $self = {}; - $self->{comments} = {}; # typ->comment - $self->{fields} = {}; # typ->{ name->StructField, ... } - $self->{order} = {}; - - bless $self; -} - -sub selectType { - my $self = shift; - my $type = shift; - $self->{type} = $type; - 1; -} - -sub addType { - my $self = shift; - my $type = shift; - my $comment = shift; - $self->selectType($type); - $self->{comments}->{$type} = $comment; - $self->{fields}->{$type} = {}; - 1; -} - -sub selectField { - my $self = shift; - $self->{field} = shift; - $self->getField; -} - -sub addField { - my $self = shift; - my $field = shift; - - die "unselected type" unless $self->{type}; - $self->{fields}->{$self->{type}}->{$field->{name}} = $field; - $self->selectField($field->{name}); - 1; -} - -sub getField { - my $self = shift; - my $f = $self->{fields}->{$self->{type}}->{$self->{field}}; - return $f ? $f : $self->{fields}->{_common_}->{$self->{field}}; -} - -sub load { - my $self = shift; - my $fh = shift; - local $_; - - while ($_ = <$fh>) { - - chomp; - s/#.*$//; - next if /^\s*$/; - - if (/^\@type\s+(\S+)\s*(.*$)$/) { - $self->addType($1,$2); - $self->{order}->{$1} = $.; - next; - } - - s/^\s*//; - my ($ftype,$fname,$comment) = split /\s+/,$_,3; - if ($ftype eq '_code_') { - my $f = $self->getField(); - addCode $f $fname,$comment; - } - elsif ($ftype eq '_alias_') { - my $f = $self->getField(); - addAlias $f $fname,$comment; - } - elsif ($ftype eq '_special_') { - my $f = $self->getField(); - addSpecial $f $fname; - } - elsif ($ftype eq '_null_') { - my $f = $self->getField(); - setNull $f $fname; - } - elsif ($ftype eq '_optional_') { - my $f = $self->getField(); - $f->{optional} = 1; - } - elsif ($ftype eq '_index_') { - my $f = $self->getField(); - $f->{index} = 1; - } - else { - my $f = new StructField $fname,$ftype,$comment,$.; - $self->addField($f); - } - } -} - -sub getTypes { - my $self = shift; - my @out; - local $_; - - for (keys %{$self->{fields}}) { - push @out,$_ unless $_ eq '_common_'; - } - @out; -} - -sub getTypesOrdered { - my $self = shift; - my @names = getTypes $self; - - sort { - my $oa = $self->{order}->{$a}; - my $ob = $self->{order}->{$b}; - $oa <=> $ob; - } @names; -} - -sub getTypeComment { - my $self = shift; - my $type = shift || $self->{type}; - $self->{comments}->{$type}; -} - -sub getFieldComment { - my $self = shift; - my $fname = shift; - $self->{fields}->{$self->{type}}->{$fname}->{comment}; -} - -sub getFields { - my $self = shift; - keys %{$self->{fields}->{$self->{type}}}; -} - -sub getFieldsOrdered { - my $self = shift; - my @names = $self->getFields; - sort { - my $oa = $self->selectField($a)->{order}; - my $ob = $self->selectField($b)->{order}; - $oa <=> $ob; - } @names; -} - -sub getFieldOccurence { - my $self = shift; - my $fname = shift; - my @out; - local $_; - - for (keys %{$self->{fields}}) { - push @out,$_ if $self->{fields}->{$_}->{$fname}; - } - @out; -} - -sub getAllFields { - my $self = shift; - my %out; - local $_; - - for my $t (values %{$self->{fields}}) { - $out{$_->{name}} = 1 for (values %$t); - } - keys %out; -} - -sub getAllFieldsOrdered { - my $self = shift; - my @names = getAllFields $self; - - sort { - my @occ = $self->getFieldOccurence($a); - $self->selectType($occ[0]); - my $oa = $self->selectField($a)->{order}; - @occ = $self->getFieldOccurence($b); - $self->selectType($occ[0]); - my $ob = $self->selectField($b)->{order}; - $oa <=> $ob; - } @names; -} - -1; diff --git a/org.glite.lb/project/StructField.pm b/org.glite.lb/project/StructField.pm deleted file mode 100644 index 95d33b8..0000000 --- a/org.glite.lb/project/StructField.pm +++ /dev/null @@ -1,116 +0,0 @@ -package StructField; - -$lang = 'C'; -1; - -sub new { - shift; - my $self = {}; - $self->{name} = shift; - $self->{type} = shift; - $self->{comment} = shift; - $self->{order} = shift; - $self->{null} = $main::DefaultNullValue{$self->{type}}; - bless $self; -} - -sub addCode { - my $self = shift; - my $code = shift; - my $comment = shift; - push @{$self->{codes}},{name=>$code,comment=>$comment}; - 1; -} - -sub addSpecial { - my $self = shift; - my $special = shift; - $self->{special} = $special; - 1; -} - -sub addAlias { - my $self = shift; - my $name = shift; - my $lang = shift; - $self->{aliases}->{$lang} = $name; - 1; -} - -sub hasAlias { - my $self = shift; - my $lang = shift; - return $self->{aliases}->{$lang} ? 1 : 0; -} - -sub getName { - my $self = shift; - my $lang = shift || $lang; - $self->{aliases}->{$lang} || $self->{name}; -# return $self->{aliases}->{$lang} ? $self->{aliases}->{$lang} : $self->{name}; -} - -sub getComment { - my $self = shift; - $self->{comment}; -} - -sub getDefaultNullValue { - my $self = shift; - $self->{null}; -} - -sub toString { - my $self = shift; - my $src = shift; - my $dst = shift; - - eval $main::toString{$lang}->{$self->{type}}; -} - -sub fromString { - my $self = shift; - my $src = shift; - my $dst = shift; - - eval $main::fromString{$lang}->{$self->{type}}; -} - -sub isNULL { - my $self = shift; - my $a = shift; - my $b = $self->{null}; - - eval $main::compare{$lang}->{$self->{type}}; -} - -sub isnotNULL { - my $self = shift; - my $src = shift; - - '!('.$self->isNULL($src).')'; -} - -sub compare { - my $self = shift; - my $a = shift; - my $b = shift; - eval $main::compare{$lang}->{$self->{type}}; -} - -sub toFormatString { - my $self = shift; - - eval $main::toFormatString{$lang}->{$self->{type}}; -} - -sub setNull { - my $self = shift; - $self->{null} = shift; -} - -sub getType { - my $self = shift; - - eval $main::types{$lang}->{$self->{type}}; -} diff --git a/org.glite.lb/project/at3 b/org.glite.lb/project/at3 deleted file mode 100755 index 8ff52ec..0000000 --- a/org.glite.lb/project/at3 +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/perl -w - -use File::Basename; -my $dir; -BEGIN{ - $dir = dirname $0; -} - -my $lines = $ENV{AT3_LINES}; - -use lib $dir; -use MultiStruct; -require 'types.T'; - -my $eventsn; -for (@INC) { - if (-f "$_/events.T") { - $eventsn="$_/events.T"; - last; - } -} - -my $statusn; -for (@INC) { - if (-f "$_/status.T") { - $statusn = "$_/status.T"; - last; - } -} - -my $indent = ''; - -my $event = new MultiStruct; -my $status = new MultiStruct; - -sub gen { - local $_ = shift; - - s/^\n!//; - s/\n!/\n/g; - print $_; -} - - -open EVENTS,$eventsn or die "$eventsn: $!\n"; -$event->load(\*EVENTS); -close EVENTS; - -open STATUS,$statusn or die "$statusn: $!\n"; -$status->load(\*STATUS); -close STATUS; - -my $code; -my $startcode; -while (<>) { - chomp; - if (/^\@\@\@LANG: (\S+)$/) { - $StructField::lang = $1; - next; - } - - if ($code) { - if (/^\@\@\@}$/) { - $code .= "1;\n"; - print "#line $startcode \"$ARGV\"\n/* begin */\n" if $lines; - eval $code or warn "eval: $@ at $ARGV:$.\n"; - my $nxtline = $.+1; - print "/* end */\n#line $nxtline \"$ARGV\"\n" if $lines; - undef $code; - } - else { $code .= $_."\n"; } - } - else { - if (/^\@\@\@{$/) { - $startcode = $.; - $code = "\n"; - } - elsif (/^\@\@\@AUTO$/) { - print qq{ - !! Automatically generated file - !! Do not edit, your changes will be discarded upon build - !! Change the corresponding template file $ARGV - -}; - print "#line $. \"$ARGV\"\n" if $lines; - } - else { - print "$_\n"; - } - } -} - -# print $event_common{prog}->copy('bla','hu'); diff --git a/org.glite.lb/project/build.properties b/org.glite.lb/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.lb/project/dependencies.properties b/org.glite.lb/project/dependencies.properties deleted file mode 100644 index 8757f10..0000000 --- a/org.glite.lb/project/dependencies.properties +++ /dev/null @@ -1,15 +0,0 @@ -################################################################### -# System dependencies -################################################################### - -org.glite.version = HEAD -org.glite.lb.version = HEAD - -# Component dependencies tag = do not remove this line = -org.glite.lb.client-interface.version = HEAD -org.glite.lb.ws-interface.version = HEAD -org.glite.lb.common.version = HEAD -org.glite.lb.client.version = HEAD -org.glite.lb.server.version = HEAD -org.glite.lb.server-bones.version = HEAD -org.glite.lb.logger.version = HEAD diff --git a/org.glite.lb/project/events.T b/org.glite.lb/project/events.T deleted file mode 100644 index b8e5399..0000000 --- a/org.glite.lb/project/events.T +++ /dev/null @@ -1,183 +0,0 @@ -@type _common_ - timeval timestamp timestamp of event generation - _alias_ date ULM - timeval arrived timestamp of event store - _alias_ arr_date ULM - _optional_ - string host hostname of the machine where the event was generated - _alias_ host ULM - int level logging level (system, debug, ...) - _alias_ lvl ULM - _code_ EMERGENCY emergency - _code_ ALERT alert - _code_ ERROR error - _code_ WARNING warning - _code_ AUTH authentication - _code_ SECURITY security - _code_ USAGE usage - _code_ SYSTEM system - _code_ IMPORTANT important - _code_ DEBUG debug - int priority message priority (yet 0 for asynchronous and 1 for synchronous transfers) - _null_ -1 - jobid jobId DataGrid job id of the source job - string seqcode sequence code assigned to the event - string user identity (cert. subj.) of the generator - logsrc source source (WMS component) which generated this event -# string prog name of program ("EDG WMS" of name of the application) - string src_instance instance of WMS component (e.g. service communication endpoint) - _optional_ - -@type Transfer Start, success, or failure of job transfer to another component - logsrc destination destination where the job is being transfered to - string dest_host destination hostname - string dest_instance destination instance - _optional_ - string job job description in receiver language - int result result of the attempt - _code_ START the sending component has started or is about to start the transfer - _code_ OK job was sent successfully - _code_ REFUSED job was refused by the other component - _code_ FAIL transfer failed for other reason than explicit refusal (eg. network timeout) - string reason detailed description of transfer, especially reason of failure - _optional_ - string dest_jobid destination internal jobid - _optional_ - -@type Accepted Accepting job (successful couterpart to Transfer) - logsrc from where was the job received from - string from_host sending component hostname - string from_instance sending component instance - _optional_ - string local_jobid new jobId (Condor, Globus ...) assigned by the receiving component - -@type Refused Refusing job (unsuccessful couterpart to Transfer) - logsrc from where was the job received from - string from_host sending component hostname - string from_instance sending component instance - _optional_ - string reason reason of refusal - -@type EnQueued The job has been enqueued in an inter-component queue - string queue destination queue - string job job description in receiver language - int result result of the attempt - _code_ START the sending component has started or is about to start the transfer - _code_ OK job was sent successfully - _code_ REFUSED job was refused by the other component - _code_ FAIL transfer failed for other reason than explicit refusal (eg. network timeout) - string reason detailed description of transfer, especially reason of failure - -@type DeQueued The job has been dequeued from an inter-component queue - string queue queue name - string local_jobid new jobId assigned by the receiving component - -@type HelperCall Helper component is called - string helper_name name of the called component - string helper_params parameters of the call - int src_role whether the logging component is called or calling one - _code_ CALLING the logging component is caller - _code_ CALLED the logging component is callee - -@type HelperReturn Helper component is returning the control - string helper_name name of the called component - string retval returned data - int src_role whether the logging component is called or calling one - _code_ CALLING the logging component is caller - _code_ CALLED the logging component is callee - -@type Running Executable started - string node worker node where the executable is run - -@type Resubmission Result of resubmission decision - int result result code - _code_ WILLRESUB will be resubmitted - _code_ WONTRESUB will not be resubmitted - string reason reason for the decision - string tag value of the attribute on which the decision is based - -@type Done Execution terminated (normally or abnormally) - int status_code way of termination - _code_ OK terminated by itself - _code_ FAILED disappeared from LRMS - _code_ CANCELLED cancelled by user request - string reason reason for the change - int exit_code process exit code - _null_ -1 - -@type Cancel Cancel operation has been attempted on the job - int status_code classification of the cancel - _code_ REQ request acknowledged - _code_ REFUSE request declined by this component - _code_ DONE request completed by whole WMS - _code_ ABORT request refused by whole WMS - string reason detailed description - -@type Abort Job aborted by system - string reason reason of abort - -@type Clear Job cleared, output sandbox removed - int reason why the job was cleared - _code_ USER user retrieved output sandbox - _code_ TIMEOUT timed out, resource purge forced - _code_ NOOUTPUT no output was generated - -@type Purge Job is purged from bookkepping server - -@type Match Matching CE found - string dest_id Id of the destination CE/queue - -@type Pending No match found yet - string reason why matching CE cannot be found - -@type RegJob New job registration - string jdl job description - string ns NetworkServer handling the job - jobid parent jobid of parent job - _optional_ - - int jobtype job type - _code_ SIMPLE simple job - _code_ DAG dag (containing static set of subjobs) - _code_ PARTITIONABLE partitionable (may become partitioned) - _code_ PARTITIONED partitioned (dynamically created dag) - - int nsubjobs number of subjobs - _optional_ - string seed seed for subjob id generation - _optional_ - -@type Chkpt Application-specific checkpoint record - string tag checkpoint tag - string classad checkpoint value - -@type Listener Listening network port for interactive control - string svc_name port instance name - string svc_host hostname - port svc_port port number - -@type CurDescr current state of job processing (optional event) - string descr description of current job transformation (output of helper) - -@type UserTag user tag -- arbitrary name=value pair - string name tag name - string value tag value - -@type ChangeACL Management of ACL stored on bookkepping server - string user_id DN or VOMS parameter (in format VO:group) - int user_id_type type of information given in user_id (DN or VOMS) - _null_ -1 - int permission ACL permission to change (currently only READ) - _null_ -1 - int permission_type type of permission requested ('allow', 'deny') - _null_ -1 - int operation operation requested to perform with ACL (add, remove) - _null_ -1 - -@type Notification Management of notification service - notifid notifId notification id - string owner owner - string dest_host destination host - port dest_port destination port - string jobstat job status - diff --git a/org.glite.lb/project/glite.lb.csf.xml b/org.glite.lb/project/glite.lb.csf.xml deleted file mode 100644 index d78376b..0000000 --- a/org.glite.lb/project/glite.lb.csf.xml +++ /dev/null @@ -1,335 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The org.glite and org.glite.lb modules have been updated, please rerun the configuration file - - - - The org.glite and org.glite.lb modules have been updated, please rerun the configuration file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.lb/project/properties.xml b/org.glite.lb/project/properties.xml deleted file mode 100755 index 0d0291a..0000000 --- a/org.glite.lb/project/properties.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.glite.lb/project/run-workspace b/org.glite.lb/project/run-workspace deleted file mode 100644 index 03a3381..0000000 --- a/org.glite.lb/project/run-workspace +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -cd ../.. - -cvs co org.glite -cvs co org.glite.lb - -cd org.glite.lb/project -ant -f glite.lb.csf.xml - diff --git a/org.glite.lb/project/status.T b/org.glite.lb/project/status.T deleted file mode 100644 index 10071ac..0000000 --- a/org.glite.lb/project/status.T +++ /dev/null @@ -1,77 +0,0 @@ -@type _common_ -jobid jobId Id of the job -string owner Job owner -_index_ - -int jobtype Type of job - _null_ -1 - _code_ SIMPLE simple job - _code_ DAG composite job -jobid parent_job parent job of subjob - -string seed string used for generation of subjob IDs -int children_num number of subjobs -strlist children list of subjob IDs - _special_ XMLstructured -intlist children_hist summary (histogram) of children job states - _special_ XMLstructured -stslist children_states full status information of the children - _special_ XMLstructured - -string condorId Id within Condor-G -string globusId Globus allocated Id -string localId Id within LRMS - -string jdl User submitted job description -string matched_jdl Full job description after matchmaking -string destination ID of CE where the job is being sent -_index_ -string condor_jdl ClassAd passed to Condor-G for last job execution -string rsl Job RSL sent to Globus - -string reason Reason of being in this status, if any - -string location Where the job is being processed -_index_ -string ce_node Worker node where the job is executed -string network_server Network server handling the job - -bool subjob_failed Subjob failed (the parent job will fail too) -int done_code Return code - _null_ -1 - _code_ OK Finished correctly - _code_ FAILED Execution failed - _code_ CANCELLED Cancelled by user -int exit_code Unix exit code -bool resubmitted The job was resubmitted - -bool cancelling Cancellation request in progress -string cancelReason Reason of cancel - -int cpuTime Consumed CPU time - _null_ -1 - -taglist user_tags List of pairs (user_tag, user_value) - _special_ XMLstructured - -timeval stateEnterTime When entered this status -timeval lastUpdateTime Last known event of the job - -intlist stateEnterTimes When all previous states were entered - _special_ XMLstructured - -bool expectUpdate Some logged information has not arrived yet -string expectFrom Sources of the missing information -string acl ACL of the job - -@type Submitted entered by the user to the User Interface or registered by Job Partitioner -@type Waiting Accepted by WMS, waiting for resource allocation -@type Ready Matching resources found -@type Scheduled Accepted by LRMS queue -@type Running Executable is running -@type Done Execution finished, output is available -@type Cleared Output transfered back to user and freed -@type Aborted Aborted by system (at any stage) -@type Cancelled Cancelled by user -@type Unknown Status cannot be determined -@type Purged Job has been purged from bookkeeping server (for LB->RGMA interface) diff --git a/org.glite.lb/project/taskdefs.xml b/org.glite.lb/project/taskdefs.xml deleted file mode 100755 index 251f790..0000000 --- a/org.glite.lb/project/taskdefs.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/org.glite.lb/project/types.T b/org.glite.lb/project/types.T deleted file mode 100644 index ccabc74..0000000 --- a/org.glite.lb/project/types.T +++ /dev/null @@ -1,108 +0,0 @@ -%types = ( - C=>{ - bool=>'"int"', - string=>'"char *"', - strlist=>'"char **"', - intlist=>'"int *"', - taglist=>'"edg_wll_TagValue *"', - stslist=>'"struct _edg_wll_JobStat *"', - timeval=>'"struct timeval"', - jobid=>'"edg_wlc_JobId"', - notifid=>'"edg_wll_NotifId"', - logsrc=>'"edg_wll_Source"', - port=>'"uint16_t"', -# level=>'"enum edg_wll_Level"', - int=>'"int"' - }, - 'C++'=>{ - string=>'"std::string"', - timeval=>'"struct timeval"', - jobid=>'"edg::workload::common::jobid::JobId"', - bool=>'"int"', - intlist=>'"std::vector"', - strlist=>'"std::vector"', - taglist=>'"std::vector>"', - stslist=>'"std::vector"', - logsrc=>'"int"', - port=>'"int"', - int=>'"int"' - } -); - -%toString = ( - C=>{ - int=>'qq{asprintf(&$dst,"%d",$src);}', - port=>'qq{asprintf(&$dst,"%d",(int) $src);}', - bool=>'qq{asprintf(&$dst,"%d",$src);}', - string=>'qq{$dst = $src?strdup($src):NULL;}', - timeval=>'qq{edg_wll_ULMTimevalToDate(($src).tv_sec,($src).tv_usec,$dst);}', - jobid=>'qq{$dst = edg_wlc_JobIdUnparse($src);}', - notifid=>'qq{$dst = edg_wll_NotifIdUnparse($src);}', -# level=>'qq{$dst = edg_wll_LevelToString($src);}', - logsrc=>'qq{$dst = edg_wll_SourceToString($src);}', -# strlist, intlist, stslist are used only in consumer API, they don't need toString method - } -); - -%ULMasString = ( - logsrc=>1 -); - -%fromString = ( - C=>{ - int=>'qq{$dst = atoi($src);}', - port=>'qq{$dst = (uint16_t) atoi($src);}', - bool=>'qq{$dst = atoi($src);}', - string=>'qq{$dst = strdup($src);}', - timeval=>'qq{edg_wll_ULMDateToTimeval($src,&$dst);}', - jobid=>'qq{edg_wlc_JobIdParse($src,&$dst);}', - notifid=>'qq{edg_wll_NotifIdParse($src,&$dst);}', -# level=>'qq{$dst = edg_wll_StringToLevel($src);}', - logsrc=>'qq{$dst = edg_wll_StringToSource($src);}', -# strlist, intlist, stslist are used only in consumer API, they don't need fromString method - } -); - -%DefaultNullValue = ( - int=>0, - port=>0, -# level=>'EDG_WLL_LEVEL_UNDEFINED', - bool=>0, - string=>'NULL', - jobid=>'NULL', - notifid=>'NULL', - logsrc=>'EDG_WLL_SOURCE_NONE', - timeval=>'null_timeval', - strlist=>'NULL', - intlist=>'NULL', - taglist=>'NULL', - stslist=>'NULL', -); - -%compare = ( - C=>{ - int=>'"($a == $b)"', - port=>'"($a == $b)"', -# level=>'"($a == $b)"', - bool=>'"(($a || !$b) && ($b || !$a))"', - string=>'"(($a) == NULL && ($b) == NULL) || (($a)&&($b)&& !strcmp($a,$b))"', - jobid=>'"(($a) == NULL && ($b) == NULL) || (($a)&&($b)&& !strcmp(edg_wlc_JobIdUnparse($a),edg_wlc_JobIdUnparse($b)))"', - notifid=>'"($a) == ($b)"', - logsrc=>'"($a) == ($b)"', - timeval=>'"($a).tv_sec == ($b).tv_sec && ($a).tv_usec == ($b).tv_usec"', - } -); - -%toFormatString = ( - C=>{ - int=>'"%d"', - port=>'"%d"', - bool=>'"%d"', -# level=>'"%s"', - string=>'"%|Us"', - jobid=>'"%s"', - notifid=>'"%s"', - logsrc=>'"%s"', - timeval=>'"%s"', - } -); diff --git a/org.glite.lb/project/version.properties b/org.glite.lb/project/version.properties deleted file mode 100644 index 7ebba2f..0000000 --- a/org.glite.lb/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Dec 09 05:07:12 CET 2004 -module.version=0.3.0 -module.build=112 -module.age=2 diff --git a/org.glite.security.proxyrenewal/.cvsignore b/org.glite.security.proxyrenewal/.cvsignore deleted file mode 100644 index 3a4edf6..0000000 --- a/org.glite.security.proxyrenewal/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -.project diff --git a/org.glite.security.proxyrenewal/LICENSE b/org.glite.security.proxyrenewal/LICENSE deleted file mode 100644 index 01b973b..0000000 --- a/org.glite.security.proxyrenewal/LICENSE +++ /dev/null @@ -1,69 +0,0 @@ -LICENSE file for EGEE Middleware -================================ - -Copyright (c) 2004 on behalf of the EU EGEE Project: -The European Organization for Nuclear Research (CERN), -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Datamat Spa, Italy -Centre National de la Recherche Scientifique (CNRS), France -CS Systeme d'Information (CSSI), France -Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden -Universiteit van Amsterdam (UvA), Netherlands -University of Helsinki (UH.HIP), Finlan -University of Bergen (UiB), Norway -Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. The end-user documentation included with the redistribution, if -any, must include the following acknowledgment: "This product includes -software developed by The EU EGEE Project (http://cern.ch/eu-egee/)." -Alternatively, this acknowledgment may appear in the software itself, if -and wherever such third-party acknowledgments normally appear. - -4. The names EGEE and the EU EGEE Project must not be -used to endorse or promote products derived from this software without -prior written permission. For written permission, please contact -. - -5. You are under no obligation whatsoever to provide anyone with any -bug fixes, patches, or upgrades to the features, functionality or -performance of the Software ("Enhancements") that you may develop over -time; however, if you choose to provide your Enhancements to The EU -EGEE Project, or if you choose to otherwise publish or distribute your -Enhancements, in source code form without contemporaneously requiring -end users of The EU EGEE Proejct to enter into a separate written license -agreement for such Enhancements, then you hereby grant The EU EGEE Project -a non-exclusive, royalty-free perpetual license to install, use, copy, -modify, prepare derivative works, incorporate into the EGEE Middleware -or any other computer software, distribute, and sublicense your -Enhancements or derivative works thereof, in binary and source code -form (if any), whether developed by The EU EGEE Project or third parties. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL PROJECT OR ITS CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This software consists of voluntary contributions made by many -individuals on behalf of the EU EGEE Prject. For more information on The -EU EGEE Project, please see http://cern.ch/eu-egee/. For more information on -EGEE Middleware, please see http://egee-jra1.web.cern.ch/egee-jra1/ - - diff --git a/org.glite.security.proxyrenewal/Makefile b/org.glite.security.proxyrenewal/Makefile deleted file mode 100644 index f567f8a..0000000 --- a/org.glite.security.proxyrenewal/Makefile +++ /dev/null @@ -1,145 +0,0 @@ -# -# Copyright (c) 2004 on behalf of the EU EGEE Project: -# The European Organization for Nuclear Research (CERN), -# Istituto Nazionale di Fisica Nucleare (INFN), Italy -# Datamat Spa, Italy -# Centre National de la Recherche Scientifique (CNRS), France -# CS Systeme d'Information (CSSI), France -# Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden -# Universiteit van Amsterdam (UvA), Netherlands -# University of Helsinki (UH.HIP), Finland -# University of Bergen (UiB), Norway -# Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom -# -# Top Makefile file for the GLite Security Proxyrenewal module -# -# Authors: Ales Krenek -# Version info: $Id$ -# Release: $Name$ -# -# Revision history: -# $Log -# - -# defaults -top_srcdir=. -builddir=build -top_builddir=${top_srcdir}/${builddir} -stagedir=. -distdir=. -globalprefix=glite -lbprefix=lb -package=glite-security-proxyrenewal -version=0.0.0 -PREFIX=/opt/glite - -glite_location=$PREFIX -globus_prefix=/opt/globus -voms_prefix=/opt/glite -nothrflavour=gcc32 -thrflavour=gcc32pthr -myproxy_prefix=$globus_prefix - --include Makefile.inc - -VPATH:=${top_srcdir}/src - -GLOBUSINC:= -I${globus_prefix}/include/${nothrflavour} \ - -I${globus_prefix}/include/${nothrflavour}/openssl - -GLOBUSTHRINC:= -I${globus_prefix}/include/${thrflavour} \ - -I${globus_prefix}/include/${thrflavour}/openssl - -MYPROXYINC:= -I${myproxy_prefix}/include/${nothrflavour} -MYPROXYTHRINC:= -I${myproxy_prefix}/include/${thrflavour} - -DEBUG:=-g -O0 - -# XXX: until VOMS is ready in SCM -CFLAGS:= -DNOVOMS \ - ${DEBUG} \ - -DVOMS_INSTALL_PATH=\"${voms_prefix}\"\ - ${MYPROXYINC} \ - -I${top_srcdir}/src -I${top_srcdir}/interface \ - -I${glite_location}/include - -GLOBUS_LIBS:=-L${globus_prefix}/lib \ - -lglobus_common_${nothrflavour} \ - -lssl_${nothrflavour} - -MYPROXY_LIB:=-L${myproxy_prefix}/lib -lmyproxy_${nothrflavour} - -JOBIDLIB:=-L${glite_location}/lib -lglite_wmsutils_cjobid - -COMPILE:=libtool --mode=compile ${CC} ${CFLAGS} -LINK:=libtool --mode=link ${CC} ${LDFLAGS} -INSTALL:=libtool --mode=install install - -DAEMONOBJ:=renewd.o renew.o common.o commands.o api.o -LIBOBJ:=api.o common.o -CLIENTOBJ:=client.o - -THRLIBOBJ:=${LIBOBJ:.o=.thr.o} -LIBLOBJ:=${LIBOBJ:.o=.lo} -THRLIBLOBJ:=${LIBOBJ:.o=.thr.lo} - -LIB:=libglite_security_proxyrenewal_${nothrflavour}.la -THRLIB:=libglite_security_proxyrenewal_${thrflavour}.la - -DAEMON:=glite-proxy-renewd -CLIENT:=glite-proxy-renew - -default: all -compile all: ${LIB} ${THRLIB} ${DAEMON} ${CLIENT} - -${LIB}: ${LIBOBJ} - ${LINK} -o $@ ${LIBLOBJ} -rpath ${glite_location}/lib ${JOBIDLIB} - - -${THRLIB}: ${THRLIBOBJ} - ${LINK} -o $@ ${THRLIBLOBJ} -rpath ${glite_location}/lib - -${DAEMON}: ${DAEMONOBJ} - ${LINK} -o $@ ${DAEMONOBJ} ${JOBIDLIB} ${MYPROXY_LIB} -lglobus_gss_assist_${nothrflavour} ${GLOBUS_LIBS} - -${CLIENT}: ${CLIENTOBJ} ${LIB} - ${LINK} -o $@ ${CLIENTOBJ} ${LIB} ${GLOBUS_LIBS} - -${THRLIBOBJ}: %.thr.o: %.c - ${COMPILE} ${GLOBUSTHRINC} -o $@ -c $< - -%.o: %.c - ${COMPILE} ${GLOBUSINC} -c $< - -stage: compile - $(MAKE) install PREFIX=${stagedir} - - -check: - echo No unit tests - -dist: distsrc distbin - -distsrc: - mkdir -p ${top_srcdir}/${package}-${version} - cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version} - cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version} - rm -rf ${top_srcdir}/${package}-${version} - -distbin: - $(MAKE) install PREFIX=`pwd`/tmpbuilddir - cd tmpbuilddir && tar -czf ../${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz * - rm -rf tmpbuilddir - -install: - -mkdir -p ${PREFIX}/bin ${PREFIX}/lib ${PREFIX}/include/glite/security/proxyrenewal ${PREFIX}/share/doc/${package}-${version} ${PREFIX}/etc/init.d - ${INSTALL} -m 644 ${LIB} ${THRLIB} ${PREFIX}/lib - ${INSTALL} -m 755 ${DAEMON} ${CLIENT} ${PREFIX}/bin - ${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} - cd ${top_srcdir}/interface && ${INSTALL} -m 644 renewal.h ${PREFIX}/include/glite/security/proxyrenewal - - ${INSTALL} -m 755 ${top_srcdir}/config/startup ${PREFIX}/etc/init.d/${DAEMON} - - -clean: - $(RM) $(LIB) $(DAEMON) $(CLIENT) *.o core diff --git a/org.glite.security.proxyrenewal/build.xml b/org.glite.security.proxyrenewal/build.xml deleted file mode 100755 index fcced8d..0000000 --- a/org.glite.security.proxyrenewal/build.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.security.proxyrenewal/config/startup b/org.glite.security.proxyrenewal/config/startup deleted file mode 100755 index efbc8d5..0000000 --- a/org.glite.security.proxyrenewal/config/startup +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -GLITE_LOCATION=${GLITE_LOCATION:-/opt/glite} -GLITE_USER=${GLITE_USER:-glite} -GLITE_LOCATION_VAR=${GLITE_LOCATION_VAR:-/opt/glite/var} - -[ -f /etc/glite.conf ] && . /etc/glite.conf -[ -f $GLITE_LOCATION/etc/glite-wms.conf ] && . $GLITE_LOCATION/etc/glite-wms.conf -[ -f $HOME/.glite.conf ] && . $HOME/.glite.conf - -PROXY_REPOSITORY="$GLITE_LOCATION_VAR/spool/glite-renewd" - -start() -{ - [ -n "$GLITE_HOST_CERT" ] && X509_USER_CERT="$GLITE_HOST_CERT" - [ -n "$GLITE_HOST_KEY" ] && X509_USER_KEY="$GLITE_HOST_KEY" - export X509_USER_CERT X509_USER_KEY - - echo -n Starting ProxyRenewal Daemon: glite-proxy-renewd ... - - if [ ! -d "$PROXY_REPOSITORY" ]; then - mkdir -p $PROXY_REPOSITORY || exit 1 - chown $GLITE_USER $PROXY_REPOSITORY - chmod 0700 $PROXY_REPOSITORY - fi - - su $GLITE_USER -c "$GLITE_LOCATION/bin/glite-proxy-renewd \ - -r $PROXY_REPOSITORY" && echo " done" -} - -stop() -{ - echo -n "Stopping ProxyRenewal Daemon: glite-proxy-renewd ..." - PIDS=`ps -C glite-proxy-renewd -o pid --no-heading` - if [ -z "$PIDS" ]; then - echo " no process glite-proxy-renewd running" - exit 1 - else - kill $PIDS && echo " done" - fi -} - -status() -{ - PIDS=`ps -C glite-proxy-renewd -o pid --no-heading` - if ps p $PIDS >/dev/null 2>&1; then - echo glite-proxy-renewd running \($PIDS\) - return 0 - fi - - echo glite-proxy-renewd not running - return 1 -} - -case x$1 in - xstart) start;; - xstop) stop;; - xrestart) stop; start;; - xstatus) status;; - x*) echo usage: $0 start,stop,restart,status >&2 - exit 1;; -esac diff --git a/org.glite.security.proxyrenewal/interface/renewal.h b/org.glite.security.proxyrenewal/interface/renewal.h deleted file mode 100644 index 167b27d..0000000 --- a/org.glite.security.proxyrenewal/interface/renewal.h +++ /dev/null @@ -1,144 +0,0 @@ -/** - * \file proxyrenewal/renewal.h - * \author Daniel Kouril - * \author Miroslav Ruda - * \brief API for proxy renewal. - * \version 2.0 - * - * General rules: - * - functions return 0 on success, nonzero on error, errror details can - * be found via edg_wlpr_GetErrorText() - */ - -#ifndef RENEWAL_H -#define RENEWAL_H - -#ident "$Header$" - -#include "glite/wmsutils/jobid/cjobid.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define EDG_WLPR_FLAG_UNIQUE 1 -#define EDG_WLPR_FLAG_UPDATE 2 - -typedef enum _edg_wlpr_ErrorCode { -/** - * Base for proxy renewal specific code. - * Start sufficently high not to collide with standard errno. */ - /* XXX see common/exception_codes.h */ - EDG_WLPR_ERROR_BASE = 1900, - EDG_WLPR_ERROR_UNEXPECTED_EOF, - EDG_WLPR_ERROR_GENERIC, - EDG_WLPR_ERROR_PROTO_PARSE_ERROR, - EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND, - EDG_WLPR_ERROR_UNKNOWN_COMMAND, - EDG_WLPR_ERROR_SSL, - EDG_WLPR_ERROR_MYPROXY, - EDG_WLPR_PROXY_NOT_REGISTERED, - EDG_WLPR_PROXY_EXPIRED, - EDG_WLPR_ERROR_VOMS, -} edg_wlpr_ErrorCode; - -/** - * Return a human readable string containg description of the errorcode - * \retval char* pointer to a error description - */ -const char * -edg_wlpr_GetErrorText(int err_code); - -/** - * This function contacts the renewal daemon and registers the specified proxy - * for periodic renewal. - * \param filename IN: specification of the proxy to register. - * \param jdl IN: JDL of the job owing the proxy. The JDL is looked for a - * myproxy server contact. - * \param flags IN: one of EDG_WLPR_FLAG_UNIQUE or EDG_WLPR_FLAG_UPDATE, or - * their bitwise OR. - * \param repository_filename OUT: filename of registered proxy in repository. - * \retval 0 success - * \retval nonzero on error. Human readable form of the error can be get via - * edg_wlpr_GetErrorText(). - */ -int -edg_wlpr_RegisterProxy( - const char * filename, - const char *jdl, - int flags, - char ** repository_filename -); - -/** - * The same function as edg_wlpr_RegisterProxy() but information about the - * myproxy server and jobid are passed as parameters instead of in JDL. - */ -int -edg_wlpr_RegisterProxyExt( - const char * filename, - const char * server, - unsigned int port, - edg_wlc_JobId jobid, - int flags, - char ** repository_filename -); - -/** - * Unregister proxy from the renewal daemon. - * \param jobid IN: specification of job whose proxy shall be unregistered - * \param filename IN: (optional) specification of the proxy to unregister. - * \retval 0 success - * \retval nonzero on error. Human readable form of the error can be get via - * edg_wlpr_GetErrorText(). - */ -int -edg_wlpr_UnregisterProxy( - edg_wlc_JobId jobid, - const char * repository_filename -); - -/** - * Get a list of registered proxies maintained by the renewal daemon. - * \param count OUT: number of proxies - * \param list OUT: a list of filenames separated by '\n' - * specifying the registered proxies. - * \warning The caller is responsible for freeing the data. - * \retval 0 success - * \retval nonzero on error. Human readable form of the error can be get via - * edg_wlpr_GetErrorText(). - */ -int -edg_wlpr_GetList(int *count, char **list); - -/** - * Get a status message about a proxy. - * The function contacts the renewal daemon and retrieve information it - * maintains about the proxy. - * \param filename IN: specification of the proxy to query - * \param info OUT: status message. - * \warning The caller is responsible for freeing the data. - * \retval 0 success - * \retval nonzero on error. Human readable form of the error can be get via - * edg_wlpr_GetErrorText(). - */ -int -edg_wlpr_GetStatus(const char *repository_filename, char **info); - -/** - * For given jobid return registered proxy filename from repository - * \param jobid IN: specification of jobid - * \param repository_filename OUT: proxy regitered for given jobid - * \warning The caller is responsible for freeing the data. - * \retval 0 success - * \retval nonzero on error. Human readable form of the error can be get via - * edg_wlpr_GetErrorText(). - */ -int -edg_wlpr_GetProxy(edg_wlc_JobId jobid, char **repository_filename); - -#ifdef __cplusplus -} -#endif - -#endif /* RENEWAL_H */ diff --git a/org.glite.security.proxyrenewal/project/build.properties b/org.glite.security.proxyrenewal/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.glite.security.proxyrenewal/project/configure.properties.xml b/org.glite.security.proxyrenewal/project/configure.properties.xml deleted file mode 100644 index 4122b9d..0000000 --- a/org.glite.security.proxyrenewal/project/configure.properties.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - -top_srcdir=.. -builddir=build -stagedir=${stage.abs.dir} -distdir=${dist.dir} -globalprefix=${global.prefix} -package=${module.package.name} -PREFIX=${install.dir} -version=${module.version} -glite_location=${with.glite.location} -globus_prefix=${with.globus.prefix} -thrflavour=${with.globus.thr.flavor} -nothrflavour=${with.globus.nothr.flavor} -myproxy_prefix=${with.myproxy.prefix} -voms_prefix=${with.glite.location} - - - diff --git a/org.glite.security.proxyrenewal/project/properties.xml b/org.glite.security.proxyrenewal/project/properties.xml deleted file mode 100755 index f1e51dd..0000000 --- a/org.glite.security.proxyrenewal/project/properties.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.security.proxyrenewal/project/tar_exclude b/org.glite.security.proxyrenewal/project/tar_exclude deleted file mode 100644 index e1fcd1a..0000000 --- a/org.glite.security.proxyrenewal/project/tar_exclude +++ /dev/null @@ -1,10 +0,0 @@ -tar_exclude -CVS -build.xml -build -build.properties -properties.xml -configure.properties.xml -.cvsignore -.project -.cdtproject diff --git a/org.glite.security.proxyrenewal/project/taskdefs.xml b/org.glite.security.proxyrenewal/project/taskdefs.xml deleted file mode 100755 index 13e894e..0000000 --- a/org.glite.security.proxyrenewal/project/taskdefs.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/org.glite.security.proxyrenewal/project/version.properties b/org.glite.security.proxyrenewal/project/version.properties deleted file mode 100644 index 8493a93..0000000 --- a/org.glite.security.proxyrenewal/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Dec 09 04:11:20 CET 2004 -module.version=0.1.1 -module.build=103 -module.age=1 diff --git a/org.glite.security.proxyrenewal/src/api.c b/org.glite.security.proxyrenewal/src/api.c deleted file mode 100644 index e241f20..0000000 --- a/org.glite.security.proxyrenewal/src/api.c +++ /dev/null @@ -1,436 +0,0 @@ -#include "renewal.h" -#include "renewal_locl.h" - -#ident "$Header$" - -#define SEPARATORS "\n" - -/* prototypes of static routines */ -static int -encode_request(edg_wlpr_Request *request, char **msg); - -static int -decode_response(const char *msg, const size_t msg_len, edg_wlpr_Response *response); - -static int -do_connect(char *socket_name, int *sock); - -static int -send_request(int sock, edg_wlpr_Request *request, edg_wlpr_Response *response); - - -static int -encode_request(edg_wlpr_Request *request, char **msg) -{ - char *buf; - size_t buf_len; - int ret; - - buf_len = EDG_WLPR_BUF_SIZE; - buf = malloc(buf_len); - if (buf == NULL) - return ENOMEM; - buf[0] = '\0'; - - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_VERSION, - EDG_WLPR_VERSION, SEPARATORS); - if (ret) - goto err; - - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_COMMAND, - edg_wlpr_EncodeInt(request->command), - SEPARATORS); - if (ret) - goto err; - - if (request->myproxy_server) { - char host[1024]; - -#if 0 - snprintf(host, sizeof(host), "%s:%d", request->myproxy_server, - (request->myproxy_port) ? request->myproxy_port : EDG_WLPR_MYPROXY_PORT); /* XXX let server decide ? */ -#else - snprintf(host, sizeof(host), "%s", request->myproxy_server); -#endif - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_MYPROXY_SERVER, - host, SEPARATORS); - if (ret) - goto err; - } - - if (request->proxy_filename) { - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_PROXY, - request->proxy_filename, SEPARATORS); - if (ret) - goto err; - } - - if (request->jobid) { - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_JOBID, - request->jobid, SEPARATORS); - if (ret) - goto err; - } - - if (request->entries) { - char **p = request->entries; - while (*p) { - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_ENTRY, - *p, SEPARATORS); - if (ret) - goto err; - p++; - } - } - - buf[strlen(buf)] = '\0'; - *msg = buf; - return 0; - -err: - free(buf); - *msg = NULL; - return ret; -} - -static int -decode_response(const char *msg, const size_t msg_len, edg_wlpr_Response *response) -{ - int ret; - char *value = NULL; - /* char *p; */ - int i; - int current_size = 0; - - /* XXX add an ending zero '\0' */ - - assert(msg != NULL); - assert(response != NULL); - - memset(response, 0, sizeof(*response)); - - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_VERSION, SEPARATORS, - 0, &response->version); - if (ret) - goto err; - - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_RESPONSE, SEPARATORS, - 0, &value); - if (ret) - goto err; - - ret = edg_wlpr_DecodeInt(value, (int *)(&response->response_code)); - free(value); - if (ret) - goto err; - - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_MYPROXY_SERVER, - SEPARATORS, 0, &response->myproxy_server); - if (ret && ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) - goto err; - -#if 0 - response->myproxy_port = EDG_WLPR_MYPROXY_PORT; /* ??? */ - if (response->myproxy_server && (p = strchr(response->myproxy_server, ':'))) { - int port; - *p = '\0'; - port = atol(p+1); /* XXX */ - response->myproxy_port = port; - } -#endif - - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_START_TIME, SEPARATORS, - 0, &value); - if (ret && ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) - goto err; - if (ret == 0) { - ret = edg_wlpr_DecodeInt(value, (int *)(&response->start_time)); - free(value); - if (ret) - goto err; - } - - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_END_TIME, SEPARATORS, - 0, &value); - if (ret && ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) - goto err; - if (ret == 0) { - ret = edg_wlpr_DecodeInt(value, (int *)(&response->end_time)); - free(value); - if (ret) - goto err; - } - - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_RENEWAL_TIME, - SEPARATORS, 0, &value); - if (ret && ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) - goto err; - if (ret == 0) { - ret = edg_wlpr_DecodeInt(value, (int *)(&response->next_renewal_time)); - free(value); - if (ret) - goto err; - } - - /* XXX Counter */ - - i = 0; - while ((ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_PROXY, - SEPARATORS, i, &value)) == 0) { - if (i >= current_size) { - char **tmp; - - tmp = realloc(response->filenames, - (current_size + 16 + 1) * sizeof(*tmp)); - if (tmp == NULL) { - ret = ENOMEM; - goto err; - } - response->filenames = tmp; - current_size += 16; - } - response->filenames[i] = value; - i++; - } - if (ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) - goto err; - if (response->filenames) - response->filenames[i] = NULL; - - return 0; - -err: - edg_wlpr_CleanResponse(response); - - return ret; -} - -static int -do_connect(char *socket_name, int *sock) -{ - struct sockaddr_un my_addr; - int s; - int ret; - - assert(sock != NULL); - memset(&my_addr, 0, sizeof(my_addr)); - - s = socket(AF_UNIX, SOCK_STREAM, 0); - if (s == -1) { - return errno; - } - - my_addr.sun_family = AF_UNIX; - strncpy(my_addr.sun_path, socket_name, sizeof(my_addr.sun_path)); - - ret = connect(s, (struct sockaddr *) &my_addr, sizeof(my_addr)); - if (ret == -1) { - close(s); - return errno; - } - - *sock = s; - return 0; -} - -static int -send_request(int sock, edg_wlpr_Request *request, edg_wlpr_Response *response) -{ - int ret; - char *buf = NULL; - size_t buf_len; - - /* timeouts ?? */ - - ret = encode_request(request, &buf); - if (ret) - return ret; - - ret = edg_wlpr_Write(sock, buf, strlen(buf) + 1); - free(buf); - if (ret) - return ret; - - ret = edg_wlpr_Read(sock, &buf, &buf_len); - if (ret) - return ret; - - ret = decode_response(buf, buf_len, response); - free(buf); - if (ret) - return ret; - - return 0; -} - -int -edg_wlpr_RequestSend(edg_wlpr_Request *request, edg_wlpr_Response *response) -{ - char sockname[1024]; - int ret; - int sock; - - snprintf(sockname, sizeof(sockname), "%s%d", - DGPR_REG_SOCKET_NAME_ROOT, getuid()); - ret = do_connect(sockname, &sock); - if (ret) - return ret; - - ret = send_request(sock, request, response); - - close(sock); - return ret; -} - -int -edg_wlpr_RegisterProxyExt(const char *filename, const char * server, - unsigned int port, - edg_wlc_JobId jobid, int flags, - char **repository_filename) -{ - edg_wlpr_Request request; - edg_wlpr_Response response; - int ret; - - memset(&request, 0, sizeof(request)); - memset(&response, 0, sizeof(response)); - - request.command = EDG_WLPR_COMMAND_REG; - request.myproxy_server = server; - request.proxy_filename = filename; - request.jobid = edg_wlc_JobIdUnparse(jobid); - if (request.jobid == NULL) - return EINVAL; /* XXX */ - - ret = edg_wlpr_RequestSend(&request, &response); - free(request.jobid); - if (ret == 0 && response.response_code == 0 && repository_filename && - response.filenames && response.filenames[0] ) - *repository_filename = strdup(response.filenames[0]); - - if (ret == 0) - ret = response.response_code; - - edg_wlpr_CleanResponse(&response); - - return ret; -} - -int -edg_wlpr_RegisterProxy(const char *filename, const char *jdl, - int flags, char **repository_filename) -{ - char server[1024]; - size_t server_len; - unsigned int port = 0; - char *p, *q; - - memset(server, 0, sizeof(server)); - - /* parse JDL and find information about myproxy server */ - p = strstr(jdl, JDL_MYPROXY); - if (p == NULL) - return 0; /* XXX */ - q = strchr(p, '\n'); /* XXX */ - if (q) - server_len = q - p; - else - server_len = jdl + strlen(jdl) - p; - if (server_len >= sizeof(server)) - return EINVAL; /* XXX */ - strncmp(server, p, sizeof(server)); - - return (edg_wlpr_RegisterProxyExt(filename, server, port, NULL, flags, - repository_filename)); -} - -int -edg_wlpr_UnregisterProxy(edg_wlc_JobId jobid, const char *repository_filename) -{ - edg_wlpr_Request request; - edg_wlpr_Response response; - int ret; - - memset(&request, 0, sizeof(request)); - memset(&response, 0, sizeof(response)); - - request.command = EDG_WLPR_COMMAND_UNREG; - request.proxy_filename = repository_filename; - request.jobid = edg_wlc_JobIdUnparse(jobid); - if (request.jobid == NULL) - return EINVAL; - - ret = edg_wlpr_RequestSend(&request, &response); - free(request.jobid); - - if (ret == 0) - ret = response.response_code; - edg_wlpr_CleanResponse(&response); - - return ret; -} - -int -edg_wlpr_GetList(int *count, char **list) -{ - return ENOSYS; /* XXX */ -} - -int -edg_wlpr_GetStatus(const char *filename, char **info) -{ - return ENOSYS; /* XXX */ -} - -static const char* const errTexts[] = { - "Unexpected EOF from peer", - "Generic error", - "Protocol parse error", - "Compulsory element not found in message", - "Unknown protocol command", - "SSL error", - "Error from Myproxy server", - "Proxy not registered", - "Proxy expired", - "VOMS error", -}; - -const char * -edg_wlpr_GetErrorText(int code) -{ - return code ? - (code <= EDG_WLPR_ERROR_BASE ? - strerror(code) : - errTexts[code - EDG_WLPR_ERROR_BASE - 1] - ) : - NULL; -} - -int -edg_wlpr_GetProxy(edg_wlc_JobId jobid, char **repository_filename) -{ - edg_wlpr_Request request; - edg_wlpr_Response response; - int ret; - - memset(&request, 0, sizeof(request)); - memset(&response, 0, sizeof(response)); - - request.command = EDG_WLPR_COMMAND_GET; - request.jobid = edg_wlc_JobIdUnparse(jobid); - if (request.jobid == NULL) - return EINVAL; - - ret = edg_wlpr_RequestSend(&request, &response); - free(request.jobid); - - if (ret == 0 && response.response_code == 0 && repository_filename && - response.filenames && response.filenames[0] ) - *repository_filename = strdup(response.filenames[0]); - - if (ret == 0) - ret = response.response_code; - edg_wlpr_CleanResponse(&response); - - return ret; -} diff --git a/org.glite.security.proxyrenewal/src/client.c b/org.glite.security.proxyrenewal/src/client.c deleted file mode 100644 index eb2d36b..0000000 --- a/org.glite.security.proxyrenewal/src/client.c +++ /dev/null @@ -1,117 +0,0 @@ -#include -#include -#include -#include -#include "renewal.h" - -static const char rcsid[] = "$Header$"; - -static struct option const long_options[] = { - { "help", no_argument, 0, 'h' }, - { "version", no_argument, 0, 'v' }, - { "server", required_argument, 0, 's' }, - { "port", required_argument, 0, 'p' }, - { "file", required_argument, 0, 'f' }, - { "jobid", required_argument, 0, 'j' }, - { NULL, 0, NULL, 0} -}; - -static char short_options[] = "hvs:p:f:j:"; - -static void -usage(exit_code) -{ - fprintf(stdout, "Usage: edg-wl-renew [option] operation\n" - "\t-s myproxy_server [-p port] -f filename -j jobid start |\n" - "\t-j jobid [-f filename] stop |\n" - "\t-j jobid get\n" - "-h, --help display this help and exit\n" - "-v, --version output version information and exit\n" - "-s, --server address of myproxy server\n" - "-p, --port port of myproxy server\n" - "-f, --file filename with proxy\n" - "-j, --jobid datagrid jobid\n"); - exit(exit_code); -} - -int -main(int argc, char *argv[]) -{ - char *server = NULL; - int port = 0; - char *proxyfile = NULL; - char *jobid_str = NULL; - edg_wlc_JobId jobid = NULL; - char *repository_filename = NULL; - int ret; - int arg; - extern int optind; - - while ((arg = getopt_long(argc, argv, - short_options, long_options, (int *) 0)) != EOF) - switch(arg) { - case 'h': - usage(0); break; - case 'v': - fprintf(stdout, "%s:\t%s\n", argv[0], rcsid); exit(0); - case 's': - server = strdup(optarg); break; - case 'p': - port = atoi(optarg); break; - case 'f': - proxyfile = strdup(optarg); break; - case 'j': - jobid_str = strdup(optarg); break; - default: - usage(1); break; - } - - if (optind >= argc) - usage(1); - - if (jobid_str && edg_wlc_JobIdParse(jobid_str, &jobid)) { - fprintf(stderr, "Cannot parse jobid\n"); - exit(1); - } - - if (strcmp(argv[optind], "start") == 0) { - if (proxyfile == NULL || server == NULL || jobid == NULL) - usage(1); - ret = edg_wlpr_RegisterProxyExt(proxyfile, server, port, jobid, 0, - &repository_filename); - if (ret) { - fprintf(stderr, "Registering proxy failed: %s\n", - edg_wlpr_GetErrorText(ret)); - exit(1); - } - printf("%s\n", repository_filename); - free(repository_filename); - exit(0); - } - else if (strcmp(argv[optind], "stop") == 0) { - if (jobid == NULL) - usage(1); - ret = edg_wlpr_UnregisterProxy(jobid, proxyfile); - if (ret) { - fprintf(stderr, "Unregistering proxy failed: %s\n", - edg_wlpr_GetErrorText(ret)); - exit(1); - } - } - else if (strcmp(argv[optind], "get") == 0) { - if (jobid == NULL) - usage(1); - ret = edg_wlpr_GetProxy(jobid, &proxyfile); - if (ret) { - fprintf(stderr, "GET request failed: %s\n", - edg_wlpr_GetErrorText(ret)); - exit(1); - } - printf("%s\n", proxyfile); - free(proxyfile); - } - else - usage(1); - - return 0; -} diff --git a/org.glite.security.proxyrenewal/src/commands.c b/org.glite.security.proxyrenewal/src/commands.c deleted file mode 100644 index fc6235e..0000000 --- a/org.glite.security.proxyrenewal/src/commands.c +++ /dev/null @@ -1,1233 +0,0 @@ -#include "renewal_locl.h" -#include "renewd_locl.h" - -#ifndef NOVOMS -#include -#endif - -#ident "$Header$" - -#define SEPARATORS ",\n" -#define RENEWAL_START_FRACTION 0.75 /* XXX */ -#define RENEWAL_CLOCK_SKEW (5 * 60) -#define RENEWAL_MIN_LIFETIME (15 * 60) - -extern char *repository; -extern time_t condor_limit; -extern char *cadir; -extern char *vomsdir; -extern int voms_enabled; - -static char * -strmd5(const char *s, unsigned char *digest); - -static int -get_record_ext(FILE *fd, proxy_record *record, int *last_used_suffix); - -static int -get_record(FILE *fd, proxy_record *record); - -static int -store_record(char *basename, proxy_record *record); - -static int -copy_file_content(FILE *in, FILE *out); - -static int -copy_file(char *src, char *dst); - -static int -get_base_filename(char *proxy_file, char **basefilename); - -int -decode_record(char *line, proxy_record *record); - -int -encode_record(proxy_record *record, char **line); - -static int -open_metafile(char *proxy_file, FILE **fd); - -void -free_record(proxy_record *record); - -static int -realloc_prd_list(prd_list *list); - -/* make public: */ -static int -edg_wlpr_GetTokenInt(const char *msg, const size_t msg_len, - const char *key, const char *separators, - int req_index, int *value); - -static void -record_to_response(int status_code, proxy_record *record, - edg_wlpr_Response *response); - -static int -filename_to_response(char *filename, edg_wlpr_Response *response); - - - - -static char * -strmd5(const char *s, unsigned char *digest) -{ - MD5_CTX md5; - unsigned char d[16]; - int i; - static char mbuf[33]; - - MD5_Init(&md5); - MD5_Update(&md5,s,strlen(s)); - MD5_Final(d,&md5); - - if (digest) - memcpy(digest,d,sizeof(d)); - for (i=0; i<16; i++) { - int dd = d[i] & 0x0f; - mbuf[2*i+1] = dd<10 ? dd+'0' : dd-10+'a'; - dd = d[i] >> 4; - mbuf[2*i] = dd<10 ? dd+'0' : dd-10+'a'; - } - mbuf[32] = 0; - return mbuf; -} - -static int -get_base_filename(char *proxy_file, char **basefilename) -{ - char *subject = NULL; - char file[FILENAME_MAX]; - int ret; - - assert(basefilename != NULL); - - ret = get_proxy_base_name(proxy_file, &subject); - if (ret) - goto end; - - snprintf(file, sizeof(file), "%s/%s", repository, strmd5(subject, NULL)); - *basefilename = strdup(file); /* XXX test ENOMEM */ - ret = 0; - -end: - if (subject) - free(subject); - return ret; -} - -static int -copy_file_content(FILE *in, FILE *out) -{ - char buf[1024]; - size_t num; - int ret; - - while (1) { - num = fread(buf, sizeof(*buf), sizeof(buf), in); - if ((ret = ferror(in))) { - edg_wlpr_Log(LOG_ERR, "Reading failed: %s", strerror(errno)); - return ret; - } - num = fwrite(buf, sizeof(*buf), num, out); - if ((ret = ferror(in))) { - edg_wlpr_Log(LOG_ERR, "Writing failed: %s", strerror(errno)); - return ret; - } - if (feof(in)) - return 0; - } -} - -/* return the time interval, after which the renewal should be started */ -static time_t -get_delta(time_t current_time, time_t start_time, time_t end_time) -{ - time_t length, lifetime; - time_t delta; - int condor_tested = 0; - - lifetime = end_time - start_time; - delta = 0; - while (1) { - if (end_time - current_time <= RENEWAL_MIN_LIFETIME) - /* if the proxy is too short, renew it as soon as possible */ - return RENEWAL_CLOCK_SKEW; - - /* renewal starts at 3/4 of lifetime */ - length = end_time - (start_time + delta); - delta += length * RENEWAL_START_FRACTION; - - if (!condor_tested && delta > lifetime - condor_limit) { - /* Condor requires the proxies to be renewed a specified time interval - before the proxies have expired (see the - GRIDMANAGER_MINIMUM_PROXY_TIME variable). We must ensure that - renewal takes place before Condor does this check */ - if (current_time > end_time - condor_limit) { - edg_wlpr_Log(LOG_ERR, "Proxy lifetime exceeded value of the Condor limit!"); - } - else - delta = lifetime - condor_limit - RENEWAL_CLOCK_SKEW; - condor_tested = 1; - } - - if (abs(current_time - (start_time + delta)) < RENEWAL_CLOCK_SKEW) - continue; - - return (start_time + delta) - current_time; - }; - - /* not reachable */ - return 0; -} - -int -get_times(char *proxy_file, proxy_record *record) -{ - FILE *fd; - X509 *cert = NULL; - ASN1_UTCTIME *asn1_time = NULL; - int ret; - time_t current_time, start_time, end_time; - - assert(record != NULL); - assert(proxy_file != NULL); - - fd = fopen(proxy_file, "r"); - if (fd == NULL) { - edg_wlpr_Log(LOG_ERR, "Opening proxy file %s failed: %s", - proxy_file, strerror(errno)); - return errno; - } - - cert = PEM_read_X509(fd, NULL, NULL, NULL); - if (cert == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot read X.509 certificate from %s", - proxy_file); - ret = -1; /* XXX SSL_ERROR */ - goto end; - } - - asn1_time = ASN1_UTCTIME_new(); - X509_gmtime_adj(asn1_time,0); - globus_gsi_cert_utils_make_time(X509_get_notAfter(cert), &end_time); - globus_gsi_cert_utils_make_time(X509_get_notBefore(cert), &start_time); - current_time = time(NULL); - ASN1_UTCTIME_free(asn1_time); - /* if (end_time - RENEWAL_CLOCK_SKEW < current_time) { Too short proxy } */ - if (end_time + RENEWAL_CLOCK_SKEW < current_time) { - edg_wlpr_Log(LOG_ERR, "Expired proxy in %s", proxy_file); - ret = EDG_WLPR_PROXY_EXPIRED; - goto end; - } - - /* Myproxy seems not to do check on expiration and return expired proxies - if credentials in repository are expired */ - X509_free(cert); - cert = NULL; - while (1) { - time_t tmp_end; - /* see http://www.openssl.org/docs/crypto/pem.html section BUGS */ - cert = PEM_read_X509(fd, NULL, NULL, NULL); - if (cert == NULL) { - if (ERR_GET_REASON(ERR_peek_error()) == PEM_R_NO_START_LINE) { - /* End of file reached. no error */ - ERR_clear_error(); - break; - } - edg_wlpr_Log(LOG_ERR, "Cannot read additional certificates from %s", - proxy_file); - ret = -1; /* XXX SSL_ERROR */ - goto end; - } - globus_gsi_cert_utils_make_time(X509_get_notAfter(cert), &tmp_end); - if (tmp_end + RENEWAL_CLOCK_SKEW < current_time) { - edg_wlpr_Log(LOG_ERR, "Expired proxy in %s", proxy_file); - ret = EDG_WLPR_PROXY_EXPIRED; - goto end; - } - X509_free(cert); - cert = NULL; - } - - record->next_renewal = current_time + get_delta(current_time, start_time, - end_time); - record->end_time = end_time; - ret = 0; - -end: - fclose(fd); - if (cert) - X509_free(cert); - - return ret; -} - -static int -copy_file(char *src, char *dst) -{ - FILE *from = NULL; - FILE *tmp_to = NULL; - int tmp_fd; - char tmpfile[FILENAME_MAX]; - int ret; - - if (strcmp(src, dst) == 0) - return 0; - - from = fopen(src, "r"); - if (from == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot open file %s for reading (%s)", - src, strerror(errno)); - return errno; - } - - snprintf(tmpfile, sizeof(tmpfile), "%s.XXXXXX", dst); - tmp_fd = mkstemp(tmpfile); - if (tmp_fd == -1) { - edg_wlpr_Log(LOG_ERR, "Cannot create temporary file (%s)", - strerror(errno)); - ret = errno; - goto end; - } - - - tmp_to = fdopen(tmp_fd, "w"); - if (tmp_to == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot associate stream with temporary file (%s)", - strerror(errno)); - unlink(tmpfile); - ret = errno; - goto end; - } - - ret = copy_file_content(from, tmp_to); - fclose(tmp_to); - if (ret) { - goto end; - } - - ret = rename(tmpfile, dst); - if (ret) { - edg_wlpr_Log(LOG_ERR, "Cannot replace repository file %s with temporary file (%s)", - strerror(errno)); - unlink(tmpfile); - ret = errno; - goto end; - } - tmp_to = NULL; - -end: - fclose(from); - close(tmp_fd); - unlink(tmpfile); - - return ret; -} - -void -free_record(proxy_record *record) -{ - int i; - - if (record == NULL) - return; - if (record->myproxy_server) - free(record->myproxy_server); - if (record->jobids.val) { - for (i = 0; i < record->jobids.len; i++) - free(record->jobids.val[i]); - free(record->jobids.val); - } - memset(record, 0, sizeof(*record)); -} - -static int -realloc_prd_list(prd_list *list) -{ - char **tmp; - - tmp = realloc(list->val, (list->len + 1) * sizeof(*list->val)); - if (tmp == NULL) - return ENOMEM; - list->val = tmp; - list->len++; - return 0; -} - -static int -get_jobids(const char *msg, const size_t msg_len, proxy_record *record) -{ - int index = 0; - int ret; - char *value; - char **tmp; - - memset(&record->jobids, 0, sizeof(record->jobids)); - while ((ret = edg_wlpr_GetToken(msg, msg_len, "jobid=", SEPARATORS, - index, &value)) == 0) { - tmp = realloc(record->jobids.val, (record->jobids.len + 1) * sizeof(*tmp)); - if (tmp == NULL) { - ret = ENOMEM; - break; - } - record->jobids.val = tmp; - record->jobids.val[index] = value; - record->jobids.len++; - index++; - } - if (ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) { - if (record->jobids.len) - free(record->jobids.val); - record->jobids.len = 0; - record->jobids.val = NULL; - return ret; - } - - return 0; -} - -static int -edg_wlpr_GetTokenInt(const char *msg, const size_t msg_len, - const char *key, const char *separators, - int req_index, int *value) -{ - int ret; - char *str_value = NULL; - - ret = edg_wlpr_GetToken(msg, msg_len, key, separators, req_index, &str_value); - if (ret) - return ret; - - ret = edg_wlpr_DecodeInt(str_value, value); - free(str_value); - return ret; -} - -int -decode_record(char *line, proxy_record *record) -{ - /* line must be ended with '\0' */ - int ret; - size_t len; - - assert(line != NULL); - assert(record != NULL); - - memset(record, 0, sizeof(*record)); - - len = strlen(line) + 1; - - ret = edg_wlpr_GetTokenInt(line, len, "suffix=", SEPARATORS, 0, - &record->suffix); - if (ret) - return ret; - -#if 0 - ret = edg_wlpr_GetTokenInt(line, len, "counter=", SEPARATORS, 0, - &record->counter); - if (ret) - goto end; -#endif - - ret = edg_wlpr_GetTokenInt(line, len, "unique=", SEPARATORS, 0, - &record->unique); - if (ret) - goto end; - - ret = edg_wlpr_GetTokenInt(line, len, "voms_exts=", SEPARATORS, 0, - &record->voms_exts); - - ret = edg_wlpr_GetToken(line, len, "server=", SEPARATORS, 0, - &record->myproxy_server); - if (ret) - goto end; - - ret = edg_wlpr_GetTokenInt(line, len, "next_renewal=", SEPARATORS, 0, - (int *)&record->next_renewal); - if (ret) - goto end; - - ret = edg_wlpr_GetTokenInt(line, len, "end_time=", SEPARATORS, 0, - (int *)&record->end_time); - if (ret) - goto end; - - ret = get_jobids(line, len, record); - if (ret) - goto end; - -end: - if (ret) - free_record(record); - - return ret; -} - -int -encode_record(proxy_record *record, char **line) -{ - char tmp_line[1024]; - size_t jobids_len = 0; - int i; - - snprintf(tmp_line, sizeof(tmp_line), "suffix=%d, unique=%d, voms_exts=%d, server=%s, next_renewal=%ld, end_time=%ld", - record->suffix, record->unique, record->voms_exts, - (record->myproxy_server) ? record->myproxy_server : "", - record->next_renewal, record->end_time); - for (i = 0; i < record->jobids.len; i++) - /* alloc space for string ", jobid=" */ - jobids_len += 2 + strlen("jobid=") + strlen(record->jobids.val[i]); - - *line = calloc(1, strlen(tmp_line) + jobids_len + 1); - if (*line == NULL) - return ENOMEM; - - strcat(*line, tmp_line); - memset(tmp_line, 0, sizeof(tmp_line)); - - for (i = 0; i < record->jobids.len; i++) { - snprintf(tmp_line, sizeof(tmp_line), ", jobid=%s", record->jobids.val[i]); - strcat(*line, tmp_line); - } - - return 0; -} - -/* Get proxy record from the index file. If no suffix is defined return a free - record with the smallest index */ -static int -get_record_ext(FILE *fd, proxy_record *record, int *last_used_suffix) -{ - char line[1024]; - int last_suffix = -1; - int ret; - char *p; - proxy_record tmp_record; - time_t current_time; - - assert(record != NULL); - memset(&tmp_record, 0, sizeof(tmp_record)); - - current_time = time(NULL); - while (fgets(line, sizeof(line), fd) != NULL) { - free_record(&tmp_record); - p = strchr(line, '\n'); - if (p) - *p = '\0'; - ret = decode_record(line, &tmp_record); - if (ret) - return ret; /* XXX continue */ - if (record->suffix >= 0) { - if (record->suffix == tmp_record.suffix) { - record->suffix = tmp_record.suffix; - record->jobids.len = tmp_record.jobids.len; - record->jobids.val = tmp_record.jobids.val; - record->unique = tmp_record.unique; - record->voms_exts = tmp_record.voms_exts; - if (record->myproxy_server) - free(record->myproxy_server); - record->myproxy_server = tmp_record.myproxy_server; - record->end_time = tmp_record.end_time; - record->next_renewal = tmp_record.next_renewal; - return 0; - } else - continue; - } - if (tmp_record.suffix > last_suffix) - last_suffix = tmp_record.suffix; - - /* if no particular suffix was specified get the first free record - available */ - if (tmp_record.jobids.len >= MAX_PROXIES || tmp_record.unique || - tmp_record.voms_exts) - continue; - - if (tmp_record.jobids.len == 0) { - /* no jobs registered for this record, so use it initialized with the - * parameters (currently myproxy location) provided by user */ - char *server = record->myproxy_server; - - memset(record, sizeof(*record), 0); - record->suffix = tmp_record.suffix; - if (record->myproxy_server) - free(record->myproxy_server); - record->myproxy_server = server; - free_record(&tmp_record); - return 0; - } - - if (tmp_record.jobids.len > 0 && record->myproxy_server && - strcmp(record->myproxy_server, tmp_record.myproxy_server) != 0) - continue; - - if (tmp_record.jobids.len > 0 && - tmp_record.end_time - current_time < condor_limit) { - /* skip expired proxy (and that ones that are going to expire soon), - leaving it untouched (it will be removed after next run of the - renewal process */ - continue; - } - - record->suffix = tmp_record.suffix; - record->jobids.len = tmp_record.jobids.len; - record->jobids.val = tmp_record.jobids.val; - record->unique = tmp_record.unique; - record->voms_exts = tmp_record.voms_exts; - if (record->myproxy_server) - free(record->myproxy_server); - record->myproxy_server = tmp_record.myproxy_server; - record->end_time = tmp_record.end_time; - record->next_renewal = tmp_record.next_renewal; - return 0; - } - - if (last_used_suffix) - *last_used_suffix = last_suffix; - - if (record->suffix >= 0) { - edg_wlpr_Log(LOG_DEBUG, "Requested suffix %d not found in meta file", - record->suffix); - } - - free_record(&tmp_record); - - return EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND; -} - -static int -get_record(FILE *fd, proxy_record *record) -{ - return get_record_ext(fd, record, NULL); -} - -static int -store_record(char *basename, proxy_record *record) -{ - int stored = 0; - FILE *fd = NULL; - int temp; - char line[1024]; - char *new_line = NULL; - int ret, i; - char *p; - proxy_record tmp_record; - char tmp_file[FILENAME_MAX]; - char meta_file[FILENAME_MAX]; - - assert (record != NULL); - - memset(&tmp_record, 0, sizeof(tmp_record)); - - snprintf(meta_file, sizeof(meta_file), "%s.data", basename); - snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", meta_file); - - temp = mkstemp(tmp_file); - if (temp < 0) - return errno; - - fd = fopen(meta_file, "r"); - if (fd == NULL) { - ret = errno; - goto end; - } - while (fgets(line, sizeof(line), fd) != NULL) { - free_record(&tmp_record); - p = strchr(line, '\n'); - if (p) - *p = '\0'; - ret = decode_record(line, &tmp_record); - if (ret) - goto end; - if (record->suffix == tmp_record.suffix && - record->unique == tmp_record.unique) { - tmp_record.next_renewal = record->next_renewal; - tmp_record.end_time = record->end_time; - tmp_record.voms_exts = record->voms_exts; - if (tmp_record.myproxy_server != NULL) - free(tmp_record.myproxy_server); - tmp_record.myproxy_server = strdup(record->myproxy_server); - if (tmp_record.jobids.val) { - for (i = 0; i < tmp_record.jobids.len; i++) - free(tmp_record.jobids.val[i]); - free(tmp_record.jobids.val); - } - tmp_record.jobids.len = 0; - tmp_record.jobids.val = NULL; - for (i = 0; i < record->jobids.len; i++) { - realloc_prd_list(&tmp_record.jobids); - tmp_record.jobids.val[tmp_record.jobids.len - 1] = - strdup(record->jobids.val[i]); - } - stored = 1; - } - ret = encode_record(&tmp_record, &new_line); - if (ret) - goto end; - dprintf(temp, "%s\n", new_line); - free(new_line); - new_line = NULL; - } - if (! stored) { - ret = encode_record(record, &new_line); - if (ret) - goto end; - ret = dprintf(temp, "%s\n", new_line); - free(new_line); - new_line = NULL; - } - fclose(fd); fd = NULL; - close(temp); - - ret = rename(tmp_file, meta_file); - if (ret) - ret = errno; - -end: - free_record(&tmp_record); - if (fd) - fclose(fd); - close(temp); - return ret; -} - -static int -open_metafile(char *basename, FILE **fd) -{ - FILE *meta_fd; - char meta_filename[FILENAME_MAX]; - - snprintf(meta_filename, sizeof(meta_filename), "%s.data", basename); - meta_fd = fopen(meta_filename, "a+"); - if (meta_fd == NULL) { - edg_wlpr_Log(LOG_ERR, "Opening meta file %s failed (%s)", - meta_filename, strerror(errno)); - return errno; - } - rewind(meta_fd); - *fd = meta_fd; - edg_wlpr_Log(LOG_DEBUG, "Using meta file %s", meta_filename); - return 0; -} - -static int -filename_to_response(char *filename, edg_wlpr_Response *response) -{ - response->filenames = malloc(2 * sizeof(*response->filenames)); - if (response->filenames == NULL) { - edg_wlpr_Log(LOG_DEBUG, "Not enough memory"); - return errno; - } - response->filenames[0] = strdup(filename); - if (response->filenames[0] == NULL) { - edg_wlpr_Log(LOG_DEBUG, "Not enough memory"); - free(response->filenames); - return errno; - } - response->filenames[1] = NULL; - return 0; -} - -static void -record_to_response(int status_code, proxy_record *record, - edg_wlpr_Response *response) -{ - /* XXX Neni struktrura proxy_record zbytecna? Mohla by se pouzivat primo - edg_wlpr_Response? */ - response->response_code = status_code; /* XXX chyba parsovatelna pres API */ - if (status_code) - return; - - if (response->myproxy_server) { - response->myproxy_server = strdup(record->myproxy_server); - if (response->myproxy_server == NULL) { - response->response_code = ENOMEM; /* XXX */ - return; - } - } - response->end_time = record->end_time; - response->next_renewal_time = record->next_renewal; - /* XXX use jobid response->counter = record->counter; */ -} - -int -check_proxyname(char *datafile, char *jobid, char **filename) -{ - proxy_record record; - FILE *meta_fd = NULL; - char line[1024]; - char proxy[FILENAME_MAX]; - char *p; - int ret, i; - - memset(&record, 0, sizeof(record)); - - meta_fd = fopen(datafile, "r"); - if (meta_fd == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot open meta file %s (%s)", - datafile, strerror(errno)); - return errno; - } - - while (fgets(line, sizeof(line), meta_fd) != NULL) { - free_record(&record); - p = strchr(line, '\n'); - if (p) - *p = '\0'; - ret = decode_record(line, &record); - if (ret) - continue; /* XXX exit? */ - for (i = 0; i < record.jobids.len; i++) { - if (strcmp(jobid, record.jobids.val[i]) == 0) { - snprintf(proxy, sizeof(proxy), "%s/%s", repository, datafile); - p = strrchr(proxy, '.'); - sprintf(p, ".%d", record.suffix); - *filename = strdup(proxy); - free_record(&record); - fclose(meta_fd); - return 0; - } - } - } - free_record(&record); - fclose(meta_fd); - return EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND; -} - -int -find_proxyname(char *jobid, char **filename) -{ - DIR *dir = NULL; - struct dirent *file; - int ret; - - chdir(repository); - - dir = opendir(repository); - if (dir == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot open repository directory %s (%s)", - repository, strerror(errno)); - return errno; - } - - while ((file = readdir(dir))) { - /* read files of format `md5sum`.data, where md5sum() is of fixed length - 32 chars */ - if (file->d_name == NULL || strlen(file->d_name) != 37 || - strcmp(file->d_name + 32, ".data") != 0) - continue; - ret = check_proxyname(file->d_name, jobid, filename); - if (ret == 0) { - closedir(dir); - return 0; - } - } - closedir(dir); - edg_wlpr_Log(LOG_ERR, "Requested proxy is not registered"); - return EDG_WLPR_PROXY_NOT_REGISTERED; -} - -#ifdef NOVOMS -int -find_voms_cert(char *file, int *present) -{ - *present = 0; - return 0; -} - -#else -int -find_voms_cert(char *file, int *present) -{ - struct vomsdata *voms_info = NULL; - STACK_OF(X509) *chain = NULL; - EVP_PKEY *privkey = NULL; - X509 *cert = NULL; - int ret, err; - - *present = 0; - - voms_info = VOMS_Init(vomsdir, cadir); - if (voms_info == NULL) { - edg_wlpr_Log(LOG_ERR, "check_voms_cert(): Cannot initialize VOMS context (VOMS_Init() failed, probably voms dir was not specified)"); - return EDG_WLPR_ERROR_VOMS; - } - - ret = load_proxy(file, &cert, &privkey, &chain); - if (ret) { - VOMS_Destroy(voms_info); - return ret; - } - - ret = VOMS_Retrieve(cert, chain, RECURSE_CHAIN, voms_info, &err); - if (ret == 1) { - *present = 1; - } - - VOMS_Destroy(voms_info); - X509_free(cert); - EVP_PKEY_free(privkey); - sk_X509_pop_free(chain, X509_free); - return 0; -} -#endif - -void -register_proxy(edg_wlpr_Request *request, edg_wlpr_Response *response) -{ - proxy_record record; - int ret; - FILE *meta_fd = NULL; - int last_suffix; - char *basename = NULL; - char filename[FILENAME_MAX]; - - assert(request != NULL); - assert(response != NULL); - - memset(&record, 0, sizeof(record)); - memset(response, 0, sizeof(*response)); - edg_wlpr_Log(LOG_DEBUG, "Registration request for %s", request->proxy_filename); - - if (request->proxy_filename == NULL || request->jobid == NULL) { - edg_wlpr_Log(LOG_ERR, "Registration request doesn't contain registration information"); - return; /* EINVAL; */ - } - umask(0177); - - ret = get_base_filename(request->proxy_filename, &basename); - if (ret) - goto end; - - ret = open_metafile(basename, &meta_fd); - if (ret) - goto end; - - if (voms_enabled) - ret = find_voms_cert(request->proxy_filename, &record.voms_exts); - /* ignore VOMS related error */ - - /* Find first free record */ - record.suffix = -1; - record.myproxy_server = strdup(request->myproxy_server); - ret = get_record_ext(meta_fd, &record, &last_suffix); - fclose(meta_fd); meta_fd = NULL; - if (ret && ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) - goto end; - - if (ret == EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND || record.jobids.len == 0 || request->unique || record.voms_exts) { - /* create a new proxy file in the repository */ - int suffix; - - suffix = (record.jobids.len == 0 && record.suffix >= 0) ? - record.suffix : last_suffix + 1; - snprintf(filename, sizeof(filename), "%s.%d", basename, suffix); - ret = copy_file(request->proxy_filename, filename); - if (ret) - goto end; - ret = get_times(filename, &record); - if (ret) - goto end; - record.suffix = suffix; - ret = realloc_prd_list(&record.jobids); - if (ret) - goto end; - record.jobids.val[record.jobids.len - 1] = strdup(request->jobid); - record.unique = request->unique; - edg_wlpr_Log(LOG_DEBUG, "Created a new proxy file in repository (%s)", - filename); - } else { - ret = realloc_prd_list(&record.jobids); - if (ret) - goto end; - record.jobids.val[record.jobids.len - 1] = strdup(request->jobid); - snprintf(filename, sizeof(filename), "%s.%d", basename, record.suffix); - edg_wlpr_Log(LOG_DEBUG, "Inremented counter on %s", filename); - } - - ret = store_record(basename, &record); - -end: - if (meta_fd) { - fclose(meta_fd); - } - - if (basename) - free(basename); - - if (ret == 0) - ret = filename_to_response(filename, response); - record_to_response(ret, &record, response); - free_record(&record); -} - -void -unregister_proxy(edg_wlpr_Request *request, edg_wlpr_Response *response) -{ - proxy_record record; - int ret, i, index; - FILE *meta_fd = NULL; - char *basename = NULL; - char *p; - struct stat stat_buf; - - memset(&record, 0, sizeof(record)); - edg_wlpr_Log(LOG_DEBUG, "Unregistration request for %s", request->jobid); - - if (request->jobid == NULL) { - edg_wlpr_Log(LOG_ERR, "Unregistration request doesn't contain needed information"); - ret = EINVAL; - goto end; - } - - if (request->proxy_filename == NULL) { - ret = find_proxyname(request->jobid, &request->proxy_filename); - if (ret) - goto end; - } - - ret = get_base_filename(request->proxy_filename, &basename); - if (ret) { - goto end; - } - - if (strncmp(request->proxy_filename, basename, strlen(basename) != 0)) { - edg_wlpr_Log(LOG_DEBUG, "Requested proxy %s is not from repository", - request->proxy_filename); - ret = EDG_WLPR_PROXY_NOT_REGISTERED; - goto end; - } - - p = strrchr(request->proxy_filename, '.'); - if (p == NULL) { - edg_wlpr_Log(LOG_DEBUG, "Requested proxy %s is not from repository", - request->proxy_filename); - ret = EDG_WLPR_PROXY_NOT_REGISTERED; - goto end; - } - - ret = edg_wlpr_DecodeInt(p+1, &record.suffix); - if (ret) { - edg_wlpr_Log(LOG_DEBUG, "Requested proxy %s is not from repository", - request->proxy_filename); - ret = EDG_WLPR_PROXY_NOT_REGISTERED; - goto end; - } - - ret = open_metafile(basename, &meta_fd); - if (ret) { - /* fill in error response */ - return; - } - - ret = get_record(meta_fd, &record); - if (ret) - goto end; - - ret = EDG_WLPR_PROXY_NOT_REGISTERED; - for (i = 0; i < record.jobids.len; i++) - if (strcmp(request->jobid, record.jobids.val[i]) == 0) { - ret = 0; - break; - } - if (ret) { - edg_wlpr_Log(LOG_DEBUG, "Requested proxy %s is not registered", - request->proxy_filename); - goto end; - } - - /* remove jobid from the list */ - index = i; - free(record.jobids.val[i]); - record.jobids.len--; - for (i = index; i < record.jobids.len; i++) - record.jobids.val[i] = record.jobids.val[i+1]; - - if (record.jobids.len == 0) { - record.unique = 0; - record.voms_exts = 0; - record.end_time = 0; - record.next_renewal = 0; - } - - ret = stat(request->proxy_filename, &stat_buf); - if (ret) { - edg_wlpr_Log(LOG_DEBUG, "Cannot stat file %s: (%s)", - request->proxy_filename, strerror(errno)); - ret = errno; - goto end; - } - - ret = store_record(basename, &record); - if (ret) - goto end; - - if (record.jobids.len == 0) - unlink(request->proxy_filename); - -end: - if (meta_fd) { - fclose(meta_fd); - } - if (basename) - free(basename); - - if (ret == 0) - ret = filename_to_response(request->proxy_filename, response); - record_to_response(ret, &record, response); - free_record(&record); -} - -void -get_proxy(edg_wlpr_Request *request, edg_wlpr_Response *response) -{ - char *filename = NULL; - int ret; - - memset(response, 0, sizeof(*response)); - - edg_wlpr_Log(LOG_DEBUG, "GET request for %s", request->jobid); - - if (request->jobid == NULL) { - edg_wlpr_Log(LOG_ERR, "GET request doesn't contain jobid specification"); - ret = EINVAL; - goto end; - } - - ret = find_proxyname(request->jobid, &filename); - -end: - if (ret == 0) - ret = filename_to_response(filename, response); - if (filename) - free(filename); - response->response_code = ret; -} - -void -update_db(edg_wlpr_Request *request, edg_wlpr_Response *response) -{ - FILE *fd = NULL; - int tmp_fd = -1; - int suffix = -1; - char tmp_file[FILENAME_MAX]; - char cur_proxy[FILENAME_MAX]; - char datafile[FILENAME_MAX]; - char line[1024]; - char *new_line = NULL; - char *basename, *proxy = NULL; - char **entry; - proxy_record record; - int ret; - char *p; - time_t current_time; - - memset(&record, 0, sizeof(record)); - - edg_wlpr_Log(LOG_DEBUG, "UPDATE_DB request for %s", request->proxy_filename); - - chdir(repository); - basename = request->proxy_filename; - - snprintf(datafile, sizeof(datafile), "%s.data", basename); - fd = fopen(datafile, "r"); - if (fd == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot open meta file %s (%s)", - datafile, strerror(errno)); - ret = errno; - return; - } - - snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", datafile); - tmp_fd = mkstemp(tmp_file); - if (tmp_fd < 0) { - edg_wlpr_Log(LOG_ERR, "Cannot create temporary file (%s)", - strerror(errno)); - ret = errno; - goto end; - } - - entry = request->entries; - if (entry) { - p = strchr(*entry, ':'); - *p = '\0'; - suffix = atoi(*entry); - proxy = p+1; - } - - current_time = time(NULL); - - while (fgets(line, sizeof(line), fd) != NULL) { - free_record(&record); - p = strchr(line, '\n'); - if (p) - *p = '\0'; - ret = decode_record(line, &record); - if (ret) - goto end; - - if (record.suffix > suffix && entry && *entry) { - do { - entry++; - if (entry == NULL || *entry == NULL) { - suffix = -1; - break; - } - - p = strchr(*entry, ':'); - suffix = atoi(*entry); - proxy = p+1; - } while (record.suffix > suffix); - } - - if (record.suffix == suffix) { - snprintf(cur_proxy, sizeof(cur_proxy), "%s.%d", basename, suffix); - if (proxy == NULL || *proxy == '\0') { - /* if proxy isn't specified use file registered currently and - * reschedule renewal */ - if (record.end_time < current_time) { - char *server; - /* remove file with expired proxy and clean the record in db */ - unlink(cur_proxy); - server = strdup(record.myproxy_server); - free_record(&record); - record.suffix = suffix; - record.myproxy_server = server; - edg_wlpr_Log(LOG_WARNING, "Removed expired proxy (suffix %d)", - suffix); - } else - get_times(cur_proxy, &record); - } else { - ret = get_times(proxy, &record); - (ret == 0) ? rename(proxy, cur_proxy) : unlink(proxy); - } - } - - ret = encode_record(&record, &new_line); - if (ret) - goto end; - - dprintf(tmp_fd, "%s\n", new_line); - free(new_line); - new_line = NULL; - } - free_record(&record); - - close(tmp_fd); - fclose(fd); - - rename(tmp_file, datafile); - - return; - -end: - if (fd) - fclose(fd); - unlink(tmp_file); - if (tmp_fd > 0) - close(tmp_fd); - free_record(&record); - - return; -} diff --git a/org.glite.security.proxyrenewal/src/common.c b/org.glite.security.proxyrenewal/src/common.c deleted file mode 100644 index 87fff76..0000000 --- a/org.glite.security.proxyrenewal/src/common.c +++ /dev/null @@ -1,239 +0,0 @@ -#include "renewal_locl.h" - -#ident "$Header$" - -/* nread() and nwrite() never return partial data */ -static size_t -nread(int sock, char *buf, size_t buf_len) -{ - size_t count; - size_t remain = buf_len; - char *cbuf = buf; - - while (remain > 0) { - count = read(sock, cbuf, remain); - if (count < 0) { - if (errno == EINTR) - continue; - else - return count; - } else - if (count == 0) { - return count; - } - cbuf += count; - remain -= count; - } - return buf_len; -} - -static size_t -nwrite(int sock, const char *buf, size_t buf_len) -{ - const char *cbuf = buf; - size_t count; - size_t remain = buf_len; - - while (remain > 0) { - count = write(sock, cbuf, remain); - if (count < 0) { - if (errno == EINTR) - continue; - else - return count; - } - cbuf += count; - remain -= count; - } - return buf_len; -} - -int -edg_wlpr_Read(int sock, char **buf, size_t *buf_len) -{ - int ret; - unsigned char length[4]; - - ret = nread(sock, length, 4); - if (ret == -1) { - *buf_len = 0; - return errno; - } - if (ret < 4) { - *buf_len = 0; - return EDG_WLPR_ERROR_UNEXPECTED_EOF; /* XXX vraci i kdyz peer spadne a zavre trubku */ - } - *buf_len = (length[0] << 24) | - (length[1] << 16) | - (length[2] << 8 ) | - (length[3] << 0); - - *buf = malloc(*buf_len); - if (*buf == NULL) - return ENOMEM; - - ret = nread(sock, *buf, *buf_len); - if (ret != *buf_len) { - free(*buf); - *buf_len = 0; - return errno; - } - - return 0; -} - -int -edg_wlpr_Write(int sock, char *buf, size_t buf_len) -{ - unsigned char length[4]; - - length[0] = (buf_len >> 24) & 0xFF; - length[1] = (buf_len >> 16) & 0xFF; - length[2] = (buf_len >> 8) & 0xFF; - length[3] = (buf_len >> 0) & 0xFF; - - if (nwrite(sock, length, 4) != 4 || - nwrite(sock, buf, buf_len) != buf_len) - return errno; - - return 0; -} - -int -edg_wlpr_GetToken(const char *msg, const size_t msg_len, - const char *key, const char *separators, - int req_index, char **value) -{ - char *p; - size_t len; - int index; - - assert(separators != NULL); - - /* Add ending zero ? */ - - index = 0; - p = (char *)msg; - while (p && (p = strstr(p, key))) { - if (index == req_index) - break; - index++; - p += strlen(key); - } - if (p == NULL) - return EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND; - - p = strchr(p, '='); - if (p == NULL) - return EDG_WLPR_ERROR_PROTO_PARSE_ERROR; - - len = strcspn(p+1, separators); - if (len == 0) - return EDG_WLPR_ERROR_PROTO_PARSE_ERROR; - - *value = malloc(len + 1); - if (*value == NULL) - return ENOMEM; - - memcpy(*value, p+1, len); - (*value)[len] = '\0'; - - return 0; -} - -int -edg_wlpr_StoreToken(char **buf, size_t *buf_len, char *command, - char *value, const char *separator) -{ - char line[2048]; - char *tmp; - - assert(buf != NULL); - assert(separator != NULL); - - if (strlen(command) + 1 + strlen(value) + 2 > sizeof(line)) - return ERANGE; /* XXX */ - - snprintf(line, sizeof(line), "%s%s%s", command, value, separator); - - while (strlen(*buf) + strlen(line) + 1 > *buf_len) { - tmp = realloc(*buf, *buf_len + EDG_WLPR_BUF_SIZE); - if (tmp == NULL) - return ENOMEM; - *buf = tmp; - *buf_len += EDG_WLPR_BUF_SIZE; - } - strcat(*buf, line); - - return 0; -} - -void -edg_wlpr_CleanRequest(edg_wlpr_Request *request) -{ - assert(request != NULL); - if (request->version) - free(request->version); - if (request->proxy_filename) - free(request->proxy_filename); - if (request->myproxy_server) - free(request->myproxy_server); - if (request->jobid) - free(request->jobid); - if (request->entries) { - char **p = request->entries; - char **next; - while (*p) { - next = p+1; - free(*p); - p = next; - } - free(request->entries); - } - - memset(request, 0, sizeof(request)); -} - -void -edg_wlpr_CleanResponse(edg_wlpr_Response *response) -{ - assert(response != NULL); - if (response->version) - free(response->version); - if (response->myproxy_server) - free(response->myproxy_server); - if (response->filenames) { - char **p = response->filenames; - char **next; - - while (*p) { - next = p+1; - free(*p); - p = next; - } - free(response->filenames); - } - memset(response, 0, sizeof(*response)); -} - -const char * -edg_wlpr_GetErrorString(int code) -{ - return (code == 0) ? "OK" : "Error"; -} - -char * -edg_wlpr_EncodeInt(int num) /* long? time */ -{ - static char ret[64]; - - snprintf(ret, sizeof(ret), "%d", num); - return ret; -} - -int -edg_wlpr_DecodeInt(char *str, int *num) -{ - *num = atol(str); /* XXX */ - return 0; -} diff --git a/org.glite.security.proxyrenewal/src/renew.c b/org.glite.security.proxyrenewal/src/renew.c deleted file mode 100644 index 6c6e577..0000000 --- a/org.glite.security.proxyrenewal/src/renew.c +++ /dev/null @@ -1,1120 +0,0 @@ -#include "renewal_locl.h" -#include "renewd_locl.h" - -#ifndef NOVOMS -#include -#endif - -#ident "$Header$" - -extern char *repository; -extern char *cadir; -extern char *vomsdir; -extern int voms_enabled; -extern char *vomsconf; -extern struct vomses_records vomses; - -static int received_signal = -1; - -static void -check_renewal(char *datafile, int force_renew); - -static int -renew_proxy(proxy_record *record, char *basename, char **new_proxy); - -static void -register_signal(int signal); - - -#define DGPR_RETRIEVE_DEFAULT_HOURS 10 -#define RENEWAL_CLOCK_SKEW 5 * 60 - -static const char * -get_ssl_err() -{ - return "SSL failed"; -} - -int -load_proxy(const char *filename, X509 **cert, EVP_PKEY **privkey, - STACK_OF(X509) **chain) -{ - X509 *my_cert = NULL; - EVP_PKEY *my_key = NULL; - STACK_OF(X509) *my_chain = NULL; - FILE *fd = NULL; - int ret; - - fd = fopen(filename, "r"); - if (fd == NULL) { - edg_wlpr_Log(LOG_ERR, - "Cannot read VOMS certificate (fopen() failed on %s: %s)", - filename, strerror(errno)); - return errno; - } - - my_cert = PEM_read_X509(fd, NULL, NULL, NULL); - if (my_cert == NULL) { - edg_wlpr_Log(LOG_ERR, - "Cannot read VOMS certificate (PEM_read_X509() failed: %s)", - get_ssl_err()); - ret = EDG_WLPR_ERROR_SSL; - goto end; - } - - my_key = PEM_read_PrivateKey(fd, NULL, NULL, NULL); - if (my_key == NULL) { - edg_wlpr_Log(LOG_ERR, - "Cannot read VOMS certificate (PEM_read_PrivateKey() failed: %s)", - get_ssl_err()); - ret = EDG_WLPR_ERROR_SSL; - goto end; - } - - my_chain = sk_X509_new_null(); - if (my_chain == NULL) { - edg_wlpr_Log(LOG_ERR, - "Cannot read VOMS certificate (sk_X509_new_null() failed: %s)", - get_ssl_err()); - ret = EDG_WLPR_ERROR_SSL; - goto end; - } - - while (1) { - X509 *c; - - c = PEM_read_X509(fd, NULL, NULL, NULL); - if (c == NULL) { - if (ERR_GET_REASON(ERR_peek_error()) == PEM_R_NO_START_LINE) { - /* End of file reached. no error */ - ERR_clear_error(); - break; - } - edg_wlpr_Log(LOG_ERR, - "Cannot read VOMS certificate (PEM_read_X509() failed: %s)", - get_ssl_err()); - ret = EDG_WLPR_ERROR_SSL; - goto end; - } - sk_X509_push(my_chain, c); - } - - *cert = my_cert; - *privkey = my_key; - *chain = my_chain; - my_cert = NULL; my_key = NULL; my_chain = NULL; - ret = 0; - -end: - fclose(fd); - - if (my_cert) - X509_free(my_cert); - if (my_key) - EVP_PKEY_free(my_key); - if (my_chain) - sk_X509_pop_free(my_chain, X509_free); - - return ret; -} - -static int -save_proxy(const char *filename, X509 *new_cert, EVP_PKEY *new_privkey, - STACK_OF(X509) *chain) -{ - FILE *fd = NULL; - int ret, i; - int retval = EDG_WLPR_ERROR_SSL; - - fd = fopen(filename, "w"); - if (fd == NULL) { - edg_wlpr_Log(LOG_ERR, - "Cannot store proxy (fopen() failed on %s: %s)", - filename, strerror(errno)); - return errno; - } - - ret = PEM_write_X509(fd, new_cert); - if (ret == 0) { - edg_wlpr_Log(LOG_ERR, - "Cannot store proxy (PEM_write_X509() failed: %s)", - get_ssl_err()); - goto end; - } - - ret = PEM_write_PrivateKey(fd, new_privkey, NULL, NULL, 0, NULL, NULL); - if (ret == 0) { - edg_wlpr_Log(LOG_ERR, - "Cannot store proxy (PEM_write_PrivateKey() failed: %s)", - get_ssl_err()); - goto end; - } - - for (i = 0; i < sk_X509_num(chain); i++) { - X509 *cert = sk_X509_value(chain, i); - ret = PEM_write_X509(fd, cert); - if (ret == 0) { - edg_wlpr_Log(LOG_ERR, - "Cannot store proxy (PEM_write_X509() failed: %s)", - get_ssl_err()); - goto end; - } - } - - retval = 0; - -end: - fclose(fd); - - return retval; -} - -static int -gen_keypair(EVP_PKEY **keypair, int requested_bits) -{ - RSA *rsa = NULL; - EVP_PKEY *key; - - *keypair = NULL; - rsa = RSA_generate_key(requested_bits, - RSA_F4 /* public exponent */, - NULL, NULL); - if (rsa == NULL) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (RSA_generate_key() failed: %s)", - get_ssl_err()); - return EDG_WLPR_ERROR_SSL; - } - - key = EVP_PKEY_new(); - if (key == NULL) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (EVP_PKEY_new() failed: %s)", - get_ssl_err()); - RSA_free(rsa); - return EDG_WLPR_ERROR_SSL; - } - - if (EVP_PKEY_assign_RSA(key, rsa) == 0) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (EVP_PKEY_assign_RSA() failed: %s)", - get_ssl_err()); - RSA_free(rsa); - EVP_PKEY_free(key); - return EDG_WLPR_ERROR_SSL; - } - - *keypair = key; - - return 0; -} - -static int -gen_subject_name(X509 *old_cert, X509 *new_cert) -{ - X509_NAME *name = NULL; - X509_NAME_ENTRY *name_entry = NULL; - int ret = EDG_WLPR_ERROR_SSL; - - name = X509_NAME_dup(X509_get_subject_name(old_cert)); - if (name == NULL) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (X509_NAME_dup() failed: %s", - get_ssl_err()); - goto end; - } - - name_entry = X509_NAME_ENTRY_create_by_NID(NULL /* make new entry */, - NID_commonName, - V_ASN1_APP_CHOOSE, - "proxy", -1); - if (name_entry == NULL) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (X509_NAME_ENTRY_create_by_NID() failed: %s)", - get_ssl_err()); - goto end; - } - - if (X509_NAME_add_entry(name, name_entry, X509_NAME_entry_count(name), 0) == 0) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (X509_NAME_add_entry() failed: %s)", - get_ssl_err()); - goto end; - } - - - if (X509_set_subject_name(new_cert, name) == 0) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (X509_set_subject_name() failed: %s)", - get_ssl_err()); - goto end; - } - - ret = 0; - -end: - if (name) - X509_NAME_free(name); - if (name_entry != NULL) - X509_NAME_ENTRY_free(name_entry); - - return ret; -} - -static int -create_proxy(X509 *old_cert, EVP_PKEY *old_privkey, X509_EXTENSION *extension, - X509 **new_cert, EVP_PKEY **new_privkey) -{ - /* Inspired by code from Myproxy */ - EVP_PKEY *key_pair = NULL; - X509 *cert = NULL; - int ret; - int retval = EDG_WLPR_ERROR_SSL; - - ret = gen_keypair(&key_pair, 512); - if (ret) - return ret; - - cert = X509_new(); - if (cert == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot generate new proxy (X509_new() failed: Not enough memory)"); - goto end; - } - - ret = gen_subject_name(old_cert, cert); - if (ret) { - retval = ret; - goto end; - } - - if (X509_set_issuer_name(cert, X509_get_subject_name(old_cert)) == 0) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (X509_set_issuer_name() failed: %s)", - get_ssl_err()); - goto end; - } - - if (X509_set_serialNumber(cert, X509_get_serialNumber(old_cert)) == 0) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (X509_set_serialNumber() failed: %s)", - get_ssl_err()); - goto end; - } - - X509_gmtime_adj(X509_get_notBefore(cert), -(60 * 5)); - X509_set_notAfter(cert, X509_get_notAfter(old_cert)); - - if (X509_set_pubkey(cert, key_pair) == 0) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (X509_set_pubkey() failed: %s)", - get_ssl_err()); - goto end; - } - - /* set v3 */ - if (X509_set_version(cert, 2L) == 0) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (X509_set_version() failed: %s)", - get_ssl_err()); - goto end; - } - - if (cert->cert_info->extensions != NULL) - sk_X509_EXTENSION_pop_free(cert->cert_info->extensions, - X509_EXTENSION_free); - cert->cert_info->extensions = sk_X509_EXTENSION_new_null(); - sk_X509_EXTENSION_push(cert->cert_info->extensions, extension); - - if (X509_sign(cert, old_privkey, EVP_md5()) == 0) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (X509_sign() failed: %s)", - get_ssl_err()); - goto end; - } - - *new_privkey = key_pair; - *new_cert = cert; - key_pair = NULL; - cert = NULL; - - retval = 0; - -end: - if (key_pair) - EVP_PKEY_free(key_pair); - if (cert) - X509_free(cert); - - return retval; -} - -static int -create_voms_extension(char *buf, size_t buf_len, X509_EXTENSION **extensions) -{ - ASN1_OBJECT *voms_obj = NULL; - ASN1_OCTET_STRING *voms_oct = NULL; - - *extensions = NULL; - - voms_oct = ASN1_OCTET_STRING_new(); - if (voms_oct == NULL) { - edg_wlpr_Log(LOG_ERR, - "Cannot generate new proxy (ASN1_OCTET_STRING_new() failed: %s)", - get_ssl_err()); - return EDG_WLPR_ERROR_SSL; - } - - voms_oct->data = buf; - voms_oct->length = buf_len; - - voms_obj = OBJ_nid2obj(OBJ_txt2nid("VOMS")); - if (voms_obj == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot generate new proxy (OBJ_nid2obj() failed"); - goto end; - } - - *extensions = X509_EXTENSION_create_by_OBJ(NULL, voms_obj, 0, voms_oct); - if (*extensions == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot generate new proxy (X509_EXTENSION_create_by_OBJ() failed"); - goto end; - } - - return 0; - -end: - if (voms_oct) - ASN1_OCTET_STRING_free(voms_oct); - if (voms_obj) - ASN1_OBJECT_free(voms_obj); - return EDG_WLPR_ERROR_SSL; -} - -#ifndef NOVOMS -static int -export_std_data(struct data *voms_data, char **buf) -{ - asprintf(buf, "GROUP: %s\n" - "ROLE:%s\n" /* the space is missing intentionaly */ - "CAP: %s\n", - (voms_data->group) ? voms_data->group : "NULL", - (voms_data->role) ? voms_data->role : "NULL", - (voms_data->cap) ? voms_data->cap : "NULL"); - return 0; -} - -static int -export_user_data(struct voms *voms_cert, char **buf, size_t *len) -{ - struct data **voms_data; - char *str = NULL; - char *ptr; - - *buf = NULL; - - switch (voms_cert->type) { - case TYPE_NODATA: - *buf = strdup("NO DATA"); - break; - case TYPE_CUSTOM: - *buf = strdup(voms_cert->custom); - break; - case TYPE_STD: - for (voms_data = voms_cert->std; voms_data && *voms_data; voms_data++) { - export_std_data(*voms_data, &str); - if (*buf == NULL) - ptr = calloc(strlen(str) + 1, 1); - else - ptr = realloc(*buf, strlen(*buf) + strlen(str) + 1); - if (ptr == NULL) { - return ENOMEM; - } - *buf = ptr; - strcat(*buf, str); - free(str); - } - - break; - default: - return -1; - } - - *len = strlen(*buf); - return 0; -} - -#endif - -static int -encode_voms_buf(const char *label, char *data, size_t data_len, - char **buf, size_t *buf_len) -{ - char *tmp; - - tmp = realloc(*buf, *buf_len + strlen(label) + data_len + 1); - if (tmp == NULL) - return ENOMEM; - - memcpy(tmp + *buf_len, label, strlen(label)); - - memcpy(tmp + *buf_len + strlen(label), data, data_len); - tmp[*buf_len + strlen(label) + data_len] = '\n'; - *buf = tmp; - *buf_len = *buf_len + strlen(label) + data_len + 1; - - return 0; -} - -static int -encode_voms_int(const char *label, int value, char **buf, size_t *buf_len) -{ - char tmp[16]; - - snprintf(tmp, sizeof(tmp), "%d", value); - return encode_voms_buf(label, tmp, strlen(tmp), buf, buf_len); -} - -static int -encode_voms_str(const char *label, char *value, char **buf, size_t *buf_len) -{ - return encode_voms_buf(label, value, strlen(value), buf, buf_len); -} - -#if 0 -static int -VOMS_Export(struct vomsdata *voms_info, char **buf, size_t *len) -{ - struct voms *vc; - char *enc_voms = NULL; - size_t enc_voms_len = 0; - char *data_buf; - size_t data_len; - int ret; - - if (voms_info == NULL || voms_info->data == NULL || *voms_info->data == NULL) - return EINVAL; - vc = *voms_info->data; - - ret = export_user_data(vc, &data_buf, &data_len); - if (ret) - return ret; - - encode_voms_int("SIGLEN:", vc->siglen, &enc_voms, &enc_voms_len); - encode_voms_buf("SIGNATURE:",vc->signature, vc->siglen, - &enc_voms, &enc_voms_len); - enc_voms_len--; /* Signature is not followed by '\n' */ - encode_voms_str("USER:", vc->user, &enc_voms, &enc_voms_len); - encode_voms_str("UCA:", vc->userca, &enc_voms, &enc_voms_len); - encode_voms_str("SERVER:", vc->server, &enc_voms, &enc_voms_len); - encode_voms_str("SCA:", vc->serverca, &enc_voms, &enc_voms_len); - encode_voms_str("VO:", vc->voname, &enc_voms, &enc_voms_len); - encode_voms_str("URI:", vc->uri, &enc_voms, &enc_voms_len); - encode_voms_str("TIME1:", vc->date1, &enc_voms, &enc_voms_len); - encode_voms_str("TIME2:", vc->date2, &enc_voms, &enc_voms_len); - encode_voms_int("DATALEN:", data_len, &enc_voms, &enc_voms_len); - encode_voms_buf("", data_buf, data_len, &enc_voms, &enc_voms_len); - enc_voms_len--; /* the data already contains endind '\n' */ - - free(data_buf); - if (enc_voms == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot renew VOMS certificate (Not enough memory)"); - return ENOMEM; - } - *buf = enc_voms; - *len = enc_voms_len; - return 0; -} - -static int -voms_cert_renew(char *hostname, int port, char *voms_subject, - char *proxy, - struct voms **cur_voms_cert, struct vomsdata *voms_info) -{ - int ret = 0; - char *command = "A"; - int err = 0; - char *old_env_proxy = getenv("X509_USER_PROXY"); - - setenv("X509_USER_PROXY", proxy, 1); - - /* hack (suggested by Vincenzo Ciaschini) to work around problem with - * unitialized VOMS struct */ - ret = VOMS_Ordering("zzz:zzz", voms_info, &err); - if (ret == 0) { - edg_wlpr_Log(LOG_ERR, "Cannot renew VOMS certificate (VOMS_Ordering() failed"); - ret = EDG_WLPR_ERROR_VOMS; - goto end; - } - - /* XXX only attributes which are in current certificate should be requested*/ - ret = VOMS_Contact(hostname, port, (*cur_voms_cert)->server, command, - voms_info, &err); - if (ret == 0) { -#if 0 - if (err == 1) { /* XXX cannot connect voms server */ - ret = 0; - goto end; - } -#endif - edg_wlpr_Log(LOG_ERR, "Cannot renew VOMS certificate (VOMS_Contact() failed: %d)", err); - ret = EDG_WLPR_ERROR_VOMS; - } else - ret = 0; - -end: - (old_env_proxy) ? setenv("X509_USER_PROXY", old_env_proxy, 1) : - unsetenv("X509_USER_PROXY"); - - return ret; -} - -static int -renew_voms_cert(struct voms **cur_voms_cert, char *proxy, char **buf, size_t *buf_len) -{ - struct vomsdata *voms_info = NULL; - char *hostname = NULL; - char *p; - int port, ret; - - hostname = strdup((*cur_voms_cert)->uri); - p = strchr(hostname, ':'); - if (p) - *p = '\0'; - port = (p) ? atoi(p+1) : 15000; - - voms_info = VOMS_Init(vomsdir, cadir); - if (voms_info == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot renew VOMS certificate (VOMS_Init() failed)"); - ret = EDG_WLPR_ERROR_VOMS; - goto end; - } - - ret = voms_cert_renew(hostname, port, (*cur_voms_cert)->server, proxy, cur_voms_cert, - voms_info); - if (ret) - goto end; - - ret = VOMS_Export(voms_info, buf, buf_len); - if (ret) { - edg_wlpr_Log(LOG_ERR, "Cannot renew VOMS certificate (VOMS_Export() failed)"); - ret = EDG_WLPR_ERROR_VOMS; - goto end; - } - - ret = 0; - -end: - if (hostname) - free(hostname); -#if 0 - if (voms_info) - VOMS_Destroy(voms_info); -#endif - - return ret; -} -#endif - -#ifndef NOVOMS -static vomses_record * -find_vomses_record(char *hostname, int port) -{ - int i; - - for (i = 0; i < vomses.len; i++) { - if (strcmp(vomses.val[i]->hostname, hostname) == 0 && - vomses.val[i]->port == port) - return vomses.val[i]; - } - - return NULL; -} - -static int -set_vo_params(struct voms **voms_cert, char **arg) -{ - vomses_record *r; - char *tmp; - int port; - char *hostname; - char *p; - - hostname = strdup((*voms_cert)->uri); - p = strchr(hostname, ':'); - if (p) - *p = '\0'; - port = (p) ? atoi(p+1) : 15000; - - r = find_vomses_record(hostname, port); - if (r == NULL) - return EINVAL; - - if (*arg == NULL) { - asprintf(arg, " -voms %s", r->nick); - } else { - tmp = realloc(*arg, - strlen(*arg) + strlen(" -voms ") + strlen(r->nick) + 1); - if (tmp == NULL) - return ENOMEM; - *arg = tmp; - *arg = strcat(*arg, " -voms "); - *arg = strcat(*arg, r->nick); - } - return 0; -} -#endif - -static int -exec_voms_proxy_init(char *arg, char *old_proxy, char *new_proxy) -{ - char command[256]; - int ret; - char *old_env_proxy = getenv("X509_USER_PROXY"); - - setenv("X509_USER_PROXY", old_proxy, 1); - - snprintf(command, sizeof(command), - "edg-voms-proxy-init -out %s -key %s -cert %s -confile %s -q %s", - new_proxy, old_proxy, old_proxy, vomsconf, arg); - ret = system(command); - - (old_env_proxy) ? setenv("X509_USER_PROXY", old_env_proxy, 1) : - unsetenv("X509_USER_PROXY"); - - return ret; -} - -#if 0 -static int -renew_voms_certs(const char *old_proxy, const char *new_proxy) -{ - struct vomsdata *voms_info = NULL; - struct voms **voms_cert = NULL; - STACK_OF(X509) *chain = NULL; - EVP_PKEY *privkey = NULL; - X509 *cert = NULL; - int ret, err; - char *buf = NULL; - size_t buf_len = 0; - X509_EXTENSION *extension = NULL; - X509 *new_cert = NULL; - EVP_PKEY *new_privkey = NULL; - - voms_info = VOMS_Init(vomsdir, cadir); - if (voms_info == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot initialize VOMS context (VOMS_Init() failed)"); - return EDG_WLPR_ERROR_VOMS; - } - - ret = load_proxy(old_proxy, &cert, &privkey, &chain); - if (ret) - goto end; - - ret = VOMS_Retrieve(cert, chain, RECURSE_CHAIN, voms_info, &err); - if (ret == 0) { - if (err == VERR_NOEXT) { - /* no VOMS cred, no problem; continue */ - ret = 0; - } else { - edg_wlpr_Log(LOG_ERR, "Cannot get VOMS certificate(s) from proxy"); - ret = EDG_WLPR_ERROR_VOMS; - } - goto end; - } - - for (voms_cert = voms_info->data; voms_cert && *voms_cert; voms_cert++) { - char *tmp, *ptr; - size_t tmp_len; - - ret = renew_voms_cert(voms_cert, old_proxy, &tmp, &tmp_len); - if (ret) - continue; - ptr = realloc(buf, buf_len + tmp_len); - if (ptr == NULL) { - ret = ENOMEM; - goto end; - } - buf = ptr; - memcpy(buf + buf_len, tmp, tmp_len); - buf_len += tmp_len; - } - - if (buf == NULL) { - /* no extension renewed, return */ - ret = 0; - goto end; - } - - ret = create_voms_extension(buf, buf_len, &extension); - if (ret) - goto end; - - X509_free(cert); - EVP_PKEY_free(privkey); - sk_X509_pop_free(chain, X509_free); - - ret = load_proxy(new_proxy, &cert, &privkey, &chain); - if (ret) - goto end; - - ret = create_proxy(cert, privkey, extension, &new_cert, &new_privkey); - if (ret) - goto end; - - sk_X509_insert(chain, cert, 0); - - ret = save_proxy(new_proxy, new_cert, new_privkey, chain); - if (ret) - goto end; - - ret = 0; - -end: - VOMS_Destroy(voms_info); - - return ret; -} -#else /* 0 */ - -#ifdef NOVOMS -static int -renew_voms_certs(const char *old_proxy, char *myproxy_proxy, const char *new_proxy) -{ - return 0; -} - -#else -static int -renew_voms_certs(const char *old_proxy, char *myproxy_proxy, const char *new_proxy) -{ - struct vomsdata *voms_info = NULL; - struct voms **voms_cert = NULL; - STACK_OF(X509) *chain = NULL; - EVP_PKEY *privkey = NULL; - X509 *cert = NULL; - int ret, err; - char *arg = NULL; - - voms_info = VOMS_Init(vomsdir, cadir); - if (voms_info == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot initialize VOMS context (VOMS_Init() failed)"); - return EDG_WLPR_ERROR_VOMS; - } - - ret = load_proxy(old_proxy, &cert, &privkey, &chain); - if (ret) - goto end; - - ret = VOMS_Retrieve(cert, chain, RECURSE_CHAIN, voms_info, &err); - if (ret == 0) { - if (err == VERR_NOEXT) { - /* no VOMS cred, no problem; continue */ - ret = 0; - } else { - edg_wlpr_Log(LOG_ERR, "Cannot get VOMS certificate(s) from proxy"); - ret = EDG_WLPR_ERROR_VOMS; - } - goto end; - } - - for (voms_cert = voms_info->data; voms_cert && *voms_cert; voms_cert++) { - ret = set_vo_params(voms_cert, &arg); - if (ret) - goto end; - } - ret = exec_voms_proxy_init(arg, myproxy_proxy, new_proxy); - -end: - VOMS_Destroy(voms_info); - return ret; -} -#endif /* NOVOMS */ - -#endif /* 0 */ - -static void -register_signal(int signal) -{ - received_signal = signal; -} - -static int -renew_proxy(proxy_record *record, char *basename, char **new_proxy) -{ - char tmp_proxy[FILENAME_MAX]; - int tmp_fd; - char repository_file[FILENAME_MAX]; - int ret = -1; - char *p; - char *server = NULL; - myproxy_socket_attrs_t *socket_attrs; - myproxy_request_t *client_request; - myproxy_response_t *server_response; - char *renewed_proxy; - - socket_attrs = malloc(sizeof(*socket_attrs)); - memset(socket_attrs, 0, sizeof(*socket_attrs)); - - client_request = malloc(sizeof(*client_request)); - memset(client_request, 0, sizeof(*client_request)); - - server_response = malloc(sizeof(*server_response)); - memset(server_response, 0, sizeof(*server_response)); - - myproxy_set_delegation_defaults(socket_attrs, client_request); - - edg_wlpr_Log(LOG_DEBUG, "Trying to renew proxy in %s.%d", - basename, record->suffix); - - snprintf(tmp_proxy, sizeof(tmp_proxy), "%s.%d.renew.XXXXXX", - basename, record->suffix); - tmp_fd = mkstemp(tmp_proxy); - if (tmp_fd == -1) { - edg_wlpr_Log(LOG_ERR, "Cannot create temporary file (%s)", - strerror(errno)); - return errno; - } - - snprintf(repository_file, sizeof(repository_file),"%s.%d", - basename, record->suffix); - - ret = get_proxy_base_name(repository_file, &client_request->username); - if (ret) - goto end; - - client_request->proxy_lifetime = 60 * 60 * DGPR_RETRIEVE_DEFAULT_HOURS; - client_request->authzcreds = repository_file; - - server = (record->myproxy_server) ? record->myproxy_server : - socket_attrs->pshost; - if (server == NULL) { - edg_wlpr_Log(LOG_ERR, "No myproxy server specified"); - ret = EINVAL; - goto end; - } - socket_attrs->pshost = strdup(server); - - p = strchr(socket_attrs->pshost, ':'); - if (p) { - *p++ = '\0'; - ret = edg_wlpr_DecodeInt(p, &socket_attrs->psport); - if (ret) - goto end; - } else - socket_attrs->psport = MYPROXY_SERVER_PORT; - - ret = myproxy_get_delegation(socket_attrs, client_request, - server_response, tmp_proxy); - if (ret == 1) { - ret = EDG_WLPR_ERROR_MYPROXY; - edg_wlpr_Log(LOG_ERR, "Cannot get renewed proxy from Myproxy server"); - goto end; - } - - renewed_proxy = tmp_proxy; - - if (voms_enabled) { - char tmp_voms_proxy[FILENAME_MAX]; - int tmp_voms_fd; - - snprintf(tmp_voms_proxy, sizeof(tmp_voms_proxy), "%s.%d.renew.XXXXXX", - basename, record->suffix); - tmp_voms_fd = mkstemp(tmp_voms_proxy); - if (tmp_voms_fd == -1) { - edg_wlpr_Log(LOG_ERR, "Cannot create temporary file (%s)", - strerror(errno)); - ret = errno; - goto end; - } - - ret = renew_voms_certs(repository_file, tmp_proxy, tmp_voms_proxy); - if (ret) - goto end; - - renewed_proxy = tmp_voms_proxy; - } - - if (new_proxy) - *new_proxy = strdup(renewed_proxy); - - ret = 0; - -end: - if (socket_attrs->socket_fd) - close(socket_attrs->socket_fd); - close(tmp_fd); - if (ret) - unlink(tmp_proxy); - myproxy_free(socket_attrs, client_request, server_response); - - return ret; -} - -static void -check_renewal(char *datafile, int force_renew) -{ - char line[1024]; - proxy_record record; - char *p; - int ret, i; - time_t current_time; - FILE *meta_fd = NULL; - char basename[FILENAME_MAX]; - edg_wlpr_Request request; - edg_wlpr_Response response; - char *new_proxy = NULL; - char *entry = NULL; - char **tmp; - int num = 0; - - assert(datafile != NULL); - - memset(&record, 0, sizeof(record)); - memset(basename, 0, sizeof(basename)); - memset(&request, 0, sizeof(request)); - memset(&response, 0, sizeof(response)); - - strncpy(basename, datafile, sizeof(basename) - 1); - p = basename + strlen(basename) - strlen(".data"); - if (strcmp(p, ".data") != 0) { - edg_wlpr_Log(LOG_ERR, "Meta filename doesn't end with '.data'"); - return; - } - *p = '\0'; - - request.command = EDG_WLPR_COMMAND_UPDATE_DB; - request.proxy_filename = strdup(basename); - - meta_fd = fopen(datafile, "r"); - if (meta_fd == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot open meta file %s (%s)", - datafile, strerror(errno)); - return; - } - - current_time = time(NULL); - edg_wlpr_Log(LOG_DEBUG, "Reading metafile %s", datafile); - - while (fgets(line, sizeof(line), meta_fd) != NULL) { - free_record(&record); - p = strchr(line, '\n'); - if (p) - *p = '\0'; - ret = decode_record(line, &record); - if (ret) - continue; /* XXX exit? */ - if (record.jobids.len == 0) /* no jobid registered for this proxy */ - continue; - if (record.end_time - current_time < RENEWAL_CLOCK_SKEW || - abs(record.next_renewal - current_time) < RENEWAL_CLOCK_SKEW || - record.next_renewal < current_time || - record.end_time < current_time || - force_renew) { - ret = EDG_WLPR_PROXY_EXPIRED; - if (record.end_time >= current_time) - /* only try renewal if the proxy hasn't already expired */ - ret = renew_proxy(&record, basename, &new_proxy); - - /* if the proxy wasn't renewed have the daemon planned another renewal */ - asprintf(&entry, "%d:%s", record.suffix, (ret == 0) ? new_proxy : ""); - if (new_proxy) { - free(new_proxy); new_proxy = NULL; - } - - tmp = realloc(request.entries, (num + 2) * sizeof(*tmp)); - if (tmp == NULL) { - free_record(&record); - return; - } - request.entries = tmp; - request.entries[num] = entry; - request.entries[num+1] = NULL; - num++; - } - } - free_record(&record); - - if (num > 0) { - ret = edg_wlpr_RequestSend(&request, &response); - if (ret != 0) - edg_wlpr_Log(LOG_ERR, - "Failed to send update request to master (%d)", ret); - else if (response.response_code != 0) - edg_wlpr_Log(LOG_ERR, - "Master failed to update database (%d)", response.response_code); - - /* delete all tmp proxy files which may survive */ - for (i = 0; i < num; i++) { - p = strchr(request.entries[i], ':'); - if (p+1) - unlink(p+1); - } - } - fclose(meta_fd); - - edg_wlpr_CleanResponse(&response); - edg_wlpr_CleanRequest(&request); - - return; -} - -int renewal(int force_renew) -{ - DIR *dir = NULL; - struct dirent *file; - FILE *fd; - - edg_wlpr_Log(LOG_DEBUG, "Starting renewal process"); - - if (chdir(repository)) { - edg_wlpr_Log(LOG_ERR, "Cannot access repository directory %s (%s)", - repository, strerror(errno)); - return errno; - } - - dir = opendir(repository); - if (dir == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot open repository directory %s (%s)", - repository, strerror(errno)); - return errno; - } - - while ((file = readdir(dir))) { - /* read files of format `md5sum`.data, where md5sum() is of fixed length - 32 chars */ - if (file->d_name == NULL || strlen(file->d_name) != 37 || - strcmp(file->d_name + 32, ".data") != 0) - continue; - fd = fopen(file->d_name, "r"); - if (fd == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot open meta file %s (%s)", - file->d_name, strerror(errno)); - continue; - } - check_renewal(file->d_name, force_renew); - fclose(fd); - } - closedir(dir); - edg_wlpr_Log(LOG_DEBUG, "Finishing renewal process"); - return 0; -} - -void -watchdog_start(void) -{ - struct sigaction sa; - int force_renewal; - - memset(&sa,0,sizeof(sa)); - sa.sa_handler = register_signal; - sigaction(SIGUSR1, &sa, NULL); - - /* load_vomses(); */ - - while (1) { - received_signal = -1; - sleep(60 * 5); - force_renewal = (received_signal == SIGUSR1) ? 1 : 0; - /* XXX uninstall signal handler ? */ - renewal(force_renewal); - } -} diff --git a/org.glite.security.proxyrenewal/src/renewal_locl.h b/org.glite.security.proxyrenewal/src/renewal_locl.h deleted file mode 100644 index 45317e3..0000000 --- a/org.glite.security.proxyrenewal/src/renewal_locl.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef RENEWAL_LOCL_H -#define RENEWAL_LOCL_H - -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "renewal.h" - -#define JDL_MYPROXY "Myproxy_server=" - -typedef enum { - EDG_WLPR_COMMAND_NONE = 0, - EDG_WLPR_COMMAND_REG = 1, - EDG_WLPR_COMMAND_UNREG, - EDG_WLPR_COMMAND_GET, - EDG_WLPR_COMMAND_LIST, - EDG_WLPR_COMMAND_STATUS, - EDG_WLPR_COMMAND_UPDATE_DB, -} edg_wlpr_Command; - -/* prefix neni nutny */ -#define EDG_WLPR_PROTO_VERSION "Version=" -#define EDG_WLPR_PROTO_COMMAND "Command=" -#define EDG_WLPR_PROTO_MYPROXY_SERVER "Myproxy_server=" -#define EDG_WLPR_PROTO_PROXY "Proxy_name=" -#define EDG_WLPR_PROTO_UNIQUE_PROXY "Unique=" /* XXX */ -#define EDG_WLPR_PROTO_JOBID "Jobid=" -#define EDG_WLPR_PROTO_ENTRY "Entry=" - -#define EDG_WLPR_PROTO_RESPONSE "Response=" /* XXX result ?? */ -#define EDG_WLPR_PROTO_START_TIME "Start_time=" -#define EDG_WLPR_PROTO_END_TIME "End_time=" -#define EDG_WLPR_PROTO_RENEWAL_TIME "Renewal_time=" /* XXX Next renewal ?? */ - -#define EDG_WLPR_MYPROXY_PORT 7512 - -#define EDG_WLPR_REPOSITORY_ROOT "/var/spool/edg-wl-renewd" - -#define EDG_WLPR_BUF_SIZE 4096 - -#define EDG_WLPR_VERSION "EDG Proxy Renewal 1.0" - -#define MAX_PROXIES 4 /* max. number of jobids sharing one proxy */ - -typedef struct { - char *version; - edg_wlpr_Command command; - char *myproxy_server; - char *proxy_filename; - int unique; - char *jobid; - char **entries; /* for updates from the renewal part (renew.c) */ -} edg_wlpr_Request; - -typedef struct { - char *version; - int response_code; - time_t start_time; - time_t end_time; - time_t next_renewal_time; - int counter; - char *myproxy_server; - char **filenames; -} edg_wlpr_Response; - -#define DGPR_REG_SOCKET_NAME_ROOT "/tmp/dgpr_renew_" - -#if 0 -/* Errors: */ -/* XXX enum */ -#define EDG_WLPR_ERROR_EOF 1 -#define EDG_WLPR_ERROR_PARSE_NOT_FOUND 2 -#define EDG_WLPR_ERROR_PARSE_ERROR 3 -#define EDG_WLPR_ERROR_UNKNOWN_COMMAND 4 -#define EDG_WLPR_ERROR_NOTFOUND 5 -#endif - -int -edg_wlpr_GetToken(const char *msg, const size_t msg_len, - const char *key, const char *separators, - int req_index, char **value); - -int -edg_wlpr_StoreToken(char **buf, size_t *buf_len, char *command, - char *value, const char *separator); - -int -edg_wlpr_Read(int sock, char **buf, size_t *buf_len); - -int -edg_wlpr_Write(int sock, char *buf, size_t buf_len); - -void -edg_wlpr_CleanRequest(edg_wlpr_Request *request); - -void -edg_wlpr_CleanResponse(edg_wlpr_Response *response); - -const char * -edg_wlpr_GetErrorString(int err); - -char * -edg_wlpr_EncodeInt(int num); /* long? time */ - -int -edg_wlpr_DecodeInt(char *str, int *num); - -int -edg_wlpr_RequestSend(edg_wlpr_Request *request, edg_wlpr_Response *response); - -#endif /* RENEWAL_LOCL_H */ diff --git a/org.glite.security.proxyrenewal/src/renewd.c b/org.glite.security.proxyrenewal/src/renewd.c deleted file mode 100644 index adebb09..0000000 --- a/org.glite.security.proxyrenewal/src/renewd.c +++ /dev/null @@ -1,709 +0,0 @@ -#include "renewal_locl.h" -#include "renewd_locl.h" - -static const char rcsid[] = "$Header$"; - -#define SEPARATORS "\n" -/* GRIDMANAGER_CHECKPROXY_INTERVAL + GRIDMANAGER_MINIMUM_PROXY_TIME */ -#define CONDOR_MINIMUM_PROXY_TIME (1800) - -int debug = 0; -char *repository = NULL; -time_t condor_limit = CONDOR_MINIMUM_PROXY_TIME; -char *cadir = NULL; -char *vomsdir = NULL; -int voms_enabled = 0; - -char *vomsconf = "/opt/edg/etc/vomses"; -#ifndef NOVOMS -struct vomses_records vomses; -#endif - -static struct option opts[] = { - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, 'v' }, - { "debug", no_argument, NULL, 'd' }, - { "repository", required_argument, NULL, 'r' }, - { "condor-limit", required_argument, NULL, 'c' }, - { "CAdir", required_argument, NULL, 'C' }, - { "VOMSdir", required_argument, NULL, 'V' }, - { "enable-voms", no_argument, NULL, 'A' }, - { "voms-config", required_argument, NULL, 'G' }, - { NULL, 0, NULL, 0 } -}; - -typedef struct { - edg_wlpr_Command code; - void (*handler) (edg_wlpr_Request *request, edg_wlpr_Response *response); -} command_table; - -static command_table commands[] = { - { EDG_WLPR_COMMAND_REG, register_proxy, }, - { EDG_WLPR_COMMAND_UNREG, unregister_proxy, }, - { EDG_WLPR_COMMAND_GET, get_proxy, }, -#if 0 - { EDG_WLPR_COMMAND_LIST, list_proxies, }, - { EDG_WLPR_COMMAND_STATUS, status_proxy, }, -#endif - { EDG_WLPR_COMMAND_UPDATE_DB, update_db, }, - { 0, NULL }, -}; - -/* static prototypes */ -static void -usage(char *progname); - -static int -do_listen(char *socket_name, int *sock); - -static int -encode_response(edg_wlpr_Response *response, char **msg); - -static command_table * -find_command(edg_wlpr_Command code); - -static int -proto(int sock); - -static int -doit(int sock); - -static int -decode_request(const char *msg, const size_t msg_len, edg_wlpr_Request *request); - -static command_table * -find_command(edg_wlpr_Command code) -{ - command_table *c; - - for (c = commands; c->code; c++) { - if (c->code == code) - return c; - } - return NULL; -} - -static int -proto(int sock) -{ - char *buf = NULL; - size_t buf_len; - int ret; - edg_wlpr_Response response; - edg_wlpr_Request request; - command_table *command; - - memset(&request, 0, sizeof(request)); - memset(&response, 0, sizeof(response)); - - ret = edg_wlpr_Read(sock, &buf, &buf_len); - if (ret) { - edg_wlpr_Log(LOG_ERR, "Error reading from client: %s", - edg_wlpr_GetErrorString(ret)); - return ret; - } - - ret = decode_request(buf, buf_len, &request); - free(buf); - if (ret) - goto end; - - /* XXX check request (protocol version, ...) */ - - command = find_command(request.command); - if (command == NULL) { - ret = EDG_WLPR_ERROR_UNKNOWN_COMMAND; - edg_wlpr_Log(LOG_ERR, "Received unknown command (%d)", request.command); - goto end; - } - - edg_wlpr_Log(LOG_INFO, "Received command code %d for proxy %s", - request.command, - request.proxy_filename ? request.proxy_filename : "(unspecified)"); - - command->handler(&request, &response); - - ret = encode_response(&response, &buf); - if (ret) - goto end; - - ret = edg_wlpr_Write(sock, buf, strlen(buf) + 1); - free(buf); - if (ret) { - edg_wlpr_Log(LOG_ERR, "Error sending response to client: %s", - edg_wlpr_GetErrorString(ret)); - goto end; - } - -end: - edg_wlpr_CleanRequest(&request); - edg_wlpr_CleanResponse(&response); - - return ret; -} - -static int -doit(int sock) -{ - int newsock; - struct sockaddr_un client_addr; - int client_addr_len = sizeof(client_addr); -#if 0 - next_renewal = LONG_MAX; - size_of_proxies = PROXIES_ALLOC_SIZE; - proxies = malloc((size_of_proxies) * sizeof(struct guarded_proxy *)); - if (proxies == NULL) { - return ENOMEM; - } - proxies[0] = NULL; -#endif - -#if 0 - sigemptyset(&sset); - sigaddset(&sset,SIGTERM); - sigaddset(&sset,SIGINT); - sigaddset(&sset, SIGKILL); - sigaddset(&sset, SIGUSR1); - sigaddset(&sset, SIGALRM); - sigprocmask(SIG_BLOCK,&sset,NULL); -#endif - - while (1) { -#if 0 - sigprocmask(SIG_UNBLOCK,&sset,NULL); - newsock = accept(sock, (struct sockaddr *) &client_addr, &client_addr_len); - sigprocmask(SIG_BLOCK,&sset,NULL); - - if (newsock == -1) { - if (errno == EINTR) /* ERESTARTSYS */ - proxy_renewal(received_signal); - else - log(); - continue; - } -#else - newsock = accept(sock, (struct sockaddr *) &client_addr, &client_addr_len); - if (newsock == -1) { - edg_wlpr_Log(LOG_ERR, "accept() failed"); - continue; - } - edg_wlpr_Log(LOG_DEBUG, "Got connection"); - -#endif - - proto(newsock); - - edg_wlpr_Log(LOG_DEBUG, "Connection closed"); - close(newsock); - } -} - -static int -decode_request(const char *msg, const size_t msg_len, edg_wlpr_Request *request) -{ - char *value = NULL; -#if 0 - char *p; - int port; -#endif - int ret; - int index; - - /* XXX add an ending zero '\0' */ - - assert(msg != NULL); - assert(request != NULL); - - memset(request, 0, sizeof(*request)); - - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_VERSION, SEPARATORS, - 0, &request->version); - if (ret) { - edg_wlpr_Log(LOG_ERR, "Protocol error reading protocol specification: %s", - edg_wlpr_GetErrorString(ret)); - return ret; - } - - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_COMMAND, SEPARATORS, - 0, &value); - if (ret) { - edg_wlpr_Log(LOG_ERR, "Protocol error reading command specification: %s", - edg_wlpr_GetErrorString(ret)); - goto err; - } - - ret = edg_wlpr_DecodeInt(value, (int *)(&request->command)); - if (ret) { - edg_wlpr_Log(LOG_ERR, "Received non-numeric command specification (%s)", - value); - free(value); - goto err; - } - free(value); - - if (find_command(request->command) == NULL) { - edg_wlpr_Log(LOG_ERR, "Received unknown command (%d)", request->command); - ret = EDG_WLPR_ERROR_UNKNOWN_COMMAND; - goto err; - } - - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_MYPROXY_SERVER, - SEPARATORS, 0, &request->myproxy_server); - if (ret && ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) { - edg_wlpr_Log(LOG_ERR, "Protocol error reading myproxy server specification: %s", - edg_wlpr_GetErrorString(ret)); - goto err; - } - -#if 0 - request->myproxy_port = EDG_WLPR_MYPROXY_PORT; /* ??? */ - if (request->myproxy_server && (p = strchr(request->myproxy_server, ':'))) { - *p = '\0'; - port = atol(p+1); /* XXX see myproxy for err check */ - request->myproxy_port = port; - } -#endif - - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_PROXY, SEPARATORS, - 0, &request->proxy_filename); - if (ret && ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) { - edg_wlpr_Log(LOG_ERR, "Protocol error reading proxy specification: %s", - edg_wlpr_GetErrorString(ret)); - goto err; - } - -#if 0 - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_UNIQUE_PROXY, - SEPARATORS, 0, &value); - if (ret && ret != EDG_WLPR_ERROR_PARSE_NOT_FOUND) - goto err; - if (ret == 0 && strcasecmp(value, "yes") == 0) - request->unique = 1; - free(value); -#endif - - ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_JOBID, SEPARATORS, - 0, &request->jobid); - if (ret && ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) { - edg_wlpr_Log(LOG_ERR, "Protocol error reading JobId : %s", - edg_wlpr_GetErrorString(ret)); - goto err; - } - - index = 0; - while ((ret = edg_wlpr_GetToken(msg, msg_len, EDG_WLPR_PROTO_ENTRY, - SEPARATORS, index, &value)) == 0) { - char **tmp; - - tmp = realloc(request->entries, (index + 2) * sizeof(*tmp)); - if (tmp == NULL) { - ret = ENOMEM; - goto err; - } - request->entries = tmp; - request->entries[index] = value; - index++; - } - if (ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) - goto err; - if (request->entries) - request->entries[index] = NULL; - - return 0; - -err: - edg_wlpr_CleanRequest(request); - return ret; -} - -static int -encode_response(edg_wlpr_Response *response, char **msg) -{ - char *buf; - size_t buf_len; - int ret; - - buf_len = EDG_WLPR_BUF_SIZE; - buf = malloc(buf_len); - if (buf == NULL) - return ENOMEM; - buf[0] = '\0'; - - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_VERSION, - EDG_WLPR_VERSION, SEPARATORS); - if (ret) - goto err; - - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_RESPONSE, - edg_wlpr_EncodeInt(response->response_code), - SEPARATORS); - if (ret) - goto err; - - if (response->myproxy_server) { - char host[1024]; - -#if 0 - snprintf(host, sizeof(host), "%s:%d", response->myproxy_server, - (response->myproxy_port) ? response->myproxy_port : EDG_WLPR_MYPROXY_PORT); -#endif - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_MYPROXY_SERVER, - host, SEPARATORS); - if (ret) - goto err; - } - - if (response->start_time) { - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_START_TIME, - edg_wlpr_EncodeInt(response->start_time), - SEPARATORS); - if (ret) - goto err; - } - - if (response->end_time) { - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_END_TIME, - edg_wlpr_EncodeInt(response->end_time), - SEPARATORS); - if (ret) - goto err; - } - - if (response->next_renewal_time) { - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_RENEWAL_TIME, - edg_wlpr_EncodeInt(response->next_renewal_time), - SEPARATORS); - if (ret) - goto err; - } - - if (response->filenames) { - char **p = response->filenames; - while (*p) { - ret = edg_wlpr_StoreToken(&buf, &buf_len, EDG_WLPR_PROTO_PROXY, *p, - SEPARATORS); - if (ret) - goto err; - p++; - } - } - - buf[strlen(buf)] = '\0'; - *msg = buf; - return 0; - -err: - free(buf); - *msg = NULL; - return ret; -} - - -static void -usage(char *progname) -{ - fprintf(stderr,"usage: %s [option]\n" - "\t-h, --help display this help and exit\n" - "\t-v, --version output version information and exit\n" - "\t-d, --debug don't fork, print out debugging information\n" - "\t-r, --repository repository directory\n" - "\t-c, --condor-limit how long before expiration the proxy must be renewed\n" - "\t-C, --CAdir trusted certificates directory\n" - "\t-V, --VOMSdir trusted VOMS servers certificates directory\n" - "\t-A, --enable-voms renew also VOMS certificates in proxies\n" - "\t-G, --voms-config location of the vomses configuration file\n", - progname); -} - -static int -do_listen(char *socket_name, int *sock) -{ - struct sockaddr_un my_addr; - int s; - int ret; - - assert(sock != NULL); - - memset(&my_addr, 0, sizeof(my_addr)); - my_addr.sun_family = AF_UNIX; - strncpy(my_addr.sun_path, socket_name, sizeof(my_addr.sun_path)); - unlink(socket_name); - umask(0177); - - s = socket(AF_UNIX, SOCK_STREAM, 0); - if (s == -1) { - edg_wlpr_Log(LOG_ERR, "socket(): %s", strerror(errno)); - return errno; - } - - ret = bind(s, (struct sockaddr *)&my_addr, sizeof(my_addr)); - if (ret == -1) { - edg_wlpr_Log(LOG_ERR, "bind(): %s", strerror(errno)); - close(s); - return errno; - } - - ret = listen(s, 5); /* XXX enough ? */ - if (ret == -1) { - edg_wlpr_Log(LOG_ERR, "listen(): %s", strerror(errno)); - close(s); - return errno; - } - - *sock = s; - return 0; -} - -void -edg_wlpr_Log(int dbg_level, const char *format, ...) -{ - va_list ap; - char log_mess[1024]; - - /* cannot handle the %m format argument specific for syslog() */ - va_start(ap, format); - vsnprintf(log_mess, sizeof(log_mess), format, ap); - va_end(ap); - - if (debug) - printf("[%d] %s\n", getpid(), log_mess); - else - if (dbg_level < LOG_DEBUG) /* XXX make configurable */ - syslog(dbg_level, "%s", log_mess); -} - -int -start_watchdog(pid_t *pid) -{ - pid_t p; - - switch ((p = fork())) { - case -1: - edg_wlpr_Log(LOG_ERR, "fork() failed: %s", - strerror(errno)); - return errno; - case 0: - watchdog_start(); - exit(0); - break; - default: - *pid = p; - return 0; - } - /* not reachable */ - exit(0); -} - -#ifdef NOVOMS -static int -load_vomses() -{ - return ENOSYS; -} - -#else -static int -load_vomses() -{ - FILE *fd = NULL; - char line[1024]; - char *nick, *hostname; - int port; - vomses_record *rec; - vomses_record **tmp; - char *p; - - fd = fopen(vomsconf, "r"); - if (fd == NULL) { - edg_wlpr_Log(LOG_ERR, "Cannot open vomses configuration file (%s)", - strerror(errno)); - return errno; - } - while (fgets(line, sizeof(line), fd) != NULL) { - p = line; - if (*p != '"') { - edg_wlpr_Log(LOG_ERR, "Parsing error when reading vomses configuration file"); - return EINVAL; - } - nick = strdup(strtok(p+1, "\"")); - - p = strtok(NULL, "\""); - hostname = strdup(strtok(NULL, "\"")); - - p = strtok(NULL, "\""); - port = atoi(strdup(strtok(NULL, "\""))); - - if (nick == NULL || hostname == NULL) { - edg_wlpr_Log(LOG_ERR, "Parsing error when reading vomses configuration file"); - return EINVAL; - } - - rec = calloc(1, sizeof(*rec)); - if (rec == NULL) { - edg_wlpr_Log(LOG_ERR, "Not enough memory"); - return ENOMEM; - } - rec->nick = nick; - rec->hostname = hostname; - rec->port = port; - - tmp = realloc(vomses.val, vomses.len + 1); - if (tmp == NULL) { - edg_wlpr_Log(LOG_ERR, "Not enough memory"); - return ENOMEM; - } - vomses.val = tmp; - vomses.len++; - - vomses.val[vomses.len-1] = rec; - } - fclose(fd); - return 0; -} -#endif - -int main(int argc, char *argv[]) -{ - int sock; - char *progname; - int opt; - int fd; - char sockname[PATH_MAX]; - int ret; - pid_t pid; - - progname = strrchr(argv[0],'/'); - if (progname) progname++; - else progname = argv[0]; - - repository = EDG_WLPR_REPOSITORY_ROOT; - debug = 0; - - while ((opt = getopt_long(argc, argv, "hvdr:c:C:V:AG:", opts, NULL)) != EOF) - switch (opt) { - case 'h': usage(progname); exit(0); - case 'v': fprintf(stdout, "%s:\t%s\n", progname, rcsid); exit(0); - case 'd': debug = 1; break; - case 'r': repository = optarg; break; - case 'c': condor_limit = atoi(optarg); break; - case 'C': cadir = optarg; break; - case 'V': vomsdir = optarg; break; - case 'A': voms_enabled = 1; break; - case 'G': vomsconf = optarg; break; - case '?': usage(progname); return 1; - } - - if (optind < argc) { - usage(progname); - exit(1); - } - - if (chdir(repository)) { - edg_wlpr_Log(LOG_ERR, "Cannot access repository directory %s (%s)", - repository, strerror(errno)); - exit(1); - } - - globus_module_activate(GLOBUS_GSI_CERT_UTILS_MODULE); - - if (!debug) - for (fd = 3; fd < OPEN_MAX; fd++) close(fd); - - if (!debug) { - /* chdir ? */ - if (daemon(1,0) == -1) { - perror("deamon()"); - exit(1); - } - openlog(progname, LOG_PID, LOG_DAEMON); - } - - if (voms_enabled) { - char *path; - char *new_path; - ret = load_vomses(); - if (ret) - return 1; - setenv("GLOBUS_VERSION", "22", 0); - if (VOMS_INSTALL_PATH != NULL && *VOMS_INSTALL_PATH != '\0') { - path = getenv("PATH"); - asprintf(&new_path, "%s:%s/bin", path, VOMS_INSTALL_PATH); - setenv("PATH", new_path, 1); - } - } - - ret = start_watchdog(&pid); - if (ret) - return 1; - - umask(0177); - snprintf(sockname, sizeof(sockname), "%s%d", - DGPR_REG_SOCKET_NAME_ROOT, getuid()); - /* XXX check that the socket is not already active */ - ret = do_listen(sockname, &sock); - if (ret) - return 1; - edg_wlpr_Log(LOG_DEBUG, "Listening at %s", sockname); - -#if 0 - /* XXX ??? */ - install_handlers(); -#endif - - -#if 0 - /* XXX this overrides setings done by install_handlers()? */ - signal(SIGTERM, cleanup); - signal(SIGINT, cleanup); - signal(SIGKILL, cleanup); - signal(SIGPIPE, SIG_IGN); - - atexit(cleanup); -#endif - - ret = doit(sock); - - close(sock); - return ret; -} - -int -get_proxy_base_name(char *file, char **name) -{ - X509 *cert = NULL; - EVP_PKEY *key = NULL; - STACK_OF(X509) *chain = NULL; - X509_NAME *subject = NULL; - int ret; - - ret = load_proxy(file, &cert, &key, &chain); - if (ret) - return ret; - - subject = X509_NAME_dup(X509_get_subject_name(cert)); - - sk_X509_insert(chain, cert, 0); - cert = NULL; - - ret = globus_gsi_cert_utils_get_base_name(subject, chain); - if (ret) { - edg_wlpr_Log(LOG_ERR, "Cannot get subject name from proxy %s", file); - ret = EDG_WLPR_ERROR_SSL; /* XXX ??? */ - goto end; - } - - *name = X509_NAME_oneline(subject, NULL, 0); - ret = 0; - -end: - if (cert) - X509_free(cert); - if (key) - EVP_PKEY_free(key); - if (chain) - sk_X509_pop_free(chain, X509_free); - if (subject) - X509_NAME_free(subject); - - return ret; -} diff --git a/org.glite.security.proxyrenewal/src/renewd_locl.h b/org.glite.security.proxyrenewal/src/renewd_locl.h deleted file mode 100644 index 426c2ee..0000000 --- a/org.glite.security.proxyrenewal/src/renewd_locl.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef RENEWALD_LOCL_H -#define RENEWALD_LOCL_H - -#ident "$Header$" - -#include -#include -#include - -#include "renewal.h" - -#ifdef HAVE_DMALLOC_H -#include -#endif - -/* XXX */ -#if 0 -#define EDG_WLPR_ERROR_PARSE_NOT_FOUND EDG_WLPR_ERROR_PROTO_PARSE_ERROR -#define EDG_WLPR_ERROR_NOTFOUND EDG_WLPR_PROXY_NOT_REGISTERED -#endif - -typedef struct { - unsigned int len; - char **val; -} prd_list; - -typedef struct { - int suffix; - prd_list jobids; - int unique; - int voms_exts; - char *myproxy_server; - time_t end_time; - time_t next_renewal; -} proxy_record; - -typedef struct vomses_record { - char *nick; - char *hostname; - int port; -} vomses_record; - -typedef struct vomses_records { - unsigned int len; - struct vomses_record **val; -} vomses_records; - -/* commands */ -void -register_proxy(edg_wlpr_Request *request, edg_wlpr_Response *response); - -void -unregister_proxy(edg_wlpr_Request *request, edg_wlpr_Response *response); - -void -get_proxy(edg_wlpr_Request *request, edg_wlpr_Response *response); - -void -update_db(edg_wlpr_Request *request, edg_wlpr_Response *response); - -int -get_times(char *proxy_file, proxy_record *record); - -void -watchdog_start(void); - -void -edg_wlpr_Log(int dbg_level, const char *format, ...); - -int -decode_record(char *line, proxy_record *record); - -int -encode_record(proxy_record *record, char **line); - -void -free_record(proxy_record *record); - -int -load_proxy(const char *filename, X509 **cert, EVP_PKEY **privkey, - STACK_OF(X509) **chain); - -int -get_proxy_base_name(char *file, char **subject); - -#endif /* RENEWALD_LOCL_H */ diff --git a/org.glite.wms-utils.jobid/.cvsignore b/org.glite.wms-utils.jobid/.cvsignore deleted file mode 100755 index 1df717b..0000000 --- a/org.glite.wms-utils.jobid/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -.project -.cdtproject \ No newline at end of file diff --git a/org.glite.wms-utils.jobid/LICENSE b/org.glite.wms-utils.jobid/LICENSE deleted file mode 100755 index 01b973b..0000000 --- a/org.glite.wms-utils.jobid/LICENSE +++ /dev/null @@ -1,69 +0,0 @@ -LICENSE file for EGEE Middleware -================================ - -Copyright (c) 2004 on behalf of the EU EGEE Project: -The European Organization for Nuclear Research (CERN), -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Datamat Spa, Italy -Centre National de la Recherche Scientifique (CNRS), France -CS Systeme d'Information (CSSI), France -Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden -Universiteit van Amsterdam (UvA), Netherlands -University of Helsinki (UH.HIP), Finlan -University of Bergen (UiB), Norway -Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. The end-user documentation included with the redistribution, if -any, must include the following acknowledgment: "This product includes -software developed by The EU EGEE Project (http://cern.ch/eu-egee/)." -Alternatively, this acknowledgment may appear in the software itself, if -and wherever such third-party acknowledgments normally appear. - -4. The names EGEE and the EU EGEE Project must not be -used to endorse or promote products derived from this software without -prior written permission. For written permission, please contact -. - -5. You are under no obligation whatsoever to provide anyone with any -bug fixes, patches, or upgrades to the features, functionality or -performance of the Software ("Enhancements") that you may develop over -time; however, if you choose to provide your Enhancements to The EU -EGEE Project, or if you choose to otherwise publish or distribute your -Enhancements, in source code form without contemporaneously requiring -end users of The EU EGEE Proejct to enter into a separate written license -agreement for such Enhancements, then you hereby grant The EU EGEE Project -a non-exclusive, royalty-free perpetual license to install, use, copy, -modify, prepare derivative works, incorporate into the EGEE Middleware -or any other computer software, distribute, and sublicense your -Enhancements or derivative works thereof, in binary and source code -form (if any), whether developed by The EU EGEE Project or third parties. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL PROJECT OR ITS CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This software consists of voluntary contributions made by many -individuals on behalf of the EU EGEE Prject. For more information on The -EU EGEE Project, please see http://cern.ch/eu-egee/. For more information on -EGEE Middleware, please see http://egee-jra1.web.cern.ch/egee-jra1/ - - diff --git a/org.glite.wms-utils.jobid/Makefile.am b/org.glite.wms-utils.jobid/Makefile.am deleted file mode 100755 index bf956e1..0000000 --- a/org.glite.wms-utils.jobid/Makefile.am +++ /dev/null @@ -1,69 +0,0 @@ -## ********************************************************************* -## * -## * Copyright (c) 2002 CERN and INFN on behalf of the EU DataGrid. -## * For license conditions see LICENSE file or -## * http://www.edg.org/license.html -## * -## ********************************************************************* - -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = LICENSE - -docdir = $(datadir)/doc/@PACKAGE@-@VERSION@ -doc_DATA = LICENSE - -## Subdirectories list -SUBDIRS = interface src examples - -## Default flags to run aclocal -ACLOCAL_AMFLAGS = -I project - -stage: - @set fnord $(MAKEFLAGS); amf=$$2; \ - dot_seen=no; \ - target="install"; \ - prefix_arg="@prefix@"; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target $$prefix_arg in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target $$prefix_arg) \ - || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" $$prefix_arg || exit 1; \ - fi; test -z "$$fail" - -distsrc: dist - mv $(distdir).tar.gz $(DISTTAR)/$(distdir)_src.tar.gz - -distbin: - @set fnord $(MAKEFLAGS); amf=$$2; \ - dot_seen=no; \ - target="install"; \ - tmpdistbin="$(WORKDIR)/dist_bin"; \ - prefix_arg="prefix=$$tmpdistbin"; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target $$prefix_arg in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target $$prefix_arg) \ - || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" $$prefix_arg || exit 1; \ - fi; test -z "$$fail"; \ - pushd $$tmpdistbin; \ - $(AMTAR) -zcf $(DISTTAR)/$(distdir)_bin.tar.gz .; \ - popd; \ - rm -rf $$tmpdistbin - diff --git a/org.glite.wms-utils.jobid/bootstrap b/org.glite.wms-utils.jobid/bootstrap deleted file mode 100755 index ceeb099..0000000 --- a/org.glite.wms-utils.jobid/bootstrap +++ /dev/null @@ -1,9 +0,0 @@ -#! /bin/sh - -mkdir -p src/autogen -set -x -aclocal -I project -libtoolize --force -autoheader -automake --foreign --add-missing --copy -autoconf diff --git a/org.glite.wms-utils.jobid/build.xml b/org.glite.wms-utils.jobid/build.xml deleted file mode 100755 index 220b2a6..0000000 --- a/org.glite.wms-utils.jobid/build.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.wms-utils.jobid/configure.ac b/org.glite.wms-utils.jobid/configure.ac deleted file mode 100755 index 0f1deb4..0000000 --- a/org.glite.wms-utils.jobid/configure.ac +++ /dev/null @@ -1,128 +0,0 @@ -# -# Copyright (c) 2004 on behalf of the EU EGEE Project: -# The European Organization for Nuclear Research (CERN), -# Istituto Nazionale di Fisica Nucleare (INFN), Italy -# Datamat Spa, Italy -# Centre National de la Recherche Scientifique (CNRS), France -# CS Systeme d'Information (CSSI), France -# Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden -# Universiteit van Amsterdam (UvA), Netherlands -# University of Helsinki (UH.HIP), Finland -# University of Bergen (UiB), Norway -# Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom -# -# Common configure.ac file for the GLite WMS Common module -# -# Authors: Alberto Di Meglio -# Version info: $Id$ -# Release: $Name$ -# -# Revision history: -# $Log$ -# Revision 1.15 2004/11/16 15:35:22 eronchie -# Increased version -# -# Revision 1.14 2004/11/16 15:15:45 eronchie -# Increased version -# -# Revision 1.13 2004/09/22 00:25:17 glbuild -# Fixed missing parenthesis -# -# Revision 1.12 2004/09/21 19:22:09 glbuild -# modified module.version -# -# Revision 1.11 2004/08/17 13:46:28 eronchie -# Added interface -# -# Revision 1.10 2004/08/17 13:41:20 eronchie -# Moved out JobIdExceptions.h cjobid.h JobId.h -# Put in interface/glite/wmsutils/jobid -# -# Revision 1.9 2004/08/17 10:40:34 eronchie -# Added optimize option -# -# Revision 1.8 2004/07/27 09:14:19 eronchie -# Removed AC_WMSUTILS_EXCEPTION and AC_GLOBUS_SSL_UTILS checks -# Set directly exception library macro -# -# Revision 1.7 2004/07/21 17:53:36 eronchie -# Moved out org.glite.wms.jobid from org.glite.wms and put in org.glite.wms-utils -# -# -# - -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.57) -AC_INIT([GLite WMS Utils Jobid], [1.0.0]) -AC_CONFIG_AUX_DIR([./project]) -AM_INIT_AUTOMAKE([1.6.3 subdir-objects]) -AC_CONFIG_SRCDIR([src/jobid/strmd5.h]) - -# Notices. -AC_COPYRIGHT([Copyright (c) 2004 The EU EGEE Project -See LICENCE file for details -]) -AC_REVISION([$Revision$]) - -#Environment. -WORKDIR=`pwd` -AC_SUBST(WORKDIR) - -# Checks for programs. -AC_PROG_CC -AC_PROG_CPP -AC_PROG_CXX -AC_PROG_CXXCPP -AM_PROG_CC_C_O -AC_PROG_LIBTOOL - -# Checks for libraries. - -# Checks for header files. -AC_CHECK_HEADERS([fcntl.h mntent.h sys/vfs.h syslog.h unistd.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_HEADER_STDBOOL -AC_C_CONST -AC_C_INLINE -AC_TYPE_OFF_T -AC_TYPE_SIZE_T -AC_CHECK_MEMBERS([struct stat.st_rdev]) -AC_TYPE_UID_T -AC_CHECK_TYPES([ptrdiff_t]) - -# Checks for library functions. -AC_HEADER_STDC -AC_FUNC_ERROR_AT_LINE -AC_FUNC_GETMNTENT -AC_FUNC_MEMCMP -AC_FUNC_STAT -AC_FUNC_STRFTIME -AC_FUNC_VPRINTF -AC_CHECK_FUNCS([bzero endpwent ftruncate getmntent memset mkdir pow strerror strtol]) - -have_globus=no - -AC_GLOBUS([], have_globus=yes, have_globus=no) -AC_MSG_RESULT(["GLOBUS found $have_globus"]) - -have_glite_wmsutils_exception=no - -AC_GLITE - -GLITE_WMSUTILS_EXCEPTION_LIBS="-L$GLITE_LOCATION/lib -lglite_wmsutils_exception"AC_SUBST(GLITE_WMSUTILS_EXCEPTION_LIBS) - -AC_OPTIMIZE - -# Configuration items -AC_PREFIX_DEFAULT([/opt/glite]) -AM_CONFIG_HEADER([src/autogen/config.h]) -AC_CONFIG_FILES([Makefile]) -AC_CONFIG_FILES([examples/Makefile]) -AC_CONFIG_FILES([interface/Makefile]) -AC_CONFIG_FILES([src/Makefile]) -AC_CONFIG_FILES([src/jobid/Makefile]) - -AC_OUTPUT - diff --git a/org.glite.wms-utils.jobid/examples/Makefile.am b/org.glite.wms-utils.jobid/examples/Makefile.am deleted file mode 100755 index fa9a407..0000000 --- a/org.glite.wms-utils.jobid/examples/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -## ********************************************************************* -## * -## * Copyright (c) 2002 CERN and INFN on behalf of the EU DataGrid. -## * For license conditions see LICENSE file or -## * http://www.edg.org/license.html -## * -## ********************************************************************* - -STDCPP = -lstdc++ - -JOBID = $(top_builddir)/src/jobid/libglite_wmsutils_cjobid.la - -check_PROGRAMS = testjobid - -testjobid_SOURCES = testjobid.c -testjobid_LDADD = \ - $(JOBID) \ - $(GLITE_WMSUTILS_EXCEPTION_LIBS) \ - $(GLOBUS_SSL_THR_LIBS) \ - $(STDCPP) - -AM_CPPFLAGS = -I$(top_srcdir)/src \ - -I$(top_srcdir)/interface \ - $(GLITE_CFLAGS) \ - $(GLOBUS_THR_CFLAGS) - -MAINTAINERCLEANFILES = Makefile.in *~ - diff --git a/org.glite.wms-utils.jobid/examples/testjobid.c b/org.glite.wms-utils.jobid/examples/testjobid.c deleted file mode 100755 index 56f6cba..0000000 --- a/org.glite.wms-utils.jobid/examples/testjobid.c +++ /dev/null @@ -1,33 +0,0 @@ -/* test code for jobid routines */ - -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" - -int main(int argc, char* argv[]) -{ - char* ju; - char* bkserver = "ujsa.uhjs"; - - edg_wlc_JobId ji = 0; - edg_wlc_JobId ji2 = 0; - - int r = edg_wlc_JobIdCreate(bkserver, 0, &ji); - printf("Create: %d\n", r); - - ju = edg_wlc_JobIdUnparse(ji); - printf("Unparse: %s\n", ju); - - edg_wlc_JobIdParse(ju, &ji2); - free(ju); - - ju = edg_wlc_JobIdUnparse(ji); - printf("Unparse2: %s\n", ju); - free(ju); - - edg_wlc_JobIdFree(ji); - edg_wlc_JobIdFree(ji2); - - return 0; -} diff --git a/org.glite.wms-utils.jobid/interface/Makefile.am b/org.glite.wms-utils.jobid/interface/Makefile.am deleted file mode 100755 index 8737f19..0000000 --- a/org.glite.wms-utils.jobid/interface/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -## ********************************************************************* -## * -## * Copyright (c) 2002 CERN and INFN on behalf of the EU DataGrid. -## * For license conditions see LICENSE file or -## * http://www.edg.org/license.html -## * -## ********************************************************************* - -jobiddir = $(includedir) -nobase_jobid_HEADERS = \ - glite/wmsutils/jobid/cjobid.h \ - glite/wmsutils/jobid/manipulation.h \ - glite/wmsutils/jobid/JobIdExceptions.h \ - glite/wmsutils/jobid/JobId.h - -MAINTAINERCLEANFILES = Makefile.in diff --git a/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/JobId.h b/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/JobId.h deleted file mode 100755 index f7c1bb5..0000000 --- a/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/JobId.h +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef GLITE_WMSUTILS_JOBID_JOBID_H -#define GLITE_WMSUTILS_JOBID_JOBID_H - -/* - * JobId.h - * Copyright (c) 2001 The European Datagrid Project - IST programme, all rights reserved. - * - */ - -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" - -typedef struct _edg_wlc_jobid_s* edg_wlc_jobid_t; - -namespace glite { -namespace wmsutils { -namespace jobid { - -/** - * Managing Identification, checking, retreiving info from a job - * File name: JobId.h - * The JobId class provides a representation of the Datagrid job identifier - * (dg_jobId) and the methods for manipulating it. - * We remind that the format of the dg_jobId is as follows: - * :/ - * - * @ingroup common - * @version 0.1 - * @date 15 April 2002 - * @author Alessandro Maraschini */ - -class JobId { -public: - /**@name Constructors/Destructor */ - //@{ - /** Instantiates an empty JobId object */ - JobId() ; - /** - * Instantiates a JobId object from the passed dg_jobId in string format. - * @param job_id_string a string representig a classAd expression - * @throws WrongIdException When a string is passed in a wrong format - */ - JobId(const std::string& job_id_string ) ; - JobId(const JobId&); - JobId(const edg_wlc_JobId&); - /** - * Destructor - * Destroy the Job Id instance - */ - ~JobId() ; - //@} - - /**@name Miscellaneous */ - //@{ - /** Unsets the JobId instance. Clear all it's memebers */ - void clear() ; - /** - * Check wheater the jobId has been already created (true) or not (false) - *@return true (jobId created) or false (jobId not yet created) - */ - bool isSet() { return ( m_JobId != 0 ) ; } - /** - * Set the JobId instance according to the LB and RB server addresses and the unique string passed as input parameters. - * @param lb_server Loggin and Bookkeeping server address - * @param port Loggin and Bookkeeping port ( dafault value is 9000 ) - * @param unique A Unique identification ( automatically generatad by md5 protocol ) - * @throws WrongIdException When one parameter has been passed in a wrong format */ - void setJobId(const std::string& lb_server, int port = 0, const std::string& unique = ""); - //@} - /**@name Get Methods */ - //@{ - /** @return the LB address into its string format - * @throws EmptyIdException If the jobId has not been initialised yet */ - std::string getServer() const; - /** @return the Unique string into its string format - * @throws EmptyIdException If the jobId has not been initialised yet */ - std::string getUnique() const; - //@} - /** This method sets the JobId instance from the JobId in string format given - * as input. - * @param dg_JobId the string representing the job - * @throws WrongIdException When a string is passed in a wrong format */ - void fromString ( const std::string& dg_JobId ); - /** Converts the jobId into a string - @return the string representation of a JobId*/ - std::string toString() const; - operator const edg_wlc_JobId() const { return m_JobId; } - JobId & operator=(JobId const &); - JobId & operator=(const edg_wlc_JobId &); - edg_wlc_JobId getId() const ; -private: - // This Variable stores the Job unique identification String - edg_wlc_JobId m_JobId; - mutable char* m_pStr; - mutable char* m_pBkserver; - mutable char* m_pUnique; - - friend bool operator<(JobId const& lhs, JobId const& rhs); - friend bool operator==(JobId const& lhs, JobId const& rhs); -}; - -inline bool operator<(JobId const& lhs, JobId const& rhs) -{ - return strcmp ( lhs.m_pStr , rhs.m_pStr ) <0 ; -} - -inline bool operator==(JobId const& lhs, JobId const& rhs) -{ -return strcmp ( lhs.m_pStr , rhs.m_pStr ) ==0 ; -} - -std::ostream& operator<<(std::ostream& os, JobId const& id); - -} // namespace jobid -} // namespace wmsutils -} // namespace glite - -#endif // GLITE_WMSUTILS_JOBID_JOBID_H diff --git a/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/JobIdExceptions.h b/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/JobIdExceptions.h deleted file mode 100755 index 42cbdf4..0000000 --- a/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/JobIdExceptions.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef GLITE_WMSUTILS_JOBID_EXCEPTIONS_H -#define GLITE_WMSUTILS_JOBID_EXCEPTIONS_H - -/* - * JobIdExceptions.h - * Copyright (c) 2001 The European Datagrid Project - IST programme, all rights reserved. - */ - -#include "glite/wmsutils/exception/Exception.h" - -namespace glite { -namespace wmsutils { -namespace jobid { - -/** - * JobIdException - Exception thrown by JobId Class - * @ingroup Common - * @version 0.1 - * @date 15 April 2002 - * @author Alessandro Maraschini -*/ - -class JobIdException : public glite::wmsutils::exception::Exception { -public: - /** - * Update all mandatory Exception Information - */ - JobIdException (const std::string& file, - int line, - const std::string& method, - int code, - const std::string& exception_name) ; -};//End CLass JobIdException - -/** -* WrongIdFieldException -* This Exception is thrown when a Job Id syntax error is found -* A valid Job Identification string should be made as follows: -* :/ */ -class WrongIdException : public JobIdException { -public: - /** - * Constructor - * @param file - The source file which has generated the Exception - * @param line - The line number in the source file where the Exception has been thrown - * @param method - The Name of the method which has thrown the Exception - * @param code - The Code of the Error raised - * @param field - The wrong expression catched */ - WrongIdException(const std::string& file, - int line, - const std::string& method, - int code ); -}; //End CLass WrongIdException -/** -* EmptyIdException -* This Exception is thrown when the user tries to get information from a JobId -* which has not been initialized yet, i.e tries to use the get Methods -*/ -class EmptyIdException : public JobIdException { -public: - /** - * Constructor - * @param file - The source file which has generated the Exception - * @param line - The line number in the source file where the Exception has been thrown - * @param method - The Name of the method which has thrown the Exception - * @param code - The Code of the Error raised - * @param field - The Empty filed requested for */ - EmptyIdException::EmptyIdException(const std::string& file, - int line, - const std::string& method, - int code , - const std::string& field ); -}; //End CLass EmptyIdException - -} // namespace jobid -} // namespace wmsutils -} // namespace glite - -#endif // GLITE_WMSUTILS_JOBID_EXCEPTIONS_H - diff --git a/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/cjobid.h b/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/cjobid.h deleted file mode 100755 index e8f84f5..0000000 --- a/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/cjobid.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef _GLITE_JOBID_H -#define _GLITE_JOBID_H - -/*! - * \file cjobid.h - * \brief L&B consumer API - */ - -#ident "$Header$" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _edg_wlc_JobId *edg_wlc_JobId; - -#define GLITE_WMSC_JOBID_DEFAULT_PORT 9000 /**< Default port where bookkeeping server listens */ -#define GLITE_WMSC_JOBID_PROTO_PREFIX "https://" /**< JobId protocol prefix */ - - -/* All the pointer functions return malloc'ed objects (or NULL on error) */ - -/** - * Create a Job ID. - * See the lb_draft document for details on its construction and components - * \param bkserver book keeping server hostname - * \param port port for the bk service - * \param jobid new created job id - * \ret al 0 success - * \retval EINVAL invalid bkserver - * \retval ENOMEM if memory allocation fails - */ -int edg_wlc_JobIdCreate(const char * bkserver, int port, edg_wlc_JobId * jobid); - -/** - * Recreate a Job ID - * \param bkserver bookkeeping server hostname - * \param port port for the bk service - * \param unique string which represent created jobid (if NULL then new - * one is created) - * \param jobid new created job id - * \retval 0 success - * \retval EINVAL invalid bkserver - * \retval ENOMEM if memory allocation fails - */ -int edg_wlc_JobIdRecreate(const char *bkserver, int port, const char * unique, edg_wlc_JobId * jobid); - -/** - * Create copy of Job ID - * \param in jobid for duplication - * \param jobid duplicated jobid - * \retval 0 for success - * \retval EINVAL invalid jobid - * \retval ENOMEM if memory allocation fails - */ -int edg_wlc_JobIdDup(const edg_wlc_JobId in, edg_wlc_JobId * jobid); - -/* - * Free jobid structure - * \param jobid for dealocation - */ -void edg_wlc_JobIdFree(edg_wlc_JobId jobid); - -/** - * Parse Job ID string and creates jobid structure - * \param jobidstr string representation of jobid - * \param jobid parsed job id - * \retval 0 for success - * \retval EINVAL jobidstr can't be parsed - * \retval ENOMEM if memory allocation fails - */ -int edg_wlc_JobIdParse(const char* jobidstr, edg_wlc_JobId * jobid); - -/** - * Unparse Job ID (produce the string form of JobId). - * \param jobid to be converted to string - * \return allocated string which represents jobid - */ -char* edg_wlc_JobIdUnparse(const edg_wlc_JobId jobid); - -/** - * Extract bookkeeping server address (address:port) - * \param jobid from which the bkserver address should be extracted - * \retval pointer to allocated string with bkserver address - * \retval NULL if jobid is 0 or memory allocation fails - */ -char* edg_wlc_JobIdGetServer(const edg_wlc_JobId jobid); - -/** - * Extract bookkeeping server address and port - * \param jobid from which the bkserver address should be extracted - * \param srvName pointer where to return server name - * \param srvPort pointer where to return server port - * */ -void edg_wlc_JobIdGetServerParts(const edg_wlc_JobId jobid, char **srvName, unsigned int *srvPort); - -/** - * Extract unique string - * \param jobid - * \retval pointer to allocated unique string representing jobid - * \retval NULL if jobid is 0 or memory allocation fails - */ -char* edg_wlc_JobIdGetUnique(const edg_wlc_JobId jobid); - -#ifdef __cplusplus -} -#endif - -#endif /* _GLITE_JOBID_H */ diff --git a/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/manipulation.h b/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/manipulation.h deleted file mode 100755 index 9f862ae..0000000 --- a/org.glite.wms-utils.jobid/interface/glite/wmsutils/jobid/manipulation.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef GLITE_WMSUTILS_JOBID_MANIPULATION_H -#define GLITE_WMSUTILS_JOBID_MANIPULATION_H - -#include - -namespace glite { -namespace wmsutils { -namespace jobid { - -class JobId; - -std::string get_reduced_part( const JobId &id, int level = 0 ); -std::string to_filename( const JobId &id ); -JobId from_filename( const std::string &filename ); - -} // namespace jobid -} // namespace wmsutils -} // namespace glite - -#endif /* GLITE_WMSUTILS_JOBID_MANIPULATION_H */ - -// Local Variables: -// mode: c++ -// End: diff --git a/org.glite.wms-utils.jobid/project/build.properties b/org.glite.wms-utils.jobid/project/build.properties deleted file mode 100755 index e69de29..0000000 diff --git a/org.glite.wms-utils.jobid/project/configure.properties.xml b/org.glite.wms-utils.jobid/project/configure.properties.xml deleted file mode 100644 index 04d3b17..0000000 --- a/org.glite.wms-utils.jobid/project/configure.properties.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/org.glite.wms-utils.jobid/project/properties.xml b/org.glite.wms-utils.jobid/project/properties.xml deleted file mode 100755 index 9662658..0000000 --- a/org.glite.wms-utils.jobid/project/properties.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.glite.wms-utils.jobid/project/version.properties b/org.glite.wms-utils.jobid/project/version.properties deleted file mode 100755 index 96c7c6b..0000000 --- a/org.glite.wms-utils.jobid/project/version.properties +++ /dev/null @@ -1,3 +0,0 @@ -module.version=1.0.0 -module.build=103 -module.age=1 diff --git a/org.glite.wms-utils.jobid/src/Makefile.am b/org.glite.wms-utils.jobid/src/Makefile.am deleted file mode 100755 index 5225c64..0000000 --- a/org.glite.wms-utils.jobid/src/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -## ********************************************************************* -## * -## * Copyright (c) 2002 CERN and INFN on behalf of the EU DataGrid. -## * For license conditions see LICENSE file or -## * http://www.edg.org/license.html -## * -## ********************************************************************* - -## Subdirectories list -SUBDIRS = jobid - -MAINTAINERCLEANFILES = Makefile.in diff --git a/org.glite.wms-utils.jobid/src/jobid/JobId.cpp b/org.glite.wms-utils.jobid/src/jobid/JobId.cpp deleted file mode 100755 index 273f9f9..0000000 --- a/org.glite.wms-utils.jobid/src/jobid/JobId.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* ************************************************************************** - * filename : JobId.cpp - * author : Alessandro Maraschini - * copyright : (C) 2002 by DATAMAT - ***************************************************************************/ - -#include "glite/wmsutils/jobid/JobId.h" - -#include - -#include "glite/wmsutils/jobid/JobIdExceptions.h" - -namespace glite { -namespace wmsutils { -namespace jobid { - -using namespace std ; - -/****************************************************************** - Constructor / Destructor - *******************************************************************/ -JobId::JobId() : m_JobId( 0 ), m_pStr( 0 ), m_pBkserver( 0 ), m_pUnique( 0 ) -{ -} - -JobId::JobId(const std::string& job_id_string ) - : m_JobId( 0 ), m_pStr( 0 ), m_pBkserver( 0 ), m_pUnique( 0 ) -{ - fromString( job_id_string ) ; -} - -JobId::JobId(const JobId &old) -{ - edg_wlc_JobIdDup(old.m_JobId,&m_JobId); - m_pStr = old.m_pStr ? strdup(old.m_pStr) : 0; - m_pBkserver = old.m_pBkserver ? strdup(old.m_pBkserver) : 0; - m_pUnique = old.m_pUnique ? strdup(old.m_pUnique) : 0; -} - -JobId & JobId::operator=(JobId const &old) -{ - clear(); - edg_wlc_JobIdDup(old.m_JobId,&m_JobId); - m_pStr = old.m_pStr ? strdup(old.m_pStr) : 0; - m_pBkserver = old.m_pBkserver ? strdup(old.m_pBkserver) : 0; - m_pUnique = old.m_pUnique ? strdup(old.m_pUnique) : 0; - - return *this; -} - - -JobId::JobId(const edg_wlc_JobId &old) - : m_pStr(0), m_pBkserver(0), m_pUnique(0) -{ - edg_wlc_JobIdDup(old,&m_JobId); -} - - -JobId & JobId::operator=(const edg_wlc_JobId &old) -{ - clear(); - edg_wlc_JobIdDup(old,&m_JobId); - m_pStr = 0; - m_pBkserver = 0; - m_pUnique = 0; - return(*this); -} - -JobId::~JobId() -{ - clear(); -} - -/****************************************************************** - method : clear - unsets the JobId instance. - *******************************************************************/ -void JobId::clear() -{ - if ( m_JobId ) - { - edg_wlc_JobIdFree( m_JobId ); - m_JobId = 0; - if (m_pStr) - free(m_pStr); - if (m_pBkserver) - free(m_pBkserver); - if (m_pUnique) - free(m_pUnique); - m_pStr = m_pBkserver = m_pUnique = NULL; - } -} - - -/****************************************************************** - method : setJobId - sets the JobId instance according to the LB and RB - server addresses and the unique string passed as input parameters. - *******************************************************************/ -void JobId::setJobId(const string& bkserver, int port, const string& unique) -{ - int code = edg_wlc_JobIdRecreate(bkserver.c_str(), port, unique.size() ? unique.c_str() : NULL, &m_JobId) ; - if ( code != 0 ) - throw WrongIdException(__FILE__ , __LINE__ , "setJobId(const string& bkserver, int port, const string& unique)" , code ) ; -} - - -/****************************************************************** - Protected method : fromString - sets the JobId instance from the dg_jobId in string format given as input. - *******************************************************************/ -void JobId::fromString (const string& dg_JobId) -{ - clear(); - int code = edg_wlc_JobIdParse(dg_JobId.c_str(), &m_JobId) ; - if ( code != 0 ) - throw WrongIdException(__FILE__ , __LINE__ , "fromString (const string& dg_JobId)" , code ) ; -} - -/****************************************************************** - method : ToString - converts the JobId instance into its string format. - and put it in the dg_jobId output variable - *******************************************************************/ -std::string JobId::toString() const -{ - if ( m_JobId && !m_pStr ) - m_pStr = edg_wlc_JobIdUnparse(m_JobId) ; - if ( !m_pStr ) - throw EmptyIdException (__FILE__ , __LINE__ ,"toString()" ,ENOENT , "JobId") ; - return m_pStr; -} - -/****************************************************************** - method : getServer - return a string containing the LB server address, - *******************************************************************/ -std::string JobId::getServer() const -{ - if ( m_JobId && !m_pBkserver ) - m_pBkserver = edg_wlc_JobIdGetServer( m_JobId ) ; - - if ( !m_pBkserver ) - throw EmptyIdException (__FILE__ , __LINE__ , "getServer()", ENOENT , "LB server Address") ; - - return m_pBkserver; -} - -/****************************************************************** - method : getUnique - return a string containing unique jobid string - *******************************************************************/ -std::string JobId::getUnique() const -{ - if ( m_JobId && !m_pUnique ) - m_pUnique = edg_wlc_JobIdGetUnique( m_JobId ) ; - - if ( !m_pUnique ) - throw EmptyIdException (__FILE__ , __LINE__ , "getUnique()" , ENOENT , "Unique") ; - - return m_pUnique; -} -/****************************************************************** - method : getId - return the c JobId struct representing this instance - *******************************************************************/ -edg_wlc_JobId JobId::getId() const -{ - edg_wlc_JobId out ; - if ( edg_wlc_JobIdDup(m_JobId, &out) ) - throw EmptyIdException (__FILE__ , __LINE__ , "getId()" , ENOENT , "JobId") ; - return out ; -} - -std::ostream& -operator<<(std::ostream& os, JobId const& id) -{ - return os << id.toString(); -} - -} // namespace jobid -} // namespace wmsutils -} // namespace glite diff --git a/org.glite.wms-utils.jobid/src/jobid/JobIdExceptions.cpp b/org.glite.wms-utils.jobid/src/jobid/JobIdExceptions.cpp deleted file mode 100755 index 6be40b7..0000000 --- a/org.glite.wms-utils.jobid/src/jobid/JobIdExceptions.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* ************************************************************************** -* filename : JobIdExecptions.cpp -* author : Alessandro Maraschini -* copyright : (C) 2002 by DATAMAT -***************************************************************************/ - -#include "glite/wmsutils/jobid/JobIdExceptions.h" - -namespace glite { -namespace wmsutils { -namespace jobid { - -using namespace std; -using namespace glite::wmsutils::exception; - -/***************************** -* JobIdException -*****************************/ -JobIdException::JobIdException (const string& file, - int line, - const string& method, - int code, - const string& exception_name) - : Exception(file, line, method, code, exception_name) -{ -} - -/***************************** -* WrongIdException -*****************************/ -WrongIdException::WrongIdException(const string& file, - int line, - const string& method, - int code ) - : JobIdException(file, line, method, code, - "WrongIdException") -{ - error_message = "Wrong Field caught while parsing Job Id" ; -} - -/***************************** -* EmptyIdException -*****************************/ -EmptyIdException::EmptyIdException(const string& file, - int line, - const string& method, - int code , - const string& field ) - : JobIdException(file, line, method, code, - "EmptyIdException") -{ - error_message = "Unable to retrieve " + field + ": the instance has not been initialized yet"; -} - -} // namespace jobid -} // namespace wmsutils -} // namespace glite - diff --git a/org.glite.wms-utils.jobid/src/jobid/Makefile.am b/org.glite.wms-utils.jobid/src/jobid/Makefile.am deleted file mode 100755 index 7a23118..0000000 --- a/org.glite.wms-utils.jobid/src/jobid/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -## ********************************************************************* -## * -## * Copyright (c) 2002 CERN and INFN on behalf of the EU DataGrid. -## * For license conditions see LICENSE file or -## * http://www.edg.org/license.html -## * -## ********************************************************************* - -lib_LTLIBRARIES = libglite_wmsutils_jobid.la libglite_wmsutils_cjobid.la - -libglite_wmsutils_jobid_la_SOURCES = \ - JobId.cpp \ - JobIdExceptions.cpp \ - manipulation.cpp - -libglite_wmsutils_cjobid_la_SOURCES = \ - cjobid.c \ - strmd5.c - -jobidincludedir = $(includedir)/glite/wmsutils/jobid -jobidinclude_HEADERS = \ - strmd5.h - -AM_CPPFLAGS = -I$(top_srcdir)/src \ - -I$(top_srcdir)/interface \ - $(GLITE_CFLAGS) \ - $(GLOBUS_THR_CFLAGS) \ - -D_GNU_SOURCE - -MAINTAINERCLEANFILES = Makefile.in diff --git a/org.glite.wms-utils.jobid/src/jobid/cjobid.c b/org.glite.wms-utils.jobid/src/jobid/cjobid.c deleted file mode 100755 index 2fa0010..0000000 --- a/org.glite.wms-utils.jobid/src/jobid/cjobid.c +++ /dev/null @@ -1,258 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "strmd5.h" - -struct _edg_wlc_JobId { - char *id; /* unique job identification */ - /* additional information */ - char *BShost;/* bookkeeping server hostname */ - unsigned int BSport; /* bookkeeping server port */ - char *info; /* additional information (after ? in URI) */ -}; - -int edg_wlc_JobIdCreate(const char *bkserver, int port, edg_wlc_JobId *jobId) -{ - return edg_wlc_JobIdRecreate(bkserver, port, NULL, jobId); -} - - -int edg_wlc_JobIdRecreate(const char* bkserver, int port, const char *unique, edg_wlc_JobId *jobId) -{ - edg_wlc_JobId out; - char hostname[200]; /* used to hold string for encrypt */ - struct timeval tv; - int skip; - char* portbeg; - - struct hostent* he; - - if (!bkserver) - return EINVAL; - - if (unique == NULL) { - gethostname(hostname, 100); - he = gethostbyname(hostname); - assert(he->h_length > 0); - gettimeofday(&tv, NULL); - srandom(tv.tv_usec); - - skip = strlen(hostname); - skip += sprintf(hostname + skip, "-IP:0x%x-pid:%d-rnd:%d-time:%d:%d", - *((int*)he->h_addr_list[0]), getpid(), (int)random(), - (int)tv.tv_sec, (int)tv.tv_usec); - } - - *jobId = NULL; - out = (edg_wlc_JobId) malloc (sizeof(*out)); - if (!out) - return ENOMEM; - - memset(out, 0, sizeof(*out)); - - /* check if it begins with prefix */ - /* unsupported */ - if (strncmp(bkserver, GLITE_WMSC_JOBID_PROTO_PREFIX, sizeof(GLITE_WMSC_JOBID_PROTO_PREFIX)-1) == 0) - return EINVAL; - - out->BShost = strdup(bkserver); - portbeg = strchr(out->BShost, ':'); - if (portbeg) { - *portbeg = 0; - /* try to get port number */ - if (port == 0) - port = atoi(portbeg + 1); - } - - if (port == 0) - port = GLITE_WMSC_JOBID_DEFAULT_PORT; - - out->BSport = port; - - out->id = (unique) ? strdup(unique) : str2md5base64(hostname); - //printf("Encrypt: %s\nBASE64 %s\n", hostname, out->id); - - if (!out->id || !out->BShost) { - edg_wlc_JobIdFree(out); - return ENOMEM; - } - - *jobId = out; - return 0; -} - - -int edg_wlc_JobIdDup(const edg_wlc_JobId in, edg_wlc_JobId *out) -{ - edg_wlc_JobId jid; - *out = NULL; - if (in == NULL) - return 0; - - jid = malloc(sizeof(*jid)); - if (!jid) - return ENOMEM; - - memset(jid, 0,sizeof(*jid)); - jid->BShost = strdup(in->BShost); - jid->id = strdup(in->id); - if (in->info) - jid->info = strdup(in->info); - - if (jid->BShost == NULL || jid->id == NULL) { - edg_wlc_JobIdFree(jid); - return ENOMEM; - } - - jid->BSport = in->BSport; - *out = jid; - return 0; -} - - -// XXX -// use recreate -// parse name, port, unique -int edg_wlc_JobIdParse(const char *idString, edg_wlc_JobId *jobId) -{ - char *pom, *pom1, *pom2; - edg_wlc_JobId out; - - *jobId = NULL; - - out = (edg_wlc_JobId) malloc (sizeof(*out)); - if (out == NULL ) - return ENOMEM; - - memset(out,0,sizeof(*out)); - - if (strncmp(idString, GLITE_WMSC_JOBID_PROTO_PREFIX, sizeof(GLITE_WMSC_JOBID_PROTO_PREFIX) - 1)) { - out->BShost = (char *) NULL; - out->BSport = 0; - - free(out); - return EINVAL; - } - - pom = strdup(idString + sizeof(GLITE_WMSC_JOBID_PROTO_PREFIX) - 1); - pom1 = strchr(pom, '/'); - pom2 = strchr(pom, ':'); - - if (!pom1) { free(pom); free(out); return EINVAL; } - - if ( pom2 && (pom1 > pom2)) { - pom[pom2-pom] = '\0'; - out->BShost = strdup(pom); - pom[pom1-pom] = '\0'; - out->BSport = (unsigned int) strtoul(pom2 + 1,NULL,10); - } else { - pom[pom1-pom] = '\0'; - out->BShost = strdup(pom); - out->BSport = GLITE_WMSC_JOBID_DEFAULT_PORT; - } - - /* XXX: localhost not supported in jobid - if (!strncmp(out->BShost,"localhost",9) { - free(pom); - free(out->BShost); - free(out); - return EINVAL; - } - */ - - /* additional info from URI */ - pom2 = strchr(pom1+1,'?'); - if (pom2) { - *pom2 = 0; - out->info = strdup(pom2+1); - } - - /* extract the unique part */ - out->id = strdup(pom1+1); - - for (pom1 = out->BShost; *pom1; pom1++) - if (isspace(*pom1)) break; - - for (pom2 = out->id; *pom2; pom2++) - if (isspace(*pom2)) break; - - if (*pom1 || *pom2) { - free(pom); - edg_wlc_JobIdFree(out); - return EINVAL; - } - - free(pom); - *jobId = out; - return 0; -} - - -void edg_wlc_JobIdFree(edg_wlc_JobId job) -{ - if (job) { - free(job->id); - free(job->BShost); - free(job->info); - free(job); - } -} - - -char* edg_wlc_JobIdUnparse(const edg_wlc_JobId jobid) -{ - char *out, port[40]; - - if (!jobid) - return NULL; - - if (jobid->BSport) - sprintf(port,":%d",jobid->BSport); - else - *port = 0; - - asprintf(&out, GLITE_WMSC_JOBID_PROTO_PREFIX"%s%s/%s%s%s", - jobid->BShost,port, - jobid->id, - (jobid->info ? "?" : ""), - (jobid->info ? jobid->info : "")); - - return out; -} - - -char* edg_wlc_JobIdGetServer(const edg_wlc_JobId jobid) -{ - char *bs = NULL; - - if (jobid) - asprintf(&bs, "%s:%u", jobid->BShost, - jobid->BSport ? jobid->BSport : GLITE_WMSC_JOBID_DEFAULT_PORT); - - return bs; -} - - -void edg_wlc_JobIdGetServerParts(const edg_wlc_JobId jobid, char **srvName, unsigned int *srvPort) -{ - if (jobid) { - *srvName = strdup(jobid->BShost); - *srvPort = jobid->BSport ? jobid->BSport : GLITE_WMSC_JOBID_DEFAULT_PORT; - } -} - - -char* edg_wlc_JobIdGetUnique(const edg_wlc_JobId jobid) -{ - return jobid ? strdup(jobid->id) : NULL; -} diff --git a/org.glite.wms-utils.jobid/src/jobid/manipulation.cpp b/org.glite.wms-utils.jobid/src/jobid/manipulation.cpp deleted file mode 100755 index cf3a710..0000000 --- a/org.glite.wms-utils.jobid/src/jobid/manipulation.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include - -#include -#include - -#include "glite/wmsutils/jobid/JobId.h" - -using namespace std; - -namespace glite { -namespace wmsutils { -namespace jobid { - -namespace { - -class HexInt { -public: - HexInt( unsigned int i = 0 ); - HexInt( const string &str ); - HexInt( string::const_iterator begin, string::const_iterator end ); - ~HexInt( void ); - - inline operator unsigned int( void ) const { return this->hi_int; } - inline operator const string &( void ) const { return this->hi_str; } - - static unsigned int least( void ) { return hi_s_least; } - static void least( unsigned int least ) { hi_s_least = least; } - -private: - void parseString( void ); - - unsigned int hi_int; - string hi_str; - - static unsigned int hi_s_least; - static const char *hi_s_map; -}; - -class BadChar { -public: - BadChar( void ); - ~BadChar( void ); - - inline bool operator()( char c ) - { return( !(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')) || - (c == '.') || (c == '-') || (c == ' ')) ); } -}; - -unsigned int HexInt::hi_s_least = 2; -const char *HexInt::hi_s_map = "0123456789abcdef"; - -HexInt::HexInt( unsigned int ui ) : hi_int( ui ), hi_str( hi_s_least, '0' ) -{ - int n; - string::reverse_iterator pos = this->hi_str.rbegin(); - - while( ui != 0 ) { - n = ui % 16; - if( pos != this->hi_str.rend() ) { - *pos = hi_s_map[n]; - pos += 1; - } - else this->hi_str.insert( this->hi_str.begin(), hi_s_map[n] ); - - ui /= 16; - } - - if( this->hi_str.length() < hi_s_least ) - this->hi_str.insert( this->hi_str.begin(), (hi_s_least - this->hi_str.length()), '0' ); -} - -HexInt::HexInt( const string &str ) : hi_int( 0 ), hi_str( str ) -{ - this->parseString(); -} - -HexInt::HexInt( string::const_iterator begin, string::const_iterator end ) : hi_int( 0 ), hi_str( begin, end ) -{ - this->parseString(); -} - -void HexInt::parseString( void ) -{ - int hexbase; - char *pos, *end = (char *) hi_s_map + 16; - string::reverse_iterator it; - - for( it = this->hi_str.rbegin(), hexbase = 1; it != this->hi_str.rend(); ++it, hexbase *= 16 ) { - pos = find( (char *) hi_s_map, end, (char) tolower(*it) ); - - if( pos != end ) this->hi_int += hexbase * (pos - hi_s_map); - else { - this->hi_int = 0; - break; - } - } - - return; -} - -HexInt::~HexInt( void ) {} - -BadChar::BadChar( void ) {} - -BadChar::~BadChar( void ) {} - -/* - Helper function for the get_reduced_part(...) -*/ -string get_reduced_part_internal( const string &unique, int level ) -{ - string::size_type length = unique.length(); - string piece( unique.substr(0, 2) ), answer; - - if( (level == 0) || (length <= 2) ) answer.assign( piece ); - else if( length != 0 ) { - answer.assign( piece ); - answer.append( 1, '/' ); - answer.append( get_reduced_part_internal(unique.substr(2, length - 2), level - 1) ); - } - - return answer; -} - -}; // Unnamed namespace - -string get_reduced_part( const JobId &id, int level ) -{ - return get_reduced_part_internal( id.getUnique(), level ); -} - -string to_filename( const JobId &id ) -{ - string sid( id.toString() ), coded; - string::iterator last, next; - - last = sid.begin(); - do { - next = find_if( last, sid.end(), BadChar() ); - - if( next != sid.end() ) { - if( last != next ) coded.append( last, next ); - coded.append( 1, '_' ); - coded.append( HexInt(*next) ); - - last = next + 1; - } - else coded.append( last, sid.end() ); - } while( next != sid.end() ); - - return coded; -} - -JobId from_filename( const string &filename ) -{ - char c; - string decoded; - string::const_iterator last, next; - - last = filename.begin(); - do { - next = find( last, filename.end(), '_' ); - - if( next != filename.end() ) { - c = HexInt( next + 1, next + 3 ); - - if( last != next ) decoded.append( last, next ); - decoded.append( 1, c ); - - last = next + 3; - } - else decoded.append( last, filename.end() ); - } while( next != filename.end() ); - - return JobId( decoded ); -} - -} // namespace jobid -} // namespace wmsutils -} // namespace glite diff --git a/org.glite.wms-utils.jobid/src/jobid/strmd5.c b/org.glite.wms-utils.jobid/src/jobid/strmd5.c deleted file mode 100755 index 0433f55..0000000 --- a/org.glite.wms-utils.jobid/src/jobid/strmd5.c +++ /dev/null @@ -1,118 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include - -#include "jobid/strmd5.h" - -#warning Thread unsafe! -static char mbuf[33]; - -static int base64_encode(const void *enc, int enc_size, char *out, int out_max_size) -{ - static const char* b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; - - unsigned char* enc_buf = (unsigned char*)enc; - int out_size = 0; - unsigned int bits = 0; - unsigned int shift = 0; - - while ( out_size < out_max_size ) { - if ( enc_size>0 ) { - // Shift in byte - bits <<= 8; - bits |= *enc_buf; - shift += 8; - // Next byte - enc_buf++; - enc_size--; - } else if ( shift>0 ) { - // Pad last bits to 6 bits - will end next loop - bits <<= 6 - shift; - shift = 6; - } else { - // Terminate with Mime style '=' - *out = '='; - out_size++; - - return out_size; - } - - // Encode 6 bit segments - while ( shift>=6 ) { - shift -= 6; - *out = b64[ (bits >> shift) & 0x3F ]; - out++; - out_size++; - } - } - - // Output overflow - return -1; -} - -char *strmd5(const char *s, unsigned char *digest) -{ - MD5_CTX md5; - unsigned char d[16]; - int i; - - MD5_Init(&md5); - MD5_Update(&md5,s,strlen(s)); - MD5_Final(d,&md5); - - if (digest) memcpy(digest,d,sizeof(d)); - - for (i=0; i<16; i++) { - int dd = d[i] & 0x0f; - mbuf[2*i+1] = dd<10 ? dd+'0' : dd-10+'a'; - dd = d[i] >> 4; - mbuf[2*i] = dd<10 ? dd+'0' : dd-10+'a'; - } - mbuf[32] = 0; - return (char *) mbuf; -} - -char *str2md5(const char *s) -{ - MD5_CTX md5; - unsigned char d[16]; - char* ret = malloc(33); - int i; - - if (!ret) - return NULL; - - MD5_Init(&md5); - MD5_Update(&md5, s, strlen(s)); - MD5_Final(d, &md5); - - for (i=0; i<16; i++) { - int dd = d[i] & 0x0f; - ret[2*i+1] = dd<10 ? dd+'0' : dd-10+'a'; - dd = d[i] >> 4; - ret[2*i] = dd<10 ? dd+'0' : dd-10+'a'; - } - ret[32] = 0; - return ret; -} - -char *str2md5base64(const char *s) -{ - MD5_CTX md5; - unsigned char d[16]; - char buf[50]; - int l; - - MD5_Init(&md5); - MD5_Update(&md5, s, strlen(s)); - MD5_Final(d, &md5); - - l = base64_encode(d, 16, buf, sizeof(buf) - 1); - if (l < 1) - return NULL; - buf[l - 1] = 0; - return strdup(buf); -} diff --git a/org.glite.wms-utils.jobid/src/jobid/strmd5.h b/org.glite.wms-utils.jobid/src/jobid/strmd5.h deleted file mode 100755 index c5d76b6..0000000 --- a/org.glite.wms-utils.jobid/src/jobid/strmd5.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _GLITE_STRMD5_H -#define _GLITE_STRMD5_H - -#ident "$Header$" - -/* Compute MD5 sum of the first argument. - * The sum is returned in the 16-byte array pointed to by 2nd argument - * (if not NULL) - * - * Return value: ASCII string of the sum, i.e. 32 characters [0-9a-f] - * (pointer to static area, changed by subsequent calls) - */ - -char *strmd5(const char *src, unsigned char *dst); - -/** - * Returns: allocated 32bytes long ASCII string with md5 sum - * of the first argument - */ -char *str2md5(const char *src); - -/** - * Returns: allocated 22bytes long ASCII string with md5 sum in base64 - * format of the source argument - */ -char *str2md5base64(const char *src); - -#endif /* _GLITE_STRMD5_H */ diff --git a/org.gridsite.core/.cvsignore b/org.gridsite.core/.cvsignore deleted file mode 100644 index e970233..0000000 --- a/org.gridsite.core/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -.project \ No newline at end of file diff --git a/org.gridsite.core/CHANGES b/org.gridsite.core/CHANGES deleted file mode 100644 index e46eee6..0000000 --- a/org.gridsite.core/CHANGES +++ /dev/null @@ -1,148 +0,0 @@ -* Mon Nov 15 2004 Andrew McNab -- Back out of (most of) redone VOMS support for committing - to JRA1 CVS. -* Thu Oct 19 2004 Andrew McNab -- ==== GridSite version 1.1.3 ==== -* Thu Oct 19 2004 Andrew McNab -- Fix Bug #5203 from Martijn Steenbakkers - by fixing GACLparseEntry in gridsite-gacl.h -- Change to C style comments (mostly) in gridsite.h and - gridsite-gacl.h (fixes part of Bug #4222 from - ) -- Fix Bug #4225 from in - GRSTgaclCredsFree() -- Add GRSTx509CachedProxyFind() and findproxyfile - command to allow proxies to be found in proxy cache -- Change GRSTx509StoreProxy() to GRSTx509CacheProxy() for - consistency with this and GRSTx509CachedProxyKeyFind() -* Wed Oct 18 2004 Andrew McNab -- ==== GridSite version 1.1.2 ==== -* Tue Oct 19 2004 Andrew McNab -- Copy code from delegation prototype into grst_x509.c - and include htproxyput.c and grst-delegation.c - optional targets (which depend on gSOAP.) -* Wed Oct 13 2004 Andrew McNab -- Include per-file patch to GRSTgaclFileFindAclname: - .gacl:FILENAME controls FILENAME if it exists. -* Tue Jul 27 2004 Andrew McNab -- ==== GridSite version 1.1.1 ==== -* Tue Jul 27 2004 Andrew McNab -- Include HTTP Downgrade support in htcp -* Sat Jul 24 2004 Andrew McNab -- Include HTTP Downgrade support in mod_gridsite. -* Thu Jul 22 2004 Andrew McNab -- Begin development version 1.1.x -* Thu Jul 22 2004 Andrew McNab -- ==== GridSite version 1.1.0 ==== -* Mon Jul 19 2004 Andrew McNab -- Changes in line with EGEE SCM - most importantly - the top level directory becomes org.gridsite.core -* Mon Jul 19 2004 Andrew McNab -- ==== GridSite version 1.0.3 ==== -* Mon Jun 28 2004 Andrew McNab -- In GRSTx509CheckChain() and GRSTx509CompactCreds() - we now accept the first cert in a chain as a CA - even if it is X509v3 but without the CA bits set. - (On the basis that the first chain is from the - administrator-installed CA files store.) -* Sun Jun 27 2004 Andrew McNab -- ==== GridSite version 1.0.2 ==== -* Sun Jun 27 2004 Andrew McNab -- Fix for Bug #2860 (so can now read DN Lists over - HTTPS when have no user certificate if relevant - .gacl gives permission but not ) -- Include gridsite-gacl.h mods from Daniel Kouril - to fix faulty definitions - of GACLnewEntry() and GACLnewAcl() and to make - a legacy non-static GACLparseEntry() wrapper. -* Thu Jun 17 2004 Andrew McNab -- Changes to mod_gridsite.h for Fedora Core 2 / - Apache 2.0.49+ mod_ssl changes (mod_ssl-private.h) -* Wed Jun 9 2004 Andrew McNab -- Incorporate EGEE CVS layout changes in production - branch. -* Wed Jun 9 2004 Andrew McNab -- ==== GridSite version 1.0.1 ==== -* Sun Dec 14 2003 Andrew McNab -- 1.0.0 is first full production release - (development now in 1.1.x branch) -* Sun Dec 14 2003 Andrew McNab -- ==== GridSite version 1.0.0 ==== -* Sat Dec 13 2003 Andrew McNab -- Remove need for modified mod_ssl-gridsite: now - mod_gridsite intercepts callbacks with wrappers. -- Add GRSTx509NameCmp() which compares string reps of - DNs across OpenSSL version changes (ie Email=) -* Fri Dec 12 2003 Andrew McNab -- ==== GridSite version 0.9.11 ==== -* Thu Dec 11 2003 Andrew McNab -- Simplify checking of cert/proxy chain in - mod_ssl-gridsite: rely on mod_ssl/OpenSSL more. -* Wed Dec 2 2003 Andrew McNab -- ==== GridSite version 0.9.10 ==== -* Tue Dec 1 2003 Andrew McNab -- GACL ignores leading/trailing spaces in values. -* Sat Nov 29 2003 Andrew McNab -- Better directory listing in htcp. -- htcp now built as separate binary RPM. -- gridsite-admin.cgi upload now redirects to same - directory after upload (Bug #1939); allows - optional new name for file (Request / Bug #1940); - and has better checking of ../dir/file attacks. -* Sat Nov 29 2003 Andrew McNab -- ==== GridSite version 0.9.8 ==== -* Thu Nov 27 2003 Andrew McNab -- Shiv's updated GACL editor, with redirects. -* Wed Nov 26 2003 Andrew McNab -- Include Daniel Stenberg's roffit script to make - HTML man pages for htcp and urlencode. -- Various fixes found when installing GridPP WWW. -* Wed Nov 26 2003 Andrew McNab -- ==== GridSite version 0.9.7 ==== -* Thu Nov 20 2003 Andrew McNab -- Major updates to htcp (htrm/htls/htll) -- GACL now recurses subdirectories when examining - the DN List directories path. -* Sat Nov 15 2003 Andrew McNab -- ==== GridSite version 0.9.6 ==== -* Fri Nov 14 2003 Andrew McNab -- Function call fixes in grst-admin.cgi -* Thu Nov 13 2003 Andrew McNab -- Add htcp (curl-url-get reborn) -* Thu Nov 13 2003 Andrew McNab -- ==== GridSite version 0.9.5 ==== -* Thu Nov 13 2003 Andrew McNab -- More grst-admin.cgi GACL updates from Shiv. -- .gacl security improvements to grst-admin.cgi from - Shiv Kaushal and Peter Moore. -* Tue Nov 11 2003 Andrew McNab -- One RPM instead of three, with version from VERSION -- Textarea for HTML/Text editing now 80 columns -* Mon Nov 10 2003 Andrew McNab -- Add delegation level and GridSiteGSIProxyLimit - support. -- Add GridSiteAdminList handling to mod_gridsite - and real-gridsite-admin.cgi -* Sun Nov 9 2003 Andrew McNab -- Add directory create/delete, and file/dir rename. -- Add ZIP listing/unzipping via external unzip - utility from http://www.info-zip.org/pub/infozip/ -* Mon Nov 3 2003 Andrew McNab -- Include next version of Shiv's GACL editor. -- Add rpm-usr target to Makefile, to make RPMs - out-of-the-box compatible with RH9 and its Apache2 -- Use REMOTE_DOUBLE_REV for GACL hostname creds in - mod_gridsite.c/mod_gridsite_perm_handler() -* Sun Oct 26 2003 Andrew McNab -- Include GACL editor in real-gridsite-admin.cgi - from Shiv Kaushal -* Sun Oct 26 2003 Andrew McNab -- Reorganise into a single build tree, including - Apache 2.0 .h files to remove circular dependency. -* Sun Oct 26 2003 Andrew McNab -- ==== GridSite version 0.9.4 ==== -* Sun Oct 19 2003 Andrew McNab -- Include many pieces of GridSite code from 0.3.x (CGI) - fileGridSite and mod_gridsite 0.9.0 -* Sun Oct 19 2003 Andrew McNab -- ==== GridSite version 0.9.3 ==== diff --git a/org.gridsite.core/INSTALL b/org.gridsite.core/INSTALL deleted file mode 100644 index 3da6cde..0000000 --- a/org.gridsite.core/INSTALL +++ /dev/null @@ -1,39 +0,0 @@ -BUILDING/INSTALLING GRIDSITE -============================ - -For more detailed instructions, see the install.html file, either -in the ./doc subdirectory in the sources, in the directory -gridsite-VERSION/html of the docs directory when GridSite is -installed, or http://www.gridsite.org/1.1.x/install.html - -GridSite is currently only supported on Linux, but should be -trivially portable to other Unix platforms where the GNU build -tools are available. - -When building from source, two routes are available: building -with Make or with RPM. - -BUILDING WITH MAKE -================== - -make -make install - -will build all components and install them all under the default -locations of /usr/local/[lib|bin|include|sbin] The default prefix -/usr/local is set by the prefix variable in the top level Makefile - -BUILDING WITH RPM -================= - -For RedHat Linux and derivatives, building with RPM is recommended. -The command - -make rpm - -will build the gridsite and htcp binary RPMs in the directory -../RPMTMP/RPMS/i386 relative to the working directory. A SRPM is -put into ../RPMTMP/SRPMS - -Building with RPM uses the default prefix /usr, although the -resulting RPMs are relocatable to other hierarchies. diff --git a/org.gridsite.core/LICENSE b/org.gridsite.core/LICENSE deleted file mode 100644 index ce67433..0000000 --- a/org.gridsite.core/LICENSE +++ /dev/null @@ -1,47 +0,0 @@ -Copyright (c) 2002-4, Andrew McNab and Shiv Kaushal, -University of Manchester. All rights reserved. - -Redistribution and use in source and binary forms, with or -without modification, are permitted provided that the following -conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - - -Clearly marked portions of the published GridSite source code -are derived from Apache httpd or its modules, and are covered -by the Apache Software License: - -Copyright 2001-2004 The Apache Software Foundation - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/org.gridsite.core/README b/org.gridsite.core/README deleted file mode 100644 index 62730a6..0000000 --- a/org.gridsite.core/README +++ /dev/null @@ -1,3 +0,0 @@ -See INSTALL for build and installation instructions, and -the Documentation section of http://www.gridsite.org/ -for configuration and usage guides. diff --git a/org.gridsite.core/VERSION b/org.gridsite.core/VERSION deleted file mode 100644 index 372ce91..0000000 --- a/org.gridsite.core/VERSION +++ /dev/null @@ -1,4 +0,0 @@ -MAJOR_VERSION=1 -MINOR_VERSION=1.1 -PATCH_VERSION=1.1.3 -VERSION=$(PATCH_VERSION) diff --git a/org.gridsite.core/build.xml b/org.gridsite.core/build.xml deleted file mode 100644 index a214d0a..0000000 --- a/org.gridsite.core/build.xml +++ /dev/null @@ -1,223 +0,0 @@ - - - - - - - Ant build file to build the Gridsite Core Component - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${global.prefix} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.gridsite.core/doc/README.htcp-bin b/org.gridsite.core/doc/README.htcp-bin deleted file mode 100644 index ac546fc..0000000 --- a/org.gridsite.core/doc/README.htcp-bin +++ /dev/null @@ -1,13 +0,0 @@ -Binaries (and links) are in ./bin; man pages are in ./man/man1 - -Install by copying binaries/links onto your path, or by copying htcp -and making symbolic links to htcp from htls, htll, htrm and htmkdir. - -All the .1 man pages should be copied to a suitable ./man/man1 -directory on your man path. - -If you just want to install htcp in /usr/local, then unpacking this -tgz file in /usr/local should do the trick. (Delete this README when -you're finished!) - -For more about htcp see http://www.gridsite.org/ diff --git a/org.gridsite.core/doc/admin.html b/org.gridsite.core/doc/admin.html deleted file mode 100644 index 1f7f422..0000000 --- a/org.gridsite.core/doc/admin.html +++ /dev/null @@ -1,103 +0,0 @@ -GridSite Admin Guide - -

    GridSite Admin Guide

    - -

    -This Guide is intended for people administrating areas of GridSite -websites or fileservers, or managing GridSite's DN List groups - that is, -how to use GridSite to manage other people's access to parts of the site - -for example, people's write access to areas devoted to specific subprojects. - -

    - There is a separate -User Guide - which explains how to authenticate to the server with X.509 certificates, -and how to manage files via a standard web browser or with command-line -HTTPS clients. You should be familiar with the User Guide to fully -understand this Admin Guide. - -

    - You may also find the -Config Guide - useful to understand how the Apache webserver is configured with GridSite -extensions. If you are also the Apache webmaster for your site, you will -definitely need to read the Config Guide to create the httpd.conf file. -However, if you only need to manage webpages and files, then this Admin -Guide and the User Guide should be sufficient. - -

    Groups and DN Lists

    - -

    -GridSite defines groups of people using plain text DN Lists - that is, lists -of people's certificate DNs. Each DN List has a URL which uniquely -identifies the list (and may also allow other sites to obtain the list and -use it themselves.) For example, the list of all GridPP members is -https://www.gridpp.ac.uk/dn-lists/gridpp (note that it's https:// not -http:// - this means that other sites that download the list can check the -certificate of www.gridpp.ac.uk and know they're talking to the -authoritative source of the lists.) - -

    -The system can also have a number of other DN Lists which are associated with -specific groups of people and perhaps with specific areas of responsibility -of the website. If the DN List directory URI is /dn-lists/ then -there is a full list of the DN Lists exported by the server at that URI -(for example, https://www.gridpp.ac.uk/dn-lists/ ) - -

    -If you have permission to modify a DN List, you can start changing it by -going to /dn-lists/ (via HTTPS), using the "Manage directory" -button and finding the URL of your DN List in the listings. You may -need to go down into a subdirectory to find your list. For -example, https://www.gridpp.ac.uk/dn-lists/atlas is in the atlas -subdirectory of /dn-lists/ (You may wish to bookmark the listing of such -a directory if you frequently work with one.) - -

    -DN List directories are managed by the ACLs described in the next section, -and if you have write permission, you can edit the lists already there, and -add new lists with the same prefix (this means you can readily create your -own subgroups.) - -

    Access Control Lists

    - -

    -DN Lists appear in the Grid Access Control Lists (GACL) used by GridSite. -These are stored as .gacl files in directories: if the .gacl file is -present, it governs access to the directory; if it is absent, then the -parent directories are searched upwards until a .gacl is found. - -

    -The GridSite GACL Reference explains the XML format -of these files, but they -can be edited using the ACL editor built into the GridSite system by people -who have the Admin permission within the ACL. - -

    -If you have this permission in a given directory, when you view directory -listings or files in that directory you will see the option "Manage -Directory" in the page footer. This allows you to get a listing of the -directory and the .gacl file will appear at the top if it's present. If not, -then there will be a button to create a new .gacl file with the same -permissions as have been inherited by that directory from its parent. - -

    -GACL allows quite complex conditions to be imposed on access, but normally -you can think of an ACL as being composed of a number of entries, each of -which contains one condition (the required credential) and a set of allowed -and denied permissions. - -

    -Credentials can be individual user's certificate names or whole groups of -certificate names if a DN List is given. (You can also specifiy hostname -patterns using Unix shell wildcards (eg *.ac.uk) or EDG VOMS attribute -certificates - see the GACL Reference for details.) - -

    -Permissions can be Admin (edit the ACL), Write (create, modify or delete -files), List (browse the directory) or Read (read files.) Permissions can be -allowed or denied. If denied by any entry, the permission is not available -to that user or DN List (depending on what credential type was associated -with the Deny.) - - diff --git a/org.gridsite.core/doc/build-apache2.sh b/org.gridsite.core/doc/build-apache2.sh deleted file mode 100644 index 507be31..0000000 --- a/org.gridsite.core/doc/build-apache2.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2002-3, Andrew McNab, University of Manchester -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# o Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# o Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -#--------------------------------------------------------------- -# For more information about GridSite: http://www.gridsite.org/ -#--------------------------------------------------------------- -# -# This script takes an Apache .tar.gz as the single command line argument, -# unpacks the file, modifies the httpd.spec it contains to work without -# the "-C" option to configure (which RedHat 7.3 doesnt like) and -# outputs source and binary RPMs in SRPMS and RPMS/i386 - -if [ "$1" = "" ] ; then - echo Must give a tar.gz file name - exit -fi - -export MYTOPDIR=`pwd` - -if [ -x /usr/bin/rpmbuild ] ; then - export RPMCMD=rpmbuild -else - export RPMCMD=rpm -fi - -echo "$1" | grep '\.tar\.gz$' >/dev/null 2>&1 -if [ $? = 0 ] ; then # a gzipped source tar ball - - rm -Rf $MYTOPDIR/BUILD $MYTOPDIR/BUILDROOT $MYTOPDIR/SOURCES - mkdir -p $MYTOPDIR/SOURCES $MYTOPDIR/SPECS $MYTOPDIR/BUILD \ - $MYTOPDIR/SRPMS $MYTOPDIR/RPMS/i386 $MYTOPDIR/BUILDROOT - - shortname=`echo $1 | sed 's:^.*/::' | sed 's:\.tar\.gz$::'` - - cp -f $1 SOURCES - - tar zxvf SOURCES/$shortname.tar.gz $shortname/httpd.spec - cp -f $shortname/httpd.spec SPECS - - sed -e 's/configure -C /configure /' \ - SPECS/httpd.spec >SPECS/httpd-2.spec - - $RPMCMD --define "_topdir $MYTOPDIR" \ - -ba --buildroot $MYTOPDIR/BUILDROOT SPECS/httpd-2.spec - - exit -fi - -echo I dont recognise the file type (must be .tar.gz) - -exit diff --git a/org.gridsite.core/doc/config.html b/org.gridsite.core/doc/config.html deleted file mode 100644 index 825bf49..0000000 --- a/org.gridsite.core/doc/config.html +++ /dev/null @@ -1,192 +0,0 @@ -GridSite Config Guide - -

    GridSite Config Guide

    - -

    -This Guide is intended for webmasters setting up -GridSite with an Apache 2.0 -webserver. We assume you have root access to the server machine to do this. -There is a separate Admin Guide for -people administrating areas of GridSite -websites or fileservers, or managing GridSite's DN List groups. That is, for -people managing files on the server rather than the server itself. - -

    Installation

    - -

    -We assume you have installed Apache 2.0 and GridSite, using the -Building and Installation Guide where necessary. -This Config Guide assumes installation has been done under /usr. For an -alternative tree like /usr/local, the relative paths should be the same. - -

    -Installation should have given you an Apache 2.0 httpd binary at -/usr/sbin/httpd and a set of standard Apache 2.0 modules in -/usr/lib/httpd/modules/ including the standard mod_ssl -and our mod_gridsite.so module. - -

    -GridSite also includes some commands and man pages in /usr/bin and -/usr/share/man/man1: urlencode and -htcp. - -

    Certificates

    - -

    -You must also install the CA root certificates of the CA's -used by the users you wish to talk to. These should be installed in -/etc/grid-security/certificates as files like 01621954.0, and RPMs and tar -files for many common European and North American CAs are available from - -https://datagrid.in2p3.fr/distribution/datagrid/security/ - -

    -This location also has VOMS server certificate RPMs which install into -the /etc/grid-security/vomsdir directory. You may also manually install VOMS -server certificates into that directory with any filename. (GridSite -currently parses the certificate itself when looking for a match, rather -than checking the filename.) - -

    -The server itself needs a certificate to supply to clients that use HTTPS -connections. You should apply for this from your Certification Authority -(for example, the UK e-Science -CA) and your request must use the advertised hostname of your server -(the one that appears in URLs and not, for instance, the canonical name of -the host itself.) This advertised hostname should appear in the -Distinguished Name of your request. (For example -/C=UK/O=eScience/OU=Manchester/L=HEP/CN=www.gridpp.ac.uk) For compatability -with standard browsers, the /CN= component should not include any -Globus-style service name (so not /CN=host/www.gridpp.ac.uk) If -possible, you should also include the advertised hostname as a DNS Subject -Alternative Name. Consult your CA first if you're in any doubt about how to -compose your certificate request. - -

    -Once you've got your certificate, -Apache uses the certificate and private key in PEM format. If you obtained -your certificate and key in PKCS#12 or .p12 format (eg by exporting from a web -browser), you can convert the .p12 file to .pem with the following commands: -

    -openssl pkcs12 -in ck.p12 -clcerts -nokeys -out hostcert.pem
    -openssl pkcs12 -in ck.p12 -nodes  -nocerts -out hostkey.pem
    -
    - -

    -Copy the PEM files to /etc/grid-security/ as hostcert.pem (which -should be world readable) and hostkey.pem (which should only be readable by -root): - -

    -chown root.root hostkey.pem hostcert.pem
    -chmod 400 hostkey.pem
    -chmod 444 hostcert.pem
    -
    - -

    httpd.conf

    - -

    -/etc/httpd/conf/httpd.conf is the key to configuring the Apache 2.0 -webserver. The directives in this file determine which files the server will -publish, how they are handled, which areas are writeable and who can access -them. Through mod_gridsite.so, the GridSite system itself is configured by -directives in this file. - -

    -The easiest way to get started is to examine the example httpd.conf files we -provide. - - - -

    httpd-fileserver.conf

    - -

    -httpd-fileserver.conf is an example -configuration file to use Apache/GridSite as a read/write HTTP(S) -fileserver, including comments on how to get the server up and running. - -

    httpd-webserver.conf

    - -

    -httpd-webserver.conf is an example -configuration file to use Apache/GridSite as a Web Server -(that is, primarily for interactive use with a browser) -including comments on how to get the server up and running. - -

    GridSite Directives

    - -

    -The mod_gridsite reference lists all the GridSite -httpd.conf directives. - -

    -To start serving files, make a directory /var/www/htdocs owned by -nobody.nobody, including the .gacl access control file described below, -and add the following directive to the HTTPS <Directory> section: - -

    -GridSiteMethods GET PUT DELETE - -

    -If you wish to accept Globus GSI Proxies as well as full X.509 user -certificates, set GridSiteGSIProxyLimit to the depth of proxy you -wish to accept. (As a _rough_ guide: 0=No Proxies; 1=Proxy on user's -machine; 2=Proxy owned by running Globus job; 3=Proxy delegated by a -Globus job.) - -

    GACL access control

    - -

    -The GACL reference explains the XML access -control files used by GridSite. These allow flexible policies to be written, -in terms of X.509 user certificates, GSI proxies, VOMS attribute -certificates, DN List groups and DNS hostnames. - -

    -For example, to give all clients read and list permission: -

    -

    -<gacl>
    -<entry>
    -  <any-user/>
    -  <allow><read/><list/></allow>
    -</entry>
    -</gacl>
    -
    - -

    -To enable writing, add DN List, Person or VOMS entries to the file. -For example: - -

    -

    -<gacl>
    -<entry>
    -  <any-user/>
    -  <allow><read/><list/></allow>
    -</entry>
    -<entry>
    -  <person>
    -  <dn>/C=UK/O=eScience/OU=Manchester/L=HEP/CN=Andrew McNab</dn>
    -  </person>
    -  <allow><write/></allow>
    -</entry>
    -</gacl>
    -
    - -

    -The GACL file that governs a directory is stored as .gacl in that directory. -If no .gacl is present, then GridSite will search the parent directories in -ascending order until one is found. - - - - diff --git a/org.gridsite.core/doc/findproxyfile.1 b/org.gridsite.core/doc/findproxyfile.1 deleted file mode 100644 index ae2f944..0000000 --- a/org.gridsite.core/doc/findproxyfile.1 +++ /dev/null @@ -1,63 +0,0 @@ -.TH findproxyfile 1 "October 2004" findproxyfile "FINDPROXYFILE Manual" -.SH NAME -.B findproxyfile -\- returns full path to GSI Proxy file -.SH SYNOPSIS -.B findproxyfile -[--proxycache=PATH] [--delegation-id=ID] [--user-dn=DN] [--outsidecache] -.SH DESCRIPTION -.B findproxyfile -returns full path to a GSI Proxy file, either in the proxy cache maintained -by the GridSite G-HTTPS and delegation portType functions, or in other -standard places. - -If a User DN is given -.B findproxyfile -uses the value of the -.B --proxycache -argument, the GRST_PROXY_PATH or the -compile time default to detemine the location of the proxy cache directory. -The directory is searched for a proxy having the given User DN and -Delegation ID. (If no Delegation ID is specificed, then the default value is -used.) - -If -.B findproxyfile -does not find a proxy or if a User DN is not given, but -.B --outsidecache -was given, then the environment variable X509_USER_PROXY and the standard -location /tmp/x509up_uUID are searched as well. - -.SH OPTIONS - -.IP "--proxycache=PATH" -Give the path of the proxy cache directory explicitly, overriding the -default and the GRST_PROXY_PATH environment variable if present. - -.IP "--delegation-id=ID" -The optional delegation ID is search for in the proxy cache in addition to -the User DN. If absent, the default Delegation ID value is searched for. - -.IP "--user-dn=DN" -The DN of the full user certificate associated with the proxy to be searched -for in the proxy cache. (This is not the DN of any proxy earlier in the -chain: it is a the DN of a certificate issued by a recognised CA.) - -.IP "--outsidecache" -If a User DN is not given, or a proxy not found in the cache, then search -for a proxy using X509_USER_PROXY environment variable and file name of -form /tmp/x509up_uUID as well. - -.SH RETURN VALUE -If a proxy is found, its full path is output on standard out. - -.SH EXIT CODES -0 is returned on succcess. Non-zero otherwise. - -.SH BUGS -In this version, no attempt is made to verify or validate the proxies. - -.SH AUTHOR -Andrew McNab - -findproxyfile is part of GridSite: http://www.gridsite.org/ diff --git a/org.gridsite.core/doc/gacl.html b/org.gridsite.core/doc/gacl.html deleted file mode 100644 index 40efdd2..0000000 --- a/org.gridsite.core/doc/gacl.html +++ /dev/null @@ -1,84 +0,0 @@ -GridSite: Grid Access Control Language - -

    GridSite: Grid Access Control Language

    - -

    -GACL is the authorization policy language used by -GridSite GACL allows -policies to be written in terms of common Grid credentials: X.509 -identities, GSI proxies, VOMS attribute certificates and lists of X.509 -identities. - -

    -GridSite both uses GACL policies and provides a GACL manipulation API for -C/C++ in the GridSite library. - -

    Credentials

    - -

    -In GridSite 1.0.x, four credential types are supported: - -

    -<person> -<dn>/O=Grid/CN=Name</dn> -</person> - -

    -<voms> -<fqan>/vo.dom.ain/group</fqan> -</voms> - -

    -<dn-list> -<url>https://www.vo.dom.ain/dn-lists/group</url> -</dn-list> - -

    -<dns> -<hostname>host*.dom.ain</hostname> -</dns> - -

    Permissions

    - -

    -Five permissions are supported: Admin, Write, List, Exec and Read. Admin is -permission to modify the authorization policy itself, but applications can -map the other permissions to local methods as appropriate to their -environment. For filesystems and fileservers, Write, List and Read have -their usual meanings: creating or modifying files or directories; browsing -directories; reading files. Exec is not used by GridSite itself, and -applications are free to give it a meaning within their own contexts. - -

    -In 1.0.x, only per-directory GACL files are supported, and the file is stored -in the directory in question, or in one of its parent directories. (GridSite -searches upwards until it finds one.) - -

    -In GACL files, the permissions are represented by single tags: -<admin/>, <write/>, <list/>, <exec/>, <read/>. -Permission -tags are contained within Allow or Deny blocks. For example: -<allow><read/><list/></allow> or -<deny><admin/></deny>. - -

    Entries

    - -

    -Entries associate credentials with permission statements. Entries consist of -one or more credential blocks, and either an Allow or a Deny block, or both. -If multiple credentials are present in one entry, they must all be held by a -user to receive the association permissions. (So Entries provide logical AND -of credentials.) - -

    Access Control Lists

    - -

    -ACLs consist of a list of one or more Entry blocks. When a user's credentials -are compared to the ACL, the permissions given to the user by Allow blocks -are recorded, along with those forbidden by Deny blocks. When all entries -have been evaluated, any forbidden permissions are removed from those -granted. (So Deny always wins over Allow, even between different Entries, -but otherwise ACLs provide logical OR of credentials.) - - diff --git a/org.gridsite.core/doc/htcp.1 b/org.gridsite.core/doc/htcp.1 deleted file mode 100644 index 984aaaf..0000000 --- a/org.gridsite.core/doc/htcp.1 +++ /dev/null @@ -1,147 +0,0 @@ -.TH htcp 1 "July 2004" htcp "HTCP Manual" -.SH NAME -.B htcp, htrm, htls, htll, htmkdir -\- get, put, delete or list HTTP/HTTPS files or directories -.SH SYNOPSIS -.B htcp [options] -.I Source-URL[s] [Destination URL] -.SH DESCRIPTION -.B htcp -is a client to fetch files or directory listings from remote servers using -HTTP or HTTPS, or to put or delete files or directories onto remote servers -using HTTPS. htcp is similar to scp(1), but uses HTTP/HTTPS rather than ssh -as its transfer protocol. - -When talking to an HTTPS server, htcp can run "anonymously", with a -standard X.509 user certificate and key, or with a GSI Proxy. This makes -htcp very useful in Grid environments where many users have certificates -and where jobs and users have access to GSI proxies. - -.SH URLs -htcp supports the file:, http: and https: URL schemes as sources and -destinations. If no scheme is given, the URL scheme is assumed to be file: -and relative to the current directory if not an absolute path. - -If multiple sources are given, they will be used in turn and the destination -must be a directory (directories are indicated by a trailing /) However, -source and destination cannot both refer to remote servers. - -.SH OPTIONS -.IP "-v/--verbose" -Turn on debugging information. Used once, this option will enable htcp's -messages to stderr. Used twice, will also enable the underlying libcurl -messages. - -.IP "--delete" -Instead of copying files, delete all the URLs given on the command line. -Calling the program as htrm has the same effect. - -.IP "--list" -.br -Instead of copying files, output lists of files located in the URL-directories -given on the command line. Calling the program as htls has the same effect. - -.IP "--long-list" -Instead of copying files, output long listings of files located in the -URL-directories given on the command line. If available, the size in bytes -and modification time of each file is given. Calling the program as -htll has the same effect. - -.IP "--mkdir" -Instead of copying files, attempt to create a directory on a remote server -with HTTP PUT. The server must support the convention that PUT to a URL with -a trailing slash means create a directory. No file body is sent. Calling the -program as htmkdir has the same effect. - -.IP "--anon" -.br -Do not attempt to use X.509 user certificates or GSI proxies to authenticate -to the remote HTTPS server. This means you are "anonymous", but the server's -identity may still be verified and the connection is still encrypted. - -.IP "--cert and --key " -Path to the PEM-encoded -X.509 or GSI Proxy user certificate and key to use for HTTPS -connections, intead of "anonymous mode." If only one of --key or --cert -is given, then that will be tried for both. If neither is given, then the -following order of precedence is used: -the file name held by the variable X509_USER_PROXY; the file -/tmp/x509up_uID (with Unix UID equal to ID); the file names held by -X509_USER_CERT / X509_USER_KEY; the files ~/.globus/usercert.pem and -~/.globus/userkey.pem (where ~/ is the home directory of the user.) - -.IP "--capath " -Path to the PEM-encoded CA root certificates to use when -verifying remote servers' host certificates in HTTPS connections. Ideally -this should be a directory of hash.0 files as described in the OpenSSL -verify(1) man page, but a file may be used instead. If --capath is not -given, the value of the environment variable X509_CERT_DIR will be tried. -If this is not valid, then /etc/grid-security/certificates will be used. - -.IP "--no-verify" -Do not use CA root certificates to verify remote servers' host certificates. -This is useful for testing sites before their certificate is set up properly, -but leaves you vulnerable to "man in the middle" attacks by hostile servers -masquerading as your target. - -.IP "--downgrade-size " -Try to use HTTP-Downgrade for HTTPS URLs. Compatible servers will perform -authentication and authorization on the HTTPS connection and then redirect -to HTTP for the GET or PUT file transfer. htcp makes the HTTP request using -the GRID_AUTH_ONETIME single-use passcode obtained via HTTPS. The downgrade -option will be ignored for directory operations, HTTP URLs, or if the file -size is less than the value given. If a downgraded transfer isn't possible, -a normal HTTPS data transfer will be done. - -.SH FILES -.IP /tmp/x509up_uID -Default GSI Proxy file for Unix UID equal to ID. - -.IP /etc/grid-security/certificates -Default location for trusted Certification Authority root certificates to use -when checking server certificates. - -.IP /tmp/.ca-roots-XXXXXX -Prior to 7.9.8, the underlying curl library did not support the CA root -certificates directory. -If built with an old version of libcurl, htcp will concatenate the -certificates in the CA roots directory into a unique temporary file and use -that. - -.SH ENVIRONMENT - -.IP X509_CERT_DIR -Holds directory to search for Certification Authority root certificates when -verifying server certificates. (Tried if --capath is not given on the -command line.) - -.IP X509_USER_PROXY -Holds file name of a GSI Proxy to use as user certificate. (Tried if --cert or ---key are not given on the command line.) - -.IP "X509_USER_CERT and X509_USER_KEY" -Holds file name of X.509 user certificate and key. (Tried if X509_USER_PROXY -is not valid.) - -.SH EXIT CODES -0 is returned on complete success. Curl error codes are returned when -reported by the underlying curl library, and CURLE_HTTP_RETURNED_ERROR (22) -is returned when the HTTP(S) server returns a code outside the range 200-299. -The manpage libcurl-errors(3) lists all the curl error codes. - -.SH TO DO -Recursive copying. Server-side wildcards. Parallel streams. Error recovery. - -.SH BUGS -Not enough beta testing (hint hint...) - -.SH AUTHOR -Andrew McNab - -htcp is part of GridSite: http://www.gridsite.org/ -.SH "SEE ALSO" -.BR scp(1), -.BR curl(1), -.BR wget(1), -.BR verify(1), -.BR libcurl-errors(3) diff --git a/org.gridsite.core/doc/htll.1 b/org.gridsite.core/doc/htll.1 deleted file mode 100644 index 11a60d1..0000000 --- a/org.gridsite.core/doc/htll.1 +++ /dev/null @@ -1 +0,0 @@ -.so man1/htcp.1 diff --git a/org.gridsite.core/doc/htls.1 b/org.gridsite.core/doc/htls.1 deleted file mode 100644 index 11a60d1..0000000 --- a/org.gridsite.core/doc/htls.1 +++ /dev/null @@ -1 +0,0 @@ -.so man1/htcp.1 diff --git a/org.gridsite.core/doc/htmkdir.1 b/org.gridsite.core/doc/htmkdir.1 deleted file mode 100644 index 11a60d1..0000000 --- a/org.gridsite.core/doc/htmkdir.1 +++ /dev/null @@ -1 +0,0 @@ -.so man1/htcp.1 diff --git a/org.gridsite.core/doc/htrm.1 b/org.gridsite.core/doc/htrm.1 deleted file mode 100644 index 11a60d1..0000000 --- a/org.gridsite.core/doc/htrm.1 +++ /dev/null @@ -1 +0,0 @@ -.so man1/htcp.1 diff --git a/org.gridsite.core/doc/httpd-fileserver.conf b/org.gridsite.core/doc/httpd-fileserver.conf deleted file mode 100644 index 9bd51e2..0000000 --- a/org.gridsite.core/doc/httpd-fileserver.conf +++ /dev/null @@ -1,147 +0,0 @@ -############################################################################## -## GridSite httpd-fileserver.conf - Andrew McNab -## -## Example configuration file for GridSite as an HTTP(S) fileserver. -## -## For GridSite documentation, see http://www.gridsite.org/ -## -## This file should be renamed /etc/httpd/conf/httpd.conf and Apache -## restarted to use Apache2/GridSite as a simple HTTP(S) fileserver. -## -## You do not need to install the GridSite mod_ssl.so module if you -## do not wish to use Globus Proxies or VOMS attributes, but you must -## have the mod_gridsite.so in /usr/lib/httpd/modules -## -## We're assuming you have (a) the host's hostcert.pem and hostkey.pem -## in /etc/grid-security/ and (b) the Certification Authorities' you -## trust have their root certs in /etc/grid-security/certificates -## -## (You can get RPMs for many European and North American Grid CAs -## from https://datagrid.in2p3.fr/distribution/datagrid/security/ ) -## -## If you want to use DN Lists in ACLs, they should be placed/downloaded -## in /etc/grid-security/dn-lists/ -## -## To start serving files, make a directory /var/www/htdocs owned by -## nobody.nobody, including the file .gacl containing: -## -## -## -## -## -## -## -## -## To enable writing, add DN List, Person or VOMS entries to the GACL -## (see the GridSite GACL document for the syntax.) For example: -## -## -## -## -## -## -## -## -## /C=UK/O=eScience/OU=Manchester/L=HEP/CN=Andrew McNab -## -## -## -## -## -## and add the following directive to the HTTPS section: -## -## GridSiteMethods GET PUT DELETE -## -## If you wish to accept Globus GSI Proxies as well as full X.509 user -## certificates, set GridSiteGSIProxyLimit to the depth of proxy you -## wish to accept. -## -## (As a _rough_ guide: 0=No Proxies; 1=Proxy on user's machine; 2=Proxy -## owned by running Globus job; 3=Proxy delegated by a Globus job.) -## -## With this done and Apache restarted, you can upload a file with: -## -## curl -v --cert ~/.globus/usercert.pem --key ~/.globus/userkey.pem \ -## --capath /etc/grid-security/certificates --upload-file /tmp/tmp.txt \ -## https://INSERT.HOSTNAME.HERE/tmp.txt -## -## (or with --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` to use -## a Globus GSI Proxy created with grid-proxy-init.) -############################################################################## - -ServerRoot "/etc/httpd" - -PidFile logs/httpd.pid - -Timeout 300 -KeepAlive On -MaxKeepAliveRequests 100 -KeepAliveTimeout 15 - -LoadModule log_config_module /usr/lib/httpd/modules/mod_log_config.so -LoadModule ssl_module /usr/lib/httpd/modules/mod_ssl.so -LoadModule gridsite_module /usr/lib/httpd/modules/mod_gridsite.so -LoadModule mime_module /usr/lib/httpd/modules/mod_mime.so -LoadModule dir_module /usr/lib/httpd/modules/mod_dir.so - -TypesConfig /etc/mime.types - -# User and group who will own files created by Apache -User nobody -Group nobody - -DocumentRoot "/var/www/htdocs" - - - AllowOverride None - - -LogLevel debug -LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined - -CustomLog logs/httpd-gridsite-access combined -ErrorLog logs/httpd-gridsite-errors - -HostnameLookups On - -###################################################################### -# Plain unauthenticated HTTP on port 80 -###################################################################### - -Listen 80 - - - - GridSiteIndexes on - GridSiteAuth on - GridSiteDNlists /etc/grid-security/dn-lists/ - - - - -###################################################################### -# Secured and possibly authenticated HTTPS on port 443 -###################################################################### -Listen 443 - - -SSLEngine on -SSLCertificateFile /etc/grid-security/hostcert.pem -SSLCertificateKeyFile /etc/grid-security/hostkey.pem -SSLCACertificatePath /etc/grid-security/certificates -#SSLCARevocationPath YOUR CRL DIRECTORY WOULD GO HERE -SSLSessionCache dbm:/var/cache/mod_ssl/scache -SSLSessionCacheTimeout 300 -SSLVerifyClient optional -SSLVerifyDepth 10 -SSLOptions +ExportCertData +StdEnvVars - - - GridSiteIndexes on - GridSiteAuth on - GridSiteDNlists /etc/grid-security/dn-lists/ - GridSiteGSIProxyLimit 0 -# GridSiteMethods GET PUT DELETE - - - diff --git a/org.gridsite.core/doc/httpd-webserver.conf b/org.gridsite.core/doc/httpd-webserver.conf deleted file mode 100644 index da332a0..0000000 --- a/org.gridsite.core/doc/httpd-webserver.conf +++ /dev/null @@ -1,219 +0,0 @@ -############################################################################## -## GridSite httpd-webserver.conf - Andrew McNab -## -## Example configuration file for GridSite as a Web Server -## (that is, primarily for interactive use with a browser.) -## -## For GridSite documentation, see http://www.gridsite.org/ -## -## This file should be renamed /etc/httpd/conf/httpd.conf and Apache -## restarted to use Apache2/GridSite as a webserver. -## -## You do not need to install the GridSite mod_ssl.so module if you -## do not wish to use Globus Proxies or VOMS attributes, but you must -## have the mod_gridsite.so in /usr/lib/httpd/modules -## -## We're assuming you have (a) the host's hostcert.pem and hostkey.pem -## in /etc/grid-security/ and (b) the Certification Authorities' you -## trust have their root certs in /etc/grid-security/certificates -## -## (You can get RPMs for many European and North American Grid CAs -## from https://datagrid.in2p3.fr/distribution/datagrid/security/ ) -## -## If you want to use DN Lists in ACLs, they should be placed/downloaded -## in /etc/grid-security/dn-lists/ or /var/www/htdocs/dn-lists/ -## (Lists in /etc/grid-security/dn-lists/ override lists elsewhere.) -## -## To start serving files, make a directory /var/www/htdocs owned by -## nobody.nobody, including the file .gacl containing: -## -## -## -## -## -## -## -## -## To enable writing, add DN List, Person or VOMS entries to the GACL -## (see the GridSite GACL document for the syntax.) For example: -## -## -## -## -## -## -## -## -## /C=UK/O=eScience/OU=Manchester/L=HEP/CN=Andrew McNab -## -## -## -## -## -## and add the following directive to the HTTPS section: -## -## GridSiteMethods GET PUT DELETE -## -## If you wish to accept Globus GSI Proxies as well as full X.509 user -## certificates, set GridSiteGSIProxyLimit to the depth of proxy you -## wish to accept. -## -## (As a _rough_ guide: 0=No Proxies; 1=Proxy on user's machine; 2=Proxy -## owned by running Globus job; 3=Proxy delegated by a Globus job.) -## -## With this done and Apache restarted, you can upload a file with: -## -## curl -v --cert ~/.globus/usercert.pem --key ~/.globus/userkey.pem \ -## --capath /etc/grid-security/certificates --upload-file /tmp/tmp.txt \ -## https://INSERT.HOSTNAME.HERE/tmp.txt -## -## (or with --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` to use -## a Globus GSI Proxy created with grid-proxy-init.) -############################################################################## - -ServerRoot "/etc/httpd" - -## You MUST put your server's fully qualified domain name here -## This, the DOMAIN part of the https://DOMAIN/... URLs you want -ServerName FULL.SERVER.NAME - -PidFile logs/httpd.pid - -Timeout 300 -KeepAlive On -MaxKeepAliveRequests 100 -KeepAliveTimeout 15 - -LoadModule log_config_module /usr/lib/httpd/modules/mod_log_config.so -LoadModule ssl_module /usr/lib/httpd/modules/mod_ssl.so -LoadModule gridsite_module /usr/lib/httpd/modules/mod_gridsite.so -LoadModule mime_module /usr/lib/httpd/modules/mod_mime.so -LoadModule dir_module /usr/lib/httpd/modules/mod_dir.so -LoadModule alias_module /usr/lib/httpd/modules/mod_alias.so -LoadModule cgi_module /usr/lib/httpd/modules/mod_cgi.so - -TypesConfig /etc/mime.types - -# User and group who will own files created by Apache -User nobody -Group nobody - -DocumentRoot "/var/www/htdocs" - - - AllowOverride None - - -LogLevel debug -LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined - -CustomLog logs/httpd-gridsite-access combined -ErrorLog logs/httpd-gridsite-errors - -HostnameLookups On - -###################################################################### -# Plain unauthenticated HTTP on port 80 -###################################################################### - -Listen 80 - - -## This is used to serve the Manage Directory links in footers, -## and to allow you to edit files and ACLs via your browser. -ScriptAlias /real-gridsite-admin.cgi /usr/sbin/real-gridsite-admin.cgi - - - ## This sets up GACL authorization for this server. - GridSiteAuth on - - ## This exports various bits of info into the CGI environment - ## variables (and is needed for gridsite-admin.cgi to work.) - GridSiteEnvs on - - ## Nice GridSite directory listings (without truncating file names!) - GridSiteIndexes on - - ## If this is on, GridSite will look for gridsitehead.txt and - ## gridsitefoot.txt in the current directory or its parents, and - ## use them to replace the and tags in .html files. - GridSiteHtmlFormat on - - ## These directives (and the ScriptAlias above) allow authorized - ## people to manage files, ACLs and DN Lists through their web - ## browsers. Via HTTP, this just means extended directory listings - ## and History pages. - GridSiteAdminURI /real-gridsite-admin.cgi - GridSiteAdminFile gridsite-admin.cgi - - - - -###################################################################### -# Secured and possibly authenticated HTTPS on port 443 -###################################################################### -Listen 443 - - -SSLEngine on -SSLCertificateFile /etc/grid-security/hostcert.pem -SSLCertificateKeyFile /etc/grid-security/hostkey.pem -SSLCACertificatePath /etc/grid-security/certificates -#SSLCARevocationPath YOUR CRL DIRECTORY WOULD GO HERE -SSLSessionCache dbm:/var/cache/mod_ssl/scache -SSLSessionCacheTimeout 300 -SSLVerifyClient optional -SSLVerifyDepth 10 -SSLOptions +ExportCertData +StdEnvVars - -## This is used to serve the Manage Directory links in footers, -## and to allow you to edit files and ACLs via your browser. -ScriptAlias /real-gridsite-admin.cgi /usr/sbin/real-gridsite-admin.cgi - - - ## This sets up GACL authorization for this server. - GridSiteAuth on - - ## This exports various bits of info into the CGI environment - ## variables (and is needed for gridsite-admin.cgi to work.) - GridSiteEnvs on - - ## Nice GridSite directory listings (without truncating file names!) - GridSiteIndexes on - - ## If this is on, GridSite will look for gridsitehead.txt and - ## gridsitefoot.txt in the current directory or its parents, and - ## use them to replace the and tags in .html files. - GridSiteHtmlFormat on - - ## This is the path of directories (and all their subdirectories) for - ## GACL to search when it encounters a dn-list credential. The DN List - ## files are plain text, one DN per line, and must have the full url - ## as the file name, but URL Encoded - eg with urlencode(1) - GridSiteDNlists /etc/grid-security/dn-lists/:/var/www/htdocs/dn-lists/ - - ## This is used to form the URL at which DN Lists "owned" by this - ## server are exported. https://FULL.SERVER.NAME/dn-lists/file - ## ALL FILES WITH URLs ON THIS SERVER WILL BE EXPORTED IRRESPECTIVE - ## OF WHERE THEY ARE FOUND ON THE DN-LISTS PATH!! - GridSiteDNlistsURI /dn-lists/ - - ## If this is greater than zero, we will accept GSI Proxies for clients - ## (full client certificates - eg inside web browsers - are always ok) - GridSiteGSIProxyLimit 0 - - ## This directive allows authorized people to write/delete files - ## from non-browser clients - eg with htcp(1) - GridSiteMethods GET PUT DELETE - - ## These directives (and the ScriptAlias above) allow authorized - ## people to manage files, ACLs and DN Lists through their web - ## browsers via HTTPS. The value of GridSiteAdminFile appears to - ## exist in every directory, but is internally redirected by - ## mod_gridsite to the value of GridSiteAdminURI (the ScriptAlias - ## then maps that onto the real-gridsite-admin.cgi executable.) - GridSiteAdminURI /real-gridsite-admin.cgi - GridSiteAdminFile gridsite-admin.cgi - - - diff --git a/org.gridsite.core/doc/index.html b/org.gridsite.core/doc/index.html deleted file mode 100644 index a93f2cb..0000000 --- a/org.gridsite.core/doc/index.html +++ /dev/null @@ -1,92 +0,0 @@ -GridSite 1.1.x Documentation - -

    GridSite 1.1.x Documentation

    - -

    -GridSite -is a set of extensions to the Apache 2.0 webserver, which support -Grid security based on X.509 certificates. Since GridSite applies access -control within Apache itself, via mod_gridsite, Grid authorization and -the associated verified credentials are available to all technologies -supported by Apache, including static file serving, SSI, CGI, PHP, JSP and -mod_perl. - -

    Guides

    - -

    -

    -
    User Guide -
    End-user documentation for people managing webpages and files on - GridSite servers, either through the web interface or with command - line clients like htcp. -

    - -

    Admin Guide -
    For people administering areas of GridSite websites or fileservers, or - managing GridSite's support for DN List groups. -

    - -

    Building and Installation -
    Instructions for building GridSite from source, and installing from - binaries or RPMs. -

    - -

    Config Guide -
    For webmasters setting up Apache 2.0 and GridSite, and writing the - Apache httpd.conf file. -

    - -

    httpd-fileserver.conf and - httpd-webserver.conf -
    Example configuration files for simple HTTP(S) fileservers and - webservers, with explanatory comments. -

    - -

    - -

    Reference

    - -

    -

    -
    Grid Access Control Lists -
    Syntax and usage of the XML Grid Access Control Lists used by GridSite. -

    - -

    htcp and - urlencode man pages -
    Command line tools for copying files to or from HTTP(S) servers, and - for URL-encoding strings. -

    - - - -

    mod_gridsite -
    An Apache 2.0 module which enforces access control via Grid Access - Control Lists, and X.509, GSI or VOMS credentials. mod_gridsite also - gives Apache built-in support for the HTTP PUT and DELETE methods, and - formatting of HTML pages with standard headers and footers. -

    - - - -

    gridsite.h API reference -
    A detailed description of the C API provided by libgridsite, generated - from the sources by doxygen. -

    - -

    - - diff --git a/org.gridsite.core/doc/install.html b/org.gridsite.core/doc/install.html deleted file mode 100644 index 91a60d2..0000000 --- a/org.gridsite.core/doc/install.html +++ /dev/null @@ -1,148 +0,0 @@ -GridSite: Building and Installation Guide - -

    GridSite: Building and Installation Guide

    - -

    -This Guide explains how to build GridSite from source, and how to install -the server components alongside an Apache 2.0 webserver. There is a -separate Config Guide which explains how to modify -the httpd.conf file, and how to set up other files and directories used by -the system. You should look through all of this Building and Installation -Guide to decide which is the easiest route for your system. - -

    Installing with RPM

    - -

    -If you are installing on Linux with the binary RPM release, you can skip -most of this Guide, install the binary rpm(s) and go straight -to the Config Guide. - -

    -We currently distribute GridSite RPMs for RedHat Linux versions 9 and 7.3 -from our download area at - -https://www.gridsite.org/download/ - -

    -RedHat 9: -This is the simpler case, since the standard release includes a suitable -version of Apache 2.0: just install the gridsite-...-1.i386.rpm to get the -various GridSite components. - -

    -RedHat 7.3: -This is more complicated because you must also install a back-ported Apache -2.0 RPM. We distribute RPMs built on 7.3 aimed at RedHat 7.3 -machines with updates, from our download area. These are built from the -tar.gz and .spec files distributed by the -Apache Foundation itself, using the -build-apache2.sh script in the GridSite -/usr/share/doc/gridsite directory. The Apache RPMs install in /usr, and you -should at least install the httpd and mod_ssl RPMs. -You must also install the gridsite-...-1.i386.rpm as above. - -

    -GridSite also depends on shared libraries from libcurl and libxml2, and the -RPMs distributed as part of the standard RedHat 7.3 and 9 releases are -sufficient. - -

    -With the RPMs installed, you can proceed to the -Config Guide. - -

    Requirements for building GridSite from source

    - -

    -GridSite is currently only supported on Linux, but should be -straightforwardly -portable to other Unix platforms where the GNU build tools are available. - -

    -GridSite consists of a core library (libgridsite[.so|.a]), an Apache module -(mod_gridsite.so), a CGI utility (gridsite-admin.cgi) and some command line -tools (htcp, urlencode.) - -

    -All of the components use the GridSite library, and this in turn depends on -libcurl and libxml2. You will need the development versions of these -packages installed before you can proceed. (They are available as part of -RedHat Linux releases 7.x onwards, for instance.) - -

    Building GridSite with Make

    - -

    -Our download area at - -https://www.gridsite.org/download/ includes a tar-ball -distribution of the sources, which can be unpacked and used to build -GridSite from source. (Bleeding-edge developers can get the current snapshot -of the same files from our CVS area.) - -

    -GridSite needs a copy of the Apache 2.0 include files to build, and the -location of this is set by the MYCFLAGS variable in the top-level Makefile. -For manual builds, the default -MYCFLAGS=-I/usr/local/include/httpd is used. -If you wish to use the GridSite module with Apache -2.0 installed elsewhere, you should change the MYCFLAGS variable to point to -the includes directory installed by the development part of that Apache 2.0 -distribution. - -

    -

    -make 
    -make install
    -
    - -

    -will build all components and install them all under the default -locations of /usr/local/[lib|bin|include|sbin] The default prefix for manual -builds is -/usr/local, as set by the prefix variable in the top level Makefile -(/usr is the default for RPMs.) - -

    Building GridSite with RPM

    - -

    -For RedHat Linux and derivatives, building with RPM is recommended. -The command make rpm in the top level of the source tree -will build the GridSite and htcp binary RPMs in the -directory ../RPMTMP/RPMS/i386 relative to the working directory. An SRPM is -put into ../RPMTMP/SRPMS -This build assumes the Apache 2.0 includes are in /usr/include/httpd. - -

    -If you make RPMs on a RedHat 9 system (or a 7.3 system with our httpd RPM -installed), you can install the resulting GridSite -RPM alongside the standard Apache 2.0 RPM without having to -modify shared library or Apache module paths. - -

    -For other configurations, -you can modify the assumed location of the Apache 2.0 includes -by changing the MYCFLAGS variable in the rpm target near the -foot of the top level Makefile. - -

    Building Apache 2.0

    - -

    -If it is not possible to use binary RPMs of Apache 2.0, -then it can be built from source using the build-apache2.sh script -found in the GridSite docs directory. -The script includes instructions on how to build from the tarballs -distributed by the Apache Foundation. -(it removes the -C option from "configure -C" in the .spec file -and builds the RPMs under the current directory.) - -

    -If these targets do not work on your build platform, -the Makefile and the scriptlets in the included SPEC files are a good -starting point for building Apache by hand yourself. The complexities of -this are outside of the scope of this Guide, but you are welcome to ask for -assistance on the -GridSite -Discussion List, although -www.apache.org is a better starting -point for purely Apache problems. - - diff --git a/org.gridsite.core/doc/library.html b/org.gridsite.core/doc/library.html deleted file mode 100644 index 28458ae..0000000 --- a/org.gridsite.core/doc/library.html +++ /dev/null @@ -1 +0,0 @@ -library docs diff --git a/org.gridsite.core/doc/module.html b/org.gridsite.core/doc/module.html deleted file mode 100644 index 7f2096e..0000000 --- a/org.gridsite.core/doc/module.html +++ /dev/null @@ -1,271 +0,0 @@ -GridSite Apache module: mod_gridsite - -

    GridSite Apache module: mod_gridsite

    - -

    -mod_gridsite is an Apache 2.0 module which enforces access control via Grid -Access Control Lists, and X.509, GSI or VOMS credentials. mod_gridsite also -gives Apache built-in support for the HTTP PUT and DELETE methods, and -formatting of HTML pages with standard headers and footers. - -

    -Since mod_gridsite access -control within Apache itself, Grid authorization and -the associated verified credentials are available to all technologies -supported by Apache, including static file serving, SSI, CGI, PHP, mod_perl -and Java servlets via a connector to Tomcat. - -

    -Operation of mod_gridsite can be configured using runtime directives -in Apache's standard httpd.conf configuration file. The module must first be -loaded with a LoadModule directive: - -

    -LoadModule gridsite_module /PATH/TO/MODULES/mod_gridsite.so - -

    -The module's behaviour is then controlled by GridSite... directives within -Apache <Directory ...> sections, allowing different directories to use -GridSite features in different ways. - -

    GridSite directives

    - -
    -
    GridSiteIndexes on|off -
    Determines whether GridSite generates HTML directory listings. These - have some advantages over standard Apache directory listings (eg the - displayed filenames are never truncated) and will include standard - headers and footers if GridSiteHtmlFormat is on. -
    - (Default: GridSiteIndexes off) -

    - -

    GridSiteIndexHeader file -
    If the named file is found in the directory being listed, the file - is included verbatim at the top of the listing and excluded from - the file-by-file listing. The file can either be HTML or plain text (in - which case browsers will be treat it as one HTML paragraph.) -
    - (Default: none) -

    - -

    GridSiteHtmlFormat on|off -
    Determines where HTML pages receive additional formatting before being - sent to the client. This includes the "Last modified", - "View page history", "Switch to HTTP(S)", - "Print View" and "Built with GridSite" footer - elements. If header and footer files are found, they will be used too. -
    - (Default: GridSiteHtmlFormat off) -

    - -

    GridSiteHeadFile file
    - GridSiteFootFile file -
    Set the filenames to be searched for as standard headers and footers - for HTML pages. For each HTML page, the directory of that page is tried - first, and then parent directories in ascending order until a header / - footer file is found. Header files are inserted in place of HTML - <body[ ...]> tags; footer files in place of </body>. (These - standard files should each include the appropriate body tag as a - replacement.) -
    - (Defaults: GridSiteHeadFile gridsitehead.txt, - GridSiteFootFile gridsitefoot.txt) -

    - -

    GridSiteAuth on|off -
    Enables GridSite access control features, using - GACL files. The files are named .gacl and are - per-directory. The current directory is tried and then parent - directories in ascending order until a .gacl file is found. -
    - (Default: GridSiteAuth off) -

    - -

    GridSiteAdminList uri -
    All members of the DN List with name "uri" receive the full set - of permissions, irrespective of per-directory .gacl files. People in - this group have full control over the whole site. -
    - (Default: none) -

    - -

    GridSiteGSIProxyLimit limit -
    When using GSI Proxy credentials, - proxies with delegation depth greater than "limit" will - be ignored by mod_gridsite authorization decisions. A limit of zero - implies only full X.509 - certificates (and no proxies) will be accepted. A limit of 1 implies - that only the initial proxy, usually created on the user's own machine, - is acceptable. Higher levels lead to proxies on remote machines, eg - used by running jobs, being accepted. -
    - (Default: GridSiteGSIProxyLimit 1) -

    - -

    GridSiteMethods [GET] [PUT] [DELETE] -
    Specifies which HTTP methods are supported by GridSite. GET (and HEAD) - are always supported. PUT and DELETE support is turned on by this - directive, subject to a positive statement that write permission is - allowed for the directory in question, by a GACL file. -
    - (Default: GridSite GET) -

    - -

    GridSiteDNlists directory1[:directory2[:directory3]...] -
    Sets up the DN List path used by GACL for - evaluating <dn-list> credentials. If this directive is not used, - then GACL will use the GRST_DN_LISTS variable from Apache's own - environment. If that is not set either, then /etc/grid-security/dn-lists - is searched. -
    - (Default: none) -

    - -

    GridSiteDNlistsURI uri -
    If GridSiteDNlistsURI is used, then the URI given appears to be - populated with all the DN lists on the current DN lists path which - match the current server. That is, for server https://example.org/ - with DN lists URI /dn-lists/, all DN lists with URLs starting - https://example.org/dn-lists/ will appear to be present in /dn-lists/, - irrespective of where in the path they are stored. -
    - (Default: none) -

    - -

    GridSiteAdminURI uri -
    GridSiteAdminURI gives the absolute URI on the server of the GridSite - Admin CGI program, which is used for file management, HTML and GACL - editing. This should be used in conjunction with the standard Apache - directive ScriptAlias to map that URI to the real-gridsite-admin.cgi - executable. For example: -
    - ScriptAlias /real-gridsite-admin.cgi - /PATH/TO/real-gridsite-admin.cgi -
    - This URI is always reached by an internal redirection from the value - set by GridSiteAdminFile, and is never visible to users. -
    - (Default: none) -

    - -

    GridSiteAdminFile cgifilename -
    If GridSiteAdminURI is set, then the cgifilename of GridSiteAdminFile - appears to be present in all directories when explicitly - requested (it does not appear in directory listings.) Requests for these - ghost CGI URIs are internally redirected to the value set by - GridSiteAdminURI. -
    - (Default: GridSiteAdminFile gridsite-admin.cgi) -

    - -

    GridSiteEnvs on|off -
    This makes mod_gridsite export several variables into the environment - of CGI programs and other dynamic content systems. The variable names - are listed below. For gridsite-admin.cgi mechanism to work, this switch - must be left in its default state of on. -
    - (Default: GridSiteEnvs on) -

    - -

    GridSiteEditable [ext1 [ext2 [ext3] ...]]] -
    A space-separated list of file extensions which can safely be edited - by the GridSite Text/HTML editor. The extensions are given without the - initial dot. -
    - (Default: GridSiteEditable txt shtml html htm css js php jsp) -

    - -

    GridSiteHelpURI uri -
    If set, gives the URI to use for "Website Help" links in HTML - page footers. -
    - (Default: none) -

    - -

    GridSiteLink on|off -
    Turns off the link in the HTML page footers which gives credit to - GridSite. -
    - (Default: GridSiteLink on) -

    - -

    GridSiteUnzip path -
    If "path" is set by this directive, then real-gridsite-admin.cgi - will offer to list the contents of .zip archives on the server. - Users with write access are able to unpack the contents into the same - directory as the .zip file. The value of "path" must point - to the location of the - unzip binary. -
    - (Default: none) -

    - -

    - -

    Environment variables

    - -

    -The following variables are present in the environment of CGI programs and -other dynamic content systems if the GridSiteEnvs on directive is -in effect. - -

    -

    -
    GRST_PERM -
    Numerical value of the permission bit-map obtained by comparing the - user with the GACL in force. (These should be tested using the - GRSTgaclPermHasXXXX functions from GACL.) -

    - -

    GRST_ADMIN_LIST -
    URI of the DN List, listing people with full admin and write access - to the whole site. -

    - -

    GRST_GSIPROXY_LIMIT -
    Maximum valid delegation level for GSI Proxies. -

    - -

    GRST_DIR_PATH -
    Absolute path in the local filesystem to the directory holding the - file being requested. -

    - -

    GRST_HELP_URI -
    URI of website help pages set by GridSiteHelpURI directive. -

    - -

    GRST_ADMIN_FILE -
    Filename of per-directory ghost gridsite-admin.cgi program. (This is - used by real-gridsite-admin.cgi to construct links in its pages.) -

    - -

    GRST_EDITABLE -
    Space-separated list of extensions which can safely be edited with a - Text/HTML editor. -

    - -

    GRST_HEAD_FILE and GRST_FOOT_FILE -
    Filenames of standard header and footer files. -

    - -

    GRST_DN_LISTS -
    DN lists search path. -

    - -

    GRST_DN_LISTS_URI -
    Directory of virtual URIs used to publish this site's DN Lists. -

    - -

    GRST_UNZIP -
    Full path to the unzip binary, used to list and unpack .zip files. -

    - -

    GRST_NO_LINK -
    If set, do not include credit links to GridSite in page footers. -

    - -

    - - diff --git a/org.gridsite.core/doc/urlencode.1 b/org.gridsite.core/doc/urlencode.1 deleted file mode 100644 index fe84405..0000000 --- a/org.gridsite.core/doc/urlencode.1 +++ /dev/null @@ -1,46 +0,0 @@ -.TH urlencode 1 "November 2003" urlencode "URLENCODE Manual" -.SH NAME -.B urlencode -\- convert strings to or from URL-encoded form -.SH SYNOPSIS -.B urlencode -[-m|-d] -.I string [string ...] -.SH DESCRIPTION -.B urlencode -encodes strings according to RFC 1738. - -That is, characters A-Z a-z 0-9 . _ -and - are passed through unmodified, but all other characters are -represented as %HH, where HH is their two-digit upper-case hexadecimal ASCII -representation. -For example, the URL http://www.gridpp.ac.uk/ becomes -http%3A%2F%2Fwww.gridpp.ac.uk%2F - -.B urlencode -converts each character in all the strings given on the command line. If -multiple strings are given, they are concatenated with separating spaces -before conversion. - -.SH OPTIONS -.IP "-m" -Instead of full conversion, do GridSite "mild URL encoding" in which A-Z a-z -0-9 . = - _ @ and / are passed through unmodified. This results in slightly -more human-readable strings but the application must be prepared to create -or simulate the directories implied by any slashes. - -.IP "-d" -Do URL-decoding rather than encoding, according to RFC 1738. %HH and %hh -strings are converted and other characters are passed through unmodified, -with the exception that + is converted to space. - -.SH EXIT CODES -0 is always returned. - -.SH BUGS -Not enough beta testing (hint hint...) - -.SH AUTHOR -Andrew McNab - -urlencode is part of GridSite: http://www.gridsite.org/ diff --git a/org.gridsite.core/doc/user.html b/org.gridsite.core/doc/user.html deleted file mode 100644 index ae37cdd..0000000 --- a/org.gridsite.core/doc/user.html +++ /dev/null @@ -1,302 +0,0 @@ -GridSite User Guide - -

    GridSite User Guide

    - -

    If you are setting up a GridSite-based website you may wish to use this -file as the basis of your end-user documentation. If so, copy all of the -files from the GridSite doc directory (probably -/usr/share/doc/gridsite-VERSION/) -to somewhere on your website like -/gridsite-doc/ and add GridSiteHelpURI /gridsite-doc/user.html -to the virtual server configuration in -httpd.conf - you should also look through the rest of the HTML source since -there are some comments you may find helpful. - -

    -This Guide is intended for people using GridSite websites with conventional -web browsers, especially people with write access to areas of the site. - There is a separate -Administration Guide - with additional information for people managing access control and group -membership. This Guide assumes you are familiar with basic Web and HTML -concepts. Towards the end we discuss how to access servers with command -line tools like curl and htcp. - -

    Reading from HTTP and HTTPS servers

    - -

    -GridSite servers are usually accessible both via HTTP and via HTTPS. You can -always tell which version you are using by looking at whether the URL in your -browser's location window starts with "http://" or -"https://" HTTPS means that the connection to the server is -encrypted, that you can verify you're talking to the real server and not an -imposter, and gives you the option to authenticate to the site and perhaps -gain write access. - -

    - Simple browsing of the website via HTTP or HTTPS is reasonably - self-explanatory. If configured, additional links may appear in the footer - of each webpage with links to this help, - - and to switch between HTTP and HTTPS versions of the page. Pages may also - have a link to the page History, - - showing the dates of changes to that page and names of its authors. - -

    - When looking at HTTPS pages, you may find your browser reports it cannot - verify the server's certificate since it does not recognise the - Certification Authority (CA) it uses. You should attempt to load the CA's - root certificate into your browser to stop these warnings. (This means your - browser will be able to identify any servers using fake certificates which - you shouldn't trust.) How you obtain the CA Root Certificate from a - trust-worthy source depends on the CA. For example, the UK e-Science CA - lets you download it from their - website. - - -

    Authenticating

    - -

    - To go beyond reading pages you need to obtain a user certificate and load it - into your web browser. How you do this again depends on the Certification - Authority you have access to (for most Grid projects, CAs are organised - on a national basis.) To use the UK e-Science CA example again, - from their website has links to - the procedure for applying for a certificate from within a web browser. - - -

    -A user certificate usually has a version of your name and affiliation as its -Distinguished Name (DN) - for example, -"/C=UK/O=eScience/OU=Manchester/L=HEP/CN=Andrew McNab" - -

    -Once you've obtained a user certificate in your name from your CA, you need -to make sure it is loaded into the browser you normally use to browse the -web. How you do this is different for different browsers and to some extent -for different CAs (but if you applied -for the CA through your browser, you may already have it there.) - -

    -Browsers want the certificate and private key in the PKCS#12 format, which -is normally a single file with the extension ".p12". -Many programs which are based on OpenSSL, such as Globus and curl, prefer -the PEM (".pem") format for certificates, with separate -certificate and key files ("usercert.pem" and -"userkey.pem", for example.) If you only have the files in .pem -format and have access to openssl, you -can use its command line tools to convert PEM to PKCS#12: -

    -openssl pkcs12 -in usercert.pem -inkey userkey.pem -export -out certkey.p12
    -
    - -

    -Be very careful not to accidentally overwrite .pem or .p12 files when -doing this kind of thing! In particular, if you lose your private key, you -cannot retrieve it from your CA. - -

    - Once your user certificate is loaded, you should be able to see your - certificate name appear when you look at an HTTPS GridSite page which has - the page footers enabled - for example, the "Switch to HTTP" link - present. If GridSite understands your user certificate, it displays a - "You are ..." line in the footer. (However, the Apache webserver - must also be set up with your CAs root certificate for this to work. The - GridPP HTTPS home page is set up - to recognise a good range of European and North American Grid CAs.) - - -

    Authorization

    - -

    - Once users can prove their identity to the web server, it then becomes - possible to give them appropriate rights depending on that identity. - GridSite allows site administrators to specify these rights for individuals - and groups using -GACL - access control files. (The -Administration Guide - explains how to manage these files.) GACL defines who can - read files, who can list directories, - who can write or create files and who can modify the GACL policy files. To - get increased access to an area of a site, you need to contact the - administrator for that area and give the DN of your certificate (it's not - necessary to send any certificate files.) - -

    Managing Directories and Files

    - -

    -If you have list permission for the directory containing a page, you should -see an extra link "Manage Directory" in the page's set of footer -links, which allows you to browse the directory even if the normal -index.html is present. If page histories are available, this listing view -also has links to them. - -

    -The real power of GridSite becomes available if you have write access to a -directory. In that case, the "Manage Directory" page has -additional links to Delete or Rename pages and other files, and to Edit HTML -and plain text files. An Edit link also appears in the footer links of HTML -pages. - -

    -If you use the Edit function, you are presented with an HTML form containing -the current filename and the full HTML or plain text of the page for you to -edit. This allows you to maintain the content of the site "in -place" and to see the result of your changes immediately, in context. - -

    -If you modify the filename in the form before saving, GridSite will make a -new file with that name, and the old file will still be present, unmodified. -(However, you cannot use this feature for creating a file in a different -directory.) -As you make changes, the history of the changes and your certificate DN are -recorded, and available in the history page for that file. - -

    - For people with write access, the "Manage Directory" page also has - options to upload a file from the computer your browser is running on, and to - create files and directories. If it's enabled, you can also view the - contents of WinZIP / PKZIP / .zip files, and unpack their contents into the - current directory. (This feature is very useful if you have several files - to upload at one time.) - - -

    HTML Formatting in GridSite

    - -

    -As well as providing access control and file management, GridSite provides -some simple formatting of HTML pages by adding standard headers and footers. -(If this isn't sufficient, GridSite will happily coexist with HTML -preprocessor languages like SSI, PHP and JSP.) - -

    - If HTML formatting is enabled - for the current directory, GridSite looks for the files gridsitehead.txt and - gridsitefoot.txt in that directory, or goes up through the parent - directories until they are found. - - -

    -The <body> and </body> tags from the HTML file are replaced with -the contents of the gridsitehead.txt and gridsitefoot.txt files, which -should normally be chunks of HTML including a replacement <body> -or </body> tag. If either tag is absent from the original page, then -the header or footer is just added rather than being inserted in place of -the tag. (One consequence of this absence is that HTML header tags like -<title> can end up after a <body> tag, and can get ignored by -browsers - so always include <body> ... </body> in your pages.) - -

    -This simple system is suprisingly flexible, and allows a variety of top and -bottom, or sidebar navigation layouts of pages. Since the <body ...> -tag is under full control of the author of the gridsitehead.txt file, -backgrounds, colour schemes and style sheets can easily be specified. - -

    -For example: - -

    - - - - - - - - - -
    SourceHTML
    page.html<title>PAGE TITLE</title>
    page.html
    (replaced)
    <body>
    gridsitehead.txt<body text=blue>
    - Heading text
    - <table border=1>
    <tr>
    <td>Standard<br>
    - sidebar</td>
    <td>
    page.html<p>
    Page content...
    page.html
    (replaced)
    </body>
    gridsitefoot.txt</td>
    </tr>
    - </table>
    Footer text
    </body>
    - -

    -produces pages with a layout like: - -

    - - - - -
    Heading text
    Standard
    sidebar
    Page content...
    Footer text
    - -

    Command line use

    - -

    -GridSite adds support for the HTTP PUT and DELETE methods, and this makes it -easy to create or delete files from within programs and commands without -using a web browser and HTML forms. It is straightforward, although slightly -awkward, to use a standard HTTPS-aware client like -curl to upload files, but GridSite -provides htcp as a more convenient client program, which is easier to use -with GSI Proxies and X.509 user certificates, and has a syntax closer to the -familiar scp command. - -

    -The following examples assume the GridSite server has GSI support and use a -GSI proxy as the client certificate. For non-GSI use, just skip the -grid-proxy-init stage, and replace the proxy -filename with $HOME/.globus/usercert.pem and $HOME/.globus/userkey.pem (or -wherever your PEM format certificate and key are stored.) - -

    -First generate a GSI proxy with grid-proxy-init. This will create a proxy file -in /tmp/x509up_uXXXXX where XXXXX is your Unix UID (also given by id --u.) The GSI proxy contains a -temporary private key and certificate signed by your long-term user -certificate. - -

    -You should make sure you have a copy of the CA root certificates of the CA's -used by the servers you wish to talk to. These are usually installed in -/etc/grid-security/certificates as files like 01621954.0, and RPMs and tar -files for many common European and North American CAs are available from - -https://datagrid.in2p3.fr/distribution/datagrid/security/ - -

    -To upload a file with curl: -

    -curl --cert /tmp/x509up_u`id -n` --key /tmp/x509up_u`id -n` \
    -     --capath /etc/grid-security/certificates \
    -     --upload-file /tmp/new.file.txt https://server/new.file.txt
    -
    - -

    -The equivalent htcp command is: -

    -htcp /tmp/new.file.txt https://server/new.file.txt
    -
    -since htcp looks for the GSI proxy and CA certificates automatically. htcp -can also be used to copy remote files to the local machine by reversing the -arguments. For more details, see the -htcp(1) man page. - -

    -htcp also has options for deleting files, and doing short or long listings, -and these can also be accessed using the htrm, htls and htll commands (which -are normally symbolic links to htcp.) - -

    -Directory indexes are based on parsing the index returned by the web server -and by using the HTTP HEAD method to obtain the file size and modification -times. - -

    -All of the ht** commands can accept multiple source file arguments, and this -allows you to copy multiple files to or from the server. Shell wildcard -expansion on the local machine is especially useful: -

    -htcp /tmp/new.*.txt https://server/
    -
    - - diff --git a/org.gridsite.core/interface/gridsite-gacl.h b/org.gridsite.core/interface/gridsite-gacl.h deleted file mode 100644 index f739c00..0000000 --- a/org.gridsite.core/interface/gridsite-gacl.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - Copyright (c) 2002-4, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/*---------------------------------------------------------------* - * For more about GridSite: http://www.gridsite.org/ * - *---------------------------------------------------------------*/ - -#ifndef HEADER_GACL_H -#define HEADER_GACL_H -#endif - -#ifndef GACL_LIB_VERSION -#define GACL_LIB_VERSION "x.x.x" -#endif - -typedef GRSTgaclCred GACLcred; - -typedef int GACLaction; -typedef unsigned int GACLperm; - -typedef GRSTgaclEntry GACLentry; - -typedef GRSTgaclAcl GACLacl; - -typedef GRSTgaclUser GACLuser; - -extern char *gacl_perm_syms[]; -extern GACLperm gacl_perm_vals[]; - -#define GACL_PERM_NONE GRST_PERM_NONE -#define GACL_PERM_READ GRST_PERM_READ -#define GACL_PERM_LIST GRST_PERM_LIST -#define GACL_PERM_WRITE GRST_PERM_WRITE -#define GACL_PERM_ADMIN GRST_PERM_ADMIN - -#define GACLhasNone(perm) (perm == 0) -#define GACLhasRead(perm) ((perm & GRST_PERM_READ) != 0) -#define GACLhasList(perm) ((perm & GRST_PERM_LIST) != 0) -#define GACLhasWrite(perm) ((perm & GRST_PERM_WRITE) != 0) -#define GACLhasAdmin(perm) ((perm & GRST_PERM_ADMIN) != 0) - -#define GACL_ACTION_ALLOW GRST_ACTION_ALLOW -#define GACL_ACTION_DENY GRST_ACTION_DENY - -#define GACL_ACL_FILE GRST_ACL_FILE -#define GACL_DN_LISTS GRST_DN_LISTS - -#define GACLinit() GRSTgaclInit() - -#define GACLnewCred(x) GRSTgaclCredNew((x)) -/* GACLcred *GACLnewCred(char *); */ - -#define GACLaddToCred(x,y,z) GRSTgaclCredAddValue((x),(y),(z)) -/* int GACLaddToCred(GACLcred *, char *, char *); */ - -#define GACLfreeCred(x) GRSTgaclCredFree((x)) -/* int GACLfreeCred(GACLcred *); */ - -#define GACLaddCred(x,y) GRSTgaclEntryAddCred((x),(y)) -/* int GACLaddCred(GACLentry *, GACLcred *); */ - -#define GACLdelCred(x,y) GRSTgaclEntryDelCred((x),(y)) -/* int GACLdelCred(GACLentry *, GACLcred *); */ - -#define GACLprintCred(x,y) GRSTgaclCredPrint((x),(y)) -/* int GACLprintCred(GACLcred *, FILE *); */ - - -#define GACLnewEntry() GRSTgaclEntryNew() -/* GACLentry *GACLnewEntry(void); */ - -#define GACLfreeEntry(x) GRSTgaclEntryFree((x)) -/* int GACLfreeEntry(GACLentry *); */ - -#define GACLaddEntry(x,y) GRSTgaclAclAddEntry((x),(y)) -/* int GACLaddEntry(GACLacl *, GACLentry *); */ - -#define GACLprintEntry(x,y) GRSTgaclEntryPrint((x),(y)) -/* int GACLprintEntry(GACLentry *, FILE *); */ - - -#define GACLprintPerm(x,y) GRSTgaclPermPrint((x),(y)) -/* int GACLprintPerm(GACLperm, FILE *); */ - -#define GACLallowPerm(x,y) GRSTgaclEntryAllowPerm((x),(y)) -/* int GACLallowPerm(GACLentry *, GACLperm); */ - -#define GACLunallowPerm(x,y) GRSTgaclEntryUnallowPerm((x),(y)) -/* int GACLunallowPerm(GACLentry *, GACLperm); */ - -#define GACLdenyPerm(x,y) GRSTgaclEntryDenyPerm((x),(y)) -/* int GACLdenyPerm(GACLentry *, GACLperm); */ - -#define GACLundenyPerm(x,y) GRSTgaclEntryUndenyPerm((x),(y)) -/* int GACLundenyPerm(GACLentry *, GACLperm); */ - -#define GACLpermToChar(x) GRSTgaclPermToChar((x)) -/* char *GACLpermToChar(GACLperm); */ - -#define GACLcharToPerm(x) GRSTgaclPermFromChar((x)) -/* GACLperm GACLcharToPerm(char *); */ - -#define GACLnewAcl() GRSTgaclAclNew() -/* GACLacl *GACLnewAcl(void); */ - -#define GACLfreeAcl(x) GRSTgaclAclFree((x)) -/* int GACLfreeAcl(GACLacl *); */ - -#define GACLprintAcl(x,y) GRSTgaclAclPrint((x),(y)) -/* int GACLprintAcl(GACLacl *, FILE *); */ - -#define GACLsaveAcl(x,y) GRSTgaclAclSave((y),(x)) -/* int GACLsaveAcl(char *, GACLacl *); */ - -#define GACLloadAcl(x) GRSTgaclAclLoadFile((x)) -/* GACLacl *GACLloadAcl(char *); */ - -#define GACLfindAclForFile(x) GRSTgaclFileFindAclname((x)) -/* char *GACLfindAclForFile(char *); */ - -#define GACLloadAclForFile(x) GRSTgaclAclLoadforFile((x)) -/* GACLacl *GACLloadAclForFile(char *); */ - -#define GACLisAclFile(x) GRSTgaclFileIsAcl((x)) -/* int GACLisAclFile(char *); */ - - -#define GACLnewUser(x) GRSTgaclUserNew((x)) -/* GACLuser *GACLnewUser(GACLcred *); */ - -#define GACLfreeUser(x) GRSTgaclUserFree((x)) -/* int GACLfreeUser(GACLuser *); */ - -#define GACLuserAddCred(x,y) GRSTgaclUserAddCred((x),(y)) -/* int GACLuserAddCred(GACLuser *, GACLcred *); */ - -#define GACLuserHasCred(x,y) GRSTgaclUserHasCred((x),(y)) -/* int GACLuserHasCred(GACLuser *, GACLcred *); */ - -#define GACLuserFindCredType(x,y) GRSTgaclUserFindCredtype((x),(y)) -/* GACLcred *GACLuserFindCredType(GACLuser *, char *); */ - -#define GACLtestDnList(x,y) GRSTgaclDNlistHasUser((x),(y)) -/* int GACLtestDnList(char *, GACLuser *); */ - -#define GACLtestUserAcl(x,y) GRSTgaclAclTestUser((x),(y)) -/* GACLperm GACLtestUserAcl(GACLacl *, GACLuser *); */ - -#define GACLtestExclAcl(x,y) GRSTgaclAclTestexclUser((x),(y)) -/* GACLperm GACLtestExclAcl(GACLacl *, GACLuser *); */ - - -#define GACLurlEncode(x) GRSThttpUrlEncode((x)) -/* char *GACLurlEncode(char *); */ - -#define GACLmildUrlEncode(x) GRSThttpUrlMildencode((x)) -/* char *GACLmildUrlEncode(char *); */ - -GACLentry *GRSTgaclEntryParse(xmlNodePtr cur); -/* special function for legacy EDG LB service */ diff --git a/org.gridsite.core/interface/gridsite.h b/org.gridsite.core/interface/gridsite.h deleted file mode 100644 index febda2c..0000000 --- a/org.gridsite.core/interface/gridsite.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - Copyright (c) 2002-3, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/*---------------------------------------------------------------* - * For more about GridSite: http://www.gridsite.org/ * - *---------------------------------------------------------------*/ - -#ifndef HEADER_SSL_H -#include -#endif - -#ifndef HEADER_CRYPTO_H -#include -#endif - -#ifndef FALSE -#define FALSE (0) -#endif -#ifndef TRUE -#define TRUE (!FALSE) -#endif - -/// Everything ok (= OpenSSL X509_V_OK) -#define GRST_RET_OK 0 - -/// Failed for unspecified reason -#define GRST_RET_FAILED 1000 - -/// Failed to find certificate in some cert store / directory -#define GRST_RET_CERT_NOT_FOUND 1001 - -/// Bad signature -#define GRST_RET_BAD_SIGNATURE 1002 - -/// No such file or directory -#define GRST_RET_NO_SUCH_FILE 1003 - -#define GRST_PROXYCERTINFO_OID "1.3.6.1.4.1.3536.1.222" -#define GRST_VOMS_OID "1.3.6.1.4.1.8005.100.100.1" -#define GRST_VOMS_DIR "/etc/grid-security/vomsdir" - - - -typedef struct { char *name; - char *value; - void *next; } GRSTgaclNamevalue; - -typedef struct { char *type; - int delegation; - GRSTgaclNamevalue *firstname; - void *next; } GRSTgaclCred; - -typedef int GRSTgaclAction; -typedef unsigned int GRSTgaclPerm; - -typedef struct { GRSTgaclCred *firstcred; - GRSTgaclPerm allowed; - GRSTgaclPerm denied; - void *next; } GRSTgaclEntry; - -typedef struct { GRSTgaclEntry *firstentry; } GRSTgaclAcl; - -typedef struct { GRSTgaclCred *firstcred; - char *dnlists; } GRSTgaclUser; - -#define GRST_PERM_NONE 0 -#define GRST_PERM_READ 1 -#define GRST_PERM_EXEC 2 -#define GRST_PERM_LIST 4 -#define GRST_PERM_WRITE 8 -#define GRST_PERM_ADMIN 16 -#define GRST_PERM_ALL 31 - -/* DO NOT USE PermIsNone!! */ -#define GRSTgaclPermIsNone(perm) (perm == 0) - -#define GRSTgaclPermHasNone(perm) (perm == 0) -#define GRSTgaclPermHasRead(perm) ((perm & GRST_PERM_READ ) != 0) -#define GRSTgaclPermHasExec(perm) ((perm & GRST_PERM_EXEC ) != 0) -#define GRSTgaclPermHasList(perm) ((perm & GRST_PERM_LIST ) != 0) -#define GRSTgaclPermHasWrite(perm) ((perm & GRST_PERM_WRITE) != 0) -#define GRSTgaclPermHasAdmin(perm) ((perm & GRST_PERM_ADMIN) != 0) - -#define GRST_ACTION_ALLOW 0 -#define GRST_ACTION_DENY 1 - -#define GRST_HIST_PREFIX ".grsthist" -#define GRST_ACL_FILE ".gacl" -#define GRST_DN_LISTS "/etc/grid-security/dn-lists" -#define GRST_RECURS_LIMIT 9 - -int GRSTgaclInit(void); - -/* #define GACLnewCred(x) GRSTgaclCredNew((x)) */ -GRSTgaclCred *GRSTgaclCredNew(char *); - -/* #define GACLaddToCred(x,y,z) GRSTgaclCredAddValue((x),(y),(z)) */ -int GRSTgaclCredAddValue(GRSTgaclCred *, char *, char *); - -#define GRSTgaclCredSetDelegation(cred, level) ((cred)->delegation = (level)) -#define GRSTgaclCredGetDelegation(cred) ((cred)->delegation) - -/* #define GACLfreeCred(x) GRSTgaclCredFree((x)) */ -int GRSTgaclCredFree(GRSTgaclCred *); - -/* #define GACLaddCred(x,y) GRSTgaclEntryAddCred((x),(y)) */ -int GRSTgaclEntryAddCred(GRSTgaclEntry *, GRSTgaclCred *); - -/* #define GACLdelCred(x,y) GRSTgaclEntryDelCred((x),(y)) */ -int GRSTgaclEntryDelCred(GRSTgaclEntry *, GRSTgaclCred *); - -/* #define GACLprintCred(x,y) GRSTgaclCredPrint((x),(y)) */ -int GRSTgaclCredCredPrint(GRSTgaclCred *, FILE *); - - -/* #define GACLnewEntry(x) GRSTgaclEntryNew((x)) */ -GRSTgaclEntry *GRSTgaclEntryNew(void); - -/* #define GACLfreeEntry(x) GRSTgaclEntryFree((x)) */ -int GRSTgaclEntryFree(GRSTgaclEntry *); - -/* #define GACLaddEntry(x,y) GRSTgaclAclAddEntry((x),(y)) */ -int GRSTgaclAclAddEntry(GRSTgaclAcl *, GRSTgaclEntry *); - -/* #define GACLprintEntry(x,y) GRSTgaclEntryPrint((x),(y)) */ -int GRSTgaclEntryPrint(GRSTgaclEntry *, FILE *); - - -/* #define GACLprintPerm(x,y) GRSTgaclPermPrint((x),(y)) */ -int GRSTgaclPermPrint(GRSTgaclPerm, FILE *); - -/* #define GACLallowPerm(x,y) GRSTgaclEntryAllowPerm((x),(y)) */ -int GRSTgaclEntryAllowPerm(GRSTgaclEntry *, GRSTgaclPerm); - -/* #define GACLunallowPerm(x,y) GRSTgaclEntryUnallowPerm((x),(y)) */ -int GRSTgaclEntryUnallowPerm(GRSTgaclEntry *, GRSTgaclPerm); - -/* #define GACLdenyPerm(x,y) GRSTgaclEntryDenyPerm((x),(y)) */ -int GRSTgaclEntryDenyPerm(GRSTgaclEntry *, GRSTgaclPerm); - -/* #define GACLundenyPerm(x,y) GRSTgaclEntryUndenyPerm((x),(y)) */ -int GRSTgaclUndenyPerm(GRSTgaclEntry *, GRSTgaclPerm); - -/* #define GACLpermToChar(x) GRSTgaclPermToChar((x)) */ -char *GRSTgaclPermToChar(GRSTgaclPerm); - -/* #define GACLcharToPerm(x) GRSTgaclPermFromChar((x)) */ -GRSTgaclPerm GRSTgaclPermFromChar(char *); - -/* #define GACLnewAcl(x) GRSTgaclAclNew((x)) */ -GRSTgaclAcl *GRSTgaclAclNew(void); - -/* #define GACLfreeAcl(x) GRSTgaclAclFree((x)) */ -int GRSTgaclAclFree(GRSTgaclAcl *); - -/* #define GACLprintAcl(x,y) GRSTgaclAclPrint((x),(y)) */ -int GRSTgaclAclPrint(GRSTgaclAcl *, FILE *); - -/* #define GACLsaveAcl(x,y) GRSTgaclAclSave((y),(x)) */ -int GRSTgaclAclSave(GRSTgaclAcl *, char *); - -/* #define GACLloadAcl(x) GRSTgaclFileLoadAcl((x)) */ -GRSTgaclAcl *GRSTgaclAclLoadFile(char *); - -/* #define GACLfindAclForFile(x) GRSTgaclFileFindAclname((x)) */ -char *GRSTgaclFileFindAclname(char *); - -/* #define GACLloadAclForFile(x) GRSTgaclFileLoadAcl((x)) */ -GRSTgaclAcl *GRSTgaclAclLoadforFile(char *); - -/* #define GACLisAclFile(x) GRSTgaclFileIsAcl((x)) */ -int GRSTgaclFileIsAcl(char *); - - -/* #define GACLnewUser(x) GRSTgaclUserNew((x)) */ -GRSTgaclUser *GRSTgaclUserNew(GRSTgaclCred *); - -/* #define GACLfreeUser(x) GRSTgaclUserFree((x)) */ -int GRSTgaclUserFree(GRSTgaclUser *); - -/* #define GACLuserAddCred(x,y) GRSTgaclUserAddCred((x),(y)) */ -int GRSTgaclUserAddCred(GRSTgaclUser *, GRSTgaclCred *); - -/* #define GACLuserHasCred(x,y) GRSTgaclUserHasCred((x),(y)) */ -int GRSTgaclUserHasCred(GRSTgaclUser *, GRSTgaclCred *); - -int GRSTgaclUserSetDNlists(GRSTgaclUser *, char *); - -/* #define GACLuserFindCredType(x,y) GRSTgaclUserFindCredtype((x),(y)) */ -GRSTgaclCred *GRSTgaclUserFindCredtype(GRSTgaclUser *, char *); - -/* #define GACLtestDnList(x,y) GRSTgaclDNlistHasUser((x),(y)) */ -int GRSTgaclDNlistHasUser(char *, GRSTgaclUser *); - -/* #define GACLtestUserAcl(x,y) GRSTgaclAclTestUser((x),(y)) */ -GRSTgaclPerm GRSTgaclAclTestUser(GRSTgaclAcl *, GRSTgaclUser *); - -/* #define GACLtestExclAcl(x,y) GRSTgaclAclTestexclUser((x),(y)) */ -GRSTgaclPerm GRSTgaclAclTestexclUser(GRSTgaclAcl *, GRSTgaclUser *); - - -char *GRSThttpUrlDecode(char *); - -/* #define GACLurlEncode(x) GRSThttpUrlEncode((x)) */ -char *GRSThttpUrlEncode(char *); - -/* #define GACLmildUrlEncode(x) GRSThttpMildUrlEncode((x)) */ -char *GRSThttpUrlMildencode(char *); - -int GRSTx509NameCmp(char *, char *); - -int GRSTx509KnownCriticalExts(X509 *); - -time_t GRSTasn1TimeToTimeT(char *); -int GRSTx509IsCA(X509 *); -int GRSTx509CheckChain(int *, X509_STORE_CTX *); -int GRSTx509VerifyCallback(int, X509_STORE_CTX *); - -int GRSTx509GetVomsCreds(int *, int, size_t, char *, X509 *, STACK_OF(X509) *, char *); -GRSTgaclCred *GRSTx509CompactToCred(char *); -int GRSTx509CompactCreds(int *, int, size_t, char *, STACK_OF(X509) *, char *); -char *GRSTx509CachedProxyFind(char *, char *, char *); -char *GRSTx509FindProxyFileName(void); -int GRSTx509MakeProxyCert(char **, FILE *, char *, char *, char *, int); -char *GRSTx509CachedProxyKeyFind(char *, char *, char *); -int GRSTx509MakeProxyRequest(char **, char *, char *, char *); -int GRSTx509CacheProxy(char *, char *, char *, char *); - -#define GRST_HEADFILE "gridsitehead.txt" -#define GRST_FOOTFILE "gridsitefoot.txt" -#define GRST_ADMIN_FILE "gridsite-admin.cgi" - -typedef struct { char *text; - void *next; } GRSThttpCharsList; - -typedef struct { size_t size; - GRSThttpCharsList *first; - GRSThttpCharsList *last; } GRSThttpBody; - -void GRSThttpBodyInit(GRSThttpBody *); -void GRSThttpPrintf(GRSThttpBody *, char *, ...); -int GRSThttpCopy(GRSThttpBody *, char *); -void GRSThttpWriteOut(GRSThttpBody *); -int GRSThttpPrintHeaderFooter(GRSThttpBody *, char *, char *); -char *GRSThttpGetCGI(char *); diff --git a/org.gridsite.core/project/build.properties b/org.gridsite.core/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/org.gridsite.core/project/configure.properties.xml b/org.gridsite.core/project/configure.properties.xml deleted file mode 100644 index 6ee8706..0000000 --- a/org.gridsite.core/project/configure.properties.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/org.gridsite.core/project/dependencies.properties b/org.gridsite.core/project/dependencies.properties deleted file mode 100644 index 2a7383b..0000000 --- a/org.gridsite.core/project/dependencies.properties +++ /dev/null @@ -1,9 +0,0 @@ -################################################################### -# System dependencies -################################################################### - -org.glite.version = HEAD -org.glite.core.version = HEAD - -# Component dependencies tag = do not remove this line = - diff --git a/org.gridsite.core/project/gridsite.core.csf.xml b/org.gridsite.core/project/gridsite.core.csf.xml deleted file mode 100644 index 7ca38dc..0000000 --- a/org.gridsite.core/project/gridsite.core.csf.xml +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The org.glite and org.gridsite.core modules have been updated, please rerun the configuration file - - - - The org.glite and org.gridsite.core modules have been updated, please rerun the configuration file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.gridsite.core/project/properties.xml b/org.gridsite.core/project/properties.xml deleted file mode 100644 index 74f88dc..0000000 --- a/org.gridsite.core/project/properties.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.gridsite.core/project/taskdefs.xml b/org.gridsite.core/project/taskdefs.xml deleted file mode 100644 index 9c35cef..0000000 --- a/org.gridsite.core/project/taskdefs.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/org.gridsite.core/project/version.properties b/org.gridsite.core/project/version.properties deleted file mode 100644 index a53595e..0000000 --- a/org.gridsite.core/project/version.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Dec 09 02:04:57 CET 2004 -module.version=1.1.3 -module.build=70 -module.age=2 diff --git a/org.gridsite.core/src/Doxyfile b/org.gridsite.core/src/Doxyfile deleted file mode 100644 index e47d005..0000000 --- a/org.gridsite.core/src/Doxyfile +++ /dev/null @@ -1,993 +0,0 @@ -# Doxyfile 1.2.18 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, -# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en -# (Japanese with english messages), Korean, Norwegian, Polish, Portuguese, -# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these class will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited -# members of a class in the documentation of that class as if those members were -# ordinary class members. Constructors, destructors and assignment operators of -# the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. It is allowed to use relative paths in the argument list. - -STRIP_FROM_PATH = - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower case letters. If set to YES upper case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# users are adviced to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explict @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# reimplements. - -INHERIT_DOCS = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consist of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. -# For instance some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. -# For instance namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp -# *.h++ *.idl *.odl - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories -# that are symbolic links (a Unix filesystem feature) are excluded from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. - -INPUT_FILTER = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = doxygen - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet - -HTML_STYLESHEET = doxygen.css - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output dir. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non empty doxygen will try to run -# the html help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the Html help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = YES - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript and frames is required (for instance Mozilla, Netscape 4.0+, -# or Internet explorer 4.0+). Note that for large projects the tree generation -# can take a very long time. In such cases it is better to disable this feature. -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimised for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assigments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_XML = NO - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = NO - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse the -# parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES tag can be used to specify one or more tagfiles. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or -# super classes. Setting the tag to NO turns the diagrams off. Note that this -# option is superceded by the HAVE_DOT option below. This is only a fallback. It is -# recommended to install and use dot, since it yield more powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found on the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermedate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO - -# The CGI_NAME tag should be the name of the CGI script that -# starts the search engine (doxysearch) with the correct parameters. -# A script with this name will be generated by doxygen. - -CGI_NAME = search.cgi - -# The CGI_URL tag should be the absolute URL to the directory where the -# cgi binaries are located. See the documentation of your http daemon for -# details. - -CGI_URL = - -# The DOC_URL tag should be the absolute URL to the directory where the -# documentation is located. If left blank the absolute path to the -# documentation, with file:// prepended to it, will be used. - -DOC_URL = - -# The DOC_ABSPATH tag should be the absolute path to the directory where the -# documentation is located. If left blank the directory on the local machine -# will be used. - -DOC_ABSPATH = - -# The BIN_ABSPATH tag must point to the directory where the doxysearch binary -# is installed. - -BIN_ABSPATH = /usr/local/bin/ - -# The EXT_DOC_PATHS tag can be used to specify one or more paths to -# documentation generated for other projects. This allows doxysearch to search -# the documentation for these projects as well. - -EXT_DOC_PATHS = diff --git a/org.gridsite.core/src/Makefile b/org.gridsite.core/src/Makefile deleted file mode 100644 index bd66586..0000000 --- a/org.gridsite.core/src/Makefile +++ /dev/null @@ -1,280 +0,0 @@ -# -# Andrew McNab and Shiv Kaushal, University of Manchester. -# Copyright (c) 2002-4. All rights reserved. -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# o Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# o Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -#--------------------------------------------------------------- -# For more information about GridSite: http://www.gridsite.org/ -#--------------------------------------------------------------- - -include ../VERSION - -RPMCMD=$(shell if [ -x /usr/bin/rpmbuild ] ; then echo /usr/bin/rpmbuild; else echo rpm; fi) - -ifndef MYRPMDIR -export MYRPMDIR=$(shell pwd)/../RPMTMP -endif - -ifndef prefix -export prefix=/usr/local -endif - -ifndef MYCFLAGS -export MYCFLAGS=-I. -I../interface -I/usr/include/httpd -I/usr/include/apr-0 -I/opt/glite/include -endif - -ifndef OPENSSL_FLAGS -export OPENSSL_FLAGS=-I/usr/include/openssl -endif - -ifndef MYLDFLAGS -export MYLDFLAGS=-L. -# export MYLDFLAGS=-L. -L/opt/glite/lib -lvomsc -endif - -ifndef OPENSSL_LIBS -export OPENSSL_LIBS=-L/usr/lib/openssl -endif - -# -# Build -# - -build: libgridsite.so.$(VERSION) libgridsite.a htcp mod_gridsite.so \ - urlencode findproxyfile real-gridsite-admin.cgi \ - # gridsite-delegation.cgi # htproxyput - -libgridsite.so.$(VERSION): grst_x509.o grst_gacl.o grst_http.o - gcc -shared -Wl,-soname,libgridsite.so.$(MINOR_VERSION) \ - -o libgridsite.so.$(PATCH_VERSION) grst_x509.o grst_gacl.o grst_http.o - -libgridsite.a: grst_x509.o grst_gacl.o grst_http.o - ar src libgridsite.a grst_x509.o grst_gacl.o grst_http.o - -grst_x509.o: grst_x509.c ../interface/gridsite.h - gcc $(MYCFLAGS) $(OPENSSL_FLAGS) \ - -I/usr/kerberos/include -c grst_x509.c - -grst_gacl.o: grst_gacl.c ../interface/gridsite.h - gcc $(MYCFLAGS) $(OPENSSL_FLAGS) \ - -I/usr/kerberos/include `xml2-config --cflags` -c grst_gacl.c - -grst_http.o: grst_http.c ../interface/gridsite.h - gcc $(MYCFLAGS) $(OPENSSL_FLAGS) \ - -I/usr/kerberos/include -c grst_http.c - -urlencode: urlencode.c libgridsite.a - gcc -DVERSION=\"$(PATCH_VERSION)\" $(MYCFLAGS) \ - -o urlencode urlencode.c -L. \ - $(OPENSSL_FLAGS) -I/usr/kerberos/include -lgridsite - -htcp: htcp.c - gcc -DVERSION=\"$(PATCH_VERSION)\" -I. -o htcp htcp.c \ - `curl-config --cflags` `curl-config --libs` - -mod_gridsite.so: mod_gridsite.c mod_ssl-private.h libgridsite.a - gcc $(MYCFLAGS) -shared -Wl,-soname=gridsite_module \ - $(OPENSSL_FLAGS) -I/usr/kerberos/include \ - -I/usr/include/libxml2 \ - -DVERSION=\"$(VERSION)\" -o mod_gridsite.so \ - mod_gridsite.c $(MYLDFLAGS) -lxml2 -lm -lz -lgridsite - -real-gridsite-admin.cgi: grst_admin_main.c grst_admin_gacl.c \ - grst_admin_file.c grst_admin.h - gcc $(MYCFLAGS) $(MYLDFLAGS) -o real-gridsite-admin.cgi \ - grst_admin_main.c \ - grst_admin_gacl.c \ - grst_admin_file.c \ - $(OPENSSL_FLAGS) -I/usr/kerberos/include \ - -DVERSION=\"$(VERSION)\" $(OPENSSL_LIBS) -lgridsite -lssl -lcrypto -lxml2 -lz -lm - -findproxyfile: findproxyfile.c libgridsite.a - gcc -DVERSION=\"$(PATCH_VERSION)\" $(MYCFLAGS) $(MYLDFLAGS) \ - -o findproxyfile findproxyfile.c -L. \ - $(OPENSSL_FLAGS) -I/usr/kerberos/include -lgridsite \ - $(OPENSSL_LIBS) -lssl -lcrypto -lxml2 -lz -lm - -apidoc: - doxygen Doxyfile - -gaclexample: gaclexample.c libgridsite.a - gcc -o gaclexample gaclexample.c -I. -L. \ - $(OPENSSL_FLAGS) -I/usr/kerberos/include -lgridsite \ - -lssl -lcrypto -lxml2 -lz -lm - -# -# Delegation machinery, including SOAP delegation portType. To build this -# you need to install gSOAP and set GSOAPDIR to the directory containing -# soapcpp2 and stdsoap2.h (unless GSOAPDIR is set already) -# - -ifndef GSOAPDIR -export GSOAPDIR=/usr/local/lib/gsoap -endif - -delegation.wsdl: delegation.h - ls -lR $(GSOAPDIR) - $(GSOAPDIR)/bin/soapcpp2 -c delegation.h - -libstdsoap2.a: $(GSOAPDIR)/stdsoap2.c - gcc -c -DWITH_OPENSSL $(GSOAPDIR)/stdsoap2.c - ar src libstdsoap2.a stdsoap2.o - -gridsite-delegation.cgi: grst-delegation.c delegation.h delegation.wsdl \ - soapC.c soapServer.c - gcc $(MYCFLAGS) $(MYLDFLAGS) -o gridsite-delegation.cgi \ - grst-delegation.c \ - $(OPENSSL_FLAGS) -I/usr/kerberos/include -I$(GSOAPDIR)/include \ - -DVERSION=\"$(VERSION)\" -L$(GSOAPDIR)/lib \ - soapC.c soapServer.c -lgsoap \ - -lgridsite -lcurl -lz -lssl -lcrypto -lxml2 -lm - -htproxyput: htproxyput.c delegation.h delegation.wsdl \ - soapC.c soapServer.c - gcc $(MYCFLAGS) $(MYLDFLAGS) -o htproxyput \ - htproxyput.c \ - $(OPENSSL_FLAGS) -I/usr/kerberos/include \ - -g -DVERSION=\"$(VERSION)\" \ - -I$(GSOAPDIR)/include -DWITH_OPENSSL -L$(GSOAPDIR)/lib \ - soapC.c soapClient.c -lgsoap \ - -lgridsite -lcurl -lz -lssl -lcrypto -lxml2 -lm - -proxyput-example: proxyput-example.c delegation.h delegation.wsdl \ - soapC.c soapServer.c libstdsoap2.a - gcc $(MYCFLAGS) $(MYLDFLAGS) -o proxyput-example \ - proxyput-example.c \ - $(OPENSSL_FLAGS) -I/usr/kerberos/include \ - -g -DVERSION=\"$(VERSION)\" \ - -I$(GSOAPDIR) -DWITH_OPENSSL \ - soapC.c soapClient.c libstdsoap2.a \ - -lgridsite -lcurl -lz -lssl -lcrypto -lxml2 -lm - -clean: - -# -# Install -# - -install: apidoc - mkdir -p $(prefix)/include \ - $(prefix)/lib \ - $(prefix)/bin \ - $(prefix)/sbin \ - $(prefix)/share/man/man1 \ - $(prefix)/lib/httpd/modules \ - $(prefix)/share/doc/gridsite-$(PATCH_VERSION) - cp -f ../interface/gridsite.h $(prefix)/include - cp -f ../interface/gridsite-gacl.h $(prefix)/include - cp -f urlencode $(prefix)/bin - cp -f findproxyfile $(prefix)/bin - cp -f libgridsite.a $(prefix)/lib - cp -f real-gridsite-admin.cgi $(prefix)/sbin - cp -f libgridsite.so.$(PATCH_VERSION) $(prefix)/lib - ln -sf libgridsite.so.$(PATCH_VERSION) \ - $(prefix)/lib/libgridsite.so - ln -sf libgridsite.so.$(PATCH_VERSION) \ - $(prefix)/lib/libgridsite.so.$(MAJOR_VERSION) - ln -sf libgridsite.so.$(PATCH_VERSION) \ - $(prefix)/lib/libgridsite.so.$(MINOR_VERSION) - cp -f doxygen/index.html \ - $(prefix)/share/doc/gridsite-$(PATCH_VERSION)/doxygen-index.html - cp -f doxygen/* $(prefix)/share/doc/gridsite-$(PATCH_VERSION) - cp -f ../CHANGES ../README ../INSTALL ../LICENSE ../VERSION \ - $(prefix)/share/doc/gridsite-$(PATCH_VERSION) - cp -f ../doc/*.html ../doc/*.conf ../doc/*.1 ../doc/*.sh \ - $(prefix)/share/doc/gridsite-$(VERSION) - cp -f ../doc/*.1 $(prefix)/share/man/man1 - gzip -f $(prefix)/share/man/man1/*.1 - cd ../doc ; for i in *.1 ; do ../src/roffit < $$i \ - > $(prefix)/share/doc/gridsite-$(VERSION)/$$i.html ; done - cp -f htcp $(prefix)/bin - ln -sf htcp $(prefix)/bin/htls - ln -sf htcp $(prefix)/bin/htll - ln -sf htcp $(prefix)/bin/htrm - ln -sf htcp $(prefix)/bin/htmkdir - cp -f mod_gridsite.so $(prefix)/lib/httpd/modules - -# -# Distributions -# - -# source files tarball -dist: - mkdir -p ../gridsite-$(PATCH_VERSION)/src \ - ../gridsite-$(PATCH_VERSION)/doc \ - ../gridsite-$(PATCH_VERSION)/interface - cp -f ../VERSION ../README ../LICENSE ../CHANGES ../INSTALL \ - ../gridsite-$(PATCH_VERSION) - cp -f Makefile grst*.c htproxyput.c proxyput-example.c htcp.c \ - urlencode.c findproxyfile.c gaclexample.c mod_gridsite.c \ - delegation.h grst_admin.h mod_ssl-private.h \ - roffit gridsite.spec \ - Doxyfile doxygen.css doxyheader.html \ - ../gridsite-$(PATCH_VERSION)/src - cp -f ../doc/*.html ../doc/*.1 ../doc/*.conf ../doc/*.sh \ - ../gridsite-$(PATCH_VERSION)/doc - cp -f ../interface/*.h \ - ../gridsite-$(PATCH_VERSION)/interface - cd .. ; tar zcvf gridsite-$(PATCH_VERSION).src.tar.gz \ - gridsite-$(PATCH_VERSION) - rm -Rf ../gridsite-$(PATCH_VERSION) - - -# binary tarball distribution for htcp users -htcp-bin: htcp - mkdir -p ../htcp-bin-$(PATCH_VERSION)/bin \ - ../htcp-bin-$(PATCH_VERSION)/man/man1 - cp -f ../doc/README.htcp-bin ../htcp-bin-$(PATCH_VERSION) - cp -f htcp ../htcp-bin-$(PATCH_VERSION)/bin - cp -f ../doc/htcp.1 ../doc/htrm.1 ../doc/htls.1 ../doc/htll.1 \ - ../doc/htmkdir.1 ../htcp-bin-$(PATCH_VERSION)/man/man1 - ln -sf htcp ../htcp-bin-$(PATCH_VERSION)/bin/htls - ln -sf htcp ../htcp-bin-$(PATCH_VERSION)/bin/htll - ln -sf htcp ../htcp-bin-$(PATCH_VERSION)/bin/htrm - ln -sf htcp ../htcp-bin-$(PATCH_VERSION)/bin/htmkdir - cd ../htcp-bin-$(VERSION) ; tar zcvf ../htcp-$(VERSION).bin.tar.gz . - rm -Rf ../htcp-bin-$(PATCH_VERSION) - -# RPM targets: build and RPMs go into subdirectories of ../RPMTMP/ -rpm: dist gridsite.spec - rm -Rf $(MYRPMDIR)/BUILDROOT $(MYRPMDIR)/BUILD - mkdir -p $(MYRPMDIR)/SOURCES $(MYRPMDIR)/SPECS $(MYRPMDIR)/BUILD \ - $(MYRPMDIR)/SRPMS $(MYRPMDIR)/RPMS/i386 $(MYRPMDIR)/BUILDROOT - cp -f ../gridsite-$(PATCH_VERSION).src.tar.gz $(MYRPMDIR)/SOURCES - cp -f gridsite.spec $(MYRPMDIR)/SPECS - export MYPREFIX=/usr ; export MYVERSION=$(PATCH_VERSION) ; \ - $(RPMCMD) --define "_topdir $(MYRPMDIR)" \ - -ba --buildroot $(MYRPMDIR)/BUILDROOT gridsite.spec - - -wtf: - pwd - printenv - ls -l - ls -lR /usr/local/ - diff --git a/org.gridsite.core/src/delegation.h b/org.gridsite.core/src/delegation.h deleted file mode 100644 index e612498..0000000 --- a/org.gridsite.core/src/delegation.h +++ /dev/null @@ -1,12 +0,0 @@ -//gsoap ns service name: delegation -//gsoap ns service style: rpc -//gsoap ns service encoding: encoded -//gsoap ns service namespace: http://www.gridsite.org/ns/delegation.wsdl -//gsoap ns service location: http://localhost/delegserver.cgi - -struct ns__putProxyResponse { } ; - -//gsoap ns schema namespace: urn:delegation -int ns__getProxyReq(char *delegationID, char **request); -int ns__putProxy(char *delegationID, char *proxy, - struct ns__putProxyResponse *unused); diff --git a/org.gridsite.core/src/doxygen.css b/org.gridsite.core/src/doxygen.css deleted file mode 100644 index 97ebc25..0000000 --- a/org.gridsite.core/src/doxygen.css +++ /dev/null @@ -1,49 +0,0 @@ -H1 { text-align: center; } -CAPTION { font-weight: bold } -A.qindex {} -A.qindexRef {} -A.el { text-decoration: none; font-weight: bold } -A.elRef { font-weight: bold } -A.code { text-decoration: none; font-weight: normal; color: #4444ee } -A.codeRef { font-weight: normal; color: #4444ee } -A:hover { text-decoration: none; background-color: #f2f2ff } -DL.el { margin-left: -1cm } -DIV.fragment { width: 100%; border: none; background-color: #eeeeee } -DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } -TD.md { background-color: #f2f2ff; font-weight: bold; } -TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; } -TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; } -DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold } -DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller } -XXBODY { background: white } -TD.indexkey { - background-color: #eeeeff; - font-weight: bold; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px -} -TD.indexvalue { - background-color: #eeeeff; - font-style: italic; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px -} -span.keyword { color: #008000 } -span.keywordtype { color: #604020 } -span.keywordflow { color: #e08000 } -span.comment { color: #800000 } -span.preprocessor { color: #806020 } -span.stringliteral { color: #002080 } -span.charliteral { color: #008080 } diff --git a/org.gridsite.core/src/doxyheader.html b/org.gridsite.core/src/doxyheader.html deleted file mode 100644 index af78b52..0000000 --- a/org.gridsite.core/src/doxyheader.html +++ /dev/null @@ -1 +0,0 @@ -

    GridSite Version 1.1.x diff --git a/org.gridsite.core/src/findproxyfile.c b/org.gridsite.core/src/findproxyfile.c deleted file mode 100644 index 4485cc5..0000000 --- a/org.gridsite.core/src/findproxyfile.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - Copyright (c) 2002-4, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef VERSION -#define VERSION "0.0.0" -#endif - -#define _GNU_SOURCE - -#include -#include -#include -#include - -#include - -#include "gridsite.h" - -void printsyntax(char *argv0) -{ - char *p; - - p = rindex(argv0, '/'); - if (p != NULL) ++p; - else p = argv0; - - fprintf(stderr, "%s [--outsidecache] [--proxycache=PATH] " - "[--delegation-id=DELEGATION-ID] [--user-dn=USER-DN]\n" - "(Version: %s)\n", p, VERSION); -} - -#define GRST_PROXY_CACHE "/var/www/proxycache" - -int main(int argc, char *argv[]) -{ - char *delegation_id = "_", *proxycache = "", *user_dn = "", - *proxyfile = NULL; - int c, outsidecache = 0, verbose = 0, option_index; - struct option long_options[] = { {"verbose", 0, 0, 'v'}, - {"outsidecache", 0, 0, 0}, - {"proxycache", 1, 0, 0}, - {"delegation-id", 1, 0, 0}, - {"user-dn", 1, 0, 0}, - {0, 0, 0, 0} }; - - if (argc == 1) - { - printsyntax(argv[0]); - return 0; - } - - while (1) - { - option_index = 0; - - c = getopt_long(argc, argv, "v", long_options, &option_index); - - if (c == -1) break; - else if (c == 0) - { - if (option_index == 1) outsidecache = 1; - else if (option_index == 2) proxycache = optarg; - else if (option_index == 3) delegation_id = optarg; - else if (option_index == 4) user_dn = optarg; - } - else if (c == 'v') ++verbose; - } - - if (*user_dn != '\0') /* try to find in proxy cache */ - { - if ((proxycache == NULL) || (*proxycache == '\0')) - proxycache = getenv("GRST_PROXY_CACHE"); - - if ((proxycache == NULL) || (*proxycache == '\0')) - proxycache = GRST_PROXY_CACHE; - - proxyfile = GRSTx509CachedProxyFind(proxycache, delegation_id, user_dn); - } - - if (((proxyfile == NULL) || (*proxyfile == '\0')) && outsidecache) - { - proxyfile = GRSTx509FindProxyFileName(); - } - - if ((proxyfile != NULL) && (*proxyfile != '\0')) - { - puts(proxyfile); - return 0; - } - - fputs("No proxy file found\n", stderr); - - return 1; -} diff --git a/org.gridsite.core/src/gaclexample.c b/org.gridsite.core/src/gaclexample.c deleted file mode 100644 index 5ad29b7..0000000 --- a/org.gridsite.core/src/gaclexample.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - Copyright (c) 2002-3, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/*---------------------------------------------------------------* - * For more about GridSite: http://www.gridsite.org/ * - *---------------------------------------------------------------*/ - -/* - Example program using GACL - - Build with: - - gcc -o gaclexample gaclexample.c -L. -I. -lgridsite -lxml2 -lz -lm -*/ - -#include -#include -#include -#include - -int main() -{ - GRSTgaclCred *cred, *usercred; - GRSTgaclEntry *entry; - GRSTgaclAcl *acl1, *acl2; - GRSTgaclUser *user; - GRSTgaclPerm perm0, perm1, perm2; - FILE *fp; - - /* must initialise GACL before using it */ - - GRSTgaclInit(); - - /* build up an ACL, starting with a credential */ - - cred = GRSTgaclCredNew("person"); - - GRSTgaclCredAddValue(cred, "dn", "/O=Grid/CN=Mr Grid Person"); - - /* create an entry to put it in */ - - entry = GRSTgaclEntryNew(); - - /* add the credential to it */ - - GRSTgaclEntryAddCred(entry, cred); - - /* add another credential */ - - cred = GRSTgaclCredNew("dn-list"); - GRSTgaclCredAddValue(cred, "url", "example-dn-list"); - GRSTgaclEntryAddCred(entry, cred); - - fp = fopen("example-dn-list", "w"); - fputs("/O=Grid/CN=Mr Grid Person\n", fp); - fclose(fp); - - /* associate some permissions and denials to the credential */ - - GRSTgaclEntryAllowPerm( entry, GRST_PERM_READ); - GRSTgaclEntryAllowPerm( entry, GRST_PERM_WRITE); - GRSTgaclEntryAllowPerm( entry, GRST_PERM_ADMIN); - GRSTgaclEntryDenyPerm( entry, GRST_PERM_ADMIN); - GRSTgaclEntryDenyPerm( entry, GRST_PERM_LIST); - - perm0 = GRST_PERM_READ | GRST_PERM_WRITE; - - printf("test perm should be %d\n", perm0); - - /* create a new ACL and add the entry to it */ - - acl1 = GRSTgaclAclNew(); - - GRSTgaclAclAddEntry(acl1, entry); - - /* create a GRSTgaclUser to compare with the ACL */ - - usercred = GRSTgaclCredNew("person"); - - GRSTgaclCredAddValue(usercred, "dn", "/O=Grid/CN=Mr Grid Person"); - - user = GRSTgaclUserNew(usercred); - - GRSTgaclUserSetDNlists(user, getcwd(NULL, 0)); - printf("DN Lists dir %s\n", getcwd(NULL, 0)); - -// putenv("GRST_DN_LISTS=."); - - perm1 = GRSTgaclAclTestUser(acl1, user); - - printf("test /O=Grid/CN=Mr Grid Person in acl = %d\n", perm1); - - /* print and save the whole ACL */ - - GRSTgaclAclPrint(acl1, stdout); - - GRSTgaclAclSave(acl1, "example.gacl"); - - puts("gridacl.out saved"); - - puts(""); - - /* load the ACL back off the disk, print and test it */ - - acl2 = GRSTgaclAclLoadFile("example.gacl"); - - puts("gridacl.out loaded"); - - if (acl2 != NULL) GRSTgaclAclPrint(acl2, stdout); else puts("acl2 is NULL"); - - perm2 = GRSTgaclAclTestUser(acl2, user); - - printf("test /O=Grid/CN=Mr Grid Person in acl = %d\n", perm2); - - if (perm1 != perm0) return 1; - if (perm2 != perm0) return 2; - - return 0; -} diff --git a/org.gridsite.core/src/gridsite.spec b/org.gridsite.core/src/gridsite.spec deleted file mode 100644 index 877f25d..0000000 --- a/org.gridsite.core/src/gridsite.spec +++ /dev/null @@ -1,78 +0,0 @@ -Name: gridsite -Version: %(echo ${MYVERSION:-1.1.x}) -Release: 2 -Summary: GridSite -Copyright: Modified BSD -Group: System Environment/Daemons -Source: %{name}-%{version}.src.tar.gz -Prefix: %(echo ${MYPREFIX:-/usr}) -URL: http://www.gridsite.org/ -Vendor: GridPP -#Requires: libxml2,curl-ssl,mod_ssl -#Buildrequires: libxml2-devel,curl-ssl-devel,httpd-devel -Packager: Andrew McNab - -%description -GridSite adds GSI, VOMS and GACL support to Apache 2.0 (mod_gridsite), -a library for manipulating these technologies (libgridsite), and CGI -programs for interactive management of HTTP(S) servers (gridsite-admin.cgi) - -See %(echo ${MYPREFIX:-/usr})/share/doc/gridsite-%{version} and -http://www.gridsite.org/ for details. - -%package -n htcp -Group: Applications/Internet -Summary: HTTP(S) read/write client -#Requires: curl-ssl - -%description -n htcp -htcp is a client to fetch files or directory listings from remote -servers using HTTP or HTTPS, or to put or delete files or directories -onto remote servers using HTTPS. htcp is similar to scp(1), but uses -HTTP/HTTPS rather than ssh as its transfer protocol. - -%prep - -%setup - -%build -cd src -make prefix=$RPM_BUILD_ROOT/%(echo ${MYPREFIX:-/usr}) - -%install -cd src -make install prefix=$RPM_BUILD_ROOT/%(echo ${MYPREFIX:-/usr}) - -%post -/sbin/ldconfig -ln -sf %(echo ${MYPREFIX:-/usr})/share/doc/gridsite-%{version} \ - %(echo ${MYPREFIX:-/usr})/share/doc/gridsite - -%postun -rm -f %(echo ${MYPREFIX:-/usr})/share/doc/gridsite - -%files -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/lib/libgridsite.so.%{version} -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/lib/libgridsite.so -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/bin/urlencode -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/bin/findproxyfile -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/share/doc/gridsite-%{version} -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/share/man/man1/urlencode.1.gz -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/share/man/man1/findproxyfile.1.gz -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/include/gridsite.h -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/include/gridsite-gacl.h -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/lib/libgridsite.a -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/lib/httpd/modules/mod_gridsite.so -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/sbin/real-gridsite-admin.cgi - -%files -n htcp -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/bin/htcp -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/bin/htls -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/bin/htll -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/bin/htrm -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/bin/htmkdir -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/share/man/man1/htcp.1.gz -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/share/man/man1/htrm.1.gz -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/share/man/man1/htls.1.gz -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/share/man/man1/htll.1.gz -%attr(-, root, root) %(echo ${MYPREFIX:-/usr})/share/man/man1/htmkdir.1.gz diff --git a/org.gridsite.core/src/grst-delegation.c b/org.gridsite.core/src/grst-delegation.c deleted file mode 100644 index 2a8a9b2..0000000 --- a/org.gridsite.core/src/grst-delegation.c +++ /dev/null @@ -1,295 +0,0 @@ -/* - Copyright (c) 2002-4, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/*---------------------------------------------------------------------------* - * This program is part of GridSite: http://www.gridpp.ac.uk/authz/gridsite/ * - *---------------------------------------------------------------------------*/ - -#ifndef VERSION -#define VERSION "0.0.1" -#endif - -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -/* #include */ - -#include "gridsite.h" - -#include "soapH.h" -#include "delegation.nsmap" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define GRST_KEYSIZE 512 -#define GRST_PROXYCACHE "/../proxycache/" -#define GRST_SUPPORT_G_HTTPS - -#ifdef GRST_SUPPORT_G_HTTPS -void GRSThttpError(char *status) -{ - printf("Status: %s\n", status); - printf("Server-CGI: GridSite %s\n", VERSION); - printf("Content-Length: %d\n", 2 * strlen(status) + 58); - puts("Content-Type: text/html\n"); - - printf("%s\n", status); - printf("

    %s

    \n", status); - - exit(0); -} - -int GRSTmethodPutProxy(char *delegation_id, char *user_dn) -/* return 0 on success; non-zero on error */ -{ - int c, len = 0, i; - char *docroot, *contentlen, *contenttype, *proxychain, *proxydir; - FILE *fp; - - if (((contenttype = getenv("CONTENT_TYPE")) == NULL) || - (strcmp(contenttype, "application/x-x509-user-cert-chain") != 0)) - return 2; - - contentlen = getenv("CONTENT_LENGTH"); - if (contentlen == NULL) return 2; - len = atoi(contentlen); - - if ((delegation_id == NULL) || (*delegation_id == '\0')) - delegation_id = "_"; - - docroot = getenv("DOCUMENT_ROOT"); - asprintf(&proxydir, "%s/%s", docroot, GRST_PROXYCACHE); - - if ((user_dn == NULL) || (user_dn[0] == '\0') || - (GRSTx509CacheProxy(proxydir, delegation_id, user_dn, proxychain) - != GRST_RET_OK)) - { - return GRST_RET_FAILED; - } - - free(proxydir); - - return GRST_RET_OK; -} -#endif - -int main(int argn, char *argv[]) -{ - char *docroot, *method, *request, *p, *client_dn, *user_dn, - *delegation_id, *reqtxt, *proxydir; - struct soap soap; - - method = getenv("REQUEST_METHOD"); - if (strcmp(method, "POST") == 0) - { - soap_init(&soap); - soap_serve(&soap); /* CGI application */ - return 0; - } - -#ifdef GRST_SUPPORT_G_HTTPS - docroot = getenv("DOCUMENT_ROOT"); - - request = strdup(getenv("REQUEST_URI")); - p = index(request, '?'); - if (p != NULL) *p = '\0'; - - - /* non HTTP POST methods - ie special G-HTTPS methods */ - - delegation_id = getenv("HTTP_DELEGATION_ID"); - if ((delegation_id == NULL) || (*delegation_id == '\0')) delegation_id = "_"; - - user_dn = NULL; - client_dn = getenv("SSL_CLIENT_S_DN"); - if (client_dn != NULL) - { - user_dn = strdup(client_dn); - - /* we assume here that mod_ssl has verified proxy chain already ... */ - - p = strstr(user_dn, "/CN=proxy"); - if (p != NULL) *p = '\0'; - - p = strstr(user_dn, "/CN=limited proxy"); - if (p != NULL) *p = '\0'; - } - - if (user_dn == NULL) /* all methods require client auth */ - { - GRSThttpError("403 Forbidden"); - } - else if (strcmp(method, "GET-PROXY-REQ") == 0) - { - docroot = getenv("DOCUMENT_ROOT"); - asprintf(&proxydir, "%s/%s", docroot, GRST_PROXYCACHE); - - if (GRSTx509MakeProxyRequest(&reqtxt, proxydir, - delegation_id, user_dn) == 0) - { - puts("Status: 200 OK"); - puts("Content-Type: application/x-x509-cert-request"); - printf("Content-Length: %d\n\n", strlen(reqtxt)); - fputs(reqtxt, stdout); - free(proxydir); - return 0; - } - - puts("Status: 500 Internal Server Error\n"); - free(proxydir); - return 0; - } - else if (strcmp(method, "PUT-PROXY-CERT") == 0) - { - if (GRSTmethodPutProxy(delegation_id, user_dn) == 0) - { - puts("Status: 200 OK\n"); - return 0; - } - - puts("Status: 500 Internal Server Error\n"); - return 0; - } - else - { - GRSThttpError("501 Method Not Implemented"); - } -#endif -} - -int ns__getProxyReq(struct soap *soap, char *delegation_id, - char **request) -{ - char *p, *client_dn, *user_dn, *docroot, *proxydir; - - user_dn = NULL; - client_dn = getenv("SSL_CLIENT_S_DN"); - if (client_dn != NULL) - { - user_dn = strdup(client_dn); - - /* we assume here that mod_ssl has verified proxy chain already ... */ - - p = strstr(user_dn, "/CN=proxy"); - if (p != NULL) *p = '\0'; - - p = strstr(user_dn, "/CN=limited proxy"); - if (p != NULL) *p = '\0'; - } - - if ((delegation_id == NULL) || (*delegation_id == '\0')) delegation_id = "_"; - - docroot = getenv("DOCUMENT_ROOT"); - asprintf(&proxydir, "%s/%s", docroot, GRST_PROXYCACHE); - - if ((user_dn != NULL) && (user_dn[0] != '\0') && - (GRSTx509MakeProxyRequest(request, proxydir, - delegation_id, user_dn) == 0)) - { - return SOAP_OK; - } - - return SOAP_ERR; -} - -int ns__putProxy(struct soap *soap, char *delegation_id, - char *proxy, - struct ns__putProxyResponse *unused) -{ - int fd, c, len = 0, i; - char *docroot, *proxydir, *p, *client_dn, *user_dn; - - user_dn = NULL; - client_dn = getenv("SSL_CLIENT_S_DN"); - if (client_dn != NULL) - { - user_dn = strdup(client_dn); - - /* we assume here that mod_ssl has verified proxy chain already ... */ - - p = strstr(user_dn, "/CN=proxy"); - if (p != NULL) *p = '\0'; - - p = strstr(user_dn, "/CN=limited proxy"); - if (p != NULL) *p = '\0'; - } - - if ((delegation_id == NULL) || (*delegation_id == '\0')) - delegation_id = "_"; - - docroot = getenv("DOCUMENT_ROOT"); - asprintf(&proxydir, "%s/%s", docroot, GRST_PROXYCACHE); - - if ((user_dn == NULL) || (user_dn[0] == '\0') || - (GRSTx509CacheProxy(proxydir, delegation_id, user_dn, proxy) - != GRST_RET_OK)) - { - return SOAP_ERR; - } - - return SOAP_OK; -} - diff --git a/org.gridsite.core/src/grst_admin.h b/org.gridsite.core/src/grst_admin.h deleted file mode 100644 index cddc415..0000000 --- a/org.gridsite.core/src/grst_admin.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (c) 2002-3, Andrew McNab and Shiv Kaushal, - University of Manchester. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/*------------------------------------------------------------------* - * This program is part of GridSite: http://www.gridsite.org/ * - *------------------------------------------------------------------*/ - -void GRSThttpError(char *); -void adminfooter(GRSThttpBody *, char *, char *, char *, char *); -int GRSTstrCmpShort(char *, char *); -char *makevfilename(char *, size_t, char *); - -/*CGI GACL - Edit interface functions*/ -void show_acl(int admin, GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void new_entry_form(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void new_entry(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void del_entry(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void edit_entry_form(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void edit_entry(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void add_cred_form(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void add_cred(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void del_cred(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void del_entry_sure(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void del_cred_sure(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); - -/*Functions producing messages*/ -//void error(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void admin_continue(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file, GRSThttpBody *bp); - diff --git a/org.gridsite.core/src/grst_admin_file.c b/org.gridsite.core/src/grst_admin_file.c deleted file mode 100644 index f89a004..0000000 --- a/org.gridsite.core/src/grst_admin_file.c +++ /dev/null @@ -1,1571 +0,0 @@ -/* - Copyright (c) 2002-3, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/*------------------------------------------------------------------* - * This program is part of GridSite: http://www.gridsite.org/ * - *------------------------------------------------------------------*/ - -#ifndef VERSION -#define VERSION "x.x.x" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// when porting: remember that sendfile() is very OS-specific! -#include - -#include - -#include "grst_admin.h" - -char *storeuploadfile(char *boundary, int *bufferused) -{ -// rewrite this to copy whole POSTed stdin HTTP body to disk then -// mmap() and pick apart? How to deal with 100MB uploaded files, say? - - char *filebuffer = NULL; - int bufferlen = 0, c, boundarylen; - - *bufferused = 0; - boundarylen = strlen(boundary); - - while ((c = getchar()) != EOF) - { - if (*bufferused > 1024*1024*100) return NULL; - - ++(*bufferused); - - if (*bufferused > bufferlen) - { - bufferlen = bufferlen + 1000; - filebuffer = realloc(filebuffer, (size_t) bufferlen); - } - - filebuffer[*bufferused - 1] = c; - - if ( (*bufferused >= boundarylen + 4) && - (boundary[boundarylen-1] == c) && - (boundary[boundarylen-2] == filebuffer[*bufferused - 2]) && - (strncmp(boundary, &filebuffer[*bufferused - boundarylen], - boundarylen) == 0)) - { - *bufferused = *bufferused - boundarylen - 4; - - if (filebuffer == NULL) return strdup(""); - else return filebuffer; - } - } - - return NULL; -} - -void uploadfile(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *dir_uri, char *admin_file) -{ - char *boundary, *p, oneline[200], *filename = NULL, - tmpfilename[256], *filebuffer = NULL, *filepath, - *vfile, *dir_path_vfile; - int mimestate, bufferused = 0, itworked = 0; - FILE *fp; - GRSThttpBody bp; - -#define MIMESTUNKNOWN 1 -#define MIMESTUPLOAD 2 -#define MIMESTFILENM 3 - - if (!GRSTgaclPermHasWrite(perm)) GRSThttpError("403 Forbidden"); - - p = getenv("CONTENT_TYPE"); - boundary = &p[30]; - - mimestate = MIMESTUNKNOWN; - - while (fgets(oneline, sizeof(oneline), stdin) != NULL) - { - if (*oneline == 13) // MIME has CR/LF line breaks, CR=13 - { - if (mimestate == MIMESTUPLOAD) - { - filebuffer = storeuploadfile(boundary, &bufferused); - mimestate = MIMESTUNKNOWN; - } - else if (mimestate == MIMESTFILENM) - { - fgets(tmpfilename, sizeof(tmpfilename), stdin); - if (*tmpfilename != 13) - { - p = index(tmpfilename, 13); - *p = '\0'; - filename = strdup(tmpfilename); - } - mimestate = MIMESTUNKNOWN; - } - } - else if (GRSTstrCmpShort(oneline, - "Content-Disposition: form-data; name=\"uploadfile\"; filename=\"") - == 0) - { - mimestate = MIMESTUPLOAD; - if (filename == NULL) - { - filename = strdup(&oneline[61]); - - p = rindex(&oneline[61], '\\'); - if (p != NULL) { ++p ; filename = p; } - - p = rindex(&oneline[61], '/'); - if (p != NULL) { ++p ; filename = p; } - - p = index(filename, '"'); - if (p != NULL) *p = '\0'; - } - } - else if (GRSTstrCmpShort(oneline, - "Content-Disposition: form-data; name=\"file\"") == 0) - { - mimestate = MIMESTFILENM; - } - } - - if ((filebuffer != NULL) && (bufferused >= 0)) - { - if (filename == NULL) GRSThttpError("403 Forbidden"); - else if ((index(filename, '/') != NULL) || - (strcmp(filename, GRST_ACL_FILE) == 0)) - { - puts("Status: 403 Forbidden filename\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp,"Forbidden filename %s\n", filename); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Forbidden filename %s

    \n", - filename); - - GRSThttpPrintf(&bp, - "

    New file names cannot include slashes " - "or use the reserved ACL name, %s\n", GRST_ACL_FILE); - - GRSThttpPrintf(&bp,"

    " - "Return to " - "directory listing\n", dir_uri, admin_file); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); - return; - } - else - { - vfile = makevfilename(filename, bufferused, dn); - asprintf(&dir_path_vfile, "%s/%s", dir_path, vfile); - - fp = fopen(dir_path_vfile, "w"); - if (fp != NULL) - { - if ((fwrite(filebuffer, - sizeof(char), bufferused, fp) == bufferused) && - (fclose(fp) == 0)) - { - asprintf(&filepath, "%s/%s", dir_path, filename); - - unlink(filepath); /* this can fail ok */ - - itworked = (link(dir_path_vfile, filepath) == 0); - } - } - } - - free((void *) filebuffer); - } - - if (itworked) - { - printf("Status: 302 Moved Temporarily\nContent-Length: 0\n" - "Location: %s%s?cmd=managedir\n\n", dir_uri, admin_file); - return; - } - - puts("Status: 500 Failed trying to upload\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp, "Failed to upload\n"); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Failed to upload

    \n"); - - GRSThttpPrintf(&bp, "

    GridSite considers you are authorized " - "to upload the file, but the upload failed. This is " - "probably a web server or operating system level " - "misconfiguration. Consult the site administrator."); - - GRSThttpPrintf(&bp,"

    " - "Return to " - "directory listing\n", dir_uri, admin_file); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); -} - -void deletefileaction(char *dn, GRSTgaclPerm perm, char *help_uri, - char *dir_path, char *file, char *dir_uri, - char *admin_file) -{ - int fd, numfiles; - char *dir_path_file, *dir_path_vfile, *p, *vfile, *dnlistsuri, - *fulluri, *server_name, *realfile; - struct stat statbuf; - GRSThttpBody bp; - struct dirent *subdirfile_ent; - DIR *subDIR; - - if (((strcmp(file, GRST_ACL_FILE) != 0) && !GRSTgaclPermHasWrite(perm)) || - ((strcmp(file, GRST_ACL_FILE) == 0) && !GRSTgaclPermHasAdmin(perm))) - GRSThttpError("403 Forbidden"); - - dnlistsuri = getenv("GRST_DN_LISTS_URI"); - if (dnlistsuri == NULL) dnlistsuri = getenv("REDIRECT_GRST_DN_LISTS_URI"); - - if ((dnlistsuri != NULL) && - (strncmp(dnlistsuri, dir_uri, strlen(dnlistsuri)) == 0)) - realfile = GRSThttpUrlEncode(file); - else if (index(file, '/') != NULL) GRSThttpError("403 Forbidden"); - else realfile = file; - - dir_path_file = malloc(strlen(dir_path) + strlen(realfile) + 2); - - strcpy(dir_path_file, dir_path); - strcat(dir_path_file, "/"); - strcat(dir_path_file, realfile); - - if ((stat(dir_path_file, &statbuf) == 0) && S_ISDIR(statbuf.st_mode)) - { - subDIR = opendir(dir_path_file); - if (subDIR == NULL) numfiles = 99; /* stop deletion */ - else - { - numfiles = 0; - while ((subdirfile_ent = readdir(subDIR)) != NULL) - if (subdirfile_ent->d_name[0] != '.') ++numfiles; - else if (strncmp(subdirfile_ent->d_name, - GRST_ACL_FILE, - sizeof(GRST_ACL_FILE)) == 0) ++numfiles; - closedir(subDIR); - } - - if (numfiles == 0) - { - vfile = makevfilename(file, 0, dn); - dir_path_vfile = malloc(strlen(dir_path) + strlen(vfile) + 2); - strcpy(dir_path_vfile, dir_path); - strcat(dir_path_vfile, "/"); - strcat(dir_path_vfile, vfile); - - if (rename(dir_path_file, dir_path_vfile) == 0) - { - printf("Status: 302 Moved Temporarily\nContent-Length: 0\n" - "Location: %s%s?cmd=managedir\n\n", dir_uri, admin_file); - return; - } - } - } - else if (unlink(dir_path_file) == 0) - { - if (strcmp(file, GRST_ACL_FILE) != 0) - { - vfile = makevfilename(file, 0, dn); - dir_path_file = malloc(strlen(dir_path) + strlen(vfile) + 2); - strcpy(dir_path_file, dir_path); - strcat(dir_path_file, "/"); - strcat(dir_path_file, vfile); - - fd = open(dir_path_file, O_WRONLY | O_CREAT); - if (fd != -1) close(fd); - } - - printf("Status: 302 Moved Temporarily\nContent-Length: 0\n" - "Location: %s%s?cmd=managedir\n\n", dir_uri, admin_file); - - return; - } - - puts("Status: 500 Failed trying to delete\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp, "Error deleting %s%s\n", dir_uri, file); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Error deleting %s%s

    \n", - dir_uri, file); - - GRSThttpPrintf(&bp, "

    GridSite considers you are authorized " - "to delete %s, but the delete failed. This is " - "probably a web server or operating system level " - "misconfiguration. Consult the site administrator.", - file); - - GRSThttpPrintf(&bp,"

    " - "Return to " - "directory listing\n", dir_uri, admin_file); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); -} - -void deletefileform(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - GRSThttpBody bp; - - if (!GRSTgaclPermHasWrite(perm)) GRSThttpError("403 Forbidden"); - - puts("Status: 200 OK\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp, "Delete %s\n", file); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Delete %s

    \n", file); - - GRSThttpPrintf(&bp,"
    \n",dir_uri,admin_file); - GRSThttpPrintf(&bp,"

    Do you really want to delete %s?", file); - GRSThttpPrintf(&bp,"

    \n", file); - GRSThttpPrintf(&bp,"\n", file); - GRSThttpPrintf(&bp,"\n"); - GRSThttpPrintf(&bp,"
    \n"); - - GRSThttpPrintf(&bp,"

    Or " - "return to " - "directory listing\n", dir_uri, admin_file); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); -} - -void renameform(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - GRSThttpBody bp; - - if (!GRSTgaclPermHasWrite(perm)) GRSThttpError("403 Forbidden"); - - puts("Status: 200 OK\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp, "Rename %s\n", file); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Rename %s%s

    \n", dir_uri, file); - - GRSThttpPrintf(&bp,"
    \n",dir_uri,admin_file); - GRSThttpPrintf(&bp,"

    What do you want to rename %s to?

    ", file); - GRSThttpPrintf(&bp,"\n", file); - GRSThttpPrintf(&bp,"

    New name: \n", file); - GRSThttpPrintf(&bp,"\n"); - GRSThttpPrintf(&bp,"\n"); - GRSThttpPrintf(&bp,"

    \n"); - - GRSThttpPrintf(&bp,"

    Or " - "return to " - "directory listing\n", dir_uri, admin_file, dir_uri); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); -} - -void editfileaction(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - char *pagetext, *dir_path_file, *vfile, *dir_path_vfile, - *dnlistsuri, *server_name, *fulluri, *realfile; - FILE *fp; - GRSThttpBody bp; - - if (!GRSTgaclPermHasWrite(perm) || (strcmp(file, GRST_ACL_FILE) == 0)) - GRSThttpError("403 Forbidden"); - - dnlistsuri = getenv("GRST_DN_LISTS_URI"); - if (dnlistsuri == NULL) dnlistsuri = getenv("REDIRECT_GRST_DN_LISTS_URI"); - - if ((dnlistsuri != NULL) && - (strncmp(dnlistsuri, dir_uri, strlen(dnlistsuri)) == 0)) - { - realfile = GRSThttpUrlEncode(file); - - if (realfile[0] == '.') GRSThttpError("403 Forbidden"); - } - else if (index(file, '/') != NULL) GRSThttpError("403 Forbidden"); - else realfile = file; - - asprintf(&dir_path_file, "%s/%s", dir_path, realfile); - - pagetext = GRSThttpGetCGI("pagetext"); - vfile = makevfilename(file, strlen(pagetext), dn); - asprintf(&dir_path_vfile, "%s/%s", dir_path, vfile); - - fp = fopen(dir_path_vfile, "w"); - if (fp == NULL) - { - puts("Status: 500 Failed trying to write\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp,"Error writing %s%s\n", dir_uri, file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Error writing %s%s

    \n", - dir_uri, file); - - GRSThttpPrintf(&bp, - "

    GridSite considers you are authorized " - "to write the file, but the write failed. This is " - "probably a web server or operating system level " - "misconfiguration. Consult the site administrator."); - - GRSThttpPrintf(&bp,"

    " - "Return to " - "directory listing\n", dir_uri, admin_file); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); - return; - } - - fwrite(pagetext, strlen(pagetext), sizeof(char), fp); - - fclose(fp); - - unlink(dir_path_file); - - if (link(dir_path_vfile,dir_path_file) != 0) GRSThttpError("403 Forbidden"); - - if ((strlen(file) > 7) && (strcmp(&file[strlen(file) - 5], ".html") == 0)) - printf("Status: 302 Moved Temporarily\nContent-Length: 0\n" - "Location: %s%s\n\n", dir_uri, file); - else printf("Status: 302 Moved Temporarily\nContent-Length: 0\n" - "Location: %s%s?cmd=managedir\n\n", dir_uri, admin_file); -} - -void create_acl(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - int fd; - char *tmpgacl, *newgacl; - GRSTgaclAcl *acl; - FILE *fp; - GRSThttpBody bp; - - if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError("403 Forbidden"); - - asprintf(&tmpgacl, "%s/.tmp.XXXXXX", dir_path); - asprintf(&newgacl, "%s/%s", dir_path, GRST_ACL_FILE); - - if (((acl = GRSTgaclAclLoadforFile(dir_path)) != NULL) && - ((fd = mkstemp(tmpgacl)) != -1) && - ((fp = fdopen(fd, "w+")) != NULL) && - GRSTgaclAclPrint(acl, fp) && - (fclose(fp) == 0) && - (rename(tmpgacl, newgacl) == 0)) - { - printf("Status: 302 Moved Temporarily\nContent-Length: 0\n" - "Location: %s%s?cmd=managedir\n\n", dir_uri, admin_file); - - free(tmpgacl); - free(newgacl); - return; - } - - puts("Status: 500 Failed trying to create\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp,"Error creating %s%s\n", dir_uri, - GRST_ACL_FILE); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Error creating %s%s

    \n", - dir_uri, GRST_ACL_FILE); - - GRSThttpPrintf(&bp, "

    GridSite considers you are authorized " - "to create it, but the create failed. This is " - "probably a web server or operating system level " - "misconfiguration. Consult the site administrator."); - - GRSThttpPrintf(&bp,"

    " - "Return to " - "directory listing\n", dir_uri, admin_file); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); - - free(tmpgacl); - free(newgacl); -} - -void renameaction(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - int len; - char *dir_path_file, *vfile, *dir_path_vfile, - *dnlistsuri, *newfile, *dir_path_newfile; - struct stat statbuf; - FILE *fp; - GRSThttpBody bp; - - if (!GRSTgaclPermHasWrite(perm) || (strcmp(file, GRST_ACL_FILE) == 0)) - GRSThttpError("403 Forbidden"); - - if (index(file, '/') != NULL) GRSThttpError("403 Forbidden"); - - dir_path_file = malloc(strlen(dir_path) + strlen(file) + 2); - strcpy(dir_path_file, dir_path); - strcat(dir_path_file, "/"); - strcat(dir_path_file, file); - - if (stat(dir_path_file, &statbuf) != 0) GRSThttpError("404 Not Found"); - - newfile = GRSThttpGetCGI("newfile"); - - if ((strcmp(newfile, GRST_ACL_FILE) == 0) || - (strcmp(newfile, file) == 0)) GRSThttpError("403 Forbidden"); - - dir_path_newfile = malloc(strlen(dir_path) + strlen(newfile) + 2); - strcpy(dir_path_newfile, dir_path); - strcat(dir_path_newfile, "/"); - strcat(dir_path_newfile, newfile); - - vfile = makevfilename(newfile, statbuf.st_size, dn); - dir_path_vfile = malloc(strlen(dir_path) + strlen(vfile) + 2); - strcpy(dir_path_vfile, dir_path); - strcat(dir_path_vfile, "/"); - strcat(dir_path_vfile, vfile); - - unlink(dir_path_newfile); /* just in case */ - - if ((link(dir_path_file, dir_path_vfile ) == 0) && - (link(dir_path_file, dir_path_newfile) == 0) && - (unlink(dir_path_file) == 0)) - { - printf("Status: 302 Moved Temporarily\nContent-Length: 0\n" - "Location: %s\n\n", dir_uri); - return; - } - - puts("Status: 500 Failed trying to rename\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp,"Error renaming %s%s\n", dir_uri, file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Error renaming %s%s

    \n", - dir_uri, file); - - GRSThttpPrintf(&bp, "

    GridSite considers you are authorized " - "to rename it, but the rename failed. This is " - "probably a web server or operating system level " - "misconfiguration. Consult the site administrator."); - - GRSThttpPrintf(&bp,"

    " - "Return to " - "directory listing\n", dir_uri, admin_file); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); -} - -void newdirectory(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - int len; - char *dir_path_file, *vfile, *dir_path_vfile, *filedup; - FILE *fp; - GRSThttpBody bp; - - if ((file[0] == '\0') || - !GRSTgaclPermHasWrite(perm) || (strcmp(file, GRST_ACL_FILE) == 0)) - GRSThttpError("403 Forbidden"); - - filedup = strdup(file); - if (filedup[strlen(filedup)-1] == '/') filedup[strlen(filedup)-1] = '\0'; - if (index(filedup, '/') != NULL) GRSThttpError("403 Forbidden"); - - dir_path_file = malloc(strlen(dir_path) + strlen(file) + 2); - strcpy(dir_path_file, dir_path); - strcat(dir_path_file, "/"); - strcat(dir_path_file, file); - - if (mkdir(dir_path_file, 0751) == 0) - { - printf("Status: 302 Moved Temporarily\nContent-Length: 0\n" - "Location: %s%s?cmd=managedir\n\n", dir_uri, admin_file); - return; - } - - puts("Status: 500 Failed trying to create\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp,"Error create %s%s\n", dir_uri, file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Error creating directory %s%s

    \n", - dir_uri, file); - - GRSThttpPrintf(&bp, - "

    GridSite considers you are authorized " - "to create the directory, but the creation failed. This " - "is probably a web server or operating system level " - "misconfiguration. Consult the site administrator."); - - GRSThttpPrintf(&bp,"

    " - "Return to " - "parent directory listing\n", dir_uri, admin_file); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); -} - -void editdnlistaction(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - int numdn = 0, ifd, ofd, numdnlines = 0, i, found; - char *dir_path_file, *dir_path_tmpfile, *realfile, - *dnlistsuri, *server_name, *fulldiruri, *p, oneline[513], - **dnlines, name[81], *add; - FILE *ofp; - struct stat statbuf; - GRSThttpBody bp; - - if (!GRSTgaclPermHasWrite(perm)) GRSThttpError("403 Forbidden"); - - dnlistsuri = getenv("GRST_DN_LISTS_URI"); - if (dnlistsuri == NULL) dnlistsuri = getenv("REDIRECT_GRST_DN_LISTS_URI"); - - server_name = getenv("SERVER_NAME"); - - if ((server_name == NULL) || - (dnlistsuri == NULL) || - (strncmp(dnlistsuri, dir_uri, strlen(dnlistsuri)) != 0)) - GRSThttpError("403 Forbidden"); - - asprintf(&fulldiruri, "https://%s%s", server_name, dir_uri); - - if ((strncmp(fulldiruri, file, strlen(fulldiruri)) != 0) && - ((strncmp(fulldiruri, file, strlen(fulldiruri) - 1) != 0) || - (strlen(fulldiruri) - 1 != strlen(file)))) - { - puts("Status: 403 Forbidden\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp,"Error writing %s\n", file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Error writing %s to %s

    \n", - file, dir_uri); - - GRSThttpPrintf(&bp, "

    You cannot create a DN List " - "with that prefix in this directory. Please see the " - "the GridSite User's Guide for an explanation."); - - GRSThttpPrintf(&bp,"

    " - "Return to " - "directory listing\n", dir_uri, admin_file); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); - return; - } - - p = GRSThttpGetCGI("numdn"); - if ((p == NULL) || (sscanf(p, "%d", &numdn) != 1)) - GRSThttpError("500 No number of DNs"); - - if (numdn > 0) - { - dnlines = malloc(sizeof(char *) * numdn); - - for (i=1; i <= numdn; ++i) - { - sprintf(name, "dn%d", i); - p = GRSThttpGetCGI(name); - - if (*p != '\0') - { - dnlines[numdnlines] = p; - ++numdnlines; - } - } - } - - add = GRSThttpGetCGI("add"); - - realfile = GRSThttpUrlEncode(file); - - dir_path_file = malloc(strlen(dir_path) + strlen(realfile) + 2); - strcpy(dir_path_file, dir_path); - strcat(dir_path_file, "/"); - strcat(dir_path_file, realfile); - - dir_path_tmpfile = malloc(strlen(dir_path) + 13); - strcpy(dir_path_tmpfile, dir_path); - strcat(dir_path_tmpfile, "/.tmp.XXXXXX"); - - if (((ofd = mkstemp(dir_path_tmpfile)) != -1) && - ((ofp = fdopen(ofd, "w")) != NULL)) - { - if (*add != '\0') - { - fputs(add, ofp); - fputc('\n', ofp); - } - - for (i=0; i < numdnlines; ++i) - { - fputs(dnlines[i], ofp); - fputc('\n', ofp); - } - - if ((fclose(ofp) == 0) && - ((stat(dir_path_file, &statbuf) != 0) || - (unlink(dir_path_file) == 0)) && - (rename(dir_path_tmpfile, dir_path_file) == 0)) - { - printf("Status: 302 Moved Temporarily\nContent-Length: 0\n" - "Location: %s%s?cmd=managedir\n\n", dir_uri, admin_file); - return; - } - } - - puts("Status: 500 Failed trying to write\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp,"Error writing %s%s\n", dir_uri, file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Error writing %s%s

    \n", - dir_uri, file); - - GRSThttpPrintf(&bp, "

    GridSite considers you are authorized " - "to write the file, but the write failed. This is " - "probably a web server or operating system level " - "misconfiguration. Consult the site administrator."); - - GRSThttpPrintf(&bp,"

    " - "Return to " - "directory listing\n", dir_uri, admin_file); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); - - /* try to clean up */ - if (stat(dir_path_tmpfile, &statbuf) == 0) unlink(dir_path_tmpfile); -} - -void printfile(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - int fd; - char *dir_path_file; - struct stat statbuf; - - if (!GRSTgaclPermHasRead(perm)) GRSThttpError("403 Forbidden"); - - if (index(file, '/') != NULL) GRSThttpError("403 Forbidden"); - - dir_path_file = malloc(strlen(dir_path) + strlen(file) + 2); - - strcpy(dir_path_file, dir_path); - strcat(dir_path_file, "/"); - strcat(dir_path_file, file); - - fd = open(dir_path_file, O_RDONLY); - if (fd == -1) GRSThttpError("500 Internal server error"); - - if ((fstat(fd, &statbuf) != 0) || - !S_ISREG(statbuf.st_mode)) GRSThttpError("403 Forbidden"); - - printf("Status: 200 OK\nContent-Type: text/html\nContent-Length: %d\n\n", - statbuf.st_size); - - fflush(stdout); - - sendfile(1, fd, 0, statbuf.st_size); -} - -void filehistory(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - int fd, n, i, j, enclen, num = 0; - char *encodedfile, *p, *dndecoded, modified[99], *vfile, *q, - *encdn; - time_t file_time; - size_t file_size; - struct stat statbuf; - struct dirent **namelist; - struct tm file_tm; - GRSThttpBody bp; - - if (!GRSTgaclPermHasRead(perm)) GRSThttpError("403 Forbidden"); - - if (index(file, '/') != NULL) GRSThttpError("403 Forbidden"); - - puts("Status: 200 OK\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - GRSThttpPrintf(&bp, "History of %s%s\n", dir_uri, file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - GRSThttpPrintf(&bp, - "

    History of %s%s

    \n", - dir_uri, file, dir_uri, file); - - asprintf(&vfile, "%s/%s", dir_path, file); - if (stat(vfile, &statbuf) == 0) - { - localtime_r((const time_t *) &(statbuf.st_mtime), &file_tm); - strftime(modified, sizeof(modified), - "%a %e %b %Y %k:%M", &file_tm); - - GRSThttpPrintf(&bp, "

    Last modified: %s\n", modified); - } - free(vfile); - - encodedfile = GRSThttpUrlEncode(file); - for (p=encodedfile; *p != '\0'; ++p) if (*p == '%') *p = '='; - enclen = strlen(encodedfile); - - n = scandir(dir_path, &namelist, 0, alphasort); - - if (n > 0) - { - for (i = n - 1; i >= 0; --i) - { - if ((strncmp(namelist[i]->d_name, GRST_HIST_PREFIX, - sizeof(GRST_HIST_PREFIX) - 1) == 0) && - ((namelist[i]->d_name)[sizeof(GRST_HIST_PREFIX) - 1] == ':') && - (strncmp(&((namelist[i]->d_name)[sizeof(GRST_HIST_PREFIX)]), - encodedfile, enclen) == 0) && - ((namelist[i]->d_name)[sizeof(GRST_HIST_PREFIX)+enclen] == ':')) - { - if (num == 0) GRSThttpPrintf(&bp, - "

    \n" - "" - "\n"); - - ++num; - - p = index(namelist[i]->d_name, ':'); - p = index(&p[1], ':'); - sscanf(&p[1], "%X:", &file_time); - p = index(&p[1], ':'); /* skip over microseconds time */ - p = index(&p[1], ':'); - sscanf(&p[1], "%X:", &file_size); - p = index(&p[1], ':'); - - encdn = strdup(&p[1]); - q = index(encdn, ':'); - if (q != NULL) *q = '\0'; - - for (q=encdn; *q != '\0'; ++q) if (*q == '=') *q = '%'; - dndecoded = GRSThttpUrlDecode(encdn); - - localtime_r((const time_t *) &file_time, &file_tm); - strftime(modified, sizeof(modified), - "%a %e %b %Y %k:%M", &file_tm); - - GRSThttpPrintf(&bp, - "\n", - modified, file_size, dndecoded); - - free(dndecoded); - - asprintf(&vfile, "%s/%s", dir_path, namelist[i]->d_name); - if ((stat(vfile, &statbuf) == 0) && (statbuf.st_size > 0)) - { - GRSThttpPrintf(&bp, "\n", - dir_uri, admin_file, dir_uri, namelist[i]->d_name); - else GRSThttpPrintf(&bp, "%s%s\">View\n", - dir_uri, namelist[i]->d_name); - } - else GRSThttpPrintf(&bp, ""); - - free(vfile); - } - } - } - - if (num > 0) GRSThttpPrintf(&bp, "
    DateSize afterChanged by
    %s%d%sView
     
    \n"); - else GRSThttpPrintf(&bp, "

    No history for this file\n"); - - if (GRSTgaclPermHasList(perm)) - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - else adminfooter(&bp, dn, help_uri, dir_uri, NULL); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - GRSThttpWriteOut(&bp); -} - -void ziplist(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - char *shellcmd, *unzip, oneline[129]; - FILE *fp; - GRSThttpBody bp; - - if (!GRSTgaclPermHasRead(perm)) GRSThttpError("403 Forbidden"); - - if (index(file, '/') != NULL) GRSThttpError("403 Forbidden"); - - puts("Status: 200 OK\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - GRSThttpPrintf(&bp, "Contents of %s%s\n", dir_uri, file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - GRSThttpPrintf(&bp, - "

    Contents of ZIP file %s%s

    \n", - dir_uri, file, dir_uri, file); - - unzip = getenv("GRST_UNZIP"); - if (unzip == NULL) unzip = getenv("REDIRECT_GRST_UNZIP"); - - if (unzip != NULL) - { - GRSThttpPrintf(&bp, "
    \n");
    -      asprintf(&shellcmd, "cd %s ; %s -Z %s", dir_path, unzip, file);
    -      fp = popen(shellcmd, "r");
    -  
    -      while (fgets(oneline, sizeof(oneline), fp) != NULL)           
    -                          GRSThttpPrintf(&bp, "%s", oneline);         
    -      pclose(fp);
    -      GRSThttpPrintf(&bp, "
    \n"); - - if (GRSTgaclPermHasWrite(perm)) - GRSThttpPrintf(&bp, - "

    " - " in %s" - "" - "
    " - "

    (All files are placed in the same directory and files " - "beginning with "." are ignored.)

    \n", - dir_uri, admin_file, dir_uri, file); - } - else GRSThttpPrintf(&bp, "

    unzip path not defined!\n"); - - if (GRSTgaclPermHasList(perm)) - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - else adminfooter(&bp, dn, help_uri, dir_uri, NULL); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - GRSThttpWriteOut(&bp); -} - -void unzipfile(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - char *shellcmd, *unzip, oneline[129]; - FILE *fp; - GRSThttpBody bp; - - if (!GRSTgaclPermHasWrite(perm)) GRSThttpError("403 Forbidden"); - - if (index(file, '/') != NULL) GRSThttpError("403 Forbidden"); - - puts("Status: 200 OK\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - GRSThttpPrintf(&bp, "Unzipping %s%s\n", dir_uri, file); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - GRSThttpPrintf(&bp, - "

    Unzipping %s%s

    \n", - dir_uri, file, dir_uri, file); - - unzip = getenv("GRST_UNZIP"); - if (unzip == NULL) unzip = getenv("REDIRECT_GRST_UNZIP"); - - if (unzip != NULL) - { - GRSThttpPrintf(&bp, "
    \n");
    -      asprintf(&shellcmd, "cd %s ; %s -jo %s -x '.*'", dir_path, unzip, file);
    -      fp = popen(shellcmd, "r");
    -  
    -      while (fgets(oneline, sizeof(oneline), fp) != NULL)           
    -                          GRSThttpPrintf(&bp, "%s", oneline);         
    -      pclose(fp);
    -      GRSThttpPrintf(&bp, "
    \n"); - - if (GRSTgaclPermHasList(perm)) - GRSThttpPrintf(&bp, "

    " - "Back to " - "directory", dir_uri, admin_file); - } - else GRSThttpPrintf(&bp, "

    unzip path not defined!\n"); - - if (GRSTgaclPermHasList(perm)) - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - else adminfooter(&bp, dn, help_uri, dir_uri, NULL); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - GRSThttpWriteOut(&bp); -} - -void editfileform(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - int fd, rawpagesize, i, c; - char *dir_path_file, *rawpage, *p; - FILE *fp = NULL; - struct stat statbuf; - GRSThttpBody bp; - - if (!GRSTgaclPermHasWrite(perm)) GRSThttpError("403 Forbidden"); - - if (index(file, '/') != NULL) GRSThttpError("403 Forbidden"); - - dir_path_file = malloc(strlen(dir_path) + strlen(file) + 2); - - strcpy(dir_path_file, dir_path); - strcat(dir_path_file, "/"); - strcat(dir_path_file, file); - - fd = open(dir_path_file, O_RDONLY); - if (fd != -1) - { - fp = fdopen(fd, "r"); - if (fp == NULL) GRSThttpError("500 File open failed!"); - - if ((fstat(fd, &statbuf) != 0) || - !S_ISREG(statbuf.st_mode)) GRSThttpError("500 Not a regular file!"); - } - - puts("Status: 200 OK\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp, "Edit file %s\n", file); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Edit file %s

    \n", file); - - GRSThttpPrintf(&bp,"
    \n",dir_uri,admin_file); - GRSThttpPrintf(&bp,"

    \n"); - GRSThttpPrintf(&bp,"

    File name: \n", file); - GRSThttpPrintf(&bp,"\n"); - GRSThttpPrintf(&bp,"

    \n"); - GRSThttpPrintf(&bp, "

    \n"); - GRSThttpPrintf(&bp, "

    \n"); - - if (fp != NULL) fclose(fp); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - GRSThttpWriteOut(&bp); -} - -void editdnlistform(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *file, char *dir_uri, char *admin_file) -{ - int fd, i, c, numdn = 0; - char *dir_path_file, *rawpage, *p, *dnlistsuri, *server_name, *fulluri, - *realfile, oneline[513]; - FILE *fp = NULL; - struct stat statbuf; - GRSThttpBody bp; - - dnlistsuri = getenv("GRST_DN_LISTS_URI"); - if (dnlistsuri == NULL) dnlistsuri = getenv("REDIRECT_GRST_DN_LISTS_URI"); - - if (!GRSTgaclPermHasWrite(perm) || - (dnlistsuri == NULL) || - (strncmp(dnlistsuri, dir_uri, strlen(dnlistsuri)) != 0)) - GRSThttpError("403 Forbidden"); - - realfile = GRSThttpUrlEncode(file); - - dir_path_file = malloc(strlen(dir_path) + strlen(realfile) + 2); - - strcpy(dir_path_file, dir_path); - strcat(dir_path_file, "/"); - strcat(dir_path_file, realfile); - - fd = open(dir_path_file, O_RDONLY); - if (fd != -1) /* we dont mind open failing, but it must work if it doesnt */ - { - fp = fdopen(fd, "r"); - if (fp == NULL) GRSThttpError("500 File open failed!"); - - if ((fstat(fd, &statbuf) != 0) || - !S_ISREG(statbuf.st_mode)) GRSThttpError("500 Not a regular file!"); - } - - puts("Status: 200 OK\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp, "Edit DN List %s\n", file); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Edit DN List

    \n"); - - GRSThttpPrintf(&bp,"
    \n",dir_uri,admin_file); - GRSThttpPrintf(&bp,"

    \n"); - GRSThttpPrintf(&bp,"

    List URL: \n", file, strlen(file)); - GRSThttpPrintf(&bp,"\n"); - - if (fp != NULL) - { - GRSThttpPrintf(&bp, "

    \n" - "\n"); - - while (fgets(oneline, sizeof(oneline), fp) != NULL) - { - ++numdn; - - p = rindex(oneline, '\n'); - if (p != NULL) *p = '\0'; - - GRSThttpPrintf(&bp, "" - "\n", numdn, oneline, oneline); - } - - GRSThttpPrintf(&bp,"
    Keep?Name
    %s
    \n"); - } - - GRSThttpPrintf(&bp,"\n", numdn); - - GRSThttpPrintf(&bp, "

    Add new DN: \n"); - - GRSThttpPrintf(&bp,"

    \n"); - GRSThttpPrintf(&bp, "

    \n"); - - if (fp != NULL) fclose(fp); - - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - GRSThttpWriteOut(&bp); -} - -void managedir(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *dir_uri, char *admin_file) -{ - int n, is_dnlists_dir = 0, enclen, numfiles, encprefixlen; - char *d_namepath, modified[99], *absaclpath, *editable, *p, *unzip, - *dnlistsuri, *d_name, *server_name, *fulluri, *encfulluri, - *encprefix, *dnlistsprefix; - GRSThttpBody bp; - struct tm mtime_tm; - struct stat statbuf; - struct dirent **namelist, *subdirfile_ent; - DIR *subDIR; - - if (((!GRSTgaclPermHasWrite(perm)) && - (!GRSTgaclPermHasList(perm))) || - (stat(dir_path, &statbuf) != 0) || !S_ISDIR(statbuf.st_mode)) - GRSThttpError("403 Forbidden"); - - editable = getenv("GRST_EDITABLE"); - if (editable == NULL) editable = getenv("REDIRECT_GRST_EDITABLE"); - - unzip = getenv("GRST_UNZIP"); - if (unzip == NULL) unzip = getenv("REDIRECT_GRST_UNZIP"); - - dnlistsuri = getenv("GRST_DN_LISTS_URI"); - if (dnlistsuri == NULL) dnlistsuri = getenv("REDIRECT_GRST_DN_LISTS_URI"); - - if (dnlistsuri && (strncmp(dnlistsuri, dir_uri, strlen(dnlistsuri)) == 0)) - { - is_dnlists_dir = 1; - server_name = getenv("SERVER_NAME"); - - asprintf(&fulluri, "https://%s%s", server_name, dir_uri); - encfulluri = GRSThttpUrlEncode(fulluri); - enclen = strlen(encfulluri); - - asprintf(&dnlistsprefix, "https://%s%s", server_name, dnlistsuri); - encprefix = GRSThttpUrlEncode(dnlistsprefix); - encprefixlen = strlen(encprefix); - } - - printf("Status: 200 OK\nContent-Type: text/html\n"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintf(&bp,"Manage directory %s\n", dir_uri); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpPrintf(&bp, "

    Manage directory %s

    \n\n", dir_uri); - - if (dir_uri[1] != '\0') - GRSThttpPrintf(&bp, - "\n", admin_file); - - if (GRSTgaclPermHasList(perm) || GRSTgaclPermHasAdmin(perm)) - { - absaclpath = malloc(strlen(dir_path) + sizeof(GRST_ACL_FILE) + 1); - strcpy(absaclpath, dir_path); - strcat(absaclpath, "/"); - strcat(absaclpath, GRST_ACL_FILE); - - if (stat(absaclpath, &statbuf) == 0) /* ACL exists in THIS directory */ - { - localtime_r(&(statbuf.st_mtime), &mtime_tm); - strftime(modified, sizeof(modified), - "", - &mtime_tm); - - if (!is_dnlists_dir) - { - GRSThttpPrintf(&bp, - "" - "%s\n", - GRST_ACL_FILE, - GRST_ACL_FILE, - statbuf.st_size, modified); - - GRSThttpPrintf(&bp, - "", - dir_uri, admin_file, GRST_ACL_FILE); - } - else GRSThttpPrintf(&bp, - "" - "%s\n", - GRST_ACL_FILE, - statbuf.st_size, modified); - - if (GRSTgaclPermHasAdmin(perm)) - GRSThttpPrintf(&bp, - "" - "", - dir_uri, admin_file, - dir_uri, admin_file, GRST_ACL_FILE); - else if (GRSTgaclPermHasRead(perm)) - GRSThttpPrintf(&bp, - "" - "", dir_uri, admin_file); - else GRSThttpPrintf(&bp, "\n"); - - GRSThttpPrintf(&bp, "\n"); - } - else if (GRSTgaclPermHasAdmin(perm)) - GRSThttpPrintf(&bp, "\n" - "\n" - "\n", - dir_uri, admin_file); - } - - if (GRSTgaclPermHasList(perm)) - { - n = scandir(dir_path, &namelist, 0, alphasort); - while (n--) - { - if (namelist[n]->d_name[0] != '.') - { - d_namepath = malloc(strlen(dir_path) + - strlen(namelist[n]->d_name) + 2); - strcpy(d_namepath, dir_path); - strcat(d_namepath, "/"); - strcat(d_namepath, namelist[n]->d_name); - stat(d_namepath, &statbuf); - - if (S_ISDIR(statbuf.st_mode)) - { - subDIR = opendir(d_namepath); - - if (subDIR == NULL) numfiles = 99; /* stop deletion */ - else - { - numfiles = 0; - while ((subdirfile_ent = readdir(subDIR)) != NULL) - if (subdirfile_ent->d_name[0] != '.') ++numfiles; - else if (strncmp(subdirfile_ent->d_name, - GRST_ACL_FILE, - sizeof(GRST_ACL_FILE)) == 0) ++numfiles; - - closedir(subDIR); - } - } - - free(d_namepath); - - localtime_r(&(statbuf.st_mtime), &mtime_tm); - strftime(modified, sizeof(modified), - "", - &mtime_tm); - - if (S_ISDIR(statbuf.st_mode)) - { - GRSThttpPrintf(&bp, - "" - "%s\n", - dir_uri, namelist[n]->d_name, admin_file, - namelist[n]->d_name, - statbuf.st_size, modified); - - if (numfiles == 0) - GRSThttpPrintf(&bp, - "\n", - dir_uri, admin_file, namelist[n]->d_name); - else GRSThttpPrintf(&bp, "\n"); - - GRSThttpPrintf(&bp, "\n"); - } - else if (is_dnlists_dir) - { - if ((strlen(namelist[n]->d_name) <= encprefixlen) || - (strncmp(namelist[n]->d_name, encprefix, - encprefixlen) != 0)) continue; - - d_name = GRSThttpUrlDecode(namelist[n]->d_name); - - GRSThttpPrintf(&bp, "" - "%s" - "", - d_name, d_name, - statbuf.st_size, modified); - - if (GRSTgaclPermHasWrite(perm)) - GRSThttpPrintf(&bp, "" - "" - "" - "" - "\n", - dir_uri, admin_file, d_name); - else GRSThttpPrintf(&bp, "\n"); - - if (GRSTgaclPermHasWrite(perm)) - GRSThttpPrintf(&bp, "" - "" - "" - "" - "\n", - dir_uri, admin_file, d_name); - else GRSThttpPrintf(&bp, "\n"); - - GRSThttpPrintf(&bp, ""); - } - else /* regular directory, not DN Lists */ - { - d_name = namelist[n]->d_name; - - GRSThttpPrintf(&bp, - "" - "%s", - dir_uri, d_name, - d_name, - statbuf.st_size, modified); - - GRSThttpPrintf(&bp, - "", - dir_uri, admin_file, d_name); - - p = rindex(namelist[n]->d_name, '.'); - - if ((unzip != NULL) && - (p != NULL) && - (strcasecmp(&p[1], "zip") == 0) && - GRSTgaclPermHasRead(perm)) - GRSThttpPrintf(&bp, - "\n", - dir_uri, admin_file, d_name); - else if ((p != NULL) && - (strstr(editable, &p[1]) != NULL) && - GRSTgaclPermHasWrite(perm)) - GRSThttpPrintf(&bp, - "\n", - dir_uri, admin_file, d_name); - else GRSThttpPrintf(&bp, ""); - - if (GRSTgaclPermHasWrite(perm)) - GRSThttpPrintf(&bp, - "\n", dir_uri, admin_file, d_name); - else - GRSThttpPrintf(&bp, "\n"); - - if (GRSTgaclPermHasWrite(perm)) - GRSThttpPrintf(&bp, - "\n", dir_uri, admin_file, d_name); - else - GRSThttpPrintf(&bp, ""); - } - } - - free(namelist[n]); - } - - free(namelist); - } - - if (GRSTgaclPermHasWrite(perm)) - { - if (is_dnlists_dir) - { - GRSThttpPrintf(&bp, "\n" - "" - "\n" - "\n", - dir_uri, admin_file, fulluri, strlen(fulluri)+8); - - GRSThttpPrintf(&bp, "\n" - "\n" - "\n", - dir_uri, admin_file); - } - else - { - GRSThttpPrintf(&bp, "\n" - "\n" - "" - "\n" - "\n" - "\n", - dir_uri, admin_file); - - GRSThttpPrintf(&bp, - "\n" - "\n" - "" - "" - "\n" - "" - "\n" - "\n", dir_uri, admin_file); - } - } - - GRSThttpPrintf(&bp, "
    [Parent " - "directory]
    %R%e %b %y
    %s%ld" - "History
    %s%ldEditDeleteView    
    %R%e %b %y
    " - "%s/%ld " - "Delete  
    %s%ld 
     
      
    %s%ld" - "History" - "List" - "Edit " - "Delete " - "Rename
     
    New list name: " - "\n" - "
    New directory: " - "\n" - "

    New name:\n" - "

    Upload file:New name: " - "
    Local name:
    \n"); - - if (!is_dnlists_dir) adminfooter(&bp, dn, help_uri, dir_uri, NULL); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - GRSThttpWriteOut(&bp); -} - diff --git a/org.gridsite.core/src/grst_admin_gacl.c b/org.gridsite.core/src/grst_admin_gacl.c deleted file mode 100644 index 2a40b28..0000000 --- a/org.gridsite.core/src/grst_admin_gacl.c +++ /dev/null @@ -1,968 +0,0 @@ -/* - Copyright (c) 2003, Shiv Kaushal, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/*-----------------------------------------------------------* -* This program is part of GridSite: http://www.gridsite.org/ * -*------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -extern char *grst_perm_syms[]; -extern int grst_perm_vals[]; - -#include "grst_admin.h" - -// CGI GACL Editor interface functions -void show_acl(int admin, GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void new_entry_form(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void new_entry(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void del_entry(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void edit_entry_form(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void edit_entry(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void add_cred_form(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void add_cred(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void del_cred(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void del_entry_sure(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void del_cred_sure(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void admin_continue(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file, GRSThttpBody *bp); - -// Functions for producing HTML output -void StartHTML(GRSThttpBody *bp, char *dir_uri, char* dir_path); -void StartForm(GRSThttpBody *bp, char* dir_uri, char* dir_path, char* admin_file, int timestamp, char* target_function); -void EndForm(GRSThttpBody *bp); -void GRSTgaclCredTableStart(GRSThttpBody *bp); -void GRSTgaclCredTableAdd(GRSTgaclUser *user, GRSTgaclEntry *entry, GRSTgaclCred *cred, GRSTgaclNamevalue *namevalue, int cred_no, int entry_no, int admin, int timestamp, GRSThttpBody *bp, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); -void GRSTgaclCredTableEnd(GRSTgaclEntry* entry, int entry_no, int admin, int timestamp, GRSThttpBody *bp, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); - -// ACL Manipulation functions -int GACLentriesInAcl(GRSTgaclAcl *acl); -int GRSTgaclCredsInEntry(GRSTgaclEntry *entry); -void check_acl_save(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file, GRSTgaclUser* user, GRSTgaclAcl *acl, GRSThttpBody *bp); -void GACLeditGetPerms(GRSTgaclEntry *entry); -GRSTgaclEntry *GACLreturnEntry(GRSTgaclAcl *acl, int entry_no); -GRSTgaclCred *GACLreturnCred(GRSTgaclEntry *entry, int cred_no); - -void StringHTMLEncode (char* string, GRSThttpBody *bp); - -void revert_acl(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file); - -/*****************************************/ -/********** FUNCTIONS FOLLOW *************/ -/*****************************************/ - -void show_acl(int admin, GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Shows the contents of the ACL. Gives edit 'buttons' if (int admin) == 1 - GRSTgaclAcl *acl; - GRSTgaclEntry *entry; - GRSTgaclCred *cred; - GRSTgaclNamevalue *namevalue; - int entry_no, cred_no, allow, deny,timestamp; - GRSThttpBody bp; - char* AclFilename; - struct stat file_info; - int history_mode=0; - - if (admin==2){ - history_mode=1; - admin=0; - } - - /*double-check access permision*/ - if (!GRSTgaclPermHasAdmin(perm)) admin=0; - - StartHTML(&bp, dir_uri, dir_path); - - /* Load ACL from file and get timestamp*/ - if (history_mode==1) { - AclFilename=malloc(strlen(dir_path)+strlen(file)+2); - strcpy(AclFilename, dir_path); - strcat(AclFilename, "/"); - strcat(AclFilename, file); - } - else AclFilename=GRSTgaclFileFindAclname(dir_path); - - if (AclFilename==NULL){ - GRSThttpPrintf ( &bp,"The ACL was not found !!!
    \n"); - admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, &bp); - return; - } - - stat(GRSTgaclFileFindAclname(dir_path), &file_info); - timestamp=file_info.st_mtime; - acl = GRSTgaclAclLoadFile(AclFilename); - - if (acl==NULL){ - GRSThttpPrintf ( &bp,"The ACL was found but could not be loaded - it could be incorrectly formatted
    \n"); - adminfooter(&bp, dn, help_uri, dir_uri, NULL); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - GRSThttpWriteOut(&bp); - return; - } - - if (admin) GRSThttpPrintf (&bp,"New Entry
    \n", dir_uri, admin_file, dir_uri, timestamp ); - - // Start with the first entry in the list and work through - entry=acl->firstentry; - entry_no=1; - while (entry!=NULL){ - - GRSThttpPrintf (&bp,"
    Entry %d:\n", entry_no); - if (admin){ - GRSThttpPrintf (&bp,"Edit Entry ", dir_uri, admin_file, entry_no, dir_uri, timestamp ); - GRSThttpPrintf (&bp,"Delete Entry ",dir_uri, admin_file, entry_no, dir_uri, timestamp ); - GRSThttpPrintf (&bp,"

    \n"); - } - - GRSTgaclCredTableStart(&bp); - - // Start with the first credential in the entry and work through - cred=entry->firstcred; - cred_no=1; - while (cred!=NULL){ - namevalue=cred->firstname; - GRSTgaclCredTableAdd(user, entry, cred, namevalue, cred_no, entry_no, admin, timestamp, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - // Change to next credential - cred=cred->next; - cred_no++; - } - - GRSTgaclCredTableEnd (entry, entry_no, admin, timestamp, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - // Change to next entry - entry=entry->next; - entry_no++; - } - - if (!admin && GRSTgaclPermHasAdmin(perm) && !history_mode) //Print a link for admin mode, if not in admin mode but the user has admin permissions - GRSThttpPrintf (&bp,"Admin Mode", dir_uri, admin_file, dir_uri, timestamp ); - if (history_mode==1 && GRSTgaclDNlistHasUser(getenv("REDIRECT_GRST_ADMIN_LIST"), user)){ - StartForm(&bp, dir_uri, dir_path, admin_file, timestamp, "revert_acl"); -//GRSThttpPrintf (&bp,"Revert to this Version", dir_uri, admin_file, dir_uri, timestamp, file ); - GRSThttpPrintf (&bp, "\n", file); - // Revert Button - GRSThttpPrintf (&bp, "

    \n\n"); - } - - adminfooter(&bp, dn, help_uri, dir_uri, NULL); - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); GRSThttpWriteOut(&bp); return; -} - - -void new_entry_form(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm,char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Presents the user with a form asking for details required to create a new entry - GRSThttpBody bp; - int timestamp=atol(GRSThttpGetCGI("timestamp")); - GRSTgaclCred* cred; - GRSTgaclEntry *entry; - GRSTgaclNamevalue* namevalue; - - if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError ("403 Forbidden"); - - StartHTML(&bp, dir_uri, dir_path); - StartForm(&bp, dir_uri, dir_path, admin_file, timestamp, "new_entry"); - GRSThttpPrintf (&bp, "NEW ENTRY IN ACL FOR %s

    \n", dir_uri); - - GRSTgaclCredTableStart(&bp); - GRSTgaclCredTableAdd(user, entry,cred, namevalue, 0, 0, 0, timestamp, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - GRSTgaclCredTableEnd (entry, 0, 0, timestamp, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - - /*Submit and reset buttons - submit button sends the data in the form back to the script & new_entry() to be called*/ - EndForm(&bp); - admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, &bp); - return; -} - -void new_entry(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Processes the information entered into the form from new_entry_form() and adds a new entry to the ACL - GRSTgaclAcl *acl; - GRSTgaclEntry *entry; - GRSTgaclCred *cred; - char *type, *value; - GRSThttpBody bp; - if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError ("403 Forbidden"); - - // Get new credential info and perform checks - type=GRSThttpGetCGI("type"); - value=GRSThttpGetCGI("cred0_value"); - - if (strcmp(type, "not_chosen")==0){ - GRSThttpError ("500 Invalid input - credential type not chosen"); - return; - } - - // Create the credential - cred=GRSTgaclCredNew(type); - if (strcmp(type, "person")==0) GRSTgaclCredAddValue(cred,"dn", value); - else if (strcmp(type, "dn-list")==0) GRSTgaclCredAddValue(cred, "url", value); - else if (strcmp(type, "voms")==0) GRSTgaclCredAddValue(cred, "fqan", value); - else if (strcmp(type, "dns")==0) GRSTgaclCredAddValue(cred, "hostname", value); - else if (strcmp(type, "any-user")==0) {} // namevalue not entered for any-user credential - else{ - GRSThttpError ("500 Invalid input - credential type not valid"); - return; - } - - // Create and empty entry, add the credential and get permissions - entry = GRSTgaclEntryNew(); - GRSTgaclEntryAddCred(entry, cred); - GACLeditGetPerms(entry); - - // Load the ACL, add the entry and save - acl = GRSTgaclAclLoadFile(GRSTgaclFileFindAclname(dir_path)); - GRSTgaclAclAddEntry(acl, entry); - check_acl_save(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, user, acl, &bp); - return; -} - -void del_entry(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Deletes the entry denoted by the GCI variable "entry_no"*/ - int entry_no; - GRSTgaclAcl *acl; - GRSTgaclEntry *previous, *entry; - GRSThttpBody bp; - - if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError ("403 Forbidden"); - - // Load the ACL - acl = GRSTgaclAclLoadFile(GRSTgaclFileFindAclname(dir_path)); - - // Get the number of the entry to be deleted and check okay to delete - entry_no=atol(GRSThttpGetCGI("entry_no")); - if(GACLentriesInAcl(acl)<=1){ - StartHTML(&bp, dir_uri, dir_path); - GRSThttpPrintf (&bp, "ERROR: Cannot delete all entries from the ACL
    \n"); - admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, &bp); - return; - } - - // Get pointer to entry and previous entry - entry = GACLreturnEntry(acl, entry_no); - if (entry_no!=1) previous = GACLreturnEntry(acl, entry_no-1); - - if(entry==NULL || entry_no<1 || entry_no>GACLentriesInAcl(acl) ){ - GRSThttpError ("500 Unable to read entry from ACL file"); - return; - } - - // Perform deletion from the list by changing pointers - if (entry_no==1) acl->firstentry=entry->next; - else if (entry_no==GACLentriesInAcl(acl)) previous->next=NULL; - else previous->next=entry->next; - - // Save ACL and exit - check_acl_save(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, user, acl, &bp); - - return; -} - - -void edit_entry_form(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Presents the user with an editable form containing details of entry denoted by CGI variable entry_no*/ - int entry_no, cred_no, i, admin=0, timestamp=atol(GRSThttpGetCGI("timestamp")); - GRSTgaclAcl *acl; - GRSTgaclEntry *entry; - GRSTgaclCred *cred; - GRSTgaclNamevalue *namevalue; - // struct _GACLnamevalue *namevalue; - GRSThttpBody bp; - - if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError ("403 Forbidden"); - - // Load ACL from file - acl = GRSTgaclAclLoadFile(GRSTgaclFileFindAclname(dir_path)); - - // Get pointer to the entry and check okay - entry_no=atol(GRSThttpGetCGI("entry_no")); - entry = GACLreturnEntry(acl, entry_no); - if(entry==NULL || entry_no<1 || entry_no>GACLentriesInAcl(acl) ){ - GRSThttpError ("500 Unable to read from ACL file"); - return; - } - - StartHTML(&bp, dir_uri, dir_path); - GRSThttpPrintf (&bp, "EDITING ENTRY %d IN ACL FOR %s

    \n", entry_no, dir_uri); - - // Start with first credential in the entry and display them in order*/ - cred=entry->firstcred; - cred_no=1; - StartForm(&bp, dir_uri, dir_path, admin_file, timestamp, "edit_entry"); - GRSThttpPrintf (&bp, "\n", entry_no); - - GRSTgaclCredTableStart(&bp); - - while (cred!=NULL){ - // Start with the first namevalue in the credential - namevalue=cred->firstname; - GRSTgaclCredTableAdd(user, entry, cred, namevalue, cred_no, entry_no, admin, timestamp, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - // Change to next credential - cred=cred->next; - cred_no++; - } - GRSTgaclCredTableEnd (entry, entry_no, admin, timestamp, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - EndForm(&bp); - - admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, &bp); - return; -} - - -void edit_entry(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - //Processes the information entered into the form from edit_entry_form() and updates the entry corresponding to entry_no*/ - int entry_no, cred_no, i; - GRSTgaclAcl *acl; - GRSTgaclEntry *entry; - GRSTgaclCred *cred; - GRSTgaclNamevalue *namevalue; - char variable[30]; - GRSThttpBody bp; - - if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError ("403 Forbidden"); - - // Load the ACL - acl = GRSTgaclAclLoadFile(GRSTgaclFileFindAclname(dir_path)); - - // Get pointer to the entry and perform checks - entry_no=atol(GRSThttpGetCGI("entry_no")); - entry = GACLreturnEntry(acl, entry_no); - if(entry==NULL || entry_no<1 || entry_no>GACLentriesInAcl(acl) ){ - GRSThttpError ("500 Unable to read from ACL file"); - return; - } - - // Start with the first credential and update each one - cred=entry->firstcred; - cred_no=1; - - while (cred!=NULL){ - if (strcmp(cred->type, "any-user")!=0){ - namevalue=cred->firstname; - sprintf(variable, "cred%d_value", cred_no); - namevalue->value=GRSThttpGetCGI(variable); - } - //Change to next credential*/ - cred=cred->next; - cred_no++; - } - - // Update permissions - GACLeditGetPerms(entry); - check_acl_save(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, user, acl, &bp); - return; -} - - -void add_cred_form(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Presents the user with a form asking for details required to create a new credential in the entry denoted by entry_no - GRSThttpBody bp; - int timestamp=atol(GRSThttpGetCGI("timestamp")), entry_no=atol(GRSThttpGetCGI("entry_no")); - GRSTgaclAcl *acl; - GRSTgaclEntry* entry; - GRSTgaclCred* cred; - GRSTgaclNamevalue* namevalue; - - if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError ("403 Forbidden"); - - acl = GRSTgaclAclLoadFile(GRSTgaclFileFindAclname(dir_path)); // Load the ACL - - //Get pointer to the entry and perform checks - entry = GACLreturnEntry(acl, entry_no); - if(entry==NULL || entry_no<1 || entry_no>GACLentriesInAcl(acl) ){ - GRSThttpError ("500 Unable to read from ACL file"); - return; - } - - - if (strcmp(GRSThttpGetCGI("cmd"), "add_cred_form")==0){ //if not a new entry check to see if cred exists - cred=entry->firstcred; - while (cred!=NULL) { - if (strcmp (cred->type, "any-user")==0) { - StartHTML(&bp, dir_uri, dir_path); - GRSThttpPrintf (&bp, "ERROR: AND-ing \"any-user\" credential with other credential does not make sense
    \n"); - admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, &bp); - return; - } - cred=cred->next; - } - } - - StartHTML(&bp, dir_uri, dir_path); - GRSThttpPrintf (&bp, " NEW CREDENTIAL IN ENTRY %d OF ACL FOR %s

    \n", entry_no, dir_uri); - StartForm(&bp, dir_uri, dir_path, admin_file, timestamp, "add_cred"); - - GRSThttpPrintf (&bp, " \n", entry_no); - - GRSTgaclCredTableStart(&bp); - GRSTgaclCredTableAdd(user, entry, cred, namevalue, 0, 0, 0, timestamp, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - GRSTgaclCredTableEnd (entry, 0, 0, timestamp, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - - EndForm(&bp); - admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, &bp); - return; -} - - -void add_cred(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Processes the information entered into the form [add_cred_form()]and adds a new credential to the entry corresponding to entry_no - int entry_no; - GRSTgaclAcl *acl; - GRSTgaclEntry *entry; - GRSTgaclCred *cred; - GRSThttpBody bp; - char *type, *value; - - if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError ("403 Forbidden"); - - acl = GRSTgaclAclLoadFile(GRSTgaclFileFindAclname(dir_path));// Load the ACL - - // Get pointer to the entry and perform checks - entry_no=atol(GRSThttpGetCGI("entry_no")); - entry = GACLreturnEntry(acl, entry_no); - if(entry==NULL || entry_no<1 || entry_no>GACLentriesInAcl(acl)){ - GRSThttpError ("500 Unable to read from ACL file"); - return; - } - - // Create new credential and add it to entry - type=GRSThttpGetCGI("type"); - value=GRSThttpGetCGI("cred0_value"); - cred=GRSTgaclCredNew(type); - if (strcmp(type, "person") ==0) GRSTgaclCredAddValue(cred,"dn", value); - else if (strcmp(type, "dn-list") ==0) GRSTgaclCredAddValue(cred, "url", value); - else if (strcmp(type, "voms") ==0) GRSTgaclCredAddValue(cred, "fqan", value); - else if (strcmp(type, "dns") ==0) GRSTgaclCredAddValue(cred, "hostname", value); - else if (strcmp(type, "any-user")==0) {}// namevalue not entered for any-user credential - else{ - GRSThttpError ("500 Credential type not valid"); - return; - } - GRSTgaclEntryAddCred(entry, cred); - - check_acl_save(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, user, acl, &bp); - return; -} - - -void del_cred(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Deletes the credential denoted by the GCI variable "cred_no", in the entry denoted by "entry_no" - int entry_no, cred_no; - GRSTgaclAcl *acl; - GRSTgaclEntry *entry; - GRSTgaclCred *previous, *cred; - GRSThttpBody bp; - - if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError ("403 Forbidden"); - - acl = GRSTgaclAclLoadFile(GRSTgaclFileFindAclname(dir_path)); - - // Get pointer to the entry and perform checks - entry_no=atol(GRSThttpGetCGI("entry_no")); - entry = GACLreturnEntry(acl, entry_no); - if(entry==NULL || entry_no<1 || entry_no>GACLentriesInAcl(acl) ){ - GRSThttpError ("500 Unable to read from ACL file"); - return; - } - // Get pointer the the credential and perform checks - cred_no=atol(GRSThttpGetCGI("cred_no")); - cred=GACLreturnCred(entry, cred_no); - if(entry==NULL || entry_no<1 || cred_no>GRSTgaclCredsInEntry(entry)){ - GRSThttpError ("500 Unable to read from ACL file"); - return; - } - // Get pointer to previous credential - if needed - if (cred_no!=1) previous = GACLreturnCred(entry, cred_no-1); - - // Perform deletion from the list by changing pointers - if (cred_no==1) entry->firstcred=cred->next; - else if (cred_no==GRSTgaclCredsInEntry(entry)) previous->next=NULL; - else previous->next=cred->next; - - check_acl_save(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, user, acl, &bp); - return; -} - -void admin_continue(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file, GRSThttpBody *bp){ - // Single line printed out to forward users back to show_acl in admin mode - // Should ALWAYS called from another function so no HTML header required - // Should ALWAYS be the end of a page - GRSThttpPrintf (bp, "\n
    Click Here to return to the editor", dir_uri,admin_file,dir_uri, time(NULL)); - adminfooter(bp, dn, help_uri, dir_uri, NULL); - GRSThttpPrintHeaderFooter(bp, dir_path, GRST_FOOTFILE); - GRSThttpWriteOut(bp); - return; -} - - -void del_entry_sure(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Prints out entry denoted by entry_no and asks if the user really wants to delete it - GRSTgaclAcl *acl; - GRSTgaclEntry *entry; - GRSTgaclCred *cred; - GRSTgaclNamevalue *namevalue; - int entry_no, cred_no, allow, deny, i, timestamp; - GRSThttpBody bp; - - if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError ("403 Forbidden"); - - acl = GRSTgaclAclLoadFile(GRSTgaclFileFindAclname(dir_path));// Load ACL from file - - if (acl==NULL){ - GRSThttpError ("500 Unable to read from ACL file"); - return; - } - - // Get pointer to the entry and check okay - entry_no=atol(GRSThttpGetCGI("entry_no")); - entry = GACLreturnEntry(acl, entry_no); - if(entry==NULL || entry_no<1 || entry_no>GACLentriesInAcl(acl) ){ - GRSThttpError ("500 Unable to read from ACL file"); - return; - } - - StartHTML(&bp, dir_uri, dir_path); - GRSThttpPrintf (&bp, "

    Do you really want to delete the following entry?



    \n"); - GRSThttpPrintf (&bp,"
    Entry %d:
    \n", entry_no); - - // Print the entry out - // Start with the first credential in the entry and work through - cred=entry->firstcred; - cred_no=1; - - GRSTgaclCredTableStart(&bp); - while (cred!=NULL){ - // Start with the first namevalue in the credential - namevalue=cred->firstname; - GRSTgaclCredTableAdd(user, entry, cred, namevalue, cred_no, entry_no, 0, 0, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - // Change to next credential - cred=cred->next; - cred_no++; - } - - GRSTgaclCredTableEnd (entry, entry_no, 0, 0, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - - StartForm(&bp, dir_uri, dir_path, admin_file, atol(GRSThttpGetCGI("timestamp")), "del_entry"); - GRSThttpPrintf (&bp, "\n", entry_no); - GRSThttpPrintf (&bp, "

    \n\n"); - - admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, &bp); - return; -} - -void del_cred_sure(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Prints out credential denoted by entry_no/cred_no and asks if the user really wants to delete it - GRSTgaclAcl *acl; - GRSTgaclEntry *entry; - GRSTgaclCred *cred; - GRSTgaclNamevalue *namevalue; - int entry_no, cred_no, allow, deny, timestamp, i; - GRSThttpBody bp; - - if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError ("403 Forbidden"); - - acl = GRSTgaclAclLoadFile(GRSTgaclFileFindAclname(dir_path));// Load ACL from file - - if (acl==NULL){ - GRSThttpError ("500 Unable to read from ACL file"); - return; - } - - // Get pointer to the entry and check okay - entry_no=atol(GRSThttpGetCGI("entry_no")); - entry = GACLreturnEntry(acl, entry_no); - if(entry==NULL || entry_no<1 || entry_no>GACLentriesInAcl(acl) ){ - GRSThttpError ("500 Unable to read from ACL file"); - return; - } - - // Get pointer to the credential and check okay - cred_no=atol(GRSThttpGetCGI("cred_no")); - cred=GACLreturnCred(entry, cred_no); - if(entry==NULL || entry_no<1 || cred_no>GRSTgaclCredsInEntry(entry)){ - GRSThttpError ("500 Unable to read from ACL file"); - return; - } - - if(GRSTgaclCredsInEntry(entry)<=1){ - del_entry_sure(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - return; - } - - StartHTML(&bp, dir_uri, dir_path); - GRSThttpPrintf (&bp, "

    Do you really want to delete the following credential from entry %d?



    ", entry_no); - - // Print the credential out - GRSTgaclCredTableStart(&bp); - GRSTgaclCredTableAdd(user, entry, cred, cred->firstname, cred_no, entry_no, 0, 0, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - GRSTgaclCredTableEnd (entry, entry_no, 0, 0, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - GRSThttpPrintf (&bp,"
    \n"); - - // Yes Button - StartForm(&bp, dir_uri, dir_path, admin_file, atol(GRSThttpGetCGI("timestamp")), "del_cred"); - GRSThttpPrintf (&bp, "\n", entry_no); - GRSThttpPrintf (&bp, "\n", cred_no); - GRSThttpPrintf (&bp, "

    \n\n"); - - admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, &bp); - return; -} - - -int GACLentriesInAcl(GRSTgaclAcl *acl){ - // Returns the number of entries in acl - GRSTgaclEntry *entry; - int number; - - entry=acl->firstentry; - number=0; - - while (entry!=NULL) - { - number++; - entry=entry->next; - } - - return number; -} - -int GRSTgaclCredsInEntry(GRSTgaclEntry *entry){ - // Returns the number of credentials in entry - int number; - GRSTgaclCred *cred; - - cred=entry->firstcred; - number=0; - - while (cred!=NULL) - { - number++; - cred=cred->next; - } - - return number; -} - - -void GACLeditGetPerms(GRSTgaclEntry *entry){ - // Updates the permissions entry using permissions from a form produced using GRSTgaclCredTableEnd - int i; - char buf[30]; - - - for (i=0; grst_perm_syms[i]!=NULL; i++) /* Print the list of allowed permissions*/ - { - sprintf (buf, "allow_%s", grst_perm_syms[i]); // Update allowed - if (strcmp (GRSThttpGetCGI(buf), "ON") == 0 ) GRSTgaclEntryAllowPerm(entry, grst_perm_vals[i]); else GRSTgaclEntryUnallowPerm(entry, grst_perm_vals[i]); - - sprintf (buf, "deny_%s", grst_perm_syms[i]); // Update denied - if (strcmp (GRSThttpGetCGI(buf), "ON") == 0 ) GRSTgaclEntryDenyPerm(entry, grst_perm_vals[i]); else GRSTgaclEntryUndenyPerm(entry, grst_perm_vals[i]); - - } - - return; -} - -GRSTgaclEntry *GACLreturnEntry(GRSTgaclAcl *acl, int entry_no){ - // Returns a pointer to entry in ACL denoted by entry_no, returns NULL if not found - int number; - GRSTgaclEntry *entry; - - if (acl==NULL) return NULL; - - entry=acl->firstentry; - number=1; - - while (entry!=NULL) - { - if (number==entry_no) return entry; - number++; - entry=entry->next; - } - - return NULL; -} - - -GRSTgaclCred *GACLreturnCred(GRSTgaclEntry *entry, int cred_no){ - // Returns a pointer to credential denoted by cred_no in entry, returns NULL if not found - int number; - GRSTgaclCred *cred; - - if (entry==NULL) return NULL; - - cred=entry->firstcred; - number=1; - - while (cred!=NULL) - { - if (number==cred_no) return cred; - number++; - cred=cred->next; - } - - return NULL; -} -void StartHTML(GRSThttpBody *bp, char *dir_uri, char* dir_path){ - //Start HTML output and insert page title - printf("Status: 200 OK\nContent-Type: text/html\n"); - GRSThttpBodyInit(bp); - GRSThttpPrintf(bp, "Access Control List for %s\n", dir_uri); - GRSThttpPrintHeaderFooter(bp, dir_path, GRST_HEADFILE); - return; -} -void StartForm(GRSThttpBody *bp, char* dir_uri, char* dir_path, char* admin_file, int timestamp, char* target_function){ - // Starts an HTML form with gridsite admin as the target and target_function as the value of cmd. - // Also inputs the dir_uri and the timestamp - GRSThttpPrintf (bp, "
    \n", dir_uri, admin_file, dir_uri); - GRSThttpPrintf (bp, " \n", target_function); - GRSThttpPrintf (bp, " \n", timestamp); - return; -} - -void EndForm(GRSThttpBody *bp){ - GRSThttpPrintf (bp, "

    \n"); - GRSThttpPrintf (bp, "
    \n"); - return; -} - -void GRSTgaclCredTableStart(GRSThttpBody *bp){ - //Starts an HTML table of credentials by setting the column widths and inputting the headings - GRSThttpPrintf (bp,""); - GRSThttpPrintf (bp,""); - return; -} - -void GRSTgaclCredTableAdd(GRSTgaclUser *user, GRSTgaclEntry *entry, GRSTgaclCred *cred, GRSTgaclNamevalue *namevalue, int cred_no, int entry_no, int admin, int timestamp, GRSThttpBody *bp, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Adds the credential "cred" to a table started byGRSTgaclCredTableStart allowing the user to edit if appropriate - char* cmd = GRSThttpGetCGI("cmd"); - int edit_values=0, new_cred=0, allow_new_person=1; - int site_admin=GRSTgaclDNlistHasUser(getenv("REDIRECT_GRST_ADMIN_LIST"), user); - - if (strcmp(cmd, "new_entry_form")==0 || strcmp(cmd, "add_cred_form")==0) new_cred=1; - if (new_cred || strcmp(cmd, "edit_entry_form")==0) edit_values=1; - - if (new_cred) { /*Print out type and descriptor*/ - if (strcmp(cmd, "add_cred_form")==0){ /*if not a new entry check to see if cred exists.*/ - cred=entry->firstcred; - while (cred!=NULL) {if (strcmp (cred->type, "person")==0) allow_new_person=0; cred=cred->next;} - } - //create dummy credential for the user to edit - cred=GRSTgaclCredNew("new"); - GRSTgaclCredAddValue(cred, "", ""); - namevalue=cred->firstname; - //Drop down list of types - GRSThttpPrintf(bp,""); - GRSThttpPrintf(bp,""); - } - - else { //Print out type and descriptor for existing cred - - GRSThttpPrintf(bp,""); -} - -void GRSTgaclCredTableEnd(GRSTgaclEntry* entry, int entry_no, int admin, int timestamp, GRSThttpBody *bp, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - // Finishes off a table of credentials by inputting "Add Credential" link and a list of premissions in the final row - int i, blank_perms, edit_perms, show_perms; - char* cmd = GRSThttpGetCGI("cmd"); - - if (strcmp(cmd, "add_cred_form")==0 ||strcmp(cmd, "del_cred_sure")==0) show_perms=0; else show_perms=1; - if (strcmp(cmd, "edit_entry_form")==0 || strcmp(cmd, "new_entry_form")==0) edit_perms=1; else edit_perms=0; - if (strcmp(cmd, "new_entry_form")==0) blank_perms=1; else blank_perms=0; - - // If showing the last row is not required then exit - if (show_perms==0){GRSThttpPrintf (bp,"
    Credential No.TypeValue
    New"); - GRSThttpPrintf (bp, "
    %d", cred_no); - if (admin) GRSThttpPrintf (bp,"(Delete)", dir_uri,admin_file,dir_uri, entry_no, cred_no, timestamp); - GRSThttpPrintf(bp, "%s ", cred->type); - } - - if (strcmp(cred->type, "any-user")==0) GRSThttpPrintf (bp, " "); /* Do not print out namevalue for any-user credential*/ - else{ - if (edit_values){ // Place namevalue in an editable box if appropriate - GRSThttpPrintf (bp, "value, bp); - GRSThttpPrintf (bp, "\">"); - } - else if (strcmp(cred->type, "dn-list")==0){ - GRSThttpPrintf(bp, "value, bp); - GRSThttpPrintf(bp, " \">"); - StringHTMLEncode(namevalue->value, bp); - GRSThttpPrintf(bp, ""); - } - else { GRSThttpPrintf(bp, " "); StringHTMLEncode(namevalue->value, bp);} - - } - //Print out warning symbol if cred being printed relates to current user - but NOT for users in site admin list - if (GRSTgaclUserHasCred(user, cred) && !site_admin) GRSThttpPrintf(bp, " <--"); - GRSThttpPrintf(bp, "

    \n"); return;} - - GRSThttpPrintf (bp,""); - - if (admin) GRSThttpPrintf (bp,"Add Credential", dir_uri,admin_file,dir_uri, entry_no, timestamp); - - GRSThttpPrintf (bp, "\n "); - - if (blank_perms) entry->allowed=entry->denied=GRST_PERM_NONE; - - // Show Permissions - will produce a list or a list of check boxes depending on whether the permissions are to be edited or not - GRSThttpPrintf (bp, "Allowed: "); - for (i=0; grst_perm_syms[i]!=NULL; i++) /* Print the list of allowed permissions*/ - { - if ( entry->allowed & grst_perm_vals[i]){ - if (edit_perms) GRSThttpPrintf (bp, "%s   \n", grst_perm_syms[i],grst_perm_syms[i]); - else GRSThttpPrintf(bp,"%s ", grst_perm_syms[i]); if (strcmp(grst_perm_syms[i], "none")==0) break; - } - else if (strcmp(grst_perm_syms[i], "none")!=0 && edit_perms) GRSThttpPrintf (bp, "%s   \n", grst_perm_syms[i],grst_perm_syms[i]); - } - - if (edit_perms) GRSThttpPrintf (bp, "

    "); - GRSThttpPrintf (bp, "Denied: "); - for (i=0; grst_perm_syms[i]!=NULL; i++) /* Print the list of denied permissions*/ - { - if ( entry->denied & grst_perm_vals[i]) - { - if (edit_perms) GRSThttpPrintf (bp, "%s   \n", grst_perm_syms[i],grst_perm_syms[i]); - else GRSThttpPrintf(bp,"%s ", grst_perm_syms[i]); - if (strcmp(grst_perm_syms[i], "none")==0) break; - } - else if (strcmp(grst_perm_syms[i], "none")!=0 && edit_perms) GRSThttpPrintf (bp, "%s   \n", grst_perm_syms[i],grst_perm_syms[i]); - } - - GRSThttpPrintf (bp, ""); - GRSThttpPrintf (bp,"
    \n"); - GRSThttpPrintf (bp,"\n"); -} - -void check_acl_save(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file, GRSTgaclUser* user, GRSTgaclAcl *acl, GRSThttpBody *bp){ - // Checks if the acl for the current directory has been changed, check the current user's permissions. - // If all is okay the ACl is saved -> returns 1 else returns 0 - struct stat file_info; - GRSTgaclPerm new_perm; - char *vfile, *dir_path_vfile, *dir_path_file; - FILE *fp; - - - /*Check ACL has not been modified*/ - stat(GRSTgaclFileFindAclname(dir_path), &file_info); - if (atol(GRSThttpGetCGI("timestamp"))!=file_info.st_mtime){ - StartHTML(bp, dir_uri, dir_path); - GRSThttpPrintf (bp, "ERROR: CANNOT SAVE CHANGES

    The ACL has been modified since it was last viewed\n

    "); - admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, bp); - return; - } - - // check users permissions in the new ACL - - if (!GRSTgaclDNlistHasUser(getenv("REDIRECT_GRST_ADMIN_LIST"), user)) - { - new_perm = GRSTgaclAclTestUser(acl, user); - if (new_perm != perm){ - StartHTML(bp, dir_uri, dir_path); - if (!GRSTgaclPermHasAdmin(new_perm)){//Check that user still has Admin permissions - if not then exit without saving the new ACL - GRSThttpPrintf (bp, "ERROR: CANNOT SAVE CHANGES\n\n

    You cannot deny yourself admin access from within the editor\n"); - admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, bp); - return; - } - //Functions to inform of other permission changes come next - GRSThttpPrintf (bp, "WARNING: OPERATION CHANGED YOUR PERMISSIONS!\n\n

    You still have Admin permissions

    \n"); - admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, bp); - return; - } - } - // ACL not modified, notified of permission changes - can now save - - dir_path_file=GRSTgaclFileFindAclname(dir_path); - vfile=makevfilename(".gacl", file_info.st_size, dn); // Make temporary file name - dir_path_vfile = malloc(strlen(dir_path) + strlen(vfile) + 2); - strcpy(dir_path_vfile, dir_path); - strcat(dir_path_vfile, "/"); - strcat(dir_path_vfile, vfile); - - GRSTgaclAclSave(acl, dir_path_vfile); // save the new ACL to the temporary file - unlink(dir_path_file); - if (link (dir_path_vfile,dir_path_file)!=0) GRSThttpError("403 Forbidden"); - - printf ("Status: 302 Moved Temporarily\n Content Length: 0\nLocation: %s%s?cmd=admin_acl\n\n", dir_uri, admin_file); - return; -} - -void StringHTMLEncode (char* string, GRSThttpBody *bp){ - - char* current_char; - char* tmp; - int n; - tmp=malloc(2); - - *(tmp+1)='\0'; - current_char=string; - while(*current_char != '\0'){ - - if (*current_char == '<') GRSThttpPrintf (bp,"<"); - else if (*current_char == '>') GRSThttpPrintf (bp,">"); - else if (*current_char == '&') GRSThttpPrintf (bp,"&"); - else if (*current_char == '\'') GRSThttpPrintf (bp,"'"); - else if (*current_char == '"') GRSThttpPrintf (bp,"""); - else{ - *tmp=*current_char; - GRSThttpPrintf(bp, "%s", tmp); - - } - current_char++; - } - return; -} - -void revert_acl(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){ - char *AclFilename; - GRSTgaclAcl *acl; - GRSThttpBody bp; - // Load the old ACL, add the entry and save - AclFilename=malloc(strlen(dir_path)+strlen(file)+2); - strcpy(AclFilename, dir_path); - strcat(AclFilename, "/"); - strcat(AclFilename, file); - - acl = GRSTgaclAclLoadFile(AclFilename); - check_acl_save(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, user, acl, &bp); - return; -} diff --git a/org.gridsite.core/src/grst_admin_main.c b/org.gridsite.core/src/grst_admin_main.c deleted file mode 100644 index d884bf5..0000000 --- a/org.gridsite.core/src/grst_admin_main.c +++ /dev/null @@ -1,365 +0,0 @@ -/* - Andrew McNab and Shiv Kaushal, University of Manchester. - Copyright (c) 2002-3. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/*------------------------------------------------------------------* - * This program is part of GridSite: http://www.gridsite.org/ * - *------------------------------------------------------------------*/ - -#ifndef VERSION -#define VERSION "x.x.x" -#endif - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// when porting: remember that sendfile() is very OS-specific! -#include - -#include - -#include "grst_admin.h" - -/* - - GridSite human/interactive management interface. This should produce - a CGI executable, usually ./sbin/real-gridsite-admin.cgi, which is - called from HTML forms either by GET or POST methods or both (ie input - present in both QUERY_STRING and the stdin of the CGI process.) - - The CGI name/value pairs used are: - - cmd = edit, managedir, print, history - file = short name of file, without path - - If real-gridsite-admin.cgi is run by an internal redirection inside - mod_gridsite (as should ALWAYS be the case) then the environment - variable REDIRECT_GRST_DIR_PATH will be set to the full path of - the directory holding the file in question. This respects any complex - URI -> file path mapping done by Apache. - -*/ - -void GRSThttpError(char *status) -{ - printf("Status: %s\n", status); - printf("Server-CGI: GridSite Admin %s\n", VERSION); - printf("Content-Length: %d\n", 2 * strlen(status) + 58); - puts("Content-Type: text/html\n"); - - printf("%s\n", status); - printf("

    %s

    \n", status); - - exit(0); -} - -void adminfooter(GRSThttpBody *bp, char *dn, char *help_uri, char *dir_uri, - char *admin_file) -{ - GRSThttpPrintf(bp, "

    \n"); - - if (dn != NULL) GRSThttpPrintf(bp, "


    You are %s
    \n", dn); - else GRSThttpPrintf(bp, "
    \n"); - - if (admin_file != NULL) - GRSThttpPrintf(bp, "" - "Manage directory .\n", - dir_uri, admin_file); - else GRSThttpPrintf(bp, "" - "Back to directory .\n", dir_uri); - - if (help_uri != NULL) - GRSThttpPrintf(bp, "Website Help .\n", help_uri); - - if ((getenv("GRST_NO_LINK") == NULL) && - (getenv("REDIRECT_GRST_NO_LINK") == NULL)) - GRSThttpPrintf(bp, "Built with " - "GridSite %s\n", - VERSION); - - GRSThttpPrintf(bp, "
    \n"); -} - -int GRSTstrCmpShort(char *long_s, char *short_s) -{ - while (*short_s != '\0') - { - if (*long_s > *short_s) return +1; - if (*long_s < *short_s) return -1; - - ++long_s; - ++short_s; - } - - return 0; -} - -char *makevfilename(char *publicname, size_t size, char *dn) -{ - int i; - char *ext, *vfilename, *encpublicname, *encdn, *p; - struct timeval tv_now; - - gettimeofday(&tv_now, NULL); - - ext = rindex(publicname, '.'); - if (ext == NULL) ext = ""; - - encpublicname = GRSThttpUrlEncode(publicname); - for (p=encpublicname; *p != '\0'; ++p) if (*p == '%') *p = '='; - - encdn = GRSThttpUrlEncode(dn); - for (p=encdn; *p != '\0'; ++p) if (*p == '%') *p = '='; - - /* we used zero-padding for times so - alphanumeric sorting will sort chronologically too */ - - asprintf(&vfilename, "%s:%s:%08X:%05X:%X:%s:%s", GRST_HIST_PREFIX, - encpublicname, tv_now.tv_sec, tv_now.tv_usec, size, encdn, ext); - - return vfilename; -} - -void justheader(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *dir_uri, char *admin_file) -{ - GRSThttpBody bp; - - puts("Status: 200 OK\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_HEADFILE); - - GRSThttpWriteOut(&bp); -} - -void justfooter(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, - char *dir_uri, char *admin_file) -{ - GRSThttpBody bp; - - puts("Status: 200 OK\nContent-Type: text/html"); - - GRSThttpBodyInit(&bp); - - if (GRSTgaclPermHasList(perm) || GRSTgaclPermHasWrite(perm) - || GRSTgaclPermHasAdmin(perm)) - adminfooter(&bp, dn, help_uri, dir_uri, admin_file); - - GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE); - - GRSThttpWriteOut(&bp); -} - -int main() -{ - int gsiproxylimit_i = 1; - char *cmd, *dir_uri, *file, *dir_path, *admin_file, *dn = NULL, - *help_uri, *p, *content_type, *request_uri, *button, - *grst_cred_0, *gsiproxylimit, *dn_lists; - GRSTgaclCred *cred; - GRSTgaclUser *user = NULL; - GRSTgaclAcl *acl; - GRSTgaclPerm perm = GRST_PERM_NONE; - - help_uri = getenv("REDIRECT_GRST_HELP_URI"); /* can be NULL */ - admin_file = getenv("REDIRECT_GRST_ADMIN_FILE"); - dir_path = getenv("REDIRECT_GRST_DIR_PATH"); - request_uri = getenv("REQUEST_URI"); - - if ((dir_path == NULL) || (admin_file == NULL) || (request_uri == NULL)) - { - puts("Status: 500 Internal Server Error\nContent-type: text/plain\n\n" - "REDIRECT_GRST_DIR_PATH or REDIRECT_GRST_ADMIN_FILE " - "or REQUEST_URI missing"); - return; - } - - GRSTgaclInit(); - - grst_cred_0 = getenv("GRST_CRED_0"); - - if ((grst_cred_0 != NULL) && (cred = GRSTx509CompactToCred(grst_cred_0))) - { - gsiproxylimit = getenv("REDIRECT_GRST_GSIPROXY_LIMIT"); - if (gsiproxylimit != NULL) sscanf(gsiproxylimit, "%d", &gsiproxylimit_i); - - if (GRSTgaclCredGetDelegation(cred) <= gsiproxylimit_i) - { - user = GRSTgaclUserNew(cred); - - if ((p = index(grst_cred_0, ' ')) && - (p = index(++p, ' ')) && - (p = index(++p, ' ')) && - (p = index(++p, ' '))) dn = &p[1]; - } - } - else if ((dn = getenv("SSL_CLIENT_S_DN")) != NULL) - { - cred = GRSTgaclCredNew("person"); - GRSTgaclCredAddValue(cred, "dn", dn); - user = GRSTgaclUserNew(cred); - } - - dn_lists = getenv("REDIRECT_GRST_DN_LISTS"); - if (dn_lists == NULL) dn_lists = getenv("GRST_DN_LISTS"); - if (dn_lists != NULL) GRSTgaclUserSetDNlists(user, dn_lists); - - if (GRSTgaclDNlistHasUser(getenv("REDIRECT_GRST_ADMIN_LIST"), - user)) perm = GRST_PERM_ALL; - else - { - p = getenv("REMOTE_HOST"); - if (p != NULL) - { - cred = GRSTgaclCredNew("dns"); - GRSTgaclCredAddValue(cred, "hostname", p); - - if (user == NULL) user = GRSTgaclUserNew(cred); - else GRSTgaclUserAddCred(user, cred); - } - - acl = GRSTgaclAclLoadforFile(dir_path); - if (acl != NULL) perm = GRSTgaclAclTestUser(acl, user); - } - - /* we're relying on being a CGI with all this un-free()ed strdup()ing */ - - dir_uri = strdup(request_uri); - p = rindex(dir_uri, '?'); - if (p != NULL) *p = '\0'; - p = rindex(dir_uri, '/'); - if (p != NULL) p[1] = '\0'; - - content_type = getenv("CONTENT_TYPE"); - - if ((content_type != NULL) && - (GRSTstrCmpShort(content_type, "multipart/form-data; boundary=") == 0)) - { - uploadfile(dn, perm, help_uri, dir_path, dir_uri, admin_file); - return 0; - } - - cmd = GRSThttpGetCGI("cmd"); - file = GRSThttpGetCGI("file"); - button = GRSThttpGetCGI("button"); - - /* file and directory functions in grst_admin_file.c */ - - if (strcmp(cmd, "header") == 0) - justheader(dn, perm, help_uri, dir_path, dir_uri, admin_file); - else if (strcmp(cmd, "footer") == 0) - justfooter(dn, perm, help_uri, dir_path, dir_uri, admin_file); - else if (strcmp(cmd, "managedir") == 0) - managedir(dn, perm, help_uri, dir_path, dir_uri, admin_file); - else if (strcmp(cmd, "print") == 0) - printfile(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "history") == 0) - filehistory(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "editdnlist") == 0) - editdnlistform(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "edit") == 0) - { - if ((strcasecmp(button, "new directory") == 0) || - (strcasecmp(button, "Create") == 0)) - newdirectory(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else - editfileform(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - } - else if (strcmp(cmd, "editaction") == 0) - editfileaction(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "editdnlistaction") == 0) - editdnlistaction(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "delete") == 0) - deletefileform(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "deleteaction") == 0) - deletefileaction(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "rename") == 0) - renameform(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "renameaction") == 0) - renameaction(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "ziplist") == 0) - ziplist(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "unzipfile") == 0) - unzipfile(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "create_acl") == 0) - create_acl(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - - /* GACL functions in grst_admin_gacl.c */ - - else if (strcmp(cmd, "show_acl") == 0) - show_acl(0, user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "admin_acl") == 0) - show_acl(1, user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "acl_history") == 0) - show_acl(2, user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd, "revert_acl") == 0) - revert_acl(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - //show_acl(2, user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd,"new_entry_form")==0) - new_entry_form(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd,"new_entry")==0) - new_entry(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd,"del_entry_sure")==0) - del_entry_sure(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd,"del_entry")==0) - del_entry(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd,"edit_entry_form")==0) - edit_entry_form(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd,"edit_entry")==0) - edit_entry(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd,"add_cred_form")==0) - add_cred_form(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd,"add_cred")==0) - add_cred(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd,"del_cred_sure")==0) - del_cred_sure(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - else if (strcmp(cmd,"del_cred")==0) - del_cred(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); - - /* you what? */ - - else GRSThttpError("500 Internal Server Error"); -} diff --git a/org.gridsite.core/src/grst_gacl.c b/org.gridsite.core/src/grst_gacl.c deleted file mode 100644 index 13b46c8..0000000 --- a/org.gridsite.core/src/grst_gacl.c +++ /dev/null @@ -1,1154 +0,0 @@ -/* - Copyright (c) 2002-3, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ -/*---------------------------------------------------------------* - * For more information about GridSite: http://www.gridsite.org/ * - *---------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include - -#include -#include -#include - -#include "gridsite.h" - -/* * - * Global variables, shared by all GACL functions by private to libgacl * - * */ - -char *grst_perm_syms[] = { "none", - "read", - "exec", - "list", - "write", - "admin", - NULL }; - -GRSTgaclPerm grst_perm_vals[] = { GRST_PERM_NONE, - GRST_PERM_READ, - GRST_PERM_EXEC, - GRST_PERM_LIST, - GRST_PERM_WRITE, - GRST_PERM_ADMIN, - -1 }; - -int GRSTgaclInit(void) -{ - xmlInitParser(); - - LIBXML_TEST_VERSION - - xmlKeepBlanksDefault(0); - - return 1; -} - -/* * - * Functions to manipulate GRSTgaclCred structures * - * */ - -GRSTgaclCred *GRSTgaclCredNew(char *type) -/* - GRSTgaclCredNew - allocate a new GRSTgaclCred structure, and return - it's pointer or NULL on (malloc) error. -*/ -{ - GRSTgaclCred *newcred; - - if (type == NULL) return NULL; - - newcred = malloc(sizeof(GRSTgaclCred)); - if (newcred == NULL) return NULL; - - newcred->type = strdup(type); - newcred->delegation = 0; - newcred->firstname = NULL; - newcred->next = NULL; - - return newcred; -} - -int GRSTgaclCredAddValue(GRSTgaclCred *cred, char *rawname, char *rawvalue) -/* - GRSTgaclCredAddValue - add a name/value pair to a GRSTgaclCred -*/ -{ - int i; - char *name, *value; - GRSTgaclNamevalue *p; - - name = strdup(rawname); - - /* no leading or trailing space in value */ - - value = rawvalue; - while ((*value != '\0') && isspace(*value)) ++value; - - value = strdup(value); - - for (i=strlen(value) - 1; (i >= 0) && isspace(value[i]); --i) value[i]='\0'; - - if (cred->firstname == NULL) - { - cred->firstname = malloc(sizeof (GRSTgaclNamevalue)); - (cred->firstname)->name = name; - (cred->firstname)->value = value; - (cred->firstname)->next = NULL; - } - else - { - p = cred->firstname; - - while (p->next != NULL) p = (GRSTgaclNamevalue *) p->next; - - p->next = malloc(sizeof(GRSTgaclNamevalue)); - ((GRSTgaclNamevalue *) p->next)->name = name; - ((GRSTgaclNamevalue *) p->next)->value = value; - ((GRSTgaclNamevalue *) p->next)->next = NULL; - } - - return 1; -} - -static int GRSTgaclNamevalueFree(GRSTgaclNamevalue *p) -{ - if (p == NULL) return 1; - - if (p->next != NULL) - GRSTgaclNamevalueFree((GRSTgaclNamevalue *) p->next); - if (p->name != NULL) free(p->name); - if (p->value != NULL) free(p->value); - free(p); - - return 1; -} - -int GRSTgaclCredFree(GRSTgaclCred *cred) -/* - GRSTgaclCredFree - free memory structures of a GRSTgaclCred, - returning 1 always! -*/ -{ - if (cred == NULL) return 1; - - GRSTgaclNamevalueFree(cred->firstname); - if (cred->type != NULL) free(cred->type); - free(cred); - - return 1; -} - -static int GRSTgaclCredsFree(GRSTgaclCred *firstcred) -/* - GRSTgaclCredsFree - free a cred and all the creds in its *next chain -*/ -{ - if (firstcred == NULL) return 0; - - if (firstcred->next != NULL) GRSTgaclCredsFree(firstcred->next); - - return GRSTgaclCredFree(firstcred); -} - -static int GRSTgaclCredInsert(GRSTgaclCred *firstcred, GRSTgaclCred *newcred) -/* - GRSTgaclCredInsert - insert a cred in the *next chain of firstcred - - FOR THE MOMENT THIS JUST APPENDS! -*/ -{ - if (firstcred == NULL) return 0; - - if (firstcred->next == NULL) - { - firstcred->next = newcred; - return 1; - } - - return GRSTgaclCredInsert(firstcred->next, newcred); -} - -int GRSTgaclEntryAddCred(GRSTgaclEntry *entry, GRSTgaclCred *cred) -/* - GRSTaddCred - add a new credential to an existing entry, returning 1 - on success or 0 on error -*/ -{ - if (entry == NULL) return 0; - - if (entry->firstcred == NULL) - { - entry->firstcred = cred; - return 1; - } - else return GRSTgaclCredInsert(entry->firstcred, cred); -} - -static int GRSTgaclCredRemoveCred(GRSTgaclCred *firstcred, GRSTgaclCred *oldcred) -/* - (Private) - - GRSTgaclCredRemoveCred - remove a cred in the *next chain of firstcred - and relink the chain -*/ -{ - if (firstcred == NULL) return 0; - -// yeah, I know -} - -int GRSTgaclEntryDelCred(GRSTgaclEntry *entry, GRSTgaclCred *cred) -/* - GRSTgaclEntryDelCred - remove a new cred from an entry, returning 1 - on success (or absense) or 0 on error. -*/ -{ - if (entry == NULL) return 0; - - return GRSTgaclCredRemoveCred(entry->firstcred, cred); -} - -int GRSTgaclCredPrint(GRSTgaclCred *cred, FILE *fp) -/* - GRSTgaclCredPrint - print a credential and any name-value pairs is contains -*/ -{ - char *q; - GRSTgaclNamevalue *p; - - if (cred->firstname != NULL) - { - fprintf(fp, "<%s>\n", cred->type); - - p = cred->firstname; - - do { - fprintf(fp, "<%s>", p->name); - - for (q=p->value; *q != '\0'; ++q) - if (*q == '<') fputs("<", fp); - else if (*q == '>') fputs(">", fp); - else if (*q == '&') fputs("&" , fp); - else if (*q == '\'') fputs("'", fp); - else if (*q == '"') fputs(""", fp); - else fputc(*q, fp); - - fprintf(fp, "\n", p->name); - - p = (GRSTgaclNamevalue *) p->next; - - } while (p != NULL); - - fprintf(fp, "\n", cred->type); - } - else fprintf(fp, "<%s/>\n", cred->type); - - return 1; -} - -/* * - * Functions to manipulate GRSTgaclEntry structures * - * */ - -GRSTgaclEntry *GRSTgaclEntryNew(void) -/* - GRSTgaclEntryNew - allocate space for a new entry, returning its pointer - or NULL on failure. -*/ -{ - GRSTgaclEntry *newentry; - - newentry = (GRSTgaclEntry *) malloc(sizeof(GRSTgaclEntry)); - if (newentry == NULL) return NULL; - - newentry->firstcred = NULL; - newentry->allowed = 0; - newentry->denied = 0; - newentry->next = NULL; - - return newentry; -} - -int GRSTgaclEntryFree(GRSTgaclEntry *entry) -/* - GRSTgaclEntryFree - free up space used by an entry (always returns 1) -*/ -{ - int i; - - if (entry == NULL) return 1; - - GRSTgaclCredsFree(entry->firstcred); - - free(entry); - - return 1; -} - -static int GRSTgaclEntriesFree(GRSTgaclEntry *entry) -/* - GRSTgaclEntriesFree - free up entry and all entries linked to in its *next - chain -*/ -{ - if (entry == NULL) return 0; - - if (entry->next != NULL) GRSTgaclEntriesFree(entry->next); - - return GRSTgaclEntryFree(entry); -} - -static int GRSTgaclEntryInsert(GRSTgaclEntry *firstentry, GRSTgaclEntry *newentry) -/* - GRSTgaclEntryInsert - insert an entry in the *next chain of firstentry - - FOR THE MOMENT THIS JUST APPENDS -*/ -{ - if (firstentry == NULL) return 0; - - if (firstentry->next == NULL) - { - firstentry->next = newentry; - return 1; - } - - return GRSTgaclEntryInsert(firstentry->next, newentry); -} - -int GRSTgaclAclAddEntry(GRSTgaclAcl *acl, GRSTgaclEntry *entry) -/* - GRSTgaclAclAddEntry - add a new entry to an existing acl, returning 1 - on success or 0 on error -*/ -{ - if (acl == NULL) return 0; - - if (acl->firstentry == NULL) - { - acl->firstentry = entry; - return 1; - } - else return GRSTgaclEntryInsert(acl->firstentry, entry); -} - -int GRSTgaclEntryPrint(GRSTgaclEntry *entry, FILE *fp) -{ - GRSTgaclCred *cred; - GRSTgaclPerm i; - - fputs("\n", fp); - - for (cred = entry->firstcred; cred != NULL; cred = cred->next) - GRSTgaclCredPrint(cred, fp); - - if (entry->allowed) - { - fputs("", fp); - - for (i=GRST_PERM_READ; i <= GRST_PERM_ADMIN; ++i) - if ((entry->allowed) & i) GRSTgaclPermPrint(i, fp); - - fputs("\n", fp); - } - - - if (entry->denied) - { - fputs("", fp); - - for (i=GRST_PERM_READ; i <= GRST_PERM_ADMIN; ++i) - if (entry->denied & i) GRSTgaclPermPrint(i, fp); - - fputs("\n", fp); - } - - fputs("\n", fp); - - return 1; -} - -/* * - * Functions to manipulate GRSTgaclPerm items * - * */ - -int GRSTgaclPermPrint(GRSTgaclPerm perm, FILE *fp) -{ - GRSTgaclPerm i; - - for (i=GRST_PERM_READ; grst_perm_syms[i] != NULL; ++i) - if (perm == grst_perm_vals[i]) - { - fprintf(fp, "<%s/>", grst_perm_syms[i]); - return 1; - } - - return 0; -} - -int GRSTgaclEntryAllowPerm(GRSTgaclEntry *entry, GRSTgaclPerm perm) -{ - entry->allowed = entry->allowed | perm; - - return 1; -} - -int GRSTgaclEntryUnallowPerm(GRSTgaclEntry *entry, GRSTgaclPerm perm) -{ - entry->allowed = entry->allowed & ~perm; - - return 1; -} - -int GRSTgaclEntryDenyPerm(GRSTgaclEntry *entry, GRSTgaclPerm perm) -{ - entry->denied = entry->denied | perm; - - return 1; -} - -int GRSTgaclEntryUndenyPerm(GRSTgaclEntry *entry, GRSTgaclPerm perm) -{ - entry->denied = entry->denied & ~perm; - - return 1; -} - -char *GRSTgaclPermToChar(GRSTgaclPerm perm) -/* - GRSTgaclPermToChar - return char * or NULL corresponding to most significant - set bit of perm. -*/ -{ - char *p = NULL; - GRSTgaclPerm i; - - for (i=0; grst_perm_syms[i] != NULL; ++i) - if (perm & grst_perm_vals[i]) p = grst_perm_syms[i]; - - return p; -} - -GRSTgaclPerm GRSTgaclPermFromChar(char *s) -/* - GRSTgaclPermToChar - return access perm corresponding to symbol s[] -*/ -{ - GRSTgaclPerm i; - - for (i=0; grst_perm_syms[i] != NULL; ++i) - if (strcasecmp(grst_perm_syms[i], s) == 0) return grst_perm_vals[i]; - - return -1; -} - -/* * - * Functions to manipulate GRSTgaclAcl structures * - * */ - -GRSTgaclAcl *GRSTgaclAclNew(void) -/* - GRSTgaclAclNew - allocate a new acl and return its pointer (or NULL - on failure.) -*/ -{ - GRSTgaclAcl *newacl; - - newacl = (GRSTgaclAcl *) malloc(sizeof(GRSTgaclAcl)); - if (newacl == NULL) return NULL; - - newacl->firstentry = NULL; - - return newacl; -} - -int GRSTgaclAclFree(GRSTgaclAcl *acl) -/* - GRSTgaclAclFree - free up space used by *acl. Always returns 1. -*/ -{ - if (acl == NULL) return 1; - - GRSTgaclEntriesFree(acl->firstentry); - - return 1; -} - -int GRSTgaclAclPrint(GRSTgaclAcl *acl, FILE *fp) -{ - GRSTgaclEntry *entry; - - fputs("\n", fp); - - for (entry = acl->firstentry; entry != NULL; entry = entry->next) - GRSTgaclEntryPrint(entry, fp); - - fputs("\n", fp); - - return 1; -} - -int GRSTgaclAclSave(GRSTgaclAcl *acl, char *filename) -{ - int ret; - FILE *fp; - - fp = fopen(filename, "w"); - if (fp == NULL) return 0; - - fputs("\n", fp); - - ret = GRSTgaclAclPrint(acl, fp); - - fclose(fp); - - return ret; -} - -/* * - * Functions for loading and parsing XML using libxml * - * */ - -// need to check these for libxml memory leaks? - what needs to be freed? - -static GRSTgaclCred *GRSTgaclCredParse(xmlNodePtr cur) -/* - GRSTgaclCredParse - parse a credential stored in the libxml structure cur, - returning it as a pointer or NULL on error. -*/ -{ - xmlNodePtr cur2; - GRSTgaclCred *cred; - - cred = GRSTgaclCredNew((char *) cur->name); - - cred->firstname = NULL; - cred->next = NULL; - - for (cur2 = cur->xmlChildrenNode; cur2 != NULL; cur2=cur2->next) - { - GRSTgaclCredAddValue(cred, (char *) cur2->name, - (char *) xmlNodeGetContent(cur2)); - } - - return cred; -} - -static GRSTgaclEntry *GRSTgaclEntryParse(xmlNodePtr cur) -/* - GRSTgaclEntryParse - parse an entry stored in the libxml structure cur, - returning it as a pointer or NULL on error. -*/ -{ - int i; - xmlNodePtr cur2; - GRSTgaclEntry *entry; - GRSTgaclCred *cred; - GRSTgaclPerm perm; - - if (xmlStrcmp(cur->name, (const xmlChar *) "entry") != 0) return NULL; - - cur = cur->xmlChildrenNode; - - entry = GRSTgaclEntryNew(); - - while (cur != NULL) - { - if (xmlStrcmp(cur->name, (const xmlChar *) "allow") == 0) - { - for (cur2 = cur->xmlChildrenNode; cur2 != NULL; cur2=cur2->next) - for (i=0; grst_perm_syms[i] != NULL; ++i) - if (xmlStrcmp(cur2->name, - (const xmlChar *) grst_perm_syms[i]) == 0) - GRSTgaclEntryAllowPerm(entry, grst_perm_vals[i]); - } - else if (xmlStrcmp(cur->name, (const xmlChar *) "deny") == 0) - { - for (cur2 = cur->xmlChildrenNode; cur2 != NULL; cur2=cur2->next) - for (i=0; grst_perm_syms[i] != NULL; ++i) - if (xmlStrcmp(cur2->name, - (const xmlChar *) grst_perm_syms[i]) == 0) - GRSTgaclEntryDenyPerm(entry, grst_perm_vals[i]); - } - else if ((cred = GRSTgaclCredParse(cur)) != NULL) - { - if (!GRSTgaclEntryAddCred(entry, cred)) - { - GRSTgaclCredFree(cred); - GRSTgaclEntryFree(entry); - return NULL; - } - } - else /* I cannot parse this - give up rather than get it wrong */ - { - GRSTgaclEntryFree(entry); - return NULL; - } - - cur=cur->next; - } - - return entry; -} - -GRSTgaclAcl *GRSTgaclAclLoadFile(char *filename) -{ - xmlDocPtr doc; - xmlNodePtr cur; - GRSTgaclAcl *acl; - GRSTgaclEntry *entry; - - doc = xmlParseFile(filename); - if (doc == NULL) return NULL; - - cur = xmlDocGetRootElement(doc); - - if (xmlStrcmp(cur->name, (const xmlChar *) "gacl")) - { - free(doc); - free(cur); - return NULL; - } - - cur = cur->xmlChildrenNode; - - acl = GRSTgaclAclNew(); - - while (cur != NULL) - { - entry = GRSTgaclEntryParse(cur); - if (entry == NULL) - { - GRSTgaclAclFree(acl); - xmlFreeDoc(doc); - return NULL; - } - - GRSTgaclAclAddEntry(acl, entry); - - cur=cur->next; - } - - xmlFreeDoc(doc); - return acl; -} - -int GRSTgaclFileIsAcl(char *pathandfile) -/* Return 1 if filename in *pathandfile starts GRST_ACL_FILE - Return 0 otherwise. */ -{ - char *filename; - - filename = rindex(pathandfile, '/'); - if (filename == NULL) filename = pathandfile; - else filename++; - - return (strncmp(filename, GRST_ACL_FILE, sizeof(GRST_ACL_FILE) - 1) == 0); -} - -char *GRSTgaclFileFindAclname(char *pathandfile) -/* Return malloc()ed ACL filename that governs the given file or directory - (for directories, the ACL file is in the directory itself), or NULL if none - can be found. */ -{ - int len; - char *path, *file, *p; - struct stat statbuf; - - len = strlen(pathandfile); - if (len == 0) return NULL; - - path = malloc(len + sizeof(GRST_ACL_FILE) + 2); - strcpy(path, pathandfile); - - if ((stat(path, &statbuf) == 0) && - S_ISDIR(statbuf.st_mode) && - (path[len-1] != '/')) - { - strcat(path, "/"); - ++len; - } - - if (path[len-1] != '/') - { - p = rindex(pathandfile, '/'); - if (p != NULL) - { - file = &p[1]; - p = rindex(path, '/'); - sprintf(p, "/%s:%s", GRST_ACL_FILE, file); - - if (stat(path, &statbuf) == 0) return path; - - *p = '\0'; /* otherwise strip off any filename */ - } - } - - while (path[0] != '\0') - { - strcat(path, "/"); - strcat(path, GRST_ACL_FILE); - - if (stat(path, &statbuf) == 0) return path; - - p = rindex(path, '/'); - *p = '\0'; /* strip off the / we added for ACL */ - - p = rindex(path, '/'); - if (p == NULL) break; /* must start without / and we there now ??? */ - - *p = '\0'; /* strip off another layer of / */ - } - - free(path); - return NULL; -} - -GRSTgaclAcl *GRSTgaclAclLoadforFile(char *pathandfile) -/* Return ACL that governs the given file or directory (for directories, - the ACL file is in the directory itself.) */ -{ - char *path; - GRSTgaclAcl *acl; - - path = GRSTgaclFileFindAclname(pathandfile); - - if (path != NULL) - { - acl = GRSTgaclAclLoadFile(path); - free(path); - return acl; - } - - return NULL; -} - -/* * - * Functions to create and query GACLuser * - * */ - -GRSTgaclUser *GRSTgaclUserNew(GRSTgaclCred *cred) -{ - GRSTgaclUser *user; - - if (cred == NULL) return NULL; - - user = malloc(sizeof(GRSTgaclUser)); - - if (user != NULL) user->firstcred = cred; - - user->dnlists = NULL; - - return user; -} - -int GRSTgaclUserFree(GRSTgaclUser *user) -{ - if (user == NULL) return 1; - - if (user->firstcred != NULL) GRSTgaclCredsFree(user->firstcred); - - if (user->dnlists != NULL) free(user->dnlists); - - free(user); - - return 1; -} - -int GRSTgaclUserAddCred(GRSTgaclUser *user, GRSTgaclCred *cred) -{ - GRSTgaclCred *crediter; - - if ((user == NULL) || (cred == NULL)) return 0; - - if (user->firstcred == NULL) - { - user->firstcred = cred; - cred->next = NULL; /* so cannot be used to add whole lists */ - return 1; - } - - crediter = user->firstcred; - - while (crediter->next != NULL) crediter = crediter->next; - - crediter->next = cred; - cred->next = NULL; /* so cannot be used to add whole lists */ - - return 1; -} - -int GRSTgaclUserHasCred(GRSTgaclUser *user, GRSTgaclCred *cred) -/* test if the user has the given credential */ -{ - GRSTgaclCred *crediter; - GRSTgaclNamevalue *usernamevalue, *crednamevalue; - - if (cred == NULL) return 0; - - if (strcmp(cred->type, "any-user") == 0) return 1; - - if (user == NULL) return 0; - - if (strcmp(cred->type, "dn-list") == 0) - { - if ((cred->firstname == NULL) || - (strcmp((cred->firstname)->name, "url") != 0) || - ((cred->firstname)->next != NULL)) return 0; - - return GRSTgaclDNlistHasUser((cred->firstname)->value, user); - } - - if (strcmp(cred->type, "dns") == 0) - { - if ((user->firstcred == NULL) || - ((user->firstcred)->firstname == NULL) || - (cred->firstname == NULL) || - (strcmp((cred->firstname)->name, "hostname") != 0) || - ((cred->firstname)->next != NULL)) return 0; - - for (crediter=user->firstcred; - crediter != NULL; - crediter = crediter->next) - if (strcmp(crediter->type, "dns") == 0) - { - if ((crediter->firstname == NULL) || - (strcmp((crediter->firstname)->name, "hostname") != 0)) return 0; - - return (fnmatch((cred->firstname)->value, - (crediter->firstname)->value, FNM_CASEFOLD) == 0); - } - - return 0; - } - - if (strcmp(cred->type, "auth-user") == 0) - { - if ((user->firstcred == NULL) || - ((user->firstcred)->firstname == NULL)) return 0; - - for (crediter=user->firstcred; - crediter != NULL; - crediter = crediter->next) - if (strcmp(crediter->type, "person") == 0) return 1; - - return 0; - } - - for (crediter=user->firstcred; crediter != NULL; crediter = crediter->next) - { - if (strcmp(crediter->type, cred->type) != 0) continue; - - if ((crediter->firstname == NULL) && - (cred->firstname == NULL)) return 1; - - if ((crediter->firstname == NULL) || - (cred->firstname == NULL)) continue; - - usernamevalue = crediter->firstname; - crednamevalue = cred->firstname; - - for (;;) - { - if (strcmp(usernamevalue->name,crednamevalue->name) != 0) break; - - if (strcmp(cred->type, "person") == 0) - { - if (GRSTx509NameCmp(usernamevalue->value, - crednamevalue->value) != 0) break; - } - else if (strcmp(usernamevalue->value, - crednamevalue->value) != 0) break; - - /* ok if cred list runs out before user's cred list */ - if (crednamevalue->next == NULL) return 1; - - /* but not ok if more names to match which user doesn't have */ - if (usernamevalue->next == NULL) break; - - crednamevalue = (GRSTgaclNamevalue *) crednamevalue->next; - usernamevalue = (GRSTgaclNamevalue *) usernamevalue->next; - } - } - - return 0; -} - -GRSTgaclCred *GRSTgaclUserFindCredtype(GRSTgaclUser *user, char *type) -/* find the first credential of a given type for this user */ -{ - GRSTgaclCred *cred; - - if (user == NULL) return NULL; - - cred = user->firstcred; - - while (cred != NULL) - { - if (strcmp(cred->type, type) == 0) return cred; - - cred = cred->next; - } - - return NULL; -} - -int GRSTgaclUserSetDNlists(GRSTgaclUser *user, char *dnlists) -{ - if ((user == NULL) || (dnlists == NULL)) return 0; - - if (user->dnlists != NULL) free(user->dnlists); - - user->dnlists = strdup(dnlists); - - return 1; -} - -/* * - * Functions to test for access perm of an individual * - * */ - -static char *recurse4file(char *dir, char *file, int recurse_level) -/* try to find file[] in dir[]. try subdirs if not found. - return full path to first found version or NULL on failure */ -{ - char *fullfilename, *fulldirname; - struct stat statbuf; - DIR *dirDIR; - struct dirent *file_ent; - - /* try to find in current directory */ - - asprintf(&fullfilename, "%s/%s", dir, file); - if (stat(fullfilename, &statbuf) == 0) return fullfilename; - free(fullfilename); - - /* maybe search in subdirectories */ - - if (recurse_level >= GRST_RECURS_LIMIT) return NULL; - - dirDIR = opendir(dir); - - if (dirDIR == NULL) return NULL; - - while ((file_ent = readdir(dirDIR)) != NULL) - { - if (file_ent->d_name[0] == '.') continue; - - asprintf(&fulldirname, "%s/%s", dir, file_ent->d_name); - - if ((stat(fulldirname, &statbuf) == 0) && - S_ISDIR(statbuf.st_mode) && - ((fullfilename = recurse4file(fulldirname, file, - recurse_level + 1)) != NULL)) - { - closedir(dirDIR); - return fullfilename; - } - - free(fulldirname); - } - - closedir(dirDIR); - - return NULL; -} - -int GRSTgaclDNlistHasUser(char *listurl, GRSTgaclUser *user) -{ - char *dn_lists_dirs, *dn_list_ptr, *enclisturl, *filename, *dirname, - line[512], *p; - FILE *fp; - GRSTgaclCred *cred; - - if ((listurl == NULL) || (user == NULL)) return 0; - - enclisturl = GRSThttpUrlEncode(listurl); - - if (user->dnlists != NULL) p = user->dnlists; - else p = getenv("GRST_DN_LISTS"); - - if (p == NULL) p = GRST_DN_LISTS; - dn_lists_dirs = strdup(p); /* we need to keep this for free() later! */ - dn_list_ptr = dn_lists_dirs; /* copy, for naughty function strsep() */ - - while ((dirname = strsep(&dn_list_ptr, ":")) != NULL) - { - filename = recurse4file(dirname, enclisturl, 0); - if (filename == NULL) continue; - - fp = fopen(filename, "r"); - free(filename); - - if (fp == NULL) continue; - - while (fgets(line, sizeof(line), fp) != NULL) - { - p = index(line, '\n'); - if (p != NULL) *p = '\0'; - - cred = user->firstcred; - - while (cred != NULL) - { - if ((strcmp(cred->type, "person") == 0) && - (cred->firstname != NULL) && - (strcmp("dn", (cred->firstname)->name) == 0) && - (GRSTx509NameCmp(line, (cred->firstname)->value) == 0)) - { - fclose(fp); - free(dn_lists_dirs); - free(enclisturl); - return 1; - } - - cred = cred->next; - } - } - - fclose(fp); - } - - free(dn_lists_dirs); - free(enclisturl); - - return 0; -} - -GRSTgaclPerm GRSTgaclAclTestUser(GRSTgaclAcl *acl, GRSTgaclUser *user) -/* - GACLgaclAclTestUser - return bit fields depending on access perms user has - for given acl. All zero for no access. If *user is - NULL, matching to "any-user" will still work. -*/ -{ - int flag, onlyanyuser; - GRSTgaclPerm allowperms = 0, denyperms = 0, allowed; - GRSTgaclEntry *entry; - GRSTgaclCred *cred, *usercred; - - if (acl == NULL) return 0; - - for (entry = acl->firstentry; entry != NULL; entry = entry->next) - { - flag = 1; /* begin by assuming this entry applies to us */ - onlyanyuser = 1; /* begin by assuming just */ - - /* now go through creds, checking they all do apply to us */ - - for (cred = entry->firstcred; cred != NULL; cred = cred->next) - if (!GRSTgaclUserHasCred(user, cred)) flag = 0; - else if (strcmp(cred->type, "any-user") != 0) onlyanyuser = 0; - - if (!flag) continue; /* flag false if a subtest failed */ - - /* does apply to us, so we remember this entry's perms */ - - /* we dont allow Write or Admin on the basis of any-user alone */ - - allowed = entry->allowed; - - if (onlyanyuser) - allowed = entry->allowed & ~GRST_PERM_WRITE & ~GRST_PERM_ADMIN; - else allowed = entry->allowed; - - allowperms = allowperms | allowed; - denyperms = denyperms | entry->denied; - } - - return (allowperms & (~ denyperms)); - /* for each perm type, any deny we saw kills any allow */ -} - -GRSTgaclPerm GRSTgaclAclTestexclUser(GRSTgaclAcl *acl, GRSTgaclUser *user) -/* - GRSTgaclAclTestexclUser - - return bit fields depending on ALLOW perms OTHER users - have for given acl. All zero if they have no access. - (used for testing if a user has exclusive access) -*/ -{ - int flag; - GRSTgaclPerm perm = 0; - GRSTgaclEntry *entry; - GRSTgaclCred *cred; - - if (acl == NULL) return 0; - - for (entry = acl->firstentry; entry != NULL; entry = entry->next) - { - flag = 0; /* flag will be set if cred implies other users */ - - for (cred = entry->firstcred; cred != NULL; cred = cred->next) - { - if (strcmp(cred->type, "person") != 0) - /* if we ever add support for other person-specific credentials, - they must also be recognised here */ - { - flag = 1; - break; - } - - if (!GRSTgaclUserHasCred(user, cred)) - /* if user doesnt have this person credential, assume - it refers to a different individual */ - { - flag = 1; - break; - } - } - - if (flag) perm = perm | entry->allowed; - } - - return perm; -} - -/* - Wrapper functions for gridsite-gacl.h support of legacy API -*/ - -GRSTgaclEntry *GACLparseEntry(xmlNodePtr cur) -{ - return GRSTgaclEntryParse(cur); -} diff --git a/org.gridsite.core/src/grst_http.c b/org.gridsite.core/src/grst_http.c deleted file mode 100644 index c7b375e..0000000 --- a/org.gridsite.core/src/grst_http.c +++ /dev/null @@ -1,407 +0,0 @@ -/* - Copyright (c) 2002-3, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef VERSION -#define VERSION "x.x.x" -#endif - -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "gridsite.h" - -void GRSThttpBodyInit(GRSThttpBody *thisbody) -{ - thisbody->size = 0; /* simple, but we don't expose internals to callers */ -} - -void GRSThttpPrintf(GRSThttpBody *thisbody, char *fmt, ...) -/* append printf() style format and arguments to *thisbody. - This requires vasprintf from glibc!! */ -{ - char *p; - size_t size; - va_list args; - - va_start(args, fmt); - size = vasprintf(&p, fmt, args); - va_end(args); - - if (size == 0) free(p); /* don't need to bother in this case */ - else if (size > 0) - { - if (thisbody->size == 0) /* need to initialise */ - { - thisbody->first = (GRSThttpCharsList *)malloc(sizeof(GRSThttpCharsList)); - thisbody->first->text = p; - thisbody->first->next = NULL; - - thisbody->last = thisbody->first; - thisbody->size = size; - } - else - { - thisbody->last->next = (GRSThttpCharsList *) - malloc(sizeof(GRSThttpCharsList)); - ((GRSThttpCharsList *) thisbody->last->next)->text = p; - ((GRSThttpCharsList *) thisbody->last->next)->next = NULL; - - thisbody->last = thisbody->last->next; - thisbody->size = thisbody->size + size; - } - } -} - -int GRSThttpCopy(GRSThttpBody *thisbody, char *file) -/* - copy a whole file, named file[], into the body output buffer, returning - 1 if file was found and copied ok, or 0 otherwise. -*/ -{ - int fd, len; - char c, *p; - struct stat statbuf; - - fd = open(file, O_RDONLY); - - if (fd == -1) return 0; - - if (fstat(fd, &statbuf) != 0) - { - close(fd); - return 0; - } - - p = malloc(statbuf.st_size + 1); - - if (p == NULL) - { - close(fd); - return 0; - } - - len = read(fd, p, statbuf.st_size); - p[len] = '\0'; - - close(fd); - - if (thisbody->size == 0) /* need to initialise */ - { - thisbody->first = (GRSThttpCharsList *) malloc(sizeof(GRSThttpCharsList)); - thisbody->first->text = p; - thisbody->first->next = NULL; - - thisbody->last = thisbody->first; - thisbody->size = len; - } - else - { - thisbody->last->next=(GRSThttpCharsList *)malloc(sizeof(GRSThttpCharsList)); - ((GRSThttpCharsList *) thisbody->last->next)->text = p; - ((GRSThttpCharsList *) thisbody->last->next)->next = NULL; - - thisbody->last = thisbody->last->next; - thisbody->size = thisbody->size + len; - } - - return 1; -} - -void GRSThttpWriteOut(GRSThttpBody *thisbody) -/* output Content-Length header, blank line then whole of the body to - standard output */ -{ - GRSThttpCharsList *p; - - printf("Content-Length: %d\n\n", thisbody->size); - - p = thisbody->first; - - while (p != NULL) - { - fputs(p->text, stdout); - - p = p->next; - } -} - -int GRSThttpPrintHeaderFooter(GRSThttpBody *bp, char *file, char *headfootname) -/* - try to print Header or Footer appropriate for absolute path file[], - returning 1 rather than 0 if found. -*/ -{ - int found = 0; - char *pathfile, *p; - struct stat statbuf; - - pathfile = malloc(strlen(file) + strlen(headfootname) + 2); - strcpy(pathfile, file); - - if ((pathfile[strlen(pathfile) - 1] != '/') && - (stat(pathfile, &statbuf) == 0) && - S_ISDIR(statbuf.st_mode)) strcat(pathfile, "/"); - - for (;;) - { - p = rindex(pathfile, '/'); - if (p == NULL) break; - p[1] = '\0'; - strcat(p, headfootname); - - if (stat(pathfile, &statbuf) == 0) - { - found = GRSThttpCopy(bp, pathfile); - break; - } - - p[0] = '\0'; - } - - free(pathfile); - return found; -} - -char *GRSThttpGetCGI(char *name) -/* - Return a malloc()ed copy of CGI form parameter identified by name[], - either received by QUERY_STRING (via GET) or on stdin (via POST). - Caller must free() the returned string itself. If name[] is not found, - an empty NUL-terminated malloc()ed string is returned. name[] has any - URL-encoding reversed. -*/ -{ - char *p, *namepattern, *valuestart, *returnvalue, *querystring; - int c, i, j, n, contentlength = 0; - static char *cgiposted = NULL; - size_t size_needed; - - if (cgiposted == NULL) /* have to initialise cgiposted */ - { - p = getenv("CONTENT_LENGTH"); - if (p != NULL) sscanf(p, "%d", &contentlength); - - querystring = getenv("REDIRECT_QUERY_STRING"); - if (querystring == NULL) querystring = getenv("QUERY_STRING"); - - if (querystring == NULL) cgiposted = malloc(contentlength + 3); - else cgiposted = malloc(contentlength + strlen(querystring) + 4); - - cgiposted[0] = '&'; - - for (i = 1; i <= contentlength; ++i) - { - c = getchar(); - if (c == EOF) break; - cgiposted[i] = c; - } - - cgiposted[i] = '&'; - cgiposted[i+1] = '\0'; - - if (querystring != NULL) - { - strcat(cgiposted, querystring); - strcat(cgiposted, "&"); - } - } - - namepattern = malloc(strlen(name) + 3); - sprintf(namepattern, "&%s=", name); - - p = strstr(cgiposted, namepattern); - free(namepattern); - if (p == NULL) return strdup(""); - - valuestart = &p[strlen(name) + 2]; - - for (n=0; valuestart[n] != '&'; ++n) ; - - returnvalue = malloc(n + 1); - - j=0; - - for (i=0; i < n; ++i) - { - if ((i < n - 2) && (valuestart[i] == '%')) /* url encoded as %HH */ - { - returnvalue[j] = 0; - - if (isdigit(valuestart[i+1])) - returnvalue[j] += 16 * (valuestart[i+1] - '0'); - else if (isalpha(valuestart[i+1])) - returnvalue[j] += 16 * (10 + tolower(valuestart[i+1]) - 'a'); - - if (isdigit(valuestart[i+2])) - returnvalue[j] += valuestart[i+2] - '0'; - else if (isalpha(valuestart[i+2])) - returnvalue[j] += 10 + tolower(valuestart[i+2]) - 'a'; - - i = i + 2; - } - else if (valuestart[i] == '+') returnvalue[j] = ' '; - else returnvalue[j] = valuestart[i]; - - if (returnvalue[j] == '\r') continue; /* CR/LF -> LF */ - ++j; - } - - returnvalue[j] = '\0'; - - return returnvalue; -} - -/* * - * Utility functions * - * */ - -char *GRSThttpUrlDecode(char *in) -{ - int i, j, n; - char *out; - - n = strlen(in); - out = malloc(n + 1); - - j=0; - - for (i=0; i < n; ++i) - { - if ((i < n - 2) && (in[i] == '%')) /* url encoded as %HH */ - { - out[j] = 0; - - if (isdigit(in[i+1])) - out[j] += 16 * (in[i+1] - '0'); - else if (isalpha(in[i+1])) - out[j] += 16 * (10 + tolower(in[i+1]) - 'a'); - - if (isdigit(in[i+2])) - out[j] += in[i+2] - '0'; - else if (isalpha(in[i+2])) - out[j] += 10 + tolower(in[i+2]) - 'a'; - - i = i + 2; - } - else if (in[i] == '+') out[j] = ' '; - else out[j] = in[i]; - - ++j; - } - - out[j] = '\0'; - - return out; -} - -char *GRSThttpUrlEncode(char *in) -/* Return a pointer to a malloc'd string holding a URL-encoded (RFC 1738) - version of *in. Only A-Z a-z 0-9 . _ - are passed through unmodified. - (DN's processed by GRSThttpUrlEncode can be used as valid Unix filenames, - assuming they do not exceed restrictions on filename length.) */ -{ - char *out, *p, *q; - - out = malloc(3*strlen(in) + 1); - - p = in; - q = out; - - while (*p != '\0') - { - if (isalnum(*p) || (*p == '.') || (*p == '_') || (*p == '-')) - { - *q = *p; - ++q; - } - else - { - sprintf(q, "%%%2X", *p); - q = &q[3]; - } - - ++p; - } - - *q = '\0'; - return out; -} - -char *GRSThttpUrlMildencode(char *in) -/* Return a pointer to a malloc'd string holding a partially URL-encoded - version of *in. "Partially" means that A-Z a-z 0-9 . = - _ @ and / - are passed through unmodified. (DN's processed by GRSThttpUrlMildencode() - can be used as valid Unix paths+filenames if you are prepared to - create or simulate the resulting /X=xyz directories.) */ -{ - char *out, *p, *q; - - out = malloc(3*strlen(in) + 1); - - p = in; - q = out; - - while (*p != '\0') - { - if (isalnum(*p) || (*p == '.') || (*p == '=') || (*p == '-') - || (*p == '/') || (*p == '@') || (*p == '_')) - { - *q = *p; - ++q; - } - else if (*p == ' ') - { - *q = '+'; - ++q; - } - else - { - sprintf(q, "%%%2X", *p); - q = &q[3]; - } - - ++p; - } - - *q = '\0'; - return out; -} diff --git a/org.gridsite.core/src/grst_x509.c b/org.gridsite.core/src/grst_x509.c deleted file mode 100644 index 37b60e6..0000000 --- a/org.gridsite.core/src/grst_x509.c +++ /dev/null @@ -1,1398 +0,0 @@ -/* - Copyright (c) 2002-4, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - --------------------------------------------------------------- - For more information about GridSite: http://www.gridsite.org/ - --------------------------------------------------------------- -*/ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef GRST_VOMS_SUPPORT -#include -#endif - -#include "gridsite.h" - -#define GRST_KEYSIZE 512 -#define GRST_PROXYCACHE "/../proxycache/" -#define GRST_MAX_CHAIN_LEN 9 - -/// Compare X509 Distinguished Name strings -int GRSTx509NameCmp(char *a, char *b) -/** - * This function attempts to do with string representations what - * would ideally be done with OIDs/values. In particular, we equate - * "/Email=" == "/emailAddress=" to deal with this important change - * between OpenSSL 0.9.6 and 0.9.7. - * Other than that, it is currently the same as ordinary strcmp(3). - */ -{ - int ret; - char *aa, *bb, *p; - - aa = strdup(a); - while ((p = strstr(aa, "/emailAddress=")) != NULL) - { - memmove(&p[6], &p[13], strlen(&p[13]) + 1); - p[1] = 'E'; - } - - bb = strdup(b); - while ((p = strstr(bb, "/emailAddress=")) != NULL) - { - memmove(&p[6], &p[13], strlen(&p[13]) + 1); - p[1] = 'E'; - } - - ret = strcmp(aa, bb); - - free(aa); - free(bb); - - return ret; -} - - -/// Check critical extensions -/** - * Returning GRST_RET_OK if all of extensions are known to us or - * OpenSSL; GRST_REF_FAILED otherwise. - * - * Since this function relies on functionality (X509_supported_extension) - * introduced in 0.9.7, then we do nothing and report an error - * (GRST_RET_FAILED) if one of the associated defines - * (X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION) is absent. - */ - -int GRSTx509KnownCriticalExts(X509 *cert) -{ - int i; - char s[80]; - X509_EXTENSION *ex; - -#ifdef X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION - for (i = 0; i < X509_get_ext_count(cert); ++i) - { - ex = X509_get_ext(cert, i); - - if (X509_EXTENSION_get_critical(ex) && - !X509_supported_extension(ex)) - { - OBJ_obj2txt(s, sizeof(s), X509_EXTENSION_get_object(ex), 1); - - if (strcmp(s, GRST_PROXYCERTINFO_OID) != 0) return GRST_RET_FAILED; - } - } - - return GRST_RET_OK; -#else - return GRST_RET_FAILED; -#endif -} - -/// ASN1 time string (in a char *) to time_t -/** - * (Use ASN1_STRING_data() to convert ASN1_GENERALIZEDTIME to char * if - * necessary) - */ - -time_t GRSTasn1TimeToTimeT(char *asn1time) -{ - char zone; - struct tm time_tm; - - if ((sscanf(asn1time, "%02d%02d%02d%02d%02d%02d%c", - &(time_tm.tm_year), - &(time_tm.tm_mon), - &(time_tm.tm_mday), - &(time_tm.tm_hour), - &(time_tm.tm_min), - &(time_tm.tm_sec), - &zone) != 7) || (zone != 'Z')) return 0; /* dont understand */ - - /* time format fixups */ - - if (time_tm.tm_year < 90) time_tm.tm_year += 100; - --(time_tm.tm_mon); - - return timegm(&time_tm); -} - -/// Check if certificate can be used as a CA to sign standard X509 certs -/* - * Return GRST_RET_OK if true; GRST_RET_FAILED if not. - */ - -int GRSTx509IsCA(X509 *cert) -{ - int idret, purpose_id; - - purpose_id = X509_PURPOSE_get_by_sname("sslclient"); - - /* final argument to X509_check_purpose() is whether to check for CAness */ - - if (X509_check_purpose(cert, purpose_id + X509_PURPOSE_MIN, 1)) - return GRST_RET_OK; - else return GRST_RET_FAILED; -} - -/// Check certificate chain for GSI proxy acceptability. -/** - * Returns X509_V_OK/GRST_RET_OK if valid; OpenSSL X509 errors otherwise. - * - * Inspired by GSIcheck written by Mike Jones, SVE, Manchester Computing, - * The University of Manchester. - * - * The GridSite version handles old and new style Globus proxies, and - * proxies derived from user certificates issued with "X509v3 Basic - * Constraints: CA:FALSE" (eg UK e-Science CA) - * - * We do not check chain links between certs here: this is done by - * GRST_check_issued/X509_check_issued in mod_ssl's ssl_engine_init.c - * - * TODO: we do not yet check ProxyCertInfo and ProxyCertPolicy extensions - * (although via GRSTx509KnownCriticalExts() we can accept them.) - */ - -int GRSTx509CheckChain(int *first_non_ca, X509_STORE_CTX *ctx) -{ - STACK_OF(X509) *certstack; /* Points to the client's cert chain */ - X509 *cert; /* Points to the client's cert */ - int depth; /* Depth of cert chain */ - size_t len,len2; /* Lengths of issuer and cert DN */ - int IsCA; /* Holds whether cert is allowed to sign */ - int prevIsCA; /* Holds whether previous cert in chain is - allowed to sign */ - int prevIsLimited; /* previous cert was proxy and limited */ - int i,j; /* Iteration variables */ - char *cert_DN; /* Pointer to current-certificate-in-chain's - DN */ - char *issuer_DN; /* Pointer to - issuer-of-current-cert-in-chain's DN */ - char *proxy_part_DN; /* Pointer to end part of current-cert-in-chain - maybe eg "/CN=proxy" */ - time_t now; - - time(&now); - - *first_non_ca = 0; /* set to something predictable if things fail */ - - /* Check for context */ - if (!ctx) return X509_V_ERR_INVALID_CA; - /* Can't GSI-verify if there is no context. Here and throughout this - function we report all errors as X509_V_ERR_INVALID_CA. */ - - /* Set necessary preliminary values */ - IsCA = TRUE; /* =prevIsCA - start from a CA */ - prevIsLimited = 0; - - /* Get the client cert chain */ - certstack = X509_STORE_CTX_get_chain(ctx); /* Get the client's chain */ - depth = sk_X509_num(certstack); /* How deep is that chain? */ - - /* Check the client chain */ - for (i=depth-1; i >= 0; --i) - /* loop through client-presented chain starting at CA end */ - { - prevIsCA=IsCA; - - /* Check for X509 certificate and point to it with 'cert' */ - if (cert = sk_X509_value(certstack, i)) - { - /* we check times and reject immediately if invalid */ - - if (now < - GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notBefore(cert)))) - return X509_V_ERR_INVALID_CA; - - if (now > - GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notAfter(cert)))) - return X509_V_ERR_INVALID_CA; - - /* If any forebear certificate is not allowed to sign we must - assume all decendents are proxies and cannot sign either */ - if (prevIsCA) - { - /* always treat the first cert (from the CA files) as a CA */ - if (i == depth-1) IsCA = TRUE; - /* check if this cert is valid CA for signing certs */ - else IsCA = (GRSTx509IsCA(cert) == GRST_RET_OK); - - if (!IsCA) *first_non_ca = i; - } - else - { - IsCA = FALSE; - /* Force proxy check next iteration. Important because I can - sign any CA I create! */ - } - - cert_DN = X509_NAME_oneline(X509_get_subject_name(cert),NULL,0); - issuer_DN = X509_NAME_oneline(X509_get_issuer_name(cert),NULL,0); - len = strlen(cert_DN); - len2 = strlen(issuer_DN); - - /* issuer didn't have CA status, so this is (at best) a proxy: - check for bad proxy extension*/ - - if (!prevIsCA) - { - if (prevIsLimited) /* we reject proxies of limited proxies! */ - return X509_V_ERR_INVALID_CA; - - /* User not allowed to sign shortened DN */ - if (len2 > len) return X509_V_ERR_INVALID_CA; - - /* Proxy subject must begin with issuer. */ - if (strncmp(cert_DN, issuer_DN, len2) != 0) - return X509_V_ERR_INVALID_CA; - - /* Set pointer to end of base DN in cert_DN */ - proxy_part_DN = &cert_DN[len2]; - - /* First attempt at support for Old and New style GSI - proxies: /CN=anything is ok for now */ - if (strncmp(proxy_part_DN, "/CN=", 4) != 0) - return X509_V_ERR_INVALID_CA; - - if ((strncmp(proxy_part_DN, "/CN=limited proxy", 17) == 0) && - (i > 0)) prevIsLimited = 1; /* ready for next cert ... */ - } - } - } - - /* Check cert whose private key is being used by client. If previous in - chain is not allowed to be a CA then need to check this final cert for - valid proxy-icity too */ - if (!prevIsCA) - { - if (prevIsLimited) return X509_V_ERR_INVALID_CA; - /* we do not accept proxies signed by limited proxies */ - - if (cert = sk_X509_value(certstack, 0)) - { - /* Load DN & length of DN and either its issuer or the - first-bad-issuer-in-chain */ - cert_DN = X509_NAME_oneline(X509_get_subject_name(cert), NULL, 0); - issuer_DN = X509_NAME_oneline(X509_get_issuer_name(cert), NULL, 0); - len = strlen(cert_DN); - len2 = strlen(issuer_DN); - - /* issuer didn't have CA status, check for bad proxy extension */ - - if (len2 > len) return X509_V_ERR_INVALID_CA; - /* User not allowed to sign shortened DN */ - - if (strncmp(cert_DN, issuer_DN, len2) != 0) - return X509_V_ERR_INVALID_CA; - /* Proxy subject must begin with issuer. */ - - proxy_part_DN = &cert_DN[len2]; - /* Set pointer to end of DN base in cert_DN */ - - /* Remander of subject must be either "/CN=proxy" or - "/CN=limited proxy" (or /CN=XYZ for New style GSI) */ - - /* First attempt at support for Old and New style GSI - proxies: /CN=anything is ok for now. */ - if (strncmp(proxy_part_DN, "/CN=", 4) != 0) - return X509_V_ERR_INVALID_CA; - } - } - - return X509_V_OK; /* this is also GRST_RET_OK, of course - by choice */ -} - -/// Example VerifyCallback routine - -/** - * - */ - -int GRSTx509VerifyCallback (int ok, X509_STORE_CTX *ctx) -{ - int errnum = X509_STORE_CTX_get_error(ctx); - int errdepth = X509_STORE_CTX_get_error_depth(ctx); - int first_non_ca; - -#ifndef X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION -#define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 -#endif - - if (errnum == X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION) - { - if (GRSTx509KnownCriticalExts(X509_STORE_CTX_get_current_cert(ctx)) - == GRST_RET_OK) - { - ok = TRUE; - errnum = X509_V_OK; - X509_STORE_CTX_set_error(ctx, errnum); - } - } - else if ((errdepth == 0) && - (errnum == X509_V_OK) && - (GRSTx509CheckChain(&first_non_ca, ctx) != X509_V_OK)) ok = FALSE; - - - return ok; - -// check this - -// if (ok) return GRST_RET_OK; -// else return GRST_RET_FAILED; -} - -/// Get the VOMS attributes in the extensions to the given cert -/* - * Puts any VOMS credentials found into the Compact Creds string array - * starting at *creds. Always returns GRST_RET_OK. - */ - -int GRSTx509GetVomsCreds(int *lastcred, int maxcreds, size_t credlen, - char *creds, X509 *cert, STACK_OF(X509) *certstack, - char *vomsdir) -{ -#ifndef GRST_VOMS_SUPPORT - return GRST_RET_OK; -} -#else - -/* - int j; - unsigned int siglen=-1, datalength=-1, dataoffset = -1; - char s[80]; - unsigned char *charstr, *p, *time1 = NULL, *time2 = NULL, *vo = NULL, - *uri = NULL, *user = NULL, *group = "NULL", *role = "NULL", - *cap = "NULL", *server = NULL, *ucuser, *signature = NULL, - *data = NULL, *datalen = NULL; - X509_EXTENSION *ex; - ASN1_STRING *asn1str; - time_t now, time1_time = 0, time2_time = 0, - uctime1_time, uctime2_time; -*/ - - - struct vomsdata *vd; - int i, j, vomserror; - - vd = VOMS_Init(NULL, NULL); - - if (VOMS_Retrieve(cert, certstack, RECURSE_CHAIN, vd, &vomserror) && - (vd->data != NULL)) - { - for (i = 0; vd->data[i] != NULL; ++i) - { - if (vd->data[i]->fqan != NULL) - for (j = 0; vd->data[i]->fqan[j] != NULL; ++j) - { - if (*lastcred >= maxcreds - 1) - { - VOMS_Destroy(vd); - return GRST_RET_OK; - } - - ++(*lastcred); - - snprintf(&creds[*lastcred * (credlen + 1)], - credlen+1, - "VOMS %010lu %010lu 0 %s", - GRSTasn1TimeToTimeT(vd->data[i]->date1), - GRSTasn1TimeToTimeT(vd->data[i]->date2), - vd->data[i]->fqan[j]); - } - } - } - else - { - FILE *fp = fopen("/tmp/getvoms.log", "w"); - fprintf(fp, "%d\n", vomserror); - fclose(fp); - } - - VOMS_Destroy(vd); - return GRST_RET_OK; -} - -#if 0 - - time(&now); - - uctime1_time = - GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notBefore(usercert))); - uctime2_time = - GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notAfter(usercert))); - ucuser = - X509_NAME_oneline(X509_get_subject_name(usercert), NULL, 0); - - for (i = 0; i < X509_get_ext_count(cert); ++i) - { - ex = X509_get_ext(cert, i); - - OBJ_obj2txt(s, sizeof(s), X509_EXTENSION_get_object(ex), 1); - - if (strcmp(s, GRST_VOMS_OID) == 0) /* a VOMS extension */ - { - asn1str = X509_EXTENSION_get_data(ex); - charstr = (char *) malloc(ASN1_STRING_length(asn1str) + 1); - memcpy(charstr, ASN1_STRING_data(asn1str), - ASN1_STRING_length(asn1str)); - charstr[ASN1_STRING_length(asn1str)] = '\0'; - - siglen = -1; - - if ((sscanf(charstr, "SIGLEN:%u", &siglen) != 1) || - (siglen == -1) || - ((p = index(charstr, '\n')) == NULL)) - { - free(charstr); - continue; - } - - ++p; - - if (strncmp(p, "SIGNATURE:", sizeof("SIGNATURE:") - 1) != 0) - { - free(charstr); - continue; - } - - signature = &p[sizeof("SIGNATURE:") - 1]; - - p = &p[siglen + sizeof("SIGNATURE:") - 1]; - data = p; - - /* nasty pointer arithmetic! */ - dataoffset = (unsigned int) ((long) data - (long) charstr); - datalength = (unsigned int) - (ASN1_STRING_length(asn1str) - dataoffset); - - if (datalength <= 0) - { - free(charstr); - continue; - } - - while (1) - { - if (strncmp(p, "USER:", sizeof("USER:") - 1) == 0) - { - p = &p[sizeof("USER:") - 1]; - while ((*p != '\n') && (*p != '\0') && (*p <= ' ')) ++p; - user = p; - p = index(p, '\n'); - if (p == NULL) break; - *p = '\0'; - ++p; - } - else if (strncmp(p, "TIME1:", sizeof("TIME1:") - 1) == 0) - { - p = &p[sizeof("TIME1:") - 1]; - while ((*p != '\n') && (*p != '\0') && (*p <= ' ')) ++p; - time1 = p; - p = index(p, '\n'); - if (p != NULL) *p = '\0'; - - time1_time = GRSTasn1TimeToTimeT(time1); - if (time1_time < uctime1_time) time1_time = uctime1_time; - if (p == NULL) break; - ++p; - } - else if (strncmp(p, "TIME2:", sizeof("TIME2:") - 1) == 0) - { - p = &p[sizeof("TIME2:") - 1]; - while ((*p != '\n') && (*p != '\0') && (*p <= ' ')) ++p; - time2 = p; - p = index(p, '\n'); - if (p != NULL) *p = '\0'; - - time2_time = GRSTasn1TimeToTimeT(time2); - if (time2_time > uctime2_time) time2_time = uctime2_time; - if (p == NULL) break; - ++p; - } - else if (strncmp(p, "VO:", sizeof("VO:") - 1) == 0) - { - p = &p[sizeof("VO:") - 1]; - while ((*p != '\n') && (*p != '\0') && (*p <= ' ')) ++p; - vo = p; - - p = index(p, '\n'); - if (p == NULL) break; - *p = '\0'; - ++p; - } - else if (strncmp(p, "SERVER:", sizeof("SERVER:") - 1) == 0) - { - p = &p[sizeof("SERVER:") - 1]; - while ((*p != '\n') && (*p != '\0') && (*p <= ' ')) ++p; - server = p; - - p = index(p, '\n'); - if (p == NULL) break; - *p = '\0'; - ++p; - } - else if (strncmp(p, "DATALEN:", sizeof("DATALEN:") - 1) == 0) - { - p = &p[sizeof("DATALEN:") - 1]; - while ((*p != '\n') && (*p != '\0') && (*p <= ' ')) ++p; - datalen = p; - p = index(p, '\n'); - if (p == NULL) break; - *p = '\0'; - ++p; - break; - } - else /* not something we use */ - { - p = index(p, '\n'); - if (p == NULL) break; - *p = '\0'; - ++p; - } - } -/* - if ((now >= time1_time) && - (now <= time2_time) && - (signature != NULL) && - (data != NULL) && - (siglen > 0) && - (user != NULL) && - (ucuser != NULL) && - (strcmp(user, ucuser) == 0) && - (GRSTx509CheckVomsSig(signature, siglen, - &((ASN1_STRING_data(asn1str))[dataoffset]), - datalength, vomsdir, vo, - server) == GRST_RET_OK)) - while (1) -*/ - { - if (strncmp(p, "GROUP:", sizeof("GROUP:") - 1) == 0) - { - p = &p[sizeof("GROUP:") - 1]; - while ((*p != '\n') && (*p != '\0') && (*p <= ' ')) ++p; - group = p; - role = "NULL"; - cap = "NULL"; - - p = index(p, '\n'); - if (p == NULL) break; - *p = '\0'; - ++p; - } - else if (strncmp(p, "ROLE:", sizeof("ROLE:") - 1) == 0) - { - p = &p[sizeof("ROLE:") - 1]; - while ((*p != '\n') && (*p != '\0') && (*p <= ' ')) ++p; - role = p; - - p = index(p, '\n'); - if (p == NULL) break; - *p = '\0'; - ++p; - } - else if (strncmp(p, "CAP:", sizeof("CAP:") - 1) == 0) - { - p = &p[sizeof("CAP:") - 1]; - while ((*p != '\n') && (*p != '\0') && (*p <= ' ')) ++p; - cap = p; - - p = index(p, '\n'); - if (p != NULL) *p = '\0'; - - if (*lastcred < maxcreds - 1) - { - ++(*lastcred); - - if ((strcmp(role, "NULL") == 0) && - (strcmp(cap , "NULL") == 0)) - snprintf(&creds[*lastcred * (credlen + 1)], credlen+1, - "VOMS %010lu %010lu 0 /%s%s", - time1_time, time2_time, vo, group); - else if ((strcmp(role, "NULL") != 0) && - (strcmp(cap , "NULL") == 0)) - snprintf(&creds[*lastcred * (credlen + 1)], credlen+1, - "VOMS %010lu %010lu 0 /%s%s/Role=%s", - time1_time, time2_time, vo, group, role); - else if ((strcmp(role, "NULL") == 0) && - (strcmp(cap , "NULL") != 0)) - snprintf(&creds[*lastcred * (credlen + 1)], credlen+1, - "VOMS %010lu %010lu 0 /%s%s/Capability=%s", - time1_time, time2_time, vo, group, cap); - else - snprintf(&creds[*lastcred * (credlen + 1)], credlen+1, - "VOMS %010lu %010lu 0 /%s%s/Role=%s/Capability=%s", - time1_time, time2_time, vo, group, role, cap); - } - - if (p == NULL) break; - ++p; - } - else /* not something we use */ - { - p = index(p, '\n'); - if (p == NULL) break; - *p = '\0'; - ++p; - } - } - - free(charstr); - } - } - - return GRST_RET_OK; -} -#endif - -#endif - -/// Turn a Compact Cred line into a GRSTgaclCred object -/** - * Returns pointer to created GRSTgaclCred or NULL or failure. - */ - -GRSTgaclCred *GRSTx509CompactToCred(char *grst_cred) -{ - int delegation; - char *p; - time_t now, notbefore, notafter; - GRSTgaclCred *cred = NULL; - - time(&now); - - if (grst_cred == NULL) return NULL; /* just in case */ - - if (strncmp(grst_cred, "X509USER ", 9) == 0) - { - if ((sscanf(grst_cred, "X509USER %lu %lu %d", - ¬before, ¬after, &delegation) == 3) - && (now >= notbefore) - && (now <= notafter) - && (p = index(grst_cred, ' ')) - && (p = index(++p, ' ')) - && (p = index(++p, ' ')) - && (p = index(++p, ' '))) - { - cred = GRSTgaclCredNew("person"); - GRSTgaclCredSetDelegation(cred, delegation); - GRSTgaclCredAddValue(cred, "dn", &p[1]); - } - - return cred; - } - - if (strncmp(grst_cred, "VOMS ", 5) == 0) - { - if ((sscanf(grst_cred, "VOMS %lu %lu", - ¬before, ¬after, &delegation) == 3) - && (now >= notbefore) - && (now <= notafter) - && (p = index(grst_cred, ' ')) - && (p = index(++p, ' ')) - && (p = index(++p, ' ')) - && (p = index(++p, ' '))) - { - /* include /VO/group/subgroup/Role=role/Capability=cap */ - - if (*p != '/') return NULL; /* must begin with / */ - - cred = GRSTgaclCredNew("voms"); - GRSTgaclCredSetDelegation(cred, delegation); - GRSTgaclCredAddValue(cred, "fqan", p); - } - - return cred; - } - - return NULL; /* dont recognise this credential type */ -} - -/// Get the credentials in an X509 cert/GSI proxy, including any VOMS -/** - * Credentials are placed in Compact Creds string array at *creds. - * - * Function returns GRST_RET_OK on success, or GRST_RET_FAILED if - * some inconsistency found in certificate. - */ - -int GRSTx509CompactCreds(int *lastcred, int maxcreds, size_t credlen, - char *creds, STACK_OF(X509) *certstack, char *vomsdir) -{ - int i, j, delegation = 0; - char credtemp[credlen+1]; - X509 *cert, *usercert = NULL, *gsiproxycert = NULL; - - *lastcred = -1; - - for (i = sk_X509_num(certstack) - 1; i >= 0; --i) - { - cert = sk_X509_value(certstack, i); - - if (usercert != NULL) - { /* found a (GSI proxy) cert after the user cert */ - gsiproxycert = cert; - ++delegation; - } - - if ((usercert == NULL) && - (i < sk_X509_num(certstack) - 1) && - (GRSTx509IsCA(cert) != GRST_RET_OK)) usercert = cert; - /* found the 1st non-CA cert */ - } - - if ((usercert == NULL) /* if no usercert ("EEC"), we're not interested */ - || - (snprintf(credtemp, credlen+1, "X509USER %010lu %010lu %d %s", - GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notBefore(usercert))), - GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notAfter(usercert))), - delegation, - X509_NAME_oneline(X509_get_subject_name(usercert), NULL, 0)) >= credlen+1) - || - (*lastcred >= maxcreds-1)) - { - *lastcred = -1; /* just in case the caller looks at it */ - return GRST_RET_FAILED; /* tell caller that things didn't work out */ - } - - ++(*lastcred); - strcpy(&creds[*lastcred * (credlen + 1)], credtemp); - - if ((gsiproxycert != NULL) - && - (snprintf(credtemp, credlen+1, "GSIPROXY %010lu %010lu %d %s", - GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notBefore(gsiproxycert))), - GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notAfter(gsiproxycert))), - delegation, - X509_NAME_oneline(X509_get_subject_name(gsiproxycert), NULL, 0)) < credlen+1) - && - (*lastcred < maxcreds-1)) - { - ++(*lastcred); - strcpy(&creds[*lastcred * (credlen + 1)], credtemp); - - GRSTx509GetVomsCreds(lastcred, maxcreds, credlen, creds, - gsiproxycert, certstack, vomsdir); - } - - return GRST_RET_OK; -} - -/// Find proxy file name of the current user -/** - * Return a string with the proxy file name or NULL if not present. - * This function does not check if the proxy has expired. - */ - -char *GRSTx509FindProxyFileName(void) -{ - char *p; - - p = getenv("X509_USER_PROXY"); - - if (p != NULL) return strdup(p); - - p = malloc(sizeof("/tmp/x509up_uXYYYXXXYYY")); - - sprintf(p, "/tmp/x509up_u%d", getuid()); - - return p; -} - -static void mpcerror(FILE *debugfp, char *msg) -{ - if (debugfp != NULL) - { - fputs(msg, debugfp); - ERR_print_errors_fp(debugfp); - } -} - -/// Make a GSI Proxy chain from a request, certificate and private key -/** - * The proxy chain is returned in *proxychain. If debugfp is non-NULL, - * errors are output to that file pointer. The proxy will expired in - * the given number of minutes starting from the current time. - */ - -int GRSTx509MakeProxyCert(char **proxychain, FILE *debugfp, - char *reqtxt, char *cert, char *key, int minutes) -{ - char *ptr, *certchain; - int i, subjAltName_pos, ncerts; - long serial = 1, ptrlen; - EVP_PKEY *pkey, *CApkey; - const EVP_MD *digest; - X509 *certs[GRST_MAX_CHAIN_LEN]; - X509_REQ *req; - X509_NAME *name, *CAsubject, *newsubject; - X509_NAME_ENTRY *ent; - X509V3_CTX ctx; - X509_EXTENSION *subjAltName; - STACK_OF (X509_EXTENSION) * req_exts; - FILE *fp; - BIO *reqmem, *certmem; - - /* read in the request */ - reqmem = BIO_new(BIO_s_mem()); - BIO_puts(reqmem, reqtxt); - - if (!(req = PEM_read_bio_X509_REQ(reqmem, NULL, NULL, NULL))) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error reading request from BIO memory\n"); - BIO_free(reqmem); - return GRST_RET_FAILED; - } - - BIO_free(reqmem); - - /* verify signature on the request */ - if (!(pkey = X509_REQ_get_pubkey (req))) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error getting public key from request\n"); - return GRST_RET_FAILED; - } - - if (X509_REQ_verify(req, pkey) != 1) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error verifying signature on certificate\n"); - return GRST_RET_FAILED; - } - - /* read in the signing certificate */ - if (!(fp = fopen(cert, "r"))) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error opening signing certificate file\n"); - return GRST_RET_FAILED; - } - - for (ncerts = 1; ncerts < GRST_MAX_CHAIN_LEN; ++ncerts) - if (!(certs[ncerts] = PEM_read_X509(fp, NULL, NULL, NULL))) break; - - if (ncerts == 1) /* zeroth cert with be new proxy cert */ - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error reading signing certificate file\n"); - return GRST_RET_FAILED; - } - - fclose(fp); - - CAsubject = X509_get_subject_name(certs[1]); - - /* read in the CA private key */ - if (!(fp = fopen(key, "r"))) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error reading signing private key file\n"); - return GRST_RET_FAILED; - } - - if (!(CApkey = PEM_read_PrivateKey (fp, NULL, NULL, NULL))) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error reading signing private key in file\n"); - return GRST_RET_FAILED; - } - - fclose(fp); - - /* get subject name */ - if (!(name = X509_REQ_get_subject_name (req))) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error getting subject name from request\n"); - return GRST_RET_FAILED; - } - - /* create new certificate */ - if (!(certs[0] = X509_new ())) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error creating X509 object\n"); - return GRST_RET_FAILED; - } - - /* set version number for the certificate (X509v3) and the serial number - need 3 = v4 for GSI proxy?? */ - if (X509_set_version (certs[0], 3L) != 1) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error setting certificate version\n"); - return GRST_RET_FAILED; - } - - ASN1_INTEGER_set (X509_get_serialNumber (certs[0]), serial++); - - if (!(name = X509_get_subject_name(certs[1]))) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error getting subject name from CA certificate\n"); - return GRST_RET_FAILED; - } - - if (X509_set_issuer_name (certs[0], name) != 1) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error setting issuer name of certificate\n"); - return GRST_RET_FAILED; - } - - /* set issuer and subject name of the cert from the req and the CA */ - ent = X509_NAME_ENTRY_create_by_NID(NULL, OBJ_txt2nid("commonName"), - MBSTRING_ASC, "proxy", -1); - - newsubject = X509_NAME_dup(CAsubject); - - X509_NAME_add_entry(newsubject, ent, -1, 0); - - if (X509_set_subject_name(certs[0], newsubject) != 1) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error setting subject name of certificate\n"); - return GRST_RET_FAILED; - } - - /* set public key in the certificate */ - if (X509_set_pubkey(certs[0], pkey) != 1) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error setting public key of the certificate\n"); - return GRST_RET_FAILED; - } - -// need to set validity within limits of earlier certificates in the chain - - /* set duration for the certificate */ - if (!(X509_gmtime_adj (X509_get_notBefore(certs[0]), 0))) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error setting beginning time of the certificate\n"); - return GRST_RET_FAILED; - } - - if (!(X509_gmtime_adj (X509_get_notAfter(certs[0]), 60 * minutes))) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error setting ending time of the certificate\n"); - return GRST_RET_FAILED; - } - - /* sign the certificate with the signing private key */ - if (EVP_PKEY_type (CApkey->type) == EVP_PKEY_RSA) - digest = EVP_md5(); - else - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error checking signing private key for a valid digest\n"); - return GRST_RET_FAILED; - } - - if (!(X509_sign (certs[0], CApkey, digest))) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error signing certificate\n"); - return GRST_RET_FAILED; - } - - /* store the completed certificate chain */ - - certchain = strdup(""); - - for (i=0; i < ncerts; ++i) - { - certmem = BIO_new(BIO_s_mem()); - - if (PEM_write_bio_X509(certmem, certs[i]) != 1) - { - mpcerror(debugfp, - "GRSTx509MakeProxyCert(): error writing certificate to memory BIO\n"); - return GRST_RET_FAILED; - } - - ptrlen = BIO_get_mem_data(certmem, &ptr); - - certchain = realloc(certchain, strlen(certchain) + ptrlen + 1); - - strncat(certchain, ptr, ptrlen); - - BIO_free(certmem); - } - - *proxychain = certchain; - - return GRST_RET_OK; -} - -/// Find a proxy file in the proxy cache -/** - * Returns the full path and file name of proxy file associated - * with given delegation ID and user DN. - */ - -char *GRSTx509CachedProxyFind(char *proxydir, char *delegation_id, - char *user_dn) -/* - Return a pointer to a malloc'd string with the full path of the - proxy file corresponding to the given delegation_id, or NULL - if not found. -*/ -{ - int ret, len; - char *filename = NULL, *line, *p, *proxyfile = NULL; - DIR *proxyDIR; - FILE *fp; - struct dirent *ent; - struct stat entstat; - - if ((proxyDIR = opendir(proxydir)) == NULL) return NULL; - - len = strlen(delegation_id); - if (strlen(user_dn) > len) len = strlen(user_dn); - - if ((line = malloc(len + 2)) == NULL) return NULL; - - while ((ent = readdir(proxyDIR)) != NULL) - { - if (ent->d_name[0] != '.') /* private keys begin with . */ - { - if (asprintf(&filename, "%s/%s", proxydir, ent->d_name) == -1) - break; - if ((stat(filename, &entstat) != 0) - || !S_ISREG(entstat.st_mode)) - { - free(filename); - continue; - } - - fp = fopen(filename, "r"); - if (fp != NULL) - { - if (fgets(line, len + 2, fp) != NULL) - { - p = index(line, '\n'); - - if (p != NULL) - { - *p = '\0'; - if (strcmp(line, delegation_id) == 0) - { - if (fgets(line, len + 2, fp) != NULL) - { - p = index(line, '\n'); - - if (p != NULL) - { - *p = '\0'; - - if (strcmp(line, user_dn) == 0) - { - proxyfile = filename; - fclose(fp); - break; - } - } - } - } - } - } - - fclose(fp); - } - - free(filename); - } - } - - closedir(proxyDIR); - free(line); - - return proxyfile; -} - -/// Find a temporary proxy private key file in the proxy cache -/** - * Returns the full path and file name of the private key file associated - * with given delegation ID and user DN. - */ - -char *GRSTx509CachedProxyKeyFind(char *proxydir, char *delegation_id, - char *user_dn) -/* - Return a pointer to a malloc'd string with the full path of the - private proxy key corresponding to the given delegation_id, or NULL - if not found. -*/ -{ - int ret, len; - char *filename = NULL, *line, *p, *keyfile = NULL; - DIR *proxyDIR; - FILE *fp; - struct dirent *ent; - struct stat entstat; - - if ((proxyDIR = opendir(proxydir)) == NULL) return NULL; - - len = strlen(delegation_id); - if (strlen(user_dn) > len) len = strlen(user_dn); - - if ((line = malloc(len + 2)) == NULL) return NULL; - - while ((ent = readdir(proxyDIR)) != NULL) - { - if (ent->d_name[0] == '.') /* private keys begin with . */ - { - if (asprintf(&filename, "%s/%s", proxydir, ent->d_name) == -1) - break; - if ((stat(filename, &entstat) != 0) - || !S_ISREG(entstat.st_mode)) - { - free(filename); - continue; - } - - fp = fopen(filename, "r"); - if (fp != NULL) - { - if (fgets(line, len + 2, fp) != NULL) - { - p = index(line, '\n'); - - if (p != NULL) - { - *p = '\0'; - if (strcmp(line, delegation_id) == 0) - { - if (fgets(line, len + 2, fp) != NULL) - { - p = index(line, '\n'); - - if (p != NULL) - { - *p = '\0'; - - if (strcmp(line, user_dn) == 0) - { - keyfile = filename; - fclose(fp); - break; - } - } - } - } - } - } - - fclose(fp); - } - - free(filename); - } - } - - closedir(proxyDIR); - free(line); - - return keyfile; -} - -/// Make and store a X.509 request for a GSI proxy -/** - * Returns GRST_RET_OK on success, non-zero otherwise. Request string - * is PEM encoded, and the key is stored in proxydir as temporary file - * with a filename like .XXXXXX - */ - -int GRSTx509MakeProxyRequest(char **reqtxt, char *proxydir, - char *delegation_id, char *user_dn) -{ - int i, fd; - char *docroot, *reqfile, *prvkeyfile, *ptr; - size_t ptrlen; - FILE *fp; - RSA *keypair; - X509_NAME *subject; - X509_NAME_ENTRY *ent; - EVP_PKEY *pkey; - X509_REQ *certreq; - BIO *reqmem; - const EVP_MD *digest; - struct stat statbuf; - - if ((keypair = RSA_generate_key(GRST_KEYSIZE, 3, NULL, NULL)) == NULL) - return 1; - asprintf(&prvkeyfile, "%s/.XXXXXX", proxydir); - - fd = mkstemp(prvkeyfile); - - if ((fp = fdopen(fd, "w")) == NULL) return 1; - - fprintf(fp, "%s\n%s\n", delegation_id, user_dn); - - if (!PEM_write_RSAPrivateKey(fp, keypair, NULL, NULL, 0, NULL, NULL)) - return 1; - - if (fclose(fp) != 0) return 1; - - /* now create the certificate request */ - - certreq = X509_REQ_new(); - if (certreq == NULL) return 1; - - OpenSSL_add_all_algorithms(); - - pkey = EVP_PKEY_new(); - EVP_PKEY_assign_RSA(pkey, keypair); - - X509_REQ_set_pubkey(certreq, pkey); - - subject = X509_NAME_new(); - ent = X509_NAME_ENTRY_create_by_NID(NULL, OBJ_txt2nid("organizationName"), - MBSTRING_ASC, "Dummy", -1); - X509_NAME_add_entry (subject, ent, -1, 0); - X509_REQ_set_subject_name (certreq, subject); - - digest = EVP_md5(); - X509_REQ_sign(certreq, pkey, digest); - - reqmem = BIO_new(BIO_s_mem()); - PEM_write_bio_X509_REQ(reqmem, certreq); - ptrlen = BIO_get_mem_data(reqmem, &ptr); - - *reqtxt = malloc(ptrlen + 1); - memcpy(*reqtxt, ptr, ptrlen); - (*reqtxt)[ptrlen] = '\0'; - - BIO_free(reqmem); - - X509_REQ_free(certreq); - - return 0; -} - -/// Store a GSI proxy chain in the proxy cache, along with the private key -/** - * Returns GRST_RET_OK on success, non-zero otherwise. The existing - * private key with the same delegation ID and user DN is appended to - * make a valid proxy file, and the temporary private key file deleted. - */ - -int GRSTx509CacheProxy(char *proxydir, char *delegation_id, - char *user_dn, char *proxychain) -{ - int fd, c, len = 0, i; - char *cert, *upcertfile, *prvkeyfile, *p; - FILE *ifp, *ofp; - - prvkeyfile = GRSTx509CachedProxyKeyFind(proxydir, delegation_id, user_dn); - - if (prvkeyfile == NULL) - { - free(proxydir); - return GRST_RET_FAILED; - } - - if ((ifp = fopen(prvkeyfile, "r")) == NULL) - { - free(prvkeyfile); - free(proxydir); - return GRST_RET_FAILED; - } - - if (asprintf(&upcertfile, "%s/XXXXXX", proxydir) == -1) - return GRST_RET_FAILED; - - if ((fd = mkstemp(upcertfile)) == -1) - { - fclose(ifp); - free(prvkeyfile); - free(upcertfile); - return GRST_RET_FAILED; - } - - if ((ofp = fdopen(fd, "w")) == NULL) - { - close(fd); - fclose(ifp); - free(prvkeyfile); - free(upcertfile); - return GRST_RET_FAILED; - } - - fprintf(ofp, "%s\n%s\n", delegation_id, user_dn); - - fputs(proxychain, ofp); /* write out certificates */ - - while ((c = fgetc(ifp)) != EOF) fputc(c, ofp); /* append proxy private key */ - - if (fclose(ifp) != 0) return GRST_RET_FAILED; - if (fclose(ofp) != 0) return GRST_RET_FAILED; - - unlink(prvkeyfile); - - free(prvkeyfile); - free(upcertfile); - -/* should also check validity of proxy cert to avoid suprises? */ - - return GRST_RET_OK; -} diff --git a/org.gridsite.core/src/htcp b/org.gridsite.core/src/htcp deleted file mode 100644 index ac0153b23a52348015c9bedbcc3153157cb93075..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 29747 zcmd^odwi7Dng5wf!jObakf_*F94@h;k_#6#pduKCi$aJH6stH)GLyW4$xNJi2f|hm z8>Sj#l(x1@E8Sw%mTkT6YFFFE#>*P~lx_K0YT1@nTItU>4ehcmb=gXr-}igYd1u}X z!M5)1U%xjwbIxuK0Wv&Q_LQyHE zii_b3!L+$MfCJZ$FkJzh7tRBBiVkUX6A-3j8fj-sLz;lwTQ3A1^NTW-F5`ZHG`Q!H z;UFB#Wx5;Q=z6(=nZ8(D{JxyUXjN3jn6G(`sVv%{8$|RjfUp?y62Ds%NV- zke0kHZCHztDu-o}uL`)!;4Xx#g$uy(I!}4>cMg6jmr}Tk;8^F6!F>qsQn)E_yk@|W z9*UJ$6@I6|6~Pt5T@1%-s`5m+_AB9!ha*4La5Zo<;qot3J$p%+0UDEyIXmFbiy8;m z14nuADpB5u-wOayHug0cfsbfl5_})rL=Asb`}97n!_&2Y3Hn-GBMod->wkNDkypVjGg@b>|3(=hGidB6)Kz7YQx{<@ z@NRX$zXf~%_?JNNEbr%lj{v4^5dM3>7T|>%UJ3X#;A=Ge4q#ue*S7>d@qY||BH*WV z`eT4A0bj0RwvRf%Yc+lo{AGauQK!40T=EN0%DWQ&I;6*S`h55X;OjJe0QtKBzo+3Z z0KNw>+YI@+74UArFT*Fi6aGHH^K|-h_!GZn%Xge8Mf&qdr|l5G7w`eVeLDZ|5qAWz zT|V_-0k-880el)T+avS;0kE?^s}T3};avTGjdUOSycab7IMhGpsQ;x%pNRAi!6&^d z;8zk~!%xDm18moK65tIE{St36>ZkNyDn1E#8SriXqM*4B@V&bHufVsj00LX!45U-; zET4LgIOzWxaa~BKoie=#&b|T+pwDYbCu6F+3oX96VbRLv^@35MXgIYsl!}^(PSX+5 z8BMk(k{yni_ISG~Lap#bXz7Yo*DhKSTD4@!nqX6?Y0EpW^sEeku*g|w4gO^-pIe){N3U!{*m zcYrBq7TMS(8nNrl0F*RDf$@b zPt(UheTF^0GY?d zuc1E`<30Upn1j%tj`;?Cbdq)SF|oLc{>Ow^NFS4q#q=>*SVq4_h!ylP$Trf)gk^2d zFS}3ptcM{o>kNP10@CZRh~dkgMNNh)p2sh0BZey|S%bmBW5c*AC}D$XgNGzcNgGt% zV84VZaf4HU!KWom$r}N}dnHT_7?p%~Ntl{2Y6QHDfF!yg|a$kg<$# zqlBp`qml4J2~%UnI>NOQrsj+dgaZ<$1`SqduuQ_#q|r%ONSGQmx(J{A6Cx_8Sz`y` zV-lu@je7_mk}x%G>>}JRVQSpiP55aEQ}f1N!h0o53o!N(-X&pLg7Gxr9TKKR7|#># zlrSyB=qJ2E!n6?M0O3Xn(^8B>gcnMf7GoSCTq|K(j&Y1|K*F>j!y;TJVOo-LlCY34 zEy_4e_~aj1e_ED-c8vNrCx!cR+>mS+SA@0Bnu(5NK5 z3-GL8-`4Z(9LYio}6E@3`6kb&;O&@IK5Ld&@F!m>2fE+uiSdgz)ei+357pYXwAg zz5YtiyQ(cb{5TX1nio;_Bwp5iqQqdN_5I{~|JnU&nJ#Bd_lc(7V0lmQ+1_A@|EXYE zPtXEtZ_rxUXkCRm0ktQ1vipR0IBgB5eZ%RKRuDBoG;ln@ldlPZ#NObu-Tftv#s0q|gv)ECD-4tB(IpHXa#= zJIjq3I^nA$6DAsMI-yS`4Aqj>b);pNk;-N<8k}X^qT(fIlZ1IIjG!;LyHOT6$+`hU z71{wz^JBfieHC23Uo932k^V3WP&mfzy6o|~?2B?qH|V5y|0^elN@11*10uSCb^nP< z8aj`0ZWTA6;<%rHF^=8IT_;{ecpxZym4QqXIy%5&Aj2_*A*&vx_XLmj2Ftp;=8CS{ z5E$;9JKR}otVVU&94(;~i5d>4PYpjuBGwtjbdMw{wR+0ht>S=Z#E^IRITm8QVPg`K zRYU;+W2&s;QEP%-MU-FX+Agc(+Bjo4ebhRATGk$UjJiIkB+)>%AGMBU;h$`@x}EY7+b==$8Ic*(jZab9sxOQDr?wb~v&7}ka9!8C z9$h@fZepSFP0_s6qnid6_`e$RL5i_AM`x0v1IuYaO<6Vn&Rv*a>IVFT64>B283l`m zPRoq(TDaG!%u?zOX^_?PG>WEgn_c^eIw9jmpYeTi1KHiBsG%*@OY}OieUdCtTIsPI z&&Ip9y(l9!KB^0QN+k?((a)+%!_20BTBp8EQBfi#Zhz)Y0Bq8kE*jVf?#R>a6-Z|L zHm@74mcD<^D&z;hmrRWi=2InG5>**3?KC8f(5<*W-X`>drFjw%$M=AJw zSTX2=hjgvKEu(A=UZf?qO=YIAU>CO1+8nWuZY*U3YsyA#bZx9=%(W_}H~45zW*LO{ zg`Ur?fCtI;WEL}!k>KYTzVh0+cifm4ap(A6nXgx4)F$UT>;d+ByD9+oz|J&J)vunC z;vQmWny2T#S4ji1&tUT%$lMAZRETqKh9sLN04b)UR=FyyCwLqY((1~rPP>M%mAS%y z5BIXVw;dP$%#RSdYyUcAuSUq98DPqOS&Dz>w+O(p#~3Zt(sPWq9#u?nbpN76mW=p! zavw+F)<9oVWX{&T zrY{pHVdD~Q=nvXCP}8H0x`!|?Dp3j=P9K+c zGTrFUY3g79gY^rLh>6C198>9`+Fogi3|82xo+LSxdLGQ>en93flLJhtZoii*w)%o6 zhQ(kzyL3*ij#?=dKVoWCHxT5)M~!F4twz*Y&gIoi#2$++>uyz!oYRaLi!CdrSr|DM zTUJvxzAt#d9*8aL>TI-}?AYV3Wlhf}81JHj#$2ff%PPsnqaT@x1%>s8lhP#QtOGT( ztT&Z84+KxCx}0*1vuYIPEJrbqffADJ4LWc*`us5`(<^QAXJe`E&a%1`%0Tb{3zYJ; zERSNeN6qom<#%m6AkCo|0c{I)67|4v`h>2$!w_EmcWnq*AF!9_`~p+N1N5ibyvxoj zeZX*-zy0XgC8K9Q&E2Z&=GWz}U9jH3MxT?ex9wysO<7)(&4u79Ph_`jp;QWU8tMXP?JP3hda zzE7cy)b)jmtq-c}BftJ&y51}EovrKLiXB_mSf6`)*J5!e7w5g#dHc#;Sg&8%=u6J& zU0I$>@?7gJ;HG2GB46)%tRY}`Xnv z_AFut!kvNKDsG~*%Mxpkssksyxyc-sEzhcWOq@Q#1U(ia;UPQ0pZT(EZ5X6D6Xsgy zPCLyk(R1*@4`V8a=IsgkcGQVq)%PdV5IP4s2lXYv}6xf@g-s&?CJpx5mG-7gU|)Np9S1(I}iK>4_>hvW)dvO0P?K z`K&waVoo~Aon+-Nj&pg!~}Dtj8KUOMJ>@u$%W+I%1G4IXB{ zPdht2un@C%9iseI9Cp`r2yKrcpIm1jCHDn`4{^dD1aOr<^Iu4oJv$bMShM|%*lUmL zaaz0`6dK-7D zxzG*QnqUSnMYa5=vMQ-mWYCs68%)-Ob3Zc zit{vDD|F0_?ndhkEs@2Oz38WN#f`-EOWd#KaQi?(_y>Qi%GyyE)3sWGTIqe+jitsF zx>jFO8EIkUrsRkD;)>OgUCtjn;abKuJ#~f*9){B6@-t7dVB;?FSyTJXy@V{lJ5kbzE|RJbiM9 zz+P?~w7!>3an4u|THnmZ%TnxR$U*B%c7mF49<;U&O4_>rN7tI|cI_>`Rbyyn*oVf7 zTrDmfI9y!pqwdu%+|S=1fSh&ZWq1}D?D|SUE07r99rr%Q)N{1Hr>IB9JzY?7{r|Qn`P6(Aul$Njb{xExmDf(E3z11>4M6 zg&nj^6*D0B!9Wbl?>nGB84B*8H&l;u7y!MEB3sCn4pLeAm*gVlD(|3GZqskHsXDf2 z>`j>gscuyUCWHsA?J5_#neJ^z<+6MkvdeWCmgNlVrPyMM<~c^7yrZrf^Na6tEF2w&iW*~l zi{=WenJQ(#ql$vT&okmy?0yY`UHK#A%^zeFz2NfD%qN$u5RQU;RRGC3R{=?Na{ z-o}~Bg!f_TjxwJxr=E-a9c9R$;r`P|BYRVorXtnu^FiyST%2sDtehtqHK+ zet)ph@+#?|gyHmqdY|c_b(M<)YPcujWCkO&JW$&!71R zWKp(DJNDoIl`KqK_CN3$z}<3hQDCw#x@HF!m+{2fsd%lu&q?jc)0&>eMc(fHlFRoa zRQA4vxa|f)m|Bl+s8XL*az;8T!mwH9HC|>1=vGo0x`4Bb%hvJK{B_1(_m*l+=PZCG z^>qq`+w>E`Ph*Z5Ox8WB#o*}Ky7MejBc;MIs!BBcTFgU@wq4qrnTd#k7&`pM;pe6! z+?%Py@35KKZTyhDHM}Kx8&ciNB&IzVkiU7@zaVx%Vh5ZxJjHn9XOaqxA;-8q>`3O> zpkDc@MCuD3!N~kep2W$vv`1B3?|w@`zF?EH#i2&Y?*8&dYnw{zmBX>Bs@(kkODY>y zd531ozVy#kc8ZYu{b@$ zsx+h!dV*)Vx1ABDUd3XmhZWTs5HZ{@a%O)9|3-j8H43kj=+QVnFTLOj8N z%))GFaW*tphsYtk#6l z4l!gXc#yoHw7%fMMjVZT*GA)QP}kci2b4T|f`>7p4WqmFQXU-KGH)~Ewu7$pxQ92O z1@_3A4LyMT7V0iu5s(RcA*uI9WxGWhA8_Bgd-9B7bHWl|{{mFC+Wb&wecR)uT4p zKX)t827gM7ZHG7eGe1D6Pj=I=!`B$Cdc*BO&hMnr)mlS8Q6z##y0;yXHirf{gn3s< zujmOL(I$7q_$B45?9KW&nWcNb)RKA8X!bG48)>`uOT$TjsC&P(8xu!f3@EV=_U2Gb z8zl`CX6liMgGLTTEn+n#f2M&cFt}6T%W72|DZ08;7UrNdS>k(<#abq-j9YcQFXb!} zorh4Oko~Ly9?&V0fEB|YfV#lhED9<> zX4nK3TOKT1B!6D>LKP@9OI4r%tKPR@IS)tB+^!7z?zoIJ`$)oG$LTqpF zP@f*h*B=MqDIg_#07W~+Z57^P&3Jk<(e33E(X)uh!3Bq>K~=0?KAAzD{ zv(0}VN||261LYd6k~CK(8(j`MH=fMWL3XUp9BK2jY2Dinv~0%?zyUt2?*I@z6ly=`#+Raxet59IX zr~;^KqoRWraw$doXDk6bd@zQgOa1~>;Em9gTvCbjd}R*{8;xYn2!8(qS?jEs*Z*g} z6y9*#Mo@kZBS2yAU(+3jB~jFL@+i1qkCh7^8@g!pR3!BVk8#(Tja2J!FLn4%9`_k_ zPl%(DmVAd6H4|JBNV4s%NMg4*^lAAp1YK3IU9fW6beRl zzFm$fEycdg3tdE(8({tW8@56ml@7duN`FqJWbI+j@AK{9WiX()aizD9WEW-V^Dvar zYnNfJI}0m!Z&WmkH9M!<4dkRakCW`(FPy^4Vc<&DH@(gY5VzEH_j8OrP`?@#&;yO$ zJM_vv!k(`0lJ_OwxW>Bw(D3l{e5A38KQEnj&-%%{S5p3-*LDq;e~D4`^M04a6kkrs z*EEhm&Gh%J8^-w-?sFcz4MOU9SLf;Z@%5QE(!U-0C2weCE!CkQPU-5AVSp&E2PmzfIpP=^pap9%>IF(x=wlqRL-wX&U!~hV>N)Oj2NE_M)V6 z&vs;^vw`|V+>FM}suj_An`z7sR7AwGrl!W4idF;zVg;UlG20XI`2n#y+7fNw9E}8W zaTO`7BHsU66E&;q6Nydj(fNU;tCuehEn3^OEVQa2*tC3Q@M@8xx-{7y2`oyRM!-fV z^%dciS+z0|X>VBVX3TM)#AjKcv~_YiB_#?{~NGY5sRsc=ckB@R7DCufvN=oGQ{V+oL6;qb)Yre z9)n!WM1YS41tQTDoqHrtNdqd zfcg0lTL8~eC6W+yN)nnW>zs{56^OX%dR2;899$7>3W~+iSQMgclZ7;{Z4xWPo1%e8 zdotQ$CX!G#6k;T!tyhZ{ZN_-g3TAw@!1HNlRfo2ltHpKUxL6WxM*gH&)R~08Ra}>j z!^Om+bemWc?G&q8Owo|oj6z!=fhE}BxDKuXZZ+JEa36=e4Xzok6>cM394-mB0?)Qf67kgfKwynDx2mKkg zrMeA0QmWmIRwt5eHE3y&M%08-Q`JS4H=@?ETdYXUC=!rCGangjiQ?JCP0_8QCEN)n zL_}5^Pe!IpJVzLB!xQZYb!_i%7OZN})p%;xTOJ*ec(Qz!QKu zPq43l$b-L`2k&>}XP#H{;MeouALPORmIuF`2U~!h{MdZu`&3;GtgiB0f}J5YvkB0Q zAW+$)*IiaSFSK?|aCNA0^{RC@iyE_|v!)A?>CR9Z15_@(KDfHc0bU=x8MJDu+hU34 zbgBl1fzCH+R(D1_^5dZ;87*m%Ola}))%nZ=u0eaKp(Rw|fzx!d-P~G3k{FLLFh*18 zJY(`Fh7cacHB6=5ETxs{lo@ElxETnW0X$+0Xcl_zc$I3j0X*26?m*)!I>$)5NT&y; zR-~q~4Y1b_JK80hb)Yhypn13Bg$Zqeni)=7qm(~;wDMEP#8GO#P<=?2F%GvVHrml? zZgmpYHFWkcc3qtKOVDgO(s+Qj6C`0^)b8;{(0~#;qVx&eD4D$%!w|sf z*?gj~8rggWC7(j7xA2m2JCRL{qZPQuy^E6F<5sf7aeS4EcU&0p1>?SqaN#%_*qCt! zetqNq88~A_$wQJz-MDUwd)y>+rEXE`N1m%tNO|G4#a)OhT*nyC)xas-$h%`%t@l8n zaQy_tdCma0a8tib@D@KrC`x3{-7GftZ!*E>xtF9m-a)c^T8Za;Lh)5Vb5Fw&ulIZu zQMLv@E(&@)L*paB9nTEo2l?|}HsnIK@#FAQyb;8`Kg=KtXxxlUrOb2^fvXCy@%#~f zVfq$Xi17RtDTSNE67qU@H&%YN-D8;e;RhclccoESWUSk5;FTC@oGGS8j0Ynw9I?9CEq`Ko>nGo=_ z656S_neI8s{22vRdP+#*Qwo~tNh3$$-3qGpJV5AP1qnPLcQ{sFus;_fngFFU$3Nnc(*>MQMI7_oB;aIm!ld znwRP){&@ZXvmRbK3vo&NKnyMU{O9oF@_W}J!S8Lu?*uk$zii-sZxG!gp?M3hrLE@{Y!p?FF!g%-LI@D)DcISRk< zN!FX1sHa4qqS3pjd6gQUCboN;Pk84eKuuo2?oPNv0B07=^}L5X1+!0~6jEU8Dwsnw z=J9QpNS75!q#7a>{R`3x=8~8weupJZWgUv=%0eGRbm1Jw`Ry@PR z^+5KHDgFe)?#fpf^B6E(g~f|evU`T4^)!PYJI2IG~H%}(+BBA+AEauCl+}$#mU~s1-^cD$aWRRnq z`%~n)_;!ltZi)L8gZD^;eZ=jN!I{LpPja=6!M+M|e@5ay!{BFSYzwnJC}XP_`*~T!KalR<%GkG9nrv>x?=bcuiI8FJ-^pN< zMLaBVKhEG+W$?44`!y+&2bk^alC!;x{f6Z1a^gNIW3OlMDH+QbIk}&ebiYO=J;%YN z_<3gg<}Ta;kYajE4L%MU^2VJ;@d&3 zU|JDrUX0kn@Nr4=SNJXCOj5NDcD>^X%Dx+A79s5SGP?K>G+7w=u#A|3-?Gc`qp~qH zo=CuDpHRFF>_?HY`K@+52L_wXb!9%E5!8~b(dyrHxKZCRj zk07t>qR+FS0uNtnHG#i6P{8Amrtm}V$X{gK2BIZ0ot4*mQSbwLg92E6c;Z*a14Sz74%)`pfUCWMWcWj zi*f{EE;gnmE@KjgpGzcE zuF^3;O#r2t9J6N`BN{Ra^p>tFTVLEH{O%!;)$?Zu9-&?#d(`dc?rKG zQyj&$MdR3@!@>Z&huEI3+0v5gXilj{gEc`-TT2TXK(ky@R3)PkBW&shAs3W2?eUga zIud18d-c&4PZMm%b~QHj_`bI47O)`9t)02?jiKcY^{ZAk@{|HW9!-Qok#HoE zl(@NEQcs}LZiZTMzCeo9oWx4T+B+_vD}$QmiWR}7cxm6_;F|i?%Nv_ktp-(_LTf^# z47?jJkdCL?+v3=w;HoeS&}x8xCWsZ(;S12BhMxv1rxA}pkif=X(TUs=gL~Ev`Ih430X9H3}(MrkSRB(}s& zohVDmM(P?j$2Qp*2->8UhFUulDUG6vma^y8Jzt8aSx8eaU~Z(?Y(1!au>=mzBB4a{ zMjRFa*Gz=sVZ6EzGD2ouM0-T?sOSV&Ha6Xy)n*Id<<}lhI1n0EQS~x*-8rL={J8~$&OdvZgPuUgU7Z`2Dnbikt z+T65I)z>zSO>kMgbV!?z5*-Z#h$#cTTL`Bpkr>6+fma-A+W=e27L^(zQ5rN4I0EuV z#cK6Q)#*1J;@ywU=~f43)_heKyoOQogFdiXb1DsU3z9XXSy?*C=PaW&7H)%0hg3;? zjUv_1(cF#(gP=20u2DMLX9#D8+Dznm5j$No+ND}AH+<^<(%nMnO;%ksJ+^hbYTyI) z=`^)YM>JU&oHR{23djuF#@B>aELziqtg7K?`)y5)0KvR!k+)~NA~dILy|ZG-U-&pAs=k4iea;t8iDP+M(tjq=4npvCd zN*u;RL#?ek-qE?J_HXB_a|mG7^~hsam+?zwJJyCA$H|9cGPMN~apYUx&=g$VfKD~I zdbR9NF@&=fNt8BiZ?cX$EK~F9<}?CyoUjKVXvHjTShYH+sINh6R>n&Gh+%i5YNEuY z41(RO-61(z)`(u$X+T=yEw*A+^>w!$v-@NeC8I=jYHNoXZia6rm2cP~sq9WsjboE& z^`dK+SDE29QEh}%hNzBgjU%J-&7`Qte5G2S%#8r>F4XE|G)8n<24J86FB1W+=t7YPB=TAJ{|WLFz1$dJP+E9 z42_r*GB4024(Bh|z#&@V@%+dF0?&=?i@3a&!eOeDU=q)LO0iDdh_GEQ#Ncc^o=+VjJzZbc&&Eq5OkT0HRqyo1 z`T?(K&0aR$PQ=)F6EUBg2)s@*p)cameFDzL<5J-stW$Pz??PWTy}JP0c%0%+oS%Ci zI#F%ByEPt*S_r&_!238WrmukZAAnDK#M^^=+V<4vXb{Dw_XUKBN8Rxzv%SCri`mP@ z`!ZrE6XMBt>jUp3!qf*Z;!)1~;B0!ldu-2Q6_03n+4P~9pT8!Gw>1uMm}|4=Y{B6W1A zVAT@sci(#iPwQ2?SLvk^X8TsKU&3t13Z~>#dsQ&Cg8l&QL%}?q7lQ3i!D>X|`)n1= z!>!!A@ICtUpY2AabB`l;c}Db zd&K0t^o#T0Kps40gpGUgtq3I{g+|zEM}#*xC=lM12V*NGdyST!Pd`6@etG%$`RN<7 zrLk?C&Chr9(%;B~r#lET|K>b6AK#HI%lm8j%cpl22y$5woezn zR`7Mewtc!VRZF_eKzu=*wZLcmIeIEhL_c)Wj3q8kC!15)|623rKfDbv!{}bR6 zydahMqw!OOE@H2459Eg@c)Z_+_~d6gU?)Gb0XzBOG50CFuG*&G1lYb<-#@31e0;E* zy_o;6)ki+PujcXd1Yo|t0Tq;Ds8F06q4tjA-uM)5U_&N>q6s-&Jdm3&6e9>OW6F&2|!grRx1@Jw@I&AJXS({1*Y+Zn8m@zm0JixZ2Fw>ScWC=5 z!xX|ox~;zeVB4Oj!k&46cpB--Ua=kn?3C96z?|=*c(kAY7;XaWgMMGo{6ql9^mxtm zcEHYW)$9OVNqk-Z&j5CQtL72FPWgQkFdq|!8d2T_;s9Xhw`+a`cp2!~{0;$je!J$6 zfOGW9M3G|-7XZ!4gujq$zcT^HD{+{FQ*6-?rJn{Q3&ezltk)-jT_b z_<|3(dwKS;qkSH76_d=W_V@x3Zf>uV8yg?=#;&tV!Qm#UVwVKxEqagpgYCbLO8dWc za5^eQoEh;fiL7!L1}9ATf=$fvSs$L}q|9_{E0RK?dYm(aRxDrBgs=UCLW@U0!DXQ( zs~4>dhOP}RUEUxOuB*>tcUITp!HW*u*=t54{6bJDk_hqMYwRS-9i31(jc@aC<0lkJ zcXVvEOA9tE&J|_@svsL;F?KjdRc;qas{gYZ;7JkhREI#?lK46jZqUbfd=TIlg5+m` zQd{F@xJzU|%!I8Yd_-vB!rZrc@GJ#B--8o}P8=5^8Cjjl`s+o`C>(Z#j4k%Zi<~L^ zKvI0OGX|TV&?WZ3lHslL^FY|2=huTE8+pe$cX=bJL~gsDcP)mn3*l&IiWi=0{Ij=BCklQUk@a7LW<{VGTZd-F~d z#NgQ=XN>+bk~0dQT8hP-5j+%e!s?Sx&KSxEk7J;gEs0J%W}?2m96x;(ZVAzl47EGIE;%4%_`Z(unSl>wlJvz(vv%0<@-^$1%kXIlJj zmJ>l5vidleGur+z)~KH{<0rI6BIB$_YDRq-%$cS>66TDN-|xyru -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* deal with older versions of libcurl and curl.h */ - -#ifndef CURLOPT_WRITEDATA -#define CURLOPT_WRITEDATA CURLOPT_FILE -#endif - -#ifndef CURLOPT_READDATA -#define CURLOPT_READDATA CURLOPT_FILE -#endif - -#ifndef CURLE_HTTP_RETURNED_ERROR -#define CURLE_HTTP_RETURNED_ERROR CURLE_HTTP_NOT_FOUND -#endif - -#define HTCP_GET 1 -#define HTCP_PUT 2 -#define HTCP_DELETE 3 -#define HTCP_LIST 4 -#define HTCP_LONGLIST 5 -#define HTCP_MKDIR 6 - -struct grst_stream_data { char *source; - char *destination; - int ishttps; - int method; - FILE *fp; - char *cert; - char *key; - char *capath; - char *useragent; - char *errorbuf; - int noverify; - int anonymous; - long long downgrade; - int verbose; } ; - -struct grst_index_blob { char *text; - size_t used; - size_t allocated; } ; - -struct grst_dir_list { char *filename; - size_t length; - int length_set; - time_t modified; - int modified_set; } ; - -struct grst_header_data { int retcode; - char *location; - char *gridauthonetime; - size_t length; - int length_set; - time_t modified; - int modified_set; - struct grst_stream_data *common_data; } ; - -size_t headers_callback(void *ptr, size_t size, size_t nmemb, void *p) -/* Find the values of the return code, Content-Length, Last-Modified - and Location headers */ -{ - float f; - char *s, *q; - size_t realsize; - struct tm modified_tm; - struct grst_header_data *header_data; - - header_data = (struct grst_header_data *) p; - realsize = size * nmemb; - s = malloc(realsize + 1); - memcpy(s, ptr, realsize); - s[realsize] = '\0'; - - if (sscanf(s, "Content-Length: %d", &(header_data->length)) == 1) - header_data->length_set = 1; - else if (sscanf(s, "HTTP/%f %d ", &f, &(header_data->retcode)) == 2) ; - else if (strncmp(s, "Location: ", 10) == 0) - { - header_data->location = strdup(&s[10]); - - if (header_data->common_data->verbose > 0) - fprintf(stderr, "Received Location: %s\n", header_data->location); - } - else if (strncmp(s, "Set-Cookie: GRID_AUTH_ONETIME=", 30) == 0) - { - header_data->gridauthonetime = strdup(&s[12]); - q = index(header_data->gridauthonetime, ';'); - if (q != NULL) *q = '\0'; - - if (header_data->common_data->verbose > 0) - fprintf(stderr, "Received Grid Auth Cookie: %s\n", - header_data->gridauthonetime); - } - else if (strncmp(s, "Last-Modified: ", 15) == 0) - { - /* follow RFC 2616: first try RFC 822 (kosher), then RFC 850 and - asctime() formats too. Must be GMT whatever the format. */ - - if (strptime(&s[15], "%a, %d %b %Y %T GMT", &modified_tm) != NULL) - { - header_data->modified = mktime(&modified_tm); - header_data->modified_set = 1; - } - else if (strptime(&s[15], "%a, %d-%b-%y %T GMT", &modified_tm) != NULL) - { - header_data->modified = mktime(&modified_tm); - header_data->modified_set = 1; - } - else if (strptime(&s[15], "%a %b %d %T %Y", &modified_tm) != NULL) - { - header_data->modified = mktime(&modified_tm); - header_data->modified_set = 1; - } - } - - free(s); - return realsize; -} - -int set_std_opts(CURL *easyhandle, struct grst_stream_data *common_data) -{ - struct stat statbuf; - - curl_easy_setopt(easyhandle, CURLOPT_FOLLOWLOCATION, 0); - - if ((common_data->cert != NULL) && (common_data->key != NULL)) - { - curl_easy_setopt(easyhandle, CURLOPT_SSLENGINE, NULL); - curl_easy_setopt(easyhandle, CURLOPT_SSLCERTTYPE, "PEM"); - curl_easy_setopt(easyhandle, CURLOPT_SSLCERT, common_data->cert); - curl_easy_setopt(easyhandle, CURLOPT_SSLKEY, common_data->key); - } - else - { - curl_easy_setopt(easyhandle, CURLOPT_SSLENGINE, "RSA"); - curl_easy_setopt(easyhandle, CURLOPT_SSLCERTTYPE, "ENG"); - } - - if (common_data->capath != NULL) - { -#if (LIBCURL_VERSION_NUM >= 0x070908) - if ((stat(common_data->capath, &statbuf) == 0) && - S_ISDIR(statbuf.st_mode)) - curl_easy_setopt(easyhandle, CURLOPT_CAPATH, common_data->capath); - else -#endif - curl_easy_setopt(easyhandle, CURLOPT_CAINFO, common_data->capath); - } - - if (common_data->noverify) - curl_easy_setopt(easyhandle, CURLOPT_SSL_VERIFYHOST, 0); - else curl_easy_setopt(easyhandle, CURLOPT_SSL_VERIFYHOST, 2); - - return 1; -} - -int do_copies(char *sources[], char *destination, - struct grst_stream_data *common_data) -{ - char *p, *thisdestination; - int isrc, anyerror = 0, thiserror, isdirdest; - CURL *easyhandle; - struct stat statbuf; - struct grst_header_data header_data; - struct curl_slist *dgheader_slist = NULL, *nodgheader_slist = NULL; - - easyhandle = curl_easy_init(); - - if (common_data->downgrade >= (long long) 0) - { - asprintf(&p, "HTTP-Downgrade-Size: %lld", common_data->downgrade); - dgheader_slist = curl_slist_append(dgheader_slist, p); - free(p); - - nodgheader_slist = curl_slist_append(nodgheader_slist, - "HTTP-Downgrade-Size:"); - } - - curl_easy_setopt(easyhandle, CURLOPT_USERAGENT, common_data->useragent); - if (common_data->verbose > 1) - curl_easy_setopt(easyhandle, CURLOPT_VERBOSE, 1); - - curl_easy_setopt(easyhandle, CURLOPT_HEADERFUNCTION, headers_callback); - curl_easy_setopt(easyhandle, CURLOPT_WRITEHEADER, &header_data); - - set_std_opts(easyhandle, common_data); - - curl_easy_setopt(easyhandle, CURLOPT_ERRORBUFFER, common_data->errorbuf); - - if (destination[strlen(destination) - 1] != '/') - { - isdirdest = 0; - thisdestination = destination; - } - else isdirdest = 1; - - for (isrc=0; sources[isrc] != NULL; ++isrc) - { - if (isdirdest) - { - p = rindex(sources[isrc], '/'); - if (p == NULL) p = sources[isrc]; - else p++; - - asprintf(&thisdestination, "%s%s", destination, p); - } - - if (common_data->verbose > 0) - fprintf(stderr, "%s -> %s\n", sources[isrc], thisdestination); - - if (common_data->method == HTCP_GET) - { - common_data->fp = fopen(thisdestination, "w"); - if (common_data->fp == NULL) - { - fprintf(stderr,"... failed to open destination source file %s\n", - thisdestination); - anyerror = 99; - if (isdirdest) free(thisdestination); - continue; - } - - curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, common_data->fp); - curl_easy_setopt(easyhandle, CURLOPT_URL, sources[isrc]); - - if ((common_data->downgrade >= (long long) 0) && - (strncmp(sources[isrc], "https://", 8) == 0)) - { - if (common_data->verbose > 0) - fprintf(stderr, "Add HTTP-Downgrade-Size: %lld header\n", - common_data->downgrade); - - curl_easy_setopt(easyhandle,CURLOPT_HTTPHEADER,dgheader_slist); - } - else - curl_easy_setopt(easyhandle,CURLOPT_HTTPHEADER,nodgheader_slist); - } - else if (common_data->method == HTCP_PUT) - { - if (stat(sources[isrc], &statbuf) != 0) - { - fprintf(stderr, "... source file %s not found\n", sources[isrc]); - anyerror = 99; - if (isdirdest) free(thisdestination); - continue; - } - - common_data->fp = fopen(sources[isrc], "r"); - if (common_data->fp == NULL) - { - fprintf(stderr, "... failed to open source file %s\n", - sources[isrc]); - anyerror = 99; - if (isdirdest) free(thisdestination); - continue; - } - - curl_easy_setopt(easyhandle, CURLOPT_READDATA, common_data->fp); - curl_easy_setopt(easyhandle, CURLOPT_URL, thisdestination); - curl_easy_setopt(easyhandle, CURLOPT_INFILESIZE, statbuf.st_size); - curl_easy_setopt(easyhandle, CURLOPT_UPLOAD, 1); - - if (((long long) statbuf.st_size >= common_data->downgrade) && - (strncmp(thisdestination, "https://", 8) == 0)) - curl_easy_setopt(easyhandle,CURLOPT_HTTPHEADER,dgheader_slist); - else - curl_easy_setopt(easyhandle,CURLOPT_HTTPHEADER,nodgheader_slist); - } - - header_data.retcode = 0; - header_data.location = NULL; - header_data.gridauthonetime = NULL; - header_data.common_data = common_data; - thiserror = curl_easy_perform(easyhandle); - - fclose(common_data->fp); - - if ((common_data->downgrade >= (long long) 0) && - (thiserror == 0) && - (header_data.retcode == 302) && - (header_data.location != NULL) && - (strncmp(header_data.location, "http://", 7) == 0) && - (header_data.gridauthonetime != NULL)) - { - if (common_data->verbose > 0) - fprintf(stderr, "... Found (%d)\nHTTP-Downgrade to %s\n", - header_data.retcode, header_data.location); - - /* try again with new URL and all the previous CURL options */ - - if (common_data->method == HTCP_GET) - { - common_data->fp = fopen(thisdestination, "w"); - if (common_data->fp == NULL) - { - fprintf(stderr, "... failed to open destination source " - "file %s\n", thisdestination); - anyerror = 99; - if (isdirdest) free(thisdestination); - continue; - } - } - else if (common_data->method == HTCP_PUT) - { - common_data->fp = fopen(sources[isrc], "r"); - if (common_data->fp == NULL) - { - fprintf(stderr, "... failed to open source file %s\n", - sources[isrc]); - anyerror = 99; - if (isdirdest) free(thisdestination); - continue; - } - } - - header_data.retcode = 0; - curl_easy_setopt(easyhandle, CURLOPT_URL, header_data.location); - curl_easy_setopt(easyhandle, CURLOPT_HTTPHEADER, nodgheader_slist); - curl_easy_setopt(easyhandle, CURLOPT_COOKIE, - header_data.gridauthonetime); - thiserror = curl_easy_perform(easyhandle); - - fclose(common_data->fp); - } - - if ((thiserror != 0) || - (header_data.retcode < 200) || - (header_data.retcode >= 300)) - { - fprintf(stderr, "... curl error: %s (%d), HTTP error: %d\n", - common_data->errorbuf, thiserror, header_data.retcode); - - if (thiserror != 0) anyerror = thiserror; - else anyerror = header_data.retcode; - } - else if (common_data->verbose > 0) - fprintf(stderr, "... OK (%d)\n", header_data.retcode); - - if (isdirdest) free(thisdestination); - } - - curl_easy_cleanup(easyhandle); - - return anyerror; -} - -int do_deletes(char *sources[], struct grst_stream_data *common_data) -{ - int isrc, anyerror = 0, thiserror; - CURL *easyhandle; - struct grst_header_data header_data; - - header_data.common_data = common_data; - - easyhandle = curl_easy_init(); - - curl_easy_setopt(easyhandle, CURLOPT_USERAGENT, common_data->useragent); - if (common_data->verbose > 1) - curl_easy_setopt(easyhandle, CURLOPT_VERBOSE, 1); - - curl_easy_setopt(easyhandle, CURLOPT_HEADERFUNCTION, headers_callback); - curl_easy_setopt(easyhandle, CURLOPT_WRITEHEADER, &header_data); - - curl_easy_setopt(easyhandle, CURLOPT_ERRORBUFFER, common_data->errorbuf); - curl_easy_setopt(easyhandle, CURLOPT_CUSTOMREQUEST, "DELETE"); - curl_easy_setopt(easyhandle, CURLOPT_NOBODY, 1); - - set_std_opts(easyhandle, common_data); - - for (isrc=0; sources[isrc] != NULL; ++isrc) - { - if (common_data->verbose > 0) - fprintf(stderr, "Deleting %s\n", sources[isrc]); - - curl_easy_setopt(easyhandle, CURLOPT_URL, sources[isrc]); - - header_data.retcode = 0; - thiserror = curl_easy_perform(easyhandle); - - if ((thiserror != 0) || - (header_data.retcode < 200) || - (header_data.retcode >= 300)) - { - fprintf(stderr, "... curl error: %s (%d), HTTP error: %d\n", - common_data->errorbuf, thiserror, header_data.retcode); - - if (thiserror != 0) anyerror = thiserror; - else anyerror = header_data.retcode; - } - else if (common_data->verbose > 0) - fprintf(stderr, "... OK (%d)\n", header_data.retcode); - } - - curl_easy_cleanup(easyhandle); - - return anyerror; -} - -int do_mkdirs(char *sources[], struct grst_stream_data *common_data) -{ - int isrc, anyerror = 0, thiserror; - CURL *easyhandle; - struct grst_header_data header_data; - - header_data.common_data = common_data; - - easyhandle = curl_easy_init(); - - curl_easy_setopt(easyhandle, CURLOPT_USERAGENT, common_data->useragent); - if (common_data->verbose > 1) - curl_easy_setopt(easyhandle, CURLOPT_VERBOSE, 1); - - curl_easy_setopt(easyhandle, CURLOPT_HEADERFUNCTION, headers_callback); - curl_easy_setopt(easyhandle, CURLOPT_WRITEHEADER, &header_data); - - curl_easy_setopt(easyhandle, CURLOPT_ERRORBUFFER, common_data->errorbuf); - curl_easy_setopt(easyhandle, CURLOPT_CUSTOMREQUEST, "PUT"); - curl_easy_setopt(easyhandle, CURLOPT_NOBODY, 1); - - set_std_opts(easyhandle, common_data); - - for (isrc=0; sources[isrc] != NULL; ++isrc) - { - if (common_data->verbose > 0) - fprintf(stderr, "Make directory %s\n", sources[isrc]); - - curl_easy_setopt(easyhandle, CURLOPT_URL, sources[isrc]); - - header_data.retcode = 0; - thiserror = curl_easy_perform(easyhandle); - - if ((thiserror != 0) || - (header_data.retcode < 200) || - (header_data.retcode >= 300)) - { - fprintf(stderr, "... curl error: %s (%d), HTTP error: %d\n", - common_data->errorbuf, thiserror, header_data.retcode); - - if (thiserror != 0) anyerror = thiserror; - else anyerror = header_data.retcode; - } - else if (common_data->verbose > 0) - fprintf(stderr, "... OK (%d)\n", header_data.retcode); - } - - curl_easy_cleanup(easyhandle); - - return anyerror; -} - -size_t rawindex_callback(void *ptr, size_t size, size_t nmemb, void *data) -{ - if ( ((struct grst_index_blob *) data)->used + size * nmemb >= - ((struct grst_index_blob *) data)->allocated ) - { - ((struct grst_index_blob *) data)->allocated = - ((struct grst_index_blob *) data)->used + size * nmemb + 4096; - - ((struct grst_index_blob *) data)->text = - realloc( ((struct grst_index_blob *) data)->text, - ((struct grst_index_blob *) data)->allocated ); - } - - memcpy( &( ((struct grst_index_blob *) - data)->text[((struct grst_index_blob *) data)->used] ), - ptr, size * nmemb); - - ((struct grst_index_blob *) data)->used += size * nmemb; - - return size * nmemb; -} - -char *canonicalise(char *link, char *source) -{ - int i, j, srclen; - char *s; - - srclen = strlen(source); - - if ((strncmp(link, "https://", 8) == 0) || - (strncmp(link, "http://", 7) == 0)) - { - if (strncmp(link, source, srclen) != 0) return NULL; /* other site */ - - if (link[srclen] == '\0') return NULL; /* we dont self-link! */ - - for (i=0; link[srclen + i] != '\0'; ++i) - if (link[srclen + i] == '/') - { - if (link[srclen + i + 1] != '\0') return NULL; /* no subdirs */ - else return strdup(&link[srclen]); /* resolves to this dir */ - } - } - else if (link[0] != '/') /* relative link - need to check for subsubdirs */ - { - for (i=0; link[i] != '\0'; ++i) - if ((link[i] == '/') && (link[i+1] != '\0')) return NULL; - - s = strdup(link); - - for (i=0; s[i] != '\0'; ++i) - if (s[i] == '#') - { - s[i] = '\0'; - break; - } - - return s; - } - - /* absolute link on this server, starting / */ - - for (i=8; source[i] != '\0'; ++i) if (source[i] == '/') break; - - if (strncmp(link, &source[i], srclen - i) != 0) return NULL; - - for (j = srclen - i; link[j] != '\0'; ++j) - if ((link[j] == '/') && (link[j+1] != '\0')) return NULL; - - s = strdup(&link[srclen - i]); - - for (i=0; s[i] != '\0'; ++i) - if (s[i] == '#') - { - s[i] = '\0'; - break; - } - - if (s[0] == '\0') /* on second thoughts... */ - { - free(s); - return NULL; - } - - return s; -} - -int grst_dir_list_cmp(const void *a, const void *b) -{ - return strcmp( ((struct grst_dir_list *) a)->filename, - ((struct grst_dir_list *) b)->filename); -} - -struct grst_dir_list *index_to_dir_list(char *text, char *source) -{ - int taglevel = 0, wordnew = 1, i, namestart, used = 0, - allocated = 256; - char *p, *s; - struct grst_dir_list *list; - - list = (struct grst_dir_list *) - malloc(allocated * sizeof(struct grst_dir_list)); - - list[0].filename = NULL; - list[0].length = 0; - list[0].length_set = 0; - list[0].modified = 0; - list[0].modified_set = 0; - - for (p=text; *p != '\0'; ++p) - { - if (*p == '<') - { - ++taglevel; - - if ((taglevel == 1) && (list[used].filename != NULL)) - { - ++used; - if (used >= allocated) - { - allocated += 256; - list = (struct grst_dir_list *) - realloc((void *) list, - allocated * sizeof(struct grst_dir_list)); - } - - list[used].filename = NULL; - list[used].length = 0; - list[used].length_set = 0; - list[used].modified = 0; - list[used].modified_set = 0; - } - - wordnew = 1; - continue; - } - - if (*p == '>') - { - --taglevel; - wordnew = 1; - continue; - } - - if (isspace(*p)) - { - wordnew = 1; - continue; - } - - if ((wordnew) && (taglevel == 1)) - { - if (((*p == 'h') || (*p == 'H')) && - (strncasecmp(p, "href=", 5) == 0)) - { - if (p[5] == '"') { namestart = 6; - for (i=namestart; (p[i] != '\0') && - (p[i] != '"' ) && - (p[i] != '\n') && - (p[i] != '\t') && - (p[i] != '>' ) ; ++i) ; } - else { namestart = 5; - for (i=namestart; (p[i] != '\0') && - (p[i] != '"' ) && - (p[i] != ' ' ) && - (p[i] != '\n') && - (p[i] != '\t') && - (p[i] != ')' ) && - (p[i] != '>' ) ; ++i) ; } - if (i > namestart) - { - s = malloc(1 + i - namestart); - memcpy(s, &p[namestart], i - namestart); - s[i - namestart] = '\0'; - - list[used].filename = canonicalise(s, source); - free(s); - } - - p = &p[i-1]; /* -1 since continue results in ++i */ - continue; - } - - if (((*p == 'c') || (*p == 'C')) && - (strncasecmp(p, "content-length=", 15) == 0)) - { - list[used].length = 0; - list[used].length_set = 1; - - if (p[15] == '"') list[used].length = atoi(&p[16]); - else list[used].length = atoi(&p[15]); - - p = &p[15]; - continue; - } - - if (((*p == 'l') || (*p == 'L')) && - (strncasecmp(p, "last-modified=", 14) == 0)) - { - list[used].modified = 0; - list[used].modified_set = 1; - - if (p[14] == '"') list[used].modified = atoi(&p[15]); - else list[used].modified = atoi(&p[14]); - - p = &p[14]; - continue; - } - } - - wordnew = 0; - } - - qsort((void *) list, used, sizeof(struct grst_dir_list), grst_dir_list_cmp); - - return list; -} - -int do_listings(char *sources[], struct grst_stream_data *common_data, - int islonglist) -{ - int isrc, anyerror = 0, thiserror, i, isdir, ilast; - CURL *easyhandle; - const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - char *s; - struct grst_index_blob rawindex; - struct grst_dir_list *list; - struct grst_header_data header_data; - struct tm modified_tm; - time_t now; - - time(&now); - - header_data.common_data = common_data; - - easyhandle = curl_easy_init(); - - curl_easy_setopt(easyhandle, CURLOPT_USERAGENT, common_data->useragent); - if (common_data->verbose > 1) - curl_easy_setopt(easyhandle, CURLOPT_VERBOSE, 1); - - curl_easy_setopt(easyhandle, CURLOPT_WRITEHEADER, &header_data); - curl_easy_setopt(easyhandle, CURLOPT_HEADERFUNCTION, headers_callback); - - curl_easy_setopt(easyhandle, CURLOPT_ERRORBUFFER, common_data->errorbuf); - - set_std_opts(easyhandle, common_data); - - for (isrc=0; sources[isrc] != NULL; ++isrc) - { - if (common_data->verbose > 0) - fprintf(stderr, "Listing %s\n", sources[isrc]); - - if (sources[1] != NULL) printf("\n%s:\n", sources[isrc]); - - curl_easy_setopt(easyhandle, CURLOPT_URL, sources[isrc]); - - if (sources[isrc][strlen(sources[isrc])-1] == '/') - { - isdir = 1; - curl_easy_setopt(easyhandle,CURLOPT_WRITEFUNCTION,rawindex_callback); - curl_easy_setopt(easyhandle,CURLOPT_WRITEDATA,(void *) &rawindex); - curl_easy_setopt(easyhandle,CURLOPT_NOBODY,0); - rawindex.text = NULL; - rawindex.used = 0; - rawindex.allocated = 0; - } - else - { - isdir = 0; - curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, NULL); - curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, NULL); - curl_easy_setopt(easyhandle, CURLOPT_NOBODY, 1); - } - - header_data.gridauthonetime = NULL; - header_data.length_set = 0; - header_data.modified_set = 0; - header_data.retcode = 0; - thiserror = curl_easy_perform(easyhandle); - - if ((thiserror != 0) || - (header_data.retcode < 200) || - (header_data.retcode >= 300)) - { - fprintf(stderr, "... curl error: %s (%d), HTTP error: %d\n", - common_data->errorbuf, thiserror, header_data.retcode); - - if (thiserror != 0) anyerror = thiserror; - else anyerror = header_data.retcode; - } - else if (isdir) - { - if (common_data->verbose > 0) - fprintf(stderr, "... OK (%d)\n", header_data.retcode); - - rawindex.text[rawindex.used] = '\0'; - - list = index_to_dir_list(rawindex.text, sources[isrc]); - ilast = -1; - - for (i=0; list[i].filename != NULL; ++i) - { - if (list[i].filename[0] == '.') continue; - - if (strncmp(list[i].filename, "mailto:", 7) == 0) continue; - - if ((ilast >= 0) && - (strcmp(list[i].filename, list[ilast].filename) == 0)) - continue; - ilast=i; - - if (islonglist) - { - if (!list[i].length_set || !list[i].modified_set) - { - curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, - NULL); - curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, NULL); - curl_easy_setopt(easyhandle, CURLOPT_NOBODY, 1); - - asprintf(&s, "%s%s", sources[isrc], list[i].filename); - curl_easy_setopt(easyhandle, CURLOPT_URL, s); - - header_data.gridauthonetime = NULL; - header_data.length_set = 0; - header_data.modified_set = 0; - header_data.retcode = 0; - thiserror = curl_easy_perform(easyhandle); - free(s); - - if ((thiserror == 0) && - (header_data.retcode >= 200) && - (header_data.retcode <= 299)) - { - if (header_data.length_set) - { - list[i].length_set = 1; - list[i].length = header_data.length; - } - - if (header_data.modified_set) - { - list[i].modified_set = 1; - list[i].modified = header_data.modified; - } - } - } - - if (list[i].length_set) printf("%10ld ", list[i].length); - else fputs(" ? ", stdout); - - if (list[i].modified_set) - { - localtime_r(&(list[i].modified), &modified_tm); - - if (list[i].modified < now - 15552000) - printf("%s %2d %4d ", - months[modified_tm.tm_mon], - modified_tm.tm_mday, - modified_tm.tm_year + 1900); - else printf("%s %2d %02d:%02d ", - months[modified_tm.tm_mon], - modified_tm.tm_mday, - modified_tm.tm_hour, - modified_tm.tm_min); - } - else fputs(" ? ? ? ", stdout); - } - - puts(list[i].filename); - } - } - else - { - if (islonglist) - { - printf("%10ld ", header_data.length); - - localtime_r(&(header_data.modified), &modified_tm); - - if (header_data.modified < now - 15552000) - printf("%s %2d %4d ", - months[modified_tm.tm_mon], - modified_tm.tm_mday, - modified_tm.tm_year + 1900); - else printf("%s %2d %02d:%02d ", - months[modified_tm.tm_mon], - modified_tm.tm_mday, - modified_tm.tm_hour, - modified_tm.tm_min); - } - - puts(sources[isrc]); - } - } - - curl_easy_cleanup(easyhandle); - - return anyerror; -} - -#if (LIBCURL_VERSION_NUM < 0x070908) -char *make_tmp_ca_roots(char *dir) -/* libcurl before 7.9.8 doesnt support CURLOPT_CAPATH and the directory, - so we make a temporary file with the concatenated CA root certs: that - is, all the files in that directory which end in .0 */ -{ - int ofd, ifd, c; - size_t size; - char tmp_ca_roots[] = "/tmp/.ca-roots-XXXXXX", buffer[4096], *s; - DIR *rootsDIR; - struct dirent *root_ent; - - if ((rootsDIR = opendir(dir)) == NULL) return NULL; - - if ((ofd = mkstemp(tmp_ca_roots)) == -1) - { - closedir(rootsDIR); - return NULL; - } - - while ((root_ent = readdir(rootsDIR)) != NULL) - { - if ((root_ent->d_name[0] != '.') && - (strlen(root_ent->d_name) > 2) && - (strncmp(&(root_ent->d_name[strlen(root_ent->d_name)-2]), - ".0", 2) == 0)) - { - asprintf(&s, "%s/%s", dir, root_ent->d_name); - ifd = open(s, O_RDONLY); - free(s); - - if (ifd != -1) - { - while ((size = read(ifd, buffer, sizeof(buffer))) > 0) - write(ofd, buffer, size); - close(ifd); - } - } - } - - closedir(rootsDIR); - - if (close(ofd) == 0) return strdup(tmp_ca_roots); - - unlink(tmp_ca_roots); /* try to clean up */ - - return NULL; -} -#endif - -void printsyntax(char *argv0) -{ - char *p; - - p = rindex(argv0, '/'); - if (p != NULL) ++p; - else p = argv0; - - fprintf(stderr, "%s [options] Source-URL[s] [Destination URL]\n" - "%s is one of a set of clients to fetch files or directory listings\n" -"from remote servers using HTTP or HTTPS, or to put or delete files or\n" -"directories onto remote servers using HTTPS. htcp is similar to scp(1)\n" -"but uses HTTP/HTTPS rather than ssh as its transfer protocol.\n" -"See the htcp(1) or http://www.gridsite.org/ for details.\n" -"(Version: %s)\n", p, p, VERSION); -} - -int main(int argc, char *argv[]) -{ - char **sources, *destination = NULL, *executable, *p; - int c, i, option_index, anyerror; - struct stat statbuf; - struct grst_stream_data common_data; - struct passwd *userpasswd; - struct option long_options[] = { {"verbose", 0, 0, 'v'}, - {"cert", 1, 0, 0}, - {"key", 1, 0, 0}, - {"capath", 1, 0, 0}, - {"delete", 0, 0, 0}, - {"list", 0, 0, 0}, - {"long-list", 0, 0, 0}, - {"mkdir", 0, 0, 0}, - {"no-verify", 0, 0, 0}, - {"anon", 0, 0, 0}, - {"downgrade-size", 1, 0, 0}, -// {"streams", 1, 0, 0}, -// {"blocksize", 1, 0, 0}, -// {"recursive", 0, 0, 0}, - {0, 0, 0, 0} }; - -#if (LIBCURL_VERSION_NUM < 0x070908) - char *tmp_ca_roots = NULL; -#endif - - if (argc == 1) - { - printsyntax(argv[0]); - return 0; - } - - common_data.cert = NULL; - common_data.key = NULL; - common_data.capath = NULL; - common_data.method = 0; - common_data.errorbuf = malloc(CURL_ERROR_SIZE); - asprintf(&(common_data.useragent), - "htcp/%s (http://www.gridsite.org/)", VERSION); - common_data.verbose = 0; - common_data.noverify = 0; - common_data.anonymous = 0; - common_data.downgrade = (long long) -1; - - while (1) - { - option_index = 0; - - c = getopt_long(argc, argv, "v", long_options, &option_index); - - if (c == -1) break; - else if (c == 0) - { - if (option_index == 1) common_data.cert = optarg; - else if (option_index == 2) common_data.key = optarg; - else if (option_index == 3) common_data.capath = optarg; - else if (option_index == 4) common_data.method = HTCP_DELETE; - else if (option_index == 5) common_data.method = HTCP_LIST; - else if (option_index == 6) common_data.method = HTCP_LONGLIST; - else if (option_index == 7) common_data.method = HTCP_MKDIR; - else if (option_index == 8) common_data.noverify = 1; - else if (option_index == 9) common_data.anonymous = 1; - else if (option_index ==10) common_data.downgrade = atoll(optarg); - } - else if (c == 'v') ++(common_data.verbose); - } - - if (common_data.verbose > 0) - { - p = rindex(argv[0], '/'); - if (p != NULL) ++p; - else p = argv[0]; - fprintf(stderr, "%s version %s\n", p, VERSION); - } - - if (common_data.anonymous) /* prevent any use of user certs */ - { - common_data.cert = NULL; - common_data.key = NULL; - } - else if ((common_data.cert == NULL) && (common_data.key != NULL)) - common_data.cert = common_data.key; - else if ((common_data.cert != NULL) && (common_data.key == NULL)) - common_data.key = common_data.cert; - else if ((common_data.cert == NULL) && (common_data.key == NULL)) - { - common_data.cert = getenv("X509_USER_PROXY"); - if (common_data.cert != NULL) common_data.key = common_data.cert; - else - { - asprintf(&(common_data.cert), "/tmp/x509up_u%d", geteuid()); - - /* one fine day, we will check the proxy file for expiry too ... */ - - if (stat(common_data.cert, &statbuf) == 0) - common_data.key = common_data.cert; - else - { - common_data.cert = getenv("X509_USER_CERT"); - common_data.key = getenv("X509_USER_KEY"); - - userpasswd = getpwuid(geteuid()); - - if ((common_data.cert == NULL) && - (userpasswd != NULL) && - (userpasswd->pw_dir != NULL)) - asprintf(&(common_data.cert), "%s/.globus/usercert.pem", - userpasswd->pw_dir); - - if ((common_data.key == NULL) && - (userpasswd != NULL) && - (userpasswd->pw_dir != NULL)) - asprintf(&(common_data.key), "%s/.globus/userkey.pem", - userpasswd->pw_dir); - } - } - } - - if (common_data.capath == NULL) common_data.capath = getenv("X509_CERT_DIR"); - - if (common_data.capath == NULL) - common_data.capath = "/etc/grid-security/certificates"; - -#if (LIBCURL_VERSION_NUM < 0x070908) - /* libcurl before 7.9.8 doesnt support CURLOPT_CAPATH and the directory */ - - if ((common_data.capath != NULL) && - (stat(common_data.capath, &statbuf) == 0) && S_ISDIR(statbuf.st_mode)) - { - tmp_ca_roots = make_tmp_ca_roots(common_data.capath); - common_data.capath = tmp_ca_roots; - } -#endif - - executable = rindex(argv[0], '/'); - if (executable != NULL) executable++; - else executable = argv[0]; - - if (common_data.method == 0) /* command-line options override exec name */ - { - if (strcmp(executable,"htls")==0) common_data.method=HTCP_LIST; - else if (strcmp(executable,"htll")==0) common_data.method=HTCP_LONGLIST; - else if (strcmp(executable,"htrm")==0) common_data.method=HTCP_DELETE; - else if (strcmp(executable,"htmkdir")==0) common_data.method=HTCP_MKDIR; - } - - if ((common_data.method == HTCP_DELETE) || - (common_data.method == HTCP_LIST) || - (common_data.method == HTCP_MKDIR) || - (common_data.method == HTCP_LONGLIST)) - { - if (optind >= argc) - { - fprintf(stderr, "Must give at least 1 non-option argument\n\n"); - printsyntax(argv[0]); - return CURLE_URL_MALFORMAT; - } - - sources = (char **) malloc(sizeof(char *) * (1 + argc - optind)); - for (i=0; i < argc - optind; ++i) - { - sources[i] = argv[optind + i]; - - if ((common_data.method == HTCP_MKDIR) && - (sources[i][strlen(sources[i])-1] != '/')) - { - fprintf(stderr, "Argument \"%s\" is not a " - "directory URL (no trailing /)\n\n", sources[i]); - printsyntax(argv[0]); - return CURLE_URL_MALFORMAT; - } - } - - sources[i] = NULL; - - if (common_data.method == HTCP_DELETE) - anyerror = do_deletes(sources, &common_data); - else if (common_data.method == HTCP_MKDIR) - anyerror = do_mkdirs(sources, &common_data); - else if (common_data.method == HTCP_LONGLIST) - anyerror = do_listings(sources, &common_data, 1); - else anyerror = do_listings(sources, &common_data, 0); - - if (anyerror > 99) anyerror = CURLE_HTTP_RETURNED_ERROR; - - return anyerror; - } - - if (optind >= argc - 1) - { - fputs("Must give at least 2 non-option arguments\n\n", stderr); - printsyntax(argv[0]); - return CURLE_URL_MALFORMAT; - } - - sources = (char **) malloc(sizeof(char *) * (argc - optind)); - - for (i=0; i < (argc - optind - 1); ++i) - { - if (strncmp(argv[optind + i], "file:", 5) == 0) - sources[i] = &argv[optind + i][5]; - else sources[i] = argv[optind + i]; - - if (sources[i][0] == '\0') - { - fprintf(stderr, "Source argument %d is empty\n\n", i + 1); - printsyntax(argv[0]); - return CURLE_URL_MALFORMAT; - } - } - - sources[i] = NULL; - - if (strncmp(argv[optind + i], "file:", 5) == 0) - destination = &argv[optind + i][5]; - else destination = argv[optind + i]; - - if (destination[0] == '\0') - { - fputs("Destination argument is empty\n\n", stderr); - printsyntax(argv[0]); - return CURLE_URL_MALFORMAT; - } - - if ((argc - optind > 2) && (destination[strlen(destination)-1] != '/')) - { - fputs("For multiple sources, destination " - "must be a directory (end in /)\n\n", stderr); - printsyntax(argv[0]); - return CURLE_URL_MALFORMAT; - } - - if ((strncmp(destination, "http://", 7) == 0) || - (strncmp(destination, "https://", 8) == 0)) - common_data.method = HTCP_PUT; - else common_data.method = HTCP_GET; - - for (i=0; sources[i] != NULL; ++i) - { - if ((common_data.method == HTCP_PUT) && - ((strncmp(sources[i], "http://", 7) == 0) || - (strncmp(sources[i], "https://", 8) == 0))) - { - fputs("Cannot have both source and destination remote\n\n",stderr); - printsyntax(argv[0]); - return CURLE_URL_MALFORMAT; - } - - if ((common_data.method == HTCP_GET) && - ((strncmp(sources[i], "http://", 7) != 0) && - (strncmp(sources[i], "https://", 8) != 0))) - { - fputs("Cannot have both source and " - "destination local (for now)\n\n",stderr); - printsyntax(argv[0]); - return CURLE_URL_MALFORMAT; - } - } - - anyerror = do_copies(sources, destination, &common_data); - if (anyerror > 99) anyerror = CURLE_HTTP_RETURNED_ERROR; - - return anyerror; -} diff --git a/org.gridsite.core/src/htproxyput.c b/org.gridsite.core/src/htproxyput.c deleted file mode 100644 index 834bea2..0000000 --- a/org.gridsite.core/src/htproxyput.c +++ /dev/null @@ -1,565 +0,0 @@ -/* - Copyright (c) 2002-4, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - -Build with: - -gcc -lcurl -lssl -lcrypto -o grst-proxy-put grst-proxy-put.c libgridsite.a - -http://www.gridpp.ac.uk/authz/gridsite/ - -*/ - -#ifndef VERSION -#define VERSION "0.0.0" -#endif - -#define _GNU_SOURCE - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "gridsite.h" - -#include "soapH.h" -#include "delegation.nsmap" - -#define USE_SOAP 0 -#define USE_G_HTTPS 1 -#define HTPROXY_PUT 0 - -int debugfunction(CURL *curl, curl_infotype type, char *s, size_t n, void *p) -{ - fwrite(s, sizeof(char), n, (FILE *) p); - - return 0; -} - -size_t parsegprheaders(void *ptr, size_t size, size_t nmemb, void *p) -{ - int i; - - if ((size * nmemb > 15) && - (strncmp((char *) ptr, "Delegation-ID: ", 15) == 0)) - { - *((char **) p) = malloc( size * nmemb - 14 ); - - memcpy(*((char **) p), &(((char *) ptr)[15]), size * nmemb - 15); - - for (i=0; i < size * nmemb - 15; ++i) - if (((*((char **) p))[i] == '\n') || ((*((char **) p))[i] == '\r')) - { - (*((char **) p))[i] = '\0'; /* drop trailing newline */ - break; - } - - (*((char **) p))[size * nmemb - 15] = '\0'; - } - - return size * nmemb; -} - -struct gprparams { char *req; size_t len; } ; - -size_t storegprbody(void *ptr, size_t size, size_t nmemb, void *p) -{ - ((struct gprparams *) p)->req = realloc( ((struct gprparams *) p)->req, - ((struct gprparams *) p)->len + size * nmemb + 1); - - memcpy( &((((struct gprparams *) p)->req)[((struct gprparams *) p)->len]), - ptr, size * nmemb); - - ((struct gprparams *) p)->len += size * nmemb; - - return size * nmemb; -} - -int GRSTgetProxyReq(CURL *curl, FILE *debugfp, char *delegid, char **reqtxt, - char *requrl, char *cert, char *key) -{ - char *delheader; - struct curl_slist *headerlist = NULL; - CURLcode res; - struct gprparams params; - - params.req = NULL; - params.len = 0; - - curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) ¶ms); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, storegprbody); - - curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); - curl_easy_setopt(curl, CURLOPT_SSLCERT, cert); - - curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM"); - curl_easy_setopt(curl, CURLOPT_SSLKEY, key); - curl_easy_setopt(curl, CURLOPT_SSLKEYPASSWD, NULL); - -// curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, parsegprheaders); -// curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *) delegid); - - curl_easy_setopt(curl, CURLOPT_CAPATH, "/etc/grid-security/certificates/"); - - curl_easy_setopt(curl, CURLOPT_URL, requrl); - curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET-PROXY-REQ"); - - curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER,0); - curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST,0); - - asprintf(&delheader, "Delegation-ID: %s", delegid); - headerlist = curl_slist_append(headerlist, delheader); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); - - if (debugfp != NULL) - { - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - curl_easy_setopt(curl, CURLOPT_DEBUGDATA, debugfp); - curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, debugfunction); - } - - res = curl_easy_perform(curl); - - if (params.req != NULL) - { - params.req[params.len] = '\0'; - *reqtxt = params.req; - } - else *reqtxt = NULL; - - return (int) res; -} - -struct ppcparams{ char *cert; size_t len; }; - -size_t getppcbody(void *ptr, size_t size, size_t nmemb, void *p) -{ - size_t i; - - if (((struct ppcparams *) p)->len == 0) return 0; - - if (size * nmemb < ((struct ppcparams *) p)->len) i = size * nmemb; - else i = ((struct ppcparams *) p)->len; - - memcpy(ptr, ((struct ppcparams *) p)->cert, i); - - ((struct ppcparams *) p)->len -= i; - ((struct ppcparams *) p)->cert = &((((struct ppcparams *) p)->cert)[i+1]); - - return i; -} - -int GRSTputProxyCerts(CURL *curl, FILE *debugfp, char *delegid, char *certtxt, - char *requrl, char *cert, char *key) -{ - CURLcode res; - char *delheader; - long httpcode; - struct curl_slist *headerlist = NULL; - struct ppcparams params; - - params.cert = certtxt; - params.len = strlen(certtxt); - - curl_easy_setopt(curl, CURLOPT_READDATA, ¶ms); - curl_easy_setopt(curl, CURLOPT_READFUNCTION, getppcbody); - curl_easy_setopt(curl, CURLOPT_INFILESIZE, strlen(certtxt)); - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); - - curl_easy_setopt(curl, CURLOPT_NOBODY, 1); - - curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); - curl_easy_setopt(curl, CURLOPT_SSLCERT, cert); - - curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM"); - curl_easy_setopt(curl, CURLOPT_SSLKEY, key); -// curl_easy_setopt(curl, CURLOPT_SSLKEYPASSWD, NULL); - - curl_easy_setopt(curl, CURLOPT_CAPATH, "/etc/grid-security/certificates/"); - - curl_easy_setopt(curl, CURLOPT_URL, requrl); - curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT-PROXY-CERT"); - - headerlist = curl_slist_append(headerlist, - "Content-Type: application/x-x509-user-cert-chain"); - - asprintf(&delheader, "Delegation-ID: %s", delegid); - headerlist = curl_slist_append(headerlist, delheader); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); - -curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); -curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); - - if (debugfp != NULL) - { - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - curl_easy_setopt(curl, CURLOPT_DEBUGDATA, debugfp); - curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, debugfunction); - } - - res = curl_easy_perform(curl); - - curl_easy_getinfo(curl, CURLINFO_HTTP_CODE, &httpcode); - - curl_slist_free_all(headerlist); - - free(delheader); - - return (int) res; -} - - -#if (LIBCURL_VERSION_NUM < 0x070908) -char *make_tmp_ca_roots(char *dir) -/* libcurl before 7.9.8 doesnt support CURLOPT_CAPATH and the directory, - so we make a temporary file with the concatenated CA root certs: that - is, all the files in that directory which end in .0 */ -{ - int ofd, ifd, c; - size_t size; - char tmp_ca_roots[] = "/tmp/.ca-roots-XXXXXX", buffer[4096], *s; - DIR *rootsDIR; - struct dirent *root_ent; - - if ((rootsDIR = opendir(dir)) == NULL) return NULL; - - if ((ofd = mkstemp(tmp_ca_roots)) == -1) - { - closedir(rootsDIR); - return NULL; - } - - while ((root_ent = readdir(rootsDIR)) != NULL) - { - if ((root_ent->d_name[0] != '.') && - (strlen(root_ent->d_name) > 2) && - (strncmp(&(root_ent->d_name[strlen(root_ent->d_name)-2]), - ".0", 2) == 0)) - { - asprintf(&s, "%s/%s", dir, root_ent->d_name); - ifd = open(s, O_RDONLY); - free(s); - - if (ifd != -1) - { - while ((size = read(ifd, buffer, sizeof(buffer))) > 0) - write(ofd, buffer, size); - - close(ifd); - } - } - } - - closedir(rootsDIR); - - if (close(ofd) == 0) return strdup(tmp_ca_roots); - - unlink(tmp_ca_roots); /* try to clean up if errors */ - - return NULL; -} -#endif - -void printsyntax(char *argv0) -{ - char *p; - - p = rindex(argv0, '/'); - if (p != NULL) ++p; - else p = argv0; - - fprintf(stderr, "%s [options] URL\n" - "(Version: %s)\n", p, VERSION); -} - -int main(int argc, char *argv[]) -{ - char *delegation_id = "", *reqtxt, *certtxt, *valid = NULL, - *cert = NULL, *key = NULL, *capath = NULL, *keycert; - struct ns__putProxyResponse *unused; - int option_index, c, protocol = USE_SOAP, noverify = 0, - method = HTPROXY_PUT, verbose = 0, fd, minutes; - struct soap soap_get, soap_put; - FILE *ifp, *ofp; - struct stat statbuf; - struct passwd *userpasswd; - struct option long_options[] = { {"verbose", 0, 0, 'v'}, - {"cert", 1, 0, 0}, - {"key", 1, 0, 0}, - {"capath", 1, 0, 0}, - {"soap", 0, 0, 0}, - {"g-https", 0, 0, 0}, - {"no-verify", 0, 0, 0}, - {"valid", 1, 0, 0}, - {"delegation-id",1, 0, 0}, - {"put", 0, 0, 0}, - {0, 0, 0, 0} }; - CURL *curl; - - if (argc == 1) - { - printsyntax(argv[0]); - return 0; - } - - while (1) - { - option_index = 0; - - c = getopt_long(argc, argv, "v", long_options, &option_index); - - if (c == -1) break; - else if (c == 0) - { - if (option_index == 1) cert = optarg; - else if (option_index == 2) key = optarg; - else if (option_index == 3) capath = optarg; - else if (option_index == 4) protocol = USE_SOAP; - else if (option_index == 5) protocol = USE_G_HTTPS; - else if (option_index == 6) noverify = 1; - else if (option_index == 7) valid = optarg; - else if (option_index == 8) delegation_id = optarg; - else if (option_index == 9) method = HTPROXY_PUT; - } - else if (c == 'v') ++verbose; - } - - if (optind + 1 != argc) - { - fprintf(stderr, "Must specify a target URL!\n"); - return 1; - } - - if (valid == NULL) minutes = 60 * 12; - else minutes = atoi(valid); - - if (verbose) fprintf(stderr, "Proxy valid for %d minutes\n", minutes); - - ERR_load_crypto_strings (); - OpenSSL_add_all_algorithms(); - - if ((cert == NULL) && (key != NULL)) cert = key; - else if ((cert != NULL) && (key == NULL)) key = cert; - else if ((cert == NULL) && (key == NULL)) - { - cert = getenv("X509_USER_PROXY"); - if (cert != NULL) key = cert; - else - { - asprintf(&(cert), "/tmp/x509up_u%d", geteuid()); - - /* one fine day, we will check the proxy file for - expiry too to avoid suprises when we try to use it ... */ - - if (stat(cert, &statbuf) == 0) key = cert; - else - { - cert = getenv("X509_USER_CERT"); - key = getenv("X509_USER_KEY"); - - userpasswd = getpwuid(geteuid()); - - if ((cert == NULL) && - (userpasswd != NULL) && - (userpasswd->pw_dir != NULL)) - asprintf(&(cert), "%s/.globus/usercert.pem", - userpasswd->pw_dir); - - if ((key == NULL) && - (userpasswd != NULL) && - (userpasswd->pw_dir != NULL)) - asprintf(&(key), "%s/.globus/userkey.pem", - userpasswd->pw_dir); - - } - } - } - - if (capath == NULL) capath = getenv("X509_CERT_DIR"); - if (capath == NULL) capath = "/etc/grid-security/certificates"; - - if (verbose) fprintf(stderr, "key=%s\ncert=%s\ncapath=%s\n", - key, cert, capath); - -#if (LIBCURL_VERSION_NUM < 0x070908) - /* libcurl before 7.9.8 doesnt support CURLOPT_CAPATH and the directory */ - - if ((capath != NULL) && - (stat(capath, &statbuf) == 0) && S_ISDIR(statbuf.st_mode)) - { - tmp_ca_roots = make_tmp_ca_roots(capath); - capath = tmp_ca_roots; - } -#endif - - if (protocol == USE_G_HTTPS) - { - if (verbose) fprintf(stderr, "Using G-HTTPS delegation protocol\n"); - - if (verbose) fprintf(stderr, "Delegation-ID: %s\n", delegation_id); - - curl_global_init(CURL_GLOBAL_DEFAULT); - curl = curl_easy_init(); - -// curl_easy_setopt(curl, CURLOPT_SSLKEYPASSWD, NULL); - - GRSTgetProxyReq(curl, stderr, delegation_id, &reqtxt, - argv[optind], cert, key); - - if (GRSTx509MakeProxyCert(&certtxt, stderr, reqtxt, cert, key, minutes) - != GRST_RET_OK) - { - return 1; - } - - GRSTputProxyCerts(curl, stderr, delegation_id, certtxt, - argv[optind], cert, key); - - curl_easy_cleanup(curl); - curl_global_cleanup(); - - return 0; - } - else if (protocol == USE_SOAP) - { - if (strcmp(key, cert) != 0) /* we have to concatenate for gSOAP */ - { - keycert = strdup("/tmp/XXXXXX"); - - fd = mkstemp(keycert); - ofp = fdopen(fd, "w"); - - ifp = fopen(key, "r"); - while ((c = fgetc(ifp)) != EOF) fputc(c, ofp); - fclose(ifp); - - ifp = fopen(cert, "r"); - while ((c = fgetc(ifp)) != EOF) fputc(c, ofp); - fclose(ifp); - - fclose(ofp); - - if (verbose) fprintf(stderr, "Created %s key/cert file\n", keycert); - } - else keycert = key; - - if (verbose) - { - fprintf(stderr, "Using SOAP delegation protocol\n"); - fprintf(stderr, "Delegation-ID: %s\n", delegation_id); - fprintf(stderr, "Send getProxyReq to service\n"); - } - - soap_init(&soap_get); - - if (soap_ssl_client_context(&soap_get, - SOAP_SSL_DEFAULT, - keycert, - "", - NULL, - capath, - NULL)) - { - soap_print_fault(&soap_get, stderr); - return 1; - } - - soap_call_ns__getProxyReq(&soap_get, - argv[optind], /* HTTPS url of service */ - "", /* no password on proxy */ - delegation_id, - &reqtxt); - - if (soap_get.error) - { - soap_print_fault(&soap_get, stderr); - return 1; - } - - if (verbose) fprintf(stderr, "reqtxt:\n%s", reqtxt); - - if (GRSTx509MakeProxyCert(&certtxt, stderr, reqtxt, cert, key, minutes) - != GRST_RET_OK) - { - return 1; - } - - soap_init(&soap_put); - - if (verbose) fprintf(stderr, "Send putProxy to service:\n%s\n", certtxt); - - if (soap_ssl_client_context(&soap_put, - SOAP_SSL_DEFAULT, - keycert, - "", - NULL, - capath, - NULL)) - { - soap_print_fault(&soap_put, stderr); - return 1; - } - - soap_call_ns__putProxy(&soap_put, argv[optind], "", delegation_id, - certtxt, unused); - if (soap_put.error) - { - soap_print_fault(&soap_put, stderr); - return 1; - } - - return 0; - } - - /* weirdness */ -} - diff --git a/org.gridsite.core/src/mod_gridsite.c b/org.gridsite.core/src/mod_gridsite.c deleted file mode 100644 index 78d853c..0000000 --- a/org.gridsite.core/src/mod_gridsite.c +++ /dev/null @@ -1,2357 +0,0 @@ -/* - Copyright (c) 2003-4, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/*------------------------------------------------------------------* - * This program is part of GridSite: http://www.gridsite.org/ * - *------------------------------------------------------------------*/ - -#ifndef VERSION -#define VERSION "x.x.x" -#endif - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - - -#include "mod_ssl-private.h" - -#include "gridsite.h" - -#ifndef UNSET -#define UNSET -1 -#endif - -module AP_MODULE_DECLARE_DATA gridsite_module; - -typedef struct -{ - int auth; - int envs; - int format; - int indexes; - char *indexheader; - int gridsitelink; - char *adminfile; - char *adminuri; - char *helpuri; - char *dnlists; - char *dnlistsuri; - char *adminlist; - int gsiproxylimit; - char *unzip; - char *methods; - char *editable; - char *headfile; - char *footfile; - int downgrade; - char *authcookiesdir; - int soap2cgi; -} mod_gridsite_cfg; /* per-directory config choices */ - - -typedef struct -{ - xmlDocPtr doc; -// char *outbuffer; -} soap2cgi_ctx; /* store per-request context for Soap2cgi in/out filters */ - -static const char Soap2cgiFilterName[]="Soap2cgiFilter"; - -static void mod_gridsite_soap2cgi_insert(request_rec *r) -{ - mod_gridsite_cfg *conf; - soap2cgi_ctx *ctx; - - conf = (mod_gridsite_cfg *) ap_get_module_config(r->per_dir_config, - &gridsite_module); - - if (conf->soap2cgi) - { - ctx = (soap2cgi_ctx *) malloc(sizeof(soap2cgi_ctx)); - ctx->doc = NULL; - - ap_add_output_filter(Soap2cgiFilterName, ctx, r, r->connection); - - ap_add_input_filter(Soap2cgiFilterName, NULL, r, r->connection); - } -} - -xmlNodePtr find_one_child(xmlNodePtr parent_node, char *name) -{ - xmlNodePtr cur; - - for (cur = parent_node->children; cur != NULL; cur = cur->next) - { - if ((cur->type == XML_ELEMENT_NODE) && - (strcmp(cur->name, name) == 0)) return cur; - } - - return NULL; -} - -int add_one_node(xmlDocPtr doc, char *line) -{ - char *p, *name, *aftername, *attrname = NULL, *value = NULL; - xmlNodePtr cur, cur_child; - - cur = xmlDocGetRootElement(doc); - - p = index(line, '='); - if (p == NULL) return 1; - - *p = '\0'; - value = &p[1]; - - name = line; - - while (1) /* go through each .-deliminated segment of line[] */ - { - if ((p = index(name, '.')) != NULL) - { - *p = '\0'; - aftername = &p[1]; - } - else aftername = &name[strlen(name)]; - - if ((p = index(name, '_')) != NULL) - { - *p = '\0'; - attrname = &p[1]; - } - - cur_child = find_one_child(cur, name); - - if (cur_child == NULL) - cur_child = xmlNewChild(cur, NULL, name, NULL); - - cur = cur_child; - - name = aftername; - - if (attrname != NULL) - { - xmlSetProp(cur, attrname, value); - return 0; - } - - if (*name == '\0') - { - xmlNodeSetContent(cur, value); - return 0; - } - } -} - -static apr_status_t mod_gridsite_soap2cgi_out(ap_filter_t *f, - apr_bucket_brigade *bbIn) -{ - char *p, *name, *outbuffer; - request_rec *r = f->r; - conn_rec *c = r->connection; - apr_bucket *bucketIn, *pbktEOS; - apr_bucket_brigade *bbOut; - - const char *data; - apr_size_t len; - char *buf; - apr_size_t n; - apr_bucket *pbktOut; - - soap2cgi_ctx *ctx; - xmlNodePtr root_node = NULL; - xmlBufferPtr buff; - - ctx = (soap2cgi_ctx *) f->ctx; - -// LIBXML_TEST_VERSION; - - bbOut = apr_brigade_create(r->pool, c->bucket_alloc); - - if (ctx->doc == NULL) - { - ctx->doc = xmlNewDoc("1.0"); - - root_node = xmlNewNode(NULL, "Envelope"); - xmlDocSetRootElement(ctx->doc, root_node); - - xmlNewChild(root_node, NULL, "Header", NULL); - xmlNewChild(root_node, NULL, "Body", NULL); - } - - apr_brigade_pflatten(bbIn, &outbuffer, &len, r->pool); - - /* split up buffer and feed each line to add_one_node() */ - - name = outbuffer; - - while (*name != '\0') - { - p = index(name, '\n'); - if (p != NULL) - { - *p = '\0'; - ++p; - } - else p = &name[strlen(name)]; /* point to final NUL */ - - add_one_node(ctx->doc, name); - - name = p; - } - - APR_BRIGADE_FOREACH(bucketIn, bbIn) - { - if (APR_BUCKET_IS_EOS(bucketIn)) - { - /* write out XML tree we have built */ - - buff = xmlBufferCreate(); - xmlNodeDump(buff, ctx->doc, root_node, 0, 0); - -// TODO: simplify/reduce number of copies or libxml vs APR buffers? - - buf = (char *) xmlBufferContent(buff); - - pbktOut = apr_bucket_heap_create(buf, strlen(buf), NULL, - c->bucket_alloc); - - APR_BRIGADE_INSERT_TAIL(bbOut, pbktOut); - - xmlBufferFree(buff); - - pbktEOS = apr_bucket_eos_create(c->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(bbOut, pbktEOS); - - continue; - } - } - - return ap_pass_brigade(f->next, bbOut); -} - -static apr_status_t mod_gridsite_soap2cgi_in(ap_filter_t *f, - apr_bucket_brigade *pbbOut, - ap_input_mode_t eMode, - apr_read_type_e eBlock, - apr_off_t nBytes) -{ - request_rec *r = f->r; - conn_rec *c = r->connection; -// CaseFilterInContext *pCtx; - apr_status_t ret; - -#ifdef NEVERDEFINED - - ret = ap_get_brigade(f->next, pCtx->pbbTmp, eMode, eBlock, nBytes); - - if (!(pCtx = f->ctx)) { - f->ctx = pCtx = apr_palloc(r->pool, sizeof *pCtx); - pCtx->pbbTmp = apr_brigade_create(r->pool, c->bucket_alloc); - } - - if (APR_BRIGADE_EMPTY(pCtx->pbbTmp)) { - ret = ap_get_brigade(f->next, pCtx->pbbTmp, eMode, eBlock, nBytes); - - if (eMode == AP_MODE_EATCRLF || ret != APR_SUCCESS) - return ret; - } - - while(!APR_BRIGADE_EMPTY(pCtx->pbbTmp)) { - apr_bucket *pbktIn = APR_BRIGADE_FIRST(pCtx->pbbTmp); - apr_bucket *pbktOut; - const char *data; - apr_size_t len; - char *buf; - int n; - - /* It is tempting to do this... - * APR_BUCKET_REMOVE(pB); - * APR_BRIGADE_INSERT_TAIL(pbbOut,pB); - * and change the case of the bucket data, but that would be wrong - * for a file or socket buffer, for example... - */ - - if(APR_BUCKET_IS_EOS(pbktIn)) { - APR_BUCKET_REMOVE(pbktIn); - APR_BRIGADE_INSERT_TAIL(pbbOut, pbktIn); - break; - } - - ret=apr_bucket_read(pbktIn, &data, &len, eBlock); - if(ret != APR_SUCCESS) - return ret; - - buf = malloc(len); - for(n=0 ; n < len ; ++n) - buf[n] = apr_toupper(data[n]); - - pbktOut = apr_bucket_heap_create(buf, len, 0, c->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(pbbOut, pbktOut); - apr_bucket_delete(pbktIn); - } -#endif - - return APR_SUCCESS; -} - -char *make_admin_footer(request_rec *r, mod_gridsite_cfg *conf, - int isdirectory) -/* - make string holding last modified text and admin links -*/ -{ - char *out, *https, *p, *dn = NULL, *file = NULL, *permstr = NULL, - *temp, modified[99], *dir_uri, *grst_cred_0 = NULL; - GRSTgaclPerm perm = GRST_PERM_NONE; - struct tm mtime_tm; - time_t mtime_time; - - https = (char *) apr_table_get(r->subprocess_env, "HTTPS"); - - dir_uri = apr_pstrdup(r->pool, r->uri); - p = rindex(dir_uri, '/'); - - if (p == NULL) return ""; - - file = apr_pstrdup(r->pool, &p[1]); - p[1] = '\0'; - /* dir_uri always gets both a leading and a trailing slash */ - - out = apr_pstrdup(r->pool, "

    \n"); - - if (!isdirectory) - { - mtime_time = apr_time_sec(r->finfo.mtime); - - localtime_r(&mtime_time, &mtime_tm); - strftime(modified, sizeof(modified), - "%a %e %B %Y", &mtime_tm); - temp = apr_psprintf(r->pool,"


    Last modified %s\n", modified); - out = apr_pstrcat(r->pool, out, temp, NULL); - - if ((conf->adminuri != NULL) && - (conf->adminuri[0] != '\0') && - (conf->adminfile != NULL) && - (conf->adminfile[0] != '\0') && - (strncmp(file, GRST_HIST_PREFIX, sizeof(GRST_HIST_PREFIX)-1) != 0)) - { - temp = apr_psprintf(r->pool, - ". " - "View page history\n", - conf->adminfile, file); - out = apr_pstrcat(r->pool, out, temp, NULL); - } - } - - out = apr_pstrcat(r->pool, out, "
    ", NULL); - - if (r->connection->notes != NULL) - grst_cred_0 = (char *) - apr_table_get(r->connection->notes, "GRST_CRED_0"); - - if ((grst_cred_0 != NULL) && - (strncmp(grst_cred_0, "X509USER ", sizeof("X509USER")) == 0)) - { - p = index(grst_cred_0, ' '); - if (p != NULL) - { - p = index(++p, ' '); - if (p != NULL) - { - p = index(++p, ' '); - if (p != NULL) - { - p = index(++p, ' '); - if (p != NULL) dn = p; - } - } - } - } - - if (dn != NULL) - { - temp = apr_psprintf(r->pool, "You are %s
    \n", dn); - out = apr_pstrcat(r->pool, out, temp, NULL); - - if (r->notes != NULL) - permstr = (char *) apr_table_get(r->notes, "GRST_PERM"); - - if ((permstr != NULL) && - (conf->adminuri != NULL) && - (conf->adminuri[0] != '\0') && - (conf->adminfile != NULL) && - (conf->adminfile[0] != '\0')) - { - sscanf(permstr, "%d", &perm); - - if (!isdirectory && - GRSTgaclPermHasWrite(perm) && - (strncmp(file, GRST_HIST_PREFIX, - sizeof(GRST_HIST_PREFIX) - 1) != 0)) - { - temp = apr_psprintf(r->pool, - "" - "Edit page .\n", conf->adminfile, file); - out = apr_pstrcat(r->pool, out, temp, NULL); - } - - if (GRSTgaclPermHasList(perm) || GRSTgaclPermHasWrite(perm)) - { - temp = apr_psprintf(r->pool, - "Manage directory .\n", - dir_uri, conf->adminfile); - - out = apr_pstrcat(r->pool, out, temp, NULL); - } - } - } - - if ((https != NULL) && (strcasecmp(https, "on") == 0)) - temp = apr_psprintf(r->pool, - "Switch to HTTP \n", - r->server->server_hostname, r->unparsed_uri); - else temp = apr_psprintf(r->pool, - "Switch to HTTPS \n", - r->server->server_hostname, r->unparsed_uri); - - out = apr_pstrcat(r->pool, out, temp, NULL); - - if ((conf->helpuri != NULL) && (conf->helpuri[0] != '\0')) - { - temp = apr_psprintf(r->pool, - ". Website Help\n", conf->helpuri); - out = apr_pstrcat(r->pool, out, temp, NULL); - } - - if ((!isdirectory) && - (conf->adminuri != NULL) && - (conf->adminuri[0] != '\0') && - (conf->adminfile != NULL) && - (conf->adminfile[0] != '\0')) - { - temp = apr_psprintf(r->pool, ". " - "Print View\n", conf->adminfile, file); - out = apr_pstrcat(r->pool, out, temp, NULL); - } - - if (conf->gridsitelink) - { - temp = apr_psprintf(r->pool, - ". Built with " - "GridSite %s\n", VERSION); - out = apr_pstrcat(r->pool, out, temp, NULL); - } - - out = apr_pstrcat(r->pool, out, "\n
    \n", NULL); - - return out; -} - -int html_format(request_rec *r, mod_gridsite_cfg *conf) -/* - try to do GridSite formatting of .html files (NOT .shtml etc) -*/ -{ - int i, fd, errstatus; - char *buf, *p, *file, *s, *head_formatted, *header_formatted, - *body_formatted, *admin_formatted, *footer_formatted; - size_t length; - struct stat statbuf; - apr_file_t *fp; - - if (r->finfo.filetype == APR_NOFILE) return HTTP_NOT_FOUND; - - if (apr_file_open(&fp, r->filename, APR_READ, 0, r->pool) != 0) - return HTTP_INTERNAL_SERVER_ERROR; - - file = rindex(r->uri, '/'); - if (file != NULL) ++file; /* file points to name without path */ - - buf = apr_palloc(r->pool, (size_t)(r->finfo.size + 1)); - length = r->finfo.size; - apr_file_read(fp, buf, &length); - buf[r->finfo.size] = '\0'; - apr_file_close(fp); - - /* **** try to find a header file in this or parent directories **** */ - - /* first make a buffer big enough to hold path names we want to try */ - fd = -1; - s = malloc(strlen(r->filename) + strlen(conf->headfile) + 1); - strcpy(s, r->filename); - - for (;;) - { - p = rindex(s, '/'); - if (p == NULL) break; /* failed to find one */ - p[1] = '\0'; - strcat(p, conf->headfile); - - fd = open(s, O_RDONLY); - if (fd != -1) break; /* found one */ - - *p = '\0'; - } - - free(s); - - if (fd == -1) /* not found, so set up not to output one */ - { - head_formatted = apr_pstrdup(r->pool, ""); - header_formatted = apr_pstrdup(r->pool, ""); - body_formatted = buf; - } - else /* found a header file, so set up head and body to surround it */ - { - fstat(fd, &statbuf); - header_formatted = apr_palloc(r->pool, statbuf.st_size + 1); - read(fd, header_formatted, statbuf.st_size); - header_formatted[statbuf.st_size] = '\0'; - close(fd); - - p = strstr(buf, "pool, ""); - body_formatted = buf; - } - else - { - *p = '\0'; - head_formatted = buf; - ++p; - - while ((*p != '>') && (*p != '\0')) ++p; - - if (*p == '\0') - { - body_formatted = p; - } - else - { - *p = '\0'; - ++p; - body_formatted = p; - } - } - } - - /* **** remove closing tag from body **** */ - - p = strstr(body_formatted, "filename) + strlen(conf->footfile)); - strcpy(s, r->filename); - - for (;;) - { - p = rindex(s, '/'); - if (p == NULL) break; /* failed to find one */ - - p[1] = '\0'; - strcat(p, conf->footfile); - - fd = open(s, O_RDONLY); - if (fd != -1) break; /* found one */ - - *p = '\0'; - } - - free(s); - - if (fd == -1) /* failed to find a footer, so set up empty default */ - { - footer_formatted = apr_pstrdup(r->pool, ""); - } - else /* found a footer, so set up to use it */ - { - fstat(fd, &statbuf); - footer_formatted = apr_palloc(r->pool, statbuf.st_size + 1); - read(fd, footer_formatted, statbuf.st_size); - footer_formatted[statbuf.st_size] = '\0'; - close(fd); - } - - /* **** can now calculate the Content-Length and output headers **** */ - - length = strlen(head_formatted) + strlen(header_formatted) + - strlen(body_formatted) + strlen(admin_formatted) + - strlen(footer_formatted); - - ap_set_content_length(r, length); - ap_set_content_type(r, "text/html"); - - /* ** output the HTTP body (HTML Head+Body) ** */ - - ap_rputs(head_formatted, r); - ap_rputs(header_formatted, r); - ap_rputs(body_formatted, r); - ap_rputs(admin_formatted, r); - ap_rputs(footer_formatted, r); - - return OK; -} - -int html_dir_list(request_rec *r, mod_gridsite_cfg *conf) -/* - output HTML directory listing, with level of formatting controlled - by GridSiteHtmlFormat/conf->format -*/ -{ - int i, fd, n; - char *buf, *p, *s, *head_formatted, *header_formatted, - *body_formatted, *admin_formatted, *footer_formatted, *temp, - modified[99], *d_namepath, *indexheaderpath, *indexheadertext; - size_t length; - struct stat statbuf; - struct tm mtime_tm; - struct dirent **namelist; - - if (r->finfo.filetype == APR_NOFILE) return HTTP_NOT_FOUND; - - head_formatted = apr_psprintf(r->pool, - "Directory listing %s\n", r->uri); - - if (conf->format) - { - /* **** try to find a header file in this or parent directories **** */ - - /* first make a buffer big enough to hold path names we want to try */ - fd = -1; - s = malloc(strlen(r->filename) + strlen(conf->headfile) + 1); - strcpy(s, r->filename); - - for (;;) - { - p = rindex(s, '/'); - if (p == NULL) break; /* failed to find one */ - p[1] = '\0'; - strcat(p, conf->headfile); - - fd = open(s, O_RDONLY); - if (fd != -1) break; /* found one */ - - *p = '\0'; - } - - free(s); - - if (fd == -1) /* not found, so set up to output sensible default */ - { - header_formatted = apr_pstrdup(r->pool, ""); - } - else /* found a header file, so set up head and body to surround it */ - { - fstat(fd, &statbuf); - header_formatted = apr_palloc(r->pool, statbuf.st_size + 1); - read(fd, header_formatted, statbuf.st_size); - header_formatted[statbuf.st_size] = '\0'; - close(fd); - } - } - else header_formatted = apr_pstrdup(r->pool, ""); - - body_formatted = apr_psprintf(r->pool, - "

    Directory listing %s

    \n", r->uri); - - if (conf->indexheader != NULL) - { - indexheaderpath = apr_psprintf(r->pool, "%s/%s", r->filename, - conf->indexheader); - fd = open(indexheaderpath, O_RDONLY); - if (fd != -1) - { - fstat(fd, &statbuf); - indexheadertext = apr_palloc(r->pool, statbuf.st_size + 1); - read(fd, indexheadertext, statbuf.st_size); - indexheadertext[statbuf.st_size] = '\0'; - close(fd); - - body_formatted = apr_pstrcat(r->pool, body_formatted, - indexheadertext, NULL); - } - } - - body_formatted = apr_pstrcat(r->pool, body_formatted, "

    \n", NULL); - - if (r->unparsed_uri[1] != '\0') - body_formatted = apr_pstrcat(r->pool, body_formatted, - "\n", - NULL); - - n = scandir(r->filename, &namelist, 0, versionsort); - while (n--) - { - if ((namelist[n]->d_name[0] != '.') && - ((conf->indexheader == NULL) || - (strcmp(conf->indexheader, namelist[n]->d_name) != 0))) - { - d_namepath = apr_psprintf(r->pool, "%s/%s", r->filename, - namelist[n]->d_name); - stat(d_namepath, &statbuf); - - localtime_r(&(statbuf.st_mtime), &mtime_tm); - strftime(modified, sizeof(modified), - "", - &mtime_tm); - - if (S_ISDIR(statbuf.st_mode)) - temp = apr_psprintf(r->pool, - "" - "%s\n", - namelist[n]->d_name, statbuf.st_size, statbuf.st_mtime, - namelist[n]->d_name, - statbuf.st_size, modified); - else temp = apr_psprintf(r->pool, - "" - "%s\n", - namelist[n]->d_name, statbuf.st_size, statbuf.st_mtime, - namelist[n]->d_name, - statbuf.st_size, modified); - - body_formatted = apr_pstrcat(r->pool,body_formatted,temp,NULL); - } - - free(namelist[n]); - } - - free(namelist); - - body_formatted = apr_pstrcat(r->pool, body_formatted, "
    [Parent directory]
    %R%e %b %y
    " - "%s/%ld
    " - "%s%ld
    \n", NULL); - - if (conf->format) - { - /* **** set up dynamic part of footer to go at end of body **** */ - - admin_formatted = make_admin_footer(r, conf, TRUE); - - /* **** try to find a footer file in this or parent directories **** */ - - /* first make a buffer big enough to hold path names we want to try */ - fd = -1; - s = malloc(strlen(r->filename) + strlen(conf->footfile)); - strcpy(s, r->filename); - - for (;;) - { - p = rindex(s, '/'); - if (p == NULL) break; /* failed to find one */ - - p[1] = '\0'; - strcat(p, conf->footfile); - - fd = open(s, O_RDONLY); - if (fd != -1) break; /* found one */ - - *p = '\0'; - } - - free(s); - - if (fd == -1) /* failed to find a footer, so use standard default */ - { - footer_formatted = apr_pstrdup(r->pool, ""); - } - else /* found a footer, so set up to use it */ - { - fstat(fd, &statbuf); - footer_formatted = apr_palloc(r->pool, statbuf.st_size + 1); - read(fd, footer_formatted, statbuf.st_size); - footer_formatted[statbuf.st_size] = '\0'; - close(fd); - } - } - else - { - admin_formatted = apr_pstrdup(r->pool, ""); - footer_formatted = apr_pstrdup(r->pool, ""); - } - - /* **** can now calculate the Content-Length and output headers **** */ - - length = strlen(head_formatted) + strlen(header_formatted) + - strlen(body_formatted) + strlen(admin_formatted) + - strlen(footer_formatted); - - ap_set_content_length(r, length); - ap_set_content_type(r, "text/html"); - - /* ** output the HTTP body (HTML Head+Body) ** */ - - ap_rputs(head_formatted, r); - ap_rputs(header_formatted, r); - ap_rputs(body_formatted, r); - ap_rputs(admin_formatted, r); - ap_rputs(footer_formatted, r); - - return OK; -} - -int http_downgrade(request_rec *r, mod_gridsite_cfg *conf) -{ - int i; - char *httpurl, *filetemplate, *cookievalue, *envname_i, - *grst_cred_i, expires_str[APR_RFC822_DATE_LEN]; - apr_uint64_t gridauthcookie; - apr_table_t *env; - apr_time_t expires_time; - apr_file_t *fp; - - /* create random cookie and gridauthcookie file */ - - if (apr_generate_random_bytes((char *) &gridauthcookie, - sizeof(gridauthcookie)) - != APR_SUCCESS) return HTTP_INTERNAL_SERVER_ERROR; - - filetemplate = apr_psprintf(r->pool, "%s/%016llxXXXXXX", - ap_server_root_relative(r->pool, - conf->authcookiesdir), - gridauthcookie); - - if (apr_file_mktemp(&fp, - filetemplate, - APR_CREATE | APR_WRITE | APR_EXCL, - r->pool) - != APR_SUCCESS) return HTTP_INTERNAL_SERVER_ERROR; - - expires_time = apr_time_now() + apr_time_from_sec(300); - /* onetime cookies are valid for only 5 mins! */ - - apr_file_printf(fp, "expires=%lu\ndomain=%s\npath=%s\nonetime=yes\n", - (time_t) apr_time_sec(expires_time), r->hostname, r->uri); - - for (i=0; ; ++i) - { - envname_i = apr_psprintf(r->pool, "GRST_CRED_%d", i); - if (grst_cred_i = (char *) - apr_table_get(r->connection->notes, envname_i)) - { - apr_file_printf(fp, "%s=%s\n", envname_i, grst_cred_i); - } - else break; /* GRST_CRED_i are numbered consecutively */ - } - - if (apr_file_close(fp) != APR_SUCCESS) - { - apr_file_remove(filetemplate, r->pool); /* try to clean up */ - return HTTP_INTERNAL_SERVER_ERROR; - } - - /* send redirection header back to client */ - - cookievalue = rindex(filetemplate, '/'); - if (cookievalue != NULL) ++cookievalue; - else cookievalue = filetemplate; - - apr_rfc822_date(expires_str, expires_time); - - apr_table_add(r->headers_out, - apr_pstrdup(r->pool, "Set-Cookie"), - apr_psprintf(r->pool, - "GRID_AUTH_ONETIME=%s; " - "expires=%s; " - "domain=%s; " - "path=%s", - cookievalue, expires_str, r->hostname, r->uri)); - - httpurl = apr_pstrcat(r->pool, "http://", r->hostname, - ap_escape_uri(r->pool, r->uri), NULL); - apr_table_setn(r->headers_out, apr_pstrdup(r->pool, "Location"), httpurl); - - r->status = HTTP_MOVED_TEMPORARILY; - return OK; -} - -int http_put_method(request_rec *r, mod_gridsite_cfg *conf) -{ - char buf[2048]; - size_t length; - int retcode; - apr_file_t *fp; - - /* *** check if directory creation: PUT /.../ *** */ - - if ((r->unparsed_uri != NULL) && - (r->unparsed_uri[0] != '\0') && - (r->unparsed_uri[strlen(r->unparsed_uri) - 1] == '/')) - { - if (apr_dir_make(r->filename, APR_UREAD | APR_UWRITE | APR_UEXECUTE, - r->pool) != 0) return HTTP_INTERNAL_SERVER_ERROR; - - ap_set_content_length(r, 0); - ap_set_content_type(r, "text/html"); - return OK; - } - - /* *** otherwise assume trying to create a regular file *** */ - - if (apr_file_open(&fp, r->filename, APR_WRITE | APR_CREATE | APR_BUFFERED, - APR_UREAD | APR_UWRITE, r->pool) != 0) return HTTP_INTERNAL_SERVER_ERROR; - -// TODO: need to add Range: support at some point too - - retcode = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK); - if (retcode == OK) - { - if (ap_should_client_block(r)) - while ((length = ap_get_client_block(r, buf, sizeof(buf))) > 0) - if (apr_file_write(fp, buf, &length) != 0) - { - retcode = HTTP_INTERNAL_SERVER_ERROR; - break; - } - - ap_set_content_length(r, 0); - ap_set_content_type(r, "text/html"); - } - - if (apr_file_close(fp) != 0) return HTTP_INTERNAL_SERVER_ERROR; - - return retcode; -} - -int http_delete_method(request_rec *r, mod_gridsite_cfg *conf) -{ - if (remove(r->filename) != 0) return HTTP_FORBIDDEN; - - ap_set_content_length(r, 0); - ap_set_content_type(r, "text/html"); - - return OK; -} - -static int mod_gridsite_dir_handler(request_rec *r, mod_gridsite_cfg *conf) -/* - handler switch for directories -*/ -{ - /* *** is this a write method? only possible if GridSiteAuth on *** */ - - if (conf->auth) - { - if ((r->method_number == M_PUT) && - (conf->methods != NULL) && - (strstr(conf->methods, " PUT " ) != NULL)) - return http_put_method(r, conf); - - if ((r->method_number == M_DELETE) && - (conf->methods != NULL) && - (strstr(conf->methods, " DELETE ") != NULL)) - return http_delete_method(r, conf); - } - - /* *** directory listing? *** */ - - if ((r->method_number == M_GET) && (conf->indexes)) - return html_dir_list(r, conf); /* directory listing */ - - return DECLINED; /* *** nothing to see here, move along *** */ -} - -static int mod_gridsite_nondir_handler(request_rec *r, mod_gridsite_cfg *conf) -/* - one big handler switch for everything other than directories, since we - might be responding to MIME * / * for local PUT, MOVE, COPY and DELETE, - and GET inside ghost directories. -*/ -{ - char *downgradesize; - apr_off_t numericsize; - - /* *** is this a write method or HTTP downgrade? - only possible if GridSiteAuth on *** */ - - if (conf->auth) - { - if ((conf->downgrade) && - ((downgradesize = (char *) apr_table_get(r->headers_in, - "HTTP-Downgrade-Size")) != NULL) && - ((numericsize = (apr_off_t) atoll(downgradesize)) >= 0) && - -// TODO: what if we're pointing at a CGI or some dynamic content??? - (((r->method_number == M_GET) && (r->finfo.size >= numericsize)) - || (r->method_number == M_PUT)) && - - (strcasecmp(apr_table_get(r->subprocess_env, "HTTPS"), "on") == 0)) - return http_downgrade(r, conf); - - if ((r->method_number == M_PUT) && - (conf->methods != NULL) && - (strstr(conf->methods, " PUT " ) != NULL)) - return http_put_method(r, conf); - - if ((r->method_number == M_DELETE) && - (conf->methods != NULL) && - (strstr(conf->methods, " DELETE ") != NULL)) - return http_delete_method(r, conf); - } - - /* *** check if a special ghost admin CGI *** */ - - if (conf->adminfile && conf->adminuri && - (strlen(r->filename) > strlen(conf->adminfile) + 1) && - (strcmp(&(r->filename[strlen(r->filename) - strlen(conf->adminfile)]), - conf->adminfile) == 0) && - (r->filename[strlen(r->filename)-strlen(conf->adminfile)-1] == '/') && - ((r->method_number == M_POST) || - (r->method_number == M_GET))) - { - ap_internal_redirect(conf->adminuri, r); - return OK; - } - - /* *** finally look for .html files that we should format *** */ - - if ((conf->format) && /* conf->format set by GridSiteHtmlFormat on */ - (strlen(r->filename) > 5) && - (strcmp(&(r->filename[strlen(r->filename)-5]), ".html") == 0) && - (r->method_number == M_GET)) return html_format(r, conf); - - return DECLINED; /* *** nothing to see here, move along *** */ -} - -static void recurse4dirlist(char *dirname, time_t *dirs_time, - char *fulluri, int fullurilen, - char *encfulluri, int enclen, - apr_pool_t *pool, char **body, - int recurse_level) -/* try to find DN Lists in dir[] and its subdirs that match the fulluri[] - prefix. add blobs of HTML to body as they are found. */ -{ - char *unencname, modified[99], *oneline, *d_namepath; - DIR *oneDIR; - struct dirent *onedirent; - struct tm mtime_tm; - size_t length; - struct stat statbuf; - - if ((stat(dirname, &statbuf) != 0) || - (!S_ISDIR(statbuf.st_mode)) || - ((oneDIR = opendir(dirname)) == NULL)) return; - - if (statbuf.st_mtime > *dirs_time) *dirs_time = statbuf.st_mtime; - - while ((onedirent = readdir(oneDIR)) != NULL) - { - if (onedirent->d_name[0] == '.') continue; - - d_namepath = apr_psprintf(pool, "%s/%s", dirname, onedirent->d_name); - if (stat(d_namepath, &statbuf) != 0) continue; - - if (S_ISDIR(statbuf.st_mode) && (recurse_level < GRST_RECURS_LIMIT)) - recurse4dirlist(d_namepath, dirs_time, fulluri, - fullurilen, encfulluri, enclen, - pool, body, recurse_level + 1); - else if ((strncmp(onedirent->d_name, encfulluri, enclen) == 0) && - (onedirent->d_name[strlen(onedirent->d_name) - 1] != '~')) - { - unencname = GRSThttpUrlDecode(onedirent->d_name); - - if (strncmp(unencname, fulluri, fullurilen) == 0) - { - - if (statbuf.st_mtime > *dirs_time) - *dirs_time = statbuf.st_mtime; - - localtime_r(&(statbuf.st_mtime), &mtime_tm); - strftime(modified, sizeof(modified), - "%R%e %b %y", - &mtime_tm); - - oneline = apr_psprintf(pool, - "" - "%s" - "%ld%s\n", - &unencname[fullurilen], statbuf.st_size, - statbuf.st_mtime, unencname, - statbuf.st_size, modified); - - *body = apr_pstrcat(pool, *body, oneline, NULL); - } - - free(unencname); /* libgridsite doesnt use pools */ - } - } - - closedir(oneDIR); -} - -static int mod_gridsite_dnlistsuri_dir_handler(request_rec *r, - mod_gridsite_cfg *conf) -/* - virtual DN-list file lister: make all DN lists on the dn-lists - path of this server appear to be in the dn-lists directory itself - (ie where they appear in the DN lists path doesnt matter, as long - as their name matches) -*/ -{ - int enclen, fullurilen, fd; - char *fulluri, *encfulluri, *dn_list_ptr, *dirname, *unencname, - *body, *oneline, *p, *s, - *head_formatted, *header_formatted, *footer_formatted, - *permstr = NULL; - struct stat statbuf; - size_t length; - time_t dirs_time = 0; - GRSTgaclPerm perm = GRST_PERM_NONE; - - if (r->notes != NULL) - permstr = (char *) apr_table_get(r->notes, "GRST_PERM"); - - if (permstr != NULL) sscanf(permstr, "%d", &perm); - - fulluri = apr_psprintf(r->pool, "https://%s%s", - ap_get_server_name(r), conf->dnlistsuri); - fullurilen = strlen(fulluri); - - encfulluri = GRSThttpUrlEncode(fulluri); - enclen = strlen(encfulluri); - - if (conf->dnlists != NULL) p = conf->dnlists; - else p = getenv("GRST_DN_LISTS"); - - if (p == NULL) p = GRST_DN_LISTS; - dn_list_ptr = apr_pstrdup(r->pool, p); - - head_formatted = apr_psprintf(r->pool, - "Directory listing %s\n", r->uri); - - if (conf->format) - { - /* **** try to find a header file in this or parent directories **** */ - - /* first make a buffer big enough to hold path names we want to try */ - fd = -1; - s = malloc(strlen(r->filename) + strlen(conf->headfile) + 1); - strcpy(s, r->filename); - - for (;;) - { - p = rindex(s, '/'); - if (p == NULL) break; /* failed to find one */ - p[1] = '\0'; - strcat(p, conf->headfile); - - fd = open(s, O_RDONLY); - if (fd != -1) break; /* found one */ - - *p = '\0'; - } - - free(s); - - if (fd == -1) /* not found, so set up to output sensible default */ - { - header_formatted = apr_pstrdup(r->pool, ""); - } - else /* found a header file, so set up head and body to surround it */ - { - fstat(fd, &statbuf); - header_formatted = apr_palloc(r->pool, statbuf.st_size + 1); - read(fd, header_formatted, statbuf.st_size); - header_formatted[statbuf.st_size] = '\0'; - close(fd); - } - } - else header_formatted = apr_pstrdup(r->pool, ""); - - body = apr_psprintf(r->pool, - "

    Directory listing %s

    \n", r->uri); - - if ((r->uri)[1] != '\0') - body = apr_pstrcat(r->pool, body, - "\n", - NULL); - - while ((dirname = strsep(&dn_list_ptr, ":")) != NULL) - recurse4dirlist(dirname, &dirs_time, fulluri, fullurilen, - encfulluri, enclen, r->pool, &body, 0); - - if ((stat(r->filename, &statbuf) == 0) && - S_ISDIR(statbuf.st_mode) && - GRSTgaclPermHasWrite(perm)) - { - oneline = apr_psprintf(r->pool, - "\n" - "" - "\n", - r->uri, conf->adminfile); - - body = apr_pstrcat(r->pool, body, oneline, NULL); - } - - body = apr_pstrcat(r->pool, body, "
    [Parent directory]
    \n", NULL); - - free(encfulluri); /* libgridsite doesnt use pools */ - - if (conf->format) - { - /* **** try to find a footer file in this or parent directories **** */ - - /* first make a buffer big enough to hold path names we want to try */ - fd = -1; - s = malloc(strlen(r->filename) + strlen(conf->footfile)); - strcpy(s, r->filename); - - for (;;) - { - p = rindex(s, '/'); - if (p == NULL) break; /* failed to find one */ - - p[1] = '\0'; - strcat(p, conf->footfile); - - fd = open(s, O_RDONLY); - if (fd != -1) break; /* found one */ - - *p = '\0'; - } - - free(s); - - if (fd == -1) /* failed to find a footer, so use standard default */ - { - footer_formatted = apr_pstrdup(r->pool, ""); - } - else /* found a footer, so set up to use it */ - { - fstat(fd, &statbuf); - footer_formatted = apr_palloc(r->pool, statbuf.st_size + 1); - read(fd, footer_formatted, statbuf.st_size); - footer_formatted[statbuf.st_size] = '\0'; - close(fd); - } - } - else footer_formatted = apr_pstrdup(r->pool, ""); - - /* **** can now calculate the Content-Length and output headers **** */ - - length = strlen(head_formatted) + strlen(header_formatted) + - strlen(body) + strlen(footer_formatted); - - ap_set_content_length(r, length); - r->mtime = apr_time_from_sec(dirs_time); - ap_set_last_modified(r); - ap_set_content_type(r, "text/html"); - - /* ** output the HTTP body (HTML Head+Body) ** */ - ap_rputs(head_formatted, r); - ap_rputs(header_formatted, r); - ap_rputs(body, r); - ap_rputs(footer_formatted, r); - - return OK; -} - -static char *recurse4file(char *dir, char *file, apr_pool_t *pool, - int recurse_level) -/* try to find file[] in dir[]. try subdirs if not found. - return full path to first found version or NULL on failure */ -{ - char *fullfilename, *fulldirname; - struct stat statbuf; - DIR *dirDIR; - struct dirent *file_ent; - - /* try to find in current directory */ - - fullfilename = apr_psprintf(pool, "%s/%s", dir, file); - - if (stat(fullfilename, &statbuf) == 0) return fullfilename; - - /* maybe search in subdirectories */ - - if (recurse_level >= GRST_RECURS_LIMIT) return NULL; - - dirDIR = opendir(dir); - - if (dirDIR == NULL) return NULL; - - while ((file_ent = readdir(dirDIR)) != NULL) - { - if (file_ent->d_name[0] == '.') continue; - - fulldirname = apr_psprintf(pool, "%s/%s", dir, file_ent->d_name); - if ((stat(fulldirname, &statbuf) == 0) && - S_ISDIR(statbuf.st_mode) && - ((fullfilename = recurse4file(fulldirname, file, - pool, recurse_level + 1)) != NULL)) - { - closedir(dirDIR); - return fullfilename; - } - } - - closedir(dirDIR); - - return NULL; -} - -static int mod_gridsite_dnlistsuri_handler(request_rec *r, - mod_gridsite_cfg *conf) -/* - virtual DN-list file generator -*/ -{ - int fd; - char *fulluri, *encfulluri, *dn_list_ptr, *filename, *dirname, *p, - *buf; - struct stat statbuf; - - /* *** check if a special ghost admin CGI *** */ - - if (conf->adminfile && conf->adminuri && - (strlen(r->filename) > strlen(conf->adminfile) + 1) && - (strcmp(&(r->filename[strlen(r->filename) - strlen(conf->adminfile)]), - conf->adminfile) == 0) && - (r->filename[strlen(r->filename)-strlen(conf->adminfile)-1] == '/') && - ((r->method_number == M_POST) || - (r->method_number == M_GET))) - { - ap_internal_redirect(conf->adminuri, r); - return OK; - } - - fulluri = apr_psprintf(r->pool, "https://%s%s", - ap_get_server_name(r), r->uri); - - encfulluri = GRSThttpUrlEncode(fulluri); - - if (conf->dnlists != NULL) p = conf->dnlists; - else p = getenv("GRST_DN_LISTS"); - - if (p == NULL) p = GRST_DN_LISTS; - dn_list_ptr = apr_pstrdup(r->pool, p); - - while ((dirname = strsep(&dn_list_ptr, ":")) != NULL) - { - filename = recurse4file(dirname, encfulluri, r->pool, 0); - - if (filename == NULL) continue; - - fd = open(filename, O_RDONLY); - - if (fd == -1) continue; - - fstat(fd, &statbuf); - ap_set_content_length(r, (apr_off_t) statbuf.st_size); - r->mtime = apr_time_from_sec(statbuf.st_mtime); - ap_set_content_type(r, "text/plain"); - ap_set_last_modified(r); - - buf = apr_palloc(r->pool, statbuf.st_size + 1); - read(fd, buf, statbuf.st_size); - buf[statbuf.st_size] = '\0'; - - ap_rputs(buf, r); - - close(fd); - - return OK; - } - - return HTTP_NOT_FOUND; -} - -static void *create_gridsite_dir_config(apr_pool_t *p, char *path) -{ - mod_gridsite_cfg *conf = apr_palloc(p, sizeof(*conf)); - - if (path == NULL) /* set up server defaults */ - { - conf->auth = 0; /* GridSiteAuth on/off */ - conf->envs = 1; /* GridSiteEnvs on/off */ - conf->format = 0; /* GridSiteHtmlFormat on/off */ - conf->indexes = 0; /* GridSiteIndexes on/off */ - conf->indexheader = NULL; /* GridSiteIndexHeader File-value */ - conf->gridsitelink = 1; /* GridSiteLink on/off */ - conf->adminfile = apr_pstrdup(p, GRST_ADMIN_FILE); - /* GridSiteAdminFile File-value */ - conf->adminuri = NULL; /* GridSiteAdminURI URI-value */ - conf->helpuri = NULL; /* GridSiteHelpURI URI-value */ - conf->dnlists = NULL; /* GridSiteDNlists Search-path */ - conf->dnlistsuri = NULL; /* GridSiteDNlistsURI URI-value */ - conf->adminlist = NULL; /* GridSiteAdminList URI-value */ - conf->gsiproxylimit = 1; /* GridSiteGSIProxyLimit number */ - conf->unzip = NULL; /* GridSiteUnzip file-path */ - - conf->methods = apr_pstrdup(p, " GET "); - /* GridSiteMethods methods */ - - conf->editable = apr_pstrdup(p, " txt shtml html htm css js php jsp "); - /* GridSiteEditable types */ - - conf->headfile = apr_pstrdup(p, GRST_HEADFILE); - conf->footfile = apr_pstrdup(p, GRST_FOOTFILE); - /* GridSiteHeadFile and GridSiteFootFile file name */ - - conf->downgrade = 0; /* GridSiteDowngrade on/off */ - conf->authcookiesdir = apr_pstrdup(p, "gridauthcookies"); - /* GridSiteAuthCookiesDir dir-path */ - conf->soap2cgi = 0; /* GridSiteSoap2cgi on/off */ - } - else - { - conf->auth = UNSET; /* GridSiteAuth on/off */ - conf->envs = UNSET; /* GridSiteEnvs on/off */ - conf->format = UNSET; /* GridSiteHtmlFormat on/off */ - conf->indexes = UNSET; /* GridSiteIndexes on/off */ - conf->indexheader = NULL; /* GridSiteIndexHeader File-value */ - conf->gridsitelink = UNSET; /* GridSiteLink on/off */ - conf->adminfile = NULL; /* GridSiteAdminFile File-value */ - conf->adminuri = NULL; /* GridSiteAdminURI URI-value */ - conf->helpuri = NULL; /* GridSiteHelpURI URI-value */ - conf->dnlists = NULL; /* GridSiteDNlists Search-path */ - conf->dnlistsuri = NULL; /* GridSiteDNlistsURI URI-value */ - conf->adminlist = NULL; /* GridSiteAdminList URI-value */ - conf->gsiproxylimit = UNSET; /* GridSiteGSIProxyLimit number */ - conf->unzip = NULL; /* GridSiteUnzip file-path */ - conf->methods = NULL; /* GridSiteMethods methods */ - conf->editable = NULL; /* GridSiteEditable types */ - conf->headfile = NULL; /* GridSiteHeadFile file name */ - conf->footfile = NULL; /* GridSiteFootFile file name */ - conf->downgrade = UNSET; /* GridSiteDowngrade on/off */ - conf->authcookiesdir= NULL; /* GridSiteAuthCookiesDir dir-path */ - conf->soap2cgi = UNSET; /* GridSiteSoap2cgi on/off */ - } - - return conf; -} - -static void *merge_gridsite_dir_config(apr_pool_t *p, void *vserver, - void *vdirect) -/* merge directory with server-wide directory configs */ -{ - mod_gridsite_cfg *conf, *server, *direct; - - server = (mod_gridsite_cfg *) vserver; - direct = (mod_gridsite_cfg *) vdirect; - conf = apr_palloc(p, sizeof(*conf)); - - if (direct->auth != UNSET) conf->auth = direct->auth; - else conf->auth = server->auth; - - if (direct->envs != UNSET) conf->envs = direct->envs; - else conf->envs = server->envs; - - if (direct->format != UNSET) conf->format = direct->format; - else conf->format = server->format; - - if (direct->indexes != UNSET) conf->indexes = direct->indexes; - else conf->indexes = server->indexes; - - if (direct->gridsitelink != UNSET) conf->gridsitelink=direct->gridsitelink; - else conf->gridsitelink=server->gridsitelink; - - if (direct->indexheader != NULL) conf->indexheader = direct->indexheader; - else conf->indexheader = server->indexheader; - - if (direct->adminfile != NULL) conf->adminfile = direct->adminfile; - else conf->adminfile = server->adminfile; - - if (direct->adminuri != NULL) conf->adminuri = direct->adminuri; - else conf->adminuri = server->adminuri; - - if (direct->helpuri != NULL) conf->helpuri = direct->helpuri; - else conf->helpuri = server->helpuri; - - if (direct->dnlists != NULL) conf->dnlists = direct->dnlists; - else conf->dnlists = server->dnlists; - - if (direct->dnlistsuri != NULL) conf->dnlistsuri = direct->dnlistsuri; - else conf->dnlistsuri = server->dnlistsuri; - - if (direct->adminlist != NULL) conf->adminlist = direct->adminlist; - else conf->adminlist = server->adminlist; - - if (direct->gsiproxylimit != UNSET) - conf->gsiproxylimit = direct->gsiproxylimit; - else conf->gsiproxylimit = server->gsiproxylimit; - - if (direct->unzip != NULL) conf->unzip = direct->unzip; - else conf->unzip = server->unzip; - - if (direct->methods != NULL) conf->methods = direct->methods; - else conf->methods = server->methods; - - if (direct->editable != NULL) conf->editable = direct->editable; - else conf->editable = server->editable; - - if (direct->headfile != NULL) conf->headfile = direct->headfile; - else conf->headfile = server->headfile; - - if (direct->footfile != NULL) conf->footfile = direct->footfile; - else conf->footfile = server->footfile; - - if (direct->downgrade != UNSET) conf->downgrade = direct->downgrade; - else conf->downgrade = server->downgrade; - - if (direct->authcookiesdir != NULL) - conf->authcookiesdir = direct->authcookiesdir; - else conf->authcookiesdir = server->authcookiesdir; - - if (direct->soap2cgi != UNSET) conf->soap2cgi = direct->soap2cgi; - else conf->soap2cgi = server->soap2cgi; - - return conf; -} - -static const char *mod_gridsite_take1_cmds(cmd_parms *a, void *cfg, - const char *parm) -{ - int n; - char *p; - - if (strcasecmp(a->cmd->name, "GridSiteAdminFile") == 0) - { - if (index(parm, '/') != NULL) - return "/ not permitted in GridSiteAdminFile"; - - ((mod_gridsite_cfg *) cfg)->adminfile = - apr_pstrdup(a->pool, parm); - } - else if (strcasecmp(a->cmd->name, "GridSiteAdminURI") == 0) - { - if (*parm != '/') return "GridSiteAdminURI must begin with /"; - - ((mod_gridsite_cfg *) cfg)->adminuri = - apr_pstrdup(a->pool, parm); - } - else if (strcasecmp(a->cmd->name, "GridSiteHelpURI") == 0) - { - if (*parm != '/') return "GridSiteHelpURI must begin with /"; - - ((mod_gridsite_cfg *) cfg)->helpuri = - apr_pstrdup(a->pool, parm); - } - else if (strcasecmp(a->cmd->name, "GridSiteDNlists") == 0) - { - ((mod_gridsite_cfg *) cfg)->dnlists = - apr_pstrdup(a->pool, parm); - } - else if (strcasecmp(a->cmd->name, "GridSiteDNlistsURI") == 0) - { - if (*parm != '/') return "GridSiteDNlistsURI must begin with /"; - - if ((*parm != '\0') && (parm[strlen(parm) - 1] == '/')) - ((mod_gridsite_cfg *) cfg)->dnlistsuri = - apr_pstrdup(a->pool, parm); - else - ((mod_gridsite_cfg *) cfg)->dnlistsuri = - apr_pstrcat(a->pool, parm, "/", NULL); - } - else if (strcasecmp(a->cmd->name, "GridSiteAdminList") == 0) - { - ((mod_gridsite_cfg *) cfg)->adminlist = - apr_pstrdup(a->pool, parm); - } - else if (strcasecmp(a->cmd->name, "GridSiteGSIProxyLimit") == 0) - { - n = -1; - - if ((sscanf(parm, "%d", &n) == 1) && (n >= 0)) - ((mod_gridsite_cfg *) cfg)->gsiproxylimit = n; - else return "GridSiteGSIProxyLimit must be a number >= 0"; - } - else if (strcasecmp(a->cmd->name, "GridSiteUnzip") == 0) - { - if (*parm != '/') return "GridSiteUnzip must begin with /"; - - ((mod_gridsite_cfg *) cfg)->unzip = - apr_pstrdup(a->pool, parm); - } - else if (strcasecmp(a->cmd->name, "GridSiteMethods") == 0) - { - ((mod_gridsite_cfg *) cfg)->methods = - apr_psprintf(a->pool, " %s ", parm); - - for (p = ((mod_gridsite_cfg *) cfg)->methods; - *p != '\0'; - ++p) if (*p == '\t') *p = ' '; - } - else if (strcasecmp(a->cmd->name, "GridSiteEditable") == 0) - { - ((mod_gridsite_cfg *) cfg)->editable = - apr_psprintf(a->pool, " %s ", parm); - - for (p = ((mod_gridsite_cfg *) cfg)->editable; - *p != '\0'; - ++p) if (*p == '\t') *p = ' '; - } - else if (strcasecmp(a->cmd->name, "GridSiteHeadFile") == 0) - { - ((mod_gridsite_cfg *) cfg)->headfile = - apr_pstrdup(a->pool, parm); - } - else if (strcasecmp(a->cmd->name, "GridSiteFootFile") == 0) - { - ((mod_gridsite_cfg *) cfg)->footfile = - apr_pstrdup(a->pool, parm); - } - else if (strcasecmp(a->cmd->name, "GridSiteIndexHeader") == 0) - { - if (index(parm, '/') != NULL) - return "/ not permitted in GridSiteIndexHeader"; - - ((mod_gridsite_cfg *) cfg)->indexheader = - apr_pstrdup(a->pool, parm); - } - else if (strcasecmp(a->cmd->name, "GridSiteAuthCookiesDir") == 0) - { - if (index(parm, '/') != NULL) - return "/ not permitted in GridSiteAuthCookiesDir"; - - ((mod_gridsite_cfg *) cfg)->authcookiesdir = - apr_pstrdup(a->pool, parm); - } - - return NULL; -} - -static const char *mod_gridsite_flag_cmds(cmd_parms *a, void *cfg, - int flag) -{ - if (strcasecmp(a->cmd->name, "GridSiteAuth") == 0) - { - ((mod_gridsite_cfg *) cfg)->auth = flag; - } - else if (strcasecmp(a->cmd->name, "GridSiteEnvs") == 0) - { - ((mod_gridsite_cfg *) cfg)->envs = flag; - } - else if (strcasecmp(a->cmd->name, "GridSiteHtmlFormat") == 0) - { - ((mod_gridsite_cfg *) cfg)->format = flag; - } - else if (strcasecmp(a->cmd->name, "GridSiteIndexes") == 0) - { - ((mod_gridsite_cfg *) cfg)->indexes = flag; - } - else if (strcasecmp(a->cmd->name, "GridSiteLink") == 0) - { - ((mod_gridsite_cfg *) cfg)->gridsitelink = flag; - } - else if (strcasecmp(a->cmd->name, "GridSiteDowngrade") == 0) - { -// TODO: return error if try this on non-HTTPS virtual server - - ((mod_gridsite_cfg *) cfg)->downgrade = flag; - } - else if (strcasecmp(a->cmd->name, "GridSiteSoap2cgi") == 0) - { - ((mod_gridsite_cfg *) cfg)->soap2cgi = flag; - } - - return NULL; -} - -static const command_rec mod_gridsite_cmds[] = -{ -// TODO: need to check and document valid contexts for each command! - - AP_INIT_FLAG("GridSiteAuth", mod_gridsite_flag_cmds, - NULL, OR_FILEINFO, "on or off"), - AP_INIT_FLAG("GridSiteEnvs", mod_gridsite_flag_cmds, - NULL, OR_FILEINFO, "on or off"), - AP_INIT_FLAG("GridSiteHtmlFormat", mod_gridsite_flag_cmds, - NULL, OR_FILEINFO, "on or off"), - AP_INIT_FLAG("GridSiteIndexes", mod_gridsite_flag_cmds, - NULL, OR_FILEINFO, "on or off"), - AP_INIT_FLAG("GridSiteLink", mod_gridsite_flag_cmds, - NULL, OR_FILEINFO, "on or off"), - - AP_INIT_TAKE1("GridSiteAdminFile", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "Ghost per-directory admin CGI"), - AP_INIT_TAKE1("GridSiteAdminURI", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "URI of real gridsite-admin.cgi"), - AP_INIT_TAKE1("GridSiteHelpURI", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "URI of Website Help pages"), - AP_INIT_TAKE1("GridSiteDNlists", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "DN Lists directories search path"), - AP_INIT_TAKE1("GridSiteDNlistsURI", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "URI of published DN lists"), - AP_INIT_TAKE1("GridSiteAdminList", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "URI of admin DN List"), - AP_INIT_TAKE1("GridSiteGSIProxyLimit", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "Max level of GSI proxy validity"), - AP_INIT_TAKE1("GridSiteUnzip", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "Absolute path to unzip command"), - - AP_INIT_RAW_ARGS("GridSiteMethods", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "permitted HTTP methods"), - AP_INIT_RAW_ARGS("GridSiteEditable", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "editable file extensions"), - AP_INIT_TAKE1("GridSiteHeadFile", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "filename of HTML header"), - AP_INIT_TAKE1("GridSiteFootFile", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "filename of HTML footer"), - AP_INIT_TAKE1("GridSiteIndexHeader", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "filename of directory header"), - - AP_INIT_FLAG("GridSiteDowngrade", mod_gridsite_flag_cmds, - NULL, OR_FILEINFO, "on or off"), - AP_INIT_TAKE1("GridSiteAuthCookiesDir", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "directory with Grid Auth Cookies"), - - AP_INIT_FLAG("GridSiteSoap2cgi", mod_gridsite_flag_cmds, - NULL, OR_FILEINFO, "on or off"), - {NULL} -}; - -static int mod_gridsite_first_fixups(request_rec *r) -{ - mod_gridsite_cfg *conf; - - if (r->finfo.filetype != APR_DIR) return DECLINED; - - conf = (mod_gridsite_cfg *) - ap_get_module_config(r->per_dir_config, &gridsite_module); - - /* we handle DN Lists as regular files, even if they also match - directory names */ - - if ((conf != NULL) && - (conf->dnlistsuri != NULL) && - (strncmp(r->uri, conf->dnlistsuri, strlen(conf->dnlistsuri)) == 0) && - (strcmp(r->uri, conf->dnlistsuri) != 0)) - { - r->finfo.filetype = APR_REG; - } - - return DECLINED; -} - -static int mod_gridsite_perm_handler(request_rec *r) -/* - Do authentication/authorization here rather than in the normal module - auth functions since the results of mod_ssl are available. - - We also publish environment variables here if requested by GridSiteEnv. -*/ -{ - int retcode = DECLINED, i, n; - char *dn, *p, envname[14], *grst_cred_0 = NULL, *dir_path, - *remotehost, s[99], *grst_cred_i, *file, *cookies, - *gridauthonetime, *cookiefile, oneline[1025], *key_i; - const char *content_type; - time_t now, notbefore, notafter; - apr_table_t *env; - apr_finfo_t cookiefile_info; - apr_file_t *fp; - GRSTgaclCred *cred = NULL, *cred_0 = NULL; - GRSTgaclUser *user = NULL; - GRSTgaclPerm perm = GRST_PERM_NONE; - GRSTgaclAcl *acl = NULL; - mod_gridsite_cfg *cfg; - - cfg = (mod_gridsite_cfg *) - ap_get_module_config(r->per_dir_config, &gridsite_module); - - if (cfg == NULL) return DECLINED; - - if ((cfg->auth == 0) && - (cfg->envs == 0)) - return DECLINED; /* if not turned on, look invisible */ - - env = r->subprocess_env; - - if ((p = (char *) apr_table_get(r->headers_in, "Cookie")) != NULL) - { - cookies = apr_pstrcat(r->pool, " ", p, NULL); - gridauthonetime = strstr(cookies, " GRID_AUTH_ONETIME="); - - if (gridauthonetime != NULL) - { - for (p = &gridauthonetime[19]; (*p != '\0') && (*p != ';'); ++p) - if (!isalnum(*p)) *p = '_'; - - cookiefile = apr_psprintf(r->pool, "%s/%s", - ap_server_root_relative(r->pool, - cfg->authcookiesdir), - &gridauthonetime[19]); - - if ((apr_stat(&cookiefile_info , cookiefile, - APR_FINFO_TYPE, r->pool) == APR_SUCCESS) && - (cookiefile_info.filetype == APR_REG) && - (apr_file_open(&fp, cookiefile, APR_READ, 0, r->pool) - == APR_SUCCESS)) - { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "Open Grid Auth Cookie file %s", cookiefile); - - while (apr_file_gets(oneline, - sizeof(oneline), fp) == APR_SUCCESS) - { - p = index(oneline, '\n'); - if (p != NULL) *p = '\0'; - - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "%s: %s", cookiefile, oneline); - - if ((strncmp(oneline, "expires=", 8) == 0) && - (apr_time_from_sec(atoll(&oneline[8])) < - apr_time_now())) - break; - else if ((strncmp(oneline, "domain=", 7) == 0) && - (strcmp(&oneline[7], r->hostname) != 0)) - break; /* exact needed in the version */ - else if ((strncmp(oneline, "path=", 5) == 0) && - (strcmp(&oneline[5], r->uri) != 0)) - break; - else if (strncmp(oneline, "onetime=yes", 11) == 0) - apr_file_remove(cookiefile, r->pool); - else if (strncmp(oneline, "GRST_CRED_", 10) == 0) - { - grst_cred_i = index(oneline, '='); - if (grst_cred_i == NULL) continue; - *grst_cred_i = '\0'; - ++grst_cred_i; - - i = atoi(&oneline[10]); - cred = GRSTx509CompactToCred(grst_cred_i); - - if (cred == NULL) continue; - - if ((i == 0) && (user == NULL)) - { - if (GRSTgaclCredGetDelegation(cred) - <= ((mod_gridsite_cfg *) cfg)->gsiproxylimit) - { - user = GRSTgaclUserNew(cred); - - ap_log_error(APLOG_MARK, APLOG_DEBUG, - 0, r->server, - "Using identity %s from " - "GRID_AUTH_ONETIME", - grst_cred_i); - - if (((mod_gridsite_cfg *) cfg)->envs) - apr_table_setn(env, oneline, grst_cred_i); - } - } - else if ((i > 0) && (user != NULL)) - { - GRSTgaclUserAddCred(user, cred); - - if (((mod_gridsite_cfg *) cfg)->envs) - apr_table_set(env,oneline,grst_cred_i); - } - } - } - - apr_file_close(fp); - } - } - } - - /* do we need/have per-connection (SSL) cred variable(s)? */ - - if ((user == NULL) && - (r->connection->notes != NULL) && - ((grst_cred_0 = (char *) - apr_table_get(r->connection->notes, "GRST_CRED_0")) != NULL)) - { - if (((mod_gridsite_cfg *) cfg)->envs) - apr_table_setn(env, "GRST_CRED_0", grst_cred_0); - - cred_0 = GRSTx509CompactToCred(grst_cred_0); - if ((cred_0 != NULL) && - (GRSTgaclCredGetDelegation(cred_0) - <= ((mod_gridsite_cfg *) cfg)->gsiproxylimit)) - { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "Using identity %s from SSL/TLS", grst_cred_0); - - user = GRSTgaclUserNew(cred_0); - - /* check for VOMS GRST_CRED_i too */ - - for (i=1; ; ++i) - { - snprintf(envname, sizeof(envname), "GRST_CRED_%d", i); - if (grst_cred_i = (char *) - apr_table_get(r->connection->notes,envname)) - { - if (((mod_gridsite_cfg *) cfg)->envs) - apr_table_setn(env, - apr_pstrdup(r->pool, envname), - grst_cred_i); - - if (cred = GRSTx509CompactToCred(grst_cred_i)) - GRSTgaclUserAddCred(user, cred); - } - else break; /* GRST_CRED_i are numbered consecutively */ - } - } - } - - if ((user != NULL) && ((mod_gridsite_cfg *) cfg)->dnlists) - GRSTgaclUserSetDNlists(user, ((mod_gridsite_cfg *) cfg)->dnlists); - - /* this checks for NULL arguments itself */ - if (GRSTgaclDNlistHasUser(((mod_gridsite_cfg *) cfg)->adminlist, user)) - perm = GRST_PERM_ALL; - else - { - remotehost = (char *) ap_get_remote_host(r->connection, - r->per_dir_config, REMOTE_DOUBLE_REV, NULL); - if ((remotehost != NULL) && (*remotehost != '\0')) - { - cred = GRSTgaclCredNew("dns"); - GRSTgaclCredAddValue(cred, "hostname", remotehost); - - if (user == NULL) user = GRSTgaclUserNew(cred); - else GRSTgaclUserAddCred(user, cred); - } - - acl = GRSTgaclAclLoadforFile(r->filename); - if (acl != NULL) perm = GRSTgaclAclTestUser(acl, user); - } - - apr_table_setn(r->notes, "GRST_PERM", apr_psprintf(r->pool, "%d", perm)); - - if (((mod_gridsite_cfg *) cfg)->envs) - { - apr_table_setn(env, "GRST_PERM", apr_psprintf(r->pool, "%d", perm)); - - if (((dir_path = apr_pstrdup(r->pool, r->filename)) != NULL) && - ((p = rindex(dir_path, '/')) != NULL)) - { - *p = '\0'; - apr_table_setn(env, "GRST_DIR_PATH", dir_path); - } - - if (((mod_gridsite_cfg *) cfg)->helpuri != NULL) - apr_table_setn(env, "GRST_HELP_URI", - ((mod_gridsite_cfg *) cfg)->helpuri); - - if (((mod_gridsite_cfg *) cfg)->adminfile != NULL) - apr_table_setn(env, "GRST_ADMIN_FILE", - ((mod_gridsite_cfg *) cfg)->adminfile); - - if (((mod_gridsite_cfg *) cfg)->editable != NULL) - apr_table_setn(env, "GRST_EDITABLE", - ((mod_gridsite_cfg *) cfg)->editable); - - if (((mod_gridsite_cfg *) cfg)->headfile != NULL) - apr_table_setn(env, "GRST_HEAD_FILE", - ((mod_gridsite_cfg *) cfg)->headfile); - - if (((mod_gridsite_cfg *) cfg)->footfile != NULL) - apr_table_setn(env, "GRST_FOOT_FILE", - ((mod_gridsite_cfg *) cfg)->footfile); - - if (((mod_gridsite_cfg *) cfg)->dnlists != NULL) - apr_table_setn(env, "GRST_DN_LISTS", - ((mod_gridsite_cfg *) cfg)->dnlists); - - if (((mod_gridsite_cfg *) cfg)->dnlistsuri != NULL) - apr_table_setn(env, "GRST_DN_LISTS_URI", - ((mod_gridsite_cfg *) cfg)->dnlistsuri); - - if (((mod_gridsite_cfg *) cfg)->adminlist != NULL) - apr_table_setn(env, "GRST_ADMIN_LIST", - ((mod_gridsite_cfg *) cfg)->adminlist); - - apr_table_setn(env, "GRST_GSIPROXY_LIMIT", - apr_psprintf(r->pool, "%d", - ((mod_gridsite_cfg *)cfg)->gsiproxylimit)); - - if (((mod_gridsite_cfg *) cfg)->unzip != NULL) - apr_table_setn(env, "GRST_UNZIP", - ((mod_gridsite_cfg *) cfg)->unzip); - - if (!(((mod_gridsite_cfg *) cfg)->gridsitelink)) - apr_table_setn(env, "GRST_NO_LINK", "1"); - } - - if (((mod_gridsite_cfg *) cfg)->auth) - { - /* *** Check HTTP method to decide which perm bits to check *** */ - - if (r->filename != NULL) - { - file = rindex(r->filename, '/'); - if (file != NULL) ++file; - else file = r->filename; - } - else file = NULL; - - content_type = r->content_type; - if ((content_type != NULL) && - (strcmp(content_type, DIR_MAGIC_TYPE) == 0) && - (((mod_gridsite_cfg *) cfg)->dnlistsuri != NULL) && - (strncmp(r->uri, - ((mod_gridsite_cfg *) cfg)->dnlistsuri, - strlen(((mod_gridsite_cfg *) cfg)->dnlistsuri)) == 0) && - (strlen(r->uri) > strlen(((mod_gridsite_cfg *) cfg)->dnlistsuri))) - content_type = "text/html"; - - if ( GRSTgaclPermHasNone(perm) || - - /* first two M_GET conditions make the subtle distinction - between .../ that maps to .../index.html (governed by - Read perm) or to dir list (governed by List perm); - third M_GET condition deals with typeless CGI requests */ - - ((r->method_number == M_GET) && - !GRSTgaclPermHasRead(perm) && - (content_type != NULL) && - (strcmp(content_type, DIR_MAGIC_TYPE) != 0)) || - - ((r->method_number == M_GET) && - !GRSTgaclPermHasList(perm) && - (content_type != NULL) && - (strcmp(content_type, DIR_MAGIC_TYPE) == 0)) || - - ((r->method_number == M_GET) && - !GRSTgaclPermHasRead(perm) && - (content_type == NULL)) || - - ((r->method_number == M_POST) && !GRSTgaclPermHasRead(perm) ) || - - (((r->method_number == M_PUT) || (r->method_number == M_DELETE)) && - !GRSTgaclPermHasWrite(perm) && - ((file == NULL) || (strcmp(file, GRST_ACL_FILE) != 0)) ) || - - (((r->method_number == M_PUT) || (r->method_number == M_DELETE)) && - !GRSTgaclPermHasAdmin(perm) && - (file != NULL) && - (strcmp(file, GRST_ACL_FILE) == 0) ) ) retcode = HTTP_FORBIDDEN; - } - - return retcode; -} - -int GRST_X509_check_issued_wrapper(X509_STORE_CTX *ctx,X509 *x,X509 *issuer) -/* We change the default callback to use our wrapper and discard errors - due to GSI proxy chains (ie where users certs act as CAs) */ -{ - int ret; - ret = X509_check_issued(issuer, x); - if (ret == X509_V_OK) - return 1; - - /* Non self-signed certs without signing are ok if they passed - the other checks inside X509_check_issued. Is this enough? */ - if ((ret == X509_V_ERR_KEYUSAGE_NO_CERTSIGN) && - (X509_NAME_cmp(X509_get_subject_name(issuer), - X509_get_subject_name(x)) != 0)) return 1; - - /* If we haven't asked for issuer errors don't set ctx */ - if (!(ctx->flags & X509_V_FLAG_CB_ISSUER_CHECK)) return 0; - - ctx->error = ret; - ctx->current_cert = x; - ctx->current_issuer = issuer; - return ctx->verify_cb(0, ctx); -} - -/* Later OpenSSL versions add a second pointer ... */ -int GRST_verify_cert_wrapper(X509_STORE_CTX *ctx, void *p) - -/* Earlier ones have a single argument ... */ -// int GRST_verify_cert_wrapper(X509_STORE_CTX *ctx) - -/* Before 0.9.7 we cannot change the check_issued callback directly in - the X509_STORE, so we must insert it in another callback that gets - called early enough */ -{ - ctx->check_issued = GRST_X509_check_issued_wrapper; - - return X509_verify_cert(ctx); -} - -int GRST_callback_SSLVerify_wrapper(int ok, X509_STORE_CTX *ctx) -{ - SSL *ssl = (SSL *) X509_STORE_CTX_get_app_data(ctx); - conn_rec *conn = (conn_rec *) SSL_get_app_data(ssl); - server_rec *s = conn->base_server; - SSLConnRec *sslconn = - (SSLConnRec *) ap_get_module_config(conn->conn_config, &ssl_module); - int errnum = X509_STORE_CTX_get_error(ctx); - int errdepth = X509_STORE_CTX_get_error_depth(ctx); - int returned_ok; - int first_non_ca; - - /* - * GSI Proxy user-cert-as-CA handling: - * we skip Invalid CA errors at this stage, since we will check this - * again at errdepth=0 for the full chain using GRSTx509CheckChain - */ - if (errnum == X509_V_ERR_INVALID_CA) - { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, - "Skip Invalid CA error in case a GSI Proxy"); - - sslconn->verify_error = NULL; - ok = TRUE; - errnum = X509_V_OK; - X509_STORE_CTX_set_error(ctx, errnum); - } - - /* - * New style GSI Proxy handling, with critical ProxyCertInfo - * extension: we use GRSTx509KnownCriticalExts() to check this - */ -#ifndef X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION -#define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 -#endif - if (errnum == X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION) - { - if (GRSTx509KnownCriticalExts(X509_STORE_CTX_get_current_cert(ctx)) - == GRST_RET_OK) - { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, - "GRSTx509KnownCriticalExts() accepts previously " - "Unhandled Critical Extension (GSI Proxy?)"); - - sslconn->verify_error = NULL; - ok = TRUE; - errnum = X509_V_OK; - X509_STORE_CTX_set_error(ctx, errnum); - } - } - - returned_ok = ssl_callback_SSLVerify(ok, ctx); - - /* in case ssl_callback_SSLVerify changed it */ - errnum = X509_STORE_CTX_get_error(ctx); - - if ((errdepth == 0) && (errnum == X509_V_OK)) - /* - * We've now got the last certificate - the identity being used for - * this connection. At this point we check the whole chain for valid - * CAs or, failing that, GSI-proxy validity using GRSTx509CheckChain. - */ - { - errnum = GRSTx509CheckChain(&first_non_ca, ctx); - - if (errnum != X509_V_OK) - { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, - "Invalid certificate chain reported by " - "GRSTx509CheckChain()"); - - sslconn->verify_error = X509_verify_cert_error_string(errnum); - ok = FALSE; - } - else - { - int i, lastcred; - STACK_OF(X509) *peer_certs; - const int maxcreds = 99; - const size_t credlen = 1024; - char creds[maxcreds][credlen+1], envname[14]; - - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "Valid certificate" - " chain reported by GRSTx509CheckChain()"); - - /* - * Always put result of GRSTx509CompactCreds() into environment - */ - if (peer_certs = (STACK_OF(X509) *) X509_STORE_CTX_get_chain(ctx)) - { - if (GRSTx509CompactCreds(&lastcred, maxcreds, credlen, - (char *) creds, peer_certs, GRST_VOMS_DIR) == GRST_RET_OK) - { - for (i=0; i <= lastcred; ++i) - { - apr_table_setn(conn->notes, - apr_psprintf(conn->pool, "GRST_CRED_%d", i), - apr_pstrdup(conn->pool, creds[i])); - - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, - "store GRST_CRED_%d=%s", i, creds[i]); - } - } - /* free remaining dup'd certs? */ - } - } - } - - return returned_ok; -} - -static int mod_gridsite_server_post_config(apr_pool_t *pPool, - apr_pool_t *pLog, apr_pool_t *pTemp, server_rec *main_server) -{ - SSL_CTX *ctx; - SSLSrvConfigRec *sc; - server_rec *this_server; - - ap_add_version_component(pPool, - apr_psprintf(pPool, "mod_gridsite/%s", VERSION)); - - for (this_server = main_server; - this_server != NULL; - this_server = this_server->next) - { - sc = ap_get_module_config(this_server->module_config, &ssl_module); - - if ((sc != NULL) && - (sc->enabled) && - (sc->server != NULL) && - (sc->server->ssl_ctx != NULL)) - { - ctx = sc->server->ssl_ctx; - - /* in 0.9.7 we could set the issuer-checking callback directly */ -// ctx->cert_store->check_issued = GRST_X509_check_issued_wrapper; - - /* but in case 0.9.6 we do it indirectly with another wrapper */ - SSL_CTX_set_cert_verify_callback(ctx, - GRST_verify_cert_wrapper, - (void *) NULL); - - /* whatever version, we can set the SSLVerify wrapper properly */ - SSL_CTX_set_verify(ctx, ctx->verify_mode, - GRST_callback_SSLVerify_wrapper); - - if (main_server->loglevel >= APLOG_DEBUG) - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, main_server, - "Set mod_ssl verify callbacks to GridSite wrappers"); - } - } - - return OK; -} - -static void mod_gridsite_child_init(apr_pool_t *pPool, server_rec *pServer) -{ - GRSTgaclInit(); -} - -static int mod_gridsite_handler(request_rec *r) -{ - mod_gridsite_cfg *conf; - - conf = (mod_gridsite_cfg *) - ap_get_module_config(r->per_dir_config, &gridsite_module); - - if ((conf->dnlistsuri != NULL) && - (strncmp(r->uri, conf->dnlistsuri, strlen(conf->dnlistsuri)) == 0)) - { - if (strcmp(r->uri, conf->dnlistsuri) == 0) - return mod_gridsite_dnlistsuri_dir_handler(r, conf); - - return mod_gridsite_dnlistsuri_handler(r, conf); - } - - if (strcmp(r->handler, DIR_MAGIC_TYPE) == 0) - return mod_gridsite_dir_handler(r, conf); - - return mod_gridsite_nondir_handler(r, conf); -} - -static void register_hooks(apr_pool_t *p) -{ - /* set up the Soap2cgi input and output filters */ - - ap_hook_insert_filter(mod_gridsite_soap2cgi_insert, NULL, NULL, - APR_HOOK_MIDDLE); - - ap_register_output_filter(Soap2cgiFilterName, mod_gridsite_soap2cgi_out, - NULL, AP_FTYPE_RESOURCE); - -// ap_register_input_filter(Soap2cgiFilterName, mod_gridsite_soap2cgi_in, -// NULL, AP_FTYPE_RESOURCE); - - /* config and handler stuff */ - - ap_hook_post_config(mod_gridsite_server_post_config, NULL, NULL, - APR_HOOK_LAST); - ap_hook_child_init(mod_gridsite_child_init, NULL, NULL, APR_HOOK_MIDDLE); - - ap_hook_fixups(mod_gridsite_first_fixups,NULL,NULL,APR_HOOK_FIRST); - - ap_hook_fixups(mod_gridsite_perm_handler,NULL,NULL,APR_HOOK_REALLY_LAST); - - ap_hook_handler(mod_gridsite_handler, NULL, NULL, APR_HOOK_FIRST); -} - -module AP_MODULE_DECLARE_DATA gridsite_module = -{ - STANDARD20_MODULE_STUFF, - create_gridsite_dir_config, /* dir config creater */ - merge_gridsite_dir_config, /* dir merger */ - NULL, /* server config */ - NULL, /* merge server config */ - mod_gridsite_cmds, /* command apr_table_t */ - register_hooks /* register hooks */ -}; diff --git a/org.gridsite.core/src/mod_ssl-private.h b/org.gridsite.core/src/mod_ssl-private.h deleted file mode 100644 index 7b0b784..0000000 --- a/org.gridsite.core/src/mod_ssl-private.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - Copyright (c) 2003-4, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - - Portions of this code are derived from Apache mod_ssl, and are covered - by the Apache Software License: - - * Copyright 2001-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*------------------------------------------------------------------* - * This program is part of GridSite: http://www.gridsite.org/ * - *------------------------------------------------------------------*/ - - -/* - * After 2.0.49, Apache mod_ssl has most of the mod_ssl structures defined - * in ssl_private.h, which is not installed along with httpd-devel (eg in - * the FC2 RPM.) This include file provides SIMPLIFIED structures for use - * by mod_gridsite: for example, pointers to unused structures are replaced - * by void * and some of the structures are truncated when only the early - * members are used. - * - * CLEARLY, THIS WILL BREAK IF THERE ARE MAJOR CHANGES TO ssl_private.h!!! - */ - -#include - -typedef enum { - SSL_SHUTDOWN_TYPE_UNSET, - SSL_SHUTDOWN_TYPE_STANDARD, - SSL_SHUTDOWN_TYPE_UNCLEAN, - SSL_SHUTDOWN_TYPE_ACCURATE -} ssl_shutdown_type_e; - -typedef struct { - SSL *ssl; - const char *client_dn; - X509 *client_cert; - ssl_shutdown_type_e shutdown_type; - const char *verify_info; - const char *verify_error; - int verify_depth; - int is_proxy; - int disabled; - int non_ssl_request; -} SSLConnRec; - -typedef struct { - void *sc; /* pointer back to server config */ - SSL_CTX *ssl_ctx; -} modssl_ctx_t; - -typedef struct { - void *mc; - unsigned int enabled; - unsigned int proxy_enabled; - const char *vhost_id; - int vhost_id_len; - int session_cache_timeout; - modssl_ctx_t *server; - modssl_ctx_t *proxy; -} SSLSrvConfigRec; - -extern module AP_MODULE_DECLARE_DATA ssl_module; diff --git a/org.gridsite.core/src/proxyput-example.c b/org.gridsite.core/src/proxyput-example.c deleted file mode 100644 index f0fe834..0000000 --- a/org.gridsite.core/src/proxyput-example.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - Copyright (c) 2002-4, Andrew McNab, University of Manchester - All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - o Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - o Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - Change the hard-coded defaults below to your set up. -*/ - -#define LOCALPROXY "/tmp/x509up" -#define DELEGATIONURL "https://testing.hep.man.ac.uk/gridsite-delegation.cgi" -#define CAPATH "/etc/grid-security/certificates" -#define DELEGATIONID "1234567890" -#define EXPIREMINUTES 60 - -#ifndef VERSION -#define VERSION "0.0.0" -#endif - -#define _GNU_SOURCE - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "gridsite.h" - -#include "soapH.h" -#include "delegation.nsmap" - -int main(int argc, char *argv[]) -{ - char *reqtxt, *certtxt; - struct ns__putProxyResponse *unused; - struct soap soap_get, soap_put; - - ERR_load_crypto_strings (); - OpenSSL_add_all_algorithms(); - - soap_init(&soap_get); - - if (soap_ssl_client_context(&soap_get, - SOAP_SSL_DEFAULT, - LOCALPROXY, - "", - NULL, - CAPATH, - NULL)) - { - soap_print_fault(&soap_get, stderr); - return 1; - } - - soap_call_ns__getProxyReq(&soap_get, - DELEGATIONURL, /* HTTPS url of service */ - "", /* no password on proxy */ - DELEGATIONID, - &reqtxt); - - if (soap_get.error) - { - soap_print_fault(&soap_get, stderr); - return 1; - } - - if (GRSTx509MakeProxyCert(&certtxt, stderr, reqtxt, - LOCALPROXY, LOCALPROXY, EXPIREMINUTES) - != GRST_RET_OK) - { - return 1; - } - - soap_init(&soap_put); - - if (soap_ssl_client_context(&soap_put, - SOAP_SSL_DEFAULT, - LOCALPROXY, - "", - NULL, - CAPATH, - NULL)) - { - soap_print_fault(&soap_put, stderr); - return 1; - } - - soap_call_ns__putProxy(&soap_put, DELEGATIONURL, "", DELEGATIONID, - certtxt, unused); - if (soap_put.error) - { - soap_print_fault(&soap_put, stderr); - return 1; - } - - return 0; -} - diff --git a/org.gridsite.core/src/real-gridsite-admin.cgi b/org.gridsite.core/src/real-gridsite-admin.cgi deleted file mode 100644 index 74a00102428cd5c64342d721f34b0f96e422672f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 96256 zcmd4)3wTu3)d!3pLeK%DiHaJnw$X}$S5#CKFA*3;MH#s$UN9g84v|YFGm4i;a1tek zXslGJwTe|+ytL8^Ev-_cQbB8LR9d4=-$tA2o=$AXzIioOYQEoZt-a5j$whho&;NU# z4?Wql_Fil4wbxpE?aSHcoE6c@=MEY)$aDYlyultJ^Jso#4AQ5gS~kWj@pkh@dWU)6 zLh5-e8&d-uT+R5+YY47Ycov3ACEwY_=@eKUZdRQ0bO5(Z)7uy}fH4GR39gmCkPQ}%P>l9q!eFM_OT}W5s8jb4;n-@oV46cQ^F0y${E)D%&hTmsem^Pk< zYcj4YaV^2M0M`^;7vj1J*PXZ;a3yff#C0UDp}20r#eX;BS}ecxPdSnr3(rP+zWqHG zX&tU>aNU7xFI)%W;=jvr9gXWST(slCxaQzmfvX-D|Ev~)_;5q;o|5a$>U1rm7Aw2?DqlJ4XC-3HY z>%X5L`49!P_cS=|X28@h;WWy(17=?(yeF;tCVS$;3z z<$%*LCSmHFF&l}uxA#fUp{Rcq%Bdfg{~Y*h0n?`mKMr_3;1ezUCg9D08FyIzSHRl= z(_Byb0}y{2)I%h zi~lsrHv=AT;bTy~o#jZ$@7{d0A8>`0uL}4E@H~ru64GwK#kPDb=pqm0M`E`8AejKERgOp}zHi z&$IAN42KYW;jw>vG3-vDt{J&P-VbJp` zz|=F#4+Fdw@BD)Rc)l$k3D^L3{pn1=-GIAneHTEU$Pe=)9OEhfnShG{ z-(um_*Dz<1N>Eh z$5=S8mwmS&zxLPJ@#cQeuLb_EEdGAL-w^VL&rrS|_VPXe zJkqYssPDf49vgz!0-gl;I$M7|1Yv#P2^ zT$PRSW}ZCyw6crOxhPsTFHz~0O}rex&!6B`U0b#!vDk}V8Y^2o?__WM`BTa&6Y(mq zY~hlHaRKKqD=(KHbK}bv31aNR=;dW|s;U+)SdxX~H&!azlJXnK_4+xB66IR!g7SD- zRpOe8^11P{C36;+XNibgHXl`a=S;i!gtGH5o*q3fI<>5-Jnog9H+jnVb0(KfIrrRY z(dlK=&lx{CT9)Ovu&OFizD(Ik(^yIQ@_5jMgO;`k3%h9B= z1&fz1DXWUlSr#uVqjKghyRkC9w6}id%$rwMz9hcvMlTkZL#K4)H8Y}vx=k$EBV1RD*>ZF$xTOP7>m%^cDYgjb?z z)2B?0mQ9#G6P2J%%a$!&RyMD^GVW_JBq$TrJ9)~e#h|)Aiec%LSoGp)(%4W z!nI&2+T|~#ffo9!QV(vT(WRps7lCEnYf0{jZU3fR=I59 z5-VI)+5F1>B%kZgS-2$2;QI1q3+G$CL}yNiK<7`nSeiH&qAZ*{XOZGASR7xtxE!KZ zi2g;dIqH|DW|c%8i;|Q)mo=IMuL~Ixw(D&q=@ik6r%%1SY%Xe}wQnrD`22~=FE(Rp zY|6B#2#WkFao|Apw2;+GFR@rMH?eFPJgIDM`7&!;8c#Zu`1`c!Q_sKnys~+7;&Zez zwgq~sTDa6Ij$EpsxH*e1PAtBrd|4JPT0A##k(^f^pSpBuJi4fSF*L=@Y4K%q7gzGv#Y^XvqkO{BB@jW%Vsn;Nm7lwCQ8|mx zM}(4$WrQYB2bWsi0lu)jymI`aIZLjsnpi%6PGV710sU2lYAbK_ zs^asOCgR@wc}pwHmw3?C;-%M@dsR!s-{*UC;!78K&}jLR>%I9%tB69n%DIcEdlWCd z0cJu`0=;K3IvbiwAD*{xnKys_qC}PNRSIu-24f-m(Y*5IURC*$dGpz@`L-s?Gbc`Y z(23?RSv)5`*Y~RC&RIf6D8&E5m%o=#VRIH$`g5vaG%v9Pk>y$z%$-wJ&N2uff>e>g zd?gX)%QzT7Sa!Lk^XJXEkpMdGGLJIas>p$jo$JllRxZ94aTS>qqa0-zG3I(?v0yQx z>|727W!IFk<+$c7lKw10&*x8XzQk0od^tv#`J#(53_H@&vP4z+Jn&#}wvl=RE^7-Q@l%06o zNx`r1?-PPtj-+|=pQikaNlox?knEo-h{<;j?qFNSe5K(p{>#J8C`%PqI_4_9V(@Ri z#c_DKDKYp@bCp&n1dfwSDP>k_ZI9Nj7|LZ3q@rZ{&q+r*=IejD@2B`qVwUH7-^Sd7 z>kj_gci}=z$%c3bVLr&bs)H5|Wor(%@ZM5B*c)x(B7yU~(*g6}I?MrgyIa>5L$GM( zoNx#xMNOD{?hXOhFoo!AnL@w^nPRTAjw$4Lj49?y>zRV*(@e2S*}xQ%Y-BnNb1SBp zoIcOA0Q>GtA^BFOSafY?iUz#SbZ^gVVTy^@4yM=yX=OUx^V*p1=Xvc+_xHRGrdU)O zrkLz@GCdIc>P!#9UOrQ7-gGlP*zJZ4kPYcHugf8mST;;^c>8UnU2T)InxQSKhue@Khr4e&-7f_pXqt9 zKhsIDKhyJJf2J3}{!A}~{h3aN{h3|_`!l^5_GgMkNHfzI?9cQP*q`ZC*q`Y%*q`Zi z*qwh_BT#)C|4e(q^Im<~>p6K9dRWhh)%Xi7dp#oBQPV7kDlSBDg|aF@=FQN z7MKyqpF}t&Fe8&6BU~ylBa{yh^HQS)W~B0G6D|>$5zA+TQbhtYa`}~nJ%Jg){N;o* zUm{}!Bbi@AxLsgIG=CN07J(Vr{3gQ90yDz-YYA@J9gcET}%85#W+!leQ;Li(+QM+@ws$N24pO9aj*YzP+# z93h+`>MTDCLKA14Kc~ct%E+Je(c%8t9 z6CO#pN#K!$M-#3Q_!z=t30Dd{ns6!M*#eItJc)2j;IV{bgi8fJgD`Iwq(%!|N_aNm z5`iZY_6ZjWJc)26VNc-6gqIV}>}306glh=53p}0hD#9%S&m`PLxLM$<2(Kl)LEzbh z*AZSP@I1on2{#Gs6W&0$M&Lz+HxsTDxRP));n@Pm32!GH6L>k{7Q&?h-$J;R@MwW+ z2)7e15xADHAzUQzD#97Up1`XKcN5Nh!S**1#+(N27kCZf2;mli*Agxw+$`{ego_Dp z5O^Ko62j{QevI%)!c79NCp?;PjlfS6=Iw!0rNA2qmlB>W@J7Ou2*(88OgKikRN&_c zbNf6sTHt2Fvk8|7yp^y|xJcmbgewVq0>4gpIpNIb(*Ft95N;QE2jNwOTLf+;+(fup z;5Nc*32zX%o$xxs>jdr~yq<8Az=rS!!ZiYS65dR>Qs4~XX2P=t?jpRMa7^HC!YzbL z1>Q-xmGEeRJw$xJop6c3`GgJOB7q}>GlV^X3kY`;&iqIEKVi;^Q|$r|CmbQ%B5*O` zBEroAA56HI@CJcP2$v9EC-C8fM-pxlcqHM`glhyohVWRzl>&1l_Dc!R7I+NdNrYnp zk0l%Y@Zo-+*r2iAfiUjQ! zcnx9h3#VEHUQ3wU)v0EIA0%8%cmv=QKEAsC{bWZbHhro;?+TQR!JkVm_4iqyA2I(z z!0Bpg!dzrpj3bhF<;s_rV28dTc`*F1t~s99)6y_&=c_LZ4(2O0XFd(?USiZErMQ>d zP*nF;{DAsTlg;^$67G2`$WEkR8A8-SufAOWsm^sCslmVqo(FPlCG(_~2nyxE>?K0W3?Oq}Z+ zPJ#a{;S=Cq%80z%nRT&4k?OpwkTuR_6;ycUIE+XtJ*zK4IqUk-6S%(xiK+{{c(K%9 z;2&el?$omMz9cBMnF&Ww41%5n{vYnowq=)Fg8hZjaDSc6KgZD&d2uZ(^4o3M2wMjI z?KTTCFMy#TP+fE480vIi=1mLoD59#a6a{R+-!c8MDqUf--qNgBUzXLsT%ZcCk9H@kyS>Ej+oIj|5DE=p>HqvpM6Hiz8lsu{sA-5A zm1{rwH6pPa(pS7Q8>0plzb{lpX1$~8Y>0O5B2{-!qO&J~N;`TI?LCQ%eJhOs4k&nIoRVm+fa?8B@f zm)SAO4CY9-=flAJ%P;h!M1lOG(eu*Zkaiy|u2lrJNre;OyveO4w0?I;j=I2k1nbBg zIc6eMNdFwQ)!KSnw1cMH7JXimjZE0|p;x2nA9qR9>!a<=Dq+@pF3T|MG-hpcS)I&^ zF>9mC+L5g8^x_4{YU9OsOIGjj68jNpHj!5RpKwq8au^m!?_qVtk`GyuaOAHit6%pD zYyYJ}^(0<5+Y_Sa`e<{qx*0_~ti1mw-IexA--!pink3G1V6$?7&#_G@4_M%#KoA{cEZ?P|0b zYx`ilnu8I)DVP4K+|sKWqHU%1(T?;q>S7;=Z5IBowLwR+y2Fc~&Vs{O@J@Z82?ogy zf0VSc*_=pKGNekgHh(YMECe!A?(bM`O;&I95(s7m{sb2M_usZIDTwclX7(hu_9UJ+ zs~@sFk@38L36Wa_IX`Abt&=ju{DN)Kjo*R>QupHzxmFPI$BwJ$C@xLAo(22mwxG?w z3Ar>yr4}TspI7Oamw{^0s`}{jX_c#)a^0YPeb@9k;#Ce1SEu_jj)}0{5Z;2vMtJ`s+W3fcUD~Bzd**n`;nEs zn^`Y2YqQJBFl#%r9(P$StoRM7xZC_L<0?L^|B4GG@Rg)alo})cpDf{bzK-zQmXJqN zSmR$T;pJaP_zUbap{c26OZbr`EC~ol$Y7~D%H*hNG4{?#TWe`QwzM7pa?Ko=wraA{ zPO`NBXKB~(0_~C5J7c{Cme!k1N9{I?0@~%&!4S!AF`KkkqembFMf`nj_Cqc^F|d>i z$7@YL9D^YWU7+N_&o_9bsu7*#+7^O;Fk)mi81& zTfPglXJA{FGQWzsE0uDlr5&{kv=^M9w2hYb0!#bx$6w#xBd~4HdM~lGmsr}L?E>xf z*cvA7ewOxXOPkmQ+QVZ?`!44CZ0~$ad)hA0UV^P&*82lXTWM+k+xhkFeeQInonvWl zwzMw>v`0w@?8mPVP%$eWO~S3CQze!`tz}TNYYYaNe_?e&27hIWmfvL=oV{xd^2|>y zgNH1G2P}gx(?Rq5?H3#nZah+(e~qPm+|s_Z3$&-RcSG$*SlW%2_V!(%J(}?owEw^i znvMRArM+MmXiplhv_G}9zqhn|?E>v15v5&bY2UH5Z~f!zb@lO3r9H*ceq?Fy+XdQ< zdnoPaGSWxyC!6zP<}y`VeH3#Wj7ng&(Y&n#6B}A84c%x;H1G%xX15znp=NM8g_+{P<|f?8 zkQvs-Wc5Zbfte=O=pYuknsj!|-#v+ukQRbSU0m+=B#KOr>L|s%E>JesO+o{Jd$2i7 z_+p~?<>OL8Lv&Srbca;B(L8~>DN<=yvbxJlT+T{sT&3U8N`YG8NtLLqNW_WCWT6DQ z^WT>C9W2>*JSf~iAmAtkQ&&-@>WCKy0W`Ejc(D<_ca3e|2AN2fU;)_RVL6I*5p9;N z&UlF-spF-C$Rzs`N3g=qJjwP7v7xfFs=!}`ax?Ek_HMY)mU~4Fm|0y&Pk97|V$YG{i`s<_-=8@24fv?v?D+oy zixT!Mka_d0l7H>;`Z!pJbdEj_c0}Nj;$Yj=NV1FOc0vmLnP6}B`@XHNAZA8%NN~c! zt|3~ay2Ik1a|y8Mp=1qlOTrO? z&i0;0e!DF)wjXW0r(+&C`p;22e^3p>wVBn-tmj--2W|PfsK=Q1|KN)l{P#kC}mi3`H)KWZa zDX@kWiV>EgG@#&?9qTyCQmj;pG{Q*4Ki;D6-3R?7i$2w&A5HW#Ecyo@xaQ}j_o1q0 zqrj}zp&@;X*^0a2=%66cu5W&Pizou92n6PRiQaTdIGL%ugJtM$d)zKa^-->pC17-! z@2;?f7#Oz0&Rr5$`m^>=4TI=;x4^%PEqNvAsWJ1X zcH5mGl}P`BObUvU-Gf$43H77an0aMyC#=5?Y#O7;`>nbGhHC1*M4@ z^E*`$J+ZoL5O-}O7%e7&N5(wk$~tAI>l+-)Zlxcx@KBZRv}o4~YnyhqC}X4*X`k#8 zdoqU3Fbz`+>Wk8_tWbWmmq-sv?gw^mD@FIg{w#l6+*kp`(3WHdw8IhFORXIyZHsc( z3%+S1)wMy;h?$%JYE|1`q&iC_7U7D`g<>RF>%*i-X?F?5TE!ujBOOciA-GGsS)nR% zTPDG~qa@|zu(`;`kCEli`fqhO0i2i{g0cy;XW9q)AD?Fdas zfrm&dVRn>o!oUj-7&}`VF{hD%x1X-mi&2}|wlCYJffur`R1GLvKlEmfE>FY-umLx{ zpT0O-##k2u7K>3~T|N^d6Eq3HV%^i%NETEQGZ*|N+ZUlzSQjx?4T#}Rwk*TeHD+HK z0*bUZWUc$b-_^Q5fr%P0PQqgC&SKT=)b-WybP0D2n4yd|pJ>IH37m`!F+!WzF5~~( z+3r{!cN=D*M9sHC`+og|d?A9~+g0xmh*x)*R$13T3-F=!=-Xz%UezMQ z>_1Rz5e1EEb3Ka1qQB3-lhxlaSKQu@Nq(>Li)h8>y_F<`NfI^IBxn|N-p-NuSXC?h zNOm8g^L7`3+RVce(4h17oF27A*{7bC9u@I>pf`Wd1?X!tMM6~7pyJgv7uLZcV3}50 z2D|#$$h2lFnf2ih?uHWw0IOZS7l7m+CUq@bUUkBMB5lH)byWj4}o^oU|J2IE6*!>O? zy{1nsG7Cl5j+je?Y8R$Yt!9vf0PV$)>N#!9z$*DZw`8`Ke8u$X`#KG<9-h0e-a?5xa~bfw4?o|Ww|H}^r;S(!1^FZ zu=1VWKG11eWz>KVV9J9VcwrytG#AKjSsx!bP-{R9$1Hm>Ke4RxiXcb}iAH@M=GVA^G#SLJa{flU(nMu!`4y3BDByWtxh zIVStBj@hX>Qc=EJ&td}eO|>!D`^`|2OtlVKWhDS&hrjnio4uQ6_udJy1N`Hbk#3B{ zLK`FfOp92JE`K{@7-d%!kBpcG;ZxdcTV(wJV?l^b#vCo9EuwnFKO92qlwdcp8mw^O z4(c)=UIBrEDQu-^QwOAu?Bw&HJFE(@jTf|E^9G*lCG=##S2zeJpu8Pv9pttft%Dr0 zTx#pI-7II&xQX$(~2Ai zd{SbcIN;z4+iO}7CdK3te<NBN#|r(j-7j%9EOFT( zU%f)}2KLog<;J+1(O^Lx;rwzZP6;8ZBdqV_G!v7=?jFnmcgh@aXBx+Zx~+FRif(%* zNe&qa#ZFRm3q?06+*zfu+oE0MjkSC7jJk<@X$f|CJ6T&N76n~BV;p}1>Baoo;72nb3(n}_A#E932q027N|CFf{KZiTZP^Bel9aNF%PA1eI3 zMLIyg6%HA&!h9{kQ73HA=JoXSSoPsx4w{cMUZRrpSyunlCLA34$C0hPbP2RKE?SU4 zE4mRJ(g)yBO<22FT052gzswgSD-IPxQD&KhQ4L`c)3K830R)%CE+G(TfVLplPfHeu zSu8)=4Sa}2(v|3I)aElVv%y5 z)EB$d79E?#Zns$nwY z|Hk3UB084LmAMCtNetGH-wY5@X$JhzNsFWh7o~sCwl|_?^VfM|YjVLf=^kXsAKrr+ zTP{UHg}WicDaAUGcBFYD*tYavuvyP%v)XOe6WJ_p2~{!D+-I{m%fV48L^oSdoyD!O zSryr=cAIrsHmh{0a-5jWa%TAU?_IZ+Drzj|L0Qb7*epKI1XoXAD$ZW)Z?XCR(j{K9 zy2Oj)7N|}xFtx;pF%f_Lc8j-7@aWp2bpMP>73vvFj|Os2SuL{qbte{sn17kYO)75c zOR;&k7oTB;sj&#xWSRZaW=#pQpj6x!>Z!~(ZP{7hs}^mfW&J2wqe||#t1Mn1%Ul+` zZV5h<^$mQ1#E?Y(b5|LU$Ih*g$?g*nvKPQ?UpmBdxTw|h0 zRBU{WGATZCK_*jeeoXV(@#8p(hB%F-4Z`l|p2QgZ^=mBNNWp`9;taRV+Ru@~(S|q7 zfICFCm0|+|x75eyGa>SjWz=-BF|yhz${tY;4f1aQSLk;(l_)#Lp;aS@3 zFTcjtGfeA|@i+A?jN?KhuJ)Ei`AAoJtm;oTYlmj-s!n)}|EqN3RjI10mF++}xjHLI zFP)sS{i}7dzbpSroy@jkd@9Qq%n>msQJtXa+RKW~yIM$XI1ha#oAoox;#tj-zBp}V zCk9vgRAY24R%ye{HH+9IG50zvn9J+*`9#;Nu`n6`inM85v^752xi_NkF=patQa}ls zr8;D3btvt7iRaOc3Bh79%NI`vc zO+$1Irfh|^*myx(w7ZEs8}$S_%JoL{SV~qBr%8`7PwEPAK* z^O@K<4H?D;L_3yYZn_OR21l+4aKF(REMsQ8)YGH8B0aDacQ%2%a;)c-?shBAymRsB zrT(JXTo_@JJ1*LN>mgXTuJrgYm^7f96YD#j!@}}F8ywx)80)z++O;YVkKtfX3r|~} zmUl}dehrRBCKdh$jJgWzZi0F>t8vnoS;8;x9CUhKVck_yTF@{9XM;wyfTdU}gW!eU zq^)46pp6&?U2+jfL61G`Fj@D$-Hq3iSrVi#5LAYB&edx z?9O9JXqt$dtswn_q~H%utfAhtE)P5#>ms0tnNzi{nk@wPjGwIe;9apNPTYiLN3TYs z99>Vdt&fVz)|Wa8AgKLyXuE6AJU7QGtoxOyR9b*v$t|Mh!n!U>Pv&fBviZ!Ic{t2J z$fsOa#mrlQ_saI{UUHWc>a7>E8@U3?JS4|wrF{3 zsz``=Tc};D-Snog?j#he7SJKQ)ZxV5BA!!Ndo^c^Tf}(^S6w22G@CK0z!#@^Q9DlR zFr8T9nG6+Zp$Y^~_$HNFa6Q7Nmb~$Th)UQ0f|>-U5|o&+pWUr7Dg zz-z42!ux_k|8_FR17Eh}Kplp&Wa~m?Wmz)H+5z(p8Umgiw}z| z-J+Ghs^3$qkF&N-%r;MGZhf5rl-$CTyc{IZc)Ebz1O>^Ndn(ONrd88f@0K*S^ zeR7KgB;2RqC`Q%#&1jT4O2tV1-Fe7zWd7aN6lgQK6b_^-%GtnhO1{Zu=lAxF|2jjW zpN9y}cLZ>VQ1*$M-H$^QJA!^4;w%|P`*VnDSAWoigEhxZayLqYZHK|a>5=C}Pnh8p z1R*;weQ409fO4xtNgO07-1f{y^^(9|{!=$Xi5nE#p7GJA%(k%L{+xpNsk9YNFvQf3 zun(d&4Af@+=`1V6T;2WD&2L-M$3QYZm{n{RY;lsy!8eH(_o~&?c!;aGKH4Hx3^yN( zU1cWOV%imOGm^cPi>|w6CfR8k)j6nxR!GhpweLA80ktsW)gYs>&hL?-rqc}989qbL ze2gRwb<0sQf}b-u(<{a6GV5Z<6`?xKBp1eGz)5c5U)hq)%!P&0al5V;hh~{sZX
    c9Yl`Gi%kkVY{ak?XfKH2Vc<6g1xT7 zy8A^&Mh+ejEjD}Go-a>>LPO>uQJJW--Q1&qQ|C+12`4$X$w0+>vS+!#>(psXg9^hw zE$5QWO`!}!{f_#TwQgbEZcZSXZAN^=y~HEB%qc3S zM5=64Ym_+kPm#R9Z)aZ`r;>oMv2G?jA!gpKkVplCp%?ijH!)ag$?vrUY_q{iOJa+| zG_ylA-wSBK&|eoSS>fst33UupZsm>!-I|4N4AasE(Nk{7(vsI?oy~yaBwnaFp(%S1 znzC_cz4ciP?=?3=B_o~o^bpUh3vJ|vt&9C114E7fC)8R>ag>2vIAA7bv-B@2RCRO_70bgLD%IqXY)!{SQ(zq<^@_` z>+*E`6=$FA2yT`_D7dfgACunNNB18(!>aCADQI;+$?0CVX=N&lxV!r%8_+_7?Xx)Z3K=t6!#G!)SoBhZTdYwub$JW~8>d%vnJs1cs?}CP$SSGyYlIhcWPGI5^+4(b`{k zxWvpCIi-T6*gRuZ*1h}n=ZG5>n+G*(aI`pShH&UxxN=A&W@h}{`4Tq27!^1a)u6~c zC*l>Q^_?f86B)-J)qL9#aHbfs*h|ZWfR0~8< z?BUK7)7X=2g|$!WAWBWFRYW@o7uMb_MR@5Cs-PBIH%MdLY33>!&O4~GKU^YAF=fWt zWT>da6lgOrx56ecs5@D~0%d?qOm!iBw$(ogoRD~bRbpY)Y2H*Q#k)Gl^4qDt$*Neu zeD=b8e2oZT8;{ZcHfjY0A80|2-y+*ruM6;JJN%zJe5_Vn-b0#a<&^=RtnYBBXfRu1 zM|T!&5KZQKF0%ivH*B5IYXXps{zpg!ou*A8w?=skZSOxO{_iu+!?F{Bhn<7lb-|RM z_4VkR9S)=)ZvG)m7IG8VjCn28kKpDR^Q$1EQD*(< zi5Zix6D+rVT%Lq2Gmcq-Uq!e>^&&G+w=8Qn!(2n--1U{N)NcOor+r)hNWhLQ8=P%f zyZKa_66~2D=^R>*kE3O6=22$`*RnQ~alVFH+llj6mjNF}-ebr%|5bg;OjuNUr`E+y z-%eAVTk%h|EjeofJ3cXX=n~7A8(clwfsC2&GEhUCS*48^Z5S%|9jBti*^=4D%$I^p zecU}`Vu8|l!%`v=)jmp@r_#2cHH$4=9l=!ewle8zHkNs{=xBCYeZ7{1`Ic`pk{d&9usu=em z;)nL%)mA;-*V)GCU;(xq81`2TMo0~Vb*lWq(T+(qV~>|jJVwVQ*=*SE%kD(@+2C9L70S#vGjC7~(AOf;v(eC#{} z`y1If|4WU`g7dn6DELZqMmvMTWwx8VFf-_QyIJR$71o{!gG;5`&3kIZNm{EQ-rx`u zBQ4S|O;Lz$@wL}^c@)BFom!h*AM{&YAM+_R$ zrv8@dfRlio--!Cn@mEX5^-+Ce6t>{;#;vZHe=iDgN7sB|&Cor_neaZ6b!jBv>4n0( zZqrVM!;>$z<8=nBo{(NxU-#I5al=5L!^i1-+y}cgFOByDK#v{%Q_}dcz=)aiLcv;d zzNf-Ns)p!RhPH3uHFAvwb>h+AC12#%=MTgBx5txb)^QUEP1-=&uCl~+V}K`mD>kQK zFOIj4>}v~#n@7dY5|MV8`xI~yY1?{j0NxtLaYn}12~I{Ak=jhtQ-UTqJ2J)i^(Pm%Ibb8M#KrDC&L^D%wC5-c0*wzFGNU(cvfP{1W8a~5lpkTaUK^Et~_ zJlrkqL}u@(ew=bn?W5s97ltY20gkSp-f@}jToS5fZD>2m%~}GV?A?REygW=JD@03k zo}q0Z-_9^HOyHAg-! z3Jb=CWM^Dv27`c;jlw6m(a+Ad-&ZO(#g+Bro(@Mmdg+hJ*N)=XDB$|cy-J-kiWfR} zc6}yeuF{Sm#)UO9=E5L@d(;{84I4b<85fL*Xuba;d-ZJrv&QHuxKEc^J4Z}}M(y1Y zU28YzYw+!?@K|$UK!!J_`0eD>Es~RS&&iMBzO;GgQPCF=C_`7pAak<1oYUaS&gJkh zys|^$50|#Ns{By>5UtW18uvMm4K2lAayWJmZoJ}%byt1KFxWml>~bab^ervfp(QzP zswI~>-$G}hck5rjG(>#A5X13M?rzZWoNq zTpBYsXb)?wlLEg6l~v4j)6>^fnH)!S!s<7Ngc;^qg5V%^J(V>EhUL3m+;77}-)`TE z2F2?{v4bVA6K$2(iM9r>6Kyl^s46ji_4$oXyvVd}hcpN4sH3xf$$KJqJ&M5(x4S24 zRP}BglDbE7I)eyD(uVvZd(&m8|2K#qGv9W-qpMcZY zV~C(YtGe%Dm85PmsHL)=P5fytvbc3I7U-?D_|OIcc>+ra>IKwH9>vN_f71bHCIaLU zje-WZ`6GM2^0xt1rUmG2*3m^1<{owA{=K|ook&bhcpK3sw%WOSO~^pskPRjTccPgW z)a?CR3L!1GcOI&mlO7oEoj2+E#I8xPEm^Nm% zT`bMEv3;GiTT7nP5(*p~ZPAjmoWQvQLwkt$Rw1UU{KHpc7;Jt}JcC0xLZ#kD z>S*3w*=Al4;?lpPsXFG1L-*roT6~@s=Qx^{+^(J+vi=Co>FsE_C-UZLfDasPxGEuM zGFR$wtfMu5UrZ3H>gvg1M=K4rd#aZ7<7j_$h7YvKd5AwdM7*C6XC3Xb2L^DovvLXw zYyYPoN85g($Vht!j`lrPMo0VjVRFuKw0~HhU*Tv6IAwi>qg|rarbCXl;d@qpxsGumB~6j)Sed~!1Too}5~_Ke1Y$dwEY zO0p4KX;wSO7Md9$nmA^O-59*34?9?Y9D-@o6g7ccwiq|=DQwwiB$*XHxh6FhYN9?PoD z8413}+FyiPFpC(>FAf;BUL*E7y!;eL0N|aK_!jZ53*p)EN%7KG0qF=ux;}*T{SdPu z=~IDpm?GU0Lb^VLv|D-~2!hu|40`F#s9BW<_MA*-l4keQqMe1SkAXpPqcU_19AjI% zNjleUPYnZxwna9@q4RcM$0#-I{^yDL*qkJUaGua}Zjc?eoylg)83t?VH*GfGOzzhC zWi9~q3K3fE-=vYbF+fWWb3PdO>x*h=x8B7gG+VLgu*gH=TvUlT*VC6>NK~oSQGhnkyHp+KO(zK=&+CjL%|V7nl_u@hE~+dg zv5P9T-%$mKYLZ(-L7~|4$DlgAMit7F*kW|ni-rzwsGEu00m92#M{L7OvFcPqHkp}U zOth{e{d=7_m2R9q8I)whix(Y|88 zD zL)k}Vv%^Z;H=C`UTG{U$uT52T@N*5A#Int%R`n|09$v;MT|_#5Zr9e5^P*OHXtCye zs45S2?YQh^W!RxzC$(QI!HgE2@K|WUu6j9u57h~ty6yTe1Gg>hwbS;#>ps}9gGS7C zO}2~7Mtn?e;a@L-VHlfN7g|(tj+*N%Y$VKYVRZ5k5cJygN=k*%oa(QR;^Vy5Zc|=j1Ms>~r3&w6?%6S)==$ zI*5L7m*`oR%6u-^9UkAb738wpqJL(C$|<+tY^ojow!od>p(@vfF#d6tV5ISt5jQyZ zggCZ`P+w3~r%2xF$q%uW(G@}YyV>d+Ept3Cs9V@^48ZswB80FO2v(7$#o??k{rg zI25?JyBO?m5*=H#JStyU`|6Ouef}Ue!K|PkWbEh0%uf`-%@qD;we2hIXq2o!+RYVN zH`19xyZNyS1)Kr+azc1pfE2{ecJq5Xud2(9n}u}`cvk3kGt@<|)%3e9{40+Sn7P2= z;{yh%bdXIfGpE@OUe_e}{L4L0JU+mm?(qSBZVQhO2u^d(;{%tgdVkh$S16_W`3<3h`BK0&ZjPT%(d^XagHa>zCDdMxz|ntw5CkvHRPP!W z?I^sRU#c4j6~VHjXA^^W%sj6&3`<|^gc1jAkSWt}tef9rB8f{HEqXS^z)t`A>q2e2 z^K?;{bVID{2(1Rw~LsM#9(d@cw{CjTiF3ZgPvvPU6#( zTdsnxz4(O)96LTW zhXlJ$>es0@BFy)*>bp!OOOJ6>4`$28X_+l4eJERUsB4c~P^fbcv)SBWcQ+xhUs{9% znQoGBv^W`jHMDo9#1*c?1oOC|nj@2Ye#0c$iKCH--4QdPR$UdJZG<~EKg?bCZu5gX zY_4wc=cN%c^SRm4yeH6NrcufZN@JR*$!^%sx?Sjyix(e6(@#q!1?GQ}mK_fKyGn50 z|7$84IY1>F>UviKnKAx%n^#;tcrYHV>oy7P0|IrK1q$J5ciF^Db}kQIf+M=vrsa5J z^({kEx5;3toFnE8#~F`~19y$NQd^4Ng-M;{q+EYXl=6^1DA$uaa3=JHd&EpqPE89XW+M)7v3VENko$Z zO^P%b9`ipGi$=_q;@hK>-Mc3uHPxS8ftdj6+eqf=Z{y>Om#^5Z5xXYdJRGsZe2SIe zS%giuS;K8?h;FnJ&~yAj>#$xpQgy&je&VsiL3n{gDJExlahDoao75#$@O49M8^We# zgM)Z_w*3)RN&{Z@LsX2J1zrL#Ti99*AaxLkFttI9N79bJGQ+{^GER4ntG3>0-d*XO z43*%%y?lfa_wCzcd@yeFxQ#DonB|E1jt)kIp8yF00c!9XO8Jhm)1`5E2TL8NPkgcD z_Ub^Y+PqwJyy9w@!=Dl0^OX_Wis{7XR~_+Uw5~~~MceoyCTUa}H!sCi*C`o<(WjgB zRlGQ|!uKGx)#vf;40eWxcg}L>soR_@&47%HYi!$h&=R(^)k!qPm9|J-JIo)PH)kZH z#cXjII6~Ip71ljOJy*BmgPyJh-w`c#j*Dil5AtpmrD0mqDUZnRFh{6bVfX;&3Z)wy z-65ND`4##89`GH0bhA6~`~dqH&fw2UX`ri}QVvaidqqE*yh|buN{6^or^#B!*J-lKWprYzm)e4% z#RvGM&ycFVP(1A;ig2QA4)@hlOJ7uIfm393r>&u0$+yVd>pWY#MS)p%t8Gv>UI21f z0=F~aZUyEkVTvaG@8?pEY5oPBc1eE)>e^N6|2T6t>%Rhcwsi#Vd15-^(q;58qhwUTRH|}`=t=o3>%I% z@PH}aQf>I&mGSv9v?6r+=Sf?Pxk7PplodfMb%gB`L;MSDTVGJkQ6+g&n5&YQMf1hP zs*<;y8laL_+;6Dl*I||Ho+ET&?GO5>{~D{IvHJ>!YKW0hSm6Ar^R@c&c00D?or0yw=E4_E{)_GT zqqf$Ux7iy|)*WTs!AL7xW7w(w&dt(93?Mt{=r`*3C@^SXtzbqt4Pjn{cjfPai4H6& z!?nB%5br8L?Eb{m4OC(WhwaoC;xiHPaBvX(qSC@=@&-qT$IQjrN4dBz ztfhMeqmVH_6thFpS8oip!~`vQ%eC~7a7%3YX!EQq{_;~%U(Bx!wac&?Ebguow3EWmgB&YnTcz^!6i?OYRZ_e@l zCWK-j{*$_u)P#5KDs*WlZ3An@Bo(gHKDM_NY-6nS55+_t(>l!&XmY4_Q*{C~9q5qXUnaf?-s-ei|s zyd{rtI#6JSD(euZJA@MoTRE5hmDYsUcJsZGxL;)H-uzN{hUlg!o&Ts{3^#wZkw=dW zZkddVJiWc#YH;jssJ!1*~IVuBID6A8yO%<6D@A`3IgvYq&YwGFs1f?|@Ur`lf! z%^#Ys+<1V7hc1vE@hkS63ko&2Sc&DKBU%a{xtriZYk7_gZYxPATYrKf~VcJk>eROR@ zlxh-!b(UbCK20IjYV+>=;q-tJ}fc1!kWopXfhk^MGqy|!a!fP=22eq5*#e9p+x z?q06zHYKZ@tSgi}rVY5Q4`WZ|=}9z^<pl#|3Ioi+TX+^1D!f5e;TqFyDQo&re#t0+xZec~vv-v>5565LCs|~o-+?WI z-zpkI@4@0>aJ;wGUEGa4xMyciyl$-?1vY=Q(Gf;unD@OOYwQ2}pI)s`-^!Ub{9&-A z{IheCHqfC)&M-ccx*~(|y?PAu8MC{pRu16+0V`kZl4MN#b;4Xi&qM~YDauPuw4{zh zjtrui`aJDjXqDF>@!j1VUfH=GdBHrYofzW0cj4xwC=c!u+3seVc?|n>oXc!W!g;q!yzP zt|PZS{)`{I&4W?Z9}kUlF=5_Q!IRy*k#x4WO2q9O;|b@Zk4F=^#^Iq1FwZ@dp@V;? z8KO*5@J`GpUEuCCvz%6B+$*eoT@(hJwAzO8Ed!giZQPEK^*4_yFu!t{=!P2@T9uBqj;yc^%jb8u)<#})p&-e);ensSWOTce`c&vL_QmYxR zM&awiP;aZrS6HA%}h`1G_yK(Conv;zr+%irvyV>= zb>e)LPtDV|_3^2L)xKZpQ_GhO>{A7fZ^);%FAe)?U!NKo@XPh7W;IISQyUbvKJ|0; z-mp*oHH3ionJ7YkK80B^cQ|GGGuZbKf6Ts%t&nO&_|kOrRdjbRb%4Ytbe;l#l0=1$ znAxh#MV1b8sSCPrv4}rSf_28MTVz@4q&CcQD;Vp_!k;17t!AnUfL^MzGX9nEsMY*Z zj8dXuEfA|lVv+Q=`vR?pD=7nlc@9F@hjSSe1M2ZCycKntQQ%%5-7eu_N5yV@Qu-Ha z5eXyP`4n%tW|&53Sl_0H*~?XsJea*)1HjxRZIIc^zA7^|_s|ebR$k}h+)J(%jR;>1 zwp-0#)MDnhBIWZU!}E}UWuG`?S+o32nuvk(0Trb_+AM6g_9U9kxr&PEoeqV_dfVBv ztzj0|X4osmGfBtV+`&>42EKMK21lEyy1k5VZG-b9ghI2;X0j59owu5Qswb-&;TjnJ zs8BcjB|F`>WrRHfCU`{5sX7U=eTv_Sk?c>j&TY{hvOIcQ%;|=P4l`bD>Vn%y>uS#_ zmF4l1Tpo7|4|re5wn=JW5QS*L+|qf9bmR!r2yaft{bD% zlAXhIKhAS0C@YH0Lam#3SGetpeKNh3a%#gY+;4$Ec%QOWz+mhdY%9e|jS~a>vU{-j zRbcaQI2Ajh&Vi*)vM4YUoDNZrEs6{VMV`$XWrm@7^)CX%tEn4@dkur;<0Q=puf+4_ zBS6VYm!GkHLqy4#FBVu^=;)g<71~#^k0$ajKiOrE5M?}a>5Z&batyunQ(u#Q0N-&zHhH8Fdf0rL1r+^ zi~Wft?TKLSeV#^Mia*-_feh&dW<|Nvy?7PxhQg15@Tf(&+9BXGW%=Q60X!=`79R%C zZvj98e?14-kF__Y>Rq{h3xMT6VfpX1JiQ2Qsu`=_0$}0KS-8O#PLV?W761!3v+!P9 z2or%)zXia;7g%_`Ez~zqLA5*4`D3O`yM}%Mfctzw1786Zs7*B%dE(<}V8r(LLi;9j zc1Y;Lp-xrQG`7WU$?q+bv09Sr=n@L8{_IvOLt!`LTKZT>s5g!I!v#S6vH=jkYyj+M zV-+zBZ!xj{^NH@>SQkG_V@$3j_5*6W+D-25$B+I$*-fnL`#b0Xap$S}c|N(-mzO@+ z_6}@scdDYGZ~KitJb{nCjsSL*BKdzIpJS8{48?&C16a}ZdFdm8+AxEC;LsKf#8~J{ zpTn)T2Z_XQMB^S>`c2E|?_~5h=UEz8T_yiw*)}a3ppr=MN^qp6ZzZ3S(XGnJ*4x9Z zYx{9V8+p+7;9Em^=`--r476)p{&)GIp#+{^fm;XP4H~*$JIGaYq=Q&d(|AiiK4O#J zWE~mNLIP>SMbHn%pMpKc=hvT;pY^|>;IkHd%BcUMJ;q1s&xs5`lUsy_+IXK8Ak?H0 zkjH&EDavDGduql+G!T7It@JutX`{bmma7;>7}03Ner?Izp-#c|4a#f{h!##AFF+df z8XSPk-T^`X&o@`A_WJaHvI+V>7=;PhUG+gBi9hBPb=<6eAe%LKA&g{hx+VzXcx+AX z>3}}u`ET^`d`o^L$;T;qm^~s~#2;-P;7V<~jg8sa+&E#XQ zHg72_+Nu;USKpa_EvsN@-1!ii+T|>#Osa*mV5m3fXP0^GlPk&7`7moaOC0(mk()`mn#Vedn? zurp?~;#j*hL~DEXkE6e|&aVdn@G&B|_D;js^1&3+CnUqD$nZSanuk_oJrA7+o@S?* zI=Mw?E~to@Yp%%QjtK&%8(i{+X1p5hbNJ+?OM!=#Q)tP#$G?Ra^EqSVofiD&2RbJ^ zbxMyvOQG;!CQGLHZgMy?n15fXH6*@)6koNf$0E1DPPyGoXDo|2ph8|*5{io5}vAEHbeX<{J;u^yjLhvRe-dYE#r1XUOM3Wh2AAaPtkH})8hdInm&_iLovC7 zV^TRD>NpnG4bc&jM$#`bixB9!eWbZVY5#tyYv};eESBm*llLL+dvYNO9uBxH7OSA) z-=rb5;kK%q0;Eu5_tGu$3K*K`Xlu67znW$5^$`j|Z>y*)K4mACM^7&=JC-94l!eXSiI~h*t z&1*>NU=<794IFz$_nc^a$1bk#0=2qJ;GJV)udMfdBry&C&MgDp6?PayQhFYd%9B1z zZ$mUd5WvF7Rn&vcW(ne`=nhMrZPoj(RL)?6QmlZ{Hs2i9;t0Q$z9h@DGQVe8zInpY z#q-i*P$=3&SC$TwJ{A2VKA{d=Z>j&5%H|*5NdP6P7oV-{3>i4 zbS=@OY_c5UWMQx2+MF*}u+EYGLv~Rjtg%}u3+LX^=VUrZuQ*nFxoALl3%N5fcba6> zPsq0si39&EUAgEm3@mhB{}K3%oMwGfS-=?X1%k)#?FKFMx~}@VTcC{8aQKHr`Yuyw zDXNPix8mLlizVcIg1>@-^B%5q)F!KIJ>H=Suzm-uCPAw;b;_weT9d4<;XL_1F@Ftj zTO;Va+kgUl<67m-;QjZ#4Sirn;ZIQ!^x0FUG_jIXTPTVg3phq8OR;K=aL{e;f3?mvXnZxxTK2XdLa0 z*+cV^TbRcI;x5<}Z>u6GcODz<=i1&ago*`VY`{x%|}b`V>Gk(v`%?ZMSVYKSt5eq2w zeCmg9VJtAqKXZ*oY}4Jp5*(MHL)iJplqnX2=ig=WhH_c*vY8jA7N;2s1{xa&_Yp-t*+s0{HIdq8w)Y`nGE<`>&)UAuKL z^+2}W(!b$wE4AJD3ypNK!R`UC3&EI8vP0)B=;AsAvC(2dJZjEG2USx3X;>vv%IUl` zIg|bgo6I4*t09J$M0c|Z7*NoJu2fu_fC(_?1y*|LwOD98_AlYe+i1Lx29xRDj-c_D zRioUYVz&}8z&d9Brn+~lr+vi%yUi`y%TkY`rSkIW+V4r5e5xn@OelZabO#aoEGiuOF{_bGX|CXGYdc%8d#7i>fM&FoKxNhLpWHIc9dRuWN8# z{UA3YWxq+yP*h+}w(-Eeb%fcnKS37}YI>rLk_(>7Uj>F@^$J|@{4 zadW)L3T&S+awJdWlKg?1qpCL|ysyCnqok)URZ27;GucE|yFb22gs_^S zcFosm7l+PrwL3S5N2zMpvH5!KW~g0gfj)|ro6|FNhyNikVqhy{AP(5m-^GHwLt}d_ zjyXm2<-eGoV5KobRVQ;5qNU$)&WY#mB?5{66_`bWDDNFAGGz+5w+S?P6~vw?i9w9{}@2j@^-rv`QDy*Bjyh`E%557#zbX(+H0EYjbzV(;#h7~E*S z6y0|8wrC5q?k>N=v%TquLVG;17BN z_!AtyMr!tV{{R*om0Q5MOas1D&^$P1zICD0@hI!(AyGJOhj~q`kUy9>IBxQVk_*lw zM0~|NVq28Y4#IER#zk9j0{lpG@+9s^wd2t^9yh>5xvgP8BJ-VK?R+O#8*hmtd+-p; zBls=K#^9o_TF20GGBHe*`ZtYtIGSN|XSrO68ZqBeQKc=@Tr&}^!>GPhXlmJOo+TST10jFdTt5 zCJWfA!NshCuskoo;?mqx2yjfCLf~?}wc#Q&2uQ7XoN5rBXK~1Q*yqlD2EDYwYs@cN zH7GsPoIWr&9GoCGEQ(qiW|={FD@bcY!VG#vn&lYA%yLx|Iqwh7P2@b-d;n89DWRx- z4;8MSVF5BfYYLEhk`xoj1l>1|7TdFhd= zn3}OiConFnf=jsO3ajl-58o!2!kV#r!n)Yl#M`sQr&HswQgDPYpus`1hUoUj^6o3I zmI%m>j?f|QTIrlX{h||o@dFhKlNdWg%Wi&+i*~{X{l+pRcucNts(PjODIMy#z!QvNTwb3sy6QwKgvGhse z3f35Kg{%`~-zu~=Y@T$hh>%WR0E`TtTkwyO(1`W9#!QHx^aktQ%iG~T z|4)109v|0H-#e0a<&7l2;t(7X!m%6~2kh0ucCZ~;M3!V*L|!?PoY+apX0^MLHeT&+ z_F>Beasx>qPza%=Bp1>ErA@-436uhcLU^{#Ep2Xj-I`Ylw-n5yX@HbZTH54(zrUF| zFRf(d0r!u4_oLA{-!n76nfd*G^PA_H16@KxZaSf~hP1UG6=C{w{{2B?(`4S2i;TXU zM}Pbt*tb*Pg~~6Kd8~s<=3%UG-Bm@qjqB#BE>x!})Fq}+$$EvtOb4PkHLSxT*Dn=0 z)GcX;u6n+b{usSBuI$*t>b~{mjxSbLzVWYaf9kA1 zyIe(}?PM*kfa0ZoxG zl}*4^ul?e;lGuyebm|%~R61fhFZ09wnGSa{6mIOjrB7jq|HM;&!E3ecrk_Th`upE) z;*Q714_&1@Vq>RFS_RNJwF2yrl=!gj50k>Gfg6Jt_>EUn)mmkz(@|+r-SO`DmQc9y zZ24%mym?^n@J?rMIhPsFRkKciW;R!lCzX;Jps#PL#gr&G<& zRXb;@vw3vk>->6WvZ+j8Z#7rVXZt!Ty`B25w^N?CsNTt9=6GN4Ot<4W;;-*|JLNh2 zOMShS*;GE?hx?gw-{E4-NtLt6T<>JrJgc9w&P;F0nJH(dcC~j@Iw~(u&t`VbrV6R) zY$jK3@7pi88w!(^(#3d?O;?NMTqOm+i1ma(joveVr zI_kb`zGTzdJ2pO%OpGQ+h7*^nv7y1?v7v#9WZ#<0dszt(JCn zb{;!+EItj9GRb(cJl)yeXC*A@QYCsjEprvZR;n|(N>z1KcJi-l`yu?>hJX0uqd>w2 zSpDkh>T*UeZCOA!l+6dF9}VpSdlOTBMss${e%056UjZpBSRq% za4dPCe_|gVUv_W^%w$~tZ2q<(f5Xt_av_y>w9-36<#Ms?X1VIAb19$76R1l zL~=Yim{6r`xl$~sOd%9=Fo8JZ6XTk=i|S>K;ShWO=)_QR-ze@gg^HRfR;q>6Y*r17 zCMKBL#Nh)&MylRrwwABvN~v*iq2WLZk;xt%I~lJAW0`(tmQKjelqLii;!u?+3e)32Oj1M z>0+4{Gk+X3%d@F!HJi~iZC!V(_F@@yjh1VlUG55lHb5_G<=n20%7$ugHe0EtW=p#| zGVOhd>@jUehbR~tG}9oUS&&C)t9HV`&9ncWD0Bi^u!SP1E|}O5#2HG>(WRPCKd2KM zmO_3|)OlV4X!~q4v>*%Tr|)X>f~Aq>U8lCcn8}iNA={!YnwSk=HK><~-dv#sg`x4> z)jpHUWU_^JhZS*GJL_A!b2OE&0d!Q_>lUWBB6ow7?mye1?W|3le4+1OJhuG zq*Ea`mRYfqb|s~d3iT_QhFQ%PJWlEQ3;$dO zb%w0k>@W^Wn?p-P8dA?pJkQu?3Y)d*D(BVF;%r4tU6*1j;4|E*!tu?u3heA6zon)x zIaF3zJ%U4HW20j`oq<$=)R9r=tpDYDT;*?vTeF14;SV zd2(j6)tO>uSNj2U&f6W`c{M{;SDWj%pNrKmsK3XY1=`=m;=2{bqaqf}&rY!@0U?DN z?QzqF>pp=r)c!6*Ia|s4TX;bxY!BLFF~M%D?oV0Y_g1BCnJktu?%37d4ZE1l=Swg} zsA0R>do-?;Qfa|m?M|h7Jdeg+$Jm@kZA_Ian8>hq?HJyW7;q63*LTaW9b@cFbp|PP zb#=5mIS6aOwNVqyLpu)sp8xBu!aP+o0UP0w>Ocu6`#eHUq8Nw5aKdDPDBEJ87c=qSUH_>zls=e=k zjGCPd`Rc`)!iMSU#d6!J?|pQ_@lCg@y>BqFS!yvU)XI5}gaJMpHZS$A^Xa1^4kpGW zJ9Y@}5%)h?QVL=E>?*eRT|T;Br@&65N8KVH<#2qrf6>=pIPM%o?=ld$Q;P}p5=si` z*HP|1%wc%H#hPYo@{=6$1_nyTv~x)28X;-5Hx9~B37UX0OQ-_q5d>!u9oMT*4|BZy zgzr2BX8j2cKRC5%^_4lYy|(rir3Vb#U`~wQDOCR;EywGYD2Kk1Ww%~Sa>%H3PPMH; z5;O-o%hbEgn|*yOQzog$0nX8b21q&)81dE-O1M^fTv$v#wm&z2oE#KNe=`mC zEK?B~wSY6GSRt7S7tjOf>u0l_&Fo}>9mmTb8c=_8k)Fw>k4zTltXOPo@5*5`0gKN- z;H6=tOz-OZ7R+rr7^fAoHic(GzgAc*1&rERpuub*hw|ujSt^@i@Oql`O%G+5B`rHX>`x>{C!F#A%ZHqSef^2OL*tyeFZDTgf@ua5P?Ong!I>>)a#LUp z2Hk};CX&!-!7HCakLhSG3ms@72kmcR`YjB{6u2aiw&PP6Ep)%jFjG^Gbp6qrlCGKb zKsivt$_BgPx@#XQjZM|NUeQ06z-V!&GkRcXtbby7G-1j&=o}tBIOgE#{^9X)JRe^d z$Wf)5!zg(sb<{4WpkB!olg0d2_*b zLVqw<0im2unSE9>6|7tHT8Wc{GU0Qv4CwV^uyJYeC8pts$9vvc{sgk=CgD!rvp?ip zi}Glg{<%8=N?CBZ+X$P}@(a2Lcq!@!&dBoy9r31SMW}U1CxBp&Nr` zoTbQ5mg@8@3QI!Mw=@yXlV4p*3ybg>%TJdLIrSuG9{u(u7gXs0vhrDc{sWy#v6O=% zuz=|dP@50t@!v;cVXk|0&_Blfh<`?;-OiSvJ*w6>x?Xhb8R!X&z55oOpF@M{i_6=v z{QbRAJ=0-F0GM3cWas&~+JSk!p3`P8Fu$dzkM#hVb>325XzfJu=j$E&&WWMb+^`>uZb4*IP1Nf}~5>MnlGgQVc?CU+T8s$I57C7B&CY@Mx>e@K4YDqyC5H z=j%~gM9sqbvE=q!%2ucO*3W9oN8cf5| zuPc8{s$i$bq6%QliI$p#e|ieAfc!(07FK{~EPq`#3~#;m-#q&5%YJLuR?I9{u?&vQ zADjfH3Da`2@_8omXMf$suPa||nwBnK3ICkPH$>?-AYWa!fPBrP-@bf8(E*<1AbJW}s9^66d@v`j0u3I6x*JQ) zs5{Gzr9t^DKE84VW+zIp&stB082RkOFdRE4nU!GeoyUJ)$bc@kV_k%Dz&<&Dx4I*x zXQ(^OuH=qMgAbeQk)0j;gDMk1Vfl@uFpq1ec=fh(Z)0&FrUv2o!S&qkz-sO`?C;Wx z8-0W5H$X>ap|o!tb0$t|3fsr*BQEA*&9|_tr*B{;Rls&{XA*k^8J_DW=(QZ$Y0@_Y z#UlFGUCX)YnJU(@EJ?k2J;MtM5fEOb4>Qyt)=W`C(Witw#3-nh$TDB zeQW9Xa*4?GeZmVWvMPkE$~usL8ZFFUXfu82vL7d6=0DE1*Ac zo%?zE>8Et%@Buv;>avsUny0CA8 z68}|M`3)&H7$BIZ8kUE>ordZ{j4@^98iY;%G*cA|4+Rf$d$K2s_C8uRXyj?f_U^vs zz`~_}oERRgn&CgPy%9@p!u^W8PysWTMl~_3BNYsRJ+tbhuxFT*xP&vED-_sA6Kky3 z72^6Lbg-ARh=t5JmS~s4!LWWxiJVdj?=$EPhf}#iHnVO)DH#0}4wmY49p~wv7jki> z^XtvEY{Hz)bIyz7FL`lL$;0`_%3pwP_>~jBLc%7|ZL)No$MT@`puuBK*xG*0I@1zW zF{@k7PS^6OvdCebJ1)isHC=_ofSKhC6uNIH;1lkaxrLzq`qV5qr8UmgtF#zU)XKUt zK>R(-^kQ=+VIA}n@+a=sTW|h~3v~<4Zg74Mdu1>Qf&NrV&(PRu326g%ZSQi*#bcFS zJ(%;Ew>G91#Zcu9fjULB{UdVI_CxBj+IR*US8#bz{vIsheG1tI1)J zLQ_&9_Ug^d9c-zXzE8Ld^H;x&QIE^QU)`$cws)rQ(rmVbS+wd5I6u>ufThqtx2&N8 z)ZLBX&y-!!*TQROC(B*!MqA)6<|7T=+S`^|C+8>SFQ0Vf+zHfq+t%D%qI}rC;9yJ) z@h-$+bow+`FY3Z(+PS>E47Y1rH|KYyapIoh{@wH5N^&2&$<4d5s@Io>PDu;(4Db5wZfxhuI?gatxuo?(x|*)<9>^?aY}j z)CN{P>Ajg=w@cP#kWJre?P-#8ANfb?PBNMWb234D*#?*^%9I5$tG3zTA!kQ zbt>FBMHRIhUT{l-jPH9Cg1R&9_YdoUUjH%sW4YoJTnlnX1a6Oi`y%bxfXp{Kvh#uq zG{{@aLI%WZfZFvyly8DbBl&JMOXcs_ z>&IuG(2Gnp@I_vl;+c%rr>|#ny%fe|HPcN4mV=WB{5@^^w3VBuWxDTa^qKKan!N0b z-Rpc)jh#DxrSL1UXSc{C-LW$o=C>`uMR7l|Kn>FtQ^&{4b!<#M+xINW?+$+!>THII<){|$3TXhO65)b}++VV&HG*b@l)A#13thJ?z$cW1A z?AS(OOQ8OH>(XMoL^*n7n(SHfjTs(%!ZR^@`5Gx{%ch`}x zIpQ+D(-GvI2POZFzwfi1;KB-2mIISr~4i`|`bcvveX zYk^lCf`-8$4i6c6KiP=SpX?sR00KwgODtW`OCT@5d{>$hTe507Gx(=6uu z_3(0$_}GCVJ0eQ8NxaYK9Lbs&YYn~A#>XDP+>~smtYG2}N5xb&|0ORe!Y_0NWXzb*PW$KoiMq8SbQ_+01TPajjUtci;!aT@+x z{ebnjmTzIPmTM(*HKZ=v-G`^4FGC{=mes^5N+N*_pC&$D_Y?i~>jiYOf~8$e<}~pa zF5f`EU)chAatnu>)6lp1!#OTBtON@Cums}EZVS#fp_xh-XJ?Cr1o-PGzf}4G`GgY) z5DbAO=HF)@K%J|ifg*&6`rs1jd&>fRHHfQ3OH5;l^s@!N&*?l(;wZ;y=*#S*-$3~* zAQ#9|>`CJ6hD>f6_IbV)Mu+WBa8~V#YpHhX~t7M5=)DuBXNO=(ob0Qg)oy(>bUj;`w$nXRTfdCbk`N;Zv!-0E?>SSkc7YA4!DY$7nroc@E;T2!Zd z*3!sOVlPgsLjS=%uL-9{jU7&oPmJMpBNYG})P@f9tyD)xN6#T&-Q?}7agy9?@V&R! z!My?Q&2Vpny93S!#nF^gze?x*pdy zJiqZ>kr+eGf%8@ z5cw=z@pS@)Z{MhE?uf*AzYo_lamA;A)EYSE8D};YpLjw`FcR$>Na1X;h0{1A~lW;5k2=U?KaD8wIxU1m`a5uo+26s2y z{csP$Jq-5<+@o+$!mW58;={$^`rs09SHl(HZh*TD?rymI;U0v0814}`(TlwU13R6K zdlLsQbhgBM;yn&lYp`Lmr^neihH=V1>_{5P6>4+Zck{Lj(eC{JDE|+0OsVsrIQmph zT1Xt_30=BC?)1M+xHKx~45hR`Z7FRbZ7XeT+aE__>vd51&$x~1t8Vyqgs08@1BCaV z{<%)V-HiWtL3eM4OAe1FD^+x#l6a*s0}mtuXEH}yDw$(~Sg^x8Vwr5I(wW<`{i061 zMB7=x(t0&Mt~zU#a%ZKS?wrJllbOz*E!|sp?AR>9b{`xb8SI?S=O)vedoTgevsvoL zmhLT`=}JwZ-Z=f^PEWjhOMHj4=-XApjdvnzjbi>I4Lr?<>C<&0NAE=DRz=YGH1@(L z*7%kt9_HWp7NSOQB{G7WakwaN8dUQnnw7}1Wjtdr5{=!0hmoel8E@p%$p*rfF_3E- zndI#;JZ{?mX589{k-KnDC-j&_%eq$ttab+njjjw4zu+V*<*Mw&M)zZucga%w@t@?Rn4#^w8&;_@HS ze|ZYeqs!lo`{w0Tuw~0<@ISWv(+G2hYI~Ou*}nWHvU~Y?XuccOij|1di$u<9-rYKf zN6m-$q-htzG+%o!Vz5}h27%^RuEDdW|3uj4BcBtGNb9?ZvJBkx1}2;Trg+4f-b7Nf zKZ1AT`nIO$5fw%eta1G+wKDQNB(Z87{~E~X)x2AsLDaR_iOjA0nt`3$G_HV zK|Jz}TMz{_4kOYEMtTf4z0EIg`Y&9YYgb7ks_7T-X+D|~6lr=8QJUwpRAWt7GCQxz zi(gyQmznYFHCol0px?eS{FqB_dJo+7a^pNU}zY-6pX^QA(otq1q9%KAlG}_qIMiQ^rXj4-SF`D0? zQCHJjiQc5qR?Xr!YZh+@L#{>46@<%?y$hNzfiffb?=M68RIE=DydeT>$iIT_n#W1} zeJEB#Y-NPfTp3}yDOKCC{K?jp8jttiai6E~FP*)(^mF$uUSy0z)oh!gF39I223Ygcp&gE3C*1_`vSMFMp)P|IJ! zFS?b)RO^qJQaj7gx>XW=J03URPV&oI?*QS(3vOY!QF?ZKgr2WN;K;Jp>v7+>@r!)& zCkWBd+&YMq8!r@EALi{#zDLjVn3HJh4ZOUR)LUOh>YK>d)~}Q7=396>0I$X#TD{h9 zFx@TZQ-Ka4T5MVC9){Z?p0|_GPI|U(;O$LvTjcG{Lg*h!=oYzU>(=;s=DPJdvgZvF z_5t4BDgo|e*f+}UCWd{pD_Y6k4rSZSHfP& z+k52p_eu9&VaZz=?E{jt_weZlC1?B=VB`Jr^itkFAW!)@z{Wopy7y8@A7kUvdV*06-mPXJ zgr!YreGSrS{>WYlOVw^2gI{zTD@N--^Y&#_LCQr%w@V4$g>prAh#KAnujtNO;P?EK zh}&?^JD5K8U@RL}HJ^$9O)Jh_(XnC;1lYKyp(17T0h*SprWL#$Ub7t&43P%-4X=ST*Qwz(oe0o;0RptP_ThFJZe#j3_Iw|WGtSmD zqKw$$5rn!JA5ce+4#eGbmv2Oz^FVY3bHfyLepaqjtrB|G^YHw|ZH%}&io7UwCcV)7 zY!Gyo_D2J?29$c+V9J?gXy8_z8&G+9TO%h;gf9V}fKNVrndl~uS7>PX^@B{V6MOPY(2|B0KX;gqo8B%P<)^NPQV=9CUraR5yCyZ)G zAJc^zVJ=-P991e;$W`NMWI>MHt;A>0Zds}GPJjUBsn-VJ}@?XU}AI(R4s+6A`f;iSDhNp zSDD7U19+vOs$4*=L1+wxK|fOwsyOYOXHVm?q|KvwagYDCEUpC{no_EmLUvyyF|Y|Z zS;*oPXPn}WbBqy6CqG#&9!nc4#i=O?i!T7YN^=CY5u~g-Bee?F_tJ%`4yIFaADR+R z=8xDAxV5DACa16$(ge{-3-8ORLIuapBUfZ%vPQY!YD8h!X62yc>C@eldg%^ftHmT& zxfmOfO%l0`Qb$q#Jcq{*o$CQcRB%2e}s=_l`L##BBv4V^YA;W_THf;q{T zZE)+4H&Kcgl%9tcW@+QiLBqIjI}8CdE}DdZ*uw8pZo+oB;KC{L+sWE!Zl zP&iRdX$2&L(ed%*NIyPskxc4}WAt~b5`f6Ou94TdrU=!^Ew{_2;LMq1M?N4z^MTMh z$;9a3Zh&;Ym_8yo@stCmPUPulC-!;pI}%bqD~N)Z2_zPZYBFod?jPC@x-cW=xzD)h z`fuamgHmp8MlZ#!EiRw$m3nLx8Q4%`C`G~qN?5@g!w zo0QSqi!Z|Y%jQ=C7*3uIV!1TDH!(Ukq^XbNsmo(6emtSM(IwF&HH&CotwHkDtbo<^ zE0E!M+6q<|-QSw za7M*5#|wz4uhlXRt}E2yX3;VLlJF~M^9-+VO8Kgavqq^ntBZ=`^|lJ*KY^~9di=&n>~UPt*L8o=*8o}%hw-6= zi@i1yi^0PIwm%N|`0Iva2afc(*2rNF2dCDbS31rwpwBJgxCVJ6BCR?@$7Pxf!~V<5 z;m}o-a9p#zeT81D#3T7JEPs39(A6n2U9L5L9gCRl@U-djIo$*t*C%<;HOeQ@oj!nj z=Gmr;Tg5IcvLkW0#<>rRo?PR!^mxTkROR7pIIf9agK!Q!>Cf`na5dbMK8CikZg3+Q zkD%_4;rJ`T*>HEFKX)g>9biJ{$8dDl!`W~gDx89VF8G8AWWo@=7S4ua7q{)(N`a*N zv+2IUgd<-rLAXm0?iaq7$sH5pt-f$u@yWZb7dA+KjJJEwFCa5r%8nm++m3MiY#>~1 zy6?t4dBSj9+r1It9>YE5!5_o1`1iqCdi)|==_L*F9FOH^={*2s!_6Vw+ydeFQEnUV zMufW&;VcajwD*7E3&*wan-R_-lgy9d=spL>e6k#W{OM@yk2f{Q`a7WfEWN)3V!HOn zaNRz7*6(2iu=fmmGTxx(Y$RNn7JuJ`^M^ZtHJJ|a(f_R9zl6fo5bkE*_7)rN-$UX4 zeMf`ZZasZ|%ka$iSao0Apk7_49BV@1KD?_z7Ls)CJU%-nT$l0q62g6oieY|Ci;jB^ z$YcAvVX#5Hlpf}1Z+Z1)NB!q38dMi5+&VnZz)>En;8=J4^fpa4DB2GDv-B+XUuiFi zF)EkGw2K<+lxhDo)+x}=X{@z@_Do}~?RJj@7Pa_T?34DV<<)yFG?r+x2Sa0)LWy0` zSPPc+Lt|PZy>zHCCN=P*J^NuT7>!VLj8Bi(7hciN>1YtT!5Sj>G#k1uP}$(Gq*VCUuSnaMz?>5W;?oNB{Fe z{x1yS^F#PWA?$?kxeO`gu}BO_Q&{7 zR~}({_k{9uB82}YgufHQr+`nc#|LAPDVFc&A%89wziwMJRy6)=U}AS&6palT+yVSL z;1Pqj13&*|(HJcQ>2Yl}v%?FY27W)V4bP1SjeXHr*@S;1a25EUz$nJQ3wY;nGJ@w`D!1uu({}A|0xUU1B0A~4!e*k<9!qYNgwq5-a_#yc7=o|V+ zK&bT5NQ~Drkv`YckDZLf-Y@=bYAx_dgzqxpHvpdk{=UI41CCx0jTO+eF#dkv>L-vs z@=yFbz)$$nD*(r^7w)s-4_*S_b$(R#3Nrj1z#n@-G)6uWe*kzb!rx}n`wZ}!UC|i( zBJ}?|;BRe@#;!2<5#Wso&%O`K_ZaYY;GBuS3{B!bVqEFJ7S}_-e{TFY0e}8yk=T?; ze+Tdk{0EKyDDc@|#@6oq<%3!w*tqow{g9R&o#QW!2JgQ zDe$0Ae?JYp5&l*lUjg0@%>E$r^H0G0fS)k&{|)#M@CJjIq094wi=#2N+)UpAei-$6 z*x+rz=XOG$3_laVGl+kYiGL07958zdOm7DGuLq*BeJ1`Ku_1Mttz!Cqk#e<$$Yjz(iMCO+3w-*j&zcB}Cp1HKROt^BLN zy^sgI)#}Do>b1B#0sq|+9(&P%U%xLJyUN7BA2@^ZZZ-HpVwCTCgTD&=-V@lPY101= z@Iy>b_yt`9J_&rSk?${oPXT94dd+7*|A4trOL?pWj$yCs0pouz@Lz9=#@LRKzZU_o zg}>&XQkMd61U_!!Uj@w78AM0;7L@|t4u5MO%D}t8pZ((Brd|Vl4D#3MwW+rQ?_+pF z?;hY3+6PU)O`QOKALJP~@&70AA%vec;lBqw1AM9YEAWB)U?NK>Px`;5Wi~j|4raSz;843ehNGTe2Kxo2IjmApvVU-RCDmZ%lNkd-wHf# z=$#Av&R3xRn*4VI-*P$jg&I5nT>5MzRxlpu^d15JEbLd+r1vQB zDfnCa`fK1PfWL0iTaF=Q>^;zTgI@$Z`~>Wcq}Qe{1pX-6+b z?HLw>fwu$e@VJmuQK%i19%Sjmxf={O^exoeFCxAa{!oL&v4)mXnnDTu9*xz1#2KXU_xApm9 z;H{|7x_-5(M}YI_Kj%&SCxGqvn(bX=CGv4!Bz6__nE5#a_$27z)fM6I3xR*&(~lnD zQ}9P{@gD=e_MS-WYli+cz}tQpiM`s$_XzM42>)vn{#M}Fdn2YjQ|cYS{_@-lycYge zA07nm0KX3y`VRrG_toE%z#9?%3r0Ra1>O$KaUJc)e-VEJ`efwO2ElG!i~45rcOGyz z?7ihzH}FgTBog~qlin_1n?DEr@qNG%^bhVd{z>2l)JJYiCI5~A??d`sf>F1D4*~1` z6=VrK13X~--w$l(U(Qs^)dRpk_+ljXdnSJ;faehY#U}jU0N)Dy7E`|O0N)90h89 z(HN#@rMyRgPr=`|FE;@}@FC!D8hkPE4Df##JOVri z{67p%0)H0rJX>&^Dgd7Y{l3iL8-Q(pknQD7z_%j4?k}M~1?;b1cLDz!+Mi()|HHul zjQ;dGqmQ2j=6o`|(ck|0Q{Mo-6ZAeQ;Sm=2!)RaW&-(fk;1529@sNrC3*h?@-paof z9sLu)w!e$bOX?xuQA2M%@O{4adMofrrf2xM2ly25g(mz2@DspRUvj|TM}P6K__wJW zfp?q}HTJ4ay%YG#Z$)BX#JGm_;ZJ~nj`8`33IB267}`r)zyBKeO^2efPZ|Gj0^9n= z^8O5XEyBOl-41*R;s2M(-}`{=&%wPRJrAWA8nxvYakdpIZrVC*5?p zQcdau`fxN#0le`&;Y-QEC)fg(wNH4^2kvJ}c-@;Ph)YBhg>NA9Hi5N#*_yVeoXyI6 z$$W})jxv>bPloZycZkVGWuP&fD{?f;JNNMrzFD2i24nNt@jB6QdLy>JSb`EtKPvM@ z=t_1gi=*?+gX>Y4^mLBL_Cc^+3a2%21Jxy$>>U~2J&^3dBYavc@5fSPekzgs?<#8c z2o4SM``eQT74|KlY&?`t&V@g7qJ^f4y(HML z0)|MzNosGldO1F{D_nOU4)C+112d30cBGaII6TEq&ho53oe#)Kc!<-H)KrFtrFc=g z)q$b?NqHSVIhiXaB|l?Bm#MMw{-o@=<@OwGO_OkZi$8flpH6Zqp6T-F6J0ffaFhi; zv@0ic=nXY{`v*pN-W3XS01U7A_=pdr%4QIo={=C@a0OXc$-%?m^zZa0pqhCPl52c)_qbqrK%J_QBY~CAnu4c7@-C5!q6o%xRm-{S1{C zya2}8Odf=?yR4=5UBS-_jn=BnTY5H-x5|+uPKZ_5&{WC#^K5CMsFVq|Ste(W>C+Ho ziyQXwXVnxAi6~U3{PDQ=aC+AN#8YJK6f(S}2=qxJS^_A2ws6!RYicTAtIYVHltOvz zcFQZ8bFd&s9#DWmkN!-?t>si%_W+_Xebf-P#Bwv3KdGV14!vKIRK*#6`LqZO4tdB9b;~6$zFdR=RO27N22>uQgz&*j6T6bhLLIa;V^ee zS$Qx7JTI3$xuPtTd@5hUek^SE^_PNCQk6pY1Vl1Xl>b788Zl5T9aq=ZDph{q5<7nJ zQP;%y_z28(Cdsxfm7m5J7^^e0m1Loa-E32Aiz-FCxwC@8Qz5 zd?7Z8&7{IUw0nZIWP+urJL%$4 z@&#<1j}ojeOg~*M=hc*}_*60}^giL*9<62`A(t11jlx5`zknUT{@ff*Rp#3mR?h>M z4joRWu%#SU5<4}M5=xuZ3XGMImzwG6fha*TImbNu)38z@r}ki%C0edBi~^44B%hR< znkcidCuqyjlB1=wRD|`~`l4CUUkRkVC4kG7DK%A?O`#LuWdtvbQ@E9Ez&?jXZ91If zI4eHe_<;V}Yz!uNhz;xuYnhw&!E$~O`~5Rne!fLCLJJhFfZpZL=*;BqVg|h)*d0${ z{7ooY-z0h+I57>idukp>r^2;LT3Fq?8ZNN)6gCbWnt;{87o(*~O!J#|=vcd)B-dzl zQ3s@JWmE*c%77UF#MWVtk6k#2imei5XSuw-dm^_|L3=g{5 zk!(xQ0|&!?v7%*Ir`lthjs%@=|zF{@V6Qy9ik7SQh0#Y#D zXOz;L%t_XhOw+Gu&`eem(N4ZK!|eNd2WSscdC{?e!j6*-T4b(;(7A*V!i@-c9O^&I zNnPv`CM)Ey6+0O;Fslt8TOFY|n3VyM?zfqyo*SwS4{hAbr78~~@kxA@!>u(C;snn6 z%FdUw}NtcfM15C~9)b)=iy3OHF`mF&lSq2oy zBu~TBqGVl!0rDPD0buEJseD4dRYk+)8>`T!!T9aRi5)lyl?G4}4pk+qI>I~D7Bsh@ zO9>XIGO0kuZBWA_*UFOhY)H@*WHZ8kL@1F;VLs=A-Hk4qJbqkaH@?Vqq%xSDO5tMS;pCRh-)$UiQz zg`s%IvsK-w>O;`xkjkZn;<3VjX}5;v&=vKK18rQ|A?XiH1*NQe%tkRyixDs(+FZK% z;!8#L1u@;v3LR*}1W9g4rcCN}oa*$YY%Zb4TH&W;pzY_J4Z?!R-~=rWjGfPpaLgUj z^5iRyCdcrJB$$u#Kpq`6ymx_jgV={kPU5XLUkk8>-_9&o*>D>5t(8hpG`v%YGH3Dj zqOJ9`J*@eGW_SMN0LJ{OfEi*5D6au_2Bk?c39$xMdkFfo3b-4|1mqF;z#i9<+r22MUyicmMzZ diff --git a/org.gridsite.core/src/roffit b/org.gridsite.core/src/roffit deleted file mode 100755 index d1c7263..0000000 --- a/org.gridsite.core/src/roffit +++ /dev/null @@ -1,370 +0,0 @@ -#!/usr/bin/env perl -# -# roffit: convert man page source files to HTML -# -# Read an nroff file. Output a HTML file. -# -# This is a very simple script, but I use it on very simple man pages and I've -# found no other script that makes beautiful web pages. -# -my $version = "0.3"; # (14 November 2003) -# Author: Daniel Stenberg -# Please email me improvements. -# -# You're free to do whatever you want with this script. -# -# Changes: -# -# 0.3 - Daniel Fandrich brought: -# o deal with .lp lines -# o .TH needs no section portion anymore -# o added generator meta tag in the header -# -# 0.2 - fixed the name for the SH section -# - added links from all words within \fIthis\fP or \fBthis\fP -# that has the same text as a .SH or .IP. -# - -use strict; -#use warnings; - -my $InFH = \*STDIN; -my $OutFH = \*STDOUT; -my $debugFH = \*STDERR; - -my %manpage; -my @out; - -my $indentlevel=0; # logical levels, not columns -my @p; -my $within_tp; -my $standalone=1; # by default we make stand-alone HTML pages -my $pre; -my %anchor; # hash with all anchors - -while($ARGV[0]) { - if($ARGV[0] eq "--bare") { - # don't include headers and stuff - $standalone=0; - shift @ARGV; - } - else { - printf $debugFH "unknown option: %s\n", $ARGV[0] if($ARGV[0] ne "-h"); - print $debugFH "Usage: roffit [options] < infile > outfile\n", - "Options:\n", - " --bare Do not put in HTML, HEAD, BODY tags\n"; - exit; - } -} - -sub showp { - my @p = @_; - push @out, "\n

    ", @p; -} - -sub defaultcss { - print $OutFH < -P.level0 { - padding-left: 2em; -} - -P.level1 { - padding-left: 4em; -} - -P.level2 { - padding-left: 6em; -} - -span.emphasis { - font-style: italic; -} - -span.bold { - font-weight: bold; -} - -span.manpage { - font-weight: bold; -} - -h2.nroffsh { - background-color: #e0e0e0; -} - -span.nroffip { - font-weight: bold; - font-size: 120%; - font-family: monospace; -} - -p.roffit { - text-align: center; - font-size: 80%; -} - -ENDOFCSS - ; -} - -sub text2name { - my ($text) = @_; - $text =~ s/^ *([^ ]*).*/$1/g; - $text =~ s/[^a-zA-Z0-9-]//g; - return $text; -} - -# scan through the file and check for sections we should convert -# to proper links -sub linkfile { - my @new; - for(@out) { - my $line=$_; - my $l; - while($line =~ s/([^<]*)<\/span>/[]/) { - my ($style, $name)=($1, $2); - - $l = text2name($name); - - #printf $debugFH "$style - $name - %s - %d\n", - #$l, $anchor{$l}; - - my $link; - if($anchor{$l}) { - $link="$name"; - } - else { - $link="$name"; - } - $line =~ s/\[\]/$link/; - } - push @new, $line; - } - return @new; -} - -sub parsefile { - - while(<$InFH>) { - my $in = $_; - my $out; - # print $debugFH "DEBUG IN: $_"; - - $in =~ s/[\r\n]//g if(!$pre); # tear off newlines - - if($in =~ /^\.([^ \n]*)(.*)/) { - # this is a line starting with a dot, that means it is special - my ($keyword, $rest) = ($1, $2); - $out = ""; - - # cut off initial spaces - $rest =~ s/^ +//g; - - if($keyword eq "\\\"") { - # this is a comment, skip this line - } - elsif($keyword =~ /^TH$/i) { - # man page header: - # curl 1 "22 Oct 2003" "Curl 7.10.8" "Curl Manual" - # NAME SECTION DATE VERSION MANUAL - if($rest =~ /([^ ]*) (\d+) \"([^\"]*)\" \"([^\"]*)\"(\"([^\"]*)\")?/) { - # strict matching only so far - $manpage{'name'} = $1; - $manpage{'section'} = $2; - $manpage{'date'} = $3; - $manpage{'version'} = $4; - $manpage{'manual'} = $6; - } - } - elsif($keyword =~ /^SH$/i) { - # Section Header - showp(@p); - @p=""; - if($pre) { - push @out, "\n"; - $pre = 0; - } - - my $name = text2name($rest); - $anchor{$name}=1; - - $rest =~ s/\"//g; # cut off quotes - $rest =~ s//>/g; - $out = "

    $rest

    "; - $indentlevel=0; - $within_tp=0; - } - elsif(($keyword =~ /^B$/i) || ($keyword =~ /^BI$/i)) { - # Make B and BI the same for simplicity - $rest =~ s/\"//g; # cut off quotes - $rest =~ s//>/g; - push @p, "$rest "; - } - elsif($keyword =~ /^I$/i) { - $rest =~ s/\"//g; # cut off quotes - $rest =~ s//>/g; - push @p, "$rest "; - } - elsif($keyword =~ /^RS$/i) { - # the start of another indent-level. for inlined tables - # within an "IP" - showp(@p); - @p=""; - $indentlevel++; - } - elsif($keyword =~ /^RE$/i) { - # end of the RS section - showp(@p); - @p=""; - $indentlevel--; - } - elsif($keyword =~ /^NF$/i) { - # We let nf start a
     section
    -                showp(@p);
    -                @p="";
    -                push @out, "
    \n";
    -                $pre=1
    -            }
    -            elsif($keyword =~ /^TP$/i) {
    -                # Used within an "RS" section to make a new line. The first
    -                # TP as a column indicator, but we decide to do that
    -                # controlling in the CSS instead.
    -                $within_tp=1;
    -                showp(@p);
    -                @p="";                
    -            }
    -            elsif($keyword =~ /^IP$/i) {
    -                # start of a new paragraph coming up
    -                showp(@p);
    -                @p="";
    -
    -                my $name= text2name($rest);
    -                $anchor{$name}=1;
    -
    -                $rest =~ s/\"//g; # cut off quotes
    -                $rest =~ s//>/g;
    -                
    -                $indentlevel-- if ($indentlevel);
    -                push @p, "$rest ";
    -                # make this a single-line title
    -                showp(@p);
    -                @p="";
    -                $indentlevel++;
    -                $within_tp=0;
    -            }
    -            elsif($keyword =~ /^ad$/i) {
    -                showp(@p);
    -                @p="";
    -            }
    -            elsif($keyword =~ /^sp$/i) {
    -                showp(@p);
    -                @p="";
    -            }
    -            elsif($keyword =~ /^lp$/i) {
    -                # marks end of a paragraph
    -                showp(@p);
    -                @p="";
    -            }
    -            elsif($keyword =~ /^pp$/i) {
    -                # PP ends a TP section, but some TP sections don't use it
    -                $within_tp=0;
    -            }
    -            elsif($keyword =~ /^so$/i) {
    -                # This keyword refers to a different man page, named in the
    -                # $rest.
    -                # We don't support this
    -                push @out, "See the $rest man page.\n";
    -            }
    -            elsif($keyword =~ /^BR$/i) {
    -                # I'm not sure what this does exactly, but this is commonly
    -                # used to include pointers to other man pages. Let's assume
    -                # it only does that for now.
    -                # blabla (3)
    -                # or "blabla (3)"
    -                # or strcmp "(3), " strcasecmp "(3)"
    -                # etc
    -                
    -                $rest =~ s/\"//g; # cut off quotes
    -                my @all = split /,/, $rest;
    -                for(@all) {
    -                    if(/([^ ]*) *\((\d+)\)/) {
    -                        # TODO: this looks like a man page, check if there's a
    -                        # HTML file for it and if so make a link to it
    -                    }
    -
    -                    push @p, "$_ ";
    -                }
    -            }
    -            else {
    -                showp(@p);
    -                print $debugFH "ALERT: unknown keyword \"$keyword\"\n";
    -            }
    -        }
    -        else {
    -            # text line, decode \-stuff
    -            my $txt = $in;
    -
    -            $txt =~ s//>/g;
    -            $txt =~ s/\\&//g; # cut off \&
    -            $txt =~ s/\\fI//g;
    -            $txt =~ s/\\fB//g;
    -            $txt =~ s/\\fP/<\/span>/g;
    -            $txt =~ s/\\//g;
    -
    -            if($txt =~ /^[ \t\r\n]*$/) {
    -                # no contents, marks end of a paragraph
    -                showp(@p);
    -                @p="";
    -            }
    -            else {
    -                $txt =~ s/^ /\ \;/g;
    -                push @p, "$txt ";
    -            }
    -            $out ="";
    -        }
    -
    -        if($out) {
    -            push @out, $out;
    -   #         print $debugFH "DEBUG OUT: $out\n";
    -        }
    -        else {
    -   #         print $debugFH "DEBUG OUT: [withheld]\n";
    -        }
    -    }
    -    showp(@p);
    -}
    -
    -parsefile();
    -
    -my @conv = linkfile();
    -
    -my $title=sprintf("%s man page",
    -                  $manpage{'name'}?$manpage{'name'}:"secret");
    -
    -if($standalone) {
    -    print $OutFH <
    -$title
    -
    -MOO
    -    ;
    -    defaultcss();
    -    print "\n";
    -}
    -
    -print $OutFH @conv;
    -print $OutFH <
    - This HTML page was made with roffit.
    -ROFFIT
    -    ;
    -
    -if($standalone) {
    -    print "\n";
    -}
    diff --git a/org.gridsite.core/src/urlencode.c b/org.gridsite.core/src/urlencode.c
    deleted file mode 100644
    index bea36a9..0000000
    --- a/org.gridsite.core/src/urlencode.c
    +++ /dev/null
    @@ -1,73 +0,0 @@
    -/*
    -   Copyright (c) 2002-3, Andrew McNab, University of Manchester
    -   All rights reserved.
    -
    -   Redistribution and use in source and binary forms, with or
    -   without modification, are permitted provided that the following
    -   conditions are met:
    -
    -     o Redistributions of source code must retain the above
    -       copyright notice, this list of conditions and the following
    -       disclaimer. 
    -     o Redistributions in binary form must reproduce the above
    -       copyright notice, this list of conditions and the following
    -       disclaimer in the documentation and/or other materials
    -       provided with the distribution. 
    -
    -   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
    -   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
    -   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    -   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    -   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
    -   BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    -   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
    -   TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    -   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    -   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    -   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    -   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    -   POSSIBILITY OF SUCH DAMAGE.
    -*/
    -
    -/*---------------------------------------------------------------*
    - * For more about GridSite: http://www.gridsite.org/             *
    - *---------------------------------------------------------------*/
    -
    -#include 
    -#include 
    -
    -#include "gridsite.h"
    -
    -int main(int argn, char *argv[])
    -{
    -  int    i;
    -
    -  if (argn == 1)
    -    {
    -      puts("urlencode [-m|-d] string-to-encode-or-decode");
    -      return 0;
    -    }
    -
    -  if      (strcmp(argv[1], "-d") == 0) /* decode */
    -   for (i = 2; i < argn; ++i) 
    -      {
    -        if (i > 2) fputs(" ", stdout);
    -        fputs(GRSThttpUrlDecode(argv[i]), stdout);
    -      }
    -  else if (strcmp(argv[1], "-m") == 0) /* mild encode */
    -   for (i = 2; i < argn; ++i) 
    -      {
    -        if (i > 2) fputs("%20", stdout);
    -        fputs(GRSThttpUrlMildencode(argv[i]), stdout);
    -      }
    -  else /* standard encode */
    -   for (i = 1; i < argn; ++i) 
    -      {
    -        if (i > 1) fputs("%20", stdout);
    -        fputs(GRSThttpUrlEncode(argv[i]), stdout);
    -      }
    -
    -  puts("");
    -
    -  return 0;
    -}
    -- 
    1.8.2.3
    
    
  • - -

    gLite Logging & Bookkeeping Server

    - -

    1. Release Description

    - -

    This release contains the gLite Logging & Bookkeeping -Server module v. 0.2.0. The following sections provide additional information about -the release content, the module dependencies, the know bugs and issues and a -list of bugs closed since the previous release. For information about -installing and using the gLite Logging & Bookkeeping Server, please refer -to the gLite Installation and User Guides.

    - -

    2. Release contents

    - -

    The gLite Logging & Bookkeeping Server v. 0.2.0 is -composed of the following gLite components:

    - -

     

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    Component name

    -
    -

    Version

    -
    -

    File

    -
    -

    org.glite.deployment.lb

    -
    -

    0.2.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/installers/glite-lb_installer.sh -

    -

    http://glite.web.cern.ch/glite/packages/I20041210/bin/rhel30/noarch/RPMS/glite-lb-config-0.2.0-1.noarch.rpm

    -
    -

    org.glite.deployment.config

    -
    -

    0.3.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/bin/rhel30/noarch/RPMS/glite- - config-0.3.0-1.noarch.rpm

    -
    -

    glite-lb-client-interface

    -
    -

    0.3.1

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/bin/rhel30/i386/RPMS/glite-lb-client-interface-0.3.1-2.i386.rpm

    -
    -

    glite-lb-common

    -
    -

    0.4.1

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/bin/rhel30/i386/RPMS/glite-lb-common-0.4.1-2.i386.rpm

    -
    -

    glite-lb-logger

    -
    -

    0.4.1

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/bin/rhel30/i386/RPMS/glite-lb-logger-0.4.1-3.i386.rpm

    -
    -

    glite-lb-server

    -
    -

    0.6.2

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/bin/rhel30/i386/RPMS/glite-lb-server-0.6.2-4.i386.rpm

    -
    -

    glite-lb-server-bones

    -
    -

    0.1.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/bin/rhel30/i386/RPMS/glite-lb-server-bones-0.1.0-1.i386.rpm

    -
    -

    glite-lb-ws-interface

    -
    -

    0.1.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/bin/rhel30/i386/RPMS/glite-lb-ws-interface-0.1.0-0.i386.rpm

    -
    -

    glite-security-proxyrenewal

    -
    -

    0.1.1

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/bin/rhel30/i386/RPMS/glite-security-proxyrenewal-0.1.1-1.i386.rpm

    -
    -

    glite-wms-utils-exception

    -
    -

    0.1.2

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/bin/rhel30/i386/RPMS/glite-wms-utils-exception-0.1.2-1.i386.rpm

    -
    -

    glite-wms-utils-jobid

    -
    -

    0.1.2

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/bin/rhel30/i386/RPMS/glite-wms-utils-jobid-0.1.2-1.i386.rpm

    -
    - -

     

    - -

    3. Dependencies

    - -

    The gLite Logging & Bookkeeping Server module has the -following dependencies:

    - -

     

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    Component name

    -
    -

    Version

    -
    -

    RPM file name

    -
    -

    gLite Security Utilities

    -
    -

    0.2.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041210/installers/glite-security-utils_installer.sh

    -
    -

    GPT

    -
    -

    VDT 1.2.0

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/gpt-VDT1.2.0rh9-1.i386.rpm

    -
    -

    VDT Globus Essentials

    -
    -

    VDT 1.2.0

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/vdt_globus_essentials-VDT1.2.0rh9-1.i386.rpm

    -
    -

    MySQL-server

    -
    -

    4.0.20

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/MySQL-server-4.0.20-0.i386.rpm

    -
    -

    MySQL-client

    -
    -

    4.0.20

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/MySQL-client-4.0.20-0.i386.rpm

    -
    -

    ares

    -
    -

    1.1.1

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/ares-1.1.1-EGEE.i386.rpm

    -
    -

    myproxy

    -
    -

    1.14

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/myproxy-1.14-EGEE.i386.rpm

    -
    -

    perl-Expect.pm

    -
    -

    1.01

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/per-Expect.pm-1.01-9.i386.rpm

    -
    - -

     

    - -

    4. Known bugs and issues

    - -

    This release has the -following bugs and issues. Bug numbers refer to the gLite Bug Tracking system -database hosted on the CERN Savannah system at https://savannah.cern.ch/bugs/?group=jra1mdw -.

    - -

     

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    Bug number

    -
    -

    Description

    -
    -

     #5125

    -
    -

    glite-lb-bkserverd - start/stop/status displays usage options 

    -
    -

     #5202

    -
    -

    no RPM provides the - lb-local-logger daemon -  

    -
    -

     #5248

    -
    -

    When running - "glite-lb-bkserverd start", glite-lb-bkserverd doesn't start in - background 

    -
    -

     #5833

    -
    -

    all jobs in SUBMITTED after a - job storm 

    -
    -

     #5903

    -
    -

    glite-lb-bkserverd script gives - bash: /root/.bashrc: Permission denied error  

    -
    -

     #5904

    -
    -

    glite-lb-bkserverd does not - check default location for credentials 

    -
    -

     #5926

    -
    -

    Default user should not be used - in the init.d scripts 

    -
    -

     #5932

    -
    -

    credential file created in - /var/tmp is unnecessary 

    -
    -

     #5934

    -
    -

    service start and stop notifications - are inconsistent for glite-lb-bkserverd init,d script 

    -
    - -

     

    - -

    No removal procedure is -provided with this release apart from the removal of the RPMS. Any account, -group or other resource created during the module configuration must be -manually cleaned.

    - -

     

    - -

    5. Bugs closed since last release

    - -

    This release fixes the -following bugs and issues. Since there are no previous public releases, this -list refers to the previous development release. Bug numbers refer to the gLite -Bug Tracking system database hosted on the CERN Savannah system at https://savannah.cern.ch/bugs/?group=jra1mdw - 

    - -

     

    - - - - - - - - - - - - - - - - - - - - - - -
    -

    Bug number

    -
    -

    Description

    -
    -

     #4627

    -
    -

    no licence found in lb packages 

    -
    -

     #5236

    -
    -

    LB install/config documentation - has some errors 

    -
    -

     #5912

    -
    -

    glite-lb-bkserver daemon looks - hangs is /tmp/mysql.sock is not present 

    -
    -

     #5930

    -
    -

    running start on started - service is not an error.  

    -
    - -

     

    - -

    6. Previous Releases

    - -

    6.1. Release 0.1.0

    - -

    6.1.1. Release Description

    - -

    This release contains the gLite Logging & Bookkeeping -Server module v. 0.1.0. The following sections provide additional information -about the release content, the module dependencies, the know bugs and issues -and a list of bugs closed since the previous release. For information about -installing and using the gLite Logging & Bookkeeping Server, please refer -to the gLite Installation and User Guides.

    - -

    6.1.2. Release contents

    - -

    The gLite Logging & Bookkeeping Server v. 0.1.0 is -composed of the following gLite components:

    - -

     

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    Component name

    -
    -

    Version

    -
    -

    File

    -
    -

    org.glite.deployment.lb

    -
    -

    0.1.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041126/installers/glite-lb_installer.sh -

    -

    http://glite.web.cern.ch/glite/packages/I20041126/bin/rhel30/noarch/RPMS/glite-lb-config-0.1.0-1.noarch.rpm

    -
    -

    org.glite.deployment.config

    -
    -

    0.1.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041126/bin/rhel30/noarch/RPMS/glite- - config-0.1.0-1.noarch.rpm

    -
    -

    glite-lb-client-interface

    -
    -

    0.3.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041126/bin/rhel30/i386/RPMS/glite-lb-client-interface-0.3.0-2.i386.rpm

    -
    -

    glite-lb-logger

    -
    -

    0.3.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041126/bin/rhel30/i386/RPMS/glite-lb-logger-0.3.0-3.i386.rpm

    -
    -

    glite-lb-common

    -
    -

    0.3.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041126/bin/rhel30/i386/RPMS/glite-lb-common-0.3.0-2.i386.rpm

    -
    -

    glite-lb-server

    -
    -

    0.5.2

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041126/bin/rhel30/i386/RPMS/glite-lb-server-0.5.2-4.i386.rpm

    -
    -

    glite-lb-server-bones

    -
    -

    0.1.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041126/bin/rhel30/i386/RPMS/glite-lb-server-bones-0.1.0-1.i386.rpm

    -
    -

    glite-wms-utils-jobid

    -
    -

    0.1.2

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041126/bin/rhel30/i386/RPMS/glite-wms-utils-jobid-0.1.2-1.i386.rpm

    -
    -

    glite-wms-utils-exception

    -
    -

    0.1.2

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041126/bin/rhel30/i386/RPMS/glite-wms-utils-exception-0.1.2-1.i386.rpm

    -
    -

    glite-security-proxyrenewal

    -
    -

    0.1.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041126/bin/rhel30/i386/RPMS/glite-security-proxyrenewal-0.1.0-1.i386.rpm

    -
    - -

     

    - -

    6.1.3. Dependencies

    - -

    The gLite Logging & Bookkeeping Server module has the -following dependencies:

    - -

     

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    Component name

    -
    -

    Version

    -
    -

    RPM file name

    -
    -

    gLite Security Utilities

    -
    -

    0.2.0

    -
    -

    http://glite.web.cern.ch/glite/packages/I20041126/installers/glite-security-utils_installer.sh

    -
    -

    GPT

    -
    -

    VDT 1.2.0

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/gpt-VDT1.2.0rh9-1.i386.rpm

    -
    -

    VDT Globus Essentials

    -
    -

    VDT 1.2.0

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/vdt_globus_essentials-VDT1.2.0rh9-1.i386.rpm

    -
    -

    MySQL-server

    -
    -

    4.0.20

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/MySQL-server-4.0.20-0.i386.rpm

    -
    -

    MySQL-client

    -
    -

    4.0.20

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/MySQL-client-4.0.20-0.i386.rpm

    -
    -

    ares

    -
    -

    1.1.1

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/ares-1.1.1-EGEE.i386.rpm

    -
    -

    myproxy

    -
    -

    1.14

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/myproxy-1.14-EGEE.i386.rpm

    -
    -

    perl-Expect.pm

    -
    -

    1.01

    -
    -

    http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/per-Expect.pm-1.01-9.i386.rpm

    -
    - -

     

    - -

    6.1.4. Known bugs and issues

    - -

    This release has the -following bugs and issues. Bug numbers refer to the gLite Bug Tracking system -database hosted on the CERN Savannah system at https://savannah.cern.ch/bugs/?group=jra1mdw -.

    - -

     

    - - - - - - - - - - - - - - -
    -

    Bug number

    -
    -

    Description

    -
    -

     #5125

    -
    -

    glite-lb-bkserverd - start/stop/status displays usage options 

    -
    -

     #5248

    -
    -

    When running - "glite-lb-bkserverd start", glite-lb-bkserverd doesn't start in - background 

    -
    - -

     

    - -

    No removal procedure is -provided with this release apart from the removal of the RPMS. Any account, -group or other resource created during the module configuration must be -manually cleaned.

    - -

     

    - -

    6.1.5. Bugs closed since last release

    - -

    This release fixes the -following bugs and issues. Since there are no previous public releases, this -list refers to the previous development release. Bug numbers refer to the gLite -Bug Tracking system database hosted on the CERN Savannah system at https://savannah.cern.ch/bugs/?group=jra1mdw - 

    - -

     

    - - - - - - - - - - - - - - -
    -

    Bug number

    -
    -

    Description

    -
    -

     #4627

    -
    -

    no licence found in lb packages 

    -
    -

     #5236

    -
    -

    LB install/config documentation - has some errors 

    -
    - -

     

    - -

     

    - -