[mod_rayo, mod_ssml, iksemel] Remove from tree

This commit is contained in:
Andrey Volk
2024-12-31 13:43:48 +03:00
parent 3687972db7
commit 0e412ac0ee
211 changed files with 2 additions and 56590 deletions

28
libs/.gitignore vendored
View File

@@ -58,32 +58,6 @@ opal
/esl/Release/
/flite-*/
/freeradius-client-*/
/iksemel/build/compile
/iksemel/doc/Makefile
/iksemel/doc/Makefile.in
/iksemel/include/config.h
/iksemel/include/Makefile
/iksemel/include/Makefile.in
/iksemel/include/stamp-h1
/iksemel/Makefile
/iksemel/Makefile.in
/iksemel/src/Makefile
/iksemel/src/Makefile.in
/iksemel/test/Makefile
/iksemel/test/Makefile.in
/iksemel/test/tst-dom
/iksemel/test/tst-filter
/iksemel/test/tst-iks
/iksemel/test/tst-ikstack
/iksemel/test/tst-jid
/iksemel/test/tst-md5
/iksemel/test/tst-sax
/iksemel/test/tst-sha
/iksemel/tools/ikslint
/iksemel/tools/iksperf
/iksemel/tools/iksroster
/iksemel/tools/Makefile
/iksemel/tools/Makefile.in
/ilbc/config-h.in
/ilbc/doc/Makefile
/ilbc/doc/Makefile.in
@@ -600,7 +574,6 @@ opal
/v8-*.zip
# build products we should remove
!/iksemel/ltmain.sh
!/libg722_1/config/depcomp
!/libg722_1/config/missing
!/tiff-*/config/depcomp
@@ -622,7 +595,6 @@ srtp/build/compile
/portaudio/
portaudio.*.log
apr/configure
iksemel/configure
libyuv/Makefile
libyuv/convert
srtp/configure

View File

@@ -1 +0,0 @@
Mon Jul 15 16:57:11 CDT 2013

View File

@@ -1,17 +0,0 @@
Author
======
Gurer Ozen <madcat@e-kolay.net>
Contributions
=============
Bernhard R. Link (code)
Fabien Ninoles (code)
Evan Prodromou (jabberx improvements, project maintenance)
David Yitzchak Cohen (countless bug reports)
Benoit Laniel (mingw port)
Darrell Karbott (ikstransport)
Rafal Piotrowski (SASL auth)

View File

@@ -1,515 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations
below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
^L
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it
becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
^L
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control
compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
^L
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
^L
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
^L
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
^L
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply, and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License
may add an explicit geographical distribution limitation excluding those
countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
^L
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
^L
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms
of the ordinary General Public License).
To apply these terms, attach the following notices to the library.
It is safest to attach them to the start of each source file to most
effectively convey the exclusion of warranty; and each file should
have at least the "copyright" line and a pointer to where the full
notice is found.
<one line to give the library's name and a brief idea of what it
does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper
mail.
You should also get your employer (if you work as a programmer) or
your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James
Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@@ -1,648 +0,0 @@
2007-08-02 Gurer
* tst-iks.c: test for new append/prepend functions added.
2007-08-01 Gurer
* Patch from Benjamin Bennett:
base64.c: fix padding
* sha.c: 64bit fix (long -> int)
* iks.c: new funcs: iks_append, iks_prepend
iks_append_cdata, iks_prepend_cdata
* stream.c: iks_sasl_challenge split into smaller functions
This change also fixes some possible leaks which are detected
by Coverity Inc's excellent Prevent product.
2006-05-19 Gurer
* dom.c: fixed (size % FILE_IO_BUFFER_SIZE) problem in iks_load()
2005-08-29 Gurer
* Patch from Jakob Schroter:
iksemel.texi: small documentation update
* Patch from Darrell Karbott:
sax.c: use fixed instead of floating point (for arm)
mark static const data properly
explicit char* uchar* casts
2004-08-14 Gurer
* version bump to 1.3
* patch from Roland Hedberg
io-posix.c: io_connect now tries all addrinfo values.
2004-08-05 Gurer
* iksemel.h: ikstransport cosmetic cleanup.
* iksemel.texi: mingw notice added.
2004-07-30 Gurer
* iksemel.h: get_fd and connect_fd is removed from ikstransport api.
ikstransport structure now has an abi_version field.
new IKS_TRANSPORT_V1 macro defined for using in abi_version.
* io-posix.c: modified for new ikstransport scheme.
* stream.c: iks_connect_fd and iks_fd now works directly.
2004-07-30 Gurer
* sax.c: bug in parser's utf8 checker fixed.
2004-07-28 Gurer
* stream.c: buffer size corrected in iks_send_header.
2004-07-26 Gurer
* iksroster.c: "iksroster" resource is default, if not given by user.
* stream.c: iks_start_tls() cosmetic cleanup.
2004-07-23 Gurer
* iks.c: ikstack value of attribute nodes wasnt set correctly. fixed.
2004-07-21 Gurer
* patch from Benoit Laniel
configure.ac: objdump check for cross compiling
iksroster.c, perf.c, io-unix.c: WIN32 is changed to _WIN32
2004-07-19 Gurer
* iks.c: iks_child() verifies that node is a tag before accessing
children field in struct.
2004-07-13 Gurer
* stream.c: if no realm is provided in sasl, server name is used
2004-06-14 Gurer
* iksemel.texi: sasl&tls funcs documented a bit.
2004-06-14 Gurer
* patch from Darrell Karbott
iksemel.h: async events are passed as a struct
ikstransport struct is defined as const
server_name is passed to the iksTConnectAsync
additional network error codes
stream.c: iks_recv() checks if iks_disconnect called during parsing
2004-05-22 Gurer
* iks.c: iks_cdata() returns value for attributes
* sax.c: utf8 stack_pos fix
2004-05-19 Gurer
* io-posix.c: now compiles without getaddrinfo()
2004-05-05 Gurer
* sax.c: iks_parser_stack() added, returns the ikstack of an iksparser
* stream.c: ikstranport api is now passing iksparser instead of ikstack
to the connect functions.
2004-05-05 Gurer
* stream.c: patch from Rafal Piotrowski
iks_sasl_challenge() cleanup
2004-05-01 Gurer
* iksroster.c: sasl auth finally works.
2004-04-30 Gurer
* iksroster.c: cleanup.
2004-04-30 Gurer
* Another patch from Rafal Piotrowski
tst-md5.c: test code for md5.c functions, and new utils:
iks_make_resource_bind(), iks_make_session(), iks_stream_features()
* iksemel.h: iks_auth_sasl renamed to iks_start_sasl
IKS_AUTH_SASL_PLAIN renamed to IKS_SASL_PLAIN
IKS_AUTH_SASL_DIGEST_MD5 renamed to IKS_SASL_DIGEST_MD5
2004-04-29 Gurer
* Patch from Rafal Piotrowski applied
md5 and base64 api, and sasl auth support!
* iksroster.c: --sasl option added.
2004-04-27 Gurer
* io-unix.c: renamed to io-posix.c, it runs on windows with mingw
so less confusion this way.
* stream.c: warnings cleaned up, iks_connect_async_with finished.
2004-04-26 Gurer
* iksemel.h: new error code IKS_NET_TLSFAIL
* stream.c: tls code cleaned up.
* configure.ac: new option --disable-default-io
you can use it to disable compiling of io-unix.c if you dont need
it and want to use your own socket code.
2004-04-13 Gurer
* iksemel.h: new error code IKS_NET_NOTSUPP
* stream.c: not supported error code is supported now :)
* sha.c: free() is replaced with iks_free()
2004-04-10 Gurer
* stream.c: saga continues, tls is working on ikstransport.
* iksroster.c: --log option for turning on xml debug output.
2004-04-10 Gurer
* stream.c: second part:
it is using iks_default_transport (provided by io-unix.c) now.
all network code is removed.
iks_connect_with() allows you to use your own transport code.
(note: testing needed and async api is not fully implemented yet)
2004-04-10 Gurer
* iksemel.h: first part of the long expected socket abstraction.
many thanks to Darrell Karbott for ideas and a sample implementation.
* io-unix.c: new file, transport code for unix sockets.
2004-03-22 Gurer
* dom.c: iks_load() now frees the resources if iks_parse returns error.
2004-03-19 Gurer
* stream.c: iks_is_secure() added, checks that if a stream is secured.
* iksroster.c: cleanup a bit.
2004-03-18 Gurer
* iksroster.c, stream.c: secure connection works, but api isn't
stablized yet, and some cleanup needed.
2004-03-08 Gurer
* iksroster.c: new option for secure connection, needs testing.
2004-03-01 Gurer
* sax.c: second part, IKS_NOMEM conditions are checked properly.
2004-02-29 Gurer
* iksemel.h: stddef.h is included to get size_t for C apps.
* sax.c: first part of the memory usage optimization.
2004-02-27 Gurer
* iksemel.h: cstddef is included for C++ apps to provide size_t type.
2004-02-25 Gurer
* src/sha.c: iks_sha_print() uses lowercase hex numbers now.
2004-02-10 Gurer
* src/iks.c: Tag, cdata and attribute structures have different sizes now.
Saves 8 bytes per tag, 20 bytes per cdata/attrib on 32 bit archs.
2004-02-10 Gurer
* src/ikstack.c: iks_stack_stats is dead, long live iks_stack_stat.
* tools/iksperf.c: dom test now iks_delete()s the parsed tree
and even measures the freeing time.
2004-02-07 Gurer
* src/ikstack.c: iks_stack_stats returns total values.
2004-02-06 Gurer
* src/ikstack.c: new stack implementation, all callers changed too.
2004-02-03 Gurer
* test/tst-ikstack.c: tst-ikstack-str.c moved here.
* test/tst-ikstack.c: alignment test added.
* src/ikstack.c: iks_stack_alloc() always returns aligned memory.
* src/ikstack.c: patch from Ilkka Lyytinen:
iks_stack_strecat alignment fix.
2003-10-16 Gurer
* src/iks.c: escape_size off by one bug in iks_string() is fixed.
* src/dom.c: iks_load and iks_save uses (const char *) for filename now.
2003-10-09 Gurer
* src/Makefile.am: --no-undefined changed to -no-undefined
* stream.c: data->current is NULLed *before* calling the hook,
so you can keep the node in memory when you are returning
an error from your hook.
* tools/perf.c: GetTickCount is used instead of gettimeofday on Windows.
2003-10-08 Gurer
* dom.c: iks_save is not using unnecessary object stack.
* A great patch from Benoit Laniel <nels@pgroupe.net> applied.
This allows iksemel to be compiled on Windows with MinGW.
Detailed changes:
* configure.ac: check for st_blksize in stat structure (which is
missing in Windows). Check for libwsock32, the Windows socket library.
The check is only done when compiling for a MinGW host to avoid
problems when having Wine libraries.
* src/Makefile.am: add -no-undefined to libiksmel_la_LDFLAGS to enable
DLL compilation on Windows.
* src/stream.c: include winsock.h and do not include posix socket
headers on Windows. Use closesocket instead of close on Windows.
Check socket errors with '== -1' instead of '< 0'.
* tools/ikslint.c: conditional use of st_blksize.
* tools/iksroster.c: add Winsock initialization and cleanup code
(needed to use sockets on Windows).
2003-10-05 Gurer
* utility.c: iks_set_mem_funcs() added.
* iksperf.c: --memdbg option added.
* tools/perf.c: mallinfo stuff removed.
2003-09-15 Gurer
* version bump to 1.2
* stream.c: iks_start_tls() added with the help of gnutls library.
2003-09-11 Gurer
* stream.c: iks_connect_via() added. it can send a different name to the
connected server. useful for connecting the server via a ssh tunnel.
suggestion and patch by Wolf Bergenheim.
2003-09-09 Gurer
* stream.c: network buffer is allocated inside the stack at the first
connect call, and not free()d with reset.
2003-09-08 Gurer
* sax.c: iks_parser_reset() no longer free()s allocated buffers.
it also calls the delete hook of the extending parser.
* dom.c: reset zeroes internal state.
* stream.c: resetting the parser is now equal to iks_disconnect ()
2003-09-07 Gurer
* sax.c: malloc()s changed with iks_malloc()
attr buffer is not freed after each tag. minor speedup.
2003-09-05 Gurer
* ikslint.c: tag histogram is per file now instead of global.
2003-09-04 Gurer
* iksemel.texi: resource links moved to here from HACKING.
* utility.c: iks_malloc(), iks_free() wrappers added.
all malloc() and free() calls are changed with them.
2003-09-03 Gurer
* ikslint.c: can display tag usage histogram now.
2003-09-03 Gurer
* ikslint.c: benchmark options removed. reading from stdin supported.
reports tag mismatchs.
* dom.c: iks_tree() added. converts a string into a tree.
* iksemel.texi: iks_tree, iks_set_size_hint, iks_copy documented.
2003-09-03 Gurer
* iks.c: iks_string() now malloc()s memory if no stack is given.
it also runs *very* fast now.
2003-09-02 Gurer
* iksperf.c: errors are redirected to stderr again.
tree serialization test added.
2003-08-31 Gurer
* dom.c: default chunk size is increased. iks_set_size_hint()
function added. you can give an approximate size for the
file, and a better chunk size is selected for memory allocations.
greatly speeds up dom parser.
* iksperf.c: dom test uses iks_set_size_hint(). small fixes.
* iksperf.c: sha1 test.
2003-08-31 Gurer
* tools/iksperf.c: new tool for speed/memory usage testing.
* iksemel.texi: a new chapter about iksemel development added.
2003-08-23 Gurer
* doc/iksemel.texi: document license changed to GPL from GNU Free
Documentation License.
* ikstack.c: iks_stack_strecat() added.
* iks.c: iks_insert_cdata() modified to use iks_stack_strecat().
this greatly reduces memory usage when data is parsed in very small
chunks or cdata sections contains lots of escaped characters.
2003-07-29 Gurer
* iksemel.h: iks_connect_tcp(), iks_send_stream() and
iks_send_raw() now take const arguments.
* iks.c: iks_root() added.
* iks.c: iks_string() works on cdata nodes.
2003-07-20 Gurer
* iks.c: iks_copy() bug is fixed.
2003-07-15 Gurer
* dom.c: whitespace outside of markup won't added to the tree.
* stream.c: iks_connect_fd correctly sets SF_FOREIGN flag.
* src/Makefile.am: libtool revision bump, forgot that while doing 1.1 bump.
* iks.c: new iks_copy() and iks_copy_within() functions.
2003-06-29 Gurer
* 1.0 release!
* version bump to 1.1
2003-06-26 Gurer
* ikstack.c: reallocation bug in iks_stack_strcat() fixed.
* ikstack.c: iks_stack_strcat() and iks_stack_strcatv() now returns
a non-zero value if there isn't enough memory.
* iks.c: new functions: iks_next_tag(), iks_prev_tag(), iks_first_tag().
* iks.c: new function: iks_find_with_attrib().
2003-06-19 Gurer
* stream.c: new function iks_connect_fd ().
* stream.c: iks_send_header () is modified.
2003-06-17 Gurer
* sax.c: tags without attributes which contain whitespace before '>'
parsed correctly.
2003-06-16 Gurer
* stream.c: node isn't deleted automatically after hook anymore.
* iksroster.c: upload is working.
2003-06-15 Gurer
* tools/iksroster.c: new goodie. backups your jabber roster.
* iks.c: iks_insert_attrib() can be used for modifying and deleting attributes.
* stream.c: return value of the stream hook is actually used.
2003-06-13 Gurer
* iksemel.texi: more text.
* iksemel.h: iksFilterHook now returns 'int' instead of 'enum iksfilterret'.
2003-06-12 Gurer
* iksemel.h: iksStreamHook's return type is changed 'enum ikserror' to int.
type is changed 'enum iksnodetype' to int.
* iksemel.texi: more text.
2003-06-09 Gurer
* doc/iksemel.texi: restructured.
* iksemel.h: 'enum ikstagtype' type is changed to 'int' in iksTagHook.
'enum ikserror' changed to 'int' in iksTagHook, iksCDataHook, iks_parse().
'enum iksfileerror' changed to 'int' in iks_load() and iks_save().
'enum iksneterror' changed to 'int' in stream.c functions.
common error values removed from iksfileerror and iksneterror.
* dom.c: iks_load() checks the return value of iks_parse() now.
2003-06-02 Gurer
* filter.c: rules now has priority:
id > from = from_partial > ns > subtype > type
2003-05-29 Gurer
* jabber.c: fixes and API cleanup:
iks_id_new() now sets id->partial field.
pak->to field removed.
'to' argument added to iks_make_s10n()
'type' and 'to' arguments removed from iks_make_pres()
const keyword added to prototypes.
* filter.c: TO rule removed, FROM_PARTIAL rule added.
2003-05-26 Gurer
* sax.c: new function iks_nr_lines(), returns how much lines parsed.
* ikslint.c: document's line number is displayed in errors. some cleanup.
2003-05-26 Gurer
* sax.c: a bug in C_TAG context is found and fixed.
2003-05-24 Gurer
* sax.c: saga continues:
UTF8 validity checks added. You can't feed famous 0xC0 0x80 anymore.
<![CDATA[ ... ]]> sections are recognized.
* tst-sax.c: related tests added as usual.
2003-05-23 Gurer
* tools/ikslint.c: new goodie, checks xml files for well-formedness.
* sax.c: Attribute values can contain ' or " if they are quoted within
the other quote character.
2003-05-23 Gurer
* tst-sax.c: framework and tests for badly formed xml.
* sax.c: more cleanup, and well-formedness checks:
iks_parse() argument for xml data is now const char*.
0xFF, 0xFE and 0x00 bytes are invalid utf8.
Close tags have no attributes.
Single tags must end with '/>'.
2003-05-22 Gurer
* sax.c: some cleanup.
* sax.c: iks_get_udata() renamed to iks_user_data()
* sax.c: new function iks_nr_bytes(), returns how much bytes parsed.
* tst-sax.c, tst-dom.c: uses iks_nr_bytes() when reporting bugs.
2003-05-22 Gurer
* iks.c: iks_string() was printing siblings of the toplevel tag. fixed.
thanks David Yitzchak Cohen for reporting.
* HACKING: URLs of related standart documents added.
* tst-filter.c: new framework.
* tst-dom.c: new framework and tests.
2003-05-20 Gurer
* sax.c: '>' is valid and '--' is invalid inside the comments.
2003-05-17 Gurer
* HACKING: explanation of iksemel's design goals added.
* sax.c: parser now ignores PIs, markup and comments.
* dom.c, stream.c: PI checks removed.
2003-05-16 Gurer
* sax.c: several fixes.
* tst-sax.c: attribute checks and more tests.
2003-05-16 Gurer
* tst-sax.c: improved framework and more tests.
* finetune.h: DEFAULT_DOM_CHUNK_SIZE, DEFAULT_STREAM_CHUNK_SIZE
* stream.c, dom.c: now uses chunk size values from finetune.h
2003-05-07 Gurer
* complete redesign here.
2002-01-16 Evan Prodromou <mr.bad@pigdog.org>
* test/testiks.c: removed buggy unit test for previous entry,
since I couldn't figure out why it segfaulted. Will investigate
and fix later.
2002-01-07 Evan Prodromou <mr.bad@pigdog.org>
* core.c: fixed off-by-one bug with reallocation of attributes.
* test/testiks.c: added test for above bug.
2002-12-20 Evan Prodromou <mr.bad@pigdog.org>
* COPYING: New version of the LGPL.
* INSTALL: New FSF install info. Both of these were updated by autoreconf.
2002-12-12 Evan Prodromou <mr.bad@pigdog.org>
* include/iksemel.h: added id to Jabber packets.
* src/jabber.c: get ID in Jabber packets.
2002-12-9 Evan Prodromou <mr.bad@pigdog.org>
* doc/ROADMAP: added this file.
2002-11-28 Evan Prodromou <mr.bad@pigdog.org>
* io.c: broke out stream initialization to its own function, in
anticipation of supporting other kinds of streams.
* iksemel.h: added new stream function.
2002-11-15 Evan Prodromou <mr.bad@pigdog.org>
* configure.in: added check to see if you want to build with dmalloc.
* parser.c: make Jabber parsers use pool memory. Also, make Jabber
parser delete packets after posting them to callback function.
* convert.c: made converter used pool memory.
* iks.c: fixed iks constructor/destructor so they mark pool owner
and only delete the pool if the iks is the owner.
* sha.c: changed sha objects to use pool memory.
2002-11-07 Evan Prodromou <mr.bad@pigdog.org>
* ikspool.c: added ALIGN_ON, ALIGNED(), *_OFFSET macros.
Try to make sure that all pointer math is done with
aligned (val % ALIGN_ON == 0) values.
Fixed bug in _realloc() where incoming size wasn't
checked for alignment, size.
* testpool.c: added tests for absurdly small values
of page size, alloc size, realloc size.
2002-11-06 Evan Prodromou <mr.bad@pigdog.org>
* iksemel.h: added IKS_NS_XROSTER, for jabber:x:roster NS.
2002-11-06 Evan Prodromou <mr.bad@pigdog.org>
* core.c: changed iks_parse to use realloc instead of
malloc, copy, free.
2002-11-04 Evan Prodromou <mr.bad@pigdog.org>
* ikspool.c: For iks_pool_realloc, made it call _alloc if the
passed-in pointer is NULL. This is the way realloc() works.
* testpool.c: added a test for the above condition.
2002-11-04 Evan Prodromou <mr.bad@pigdog.org>
* ikspool.c: Added some comments.
2002-11-03 Evan Prodromou <mr.bad@pigdog.org>
* iksid.c: changed contract for iks_id_new, iks_id_set: const char *
instead of char *.
* iksemel.h: changed prototypes for iks_id_new, iks_id_set.
2002-11-03 Evan Prodromou <mr.bad@pigdog.org>
* iksid.c: fixed bug in iks_id_set causing segfault if field was
previously NULL.
* testid.c: added tests to check for above bug.
* test/.cvsignore: Ignore testpool and testid.
2002-11-03 Evan Prodromou <mr.bad@pigdog.org>
* iksid.c: fixed bug in iks_id_new with partial (no resource) IDs.
* testid.c: added tests to check for above bug.
2002-11-03 Evan Prodromou <mr.bad@pigdog.org>
* iksid.c: moved iksid functions to this file from jabber.c.
added new function, iks_id_delete, to delete an iksid.
implemented iks_id_set.
made iks_id_new use iks_pool_set_owner if it creates a pool.
changed iks_id_new so it doesn't write on src.
* iksemel.h: added prototype for iks_id_delete.
* testid.c: created basic unit tests for iksid.
2002-11-02 Evan Prodromou <mr.bad@pigdog.org>
* Added the beginnings of unit tests for memory allocation.
More needed.
2002-11-02 Evan Prodromou <mr.bad@pigdog.org>
* ikspool.c: added new best-fit memory allocation functions.
* utility.c: removed old memory-allocation functions.
* iksemel.h: added new memory allocation functions:
iks_pool_owner
iks_pool_set_owner
iks_pool_realloc
iks_pool_calloc
iks_pool_free
redefined ikspool structure for hiding.
2001-06-08 Gurer <palpa@jabber.org>
* core.c: xml unescaping.
2001-06-07 Gurer <palpa@jabber.org>
* convert.c: small bugfix in iks_conv_new()
2001-05-25 Gurer <palpa@jabber.org>
* configure.in: now checks gcc before adding -Wall to CFLAGS
* io.c: iks_recv() and iks_load() fixes.
2001-05-24 Gurer <palpa@jabber.org>
* configure.in: more checks.
* include/common.h: deals with including right files depending on
configure checks, source files include this.
2001-05-22 Gurer <palpa@jabber.org>
* jabber.c: iks_id_printx() added
new packet type IKS_PAK_ERROR for <stream:error>
* sha.c: iks_sha_delete() added
* configure.in, parser.c: optional expat support
2001-05-21 Gurer <palpa@jabber.org>
* parser.c: restructured. now parsers are allocated via iks_sax_new
* core.c: actual parser is moved to here
* convert.c: charset conversion stuff moved to here
* utility.c: alignment bug of iks_pool_alloc fixed
2001-04-10 Gurer <palpa@jabber.org>
* utility.c: charset convertion functions now use a static buffer and
require string length argument
2001-03-19 Gurer <palpa@jabber.org>
* utility.c: iks_conv_from/to renamed to iks_conv_utf8/locale
iconv fixes
2001-03-17 Gurer <palpa@jabber.org>
* utility.c: iks_conv_from/to() fixes
* doc/: a bit more documentation
2001-03-15 Gurer <palpa@jabber.org>
* jabber.c: iks_packet() uses the namespace of first child in IQ packets
instead of looking for a <query> tag.
* utility.c: iks_conv_ functions for utf8<->locale convertions
2001-03-13 Fabien Ninoles <fabien@debian.org>
* autogen.sh: Well, autoconf are better run into the src directory, indeed.
* configure.in: Add iconv check, ripped from gabber.
* src/Makefile.am: Oops! include dir is in srcdir!
2001-03-12 Gurer <palpa@jabber.org>
* doc/ : new files, basic structure for documentation
2001-03-09 Fabien Ninoles <fabien@debian.org>
* utility.c: Correction to the unescape routine... which do some
mess around with indexes.
* parser.c: Unescape CDATA et attrib value before inserting them.
* autogen.sh: Enable running it from a build directory.
2000-03-07 Gurer <palpa@jabber.org>
* iks.c: iks_string() now works correctly with a NULL ikspool argument
* io.c: return code check of fputs in iks_save() is corrected
* doc: new directory
* doc/main.texi: started documenting the library API in Texinfo format
2000-03-05 Gurer <palpa@jabber.org>
* iksemel.h: IKS_NS_ macros synced with latest jabber server
* parser.c: attribute buffer grow bug fixed
* iks.c: iks_hide() implemented
2000-02-01 Gurer <palpa@jabber.org>
* parser.c: attribute pointers bug fixed
* testiks.c: new test for parser
2000-01-30 Gurer <palpa@jabber.org>
* configure.in, makefile.am, test/makefile.am: make check target works now
* testiks.c: new tests for string and xml node functions
2000-01-28 Gurer <palpa@jabber.org>
* test: new directory
* test/testiks.c: a simple program for self testing
* makefile.am, src/makefile.am: fixes for make dist
2000-01-25 Gurer <palpa@jabber.org>
* sha.c: sha1 implementation
* jabber.c: iks_make_auth() now supports digest auth
2000-01-16 Gurer <palpa@jabber.org>
* io.c: iks_load() implemented
2000-12-20 Gurer <palpa@jabber.org>
* initial commit.

