From 6457c46897d6e0c63476bf4ba4ca14b4844fac0d Mon Sep 17 00:00:00 2001 From: m0gg Date: Thu, 23 Nov 2006 15:27:32 +0000 Subject: Code cleanup --- examples/csoap/echoattachments-client.c | 33 +++++++++------------------ examples/csoap/echoattachments-server.c | 18 +++++---------- examples/csoap/simpleclient.c | 20 +++++++---------- examples/csoap/simpleserver.c | 15 +++++-------- examples/csoap/soapclient.c | 24 +++++++++----------- examples/nanohttp/http_client.c | 4 +--- examples/nanohttp/http_server.c | 40 ++++++++++++++++----------------- 7 files changed, 58 insertions(+), 96 deletions(-) (limited to 'examples') diff --git a/examples/csoap/echoattachments-client.c b/examples/csoap/echoattachments-client.c index b128563..26c65ff 100755 --- a/examples/csoap/echoattachments-client.c +++ b/examples/csoap/echoattachments-client.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: echoattachments-client.c,v 1.13 2006/11/21 20:58:59 m0gg Exp $ + * $Id: echoattachments-client.c,v 1.14 2006/11/23 15:27:33 m0gg Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -20,30 +20,22 @@ * * Email: ferhatayaz@yahoo.com ******************************************************************/ -#include #include -#include +#include #include #include -#include -#include -#include -#include -#include #include #include #include #include - static const char *urn = "urn:examples"; static const char *url = "http://localhost:10000/echoattachments"; static const char *method = "echo"; - void compareFiles(const char *received, const char *sent) { @@ -116,14 +108,13 @@ compareFiles(const char *received, const char *sent) } int -main(int argc, char *argv[]) +main(int argc, char **argv) { - SoapCtx *ctx, *ctx2; + struct SoapCtx *ctx, *ctx2; char href[MAX_HREF_SIZE]; xmlNodePtr fault; herror_t err; - if (argc < 2) { fprintf(stderr, "usage: %s [url]\n", argv[0]); @@ -135,8 +126,7 @@ main(int argc, char *argv[]) err = soap_client_init_args(argc, argv); if (err != H_OK) { - log_error4("[%d] %s():%s ", herror_code(err), herror_func(err), - herror_message(err)); + printf("[%d] %s():%s ", herror_code(err), herror_func(err), herror_message(err)); herror_release(err); return 1; } @@ -146,8 +136,7 @@ main(int argc, char *argv[]) err = soap_ctx_new_with_method(urn, method, &ctx); if (err != H_OK) { - log_error4("[%d] %s():%s ", herror_code(err), herror_func(err), - herror_message(err)); + printf("[%d] %s():%s ", herror_code(err), herror_func(err), herror_message(err)); herror_release(err); return 1; } @@ -157,8 +146,7 @@ main(int argc, char *argv[]) err = soap_ctx_add_file(ctx, argv[1], "application/octet-stream", href); if (err != H_OK) { - log_error4("%s():%s [%d]", herror_func(err), herror_message(err), - herror_code(err)); + printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err)); herror_release(err); return 1; } @@ -177,8 +165,7 @@ main(int argc, char *argv[]) if (err != H_OK) { - log_error4("%s():%s [%d]", herror_func(err), herror_message(err), - herror_code(err)); + printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err)); herror_release(err); return 1; } @@ -188,7 +175,7 @@ main(int argc, char *argv[]) fault = soap_env_get_fault(ctx2->env); if (fault) { - soap_xml_doc_print(ctx2->env->root->doc); + xmlDocDump(stdout, ctx2->env->root->doc); } else if (ctx2->attachments) { @@ -197,7 +184,7 @@ main(int argc, char *argv[]) else { printf("No attachments!"); - soap_xml_doc_print(ctx2->env->root->doc); + xmlDocDump(stdout, ctx2->env->root->doc); } /* diff --git a/examples/csoap/echoattachments-server.c b/examples/csoap/echoattachments-server.c index a065cc5..abfb7ec 100755 --- a/examples/csoap/echoattachments-server.c +++ b/examples/csoap/echoattachments-server.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: echoattachments-server.c,v 1.10 2006/11/21 20:58:59 m0gg Exp $ + * $Id: echoattachments-server.c,v 1.11 2006/11/23 15:27:33 m0gg Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -22,16 +22,10 @@ ******************************************************************/ #include #include -#include #include #include -#include -#include -#include -#include -#include #include #include @@ -45,7 +39,7 @@ static const char *urn = "urn:examples"; static const char *method = "echo"; herror_t -echo_attachments(SoapCtx * req, SoapCtx * res) +echo_attachments(struct SoapCtx * req, struct SoapCtx * res) { herror_t err; @@ -70,20 +64,18 @@ echo_attachments(SoapCtx * req, SoapCtx * res) return H_OK; } - int -main(int argc, char *argv[]) +main(int argc, char **argv) { herror_t err; - SoapRouter *router; + struct SoapRouter *router; hlog_set_level(HLOG_VERBOSE); err = soap_server_init_args(argc, argv); if (err != H_OK) { - log_error4("%s():%s [%d]", herror_func(err), herror_message(err), - herror_code(err)); + printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err)); herror_release(err); return 1; } diff --git a/examples/csoap/simpleclient.c b/examples/csoap/simpleclient.c index 6a4451e..1e3b3ff 100644 --- a/examples/csoap/simpleclient.c +++ b/examples/csoap/simpleclient.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: simpleclient.c,v 1.14 2006/11/21 20:58:59 m0gg Exp $ + * $Id: simpleclient.c,v 1.15 2006/11/23 15:27:33 m0gg Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -22,18 +22,14 @@ ******************************************************************/ #include #include -#include #include #include -#include -#include -#include -#include -#include #include +#include +#include #include static char *url = "http://localhost:10000/csoapserver"; @@ -41,12 +37,12 @@ static char *urn = "urn:examples"; static char *method = "sayHello"; int -main(int argc, char *argv[]) +main(int argc, char **argv) { - SoapCtx *ctx, *ctx2; + struct SoapCtx *ctx, *ctx2; herror_t err; - // hlog_set_level(HLOG_VERBOSE); + hlog_set_level(HLOG_VERBOSE); err = soap_client_init_args(argc, argv); if (err != H_OK) @@ -67,7 +63,7 @@ main(int argc, char *argv[]) soap_env_add_item(ctx->env, "xsd:string", "name", "Jonny B. Good"); printf("**** sending ****\n"); - soap_xml_doc_print(ctx->env->root->doc); + xmlDocDump(stderr, ctx->env->root->doc); if (argc > 1) url = argv[1]; @@ -82,7 +78,7 @@ main(int argc, char *argv[]) } printf("**** received ****\n"); - soap_xml_doc_print(ctx2->env->root->doc); + xmlDocDump(stdout, ctx2->env->root->doc); soap_ctx_free(ctx2); soap_ctx_free(ctx); diff --git a/examples/csoap/simpleserver.c b/examples/csoap/simpleserver.c index a433783..c67d0e5 100644 --- a/examples/csoap/simpleserver.c +++ b/examples/csoap/simpleserver.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: simpleserver.c,v 1.21 2006/11/21 20:59:02 m0gg Exp $ + * $Id: simpleserver.c,v 1.22 2006/11/23 15:27:33 m0gg Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -22,16 +22,11 @@ ******************************************************************/ #include #include -#include #include +#include #include -#include -#include -#include -#include -#include #include #include @@ -46,7 +41,7 @@ static const char const *urn = "urn:examples"; static const char const *method = "sayHello"; herror_t -say_hello(SoapCtx * req, SoapCtx * res) +say_hello(struct SoapCtx *req, struct SoapCtx *res) { herror_t err; char *name; @@ -76,11 +71,11 @@ say_hello(SoapCtx * req, SoapCtx * res) } int -main(int argc, char *argv[]) +main(int argc, char **argv) { herror_t err; - SoapRouter *router; + struct SoapRouter *router; // hlog_set_level(HLOG_VERBOSE); diff --git a/examples/csoap/soapclient.c b/examples/csoap/soapclient.c index c7d55f3..ea7d05f 100644 --- a/examples/csoap/soapclient.c +++ b/examples/csoap/soapclient.c @@ -7,19 +7,15 @@ #include #include #include -#include #include #include #include -#include -#include -#include -#include -#include -#include +// #include +// #include +// #include #include #include @@ -128,7 +124,7 @@ stripcslashes(char *str, int *len) // to the SOAP request */ void -ParseLine(SoapCtx * ctx, char *Buffer, int LineLen) +ParseLine(struct SoapCtx * ctx, char *Buffer, int LineLen) { char *Line, *FirstCommaPos, *SecondCommaPos; int len; @@ -191,7 +187,7 @@ printusage(char *FileName) int main(int argc, char *argv[]) { - SoapCtx *ctx, *ctx2; + struct SoapCtx *ctx, *ctx2; herror_t err; /* create buffer */ @@ -211,7 +207,7 @@ main(int argc, char *argv[]) err = soap_client_init_args(argc, argv); if (err != H_OK) { - log_error4("%s():%s [%d]", herror_func(err), + printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err)); herror_release(err); return 1; @@ -221,7 +217,7 @@ main(int argc, char *argv[]) err = soap_ctx_new_with_method(argv[2], argv[3], &ctx); if (err != H_OK) { - log_error4("%s():%s [%d]", herror_func(err), + printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err)); herror_release(err); return 1; @@ -244,7 +240,7 @@ main(int argc, char *argv[]) bytes_left = strlen(Buffer); if (bytes_left == MAX_LINE_LENGTH) { - log_error1("The parameter line is too long."); + printf("The parameter line is too long."); herror_release(err); soap_ctx_free(ctx); return 1; @@ -255,7 +251,7 @@ main(int argc, char *argv[]) err = soap_client_invoke(ctx, &ctx2, argv[1], ""); if (err != H_OK) { - log_error4("[%d] %s(): %s ", herror_code(err), + printf("[%d] %s(): %s ", herror_code(err), herror_func(err), herror_message(err)); herror_release(err); soap_ctx_free(ctx); @@ -263,7 +259,7 @@ main(int argc, char *argv[]) } /* print the result */ - soap_xml_doc_print(ctx2->env->root->doc); + xmlDocDump(stdout, ctx2->env->root->doc); /* free the objects */ soap_ctx_free(ctx2); diff --git a/examples/nanohttp/http_client.c b/examples/nanohttp/http_client.c index 4fa5bed..f871739 100644 --- a/examples/nanohttp/http_client.c +++ b/examples/nanohttp/http_client.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: http_client.c,v 1.4 2006/11/21 20:59:02 m0gg Exp $ +* $Id: http_client.c,v 1.5 2006/11/23 15:27:33 m0gg Exp $ * * CSOAP Project: A http client/server library in C (example) * Copyright (C) 2003-2004 Ferhat Ayaz @@ -24,10 +24,8 @@ #include #include #include -#include #include -#include #include #include #include diff --git a/examples/nanohttp/http_server.c b/examples/nanohttp/http_server.c index 420c32f..950a717 100644 --- a/examples/nanohttp/http_server.c +++ b/examples/nanohttp/http_server.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: http_server.c,v 1.6 2006/11/21 20:59:02 m0gg Exp $ +* $Id: http_server.c,v 1.7 2006/11/23 15:27:33 m0gg Exp $ * * CSOAP Project: A http client/server library in C (example) * Copyright (C) 2003 Ferhat Ayaz @@ -23,17 +23,15 @@ ******************************************************************/ #include #include -#include #include -#include #include #include #include #include #include -static int simple_authenticator(hrequest_t *req, const char *user, const char *password) +static int simple_authenticator(struct hrequest_t *req, const char *user, const char *password) { log_info3("logging in user=\"%s\" password=\"%s\"", user, password); @@ -53,11 +51,11 @@ static int simple_authenticator(hrequest_t *req, const char *user, const char *p return 1; } -static void secure_service(httpd_conn_t *conn, hrequest_t *req) +static void secure_service(httpd_conn_t *conn, struct hrequest_t *req) { httpd_send_header(conn, 200, "OK"); - hsocket_send(conn->sock, + http_output_stream_write_string(conn->out, "" "" "Secure ressource!" @@ -70,11 +68,11 @@ static void secure_service(httpd_conn_t *conn, hrequest_t *req) return; } -static void default_service(httpd_conn_t *conn, hrequest_t *req) +static void default_service(httpd_conn_t *conn, struct hrequest_t *req) { httpd_send_header(conn, 404, "Not found"); - hsocket_send(conn->sock, + http_output_stream_write_string(conn->out, "" "" "Default error page" @@ -83,9 +81,9 @@ static void default_service(httpd_conn_t *conn, hrequest_t *req) "

