pax_global_header 0000666 0000000 0000000 00000000064 12547225624 0014523 g ustar 00root root 0000000 0000000 52 comment=fcef533525875fb4c8bdf7f011b67396d9d305b4
termdebug-2.2+dfsg/ 0000775 0000000 0000000 00000000000 12547225624 0014263 5 ustar 00root root 0000000 0000000 termdebug-2.2+dfsg/COPYING 0000664 0000000 0000000 00000104513 12547225624 0015322 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, 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
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
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 3 of the License, 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, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
termdebug-2.2+dfsg/Changelog 0000664 0000000 0000000 00000002472 12547225624 0016102 0 ustar 00root root 0000000 0000000 Version 2.2:
- Fixed bug in configure script which prevented compilation with pthreads
Version 2.1:
- Fixed incorrect output of window_size directive in tdrerecord
- Fixed several print formatting issues
- Reset the terminal to blocking mode after exit
- Fixed several build issues with different combinations of available
libraries
Version 2.0:
- Added visual comparison mode, which emulates a terminal and compares the
emulated outputs
- Added a program to compare two recordings
- Changed handling of expect in tdreplay, such that it now waits for the
amount of time specified by the next send or window_size event
- Added optional minimum delay to send events and window_size events to
force a wait even if the key delay setting causes a smaller wait
- Fixed incorrect printing of line numbers in parse errors
Version 1.2:
- Added an option to tdrecord to prevent clearing of the DISPLAY
environment variable
- Fixed handling of octal escapes in strings for octal numbers starting
with 4 through 7
- Fixed handling of unknown escape sequences in strings
- Fixed handling of -- for tdrecord
Version 1.1:
- Added code to reset terminal to sane values after abort when replaying
in display mode
Version 1.0:
- Initial release
termdebug-2.2+dfsg/Makefile.in 0000664 0000000 0000000 00000003630 12547225624 0016332 0 ustar 00root root 0000000 0000000 # Copyright (C) 2006-2010,2012-2013 G.P. Halkes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# 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, see .
.POSIX:
# C-compiler flags
CFLAGS=-O2 -Isrc
CONFIGFLAGS=
CONFIGLIBS=
INSTALL=install
SILENTCC=@echo '[CC]' $< ;
SILENTLD=@echo '[LD]' $@ ;
prefix=/usr/local
bindir=$(prefix)/bin
docdir=$(prefix)/share/doc/termdebug
mandir=$(prefix)/share/man
OBJECTS=src/input_lex.o src/common.o src/replay.o src/view.o src/rerecord.o src/compare.o src/record.o src/input.o
OPTOBJECTS=
all: termdebug
.PHONY: all clean install
clean:
rm -rf src/*.o
dist-clean: clean
rm -rf tdrecord tdreplay tdrerecord tdview tdcompare config.log Makefile
.c.o:
$(SILENTCC) $(CC) $(CFLAGS) $(CONFIGFLAGS) -c -o $@ $<
termdebug: $(OBJECTS) $(OPTOBJECTS)
$(SILENTLD) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(OPTOBJECTS) $(LDLIBS) $(CONFIGLIBS)
# Macros to make DESTDIR support more readable
_bindir=$(DESTDIR)$(bindir)
_docdir=$(DESTDIR)$(docdir)
_mandir=$(DESTDIR)$(mandir)
install: all
$(INSTALL) -d "$(_bindir)"
$(INSTALL) termdebug "$(_bindir)"
cd "$(_bindir)" && ln -s termdebug tdrecord
cd "$(_bindir)" && ln -s termdebug tdreplay
cd "$(_bindir)" && ln -s termdebug tdrerecord
cd "$(_bindir)" && ln -s termdebug tdview
cd "$(_bindir)" && ln -s termdebug tdcompare
$(INSTALL) -d "$(_mandir)/man1"
$(INSTALL) -m 644 man/*.1 "$(_mandir)/man1"
$(INSTALL) -d "$(_docdir)"
$(INSTALL) -m 644 README COPYING Changelog "$(_docdir)"
termdebug-2.2+dfsg/README 0000664 0000000 0000000 00000005307 12547225624 0015150 0 ustar 00root root 0000000 0000000 Introduction
============
Termdebug is a set of utilities to record and replay the input and output of a
terminal program. Its main goal is to aid in developing and debugging terminal
programs. Other programs such as termrec/termplay, nethack-recorder/player and
script/scriptreplay only record the output. However, when debugging an
interactive terminal program, the input is often more important than the
output.
Motivation
==========
When developing an interactive terminal program, bugs can be very hard to track
down, as a specific sequence of actions may have triggered the bug. Usually one
stumbles upon a bug when doing undirected testing, and it is unclear which
sequence of actions triggered it. Moreover, it is often hard, if not
impossible, to recreate such a sequence from memory.
Termdebug allows you to record the input and output of your testing sessions
such that if you stumble upon a bug, you have a record of what you did. This
record can then be replayed to the program to recreate the exact circumstances
that triggered the bug.
A second use of termdebug is testsuites for interactive terminal programs. The
tdreplay program can verify that the output of the program is the same as the
recorded output. By building a set of testcases with known output you can
verify that changes to the program don't affect the output behaviour of the
program, or only those parts of the behaviour that you intended.
Utilities
=========
tdrecord Starts a program and records its input and output.
tdreplay Starts a program and replays the input of a recording.
tdview Shows the output of a recording.
tdrerecord Starts a program and replays the input of a recording,
recording the input and output to create a new recording.
tdcompare Compares two recordings.
Prerequisites and Installation
==============================
Termdebug can provide optional (but recommended) functionality. This requires
at least ncurses, to add a visual comparison mode.
If further iconv, libunistring, Cairo and Pango are installed, pictures can be
generated of the visual differences. Finally, if pthread is available, tdreplay
will also include the option to generate a sequence of pictures showing the
progression of the terminal output.
To compile and install termdebug:
$ ./configure
or
$ ./configure --prefix=/usr
(see ./configure --help for more tuning options)
$ make all
$ make install
Reporting Bugs
==============
If you think you have found a bug, please check that you are using the latest
version of termdebug [http://os.ghalkes.nl/termdebug.html]. When reporting bugs,
please include a minimal example that demonstrates the problem.
Author
======
Gertjan Halkes
termdebug-2.2+dfsg/config.pkg 0000664 0000000 0000000 00000034433 12547225624 0016242 0 ustar 00root root 0000000 0000000 # Copyright (C) 2010,2012-2013 G.P. Halkes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# 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, see .
EXTENSIONS="c pkgconfig_dep verbose_compile"
checkfunction() {
CHECKFOR="$1"
CODE="$2"
shift 2
{
while [ $# -ne 0 ]
do
if [ "x$1" = "x--" ]
then
shift
break
fi
echo "#include $1"
shift
done
cat < .config.c
clean .config.o .config
test_link "${CHECKFOR}" "$@"
}
config() {
unset CONFIGFLAGS CONFIGLIBS
# Test for all required functionality
cat > .config.c <
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main(int argc, char *argv[]) {
char *args[2];
struct timeval tv;
struct winsize wsz;
struct timespec ts;
int fd[2];
struct sigaction sa;
sigset_t ss;
struct termios tios;
execvp("test", args);
fcntl(0, F_SETFL, 0);
fileno(stdin);
fork();
getcwd(args[0], 0);
gettimeofday(&tv, NULL);
ioctl(0, TIOCGWINSZ, &wsz);
isatty(0);
kill(0, SIGTERM);
localtime((time_t) 0);
nanosleep(&ts, &ts);
pipe(fd);
read(0, args[0], 1);
write(0, args[0], 1);
close(0);
setenv("NAME", "VALUE", 1);
unsetenv("NAME");
sigaction(SIGWINCH, &sa, &sa);
sigemptyset(&ss);
sigaddset(&ss, SIGCHLD);
sigprocmask(SIG_UNBLOCK, &ss, NULL);
sleep(3);
snprintf(args[0], 1, "foo%d", 1);
tcgetattr(0, &tios);
tcsetattr(0, TCSAFLUSH, &tios);
umask((mode_t) 0077);
unlink("PATH");
waitpid(0, fd, WNOHANG | WUNTRACED);
basename("foo");
}
EOF
clean .config.o
test_link "required functions" || {
check_message_result "Testing required functions seperatly for debugging purposes"
checkfunction "execvp" 'char *args[2]; execvp("test", args);' ""
checkfunction "fcntl" "fcntl(0, F_SETFL, 0);" "" ""
checkfunction "fileno" "fileno(stdin);" ""
checkfunction "fork" "fork();" ""
checkfunction "getcwd" 'char *args[2]; getcwd(args[0], 0);' ""
checkfunction "gettimeofday" "struct timeval tv; gettimeofday(&tv, NULL);" "" ""
checkfunction "ioctl" "struct winsize wsz; ioctl(0, TIOCGWINSZ, &wsz);" ""
checkfunction "isatty" "isatty(0);" ""
checkfunction "kill" "kill(0, SIGTERM);" "" ""
checkfunction "localtime" "localtime((time_t) 0);" ""
checkfunction "nanosleep" "struct timespec ts; nanosleep(&ts, &ts);" ""
checkfunction "pipe" "int fd[2]; pipe(fd);" ""
checkfunction "read" "char *args[2]; read(0, args[0], 1);" ""
checkfunction "write" "char *args[2]; write(0, args[0], 1);" ""
checkfunction "close" "close(0);" ""
checkfunction "setenv" 'setenv("NAME", "VALUE", 1);' ""
checkfunction "unsetenv" 'unsetenv("NAME");' ""
checkfunction "sigaction" "struct sigaction sa; sigaction(SIGWINCH, &sa, &sa);" ""
checkfunction "sigemptyset" "sigset_t ss; sigemptyset(&ss);" ""
checkfunction "sigaddset" "sigset_t ss; sigaddset(&ss, SIGCHLD);" ""
checkfunction "sigprocmask" "sigset_t ss; sigprocmask(SIG_UNBLOCK, &ss, NULL);" "" ""
checkfunction "sleep" "sleep(3);" ""
checkfunction "snprintf" 'char *args[2]; snprintf(args[0], 1, "foo%d", 1);' ""
checkfunction "tcgetattr" "struct termios tios; tcgetattr(0, &tios);" "" ""
checkfunction "tcsetattr" "struct termios tios; tcsetattr(0, TCSAFLUSH, &tios);" "" ""
checkfunction "umask" "umask((mode_t) 0077);" "" ""
checkfunction "unlink" 'unlink("PATH");' ""
checkfunction "waitpid" "int fd[2]; waitpid(0, fd, WNOHANG | WUNTRACED);" "" ""
checkfunction "basename" 'basename("foo");' ""
check_message_result "!! A required function is not available."
exit 1
}
checkfunction "strdup" "strdup(\"foo\");" "" && CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_STRDUP"
if checkfunction "poll" "struct pollfd fds[1]; fds[0].events = POLLIN; poll(fds, 1, 1);" ""
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_POLL"
else
if checkfunction "select in sys/select.h" "fd_set readfds; struct timeval timeout; select(&readfds, NULL, NULL, NULL, &timeout);" "" ""
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_SYS_SELECT_H"
elif not checkfunction "select in old header files" "fd_set readfds; struct timeval timeout; select(&readfds, NULL, NULL, NULL, &timeout);" "" "" "" ""
then
check_message_result "!! Could not find select"
exit 1
fi
fi
unset NEED_LIBUTIL
if checkfunction "openpty in pty.h" "int a; struct winsize wsz; openpty(&a, &a, NULL, NULL, &wsz);" "" "" -- "TESTLIBS=-lutil"
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_OPENPTY"
NEED_LIBUTIL=1
elif checkfunction "openpty in util.h" "int a; struct winsize wsz; openpty(&a, &a, NULL, NULL, &wsz);" "" "" "" "" "" -- "TESTLIBS=-lutil"
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_OPENPTY -DOPENPTY_IN_UTIL_H"
NEED_LIBUTIL=1
elif checkfunction "openpty in libutil.h" "int a; struct winsize wsz; openpty(&a, &a, NULL, NULL, &wsz);" "" "" "" "" "" -- "TESTLIBS=-lutil"
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_OPENPTY -DOPENPTY_IN_LIBUTIL_H"
NEED_LIBUTIL=1
else
cat > .config.c <
#include
#include
int main(int argc, char *argv[]) {
grantpt(0);
unlockpt(0);
ptsname(0);
open("foo", O_RDWR | O_NOCTTY);
}
EOF
clean .config.o
test_link "required functions for openpty work-around" || {
check_message_result "Testing required functions seperatly for debugging purposes"
checkfunction "grantpt" "grantpt(0);" ""
checkfunction "unlockpt" "unlockpt(0);" ""
checkfunction "ptsname" "ptsname(0);" ""
checkfunction "open" 'open("foo", O_RDWR | O_NOCTTY);' "" ""
check_message_result "!! Did not find any method to open a new pseudo terminal."
exit 1
}
if checkfunction "posix_openpt" "posix_openpt(O_RDWR | O_NOCTTY);" "" ""
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_POSIX_OPENPT"
else
check_message "Checking for /dev/ptmx... "
if not [ -c "/dev/ptmx" ]
then
check_message_result "no"
check_message_result "!! Did not find a method to open a new pseudo terminal."
exit 1
fi
check_message_result "yes"
fi
fi
if checkfunction "login_tty in utmp.h" "login_tty(0);" "" -- "TESTLIBS=-lutil"
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_LOGIN_TTY"
NEED_LIBUTIL=1
elif checkfunction "login_tty in util.h" "login_tty(0);" "" "" -- "TESTLIBS=-lutil"
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_LOGIN_TTY -DLOGIN_TTY_IN_UTIL_H"
NEED_LIBUTIL=1
elif checkfunction "login_tty in libutil.h" "login_tty(0);" "" "" "" "" -- "TESTLIBS=-lutil"
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_LOGIN_TTY -DLOGIN_TTY_IN_LIBUTIL_H"
NEED_LIBUTIL=1
else
cat > .config.c <
int main(int argc, char *argv[]) {
dup2(0, 1);
setsid();
}
EOF
clean .config.o
test_link "required functions for login_tty work-around" || {
check_message_result "Testing required functions seperatly for debugging purposes"
checkfunction "dup2" "dup2(0, 1);" ""
checkfunction "setsid" "unlockpt(0);" ""
check_message_result "!! Did not find a method to open a new pseudo terminal."
exit 1
}
fi
if checkfunction "forkpty in pty.h" "int a; struct winsize wsz; forkpty(&a, NULL, NULL, &wsz);" "" "" -- "TESTLIBS=-lutil"
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_FORKPTY"
NEED_LIBUTIL=1
elif checkfunction "forkpty in util.h" "int a; struct winsize wsz; forkpty(&a, NULL, NULL, &wsz);" "" "" "" "" "" -- "TESTLIBS=-lutil"
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_FORKPTY -DFORKPTY_IN_UTIL_H"
NEED_LIBUTIL=1
elif checkfunction "forkpty in libutil.h" "int a; struct winsize wsz; forkpty(&a, NULL, NULL, &wsz);" "" "" "" "" "" -- "TESTLIBS=-lutil"
then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_FORKPTY -DFORKPTY_IN_LIBUTIL_H"
NEED_LIBUTIL=1
fi
[ "x${NEED_LIBUTIL}" = "x1" ] && CONFIGLIBS="${CONFIGLIBS} -lutil"
unset CURSES_FOUND CURSES_LIBS CURSES_FLAGS
cat > .config.c <
#include
#include
int main(int argc, char *argv[]) {
setupterm(NULL, 1, NULL);
putp(tigetstr("smacs"));
return 0;
}
EOF
clean .config.o
if pkgconfig tinfo CURSES test_link ; then
CURSES_FOUND=1
elif pkgconfig ncurses CURSES test_link ; then
CURSES_FOUND=1
elif test_compile "curses header file" ; then
if test_link "terminfo access functions in -ltinfo" "TESTLIBS=-ltinfo" ; then
CURSES_LIBS="-ltinfo"
CURSES_FOUND=1
elif test_link "curses library in -lcurses" "TESTLIBS=-lcurses" ; then
CURSES_LIBS="-lcurses"
CURSES_FOUND=1
else
if test_link "ncurses library in -lncurses" "TESTLIBS=-lncurses" ; then
CURSES_LIBS="-lncurses"
CURSES_FOUND=1
fi
fi
fi
if [ "${CURSES_FOUND}" = 1 ] ; then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_CURSES ${CURSES_FLAGS}"
CONFIGLIBS="${CONFIGLIBS} ${CURSES_LIBS}"
OPTOBJECTS="${OPTOBJECTS} src/curses_handling.o"
KEEPGOING=1
else
check_message_result "!! Warning: compiling without curses. This means visual compare will not be available. Install the curses development package if you wish to compile with curses."
KEEPGOING=0
fi
if [ $KEEPGOING = 1 ] ; then
clean_c
cat > .config.c <
#include
int main(int argc, char *argv[]) {
int32_t c;
char nul;
uc_is_general_category_withtable(c, UC_CATEGORY_MASK_Cs);
uc_width(c, &nul);
return 0;
}
EOF
if test_link "libunistring" TESTLIBS="-lunistring" ; then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_UNISTRING"
CONFIGLIBS="${CONFIGLIBS} -lunistring"
OPTOBJECTS="${OPTOBJECTS} src/window.o src/write_stringlist.o"
else
check_message_result "!! Warning: compiling without libunistring. This means visual compare will not be available."
KEEPGOING=0
fi
fi
if [ $KEEPGOING = 1 ] ; then
clean_c
cat > .config.c <
#include
int main(int argc, char *argv[]) {
cairo_surface_write_to_png(NULL, NULL);
return 0;
}
EOF
pkgconfig cairo CAIRO test_link || KEEPGOING=0
fi
if [ $KEEPGOING = 1 ] ; then
clean_c
cat > .config.c <
#include
int main(int argc, char *argv[]) {
PangoFontDescription *font_desc = pango_font_description_new();
return 0;
}
EOF
pkgconfig pangocairo PANGOCAIRO test_link || KEEPGOING=0
fi
if [ $KEEPGOING = 1 ] ; then
clean_c
cat > .config.c <
int main(int argc, char *argv[]) {
iconv_t handle = iconv_open("UTF-8", "ISO-8859-1");
return 0;
}
EOF
if test_link "iconv" ; then
ICONVLIBS=
elif test_link "iconv in -liconv" TESTLIBS="-liconv" ; then
ICONVLIBS=-liconv
else
KEEPGOING=0
fi
fi
if [ $KEEPGOING = 1 ] ; then
CONFIGFLAGS="${CONFIGFLAGS} -DHAVE_CAIRO ${CAIRO_FLAGS} ${PANGOCAIRO_FLAGS}"
CONFIGLIBS="${CONFIGLIBS} -DHAVE_CAIRO ${CAIRO_LIBS} ${PANGOCAIRO_LIBS} -lunistring ${ICONVLIBS}"
OPTOBJECTS="${OPTOBJECTS} src/write_image.o"
else
check_message_result "!! Warning: compiling without cairo. This means that no images can be generated from tdreplay and tdcompare."
fi
if [ $KEEPGOING = 1 ] ; then
clean_c
unset PTHREADFLAGS PTHREADLIBS
PTHREAD_NOT_FOUND=0
cat > .config.c <
#include
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
pthread_t thread;
void *thread_func(void *arg) {
(void) arg;
return NULL;
}
int main(int argc, char *argv[]) {
void *result;
pthread_mutex_lock(&mutex);
pthread_mutex_unlock(&mutex);
pthread_cond_signal(&cond);
pthread_cond_wait(&cond, &mutex);
pthread_create(&thread, NULL, thread_func, NULL);
pthread_join(thread, &result);
return 0;
}
EOF
if not test_compile "pthreads" ; then
PTHREAD_NOT_FOUND=1
check_message_result "!! Can not find flags to compile with pthreads. Image writing will be done on main thread. See config.log for compile details."
else
test_compile "-pthread flag" && PTHREADFLAGS=-pthread
# Libtool sometimes adds -nostdlib, which then requires that -lpthread is specified
# separately. Therefore, we first test for -pthread -lpthread, then for
# -pthread, then -lpthread and if all else fails without anything
if [ -n "${PTHREADFLAGS}" ] && test_link "pthreads in ${PTHREADFLAGS} -lpthread" "TESTLIBS=${PTHREADFLAGS} -lpthread" ; then
PTHREADLIBS="${PTHREADFLAGS} -lpthread"
elif [ -n "${PTHREADFLAGS}" ] && test_link "pthreads in ${PTHREADFLAGS}" "TESTLIBS=${PTHREADFLAGS}" ; then
PTHREADLIBS="${PTHREADFLAGS}"
elif test_link "pthreads in -lpthread" TESTLIBS=-lpthread ; then
PTHREADLIBS=-lpthread
elif test_link "pthreads in standard library" "TESTLIBS=" ; then
:
else
PTHREAD_NOT_FOUND=1
check_message_result "!! Can not find flags to link with pthreads. tdreplay will not provide -P/--picture-series. See config.log for compile details."
fi
fi
if [ "$PTHREAD_NOT_FOUND" = 0 ] ; then
CONFIGFLAGS="${CONFIGFLAGS} ${PTHREADFLAGS}"
CONFIGLIBS="${CONFIGLIBS} ${PTHREADLIBS}"
OPTOBJECTS="${OPTOBJECTS} src/picture_queue.o"
fi
fi
create_makefile "CONFIGFLAGS=${CONFIGFLAGS}" "CONFIGLIBS=${CONFIGLIBS}" "OPTOBJECTS=${OPTOBJECTS}"
}
termdebug-2.2+dfsg/configure 0000775 0000000 0000000 00000027115 12547225624 0016200 0 ustar 00root root 0000000 0000000 #!/bin/sh
# Copyright (C) 2006-2007,2009,2011 G.P. Halkes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# 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, see .
# Set zsh to emulate sh (otherwise all kinds of eval's wont work)
[ -n "${ZSH_VERSION}" ] && emulate sh
#==============================
# Functions
#==============================
error() {
echo "$*"
[ -n "$DUMP_LOG" ] && cat config.log
exit 1
}
not() {
if "$@" ; then
false
else
true
fi
}
check() {
if not "$@" ; then
error "Error executing $*. Aborting."
fi
}
check_message() {
printf "$*"
echo "----------------------------------" >> config.log
echo "$*" >> config.log
}
check_message_result() {
echo "$*"
echo "$*" >> config.log
}
clean() {
rm -rf "$@" >/dev/null 2>&1
}
test_make() {
printf "%s" "Running: ${MAKE} -f .Makefile" >> config.log
for ARG in "$@"
do
printf " '%s'" "${ARG}" >> config.log
done
echo >> config.log
"${MAKE}" -f .Makefile "$@"
}
test_install() {
clean .foo
check_message "Checking for working install ($*)... "
if test_make "INSTALL=$*" "install" >> config.log 2>&1 ; then
check_message_result "yes"
true
else
check_message_result "no"
false
fi
}
test_and_set() {
SETTING="$4${5+ }$5"
if $1 "$2${SETTING+ in }${SETTING}" "TESTFLAGS=$4" "TESTLIBS=$5" ; then
eval "${3}_FLAGS=\"$4\""
eval "${3}_LIBS=\"$5\""
true
else
false
fi
}
add_replace_settings() {
for SETTING
do
echo "/^${SETTING%%=*}/s/^/# Disabled by configure: /"
echo "/\.POSIX/a\\
${SETTING}"
done
}
replace_default() {
if [ -n "$2" ] ; then
echo "/^$1=/c\\
$1=$2"
fi
}
insert() {
[ -n "$2" ] && echo "/^\\.POSIX:/a\\
$1=$2"
}
create_makefile() {
for _INSTALL in ${TEST_INSTALL}
do
# Don't test the sun install program, because it is dangerous.
if [ "`uname`" = "SunOS" ] && [ "$_INSTALL" = "install" ] ; then
continue
fi
test_install "${_INSTALL}" && INSTALL="${_INSTALL}" && break
done
if [ -z "${INSTALL}" ] ; then
check_message_result "!! No working install program found. The install target will not work."
fi
{
echo '/\.POSIX/a\
# Settings from configure script'
replace_default prefix "${PREFIX}"
for INSTALLDIR in ${INSTALLDIRS}
do
[ -n "`eval echo \\${option_${INSTALLDIR}}`" ] && replace_default "${INSTALLDIR}" "`eval echo \\${option_${INSTALLDIR}}`"
done
replace_default INSTALL "${INSTALL}"
insert LDFLAGS "${LDFLAGS}"
insert LDLIBS "${LDLIBS}"
for EXT in ${EXTENSIONS}
do
sed_rules_${EXT}
done
add_replace_settings "$@"
[ -n "${SEDEXTRA}" ] && ${SEDEXTRA}
} > .sedscript
for MAKEFILE in ${MAKEFILES:-Makefile}
do
echo "----------------------------------">> config.log
check_message_result "Creating ${MAKEFILE}"
cat ${MAKEFILE}.in | sed -f .sedscript > ${MAKEFILE}
done
clean .sedscript .Makefile .foo .config_base
for EXT in ${EXTENSIONS}
do
clean_${EXT}
done
exit 0
}
#==============================
# Setup
#==============================
unset LINKRULE COMPILERULE USERRULES USERHELP EXTENSIONS SWITCHES PRECHECKFUNC INSTALLDIRS DUMP_LOG
. ./config.pkg
for MAKEFILE in ${MAKEFILES:-Makefile}
do
[ -f ${MAKEFILE}.in ] || error "${MAKEFILE}.in does not exist"
grep "^\\.POSIX:" ${MAKEFILE}.in > /dev/null || error "${MAKEFILE}.in does not contain .POSIX target"
done
#@INCLUDE_START
[ "${EXTENSIONS}" = "c pkgconfig_dep verbose_compile" ] || error "EXTENSIONS changed after running merge_config. Run merge_config again."
SUFFIXES="${SUFFIXES} .c .o"
[ -z "${LINKRULE}" ] && LINKRULE='$(CC) $(CFLAGS) $(LDFLAGS) -o $@ .config.o $(LDLIBS) $(TESTLIBS)'
[ -z "${COMPILERULE}" ] && COMPILERULE='$(CC) $(CFLAGS) $(TESTFLAGS) -c -o $@ $<'
clean_c() {
clean .config .config.o .config.c
}
show_help_c() {
if [ "$1" = VARIABLES ] ; then
cat < .config.c <> config.log 2>&1 ; then
check_message_result "yes"
true
else
check_message_result "no"
echo "Source of the failed compile:" >> config.log
nl -ba .config.c >> config.log
false
fi
}
test_link() {
clean .config
check_message "Checking for $1... "
shift
if test_make "$@" .config >> config.log 2>&1 ; then
check_message_result "yes"
true
else
check_message_result "no"
echo "Source of the failed compile:" >> config.log
nl -ba .config.c >> config.log
false
fi
}
touch_c() {
[ -f .config.c ] && touch .config.c
}
unset HASPKGCONFIG
show_help_pkgconfig_dep() {
:
}
print_rules_pkgconfig_dep() {
:
}
clean_pkgconfig_dep() {
:
}
basic_test_pkgconfig_dep() {
:
}
sed_rules_pkgconfig_dep() {
:
}
pkgconfig() {
if [ -z "${HASPKGCONFIG}" ] ; then
check_message "Checking for pkg-config... "
echo "Running: pkg-config --variable pc_path pkg-config" >> .config.log
if pkg-config --variable pc_path pkg-config > /dev/null 2>>config.log ; then
check_message_result "yes"
HASPKGCONFIG=yes
else
check_message_result "no"
HASPKGCONFIG=no
fi
fi
PKGNAME="${1%/*}"
PKGVERSION="${1##*/}"
if [ "${PKGVERSION}" = "$1" ] ; then
unset PKGVERSION
else
PKGVERSION=" >= $PKGVERSION"
fi
if [ "${HASPKGCONFIG}" = no ] ; then
check_message_result "Skipping check for $PKGNAME pkg-config because pkg-config is unavailable"
return 2
fi
unset "${2}_FLAGS" "${2}_LIBS"
check_message "Checking for $PKGNAME$PKGVERSION pkg-config... "
echo "Running: pkg-config --print-errors --exists $PKGNAME$PKGVERSION" >> config.log
if not pkg-config --exists $PKGNAME $PKGVERSION 2>>config.log >/dev/null ; then
check_message_result "no"
return 1
fi
check_message_result "yes"
if [ $# -ge 3 ] ; then
if $3 "$PKGNAME pkg-config compile" "TESTFLAGS=\`pkg-config --cflags $PKGNAME\`" "TESTLIBS=\`pkg-config --libs $PKGNAME\`" 2>>config.log ; then
eval "${2}_FLAGS"="\"\\\`pkg-config --cflags $PKGNAME\\\`\""
eval "${2}_LIBS"="\"\\\`pkg-config --libs $PKGNAME\\\`\""
else
return 1
fi
[ $# -ge 4 ] && eval $4="\"\${$4:+\${$4}, }$PKGNAME$PKGVERSION\""
fi
return 0
}
SWITCHES="${SWITCHES} -verbose-compile"
clean_verbose_compile() {
:
}
show_help_verbose_compile() {
if [ "$1" = OPTIONS ] ; then
cat <] [=]
--dump-log Dump config.log to stdout on error
--prefix= Prefix for installation [/usr/local]
EOF
for INSTALLDIR in ${INSTALLDIRS}
do
case "${INSTALLDIR}" in
bindir) echo ' --bindir= Binaries directory [/bin]' ;;
sbindir) echo ' --sbindir= System binaries directory [/sbin]' ;;
libdir) echo ' --libdir= Library directory [/lib]' ;;
includedir) echo ' --includedir= Include file directory [/include]' ;;
datadir) echo ' --datadir= Directory for data [/share]' ;;
mandir) echo ' --mandir= Manual page directory [/share/man]' ;;
infodir) echo ' --infodir= Info page directory [/share/man]' ;;
docdir) echo ' --docdir= Document dir [/share/doc/-]' ;;
esac
done
[ -n "${USERINSTALLDIRSHELP}" ] && echo "${USERINSTALLDIRSHELP}"
for EXT in ${EXTENSIONS}
do
show_help_$EXT OPTIONS
done
cat <
INSTALL The install program to use
LDFLAGS Linker flags to use (default determined by make)
LDLIBS Extra libraries to link
EOF
for EXT in ${EXTENSIONS}
do
show_help_$EXT VARIABLES
done
[ -n "${USERHELP}" ] && { echo ; echo "Package specific settings" ; ${USERHELP} ; }
cat <&2
;;
--*)
unset _match
for _switch in ${_SWITCHES}
do
case "${PARAM}" in
--with-${_switch})
_name=`echo "${_switch}" | sed 's/-/_/g'`
eval with_${_name}="yes"
_match="1"
break
;;
--without-${_switch})
_name=`echo "${_switch}" | sed 's/-/_/g'`
eval with_${_name}="no"
_match="1"
break
;;
esac
done
[ -z "${_match}" ] && echo "WARNING: ignoring unknown parameter: ${PARAM}" >&2
;;
*=*)
name="${PARAM%%=*}"
value="${PARAM#*=}"
eval "${name}"="\"${value}\""
;;
*)
error "Error on commandline: ${PARAM}"
;;
esac
done
if [ -n "${INSTALL}" ] ; then
TEST_INSTALL="${INSTALL}"
unset INSTALL
else
TEST_INSTALL="install ./install.sh"
fi
echo "Configuration test log created at `date`" > config.log
echo "-- configure called with $0 $@" >> config.log
clean config.log .Makefile .sedscript .config_base
for EXT in ${EXTENSIONS}
do
clean_${EXT}
done
{
echo ".POSIX:"
[ -z "${LDFLAGS}" ] || echo "LDFLAGS=${LDFLAGS}"
[ -z "${LDLIBS}" ] || echo "LDLIBS=${LDLIBS}"
[ -z "${SUFFIXES}" ] || echo ".SUFFIXES: ${SUFFIXES}"
[ -z "${USERRULES}" ] || ${USERRULES}
cat < .Makefile
echo "Using settings:" >> config.log
grep '^[[:upper:]_]\+=' .Makefile >> config.log
[ -n "${MAKE}" ] || MAKE=make
[ -z "${PRECHECKFUNC}" ] || ${PRECHECKFUNC}
check_message "Checking for working make (${MAKE})... "
if test_make .config_base >> config.log 2>&1 ; then
check_message_result "yes"
else
check_message_result "no"
error "${MAKE} failed. See config.log for errors."
fi
for EXT in ${EXTENSIONS}
do
basic_test_${EXT}
done
config
error "Error in config.pkg. Cannot continue."
termdebug-2.2+dfsg/install.sh 0000775 0000000 0000000 00000006052 12547225624 0016273 0 ustar 00root root 0000000 0000000 #!/bin/sh
# Copyright (C) 2009 G.P. Halkes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# 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, see .
# Set zsh to emulate sh (otherwise all kinds of eval's wont work)
[ -n "${ZSH_VERSION}" ] && emulate sh
unset directory sources dest mode owner group strip
# Provide an alternative to !
not() {
if "$@" ; then
false
else
true
fi
}
# Default mode for install is rwxr-xr-x
mode="0755"
while [ $# -gt 0 ]
do
case "$1" in
-d)
directory="1"
;;
-m)
mode="$2"
shift
;;
-m*)
mode=`echo "$1" | sed 's/^-m//'`
;;
-o)
owner="$2"
shift
;;
-o*)
owner=`echo "$1" | sed 's/^-o//'`
;;
-g)
group="$2"
shift
;;
-g*)
group=`echo "$1" | sed 's/^-g//'`
;;
-s)
strip=1
;;
*)
break
;;
esac
shift
done
if [ "1" = "${directory}" ] ; then
if [ $# -eq 0 ] ; then
echo "No directory names supplied" >&2
exit 1
fi
# Create directories
while [ $# -gt 0 ]
do
if [ ! -d "$1" ] ; then
# Find name of dir to apply chown/chgrp -R to, i.e., the first part
# of the path that does not yet exist.
firstDir="$1"
testDir=`dirname "$1"`
while [ ! -d "${testDir}" ] ; do
firstDir="${testDir}"
testDir=`dirname "${firstDir}"`
done
# Make the directory
if not mkdir -p "$1" ; then
exit 1
fi
if not chmod -R "${mode}" "${firstDir}" ; then
exit 1
fi
# Set owner and group, if specified
if [ -n "${owner}" ] ; then
if not chown -R "${owner}" "${firstDir}" ; then
exit 1
fi
fi
if [ -n "${group}" ] ; then
if not chgrp -R "${group}" "${firstDir}" ; then
exit 1
fi
fi
fi
shift
done
exit
fi
if [ $# -lt 2 ] ; then
echo "No destination and/or source(s) supplied" >&2
exit 1
fi
install_file() {
if [ -d "$2" ] ; then
echo "Cannot install $2: directory in the way" >&2
exit 1
fi
# Copy file
if not cp "$1" "$2" ; then
exit 1
fi
# Set attributes
if [ -n "${mode}" ] ; then
if not chmod "${mode}" "$2" ; then
exit 1
fi
fi
if [ -n "${owner}" ] ; then
if not chown "${owner}" "$2" ; then
exit 1
fi
fi
if [ -n "${group}" ] ; then
if not chgrp "${group}" "$2" ; then
exit 1
fi
fi
if [ -n "${strip}" ] ; then
if not strip "$2" ; then
exit 1
fi
fi
}
eval dest="\"\${$#}\""
if [ -d "${dest}" ] ; then
# Loop over all sources, but do not process destination as source
while [ $# -gt 1 ]
do
install_file "$1" "${dest}/`basename \"$1\"`"
shift
done
elif [ $# -eq 2 ] ; then
install_file "$1" "${dest}"
else
echo "Multiple sources specified, but destination is not a directory" >&2
exit 1
fi
termdebug-2.2+dfsg/man/ 0000775 0000000 0000000 00000000000 12547225624 0015036 5 ustar 00root root 0000000 0000000 termdebug-2.2+dfsg/man/tdcompare.1 0000664 0000000 0000000 00000007373 12547225624 0017110 0 ustar 00root root 0000000 0000000 .\" Generated by manscript from tdcompare.1.txt
.TH "TDCOMPARE" "1" "2013/03/03" "2.2" "termdebug"
.SH NAME
tdcompare \- compare two recordings of a terminal program
.SH SYNOPSIS
\fBtdcompare\fR [\fIOPTIONS\fR]... \fIOLD\fR \fINEW\fR
.SH DESCRIPTION
\fBtdcompare\fR compares two recordings of a terminal program to determine whether
they represent the same output. The comparison can be both at the input/output
level, or at the visual level. When comparing at the input/output level, the
difference will be reported as line numbers in the \fIOLD\fR and \fINEW\fR files. For
visual comparisons, a textual description of the first difference can be
produced, and a picture of the first different terminal state can be
written (if \fBtermdebug\fR was compiled with Cairo support).
.PP
\fBtdcompare\fR is useful to verify that a new recording of the same program produced
the same result. To do on-line verification, use \fBtdreplay\fR(1) instead.
.SH OPTIONS
\fBtdcompare\fR accepts the following options:
.PP
.TP
\fB\-h\fR, \fB\-\-help\fR
Display a short help message.
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version and copyright information.
.TP
\fB\-v\fR, \fB\-\-visual\-compare\fR
Check for visual equality, rather than exact input/output behaviour.
(Requires a build with ncurses support.)
.TP
\fB\-D\fR, \fB\-\-describe\fR
Write a description of the first visual difference encountered. Only useful
with \fB\-v\fR/\fB\-\-visual\-compare\fR. (Requires a build with ncurses support.)
.TP
\fB\-p\fR \fIname\fR, \fB\-\-picture\fR=\fIname\fR
Write a picture of the difference to \fIname\fR. Only useful with
\fB\-v\fR/\fB\-\-visual\-compare\fR. (Requires a build with ncurses and Cairo support.)
.TP
\fB\-f\fR \fIfont\fR, \fB\-\-font\fR=\fIfont\fR
Use \fIfont\fR to show text in generated pictures. Only useful with
\fB\-p\fR/\fB\-\-picture\fR or \fB\-P\fR/\fB\-\-picture\-series\fR. (Requires a build with ncurses
and Cairo support.)
.TP
\fB\-W\fR \fIwidth\fR, \fB\-\-cell\-width\fR=\fIwidth\fR
Use cells of \fIwidth\fR pixels wide in generated pictures. Only useful with
\fB\-p\fR/\fB\-\-picture\fR or \fB\-P\fR/\fB\-\-picture\-series\fR. (Requires a build with ncurses
and Cairo support.)
.TP
\fB\-H\fR \fIheight\fR, \fB\-\-cell\-height\fR=\fIheight\fR
Use cells of \fIheight\fR pixels wide in generated pictures. Only useful with
\fB\-p\fR/\fB\-\-picture\fR or \fB\-P\fR/\fB\-\-picture\-series\fR. (Requires a build with ncurses
and Cairo support.)
.TP
\fB\-P\fR \fIname\fR, \fB\-\-picture\-series\fR=\fIname\fR
Create a series of pictures, representing the different visual steps in the
client interface, using \fIname\fR as the file name template. \fIname\fR is a
\fBprintf\fR(3) format string, where a single d-type conversion is required.
(Requires a build with ncurses and Cairo support.)
.TP
\fB\-s\fR, \fB\-\-stop\-on\-difference\fR
Stop when the first visual difference is found. Only valid with
\fB\-P\fR/\fB\-\-picture\-series\fR.
.PP
To stop \fBtdcompare\fR from interpreting file names that start with a dash as
options, one can specify a double dash (\-\-) after which tdreplay will interpret
any following arguments as files to read.
.SH BUGS
If you think you have found a bug, please check that you are using the latest
version of \fBtermdebug\fR . When reporting bugs,
please include a minimal example that demonstrates the problem.
.SH AUTHOR
G.P. Halkes
.SH COPYRIGHT
Copyright \(co 2010,2012\-2013 G.P. Halkes
.br
\fBtermdebug\fR is licensed under the GNU General Public License version 3.
.br
For more details on the license, see the file COPYING in the documentation
directory. On Un*x systems this is usually /usr/share/doc/termdebug.
.SH SEE\ ALSO
\fBtermdebug\fR(1), \fBtdrecord\fR(1), \fBtdrerecord\fR(1), \fBtdview\fR(1), \fBtdreplay\fR(1)
.RS
.ft CW
termdebug-2.2+dfsg/man/tdrecord.1 0000664 0000000 0000000 00000004435 12547225624 0016734 0 ustar 00root root 0000000 0000000 .\" Generated by manscript from tdrecord.1.txt
.TH "TDRECORD" "1" "2013/03/03" "2.2" "termdebug"
.SH NAME
tdrecord \- record input and output of a terminal program
.SH SYNOPSIS
\fBtdrecord\fR [\fIOPTIONS\fR]... \fICLIENT\fR [\fICLIENT OPTIONS\fR]...
.SH DESCRIPTION
\fBtdrecord\fR records the input and output of client. The recording can later be
replayed using \fBtdreplay\fR(1) to compare behaviour of different versions of
client. Without options, \fBtdrecord\fR will create the recording in the file
tdrecord-\fIyear\fR\-\fImonth\fR\-\fIday\fR@\fIhour\fR:\fIminute\fR:\fIsecond\fR.
.SH OPTIONS
\fBtdrecord\fR accepts the following options:
.PP
.TP
\fB\-h\fR, \fB\-\-help\fR
Display a short help message.
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version and copyright information.
.TP
\fB\-d\fR \fIdir\fR, \fB\-\-directory\fR=\fIdir\fR
Create the recording in directory \fIdir\fR. This option can not be used
together with the \fB\-o\fR/\fB\-\-output\fR option.
.TP
\fB\-e\fR \fIvars\fR, \fB\-\-environment\fR=\fIvars\fR
Save the environment variables indicated by the comma-separated list
\fIvars\fR to the recording. These will be set on replay.
.TP
\fB\-o\fR \fIfile\fR, \fB\-\-output\fR=\fIfile\fR
Save the output in \fIfile\fR. This option can not be used together with the
\fB\-d\fR/\fB\-\-directory\fR option.
.TP
\fB\-X\fR, \fB\-\-allow\-x11\fR
Don't clear the DISPLAY environment variable, to allow communication with
X11.
.PP
To stop \fBtdrecord\fR from interpreting file names that start with a dash as
options, one can specify a double dash (\-\-) after which \fBtdrecord\fR will interpret
any following arguments as the client and its options.
.SH BUGS
If you think you have found a bug, please check that you are using the latest
version of \fBtermdebug\fR . When reporting bugs,
please include a minimal example that demonstrates the problem.
.SH AUTHOR
G.P. Halkes
.SH COPYRIGHT
Copyright \(co 2010,2012\-2013 G.P. Halkes
.br
\fBtermdebug\fR is licensed under the GNU General Public License version 3.
.br
For more details on the license, see the file COPYING in the documentation
directory. On Un*x systems this is usually /usr/share/doc/termdebug.
.SH SEE\ ALSO
\fBtermdebug\fR(1), \fBtdreplay\fR(1), \fBtdrerecord\fR(1), \fBtdview\fR(1), \fBtdcompare\fR(1)
termdebug-2.2+dfsg/man/tdreplay.1 0000664 0000000 0000000 00000011470 12547225624 0016747 0 ustar 00root root 0000000 0000000 .\" Generated by manscript from tdreplay.1.txt
.TH "TDREPLAY" "1" "2013/03/03" "2.2" "termdebug"
.SH NAME
tdreplay \- replay input to a terminal program
.SH SYNOPSIS
\fBtdreplay\fR [\fIOPTIONS\fR] \fIRECORDING\fR
.SH DESCRIPTION
\fBtdreplay\fR replays the input from a recording to the terminal program named in
the recording. This allows verification that the program behaviour has not
changed, or confirmation that it has.
.SH OPTIONS
\fBtdreplay\fR accepts the following options:
.PP
.TP
\fB\-h\fR, \fB\-\-help\fR
Display a short help message.
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version and copyright information.
.TP
\fB\-a\fR \fIcmd\fR, \fB\-\-alert\fR=\fIcmd\fR
Execute \fIcmd\fR when a difference is detected between the recorded output and
the output generated by replaying the input back to the program.
The environment variable REASON contains a message about what sort of
difference was detected. A useful command is 'xmessage "$REASON"'.
.TP
\fB\-d\fR, \fB\-\-display\fR
Show the output of the running program on the current terminal. The default
is to only verify that the program behaves as recorded without showing the
output.
.TP
\fB\-e\fR \fIaction\fR, \fB\-\-on\-error\fR=\fIaction\fR
Set the action to take when a difference is detected between the recorded
and the actual output. Possible values for \fIaction\fR are interact, continue
and abort. When the \fIaction\fR is interact, \fBtdreplay\fR will allow the user to
interact with the program. When the \fIaction\fR is continue, \fBtdreplay\fR will
continue as if no difference was detected. This can be dangerous as the
input is no longer in sync with the output. Depending on the possible
actions of the program being run this can cause data corruption.
.TP
\fB\-k\fR \fIdelay\fR, \fB\-\-key\-delay\fR=\fIdelay\fR
Set the delay for sending a the next keys to \fIdelay\fR. Delay may be either a
fixed number of miliseconds, or it may be specified as / (slash) followed by
a divisor. When a divisor is specified, all key delays specified in the
recording will be divided by the divisor.
.TP
\fB\-l\fR \fIlog\fR, \fB\-\-log\fR=\fIlog\fR
Write a log of the events to \fIlog\fR. This may be useful in figuring out what
the difference between the recorded and the actual output is.
.TP
\fB\-R\fR, \fB\-\-no\-resize\fR
Do not try to resize the output terminal by sending a resize command
sequence.
.TP
\fB\-v\fR, \fB\-\-visual\-compare\fR
Check for visual equality, rather than exact input/output behaviour.
(Requires a build with ncurses support.)
.TP
\fB\-D\fR, \fB\-\-describe\fR
Write a description of the first visual difference encountered. Only useful
with \fB\-v\fR/\fB\-\-visual\-compare\fR. (Requires a build with ncurses support.)
.TP
\fB\-p\fR \fIname\fR, \fB\-\-picture\fR=\fIname\fR
Write a picture of the difference to \fIname\fR. Only useful with
\fB\-v\fR/\fB\-\-visual\-compare\fR. (Requires a build with ncurses and Cairo support.)
.TP
\fB\-f\fR \fIfont\fR, \fB\-\-font\fR=\fIfont\fR
Use \fIfont\fR to show text in generated pictures. Only useful with
\fB\-p\fR/\fB\-\-picture\fR or \fB\-P\fR/\fB\-\-picture\-series\fR. (Requires a build with ncurses
and Cairo support.)
.TP
\fB\-W\fR \fIwidth\fR, \fB\-\-cell\-width\fR=\fIwidth\fR
Use cells of \fIwidth\fR pixels wide in generated pictures. Only useful with
\fB\-p\fR/\fB\-\-picture\fR or \fB\-P\fR/\fB\-\-picture\-series\fR. (Requires a build with ncurses
and Cairo support.)
.TP
\fB\-H\fR \fIheight\fR, \fB\-\-cell\-height\fR=\fIheight\fR
Use cells of \fIheight\fR pixels wide in generated pictures. Only useful with
\fB\-p\fR/\fB\-\-picture\fR or \fB\-P\fR/\fB\-\-picture\-series\fR. (Requires a build with ncurses
and Cairo support.)
.TP
\fB\-P\fR \fIname\fR, \fB\-\-picture\-series\fR=\fIname\fR
Create a series of pictures, representing the different visual steps in the
client interface, using \fIname\fR as the file name template. \fIname\fR is a
\fBprintf\fR(3) format string, where a single d-type conversion is required.
(Requires a build with ncurses, Cairo and Pthread support.)
.PP
To stop \fBtdreplay\fR from interpreting file names that start with a dash as
options, one can specify a double dash (\-\-) after which \fBtdreplay\fR will interpret
any following arguments as files to read.
.SH BUGS
If you think you have found a bug, please check that you are using the latest
version of \fBtermdebug\fR . When reporting bugs,
please include a minimal example that demonstrates the problem.
.SH AUTHOR
G.P. Halkes
.SH COPYRIGHT
Copyright \(co 2010,2012\-2013 G.P. Halkes
.br
\fBtermdebug\fR is licensed under the GNU General Public License version 3.
.br
For more details on the license, see the file COPYING in the documentation
directory. On Un*x systems this is usually /usr/share/doc/termdebug.
.SH SEE\ ALSO
\fBtermdebug\fR(1), \fBtdrecord\fR(1), \fBtdrerecord\fR(1), \fBtdview\fR(1), \fBtdcompare\fR(1)
termdebug-2.2+dfsg/man/tdrerecord.1 0000664 0000000 0000000 00000005310 12547225624 0017254 0 ustar 00root root 0000000 0000000 .\" Generated by manscript from tdrerecord.1.txt
.TH "TDRERECORD" "1" "2013/03/03" "2.2" "termdebug"
.SH NAME
tdrerecord \- rerecord output of a terminal program
.SH SYNOPSIS
\fBtdrerecord\fR [OPTIONS] \fIRECORDING\fR
.SH DESCRIPTION
\fBtdrerecord\fR re-records the output of a terminal program, by replaying the input
from a recording. This allows a new recording to created based on the same
input, after modifying the behaviour of the program. Without options,
\fBtdrerecord\fR will create the recording in the file
tdrecord-\fIyear\fR\-\fImonth\fR\-\fIday\fR@\fIhour\fR:\fIminute\fR:\fIsecond\fR.
.PP
\fBNote\fR that \fBtdrerecord\fR does \fBnot\fR check whether the output conforms to the
recorded output. This can be dangerous as the input may not be in sync with the
output. Depending on the possible actions of the program being run this can
cause data corruption.
.SH OPTIONS
\fBtdrerecord\fR accepts the following options:
.PP
.TP
\fB\-h\fR, \fB\-\-help\fR
Display a short help message.
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version and copyright information.
.TP
\fB\-d\fR \fIdir\fR, \fB\-\-directory\fR=\fIdir\fR
Create the recording in directory \fIdir\fR. This option can not be used
together with the \fB\-o\fR/\fB\-\-output\fR option.
.TP
\fB\-o\fR \fIfile\fR, \fB\-\-output\fR=\fIfile\fR
Save the output in \fIfile\fR. This option can not be used togehter with the
\fB\-d\fR/\fB\-\-directory\fR option.
.TP
\fB\-l\fR, \fB\-\-no\-strip\-location\-reports\fR
Do not remove ANSI cursor location reports from the recorded client input.
These reports are normally generated on request by the client program.
Including these in the client input will result in duplicate location
reports which is likely to confuse the client. However, in some cases it
may be necessary to retain these strings (e.g. if they were not generated
in response to a client request).
.PP
To stop \fBtdrerecord\fR from interpreting file names that start with a dash as
options, one can specify a double dash (\-\-) after which \fBtdrerecord\fR will
interpret any following arguments as files to read.
.SH BUGS
If you think you have found a bug, please check that you are using the latest
version of \fBtermdebug\fR . When reporting bugs,
please include a minimal example that demonstrates the problem.
.SH AUTHOR
G.P. Halkes
.SH COPYRIGHT
Copyright \(co 2010,2012\-2013 G.P. Halkes
.br
\fBtermdebug\fR is licensed under the GNU General Public License version 3.
.br
For more details on the license, see the file COPYING in the documentation
directory. On Un*x systems this is usually /usr/share/doc/termdebug.
.SH SEE\ ALSO
\fBtermdebug\fR(1), \fBtdrecord\fR(1), \fBtdreplay\fR(1), \fBtdview\fR(1), \fBtdcompare\fR(1)
termdebug-2.2+dfsg/man/tdview.1 0000664 0000000 0000000 00000003353 12547225624 0016426 0 ustar 00root root 0000000 0000000 .\" Generated by manscript from tdview.1.txt
.TH "TDVIEW" "1" "2013/03/03" "2.2" "termdebug"
.SH NAME
tdview \- show recorded output of a terminal program
.SH SYNOPSIS
\fBtdview\fR [OPTIONS] \fIRECORDING\fR
.SH DESCRIPTION
\fBtdview\fR shows the recorded output of a terminal program. The recording can be
made by either \fBtdrecord\fR(1) or \fBtdrerecord\fR(1).
.SH OPTIONS
\fBtdview\fR accepts the following options:
.PP
.TP
\fB\-h\fR, \fB\-\-help\fR
Display a short help message.
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version and copyright information.
.TP
\fB\-k\fR\fIdelay\fR, \fB\-\-key\-delay\fR=\fIdelay\fR
Set the delay for sending a the next keys to \fIdelay\fR. Delay may be either a
fixed number of miliseconds, or it may be specified as / (slash) followed by
a divisor. When a divisor is specified, all key delays specified in the
recording will be divided by the divisor.
.PP
To stop \fBtdview\fR from interpreting file names that start with a dash as options,
one can specify a double dash (\-\-) after which \fBtdview\fR will interpret any
following arguments as files to read.
.SH BUGS
If you think you have found a bug, please check that you are using the latest
version of \fBtermdebug\fR . When reporting bugs,
please include a minimal example that demonstrates the problem.
.SH AUTHOR
G.P. Halkes
.SH COPYRIGHT
Copyright \(co 2010,2012\-2013 G.P. Halkes
.br
\fBtermdebug\fR is licensed under the GNU General Public License version 3.
.br
For more details on the license, see the file COPYING in the documentation
directory. On Un*x systems this is usually /usr/share/doc/termdebug.
.SH SEE\ ALSO
\fBtermdebug\fR(1), \fBtdrecord\fR(1), \fBtdreplay\fR(1), \fBtdrerecord\fR(1), \fBtdcompare\fR(1)
termdebug-2.2+dfsg/man/termdebug.1 0000664 0000000 0000000 00000007462 12547225624 0017107 0 ustar 00root root 0000000 0000000 .\" Generated by manscript from termdebug.1.txt
.TH "TERMDEBUG" "1" "2013/03/03" "2.2" "termdebug"
.SH NAME
termdebug \- utilities for debugging interactive terminal programs.
.SH DESCRIPTION
\fBtermdebug\fR is a set of utilities to record and replay the input and output of
terminal programs. Its main goal is to aid in developing and debugging terminal
programs. Other programs such as termrec/termplay, nethack-recorder/player and
script/scriptreplay only record the output. However, when debugging an
interactive terminal program, the input is often as important as the output.
.PP
\fBtermdebug\fR consists of the following utilities:
.PP
.TP
\fBtdrecord\fR
Starts a program and records its input and output.
.TP
\fBtdreplay\fR
Starts a program and replays the input of a recording.
.TP
\fBtdview\fR
Shows the output of a recording.
.TP
\fBtdrerecord\fR
Starts a program and replays the input of a recording, recording
the input and output to create a new recording.
.TP
\fBtdcompare\fR
Compares two recordings to determine if there are differences. The reported
differences can be either on the exact input/output behaviour, or on the
visual behaviour.
.SH GRAMMAR
The recordings made with the \fBtermdebug\fR utilities use a simple format. Each
recording consists of a set of directives with arguments. White space is not
important. The language supports line comments which start at # and run to the
end of the line. The only other elements are numbers (a sequence of digits) and
strings. Strings start and end with a double qoute, and use C-style escaping.
The following directives are known:
.PP
.TP
\fBenv\fR \fIname\fR \fIvalue\fR
Set the value of environment variable \fIname\fR to \fIvalue\fR. \fIname\fR and \fIvalue\fR
are strings. All env directives must appear before the start directive.
.TP
\fBwindow_size\fR \fIcolumns\fR \fIlines\fR [\fIdelay\fR [\fB>\fR \fImin_delay\fR]]
Set the terminal window size to \fIcolumns\fR by lines_. May be specified both
before and after the start directive. On optional \fIdelay\fR in milliseconds
may be specified. Furthermore, \fImin_delay\fR may be specified to force a wait
of at least \fImin_delay\fR milliseconds regardless of program options changing
the key delay.
.TP
\fBstart\fR \fIclient\fR [\fIargument\fR+]
The start directive indicates the \fIclient\fR to start. Zero or more
\fIargument\fRs for the \fIclient\fR may be specified. \fIclient\fR and \fIargument\fR are
strings.
.TP
\fBrequire_version\fR \fIversion\fR
Tell the interpreter that the script langauge version must be \fIversion\fR. The
current version is 1.
.PP
The following directives may only appear after the start directive:
.PP
.TP
\fBexpect\fR \fIstring\fR+
Indicate what output to expect. One or more \fIstring\fRs may be specified.
.TP
\fBsend\fR (\fIdelay\fR \fIstring\fR [\fB>\fR \fImin_delay\fR)+
Specify one or more key \fIstring\fRs to send to the client program. \fIdelay\fR is
the delay in miliseconds to wait before sending \fIstring\fR. Furthermore,
\fImin_delay\fR may be specified to force a wait of at least \fImin_delay\fR
milliseconds regardless of program options changing the key delay.
.TP
\fBexpect_exit\fR \fIstatus\fR
Signal that the client should stop at this point, returning \fIstatus\fR.
.TP
\fBexpect_suspend\fR
Indicate that the client should suspend itself at this point.
.TP
\fBinteract\fR
Indicate the interaction with the user should be started at this point. Any
directives after this point will be ignored.
.SH AUTHOR
G.P. Halkes
.SH COPYRIGHT
Copyright \(co 2010,2012 G.P. Halkes
.br
\fBtermdebug\fR is licensed under the GNU General Public License version 3.
.br
For more details on the license, see the file COPYING in the documentation
directory. On Un*x systems this is usually /usr/share/doc/termdebug.
.SH SEE\ ALSO
\fBtdrecord\fR(1), \fBtdreplay\fR(1), \fBtdrerecord\fR(1), \fBtdview\fR(1)
termdebug-2.2+dfsg/src/ 0000775 0000000 0000000 00000000000 12547225624 0015052 5 ustar 00root root 0000000 0000000 termdebug-2.2+dfsg/src/common.c 0000664 0000000 0000000 00000050227 12547225624 0016514 0 ustar 00root root 0000000 0000000 /* Copyright (C) 2010,2013 G.P. Halkes
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3, as
published by the Free Software Foundation.
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, see .
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef HAVE_SYS_SELECT_H
#include
#endif
#include "common.h"
int signal_pipe[2];
static const char controlMap[] = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]_^";
static struct termios saved;
static struct timeval timestamp;
static Type last_type = TYPE_NONE;
/** Alert the user of a fatal error and quit.
@param fmt The format string for the message. See fprintf(3) for details.
@param ... The arguments for printing.
*/
void fatal(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
//FIXME: should we always do this? Standard error is not always visible...
/*
char *fmtBuffer, *msgBuffer;
va_start(args, fmt);
asprintf(&fmtBuffer, "xmessage \"%s\"", fmt, args);
vasprintf(&msgBuffer, fmtBuffer, args);
system(msgBuffer);
va_end(args); */
exit(EXIT_FAILURE);
}
void safe_write(int fd, const void *buffer, size_t size) {
while (size) {
ssize_t result = write(fd, buffer, size);
if (result < 0) {
if (errno == EINTR || errno == EAGAIN)
continue;
fatal("Error writing data: %s\n", strerror(errno));
}
buffer += result;
size -= result;
}
}
ssize_t safe_read(int fd, char *buffer, size_t size) {
size_t todo = size;
while (todo) {
ssize_t result = read(fd, buffer, todo);
if (result < 0) {
if (errno == EINTR)
continue;
else if (errno == EAGAIN)
return size - todo;
fatal("Error reading data: %s\n", strerror(errno));
}
buffer += result;
todo -= result;
}
return size;
}
void write_echo(const unsigned char *buffer, size_t size) {
size_t write_from = 0, i;
char ctrl[2] = { '^', 0 };
for (i = 0; i < size; i++) {
/* FIXME: some of the control characters should be interpreted or sent to the
terminal, depending on the terminal settings.
C-D (4) should not be printed at all
return (13) and newline (10) should be printed depending on the NL to CR mapping
tab (9) should be sent to the terminal
C-U, C-W seem to kill the line
if (buffer[i] < 32 && buffer[i] != 4 && buffer[i] != 10 && buffer[i] != 9 && buffer[i] != 13 && buffer[i] != 21 && buffer[i] != 23 && buffer[i] != 28) {
*/
if (buffer[i] < 32 && buffer[i] != 4 && buffer[i] != 9 && buffer[i] != 10 && buffer[i] != 13) {
if (i > write_from)
safe_write(STDOUT_FILENO, buffer + write_from, i - write_from);
write_from = i + 1;
ctrl[1] = controlMap[buffer[i]];
safe_write(STDOUT_FILENO, ctrl, 2);
}
}
if (i > write_from)
safe_write(STDOUT_FILENO, buffer + write_from, i - write_from);
}
void copy_attrs_to_terminal(int from) {
struct termios attrs;
if (tcgetattr(from, &attrs) < 0)
return;
attrs.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSADRAIN, &attrs);
}
void set_non_block(int fd, const char *descr, td_bool value) {
int flags;
if ((flags = fcntl(fd, F_GETFL)) < 0)
fatal("Could not get flags for %s\n", descr);
if (value)
flags |= O_NONBLOCK;
else
flags &= ~O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) < 0)
fatal("Could not set flags for %s\n", descr);
}
FILE *open_output(char **name, const char *directory) {
FILE *retval;
mode_t oldUmask;
/* If no name is given, create one */
if (*name == NULL) {
char nameBuffer[1024];
time_t seconds;
struct tm *local;
seconds = time(NULL);
local = localtime(&seconds);
if (!local)
fatal("Error getting localtime\n");
strftime(nameBuffer, 1024, "tdrecord-%Y-%m-%d@%H:%M:%S", local);
*name = strdup(nameBuffer);
if (*name == NULL)
fatal("Out of memory\n");
/* Use directory if one is supplied */
if (directory != NULL) {
snprintf(nameBuffer, 1024, "%s/%s", directory, *name);
free(*name);
*name = strdup(nameBuffer);
if (*name == NULL)
fatal("Out of memory\n");
}
}
oldUmask = umask((mode_t) 0077);
if ((retval = fopen(*name, "w")) == NULL)
fatal("Could not open output %s: %s\n", *name, strerror(errno));
umask(oldUmask);
return retval;
}
void install_signal_handler(int sig, void (*handler)(int), const char *descr) {
static td_bool pipe_initialised = td_false;
struct sigaction sa;
sigset_t sigs;
if (!pipe_initialised) {
if (pipe(signal_pipe) < 0)
fatal("Could not open pipe: %s\n", strerror(errno));
pipe_initialised = td_true;
}
/* Set signal handler to catch sig */
sa.sa_handler = handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
if (sigaction(sig, &sa, NULL) < 0)
fatal("Could not set signal handler for %s: %s\n", descr, strerror(errno));
sigemptyset(&sigs);
sigaddset(&sigs, sig);
if (sigprocmask(SIG_UNBLOCK, &sigs, NULL) < 0)
fatal("Could not block %s: %s\n", descr, strerror(errno));
}
void sigwinch_handler(int param) {
char signal_byte = SIGNAL_WINCH;
(void) param;
safe_write(signal_pipe[PIPE_WRITE], &signal_byte, 1);
}
void sigchld_handler(int param) {
char signal_byte = SIGNAL_CHILD;
(void) param;
safe_write(signal_pipe[PIPE_WRITE], &signal_byte, 1);
}
void save_tty(void) {
/* Get terminal attributes. */
if (tcgetattr(STDIN_FILENO, &saved) < 0)
fatal("Could not get terminal settings: %s\n", strerror(errno));
atexit(reset_tty);
}
void reset_tty(void) {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &saved);
set_non_block(STDIN_FILENO, "terminal", td_false);
}
int timevaldiff(struct timeval origin, struct timeval now) {
return (now.tv_usec - origin.tv_usec) / 1000 + (now.tv_sec - origin.tv_sec) * 1000;
}
void init_timestamp(void) { gettimeofday(×tamp, NULL); }
int get_elapsed(void) {
struct timeval now;
int retval;
gettimeofday(&now, NULL);
retval = timevaldiff(timestamp, now);
timestamp = now;
return retval;
}
void write_record(FILE *output, Type dir, int delay, int min_delay, unsigned char *buffer, ssize_t length) {
int i;
if (last_type != dir) {
if (last_type == TYPE_OUTPUT)
fputc('"', output);
if (last_type != TYPE_NONE)
fputc('\n', output);
fprintf(output, "%s", dir == TYPE_OUTPUT ? "expect " : "send");
if (dir == TYPE_OUTPUT)
fputc('"', output);
last_type = dir;
}
if (dir == TYPE_INPUT) {
fprintf(output, " %d ", delay);
if (min_delay > 0)
fprintf(output, ">%d ", min_delay);
fputc('"', output);
}
for (i = 0; i < length; i++) {
if (buffer[i] == '\r' && dir == TYPE_OUTPUT) {
/* FIXME: don't start a new string here because it may become an empty string. */
fputs("\\r\"\n\t\"", output);
} else if (!isprint(buffer[i])) {
fprintf(output, "\\%03o", buffer[i]);
} else if (buffer[i] == '"' || buffer[i] == '\\') {
fputc('\\', output);
fputc(buffer[i], output);
} else {
fputc(buffer[i], output);
}
}
if (dir == TYPE_INPUT)
fputc('"', output);
}
void copy_fd(int from, int to, Type dir, FILE *output) {
unsigned char buffer[1024];
ssize_t result;
struct termios backup;
td_bool restore = td_true;
if (dir == TYPE_INPUT) {
/* Temporarily disable ECHO on the terminal to prevent duplicate output.
Note that the "to" terminal in this case is the pty connected to the
client program. */
if (tcgetattr(to, &backup) < 0 || !(backup.c_lflag & ECHO)) {
/* If we can't read the attributes, we can't restore them at the end either.
And if echo is disabled anyway, we don't have to. */
restore = td_false;
} else {
struct termios noecho = backup;
noecho.c_lflag &= ~ECHO;
tcsetattr(to, TCSANOW, &noecho);
}
}
repeat:
while ((result = read(from, buffer, sizeof(buffer))) > 0) {
/* Record copied data to file. */
if (output != NULL)
write_record(output, dir, dir == TYPE_INPUT ? get_elapsed() : 0, 0, buffer, result);
/* Simulate ECHO flag on terminal. The ECHO flag has been disabled because
we can't get a signal when the client program changes the terminal
settings. This means that the first character typed will have the old ECHO
settings and may echo when it is not desired. However, if the client
program does want the ECHO flag we must now provide... */
if (dir == TYPE_INPUT && restore)
write_echo(buffer, result);
safe_write(to, buffer, result);
}
if (result < 0) {
if (errno == EINTR) {
goto repeat;
} else if (errno != EAGAIN) {
if (dir == TYPE_INPUT)
fatal("Error reading data from terminal or pty: %s\n", strerror(errno));
}
}
if (dir == TYPE_INPUT && restore)
tcsetattr(to, TCSANOW, &backup);
}
int interact_loop(int master, pid_t pid, FILE *output, int timeout) {
port_pollfd fdset[3];
struct winsize wsz;
int status;
int remaining_timeout = timeout;
struct timeval start;
fdset[0].fd = STDIN_FILENO;
fdset[0].events = PORT_POLLIN;
fdset[1].fd = master;
fdset[1].events = PORT_POLLIN;
fdset[2].fd = signal_pipe[PIPE_READ];
fdset[2].events = PORT_POLLIN;
copy_attrs_to_terminal(STDIN_FILENO);
if (timeout >= 0)
gettimeofday(&start, NULL);
while (1) {
int result;
result = port_poll(fdset, 3, remaining_timeout);
if (result == -1) {
if (errno != EINTR)
fatal("Error during poll: %s\n", strerror(errno));
}
if (result == 0)
return -1;
copy_attrs_to_terminal(master);
if (fdset[1].revents & PORT_POLLIN)
copy_fd(master, STDOUT_FILENO, TYPE_OUTPUT, output);
copy_attrs_to_terminal(master);
if (fdset[0].revents & PORT_POLLIN)
copy_fd(STDIN_FILENO, master, TYPE_INPUT, output);
/* Check if a signal handler has been called since the last check. */
if (fdset[2].revents & PORT_POLLIN) {
HANDLE_SIG_BYTES()
case SIGNAL_CHILD:
if (waitpid(pid, &status, WNOHANG | WUNTRACED) == pid) {
if (WIFSTOPPED(status)) {
if (output != NULL) {
if (last_type == TYPE_OUTPUT)
fputs("\"\n", output);
fprintf(output, "expect_suspend\n");
last_type = TYPE_NONE;
}
printf("Process has stopped. Will send continue signal in 3 seconds\n");
sleep(3);
kill(pid, SIGCONT);
if (timeout >=0)
timeout += 3000;
} else {
goto end;
}
}
break;
case SIGNAL_WINCH:
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &wsz) < 0)
fatal("Error obtaining window size: %s\n", strerror(errno));
if (output != NULL) {
if (last_type == TYPE_OUTPUT)
fputs("\"\n", output);
fprintf(output, "window_size %d %d %d\n", wsz.ws_col, wsz.ws_row, get_elapsed());
last_type = TYPE_NONE;
}
if (ioctl(master, TIOCSWINSZ, &wsz) < 0)
fatal("Error setting window size: %s\n", strerror(errno));
break;
END_HANDLE
}
if (timeout >= 0) {
struct timeval now;
gettimeofday(&now, NULL);
remaining_timeout = timeout - timevaldiff(start, now);
if (remaining_timeout <= 0)
return -1;
}
}
end:
/* Copy any remaining data */
copy_attrs_to_terminal(master);
copy_fd(master, STDOUT_FILENO, TYPE_OUTPUT, output);
if (output != NULL) {
if (last_type == TYPE_OUTPUT)
fputs("\"\n", output);
fprintf(output, "expect_exit %d\n", WEXITSTATUS(status));
}
return status;
}
void write_escaped_string(FILE *out, const char *string, size_t length) {
size_t i;
fputc('"', out);
for (i = 0; i < length; i++, string++) {
if (!isprint(*string)) {
fprintf(out, "\\%03o", (unsigned char) *string);
} else if (*string == '\\' || *string == '"') {
fputc('\\', out);
fputc(*string, out);
} else {
fputc(*string, out);
}
}
fputs("\"", out);
}
td_bool detect_resize_capable(void) {
/* Only way to check whether the terminal is resize capable is to check the TERM
environment variable. Unfortunately, this is not 100% sure. For example, xterm
only allows this when "XTerm*allowWindowOps" resource is set to td_true. */
const char *term = getenv("TERM");
if (term == NULL)
return td_false;
return strcmp(term, "xterm") == 0 || strcmp(term, "rxvt") == 0 || strcmp(term, "Eterm") == 0;
}
pid_t start_client(ExpNode *client, int fd, FILE *log_file) {
pid_t result;
StringListNode *ptr;
int argc = 0;
char **argv;
if (log_file != NULL) {
/* Log the start attempt */
fprintf(log_file, "Starting client:");
ptr = client->un.args;
while (ptr != NULL) {
fprintf(log_file, " %s", ptr->string);
ptr = ptr->next;
}
fprintf(log_file, "\n");
fflush(log_file);
}
/* Start the client */
if ((result = fork()) < 0)
fatal("Error executing fork: %s\n", strerror(errno));
else if (result != 0)
return result;
if (port_login_tty(fd) < 0)
fatal("Error executing login_tty: %s\n", strerror(errno));
ptr = client->un.args;
while (ptr != NULL) {
argc++;
ptr = ptr->next;
}
if ((argv = malloc(sizeof(char *) * (argc + 1))) == NULL)
fatal("Could not allocate client argument array: %s\n", strerror(errno));
ptr = client->un.args;
argc = 0;
while (ptr != NULL) {
argv[argc++] = ptr->string;
ptr = ptr->next;
}
argv[argc] = NULL;
/* Don't want program to communicate with X11 server for modifier states. */
unsetenv("DISPLAY");
execvp(argv[0], argv);
fatal("execvp failed: %s\n", strerror(errno));
return 0;
}
char *getcwd_wrapper(void) {
size_t cwdBufferLength = 1024;
char *cwdBuffer, *retval;
if ((cwdBuffer = malloc(cwdBufferLength)) == NULL)
return strdup("");
repeat_getcwd:
retval = getcwd(cwdBuffer, cwdBufferLength);
if (retval != NULL)
return retval;
if (errno == ERANGE) {
char *newCwdBuffer;
if (SIZE_MAX / 2 > cwdBufferLength) {
free(cwdBuffer);
return strdup("");
}
cwdBufferLength <<= 1;
newCwdBuffer = realloc(cwdBuffer, cwdBufferLength);
if (newCwdBuffer == NULL) {
free(cwdBuffer);
return strdup("");
}
goto repeat_getcwd;
}
free(cwdBuffer);
/* FIXME: report _which_ error */
return strdup("");
}
void check_script(const char *file_name, ExpNode *script) {
int current_check_version = 0;
for (; script != NULL; script = script->next) {
switch (script->type) {
case EXP_START:
case EXP_INTERACT:
case EXP_ENV:
case EXP_EXPECT:
case EXP_EXPECT_EXIT:
case EXP_EXPECT_SUSPEND:
/* Ignore stuff that isn't relavant to simply checking the script. */
break;
case EXP_SEND: {
StringListNode *string;
if (current_check_version >= 2)
break;
for (string = script->un.args; string != NULL; string = string->next) {
if (string->min_delay > 0) {
fprintf(stderr, "%s:%d: WARNING: minimum delay construct is not supported in script version 1. "
"Please add 'require_version 2' to your script.\n", file_name, script->line);
break;
}
}
break;
}
case EXP_WINDOW_SIZE:
if (script->un.size.min_delay > 0)
fprintf(stderr, "%s:%d: WARNING: minimum delay construct is not supported in script version 1. "
"Please add 'require_version 2' to your script.\n", file_name, script->line);
break;
case EXP_REQUIRE_VERSION:
if (script->un.number > CURRENT_SCRIPT_VERSION)
fatal("Script requires an unsupported script version.\n");
current_check_version = script->un.number;
break;
default:
fatal("Internal error\n");
}
}
}
#ifndef HAVE_OPENPTY
int port_openpty(int *master, int *slave, struct winsize *wsz) {
char *slave_name;
int save_errno;
# ifdef HAVE_POSIX_OPENPT
*master = posix_openpt(O_RDWR | O_NOCTTY);
# else
*master = open("/dev/ptmx", O_RDWR | O_NOCTTY);
# endif
if (*master == -1)
return -1;
if (grantpt (*master) == -1 ||
unlockpt (*master) == -1 ||
(slave_name = ptsname(*master)) == NULL ||
(*slave = open(slave_name, O_RDWR | O_NOCTTY)) == -1)
{
save_errno = errno;
goto error_end_close_master;
}
if (wsz == NULL || ioctl(*master, TIOCSWINSZ, wsz) != -1)
return 0;
/* ioctl failed. */
save_errno = errno;
close(*slave);
error_end_close_master:
close(*master);
errno = save_errno;
return -1;
}
#endif
#ifndef HAVE_LOGIN_TTY
int port_login_tty(int fd) {
if (setsid() == -1)
return -1;
if (ioctl(fd, TIOCSCTTY, 0) == -1)
return -1;
if (dup2(fd, STDIN_FILENO) == -1)
return -1;
if (dup2(fd, STDOUT_FILENO) == -1)
return -1;
if (dup2(fd, STDOUT_FILENO) == -1)
return -1;
close(fd);
return 0;
}
#endif
#ifndef HAVE_FORKPTY
pid_t port_forkpty(int *master, struct winsize *wsz) {
pid_t pid;
int slave, save_errno;
if (port_openpty(master, &slave, wsz) == -1)
return -1;
if ((pid = fork()) == -1) {
save_errno = errno;
goto error_end_close;
}
if (pid != 0)
return pid;
if (port_login_tty(slave) == -1) {
save_errno = errno;
goto error_end_close;
}
return 0;
error_end_close:
close(slave);
close(*master);
errno = save_errno;
return -1;
}
#endif
#ifndef HAVE_POLL
int port_poll(port_pollfd *fds, port_nfds_t nfds, int timeout) {
fd_set readfds, writefds, exceptfds;
struct timeval _timeout;
port_nfds_t i;
int maxfd = 0, result;
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
for (i = 0; i < nfds; i++) {
if (fds[i].events & PORT_POLLIN)
FD_SET(fds[i].fd, &readfds);
if (fds[i].events & PORT_POLLOUT)
FD_SET(fds[i].fd, &writefds);
if (fds[i].events & PORT_POLLERR)
FD_SET(fds[i].fd, &exceptfds);
if (fds[i].events != 0 && fds[i].fd > maxfd)
maxfd = fds[i].fd;
}
_timeout.tv_sec = timeout / 1000;
_timeout.tv_usec = (timeout % 1000) * 1000;
result = select(maxfd + 1, &readfds, &writefds, &exceptfds, timeout < 0 ? NULL : &_timeout);
if (result == -1)
return -1;
if (result == 0)
return 0;
result = 0;
for (i = 0; i < nfds; i++) {
fds[i].revents = 0;
if (FD_ISSET(fds[i].fd, &readfds))
fds[i].revents |= PORT_POLLIN;
if (FD_ISSET(fds[i].fd, &writefds))
fds[i].revents |= PORT_POLLOUT;
if (FD_ISSET(fds[i].fd, &exceptfds))
fds[i].revents |= PORT_POLLERR;
if (fds[i].revents != 0)
result++;
}
return result;
}
#endif
#ifndef HAVE_STRDUP
char *port_strdup(const char *s) {
char *result = malloc(strlen(s) + 1);
if (result == NULL)
return NULL;
strcpy(result, s);
return result;
}
#endif
const char *get_script_env(const ExpNode *script, const char *name) {
for (; script != NULL; script = script->next) {
if (script->type == EXP_ENV && strcmp(script->un.args->string, name) == 0)
return script->un.args->next->string;
}
return NULL;
}
/* Check if a format string contains exactly 1 d-type conversion. */
td_bool check_fmt(const char *str) {
td_bool percent_seen = td_false;
td_bool conversion_seen = td_false;
for (; *str != 0; str++) {
if (*str == '%') {
if (percent_seen)
return td_false;
if (str[1] == '%') {
str++;
continue;
}
percent_seen = td_true;
} else if (percent_seen) {
if (*str == 'd') {
percent_seen = td_false;
if (conversion_seen)
return td_false;
conversion_seen = td_true;
} else if (*str < '0' || *str > '9') {
return td_false;
}
}
}
return !percent_seen && conversion_seen;
}
int tdrecord_main(int argc, char *argv[]);
int tdrerecord_main(int argc, char *argv[]);
int tdreplay_main(int argc, char *argv[]);
int tdview_main(int argc, char *argv[]);
int tdcompare_main(int argc, char *argv[]);
int main(int argc, char *argv[]) {
char *name = basename(argv[0]);
if (strcmp(name, "tdrecord") == 0)
return tdrecord_main(argc, argv);
if (strcmp(name, "tdreplay") == 0)
return tdreplay_main(argc, argv);
if (strcmp(name, "tdrerecord") == 0)
return tdrerecord_main(argc, argv);
if (strcmp(name, "tdview") == 0)
return tdview_main(argc, argv);
if (strcmp(name, "tdcompare") == 0)
return tdcompare_main(argc, argv);
fprintf(stderr, "Please use the tdrecord, tdreplay, tdrerecord, tdview, tdcompare symlinks instead of running this executable\n");
return 0;
}
termdebug-2.2+dfsg/src/common.h 0000664 0000000 0000000 00000015407 12547225624 0016522 0 ustar 00root root 0000000 0000000 /* Copyright (C) 2010,2013 G.P. Halkes
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3, as
published by the Free Software Foundation.
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, see .
*/
#ifndef COMMON_H
#define COMMON_H
#include
#include
#include
#include
#include
#include "replay.h"
/* This should be automatically determined from the repository
[and is, by the mkdist.sh script] */
#define VERSION_STRING "2.2"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
/* Define a td_bool type */
typedef enum { td_false, td_true } td_bool;
/* Exit program with message, in response to an error. */
#ifdef __GNUC__
void fatal(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
#else
void fatal(const char *fmt, ...);
#endif
/* Write to file descriptor, retrying if interrupted by a signal. */
void safe_write(int fd, const void *buffer, size_t size);
/* Read from file descriptor, retrying if interrupted by a signal. */
ssize_t safe_read(int fd, char *buffer, size_t size);
/* Echo characters to screen, interpreting control characters as ^X. */
void write_echo(const unsigned char *buffer, size_t size);
/* Copy the attributes from a file descriptor (pseudo tty) to the actual terminal. */
void copy_attrs_to_terminal(int from);
void set_non_block(int fd, const char *descr, td_bool value);
/* Open the output file. If *name == NULL, a file is created in directory (if != NULL) or in the cwd. */
FILE *open_output(char **name, const char *directory);
void install_signal_handler(int sig, void (*handler)(int), const char *descr);
/* Calculate the difference between two timeval structs in miliseconds. */
int timevaldiff(struct timeval origin, struct timeval now);
/* Values for bytes sent over the signal_pipe. */
enum {
SIGNAL_CHILD,
SIGNAL_WINCH
};
/* Give the pipe fd's names. */
enum {
PIPE_READ,
PIPE_WRITE
};
extern int signal_pipe[2];
void sigwinch_handler(int param);
void sigchld_handler(int param);
void save_tty(void);
void reset_tty(void);
#define HANDLE_SIG_BYTES() { char signal_byte; \
while (safe_read(signal_pipe[PIPE_READ], &signal_byte, 1) == 1) { \
switch (signal_byte) {
#define END_HANDLE default: break; }}}
/* Directions for copying bytes to/from terminal. NONE is used only for keeping track of the last
direction output to file. */
typedef enum {
TYPE_NONE,
TYPE_INPUT,
TYPE_OUTPUT
} Type;
void init_timestamp(void);
/* Write a set of bytes to the output file. */
void write_record(FILE *output, Type dir, int delay, int min_delay, unsigned char *buffer, ssize_t length);
/* Copy bytes between tty and pseudo tty, recording the events to output. */
void copy_fd(int from, int to, Type dir, FILE *output);
/* Main loop for interactive operation of the child program. */
int interact_loop(int master, pid_t pid, FILE *output, int timeout);
/* Write a string to out, using escaping to ensure that it can be read back. */
void write_escaped_string(FILE *out, const char *string, size_t length);
/* Check if the current terminal is capable of resizing initiated by a program. */
td_bool detect_resize_capable(void);
/* Start the child program. */
pid_t start_client(ExpNode *client, int fd, FILE *log_file);
/* getcwd which allocates a large enough buffer. */
char *getcwd_wrapper(void);
#define CURRENT_SCRIPT_VERSION 2
void check_script(const char *file_name, ExpNode *script);
/* Portable implementation wrappers for openpty, login_tty, forkpty, poll and strdup.
Note that these only provide the arguments actually used in the termdebug programs. */
#ifdef HAVE_OPENPTY
#if defined(OPENPTY_IN_UTIL_H)
#include
#include
#include
#include
#elif defined(OPENPTY_IN_LIBUTIL_H)
#include
#include
#include
#include
#else
#include
#endif
#define port_openpty(_a, _b, _c) openpty((_a), (_b), NULL, NULL, (_c))
#else
#include
#include
int port_openpty(int *master, int *slave, struct winsize *wsz);
#endif
#ifdef HAVE_LOGIN_TTY
#if defined(LOGIN_TTY_IN_UTIL_H)
#include
#include
#elif defined(LOGIN_TTY_IN_LIBUTIL_H)
#include
#include
#include
#include
#else
#include
#endif
#define port_login_tty(_a) login_tty((_a))
#else
int port_login_tty(int fd);
#endif
#ifdef HAVE_FORKPTY
#if defined(FORKPTY_IN_UTIL_H)
#include
#include
#include
#include
#elif defined(FORKPTY_IN_LIBUTIL_H)
#include
#include
#include
#include
#else
#include
#endif
#define port_forkpty(_a, _b) forkpty((_a), NULL, NULL, (_b))
#else
#include
#include
pid_t port_forkpty(int *master, struct winsize *wsz);
#endif
#ifdef HAVE_POLL
#include
typedef struct pollfd port_pollfd;
typedef nfds_t port_nfds_t;
#define PORT_POLLIN POLLIN
#define PORT_POLLOUT POLLOUT
#define PORT_POLLERR POLLERR
#define port_poll(_a, _b, _c) poll((_a), (_b), (_c))
#else
typedef struct {
int fd;
short events, revents;
} port_pollfd;
typedef size_t port_nfds_t;
#define PORT_POLLIN (1<<0)
#define PORT_POLLOUT (1<<1)
#define PORT_POLLERR (1<<2)
int port_poll(port_pollfd *fds, port_nfds_t nfds, int timeout);
#endif
#ifdef HAVE_STRDUP
#include
#define port_strdup(_a) strdup(_a)
#else
char *port_strdup(const char *s);
#endif
/* Retrieve an environment variable from a script. */
const char *get_script_env(const ExpNode *script, const char *name);
td_bool check_fmt(const char *str);
/* Unfortunately, the system(3) call has been marked as warn_unused_result in
some distributions. In our case, we don't care about whether the program we
are trying to start actually succeeded, or whether the fork failed. There is
nothing we can do about it, and we don't have a good fall back.
The only way to stop GCC whining about ignoring the result, is by assigning
to a variable, or using the result in some other way. However, if we simply
assign the variable, GCC will start whining about the fact that the assigned
value is never used. Sigh. So we explicitly tell it to ignore that, by
casting it to a void.
*/
#ifdef __GNUC__
#define ignore_result(x) do { __typeof__(x) _ignore = x; (void) _ignore; } while (0)
#else
#define ignore_result(x) x
#endif
#endif
termdebug-2.2+dfsg/src/compare.c 0000664 0000000 0000000 00000026733 12547225624 0016657 0 ustar 00root root 0000000 0000000 /* Copyright (C) 2013 G.P. Halkes
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3, as
published by the Free Software Foundation.
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, see .
*/
#include
#include
#include
#include
#include
#include
#include
#include "common.h"
#include "optionMacros.h"
#include "replay.h"
#include "input.h"
#if defined(HAVE_CURSES) && defined(HAVE_UNISTRING)
#include "write_stringlist.h"
#endif
static const char *inputA, *inputB;
static ExpNode *scriptA, *scriptB;
static td_bool stop_on_difference;
#if defined(HAVE_CURSES) && defined(HAVE_UNISTRING)
static td_bool describe;
static td_bool visual_compare;
static window_t *winA, *winB;
#ifdef HAVE_CAIRO
static const char *picture_name;
static const char *picture_series;
#endif
#endif
// FIXME: add option to check equality of sent strings as well
static void printUsage(void) {
printf("Usage: tdcompare [OPTIONS] \n");
#if defined(HAVE_CURSES) && defined(HAVE_UNISTRING)
printf(" -v, --visual-compare Check for visual equality\n");
printf(" -D, --describe Print a description of the first\n"
" difference found\n");
#ifdef HAVE_CAIRO
printf(" -p, --picture= Write a picture of the differences to\n"
" \n");
printf(" -f, --font= Use to show text in picture.\n");
printf(" -W, --cell-width= Use as cell width in picture.\n");
printf(" -H, --cell-height= Use as cell width in picture.\n");
printf(" -P, --picture-series= Create a series of picutes use as\n"
" template\n");
printf(" -s, --stop-on-difference Stop when the first visual difference is\n"
" found\n");
#endif
#endif
printf(" -V, --version Print version and copyright information\n");
exit(EXIT_SUCCESS);
}
static PARSE_FUNCTION(parse_options)
OPTIONS
OPTION('h', "help", NO_ARG)
printUsage();
END_OPTION
OPTION('V', "version", NO_ARG)
fputs("tdcompare " VERSION_STRING "\nCopyright (C) 2013 G.P. Halkes\nLicensed under the GNU General Public License version 3\n", stdout); /* @copyright */
exit(0);
END_OPTION
OPTION('v', "visual-compare", NO_ARG)
#if defined(HAVE_CURSES) && defined(HAVE_UNISTRING)
visual_compare = td_true;
#else
fatal("termdebug was built without (n)curses and/or libunistring, and therefore tdcompare does not provide " OPTFMT "\n", OPTPRARG);
#endif
END_OPTION
OPTION('D', "describe", NO_ARG)
#if defined(HAVE_CURSES) && defined(HAVE_UNISTRING)
describe = td_true;
#else
fatal("termdebug was built without (n)curses and/or libunistring, and therefore tdcompare does not provide " OPTFMT "\n", OPTPRARG);
#endif
END_OPTION
OPTION('p', "picture", REQUIRED_ARG)
#ifdef HAVE_CAIRO
picture_name = optArg;
#else
fatal("termdebug was built without cairo, and therefore tdcompare does not provide " OPTFMT "\n", OPTPRARG);
#endif
END_OPTION
OPTION('f', "font", REQUIRED_ARG)
#ifdef HAVE_CAIRO
option_font = optArg;
#else
fatal("termdebug was built without cairo, and therefore tdcompare does not provide " OPTFMT "\n", OPTPRARG);
#endif
END_OPTION
OPTION('W', "cell-width", REQUIRED_ARG)
#ifdef HAVE_CAIRO
PARSE_INT(cell_width, 6, 16);
#else
fatal("termdebug was built without cairo, and therefore tdcompare does not provide " OPTFMT "\n", OPTPRARG);
#endif
END_OPTION
OPTION('H', "cell-heigth", REQUIRED_ARG)
#ifdef HAVE_CAIRO
PARSE_INT(cell_width, 6, 24);
#else
fatal("termdebug was built without cairo, and therefore tdcompare does not provide " OPTFMT "\n", OPTPRARG);
#endif
END_OPTION
OPTION('P', "picture-series", REQUIRED_ARG)
#ifdef HAVE_CAIRO
if (!check_fmt(optArg))
fatal(OPTFMT " argument must have exactly one d-type printf conversion\n", OPTPRARG);
picture_series = optArg;
#else
fatal("termdebug was built without cairo, and therefore tdcompare does not provide " OPTFMT "\n", OPTPRARG);
#endif
END_OPTION
OPTION('s', "stop-on-difference", NO_ARG)
#ifdef HAVE_CAIRO
stop_on_difference = td_true;
#else
fatal("termdebug was built without cairo, and therefore tdcompare does not provide " OPTFMT "\n", OPTPRARG);
#endif
END_OPTION
DOUBLE_DASH
NO_MORE_OPTIONS;
END_OPTION
fatal("Unknown option " OPTFMT "\n", OPTPRARG);
NO_OPTION
if (inputA != NULL) {
if (inputB != NULL)
fatal("More than two recordings specified\n");
inputB = optcurrent;
} else {
inputA = optcurrent;
}
END_OPTIONS
if (inputA == NULL || inputB == NULL)
fatal("Two recordings should be specified\n");
#ifdef HAVE_CAIRO
if (picture_series == NULL)
stop_on_difference = td_true;
#else
stop_on_difference = td_true;
#endif
END_FUNCTION
#if defined(HAVE_CURSES) && defined(HAVE_UNISTRING)
static td_bool advance_script(ExpNode **script, window_t *win) {
while (*script != NULL) {
switch ((*script)->type) {
case EXP_START:
case EXP_INTERACT:
case EXP_ENV:
/* Ignore stuff that isn't relavant to simply viewing the replay. */
break;
case EXP_EXPECT:
win_write_stringlist(win, (*script)->un.args);
break;
case EXP_SEND:
*script = (*script)->next;
return td_true;
case EXP_EXPECT_EXIT:
*script = (*script)->next;
return td_true;
case EXP_WINDOW_SIZE:
win_resize(win, (*script)->un.size.rows, (*script)->un.size.columns);
*script = (*script)->next;
return td_true;
case EXP_EXPECT_SUSPEND:
win_set_paint(win, 0, 0);
win_clrtobot(win);
return td_true;
case EXP_REQUIRE_VERSION:
break;
default:
fatal("Internal error\n");
}
*script = (*script)->next;
}
return td_false;
}
static void do_visual_compare(void) {
td_bool difference_reported = td_false;
const char *winAterm, *winBterm;
int step_count = 0;
init_attr_map();
if ((winA = win_new(24, 80)) == NULL)
fatal("Out of memory\n");
if ((winB = win_new(24, 80)) == NULL)
fatal("Out of memory\n");
winAterm = get_script_env(scriptA, "TERM");
winBterm = get_script_env(scriptB, "TERM");
if (winAterm == NULL)
fatal("Recording %s does not contain a TERM environment variable\n", inputA);
if (winBterm == NULL)
fatal("Recording %s does not contain a TERM environment variable\n", inputB);
if (strcmp(winAterm, winBterm) != 0)
fatal("Recordings have a different TERM environment variable\n");
setup_ti_strings(winAterm, get_script_env(scriptA, "LANG"));
while (td_true) {
if (!advance_script(&scriptA, winA))
break;
if (!advance_script(&scriptB, winB))
break;
#ifdef HAVE_CAIRO
if (picture_series != NULL) {
char output_name_buffer[1024];
snprintf(output_name_buffer, sizeof(output_name_buffer), picture_series, step_count);
win_write_image(winA, winB, output_name_buffer);
}
#endif
if (!win_compare(winA, winB, describe ? stderr : NULL)) {
#ifdef HAVE_CAIRO
if (picture_name != NULL) {
win_write_image(winA, winB, picture_name);
picture_name = NULL;
}
#endif
if (!difference_reported) {
fprintf(stderr, "Recordings have different results\n");
difference_reported = td_true;
}
/* stop_on_difference will be set to false if picture_series == NULL. */
if (stop_on_difference)
exit(EXIT_FAILURE);
describe = td_false;
}
step_count++;
}
if (scriptA != scriptB && !difference_reported)
fatal("Recordings have different results\n");
free_attr_map();
}
#endif
static ExpNode *find_start(ExpNode *script) {
for (; script != NULL && script->type != EXP_START; script = script->next) {}
return script;
}
static void compare_expects(void) {
StringListNode *stringA = scriptA->un.args;
StringListNode *stringB = scriptB->un.args;
int stringA_offset = 0;
int stringB_offset = 0;
int min_length;
while (1) {
min_length = MIN(stringA->length - stringA_offset, stringB->length - stringB_offset);
/* FIXME: explain which string and at which offset */
if (memcmp(stringA->string + stringA_offset, stringB->string + stringB_offset, min_length) != 0)
fatal("Different strings expected at %d/%d\n", scriptA->line, scriptB->line);
stringA_offset += min_length;
if (stringA->length <= stringA_offset) {
stringA = stringA->next;
stringA_offset = 0;
}
stringB_offset += min_length;
if (stringB->length <= stringB_offset) {
stringB = stringB->next;
stringB_offset = 0;
}
if (stringA == NULL && stringB == NULL) {
scriptA = scriptA->next;
scriptB = scriptB->next;
return;
}
if (stringA == NULL) {
/* FIXME: explain which string and at which offset */
if (scriptA->next->type != EXP_EXPECT)
fatal("Different strings expected at %d/%d\n", scriptA->line, scriptB->line);
scriptA = scriptA->next;
stringA = scriptA->un.args;
}
if (stringB == NULL) {
/* FIXME: explain which string and at which offset */
if (scriptB->next->type != EXP_EXPECT)
fatal("Different strings expected at %d/%d\n", scriptA->line, scriptB->line);
scriptB = scriptB->next;
stringB = scriptB->un.args;
}
}
}
static void compare(void) {
static const char *exp2string[] = {
"start", "env", "window_size", "expect", "send", "expect_exit",
"interact", "expect_suspend", "require_version"
};
scriptA = find_start(scriptA);
scriptB = find_start(scriptB);
if (scriptA == NULL)
fatal("Recording '%s' does not have a start directive\n", inputA);
if (scriptB == NULL)
fatal("Recording '%s' does not have a start directive\n", inputB);
while (scriptA != NULL && scriptB != NULL) {
if (scriptA->type != scriptB->type)
fatal("Recordings have different actions (%s/%s) at line %d/%d\n",
exp2string[scriptA->type], exp2string[scriptB->type],
scriptA->line, scriptB->line);
switch (scriptA->type) {
case EXP_START:
case EXP_INTERACT:
/* Ignore stuff that isn't relavant to simply viewing the replay. */
break;
case EXP_EXPECT:
compare_expects();
break;
case EXP_SEND:
break;
case EXP_WINDOW_SIZE:
if (scriptA->un.size.columns != scriptB->un.size.columns ||
scriptA->un.size.rows != scriptB->un.size.rows)
fatal("Recordings set different window size (%dx%d/%dx%d) at line %d/%d\n",
scriptA->un.size.columns, scriptA->un.size.rows,
scriptB->un.size.columns, scriptB->un.size.rows,
scriptA->line, scriptB->line);
break;
case EXP_EXPECT_EXIT:
if (scriptA->un.number != scriptB->un.number)
fatal("Expecting different exit value (%d/%d) at line %d/%d\n",
scriptA->un.number, scriptB->un.number, scriptA->line, scriptB->line);
break;
case EXP_EXPECT_SUSPEND:
break;
default:
fatal("Internal error\n");
}
scriptA = scriptA->next;
scriptB = scriptB->next;
}
}
int tdcompare_main(int argc, char *argv[]) {
parse_options(argc, argv);
reset_lexer(inputA);
parse();
scriptA = script;
script = NULL;
reset_lexer(inputB);
parse();
scriptB = script;
#if defined(HAVE_CURSES) && defined(HAVE_UNISTRING)
if (visual_compare)
do_visual_compare();
else
#endif
compare();
return EXIT_SUCCESS;
}
termdebug-2.2+dfsg/src/curses_handling.c 0000664 0000000 0000000 00000003145 12547225624 0020371 0 ustar 00root root 0000000 0000000 /* Copyright (C) 2010,2012-2013 G.P. Halkes
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3, as
published by the Free Software Foundation.
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, see .
*/
/* We have all this in a separate file, because the curses header files
clutter up the name space too much with macros and what not. This also
means we have to duplicate some of the stuf from common.h. */
#include
#include
#ifdef HAVE_STRDUP
#include
#define port_strdup(_a) strdup(_a)
#else
char *port_strdup(const char *s);
#endif
void reset_tty(void);
char *get_ti_string(const char *name) {
char *result = tigetstr(name);
if (result == (char *) 0 || result == (char *) -1)
return NULL;
return port_strdup(result);
}
int get_ti_bool(const char *name) {
return tigetflag(name);
}
void sanitize_term(void) {
char *tistr;
int errret;
if (setupterm(NULL, 1, &errret) == ERR)
return;
tistr = get_ti_string("rmcup");
if (tistr != NULL)
putp(tistr);
tistr = get_ti_string("rmacs");
if (tistr != NULL)
putp(tistr);
tistr = get_ti_string("cvvis");
if (tistr != NULL)
putp(tistr);
}
void call_setupterm(const char *name) {
setupterm(name, 1, 0);
}
termdebug-2.2+dfsg/src/curses_handling.h 0000664 0000000 0000000 00000001464 12547225624 0020400 0 ustar 00root root 0000000 0000000 /* Copyright (C) 2010,2012 G.P. Halkes
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3, as
published by the Free Software Foundation.
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, see