~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to tools/gsoap/gsoap-linux-2.7/custom/.svn/text-base/struct_tm.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
 
struct_tm.c
4
 
 
5
 
Custom serializer for <time.h> struct tm
6
 
 
7
 
Compile this file and link it with your code.
8
 
 
9
 
gSOAP XML Web services tools
10
 
Copyright (C) 2000-2005, Robert van Engelen, Genivia Inc., All Rights Reserved.
11
 
This part of the software is released under one of the following licenses:
12
 
GPL, the gSOAP public license, or Genivia's license for commercial use.
13
 
--------------------------------------------------------------------------------
14
 
gSOAP public license.
15
 
 
16
 
The contents of this file are subject to the gSOAP Public License Version 1.3
17
 
(the "License"); you may not use this file except in compliance with the
18
 
License. You may obtain a copy of the License at
19
 
http://www.cs.fsu.edu/~engelen/soaplicense.html
20
 
Software distributed under the License is distributed on an "AS IS" basis,
21
 
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
22
 
for the specific language governing rights and limitations under the License.
23
 
 
24
 
The Initial Developer of the Original Code is Robert A. van Engelen.
25
 
Copyright (C) 2000-2005, Robert van Engelen, Genivia, Inc., All Rights Reserved.
26
 
--------------------------------------------------------------------------------
27
 
GPL license.
28
 
 
29
 
This program is free software; you can redistribute it and/or modify it under
30
 
the terms of the GNU General Public License as published by the Free Software
31
 
Foundation; either version 2 of the License, or (at your option) any later
32
 
version.
33
 
 
34
 
This program is distributed in the hope that it will be useful, but WITHOUT ANY
35
 
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
36
 
PARTICULAR PURPOSE. See the GNU General Public License for more details.
37
 
 
38
 
You should have received a copy of the GNU General Public License along with
39
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
40
 
Place, Suite 330, Boston, MA 02111-1307 USA
41
 
 
42
 
Author contact information:
43
 
engelen@genivia.com / engelen@acm.org
44
 
--------------------------------------------------------------------------------
45
 
A commercial use license is available from Genivia, Inc., contact@genivia.com
46
 
--------------------------------------------------------------------------------
47
 
*/
48
 
 
49
 
// soapH.h generated by soapcpp2 from .h file containing #import "struct_tm.h":
50
 
#include "soapH.h"
51
 
 
52
 
void soap_default_xsd__dateTime(struct soap *soap, struct tm *a)
53
 
{ memset(a, 0, sizeof(struct tm));
54
 
}
55
 
 
56
 
void soap_serialize_xsd__dateTime(struct soap *soap, struct tm const *a)
57
 
{ }
58
 
 
59
 
int soap_out_xsd__dateTime(struct soap *soap, const char *tag, int id, const struct tm *a, const char *type)
60
 
{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_xsd__dateTime), type)
61
 
   || soap_string_out(soap, soap_xsd__dateTime2s(soap, *a), 0))
62
 
    return soap->error;
63
 
  return soap_element_end_out(soap, tag);
64
 
}
65
 
 
66
 
const char *soap_xsd__dateTime2s(struct soap *soap, const struct tm a)
67
 
{ strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", &a);
68
 
  return soap->tmpbuf;
69
 
}
70
 
 
71
 
struct tm *soap_in_xsd__dateTime(struct soap *soap, const char *tag, struct tm *a, const char *type)
72
 
{ if (soap_element_begin_in(soap, tag, 0, NULL))
73
 
    return NULL;
74
 
  if (*soap->type
75
 
   && soap_match_tag(soap, soap->type, type)
76
 
   && soap_match_tag(soap, soap->type, ":dateTime"))
77
 
  { soap->error = SOAP_TYPE;
78
 
    soap_revert(soap);
79
 
    return NULL;
80
 
  }
81
 
  a = (struct tm*)soap_id_enter(soap, soap->id, a, SOAP_TYPE_xsd__dateTime, sizeof(struct tm), 0, NULL, NULL, NULL);
82
 
  if (*soap->href)
83
 
    a = (struct tm*)soap_id_forward(soap, soap->href, a, 0, SOAP_TYPE_xsd__dateTime, 0, sizeof(struct tm), 0, NULL);
84
 
  else if (a)
85
 
  { if (soap_s2xsd__dateTime(soap, soap_value(soap), a))
86
 
      return NULL;
87
 
  }
88
 
  if (soap->body && soap_element_end_in(soap, tag))
89
 
    return NULL;
90
 
  return a;
91
 
}
92
 
 
93
 
int soap_s2xsd__dateTime(struct soap *soap, const char *s, struct tm *a)
94
 
{ memset((void*)a, 0, sizeof(struct tm));
95
 
  if (s)
96
 
  { char zone[32];
97
 
    const char *t;
98
 
    zone[sizeof(zone)-1] = '\0';
99
 
    if (strchr(s, '-'))
100
 
      t = "%d-%d-%dT%d:%d:%d%31s";
101
 
    else if (strchr(s, ':'))
102
 
      t = "%4d%2d%2dT%d:%d:%d%31s";
103
 
    else /* parse non-XSD-standard alternative ISO 8601 format */
104
 
      t = "%4d%2d%2dT%2d%2d%2d%31s";
105
 
    sscanf(s, t, &a->tm_year, &a->tm_mon, &a->tm_mday, &a->tm_hour, &a->tm_min, &a->tm_sec, zone);
106
 
    a->tm_wday = -1;
107
 
    a->tm_yday = -1;
108
 
    if (a->tm_year == 1)
109
 
      a->tm_year = 70;
110
 
    else
111
 
      a->tm_year -= 1900;
112
 
    a->tm_mon--;
113
 
    if (*zone)
114
 
    { if (*zone == '.')
115
 
      { for (s = zone + 1; *s; s++)
116
 
          if (*s < '0' || *s > '9')
117
 
            break;
118
 
      }
119
 
      else
120
 
        s = zone;
121
 
      if (*s == '+' || *s == '-')
122
 
      { int h = 0, m = 0;
123
 
        if (s[3] == ':')
124
 
        { sscanf(s, "%d:%d", &h, &m);
125
 
          if (h < 0)
126
 
            m = -m;
127
 
        }
128
 
        else
129
 
        { m = (int)atol(s);
130
 
          h = m / 100;
131
 
          m = m % 100;
132
 
        }
133
 
        a->tm_hour -= h;
134
 
        a->tm_min -= m;
135
 
      }
136
 
      a->tm_isdst = 0;
137
 
    }
138
 
    else
139
 
      a->tm_isdst = -1;
140
 
  }
141
 
  return soap->error;
142
 
}