mirror of https://github.com/wwarthen/RomWBW.git
Browse Source
- I know I said I was done, but I found some more stuff to clean up. I think I am really done now.pull/283/head
31 changed files with 5449 additions and 5329 deletions
@ -1,339 +1,339 @@ |
|||
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. |
|||
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,5 +1,10 @@ |
|||
#define HAVE_WINDOWS_H |
|||
#define HAVE_FCNTL_H |
|||
#ifdef _MSC_VER |
|||
#define HAVE_DIRENT_H |
|||
#endif |
|||
#define HAVE_DIRECT_H |
|||
#define HAVE_IO_H |
|||
#define WINVER _WIN32_WINNT_WINXP // target Windows XP |
|||
#define _WIN32_WINNT _WIN32_WINNT_WINXP // target Windows XP |
|||
//#define FILETRACKER 1 |
|||
|
|||
@ -1,186 +1,182 @@ |
|||
/*
|
|||
|
|||
CPMREDIR: CP/M filesystem redirector |
|||
Copyright (C) 1998,2003 John Elliott <jce@seasip.demon.co.uk> |
|||
|
|||
This 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. |
|||
|
|||
This library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Library General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Library General Public |
|||
License along with this library; if not, write to the Free |
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
|
|||
This file deals with drive-based functions. |
|||
*/ |
|||
|
|||
#include "cpmint.h" |
|||
|
|||
#ifdef _WIN32 |
|||
static char *drive_to_hostdrive(int cpm_drive) |
|||
{ |
|||
static char prefix[CPM_MAXPATH]; |
|||
char *lpfp; |
|||
dword dw; |
|||
|
|||
if (!redir_drive_prefix[cpm_drive]) return NULL; |
|||
dw = GetFullPathName(redir_drive_prefix[cpm_drive], sizeof(prefix), |
|||
prefix, &lpfp); |
|||
|
|||
if (!dw) return NULL; |
|||
if (prefix[1] == ':') /* If path starts with a drive, limit it */ |
|||
{ /* to just that drive */ |
|||
prefix[2] = '\\'; /* GetDiskFreeSpace should have trailing backslash */ |
|||
prefix[3] = 0; |
|||
} |
|||
return prefix; |
|||
} |
|||
#endif |
|||
|
|||
|
|||
cpm_byte fcb_reset(void) |
|||
{ |
|||
#ifdef __MSDOS__ |
|||
bdos(0x0D, 0, 0); |
|||
#endif |
|||
|
|||
redir_l_drives = 0; |
|||
redir_cpmdrive = 0; /* A reset forces current drive to A: */ |
|||
/* redir_ro_drives = 0; Software write protect not revoked by func 0Dh.
|
|||
* |
|||
* This does not follow true CP/M, but does match many 3rd-party replacements. |
|||
*/ |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_drive (cpm_byte drv) |
|||
{ |
|||
if (redir_drive_prefix[drv][0]) |
|||
{ |
|||
redir_cpmdrive = drv; |
|||
redir_log_drv(drv); |
|||
return 0; |
|||
} |
|||
else return 0x04FF; /* Drive doesn't exist */ |
|||
} |
|||
|
|||
cpm_byte fcb_getdrv(void) |
|||
{ |
|||
return redir_cpmdrive; |
|||
} |
|||
|
|||
|
|||
cpm_byte fcb_user (cpm_byte usr) |
|||
{ |
|||
if (usr != 0xFF) redir_cpmuser = usr % 16; |
|||
|
|||
redir_Msg("User: parameter %d returns %d\r\n", usr, redir_cpmuser); |
|||
|
|||
return redir_cpmuser; |
|||
} |
|||
|
|||
|
|||
|
|||
cpm_word fcb_logvec(void) |
|||
{ |
|||
return redir_l_drives; |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_rovec(void) |
|||
{ |
|||
return redir_ro_drives; |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_rodisk(void) |
|||
{ |
|||
cpm_word mask = 1; |
|||
|
|||
if (redir_cpmdrive) mask = mask << redir_cpmdrive; |
|||
|
|||
redir_ro_drives |= mask; |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_resro(cpm_word bitmap) |
|||
{ |
|||
redir_ro_drives &= ~bitmap; |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_sync(cpm_byte flag) |
|||
{ |
|||
#ifdef _WIN32 |
|||
return 0; |
|||
#else |
|||
sync(); return 0; /* Apparently some sync()s are void not int */ |
|||
#endif |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_purge() |
|||
{ |
|||
#ifdef _WIN32 |
|||
return 0; |
|||
#else |
|||
sync(); return 0; /* Apparently some sync()s are void not int */ |
|||
#endif |
|||
} |
|||
|
|||
/* Generic 8MB disk definition */ |
|||
|
|||
static cpm_byte exdpb[0x11] = { |
|||
0x80, 0, /* 128 records/track */ |
|||
0x04, 0x0F, /* 2k blocks */ |
|||
0x00, /* 16k / extent */ |
|||
0xFF, 0x0F, /* 4095 blocks */ |
|||
0xFF, 0x03, /* 1024 dir entries */ |
|||
0xFF, 0xFF, /* 16 directory blocks */ |
|||
0x00, 0x80, /* Non-removable media */ |
|||
0x00, 0x00, /* No system tracks */ |
|||
0x02, 0x03 /* 512-byte sectors */ |
|||
}; |
|||
|
|||
cpm_word fcb_getdpb(cpm_byte *dpb) |
|||
{ |
|||
/* Return the example dpb */ |
|||
memcpy(dpb, &exdpb, 0x11); |
|||
return 0x11; |
|||
} |
|||
|
|||
|
|||
/* Create an entirely bogus ALV
|
|||
* TODO: Make it a bit better */ |
|||
|
|||
cpm_word fcb_getalv(cpm_byte *alv, cpm_word max) |
|||
{ |
|||
if (max > 1024) max = 1024; |
|||
|
|||
memset(alv, 0xFF, max / 2); |
|||
memset(alv + (max / 2), 0, max / 2); |
|||
|
|||
return max; |
|||
} |
|||
|
|||
/* Get disk free space */ |
|||
|
|||
cpm_word fcb_dfree (cpm_byte drive, cpm_byte *dma) |
|||
{ |
|||
/* Return half of disk capacity */ |
|||
redir_wr24(dma, 0x8000L); /* 8MB / 128 / 2 */ |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
|
|||
/*
|
|||
|
|||
CPMREDIR: CP/M filesystem redirector |
|||
Copyright (C) 1998,2003 John Elliott <jce@seasip.demon.co.uk> |
|||
|
|||
This 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. |
|||
|
|||
This library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Library General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Library General Public |
|||
License along with this library; if not, write to the Free |
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
|
|||
This file deals with drive-based functions. |
|||
*/ |
|||
|
|||
#include "cpmint.h" |
|||
|
|||
#ifdef _WIN32 |
|||
static char* drive_to_hostdrive(int cpm_drive) |
|||
{ |
|||
static char prefix[CPM_MAXPATH]; |
|||
char* lpfp; |
|||
dword dw; |
|||
|
|||
if (!redir_drive_prefix[cpm_drive]) return NULL; |
|||
dw = GetFullPathName(redir_drive_prefix[cpm_drive], sizeof(prefix), |
|||
prefix, &lpfp); |
|||
|
|||
if (!dw) return NULL; |
|||
if (prefix[1] == ':') /* If path starts with a drive, limit it */ |
|||
{ /* to just that drive */ |
|||
prefix[2] = '\\'; /* GetDiskFreeSpace should have trailing backslash */ |
|||
prefix[3] = 0; |
|||
} |
|||
return prefix; |
|||
} |
|||
#endif |
|||
|
|||
|
|||
cpm_byte fcb_reset(void) |
|||
{ |
|||
#ifdef __MSDOS__ |
|||
bdos(0x0D, 0, 0); |
|||
#endif |
|||
|
|||
redir_l_drives = 0; |
|||
redir_cpmdrive = 0; /* A reset forces current drive to A: */ |
|||
/* redir_ro_drives = 0; Software write protect not revoked by func 0Dh.
|
|||
* |
|||
* This does not follow true CP/M, but does match many 3rd-party replacements. |
|||
*/ |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_drive(cpm_byte drv) |
|||
{ |
|||
if (redir_drive_prefix[drv][0]) |
|||
{ |
|||
redir_cpmdrive = drv; |
|||
redir_log_drv(drv); |
|||
return 0; |
|||
} |
|||
else return 0x04FF; /* Drive doesn't exist */ |
|||
} |
|||
|
|||
cpm_byte fcb_getdrv(void) |
|||
{ |
|||
return redir_cpmdrive; |
|||
} |
|||
|
|||
|
|||
cpm_byte fcb_user(cpm_byte usr) |
|||
{ |
|||
if (usr != 0xFF) redir_cpmuser = usr % 16; |
|||
|
|||
DBGMSGV("User: parameter %d returns %d\n", usr, redir_cpmuser); |
|||
|
|||
return redir_cpmuser; |
|||
} |
|||
|
|||
|
|||
|
|||
cpm_word fcb_logvec(void) |
|||
{ |
|||
return redir_l_drives; |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_rovec(void) |
|||
{ |
|||
return redir_ro_drives; |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_rodisk(void) |
|||
{ |
|||
cpm_word mask = 1; |
|||
|
|||
if (redir_cpmdrive) mask = mask << redir_cpmdrive; |
|||
|
|||
redir_ro_drives |= mask; |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_resro(cpm_word bitmap) |
|||
{ |
|||
redir_ro_drives &= ~bitmap; |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_sync(cpm_byte flag) |
|||
{ |
|||
#ifdef _WIN32 |
|||
return 0; |
|||
#else |
|||
sync(); return 0; /* Apparently some sync()s are void not int */ |
|||
#endif |
|||
} |
|||
|
|||
|
|||
cpm_word fcb_purge() |
|||
{ |
|||
#ifdef _WIN32 |
|||
return 0; |
|||
#else |
|||
sync(); return 0; /* Apparently some sync()s are void not int */ |
|||
#endif |
|||
} |
|||
|
|||
/* Generic 8MB disk definition */ |
|||
|
|||
static cpm_byte exdpb[0x11] = { |
|||
0x80, 0, /* 128 records/track */ |
|||
0x04, 0x0F, /* 2k blocks */ |
|||
0x00, /* 16k / extent */ |
|||
0xFF, 0x0F, /* 4095 blocks */ |
|||
0xFF, 0x03, /* 1024 dir entries */ |
|||
0xFF, 0xFF, /* 16 directory blocks */ |
|||
0x00, 0x80, /* Non-removable media */ |
|||
0x00, 0x00, /* No system tracks */ |
|||
0x02, 0x03 /* 512-byte sectors */ |
|||
}; |
|||
|
|||
cpm_word fcb_getdpb(cpm_byte* dpb) |
|||
{ |
|||
/* Return the example dpb */ |
|||
memcpy(dpb, &exdpb, 0x11); |
|||
return 0x11; |
|||
} |
|||
|
|||
/* Create an entirely bogus ALV
|
|||
* TODO: Make it a bit better */ |
|||
|
|||
cpm_word fcb_getalv(cpm_byte* alv, cpm_word max) |
|||
{ |
|||
if (max > 1024) max = 1024; |
|||
|
|||
memset(alv, 0xFF, max / 2); |
|||
memset(alv + (max / 2), 0, max / 2); |
|||
|
|||
return max; |
|||
} |
|||
|
|||
/* Get disk free space */ |
|||
|
|||
cpm_word fcb_dfree(cpm_byte drive, cpm_byte* dma) |
|||
{ |
|||
/* Return half of disk capacity */ |
|||
redir_wr24(dma, 0x8000L); /* 8MB / 128 / 2 */ |
|||
return 0; |
|||
} |
|||
|
|||
File diff suppressed because it is too large
@ -1,249 +1,274 @@ |
|||
/*
|
|||
|
|||
CPMREDIR: CP/M filesystem redirector |
|||
Copyright (C) 1998, John Elliott <jce@seasip.demon.co.uk> |
|||
|
|||
This 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. |
|||
|
|||
This library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Library General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Library General Public |
|||
License along with this library; if not, write to the Free |
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
|
|||
This file holds internal declarations for the library. |
|||
*/ |
|||
|
|||
#ifndef _WIN32 |
|||
#include "config.h" |
|||
#define DIRSEP "/" |
|||
#else |
|||
#include "config.h" |
|||
#define DIRSEP "/\\:" |
|||
#endif |
|||
#include <stdio.h> |
|||
#ifdef HAVE_STDLIB_H |
|||
#include <stdlib.h> |
|||
#endif |
|||
#include <stdarg.h> |
|||
#ifdef HAVE_STRING_H |
|||
#include <string.h> |
|||
#endif |
|||
#include <ctype.h> |
|||
#include <time.h> |
|||
#ifdef _WIN32 |
|||
#include <sys/utime.h> |
|||
#endif |
|||
#ifdef HAVE_SYS_TYPES_H |
|||
#include <sys/types.h> |
|||
#endif |
|||
#include <sys/stat.h> |
|||
#include <errno.h> |
|||
#ifdef HAVE_DIRENT_H |
|||
#include <dirent.h> |
|||
#ifdef HAVE_DIRECT_H |
|||
#include <direct.h> |
|||
#endif |
|||
#else |
|||
#ifdef __WATCOMC__ |
|||
#include <io.h> |
|||
#include <direct.h> |
|||
#else |
|||
#include "dirent.h" |
|||
#endif |
|||
#endif |
|||
#ifdef HAVE_NDIR_H |
|||
#include <ndir.h> |
|||
#endif |
|||
#ifdef HAVE_SYS_DIR_H |
|||
#include <sys/dir.h> |
|||
#endif |
|||
#ifdef HAVE_SYS_NDIR_H |
|||
#include <sys/ndir.h> |
|||
#endif |
|||
#ifdef HAVE_WINDOWS_H |
|||
#include <windows.h> |
|||
#endif |
|||
#ifdef HAVE_WINNT_H |
|||
#include <winnt.h> |
|||
#endif |
|||
#ifdef HAVE_SYS_VFS_H |
|||
#include <sys/vfs.h> |
|||
#endif |
|||
#ifdef HAVE_UTIME_H |
|||
#include <utime.h> |
|||
#endif |
|||
#ifdef HAVE_FCNTL_H |
|||
#include <fcntl.h> |
|||
#endif |
|||
#ifdef HAVE_UNISTD_H |
|||
#include <unistd.h> |
|||
#endif |
|||
#ifndef _WIN32 |
|||
#include <sys/param.h> |
|||
#include <sys/mount.h> |
|||
#define _S_IFDIR S_IFDIR |
|||
#endif |
|||
|
|||
/* MSDOS includes removed */ |
|||
|
|||
#ifdef _WIN32 |
|||
#define mkdir(dir, mode) _mkdir(dir) |
|||
#define strcasecmp _stricmp |
|||
int truncate(const char* path, off_t length); /* see util.c */ |
|||
#define ftruncate _chsize |
|||
/* note Windows build assumes Windows is configured as a non case sensitive filesystem */ |
|||
#else |
|||
#define CASE_SENSITIVE_FILESYSTEM 1 |
|||
#endif |
|||
|
|||
#include "cpmredir.h" |
|||
|
|||
typedef unsigned long dword; /* Must be at least 32 bits, and
|
|||
>= sizeof(int) */ |
|||
|
|||
#ifdef CPMDEF |
|||
#define EXT |
|||
#define INIT(x) =x |
|||
#else |
|||
#define EXT extern |
|||
#define INIT(x) |
|||
#endif |
|||
|
|||
/* The 16 directories to which the 16 CP/M drives are mapped */ |
|||
|
|||
EXT char redir_drive_prefix[16][CPM_MAXPATH]; |
|||
|
|||
/* Current drive and user */ |
|||
|
|||
EXT int redir_cpmdrive; |
|||
EXT int redir_cpmuser; |
|||
|
|||
/* Length of 1 read/write operation, bytes */ |
|||
|
|||
EXT int redir_rec_len INIT(128); |
|||
|
|||
/* Same, but in 128-byte records */ |
|||
EXT int redir_rec_multi INIT(1); |
|||
|
|||
/* Using a DRDOS system? */ |
|||
EXT int redir_drdos INIT(0); |
|||
|
|||
/* Default password */ |
|||
#ifdef __MSDOS__ |
|||
EXT char redir_passwd[8] INIT(""); |
|||
#endif |
|||
|
|||
EXT cpm_word redir_l_drives INIT(0); |
|||
EXT cpm_word redir_ro_drives INIT(0); |
|||
|
|||
#undef EXT |
|||
#undef INIT |
|||
|
|||
|
|||
|
|||
/* Convert FCB to a Unix filename, returning 1 if it's ambiguous */ |
|||
int redir_fcb2unix(cpm_byte *fcb, char *fname); |
|||
|
|||
/* Open FCB, set file attributes */ |
|||
int redir_ofile(cpm_byte * fcb, char *s); |
|||
|
|||
/* Check that the FCB we have is valid */ |
|||
int redir_verify_fcb(cpm_byte *fcb); |
|||
|
|||
#ifndef O_BINARY /* Necessary in DOS, not present in Linux */ |
|||
#define O_BINARY 0 |
|||
#endif |
|||
|
|||
/* Facilities for debug tracing */ |
|||
|
|||
|
|||
long zxlseek(int fd, long offset, int wh); |
|||
|
|||
#ifdef DEBUG |
|||
// long zxlseek(int fd, long offset, int wh);
|
|||
void redir_Msg(char *s, ...); |
|||
void redir_showfcb(cpm_byte *fcb); |
|||
#else |
|||
// #define zxlseek lseek
|
|||
/* Warning: This is a GCC extension */ |
|||
#define redir_Msg(x, ...) |
|||
#define redir_showfcb(x) |
|||
#endif |
|||
|
|||
|
|||
|
|||
/* Get the "sequential access" file pointer out of an FCB */ |
|||
|
|||
long redir_get_fcb_pos(cpm_byte *fcb); |
|||
|
|||
/* Write "sequential access" pointer to FCB */ |
|||
|
|||
void redir_put_fcb_pos(cpm_byte *fcb, long npos); |
|||
|
|||
/* Convert time_t to CP/M day count/hours/minutes */ |
|||
dword redir_cpmtime(time_t t); |
|||
/* And back */ |
|||
time_t redir_unixtime(cpm_byte *c); |
|||
|
|||
|
|||
/* Functions to access 24-bit & 32-bit words in memory. These are always
|
|||
little-endian. */ |
|||
|
|||
void redir_wr24(cpm_byte *addr, dword v); |
|||
void redir_wr32(cpm_byte *addr, dword v); |
|||
dword redir_rd24(cpm_byte *addr); |
|||
dword redir_rd32(cpm_byte *addr); |
|||
|
|||
/* If you have 64-bit file handles, you'll need to write separate wrhandle()
|
|||
and rdhandle() routines */ |
|||
#define redir_wrhandle redir_wr32 |
|||
#define redir_rdhandle redir_rd32 |
|||
|
|||
/* Mark a drive as logged in */ |
|||
|
|||
void redir_log_drv(cpm_byte drv); |
|||
void redir_log_fcb(cpm_byte *fcb); |
|||
|
|||
/* Check if a drive is software read-only */ |
|||
|
|||
int redir_ro_drv(cpm_byte drv); |
|||
int redir_ro_fcb(cpm_byte *fcb); |
|||
|
|||
/* Translate errno to a CP/M error */ |
|||
|
|||
cpm_word redir_xlt_err(void); |
|||
|
|||
/* Get disc label */ |
|||
cpm_word redir_get_label(cpm_byte drv, char *pattern); |
|||
|
|||
|
|||
/* DRDOS set/get access rights - no-ops under MSDOS and Unix:
|
|||
* |
|||
* CP/M password mode -> DRDOS password mode */ |
|||
cpm_word redir_drdos_pwmode(cpm_byte b); |
|||
|
|||
/* DRDOS password mode to CP/M password mode */ |
|||
cpm_byte redir_cpm_pwmode(cpm_word w); |
|||
|
|||
/* Get DRDOS access rights for a file */ |
|||
cpm_word redir_drdos_get_rights(char *path); |
|||
|
|||
/* Set DRDOS access rights and/or password */ |
|||
cpm_word redir_drdos_put_rights(char *path, cpm_byte *dma, cpm_word rights); |
|||
|
|||
/* Was the last error caused by invalid password? */ |
|||
cpm_word redir_password_error(void); |
|||
|
|||
/* Append password to filename (FILE.TYP -> FILE.TYP;PASSWORD) */ |
|||
void redir_password_append(char *s, cpm_byte *dma); |
|||
|
|||
void releaseFile(char *fname); |
|||
int trackFile(char *fname, void *fcb, int fd); |
|||
#define releaseFCB(fcb) trackFile(NULL, fcb, -1) |
|||
/*
|
|||
|
|||
CPMREDIR: CP/M filesystem redirector |
|||
Copyright (C) 1998, John Elliott <jce@seasip.demon.co.uk> |
|||
|
|||
This 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. |
|||
|
|||
This library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Library General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Library General Public |
|||
License along with this library; if not, write to the Free |
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
|
|||
This file holds internal declarations for the library. |
|||
*/ |
|||
|
|||
#include "config.h" |
|||
#include <stdio.h> |
|||
#ifdef HAVE_STDLIB_H |
|||
#include <stdlib.h> |
|||
#endif |
|||
#include <stdarg.h> |
|||
#ifdef HAVE_STRING_H |
|||
#include <string.h> |
|||
#endif |
|||
#include <ctype.h> |
|||
#include <time.h> |
|||
#ifdef _WIN32 |
|||
#include <sys/utime.h> |
|||
#endif |
|||
#ifdef HAVE_SYS_TYPES_H |
|||
#include <sys/types.h> |
|||
#endif |
|||
#include <sys/stat.h> |
|||
#include <errno.h> |
|||
#ifdef HAVE_DIRENT_H |
|||
#include <dirent.h> |
|||
#endif |
|||
#ifdef HAVE_DIRECT_H |
|||
#include <direct.h> |
|||
#endif |
|||
#ifdef HAVE_IO_H |
|||
#include <io.h> |
|||
#endif |
|||
#ifdef HAVE_NDIR_H |
|||
#include <ndir.h> |
|||
#endif |
|||
#ifdef HAVE_SYS_DIR_H |
|||
#include <sys/dir.h> |
|||
#endif |
|||
#ifdef HAVE_SYS_NDIR_H |
|||
#include <sys/ndir.h> |
|||
#endif |
|||
#ifdef HAVE_WINDOWS_H |
|||
#include <windows.h> |
|||
#endif |
|||
#ifdef HAVE_WINNT_H |
|||
#include <winnt.h> |
|||
#endif |
|||
#ifdef HAVE_SYS_VFS_H |
|||
#include <sys/vfs.h> |
|||
#endif |
|||
#ifdef HAVE_UTIME_H |
|||
#include <utime.h> |
|||
#endif |
|||
#ifdef HAVE_FCNTL_H |
|||
#include <fcntl.h> |
|||
#endif |
|||
#ifdef HAVE_UNISTD_H |
|||
#include <unistd.h> |
|||
#endif |
|||
#ifndef _WIN32 |
|||
#include <sys/param.h> |
|||
#include <sys/mount.h> |
|||
#define _S_IFDIR S_IFDIR |
|||
#endif |
|||
|
|||
/* MSDOS includes removed */ |
|||
|
|||
#ifdef _WIN32 |
|||
#define DIRSEP "/" |
|||
#define mkdir(dir, mode) _mkdir(dir) |
|||
#define strcasecmp _stricmp |
|||
#define ftruncate _chsize |
|||
/* note Windows build assumes Windows is configured as a non case sensitive filesystem */ |
|||
#ifndef STDIN_FILENO |
|||
#define STDIN_FILENO _fileno(stdin) |
|||
#define STDOUT_FILENO _fileno(stdout) |
|||
#define STDERR_FILENO _fileno(stderr) |
|||
#endif |
|||
#else |
|||
#define DIRSEP "/\\:" |
|||
#define CASE_SENSITIVE_FILESYSTEM 1 |
|||
#endif |
|||
|
|||
#ifdef _WIN32 |
|||
int truncate(const char* path, off_t length); /* see util.c */ |
|||
#endif |
|||
|
|||
typedef unsigned char byte; /* Must be exactly 8 bits */ |
|||
typedef unsigned short word; /* Must be exactly 16 bits */ |
|||
typedef unsigned long dword; /* Must be at least 32 bits, and
|
|||
>= sizeof(int) */ |
|||
|
|||
#include "cpmredir.h" |
|||
|
|||
#ifdef CPMDEF |
|||
#define EXT |
|||
#define INIT(x) =x |
|||
#else |
|||
#define EXT extern |
|||
#define INIT(x) |
|||
#endif |
|||
|
|||
/* The 16 directories to which the 16 CP/M drives are mapped */ |
|||
|
|||
EXT char redir_drive_prefix[16][CPM_MAXPATH]; |
|||
|
|||
/* Current drive and user */ |
|||
|
|||
EXT int redir_cpmdrive; |
|||
EXT int redir_cpmuser; |
|||
|
|||
/* Length of 1 read/write operation, bytes */ |
|||
|
|||
EXT int redir_rec_len INIT(128); |
|||
|
|||
/* Same, but in 128-byte records */ |
|||
EXT int redir_rec_multi INIT(1); |
|||
|
|||
/* Using a DRDOS system? */ |
|||
EXT int redir_drdos INIT(0); |
|||
|
|||
/* Default password */ |
|||
#ifdef __MSDOS__ |
|||
EXT char redir_passwd[8] INIT(""); |
|||
#endif |
|||
|
|||
EXT cpm_word redir_l_drives INIT(0); |
|||
EXT cpm_word redir_ro_drives INIT(0); |
|||
|
|||
#undef EXT |
|||
#undef INIT |
|||
|
|||
/* Convert FCB to a Unix filename, returning 1 if it's ambiguous */ |
|||
int redir_fcb2unix(cpm_byte* fcb, char* fname); |
|||
|
|||
/* Open FCB, set file attributes */ |
|||
int redir_ofile(cpm_byte* fcb, char* s); |
|||
|
|||
/* Check that the FCB we have is valid */ |
|||
int redir_verify_fcb(cpm_byte* fcb); |
|||
|
|||
#ifndef O_BINARY /* Necessary in DOS, not present in Linux */ |
|||
#define O_BINARY 0 |
|||
#endif |
|||
|
|||
/* Facilities for debug tracing */ |
|||
|
|||
long zxlseek(int fd, long offset, int wh); |
|||
|
|||
#ifdef _WIN32 |
|||
char* GetErrorStr(DWORD); |
|||
#endif |
|||
|
|||
#ifdef DEBUG |
|||
// long zxlseek(int fd, long offset, int wh);
|
|||
// void redir_Msg(char *s, ...);
|
|||
void DbgMsg(const char* file, int line, const char* func, char* s, ...); |
|||
void redir_showfcb(cpm_byte* fcb); |
|||
#else |
|||
// #define zxlseek lseek
|
|||
/* Warning: This is a GCC extension */ |
|||
// #define redir_Msg(x, ...)
|
|||
#define redir_showfcb(x) |
|||
#endif |
|||
|
|||
#ifdef DEBUG |
|||
#define FCBENT(fcb) \ |
|||
{ \ |
|||
char fname[CPM_MAXPATH] = ""; \ |
|||
redir_fcb2unix(fcb, fname); \ |
|||
DBGMSGV("entry w/ FCB @ 0x%04X, filename:'%s'\n", fcb-RAM, fname); \ |
|||
} |
|||
|
|||
#define FCBRET(rc) \ |
|||
{ \ |
|||
DBGMSGV("returning 0x%04X\n", rc); \ |
|||
return rc; \ |
|||
} |
|||
|
|||
#define DBGMSGV(s, ...) DbgMsg(__FILE__, __LINE__, __func__, s, __VA_ARGS__) |
|||
#define DBGMSG(s) DbgMsg(__FILE__, __LINE__, __func__, s) |
|||
#else |
|||
#define FCBENT(fcb) |
|||
#define FCBRET(rc) return rc; |
|||
#define DBGMSGV(s, ...) |
|||
#define DBGMSG(s) |
|||
#endif |
|||
|
|||
/* Get the "sequential access" file pointer out of an FCB */ |
|||
|
|||
long redir_get_fcb_pos(cpm_byte* fcb); |
|||
|
|||
/* Write "sequential access" pointer to FCB */ |
|||
|
|||
void redir_put_fcb_pos(cpm_byte* fcb, long npos); |
|||
|
|||
/* Convert time_t to CP/M day count/hours/minutes */ |
|||
dword redir_cpmtime(time_t t); |
|||
/* And back */ |
|||
time_t redir_unixtime(cpm_byte* c); |
|||
|
|||
/* Functions to access 24-bit & 32-bit words in memory. These are always
|
|||
little-endian. */ |
|||
|
|||
void redir_wr24(cpm_byte* addr, dword v); |
|||
void redir_wr32(cpm_byte* addr, dword v); |
|||
dword redir_rd24(cpm_byte* addr); |
|||
dword redir_rd32(cpm_byte* addr); |
|||
|
|||
/* If you have 64-bit file handles, you'll need to write separate wrhandle()
|
|||
and rdhandle() routines */ |
|||
#define redir_wrhandle redir_wr32 |
|||
#define redir_rdhandle redir_rd32 |
|||
|
|||
/* Mark a drive as logged in */ |
|||
|
|||
void redir_log_drv(cpm_byte drv); |
|||
void redir_log_fcb(cpm_byte* fcb); |
|||
|
|||
/* Check if a drive is software read-only */ |
|||
|
|||
int redir_ro_drv(cpm_byte drv); |
|||
int redir_ro_fcb(cpm_byte* fcb); |
|||
|
|||
/* Translate errno to a CP/M error */ |
|||
|
|||
cpm_word redir_xlt_err(void); |
|||
|
|||
/* Get disc label */ |
|||
cpm_word redir_get_label(cpm_byte drv, char* pattern); |
|||
|
|||
/* DRDOS set/get access rights - no-ops under MSDOS and Unix:
|
|||
* |
|||
* CP/M password mode -> DRDOS password mode */ |
|||
cpm_word redir_drdos_pwmode(cpm_byte b); |
|||
|
|||
/* DRDOS password mode to CP/M password mode */ |
|||
cpm_byte redir_cpm_pwmode(cpm_word w); |
|||
|
|||
/* Get DRDOS access rights for a file */ |
|||
cpm_word redir_drdos_get_rights(char* path); |
|||
|
|||
/* Set DRDOS access rights and/or password */ |
|||
cpm_word redir_drdos_put_rights(char* path, cpm_byte* dma, cpm_word rights); |
|||
|
|||
/* Was the last error caused by invalid password? */ |
|||
cpm_word redir_password_error(void); |
|||
|
|||
/* Append password to filename (FILE.TYP -> FILE.TYP;PASSWORD) */ |
|||
void redir_password_append(char* s, cpm_byte* dma); |
|||
|
|||
void releaseFile(char* fname); |
|||
int trackFile(char* fname, void* fcb, int fd); |
|||
#define releaseFCB(fcb) trackFile(NULL, fcb, -1) |
|||
|
|||
extern byte RAM[65536]; /* The Z80's address space */ |
|||
|
|||
@ -1,126 +1,124 @@ |
|||
/*
|
|||
|
|||
CPMREDIR: CP/M filesystem redirector |
|||
Copyright (C) 1998, John Elliott <jce@seasip.demon.co.uk> |
|||
CPMREDIR: CP/M filesystem redirector |
|||
Copyright (C) 1998, John Elliott <jce@seasip.demon.co.uk> |
|||
|
|||
This 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. |
|||
This 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. |
|||
|
|||
This library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Library General Public License for more details. |
|||
This library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Library General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Library General Public |
|||
License along with this library; if not, write to the Free |
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
You should have received a copy of the GNU Library General Public |
|||
License along with this library; if not, write to the Free |
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
|
|||
This file parses filenames to FCBs. |
|||
This file parses filenames to FCBs. |
|||
*/ |
|||
|
|||
#include "cpmint.h" |
|||
|
|||
#define is_num(c) ((c >= '0') && (c <= '9')) |
|||
|
|||
static int parse_drive_user(char *txt, cpm_byte *fcb) |
|||
static int parse_drive_user(char* txt, cpm_byte* fcb) |
|||
{ |
|||
char uid[4], drvid[4]; |
|||
int up, dp; |
|||
char uid[4], drvid[4]; |
|||
int up, dp; |
|||
|
|||
for (up = dp = 0; *txt != ':'; ++txt) |
|||
{ |
|||
if (is_num (*txt)) uid [up++] = *txt; |
|||
if (isalpha(*txt)) drvid[dp++] = *txt; |
|||
if (!is_num(*txt) && !isalpha(*txt)) return -1; |
|||
} |
|||
uid[up] = 0; drvid[dp] = 0; |
|||
for (up = dp = 0; *txt != ':'; ++txt) |
|||
{ |
|||
if (is_num(*txt)) uid[up++] = *txt; |
|||
if (isalpha(*txt)) drvid[dp++] = *txt; |
|||
if (!is_num(*txt) && !isalpha(*txt)) return -1; |
|||
} |
|||
uid[up] = 0; drvid[dp] = 0; |
|||
|
|||
if (dp > 1) return -1; /* Invalid driveletter */ |
|||
if (up > 2) return -1; /* Invalid uid */ |
|||
|
|||
fcb[0x0d] = atoi(uid) + 1; if (fcb[0x0d] > 16) return -1; |
|||
if (dp > 1) return -1; /* Invalid driveletter */ |
|||
if (up > 2) return -1; /* Invalid uid */ |
|||
|
|||
if (islower(drvid[0])) drvid[0] = toupper(drvid[0]); |
|||
fcb[0x0d] = atoi(uid) + 1; if (fcb[0x0d] > 16) return -1; |
|||
|
|||
if (drvid[0] < 'A' || drvid[0] > 'P') return -1; |
|||
|
|||
fcb[0] = drvid[0] - '@'; |
|||
return 0; |
|||
} |
|||
if (islower(drvid[0])) drvid[0] = toupper(drvid[0]); |
|||
|
|||
if (drvid[0] < 'A' || drvid[0] > 'P') return -1; |
|||
|
|||
fcb[0] = drvid[0] - '@'; |
|||
return 0; |
|||
} |
|||
|
|||
cpm_word fcb_parse(char *txt, cpm_byte *fcb) |
|||
cpm_word fcb_parse(char* txt, cpm_byte* fcb) |
|||
{ |
|||
int nl = 0, tl = 0, pl = 0, phase = 0; |
|||
char *ntxt, ch; |
|||
|
|||
memset(fcb, 0, 0x24); |
|||
|
|||
if (txt[1] == ':' || txt[2] == ':' || txt[3] == ':') |
|||
{ |
|||
if (parse_drive_user(txt, fcb)) return 0xFFFF; |
|||
/* Move past the colon */ |
|||
ntxt = strchr(txt, ':') + 1; |
|||
} |
|||
else ntxt = txt; |
|||
while (phase < 3) |
|||
{ |
|||
ch = *ntxt; |
|||
if (islower(ch)) ch = toupper(ch); |
|||
|
|||
switch(ch) |
|||
{ |
|||
case 0: |
|||
case '\r': /* EOL */ |
|||
phase = 4; |
|||
break; |
|||
|
|||
case '.': /* file.typ */ |
|||
if (!phase) ++phase; |
|||
else phase = 3; |
|||
break; |
|||
|
|||
case ';': /* Password */ |
|||
if (phase < 2) phase = 2; |
|||
else phase = 3; |
|||
break; |
|||
|
|||
case '[': case ']': case '=': case 9: case ' ': |
|||
case '>': case '<': case ':': case ',': case '/': |
|||
case '|': /* Terminator */ |
|||
phase = 3; |
|||
|
|||
default: |
|||
switch(phase) |
|||
{ |
|||
case 0: |
|||
if (nl >= 8) return 0xFFFF; |
|||
fcb[++nl] = ch; |
|||
break; |
|||
|
|||
case 1: |
|||
if (tl >= 3) return 0xFFFF; |
|||
fcb[tl + 9] = ch; |
|||
++tl; |
|||
break; |
|||
|
|||
case 2: |
|||
if (pl >= 8) return 0xFFFF; |
|||
fcb[pl + 0x10] = ch; |
|||
++pl; |
|||
break; |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
if (!nl) return 0xFFFF; |
|||
|
|||
fcb[0x1A] = pl; |
|||
|
|||
if (phase == 4) return 0; |
|||
|
|||
return (cpm_word)(ntxt - txt); |
|||
int nl = 0, tl = 0, pl = 0, phase = 0; |
|||
char* ntxt, ch; |
|||
|
|||
memset(fcb, 0, 0x24); |
|||
|
|||
if (txt[1] == ':' || txt[2] == ':' || txt[3] == ':') |
|||
{ |
|||
if (parse_drive_user(txt, fcb)) return 0xFFFF; |
|||
/* Move past the colon */ |
|||
ntxt = strchr(txt, ':') + 1; |
|||
} |
|||
else ntxt = txt; |
|||
while (phase < 3) |
|||
{ |
|||
ch = *ntxt; |
|||
if (islower(ch)) ch = toupper(ch); |
|||
|
|||
switch (ch) |
|||
{ |
|||
case 0: |
|||
case '\r': /* EOL */ |
|||
phase = 4; |
|||
break; |
|||
|
|||
case '.': /* file.typ */ |
|||
if (!phase) ++phase; |
|||
else phase = 3; |
|||
break; |
|||
|
|||
case ';': /* Password */ |
|||
if (phase < 2) phase = 2; |
|||
else phase = 3; |
|||
break; |
|||
|
|||
case '[': case ']': case '=': case 9: case ' ': |
|||
case '>': case '<': case ':': case ',': case '/': |
|||
case '|': /* Terminator */ |
|||
phase = 3; |
|||
|
|||
default: |
|||
switch (phase) |
|||
{ |
|||
case 0: |
|||
if (nl >= 8) return 0xFFFF; |
|||
fcb[++nl] = ch; |
|||
break; |
|||
|
|||
case 1: |
|||
if (tl >= 3) return 0xFFFF; |
|||
fcb[tl + 9] = ch; |
|||
++tl; |
|||
break; |
|||
|
|||
case 2: |
|||
if (pl >= 8) return 0xFFFF; |
|||
fcb[pl + 0x10] = ch; |
|||
++pl; |
|||
break; |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
if (!nl) return 0xFFFF; |
|||
|
|||
fcb[0x1A] = pl; |
|||
|
|||
if (phase == 4) return 0; |
|||
|
|||
return (cpm_word)(ntxt - txt); |
|||
} |
|||
|
|||
File diff suppressed because it is too large
@ -1,151 +1,150 @@ |
|||
/*
|
|||
CPMREDIR: CP/M filesystem redirector |
|||
Copyright (C) 1998, John Elliott <jce@seasip.demon.co.uk> |
|||
|
|||
This 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. |
|||
|
|||
This library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Library General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Library General Public |
|||
License along with this library; if not, write to the Free |
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
|
|||
This file holds the public interface to CPMREDIR. |
|||
*/ |
|||
|
|||
#ifndef CPMREDIR_H_INCLUDED |
|||
|
|||
#define CPMREDIR_H_INCLUDED 16-11-1998 |
|||
|
|||
/* The "cpm_byte" must be exactly 8 bits.
|
|||
The "cpm_word" must be exactly 16 bits. */ |
|||
|
|||
typedef unsigned char cpm_byte; |
|||
typedef unsigned short cpm_word; |
|||
|
|||
/* Maximum length of a directory path */ |
|||
#ifdef _POSIX_PATH_MAX |
|||
#define CPM_MAXPATH _POSIX_PATH_MAX |
|||
#else |
|||
#ifdef _MAX_PATH |
|||
#define CPM_MAXPATH _MAX_PATH |
|||
#else |
|||
#define CPM_MAXPATH 260 |
|||
#endif |
|||
#endif |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
/* Initialise this library. Call this function first.
|
|||
* |
|||
* Returns 0 if failed to initialise. |
|||
*/ |
|||
int fcb_init(void); |
|||
|
|||
/* Deinitialise the library. */ |
|||
|
|||
void fcb_deinit(void); |
|||
|
|||
/* Translate a name from the host FS to a CP/M name. This will (if necessary)
|
|||
* create a mapping between a CP/M drive and a host directory path. |
|||
* |
|||
* CP/M drives A: to O: can be mapped in this way. P: is always the current |
|||
* drive. |
|||
* |
|||
*/ |
|||
|
|||
void xlt_name(char *localname, char *cpmname); |
|||
|
|||
/* It is sometimes convenient to set some fixed mappings. This will create
|
|||
* a mapping for a given directory. |
|||
* Pass drive = -1 for "first available", or 0-15 for A: to P: |
|||
* Returns 1 if OK, 0 if requested drive not available. |
|||
* |
|||
* NB: It is important that the localname should have a trailing |
|||
* directory separator! |
|||
*/ |
|||
|
|||
int xlt_map(int drive, char *localdir); |
|||
|
|||
/*
|
|||
* This revokes a mapping. No check is made whether CP/M has files open |
|||
* on the drive or not. |
|||
*/ |
|||
|
|||
int xlt_umap(int drive); |
|||
|
|||
/* Find out if a drive is mapped, and if so to what directory */ |
|||
|
|||
char *xlt_getcwd(int drive); |
|||
|
|||
|
|||
/* BDOS functions. Eventually this should handle all disc-related BDOS
|
|||
* functions. |
|||
* |
|||
* I am assuming that your emulator has the CP/M RAM in its normal address |
|||
* space, accessible as a range 0-64k. If this is not the case |
|||
* (eg: you are emulating banked memory, or using a segmented architecture) |
|||
* you will have to use "copy in and copy out" techniques. The "fcb" area |
|||
* must be 36 bytes long; the "dma" area should be 128 * the value set |
|||
* in fcb_multirec() [default is 1, so 128 bytes]. |
|||
* |
|||
*/ |
|||
|
|||
cpm_byte fcb_reset (void); /* 0x0D */ |
|||
cpm_word fcb_drive (cpm_byte drv); /* 0x0E */ |
|||
cpm_word fcb_open (cpm_byte *fcb, cpm_byte *dma); /* 0x0F */ |
|||
cpm_word fcb_close (cpm_byte *fcb); /* 0x10 */ |
|||
cpm_word fcb_find1 (cpm_byte *fcb, cpm_byte *dma); /* 0x11 */ |
|||
cpm_word fcb_find2 (cpm_byte *fcb, cpm_byte *dma); /* 0x12 */ |
|||
cpm_word fcb_unlink(cpm_byte *fcb, cpm_byte *dma); /* 0x13 */ |
|||
cpm_word fcb_read (cpm_byte *fcb, cpm_byte *dma); /* 0x14 */ |
|||
cpm_word fcb_write (cpm_byte *fcb, cpm_byte *dma); /* 0x15 */ |
|||
cpm_word fcb_creat (cpm_byte *fcb, cpm_byte *dma); /* 0x16 */ |
|||
cpm_word fcb_rename(cpm_byte *fcb, cpm_byte *dma); /* 0x17 */ |
|||
cpm_word fcb_logvec(void); /* 0x18 */ |
|||
cpm_byte fcb_getdrv(void); /* 0x19 */ |
|||
/* DMA is a parameter to routines, not a separate call */ |
|||
cpm_word fcb_getalv(cpm_byte *alv, cpm_word max); /* 0x1B */ |
|||
/* Get alloc vector: caller must provide space and say how big it is. */ |
|||
cpm_word fcb_rodisk(void); /* 0x1C */ |
|||
cpm_word fcb_rovec (void); /* 0x1D */ |
|||
cpm_word fcb_chmod (cpm_byte *fcb, cpm_byte *dma); /* 0x1E */ |
|||
cpm_word fcb_getdpb(cpm_byte *dpb); /* 0x1F */ |
|||
cpm_byte fcb_user (cpm_byte usr); /* 0x20 */ |
|||
cpm_word fcb_randrd(cpm_byte *fcb, cpm_byte *dma); /* 0x21 */ |
|||
cpm_word fcb_randwr(cpm_byte *fcb, cpm_byte *dma); /* 0x22 */ |
|||
cpm_word fcb_stat (cpm_byte *fcb); /* 0x23 */ |
|||
cpm_word fcb_tell (cpm_byte *fcb); /* 0x24 */ |
|||
cpm_word fcb_resro (cpm_word bitmap); /* 0x25 */ |
|||
/* Access Drives and Free Drives are not supported. */ |
|||
cpm_word fcb_randwz(cpm_byte *fcb, cpm_byte *dma); /* 0x28 */ |
|||
/* Record locking calls not supported (though they could be) */ |
|||
cpm_word fcb_multirec(cpm_byte rc); /* 0x2C */ |
|||
/* Set hardware error action must be done by caller */ |
|||
cpm_word fcb_dfree (cpm_byte drive, cpm_byte *dma);/* 0x2E */ |
|||
cpm_word fcb_sync (cpm_byte flag); /* 0x30 */ |
|||
cpm_word fcb_purge (void); /* 0x62 */ |
|||
cpm_word fcb_trunc (cpm_byte *fcb, cpm_byte *dma); /* 0x63 */ |
|||
cpm_word fcb_setlbl(cpm_byte *fcb, cpm_byte *dma); /* 0x64 */ |
|||
cpm_word fcb_getlbl(cpm_byte drive); /* 0x65 */ |
|||
cpm_word fcb_date (cpm_byte *fcb); /* 0x66 */ |
|||
cpm_word fcb_setpwd(cpm_byte *fcb, cpm_byte *dma); /* 0x67 */ |
|||
cpm_word fcb_defpwd(cpm_byte *pwd); /* 0x6A */ |
|||
cpm_word fcb_sdate (cpm_byte *fcb, cpm_byte *dma); /* 0x74 */ |
|||
cpm_word fcb_parse (char *txt, cpm_byte *fcb); /* 0x98 */ |
|||
|
|||
/* fcb_parse returns length of filename parsed, 0 if EOL, 0xFFFF if error */ |
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
|
|||
#endif /* def CPMREDIR_H_INCLUDED */ |
|||
/*
|
|||
CPMREDIR: CP/M filesystem redirector |
|||
Copyright (C) 1998, John Elliott <jce@seasip.demon.co.uk> |
|||
|
|||
This 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. |
|||
|
|||
This library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Library General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Library General Public |
|||
License along with this library; if not, write to the Free |
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
|
|||
This file holds the public interface to CPMREDIR. |
|||
*/ |
|||
|
|||
#ifndef CPMREDIR_H_INCLUDED |
|||
|
|||
#define CPMREDIR_H_INCLUDED 16-11-1998 |
|||
|
|||
/* The "cpm_byte" must be exactly 8 bits.
|
|||
The "cpm_word" must be exactly 16 bits. */ |
|||
|
|||
typedef unsigned char cpm_byte; |
|||
typedef unsigned short cpm_word; |
|||
|
|||
/* Maximum length of a directory path */ |
|||
#ifdef _POSIX_PATH_MAX |
|||
#define CPM_MAXPATH _POSIX_PATH_MAX |
|||
#else |
|||
#ifdef _MAX_PATH |
|||
#define CPM_MAXPATH _MAX_PATH |
|||
#else |
|||
#define CPM_MAXPATH 260 |
|||
#endif |
|||
#endif |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
/* Initialise this library. Call this function first.
|
|||
* |
|||
* Returns 0 if failed to initialise. |
|||
*/ |
|||
int fcb_init(void); |
|||
|
|||
/* Deinitialise the library. */ |
|||
|
|||
void fcb_deinit(void); |
|||
|
|||
/* Translate a name from the host FS to a CP/M name. This will (if necessary)
|
|||
* create a mapping between a CP/M drive and a host directory path. |
|||
* |
|||
* CP/M drives A: to O: can be mapped in this way. P: is always the current |
|||
* drive. |
|||
* |
|||
*/ |
|||
|
|||
void xlt_name(char* localname, char* cpmname); |
|||
|
|||
/* It is sometimes convenient to set some fixed mappings. This will create
|
|||
* a mapping for a given directory. |
|||
* Pass drive = -1 for "first available", or 0-15 for A: to P: |
|||
* Returns 1 if OK, 0 if requested drive not available. |
|||
* |
|||
* NB: It is important that the localname should have a trailing |
|||
* directory separator! |
|||
*/ |
|||
|
|||
int xlt_map(int drive, char* localdir); |
|||
|
|||
/*
|
|||
* This revokes a mapping. No check is made whether CP/M has files open |
|||
* on the drive or not. |
|||
*/ |
|||
|
|||
int xlt_umap(int drive); |
|||
|
|||
/* Find out if a drive is mapped, and if so to what directory */ |
|||
|
|||
char* xlt_getcwd(int drive); |
|||
|
|||
/* BDOS functions. Eventually this should handle all disc-related BDOS
|
|||
* functions. |
|||
* |
|||
* I am assuming that your emulator has the CP/M RAM in its normal address |
|||
* space, accessible as a range 0-64k. If this is not the case |
|||
* (eg: you are emulating banked memory, or using a segmented architecture) |
|||
* you will have to use "copy in and copy out" techniques. The "fcb" area |
|||
* must be 36 bytes long; the "dma" area should be 128 * the value set |
|||
* in fcb_multirec() [default is 1, so 128 bytes]. |
|||
* |
|||
*/ |
|||
|
|||
cpm_byte fcb_reset(void); /* 0x0D */ |
|||
cpm_word fcb_drive(cpm_byte drv); /* 0x0E */ |
|||
cpm_word fcb_open(cpm_byte* fcb, cpm_byte* dma); /* 0x0F */ |
|||
cpm_word fcb_close(cpm_byte* fcb); /* 0x10 */ |
|||
cpm_word fcb_find1(cpm_byte* fcb, cpm_byte* dma); /* 0x11 */ |
|||
cpm_word fcb_find2(cpm_byte* fcb, cpm_byte* dma); /* 0x12 */ |
|||
cpm_word fcb_unlink(cpm_byte* fcb, cpm_byte* dma); /* 0x13 */ |
|||
cpm_word fcb_read(cpm_byte* fcb, cpm_byte* dma); /* 0x14 */ |
|||
cpm_word fcb_write(cpm_byte* fcb, cpm_byte* dma); /* 0x15 */ |
|||
cpm_word fcb_creat(cpm_byte* fcb, cpm_byte* dma); /* 0x16 */ |
|||
cpm_word fcb_rename(cpm_byte* fcb, cpm_byte* dma); /* 0x17 */ |
|||
cpm_word fcb_logvec(void); /* 0x18 */ |
|||
cpm_byte fcb_getdrv(void); /* 0x19 */ |
|||
/* DMA is a parameter to routines, not a separate call */ |
|||
cpm_word fcb_getalv(cpm_byte* alv, cpm_word max); /* 0x1B */ |
|||
/* Get alloc vector: caller must provide space and say how big it is. */ |
|||
cpm_word fcb_rodisk(void); /* 0x1C */ |
|||
cpm_word fcb_rovec(void); /* 0x1D */ |
|||
cpm_word fcb_chmod(cpm_byte* fcb, cpm_byte* dma); /* 0x1E */ |
|||
cpm_word fcb_getdpb(cpm_byte* dpb); /* 0x1F */ |
|||
cpm_byte fcb_user(cpm_byte usr); /* 0x20 */ |
|||
cpm_word fcb_randrd(cpm_byte* fcb, cpm_byte* dma); /* 0x21 */ |
|||
cpm_word fcb_randwr(cpm_byte* fcb, cpm_byte* dma); /* 0x22 */ |
|||
cpm_word fcb_stat(cpm_byte* fcb); /* 0x23 */ |
|||
cpm_word fcb_tell(cpm_byte* fcb); /* 0x24 */ |
|||
cpm_word fcb_resro(cpm_word bitmap); /* 0x25 */ |
|||
/* Access Drives and Free Drives are not supported. */ |
|||
cpm_word fcb_randwz(cpm_byte* fcb, cpm_byte* dma); /* 0x28 */ |
|||
/* Record locking calls not supported (though they could be) */ |
|||
cpm_word fcb_multirec(cpm_byte rc); /* 0x2C */ |
|||
/* Set hardware error action must be done by caller */ |
|||
cpm_word fcb_dfree(cpm_byte drive, cpm_byte* dma); /* 0x2E */ |
|||
cpm_word fcb_sync(cpm_byte flag); /* 0x30 */ |
|||
cpm_word fcb_purge(void); /* 0x62 */ |
|||
cpm_word fcb_trunc(cpm_byte* fcb, cpm_byte* dma); /* 0x63 */ |
|||
cpm_word fcb_setlbl(cpm_byte* fcb, cpm_byte* dma); /* 0x64 */ |
|||
cpm_word fcb_getlbl(cpm_byte drive); /* 0x65 */ |
|||
cpm_word fcb_date(cpm_byte* fcb); /* 0x66 */ |
|||
cpm_word fcb_setpwd(cpm_byte* fcb, cpm_byte* dma); /* 0x67 */ |
|||
cpm_word fcb_defpwd(cpm_byte* pwd); /* 0x6A */ |
|||
cpm_word fcb_sdate(cpm_byte* fcb, cpm_byte* dma); /* 0x74 */ |
|||
cpm_word fcb_parse(char* txt, cpm_byte* fcb); /* 0x98 */ |
|||
|
|||
/* fcb_parse returns length of filename parsed, 0 if EOL, 0xFFFF if error */ |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#endif /* def CPMREDIR_H_INCLUDED */ |
|||
|
|||
@ -1,408 +1,484 @@ |
|||
/*
|
|||
|
|||
CPMREDIR: CP/M filesystem redirector |
|||
Copyright (C) 1998, John Elliott <jce@seasip.demon.co.uk> |
|||
|
|||
This 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. |
|||
|
|||
This library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Library General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Library General Public |
|||
License along with this library; if not, write to the Free |
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
|
|||
This file holds miscellaneous utility functions. |
|||
*/ |
|||
|
|||
#include "cpmint.h" |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
/* In debug mode, lseek()s can be traced. */ |
|||
|
|||
#ifdef DEBUG |
|||
|
|||
long zxlseek(int fd, long offset, int wh) |
|||
{ |
|||
#ifdef _WIN32 |
|||
long v; |
|||
redir_Msg(">SetFilePointer() Handle=%lu, Offset=%lu, Method=%lu\n", fd, offset, wh); |
|||
v = SetFilePointer((HANDLE)fd, offset, NULL, wh); |
|||
redir_Msg("<SetFilePointer() FilePos=%lu, LastErr=%lu\n", v, GetLastError()); |
|||
if (v == INVALID_SET_FILE_POINTER) |
|||
return -1; |
|||
return v; |
|||
#else |
|||
long v = lseek(fd, offset, wh); |
|||
if (v >= 0) return v; |
|||
|
|||
redir_Msg("lseek fails with errno = %d\n", errno); |
|||
if (errno == EBADF) redir_Msg(" (bad file descriptor %d)\n", fd); |
|||
if (errno == ESPIPE) redir_Msg(" (file %d is a pipe)\n", fd); |
|||
if (errno == EINVAL) redir_Msg(" (bad parameter %d)\n", wh); |
|||
|
|||
return -1; |
|||
#endif |
|||
} |
|||
|
|||
#else |
|||
|
|||
long zxlseek(int fd, long offset, int wh) |
|||
{ |
|||
#ifdef _WIN32 |
|||
return SetFilePointer((HANDLE)fd, offset, NULL, wh); |
|||
#else |
|||
return lseek(fd, offset, wh); |
|||
#endif |
|||
} |
|||
|
|||
|
|||
#endif |
|||
|
|||
#ifdef DEBUG |
|||
|
|||
void redir_showfcb(cpm_byte *fd) |
|||
{ |
|||
int n; |
|||
|
|||
for (n = 0; n < 32; n++) |
|||
{ |
|||
if (!n || n>= 12) printf("%02x ", fd[n]); |
|||
else printf("%c", fd[n] & 0x7F); |
|||
} |
|||
printf("\r\n"); |
|||
} |
|||
|
|||
#endif |
|||
|
|||
/* Get the "sequential access" file pointer out of an FCB */ |
|||
|
|||
long redir_get_fcb_pos(cpm_byte *fcb) |
|||
{ |
|||
long npos; |
|||
|
|||
npos = 524288L * fcb[0x0E]; /* S2 */ |
|||
npos += 16384L * fcb[0x0C]; /* Extent */ |
|||
npos += 128L * fcb[0x20]; /* Record */ |
|||
|
|||
return npos; |
|||
} |
|||
|
|||
void redir_put_fcb_pos(cpm_byte *fcb, long npos) |
|||
{ |
|||
fcb[0x20] = (npos / 128) % 128; /* Record */ |
|||
fcb[0x0C] = (npos / 16384) % 32; /* Extent */ |
|||
fcb[0x0E] = (npos / 524288L) % 64; /* S2 */ |
|||
} |
|||
|
|||
|
|||
/*
|
|||
* find a filename that works. |
|||
* note that this is where we handle the case sensitivity/non-case sensitivity |
|||
* horror. |
|||
* the name that is passed in should be in lower case. |
|||
* we'll modify it to the first one that matches |
|||
*/ |
|||
void |
|||
swizzle(char *fullpath) |
|||
{ |
|||
struct stat ss; |
|||
char *slash; |
|||
DIR *dirp; |
|||
struct dirent *dentry; |
|||
|
|||
/* short circuit if ok */ |
|||
if (stat(fullpath, &ss) == 0) { |
|||
return; |
|||
} |
|||
|
|||
slash = strrchr(fullpath, '/'); |
|||
if (!slash) { |
|||
return; |
|||
} |
|||
*slash = '\0'; |
|||
dirp = opendir(fullpath); |
|||
*slash = '/'; |
|||
while ((dentry = readdir(dirp)) != NULL) { |
|||
if (strcasecmp(dentry->d_name, slash + 1) == 0) { |
|||
strcpy(slash + 1, dentry->d_name); |
|||
break; |
|||
} |
|||
} |
|||
closedir(dirp); |
|||
} |
|||
|
|||
/* Passed a CP/M FCB, convert it to a unix filename. Turn its drive back into
|
|||
* a path. */ |
|||
|
|||
int redir_fcb2unix(cpm_byte *fcb, char *fname) |
|||
{ |
|||
int n, q, drv, ddrv; |
|||
char s[2]; |
|||
|
|||
s[1] = 0; |
|||
q = 0; |
|||
drv = fcb[0] & 0x7F; |
|||
if (drv == '?') drv = 0; |
|||
|
|||
ddrv = fcb[0] & 0x7F; |
|||
if (ddrv < 0x1F) ddrv += '@'; |
|||
|
|||
redir_Msg("%c:%-8.8s.%-3.3s\n", |
|||
ddrv, |
|||
fcb + 1, |
|||
fcb + 9); |
|||
|
|||
if (!drv) strcpy(fname, redir_drive_prefix[redir_cpmdrive]); |
|||
else strcpy(fname, redir_drive_prefix[drv - 1]); |
|||
|
|||
for (n = 1; n < 12; n++) |
|||
{ |
|||
s[0] = (fcb[n] & 0x7F); |
|||
if (s[0] == '?') q = 1; |
|||
if (isupper(s[0])) s[0] = tolower(s[0]); |
|||
if (s[0] != ' ') |
|||
{ |
|||
if (n == 9) strcat(fname, "."); |
|||
strcat(fname, s); |
|||
} |
|||
} |
|||
return q; |
|||
} |
|||
|
|||
#ifndef EROFS /* Open fails because of read-only FS */ |
|||
#define EROFS EACCES |
|||
#endif |
|||
|
|||
int redir_ofile(cpm_byte *fcb, char *s) |
|||
{ |
|||
int h; |
|||
|
|||
/* Software write-protection */ |
|||
#ifdef _WIN32 |
|||
redir_Msg(">CreateFile([OPEN_EXISTING]) Name='%s'\n", s); |
|||
h = (int)CreateFile(s, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
|||
redir_Msg("<CreateFile([OPEN_EXISTING]) Handle=%lu, LastErr=%lu\n", h, GetLastError()); |
|||
if (h == HFILE_ERROR) |
|||
{ |
|||
redir_Msg("Returning -1\n"); |
|||
return -1; |
|||
} |
|||
fcb[9] |= 0x80; |
|||
#else |
|||
#ifdef __MSDOS__ |
|||
int rv; |
|||
if (!redir_ro_fcb(fcb)) |
|||
{ |
|||
rv = _dos_open(s, O_RDWR, &h); |
|||
if (!rv) return h; |
|||
redir_Msg("Open of %s fails: error %x\r\n", s, rv); |
|||
} |
|||
rv = _dos_open(s, O_RDONLY, &h); |
|||
if (rv) return -1; |
|||
fcb[9] |= 0x80; |
|||
#else |
|||
releaseFCB(fcb); |
|||
|
|||
|
|||
swizzle(s); |
|||
|
|||
if (!redir_ro_fcb(fcb)) |
|||
{ |
|||
h = open(s, O_RDWR | O_BINARY); |
|||
if (h >= 0 || (errno != EACCES && errno != EROFS)) |
|||
return trackFile(s, fcb, h); |
|||
} |
|||
h = open(s, O_RDONLY | O_BINARY); |
|||
if (h < 0) return -1; |
|||
fcb[9] |= 0x80; |
|||
#endif |
|||
#endif |
|||
return trackFile(s, fcb, h); |
|||
} |
|||
|
|||
|
|||
/* Extract a file handle from where it was stored in an FCB by fcb_open()
|
|||
or fcb_creat(). Aborts if the FCB has been tampered with. |
|||
|
|||
Note: Some programs (like GENCOM) close FCBs they never opened. This causes |
|||
the Corrupt FCB message, but no harm seems to ensue. */ |
|||
|
|||
int redir_verify_fcb(cpm_byte *fcb) |
|||
{ |
|||
if (fcb[16] != 0xFD || fcb[17] != 0x00) |
|||
{ |
|||
fprintf(stderr,"cpmredir: Corrupt FCB\n"); |
|||
return -1; |
|||
} |
|||
return (int)(redir_rd32(fcb + 18)); |
|||
|
|||
} |
|||
|
|||
/* Print a trace message */ |
|||
|
|||
#ifdef DEBUG |
|||
|
|||
void redir_Msg(char *s, ...) |
|||
{ |
|||
va_list ap; |
|||
|
|||
va_start(ap, s); |
|||
fprintf(stderr, "cpmredir trace: "); |
|||
vfprintf(stderr, s, ap); |
|||
va_end(ap); |
|||
fflush(stderr); |
|||
} |
|||
|
|||
#endif |
|||
|
|||
#define BCD(x) (((x % 10)+16*(x/10)) & 0xFF) |
|||
|
|||
/* Convert time_t to CP/M day count/hours/minutes */ |
|||
dword redir_cpmtime(time_t t) |
|||
{ |
|||
/* Microsoft compiler warned around the conversion from time_t to long
|
|||
* as to support dates beyond 2038 time_t is set as a long long |
|||
* and for the Microsoft compiler sizeof(long) == 4 and sizeof(long long) == 8 |
|||
* for other compilers both have size 8 |
|||
* As the result is a dword (unsigned long), the code below is modified to reflect this |
|||
*/ |
|||
|
|||
dword d = (dword)((t / 86400) - 2921); /* CP/M day 0 is unix day 2921 */ |
|||
dword h = (t % 86400) / 3600; /* Hour, 0-23 */ |
|||
dword m = (t % 3600) / 60; /* Minute, 0-59 */ |
|||
|
|||
return (d | (BCD(h) << 16) | (BCD(m) << 24)); |
|||
} |
|||
|
|||
#undef BCD |
|||
|
|||
#define UNBCD(x) (((x % 16) + 10 * (x / 16)) & 0xFF) |
|||
|
|||
time_t redir_unixtime(cpm_byte *c) |
|||
{ |
|||
time_t t; |
|||
cpm_word days; |
|||
|
|||
days = (c[0] + 256 * c[1]) + 2921; |
|||
|
|||
t = 60L * UNBCD(c[3]); |
|||
t += 3600L * UNBCD(c[2]); |
|||
t += 86400L * days; |
|||
|
|||
return t; |
|||
} |
|||
|
|||
#undef UNBCD |
|||
|
|||
|
|||
/* Functions to access 24-bit & 32-bit words in memory. These are always
|
|||
little-endian. */ |
|||
|
|||
void redir_wr24(cpm_byte *addr, dword v) |
|||
{ |
|||
addr[0] = v & 0xFF; |
|||
addr[1] = (v >> 8) & 0xFF; |
|||
addr[2] = (v >> 16) & 0xFF; |
|||
} |
|||
|
|||
void redir_wr32(cpm_byte *addr, dword v) |
|||
{ |
|||
addr[0] = v & 0xFF; |
|||
addr[1] = (v >> 8) & 0xFF; |
|||
addr[2] = (v >> 16) & 0xFF; |
|||
addr[3] = (v >> 24) & 0xFF; |
|||
} |
|||
|
|||
dword redir_rd24(cpm_byte *addr) |
|||
{ |
|||
register dword rv = addr[2]; |
|||
|
|||
rv = (rv << 8) | addr[1]; |
|||
rv = (rv << 8) | addr[0]; |
|||
return rv; |
|||
} |
|||
|
|||
|
|||
dword redir_rd32(cpm_byte *addr) |
|||
{ |
|||
register dword rv = addr[3]; |
|||
|
|||
rv = (rv << 8) | addr[2]; |
|||
rv = (rv << 8) | addr[1]; |
|||
rv = (rv << 8) | addr[0]; |
|||
return rv; |
|||
} |
|||
|
|||
|
|||
void redir_log_drv(cpm_byte drv) |
|||
{ |
|||
if (!drv) redir_l_drives |= 1; |
|||
else redir_l_drives |= (1L << drv); |
|||
} |
|||
|
|||
void redir_log_fcb(cpm_byte *fcb) |
|||
{ |
|||
int drv = fcb[0] & 0x7F; |
|||
|
|||
if (drv && drv != '?') redir_log_drv(drv - 1); |
|||
else redir_log_drv(redir_cpmdrive); |
|||
} |
|||
|
|||
|
|||
int redir_ro_drv(cpm_byte drv) |
|||
{ |
|||
if (!drv) return redir_ro_drives & 1; |
|||
else return redir_ro_drives & (1L << drv); |
|||
} |
|||
|
|||
int redir_ro_fcb(cpm_byte *fcb) |
|||
{ |
|||
int drv = fcb[0] & 0x7F; |
|||
|
|||
if (drv && drv != '?') return redir_ro_drv(drv - 1); |
|||
else return redir_ro_drv(redir_cpmdrive); |
|||
} |
|||
|
|||
|
|||
|
|||
cpm_word redir_xlt_err(void) |
|||
{ |
|||
if (redir_password_error()) return 0x7FF; /* DRDOS pwd error */ |
|||
switch(errno) |
|||
{ |
|||
case EISDIR: |
|||
case EBADF: return 9; /* Bad FCB */ |
|||
case EINVAL: return 0x03FF; /* Readonly file */ |
|||
case EPIPE: return 0x01FF; /* Broken pipe */ |
|||
case ENOSPC: return 1; /* No space */ |
|||
default: return 0xFF; /* Software error */ |
|||
} |
|||
} |
|||
|
|||
|
|||
#ifdef _WIN32 |
|||
/* minimal implementation of truncate */ |
|||
int truncate(const char* path, off_t length) |
|||
{ |
|||
int result; |
|||
int fd = open(path, O_BINARY | O_RDWR); |
|||
|
|||
if (fd < 0) |
|||
return -1; |
|||
result = ftruncate(fd, length); |
|||
return close(fd) == 0 && result == 0 ? 0 : -1; |
|||
|
|||
} |
|||
|
|||
|
|||
#endif |
|||
/*
|
|||
|
|||
CPMREDIR: CP/M filesystem redirector |
|||
Copyright (C) 1998, John Elliott <jce@seasip.demon.co.uk> |
|||
|
|||
This 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. |
|||
|
|||
This library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Library General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Library General Public |
|||
License along with this library; if not, write to the Free |
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|||
|
|||
This file holds miscellaneous utility functions. |
|||
*/ |
|||
|
|||
#include "cpmint.h" |
|||
|
|||
#ifdef _WIN32 |
|||
|
|||
char* GetErrorStr(dword dwErr) |
|||
{ |
|||
LPVOID lpMsgBuf; |
|||
static char ErrStr[256] = ""; |
|||
|
|||
FormatMessage( |
|||
FORMAT_MESSAGE_ALLOCATE_BUFFER | |
|||
FORMAT_MESSAGE_FROM_SYSTEM | |
|||
FORMAT_MESSAGE_IGNORE_INSERTS | |
|||
FORMAT_MESSAGE_MAX_WIDTH_MASK, |
|||
NULL, |
|||
dwErr, |
|||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
|||
(LPTSTR)&lpMsgBuf, |
|||
sizeof(ErrStr), NULL); |
|||
|
|||
strncpy(ErrStr, lpMsgBuf, sizeof(ErrStr)); |
|||
|
|||
LocalFree(lpMsgBuf); |
|||
|
|||
return ErrStr; |
|||
} |
|||
|
|||
#endif |
|||
|
|||
char* whence(int wh) |
|||
{ |
|||
switch (wh) |
|||
{ |
|||
case SEEK_SET: return("SEEK_SET"); |
|||
case SEEK_CUR: return("SEEK_CUR"); |
|||
case SEEK_END: return("SEEK_END"); |
|||
default: return("SEEK_???"); |
|||
} |
|||
} |
|||
|
|||
/* In debug mode, lseek()s can be traced. */ |
|||
|
|||
long zxlseek(int fd, long offset, int wh) |
|||
{ |
|||
#ifdef _WIN32 |
|||
|
|||
long v; |
|||
DBGMSGV("seek on file #%i to 0x%lX using %s\n", fd, offset, whence(wh)); |
|||
v = SetFilePointer((HANDLE)fd, offset, NULL, wh); |
|||
if (v != INVALID_SET_FILE_POINTER) return v; |
|||
DBGMSGV("seek failed (Error=%lu): %s\n", GetLastError(), GetErrorStr(GetLastError())); |
|||
return -1; |
|||
|
|||
#else |
|||
|
|||
DBGMSGV("seek on #%i to 0x%lX using %s\n", fd, offset, whence(wh)); |
|||
long v = lseek(fd, offset, wh); |
|||
if (v >= 0) return v; |
|||
DBGMSGV("seek failed (errno=%lu): %s\n", errno, strerror(errno)); |
|||
return -1; |
|||
|
|||
#endif |
|||
} |
|||
|
|||
#ifdef DEBUG |
|||
|
|||
void redir_showfcb(cpm_byte* fd) |
|||
{ |
|||
int n; |
|||
|
|||
for (n = 0; n < 32; n++) |
|||
{ |
|||
if (!n || n >= 12) printf("%02x ", fd[n]); |
|||
else printf("%c", fd[n] & 0x7F); |
|||
} |
|||
printf("\n"); |
|||
} |
|||
|
|||
#endif |
|||
|
|||
/* Get the "sequential access" file pointer out of an FCB */ |
|||
|
|||
long redir_get_fcb_pos(cpm_byte* fcb) |
|||
{ |
|||
long npos; |
|||
|
|||
npos = 524288L * fcb[0x0E]; /* S2 */ |
|||
npos += 16384L * fcb[0x0C]; /* Extent */ |
|||
npos += 128L * fcb[0x20]; /* Record */ |
|||
|
|||
return npos; |
|||
} |
|||
|
|||
void redir_put_fcb_pos(cpm_byte* fcb, long npos) |
|||
{ |
|||
fcb[0x20] = (npos / 128) % 128; /* Record */ |
|||
fcb[0x0C] = (npos / 16384) % 32; /* Extent */ |
|||
fcb[0x0E] = (npos / 524288L) % 64; /* S2 */ |
|||
} |
|||
|
|||
/*
|
|||
* find a filename that works. |
|||
* note that this is where we handle the case sensitivity/non-case sensitivity |
|||
* horror. |
|||
* the name that is passed in should be in lower case. |
|||
* we'll modify it to the first one that matches |
|||
*/ |
|||
void swizzle(char* fullpath) |
|||
{ |
|||
struct stat ss; |
|||
char* slash; |
|||
DIR* dirp; |
|||
struct dirent* dentry; |
|||
|
|||
/* short circuit if ok */ |
|||
if (stat(fullpath, &ss) == 0) { |
|||
return; |
|||
} |
|||
|
|||
slash = strrchr(fullpath, '/'); |
|||
if (!slash) { |
|||
return; |
|||
} |
|||
*slash = '\0'; |
|||
dirp = opendir(fullpath); |
|||
*slash = '/'; |
|||
while ((dentry = readdir(dirp)) != NULL) { |
|||
if (strcasecmp(dentry->d_name, slash + 1) == 0) { |
|||
strcpy(slash + 1, dentry->d_name); |
|||
break; |
|||
} |
|||
} |
|||
closedir(dirp); |
|||
} |
|||
|
|||
/* Passed a CP/M FCB, convert it to a unix filename. Turn its drive back into
|
|||
* a path. */ |
|||
|
|||
int redir_fcb2unix(cpm_byte* fcb, char* fname) |
|||
{ |
|||
int n, q, drv, ddrv; |
|||
char s[2]; |
|||
char buf[256]; |
|||
|
|||
s[1] = 0; |
|||
q = 0; |
|||
drv = fcb[0] & 0x7F; |
|||
if (drv == '?') drv = 0; |
|||
|
|||
ddrv = fcb[0] & 0x7F; |
|||
if (ddrv < 0x1F) ddrv += '@'; |
|||
|
|||
if (!drv) strcpy(fname, redir_drive_prefix[redir_cpmdrive]); |
|||
else strcpy(fname, redir_drive_prefix[drv - 1]); |
|||
|
|||
for (n = 1; n < 12; n++) |
|||
{ |
|||
s[0] = (fcb[n] & 0x7F); |
|||
if (s[0] == '?') q = 1; |
|||
if (isupper(s[0])) s[0] = tolower(s[0]); |
|||
if (s[0] != ' ') |
|||
{ |
|||
if (n == 9) strcat(fname, "."); |
|||
strcat(fname, s); |
|||
} |
|||
} |
|||
|
|||
sprintf(buf, "'%c:%-8.8s.%-3.3s' --> '%s'", ddrv, fcb + 1, fcb + 9, fname); |
|||
for (n = 0; buf[n] != '\0'; n++) |
|||
{ |
|||
buf[n] &= 0x7F; |
|||
if (buf[n] < ' ') buf[n] = 'x'; |
|||
} |
|||
|
|||
DBGMSGV("%s\n", buf); |
|||
|
|||
return q; |
|||
} |
|||
|
|||
#ifndef EROFS /* Open fails because of read-only FS */ |
|||
#define EROFS EACCES |
|||
#endif |
|||
|
|||
int redir_ofile(cpm_byte* fcb, char* s) |
|||
{ |
|||
int h; |
|||
|
|||
/* Software write-protection */ |
|||
|
|||
#ifdef _WIN32 |
|||
|
|||
releaseFCB(fcb); |
|||
|
|||
if (!redir_ro_fcb(fcb)) |
|||
{ |
|||
// Attempt to open existing file with read/write access
|
|||
DBGMSGV("open existing file '%s' with read/write access\n", s); |
|||
h = (int)CreateFile(s, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
|||
if (h != HFILE_ERROR) |
|||
{ |
|||
DBGMSGV("file '%s' opened R/W as #%i\n", s, h); |
|||
return trackFile(s, fcb, h); |
|||
} |
|||
DBGMSGV("open R/W failed (errno=%lu): %s\n", GetLastError(), GetErrorStr(GetLastError())); |
|||
} |
|||
|
|||
// Attempt to open existing file with read-only access
|
|||
DBGMSGV("open existing file '%s' with read-only access\n", s); |
|||
h = (int)CreateFile(s, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
|||
if (h == HFILE_ERROR) |
|||
{ |
|||
DBGMSGV("open R/O failed (errno=%lu): %s\n", GetLastError(), GetErrorStr(GetLastError())); |
|||
return -1; |
|||
} |
|||
DBGMSGV("file '%s' opened R/O as #%i\n", s, h); |
|||
fcb[9] |= 0x80; |
|||
|
|||
#elif defined(__MSDOS__) |
|||
|
|||
int rv; |
|||
if (!redir_ro_fcb(fcb)) |
|||
{ |
|||
rv = _dos_open(s, O_RDWR, &h); |
|||
if (!rv) return h; |
|||
DBGMSGV("Open of %s fails: error %x\n", s, rv); |
|||
} |
|||
rv = _dos_open(s, O_RDONLY, &h); |
|||
if (rv) return -1; |
|||
fcb[9] |= 0x80; |
|||
|
|||
#else |
|||
|
|||
releaseFCB(fcb); |
|||
|
|||
swizzle(s); |
|||
|
|||
if (!redir_ro_fcb(fcb)) |
|||
{ |
|||
// Attempt to open existing file with read/write access
|
|||
DBGMSGV("open existing file '%s' with read/write access\n", s); |
|||
h = open(s, O_RDWR | O_BINARY); |
|||
if (h >= 0 || (errno != EACCES && errno != EROFS)) |
|||
{ |
|||
DBGMSGV("file '%s' opened R/W as #%i\n", s, h); |
|||
return trackFile(s, fcb, h); |
|||
} |
|||
DBGMSGV("failed to open R/W (errno=%lu): %s\n", errno, strerror(errno)); |
|||
} |
|||
|
|||
// Attempt to open existing file with read-only access
|
|||
DBGMSGV("open existing file '%s' with read-only access\n", s); |
|||
h = open(s, O_RDONLY | O_BINARY); |
|||
if (h < 0) |
|||
{ |
|||
DBGMSGV("failed to open R/O (errno=%lu): %s\n", errno, strerror(errno)); |
|||
return -1; |
|||
} |
|||
DBGMSGV("file '%s' opened R/O as #%i\n", s, h); |
|||
fcb[9] |= 0x80; |
|||
|
|||
#endif |
|||
|
|||
return trackFile(s, fcb, h); |
|||
} |
|||
|
|||
/* Extract a file handle from where it was stored in an FCB by fcb_open()
|
|||
or fcb_creat(). Aborts if the FCB has been tampered with. |
|||
|
|||
Note: Some programs (like GENCOM) close FCBs they never opened. This causes |
|||
the Corrupt FCB message, but no harm seems to ensue. */ |
|||
|
|||
int redir_verify_fcb(cpm_byte* fcb) |
|||
{ |
|||
if (fcb[16] != 0xFD || fcb[17] != 0x00) |
|||
{ |
|||
fprintf(stderr, "cpmredir: Corrupt FCB\n"); |
|||
return -1; |
|||
} |
|||
return (int)(redir_rd32(fcb + 18)); |
|||
} |
|||
|
|||
/* Print a trace message */ |
|||
|
|||
#ifdef DEBUG |
|||
|
|||
void DbgMsg(const char* file, int line, const char* func, char* s, ...) |
|||
{ |
|||
va_list ap; |
|||
|
|||
va_start(ap, s); |
|||
fprintf(stderr, "%s(%s@%i): ", func, file, line); |
|||
vfprintf(stderr, s, ap); |
|||
va_end(ap); |
|||
fflush(stderr); |
|||
} |
|||
|
|||
#endif |
|||
|
|||
#define BCD(x) (((x % 10)+16*(x/10)) & 0xFF) |
|||
|
|||
/* Convert time_t to CP/M day count/hours/minutes */ |
|||
dword redir_cpmtime(time_t t) |
|||
{ |
|||
/* Microsoft compiler warned around the conversion from time_t to long
|
|||
* as to support dates beyond 2038 time_t is set as a long long |
|||
* and for the Microsoft compiler sizeof(long) == 4 and sizeof(long long) == 8 |
|||
* for other compilers both have size 8 |
|||
* As the result is a dword (unsigned long), the code below is modified to reflect this |
|||
*/ |
|||
|
|||
dword d = (dword)((t / 86400) - 2921); /* CP/M day 0 is unix day 2921 */ |
|||
dword h = (t % 86400) / 3600; /* Hour, 0-23 */ |
|||
dword m = (t % 3600) / 60; /* Minute, 0-59 */ |
|||
|
|||
return (d | (BCD(h) << 16) | (BCD(m) << 24)); |
|||
} |
|||
|
|||
#undef BCD |
|||
|
|||
#define UNBCD(x) (((x % 16) + 10 * (x / 16)) & 0xFF) |
|||
|
|||
time_t redir_unixtime(cpm_byte* c) |
|||
{ |
|||
time_t t; |
|||
cpm_word days; |
|||
|
|||
days = (c[0] + 256 * c[1]) + 2921; |
|||
|
|||
t = 60L * UNBCD(c[3]); |
|||
t += 3600L * UNBCD(c[2]); |
|||
t += 86400L * days; |
|||
|
|||
return t; |
|||
} |
|||
|
|||
#undef UNBCD |
|||
|
|||
/* Functions to access 24-bit & 32-bit words in memory. These are always
|
|||
little-endian. */ |
|||
|
|||
void redir_wr24(cpm_byte* addr, dword v) |
|||
{ |
|||
addr[0] = v & 0xFF; |
|||
addr[1] = (v >> 8) & 0xFF; |
|||
addr[2] = (v >> 16) & 0xFF; |
|||
} |
|||
|
|||
void redir_wr32(cpm_byte* addr, dword v) |
|||
{ |
|||
addr[0] = v & 0xFF; |
|||
addr[1] = (v >> 8) & 0xFF; |
|||
addr[2] = (v >> 16) & 0xFF; |
|||
addr[3] = (v >> 24) & 0xFF; |
|||
} |
|||
|
|||
dword redir_rd24(cpm_byte* addr) |
|||
{ |
|||
register dword rv = addr[2]; |
|||
|
|||
rv = (rv << 8) | addr[1]; |
|||
rv = (rv << 8) | addr[0]; |
|||
return rv; |
|||
} |
|||
|
|||
dword redir_rd32(cpm_byte* addr) |
|||
{ |
|||
register dword rv = addr[3]; |
|||
|
|||
rv = (rv << 8) | addr[2]; |
|||
rv = (rv << 8) | addr[1]; |
|||
rv = (rv << 8) | addr[0]; |
|||
return rv; |
|||
} |
|||
|
|||
void redir_log_drv(cpm_byte drv) |
|||
{ |
|||
if (!drv) redir_l_drives |= 1; |
|||
else redir_l_drives |= (1L << drv); |
|||
} |
|||
|
|||
void redir_log_fcb(cpm_byte* fcb) |
|||
{ |
|||
int drv = fcb[0] & 0x7F; |
|||
|
|||
if (drv && drv != '?') redir_log_drv(drv - 1); |
|||
else redir_log_drv(redir_cpmdrive); |
|||
} |
|||
|
|||
int redir_ro_drv(cpm_byte drv) |
|||
{ |
|||
if (!drv) return redir_ro_drives & 1; |
|||
else return redir_ro_drives & (1L << drv); |
|||
} |
|||
|
|||
int redir_ro_fcb(cpm_byte* fcb) |
|||
{ |
|||
int drv = fcb[0] & 0x7F; |
|||
|
|||
if (drv && drv != '?') return redir_ro_drv(drv - 1); |
|||
else return redir_ro_drv(redir_cpmdrive); |
|||
} |
|||
|
|||
cpm_word redir_xlt_err(void) |
|||
{ |
|||
if (redir_password_error()) return 0x7FF; /* DRDOS pwd error */ |
|||
|
|||
switch (errno) |
|||
{ |
|||
case EISDIR: |
|||
case EBADF: return 9; /* Bad FCB */ |
|||
case EINVAL: return 0x03FF; /* Readonly file */ |
|||
case EPIPE: return 0x01FF; /* Broken pipe */ |
|||
case ENOSPC: return 1; /* No space */ |
|||
default: return 0xFF; /* Software error */ |
|||
} |
|||
} |
|||
|
|||
#ifdef _WIN32 |
|||
|
|||
int truncate(const char* path, off_t length) |
|||
{ |
|||
BOOL bResult; |
|||
HANDLE hFile; |
|||
DWORD dwOffset; |
|||
|
|||
DBGMSGV("truncate file %s to %lu\n", path, length); |
|||
|
|||
hFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
|||
if (hFile == INVALID_HANDLE_VALUE) |
|||
{ |
|||
DBGMSGV("truncate failed to open file (Error=%lu): %s\n", GetLastError(), GetErrorStr(GetLastError())); |
|||
return -1; |
|||
} |
|||
|
|||
dwOffset = SetFilePointer(hFile, length, NULL, FILE_BEGIN); |
|||
if (dwOffset == INVALID_SET_FILE_POINTER) |
|||
{ |
|||
DBGMSGV("truncate failed to open file (Error=%lu): %s\n", GetLastError(), GetErrorStr(GetLastError())); |
|||
CloseHandle(hFile); |
|||
return -1; |
|||
} |
|||
|
|||
bResult = SetEndOfFile(hFile); |
|||
if (!bResult) |
|||
{ |
|||
DBGMSGV("truncate failed to set end of file (Error=%lu): %s\n", GetLastError(), GetErrorStr(GetLastError())); |
|||
CloseHandle(hFile); |
|||
return -1; |
|||
} |
|||
|
|||
bResult = CloseHandle(hFile); |
|||
if (!bResult) |
|||
{ |
|||
DBGMSGV("truncate failed to close file (Error=%lu): %s\n", GetLastError(), GetErrorStr(GetLastError())); |
|||
return -1; |
|||
} |
|||
|
|||
DBGMSGV("truncate set file length to %lu\n", dwOffset); |
|||
return 0; |
|||
} |
|||
|
|||
#endif |
|||
|
|||
File diff suppressed because it is too large
@ -1,50 +1,49 @@ |
|||
extern char *progname; |
|||
extern char **argv; |
|||
extern int argc; |
|||
|
|||
extern byte cpm_drive; |
|||
extern byte cpm_user; |
|||
|
|||
extern byte RAM[65536]; /* The Z80's address space */ |
|||
|
|||
extern void Msg(char *s, ...); |
|||
|
|||
#ifdef BDOS_DEF |
|||
|
|||
word cpm_dma = 0x80; /* DMA address */ |
|||
byte err_mode = 0xFF; |
|||
byte rec_multi = 1; |
|||
word rec_len = 128; |
|||
word ffirst_fcb = 0xFFFF; |
|||
byte cpm_error = 0; /* Error code returned by CP/M */ |
|||
|
|||
#else /* BDOS_DEF */ |
|||
|
|||
extern word cpm_dma, rec_len, ffirst_fcb; |
|||
extern byte err_mode, rec_multi, cpm_error; |
|||
|
|||
#endif /* BDOS_DEF */ |
|||
|
|||
#ifndef O_BINARY /* Necessary in DOS, not present in Linux */ |
|||
#define O_BINARY 0 |
|||
#endif |
|||
|
|||
typedef unsigned long dword; |
|||
|
|||
/* Functions in zxbdos.c */ |
|||
|
|||
void wr24(word addr, dword v); |
|||
void wr32(word addr, dword v); |
|||
dword rd24(word addr); |
|||
dword rd32(word addr); |
|||
dword cpmtime(time_t t); |
|||
word cpm_errcde(word DE); |
|||
|
|||
#ifdef USE_CPMGSX |
|||
gsx_byte gsxrd(gsx_word addr); |
|||
void gsxwr(gsx_word addr, gsx_byte value); |
|||
#endif |
|||
|
|||
void cpmbdos(); |
|||
void cpmbios(); |
|||
|
|||
extern char* progname; |
|||
extern char** argv; |
|||
extern int argc; |
|||
|
|||
extern byte cpm_drive; |
|||
extern byte cpm_user; |
|||
|
|||
extern byte RAM[65536]; /* The Z80's address space */ |
|||
|
|||
extern void Msg(char* s, ...); |
|||
|
|||
#ifdef BDOS_DEF |
|||
|
|||
word cpm_dma = 0x80; /* DMA address */ |
|||
byte err_mode = 0xFF; |
|||
byte rec_multi = 1; |
|||
word rec_len = 128; |
|||
word ffirst_fcb = 0xFFFF; |
|||
byte cpm_error = 0; /* Error code returned by CP/M */ |
|||
|
|||
#else /* BDOS_DEF */ |
|||
|
|||
extern word cpm_dma, rec_len, ffirst_fcb; |
|||
extern byte err_mode, rec_multi, cpm_error; |
|||
|
|||
#endif /* BDOS_DEF */ |
|||
|
|||
#ifndef O_BINARY /* Necessary in DOS, not present in Linux */ |
|||
#define O_BINARY 0 |
|||
#endif |
|||
|
|||
typedef unsigned long dword; |
|||
|
|||
/* Functions in zxbdos.c */ |
|||
|
|||
void wr24(word addr, dword v); |
|||
void wr32(word addr, dword v); |
|||
dword rd24(word addr); |
|||
dword rd32(word addr); |
|||
dword cpmtime(time_t t); |
|||
word cpm_errcde(word DE); |
|||
|
|||
#ifdef USE_CPMGSX |
|||
gsx_byte gsxrd(gsx_word addr); |
|||
void gsxwr(gsx_word addr, gsx_byte value); |
|||
#endif |
|||
|
|||
void cpmbdos(); |
|||
void cpmbios(); |
|||
|
|||
@ -1,154 +1,145 @@ |
|||
#include "zxcc.h" |
|||
#include "zxbdos.h" |
|||
#include "zxcbdos.h" |
|||
|
|||
#ifndef _WIN32 |
|||
#include <sys/ioctl.h> |
|||
#endif |
|||
|
|||
#ifdef _WIN32 |
|||
#include <conio.h> |
|||
#endif |
|||
|
|||
/* Line input */ |
|||
#ifdef USE_CPMIO |
|||
|
|||
|
|||
void bdos_rdline(word line, word *PC) |
|||
{ |
|||
unsigned char *buf; |
|||
|
|||
if (!line) line = cpm_dma; |
|||
else RAM[line + 1] = 0; |
|||
|
|||
buf = (unsigned char *)&RAM[line]; |
|||
|
|||
if (cpm_bdos_10(buf)) *PC = 0; |
|||
} |
|||
|
|||
#else /* def USE_CPMIO */ |
|||
|
|||
void bdos_rdline(word line, word *PC) |
|||
{ |
|||
unsigned char c; |
|||
unsigned char *p; |
|||
int n; |
|||
int maxlen; |
|||
|
|||
if (!line) line = cpm_dma; |
|||
maxlen = RAM[line]; |
|||
|
|||
// fgets causes extra linefeeds, so we invent our own
|
|||
//fgets((char *)(RAM + line + 2), maxlen, stdin);
|
|||
|
|||
p = (RAM + line + 2); |
|||
n = 0; |
|||
|
|||
while (1) { |
|||
c = cin(); |
|||
if (c == '\r') |
|||
break; |
|||
if (c == '\b') { |
|||
if (n > 0) { |
|||
cout('\b'); |
|||
cout(' '); |
|||
cout('\b'); |
|||
n--; |
|||
p--; |
|||
} |
|||
} |
|||
else { |
|||
if (n < maxlen) { |
|||
cout(c); |
|||
*p++ = c; |
|||
n++; |
|||
} |
|||
} |
|||
} |
|||
|
|||
cout('\r'); |
|||
*p = '\0'; |
|||
|
|||
//RAM[line + 1] = strlen((char *)(RAM + line + 2)) - 1;
|
|||
RAM[line + 1] = (unsigned char)n; |
|||
|
|||
Msg("Input: [%d] %-*.*s\n", RAM[line + 1], RAM[line + 1], RAM[line +1], (char *)(RAM+line+2)); |
|||
} |
|||
#endif /* ndef USE_CPMIO */ |
|||
|
|||
#ifndef USE_CPMIO |
|||
|
|||
int cpm_bdos_6(byte e) |
|||
{ |
|||
int c; |
|||
|
|||
switch(e) { |
|||
case 0xFF: |
|||
if (cstat()) return cin(); |
|||
return 0; |
|||
|
|||
case 0xFE: |
|||
return cstat(); |
|||
|
|||
case 0xFD: |
|||
return cin(); |
|||
|
|||
default: |
|||
cout(e); |
|||
break; |
|||
} |
|||
return 0; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef _WIN32 |
|||
byte cin() |
|||
{ |
|||
if (_isatty(STDIN_FILENO)) |
|||
return getch(); |
|||
else |
|||
return getchar(); |
|||
} |
|||
|
|||
void cout(byte c) |
|||
{ |
|||
if (_isatty(STDOUT_FILENO)) |
|||
putch(c); |
|||
else |
|||
putchar(c); |
|||
} |
|||
|
|||
int cstat() |
|||
{ |
|||
if (_isatty(STDIN_FILENO)) |
|||
return _kbhit() ? 0xFF : 0; |
|||
else |
|||
return 0xFF; |
|||
} |
|||
|
|||
#else /* def _WIN32 */ |
|||
|
|||
byte cin() |
|||
{ |
|||
char c = 0; |
|||
|
|||
read(STDIN_FILENO, &c, 1); |
|||
return c; |
|||
} |
|||
|
|||
void cout(byte c) |
|||
{ |
|||
write(STDOUT_FILENO, &c, 1); |
|||
return; |
|||
} |
|||
|
|||
int cstat() |
|||
{ |
|||
int i; |
|||
|
|||
ioctl(STDIN_FILENO, FIONREAD, &i); |
|||
if (i > 0) return 0xFF; |
|||
return 0; |
|||
} |
|||
|
|||
#endif |
|||
#include "zxcc.h" |
|||
#include "zxbdos.h" |
|||
#include "zxcbdos.h" |
|||
|
|||
/* Line input */ |
|||
#ifdef USE_CPMIO |
|||
|
|||
void bdos_rdline(word line, word* PC) |
|||
{ |
|||
unsigned char* buf; |
|||
|
|||
if (!line) line = cpm_dma; |
|||
else RAM[line + 1] = 0; |
|||
|
|||
buf = (unsigned char*)&RAM[line]; |
|||
|
|||
if (cpm_bdos_10(buf)) *PC = 0; |
|||
} |
|||
|
|||
#else /* def USE_CPMIO */ |
|||
|
|||
void bdos_rdline(word line, word* PC) |
|||
{ |
|||
unsigned char c; |
|||
unsigned char* p; |
|||
int n; |
|||
int maxlen; |
|||
|
|||
if (!line) line = cpm_dma; |
|||
maxlen = RAM[line]; |
|||
|
|||
// fgets causes extra linefeeds, so we invent our own
|
|||
// fgets((char *)(RAM + line + 2), maxlen, stdin);
|
|||
|
|||
p = (RAM + line + 2); |
|||
n = 0; |
|||
|
|||
while (1) { |
|||
c = cin(); |
|||
if (c == '\r') |
|||
break; |
|||
if (c == '\b') { |
|||
if (n > 0) { |
|||
cout('\b'); |
|||
cout(' '); |
|||
cout('\b'); |
|||
n--; |
|||
p--; |
|||
} |
|||
} |
|||
else { |
|||
if (n < maxlen) { |
|||
cout(c); |
|||
*p++ = c; |
|||
n++; |
|||
} |
|||
} |
|||
} |
|||
|
|||
cout('\r'); |
|||
*p = '\0'; |
|||
|
|||
//RAM[line + 1] = strlen((char *)(RAM + line + 2)) - 1;
|
|||
RAM[line + 1] = (unsigned char)n; |
|||
|
|||
DBGMSGV("Input: [%d] %-*.*s\n", RAM[line + 1], RAM[line + 1], RAM[line + 1], (char*)(RAM + line + 2)); |
|||
} |
|||
#endif /* ndef USE_CPMIO */ |
|||
|
|||
#ifndef USE_CPMIO |
|||
|
|||
int cpm_bdos_6(byte e) |
|||
{ |
|||
int c; |
|||
|
|||
switch (e) { |
|||
case 0xFF: |
|||
if (cstat()) return cin(); |
|||
return 0; |
|||
|
|||
case 0xFE: |
|||
return cstat(); |
|||
|
|||
case 0xFD: |
|||
return cin(); |
|||
|
|||
default: |
|||
cout(e); |
|||
break; |
|||
} |
|||
return 0; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef _WIN32 |
|||
byte cin() |
|||
{ |
|||
if (_isatty(STDIN_FILENO)) |
|||
return getch(); |
|||
else |
|||
return getchar(); |
|||
} |
|||
|
|||
void cout(byte c) |
|||
{ |
|||
if (_isatty(STDOUT_FILENO)) |
|||
putch(c); |
|||
else |
|||
putchar(c); |
|||
} |
|||
|
|||
int cstat() |
|||
{ |
|||
if (_isatty(STDIN_FILENO)) |
|||
return _kbhit() ? 0xFF : 0; |
|||
else |
|||
return 0xFF; |
|||
} |
|||
|
|||
#else /* def _WIN32 */ |
|||
|
|||
byte cin() |
|||
{ |
|||
char c = 0; |
|||
|
|||
read(STDIN_FILENO, &c, 1); |
|||
return c; |
|||
} |
|||
|
|||
void cout(byte c) |
|||
{ |
|||
write(STDOUT_FILENO, &c, 1); |
|||
return; |
|||
} |
|||
|
|||
int cstat() |
|||
{ |
|||
int i; |
|||
|
|||
ioctl(STDIN_FILENO, FIONREAD, &i); |
|||
if (i > 0) return 0xFF; |
|||
return 0; |
|||
} |
|||
|
|||
#endif |
|||
|
|||
@ -1,4 +1,6 @@ |
|||
void bdos_rdline(word line, word *PC); |
|||
int cpm_bdos_6(byte e); |
|||
|
|||
|
|||
void bdos_rdline(word line, word* PC); |
|||
int cpm_bdos_6(byte e); |
|||
|
|||
byte cin(void); |
|||
void cout(byte); |
|||
int cstat(void); |
|||
|
|||
File diff suppressed because it is too large
@ -1,126 +1,141 @@ |
|||
/*
|
|||
* Change the directories in these #defines if necessary. Note trailing slash. |
|||
*/ |
|||
#ifndef _WIN32 |
|||
#include "config.h" |
|||
#define ISDIRSEP(c) ((c) == '/') |
|||
#define DIRSEPCH '/' |
|||
#define DIRSEP "/" |
|||
#else |
|||
#include "config.h" |
|||
#define ISDIRSEP(c) ((c) == '/' || (c) == '\\') |
|||
#define DIRSEPCH '\\' |
|||
#define DIRSEP "/\\:" |
|||
#endif |
|||
|
|||
#ifndef CPMDIR80 |
|||
#ifdef _WIN32 |
|||
#define CPMDIR80 "d:/local/lib/cpm/" |
|||
#else |
|||
#define CPMDIR80 "/usr/local/lib/cpm/" |
|||
#endif |
|||
#endif |
|||
|
|||
/* the default sub directories trailing / is required */ |
|||
#define BIN80 "bin80/" |
|||
#define LIB80 "lib80/" |
|||
#define INC80 "include80/" |
|||
|
|||
#ifndef BINDIR80 |
|||
#define BINDIR80 CPMDIR80 BIN80 |
|||
#endif |
|||
#ifndef LIBDIR80 |
|||
#define LIBDIR80 CPMDIR80 LIB80 |
|||
#endif |
|||
#ifndef INCDIR80 |
|||
#define INCDIR80 CPMDIR80 INC80 |
|||
#endif |
|||
|
|||
extern char bindir80[]; |
|||
extern char libdir80[]; |
|||
extern char incdir80[]; |
|||
|
|||
#define SERIAL "ZXCC05" |
|||
|
|||
/* System include files */ |
|||
|
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <stdarg.h> |
|||
#include <ctype.h> |
|||
#include <sys/types.h> |
|||
#include <sys/stat.h> |
|||
#include <fcntl.h> |
|||
#ifdef HAVE_UNISTD_H |
|||
#include <unistd.h> |
|||
#endif |
|||
#ifdef _WIN32 |
|||
#include <windows.h> |
|||
#include <io.h> |
|||
#define strcasecmp _stricmp |
|||
#ifndef STDIN_FILENO |
|||
#define STDIN_FILENO _fileno(stdin) |
|||
#define STDOUT_FILENO _fileno(stdout) |
|||
#define STDERR_FILENO _fileno(stderr) |
|||
#endif |
|||
#else |
|||
#include <termios.h> |
|||
#define _isatty(a) isatty(a) |
|||
#define _fileno(a) fileno(a) |
|||
#endif |
|||
#include <errno.h> |
|||
#include <time.h> |
|||
#ifdef __MSDOS |
|||
#include <dos.h> |
|||
#endif |
|||
#ifndef _WIN32 |
|||
#include <sys/param.h> |
|||
#include <sys/mount.h> |
|||
#define _S_IFDIR S_IFDIR |
|||
#endif |
|||
|
|||
/* Library includes */ |
|||
|
|||
#ifdef USE_CPMIO |
|||
#include "cpmio.h" |
|||
#endif |
|||
|
|||
#ifdef USE_CPMGSX |
|||
#include "cpmgsx.h" |
|||
#endif |
|||
|
|||
#include "cpmredir.h" /* BDOS disc simulation */ |
|||
|
|||
typedef unsigned char byte; /* Must be exactly 8 bits */ |
|||
typedef unsigned short word; /* Must be exactly 16 bits */ |
|||
|
|||
/* Prototypes */ |
|||
|
|||
void ed_fe (byte *a, byte *b, byte *c, byte *d, byte *e, byte *f, |
|||
byte *h, byte *l, word *pc, word *ix, word *iy); |
|||
void cpmbdos(byte *a, byte *b, byte *c, byte *d, byte *e, byte *f, |
|||
byte *h, byte *l, word *pc, word *ix, word *iy); |
|||
void cpmbios(byte *a, byte *b, byte *c, byte *d, byte *e, byte *f, |
|||
byte *h, byte *l, word *pc, word *ix, word *iy); |
|||
void dump_regs(FILE *fp, byte a, byte b, byte c, byte d, byte e, byte f, |
|||
byte h, byte l, word pc, word ix, word iy); |
|||
void Msg(char *s, ...); |
|||
int zxcc_term(void); |
|||
void zxcc_exit(int code); |
|||
|
|||
byte cin(void); |
|||
void cout(byte); |
|||
int cstat(void); |
|||
|
|||
/* Global variables */ |
|||
|
|||
extern char *progname; |
|||
extern char **argv; |
|||
extern int argc; |
|||
extern byte RAM[65536]; /* The Z80's address space */ |
|||
|
|||
/* Z80 CPU emulation */ |
|||
|
|||
#include "z80.h" |
|||
|
|||
/*
|
|||
* Change the directories in these #defines if necessary. Note trailing slash. |
|||
*/ |
|||
#ifndef _WIN32 |
|||
#include "config.h" |
|||
#define ISDIRSEP(c) ((c) == '/') |
|||
#define DIRSEPCH '/' |
|||
#define DIRSEP "/" |
|||
#else |
|||
#include "config.h" |
|||
#define ISDIRSEP(c) ((c) == '/' || (c) == '\\') |
|||
#define DIRSEPCH '\\' |
|||
#define DIRSEP "/\\:" |
|||
#endif |
|||
|
|||
#ifndef CPMDIR80 |
|||
#ifdef _WIN32 |
|||
#define CPMDIR80 "d:/local/lib/cpm/" |
|||
#else |
|||
#define CPMDIR80 "/usr/local/lib/cpm/" |
|||
#endif |
|||
#endif |
|||
|
|||
/* the default sub directories trailing / is required */ |
|||
#ifdef _WIN32 |
|||
#define BIN80 "bin80\\" |
|||
#define LIB80 "lib80\\" |
|||
#define INC80 "include80\\" |
|||
#else |
|||
#define BIN80 "bin80/" |
|||
#define LIB80 "lib80/" |
|||
#define INC80 "include80/" |
|||
#endif |
|||
|
|||
#ifndef BINDIR80 |
|||
#define BINDIR80 CPMDIR80 BIN80 |
|||
#endif |
|||
#ifndef LIBDIR80 |
|||
#define LIBDIR80 CPMDIR80 LIB80 |
|||
#endif |
|||
#ifndef INCDIR80 |
|||
#define INCDIR80 CPMDIR80 INC80 |
|||
#endif |
|||
|
|||
extern char bindir80[]; |
|||
extern char libdir80[]; |
|||
extern char incdir80[]; |
|||
|
|||
#define SERIAL "ZXCC05" |
|||
|
|||
/* System include files */ |
|||
|
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <stdarg.h> |
|||
#include <ctype.h> |
|||
#include <sys/types.h> |
|||
#include <sys/stat.h> |
|||
#include <fcntl.h> |
|||
#ifdef HAVE_UNISTD_H |
|||
#include <unistd.h> |
|||
#endif |
|||
#ifdef _WIN32 |
|||
#include <windows.h> |
|||
#include <io.h> |
|||
#include <conio.h> |
|||
#define strcasecmp _stricmp |
|||
#ifndef STDIN_FILENO |
|||
#define STDIN_FILENO _fileno(stdin) |
|||
#define STDOUT_FILENO _fileno(stdout) |
|||
#define STDERR_FILENO _fileno(stderr) |
|||
#endif |
|||
#else |
|||
#include <termios.h> |
|||
#define _isatty(a) isatty(a) |
|||
#define _fileno(a) fileno(a) |
|||
#endif |
|||
#include <errno.h> |
|||
#include <time.h> |
|||
#ifdef __MSDOS |
|||
#include <dos.h> |
|||
#endif |
|||
#ifndef _WIN32 |
|||
#include <sys/param.h> |
|||
#include <sys/mount.h> |
|||
#define _S_IFDIR S_IFDIR |
|||
#endif |
|||
|
|||
/* Library includes */ |
|||
|
|||
#ifdef USE_CPMIO |
|||
#include "cpmio.h" |
|||
#endif |
|||
|
|||
#ifdef USE_CPMGSX |
|||
#include "cpmgsx.h" |
|||
#endif |
|||
|
|||
typedef unsigned char byte; /* Must be exactly 8 bits */ |
|||
typedef unsigned short word; /* Must be exactly 16 bits */ |
|||
|
|||
#include "cpmredir.h" /* BDOS disc simulation */ |
|||
|
|||
/* Prototypes */ |
|||
|
|||
void ed_fe (byte *a, byte *b, byte *c, byte *d, byte *e, byte *f, |
|||
byte *h, byte *l, word *pc, word *ix, word *iy); |
|||
void cpmbdos(byte *a, byte *b, byte *c, byte *d, byte *e, byte *f, |
|||
byte *h, byte *l, word *pc, word *ix, word *iy); |
|||
void cpmbios(byte *a, byte *b, byte *c, byte *d, byte *e, byte *f, |
|||
byte *h, byte *l, word *pc, word *ix, word *iy); |
|||
void dump_regs(FILE *fp, byte a, byte b, byte c, byte d, byte e, byte f, |
|||
byte h, byte l, word pc, word ix, word iy); |
|||
void Msg(char *s, ...); |
|||
void DbgMsg(const char *file, int line, const char *func, char *s, ...); |
|||
int zxcc_term(void); |
|||
void zxcc_exit(int code); |
|||
|
|||
void term_init(void); |
|||
void term_reset(void); |
|||
|
|||
#ifdef DEBUG |
|||
#define DBGMSGV(s, ...) DbgMsg(__FILE__, __LINE__, __func__, s, __VA_ARGS__) |
|||
#define DBGMSG(s) DbgMsg(__FILE__, __LINE__, __func__, s) |
|||
|
|||
#else |
|||
#define DBGMSGV(s, ...) |
|||
#define DBGMSG(s) |
|||
#endif |
|||
|
|||
/* Global variables */ |
|||
|
|||
extern char *progname; |
|||
extern char **argv; |
|||
extern int argc; |
|||
extern byte RAM[65536]; /* The Z80's address space */ |
|||
|
|||
/* Z80 CPU emulation */ |
|||
|
|||
#include "z80.h" |
|||
|
|||
@ -1,8 +1,4 @@ |
|||
|
|||
|
|||
|
|||
int fcbforce(byte *fcb, byte *odrv); |
|||
|
|||
word x_fcb_open(byte *fcb, byte *dma); |
|||
word x_fcb_stat(byte *fcb); |
|||
|
|||
int fcbforce(byte* fcb, byte* odrv); |
|||
|
|||
word x_fcb_open(byte* fcb, byte* dma); |
|||
word x_fcb_stat(byte* fcb); |
|||
|
|||
@ -1,339 +1,339 @@ |
|||
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. |
|||
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. |
|||
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue