From 07c7c81772c4b60b7980880847f3b21455a0f3c9 Mon Sep 17 00:00:00 2001 From: snowdrop Date: Tue, 10 Jan 2006 11:29:04 +0000 Subject: indent with 'indent -nut -bli0 -fca -npcs' command --- examples/csoap/echoattachments-client.c | 120 ++++++++++++++++---------------- examples/csoap/echoattachments-server.c | 36 +++++----- examples/csoap/simpleclient.c | 42 +++++------ examples/csoap/simpleserver.c | 43 ++++++------ examples/csoap/soapclient.c | 101 +++++++++++++-------------- 5 files changed, 170 insertions(+), 172 deletions(-) (limited to 'examples') diff --git a/examples/csoap/echoattachments-client.c b/examples/csoap/echoattachments-client.c index 353e1d2..b3dd3f8 100755 --- a/examples/csoap/echoattachments-client.c +++ b/examples/csoap/echoattachments-client.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: echoattachments-client.c,v 1.9 2006/01/10 11:21:55 snowdrop Exp $ + * $Id: echoattachments-client.c,v 1.10 2006/01/10 11:29:04 snowdrop Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -32,78 +32,78 @@ static const char *method = "echo"; void -compareFiles (const char *received, const char *sent) +compareFiles(const char *received, const char *sent) { FILE *f1, *f2; char c1, c2; long s1, s2; - printf ("Opening received file to compare: '%s'\n", received); - f1 = fopen (received, "r"); + printf("Opening received file to compare: '%s'\n", received); + f1 = fopen(received, "r"); if (!f1) { - fprintf (stderr, "Can not open '%s'\n", received); + fprintf(stderr, "Can not open '%s'\n", received); return; } - printf ("Opening sent file to compare: '%s'\n", sent); - f2 = fopen (sent, "r"); + printf("Opening sent file to compare: '%s'\n", sent); + f2 = fopen(sent, "r"); if (!f2) { - fprintf (stderr, "Can not open '%s'\n", sent); - fclose (f1); + fprintf(stderr, "Can not open '%s'\n", sent); + fclose(f1); return; } - fseek (f1, 0, SEEK_END); - fseek (f2, 0, SEEK_END); + fseek(f1, 0, SEEK_END); + fseek(f2, 0, SEEK_END); - s1 = ftell (f1); - s2 = ftell (f2); + s1 = ftell(f1); + s2 = ftell(f2); - fseek (f1, 0, SEEK_SET); - fseek (f2, 0, SEEK_SET); + fseek(f1, 0, SEEK_SET); + fseek(f2, 0, SEEK_SET); if (s1 > s2) { - printf ("ERROR: files are not equal! Received file is bigger\n"); - fclose (f1); - fclose (f2); + printf("ERROR: files are not equal! Received file is bigger\n"); + fclose(f1); + fclose(f2); return; } else if (s2 > s1) { - printf ("ERROR: files are not equal! Sent file is bigger\n"); - fclose (f1); - fclose (f2); + printf("ERROR: files are not equal! Sent file is bigger\n"); + fclose(f1); + fclose(f2); return; } - while (feof (f1)) + while (feof(f1)) { - c1 = fgetc (f1); - c2 = fgetc (f2); + c1 = fgetc(f1); + c2 = fgetc(f2); if (c1 != c2) { - printf ("ERROR: files are not equal! Byte compare failed\n"); - fclose (f1); - fclose (f2); + printf("ERROR: files are not equal! Byte compare failed\n"); + fclose(f1); + fclose(f2); break; } } - printf ("OK: files are equal!\n"); - fclose (f1); - fclose (f2); + printf("OK: files are equal!\n"); + fclose(f1); + fclose(f2); } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SoapCtx *ctx, *ctx2; char href[MAX_HREF_SIZE]; @@ -113,86 +113,86 @@ main (int argc, char *argv[]) if (argc < 2) { - fprintf (stderr, "usage: %s [url]\n", argv[0]); - exit (1); + fprintf(stderr, "usage: %s [url]\n", argv[0]); + exit(1); } /* Initialize soap client */ - err = soap_client_init_args (argc, 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)); - herror_release (err); + log_error4("[%d] %s():%s ", herror_code(err), herror_func(err), + herror_message(err)); + herror_release(err); return 1; } /* Create a context object */ - err = soap_ctx_new_with_method (urn, method, &ctx); + 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)); - herror_release (err); + log_error4("[%d] %s():%s ", herror_code(err), herror_func(err), + herror_message(err)); + herror_release(err); return 1; } /* Add file to the context */ - err = soap_ctx_add_file (ctx, argv[1], "application/octet-stream", href); + 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)); - herror_release (err); + log_error4("%s():%s [%d]", herror_func(err), herror_message(err), + herror_code(err)); + herror_release(err); return 1; } /* Add file reference to the envelope */ - soap_env_add_attachment (ctx->env, "source", href); + soap_env_add_attachment(ctx->env, "source", href); /* Send soap request to the server */ - printf ("sending request ...\n"); + printf("sending request ...\n"); if (argc > 2) - err = soap_client_invoke (ctx, &ctx2, argv[2], ""); + err = soap_client_invoke(ctx, &ctx2, argv[2], ""); else - err = soap_client_invoke (ctx, &ctx2, url, ""); + err = soap_client_invoke(ctx, &ctx2, url, ""); if (err != H_OK) { - log_error4 ("%s():%s [%d]", herror_func (err), herror_message (err), - herror_code (err)); - herror_release (err); + log_error4("%s():%s [%d]", herror_func(err), herror_message(err), + herror_code(err)); + herror_release(err); return 1; } /* Handle response (just print to the screen) */ - fault = soap_env_get_fault (ctx2->env); + fault = soap_env_get_fault(ctx2->env); if (fault) { - soap_xml_doc_print (ctx2->env->root->doc); + soap_xml_doc_print(ctx2->env->root->doc); } else if (ctx2->attachments) { - compareFiles (ctx2->attachments->parts->filename, argv[1]); + compareFiles(ctx2->attachments->parts->filename, argv[1]); } else { - printf ("No attachments!"); - soap_xml_doc_print (ctx2->env->root->doc); + printf("No attachments!"); + soap_xml_doc_print(ctx2->env->root->doc); } /* Clean up */ - soap_ctx_free (ctx2); - soap_ctx_free (ctx); + soap_ctx_free(ctx2); + soap_ctx_free(ctx); - soap_client_destroy (); + soap_client_destroy(); return 0; } diff --git a/examples/csoap/echoattachments-server.c b/examples/csoap/echoattachments-server.c index 151d020..4b37aa8 100755 --- a/examples/csoap/echoattachments-server.c +++ b/examples/csoap/echoattachments-server.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: echoattachments-server.c,v 1.6 2006/01/10 11:21:55 snowdrop Exp $ + * $Id: echoattachments-server.c,v 1.7 2006/01/10 11:29:04 snowdrop Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -32,14 +32,14 @@ static const char *method = "echo"; herror_t -echo_attachments (SoapCtx * req, SoapCtx * res) +echo_attachments(SoapCtx * req, SoapCtx * res) { herror_t err; part_t *part; char href[MAX_HREF_SIZE]; - err = soap_env_new_with_response (req->env, &res->env); + err = soap_env_new_with_response(req->env, &res->env); if (err != H_OK) { return err; @@ -49,8 +49,8 @@ echo_attachments (SoapCtx * req, SoapCtx * res) { for (part = req->attachments->parts; part != NULL; part = part->next) { - soap_ctx_add_file (res, part->filename, part->content_type, href); - soap_env_add_attachment (res->env, "echoFile", href); + soap_ctx_add_file(res, part->filename, part->content_type, href); + soap_env_add_attachment(res->env, "echoFile", href); } } @@ -59,31 +59,31 @@ echo_attachments (SoapCtx * req, SoapCtx * res) int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { herror_t err; SoapRouter *router; - log_set_level (HLOG_VERBOSE); + log_set_level(HLOG_VERBOSE); - err = soap_server_init_args (argc, argv); + 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)); - herror_release (err); + log_error4("%s():%s [%d]", herror_func(err), herror_message(err), + herror_code(err)); + herror_release(err); return 1; } - router = soap_router_new (); - soap_router_register_service (router, echo_attachments, method, urn); - soap_server_register_router (router, url); + router = soap_router_new(); + soap_router_register_service(router, echo_attachments, method, urn); + soap_server_register_router(router, url); - log_info1 ("send SIGTERM to shutdown"); - soap_server_run (); + log_info1("send SIGTERM to shutdown"); + soap_server_run(); - log_info1 ("shutting down\n"); - soap_server_destroy (); + log_info1("shutting down\n"); + soap_server_destroy(); return 0; } diff --git a/examples/csoap/simpleclient.c b/examples/csoap/simpleclient.c index 4e0e843..6ae206b 100644 --- a/examples/csoap/simpleclient.c +++ b/examples/csoap/simpleclient.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: simpleclient.c,v 1.10 2006/01/10 11:21:55 snowdrop Exp $ + * $Id: simpleclient.c,v 1.11 2006/01/10 11:29:04 snowdrop Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -30,50 +30,50 @@ static const char *method = "sayHello"; int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SoapCtx *ctx, *ctx2; herror_t err; /* log_set_level(HLOG_VERBOSE); */ - err = soap_client_init_args (argc, argv); + err = soap_client_init_args(argc, argv); if (err != H_OK) { - log_error4 ("%s():%s [%d]", herror_func (err), herror_message (err), - herror_code (err)); - herror_release (err); + log_error4("%s():%s [%d]", herror_func(err), herror_message(err), + herror_code(err)); + herror_release(err); return 1; } - err = soap_ctx_new_with_method (urn, method, &ctx); + err = soap_ctx_new_with_method(urn, method, &ctx); if (err != H_OK) { - log_error4 ("%s():%s [%d]", herror_func (err), herror_message (err), - herror_code (err)); - herror_release (err); + log_error4("%s():%s [%d]", herror_func(err), herror_message(err), + herror_code(err)); + herror_release(err); return 1; } - soap_env_add_item (ctx->env, "xsd:string", "name", "Jonny B. Good"); + soap_env_add_item(ctx->env, "xsd:string", "name", "Jonny B. Good"); if (argc > 1) - err = soap_client_invoke (ctx, &ctx2, argv[1], ""); + err = soap_client_invoke(ctx, &ctx2, argv[1], ""); else - err = soap_client_invoke (ctx, &ctx2, url, ""); + err = soap_client_invoke(ctx, &ctx2, url, ""); if (err != H_OK) { - log_error4 ("[%d] %s(): %s ", herror_code (err), herror_func (err), - herror_message (err)); - herror_release (err); - soap_ctx_free (ctx); + log_error4("[%d] %s(): %s ", herror_code(err), herror_func(err), + herror_message(err)); + herror_release(err); + soap_ctx_free(ctx); return 1; } - soap_xml_doc_print (ctx2->env->root->doc); - soap_ctx_free (ctx2); - soap_ctx_free (ctx); + soap_xml_doc_print(ctx2->env->root->doc); + soap_ctx_free(ctx2); + soap_ctx_free(ctx); - soap_client_destroy (); + soap_client_destroy(); return 0; } diff --git a/examples/csoap/simpleserver.c b/examples/csoap/simpleserver.c index b0d37f9..9edd86f 100644 --- a/examples/csoap/simpleserver.c +++ b/examples/csoap/simpleserver.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: simpleserver.c,v 1.15 2006/01/10 11:21:55 snowdrop Exp $ + * $Id: simpleserver.c,v 1.16 2006/01/10 11:29:04 snowdrop Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -30,7 +30,7 @@ static const char *method = "sayHello"; herror_t -say_hello (SoapCtx * req, SoapCtx * res) +say_hello(SoapCtx * req, SoapCtx * res) { herror_t err; @@ -38,21 +38,20 @@ say_hello (SoapCtx * req, SoapCtx * res) xmlNodePtr method, node; - err = soap_env_new_with_response (req->env, &res->env); + err = soap_env_new_with_response(req->env, &res->env); if (err != H_OK) { return err; } - method = soap_env_get_method (req->env); - node = soap_xml_get_children (method); + method = soap_env_get_method(req->env); + node = soap_xml_get_children(method); while (node) { - name = - (char *) xmlNodeListGetString (node->doc, node->xmlChildrenNode, 1); - soap_env_add_itemf (res->env, "xsd:string", "echo", "Hello '%s'", name); - node = soap_xml_get_next (node); + name = (char *) xmlNodeListGetString(node->doc, node->xmlChildrenNode, 1); + soap_env_add_itemf(res->env, "xsd:string", "echo", "Hello '%s'", name); + node = soap_xml_get_next(node); } return H_OK; @@ -60,32 +59,32 @@ say_hello (SoapCtx * req, SoapCtx * res) int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { herror_t err; SoapRouter *router; - log_set_level (HLOG_INFO); + log_set_level(HLOG_INFO); - err = soap_server_init_args (argc, argv); + 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)); - herror_release (err); + log_error4("%s():%s [%d]", herror_func(err), herror_message(err), + herror_code(err)); + herror_release(err); return 1; } - router = soap_router_new (); - soap_router_register_service (router, say_hello, method, urn); - soap_server_register_router (router, url); + router = soap_router_new(); + soap_router_register_service(router, say_hello, method, urn); + soap_server_register_router(router, url); - log_info1 ("send SIGTERM to shutdown"); - soap_server_run (); + log_info1("send SIGTERM to shutdown"); + soap_server_run(); - log_info1 ("shutting down\n"); - soap_server_destroy (); + log_info1("shutting down\n"); + soap_server_destroy(); return 0; } diff --git a/examples/csoap/soapclient.c b/examples/csoap/soapclient.c index 826d518..7f96364 100644 --- a/examples/csoap/soapclient.c +++ b/examples/csoap/soapclient.c @@ -11,7 +11,7 @@ // stripcslashes - unescapes the string void -stripcslashes (char *str, int *len) +stripcslashes(char *str, int *len) { char *source, *target, *end; int nlen = *len, i; @@ -57,10 +57,10 @@ stripcslashes (char *str, int *len) nlen--; break; case 'x': - if (source + 1 < end && isxdigit ((int) (*(source + 1)))) + if (source + 1 < end && isxdigit((int) (*(source + 1)))) { numtmp[0] = *++source; - if (source + 1 < end && isxdigit ((int) (*(source + 1)))) + if (source + 1 < end && isxdigit((int) (*(source + 1)))) { numtmp[1] = *++source; numtmp[2] = '\0'; @@ -71,7 +71,7 @@ stripcslashes (char *str, int *len) numtmp[1] = '\0'; nlen -= 2; } - *target++ = (char) strtol (numtmp, NULL, 16); + *target++ = (char) strtol(numtmp, NULL, 16); break; } default: @@ -83,7 +83,7 @@ stripcslashes (char *str, int *len) if (i) { numtmp[i] = '\0'; - *target++ = (char) strtol (numtmp, NULL, 8); + *target++ = (char) strtol(numtmp, NULL, 8); nlen -= i; source--; } @@ -108,24 +108,24 @@ stripcslashes (char *str, int *len) // ParseLine - gets a line, finds the commas, unescapes the value and adds it // to the SOAP request void -ParseLine (SoapCtx * ctx, char *Buffer, int LineLen) +ParseLine(SoapCtx * ctx, char *Buffer, int LineLen) { // if wrong line length, return if (LineLen <= 0) return; // alloc buffer for the line, copy it - char *Line = (char *) malloc (LineLen + 1); - memcpy (Line, Buffer, LineLen); + char *Line = (char *) malloc(LineLen + 1); + memcpy(Line, Buffer, LineLen); Line[LineLen] = '\0'; // find first comma - char *FirstCommaPos = strchr (Line, ','); + char *FirstCommaPos = strchr(Line, ','); if (!FirstCommaPos) return; // find second comma - char *SecondCommaPos = strchr (FirstCommaPos + 1, ','); + char *SecondCommaPos = strchr(FirstCommaPos + 1, ','); if (!SecondCommaPos) return; @@ -134,29 +134,29 @@ ParseLine (SoapCtx * ctx, char *Buffer, int LineLen) SecondCommaPos[0] = '\0'; // unescape - int len = strlen (SecondCommaPos + 1); - stripcslashes (SecondCommaPos + 1, &len); + int len = strlen(SecondCommaPos + 1); + stripcslashes(SecondCommaPos + 1, &len); // add to the request - soap_env_add_item (ctx->env, Line, FirstCommaPos + 1, SecondCommaPos + 1); + soap_env_add_item(ctx->env, Line, FirstCommaPos + 1, SecondCommaPos + 1); // free the buffer - free (Line); + free(Line); } void -printusage (char *FileName) +printusage(char *FileName) { - printf ("Usage: %s [URL] [URN] [SOAPMETHOD]\n\n", FileName); - printf ("- [URL] is the url of the SOAP server.\n"); - printf ("- [URN] is the namespace for the method/webservice.\n"); - printf ("- [SOAPMETHOD] is the method to call.\n\n"); - printf ("All commandline paramaters are mandatory.\n\n"); + printf("Usage: %s [URL] [URN] [SOAPMETHOD]\n\n", FileName); + printf("- [URL] is the url of the SOAP server.\n"); + printf("- [URN] is the namespace for the method/webservice.\n"); + printf("- [SOAPMETHOD] is the method to call.\n\n"); + printf("All commandline paramaters are mandatory.\n\n"); printf ("%s reads the parameters for the SOAPMETHOD from STDIN as a comma-separated list\n\n", FileName); - printf ("Each line is one parameter and has the following form:\n\n"); - printf ("xsd:[TYPE],[PARAMETERNAME],[PARAMETERVALUE]\n\n"); + printf("Each line is one parameter and has the following form:\n\n"); + printf("xsd:[TYPE],[PARAMETERNAME],[PARAMETERVALUE]\n\n"); printf ("- [TYPE] is a basic type for SOAP or a complex type defined by the WSDL.\n"); printf @@ -166,7 +166,7 @@ printusage (char *FileName) } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SoapCtx *ctx, *ctx2; herror_t err; @@ -174,27 +174,27 @@ main (int argc, char *argv[]) // check the parameter count if (argc != 4) { - printusage (argv[0]); + printusage(argv[0]); return 1; } // init cSOAP client - err = soap_client_init_args (argc, argv); + err = soap_client_init_args(argc, argv); if (err != H_OK) { - log_error4 ("%s():%s [%d]", herror_func (err), - herror_message (err), herror_code (err)); - herror_release (err); + log_error4("%s():%s [%d]", herror_func(err), + herror_message(err), herror_code(err)); + herror_release(err); return 1; } // create a SoapCtx object - err = soap_ctx_new_with_method (argv[2], argv[3], &ctx); + err = soap_ctx_new_with_method(argv[2], argv[3], &ctx); if (err != H_OK) { - log_error4 ("%s():%s [%d]", herror_func (err), - herror_message (err), herror_code (err)); - herror_release (err); + log_error4("%s():%s [%d]", herror_func(err), + herror_message(err), herror_code(err)); + herror_release(err); return 1; } @@ -203,51 +203,50 @@ main (int argc, char *argv[]) int bytes_read, bytes_left; // read from stdin until EOF - while (!feof (stdin)) + while (!feof(stdin)) { - bytes_read = fread (Buffer, 1, MAX_LINE_LENGTH, stdin); + bytes_read = fread(Buffer, 1, MAX_LINE_LENGTH, stdin); // pass each line into ParseLine char *EndLinePos; - while (EndLinePos = strchr (Buffer, '\n')) + while (EndLinePos = strchr(Buffer, '\n')) { - ParseLine (ctx, Buffer, EndLinePos - Buffer); - memmove (Buffer, EndLinePos + 1, bytes_read - (EndLinePos - - Buffer + 1)); + ParseLine(ctx, Buffer, EndLinePos - Buffer); + memmove(Buffer, EndLinePos + 1, bytes_read - (EndLinePos - Buffer + 1)); Buffer[bytes_read - (EndLinePos - Buffer + 1)] = '\0'; } // no '\n' found in the whole Buffer, that means line's too - long bytes_left = strlen (Buffer); + long bytes_left = strlen(Buffer); if (bytes_left == MAX_LINE_LENGTH) { - log_error1 ("The parameter line is too long."); - herror_release (err); - soap_ctx_free (ctx); + log_error1("The parameter line is too long."); + herror_release(err); + soap_ctx_free(ctx); return 1; } } // invoke - err = soap_client_invoke (ctx, &ctx2, argv[1], ""); + err = soap_client_invoke(ctx, &ctx2, argv[1], ""); if (err != H_OK) { - log_error4 ("[%d] %s(): %s ", herror_code (err), - herror_func (err), herror_message (err)); - herror_release (err); - soap_ctx_free (ctx); + log_error4("[%d] %s(): %s ", herror_code(err), + herror_func(err), herror_message(err)); + herror_release(err); + soap_ctx_free(ctx); return 1; } // print the result - soap_xml_doc_print (ctx2->env->root->doc); + soap_xml_doc_print(ctx2->env->root->doc); // free the objects - soap_ctx_free (ctx2); - soap_ctx_free (ctx); + soap_ctx_free(ctx2); + soap_ctx_free(ctx); // destroy the cSOAP client - soap_client_destroy (); + soap_client_destroy(); return 0; } -- cgit v1.1-32-gdbae