View File

@@ -1,71 +0,0 @@
License:
========
iksemel is developed and released under GNU Lesser General Public License.
A copy of the license can be found in the file COPYING. You should read it
before sending patches to the iksemel, since it is implicitly assumed that
your patches are also submitted under the LGPL license.
Roadmap:
========
Main goal of the iksemel is removing complexity from programs using the
library and the library itself. This is the reason why only a subset of XML
is supported. Some things like UTF16, entity definitons, DTDs will be eventually
implemented when we found ways to implement them without adding
too much complexity to the iksemel code. Somewhat external standarts
(XPath, XQuery, XSLT, vs) will probably not make it into the iksemel.
* validation
I think easiest way to add this feature is writing another parser based on the
sax parser which parses a dtd (either from sax parser's markup callback which
needs to be implemented or from an external source via iks_vsax_set_dtd() call)
and checks the arguments of sax callbacks. Using it via dom or stream parsers
can require some clever tricks. there are also xml schemas. they are easy to parse
(it is xml anyway) but can be hard to apply.
* utf16
There are two sides of this. Improving parser to accept utf16 can be relatively
easy. But on the client side things can get confusing. What will be the default
character set used by iks_new(), iks_insert_cdata() and similar functions? and
how they will allow other charsets to be used. Supporting more than utf8 and
utf16 is more difficult. Hopefully there is no immediate need for this. Jabber
uses only utf8 and you can use iconv if you are using another charset in your
application. Btw, there is also byte order issue which is silly. Inventor of BOM
crap must be killed.
* jabber roster
Roster handling generally depends on the UI system used. But I think a generic
roster handler which parses roster result, pushes, presence changes and
allows application to access and display this data can be useful. Challenge
here is making it UI independent and extensible by the application.
File Layout:
============
doc/
* iksemel.texi Documentation in texinfo format.
include/
* common.h Internal header for some common definitions.
* iksemel.h Library API
* finetune.h Default memory allocation sizes.
src/
* ikstack.c Memory management functions.
* utility.c Small string utility functions.
* iks.c XML tree management.
* sax.c SAX parser.
* dom.c DOM parser.
* stream.c Stream parser.
* sha.c SHA1 hash functions.
* jabber.c Jabber utilities.
* filter.c Packet filter for Jabber.
test/
(self test programs)
tools/
(varius utility programs)

View File

@@ -1,365 +0,0 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without warranty of any kind.
Basic Installation
==================
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
below. The lack of an optional feature in a given package is not
necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type `make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the `make install' phase executed with root
privileges.
5. Optionally, type `make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior `make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type `make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide `make
distcheck', which can by used by developers to test that all other
targets like `make install' and `make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. This
is known as a "VPATH" build.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, `make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'. Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated. The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.
The second method involves providing the `DESTDIR' variable. For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names. The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of `make' will be. For these packages, running `./configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
./configure CC="cc"
and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
`--help=short'
`--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
`--no-create'
`-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View File

@@ -1,18 +0,0 @@
##
## Process this file with automake to produce Makefile.in
##
SUBDIRS = include src tools test doc
EXTRA_DIST = HACKING iksemel.pc.in
pkgconfigdir=$(libdir)/pkgconfig
pkgconfig_DATA = iksemel.pc
snapshot:
$(MAKE) dist distdir=$(PACKAGE)-`date +"%y%m%d"`
mv $(PACKAGE)-`date +"%y%m%d"`.tar.gz ../
ikslite:
cp include/iksemel.h ../
cat include/finetune.h src/utility.c src/ikstack.c src/sax.c src/iks.c src/dom.c >../iksemel.c

View File

@@ -1,53 +0,0 @@
V1.3 (2007-08-02)
* Project is moved to
http://code.google.com/p/iksemel/
there is also a new mailing list at:
http://groups.google.com/group/iksemel
Please use those instead of old jabberstudio.org addresses.
* iksemel is now participating in Coverity Inc's free software
quality improvement program (http://scan.coverity.com). As a
first result, a few problems found by Coverity's static analysis
tool in the iks_sasl_challenge() are fixed in this release, and
other than that, iksemel passes from defect test with no problems.
* Extra padding problem in the base64 encoder is fixed. Some servers
were having problems with extra '=' padded SASL digests.
* New dom functions: iks_append(), iks_prepend(), iks_append_cdata(),
iks_prepend_cdata(). You can append/prepend new nodes within the
siblings with them, insert_ functions were only appending at the
last child. Thus editing a tree is much easier now.
* iks_load was giving error on files with multiply of 4Kb sizes, fixed.
V1.2 (2004-08-06)
* SASL authentication.
* SSH connections via gnutls library.
* Socket code abstracted, you can even provide your own transport functions.
* Compiles on Windows with MinGW.
* iks_sha_print() uses lowercase hex numbers to comply with latest jabber.
* New stack implementation, much faster and uses less memory.
Unfortunately API has changed a bit:
iks_stack_strcat, strcatv, print functions removed.
iks_stack_stats modified.
iks_stack_strecat renamed to iks_stack_strcat.
iks_stack_new takes two chunk sizes, one for structures one for strings.
iks_stack_strdup returns (char *).
V1.1 (2003-09-11)
* Minor sax parser speed up.
* iks_string() and dom parser performance is improved greatly.
* iksperf: new tool for measuring iksemel performance.
* ikslint: better error checking. supports stdin. can display tag usage histogram.
* New dom functions: iks_copy(), iks_copy_within(), iks_root(), iks_tree().
* License of the documentation changed to GPL from GNU FDL.
V1.0 (2003-06-29)
* API redesigned.
* iconv interface removed.
* ikslint and iksroster tools.
* Jabber packet filter.
* IPv6 support.
* iks_find_with_attrib, iks_next_tag, iks_prev_tag, iks_first_tag functions.
* Parser improvements (CDATA sections, comments, UTF8 validity checks)
* Memory pools are replaced with object stacks.
V0.1 (2002-10-30)
* First release.

View File

@@ -1,45 +0,0 @@
iksemel 1.3
Copyright (c) 2000-2004 Gurer Ozen <madcat@e-kolay.net>
Introduction:
-------------
This is an XML parser library mainly designed for Jabber applications.
It provides SAX, DOM, and special Jabber stream APIs. Library is coded
in ANSI C except the network code (which is POSIX compatible), thus
highly portable. Iksemel is released under GNU Lesser General Public
License. A copy of the license is included in the COPYING file.
Requirements:
-------------
Libtool, Automake and Autoconf packages are required for compiling cvs
versions.
Compiling & Install:
--------------------
If you got the source from CVS, type
./autogen.sh
for creating configuration script and files.
Then type
./configure
make
now library is compiled. You can test it with
make check
and install it with
(become root if necessary)
make install

View File

@@ -1,12 +0,0 @@
This file contains a simple list of TODO items.
More general ideas can be found in the roadmap part of the file HACKING.
(in order of importance)
* parser: &#1234; and &#xA25F; like entities must be unescaped.
* packet filter or a generic xml filter? something like a simplified xpath?
* a separate utf8 validator function can be useful
* utf8 <-> utf16 conversion functions can be useful
anything else? :-)

View File

@@ -1,59 +0,0 @@
dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
dnl also defines GSTUFF_PKG_ERRORS on error
AC_DEFUN([PKG_CHECK_MODULES], [
succeeded=no
if test -z "$PKG_CONFIG"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi
if test "$PKG_CONFIG" = "no" ; then
echo "*** The pkg-config script could not be found. Make sure it is"
echo "*** in your path, or set the PKG_CONFIG environment variable"
echo "*** to the full path to pkg-config."
echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
else
PKG_CONFIG_MIN_VERSION=0.9.0
if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
AC_MSG_CHECKING(for $2)
if $PKG_CONFIG --exists "$2" ; then
AC_MSG_RESULT(yes)
succeeded=yes
AC_MSG_CHECKING($1_CFLAGS)
$1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
AC_MSG_RESULT($$1_CFLAGS)
AC_MSG_CHECKING($1_LIBS)
$1_LIBS=`$PKG_CONFIG --libs "$2"`
AC_MSG_RESULT($$1_LIBS)
else
$1_CFLAGS=""
$1_LIBS=""
## If we have a custom action on failure, don't print errors, but
## do set a variable so people can do so.
$1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
ifelse([$4], ,echo $$1_PKG_ERRORS,)
fi
AC_SUBST($1_CFLAGS)
AC_SUBST($1_LIBS)
else
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
echo "*** See http://www.freedesktop.org/software/pkgconfig"
fi
fi
if test $succeeded = yes; then
ifelse([$3], , :, [$3])
else
ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
fi
])

View File

@@ -1,2 +0,0 @@
m4_include([build/libgnutls.m4])

View File

@@ -1,168 +0,0 @@
dnl Autoconf macros for libgnutls
dnl $id$
# Modified for LIBGNUTLS -- nmav
# Configure paths for LIBGCRYPT
# Shamelessly stolen from the one of XDELTA by Owen Taylor
# Werner Koch 99-12-09
dnl AM_PATH_LIBGNUTLS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
dnl Test for libgnutls, and define LIBGNUTLS_CFLAGS and LIBGNUTLS_LIBS
dnl
AC_DEFUN([AX_PATH_LIBGNUTLS],
[dnl
dnl Get the cflags and libraries from the libgnutls-config script
dnl
AC_ARG_WITH(libgnutls-prefix,
[ --with-libgnutls-prefix=PFX Prefix where libgnutls is installed (optional)],
libgnutls_config_prefix="$withval", libgnutls_config_prefix="")
if test x$libgnutls_config_prefix != x ; then
if test x${LIBGNUTLS_CONFIG+set} != xset ; then
LIBGNUTLS_CONFIG=$libgnutls_config_prefix/bin/libgnutls-config
fi
fi
AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no)
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
no_libgnutls=""
if test "$LIBGNUTLS_CONFIG" != "no"; then
LIBGNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG $libgnutls_config_args --cflags`
LIBGNUTLS_LIBS="`$LIBGNUTLS_CONFIG $libgnutls_config_args --libs` -lpthread -lgcrypt"
libgnutls_config_version=`$LIBGNUTLS_CONFIG $libgnutls_config_args --version`
elif test "$PKG_CONFIG" != "no"; then
LIBGNUTLS_CFLAGS=`$PKG_CONFIG --cflags gnutls`
LIBGNUTLS_LIBS="`$PKG_CONFIG --libs gnutls` -lpthread -lgcrypt"
libgnutls_config_version=`$PKG_CONFIG --modversion gnutls`
else
no_libgnutls=yes
fi
min_libgnutls_version=ifelse([$1], ,0.1.0,$1)
AC_MSG_CHECKING(for libgnutls - version >= $min_libgnutls_version)
if test x"$no_libgnutls" = x""; then
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
LIBS="$LIBS $LIBGNUTLS_LIBS"
dnl
dnl Now check if the installed libgnutls is sufficiently new. Also sanity
dnl checks the results of libgnutls-config to some extent
dnl
rm -f conf.libgnutlstest
AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
int
main ()
{
system ("touch conf.libgnutlstest");
if( strcmp( gnutls_check_version(NULL), "$libgnutls_config_version" ) )
{
printf("\n*** 'libgnutls-config --version' returned %s, but LIBGNUTLS (%s)\n",
"$libgnutls_config_version", gnutls_check_version(NULL) );
printf("*** was found! If libgnutls-config was correct, then it is best\n");
printf("*** to remove the old version of LIBGNUTLS. You may also be able to fix the error\n");
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
printf("*** required on your system.\n");
printf("*** If libgnutls-config was wrong, set the environment variable LIBGNUTLS_CONFIG\n");
printf("*** to point to the correct copy of libgnutls-config, and remove the file config.cache\n");
printf("*** before re-running configure\n");
}
else if ( strcmp(gnutls_check_version(NULL), LIBGNUTLS_VERSION ) )
{
printf("\n*** LIBGNUTLS header file (version %s) does not match\n", LIBGNUTLS_VERSION);
printf("*** library (version %s)\n", gnutls_check_version(NULL) );
}
else
{
if ( gnutls_check_version( "$min_libgnutls_version" ) )
{
return 0;
}
else
{
printf("no\n*** An old version of LIBGNUTLS (%s) was found.\n",
gnutls_check_version(NULL) );
printf("*** You need a version of LIBGNUTLS newer than %s. The latest version of\n",
"$min_libgnutls_version" );
printf("*** LIBGNUTLS is always available from ftp://gnutls.hellug.gr/pub/gnutls.\n");
printf("*** \n");
printf("*** If you have already installed a sufficiently new version, this error\n");
printf("*** probably means that the wrong copy of the libgnutls-config shell script is\n");
printf("*** being found. The easiest way to fix this is to remove the old version\n");
printf("*** of LIBGNUTLS, but you can also set the LIBGNUTLS_CONFIG environment to point to the\n");
printf("*** correct copy of libgnutls-config. (In this case, you will have to\n");
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
printf("*** so that the correct libraries are found at run-time))\n");
}
}
return 1;
}
],, no_libgnutls=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
if test "x$no_libgnutls" = x ; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
if test -f conf.libgnutlstest ; then
:
else
AC_MSG_RESULT(no)
fi
if test "$LIBGNUTLS_CONFIG" = "no" ; then
echo "*** The libgnutls-config script installed by LIBGNUTLS could not be found"
echo "*** If LIBGNUTLS was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the LIBGNUTLS_CONFIG environment variable to the"
echo "*** full path to libgnutls-config."
else
if test -f conf.libgnutlstest ; then
:
else
echo "*** Could not run libgnutls test program, checking why..."
CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
LIBS="$LIBS $LIBGNUTLS_LIBS"
AC_TRY_LINK([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
], [ return !!gnutls_check_version(NULL); ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding LIBGNUTLS or finding the wrong"
echo "*** version of LIBGNUTLS. If it is not finding LIBGNUTLS, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
echo "***" ],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means LIBGNUTLS was incorrectly installed"
echo "*** or that you have moved LIBGNUTLS since it was installed. In the latter case, you"
echo "*** may want to edit the libgnutls-config script: $LIBGNUTLS_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
LIBGNUTLS_CFLAGS=""
LIBGNUTLS_LIBS=""
ifelse([$3], , :, [$3])
fi
rm -f conf.libgnutlstest
AC_SUBST(LIBGNUTLS_CFLAGS)
AC_SUBST(LIBGNUTLS_LIBS)
])
dnl *-*wedit:notab*-* Please keep this as the last line.

View File

@@ -1,111 +0,0 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(iksemel,1.3)
AC_PREREQ(2.50)
AC_CONFIG_AUX_DIR(build)
AC_CONFIG_SRCDIR([configure.ac])
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS(include/config.h)
CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
AC_CANONICAL_HOST
dnl Checks for programs
AC_PROG_CC
AC_PROG_INSTALL
AC_CHECK_TOOL(OBJDUMP, objdump, :)
AM_PROG_LIBTOOL
AC_LANG_C
dnl Checks for header files
AC_HEADER_STDC
AC_CHECK_HEADERS(unistd.h strings.h errno.h)
dnl Checks for typedefs and structures
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_CHECK_MEMBERS([struct stat.st_blksize])
dnl Special check for windows
case "$host_os" in
*mingw*)
AC_CHECK_LIB(wsock32, main, , AC_MSG_ERROR(Winsock is needed for a Win32 build.))
;;
esac
dnl Check for posix io
AC_ARG_ENABLE(default-io,
[ --disable-default-io disable builtin socket transport code ],
defio=$enableval, defio=yes)
if test "$defio" = yes; then
AC_DEFINE(USE_DEFAULT_IO,1,[Define this is you want default transport])
fi
AM_CONDITIONAL(DO_POSIX, test "x$defio" = "xyes")
dnl Checks for library functions
AC_SEARCH_LIBS(recv,socket)
AC_CHECK_FUNCS(getopt_long)
AC_CHECK_FUNCS(getaddrinfo)
#AX_PATH_LIBGNUTLS(,AC_DEFINE(HAVE_GNUTLS,,"Use libgnutls"))
m4_include([openssl.m4])
SAC_OPENSSL
dnl Check -Wall flag of GCC
if test "x$GCC" = "xyes"; then
if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
CFLAGS="$CFLAGS -Wall"
fi
fi
AC_DEFUN([AX_COMPILER_VENDOR],
[
AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
[ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
# note: don't check for gcc first since some other compilers define __GNUC__
for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
#if !($vencpp)
thisisanerror;
#endif
])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
done
])
])
AX_COMPILER_VENDOR
# Enable 64 bit build
AC_ARG_ENABLE(64,
[AC_HELP_STRING([--enable-64],[build with 64 bit support])],[enable_64="$enable_64"],[enable_64="no"])
if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
if test "${enable_64}" = "yes"; then
CFLAGS="$CFLAGS -mt -m64 -lgpg-error"
CXXFLAGS="$CXXFLAGS -mt -m64 -lgpg-error"
SUNFLAGS="-xc99=all -mt -m64 -lgpg-error"
else
CFLAGS="$CFLAGS -mt -lgpg-error"
CXXFLAGS="$CXXFLAGS -mt -lgpg-error"
SUNFLAGS="-xc99=all -mt -lgpg-error"
fi
fi
AC_SUBST(SUNCFLAGS)
dnl Generating makefiles
AC_CONFIG_FILES([
Makefile
iksemel.pc
src/Makefile
include/Makefile
tools/Makefile
test/Makefile
doc/Makefile
])
AC_OUTPUT

View File

@@ -1,4 +0,0 @@
#! /bin/sh
srcpath=$(dirname $0 2>/dev/null ) || srcpath="."
$srcpath/configure "$@" --disable-shared --with-pic

View File

@@ -1,5 +0,0 @@
##
## Process this file with automake to produce Makefile.in
##
#info_TEXINFOS = iksemel.texi

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +0,0 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: iksemel
Description: XML parser library for Jabber
Version: @VERSION@
Libs: -L${libdir} -liksemel
Cflags: -I${includedir}

View File

@@ -1,6 +0,0 @@
##
## Process this file with automake to produce Makefile.in
##
include_HEADERS = iksemel.h
noinst_HEADERS = common.h finetune.h

View File

@@ -1,33 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <stdio.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#elif HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifndef errno
extern int errno;
#endif
#include "finetune.h"

View File

@@ -1,29 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
/* minimum sax buffer size */
#define SAX_BUFFER_MIN_SIZE 128
/* sax parser structure plus extra data of dom parser */
#define DEFAULT_DOM_CHUNK_SIZE 256
/* sax parser structure plus extra data of stream parser */
#define DEFAULT_STREAM_CHUNK_SIZE 256
/* iks structure, its data, child iks structures, for stream parsing */
#define DEFAULT_IKS_CHUNK_SIZE 1024
/* iks structure, its data, child iks structures, for file parsing */
#define DEFAULT_DOM_IKS_CHUNK_SIZE 2048
/* rule structure and from/to/id/ns strings */
#define DEFAULT_RULE_CHUNK_SIZE 128
/* file is read by blocks with this size */
#define FILE_IO_BUF_SIZE 4096
/* network receive buffer */
#define NET_IO_BUF_SIZE 4096

View File

