~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to tools/gsoap/macosx-x86-2.7/extras/.svn/text-base/httpmd5test.c.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 
3
 
httpmd5test.c
4
 
 
5
 
gSOAP HTTP Content-MD5 digest plugin example application.
6
 
 
7
 
gSOAP XML Web services tools
8
 
Copyright (C) 2000-2004, Robert van Engelen, Genivia, Inc., All Rights Reserved.
9
 
 
10
 
--------------------------------------------------------------------------------
11
 
gSOAP public license.
12
 
 
13
 
The contents of this file are subject to the gSOAP Public License Version 1.3
14
 
(the "License"); you may not use this file except in compliance with the
15
 
License. You may obtain a copy of the License at
16
 
http://www.cs.fsu.edu/~engelen/soaplicense.html
17
 
Software distributed under the License is distributed on an "AS IS" basis,
18
 
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19
 
for the specific language governing rights and limitations under the License.
20
 
 
21
 
The Initial Developer of the Original Code is Robert A. van Engelen.
22
 
Copyright (C) 2000-2004, Robert van Engelen, Genivia, Inc., All Rights Reserved.
23
 
--------------------------------------------------------------------------------
24
 
GPL license.
25
 
 
26
 
This program is free software; you can redistribute it and/or modify it under
27
 
the terms of the GNU General Public License as published by the Free Software
28
 
Foundation; either version 2 of the License, or (at your option) any later
29
 
version.
30
 
 
31
 
This program is distributed in the hope that it will be useful, but WITHOUT ANY
32
 
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
33
 
PARTICULAR PURPOSE. See the GNU General Public License for more details.
34
 
 
35
 
You should have received a copy of the GNU General Public License along with
36
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
37
 
Place, Suite 330, Boston, MA 02111-1307 USA
38
 
 
39
 
Author contact information:
40
 
engelen@genivia.com / engelen@acm.org
41
 
--------------------------------------------------------------------------------
42
 
 
43
 
Requires OpenSSL
44
 
 
45
 
Compile:
46
 
 
47
 
soapcpp2 -c httpmd5test.h
48
 
cc -DWITH_OPENSSL -o httpmd5test httpmd5test.c soapC.c soapClient.c soapServer.c httpmd5.c stdsoap2.c -lssl -lcrypto -lz
49
 
 
50
 
*/
51
 
 
52
 
#include "httpmd5.h"
53
 
#include "soapH.h"
54
 
#include "ns.nsmap"
55
 
 
56
 
static int http_md5_handler(struct soap *soap, void **context, enum http_md5_action, char *buf, size_t len);
57
 
 
58
 
int main(int argc, char **argv)
59
 
{ struct soap soap;
60
 
  struct ns__echoString r;
61
 
  soap_init(&soap);
62
 
  soap_register_plugin_arg(&soap, http_md5, http_md5_handler);
63
 
  if (argc < 2)
64
 
    soap_serve(&soap);
65
 
  else if (soap_call_ns__echoString(&soap, "http://", NULL, argv[1], &r))
66
 
    soap_print_fault(&soap, stderr);
67
 
  soap_end(&soap);
68
 
  soap_done(&soap);
69
 
  return 0;
70
 
}
71
 
 
72
 
int ns__echoString(struct soap *soap, char *arg, struct ns__echoString *response)
73
 
{ response->arg = arg;
74
 
  return SOAP_OK;
75
 
}
76
 
 
77
 
static int http_md5_handler(struct soap *soap, void **context, enum http_md5_action action, char *buf, size_t len)
78
 
{ const EVP_MD *m;
79
 
  EVP_MD_CTX *ctx;
80
 
  unsigned char hash[EVP_MAX_MD_SIZE];
81
 
  unsigned int size;
82
 
  switch (action)
83
 
  { case HTTP_MD5_INIT:
84
 
      OpenSSL_add_all_digests();
85
 
      if (!(m = EVP_get_digestbyname("md5")))
86
 
        return SOAP_PLUGIN_ERROR;
87
 
      if (!*context)
88
 
        *context = (void*)malloc(sizeof(EVP_MD_CTX));
89
 
      ctx = (EVP_MD_CTX*)*context;
90
 
#ifdef DEBUG
91
 
      fprintf(stderr, "MD5 Init %p\n", ctx);
92
 
#endif
93
 
      EVP_DigestInit(ctx, m);
94
 
      break;
95
 
    case HTTP_MD5_UPDATE:
96
 
      ctx = (EVP_MD_CTX*)*context;
97
 
#ifdef DEBUG
98
 
      fprintf(stderr, "MD5 Update %p: ", ctx);
99
 
      fwrite(buf, len, 1, stderr);
100
 
      fprintf(stderr, "\n");
101
 
#endif
102
 
      EVP_DigestUpdate(ctx, (void*)buf, (unsigned int)len);
103
 
      break;
104
 
    case HTTP_MD5_FINAL:
105
 
      ctx = (EVP_MD_CTX*)*context;
106
 
#ifdef DEBUG
107
 
      fprintf(stderr, "MD5 Final %p\n", ctx);
108
 
#endif
109
 
      EVP_DigestFinal(ctx, (void*)hash, &size);
110
 
      memcpy(buf, hash, 16);
111
 
      break;
112
 
    case HTTP_MD5_DELETE:
113
 
      ctx = (EVP_MD_CTX*)*context;
114
 
#ifdef DEBUG
115
 
      fprintf(stderr, "MD5 Delete %p\n", ctx);
116
 
#endif
117
 
      free(ctx);
118
 
  }
119
 
  return SOAP_OK;
120
 
}