Default error page

" "
"); - hsocket_send(conn->sock, req->path); + http_output_stream_write_string(conn->out, req->path); - hsocket_send(conn->sock, " can not be found" + http_output_stream_write_string(conn->out, " can not be found" "
" "" ""); @@ -93,12 +91,12 @@ static void default_service(httpd_conn_t *conn, hrequest_t *req) return; } -static void headers_service(httpd_conn_t *conn, hrequest_t *req) +static void headers_service(httpd_conn_t *conn, struct hrequest_t *req) { hpair_t *walker; httpd_send_header(conn, 200, "OK"); - hsocket_send(conn->sock, + http_output_stream_write_string(conn->out, "" "" "Request headers" @@ -109,14 +107,14 @@ static void headers_service(httpd_conn_t *conn, hrequest_t *req) for (walker=req->header; walker; walker=walker->next) { - hsocket_send(conn->sock, "
  • "); - hsocket_send(conn->sock, walker->key); - hsocket_send(conn->sock, " = "); - hsocket_send(conn->sock, walker->value); - hsocket_send(conn->sock, "
  • "); + http_output_stream_write_string(conn->out, "
  • "); + http_output_stream_write_string(conn->out, walker->key); + http_output_stream_write_string(conn->out, " = "); + http_output_stream_write_string(conn->out, walker->value); + http_output_stream_write_string(conn->out, "
  • "); } - hsocket_send(conn->sock, + http_output_stream_write_string(conn->out, "" "" ""); @@ -124,10 +122,10 @@ static void headers_service(httpd_conn_t *conn, hrequest_t *req) return; } -static void root_service(httpd_conn_t *conn, hrequest_t *req) +static void root_service(httpd_conn_t *conn, struct hrequest_t *req) { httpd_send_header(conn, 200, "OK"); - hsocket_send(conn->sock, + http_output_stream_write_string(conn->out, "" "" "nanoHTTP server examples" @@ -147,7 +145,7 @@ static void root_service(httpd_conn_t *conn, hrequest_t *req) return; } -int main(int argc, char *argv[]) +int main(int argc, char **argv) { hlog_set_level(HLOG_INFO); -- cgit v1.1-32-gdbae