@@ -1,414 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2007 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#ifndef IKSEMEL_H
#define IKSEMEL_H 1
#ifdef __cplusplus
#include <cstddef> /* size_t for C++ */
extern "C" {
#else
#include <stddef.h> /* size_t for C */
#endif
/***** object stack *****/
struct ikstack_struct;
typedef struct ikstack_struct ikstack;
ikstack *iks_stack_new (size_t meta_chunk, size_t data_chunk);
void *iks_stack_alloc (ikstack *s, size_t size);
char *iks_stack_strdup (ikstack *s, const char *src, size_t len);
char *iks_stack_strcat (ikstack *s, char *old, size_t old_len, const char *src, size_t src_len);
void iks_stack_stat (ikstack *s, size_t *allocated, size_t *used);
void iks_stack_delete (ikstack **sp);
/***** utilities *****/
void *iks_malloc (size_t size);
void iks_real_free (void *ptr);
void iks_set_mem_funcs (void *(*malloc_func)(size_t size), void (*free_func)(void *ptr));
char *iks_strdup (const char *src);
char *iks_strcat (char *dest, const char *src);
int iks_strcmp (const char *a, const char *b);
int iks_strcasecmp (const char *a, const char *b);
int iks_strncmp (const char *a, const char *b, size_t n);
int iks_strncasecmp (const char *a, const char *b, size_t n);
size_t iks_strlen (const char *src);
char *iks_escape (ikstack *s, char *src, size_t len);
char *iks_unescape (ikstack *s, char *src, size_t len);
#define iks_free(p) if (p) {iks_real_free(p) ; p = NULL;}
/***** dom tree *****/
enum ikstype {
IKS_NONE = 0,
IKS_TAG,
IKS_ATTRIBUTE,
IKS_CDATA
};
struct iks_struct;
typedef struct iks_struct iks;
iks *iks_new (const char *name);
iks *iks_new_within (const char *name, ikstack *s);
iks *iks_insert (iks *x, const char *name);
iks *iks_insert_cdata (iks *x, const char *data, size_t len);
iks *iks_insert_attrib (iks *x, const char *name, const char *value);
iks *iks_insert_node (iks *x, iks *y);
iks *iks_append (iks *x, const char *name);
iks *iks_prepend (iks *x, const char *name);
iks *iks_append_cdata (iks *x, const char *data, size_t len);
iks *iks_prepend_cdata (iks *x, const char *data, size_t len);
void iks_hide (iks *x);
void iks_delete (iks *x);
iks *iks_next (iks *x);
iks *iks_next_tag (iks *x);
iks *iks_prev (iks *x);
iks *iks_prev_tag (iks *x);
iks *iks_parent (iks *x);
iks *iks_root (iks *x);
iks *iks_child (iks *x);
iks *iks_first_tag (iks *x);
iks *iks_attrib (iks *x);
iks *iks_find (iks *x, const char *name);
char *iks_find_cdata (iks *x, const char *name);
char *iks_find_attrib (iks *x, const char *name);
iks *iks_find_with_attrib (iks *x, const char *tagname, const char *attrname, const char *value);
ikstack *iks_stack (iks *x);
enum ikstype iks_type (iks *x);
char *iks_name (iks *x);
char *iks_cdata (iks *x);
size_t iks_cdata_size (iks *x);
int iks_has_children (iks *x);
int iks_has_attribs (iks *x);
char *iks_string (ikstack *s, iks *x);
iks *iks_copy (iks *x);
iks *iks_copy_within (iks *x, ikstack *s);
/***** sax parser *****/
enum ikserror {
IKS_OK = 0,
IKS_NOMEM,
IKS_BADXML,
IKS_HOOK
};
enum ikstagtype {
IKS_OPEN,
IKS_CLOSE,
IKS_SINGLE
};
typedef int (iksTagHook)(void *user_data, char *name, char **atts, int type);
typedef int (iksCDataHook)(void *user_data, char *data, size_t len);
typedef void (iksDeleteHook)(void *user_data);
struct iksparser_struct;
typedef struct iksparser_struct iksparser;
iksparser *iks_sax_new (void *user_data, iksTagHook *tagHook, iksCDataHook *cdataHook);
iksparser *iks_sax_extend (ikstack *s, void *user_data, iksTagHook *tagHook, iksCDataHook *cdataHook, iksDeleteHook *deleteHook);
ikstack *iks_parser_stack (iksparser *prs);
void *iks_user_data (iksparser *prs);
unsigned long iks_nr_bytes (iksparser *prs);
unsigned long iks_nr_lines (iksparser *prs);
int iks_parse (iksparser *prs, const char *data, size_t len, int finish);
void iks_parser_reset (iksparser *prs);
void iks_parser_delete (iksparser *prs);
/***** dom parser *****/
enum iksfileerror {
IKS_FILE_NOFILE = 4,
IKS_FILE_NOACCESS,
IKS_FILE_RWERR
};
iksparser *iks_dom_new (iks **iksptr);
void iks_set_size_hint (iksparser *prs, size_t approx_size);
iks *iks_tree (const char *xml_str, size_t len, int *err);
int iks_load (const char *fname, iks **xptr);
int iks_save (const char *fname, iks *x);
/***** transport layer *****/
enum iksasyncevents {
IKS_ASYNC_RESOLVED,
IKS_ASYNC_CONNECTED,
IKS_ASYNC_WRITE,
IKS_ASYNC_WRITTEN,
IKS_ASYNC_READ,
IKS_ASYNC_CLOSED,
IKS_ASYNC_ERROR
};
typedef struct iksasyncevent_struct {
int event;
int data0;
int data1;
} iksasyncevent;
typedef void (iksTClose)(void *socket);
typedef int (iksTConnect)(iksparser *prs, void **socketptr, const char *server, int port);
typedef int (iksTSend)(void *socket, const char *data, size_t len);
typedef int (iksTRecv)(void *socket, char *buffer, size_t buf_len, int timeout);
typedef int (iksAsyncNotify)(void *user_data, iksasyncevent *event);
typedef int (iksTConnectAsync)(iksparser *prs, void **socketptr, const char *server, const char *server_name, int port, void *notify_data, iksAsyncNotify *notify_func);
#define IKS_TRANSPORT_V1 0
typedef const struct ikstransport_struct {
int abi_version;
/* basic api, connect can be NULL if only async api is provided */
iksTConnect *connect;
iksTSend *send;
iksTRecv *recv;
iksTClose *close;
/* optional async api */
iksTConnectAsync *connect_async;
} ikstransport;
extern ikstransport iks_default_transport;
/***** stream parser *****/
enum iksneterror {
IKS_NET_NODNS = 4,
IKS_NET_NOSOCK,
IKS_NET_NOCONN,
IKS_NET_RWERR,
IKS_NET_NOTSUPP,
IKS_NET_TLSFAIL,
IKS_NET_DROPPED,
IKS_NET_UNKNOWN
};
enum iksnodetype {
IKS_NODE_START,
IKS_NODE_NORMAL,
IKS_NODE_ERROR,
IKS_NODE_STOP
};
enum ikssasltype {
IKS_SASL_PLAIN,
IKS_SASL_DIGEST_MD5
};
#define IKS_JABBER_PORT 5222
typedef int (iksStreamHook)(void *user_data, int type, iks *node);
typedef void (iksLogHook)(void *user_data, const char *data, size_t size, int is_incoming);
iksparser *iks_stream_new (char *name_space, void *user_data, iksStreamHook *streamHook);
void *iks_stream_user_data (iksparser *prs);
void iks_set_log_hook (iksparser *prs, iksLogHook *logHook);
int iks_connect_tcp (iksparser *prs, const char *server, int port);
int iks_connect_fd (iksparser *prs, int fd);
int iks_connect_via (iksparser *prs, const char *server, int port, const char *server_name);
int iks_connect_with (iksparser *prs, const char *server, int port, const char *server_name, ikstransport *trans);
int iks_connect_async (iksparser *prs, const char *server, int port, void *notify_data, iksAsyncNotify *notify_func);
int iks_connect_async_with (iksparser *prs, const char *server, int port, const char *server_name, ikstransport *trans, void *notify_data, iksAsyncNotify *notify_func);
int iks_fd (iksparser *prs);
int iks_recv (iksparser *prs, int timeout);
int iks_send_header (iksparser *prs, const char *to);
int iks_send (iksparser *prs, iks *x);
int iks_send_raw (iksparser *prs, const char *xmlstr);
void iks_disconnect (iksparser *prs);
int iks_has_tls (void);
int iks_is_secure (iksparser *prs);
int iks_start_tls (iksparser *prs);
int iks_proceed_tls (iksparser *prs, const char *cert_file, const char *key_file);
int iks_start_sasl (iksparser *prs, enum ikssasltype type, char *username, char *pass);
/***** jabber *****/
#define IKS_NS_CLIENT "jabber:client"
#define IKS_NS_SERVER "jabber:server"
#define IKS_NS_AUTH "jabber:iq:auth"
#define IKS_NS_AUTH_0K "jabber:iq:auth:0k"
#define IKS_NS_REGISTER "jabber:iq:register"
#define IKS_NS_ROSTER "jabber:iq:roster"
#define IKS_NS_XROSTER "jabber:x:roster"
#define IKS_NS_OFFLINE "jabber:x:offline"
#define IKS_NS_AGENT "jabber:iq:agent"
#define IKS_NS_AGENTS "jabber:iq:agents"
#define IKS_NS_BROWSE "jabber:iq:browse"
#define IKS_NS_CONFERENCE "jabber:iq:conference"
#define IKS_NS_DELAY "jabber:x:delay"
#define IKS_NS_VERSION "jabber:iq:version"
#define IKS_NS_TIME "jabber:iq:time"
#define IKS_NS_VCARD "vcard-temp"
#define IKS_NS_PRIVATE "jabber:iq:private"
#define IKS_NS_SEARCH "jabber:iq:search"
#define IKS_NS_OOB "jabber:iq:oob"
#define IKS_NS_XOOB "jabber:x:oob"
#define IKS_NS_ADMIN "jabber:iq:admin"
#define IKS_NS_FILTER "jabber:iq:filter"
#define IKS_NS_GATEWAY "jabber:iq:gateway"
#define IKS_NS_LAST "jabber:iq:last"
#define IKS_NS_SIGNED "jabber:x:signed"
#define IKS_NS_ENCRYPTED "jabber:x:encrypted"
#define IKS_NS_ENVELOPE "jabber:x:envelope"
#define IKS_NS_EVENT "jabber:x:event"
#define IKS_NS_EXPIRE "jabber:x:expire"
#define IKS_NS_XHTML "http://www.w3.org/1999/xhtml"
#define IKS_NS_XMPP_SASL "urn:ietf:params:xml:ns:xmpp-sasl"
#define IKS_NS_XMPP_BIND "urn:ietf:params:xml:ns:xmpp-bind"
#define IKS_NS_XMPP_SESSION "urn:ietf:params:xml:ns:xmpp-session"
#define IKS_ID_USER 1
#define IKS_ID_SERVER 2
#define IKS_ID_RESOURCE 4
#define IKS_ID_PARTIAL IKS_ID_USER | IKS_ID_SERVER
#define IKS_ID_FULL IKS_ID_USER | IKS_ID_SERVER | IKS_ID_RESOURCE
#define IKS_STREAM_STARTTLS 1
#define IKS_STREAM_SESSION 2
#define IKS_STREAM_BIND 4
#define IKS_STREAM_SASL_PLAIN 8
#define IKS_STREAM_SASL_MD5 16
typedef struct iksid_struct {
char *user;
char *server;
char *resource;
char *partial;
char *full;
} iksid;
iksid *iks_id_new (ikstack *s, const char *jid);
int iks_id_cmp (iksid *a, iksid *b, int parts);
enum ikspaktype {
IKS_PAK_NONE = 0,
IKS_PAK_MESSAGE,
IKS_PAK_PRESENCE,
IKS_PAK_IQ,
IKS_PAK_S10N
};
enum iksubtype {
IKS_TYPE_NONE = 0,
IKS_TYPE_ERROR,
IKS_TYPE_CHAT,
IKS_TYPE_GROUPCHAT,
IKS_TYPE_HEADLINE,
IKS_TYPE_GET,
IKS_TYPE_SET,
IKS_TYPE_RESULT,
IKS_TYPE_SUBSCRIBE,
IKS_TYPE_SUBSCRIBED,
IKS_TYPE_UNSUBSCRIBE,
IKS_TYPE_UNSUBSCRIBED,
IKS_TYPE_PROBE,
IKS_TYPE_AVAILABLE,
IKS_TYPE_UNAVAILABLE
};
enum ikshowtype {
IKS_SHOW_UNAVAILABLE = 0,
IKS_SHOW_AVAILABLE,
IKS_SHOW_CHAT,
IKS_SHOW_AWAY,
IKS_SHOW_XA,
IKS_SHOW_DND
};
typedef struct ikspak_struct {
iks *x;
iksid *from;
iks *query;
char *ns;
char *id;
enum ikspaktype type;
enum iksubtype subtype;
enum ikshowtype show;
} ikspak;
ikspak *iks_packet (iks *x);
iks *iks_make_auth (iksid *id, const char *pass, const char *sid);
iks *iks_make_msg (enum iksubtype type, const char *to, const char *body);
iks *iks_make_s10n (enum iksubtype type, const char *to, const char *msg);
iks *iks_make_pres (enum ikshowtype show, const char *status);
iks *iks_make_iq (enum iksubtype type, const char *xmlns);
iks *iks_make_resource_bind(iksid *id);
iks *iks_make_session(void);
int iks_stream_features(iks *x);
/***** jabber packet filter *****/
#define IKS_RULE_DONE 0
#define IKS_RULE_ID 1
#define IKS_RULE_TYPE 2
#define IKS_RULE_SUBTYPE 4
#define IKS_RULE_FROM 8
#define IKS_RULE_FROM_PARTIAL 16
#define IKS_RULE_NS 32
enum iksfilterret {
IKS_FILTER_PASS,
IKS_FILTER_EAT
};
typedef int (iksFilterHook)(void *user_data, ikspak *pak);
struct iksfilter_struct;
typedef struct iksfilter_struct iksfilter;
struct iksrule_struct;
typedef struct iksrule_struct iksrule;
iksfilter *iks_filter_new (void);
iksrule *iks_filter_add_rule (iksfilter *f, iksFilterHook *filterHook, void *user_data, ...);
void iks_filter_remove_rule (iksfilter *f, iksrule *rule);
void iks_filter_remove_hook (iksfilter *f, iksFilterHook *filterHook);
void iks_filter_packet (iksfilter *f, ikspak *pak);
void iks_filter_delete (iksfilter *f);
/***** sha1 *****/
struct iksha_struct;
typedef struct iksha_struct iksha;
iksha *iks_sha_new (void);
void iks_sha_reset (iksha *sha);
void iks_sha_hash (iksha *sha, const unsigned char *data, size_t len, int finish);
void iks_sha_print (iksha *sha, char *hash);
void iks_sha_delete (iksha *sha);
void iks_sha (const char *data, char *hash);
/***** md5 *****/
struct ikmd5_struct;
typedef struct iksmd5_struct iksmd5;
iksmd5 *iks_md5_new(void);
void iks_md5_reset(iksmd5 *md5);
void iks_md5_hash(iksmd5 *md5, const unsigned char *data, size_t slen, int finish);
void iks_md5_delete(iksmd5 *md5);
void iks_md5_print(iksmd5 *md5, char *buf);
void iks_md5_digest(iksmd5 *md5, unsigned char *digest);
void iks_md5(const char *data, char *buf);
/***** base64 *****/
char *iks_base64_decode(const char *buf);
char *iks_base64_encode(const char *buf, int len);
#ifdef __cplusplus
}
#endif
#endif /* IKSEMEL_H */

View File

@@ -1 +0,0 @@
timestamp

File diff suppressed because it is too large Load Diff

View File

