summaryrefslogtreecommitdiffstats
path: root/wsdl2c/codewriter.c
diff options
context:
space:
mode:
authorGravatar snowdrop2004-10-15 13:34:47 +0000
committerGravatar snowdrop2004-10-15 13:34:47 +0000
commita6cc4ca8b8432acdc2ce7bf7ebb92583eeeeff9f (patch)
tree4f954c8c2416bcb7220c42afcc93c95747c8d28c /wsdl2c/codewriter.c
parent73e428cb61f06f1582d65f98843a0bcf174c2f00 (diff)
downloadcsoap-a6cc4ca8b8432acdc2ce7bf7ebb92583eeeeff9f.tar.gz
csoap-a6cc4ca8b8432acdc2ce7bf7ebb92583eeeeff9f.tar.bz2
development
Diffstat (limited to 'wsdl2c/codewriter.c')
-rwxr-xr-xwsdl2c/codewriter.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/wsdl2c/codewriter.c b/wsdl2c/codewriter.c
new file mode 100755
index 0000000..7f46b7f
--- /dev/null
+++ b/wsdl2c/codewriter.c
@@ -0,0 +1,125 @@
+#include "codewriter.h"
+#include <xsd2c/tr.h>
+#include <xsd2c/obj.h>
+
+#include <stdio.h>
+
+static FILE *header;
+static FILE *source;
+static char* ns = "impl";
+
+static int openSourceFile(const char* filename);
+static void closeSourceFile();
+
+static int openHeaderFile(const char* filename);
+static void closeHeaderFile();
+
+static void writeOperation(struct CallFunc *call)
+{
+ struct CallVar_List* var;
+
+ fprintf(header, "%s %s_%s(", trXSD2C(call->out->type), ns, call->name);
+
+ var = CallFunc_Get_in(call);
+
+ while (var) {
+ fprintf(header, "const %s %s", trXSD2C(var->value->type), var->value->name);
+ var = var->next;
+ if (var) fprintf(header, ",");
+ }
+
+ fprintf(header, ")");
+}
+
+void codeWriteStubHeader(struct CallList *cl, const char* filename)
+{
+ struct CallFunc_List *call;
+ struct CallVar_List* var;
+ HCOMPLEXTYPE ct;
+
+ openHeaderFile(filename);
+
+ fprintf(header, "#ifndef __TEST_SOAP_H__\n#define __TEST_SOAP_H__\n\n");
+
+ /* Find header files */
+ call = CallList_Get_operation(cl);
+ while (call) {
+ var = CallFunc_Get_in(call->value);
+ while (var) {
+ ct = objRegistryGetComplexType(var->value->type);
+ if (ct /* TODO: && not in written before */)
+ fprintf(header, "#include \"%s.h\"\n", trXSDParseNs(var->value->type)); /* _xsd*/
+ var = var->next;
+ }
+ call = call->next;
+ }
+
+ fprintf(header, "\n");
+ call = CallList_Get_operation(cl);
+ while (call) {
+
+ writeOperation(call->value);
+ fprintf(header, ";\n");
+ call = call->next;
+ }
+
+ fprintf(header, "\n\n#endif\n");
+
+ closeHeaderFile();
+}
+
+
+void codeWriteStubSource(struct CallList *cl, const char* filename)
+{
+ struct CallFunc_List *call;
+
+ openSourceFile(filename);
+
+ fprintf(source, "#include \"test_stub.h\"\n\n");
+
+ call = CallList_Get_operation(cl);
+ while (call) {
+
+ writeOperation(call->value);
+/* fwrite(source, "\n{\n\t*/
+ call = call->next;
+ }
+
+
+ fprintf(source, "\n");
+
+ closeSourceFile();
+}
+
+
+
+static
+int openSourceFile(const char* filename)
+{
+ source = fopen(filename, "w");
+ if (!source) return 0;
+ return 1;
+}
+
+static
+void closeSourceFile()
+{
+ fclose(source);
+}
+
+static
+int openHeaderFile(const char* filename)
+{
+ header= fopen(filename, "w");
+ if (!header) return 0;
+ return 1;
+}
+
+
+static
+void closeHeaderFile()
+{
+ fclose(header);
+}
+
+