From 4ab669f746bdfe4e32837be8e16b761c0490e21c Mon Sep 17 00:00:00 2001 From: snowdrop Date: Tue, 25 Mar 2003 22:14:36 +0000 Subject: initial import --- Doxyfile | 993 ++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 35 ++ doc/doxygen.css | 49 +++ doc/footer.html | 6 + doc/header.html | 20 + doc/images/logo02.gif | Bin 0 -> 5193 bytes ex1.c | 389 ++++++++++++++++++++ src/csoap.c | 37 ++ src/csoap.h | 55 +++ src/csoapbody.c | 96 +++++ src/csoapbody.h | 58 +++ src/csoapcall.c | 225 ++++++++++++ src/csoapcall.h | 90 +++++ src/csoapenv.c | 168 +++++++++ src/csoapenv.h | 86 +++++ src/csoaperror.h | 47 +++ src/csoapfault.c | 140 +++++++ src/csoapfault.h | 124 +++++++ src/csoaphttp.c | 153 ++++++++ src/csoaphttp.h | 45 +++ src/csoaplog.c | 65 ++++ src/csoaplog.h | 26 ++ src/csoapmethod.c | 70 ++++ src/csoapmethod.h | 56 +++ src/csoapparam.c | 384 +++++++++++++++++++ src/csoapparam.h | 187 ++++++++++ src/csoapres.c | 154 ++++++++ src/csoapres.h | 90 +++++ src/csoapsocket.c | 154 ++++++++ src/csoapsocket.h | 81 ++++ src/csoaptypes.h | 33 ++ src/csoapurl.c | 185 ++++++++++ src/csoapurl.h | 70 ++++ src/csoapxml.c | 151 ++++++++ src/csoapxml.h | 90 +++++ 35 files changed, 4612 insertions(+) create mode 100644 Doxyfile create mode 100644 Makefile create mode 100644 doc/doxygen.css create mode 100644 doc/footer.html create mode 100644 doc/header.html create mode 100644 doc/images/logo02.gif create mode 100644 ex1.c create mode 100644 src/csoap.c create mode 100644 src/csoap.h create mode 100644 src/csoapbody.c create mode 100644 src/csoapbody.h create mode 100644 src/csoapcall.c create mode 100644 src/csoapcall.h create mode 100644 src/csoapenv.c create mode 100644 src/csoapenv.h create mode 100644 src/csoaperror.h create mode 100644 src/csoapfault.c create mode 100644 src/csoapfault.h create mode 100644 src/csoaphttp.c create mode 100644 src/csoaphttp.h create mode 100644 src/csoaplog.c create mode 100644 src/csoaplog.h create mode 100644 src/csoapmethod.c create mode 100644 src/csoapmethod.h create mode 100644 src/csoapparam.c create mode 100644 src/csoapparam.h create mode 100644 src/csoapres.c create mode 100644 src/csoapres.h create mode 100644 src/csoapsocket.c create mode 100644 src/csoapsocket.h create mode 100644 src/csoaptypes.h create mode 100644 src/csoapurl.c create mode 100644 src/csoapurl.h create mode 100644 src/csoapxml.c create mode 100644 src/csoapxml.h diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..58d8030 --- /dev/null +++ b/Doxyfile @@ -0,0 +1,993 @@ +# 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 = csoap + +# 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 = doc/ + +# 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 = YES + +# 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 = YES + +# 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 = YES + +#--------------------------------------------------------------------------- +# 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 = src/ + +# 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 = csoap*.h + +# 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 = YES + +# 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 = YES + +#--------------------------------------------------------------------------- +# 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 = html + +# 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 = doc/header.html + +# 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 = doc/footer.html + +# 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 = doc/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 = YES + +# 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 = YES + +# 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 = NO + +# 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 = YES + +# 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 = 220 + +#--------------------------------------------------------------------------- +# 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 = YES + +# 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 = YES + +# 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 = YES + +# 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 = YES + +# 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/Makefile b/Makefile new file mode 100644 index 0000000..e523530 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +######################################################### +# +# CSOAP Makefile +# +######################################################### + +SHELL = bash +CC = gcc + + +VPATH = . src + +LIBNAME = libsoap.a +EXLIB = -L. -lsoap + +SOURCE = ${wildcard src/csoap*.c} +OBJECTS = $(addsuffix .o, $(basename $(SOURCE))) + +CFLAGS = `xml2-config --cflags` # -fwritable-strings +CLIBS = `xml2-config --libs` + +lib: $(OBJECTS) + ar -rc $(LIBNAME) $(OBJECTS) + +shared: $(OBJECTS) + gcc --shared -o libsoap.dll $(OBJECTS) `xml2-config --libs` + +example1: lib + $(CC) -Isrc $(CFLAGS) ex1.c -o $@ $(EXLIB) $(CLIBS) + +clean: + -@rm -f src/*.o + -@rm -f $(LIBNAME) + -@rm -f *~ + -@rm -f src/*~ \ No newline at end of file diff --git a/doc/doxygen.css b/doc/doxygen.css new file mode 100644 index 0000000..6f0f0d8 --- /dev/null +++ b/doc/doxygen.css @@ -0,0 +1,49 @@ +H1 { text-align: center; color: #1264A4; background-color: #F9C4CF} +CAPTION { font-weight: bold; color: #C40D29} +A.qindex {} +A.qindexRef {} +A.el { text-decoration: none; font-weight: bold; color: #1264A4} +A.elRef { font-weight: bold; color: #C40D29 } +A.code { text-decoration: none; font-weight: normal; color: #088741 } +A.codeRef { font-weight: normal; color: #088741 } +A:hover { text-decoration: none; background-color: #FFEB04 } +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: #FEF8AA; font-weight: bold; } +TD.mdname1 { background-color: #FEF8AA; font-weight: bold; color: #602020; } +TD.mdname { background-color: #FEF8AA; font-weight: bold; color: #602020; width: 600px; } +DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold; color: #C40D29} +DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller } +BODY { 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/doc/footer.html b/doc/footer.html new file mode 100644 index 0000000..d2b70e9 --- /dev/null +++ b/doc/footer.html @@ -0,0 +1,6 @@ + +
+csoap project homepage: http://csoap.sourceforge.net + + + diff --git a/doc/header.html b/doc/header.html new file mode 100644 index 0000000..3232ffd --- /dev/null +++ b/doc/header.html @@ -0,0 +1,20 @@ + + + +csoap + + + + + + + + + +
+
+

C library for SOAP (Simple Object Access Protocol)

