mirror of
https://github.com/reactos/reactos
synced 2025-10-06 16:32:42 +02:00
Compare commits
1 Commits
ReactOS-0.
...
backups/Fr
Author | SHA1 | Date | |
---|---|---|---|
|
0b9b1711a0 |
@@ -1,2 +0,0 @@
|
||||
dist
|
||||
errors
|
@@ -1,7 +0,0 @@
|
||||
file ntoskrnl/ntoskrnl.nostrip.exe
|
||||
#add-symbol-file lib/ntdll/ntdll.dll 0x77f61000
|
||||
#add-symbol-file lib/kernel32/kernel32.dll 0x77f01000
|
||||
#add-symbol-file apps/exp/exp.exe 0x401000
|
||||
#add-symbol-file subsys/csrss/csrss.exe 0x401000
|
||||
#add-symbol-file subsys/smss/smss.exe 0x401000
|
||||
break exp.c:254
|
340
reactos/COPYING
340
reactos/COPYING
@@ -1,340 +0,0 @@
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) 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
|
||||
this service 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 make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. 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.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the 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 a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE 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.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: 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
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision 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, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This 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 Library General
|
||||
Public License instead of this License.
|
@@ -1,41 +0,0 @@
|
||||
In no particular order
|
||||
|
||||
Rex Jolliff (rex@lvcablemodem.com)
|
||||
Boudewijn Dekker (ariadne@xs4all.nl)
|
||||
Eric Kohl (ekohl@rz-online.de)
|
||||
Emanuele Aliberti (ea@iol.it)
|
||||
David Welch (welch@cwcom.net)
|
||||
Iwan Fatahi (i_fatahi@hotmail.com)
|
||||
Robert Bergkvist (fragdance@hotmail.com)
|
||||
Victor Kirhenshtein (sauros@iname.com)
|
||||
Jason Filby (jasonfilby@yahoo.com)
|
||||
Brian Palmer (brianp@sginet.com)
|
||||
Phillip Susi (phreak@iag.net)
|
||||
Paolo Pantaleo (paolopan@freemail.it)
|
||||
Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
|
||||
Source and inspiration from
|
||||
|
||||
WINE (http://www.winehq.com)
|
||||
WinFree (http://www.stack.nl/~onno/win32/)
|
||||
Linux (http://www.kernel.org)
|
||||
|
||||
References (Rex's at least)
|
||||
|
||||
Baker, Art. The Windows NT Device Driver Book. Prentice Hall, 1997.
|
||||
Borate, Dabak & Phadke. Undocumented Windows NT. M&T Books, 1999.
|
||||
Brain, Marshall. Win32 System Services. Prentice Hall, 1996.
|
||||
Cant, Chris. Writing Windows WDM Device Drivers. R&D Books, 1999.
|
||||
Canton & Sanchez. IBM Microcomputers: A Programmer's Handbook. McGraw Hill, 1990.
|
||||
Davis & Wallace. Windows Undocumented File Formats. R&D Books, 1997.
|
||||
Mason & Viscarola. Windows NT Device Driver Development. Macmillan, 1999.
|
||||
Mitchell, Stan. Inside the Windows 95 File System. O'Reilly, 1997.
|
||||
Murray, James D. Windows NT Event Logging. O'Reilly, 1998.
|
||||
Nagar, Rajeev. Windows NT File System Internals. O'Reilly, 1997.
|
||||
Osbourne, Sandra. Windows NT Registry: A Settings Reference. New Riders, 1998.
|
||||
Pietrek, Matt. Windows 95 System Programming Secrets. IDG, 1995.
|
||||
Richter, Jeffery. Advanced Windows, 3rd ed. Microsoft, 1997.
|
||||
Simon, Richard J. Windows NT Win32 API Superbible. Waite Group, 1996.
|
||||
Solomon, David A. Inside Windows NT, 2nd Ed. Microsoft, 1998.
|
||||
"The NT Insider." Open Systems Resources, 1999-2000.
|
||||
|
@@ -1,154 +0,0 @@
|
||||
2001-03-18 David Welch <welch@cwcom>
|
||||
|
||||
* ntoskrnl/ke/apc.c (KiDeliverApc): Bug fix.
|
||||
* ntoskrnl/ke/apc.c (KeInsertQueueApc): More comments.
|
||||
* ntoskrnl/ke/catch.c (KiDispatchException): Bug fix.
|
||||
* ntoskrnl/ke/timer.c (KeDelayExecutionThread): Don't use removed
|
||||
function KeAddTimeoutThread.
|
||||
* ntoskrnl/ke/timer.c (KeAddTimeoutThread): Removed.
|
||||
* ntoskrnl/ke/wait.c (KeWaitForSingleObject, KeWaitForMultipleObjects):
|
||||
Don't use KeAddTimeoutThread.
|
||||
* ntoskrnl/mm/freelist.c (MmAllocateContiguousAlignedMemory): Bug fix
|
||||
* ntoskrnl/mm/freelist.c (MmAllocatePage): Allocate from the top
|
||||
memory.
|
||||
|
||||
2001-03-17 David Welch <welch@cwcom.net>
|
||||
|
||||
* ntoskrnl/ke/catch.c (KiDispatchException): Implementation of
|
||||
exception handling, user-mode only.
|
||||
|
||||
2001-03-16 David Welch <welch@cwcom.net>
|
||||
|
||||
* include/ddk/zw.h: Corrected declarations of NtCreateProfile,
|
||||
NtQueryIntervalProfile, NtSetIntervalProfile.
|
||||
* include/ddk/zwtypes.h: Added definitions of KPROFILE_SOURCE.
|
||||
* ntoskrnl/include/internal/ke.h: Added the interrupted EIP as a
|
||||
parameter to KiUpdateSystemTime for profiling purposes.
|
||||
* ntoskrnl/include/internal/nt: Added declaration for profiling
|
||||
support initialization.
|
||||
* ntoskrnl/ke/timer.c (KiUpdateSystemTime, KeExpireTimers): Call
|
||||
the profiling code on a timer interrupt with the interrupt EIP.
|
||||
* ntoskrnl/ke/i386/irq.c (KiDispatchInterrupt): Pass the interrupted
|
||||
EIP to KiUpdateSystemTime.
|
||||
* ntoskrnl/mm/virtual.c (NtReadVirtualMemory, NtWriteVirtualMemory):
|
||||
Release the MDLs used properly.
|
||||
* ntoskrnl/nt/nt.c: Call the profiling support initialization.
|
||||
* ntoskrnl/nt/ntevent.c (NtCreateEvent): Don't try copying the
|
||||
ObjectAttributes parameter if it is NULL.
|
||||
* ntoskrnl/nt/profile.c: Implemented profiling.
|
||||
|
||||
2001-03-16 David Welch <welch@cwcom.net>
|
||||
|
||||
* ntoskrnl/include/internal/safe.h: Corrected typo.
|
||||
* ntoskrnl/nt/ntevent.c (NtCreateEvent, NtOpenEvent, NtQueryEvent):
|
||||
Corrected typos.
|
||||
* ntoskrnl/rtl/mem.c: Missing header file.
|
||||
|
||||
2001-03-16 David Welch <welch@cwcom.net>
|
||||
|
||||
* ntoskrnl/include/internal/safe.h: Add definitions for handling
|
||||
potentially unsafe pointers.
|
||||
|
||||
2001-03-16 David Welch <welch@cwcom.net>
|
||||
|
||||
* ntoskrnl/include/internal/mm.h: Removed MmSafeCopyToUser and
|
||||
MmSafeCopyFromUser as source files need these but don't want internal
|
||||
mm definitions.
|
||||
* ntoskrnl/nt/ntevent.c (NtCreateEvent, NtOpenEvent, NtPulseEvent,
|
||||
NtQueryEvent, NtResetEvent, NtSetEvent): Copy data to and from
|
||||
user mode safely.
|
||||
* ntoskrnl/rtl/mem.c (MmCopyToCaller, MmCopyFromCaller): Helper
|
||||
functions for copying data to and from potentially unsafe pointers.
|
||||
|
||||
2000-12-23 David Welch <welch@cwcom.net>
|
||||
|
||||
* All task switching is done in software.
|
||||
* Beginnings of v86 mode support.
|
||||
|
||||
2000-12-22 David Welch <welch@cwcom.net>
|
||||
|
||||
* ntoskrnl/ps/kill.c (PiTerminateProcessThreads): Drop
|
||||
PiThreadListLock before calling PsTerminateOtherThread
|
||||
|
||||
2000-12-16 David Welch <welch@cwcom.net>
|
||||
|
||||
* ntoskrnl/ex/fmutex.c (ExReleaseFastMutexUnsafe): Only set the
|
||||
fast mutex's owner back to NULL if it is being released
|
||||
|
||||
2000-12-10 David Welch <welch@cwcom.net>
|
||||
|
||||
* ntoskrnl/ke/i386/vm86_sup.S (Ki386RetToV86Mode): Added function
|
||||
to do the raw switch to v86 mode.
|
||||
* ntoskrnl/include/internal/vm86.h: Definitions for the v86 mode
|
||||
support.
|
||||
|
||||
2000-12-10 David Welch <welch@cwcom.net>
|
||||
|
||||
* ntoskrnl/ke/i386/trap.s (PsBeginThreadWithContextInternal): Moved
|
||||
to ntoskrnl/ke/i386/bswitch.S.
|
||||
* ntoskrnl/ke/i386/trap.s (interrupt_handler2e): Moved to
|
||||
ntoskrnl/ke/i386/syscall.S.
|
||||
* ntoskrnl/ke/i386/trap.s (old_interrupt_handler2e): Removed.
|
||||
|
||||
2000-12-04 David Welch <welch@cwcom.net>
|
||||
|
||||
* ntoskrnl/ke/i386/irq.c (KiInterruptDispatch): Record the last PC
|
||||
value for a rescheduled thread.
|
||||
* ntoskrnl/ke/i386/irqhand.s: Construct a primitive trap frame
|
||||
in interrupt handlers.
|
||||
|
||||
2000-08-30 David Welch <welch@cwcom.net>
|
||||
|
||||
* Added calibration of KeStallExecutionProcessor timing
|
||||
(code from linux 2.2.16).
|
||||
|
||||
* Corrected compilation bugs in user32 library.
|
||||
|
||||
* Corrected compilation bugs related to anonymous structs
|
||||
in ndis code.
|
||||
|
||||
* Pass command line to kernel from loadros.
|
||||
|
||||
* Corrected PIC mask calculation.
|
||||
|
||||
2000-05-27 David Welch <welch@cwcom.net>
|
||||
|
||||
* Fixed issue with closing non-existent or already closed
|
||||
handle.
|
||||
|
||||
2000-01-26 David Welch <welch@cwcom.net>
|
||||
|
||||
* ZwCreateProcess now maps ntdll rather than the user-mode
|
||||
code.
|
||||
|
||||
1999-09-06 David Welch <welch@cwcom.net>
|
||||
|
||||
* Implemented ZwOpenProcess.
|
||||
|
||||
* Partially implemented killing other threads (possible memory
|
||||
leaks).
|
||||
|
||||
* Made a start on a proper implemention of APCs (based on
|
||||
article in NT insider).
|
||||
|
||||
1998-12-08 David Welch <welch@cwcom.net>
|
||||
|
||||
* Corrected bug in shell (Read two keypresses and assumed they
|
||||
where the key going up and down respectively).
|
||||
|
||||
* Corrected race in dpc handling.
|
||||
|
||||
* Took out cleanup sections in ZwReadFile (now handled by the
|
||||
APC).
|
||||
|
||||
* Disabled broken code in kernel32.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,39 +0,0 @@
|
||||
1. Build environment
|
||||
|
||||
To build the system you need either mingw32 installed on Windows or a
|
||||
mingw32 cross compiler running on unix.
|
||||
|
||||
2. Building
|
||||
|
||||
To build from Windows run make. To build from unix, edit rules.mak and change
|
||||
the PREFIX variable to the correct value for your cross-compiler, then run
|
||||
'make'.
|
||||
|
||||
3. Installation
|
||||
|
||||
Installation isn't yet automated, sorry. The system can only be installed on
|
||||
the first partition which must be formatted for DOS. Set up a directory
|
||||
structure like the following
|
||||
|
||||
make directories C:\reactos,C:\reactos\system32,C:\reactos\system32\drivers
|
||||
|
||||
Copy apps/system/shell/shell.exe to C:\reactos\system32
|
||||
Copy subsys/smss/smss.exe to C:\reactos\system32
|
||||
Copy apps/system/winlogon/winlogon.exe to C:\reactos\system32
|
||||
Copy apps/system/services/services.exe to C:\reactos\system32
|
||||
Copy services/input/keyboard/keyboard.sys to C:\reactos\system32\drivers
|
||||
Copy services/dd/blue/blue.sys to C:\reactos\system32\drivers
|
||||
Copy lib/ntdll/ntdll.dll to C:\reactos\system32
|
||||
Copy lib/kernel32/kernel32.dll to C:\reactos\system32
|
||||
Copy lib/crtdll/crtdll.dll to C:\reactos\system32
|
||||
|
||||
The system can only be started from DOS. Copy the following files,
|
||||
services/dd/ide/ide.sys, services/fs/vfat/vfatfsd.sys
|
||||
ntoskrnl/ntoskrnl.exe and loaders/dos/loadros.com, to a suitable
|
||||
directory, such as C:\. The system can then be booted with the
|
||||
command 'loadros.com ntoskrnl.exe ide.sys vfatfs.sys'.
|
||||
|
||||
|
||||
You may also want to try running the enhanced shell, cmd.exe, found in
|
||||
the rosapps CVS module. For more information see the doc directory
|
||||
|
427
reactos/Makefile
427
reactos/Makefile
@@ -1,427 +0,0 @@
|
||||
#
|
||||
# Global makefile
|
||||
#
|
||||
|
||||
#
|
||||
# Select your host
|
||||
#
|
||||
#HOST = mingw32-linux
|
||||
#HOST = mingw32-windows
|
||||
|
||||
PATH_TO_TOP = .
|
||||
|
||||
include rules.mak
|
||||
|
||||
#
|
||||
# Required to run the system
|
||||
#
|
||||
COMPONENTS = iface_native iface_additional ntoskrnl
|
||||
BUS = acpi isapnp
|
||||
DLLS = ntdll kernel32 crtdll advapi32 fmifs gdi32 secur32 user32 ws2_32 \
|
||||
msafd msvcrt
|
||||
SUBSYS = smss win32k csrss
|
||||
|
||||
#
|
||||
# Select the server(s) you want to build
|
||||
#
|
||||
#SERVERS = posix linux os2
|
||||
SERVERS = win32
|
||||
|
||||
#
|
||||
# Select the loader(s) you want to build
|
||||
#
|
||||
#LOADERS = boot dos
|
||||
LOADERS = dos
|
||||
|
||||
#
|
||||
# Select the device drivers and filesystems you want
|
||||
#
|
||||
#DEVICE_DRIVERS = beep event floppy ide_test mouse sound test test1 parallel serial
|
||||
DEVICE_DRIVERS = vidport vga blue ide null floppy
|
||||
|
||||
#INPUT_DRIVERS = keyboard
|
||||
INPUT_DRIVERS = keyboard
|
||||
|
||||
#FS_DRIVERS = vfat minix ms np ext2 template
|
||||
FS_DRIVERS = vfat ms np
|
||||
|
||||
#NET_DRIVERS = ndis tdi tcpip tditest wshtcpip afd
|
||||
NET_DRIVERS = ndis tcpip tditest wshtcpip afd
|
||||
|
||||
#NET_DEVICE_DRIVERS = ne2000
|
||||
NET_DEVICE_DRIVERS = ne2000
|
||||
|
||||
#
|
||||
# system applications (required for startup)
|
||||
#
|
||||
#SYS_APPS = shell winlogon services
|
||||
SYS_APPS = shell winlogon services
|
||||
|
||||
APPS = args hello test cat bench apc shm lpc thread event file gditest \
|
||||
pteb consume dump_shared_data vmtest regtest alive mstest objdir
|
||||
|
||||
#NET_APPS = ping roshttpd
|
||||
NET_APPS = ping
|
||||
|
||||
|
||||
KERNEL_SERVICES = $(DEVICE_DRIVERS) $(INPUT_DRIVERS) $(FS_DRIVERS) $(NET_DRIVERS) $(NET_DEVICE_DRIVERS)
|
||||
|
||||
all: buildno $(COMPONENTS) $(BUS) $(DLLS) $(SUBSYS) $(LOADERS) $(KERNEL_SERVICES) $(SYS_APPS) $(APPS) $(NET_APPS)
|
||||
|
||||
.PHONY: all
|
||||
|
||||
clean: buildno_clean $(COMPONENTS:%=%_clean) $(BUS:%=%_clean) $(DLLS:%=%_clean) $(LOADERS:%=%_clean) \
|
||||
$(KERNEL_SERVICES:%=%_clean) $(SUBSYS:%=%_clean) $(SYS_APPS:%=%_clean) $(APPS:%=%_clean)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
ifeq ($(HOST),mingw32-linux)
|
||||
rcopy$(EXE_POSTFIX): rcopy.c
|
||||
$(HOST_CC) -g -DUNIX_PATHS rcopy.c -o rcopy$(EXE_POSTFIX)
|
||||
endif
|
||||
ifeq ($(HOST),mingw32-windows)
|
||||
rcopy$(EXE_POSTFIX): rcopy.c
|
||||
$(HOST_CC) -g -DDOS_PATHS rcopy.c -o rcopy$(EXE_POSTFIX)
|
||||
endif
|
||||
|
||||
ifeq ($(HOST),mingw32-linux)
|
||||
rmkdir$(EXE_POSTFIX): rmkdir.c
|
||||
$(HOST_CC) -g -DUNIX_PATHS rmkdir.c -o rmkdir$(EXE_POSTFIX)
|
||||
endif
|
||||
ifeq ($(HOST),mingw32-windows)
|
||||
rmkdir$(EXE_POSTFIX): rmkdir.c
|
||||
$(HOST_CC) -g -DDOS_PATHS rmkdir.c -o rmkdir$(EXE_POSTFIX)
|
||||
endif
|
||||
|
||||
|
||||
install: rcopy$(EXE_POSTFIX) rmkdir$(EXE_POSTFIX) make_install_dirs autoexec_install \
|
||||
$(COMPONENTS:%=%_install) $(BUS:%=%_install) \
|
||||
$(DLLS:%=%_install) $(LOADERS:%=%_install) \
|
||||
$(KERNEL_SERVICES:%=%_install) $(SUBSYS:%=%_install) \
|
||||
$(SYS_APPS:%=%_install) $(APPS:%=%_install)
|
||||
|
||||
dist: rcopy$(EXE_POSTFIX) clean_dist_dir make_dist_dirs $(COMPONENTS:%=%_dist) \
|
||||
$(BUS:%=%_dist) $(DLLS:%=%_dist) \
|
||||
$(LOADERS:%=%_dist) $(KERNEL_SERVICES:%=%_dist) $(SUBSYS:%=%_dist) \
|
||||
$(SYS_APPS:%=%_dist) $(APPS:%=%_dist)
|
||||
|
||||
#
|
||||
# Build number generator
|
||||
#
|
||||
buildno: include/reactos/version.h
|
||||
make -C apps/buildno
|
||||
|
||||
buildno_clean:
|
||||
make -C apps/buildno clean
|
||||
|
||||
buildno_dist:
|
||||
|
||||
buildno_install:
|
||||
|
||||
.PHONY: buildno buildno_clean buildno_dist buildno_install
|
||||
|
||||
#
|
||||
# System Applications
|
||||
#
|
||||
$(SYS_APPS): %:
|
||||
make -C apps/system/$*
|
||||
|
||||
$(SYS_APPS:%=%_clean): %_clean:
|
||||
make -C apps/system/$* clean
|
||||
|
||||
$(SYS_APPS:%=%_dist): %_dist:
|
||||
make -C apps/system/$* dist
|
||||
|
||||
$(SYS_APPS:%=%_install): %_install:
|
||||
make -C apps/system/$* install
|
||||
|
||||
.PHONY: $(SYS_APPS) $(SYS_APPS:%=%_clean) $(SYS_APPS:%=%_install) $(SYS_APPS:%=%_dist)
|
||||
|
||||
#
|
||||
# Applications
|
||||
#
|
||||
$(APPS): %:
|
||||
make -C apps/$*
|
||||
|
||||
$(APPS:%=%_clean): %_clean:
|
||||
make -C apps/$* clean
|
||||
|
||||
$(APPS:%=%_dist): %_dist:
|
||||
make -C apps/$* dist
|
||||
|
||||
$(APPS:%=%_install): %_install:
|
||||
make -C apps/$* install
|
||||
|
||||
.PHONY: $(APPS) $(APPS:%=%_clean) $(APPS:%=%_install) $(APPS:%=%_dist)
|
||||
|
||||
#
|
||||
# Network applications
|
||||
#
|
||||
$(NET_APPS): %:
|
||||
make -C apps/net/$*
|
||||
|
||||
$(NET_APPS:%=%_clean): %_clean:
|
||||
make -C apps/net/$* clean
|
||||
|
||||
$(NET_APPS:%=%_dist): %_dist:
|
||||
make -C apps/net/$* dist
|
||||
|
||||
$(NET_APPS:%=%_install): %_install:
|
||||
make -C apps/net/$* install
|
||||
|
||||
.PHONY: $(NET_APPS) $(NET_APPS:%=%_clean) $(NET_APPS:%=%_install) $(NET_APPS:%=%_dist)
|
||||
|
||||
#
|
||||
# Interfaces
|
||||
#
|
||||
iface_native:
|
||||
make -C iface/native
|
||||
|
||||
iface_native_clean:
|
||||
make -C iface/native clean
|
||||
|
||||
iface_native_install:
|
||||
|
||||
iface_native_dist:
|
||||
|
||||
iface_additional:
|
||||
make -C iface/addsys
|
||||
|
||||
iface_additional_clean:
|
||||
make -C iface/addsys clean
|
||||
|
||||
iface_additional_install:
|
||||
|
||||
iface_additional_dist:
|
||||
|
||||
.PHONY: iface_native iface_native_clean iface_native_install \
|
||||
iface_native_dist \
|
||||
iface_additional iface_additional_clean iface_additional_install \
|
||||
iface_additional_dist
|
||||
|
||||
#
|
||||
# Bus driver rules
|
||||
#
|
||||
$(BUS): %:
|
||||
make -C services/bus/$*
|
||||
|
||||
$(BUS:%=%_clean): %_clean:
|
||||
make -C services/bus/$* clean
|
||||
|
||||
$(BUS:%=%_install): %_install:
|
||||
make -C services/bus/$* install
|
||||
|
||||
$(BUS:%=%_dist): %_dist:
|
||||
make -C services/bus/$* dist
|
||||
|
||||
.PHONY: $(BUS) $(BUS:%=%_clean) \
|
||||
$(BUS:%=%_install) $(BUS:%=%_dist)
|
||||
|
||||
#
|
||||
# Device driver rules
|
||||
#
|
||||
$(DEVICE_DRIVERS): %:
|
||||
make -C services/dd/$*
|
||||
|
||||
$(DEVICE_DRIVERS:%=%_clean): %_clean:
|
||||
make -C services/dd/$* clean
|
||||
|
||||
$(DEVICE_DRIVERS:%=%_install): %_install:
|
||||
make -C services/dd/$* install
|
||||
|
||||
$(DEVICE_DRIVERS:%=%_dist): %_dist:
|
||||
make -C services/dd/$* dist
|
||||
|
||||
.PHONY: $(DEVICE_DRIVERS) $(DEVICE_DRIVERS:%=%_clean) \
|
||||
$(DEVICE_DRIVERS:%=%_install) $(DEVICE_DRIVERS:%=%_dist)
|
||||
|
||||
#
|
||||
# Input driver rules
|
||||
#
|
||||
$(INPUT_DRIVERS): %:
|
||||
make -C services/input/$*
|
||||
|
||||
$(INPUT_DRIVERS:%=%_clean): %_clean:
|
||||
make -C services/input/$* clean
|
||||
|
||||
$(INPUT_DRIVERS:%=%_install): %_install:
|
||||
make -C services/input/$* install
|
||||
|
||||
$(INPUT_DRIVERS:%=%_dist): %_dist:
|
||||
make -C services/input/$* dist
|
||||
|
||||
.PHONY: $(INPUT_DRIVERS) $(INPUT_DRIVERS:%=%_clean) \
|
||||
$(INPUT_DRIVERS:%=%_install) $(INPUT_DRIVERS:%=%_dist)
|
||||
|
||||
$(FS_DRIVERS): %:
|
||||
make -C services/fs/$*
|
||||
|
||||
$(FS_DRIVERS:%=%_clean): %_clean:
|
||||
make -C services/fs/$* clean
|
||||
|
||||
$(FS_DRIVERS:%=%_install): %_install:
|
||||
make -C services/fs/$* install
|
||||
|
||||
$(FS_DRIVERS:%=%_dist): %_dist:
|
||||
make -C services/fs/$* dist
|
||||
|
||||
.PHONY: $(FS_DRIVERS) $(FS_DRIVERS:%=%_clean) $(FS_DRIVERS:%=%_install) \
|
||||
$(FS_DRIVERS:%=%_dist)
|
||||
|
||||
$(NET_DRIVERS): %:
|
||||
make -C services/net/$*
|
||||
|
||||
$(NET_DRIVERS:%=%_clean): %_clean:
|
||||
make -C services/net/$* clean
|
||||
|
||||
$(NET_DRIVERS:%=%_install): %_install:
|
||||
make -C services/net/$* install
|
||||
|
||||
$(NET_DRIVERS:%=%_dist): %_dist:
|
||||
make -C services/net/$* dist
|
||||
|
||||
.PHONY: $(NET_DRIVERS) $(NET_DRIVERS:%=%_clean) $(NET_DRIVERS:%=%_install) \
|
||||
$(NET_DRIVERS:%=%_dist)
|
||||
|
||||
$(NET_DEVICE_DRIVERS): %:
|
||||
make -C services/net/dd/$*
|
||||
|
||||
$(NET_DEVICE_DRIVERS:%=%_clean): %_clean:
|
||||
make -C services/net/dd/$* clean
|
||||
|
||||
$(NET_DEVICE_DRIVERS:%=%_install): %_install:
|
||||
make -C services/net/dd/$* install
|
||||
|
||||
$(NET_DEVICE_DRIVERS:%=%_dist): %_dist:
|
||||
make -C services/net/dd/$* dist
|
||||
|
||||
.PHONY: $(NET_DEVICE_DRIVERS) $(NET_DEVICE_DRIVERS:%=%_clean) \
|
||||
$(NET_DEVICE_DRIVERS:%=%_install) $(NET_DEVICE_DRIVERS:%=%_dist)
|
||||
|
||||
#
|
||||
# Kernel loaders
|
||||
#
|
||||
|
||||
$(LOADERS): %:
|
||||
make -C loaders/$*
|
||||
|
||||
$(LOADERS:%=%_clean): %_clean:
|
||||
make -C loaders/$* clean
|
||||
|
||||
$(LOADERS:%=%_install): %_install:
|
||||
make -C loaders/$* install
|
||||
|
||||
$(LOADERS:%=%_dist): %_dist:
|
||||
make -C loaders/$* dist
|
||||
|
||||
.PHONY: $(LOADERS) $(LOADERS:%=%_clean) $(LOADERS:%=%_install) \
|
||||
$(LOADERS:%=%_dist)
|
||||
|
||||
#
|
||||
# Required system components
|
||||
#
|
||||
|
||||
ntoskrnl:
|
||||
make -C ntoskrnl
|
||||
|
||||
ntoskrnl_clean:
|
||||
make -C ntoskrnl clean
|
||||
|
||||
ntoskrnl_install:
|
||||
make -C ntoskrnl install
|
||||
|
||||
ntoskrnl_dist:
|
||||
make -C ntoskrnl dist
|
||||
|
||||
.PHONY: ntoskrnl ntoskrnl_clean ntoskrnl_install ntoskrnl_dist
|
||||
|
||||
#
|
||||
# Required DLLs
|
||||
#
|
||||
|
||||
$(DLLS): %:
|
||||
make -C lib/$*
|
||||
|
||||
$(DLLS:%=%_clean): %_clean:
|
||||
make -C lib/$* clean
|
||||
|
||||
$(DLLS:%=%_install): %_install:
|
||||
make -C lib/$* install
|
||||
|
||||
$(DLLS:%=%_dist): %_dist:
|
||||
make -C lib/$* dist
|
||||
|
||||
.PHONY: $(DLLS) $(DLLS:%=%_clean) $(DLLS:%=%_install) $(DLLS:%=%_dist)
|
||||
|
||||
#
|
||||
# Kernel Subsystems
|
||||
#
|
||||
|
||||
$(SUBSYS): %:
|
||||
make -C subsys/$*
|
||||
|
||||
$(SUBSYS:%=%_clean): %_clean:
|
||||
make -C subsys/$* clean
|
||||
|
||||
$(SUBSYS:%=%_install): %_install:
|
||||
make -C subsys/$* install
|
||||
|
||||
$(SUBSYS:%=%_dist): %_dist:
|
||||
make -C subsys/$* dist
|
||||
|
||||
.PHONY: $(SUBSYS) $(SUBSYS:%=%_clean) $(SUBSYS:%=%_install) \
|
||||
$(SUBSYS:%=%_dist)
|
||||
|
||||
#
|
||||
# Make an install floppy
|
||||
#
|
||||
make_install_dirs:
|
||||
./rmkdir $(FLOPPY_DIR)/dlls
|
||||
./rmkdir $(FLOPPY_DIR)/apps
|
||||
./rmkdir $(FLOPPY_DIR)/drivers
|
||||
./rmkdir $(FLOPPY_DIR)/subsys
|
||||
|
||||
|
||||
.PHONY: make_install_dirs
|
||||
|
||||
autoexec_install: $(FLOPPY_DIR)/autoexec.bat
|
||||
|
||||
$(FLOPPY_DIR)/autoexec.bat: bootflop.bat
|
||||
$(CP) bootflop.bat $(FLOPPY_DIR)/autoexec.bat
|
||||
|
||||
#
|
||||
# Make a distribution saveset
|
||||
#
|
||||
|
||||
clean_dist_dir:
|
||||
ifeq ($(DOSCLI),yes)
|
||||
- $(RM) $(DIST_DIR)\dlls\*.dll
|
||||
- $(RM) $(DIST_DIR)\apps\*.exe
|
||||
- $(RM) $(DIST_DIR)\drivers\*.sys
|
||||
- $(RM) $(DIST_DIR)\subsys\*.exe
|
||||
- $(RMDIR) $(DIST_DIR)\dlls
|
||||
- $(RMDIR) $(DIST_DIR)\apps
|
||||
- $(RMDIR) $(DIST_DIR)\drivers
|
||||
- $(RMDIR) $(DIST_DIR)\subsys
|
||||
- $(RMDIR) $(DIST_DIR)
|
||||
else
|
||||
$(RM) -r $(DIST_DIR)
|
||||
endif
|
||||
|
||||
make_dist_dirs: ./rmkdir
|
||||
./rmkdir $(DIST_DIR)
|
||||
./rmkdir $(DIST_DIR)/dlls
|
||||
./rmkdir $(DIST_DIR)/apps
|
||||
./rmkdir $(DIST_DIR)/drivers
|
||||
./rmkdir $(DIST_DIR)/dlls
|
||||
./rmkdir $(DIST_DIR)/subsys
|
||||
|
||||
.PHONY: clean_dist_dir make_dist_dirs
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
etags:
|
||||
find . -name "*.[ch]" -print | etags --language=c -
|
||||
|
||||
# EOF
|
15
reactos/NEWS
15
reactos/NEWS
@@ -1,15 +0,0 @@
|
||||
0.0.14: Converted to PE format
|
||||
All system libraries are now dlls
|
||||
|
||||
0.0.13: Mostly bugfixes (I think)
|
||||
|
||||
0.0.12: Added support for multiple processes (not really tested)
|
||||
System calls
|
||||
kernel32 now compiles (only as a static library)
|
||||
Fixed invalid tss bug (hopefully)
|
||||
Added section support
|
||||
Added some of the ZwxxxVirtual calls
|
||||
Added prototype caching functions (only the Minix fsd actually
|
||||
uses them)
|
||||
Added handle access and type checking
|
||||
Prototype APC implementation (no support for user APCs)
|
@@ -1,24 +0,0 @@
|
||||
About Reactos
|
||||
|
||||
1. What is Reactos
|
||||
|
||||
A project aiming to make an approximate clone of Windows NT, compatible
|
||||
with most Windows applications.
|
||||
|
||||
The project has a website at http://www.reactos.com/
|
||||
|
||||
2. Building Reactos
|
||||
|
||||
See the INSTALL file for more details.
|
||||
|
||||
3. More information
|
||||
|
||||
See the doc subdirectory for some sparse notes
|
||||
|
||||
4. Who is responsible
|
||||
|
||||
See the CREDITS file
|
||||
|
||||
5. Recent developments
|
||||
|
||||
See the NEWS file
|
@@ -1,33 +0,0 @@
|
||||
#include <windows.h>
|
||||
|
||||
extern int main(int args, char* argv[], char* environ[]);
|
||||
|
||||
static unsigned int _argc = 0;
|
||||
static char** _argv = NULL;
|
||||
static char** _environ = NULL;
|
||||
|
||||
int mainCRTStartup(PWSTR args)
|
||||
{
|
||||
int nRet;
|
||||
|
||||
// SetUnhandledExceptionFilter(NULL);
|
||||
|
||||
// _fpreset();
|
||||
|
||||
// __GetMainArgs(&_argc, &_argv, &_environ, 0);
|
||||
|
||||
nRet = main(_argc, _argv, _environ);
|
||||
|
||||
// _cexit();
|
||||
|
||||
ExitProcess(nRet);
|
||||
}
|
||||
|
||||
int WinMainCRTStartup()
|
||||
{
|
||||
return mainCRTStartup(NULL);
|
||||
}
|
||||
|
||||
void __main(void)
|
||||
{
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP=../..
|
||||
|
||||
TARGET_NAME=alive
|
||||
|
||||
OBJECTS=\
|
||||
$(TARGET_NAME).o
|
||||
|
||||
LIBRARIES=\
|
||||
$(PATH_TO_TOP)/lib/kernel32/kernel32.a\
|
||||
$(PATH_TO_TOP)/lib/crtdll/crtdll.a\
|
||||
$(PATH_TO_TOP)/lib/user32/user32.a
|
||||
|
||||
PROGS=\
|
||||
$(TARGET_NAME).exe
|
||||
|
||||
BASE_CFLAGS = -I$(PATH_TO_TOP)/include
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) $(TARGET_NAME).o
|
||||
- $(RM) $(TARGET_NAME).exe
|
||||
- $(RM) $(TARGET_NAME).sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=$(PATH_TO_TOP)/$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(PATH_TO_TOP)/$(DIST_DIR)/apps/%): $(PATH_TO_TOP)/$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* $(PATH_TO_TOP)/$(DIST_DIR)/apps/$*
|
||||
|
||||
$(TARGET_NAME).exe: $(OBJECTS)
|
||||
$(CC)\
|
||||
$(OBJECTS)\
|
||||
$(LIBRARIES)\
|
||||
-o $(TARGET_NAME).exe
|
||||
$(NM) --numeric-sort $(TARGET_NAME).exe > $(TARGET_NAME).sym
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
@@ -1,48 +0,0 @@
|
||||
/* $Id: alive.c,v 1.2 2001/03/26 21:30:20 ea Exp $
|
||||
*
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
HANDLE StandardOutput = INVALID_HANDLE_VALUE;
|
||||
CHAR Message [80];
|
||||
DWORD CharactersToWrite = 0;
|
||||
DWORD WrittenCharacters = 0;
|
||||
INT d = 0, h = 0, m = 0, s = 0;
|
||||
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
{
|
||||
StandardOutput = GetStdHandle (STD_OUTPUT_HANDLE);
|
||||
if (INVALID_HANDLE_VALUE == StandardOutput)
|
||||
{
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
while (TRUE)
|
||||
{
|
||||
/* Prepare the message and update it */
|
||||
CharactersToWrite =
|
||||
wsprintf (
|
||||
Message,
|
||||
"Alive for %dd %dh %d' %d\" \r",
|
||||
d, h, m, s
|
||||
);
|
||||
WriteConsole (
|
||||
StandardOutput,
|
||||
Message,
|
||||
CharactersToWrite,
|
||||
& WrittenCharacters,
|
||||
NULL
|
||||
);
|
||||
/* suspend the execution for 1s */
|
||||
Sleep (1000);
|
||||
/* increment seconds */
|
||||
++ s;
|
||||
if (60 == s) { s = 0; ++ m; }
|
||||
if (60 == m) { m = 0; ++ h; }
|
||||
if (24 == h) { h = 0; ++ d; }
|
||||
}
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* EOF */
|
@@ -1,87 +0,0 @@
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
VOID STDCALL
|
||||
ApcRoutine(PVOID Context,
|
||||
PIO_STATUS_BLOCK IoStatus,
|
||||
ULONG Reserved)
|
||||
{
|
||||
printf("(apc.exe) ApcRoutine(Context %p)\n", Context);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
NTSTATUS Status;
|
||||
HANDLE FileHandle;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING FileName;
|
||||
IO_STATUS_BLOCK IoStatus;
|
||||
CHAR Buffer[256];
|
||||
HANDLE EventHandle;
|
||||
|
||||
AllocConsole();
|
||||
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
printf("APC test program\n");
|
||||
|
||||
EventHandle = CreateEventW(NULL,
|
||||
FALSE,
|
||||
FALSE,
|
||||
NULL);
|
||||
if (EventHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("Failed to create event\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Opening file\n");
|
||||
RtlInitUnicodeString(&FileName,
|
||||
L"\\C:\\a.txt");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&FileName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
printf("Creating file\n");
|
||||
FileHandle = CreateFileW(L"C:\\a.txt",
|
||||
FILE_GENERIC_READ | FILE_GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
if (FileHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("Open failed\n");
|
||||
return 0;
|
||||
}
|
||||
printf("Reading file\n");
|
||||
Status = ZwReadFile(FileHandle,
|
||||
NULL,
|
||||
(PIO_APC_ROUTINE)ApcRoutine,
|
||||
(PVOID)0xdeadbeef,
|
||||
&IoStatus,
|
||||
Buffer,
|
||||
256,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
printf("Read failed\n");
|
||||
}
|
||||
printf("Waiting\n");
|
||||
WaitForSingleObjectEx(EventHandle, INFINITE, TRUE);
|
||||
printf("Returned from wait\n");
|
||||
ZwClose(FileHandle);
|
||||
printf("Program finished\n");
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,40 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
CFLAGS = -g
|
||||
|
||||
OBJECTS= apc.o
|
||||
PROGS= apc.exe
|
||||
|
||||
BASE_CFLAGS = -I../../include
|
||||
LIBS = ../../lib/crtdll/crtdll.a ../../lib/kernel32/kernel32.a \
|
||||
../../lib/ntdll/ntdll.a
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) apc.o
|
||||
- $(RM) apc.exe
|
||||
- $(RM) apc.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
apc.exe: $(OBJECTS) $(LIBS)
|
||||
$(CC) $(OBJECTS) $(LIBS) -o apc.exe
|
||||
$(NM) --numeric-sort apc.exe > apc.sym
|
||||
|
||||
include ../../rules.mak
|
@@ -1,39 +0,0 @@
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
void debug_printf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
AllocConsole();
|
||||
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
printf("GetCommandLineA() %s\n",GetCommandLineA());
|
||||
debug_printf("GetCommandLineA() %s\n",GetCommandLineA());
|
||||
debug_printf("argc %d\n", argc);
|
||||
for (i=0; i<argc; i++)
|
||||
{
|
||||
debug_printf("Argv[%d]: %x\n",i,argv[i]);
|
||||
debug_printf("Argv[%d]: '%s'\n",i,argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,36 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
OBJECTS= args.o
|
||||
PROGS= args.exe
|
||||
|
||||
BASE_CFLAGS = -I../../include
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) args.o
|
||||
- $(RM) args.exe
|
||||
- $(RM) args.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
args.exe: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -o args.exe
|
||||
$(NM) --numeric-sort args.exe > args.sym
|
||||
|
||||
include ../../rules.mak
|
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
}
|
@@ -1,82 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
#define NR_THREADS (30)
|
||||
|
||||
|
||||
DWORD WINAPI
|
||||
thread_main1(LPVOID param)
|
||||
{
|
||||
printf("Thread 1 running (Counter %lu)\n", (DWORD)param);
|
||||
SleepEx(INFINITE, TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DWORD WINAPI
|
||||
thread_main2(LPVOID param)
|
||||
{
|
||||
printf("Thread 2 running (Counter %lu)\n", (DWORD)param);
|
||||
Sleep(INFINITE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
HANDLE hThread;
|
||||
DWORD i=0;
|
||||
DWORD id;
|
||||
|
||||
#if 1
|
||||
printf("Creating %d threads...\n",NR_THREADS*2);
|
||||
for (i=0;i<NR_THREADS;i++)
|
||||
{
|
||||
CreateThread(NULL,
|
||||
0,
|
||||
thread_main1,
|
||||
(LPVOID)i,
|
||||
0,
|
||||
&id);
|
||||
|
||||
/* CreateThread(NULL,
|
||||
0,
|
||||
thread_main2,
|
||||
(LPVOID)i,
|
||||
0,
|
||||
&id);*/
|
||||
}
|
||||
|
||||
printf("All threads created...\n");
|
||||
|
||||
/*
|
||||
* Waiting for threads is not implemented yet.
|
||||
* If you want to see all threads running, uncomment the
|
||||
* call to SuspendThread(). The test application will
|
||||
* freeze after all threads are created.
|
||||
*/
|
||||
/* SuspendThread (GetCurrentThread()); */
|
||||
|
||||
#else
|
||||
|
||||
printf("Creating thread...\n");
|
||||
|
||||
hThread = CreateThread(NULL,
|
||||
0,
|
||||
thread_main1,
|
||||
(LPVOID)i,
|
||||
0,
|
||||
&id);
|
||||
|
||||
printf("Thread created. Waiting for termination...\n");
|
||||
|
||||
WaitForSingleObject (hThread,
|
||||
-1);
|
||||
|
||||
CloseHandle (hThread);
|
||||
|
||||
printf("Thread terminated...\n");
|
||||
#endif
|
||||
printf("Exiting\n");
|
||||
return 0;
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
PROGS = bench-thread
|
||||
|
||||
all: $(PROGS:%=%.exe)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean: $(PROGS:%=%_clean)
|
||||
|
||||
$(PROGS:%=%_clean): %_clean:
|
||||
- $(RM) $*.o
|
||||
- $(RM) $*.exe
|
||||
- $(RM) $*.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: # $(PROGS:%=$(FLOPPY_DIR)/apps/%.exe)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%.exe): $(FLOPPY_DIR)/apps/%.exe: %.exe
|
||||
$(CP) $*.exe $(FLOPPY_DIR)/apps/$*.exe
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%.exe)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%.exe): ../../$(DIST_DIR)/apps/%.exe: %.exe
|
||||
$(CP) $*.exe ../../$(DIST_DIR)/apps/$*.exe
|
||||
|
||||
bench-thread.exe: bench-thread.c
|
||||
$(CC) $(CFLAGS) bench-thread.c -lkernel32 -o bench-thread.exe
|
||||
$(NM) --numeric-sort bench-thread.exe > bench-thread.sym
|
||||
|
||||
include ../../rules.mak
|
@@ -1,33 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
OBJECTS = consume.o
|
||||
PROGS = consume.exe
|
||||
LIBS =
|
||||
CLEAN_FILES = consume.o consume.exe
|
||||
|
||||
all: consume.exe
|
||||
|
||||
clean: $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
$(CLEAN_FILES:%=%_clean): %_clean:
|
||||
- $(RM) $*
|
||||
|
||||
.phony: clean $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
consume.exe: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -o consume.exe
|
||||
|
||||
include ../../rules.mak
|
@@ -1,29 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
ULONG x[(4 * 1024 * 1024) / 4096];
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
PUCHAR BaseAddress;
|
||||
|
||||
BaseAddress = VirtualAlloc(NULL,
|
||||
4 * 1024 * 1024,
|
||||
MEM_COMMIT,
|
||||
PAGE_READONLY);
|
||||
if (BaseAddress == NULL)
|
||||
{
|
||||
printf("Failed to allocate virtual memory");
|
||||
return(1);
|
||||
}
|
||||
printf("BaseAddress %p\n", BaseAddress);
|
||||
for (i = 0; i < ((4 * 1024 * 1024) / 4096); i++)
|
||||
{
|
||||
printf("%.6x, ", i*4096);
|
||||
x[i] = BaseAddress[i*4096];
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP=../..
|
||||
|
||||
TARGET_NAME=count
|
||||
|
||||
OBJECTS=\
|
||||
$(TARGET_NAME).o
|
||||
|
||||
LIBRARIES=\
|
||||
$(PATH_TO_TOP)/lib/kernel32/kernel32.a\
|
||||
$(PATH_TO_TOP)/lib/crtdll/crtdll.a\
|
||||
$(PATH_TO_TOP)/lib/user32/user32.a
|
||||
|
||||
PROGS=\
|
||||
$(TARGET_NAME).exe
|
||||
|
||||
BASE_CFLAGS = -I$(PATH_TO_TOP)/include
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) $(TARGET_NAME).o
|
||||
- $(RM) $(TARGET_NAME).exe
|
||||
- $(RM) $(TARGET_NAME).sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=$(PATH_TO_TOP)/$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(PATH_TO_TOP)/$(DIST_DIR)/apps/%): $(PATH_TO_TOP)/$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* $(PATH_TO_TOP)/$(DIST_DIR)/apps/$*
|
||||
|
||||
$(TARGET_NAME).exe: $(OBJECTS)
|
||||
$(CC)\
|
||||
$(OBJECTS)\
|
||||
$(LIBRARIES)\
|
||||
-o $(TARGET_NAME).exe
|
||||
$(NM) --numeric-sort $(TARGET_NAME).exe > $(TARGET_NAME).sym
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
@@ -1,15 +0,0 @@
|
||||
/* $Id: count.c,v 1.1 2001/03/26 21:30:20 ea Exp $
|
||||
*
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
int n = 0;
|
||||
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
{
|
||||
while (1) printf ("%d ", n ++ );
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* EOF */
|
@@ -1,9 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <ntddk.h>
|
||||
#include <napi/shared_data.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("TickCountLow: %x\n",
|
||||
((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->TickCountLow);
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
OBJECTS = dump_shared_data.o
|
||||
PROGS = dump_shared_data.exe
|
||||
LIBS =
|
||||
CLEAN_FILES = dump_shared_data.o dump_shared_data.exe
|
||||
|
||||
all: dump_shared_data.exe
|
||||
|
||||
clean: $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
$(CLEAN_FILES:%=%_clean): %_clean:
|
||||
- $(RM) $*
|
||||
|
||||
.phony: clean $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
floppy: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
dump_shared_data.exe: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -o dump_shared_data.exe
|
||||
|
||||
BASE_CFLAGS = -I../../include
|
||||
include ../../rules.mak
|
@@ -1,33 +0,0 @@
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
HANDLE events[2];
|
||||
|
||||
DWORD WINAPI thread( LPVOID crap )
|
||||
{
|
||||
SetEvent( events[0] );
|
||||
if( crap )
|
||||
SetEvent( events[1] );
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main( void )
|
||||
{
|
||||
DWORD id, Status;
|
||||
printf( "Creating events\n" );
|
||||
events[0] = CreateEvent( 0, TRUE, FALSE, 0 );
|
||||
events[1] = CreateEvent( 0, TRUE, FALSE, 0 );
|
||||
printf( "Created events\n" );
|
||||
CreateThread( 0, 0, thread, 0, 0, &id );
|
||||
printf( "WaitForSingleObject %s\n", ( WaitForSingleObject( events[0], INFINITE ) == WAIT_OBJECT_0 ? "worked" : "failed" ) );
|
||||
ResetEvent( events[0] );
|
||||
CreateThread( 0, 0, thread, 0, 0, &id );
|
||||
printf( "WaitForMultipleObjects with waitall = FALSE %s\n", ( WaitForMultipleObjects( 2, events, FALSE, INFINITE ) == WAIT_OBJECT_0 ? "worked" : "failed" ) );
|
||||
ResetEvent( events[0] );
|
||||
CreateThread( 0, 0, thread, (void *)1, 0, &id );
|
||||
Status = WaitForMultipleObjects( 2, events, TRUE, INFINITE );
|
||||
printf( "WaitForMultipleObjects with waitall = TRUE %s\n", ( Status == WAIT_OBJECT_0 || Status == WAIT_OBJECT_0 + 1 ? "worked" : "failed" ) );
|
||||
ResetEvent( events[0] );
|
||||
printf( "WaitForSingleObject with timeout %s\n", ( WaitForSingleObject( events[0], 100 ) == WAIT_TIMEOUT ? "worked" : "failed" ) );
|
||||
return 0;
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
PROGS = event
|
||||
|
||||
all: $(PROGS:%=%.exe)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean: $(PROGS:%=%_clean)
|
||||
|
||||
$(PROGS:%=%_clean): %_clean:
|
||||
- $(RM) $*.o
|
||||
- $(RM) $*.exe
|
||||
- $(RM) $*.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: # $(PROGS:%=$(FLOPPY_DIR)/apps/%.exe)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%.exe): $(FLOPPY_DIR)/apps/%.exe: %.exe
|
||||
$(CP) $*.exe $(FLOPPY_DIR)/apps/$*.exe
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%.exe)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%.exe): ../../$(DIST_DIR)/apps/%.exe: %.exe
|
||||
$(CP) $*.exe ../../$(DIST_DIR)/apps/$*.exe
|
||||
|
||||
event.exe: event.c
|
||||
$(CC) $(CFLAGS) event.c -lkernel32 -o event.exe
|
||||
$(NM) --numeric-sort event.exe > event.sym
|
||||
|
||||
include ../../rules.mak
|
@@ -1,45 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
OBJECTS= file.o
|
||||
PROGS= file.exe
|
||||
|
||||
BASE_CFLAGS = -I../../include
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) file.o
|
||||
- $(RM) file.exe
|
||||
- $(RM) file.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
file.exe: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) $(BASE_CFLAGS) -o file.exe
|
||||
$(NM) --numeric-sort file.exe > file.sym
|
||||
|
||||
include ../../rules.mak
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,54 +0,0 @@
|
||||
/***********************************************************
|
||||
* File read/write test utility *
|
||||
**********************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main( void )
|
||||
{
|
||||
HANDLE file;
|
||||
char buffer[4096];
|
||||
DWORD wrote;
|
||||
int c;
|
||||
|
||||
file = CreateFile("test.dat",
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
CREATE_ALWAYS,
|
||||
0,
|
||||
0);
|
||||
|
||||
if (file == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("Error opening file (Status %x)\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
for( c = 0; c < sizeof( buffer ); c++ )
|
||||
buffer[c] = (char)c;
|
||||
printf("Writing file\n");
|
||||
if (WriteFile( file, buffer, 4096, &wrote, NULL) == FALSE)
|
||||
{
|
||||
printf("Error writing file (Status %x)\n", GetLastError());
|
||||
exit(2);
|
||||
}
|
||||
printf("Reading file\n");
|
||||
SetFilePointer( file, 0, 0, FILE_BEGIN );
|
||||
if (ReadFile( file, buffer, 4096, &wrote, NULL) == FALSE)
|
||||
{
|
||||
printf("Error reading file (Status %x)\n", GetLastError());
|
||||
exit(3);
|
||||
}
|
||||
for( c = 0; c < sizeof( buffer ); c++ )
|
||||
if( buffer[c] != (char)c )
|
||||
{
|
||||
printf( "Error: data read back is not what was written\n" );
|
||||
CloseHandle( file );
|
||||
return 0;
|
||||
}
|
||||
printf("Finished, works fine\n");
|
||||
CloseHandle( file );
|
||||
return 0;
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/***********************************************************
|
||||
* File read/write test utility *
|
||||
**********************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main( void )
|
||||
{
|
||||
HANDLE file = CreateFile( "test.dat", GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
|
||||
char buffer[4096];
|
||||
|
||||
if( file == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, buffer, 4096, NULL );
|
||||
cout << "Error opening file: " << buffer << endl;
|
||||
return 1;
|
||||
}
|
||||
DWORD wrote;
|
||||
for( int c = 0; c < 1024; c++ )
|
||||
if( WriteFile( file, buffer, 4096, &wrote, NULL ) == FALSE )
|
||||
{
|
||||
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, buffer, 4096, NULL );
|
||||
cout << "Error writing file: " << buffer << endl;
|
||||
exit(2);
|
||||
}
|
||||
cout << "File written, trying to read now" << endl;
|
||||
for( int c = 0; c < 1024; c++ )
|
||||
if( ReadFile( file, buffer, 4096, &wrote, NULL ) == FALSE )
|
||||
{
|
||||
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, buffer, 4096, NULL );
|
||||
cout << "Error reading file: " << buffer << endl;
|
||||
exit(3);
|
||||
}
|
||||
cout << "Test passed" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* gditest
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
extern BOOL STDCALL GdiDllInitialize(HANDLE hInstance, DWORD Event, LPVOID Reserved);
|
||||
|
||||
int main (void)
|
||||
{
|
||||
HDC Desktop, MyDC, DC24;
|
||||
HPEN RedPen, GreenPen, BluePen, WhitePen;
|
||||
HBITMAP MyBitmap, DIB24;
|
||||
HFONT hf, tf;
|
||||
BITMAPINFOHEADER BitInf;
|
||||
BITMAPINFO BitPalInf;
|
||||
|
||||
printf("Entering GDITest..\n");
|
||||
|
||||
GdiDllInitialize (NULL, DLL_PROCESS_ATTACH, NULL);
|
||||
|
||||
// Set up a DC called Desktop that accesses DISPLAY
|
||||
Desktop = CreateDCA("DISPLAY", NULL, NULL, NULL);
|
||||
if (Desktop == NULL)
|
||||
return 1;
|
||||
|
||||
// Create a blue pen and select it into the DC
|
||||
BluePen = CreatePen(PS_SOLID, 8, RGB(0, 0, 0xff));
|
||||
SelectObject(Desktop, BluePen);
|
||||
|
||||
// Draw a shape on the DC
|
||||
MoveToEx(Desktop, 50, 50, NULL);
|
||||
LineTo(Desktop, 200, 60);
|
||||
LineTo(Desktop, 200, 300);
|
||||
LineTo(Desktop, 50, 50);
|
||||
MoveToEx(Desktop, 50, 50, NULL);
|
||||
LineTo(Desktop, 200, 50);
|
||||
|
||||
WhitePen = CreatePen(PS_SOLID, 3, RGB(0xff, 0xff, 0xff));
|
||||
SelectObject(Desktop, GreenPen);
|
||||
|
||||
MoveToEx(Desktop, 20, 70, NULL);
|
||||
LineTo(Desktop, 500, 70);
|
||||
MoveToEx(Desktop, 70, 20, NULL);
|
||||
LineTo(Desktop, 70, 150);
|
||||
|
||||
// Test font support
|
||||
GreenPen = CreatePen(PS_SOLID, 3, RGB(0, 0xff, 0));
|
||||
RedPen = CreatePen(PS_SOLID, 3, RGB(0xff, 0, 0));
|
||||
|
||||
hf = CreateFontA(24, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Helmet");
|
||||
SelectObject(Desktop, hf);
|
||||
SetTextColor(Desktop, RGB(0xff, 0, 0));
|
||||
TextOutA(Desktop, 70, 70, "React", 5);
|
||||
SetTextColor(Desktop, RGB(0, 0xff, 0));
|
||||
TextOutA(Desktop, 140, 70, "OS", 2);
|
||||
|
||||
tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
|
||||
SelectObject(Desktop, tf);
|
||||
SetTextColor(Desktop, RGB(0xff, 0xff, 0xff));
|
||||
TextOutA(Desktop, 70, 90, "This is a test of ReactOS text, using the FreeType 2 library!", 61);
|
||||
|
||||
// TEST 1: Copy from the VGA into a device compatible DC, draw on it, then blt it to the VGA again
|
||||
MyDC = CreateCompatibleDC(Desktop);
|
||||
MyBitmap = CreateCompatibleBitmap(Desktop, 151, 251);
|
||||
SelectObject(MyDC, MyBitmap);
|
||||
BitBlt(MyDC, 0, 0, 151, 251, Desktop, 50, 50, SRCCOPY); // can we say 151, 251 since bottom corner is not inclusive?
|
||||
|
||||
SelectObject(MyDC, GreenPen);
|
||||
Rectangle(MyDC, 10, 10, 50, 50);
|
||||
|
||||
// TEST 2: Copy from the device compatible DC into a 24BPP bitmap, draw on it, then blt to the VGA again
|
||||
BitInf.biSize = sizeof(BITMAPINFOHEADER);
|
||||
BitInf.biWidth = 152;
|
||||
BitInf.biHeight = -252; // it's top down (since BI_RGB is used, the sign is operative of direction)
|
||||
BitInf.biPlanes = 1;
|
||||
BitInf.biBitCount = 24;
|
||||
BitInf.biCompression = BI_RGB;
|
||||
BitInf.biSizeImage = 0;
|
||||
BitInf.biXPelsPerMeter = 0;
|
||||
BitInf.biYPelsPerMeter = 0;
|
||||
BitInf.biClrUsed = 0;
|
||||
BitInf.biClrImportant = 0;
|
||||
BitPalInf.bmiHeader = BitInf;
|
||||
DIB24 = (HBITMAP) CreateDIBSection(NULL, &BitPalInf, DIB_RGB_COLORS, NULL, NULL, 0);
|
||||
DC24 = CreateCompatibleDC(NULL);
|
||||
SelectObject(DC24, DIB24);
|
||||
|
||||
BitBlt(DC24, 0, 0, 101, 201, MyDC, 0, 0, SRCCOPY);
|
||||
SelectObject(DC24, RedPen);
|
||||
Rectangle(DC24, 80, 90, 100, 110);
|
||||
MoveToEx(DC24, 80, 90, NULL);
|
||||
LineTo(DC24, 100, 110);
|
||||
BitBlt(Desktop, 200, 200, 110, 120, DC24, 0, 0, SRCCOPY);
|
||||
|
||||
Sleep( 10000 );
|
||||
// Free up everything
|
||||
DeleteDC(Desktop);
|
||||
DeleteDC(MyDC);
|
||||
return 0;
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
PROGS = gditest
|
||||
|
||||
OBJECTS =
|
||||
LIBS= ../../lib/kernel32/kernel32.a ../../lib/gdi32/gdi32.a
|
||||
CFLAGS = -I../../include
|
||||
|
||||
all: $(PROGS:%=%.exe)
|
||||
|
||||
.phony: all
|
||||
|
||||
$(PROGS:%=%_clean): %_clean:
|
||||
- $(RM) $*.o
|
||||
- $(RM) $*.exe
|
||||
- $(RM) $*.sym
|
||||
|
||||
clean: $(PROGS:%=%_clean)
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%.exe)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%.exe): $(FLOPPY_DIR)/apps/%.exe: %.exe
|
||||
$(CP) $*.exe $(FLOPPY_DIR)/apps/$*.exe
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%.exe)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%.exe): ../../$(DIST_DIR)/apps/%.exe: %.exe
|
||||
$(CP) $*.exe ../../$(DIST_DIR)/apps/$*.exe
|
||||
|
||||
gditest.exe: gditest.c
|
||||
$(CC) $(CFLAGS) gditest.c $(LIBS) -o gditest.exe
|
||||
$(NM) --numeric-sort gditest.exe > gditest.sym
|
||||
|
||||
include ../../rules.mak
|
@@ -1,8 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
printf("Hello world\n");
|
||||
return(0);
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
OBJECTS = hello.o
|
||||
PROGS = hello.exe
|
||||
LIBS =
|
||||
CLEAN_FILES = hello.o hello.exe
|
||||
|
||||
all: hello.exe
|
||||
|
||||
clean: $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
$(CLEAN_FILES:%=%_clean): %_clean:
|
||||
- $(RM) $*
|
||||
|
||||
.phony: clean $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
hello.exe: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -o hello.exe
|
||||
|
||||
include ../../rules.mak
|
@@ -1,205 +0,0 @@
|
||||
/* $Id: conport.c,v 1.6 2000/04/25 23:22:46 ea Exp $
|
||||
*
|
||||
* reactos/apps/lpc/conport.c
|
||||
*
|
||||
* To be run in a real WNT 4.0 system with
|
||||
* "\SmApiPort" as argument. Do not try to
|
||||
* connect to "\Windows\ApiPort" since that
|
||||
* reboots immeditely.
|
||||
*
|
||||
* Use Russinovich' HandleEx to verify
|
||||
* conport.exe owns two unnamed LPC ports:
|
||||
* the one created by kernel32.dll connecting
|
||||
* to csrss.exe, and one connected to here.
|
||||
*
|
||||
* 19990627 (Emanuele Aliberti)
|
||||
* Initial implementation.
|
||||
* 19990704 (EA)
|
||||
* Dump object's attributes moved in dumpinfo.c.
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define PROTO_LPC
|
||||
#include <ddk/ntddk.h>
|
||||
#include "dumpinfo.h"
|
||||
|
||||
#define LPC_CONNECT_FLAG1 0x00000001
|
||||
#define LPC_CONNECT_FLAG2 0x00000010
|
||||
#define LPC_CONNECT_FLAG3 0x00000100
|
||||
#define LPC_CONNECT_FLAG4 0x00001000
|
||||
#define LPC_CONNECT_FLAG5 0x00010000
|
||||
|
||||
NTSTATUS
|
||||
(STDCALL * ConnectPort)(
|
||||
OUT PHANDLE PortHandle,
|
||||
IN PUNICODE_STRING PortName,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN DWORD Unknown3,
|
||||
IN DWORD Unknown4,
|
||||
IN DWORD Unknown5,
|
||||
IN DWORD Unknown6,
|
||||
IN ULONG Flags
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
(STDCALL * QueryObject)(
|
||||
IN HANDLE ObjectHandle,
|
||||
IN CINT ObjectInformationClass,
|
||||
OUT PVOID ObjectInformation,
|
||||
IN ULONG Length,
|
||||
OUT PULONG ResultLength
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
(STDCALL * YieldExecution)(VOID);
|
||||
|
||||
#define BUF_SIZE 1024
|
||||
#define MAXARG 1000000
|
||||
|
||||
|
||||
VOID
|
||||
TryConnectPort(char *port_name)
|
||||
{
|
||||
DWORD Status = 0;
|
||||
HANDLE Port = 0;
|
||||
int i;
|
||||
UNICODE_STRING PortName;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
WORD Name [BUF_SIZE] = {0};
|
||||
int dwx = 0;
|
||||
char * port_name_save = port_name;
|
||||
|
||||
/*
|
||||
* Convert the port's name to Unicode.
|
||||
*/
|
||||
for (
|
||||
PortName.Length = 0;
|
||||
( *port_name
|
||||
&& (PortName.Length < BUF_SIZE)
|
||||
);
|
||||
)
|
||||
{
|
||||
Name[PortName.Length++] = (WORD) *port_name++;
|
||||
}
|
||||
Name[PortName.Length] = 0;
|
||||
|
||||
PortName.Length = PortName.Length * sizeof (WORD);
|
||||
PortName.MaximumLength = PortName.Length + sizeof (WORD);
|
||||
PortName.Buffer = (PWSTR) Name;
|
||||
/*
|
||||
* Prepare the port object attributes.
|
||||
*/
|
||||
ObjectAttributes.Length =
|
||||
sizeof (OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory =
|
||||
NULL;
|
||||
ObjectAttributes.ObjectName =
|
||||
NULL /*& PortName */;
|
||||
ObjectAttributes.Attributes =
|
||||
OBJ_CASE_INSENSITIVE;
|
||||
ObjectAttributes.SecurityDescriptor =
|
||||
NULL;
|
||||
ObjectAttributes.SecurityQualityOfService =
|
||||
NULL;
|
||||
/*
|
||||
* Try to issue a connection request.
|
||||
*/
|
||||
Port = 0;
|
||||
Status = ConnectPort(
|
||||
& Port, /* & PortHandle */
|
||||
& PortName, /* & PortName */
|
||||
& ObjectAttributes, /* & PortAttributes */
|
||||
NULL, /* & SecurityQos */
|
||||
NULL, /* & SectionInfo */
|
||||
NULL, /* & MapInfo */
|
||||
NULL, /* & MaxMessageSize */
|
||||
LPC_CONNECT_FLAG5 /* & ConnectInfoLength */
|
||||
);
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
DumpInfo(
|
||||
Name,
|
||||
Status,
|
||||
"connected",
|
||||
Port
|
||||
);
|
||||
/* Hot waiting */
|
||||
for (dwx=0; dwx<MAXARG; ++dwx)
|
||||
{
|
||||
YieldExecution();
|
||||
}
|
||||
if (FALSE == CloseHandle(Port))
|
||||
{
|
||||
printf(
|
||||
"Could not close the port handle %08X.\n",
|
||||
Port
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
printf(
|
||||
"Connection to port \"%s\" failed (Status = %08X).\n",
|
||||
port_name_save,
|
||||
Status
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
main( int argc, char * argv[] )
|
||||
{
|
||||
HINSTANCE ntdll;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("WNT LPC Port Connector\n");
|
||||
printf("Usage: %s [port_name]\n",argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("LoadLibrary(NTDLL)\n");
|
||||
ntdll = LoadLibrary("NTDLL");
|
||||
if (ntdll == NULL)
|
||||
{
|
||||
printf("Could not load NTDLL\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("GetProcAddress(NTDLL.NtConnectPort)\n");
|
||||
ConnectPort = (VOID*) GetProcAddress(
|
||||
ntdll,
|
||||
"NtConnectPort"
|
||||
);
|
||||
if (ConnectPort == NULL)
|
||||
{
|
||||
FreeLibrary(ntdll);
|
||||
printf("Could not find NTDLL.NtConnectPort\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("GetProcAddress(NTDLL.NtQueryObject)\n");
|
||||
QueryObject = (VOID*) GetProcAddress(
|
||||
ntdll,
|
||||
"NtQueryObject"
|
||||
);
|
||||
if (QueryObject == NULL)
|
||||
{
|
||||
FreeLibrary(ntdll);
|
||||
printf("Could not find NTDLL.NtQueryObject\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("GetProcAddress(NTDLL.NtYieldExecution)\n");
|
||||
YieldExecution = (VOID*) GetProcAddress(
|
||||
ntdll,
|
||||
"NtYieldExecution"
|
||||
);
|
||||
if (YieldExecution == NULL)
|
||||
{
|
||||
FreeLibrary(ntdll);
|
||||
printf("Could not find NTDLL.NtYieldExecution\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("TryConnectPort(%s)\n",argv[1]);
|
||||
TryConnectPort(argv[1]);
|
||||
printf("Done\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
@@ -1,192 +0,0 @@
|
||||
/* $Id: creport.c,v 1.2 1999/07/17 23:10:12 ea Exp $
|
||||
*
|
||||
* reactos/apps/lpc/creport.c
|
||||
*
|
||||
* To be run in a real WNT 4.0 system to
|
||||
* create an LPC named port.
|
||||
*
|
||||
* Use Russinovich' HandleEx to verify
|
||||
* creport.exe owns the named LPC port
|
||||
* you asked to create.
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define PROTO_LPC
|
||||
#include <ddk/ntddk.h>
|
||||
#include "dumpinfo.h"
|
||||
|
||||
#define LPC_CONNECT_FLAG1 0x00000001
|
||||
#define LPC_CONNECT_FLAG2 0x00000010
|
||||
#define LPC_CONNECT_FLAG3 0x00000100
|
||||
#define LPC_CONNECT_FLAG4 0x00001000
|
||||
#define LPC_CONNECT_FLAG5 0x00010000
|
||||
|
||||
NTSTATUS
|
||||
(STDCALL * CreatePort)(
|
||||
/*OUT PHANDLE PortHandle,*/
|
||||
PVOID Buffer,
|
||||
IN POBJECT_ATTRIBUTES PortAttributes OPTIONAL,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN DWORD Unknown3,
|
||||
IN ULONG Flags
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
(STDCALL * QueryObject)(
|
||||
IN HANDLE ObjectHandle,
|
||||
IN CINT ObjectInformationClass,
|
||||
OUT PVOID ObjectInformation,
|
||||
IN ULONG Length,
|
||||
OUT PULONG ResultLength
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
(STDCALL * YieldExecution)(VOID);
|
||||
|
||||
#define BUF_SIZE 1024
|
||||
#define MAXARG 5000000
|
||||
|
||||
|
||||
VOID
|
||||
TryCreatePort(char *port_name)
|
||||
{
|
||||
DWORD Status = 0;
|
||||
HANDLE Port = 0;
|
||||
int i;
|
||||
UNICODE_STRING PortName;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
WORD Name [BUF_SIZE] = {0};
|
||||
int dwx = 0;
|
||||
char * port_name_save = port_name;
|
||||
|
||||
/*
|
||||
* Convert the port's name to Unicode.
|
||||
*/
|
||||
for (
|
||||
PortName.Length = 0;
|
||||
( *port_name
|
||||
&& (PortName.Length < BUF_SIZE)
|
||||
);
|
||||
)
|
||||
{
|
||||
Name[PortName.Length++] = (WORD) *port_name++;
|
||||
}
|
||||
Name[PortName.Length] = 0;
|
||||
|
||||
PortName.Length = PortName.Length * sizeof (WORD);
|
||||
PortName.MaximumLength = PortName.Length + sizeof (WORD);
|
||||
PortName.Buffer = (PWSTR) Name;
|
||||
/*
|
||||
* Prepare the port object attributes.
|
||||
*/
|
||||
ObjectAttributes.Length =
|
||||
sizeof (OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory =
|
||||
NULL;
|
||||
ObjectAttributes.ObjectName =
|
||||
& PortName;
|
||||
ObjectAttributes.Attributes =
|
||||
0; //OBJ_CASE_INSENSITIVE --> STATUS_INVALID_PARAMETER ==> case sensitive!;
|
||||
ObjectAttributes.SecurityDescriptor =
|
||||
NULL;
|
||||
ObjectAttributes.SecurityQualityOfService =
|
||||
NULL;
|
||||
/*
|
||||
* Try to issue a connection request.
|
||||
*/
|
||||
Port = 0;
|
||||
Status = CreatePort(
|
||||
& Port,
|
||||
& ObjectAttributes,
|
||||
0, /* ACCESS_MASK? */
|
||||
0, /* Unknown3 */
|
||||
LPC_CONNECT_FLAG5
|
||||
);
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
DumpInfo(
|
||||
Name,
|
||||
Status,
|
||||
"created",
|
||||
Port
|
||||
);
|
||||
/* Hot waiting */
|
||||
for (dwx=0; dwx<MAXARG; ++dwx)
|
||||
{
|
||||
YieldExecution();
|
||||
}
|
||||
if (FALSE == CloseHandle(Port))
|
||||
{
|
||||
printf(
|
||||
"Could not close the port handle %08X.\n",
|
||||
Port
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
printf(
|
||||
"Creating port \"%s\" failed (Status = %08X).\n",
|
||||
port_name_save,
|
||||
Status
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
main( int argc, char * argv[] )
|
||||
{
|
||||
HINSTANCE ntdll;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("WNT LPC Port Creator\n");
|
||||
printf("Usage: %s [port_name]\n",argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("LoadLibrary(NTDLL)\n");
|
||||
ntdll = LoadLibrary("NTDLL");
|
||||
if (ntdll == NULL)
|
||||
{
|
||||
printf("Could not load NTDLL\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("GetProcAddress(NTDLL.NtCreatePort)\n");
|
||||
CreatePort = (VOID*) GetProcAddress(
|
||||
ntdll,
|
||||
"NtCreatePort"
|
||||
);
|
||||
if (CreatePort == NULL)
|
||||
{
|
||||
FreeLibrary(ntdll);
|
||||
printf("Could not find NTDLL.NtCreatePort\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("GetProcAddress(NTDLL.NtQueryObject)\n");
|
||||
QueryObject = (VOID*) GetProcAddress(
|
||||
ntdll,
|
||||
"NtQueryObject"
|
||||
);
|
||||
if (QueryObject == NULL)
|
||||
{
|
||||
FreeLibrary(ntdll);
|
||||
printf("Could not find NTDLL.NtQueryObject\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("GetProcAddress(NTDLL.NtYieldExecution)\n");
|
||||
YieldExecution = (VOID*) GetProcAddress(
|
||||
ntdll,
|
||||
"NtYieldExecution"
|
||||
);
|
||||
if (YieldExecution == NULL)
|
||||
{
|
||||
FreeLibrary(ntdll);
|
||||
printf("Could not find NTDLL.NtYieldExecution\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("TryCreatePort(%s)\n",argv[1]);
|
||||
TryCreatePort(argv[1]);
|
||||
printf("Done\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
@@ -1,239 +0,0 @@
|
||||
/* $Id: dumpinfo.c,v 1.2 1999/07/17 23:10:12 ea Exp $
|
||||
*
|
||||
* reactos/apps/lpc/dumpinfo.c
|
||||
*
|
||||
* ReactOS Operating System
|
||||
*
|
||||
* Dump a kernel object's attributes by its handle.
|
||||
*
|
||||
* 19990627 (Emanuele Aliberti)
|
||||
* Initial implementation.
|
||||
* 19990704 (EA)
|
||||
* Added code to find the basic information buffer size
|
||||
* for the LPC port object.
|
||||
* 19990710 (EA)
|
||||
*
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#define BUF_SIZE 1024
|
||||
#define MAX_BASIC_INFO_SIZE 512
|
||||
|
||||
|
||||
extern
|
||||
NTSTATUS
|
||||
(STDCALL * QueryObject)(
|
||||
IN HANDLE ObjectHandle,
|
||||
IN CINT ObjectInformationClass,
|
||||
OUT PVOID ObjectInformation,
|
||||
IN ULONG Length,
|
||||
OUT PULONG ResultLength
|
||||
);
|
||||
|
||||
extern
|
||||
NTSTATUS
|
||||
(STDCALL * QueryInformationPort)(
|
||||
IN HANDLE PortHandle,
|
||||
IN CINT PortInformationClass, /* guess */
|
||||
OUT PVOID PortInformation, /* guess */
|
||||
IN ULONG PortInformationLength, /* guess */
|
||||
OUT PULONG ReturnLength /* guess */
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
static
|
||||
VOID
|
||||
DumpBuffer(
|
||||
char *Name,
|
||||
BYTE *buffer,
|
||||
ULONG size
|
||||
)
|
||||
{
|
||||
register ULONG i = 0;
|
||||
|
||||
printf("%s [%d] = ",Name,size);
|
||||
for ( i = 0;
|
||||
i != size;
|
||||
++i
|
||||
)
|
||||
{
|
||||
printf("%02X",buffer[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
*/
|
||||
|
||||
VOID
|
||||
DumpInfo (
|
||||
LPCWSTR Name,
|
||||
NTSTATUS Status,
|
||||
LPCWSTR Comment,
|
||||
HANDLE Port
|
||||
)
|
||||
{
|
||||
BYTE ObjectInformation [BUF_SIZE] = {0};
|
||||
ULONG ResultLength;
|
||||
|
||||
wprintf(
|
||||
L"Port \"%s\" %s:\n",
|
||||
Name,
|
||||
Comment
|
||||
);
|
||||
|
||||
printf("\tStatus = %08X\n",Status);
|
||||
printf("\tPort = %08X\n\n",Port);
|
||||
/*
|
||||
* Query object information.
|
||||
*/
|
||||
printf("Basic Information:\n");
|
||||
Status = QueryObject(
|
||||
Port,
|
||||
ObjectBasicInformation,
|
||||
ObjectInformation,
|
||||
sizeof (LPC_PORT_BASIC_INFORMATION),
|
||||
& ResultLength
|
||||
);
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
PLPC_PORT_BASIC_INFORMATION i;
|
||||
|
||||
i = (PLPC_PORT_BASIC_INFORMATION) ObjectInformation;
|
||||
|
||||
printf( "\tUnknown01 = 0x%08X\n", i->Unknown0 );
|
||||
printf( "\tUnknown02 = 0x%08X\n", i->Unknown1 );
|
||||
printf( "\tUnknown03 = 0x%08X\n", i->Unknown2 );
|
||||
printf( "\tUnknown04 = 0x%08X\n", i->Unknown3 );
|
||||
printf( "\tUnknown05 = 0x%08X\n", i->Unknown4 );
|
||||
printf( "\tUnknown06 = 0x%08X\n", i->Unknown5 );
|
||||
printf( "\tUnknown07 = 0x%08X\n", i->Unknown6 );
|
||||
printf( "\tUnknown08 = 0x%08X\n", i->Unknown7 );
|
||||
printf( "\tUnknown09 = 0x%08X\n", i->Unknown8 );
|
||||
printf( "\tUnknown10 = 0x%08X\n", i->Unknown9 );
|
||||
printf( "\tUnknown11 = 0x%08X\n", i->Unknown10 );
|
||||
printf( "\tUnknown12 = 0x%08X\n", i->Unknown11 );
|
||||
printf( "\tUnknown13 = 0x%08X\n", i->Unknown12 );
|
||||
printf( "\tUnknown14 = 0x%08X\n", i->Unknown13 );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\tStatus = %08X\n",Status);
|
||||
}
|
||||
printf("Type Information:\n");
|
||||
Status = QueryObject(
|
||||
Port,
|
||||
ObjectTypeInformation,
|
||||
ObjectInformation,
|
||||
sizeof ObjectInformation,
|
||||
& ResultLength
|
||||
);
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
OBJECT_TYPE_INFORMATION * i;
|
||||
|
||||
i = (OBJECT_TYPE_INFORMATION *) ObjectInformation;
|
||||
|
||||
wprintf(
|
||||
L"\tName: \"%s\"\n",
|
||||
(i->Name.Length ? i->Name.Buffer : L"")
|
||||
);
|
||||
/*
|
||||
FIXME: why this always raise an access violation exception?
|
||||
wprintf(
|
||||
L"\tType: \"%s\"\n",
|
||||
(i->Type.Length ? i->Type.Buffer : L"")
|
||||
);
|
||||
/**/
|
||||
printf(
|
||||
"\tTotal Handles: %d\n",
|
||||
i->TotalHandles
|
||||
);
|
||||
printf(
|
||||
"\tReference Count: %d\n",
|
||||
i->ReferenceCount
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\tStatus = %08X\n",Status);
|
||||
}
|
||||
printf("Name Information:\n");
|
||||
Status = QueryObject(
|
||||
Port,
|
||||
ObjectNameInformation,
|
||||
ObjectInformation,
|
||||
sizeof ObjectInformation,
|
||||
& ResultLength
|
||||
);
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
OBJECT_NAME_INFORMATION * i;
|
||||
|
||||
i = (OBJECT_NAME_INFORMATION *) ObjectInformation;
|
||||
wprintf(
|
||||
L"\tName: \"%s\"\n",
|
||||
(i->Name.Length ? i->Name.Buffer : L"")
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\tStatus = %08X\n",Status);
|
||||
}
|
||||
printf("Data Information:\n");
|
||||
Status = QueryObject(
|
||||
Port,
|
||||
ObjectDataInformation,
|
||||
ObjectInformation,
|
||||
sizeof ObjectInformation,
|
||||
& ResultLength
|
||||
);
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
OBJECT_DATA_INFORMATION * i;
|
||||
|
||||
i = (OBJECT_DATA_INFORMATION *) ObjectInformation;
|
||||
printf(
|
||||
"\tInherit Handle: %s\n",
|
||||
(i->bInheritHandle ? "TRUE" : "FALSE")
|
||||
);
|
||||
printf(
|
||||
"\tProtect from Close: %s\n",
|
||||
(i->bProtectFromClose ? "TRUE" : "FALSE")
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\tStatus = %08X\n",Status);
|
||||
}
|
||||
//---
|
||||
printf("Port Information:\n");
|
||||
/* Status = QueryInformationPort(
|
||||
Port,
|
||||
1, /* info class * /
|
||||
ObjectInformation,
|
||||
sizeof ObjectInformation,
|
||||
& ResultLength
|
||||
);
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
DWORD * i = ObjectInformation;
|
||||
int j = 0;
|
||||
|
||||
while (j < ResultLength / sizeof (DWORD))
|
||||
{
|
||||
printf("\t%08X\n",i[j]);
|
||||
++j;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\tStatus = %08X\n",Status);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
@@ -1,8 +0,0 @@
|
||||
VOID
|
||||
DumpInfo (
|
||||
LPCWSTR Name,
|
||||
NTSTATUS Status,
|
||||
LPCWSTR Comment,
|
||||
HANDLE Port
|
||||
);
|
||||
|
@@ -1,75 +0,0 @@
|
||||
/* $Id: lpcclt.c,v 1.7 2000/06/29 23:35:09 dwelch Exp $
|
||||
*
|
||||
* DESCRIPTION: Simple LPC Client
|
||||
* PROGRAMMER: David Welch
|
||||
*/
|
||||
#include <ddk/ntddk.h>
|
||||
#include <windows.h>
|
||||
#include <napi/lpc.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
void debug_printf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
UNICODE_STRING PortName;
|
||||
NTSTATUS Status;
|
||||
HANDLE PortHandle;
|
||||
LPC_MAX_MESSAGE Request;
|
||||
ULONG ConnectInfoLength;
|
||||
|
||||
printf("(lpcclt.exe) Lpc client\n");
|
||||
|
||||
RtlInitUnicodeString(&PortName, L"\\TestPort");
|
||||
|
||||
printf("(lpcclt.exe) Connecting to port \"\\TestPort\"\n");
|
||||
ConnectInfoLength = 0;
|
||||
Status = NtConnectPort(&PortHandle,
|
||||
&PortName,
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
&ConnectInfoLength);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
printf("(lpcclt.exe) Failed to connect (Status = 0x%08X)\n", Status);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
strcpy(Request.Data, GetCommandLineA());
|
||||
Request.Header.DataSize = strlen(Request.Data);
|
||||
Request.Header.MessageSize = sizeof(LPC_MESSAGE_HEADER) +
|
||||
Request.Header.DataSize;
|
||||
|
||||
printf("(lpcclt.exe) Sending message \"%s\"\n",
|
||||
(char *) Request.Data);
|
||||
Status = NtRequestPort(PortHandle,
|
||||
&Request.Header);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
printf("(lpcclt.exe) Failed to send request (Status = 0x%8X)\n",
|
||||
Status);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf("(lpcclt.exe) Succeeded\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
/* $Id: lpcsrv.c,v 1.7 2000/06/29 23:35:10 dwelch Exp $
|
||||
*
|
||||
* DESCRIPTION: Simple LPC Server
|
||||
* PROGRAMMER: David Welch
|
||||
*/
|
||||
#include <ddk/ntddk.h>
|
||||
#include <windows.h>
|
||||
#include <napi/lpc.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
void debug_printf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
UNICODE_STRING PortName;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
NTSTATUS Status;
|
||||
HANDLE NamedPortHandle;
|
||||
HANDLE PortHandle;
|
||||
LPC_MAX_MESSAGE ConnectMsg;
|
||||
|
||||
printf("(lpcsrv.exe) Lpc test server\n");
|
||||
|
||||
RtlInitUnicodeString(&PortName, L"\\TestPort");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&PortName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
printf("(lpcsrv.exe) Creating port\n");
|
||||
Status = NtCreatePort(&NamedPortHandle,
|
||||
&ObjectAttributes,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
printf("(lpcsrv.exe) Failed to create port (Status = 0x%08lX)\n", Status);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
printf("(lpcsrv.exe) Listening for connections\n");
|
||||
Status = NtListenPort(NamedPortHandle,
|
||||
&ConnectMsg.Header);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
printf("(lpcsrv.exe) Failed to listen for connections (Status = 0x%08lX)\n", Status);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf("(lpcsrv.exe) Accepting connections\n");
|
||||
Status = NtAcceptConnectPort(&PortHandle,
|
||||
NamedPortHandle,
|
||||
NULL,
|
||||
1,
|
||||
0,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
printf("(lpcsrv.exe) Failed to accept connection (Status = 0x%08lX)\n", Status);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf("(lpcsrv.exe) Completing connection\n");
|
||||
Status = NtCompleteConnectPort(PortHandle);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
printf("(lpcsrv.exe) Failed to complete connection (Status = 0x%08lX)\n", Status);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
for(;;)
|
||||
{
|
||||
LPC_MAX_MESSAGE Request;
|
||||
|
||||
Status = NtReplyWaitReceivePort(PortHandle,
|
||||
0,
|
||||
NULL,
|
||||
&Request.Header);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
printf("(lpcsrv.exe) Failed to receive request (Status = 0x%08lX)\n", Status);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf("(lpcsrv.exe) Message contents are <%s>\n",
|
||||
Request.Data);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
@@ -1,48 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
SRV_OBJECTS= lpcsrv.o
|
||||
CLT_OBJECTS= lpcclt.o
|
||||
|
||||
PROGS= lpcsrv.exe lpcclt.exe
|
||||
|
||||
BASE_CFLAGS = -I../../include
|
||||
LIBS = ../../lib/crtdll/crtdll.a ../../lib/kernel32/kernel32.a \
|
||||
../../lib/ntdll/ntdll.a
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) lpcsrv.o
|
||||
- $(RM) lpcsrv.exe
|
||||
- $(RM) lpcsrv.sym
|
||||
- $(RM) lpcclt.o
|
||||
- $(RM) lpcclt.exe
|
||||
- $(RM) lpcsrv.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
lpcsrv.exe: $(SRV_OBJECTS) $(LIBS)
|
||||
$(CC) $(SRV_OBJECTS) $(LIBS) -o lpcsrv.exe
|
||||
$(NM) --numeric-sort lpcsrv.exe > lpcsrv.sym
|
||||
|
||||
lpcclt.exe: $(CLT_OBJECTS) $(LIBS)
|
||||
$(CC) $(CLT_OBJECTS) $(LIBS) -o lpcclt.exe
|
||||
$(NM) --numeric-sort lpcclt.exe > lpcclt.sym
|
||||
|
||||
|
||||
include ../../rules.mak
|
@@ -1,44 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
SRV_OBJECTS = msserver.o
|
||||
CLT_OBJECTS = msclient.o
|
||||
|
||||
PROGS = msserver.exe msclient.exe
|
||||
|
||||
BASE_CFLAGS = -I../../include
|
||||
LIBS = ../../lib/crtdll/crtdll.a ../../lib/kernel32/kernel32.a
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) *.o
|
||||
- $(RM) *.exe
|
||||
- $(RM) *.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
msserver.exe: $(SRV_OBJECTS) $(LIBS)
|
||||
$(CC) $(SRV_OBJECTS) $(LIBS) -o msserver.exe
|
||||
$(NM) --numeric-sort msserver.exe > msserver.sym
|
||||
|
||||
msclient.exe: $(CLT_OBJECTS) $(LIBS)
|
||||
$(CC) $(CLT_OBJECTS) $(LIBS) -o msclient.exe
|
||||
$(NM) --numeric-sort msclient.exe > msclient.sym
|
||||
|
||||
|
||||
include ../../rules.mak
|
@@ -1,46 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#define BUFSIZE 1024
|
||||
#define MAILSLOT_TIMEOUT 1000
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
HANDLE hMailslot;
|
||||
LPSTR lpszMailslotName = "\\\\.\\MAILSLOT\\mymailslot";
|
||||
LPSTR lpszTestMessage = "Mailslot test message!";
|
||||
DWORD cbLength, cbWritten;
|
||||
|
||||
hMailslot = CreateFile(lpszMailslotName,
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_READ,
|
||||
(LPSECURITY_ATTRIBUTES)NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
(HANDLE)NULL);
|
||||
printf("hMailslot %x\n", (DWORD)hMailslot);
|
||||
if (hMailslot == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("CreateFile() failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
cbLength = (ULONG)strlen(lpszTestMessage)+1;
|
||||
|
||||
WriteFile(hMailslot,
|
||||
lpszTestMessage,
|
||||
cbLength,
|
||||
&cbWritten,
|
||||
NULL);
|
||||
|
||||
CloseHandle(hMailslot);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
@@ -1,40 +0,0 @@
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
HANDLE hMailslot;
|
||||
CHAR chBuf[512];
|
||||
BOOL fResult;
|
||||
DWORD cbRead;
|
||||
LPTSTR lpszMailslotName = "\\\\.\\mailslot\\mymailslot";
|
||||
|
||||
hMailslot = CreateMailslot(lpszMailslotName,
|
||||
512,
|
||||
MAILSLOT_WAIT_FOREVER,
|
||||
NULL);
|
||||
for (;;)
|
||||
{
|
||||
fResult = ReadFile(hMailslot,
|
||||
chBuf,
|
||||
512,
|
||||
&cbRead,
|
||||
NULL);
|
||||
if (fResult == FALSE)
|
||||
{
|
||||
printf("ReadFile() failed!\n");
|
||||
CloseHandle(hMailslot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Data read: %s\n", chBuf);
|
||||
}
|
||||
|
||||
CloseHandle(hMailslot);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
@@ -1,44 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
SRV_OBJECTS = npserver.o
|
||||
CLT_OBJECTS = npclient.o
|
||||
|
||||
PROGS = npserver.exe npclient.exe
|
||||
|
||||
BASE_CFLAGS = -I../../include
|
||||
LIBS = ../../lib/crtdll/crtdll.a ../../lib/kernel32/kernel32.a
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) *.o
|
||||
- $(RM) *.exe
|
||||
- $(RM) *.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
npserver.exe: $(SRV_OBJECTS) $(LIBS)
|
||||
$(CC) $(SRV_OBJECTS) $(LIBS) -o npserver.exe
|
||||
$(NM) --numeric-sort npserver.exe > npserver.sym
|
||||
|
||||
npclient.exe: $(CLT_OBJECTS) $(LIBS)
|
||||
$(CC) $(CLT_OBJECTS) $(LIBS) -o npclient.exe
|
||||
$(NM) --numeric-sort npclient.exe > npclient.sym
|
||||
|
||||
|
||||
include ../../rules.mak
|
@@ -1,100 +0,0 @@
|
||||
#include <windows.h>
|
||||
|
||||
VOID MyErrExit(LPTSTR Message)
|
||||
{
|
||||
// MessageBox(NULL, Message, NULL, MB_OK);
|
||||
puts(Message);
|
||||
ExitProcess(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
HANDLE hPipe;
|
||||
LPVOID lpvMessage;
|
||||
CHAR chBuf[512];
|
||||
BOOL fSuccess;
|
||||
DWORD cbRead, cbWritten, dwMode;
|
||||
LPTSTR lpszPipename = "\\\\.\\pipe\\mynamedpipe";
|
||||
|
||||
// Try to open a named pipe; wait for it, if necessary.
|
||||
|
||||
while (1)
|
||||
{
|
||||
hPipe = CreateFile(
|
||||
lpszPipename, // pipe name
|
||||
GENERIC_READ | // read and write access
|
||||
GENERIC_WRITE,
|
||||
0, // no sharing
|
||||
NULL, // no security attributes
|
||||
OPEN_EXISTING, // opens existing pipe
|
||||
0, // default attributes
|
||||
NULL); // no template file
|
||||
|
||||
// Break if the pipe handle is valid.
|
||||
|
||||
if (hPipe != INVALID_HANDLE_VALUE)
|
||||
break;
|
||||
|
||||
// Exit if an error other than ERROR_PIPE_BUSY occurs.
|
||||
|
||||
if (GetLastError() != ERROR_PIPE_BUSY)
|
||||
MyErrExit("Could not open pipe");
|
||||
|
||||
// All pipe instances are busy, so wait for 20 seconds.
|
||||
|
||||
if (! WaitNamedPipe(lpszPipename, 20000) )
|
||||
MyErrExit("Could not open pipe");
|
||||
}
|
||||
|
||||
// The pipe connected; change to message-read mode.
|
||||
|
||||
dwMode = PIPE_READMODE_MESSAGE;
|
||||
fSuccess = SetNamedPipeHandleState(
|
||||
hPipe, // pipe handle
|
||||
&dwMode, // new pipe mode
|
||||
NULL, // don't set maximum bytes
|
||||
NULL); // don't set maximum time
|
||||
if (!fSuccess)
|
||||
MyErrExit("SetNamedPipeHandleState");
|
||||
|
||||
// Send a message to the pipe server.
|
||||
|
||||
lpvMessage = (argc > 1) ? argv[1] : "default message";
|
||||
|
||||
fSuccess = WriteFile(
|
||||
hPipe, // pipe handle
|
||||
lpvMessage, // message
|
||||
strlen(lpvMessage) + 1, // message length
|
||||
&cbWritten, // bytes written
|
||||
NULL); // not overlapped
|
||||
if (! fSuccess)
|
||||
MyErrExit("WriteFile");
|
||||
|
||||
do
|
||||
{
|
||||
// Read from the pipe.
|
||||
|
||||
fSuccess = ReadFile(
|
||||
hPipe, // pipe handle
|
||||
chBuf, // buffer to receive reply
|
||||
512, // size of buffer
|
||||
&cbRead, // number of bytes read
|
||||
NULL); // not overlapped
|
||||
|
||||
if (! fSuccess && GetLastError() != ERROR_MORE_DATA)
|
||||
break;
|
||||
|
||||
// Reply from the pipe is written to STDOUT.
|
||||
|
||||
if (! WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),
|
||||
chBuf, cbRead, &cbWritten, NULL))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
} while (! fSuccess); // repeat loop if ERROR_MORE_DATA
|
||||
|
||||
CloseHandle(hPipe);
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,120 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#define BUFSIZE 1024
|
||||
#define PIPE_TIMEOUT 1000
|
||||
|
||||
VOID InstanceThread (LPVOID);
|
||||
|
||||
VOID
|
||||
GetAnswerToRequest(LPTSTR lpRequest,
|
||||
LPTSTR lpReply,
|
||||
LPDWORD lpcbReplyBytes)
|
||||
{
|
||||
}
|
||||
|
||||
VOID MyErrExit(LPTSTR Message)
|
||||
{
|
||||
// MessageBox(NULL, Message, NULL, MB_OK);
|
||||
puts(Message);
|
||||
ExitProcess(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int xx = 0;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
BOOL fConnected;
|
||||
DWORD dwThreadId;
|
||||
HANDLE hPipe, hThread;
|
||||
LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe");
|
||||
|
||||
// for (;;)
|
||||
// {
|
||||
hPipe = CreateNamedPipe(lpszPipename,
|
||||
PIPE_ACCESS_DUPLEX,
|
||||
PIPE_TYPE_MESSAGE |
|
||||
PIPE_READMODE_MESSAGE |
|
||||
PIPE_WAIT,
|
||||
PIPE_UNLIMITED_INSTANCES,
|
||||
BUFSIZE,
|
||||
BUFSIZE,
|
||||
PIPE_TIMEOUT,
|
||||
NULL);
|
||||
if (hPipe == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("CreateNamedPipe() failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fConnected = ConnectNamedPipe(hPipe,
|
||||
NULL) ? TRUE : (GetLastError () ==
|
||||
ERROR_PIPE_CONNECTED);
|
||||
if (fConnected)
|
||||
{
|
||||
printf("Pipe connected!\n");
|
||||
|
||||
DisconnectNamedPipe(hPipe);
|
||||
|
||||
#if 0
|
||||
hThread = CreateThread(NULL,
|
||||
0,
|
||||
(LPTHREAD_START_ROUTINE) InstanceThread,
|
||||
(LPVOID) hPipe,
|
||||
0,
|
||||
&dwThreadId);
|
||||
if (hThread == NULL)
|
||||
MyErrExit("CreateThread");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// CloseHandle(hPipe);
|
||||
}
|
||||
// }
|
||||
|
||||
CloseHandle(hPipe);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID InstanceThread (LPVOID lpvParam)
|
||||
{
|
||||
CHAR chRequest[BUFSIZE];
|
||||
CHAR chReply[BUFSIZE];
|
||||
DWORD cbBytesRead, cbReplyBytes, cbWritten;
|
||||
BOOL fSuccess;
|
||||
HANDLE hPipe;
|
||||
|
||||
hPipe = (HANDLE)lpvParam;
|
||||
while (1)
|
||||
{
|
||||
fSuccess = ReadFile(hPipe,
|
||||
chRequest,
|
||||
BUFSIZE,
|
||||
&cbBytesRead,
|
||||
NULL);
|
||||
if (!fSuccess || cbBytesRead == 0)
|
||||
break;
|
||||
|
||||
GetAnswerToRequest(chRequest, chReply, &cbReplyBytes);
|
||||
|
||||
fSuccess = WriteFile(hPipe,
|
||||
chReply,
|
||||
cbReplyBytes,
|
||||
&cbWritten,
|
||||
NULL);
|
||||
if (!fSuccess || cbReplyBytes != cbWritten)
|
||||
break;
|
||||
}
|
||||
|
||||
FlushFileBuffers(hPipe);
|
||||
DisconnectNamedPipe(hPipe);
|
||||
CloseHandle(hPipe);
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
OBJECTS = pteb.o
|
||||
PROGS = pteb.exe
|
||||
LIBS =
|
||||
CLEAN_FILES = pteb.o pteb.exe
|
||||
|
||||
all: pteb.exe
|
||||
|
||||
clean: $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
$(CLEAN_FILES:%=%_clean): %_clean:
|
||||
- $(RM) $*
|
||||
|
||||
.phony: clean $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
pteb.exe: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -o pteb.exe
|
||||
|
||||
include ../../rules.mak
|
@@ -1,14 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int x;
|
||||
|
||||
printf("TEB dumpper\n");
|
||||
__asm__("movl %%fs:0x18, %0\n\t"
|
||||
: "=a" (x)
|
||||
: /* no inputs */);
|
||||
printf("fs[0x18] %x\n", x);
|
||||
return(0);
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
OBJECTS= regtest.o
|
||||
PROGS= regtest.exe
|
||||
LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a \
|
||||
../../lib/advapi32/advapi32.a
|
||||
|
||||
BASE_CFLAGS = -I../../include
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) *.o
|
||||
- $(RM) *.exe
|
||||
- $(RM) *.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
regtest.exe: $(OBJECTS) $(LIBS)
|
||||
$(CC) $(OBJECTS) $(LIBS) -o regtest.exe
|
||||
$(NM) --numeric-sort regtest.exe > regtest.sym
|
||||
|
||||
include ../../rules.mak
|
@@ -1,715 +0,0 @@
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
void dprintf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void do_enumeratekey(PWSTR Name)
|
||||
{
|
||||
ULONG Index,Length,i;
|
||||
KEY_BASIC_INFORMATION KeyInformation[5];
|
||||
NTSTATUS Status;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE hKey1;
|
||||
UNICODE_STRING KeyName;
|
||||
|
||||
RtlInitUnicodeString(&KeyName, Name);
|
||||
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||
, NULL, NULL);
|
||||
Status=NtOpenKey( &hKey1, MAXIMUM_ALLOWED, &ObjectAttributes);
|
||||
dprintf("NtEnumerateKey : \n");
|
||||
Index=0;
|
||||
while(Status == STATUS_SUCCESS)
|
||||
{
|
||||
Status=NtEnumerateKey(hKey1,Index++,KeyBasicInformation
|
||||
,&KeyInformation[0], sizeof(KeyInformation)
|
||||
,&Length);
|
||||
if(Status== STATUS_SUCCESS)
|
||||
{
|
||||
dprintf("\tSubKey Name = ");
|
||||
for (i=0;i<KeyInformation[0].NameLength/2;i++)
|
||||
dprintf("%C",KeyInformation[0].Name[i]);
|
||||
dprintf("\n");
|
||||
}
|
||||
}
|
||||
NtClose(hKey1);
|
||||
}
|
||||
|
||||
void test1(void)
|
||||
{
|
||||
HKEY hKey = NULL,hKey1;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
NTSTATUS Status;
|
||||
UNICODE_STRING KeyName;
|
||||
ULONG Index,Length,i;
|
||||
KEY_BASIC_INFORMATION KeyInformation[5];
|
||||
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
|
||||
|
||||
dprintf("NtOpenKey \\Registry : ");
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status=NtOpenKey( &hKey1, MAXIMUM_ALLOWED, &ObjectAttributes);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
if(Status==0)
|
||||
{
|
||||
dprintf("NtQueryKey : ");
|
||||
Status=NtQueryKey(hKey1,KeyBasicInformation
|
||||
,&KeyInformation[0], sizeof(KeyInformation)
|
||||
,&Length);
|
||||
dprintf("\t\t\t\t\tStatus =%x\n",Status);
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
dprintf("\tKey Name = ");
|
||||
for (i=0;i<KeyInformation[0].NameLength/2;i++)
|
||||
dprintf("%C",KeyInformation[0].Name[i]);
|
||||
dprintf("\n");
|
||||
}
|
||||
dprintf("NtEnumerateKey : \n");
|
||||
Index=0;
|
||||
while(Status == STATUS_SUCCESS)
|
||||
{
|
||||
Status=NtEnumerateKey(hKey1,Index++,KeyBasicInformation
|
||||
,&KeyInformation[0], sizeof(KeyInformation)
|
||||
,&Length);
|
||||
if(Status== STATUS_SUCCESS)
|
||||
{
|
||||
dprintf("\tSubKey Name = ");
|
||||
for (i=0;i<KeyInformation[0].NameLength/2;i++)
|
||||
dprintf("%C",KeyInformation[0].Name[i]);
|
||||
dprintf("\n");
|
||||
}
|
||||
}
|
||||
dprintf("NtClose : ");
|
||||
Status = NtClose( hKey1 );
|
||||
dprintf("\t\t\t\t\tStatus =%x\n",Status);
|
||||
}
|
||||
NtClose(hKey);
|
||||
|
||||
dprintf("NtOpenKey \\Registry\\Machine : ");
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status=NtOpenKey( &hKey1, MAXIMUM_ALLOWED, &ObjectAttributes);
|
||||
dprintf("\t\t\tStatus =%x\n",Status);
|
||||
|
||||
dprintf("NtOpenKey System\\Setup : ");
|
||||
RtlInitUnicodeString(&KeyName, L"System\\Setup");
|
||||
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||
, hKey1 , NULL);
|
||||
Status = NtOpenKey ( &hKey, KEY_READ , &ObjectAttributes);
|
||||
dprintf("\t\t\tStatus =%x\n",Status);
|
||||
if(Status==0)
|
||||
{
|
||||
dprintf("NtQueryValueKey : ");
|
||||
RtlInitUnicodeString(&KeyName, L"CmdLine");
|
||||
Status=NtQueryValueKey(hKey,&KeyName,KeyValueFullInformation
|
||||
,&KeyValueInformation[0], sizeof(KeyValueInformation)
|
||||
,&Length);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
|
||||
,KeyValueInformation[0].DataOffset
|
||||
,KeyValueInformation[0].DataLength
|
||||
,KeyValueInformation[0].NameLength);
|
||||
for (i=0;i<10 && i<KeyValueInformation[0].NameLength/2;i++)
|
||||
dprintf("%C",KeyValueInformation[0].Name[i]);
|
||||
dprintf("\n");
|
||||
dprintf("\t\tType = %d\n",KeyValueInformation[0].Type);
|
||||
if (KeyValueInformation[0].Type == REG_SZ)
|
||||
dprintf("\t\tValue = %S\n",KeyValueInformation[0].Name+1
|
||||
+KeyValueInformation[0].NameLength/2);
|
||||
}
|
||||
dprintf("NtEnumerateValueKey : \n");
|
||||
Index=0;
|
||||
while(Status == STATUS_SUCCESS)
|
||||
{
|
||||
Status=NtEnumerateValueKey(hKey,Index++,KeyValueFullInformation
|
||||
,&KeyValueInformation[0], sizeof(KeyValueInformation)
|
||||
,&Length);
|
||||
if(Status== STATUS_SUCCESS)
|
||||
{
|
||||
dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
|
||||
,KeyValueInformation[0].DataOffset
|
||||
,KeyValueInformation[0].DataLength
|
||||
,KeyValueInformation[0].NameLength);
|
||||
for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
|
||||
dprintf("%C",KeyValueInformation[0].Name[i]);
|
||||
dprintf(", Type = %d\n",KeyValueInformation[0].Type);
|
||||
if (KeyValueInformation[0].Type == REG_SZ)
|
||||
dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation[0]
|
||||
+KeyValueInformation[0].DataOffset));
|
||||
}
|
||||
}
|
||||
dprintf("NtClose : ");
|
||||
Status = NtClose( hKey );
|
||||
dprintf("\t\t\t\t\tStatus =%x\n",Status);
|
||||
}
|
||||
NtClose( hKey1 );
|
||||
}
|
||||
|
||||
void test2(void)
|
||||
{
|
||||
HKEY hKey,hKey1;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING KeyName,ValueName;
|
||||
NTSTATUS Status;
|
||||
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
|
||||
ULONG Index,Length,i;
|
||||
char Buffer[10];
|
||||
DWORD Result;
|
||||
dprintf("NtCreateKey volatile: \n");
|
||||
dprintf(" \\Registry\\Machine\\Software\\test2reactos: ");
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos");
|
||||
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||
, NULL, NULL);
|
||||
Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
|
||||
,0,NULL,REG_OPTION_VOLATILE,NULL);
|
||||
dprintf("\t\tStatus=%x\n",Status);
|
||||
NtClose(hKey);
|
||||
do_enumeratekey(L"\\Registry\\Machine\\Software");
|
||||
dprintf(" ...\\test2 :");
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2");
|
||||
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||
, NULL, NULL);
|
||||
Status = NtCreateKey ( &hKey1, KEY_ALL_ACCESS , &ObjectAttributes
|
||||
,0,NULL,REG_OPTION_VOLATILE,NULL);
|
||||
dprintf("\t\t\t\t\tStatus=%x\n",Status);
|
||||
dprintf(" ...\\TestVolatile :");
|
||||
RtlInitUnicodeString(&KeyName, L"TestVolatile");
|
||||
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||
, hKey1, NULL);
|
||||
Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
|
||||
,0,NULL,REG_OPTION_VOLATILE,NULL);
|
||||
dprintf("\t\t\t\tStatus=%x\n",Status);
|
||||
NtClose(hKey1);
|
||||
RtlInitUnicodeString(&ValueName, L"TestREG_SZ");
|
||||
dprintf("NtSetValueKey reg_sz: ");
|
||||
Status=NtSetValueKey(hKey,&ValueName,0,REG_SZ,(PVOID)L"Test Reg_sz",24);
|
||||
dprintf("\t\t\t\tStatus=%x\n",Status);
|
||||
RtlInitUnicodeString(&ValueName, L"TestDWORD");
|
||||
dprintf("NtSetValueKey reg_dword: ");
|
||||
Status=NtSetValueKey(hKey,&ValueName,0,REG_DWORD,(PVOID)"reac",4);
|
||||
dprintf("\t\t\tStatus=%x\n",Status);
|
||||
NtClose(hKey);
|
||||
dprintf("NtOpenKey \\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile : ");
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
if(Status==0)
|
||||
{
|
||||
dprintf("NtEnumerateValueKey : \n");
|
||||
Index=0;
|
||||
while(Status == STATUS_SUCCESS)
|
||||
{
|
||||
Status=NtEnumerateValueKey(hKey,Index++,KeyValueFullInformation
|
||||
,&KeyValueInformation[0], sizeof(KeyValueInformation)
|
||||
,&Length);
|
||||
if(Status== STATUS_SUCCESS)
|
||||
{
|
||||
dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
|
||||
,KeyValueInformation[0].DataOffset
|
||||
,KeyValueInformation[0].DataLength
|
||||
,KeyValueInformation[0].NameLength);
|
||||
for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
|
||||
dprintf("%C",KeyValueInformation[0].Name[i]);
|
||||
dprintf(", Type = %d\n",KeyValueInformation[0].Type);
|
||||
if (KeyValueInformation[0].Type == REG_SZ)
|
||||
dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation[0]
|
||||
+KeyValueInformation[0].DataOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
NtClose(hKey);
|
||||
dprintf("delete \\Registry\\Machine\\software\\test2reactos ?");
|
||||
ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
|
||||
if (Buffer[0] != 'y' && Buffer[0] != 'Y') return;
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
dprintf("NtOpenKey : ");
|
||||
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
dprintf("NtDeleteKey : ");
|
||||
Status=NtDeleteKey(hKey);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
NtClose(hKey);
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
dprintf("NtOpenKey : ");
|
||||
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
dprintf("NtDeleteKey : ");
|
||||
Status=NtDeleteKey(hKey);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
NtClose(hKey);
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
dprintf("NtOpenKey : ");
|
||||
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
dprintf("NtDeleteKey : ");
|
||||
Status=NtDeleteKey(hKey);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
NtClose(hKey);
|
||||
}
|
||||
|
||||
void test3(void)
|
||||
{
|
||||
HKEY hKey,hKey1;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING KeyName,ValueName;
|
||||
NTSTATUS Status;
|
||||
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
|
||||
ULONG Index,Length,i;
|
||||
char Buffer[10];
|
||||
DWORD Result;
|
||||
dprintf("NtCreateKey non volatile: \n");
|
||||
dprintf(" \\Registry\\Machine\\Software\\test3reactos: ");
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos");
|
||||
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||
, NULL, NULL);
|
||||
Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
|
||||
,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
|
||||
dprintf("\t\tStatus=%x\n",Status);
|
||||
NtClose(hKey);
|
||||
do_enumeratekey(L"\\Registry\\Machine\\Software");
|
||||
dprintf("NtOpenKey: ");
|
||||
Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
|
||||
dprintf("\t\tStatus=%x\n",Status);
|
||||
NtClose(hKey);
|
||||
dprintf(" ...\\test3 :");
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3");
|
||||
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||
, NULL, NULL);
|
||||
Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
|
||||
,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
|
||||
dprintf("\t\t\t\t\tStatus=%x\n",Status);
|
||||
dprintf("NtOpenKey: ");
|
||||
Status=NtOpenKey( &hKey1, MAXIMUM_ALLOWED, &ObjectAttributes);
|
||||
dprintf("\t\tStatus=%x\n",Status);
|
||||
NtClose(hKey);
|
||||
dprintf(" ...\\testNonVolatile :");
|
||||
RtlInitUnicodeString(&KeyName, L"TestNonVolatile");
|
||||
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||
, hKey1, NULL);
|
||||
Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
|
||||
,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
|
||||
dprintf("\t\t\t\tStatus=%x\n",Status);
|
||||
NtClose(hKey1);
|
||||
RtlInitUnicodeString(&ValueName, L"TestREG_SZ");
|
||||
dprintf("NtSetValueKey reg_sz: ");
|
||||
Status=NtSetValueKey(hKey,&ValueName,0,REG_SZ,(PVOID)L"Test Reg_sz",24);
|
||||
dprintf("\t\t\t\tStatus=%x\n",Status);
|
||||
RtlInitUnicodeString(&ValueName, L"TestDWORD");
|
||||
dprintf("NtSetValueKey reg_dword: ");
|
||||
Status=NtSetValueKey(hKey,&ValueName,0,REG_DWORD,(PVOID)"reac",4);
|
||||
dprintf("\t\t\tStatus=%x\n",Status);
|
||||
NtClose(hKey);
|
||||
dprintf("NtOpenKey \\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile : ");
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
if(Status==0)
|
||||
{
|
||||
dprintf("NtEnumerateValueKey : \n");
|
||||
Index=0;
|
||||
while(Status == STATUS_SUCCESS)
|
||||
{
|
||||
Status=NtEnumerateValueKey(hKey,Index++,KeyValueFullInformation
|
||||
,&KeyValueInformation[0], sizeof(KeyValueInformation)
|
||||
,&Length);
|
||||
if(Status== STATUS_SUCCESS)
|
||||
{
|
||||
dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
|
||||
,KeyValueInformation[0].DataOffset
|
||||
,KeyValueInformation[0].DataLength
|
||||
,KeyValueInformation[0].NameLength);
|
||||
for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
|
||||
dprintf("%C",KeyValueInformation[0].Name[i]);
|
||||
dprintf(", Type = %d\n",KeyValueInformation[0].Type);
|
||||
if (KeyValueInformation[0].Type == REG_SZ)
|
||||
dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation[0]
|
||||
+KeyValueInformation[0].DataOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
NtClose(hKey);
|
||||
dprintf("delete \\Registry\\Machine\\software\\test3reactos ?");
|
||||
ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
|
||||
if (Buffer[0] != 'y' && Buffer[0] != 'Y') return;
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonvolatile");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
dprintf("NtOpenKey : ");
|
||||
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
dprintf("NtDeleteKey : ");
|
||||
Status=NtDeleteKey(hKey);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
dprintf("NtOpenKey : ");
|
||||
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
dprintf("NtDeleteKey : ");
|
||||
Status=NtDeleteKey(hKey);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
NtClose(hKey);
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
dprintf("NtOpenKey : ");
|
||||
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
dprintf("NtDeleteKey : ");
|
||||
Status=NtDeleteKey(hKey);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
NtClose(hKey);
|
||||
}
|
||||
|
||||
void test4(void)
|
||||
{
|
||||
HKEY hKey = NULL,hKey1;
|
||||
DWORD dwDisposition;
|
||||
DWORD dwError;
|
||||
DWORD RegDataType, RegDataSize;
|
||||
BOOL GlobalFifoEnable;
|
||||
HKEY hPortKey;
|
||||
DWORD RegDisposition;
|
||||
WCHAR szClass[260];
|
||||
DWORD cchClass;
|
||||
DWORD cSubKeys;
|
||||
DWORD cchMaxSubkey;
|
||||
DWORD cchMaxClass;
|
||||
DWORD cValues;
|
||||
DWORD cchMaxValueName;
|
||||
DWORD cbMaxValueData;
|
||||
DWORD cbSecurityDescriptor;
|
||||
FILETIME ftLastWriteTime;
|
||||
SYSTEMTIME LastWriteTime;
|
||||
|
||||
dprintf ("RegOpenKeyExW HKLM\\System\\Setup: ");
|
||||
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||
L"System\\Setup",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey1);
|
||||
dprintf("\t\tdwError =%x\n",dwError);
|
||||
if (dwError == ERROR_SUCCESS)
|
||||
{
|
||||
dprintf("RegQueryInfoKeyW: ");
|
||||
cchClass=260;
|
||||
dwError = RegQueryInfoKeyW(hKey1
|
||||
, szClass, &cchClass, NULL, &cSubKeys
|
||||
, &cchMaxSubkey, &cchMaxClass, &cValues, &cchMaxValueName
|
||||
, &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
|
||||
dprintf ("\t\t\t\tdwError %x\n", dwError);
|
||||
FileTimeToSystemTime(&ftLastWriteTime,&LastWriteTime);
|
||||
dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
|
||||
,LastWriteTime.wMonth
|
||||
,LastWriteTime.wDay
|
||||
,LastWriteTime.wYear
|
||||
,LastWriteTime.wHour
|
||||
,LastWriteTime.wMinute
|
||||
,LastWriteTime.wSecond
|
||||
,LastWriteTime.wMilliseconds
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
dprintf ("RegOpenKeyExW: ");
|
||||
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||
L"System\\ControlSet001\\Services\\Serial",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey);
|
||||
dprintf ("\t\t\t\t\tdwError %x\n", dwError);
|
||||
RegDataSize = sizeof(GlobalFifoEnable);
|
||||
if (dwError == ERROR_SUCCESS)
|
||||
{
|
||||
dprintf ("RegQueryValueExW: ");
|
||||
dwError = RegQueryValueExW(hKey,
|
||||
L"ForceFifoEnable",
|
||||
NULL,
|
||||
&RegDataType,
|
||||
(PBYTE)&GlobalFifoEnable,
|
||||
&RegDataSize);
|
||||
dprintf("\t\t\t\tdwError =%x\n",dwError);
|
||||
if (dwError == 0)
|
||||
{
|
||||
dprintf("\tValue:DT=%d, DS=%d, Value=%d\n"
|
||||
,RegDataType
|
||||
,RegDataSize
|
||||
,GlobalFifoEnable);
|
||||
}
|
||||
}
|
||||
dprintf ("RegCreateKeyExW: ");
|
||||
dwError = RegCreateKeyExW(hKey,
|
||||
L"Parameters\\Serial001",
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&hPortKey,
|
||||
&RegDisposition
|
||||
);
|
||||
dprintf ("\t\t\t\tdwError %x\n", dwError);
|
||||
|
||||
dprintf ("RegCreateKeyExW: ");
|
||||
dwError = RegCreateKeyExW (HKEY_LOCAL_MACHINE,
|
||||
L"Software\\test4reactos\\test",
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&hKey,
|
||||
&dwDisposition);
|
||||
|
||||
dprintf ("\t\t\t\tdwError %x ", dwError);
|
||||
dprintf ("dwDisposition %x\n", dwDisposition);
|
||||
if (dwError == ERROR_SUCCESS)
|
||||
{
|
||||
dprintf ("RegSetValueExW: ");
|
||||
dwError = RegSetValueExW (hKey,
|
||||
L"TestValue",
|
||||
0,
|
||||
REG_SZ,
|
||||
(BYTE*)L"TestString",
|
||||
20);
|
||||
|
||||
dprintf ("\t\t\t\tdwError %x\n", dwError);
|
||||
dprintf ("RegCloseKey: ");
|
||||
dwError = RegCloseKey (hKey);
|
||||
dprintf ("\t\t\t\t\tdwError %x\n", dwError);
|
||||
}
|
||||
dprintf ("\n\n");
|
||||
|
||||
hKey = NULL;
|
||||
|
||||
dprintf ("RegCreateKeyExW: ");
|
||||
dwError = RegCreateKeyExW (HKEY_LOCAL_MACHINE,
|
||||
L"software\\Test",
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&hKey,
|
||||
&dwDisposition);
|
||||
|
||||
dprintf ("\t\t\t\tdwError %x ", dwError);
|
||||
dprintf ("dwDisposition %x\n", dwDisposition);
|
||||
|
||||
|
||||
if (dwError == ERROR_SUCCESS)
|
||||
{
|
||||
dprintf("RegQueryInfoKeyW: ");
|
||||
cchClass=260;
|
||||
dwError = RegQueryInfoKeyW(hKey
|
||||
, szClass, &cchClass, NULL, &cSubKeys
|
||||
, &cchMaxSubkey, &cchMaxClass, &cValues, &cchMaxValueName
|
||||
, &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
|
||||
dprintf ("\t\t\t\tdwError %x\n", dwError);
|
||||
FileTimeToSystemTime(&ftLastWriteTime,&LastWriteTime);
|
||||
dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
|
||||
,LastWriteTime.wMonth
|
||||
,LastWriteTime.wDay
|
||||
,LastWriteTime.wYear
|
||||
,LastWriteTime.wHour
|
||||
,LastWriteTime.wMinute
|
||||
,LastWriteTime.wSecond
|
||||
,LastWriteTime.wMilliseconds
|
||||
);
|
||||
dprintf ("RegCloseKey: ");
|
||||
dwError = RegCloseKey (hKey);
|
||||
dprintf ("\t\t\t\t\tdwError %x\n", dwError);
|
||||
}
|
||||
dprintf ("\nTests done...\n");
|
||||
}
|
||||
|
||||
void test5(void)
|
||||
{
|
||||
HKEY hKey,hKey1;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING KeyName,ValueName;
|
||||
NTSTATUS Status;
|
||||
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
|
||||
ULONG Index,Length,i;
|
||||
char Buffer[10];
|
||||
DWORD Result;
|
||||
dprintf("NtOpenKey : \n");
|
||||
dprintf(" \\Registry\\Machine\\Software\\reactos : ");
|
||||
RtlInitUnicodeString(&KeyName,L"\\Registry\\Machine\\Software\\reactos");
|
||||
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||
, NULL, NULL);
|
||||
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
|
||||
dprintf("\t\tStatus=%x\n",Status);
|
||||
dprintf("NtFlushKey : \n");
|
||||
Status = NtFlushKey(hKey);
|
||||
dprintf("\t\tStatus=%x\n",Status);
|
||||
dprintf("NtCloseKey : \n");
|
||||
Status=NtClose(hKey);
|
||||
dprintf("\t\tStatus=%x\n",Status);
|
||||
}
|
||||
|
||||
void test6(void)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING KeyName;
|
||||
NTSTATUS Status;
|
||||
LONG dwError;
|
||||
TOKEN_PRIVILEGES NewPrivileges;
|
||||
HANDLE Token,hKey;
|
||||
LUID Luid;
|
||||
BOOLEAN bRes;
|
||||
Status=NtOpenProcessToken(GetCurrentProcess()
|
||||
,TOKEN_ADJUST_PRIVILEGES,&Token);
|
||||
// ,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&Token);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
// bRes=LookupPrivilegeValueA(NULL,SE_RESTORE_NAME,&Luid);
|
||||
// dprintf("\t\t\t\tbRes =%x\n",bRes);
|
||||
NewPrivileges.PrivilegeCount = 1;
|
||||
NewPrivileges.Privileges[0].Luid = Luid;
|
||||
// NewPrivileges.Privileges[0].Luid.u.LowPart=18;
|
||||
// NewPrivileges.Privileges[0].Luid.u.HighPart=0;
|
||||
NewPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
// Status = NtAdjustPrivilegesToken(
|
||||
bRes = AdjustTokenPrivileges(
|
||||
Token,
|
||||
FALSE,
|
||||
&NewPrivileges,
|
||||
0,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
dprintf("\t\t\t\tbRes =%x\n",bRes);
|
||||
|
||||
// Status=NtClose(Token);
|
||||
// dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
|
||||
|
||||
RtlInitUnicodeString(&KeyName,L"test5");
|
||||
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||
, NULL, NULL);
|
||||
Status = NtLoadKey(HKEY_LOCAL_MACHINE,&ObjectAttributes);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
dwError=RegLoadKey(HKEY_LOCAL_MACHINE,"def"
|
||||
,"test5");
|
||||
dprintf("\t\t\t\tdwError =%x\n",dwError);
|
||||
|
||||
dprintf("NtOpenKey \\Registry\\Machine : ");
|
||||
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
|
||||
dprintf("\t\t\tStatus =%x\n",Status);
|
||||
RtlInitUnicodeString(&KeyName,L"test5");
|
||||
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||
, NULL, NULL);
|
||||
Status = NtLoadKey(hKey,&ObjectAttributes);
|
||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char Buffer[10];
|
||||
DWORD Result;
|
||||
|
||||
AllocConsole();
|
||||
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
while(1)
|
||||
{
|
||||
dprintf("choose test :\n");
|
||||
dprintf(" 0=Exit\n");
|
||||
dprintf(" 1=Ntxxx read functions\n");
|
||||
dprintf(" 2=Ntxxx write functions : volatile keys\n");
|
||||
dprintf(" 3=Ntxxx write functions : non volatile keys\n");
|
||||
dprintf(" 4=Regxxx functions\n");
|
||||
dprintf(" 5=FlushKey \n");
|
||||
ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
|
||||
switch (Buffer[0])
|
||||
{
|
||||
case '0':
|
||||
return(0);
|
||||
case '1':
|
||||
test1();
|
||||
break;
|
||||
case '2':
|
||||
test2();
|
||||
break;
|
||||
case '3':
|
||||
test3();
|
||||
break;
|
||||
case '4':
|
||||
test4();
|
||||
break;
|
||||
case '5':
|
||||
test5();
|
||||
break;
|
||||
case '6':
|
||||
test6();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
SRV_OBJECTS= shmsrv.o
|
||||
CLT_OBJECTS= shmclt.o
|
||||
|
||||
PROGS= shmsrv.exe shmclt.exe
|
||||
|
||||
BASE_CFLAGS = -I../../include
|
||||
LIBS = ../../lib/crtdll/crtdll.a ../../lib/kernel32/kernel32.a \
|
||||
../../lib/ntdll/ntdll.a
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) *.o
|
||||
- $(RM) *.exe
|
||||
- $(RM) *.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
shmsrv.exe: $(SRV_OBJECTS) $(LIBS)
|
||||
$(CC) $(SRV_OBJECTS) $(LIBS) -o shmsrv.exe
|
||||
$(NM) --numeric-sort shmsrv.exe > shmsrv.sym
|
||||
|
||||
shmclt.exe: $(CLT_OBJECTS) $(LIBS)
|
||||
$(CC) $(CLT_OBJECTS) $(LIBS) -o shmclt.exe
|
||||
$(NM) --numeric-sort shmsrv.exe > shmclt.sym
|
||||
|
||||
|
||||
include ../../rules.mak
|
@@ -1,61 +0,0 @@
|
||||
#include <ddk/ntddk.h>
|
||||
#include <windows.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
void debug_printf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
HANDLE Section;
|
||||
PVOID BaseAddress;
|
||||
char buffer[256];
|
||||
|
||||
printf("Shm test server\n");
|
||||
|
||||
Section = OpenFileMappingW (
|
||||
// PAGE_EXECUTE_READWRITE, invalid parameter
|
||||
FILE_MAP_WRITE,
|
||||
FALSE,
|
||||
L"TestSection"
|
||||
);
|
||||
if (Section == NULL)
|
||||
{
|
||||
printf("Failed to open section (err=%d)", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
BaseAddress = MapViewOfFile(Section,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
8192);
|
||||
if (BaseAddress == NULL)
|
||||
{
|
||||
printf("Failed to map section (err=%d)\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
printf("BaseAddress %x\n", (UINT) BaseAddress);
|
||||
printf("Copying from section\n");
|
||||
strcpy(buffer, BaseAddress);
|
||||
printf("Copyed <%s>\n", buffer);
|
||||
|
||||
// for(;;);
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,53 +0,0 @@
|
||||
/* $Id: shmsrv.c,v 1.5 2000/06/29 23:35:10 dwelch Exp $
|
||||
*
|
||||
* FILE : reactos/apps/shm/shmsrv.c
|
||||
* AUTHOR: David Welch
|
||||
*/
|
||||
#include <ddk/ntddk.h>
|
||||
#include <windows.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
HANDLE Section;
|
||||
PVOID BaseAddress;
|
||||
|
||||
printf("Shm test server\n");
|
||||
|
||||
Section = CreateFileMappingW (
|
||||
(HANDLE) 0xFFFFFFFF,
|
||||
NULL,
|
||||
PAGE_READWRITE,
|
||||
0,
|
||||
8192,
|
||||
L"TestSection"
|
||||
);
|
||||
if (Section == NULL)
|
||||
{
|
||||
printf("Failed to create section (err=%d)", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Mapping view of section\n");
|
||||
BaseAddress = MapViewOfFile(Section,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
8192);
|
||||
printf("BaseAddress %x\n", (UINT) BaseAddress);
|
||||
if (BaseAddress == NULL)
|
||||
{
|
||||
printf("Failed to map section\n");
|
||||
}
|
||||
|
||||
printf("Copying to section\n");
|
||||
printf("Copying %s\n", GetCommandLineA());
|
||||
strcpy(BaseAddress, GetCommandLineA());
|
||||
|
||||
Sleep(INFINITE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,11 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int i;
|
||||
puts ("This should print \"wow = I\" for I from 0 to 39 inclusive.");
|
||||
for (i = 0; i < 40; i++)
|
||||
printf ("%s = %d\n", "wow", i);
|
||||
return 0;
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
FILE *f;
|
||||
int i;
|
||||
const char filename[] = "/tmp/bug3.test";
|
||||
|
||||
f = fopen(filename, "w+");
|
||||
for (i=0; i<9000; i++)
|
||||
putc ('x', f);
|
||||
fseek (f, 8180L, 0);
|
||||
fwrite ("Where does this text go?", 1, 24, f);
|
||||
fflush (f);
|
||||
|
||||
rewind (f);
|
||||
for (i=0; i<9000; i++)
|
||||
{
|
||||
int j;
|
||||
|
||||
if ((j = getc(f)) != 'x')
|
||||
{
|
||||
if (i != 8180)
|
||||
{
|
||||
printf ("Test FAILED!");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf[25];
|
||||
|
||||
buf[0] = j;
|
||||
fread (buf + 1, 1, 23, f);
|
||||
buf[24] = '\0';
|
||||
if (strcmp (buf, "Where does this text go?") != 0)
|
||||
{
|
||||
printf ("%s\nTest FAILED!\n", buf);
|
||||
return 1;
|
||||
}
|
||||
i += 23;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
remove(filename);
|
||||
|
||||
puts ("Test succeeded.");
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,72 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
PROGS= test-stdio tst-printf tstdiomisc bug2 bug3 \
|
||||
temptest test-fseek test_rdwr testfsd
|
||||
|
||||
all: $(PROGS:%=%.exe)
|
||||
|
||||
.phony: all
|
||||
|
||||
$(PROGS:%=%_clean): %_clean:
|
||||
- $(RM) $*.o
|
||||
- $(RM) $*.exe
|
||||
- $(RM) $*.sym
|
||||
|
||||
clean: $(PROGS:%=%_clean)
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: # $(PROGS:%=$(FLOPPY_DIR)/apps/%.exe)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%.exe): $(FLOPPY_DIR)/apps/%.exe: %.exe
|
||||
$(CP) $*.exe $(FLOPPY_DIR)/apps/$*.exe
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%.exe)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%.exe): ../../$(DIST_DIR)/apps/%.exe: %.exe
|
||||
$(CP) $*.exe ../../$(DIST_DIR)/apps/$*.exe
|
||||
|
||||
bug2.exe: bug2.c
|
||||
$(CC) bug2.c -lkernel32 -o bug2.exe
|
||||
$(NM) --numeric-sort bug2.exe > bug2.sym
|
||||
|
||||
bug3.exe: bug3.c
|
||||
$(CC) bug3.c -lkernel32 -o bug3.exe
|
||||
$(NM) --numeric-sort bug3.exe > bug3.sym
|
||||
|
||||
temptest.exe: temptest.c
|
||||
$(CC) temptest.c -lkernel32 -o temptest.exe
|
||||
$(NM) --numeric-sort temptest.exe > temptest.sym
|
||||
|
||||
test-fseek.exe: test-fseek.c
|
||||
$(CC) test-fseek.c -lkernel32 -o test-fseek.exe
|
||||
$(NM) --numeric-sort test-fseek.exe > test-fseek.sym
|
||||
|
||||
test-fwrite.exe: test-fwrite.c
|
||||
$(CC) test-fwrite.c -lkernel32 -o test-fwrite.exe
|
||||
$(NM) --numeric-sort test-fwrite.exe > test-fwrite.sym
|
||||
|
||||
test_rdwr.exe: test_rdwr.c
|
||||
$(CC) test_rdwr.c -lkernel32 -o test_rdwr.exe
|
||||
$(NM) --numeric-sort test_rdwr.exe > test_rdwr.sym
|
||||
|
||||
test-stdio.exe: test-stdio.c
|
||||
$(CC) test-stdio.c -lkernel32 -o test-stdio.exe
|
||||
$(NM) --numeric-sort test-stdio.exe > test-stdio.sym
|
||||
|
||||
tst-printf.exe: tst-printf.c
|
||||
$(CC) tst-printf.c -lkernel32 -o tst-printf.exe
|
||||
$(NM) --numeric-sort tst-printf.exe > tst-printf.sym
|
||||
|
||||
tstdiomisc.exe: tstdiomisc.c
|
||||
$(CC) tstdiomisc.c -lkernel32 -o tstdiomisc.exe
|
||||
$(NM) --numeric-sort tstdiomisc.exe > tstdiomisc.sym
|
||||
|
||||
testfsd.exe: testfsd.c
|
||||
$(CC) testfsd.c -lkernel32 -o testfsd.exe
|
||||
$(NM) --numeric-sort testfsd.exe > testfsd.sym
|
||||
|
||||
include ../../rules.mak
|
@@ -1,27 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
char *files[500];
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
FILE *fp;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
files[i] = tempnam (NULL, "file");
|
||||
if (files[i] == NULL) {
|
||||
printf ("tempnam failed\n");
|
||||
exit (1);
|
||||
}
|
||||
printf ("file: %s\n", files[i]);
|
||||
fp = fopen (files[i], "w");
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
for (i = 0; i < 500; i++)
|
||||
remove (files[i]);
|
||||
|
||||
exit (0);
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define TESTFILE "/tmp/test.dat"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
FILE *fp;
|
||||
int i, j;
|
||||
|
||||
puts ("\nFile seek test");
|
||||
fp = fopen (TESTFILE, "w");
|
||||
if (fp == NULL)
|
||||
{
|
||||
perror (TESTFILE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
putc (i, fp);
|
||||
if (freopen (TESTFILE, "r", fp) != fp)
|
||||
{
|
||||
perror ("Cannot open file for reading");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 1; i <= 255; i++)
|
||||
{
|
||||
printf ("%3d\n", i);
|
||||
fseek (fp, (long) -i, SEEK_END);
|
||||
if ((j = getc (fp)) != 256 - i)
|
||||
{
|
||||
printf ("SEEK_END failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
if (fseek (fp, (long) i, SEEK_SET))
|
||||
{
|
||||
puts ("Cannot SEEK_SET");
|
||||
break;
|
||||
}
|
||||
if ((j = getc (fp)) != i)
|
||||
{
|
||||
printf ("SEEK_SET failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
if (fseek (fp, (long) i, SEEK_SET))
|
||||
{
|
||||
puts ("Cannot SEEK_SET");
|
||||
break;
|
||||
}
|
||||
if (fseek (fp, (long) (i >= 128 ? -128 : 128), SEEK_CUR))
|
||||
{
|
||||
puts ("Cannot SEEK_CUR");
|
||||
break;
|
||||
}
|
||||
if ((j = getc (fp)) != (i >= 128 ? i - 128 : i + 128))
|
||||
{
|
||||
printf ("SEEK_CUR failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose (fp);
|
||||
remove (TESTFILE);
|
||||
|
||||
puts ((i > 255) ? "Test succeeded." : "Test FAILED!");
|
||||
return (i > 255) ? 0 : 1;
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
FILE *f = tmpfile ();
|
||||
char obuf[99999], ibuf[sizeof obuf];
|
||||
char *line;
|
||||
size_t linesz;
|
||||
|
||||
if (! f)
|
||||
{
|
||||
perror ("tmpfile");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fputs ("line\n", f) == EOF)
|
||||
{
|
||||
perror ("fputs");
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset (obuf, 'z', sizeof obuf);
|
||||
memset (ibuf, 'y', sizeof ibuf);
|
||||
|
||||
if (fwrite (obuf, sizeof obuf, 1, f) != 1)
|
||||
{
|
||||
perror ("fwrite");
|
||||
return 1;
|
||||
}
|
||||
|
||||
rewind (f);
|
||||
|
||||
line = NULL;
|
||||
linesz = 0;
|
||||
if (getline (&line, &linesz, f) != 5)
|
||||
{
|
||||
perror ("getline");
|
||||
return 1;
|
||||
}
|
||||
if (strcmp (line, "line\n"))
|
||||
{
|
||||
puts ("Lines differ. Test FAILED!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fread (ibuf, sizeof ibuf, 1, f) != 1)
|
||||
{
|
||||
perror ("fread");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (memcmp (ibuf, obuf, sizeof ibuf))
|
||||
{
|
||||
puts ("Buffers differ. Test FAILED!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
asprintf (&line, "\
|
||||
GDB is free software and you are welcome to distribute copies of it\n\
|
||||
under certain conditions; type \"show copying\" to see the conditions.\n\
|
||||
There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
|
||||
");
|
||||
|
||||
puts ("Test succeeded.");
|
||||
return 0;
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char msg1[] = "testing _write\n";
|
||||
char msg2[] = "testing putchar.";
|
||||
char msg3[] = "testing printf.";
|
||||
char tmpbuf[255];
|
||||
FILE* f1;
|
||||
|
||||
write(1, msg1, strlen(msg1));
|
||||
|
||||
write(1, msg2, strlen(msg2));
|
||||
putchar('o'); putchar('k'); putchar('\n');
|
||||
|
||||
write(1, msg3, strlen(msg3));
|
||||
printf("ok\n");
|
||||
|
||||
printf("Testing fopen\n");
|
||||
f1 = fopen("tmp.txt","w+b");
|
||||
if (f1 == NULL)
|
||||
{
|
||||
printf("fopen failed\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
printf("Testing fwrite\n");
|
||||
if (fwrite(msg1, 1, strlen(msg1)+1, f1) != (strlen(msg1)+1))
|
||||
{
|
||||
printf("fwrite failed\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
printf("Testing fread\n");
|
||||
fseek(f1, 0, SEEK_SET);
|
||||
if (fread(tmpbuf, 1, strlen(msg1)+1, f1) != (strlen(msg1)+1))
|
||||
{
|
||||
printf("fread failed\n");
|
||||
return(1);
|
||||
}
|
||||
if (strcmp(tmpbuf,msg1) != 0)
|
||||
{
|
||||
printf("fread failed, data corrupt\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
printf("Testing fclose\n");
|
||||
if (fclose(f1) != 0)
|
||||
{
|
||||
printf("fclose failed\n");
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
@@ -1,129 +0,0 @@
|
||||
/* Copyright (C) 1991, 1992, 1996, 1997, 1998 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
static const char hello[] = "Hello, world.\n";
|
||||
static const char replace[] = "Hewwo, world.\n";
|
||||
static const size_t replace_from = 2, replace_to = 4;
|
||||
char filename[FILENAME_MAX];
|
||||
char *name = strrchr (*argv, '/');
|
||||
char buf[BUFSIZ];
|
||||
FILE *f;
|
||||
int lose = 0;
|
||||
|
||||
if (name != NULL)
|
||||
++name;
|
||||
else
|
||||
name = *argv;
|
||||
|
||||
(void) sprintf (filename, "/tmp/%s.test", name);
|
||||
|
||||
f = fopen (filename, "w+");
|
||||
if (f == NULL)
|
||||
{
|
||||
perror (filename);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
(void) fputs (hello, f);
|
||||
rewind (f);
|
||||
(void) fgets (buf, sizeof (buf), f);
|
||||
rewind (f);
|
||||
(void) fputs (buf, f);
|
||||
rewind (f);
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < replace_from; ++i)
|
||||
{
|
||||
int c = getc (f);
|
||||
if (c == EOF)
|
||||
{
|
||||
printf ("EOF at %Zu.\n", i);
|
||||
lose = 1;
|
||||
break;
|
||||
}
|
||||
else if (c != hello[i])
|
||||
{
|
||||
printf ("Got '%c' instead of '%c' at %Zu.\n",
|
||||
(unsigned char) c, hello[i], i);
|
||||
lose = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
long int where = ftell (f);
|
||||
if (where == (long int) replace_from)
|
||||
{
|
||||
register size_t i;
|
||||
for (i = replace_from; i < replace_to; ++i)
|
||||
if (putc(replace[i], f) == EOF)
|
||||
{
|
||||
printf ("putc('%c') got %s at %Zu.\n",
|
||||
replace[i], strerror (errno), i);
|
||||
lose = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (where == -1L)
|
||||
{
|
||||
printf ("ftell got %s (should be at %Zu).\n",
|
||||
strerror (errno), replace_from);
|
||||
lose = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("ftell returns %lu; should be %Zu.\n", where, replace_from);
|
||||
lose = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!lose)
|
||||
{
|
||||
rewind (f);
|
||||
if (fgets (buf, sizeof (buf), f) == NULL)
|
||||
{
|
||||
printf ("fgets got %s.\n", strerror(errno));
|
||||
lose = 1;
|
||||
}
|
||||
else if (strcmp (buf, replace))
|
||||
{
|
||||
printf ("Read \"%s\" instead of \"%s\".\n", buf, replace);
|
||||
lose = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (lose)
|
||||
printf ("Test FAILED! Losing file is \"%s\".\n", filename);
|
||||
else
|
||||
{
|
||||
(void) remove (filename);
|
||||
puts ("Test succeeded.");
|
||||
}
|
||||
|
||||
exit (lose ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
@@ -1,229 +0,0 @@
|
||||
/* $Id: testfsd.c,v 1.3 2001/05/01 19:42:56 narnaoud Exp $
|
||||
*
|
||||
* FILE: testFSD.c
|
||||
* PURPOSE: A test set for the File System Driver
|
||||
* PROJECT: ReactOS kernel
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROGRAMMER: Rex Jolliff (rex@lvcablemodem.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
#define ASSERT(x) doAssertion (x, #x, __FUNCTION__, __LINE__)
|
||||
|
||||
struct TestSuite
|
||||
{
|
||||
char *name;
|
||||
void (*testFunc)(void);
|
||||
};
|
||||
|
||||
#define ADD_TEST(x) {#x, x}
|
||||
#define COUNT_TESTS(x) (sizeof x/sizeof (struct TestSuite))
|
||||
|
||||
const char *rootDir = "c:\\";
|
||||
const char *systemRootDir = "c:\\ReactOS";
|
||||
const char *systemDllDir = "c:\\ReactOS\\System32";
|
||||
const char *bogusRootFile = "c:\\bogus";
|
||||
const char *bogusDirAndFile = "c:\\bogus\\bogus";
|
||||
const char *bogusSystemRootFile = "c:\\ReactOS\\bogus";
|
||||
const char *bogusSystemDllFile = "c:\\ReactOS\\System32\\bogus";
|
||||
|
||||
int tests, assertions, failures, successes;
|
||||
|
||||
void doAssertion (BOOL pTest, PCHAR pTestText, PCHAR pFunction, int pLine);
|
||||
|
||||
void testOpenExistant (void);
|
||||
void testOpenNonExistant (void);
|
||||
void testCreateExistant (void);
|
||||
void testCreateNonExistant (void);
|
||||
void testOverwriteExistant (void);
|
||||
void testOverwriteNonExistant (void);
|
||||
void testOpenWithBlankPathElements (void);
|
||||
|
||||
struct TestSuite gTests [] =
|
||||
{
|
||||
ADD_TEST (testOpenExistant),
|
||||
ADD_TEST (testOpenNonExistant),
|
||||
ADD_TEST (testCreateExistant),
|
||||
ADD_TEST (testCreateNonExistant),
|
||||
/* ADD_TEST (testOverwriteExistant),*/
|
||||
/* ADD_TEST (testOverwriteNonExistant),*/
|
||||
ADD_TEST (testOpenWithBlankPathElements)
|
||||
};
|
||||
|
||||
int main (void)
|
||||
{
|
||||
int testIndex;
|
||||
|
||||
tests = assertions = failures = successes = 0;
|
||||
|
||||
for (testIndex = 0; testIndex < COUNT_TESTS(gTests); testIndex++)
|
||||
{
|
||||
gTests [testIndex].testFunc ();
|
||||
tests++;
|
||||
}
|
||||
|
||||
printf ("\nTotals: tests: %d assertions: %d successes: %d failures: %d\n",
|
||||
tests,
|
||||
assertions,
|
||||
successes,
|
||||
failures);
|
||||
if (failures == 0)
|
||||
{
|
||||
printf ("\n*** OK ***\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("\n*** FAIL ***\n");
|
||||
}
|
||||
}
|
||||
|
||||
void testOpenExistant (void)
|
||||
{
|
||||
HANDLE fileHandle;
|
||||
|
||||
fileHandle = CreateFile (rootDir, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile (systemRootDir, GENERIC_READ, 0, 0,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile (systemDllDir, GENERIC_READ, 0, 0,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
}
|
||||
|
||||
void testOpenNonExistant (void)
|
||||
{
|
||||
DWORD status;
|
||||
HANDLE fileHandle;
|
||||
|
||||
fileHandle = CreateFile (bogusRootFile, GENERIC_READ, 0, 0,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
|
||||
status = GetLastError ();
|
||||
ASSERT (status == ERROR_FILE_NOT_FOUND);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile (bogusDirAndFile, GENERIC_READ, 0, 0,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
|
||||
status = GetLastError ();
|
||||
ASSERT (status == ERROR_PATH_NOT_FOUND);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile (bogusSystemRootFile, GENERIC_READ, 0, 0,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
|
||||
status = GetLastError ();
|
||||
ASSERT (status == ERROR_FILE_NOT_FOUND);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile (bogusSystemDllFile, GENERIC_READ, 0, 0,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
|
||||
status = GetLastError ();
|
||||
ASSERT (status == ERROR_FILE_NOT_FOUND);
|
||||
CloseHandle (fileHandle);
|
||||
}
|
||||
|
||||
void testCreateExistant (void)
|
||||
{
|
||||
DWORD status;
|
||||
HANDLE fileHandle;
|
||||
|
||||
printf ("before CreateFile (%s)\n", rootDir);
|
||||
fileHandle = CreateFile (rootDir, GENERIC_READ, 0, 0,
|
||||
CREATE_NEW, 0, 0);
|
||||
printf ("after CreateFile (%s)\n", rootDir);
|
||||
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
|
||||
status = GetLastError ();
|
||||
ASSERT (status == ERROR_ALREADY_EXISTS);
|
||||
printf ("before CreateFile (%s)\n", systemRootDir);
|
||||
fileHandle = CreateFile (systemRootDir, GENERIC_READ, 0, 0,
|
||||
CREATE_NEW, 0, 0);
|
||||
printf ("after CreateFile (%s)\n", rootDir);
|
||||
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
|
||||
status = GetLastError ();
|
||||
ASSERT (status == ERROR_ALREADY_EXISTS);
|
||||
printf ("before CreateFile (%s)\n", systemDllDir);
|
||||
fileHandle = CreateFile (systemDllDir, GENERIC_READ, 0, 0,
|
||||
CREATE_NEW, 0, 0);
|
||||
printf ("after CreateFile (%s)\n", rootDir);
|
||||
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
|
||||
status = GetLastError ();
|
||||
ASSERT (status == ERROR_ALREADY_EXISTS);
|
||||
}
|
||||
|
||||
void testCreateNonExistant (void)
|
||||
{
|
||||
DWORD status;
|
||||
HANDLE fileHandle;
|
||||
|
||||
fileHandle = CreateFile (bogusRootFile, GENERIC_READ, 0, 0,
|
||||
CREATE_NEW, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile (bogusSystemRootFile, GENERIC_READ, 0, 0,
|
||||
CREATE_NEW, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile (bogusSystemDllFile, GENERIC_READ, 0, 0,
|
||||
CREATE_NEW, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
|
||||
#if 0
|
||||
fileHandle = CreateFile (bogusDirAndFile, GENERIC_READ, 0, 0,
|
||||
CREATE_NEW, 0, 0);
|
||||
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
|
||||
status = GetLastError ();
|
||||
ASSERT (status == ERROR_PATH_NOT_FOUND);
|
||||
CloseHandle (fileHandle);
|
||||
#endif
|
||||
}
|
||||
|
||||
void testOpenWithBlankPathElements (void)
|
||||
{
|
||||
HANDLE fileHandle;
|
||||
|
||||
fileHandle = CreateFile ("c:", GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile ("c:\\\\", GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile ("c:\\\\reactos\\", GENERIC_READ, 0, 0,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile ("c:\\reactos\\\\", GENERIC_READ, 0, 0,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile ("c:\\reactos\\\\system32\\", GENERIC_READ, 0, 0,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
fileHandle = CreateFile ("c:\\reactos\\system32\\\\", GENERIC_READ, 0, 0,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
|
||||
CloseHandle (fileHandle);
|
||||
}
|
||||
|
||||
void doAssertion (BOOL pTest, PCHAR pTestText, PCHAR pFunction, int pLine)
|
||||
{
|
||||
assertions++;
|
||||
if (!pTest)
|
||||
{
|
||||
printf ("%s(%d): assertion \"%s\" failed", pFunction, pLine, pTestText);
|
||||
failures++;
|
||||
}
|
||||
else
|
||||
{
|
||||
successes++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,311 +0,0 @@
|
||||
/* Copyright (C) 1991, 92, 93, 95, 96, 97, 98 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef BSD
|
||||
#include </usr/include/stdio.h>
|
||||
#define EXIT_SUCCESS 0
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
|
||||
void rfg1 (void);
|
||||
void rfg2 (void);
|
||||
|
||||
|
||||
void
|
||||
fmtchk (const char *fmt)
|
||||
{
|
||||
(void) fputs(fmt, stdout);
|
||||
(void) printf(":\t`");
|
||||
(void) printf(fmt, 0x12);
|
||||
(void) printf("'\n");
|
||||
}
|
||||
|
||||
void
|
||||
fmtst1chk (const char *fmt)
|
||||
{
|
||||
(void) fputs(fmt, stdout);
|
||||
(void) printf(":\t`");
|
||||
(void) printf(fmt, 4, 0x12);
|
||||
(void) printf("'\n");
|
||||
}
|
||||
|
||||
void
|
||||
fmtst2chk (const char *fmt)
|
||||
{
|
||||
(void) fputs(fmt, stdout);
|
||||
(void) printf(":\t`");
|
||||
(void) printf(fmt, 4, 4, 0x12);
|
||||
(void) printf("'\n");
|
||||
}
|
||||
|
||||
/* This page is covered by the following copyright: */
|
||||
|
||||
/* (C) Copyright C E Chew
|
||||
*
|
||||
* Feel free to copy, use and distribute this software provided:
|
||||
*
|
||||
* 1. you do not pretend that you wrote it
|
||||
* 2. you leave this copyright notice intact.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans.
|
||||
*/
|
||||
|
||||
#define DEC -123
|
||||
#define INT 255
|
||||
#define UNS (~0)
|
||||
|
||||
/* Formatted Output Test
|
||||
*
|
||||
* This exercises the output formatting code.
|
||||
*/
|
||||
|
||||
void
|
||||
fp_test (void)
|
||||
{
|
||||
int i, j, k, l;
|
||||
char buf[7];
|
||||
char *prefix = buf;
|
||||
char tp[20];
|
||||
|
||||
puts("\nFormatted output test");
|
||||
printf("prefix 6d 6o 6x 6X 6u\n");
|
||||
strcpy(prefix, "%");
|
||||
for (i = 0; i < 2; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
for (k = 0; k < 2; k++) {
|
||||
for (l = 0; l < 2; l++) {
|
||||
strcpy(prefix, "%");
|
||||
if (i == 0) strcat(prefix, "-");
|
||||
if (j == 0) strcat(prefix, "+");
|
||||
if (k == 0) strcat(prefix, "#");
|
||||
if (l == 0) strcat(prefix, "0");
|
||||
printf("%5s |", prefix);
|
||||
strcpy(tp, prefix);
|
||||
strcat(tp, "6d |");
|
||||
printf(tp, DEC);
|
||||
strcpy(tp, prefix);
|
||||
strcat(tp, "6o |");
|
||||
printf(tp, INT);
|
||||
strcpy(tp, prefix);
|
||||
strcat(tp, "6x |");
|
||||
printf(tp, INT);
|
||||
strcpy(tp, prefix);
|
||||
strcat(tp, "6X |");
|
||||
printf(tp, INT);
|
||||
strcpy(tp, prefix);
|
||||
strcat(tp, "6u |");
|
||||
printf(tp, UNS);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%10s\n", (char *) NULL);
|
||||
printf("%-10s\n", (char *) NULL);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
static char shortstr[] = "Hi, Z.";
|
||||
static char longstr[] = "Good morning, Doctor Chandra. This is Hal. \
|
||||
I am ready for my first lesson today.";
|
||||
|
||||
fmtchk("%.4x");
|
||||
fmtchk("%04x");
|
||||
fmtchk("%4.4x");
|
||||
fmtchk("%04.4x");
|
||||
fmtchk("%4.3x");
|
||||
fmtchk("%04.3x");
|
||||
|
||||
fmtst1chk("%.*x");
|
||||
fmtst1chk("%0*x");
|
||||
fmtst2chk("%*.*x");
|
||||
fmtst2chk("%0*.*x");
|
||||
|
||||
#ifndef BSD
|
||||
printf("bad format:\t\"%b\"\n");
|
||||
printf("nil pointer (padded):\t\"%10p\"\n", (void *) NULL);
|
||||
#endif
|
||||
|
||||
printf("decimal negative:\t\"%d\"\n", -2345);
|
||||
printf("octal negative:\t\"%o\"\n", -2345);
|
||||
printf("hex negative:\t\"%x\"\n", -2345);
|
||||
printf("long decimal number:\t\"%ld\"\n", -123456L);
|
||||
printf("long octal negative:\t\"%lo\"\n", -2345L);
|
||||
printf("long unsigned decimal number:\t\"%lu\"\n", -123456L);
|
||||
printf("zero-padded LDN:\t\"%010ld\"\n", -123456L);
|
||||
printf("left-adjusted ZLDN:\t\"%-010ld\"\n", -123456);
|
||||
printf("space-padded LDN:\t\"%10ld\"\n", -123456L);
|
||||
printf("left-adjusted SLDN:\t\"%-10ld\"\n", -123456L);
|
||||
|
||||
printf("zero-padded string:\t\"%010s\"\n", shortstr);
|
||||
printf("left-adjusted Z string:\t\"%-010s\"\n", shortstr);
|
||||
printf("space-padded string:\t\"%10s\"\n", shortstr);
|
||||
printf("left-adjusted S string:\t\"%-10s\"\n", shortstr);
|
||||
printf("null string:\t\"%s\"\n", (char *)NULL);
|
||||
printf("limited string:\t\"%.22s\"\n", longstr);
|
||||
|
||||
printf("e-style >= 1:\t\"%e\"\n", 12.34);
|
||||
printf("e-style >= .1:\t\"%e\"\n", 0.1234);
|
||||
printf("e-style < .1:\t\"%e\"\n", 0.001234);
|
||||
printf("e-style big:\t\"%.60e\"\n", 1e20);
|
||||
printf ("e-style == .1:\t\"%e\"\n", 0.1);
|
||||
printf("f-style >= 1:\t\"%f\"\n", 12.34);
|
||||
printf("f-style >= .1:\t\"%f\"\n", 0.1234);
|
||||
printf("f-style < .1:\t\"%f\"\n", 0.001234);
|
||||
printf("g-style >= 1:\t\"%g\"\n", 12.34);
|
||||
printf("g-style >= .1:\t\"%g\"\n", 0.1234);
|
||||
printf("g-style < .1:\t\"%g\"\n", 0.001234);
|
||||
printf("g-style big:\t\"%.60g\"\n", 1e20);
|
||||
|
||||
printf (" %6.5f\n", .099999999860301614);
|
||||
printf (" %6.5f\n", .1);
|
||||
printf ("x%5.4fx\n", .5);
|
||||
|
||||
printf ("%#03x\n", 1);
|
||||
|
||||
{
|
||||
double d = FLT_MIN;
|
||||
int niter = 17;
|
||||
|
||||
while (niter-- != 0)
|
||||
printf ("%.17e\n", d / 2);
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
printf ("%15.5e\n", 4.9406564584124654e-324);
|
||||
|
||||
#define FORMAT "|%12.4f|%12.4e|%12.4g|\n"
|
||||
printf (FORMAT, 0.0, 0.0, 0.0);
|
||||
printf (FORMAT, 1.0, 1.0, 1.0);
|
||||
printf (FORMAT, -1.0, -1.0, -1.0);
|
||||
printf (FORMAT, 100.0, 100.0, 100.0);
|
||||
printf (FORMAT, 1000.0, 1000.0, 1000.0);
|
||||
printf (FORMAT, 10000.0, 10000.0, 10000.0);
|
||||
printf (FORMAT, 12345.0, 12345.0, 12345.0);
|
||||
printf (FORMAT, 100000.0, 100000.0, 100000.0);
|
||||
printf (FORMAT, 123456.0, 123456.0, 123456.0);
|
||||
#undef FORMAT
|
||||
|
||||
{
|
||||
char buf[20];
|
||||
printf ("sprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n",
|
||||
sprintf (buf, "%30s", "foo"), sizeof (buf), buf);
|
||||
}
|
||||
|
||||
fp_test ();
|
||||
|
||||
printf ("%e should be 1.234568e+06\n", 1234567.8);
|
||||
printf ("%f should be 1234567.800000\n", 1234567.8);
|
||||
printf ("%g should be 1.23457e+06\n", 1234567.8);
|
||||
printf ("%g should be 123.456\n", 123.456);
|
||||
printf ("%g should be 1e+06\n", 1000000.0);
|
||||
printf ("%g should be 10\n", 10.0);
|
||||
printf ("%g should be 0.02\n", 0.02);
|
||||
|
||||
{
|
||||
double x=1.0;
|
||||
printf("%.17f\n",(1.0/x/10.0+1.0)*x-x);
|
||||
}
|
||||
|
||||
puts ("--- Should be no further output. ---");
|
||||
rfg1 ();
|
||||
rfg2 ();
|
||||
|
||||
{
|
||||
char buf[200];
|
||||
int result;
|
||||
|
||||
sprintf(buf,"%*s%*s%*s",-1,"one",-20,"two",-30,"three");
|
||||
|
||||
result = strcmp (buf,
|
||||
"onetwo three ");
|
||||
|
||||
puts (result != 0 ? "Test failed!" : "Test ok.");
|
||||
return result != 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rfg1 (void)
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
sprintf (buf, "%5.s", "xyz");
|
||||
if (strcmp (buf, " ") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, " ");
|
||||
sprintf (buf, "%5.f", 33.3);
|
||||
if (strcmp (buf, " 33") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, " 33");
|
||||
sprintf (buf, "%8.e", 33.3e7);
|
||||
if (strcmp (buf, " 3e+08") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, " 3e+08");
|
||||
sprintf (buf, "%8.E", 33.3e7);
|
||||
if (strcmp (buf, " 3E+08") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, " 3E+08");
|
||||
sprintf (buf, "%.g", 33.3);
|
||||
if (strcmp (buf, "3e+01") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, "3e+01");
|
||||
sprintf (buf, "%.G", 33.3);
|
||||
if (strcmp (buf, "3E+01") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, "3E+01");
|
||||
}
|
||||
|
||||
void
|
||||
rfg2 (void)
|
||||
{
|
||||
int prec;
|
||||
char buf[100];
|
||||
|
||||
prec = 0;
|
||||
sprintf (buf, "%.*g", prec, 3.3);
|
||||
if (strcmp (buf, "3") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, "3");
|
||||
prec = 0;
|
||||
sprintf (buf, "%.*G", prec, 3.3);
|
||||
if (strcmp (buf, "3") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, "3");
|
||||
prec = 0;
|
||||
sprintf (buf, "%7.*G", prec, 3.33);
|
||||
if (strcmp (buf, " 3") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, " 3");
|
||||
prec = 3;
|
||||
sprintf (buf, "%04.*o", prec, 33);
|
||||
if (strcmp (buf, " 041") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, " 041");
|
||||
prec = 7;
|
||||
sprintf (buf, "%09.*u", prec, 33);
|
||||
if (strcmp (buf, " 0000033") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, " 0000033");
|
||||
prec = 3;
|
||||
sprintf (buf, "%04.*x", prec, 33);
|
||||
if (strcmp (buf, " 021") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, " 021");
|
||||
prec = 3;
|
||||
sprintf (buf, "%04.*X", prec, 33);
|
||||
if (strcmp (buf, " 021") != 0)
|
||||
printf ("got: '%s', expected: '%s'\n", buf, " 021");
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
t1 (void)
|
||||
{
|
||||
int n = -1;
|
||||
sscanf ("abc ", "abc %n", &n);
|
||||
printf ("t1: count=%d\n", n);
|
||||
|
||||
return n != 5;
|
||||
}
|
||||
|
||||
int
|
||||
t2 (void)
|
||||
{
|
||||
int result = 0;
|
||||
int n;
|
||||
long N;
|
||||
int retval;
|
||||
#define SCAN(INPUT, FORMAT, VAR, EXP_RES, EXP_VAL) \
|
||||
VAR = -1; \
|
||||
retval = sscanf (INPUT, FORMAT, &VAR); \
|
||||
printf ("sscanf (\"%s\", \"%s\", &x) => %d, x = %ld\n", \
|
||||
INPUT, FORMAT, retval, (long int) VAR); \
|
||||
result |= retval != EXP_RES || VAR != EXP_VAL
|
||||
|
||||
SCAN ("12345", "%ld", N, 1, 12345);
|
||||
SCAN ("12345", "%llllld", N, 0, -1);
|
||||
SCAN ("12345", "%LLLLLd", N, 0, -1);
|
||||
SCAN ("test ", "%*s%n", n, 0, 4);
|
||||
SCAN ("test ", "%2*s%n", n, 0, -1);
|
||||
SCAN ("12 ", "%l2d", n, 0, -1);
|
||||
SCAN ("12 ", "%2ld", N, 1, 12);
|
||||
|
||||
n = -1;
|
||||
N = -1;
|
||||
retval = sscanf ("1 1", "%d %Z", &n, &N);
|
||||
printf ("sscanf (\"1 1\", \"%%d %%Z\", &n, &N) => %d, n = %d, N = %ld\n", \
|
||||
retval, n, N); \
|
||||
result |= retval != 1 || n != 1 || N != -1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
result |= t1 ();
|
||||
result |= t2 ();
|
||||
|
||||
result |= fflush (stdout) == EOF;
|
||||
|
||||
return result;
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
PROGS = thread
|
||||
|
||||
all: $(PROGS:%=%.exe)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean: $(PROGS:%=%_clean)
|
||||
|
||||
$(PROGS:%=%_clean): %_clean:
|
||||
- $(RM) $*.o
|
||||
- $(RM) $*.exe
|
||||
- $(RM) $*.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: # $(PROGS:%=$(FLOPPY_DIR)/apps/%.exe)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%.exe): $(FLOPPY_DIR)/apps/%.exe: %.exe
|
||||
$(CP) $*.exe $(FLOPPY_DIR)/apps/$*.exe
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%.exe)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%.exe): ../../$(DIST_DIR)/apps/%.exe: %.exe
|
||||
$(CP) $*.exe ../../$(DIST_DIR)/apps/$*.exe
|
||||
|
||||
thread.exe: thread.c
|
||||
$(CC) $(CFLAGS) thread.c -lkernel32 -o thread.exe
|
||||
$(NM) --numeric-sort thread.exe > thread.sym
|
||||
|
||||
include ../../rules.mak
|
@@ -1,75 +0,0 @@
|
||||
/* $Id: thread.c,v 1.7 2001/02/06 00:11:17 dwelch Exp $
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define NR_THREADS (10)
|
||||
|
||||
ULONG nr;
|
||||
|
||||
DWORD WINAPI thread_main1(LPVOID param)
|
||||
{
|
||||
ULONG s;
|
||||
|
||||
printf("Thread %ld running\n", (DWORD)param);
|
||||
s = nr = ((nr * 1103515245) + 12345) & 0x7fffffff;
|
||||
s = s % 10;
|
||||
printf("s %ld\n", s);
|
||||
Sleep(s);
|
||||
printf("Thread %ld finished\n", (DWORD)param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Shows the help on how to use these program to the user
|
||||
void showHelp(void)
|
||||
{
|
||||
|
||||
printf("\nReactOS threads test program (built on %s).\n\n", __DATE__);
|
||||
printf("syntax:\tthread.exe <seed>\n");
|
||||
printf("\twhere <seed> is an integer number\n");
|
||||
printf("\texample: thread.exe 100\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
HANDLE hThread;
|
||||
DWORD i=0;
|
||||
DWORD id;
|
||||
ULONG nr;
|
||||
|
||||
|
||||
// The user must supply one argument (the seed). if he/she doesn't
|
||||
// then we show the help.
|
||||
// if(argc < 2) {
|
||||
// showHelp();
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
// nr = atoi(argv[1]);
|
||||
nr = 500;
|
||||
printf("Seed %ld\n", nr);
|
||||
|
||||
printf("Creating %d threads...\n",NR_THREADS*2);
|
||||
for (i=0;i<NR_THREADS;i++)
|
||||
{
|
||||
CreateThread(NULL,
|
||||
0,
|
||||
thread_main1,
|
||||
(LPVOID)i,
|
||||
0,
|
||||
&id);
|
||||
|
||||
}
|
||||
|
||||
printf("All threads created...\n");
|
||||
for(;;);
|
||||
return 0;
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
OBJECTS = vmtest.o
|
||||
PROGS = vmtest.exe
|
||||
LIBS =
|
||||
CLEAN_FILES = vmtest.o vmtest.exe
|
||||
|
||||
all: vmtest.exe
|
||||
|
||||
clean: $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
$(CLEAN_FILES:%=%_clean): %_clean:
|
||||
- $(RM) $*
|
||||
|
||||
.phony: clean $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
floppy: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
|
||||
vmtest.exe: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -o vmtest.exe
|
||||
|
||||
include ../../rules.mak
|
@@ -1,54 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
PVOID Base;
|
||||
PVOID Ret;
|
||||
|
||||
Base = VirtualAlloc(NULL,
|
||||
1048576,
|
||||
MEM_RESERVE,
|
||||
PAGE_READWRITE);
|
||||
if (Base == NULL)
|
||||
{
|
||||
printf("VirtualAlloc failed 1\n");
|
||||
}
|
||||
|
||||
Ret = VirtualAlloc(Base + 4096,
|
||||
4096,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
if (Ret == NULL)
|
||||
{
|
||||
printf("VirtualAlloc failed 2\n");
|
||||
}
|
||||
|
||||
Ret = VirtualAlloc(Base + 12288,
|
||||
4096,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
if (Ret == NULL)
|
||||
{
|
||||
printf("VirtualAlloc failed 3\n");
|
||||
}
|
||||
|
||||
Ret = VirtualAlloc(Base + 20480,
|
||||
4096,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
if (Ret == NULL)
|
||||
{
|
||||
printf("VirtualAlloc failed 4\n");
|
||||
}
|
||||
|
||||
Ret = VirtualAlloc(Base + 4096,
|
||||
28672,
|
||||
MEM_RESERVE,
|
||||
PAGE_READWRITE);
|
||||
if (Ret == NULL)
|
||||
{
|
||||
printf("VirtualAlloc failed 5\n");
|
||||
}
|
||||
}
|
||||
|
@@ -1,2 +0,0 @@
|
||||
buildno
|
||||
buildno.exe
|
@@ -1,28 +0,0 @@
|
||||
# $Id: Makefile,v 1.9 2001/04/11 22:13:21 dwelch Exp $
|
||||
#
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
BASE_CFLAGS =
|
||||
TARGETNAME=buildno
|
||||
CLEAN_FILES= $(TARGETNAME).o $(TARGETNAME)$(EXE_POSTFIX) $(TARGETNAME).sym
|
||||
|
||||
all: $(TARGETNAME)$(EXE_POSTFIX)
|
||||
$(EXE_PREFIX)$(TARGETNAME)$(EXE_POSTFIX)
|
||||
|
||||
|
||||
$(TARGETNAME)$(EXE_POSTFIX): $(TARGETNAME).c ../../include/reactos/version.h
|
||||
$(HOST_CC) -g -o $(TARGETNAME)$(EXE_POSTFIX) $(TARGETNAME).c
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
- $(RM) $(TARGETNAME).o
|
||||
- $(RM) $(TARGETNAME).sym
|
||||
- $(RM) $(TARGETNAME)$(EXE_POSTFIX)
|
||||
|
||||
.phony: clean
|
||||
|
||||
include ../../rules.mak
|
||||
|
||||
# EOF
|
@@ -1,329 +0,0 @@
|
||||
/* $Id: buildno.c,v 1.6 2001/04/11 22:13:21 dwelch Exp $
|
||||
*
|
||||
* buildno - Generate the build number for ReactOS
|
||||
*
|
||||
* Copyright (c) 1999,2000 Emanuele Aliberti
|
||||
*
|
||||
* License: GNU GPL
|
||||
*
|
||||
* It assumes the last release date is defined in
|
||||
* <reactos/version.h> as a macro named
|
||||
*
|
||||
* KERNEL_RELEASE_DATE
|
||||
*
|
||||
* as a 32-bit unsigned long YYYYMMDD (UTC;
|
||||
* MM=01-12; DD=01-31).
|
||||
*
|
||||
* The build number is the number of full days
|
||||
* elapsed since the last release date (UTC).
|
||||
*
|
||||
* The build number is stored in the file
|
||||
* <reactos/buildno.h> as a set of macros:
|
||||
*
|
||||
* KERNEL_VERSION_BUILD base 10 number
|
||||
* KERNEL_VERSION_BUILD_STR C string
|
||||
* KERNEL_VERSION_BUILD_RC RC string
|
||||
*
|
||||
* REVISIONS
|
||||
* ---------
|
||||
* 2000-01-22 (ea)
|
||||
* Fixed bugs: tm_year is (current_year - 1900),
|
||||
* tm_month is 0-11 not 1-12 and code ignored TZ.
|
||||
* 2000-12-10 (ea)
|
||||
* Added -p option to make it simply print the
|
||||
* version number, but skip buildno.h generation.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "../../include/reactos/version.h"
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
/* File to (over)write */
|
||||
#define BUILDNO_INCLUDE_FILE "../../include/reactos/buildno.h"
|
||||
|
||||
static char * argv0 = "";
|
||||
|
||||
#ifdef DBG
|
||||
void
|
||||
tm_dump (const char *tag, struct tm * t)
|
||||
{
|
||||
printf ("%s->tm_sec = %d\n", tag, t->tm_sec);
|
||||
printf ("%s->tm_min = %d\n", tag, t->tm_min);
|
||||
printf ("%s->tm_hour = %d\n", tag, t->tm_hour);
|
||||
printf ("%s->tm_mday = %d\n", tag, t->tm_mday);
|
||||
printf ("%s->tm_mon = %d\n", tag, t->tm_mon);
|
||||
printf ("%s->tm_year = %d\n", tag, t->tm_year);
|
||||
printf ("%s->tm_wday = %d\n", tag, t->tm_wday);
|
||||
printf ("%s->tm_yday = %d\n", tag, t->tm_yday);
|
||||
printf ("%s->tm_isdst = %d\n\n", tag, t->tm_isdst);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
elapsed_days (
|
||||
time_t t_today,
|
||||
time_t t_release_day
|
||||
)
|
||||
{
|
||||
double seconds = difftime (t_today, t_release_day);
|
||||
double days = seconds / (double) 86400.0;
|
||||
char buf [32];
|
||||
char * dot = buf;
|
||||
|
||||
sprintf (buf, "%f", days );
|
||||
|
||||
while ( *dot && *dot != '.') ++dot;
|
||||
*dot = '\0';
|
||||
|
||||
return atol (buf);
|
||||
}
|
||||
|
||||
void
|
||||
write_h (int build)
|
||||
{
|
||||
FILE *h = NULL;
|
||||
char* s;
|
||||
char* s1;
|
||||
int length;
|
||||
|
||||
s1 = s = malloc(256 * 1024);
|
||||
|
||||
s = s + sprintf (s, "/* Do not edit - Machine generated */\n");
|
||||
|
||||
s = s + sprintf (s, "#ifndef _INC_REACTOS_BUILDNO\n" );
|
||||
s = s + sprintf (s, "#define _INC_REACTOS_BUILDNO\n" );
|
||||
|
||||
s = s + sprintf (s, "#define KERNEL_VERSION_BUILD\t%d\n", build);
|
||||
s = s + sprintf (s, "#define KERNEL_VERSION_BUILD_STR\t\"%d\"\n", build);
|
||||
s = s + sprintf (s, "#define KERNEL_RELEASE_RC\t\"%d.%d.%d.%d\\0\"\n",
|
||||
KERNEL_VERSION_MAJOR, KERNEL_VERSION_MINOR,
|
||||
KERNEL_VERSION_PATCH_LEVEL, build);
|
||||
s = s + sprintf (s, "#define KERNEL_RELEASE_STR\t\"%d.%d.%d.%d\"\n",
|
||||
KERNEL_VERSION_MAJOR,
|
||||
KERNEL_VERSION_MINOR,
|
||||
KERNEL_VERSION_PATCH_LEVEL,
|
||||
build);
|
||||
s = s + sprintf (s, "#define KERNEL_VERSION_RC\t\"%d.%d.%d\\0\"\n",
|
||||
KERNEL_VERSION_MAJOR,
|
||||
KERNEL_VERSION_MINOR,
|
||||
KERNEL_VERSION_PATCH_LEVEL);
|
||||
s = s + sprintf (s, "#define KERNEL_VERSION_STR\t\"%d.%d.%d\"\n",
|
||||
KERNEL_VERSION_MAJOR,
|
||||
KERNEL_VERSION_MINOR,
|
||||
KERNEL_VERSION_PATCH_LEVEL);
|
||||
s = s + sprintf (s, "#endif\n/* EOF */\n");
|
||||
|
||||
h = fopen (BUILDNO_INCLUDE_FILE, "r");
|
||||
if (h != NULL)
|
||||
{
|
||||
fseek(h, 0, SEEK_END);
|
||||
length = ftell(h);
|
||||
if (length == strlen(s1))
|
||||
{
|
||||
char* orig;
|
||||
|
||||
orig = malloc(length);
|
||||
fseek(h, 0, SEEK_SET);
|
||||
fread(orig, 1, length, h);
|
||||
if (memcmp(s1, orig, length) == 0)
|
||||
{
|
||||
fclose(h);
|
||||
return;
|
||||
}
|
||||
}
|
||||
fclose(h);
|
||||
}
|
||||
|
||||
h = fopen (BUILDNO_INCLUDE_FILE, "w");
|
||||
if (!h)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: can not create file \"%s\"!\n",
|
||||
argv0,
|
||||
BUILDNO_INCLUDE_FILE);
|
||||
return;
|
||||
}
|
||||
fwrite(s1, 1, strlen(s1), h);
|
||||
fclose (h);
|
||||
}
|
||||
|
||||
void
|
||||
usage (void)
|
||||
{
|
||||
fprintf (
|
||||
stderr,
|
||||
"Usage: %s [-{p|q}]\n\n -p print version number and exit\n -q run in quiet mode\n",
|
||||
argv0
|
||||
);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
{
|
||||
int print_only = FALSE;
|
||||
int quiet = FALSE;
|
||||
|
||||
int year = 0;
|
||||
int month = 0;
|
||||
int day = 0;
|
||||
int build = 0;
|
||||
|
||||
time_t t0 = 0;
|
||||
struct tm t0_tm = {0};
|
||||
time_t t1 = 0;
|
||||
struct tm * t1_tm = NULL;
|
||||
|
||||
argv0 = argv[0];
|
||||
|
||||
switch (argc)
|
||||
{
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
if (argv[1][0] == '-')
|
||||
{
|
||||
if (argv[1][1] == 'q')
|
||||
{
|
||||
quiet = TRUE;
|
||||
}
|
||||
else if (argv[1][1] == 'p')
|
||||
{
|
||||
print_only = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
usage ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
usage ();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage ();
|
||||
}
|
||||
/*
|
||||
* Set TZ information.
|
||||
*/
|
||||
tzset ();
|
||||
/*
|
||||
* We are building TODAY!
|
||||
*/
|
||||
time (& t0);
|
||||
/*
|
||||
* "Parse" the release date.
|
||||
*/
|
||||
day = KERNEL_RELEASE_DATE % 100;
|
||||
month = ( ( KERNEL_RELEASE_DATE
|
||||
% 10000
|
||||
)
|
||||
- day
|
||||
)
|
||||
/ 100;
|
||||
year =
|
||||
( KERNEL_RELEASE_DATE
|
||||
- (month * 100)
|
||||
- day
|
||||
)
|
||||
/ 10000;
|
||||
if (FALSE == quiet)
|
||||
{
|
||||
printf ( "\n\
|
||||
ReactOS Build Number Generator\n\n\
|
||||
Last release: %4d-%02d-%02d\n",
|
||||
year,
|
||||
month,
|
||||
day
|
||||
);
|
||||
}
|
||||
#ifdef DBG
|
||||
tm_dump ("t0", & t0_tm);
|
||||
#endif
|
||||
t0_tm.tm_year = (year - 1900);
|
||||
t0_tm.tm_mon = --month; /* 0-11 */
|
||||
t0_tm.tm_mday = day;
|
||||
t0_tm.tm_hour = 0;
|
||||
t0_tm.tm_min = 0;
|
||||
t0_tm.tm_sec = 1;
|
||||
t0_tm.tm_isdst = -1;
|
||||
|
||||
#ifdef DBG
|
||||
tm_dump ("t0", & t0_tm);
|
||||
#endif
|
||||
|
||||
if (-1 == (t0 = mktime (& t0_tm)))
|
||||
{
|
||||
fprintf (
|
||||
stderr,
|
||||
"%s: can not convert release date!\n",
|
||||
argv[0]
|
||||
);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
time (& t1); /* current build time */
|
||||
t1_tm = gmtime (& t1);
|
||||
|
||||
#ifdef DBG
|
||||
tm_dump ("t1", t1_tm);
|
||||
#endif
|
||||
t1_tm->tm_year +=
|
||||
(t1_tm->tm_year < 70)
|
||||
? 2000
|
||||
: 1900;
|
||||
#ifdef DBG
|
||||
tm_dump ("t1", t1_tm);
|
||||
#endif
|
||||
if (FALSE == quiet)
|
||||
{
|
||||
printf (
|
||||
"Current date: %4d-%02d-%02d\n\n",
|
||||
t1_tm->tm_year,
|
||||
(t1_tm->tm_mon + 1),
|
||||
t1_tm->tm_mday
|
||||
);
|
||||
}
|
||||
/*
|
||||
* Compute delta days.
|
||||
*/
|
||||
build = elapsed_days (t1, t0);
|
||||
|
||||
if (FALSE == quiet)
|
||||
{
|
||||
printf (
|
||||
"Build number: %d (elapsed days since last release)\n",
|
||||
build
|
||||
);
|
||||
printf (
|
||||
"ROS Version : %d.%d.%d.%d\n",
|
||||
KERNEL_VERSION_MAJOR,
|
||||
KERNEL_VERSION_MINOR,
|
||||
KERNEL_VERSION_PATCH_LEVEL,
|
||||
build
|
||||
);
|
||||
}
|
||||
/*
|
||||
* (Over)write the include file, unless
|
||||
* the user switched on -p.
|
||||
*/
|
||||
if (FALSE == print_only)
|
||||
{
|
||||
write_h (build);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("%s: no code generated", argv [0]);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
File diff suppressed because it is too large
Load Diff
@@ -1,431 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS cabinet manager
|
||||
* FILE: apps/cabman/cabinet.h
|
||||
* PURPOSE: Cabinet definitions
|
||||
*/
|
||||
#ifndef __CABINET_H
|
||||
#define __CABINET_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Debugging */
|
||||
|
||||
#define DBG
|
||||
|
||||
#define NORMAL_MASK 0x000000FF
|
||||
#define SPECIAL_MASK 0xFFFFFF00
|
||||
#define MIN_TRACE 0x00000001
|
||||
#define MID_TRACE 0x00000002
|
||||
#define MAX_TRACE 0x00000003
|
||||
|
||||
#define DEBUG_MEMORY 0x00000100
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
extern DWORD DebugTraceLevel;
|
||||
|
||||
#define DPRINT(_t_, _x_) \
|
||||
if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
|
||||
((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
|
||||
printf("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
|
||||
printf _x_ ; \
|
||||
}
|
||||
|
||||
#define ASSERT(_b_) { \
|
||||
if (!(_b_)) { \
|
||||
printf("(%s:%d)(%s) ASSERTION: ", __FILE__, __LINE__, __FUNCTION__); \
|
||||
printf(#_b_); \
|
||||
ExitProcess(0); \
|
||||
} \
|
||||
}
|
||||
|
||||
#else /* DBG */
|
||||
|
||||
#define DPRINT(_t_, _x_)
|
||||
|
||||
#define ASSERT(_x_)
|
||||
|
||||
#endif /* DBG */
|
||||
|
||||
|
||||
/* Macros */
|
||||
|
||||
#ifndef CopyMemory
|
||||
#define CopyMemory(destination, source, length) memcpy(destination, source, length)
|
||||
#endif /* CopyMemory */
|
||||
|
||||
/* Cabinet constants */
|
||||
|
||||
#define CAB_SIGNATURE 0x4643534D // "MSCF"
|
||||
#define CAB_VERSION 0x0103
|
||||
#define CAB_BLOCKSIZE 32768
|
||||
|
||||
#define CAB_COMP_MASK 0x00FF
|
||||
#define CAB_COMP_NONE 0x0000
|
||||
#define CAB_COMP_MSZIP 0x0001
|
||||
#define CAB_COMP_QUANTUM 0x0002
|
||||
#define CAB_COMP_LZX 0x0003
|
||||
|
||||
#define CAB_FLAG_HASPREV 0x0001
|
||||
#define CAB_FLAG_HASNEXT 0x0002
|
||||
#define CAB_FLAG_RESERVE 0x0004
|
||||
|
||||
#define CAB_ATTRIB_READONLY 0x0001
|
||||
#define CAB_ATTRIB_HIDDEN 0x0002
|
||||
#define CAB_ATTRIB_SYSTEM 0x0004
|
||||
#define CAB_ATTRIB_VOLUME 0x0008
|
||||
#define CAB_ATTRIB_DIRECTORY 0x0010
|
||||
#define CAB_ATTRIB_ARCHIVE 0x0020
|
||||
#define CAB_ATTRIB_EXECUTE 0x0040
|
||||
#define CAB_ATTRIB_UTF_NAME 0x0080
|
||||
|
||||
#define CAB_FILE_MAX_FOLDER 0xFFFC
|
||||
#define CAB_FILE_CONTINUED 0xFFFD
|
||||
#define CAB_FILE_SPLIT 0xFFFE
|
||||
#define CAB_FILE_PREV_NEXT 0xFFFF
|
||||
|
||||
|
||||
/* Cabinet structures */
|
||||
|
||||
typedef struct _CFHEADER
|
||||
{
|
||||
DWORD Signature; // File signature 'MSCF' (CAB_SIGNATURE)
|
||||
DWORD Reserved1; // Reserved field
|
||||
DWORD CabinetSize; // Cabinet file size
|
||||
DWORD Reserved2; // Reserved field
|
||||
DWORD FileTableOffset; // Offset of first CFFILE
|
||||
DWORD Reserved3; // Reserved field
|
||||
WORD Version; // Cabinet version (CAB_VERSION)
|
||||
WORD FolderCount; // Number of folders
|
||||
WORD FileCount; // Number of files
|
||||
WORD Flags; // Cabinet flags (CAB_FLAG_*)
|
||||
WORD SetID; // Cabinet set id
|
||||
WORD CabinetNumber; // Zero-based cabinet number
|
||||
/* Optional fields (depends on Flags)
|
||||
WORD CabinetResSize // Per-cabinet reserved area size
|
||||
CHAR FolderResSize // Per-folder reserved area size
|
||||
CHAR FileResSize // Per-file reserved area size
|
||||
CHAR CabinetReserved[] // Per-cabinet reserved area
|
||||
CHAR CabinetPrev[] // Name of previous cabinet file
|
||||
CHAR DiskPrev[] // Name of previous disk
|
||||
CHAR CabinetNext[] // Name of next cabinet file
|
||||
CHAR DiskNext[] // Name of next disk
|
||||
*/
|
||||
} CFHEADER, *PCFHEADER;
|
||||
|
||||
|
||||
typedef struct _CFFOLDER
|
||||
{
|
||||
DWORD DataOffset; // Absolute offset of first CFDATA block in this folder
|
||||
WORD DataBlockCount; // Number of CFDATA blocks in this folder in this cabinet
|
||||
WORD CompressionType; // Type of compression used for all CFDATA blocks in this folder
|
||||
/* Optional fields (depends on Flags)
|
||||
CHAR FolderReserved[] // Per-folder reserved area
|
||||
*/
|
||||
} CFFOLDER, *PCFFOLDER;
|
||||
|
||||
|
||||
typedef struct _CFFILE
|
||||
{
|
||||
DWORD FileSize; // Uncompressed file size in bytes
|
||||
DWORD FileOffset; // Uncompressed offset of file in the folder
|
||||
WORD FileControlID; // File control ID (CAB_FILE_*)
|
||||
WORD FileDate; // File date stamp, as used by DOS
|
||||
WORD FileTime; // File time stamp, as used by DOS
|
||||
WORD Attributes; // File attributes (CAB_ATTRIB_*)
|
||||
/* After this is the NULL terminated filename */
|
||||
} CFFILE, *PCFFILE;
|
||||
|
||||
|
||||
typedef struct _CFDATA
|
||||
{
|
||||
DWORD Checksum; // Checksum of CFDATA entry
|
||||
WORD CompSize; // Number of compressed bytes in this block
|
||||
WORD UncompSize; // Number of uncompressed bytes in this block
|
||||
/* Optional fields (depends on Flags)
|
||||
CHAR DataReserved[] // Per-datablock reserved area
|
||||
*/
|
||||
} CFDATA, *PCFDATA;
|
||||
|
||||
typedef struct _CFDATA_NODE
|
||||
{
|
||||
struct _CFDATA_NODE *Next;
|
||||
struct _CFDATA_NODE *Prev;
|
||||
DWORD ScratchFilePosition; // Absolute offset in scratch file
|
||||
DWORD AbsoluteOffset; // Absolute offset in cabinet
|
||||
DWORD UncompOffset; // Uncompressed offset in folder
|
||||
CFDATA Data;
|
||||
} CFDATA_NODE, *PCFDATA_NODE;
|
||||
|
||||
typedef struct _CFFOLDER_NODE
|
||||
{
|
||||
struct _CFFOLDER_NODE *Next;
|
||||
struct _CFFOLDER_NODE *Prev;
|
||||
DWORD UncompOffset; // File size accumulator
|
||||
DWORD AbsoluteOffset;
|
||||
DWORD TotalFolderSize; // Total size of folder in current disk
|
||||
PCFDATA_NODE DataListHead;
|
||||
PCFDATA_NODE DataListTail;
|
||||
DWORD Index;
|
||||
BOOL Commit; // TRUE if the folder should be committed
|
||||
BOOL Delete; // TRUE if marked for deletion
|
||||
CFFOLDER Folder;
|
||||
} CFFOLDER_NODE, *PCFFOLDER_NODE;
|
||||
|
||||
typedef struct _CFFILE_NODE
|
||||
{
|
||||
struct _CFFILE_NODE *Next;
|
||||
struct _CFFILE_NODE *Prev;
|
||||
CFFILE File;
|
||||
LPTSTR FileName;
|
||||
PCFDATA_NODE DataBlock; // First data block of file. NULL if not known
|
||||
BOOL Commit; // TRUE if the file data should be committed
|
||||
BOOL Delete; // TRUE if marked for deletion
|
||||
PCFFOLDER_NODE FolderNode; // Folder this file belong to
|
||||
} CFFILE_NODE, *PCFFILE_NODE;
|
||||
|
||||
|
||||
typedef struct _CAB_SEARCH
|
||||
{
|
||||
TCHAR Search[MAX_PATH]; // Search criteria
|
||||
PCFFILE_NODE Next; // Pointer to next node
|
||||
PCFFILE File; // Pointer to current CFFILE
|
||||
LPTSTR FileName; // Current filename
|
||||
} CAB_SEARCH, *PCAB_SEARCH;
|
||||
|
||||
|
||||
/* Constants */
|
||||
|
||||
/* Status codes */
|
||||
#define CAB_STATUS_SUCCESS 0x00000000
|
||||
#define CAB_STATUS_FAILURE 0x00000001
|
||||
#define CAB_STATUS_NOMEMORY 0x00000002
|
||||
#define CAB_STATUS_CANNOT_OPEN 0x00000003
|
||||
#define CAB_STATUS_CANNOT_CREATE 0x00000004
|
||||
#define CAB_STATUS_CANNOT_READ 0x00000005
|
||||
#define CAB_STATUS_CANNOT_WRITE 0x00000006
|
||||
#define CAB_STATUS_FILE_EXISTS 0x00000007
|
||||
#define CAB_STATUS_INVALID_CAB 0x00000008
|
||||
#define CAB_STATUS_NOFILE 0x00000009
|
||||
#define CAB_STATUS_UNSUPPCOMP 0x0000000A
|
||||
|
||||
|
||||
|
||||
/* Codecs */
|
||||
|
||||
class CCABCodec {
|
||||
public:
|
||||
/* Default constructor */
|
||||
CCABCodec() {};
|
||||
/* Default destructor */
|
||||
virtual ~CCABCodec() {};
|
||||
/* Compresses a data block */
|
||||
virtual ULONG Compress(PVOID OutputBuffer,
|
||||
PVOID InputBuffer,
|
||||
DWORD InputLength,
|
||||
PDWORD OutputLength) = 0;
|
||||
/* Uncompresses a data block */
|
||||
virtual ULONG Uncompress(PVOID OutputBuffer,
|
||||
PVOID InputBuffer,
|
||||
DWORD InputLength,
|
||||
PDWORD OutputLength) = 0;
|
||||
};
|
||||
|
||||
|
||||
/* Codec status codes */
|
||||
#define CS_SUCCESS 0x0000 /* All data consumed */
|
||||
#define CS_NOMEMORY 0x0001 /* Not enough free memory */
|
||||
#define CS_BADSTREAM 0x0002 /* Bad data stream */
|
||||
|
||||
|
||||
/* Codec indentifiers */
|
||||
#define CAB_CODEC_RAW 0x00
|
||||
#define CAB_CODEC_LZX 0x01
|
||||
#define CAB_CODEC_MSZIP 0x02
|
||||
|
||||
|
||||
|
||||
/* Classes */
|
||||
|
||||
#ifndef CAB_READ_ONLY
|
||||
|
||||
class CCFDATAStorage {
|
||||
public:
|
||||
/* Default constructor */
|
||||
CCFDATAStorage();
|
||||
/* Default destructor */
|
||||
virtual ~CCFDATAStorage();
|
||||
ULONG Create(LPTSTR FileName);
|
||||
ULONG Destroy();
|
||||
ULONG Truncate();
|
||||
ULONG Position();
|
||||
ULONG Seek(LONG Position);
|
||||
ULONG ReadBlock(PCFDATA Data, PVOID Buffer, PDWORD BytesRead);
|
||||
ULONG WriteBlock(PCFDATA Data, PVOID Buffer, PDWORD BytesWritten);
|
||||
private:
|
||||
BOOL FileCreated;
|
||||
HANDLE FileHandle;
|
||||
};
|
||||
|
||||
#endif /* CAB_READ_ONLY */
|
||||
|
||||
class CCabinet {
|
||||
public:
|
||||
/* Default constructor */
|
||||
CCabinet();
|
||||
/* Default destructor */
|
||||
virtual ~CCabinet();
|
||||
/* Returns a pointer to the filename part of a fully qualified filename */
|
||||
LPTSTR GetFileName(LPTSTR Path);
|
||||
/* Removes a filename from a fully qualified filename */
|
||||
VOID RemoveFileName(LPTSTR Path);
|
||||
/* Normalizes a path */
|
||||
BOOL NormalizePath(LPTSTR Path, DWORD Length);
|
||||
/* Returns name of cabinet file */
|
||||
LPTSTR GetCabinetName();
|
||||
/* Sets the name of the cabinet file */
|
||||
VOID SetCabinetName(LPTSTR FileName);
|
||||
/* Sets destination path for extracted files */
|
||||
VOID SetDestinationPath(LPTSTR DestinationPath);
|
||||
/* Returns destination path */
|
||||
LPTSTR GetDestinationPath();
|
||||
/* Returns zero-based current disk number */
|
||||
DWORD GetCurrentDiskNumber();
|
||||
/* Opens the current cabinet file */
|
||||
ULONG Open();
|
||||
/* Closes the current open cabinet file */
|
||||
VOID Close();
|
||||
/* Locates the first file in the current cabinet file that matches a search criteria */
|
||||
ULONG FindFirst(LPTSTR FileName, PCAB_SEARCH Search);
|
||||
/* Locates the next file in the current cabinet file */
|
||||
ULONG FindNext(PCAB_SEARCH Search);
|
||||
/* Extracts a file from the current cabinet file */
|
||||
ULONG ExtractFile(LPTSTR FileName);
|
||||
/* Select codec engine to use */
|
||||
VOID SelectCodec(ULONG Id);
|
||||
#ifndef CAB_READ_ONLY
|
||||
/* Creates a new cabinet file */
|
||||
ULONG NewCabinet();
|
||||
/* Forces a new disk to be created */
|
||||
ULONG NewDisk();
|
||||
/* Forces a new folder to be created */
|
||||
ULONG NewFolder();
|
||||
/* Writes a file to scratch storage */
|
||||
ULONG WriteFileToScratchStorage(PCFFILE_NODE FileNode);
|
||||
/* Forces the current disk to be written */
|
||||
ULONG WriteDisk(DWORD MoreDisks);
|
||||
/* Commits the current disk */
|
||||
ULONG CommitDisk(DWORD MoreDisks);
|
||||
/* Closes the current disk */
|
||||
ULONG CloseDisk();
|
||||
/* Closes the current cabinet */
|
||||
ULONG CloseCabinet();
|
||||
/* Adds a file to the current disk */
|
||||
ULONG AddFile(LPTSTR FileName);
|
||||
/* Sets the maximum size of the current disk */
|
||||
VOID SetMaxDiskSize(DWORD Size);
|
||||
#endif /* CAB_READ_ONLY */
|
||||
|
||||
/* Default event handlers */
|
||||
|
||||
/* Handler called when a file is about to be overridden */
|
||||
virtual BOOL OnOverwrite(PCFFILE Entry, LPTSTR FileName);
|
||||
/* Handler called when a file is about to be extracted */
|
||||
virtual VOID OnExtract(PCFFILE Entry, LPTSTR FileName);
|
||||
/* Handler called when a new disk is to be processed */
|
||||
virtual VOID OnDiskChange(LPTSTR CabinetName, LPTSTR DiskLabel);
|
||||
#ifndef CAB_READ_ONLY
|
||||
/* Handler called when a file is about to be added */
|
||||
virtual VOID OnAdd(PCFFILE Entry, LPTSTR FileName);
|
||||
/* Handler called when a cabinet need a name */
|
||||
virtual BOOL OnCabinetName(ULONG Number, LPTSTR Name);
|
||||
/* Handler called when a disk needs a label */
|
||||
virtual BOOL OnDiskLabel(ULONG Number, LPTSTR Label);
|
||||
#endif /* CAB_READ_ONLY */
|
||||
private:
|
||||
PCFFOLDER_NODE LocateFolderNode(DWORD Index);
|
||||
ULONG GetAbsoluteOffset(PCFFILE_NODE File);
|
||||
ULONG LocateFile(LPTSTR FileName, PCFFILE_NODE *File);
|
||||
ULONG ReadString(LPTSTR String, DWORD MaxLength);
|
||||
ULONG ReadFileTable();
|
||||
ULONG ReadDataBlocks(PCFFOLDER_NODE FolderNode);
|
||||
PCFFOLDER_NODE NewFolderNode();
|
||||
PCFFILE_NODE NewFileNode();
|
||||
PCFDATA_NODE NewDataNode(PCFFOLDER_NODE FolderNode);
|
||||
VOID DestroyDataNodes(PCFFOLDER_NODE FolderNode);
|
||||
VOID DestroyFileNodes();
|
||||
VOID DestroyDeletedFileNodes();
|
||||
VOID DestroyFolderNodes();
|
||||
VOID DestroyDeletedFolderNodes();
|
||||
ULONG ComputeChecksum(PVOID Buffer, UINT Size, ULONG Seed);
|
||||
ULONG ReadBlock(PVOID Buffer, DWORD Size, PDWORD BytesRead);
|
||||
#ifndef CAB_READ_ONLY
|
||||
ULONG InitCabinetHeader();
|
||||
ULONG WriteCabinetHeader(BOOL MoreDisks);
|
||||
ULONG WriteFolderEntries();
|
||||
ULONG WriteFileEntries();
|
||||
ULONG CommitDataBlocks(PCFFOLDER_NODE FolderNode);
|
||||
ULONG WriteDataBlock();
|
||||
ULONG GetAttributesOnFile(PCFFILE_NODE File);
|
||||
ULONG SetAttributesOnFile(PCFFILE_NODE File);
|
||||
#endif /* CAB_READ_ONLY */
|
||||
DWORD CurrentDiskNumber; // Zero based disk number
|
||||
TCHAR CabinetName[256]; // Filename of current cabinet
|
||||
TCHAR CabinetPrev[256]; // Filename of previous cabinet
|
||||
TCHAR DiskPrev[256]; // Label of cabinet in file CabinetPrev
|
||||
TCHAR CabinetNext[256]; // Filename of next cabinet
|
||||
TCHAR DiskNext[256]; // Label of cabinet in file CabinetNext
|
||||
DWORD TotalHeaderSize; // Size of header and optional fields
|
||||
DWORD NextFieldsSize; // Size of next cabinet name and next disk label
|
||||
DWORD TotalFolderSize; // Size of all folder entries
|
||||
DWORD TotalFileSize; // Size of all file entries
|
||||
DWORD FolderUncompSize; // Uncompressed size of folder
|
||||
DWORD BytesLeftInBlock; // Number of bytes left in current block
|
||||
BOOL ReuseBlock;
|
||||
TCHAR DestPath[MAX_PATH];
|
||||
HANDLE FileHandle;
|
||||
BOOL FileOpen;
|
||||
CFHEADER CABHeader;
|
||||
ULONG CabinetReserved;
|
||||
ULONG FolderReserved;
|
||||
ULONG DataReserved;
|
||||
PCFFOLDER_NODE FolderListHead;
|
||||
PCFFOLDER_NODE FolderListTail;
|
||||
PCFFOLDER_NODE CurrentFolderNode;
|
||||
PCFDATA_NODE CurrentDataNode;
|
||||
PCFFILE_NODE FileListHead;
|
||||
PCFFILE_NODE FileListTail;
|
||||
CCABCodec *Codec;
|
||||
ULONG CodecId;
|
||||
BOOL CodecSelected;
|
||||
PVOID InputBuffer;
|
||||
PVOID CurrentIBuffer; // Current offset in input buffer
|
||||
DWORD CurrentIBufferSize; // Bytes left in input buffer
|
||||
PVOID OutputBuffer;
|
||||
DWORD TotalCompSize; // Total size of current CFDATA block
|
||||
PVOID CurrentOBuffer; // Current offset in output buffer
|
||||
DWORD CurrentOBufferSize; // Bytes left in output buffer
|
||||
DWORD BytesLeftInCabinet;
|
||||
BOOL RestartSearch;
|
||||
DWORD LastFileOffset; // Uncompressed offset of last extracted file
|
||||
#ifndef CAB_READ_ONLY
|
||||
DWORD LastBlockStart; // Uncompressed offset of last block in folder
|
||||
DWORD MaxDiskSize;
|
||||
DWORD DiskSize;
|
||||
DWORD PrevCabinetNumber; // Previous cabinet number (where split file starts)
|
||||
BOOL CreateNewDisk;
|
||||
BOOL CreateNewFolder;
|
||||
|
||||
CCFDATAStorage *ScratchFile;
|
||||
HANDLE SourceFile;
|
||||
BOOL ContinueFile;
|
||||
DWORD TotalBytesLeft;
|
||||
BOOL BlockIsSplit; // TRUE if current data block is split
|
||||
ULONG NextFolderNumber; // Zero based folder number
|
||||
#endif /* CAB_READ_ONLY */
|
||||
};
|
||||
|
||||
#endif /* __CABINET_H */
|
||||
|
||||
/* EOF */
|
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS cabinet manager
|
||||
* FILE: apps/cabman/cabman.h
|
||||
* PURPOSE: Cabinet manager header
|
||||
*/
|
||||
#ifndef __CABMAN_H
|
||||
#define __CABMAN_H
|
||||
|
||||
#include "cabinet.h"
|
||||
#include "dfp.h"
|
||||
|
||||
/* Cabinet manager modes */
|
||||
#define CM_MODE_CREATE 0
|
||||
#define CM_MODE_DISPLAY 1
|
||||
#define CM_MODE_EXTRACT 2
|
||||
|
||||
|
||||
/* Classes */
|
||||
|
||||
class CCABManager : public CDFParser {
|
||||
public:
|
||||
CCABManager();
|
||||
virtual ~CCABManager();
|
||||
BOOL ParseCmdline(INT argc, PCHAR argv[]);
|
||||
VOID Run();
|
||||
private:
|
||||
VOID Usage();
|
||||
VOID CreateCabinet();
|
||||
VOID DisplayCabinet();
|
||||
VOID ExtractFromCabinet();
|
||||
/* Event handlers */
|
||||
virtual BOOL OnOverwrite(PCFFILE File, LPTSTR FileName);
|
||||
virtual VOID OnExtract(PCFFILE File, LPTSTR FileName);
|
||||
virtual VOID OnDiskChange(LPTSTR CabinetName, LPTSTR DiskLabel);
|
||||
virtual VOID OnAdd(PCFFILE Entry, LPTSTR FileName);
|
||||
/* Configuration */
|
||||
BOOL ProcessAll;
|
||||
DWORD Mode;
|
||||
BOOL PromptOnOverwrite;
|
||||
TCHAR Location[MAX_PATH];
|
||||
TCHAR FileName[MAX_PATH];
|
||||
};
|
||||
|
||||
#endif /* __CABMAN_H */
|
||||
|
||||
/* EOF */
|
@@ -1,55 +0,0 @@
|
||||
Directive File Format for ReactOS Cabinet Manager
|
||||
-------------------------------------------------
|
||||
|
||||
Directives begin with a period ("."), and are followed by a command
|
||||
name, and possibly blank delimited arguments. Commands and variable names are
|
||||
case insensitive.
|
||||
|
||||
Syntax Description
|
||||
-------------------------------------------------------------------------------
|
||||
; Anything on a line after this is a comment
|
||||
<filename> [destination] File copy command
|
||||
.Define variable=[value] Define variable to be equal to value (*)
|
||||
.Delete variable Delete a variable definition (*)
|
||||
.New Disk|Cabinet|Folder Start a new disk, cabinet or folder (* -- new disk will work)
|
||||
.Set variable=[value] Set variable to be equal to value (*)
|
||||
%variable% Substitute value of variable (*)
|
||||
<blank line> Blank lines are ignored
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Standard variable Description
|
||||
-------------------------------------------------------------------------------
|
||||
Cabinet=ON|OFF Turns cabinet mode on or off (* -- currently always on)
|
||||
CabinetFileCountThreshold=count Threshold count of files per cabinet (*)
|
||||
CabinetNamen=filename Cabinet file name for cabinet number n
|
||||
CabinetNameTemplate=template Cabinet file name template
|
||||
* is replaced by cabinet number
|
||||
Compress=ON|OFF Turns compression on or off (* -- currently always on)
|
||||
CompressionType=NONE|MSZIP Compression engine to use (* -- currently always mszip)
|
||||
DiskLabeln=label Printed disk label name for disk n
|
||||
DiskLabelTemplate=template Printed disk label name template
|
||||
* is replaced by disk number
|
||||
FolderFileCountThreshold=count Threshold count of files per folder (*)
|
||||
FolderSizeThreshold=size Threshold folder size for current folder (*)
|
||||
MaxDiskFileCount=count Maximum count of files per disk (*)
|
||||
MaxDiskSize[n]=size Maximum disk size (for disk n)
|
||||
ReservePerCabinetSize=size Amount of space to reserve in each cabinet (*)
|
||||
ReservePerDataBlockSize=size Amount of space to reserve in each data block (*)
|
||||
ReservePerFolderSize=size Amount of space to reserve in each folder (*)
|
||||
SourceDir=path Default path for source files (*)
|
||||
-------------------------------------------------------------------------------
|
||||
(*) = not implemented
|
||||
|
||||
|
||||
MaxDiskSize
|
||||
-----------
|
||||
0 means disk size is unlimited. Standard sizes available are:
|
||||
|
||||
2.88M
|
||||
1.44M
|
||||
1.25M
|
||||
1.2M
|
||||
720K
|
||||
360K
|
||||
CDROM
|
@@ -1,992 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS cabinet manager
|
||||
* FILE: apps/cabman/dfp.cpp
|
||||
* PURPOSE: Directive file parser
|
||||
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
* NOTES: The directive file format is similar to the
|
||||
* directive file format used by Microsoft's MAKECAB
|
||||
* REVISIONS:
|
||||
* CSH 21/03-2001 Created
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "cabinet.h"
|
||||
#include "dfp.h"
|
||||
|
||||
|
||||
/* CDFParser */
|
||||
|
||||
CDFParser::CDFParser()
|
||||
/*
|
||||
* FUNCTION: Default constructor
|
||||
*/
|
||||
{
|
||||
FileBuffer = NULL;
|
||||
FileLoaded = FALSE;
|
||||
CurrentOffset = 0;
|
||||
CurrentLine = 0;
|
||||
CabinetCreated = FALSE;
|
||||
DiskCreated = FALSE;
|
||||
FolderCreated = FALSE;
|
||||
CabinetName = NULL;
|
||||
DiskLabel = NULL;
|
||||
MaxDiskSize = NULL;
|
||||
|
||||
MaxDiskSizeAllSet = FALSE;
|
||||
CabinetNameTemplateSet = FALSE;
|
||||
DiskLabelTemplateSet = FALSE;
|
||||
}
|
||||
|
||||
|
||||
CDFParser::~CDFParser()
|
||||
/*
|
||||
* FUNCTION: Default destructor
|
||||
*/
|
||||
{
|
||||
PCABINET_NAME CNPrev;
|
||||
PCABINET_NAME CNNext;
|
||||
PDISK_NUMBER DNPrev;
|
||||
PDISK_NUMBER DNNext;
|
||||
|
||||
if (FileBuffer)
|
||||
HeapFree(GetProcessHeap(), 0, FileBuffer);
|
||||
CNNext = CabinetName;
|
||||
while (CNNext != NULL) {
|
||||
CNPrev = CNNext->Next;
|
||||
HeapFree(GetProcessHeap(), 0, CNNext);
|
||||
CNNext = CNPrev;
|
||||
}
|
||||
CNNext = DiskLabel;
|
||||
while (CNNext != NULL) {
|
||||
CNPrev = CNNext->Next;
|
||||
HeapFree(GetProcessHeap(), 0, CNNext);
|
||||
CNNext = CNPrev;
|
||||
}
|
||||
DNNext = MaxDiskSize;
|
||||
while (DNNext != NULL) {
|
||||
DNPrev = DNNext->Next;
|
||||
HeapFree(GetProcessHeap(), 0, DNNext);
|
||||
DNNext = DNPrev;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ULONG CDFParser::Load(LPTSTR FileName)
|
||||
/*
|
||||
* FUNCTION: Loads a directive file into memory
|
||||
* ARGUMENTS:
|
||||
* FileName = Pointer to name of directive file
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
*/
|
||||
{
|
||||
DWORD BytesRead;
|
||||
LONG FileSize;
|
||||
|
||||
if (FileLoaded)
|
||||
return CAB_STATUS_SUCCESS;
|
||||
|
||||
/* Create cabinet file, overwrite if it already exists */
|
||||
FileHandle = CreateFile(FileName, // Create this file
|
||||
GENERIC_READ, // Open for reading
|
||||
0, // No sharing
|
||||
NULL, // No security
|
||||
OPEN_EXISTING, // Open the file
|
||||
FILE_ATTRIBUTE_NORMAL, // Normal file
|
||||
NULL); // No attribute template
|
||||
if (FileHandle == INVALID_HANDLE_VALUE)
|
||||
return CAB_STATUS_CANNOT_OPEN;
|
||||
|
||||
FileSize = GetFileSize(FileHandle, NULL);
|
||||
if (FileSize < 0) {
|
||||
CloseHandle(FileHandle);
|
||||
return CAB_STATUS_CANNOT_OPEN;
|
||||
}
|
||||
|
||||
FileBufferSize = (ULONG)FileSize;
|
||||
|
||||
FileBuffer = (PCHAR)HeapAlloc(GetProcessHeap(), 0, FileBufferSize);
|
||||
if (!FileBuffer) {
|
||||
CloseHandle(FileHandle);
|
||||
return CAB_STATUS_NOMEMORY;
|
||||
}
|
||||
|
||||
if (!ReadFile(FileHandle, FileBuffer, FileBufferSize, &BytesRead, NULL)) {
|
||||
CloseHandle(FileHandle);
|
||||
HeapFree(GetProcessHeap(), 0, FileBuffer);
|
||||
FileBuffer = NULL;
|
||||
return CAB_STATUS_CANNOT_READ;
|
||||
}
|
||||
|
||||
CloseHandle(FileHandle);
|
||||
|
||||
FileLoaded = TRUE;
|
||||
|
||||
DPRINT(MAX_TRACE, ("File (%d bytes)\n", FileBufferSize));
|
||||
|
||||
return CAB_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ULONG CDFParser::Parse()
|
||||
/*
|
||||
* FUNCTION: Parses a loaded directive file
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
*/
|
||||
{
|
||||
BOOL Command;
|
||||
ULONG Status;
|
||||
|
||||
if (!FileLoaded)
|
||||
return CAB_STATUS_NOFILE;
|
||||
|
||||
while (ReadLine()) {
|
||||
Command = FALSE;
|
||||
|
||||
while (CurrentToken != TokenEnd) {
|
||||
switch (CurrentToken) {
|
||||
case TokenInteger:
|
||||
itoa(CurrentInteger, (LPTSTR)&CurrentString, 10);
|
||||
case TokenIdentifier:
|
||||
if (Command) {
|
||||
/* Command */
|
||||
Status = PerformCommand();
|
||||
|
||||
if (Status == CAB_STATUS_FAILURE) {
|
||||
printf("Directive file contains errors at line %d.\n", (UINT)CurrentLine);
|
||||
DPRINT(MID_TRACE, ("Error while executing command.\n"));
|
||||
}
|
||||
|
||||
if (Status != CAB_STATUS_SUCCESS)
|
||||
return Status;
|
||||
} else {
|
||||
/* File copy */
|
||||
Status = PerformFileCopy();
|
||||
|
||||
if (Status == CAB_STATUS_FAILURE) {
|
||||
printf("Directive file contains errors at line %d.\n", (UINT)CurrentLine);
|
||||
DPRINT(MID_TRACE, ("Error while copying file.\n"));
|
||||
}
|
||||
|
||||
if (Status != CAB_STATUS_SUCCESS)
|
||||
return Status;
|
||||
}
|
||||
break;
|
||||
case TokenSpace:
|
||||
break;
|
||||
case TokenSemi:
|
||||
CurrentToken = TokenEnd;
|
||||
continue;
|
||||
case TokenPeriod:
|
||||
Command = TRUE;
|
||||
break;
|
||||
default:
|
||||
printf("Directive file contains errors at line %d.\n", (UINT)CurrentLine);
|
||||
DPRINT(MIN_TRACE, ("Token is (%d).\n", (UINT)CurrentToken));
|
||||
return CAB_STATUS_SUCCESS;
|
||||
}
|
||||
NextToken();
|
||||
}
|
||||
}
|
||||
|
||||
printf("\nWriting cabinet. This may take a while...\n\n");
|
||||
|
||||
if (DiskCreated) {
|
||||
Status = WriteDisk(FALSE);
|
||||
if (Status == CAB_STATUS_SUCCESS)
|
||||
Status = CloseDisk();
|
||||
if (Status != CAB_STATUS_SUCCESS) {
|
||||
DPRINT(MIN_TRACE, ("Cannot write disk (%d).\n", (UINT)Status));
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
if (CabinetCreated) {
|
||||
Status = CloseCabinet();
|
||||
if (Status != CAB_STATUS_SUCCESS) {
|
||||
DPRINT(MIN_TRACE, ("Cannot close cabinet (%d).\n", (UINT)Status));
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\nDone.\n");
|
||||
|
||||
return CAB_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
BOOL CDFParser::OnDiskLabel(ULONG Number, LPTSTR Label)
|
||||
/*
|
||||
* FUNCTION: Called when a disk needs a label
|
||||
* ARGUMENTS:
|
||||
* Number = Cabinet number that needs a label
|
||||
* Label = Pointer to buffer to place label of disk
|
||||
* RETURNS:
|
||||
* TRUE if a disk label was returned, FALSE if not
|
||||
*/
|
||||
{
|
||||
TCHAR Buffer[20];
|
||||
INT i, j;
|
||||
TCHAR ch;
|
||||
|
||||
Number += 1;
|
||||
|
||||
DPRINT(MID_TRACE, ("Giving disk (%d) a label...\n", (UINT)Number));
|
||||
|
||||
if (GetDiskName(&DiskLabel, Number, Label))
|
||||
return TRUE;
|
||||
|
||||
if (DiskLabelTemplateSet) {
|
||||
j = 0;
|
||||
lstrcpy(Label, "");
|
||||
for (i = 0; i < lstrlen(DiskLabelTemplate); i++) {
|
||||
ch = DiskLabelTemplate[i];
|
||||
if (ch == '*') {
|
||||
lstrcat(Label, itoa(Number, Buffer, 10));
|
||||
j += lstrlen(Buffer);
|
||||
} else {
|
||||
Label[j] = ch;
|
||||
j++;
|
||||
}
|
||||
Label[j] = '\0';
|
||||
}
|
||||
|
||||
DPRINT(MID_TRACE, ("Giving disk (%s) as a label...\n", Label));
|
||||
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOL CDFParser::OnCabinetName(ULONG Number, LPTSTR Name)
|
||||
/*
|
||||
* FUNCTION: Called when a cabinet needs a name
|
||||
* ARGUMENTS:
|
||||
* Number = Disk number that needs a name
|
||||
* Name = Pointer to buffer to place name of cabinet
|
||||
* RETURNS:
|
||||
* TRUE if a cabinet name was returned, FALSE if not
|
||||
*/
|
||||
{
|
||||
TCHAR Buffer[20];
|
||||
INT i, j;
|
||||
TCHAR ch;
|
||||
|
||||
Number += 1;
|
||||
|
||||
DPRINT(MID_TRACE, ("Giving cabinet (%d) a name...\n", (UINT)Number));
|
||||
|
||||
if (GetDiskName(&CabinetName, Number, Name))
|
||||
return TRUE;
|
||||
|
||||
if (CabinetNameTemplateSet) {
|
||||
j = 0;
|
||||
lstrcpy(Name, "");
|
||||
for (i = 0; i < lstrlen(CabinetNameTemplate); i++) {
|
||||
ch = CabinetNameTemplate[i];
|
||||
if (ch == '*') {
|
||||
lstrcat(Name, itoa(Number, Buffer, 10));
|
||||
j += lstrlen(Buffer);
|
||||
} else {
|
||||
Name[j] = ch;
|
||||
j++;
|
||||
}
|
||||
Name[j] = '\0';
|
||||
}
|
||||
|
||||
DPRINT(MID_TRACE, ("Giving cabinet (%s) as a name...\n", Name));
|
||||
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOL CDFParser::SetDiskName(PCABINET_NAME *List, ULONG Number, LPTSTR String)
|
||||
/*
|
||||
* FUNCTION: Sets an entry in a list
|
||||
* ARGUMENTS:
|
||||
* List = Address of pointer to list
|
||||
* Number = Disk number
|
||||
* String = Pointer to string
|
||||
* RETURNS:
|
||||
* FALSE if there was not enough free memory available
|
||||
*/
|
||||
{
|
||||
PCABINET_NAME CN;
|
||||
|
||||
CN = *List;
|
||||
while (CN != NULL) {
|
||||
if (CN->DiskNumber == Number) {
|
||||
lstrcpy(CN->Name, String);
|
||||
return TRUE;
|
||||
}
|
||||
CN = CN->Next;
|
||||
}
|
||||
|
||||
CN = (PCABINET_NAME)HeapAlloc(GetProcessHeap(), 0, sizeof(CABINET_NAME));
|
||||
if (!CN)
|
||||
return FALSE;
|
||||
|
||||
CN->DiskNumber = Number;
|
||||
lstrcpy(CN->Name, String);
|
||||
|
||||
CN->Next = *List;
|
||||
*List = CN;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL CDFParser::GetDiskName(PCABINET_NAME *List, ULONG Number, LPTSTR String)
|
||||
/*
|
||||
* FUNCTION: Returns an entry in a list
|
||||
* ARGUMENTS:
|
||||
* List = Address of pointer to list
|
||||
* Number = Disk number
|
||||
* String = Address of buffer to copy string to
|
||||
* RETURNS:
|
||||
* FALSE if there was not enough free memory available
|
||||
*/
|
||||
{
|
||||
PCABINET_NAME CN;
|
||||
|
||||
CN = *List;
|
||||
while (CN != NULL) {
|
||||
if (CN->DiskNumber == Number) {
|
||||
lstrcpy(String, CN->Name);
|
||||
return TRUE;
|
||||
}
|
||||
CN = CN->Next;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOL CDFParser::SetDiskNumber(PDISK_NUMBER *List, ULONG Number, ULONG Value)
|
||||
/*
|
||||
* FUNCTION: Sets an entry in a list
|
||||
* ARGUMENTS:
|
||||
* List = Address of pointer to list
|
||||
* Number = Disk number
|
||||
* Value = Value to set
|
||||
* RETURNS:
|
||||
* FALSE if there was not enough free memory available
|
||||
*/
|
||||
{
|
||||
PDISK_NUMBER DN;
|
||||
|
||||
DN = *List;
|
||||
while (DN != NULL) {
|
||||
if (DN->DiskNumber == Number) {
|
||||
DN->Number = Value;
|
||||
return TRUE;
|
||||
}
|
||||
DN = DN->Next;
|
||||
}
|
||||
|
||||
DN = (PDISK_NUMBER)HeapAlloc(GetProcessHeap(), 0, sizeof(DISK_NUMBER));
|
||||
if (!DN)
|
||||
return FALSE;
|
||||
|
||||
DN->DiskNumber = Number;
|
||||
DN->Number = Value;
|
||||
|
||||
DN->Next = *List;
|
||||
*List = DN;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL CDFParser::GetDiskNumber(PDISK_NUMBER *List, ULONG Number, PULONG Value)
|
||||
/*
|
||||
* FUNCTION: Returns an entry in a list
|
||||
* ARGUMENTS:
|
||||
* List = Address of pointer to list
|
||||
* Number = Disk number
|
||||
* Value = Address of buffer to place value
|
||||
* RETURNS:
|
||||
* TRUE if the entry was found
|
||||
*/
|
||||
{
|
||||
PDISK_NUMBER DN;
|
||||
|
||||
DN = *List;
|
||||
while (DN != NULL) {
|
||||
if (DN->DiskNumber == Number) {
|
||||
*Value = DN->Number;
|
||||
return TRUE;
|
||||
}
|
||||
DN = DN->Next;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOL CDFParser::DoDiskLabel(ULONG Number, LPTSTR Label)
|
||||
/*
|
||||
* FUNCTION: Sets the label of a disk
|
||||
* ARGUMENTS:
|
||||
* Number = Disk number
|
||||
* Label = Pointer to label of disk
|
||||
* RETURNS:
|
||||
* FALSE if there was not enough free memory available
|
||||
*/
|
||||
{
|
||||
DPRINT(MID_TRACE, ("Setting label of disk (%d) to '%s'\n", (UINT)Number, Label));
|
||||
|
||||
return SetDiskName(&DiskLabel, Number, Label);
|
||||
}
|
||||
|
||||
|
||||
VOID CDFParser::DoDiskLabelTemplate(LPTSTR Template)
|
||||
/*
|
||||
* FUNCTION: Sets a disk label template to use
|
||||
* ARGUMENTS:
|
||||
* Template = Pointer to disk label template
|
||||
*/
|
||||
{
|
||||
DPRINT(MID_TRACE, ("Setting disk label template to '%s'\n", Template));
|
||||
|
||||
lstrcpy(DiskLabelTemplate, Template);
|
||||
DiskLabelTemplateSet = TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL CDFParser::DoCabinetName(ULONG Number, LPTSTR Name)
|
||||
/*
|
||||
* FUNCTION: Sets the name of a cabinet
|
||||
* ARGUMENTS:
|
||||
* Number = Disk number
|
||||
* Name = Pointer to name of cabinet
|
||||
* RETURNS:
|
||||
* FALSE if there was not enough free memory available
|
||||
*/
|
||||
{
|
||||
DPRINT(MID_TRACE, ("Setting name of cabinet (%d) to '%s'\n", (UINT)Number, Name));
|
||||
|
||||
return SetDiskName(&CabinetName, Number, Name);
|
||||
}
|
||||
|
||||
|
||||
VOID CDFParser::DoCabinetNameTemplate(LPTSTR Template)
|
||||
/*
|
||||
* FUNCTION: Sets a cabinet name template to use
|
||||
* ARGUMENTS:
|
||||
* Template = Pointer to cabinet name template
|
||||
*/
|
||||
{
|
||||
DPRINT(MID_TRACE, ("Setting cabinet name template to '%s'\n", Template));
|
||||
|
||||
lstrcpy(CabinetNameTemplate, Template);
|
||||
CabinetNameTemplateSet = TRUE;
|
||||
}
|
||||
|
||||
|
||||
ULONG CDFParser::DoMaxDiskSize(BOOL NumberValid, ULONG Number)
|
||||
/*
|
||||
* FUNCTION: Sets the maximum disk size
|
||||
* ARGUMENTS:
|
||||
* NumberValid = TRUE if disk number is valid
|
||||
* Number = Disk number
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
* NOTES:
|
||||
* Standard sizes are 2.88M, 1.44M, 1.25M, 1.2M, 720K, 360K, and CDROM
|
||||
*/
|
||||
{
|
||||
ULONG A, B, Value;
|
||||
|
||||
if (IsNextToken(TokenInteger, TRUE)) {
|
||||
|
||||
A = CurrentInteger;
|
||||
|
||||
if (IsNextToken(TokenPeriod, FALSE)) {
|
||||
if (!IsNextToken(TokenInteger, FALSE))
|
||||
return CAB_STATUS_FAILURE;
|
||||
|
||||
B = CurrentInteger;
|
||||
|
||||
} else
|
||||
B = 0;
|
||||
|
||||
if (CurrentToken == TokenIdentifier) {
|
||||
switch (CurrentString[0]) {
|
||||
case 'K':
|
||||
if (B != 0)
|
||||
return CAB_STATUS_FAILURE;
|
||||
|
||||
if (A == 720)
|
||||
/* 720K disk */
|
||||
Value = 730112;
|
||||
else if (A == 360)
|
||||
/* 360K disk */
|
||||
Value = 362496;
|
||||
else
|
||||
return CAB_STATUS_FAILURE;
|
||||
break;
|
||||
case 'M':
|
||||
if (A == 1) {
|
||||
if (B == 44)
|
||||
/* 1.44M disk */
|
||||
Value = 1457664;
|
||||
else if (B == 25)
|
||||
/* 1.25M disk */
|
||||
Value = 1300000; // FIXME: Value?
|
||||
else if (B == 2)
|
||||
/* 1.2M disk */
|
||||
Value = 1213952;
|
||||
else
|
||||
return CAB_STATUS_FAILURE;
|
||||
} else if (A == 2) {
|
||||
if (B == 88)
|
||||
/* 2.88M disk */
|
||||
Value = 2915328;
|
||||
else
|
||||
return CAB_STATUS_FAILURE;
|
||||
} else
|
||||
return CAB_STATUS_FAILURE;
|
||||
break;
|
||||
default:
|
||||
DPRINT(MID_TRACE, ("Bad suffix (%c)\n", CurrentString[0]));
|
||||
return CAB_STATUS_FAILURE;
|
||||
}
|
||||
} else
|
||||
Value = A;
|
||||
} else {
|
||||
if ((CurrentToken != TokenString) &&
|
||||
(strcmpi(CurrentString, "CDROM") != 0))
|
||||
return CAB_STATUS_FAILURE;
|
||||
/* CDROM */
|
||||
Value = 640*1024*1024; // FIXME: Correct size for CDROM?
|
||||
}
|
||||
|
||||
if (NumberValid)
|
||||
return (SetDiskNumber(&MaxDiskSize, Number, Value)?
|
||||
CAB_STATUS_SUCCESS : CAB_STATUS_FAILURE);
|
||||
|
||||
MaxDiskSizeAll = Value;
|
||||
MaxDiskSizeAllSet = TRUE;
|
||||
|
||||
SetMaxDiskSize(Value);
|
||||
|
||||
return CAB_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ULONG CDFParser::SetupNewDisk()
|
||||
/*
|
||||
* FUNCTION: Sets up parameters for a new disk
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
*/
|
||||
{
|
||||
ULONG Value;
|
||||
|
||||
if (!GetDiskNumber(&MaxDiskSize, GetCurrentDiskNumber(), &Value)) {
|
||||
if (MaxDiskSizeAllSet)
|
||||
Value = MaxDiskSizeAll;
|
||||
else
|
||||
Value = 0;
|
||||
}
|
||||
SetMaxDiskSize(Value);
|
||||
|
||||
return CAB_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ULONG CDFParser::PerformSetCommand()
|
||||
/*
|
||||
* FUNCTION: Performs a set variable command
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
*/
|
||||
{
|
||||
SETTYPE SetType;
|
||||
BOOL NumberValid = FALSE;
|
||||
ULONG Number = 0;
|
||||
|
||||
if (!IsNextToken(TokenIdentifier, TRUE))
|
||||
return CAB_STATUS_FAILURE;
|
||||
|
||||
if (strcmpi(CurrentString, "DiskLabel") == 0)
|
||||
SetType = stDiskLabel;
|
||||
else if (strcmpi(CurrentString, "DiskLabelTemplate") == 0)
|
||||
SetType = stDiskLabelTemplate;
|
||||
else if (strcmpi(CurrentString, "CabinetName") == 0)
|
||||
SetType = stCabinetName;
|
||||
else if (strcmpi(CurrentString, "CabinetNameTemplate") == 0)
|
||||
SetType = stCabinetNameTemplate;
|
||||
else if (strcmpi(CurrentString, "MaxDiskSize") == 0)
|
||||
SetType = stMaxDiskSize;
|
||||
else
|
||||
return CAB_STATUS_FAILURE;
|
||||
|
||||
if ((SetType == stDiskLabel) || (SetType == stCabinetName)) {
|
||||
if (!IsNextToken(TokenInteger, FALSE))
|
||||
return CAB_STATUS_FAILURE;
|
||||
Number = CurrentInteger;
|
||||
|
||||
if (!IsNextToken(TokenEqual, TRUE))
|
||||
return CAB_STATUS_FAILURE;
|
||||
} else if (SetType == stMaxDiskSize) {
|
||||
if (IsNextToken(TokenInteger, FALSE)) {
|
||||
NumberValid = TRUE;
|
||||
Number = CurrentInteger;
|
||||
} else {
|
||||
NumberValid = FALSE;
|
||||
while (CurrentToken == TokenSpace)
|
||||
NextToken();
|
||||
if (CurrentToken != TokenEqual)
|
||||
return CAB_STATUS_FAILURE;
|
||||
}
|
||||
} else if (!IsNextToken(TokenEqual, TRUE))
|
||||
return CAB_STATUS_FAILURE;
|
||||
|
||||
if (SetType != stMaxDiskSize) {
|
||||
if (!IsNextToken(TokenString, TRUE))
|
||||
return CAB_STATUS_FAILURE;
|
||||
}
|
||||
|
||||
switch (SetType) {
|
||||
case stDiskLabel:
|
||||
if (!DoDiskLabel(Number, CurrentString))
|
||||
DPRINT(MIN_TRACE, ("Not enough available free memory.\n"));
|
||||
return CAB_STATUS_SUCCESS;
|
||||
case stCabinetName:
|
||||
if (!DoCabinetName(Number, CurrentString))
|
||||
DPRINT(MIN_TRACE, ("Not enough available free memory.\n"));
|
||||
return CAB_STATUS_SUCCESS;
|
||||
case stDiskLabelTemplate:
|
||||
DoDiskLabelTemplate(CurrentString);
|
||||
return CAB_STATUS_SUCCESS;
|
||||
case stCabinetNameTemplate:
|
||||
DoCabinetNameTemplate(CurrentString);
|
||||
return CAB_STATUS_SUCCESS;
|
||||
case stMaxDiskSize:
|
||||
return DoMaxDiskSize(NumberValid, Number);
|
||||
default:
|
||||
return CAB_STATUS_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ULONG CDFParser::PerformNewCommand()
|
||||
/*
|
||||
* FUNCTION: Performs a new disk|cabinet|folder command
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
*/
|
||||
{
|
||||
NEWTYPE NewType;
|
||||
ULONG Status;
|
||||
|
||||
if (!IsNextToken(TokenIdentifier, TRUE))
|
||||
return CAB_STATUS_FAILURE;
|
||||
|
||||
if (strcmpi(CurrentString, "Disk") == 0)
|
||||
NewType = ntDisk;
|
||||
else if (strcmpi(CurrentString, "Cabinet") == 0)
|
||||
NewType = ntCabinet;
|
||||
else if (strcmpi(CurrentString, "Folder") == 0)
|
||||
NewType = ntFolder;
|
||||
else
|
||||
return CAB_STATUS_FAILURE;
|
||||
|
||||
switch (NewType) {
|
||||
case ntDisk:
|
||||
if (DiskCreated) {
|
||||
Status = WriteDisk(TRUE);
|
||||
if (Status == CAB_STATUS_SUCCESS)
|
||||
Status = CloseDisk();
|
||||
if (Status != CAB_STATUS_SUCCESS) {
|
||||
DPRINT(MIN_TRACE, ("Cannot write disk (%d).\n", (UINT)Status));
|
||||
return CAB_STATUS_SUCCESS;
|
||||
}
|
||||
DiskCreated = FALSE;
|
||||
}
|
||||
|
||||
Status = NewDisk();
|
||||
if (Status != CAB_STATUS_SUCCESS) {
|
||||
DPRINT(MIN_TRACE, ("Cannot create disk (%d).\n", (UINT)Status));
|
||||
return CAB_STATUS_SUCCESS;
|
||||
}
|
||||
DiskCreated = TRUE;
|
||||
SetupNewDisk();
|
||||
return CAB_STATUS_SUCCESS;
|
||||
case ntCabinet:
|
||||
if (DiskCreated) {
|
||||
Status = WriteDisk(TRUE);
|
||||
if (Status == CAB_STATUS_SUCCESS)
|
||||
Status = CloseDisk();
|
||||
if (Status != CAB_STATUS_SUCCESS) {
|
||||
DPRINT(MIN_TRACE, ("Cannot write disk (%d).\n", (UINT)Status));
|
||||
return CAB_STATUS_SUCCESS;
|
||||
}
|
||||
DiskCreated = FALSE;
|
||||
}
|
||||
|
||||
Status = NewCabinet();
|
||||
if (Status != CAB_STATUS_SUCCESS) {
|
||||
DPRINT(MIN_TRACE, ("Cannot create cabinet (%d).\n", (UINT)Status));
|
||||
return CAB_STATUS_SUCCESS;
|
||||
}
|
||||
DiskCreated = TRUE;
|
||||
SetupNewDisk();
|
||||
return CAB_STATUS_SUCCESS;
|
||||
case ntFolder:
|
||||
Status = NewFolder();
|
||||
ASSERT(Status == CAB_STATUS_SUCCESS);
|
||||
return CAB_STATUS_SUCCESS;
|
||||
default:
|
||||
return CAB_STATUS_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ULONG CDFParser::PerformCommand()
|
||||
/*
|
||||
* FUNCTION: Performs a command
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
*/
|
||||
{
|
||||
if (strcmpi(CurrentString, "Set") == 0)
|
||||
return PerformSetCommand();
|
||||
if (strcmpi(CurrentString, "New") == 0)
|
||||
return PerformNewCommand();
|
||||
|
||||
return CAB_STATUS_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
ULONG CDFParser::PerformFileCopy()
|
||||
/*
|
||||
* FUNCTION: Performs a file copy
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
*/
|
||||
{
|
||||
ULONG Status;
|
||||
ULONG i, j;
|
||||
TCHAR ch;
|
||||
TCHAR SrcName[MAX_PATH];
|
||||
TCHAR DstName[MAX_PATH];
|
||||
|
||||
lstrcpy(SrcName, "");
|
||||
lstrcpy(DstName, "");
|
||||
|
||||
i = lstrlen(CurrentString);
|
||||
while ((i < LineLength) &&
|
||||
((ch = Line[i]) != ' ') &&
|
||||
(ch != 0x09) &&
|
||||
(ch != ';')) {
|
||||
CurrentString[i] = ch;
|
||||
i++;
|
||||
}
|
||||
CurrentString[i] = '\0';
|
||||
CurrentToken = TokenString;
|
||||
CurrentChar = i + 1;
|
||||
lstrcpy(SrcName, CurrentString);
|
||||
|
||||
SkipSpaces();
|
||||
|
||||
if (CurrentToken != TokenEnd) {
|
||||
j = lstrlen(CurrentString); i = 0;
|
||||
while ((CurrentChar + i < LineLength) &&
|
||||
((ch = Line[CurrentChar + i]) != ' ') &&
|
||||
(ch != 0x09) &&
|
||||
(ch != ';')) {
|
||||
CurrentString[j + i] = ch;
|
||||
i++;
|
||||
}
|
||||
CurrentString[j + i] = '\0';
|
||||
CurrentToken = TokenString;
|
||||
CurrentChar += i + 1;
|
||||
lstrcpy(DstName, CurrentString);
|
||||
}
|
||||
|
||||
if (!CabinetCreated) {
|
||||
|
||||
DPRINT(MID_TRACE, ("Creating cabinet.\n"));
|
||||
|
||||
Status = NewCabinet();
|
||||
if (Status != CAB_STATUS_SUCCESS) {
|
||||
DPRINT(MIN_TRACE, ("Cannot create cabinet (%d).\n", (UINT)Status));
|
||||
printf("Cannot create cabinet.\n");
|
||||
return CAB_STATUS_FAILURE;
|
||||
}
|
||||
CabinetCreated = TRUE;
|
||||
|
||||
DPRINT(MID_TRACE, ("Creating disk.\n"));
|
||||
|
||||
Status = NewDisk();
|
||||
if (Status != CAB_STATUS_SUCCESS) {
|
||||
DPRINT(MIN_TRACE, ("Cannot create disk (%d).\n", (UINT)Status));
|
||||
printf("Cannot create disk.\n");
|
||||
return CAB_STATUS_FAILURE;
|
||||
}
|
||||
DiskCreated = TRUE;
|
||||
SetupNewDisk();
|
||||
}
|
||||
|
||||
DPRINT(MID_TRACE, ("Adding file: '%s' destination: '%s'.\n", SrcName, DstName));
|
||||
|
||||
Status = AddFile(SrcName);
|
||||
if (Status != CAB_STATUS_SUCCESS) {
|
||||
if (Status == CAB_STATUS_CANNOT_OPEN)
|
||||
printf("File does not exist: %s.\n", SrcName);
|
||||
else if (Status == CAB_STATUS_NOMEMORY)
|
||||
printf("Insufficient memory to add file: %s.\n", SrcName);
|
||||
else
|
||||
printf("Cannot add file: %s (%d).\n", SrcName, Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
return CAB_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
VOID CDFParser::SkipSpaces()
|
||||
/*
|
||||
* FUNCTION: Skips any spaces in the current line
|
||||
*/
|
||||
{
|
||||
NextToken();
|
||||
while (CurrentToken == TokenSpace)
|
||||
NextToken();
|
||||
}
|
||||
|
||||
|
||||
BOOL CDFParser::IsNextToken(TOKEN Token, BOOL NoSpaces)
|
||||
/*
|
||||
* FUNCTION: Checks if next token equals Token
|
||||
* ARGUMENTS:
|
||||
* Token = Token to compare with
|
||||
* SkipSp = TRUE if spaces should be skipped
|
||||
* RETURNS:
|
||||
* FALSE if next token is diffrent from Token
|
||||
*/
|
||||
{
|
||||
if (NoSpaces)
|
||||
SkipSpaces();
|
||||
else
|
||||
NextToken();
|
||||
return (CurrentToken == Token);
|
||||
}
|
||||
|
||||
|
||||
BOOL CDFParser::ReadLine()
|
||||
/*
|
||||
* FUNCTION: Reads the next line into the line buffer
|
||||
* RETURNS:
|
||||
* TRUE if there is a new line, FALSE if not
|
||||
*/
|
||||
{
|
||||
ULONG i, j;
|
||||
TCHAR ch;
|
||||
|
||||
if (CurrentOffset >= FileBufferSize)
|
||||
return FALSE;
|
||||
|
||||
i = 0;
|
||||
while (((j = CurrentOffset + i) < FileBufferSize) && (i < 127) &&
|
||||
((ch = FileBuffer[j]) != 0x0D)) {
|
||||
Line[i] = ch;
|
||||
i++;
|
||||
}
|
||||
|
||||
Line[i] = '\0';
|
||||
LineLength = i;
|
||||
|
||||
if (FileBuffer[CurrentOffset + i + 1] == 0x0A)
|
||||
CurrentOffset++;
|
||||
|
||||
CurrentOffset += i + 1;
|
||||
|
||||
CurrentChar = 0;
|
||||
|
||||
CurrentLine++;
|
||||
|
||||
NextToken();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
VOID CDFParser::NextToken()
|
||||
/*
|
||||
* FUNCTION: Reads the next token from the current line
|
||||
*/
|
||||
{
|
||||
ULONG i;
|
||||
TCHAR ch = ' ';
|
||||
|
||||
if (CurrentChar >= LineLength) {
|
||||
CurrentToken = TokenEnd;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (Line[CurrentChar]) {
|
||||
case ' ':
|
||||
case 0x09: CurrentToken = TokenSpace;
|
||||
break;
|
||||
case ';': CurrentToken = TokenSemi;
|
||||
break;
|
||||
case '=': CurrentToken = TokenEqual;
|
||||
break;
|
||||
case '.': CurrentToken = TokenPeriod;
|
||||
break;
|
||||
case '\\': CurrentToken = TokenBackslash;
|
||||
break;
|
||||
case '"':
|
||||
i = 0;
|
||||
while ((CurrentChar + i + 1 < LineLength) &&
|
||||
((ch = Line[CurrentChar + i + 1]) != '"')) {
|
||||
CurrentString[i] = ch;
|
||||
i++;
|
||||
}
|
||||
CurrentString[i] = '\0';
|
||||
CurrentToken = TokenString;
|
||||
CurrentChar += i + 2;
|
||||
return;
|
||||
default:
|
||||
i = 0;
|
||||
while ((CurrentChar + i < LineLength) &&
|
||||
((ch = Line[CurrentChar + i]) >= '0') && (ch <= '9')) {
|
||||
CurrentString[i] = ch;
|
||||
i++;
|
||||
}
|
||||
if (i > 0) {
|
||||
CurrentString[i] = '\0';
|
||||
CurrentInteger = atoi((PCHAR)CurrentString);
|
||||
CurrentToken = TokenInteger;
|
||||
CurrentChar += i;
|
||||
return;
|
||||
}
|
||||
i = 0;
|
||||
while (((CurrentChar + i < LineLength) &&
|
||||
(((ch = Line[CurrentChar + i]) >= 'a') && (ch <= 'z')) ||
|
||||
((ch >= 'A') && (ch <= 'Z')) || (ch == '_'))) {
|
||||
CurrentString[i] = ch;
|
||||
i++;
|
||||
}
|
||||
if (i > 0) {
|
||||
CurrentString[i] = '\0';
|
||||
CurrentToken = TokenIdentifier;
|
||||
CurrentChar += i;
|
||||
return;
|
||||
}
|
||||
CurrentToken = TokenUnknown;
|
||||
}
|
||||
CurrentChar++;
|
||||
}
|
||||
|
||||
/* EOF */
|
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS cabinet manager
|
||||
* FILE: apps/cabman/dfp.h
|
||||
* PURPOSE: Directive file parser header
|
||||
*/
|
||||
#ifndef __DFP_H
|
||||
#define __DFP_H
|
||||
|
||||
#include "cabinet.h"
|
||||
|
||||
typedef struct _CABINET_NAME {
|
||||
struct _CABINET_NAME *Next;
|
||||
ULONG DiskNumber;
|
||||
TCHAR Name[128];
|
||||
} CABINET_NAME, *PCABINET_NAME;
|
||||
|
||||
typedef struct _DISK_NUMBER {
|
||||
struct _DISK_NUMBER *Next;
|
||||
ULONG DiskNumber;
|
||||
ULONG Number;
|
||||
} DISK_NUMBER, *PDISK_NUMBER;
|
||||
|
||||
typedef enum {
|
||||
TokenUnknown,
|
||||
TokenInteger,
|
||||
TokenIdentifier,
|
||||
TokenString,
|
||||
TokenSpace,
|
||||
TokenSemi,
|
||||
TokenEqual,
|
||||
TokenPeriod,
|
||||
TokenBackslash,
|
||||
TokenEnd,
|
||||
} TOKEN;
|
||||
|
||||
|
||||
typedef enum {
|
||||
stCabinetName,
|
||||
stCabinetNameTemplate,
|
||||
stDiskLabel,
|
||||
stDiskLabelTemplate,
|
||||
stMaxDiskSize
|
||||
} SETTYPE;
|
||||
|
||||
|
||||
typedef enum {
|
||||
ntDisk,
|
||||
ntCabinet,
|
||||
ntFolder,
|
||||
} NEWTYPE;
|
||||
|
||||
|
||||
/* Classes */
|
||||
|
||||
class CDFParser : public CCabinet {
|
||||
public:
|
||||
CDFParser();
|
||||
virtual ~CDFParser();
|
||||
ULONG Load(LPTSTR FileName);
|
||||
ULONG Parse();
|
||||
private:
|
||||
/* Event handlers */
|
||||
virtual BOOL OnDiskLabel(ULONG Number, LPTSTR Label);
|
||||
virtual BOOL OnCabinetName(ULONG Number, LPTSTR Name);
|
||||
|
||||
BOOL SetDiskName(PCABINET_NAME *List, ULONG Number, LPTSTR String);
|
||||
BOOL GetDiskName(PCABINET_NAME *List, ULONG Number, LPTSTR String);
|
||||
BOOL SetDiskNumber(PDISK_NUMBER *List, ULONG Number, ULONG Value);
|
||||
BOOL GetDiskNumber(PDISK_NUMBER *List, ULONG Number, PULONG Value);
|
||||
BOOL DoDiskLabel(ULONG Number, LPTSTR Label);
|
||||
VOID DoDiskLabelTemplate(LPTSTR Template);
|
||||
BOOL DoCabinetName(ULONG Number, LPTSTR Name);
|
||||
VOID DoCabinetNameTemplate(LPTSTR Template);
|
||||
ULONG DoMaxDiskSize(BOOL NumberValid, ULONG Number);
|
||||
ULONG SetupNewDisk();
|
||||
ULONG PerformSetCommand();
|
||||
ULONG PerformNewCommand();
|
||||
ULONG PerformCommand();
|
||||
ULONG PerformFileCopy();
|
||||
VOID SkipSpaces();
|
||||
BOOL IsNextToken(TOKEN Token, BOOL NoSpaces);
|
||||
BOOL ReadLine();
|
||||
VOID NextToken();
|
||||
/* Parsing */
|
||||
BOOL FileLoaded;
|
||||
HANDLE FileHandle;
|
||||
PCHAR FileBuffer;
|
||||
DWORD FileBufferSize;
|
||||
ULONG CurrentOffset;
|
||||
TCHAR Line[128];
|
||||
ULONG LineLength;
|
||||
ULONG CurrentLine;
|
||||
ULONG CurrentChar;
|
||||
/* Token */
|
||||
TOKEN CurrentToken;
|
||||
ULONG CurrentInteger;
|
||||
TCHAR CurrentString[256];
|
||||
|
||||
/* State */
|
||||
BOOL CabinetCreated;
|
||||
BOOL DiskCreated;
|
||||
BOOL FolderCreated;
|
||||
/* Standard directive variable */
|
||||
BOOL Cabinet;
|
||||
ULONG CabinetFileCountThreshold;
|
||||
PCABINET_NAME CabinetName;
|
||||
BOOL CabinetNameTemplateSet;
|
||||
TCHAR CabinetNameTemplate[128];
|
||||
BOOL Compress;
|
||||
ULONG CompressionType;
|
||||
PCABINET_NAME DiskLabel;
|
||||
BOOL DiskLabelTemplateSet;
|
||||
TCHAR DiskLabelTemplate[128];
|
||||
ULONG FolderFileCountThreshold;
|
||||
ULONG FolderSizeThreshold;
|
||||
ULONG MaxCabinetSize;
|
||||
ULONG MaxDiskFileCount;
|
||||
PDISK_NUMBER MaxDiskSize;
|
||||
BOOL MaxDiskSizeAllSet;
|
||||
ULONG MaxDiskSizeAll;
|
||||
ULONG ReservePerCabinetSize;
|
||||
ULONG ReservePerDataBlockSize;
|
||||
ULONG ReservePerFolderSize;
|
||||
TCHAR SourceDir[256];
|
||||
};
|
||||
|
||||
#endif /* __DFP_H */
|
||||
|
||||
/* EOF */
|
@@ -1,493 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS cabinet manager
|
||||
* FILE: apps/cabman/main.cpp
|
||||
* PURPOSE: Main program
|
||||
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
* REVISIONS:
|
||||
* CSH 21/03-2001 Created
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <windows.h>
|
||||
#include <reactos/buildno.h>
|
||||
#include "cabman.h"
|
||||
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
DWORD DebugTraceLevel = MIN_TRACE;
|
||||
//DWORD DebugTraceLevel = MID_TRACE;
|
||||
//DWORD DebugTraceLevel = MAX_TRACE;
|
||||
|
||||
#endif /* DBG */
|
||||
|
||||
|
||||
#define CM_VERSION KERNEL_VERSION_STR
|
||||
|
||||
|
||||
LPTSTR Pad(LPTSTR Str, CHAR PadChar, UINT Length)
|
||||
/*
|
||||
* FUNCTION: Pads a string with a character to make a given length
|
||||
* ARGUMENTS:
|
||||
* Str = Pointer to string to pad
|
||||
* PadChar = Character to pad with
|
||||
* Length = Disired length of string
|
||||
* RETURNS:
|
||||
* Pointer to string
|
||||
* NOTES:
|
||||
* Str must be at least Length + 1 bytes
|
||||
*/
|
||||
{
|
||||
UINT Len;
|
||||
|
||||
Len = lstrlen(Str);
|
||||
|
||||
if (Len < Length) {
|
||||
memcpy(&Str[Length - Len], Str, Len + 1);
|
||||
memset(Str, PadChar, Length - Len);
|
||||
}
|
||||
return Str;
|
||||
}
|
||||
|
||||
|
||||
LPTSTR Date2Str(LPTSTR Str, WORD Date)
|
||||
/*
|
||||
* FUNCTION: Converts a DOS style date to a string
|
||||
* ARGUMENTS:
|
||||
* Str = Pointer to destination string
|
||||
* Date = DOS style date
|
||||
* RETURNS:
|
||||
* Pointer to string
|
||||
*/
|
||||
{
|
||||
DWORD dw;
|
||||
|
||||
/* Month */
|
||||
Str[0] = (CHAR)('0' + ((Date & 0x01E0) >> 5) / 10);
|
||||
Str[1] = (CHAR)('0' + ((Date & 0x01E0) >> 5) % 10);
|
||||
Str[2] = '-';
|
||||
/* Day */
|
||||
Str[3] = (CHAR)('0' + (Date & 0x001F) / 10);
|
||||
Str[4] = (CHAR)('0' + (Date & 0x001F) % 10);
|
||||
Str[5] = '-';
|
||||
/* Year */
|
||||
dw = 1980 + ((Date & 0xFE00) >> 9);
|
||||
Str[6] = (CHAR)('0' + dw / 1000); dw %= 1000;
|
||||
Str[7] = (CHAR)('0' + dw / 100); dw %= 100;
|
||||
Str[8] = (CHAR)('0' + dw / 10); dw %= 10;
|
||||
Str[9] = (CHAR)('0' + dw % 10);
|
||||
Str[10] = '\0';
|
||||
return Str;
|
||||
}
|
||||
|
||||
|
||||
LPTSTR Time2Str(LPTSTR Str, WORD Time)
|
||||
/*
|
||||
* FUNCTION: Converts a DOS style time to a string
|
||||
* ARGUMENTS:
|
||||
* Str = Pointer to destination string
|
||||
* Time = DOS style time
|
||||
* RETURNS:
|
||||
* Pointer to string
|
||||
*/
|
||||
{
|
||||
BOOL PM;
|
||||
DWORD Hour;
|
||||
DWORD dw;
|
||||
|
||||
Hour = ((Time & 0xF800) >> 11);
|
||||
PM = (Hour >= 12);
|
||||
Hour %= 12;
|
||||
if (Hour == 0)
|
||||
Hour = 12;
|
||||
|
||||
if (Hour >= 10)
|
||||
Str[0] = (CHAR)('0' + Hour / 10);
|
||||
else Str[0] = ' ';
|
||||
Str[1] = (CHAR)('0' + Hour % 10);
|
||||
Str[2] = ':';
|
||||
/* Minute */
|
||||
Str[3] = (CHAR)('0' + ((Time & 0x07E0) >> 5) / 10);
|
||||
Str[4] = (CHAR)('0' + ((Time & 0x07E0) >> 5) % 10);
|
||||
Str[5] = ':';
|
||||
/* Second */
|
||||
dw = 2 * (Time & 0x001F);
|
||||
Str[6] = (CHAR)('0' + dw / 10);
|
||||
Str[7] = (CHAR)('0' + dw % 10);
|
||||
|
||||
Str[8] = PM? 'p' : 'a';
|
||||
Str[9] = '\0';
|
||||
return Str;
|
||||
}
|
||||
|
||||
|
||||
LPTSTR Attr2Str(LPTSTR Str, WORD Attr)
|
||||
/*
|
||||
* FUNCTION: Converts attributes to a string
|
||||
* ARGUMENTS:
|
||||
* Str = Pointer to destination string
|
||||
* Attr = Attributes
|
||||
* RETURNS:
|
||||
* Pointer to string
|
||||
*/
|
||||
{
|
||||
/* Archive */
|
||||
if (Attr & CAB_ATTRIB_ARCHIVE)
|
||||
Str[0] = 'A';
|
||||
else
|
||||
Str[0] = '-';
|
||||
|
||||
/* Hidden */
|
||||
if (Attr & CAB_ATTRIB_HIDDEN)
|
||||
Str[1] = 'H';
|
||||
else
|
||||
Str[1] = '-';
|
||||
|
||||
/* Read only */
|
||||
if (Attr & CAB_ATTRIB_READONLY)
|
||||
Str[2] = 'R';
|
||||
else
|
||||
Str[2] = '-';
|
||||
|
||||
/* System */
|
||||
if (Attr & CAB_ATTRIB_SYSTEM)
|
||||
Str[3] = 'S';
|
||||
else
|
||||
Str[3] = '-';
|
||||
|
||||
Str[4] = '\0';
|
||||
return Str;
|
||||
}
|
||||
|
||||
|
||||
/* CCABManager */
|
||||
|
||||
CCABManager::CCABManager()
|
||||
/*
|
||||
* FUNCTION: Default constructor
|
||||
*/
|
||||
{
|
||||
ProcessAll = FALSE;
|
||||
Mode = CM_MODE_DISPLAY;
|
||||
PromptOnOverwrite = TRUE;
|
||||
}
|
||||
|
||||
|
||||
CCABManager::~CCABManager()
|
||||
/*
|
||||
* FUNCTION: Default destructor
|
||||
*/
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
VOID CCABManager::Usage()
|
||||
/*
|
||||
* FUNCTION: Display usage information on screen
|
||||
*/
|
||||
{
|
||||
printf("ReactOS Cabinet Manager - Version %s\n\n", CM_VERSION);
|
||||
printf("CABMAN [/D | /E] [/A] [/L dir] [/Y] cabinet [filename ...]\n");
|
||||
printf("CABMAN /C dirfile\n");
|
||||
printf(" cabinet Cabinet file.\n");
|
||||
printf(" filename Name of the file to extract from the cabinet.\n");
|
||||
printf(" Wild cards and multiple filenames\n");
|
||||
printf(" (separated by blanks) may be used.\n\n");
|
||||
printf(" dirfile Name of the directive file to use.\n\n");
|
||||
|
||||
|
||||
printf(" /A Process ALL cabinets. Follows cabinet chain\n");
|
||||
printf(" starting in first cabinet mentioned.\n");
|
||||
printf(" /C Create cabinet.\n");
|
||||
printf(" /D Display cabinet directory.\n");
|
||||
printf(" /E Extract files from cabinet.\n");
|
||||
printf(" /L dir Location to place extracted files\n");
|
||||
printf(" (default is current directory).\n");
|
||||
printf(" /Y Do not prompt before overwriting an existing file.\n\n");
|
||||
}
|
||||
|
||||
|
||||
BOOL CCABManager::ParseCmdline(INT argc, PCHAR argv[])
|
||||
/*
|
||||
* FUNCTION: Parse command line arguments
|
||||
* ARGUMENTS:
|
||||
* argc = Number of arguments on command line
|
||||
* argv = Pointer to list of command line arguments
|
||||
* RETURNS:
|
||||
* TRUE if command line arguments was successfully parsed, false if not
|
||||
*/
|
||||
{
|
||||
INT i;
|
||||
BOOL ShowUsage;
|
||||
BOOL FoundCabinet = FALSE;
|
||||
|
||||
ShowUsage = (argc < 2);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '/') {
|
||||
switch (argv[i][1]) {
|
||||
case 'a':
|
||||
case 'A': ProcessAll = TRUE; break;
|
||||
case 'c':
|
||||
case 'C': Mode = CM_MODE_CREATE; break;
|
||||
case 'd':
|
||||
case 'D': Mode = CM_MODE_DISPLAY; break;
|
||||
case 'e':
|
||||
case 'E': Mode = CM_MODE_EXTRACT; break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
if (argv[i][2] == ' ') {
|
||||
i++;
|
||||
SetDestinationPath((LPTSTR)&argv[i][0]);
|
||||
} else
|
||||
SetDestinationPath((LPTSTR)&argv[i][1]);
|
||||
break;
|
||||
case 'y':
|
||||
case 'Y': PromptOnOverwrite = FALSE; break;
|
||||
default:
|
||||
printf("Bad parameter %s.\n", argv[i]);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
if ((FoundCabinet) || (Mode == CM_MODE_CREATE)) {
|
||||
/* FIXME: There may be many of these if Mode != CM_MODE_CREATE */
|
||||
lstrcpy((LPTSTR)FileName, argv[i]);
|
||||
} else {
|
||||
SetCabinetName(argv[i]);
|
||||
FoundCabinet = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ShowUsage) {
|
||||
Usage();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* FIXME */
|
||||
SelectCodec(CAB_CODEC_MSZIP);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
VOID CCABManager::CreateCabinet()
|
||||
/*
|
||||
* FUNCTION: Create cabinet
|
||||
*/
|
||||
{
|
||||
ULONG Status;
|
||||
|
||||
Status = Load((LPTSTR)&FileName);
|
||||
if (Status != CAB_STATUS_SUCCESS) {
|
||||
printf("Specified directive file could not be found: %s.\n", (LPTSTR)&FileName);
|
||||
return;
|
||||
}
|
||||
|
||||
Parse();
|
||||
}
|
||||
|
||||
|
||||
VOID CCABManager::DisplayCabinet()
|
||||
/*
|
||||
* FUNCTION: Display cabinet contents
|
||||
*/
|
||||
{
|
||||
CAB_SEARCH Search;
|
||||
TCHAR Str[20];
|
||||
DWORD FileCount = 0;
|
||||
DWORD ByteCount = 0;
|
||||
|
||||
if (Open() == CAB_STATUS_SUCCESS) {
|
||||
printf("Cabinet %s\n\n", GetCabinetName());
|
||||
|
||||
if (FindFirst("", &Search) == CAB_STATUS_SUCCESS) {
|
||||
do {
|
||||
if (Search.File->FileControlID != CAB_FILE_CONTINUED) {
|
||||
printf("%s ", Date2Str((LPTSTR)&Str, Search.File->FileDate));
|
||||
printf("%s ", Time2Str((LPTSTR)&Str, Search.File->FileTime));
|
||||
printf("%s ", Attr2Str((LPTSTR)&Str, Search.File->Attributes));
|
||||
printf("%s ", Pad(itoa(Search.File->FileSize, (LPTSTR)&Str, 10), ' ', 13));
|
||||
printf("%s\n", Search.FileName);
|
||||
|
||||
FileCount++;
|
||||
ByteCount += Search.File->FileSize;
|
||||
}
|
||||
} while (FindNext(&Search) == CAB_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
if (FileCount > 0) {
|
||||
if (FileCount == 1)
|
||||
printf(" 1 file ");
|
||||
else
|
||||
printf(" %s files ",
|
||||
Pad(itoa(FileCount, (LPTSTR)&Str, 10), ' ', 12));
|
||||
|
||||
if (ByteCount == 1)
|
||||
printf(" 1 byte\n");
|
||||
else
|
||||
printf("%s bytes\n",
|
||||
Pad(itoa(ByteCount, (LPTSTR)&Str, 10), ' ', 12));
|
||||
} else {
|
||||
/* There should be at least one file in a cabinet */
|
||||
printf("No files in cabinet.");
|
||||
}
|
||||
} else
|
||||
printf("Cannot not open file: %s\n", GetCabinetName());
|
||||
}
|
||||
|
||||
|
||||
VOID CCABManager::ExtractFromCabinet()
|
||||
/*
|
||||
* FUNCTION: Extract file(s) from cabinet
|
||||
*/
|
||||
{
|
||||
CAB_SEARCH Search;
|
||||
ULONG Status;
|
||||
|
||||
if (Open() == CAB_STATUS_SUCCESS) {
|
||||
printf("Cabinet %s\n\n", GetCabinetName());
|
||||
|
||||
if (FindFirst("", &Search) == CAB_STATUS_SUCCESS) {
|
||||
do {
|
||||
switch (Status = ExtractFile(Search.FileName)) {
|
||||
case CAB_STATUS_SUCCESS:
|
||||
break;
|
||||
case CAB_STATUS_INVALID_CAB:
|
||||
printf("Cabinet contains errors.\n");
|
||||
return;
|
||||
case CAB_STATUS_UNSUPPCOMP:
|
||||
printf("Cabinet uses unsupported compression type.\n");
|
||||
return;
|
||||
case CAB_STATUS_CANNOT_WRITE:
|
||||
printf("You've run out of free space on the destination volume or the volume is damaged.\n");
|
||||
return;
|
||||
default:
|
||||
printf("Unspecified error code (%d).\n", (UINT)Status);
|
||||
return;
|
||||
}
|
||||
} while (FindNext(&Search) == CAB_STATUS_SUCCESS);
|
||||
}
|
||||
} else
|
||||
printf("Cannot not open file: %s.\n", GetCabinetName());
|
||||
}
|
||||
|
||||
|
||||
VOID CCABManager::Run()
|
||||
/*
|
||||
* FUNCTION: Process cabinet
|
||||
*/
|
||||
{
|
||||
printf("ReactOS Cabinet Manager - Version %s\n\n", CM_VERSION);
|
||||
|
||||
switch (Mode) {
|
||||
case CM_MODE_CREATE: CreateCabinet(); break;
|
||||
case CM_MODE_DISPLAY: DisplayCabinet(); break;
|
||||
case CM_MODE_EXTRACT: ExtractFromCabinet(); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
/* Event handlers */
|
||||
|
||||
BOOL CCABManager::OnOverwrite(PCFFILE File,
|
||||
LPTSTR FileName)
|
||||
/*
|
||||
* FUNCTION: Called when extracting a file and it already exists
|
||||
* ARGUMENTS:
|
||||
* File = Pointer to CFFILE for file being extracted
|
||||
* Filename = Pointer to buffer with name of file (full path)
|
||||
* RETURNS
|
||||
* TRUE if the file should be overwritten, FALSE if not
|
||||
*/
|
||||
{
|
||||
TCHAR ch;
|
||||
|
||||
if (Mode == CM_MODE_CREATE)
|
||||
return TRUE;
|
||||
|
||||
/* Should we prompt on overwrite? */
|
||||
if (!PromptOnOverwrite)
|
||||
return TRUE;
|
||||
|
||||
/* Ask if file should be overwritten */
|
||||
printf("Overwrite %s (Yes/No/All)? ", GetFileName(FileName));
|
||||
|
||||
for (;;) {
|
||||
ch = _getch();
|
||||
switch (ch) {
|
||||
case 'Y':
|
||||
case 'y': printf("%c\n", ch); return TRUE;
|
||||
case 'N':
|
||||
case 'n': printf("%c\n", ch); return FALSE;
|
||||
case 'A':
|
||||
case 'a': printf("%c\n", ch); PromptOnOverwrite = FALSE; return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID CCABManager::OnExtract(PCFFILE File,
|
||||
LPTSTR FileName)
|
||||
/*
|
||||
* FUNCTION: Called just before extracting a file
|
||||
* ARGUMENTS:
|
||||
* File = Pointer to CFFILE for file being extracted
|
||||
* FileName = Pointer to buffer with name of file (full path)
|
||||
*/
|
||||
{
|
||||
printf("Extracting %s\n", GetFileName(FileName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID CCABManager::OnDiskChange(LPTSTR CabinetName,
|
||||
LPTSTR DiskLabel)
|
||||
/*
|
||||
* FUNCTION: Called when a new disk is to be processed
|
||||
* ARGUMENTS:
|
||||
* CabinetName = Pointer to buffer with name of cabinet
|
||||
* DiskLabel = Pointer to buffer with label of disk
|
||||
*/
|
||||
{
|
||||
printf("\nChanging to cabinet %s - %s\n\n", CabinetName, DiskLabel);
|
||||
}
|
||||
|
||||
|
||||
VOID CCABManager::OnAdd(PCFFILE File,
|
||||
LPTSTR FileName)
|
||||
/*
|
||||
* FUNCTION: Called just before adding a file to a cabinet
|
||||
* ARGUMENTS:
|
||||
* File = Pointer to CFFILE for file being added
|
||||
* FileName = Pointer to buffer with name of file (full path)
|
||||
*/
|
||||
{
|
||||
printf("Adding %s\n", GetFileName(FileName));
|
||||
}
|
||||
|
||||
|
||||
INT main(INT argc, PCHAR argv[])
|
||||
/*
|
||||
* FUNCTION: Main entry point
|
||||
* ARGUMENTS:
|
||||
* argc = Number of arguments on command line
|
||||
* argv = Pointer to list of command line arguments
|
||||
*/
|
||||
{
|
||||
CCABManager CABMgr;
|
||||
|
||||
if (CABMgr.ParseCmdline(argc, argv))
|
||||
CABMgr.Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
@@ -1,60 +0,0 @@
|
||||
#
|
||||
# Makefile for ReactOS Cabinet Manager
|
||||
#
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
ZLIB_OBJECTS = zlib/adler32.o zlib/deflate.o zlib/infblock.o zlib/infcodes.o \
|
||||
zlib/inflate.o zlib/inftrees.o zlib/infutil.o zlib/inffast.o \
|
||||
zlib/trees.o zlib/zutil.o
|
||||
ENGINE_OBJECTS = $(ZLIB_OBJECTS) cabinet.o mszip.o raw.o
|
||||
TEST_OBJECTS = $(ENGINE_OBJECTS) test.o
|
||||
OBJECTS = $(ENGINE_OBJECTS) main.o dfp.o
|
||||
TARGET = cabman
|
||||
PROGS = $(TARGET).exe test.exe
|
||||
|
||||
CFLAGS += -O3
|
||||
|
||||
ifeq ($(DOSCLI),yes)
|
||||
CLEAN_FILES = *.o zlib\*.o $(TARGET).exe $(TARGET).sym test.exe test.sym
|
||||
else
|
||||
CLEAN_FILES = *.o zlib/*.o $(TARGET).exe $(TARGET).sym test.exe test.sym
|
||||
endif
|
||||
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
clean: $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
$(CLEAN_FILES:%=%_clean): %_clean:
|
||||
- $(RM) $*
|
||||
|
||||
.phony: clean $(CLEAN_FILES:%=%_clean)
|
||||
|
||||
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
ifeq ($(DOSCLI),yes)
|
||||
$(CP) $* $(FLOPPY_DIR)\apps\$*
|
||||
else
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
endif
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
ifeq ($(DOSCLI),yes)
|
||||
$(CP) $* ..\..\$(DIST_DIR)\apps\$*
|
||||
else
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
endif
|
||||
|
||||
$(TARGET).exe: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -o $(TARGET).exe
|
||||
$(NM) --numeric-sort $(TARGET).exe > $(TARGET).sym
|
||||
|
||||
test.exe: $(TEST_OBJECTS)
|
||||
$(CC) $(TEST_OBJECTS) -o test.exe
|
||||
$(NM) --numeric-sort test.exe > test.sym
|
||||
|
||||
include ../../rules.mak
|
||||
|
@@ -1,172 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS cabinet manager
|
||||
* FILE: apps/cabman/mszip.cpp
|
||||
* PURPOSE: CAB codec for MSZIP compressed data
|
||||
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
* NOTES: The ZLIB does the real work. Get the full version
|
||||
* from http://www.cdrom.com/pub/infozip/zlib/
|
||||
* REVISIONS:
|
||||
* CSH 21/03-2001 Created
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "mszip.h"
|
||||
|
||||
|
||||
/* Memory functions */
|
||||
|
||||
voidpf MSZipAlloc(voidpf opaque, uInt items, uInt size)
|
||||
{
|
||||
DPRINT(DEBUG_MEMORY, ("items = (%d) size = (%d)\n", items, size));
|
||||
return HeapAlloc(GetProcessHeap(), 0, items * size);
|
||||
}
|
||||
|
||||
void MSZipFree (voidpf opaque, voidpf address)
|
||||
{
|
||||
DPRINT(DEBUG_MEMORY, ("\n"));
|
||||
HeapFree(GetProcessHeap(), 0, address);
|
||||
}
|
||||
|
||||
|
||||
/* CMSZipCodec */
|
||||
|
||||
CMSZipCodec::CMSZipCodec()
|
||||
/*
|
||||
* FUNCTION: Default constructor
|
||||
*/
|
||||
{
|
||||
ZStream.zalloc = MSZipAlloc;
|
||||
ZStream.zfree = MSZipFree;
|
||||
ZStream.opaque = (voidpf)0;
|
||||
}
|
||||
|
||||
|
||||
CMSZipCodec::~CMSZipCodec()
|
||||
/*
|
||||
* FUNCTION: Default destructor
|
||||
*/
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ULONG CMSZipCodec::Compress(PVOID OutputBuffer,
|
||||
PVOID InputBuffer,
|
||||
DWORD InputLength,
|
||||
PDWORD OutputLength)
|
||||
/*
|
||||
* FUNCTION: Compresses data in a buffer
|
||||
* ARGUMENTS:
|
||||
* OutputBuffer = Pointer to buffer to place compressed data
|
||||
* InputBuffer = Pointer to buffer with data to be compressed
|
||||
* InputLength = Length of input buffer
|
||||
* OutputLength = Address of buffer to place size of compressed data
|
||||
*/
|
||||
{
|
||||
PUSHORT Magic;
|
||||
|
||||
DPRINT(MAX_TRACE, ("InputLength (%d).\n", InputLength));
|
||||
|
||||
Magic = (PUSHORT)OutputBuffer;
|
||||
*Magic = MSZIP_MAGIC;
|
||||
|
||||
ZStream.next_in = (PUCHAR)InputBuffer;
|
||||
ZStream.avail_in = InputLength;
|
||||
ZStream.next_out = (PUCHAR)((ULONG)OutputBuffer + 2);
|
||||
ZStream.avail_out = CAB_BLOCKSIZE + 12;
|
||||
|
||||
/* WindowBits is passed < 0 to tell that there is no zlib header */
|
||||
Status = deflateInit2(&ZStream,
|
||||
Z_BEST_COMPRESSION,
|
||||
Z_DEFLATED,
|
||||
-MAX_WBITS,
|
||||
8, /* memLevel */
|
||||
Z_DEFAULT_STRATEGY);
|
||||
if (Status != Z_OK) {
|
||||
DPRINT(MIN_TRACE, ("deflateInit() returned (%d).\n", Status));
|
||||
return CS_NOMEMORY;
|
||||
}
|
||||
|
||||
Status = deflate(&ZStream, Z_FINISH);
|
||||
if ((Status != Z_OK) && (Status != Z_STREAM_END)) {
|
||||
DPRINT(MIN_TRACE, ("deflate() returned (%d) (%s).\n", Status, ZStream.msg));
|
||||
if (Status == Z_MEM_ERROR)
|
||||
return CS_NOMEMORY;
|
||||
return CS_BADSTREAM;
|
||||
}
|
||||
|
||||
*OutputLength = ZStream.total_out + 2;
|
||||
|
||||
Status = deflateEnd(&ZStream);
|
||||
if (Status != Z_OK) {
|
||||
DPRINT(MIN_TRACE, ("deflateEnd() returned (%d).\n", Status));
|
||||
return CS_BADSTREAM;
|
||||
}
|
||||
|
||||
return CS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ULONG CMSZipCodec::Uncompress(PVOID OutputBuffer,
|
||||
PVOID InputBuffer,
|
||||
DWORD InputLength,
|
||||
PDWORD OutputLength)
|
||||
/*
|
||||
* FUNCTION: Uncompresses data in a buffer
|
||||
* ARGUMENTS:
|
||||
* OutputBuffer = Pointer to buffer to place uncompressed data
|
||||
* InputBuffer = Pointer to buffer with data to be uncompressed
|
||||
* InputLength = Length of input buffer
|
||||
* OutputLength = Address of buffer to place size of uncompressed data
|
||||
*/
|
||||
{
|
||||
USHORT Magic;
|
||||
|
||||
DPRINT(MAX_TRACE, ("InputLength (%d).\n", InputLength));
|
||||
|
||||
Magic = *((PUSHORT)InputBuffer);
|
||||
|
||||
if (Magic != MSZIP_MAGIC) {
|
||||
DPRINT(MID_TRACE, ("Bad MSZIP block header magic (0x%X)\n", Magic));
|
||||
return CS_BADSTREAM;
|
||||
}
|
||||
|
||||
ZStream.next_in = (PUCHAR)((ULONG)InputBuffer + 2);
|
||||
ZStream.avail_in = InputLength - 2;
|
||||
ZStream.next_out = (PUCHAR)OutputBuffer;
|
||||
ZStream.avail_out = CAB_BLOCKSIZE + 12;
|
||||
|
||||
/* WindowBits is passed < 0 to tell that there is no zlib header.
|
||||
* Note that in this case inflate *requires* an extra "dummy" byte
|
||||
* after the compressed stream in order to complete decompression and
|
||||
* return Z_STREAM_END.
|
||||
*/
|
||||
Status = inflateInit2(&ZStream, -MAX_WBITS);
|
||||
if (Status != Z_OK) {
|
||||
DPRINT(MIN_TRACE, ("inflateInit2() returned (%d).\n", Status));
|
||||
return CS_BADSTREAM;
|
||||
}
|
||||
|
||||
while ((ZStream.total_out < CAB_BLOCKSIZE + 12) &&
|
||||
(ZStream.total_in < InputLength - 2)) {
|
||||
Status = inflate(&ZStream, Z_NO_FLUSH);
|
||||
if (Status == Z_STREAM_END) break;
|
||||
if (Status != Z_OK) {
|
||||
DPRINT(MIN_TRACE, ("inflate() returned (%d) (%s).\n", Status, ZStream.msg));
|
||||
if (Status == Z_MEM_ERROR)
|
||||
return CS_NOMEMORY;
|
||||
return CS_BADSTREAM;
|
||||
}
|
||||
}
|
||||
|
||||
*OutputLength = ZStream.total_out;
|
||||
|
||||
Status = inflateEnd(&ZStream);
|
||||
if (Status != Z_OK) {
|
||||
DPRINT(MIN_TRACE, ("inflateEnd() returned (%d).\n", Status));
|
||||
return CS_BADSTREAM;
|
||||
}
|
||||
return CS_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS cabinet manager
|
||||
* FILE: apps/cabman/mszip.h
|
||||
* PURPOSE: CAB codec for MSZIP compressed data
|
||||
*/
|
||||
#ifndef __MSZIP_H
|
||||
#define __MSZIP_H
|
||||
|
||||
#include "cabinet.h"
|
||||
#include "zlib/zlib.h"
|
||||
|
||||
#define MSZIP_MAGIC 0x4B43
|
||||
|
||||
|
||||
/* Classes */
|
||||
|
||||
class CMSZipCodec : public CCABCodec {
|
||||
public:
|
||||
/* Default constructor */
|
||||
CMSZipCodec();
|
||||
/* Default destructor */
|
||||
virtual ~CMSZipCodec();
|
||||
/* Compresses a data block */
|
||||
virtual ULONG Compress(PVOID OutputBuffer,
|
||||
PVOID InputBuffer,
|
||||
DWORD InputLength,
|
||||
PDWORD OutputLength);
|
||||
/* Uncompresses a data block */
|
||||
virtual ULONG Uncompress(PVOID OutputBuffer,
|
||||
PVOID InputBuffer,
|
||||
DWORD InputLength,
|
||||
PDWORD OutputLength);
|
||||
private:
|
||||
INT Status;
|
||||
z_stream ZStream; /* Zlib stream */
|
||||
};
|
||||
|
||||
#endif /* __MSZIP_H */
|
||||
|
||||
/* EOF */
|
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS cabinet manager
|
||||
* FILE: apps/cabman/raw.cpp
|
||||
* PURPOSE: CAB codec for uncompressed "raw" data
|
||||
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
* REVISIONS:
|
||||
* CSH 21/03-2001 Created
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include "raw.h"
|
||||
|
||||
|
||||
/* CRawCodec */
|
||||
|
||||
CRawCodec::CRawCodec()
|
||||
/*
|
||||
* FUNCTION: Default constructor
|
||||
*/
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CRawCodec::~CRawCodec()
|
||||
/*
|
||||
* FUNCTION: Default destructor
|
||||
*/
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ULONG CRawCodec::Compress(PVOID OutputBuffer,
|
||||
PVOID InputBuffer,
|
||||
DWORD InputLength,
|
||||
PDWORD OutputLength)
|
||||
/*
|
||||
* FUNCTION: Compresses data in a buffer
|
||||
* ARGUMENTS:
|
||||
* OutputBuffer = Pointer to buffer to place compressed data
|
||||
* InputBuffer = Pointer to buffer with data to be compressed
|
||||
* InputLength = Length of input buffer
|
||||
* OutputLength = Address of buffer to place size of compressed data
|
||||
*/
|
||||
{
|
||||
CopyMemory(OutputBuffer, InputBuffer, InputLength);
|
||||
*OutputLength = InputLength;
|
||||
return CS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ULONG CRawCodec::Uncompress(PVOID OutputBuffer,
|
||||
PVOID InputBuffer,
|
||||
DWORD InputLength,
|
||||
PDWORD OutputLength)
|
||||
/*
|
||||
* FUNCTION: Uncompresses data in a buffer
|
||||
* ARGUMENTS:
|
||||
* OutputBuffer = Pointer to buffer to place uncompressed data
|
||||
* InputBuffer = Pointer to buffer with data to be uncompressed
|
||||
* InputLength = Length of input buffer
|
||||
* OutputLength = Address of buffer to place size of uncompressed data
|
||||
*/
|
||||
{
|
||||
CopyMemory(OutputBuffer, InputBuffer, InputLength);
|
||||
*OutputLength = InputLength;
|
||||
return CS_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS cabinet manager
|
||||
* FILE: apps/cabman/raw.h
|
||||
* PURPOSE: CAB codec for uncompressed data
|
||||
*/
|
||||
#ifndef __RAW_H
|
||||
#define __RAW_H
|
||||
|
||||
#include "cabinet.h"
|
||||
|
||||
|
||||
/* Classes */
|
||||
|
||||
class CRawCodec : public CCABCodec {
|
||||
public:
|
||||
/* Default constructor */
|
||||
CRawCodec();
|
||||
/* Default destructor */
|
||||
virtual ~CRawCodec();
|
||||
/* Compresses a data block */
|
||||
virtual ULONG Compress(PVOID OutputBuffer,
|
||||
PVOID InputBuffer,
|
||||
DWORD InputLength,
|
||||
PDWORD OutputLength);
|
||||
/* Uncompresses a data block */
|
||||
virtual ULONG Uncompress(PVOID OutputBuffer,
|
||||
PVOID InputBuffer,
|
||||
DWORD InputLength,
|
||||
PDWORD OutputLength);
|
||||
};
|
||||
|
||||
#endif /* __RAW_H */
|
||||
|
||||
/* EOF */
|
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: Test program for cabinet classes
|
||||
* FILE: apps/cabman/test.cpp
|
||||
* PURPOSE: Test program
|
||||
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
* REVISIONS:
|
||||
* CSH 21/03-2001 Created
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <windows.h>
|
||||
#include "test.h"
|
||||
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
DWORD DebugTraceLevel = MIN_TRACE;
|
||||
//DWORD DebugTraceLevel = MID_TRACE;
|
||||
//DWORD DebugTraceLevel = MAX_TRACE;
|
||||
|
||||
#endif /* DBG */
|
||||
|
||||
|
||||
/* CCABManager */
|
||||
|
||||
CCABTest::CCABTest()
|
||||
/*
|
||||
* FUNCTION: Default constructor
|
||||
*/
|
||||
{
|
||||
PromptOnOverwrite = FALSE;
|
||||
}
|
||||
|
||||
|
||||
CCABTest::~CCABTest()
|
||||
/*
|
||||
* FUNCTION: Default destructor
|
||||
*/
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
VOID CCABTest::ExtractFromCabinet()
|
||||
/*
|
||||
* FUNCTION: Extract file(s) from cabinet
|
||||
*/
|
||||
{
|
||||
CAB_SEARCH Search;
|
||||
ULONG Status;
|
||||
|
||||
if (Open() == CAB_STATUS_SUCCESS) {
|
||||
printf("Cabinet %s\n\n", GetCabinetName());
|
||||
|
||||
if (FindFirst("", &Search) == CAB_STATUS_SUCCESS) {
|
||||
do {
|
||||
switch (Status = ExtractFile(Search.FileName)) {
|
||||
case CAB_STATUS_SUCCESS:
|
||||
break;
|
||||
case CAB_STATUS_INVALID_CAB:
|
||||
printf("Cabinet contains errors.\n");
|
||||
return;
|
||||
case CAB_STATUS_UNSUPPCOMP:
|
||||
printf("Cabinet uses unsupported compression type.\n");
|
||||
return;
|
||||
case CAB_STATUS_CANNOT_WRITE:
|
||||
printf("You've run out of free space on the destination volume or the volume is damaged.\n");
|
||||
return;
|
||||
default:
|
||||
printf("Unspecified error code (%d).\n", (UINT)Status);
|
||||
return;
|
||||
}
|
||||
} while (FindNext(&Search) == CAB_STATUS_SUCCESS);
|
||||
}
|
||||
} else {
|
||||
printf("Cannot not open file: %s.\n", GetCabinetName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Event handlers */
|
||||
|
||||
BOOL CCABTest::OnOverwrite(PCFFILE File,
|
||||
LPTSTR FileName)
|
||||
/*
|
||||
* FUNCTION: Called when extracting a file and it already exists
|
||||
* ARGUMENTS:
|
||||
* File = Pointer to CFFILE for file being extracted
|
||||
* Filename = Pointer to buffer with name of file (full path)
|
||||
* RETURNS
|
||||
* TRUE if the file should be overwritten, FALSE if not
|
||||
*/
|
||||
{
|
||||
TCHAR ch;
|
||||
|
||||
/* Should we prompt on overwrite? */
|
||||
if (!PromptOnOverwrite)
|
||||
return TRUE;
|
||||
|
||||
/* Ask if file should be overwritten */
|
||||
printf("Overwrite %s (Yes/No/All)? ", GetFileName(FileName));
|
||||
|
||||
for (;;) {
|
||||
ch = _getch();
|
||||
switch (ch) {
|
||||
case 'Y':
|
||||
case 'y': printf("%c\n", ch); return TRUE;
|
||||
case 'N':
|
||||
case 'n': printf("%c\n", ch); return FALSE;
|
||||
case 'A':
|
||||
case 'a': printf("%c\n", ch); PromptOnOverwrite = FALSE; return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID CCABTest::OnExtract(PCFFILE File,
|
||||
LPTSTR FileName)
|
||||
/*
|
||||
* FUNCTION: Called just before extracting a file
|
||||
* ARGUMENTS:
|
||||
* File = Pointer to CFFILE for file being extracted
|
||||
* FileName = Pointer to buffer with name of file (full path)
|
||||
*/
|
||||
{
|
||||
printf("Extracting %s\n", GetFileName(FileName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID CCABTest::OnDiskChange(LPTSTR CabinetName,
|
||||
LPTSTR DiskLabel)
|
||||
/*
|
||||
* FUNCTION: Called when a new disk is to be processed
|
||||
* ARGUMENTS:
|
||||
* CabinetName = Pointer to buffer with name of cabinet
|
||||
* DiskLabel = Pointer to buffer with label of disk
|
||||
*/
|
||||
{
|
||||
printf("\nChanging to cabinet %s - %s\n\n", CabinetName, DiskLabel);
|
||||
}
|
||||
|
||||
|
||||
INT main(INT argc, PCHAR argv[])
|
||||
/*
|
||||
* FUNCTION: Main entry point
|
||||
* ARGUMENTS:
|
||||
* argc = Number of arguments on command line
|
||||
* argv = Pointer to list of command line arguments
|
||||
*/
|
||||
{
|
||||
CCABTest CABTest;
|
||||
|
||||
// Specify your cabinet filename here
|
||||
CABTest.SetCabinetName("ros1.cab");
|
||||
CABTest.ExtractFromCabinet();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: Test program for cabinet classes
|
||||
* FILE: apps/cabman/test.h
|
||||
* PURPOSE: Test program header
|
||||
*/
|
||||
#ifndef __TEST_H
|
||||
#define __TEST_H
|
||||
|
||||
#define CAB_READ_ONLY // Define for smaller read only version
|
||||
#include "cabinet.h"
|
||||
|
||||
|
||||
/* Classes */
|
||||
|
||||
class CCABTest : public CCabinet {
|
||||
public:
|
||||
CCABTest();
|
||||
virtual ~CCABTest();
|
||||
VOID ExtractFromCabinet();
|
||||
/* Event handlers */
|
||||
virtual BOOL OnOverwrite(PCFFILE File, LPTSTR FileName);
|
||||
virtual VOID OnExtract(PCFFILE File, LPTSTR FileName);
|
||||
virtual VOID OnDiskChange(LPTSTR CabinetName, LPTSTR DiskLabel);
|
||||
private:
|
||||
/* Configuration */
|
||||
BOOL PromptOnOverwrite;
|
||||
};
|
||||
|
||||
#endif /* __CABMAN_H */
|
||||
|
||||
/* EOF */
|
@@ -1,475 +0,0 @@
|
||||
|
||||
ChangeLog file for zlib
|
||||
|
||||
Changes (21 March 2001)
|
||||
- Adapted for ReactOS (Casper S. Hornstrup)
|
||||
. Removed all but core zlib itself
|
||||
|
||||
Changes in 1.1.3 (9 July 1998)
|
||||
- fix "an inflate input buffer bug that shows up on rare but persistent
|
||||
occasions" (Mark)
|
||||
- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
|
||||
- fix gzseek(..., SEEK_SET) in write mode
|
||||
- fix crc check after a gzeek (Frank Faubert)
|
||||
- fix miniunzip when the last entry in a zip file is itself a zip file
|
||||
(J Lillge)
|
||||
- add contrib/asm586 and contrib/asm686 (Brian Raiter)
|
||||
See http://www.muppetlabs.com/~breadbox/software/assembly.html
|
||||
- add support for Delphi 3 in contrib/delphi (Bob Dellaca)
|
||||
- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
|
||||
- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
|
||||
- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
|
||||
- added a FAQ file
|
||||
|
||||
- Support gzdopen on Mac with Metrowerks (Jason Linhart)
|
||||
- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart)
|
||||
- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young)
|
||||
- avoid some warnings with Borland C (Tom Tanner)
|
||||
- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant)
|
||||
- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant)
|
||||
- allow several arguments to configure (Tim Mooney, Frodo Looijaard)
|
||||
- use libdir and includedir in Makefile.in (Tim Mooney)
|
||||
- support shared libraries on OSF1 V4 (Tim Mooney)
|
||||
- remove so_locations in "make clean" (Tim Mooney)
|
||||
- fix maketree.c compilation error (Glenn, Mark)
|
||||
- Python interface to zlib now in Python 1.5 (Jeremy Hylton)
|
||||
- new Makefile.riscos (Rich Walker)
|
||||
- initialize static descriptors in trees.c for embedded targets (Nick Smith)
|
||||
- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith)
|
||||
- add the OS/2 files in Makefile.in too (Andrew Zabolotny)
|
||||
- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane)
|
||||
- fix maketree.c to allow clean compilation of inffixed.h (Mark)
|
||||
- fix parameter check in deflateCopy (Gunther Nikl)
|
||||
- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler)
|
||||
- Many portability patches by Christian Spieler:
|
||||
. zutil.c, zutil.h: added "const" for zmem*
|
||||
. Make_vms.com: fixed some typos
|
||||
. Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists
|
||||
. msdos/Makefile.msc: remove "default rtl link library" info from obj files
|
||||
. msdos/Makefile.*: use model-dependent name for the built zlib library
|
||||
. msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc:
|
||||
new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT)
|
||||
- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane)
|
||||
- replace __far with _far for better portability (Christian Spieler, Tom Lane)
|
||||
- fix test for errno.h in configure (Tim Newsham)
|
||||
|
||||
Changes in 1.1.2 (19 March 98)
|
||||
- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant)
|
||||
See http://www.winimage.com/zLibDll/unzip.html
|
||||
- preinitialize the inflate tables for fixed codes, to make the code
|
||||
completely thread safe (Mark)
|
||||
- some simplifications and slight speed-up to the inflate code (Mark)
|
||||
- fix gzeof on non-compressed files (Allan Schrum)
|
||||
- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs)
|
||||
- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn)
|
||||
- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny)
|
||||
- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori)
|
||||
- do not wrap extern "C" around system includes (Tom Lane)
|
||||
- mention zlib binding for TCL in README (Andreas Kupries)
|
||||
- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert)
|
||||
- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson)
|
||||
- allow "configure --prefix $HOME" (Tim Mooney)
|
||||
- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson)
|
||||
- move Makefile.sas to amiga/Makefile.sas
|
||||
|
||||
Changes in 1.1.1 (27 Feb 98)
|
||||
- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson)
|
||||
- remove block truncation heuristic which had very marginal effect for zlib
|
||||
(smaller lit_bufsize than in gzip 1.2.4) and degraded a little the
|
||||
compression ratio on some files. This also allows inlining _tr_tally for
|
||||
matches in deflate_slow.
|
||||
- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier)
|
||||
|
||||
Changes in 1.1.0 (24 Feb 98)
|
||||
- do not return STREAM_END prematurely in inflate (John Bowler)
|
||||
- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler)
|
||||
- compile with -DFASTEST to get compression code optimized for speed only
|
||||
- in minigzip, try mmap'ing the input file first (Miguel Albrecht)
|
||||
- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain
|
||||
on Sun but significant on HP)
|
||||
|
||||
- add a pointer to experimental unzip library in README (Gilles Vollant)
|
||||
- initialize variable gcc in configure (Chris Herborth)
|
||||
|
||||
Changes in 1.0.9 (17 Feb 1998)
|
||||
- added gzputs and gzgets functions
|
||||
- do not clear eof flag in gzseek (Mark Diekhans)
|
||||
- fix gzseek for files in transparent mode (Mark Diekhans)
|
||||
- do not assume that vsprintf returns the number of bytes written (Jens Krinke)
|
||||
- replace EXPORT with ZEXPORT to avoid conflict with other programs
|
||||
- added compress2 in zconf.h, zlib.def, zlib.dnt
|
||||
- new asm code from Gilles Vollant in contrib/asm386
|
||||
- simplify the inflate code (Mark):
|
||||
. Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new()
|
||||
. ZALLOC the length list in inflate_trees_fixed() instead of using stack
|
||||
. ZALLOC the value area for huft_build() instead of using stack
|
||||
. Simplify Z_FINISH check in inflate()
|
||||
|
||||
- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8
|
||||
- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi)
|
||||
- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with
|
||||
the declaration of FAR (Gilles VOllant)
|
||||
- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann)
|
||||
- read_buf buf parameter of type Bytef* instead of charf*
|
||||
- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout)
|
||||
- do not redeclare unlink in minigzip.c for WIN32 (John Bowler)
|
||||
- fix check for presence of directories in "make install" (Ian Willis)
|
||||
|
||||
Changes in 1.0.8 (27 Jan 1998)
|
||||
- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant)
|
||||
- fix gzgetc and gzputc for big endian systems (Markus Oberhumer)
|
||||
- added compress2() to allow setting the compression level
|
||||
- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong)
|
||||
- use constant arrays for the static trees in trees.c instead of computing
|
||||
them at run time (thanks to Ken Raeburn for this suggestion). To create
|
||||
trees.h, compile with GEN_TREES_H and run "make test".
|
||||
- check return code of example in "make test" and display result
|
||||
- pass minigzip command line options to file_compress
|
||||
- simplifying code of inflateSync to avoid gcc 2.8 bug
|
||||
|
||||
- support CC="gcc -Wall" in configure -s (QingLong)
|
||||
- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn)
|
||||
- fix test for shared library support to avoid compiler warnings
|
||||
- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant)
|
||||
- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit)
|
||||
- do not use fdopen for Metrowerks on Mac (Brad Pettit))
|
||||
- add checks for gzputc and gzputc in example.c
|
||||
- avoid warnings in gzio.c and deflate.c (Andreas Kleinert)
|
||||
- use const for the CRC table (Ken Raeburn)
|
||||
- fixed "make uninstall" for shared libraries
|
||||
- use Tracev instead of Trace in infblock.c
|
||||
- in example.c use correct compressed length for test_sync
|
||||
- suppress +vnocompatwarnings in configure for HPUX (not always supported)
|
||||
|
||||
Changes in 1.0.7 (20 Jan 1998)
|
||||
- fix gzseek which was broken in write mode
|
||||
- return error for gzseek to negative absolute position
|
||||
- fix configure for Linux (Chun-Chung Chen)
|
||||
- increase stack space for MSC (Tim Wegner)
|
||||
- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant)
|
||||
- define EXPORTVA for gzprintf (Gilles Vollant)
|
||||
- added man page zlib.3 (Rick Rodgers)
|
||||
- for contrib/untgz, fix makedir() and improve Makefile
|
||||
|
||||
- check gzseek in write mode in example.c
|
||||
- allocate extra buffer for seeks only if gzseek is actually called
|
||||
- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant)
|
||||
- add inflateSyncPoint in zconf.h
|
||||
- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def
|
||||
|
||||
Changes in 1.0.6 (19 Jan 1998)
|
||||
- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and
|
||||
gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)
|
||||
- Fix a deflate bug occuring only with compression level 0 (thanks to
|
||||
Andy Buckler for finding this one).
|
||||
- In minigzip, pass transparently also the first byte for .Z files.
|
||||
- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()
|
||||
- check Z_FINISH in inflate (thanks to Marc Schluper)
|
||||
- Implement deflateCopy (thanks to Adam Costello)
|
||||
- make static libraries by default in configure, add --shared option.
|
||||
- move MSDOS or Windows specific files to directory msdos
|
||||
- suppress the notion of partial flush to simplify the interface
|
||||
(but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4)
|
||||
- suppress history buffer provided by application to simplify the interface
|
||||
(this feature was not implemented anyway in 1.0.4)
|
||||
- next_in and avail_in must be initialized before calling inflateInit or
|
||||
inflateInit2
|
||||
- add EXPORT in all exported functions (for Windows DLL)
|
||||
- added Makefile.nt (thanks to Stephen Williams)
|
||||
- added the unsupported "contrib" directory:
|
||||
contrib/asm386/ by Gilles Vollant <info@winimage.com>
|
||||
386 asm code replacing longest_match().
|
||||
contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
|
||||
A C++ I/O streams interface to the zlib gz* functions
|
||||
contrib/iostream2/ by Tyge L<>vset <Tyge.Lovset@cmr.no>
|
||||
Another C++ I/O streams interface
|
||||
contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
|
||||
A very simple tar.gz file extractor using zlib
|
||||
contrib/visual-basic.txt by Carlos Rios <c_rios@sonda.cl>
|
||||
How to use compress(), uncompress() and the gz* functions from VB.
|
||||
- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression
|
||||
level) in minigzip (thanks to Tom Lane)
|
||||
|
||||
- use const for rommable constants in deflate
|
||||
- added test for gzseek and gztell in example.c
|
||||
- add undocumented function inflateSyncPoint() (hack for Paul Mackerras)
|
||||
- add undocumented function zError to convert error code to string
|
||||
(for Tim Smithers)
|
||||
- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code.
|
||||
- Use default memcpy for Symantec MSDOS compiler.
|
||||
- Add EXPORT keyword for check_func (needed for Windows DLL)
|
||||
- add current directory to LD_LIBRARY_PATH for "make test"
|
||||
- create also a link for libz.so.1
|
||||
- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura)
|
||||
- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX)
|
||||
- added -soname for Linux in configure (Chun-Chung Chen,
|
||||
- assign numbers to the exported functions in zlib.def (for Windows DLL)
|
||||
- add advice in zlib.h for best usage of deflateSetDictionary
|
||||
- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn)
|
||||
- allow compilation with ANSI keywords only enabled for TurboC in large model
|
||||
- avoid "versionString"[0] (Borland bug)
|
||||
- add NEED_DUMMY_RETURN for Borland
|
||||
- use variable z_verbose for tracing in debug mode (L. Peter Deutsch).
|
||||
- allow compilation with CC
|
||||
- defined STDC for OS/2 (David Charlap)
|
||||
- limit external names to 8 chars for MVS (Thomas Lund)
|
||||
- in minigzip.c, use static buffers only for 16-bit systems
|
||||
- fix suffix check for "minigzip -d foo.gz"
|
||||
- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee)
|
||||
- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau)
|
||||
- added makelcc.bat for lcc-win32 (Tom St Denis)
|
||||
- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe)
|
||||
- Avoid expanded $Id: ChangeLog,v 1.1 2001/03/21 22:32:32 chorns Exp $. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion.
|
||||
- check for unistd.h in configure (for off_t)
|
||||
- remove useless check parameter in inflate_blocks_free
|
||||
- avoid useless assignment of s->check to itself in inflate_blocks_new
|
||||
- do not flush twice in gzclose (thanks to Ken Raeburn)
|
||||
- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h
|
||||
- use NO_ERRNO_H instead of enumeration of operating systems with errno.h
|
||||
- work around buggy fclose on pipes for HP/UX
|
||||
- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson)
|
||||
- fix configure if CC is already equal to gcc
|
||||
|
||||
Changes in 1.0.5 (3 Jan 98)
|
||||
- Fix inflate to terminate gracefully when fed corrupted or invalid data
|
||||
- Use const for rommable constants in inflate
|
||||
- Eliminate memory leaks on error conditions in inflate
|
||||
- Removed some vestigial code in inflate
|
||||
- Update web address in README
|
||||
|
||||
Changes in 1.0.4 (24 Jul 96)
|
||||
- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF
|
||||
bit, so the decompressor could decompress all the correct data but went
|
||||
on to attempt decompressing extra garbage data. This affected minigzip too.
|
||||
- zlibVersion and gzerror return const char* (needed for DLL)
|
||||
- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno)
|
||||
- use z_error only for DEBUG (avoid problem with DLLs)
|
||||
|
||||
Changes in 1.0.3 (2 Jul 96)
|
||||
- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS
|
||||
small and medium models; this makes the library incompatible with previous
|
||||
versions for these models. (No effect in large model or on other systems.)
|
||||
- return OK instead of BUF_ERROR if previous deflate call returned with
|
||||
avail_out as zero but there is nothing to do
|
||||
- added memcmp for non STDC compilers
|
||||
- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly)
|
||||
- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO)
|
||||
- better check for 16-bit mode MSC (avoids problem with Symantec)
|
||||
|
||||
Changes in 1.0.2 (23 May 96)
|
||||
- added Windows DLL support
|
||||
- added a function zlibVersion (for the DLL support)
|
||||
- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model)
|
||||
- Bytef is define's instead of typedef'd only for Borland C
|
||||
- avoid reading uninitialized memory in example.c
|
||||
- mention in README that the zlib format is now RFC1950
|
||||
- updated Makefile.dj2
|
||||
- added algorithm.doc
|
||||
|
||||
Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
|
||||
- fix array overlay in deflate.c which sometimes caused bad compressed data
|
||||
- fix inflate bug with empty stored block
|
||||
- fix MSDOS medium model which was broken in 0.99
|
||||
- fix deflateParams() which could generated bad compressed data.
|
||||
- Bytef is define'd instead of typedef'ed (work around Borland bug)
|
||||
- added an INDEX file
|
||||
- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
|
||||
Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas)
|
||||
- speed up adler32 for modern machines without auto-increment
|
||||
- added -ansi for IRIX in configure
|
||||
- static_init_done in trees.c is an int
|
||||
- define unlink as delete for VMS
|
||||
- fix configure for QNX
|
||||
- add configure branch for SCO and HPUX
|
||||
- avoid many warnings (unused variables, dead assignments, etc...)
|
||||
- no fdopen for BeOS
|
||||
- fix the Watcom fix for 32 bit mode (define FAR as empty)
|
||||
- removed redefinition of Byte for MKWERKS
|
||||
- work around an MWKERKS bug (incorrect merge of all .h files)
|
||||
|
||||
Changes in 0.99 (27 Jan 96)
|
||||
- allow preset dictionary shared between compressor and decompressor
|
||||
- allow compression level 0 (no compression)
|
||||
- add deflateParams in zlib.h: allow dynamic change of compression level
|
||||
and compression strategy.
|
||||
- test large buffers and deflateParams in example.c
|
||||
- add optional "configure" to build zlib as a shared library
|
||||
- suppress Makefile.qnx, use configure instead
|
||||
- fixed deflate for 64-bit systems (detected on Cray)
|
||||
- fixed inflate_blocks for 64-bit systems (detected on Alpha)
|
||||
- declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2)
|
||||
- always return Z_BUF_ERROR when deflate() has nothing to do
|
||||
- deflateInit and inflateInit are now macros to allow version checking
|
||||
- prefix all global functions and types with z_ with -DZ_PREFIX
|
||||
- make falloc completely reentrant (inftrees.c)
|
||||
- fixed very unlikely race condition in ct_static_init
|
||||
- free in reverse order of allocation to help memory manager
|
||||
- use zlib-1.0/* instead of zlib/* inside the tar.gz
|
||||
- make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith
|
||||
-Wconversion -Wstrict-prototypes -Wmissing-prototypes"
|
||||
- allow gzread on concatenated .gz files
|
||||
- deflateEnd now returns Z_DATA_ERROR if it was premature
|
||||
- deflate is finally (?) fully deterministic (no matches beyond end of input)
|
||||
- Document Z_SYNC_FLUSH
|
||||
- add uninstall in Makefile
|
||||
- Check for __cpluplus in zlib.h
|
||||
- Better test in ct_align for partial flush
|
||||
- avoid harmless warnings for Borland C++
|
||||
- initialize hash_head in deflate.c
|
||||
- avoid warning on fdopen (gzio.c) for HP cc -Aa
|
||||
- include stdlib.h for STDC compilers
|
||||
- include errno.h for Cray
|
||||
- ignore error if ranlib doesn't exist
|
||||
- call ranlib twice for NeXTSTEP
|
||||
- use exec_prefix instead of prefix for libz.a
|
||||
- renamed ct_* as _tr_* to avoid conflict with applications
|
||||
- clear z->msg in inflateInit2 before any error return
|
||||
- initialize opaque in example.c, gzio.c, deflate.c and inflate.c
|
||||
- fixed typo in zconf.h (_GNUC__ => __GNUC__)
|
||||
- check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode)
|
||||
- fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
|
||||
- in fcalloc, normalize pointer if size > 65520 bytes
|
||||
- don't use special fcalloc for 32 bit Borland C++
|
||||
- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc...
|
||||
- use Z_BINARY instead of BINARY
|
||||
- document that gzclose after gzdopen will close the file
|
||||
- allow "a" as mode in gzopen.
|
||||
- fix error checking in gzread
|
||||
- allow skipping .gz extra-field on pipes
|
||||
- added reference to Perl interface in README
|
||||
- put the crc table in FAR data (I dislike more and more the medium model :)
|
||||
- added get_crc_table
|
||||
- added a dimension to all arrays (Borland C can't count).
|
||||
- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast
|
||||
- guard against multiple inclusion of *.h (for precompiled header on Mac)
|
||||
- Watcom C pretends to be Microsoft C small model even in 32 bit mode.
|
||||
- don't use unsized arrays to avoid silly warnings by Visual C++:
|
||||
warning C4746: 'inflate_mask' : unsized array treated as '__far'
|
||||
(what's wrong with far data in far model?).
|
||||
- define enum out of inflate_blocks_state to allow compilation with C++
|
||||
|
||||
Changes in 0.95 (16 Aug 95)
|
||||
- fix MSDOS small and medium model (now easier to adapt to any compiler)
|
||||
- inlined send_bits
|
||||
- fix the final (:-) bug for deflate with flush (output was correct but
|
||||
not completely flushed in rare occasions).
|
||||
- default window size is same for compression and decompression
|
||||
(it's now sufficient to set MAX_WBITS in zconf.h).
|
||||
- voidp -> voidpf and voidnp -> voidp (for consistency with other
|
||||
typedefs and because voidnp was not near in large model).
|
||||
|
||||
Changes in 0.94 (13 Aug 95)
|
||||
- support MSDOS medium model
|
||||
- fix deflate with flush (could sometimes generate bad output)
|
||||
- fix deflateReset (zlib header was incorrectly suppressed)
|
||||
- added support for VMS
|
||||
- allow a compression level in gzopen()
|
||||
- gzflush now calls fflush
|
||||
- For deflate with flush, flush even if no more input is provided.
|
||||
- rename libgz.a as libz.a
|
||||
- avoid complex expression in infcodes.c triggering Turbo C bug
|
||||
- work around a problem with gcc on Alpha (in INSERT_STRING)
|
||||
- don't use inline functions (problem with some gcc versions)
|
||||
- allow renaming of Byte, uInt, etc... with #define.
|
||||
- avoid warning about (unused) pointer before start of array in deflate.c
|
||||
- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c
|
||||
- avoid reserved word 'new' in trees.c
|
||||
|
||||
Changes in 0.93 (25 June 95)
|
||||
- temporarily disable inline functions
|
||||
- make deflate deterministic
|
||||
- give enough lookahead for PARTIAL_FLUSH
|
||||
- Set binary mode for stdin/stdout in minigzip.c for OS/2
|
||||
- don't even use signed char in inflate (not portable enough)
|
||||
- fix inflate memory leak for segmented architectures
|
||||
|
||||
Changes in 0.92 (3 May 95)
|
||||
- don't assume that char is signed (problem on SGI)
|
||||
- Clear bit buffer when starting a stored block
|
||||
- no memcpy on Pyramid
|
||||
- suppressed inftest.c
|
||||
- optimized fill_window, put longest_match inline for gcc
|
||||
- optimized inflate on stored blocks.
|
||||
- untabify all sources to simplify patches
|
||||
|
||||
Changes in 0.91 (2 May 95)
|
||||
- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
|
||||
- Document the memory requirements in zconf.h
|
||||
- added "make install"
|
||||
- fix sync search logic in inflateSync
|
||||
- deflate(Z_FULL_FLUSH) now works even if output buffer too short
|
||||
- after inflateSync, don't scare people with just "lo world"
|
||||
- added support for DJGPP
|
||||
|
||||
Changes in 0.9 (1 May 95)
|
||||
- don't assume that zalloc clears the allocated memory (the TurboC bug
|
||||
was Mark's bug after all :)
|
||||
- let again gzread copy uncompressed data unchanged (was working in 0.71)
|
||||
- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented
|
||||
- added a test of inflateSync in example.c
|
||||
- moved MAX_WBITS to zconf.h because users might want to change that.
|
||||
- document explicitly that zalloc(64K) on MSDOS must return a normalized
|
||||
pointer (zero offset)
|
||||
- added Makefiles for Microsoft C, Turbo C, Borland C++
|
||||
- faster crc32()
|
||||
|
||||
Changes in 0.8 (29 April 95)
|
||||
- added fast inflate (inffast.c)
|
||||
- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this
|
||||
is incompatible with previous versions of zlib which returned Z_OK.
|
||||
- work around a TurboC compiler bug (bad code for b << 0, see infutil.h)
|
||||
(actually that was not a compiler bug, see 0.81 above)
|
||||
- gzread no longer reads one extra byte in certain cases
|
||||
- In gzio destroy(), don't reference a freed structure
|
||||
- avoid many warnings for MSDOS
|
||||
- avoid the ERROR symbol which is used by MS Windows
|
||||
|
||||
Changes in 0.71 (14 April 95)
|
||||
- Fixed more MSDOS compilation problems :( There is still a bug with
|
||||
TurboC large model.
|
||||
|
||||
Changes in 0.7 (14 April 95)
|
||||
- Added full inflate support.
|
||||
- Simplified the crc32() interface. The pre- and post-conditioning
|
||||
(one's complement) is now done inside crc32(). WARNING: this is
|
||||
incompatible with previous versions; see zlib.h for the new usage.
|
||||
|
||||
Changes in 0.61 (12 April 95)
|
||||
- workaround for a bug in TurboC. example and minigzip now work on MSDOS.
|
||||
|
||||
Changes in 0.6 (11 April 95)
|
||||
- added minigzip.c
|
||||
- added gzdopen to reopen a file descriptor as gzFile
|
||||
- added transparent reading of non-gziped files in gzread.
|
||||
- fixed bug in gzread (don't read crc as data)
|
||||
- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose).
|
||||
- don't allocate big arrays in the stack (for MSDOS)
|
||||
- fix some MSDOS compilation problems
|
||||
|
||||
Changes in 0.5:
|
||||
- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but
|
||||
not yet Z_FULL_FLUSH.
|
||||
- support decompression but only in a single step (forced Z_FINISH)
|
||||
- added opaque object for zalloc and zfree.
|
||||
- added deflateReset and inflateReset
|
||||
- added a variable zlib_version for consistency checking.
|
||||
- renamed the 'filter' parameter of deflateInit2 as 'strategy'.
|
||||
Added Z_FILTERED and Z_HUFFMAN_ONLY constants.
|
||||
|
||||
Changes in 0.4:
|
||||
- avoid "zip" everywhere, use zlib instead of ziplib.
|
||||
- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush
|
||||
if compression method == 8.
|
||||
- added adler32 and crc32
|
||||
- renamed deflateOptions as deflateInit2, call one or the other but not both
|
||||
- added the method parameter for deflateInit2.
|
||||
- added inflateInit2
|
||||
- simplied considerably deflateInit and inflateInit by not supporting
|
||||
user-provided history buffer. This is supported only in deflateInit2
|
||||
and inflateInit2.
|
||||
|
||||
Changes in 0.3:
|
||||
- prefix all macro names with Z_
|
||||
- use Z_FINISH instead of deflateEnd to finish compression.
|
||||
- added Z_HUFFMAN_ONLY
|
||||
- added gzerror()
|
@@ -1,148 +0,0 @@
|
||||
zlib 1.1.3 is a general purpose data compression library. All the code
|
||||
is thread safe. The data format used by the zlib library
|
||||
is described by RFCs (Request for Comments) 1950 to 1952 in the files
|
||||
ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
|
||||
format) and rfc1952.txt (gzip format). These documents are also available in
|
||||
other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
||||
|
||||
All functions of the compression library are documented in the file zlib.h
|
||||
(volunteer to write man pages welcome, contact jloup@gzip.org). A usage
|
||||
example of the library is given in the file example.c which also tests that
|
||||
the library is working correctly. Another example is given in the file
|
||||
minigzip.c. The compression library itself is composed of all source files
|
||||
except example.c and minigzip.c.
|
||||
|
||||
To compile all files and run the test program, follow the instructions
|
||||
given at the top of Makefile. In short "make test; make install"
|
||||
should work for most machines. For Unix: "configure; make test; make install"
|
||||
For MSDOS, use one of the special makefiles such as Makefile.msc.
|
||||
For VMS, use Make_vms.com or descrip.mms.
|
||||
|
||||
Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov>, or to
|
||||
Gilles Vollant <info@winimage.com> for the Windows DLL version.
|
||||
The zlib home page is http://www.cdrom.com/pub/infozip/zlib/
|
||||
The official zlib ftp site is ftp://ftp.cdrom.com/pub/infozip/zlib/
|
||||
Before reporting a problem, please check those sites to verify that
|
||||
you have the latest version of zlib; otherwise get the latest version and
|
||||
check whether the problem still exists or not.
|
||||
|
||||
Mark Nelson <markn@tiny.com> wrote an article about zlib for the Jan. 1997
|
||||
issue of Dr. Dobb's Journal; a copy of the article is available in
|
||||
http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm
|
||||
|
||||
The changes made in version 1.1.3 are documented in the file ChangeLog.
|
||||
The main changes since 1.1.2 are:
|
||||
|
||||
- fix "an inflate input buffer bug that shows up on rare but persistent
|
||||
occasions" (Mark)
|
||||
- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
|
||||
- fix gzseek(..., SEEK_SET) in write mode
|
||||
- fix crc check after a gzeek (Frank Faubert)
|
||||
- fix miniunzip when the last entry in a zip file is itself a zip file
|
||||
(J Lillge)
|
||||
- add contrib/asm586 and contrib/asm686 (Brian Raiter)
|
||||
See http://www.muppetlabs.com/~breadbox/software/assembly.html
|
||||
- add support for Delphi 3 in contrib/delphi (Bob Dellaca)
|
||||
- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
|
||||
- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
|
||||
- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
|
||||
- added a FAQ file
|
||||
|
||||
plus many changes for portability.
|
||||
|
||||
Unsupported third party contributions are provided in directory "contrib".
|
||||
|
||||
A Java implementation of zlib is available in the Java Development Kit 1.1
|
||||
http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html
|
||||
See the zlib home page http://www.cdrom.com/pub/infozip/zlib/ for details.
|
||||
|
||||
A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk>
|
||||
is in the CPAN (Comprehensive Perl Archive Network) sites, such as:
|
||||
ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib*
|
||||
|
||||
A Python interface to zlib written by A.M. Kuchling <amk@magnet.com>
|
||||
is available in Python 1.5 and later versions, see
|
||||
http://www.python.org/doc/lib/module-zlib.html
|
||||
|
||||
A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com>
|
||||
is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html
|
||||
|
||||
An experimental package to read and write files in .zip format,
|
||||
written on top of zlib by Gilles Vollant <info@winimage.com>, is
|
||||
available at http://www.winimage.com/zLibDll/unzip.html
|
||||
and also in the contrib/minizip directory of zlib.
|
||||
|
||||
|
||||
Notes for some targets:
|
||||
|
||||
- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc
|
||||
and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL
|
||||
The zlib DLL support was initially done by Alessandro Iacopetti and is
|
||||
now maintained by Gilles Vollant <info@winimage.com>. Check the zlib DLL
|
||||
home page at http://www.winimage.com/zLibDll
|
||||
|
||||
From Visual Basic, you can call the DLL functions which do not take
|
||||
a structure as argument: compress, uncompress and all gz* functions.
|
||||
See contrib/visual-basic.txt for more information, or get
|
||||
http://www.tcfb.com/dowseware/cmp-z-it.zip
|
||||
|
||||
- For 64-bit Irix, deflate.c must be compiled without any optimization.
|
||||
With -O, one libpng test fails. The test works in 32 bit mode (with
|
||||
the -n32 compiler flag). The compiler bug has been reported to SGI.
|
||||
|
||||
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1
|
||||
it works when compiled with cc.
|
||||
|
||||
- on Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1
|
||||
is necessary to get gzprintf working correctly. This is done by configure.
|
||||
|
||||
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works
|
||||
with other compilers. Use "make test" to check your compiler.
|
||||
|
||||
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
|
||||
|
||||
- For Turbo C the small model is supported only with reduced performance to
|
||||
avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
|
||||
|
||||
- For PalmOs, see http://www.cs.uit.no/~perm/PASTA/pilot/software.html
|
||||
Per Harald Myrvang <perm@stud.cs.uit.no>
|
||||
|
||||
|
||||
Acknowledgments:
|
||||
|
||||
The deflate format used by zlib was defined by Phil Katz. The deflate
|
||||
and zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
||||
people who reported problems and suggested various improvements in zlib;
|
||||
they are too numerous to cite here.
|
||||
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-1998 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
jloup@gzip.org madler@alumni.caltech.edu
|
||||
|
||||
If you use the zlib library in a product, we would appreciate *not*
|
||||
receiving lengthy legal documents to sign. The sources are provided
|
||||
for free but without warranty of any kind. The library has been
|
||||
entirely written by Jean-loup Gailly and Mark Adler; it does not
|
||||
include third-party code.
|
||||
|
||||
If you redistribute modified sources, we would appreciate that you include
|
||||
in the file ChangeLog history information documenting your changes.
|
@@ -1,48 +0,0 @@
|
||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id: adler32.c,v 1.1 2001/03/21 22:32:32 chorns Exp $ */
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
#define BASE 65521L /* largest prime smaller than 65536 */
|
||||
#define NMAX 5552
|
||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
|
||||
#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
|
||||
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
||||
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
||||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
||||
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32(adler, buf, len)
|
||||
uLong adler;
|
||||
const Bytef *buf;
|
||||
uInt len;
|
||||
{
|
||||
unsigned long s1 = adler & 0xffff;
|
||||
unsigned long s2 = (adler >> 16) & 0xffff;
|
||||
int k;
|
||||
|
||||
if (buf == Z_NULL) return 1L;
|
||||
|
||||
while (len > 0) {
|
||||
k = len < NMAX ? len : NMAX;
|
||||
len -= k;
|
||||
while (k >= 16) {
|
||||
DO16(buf);
|
||||
buf += 16;
|
||||
k -= 16;
|
||||
}
|
||||
if (k != 0) do {
|
||||
s1 += *buf++;
|
||||
s2 += s1;
|
||||
} while (--k);
|
||||
s1 %= BASE;
|
||||
s2 %= BASE;
|
||||
}
|
||||
return (s2 << 16) | s1;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,318 +0,0 @@
|
||||
/* deflate.h -- internal compression state
|
||||
* Copyright (C) 1995-1998 Jean-loup Gailly
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* @(#) $Id: deflate.h,v 1.1 2001/03/21 22:32:32 chorns Exp $ */
|
||||
|
||||
#ifndef _DEFLATE_H
|
||||
#define _DEFLATE_H
|
||||
|
||||
#include "zutil.h"
|
||||
|
||||
/* ===========================================================================
|
||||
* Internal compression state.
|
||||
*/
|
||||
|
||||
#define LENGTH_CODES 29
|
||||
/* number of length codes, not counting the special END_BLOCK code */
|
||||
|
||||
#define LITERALS 256
|
||||
/* number of literal bytes 0..255 */
|
||||
|
||||
#define L_CODES (LITERALS+1+LENGTH_CODES)
|
||||
/* number of Literal or Length codes, including the END_BLOCK code */
|
||||
|
||||
#define D_CODES 30
|
||||
/* number of distance codes */
|
||||
|
||||
#define BL_CODES 19
|
||||
/* number of codes used to transfer the bit lengths */
|
||||
|
||||
#define HEAP_SIZE (2*L_CODES+1)
|
||||
/* maximum heap size */
|
||||
|
||||
#define MAX_BITS 15
|
||||
/* All codes must not exceed MAX_BITS bits */
|
||||
|
||||
#define INIT_STATE 42
|
||||
#define BUSY_STATE 113
|
||||
#define FINISH_STATE 666
|
||||
/* Stream status */
|
||||
|
||||
|
||||
/* Data structure describing a single value and its code string. */
|
||||
typedef struct ct_data_s {
|
||||
union {
|
||||
ush freq; /* frequency count */
|
||||
ush code; /* bit string */
|
||||
} fc;
|
||||
union {
|
||||
ush dad; /* father node in Huffman tree */
|
||||
ush len; /* length of bit string */
|
||||
} dl;
|
||||
} FAR ct_data;
|
||||
|
||||
#define Freq fc.freq
|
||||
#define Code fc.code
|
||||
#define Dad dl.dad
|
||||
#define Len dl.len
|
||||
|
||||
typedef struct static_tree_desc_s static_tree_desc;
|
||||
|
||||
typedef struct tree_desc_s {
|
||||
ct_data *dyn_tree; /* the dynamic tree */
|
||||
int max_code; /* largest code with non zero frequency */
|
||||
static_tree_desc *stat_desc; /* the corresponding static tree */
|
||||
} FAR tree_desc;
|
||||
|
||||
typedef ush Pos;
|
||||
typedef Pos FAR Posf;
|
||||
typedef unsigned IPos;
|
||||
|
||||
/* A Pos is an index in the character window. We use short instead of int to
|
||||
* save space in the various tables. IPos is used only for parameter passing.
|
||||
*/
|
||||
|
||||
typedef struct internal_state {
|
||||
z_streamp strm; /* pointer back to this zlib stream */
|
||||
int status; /* as the name implies */
|
||||
Bytef *pending_buf; /* output still pending */
|
||||
ulg pending_buf_size; /* size of pending_buf */
|
||||
Bytef *pending_out; /* next pending byte to output to the stream */
|
||||
int pending; /* nb of bytes in the pending buffer */
|
||||
int noheader; /* suppress zlib header and adler32 */
|
||||
Byte data_type; /* UNKNOWN, BINARY or ASCII */
|
||||
Byte method; /* STORED (for zip only) or DEFLATED */
|
||||
int last_flush; /* value of flush param for previous deflate call */
|
||||
|
||||
/* used by deflate.c: */
|
||||
|
||||
uInt w_size; /* LZ77 window size (32K by default) */
|
||||
uInt w_bits; /* log2(w_size) (8..16) */
|
||||
uInt w_mask; /* w_size - 1 */
|
||||
|
||||
Bytef *window;
|
||||
/* Sliding window. Input bytes are read into the second half of the window,
|
||||
* and move to the first half later to keep a dictionary of at least wSize
|
||||
* bytes. With this organization, matches are limited to a distance of
|
||||
* wSize-MAX_MATCH bytes, but this ensures that IO is always
|
||||
* performed with a length multiple of the block size. Also, it limits
|
||||
* the window size to 64K, which is quite useful on MSDOS.
|
||||
* To do: use the user input buffer as sliding window.
|
||||
*/
|
||||
|
||||
ulg window_size;
|
||||
/* Actual size of window: 2*wSize, except when the user input buffer
|
||||
* is directly used as sliding window.
|
||||
*/
|
||||
|
||||
Posf *prev;
|
||||
/* Link to older string with same hash index. To limit the size of this
|
||||
* array to 64K, this link is maintained only for the last 32K strings.
|
||||
* An index in this array is thus a window index modulo 32K.
|
||||
*/
|
||||
|
||||
Posf *head; /* Heads of the hash chains or NIL. */
|
||||
|
||||
uInt ins_h; /* hash index of string to be inserted */
|
||||
uInt hash_size; /* number of elements in hash table */
|
||||
uInt hash_bits; /* log2(hash_size) */
|
||||
uInt hash_mask; /* hash_size-1 */
|
||||
|
||||
uInt hash_shift;
|
||||
/* Number of bits by which ins_h must be shifted at each input
|
||||
* step. It must be such that after MIN_MATCH steps, the oldest
|
||||
* byte no longer takes part in the hash key, that is:
|
||||
* hash_shift * MIN_MATCH >= hash_bits
|
||||
*/
|
||||
|
||||
long block_start;
|
||||
/* Window position at the beginning of the current output block. Gets
|
||||
* negative when the window is moved backwards.
|
||||
*/
|
||||
|
||||
uInt match_length; /* length of best match */
|
||||
IPos prev_match; /* previous match */
|
||||
int match_available; /* set if previous match exists */
|
||||
uInt strstart; /* start of string to insert */
|
||||
uInt match_start; /* start of matching string */
|
||||
uInt lookahead; /* number of valid bytes ahead in window */
|
||||
|
||||
uInt prev_length;
|
||||
/* Length of the best match at previous step. Matches not greater than this
|
||||
* are discarded. This is used in the lazy match evaluation.
|
||||
*/
|
||||
|
||||
uInt max_chain_length;
|
||||
/* To speed up deflation, hash chains are never searched beyond this
|
||||
* length. A higher limit improves compression ratio but degrades the
|
||||
* speed.
|
||||
*/
|
||||
|
||||
uInt max_lazy_match;
|
||||
/* Attempt to find a better match only when the current match is strictly
|
||||
* smaller than this value. This mechanism is used only for compression
|
||||
* levels >= 4.
|
||||
*/
|
||||
# define max_insert_length max_lazy_match
|
||||
/* Insert new strings in the hash table only if the match length is not
|
||||
* greater than this length. This saves time but degrades compression.
|
||||
* max_insert_length is used only for compression levels <= 3.
|
||||
*/
|
||||
|
||||
int level; /* compression level (1..9) */
|
||||
int strategy; /* favor or force Huffman coding*/
|
||||
|
||||
uInt good_match;
|
||||
/* Use a faster search when the previous match is longer than this */
|
||||
|
||||
int nice_match; /* Stop searching when current match exceeds this */
|
||||
|
||||
/* used by trees.c: */
|
||||
/* Didn't use ct_data typedef below to supress compiler warning */
|
||||
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
|
||||
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
|
||||
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
|
||||
|
||||
struct tree_desc_s l_desc; /* desc. for literal tree */
|
||||
struct tree_desc_s d_desc; /* desc. for distance tree */
|
||||
struct tree_desc_s bl_desc; /* desc. for bit length tree */
|
||||
|
||||
ush bl_count[MAX_BITS+1];
|
||||
/* number of codes at each bit length for an optimal tree */
|
||||
|
||||
int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
|
||||
int heap_len; /* number of elements in the heap */
|
||||
int heap_max; /* element of largest frequency */
|
||||
/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
|
||||
* The same heap array is used to build all trees.
|
||||
*/
|
||||
|
||||
uch depth[2*L_CODES+1];
|
||||
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
||||
*/
|
||||
|
||||
uchf *l_buf; /* buffer for literals or lengths */
|
||||
|
||||
uInt lit_bufsize;
|
||||
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
||||
* limiting lit_bufsize to 64K:
|
||||
* - frequencies can be kept in 16 bit counters
|
||||
* - if compression is not successful for the first block, all input
|
||||
* data is still in the window so we can still emit a stored block even
|
||||
* when input comes from standard input. (This can also be done for
|
||||
* all blocks if lit_bufsize is not greater than 32K.)
|
||||
* - if compression is not successful for a file smaller than 64K, we can
|
||||
* even emit a stored file instead of a stored block (saving 5 bytes).
|
||||
* This is applicable only for zip (not gzip or zlib).
|
||||
* - creating new Huffman trees less frequently may not provide fast
|
||||
* adaptation to changes in the input data statistics. (Take for
|
||||
* example a binary file with poorly compressible code followed by
|
||||
* a highly compressible string table.) Smaller buffer sizes give
|
||||
* fast adaptation but have of course the overhead of transmitting
|
||||
* trees more frequently.
|
||||
* - I can't count above 4
|
||||
*/
|
||||
|
||||
uInt last_lit; /* running index in l_buf */
|
||||
|
||||
ushf *d_buf;
|
||||
/* Buffer for distances. To simplify the code, d_buf and l_buf have
|
||||
* the same number of elements. To use different lengths, an extra flag
|
||||
* array would be necessary.
|
||||
*/
|
||||
|
||||
ulg opt_len; /* bit length of current block with optimal trees */
|
||||
ulg static_len; /* bit length of current block with static trees */
|
||||
uInt matches; /* number of string matches in current block */
|
||||
int last_eob_len; /* bit length of EOB code for last block */
|
||||
|
||||
#ifdef DEBUG
|
||||
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
|
||||
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
|
||||
#endif
|
||||
|
||||
ush bi_buf;
|
||||
/* Output buffer. bits are inserted starting at the bottom (least
|
||||
* significant bits).
|
||||
*/
|
||||
int bi_valid;
|
||||
/* Number of valid bits in bi_buf. All bits above the last valid bit
|
||||
* are always zero.
|
||||
*/
|
||||
|
||||
} FAR deflate_state;
|
||||
|
||||
/* Output a byte on the stream.
|
||||
* IN assertion: there is enough room in pending_buf.
|
||||
*/
|
||||
#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
|
||||
|
||||
|
||||
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
|
||||
/* Minimum amount of lookahead, except at the end of the input file.
|
||||
* See deflate.c for comments about the MIN_MATCH+1.
|
||||
*/
|
||||
|
||||
#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
|
||||
/* In order to simplify the code, particularly on 16 bit machines, match
|
||||
* distances are limited to MAX_DIST instead of WSIZE.
|
||||
*/
|
||||
|
||||
/* in trees.c */
|
||||
void _tr_init OF((deflate_state *s));
|
||||
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
|
||||
void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
||||
int eof));
|
||||
void _tr_align OF((deflate_state *s));
|
||||
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
||||
int eof));
|
||||
|
||||
#define d_code(dist) \
|
||||
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
||||
/* Mapping from a distance to a distance code. dist is the distance - 1 and
|
||||
* must not have side effects. _dist_code[256] and _dist_code[257] are never
|
||||
* used.
|
||||
*/
|
||||
|
||||
#ifndef DEBUG
|
||||
/* Inline versions of _tr_tally for speed: */
|
||||
|
||||
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||
extern uch _length_code[];
|
||||
extern uch _dist_code[];
|
||||
#else
|
||||
extern const uch _length_code[];
|
||||
extern const uch _dist_code[];
|
||||
#endif
|
||||
|
||||
# define _tr_tally_lit(s, c, flush) \
|
||||
{ uch cc = (c); \
|
||||
s->d_buf[s->last_lit] = 0; \
|
||||
s->l_buf[s->last_lit++] = cc; \
|
||||
s->dyn_ltree[cc].Freq++; \
|
||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
||||
}
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
{ uch len = (length); \
|
||||
ush dist = (distance); \
|
||||
s->d_buf[s->last_lit] = dist; \
|
||||
s->l_buf[s->last_lit++] = len; \
|
||||
dist--; \
|
||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
||||
}
|
||||
#else
|
||||
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
flush = _tr_tally(s, distance, length)
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -1,398 +0,0 @@
|
||||
/* infblock.c -- interpret and process block types to last block
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "infblock.h"
|
||||
#include "inftrees.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
|
||||
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
/* Table for deflate from PKZIP's appnote.txt. */
|
||||
local const uInt border[] = { /* Order of the bit length code lengths */
|
||||
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
|
||||
|
||||
/*
|
||||
Notes beyond the 1.93a appnote.txt:
|
||||
|
||||
1. Distance pointers never point before the beginning of the output
|
||||
stream.
|
||||
2. Distance pointers can point back across blocks, up to 32k away.
|
||||
3. There is an implied maximum of 7 bits for the bit length table and
|
||||
15 bits for the actual data.
|
||||
4. If only one code exists, then it is encoded using one bit. (Zero
|
||||
would be more efficient, but perhaps a little confusing.) If two
|
||||
codes exist, they are coded using one bit each (0 and 1).
|
||||
5. There is no way of sending zero distance codes--a dummy must be
|
||||
sent if there are none. (History: a pre 2.0 version of PKZIP would
|
||||
store blocks with no distance codes, but this was discovered to be
|
||||
too harsh a criterion.) Valid only for 1.93a. 2.04c does allow
|
||||
zero distance codes, which is sent as one code of zero bits in
|
||||
length.
|
||||
6. There are up to 286 literal/length codes. Code 256 represents the
|
||||
end-of-block. Note however that the static length tree defines
|
||||
288 codes just to fill out the Huffman codes. Codes 286 and 287
|
||||
cannot be used though, since there is no length base or extra bits
|
||||
defined for them. Similarily, there are up to 30 distance codes.
|
||||
However, static trees define 32 codes (all 5 bits) to fill out the
|
||||
Huffman codes, but the last two had better not show up in the data.
|
||||
7. Unzip can check dynamic Huffman blocks for complete code sets.
|
||||
The exception is that a single code would not be complete (see #4).
|
||||
8. The five bits following the block type is really the number of
|
||||
literal codes sent minus 257.
|
||||
9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits
|
||||
(1+6+6). Therefore, to output three times the length, you output
|
||||
three codes (1+1+1), whereas to output four times the same length,
|
||||
you only need two codes (1+3). Hmm.
|
||||
10. In the tree reconstruction algorithm, Code = Code + Increment
|
||||
only if BitLength(i) is not zero. (Pretty obvious.)
|
||||
11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19)
|
||||
12. Note: length code 284 can represent 227-258, but length code 285
|
||||
really is 258. The last length deserves its own, short code
|
||||
since it gets used a lot in very redundant files. The length
|
||||
258 is special since 258 - 3 (the min match length) is 255.
|
||||
13. The literal/length and distance code bit lengths are read as a
|
||||
single stream of lengths. It is possible (and advantageous) for
|
||||
a repeat code (16, 17, or 18) to go across the boundary between
|
||||
the two sets of lengths.
|
||||
*/
|
||||
|
||||
|
||||
void inflate_blocks_reset(s, z, c)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
uLongf *c;
|
||||
{
|
||||
if (c != Z_NULL)
|
||||
*c = s->check;
|
||||
if (s->mode == BTREE || s->mode == DTREE)
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
if (s->mode == CODES)
|
||||
inflate_codes_free(s->sub.decode.codes, z);
|
||||
s->mode = TYPE;
|
||||
s->bitk = 0;
|
||||
s->bitb = 0;
|
||||
s->read = s->write = s->window;
|
||||
if (s->checkfn != Z_NULL)
|
||||
z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0);
|
||||
Tracev((stderr, "inflate: blocks reset\n"));
|
||||
}
|
||||
|
||||
|
||||
inflate_blocks_statef *inflate_blocks_new(z, c, w)
|
||||
z_streamp z;
|
||||
check_func c;
|
||||
uInt w;
|
||||
{
|
||||
inflate_blocks_statef *s;
|
||||
|
||||
if ((s = (inflate_blocks_statef *)ZALLOC
|
||||
(z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
|
||||
return s;
|
||||
if ((s->hufts =
|
||||
(inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL)
|
||||
{
|
||||
ZFREE(z, s);
|
||||
return Z_NULL;
|
||||
}
|
||||
if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL)
|
||||
{
|
||||
ZFREE(z, s->hufts);
|
||||
ZFREE(z, s);
|
||||
return Z_NULL;
|
||||
}
|
||||
s->end = s->window + w;
|
||||
s->checkfn = c;
|
||||
s->mode = TYPE;
|
||||
Tracev((stderr, "inflate: blocks allocated\n"));
|
||||
inflate_blocks_reset(s, z, Z_NULL);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
int inflate_blocks(s, z, r)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
int r;
|
||||
{
|
||||
uInt t; /* temporary storage */
|
||||
uLong b; /* bit buffer */
|
||||
uInt k; /* bits in bit buffer */
|
||||
Bytef *p; /* input data pointer */
|
||||
uInt n; /* bytes available there */
|
||||
Bytef *q; /* output window write pointer */
|
||||
uInt m; /* bytes to end of window or read pointer */
|
||||
|
||||
/* copy input/output information to locals (UPDATE macro restores) */
|
||||
LOAD
|
||||
|
||||
/* process input based on current state */
|
||||
while (1) switch (s->mode)
|
||||
{
|
||||
case TYPE:
|
||||
NEEDBITS(3)
|
||||
t = (uInt)b & 7;
|
||||
s->last = t & 1;
|
||||
switch (t >> 1)
|
||||
{
|
||||
case 0: /* stored */
|
||||
Tracev((stderr, "inflate: stored block%s\n",
|
||||
s->last ? " (last)" : ""));
|
||||
DUMPBITS(3)
|
||||
t = k & 7; /* go to byte boundary */
|
||||
DUMPBITS(t)
|
||||
s->mode = LENS; /* get length of stored block */
|
||||
break;
|
||||
case 1: /* fixed */
|
||||
Tracev((stderr, "inflate: fixed codes block%s\n",
|
||||
s->last ? " (last)" : ""));
|
||||
{
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl, *td;
|
||||
|
||||
inflate_trees_fixed(&bl, &bd, &tl, &td, z);
|
||||
s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
|
||||
if (s->sub.decode.codes == Z_NULL)
|
||||
{
|
||||
r = Z_MEM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
}
|
||||
DUMPBITS(3)
|
||||
s->mode = CODES;
|
||||
break;
|
||||
case 2: /* dynamic */
|
||||
Tracev((stderr, "inflate: dynamic codes block%s\n",
|
||||
s->last ? " (last)" : ""));
|
||||
DUMPBITS(3)
|
||||
s->mode = TABLE;
|
||||
break;
|
||||
case 3: /* illegal */
|
||||
DUMPBITS(3)
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid block type";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
break;
|
||||
case LENS:
|
||||
NEEDBITS(32)
|
||||
if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
|
||||
{
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid stored block lengths";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
s->sub.left = (uInt)b & 0xffff;
|
||||
b = k = 0; /* dump bits */
|
||||
Tracev((stderr, "inflate: stored length %u\n", s->sub.left));
|
||||
s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE);
|
||||
break;
|
||||
case STORED:
|
||||
if (n == 0)
|
||||
LEAVE
|
||||
NEEDOUT
|
||||
t = s->sub.left;
|
||||
if (t > n) t = n;
|
||||
if (t > m) t = m;
|
||||
zmemcpy(q, p, t);
|
||||
p += t; n -= t;
|
||||
q += t; m -= t;
|
||||
if ((s->sub.left -= t) != 0)
|
||||
break;
|
||||
Tracev((stderr, "inflate: stored end, %lu total out\n",
|
||||
z->total_out + (q >= s->read ? q - s->read :
|
||||
(s->end - s->read) + (q - s->window))));
|
||||
s->mode = s->last ? DRY : TYPE;
|
||||
break;
|
||||
case TABLE:
|
||||
NEEDBITS(14)
|
||||
s->sub.trees.table = t = (uInt)b & 0x3fff;
|
||||
#ifndef PKZIP_BUG_WORKAROUND
|
||||
if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
|
||||
{
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"too many length or distance symbols";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
#endif
|
||||
t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
|
||||
if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
|
||||
{
|
||||
r = Z_MEM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
DUMPBITS(14)
|
||||
s->sub.trees.index = 0;
|
||||
Tracev((stderr, "inflate: table sizes ok\n"));
|
||||
s->mode = BTREE;
|
||||
case BTREE:
|
||||
while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
|
||||
{
|
||||
NEEDBITS(3)
|
||||
s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;
|
||||
DUMPBITS(3)
|
||||
}
|
||||
while (s->sub.trees.index < 19)
|
||||
s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
|
||||
s->sub.trees.bb = 7;
|
||||
t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
|
||||
&s->sub.trees.tb, s->hufts, z);
|
||||
if (t != Z_OK)
|
||||
{
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
r = t;
|
||||
if (r == Z_DATA_ERROR)
|
||||
s->mode = BAD;
|
||||
LEAVE
|
||||
}
|
||||
s->sub.trees.index = 0;
|
||||
Tracev((stderr, "inflate: bits tree ok\n"));
|
||||
s->mode = DTREE;
|
||||
case DTREE:
|
||||
while (t = s->sub.trees.table,
|
||||
s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
|
||||
{
|
||||
inflate_huft *h;
|
||||
uInt i, j, c;
|
||||
|
||||
t = s->sub.trees.bb;
|
||||
NEEDBITS(t)
|
||||
h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
|
||||
t = h->bits;
|
||||
c = h->base;
|
||||
if (c < 16)
|
||||
{
|
||||
DUMPBITS(t)
|
||||
s->sub.trees.blens[s->sub.trees.index++] = c;
|
||||
}
|
||||
else /* c == 16..18 */
|
||||
{
|
||||
i = c == 18 ? 7 : c - 14;
|
||||
j = c == 18 ? 11 : 3;
|
||||
NEEDBITS(t + i)
|
||||
DUMPBITS(t)
|
||||
j += (uInt)b & inflate_mask[i];
|
||||
DUMPBITS(i)
|
||||
i = s->sub.trees.index;
|
||||
t = s->sub.trees.table;
|
||||
if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
|
||||
(c == 16 && i < 1))
|
||||
{
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid bit length repeat";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
c = c == 16 ? s->sub.trees.blens[i - 1] : 0;
|
||||
do {
|
||||
s->sub.trees.blens[i++] = c;
|
||||
} while (--j);
|
||||
s->sub.trees.index = i;
|
||||
}
|
||||
}
|
||||
s->sub.trees.tb = Z_NULL;
|
||||
{
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl, *td;
|
||||
inflate_codes_statef *c;
|
||||
|
||||
bl = 9; /* must be <= 9 for lookahead assumptions */
|
||||
bd = 6; /* must be <= 9 for lookahead assumptions */
|
||||
t = s->sub.trees.table;
|
||||
t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
|
||||
s->sub.trees.blens, &bl, &bd, &tl, &td,
|
||||
s->hufts, z);
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
if (t != Z_OK)
|
||||
{
|
||||
if (t == (uInt)Z_DATA_ERROR)
|
||||
s->mode = BAD;
|
||||
r = t;
|
||||
LEAVE
|
||||
}
|
||||
Tracev((stderr, "inflate: trees ok\n"));
|
||||
if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
|
||||
{
|
||||
r = Z_MEM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
s->sub.decode.codes = c;
|
||||
}
|
||||
s->mode = CODES;
|
||||
case CODES:
|
||||
UPDATE
|
||||
if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)
|
||||
return inflate_flush(s, z, r);
|
||||
r = Z_OK;
|
||||
inflate_codes_free(s->sub.decode.codes, z);
|
||||
LOAD
|
||||
Tracev((stderr, "inflate: codes end, %lu total out\n",
|
||||
z->total_out + (q >= s->read ? q - s->read :
|
||||
(s->end - s->read) + (q - s->window))));
|
||||
if (!s->last)
|
||||
{
|
||||
s->mode = TYPE;
|
||||
break;
|
||||
}
|
||||
s->mode = DRY;
|
||||
case DRY:
|
||||
FLUSH
|
||||
if (s->read != s->write)
|
||||
LEAVE
|
||||
s->mode = DONE;
|
||||
case DONE:
|
||||
r = Z_STREAM_END;
|
||||
LEAVE
|
||||
case BAD:
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
default:
|
||||
r = Z_STREAM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int inflate_blocks_free(s, z)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
{
|
||||
inflate_blocks_reset(s, z, Z_NULL);
|
||||
ZFREE(z, s->window);
|
||||
ZFREE(z, s->hufts);
|
||||
ZFREE(z, s);
|
||||
Tracev((stderr, "inflate: blocks freed\n"));
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
void inflate_set_dictionary(s, d, n)
|
||||
inflate_blocks_statef *s;
|
||||
const Bytef *d;
|
||||
uInt n;
|
||||
{
|
||||
zmemcpy(s->window, d, n);
|
||||
s->read = s->write = s->window + n;
|
||||
}
|
||||
|
||||
|
||||
/* Returns true if inflate is currently at the end of a block generated
|
||||
* by Z_SYNC_FLUSH or Z_FULL_FLUSH.
|
||||
* IN assertion: s != Z_NULL
|
||||
*/
|
||||
int inflate_blocks_sync_point(s)
|
||||
inflate_blocks_statef *s;
|
||||
{
|
||||
return s->mode == LENS;
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/* infblock.h -- header to use infblock.c
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
struct inflate_blocks_state;
|
||||
typedef struct inflate_blocks_state FAR inflate_blocks_statef;
|
||||
|
||||
extern inflate_blocks_statef * inflate_blocks_new OF((
|
||||
z_streamp z,
|
||||
check_func c, /* check function */
|
||||
uInt w)); /* window size */
|
||||
|
||||
extern int inflate_blocks OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
int)); /* initial return code */
|
||||
|
||||
extern void inflate_blocks_reset OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
uLongf *)); /* check value on output */
|
||||
|
||||
extern int inflate_blocks_free OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp));
|
||||
|
||||
extern void inflate_set_dictionary OF((
|
||||
inflate_blocks_statef *s,
|
||||
const Bytef *d, /* dictionary */
|
||||
uInt n)); /* dictionary length */
|
||||
|
||||
extern int inflate_blocks_sync_point OF((
|
||||
inflate_blocks_statef *s));
|
@@ -1,257 +0,0 @@
|
||||
/* infcodes.c -- process literals and length/distance pairs
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
#include "infblock.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
#include "inffast.h"
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
|
||||
START, /* x: set up for LEN */
|
||||
LEN, /* i: get length/literal/eob next */
|
||||
LENEXT, /* i: getting length extra (have base) */
|
||||
DIST, /* i: get distance next */
|
||||
DISTEXT, /* i: getting distance extra */
|
||||
COPY, /* o: copying bytes in window, waiting for space */
|
||||
LIT, /* o: got literal, waiting for output space */
|
||||
WASH, /* o: got eob, possibly still output waiting */
|
||||
END, /* x: got eob and all data flushed */
|
||||
BADCODE} /* x: got error */
|
||||
inflate_codes_mode;
|
||||
|
||||
/* inflate codes private state */
|
||||
struct inflate_codes_state {
|
||||
|
||||
/* mode */
|
||||
inflate_codes_mode mode; /* current inflate_codes mode */
|
||||
|
||||
/* mode dependent information */
|
||||
uInt len;
|
||||
union {
|
||||
struct {
|
||||
inflate_huft *tree; /* pointer into tree */
|
||||
uInt need; /* bits needed */
|
||||
} code; /* if LEN or DIST, where in tree */
|
||||
uInt lit; /* if LIT, literal */
|
||||
struct {
|
||||
uInt get; /* bits to get for extra */
|
||||
uInt dist; /* distance back to copy from */
|
||||
} copy; /* if EXT or COPY, where and how much */
|
||||
} sub; /* submode */
|
||||
|
||||
/* mode independent information */
|
||||
Byte lbits; /* ltree bits decoded per branch */
|
||||
Byte dbits; /* dtree bits decoder per branch */
|
||||
inflate_huft *ltree; /* literal/length/eob tree */
|
||||
inflate_huft *dtree; /* distance tree */
|
||||
|
||||
};
|
||||
|
||||
|
||||
inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z)
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl;
|
||||
inflate_huft *td; /* need separate declaration for Borland C++ */
|
||||
z_streamp z;
|
||||
{
|
||||
inflate_codes_statef *c;
|
||||
|
||||
if ((c = (inflate_codes_statef *)
|
||||
ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
|
||||
{
|
||||
c->mode = START;
|
||||
c->lbits = (Byte)bl;
|
||||
c->dbits = (Byte)bd;
|
||||
c->ltree = tl;
|
||||
c->dtree = td;
|
||||
Tracev((stderr, "inflate: codes new\n"));
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
int inflate_codes(s, z, r)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
int r;
|
||||
{
|
||||
uInt j; /* temporary storage */
|
||||
inflate_huft *t; /* temporary pointer */
|
||||
uInt e; /* extra bits or operation */
|
||||
uLong b; /* bit buffer */
|
||||
uInt k; /* bits in bit buffer */
|
||||
Bytef *p; /* input data pointer */
|
||||
uInt n; /* bytes available there */
|
||||
Bytef *q; /* output window write pointer */
|
||||
uInt m; /* bytes to end of window or read pointer */
|
||||
Bytef *f; /* pointer to copy strings from */
|
||||
inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
|
||||
|
||||
/* copy input/output information to locals (UPDATE macro restores) */
|
||||
LOAD
|
||||
|
||||
/* process input and output based on current state */
|
||||
while (1) switch (c->mode)
|
||||
{ /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
|
||||
case START: /* x: set up for LEN */
|
||||
#ifndef SLOW
|
||||
if (m >= 258 && n >= 10)
|
||||
{
|
||||
UPDATE
|
||||
r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
|
||||
LOAD
|
||||
if (r != Z_OK)
|
||||
{
|
||||
c->mode = r == Z_STREAM_END ? WASH : BADCODE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* !SLOW */
|
||||
c->sub.code.need = c->lbits;
|
||||
c->sub.code.tree = c->ltree;
|
||||
c->mode = LEN;
|
||||
case LEN: /* i: get length/literal/eob next */
|
||||
j = c->sub.code.need;
|
||||
NEEDBITS(j)
|
||||
t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
|
||||
DUMPBITS(t->bits)
|
||||
e = (uInt)(t->exop);
|
||||
if (e == 0) /* literal */
|
||||
{
|
||||
c->sub.lit = t->base;
|
||||
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
|
||||
"inflate: literal '%c'\n" :
|
||||
"inflate: literal 0x%02x\n", t->base));
|
||||
c->mode = LIT;
|
||||
break;
|
||||
}
|
||||
if (e & 16) /* length */
|
||||
{
|
||||
c->sub.copy.get = e & 15;
|
||||
c->len = t->base;
|
||||
c->mode = LENEXT;
|
||||
break;
|
||||
}
|
||||
if ((e & 64) == 0) /* next table */
|
||||
{
|
||||
c->sub.code.need = e;
|
||||
c->sub.code.tree = t + t->base;
|
||||
break;
|
||||
}
|
||||
if (e & 32) /* end of block */
|
||||
{
|
||||
Tracevv((stderr, "inflate: end of block\n"));
|
||||
c->mode = WASH;
|
||||
break;
|
||||
}
|
||||
c->mode = BADCODE; /* invalid code */
|
||||
z->msg = (char*)"invalid literal/length code";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
case LENEXT: /* i: getting length extra (have base) */
|
||||
j = c->sub.copy.get;
|
||||
NEEDBITS(j)
|
||||
c->len += (uInt)b & inflate_mask[j];
|
||||
DUMPBITS(j)
|
||||
c->sub.code.need = c->dbits;
|
||||
c->sub.code.tree = c->dtree;
|
||||
Tracevv((stderr, "inflate: length %u\n", c->len));
|
||||
c->mode = DIST;
|
||||
case DIST: /* i: get distance next */
|
||||
j = c->sub.code.need;
|
||||
NEEDBITS(j)
|
||||
t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
|
||||
DUMPBITS(t->bits)
|
||||
e = (uInt)(t->exop);
|
||||
if (e & 16) /* distance */
|
||||
{
|
||||
c->sub.copy.get = e & 15;
|
||||
c->sub.copy.dist = t->base;
|
||||
c->mode = DISTEXT;
|
||||
break;
|
||||
}
|
||||
if ((e & 64) == 0) /* next table */
|
||||
{
|
||||
c->sub.code.need = e;
|
||||
c->sub.code.tree = t + t->base;
|
||||
break;
|
||||
}
|
||||
c->mode = BADCODE; /* invalid code */
|
||||
z->msg = (char*)"invalid distance code";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
case DISTEXT: /* i: getting distance extra */
|
||||
j = c->sub.copy.get;
|
||||
NEEDBITS(j)
|
||||
c->sub.copy.dist += (uInt)b & inflate_mask[j];
|
||||
DUMPBITS(j)
|
||||
Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist));
|
||||
c->mode = COPY;
|
||||
case COPY: /* o: copying bytes in window, waiting for space */
|
||||
#ifndef __TURBOC__ /* Turbo C bug for following expression */
|
||||
f = (uInt)(q - s->window) < c->sub.copy.dist ?
|
||||
s->end - (c->sub.copy.dist - (q - s->window)) :
|
||||
q - c->sub.copy.dist;
|
||||
#else
|
||||
f = q - c->sub.copy.dist;
|
||||
if ((uInt)(q - s->window) < c->sub.copy.dist)
|
||||
f = s->end - (c->sub.copy.dist - (uInt)(q - s->window));
|
||||
#endif
|
||||
while (c->len)
|
||||
{
|
||||
NEEDOUT
|
||||
OUTBYTE(*f++)
|
||||
if (f == s->end)
|
||||
f = s->window;
|
||||
c->len--;
|
||||
}
|
||||
c->mode = START;
|
||||
break;
|
||||
case LIT: /* o: got literal, waiting for output space */
|
||||
NEEDOUT
|
||||
OUTBYTE(c->sub.lit)
|
||||
c->mode = START;
|
||||
break;
|
||||
case WASH: /* o: got eob, possibly more output */
|
||||
if (k > 7) /* return unused byte, if any */
|
||||
{
|
||||
Assert(k < 16, "inflate_codes grabbed too many bytes")
|
||||
k -= 8;
|
||||
n++;
|
||||
p--; /* can always return one */
|
||||
}
|
||||
FLUSH
|
||||
if (s->read != s->write)
|
||||
LEAVE
|
||||
c->mode = END;
|
||||
case END:
|
||||
r = Z_STREAM_END;
|
||||
LEAVE
|
||||
case BADCODE: /* x: got error */
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
default:
|
||||
r = Z_STREAM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
#ifdef NEED_DUMMY_RETURN
|
||||
return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void inflate_codes_free(c, z)
|
||||
inflate_codes_statef *c;
|
||||
z_streamp z;
|
||||
{
|
||||
ZFREE(z, c);
|
||||
Tracev((stderr, "inflate: codes free\n"));
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
/* infcodes.h -- header to use infcodes.c
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
struct inflate_codes_state;
|
||||
typedef struct inflate_codes_state FAR inflate_codes_statef;
|
||||
|
||||
extern inflate_codes_statef *inflate_codes_new OF((
|
||||
uInt, uInt,
|
||||
inflate_huft *, inflate_huft *,
|
||||
z_streamp ));
|
||||
|
||||
extern int inflate_codes OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
int));
|
||||
|
||||
extern void inflate_codes_free OF((
|
||||
inflate_codes_statef *,
|
||||
z_streamp ));
|
||||
|
@@ -1,170 +0,0 @@
|
||||
/* inffast.c -- process literals and length/distance pairs fast
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
#include "infblock.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
#include "inffast.h"
|
||||
|
||||
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
/* macros for bit input with no checking and for returning unused bytes */
|
||||
#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
|
||||
#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
|
||||
|
||||
/* Called with number of bytes left to write in window at least 258
|
||||
(the maximum string length) and number of input bytes available
|
||||
at least ten. The ten bytes are six bytes for the longest length/
|
||||
distance pair plus four bytes for overloading the bit buffer. */
|
||||
|
||||
int inflate_fast(bl, bd, tl, td, s, z)
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl;
|
||||
inflate_huft *td; /* need separate declaration for Borland C++ */
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
{
|
||||
inflate_huft *t; /* temporary pointer */
|
||||
uInt e; /* extra bits or operation */
|
||||
uLong b; /* bit buffer */
|
||||
uInt k; /* bits in bit buffer */
|
||||
Bytef *p; /* input data pointer */
|
||||
uInt n; /* bytes available there */
|
||||
Bytef *q; /* output window write pointer */
|
||||
uInt m; /* bytes to end of window or read pointer */
|
||||
uInt ml; /* mask for literal/length tree */
|
||||
uInt md; /* mask for distance tree */
|
||||
uInt c; /* bytes to copy */
|
||||
uInt d; /* distance back to copy from */
|
||||
Bytef *r; /* copy source pointer */
|
||||
|
||||
/* load input, output, bit values */
|
||||
LOAD
|
||||
|
||||
/* initialize masks */
|
||||
ml = inflate_mask[bl];
|
||||
md = inflate_mask[bd];
|
||||
|
||||
/* do until not enough input or output space for fast loop */
|
||||
do { /* assume called with m >= 258 && n >= 10 */
|
||||
/* get literal/length code */
|
||||
GRABBITS(20) /* max bits for literal/length code */
|
||||
if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)
|
||||
{
|
||||
DUMPBITS(t->bits)
|
||||
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
|
||||
"inflate: * literal '%c'\n" :
|
||||
"inflate: * literal 0x%02x\n", t->base));
|
||||
*q++ = (Byte)t->base;
|
||||
m--;
|
||||
continue;
|
||||
}
|
||||
do {
|
||||
DUMPBITS(t->bits)
|
||||
if (e & 16)
|
||||
{
|
||||
/* get extra bits for length */
|
||||
e &= 15;
|
||||
c = t->base + ((uInt)b & inflate_mask[e]);
|
||||
DUMPBITS(e)
|
||||
Tracevv((stderr, "inflate: * length %u\n", c));
|
||||
|
||||
/* decode distance base of block to copy */
|
||||
GRABBITS(15); /* max bits for distance code */
|
||||
e = (t = td + ((uInt)b & md))->exop;
|
||||
do {
|
||||
DUMPBITS(t->bits)
|
||||
if (e & 16)
|
||||
{
|
||||
/* get extra bits to add to distance base */
|
||||
e &= 15;
|
||||
GRABBITS(e) /* get extra bits (up to 13) */
|
||||
d = t->base + ((uInt)b & inflate_mask[e]);
|
||||
DUMPBITS(e)
|
||||
Tracevv((stderr, "inflate: * distance %u\n", d));
|
||||
|
||||
/* do the copy */
|
||||
m -= c;
|
||||
if ((uInt)(q - s->window) >= d) /* offset before dest */
|
||||
{ /* just copy */
|
||||
r = q - d;
|
||||
*q++ = *r++; c--; /* minimum count is three, */
|
||||
*q++ = *r++; c--; /* so unroll loop a little */
|
||||
}
|
||||
else /* else offset after destination */
|
||||
{
|
||||
e = d - (uInt)(q - s->window); /* bytes from offset to end */
|
||||
r = s->end - e; /* pointer to offset */
|
||||
if (c > e) /* if source crosses, */
|
||||
{
|
||||
c -= e; /* copy to end of window */
|
||||
do {
|
||||
*q++ = *r++;
|
||||
} while (--e);
|
||||
r = s->window; /* copy rest from start of window */
|
||||
}
|
||||
}
|
||||
do { /* copy all or what's left */
|
||||
*q++ = *r++;
|
||||
} while (--c);
|
||||
break;
|
||||
}
|
||||
else if ((e & 64) == 0)
|
||||
{
|
||||
t += t->base;
|
||||
e = (t += ((uInt)b & inflate_mask[e]))->exop;
|
||||
}
|
||||
else
|
||||
{
|
||||
z->msg = (char*)"invalid distance code";
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_DATA_ERROR;
|
||||
}
|
||||
} while (1);
|
||||
break;
|
||||
}
|
||||
if ((e & 64) == 0)
|
||||
{
|
||||
t += t->base;
|
||||
if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
|
||||
{
|
||||
DUMPBITS(t->bits)
|
||||
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
|
||||
"inflate: * literal '%c'\n" :
|
||||
"inflate: * literal 0x%02x\n", t->base));
|
||||
*q++ = (Byte)t->base;
|
||||
m--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (e & 32)
|
||||
{
|
||||
Tracevv((stderr, "inflate: * end of block\n"));
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_STREAM_END;
|
||||
}
|
||||
else
|
||||
{
|
||||
z->msg = (char*)"invalid literal/length code";
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_DATA_ERROR;
|
||||
}
|
||||
} while (1);
|
||||
} while (m >= 258 && n >= 10);
|
||||
|
||||
/* not enough input or output--restore pointers and return */
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_OK;
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
/* inffast.h -- header to use inffast.c
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
extern int inflate_fast OF((
|
||||
uInt,
|
||||
uInt,
|
||||
inflate_huft *,
|
||||
inflate_huft *,
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ));
|
@@ -1,151 +0,0 @@
|
||||
/* inffixed.h -- table for decoding fixed codes
|
||||
* Generated automatically by the maketree.c program
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
local uInt fixed_bl = 9;
|
||||
local uInt fixed_bd = 5;
|
||||
local inflate_huft fixed_tl[] = {
|
||||
{{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
|
||||
{{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},
|
||||
{{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},
|
||||
{{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224},
|
||||
{{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144},
|
||||
{{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208},
|
||||
{{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176},
|
||||
{{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240},
|
||||
{{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
|
||||
{{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200},
|
||||
{{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168},
|
||||
{{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232},
|
||||
{{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152},
|
||||
{{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216},
|
||||
{{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184},
|
||||
{{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248},
|
||||
{{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
|
||||
{{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196},
|
||||
{{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164},
|
||||
{{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228},
|
||||
{{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148},
|
||||
{{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212},
|
||||
{{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180},
|
||||
{{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244},
|
||||
{{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204},
|
||||
{{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172},
|
||||
{{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236},
|
||||
{{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156},
|
||||
{{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220},
|
||||
{{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188},
|
||||
{{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252},
|
||||
{{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
|
||||
{{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194},
|
||||
{{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162},
|
||||
{{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226},
|
||||
{{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146},
|
||||
{{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210},
|
||||
{{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178},
|
||||
{{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242},
|
||||
{{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
|
||||
{{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202},
|
||||
{{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170},
|
||||
{{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234},
|
||||
{{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154},
|
||||
{{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218},
|
||||
{{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186},
|
||||
{{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250},
|
||||
{{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
|
||||
{{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198},
|
||||
{{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166},
|
||||
{{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230},
|
||||
{{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150},
|
||||
{{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214},
|
||||
{{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182},
|
||||
{{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246},
|
||||
{{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206},
|
||||
{{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174},
|
||||
{{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238},
|
||||
{{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158},
|
||||
{{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222},
|
||||
{{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190},
|
||||
{{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254},
|
||||
{{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
|
||||
{{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193},
|
||||
{{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161},
|
||||
{{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225},
|
||||
{{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145},
|
||||
{{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209},
|
||||
{{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177},
|
||||
{{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241},
|
||||
{{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
|
||||
{{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},
|
||||
{{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169},
|
||||
{{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233},
|
||||
{{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153},
|
||||
{{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217},
|
||||
{{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185},
|
||||
{{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249},
|
||||
{{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
|
||||
{{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197},
|
||||
{{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},
|
||||
{{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},
|
||||
{{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},
|
||||
{{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},
|
||||
{{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},
|
||||
{{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},
|
||||
{{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},
|
||||
{{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},
|
||||
{{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},
|
||||
{{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},
|
||||
{{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},
|
||||
{{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},
|
||||
{{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},
|
||||
{{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
|
||||
{{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},
|
||||
{{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},
|
||||
{{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},
|
||||
{{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},
|
||||
{{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},
|
||||
{{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},
|
||||
{{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},
|
||||
{{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
|
||||
{{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},
|
||||
{{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},
|
||||
{{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},
|
||||
{{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},
|
||||
{{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},
|
||||
{{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},
|
||||
{{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},
|
||||
{{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
|
||||
{{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},
|
||||
{{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},
|
||||
{{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},
|
||||
{{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},
|
||||
{{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},
|
||||
{{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},
|
||||
{{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},
|
||||
{{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},
|
||||
{{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},
|
||||
{{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},
|
||||
{{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},
|
||||
{{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},
|
||||
{{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},
|
||||
{{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}
|
||||
};
|
||||
local inflate_huft fixed_td[] = {
|
||||
{{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
|
||||
{{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
|
||||
{{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
|
||||
{{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},
|
||||
{{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},
|
||||
{{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},
|
||||
{{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
|
||||
{{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
|
||||
};
|
@@ -1,366 +0,0 @@
|
||||
/* inflate.c -- zlib interface to inflate modules
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "infblock.h"
|
||||
|
||||
struct inflate_blocks_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
typedef enum {
|
||||
METHOD, /* waiting for method byte */
|
||||
FLAG, /* waiting for flag byte */
|
||||
DICT4, /* four dictionary check bytes to go */
|
||||
DICT3, /* three dictionary check bytes to go */
|
||||
DICT2, /* two dictionary check bytes to go */
|
||||
DICT1, /* one dictionary check byte to go */
|
||||
DICT0, /* waiting for inflateSetDictionary */
|
||||
BLOCKS, /* decompressing blocks */
|
||||
CHECK4, /* four check bytes to go */
|
||||
CHECK3, /* three check bytes to go */
|
||||
CHECK2, /* two check bytes to go */
|
||||
CHECK1, /* one check byte to go */
|
||||
DONE, /* finished check, done */
|
||||
BAD} /* got an error--stay here */
|
||||
inflate_mode;
|
||||
|
||||
/* inflate private state */
|
||||
struct internal_state {
|
||||
|
||||
/* mode */
|
||||
inflate_mode mode; /* current inflate mode */
|
||||
|
||||
/* mode dependent information */
|
||||
union {
|
||||
uInt method; /* if FLAGS, method byte */
|
||||
struct {
|
||||
uLong was; /* computed check value */
|
||||
uLong need; /* stream check value */
|
||||
} check; /* if CHECK, check values to compare */
|
||||
uInt marker; /* if BAD, inflateSync's marker bytes count */
|
||||
} sub; /* submode */
|
||||
|
||||
/* mode independent information */
|
||||
int nowrap; /* flag for no wrapper */
|
||||
uInt wbits; /* log2(window size) (8..15, defaults to 15) */
|
||||
inflate_blocks_statef
|
||||
*blocks; /* current inflate_blocks state */
|
||||
|
||||
};
|
||||
|
||||
|
||||
int ZEXPORT inflateReset(z)
|
||||
z_streamp z;
|
||||
{
|
||||
if (z == Z_NULL || z->state == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
z->total_in = z->total_out = 0;
|
||||
z->msg = Z_NULL;
|
||||
z->state->mode = z->state->nowrap ? BLOCKS : METHOD;
|
||||
inflate_blocks_reset(z->state->blocks, z, Z_NULL);
|
||||
Tracev((stderr, "inflate: reset\n"));
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateEnd(z)
|
||||
z_streamp z;
|
||||
{
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
if (z->state->blocks != Z_NULL)
|
||||
inflate_blocks_free(z->state->blocks, z);
|
||||
ZFREE(z, z->state);
|
||||
z->state = Z_NULL;
|
||||
Tracev((stderr, "inflate: end\n"));
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateInit2_(z, w, version, stream_size)
|
||||
z_streamp z;
|
||||
int w;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
||||
stream_size != sizeof(z_stream))
|
||||
return Z_VERSION_ERROR;
|
||||
|
||||
/* initialize state */
|
||||
if (z == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
z->msg = Z_NULL;
|
||||
if (z->zalloc == Z_NULL)
|
||||
{
|
||||
z->zalloc = zcalloc;
|
||||
z->opaque = (voidpf)0;
|
||||
}
|
||||
if (z->zfree == Z_NULL) z->zfree = zcfree;
|
||||
if ((z->state = (struct internal_state FAR *)
|
||||
ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
z->state->blocks = Z_NULL;
|
||||
|
||||
/* handle undocumented nowrap option (no zlib header or check) */
|
||||
z->state->nowrap = 0;
|
||||
if (w < 0)
|
||||
{
|
||||
w = - w;
|
||||
z->state->nowrap = 1;
|
||||
}
|
||||
|
||||
/* set window size */
|
||||
if (w < 8 || w > 15)
|
||||
{
|
||||
inflateEnd(z);
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
z->state->wbits = (uInt)w;
|
||||
|
||||
/* create inflate_blocks state */
|
||||
if ((z->state->blocks =
|
||||
inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))
|
||||
== Z_NULL)
|
||||
{
|
||||
inflateEnd(z);
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
Tracev((stderr, "inflate: allocated\n"));
|
||||
|
||||
/* reset state */
|
||||
inflateReset(z);
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateInit_(z, version, stream_size)
|
||||
z_streamp z;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
return inflateInit2_(z, DEF_WBITS, version, stream_size);
|
||||
}
|
||||
|
||||
|
||||
#define NEEDBYTE {if(z->avail_in==0)return r;r=f;}
|
||||
#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
|
||||
|
||||
int ZEXPORT inflate(z, f)
|
||||
z_streamp z;
|
||||
int f;
|
||||
{
|
||||
int r;
|
||||
uInt b;
|
||||
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
|
||||
r = Z_BUF_ERROR;
|
||||
while (1) switch (z->state->mode)
|
||||
{
|
||||
case METHOD:
|
||||
NEEDBYTE
|
||||
if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"unknown compression method";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"invalid window size";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
z->state->mode = FLAG;
|
||||
case FLAG:
|
||||
NEEDBYTE
|
||||
b = NEXTBYTE;
|
||||
if (((z->state->sub.method << 8) + b) % 31)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"incorrect header check";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
Tracev((stderr, "inflate: zlib header ok\n"));
|
||||
if (!(b & PRESET_DICT))
|
||||
{
|
||||
z->state->mode = BLOCKS;
|
||||
break;
|
||||
}
|
||||
z->state->mode = DICT4;
|
||||
case DICT4:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need = (uLong)NEXTBYTE << 24;
|
||||
z->state->mode = DICT3;
|
||||
case DICT3:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 16;
|
||||
z->state->mode = DICT2;
|
||||
case DICT2:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 8;
|
||||
z->state->mode = DICT1;
|
||||
case DICT1:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE;
|
||||
z->adler = z->state->sub.check.need;
|
||||
z->state->mode = DICT0;
|
||||
return Z_NEED_DICT;
|
||||
case DICT0:
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"need dictionary";
|
||||
z->state->sub.marker = 0; /* can try inflateSync */
|
||||
return Z_STREAM_ERROR;
|
||||
case BLOCKS:
|
||||
r = inflate_blocks(z->state->blocks, z, r);
|
||||
if (r == Z_DATA_ERROR)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->state->sub.marker = 0; /* can try inflateSync */
|
||||
break;
|
||||
}
|
||||
if (r == Z_OK)
|
||||
r = f;
|
||||
if (r != Z_STREAM_END)
|
||||
return r;
|
||||
r = f;
|
||||
inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
|
||||
if (z->state->nowrap)
|
||||
{
|
||||
z->state->mode = DONE;
|
||||
break;
|
||||
}
|
||||
z->state->mode = CHECK4;
|
||||
case CHECK4:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need = (uLong)NEXTBYTE << 24;
|
||||
z->state->mode = CHECK3;
|
||||
case CHECK3:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 16;
|
||||
z->state->mode = CHECK2;
|
||||
case CHECK2:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 8;
|
||||
z->state->mode = CHECK1;
|
||||
case CHECK1:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE;
|
||||
|
||||
if (z->state->sub.check.was != z->state->sub.check.need)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"incorrect data check";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
Tracev((stderr, "inflate: zlib check ok\n"));
|
||||
z->state->mode = DONE;
|
||||
case DONE:
|
||||
return Z_STREAM_END;
|
||||
case BAD:
|
||||
return Z_DATA_ERROR;
|
||||
default:
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
#ifdef NEED_DUMMY_RETURN
|
||||
return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateSetDictionary(z, dictionary, dictLength)
|
||||
z_streamp z;
|
||||
const Bytef *dictionary;
|
||||
uInt dictLength;
|
||||
{
|
||||
uInt length = dictLength;
|
||||
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0)
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR;
|
||||
z->adler = 1L;
|
||||
|
||||
if (length >= ((uInt)1<<z->state->wbits))
|
||||
{
|
||||
length = (1<<z->state->wbits)-1;
|
||||
dictionary += dictLength - length;
|
||||
}
|
||||
inflate_set_dictionary(z->state->blocks, dictionary, length);
|
||||
z->state->mode = BLOCKS;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateSync(z)
|
||||
z_streamp z;
|
||||
{
|
||||
uInt n; /* number of bytes to look at */
|
||||
Bytef *p; /* pointer to bytes */
|
||||
uInt m; /* number of marker bytes found in a row */
|
||||
uLong r, w; /* temporaries to save total_in and total_out */
|
||||
|
||||
/* set up */
|
||||
if (z == Z_NULL || z->state == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
if (z->state->mode != BAD)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->state->sub.marker = 0;
|
||||
}
|
||||
if ((n = z->avail_in) == 0)
|
||||
return Z_BUF_ERROR;
|
||||
p = z->next_in;
|
||||
m = z->state->sub.marker;
|
||||
|
||||
/* search */
|
||||
while (n && m < 4)
|
||||
{
|
||||
static const Byte mark[4] = {0, 0, 0xff, 0xff};
|
||||
if (*p == mark[m])
|
||||
m++;
|
||||
else if (*p)
|
||||
m = 0;
|
||||
else
|
||||
m = 4 - m;
|
||||
p++, n--;
|
||||
}
|
||||
|
||||
/* restore */
|
||||
z->total_in += p - z->next_in;
|
||||
z->next_in = p;
|
||||
z->avail_in = n;
|
||||
z->state->sub.marker = m;
|
||||
|
||||
/* return no joy or set up to restart on a new block */
|
||||
if (m != 4)
|
||||
return Z_DATA_ERROR;
|
||||
r = z->total_in; w = z->total_out;
|
||||
inflateReset(z);
|
||||
z->total_in = r; z->total_out = w;
|
||||
z->state->mode = BLOCKS;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
/* Returns true if inflate is currently at the end of a block generated
|
||||
* by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
|
||||
* implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
|
||||
* but removes the length bytes of the resulting empty stored block. When
|
||||
* decompressing, PPP checks that at the end of input packet, inflate is
|
||||
* waiting for these length bytes.
|
||||
*/
|
||||
int ZEXPORT inflateSyncPoint(z)
|
||||
z_streamp z;
|
||||
{
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
return inflate_blocks_sync_point(z->state->blocks);
|
||||
}
|
@@ -1,455 +0,0 @@
|
||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||
* Copyright (C) 1995-1998 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
|
||||
#if !defined(BUILDFIXED) && !defined(STDC)
|
||||
# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */
|
||||
#endif
|
||||
|
||||
const char inflate_copyright[] =
|
||||
" inflate 1.1.3 Copyright 1995-1998 Mark Adler ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
include such an acknowledgment, I would appreciate that you keep this
|
||||
copyright string in the executable of your product.
|
||||
*/
|
||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
|
||||
local int huft_build OF((
|
||||
uIntf *, /* code lengths in bits */
|
||||
uInt, /* number of codes */
|
||||
uInt, /* number of "simple" codes */
|
||||
const uIntf *, /* list of base values for non-simple codes */
|
||||
const uIntf *, /* list of extra bits for non-simple codes */
|
||||
inflate_huft * FAR*,/* result: starting table */
|
||||
uIntf *, /* maximum lookup bits (returns actual) */
|
||||
inflate_huft *, /* space for trees */
|
||||
uInt *, /* hufts used in space */
|
||||
uIntf * )); /* space for values */
|
||||
|
||||
/* Tables for deflate from PKZIP's appnote.txt. */
|
||||
local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||
/* see note #13 above about 258 */
|
||||
local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */
|
||||
local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
8193, 12289, 16385, 24577};
|
||||
local const uInt cpdext[30] = { /* Extra bits for distance codes */
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
|
||||
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
|
||||
12, 12, 13, 13};
|
||||
|
||||
/*
|
||||
Huffman code decoding is performed using a multi-level table lookup.
|
||||
The fastest way to decode is to simply build a lookup table whose
|
||||
size is determined by the longest code. However, the time it takes
|
||||
to build this table can also be a factor if the data being decoded
|
||||
is not very long. The most common codes are necessarily the
|
||||
shortest codes, so those codes dominate the decoding time, and hence
|
||||
the speed. The idea is you can have a shorter table that decodes the
|
||||
shorter, more probable codes, and then point to subsidiary tables for
|
||||
the longer codes. The time it costs to decode the longer codes is
|
||||
then traded against the time it takes to make longer tables.
|
||||
|
||||
This results of this trade are in the variables lbits and dbits
|
||||
below. lbits is the number of bits the first level table for literal/
|
||||
length codes can decode in one step, and dbits is the same thing for
|
||||
the distance codes. Subsequent tables are also less than or equal to
|
||||
those sizes. These values may be adjusted either when all of the
|
||||
codes are shorter than that, in which case the longest code length in
|
||||
bits is used, or when the shortest code is *longer* than the requested
|
||||
table size, in which case the length of the shortest code in bits is
|
||||
used.
|
||||
|
||||
There are two different values for the two tables, since they code a
|
||||
different number of possibilities each. The literal/length table
|
||||
codes 286 possible values, or in a flat code, a little over eight
|
||||
bits. The distance table codes 30 possible values, or a little less
|
||||
than five bits, flat. The optimum values for speed end up being
|
||||
about one bit more than those, so lbits is 8+1 and dbits is 5+1.
|
||||
The optimum values may differ though from machine to machine, and
|
||||
possibly even between compilers. Your mileage may vary.
|
||||
*/
|
||||
|
||||
|
||||
/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */
|
||||
#define BMAX 15 /* maximum bit length of any code */
|
||||
|
||||
local int huft_build(b, n, s, d, e, t, m, hp, hn, v)
|
||||
uIntf *b; /* code lengths in bits (all assumed <= BMAX) */
|
||||
uInt n; /* number of codes (assumed <= 288) */
|
||||
uInt s; /* number of simple-valued codes (0..s-1) */
|
||||
const uIntf *d; /* list of base values for non-simple codes */
|
||||
const uIntf *e; /* list of extra bits for non-simple codes */
|
||||
inflate_huft * FAR *t; /* result: starting table */
|
||||
uIntf *m; /* maximum lookup bits, returns actual */
|
||||
inflate_huft *hp; /* space for trees */
|
||||
uInt *hn; /* hufts used in space */
|
||||
uIntf *v; /* working area: values in order of bit length */
|
||||
/* Given a list of code lengths and a maximum table size, make a set of
|
||||
tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
|
||||
if the given code set is incomplete (the tables are still built in this
|
||||
case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
|
||||
lengths), or Z_MEM_ERROR if not enough memory. */
|
||||
{
|
||||
|
||||
uInt a; /* counter for codes of length k */
|
||||
uInt c[BMAX+1]; /* bit length count table */
|
||||
uInt f; /* i repeats in table every f entries */
|
||||
int g; /* maximum code length */
|
||||
int h; /* table level */
|
||||
register uInt i; /* counter, current code */
|
||||
register uInt j; /* counter */
|
||||
register int k; /* number of bits in current code */
|
||||
int l; /* bits per table (returned in m) */
|
||||
uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */
|
||||
register uIntf *p; /* pointer into c[], b[], or v[] */
|
||||
inflate_huft *q; /* points to current table */
|
||||
struct inflate_huft_s r; /* table entry for structure assignment */
|
||||
inflate_huft *u[BMAX]; /* table stack */
|
||||
register int w; /* bits before this table == (l * h) */
|
||||
uInt x[BMAX+1]; /* bit offsets, then code stack */
|
||||
uIntf *xp; /* pointer into x */
|
||||
int y; /* number of dummy codes added */
|
||||
uInt z; /* number of entries in current table */
|
||||
|
||||
|
||||
/* Generate counts for each bit length */
|
||||
p = c;
|
||||
#define C0 *p++ = 0;
|
||||
#define C2 C0 C0 C0 C0
|
||||
#define C4 C2 C2 C2 C2
|
||||
C4 /* clear c[]--assume BMAX+1 is 16 */
|
||||
p = b; i = n;
|
||||
do {
|
||||
c[*p++]++; /* assume all entries <= BMAX */
|
||||
} while (--i);
|
||||
if (c[0] == n) /* null input--all zero length codes */
|
||||
{
|
||||
*t = (inflate_huft *)Z_NULL;
|
||||
*m = 0;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
/* Find minimum and maximum length, bound *m by those */
|
||||
l = *m;
|
||||
for (j = 1; j <= BMAX; j++)
|
||||
if (c[j])
|
||||
break;
|
||||
k = j; /* minimum code length */
|
||||
if ((uInt)l < j)
|
||||
l = j;
|
||||
for (i = BMAX; i; i--)
|
||||
if (c[i])
|
||||
break;
|
||||
g = i; /* maximum code length */
|
||||
if ((uInt)l > i)
|
||||
l = i;
|
||||
*m = l;
|
||||
|
||||
|
||||
/* Adjust last length count to fill out codes, if needed */
|
||||
for (y = 1 << j; j < i; j++, y <<= 1)
|
||||
if ((y -= c[j]) < 0)
|
||||
return Z_DATA_ERROR;
|
||||
if ((y -= c[i]) < 0)
|
||||
return Z_DATA_ERROR;
|
||||
c[i] += y;
|
||||
|
||||
|
||||
/* Generate starting offsets into the value table for each length */
|
||||
x[1] = j = 0;
|
||||
p = c + 1; xp = x + 2;
|
||||
while (--i) { /* note that i == g from above */
|
||||
*xp++ = (j += *p++);
|
||||
}
|
||||
|
||||
|
||||
/* Make a table of values in order of bit lengths */
|
||||
p = b; i = 0;
|
||||
do {
|
||||
if ((j = *p++) != 0)
|
||||
v[x[j]++] = i;
|
||||
} while (++i < n);
|
||||
n = x[g]; /* set n to length of v */
|
||||
|
||||
|
||||
/* Generate the Huffman codes and for each, make the table entries */
|
||||
x[0] = i = 0; /* first Huffman code is zero */
|
||||
p = v; /* grab values in bit order */
|
||||
h = -1; /* no tables yet--level -1 */
|
||||
w = -l; /* bits decoded == (l * h) */
|
||||
u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */
|
||||
q = (inflate_huft *)Z_NULL; /* ditto */
|
||||
z = 0; /* ditto */
|
||||
|
||||
/* go through the bit lengths (k already is bits in shortest code) */
|
||||
for (; k <= g; k++)
|
||||
{
|
||||
a = c[k];
|
||||
while (a--)
|
||||
{
|
||||
/* here i is the Huffman code of length k bits for value *p */
|
||||
/* make tables up to required level */
|
||||
while (k > w + l)
|
||||
{
|
||||
h++;
|
||||
w += l; /* previous table always l bits */
|
||||
|
||||
/* compute minimum size table less than or equal to l bits */
|
||||
z = g - w;
|
||||
z = z > (uInt)l ? l : z; /* table size upper limit */
|
||||
if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
|
||||
{ /* too few codes for k-w bit table */
|
||||
f -= a + 1; /* deduct codes from patterns left */
|
||||
xp = c + k;
|
||||
if (j < z)
|
||||
while (++j < z) /* try smaller tables up to z bits */
|
||||
{
|
||||
if ((f <<= 1) <= *++xp)
|
||||
break; /* enough codes to use up j bits */
|
||||
f -= *xp; /* else deduct codes from patterns */
|
||||
}
|
||||
}
|
||||
z = 1 << j; /* table entries for j-bit table */
|
||||
|
||||
/* allocate new table */
|
||||
if (*hn + z > MANY) /* (note: doesn't matter for fixed) */
|
||||
return Z_MEM_ERROR; /* not enough memory */
|
||||
u[h] = q = hp + *hn;
|
||||
*hn += z;
|
||||
|
||||
/* connect to last table, if there is one */
|
||||
if (h)
|
||||
{
|
||||
x[h] = i; /* save pattern for backing up */
|
||||
r.bits = (Byte)l; /* bits to dump before this table */
|
||||
r.exop = (Byte)j; /* bits in this table */
|
||||
j = i >> (w - l);
|
||||
r.base = (uInt)(q - u[h-1] - j); /* offset to this table */
|
||||
u[h-1][j] = r; /* connect to last table */
|
||||
}
|
||||
else
|
||||
*t = q; /* first table is returned result */
|
||||
}
|
||||
|
||||
/* set up table entry in r */
|
||||
r.bits = (Byte)(k - w);
|
||||
if (p >= v + n)
|
||||
r.exop = 128 + 64; /* out of values--invalid code */
|
||||
else if (*p < s)
|
||||
{
|
||||
r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */
|
||||
r.base = *p++; /* simple code is just the value */
|
||||
}
|
||||
else
|
||||
{
|
||||
r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */
|
||||
r.base = d[*p++ - s];
|
||||
}
|
||||
|
||||
/* fill code-like entries with r */
|
||||
f = 1 << (k - w);
|
||||
for (j = i >> w; j < z; j += f)
|
||||
q[j] = r;
|
||||
|
||||
/* backwards increment the k-bit code i */
|
||||
for (j = 1 << (k - 1); i & j; j >>= 1)
|
||||
i ^= j;
|
||||
i ^= j;
|
||||
|
||||
/* backup over finished tables */
|
||||
mask = (1 << w) - 1; /* needed on HP, cc -O bug */
|
||||
while ((i & mask) != x[h])
|
||||
{
|
||||
h--; /* don't need to update q */
|
||||
w -= l;
|
||||
mask = (1 << w) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Return Z_BUF_ERROR if we were given an incomplete table */
|
||||
return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int inflate_trees_bits(c, bb, tb, hp, z)
|
||||
uIntf *c; /* 19 code lengths */
|
||||
uIntf *bb; /* bits tree desired/actual depth */
|
||||
inflate_huft * FAR *tb; /* bits tree result */
|
||||
inflate_huft *hp; /* space for trees */
|
||||
z_streamp z; /* for messages */
|
||||
{
|
||||
int r;
|
||||
uInt hn = 0; /* hufts used in space */
|
||||
uIntf *v; /* work area for huft_build */
|
||||
|
||||
if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL,
|
||||
tb, bb, hp, &hn, v);
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed dynamic bit lengths tree";
|
||||
else if (r == Z_BUF_ERROR || *bb == 0)
|
||||
{
|
||||
z->msg = (char*)"incomplete dynamic bit lengths tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, hp, z)
|
||||
uInt nl; /* number of literal/length codes */
|
||||
uInt nd; /* number of distance codes */
|
||||
uIntf *c; /* that many (total) code lengths */
|
||||
uIntf *bl; /* literal desired/actual bit depth */
|
||||
uIntf *bd; /* distance desired/actual bit depth */
|
||||
inflate_huft * FAR *tl; /* literal/length tree result */
|
||||
inflate_huft * FAR *td; /* distance tree result */
|
||||
inflate_huft *hp; /* space for trees */
|
||||
z_streamp z; /* for messages */
|
||||
{
|
||||
int r;
|
||||
uInt hn = 0; /* hufts used in space */
|
||||
uIntf *v; /* work area for huft_build */
|
||||
|
||||
/* allocate work area */
|
||||
if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
|
||||
/* build literal/length tree */
|
||||
r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);
|
||||
if (r != Z_OK || *bl == 0)
|
||||
{
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed literal/length tree";
|
||||
else if (r != Z_MEM_ERROR)
|
||||
{
|
||||
z->msg = (char*)"incomplete literal/length tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* build distance tree */
|
||||
r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);
|
||||
if (r != Z_OK || (*bd == 0 && nl > 257))
|
||||
{
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed distance tree";
|
||||
else if (r == Z_BUF_ERROR) {
|
||||
#ifdef PKZIP_BUG_WORKAROUND
|
||||
r = Z_OK;
|
||||
}
|
||||
#else
|
||||
z->msg = (char*)"incomplete distance tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
else if (r != Z_MEM_ERROR)
|
||||
{
|
||||
z->msg = (char*)"empty distance tree with lengths";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* done */
|
||||
ZFREE(z, v);
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
/* build fixed tables only once--keep them here */
|
||||
#ifdef BUILDFIXED
|
||||
local int fixed_built = 0;
|
||||
#define FIXEDH 544 /* number of hufts used by fixed tables */
|
||||
local inflate_huft fixed_mem[FIXEDH];
|
||||
local uInt fixed_bl;
|
||||
local uInt fixed_bd;
|
||||
local inflate_huft *fixed_tl;
|
||||
local inflate_huft *fixed_td;
|
||||
#else
|
||||
#include "inffixed.h"
|
||||
#endif
|
||||
|
||||
|
||||
int inflate_trees_fixed(bl, bd, tl, td, z)
|
||||
uIntf *bl; /* literal desired/actual bit depth */
|
||||
uIntf *bd; /* distance desired/actual bit depth */
|
||||
inflate_huft * FAR *tl; /* literal/length tree result */
|
||||
inflate_huft * FAR *td; /* distance tree result */
|
||||
z_streamp z; /* for memory allocation */
|
||||
{
|
||||
#ifdef BUILDFIXED
|
||||
/* build fixed tables if not already */
|
||||
if (!fixed_built)
|
||||
{
|
||||
int k; /* temporary variable */
|
||||
uInt f = 0; /* number of hufts used in fixed_mem */
|
||||
uIntf *c; /* length list for huft_build */
|
||||
uIntf *v; /* work area for huft_build */
|
||||
|
||||
/* allocate memory */
|
||||
if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
|
||||
{
|
||||
ZFREE(z, c);
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
|
||||
/* literal table */
|
||||
for (k = 0; k < 144; k++)
|
||||
c[k] = 8;
|
||||
for (; k < 256; k++)
|
||||
c[k] = 9;
|
||||
for (; k < 280; k++)
|
||||
c[k] = 7;
|
||||
for (; k < 288; k++)
|
||||
c[k] = 8;
|
||||
fixed_bl = 9;
|
||||
huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl,
|
||||
fixed_mem, &f, v);
|
||||
|
||||
/* distance table */
|
||||
for (k = 0; k < 30; k++)
|
||||
c[k] = 5;
|
||||
fixed_bd = 5;
|
||||
huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd,
|
||||
fixed_mem, &f, v);
|
||||
|
||||
/* done */
|
||||
ZFREE(z, v);
|
||||
ZFREE(z, c);
|
||||
fixed_built = 1;
|
||||
}
|
||||
#endif
|
||||
*bl = fixed_bl;
|
||||
*bd = fixed_bd;
|
||||
*tl = fixed_tl;
|
||||
*td = fixed_td;
|
||||
return Z_OK;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user