1
0
mirror of https://github.com/signalwire/freeswitch.git synced 2025-04-18 01:28:42 +00:00

add iksemel to in tree libs

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3756 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2006-12-20 15:45:14 +00:00
parent 7d37a04688
commit 83f4a9dc2f
66 changed files with 57293 additions and 2 deletions

17
libs/iksemel/AUTHORS Normal file

@ -0,0 +1,17 @@
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)

515
libs/iksemel/COPYING Normal file

@ -0,0 +1,515 @@
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!

619
libs/iksemel/ChangeLog Normal file

@ -0,0 +1,619 @@
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.

71
libs/iksemel/HACKING Normal file

@ -0,0 +1,71 @@
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)

182
libs/iksemel/INSTALL Normal file

@ -0,0 +1,182 @@
Basic Installation
==================
These are generic installation instructions.
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, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
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 at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' 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. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. 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.
4. Type `make install' to install the programs and any data files and
documentation.
5. 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.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
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 must use a version of `make' that
supports the `VPATH' variable, such as 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 `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have 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.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' 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.
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'.
Optional Features
=================
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.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
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 host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
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.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--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.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

18
libs/iksemel/Makefile.am Normal file

@ -0,0 +1,18 @@
##
## 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

380
libs/iksemel/Makefile.in Normal file

@ -0,0 +1,380 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AR = @AR@
AS = @AS@
CC = @CC@
CXX = @CXX@
CXXCPP = @CXXCPP@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
GCJ = @GCJ@
GCJFLAGS = @GCJFLAGS@
HAVE_LIB = @HAVE_LIB@
LIB = @LIB@
LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIB = @LTLIB@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
RC = @RC@
STRIP = @STRIP@
VERSION = @VERSION@
SUBDIRS = include src tools test doc
EXTRA_DIST = HACKING iksemel.pc.in
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = iksemel.pc
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ./include/config.h
CONFIG_CLEAN_FILES = iksemel.pc
DATA = $(pkgconfig_DATA)
DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
Makefile.in NEWS TODO aclocal.m4 config.guess config.sub configure \
configure.ac iksemel.pc.in install-sh ltmain.sh missing mkinstalldirs
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(ACLOCAL_M4): configure.ac
cd $(srcdir) && $(ACLOCAL)
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
iksemel.pc: $(top_builddir)/config.status iksemel.pc.in
cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
install-pkgconfigDATA: $(pkgconfig_DATA)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(pkgconfigdir)
@list='$(pkgconfig_DATA)'; for p in $$list; do \
if test -f $(srcdir)/$$p; then \
echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p"; \
$(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p; \
else if test -f $$p; then \
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p"; \
$(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p; \
fi; fi; \
done
uninstall-pkgconfigDATA:
@$(NORMAL_UNINSTALL)
list='$(pkgconfig_DATA)'; for p in $$list; do \
rm -f $(DESTDIR)$(pkgconfigdir)/$$p; \
done
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
@SET_MAKE@
all-recursive install-data-recursive install-exec-recursive \
installdirs-recursive install-recursive uninstall-recursive \
check-recursive installcheck-recursive info-recursive dvi-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
rev="$$subdir $$rev"; \
test "$$subdir" != "." || dot_seen=yes; \
done; \
test "$$dot_seen" = "no" && rev=". $$rev"; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP))
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
-rm -rf $(distdir)
GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
dc_install_base=`cd $(distdir)/=inst && pwd`; \
cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) dist
-rm -rf $(distdir)
@banner="$(distdir).tar.gz is ready for distribution"; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
echo "$$dashes"
dist: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
dist-all: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
distdir: $(DISTFILES)
-rm -rf $(distdir)
mkdir $(distdir)
-chmod 777 $(distdir)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
for subdir in $(SUBDIRS); do \
if test "$$subdir" = .; then :; else \
test -d $(distdir)/$$subdir \
|| mkdir $(distdir)/$$subdir \
|| exit 1; \
chmod 777 $(distdir)/$$subdir; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
|| exit 1; \
fi; \
done
info-am:
info: info-recursive
dvi-am:
dvi: dvi-recursive
check-am: all-am
check: check-recursive
installcheck-am:
installcheck: installcheck-recursive
install-exec-am:
install-exec: install-exec-recursive
install-data-am: install-pkgconfigDATA
install-data: install-data-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-recursive
uninstall-am: uninstall-pkgconfigDATA
uninstall: uninstall-recursive
all-am: Makefile $(DATA)
all-redirect: all-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs: installdirs-recursive
installdirs-am:
$(mkinstalldirs) $(DESTDIR)$(pkgconfigdir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-recursive
clean-am: clean-tags clean-generic mostlyclean-am
clean: clean-recursive
distclean-am: distclean-tags distclean-generic clean-am
-rm -f libtool
distclean: distclean-recursive
-rm -f config.status
maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-recursive
-rm -f config.status
.PHONY: uninstall-pkgconfigDATA install-pkgconfigDATA \
install-data-recursive uninstall-data-recursive install-exec-recursive \
uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
all-recursive check-recursive installcheck-recursive info-recursive \
dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs-am \
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
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
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

34
libs/iksemel/NEWS Normal file

@ -0,0 +1,34 @@
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.

45
libs/iksemel/README Normal file

@ -0,0 +1,45 @@
iksemel 1.2
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

12
libs/iksemel/TODO Normal file

@ -0,0 +1,12 @@
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? :-)

7056
libs/iksemel/aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

1459
libs/iksemel/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1549
libs/iksemel/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

20686
libs/iksemel/configure vendored Executable file

File diff suppressed because it is too large Load Diff

67
libs/iksemel/configure.ac Normal file

@ -0,0 +1,67 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT
AC_PREREQ(2.50)
AC_CONFIG_SRCDIR([configure.ac])
AM_INIT_AUTOMAKE(iksemel,1.2)
AM_CONFIG_HEADER(include/config.h)
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)
AM_PATH_LIBGNUTLS(,AC_DEFINE(HAVE_GNUTLS,,"Use libgnutls"))
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
dnl Generating makefiles
AC_CONFIG_FILES([
Makefile
iksemel.pc
src/Makefile
include/Makefile
tools/Makefile
test/Makefile
doc/Makefile
])
AC_OUTPUT

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