+
+
+
+
diff --git a/doc/images/logo02.gif b/doc/images/logo02.gif new file mode 100644 index 0000000..571cbdd Binary files /dev/null and b/doc/images/logo02.gif differ diff --git a/ex1.c b/ex1.c new file mode 100644 index 0000000..fafef74 --- /dev/null +++ b/ex1.c @@ -0,0 +1,389 @@ +#include + +#include +#include + +const char *url = "http://redhat.com/register/rpc"; +const char *urn = "urn:AddressFetcher"; +/*const char *urn = "urn:connector_service";*/ +const char *method = "getAddressFromName"; +/*const char *method = "Login";*/ + +struct Phone +{ + int areaCode; + char *exchange; + char *number; +}; + +#define SOAP_TYPE_USER_PHONE "ns2:phone" + +struct Phone* PhoneCreate() +{ + struct Phone* phone; + + phone = (struct Phone*)malloc(sizeof(struct Phone)); + phone->exchange = NULL; + phone->number = NULL; + + return phone; +} + +void PhoneFree(struct Phone* phone) +{ + if (phone == NULL) return; + + if (phone->exchange != NULL) + free(phone->exchange); + if (phone->number != NULL) + free(phone->number); +} + +void PhoneDump(struct Phone* phone) +{ + printf("+ Phone\n"); + if (phone == NULL) { + printf("(null)\n"); + printf("+ End Phone \n"); + return; + } + + printf("\tareaCode = %d\n", + phone->areaCode); + printf("\texchange = %s\n", + phone->exchange?phone->exchange:"(null}"); + printf("\tnumber = %s\n", + phone->number?phone->number:"(null}"); + printf("+ End Phone \n"); +} + +struct Phone* PhoneDeserialize(HSOAPPARAM rootParam) +{ + HSOAPPARAM param; + struct Phone *result; + int size; + + result = PhoneCreate(); + + param = SoapParamGetChildren(rootParam); + + if (param == NULL) { + PhoneFree(result); + return NULL; + } + + if (!SoapParamTypeIs(param, SOAP_TYPE_INT)) { + PhoneFree(result); + return NULL; + } + + result->areaCode = SoapParamGetInt(param); + + param = SoapParamGetNext(param); + + if (param == NULL) { + PhoneFree(result); + return NULL; + } + + if (!SoapParamTypeIs(param, SOAP_TYPE_STRING)) { + PhoneFree(result); + return NULL; + } + + size = SoapParamGetString(param, NULL); + result->exchange = (char*)malloc(sizeof(char)*size+1); + SoapParamGetString(param, result->exchange); + + param = SoapParamGetNext(param); + + if (param == NULL) { + PhoneFree(result); + return NULL; + } + + if (!SoapParamTypeIs(param, SOAP_TYPE_STRING)) { + PhoneFree(result); + return NULL; + } + + size = SoapParamGetString(param, NULL); + result->number = (char*)malloc(sizeof(char)*size+1); + SoapParamGetString(param, result->number); + + return result; +} + + +struct Address +{ + char *city; + struct Phone *phone; + char *state; + char *streetName; + int streetNum; + int zip; +}; + +#define SOAP_TYPE_USER_ADDRESS "address" + +struct Address* AddressCreate() +{ + struct Address* address; + + address = (struct Address*)malloc(sizeof(struct Address)); + address->city = NULL; + address->phone = PhoneCreate(); + address->state = NULL; + address->streetName = NULL; +} + + +void AddressFree(struct Address* address) +{ + if (address == NULL) return; + + if (address->city) + free(address->city); + if (address->phone) + PhoneFree(address->phone); + if (address->state) + free(address->state); + if (address->streetName) + free(address->streetName); +} + +void AddressDump(struct Address* address) +{ + printf("+ Address\n"); + if (address == NULL) { + printf("(null)\n"); + printf("+ End Address \n"); + return; + } + + printf("\tcity = %s\n", + address->city?address->city:"(null}"); + PhoneDump(address->phone); + printf("\tstate = %s\n", + address->state?address->state:"(null}"); + printf("\tstreetName = %s\n", + address->streetName?address->streetName:"(null}"); + printf("\tstreetNum = %d\n", + address->streetNum); + printf("\tzip = %d\n", + address->zip); + printf("+ End Address \n"); +} + +struct Address *AddressDeserialize(HSOAPPARAM rootParam) +{ + HSOAPPARAM param; + struct Address *result; + int size; + + result = AddressCreate(); + + param = SoapParamGetChildren(rootParam); + + if (param == NULL) { + AddressFree(result); + return NULL; + } + + if (!SoapParamTypeIs(param, SOAP_TYPE_STRING)) { + AddressFree(result); + return NULL; + } + + size = SoapParamGetString(param, NULL); + result->city = (char*)malloc(sizeof(char)*size+1); + SoapParamGetString(param, result->city); + + + param = SoapParamGetNext(param); + + if (param == NULL) { + AddressFree(result); + return NULL; + } + + if (!SoapParamTypeIs(param, SOAP_TYPE_USER_PHONE)) { + AddressFree(result); + return NULL; + } + + result->phone = PhoneDeserialize(param); + + param = SoapParamGetNext(param); + + if (param == NULL) { + AddressFree(result); + return NULL; + } + + if (!SoapParamTypeIs(param, SOAP_TYPE_STRING)) { + AddressFree(result); + return NULL; + } + + size = SoapParamGetString(param, NULL); + result->state = (char*)malloc(sizeof(char)*size+1); + SoapParamGetString(param, result->state); + + param = SoapParamGetNext(param); + + if (param == NULL) { + AddressFree(result); + return NULL; + } + + if (!SoapParamTypeIs(param, SOAP_TYPE_STRING)) { + AddressFree(result); + return NULL; + } + + size = SoapParamGetString(param, NULL); + result->streetName = (char*)malloc(sizeof(char)*size+1); + SoapParamGetString(param, result->streetName); + + param = SoapParamGetNext(param); + + if (param == NULL) { + AddressFree(result); + return NULL; + } + + if (!SoapParamTypeIs(param, SOAP_TYPE_INT)) { + AddressFree(result); + return NULL; + } + + result->streetNum = SoapParamGetInt(param); + + param = SoapParamGetNext(param); + + if (param == NULL) { + AddressFree(result); + return NULL; + } + + if (!SoapParamTypeIs(param, SOAP_TYPE_INT)) { + AddressFree(result); + return NULL; + } + + result->zip = SoapParamGetInt(param); + + return result; +}; + + +int main2(int argc, char *argv[]) +{ + HSOAPURL url; + + url = SoapUrlCreate(argv[1]); + SoapUrlDump(url); + SoapUrlFree(url); + +}; + +int main(int argc, char *argv[]) +{ + HSOAPCALL call; + HSOAPRES result; + HSOAPPARAM res; + HSOAPFAULT fault; + struct Address* address; + char *str; + + printf("\nStarting %s ... \n", argv[0]); + + /* SoapInit(argc, argv);*/ + + call = SoapCallCreate((argc>1)?argv[1]:url, urn, method); + + SoapCallAddStringParam(call, "name", "John B. Good"); +/* SoapCallAddStringParam(call, "passwd", "openpdm");*/ +/* SoapCallAddStringParam(call, "system", "imanconnector703@pdmdev2_ImanServer");*/ + /*SoapCallAddIntParam(call, "age", 24);*/ + + if (result = SoapCallInvoke(call)) { + if (fault = SoapResGetFault(result)) { + SoapFaultPrint( stdout, fault); + } else { + printf("Checking result\n"); + res = SoapResGetParamChildren(result); + printf("Result = %p\n", res); + if (res != NULL) { + address = AddressDeserialize(res); + printf("Deserializing\n", res); + AddressDump(address); + AddressFree(address); + } else { + printf("Corrupt response!\n"); + } + } + } else { + printf("Result is null\n"); + } + + return 0; + + /* + if (SoapResIsFault(result)) { + } else { + res = SoapResGetFirstChild(result); + comments = SoapParamGetStringValue(res); + + } + */ +} + +/* + +struct Person +{ + char *name; + char *lastname; + int age; +}; + + +void SerializePerson(HSOAPPARAM parent, void* data) +{ + Person* person = (Person*)data; + + SoapParamCreateString(parent, "name", person->name); + SoapParamCreateString(parent, "lastname", person->lastname); + SoapParamCreateInt(parent, "", person->age); +} + + + +int main2(int argc, char *argv[]) +{ + HSOAPCALL call; + HSOAPRES result; + HSOAPPARAM res; + Person person = {"Ferhat", "Ayaz", 24}; + + SoapInit(argc, argv); + + call = SoapCallCreate(url, urn, method); + + SoapCallAddComplexParam(call, "person", "tns:person", + SerializePerson, &person); + + result = SoapCallInvoke(call); + + if (SoapResIsFault(result)) { + } else { + res = SoapResGetFirstChild(result); + comments = SoapParamGetStringValue(res); + + } +} + +*/ diff --git a/src/csoap.c b/src/csoap.c new file mode 100644 index 0000000..c880111 --- /dev/null +++ b/src/csoap.c @@ -0,0 +1,37 @@ +/****************************************************************** + * $Id: csoap.c,v 1.1 2003/03/25 22:17:18 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoap.h" + +#include "csoapxml.h" + + +/*----------------------------------------------------------------- + FUNCTION: SoapFreeStr +/-----------------------------------------------------------------*/ + +void SoapFreeStr(char* str) +{ + if (str) xmlFree(str); +} + diff --git a/src/csoap.h b/src/csoap.h new file mode 100644 index 0000000..6022265 --- /dev/null +++ b/src/csoap.h @@ -0,0 +1,55 @@ +/****************************************************************** + * $Id: csoap.h,v 1.1 2003/03/25 22:17:18 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_H +#define CSOAP_H + + +/* Include csoap headers */ +#include "csoapcall.h" +#include "csoapfault.h" +#include "csoapurl.h" +#include "csoaptypes.h" + +/** + * Initialize routine. Must be called before any + * other csoap API function. + * + * @param argc command line parameter + * @param argv command line parameter + * + * @return CSOAP_OK if successfull. + */ +int SoapInit(int argc, char *argv[]); + + +/** + * Free a string allocated by a csoap + * function. + * + * @param str the string to free + */ +void SoapFreeStr(char* str); + + +#endif diff --git a/src/csoapbody.c b/src/csoapbody.c new file mode 100644 index 0000000..8fb35bd --- /dev/null +++ b/src/csoapbody.c @@ -0,0 +1,96 @@ +/****************************************************************** + * $Id: csoapbody.c,v 1.1 2003/03/25 22:17:18 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoapbody.h" +#include "csoaplog.h" + + +/*----------------------------------------------------------------- + FUNCTION: SoapBodyGetMethod +/-----------------------------------------------------------------*/ + +HSOAPMETHOD SoapBodyGetMethod(HSOAPBODY body, const char* method) +{ + HSOAPXML node; + const char* FUNC = "SoapBodyGetMethod"; + SoapTraceEnter(FUNC,"Method = %s", method); + + if (body == NULL) { + SoapLog(LOG_ERROR, FUNC, + "Invalid body (null)"); + return NULL; + } + + SoapLog(LOG_DEBUG, FUNC, "Searching method '%s'", method); + + node = SoapXmlFindNode((HSOAPXML)body, method); + if (node == NULL) { + SoapTraceLeaveWithError(FUNC, "Can not find method"); + return NULL; + } +/* + cur = ((xmlNodePtr)body)->xmlChildrenNode; + while (cur != NULL) { + if (!xmlStrcmp(cur->name, (const xmlChar*)method)) { + SoapTraceLeave(FUNC, "Found method (%p)", cur); + return (HSOAPMETHOD)cur; + } + cur = cur->next; + } +*/ + SoapTraceLeave(FUNC, "Method (%p)", node); + return node; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapBodyGetFault +/-----------------------------------------------------------------*/ + +HSOAPFAULT SoapBodyGetFault(HSOAPBODY body) +{ + HSOAPXML node; + const char* FUNC = "SoapBodyGetFault"; + SoapTraceEnter(FUNC,"Body (%p)", body); + + if (body == NULL) { + SoapLog(LOG_ERROR, FUNC, + "Invalid body (null)"); + return NULL; + } + +/* + cur = ((xmlNodePtr)body)->xmlChildrenNode; + while (cur != NULL) { + if (!xmlStrcmp(cur->name, (const xmlChar*)"Fault")) { + SoapTraceLeave(FUNC, "Found fault (%p)", cur); + return (HSOAPFAULT)cur; + } + cur = cur->next; + } +*/ + + node = SoapXmlFindNode((HSOAPXML)body, "Fault"); + SoapTraceLeave(FUNC, "Fault (%p)", node); + return node; +} diff --git a/src/csoapbody.h b/src/csoapbody.h new file mode 100644 index 0000000..619c2c4 --- /dev/null +++ b/src/csoapbody.h @@ -0,0 +1,58 @@ +/****************************************************************** + * $Id: csoapbody.h,v 1.1 2003/03/25 22:17:18 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_BODY_H +#define CSOAP_BODY_H + +#include "csoapmethod.h" +#include "csoapfault.h" + +typedef HSOAPXML HSOAPBODY; + + + +/** + * Returns the method object assigned to + * the given body. + * + * @param body handle to the body object + * @param method the method(operation) name + * to call. + * + * @return a handle to the method object or + * NULL if the the method was not found. + */ +HSOAPMETHOD SoapBodyGetMethod(HSOAPBODY body, const char *method); + + +/** + * Returns the fault object if any exist. + * + * @param body handle to the body object + * @return a handle to a fault object or + * NULL if no fault was generated. + */ +HSOAPFAULT SoapBodyGetFault(HSOAPBODY body); + + +#endif diff --git a/src/csoapcall.c b/src/csoapcall.c new file mode 100644 index 0000000..aa211c1 --- /dev/null +++ b/src/csoapcall.c @@ -0,0 +1,225 @@ +/****************************************************************** + * $Id: csoapcall.c,v 1.1 2003/03/25 22:17:19 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoapcall.h" +#include "csoaplog.h" +#include "csoaphttp.h" + +#include + + +HSOAPCALL SoapCallCreate( + const char* url, + const char* uri, + const char* method) +{ + const char *FUNC = "SoapCallCreate"; + HSOAPCALL call; + + SoapTraceEnter(FUNC, "url=%s;uri=%s;method=%s", + url, uri, method); + call = (HSOAPCALL)malloc(sizeof(struct SOAPCALL)); + call->m_method = (char*)malloc(strlen(method)+1); + + call->m_env = SoapEnvCreate(uri, method); + call->m_url = SoapUrlCreate(url); + strcpy(call->m_method, method); + + SoapTraceLeave(FUNC, "call (%p)", call); + return call; +} + + +HSOAPPARAM SoapCallAddParam( + HSOAPCALL call, + const char* name, + const char* type, + const char* format, + ...) +{ + const char *FUNC = "SoapCallAddParam"; + HSOAPBODY body; + HSOAPMETHOD method; + HSOAPPARAM param, result; + va_list ap; + char buffer[SOAP_MAX_STRING_BUFFER]; + + SoapTraceEnter(FUNC, "name=%s;type=%s;format=%s", + name, type, format); + + va_start(ap, format); + vsprintf(buffer, format, ap); + va_end(ap); + + body = SoapEnvGetBody(call->m_env); + method = SoapBodyGetMethod(body, call->m_method); + param = SoapMethodParamContext(method); + result = SoapParamCreate(param, type, NULL, name, "%s", buffer); + + SoapTraceLeave(FUNC, "created param (%p)", result); + return result; +} + + +HSOAPPARAM SoapCallAddStringParam( + HSOAPCALL call, + const char* name, + const char* format, + ...) +{ + const char *FUNC = "SoapCallAddStringParam"; + HSOAPBODY body; + HSOAPMETHOD method; + HSOAPPARAM param, result; + va_list ap; + char buffer[SOAP_MAX_STRING_BUFFER]; + + SoapTraceEnter(FUNC, "name=%s;format=%s", + name, format); + + va_start(ap, format); + vsprintf(buffer, format, ap); + va_end(ap); + + body = SoapEnvGetBody(call->m_env); + method = SoapBodyGetMethod(body, call->m_method); + param = SoapMethodParamContext(method); + result = SoapParamCreateString(param, name, buffer); + SoapTraceLeave(FUNC, "created param (%p)", result); + return result; +} + + +HSOAPPARAM SoapCallAddIntParam( + HSOAPCALL call, + const char* name, + int value) +{ + const char *FUNC = "SoapCallAddIntParam"; + HSOAPBODY body; + HSOAPMETHOD method; + HSOAPPARAM param, result; + + SoapTraceEnter(FUNC, "name=%s;value=%d", + name, value); + + body = SoapEnvGetBody(call->m_env); + method = SoapBodyGetMethod(body, call->m_method); + param = SoapMethodParamContext(method); + result = SoapParamCreateInt(param, name, value); + SoapTraceLeave(FUNC, "created param (%p)", result); + return result; +} + +HSOAPPARAM SoapCallAddDoubleParam( + HSOAPCALL call, + const char* name, + double value) +{ + const char *FUNC = "SoapCallAddDoubleParam"; + HSOAPBODY body; + HSOAPMETHOD method; + HSOAPPARAM param, result; + + SoapTraceEnter(FUNC, "name=%s;value=%f", + name, value); + + body = SoapEnvGetBody(call->m_env); + method = SoapBodyGetMethod(body, call->m_method); + param = SoapMethodParamContext(method); + result = SoapParamCreateDouble(param, name, value); + SoapTraceLeave(FUNC, "created param (%p)", result); + return result; +} + + +HSOAPRES SoapCallInvoke(HSOAPCALL call) +{ + const char* FUNC = "SoapCallInvoke"; + SoapTraceEnter(FUNC,"%p", call); + const char* filename = "csoap-client.xml"; + char *buf; + CSOAP_STATUS status; + HSOAPENV env; + HSOAPRES res; + + if (!call) { + SoapTraceLeaveWithError(FUNC, "Call is null!"); + return NULL; + } + + if (!call->m_env) { + SoapTraceLeaveWithError(FUNC, "Invalid envelope!"); + return NULL; + } + + if (!call->m_url) { + SoapTraceLeaveWithError(FUNC, "Invalid URL"); + return NULL; + } + +/* xmlSaveFormatFile(filename, ((xmlNodePtr)call->m_env)->doc, 1); + buffer = xmlBufferCreate(); + xmlNodeDump(buffer, ((xmlNodePtr)call->m_env)->doc, + (xmlNodePtr)call->m_env, 1 ,2); + printf("\n%s\n", (const char*)xmlBufferContent(buffer)); + xmlBufferFree(buffer); +*/ + + printf("Sending ...\n"); + status = SoapHttpSend(call->m_url, call->m_env, &env); + if (status != CSOAP_OK) { + printf("can not send. code = %d\n", status); + } + printf("Sending finished\n"); + /* + printf("Length: %d\nResponse: \n%s\n\n\r", strlen(buf), buf?buf:"null"); + */ + SoapEnvDump(env); + /* free(buf);*/ + /* SoapEnvFree(env);*/ + res = SoapResCreate(env, call->m_method); + SoapTraceLeave(FUNC, "res (%p)", res); + return res; +} + + +void SoapCallFree(HSOAPCALL call) +{ + const char* FUNC = "SoapCallFree"; + SoapTraceEnter(FUNC,"%p", call); + + if (!call) { + SoapTraceLeave(FUNC, "Call is null!"); + return; + } + + SoapEnvFree(call->m_env); + + if (call->m_url) SoapUrlFree(call->m_url); + if (call->m_method) free(call->m_method); + + free(call); + SoapTraceLeave(FUNC, "Call destroyed"); +} + diff --git a/src/csoapcall.h b/src/csoapcall.h new file mode 100644 index 0000000..eba568b --- /dev/null +++ b/src/csoapcall.h @@ -0,0 +1,90 @@ +/****************************************************************** + * $Id: csoapcall.h,v 1.1 2003/03/25 22:17:19 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_CALL_H +#define CSOAP_CALL_H + +#include "csoapparam.h" +#include "csoapres.h" +#include "csoapenv.h" +#include "csoapurl.h" + +typedef struct SOAPCALL* HSOAPCALL; + + +/** + * Stores information to + * send a soap call + */ +struct SOAPCALL +{ + HSOAPENV m_env; /* The soap envelope */ + HSOAPURL m_url; /* The target URL */ + char* m_method; /* The method to to call */ +}; + + +HSOAPCALL SoapCallCreate( + const char* url, + const char* uri, + const char* method +); + + +HSOAPPARAM SoapCallAddParam( + HSOAPCALL call, + const char* name, + const char* type, + const char* format, + ... +); + + +HSOAPPARAM SoapCallAddStringParam( + HSOAPCALL call, + const char* name, + const char* format, + ... +); + + +HSOAPPARAM SoapCallAddIntParam( + HSOAPCALL call, + const char* name, + int value +); + + +HSOAPPARAM SoapCallAddDoubleParam( + HSOAPCALL call, + const char* name, + double value +); + + +HSOAPRES SoapCallInvoke(HSOAPCALL call); + +void SoapCallFree(HSOAPCALL call); + + +#endif diff --git a/src/csoapenv.c b/src/csoapenv.c new file mode 100644 index 0000000..90bcbac --- /dev/null +++ b/src/csoapenv.c @@ -0,0 +1,168 @@ +/****************************************************************** + * $Id: csoapenv.c,v 1.1 2003/03/25 22:17:19 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoapenv.h" +#include "csoaplog.h" + +static char *soap_env_ns = "http://schemas.xmlsoap.org/soap/envelope/"; +static char *soap_env_enc = "http://schemas.xmlsoap.org/soap/encoding/"; +static char *soap_xsi_ns = "http://www.w3.org/1999/XMLSchema-instance"; +static char *soap_xsd_ns = "http://www.w3.org/1999/XMLSchema"; + +/* + Parameters: + 1- soap_env_ns + 2- soap_env_enc + 3- xsi_ns + 4- xsd_ns + 3- method name + 4- uri + 5- method name(again) + */ +#define SOAP_MSG_TEMPLATE \ + "" \ + " "\ + " "\ + " " \ + " "\ + "" + + + +/*----------------------------------------------------------------- + FUNCTION: SoapEnvCreate +/-----------------------------------------------------------------*/ + +HSOAPENV SoapEnvCreate(const char *uri, const char *method) +{ + xmlDocPtr env; + xmlNodePtr node; + char buffer[1054]; + + const char* FUNC = "SoapEnvCreate"; + + SoapTraceEnter( FUNC, + "URI = '%s'\nMethod = '%s'", + uri, method); + + sprintf(buffer, SOAP_MSG_TEMPLATE, + soap_env_ns, soap_env_enc, soap_xsi_ns, + soap_xsd_ns, method, uri, method); + + env = xmlParseDoc(buffer); + if (env == NULL) { + SoapLog(LOG_ERROR, FUNC, + "Can not create xml document!"); + return NULL; + } + + node = xmlDocGetRootElement(env); + if (node == NULL) { + SoapLog(LOG_ERROR, FUNC, + "xml document is empty!"); + return NULL; + } + + SoapLog(LOG_DEBUG, FUNC, + "Envelope created successfully"); + + SoapTraceLeave(FUNC, "Envelope: %p", node); + + return (HSOAPENV)node; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapEnvGetBody +/-----------------------------------------------------------------*/ + +HSOAPBODY SoapEnvGetBody(HSOAPENV envelope) +{ + xmlNodePtr cur; + const char* FUNC = "SoapEnvGetBody"; + SoapTraceEnter(FUNC,""); + + if (envelope == NULL) { + SoapLog(LOG_ERROR, FUNC, + "Invalid envelope (null)"); + return NULL; + } + + cur = ((xmlNodePtr)envelope)->xmlChildrenNode; + while (cur != NULL) { + if (!xmlStrcmp(cur->name, (const xmlChar*)"Body")) { + SoapTraceLeave(FUNC, "Found Body (%p)", cur); + return (HSOAPBODY)cur; + } + cur = cur->next; + } + + SoapTraceLeave(FUNC, "No body found!"); + return NULL; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapEnvFree +/-----------------------------------------------------------------*/ + +void SoapEnvFree(HSOAPENV envelope) +{ + const char* FUNC = "SoapEnvFree"; + SoapTraceEnter(FUNC,"%p", envelope); + + if (!envelope) { + SoapTraceLeave(FUNC, "Envelope is null!"); + return; + } + + xmlFreeDoc(((xmlNodePtr)envelope)->doc); + SoapTraceLeave(FUNC, "Envelope destroyed"); +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapEnvDump +/-----------------------------------------------------------------*/ + +void SoapEnvDump(HSOAPENV env) +{ + const char *FUNC = "SoapEnvDump"; + + xmlBufferPtr buffer; + xmlDocPtr doc; + char *str; + + SoapTraceEnter(FUNC, "env (%p)", env); + + buffer = xmlBufferCreate(); + xmlNodeDump(buffer, ((xmlNodePtr)env)->doc, (xmlNodePtr)env, 1 ,1); + str = (char*)xmlBufferContent(buffer); + + printf("%s\n", str?str:"null"); + + xmlBufferFree(buffer); + SoapTraceLeave(FUNC, "Leaving"); +} diff --git a/src/csoapenv.h b/src/csoapenv.h new file mode 100644 index 0000000..5455e69 --- /dev/null +++ b/src/csoapenv.h @@ -0,0 +1,86 @@ +/****************************************************************** + * $Id: csoapenv.h,v 1.1 2003/03/25 22:17:19 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_ENV_H +#define CSOAP_ENV_H + +#include "csoapxml.h" +#include "csoapbody.h" + +typedef HSOAPXML HSOAPENV; + + +/** + * Creates a new soap envelope object + * + * @param uri the URI + * @param method the method name to call + * + * @return handle to an envelope object if + * creation was successfull or NULL otherwise. + */ +HSOAPENV SoapEnvCreate(const char *uri, const char *method); + + +/** + * Creates a new soap envelope object + * + * @param uri the URI + * @param method the method name to call + * + * @return handle to an envelope object if + * creation was successfull or NULL otherwise. + */ +HSOAPENV SoapEnvCreateWithFault(const char *uri, const char *method); + + +/** + * Returns the soap body object to + * a given envelope object. + * + * @param envelope the envelope + * @return handle to a body object if + * any exist or NULL otherwise + */ +HSOAPBODY SoapEnvGetBody(HSOAPENV envelope); + + +/** + * Free a given envelope object + * + * @param envelope the envelope object + * to free + */ +void SoapEnvFree(HSOAPENV envelope); + + +/** + * Dumps an envelope object to the stdout. + * For debug puposes only. + * + * @param env the envelope object to dump + */ +void SoapEnvDump(HSOAPENV env); + + +#endif diff --git a/src/csoaperror.h b/src/csoaperror.h new file mode 100644 index 0000000..8b75291 --- /dev/null +++ b/src/csoaperror.h @@ -0,0 +1,47 @@ +/****************************************************************** + * $Id: csoaperror.h,v 1.1 2003/03/25 22:17:20 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_ERROR_H +#define CSOAP_ERROR_H + +typedef int CSOAP_STATUS; + +/* Ok status */ +#define CSOAP_OK 0 + +/* Socket related errors */ +#define ERROR_SOCKET_CAN_NOT_GET_HOSTNAME 100001 +#define ERROR_SOCKET_CAN_NOT_CONNECT 100002 +#define ERROR_SOCKET_CAN_NOT_CREATE_SOCKET 100003 +#define ERROR_SOCKET_CAN_NOT_RECEIVE 100004 +#define ERROR_SOCKET_CAN_NOT_SEND 100005 + + +/* Generic errors */ +#define ERROR_NO_MEM 110001 + + +/* xml related error */ +#define ERROR_XML_CAN_NOT_PARSE 12001 + +#endif diff --git a/src/csoapfault.c b/src/csoapfault.c new file mode 100644 index 0000000..61fe32d --- /dev/null +++ b/src/csoapfault.c @@ -0,0 +1,140 @@ +/****************************************************************** + * $Id: csoapfault.c,v 1.1 2003/03/25 22:17:20 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoapfault.h" + + + +/*----------------------------------------------------------------- + FUNCTION: SoapFaultGetFaultCode +/-----------------------------------------------------------------*/ + +char* SoapFaultGetFaultCode(HSOAPFAULT fault) +{ + xmlNodePtr node; + const char *FUNC = "SoapFaultGetFaultCode"; + + SoapTraceEnter(FUNC, "Entering"); + + node = SoapXmlFindNode((HSOAPXML)fault, "faultcode"); + if (node == NULL) { + SoapTraceLeaveWithError(FUNC, "Can not find faultcode"); + return NULL; + } + + SoapTraceLeave(FUNC, "Leaving"); + return SoapXmlGetNodeValueAlloc(node); +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapFaultGetFaultString +/-----------------------------------------------------------------*/ + +char* SoapFaultGetFaultString(HSOAPFAULT fault) +{ + xmlNodePtr node; + const char *FUNC = "SoapFaultGetFaultString"; + + SoapTraceEnter(FUNC, "Entering"); + + node = SoapXmlFindNode((HSOAPXML)fault, "faultstring"); + if (node == NULL) { + SoapTraceLeaveWithError(FUNC, "Can not find faultstring"); + return NULL; + } + + SoapTraceLeave(FUNC, "Leaving"); + return SoapXmlGetNodeValueAlloc(node); +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapFaultGetFaultActor +/-----------------------------------------------------------------*/ + +char* SoapFaultGetFaultActor(HSOAPFAULT fault) +{ + xmlNodePtr node; + const char *FUNC = "SoapFaultGetFaultActor"; + + SoapTraceEnter(FUNC, "Entering"); + + node = SoapXmlFindNode((HSOAPXML)fault, "faultactor"); + if (node == NULL) { + SoapTraceLeaveWithError(FUNC, "Can not find faultactor"); + return NULL; + } + + SoapTraceLeave(FUNC, "Leaving"); + return SoapXmlGetNodeValueAlloc(node); +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapFaultGetFaultDetail +/-----------------------------------------------------------------*/ + +HSOAPPARAM SoapFaultGetDetail(HSOAPFAULT fault) +{ + xmlNodePtr node; + const char *FUNC = "SoapFaultGetFaultCode"; + + SoapTraceEnter(FUNC, "Entering"); + + node = SoapXmlFindNode((HSOAPXML)fault, "detail"); + if (node == NULL) { + SoapTraceLeaveWithError(FUNC, "Can not find detail"); + return NULL; + } + + SoapTraceLeave(FUNC, "Leaving"); + return (HSOAPPARAM)node; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapFaultPrint +/-----------------------------------------------------------------*/ + +void SoapFaultPrint(FILE* f, HSOAPFAULT fault) +{ + char *str; + + if (fault == NULL) { + fprintf(f, "Fault object is null!.\n"); + return; + } + + str = SoapFaultGetFaultCode(fault); + fprintf(f, "FaultCode: %s\n", str?str:"null"); + SoapFreeStr(str); + + str = SoapFaultGetFaultString(fault); + fprintf(f, "FaultString: %s\n", str?str:"null"); + SoapFreeStr(str); + + str = SoapFaultGetFaultActor(fault); + fprintf(f, "FaultActor: %s\n", str?str:"null"); + SoapFreeStr(str); +} diff --git a/src/csoapfault.h b/src/csoapfault.h new file mode 100644 index 0000000..3a876e7 --- /dev/null +++ b/src/csoapfault.h @@ -0,0 +1,124 @@ +/****************************************************************** + * $Id: csoapfault.h,v 1.1 2003/03/25 22:17:20 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_FAULT_H +#define CSOAP_FAULT_H + + +#include "csoapxml.h" +#include "csoapparam.h" + +typedef HSOAPXML HSOAPFAULT; + + +/** + * Returns the [faultcode] + * + * @param fault handle to a soap fault object + * @return an allocated string or NULL + * if no [faultcode] was set. + */ +char* SoapFaultGetFaultCode(HSOAPFAULT fault); + + +/** + * Returns the [faultstring] + * + * @param fault handle to a soap fault object + * @return an allocated string or NULL + * if no [faultstring] was set. + */ +char* SoapFaultGetFaultString(HSOAPFAULT fault); + + +/** + * Returns the [faultactor] + * + * @param fault handle to a soap fault object + * @return an allocated string or NULL + * if no [faultactor] was set. + */ +char* SoapFaultGetFaultActor(HSOAPFAULT fault); + + +/** + * Returns the [detail] + * + * @param fault handle to a soap fault object + * @return handle to a soap param object + */ +HSOAPPARAM SoapFaultGetDetail(HSOAPFAULT fault); + + +/** + * Sets the a [faultcode] field. + * This will be called internally. + * + * @param fault handle to a soap fault object + * @param faultcode the faultcode to set + */ +void SoapFaultSetFaultCode(HSOAPFAULT fault, const char* faultCode); + + +/** + * Sets the a [faultstring] field. + * This will be called internally. + * + * @param fault handle to a soap fault object + * @param faultstring the faultstring to set + */ +void SoapFaultSetFaultString(HSOAPFAULT fault, const char* faultString); + + +/** + * Sets the a [faultactor] field. + * This will be called internally. + * + * @param fault handle to a soap fault object + * @param faultactor the faultactor to set + */ +void SoapFaultSetFaultActor(HSOAPFAULT fault, const char* faultActor); + + +/** + * Sets the a [faultdetail] field. + * This will be called internally. + * + * @param fault handle to a soap fault object + * @param faultcode the detail to set + */ +void SoapFaultSetFaultDetail(HSOAPFAULT fault, HSOAPPARAM param); + + +/** + * Prints a fault object into the + * given file. This is for debug puposes. + * + * @param f the file to print into + * @param fault the fault object to print + */ +void SoapFaultPrint(FILE* f, HSOAPFAULT fault); + + +#endif + diff --git a/src/csoaphttp.c b/src/csoaphttp.c new file mode 100644 index 0000000..2d578ce --- /dev/null +++ b/src/csoaphttp.c @@ -0,0 +1,153 @@ +/****************************************************************** + * $Id: csoaphttp.c,v 1.1 2003/03/25 22:17:20 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoaphttp.h" +#include "csoaplog.h" +#include "csoapxml.h" + +/*----------------------------------------------------------------- + FUNCTION: SoapHttpCreateEnv +/-----------------------------------------------------------------*/ + +static +HSOAPENV SoapHttpCreateEnv(char* httpResponse) +{ + const char *FUNC = "SoapHttpCreateEnv"; + int count = 0; + int newline = 0; + xmlDocPtr env; + xmlNodePtr node; + int len; + char *tmp; + + SoapTraceEnter(FUNC, "Entering response =\n"); + while (*(httpResponse+count) != '\0') { + if (httpResponse[count]=='\r') { + count++; + continue; + } + if (httpResponse[count]=='\n') { + if (newline) break; + else newline = 1; + } else newline = 0; + + count++; + } + + len = strlen(httpResponse); + SoapLog(LOG_DEBUG, FUNC, "count = %d\n", count); + SoapLog(LOG_DEBUG, FUNC, "response length = %d\n", len); + + len = strlen(&httpResponse[count]); + SoapLog(LOG_DEBUG, FUNC, "xml response length = %d\n", len); + + while (httpResponse[count] == '\n' + || httpResponse[count] == '\r') { + count++; + } + + SoapLog(LOG_DEBUG, FUNC, "count = %d\n", count); + + SoapLog(LOG_DEBUG, FUNC, "casting\n"); + tmp = (char*)(&httpResponse[count]); + SoapLog(LOG_DEBUG, FUNC, "casting ok\n"); + + /* SoapLog(LOG_DEBUG, FUNC, "xml = %s\n",tmp?tmp:"null"); + */ + SoapLog(LOG_DEBUG, FUNC, "Starting parsing\n"); + env = xmlParseMemory((const char*)tmp, len); + if (env == NULL) { + SoapLog(LOG_ERROR, FUNC, + "Can not create xml document!"); + return NULL; + } + + node = xmlDocGetRootElement(env); + if (node == NULL) { + SoapLog(LOG_ERROR, FUNC, + "xml document is empty!"); + return NULL; + } + + SoapLog(LOG_DEBUG, FUNC, + "Envelope created successfully"); + + SoapTraceLeave(FUNC, "env (%p)", node); + return (HSOAPENV)node; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapHttpSend +/-----------------------------------------------------------------*/ + +CSOAP_STATUS SoapHttpSend(HSOAPURL url, HSOAPENV env, HSOAPENV* res) +{ + const char *FUNC = "SoapHttpSend"; + HSOAPSOCKET http; + int len; + ssize_t size; + char *tmp; + char *response; + char tmp2[1054]; + CSOAP_STATUS status; + xmlBufferPtr buffer; + xmlDocPtr doc; + + SoapTraceEnter(FUNC, "env (%p)", env); + + buffer = xmlBufferCreate(); + xmlNodeDump(buffer, ((xmlNodePtr)env)->doc, (xmlNodePtr)env, 1 ,1); + len = strlen((const char*)xmlBufferContent(buffer)); + + tmp = (char*)malloc(1054 + len); + if (tmp == NULL) + return ERROR_NO_MEM; + + status = SoapSocketCreate(url->m_host, url->m_port, &http); + if (status != CSOAP_OK) return status; + + /*SoapSocketGetResponse(http);*/ + sprintf(tmp2, "POST %s HTTP/1.0\n", url->m_context?url->m_context:"/"); + sprintf(tmp2, "%sContent-Type: text/xml\n", tmp2); + sprintf(tmp2, "%sContent-Length: %d\n\n", tmp2, len); + + sprintf(tmp, "%s%s", tmp2, (const char*)xmlBufferContent(buffer)); + + SoapLog(LOG_DEBUG, FUNC, "sending request\n"); + status = SoapSocketSend(http, tmp, &size); + if (status != CSOAP_OK) return status; + + status = SoapSocketRecv(http, &response, &size); + SoapLog(LOG_DEBUG, FUNC, "response returned status = %d\n", status); + if (status != CSOAP_OK) return status; + + *res = SoapHttpCreateEnv(response); + free(tmp); + free(response); + xmlBufferFree(buffer); + + SoapTraceLeave(FUNC, ""); + return CSOAP_OK; +} + diff --git a/src/csoaphttp.h b/src/csoaphttp.h new file mode 100644 index 0000000..0fe8858 --- /dev/null +++ b/src/csoaphttp.h @@ -0,0 +1,45 @@ +/****************************************************************** + * $Id: csoaphttp.h,v 1.1 2003/03/25 22:17:20 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_HTTP_H +#define CSOAP_HTTP_H + +#include "csoapenv.h" +#include "csoapsocket.h" +#include "csoapurl.h" + +/** + * Sends a soap envelope to the given + * host and receives a soap envelope. + * + * @param url The target url + * @param env The soap envelope to send + * @param res The destination soap handle to + * receive the the envelope. + * + * @return CSOAP_OK if it was successfull. + */ +CSOAP_STATUS SoapHttpSend(HSOAPURL url, HSOAPENV env, HSOAPENV* res); + + +#endif diff --git a/src/csoaplog.c b/src/csoaplog.c new file mode 100644 index 0000000..536d1a9 --- /dev/null +++ b/src/csoaplog.c @@ -0,0 +1,65 @@ +#include "csoaplog.h" + +#include +#include + +static +void _SoapLogWrite(SoapLogLevel level, + const char* function, + const char* format, + va_list ap) +{ + char buffer[1054]; + char buffer2[1054]; + sprintf(buffer, "[%s] [%d] %s\n", function, level, format); + vsprintf(buffer2, buffer, ap); +/* printf(buffer2); + fflush(stdout); +*/ +} + + +void SoapTraceEnter(const char* function, + const char* format, ...) +{ + va_list ap; + + va_start(ap, format); + _SoapLogWrite(LOG_TRACE, function, format, ap); + va_end(ap); +} + + +void SoapTraceLeave(const char* function, + const char* format, ...) +{ + va_list ap; + + va_start(ap, format); + _SoapLogWrite(LOG_TRACE, function, format, ap); + va_end(ap); +} + + +void SoapTraceLeaveWithError(const char* function, + const char* format, ...) +{ + va_list ap; + + va_start(ap, format); + _SoapLogWrite(LOG_ERROR, function, format, ap); + va_end(ap); +} + + +void SoapLog(SoapLogLevel level, const char* function, + const char* format, ...) +{ + va_list ap; + + va_start(ap, format); + _SoapLogWrite(level, function, format, ap); + va_end(ap); +} + + diff --git a/src/csoaplog.h b/src/csoaplog.h new file mode 100644 index 0000000..6d7edb6 --- /dev/null +++ b/src/csoaplog.h @@ -0,0 +1,26 @@ +#ifndef CSOAP_LOG_H +#define CSOAP_LOG_H + + +typedef enum tagSoapLogLevel +{ + LOG_TRACE, + LOG_DEBUG, + LOG_INFO, + LOG_WARN, + LOG_ERROR +}SoapLogLevel; + +void SoapTraceEnter(const char* function, + const char* format, ...); + +void SoapTraceLeave(const char* function, + const char* format, ...); +void SoapTraceLeaveWithError(const char* function, + const char* format, ...); + +void SoapLog(SoapLogLevel level, const char* function, + const char* format, ...); + +#endif + diff --git a/src/csoapmethod.c b/src/csoapmethod.c new file mode 100644 index 0000000..fb85348 --- /dev/null +++ b/src/csoapmethod.c @@ -0,0 +1,70 @@ +/****************************************************************** + * $Id: csoapmethod.c,v 1.1 2003/03/25 22:17:21 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoapmethod.h" +#include "csoaplog.h" + + +/*----------------------------------------------------------------- + FUNCTION:SoapMethodGetName +/-----------------------------------------------------------------*/ + +char* SoapMethodGetName(HSOAPMETHOD method) +{ + const char* FUNC = "SoapMethodGetName"; + char *name; + xmlNodePtr node; + SoapTraceEnter(FUNC,""); + + if (method == NULL) { + SoapLog(LOG_ERROR, FUNC, + "Invalid method (null)"); + return NULL; + } + node = (xmlNodePtr)method; + name = (char*)node->name; + SoapTraceLeave(FUNC, "Name = '%s'", name); + return name; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapMethodParamContext +/-----------------------------------------------------------------*/ + +HSOAPPARAM SoapMethodParamContext(HSOAPMETHOD method) +{ + const char* FUNC = "SoapMethodParamContext"; + char *name; + SoapTraceEnter(FUNC,""); + + if (method == NULL) { + SoapLog(LOG_ERROR, FUNC, + "Invalid method (null)"); + return NULL; + } + SoapTraceLeave(FUNC, "param context = '%p'", method); + + return (xmlNodePtr)method; +} + diff --git a/src/csoapmethod.h b/src/csoapmethod.h new file mode 100644 index 0000000..aa8883d --- /dev/null +++ b/src/csoapmethod.h @@ -0,0 +1,56 @@ +/****************************************************************** + * $Id: csoapmethod.h,v 1.1 2003/03/25 22:17:21 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_METHOD_H +#define CSOAP_METHOD_H + +#include "csoapparam.h" + + +typedef HSOAPXML HSOAPMETHOD; + + +/** + * Returns the method name + * + * @param method handle to a soap method object + * @return the method name (do not free the string) + */ +char* SoapMethodGetName(HSOAPMETHOD method); + + +/** + * Returns the param context. Param context is + * also a param object. Use the param context + * as the parent of the method parameters. + * + * @param method the method object to get + * its param context + * + * @return The root parameter object if any + * exist , NULL otherwise. + */ +HSOAPPARAM SoapMethodParamContext(HSOAPMETHOD method); + + +#endif diff --git a/src/csoapparam.c b/src/csoapparam.c new file mode 100644 index 0000000..dfc9ac4 --- /dev/null +++ b/src/csoapparam.c @@ -0,0 +1,384 @@ +/****************************************************************** + * $Id: csoapparam.c,v 1.1 2003/03/25 22:17:25 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoapparam.h" +#include "csoaplog.h" +#include "csoaptypes.h" +#include "csoapxml.h" + +#include + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamCreate +/-----------------------------------------------------------------*/ + +HSOAPPARAM SoapParamCreate(HSOAPPARAM parent, const char *type, + const char *ns, const char *name, + const char *format, ...) +{ + va_list ap; + char buffer[SOAP_MAX_STRING_BUFFER]; + xmlNodePtr newnode; + const char *FUNC = "SoapParamCreate"; + + SoapTraceEnter(FUNC,""); + + va_start(ap, format); + vsprintf(buffer, format, ap); + va_end(ap); + + newnode = xmlNewTextChild(parent, NULL, name, buffer); + + if (newnode == NULL) { + SoapTraceLeaveWithError(FUNC, + "Can not create new xml node"); + return NULL; + } + + if ( !xmlNewProp(newnode, "xsi:type", type)) { + SoapTraceLeaveWithError(FUNC, + "Can not create new xml attribute"); + return NULL; + } + + SoapTraceLeave(FUNC, "New xml node (%p)", newnode); + return newnode; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamCreateString +/-----------------------------------------------------------------*/ + +HSOAPPARAM SoapParamCreateString(HSOAPPARAM parent, const char *name, + const char *format, ...) +{ + va_list ap; + HSOAPPARAM node; + char buffer[SOAP_MAX_STRING_BUFFER]; + const char* FUNC = "SoapParamCreateString"; + SoapTraceEnter(FUNC,""); + + if (parent == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid parent (null)"); + return NULL; + } + + if (name == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid name (null)"); + return NULL; + } + + if (format == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid format (null)"); + return NULL; + } + + SoapLog(LOG_DEBUG, FUNC, + "Creating string parameter\n" \ + "Name = '%s'" \ + "Format = %s", name, format); + + va_start(ap, format); + vsprintf(buffer, format, ap); + va_end(ap); + + node = SoapParamCreate(parent , SOAP_TYPE_STRING, + NULL, name, "%s", buffer); + + if (node == NULL) { + SoapTraceLeaveWithError(FUNC, "can not create param"); + return NULL; + } + + SoapTraceLeave(FUNC, "New param (%p)", node); + return (HSOAPPARAM)node; +} + + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamCreateInt +/-----------------------------------------------------------------*/ + +HSOAPPARAM SoapParamCreateInt(HSOAPPARAM parent, const char *name, + int value) +{ + HSOAPPARAM node; + const char* FUNC = "SoapParamCreateInt"; + SoapTraceEnter(FUNC,""); + + if (parent == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid parent (null)"); + return NULL; + } + + if (name == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid name (null)"); + return NULL; + } + + node = SoapParamCreate(parent , SOAP_TYPE_INT, + NULL, name, "%d", value); + + if (node == NULL) { + SoapTraceLeaveWithError(FUNC, "can not create param"); + return NULL; + } + + SoapTraceLeave(FUNC, "New param (%p)", node); + return node; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamCreateDouble +/-----------------------------------------------------------------*/ + +HSOAPPARAM SoapParamCreateDouble(HSOAPPARAM parent, const char *name, + double value) +{ + HSOAPPARAM node; + const char* FUNC = "SoapParamCreateDouble"; + SoapTraceEnter(FUNC,""); + + if (parent == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid parent (null)"); + return NULL; + } + + if (name == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid name (null)"); + return NULL; + } + + node = SoapParamCreate(parent, SOAP_TYPE_DOUBLE, + NULL, name, "%f", value); + + if (node == NULL) { + SoapTraceLeaveWithError(FUNC, "can not create param"); + return NULL; + } + + SoapTraceLeave(FUNC, "New param (%p)", node); + return node; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamSetValue +/-----------------------------------------------------------------*/ + +void SoapParamSetValue(HSOAPPARAM param, const char* type, + const char* format, ...) +{ + // Not implemented yet! +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamGetString +/-----------------------------------------------------------------*/ + +int SoapParamGetString(HSOAPPARAM param, char *dest) +{ + char *value; + int len; + xmlNodePtr xmlNode; + const char* FUNC = "SoapParamGetString"; + SoapTraceEnter(FUNC,""); + + if (param == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid parameter 'param' (null)"); + return 0; + } + + xmlNode = (xmlNodePtr)param; + value = (char*)xmlNodeListGetString(xmlNode->doc, + xmlNode->xmlChildrenNode,1); + + if (dest) + strcpy(dest, value); + + len = strlen(value); + xmlFree(value); + + SoapTraceLeave(FUNC, "Value = '%s'\nLength=%d", dest?dest:"null", len); + return len; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamGetInt +/-----------------------------------------------------------------*/ + +int SoapParamGetInt(HSOAPPARAM param) +{ + int value; + char buffer[15]; + const char* FUNC = "SoapParamGetInt"; + SoapTraceEnter(FUNC,""); + + if (param == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid parameter 'param' (null)"); + return 0; + } + + SoapParamGetString(param, buffer); + value = atoi(buffer); + SoapTraceLeave(FUNC, "Value = %d", value); + return value; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamGetDouble +/-----------------------------------------------------------------*/ + +double SoapParamGetDouble(HSOAPPARAM param) +{ + double value; + char buffer[15]; + const char* FUNC = "SoapParamGetDouble"; + SoapTraceEnter(FUNC,""); + + if (param == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid parameter 'param' (null)"); + return 0.0; + } + + SoapParamGetString(param, buffer); + value = atof(buffer); + SoapTraceLeave(FUNC, "Value = %f", value); + return value; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamGetChildren +/-----------------------------------------------------------------*/ + +HSOAPPARAM SoapParamGetChildren(HSOAPPARAM param) +{ + xmlNodePtr children; + const char* FUNC = "SoapParamGetChildren"; + SoapTraceEnter(FUNC,""); + + if (param == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid parameter 'param' (null)"); + return NULL; + } + + children = ((xmlNodePtr)param)->xmlChildrenNode; + while (children != NULL) { + if (children->type != XML_ELEMENT_NODE) + children = children->next; + else break; + } + SoapTraceLeave(FUNC, "Children node (%p)", children); + return (HSOAPPARAM)children; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamGetNext +/-----------------------------------------------------------------*/ + +HSOAPPARAM SoapParamGetNext(HSOAPPARAM param) +{ + xmlNodePtr children; + const char* FUNC = "SoapParamGetNext"; + xmlNodePtr node = (xmlNodePtr)param; + SoapTraceEnter(FUNC,"Enter. node = %s", node?(char*)node->name:"null"); + + if (param == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid parameter 'param' (null)"); + return NULL; + } + + children = node->next; + + while (children != NULL) { + if (children->type != XML_ELEMENT_NODE) + children = children->next; + else break; + } + + SoapTraceLeave(FUNC, "Children node (%p)", children); + return (HSOAPPARAM)children; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamGetType +/-----------------------------------------------------------------*/ + +char* SoapParamGetType(HSOAPPARAM param) +{ + const char* FUNC = "SoapParamGetType"; + char *value; + xmlNodePtr node = (xmlNodePtr)param; + SoapTraceEnter(FUNC,"Enter. node = %s", node?(char*)node->name:"null"); + + value = SoapXmlGetAttr(node, NULL, "type"); + + SoapTraceLeave(FUNC, "Type = %s", value?value:"(null}"); + return value; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapParamTypeIs +/-----------------------------------------------------------------*/ + +int SoapParamTypeIs(HSOAPPARAM param, const char* type) +{ + const char* FUNC = "SoapParamTypeIs"; + char *value; + SoapTraceEnter(FUNC,"Enter. Type = %s", type?type:"(null)"); + + if (type == NULL) { + SoapTraceLeaveWithError(FUNC, "type is null"); + return 0; + } + + value = SoapParamGetType(param); + + SoapTraceLeave(FUNC, "Leave"); + return (!strcmp(value, type)); +} + + diff --git a/src/csoapparam.h b/src/csoapparam.h new file mode 100644 index 0000000..23a27f9 --- /dev/null +++ b/src/csoapparam.h @@ -0,0 +1,187 @@ +/****************************************************************** + * $Id: csoapparam.h,v 1.1 2003/03/25 22:17:25 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_PARAM_H +#define CSOAP_PARAM_H + +#include "csoapxml.h" + + +typedef HSOAPXML HSOAPPARAM; + + +#define SOAP_MAX_STRING_BUFFER 1054 + + +/** + * Creates a string soap parameter + * + *
  • Default type: "xsd:string" + * + * @param parent the parent param object + * @param name the parameter name + * @param format the parameter value + * + * @return handle to a parameter object if + * the creation was successfull, NULL otherwise + */ +HSOAPPARAM SoapParamCreateString( HSOAPPARAM parent, const char *name, + const char *format, ...); + + +/** + * Creates an integer soap parameter + * + *
  • Default type: "xsd:integer" + * + * @param parent the parent param object + * @param name the parameter name + * @param value the parameter value + * + * @return handle to a parameter object if + * the creation was successfull, NULL otherwise + */ +HSOAPPARAM SoapParamCreateInt( HSOAPPARAM parent, const char *name, + int value); + + +/** + * Creates a double soap parameter + * + *
  • Default type: "xsd:double" + * + * @param parent the parent param object + * @param name the parameter name + * @param value the parameter value + * + * @return handle to a parameter object if + * the creation was successfull, NULL otherwise + */ +HSOAPPARAM SoapParamCreateDouble( HSOAPPARAM parent, const char *name, + double value); + + +/** + * Sets the parameter value. + * + * @param param the parameter object + * @param type a custom type name + * @param format value of the parameter + */ +void SoapParamSetValue(HSOAPPARAM param,const char* type, + const char* format, ...); + + +/** + * Get the value of a soap parameter + * in string format + * + * @param param the soap parameter object + * @param buffer an allocated character buffer + * to receive the content. If this is NULL, + * this function will return the size only. + * + * @return size of the content. + */ +int SoapParamGetString(HSOAPPARAM param, char *buffer); + + +/** + * Get the value of a soap parameter + * in integer format + * + * @param param the soap parameter object + * @return the param content as integer + */ +int SoapParamGetInt(HSOAPPARAM param); + + +/** + * Get the value of a soap parameter + * in double format + * + * @param param the soap parameter object + * @return the param content as double + */ +double SoapParamGetDouble(HSOAPPARAM param); + + +/** + * Get the children parameter nodes. + * This acts actually like an xml node. + * + * @param param the soap parameter object + * @return handle to the first child node + */ +HSOAPPARAM SoapParamGetChildren(HSOAPPARAM param); + + +/** + * Get the next parameter. + * This acts actually like an xml node. + * + * @param param the soap parameter object + * @return handle to the next node + */ +HSOAPPARAM SoapParamGetNext(HSOAPPARAM param); + + +/** + * Checks if the type is equals with + * the given one. + * + * @param param the param to check + * @param type the type to check + * + * @return 0 if the parameter type not equals to 'type' + */ +int SoapParamTypeIs(HSOAPPARAM param, const char* type); + + +/** + * Returns parameters type. + * + * @param param the param to return its type + * + * @return returns parameters type + */ +char* SoapParamGetType(HSOAPPARAM param); + + +/** + * Creates a new parameter node. + * This is used internally. + * + * @param parent the parent soap parameter object + * @param type the parameter type + * @param ns the namespace of the parameter + * @param name name of the parameter + * @param format value of the parameter + * + * @return A newly created soap parameter object + */ +HSOAPPARAM SoapParamCreate(HSOAPPARAM parent, const char *type, + const char *ns, const char *name, + const char *format, ...); + +#endif diff --git a/src/csoapres.c b/src/csoapres.c new file mode 100644 index 0000000..3d631e1 --- /dev/null +++ b/src/csoapres.c @@ -0,0 +1,154 @@ +/****************************************************************** + * $Id: csoapres.c,v 1.1 2003/03/25 22:17:26 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoapres.h" +#include "csoaplog.h" + + +/*----------------------------------------------------------------- + FUNCTION: SoapResCreate +/-----------------------------------------------------------------*/ + +HSOAPRES SoapResCreate(HSOAPENV env, const char* methodName) +{ + HSOAPRES res = (HSOAPRES)malloc(sizeof(struct SOAPRES)); + res->m_env = env; + res->m_method = (char*)malloc(sizeof(char)*strlen(methodName)+1); + strcpy(res->m_method, methodName); + return res; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapResGetFault +/-----------------------------------------------------------------*/ + +HSOAPFAULT SoapResGetFault(HSOAPRES res) +{ + const char *FUNC = "SoapResGetFault"; + HSOAPBODY body; + HSOAPFAULT fault; + + SoapTraceEnter(FUNC, "Entering"); + + if (res == NULL) { + SoapTraceLeaveWithError(FUNC, "res is null"); + return NULL; + } + + if (res->m_env == NULL) { + SoapTraceLeaveWithError(FUNC, "res->m_env is null"); + return NULL; + } + + if (!(body = SoapEnvGetBody(res->m_env))) { + SoapTraceLeaveWithError(FUNC, "can not get body"); + return NULL; + } + + fault = SoapBodyGetFault(body); + SoapTraceLeave(FUNC, "Leaving fault (%p)", fault); + + return fault; +} + +/*----------------------------------------------------------------- + FUNCTION: SoapResFree +/-----------------------------------------------------------------*/ + +void SoapResFree(HSOAPRES res) +{ + const char *FUNC = "SoapResFree"; + + SoapTraceEnter(FUNC, "Entering"); + + if (res == NULL) { + SoapTraceLeaveWithError(FUNC, "res is null"); + return; + } + + if (res->m_env == NULL) { + SoapTraceLeaveWithError(FUNC, "res->m_env is null"); + return; + } + + SoapEnvFree(res->m_env); + free(res); + + SoapTraceLeave(FUNC, "Leaving"); +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapResFree +/-----------------------------------------------------------------*/ + +HSOAPPARAM SoapResGetParamChildren(HSOAPRES res) +{ + const char *FUNC = "SoapResGetParamChildren"; + HSOAPBODY body; + HSOAPMETHOD method; + HSOAPPARAM param; + char tmp[1054]; + + SoapTraceEnter(FUNC, "Entering"); + + if (res == NULL) { + SoapTraceLeaveWithError(FUNC, "res is null"); + return NULL; + } + + if (res->m_env == NULL) { + SoapTraceLeaveWithError(FUNC, "res->m_env is null"); + return NULL; + } + + if (!(body = SoapEnvGetBody(res->m_env))) { + SoapTraceLeaveWithError(FUNC, "can not get body"); + return NULL; + } + + sprintf(tmp, "%sResponse", res->m_method); + method = SoapBodyGetMethod(body, tmp); + + if (method == NULL) { + SoapTraceLeaveWithError(FUNC, "method is null"); + return NULL; + } + + param = SoapMethodParamContext(method); + + if (param == NULL) { + SoapTraceLeaveWithError(FUNC, "param is null"); + return NULL; + } + + param = SoapParamGetChildren(method); + + if (param == NULL) { + SoapTraceLeaveWithError(FUNC, "child is null"); + return NULL; + } + + return param; +} diff --git a/src/csoapres.h b/src/csoapres.h new file mode 100644 index 0000000..38efd9b --- /dev/null +++ b/src/csoapres.h @@ -0,0 +1,90 @@ +/****************************************************************** + * $Id: csoapres.h,v 1.1 2003/03/25 22:17:26 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_RES_H +#define CSOAP_RES_H + +#include "csoapxml.h" +#include "csoapenv.h" + +typedef struct SOAPRES* HSOAPRES; + + +/** + * The result object. Stores + * the response of a soap request. + */ +struct SOAPRES +{ + HSOAPENV m_env; /* The soap envelope object */ + char *m_method; /* The called method name */ +}; + + +/** + * Creates a new soap result object. + * This is used actually internally. + * To get a soap result see + * HSOAPCALL + * + * @param env the envelope object to use + * @param methodName the called method name + * @return handle to a soap result object. + */ +HSOAPRES SoapResCreate(HSOAPENV env, const char* methodName); + + +/** + * Returns a soap fault object + * if any exist. This can also be + * called to check if any faults + * was occured for this result. + * + * @param res handle to the soap result object + * @return handle to a fault object or + * NULL if no fault was generated. + */ +HSOAPFAULT SoapResGetFault(HSOAPRES res); + + +/** + * Returns the first parameter + * in the result object if any exist. + * + * @param res handle to the soap result object + * @return handle to a soap param object + * NULL if no parameter was received. + */ +HSOAPPARAM SoapResGetParamChildren(HSOAPRES res); + + +/** + * Free a soap result object. + * This must be called after the result + * object was used. + * + * @param res The soap result object to free + */ +void SoapResFree(HSOAPRES res); + +#endif diff --git a/src/csoapsocket.c b/src/csoapsocket.c new file mode 100644 index 0000000..87d5515 --- /dev/null +++ b/src/csoapsocket.c @@ -0,0 +1,154 @@ +/****************************************************************** + * $Id: csoapsocket.c,v 1.1 2003/03/25 22:17:26 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoapsocket.h" +#include "csoaperror.h" +#include "csoaplog.h" + +#include +#include +#include +#include + +#define SOCKET_MAX_BUFSIZE 1054 + + +/*----------------------------------------------------------------- + FUNCTION: SoapSocketCreate +/-----------------------------------------------------------------*/ + +CSOAP_STATUS SoapSocketCreate(const char* hostname, int port, HSOAPSOCKET* hSock) +{ + + int sock; + struct sockaddr_in address; + struct hostent* host; + int i; + + sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock <= 0) return ERROR_SOCKET_CAN_NOT_CREATE_SOCKET; + + /* Get host data */ + host = gethostbyname(hostname); + if (host == NULL) return ERROR_SOCKET_CAN_NOT_GET_HOSTNAME; + + /* set server addresss */ + address.sin_family = host->h_addrtype;; + address.sin_port = htons(port); + memcpy((char*)&address.sin_addr.s_addr, + host->h_addr_list[0], host->h_length); + + /* connect to the server */ + if (connect(sock, (struct sockaddr*) &address, sizeof(address)) != 0) + return ERROR_SOCKET_CAN_NOT_CONNECT; + + *hSock = sock; + return CSOAP_OK; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapSocketRecv +/-----------------------------------------------------------------*/ + +CSOAP_STATUS SoapSocketRecv(HSOAPSOCKET sock, char** buffer, ssize_t* totalSize) +{ + const char *FUNC = "SoapSocketRecv"; + ssize_t size; + int chunk=1; + char tmp[SOCKET_MAX_BUFSIZE+1]; + + SoapTraceEnter( FUNC, "Entering"); + *totalSize = 0; + *buffer = 0; + + do { + SoapLog(LOG_DEBUG, FUNC, "Receiving buffer\n"); + size = recv(sock, tmp, SOCKET_MAX_BUFSIZE, 0); + SoapLog(LOG_DEBUG, FUNC, "received = %s\n", tmp); + if (size == -1) { + printf("Error reading from socket\n"); + return ERROR_SOCKET_CAN_NOT_RECEIVE; + } + *totalSize += size; + if (*buffer) { + SoapLog(LOG_DEBUG, FUNC, "realloc\n"); + *buffer = (char*)realloc(*buffer, SOCKET_MAX_BUFSIZE*chunk+1); + strcat(*buffer, tmp); + SoapLog(LOG_DEBUG, FUNC,"realloc ok\n"); + } else { + SoapLog(LOG_DEBUG, FUNC, "alloc\n"); + *buffer = (char*)realloc(NULL, SOCKET_MAX_BUFSIZE+1); + strcpy(*buffer, tmp); + SoapLog(LOG_DEBUG, FUNC,"alloc ok\n"); + } + + SoapLog(LOG_DEBUG, FUNC, "totalSize = %d\n", *totalSize); + (*buffer)[*totalSize] = '\0'; + chunk++; + } while (size > 0); + + SoapTraceLeave(FUNC, "totalsize: %d", *totalSize); + return CSOAP_OK; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapSocketSend +/-----------------------------------------------------------------*/ + +CSOAP_STATUS SoapSocketSend(HSOAPSOCKET sock, const char* req, ssize_t* sentSize) +{ + const char *FUNC = "SoapSocketSend"; + ssize_t size; + + SoapTraceEnter(FUNC, ""); + + size = send(sock, req, strlen(req), 0); + if (size == -1) + return ERROR_SOCKET_CAN_NOT_SEND; + + *sentSize = size; + SoapTraceLeave(FUNC, ""); + return CSOAP_OK; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapSocketInitialize +/-----------------------------------------------------------------*/ + +CSOAP_STATUS SoapSocketInitialize() +{ + const char *FUNC = "SoapSocketInitialize"; + SoapTraceEnter(FUNC, ""); + +#ifdef WIN32 + /* Initialize WinSocket for the Windows version */ +#endif + + SoapTraceLeave(FUNC, ""); + return CSOAP_OK; +} + + diff --git a/src/csoapsocket.h b/src/csoapsocket.h new file mode 100644 index 0000000..216b1a2 --- /dev/null +++ b/src/csoapsocket.h @@ -0,0 +1,81 @@ +/****************************************************************** + * $Id: csoapsocket.h,v 1.1 2003/03/25 22:17:28 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_SOCKET_H +#define CSOAP_SOCKET_H + +#include +#include "csoaperror.h" + +typedef int HSOAPSOCKET; + + +/** + * Initializes the soap socket module. + * This is called internally. Before any + * socket operation. + * + * @return CSOAP_OK if it was successfull + */ +int SoapSocketInitialize(); + + +/** + * Creates a new soap compatible socket object. + * + * @param host the host to connect + * @param port the port to connect + * @param socket the destination pointer + * to receive a connected socket object + * + * @return CSOAP_OK if it was successfull. + */ +CSOAP_STATUS SoapSocketCreate(const char* host, int port, HSOAPSOCKET* socket); + +/** + * Sends data to the connected socket. + * + * @param sock A connected socket object + * @param req data to send + * @param sentSize the size of sent data + * + * @return CSOAP_OK if it was successfull + */ +CSOAP_STATUS SoapSocketSend(HSOAPSOCKET sock, const char* req,ssize_t* sentSize); + + +/** + * Receives data from the connected socket. + * + * @param sock A connected socket object + * @param res destination pointer to receive + * the data. This will be allocated in this + * function. So you have to free it. + * @param receivedSize the size of received data + * + * @return CSOAP_OK if it was successfull + */ +CSOAP_STATUS SoapSocketRecv(HSOAPSOCKET sock, char** res,ssize_t* receivedSize); + + +#endif diff --git a/src/csoaptypes.h b/src/csoaptypes.h new file mode 100644 index 0000000..ac001f4 --- /dev/null +++ b/src/csoaptypes.h @@ -0,0 +1,33 @@ +/****************************************************************** + * $Id: csoaptypes.h,v 1.1 2003/03/25 22:17:28 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_TYPES_H +#define CSOAP_TYPES_H + + +#define SOAP_TYPE_STRING "xsd:string" +#define SOAP_TYPE_INT "xsd:int" +#define SOAP_TYPE_DOUBLE "xsd:double" + + +#endif diff --git a/src/csoapurl.c b/src/csoapurl.c new file mode 100644 index 0000000..ae91e40 --- /dev/null +++ b/src/csoapurl.c @@ -0,0 +1,185 @@ +/****************************************************************** + * $Id: csoapurl.c,v 1.1 2003/03/25 22:17:28 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoapurl.h" +#include "csoaplog.h" + +#include +#include + + +static +HSOAPURL CreateUrlFromIndex(const char* urlstr, int iprotocol, int ihost, int iport) +{ + const char *FUNC = "CreateUrlFromIndex"; + int len, size; + char tmp[8]; + HSOAPURL url; + + SoapTraceEnter(FUNC, "Entering"); + + url = (HSOAPURL)malloc(sizeof(struct SOAPURL)); + + url->m_protocol = (char*)malloc(sizeof(char)*iprotocol+1); + strncpy(url->m_protocol, urlstr, iprotocol); + + size = ihost - iprotocol - 3; + url->m_host = (char*)malloc(sizeof(char)*size); + strncpy(url->m_host, &urlstr[iprotocol+3], size); + + if (iport > ihost) + { + size = iport - ihost; + strncpy(tmp, &urlstr[ihost+1], size); + url->m_port = atoi(tmp); + } else { + url->m_port = 80; + } + + len = strlen(urlstr); + if (len > iport ) + { + size = len - iport; + url->m_context = (char*)malloc(sizeof(char)*size); + strncpy(url->m_context, &urlstr[iport], size); + } else { + url->m_context = NULL; + } + + SoapTraceEnter(FUNC, "Leaving url = %p", url); + return url; +}; + + +/*----------------------------------------------------------------- + FUNCTION: SoapUrlCreate +/-----------------------------------------------------------------*/ + +HSOAPURL SoapUrlCreate(const char* urlstr) +{ + const char *FUNC = "SoapUrlCreate"; + int iprotocol; + int ihost; + int iport; + int len; + HSOAPURL url = NULL; + + SoapTraceEnter(FUNC, "Entering. URL = %s", urlstr?urlstr:"null"); + + iprotocol = 0; + len = strlen(urlstr); + printf("len = %d\n", len); + /* find protocol */ + while (urlstr[iprotocol] != ':' && urlstr[iprotocol] != '\0') + { +/* printf("protocol: urlstr[%d] = %c\n",iprotocol, urlstr[iprotocol] );*/ + iprotocol++; + } + + if (iprotocol == 0) { + SoapTraceLeaveWithError(FUNC, "no protocol"); + return NULL; + } + + if (iprotocol + 3 >= len) { + SoapTraceLeaveWithError(FUNC, "no host"); + return NULL; + } + + if ( urlstr[iprotocol] != ':' + && urlstr[iprotocol+1] != '/' + && urlstr[iprotocol+2] != '/') + { + SoapTraceLeaveWithError(FUNC, "no protocol"); + return NULL; + } + + /* find host */ + ihost = iprotocol + 3; + while (urlstr[ihost] != ':' + && urlstr[ihost] != '/' + && urlstr[ihost] != '\0') + { +/* printf("host: urlstr[%d] = %c\n",ihost, urlstr[ihost] );*/ + ihost++; + } + + if (ihost == iprotocol + 1) { + SoapTraceLeaveWithError(FUNC, "no host"); + return NULL; + } + + /* find port */ + iport = ihost; + if (ihost + 1 < len) { + if (urlstr[ihost] == ':') { + while (urlstr[iport] != '/' && urlstr[iport] != '\0') { +/* printf("port: urlstr[%d] = %c\n", iport, urlstr[iport] );*/ + iport++; + } + } + } + +/* + printf("iprotocol = %d\nihost = %d\niport = %d\nlen = %d\n", + iprotocol, ihost, iport, len); +*/ + url = CreateUrlFromIndex(urlstr, iprotocol, ihost, iport); + SoapTraceLeave(FUNC, "Leaving url (%p)", url); + return url; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapUrlFree +/-----------------------------------------------------------------*/ + +void SoapUrlFree(HSOAPURL url) +{ + if (url != NULL) { + if (url->m_protocol) free(url->m_protocol); + if (url->m_host) free(url->m_host); + if (url->m_context) free(url->m_context); + + free(url); + } +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapUrlDump +/-----------------------------------------------------------------*/ + +void SoapUrlDump(HSOAPURL url) +{ + if (url == NULL) { + printf("(null)\n"); + return ; + } + + printf("PROTOCOL : %s\n", url->m_protocol?url->m_protocol:"(null)"); + printf(" HOST : %s\n", url->m_host?url->m_host:"(null)"); + printf(" PORT : %d\n", url->m_port); + printf(" CONTEXT : %s\n", url->m_context?url->m_context:"(null)"); + +} diff --git a/src/csoapurl.h b/src/csoapurl.h new file mode 100644 index 0000000..7840f78 --- /dev/null +++ b/src/csoapurl.h @@ -0,0 +1,70 @@ +/****************************************************************** + * $Id: csoapurl.h,v 1.1 2003/03/25 22:17:30 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_URL_H +#define CSOAP_URL_H + + +/* Include csoap headers */ + + +typedef struct SOAPURL* HSOAPURL; + + +struct SOAPURL +{ + char *m_protocol; + char *m_host; + int m_port; + char *m_context; +}; + + +/** + * Creates a new url object + * + * @param url the url string + * + * @return A soap url object if it was + * successfull, NULL otherwise. + */ +HSOAPURL SoapUrlCreate(const char* url); + + +/** + * Free a url object + * + * @param url the url to free + */ +void SoapUrlFree(HSOAPURL url); + + +/** + * Dump the url data (for debugging) + * + * @param url the url to show its content + */ +void SoapUrlDump(HSOAPURL url); + + +#endif diff --git a/src/csoapxml.c b/src/csoapxml.c new file mode 100644 index 0000000..6129747 --- /dev/null +++ b/src/csoapxml.c @@ -0,0 +1,151 @@ +/****************************************************************** + * $Id: csoapxml.c,v 1.1 2003/03/25 22:17:31 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#include "csoapxml.h" + +#include "csoaplog.h" + + +/*----------------------------------------------------------------- + FUNCTION: SoapXmlFindNode +/-----------------------------------------------------------------*/ + +HSOAPXML +SoapXmlFindNode(HSOAPXML root, const char* nodeName) +{ + xmlNodePtr cur; + const char* FUNC = "SoapXmlFindNode"; + + SoapTraceEnter(FUNC,"root (%p) node (%p)", + root, nodeName?nodeName:"null"); + + if (root == NULL) { + SoapLog(LOG_ERROR, FUNC, + "Invalid root node (null)"); + return NULL; + } + + if (nodeName == NULL) { + SoapLog(LOG_ERROR, FUNC, + "Invalid node name (null)"); + return NULL; + } + + cur = ((xmlNodePtr)root)->xmlChildrenNode; + while (cur != NULL) { + if (!xmlStrcmp(cur->name, (const xmlChar*)nodeName)) { + SoapTraceLeave(FUNC, "Found '%s' (%p)", nodeName, cur); + return cur; + } + cur = cur->next; + } + + SoapTraceLeave(FUNC, "No '%s' found!", nodeName); + return NULL; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapXmlGetNodeValue +/-----------------------------------------------------------------*/ + +int +SoapXmlGetNodeValue(HSOAPXML xmlNode, char* dest) +{ + char *value; + int len; + const char* FUNC = "SoapXmlGetNodeValue"; + SoapTraceEnter(FUNC,"Entering"); + + + if (xmlNode == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid parameter 'xmlNode' (null)"); + return 0; + } + + value = (char*)xmlNodeListGetString(((xmlNodePtr)xmlNode)->doc, + ((xmlNodePtr)xmlNode)->xmlChildrenNode,1); + strcpy(dest, value); + len = strlen(value); + xmlFree(value); + + SoapTraceLeave(FUNC, "Value = '%s'\nLength=%d", dest, len); + return len; + +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapXmlGetNodeValueAlloc +/-----------------------------------------------------------------*/ + +char* +SoapXmlGetNodeValueAlloc(HSOAPXML xmlNode) +{ + char *value; + int len; + const char* FUNC = "SoapXmlGetNodeValueAlloc"; + SoapTraceEnter(FUNC,"Entering"); + + + if (xmlNode == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid parameter 'xmlNode' (null)"); + return 0; + } + + value = (char*)xmlNodeListGetString(((xmlNodePtr)xmlNode)->doc, + ((xmlNodePtr)xmlNode)->xmlChildrenNode,1); + SoapTraceLeave(FUNC, "Value = '%s'\n", value); + return value; +} + + +/*----------------------------------------------------------------- + FUNCTION: SoapXmlGetAttr +/-----------------------------------------------------------------*/ + +char* SoapXmlGetAttr(HSOAPXML node, const char* ns, const char* key) +{ + char *value; + int len; + const char* FUNC = "SoapXmlGetAttr"; + SoapTraceEnter(FUNC,"Entering"); + + + if (node == NULL) { + SoapTraceLeaveWithError(FUNC, + "Invalid parameter 'node' (null)"); + return NULL; + } + + if (ns == NULL) { + value = (char*)xmlGetProp(node, key); + } else { + value = (char*)xmlGetNsProp(node, key, ns); + } + + SoapTraceLeave(FUNC, "Value = '%s'\n", value?value:"(null)"); + return value; +} diff --git a/src/csoapxml.h b/src/csoapxml.h new file mode 100644 index 0000000..290d556 --- /dev/null +++ b/src/csoapxml.h @@ -0,0 +1,90 @@ +/****************************************************************** + * $Id: csoapxml.h,v 1.1 2003/03/25 22:17:33 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ +#ifndef CSOAP_XML_H +#define CSOAP_XML_H + + +#include +#include + +#include "csoaperror.h" + + +typedef xmlNodePtr HSOAPXML; + + +/** + * Search for an xml node which + * has the name nodeName + * + * @param root the root xml node to search + * the nodeName in its children nodes + * @param nodeName the nodeName to find + * + * @return an xml node if any exist, + * NULL otherwise + */ +HSOAPXML SoapXmlFindNode(HSOAPXML root, const char* nodeName); + + +/** + * Receives the node value + * + * @param node the xml node to receive + * its text node + * @param dest the destination string + * + * @return length of content copied into dest + */ +int SoapXmlGetNodeValue(HSOAPXML node, char* dest); + + +/** + * Receives the node value. + * + * @param node the xml node to receive + * its text node + * + * @return An allocated string. You must free + * it using SoapFreeStr + * @see SoapFreeStr + */ +char* SoapXmlGetNodeValueAlloc(HSOAPXML node); + + +/** + * Returns the xml attribute + * + * @param node the xml node to receive its attribute + * @param ns namespace of the attribute + * @param key key of the attribute + * + * @return value of the attribute if any found, + * NULL otherwise. It's up to the caller to free + * the memory with SoapFreeStr(). + */ +char* SoapXmlGetAttr(HSOAPXML node, const char* ns, const char* key); + +#endif + -- cgit v1.1-32-gdbae