@@ -1,49 +0,0 @@
dnl ======================================================================
dnl SAC_OPENSSL
dnl ======================================================================
AC_DEFUN([SAC_OPENSSL], [
AC_ARG_WITH(openssl,
[ --with-openssl use OpenSSL [[enabled]]],, with_openssl=pkg-config)
dnl SOSXXX:SAC_ASSERT_DEF([openssl libraries])
if test "$with_openssl" = no ;then
: # No openssl
else
if test "$with_openssl" = "pkg-config" ; then
PKG_CHECK_MODULES(openssl, openssl,
[HAVE_TLS=1 HAVE_SSL=1 LIBS="$openssl_LIBS $LIBS"],
[HAVE_SSL=0])
fi
if test x$HAVE_SSL = x1 ; then
AC_DEFINE([HAVE_LIBCRYPTO], 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
AC_DEFINE([HAVE_LIBSSL], 1, [Define to 1 if you have the `ssl' library (-lssl).])
else
AC_CHECK_HEADERS([openssl/tls1.h], [
HAVE_SSL=1 HAVE_TLS=1
AC_CHECK_LIB(crypto, BIO_new,,
HAVE_SSL=0
AC_MSG_WARN(OpenSSL crypto library was not found))
AC_CHECK_LIB(ssl, TLSv1_method,,
HAVE_TLS=0
AC_MSG_WARN(OpenSSL protocol library was not found))
],[AC_MSG_WARN(OpenSSL include files were not found)],[#include <openssl/safestack.h>])
fi
if test x$HAVE_SSL = x1; then
AC_DEFINE([HAVE_SSL], 1, [Define to 1 if you have OpenSSL])
fi
if test x$HAVE_TLS = x1; then
AC_DEFINE([HAVE_TLS], 1, [Define to 1 if you have TLS])
fi
fi
AM_CONDITIONAL(HAVE_TLS, test x$HAVE_TLS = x1)
])

View File

@@ -1,29 +0,0 @@
##
## Process this file with automake to produce Makefile.in
##
AM_CPPFLAGS = -I$(top_srcdir)/include
lib_LTLIBRARIES = libiksemel.la
if DO_POSIX
posix_c = io-posix.c
endif
libiksemel_la_SOURCES = \
ikstack.c \
utility.c \
iks.c \
sax.c \
dom.c \
$(posix_c) \
stream.c \
sha.c \
jabber.c \
filter.c \
md5.c \
base64.c
libiksemel_la_LDFLAGS = -version-info 4:0:1 -no-undefined
libiksemel_la_CFLAGS = $(CFLAGS) $(LIBGNUTLS_CFLAGS)
libiksemel_la_LIBADD = $(LIBGNUTLS_LIBS)

View File

@@ -1,103 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
static const char base64_charset[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char *iks_base64_decode(const char *buf)
{
char *res, *save;
char val;
const char *foo;
const char *end;
int index;
size_t len;
if (!buf)
return NULL;
len = iks_strlen(buf) * 6 / 8 + 1;
save = res = iks_malloc(len);
if (!save)
return NULL;
memset(res, 0, len);
index = 0;
end = buf + iks_strlen(buf);
while (*buf && buf < end) {
if (!(foo = strchr(base64_charset, *buf)))
foo = base64_charset;
val = (int)(foo - base64_charset);
buf++;
switch (index) {
case 0:
*res |= val << 2;
break;
case 1:
*res++ |= val >> 4;
*res |= val << 4;
break;
case 2:
*res++ |= val >> 2;
*res |= val << 6;
break;
case 3:
*res++ |= val;
break;
}
index++;
index %= 4;
}
*res = 0;
return save;
}
char *iks_base64_encode(const char *buf, int len)
{
char *res, *save;
int k, t;
len = (len > 0) ? (len) : (iks_strlen(buf));
save = res = iks_malloc((len*8) / 6 + 4);
if (!save) return NULL;
for (k = 0; k < len/3; ++k) {
*res++ = base64_charset[*buf >> 2];
t = ((*buf & 0x03) << 4);
buf++;
*res++ = base64_charset[t | (*buf >> 4)];
t = ((*buf & 0x0F) << 2);
buf++;
*res++ = base64_charset[t | (*buf >> 6)];
*res++ = base64_charset[*buf++ & 0x3F];
}
switch (len % 3) {
case 2:
*res++ = base64_charset[*buf >> 2];
t = ((*buf & 0x03) << 4);
buf++;
*res++ = base64_charset[t | (*buf >> 4)];
*res++ = base64_charset[((*buf++ & 0x0F) << 2)];
*res++ = '=';
break;
case 1:
*res++ = base64_charset[*buf >> 2];
*res++ = base64_charset[(*buf++ & 0x03) << 4];
*res++ = '=';
*res++ = '=';
break;
}
*res = 0;
return save;
}

View File

@@ -1,181 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
struct dom_data {
iks **iksptr;
iks *current;
size_t chunk_size;
};
static int
tagHook (struct dom_data *data, char *name, char **atts, int type)
{
iks *x;
if (IKS_OPEN == type || IKS_SINGLE == type) {
if (data->current) {
x = iks_insert (data->current, name);
} else {
ikstack *s;
s = iks_stack_new (data->chunk_size, data->chunk_size);
x = iks_new_within (name, s);
}
if (atts) {
int i=0;
while (atts[i]) {
iks_insert_attrib (x, atts[i], atts[i+1]);
i += 2;
}
}
data->current = x;
}
if (IKS_CLOSE == type || IKS_SINGLE == type) {
x = iks_parent (data->current);
if (iks_strcmp(iks_name(data->current), name) != 0)
return IKS_BADXML;
if (x)
data->current = x;
else {
*(data->iksptr) = data->current;
data->current = NULL;
}
}
return IKS_OK;
}
static int
cdataHook (struct dom_data *data, char *cdata, size_t len)
{
if (data->current) iks_insert_cdata (data->current, cdata, len);
return IKS_OK;
}
static void
deleteHook (struct dom_data *data)
{
if (data->current) iks_delete (data->current);
data->current = NULL;
}
iksparser *
iks_dom_new (iks **iksptr)
{
ikstack *s;
struct dom_data *data;
*iksptr = NULL;
s = iks_stack_new (DEFAULT_DOM_CHUNK_SIZE, 0);
if (!s) return NULL;
data = iks_stack_alloc (s, sizeof (struct dom_data));
data->iksptr = iksptr;
data->current = NULL;
data->chunk_size = DEFAULT_DOM_IKS_CHUNK_SIZE;
return iks_sax_extend (s, data, (iksTagHook *) tagHook, (iksCDataHook *) cdataHook, (iksDeleteHook *) deleteHook);
}
void
iks_set_size_hint (iksparser *prs, size_t approx_size)
{
size_t cs;
struct dom_data *data = iks_user_data (prs);
cs = approx_size / 10;
if (cs < DEFAULT_DOM_IKS_CHUNK_SIZE) cs = DEFAULT_DOM_IKS_CHUNK_SIZE;
data->chunk_size = cs;
}
iks *
iks_tree (const char *xml_str, size_t len, int *err)
{
iksparser *prs;
iks *x;
int e;
if (0 == len) len = strlen (xml_str);
prs = iks_dom_new (&x);
if (!prs) {
if (err) *err = IKS_NOMEM;
return NULL;
}
e = iks_parse (prs, xml_str, len, 1);
if (err) *err = e;
iks_parser_delete (prs);
return x;
}
int
iks_load (const char *fname, iks **xptr)
{
iksparser *prs;
char *buf;
FILE *f;
int len, done = 0;
int ret;
*xptr = NULL;
buf = iks_malloc (FILE_IO_BUF_SIZE);
if (!buf) return IKS_NOMEM;
ret = IKS_NOMEM;
prs = iks_dom_new (xptr);
if (prs) {
f = fopen (fname, "r");
if (f) {
while (0 == done) {
len = fread (buf, 1, FILE_IO_BUF_SIZE, f);
if (len < FILE_IO_BUF_SIZE) {
if (0 == feof (f)) {
ret = IKS_FILE_RWERR;
break;
}
if (0 == len) ret = IKS_OK;
done = 1;
}
if (len > 0) {
int e;
e = iks_parse (prs, buf, len, done);
if (IKS_OK != e) {
ret = e;
break;
}
if (done) ret = IKS_OK;
}
}
fclose (f);
} else {
if (ENOENT == errno) ret = IKS_FILE_NOFILE;
else ret = IKS_FILE_NOACCESS;
}
iks_parser_delete (prs);
}
iks_free (buf);
return ret;
}
int
iks_save (const char *fname, iks *x)
{
FILE *f;
char *data;
int ret;
ret = IKS_NOMEM;
data = iks_string (NULL, x);
if (data) {
ret = IKS_FILE_NOACCESS;
f = fopen (fname, "w");
if (f) {
ret = IKS_FILE_RWERR;
if (fputs (data, f) >= 0) ret = IKS_OK;
fclose (f);
}
iks_free (data);
}
return ret;
}

View File

@@ -1,181 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
struct iksrule_struct {
struct iksrule_struct *next, *prev;
ikstack *s;
void *user_data;
iksFilterHook *filterHook;
char *id;
char *from;
char *ns;
int score;
int rules;
enum ikstype type;
enum iksubtype subtype;
};
struct iksfilter_struct {
iksrule *rules;
iksrule *last_rule;
};
iksfilter *
iks_filter_new (void)
{
iksfilter *f;
f = iks_malloc (sizeof (iksfilter));
if (!f) return NULL;
memset (f, 0, sizeof (iksfilter));
return f;
}
iksrule *
iks_filter_add_rule (iksfilter *f, iksFilterHook *filterHook, void *user_data, ...)
{
ikstack *s;
iksrule *rule;
va_list ap;
int type;
s = iks_stack_new (sizeof (iksrule), DEFAULT_RULE_CHUNK_SIZE);
if (!s) return NULL;
rule = iks_stack_alloc (s, sizeof (iksrule));
memset (rule, 0, sizeof (iksrule));
rule->s = s;
rule->user_data = user_data;
rule->filterHook = filterHook;
va_start (ap, user_data);
while (1) {
type = va_arg (ap, int);
if (IKS_RULE_DONE == type) break;
rule->rules += type;
switch (type) {
case IKS_RULE_TYPE:
rule->type = va_arg (ap, int);
break;
case IKS_RULE_SUBTYPE:
rule->subtype = va_arg (ap, int);
break;
case IKS_RULE_ID:
rule->id = iks_stack_strdup (s, va_arg (ap, char *), 0);
break;
case IKS_RULE_NS:
rule->ns = iks_stack_strdup (s, va_arg (ap, char *), 0);
break;
case IKS_RULE_FROM:
rule->from = iks_stack_strdup (s, va_arg (ap, char *), 0);
break;
case IKS_RULE_FROM_PARTIAL:
rule->from = iks_stack_strdup (s, va_arg (ap, char *), 0);
break;
}
}
va_end (ap);
if (!f->rules) f->rules = rule;
if (f->last_rule) f->last_rule->next = rule;
rule->prev = f->last_rule;
f->last_rule = rule;
return rule;
}
void
iks_filter_remove_rule (iksfilter *f, iksrule *rule)
{
if (rule->prev) rule->prev->next = rule->next;
if (rule->next) rule->next->prev = rule->prev;
if (f->rules == rule) f->rules = rule->next;
if (f->last_rule == rule) f->last_rule = rule->prev;
iks_stack_delete (&rule->s);
}
void
iks_filter_remove_hook (iksfilter *f, iksFilterHook *filterHook)
{
iksrule *rule, *tmp;
rule = f->rules;
while (rule) {
tmp = rule->next;
if (rule->filterHook == filterHook) iks_filter_remove_rule (f, rule);
rule = tmp;
}
}
void
iks_filter_packet (iksfilter *f, ikspak *pak)
{
iksrule *rule, *max_rule;
int fail, score, max_score;
rule = f->rules;
max_rule = NULL;
max_score = 0;
while (rule) {
score = 0;
fail = 0;
if (rule->rules & IKS_RULE_TYPE) {
if (rule->type == pak->type) score += 1; else fail = 1;
}
if (rule->rules & IKS_RULE_SUBTYPE) {
if (rule->subtype == pak->subtype) score += 2; else fail = 1;
}
if (rule->rules & IKS_RULE_ID) {
if (iks_strcmp (rule->id, pak->id) == 0) score += 16; else fail = 1;
}
if (rule->rules & IKS_RULE_NS) {
if (iks_strcmp (rule->ns, pak->ns) == 0) score += 4; else fail = 1;
}
if (rule->rules & IKS_RULE_FROM) {
if (pak->from && iks_strcmp (rule->from, pak->from->full) == 0) score += 8; else fail = 1;
}
if (rule->rules & IKS_RULE_FROM_PARTIAL) {
if (pak->from && iks_strcmp (rule->from, pak->from->partial) == 0) score += 8; else fail = 1;
}
if (fail != 0) score = 0;
rule->score = score;
if (score > max_score) {
max_rule = rule;
max_score = score;
}
rule = rule->next;
}
while (max_rule) {
if (IKS_FILTER_EAT == max_rule->filterHook (max_rule->user_data, pak)) return;
max_rule->score = 0;
max_rule = NULL;
max_score = 0;
rule = f->rules;
while (rule) {
if (rule->score > max_score) {
max_rule = rule;
max_score = rule->score;
}
rule = rule->next;
}
}
}
void
iks_filter_delete (iksfilter *f)
{
iksrule *rule, *tmp;
rule = f->rules;
while (rule) {
tmp = rule->next;
iks_stack_delete (&rule->s);
rule = tmp;
}
iks_free (f);
}

View File

@@ -1,765 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2007 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
#define IKS_COMMON \
struct iks_struct *next, *prev; \
struct iks_struct *parent; \
enum ikstype type; \
ikstack *s
struct iks_struct {
IKS_COMMON;
};
struct iks_tag {
IKS_COMMON;
struct iks_struct *children, *last_child;
struct iks_struct *attribs, *last_attrib;
char *name;
};
#define IKS_TAG_NAME(x) ((struct iks_tag *) (x) )->name
#define IKS_TAG_CHILDREN(x) ((struct iks_tag *) (x) )->children
#define IKS_TAG_LAST_CHILD(x) ((struct iks_tag *) (x) )->last_child
#define IKS_TAG_ATTRIBS(x) ((struct iks_tag *) (x) )->attribs
#define IKS_TAG_LAST_ATTRIB(x) ((struct iks_tag *) (x) )->last_attrib
struct iks_cdata {
IKS_COMMON;
char *cdata;
size_t len;
};
#define IKS_CDATA_CDATA(x) ((struct iks_cdata *) (x) )->cdata
#define IKS_CDATA_LEN(x) ((struct iks_cdata *) (x) )->len
struct iks_attrib {
IKS_COMMON;
char *name;
char *value;
};
#define IKS_ATTRIB_NAME(x) ((struct iks_attrib *) (x) )->name
#define IKS_ATTRIB_VALUE(x) ((struct iks_attrib *) (x) )->value
/***** Node Creating & Deleting *****/
iks *
iks_new (const char *name)
{
ikstack *s;
iks *x;
s = iks_stack_new (sizeof (struct iks_tag) * 6, 256);
if (!s) return NULL;
x = iks_new_within (name, s);
if (!x) {
iks_stack_delete (&s);
return NULL;
}
return x;
}
iks *
iks_new_within (const char *name, ikstack *s)
{
iks *x;
size_t len;
if (name) len = sizeof (struct iks_tag); else len = sizeof (struct iks_cdata);
x = iks_stack_alloc (s, len);
if (!x) return NULL;
memset (x, 0, len);
x->s = s;
x->type = IKS_TAG;
if (name) {
IKS_TAG_NAME (x) = iks_stack_strdup (s, name, 0);
if (!IKS_TAG_NAME (x)) return NULL;
}
return x;
}
iks *
iks_insert (iks *x, const char *name)
{
iks *y;
if (!x) return NULL;
y = iks_new_within (name, x->s);
if (!y) return NULL;
y->parent = x;
if (!IKS_TAG_CHILDREN (x)) IKS_TAG_CHILDREN (x) = y;
if (IKS_TAG_LAST_CHILD (x)) {
IKS_TAG_LAST_CHILD (x)->next = y;
y->prev = IKS_TAG_LAST_CHILD (x);
}
IKS_TAG_LAST_CHILD (x) = y;
return y;
}
iks *
iks_insert_cdata (iks *x, const char *data, size_t len)
{
iks *y;
if(!x || !data) return NULL;
if(len == 0) len = strlen (data);
y = IKS_TAG_LAST_CHILD (x);
if (y && y->type == IKS_CDATA) {
IKS_CDATA_CDATA (y) = iks_stack_strcat (x->s, IKS_CDATA_CDATA (y), IKS_CDATA_LEN (y), data, len);
IKS_CDATA_LEN (y) += len;
} else {
y = iks_insert (x, NULL);
if (!y) return NULL;
y->type = IKS_CDATA;
IKS_CDATA_CDATA (y) = iks_stack_strdup (x->s, data, len);
if (!IKS_CDATA_CDATA (y)) return NULL;
IKS_CDATA_LEN (y) = len;
}
return y;
}
iks *
iks_insert_attrib (iks *x, const char *name, const char *value)
{
iks *y;
if (!x) return NULL;
y = IKS_TAG_ATTRIBS (x);
while (y) {
if (strcmp (name, IKS_ATTRIB_NAME (y)) == 0) break;
y = y->next;
}
if (NULL == y) {
if (!value) return NULL;
y = iks_stack_alloc (x->s, sizeof (struct iks_attrib));
if (!y) return NULL;
memset (y, 0, sizeof (struct iks_attrib));
y->type = IKS_ATTRIBUTE;
y->s = x->s;
IKS_ATTRIB_NAME (y) = iks_stack_strdup (x->s, name, 0);
if (!IKS_ATTRIB_NAME (y)) return NULL;
y->parent = x;
if (!IKS_TAG_ATTRIBS (x)) IKS_TAG_ATTRIBS (x) = y;
if (IKS_TAG_LAST_ATTRIB (x)) {
IKS_TAG_LAST_ATTRIB (x)->next = y;
y->prev = IKS_TAG_LAST_ATTRIB (x);
}
IKS_TAG_LAST_ATTRIB (x) = y;
}
if (value) {
IKS_ATTRIB_VALUE (y) = iks_stack_strdup (x->s, value, 0);
if (!IKS_ATTRIB_VALUE (y)) return NULL;
} else {
if (y->next) y->next->prev = y->prev;
if (y->prev) y->prev->next = y->next;
if (IKS_TAG_ATTRIBS (x) == y) IKS_TAG_ATTRIBS (x) = y->next;
if (IKS_TAG_LAST_ATTRIB (x) == y) IKS_TAG_LAST_ATTRIB (x) = y->prev;
}
return y;
}
iks *
iks_insert_node (iks *x, iks *y)
{
y->parent = x;
if (!IKS_TAG_CHILDREN (x)) IKS_TAG_CHILDREN (x) = y;
if (IKS_TAG_LAST_CHILD (x)) {
IKS_TAG_LAST_CHILD (x)->next = y;
y->prev = IKS_TAG_LAST_CHILD (x);
}
IKS_TAG_LAST_CHILD (x) = y;
return y;
}
iks *
iks_append (iks *x, const char *name)
{
iks *y;
if (!x) return NULL;
y = iks_new_within (name, x->s);
if (!y) return NULL;
if (x->next) {
x->next->prev = y;
} else {
IKS_TAG_LAST_CHILD (x->parent) = y;
}
y->next = x->next;
x->next = y;
y->parent = x->parent;
y->prev = x;
return y;
}
iks *
iks_prepend (iks *x, const char *name)
{
iks *y;
if (!x) return NULL;
y = iks_new_within (name, x->s);
if (!y) return NULL;
if (x->prev) {
x->prev->next = y;
} else {
IKS_TAG_CHILDREN (x->parent) = y;
}
y->prev = x->prev;
x->prev = y;
y->parent = x->parent;
y->next = x;
return y;
}
iks *
iks_append_cdata (iks *x, const char *data, size_t len)
{
iks *y;
if (!x || !data) return NULL;
if (len == 0) len = strlen (data);
y = iks_new_within (NULL, x->s);
if (!y) return NULL;
y->type = IKS_CDATA;
IKS_CDATA_CDATA (y) = iks_stack_strdup (x->s, data, len);
if (!IKS_CDATA_CDATA (y)) return NULL;
IKS_CDATA_LEN (y) = len;
if (x->next) {
x->next->prev = y;
} else {
IKS_TAG_LAST_CHILD (x->parent) = y;
}
y->next = x->next;
x->next = y;
y->parent = x->parent;
y->prev = x;
return y;
}
iks *
iks_prepend_cdata (iks *x, const char *data, size_t len)
{
iks *y;
if (!x || !data) return NULL;
if (len == 0) len = strlen (data);
y = iks_new_within (NULL, x->s);
if (!y) return NULL;
y->type = IKS_CDATA;
IKS_CDATA_CDATA(y) = iks_stack_strdup (x->s, data, len);
if (!IKS_CDATA_CDATA (y)) return NULL;
IKS_CDATA_LEN (y) = len;
if (x->prev) {
x->prev->next = y;
} else {
IKS_TAG_CHILDREN (x->parent) = y;
}
y->prev = x->prev;
x->prev = y;
y->parent = x->parent;
y->next = x;
return y;
}
void
iks_hide (iks *x)
{
iks *y;
if (!x) return;
if (x->prev) x->prev->next = x->next;
if (x->next) x->next->prev = x->prev;
y = x->parent;
if (y) {
if (IKS_TAG_CHILDREN (y) == x) IKS_TAG_CHILDREN (y) = x->next;
if (IKS_TAG_LAST_CHILD (y) == x) IKS_TAG_LAST_CHILD (y) = x->prev;
}
}
void
iks_delete (iks *x)
{
if (x) iks_stack_delete (&x->s);
}
/***** Node Traversing *****/
iks *
iks_next (iks *x)
{
if (x) return x->next;
return NULL;
}
iks *
iks_next_tag (iks *x)
{
if (x) {
while (1) {
x = x->next;
if (NULL == x) break;
if (IKS_TAG == x->type) return x;
}
}
return NULL;
}
iks *
iks_prev (iks *x)
{
if (x) return x->prev;
return NULL;
}
iks *
iks_prev_tag (iks *x)
{
if (x) {
while (1) {
x = x->prev;
if (NULL == x) break;
if (IKS_TAG == x->type) return x;
}
}
return NULL;
}
iks *
iks_parent (iks *x)
{
if (x) return x->parent;
return NULL;
}
iks *
iks_root (iks *x)
{
if (x) {
while (x->parent)
x = x->parent;
}
return x;
}
iks *
iks_child (iks *x)
{
if (x && IKS_TAG == x->type) return IKS_TAG_CHILDREN (x);
return NULL;
}
iks *
iks_first_tag (iks *x)
{
if (x) {
x = IKS_TAG_CHILDREN (x);
while (x) {
if (IKS_TAG == x->type) return x;
x = x->next;
}
}
return NULL;
}
iks *
iks_attrib (iks *x)
{
if (x) return IKS_TAG_ATTRIBS (x);
return NULL;
}
iks *
iks_find (iks *x, const char *name)
{
iks *y;
if (!x) return NULL;
y = IKS_TAG_CHILDREN (x);
while (y) {
if (IKS_TAG == y->type && IKS_TAG_NAME (y) && strcmp (IKS_TAG_NAME (y), name) == 0) return y;
y = y->next;
}
return NULL;
}
char *
iks_find_cdata (iks *x, const char *name)
{
iks *y;
y = iks_find (x, name);
if (!y) return NULL;
y = IKS_TAG_CHILDREN (y);
if (!y || IKS_CDATA != y->type) return NULL;
return IKS_CDATA_CDATA (y);
}
char *
iks_find_attrib (iks *x, const char *name)
{
iks *y;
if (!x) return NULL;
y = IKS_TAG_ATTRIBS (x);
while (y) {
if (IKS_ATTRIB_NAME (y) && strcmp (IKS_ATTRIB_NAME (y), name) == 0)
return IKS_ATTRIB_VALUE (y);
y = y->next;
}
return NULL;
}
iks *
iks_find_with_attrib (iks *x, const char *tagname, const char *attrname, const char *value)
{
iks *y;
if (NULL == x) return NULL;
if (tagname) {
for (y = IKS_TAG_CHILDREN (x); y; y = y->next) {
if (IKS_TAG == y->type
&& strcmp (IKS_TAG_NAME (y), tagname) == 0
&& iks_strcmp (iks_find_attrib (y, attrname), value) == 0) {
return y;
}
}
} else {
for (y = IKS_TAG_CHILDREN (x); y; y = y->next) {
if (IKS_TAG == y->type
&& iks_strcmp (iks_find_attrib (y, attrname), value) == 0) {
return y;
}
}
}
return NULL;
}
/***** Node Information *****/
ikstack *
iks_stack (iks *x)
{
if (x) return x->s;
return NULL;
}
enum ikstype
iks_type (iks *x)
{
if (x) return x->type;
return IKS_NONE;
}
char *
iks_name (iks *x)
{
if (x) {
if (IKS_TAG == x->type)
return IKS_TAG_NAME (x);
else
return IKS_ATTRIB_NAME (x);
}
return NULL;
}
char *
iks_cdata (iks *x)
{
if (x) {
if (IKS_CDATA == x->type)
return IKS_CDATA_CDATA (x);
else
return IKS_ATTRIB_VALUE (x);
}
return NULL;
}
size_t
iks_cdata_size (iks *x)
{
if (x) return IKS_CDATA_LEN (x);
return 0;
}
int
iks_has_children (iks *x)
{
if (x && IKS_TAG == x->type && IKS_TAG_CHILDREN (x)) return 1;
return 0;
}
int
iks_has_attribs (iks *x)
{
if (x && IKS_TAG == x->type && IKS_TAG_ATTRIBS (x)) return 1;
return 0;
}
/***** Serializing *****/
static size_t
escape_size (char *src, size_t len)
{
size_t sz;
char c;
int i;
sz = 0;
for (i = 0; i < len; i++) {
c = src[i];
switch (c) {
case '&': sz += 5; break;
case '\'': sz += 6; break;
case '"': sz += 6; break;
case '<': sz += 4; break;
case '>': sz += 4; break;
default: sz++; break;
}
}
return sz;
}
static char *
my_strcat (char *dest, char *src, size_t len)
{
if (0 == len) len = strlen (src);
memcpy (dest, src, len);
return dest + len;
}
static char *
escape (char *dest, char *src, size_t len)
{
char c;
int i;
int j = 0;
for (i = 0; i < len; i++) {
c = src[i];
if ('&' == c || '<' == c || '>' == c || '\'' == c || '"' == c) {
if (i - j > 0) dest = my_strcat (dest, src + j, i - j);
j = i + 1;
switch (c) {
case '&': dest = my_strcat (dest, "&amp;", 5); break;
case '\'': dest = my_strcat (dest, "&apos;", 6); break;
case '"': dest = my_strcat (dest, "&quot;", 6); break;
case '<': dest = my_strcat (dest, "&lt;", 4); break;
case '>': dest = my_strcat (dest, "&gt;", 4); break;
}
}
}
if (i - j > 0) dest = my_strcat (dest, src + j, i - j);
return dest;
}
char *
iks_string (ikstack *s, iks *x)
{
size_t size;
int level, dir;
iks *y, *z;
char *ret, *t;
if (!x) return NULL;
if (x->type == IKS_CDATA) {
if (s) {
return iks_stack_strdup (s, IKS_CDATA_CDATA (x), IKS_CDATA_LEN (x));
} else {
ret = iks_malloc (IKS_CDATA_LEN (x));
memcpy (ret, IKS_CDATA_CDATA (x), IKS_CDATA_LEN (x));
return ret;
}
}
size = 0;
level = 0;
dir = 0;
y = x;
while (1) {
if (dir==0) {
if (y->type == IKS_TAG) {
size++;
size += strlen (IKS_TAG_NAME (y));
for (z = IKS_TAG_ATTRIBS (y); z; z = z->next) {
if (z->type == IKS_NONE) {
continue;
}
size += 4 + strlen (IKS_ATTRIB_NAME (z))
+ escape_size (IKS_ATTRIB_VALUE (z), strlen (IKS_ATTRIB_VALUE (z)));
}
if (IKS_TAG_CHILDREN (y)) {
size++;
y = IKS_TAG_CHILDREN (y);
level++;
continue;
} else {
size += 2;
}
} else {
size += escape_size (IKS_CDATA_CDATA (y), IKS_CDATA_LEN (y));
}
}
z = y->next;
if (z) {
if (0 == level) {
if (IKS_TAG_CHILDREN (y)) size += 3 + strlen (IKS_TAG_NAME (y));
break;
}
y = z;
dir = 0;
} else {
y = y->parent;
level--;
if (level >= 0) size += 3 + strlen (IKS_TAG_NAME (y));
if (level < 1) break;
dir = 1;
}
}
if (s) ret = iks_stack_alloc (s, size + 1);
else ret = iks_malloc (size + 1);
if (!ret) return NULL;
t = ret;
level = 0;
dir = 0;
while (1) {
if (dir==0) {
if (x->type == IKS_TAG) {
*t++ = '<';
t = my_strcat (t, IKS_TAG_NAME (x), 0);
y = IKS_TAG_ATTRIBS (x);
while (y) {
*t++ = ' ';
t = my_strcat (t, IKS_ATTRIB_NAME (y), 0);
*t++ = '=';
*t++ = '\'';
t = escape (t, IKS_ATTRIB_VALUE (y), strlen (IKS_ATTRIB_VALUE (y)));
*t++ = '\'';
y = y->next;
}
if (IKS_TAG_CHILDREN (x)) {
*t++ = '>';
x = IKS_TAG_CHILDREN (x);
level++;
continue;
} else {
*t++ = '/';
*t++ = '>';
}
} else {
t = escape (t, IKS_CDATA_CDATA (x), IKS_CDATA_LEN (x));
}
}
y = x->next;
if (y) {
if (0 == level) {
if (IKS_TAG_CHILDREN (x)) {
*t++ = '<';
*t++ = '/';
t = my_strcat (t, IKS_TAG_NAME (x), 0);
*t++ = '>';
}
break;
}
x = y;
dir = 0;
} else {
x = x->parent;
level--;
if (level >= 0) {
*t++ = '<';
*t++ = '/';
t = my_strcat (t, IKS_TAG_NAME (x), 0);
*t++ = '>';
}
if (level < 1) break;
dir = 1;
}
}
*t = '\0';
return ret;
}
/***** Copying *****/
iks *
iks_copy_within (iks *x, ikstack *s)
{
int level=0, dir=0;
iks *copy = NULL;
iks *cur = NULL;
iks *y;
while (1) {
if (dir == 0) {
if (x->type == IKS_TAG) {
if (copy == NULL) {
copy = iks_new_within (IKS_TAG_NAME (x), s);
cur = copy;
} else {
cur = iks_insert (cur, IKS_TAG_NAME (x));
}
for (y = IKS_TAG_ATTRIBS (x); y; y = y->next) {
iks_insert_attrib (cur, IKS_ATTRIB_NAME (y), IKS_ATTRIB_VALUE (y));
}
if (IKS_TAG_CHILDREN (x)) {
x = IKS_TAG_CHILDREN (x);
level++;
continue;
} else {
cur = cur->parent;
}
} else {
iks_insert_cdata (cur, IKS_CDATA_CDATA (x), IKS_CDATA_LEN (x));
}
}
y = x->next;
if (y) {
if (0 == level) break;
x = y;
dir = 0;
} else {
if (level < 2) break;
level--;
x = x->parent;
cur = cur->parent;
dir = 1;
}
}
return copy;
}
iks *
iks_copy (iks *x)
{
return iks_copy_within (x, iks_stack_new (sizeof (struct iks_tag) * 6, 256));
}

View File

@@ -1,214 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2004 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
struct align_test { char a; double b; };
#define DEFAULT_ALIGNMENT ((size_t) ((char *) &((struct align_test *) 0)->b - (char *) 0))
#define ALIGN_MASK ( DEFAULT_ALIGNMENT - 1 )
#define MIN_CHUNK_SIZE ( DEFAULT_ALIGNMENT * 8 )
#define MIN_ALLOC_SIZE DEFAULT_ALIGNMENT
#define ALIGN(x) ( (x) + (DEFAULT_ALIGNMENT - ( (x) & ALIGN_MASK)) )
typedef struct ikschunk_struct {
struct ikschunk_struct *next;
size_t size;
size_t used;
size_t last;
char data[4];
} ikschunk;
struct ikstack_struct {
size_t allocated;
ikschunk *meta;
ikschunk *data;
};
static ikschunk *
find_space (ikstack *s, ikschunk *c, size_t size)
{
/* FIXME: dont use *2 after over allocated chunks */
while (c) {
if (c->size - c->used >= size) return c;
if (!c->next) {
if ((c->size * 2) > size) size = c->size * 2;
c->next = iks_malloc (sizeof (ikschunk) + size);
if (!c->next) return NULL;
s->allocated += sizeof (ikschunk) + size;
c = c->next;
c->next = NULL;
c->size = size;
c->used = 0;
c->last = (size_t) -1;
return c;
}
c = c->next;
}
return NULL;
}
ikstack *
iks_stack_new (size_t meta_chunk, size_t data_chunk)
{
ikstack *s;
size_t len;
if (meta_chunk < MIN_CHUNK_SIZE) meta_chunk = MIN_CHUNK_SIZE;
if (meta_chunk & ALIGN_MASK) meta_chunk = ALIGN (meta_chunk);
if (data_chunk < MIN_CHUNK_SIZE) data_chunk = MIN_CHUNK_SIZE;
if (data_chunk & ALIGN_MASK) data_chunk = ALIGN (data_chunk);
len = sizeof (ikstack) + meta_chunk + data_chunk + (sizeof (ikschunk) * 2);
s = iks_malloc (len);
if (!s) return NULL;
s->allocated = len;
s->meta = (ikschunk *) ((char *) s + sizeof (ikstack));
s->meta->next = NULL;
s->meta->size = meta_chunk;
s->meta->used = 0;
s->meta->last = (size_t) -1;
s->data = (ikschunk *) ((char *) s + sizeof (ikstack) + sizeof (ikschunk) + meta_chunk);
s->data->next = NULL;
s->data->size = data_chunk;
s->data->used = 0;
s->data->last = (size_t) -1;
return s;
}
void *
iks_stack_alloc (ikstack *s, size_t size)
{
ikschunk *c;
void *mem;
if (size < MIN_ALLOC_SIZE) size = MIN_ALLOC_SIZE;
if (size & ALIGN_MASK) size = ALIGN (size);
c = find_space (s, s->meta, size);
if (!c) return NULL;
mem = c->data + c->used;
c->used += size;
return mem;
}
char *
iks_stack_strdup (ikstack *s, const char *src, size_t len)
{
ikschunk *c;
char *dest;
if (!src) return NULL;
if (0 == len) len = strlen (src);
c = find_space (s, s->data, len + 1);
if (!c) return NULL;
dest = c->data + c->used;
c->last = c->used;
c->used += len + 1;
memcpy (dest, src, len);
dest[len] = '\0';
return dest;
}
char *
iks_stack_strcat (ikstack *s, char *old, size_t old_len, const char *src, size_t src_len)
{
char *ret;
ikschunk *c;
if (!old) {
return iks_stack_strdup (s, src, src_len);
}
if (0 == old_len) old_len = strlen (old);
if (0 == src_len) src_len = strlen (src);
for (c = s->data; c; c = c->next) {
if (c->data + c->last == old) break;
}
if (!c) {
c = find_space (s, s->data, old_len + src_len + 1);
if (!c) return NULL;
ret = c->data + c->used;
c->last = c->used;
c->used += old_len + src_len + 1;
memcpy (ret, old, old_len);
memcpy (ret + old_len, src, src_len);
ret[old_len + src_len] = '\0';
return ret;
}
if (c->size - c->used > src_len) {
ret = c->data + c->last;
memcpy (ret + old_len, src, src_len);
c->used += src_len;
ret[old_len + src_len] = '\0';
} else {
/* FIXME: decrease c->used before moving string to new place */
c = find_space (s, s->data, old_len + src_len + 1);
if (!c) return NULL;
c->last = c->used;
ret = c->data + c->used;
memcpy (ret, old, old_len);
c->used += old_len;
memcpy (c->data + c->used, src, src_len);
c->used += src_len;
c->data[c->used] = '\0';
c->used++;
}
return ret;
}
void
iks_stack_stat (ikstack *s, size_t *allocated, size_t *used)
{
ikschunk *c;
if (allocated) {
*allocated = s->allocated;
}
if (used) {
*used = 0;
for (c = s->meta; c; c = c->next) {
(*used) += c->used;
}
for (c = s->data; c; c = c->next) {
(*used) += c->used;
}
}
}
void
iks_stack_delete (ikstack **sp)
{
ikschunk *c, *tmp;
ikstack *s;
if (!sp) {
return;
}
s = *sp;
if (!s) {
return;
}
*sp = NULL;
c = s->meta->next;
while (c) {
tmp = c->next;
iks_free (c);
c = tmp;
}
c = s->data->next;
while (c) {
tmp = c->next;
iks_free (c);
c = tmp;
}
iks_free (s);
}

View File

@@ -1,172 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2004 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
#ifdef _WIN32
#include <winsock.h>
#else
#include <netdb.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#endif
static void
io_close (void *socket)
{
int sock = (int) socket;
#ifdef _WIN32
closesocket (sock);
#else
close (sock);
#endif
}
static int
io_connect (iksparser *prs, void **socketptr, const char *server, int port)
{
int sock = -1;
int tmp;
#ifdef HAVE_GETADDRINFO
struct addrinfo hints;
struct addrinfo *addr_res, *addr_ptr;
char port_str[6];
int err = 0;
int family = AF_INET;
if (strchr(server, ':')) {
family = AF_INET6;
}
hints.ai_flags = AI_CANONNAME;
hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
hints.ai_addrlen = 0;
hints.ai_canonname = NULL;
hints.ai_addr = NULL;
hints.ai_next = NULL;
sprintf (port_str, "%i", port);
if (getaddrinfo (server, port_str, &hints, &addr_res) != 0)
return IKS_NET_NODNS;
addr_ptr = addr_res;
while (addr_ptr) {
err = IKS_NET_NOSOCK;
sock = socket (addr_ptr->ai_family, addr_ptr->ai_socktype, addr_ptr->ai_protocol);
if (sock != -1) {
err = IKS_NET_NOCONN;
tmp = connect (sock, addr_ptr->ai_addr, addr_ptr->ai_addrlen);
if (tmp == 0) break;
io_close ((void *) sock);
sock = -1;
}
addr_ptr = addr_ptr->ai_next;
}
freeaddrinfo (addr_res);
if (sock == -1) return err;
#else
struct hostent *host;
struct sockaddr_in sin;
host = gethostbyname (server);
if (!host) return IKS_NET_NODNS;
memcpy (&sin.sin_addr, host->h_addr, host->h_length);
sin.sin_family = host->h_addrtype;
sin.sin_port = htons (port);
sock = socket (host->h_addrtype, SOCK_STREAM, 0);
if (sock == -1) return IKS_NET_NOSOCK;
tmp = connect (sock, (struct sockaddr *)&sin, sizeof (struct sockaddr_in));
if (tmp != 0) {
io_close ((void *) sock);
return IKS_NET_NOCONN;
}
#endif
*socketptr = (void *) sock;
return IKS_OK;
}
static int
io_send (void *socket, const char *data, size_t len)
{
int sock = (int) socket;
if (send (sock, data, len, 0) == -1) return IKS_NET_RWERR;
return IKS_OK;
}
static int
io_recv (void *socket, char *buffer, size_t buf_len, int timeout)
{
int sock = (int) socket;
fd_set fds;
struct timeval tv, *tvptr;
int len;
char *bound;
tv.tv_sec = 0;
tv.tv_usec = 0;
FD_ZERO (&fds);
FD_SET (sock, &fds);
tv.tv_sec = timeout;
if (timeout != -1) tvptr = &tv; else tvptr = NULL;
if (select (sock + 1, &fds, NULL, NULL, tvptr) > 0) {
len = recv (sock, buffer, buf_len, 0);
if (len > 0) {
char *p, *e = NULL, *t = NULL;
bound = buffer + (len -1);
for (p = buffer; p < bound; p++) {
if (*p == '>') {
e = p;
t = p+1;
if (*t == '<') {
continue;
}
while(p < bound && t < bound) {
if (*t != ' ' && *t != '<') {
t = e = NULL;
break;
}
if (*t == '<') {
p = t;
*(p-1) = '>';
*e = ' ';
e = NULL;
break;
}
t++;
}
}
}
return len;
} else if (len <= 0) {
return -1;
}
}
return 0;
}
ikstransport iks_default_transport = {
IKS_TRANSPORT_V1,
io_connect,
io_send,
io_recv,
io_close,
NULL
};

View File

@@ -1,330 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
iksid *
iks_id_new (ikstack *s, const char *jid)
{
iksid *id;
char *src, *tmp;
/* FIXME: add jabber id validity checks to this function */
/* which characters are allowed in id parts? */
if (!jid) return NULL;
id = iks_stack_alloc (s, sizeof (iksid));
if (!id) return NULL;
memset (id, 0, sizeof (iksid));
/* skip scheme */
if (strncmp ("jabber:", jid, 7) == 0) jid += 7;
id->full = iks_stack_strdup (s, jid, 0);
src = id->full;
/* split resource */
tmp = strchr (src, '/');
if (tmp) {
id->partial = iks_stack_strdup (s, src, tmp - src);
id->resource = tmp + 1;
src = id->partial;
} else {
id->partial = src;
}
/* split user */
tmp = strchr (src, '@');
if (tmp) {
id->user = iks_stack_strdup (s, src, tmp - src);
src = ++tmp;
}
id->server = src;
return id;
}
int
iks_id_cmp (iksid *a, iksid *b, int parts)
{
int diff;
if (!a || !b) return (IKS_ID_RESOURCE | IKS_ID_USER | IKS_ID_SERVER);
diff = 0;
if (parts & IKS_ID_RESOURCE && !(!a->resource && !b->resource) && iks_strcmp (a->resource, b->resource) != 0)
diff += IKS_ID_RESOURCE;
if (parts & IKS_ID_USER && !(!a->user && !b->user) && iks_strcasecmp (a->user, b->user) != 0)
diff += IKS_ID_USER;
if (parts & IKS_ID_SERVER && !(!a->server && !b->server) && iks_strcmp (a->server, b->server) != 0)
diff += IKS_ID_SERVER;
return diff;
}
ikspak *
iks_packet (iks *x)
{
ikspak *pak;
ikstack *s;
char *tmp;
s = iks_stack (x);
pak = iks_stack_alloc (s, sizeof (ikspak));
if (!pak) return NULL;
memset (pak, 0, sizeof (ikspak));
pak->x = x;
tmp = iks_find_attrib (x, "from");
if (tmp) pak->from = iks_id_new (s, tmp);
pak->id = iks_find_attrib (x, "id");
tmp = iks_find_attrib (x, "type");
if (strcmp (iks_name (x), "message") == 0) {
pak->type = IKS_PAK_MESSAGE;
if (tmp) {
if (strcmp (tmp, "chat") == 0)
pak->subtype = IKS_TYPE_CHAT;
else if (strcmp (tmp, "groupchat") == 0)
pak->subtype = IKS_TYPE_GROUPCHAT;
else if (strcmp (tmp, "headline") == 0)
pak->subtype = IKS_TYPE_HEADLINE;
else if (strcmp (tmp, "error") == 0)
pak->subtype = IKS_TYPE_ERROR;
}
} else if (strcmp (iks_name (x), "presence") == 0) {
pak->type = IKS_PAK_S10N;
if (tmp) {
if (strcmp (tmp, "unavailable") == 0) {
pak->type = IKS_PAK_PRESENCE;
pak->subtype = IKS_TYPE_UNAVAILABLE;
pak->show = IKS_SHOW_UNAVAILABLE;
} else if (strcmp (tmp, "probe") == 0) {
pak->type = IKS_PAK_PRESENCE;
pak->subtype = IKS_TYPE_PROBE;
} else if(strcmp(tmp, "subscribe") == 0)
pak->subtype = IKS_TYPE_SUBSCRIBE;
else if(strcmp(tmp, "subscribed") == 0)
pak->subtype = IKS_TYPE_SUBSCRIBED;
else if(strcmp(tmp, "unsubscribe") == 0)
pak->subtype = IKS_TYPE_UNSUBSCRIBE;
else if(strcmp(tmp, "unsubscribed") == 0)
pak->subtype = IKS_TYPE_UNSUBSCRIBED;
else if(strcmp(tmp, "error") == 0)
pak->subtype = IKS_TYPE_ERROR;
} else {
pak->type = IKS_PAK_PRESENCE;
pak->subtype = IKS_TYPE_AVAILABLE;
tmp = iks_find_cdata (x, "show");
pak->show = IKS_SHOW_AVAILABLE;
if (tmp) {
if (strcmp (tmp, "chat") == 0)
pak->show = IKS_SHOW_CHAT;
else if (strcmp (tmp, "away") == 0)
pak->show = IKS_SHOW_AWAY;
else if (strcmp (tmp, "xa") == 0)
pak->show = IKS_SHOW_XA;
else if (strcmp (tmp, "dnd") == 0)
pak->show = IKS_SHOW_DND;
}
}
} else if (strcmp (iks_name (x), "iq") == 0) {
iks *q;
pak->type = IKS_PAK_IQ;
if (tmp) {
if (strcmp (tmp, "get") == 0)
pak->subtype = IKS_TYPE_GET;
else if (strcmp (tmp, "set") == 0)
pak->subtype = IKS_TYPE_SET;
else if (strcmp (tmp, "result") == 0)
pak->subtype = IKS_TYPE_RESULT;
else if (strcmp (tmp, "error") == 0)
pak->subtype = IKS_TYPE_ERROR;
}
for (q = iks_child (x); q; q = iks_next (q)) {
if (IKS_TAG == iks_type (q)) {
char *ns;
ns = iks_find_attrib (q, "xmlns");
if (ns) {
pak->query = q;
pak->ns = ns;
break;
}
}
}
}
return pak;
}
iks *
iks_make_auth (iksid *id, const char *pass, const char *sid)
{
iks *x, *y;
x = iks_new ("iq");
iks_insert_attrib (x, "type", "set");
y = iks_insert (x, "query");
iks_insert_attrib (y, "xmlns", IKS_NS_AUTH);
iks_insert_cdata (iks_insert (y, "username"), id->user, 0);
iks_insert_cdata (iks_insert (y, "resource"), id->resource, 0);
if(sid) {
char buf[41];
iksha *sha;
sha = iks_sha_new ();
iks_sha_hash (sha, (const unsigned char*)sid, strlen (sid), 0);
iks_sha_hash (sha, (const unsigned char*)pass, strlen (pass), 1);
iks_sha_print (sha, buf);
iks_sha_delete (sha);
iks_insert_cdata (iks_insert (y, "digest"), buf, 40);
} else {
iks_insert_cdata (iks_insert (y, "password"), pass, 0);
}
return x;
}
iks *
iks_make_msg (enum iksubtype type, const char *to, const char *body)
{
iks *x;
char *t = NULL;
x = iks_new ("message");
switch (type) {
case IKS_TYPE_CHAT: t = "chat"; break;
case IKS_TYPE_GROUPCHAT: t = "groupchat"; break;
case IKS_TYPE_HEADLINE: t = "headline"; break;
default: break;
}
if (t) iks_insert_attrib (x, "type", t);
if (to) iks_insert_attrib (x, "to", to);
if (body) iks_insert_cdata (iks_insert (x, "body"), body, 0);
return x;
}
iks *
iks_make_s10n (enum iksubtype type, const char *to, const char *msg)
{
iks *x;
char *t;
x = iks_new ("presence");
switch (type) {
case IKS_TYPE_SUBSCRIBE: t = "subscribe"; break;
case IKS_TYPE_SUBSCRIBED: t = "subscribed"; break;
case IKS_TYPE_UNSUBSCRIBE: t = "unsubscribe"; break;
case IKS_TYPE_UNSUBSCRIBED: t = "unsubscribed"; break;
case IKS_TYPE_PROBE: t = "probe"; break;
default: t = NULL; break;
}
if (t) iks_insert_attrib (x, "type", t);
if (to) iks_insert_attrib (x, "to", to);
if (msg) iks_insert_cdata(iks_insert (x, "status"), msg, 0);
return x;
}
iks *
iks_make_pres (enum ikshowtype show, const char *status)
{
iks *x;
char *t;
x = iks_new ("presence");
switch (show) {
case IKS_SHOW_CHAT: t = "chat"; break;
case IKS_SHOW_AWAY: t = "away"; break;
case IKS_SHOW_XA: t = "xa"; break;
case IKS_SHOW_DND: t = "dnd"; break;
case IKS_SHOW_UNAVAILABLE:
t = NULL;
iks_insert_attrib (x, "type", "unavailable");
break;
default: t = NULL; break;
}
if (t) iks_insert_cdata (iks_insert (x, "show"), t, 0);
if (status) iks_insert_cdata(iks_insert (x, "status"), status, 0);
return x;
}
iks *
iks_make_iq (enum iksubtype type, const char *xmlns)
{
iks *x;
char *t = NULL;
x = iks_new ("iq");
switch (type) {
case IKS_TYPE_GET: t = "get"; break;
case IKS_TYPE_SET: t = "set"; break;
case IKS_TYPE_RESULT: t = "result"; break;
case IKS_TYPE_ERROR: t = "error"; break;
default: break;
}
if (t) iks_insert_attrib (x, "type", t);
iks_insert_attrib (iks_insert (x, "query"), "xmlns", xmlns);
return x;
}
iks *
iks_make_resource_bind (iksid *id)
{
iks *x, *y, *z;
x = iks_new("iq");
iks_insert_attrib(x, "type", "set");
y = iks_insert(x, "bind");
iks_insert_attrib(y, "xmlns", IKS_NS_XMPP_BIND);
if (id->resource && iks_strcmp(id->resource, "")) {
z = iks_insert(y, "resource");
iks_insert_cdata(z, id->resource, 0);
}
return x;
}
iks *
iks_make_session (void)
{
iks *x, *y;
x = iks_new ("iq");
iks_insert_attrib (x, "type", "set");
y = iks_insert (x, "session");
iks_insert_attrib (y, "xmlns", IKS_NS_XMPP_SESSION);
return x;
}
static int
iks_sasl_mechanisms (iks *x)
{
int sasl_mech = 0;
while (x) {
if (!iks_strcmp(iks_cdata(iks_child(x)), "DIGEST-MD5"))
sasl_mech |= IKS_STREAM_SASL_MD5;
else if (!iks_strcmp(iks_cdata(iks_child(x)), "PLAIN"))
sasl_mech |= IKS_STREAM_SASL_PLAIN;
x = iks_next_tag(x);
}
return sasl_mech;
}
int
iks_stream_features (iks *x)
{
int features = 0;
if (iks_strcmp(iks_name(x), "stream:features"))
return 0;
for (x = iks_child(x); x; x = iks_next_tag(x))
if (!iks_strcmp(iks_name(x), "starttls"))
features |= IKS_STREAM_STARTTLS;
else if (!iks_strcmp(iks_name(x), "bind"))
features |= IKS_STREAM_BIND;
else if (!iks_strcmp(iks_name(x), "session"))
features |= IKS_STREAM_SESSION;
else if (!iks_strcmp(iks_name(x), "mechanisms"))
features |= iks_sasl_mechanisms(iks_child(x));
return features;
}

View File

@@ -1,189 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
#define GET_UINT32(n,b,i) { \
(n) = ( (unsigned long int) (b)[(i) ] ) \
| ( (unsigned long int) (b)[(i) + 1] << 8 ) \
| ( (unsigned long int) (b)[(i) + 2] << 16 ) \
| ( (unsigned long int) (b)[(i) + 3] << 24 ); \
}
#define PUT_UINT32(n,b,i) { \
(b)[(i) ] = (unsigned char) ( (n) ); \
(b)[(i) + 1] = (unsigned char) ( (n) >> 8 ); \
(b)[(i) + 2] = (unsigned char) ( (n) >> 16 ); \
(b)[(i) + 3] = (unsigned char) ( (n) >> 24 ); \
}
#define F(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define G(x,y,z) ((y) ^ ((z) & ((x) ^ (y))))
#define H(x,y,z) ((x) ^ (y) ^ (z))
#define I(x,y,z) ((y) ^ ((x) | ~(z)))
#define S(x,n) (((x) << (n)) | (((x) & 0xFFFFFFFF) >> (32 - (n))))
#define P(r,i,f,k,s,t) { \
r[i] += f(r[((i)+1)%4],r[((i)+2)%4],r[((i)+3)%4]) + X[k] + t; \
r[i] = S(r[i],s) + r[((i)+1)%4]; \
}
struct iksmd5_struct {
unsigned long int total[2];
unsigned long int state[4];
unsigned char buffer[64];
unsigned char blen;
};
static const unsigned long int T[] =
{ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 };
static void iks_md5_compute(iksmd5 *md5);
void iks_md5_reset(iksmd5 *md5)
{
memset(md5, 0, sizeof(iksmd5));
md5->state[0] = 0x67452301;
md5->state[1] = 0xEFCDAB89;
md5->state[2] = 0x98BADCFE;
md5->state[3] = 0x10325476;
}
iksmd5 *iks_md5_new(void)
{
iksmd5 *md5 = malloc(sizeof(iksmd5));
if (!md5)
return NULL;
iks_md5_reset(md5);
return md5;
}
void iks_md5_hash(iksmd5 *md5, const unsigned char *data, size_t slen, int finish)
{
int i, j;
int len = slen;
i = (64 - md5->blen);
j = (len < i) ? (len) : (i);
memcpy(md5->buffer + md5->blen, data, j);
md5->blen += j;
len -= j;
data += j;
while (len > 0) {
iks_md5_compute(md5);
md5->blen = 0;
md5->total[0] += 8*64;
md5->total[1] += (md5->total[0] < 8*64);
j = (len < 64) ? (len) : (64);
memcpy(md5->buffer, data, j);
md5->blen = j;
len -= j;
data += j;
}
if (finish) {
md5->total[0] += 8*md5->blen;
md5->total[1] += (md5->total[0] < 8*md5->blen);
md5->buffer[(md5->blen)++] = 0x80;
if (md5->blen > 56) {
while (md5->blen < 64)
md5->buffer[(md5->blen)++] = 0x00;
iks_md5_compute(md5);
md5->blen = 0;
}
while (md5->blen < 56)
md5->buffer[(md5->blen)++] = 0x00;
PUT_UINT32(md5->total[0], md5->buffer, 56);
PUT_UINT32(md5->total[1], md5->buffer, 60);
iks_md5_compute(md5);
}
}
void iks_md5_delete(iksmd5 *md5)
{
free(md5);
}
void iks_md5_digest(iksmd5 *md5, unsigned char *digest)
{
PUT_UINT32(md5->state[0], digest, 0);
PUT_UINT32(md5->state[1], digest, 4);
PUT_UINT32(md5->state[2], digest, 8);
PUT_UINT32(md5->state[3], digest, 12);
}
void iks_md5_print(iksmd5 *md5, char *buf)
{
int i;
unsigned char digest[16];
iks_md5_digest(md5, digest);
for (i = 0; i < 16; i++) {
sprintf (buf, "%02x", digest[i]);
buf += 2;
}
}
void iks_md5(const char *data, char *buf)
{
iksmd5 *md5 = iks_md5_new();
iks_md5_hash(md5, (const unsigned char*)data, strlen(data), 1);
iks_md5_print(md5, buf);
iks_md5_delete(md5);
}
static void iks_md5_compute(iksmd5 *md5)
{
unsigned long int X[16], R[4];
unsigned char RS1[] = { 7, 12 ,17, 22 };
unsigned char RS2[] = { 5, 9 ,14, 20 };
unsigned char RS3[] = { 4, 11 ,16, 23 };
unsigned char RS4[] = { 6, 10 ,15, 21 };
int i, j, k, p;
for (i = 0; i < 16; ++i)
GET_UINT32(X[i], md5->buffer, i*4);
for (i = 0; i < 4; ++i)
R[i] = md5->state[i];
for (i = j = k = 0; i < 16; ++i, j = i%4, k = (k+3)%4)
P(R, k, F, i, RS1[j], T[i]);
for (i = j = k = 0, p = 1; i < 16; ++i, j = i%4, k = (k+3)%4, p = (p+5)%16)
P(R, k, G, p, RS2[j], T[i+16]);
for (i = j = k = 0, p = 5; i < 16; ++i, j = i%4, k = (k+3)%4, p = (p+3)%16)
P(R, k, H, p, RS3[j], T[i+32]);
for (i = j = k = p = 0; i < 16; ++i, j = i%4, k = (k+3)%4, p = (p+7)%16)
P(R, k, I, p, RS4[j], T[i+48]);
for (i = 0; i < 4; ++i)
md5->state[i] += R[i];
}

View File

@@ -1,635 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2004 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
enum cons_e {
C_CDATA = 0,
C_TAG_START,
C_TAG,
C_TAG_END,
C_ATTRIBUTE,
C_ATTRIBUTE_1,
C_ATTRIBUTE_2,
C_VALUE,
C_VALUE_APOS,
C_VALUE_QUOT,
C_WHITESPACE,
C_ENTITY,
C_COMMENT,
C_COMMENT_1,
C_COMMENT_2,
C_COMMENT_3,
C_MARKUP,
C_MARKUP_1,
C_SECT,
C_SECT_CDATA,
C_SECT_CDATA_1,
C_SECT_CDATA_2,
C_SECT_CDATA_3,
C_SECT_CDATA_4,
C_SECT_CDATA_C,
C_SECT_CDATA_E,
C_SECT_CDATA_E2,
C_PI
};
/* if you add a variable here, dont forget changing iks_parser_reset */
struct iksparser_struct {
ikstack *s;
void *user_data;
iksTagHook *tagHook;
iksCDataHook *cdataHook;
iksDeleteHook *deleteHook;
/* parser context */
char *stack;
size_t stack_pos;
size_t stack_max;
enum cons_e context;
enum cons_e oldcontext;
char *tag_name;
enum ikstagtype tagtype;
unsigned int attmax;
unsigned int attcur;
int attflag;
char **atts;
int valflag;
unsigned int entpos;
char entity[8];
unsigned long nr_bytes;
unsigned long nr_lines;
int uni_max;
int uni_len;
};
iksparser *
iks_sax_new (void *user_data, iksTagHook *tagHook, iksCDataHook *cdataHook)
{
iksparser *prs;
prs = iks_malloc (sizeof (iksparser));
if (NULL == prs) return NULL;
memset (prs, 0, sizeof (iksparser));
prs->user_data = user_data;
prs->tagHook = tagHook;
prs->cdataHook = cdataHook;
return prs;
}
iksparser *
iks_sax_extend (ikstack *s, void *user_data, iksTagHook *tagHook, iksCDataHook *cdataHook, iksDeleteHook *deleteHook)
{
iksparser *prs;
prs = iks_stack_alloc (s, sizeof (iksparser));
if (NULL == prs) return NULL;
memset (prs, 0, sizeof (iksparser));
prs->s = s;
prs->user_data = user_data;
prs->tagHook = tagHook;
prs->cdataHook = cdataHook;
prs->deleteHook = deleteHook;
return prs;
}
ikstack *
iks_parser_stack (iksparser *prs)
{
return prs->s;
}
void *
iks_user_data (iksparser *prs)
{
return prs->user_data;
}
unsigned long
iks_nr_bytes (iksparser *prs)
{
return prs->nr_bytes;
}
unsigned long
iks_nr_lines (iksparser *prs)
{
return prs->nr_lines;
}
#define IS_WHITESPACE(x) ' ' == (x) || '\t' == (x) || '\r' == (x) || '\n' == (x)
#define NOT_WHITESPACE(x) ' ' != (x) && '\t' != (x) && '\r' != (x) && '\n' != (x)
static int
stack_init (iksparser *prs)
{
prs->stack = iks_malloc (128);
if (!prs->stack) return 0;
prs->stack_max = 128;
prs->stack_pos = 0;
return 1;
}
static int
stack_expand (iksparser *prs, int len)
{
size_t need;
off_t diff;
char *tmp;
need = len - (prs->stack_max - prs->stack_pos);
if (need < prs->stack_max) {
need = prs->stack_max * 2;
} else {
/* need x 1.2 for integer only archs like ARM */
need = prs->stack_max + ( (need * 6) / 5);
}
tmp = iks_malloc (need);
if (!tmp) return 0;
diff = tmp - prs->stack;
memcpy (tmp, prs->stack, prs->stack_max);
iks_free (prs->stack);
prs->stack = tmp;
prs->stack_max = need;
prs->tag_name += diff;
if (prs->attflag != 0) {
int i = 0;
while (i < (prs->attmax * 2)) {
if (prs->atts[i]) prs->atts[i] += diff;
i++;
}
}
return 1;
}
#define STACK_INIT \
if (NULL == prs->stack && 0 == stack_init (prs)) return IKS_NOMEM
#define STACK_PUSH_START (prs->stack + prs->stack_pos)
#define STACK_PUSH(buf,len) \
{ \
char *sbuf = (buf); \
size_t slen = (len); \
if (prs->stack_max - prs->stack_pos <= slen) { \
if (0 == stack_expand (prs, slen)) return IKS_NOMEM; \
} \
memcpy (prs->stack + prs->stack_pos, sbuf, slen); \
prs->stack_pos += slen; \
}
#define STACK_PUSH_END \
{ \
if (prs->stack_pos >= prs->stack_max) { \
if (0 == stack_expand (prs, 1)) return IKS_NOMEM; \
} \
prs->stack[prs->stack_pos] = '\0'; \
prs->stack_pos++; \
}
static enum ikserror
sax_core (iksparser *prs, char *buf, int len)
{
enum ikserror err;
int pos = 0, old = 0, re, stack_old = -1;
unsigned char c;
while (pos < len) {
re = 0;
c = buf[pos];
if (0 == c || 0xFE == c || 0xFF == c) return IKS_BADXML;
if (prs->uni_max) {
if ((c & 0xC0) != 0x80) return IKS_BADXML;
prs->uni_len++;
if (prs->uni_len == prs->uni_max) prs->uni_max = 0;
goto cont;
} else {
if (c & 0x80) {
if ((c & 0x60) == 0x40) {
prs->uni_max = 2;
} else if ((c & 0x70) == 0x60) {
prs->uni_max = 3;
} else if ((c & 0x78) == 0x70) {
prs->uni_max = 4;
} else if ((c & 0x7C) == 0x78) {
prs->uni_max = 5;
} else if ((c & 0x7E) == 0x7C) {
prs->uni_max = 6;
} else {
return IKS_BADXML;
}
/* if ((c & mask) == 0) return IKS_BADXML; I AM WRONG */
prs->uni_len = 1;
if (stack_old == -1
&& (prs->context == C_TAG
|| prs->context == C_ATTRIBUTE_1
|| prs->context == C_VALUE_APOS
|| prs->context == C_VALUE_QUOT)) stack_old = pos;
goto cont;
}
}
switch (prs->context) {
case C_CDATA:
if ('&' == c) {
if (old < pos && prs->cdataHook) {
err = prs->cdataHook (prs->user_data, &buf[old], pos - old);
if (IKS_OK != err) return err;
}
prs->context = C_ENTITY;
prs->entpos = 0;
break;
}
if ('<' == c) {
if (old < pos && prs->cdataHook) {
err = prs->cdataHook (prs->user_data, &buf[old], pos - old);
if (IKS_OK != err) return err;
}
STACK_INIT;
prs->tag_name = STACK_PUSH_START;
if (!prs->tag_name) return IKS_NOMEM;
prs->context = C_TAG_START;
}
break;
case C_TAG_START:
prs->context = C_TAG;
if ('/' == c) {
prs->tagtype = IKS_CLOSE;
break;
}
if ('?' == c) {
prs->context = C_PI;
break;
}
if ('!' == c) {
prs->context = C_MARKUP;
break;
}
prs->tagtype = IKS_OPEN;
stack_old = pos;
break;
case C_TAG:
if (IS_WHITESPACE(c)) {
if (IKS_CLOSE == prs->tagtype)
prs->oldcontext = C_TAG_END;
else
prs->oldcontext = C_ATTRIBUTE;
prs->context = C_WHITESPACE;
if (stack_old != -1) STACK_PUSH (buf + stack_old, pos - stack_old);
stack_old = -1;
STACK_PUSH_END;
break;
}
if ('/' == c) {
if (IKS_CLOSE == prs->tagtype) return IKS_BADXML;
prs->tagtype = IKS_SINGLE;
prs->context = C_TAG_END;
if (stack_old != -1) STACK_PUSH (buf + stack_old, pos - stack_old);
stack_old = -1;
STACK_PUSH_END;
break;
}
if ('>' == c) {
prs->context = C_TAG_END;
if (stack_old != -1) STACK_PUSH (buf + stack_old, pos - stack_old);
stack_old = -1;
STACK_PUSH_END;
re = 1;
break;
}
if (stack_old == -1) stack_old = pos;
break;
case C_TAG_END:
if (c != '>') return IKS_BADXML;
if (prs->tagHook) {
char **tmp;
if (prs->attcur == 0) tmp = NULL; else tmp = prs->atts;
err = prs->tagHook (prs->user_data, prs->tag_name, tmp, prs->tagtype);
if (IKS_OK != err) return err;
}
prs->stack_pos = 0;
stack_old = -1;
prs->attcur = 0;
prs->attflag = 0;
prs->context = C_CDATA;
old = pos + 1;
break;
case C_ATTRIBUTE:
if ('/' == c) {
prs->tagtype = IKS_SINGLE;
prs->context = C_TAG_END;
break;
}
if ('>' == c) {
prs->context = C_TAG_END;
re = 1;
break;
}
if (!prs->atts) {
prs->attmax = 12;
prs->atts = iks_malloc (sizeof(char *) * 2 * 12);
if (!prs->atts) return IKS_NOMEM;
memset (prs->atts, 0, sizeof(char *) * 2 * 12);
prs->attcur = 0;
} else {
if (prs->attcur >= (prs->attmax * 2)) {
void *tmp;
prs->attmax += 12;
tmp = iks_malloc (sizeof(char *) * 2 * prs->attmax);
if (!tmp) return IKS_NOMEM;
memset (tmp, 0, sizeof(char *) * 2 * prs->attmax);
memcpy (tmp, prs->atts, sizeof(char *) * prs->attcur);
free (prs->atts);
prs->atts = tmp;
}
}
prs->attflag = 1;
prs->atts[prs->attcur] = STACK_PUSH_START;
stack_old = pos;
prs->context = C_ATTRIBUTE_1;
break;
case C_ATTRIBUTE_1:
if ('=' == c) {
if (stack_old != -1) STACK_PUSH (buf + stack_old, pos - stack_old);
stack_old = -1;
STACK_PUSH_END;
prs->context = C_VALUE;
break;
}
if (stack_old == -1) stack_old = pos;
break;
case C_ATTRIBUTE_2:
if ('/' == c) {
prs->tagtype = IKS_SINGLE;
prs->atts[prs->attcur] = NULL;
prs->context = C_TAG_END;
break;
}
if ('>' == c) {
prs->atts[prs->attcur] = NULL;
prs->context = C_TAG_END;
re = 1;
break;
}
prs->context = C_ATTRIBUTE;
re = 1;
break;
case C_VALUE:
prs->atts[prs->attcur + 1] = STACK_PUSH_START;
if ('\'' == c) {
prs->context = C_VALUE_APOS;
break;
}
if ('"' == c) {
prs->context = C_VALUE_QUOT;
break;
}
return IKS_BADXML;
case C_VALUE_APOS:
if ('\'' == c) {
if (stack_old != -1) STACK_PUSH (buf + stack_old, pos - stack_old);
stack_old = -1;
STACK_PUSH_END;
prs->oldcontext = C_ATTRIBUTE_2;
prs->context = C_WHITESPACE;
prs->attcur += 2;
}
if (stack_old == -1) stack_old = pos;
break;
case C_VALUE_QUOT:
if ('"' == c) {
if (stack_old != -1) STACK_PUSH (buf + stack_old, pos - stack_old);
stack_old = -1;
STACK_PUSH_END;
prs->oldcontext = C_ATTRIBUTE_2;
prs->context = C_WHITESPACE;
prs->attcur += 2;
}
if (stack_old == -1) stack_old = pos;
break;
case C_WHITESPACE:
if (NOT_WHITESPACE(c)) {
prs->context = prs->oldcontext;
re = 1;
}
break;
case C_ENTITY:
if (';' == c) {
char hede[2];
char t = '?';
prs->entity[prs->entpos] = '\0';
if (strcmp(prs->entity, "amp") == 0)
t = '&';
else if (strcmp(prs->entity, "quot") == 0)
t = '"';
else if (strcmp(prs->entity, "apos") == 0)
t = '\'';
else if (strcmp(prs->entity, "lt") == 0)
t = '<';
else if (strcmp(prs->entity, "gt") == 0)
t = '>';
old = pos + 1;
hede[0] = t;
if (prs->cdataHook) {
err = prs->cdataHook (prs->user_data, &hede[0], 1);
if (IKS_OK != err) return err;
}
prs->context = C_CDATA;
} else {
prs->entity[prs->entpos++] = buf[pos];
if (prs->entpos > 7) return IKS_BADXML;
}
break;
case C_COMMENT:
if ('-' != c) return IKS_BADXML;
prs->context = C_COMMENT_1;
break;
case C_COMMENT_1:
if ('-' == c) prs->context = C_COMMENT_2;
break;
case C_COMMENT_2:
if ('-' == c)
prs->context = C_COMMENT_3;
else
prs->context = C_COMMENT_1;
break;
case C_COMMENT_3:
if ('>' != c) return IKS_BADXML;
prs->context = C_CDATA;
old = pos + 1;
break;
case C_MARKUP:
if ('[' == c) {
prs->context = C_SECT;
break;
}
if ('-' == c) {
prs->context = C_COMMENT;
break;
}
prs->context = C_MARKUP_1;
case C_MARKUP_1:
if ('>' == c) {
old = pos + 1;
prs->context = C_CDATA;
}
break;
case C_SECT:
if ('C' == c) {
prs->context = C_SECT_CDATA;
break;
}
return IKS_BADXML;
case C_SECT_CDATA:
if ('D' != c) return IKS_BADXML;
prs->context = C_SECT_CDATA_1;
break;
case C_SECT_CDATA_1:
if ('A' != c) return IKS_BADXML;
prs->context = C_SECT_CDATA_2;
break;
case C_SECT_CDATA_2:
if ('T' != c) return IKS_BADXML;
prs->context = C_SECT_CDATA_3;
break;
case C_SECT_CDATA_3:
if ('A' != c) return IKS_BADXML;
prs->context = C_SECT_CDATA_4;
break;
case C_SECT_CDATA_4:
if ('[' != c) return IKS_BADXML;
old = pos + 1;
prs->context = C_SECT_CDATA_C;
break;
case C_SECT_CDATA_C:
if (']' == c) {
prs->context = C_SECT_CDATA_E;
if (prs->cdataHook && old < pos) {
err = prs->cdataHook (prs->user_data, &buf[old], pos - old);
if (IKS_OK != err) return err;
}
}
break;
case C_SECT_CDATA_E:
if (']' == c) {
prs->context = C_SECT_CDATA_E2;
} else {
if (prs->cdataHook) {
err = prs->cdataHook (prs->user_data, "]", 1);
if (IKS_OK != err) return err;
}
old = pos;
prs->context = C_SECT_CDATA_C;
}
break;
case C_SECT_CDATA_E2:
if ('>' == c) {
old = pos + 1;
prs->context = C_CDATA;
} else if (']' == c) {
/* ]]] scenario */
if (prs->cdataHook) {
err = prs->cdataHook (prs->user_data, "]", 1);
if (IKS_OK != err) return err;
}
old = pos;
} else {
if (prs->cdataHook) {
err = prs->cdataHook (prs->user_data, "]]", 2);
if (IKS_OK != err) return err;
}
old = pos;
prs->context = C_SECT_CDATA_C;
}
break;
case C_PI:
old = pos + 1;
if ('>' == c) prs->context = C_CDATA;
break;
}
cont:
if (0 == re) {
pos++;
prs->nr_bytes++;
if ('\n' == c) prs->nr_lines++;
}
}
if (stack_old != -1)
STACK_PUSH (buf + stack_old, pos - stack_old);
err = IKS_OK;
if (prs->cdataHook && (prs->context == C_CDATA || prs->context == C_SECT_CDATA_C) && old < pos)
err = prs->cdataHook (prs->user_data, &buf[old], pos - old);
return err;
}
int
iks_parse (iksparser *prs, const char *data, size_t len, int finish)
{
if (!data) return IKS_OK;
if (len == 0) len = strlen (data);
return sax_core (prs, (char *) data, len);
}
void
iks_parser_reset (iksparser *prs)
{
if (prs->deleteHook) prs->deleteHook (prs->user_data);
prs->stack_pos = 0;
prs->context = 0;
prs->oldcontext = 0;
prs->tagtype = 0;
prs->attcur = 0;
prs->attflag = 0;
prs->valflag = 0;
prs->entpos = 0;
prs->nr_bytes = 0;
prs->nr_lines = 0;
prs->uni_max = 0;
prs->uni_len = 0;
}
void
iks_parser_delete (iksparser *prs)
{
if (prs->deleteHook) prs->deleteHook (prs->user_data);
if (prs->stack) iks_free (prs->stack);
if (prs->atts) iks_free (prs->atts);
if (prs->s) iks_stack_delete (&prs->s); else iks_free (prs);
}

View File

@@ -1,152 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
static void sha_buffer (iksha *sha, const unsigned char *data, int len);
static void sha_calculate (iksha *sha);
struct iksha_struct {
unsigned int hash[5];
unsigned int buf[80];
int blen;
unsigned int lenhi, lenlo;
};
iksha *
iks_sha_new (void)
{
iksha *sha;
sha = iks_malloc (sizeof (iksha));
if (!sha) return NULL;
iks_sha_reset (sha);
return sha;
}
void
iks_sha_reset (iksha *sha)
{
memset (sha, 0, sizeof (iksha));
sha->hash[0] = 0x67452301;
sha->hash[1] = 0xefcdab89;
sha->hash[2] = 0x98badcfe;
sha->hash[3] = 0x10325476;
sha->hash[4] = 0xc3d2e1f0;
}
void
iks_sha_hash (iksha *sha, const unsigned char *data, size_t len, int finish)
{
unsigned char pad[8];
unsigned char padc;
if (data && len != 0) sha_buffer (sha, data, len);
if (!finish) return;
pad[0] = (unsigned char)((sha->lenhi >> 24) & 0xff);
pad[1] = (unsigned char)((sha->lenhi >> 16) & 0xff);
pad[2] = (unsigned char)((sha->lenhi >> 8) & 0xff);
pad[3] = (unsigned char)(sha->lenhi & 0xff);
pad[4] = (unsigned char)((sha->lenlo >> 24) & 0xff);
pad[5] = (unsigned char)((sha->lenlo >> 16) & 0xff);
pad[6] = (unsigned char)((sha->lenlo >> 8) & 0xff);
pad[7] = (unsigned char)(sha->lenlo & 255);
padc = 0x80;
sha_buffer (sha, &padc, 1);
padc = 0x00;
while (sha->blen != 56)
sha_buffer (sha, &padc, 1);
sha_buffer (sha, pad, 8);
}
void
iks_sha_print (iksha *sha, char *hash)
{
int i;
for (i=0; i<5; i++)
{
sprintf (hash, "%08x", sha->hash[i]);
hash += 8;
}
}
void
iks_sha_delete (iksha *sha)
{
iks_free (sha);
}
void
iks_sha (const char *data, char *hash)
{
iksha *sha;
sha = iks_sha_new ();
iks_sha_hash (sha, (const unsigned char*)data, strlen (data), 1);
iks_sha_print (sha, hash);
iks_free (sha);
}
static void
sha_buffer (iksha *sha, const unsigned char *data, int len)
{
int i;
for (i=0; i<len; i++) {
sha->buf[sha->blen / 4] <<= 8;
sha->buf[sha->blen / 4] |= (unsigned int)data[i];
if ((++sha->blen) % 64 == 0) {
sha_calculate (sha);
sha->blen = 0;
}
sha->lenlo += 8;
sha->lenhi += (sha->lenlo < 8);
}
}
#define SRL(x,y) (((x) << (y)) | ((x) >> (32-(y))))
#define SHA(a,b,f,c) \
for (i= (a) ; i<= (b) ; i++) { \
TMP = SRL(A,5) + ( (f) ) + E + sha->buf[i] + (c) ; \
E = D; \
D = C; \
C = SRL(B,30); \
B = A; \
A = TMP; \
}
static void
sha_calculate (iksha *sha)
{
int i;
unsigned int A, B, C, D, E, TMP;
for (i=16; i<80; i++)
sha->buf[i] = SRL (sha->buf[i-3] ^ sha->buf[i-8] ^ sha->buf[i-14] ^ sha->buf[i-16], 1);
A = sha->hash[0];
B = sha->hash[1];
C = sha->hash[2];
D = sha->hash[3];
E = sha->hash[4];
SHA (0, 19, ((C^D)&B)^D, 0x5a827999);
SHA (20, 39, B^C^D, 0x6ed9eba1);
SHA (40, 59, (B&C)|(D&(B|C)), 0x8f1bbcdc);
SHA (60, 79, B^C^D, 0xca62c1d6);
sha->hash[0] += A;
sha->hash[1] += B;
sha->hash[2] += C;
sha->hash[3] += D;
sha->hash[4] += E;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,180 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
/***** malloc wrapper *****/
static void *(*my_malloc_func)(size_t size);
static void (*my_free_func)(void *ptr);
void *
iks_malloc (size_t size)
{
if (my_malloc_func)
return my_malloc_func (size);
else
return malloc (size);
}
void
iks_real_free (void *ptr)
{
if (my_free_func)
my_free_func (ptr);
else
free (ptr);
}
void
iks_set_mem_funcs (void *(*malloc_func)(size_t size), void (*free_func)(void *ptr))
{
my_malloc_func = malloc_func;
my_free_func = free_func;
}
/***** NULL-safe Functions *****/
char *
iks_strdup (const char *src)
{
if (src) return strdup(src);
return NULL;
}
char *
iks_strcat (char *dest, const char *src)
{
size_t len;
if (!src) return dest;
len = strlen (src);
memcpy (dest, src, len);
dest[len] = '\0';
return dest + len;
}
int
iks_strcmp (const char *a, const char *b)
{
if (!a || !b) return -1;
return strcmp (a, b);
}
int
iks_strcasecmp (const char *a, const char *b)
{
if (!a || !b) return -1;
return strcasecmp (a, b);
}
int
iks_strncmp (const char *a, const char *b, size_t n)
{
if (!a || !b) return -1;
return strncmp (a, b, n);
}
int
iks_strncasecmp (const char *a, const char *b, size_t n)
{
if (!a || !b) return -1;
return strncasecmp (a, b, n);
}
size_t
iks_strlen (const char *src)
{
if (!src) return 0;
return strlen (src);
}
/***** XML Escaping *****/
char *
iks_escape (ikstack *s, char *src, size_t len)
{
char *ret;
int i, j, nlen;
if (!src || !s) return NULL;
if (len == -1) len = strlen (src);
nlen = len;
for (i=0; i<len; i++) {
switch (src[i]) {
case '&': nlen += 4; break;
case '<': nlen += 3; break;
case '>': nlen += 3; break;
case '\'': nlen += 5; break;
case '"': nlen += 5; break;
}
}
if (len == nlen) return src;
ret = iks_stack_alloc (s, nlen + 1);
if (!ret) return NULL;
for (i=j=0; i<len; i++) {
switch (src[i]) {
case '&': memcpy (&ret[j], "&amp;", 5); j += 5; break;
case '\'': memcpy (&ret[j], "&apos;", 6); j += 6; break;
case '"': memcpy (&ret[j], "&quot;", 6); j += 6; break;
case '<': memcpy (&ret[j], "&lt;", 4); j += 4; break;
case '>': memcpy (&ret[j], "&gt;", 4); j += 4; break;
default: ret[j++] = src[i];
}
}
ret[j] = '\0';
return ret;
}
char *
iks_unescape (ikstack *s, char *src, size_t len)
{
int i,j;
char *ret;
if (!s || !src) return NULL;
if (!strchr (src, '&')) return src;
if (len == -1) len = strlen (src);
ret = iks_stack_alloc (s, len + 1);
if (!ret) return NULL;
for (i=j=0; i<len; i++) {
if (src[i] == '&') {
i++;
if (strncmp (&src[i], "amp;", 4) == 0) {
ret[j] = '&';
i += 3;
} else if (strncmp (&src[i], "quot;", 5) == 0) {
ret[j] = '"';
i += 4;
} else if (strncmp (&src[i], "apos;", 5) == 0) {
ret[j] = '\'';
i += 4;
} else if (strncmp (&src[i], "lt;", 3) == 0) {
ret[j] = '<';
i += 2;
} else if (strncmp (&src[i], "gt;", 3) == 0) {
ret[j] = '>';
i += 2;
} else {
ret[j] = src[--i];
}
} else {
ret[j] = src[i];
}
j++;
}
ret[j] = '\0';
return ret;
}

View File

@@ -1,33 +0,0 @@
##
## Process this file with automake to produce Makefile.in
##
AM_CPPFLAGS = -I$(top_srcdir)/include
TESTS = tst-ikstack tst-iks tst-sax tst-dom tst-sha tst-md5 tst-filter tst-jid
noinst_PROGRAMS = tst-ikstack tst-iks tst-sax tst-dom tst-sha tst-md5 tst-filter tst-jid
tst_ikstack_LDADD = $(top_builddir)/src/libiksemel.la
tst_ikstack_SOURCES = tst-ikstack.c
tst_iks_LDADD = $(top_builddir)/src/libiksemel.la
tst_iks_SOURCES = tst-iks.c
tst_sax_LDADD = $(top_builddir)/src/libiksemel.la
tst_sax_SOURCES = tst-sax.c
tst_dom_LDADD = $(top_builddir)/src/libiksemel.la
tst_dom_SOURCES = tst-dom.c
tst_sha_LDADD = $(top_builddir)/src/libiksemel.la
tst_sha_SOURCES = tst-sha.c
tst_md5_LDADD = $(top_builddir)/src/libiksemel.la
tst_md5_SOURCES = tst-md5.c
tst_filter_LDADD = $(top_builddir)/src/libiksemel.la
tst_filter_SOURCES = tst-filter.c
tst_jid_LDADD = $(top_builddir)/src/libiksemel.la
tst_jid_SOURCES = tst-jid.c

View File

@@ -1,164 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "iksemel.h"
iks *my_x;
int nr_tests;
#define PR_TEST printf ("DOM test %d:\n", nr_tests)
void
document (char *xml)
{
enum ikserror err;
iksparser *p;
nr_tests++;
if (my_x) iks_delete (my_x);
p = iks_dom_new (&my_x);
err = iks_parse (p, xml, 0, 1);
switch (err) {
case IKS_OK:
break;
case IKS_NOMEM:
PR_TEST;
puts ("Not enough memory.");
exit (1);
case IKS_BADXML:
PR_TEST;
printf ("Invalid xml at byte %ld in\n[%s]\n", iks_nr_bytes (p), xml);
exit (1);
case IKS_HOOK:
PR_TEST;
puts ("Hook.");
}
iks_parser_delete (p);
}
void
tag (char *name, ...)
{
iks *x;
va_list ap;
x = my_x;
va_start (ap, name);
while (1) {
char *name = iks_name (x);
char *tmp = va_arg (ap, char*);
if (NULL == tmp) break;
x = iks_find (x, tmp);
if (!x) {
PR_TEST;
printf ("Tag <%s> is not a child of tag <%s>\n", tmp, name);
exit (1);
}
}
if (!x || NULL == iks_find (x, name)) {
PR_TEST;
printf ("Tag <%s> is not a child of tag <%s>\n", name, iks_name (x));
exit (1);
}
va_end (ap);
}
void
cdata (char *data, ...)
{
iks *x;
va_list ap;
x = my_x;
va_start (ap, data);
while (1) {
char *name = iks_name (x);
char *tmp = va_arg (ap, char*);
if (NULL == tmp) break;
x = iks_find (x, tmp);
if (!x) {
PR_TEST;
printf ("Tag <%s> is not a child of tag <%s>\n", tmp, name);
exit (1);
}
}
if (iks_strcmp ( iks_cdata (iks_child (x)), data) != 0) {
PR_TEST;
printf ("CDATA [%s] not found.\n", data);
exit (1);
}
va_end (ap);
}
void
attrib (char *att, char *val, ...)
{
iks *x;
va_list ap;
x = my_x;
va_start (ap, val);
while (1) {
char *name = iks_name (x);
char *tmp = va_arg (ap, char*);
if (NULL == tmp) break;
x = iks_find (x, tmp);
if (!x) {
PR_TEST;
printf ("Tag <%s> is not a child of tag <%s>\n", tmp, name);
exit (1);
}
}
if (iks_strcmp (val, iks_find_attrib (x, att)) != 0) {
PR_TEST;
printf ("Attribute '%s' not found.\n", att);
exit (1);
}
va_end (ap);
}
void
string (char *xml)
{
char *tmp;
tmp = iks_string (iks_stack (my_x), my_x);
if (iks_strcmp (tmp, xml) != 0) {
PR_TEST;
printf ("Result: %s\n", tmp);
printf ("Expected: %s\n", xml);
exit (1);
}
}
static char buf[] =
"<presence id='JCOM_11' to='lala@j.org' type='available'><status>"
"&quot; &lt;online&amp;dangerous&gt; &quot;</status>meow<a><b c='d'/>"
"</a><test/></presence>";
int main (int argc, char *argv[])
{
document ("<atag></atag>");
string ("<atag/>");
document ("<test>lala<b>bold</b>blablabla<a><c/></a></test>");
tag ("b", 0);
tag ("c", "a", 0);
string ("<test>lala<b>bold</b>blablabla<a><c/></a></test>");
document (buf);
cdata ("\" <online&dangerous> \"", "status", 0);
attrib ("c", "d", "a", "b", 0);
tag ("test", 0);
string (buf);
return 0;
}

View File

@@ -1,260 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <assert.h>
#include "iksemel.h"
struct {
iksfilter *f;
char *xml;
int nr;
iksFilterHook *hook[20];
int nr_hook;
iksFilterHook *call[20];
int nr_call;
} tester;
void
document (char *xml)
{
tester.nr++;
tester.xml = xml;
tester.nr_hook = 0;
}
void
hook (iksFilterHook *hk)
{
tester.hook[tester.nr_hook++] = hk;
}
void
debug (void)
{
int i;
printf ("Filter test %d:\n", tester.nr);
if (tester.nr_hook) {
puts ("Expected hook order:");
for (i = 0; i < tester.nr_hook; i++) {
printf (" ");
tester.hook[i] (NULL, NULL);
}
} else {
puts("No hooks expected.");
}
if (tester.nr_call) {
puts ("Hook order:");
for (i = 0; i < tester.nr_call; i++) {
printf (" ");
tester.call[i] (NULL, NULL);
}
} else {
puts("No hooks called.");
}
exit (1);
}
void
test (void)
{
iksparser *prs;
iks *x;
int i;
tester.nr_call = 0;
prs = iks_dom_new (&x);
iks_parse (prs, tester.xml, strlen (tester.xml), 1);
iks_parser_delete (prs);
iks_filter_packet (tester.f, iks_packet (x));
iks_delete (x);
if (tester.nr_call != tester.nr_hook) debug ();
for (i = 0; i < tester.nr_hook; i++) {
if (tester.call[i] != tester.hook[i]) debug ();
}
}
#define DEBUG(x) if (NULL == pak) { puts ( (x) ); return IKS_FILTER_PASS; }
int
on_msg (void *user_data, ikspak *pak)
{
DEBUG ("on_msg");
assert (IKS_PAK_MESSAGE == pak->type);
tester.call[tester.nr_call++] = on_msg;
return IKS_FILTER_PASS;
}
int
on_iq (void *user_data, ikspak *pak)
{
DEBUG ("on_iq");
assert (IKS_PAK_IQ == pak->type);
tester.call[tester.nr_call++] = on_iq;
return IKS_FILTER_PASS;
}
int
on_iq_result (void *user_data, ikspak *pak)
{
DEBUG ("on_iq_result");
assert (IKS_PAK_IQ == pak->type);
assert (IKS_TYPE_RESULT == pak->subtype);
tester.call[tester.nr_call++] = on_iq_result;
return IKS_FILTER_PASS;
}
int
on_iq_result_id_auth (void *user_data, ikspak *pak)
{
DEBUG ("on_iq_result_id_auth");
assert (IKS_PAK_IQ == pak->type);
assert (IKS_TYPE_RESULT == pak->subtype);
assert (iks_strcmp (pak->id, "auth") == 0);
tester.call[tester.nr_call++] = on_iq_result_id_auth;
return IKS_FILTER_PASS;
}
int
on_id_auth (void *user_data, ikspak *pak)
{
DEBUG ("on_id_auth");
assert (iks_strcmp (pak->id, "auth") == 0);
tester.call[tester.nr_call++] = on_id_auth;
return IKS_FILTER_PASS;
}
int
on_from_patrician (void *user_data, ikspak *pak)
{
DEBUG ("on_from_patrician");
assert (iks_strcmp (pak->from->partial, "patrician@morpork.gov") == 0);
tester.call[tester.nr_call++] = on_from_patrician;
return IKS_FILTER_PASS;
}
int
on_msg_chat_from_patrician (void *user_data, ikspak *pak)
{
DEBUG ("on_msg_chat_from_patrician");
assert (pak->type == IKS_PAK_MESSAGE);
assert (pak->subtype == IKS_TYPE_CHAT);
assert (iks_strcmp (pak->from->partial, "patrician@morpork.gov") == 0);
tester.call[tester.nr_call++] = on_msg_chat_from_patrician;
return IKS_FILTER_PASS;
}
int
on_id_albatros (void *user_data, ikspak *pak)
{
DEBUG ("on_id_albatros");
assert (iks_strcmp (pak->id, "albatros") == 0);
tester.call[tester.nr_call++] = on_id_albatros;
return IKS_FILTER_PASS;
}
int
on_from_dean (void *user_data, ikspak *pak)
{
DEBUG ("on_from_dean");
assert (iks_strcmp (pak->from->partial, "dean@unseen.edu") == 0);
tester.call[tester.nr_call++] = on_from_dean;
return IKS_FILTER_PASS;
}
int
main (int argc, char *argv[])
{
tester.f = iks_filter_new ();
iks_filter_add_rule (tester.f, on_msg, 0,
IKS_RULE_TYPE, IKS_PAK_MESSAGE,
IKS_RULE_DONE);
iks_filter_add_rule (tester.f, on_iq, 0,
IKS_RULE_TYPE, IKS_PAK_IQ,
IKS_RULE_DONE);
iks_filter_add_rule (tester.f, on_iq_result, 0,
IKS_RULE_TYPE, IKS_PAK_IQ,
IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,
IKS_RULE_DONE);
iks_filter_add_rule (tester.f, on_iq_result_id_auth, 0,
IKS_RULE_TYPE, IKS_PAK_IQ,
IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,
IKS_RULE_ID, "auth",
IKS_RULE_DONE);
iks_filter_add_rule (tester.f, on_id_auth, 0,
IKS_RULE_ID, "auth",
IKS_RULE_DONE);
iks_filter_add_rule (tester.f, on_from_dean, 0,
IKS_RULE_FROM_PARTIAL, "dean@unseen.edu",
IKS_RULE_DONE);
iks_filter_add_rule (tester.f, on_from_patrician, 0,
IKS_RULE_FROM_PARTIAL, "patrician@morpork.gov",
IKS_RULE_DONE);
iks_filter_add_rule (tester.f, on_msg_chat_from_patrician, 0,
IKS_RULE_TYPE, IKS_PAK_MESSAGE,
IKS_RULE_SUBTYPE, IKS_TYPE_CHAT,
IKS_RULE_FROM_PARTIAL, "patrician@morpork.gov",
IKS_RULE_DONE);
iks_filter_add_rule (tester.f, on_id_albatros, 0,
IKS_RULE_ID, "albatros",
IKS_RULE_DONE);
document ("<message from='dean@unseen.edu' id='1234'><body>Born to Rune.</body></message>");
hook (on_from_dean);
hook (on_msg);
test ();
document ("<presence from='librarian@unseen.edu' show='away'/>");
test ();
document ("<message from='rincewind@unseen.edu' type='chat' id='albatros'><body>yaaargh</body></message>");
hook (on_id_albatros);
hook (on_msg);
test ();
document ("<iq type='get' from='rincewind@unseen.edu'><query xmlns='jabber:time'/></iq>");
hook (on_iq);
test ();
document ("<message from='patrician@morpork.gov'><body>so you admit it?</body></message>");
hook (on_from_patrician);
hook (on_msg);
test ();
document ("<iq type='result' from='rincewind@unseen.edu'><query xmlns='jabber:version'><name>cabbar</name><version>1.0</version></query></iq>");
hook (on_iq_result);
hook (on_iq);
test ();
document ("<presence from='dean@unseen.edu/psi' type='unavailable'/>");
hook (on_from_dean);
test ();
document ("<message from='patrician@morpork.gov' type='chat' id='albatros'><body>hmm</body></message>");
hook (on_id_albatros);
hook (on_msg_chat_from_patrician);
hook (on_from_patrician);
hook (on_msg);
test ();
document ("<iq type='result' id='auth'/>");
hook (on_iq_result_id_auth);
hook (on_id_auth);
hook (on_iq_result);
hook (on_iq);
test ();
iks_filter_delete (tester.f);
return 0;
}

View File

@@ -1,77 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include "iksemel.h"
int main (int argc, char *argv[])
{
static char xml[] =
"<iq type='result' to='ydobon@jabber.org'><query xmlns='jabber:iq:version'>"
"<name>TestClient</name><os>SuxOS 2000</os><version><stable solidity='rock'/>"
"1.2.0 patchlevel 2</version></query></iq>";
static char xml2[] =
"<Ni><C/>lala<br/><A/>Hello World<B/></Ni>";
iks *x, *y, *z;
char *t;
setlocale (LC_ALL, "");
x = iks_new ("iq");
iks_insert_attrib (x, "type", "resultypo");
iks_insert_attrib (x, "type", "result");
iks_insert_attrib (x, "to", "ydobon@jabber.org");
y = iks_new_within ("query", iks_stack (x));
iks_insert_cdata (iks_insert (y, "name"), "TestClient", 10);
iks_insert_cdata (iks_insert (y, "os"), "SuxOS", 0);
z = iks_insert (y, "version");
iks_insert (z, "stable");
iks_insert_cdata (z, "1.2", 3);
iks_insert_cdata (z, ".0 patchlevel 2", 0);
iks_insert_node (x, y);
z = iks_find (y, "os");
iks_insert_attrib (z, "error", "yes");
iks_insert_attrib (z, "error", NULL);
iks_insert_cdata (z, " 2000", 5);
z = iks_next (z);
z = iks_find (z, "stable");
iks_insert_attrib (z, "solidity", "rock");
z = iks_parent (iks_parent (z));
iks_insert_attrib (z, "xmlns", "jabber:iq:version");
t = iks_string (iks_stack (x), x);
if(!t || strcmp(t, xml) != 0) {
printf("Result: %s\n", t);
printf("Expected: %s\n", xml);
return 1;
}
iks_delete(x);
x = iks_new ("Ni");
y = iks_insert (x, "br");
z = iks_prepend_cdata (y, "lala", 4);
iks_prepend (z, "C");
z = iks_insert_cdata (x, "Hello", 5);
y = iks_append (z, "B");
iks_prepend (z, "A");
iks_append_cdata (z, " ", 1);
iks_prepend_cdata (y, "World", 5);
t = iks_string (iks_stack (x), x);
if(!t || strcmp(t, xml2) != 0) {
printf("Result: %s\n", t);
printf("Expected: %s\n", xml2);
return 1;
}
iks_delete(x);
return 0;
}

View File

@@ -1,54 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2004 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "iksemel.h"
struct align_test { char a; double b; };
#define DEFAULT_ALIGNMENT ((size_t) ((char *) &((struct align_test *) 0)->b - (char *) 0))
#define ALIGN_MASK ( DEFAULT_ALIGNMENT - 1 )
const char buf[] = "1234567890abcdefghijklmnopqrstuv";
void
test_stack (int cs)
{
ikstack *s;
char *mem, *old;
int i;
s = iks_stack_new (cs, cs);
old = NULL;
for (i = 0; i < strlen (buf); i++) {
iks_stack_strdup (s, buf, i);
mem = iks_stack_alloc (s, i);
if (((unsigned long) mem) & ALIGN_MASK) {
printf ("ikstack bug, addr %p should be a multiply of %d\n",
mem, DEFAULT_ALIGNMENT);
exit (1);
}
memset (mem, 'x', i);
old = iks_stack_strcat (s, old, 0, buf + i, 1);
}
if (old && strcmp (old, buf) != 0) {
printf ("ikstack strcat bug:\nExpected: %s\n Result: %s\n", buf, old);
exit (1);
}
iks_stack_delete (&s);
}
int main (int argc, char *argv[])
{
test_stack (0);
test_stack (16);
test_stack (237);
test_stack (1024);
return 0;
}

View File

@@ -1,63 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include "iksemel.h"
ikstack *my_stack;
void
print_id (iksid *id)
{
printf (" Full: [%s]\n Partial: [%s]\n User: [%s]\n Server: [%s]\n Resource: [%s]\n",
id->full, id->partial, id->user, id->server, id->resource);
}
#define BUG(x) { print_id ( (x) ); exit (1); }
void
test_id (char *id, char *partial, char *user, char *server, char *resource)
{
iksid *a;
a = iks_id_new (my_stack, id);
if ((a->partial || partial) && iks_strcmp (a->partial, partial) != 0) BUG(a);
if ((a->user || user) && iks_strcmp (a->user, user) != 0) BUG(a);
if ((a->server || server) && iks_strcmp (a->server, server) != 0) BUG(a);
if ((a->resource || resource) && iks_strcmp (a->resource, resource) != 0) BUG(a);
}
void
test_cmp (char *stra, char *strb, int parts, int diff)
{
iksid *a, *b;
a = iks_id_new (my_stack, stra);
b = iks_id_new (my_stack, strb);
if (diff != iks_id_cmp (a, b, parts)) exit (1);
}
int main (int argc, char *argv[])
{
my_stack = iks_stack_new (1024, 1024);
test_id ("jabber:madcat@jabber.org/cabbar", "madcat@jabber.org", "madcat", "jabber.org", "cabbar");
test_id ("bob@silent.org", "bob@silent.org", "bob", "silent.org", NULL);
test_cmp ("dante@jabber.org/hell", "dante@jabber.org/heaven", IKS_ID_PARTIAL, 0);
test_cmp ("madcat@jabber.org/cabbar", "madcat@jabber.org/jabberx", IKS_ID_FULL, IKS_ID_RESOURCE);
test_cmp ("dean@unseen.edu/pda", "librarian@unseen.edu/jabberx", IKS_ID_FULL, IKS_ID_USER | IKS_ID_RESOURCE);
test_cmp ("patrician@morpork.gov/gabber", "cohen@guild.org/gsm", IKS_ID_FULL, IKS_ID_FULL);
test_cmp ("peter@family.com", "peter@family.com/clam", IKS_ID_PARTIAL, 0);
iks_stack_delete (&my_stack);
return 0;
}

View File

@@ -1,38 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2004 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "iksemel.h"
int main (int argc, char *argv[])
{
struct lala {
char *str;
char *hash;
} known_hashes[] = {
{ "abc", "900150983cd24fb0d6963f7d28e17f72" },
{ "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
"57edf4a22be3c955ac49da2e2107b67a" },
{ NULL, NULL }
};
int i = 0;
char buf[33];
while (known_hashes[i].str) {
iks_md5 (known_hashes[i].str, buf);
if (strcmp (buf, known_hashes[i].hash) != 0) {
printf("MD5 hash of \"%s\"\n", known_hashes[i].str);
printf(" Result: %s\n", buf);
printf(" Expected: %s\n", known_hashes[i].hash);
return 1;
}
i++;
}
return 0;
}

View File

@@ -1,384 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "iksemel.h"
struct element_s {
struct element_s *next;
enum ikstype type;
enum ikstagtype tag;
char *name;
int nr_atts;
char *atts[10];
char *vals[10];
char *cdata;
int len;
};
struct {
char *doc;
int len;
struct element_s *elements;
struct element_s *last_element;
struct element_s *cur;
int nr_tests;
int nr_cur;
int blocksize;
} tester;
void
document (char *xml)
{
if (tester.elements) {
struct element_s *tmp;
for (; tester.elements; tester.elements = tmp) {
tmp = tester.elements->next;
free (tester.elements);
}
}
tester.doc = xml;
tester.len = strlen (xml);
tester.elements = NULL;
tester.last_element = NULL;
tester.nr_tests++;
}
void
element (enum ikstype type, ...)
{
struct element_s *el;
va_list ap;
char *tmp;
el = malloc (sizeof (struct element_s));
memset (el, 0, sizeof (struct element_s));
el->type = type;
va_start (ap, type);
switch (type) {
case IKS_TAG:
el->tag = va_arg (ap, int);
el->name = va_arg (ap, char*);
if (IKS_CLOSE == el->tag) break;
while (1) {
tmp = va_arg (ap, char*);
if (tmp) {
el->atts[el->nr_atts] = tmp;
el->vals[el->nr_atts] = va_arg (ap, char*);
el->nr_atts++;
} else {
break;
}
}
break;
case IKS_CDATA:
tmp = va_arg (ap, char*);
el->cdata = tmp;
el->len = strlen (tmp);
break;
case IKS_NONE:
case IKS_ATTRIBUTE:
puts ("invalid element() call");
exit (1);
}
va_end (ap);
if (NULL == tester.elements) tester.elements = el;
if (tester.last_element) tester.last_element->next = el;
tester.last_element = el;
}
#define PRINT_TEST printf ("Sax test %d, blocksize %d, element %d:\n", tester.nr_tests, tester.blocksize, tester.nr_cur)
#define NEXT_ELEM { tester.cur = tester.cur->next; tester.nr_cur++; }
void
debug_tag (enum ikstagtype type, char *name, char **atts)
{
int i;
PRINT_TEST;
if (tester.cur && tester.cur->type == IKS_TAG) {
switch (tester.cur->tag) {
case IKS_OPEN:
printf (" Expecting tag <%s>\n", tester.cur->name);
break;
case IKS_CLOSE:
printf (" Expecting tag </%s>\n", tester.cur->name);
break;
case IKS_SINGLE:
printf (" Expecting tag <%s/>\n", tester.cur->name);
break;
}
for (i = 0; i < tester.cur->nr_atts; i++) {
printf (" %s='%s'\n", tester.cur->atts[i], tester.cur->vals[i]);
}
} else {
printf (" Not expecting a tag here.\n");
}
switch (type) {
case IKS_OPEN:
printf (" Got tag <%s>\n", name);
break;
case IKS_CLOSE:
printf (" Got tag </%s>\n", name);
break;
case IKS_SINGLE:
printf (" Got tag <%s/>\n", name);
break;
}
i = 0;
while (atts && atts[i]) {
printf (" %s='%s'\n", atts[i], atts[i+1]);
i += 2;
}
}
#define TAG_FAIL { debug_tag (type,name,atts); exit (1); }
int
tagHook (void *udata, char *name, char **atts, int type)
{
int nr, i, flag;
if (!tester.cur) TAG_FAIL;
if (tester.cur->type != IKS_TAG) TAG_FAIL;
if (tester.cur->tag != type) TAG_FAIL;
if (iks_strcmp (tester.cur->name, name) != 0) TAG_FAIL;
if (!atts && tester.cur->nr_atts > 0) TAG_FAIL;
if (atts && tester.cur->nr_atts == 0) TAG_FAIL;
nr = tester.cur->nr_atts;
while (nr) {
flag = 0;
for (i = 0;atts&&atts[i]; i+= 2) {
if (iks_strcmp (atts[i], tester.cur->atts[nr-1]) == 0 && iks_strcmp (atts[i+1], tester.cur->vals[nr-1]) == 0) {
flag = 1;
break;
}
}
if (flag == 0) TAG_FAIL;
nr--;
}
NEXT_ELEM;
return IKS_OK;
}
void
debug_cdata (char *data, size_t len, int pos)
{
int i;
PRINT_TEST;
if (tester.cur && tester.cur->type == IKS_CDATA)
printf (" Expecting cdata [%s]\n", tester.cur->cdata);
else
printf (" Not expecting cdata here\n");
printf (" Got cdata [");
for (i = 0; i < len; i++) putchar (data[i]);
printf ("] at the pos %d.\n", pos);
}
#define CDATA_FAIL { debug_cdata (data, len, pos); exit (1); }
int
cdataHook (void *udata, char *data, size_t len)
{
static int pos = 0;
if (!tester.cur) CDATA_FAIL;
if (tester.cur->type != IKS_CDATA) CDATA_FAIL;
if (iks_strncmp (tester.cur->cdata + pos, data, len) != 0) CDATA_FAIL;
pos += len;
if (pos > tester.cur->len) CDATA_FAIL;
if (pos == tester.cur->len) {
pos = 0;
NEXT_ELEM;
}
return IKS_OK;
}
void
test_size (int blocksize)
{
enum ikserror err;
iksparser *prs;
int i, len;
tester.cur = tester.elements;
tester.nr_cur = 1;
tester.blocksize = blocksize;
len = tester.len;
prs = iks_sax_new (NULL, tagHook, cdataHook);
i = 0;
if (0 == blocksize) blocksize = len;
while (i < len) {
if (i + blocksize > len) blocksize = len - i;
err = iks_parse (prs, tester.doc + i, blocksize, 0);
switch (err) {
case IKS_OK:
break;
case IKS_NOMEM:
exit (1);
case IKS_BADXML:
PRINT_TEST;
printf ("Invalid xml at byte %ld in\n[%s]\n", iks_nr_bytes (prs), tester.doc);
exit (1);
case IKS_HOOK:
exit (1);
}
i += blocksize;
}
if (tester.cur) exit (1);
iks_parser_delete (prs);
}
void
test (void)
{
int i;
for (i = 0; i < tester.len; i++) {
test_size (i);
}
}
void
test_bad (int badbyte)
{
iksparser *p;
enum ikserror err;
p = iks_sax_new (NULL, NULL, NULL);
err = iks_parse (p, tester.doc, tester.len, 1);
switch (err) {
case IKS_OK:
break;
case IKS_NOMEM:
exit (1);
case IKS_BADXML:
if (iks_nr_bytes (p) == badbyte) return;
break;
case IKS_HOOK:
exit (1);
}
printf ("Sax test %d:\n", tester.nr_tests);
printf ("Expected bad byte %d, got %ld in\n[%s]\n", badbyte, iks_nr_bytes (p), tester.doc);
exit (1);
}
int
main (int argc, char *argv[])
{
document ("<lonely/>");
element (IKS_TAG, IKS_SINGLE, "lonely", 0);
test ();
document ("<?xml version='1.0'?><parent><child/><child/>child</parent>");
element (IKS_TAG, IKS_OPEN, "parent", 0);
element (IKS_TAG, IKS_SINGLE, "child", 0);
element (IKS_TAG, IKS_SINGLE, "child", 0);
element (IKS_CDATA, "child");
element (IKS_TAG, IKS_CLOSE, "parent");
test ();
document ("<mytag abc='123' id=\"XC72\"></mytag>");
element (IKS_TAG, IKS_OPEN, "mytag", "abc", "123", "id", "XC72", 0);
element (IKS_TAG, IKS_CLOSE, "mytag");
test ();
document ("<body>I&apos;m fixing parser&amp;tester for &quot;&lt;&quot; and &quot;&gt;&quot; chars.</body>");
element (IKS_TAG, IKS_OPEN, "body", 0);
element (IKS_CDATA, "I'm fixing parser&tester for \"<\" and \">\" chars.");
element (IKS_TAG, IKS_CLOSE, "body");
test ();
document ("<tag a='1' b='2' c='3' d='4' e='5' f='6' g='7' id='xyz9'><sub></sub></tag>");
element (IKS_TAG, IKS_OPEN, "tag", "a", "1", "b", "2", "c", "3", "d", "4", "e", "5", "f", "6", "g", "7", "id", "xyz9", 0);
element (IKS_TAG, IKS_OPEN, "sub", 0);
element (IKS_TAG, IKS_CLOSE, "sub");
element (IKS_TAG, IKS_CLOSE, "tag");
test ();
document ("<item url='http://jabber.org'><!-- little comment -->Jabber Site</item>");
element (IKS_TAG, IKS_OPEN, "item", "url", "http://jabber.org", 0);
element (IKS_CDATA, "Jabber Site");
element (IKS_TAG, IKS_CLOSE, "item");
test ();
document ("<index><!-- <item> - tag has no childs --><item name='lala' page='42'/></index>");
element (IKS_TAG, IKS_OPEN, "index", 0);
element (IKS_TAG, IKS_SINGLE, "item", "name", "lala", "page", "42", 0);
element (IKS_TAG, IKS_CLOSE, "index");
test ();
document ("<ka>1234<![CDATA[ <ka> lala ] ]] ]]] ]]>4321</ka>");
element (IKS_TAG, IKS_OPEN, "ka", 0);
element (IKS_CDATA, "1234 <ka> lala ] ]] ]]] 4321");
element (IKS_TAG, IKS_CLOSE, "ka");
test ();
document ("<test><standalone be='happy'/>abcd<br/>&lt;escape&gt;</test>");
element (IKS_TAG, IKS_OPEN, "test", 0);
element (IKS_TAG, IKS_SINGLE, "standalone", "be", "happy", 0);
element (IKS_CDATA, "abcd");
element (IKS_TAG, IKS_SINGLE, "br", 0);
element (IKS_CDATA, "<escape>");
element (IKS_TAG, IKS_CLOSE, "test");
test ();
document ("<a><b>john&amp;mary<c><d e='f' g='123456' h='madcat' klm='nop'/></c></b></a>");
element (IKS_TAG, IKS_OPEN, "a", 0);
element (IKS_TAG, IKS_OPEN, "b", 0);
element (IKS_CDATA, "john&mary");
element (IKS_TAG, IKS_OPEN, "c", 0);
element (IKS_TAG, IKS_SINGLE, "d", "e", "f", "g", "123456", "h", "madcat", "klm", "nop", 0);
element (IKS_TAG, IKS_CLOSE, "c", 0);
element (IKS_TAG, IKS_CLOSE, "b", 0);
element (IKS_TAG, IKS_CLOSE, "a", 0);
test ();
document ("<test>\xFF</test>");
test_bad (6);
document ("<t\0></t>");
tester.len = 8;
test_bad (2);
document ("<a><b/><c></c/></a>");
test_bad (13);
document ("<e><!-- -- --></e>");
test_bad (10);
document ("<g><test a='123'/ b='lala'></g>");
test_bad (17);
document ("<ha><!-- <lala> --><!- comment -></ha>");
test_bad (22);
document ("<lol>&lt;<&gt;</lol>");
test_bad (16);
document ("<a>\xC0\x80</a>");
test_bad (3);
document ("<\x8F\x85></\x8F\x85>");
test_bad (1);
document ("<utf8>\xC1\x80<br/>\xED\x95\x9C\xEA\xB5\xAD\xEC\x96\xB4<err>\xC1\x65</err></utf8>");
test_bad (28);
return 0;
}

View File

@@ -1,38 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "iksemel.h"
int main (int argc, char *argv[])
{
struct lala {
char *str;
char *hash;
} known_hashes[] = {
{ "abc", "a9993e364706816aba3e25717850c26c9cd0d89d" },
{ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
"84983e441c3bd26ebaae4aa1f95129e5e54670f1" },
{ NULL, NULL }
};
int i = 0;
char buf[42];
while (known_hashes[i].str) {
iks_sha (known_hashes[i].str, buf);
if (strcmp (buf, known_hashes[i].hash) != 0) {
printf("SHA1 hash of \"%s\"\n", known_hashes[i].str);
printf(" Result: %s\n", buf);
printf(" Expected: %s\n", known_hashes[i].hash);
return 1;
}
i++;
}
return 0;
}

View File

@@ -1,18 +0,0 @@
##
## Process this file with automake to produce Makefile.in
##
AM_CPPFLAGS = -I$(top_srcdir)/include
bin_PROGRAMS = ikslint iksroster iksperf
noinst_HEADERS = perf.h
ikslint_LDADD = $(top_builddir)/src/libiksemel.la @SUNCFLAGS@
ikslint_SOURCES = ikslint.c hash.c
iksroster_LDADD = $(top_builddir)/src/libiksemel.la @SUNCFLAGS@
iksroster_SOURCES = iksroster.c
iksperf_LDADD = $(top_builddir)/src/libiksemel.la @SUNCFLAGS@
iksperf_SOURCES = iksperf.c perf.c

View File

@@ -1,144 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
static unsigned int
hash_str (const char *str)
{
const char *p;
unsigned int h = 0;
for (p = str; *p != '\0'; p++) {
h = ( h << 5 ) - h + *p;
}
return h;
}
struct item {
char *name;
unsigned int count;
struct item *next;
};
struct hash_s {
struct item **table;
unsigned int size;
unsigned int count;
ikstack *s;
};
typedef struct hash_s hash;
hash *
hash_new (unsigned int table_size)
{
hash *h;
h = malloc (sizeof (struct hash_s));
if (!h) return NULL;
h->table = calloc (sizeof (struct item *), table_size);
if (!h->table) {
free (h);
return NULL;
}
h->s = iks_stack_new (sizeof (hash) * 128, 8192);
if (!h->s) {
free (h->table);
free (h);
return NULL;
}
h->size = table_size;
h->count = 0;
return h;
}
char *
hash_insert (hash *h, const char *name)
{
struct item *t, *p;
unsigned int val;
val = hash_str (name) % h->size;
h->count++;
for (t = h->table[val]; t; t = t->next) {
if (strcmp (t->name, name) == 0)
break;
}
if (NULL == t) {
t = iks_stack_alloc (h->s, sizeof (struct item));
if (!t) return NULL;
t->name = iks_stack_strdup (h->s, name, 0);
t->count = 0;
t->next = NULL;
p = h->table[val];
if (!p) {
h->table[val] = t;
} else {
while (1) {
if (p->next == NULL) {
p->next = t;
break;
}
p = p->next;
}
}
}
t->count++;
return t->name;
}
static int
my_cmp (const void *a, const void *b)
{
unsigned int c1, c2;
c1 = (*(struct item **)a)->count;
c2 = (*(struct item **)b)->count;
if (c1 > c2)
return -1;
else if (c1 == c2)
return 0;
else
return 1;
}
void
hash_print (hash *h, char *title_fmt, char *line_fmt)
{
struct item **tags, *t;
unsigned int i = 0, pos = 0;
tags = calloc (sizeof (struct item *), h->count);
for (; i < h->size; i ++) {
for (t = h->table[i]; t; t = t->next) {
tags[pos++] = t;
}
}
qsort (tags, pos, sizeof (struct item *), my_cmp);
printf (title_fmt, pos);
for (i = 0; i < pos; i++) {
printf (line_fmt, tags[i]->name, tags[i]->count);
}
free (tags);
}
void
hash_delete (hash *h)
{
iks_stack_delete (h->s);
free (h->table);
free (h);
}

View File

@@ -1,283 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
struct hash_s;
typedef struct hash_s hash;
hash *hash_new (unsigned int table_size);
char *hash_insert (hash *table, const char *name);
void hash_print (hash *h, char *title_fmt, char *line_fmt);
void hash_delete (hash *table);
#include <sys/stat.h>
#ifdef HAVE_GETOPT_LONG
#include <getopt.h>
#endif
#ifdef HAVE_GETOPT_LONG
static struct option longopts[] = {
{ "stats", 0, 0, 's' },
{ "histogram", 0, 0, 't' },
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
};
#endif
static char *shortopts = "sthV";
static void
print_usage (void)
{
puts ("Usage: ikslint [OPTIONS] FILE\n"
"This tool checks the well-formedness of an XML document.\n"
" -s, --stats Print statistics.\n"
" -t, --histogram Print tag histogram.\n"
" -h, --help Print this text and exit.\n"
" -V, --version Print version and exit.\n"
#ifndef HAVE_GETOPT_LONG
"(long options are not supported on your system)\n"
#endif
"Report bugs to <iksemel-dev@jabberstudio.org>.");
}
/* calculate and print statistics */
int lint_pr_stats = 0;
/* print tag histogram */
int lint_pr_hist = 0;
hash *tag_table;
char **tag_list;
int tag_size, tag_pos;
void
tag_push (const char *name)
{
if (!tag_list) {
tag_size = 128;
tag_list = malloc (sizeof (char *) * tag_size);
if (!tag_list) exit (2);
}
tag_list[tag_pos] = hash_insert (tag_table, name);
if (!tag_list[tag_pos]) exit (2);
tag_pos++;
if (tag_pos == tag_size) {
char **tmp;
tmp = malloc (sizeof (char *) * tag_size * 2);
if (!tmp) exit (2);
memcpy (tmp, tag_list, sizeof (char *) * tag_size);
free (tag_list);
tag_list = tmp;
tag_size *= 2;
}
}
char *
tag_pull (void)
{
tag_pos--;
return tag_list[tag_pos];
}
struct stats {
unsigned int level;
unsigned int max_depth;
unsigned int nr_tags;
unsigned int nr_stags;
unsigned int cdata_size;
};
int
tagHook (void *udata, char *name, char **atts, int type)
{
struct stats *st = (struct stats *) udata;
char *tmp;
switch (type) {
case IKS_OPEN:
tag_push (name);
st->level++;
if (st->level > st->max_depth) st->max_depth = st->level;
break;
case IKS_CLOSE:
tmp = tag_pull ();
if (iks_strcmp (tmp, name) != 0) {
fprintf (stderr, "Tag mismatch, expecting '%s', got '%s'.\n",
tmp, name);
return IKS_HOOK;
}
st->level--;
st->nr_tags++;
break;
case IKS_SINGLE:
if (NULL == hash_insert (tag_table, name)) exit (2);
st->nr_stags++;
break;
}
return IKS_OK;
}
int
cdataHook (void *udata, char *data, size_t len)
{
struct stats *st = (struct stats *) udata;
st->cdata_size += len;
return IKS_OK;
}
void
check_file (char *fname)
{
iksparser *prs;
struct stats st;
FILE *f;
char *buf;
struct stat fs;
size_t sz, blk, ret, pos;
enum ikserror err;
int done;
memset (&st, 0, sizeof (struct stats));
prs = iks_sax_new (&st, tagHook, cdataHook);
if (NULL == prs) exit (2);
if (fname) {
if (stat (fname, &fs) != 0) {
fprintf (stderr, "Cannot access file '%s'.\n", fname);
exit (1);
}
sz = fs.st_size;
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
blk = fs.st_blksize;
#else
blk = 4096;
#endif
f = fopen (fname, "r");
if (!f) {
fprintf (stderr, "Cannot open file '%s'.\n", fname);
exit (1);
}
buf = malloc (blk);
if (!buf) {
fclose (f);
fprintf (stderr, "Cannot allocate %d bytes.\n", blk);
exit (2);
}
} else {
f = stdin;
blk = 4096;
sz = 0;
buf = malloc (blk);
if (!buf) exit (2);
}
tag_table = hash_new (367);
if (!tag_table) exit (2);
pos = 0;
done = 0;
while (0 == done) {
ret = fread (buf, 1, blk, f);
pos += ret;
if (feof (f)) {
done = 1;
} else {
if (ret != blk) {
if (fname)
fprintf (stderr, "Read error in file '%s'.\n", fname);
else
fprintf (stderr, "Read error in stream.\n");
exit (1);
}
}
err = iks_parse (prs, buf, ret, done);
switch (err) {
case IKS_OK:
break;
case IKS_NOMEM:
exit (2);
case IKS_BADXML:
if (fname)
fprintf (stderr, "Invalid xml at byte %ld, line %ld in file '%s'.\n",
iks_nr_bytes (prs), iks_nr_lines (prs), fname);
else
fprintf (stderr, "Invalid xml at byte %ld, line %ld in stream.\n",
iks_nr_bytes (prs), iks_nr_lines (prs));
exit (1);
case IKS_HOOK:
if (fname)
fprintf (stderr, "Byte %ld, line %ld in file '%s'.\n",
iks_nr_bytes (prs), iks_nr_lines (prs), fname);
else
fprintf (stderr, "Byte %ld, line %ld in stream.\n",
iks_nr_bytes (prs), iks_nr_lines (prs));
exit (1);
}
}
free (buf);
if (fname) fclose (f);
if (fname && (lint_pr_stats || lint_pr_hist)) {
printf ("File '%s' (%d bytes):\n", fname, sz);
}
if (lint_pr_stats) {
printf ("Tags: %d pairs, %d single, %d max depth.\n", st.nr_tags, st.nr_stags, st.max_depth);
printf ("Total size of character data: %d bytes.\n", st.cdata_size);
}
if (lint_pr_hist) {
hash_print (tag_table,
"Histogram of %d unique tags:\n",
"<%s> %d times.\n");
}
hash_delete (tag_table);
iks_parser_delete (prs);
}
int
main (int argc, char *argv[])
{
int c;
#ifdef HAVE_GETOPT_LONG
int i;
while ((c = getopt_long (argc, argv, shortopts, longopts, &i)) != -1) {
#else
while ((c = getopt (argc, argv, shortopts)) != -1) {
#endif
switch (c) {
case 's':
lint_pr_stats = 1;
break;
case 't':
lint_pr_hist = 1;
break;
case 'h':
print_usage ();
exit (0);
case 'V':
puts ("ikslint (iksemel) "VERSION);
exit (0);
}
}
if (!argv[optind]) {
check_file (NULL);
} else {
for (; optind < argc; optind++) {
check_file (argv[optind]);
}
}
return 0;
}

View File

@@ -1,315 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
#include "perf.h"
#include <sys/stat.h>
#ifdef HAVE_GETOPT_LONG
#include <getopt.h>
#endif
#ifdef HAVE_GETOPT_LONG
static struct option longopts[] = {
{ "all", 0, 0, 'a' },
{ "sax", 0, 0, 's' },
{ "dom", 0, 0, 'd' },
{ "serialize", 0, 0, 'e' },
{ "sha1", 0, 0, '1' },
{ "block", required_argument, 0, 'b' },
{ "memdbg", 0, 0, 'm' },
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
};
#endif
static char *shortopts = "asde1b:mhV";
static void
print_usage (void)
{
puts ("Usage: iksperf [OPTIONS] FILE\n"
"This tool measures the performance of the iksemel library.\n"
" -a, --all Make all tests.\n"
" -s, --sax Sax test.\n"
" -d, --dom Tree generating test.\n"
" -e, --serialize Tree serializing test.\n"
" -1, --sha1 SHA1 hashing test.\n"
" -b, --block SIZE Parse the file in SIZE byte blocks.\n"
" -m, --memdbg Trace malloc and free calls.\n"
" -h, --help Print this text and exit.\n"
" -V, --version Print version and exit.\n"
#ifndef HAVE_GETOPT_LONG
"(long options are not supported on your system)\n"
#endif
"Report bugs to <iksemel-dev@jabberstudio.org>.");
}
/* if not 0, file is parsed in block_size byte blocks */
int block_size;
char *load_file (const char *fname, int *sizeptr)
{
FILE *f;
char *buf;
struct stat fs;
size_t size, ret;
if (stat (fname, &fs) != 0) {
fprintf (stderr, "Cannot access file '%s'.\n", fname);
exit (1);
}
size = fs.st_size;
printf ("Test file '%s' (%d bytes):\n", fname, size);
f = fopen (fname, "rb");
if (!f) {
fprintf (stderr, "Cannot open file.\n");
exit (1);
}
buf = malloc (size);
if (!buf) {
fclose (f);
fprintf (stderr, "Cannot allocate %d bytes for buffer.\n", size);
exit (2);
}
ret = fread (buf, 1, size, f);
if (ret < size) {
fprintf (stderr, "Read error in file.\n");
exit (1);
}
*sizeptr = size;
fclose (f);
return buf;
}
/* stats */
int sax_tag;
int sax_cdata;
int
tagHook (void *udata, char *name, char **atts, int type)
{
++sax_tag;
return IKS_OK;
}
int
cdataHook (void *udata, char *data, size_t len)
{
++sax_cdata;
return IKS_OK;
}
void
sax_test (char *buf, int len)
{
unsigned long time;
iksparser *prs;
int bs, i, err;
bs = block_size;
if (0 == bs) bs = len;
sax_tag = 0;
sax_cdata = 0;
t_reset ();
prs = iks_sax_new (NULL, tagHook, cdataHook);
i = 0;
while (i < len) {
if (i + bs > len) bs = len - i;
err = iks_parse (prs, buf + i, bs, 0);
switch (err) {
case IKS_OK:
break;
case IKS_NOMEM:
exit (2);
case IKS_BADXML:
fprintf (stderr, "Invalid xml at byte %ld, line %ld\n",
iks_nr_bytes (prs), iks_nr_lines (prs));
exit (1);
case IKS_HOOK:
exit (1);
}
i += bs;
}
time = t_elapsed ();
printf ("SAX: parsing took %ld milliseconds.\n", time);
printf ("SAX: tag hook called %d, cdata hook called %d times.\n", sax_tag, sax_cdata);
iks_parser_delete (prs);
}
void dom_test (char *buf, int len)
{
int bs, i, err;
iksparser *prs;
unsigned long time;
iks *x;
size_t allocated, used;
bs = block_size;
if (0 == bs) bs = len;
t_reset ();
prs = iks_dom_new (&x);
iks_set_size_hint (prs, len);
i = 0;
while (i < len) {
if (i + bs > len) bs = len - i;
err = iks_parse (prs, buf + i, bs, 0);
switch (err) {
case IKS_OK:
break;
case IKS_NOMEM:
exit (2);
case IKS_BADXML:
fprintf (stderr, "Invalid xml at byte %ld, line %ld\n",
iks_nr_bytes (prs), iks_nr_lines (prs));
exit (1);
case IKS_HOOK:
exit (1);
}
i += bs;
}
time = t_elapsed ();
iks_stack_stat (iks_stack (x), &allocated, &used);
printf ("DOM: parsing and building the tree took %ld milliseconds.\n", time);
printf ("DOM: ikstack: %d bytes allocated, %d bytes used.\n", allocated, used);
t_reset ();
iks_delete (x);
time = t_elapsed ();
printf ("DOM: deleting the tree took %ld milliseconds.\n", time);
iks_parser_delete (prs);
}
void
serialize_test (char *buf, int len)
{
unsigned long time;
iks *x;
iksparser *prs;
int err;
prs = iks_dom_new (&x);
err = iks_parse (prs, buf, len, 1);
switch (err) {
case IKS_OK:
break;
case IKS_NOMEM:
exit (2);
case IKS_BADXML:
fprintf (stderr, "Invalid xml at byte %ld, line %ld\n",
iks_nr_bytes (prs), iks_nr_lines (prs));
exit (1);
case IKS_HOOK:
exit (1);
}
iks_parser_delete (prs);
t_reset ();
iks_string (iks_stack (x), x);
time = t_elapsed ();
printf ("Serialize: serializing the tree took %ld milliseconds.\n", time);
iks_delete (x);
}
void
sha_test (char *buf, int len)
{
unsigned long time;
iksha *s;
char out[41];
t_reset ();
s = iks_sha_new ();
iks_sha_hash (s, buf, len, 1);
iks_sha_print (s, out);
out[40] = '\0';
iks_sha_delete (s);
time = t_elapsed ();
printf ("SHA: hashing took %ld milliseconds.\n", time);
printf ("SHA: hash [%s]\n", out);
}
int
main (int argc, char *argv[])
{
int test_type = 0;
int c;
#ifdef HAVE_GETOPT_LONG
int i;
while ((c = getopt_long (argc, argv, shortopts, longopts, &i)) != -1) {
#else
while ((c = getopt (argc, argv, shortopts)) != -1) {
#endif
switch (c) {
case 'a':
test_type = 0xffff;
break;
case 's':
test_type |= 1;
break;
case 'd':
test_type |= 2;
break;
case 'e':
test_type |= 4;
break;
case '1':
test_type |= 8;
break;
case 'b':
block_size = atoi (optarg);
break;
case 'm':
m_trace ();
break;
case 'h':
print_usage ();
exit (0);
case 'V':
puts ("iksperf (iksemel) "VERSION);
exit (0);
}
}
for (; optind < argc; optind++) {
char *buf;
int len;
buf = load_file (argv[optind], &len);
if (test_type & 1) sax_test (buf, len);
if (test_type == 0 || test_type & 2) dom_test (buf, len);
if (test_type & 4) serialize_test (buf, len);
if (test_type & 8) sha_test (buf, len);
free (buf);
}
return 0;
}

View File

@@ -1,380 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2004 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include "common.h"
#include "iksemel.h"
#ifdef HAVE_GETOPT_LONG
#include <getopt.h>
#endif
#ifdef _WIN32
#include <winsock.h>
#endif
#ifdef HAVE_GETOPT_LONG
static struct option longopts[] = {
{ "backup", required_argument, 0, 'b' },
{ "restore", required_argument, 0, 'r' },
{ "file", required_argument, 0, 'f' },
{ "timeout", required_argument, 0, 't' },
{ "secure", 0, 0, 's' },
{ "sasl", 0, 0, 'a' },
{ "log", 0, 0, 'l' },
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
};
#endif
static char *shortopts = "b:r:f:t:salhV";
static void
print_usage (void)
{
puts ("Usage: iksroster [OPTIONS]\n"
"This is a backup tool for your jabber roster.\n"
" -b, --backup=JID Download roster from the server.\n"
" -r, --restore=JID Upload roster to the server.\n"
" -f, --file=FILE Load/Save roster to this file.\n"
" -t, --timeout=SECS Set network timeout.\n"
" -s, --secure Use encrypted connection.\n"
" -a, --sasl Use SASL authentication.\n"
" -l, --log Print exchanged xml data.\n"
" -h, --help Print this text and exit.\n"
" -V, --version Print version and exit.\n"
#ifndef HAVE_GETOPT_LONG
"(long options are not supported on your system)\n"
#endif
#ifndef HAVE_GNUTLS
"(secure connections are not supported on your system)\n"
#endif
"Report bugs to <iksemel-dev@jabberstudio.org>.");
}
/* stuff we keep per session */
struct session {
iksparser *prs;
iksid *acc;
char *pass;
int features;
int authorized;
int counter;
int set_roster;
int job_done;
};
/* precious roster we'll deal with */
iks *my_roster;
/* out packet filter */
iksfilter *my_filter;
/* connection time outs if nothing comes for this much seconds */
int opt_timeout = 30;
/* connection flags */
int opt_use_tls;
int opt_use_sasl;
int opt_log;
void
j_error (char *msg)
{
fprintf (stderr, "iksroster: %s\n", msg);
exit (2);
}
int
on_result (struct session *sess, ikspak *pak)
{
iks *x;
if (sess->set_roster == 0) {
x = iks_make_iq (IKS_TYPE_GET, IKS_NS_ROSTER);
iks_insert_attrib (x, "id", "roster");
iks_send (sess->prs, x);
iks_delete (x);
} else {
iks_insert_attrib (my_roster, "type", "set");
iks_send (sess->prs, my_roster);
}
return IKS_FILTER_EAT;
}
int
on_stream (struct session *sess, int type, iks *node)
{
sess->counter = opt_timeout;
switch (type) {
case IKS_NODE_START:
if (opt_use_tls && !iks_is_secure (sess->prs)) {
iks_start_tls (sess->prs);
break;
}
if (!opt_use_sasl) {
iks *x;
x = iks_make_auth (sess->acc, sess->pass, iks_find_attrib (node, "id"));
iks_insert_attrib (x, "id", "auth");
iks_send (sess->prs, x);
iks_delete (x);
}
break;
case IKS_NODE_NORMAL:
if (strcmp ("stream:features", iks_name (node)) == 0) {
sess->features = iks_stream_features (node);
if (opt_use_sasl) {
if (opt_use_tls && !iks_is_secure (sess->prs)) break;
if (sess->authorized) {
iks *t;
if (sess->features & IKS_STREAM_BIND) {
t = iks_make_resource_bind (sess->acc);
iks_send (sess->prs, t);
iks_delete (t);
}
if (sess->features & IKS_STREAM_SESSION) {
t = iks_make_session ();
iks_insert_attrib (t, "id", "auth");
iks_send (sess->prs, t);
iks_delete (t);
}
} else {
if (sess->features & IKS_STREAM_SASL_MD5)
iks_start_sasl (sess->prs, IKS_SASL_DIGEST_MD5, sess->acc->user, sess->pass);
else if (sess->features & IKS_STREAM_SASL_PLAIN)
iks_start_sasl (sess->prs, IKS_SASL_PLAIN, sess->acc->user, sess->pass);
}
}
} else if (strcmp ("failure", iks_name (node)) == 0) {
j_error ("sasl authentication failed");
} else if (strcmp ("success", iks_name (node)) == 0) {
sess->authorized = 1;
iks_send_header (sess->prs, sess->acc->server);
} else {
ikspak *pak;
pak = iks_packet (node);
iks_filter_packet (my_filter, pak);
if (sess->job_done == 1) return IKS_HOOK;
}
break;
case IKS_NODE_STOP:
j_error ("server disconnected");
case IKS_NODE_ERROR:
j_error ("stream error");
}
if (node) iks_delete (node);
return IKS_OK;
}
int
on_error (void *user_data, ikspak *pak)
{
j_error ("authorization failed");
return IKS_FILTER_EAT;
}
int
on_roster (struct session *sess, ikspak *pak)
{
my_roster = pak->x;
sess->job_done = 1;
return IKS_FILTER_EAT;
}
void
on_log (struct session *sess, const char *data, size_t size, int is_incoming)
{
if (iks_is_secure (sess->prs)) fprintf (stderr, "Sec");
if (is_incoming) fprintf (stderr, "RECV"); else fprintf (stderr, "SEND");
fprintf (stderr, "[%s]\n", data);
}
void
j_setup_filter (struct session *sess)
{
if (my_filter) iks_filter_delete (my_filter);
my_filter = iks_filter_new ();
iks_filter_add_rule (my_filter, (iksFilterHook *) on_result, sess,
IKS_RULE_TYPE, IKS_PAK_IQ,
IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,
IKS_RULE_ID, "auth",
IKS_RULE_DONE);
iks_filter_add_rule (my_filter, on_error, sess,
IKS_RULE_TYPE, IKS_PAK_IQ,
IKS_RULE_SUBTYPE, IKS_TYPE_ERROR,
IKS_RULE_ID, "auth",
IKS_RULE_DONE);
iks_filter_add_rule (my_filter, (iksFilterHook *) on_roster, sess,
IKS_RULE_TYPE, IKS_PAK_IQ,
IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,
IKS_RULE_ID, "roster",
IKS_RULE_DONE);
}
void
j_connect (char *jabber_id, char *pass, int set_roster)
{
struct session sess;
int e;
memset (&sess, 0, sizeof (sess));
sess.prs = iks_stream_new (IKS_NS_CLIENT, &sess, (iksStreamHook *) on_stream);
if (opt_log) iks_set_log_hook (sess.prs, (iksLogHook *) on_log);
sess.acc = iks_id_new (iks_parser_stack (sess.prs), jabber_id);
if (NULL == sess.acc->resource) {
/* user gave no resource name, use the default */
char *tmp;
tmp = iks_malloc (strlen (sess.acc->user) + strlen (sess.acc->server) + 9 + 3);
sprintf (tmp, "%s@%s/%s", sess.acc->user, sess.acc->server, "iksroster");
sess.acc = iks_id_new (iks_parser_stack (sess.prs), tmp);
iks_free (tmp);
}
sess.pass = pass;
sess.set_roster = set_roster;
j_setup_filter (&sess);
e = iks_connect_tcp (sess.prs, sess.acc->server, IKS_JABBER_PORT);
switch (e) {
case IKS_OK:
break;
case IKS_NET_NODNS:
j_error ("hostname lookup failed");
case IKS_NET_NOCONN:
j_error ("connection failed");
default:
j_error ("io error");
}
sess.counter = opt_timeout;
while (1) {
e = iks_recv (sess.prs, 1);
if (IKS_HOOK == e) break;
if (IKS_NET_TLSFAIL == e) j_error ("tls handshake failed");
if (IKS_OK != e) j_error ("io error");
sess.counter--;
if (sess.counter == 0) j_error ("network timeout");
}
iks_parser_delete (sess.prs);
}
int
main (int argc, char *argv[])
{
char *from = NULL;
char *to = NULL;
char *file = NULL;
char from_pw[128], to_pw[128];
int c;
#ifdef HAVE_GETOPT_LONG
int i;
while ((c = getopt_long (argc, argv, shortopts, longopts, &i)) != -1) {
#else
while ((c = getopt (argc, argv, shortopts)) != -1) {
#endif
switch (c) {
case 'b':
from = optarg;
printf ("Password for %s: ", optarg);
fflush (stdout);
fgets (from_pw, 127, stdin);
strtok (from_pw, "\r\n");
break;
case 'r':
to = optarg;
printf ("Password for %s: ", optarg);
fflush (stdout);
fgets (to_pw, 127, stdin);
strtok (to_pw, "\r\n");
break;
case 'f':
if (file) free(file);
file = strdup (optarg);
break;
case 't':
opt_timeout = atoi (optarg);
if (opt_timeout < 10) opt_timeout = 10;
break;
case 's':
if (!iks_has_tls ()) {
puts ("Cannot make encrypted connections.");
puts ("iksemel library is not compiled with GnuTLS support.");
exit (1);
}
opt_use_tls = 1;
break;
case 'a':
opt_use_sasl = 1;
break;
case 'l':
opt_log = 1;
break;
case 'h':
print_usage ();
exit (0);
case 'V':
puts ("iksroster (iksemel) "VERSION);
exit (0);
}
}
if (from == NULL && to == NULL) {
puts ("What I'm supposed to do?");
print_usage ();
exit (1);
}
if (to && (from == NULL && file == NULL)) {
puts ("Store which roster?");
print_usage ();
exit (1);
}
#ifdef _WIN32
WSADATA wsaData;
WSAStartup (MAKEWORD (1,1), &wsaData);
#endif
if (from) {
j_connect (from, from_pw, 0);
if (file) {
switch (iks_save (file, my_roster)) {
case IKS_OK:
break;
case IKS_FILE_NOACCESS:
j_error ("cannot write to file");
default:
j_error ("file io error");
}
}
} else {
switch (iks_load (file, &my_roster)) {
case IKS_OK:
break;
case IKS_FILE_NOFILE:
j_error ("file not found");
case IKS_FILE_NOACCESS:
j_error ("cannot read file");
default:
j_error ("file io error");
}
}
if (to) {
j_connect (to, to_pw, 1);
}
#ifdef _WIN32
WSACleanup ();
#endif
if (file) free(file);
return 0;
}

View File

@@ -1,84 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#include <limits.h>
#else
#include <sys/time.h>
#endif
#include "iksemel.h"
/* timing functions */
#ifdef _WIN32
static DWORD start_tv;
void
t_reset (void)
{
start_tv = GetTickCount ();
}
unsigned long
t_elapsed (void)
{
DWORD end_tv;
end_tv = GetTickCount ();
if (end_tv < start_tv)
return UINT_MAX - (start_tv - end_tv - 1);
else
return end_tv - start_tv;
}
#else
static struct timeval start_tv;
void
t_reset (void)
{
gettimeofday (&start_tv, NULL);
}
unsigned long
t_elapsed (void)
{
unsigned long msec;
struct timeval cur_tv;
gettimeofday (&cur_tv, NULL);
msec = (cur_tv.tv_sec * 1000) + (cur_tv.tv_usec / 1000);
msec -= (start_tv.tv_sec * 1000) + (start_tv.tv_usec / 1000);
return msec;
}
#endif
/* memory functions */
static void *
m_malloc (size_t size)
{
void *ptr = malloc (size);
printf ("MEM: malloc (%d) => %p\n", size, ptr);
return ptr;
}
static void
m_free (void *ptr)
{
printf ("MEM: free (%p)\n", ptr);
}
void
m_trace (void)
{
iks_set_mem_funcs (m_malloc, m_free);
}

View File

@@ -1,10 +0,0 @@
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
void t_reset (void);
unsigned long t_elapsed (void);
void m_trace (void);

View File

@@ -1 +0,0 @@
1

View File

@@ -1,93 +0,0 @@
/* include/config.h. Generated by configure. */
/* include/config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the `getaddrinfo' function. */
//#define HAVE_GETADDRINFO 1
/* Define to 1 if you have the `getopt_long' function. */
//#define HAVE_GETOPT_LONG 1
/* "Use libgnutls" */
//#define HAVE_GNUTLS
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `wsock32' library (-lwsock32). */
/* #undef HAVE_LIBWSOCK32 */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if `st_blksize' is member of `struct stat'. */
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
//#define HAVE_UNISTD_H 1
/* Name of package */
#define PACKAGE "iksemel"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define this is you want default transport */
#define USE_DEFAULT_IO 1
/* Version number of package */
#define VERSION "1.3"
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to `unsigned' if <sys/types.h> does not define. */
/* #undef size_t */

View File

@@ -1,141 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>iksemel</ProjectName>
<ProjectGuid>{E727E8F6-935D-46FE-8B0E-37834748A0E3}</ProjectGuid>
<RootNamespace>iksemel</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="..\..\..\w32\openssl.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\w32\extlib.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\w32\extlib.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\w32\extlib.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\w32\extlib.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\iksemel\src\base64.c" />
<ClCompile Include="..\..\iksemel\src\dom.c" />
<ClCompile Include="..\..\iksemel\src\filter.c" />
<ClCompile Include="..\..\iksemel\src\iks.c" />
<ClCompile Include="..\..\iksemel\src\ikstack.c" />
<ClCompile Include="..\..\iksemel\src\io-posix.c" />
<ClCompile Include="..\..\iksemel\src\jabber.c" />
<ClCompile Include="..\..\iksemel\src\md5.c" />
<ClCompile Include="..\..\iksemel\src\sax.c" />
<ClCompile Include="..\..\iksemel\src\sha.c" />
<ClCompile Include="..\..\iksemel\src\stream.c" />
<ClCompile Include="..\..\iksemel\src\utility.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\iksemel\include\common.h" />
<ClInclude Include="..\..\iksemel\include\config.h" />
<ClInclude Include="..\..\iksemel\include\finetune.h" />
<ClInclude Include="..\..\iksemel\include\iksemel.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>