@ -0,0 +1,320 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AR = @AR@
AS = @AS@
CC = @CC@
CXX = @CXX@
CXXCPP = @CXXCPP@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
GCJ = @GCJ@
GCJFLAGS = @GCJFLAGS@
HAVE_LIB = @HAVE_LIB@
LIB = @LIB@
LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIB = @LTLIB@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
RC = @RC@
STRIP = @STRIP@
VERSION = @VERSION@
info_TEXINFOS = iksemel.texi
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../include/config.h
CONFIG_CLEAN_FILES =
TEXI2DVI = texi2dvi
INFO_DEPS = iksemel
DVIS = iksemel.dvi
TEXINFOS = iksemel.texi
DIST_COMMON = Makefile.am Makefile.in texinfo.tex
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
.SUFFIXES: .dvi .info .ps .texi .texinfo .txi
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps doc/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
iksemel: iksemel.texi
iksemel.dvi: iksemel.texi
DVIPS = dvips
.texi.info:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.texi.dvi:
TEXINPUTS=.:$$TEXINPUTS \
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
.texi:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.texinfo.info:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.texinfo:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.texinfo.dvi:
TEXINPUTS=.:$$TEXINPUTS \
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
.txi.info:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.txi.dvi:
TEXINPUTS=.:$$TEXINPUTS \
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
.txi:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.dvi.ps:
$(DVIPS) $< -o $@
install-info-am: $(INFO_DEPS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(infodir)
@list='$(INFO_DEPS)'; \
for file in $$list; do \
d=$(srcdir); \
for ifile in `cd $$d && echo $$file $$file-[0-9] $$file-[0-9][0-9]`; do \
if test -f $$d/$$ifile; then \
echo " $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile"; \
$(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile; \
else : ; fi; \
done; \
done
@$(POST_INSTALL)
@if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
list='$(INFO_DEPS)'; \
for file in $$list; do \
echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";\
install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :;\
done; \
else : ; fi
uninstall-info:
$(PRE_UNINSTALL)
@if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
ii=yes; \
else ii=; fi; \
list='$(INFO_DEPS)'; \
for file in $$list; do \
test -z "$$ii" \
|| install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \
done
@$(NORMAL_UNINSTALL)
list='$(INFO_DEPS)'; \
for file in $$list; do \
(cd $(DESTDIR)$(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \
done
dist-info: $(INFO_DEPS)
list='$(INFO_DEPS)'; \
for base in $$list; do \
d=$(srcdir); \
for file in `cd $$d && eval echo $$base*`; do \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file; \
done; \
done
mostlyclean-aminfo:
-rm -f iksemel.aux iksemel.cp iksemel.cps iksemel.dvi iksemel.fn \
iksemel.fns iksemel.ky iksemel.kys iksemel.ps iksemel.log \
iksemel.pg iksemel.toc iksemel.tp iksemel.tps iksemel.vr \
iksemel.vrs iksemel.op iksemel.tr iksemel.cv iksemel.cn
clean-aminfo:
distclean-aminfo:
maintainer-clean-aminfo:
cd $(srcdir) && for i in $(INFO_DEPS); do \
rm -f $$i; \
if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \
rm -f $$i-[0-9]*; \
fi; \
done
tags: TAGS
TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = doc
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
$(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-info
info-am: $(INFO_DEPS)
info: info-am
dvi-am: $(DVIS)
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am
install-data-am: install-info-am
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-info
uninstall: uninstall-am
all-am: Makefile $(INFO_DEPS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(infodir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-aminfo mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-aminfo clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-aminfo distclean-generic clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-aminfo maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: install-info-am uninstall-info mostlyclean-aminfo \
distclean-aminfo clean-aminfo maintainer-clean-aminfo tags distdir \
info-am info dvi-am dvi check check-am installcheck-am installcheck \
install-exec-am install-exec install-data-am install-data install-am \
install uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

1602
libs/iksemel/doc/iksemel Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

6341
libs/iksemel/doc/texinfo.tex Normal file

File diff suppressed because it is too large Load Diff

@ -0,0 +1,10 @@
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}

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

@ -0,0 +1,273 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AR = @AR@
AS = @AS@
CC = @CC@
CXX = @CXX@
CXXCPP = @CXXCPP@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
GCJ = @GCJ@
GCJFLAGS = @GCJFLAGS@
HAVE_LIB = @HAVE_LIB@
LIB = @LIB@
LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIB = @LTLIB@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
RC = @RC@
STRIP = @STRIP@
VERSION = @VERSION@
include_HEADERS = iksemel.h
noinst_HEADERS = common.h finetune.h
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
HEADERS = $(include_HEADERS) $(noinst_HEADERS)
DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in config.h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps include/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
config.h: stamp-h
@if test ! -f $@; then \
rm -f stamp-h; \
$(MAKE) stamp-h; \
else :; fi
stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES= CONFIG_HEADERS=include/config.h \
$(SHELL) ./config.status
@echo timestamp > stamp-h 2> /dev/null
$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
@if test ! -f $@; then \
rm -f $(srcdir)/stamp-h.in; \
$(MAKE) $(srcdir)/stamp-h.in; \
else :; fi
$(srcdir)/stamp-h.in: $(top_srcdir)/configure.ac $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOHEADER)
@echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
mostlyclean-hdr:
clean-hdr:
distclean-hdr:
-rm -f config.h
maintainer-clean-hdr:
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(includedir)
@list='$(include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
done
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
list='$(include_HEADERS)'; for p in $$list; do \
rm -f $(DESTDIR)$(includedir)/$$p; \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP))
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = include
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
all-recursive-am: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
install-exec-am:
install-exec: install-exec-am
install-data-am: install-includeHEADERS
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-includeHEADERS
uninstall: uninstall-am
all-am: Makefile $(HEADERS) config.h
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(includedir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-hdr clean-tags clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-hdr distclean-tags distclean-generic clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
uninstall-includeHEADERS install-includeHEADERS tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \
install-exec-am install-exec install-data-am install-data install-am \
install uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

@ -0,0 +1,33 @@
/* 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"

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

@ -0,0 +1,29 @@
/* 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

@ -0,0 +1,407 @@
/* 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.
*/
#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 *s);
/***** utilities *****/
void *iks_malloc (size_t size);
void iks_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);
/***** 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);
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_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 */

@ -0,0 +1 @@
timestamp

269
libs/iksemel/install-sh Executable file

@ -0,0 +1,269 @@
#!/bin/sh
#
# install - install a program, script, or datafile
#
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

6425
libs/iksemel/ltmain.sh Normal file

File diff suppressed because it is too large Load Diff

198
libs/iksemel/missing Executable file

@ -0,0 +1,198 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright (C) 1996, 1997, 2001, 2002 Free Software Foundation, Inc.
# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program 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 General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.in; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing - GNU libit 0.0"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acinclude.m4' or \`$configure_ac'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`$configure_ac'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acconfig.h' or \`$configure_ac'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' $configure_ac`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`$configure_ac'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequirements for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0

40
libs/iksemel/mkinstalldirs Executable file

@ -0,0 +1,40 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
# $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $
errstatus=0
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here

@ -0,0 +1,29 @@
##
## Process this file with automake to produce Makefile.in
##
INCLUDES = -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 3:0:0 -no-undefined
libiksemel_la_CFLAGS = $(CFLAGS) $(LIBGNUTLS_CFLAGS)
libiksemel_la_LIBADD = $(LIBGNUTLS_LIBS)

@ -0,0 +1,341 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AR = @AR@
AS = @AS@
CC = @CC@
CXX = @CXX@
CXXCPP = @CXXCPP@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
GCJ = @GCJ@
GCJFLAGS = @GCJFLAGS@
HAVE_LIB = @HAVE_LIB@
LIB = @LIB@
LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIB = @LTLIB@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
RC = @RC@
STRIP = @STRIP@
VERSION = @VERSION@
INCLUDES = -I$(top_srcdir)/include
lib_LTLIBRARIES = libiksemel.la
@DO_POSIX_TRUE@posix_c = io-posix.c
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 3:0:0 -no-undefined
libiksemel_la_CFLAGS = $(CFLAGS) $(LIBGNUTLS_CFLAGS)
libiksemel_la_LIBADD = $(LIBGNUTLS_LIBS)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../include/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(lib_LTLIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir) -I../include
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
libiksemel_la_DEPENDENCIES =
@DO_POSIX_TRUE@libiksemel_la_OBJECTS = ikstack.lo utility.lo iks.lo \
@DO_POSIX_TRUE@sax.lo dom.lo io-posix.lo stream.lo sha.lo jabber.lo \
@DO_POSIX_TRUE@filter.lo md5.lo base64.lo
@DO_POSIX_FALSE@libiksemel_la_OBJECTS = ikstack.lo utility.lo iks.lo \
@DO_POSIX_FALSE@sax.lo dom.lo stream.lo sha.lo jabber.lo filter.lo \
@DO_POSIX_FALSE@md5.lo base64.lo
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
SOURCES = $(libiksemel_la_SOURCES)
OBJECTS = $(libiksemel_la_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .lo .o .obj .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-libLTLIBRARIES:
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
distclean-libLTLIBRARIES:
maintainer-clean-libLTLIBRARIES:
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
list='$(lib_LTLIBRARIES)'; for p in $$list; do \
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
done
.c.o:
$(COMPILE) -c $<
# FIXME: We should only use cygpath when building on Windows,
# and only if it is available.
.c.obj:
$(COMPILE) -c `cygpath -w $<`
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
-rm -f *.$(OBJEXT)
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
libiksemel.la: $(libiksemel_la_OBJECTS) $(libiksemel_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libiksemel_la_LDFLAGS) $(libiksemel_la_OBJECTS) $(libiksemel_la_LIBADD) $(LIBS)
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP))
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = src
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-libLTLIBRARIES
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libLTLIBRARIES
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-libLTLIBRARIES distclean-compile \
distclean-libtool distclean-tags distclean-generic \
clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-tags maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
distclean-compile clean-compile maintainer-clean-compile \
mostlyclean-libtool distclean-libtool clean-libtool \
maintainer-clean-libtool tags mostlyclean-tags distclean-tags \
clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
check-am installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

98
libs/iksemel/src/base64.c Normal file

@ -0,0 +1,98 @@
/* 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 char base64_charset[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char *iks_base64_decode(const char *buf)
{
char *res, *save, *foo, val;
const char *end;
int index;
if (!buf)
return NULL;
index = iks_strlen(buf)*6 / 8 + 1;
save = res = iks_malloc(index);
memset(res, 0, index);
index = 0;
if (!save)
return NULL;
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);
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)];
break;
case 1:
*res++ = base64_charset[*buf >> 2];
*res++ = base64_charset[(*buf++ & 0x03) << 4];
break;
}
*res++ = '=';
*res++ = '=';
*res = 0;
return save;
}

178
libs/iksemel/src/dom.c Normal file

@ -0,0 +1,178 @@
/* 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 (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;
len = 0;
}
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;
}

181
libs/iksemel/src/filter.c Normal file

@ -0,0 +1,181 @@
/* 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);
}

662
libs/iksemel/src/iks.c Normal file

@ -0,0 +1,662 @@
/* 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"
#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;
}
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) {
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));
}

202
libs/iksemel/src/ikstack.c Normal file

@ -0,0 +1,202 @@
/* 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 (1) {
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 *s)
{
ikschunk *c, *tmp;
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);
}

130
libs/iksemel/src/io-posix.c Normal file

@ -0,0 +1,130 @@
/* 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];
hints.ai_flags = AI_CANONNAME;
hints.ai_family = PF_UNSPEC;
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) {
sock = socket (addr_ptr->ai_family, addr_ptr->ai_socktype, addr_ptr->ai_protocol);
if (sock != -1) break;
addr_ptr = addr_ptr->ai_next;
}
if (sock == -1) return IKS_NET_NOSOCK;
tmp = connect (sock, addr_ptr->ai_addr, addr_ptr->ai_addrlen);
freeaddrinfo (addr_res);
#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));
#endif
if (tmp != 0) {
io_close ((void *) sock);
return IKS_NET_NOCONN;
}
*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;
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) {
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
};

330
libs/iksemel/src/jabber.c Normal file

@ -0,0 +1,330 @@
/* 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, sid, strlen (sid), 0);
iks_sha_hash (sha, 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;
}

189
libs/iksemel/src/md5.c Normal file

@ -0,0 +1,189 @@
/* 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 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, 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];
}

633
libs/iksemel/src/sax.c Normal file

@ -0,0 +1,633 @@
/* 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 = prs->stack_max + (need * 1.2);
}
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) {
unsigned char mask;
if ((c & 0x60) == 0x40) {
prs->uni_max = 2;
mask = 0x1F;
} else if ((c & 0x70) == 0x60) {
prs->uni_max = 3;
mask = 0x0F;
} else if ((c & 0x78) == 0x70) {
prs->uni_max = 4;
mask = 0x07;
} else if ((c & 0x7C) == 0x78) {
prs->uni_max = 5;
mask = 0x03;
} else if ((c & 0x7E) == 0x7C) {
prs->uni_max = 6;
mask = 0x01;
} else {
return IKS_BADXML;
}
if ((c & mask) == 0) return IKS_BADXML;
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 (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);
}

152
libs/iksemel/src/sha.c Normal file

@ -0,0 +1,152 @@
/* 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 long hash[5];
unsigned long buf[80];
int blen;
unsigned long 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] = 0x67452301L;
sha->hash[1] = 0xefcdab89L;
sha->hash[2] = 0x98badcfeL;
sha->hash[3] = 0x10325476L;
sha->hash[4] = 0xc3d2e1f0L;
}
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, "%08lx", 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, 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 long)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 long 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, 0x5a827999L);
SHA (20, 39, B^C^D, 0x6ed9eba1L);
SHA (40, 59, (B&C)|(D&(B|C)), 0x8f1bbcdcL);
SHA (60, 79, B^C^D, 0xca62c1d6L);
sha->hash[0] += A;
sha->hash[1] += B;
sha->hash[2] += C;
sha->hash[3] += D;
sha->hash[4] += E;
}

605
libs/iksemel/src/stream.c Normal file

@ -0,0 +1,605 @@
/* 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_GNUTLS
#include <gnutls/gnutls.h>
#endif
#define SF_FOREIGN 1
#define SF_TRY_SECURE 2
#define SF_SECURE 4
struct stream_data {
iksparser *prs;
ikstack *s;
ikstransport *trans;
char *name_space;
void *user_data;
const char *server;
iksStreamHook *streamHook;
iksLogHook *logHook;
iks *current;
char *buf;
void *sock;
unsigned int flags;
char *auth_username;
char *auth_pass;
#ifdef HAVE_GNUTLS
gnutls_session sess;
gnutls_certificate_credentials cred;
#endif
};
#ifdef HAVE_GNUTLS
static size_t
tls_push (iksparser *prs, const char *buffer, size_t len)
{
struct stream_data *data = iks_user_data (prs);
int ret;
ret = data->trans->send (data->sock, buffer, len);
if (ret) return (size_t) -1;
return len;
}
static size_t
tls_pull (iksparser *prs, char *buffer, size_t len)
{
struct stream_data *data = iks_user_data (prs);
int ret;
ret = data->trans->recv (data->sock, buffer, len, -1);
if (ret == -1) return (size_t) -1;
return ret;
}
static int
handshake (struct stream_data *data)
{
const int protocol_priority[] = { GNUTLS_TLS1, GNUTLS_SSL3, 0 };
const int kx_priority[] = { GNUTLS_KX_RSA, 0 };
const int cipher_priority[] = { GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_ARCFOUR, 0};
const int comp_priority[] = { GNUTLS_COMP_ZLIB, GNUTLS_COMP_NULL, 0 };
const int mac_priority[] = { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0 };
int ret;
if (gnutls_global_init () != 0)
return IKS_NOMEM;
if (gnutls_certificate_allocate_credentials (&data->cred) < 0)
return IKS_NOMEM;
if (gnutls_init (&data->sess, GNUTLS_CLIENT) != 0) {
gnutls_certificate_free_credentials (data->cred);
return IKS_NOMEM;
}
gnutls_protocol_set_priority (data->sess, protocol_priority);
gnutls_cipher_set_priority(data->sess, cipher_priority);
gnutls_compression_set_priority(data->sess, comp_priority);
gnutls_kx_set_priority(data->sess, kx_priority);
gnutls_mac_set_priority(data->sess, mac_priority);
gnutls_credentials_set (data->sess, GNUTLS_CRD_CERTIFICATE, data->cred);
gnutls_transport_set_push_function (data->sess, (gnutls_push_func) tls_push);
gnutls_transport_set_pull_function (data->sess, (gnutls_pull_func) tls_pull);
gnutls_transport_set_ptr (data->sess, data->prs);
ret = gnutls_handshake (data->sess);
if (ret != 0) {
gnutls_deinit (data->sess);
gnutls_certificate_free_credentials (data->cred);
return IKS_NET_TLSFAIL;
}
data->flags &= (~SF_TRY_SECURE);
data->flags |= SF_SECURE;
iks_send_header (data->prs, data->server);
return IKS_OK;
}
#endif
static void
insert_attribs (iks *x, char **atts)
{
if (atts) {
int i = 0;
while (atts[i]) {
iks_insert_attrib (x, atts[i], atts[i+1]);
i += 2;
}
}
}
#define CNONCE_LEN 4
static void
iks_sasl_challenge (struct stream_data *data, iks *challenge)
{
char *b;
iks *x;
b = iks_cdata (iks_child (challenge));
if (!b) return;
b = iks_base64_decode (b);
if (strstr (b, "rspauth")) {
x = iks_new("response");
} else {
char *realm, *nonce, *charset = NULL, *algorithm = NULL;
char *realm_end, *nonce_end, cnonce[CNONCE_LEN*8 + 1];
unsigned char a1_h[16], a1[33], a2[33], response_value[33];
char *response, *response_coded;
iksmd5 *md5;
int i;
realm = strstr (b, "realm");
if (realm) {
realm += 7;
do {
realm_end = strchr(realm, '"');
} while (*(realm_end - 1) == '\\');
} else {
realm_end = 0;
realm = (char *) data->server;
}
nonce = strstr (b, "nonce");
if (nonce) {
nonce += 7;
do {
nonce_end = strchr (nonce, '"');
} while (*(nonce - 1) == '\\');
} else {
iks_free (b);
return;
}
charset = strstr (b, "charset");
if (charset) charset += 8;
algorithm = strstr (b, "algorithm");
if (algorithm) algorithm += 10;
if (realm_end) *realm_end = 0;
*nonce_end = 0;
for (i = 0; i < CNONCE_LEN; ++i)
sprintf (cnonce + i*8, "%08x", rand());
md5 = iks_md5_new();
iks_md5_hash (md5, data->auth_username, iks_strlen (data->auth_username), 0);
iks_md5_hash (md5, ":", 1, 0);
iks_md5_hash (md5, realm, iks_strlen (realm), 0);
iks_md5_hash (md5, ":", 1, 0);
iks_md5_hash (md5, data->auth_pass, iks_strlen (data->auth_pass), 1);
iks_md5_digest (md5, a1_h);
iks_md5_reset (md5);
iks_md5_hash (md5, a1_h, 16, 0);
iks_md5_hash (md5, ":", 1, 0);
iks_md5_hash (md5, nonce, iks_strlen (nonce), 0);
iks_md5_hash (md5, ":", 1, 0);
iks_md5_hash (md5, cnonce, iks_strlen (cnonce), 1);
iks_md5_print (md5, a1);
iks_md5_reset (md5);
iks_md5_hash (md5, "AUTHENTICATE:xmpp/", 18, 0);
iks_md5_hash (md5, data->server, iks_strlen (data->server), 1);
iks_md5_print (md5, a2);
iks_md5_reset (md5);
iks_md5_hash (md5, a1, 32, 0);
iks_md5_hash (md5, ":", 1, 0);
iks_md5_hash (md5, nonce, iks_strlen (nonce), 0);
iks_md5_hash (md5, ":00000001:", 10, 0);
iks_md5_hash (md5, cnonce, iks_strlen (cnonce), 0);
iks_md5_hash (md5, ":auth:", 6, 0);
iks_md5_hash (md5, a2, 32, 1);
iks_md5_print (md5, response_value);
iks_md5_delete (md5);
i = iks_strlen (data->auth_username) + iks_strlen (realm) +
iks_strlen (nonce) + iks_strlen (data->server) +
CNONCE_LEN*8 + 136;
response = iks_malloc (i);
sprintf (response, "username=\"%s\",realm=\"%s\",nonce=\"%s\""
",cnonce=\"%s\",nc=00000001,qop=auth,digest-uri=\""
"xmpp/%s\",response=%s,charset=utf-8",
data->auth_username, realm, nonce, cnonce,
data->server, response_value);
response_coded = iks_base64_encode (response, 0);
x = iks_new ("response");
iks_insert_cdata (x, response_coded, 0);
iks_free (response);
iks_free (response_coded);
}
iks_insert_attrib (x, "xmlns", IKS_NS_XMPP_SASL);
iks_send (data->prs, x);
iks_delete (x);
iks_free (b);
}
static int
tagHook (struct stream_data *data, char *name, char **atts, int type)
{
iks *x;
int err;
switch (type) {
case IKS_OPEN:
case IKS_SINGLE:
#ifdef HAVE_GNUTLS
if (data->flags & SF_TRY_SECURE) {
if (strcmp (name, "proceed") == 0) {
err = handshake (data);
return err;
} else if (strcmp (name, "failure") == 0){
return IKS_NET_TLSFAIL;
}
}
#endif
if (data->current) {
x = iks_insert (data->current, name);
insert_attribs (x, atts);
} else {
x = iks_new (name);
insert_attribs (x, atts);
if (iks_strcmp (name, "stream:stream") == 0) {
err = data->streamHook (data->user_data, IKS_NODE_START, x);
if (err != IKS_OK) return err;
break;
}
}
data->current = x;
if (IKS_OPEN == type) break;
case IKS_CLOSE:
x = data->current;
if (NULL == x) {
err = data->streamHook (data->user_data, IKS_NODE_STOP, NULL);
if (err != IKS_OK) return err;
break;
}
if (NULL == iks_parent (x)) {
data->current = NULL;
if (iks_strcmp (name, "challenge") == 0)
iks_sasl_challenge(data, x);
else if (iks_strcmp (name, "stream:error") == 0) {
err = data->streamHook (data->user_data, IKS_NODE_ERROR, x);
if (err != IKS_OK) return err;
} else {
err = data->streamHook (data->user_data, IKS_NODE_NORMAL, x);
if (err != IKS_OK) return err;
}
break;
}
data->current = iks_parent (x);
}
return IKS_OK;
}
static int
cdataHook (struct stream_data *data, char *cdata, size_t len)
{
if (data->current) iks_insert_cdata (data->current, cdata, len);
return IKS_OK;
}
static void
deleteHook (struct stream_data *data)
{
#ifdef HAVE_GNUTLS
if (data->flags & SF_SECURE) {
gnutls_bye (data->sess, GNUTLS_SHUT_WR);
gnutls_deinit (data->sess);
gnutls_certificate_free_credentials (data->cred);
}
#endif
if (data->trans) data->trans->close (data->sock);
data->trans = NULL;
if (data->current) iks_delete (data->current);
data->current = NULL;
data->flags = 0;
}
iksparser *
iks_stream_new (char *name_space, void *user_data, iksStreamHook *streamHook)
{
ikstack *s;
struct stream_data *data;
s = iks_stack_new (DEFAULT_STREAM_CHUNK_SIZE, 0);
if (NULL == s) return NULL;
data = iks_stack_alloc (s, sizeof (struct stream_data));
memset (data, 0, sizeof (struct stream_data));
data->s = s;
data->prs = iks_sax_extend (s, data, (iksTagHook *)tagHook, (iksCDataHook *)cdataHook, (iksDeleteHook *)deleteHook);
data->name_space = name_space;
data->user_data = user_data;
data->streamHook = streamHook;
return data->prs;
}
void *
iks_stream_user_data (iksparser *prs)
{
struct stream_data *data = iks_user_data (prs);
return data->user_data;
}
void
iks_set_log_hook (iksparser *prs, iksLogHook *logHook)
{
struct stream_data *data = iks_user_data (prs);
data->logHook = logHook;
}
int
iks_connect_tcp (iksparser *prs, const char *server, int port)
{
#ifdef USE_DEFAULT_IO
return iks_connect_with (prs, server, port, server, &iks_default_transport);
#else
return IKS_NET_NOTSUPP;
#endif
}
int
iks_connect_via (iksparser *prs, const char *server, int port, const char *server_name)
{
#ifdef USE_DEFAULT_IO
return iks_connect_with (prs, server, port, server_name, &iks_default_transport);
#else
return IKS_NET_NOTSUPP;
#endif
}
int
iks_connect_with (iksparser *prs, const char *server, int port, const char *server_name, ikstransport *trans)
{
struct stream_data *data = iks_user_data (prs);
int ret;
if (!trans->connect) return IKS_NET_NOTSUPP;
if (!data->buf) {
data->buf = iks_stack_alloc (data->s, NET_IO_BUF_SIZE);
if (NULL == data->buf) return IKS_NOMEM;
}
ret = trans->connect (prs, &data->sock, server, port);
if (ret) return ret;
data->trans = trans;
return iks_send_header (prs, server_name);
}
int
iks_connect_async (iksparser *prs, const char *server, int port, void *notify_data, iksAsyncNotify *notify_func)
{
#ifdef USE_DEFAULT_IO
return iks_connect_async_with (prs, server, port, server, &iks_default_transport, notify_data, notify_func);
#else
return IKS_NET_NOTSUPP;
#endif
}
int
iks_connect_async_with (iksparser *prs, const char *server, int port, const char *server_name, ikstransport *trans, void *notify_data, iksAsyncNotify *notify_func)
{
struct stream_data *data = iks_user_data (prs);
int ret;
if (NULL == trans->connect_async)
return IKS_NET_NOTSUPP;
if (!data->buf) {
data->buf = iks_stack_alloc (data->s, NET_IO_BUF_SIZE);
if (NULL == data->buf) return IKS_NOMEM;
}
ret = trans->connect_async (prs, &data->sock, server, server_name, port, notify_data, notify_func);
if (ret) return ret;
data->trans = trans;
data->server = server_name;
return IKS_OK;
}
int
iks_connect_fd (iksparser *prs, int fd)
{
#ifdef USE_DEFAULT_IO
struct stream_data *data = iks_user_data (prs);
if (!data->buf) {
data->buf = iks_stack_alloc (data->s, NET_IO_BUF_SIZE);
if (NULL == data->buf) return IKS_NOMEM;
}
data->sock = (void *) fd;
data->flags |= SF_FOREIGN;
data->trans = &iks_default_transport;
return IKS_OK;
#else
return IKS_NET_NOTSUPP;
#endif
}
int
iks_fd (iksparser *prs)
{
struct stream_data *data = iks_user_data (prs);
return (int) data->sock;
}
int
iks_recv (iksparser *prs, int timeout)
{
struct stream_data *data = iks_user_data (prs);
int len, ret;
while (1) {
#ifdef HAVE_GNUTLS
if (data->flags & SF_SECURE) {
len = gnutls_record_recv (data->sess, data->buf, NET_IO_BUF_SIZE - 1);
} else
#endif
{
len = data->trans->recv (data->sock, data->buf, NET_IO_BUF_SIZE - 1, timeout);
}
if (len < 0) return IKS_NET_RWERR;
if (len == 0) break;
data->buf[len] = '\0';
if (data->logHook) data->logHook (data->user_data, data->buf, len, 1);
ret = iks_parse (prs, data->buf, len, 0);
if (ret != IKS_OK) return ret;
if (!data->trans) {
/* stream hook called iks_disconnect */
return IKS_NET_NOCONN;
}
timeout = 0;
}
return IKS_OK;
}
int
iks_send_header (iksparser *prs, const char *to)
{
struct stream_data *data = iks_user_data (prs);
char *msg;
int len, err;
len = 91 + strlen (data->name_space) + 6 + strlen (to) + 16 + 1;
msg = iks_malloc (len);
if (!msg) return IKS_NOMEM;
sprintf (msg, "<?xml version='1.0'?>"
"<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='"
"%s' to='%s' version='1.0'>", data->name_space, to);
err = iks_send_raw (prs, msg);
iks_free (msg);
if (err) return err;
data->server = to;
return IKS_OK;
}
int
iks_send (iksparser *prs, iks *x)
{
return iks_send_raw (prs, iks_string (iks_stack (x), x));
}
int
iks_send_raw (iksparser *prs, const char *xmlstr)
{
struct stream_data *data = iks_user_data (prs);
int ret;
#ifdef HAVE_GNUTLS
if (data->flags & SF_SECURE) {
if (gnutls_record_send (data->sess, xmlstr, strlen (xmlstr)) < 0) return IKS_NET_RWERR;
} else
#endif
{
ret = data->trans->send (data->sock, xmlstr, strlen (xmlstr));
if (ret) return ret;
}
if (data->logHook) data->logHook (data->user_data, xmlstr, strlen (xmlstr), 0);
return IKS_OK;
}
void
iks_disconnect (iksparser *prs)
{
iks_parser_reset (prs);
}
/***** tls api *****/
int
iks_has_tls (void)
{
#ifdef HAVE_GNUTLS
return 1;
#else
return 0;
#endif
}
int
iks_is_secure (iksparser *prs)
{
#ifdef HAVE_GNUTLS
struct stream_data *data = iks_user_data (prs);
return data->flags & SF_SECURE;
#else
return 0;
#endif
}
int
iks_start_tls (iksparser *prs)
{
#ifdef HAVE_GNUTLS
int ret;
struct stream_data *data = iks_user_data (prs);
ret = iks_send_raw (prs, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");
if (ret) return ret;
data->flags |= SF_TRY_SECURE;
return IKS_OK;
#else
return IKS_NET_NOTSUPP;
#endif
}
/***** sasl *****/
int
iks_start_sasl (iksparser *prs, enum ikssasltype type, char *username, char *pass)
{
iks *x;
x = iks_new ("auth");
iks_insert_attrib (x, "xmlns", IKS_NS_XMPP_SASL);
switch (type) {
case IKS_SASL_PLAIN: {
int len = iks_strlen (username) + iks_strlen (pass) + 2;
char *s = iks_malloc (80+len);
char *base64;
iks_insert_attrib (x, "mechanism", "PLAIN");
sprintf (s, "%c%s%c%s", 0, username, 0, pass);
base64 = iks_base64_encode (s, len);
iks_insert_cdata (x, base64, 0);
iks_free (base64);
iks_free (s);
break;
}
case IKS_SASL_DIGEST_MD5: {
struct stream_data *data = iks_user_data (prs);
iks_insert_attrib (x, "mechanism", "DIGEST-MD5");
data->auth_username = username;
data->auth_pass = pass;
break;
}
default:
iks_delete (x);
return IKS_NET_NOTSUPP;
}
iks_send (prs, x);
iks_delete (x);
return IKS_OK;
}

180
libs/iksemel/src/utility.c Normal file

@ -0,0 +1,180 @@
/* 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_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;
}

@ -0,0 +1,33 @@
##
## Process this file with automake to produce Makefile.in
##
INCLUDES = -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

@ -0,0 +1,415 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AR = @AR@
AS = @AS@
CC = @CC@
CXX = @CXX@
CXXCPP = @CXXCPP@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
GCJ = @GCJ@
GCJFLAGS = @GCJFLAGS@
HAVE_LIB = @HAVE_LIB@
LIB = @LIB@
LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIB = @LTLIB@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
RC = @RC@
STRIP = @STRIP@
VERSION = @VERSION@
INCLUDES = -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
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../include/config.h
CONFIG_CLEAN_FILES =
noinst_PROGRAMS = tst-ikstack$(EXEEXT) tst-iks$(EXEEXT) \
tst-sax$(EXEEXT) tst-dom$(EXEEXT) tst-sha$(EXEEXT) tst-md5$(EXEEXT) \
tst-filter$(EXEEXT) tst-jid$(EXEEXT)
PROGRAMS = $(noinst_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir) -I../include
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
tst_ikstack_OBJECTS = tst-ikstack.$(OBJEXT)
tst_ikstack_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
tst_ikstack_LDFLAGS =
tst_iks_OBJECTS = tst-iks.$(OBJEXT)
tst_iks_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
tst_iks_LDFLAGS =
tst_sax_OBJECTS = tst-sax.$(OBJEXT)
tst_sax_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
tst_sax_LDFLAGS =
tst_dom_OBJECTS = tst-dom.$(OBJEXT)
tst_dom_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
tst_dom_LDFLAGS =
tst_sha_OBJECTS = tst-sha.$(OBJEXT)
tst_sha_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
tst_sha_LDFLAGS =
tst_md5_OBJECTS = tst-md5.$(OBJEXT)
tst_md5_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
tst_md5_LDFLAGS =
tst_filter_OBJECTS = tst-filter.$(OBJEXT)
tst_filter_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
tst_filter_LDFLAGS =
tst_jid_OBJECTS = tst-jid.$(OBJEXT)
tst_jid_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
tst_jid_LDFLAGS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
SOURCES = $(tst_ikstack_SOURCES) $(tst_iks_SOURCES) $(tst_sax_SOURCES) $(tst_dom_SOURCES) $(tst_sha_SOURCES) $(tst_md5_SOURCES) $(tst_filter_SOURCES) $(tst_jid_SOURCES)
OBJECTS = $(tst_ikstack_OBJECTS) $(tst_iks_OBJECTS) $(tst_sax_OBJECTS) $(tst_dom_OBJECTS) $(tst_sha_OBJECTS) $(tst_md5_OBJECTS) $(tst_filter_OBJECTS) $(tst_jid_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .lo .o .obj .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps test/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-noinstPROGRAMS:
clean-noinstPROGRAMS:
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
distclean-noinstPROGRAMS:
maintainer-clean-noinstPROGRAMS:
.c.o:
$(COMPILE) -c $<
# FIXME: We should only use cygpath when building on Windows,
# and only if it is available.
.c.obj:
$(COMPILE) -c `cygpath -w $<`
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
-rm -f *.$(OBJEXT)
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
tst-ikstack$(EXEEXT): $(tst_ikstack_OBJECTS) $(tst_ikstack_DEPENDENCIES)
@rm -f tst-ikstack$(EXEEXT)
$(LINK) $(tst_ikstack_LDFLAGS) $(tst_ikstack_OBJECTS) $(tst_ikstack_LDADD) $(LIBS)
tst-iks$(EXEEXT): $(tst_iks_OBJECTS) $(tst_iks_DEPENDENCIES)
@rm -f tst-iks$(EXEEXT)
$(LINK) $(tst_iks_LDFLAGS) $(tst_iks_OBJECTS) $(tst_iks_LDADD) $(LIBS)
tst-sax$(EXEEXT): $(tst_sax_OBJECTS) $(tst_sax_DEPENDENCIES)
@rm -f tst-sax$(EXEEXT)
$(LINK) $(tst_sax_LDFLAGS) $(tst_sax_OBJECTS) $(tst_sax_LDADD) $(LIBS)
tst-dom$(EXEEXT): $(tst_dom_OBJECTS) $(tst_dom_DEPENDENCIES)
@rm -f tst-dom$(EXEEXT)
$(LINK) $(tst_dom_LDFLAGS) $(tst_dom_OBJECTS) $(tst_dom_LDADD) $(LIBS)
tst-sha$(EXEEXT): $(tst_sha_OBJECTS) $(tst_sha_DEPENDENCIES)
@rm -f tst-sha$(EXEEXT)
$(LINK) $(tst_sha_LDFLAGS) $(tst_sha_OBJECTS) $(tst_sha_LDADD) $(LIBS)
tst-md5$(EXEEXT): $(tst_md5_OBJECTS) $(tst_md5_DEPENDENCIES)
@rm -f tst-md5$(EXEEXT)
$(LINK) $(tst_md5_LDFLAGS) $(tst_md5_OBJECTS) $(tst_md5_LDADD) $(LIBS)
tst-filter$(EXEEXT): $(tst_filter_OBJECTS) $(tst_filter_DEPENDENCIES)
@rm -f tst-filter$(EXEEXT)
$(LINK) $(tst_filter_LDFLAGS) $(tst_filter_OBJECTS) $(tst_filter_LDADD) $(LIBS)
tst-jid$(EXEEXT): $(tst_jid_OBJECTS) $(tst_jid_DEPENDENCIES)
@rm -f tst-jid$(EXEEXT)
$(LINK) $(tst_jid_LDFLAGS) $(tst_jid_OBJECTS) $(tst_jid_LDADD) $(LIBS)
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP))
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = test
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
check-TESTS: $(TESTS)
@failed=0; all=0; \
srcdir=$(srcdir); export srcdir; \
for tst in $(TESTS); do \
if test -f $$tst; then dir=.; \
else dir="$(srcdir)"; fi; \
if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \
all=`expr $$all + 1`; \
echo "PASS: $$tst"; \
elif test $$? -ne 77; then \
all=`expr $$all + 1`; \
failed=`expr $$failed + 1`; \
echo "FAIL: $$tst"; \
fi; \
done; \
if test "$$failed" -eq 0; then \
banner="All $$all tests passed"; \
else \
banner="$$failed of $$all tests failed"; \
fi; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
echo "$$dashes"; \
test "$$failed" -eq 0
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am:
uninstall: uninstall-am
all-am: Makefile $(PROGRAMS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-noinstPROGRAMS mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-noinstPROGRAMS clean-compile clean-libtool clean-tags \
clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-noinstPROGRAMS distclean-compile \
distclean-libtool distclean-tags distclean-generic \
clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-noinstPROGRAMS \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-tags maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \
clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir check-TESTS \
info-am info dvi-am dvi check check-am installcheck-am installcheck \
install-exec-am install-exec install-data-am install-data install-am \
install uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

164
libs/iksemel/test/tst-dom.c Normal file

@ -0,0 +1,164 @@
/* 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;
}

@ -0,0 +1,260 @@
/* 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;
}

@ -0,0 +1,56 @@
/* 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>";
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);
return 0;
}

@ -0,0 +1,54 @@
/* 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 (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;
}

@ -0,0 +1,63 @@
/* 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;
}

@ -0,0 +1,38 @@
/* 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;
}

384
libs/iksemel/test/tst-sax.c Normal file

@ -0,0 +1,384 @@
/* 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[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;
}

@ -0,0 +1,38 @@
/* 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;
}

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

@ -0,0 +1,355 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AR = @AR@
AS = @AS@
CC = @CC@
CXX = @CXX@
CXXCPP = @CXXCPP@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
GCJ = @GCJ@
GCJFLAGS = @GCJFLAGS@
HAVE_LIB = @HAVE_LIB@
LIB = @LIB@
LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIB = @LTLIB@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
RC = @RC@
STRIP = @STRIP@
VERSION = @VERSION@
INCLUDES = -I$(top_srcdir)/include
bin_PROGRAMS = ikslint iksroster iksperf
noinst_HEADERS = perf.h
ikslint_LDADD = $(top_builddir)/src/libiksemel.la
ikslint_SOURCES = ikslint.c hash.c
iksroster_LDADD = $(top_builddir)/src/libiksemel.la
iksroster_SOURCES = iksroster.c
iksperf_LDADD = $(top_builddir)/src/libiksemel.la
iksperf_SOURCES = iksperf.c perf.c
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../include/config.h
CONFIG_CLEAN_FILES =
bin_PROGRAMS = ikslint$(EXEEXT) iksroster$(EXEEXT) iksperf$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir) -I../include
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
ikslint_OBJECTS = ikslint.$(OBJEXT) hash.$(OBJEXT)
ikslint_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
ikslint_LDFLAGS =
iksroster_OBJECTS = iksroster.$(OBJEXT)
iksroster_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
iksroster_LDFLAGS =
iksperf_OBJECTS = iksperf.$(OBJEXT) perf.$(OBJEXT)
iksperf_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
iksperf_LDFLAGS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS = $(noinst_HEADERS)
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
SOURCES = $(ikslint_SOURCES) $(iksroster_SOURCES) $(iksperf_SOURCES)
OBJECTS = $(ikslint_OBJECTS) $(iksroster_OBJECTS) $(iksperf_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .lo .o .obj .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps tools/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-binPROGRAMS:
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
distclean-binPROGRAMS:
maintainer-clean-binPROGRAMS:
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \
echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
list='$(bin_PROGRAMS)'; for p in $$list; do \
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
done
.c.o:
$(COMPILE) -c $<
# FIXME: We should only use cygpath when building on Windows,
# and only if it is available.
.c.obj:
$(COMPILE) -c `cygpath -w $<`
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
-rm -f *.$(OBJEXT)
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
ikslint$(EXEEXT): $(ikslint_OBJECTS) $(ikslint_DEPENDENCIES)
@rm -f ikslint$(EXEEXT)
$(LINK) $(ikslint_LDFLAGS) $(ikslint_OBJECTS) $(ikslint_LDADD) $(LIBS)
iksroster$(EXEEXT): $(iksroster_OBJECTS) $(iksroster_DEPENDENCIES)
@rm -f iksroster$(EXEEXT)
$(LINK) $(iksroster_LDFLAGS) $(iksroster_OBJECTS) $(iksroster_LDADD) $(LIBS)
iksperf$(EXEEXT): $(iksperf_OBJECTS) $(iksperf_DEPENDENCIES)
@rm -f iksperf$(EXEEXT)
$(LINK) $(iksperf_LDFLAGS) $(iksperf_OBJECTS) $(iksperf_LDADD) $(LIBS)
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP))
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = tools
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-binPROGRAMS
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-binPROGRAMS
uninstall: uninstall-am
all-am: Makefile $(PROGRAMS) $(HEADERS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(bindir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-binPROGRAMS clean-compile clean-libtool clean-tags \
clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-binPROGRAMS distclean-compile distclean-libtool \
distclean-tags distclean-generic clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-binPROGRAMS \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-tags maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

144
libs/iksemel/tools/hash.c Normal file

@ -0,0 +1,144 @@
/* 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 tag *), 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);
}

@ -0,0 +1,283 @@
/* 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;
}

@ -0,0 +1,316 @@
/* 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;
char *xml;
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 ();
xml = 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;
}

@ -0,0 +1,379 @@
/* 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':
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
return 0;
}

84
libs/iksemel/tools/perf.c Normal file

@ -0,0 +1,84 @@
/* 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);
}

10
libs/iksemel/tools/perf.h Normal file

@ -0,0 +1,10 @@
/* 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);

@ -3,7 +3,7 @@ LDFLAGS += -ldingaling
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
depends:
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install iksemel-1.2.tar.gz --prefix=$(PREFIX)
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install iksemel --prefix=$(PREFIX)
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libdingaling --prefix=$(PREFIX)

@ -3,7 +3,7 @@ LDFLAGS += -liksemel -L/usr/local/lib
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
depends:
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install iksemel-1.2.tar.gz --prefix=$(PREFIX)
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install iksemel --prefix=$(PREFIX)
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o