DBF Client/Server Suite for Xbase++
Copyright
This document as a whole is copyrighted © 2001 by Phil Ide. The software package (comprising dbfServer.exe, dbSocketc.dll, header [.ch] files, sample programs, source code) is copyright © Jack Duijf & Phil Ide, 2002. All Rights Reserved.
The package is released under the terms of the GNU GENERAL PUBLIC LICENCEDisclaimer
This software is supplied free of charge, and so there is no warranty for the software or accompanying documentation (herinafter called the "package"), to the extent permitted by applicable law. Except when otherwise stated in writing the copyright holders and/or other parties provide the package "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 of this package is with you.
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 package 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 this package (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties).
Any contributions made by others to this package have been acknowledged where possible. Commercial products, retailers, or distributors mentioned here are not necessarily endorsed by me or any other particular party.
Phil Ide code and documentation Jack Duijf code, code, more code and lots of good ideas Bjørn Kaarigstad concept, ideas, inspiration
Many thanks to those who tested and broke everything. Special thanks goes to the following people who made particularly important contributions.
(in no particular order)An especial mention for Jack Duijf, who found more bugs than everyone else put together, and made some very shrewd suggestions, all of which have made dbfServer a far better product than it would otherwise have been.Edgar Borger
Jan-Dirk Schuitmaker
Mike Evans
Mike Grace
Jose Luis Otermin
Markus Walter
Frans Vermeulen
Jack is now an author of dbfServer.
Thanks to everyone else who made comments, gave encouragement etc.
Description
The package consists of a server program which accepts requests via TCP/IP to perform operations on .DBF database tables. All Xbase++ operations are supported with the exception of dacSession (which includes XbpQuickBrowse) and compound legacy UI superfunctions (e.g. dbEdit()). The results of these operations are returned to the client program.
There are many reasons why you might want to remove database operations to a remote program, but in Xbase++ probably the most compelling reason is the way that DBF access times deteriorate rapidly as more and more users connect to the database in a multi-user environment under Windows.
dbfServer still opens the table once for each client connection, spawning a new thread to service each connecting client. Within Xbase++, each thread maintains a unique workspace, which has it's own set of unique workareas. The thread remains active for as along as the server is running and the client is connected.
Client programs can be forced to use the server by linking in a DLL which handles all the communication between server and client. A #include file is supplied which translates all standard database operations to use the functions in the DLL. For many programs, particularly those generated by the Form Designer, this is sufficient. However, this is largely dependant upon coding style, as there are some elements the pre-processor cannot handle, and so some additional changes are likely to be required.
New code can be written to take advantage of the fact that operations are performed through the server. Converted legacy code will suffer from a certain amount of lag since the code was written in the standard 'local connection' format. Understanding how to reduce lag by caching commands is fundamental to getting the best performance from the server.
Using code optimised for best performance with regard to the server will produce fast responsive programs and reduce network traffic immensely thereby making the network itself faster and more responsive to the benefit of all users and applications regardless of whether or not they are utilising dbfServer.
There are several other distinct advantages to using this package:It should be pointed out that any DBF table can be accessed by any client program, provided it is visible to dbfServer.
- Want to lock everybody out of the system? Shut down the server program and everyone will be unable to access the tables!
- Using the server program console, you can see exactly who is connected, which machine they are using, which socket number they are connected through and which files they have open (both tables and indexes).
- Do you have a time-consuming process which you know would run much faster on the server? dbfServer has the ability to run such procedures for you. Not only will the process run much faster, but again network traffic will be vastly reduced to the benefit of all network users.
Converting Existing Programs
To link to the dbfServer in your own application, you need to do the following:That's all there is to it!
- In each source file where database activity takes place, you need to add this directive:
#include "dbfsocket.ch"
- In your project make file, you need to add the following statement to your executable's list of files:
DBFSOCKETC.LIB
- In the same directory as your executable resides, and with the same name but with an .ini extension you need to create an ini file. This file should contain the following code:
[SOCKETS]
port=1042
server=localhost
You should change the port number to match the port dbfServer is listening on, and the server name should be the IP name (or dotted octet address) of the machine where dbfServer can be found.
- New in 1.5 You can now set the client to not automatically connect to the server, by adding to the ini file:
autoconnect=0
This is a boolean value which toggles the autoconnect functionality of the client. The default if this setting is not found is 1 (connect automatically).
- There are three types of code that dbfServer cannot handle:
- Whilst it handles:
(cExpr)->fname
(cExpr)->(fname)
it cannot handle:
alias->fname
alias->(fname)
This is due to limitations in the preprocessor. You should change all such code to enclose the ALIAS in quotes and then parenthesis.
alias->fname// before
("alias")->fname// after
- Expressions generated as macro's from strings will not be parsed properly, and will still expect local workarea connectivity.
- Fieldnames without aliased expressions cannot be pre- determined by the pre-processor. You must alias them.
For example, if you have a table with the field NAME in it, you cannot do this:
cName := NAME
Instead, you must do this:
cName := (Alias())->NAME// or
cName := (cAlias)->NAME
- Remember that the path you supply to the program for opening tables is FROM THE SERVER not the client!
Optimising
The Form Designer when used to connect to a database, adds database access controls to the::editControlsarray, which is then evaluated when the dialog is created or the record pointer is moved (via dialog controls). In a 'local database connection' e.g. aUSEstatement, this is ok. In a remote connection scenario, this becomes innefficient because to refresh 20 controls, you need to send at least 60 instructions to the server. In large data-intensive dialog's, you should consider another strategy.
One method is to performdbfScatter()/dbfGather()to/from an array, and point your dialog controls at the array rather than the database. dbfServer handles these read/write operations in a single instruction.
All database functions are mapped to the functiondbfSocket(). This function accepts 3 parameters:
dbfSocket(<nFunction> [,<aParams> [, <lCache>] ] )
<nFunction>This is a numeric constant identifying the database operation to call. You should use the constants defined in dbfSocket2.ch
<aParams>This optional parameter is an array of parameters to be passed to the function defined in<nFunction>
<lCache>When this parameter is TRUE, the command is automatically cached and not sent to the server until a non-cached command is issued.
Certain commands are automatically cached, but you can usedbfSocket()with the auto-cache option to increase performance. The automatically cached commands are a subset of all commands which return NIL. Some NIL-returning commands are excluded from the subset because they are considered immediate, e.g. dbCommit() and dbCommitAll() should not be cached, nor unlock operations.
If you know that you are not interested in the return value from a command, then you should consider caching it. As an Example,Select(cAlias)may be used to select a workarea prior to performing operations on it, and if you are not interested in saving the return value then you should cache the command.
dbfScatter()anddbfGather()are special functions which request the server to return and process an array respectively. This is more efficient than a standardScatter()/Gather()which sends at least 3 requests to the server for each element of the array. As with the standard Alaska functions,dbfScatter()anddbfGather()handle arrays of simple values or objects, but also more complex data types.
dbfScatter()can accept an optional array. If no array is passed as a parameter, then it returns the entire record as an array. If the parameter is used, the elements can have various types, with each element handled individually. The type of the element dictates how it is interpreted:
Note that the O,B and C types can be aliased expressions, and the alias need not be pre-processed using dbfSocket.ch since it is evaluated on the server.
- U - NIL
The value returned is the vaue of the field at the same ordinal position as the element. For example, if element #5 is NIL, the value of field #5 is returned for this element.- O - Object
The object must have a :setData() method.- B - Code Block
The code block is evaluated, and it's value returned for this element- C - Character
This is assumed to be a quoted fieldname, and is evaluated as a macro.
e.g. 'lastname' is evaluated as &('lastname'), which returns the value of FIELD->LASTNAME.
Further, type O, B and C may refer to other workareas, since they are expressions.
dbfGather()must be passed an array. The elements of the array are handled as follows:
- O - Object
The object must have a :getData() method.- B - Code Block
The code block must perform the field assignment:
e.g. {|| lastname := 'Fredericks' }- Any other type
If the type of the element is anything other than O or B, then it is assumed to be a literal value for the field. The field at the same ordinal position as the element is assigned it's value.
e.g. {'Fredericks'} will assign the value 'Fredericks' to field #1
Automatically Cached Commands
The following commands are automatically cached:
dbAppend() dbGoTo() dbSetFilter() dbClearFilter() dbGoTop() dbSetIndex() dbClearIndex() dbRefresh() dbSetOrder() dbClearRelation() dbResumeSelect() dbSetRelation() dbClearScope() dbRollBack() dbSetScope() dbCloseRelation() dbRSuspendSelect() dbSkip() dbGoBottom() dbSelectArea() OrdCondSet() dbGoPosition() dbSetDescend()
Remote Procedures
Remote Procedures are functions which are called by the client program, but are run entirely on the server. The client tells the server to run the procedure, then waits until the process has completed. The return value of the process is the return value of the called procedure.
Alternatively, Remote Procedures can be called Asynchronously - which means the client instructs the server to perform the operation, but does not wait for it to finish. This can be used in two ways:A Remote Procedure is programmed as a function in a dynamically loadable DLL which must be visible to the server. If the function needs parameters, the function must accept at least one, possibly two parameters.
- Call a Remote Procedure and forget it (e.g. generate a report and send to a printer)
- Call the Remote Procedure, then periodically query the server for status information.
This could be used to return the number of records processed, or % compete etc.Note that you cannot pass variables by reference to a remote procedure.
- aParms - an array containing all the parameters the procedure requires
- bStatus - this is a code-block which is created and sent by the server.
The code-block must accept a single parameter, which is set as the return value if the client queries the status of the Remote Procedure.
The code-block parameter is only required if the procedure may be called asynchronously
To call the remote procedure, use this command:
REMOTE CALL <func> IN <dll> [WITH <parms,...>] [BACKGROUND] [UNLOAD]
<func> is the name of the function to call <dll> is the name (and path if required) of the dll where the function can be found <parms> is a comma-seperated list of all parameters that need to be passed to the function BACKGROUND causes the procedure to be called asynchronously UNLOAD is an optional statement which causes the dll to be unloaded once the procedure has finished.
An example of a (totally senseless!) function that can be used as a remote procedure:
Function Useless(argv) local bFilt := {|| TRUE } local i := 0 local argc := len(argv) if argc > 0 bFilt := argv[1] endif dbGoTop() While !Eof() if Eval(bFilt) i += RecNo() // this is silly... endif SKIP Enddo return (i)
To call this (assume it is linked into "RProc.DLL"):
REMOTE CALL Useless IN RProc WITH {|| GENDER == 'M' } UNLOAD
To perform the same task, but get status information back, call the procedure asynchronously. The procedure will have to be amended to accept the status code-block:
Function Useless(argv, bStatus) local bFilt := {|| TRUE } local i := 0 local argc := len(argv) local nCount := 0 if argc > 0 bFilt := argv[1] endif dbGoTop() While !Eof() if Eval(bFilt) i += RecNo() // this is silly... EVal(bStatus,++nCount) // record how many records we have processed endif SKIP Enddo return (i)
Then in the client program...
uRet := TRUE lAbort := FALSE REMOTE CALL Useless IN RProc WITH {|| GENDER == 'M' } BACKGROUND UNLOAD while ValType(uRet) != "U" .and. !lAbort uRet := dbfRemoteStatus(_DBF_REMOTEPROCSTATUS) @ 17,40 say as(uRet) if inkey(.5) = 27 lAbort := TRUE endif enddo
Error Handling
If the client attempts to perform an operation which fails at the server, the server returns an error object to the client, which automaticaly passes it to the current error handler. Any error message displayed by the client will probably display the callstack of the client program, so you should be able to track logic errors in your code. In the event the error really belongs to a bug in the server (oh, horror!), you can find the callstack of the server embedded in the error object's cargo slot.
By passing the error back to the client to handle, the error is displayed where the problem most likely lays - if you attempt to write a record without locking it first, the problem is in the client code not the server. This also makes the server robust and resilient, allowing other connected clients to continue working without interruption.
Remote Disk, File & Environment Functions
There are a number of Disk, File & Environment functions which you can call. They have the same name as their 'local' counterparts with 'cs' prepended to their name. The calling convention is the same as for their local counterparts too, but some care should be taken when using these functions.
Server-Side Functions
csCreateDir() csFError() csFseek() csMemoWrit() csDate() csFExists() csFSize() csNetErr() csDirectory() csFile() csFWrite() csPutFile() csFAttr() csFOpen() csGetDriveDescriptors() csRemoveDir() csFClose() csFread() csGetEnv() csSeconds() csFCreate() csFReadStr() csGetFile() csSetEnv() csFErase() csFRename() csMemoRead() csTime()
Warnings
csFError() returns an OS error for a low-level file operation. The error returned is for the latest error, which in a multi-user application where multiple users are using the same program, may return someone else's error.
csNetErr() suffers from the same problems as FError(), only it is more likely to return an incorrect value.
csFRead(). This is now a direct replacement for FRead(), and should be coded in exactly the same way. The second parameter should be passed by reference, and the return value is the number of bytes read. This is incompatible with releases prior to 1.0.
GetDriveDescriptors() / csGetDriveDescriptors()
These functions return a list of available local and mapped drives on the machine where the function is performed. In the case of GetDriveDescriptors() it is performed on the client machine, and csGetDriveDescriptors() is performed on the server.
The return value is an array, where each element is an array which describes a logical drive. The format of the sub-array is:
{cDriveName, nDescriptor}cDriveName is 'A:\', 'C:\', 'D:\' etc.
nDescriptor is a numeric, which matches one of the constants defined in dbfSocket.ch
Use the function DriveToText(<n>) passing nDescriptor to get a textual description of the drive, as indicated in the table below.
Constants for Drive Descriptors Constant Explanation DriveToText() DRIVE_UNKNOWN Unidentified "Unknown" DRIVE_NO_ROOT Problem with drive "No Root" DRIVE_REMOVEABLE Non-Floppy, Non-CD Removable "Removeable" DRIVE_FIXED Local Hard drive "Fixed" DRIVE_REMOTE Network Drive "Network" DRIVE_CDROM CD-ROM drive "CD-ROM" DRIVE_RAMDISK Ramdisk "Ramdisk"
csPutFile(cLocalFile,cRemoteFile) is used to transfer a file to the server.
csGetFile(cRemoteFile,cLocalFile) is used to transfer a file from the server.
Using Remote XPF files
The commands SAVE TO & RESTORE FROM (and their variants) can be forced to save/restore from files held on the server by prepending the command with the keyword REMOTE
SAVE TO temp // save all memvars to local xpf RESTORE FROM temp // restore from local xpf REMOTE SAVE TO temp // save all memvars to remote xpf REMOTE RESTORE FROM temp // restore from remote xpfAn alternative to using the REMOTE keyword, is to define the constant
_DBFSERVER_MEM_REMOTE_ before the #include "dbfSocket.ch" statement.
This will cause existing code to save/restore from the server.
Connecting New Threads
If you spawn a new thread in your application, it is necessary for that thread to have it's own connection to the server, since each thread has it's own workspace.
The easiest way to do this, is to subclass Thread() and overload with these methods:#define SOCK_STREAM 1 METHOD myThread:atStart() local aSockParms := dbfSocketGetParameters() if dbfSocketOpen( SOCK_STREAM, ; aSockParms[DBFCS_GP_SERVER],; aSockParms[DBFCS_GP_PORT] ) <> 0 // error - want to quit the thread? endif return self METHOD myThread:atEnd() dbfSocketClose() return self
Rebuilding the Server and dbfSocket.dll
To rebuild either the server or dbfSocketC.dll, you will require ASINET1C.LIB, which is part of the Professional Subscription.
ASINET1C.DLL, which is part of the Professional Subscription redistributable libraries, is supplied with the package, and should be placed in your RUNTIME directory or somewhere in your PATH.
About Scopes
Scopes implemented through dbfServer behave slightly differently from the standard Xbase++ implementation. In Xbase++, after setting a scope, the following is true:
(assume scope does not include logical top and bottom records)dbGoTop() nTop := RecNo() dbSkip(-1) ? Bof() // TRUE ? Eof() // FALSE ? RecNo() // == nTop - 1 dbGoBottom() nBottom := RecNo() dbSkip() ? Bof() // FALSE ? Eof() // TRUE ? RecNo() // nBottom+1With dbfServer, the following is true:dbGoTop() nTop := RecNo() dbSkip(-1) ? Bof() // TRUE ? Eof() // FALSE ? RecNo() // == nTop dbGoBottom() dbSkip() ? Bof() // FALSE ? Eof() // TRUE ? RecNo() // LastRec()+1 (ghost record)Whilst this is incompatible with Xbase++, we believe this is the correct behaviour.
GNU GENERAL PUBLIC LICENCE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
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.
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.