dictd-1.12.1+dfsg.orig/0000755000000000000000000000000012003013104013217 5ustar rootrootdictd-1.12.1+dfsg.orig/doc/0000755000000000000000000000000012124661563014012 5ustar rootrootdictd-1.12.1+dfsg.orig/doc/Makefile.in0000644000000000000000000000614312124661563016063 0ustar rootroot# Makefile.in -- # Created: Mon May 26 09:57:04 1997 by faith@acm.org # Revised: Sun Mar 8 08:02:35 1998 by faith@acm.org # Copyright 1997, 1998 Rickard E. Faith (faith@acm.org) # # 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 1, 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. # # $Id: Makefile.in,v 1.8 2002/09/16 12:48:39 cheusov Exp $ # ifneq (,) This makefile requires GNU Make. endif .SUFFIXES: srcdir= @srcdir@ VPATH= @srcdir@ prefix= @prefix@ subdirs= @allsubdirs@ regex exec_prefix= @exec_prefix@ man1_prefix= $(prefix)/man/man1 SHELL= /bin/sh NROFF= @NROFF@ TROFF= @TROFF@ COL= @COL@ EXPAND= @EXPAND@ INSTALL= @INSTALL@ INSTALL_PROGRAM=@INSTALL_PROGRAM@ INSTALL_DATA= @INSTALL_DATA@ dicf: dicf.txt # all: rfc.txt rfc.txt: rfc.ms toc.ms @echo "Building table of contents, pass 1" @echo "" > rfc.toc @$(NROFF) -ms toc.ms | @AWK@ '/STARTTOC/ { p = 1 } \ /\..\..\../ { if (p == 1) print }' > rfc.toc.new @cp rfc.toc.new rfc.toc @echo "Building table of contents, pass 2" @$(NROFF) -ms toc.ms | @AWK@ '/STARTTOC/ { p = 1 } \ /\..\..\../ { if (p == 1) print }' > rfc.toc.new @cp rfc.toc.new rfc.toc @echo "Building table of contents, pass 3 (verification)" @$(NROFF) -ms toc.ms | @AWK@ '/STARTTOC/ { p = 1 } \ /\..\..\../ { if (p == 1) print }' > rfc.toc.new @cmp -s rfc.toc.new rfc.toc || echo "WARNING: Contents Changed!" @echo "Building document..." $(NROFF) -ms rfc.ms | ./rfc.sh | $(EXPAND) > rfc.txt dicf.txt: dicf.ms dicftoc.ms @echo "Building table of contents, pass 1" @echo "" > dicf.toc @$(NROFF) -ms dicftoc.ms | @AWK@ '/STARTTOC/ { p = 1 } \ /\..\..\../ { if (p == 1) print }' > dicf.toc.new @cp dicf.toc.new dicf.toc @echo "Building table of contents, pass 2" @$(NROFF) -ms dicftoc.ms | @AWK@ '/STARTTOC/ { p = 1 } \ /\..\..\../ { if (p == 1) print }' > dicf.toc.new @cp dicf.toc.new dicf.toc @echo "Building table of contents, pass 3 (verification)" @$(NROFF) -ms dicftoc.ms | @AWK@ '/STARTTOC/ { p = 1 } \ /\..\..\../ { if (p == 1) print }' > dicf.toc.new @cmp -s dicf.toc.new dicf.toc || echo "WARNING: Contents Changed!" @echo "Building document..." $(NROFF) -ms dicf.ms | ./rfc.sh | $(EXPAND) > dicf.txt # This is pretty ugly rfc.ps: rfc.ms $(TROFF) -ms rfc.ms > rfc.ps .PHONY: clean distclean tags clean: -rm -f *.ps *.txt rfc.toc rfc.toc.new distclean: clean -rm -f Makefile tags: etags *.[ch] # This is from the textutils-1.11 lib/Makefile.in subdir=doc Makefile: Makefile.in ../config.status cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status dictd-1.12.1+dfsg.orig/doc/dicf.ms0000644000000000000000000002626106547774676015315 0ustar rootroot.\" .\" Created: Sun Mar 8 07:46:40 1998 .\" Revised: Sun Mar 8 10:34:44 1998 by faith@acm.org .\" Distribution of this memo is unlimited. .\" .\" $Id: dicf.ms,v 1.1 1998/07/05 22:10:06 faith Exp $ .\" .pl 10.0i .po 0 .ll 7.2i .lt 7.2i .nr LL 7.2i .nr LT 7.2i .ds DA 8 March 1988 .ds LH DDG-TR-2 DRAFT .ds CH DICT Interchange Format .ds RH \*(DA .ds LF .ds CF .ds RF FORMFEED[Page %] .hy 0 .ad l .in 0 .tl 'DICT Development Group''\*(LH' .tl '''\*(DA' .de HU .RE .SH \\$1 .RS .hy 0 .. .de HR .RE .NH \\$1 \\$2 \\$3 .RS .hy 0 .XS \\*(SN\t\\$3 .XE .. .de HN .RE .NH \\$1 \\$2 .RS .hy 0 .XS \\*(SN\t\\$2 .XE .. .de Hn .RE .NH \\$1 \\$2 .RS .hy 0 .. .ds an-empty \" this is referenced to avoid looping on eg .RB ( \\ ) .de BR .ds an-result \& .while \\n[.$]>=2 \{\ . as an-result \fB\\$1\fR\\$2\\*[an-empty] . shift 2 .\} .if \\n[.$] .as an-result \fB\\$1 \\*[an-result] .ft R .. .hy 0 .ce DICT Interchange Format .RS .HU "Status of this Memo" This document is a DICT Development Group Technical Report. .HU "Abstract" The DICT Interchange Format (DICF) is a human-readable format for the interchange of dictionary databases for the use with DICT protocol client/server software. .\".bp .HU "Table of Contents" .RE .sp .nf .so dicf.toc .fi .RS .HR 1 0 "Introduction" .HN 2 "Requirements" In this document, we adopt the convention discussed in Section 1.3.2 of [RFC1122] of using the capitalized words MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, and OPTIONAL to define the significance of each particular requirement specified in this document. In brief: "MUST" (or "REQUIRED") means that the item is an absolute requirement of the specification; "SHOULD" (or "RECOMMENDED") means there may exist valid reasons for ignoring this item, but the full implications should be understood before doing so; and "MAY" (or "OPTIONAL") means that his item is optional, and may be omitted without careful consideration. .HN 1 "Design Considerations" .HN 2 "Introduction" The goal of DICF is to provide a format suitable for the interchange of dictionary databases. New databases can be converted into DICF, and then the DICF can be analyzed and indexed by DICT server software. If machine translation were the only use of DICF, then SGML might be the best choice for DICF syntax. However, we expect humans to create new dictionary databases by hand, and we have found that the use of SGML without specialized editors is difficult for humans to read and edit. We have found a minimalistic syntax, similar to .B nroff or TeX, easier to edit using a wide variety of text-based editors. Further, we would like to be able to combine a DICF formatting engine into other pieces of software, such as DICT protocol clients and servers. Therefore, we would like the parsing and formatting requirements of DICF to be lightweight and easy to implement. We also would like underlying engine to be powerful enough to support unforeseen extensions that might be needed to support complex databases. From this viewpoint, engines bases on SGML or TeX would be too large to be easily embedded in other applications. The .B nroff language [NROFF86] is well documented, extensible, and relatively small. We have decided to base the DICF langauge syntax and capabilities on an extended subset of .BR nroff . .HN 2 "Requirements" DICF must be translatable to the following formats: .RS .IP \(bu ASCII text [ASCII] .IP \(bu UTF-8 encoded text [ISO10646,RFC2044] .IP \(bu HTML [XXX] .RE Further, DICF must be sufficiently powerful to support the indexing requirements of current and future versions of DICT client/server software; and DICF must be editable without a specialized editor. .HN 2 "Limitations" DICF provide simpler capabilities that a full .B nroff implementation: .RS .IP \(bu Page control commands are not needed, since a single definition will always appear on a single logical page. This includes the commands: .BR .pl ", " .bp ", " .pn ", " .po ", " .ne ", " .mk ", and " .rt . .IP \(bu Because definitions and formatting instructions will be included in a single file, the ability to access other files and programs should not be supported. This includes the commands: .BR .so ", " .nx ", and " .pi . Note that the elimination of these command also eliminates security considerations from the formatting language. .RE Because the notion of pages have changed, commands dealing with traps (i.e., .BR .wh ", " .ch ", " .dt ", " .em ", and " .it ) and titles (i.e., .BR .tl ", " .pc, ", and " .lt ) may have slightly different meanings than in standard .BR nroff . .HN 2 "Extensions" Because of the necessity of dealing with UTF-8 encoded characters and the requirement that DICF file can be easily edited by standard editors, the syntax for special characters is extended. .HN 1 "Language Syntax" .HN 1 "Commands" .HN 2 "Entries" An "entry" will contain a definitiona and will usually be marked for indexing by at least one headword (if no headwords are marked in an entry, then the entry cannot be searched for). An entry starts with: .DS .e .DE or with: .DS .e word .DE which is equivalent to: .DS .e .h word .DE as described in the next section. An entry ends when: .RS .IP \(bu the next entry begins, .IP \(bu the end of the file is reached, .IP \(bu or .DS .. .DE is seen on the input. .RE Blank lines at the end of an entry MUST BE elided. .HN 2 "Headwords" For an entry, several words might be marked as "headwords". These headwords are placed in an index such that a search on the index for the headword will return the entry containing the headword. By default, if a headword is indexed, then all standard search methods should find that headword and return the definition. However, some headwords may best identify an entry only when an "exact" search is performed, and should not be returned for various inexact searches. For example, uncommon spellings or misspellings of a word may reasonably identify an entry when an exact search is performed, but would confuse a user if these spellings were also returned when an inexact search was performed. Another example arises in gazetteer-like dictionaries: an exact search for "city, state" should return the appropriate informatin, but inexact searches should only return a list of cities without state names \(em otherwise too many matches are returned for inexact searches, making these types of searches useless (because so many cities have the same name). Other headwords may be marked so that they are only returned for specific types of searches. For example, an entry may mark several words as "mentioned". These words should not identify the entry for the usual exact or inexact searches, because doing to would return too many unrelated definitions. However, a special "mentioned" search may return entries which mention or provide usage examples for words which are peripheral to the main word being defined by the entry. The best types of searches provided depend on the specific database. DICF defines the three most common builtin marks for headwords: .DS .h word .DE marks "word" as a headword for common exact and inexact searches. .DS .he word .DE marks "word" as a headword only for exact searches. If the DICT server does not support multiple types of index entries, then this headword will not be indexed. .DS .hm word .DE marks "word" as a headword only for special "mentioned" searches. If the DICT server does not support multiple types of index entries, then this headword will not be indexed. By default, a word marked as a headword will be inserted in place in the text of the definition. If this insertion is not desired, the following alternative forms of these commands are provided: .B .hn ", " .hen ", and " .hmn . .HN 2 "Cross References" For an entry, several words might be marked as "cross references" so that, during definition display, selection of one of these words will search for another definition. By default, these words are inserted in place in the text of the definition. As with the headword commands, an alternative form is provided that does not have this behavior. .DS .x word .DE marks "word" as a cross reference to another entry, inserting the word in place in the definition text. .DS .xn word .DE marks "word" as a cross reference to another entry, but does not insert the word in the definition text. If the DICT server does not support cross references to words which do not appear in the text, then "word" will be ignored. This command is provided for orthogonality with the headword commands and for support of future DICT and DICF capabilities. .HN 2 "Word Marks" Some words (including compound words, or phrases) may be marked as having special features which may imply status as a headword and/or cross reference, or suggest the use of font changes to set the word appart. For example: .DS .title Book/paper/record/movie title .person Name of a person .syn Synonym .ant Antonym .cf Compare with .see See also .genus Name of a genus .species Name of a species .subspecies Name of a subspecies .order Name of an order .phylum Name of a phylum .class Name of a class .family Name of a family .chem Chemical notation .math Mathematical notation [XXX shouldn't be here] .DE .HN 2 "Informational Marks" In many databases, the text of the entry will follow the headword in a free format. For other databases, marking some parts of the entry may be helpful for later machine processing or formatting: .DS .note Note .usage Usage note .q Quote, usually as an example .qa Author of previous quote .ex Example of usage .au Author of entry .s Source of entry .pron Pronounciation .syl Syllabification .pos Part of speech .var Variant .altsp Alternative spelling .pl Spelling of plural form .sing Spelling of singular form .DE .HN 1 "Security Considerations" Because DICF commands cannot cause the execution of arbitrary programs, DICF raises no security issues. .HN 1 "References" .XP [ASCII] US-ASCII. Coded Character Set - 7-Bit American Standard Code for Information Interchange. Standard ANSI X3.4-1986, ANSI, 1986. .XP [ISO10646] ISO/IEC 10646-1:1993. International Standard -- Information technology -- Universal Multiple-Octet Coded Character Set (UCS) -- Part 1: Architecture and Basic Multilingual Plane. UTF-8 is described in Annex R, adopted but not yet published. UTF-16 is described in Annex Q, adopted but not yet published. .XP [NROFF86] Ossanna, Joseph F. Nroff/Troff User's Manual, updated for 4.3BSD by Mark Seiden (USD-24). Published in UNIX User's Supplementary Documents (USD): 4.3 Berkeley Software Distribution, Virtual VAX-11 Version, April 1986 (Computer Systems Research Group, Computer Science Division, Department of Electrical Engineering and COmputer Science, University of California, Berkeley). .XP [RFC2044] Yergeau, F., "UTF-8, a transformation format of Unicode and ISO 10646", RFC-2044, Alis Technologies, October 1996. .HN 1 "Acknowledgements" .HN 1 "Author's Addresses" .DS Rickard E. Faith EMail: faith@cs.unc.edu (or faith@acm.org) .DE .DS Bret Martin EMail: bamartin@miranda.org .DE .RE .\" Local Variables: .\" mode: nroff .\" mode: font-lock .\" fill-column: 70 .\" End: dictd-1.12.1+dfsg.orig/doc/rfc.sh0000755000000000000000000000066306342272224015125 0ustar rootroot#!/bin/sh # rfc.sh -- # Created: Tue Apr 22 09:41:37 1997 by faith@cs.unc.edu # Revised: Tue Apr 22 09:46:26 1997 by faith@cs.unc.edu # Public Domain 1997 Rickard E. Faith (faith@cs.unc.edu) # # $Id: rfc.sh,v 1.1 1997/05/26 11:31:32 faith Exp $ # # awk '/.*FORMFEED.*/ { print; flag=1; next } /^$/ { if (!flag) print; next } { print; flag=0 }' \ | sed 's/^\(.*\)FORMFEED\(.*\)$/\1 \2\ /' dictd-1.12.1+dfsg.orig/doc/security.doc0000644000000000000000000000256406363751744016370 0ustar rootroot This is a brief note on security aspects of the DICT server: * Searches that return the whole index Description: Some searches, such as "MATCH * re ." will return the whole database index, and this index must be buffered by the server. Each server instance can therefore be using 4-5MB for a typical installation. This can result in significant resource utilization on the server machine, swapping, and possible DoS. Solutions: * limit connections * limit amount of data returned * limit simultaneous outstanding searches (e.g., "increment a lock (eg, create a link to a file) every time you start searching for a definition, and decrement it (eg unlink) when the results have been looked up, if the number (eg link count) exceeds n, sleep a while before looking it up.") * Denial of service by idling clients Description: An adversary can connect to the server multiple times (until the server limit is reached) and thereby deny other clients access to the server. Solutions: * limit connections based on IP or mask * Enhance access control, like hosts_access(5) in TCP Wrappers. * NIS/YP * IP/mask * "paranoid" checks for reverse DNS * Buffer overflow * Robustify logging routines (e.g., daemon_log and use of strlen) dictd-1.12.1+dfsg.orig/ANNOUNCE0000644000000000000000000000477506474072461014417 0ustar rootrootThe DICT Development Group (www.dict.org) announces the dictd-1.4.x distribution, containing client/server software implementing the Dictionary Server Protocol, as described in RFC 2229. The Dictionary Server Protocol (DICT) is a TCP transaction based query/response protocol that allows a client to access dictionary definitions from a set of natural language dictionary databases. dict(1) is a client which can access DICT servers from the command line. dictd(8) is a server which supports the DICT protocol. dictzip(1) is a compression program which creates compressed files in the gzip format (see RFC 1952). However, unlike gzip(1), dictzip(1) compresses the file in pieces and stores an index to the pieces in the gzip header. This allows random access to the file at the granularity of the compressed pieces (currently about 64kB) while maintaining good compression ratios (within 5% of the expected ratio for dictionary data). dictd(8) uses files stored in this format. Available in separate .tar.gz files are the data, conversion programs, and formatted output for several freely-distributable dictionaries. For any single dictionary, the terms for commercial distribution may be different from the terms for non-commercial distribution -- be sure to read the copyright and licensing information at the top of each database file. Below are approximate sizes for the databases, showing the number of headwords in each, and the space required to store the database: Database Headwords Index Data Uncompressed web1913 185399 3438 kB 11 MB 30 MB wn 121967 2427 kB 7142 kB 21 MB gazetteer 52994 1087 kB 1754 kB 8351 kB jargon 2135 38 kB 536 kB 1248 kB foldoc 11508 220 kB 1759 kB 4275 kB elements 131 2 kB 12 kB 38 kB easton 3968 64 kB 1077 kB 2648 kB hitchcock 2619 34 kB 33 kB 85 kB All of these compressed databases and indices can be stored in approximately 32MB of disk space. The software has been developed under Linux 2.0.x and SunOS 4.1.x. Porting to other Unix-like operating systems should be straightforward. Software and databases are available for anonymous ftp from: ftp://ftp.cs.unc.edu/pub/users/faith/dict, and ftp://ftp.dict.org/pub/dict For more information on the DICT project, please see: http://www.dict.org dictd-1.12.1+dfsg.orig/COPYING0000644000000000000000000004307606311100513014272 0ustar rootroot 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. Copyright (C) 19yy 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. , 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. dictd-1.12.1+dfsg.orig/INITSCRIPT0000644000000000000000000000136707030136745014666 0ustar rootroot#!/bin/sh # Example script courtesy of Jeff Blain DICTD=/where/is/your/dictd_binary # DICTD_OPTIONS="-put -command_line -options -for -dictd -here" DICTD_OPTIONS="" DICTD_PID_FILE=/etc/dictd.pid case "$1" in 'start') if [ -x $DICTD ]; then echo "dictd starting." $DICTD $DICTD_OPTIONS else echo "dictd.init: cannot find $DICTD or it's not executable" fi ;; 'stop') if [ ! -f $DICTD_PID_FILE ]; then exit 0 fi dictdpid=`cat $DICTD_PID_FILE` if [ "$dictdpid" -gt 0 ]; then echo "Stopping the dictd server." kill -15 $dictdpid 2>&1 > /dev/null fi rm -f $DICTD_PID_FILE ;; *) echo "Usage: dictd.init { start | stop }" ;; esac exit 0 dictd-1.12.1+dfsg.orig/INSTALL0000644000000000000000000001646611625677537014330 0ustar rootrootPlease read the file README in this directory for additional important information on The DICT Development Group, this software, mailing lists, etc. INSTALLATION ============ 0. Before building Dictionary server (dictd) or Dictionary client (dict), you should build (and optionally install) libmaa library. cd libmaa ./configure make make install Installing libmaa is actually not mandatory. See below. 1. Configure the source code and Makefiles: ./configure NOTE: the configure script accepts the common --prefix flag for installing the software in an installer-defined location. For example, you can do something like: ./configure --prefix=/opt/gnu NOTE: as of version 1.8.0, dictd supports plugins. If you do not want support for them, disable it: ./configure --disable-plugin NOTE: as of version 1.9.10, dictd can be built with any regex engine you want. By default system-wide one is used. It is assumed that it is libc library. Example: (to build dictd with TRE regex library): env LDFLAGS='-L/usr/local/lib/ -ltre' \ CPPFLAGS='-I/usr/local/include/tre' ./configure make You can also link dictd/dict/... against libmaa statically. env LDFLAGS='-Llibmaa/.libs' CPPFLAGS='-Ilibmaa' ./configure make 2. Compile the client and server software: make NOTE: If you want to build only the client software, use 'make dict' instead of just 'make'. In order to make dictd, dictfmt or dictzip only, run 'make dictd', 'make dictfmt' or 'make dictzip'. [The dict client has been tested under Cygwin+Win98. As of version 1.9.9, dictd can also be run on cygwin from inetd. It has been tested on NT4/sp6 + cygwin-1.3.6 and W2K + cygwin-1.3.22] NOTE: If you use an old version of flex, you may get errors. Try upgrading it. 3. Install the client, server, and manual pages: make install NOTE: If you only built the client software in step 2, use 'make install.dict' instead of 'make install'. You can also use 'make install.dictd', 'make install.dictfmt' and 'make install.dictzip'. 4. Uninstall the client, server, and manual pages: make uninstall NOTE: If you only built the client software in step 2, use 'make uninstall.dict' instead of 'make uninstall' You can also use 'make uninstall.dictd', 'make uninstall.dictfmt' and 'make uninstall.dictzip'. 5. Several plugin examples are available. One of them is C++-based 'popen' plugin which runs an external program for both DEFINE and MATCH queries. If you want to build/install/uninstall these samples, run the following commands respectively: make samples make install.samples make uninstall.samples Also 'man_popen' dictionary based on 'popen' plugin is available. Its functionality is a subset of that of the 'man' command. Only 'exact' and 'substring' search strategies are implemented. In order to test 'man_dict' dictionary and 'popen' plugin, you can make the following: ./configure --prefix=/usr/local \ --libexecdir=/usr/local/libexec/dictd make dict make dictd make samples make install.samples ./dictd -dnodetach -dnofork -c examples/dictd_popen.conf and then in another terminal run ./dict -h localhost man ./dict -h localhost -s substring -m malloc NOTE: If you configure 'dictd' with '--disable-plugin' option, this test will fail. NOTE: After testing complete, do not forget to run rm -rf /tmp/dictd 6. Install any databases you would like dict/dictd to utilize. The database(s) should be installed in a location that the 'dictd' server process has access to. The preformatted dictd-usable databases you need can be found at any of the following locations: ftp://ftp.dict.org/dict/pre/ [most up to date] ftp://ftp.cs.unc.edu/pub/users/faith/dict/pre/ [mirror] a) Make a directory to contain the dictionary database(s). We'll use '/opt/public/dict-dbs' for this EXAMPLE. b) For the sake of this document and to get you up and running, let's say you're only interested in the Webster 1913 dictionary database. In that case, get the latest 'dict-web1913...' file from one of the locations above. c) Unpackage the 'dict-web1913...' file and put the resulting files (see below) into /opt/public/dict-dbs (our EXAMPLE area...). web1913.dict.dz The 'dictzip' format database web1913.index The index of the database 7. To setup a proper server, you will need to configure a dictd.conf file. Please see the man page dictd.8 and the example .conf files included with the source code for an explanation of the syntax needed and other important details. By default, dictd will try to find this file as '/etc/dictd.conf', however if you start 'dictd' with the '-c /your/path/to/your/conf/file/mydictd.conf', it will use that file as the configuration file instead. For our example, with our web1913 database in /opt/public/dict-dbs, a MINIMAL dictd.conf file would be: database web1913 { data "/opt/public/dict-dbs/web1913.dict.dz" index "/opt/public/dict-dbs/web1913.index" } 8. If you're installing this software for "intranet" use, you will want to setup a 'dict.conf' file which the client software (dict) uses to locate servers and such. The syntax of the dict.conf file is not documented anywhere that I can find, however if you have your 'dictd' server running on the host named dict.company.com, then you should put the following line in your dict.conf file so that users of the 'dict' client do not have to specify '-h dict.company.com' each time they want to query dictd: server dict.company.com 9. That's it really. Now pieces everything together, run your dictd and point it at your config file, and try running dict! GENERAL EXTRA INSTALL HELP ========================== If the above information all isn't very clear, here's a view of good distributed environment's setup: /usr/local/sbin/dictd # Accessible from all hosts on our net /usr/local/bin/dict # Accessible from all hosts on our net /usr/local/bin/dictfmt # Accessible from all hosts on our net /usr/local/etc/dictd.conf # Accessible from all hosts on our net /usr/local/etc/dict.conf # Accessible from all hosts on our net /usr/local/lib/dict-dbs # Accessible from all hosts on our net /usr/local/etc/dictd.conf contains 2 lines: database web1913 { data "/opt/public/dict-dbs/web1913.dict.dz" index "/opt/public/dict-dbs/web1913.index" } /usr/local/etc/dict.conf contains 1 line: server dict This setup allows ANY host on the network to quickly and easily become the dictd server. All you have to do is setup a 'host alias' for the name 'dict' to point at whatever host you want to be the dictd server and then start dictd on that host. NOTE: I had to install the dictd.conf and dict.conf in that location BY HAND. This is not done automatically for you. [INSTALL file courtesy Jeff Blain ] dictd-1.12.1+dfsg.orig/Makefile.conf0000644000000000000000000000010410715410322015611 0ustar rootrootall: autoheader && autoconf && cd libmaa && autoheader && autoconf dictd-1.12.1+dfsg.orig/Makefile.in0000644000000000000000000003204111534744766015325 0ustar rootroot# Makefile.in -- Makefile for dict # Created: Wed Apr 24 14:14:09 1996 by faith@dict.org # Copyright 1996-2002 Rickard E. Faith (faith@dict.org) # Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) # # 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 1, 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. # # Add a _letter_ if you change the version number and release your own version. # Numbers are for the original author(s) only. DICT_VERSION=@DICT_VERSION@ ifneq (,) This makefile requires GNU Make. endif .SUFFIXES: srcdir= @srcdir@ VPATH= @srcdir@:. prefix= @prefix@ subdirs= @allsubdirs@ # doc -- use rfc2229 instead exec_prefix= @exec_prefix@ man1_prefix= @mandir@/man1 man8_prefix= @mandir@/man8 bindir= @bindir@ libdir= @libdir@ libexecdir= @libexecdir@ sbindir= @sbindir@ includedir= @includedir@ datadir= @datadir@ DESTDIR= SHELL= /bin/sh USE_PLUGIN=@USE_PLUGIN@ EXEEXT=@EXEEXT@ CONF_DIR=@sysconfdir@ PLUGIN_DIR=${libexecdir} DICT_DIR=${datadir} CC= @CC@ CXX= @CXX@ CPP= @CPP@ LIBTOOL= @LIBTOOL@ INSTALL= @INSTALL@ -c INSTALL_PROGRAM=@INSTALL_PROGRAM@ -c INSTALL_SCRIPT= @INSTALL_SCRIPT@ -c INSTALL_DATA= @INSTALL_DATA@ -c LEX= @LEX@ YACC= @YACC@ LEXLIB= @LEXLIB@ CFLAGS= @CPPFLAGS@ @DEFS@ @CFLAGS@ -DDICT_PLUGIN_PATH=\"$(PLUGIN_DIR)/\" -DDICT_DICTIONARY_PATH=\"$(DICT_DIR)/\" -DDICT_VERSION=\"$(DICT_VERSION)\" -DDICT_CONFIG_PATH=\"$(CONF_DIR)/\" -I. -I$(srcdir) LIBMAA= @LIBMAA@ LIBS= @LIBS@ ${LIBMAA} LDFLAGS= @LDFLAGS@ LIBOBJS= @LIBOBJS@ EXES= dict dictd dictzip dictfmt all: $(EXES) $(LIBRARIES) ifdef USE_PLUGIN PLUGINS=@PLUGINS@ #dictdplugin_man.la LIBRARIES= #libdictdplugin.a INCLUDES= dictdplugin.h all: plugins .PHONY : samples install.samples uninstall.samples samples : dictdplugin_exit.la dictdplugin_popen.la install.samples : samples mkdir -p $(DESTDIR)$(libexecdir) && \ $(LIBTOOL) --mode=install $(INSTALL) -c dictdplugin_exit.la dictdplugin_popen.la $(DESTDIR)$(libexecdir) && \ $(INSTALL_SCRIPT) search_man $(DESTDIR)$(libexecdir) uninstall.samples : $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libexecdir)/search_man.la $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libexecdir)/dictdplugin_exit.la $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libexecdir)/dictdplugin_popen.la endif ifdef USE_PLUGIN SRCHOBJS= index.o data.o str.o plugin.o #dictdplugin.o else SRCHOBJS= index.o data.o str.o #dictdplugin.o endif NETOBJS= daemon.o strategy.o net.o servscan.o servparse.o md5.o CLIOBJS= net.o clientscan.o clientparse.o md5.o TMPS= servscan.c servparse.c servparse.h \ clientscan.c clientparse.c clientparse.h @SET_MAKE@ %.o: %.c $(LIBTOOL) --tag=CC --mode=compile $(CC) -c $(CFLAGS) $< -o $@ %.o: %.cpp $(LIBTOOL) --tag=CXX --mode=compile $(CXX) -c $(CFLAGS) $< -o $@ %: %.o $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ -static \ $^ $(OBJS) $(LDFLAGS) -lz ${LIBS} include $(srcdir)/deps dictd.o : servparse.h $(PLUGINS) dictdplugin_popen.la dictdplugin_exit.la : $(LIBOBJS) # libdictdplugin.a lib%.a : %.o $(AR) rc $@ $^ %.la : %.o $(LIBOBJS) $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ -module \ $(^:.o=.lo) \ -rpath "${PLUGIN_DIR}" \ $(LDFLAGS) ${LIBS} dictdplugin_man.la : data.o str.o heap.o dictdplugin_man.o \ plugins_common.o $(LIBOBJS) $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ -module \ $(^:.o=.lo) \ -rpath "${PLUGIN_DIR}" \ $(LDFLAGS) ${LIBS} dictdplugin_judy.la : data.o str.o heap.o dictdplugin_judy.o \ plugins_common.o $(LIBOBJS) $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ -module \ $(^:.o=.lo) \ -rpath "${PLUGIN_DIR}" \ $(LDFLAGS) -lJudy ${LIBS} dictdplugin_dbi.la : heap.o dictdplugin_dbi.o str.o \ plugins_common.o $(LIBOBJS) $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ -module \ $(^:.o=.lo) \ -rpath "${PLUGIN_DIR}" \ $(LDFLAGS) -ldbi ${LIBS} .PHONY: plugins plugins: $(PLUGINS) dict : $(CLIOBJS) $(LIBOBJS) parse.o dictd : $(NETOBJS) $(SRCHOBJS) $(LIBOBJS) parse.o dictzip : data.o $(LIBOBJS) dictfmt : str.o $(LIBOBJS) servscan.c: servscan.l $(LEX) $(LFLAGS) $< && mv lex.yy.c $@ servscan.o: servscan.c servparse.o servparse.h servparse.c servparse.h : servparse.y $(YACC) -tdv $<; \ cmp -s y.tab.h servparse.h || mv y.tab.h servparse.h; \ cmp -s y.tab.c servparse.c || mv y.tab.c servparse.c; \ rm -f y.tab.h y.tab.c servparse.o: servparse.c clientscan.c: clientscan.l $(LEX) $(LFLAGS) -o$@ $< clientscan.o: clientscan.c clientparse.o clientparse.h clientparse.c clientparse.h: clientparse.y $(YACC) -tdv $<; \ cmp -s y.tab.h clientparse.h || mv y.tab.h clientparse.h; \ cmp -s y.tab.c clientparse.c || mv y.tab.c clientparse.c; \ rm -f y.tab.h y.tab.c clientparse.o: clientparse.c .PHONY: install.dict install.dictzip install.dictfmt install.dictd \ install.libs install.includes install.colorit install.dict: dict mkdir -p $(DESTDIR)$(bindir) && \ mkdir -p $(DESTDIR)$(man1_prefix) && \ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) dict$(EXEEXT) $(DESTDIR)$(bindir)/ && \ $(INSTALL_DATA) dict.1 $(DESTDIR)$(man1_prefix)/ && \ $(INSTALL_SCRIPT) dictl $(DESTDIR)$(bindir)/ && \ $(INSTALL_DATA) dictl.1 $(DESTDIR)$(man1_prefix)/ $(INSTALL_SCRIPT) @srcdir@/dict_lookup $(DESTDIR)$(bindir)/ && \ $(INSTALL_DATA) dict_lookup.1 $(DESTDIR)$(man1_prefix)/ install.colorit: colorit mkdir -p $(DESTDIR)$(bindir) && \ mkdir -p $(DESTDIR)$(man1_prefix) && \ $(INSTALL_SCRIPT) colorit $(DESTDIR)$(bindir) && \ $(INSTALL_DATA) colorit.1 $(DESTDIR)$(man1_prefix) install.dictzip: dictzip mkdir -p $(DESTDIR)$(bindir) && \ mkdir -p $(DESTDIR)$(man1_prefix) && \ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) dictzip$(EXEEXT) $(DESTDIR)$(bindir) && \ $(INSTALL_DATA) dictzip.1 $(DESTDIR)$(man1_prefix)/dictzip.1 install.dictfmt: dictfmt dictfmt_index2word dictfmt_index2suffix mkdir -p $(DESTDIR)$(bindir) && \ mkdir -p $(DESTDIR)$(man1_prefix) && \ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) dictfmt$(EXEEXT) $(DESTDIR)$(bindir) && \ $(INSTALL_SCRIPT) dictfmt_index2suffix $(DESTDIR)$(bindir) && \ $(INSTALL_SCRIPT) dictfmt_index2word $(DESTDIR)$(bindir) && \ $(INSTALL_SCRIPT) dictunformat $(DESTDIR)$(bindir) && \ $(INSTALL_DATA) dictfmt.1 $(DESTDIR)$(man1_prefix) && \ $(INSTALL_DATA) dictfmt_index2word.1 $(DESTDIR)$(man1_prefix) && \ $(INSTALL_DATA) dictfmt_index2suffix.1 $(DESTDIR)$(man1_prefix) && \ $(INSTALL_DATA) dictunformat.1 $(DESTDIR)$(man1_prefix) install.dictd: dictd mkdir -p $(DESTDIR)$(sbindir) && \ mkdir -p $(DESTDIR)$(man8_prefix) && \ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) dictd$(EXEEXT) $(DESTDIR)$(sbindir) && \ $(INSTALL_DATA) dictd.8 $(DESTDIR)$(man8_prefix)/dictd.8 install.libs: $(LIBRARIES) if test _$(USE_PLUGIN) != _; then \ mkdir -p $(DESTDIR)$(libdir) && \ if test "$(LIBRARIES)"; then \ $(INSTALL_DATA) $(LIBRARIES) $(DESTDIR)$(libdir); fi fi install.includes: if test _$(USE_PLUGIN) != _; then \ mkdir -p $(DESTDIR)$(includedir) && \ if test "$(INCLUDES)"; then \ $(INSTALL_DATA) $(addprefix @srcdir@/, $(INCLUDES)) \ $(DESTDIR)$(includedir); \ fi fi install.plugins: if test _$(USE_PLUGIN) != _; then \ mkdir -p $(DESTDIR)$(libexecdir) && \ if test "$(PLUGINS)"; then \ $(LIBTOOL) --mode=install $(INSTALL_DATA) $(PLUGINS) $(DESTDIR)$(PLUGIN_DIR); else true; fi fi .PHONY: install install: \ install.dict install.dictzip install.dictd install.dictfmt \ install.libs install.includes install.plugins install.colorit ifdef USE_PLUGIN $(INSTALL_SCRIPT) dictdplugin-config $(DESTDIR)$(bindir) endif uninstall.dict: $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bindir)/dict$(EXEEXT) rm -f $(DESTDIR)$(man1_prefix)/dict.1 rm -f $(DESTDIR)$(bindir)/dictl $(DESTDIR)$(man1_prefix)/dictl.1 uninstall.dictzip: $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bindir)/dictzip$(EXEEXT) rm -f $(DESTDIR)$(man1_prefix)/dictzip.1 uninstall.dictd: $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(sbindir)/dictd$(EXEEXT) rm -f $(DESTDIR)$(man8_prefix)/dictd.8 uninstall.dictfmt: $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bindir)/dictfmt$(EXEEXT) rm -f $(DESTDIR)$(man1_prefix)/dictfmt.1 rm -f $(DESTDIR)$(man1_prefix)/dictfmt_index2word.1 rm -f $(DESTDIR)$(man1_prefix)/dictfmt_index2suffix.1 rm -f $(DESTDIR)$(man1_prefix)/dictunformat.1 rm -f $(DESTDIR)$(bindir)/dictfmt_index2suffix rm -f $(DESTDIR)$(bindir)/dictfmt_index2word rm -f $(DESTDIR)$(bindir)/dictunformat uninstall.colorit: rm -f $(DESTDIR)$(bindir)/colorit $(DESTDIR)$(man1_prefix)/colorit.1 uninstall.includes: ifdef USE_PLUGIN rm -f $(addprefix $(DESTDIR)$(includedir)/, $(INCLUDES)) endif uninstall.libs: ifdef USE_PLUGIN if test "$(LIBRARIES)"; then \ rm -f $(addprefix $(DESTDIR)$(libdir)/, $(LIBRARIES)); \ else true; fi endif uninstall.plugins: ifdef USE_PLUGIN if test "$(PLUGINS)"; then \ $(LIBTOOL) --mode=uninstall \ rm -f $(addprefix $(DESTDIR)$(libexecdir)/, $(PLUGINS)); \ fi endif .PHONY: uninstall .PHONY: \ uninstall.dict uninstall.dictzip uninstall.dictfmt uninstall.dictd \ uninstall.libs uninstall.includes uninstall.plugins uninstall.colorit uninstall: \ uninstall.dict uninstall.dictzip uninstall.dictfmt uninstall.dictd \ uninstall.libs uninstall.includes uninstall.plugins uninstall.colorit ifdef USE_PLUGIN rm -f $(DESTDIR)$(bindir)/dictdplugin-config endif .PHONY: ChangeLog ChangeLog: @(echo "***** Making new ChangeLog..."; \ rm -f ChangeLog; \ AWK=@AWK@ rcs2log -i 2 -r -d'1996-09-20<' . doc | \ ./exclude_libmaa_logs | \ sed -e 's,/cvsroot/dict/dictd1/,,g' \ -e 's,/cvs/dict/dictd1/,,g' \ -e 's,cheusov *]*>,Aleksey Cheusov ,g' \ -e 's,faith *]*>,Rik Faith ,g' \ -e 's,hilliard...hilliard@.*,Bob Hilliard ,g' \ -e 's,tek...tek@.*,Julian Squires ,g' \ -e 's,\(.*\)<\([^@<>]\+\)@\([^@<>]\+\)>\(.*\),\1<\2 at \3}\4,g' \ > ChangeLog;) cvsdist: @( CVSROOT=`cat CVS/Root` && \ export CVSROOT && \ VERSION=$(DICT_VERSION) && \ VERSION_CVS=`echo $${VERSION} | tr . -` && \ export VERSION VERSION_CVS && \ $(MAKE) ChangeLog && \ cp ChangeLog /tmp/dictd.ChangeLog.$${VERSION} && \ echo "***** Exporting files for dictd-$${VERSION}..." && \ cd /tmp && \ rm -rf /tmp/dictd-$${VERSION} && \ cvs export -fd dictd-$${VERSION} -r dictd-$${VERSION_CVS} dictd1 && \ cd dictd-$${VERSION} && \ rm -rf libmaa && \ mv /tmp/dictd.ChangeLog.$${VERSION} ChangeLog && \ autoheader && autoconf && \ rm -rf autom4te.cache libmaa/autom4te.cache && \ chmod -R a+rX,g-w . && \ cd .. && \ echo "***** Taring and zipping dictd-$${VERSION}.tar.gz..." && \ tar cvvf dictd-$${VERSION}.tar dictd-$${VERSION} && \ gzip -9f dictd-$${VERSION}.tar && \ echo "***** Done making /tmp/dictd-$${VERSION}.tar.gz") .PHONY: clean distclean tags clean: -rm -f *.o *.lo *.os *.a *.la *.s *~ core a.out config.log -rm -f $(EXES) $(TMPS) -rm -f *.log *.aux *.toc *.dvi *.ps -rm -f *.cfg *.dtk .inslog tca.map -rm -f *.dct *.idx y.output TAGS -rm -f *.dict *.index -rm -f *.exe *.dll -rm -f test/_* test/testdb.t.txt test/log.txt -rm -f ChangeLog* recursive-clean: clean @for subdir in `echo $(subdirs)`; do \ echo making clean in $$subdir; \ (cd $$subdir && $(MAKE) clean) || exit 1; \ done distclean: recursive-clean @for subdir in `echo $(subdirs)`; do \ echo making $@ in $$subdir; \ (cd $$subdir && $(MAKE) $@) || exit 1; \ done rm -f config.h config.cache config.status stamp-h.in stamp-h rm -f Makefile doc/Makefile dictdplugin-config rm -f colorit dictl dictunformat rm -f test/dictd_test test/dictzip_test rm -rf autom4te.cache libmaa/autom4te.cache rm -f dictfmt_index2suffix dictfmt_index2word rm -f *.1 *.8 cvsclean: distclean rm -f configure libmaa/configure config.h.in libmaa/config.h.in tags: etags *.[ch] deps: for i in *.c *.cpp; do \ gcc -MM $$i 2>/dev/null; \ done | awk '{gsub(/ \/[^ ]+/, ""); print}' | \ sed 's,\(.*[.]\)o,\1o \1os,1' > deps .PHONY: test test: $(EXES) $(LIBRARIES) cd test && sh dictd_test && sh dictzip_test # The following is based on the "Automatic Remaking" node in the GNU # Autoconf documentation: $(srcdir)/configure: configure.in cd $(srcdir) && autoconf # autoheader might not change config.h.in, so touch a stamp file. ${srcdir}/config.h.in: stamp-h.in ${srcdir}/stamp-h.in: configure.in cd ${srcdir} && autoheader touch ${srcdir}/stamp-h.in config.h: stamp-h stamp-h: config.h.in config.status ./config.status Makefile: Makefile.in config.status ./config.status config.status: configure ./config.status --recheck dictd-1.12.1+dfsg.orig/NEWS0000644000000000000000000013666312003012221013734 0ustar rootroot---------------------------------------------------------------------- Version 1.12.1, by Aleksey Cheusov, Sun, 22 Jul 2012 16:33:39 +0300 dictl.in: Fix for Debian bug #677868 reported by Stepan Golosunov. dictd.8: Fixes for mistypes found by A. Costa. Thanks! dictzip: Fix for sf.net bug #3390567 reported by Ivo Danihelka. INSTALL: Fix for sf.net bug #3398178 colorit: Fix for option -c. Now it works correctly. examples/dictd_virtual.conf: Fix incorrect keyword for virtual database. Thanks to Marc-Jano Knopp for the report! ---------------------------------------------------------------------- Version 1.12, by Aleksey Cheusov, Sun, 9 Jan 2011 18:16:34 +0200 New script dict_lookup for translating words and phrases from X selection. It makes sense to configure launching dict_lookup on a keyboard shortcut in the window manager. dictd: Fix for SHOW SERVER command (dict -I). On systems where sizeof(int) != sizeof (long) values in "Uncompressed" column may contain random garbage. This problem was seen on NetBSD/x86_64/5.1 Fix for sf bug #3098788 https://sf.net/tracker/?func=detail&aid=3098788&group_id=605&atid=100605 Regresson tests for dictzip were added. Fix in Makefile: non standard option for lex(1) was removed (This may unbreak compilation on SunOS, HP-UX...). dictfmt: Internal buffer size was increased from 10240 to 102400 bytes. Fixes for Tru64. Other minor fixes and cleanups ---------------------------------------------------------------------- Version 1.11.2, by Aleksey Cheusov, Sun, 4 Oct 2009 10:55:28 +0300 FIX: When search is handled by dict_search_bmh() function, the first character from the first entry in the index file is missing. Usually this is some of 00-database-* entries. Thanks to Goran Tal for a bug report and patch. fix in dictfmt.1: s/--index-keep-headword/--index-keep-orig/ dictfmt: superfluous spaces are removed not only from the beginng and the end of a headword but also inside a multiword headwords. Thank to Goran Tal for pointing out. dictfmt spawns sort command to sort the index. When there are several entries for the same headword, they get sorted BY OFFSET AND SIZE (in addition to headwords). As a result, the order of identical headwords is messed up. To fix these problem -k1,3 option is replaced with -k1,1. Thanks to Goran Tal for pointing out. With -k1,1 options not all flavours of sort(1) command keeps an original headword order but now you a have chance. Regression tests updated. ---------------------------------------------------------------------- Version 1.11.1, by Aleksey Cheusov, Fri, 27 Feb 2009 22:16:49 +0200 FIXES: Minor fix in dictd.8 (paths to config files), sf.net bug #2407717 Thanks to Peter Volkov Bug fixed in installing plugins, sf.net bug #2218879, Thanks to Peter Volkov DICTFMT sorts entries in 00-database-alphabet entry lexicographically, that is now this order doesn't depend on sizeof(long). This fixes sf.net bug #2197588. Thanks to Peter Volkov and his tests on PowerPC. DICTD: SHOW STRAT: s/databases present/strategies present/ found and reported by Goran Tal . Thanks. DICTFMT: 'dictfmt -I' never worked (regrettable oversight, heh), found and reported by Goran Tal . Thanks. Makefile.in, configure.in: "building and installing different set of things based on configure results considered harmful"(C) me :-) Plugins support in dictd is enabled by default (if available). DBI and JUDY plugins are disabled by default. Enable them explicitly by using ./configure --with-plugin-dbi and ./configure --with-plugin-judy This fixes sf.net bug #2218879 by Peter Volkov. By using DICTL_USE environment variable dictl utility can now use an external program for charset2charset conversions. This addresses sf.net bug #2407725, again by Peter Volkov * Makefile.in, configure.in: (Clean-ups) --with-local-libmaa option is removed from "configure" script. You should build libmaa manually before dictd/dict/... This removes lots of garbage from configure.in and Makefile.in and makes them MUCH cleaner. If you want to link dictd with libmaa statically, use Makefile's LIBMAA variable. configure.in, include_regex.h.in, index.c: (Clean-ups) Ages ago, I've add to "configure" script an option --with-regex-include to make possible to build dictd with PCRE. Now, I've removed this option. If you want to build dictd with with PCRE, ask PCRE developers to install pcre/regex.h file linked to pcreposix.h. All other regexp libraries compatible with POSIX API do the same, rx/regex.h, rxspencer/regex.h etc. etc. So, this is good and well known convension. Makefile.in: LIBMAA variable added. Change it if you want to link dictd against libmaa statically or... * configure.in: Enable additional gcc warnings on all platforms unconditionally, not only under Linux, I need them under NetBSD. Makefile.in: fix for "uninstall" target Lots of clean-ups in dictl. Other minor clean-ups in Makefile.in and configure.in Minor spelling fixes in NEWS ---------------------------------------------------------------------- Version 1.11.0, by Aleksey Cheusov, Sun, 7 Dec 2008 23:05:21 +0200 dictd tarball no longer contains libmaa library. Now dictd/dict/dictfmt/dictzip/... are built with external libmaa library. Also, by default local "libmaa" directory is not used to detect libmaa even if this directory is present, use './configure --with-local-libmaa' option to force this. configure: removed: --with-cc, --with-cflags, --with-prog, --with-gprof, --with-checker, --with-efence, --with-insure and --with-purify options. Use standard CC, CPPFLAGS, CFLAGS, LDFLAGS etc. environment variables instead Compilation errors fixed on Solaris, Interix, HP-UX and others. dictfmt_index2suffix: \001 -> \1 inside regexp. It seems it is better eccepted by different awk/regexp_engines. (heirloom posix2001/awk and libuxre) fixed: sf.net bug #1627458 (make samples fails to build) fixed: sf.net bug #1941358 (first connection is denied) dictfmt_index2suffix: no need for GNU awk dictfmt_index2suffix and dictfmt_index2word are generated from *.in Lots of minor fixes and clean-ups in regression tests, Makefiles, configure... Lots of GCC warning messages were also fixed ---------------------------------------------------------------------- Version 1.10.11, by Aleksey Cheusov, Mon, 7 Apr 2008 00:28:10 +0300 Everything can now be compiled with pcc (Portable C Compiler), tested under NetBSD clean-ups in C code, configure.in etc. Warning messages generated by NetBSD/alpha were fixed. Lots of warning messages produced by icc-10 (Intel C Compiler) were fixed too. FIX: now dictd/libmaa can be built from external "object" (any!) directory just like many other autobloat-based projects can do. That is, the following works fine now cd obj-dir /path/to/dictd-sources --with-libmaa gmake gmake install dictd: - FIXED: compilation failure on Linux if --disable-plugin option is specified. - index.c: FIXED: while processing MATCH command unicity of only first column of .index is checked, but fourth column (if present) is not. - timestamp log marker (log_option "timestamp") is changed from :T: to :t: because :T: begins client's full command (log_option "command") dictfmt: - FIXED: maximum length of headwords is limited to hardcoded constant just by cutting the end of headword. Now internal arrays are realloced automatically. dict: - ADDED: -F|--flush option for flushing stdout after each definition/match. This may be useful in combination with -f colorit: - bashism fixed: 'echo -en' -> more portable 'printf'. Thanks to Debian users. libmaa: - fixed: DESTDIR support dictdplugin_popen: - fixed: missed header file, seen with gcc-4.3. Thanks to Martin Michlmayr for report ---------------------------------------------------------------------- Version 1.10.10, by Aleksey Cheusov, Sat, 10 Nov 2007 22:03:06 +0200 dict, dictl, colorit: - all these programs do NOT support paging to a special program, i.e. --pager|-P option. As of this version everything is output to stdout only. Now, 'dict' program for dictionary protocol is like wget for http. Sorry for breaking backward compatibility but this change makes the code cleaner, smaller and more manageable. If you run 'dict' (or 'dictl') interactively, write the following to your interactive shell startup script (.ksh, .zsh, .bashrc etc.) mydict () { dict "$@" 2>&1 | colorit | less; } and then use 'mydict' instead of 'dict' (or 'dictl') '-P -' option is allowed. dictd: - added support for utf-8 symbols other than BMP other minor fixes and cleanups ---------------------------------------------------------------------- Version 1.10.9, by Aleksey Cheusov, Tue, 29 May 2007 23:20:14 +0300 dictd: - ADDED: 'limit_time' keyword for limiting time (in seconds) during which a client may talk to the server. This is for preventing DOS attacks. This option may be used as a replacement for 'delay' option. See dictd.8 for the documnetation - ADDED: new keyword 'limit_matches' and 'limit_defintions' limiting a number of matches and definitions respectively that the server may send to the client. This is for preventing DOS attacks. See dictd.8 for more information - ADDED: new keyword 'limit_queries' limiting a number of queries that client may send to the server This is for preventing DOS attacks. See dictd.8 for more information - ADDED: new keyword 'limit_childs' equal to old 'limit'. 'limit' is now deprecated. Use 'limit_childs' instead. - ADDED: Two new search strategies, 'first' and 'last'. They match first or last word only in a multi-word entries. See dictd.8 for more information. - ADDED: new keywords 'site_no_banner', 'site_no_uptime' and 'site_no_dblist' for changing the way dictd answers on SHOW SERVER command (dict -I) See dictd.8 for more information. - ADDED: support for the case-sensitive search. For this database should be created with dictfmt --case-sensitive. - 'site' keyword has been moved to 'global' section of dictd.conf file Do not place it at the top level! - removed: --test-XXX options. Use -i and --stdin2stdout for debugging. dictfmt: - FIXED: longopts passed to getopt_long as argument was not ended with zeros. I even don't how this code could work for so many years. Affected dictfmt versions: 1.6.1-1.10.8 - ADDED: --index-data-separator option that allows to set index and data parts of the headword in .index file (first and fourth columns respectively) completely independantly. That is, the first column in .index file can now be treated as an index and an optional fourth columns - as a data, all this for MATCH protocol command. See dictfmt.1 for more information. - added: -i and -I for resorting .index files. See dictd.8 for more information. - added: By default a special headword 00-database-dictfmt-X.Y.Z is generated, i.e. every created database is marked "what version of dictfmt was used to create it". added: --without-ver option for preventing this. dictunformat: - minor fixes and improvements for 4-column .index file input See dictfmt --index-data-separator and dictunformat --index-data-separator dictfmt_index2suffix and dictfmt_index2word - fixes, now these utilities are ready for 4-column input and use 'dictfmt -i/-I' for resorting .index entries. See dictfmt.1 for more information. dict: - ADDED: -f option that enables formatted output, i.e. output convenient for postprocessing by standard UNIX utilities. See dict.1 for more information. ---------------------------------------------------------------------- Version 1.10.8, by Aleksey Cheusov, Wed, 13 Dec 2006 22:20:04 +0200 libtool is now used for building dictd and libmaa. This makes them more portable, especially libmaa with the shared object files support. dictd: - fixed: sourceforge.net bug #1554437 ('nprefix' strategy) - added: --stdin2stdout option for debugging purposes. See dictd(8) - fixed: daemon3.c on Solaris Minor selftests improvements. ./configure.in|Makefile.in: - WCFLAGS, XTRACFLAGS, WLDFLAGS, XTRALDFLAGS, LDSHARED, XTRAHEADERS variables are no longer used. For configuring dictd use CPPFLAGS, CFLAGS and LDFLAGS variables only. - fixed: finding lex and yacc (fails on NetBSD). - --without-local-libmaa is the default now Makefile.in: - fixed: install target on Solaris (Solaris install != BSD install) ---------------------------------------------------------------------- Version 1.10.7, by Aleksey Cheusov, Sun, 16 Jul 2006 21:36:49 +0300 DICTD: - FIXED: pidof(dictd) != `cat /var/run/dictd.log` because writing a pid is made before call of daemon(3) that runs fork(2). Affected versions: 1.10.6 - FIXED: nmap utility or just a client that aborts connection for any reason can cause dictd server to exit with error on NetBSD-3.0 and probably other OSes. This happens because accept(2) returns ECONNABORTED error code allowed by SUSv3, but this error code is treated as a critical error code by dictd. Linux seems not affected. Affected versions: ALL, i.e 1.4.9-1.10.6 ---------------------------------------------------------------------- Version 1.10.6, by Aleksey Cheusov, Tue, 4 Jul 2006 01:17:53 +0300 DICTD: - FIXED: 'word' strategy works incorrectly with UTF-8 on non-glibc systems, i.e. BSD, Solaris and probably others. - new selftest added - if opening a pid file or log file failed, error messages are printed to stderr, older versions did not generate error messages at all in this case. DICTFMT: - --index-keep-orig option is added to dictfmt. When --utf-8 option is applied, headwords are lowercased and non-alphanumeric characters are removed from it before writing them to .index file in order to simplify the search. With --index-keep-headword option the fourth column is created (if necessary) in .index file, and contains the original headword which is returned by MATCH command. This option may be useful to prevent converting "AT&T" to "att" or to keep German nouns with uppercased first letter. LIBMAA: - added: new function b64_decode_buf - FIXED: sf.net bug #1463396 in hash.c ---------------------------------------------------------------------- Version 1.10.5, by Aleksey Cheusov, Fri, 26 May 2006 23:12:49 +0300 DICTD: - FIXED: In case database_exit directive is used in dictd.conf SHOW DB command returns incorrect number of databases available. Afected versions: 1.10.2 -- 1.10.4 - As of dictd-1.9.14 dictd creates log file being root and then releases root priviledges. This was my bad idea because log file may have % sign and may be used as a **pattern for log files**. NOW OLDER BEHAVIOUR IS RESTORED, i.e. log file is created after releasing root priviledges. If you want to create log file under /var/log directory, create /var/log/dictd with appropriate permissions and create log files there. I apologize for inconvenience and breaking backward compatibility. ---------------------------------------------------------------------- Version 1.10.4, by Aleksey Cheusov, Mon, 12 Dec 2005 20:36:32 +0200 DICTD FIXED: pid file was created with 0666 permissions. Affected dictd versions: 1.10.1 - 1.10.3 ---------------------------------------------------------------------- Version 1.10.3, by Aleksey Cheusov, Thu, 8 Dec 2005 20:54:23 +0200 REGEX/ZLIB libraries have been removed from dictd CVS tree. Most UNIX-like OS'es and distributions have these libraries in a prebuilt form. Otherwise, build and install them yourself. MAKE TEST: - lots of new tests for 'dictd'. - fixes, code clean-ups and improvements of tests for 'dictfmt' DICTD/DICT/DICTFMT/DICTZIP config.sub and config.guess have been updated (GNU/kFreeBSD) DICTD -ADDED: new search strategy `nprefix'. dictd.8: ... nprefix Like prefix but returns the specified range of matches. For example, when prefix strategy returns 1000 matches, you can get only 100 ones skipping the first 800 matches. This is made by specified these limits in a query like this: 800#100#app, where 800 is skip count, 100 is a number of matches you want to get and "app" is your query. This strategy allows to implement DICT client with fast autocompletion (although it is not trivial) just like many standalone dictionary programs do. NOTE: If you access the dictionary "*" (or virtual one) with nprefix strategy, the same range is set for each database in it, but globally for all matches found in all databases. NOTE: In case you access non-english dictionary the returned matches may be (and mostly will be) NOT ordered in alphabetic order. -fixed: setenv.c (Solaris) -fixed: compilation bug under Solaris (decl.h) -fixed: strange segfault in log_info function under Interix 3.5 (4096-byte array on stack + va_XXX calls) -FIXED: buffer overflow (segfault) in log_{error,info} functions. This may happen when dictd is run with -L option and it definitely segfaults on condition that: - -dinit option is enabled; - Japanese of Chinese dictionary created by dictfmt-1.9.14 (or later) is in dictd.conf - -L This happens due to too long 00-database-alphabet "definition" Affected versions: all? DICTL -fixed: sf.net bugs #1223489 and #1227624, patches by micha137 DICT -minor fixes with pager, patches by Kirk Hilliard -fixed: assert(3) Affected dict calls: dict -M -S dict -M -D dict -M LIBMAA -fixed: compilation bug (alloca) Documentation: - Samples configuration files for 'dictd' and 'dict' have been moved to samples/ subdirectory. - File names directories in manual pages are specified according to ./configure options - A few references to samples/ are added to dictd.8. I hope this will make dictd.8 a bit simplier for new users. - minor fixes and improvents removed: dictfmt_virtual, dictfmt_plugin utilities. The only way to configure plugin or virtual databases is by using dictd.conf file. I hope nobody used these utilities. Otherwise, sorry for inconvenience. ---------------------------------------------------------------------- Version 1.10.2, by Aleksey Cheusov, Tue, 6 Sep 2005 20:31:29 +0300 I started to create selftests for dict project. There are a few tests yet. Run 'make test' on your platform and notify me if some errors happend. FIXES: - fixed: compilation bugs on FreeBSD4, Solaris and MacOS-X Affected versions: 1.10.1 dictd: - because of optimization code and strange binary search the 'regexp' strategy may work incorrectly Thanks to Slava Kravchenko for bug report. Affected versions: 1.4.9(?) - 1.10.1 - 'SHOW DB' command shows the special entry '--exit--' as a normal database which cannot be used for searching. This contradicts rfc-2229. To see when the default search stops, use 'SHOW SERVER' command instead. dictfmt: - because not only index part of .index file was used for sorting bu 'sort' utility, 'dictfmt' may create incorrect index file. Now sort is run with '-t -k 1,3' options. Affected dictfmt versions: 1.6.1-1.10.1 It is recommended to rebuild existing databases. - because 'sort' utility inherits LANG and LC_... variables from 'dictfmt', incorrect .index files may be created if you run dictfmt with non_C locale even if you create ascii (non-utf8) database. To fix this LC_ALL environment variable is always set to C before running 'sort'. It is recommended to rebuild existing databases. ---------------------------------------------------------------------- Version 1.10.1, by Aleksey Cheusov, Thu, 9 Jun 2005 20:03:22 +0300 fixes: - compilation bugs on sparc64/{Free,Open,Net}BSD has been fixed Thanks to koresh for bug report and patch. dictd/dictfmt: - By default, local implementations of UCS-2/UTF-8 functions are used. As a result 'dictd' run with no option works in UTF-8 mode, but ASCII one. The option '--locale xx_YY.UTF-8' is no more requied for both dictd and dictfmt. In contrast with 'dictd', 'dictfmt' is run in ASCII mode by default. In order to create utf-8 dictionary, run 'dictfmt' with --utf8 option. Thus both 'dictd' and 'dictfmt' should work the same way on all platforms even if it doesn't provide necessary functions or UTF-8 locale. Tested on MS Interix 3.5. If you dislike this feature, ./configure dict with --with-system-utf8-funcs option. dictd: - By default dictd, when running as daemon, writes a PID to /var/run/dictd.pid file. This can be overriden by 'pid_file' keyword in dictd.conf (See dictd.8) or command line option '--pid-file'. Thanks to Josef Novak for sudgestion and patch. documentation: - fixed: dictd.8 says that 'lev' strategy doesn't work with UTF-8 dictionaries, but it does since release 1.9.13 ---------------------------------------------------------------------- Version 1.10.0, by Aleksey Cheusov, Tue, 12 Apr 2005 20:51:01 +0300 dictd: - Most parameters can be passed to `dictd' via configuration file. See 'Global Setting section' in dictd.8 for more information. Also see example.conf for the sample config. - Added: ability to create special databases that work differently depending on whether client sent OPTION MIME command or not. This allows to provide dictionaries returning either plain text or specially formatted (html, roff, TEI etc...) definitions depending on client's capabilities or needs. See example_mime.conf file for example and dictd.8 for documentation. - fixed: `default_strategy' keyword was not implemented for `database_plugin' section. - fixed: compilation bugs on OpenBSD-3.4 which doesn't provide CODESET macro in dict: - added: -M option for sending OPTION MIME command to DICT server. NOTE: client doesn't check whether DICT server supports MIME or not) dictfmt: - added option `--mime-header '. When database is accessed by client and OPTION MIME command was previously sent, definitions are prepanded by the specified MIME header. Ability to set the MIME header for the database is useful in combination with `database_mime' keyword in dictd.conf, See dictd.8 for more information. ---------------------------------------------------------------------- Version 1.9.15, by Aleksey Cheusov, Thu, 23 Dec 2004 21:16:03 +0200 Format of .index files for 8-bit databases (not-ASCII and non-UTF8) has been changed. This makes `dictd' backward incompatible with 8-bit dagabases built by earlier versions of `dictfmt', i.e. `dictd-1.9.15' and later doesn't work with 8-bit databases generated by dictfmt-1.9.14 and earlier. See ChangeLog for details. If you use 8-bit database, rebuild them using new `dictfmt' like this dictunformat db.index < db.dict | dictfmt -t --locale db-new dictd: - fixed: Function `dict_search_bmh' works incorrectly in utf-8 mode on non-GLIBC systems. As a result `suffix', `substring' and `word' strategies may work incorrectly with UTF-8 databases on such platforms (FreeBSD). - fixed: In dictd-1.9.8 support of CYGWIN was declared, but it was broken in later versions. dictd-1.9.15 can be succesfully built with CYGWIN. - fixed: `dictd' dies when client tries to obtain information about virtual database (SHOW INFO ). - Every database specified in configuration file may have its own "default" search strategy (i.e. `.' strategy). For this purpose additional keyword `default_strategy' is implemented. See example2.conf sample file and dictd.8 for documentation. - When `-d' is applied, debugging information is printed to syslog (or log file or stderr). NOTE: `-dinit' option may show you a reason why dictd doesn't start. If you are in trouble, apply it first (and -L or -s of course)! - dictd works correctly even on platforms which do not provide `iswalnum', `iswspace' and `towlower' functions. Dictd with utf-8 databases was slightly tested on FreeBSD4.{9,10} -fixed: logging is directed to stderr when --inetd is applied - `AC_FUNC_MMAP' is replaced for `AC_CHECK_FUNC(mmap)' in configure.in As a result `mmap/munmap' functions will be used on CYGWIN and INTERIX if they are present. If you dislike it, use --without-mmap option. dictdplugin_dbi plugin: - new options: `all_char' and `utf8'. `all_char' option is set to FALSE by default. `utf8' option is set to TRUE by default. Both are overrided by `00-database-allchars' and `00-database-utf8' special headwords. dictd/dict/... have been ported to Interix (MS SFU-3.0 and SFU-3.5). It works fine as Interix daemon with ASCII databases (tested on Interix 3.0 and 3.5) NOTE: GNU make is needed for building `dictd' dictfmt: - new option --default-strategy. See dictfmt(1). Documentation update ---------------------------------------------------------------------- Version 1.9.14, by Aleksey Cheusov, Sun, 6 Jun 2004 21:18:19 +0300 dictd: - fixed: SHOW INFO command sends incorrectly formatted data to the client if the information about database was set using 'info' keyword. Affected versions: 1.9.12-1.9.13 - 'dictd' opens a log file (-L option) before releasing root priviledges. As a result log file can be created in /var/log directory. Log file and syslog are opened once. Error messages of sanity checks are written to log file (or syslog) but the stderr. - --listen-to option binds a socket to the specified address. See dictd.8 for details. - SIGUSR1 causes dictd to unload databases. Then dictd returns 420 status (instead of 220). See dictd.8 for details - exit status of child processes is written to log if '--log server' is specified. dictfmt: - fixed: 'dictfmt --locale <8bit-locale>' works incorrectly and may assert(3) on platforms having no 'mbrlen' function (FreeBSD-4). Affected versions: 1.9.12-1.9.13 - -t option implies '--columns 0' to preserve original formatting - Special 00-database-XXX headwords do not affect 00-database-alphabet, i.e. only characters from "real" headwords are added to alphabet. This makes LEV search strategy a little faster, especially search in dictionaries containing non-Latin symbols only, for example, Cyrillic symbols. dict: - In case of error 'dict' exits with non-zero status. See Section EXIT STATUS in dict.1 for details. libmaa: - arg_argify function has been reimplemented because it is buggy. Affected 'dictd' versions: 1.4.9-1.9.13. More tests for arg_argify function have been added Testing program has also been reimplemeneted. See ChangeLog for details. ---------------------------------------------------------------------- Version 1.9.13, by Aleksey Cheusov, 24 Mar 2004 11:32:53 +0200 FIXED: if database has no 00-database-alphabet headword, "global" alphabet is built incorrectly. As a result dictd may work (FreeBSD does) incorrectly with LEV strategy. Affected versions: 1.9.12 ADDED: plugin using libdbi library for implementing DICT database using SQL server. It is possible to specify custom search strategies by specifying SQL query. The following option are currently supported: driverdir - path to DBI drivers drivername - DBI driver name, such as pgsql, mysql, sqlite etc. option_host - host to connect to option_port - port to connect to option_dbname - database name option_username - user name for authorizing to SQL server option_password - user password for authorizing to SQL server query_define - SQL query for implementing DEFINE command query_ - SQL query for implementing 'strategy' (MATCH command). Note that 'strategy' is not limited to the "standard" ones. See the file example_plugin_dbi.conf for sample of how this plugin can be configured. SQL queries should return 1-column result by using SELECT command. %q sequence inside SQL query is expanded to user's query. %% is expanded to single % sign. This plugin gives a simplest way to implement editable dictionaries with a help of WEB interface, but with a read-only access to it using DICT protocol. NOTE! Unless libdbi library is not found on your system or you configure dictd with --disable-plugin option, 'dictd' is linked with libdbi to resolve DBI driver's symbols. This should be fixed. NOTE! Connection to SQL database is made for every DEFINE/MATCH command. This slows down plugin and should be fixed. ---------------------------------------------------------------------- Version 1.9.12, by Aleksey Cheusov, 10 Mar 2004 18:45:15 +0200 Both dictd and Judy-plugin correctly implement the 'lev' strategy for utf-8 databases. For this purpose an additional headword 00-database-alphabet is created by dictfmt. So, if you often use 'lev' strategy with utf-8 dictionaries, rebuild them using dictfmt-1.9.12 'nl_langinfo' function is used to detect whether dictd/dictfmt uses 8bit, utf-8, or C locale. dictd: - fixes SHOW SERVER command cuts off long database names crash on Solaris (and FreeBSD5 ?) due to toupper('255') returns 376 if utf-8 locale is set. LC_CTYPE and LC_COLLATE are set according to --locale. As a result date and time are logged using the C locale - MATCH|DEFINE *|! ignore invisible dictionaries. Now there is no reason to separate visible and invisible dictionaries by database_exit command. This simplifies the configuration file. - dictd --test|--test-file notifies about invalid database name dictl: - checks whether recode/iconv/konwert/locale commands are available - analyses PAGER variable to set a pager. - incorrect charset determination has been fixed dictfmt: - new option --break-headwords for use with --headword-separator, so each headword is written on its own line of the .dict file. - correctly wraps utf-8 input - new option --columns to set a number of columns for wrapping text. See dictfmt.1. By default this value is 72. All formats are affected and use the same default. - 00-database-XXX headwords are not copied to .dict file. The only exception is 00-database-short which should be copied to .dict file for older 'dictd' maa: new functions and #defines: 'str_pool_init_position', 'str_pool_next_position', 'str_pool_get_position', 'str_pool_readonly', 'str_pool_iterate', 'str_pool_iterate_arg', 'STR_ITERATE' and 'STR_ITERATE_END' to iterate over strings in the string pool. fixed a bug in flags.c/flg_set function dictdplugin_judy: fixed: if a requested headword has more than one definition, DEFINE command always returns the first one ---------------------------------------------------------------------- Version 1.9.11, by Aleksey Cheusov, 8 Dec 2003 20:55:31 +0200 NEWS file added dictd: - dictd is compiled successfully on Solaris, MacOS-X(cc). A lot of warning and error messages appeared on 64-bit Opteron and Alpha were fixed. - fixed: 'suffix' strategy doesn't ignore characters other than alphanumeric and spaces. Affected versions: 1.9.1-1.9.10 - A multi-lined short name of the database is truncated before sending to the client - patch by Michael Bunk sets a preprocessor for configuration file. If you run DICT server having a lot of dictionaries, you can preprocess configuration file using m4 (or cpp). This significantly reduces the size of configuration file. See dictd.8 and example_complex.conf. plugins: - the default directory for databases is passed to plugins (DICT_PLUGIN_INITDATA_DEFDBDIR) - plugin support is ported to systems having dlXXX API in libc (FreeBSD). - added: Judy-based plugin implementing fast "exact" and especially "lev" strategies. http://sf.net/projects/judy See example_complex.conf for the sample of usage. "prefix" strategy is also supported but for short queries it may be very slow. If you need not this, disable it by "disable_strategy" keyword. dict: - clientparse.y will accept "pager' as the pager. Thanks to Kirk Hilliard. dictfmt: - fixed: dictfmt -f doesn't work correctly if the first two lines are empty Affected versions of dictfmt: 1.6.1-1.9.10 - fixed: --headword-separator doesn't work with -f, -p and -v formats dictl - wrapper script for "dict" that permits using utf-8 encoded dictionaries on a terminal that is not utf-8 aware. See dictl.1 for documentation. colorit - a script for colorizing the text input which can be used as dict pager. It is currently very simple but allows to make dict's output a bit nicer. See colorit.1 for documentation. documentation update other fixes and improvements ---------------------------------------------------------------------- Version 1.9.10, by Aleksey Cheusov, 22 Jul 2003 19:37:22 +0300 dictd-1.9.10 has been released. It is available for download from http://sf.net/projects/dict Major changes: - 'filter' option is fully implemented - Documentation update - fixes: - 'lev' strategy (pple' query doesn't match the word 'apple') Affected version: 1.4.9 - 1.9.9 - 're' and 'regex' strategies ('^apple|orange' and '^apple\|orange' doesn't match a word 'orange') Affected versions: 1.4.9-1.9.9 - incorrect spaces trimming Affected versions: 1.9.1-1.9.9 - 'dictd' can be built with a regex engines other than local Henry Spencer's one. A system-wide regexec/regcomp are used by default. The first reason for this is that Henry Spencer's' implementation is not a fastest one. The second reason is that it doesn't support utf-8. - added: dictfmt -t. This simplifies rebuilding databases using 'dictunformat' utility. - System-wide wcXXX and mbXXX functions are used if present. - predefined DICT servers dict.org and alt0.dict.org are not used by default by 'dict' client ---------------------------------------------------------------------- Version 1.9.9, by Aleksey Cheusov, 14 Apr 2003 19:30:54 +0300 dictd-1.9.9 has been released and it is available for download from http://sf.net/projects/dict Major changes: - dictd can be run from inetd. - cygwin improvements - dlopen is used instead of lt_dlopen on platforms where it is available (concerns to plugins) - bug fixes ---------------------------------------------------------------------- Version 1.9.8, by Aleksey Cheusov, 27 Mar 2003 15:33:34 +0200 dictd-1.9.8 has been released and is available for download from http://sf.net/projects/dict Major changes: - dictd can be compiled on CYGWIN without utf-8 support. If anyone manages to run dictd on Windows as a service, let me know. - UTF-8 support is optional. It is disabled on platforms which don't support 'iswalnum', 'iswspace' or 'towlower' functions. - fixes: - 'dictdb_free' plugin function is not called (affected versions: 1.9.1-1.9.7) - incorrect dzip format detection (affected versions: 1.4.9-1.9.7 (all?)) - possible crash while reading too long COMMENT or FNAME fields of the dzip'ed file (dictzip doesn't create them) (affected versions: 1.4.9-1.9.7 (all?)) ---------------------------------------------------------------------- Version 1.9.7, by Aleksey Cheusov, 09 Mar 2003 20:03:42 +0200 dictd-1.9.7 is released Download it from http://sourceforge.net/projects/dict. Major changes: - 'database_virtual' keyword in the configuration file specifies 'virtual' dictionary without database files. - 'database_plugin' keyword in the configuration file specifies plugin without database files. - 'info' keyword in the 'database specification' specifies the information about database. @ prefix is also supported and specifies an entry name. - dictd --add-strategy allows to implement (with a help of plugins) new strategies not available in 'dictd'. For example, 'revert' strategy may be implemented. By using '--with-strategy' and '--add-strategy' options it is possible to create DICT server with the set of strategies you need. - 'invisible' keyword in the configuration file allows to hide several databases. This may be useful if you use virtual databases. - 'string' in the configuration file can be continued between lines. - ./configure --with-nec-socks5 With this option applied, programs will be linked with the NEC socks5 library ---------------------------------------------------------------------- Version 1.9.6, by Aleksey Cheusov, 02 Mar 2003 14:19:37 +0200 A bug fixing release is available for download from http://sf.net/projects/dict Changes: critical fix: dictd may crash on BMH search (substring, suffix and word strategies) because it accesses memory outside mmap'ed region. Affected versions: 1.4.9-1.9.5 ---------------------------------------------------------------------- Version 1.9.5, by Aleksey Cheusov, 23 Feb 2003 20:28:32 +0200 If the 'name' keyword is used in database section, and it doesn't begin with '@', dictd may crash on SIGHUP. Affected versions: 1.9.1-1.9.4. The following is the patch. This patch is the only difference between dictd-1.9.4 and dictd-1.9.5 releases. You can download dictd-1.9.5 from http://sf.net/projects/dict diff -ruN dictd-1.9.4/dictd.c dictd1/dictd.c --- dictd-1.9.4/dictd.c Mon Feb 10 21:24:25 2003 +++ dictd1/dictd.c Sun Feb 23 19:13:43 2003 @@ -572,6 +572,9 @@ db->databaseShort = get_entry_info( db, DICT_SHORT_ENTRY_NAME ); else if (*db->databaseShort == '@') db->databaseShort = get_entry_info( db, db->databaseShort + 1 ); + else + db->databaseShort = xstrdup (db->databaseShort); + if (!db->databaseShort) db->databaseShort = xstrdup (db->databaseName); ---------------------------------------------------------------------- Version 1.9.4, by Aleksey Cheusov, 20 Feb 2003 17:01:30 +0200 dict-1.9.4 is released. It is available for download from http://sourceforge.net/projects/dict Major changes: - Documentation update by Bob Hilliard - 'snprintf' and 'vsnprintf' functions are used instead of 'sprintf' and 'vsprintf' on platforms where they are available. - dictd fails if it is run with "C" locale and discovers 8-bit/utf-8 dictionaries. dictfmt/dictfmt_index2suffix/dictfmt_index2word/dictfmt_virtual fails if they are run with "C" locale and discover 8-bit/utf-8 input. - 'make samples' bug fixed - 'dict --serverinfo' bug fixed - 'dictd --test-match' bug fixed ---------------------------------------------------------------------- Version 1.9.3, by Aleksey Cheusov, 24 Jan 2003 12:53:48 +0200 dictd-1.9.3 has been released. It is available for download from http://sourceforge.net/projects/dict Major changes: - fix for dictd. It crashes on exiting/reloading configuration file if access section in the configuration file is empty. Affected versions: 1.8.0, 1.9.1, 1.9.2 ---------------------------------------------------------------------- Version 1.9.2, by Aleksey Cheusov, 16 Jan 2003 15:42:29 +0200 dictd-1.9.2 has been released It is available from http://sourceforge.net/projects/dict Major changes: - fix for dictzip's segfault - dictunformat utility - additional dictfmt arguments: --without-header --without-url --without-time - error message is returned by 'dictd' for invalid utf-8 requests IMHO it is better than return code 501 specified by RFC - DESTDIR env. variable is used for installing/uninstalling This simplifies building RPMs. ---------------------------------------------------------------------- Version 1.9.1, by Aleksey Cheusov, 17 Dec 2002 17:32:40 +0200 dictd-1.9.1 is available for download from http://sourceforge.net/projects/dict/ Major changes: - Virtual dictionaries support - New search strategy 'word' - Configuration file reloading by SIGHUP - A lot of plugin enhancements and two plugin examples. You can also disable plugin support explicitly by running ./configure --disable-plugin - bugs fixing ---------------------------------------------------------------------- Version 1.8.0, by Aleksey Cheusov, 15 Sep 2002 20:54:30 -0400 - better 8bit, UTF-8, and i18n support - dictfmt is now part of the dictd tarball - dictd supports plugins - dictd will use system libz when possible ---------------------------------------------------------------------- Version 1.7.1 (broken support for 8bit dictionaries) ---------------------------------------------------------------------- Version 1.7.0, by Rick Faith, 3 May 2002 10:02:11 -0400 I've released dictd 1.7.0. It's the same as 1.6.93, except: 1) The locale for dictd defaults to "C". So if you've been using LC_ALL, you probably need to use the new --locale option. I know this is a kludge and that dictd must move to Unicode/UTF-8/UCS-4. 2) The dict pager is closed on fatal errors. This may help prevent the screen corruption under Debian when dict is used with less and there is a fatal error. Please let me know. 3) Log output no longer filters the 8th bit. I've also updated the databases on www.dict.org to the most recent ones in use by Debian, and I've put those in ftp.dict.org:/pub/dict/pre. I'm still using web1913 and wn instead of gcide. However, gcide is available for testing if you use "dict -ugcide -kgcide -dgcide" [this may be removed in the future, but try it out now; note that older client may not pass authenticate unless you also specify -h]. Please don't hard code a "user gcide gcide" in any example or distributed .dictrc files. Thanks. ---------------------------------------------------------------------- Version 1.6.93-testonly, by Rick Faith (no information available) ---------------------------------------------------------------------- Version 1.5.5, by Rick Faith (no information available) ---------------------------------------------------------------------- Version 1.5.3, by Rick Faith (no information available) ---------------------------------------------------------------------- Version 1.5.0, by Rick Faith, 22 Dec 1999 10:43:37 -0500 dictd-1.5.0 has been released. This is a bug fix release that should cover most of the common problems that have been reported. Testing on Sparc/Linux still needs to be done. The IRIX port is not useful. This files contains the sources to the dict client, the dictd server, and the dictzip compression program. Starting with version 2.0.0, sources to these programs will be in different files. Sources are available from: ftp://ftp.dict.org/pub/dict/dictd-1.5.0.tar.gz and from the SourceForge repository, via http: http://www.sourceforge.net/project/?form_grp=605 or via anonymous cvs (see the appropriate link on the page above). We have moved the core software development effort to SourceForge, since it provides a publicly accessible cvs repository and bug tracking. Feel free * to submit bugs via the SourceForge interface or via dict-beta@dict.org. ---------------------------------------------------------------------- Version 1.4.9, by Rick Faith (no information available) ---------------------------------------------------------------------- Version 1.4.8, by Rick Faith (no information available) ---------------------------------------------------------------------- Version 1.4.5, by Rick Faith, 23 Feb 1998 20:00:23 -0500 The DICT Development Group (www.dict.org) announces the dictd-1.4.x distribution, containing client/server software implementing the Dictionary Server Protocol, as described in RFC 2229. The Dictionary Server Protocol (DICT) is a TCP transaction based query/response protocol that allows a client to access dictionary definitions from a set of natural language dictionary databases. dict(1) is a client which can access DICT servers from the command line. dictd(8) is a server which supports the DICT protocol. dictzip(1) is a compression program which creates compressed files in the gzip format (see RFC 1952). However, unlike gzip(1), dictzip(1) compresses the file in pieces and stores an index to the pieces in the gzip header. This allows random access to the file at the granularity of the compressed pieces (currently about 64kB) while maintaining good compression ratios (within 5% of the expected ratio for dictionary data). dictd(8) uses files stored in this format. ---------------------------------------------------------------------- Version 1.4.3, by Rick Faith (no information available) DICT protocol, by Rick Faith, 29 Oct 1997 19:34:58 -0500 A new Request for Comments is now available in online RFC libraries. RFC 2229: Title: A Dictionary Server Protocol Author(s): R. Faith, B. Martin Status: Informational Date: October 1997 Mailbox: faith@cs.unc.edu, bamartin@miranda.org Pages: 30 Characters: 59551 Updates/Obsoletes: None URL: ftp://ds.internic.net/rfc/rfc2229.txt The Dictionary Server Protocol (DICT) is a TCP transaction based query/response protocol that allows a client to access dictionary definitions from a set of natural language dictionary databases. This memo provides information for the Internet community. It does not specify an Internet standard of any kind. Distribution of this memo is unlimited. dictd-1.12.1+dfsg.orig/README0000644000000000000000000000153107715571013014125 0ustar rootroot INSTALLATION ============ Please see the file INSTALL in this directory REPORTING BUGS ============== Please send all bug reports and patches to dict-beta@dict.org MAILING LISTS ============= The following mailing lists are publicly available: * dict-announce: a low-volume mailing list for major DICT-related announcements. * dict-beta: a high-volume discussion list for operators and implementors of DICT client/server software. If you run a DICT server, please join (at minimum) the dict-announce mailing list so that you can track new releases, bug fixes, and new databases. To join dict-announce, send email to dict-announce-subscribe@dict.org. To join dict-beta, send email to dict-beta-subscribe@dict.org. [README file courtesy Jeff Blain ] dictd-1.12.1+dfsg.orig/TODO0000644000000000000000000000235011511171225013723 0ustar rootrootstrategies: - noname? (inverted prefix when headword is a prefix for query) - double metaphone - cjk dictd: * Add portable snprintf implementation and robustify logging * Support "dict:" definition index feature * Add anagram search engine * Add search for edit distances greater than 1 * Explore improved spelling correction algorithms * Add a stemming option for spelling correction * Print a reasonable message if no config file is available * Add support for conditional searches * Add support for index entries that are only matched with "exact" * Re-write indexing scheme to make it faster (preprocess entries) * Add reverse DNS lookup * Add IP/mask notation for allow/deny dict: * Make match results line up in columns * Improve HTML support * unbundle from dictd package dictd and dict: * Add support for use of DICF format internally dictzip: * Correct error in computation of "chunk" size, so that chunk sizes can be larger * unbundle from dictd package dictfmt: * Remake dictfmt in runawk? DICT protocol: * Add syntax to describe a "web" or "net" of servers. * Add error messages to accommodate use with external database query engines (i.e., "database currently unavailable) * Add syntax to request different MIME content types dictd-1.12.1+dfsg.orig/clientparse.y0000644000000000000000000000375611116777275015773 0ustar rootroot/* clientparse.y -- * Created: Fri Jul 11 11:34:05 1997 by faith@acm.org * Copyright 1997, 1998, 2001 Rickard E. Faith (faith@acm.org) * Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) * * 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 1, 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. */ %{ #include "dict.h" #define YYDEBUG 1 #define YYERROR_VERBOSE static dictServer *s; %} %union { dictToken token; lst_List list; } /* Terminals */ %token '{' '}' TOKEN_SERVER TOKEN_PORT TOKEN_USER TOKEN_FILTER %token TOKEN_STRING %type Options Server ServerList %% Options : ServerList ; ServerList : Server { $$ = dict_Servers = lst_create(); lst_append($$, $1); } | ServerList Server { lst_append($1, $2); $$ = $1; } ; Server : TOKEN_SERVER TOKEN_STRING { s = xmalloc(sizeof(struct dictServer)); memset( s, 0, sizeof(struct dictServer)); s->host = $2.string; } '{' SpecList '}' { $$ = s; } | TOKEN_SERVER TOKEN_STRING { s = xmalloc(sizeof(struct dictServer)); memset( s, 0, sizeof(struct dictServer)); s->host = $2.string; $$ = s; } ; SpecList : Spec | SpecList Spec ; Spec : TOKEN_PORT TOKEN_STRING { s->port = $2.string; } | TOKEN_USER TOKEN_STRING TOKEN_STRING { s->user = $2.string; s->secret = $3.string; } ; dictd-1.12.1+dfsg.orig/clientscan.l0000644000000000000000000000507011116777275015557 0ustar rootroot/* clientscan.l -- * Created: Fri Jul 11 11:33:46 1997 by faith@acm.org * Copyright 1997, 1998, 1999 Rickard E. Faith (faith@acm.org) * Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) * * 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 1, 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. */ %option stack debug %{ #include #include "dict.h" #include "clientparse.h" extern int yylex( void ); extern int yydebug; extern void yyerror( const char *message ); #define RETURN(val) do { \ yylval.token.src = src_get( yyleng ); \ return val; \ } while (0) %} %s OTHER comment #.* word ([[:alnum:]_/\-\.\*][[:alnum:]_/\-\.\*]*) string \"(([^\"\n])|\"\")*\" badstring \"(([^\"\n])|\"\")* NL \n WS [[:blank:]]+ %% { .*{NL} src_line(yytext,yyleng); yyless(0); BEGIN(OTHER); .* src_line(yytext,yyleng); yyless(0); BEGIN(OTHER); } server RETURN(TOKEN_SERVER); port RETURN(TOKEN_PORT); user RETURN(TOKEN_USER); filter RETURN(TOKEN_FILTER); {word} { yylval.token.string = str_findn(yytext, yyleng); RETURN(TOKEN_STRING); } {string} { yylval.token.string = str_findn(yytext+1, yyleng-2); RETURN(TOKEN_STRING); } {NL} BEGIN(INITIAL); {WS} src_advance( yyleng ); {comment} src_advance( yyleng ); . RETURN(yytext[0]); <> RETURN(0); %% int yywrap( void ) { return 1; } void yyerror( const char *message ) { src_parse_error( stderr, yylval.token.src, message ); err_fatal( __func__, "parse error\n" ); exit( 1 ); } dictd-1.12.1+dfsg.orig/codes.h0000644000000000000000000000405511116777275014527 0ustar rootroot/* codes.h -- * Created: Wed Apr 16 08:44:03 1997 by faith@dict.org * Copyright 1997, 2000 Rickard E. Faith (faith@dict.org) * Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) * This program comes with ABSOLUTELY NO WARRANTY. */ #ifndef _CODES_H_ #define _CODES_H_ #define CODE_DATABASE_LIST 110 /* n databases present */ #define CODE_STRATEGY_LIST 111 /* n strategies available */ #define CODE_DATABASE_INFO 112 /* database information follows */ #define CODE_HELP 113 /* help text follows */ #define CODE_SERVER_INFO 114 /* server information follows */ #define CODE_DEFINITIONS_FOUND 150 /* n definitions */ #define CODE_DEFINITION_FOLLOWS 151 /* word database name */ #define CODE_MATCHES_FOUND 152 /* n matches */ #define CODE_STATUS 210 /* (status information here) */ #define CODE_HELLO 220 /* text msg-id */ #define CODE_GOODBYE 221 /* Closing Connection */ #define CODE_AUTH_OK 230 /* Authentication Successful */ #define CODE_OK 250 /* ok */ #define CODE_TEMPORARILY_UNAVAILABLE 420 /* server unavailable */ #define CODE_SHUTTING_DOWN 421 /* server shutting down */ #define CODE_SYNTAX_ERROR 500 /* syntax, command not recognized */ #define CODE_ILLEGAL_PARAM 501 /* syntax, illegal parameters */ #define CODE_COMMAND_NOT_IMPLEMENTED 502 /* command not implemented */ #define CODE_PARAM_NOT_IMPLEMENTED 503 /* parameter not implemented */ #define CODE_ACCESS_DENIED 530 /* access denied */ #define CODE_AUTH_DENIED 531 /* authentication denied */ #define CODE_UNKNOWN_MECH 532 /* unknown authentication mechanism */ #define CODE_INVALID_DB 550 /* invalid database */ #define CODE_INVALID_STRATEGY 551 /* invalid strategy */ #define CODE_NO_MATCH 552 /* no match */ #define CODE_NO_DATABASES 554 /* no databases */ #define CODE_NO_STRATEGIES 555 /* no strategies */ #endif dictd-1.12.1+dfsg.orig/colorit.1.in0000644000000000000000000000420610344375410015404 0ustar rootroot.\" colorit.1 -- .\" Created: Tue, 28 Oct 2003 22:19:36 +0200 .\" by Aleksey Cheusov .TH COLORIT 1 "28 Oct 2003" "" "" .SH "NAME" colorit - a script for markuping the text input .SH "SYNOPSIS" .nf .BI colorit " [OPTIONS] [files...]" .fi .SH "DESCRIPTION" .B colorit is a script for markuping text input and sending a result to pager ( .I less -r by default) or stdout. Markuping rules are described in a configuration file which is filtered by preprocessor (the default is .I m4 ). The define HOME equal to your home directory is set for the preprocessor using -D option supported by both .I m4 and .I cpp. This script can be used for colorizing the text by ANSI escape sequences, or making a simple text conversions and may be used as a pager instead of .I less by .I dict or other programs. In particular, log files, .I dict, .I cc, .I make, or .I diff output can easily be colorized and viewed. .SH "OPTIONS" .TP .BR \-V " or " \-\-version Shows version information. .TP .BR \-h " or " \-\-help Shows help information. .TP .BI \-c " file\fR or " \-\-config " file" Specify configuration file. The default is .I ~/.coloritrc or .I @SYSCONFDIR@/colorit.conf .TP .BI \-P " pager\fR or " \-\-pager " pager" Specify a pager (- for none). The default is .I less -r .TP .BI \-\-pp " preprocessor" Specify a preprocessor (- for none). .SH "FILES" .TP .I ~/.coloritrc User's .B colorit configuration file .TP .I @SYSCONFDIR@/colorit.conf System .B colorit configuration file .SH "CONFIG FILE" Empty lines or lines beginning with sharp sign (`#') are ignored. All other lines have this structure: .I command arg1 arg2 ... argN. All commands are processed one-by-one for each input line. .br .I args strings can be surrounded by double-quote characters. .br Currently, only .I mark command is available having the following arguments: .I regexp pre_string post_string .br The .I pre_string and .I post_string are inserted at the beginning and the end of substring matched by regular expression .I regexp .SH "BUGS" The only supported escape sequence in the strings surrounded by double quotes is \\033. .SH "SEE ALSO" .BR less (1), .BR m4 (1), .BR cpp (1), .BR dict (1) dictd-1.12.1+dfsg.orig/colorit.in0000755000000000000000000000710712003004257015243 0ustar rootroot#!/bin/sh # # Written by Aleksey Cheusov # sysconfdir=@sysconfdir@ usage (){ printf "\ colorit is intended to markup stdin or input files\n\ and output result to stdout\n\ \n\ usage: colorit [OPTIONS] [files...]\n\ OPTIONS:\n\ -h --help display this screen\n\ -V --verbose display version\n\ -c --config specify a configuration file\n\ --pp specify preprocessor (- for none). The default is \"m4\"\n\ " } version (){ printf "\ colorit 0.0.1\n\ " } pp='m4' config_file=$HOME/.coloritrc while test $# -ne 0; do case $1 in -h|--help) usage exit 0;; -V|--version) version exit 0;; -c|--config) config_file=$2 shift;; -P|--pager) pager=$2 if test "$pager" != -; then echo '--pager option is now deprecated' 1>&2 exit 1 fi shift;; --pp) pp=$2; shift;; --) shift break;; -*) echo "unknown argument '$1'" 1>&2 break;; *) break;; esac shift done if test -r "$config_file"; then : elif test -r "$sysconfdir/colorit.conf"; then config_file="$sysconfdir/colorit.conf" else echo "configuration file is not readable" > "/dev/stderr" exit 1 fi if test "_$pp" = "_-"; then pp= fi convert_files_to_stdout (){ gawk -v config_file="$config_file" -v pp="$pp" ' BEGIN { for (i=1; i <= ARGC; ++i){ if (ARGV [i] == "--help"){ usage() exit 1 } if (ARGV [i] == "--version"){ version() exit 1 } if (ARGV [i] == "--config" || ARGV [i] == "-c"){ config_file = ARGV [i + 1] ARGV [i] = ARGV [i + 1] = "" ++i continue } } } BEGIN { mark_count = 0 } function do_esc (s){ gsub(/\\033/, "\033", s) return s } function do_unquote (s) { if (s ~ /^".*"$/ || s ~ /^`.*`$/){ return substr(s, 2, length(s)-2) }else{ return s } } function process_config_mark ( ok, arr){ ok = match($0, /mark +("[^"]+"|`[^`]+`|[^ ]+) +("[^"]+"|`[^`]+`|[^ ]+) +("[^"]+"|`[^`]+`|[^ ]+) *$/, arr) if (ok){ mark_repl[mark_count] = "&" mark_re [mark_count] = do_unquote(arr [1]) mark_beg [mark_count] = do_esc(do_unquote(arr [2])) mark_end [mark_count] = do_esc(do_unquote(arr [3])) ++mark_count return 1 }else{ return 0 } } function process_config_gensub ( ok, arr){ ok = match($0, /^gensub +("[^"]+"|`[^`]+`|[^ ]+) +("[^"]+"|`[^`]+`|[^ ]+) *$/, arr) if (ok){ mark_repl[mark_count] = do_esc(do_unquote(arr [1])) mark_re [mark_count] = do_unquote(arr [2]) mark_beg [mark_count] = "" mark_end [mark_count] = "" ++mark_count return 1 }else{ return 0 } } function process_config_line (){ sub(/^#.*$/, "") if (NF == 0) return if ($1 == "mark"){ if (!process_config_mark()){ print "missing arguments to `mark` at line:\n`" $0 "`" > "/dev/stderr" exit 1 } }else if ($1 == "gensub"){ if (!process_config_gensub()){ print "missing arguments to `gensub` at line:\n`" $0 "`" > "/dev/stderr" exit 1 } }else{ print "unexpected command `" $1 "`" > "/dev/stderr" exit 2 } } function process_config (){ if (pp == ""){ while (0 < (ret = (pipe | getline))){ process_config_line() } }else{ pipe = pp " -DHOME=" ENVIRON ["HOME"] " <\"" config_file "\"" while (0 < (ret = (pipe | getline))){ process_config_line() } close(pipe) } } BEGIN { process_config() } { for (i=0; i < mark_count; ++i){ cnt = gsub(mark_re [i], (mark_beg [i] "&" mark_end [i])) } print $0 } ' "$@" } convert_files_to_stdout "$@" dictd-1.12.1+dfsg.orig/config.guess0000755000000000000000000012475310346023734015575 0ustar rootroot#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. timestamp='2005-08-03' # This file 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., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerppc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; x86:Interix*:[34]*) echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' exit ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #ifdef __INTEL_COMPILER LIBC=gnu #else LIBC=gnuaout #endif #endif #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` test x"${LIBC}" != x && { echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit } test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in *86) UNAME_PROCESSOR=i686 ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: dictd-1.12.1+dfsg.orig/config.sub0000755000000000000000000007577710346023734015253 0ustar rootroot#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. timestamp='2005-07-08' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file 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., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | ms1 \ | msp430 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m32c) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | ms1-* \ | msp430-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa-* \ | ymp-* \ | z8k-*) ;; m32c-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16c) basic_machine=cr16c-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: dictd-1.12.1+dfsg.orig/configure.in0000644000000000000000000002042512003012221015532 0ustar rootrootdnl Process this file with autoconf to produce a configure script for dict. dnl dnl Created: Wed Apr 24 14:11:05 1996 by faith@dict.org dnl Copyright 1996-1999, 2001-2002 Rickard E. Faith (faith@dict.org) dnl Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) dnl dnl This program is free software; you can redistribute it and/or modify it dnl under the terms of the GNU General Public License as published by the dnl Free Software Foundation; either version 1, or (at your option) any dnl later version. dnl dnl This program is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License along dnl with this program; if not, write to the Free Software Foundation, Inc., dnl 675 Mass Ave, Cambridge, MA 02139, USA. dnl dnl Flag conventions: dnl CFLAGS and LDFLAGS should be settable on the make commandline dnl for optimization and stripping. dnl LIBOBJS is an automatically-generated list of extra objects we need define(VERSION, 1.12.1) AC_PREREQ(2.53) AC_REVISION($Revision: 1.144 $) AC_INIT([dict],[VERSION],[dict-beta@dict.org]) AC_CONFIG_SRCDIR([dictd.c]) AC_CONFIG_HEADER(config.h) echo Configuring for dict echo . DICT_VERSION=VERSION AC_CANONICAL_HOST AC_PROG_CC AC_PROG_CPP AC_PROG_CXX AC_ISC_POSIX REALCC="$CC" if test "$CC" = gcc; then CFLAGS="$CFLAGS -Wall" CFLAGS="$CFLAGS -Wwrite-strings -Wcast-align -Wmissing-prototypes" CFLAGS="$CFLAGS -Wshadow -Wnested-externs -Waggregate-return" fi AC_ARG_WITH(nec-socks5, [ --with-nec-socks5 with NEC socks5 library], [ if test "x${withval}" = xyes; then CFLAGS="$CFLAGS -Dconnect=Rconnect \ -Dgetsockname=Rgetsockname -Dgetpeername=Rgetpeername \ -Dbind=Rbind -Daccept=Raccept \ -Dselect=Rselect -DRconnect=SOCKSconnect \ -DRgetsockname=SOCKSgetsockname -DRgetpeername=SOCKSgetpeername \ -DRbind=SOCKSbind -DRaccept=SOCKSaccept -DRlisten=SOCKSlisten \ -DRselect=SOCKSselect -Drecvfrom=SOCKSrecvfrom -Dsendto=SOCKSsendto \ -Drecv=SOCKSrecv -Dsend=SOCKSsend -Dread=SOCKSread -Dwrite=SOCKSwrite \ -Drresvport=SOCKSrresvport -Dshutdown=SOCKSshutdown -Dlisten=SOCKSlisten \ -Dclose=SOCKSclose -Ddup=SOCKSdup -Ddup2=SOCKSdup2 \ -Dgethostbyname=SOCKSgethostbyname" LIBS="$LIBS -lsocks5" fi ]) AC_ARG_WITH(system-utf8, [ --with-system-utf8-funcs use system wcXXX and mbXXX functions], [ if test "x${withval}" = xyes; then SYSTEM_UTF8=1 fi ]) AC_ARG_ENABLE([plugin],[ --disable-plugin without plugin support]) if test "x${enableval}" != xno; then AC_CHECK_LIB(c, dlopen, [USE_PLUGIN=2], AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"; USE_PLUGIN=2], AC_CHECK_LIB(ltdl,lt_dlopen, [LIBS="$LIBS -lltdl"; USE_PLUGIN=1]))) fi AC_ARG_ENABLE([dictorg],[ --enable-dictorg use predefined dict servers]) if test "x${enableval}" = xyes; then CFLAGS="$CFLAGS -DUSE_DICT_ORG" fi dnl Checks for programs. echo Checking for programs AC_PROG_AWK AC_PROG_INSTALL AC_PROG_RANLIB AC_PROG_MAKE_SET AC_PROG_YACC AC_PROG_LEX AC_CHECK_PROG(LIBTOOL,libtool,libtool) AC_CHECK_PROGS(NROFF,gnroff nroff) AC_CHECK_PROGS(TROFF,groff troff) AC_CHECK_PROGS(COL,col cat) AC_CHECK_PROGS(EXPAND,expand cat) echo . echo Checking for libraries AC_CHECK_LIB(maa,maa_shutdown, [LIBMAA=-lmaa], [AC_MSG_ERROR([Libmaa not found])]) AC_ARG_WITH(plugin-dbi, [ --with-plugin-dbi build libdbi plugin (plugin support should be enabled)], [ if test "x${withval}" != xno; then AC_CHECK_LIB(dbi, dbi_shutdown, [PLUGINS="$PLUGINS dictdplugin_dbi.la"], [AC_MSG_ERROR([libdbi not found, cannot continue])]) AC_CHECK_HEADER([dbi/dbi.h],, [AC_MSG_ERROR([dbi/dbi.h not found, cannot continue])]) fi ]) AC_ARG_WITH(plugin-judy, [ --with-plugin-judy build judy plugin (plugin support should be enabled)], [ if test "x${withval}" != xno; then AC_CHECK_LIB(Judy, JudySLNext, [PLUGINS="$PLUGINS dictdplugin_judy.la"], [AC_MSG_ERROR([libJudy not found, cannot continue])]) AC_CHECK_HEADER([Judy.h],, [AC_MSG_ERROR([Judy.h not found, cannot continue])]) fi ]) AC_CHECK_LIB(socket,main) AC_CHECK_LIB(c,inet_ntoa, [true], [AC_CHECK_LIB(nsl,inet_ntoa)]) echo . echo Checking for header files AC_HEADER_STDC AC_HEADER_TIME if test "x${USE_PLUGIN}" = "x2"; then # We use native dlopen AC_CHECK_HEADERS(dlfcn.h, [CFLAGS="$CFLAGS -DUSE_PLUGIN"], [USE_PLUGIN=]) fi if test "x${USE_PLUGIN}" = "x1"; then # We use libltdl AC_CHECK_HEADERS(ltdl.h, [CFLAGS="$CFLAGS -DUSE_PLUGIN"], [USE_PLUGIN=]) fi AC_CHECK_HEADERS(strings.h limits.h) AC_CHECK_HEADERS(inttypes.h) AC_CHECK_HEADERS(sys/resource.h sys/time.h sys/param.h sys/wait.h) AC_CHECK_HEADERS(wctype.h wchar.h) AC_CHECK_HEADERS(ctype.h getopt.h) AC_CHECK_HEADER([zlib.h], , [AC_MSG_ERROR([zlib.h is required for dictd])]) AC_CHECK_TYPES(wint_t,,, [#include ]) AC_CHECK_TYPES(mbstate_t, , , [#include ]) AC_CHECK_TYPES(wchar_t, , , [#include ]) AC_CHECK_TYPES(size_t) AC_CHECK_TYPES(socklen_t,,, [#include #include ]) echo . echo Checking for system constants AC_C_CONST AC_C_INLINE echo . echo Checking for library functions AC_FUNC_ALLOCA AC_FUNC_FORK #AC_FUNC_STAT AC_FUNC_STRCOLL AC_FUNC_STRFTIME AC_FUNC_VPRINTF AC_FUNC_WAIT3 AC_CHECK_FUNCS(waitpid) #AC_FUNC_MMAP AC_CHECK_FUNCS(mmap munmap) AC_CHECK_FUNCS(strdup strtol strtoul semget strerror inet_aton) AC_CHECK_FUNCS(strdup strtol strtoul) AC_CHECK_FUNCS(alarm gethostbyaddr gethostbyname gethostname gettimeofday) AC_CHECK_FUNCS(inet_ntoa regcomp setlocale) AC_CHECK_FUNCS(socket strcasecmp strchr strrchr strstr uname) AC_CHECK_FUNCS(dlopen) AC_CHECK_FUNCS(getopt) AC_CHECK_FUNCS(initgroups) AC_CHECK_FUNC(daemon,, [AC_LIBOBJ([daemon3])]) AC_REPLACE_FUNCS(setenv) AC_CHECK_FUNCS(putenv) AC_CHECK_FUNCS(fileno) if test "$SYSTEM_UTF8"; then CFLAGS="$CFLAGS -DSYSTEM_UTF8_FUNCS" AC_REPLACE_FUNCS(wcrtomb wctomb mbrlen mbrtowc mbstowcs mbtowc) AC_REPLACE_FUNCS(iswspace iswalnum towlower) AC_CHECK_FUNCS(wcwidth) else #not SYSTEM_UTF8 AC_LIBOBJ([wcrtomb]) AC_LIBOBJ([wctomb]) AC_LIBOBJ([mbrlen]) AC_LIBOBJ([mbrtowc]) AC_LIBOBJ([mbstowcs]) AC_LIBOBJ([mbtowc]) AC_LIBOBJ([iswspace]) AC_LIBOBJ([iswalnum]) AC_LIBOBJ([towlower]) # AC_LIBOBJ([wcwidth]) fi #end of SYSTEM_UTF8 AC_REPLACE_FUNCS(strlcpy strlcat) AC_REPLACE_FUNCS(getopt_long) AC_REPLACE_FUNCS(snprintf vsnprintf) AC_CHECK_DECLS(CODESET,, [AC_LIBOBJ(nl_langinfo)], [#include ]) echo . echo Making output files CC="$REALCC" test "_$exec_prefix" = _NONE && exec_prefix='${prefix}' eval3 () { eval echo $(eval echo $(eval echo $@)); } SYSCONFDIR=`eval3 $sysconfdir` BINDIR=`eval3 $bindir` SBINDIR=`eval3 $sbindir` LIBEXECDIR=`eval3 $libexecdir` DATADIR=`eval3 $datadir` AC_SUBST(DICT_VERSION) AC_SUBST(USE_PLUGIN) AC_SUBST(EXEEXT) AC_SUBST(allsubdirs) AC_SUBST(LIBTOOL) AC_SUBST(PLUGINS) AC_SUBST(SYSCONFDIR) AC_SUBST(BINDIR) AC_SUBST(SBINDIR) AC_SUBST(LIBEXECDIR) AC_SUBST(DATADIR) AC_SUBST(LIBMAA) AC_SUBST(srcdir) AC_CONFIG_FILES([Makefile doc/Makefile]) AC_CONFIG_FILES([dictdplugin-config], [chmod +x dictdplugin-config]) AC_CONFIG_FILES([dictl], [chmod +x dictl]) AC_CONFIG_FILES([colorit], [chmod +x colorit]) AC_CONFIG_FILES([dictunformat], [chmod +x dictunformat]) AC_CONFIG_FILES([dictfmt_index2suffix], [chmod +x dictfmt_index2suffix]) AC_CONFIG_FILES([dictfmt_index2word], [chmod +x dictfmt_index2word]) AC_CONFIG_FILES([examples/dictd_popen.conf]) AC_CONFIG_FILES(colorit.1) AC_CONFIG_FILES(dict.1) AC_CONFIG_FILES(dictfmt.1) AC_CONFIG_FILES(dictfmt_index2suffix.1) AC_CONFIG_FILES(dictfmt_index2word.1) AC_CONFIG_FILES(dictl.1) AC_CONFIG_FILES(dict_lookup.1) AC_CONFIG_FILES(dictunformat.1) AC_CONFIG_FILES(dictzip.1) AC_CONFIG_FILES(dictd.8) AC_CONFIG_FILES(test/dictd_test) AC_CONFIG_FILES(test/dictzip_test) AC_OUTPUT printf '\n\n' # PLUGIN SUPPORT printf "plugin support: " if test "_$USE_PLUGIN" = "_"; then echo disabled else case "$USE_PLUGIN" in 1) echo libltdl;; 2) echo native esac printf " enabled plugins: %s\n" "$PLUGINS" fi printf '\n\n' touch stamp-h.in touch stamp-h #echo . #echo Done dictd-1.12.1+dfsg.orig/daemon.c0000644000000000000000000012310411512164370014647 0ustar rootroot/* daemon.c -- Server daemon * Created: Fri Feb 28 18:17:56 1997 by faith@dict.org * Copyright 1997, 1998, 1999, 2000, 2002 Rickard E. Faith (faith@dict.org) * Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) * * 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 1, 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. */ #include "dictd.h" #include "index.h" #include "data.h" #include "md5.h" #include "regex.h" #include "dictdplugin.h" #include "strategy.h" #include "plugin.h" #include #include int stdin2stdout_mode = 0; /* copy stdin to stdout ( dict_dictd function ) */ static int _dict_defines, _dict_matches; static int daemonS_in = 0; static int daemonS_out = 1; static const char *daemonHostname = NULL; static const char *daemonIP = NULL; static int daemonPort = -1; static char daemonStamp[256] = ""; static jmp_buf env; static int daemonMime; static void daemon_define( const char *cmdline, int argc, const char **argv ); static void daemon_match( const char *cmdline, int argc, const char **argv ); static void daemon_show_db( const char *cmdline, int argc, const char **argv ); static void daemon_show_strat( const char *cmdline, int argc, const char **argv ); void daemon_show_info( const char *cmdline, int argc, const char **argv ); static void daemon_show_server( const char *cmdline, int argc, const char **argv ); static void daemon_show( const char *cmdline, int argc, const char **argv ); static void daemon_option_mime( const char *cmdline, int argc, const char **argv ); static void daemon_option( const char *cmdline, int argc, const char **argv ); static void daemon_client( const char *cmdline, int argc, const char **argv ); static void daemon_auth( const char *cmdline, int argc, const char **argv ); static void daemon_status( const char *cmdline, int argc, const char **argv ); static void daemon_help( const char *cmdline, int argc, const char **argv ); static void daemon_quit( const char *cmdline, int argc, const char **argv ); #define MAXARGCS 3 static struct { int argc; const char *name[MAXARGCS]; void (*f)( const char *cmdline, int argc, const char **argv ); } commandInfo[] = { { 1, {"define"}, daemon_define }, { 1, {"d"}, daemon_define }, { 1, {"match"}, daemon_match }, { 1, {"m"}, daemon_match }, { 2, {"show", "db"}, daemon_show_db }, { 2, {"show", "databases"}, daemon_show_db }, { 2, {"show", "strat"}, daemon_show_strat }, { 2, {"show", "strategies"}, daemon_show_strat }, { 2, {"show", "info"}, daemon_show_info }, { 2, {"show", "server"}, daemon_show_server }, { 1, {"show"}, daemon_show }, { 2, {"option", "mime"}, daemon_option_mime }, { 1, {"option"}, daemon_option }, { 1, {"client"}, daemon_client }, { 1, {"auth"}, daemon_auth }, { 1, {"status"}, daemon_status }, { 1, {"s"}, daemon_status }, { 1, {"help"}, daemon_help }, { 1, {"h"}, daemon_help }, { 1, {"quit"}, daemon_quit }, { 1, {"q"}, daemon_quit }, }; #define COMMANDS (sizeof(commandInfo)/sizeof(commandInfo[0])) static void *(lookup_command)( int argc, const char **argv ) { size_t i; int j; int err; for (i = 0; i < COMMANDS; i++) { if (argc >= commandInfo[i].argc) { for (err = 0, j = 0; j < commandInfo[i].argc; j++) { if (strcasecmp(argv[j], commandInfo[i].name[j])) { err = 1; break; } } if (!err) return commandInfo[i].f; } } return NULL; } static unsigned long daemon_compute_mask(int bits) { unsigned long mask = 0xffffffff; if (bits < 1) return 0; if (bits < 32) mask -= (1 << (32-bits)) - 1; return mask; } static void daemon_log( int type, const char *format, ... ) { va_list ap; char buf[8*1024]; char *buf2; size_t len; char *s, *d; int c; char marker = '?'; switch (type) { case DICT_LOG_TERM: if (!flg_test(LOG_STATS)) return; marker = 'I'; break; case DICT_LOG_TRACE: if (!flg_test(LOG_SERVER)) return; marker = 'I'; break; case DICT_LOG_CLIENT: if (!flg_test(LOG_CLIENT)) return; marker = 'C'; break; case DICT_LOG_CONNECT: if (!flg_test(LOG_CONNECT)) return; marker = 'K'; break; case DICT_LOG_DEFINE: if (!flg_test(LOG_FOUND)) return; marker = 'D'; break; case DICT_LOG_MATCH: if (!flg_test(LOG_FOUND)) return; marker = 'M'; break; case DICT_LOG_NOMATCH: if (!flg_test(LOG_NOTFOUND)) return; marker = 'N'; break; case DICT_LOG_COMMAND: if (!flg_test(LOG_COMMAND)) return; marker = 'T'; break; case DICT_LOG_AUTH: if (!flg_test(LOG_AUTH)) return; marker = 'A'; break; } if (dbg_test(DBG_PORT)) snprintf( buf, sizeof (buf)/2, ":%c: %s:%d ", marker, daemonHostname, daemonPort ); else if (flg_test(LOG_HOST)) snprintf( buf, sizeof (buf)/2, ":%c: %s ", marker, daemonHostname ); else snprintf( buf, sizeof (buf)/2, ":%c: ", marker ); len = strlen( buf ); va_start( ap, format ); vsnprintf( buf+len, sizeof (buf)/2-len, format, ap ); va_end( ap ); len = strlen( buf ); if (len >= sizeof (buf)/2) { log_info( ":E: buffer overflow (%d)\n", len ); buf[2048] = '\0'; len = strlen(buf); } buf2 = alloca( 3*(len+3) ); for (s = buf, d = buf2; *s; s++) { c = (unsigned char)*s; if (c == '\t') *d++ = ' '; else if (c == '\n') *d++ = c; else { if (c < 32) { *d++ = '^'; *d++ = c + 64; } else if (c == 127) { *d++ = '^'; *d++ = '?'; } else *d++ = c; } } *d = '\0'; log_info( "%s", buf2 ); if (d != buf2) d[-1] = '\0'; /* kill newline */ dict_setproctitle( "dictd %s", buf2 ); } static int daemon_check_mask(const char *spec, const char *ip) { char *tmp = alloca(strlen(spec) + 1); char *pt; char tstring[64], mstring[64]; struct in_addr target, mask; int bits; unsigned long bitmask; strcpy(tmp, spec); if (!(pt = strchr(tmp, '/'))) { log_info( ":E: No / in %s, denying access to %s\n", spec, ip); return DICT_DENY; } *pt++ = '\0'; if (!*pt) { log_info( ":E: No bit count after / in %s, denying access to %s\n", spec, ip); return DICT_DENY; } inet_aton(ip, &target); inet_aton(tmp, &mask); bits = strtol(pt, NULL, 10); strcpy(tstring, inet_ntoa(target)); strcpy(mstring, inet_ntoa(mask)); if (bits < 0 || bits > 32) { log_info( ":E: Bit count (%d) out of range, denying access to %s\n", bits, ip); return DICT_DENY; } bitmask = daemon_compute_mask(bits); if ((ntohl(target.s_addr) & bitmask) == (ntohl(mask.s_addr) & bitmask)) { PRINTF(DBG_AUTH, ("%s matches %s/%d\n", tstring, mstring, bits)); return DICT_MATCH; } PRINTF(DBG_AUTH, ("%s does NOT match %s/%d\n", tstring, mstring, bits)); return DICT_NOMATCH; } static int daemon_check_range(const char *spec, const char *ip) { char *tmp = alloca(strlen(spec) + 1); char *pt; char tstring[64], minstring[64], maxstring[64]; struct in_addr target, min, max; strcpy(tmp, spec); if (!(pt = strchr(tmp, ':'))) { log_info( ":E: No : in range %s, denying access to %s\n", spec, ip); return DICT_DENY; } *pt++ = '\0'; if (strchr(pt, ':')) { log_info( ":E: More than one : in range %s, denying access to %s\n", spec, ip); return DICT_DENY; } if (!*pt) { log_info( ":E: Misformed range %s, denying access to %s\n", spec, ip); return DICT_DENY; } inet_aton(ip, &target); inet_aton(tmp, &min); inet_aton(pt, &max); strcpy(tstring, inet_ntoa(target)); strcpy(minstring, inet_ntoa(min)); strcpy(maxstring, inet_ntoa(max)); if (ntohl(target.s_addr) >= ntohl(min.s_addr) && ntohl(target.s_addr) <= ntohl(max.s_addr)) { PRINTF(DBG_AUTH,("%s in range from %s to %s\n", tstring, minstring, maxstring)); return DICT_MATCH; } PRINTF(DBG_AUTH,("%s NOT in range from %s to %s\n", tstring, minstring, maxstring)); return DICT_NOMATCH; } static int daemon_check_wildcard(const char *spec, const char *ip) { char regbuf[256]; char erbuf[100]; int err; const char *s; char *d; regex_t re; for (d = regbuf, s = spec; s && *s; ++s) { switch (*s) { case '*': *d++ = '.'; *d++ = '*'; break; case '.': *d++ = '\\'; *d++ = '.'; break; case '?': *d++ = '.'; break; default: *d++ = *s; break; } } *d = '\0'; if ((err = regcomp(&re, regbuf, REG_ICASE|REG_NOSUB))) { regerror(err, &re, erbuf, sizeof(erbuf)); log_info( ":E: regcomp(%s): %s\n", regbuf, erbuf ); return DICT_DENY; /* Err on the side of safety */ } if (!regexec(&re, daemonHostname, 0, NULL, 0) || !regexec(&re, daemonIP, 0, NULL, 0)) { PRINTF(DBG_AUTH, ("Match %s with %s/%s\n", spec, daemonHostname, daemonIP)); regfree(&re); return DICT_MATCH; } regfree(&re); PRINTF(DBG_AUTH, ("No match (%s with %s/%s)\n", spec, daemonHostname, daemonIP)); return DICT_NOMATCH; } static int daemon_check_list( const char *user, lst_List acl ) { lst_Position p; dictAccess *a; int retcode; if (!acl) return DICT_ALLOW; for (p = lst_init_position(acl); p; p = lst_next_position(p)) { a = lst_get_position(p); switch (a->type) { case DICT_DENY: case DICT_ALLOW: case DICT_AUTHONLY: if (strchr(a->spec, '/')) retcode = daemon_check_mask(a->spec, daemonIP); else if (strchr(a->spec, ':')) retcode = daemon_check_range(a->spec, daemonIP); else retcode = daemon_check_wildcard(a->spec, daemonIP); switch (retcode) { case DICT_DENY: return DICT_DENY; case DICT_MATCH: if (a->type == DICT_DENY) { daemon_log( DICT_LOG_AUTH, "spec %s denies %s/%s\n", a->spec, daemonHostname, daemonIP); } return a->type; } break; case DICT_USER: if (user && !strcmp(user,a->spec)) return DICT_ALLOW; case DICT_GROUP: /* Groups are not yet implemented. */ break; } } return DICT_DENY; } static int daemon_check_auth( const char *user ) { lst_Position p; lst_List dbl = DictConfig->dbl; dictDatabase *db; switch (daemon_check_list( user, DictConfig->acl )) { default: case DICT_DENY: return 1; case DICT_AUTHONLY: if (!user) return 0; case DICT_ALLOW: for (p = lst_init_position(dbl); p; p = lst_next_position(p)) { db = lst_get_position(p); switch (daemon_check_list(user, db->acl)) { case DICT_ALLOW: db->available = 1; continue; default: db->available = 0; continue; } } break; } return 0; } void daemon_terminate( int sig, const char *name ) { alarm(0); tim_stop( "t" ); close(daemonS_in); close(daemonS_out); if (name) { daemon_log( DICT_LOG_TERM, "%s: d/m/c = %d/%d/%d; %sr %su %ss\n", name, _dict_defines, _dict_matches, _dict_comparisons, dict_format_time( tim_get_real( "t" ) ), dict_format_time( tim_get_user( "t" ) ), dict_format_time( tim_get_system( "t" ) ) ); } else { daemon_log( DICT_LOG_TERM, "signal %d: d/m/c = %d/%d/%d; %sr %su %ss\n", sig, _dict_defines, _dict_matches, _dict_comparisons, dict_format_time( tim_get_real( "t" ) ), dict_format_time( tim_get_user( "t" ) ), dict_format_time( tim_get_system( "t" ) ) ); } log_close(); longjmp(env,1); if (sig) exit(sig+128); exit(0); } static void daemon_write( const char *buf, int len ) { int left = len; int count; while (left) { if ((count = write(daemonS_out, buf, left)) != left) { if (count <= 0) { if (errno == EPIPE) { daemon_terminate( 0, "pipe" ); } #if HAVE_STRERROR log_info( ":E: writing %d of %d bytes:" " retval = %d, errno = %d (%s)\n", left, len, count, errno, strerror(errno) ); #else log_info( ":E: writing %d of %d bytes:" " retval = %d, errno = %d\n", left, len, count, errno ); #endif daemon_terminate( 0, __func__ ); } } left -= count; } } static void daemon_crlf( char *d, const char *s, int dot ) { int first = 1; while (*s) { if (*s == '\n') { *d++ = '\r'; *d++ = '\n'; first = 1; ++s; } else { if (dot && first && *s == '.' && s[1] == '\n') *d++ = '.'; /* double first dot on line */ first = 0; *d++ = *s++; } } if (dot) { /* add final . */ if (!first){ *d++ = '\r'; *d++ = '\n'; } *d++ = '.'; *d++ = '\r'; *d++ = '\n'; } *d = '\0'; } static void daemon_printf( const char *format, ... ) { va_list ap; char buf[BUFFERSIZE]; char *pt; int len; va_start( ap, format ); vsnprintf( buf, sizeof (buf), format, ap ); va_end( ap ); if ((len = strlen( buf )) >= BUFFERSIZE) { log_info( ":E: buffer overflow: %d\n", len ); daemon_terminate( 0, __func__ ); } pt = alloca(2*len + 10); /* +10 for the case when buf == "\n"*/ daemon_crlf(pt, buf, 0); daemon_write(pt, strlen(pt)); } static void daemon_mime( void ) { if (daemonMime) daemon_write( "\r\n", 2 ); } static void daemon_mime_definition (const dictDatabase *db) { if (daemonMime){ if (db -> mime_header){ daemon_printf ("%s", db -> mime_header); } daemon_write ("\r\n", 2); } } static void daemon_text( const char *text, int dot ) { char *pt = alloca( 2*strlen(text) + 10 ); daemon_crlf(pt, text, dot); daemon_write(pt, strlen(pt)); } static int daemon_read( char *buf, int count ) { return net_read( daemonS_in, buf, count ); } static void daemon_ok( int code, const char *string, const char *timer ) { static int lastDefines = 0; static int lastMatches = 0; static int lastComparisons = 0; if (code == CODE_STATUS) { lastDefines = 0; lastMatches = 0; lastComparisons = 0; } if (!timer) { daemon_printf("%d %s\n", code, string); } else { tim_stop( timer ); daemon_printf("%d %s [d/m/c = %d/%d/%d; %sr %su %ss]\n", code, string, _dict_defines - lastDefines, _dict_matches - lastMatches, _dict_comparisons - lastComparisons, dict_format_time( tim_get_real( timer ) ), dict_format_time( tim_get_user( timer ) ), dict_format_time( tim_get_system( timer ) ) ); } lastDefines = _dict_defines; lastMatches = _dict_matches; lastComparisons = _dict_comparisons; } static int daemon_count_defs( lst_List list ) { lst_Position p; dictWord *dw; unsigned long previousStart = 0; unsigned long previousEnd = 0; const char *previousDef = NULL; int count = 0; LST_ITERATE(list,p,dw) { if ( previousStart == dw->start && previousEnd == dw->end && previousDef == dw->def) { continue; } previousStart = dw->start; previousEnd = dw->end; previousDef = dw->def; ++count; } return count; } static void daemon_dump_defs( lst_List list ) { lst_Position p; char *buf; dictWord *dw; const dictDatabase *db = NULL; const dictDatabase *db_visible = NULL; unsigned long previousStart = 0; unsigned long previousEnd = 0; const char * previousDef = NULL; int count; LST_ITERATE(list,p,dw) { db = dw->database; if ( previousStart == dw->start && previousEnd == dw->end && previousDef == dw->def) { continue; } previousStart = dw->start; previousEnd = dw->end; previousDef = dw->def; buf = dict_data_obtain ( db, dw ); if (dw -> database_visible){ db_visible = dw -> database_visible; }else{ db_visible = db; } daemon_printf ( "%d \"%s\" %s \"%s\"\n", CODE_DEFINITION_FOLLOWS, dw->word, db_visible -> invisible ? "*" : db_visible -> databaseName, db_visible -> invisible ? "" : db_visible -> databaseShort); daemon_mime_definition (db); if (db->filter){ count = strlen(buf); daemon_log( DICT_LOG_AUTH, "filtering with: %s\ncount: %d\n", db->filter, count ); dict_data_filter(buf, &count, strlen (buf), db->filter); buf[count] = '\0'; } daemon_text(buf, 1); xfree( buf ); } } static int daemon_count_matches( lst_List list ) { lst_Position p; dictWord *dw; const char *prevword = NULL; const dictDatabase *prevdb = NULL; int count = 0; LST_ITERATE(list,p,dw) { if (prevdb == dw->database && prevword && !strcmp(prevword,dw->word)) continue; prevword = dw->word; prevdb = dw->database; ++count; } return count; } static void daemon_dump_matches( lst_List list ) { lst_Position p; dictWord *dw; const char *prevword = NULL; const dictDatabase *prevdb = NULL; const dictDatabase *db = NULL; daemon_mime(); LST_ITERATE(list,p,dw) { db = dw -> database; if (prevdb == dw->database && prevword && !strcmp(prevword,dw->word)) continue; prevword = dw->word; prevdb = dw->database; if (dw -> database_visible){ db = dw -> database_visible; } daemon_printf ( "%s \"%s\"\n", db -> invisible ? "*" : db -> databaseName, dw -> word ); } daemon_printf( ".\n" ); } static void daemon_banner( void ) { time_t t; time(&t); snprintf( daemonStamp, sizeof (daemonStamp), "<%d.%d.%lu@%s>", _dict_forks, (int) getpid(), (long unsigned)t, net_hostname() ); daemon_printf( "%d %s %s %s\n", CODE_HELLO, net_hostname(), dict_get_banner(0), daemonStamp ); } static void daemon_define( const char *cmdline, int argc, const char **argv ) { lst_List list = lst_create(); int matches = 0; const char *word; const char *databaseName; int extension = (argv[0][0] == 'd' && argv[0][1] == '\0'); int db_found = 0; if (extension) { switch (argc) { case 2: databaseName = "*"; word = argv[1]; break; case 3: databaseName = argv[1]; word = argv[2]; break; default: daemon_printf( "%d syntax error, illegal parameters\n", CODE_ILLEGAL_PARAM ); return; } } else if (argc == 3) { databaseName = argv[1]; word = argv[2]; } else { daemon_printf( "%d syntax error, illegal parameters\n", CODE_ILLEGAL_PARAM ); return; } matches = abs(dict_search_databases ( list, NULL, databaseName, word, DICT_STRAT_EXACT, &db_found)); if (db_found && matches > 0) { int actual_matches = daemon_count_defs( list ); _dict_defines += actual_matches; daemon_log( DICT_LOG_DEFINE, "%s \"%s\" %d\n", databaseName, word, actual_matches); daemon_printf( "%d %d definitions retrieved\n", CODE_DEFINITIONS_FOUND, actual_matches ); daemon_dump_defs( list ); daemon_ok( CODE_OK, "ok", "c" ); #ifdef USE_PLUGIN call_dictdb_free (DictConfig->dbl); #endif dict_destroy_list( list ); return; } if (!db_found) { #ifdef USE_PLUGIN call_dictdb_free (DictConfig->dbl); #endif dict_destroy_list( list ); daemon_printf( "%d invalid database, use SHOW DB for list\n", CODE_INVALID_DB ); return; } #ifdef USE_PLUGIN call_dictdb_free (DictConfig->dbl); #endif dict_destroy_list( list ); daemon_log( DICT_LOG_NOMATCH, "%s exact \"%s\"\n", databaseName, word ); daemon_ok( CODE_NO_MATCH, "no match", "c" ); } static void daemon_match( const char *cmdline, int argc, const char **argv ) { lst_List list = lst_create(); int matches = 0; const char *word; const char *databaseName; const char *strategy; int strategyNumber; int extension = (argv[0][0] == 'm' && argv[0][1] == '\0'); int db_found = 0; if (extension) { switch (argc) { case 2:databaseName = "*"; strategy = "."; word = argv[1]; break; case 3:databaseName = "*"; strategy = argv[1]; word = argv[2]; break; case 4:databaseName = argv[1]; strategy = argv[2]; word = argv[3]; break; default: daemon_printf( "%d syntax error, illegal parameters\n", CODE_ILLEGAL_PARAM ); return; } } else if (argc == 4) { databaseName = argv[1]; strategy = argv[2]; word = argv[3]; } else { daemon_printf( "%d syntax error, illegal parameters\n", CODE_ILLEGAL_PARAM ); return; } if ((strategyNumber = lookup_strategy(strategy)) < 0) { daemon_printf( "%d invalid strategy, use SHOW STRAT for a list\n", CODE_INVALID_STRATEGY ); return; } matches = abs(dict_search_databases ( list, NULL, databaseName, word, strategyNumber | DICT_MATCH_MASK, &db_found)); if (db_found && matches > 0) { int actual_matches = daemon_count_matches( list ); _dict_matches += actual_matches; daemon_log( DICT_LOG_MATCH, "%s %s \"%s\" %d\n", databaseName, strategy, word, actual_matches); daemon_printf( "%d %d matches found\n", CODE_MATCHES_FOUND, actual_matches ); daemon_dump_matches( list ); daemon_ok( CODE_OK, "ok", "c" ); #ifdef USE_PLUGIN call_dictdb_free (DictConfig->dbl); #endif dict_destroy_list( list ); return; } if (!db_found) { #ifdef USE_PLUGIN call_dictdb_free (DictConfig->dbl); #endif dict_destroy_list( list ); daemon_printf( "%d invalid database, use SHOW DB for list\n", CODE_INVALID_DB ); return; } #ifdef USE_PLUGIN call_dictdb_free (DictConfig->dbl); #endif dict_destroy_list( list ); daemon_log( DICT_LOG_NOMATCH, "%s %s \"%s\"\n", databaseName, strategy, word ); daemon_ok( CODE_NO_MATCH, "no match", "c" ); } static lst_Position first_database_pos (void) { return lst_init_position (DictConfig->dbl); } static dictDatabase *next_database ( lst_Position *databasePosition, const char *name) { dictDatabase *db = NULL; assert (databasePosition); if (!name) return NULL; if (*name == '*' || *name == '!') { if (*databasePosition) { do { db = lst_get_position( *databasePosition ); *databasePosition = lst_next_position( *databasePosition ); } while ( db && (!db->available || db->invisible)); } return db; } else { while (*databasePosition) { db = lst_get_position( *databasePosition ); *databasePosition = lst_next_position( *databasePosition ); if (db){ if ( !db -> invisible && db->available && !strcmp(db -> databaseName,name)) { return db; } }else{ return NULL; } } return NULL; } } static int count_databases( void ) { int count = 0; const dictDatabase *db; lst_Position databasePosition = first_database_pos (); while (NULL != (db = next_database (&databasePosition, "*"))){ assert (!db -> invisible); if (!db -> exit_db) ++count; } return count; } static void destroy_word_list (lst_List l) { char *word; while (lst_length (l)){ word = lst_pop (l); if (word) xfree (word); } lst_destroy (l); } /* Search for all words in word_list in the database db */ static int dict_search_words ( lst_List *l, lst_List word_list, const dictDatabase *db, int strategy, int *error, int *result, const dictPluginData **extra_result, int *extra_result_size) { lst_Position word_list_pos; int mc = 0; int matches_count = 0; const char *word; word_list_pos = lst_init_position (word_list); while (word_list_pos){ word = lst_get_position (word_list_pos); if (word){ matches_count = dict_search ( l, word, db, strategy, daemonMime, result, extra_result, extra_result_size); if (*result == DICT_PLUGIN_RESULT_PREPROCESS){ assert (matches_count > 0); xfree (lst_get_position (word_list_pos)); lst_set_position (word_list_pos, NULL); } if (matches_count < 0){ *error = 1; matches_count = abs (matches_count); mc += matches_count; break; } mc += matches_count; } word_list_pos = lst_next_position (word_list_pos); } return mc; } int dict_search_databases ( lst_List *l, lst_Position databasePosition, /* NULL for global database list */ const char *databaseName, const char *word, int strategy, int *db_found) { int matches = -1; int matches_count = 0; int error = 0; const dictDatabase *db; dictWord *dw; char *p; lst_List preprocessed_words; int i; int result; const dictPluginData *extra_result; int extra_result_size; *db_found = 0; if (!databasePosition) databasePosition = first_database_pos (); preprocessed_words = lst_create (); lst_append (preprocessed_words, xstrdup(word)); while (!error && (db = next_database (&databasePosition, databaseName))) { if (db -> exit_db) /* dictionary_exit */ break; *db_found = 1; result = DICT_PLUGIN_RESULT_NOTFOUND; matches_count = dict_search_words ( l, preprocessed_words, db, strategy, &error, &result, &extra_result, &extra_result_size); if (matches < 0) matches = 0; if (result == DICT_PLUGIN_RESULT_PREPROCESS){ for (i=0; i < matches_count; ++i){ dw = lst_pop (l); switch (dw -> def_size){ case -1: p = xstrdup (dw -> word); lst_append (preprocessed_words, p); break; case 0: break; default: p = xmalloc (1 + dw -> def_size); memcpy (p, dw -> def, dw -> def_size); p [dw -> def_size] = 0; lst_append (preprocessed_words, p); } dict_destroy_datum (dw); } }else{ matches += matches_count; if (result == DICT_PLUGIN_RESULT_EXIT) break; if (*databaseName == '*') continue; else if (!matches && *databaseName == '!') continue; break; } } destroy_word_list (preprocessed_words); return error ? -matches : matches; } static void daemon_show_db( const char *cmdline, int argc, const char **argv ) { int count; const dictDatabase *db; lst_Position databasePosition; if (argc != 2) { daemon_printf( "%d syntax error, illegal parameters\n", CODE_ILLEGAL_PARAM ); return; } if (!(count = count_databases())) { daemon_printf( "%d no databases present\n", CODE_NO_DATABASES ); } else { daemon_printf( "%d %d databases present\n", CODE_DATABASE_LIST, count ); databasePosition = first_database_pos (); daemon_mime(); while ((db = next_database(&databasePosition, "*"))) { assert (!db->invisible); if (db -> exit_db) continue; daemon_printf( "%s \"%s\"\n", db->databaseName, db->databaseShort ); } daemon_printf( ".\n" ); daemon_ok( CODE_OK, "ok", NULL ); } } static void daemon_show_strat( const char *cmdline, int argc, const char **argv ) { int i; int strat_count = get_strategy_count (); dictStrategy const * const * strats = get_strategies (); if (argc != 2) { daemon_printf( "%d syntax error, illegal parameters\n", CODE_ILLEGAL_PARAM ); return; } if (strat_count){ daemon_printf( "%d %d strategies present\n", CODE_STRATEGY_LIST, strat_count ); daemon_mime(); for (i = 0; i < strat_count; i++) { daemon_printf( "%s \"%s\"\n", strats [i] -> name, strats [i] -> description ); } daemon_printf( ".\n" ); daemon_ok( CODE_OK, "ok", NULL ); }else{ daemon_printf( "%d no strategies available\n", CODE_NO_STRATEGIES ); } } void daemon_show_info( const char *cmdline, int argc, const char **argv ) { char *buf=NULL; dictWord *dw; const dictDatabase *db; lst_List list; const char *info_entry_name = DICT_INFO_ENTRY_NAME; lst_Position databasePosition = first_database_pos (); if (argc != 3) { daemon_printf( "%d syntax error, illegal parameters\n", CODE_ILLEGAL_PARAM ); return; } if ((argv[2][0] == '*' || argv[2][0] == '!') && argv[2][1] == '\0') { daemon_printf( "%d invalid database, use SHOW DB for list\n", CODE_INVALID_DB ); return; } list = lst_create(); while ((db = next_database(&databasePosition, argv[2]))) { if (db -> databaseInfo && db -> databaseInfo [0] != '@'){ daemon_printf( "%d information for %s\n", CODE_DATABASE_INFO, argv[2] ); daemon_mime(); daemon_text(db -> databaseInfo, 1); daemon_ok( CODE_OK, "ok", NULL ); return; } if (db -> databaseInfo && db -> databaseInfo [0] == '@') info_entry_name = db -> databaseInfo + 1; if (dict_search ( list, info_entry_name, db, DICT_STRAT_EXACT, 0, NULL, NULL, NULL)) { int i=1; int list_size = lst_length (list); daemon_printf( "%d information for %s\n", CODE_DATABASE_INFO, argv[2] ); daemon_mime(); if (db -> virtual_db){ daemon_printf ("The virtual dictionary `%s' includes the following:\n\n", db -> databaseName); } for (i=1; i <= list_size; ++i){ dw = lst_nth_get( list, i ); daemon_printf ("============ %s ============\n", dw -> database -> databaseName); buf = dict_data_obtain( dw -> database, dw ); #ifdef USE_PLUGIN call_dictdb_free (DictConfig->dbl); #endif if (buf) daemon_text (buf, 0); } daemon_text ("\n", 1); daemon_ok( CODE_OK, "ok", NULL ); dict_destroy_list (list); return; } else { #ifdef USE_PLUGIN call_dictdb_free (DictConfig->dbl); #endif dict_destroy_list( list ); daemon_printf( "%d information for %s\n", CODE_DATABASE_INFO, argv[2] ); daemon_mime(); daemon_text( "No information available\n" , 1); daemon_ok( CODE_OK, "ok", NULL ); return; } } dict_destroy_list( list ); daemon_printf( "%d invalid database, use SHOW DB for list\n", CODE_INVALID_DB ); } static int daemon_get_max_dbname_length () { size_t max_len = 0; size_t curr_len = 0; const dictDatabase *db; lst_Position databasePosition = first_database_pos (); while (NULL != (db = next_database (&databasePosition, "*"))){ assert (!db -> invisible); if (db -> databaseName){ curr_len = strlen (db -> databaseName); if (curr_len > max_len){ max_len = curr_len; } } } return (int) max_len; } static void daemon_show_server ( const char *cmdline, int argc, const char **argv) { FILE *str; char buffer[1024]; const dictDatabase *db; double uptime; int headwords; int index_size; char index_size_uom; int data_size; char data_size_uom; int data_length; char data_length_uom; int max_dbname_len; lst_Position databasePosition = first_database_pos (); daemon_printf( "%d server information\n", CODE_SERVER_INFO ); daemon_mime(); /* banner: dictd and OS */ if (!site_info_no_banner){ daemon_printf( "%s\n", dict_get_banner(0) ); } /* uptime and forks */ if (!site_info_no_uptime && !inetd){ tim_stop("dictd"); uptime = tim_get_real("dictd"); daemon_printf ( "On %s: up %s, %d fork%s (%0.1f/hour)\n", net_hostname(), dict_format_time( uptime ), _dict_forks, _dict_forks > 1 ? "s" : "", (_dict_forks/uptime)*3600.0 ); daemon_printf ("\n"); } if (!site_info_no_dblist && count_databases()) { daemon_printf( "Database Headwords Index Data Uncompressed\n" ); databasePosition = first_database_pos (); while (db = next_database (&databasePosition, "*"), db != NULL) { headwords = (db->index ? db->index->headwords : 0); index_size = 0; index_size_uom = 'k'; data_size = 0; data_size_uom = 'k'; data_length = 0; data_length_uom= 'k'; max_dbname_len = 0; assert (!db -> invisible); if (db->index){ index_size = db->index->size/1024 > 10240 ? db->index->size/1024/1024 : db->index->size/1024; index_size_uom = db->index->size/1024 > 10240 ? 'M' : 'k'; } if (db->data){ data_size = db->data->size/1024 > 10240 ? db->data->size/1024/1024 : db->data->size/1024; data_size_uom = db->data->size/1024 > 10240 ? 'M' : 'k'; data_length = db->data->length/1024 > 10240 ? db->data->length/1024/1024 : db->data->length/1024; data_length_uom = db->data->length/1024 > 10240 ? 'M' : 'k'; } max_dbname_len = daemon_get_max_dbname_length (); daemon_printf( "%-*.*s %10i %10i %cB %10i %cB %10i %cB\n", max_dbname_len, max_dbname_len, db->databaseName, headwords, index_size, index_size_uom, data_size, data_size_uom, data_length, data_length_uom); } daemon_printf ("\n"); } if (site_info && (str = fopen( site_info, "r" ))) { while ((fgets( buffer, 1000, str ))) daemon_printf( "%s", buffer ); fclose( str ); } daemon_printf( ".\n" ); daemon_ok( CODE_OK, "ok", NULL ); } static void daemon_show( const char *cmdline, int argc, const char **argv ) { daemon_printf( "%d syntax error, illegal parameters\n", CODE_ILLEGAL_PARAM ); } static void daemon_option_mime( const char *cmdline, int argc, const char **argv ) { ++daemonMime; daemon_ok( CODE_OK, "ok - using MIME headers", NULL ); } static void daemon_option( const char *cmdline, int argc, const char **argv ) { daemon_printf( "%d syntax error, illegal parameters\n", CODE_ILLEGAL_PARAM ); } static void daemon_client( const char *cmdline, int argc, const char **argv ) { const char *pt = strchr( cmdline, ' ' ); if (pt) daemon_log( DICT_LOG_CLIENT, "%.200s\n", pt + 1 ); else daemon_log( DICT_LOG_CLIENT, "%.200s\n", cmdline ); daemon_ok( CODE_OK, "ok", NULL ); } static void daemon_auth( const char *cmdline, int argc, const char **argv ) { char *buf; hsh_HashTable h = DictConfig->usl; const char *secret; struct MD5Context ctx; unsigned char digest[16]; char hex[33]; int i; int buf_size; if (argc != 3) daemon_printf( "%d syntax error, illegal parameters\n", CODE_ILLEGAL_PARAM ); if (!h || !(secret = hsh_retrieve(h, argv[1]))) { daemon_log( DICT_LOG_AUTH, "%s@%s/%s denied: invalid username\n", argv[1], daemonHostname, daemonIP ); daemon_printf( "%d auth denied\n", CODE_AUTH_DENIED ); return; } buf_size = strlen(daemonStamp) + strlen(secret) + 10; buf = alloca(buf_size); snprintf( buf, buf_size, "%s%s", daemonStamp, secret ); MD5Init(&ctx); MD5Update(&ctx, (const unsigned char *) buf, strlen(buf)); MD5Final(digest, &ctx); for (i = 0; i < 16; i++) snprintf( hex+2*i, 3, "%02x", digest[i] ); hex[32] = '\0'; PRINTF(DBG_AUTH,("Got %s expected %s\n", argv[2], hex )); if (strcmp(hex,argv[2])) { daemon_log( DICT_LOG_AUTH, "%s@%s/%s denied: hash mismatch\n", argv[1], daemonHostname, daemonIP ); daemon_printf( "%d auth denied\n", CODE_AUTH_DENIED ); } else { daemon_printf( "%d authenticated\n", CODE_AUTH_OK ); daemon_check_auth( argv[1] ); } } static void daemon_status( const char *cmdline, int argc, const char **argv ) { daemon_ok( CODE_STATUS, "status", "t" ); } static void daemon_help( const char *cmdline, int argc, const char **argv ) { daemon_printf( "%d help text follows\n", CODE_HELP ); daemon_mime(); daemon_text( "DEFINE database word -- look up word in database\n" "MATCH database strategy word -- match word in database using strategy\n" "SHOW DB -- list all accessible databases\n" "SHOW DATABASES -- list all accessible databases\n" "SHOW STRAT -- list available matching strategies\n" "SHOW STRATEGIES -- list available matching strategies\n" "SHOW INFO database -- provide information about the database\n" "SHOW SERVER -- provide site-specific information\n" "OPTION MIME -- use MIME headers\n" "CLIENT info -- identify client to server\n" "AUTH user string -- provide authentication information\n" "STATUS -- display timing information\n" "HELP -- display this help information\n" "QUIT -- terminate connection\n\n" "The following commands are unofficial server extensions for debugging\n" "only. You may find them useful if you are using telnet as a client.\n" "If you are writing a client, you MUST NOT use these commands, since\n" "they won't be supported on any other server!\n\n" "D word -- DEFINE * word\n" "D database word -- DEFINE database word\n" "M word -- MATCH * . word\n" "M strategy word -- MATCH * strategy word\n" "M database strategy word -- MATCH database strategy word\n" "S -- STATUS\n" "H -- HELP\n" "Q -- QUIT\n" , 1); daemon_ok( CODE_OK, "ok", NULL ); } static void daemon_quit( const char *cmdline, int argc, const char **argv ) { daemon_ok( CODE_GOODBYE, "bye", "t" ); daemon_terminate( 0, "quit" ); } /* The whole sub should be moved here, but I want to keep the diff small. */ int _handleconn (int error); int dict_inetd (int error) { if (setjmp(env)) return 0; daemonPort = -1; daemonIP = "inetd"; daemonHostname = daemonIP; daemonS_in = 0; daemonS_out = 1; return _handleconn (error); } int dict_daemon( int s, struct sockaddr_in *csin, int error ) { struct hostent *h; if (setjmp(env)) return 0; daemonPort = ntohs(csin->sin_port); daemonIP = str_find( inet_ntoa(csin->sin_addr) ); if ((h = gethostbyaddr((void *)&csin->sin_addr, sizeof(csin->sin_addr), csin->sin_family))) { daemonHostname = str_find( h->h_name ); } else daemonHostname = daemonIP; daemonS_in = s; daemonS_out = s; return _handleconn (error); } int _handleconn (int error) { int query_count = 0; char buf[4096]; int count; arg_List cmdline; int argc; char **argv; void (*command)(const char *, int, const char **); _dict_defines = 0; _dict_matches = 0; _dict_comparisons = 0; tim_start( "t" ); daemon_log( DICT_LOG_TRACE, "connected\n" ); daemon_log( DICT_LOG_CONNECT, "%s/%s connected on port %d\n", daemonHostname, daemonIP, daemonPort ); dict_setproctitle( "dictd: %s connected", daemonHostname ); if (error) { daemon_printf( "%d server temporarily unavailable\n", CODE_TEMPORARILY_UNAVAILABLE ); daemon_terminate( 0, "temporarily unavailable" ); } if (daemon_check_auth( NULL )) { daemon_log( DICT_LOG_AUTH, "%s/%s denied: ip/hostname rules\n", daemonHostname, daemonIP ); daemon_printf( "%d access denied\n", CODE_ACCESS_DENIED ); daemon_terminate( 0, "access denied" ); } daemon_banner(); if (!_dict_daemon_limit_time) alarm (client_delay); while (count = daemon_read( buf, 4000 ), count >= 0) { ++query_count; if (_dict_daemon_limit_queries && query_count >= _dict_daemon_limit_queries) { daemon_terminate (0, "query limit"); } if (stdin2stdout_mode){ daemon_printf( "# %s\n", buf ); } if (!_dict_daemon_limit_time) alarm(0); tim_start( "c" ); if (!count) { #if 0 daemon_ok( CODE_OK, "ok", "c" ); #endif continue; } daemon_log( DICT_LOG_COMMAND, "%.80s\n", buf ); cmdline = arg_argify(buf,0); arg_get_vector( cmdline, &argc, &argv ); if ((command = lookup_command (argc, (const char **) argv))) { command(buf, argc, (const char **) argv); } else { daemon_printf( "%d unknown command\n", CODE_SYNTAX_ERROR ); } arg_destroy(cmdline); if (!_dict_daemon_limit_time) alarm (client_delay); } #if 0 printf( "%d %d\n", count, errno ); #endif daemon_terminate( 0, "close" ); return 0; } dictd-1.12.1+dfsg.orig/daemon3.c0000644000000000000000000000251210735444232014735 0ustar rootroot#include #include #include #include #include "dictd.h" int daemon (int nochdir, int noclose) { int i; int fd; switch (fork()) { case -1: err_fatal_errno( __func__, "Cannot fork\n" ); break; case 0: break; /* child */ default: exit(0); /* parent */ } /* The detach algorithm is a modification of that presented by Comer, Douglas E. and Stevens, David L. INTERNETWORKING WITH TCP/IP, VOLUME III: CLIENT-SERVER PROGRAMMING AND APPLICATIONS (BSD SOCKET VERSION). Englewood Cliffs, New Jersey: Prentice Hall, 1993 (Chapter 27). */ if (!noclose) for (i=getdtablesize()-1; i >= 0; --i) close(i); /* close everything */ #if defined(__hpux__) || defined(__CYGWIN__) || defined(__INTERIX) || defined(__OPENNT) #ifndef TIOCNOTTY #define NO_IOCTL_TIOCNOTTY #endif /* TIOCNOTTY */ #endif /* strange platforms */ #ifndef NO_IOCTL_TIOCNOTTY if ((fd = open("/dev/tty", O_RDWR)) >= 0) { /* detach from controlling tty */ ioctl(fd, TIOCNOTTY, 0); close(fd); } #endif if (!nochdir) chdir("/"); /* cd to safe directory */ setpgid(0,getpid()); /* Get process group */ if (!noclose){ fd = open("/dev/null", O_RDWR); /* stdin */ dup(fd); /* stdout */ dup(fd); /* stderr */ } } dictd-1.12.1+dfsg.orig/data.c0000644000000000000000000003403311512103042014304 0ustar rootroot/* data.c -- * Created: Tue Jul 16 12:45:41 1996 by faith@dict.org * Copyright 1996, 1997, 1998, 2000, 2002 Rickard E. Faith (faith@dict.org) * Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) * * 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 1, 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. */ #include "dictP.h" #include "data.h" #include "dictzip.h" #include #ifdef HAVE_MMAP #include #endif #include #include #include #ifdef HAVE_MMAP #include #endif #include #define USE_CACHE 1 #ifdef HAVE_MMAP int mmap_mode = 1; /* dictd uses mmap() function (the default) */ #else int mmap_mode = 0; #endif int dict_data_filter( char *buffer, int *len, int maxLength, const char *filter ) { char *outBuffer; int outLen; if (!filter) return 0; outBuffer = xmalloc( maxLength + 2 ); outLen = pr_filter( filter, buffer, *len, outBuffer, maxLength + 1 ); if (outLen > maxLength ) err_fatal( __func__, "Filter grew buffer from %d past limit of %d\n", *len, maxLength ); memcpy( buffer, outBuffer, outLen ); xfree( outBuffer ); PRINTF(DBG_UNZIP|DBG_ZIP,("Length was %d, now is %d\n",*len,outLen)); *len = outLen; return 0; } static int dict_read_header( const char *filename, dictData *header, int computeCRC ) { FILE *str; int id1, id2, si1, si2; char buffer[BUFFERSIZE]; int extraLength, subLength; int i; char *pt; int c; struct stat sb; unsigned long crc = crc32( 0L, Z_NULL, 0 ); int count; unsigned long offset; if (!(str = fopen( filename, "r" ))) err_fatal_errno( __func__, "Cannot open data file \"%s\" for read\n", filename ); header->filename = str_find( filename ); header->headerLength = GZ_XLEN - 1; header->type = DICT_UNKNOWN; id1 = getc( str ); id2 = getc( str ); if (id1 != GZ_MAGIC1 || id2 != GZ_MAGIC2) { header->type = DICT_TEXT; fstat( fileno( str ), &sb ); header->compressedLength = header->length = sb.st_size; header->origFilename = str_find( filename ); header->mtime = sb.st_mtime; if (computeCRC) { rewind( str ); while (!feof( str )) { if ((count = fread( buffer, 1, BUFFERSIZE, str ))) { crc = crc32( crc, (Bytef *) buffer, count ); } } } header->crc = crc; fclose( str ); return 0; } header->type = DICT_GZIP; header->method = getc( str ); header->flags = getc( str ); header->mtime = getc( str ) << 0; header->mtime |= getc( str ) << 8; header->mtime |= getc( str ) << 16; header->mtime |= getc( str ) << 24; header->extraFlags = getc( str ); header->os = getc( str ); if (header->flags & GZ_FEXTRA) { extraLength = getc( str ) << 0; extraLength |= getc( str ) << 8; header->headerLength += extraLength + 2; si1 = getc( str ); si2 = getc( str ); if (si1 == GZ_RND_S1 && si2 == GZ_RND_S2) { subLength = getc( str ) << 0; subLength |= getc( str ) << 8; header->version = getc( str ) << 0; header->version |= getc( str ) << 8; if (header->version != 1) err_internal( __func__, "dzip header version %d not supported\n", header->version ); header->chunkLength = getc( str ) << 0; header->chunkLength |= getc( str ) << 8; header->chunkCount = getc( str ) << 0; header->chunkCount |= getc( str ) << 8; if (header->chunkCount <= 0) { fclose( str ); return 5; } header->chunks = xmalloc( sizeof( header->chunks[0] ) * header->chunkCount ); for (i = 0; i < header->chunkCount; i++) { header->chunks[i] = getc( str ) << 0; header->chunks[i] |= getc( str ) << 8; } header->type = DICT_DZIP; } else { fseek( str, header->headerLength, SEEK_SET ); } } if (header->flags & GZ_FNAME) { /* FIXME! Add checking against header len */ pt = buffer; while ((c = getc( str )) && c != EOF){ *pt++ = c; if (pt == buffer + sizeof (buffer)){ err_fatal ( __func__, "too long FNAME field in dzip file \"%s\"\n", filename); } } *pt = '\0'; header->origFilename = str_find( buffer ); header->headerLength += strlen( header->origFilename ) + 1; } else { header->origFilename = NULL; } if (header->flags & GZ_COMMENT) { /* FIXME! Add checking for header len */ pt = buffer; while ((c = getc( str )) && c != EOF){ *pt++ = c; if (pt == buffer + sizeof (buffer)){ err_fatal ( __func__, "too long COMMENT field in dzip file \"%s\"\n", filename); } } *pt = '\0'; header->comment = str_find( buffer ); header->headerLength += strlen( header->comment ) + 1; } else { header->comment = NULL; } if (header->flags & GZ_FHCRC) { getc( str ); getc( str ); header->headerLength += 2; } if (ftell( str ) != header->headerLength + 1) err_internal( __func__, "File position (%lu) != header length + 1 (%d)\n", ftell( str ), header->headerLength + 1 ); fseek( str, -8, SEEK_END ); header->crc = getc( str ) << 0; header->crc |= getc( str ) << 8; header->crc |= getc( str ) << 16; header->crc |= getc( str ) << 24; header->length = getc( str ) << 0; header->length |= getc( str ) << 8; header->length |= getc( str ) << 16; header->length |= getc( str ) << 24; header->compressedLength = ftell( str ); /* Compute offsets */ header->offsets = xmalloc( sizeof( header->offsets[0] ) * header->chunkCount ); for (offset = header->headerLength + 1, i = 0; i < header->chunkCount; i++) { header->offsets[i] = offset; offset += header->chunks[i]; } fclose( str ); return 0; } dictData *dict_data_open( const char *filename, int computeCRC ) { dictData *h = NULL; struct stat sb; int j; if (!filename) return NULL; h = xmalloc( sizeof( struct dictData ) ); memset( h, 0, sizeof( struct dictData ) ); h->initialized = 0; if (stat( filename, &sb ) || !S_ISREG(sb.st_mode)) { err_warning( __func__, "%s is not a regular file -- ignoring\n", filename ); return h; } if (dict_read_header( filename, h, computeCRC )) { err_fatal( __func__, "\"%s\" not in text or dzip format\n", filename ); } if ((h->fd = open( filename, O_RDONLY )) < 0) err_fatal_errno( __func__, "Cannot open data file \"%s\"\n", filename ); if (fstat( h->fd, &sb )) err_fatal_errno( __func__, "Cannot stat data file \"%s\"\n", filename ); h->size = sb.st_size; if (mmap_mode){ #ifdef HAVE_MMAP h->start = mmap( NULL, h->size, PROT_READ, MAP_SHARED, h->fd, 0 ); if ((void *)h->start == (void *)(-1)) err_fatal_errno( __func__, "Cannot mmap data file \"%s\"\n", filename ); #else err_fatal (__func__, "This should not happen"); #endif }else{ h->start = xmalloc (h->size); if (-1 == read (h->fd, (char *) h->start, h->size)) err_fatal_errno ( __func__, "Cannot read data file \"%s\"\n", filename ); close (h -> fd); h -> fd = 0; } h->end = h->start + h->size; for (j = 0; j < DICT_CACHE_SIZE; j++) { h->cache[j].chunk = -1; h->cache[j].stamp = -1; h->cache[j].inBuffer = NULL; h->cache[j].count = 0; } return h; } void dict_data_close( dictData *header ) { int i; if (!header) return; if (header->fd >= 0) { if (mmap_mode){ #ifdef HAVE_MMAP munmap( (void *)header->start, header->size ); close( header->fd ); header->fd = 0; header->start = header->end = NULL; #else err_fatal (__func__, "This should not happen"); #endif }else{ if (header -> start) xfree ((char *) header -> start); } } if (header->chunks) xfree( header->chunks ); if (header->offsets) xfree( header->offsets ); if (header->initialized) { if (inflateEnd( &header->zStream )) err_internal( __func__, "Cannot shut down inflation engine: %s\n", header->zStream.msg ); } for (i = 0; i < DICT_CACHE_SIZE; ++i){ if (header -> cache [i].inBuffer) xfree (header -> cache [i].inBuffer); } memset( header, 0, sizeof( struct dictData ) ); xfree( header ); } char *dict_data_obtain (const dictDatabase *db, const dictWord *dw) { char *word_copy; int len; if (!dw || !db) return NULL; if (dw -> def){ if (-1 == dw -> def_size){ len = strlen (dw -> def); }else{ len = dw -> def_size; } word_copy = xmalloc (2 + len); memcpy (word_copy, dw -> def, len); word_copy [len + 0] = '\n'; word_copy [len + 1] = 0; return word_copy; }else{ assert (db); assert (db -> data); return dict_data_read_ ( db -> data, dw -> start, dw -> end, db->prefilter, db->postfilter); } } char *dict_data_read_ ( dictData *h, unsigned long start, unsigned long size, const char *preFilter, const char *postFilter ) { char *buffer, *pt; unsigned long end; int count; char *inBuffer; char outBuffer[OUT_BUFFER_SIZE]; int firstChunk, lastChunk; int firstOffset, lastOffset; int i, j; int found, target, lastStamp; static int stamp = 0; end = start + size; buffer = xmalloc( size + 1 ); PRINTF(DBG_UNZIP, ("dict_data_read( %p, %lu, %lu, %s, %s )\n", h, start, size, preFilter, postFilter )); assert( h != NULL); switch (h->type) { case DICT_GZIP: err_fatal( __func__, "Cannot seek on pure gzip format files.\n" "Use plain text (for performance)" " or dzip format (for space savings).\n" ); break; case DICT_TEXT: memcpy( buffer, h->start + start, size ); buffer[size] = '\0'; break; case DICT_DZIP: if (!h->initialized) { ++h->initialized; h->zStream.zalloc = NULL; h->zStream.zfree = NULL; h->zStream.opaque = NULL; h->zStream.next_in = 0; h->zStream.avail_in = 0; h->zStream.next_out = NULL; h->zStream.avail_out = 0; if (inflateInit2( &h->zStream, -15 ) != Z_OK) err_internal( __func__, "Cannot initialize inflation engine: %s\n", h->zStream.msg ); } firstChunk = start / h->chunkLength; firstOffset = start - firstChunk * h->chunkLength; lastChunk = (end - 1) / h->chunkLength; if (lastChunk < firstChunk) { lastChunk = firstChunk; } lastOffset = end - lastChunk * h->chunkLength; PRINTF(DBG_UNZIP, (" start = %lu, end = %lu\n" "firstChunk = %d, firstOffset = %d," " lastChunk = %d, lastOffset = %d\n", start, end, firstChunk, firstOffset, lastChunk, lastOffset )); for (pt = buffer, i = firstChunk; i <= lastChunk; i++) { /* Access cache */ found = 0; target = 0; lastStamp = INT_MAX; for (j = 0; j < DICT_CACHE_SIZE; j++) { #if USE_CACHE if (h->cache[j].chunk == i) { found = 1; target = j; break; } #endif if (h->cache[j].stamp < lastStamp) { lastStamp = h->cache[j].stamp; target = j; } } h->cache[target].stamp = ++stamp; if (found) { count = h->cache[target].count; inBuffer = h->cache[target].inBuffer; } else { h->cache[target].chunk = i; if (!h->cache[target].inBuffer) h->cache[target].inBuffer = xmalloc( IN_BUFFER_SIZE ); inBuffer = h->cache[target].inBuffer; if (h->chunks[i] >= OUT_BUFFER_SIZE ) { err_internal( __func__, "h->chunks[%d] = %d >= %ld (OUT_BUFFER_SIZE)\n", i, h->chunks[i], OUT_BUFFER_SIZE ); } memcpy( outBuffer, h->start + h->offsets[i], h->chunks[i] ); dict_data_filter( outBuffer, &count, OUT_BUFFER_SIZE, preFilter ); h->zStream.next_in = (Bytef *) outBuffer; h->zStream.avail_in = h->chunks[i]; h->zStream.next_out = (Bytef *) inBuffer; h->zStream.avail_out = IN_BUFFER_SIZE; if (inflate( &h->zStream, Z_PARTIAL_FLUSH ) != Z_OK) err_fatal( __func__, "inflate: %s\n", h->zStream.msg ); if (h->zStream.avail_in) err_internal( __func__, "inflate did not flush (%d pending, %d avail)\n", h->zStream.avail_in, h->zStream.avail_out ); count = IN_BUFFER_SIZE - h->zStream.avail_out; dict_data_filter( inBuffer, &count, IN_BUFFER_SIZE, postFilter ); h->cache[target].count = count; } if (i == firstChunk) { if (i == lastChunk) { memcpy( pt, inBuffer + firstOffset, lastOffset-firstOffset); pt += lastOffset - firstOffset; } else { if (count != h->chunkLength ) err_internal( __func__, "Length = %d instead of %d\n", count, h->chunkLength ); memcpy( pt, inBuffer + firstOffset, h->chunkLength - firstOffset ); pt += h->chunkLength - firstOffset; } } else if (i == lastChunk) { memcpy( pt, inBuffer, lastOffset ); pt += lastOffset; } else { assert( count == h->chunkLength ); memcpy( pt, inBuffer, h->chunkLength ); pt += h->chunkLength; } } *pt = '\0'; break; case DICT_UNKNOWN: err_fatal( __func__, "Cannot read unknown file type\n" ); break; } return buffer; } dictd-1.12.1+dfsg.orig/data.h0000644000000000000000000000316610621356374014336 0ustar rootroot/* data.h -- * Created: Sat Mar 15 18:04:25 2003 by Aleksey Cheusov * Copyright 1994-2003 Rickard E. Faith (faith@dict.org) * * 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 1, 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. */ #ifndef _DATA_H_ #define _DATA_H_ #include "dictP.h" #include "defs.h" /* initialize .data file */ extern dictData *dict_data_open ( const char *filename, int computeCRC); /* */ extern void dict_data_close ( dictData *data); extern void dict_data_print_header( FILE *str, dictData *data ); extern int dict_data_zip( const char *inFilename, const char *outFilename, const char *preFilter, const char *postFilter ); extern char *dict_data_obtain ( const dictDatabase *db, const dictWord *dw); extern char *dict_data_read_ ( dictData *data, unsigned long start, unsigned long end, const char *preFilter, const char *postFilter ); extern int dict_data_filter( char *buffer, int *len, int maxLength, const char *filter ); extern int mmap_mode; #endif /* _DATA_H_ */ dictd-1.12.1+dfsg.orig/defs.h0000644000000000000000000002330210627073546014343 0ustar rootroot/* defs.h -- * Created: Sat Mar 15 17:27:23 2003 by Aleksey Cheusov * Copyright 1994-2003 Rickard E. Faith (faith@dict.org) * * 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 1, 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. */ #ifndef _DEFS_H_ #define _DEFS_H_ #include "dictP.h" #include "dictdplugin.h" #include #include /* Configurable things */ #define DICT_DEFAULT_SERVICE "2628" /* Also in dict.h */ #define DICTD_CONFIG_NAME "dictd.conf" #define DICT_QUEUE_DEPTH 10 #define DICT_DAEMON_LIMIT_CHILDS 100 /* maximum simultaneous daemons */ #define DICT_DAEMON_LIMIT_MATCHES 2000 /* maximum number of matches */ #define DICT_DAEMON_LIMIT_DEFS 200 /* maximum number of definitions */ #define DICT_DAEMON_LIMIT_TIME 600 /* maximum seconds per client */ #define DICT_DAEMON_LIMIT_QUERIES 2000 /* maximum queries per client */ #define DICT_DEFAULT_DELAY 0 /* 'limit_time' in work by default */ #define DICT_PERSISTENT_PRESTART 3 /* not implemented */ #define DICT_PERSISTENT_LIMIT 5 /* not implemented */ #define DICT_ENTRY_PREFIX "00-database" #define DICT_ENTRY_PREFIX_LEN sizeof(DICT_ENTRY_PREFIX)-1 #define DICT_SHORT_ENTRY_NAME DICT_ENTRY_PREFIX"-short" #define DICT_LONG_ENTRY_NAME DICT_ENTRY_PREFIX"-long" #define DICT_INFO_ENTRY_NAME DICT_ENTRY_PREFIX"-info" #define DICT_FLAG_UTF8 DICT_ENTRY_PREFIX"-utf8" #define DICT_FLAG_8BIT_NEW DICT_ENTRY_PREFIX"-8bit-new" #define DICT_FLAG_8BIT_OLD DICT_ENTRY_PREFIX"-8bit" #define DICT_FLAG_ALLCHARS DICT_ENTRY_PREFIX"-allchars" #define DICT_FLAG_CASESENSITIVE DICT_ENTRY_PREFIX"-case-sensitive" #define DICT_FLAG_VIRTUAL DICT_ENTRY_PREFIX"-virtual" #define DICT_FLAG_ALPHABET DICT_ENTRY_PREFIX"-alphabet" #define DICT_FLAG_DEFAULT_STRAT DICT_ENTRY_PREFIX"-default-strategy" #define DICT_FLAG_MIME_HEADER DICT_ENTRY_PREFIX"-mime-header" #define DICT_ENTRY_PLUGIN DICT_ENTRY_PREFIX"-plugin" #define DICT_ENTRY_PLUGIN_DATA DICT_ENTRY_PREFIX"-plugin-data" #define DICT_PLUGINFUN_OPEN "dictdb_open" #define DICT_PLUGINFUN_ERROR "dictdb_error" #define DICT_PLUGINFUN_FREE "dictdb_free" #define DICT_PLUGINFUN_SEARCH "dictdb_search" #define DICT_PLUGINFUN_CLOSE "dictdb_close" #define DICT_PLUGINFUN_SET "dictdb_set" /* End of configurable things */ #define BUFFERSIZE 10240 #define DBG_VERBOSE (0<<30|1<< 0) /* Verbose */ #define DBG_ZIP (0<<30|1<< 1) /* Zip */ #define DBG_UNZIP (0<<30|1<< 2) /* Unzip */ #define DBG_SEARCH (0<<30|1<< 3) /* Search */ #define DBG_SCAN (0<<30|1<< 4) /* Config file scan */ #define DBG_PARSE (0<<30|1<< 5) /* Config file parse */ #define DBG_INIT (0<<30|1<< 6) /* Database initialization */ #define DBG_PORT (0<<30|1<< 7) /* Log port number for connections */ #define DBG_LEV (0<<30|1<< 8) /* Levenshtein matching */ #define DBG_AUTH (0<<30|1<< 9) /* Debug authentication */ #define DBG_NODETACH (0<<30|1<<10) /* Don't detach as a background proc. */ #define DBG_NOFORK (0<<30|1<<11) /* Don't fork (single threaded) */ #define DBG_ALT (0<<30|1<<12) /* altcompare() */ #define LOG_SERVER (0<<30|1<< 0) /* Log server diagnostics */ #define LOG_CONNECT (0<<30|1<< 1) /* Log connection information */ #define LOG_STATS (0<<30|1<< 2) /* Log termination information */ #define LOG_COMMAND (0<<30|1<< 3) /* Log commands */ #define LOG_FOUND (0<<30|1<< 4) /* Log words found */ #define LOG_NOTFOUND (0<<30|1<< 5) /* Log words not found */ #define LOG_CLIENT (0<<30|1<< 6) /* Log client */ #define LOG_HOST (0<<30|1<< 7) /* Log remote host name */ #define LOG_TIMESTAMP (0<<30|1<< 8) /* Log with timestamps */ #define LOG_MIN (0<<30|1<< 9) /* Log a few minimal things */ #define LOG_AUTH (0<<30|1<<10) /* Log authentication denials */ #define DICT_LOG_TERM 0 #define DICT_LOG_DEFINE 1 #define DICT_LOG_MATCH 2 #define DICT_LOG_NOMATCH 3 #define DICT_LOG_CLIENT 4 #define DICT_LOG_TRACE 5 #define DICT_LOG_COMMAND 6 #define DICT_LOG_AUTH 7 #define DICT_LOG_CONNECT 8 #define DICT_UNKNOWN 0 #define DICT_TEXT 1 #define DICT_GZIP 2 #define DICT_DZIP 3 #define DICT_CACHE_SIZE 5 typedef struct dictCache { int chunk; char *inBuffer; int stamp; int count; } dictCache; typedef struct dictData { int fd; /* file descriptor */ const char *start; /* start of mmap'd area */ const char *end; /* end of mmap'd area */ unsigned long size; /* size of mmap */ int type; const char *filename; z_stream zStream; int initialized; int headerLength; int method; int flags; time_t mtime; int extraFlags; int os; int version; int chunkLength; int chunkCount; int *chunks; unsigned long *offsets; /* Sum-scan of chunks. */ const char *origFilename; const char *comment; unsigned long crc; unsigned long length; unsigned long compressedLength; dictCache cache[DICT_CACHE_SIZE]; } dictData; typedef struct dictPlugin { void * data; #ifdef USE_PLUGIN lt_dlhandle handle; dictdb_open_type dictdb_open; dictdb_set_type dictdb_set; dictdb_search_type dictdb_search; dictdb_free_type dictdb_free; dictdb_error_type dictdb_error; dictdb_close_type dictdb_close; char dictdb_free_called; /* 1 after dictdb_free call */ #endif } dictPlugin; typedef struct dictIndex { int fd; /* file descriptor */ const char *start; /* start of mmap'd area */ const char *end; /* end of mmap'd area */ unsigned long size; /* size of mmap */ const char *optStart[UCHAR_MAX+2]; /* Optimized starting points */ unsigned long headwords; /* computed number of headwords */ int flag_utf8; /* not zero if it has 00-database-utf8 entry*/ int flag_8bit; /* not zero if it has 00-database-8bit-new entry*/ int flag_allchars; /* not zero if it has 00-database-allchars entry*/ int flag_casesensitive;/* not zero if it has 00-database-case-sensitive entry*/ const int *isspacealnum; } dictIndex; typedef struct dictDatabase { const char *databaseName; const char *databaseShort; const char *databaseInfo; const char *dataFilename; const char *indexFilename; const char *indexsuffixFilename; const char *indexwordFilename; const char *filter; const char *prefilter; const char *postfilter; lst_List acl; int available; /* if user has authenticated for database */ dictData *data; dictIndex *index; dictIndex *index_suffix; dictIndex *index_word; int *strategy_disabled; /* disable_strategy keyword*/ lst_List *virtual_db_list; char *alphabet; int invisible; /* non-zero for invisible databases */ int exit_db; /* non-zero for dictionary_exit entry */ int virtual_db; /* non-zero for virtual databases */ int plugin_db; /* non-zero for plugin entry */ int normal_db; /* non-zero for normal database */ int mime_db; /* non-zero for MIME database */ int default_strategy; /* default search strategy for `.' */ const char *mime_header; /* MIME header for OPTION MIME command */ /* database_virtual members */ const char *database_list; /* comma-separated list of database names */ /* database_plugin members */ const char *pluginFilename; const char *plugin_data; /* data for initializing plugin */ dictPlugin *plugin; /* database_mime members */ const char *mime_mimeDbname; const char *mime_nomimeDbname; struct dictDatabase *mime_mimeDB; struct dictDatabase *mime_nomimeDB; } dictDatabase; #define DICT_DENY 0 #define DICT_ALLOW 1 #define DICT_AUTHONLY 2 #define DICT_USER 3 #define DICT_GROUP 4 /* Not implemented */ #define DICT_MATCH 5 /* For IP matching routines */ #define DICT_NOMATCH 6 /* For IP matching routines */ typedef struct dictAccess { int type; /* deny, allow, accessonly, user, group */ const char *spec; } dictAccess; typedef struct dictConfig { lst_List acl; /* type dictAccess */ lst_List dbl; /* type dictDatabase */ hsh_HashTable usl; /* username/shared-secret list */ } dictConfig; typedef struct dictWord { const dictDatabase *database; const dictDatabase *database_visible; char *word; unsigned long start; unsigned long end; /* Used by plugins */ const char *def; int def_size; } dictWord; typedef struct dictToken { const char *string; int integer; src_Type src; } dictToken; #endif /* _DEFS_H_ */ dictd-1.12.1+dfsg.orig/deps0000644000000000000000000000266010416024600014112 0ustar rootrootdictdplugin.o dictdplugin.os: dictdplugin.c dictdplugin.h dictdplugin_dbi.o dictdplugin_dbi.os: dictdplugin_dbi.c dictP.h dictdplugin.h str.h \ plugins_common.h heap.h dictdplugin_exit.o dictdplugin_exit.os: dictdplugin_exit.c dictdplugin.h dictdplugin_judy.o dictdplugin_judy.os: dictdplugin_judy.c dictP.h dictdplugin.h data.h \ defs.h str.h plugins_common.h heap.h lev.h dictdplugin_man.o dictdplugin_man.os: dictdplugin_man.c dictP.h dictdplugin.h str.h \ plugins_common.h heap.h dictfmt.o dictfmt.os: dictfmt.c dictP.h str.h getopt.o getopt.os: getopt.c getopt_long.o getopt_long.os: getopt_long.c getopt.c heap.o heap.os: heap.c dictP.h heap.h iswalnum.o iswalnum.os: iswalnum.c dictP.h iswspace.o iswspace.os: iswspace.c dictP.h mbrlen.o mbrlen.os: mbrlen.c dictP.h mbrtowc.o mbrtowc.os: mbrtowc.c dictP.h mbstowcs.o mbstowcs.os: mbstowcs.c dictP.h mbtowc.o mbtowc.os: mbtowc.c dictP.h md5.o md5.os: md5.c md5.h nl_langinfo.o nl_langinfo.os: nl_langinfo.c dictP.h plugins_common.o plugins_common.os: plugins_common.c dictP.h plugins_common.h snprintf.o snprintf.os: snprintf.c dictP.h str.o str.os: str.c dictP.h str.h strlcat.o strlcat.os: strlcat.c dictP.h strlcpy.o strlcpy.os: strlcpy.c dictP.h towlower.o towlower.os: towlower.c dictP.h vsnprintf.o vsnprintf.os: vsnprintf.c dictP.h wcrtomb.o wcrtomb.os: wcrtomb.c dictP.h wctomb.o wctomb.os: wctomb.c dictP.h dictdplugin_popen.o dictdplugin_popen.os: dictdplugin_popen.cpp dictdplugin.h dictd-1.12.1+dfsg.orig/dict.1.in0000644000000000000000000002344711116777275014701 0ustar rootroot.\" dict.1 -- .\" Created: Tue Jul 8 11:36:19 1997 by faith@acm.org .\" Copyright 1997, 1998, 1999, 2002 Rickard E. Faith (faith@acm.org) .\" Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .TH DICT 1 "15 February 1998" "" "" .SH NAME dict \- DICT Protocol Client .SH SYNOPSIS .nf .BI dict " word" .br .BI dict " [options] [word]" .br .BI dict " [options] dict://host:port/d:word:database" .br .BI dict " [options] dict://host:port/m:word:database:strategy" .fi .SH DESCRIPTION .B dict is a client for the Dictionary Server Protocol (DICT), a TCP transaction based query/response protocol that provides access to dictionary definitions from a set of natural language dictionary databases. Exit status is 0 if operation succeeded, or non-zero otherwise. .br See .B EXIT STATUS section. .SH OPTIONS .TP .BI \-h " server\fR or " \-\-host " server" Specifies the hostname for the DICT server. Server/port combinations can be specified in the configuration file. If no servers are specified in the configuration file or or on the command line, .B dict will fail. (This is a compile-time option, ./configure --enable-dictorg, which is disabled by default.) If IP lookup for a server expands to a list of IP addresses (as dict.org does currently), then each IP will be tried in the order listed. .TP .BI \-p " service\fR or " \-\-port " service" Specifies the port (e.g., 2628) or service (e.g., dict) for connections. The default is 2628, as specified in the DICT Protocol RFC. Server/port combinations can be specified in the configuration file. .TP .BI \-d " dbname\fR or " \-\-database " dbname" Specifies a specific database to search. The default is to search all databases (a "*" from the DICT protocol). Note that a "!" in the DICT protocol means to search all of the databases until a match is found, and then stop searching. .TP .BR \-m " or " \-\-match Instead of printing a definition, perform a match using the specified strategy. .TP .BI \-s " strategy\fR or " \-\-strategy " strategy" Specify a matching strategy. By default, the server default match strategy is used. This is usually "exact" for definitions, and some form of spelling-correction strategy for matches ("." from the DICT protocol). The available strategies are dependent on the server implementation. For a list of available strategies, see the \-S or \-\-strats option. .TP .BR \-C " or " \-\-nocorrect Usually, if a definition is requested and the word cannot be found, spelling correction is requested from the server, and a list of possible words are provided. This option disables the generation of this list. .TP .BI \-c " file\fR or " \-\-config " file" Specify the configuration file. The default is to try .I ~/.dictrc and .IR @SYSCONFDIR@/dict.conf , using the first file that exists. If a specific configuration file is specified, then the defaults will not be tried. .TP .BR \-D " or " \-\-dbs Query the server and display a list of available databases. .TP .BR \-S " or " \-\-strats Query the server and display a list of available search strategies. .TP .BR \-H " or " \-\-serverhelp Query the server and display the help information that it provides. .TP .BI \-i " dbname\fR or " \-\-info " dbname" Request information on the specified database (usually the server will provide origination, descriptive, or other information about the database or its contents). .TP .BR \-I " or " \-\-serverinfo Query the server and display information about the server. .TP .BR \-M " or " \-\-mime Send .I OPTION MIME command to the server. .RS .B NOTE: Server's capabilities are not checked. .RE .TP .BR \-f " or " \-\-formatted Enables formatted output, i.e. output convenient for postprocessing by standard UNIX utilities. No, it is not XML ;\-) Also error and warning messages like " No matches...", " Invalid strategy..." etc. are sent to stderr, not to stdout. .RS .B Format: \-I, \-i, \-H and similar: .br hostport .br line1 .br line2 .br ... \-S: .br hostportstrategy1short description1 .br hostportstrategy2short description2 .br ... \-D: .br hostportdatabase1database description1 .br hostportdatabase2database description2 .br ... .br \-m: .br hostportdatabase1match1 .br hostportdatabase2match2 .br ... .RE .TP .BR \-a " or " \-\-noauth Disable authentication (i.e., don't send an AUTH command). .TP .BI \-u " user\fR or " \-\-user " user" Specifies the username for authentication. .TP .BI \-k " key\fR or " \-\-key " key" Specifies the shared secret for authentication. .TP .BR \-V " or " \-\-version Display version information. .TP .BR \-L " or " \-\-license Display copyright and license information. .TP .B \-\-help Display help information. .TP .BR -v " or " \-\-verbose Be verbose. .TP .BR -r " or " \-\-raw Be very verbose: show the raw client/server interaction. .TP .B \-\-pipesize Specify the buffer size for pipelineing commands. The default is 256, which should be sufficient for general tasks and be below the MTU for most transport media. Larger values may provide faster or slower throughput, depending on MTU. If the buffer is too small, requests will be serialized. Values less than 0 and greater than one million are silently changed to something more reasonable. .TP .BI \-\-client " text" Specifies additional text to be sent using the CLIENT command. .TP .BI \-\-debug " flag" Set a debugging flag. Valid flags are: .RS .TP .B verbose The same as .BR \-v " or " \-\-verbose . .TP .B raw The same as .BR \-r " or " \-\-raw . .TP .B scan Debug the scanner for the configuration file. .TP .B parse Debug the parser for the configuration file. .TP .B pipe Debug TCP pipelining support (see the DICT RFC and RFC1854). .TP .B serial Disable pipelining support. .TP .B time Perform transaction timing. .SH CONFIGURATION The configuration file currently has a very simple format. Lines are used to specify servers, for example: .RS server dict.org .RE or, with options: .RS server dict.org { port 8080 } .br server dict.org { user username secret } .br server dict.org { port dict user username secret } .RE the .B port and .B user options may be specified in any order. The .B port option is used to specify an optional port (e.g., 2628) or service (e.g., dict) for the TCP/IP connection. The .B user option is used to specify a username and shared secret to be used for authentication to this particular server. .P Servers are tried in the order listed until a connection is made. If none of the specified servers are available, and the compile-time option (./configure --enable-dictorg) is enabled, then an attempt will be made to connect on .B localhost and on .B dict.org at the standard part (2628). (This option is disabled by default.) We expect that dict.org will point to one or more DICT servers (perhaps in round-robin fashion) for the foreseeable future (starting in July 1997), although it is difficult to predict anything on the Internet for more than about 3-6 months. .SH EXIT STATUS .br 0 Successful completion .P 20 No matches found .br 21 Approximate matches found .br 22 No databases available .br 23 No strategies available .P 30 Unexpected response code from server .br 31 Server is temporarily unavailable .br 32 Server is shutting down .br 33 Syntax error, command not recognized .br 34 Syntax error, illegal parameters .br 35 Command not implemented .br 36 Command parameter not implemented .br 37 Access denied .br 38 Authentication failed .br 39 Invalid database .br 40 Invalid strategy .br 41 Connection to server failed .SH CREDITS .B dict was written by Rik Faith (faith@cs.unc.edu) and is distributed under the terms of the GNU General Public License. If you need to distribute under other terms, write to the author. .P The main libraries used by this programs (zlib, regex, libmaa) are distributed under different terms, so you may be able to use the libraries for applications which are incompatible with the GPL -- please see the copyright notices and license information that come with the libraries for more information, and consult with your attorney to resolve these issues. .SH BUGS If a .B dict: URL is given on the command line, only the first one is used. The rest are ignored. .P If a .B dict: URL contains a specifier for the nth definition or match of a word, it will be ignored and all the definitions or matches will be provided. This violates the RFC, and will be corrected in a future release. .P If a .B dict: URL contains a shared secret, it will not be parsed correctly. .P When .I OPTION MIME command is sent to the server .I (-M option) , server's capabilities are not checked. .SH FILES .TP .I ~/.dictrc User's .B dict configuration file .TP .I @SYSCONFDIR@/dict.conf System .B dict configuration file .SH "SEE ALSO" .BR dictd (8), .BR dictzip (1), .BR http://www.dict.org, .B RFC 2229 dictd-1.12.1+dfsg.orig/dict.c0000644000000000000000000014015611512103042014322 0ustar rootroot/* dict.c -- * Created: Fri Mar 28 19:16:29 1997 by faith@dict.org * Copyright 1997-2002 Rickard E. Faith (faith@dict.org) * Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) * * 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 1, 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. */ #include "dict.h" #include "parse.h" #include "md5.h" #include extern int yy_flex_debug; lst_List dict_Servers; FILE *dict_output; FILE *dict_error; int formatted; int flush; const char *host_connected = NULL; const char *service_connected = NULL; #define BUFFERSIZE 2048 #define PIPESIZE 256 #define DEF_STRAT "." #define DEF_DB "*" #define CMD_PRINT 0 #define CMD_DEFPRINT 1 #define CMD_CONNECT 2 #define CMD_CLIENT 3 #define CMD_AUTH 4 #define CMD_INFO 5 #define CMD_SERVER 6 #define CMD_DBS 7 #define CMD_STRATS 8 #define CMD_HELP 9 #define CMD_MATCH 10 #define CMD_DEFINE 11 #define CMD_SPELL 12 #define CMD_WIND 13 #define CMD_CLOSE 14 #define CMD_OPTION_MIME 15 struct cmd { int command; int sent; int flag; const char *host; const char *service; const char *database; const char *strategy; const char *word; const char *client; const char *user; const char *key; const char *comment; }; lst_List cmd_list; unsigned long client_defines; unsigned long client_bytes; unsigned long client_pipesize = PIPESIZE; char *client_text = NULL; int option_mime = 0; int ex_status = 0; static void set_ex_status (int status) { if (!ex_status) ex_status = status; } #define EXST_NO_MATCH 20 #define EXST_APPROX_MATCHES 21 #define EXST_NO_DATABASES 22 #define EXST_NO_STRATEGIES 23 #define EXST_UNEXPECTED 30 #define EXST_TEMPORARILY_UNAVAILABLE 31 #define EXST_SHUTTING_DOWN 32 #define EXST_SYNTAX_ERROR 33 #define EXST_ILLEGAL_PARAM 34 #define EXST_COMMAND_NOT_IMPLEMENTED 35 #define EXST_PARAM_NOT_IMPLEMENTED 36 #define EXST_ACCESS_DENIED 37 #define EXST_AUTH_DENIED 38 #define EXST_INVALID_DB 39 #define EXST_INVALID_STRATEGY 40 #define EXST_CONNECTION_FAILED 41 struct def { lst_List data; const char *word; const char *db; const char *dbname; }; struct reply { int s; const char *host; const char *service; const char *user; const char *key; const char *msgid; const char *word; lst_List data; int retcode; int count; /* definitions found */ int matches; /* matches found */ int match; /* doing match found */ int listed; /* Databases or strategies listed */ struct def *defs; } cmd_reply; static const char *cpy( const char *s ) { if (!s || !*s) return NULL; return str_copy(s); } static void client_crlf( char *d, const char *s ) { int flag = 0; while (*s) { if (*s == '\n') { *d++ = '\r'; *d++ = '\n'; ++s; ++flag; } else { *d++ = *s++; flag = 0; } } if (!flag) { *d++ = '\r'; *d++ = '\n'; } *d = '\0'; } static void unexpected_status_code ( int expected_status, int act_status, const char *message) { switch (act_status){ case CODE_TEMPORARILY_UNAVAILABLE: fprintf (stderr, "%s\n", (message ? message : "Server temporarily unavailable")); exit (EXST_TEMPORARILY_UNAVAILABLE); case CODE_SHUTTING_DOWN: fprintf (stderr, "%s\n", (message ? message : "Server shutting down")); exit (EXST_SHUTTING_DOWN); case CODE_SYNTAX_ERROR: fprintf (stderr, "%s\n", (message ? message : "Command not recognized")); exit (EXST_SYNTAX_ERROR); case CODE_ILLEGAL_PARAM: fprintf (stderr, "%s\n", (message ? message : "Illegal parameters")); exit (EXST_ILLEGAL_PARAM); case CODE_COMMAND_NOT_IMPLEMENTED: fprintf (stderr, "%s\n", (message ? message : "Command not implemented")); exit (EXST_COMMAND_NOT_IMPLEMENTED); case CODE_PARAM_NOT_IMPLEMENTED: fprintf (stderr, "%s\n", (message ? message : "Parameter not implemented")); exit (EXST_PARAM_NOT_IMPLEMENTED); case CODE_ACCESS_DENIED: fprintf (stderr, "%s\n", (message ? message : "Access denied")); exit (EXST_ACCESS_DENIED); case CODE_AUTH_DENIED: fprintf (stderr, "%s\n", (message ? message : "Authentication denied")); exit (EXST_AUTH_DENIED); case CODE_INVALID_DB: fprintf (stderr, "%s\n", (message ? message : "Invalid database")); exit (EXST_INVALID_DB); case CODE_INVALID_STRATEGY: fprintf (stderr, "%s\n", (message ? message : "Invalid strategy")); exit (EXST_INVALID_STRATEGY); case CODE_NO_MATCH: fprintf (stderr, "%s\n", (message ? message : "No matches found")); exit (EXST_NO_MATCH); case CODE_NO_DATABASES: fprintf (stderr, "%s\n", (message ? message : "No databases")); exit (EXST_NO_DATABASES); case CODE_NO_STRATEGIES: fprintf (stderr, "%s\n", (message ? message : "No strategies")); exit (EXST_NO_STRATEGIES); default: fprintf (stderr, "Unexpected status code %d (%s), wanted %d\n", act_status, (message ? message : "no message"), expected_status); exit (EXST_UNEXPECTED); } } static void client_open_pager( void ) { dict_output = stdout; dict_error = stderr; } static void client_close_pager( void ) { fflush (dict_output); } static lst_List client_read_text( int s ) { lst_List l = lst_create(); char line[BUFFERSIZE]; int len; while ((len = net_read(s, line, BUFFERSIZE - 1)) >= 0) { line [len] = 0; client_bytes += len; PRINTF(DBG_RAW,("* Text: %s\n",line)); if (line[0] == '.' && line[1] == '\0') break; if (len >= 2 && line[0] == '.' && line[1] == '.') lst_append( l, xstrdup(line + 1) ); else lst_append( l, xstrdup(line) ); } if (len < 0) { client_close_pager(); err_fatal_errno( __func__, "Error reading from socket\n" ); } return l; } static void client_print_text( lst_List l, int print_host_port ) { lst_Position p; const char *e; if (!l) return; if (formatted && print_host_port){ fprintf (dict_output, "%s\t%s\n", host_connected, service_connected); } LST_ITERATE(l,p,e) fprintf( dict_output, " %s\n", e ); } static void client_print_definitions (const struct def *r) { if (formatted){ fprintf (dict_output, "%s\t%s\t", host_connected, service_connected); if (r -> dbname && r -> db) { fprintf( dict_output, "%s\t%s\n", r -> db, r -> dbname); } else if (r -> dbname) { fprintf( dict_output, "%s\n", r -> dbname ); } else if (r -> db) { fprintf( dict_output, "%s\n", r -> db ); } else { fprintf( dict_output, "unknown\n" ); } }else{ fprintf (dict_output, "\nFrom "); if (r -> dbname && r -> db) { fprintf( dict_output, "%s [%s]", r -> dbname, r -> db); } else if (r -> dbname) { fprintf( dict_output, "%s", r -> dbname ); } else if (r -> db) { fprintf( dict_output, "%s", r -> db ); } else { fprintf( dict_output, "unknown" ); } fprintf( dict_output, ":\n\n" ); } client_print_text( r -> data, 0 ); } static void client_print_matches( lst_List l, int flag, const char *word ) { lst_Position p; const char *e; arg_List a; const char *prev = NULL; const char *last; const char *db; static int first = 1; int pos = 0; int len; int count; int empty_line_found = 0; const char *arg0 = NULL; const char *arg1 = NULL; count = 0; if (l) { last = NULL; LST_ITERATE(l,p,e) { if (last && !strcmp(last,e)) continue; ++count; last = e; } } else { if (flag) fprintf( dict_error, "No matches found for \"%s\"\n", word ); set_ex_status (EXST_NO_MATCH); return; } last = NULL; LST_ITERATE(l,p,e) { /* skip MIME header */ if (option_mime && !empty_line_found){ empty_line_found = (e [0] == 0 || (e [0] == '\r' && e [1] == 0)); continue; } /* */ if (last && !strcmp(last,e)) continue; last = e; a = arg_argify( e, 0 ); if (arg_count(a) != 2) err_internal( __func__, "MATCH command didn't return 2 args: \"%s\"\n", e ); arg0 = arg_get (a,0); arg1 = arg_get (a,1); if (formatted){ fprintf (dict_output, "%s\t%s\t%s\t%s\n", host_connected, service_connected, arg0, arg1); }else{ if ((db = str_find(arg0)) != prev) { if (!first) fprintf( dict_output, "\n" ); first = 0; fprintf( dict_output, "%s:", db ); prev = db; pos = 6 + strlen(db); } len = strlen(arg1); if (pos + len + 4 > 70) { fprintf( dict_output, "\n" ); pos = 0; } if (strchr (arg1,' ')) { fprintf( dict_output, " \"%s\"", arg1 ); pos += len + 4; } else { fprintf( dict_output, " %s", arg1 ); pos += len + 2; } } arg_destroy(a); } fprintf( dict_output, "\n" ); } static void client_print_listed( lst_List l ) { lst_Position p; const char *e; arg_List a; int colWidth = 10; /* minimum size of first column */ int colMax = 16; /* maximum size of unragged first column */ char format[32]; int empty_line_found = 0; int len; if (!l) return; LST_ITERATE(l,p,e) { /* skip MIME header */ if (option_mime && !empty_line_found){ empty_line_found = (e [0] == 0 || (e [0] == '\r' && e [1] == 0)); continue; } /* */ a = arg_argify( e, 0 ); if (arg_count(a) != 2) err_internal( __func__, "SHOW command didn't return 2 args: \"%s\"\n", e ); len = strlen (arg_get (a,0)); if (len > colWidth && len <= colMax) colWidth = len; arg_destroy(a); } snprintf( format, sizeof (format), " %%-%ds %%s\n", colWidth ); empty_line_found = 0; LST_ITERATE(l,p,e) { /* skip MIME header */ if (option_mime && !empty_line_found){ empty_line_found = (e [0] == 0 || (e [0] == '\r' && e [1] == 0)); continue; } /* */ a = arg_argify( e, 0 ); if (formatted){ assert (host_connected); assert (service_connected); fprintf (dict_output, "%s\t%s\t%s\t%s\n", host_connected, service_connected, arg_get (a,0), arg_get (a,1)); }else{ fprintf (dict_output, format, arg_get (a,0), arg_get (a,1)); } arg_destroy(a); } } static void client_free_text( lst_List l ) { lst_Position p; char *e; if (!l) return; LST_ITERATE(l,p,e) { if (e) xfree(e); } lst_destroy(l); } static int client_read_status( int s, const char **message, int *count, const char **word, const char **db, const char **dbname, const char **msgid ) { static char buf[BUFFERSIZE]; arg_List cmdline; int argc; char **argv; int status; char *start, *end, *p; int len; if ((len = net_read( s, buf, BUFFERSIZE )) < 0) { client_close_pager(); err_fatal_errno( __func__, "Error reading from socket\n" ); } client_bytes += len; PRINTF(DBG_RAW,("* Read: %s\n",buf)); if ((status = atoi(buf)) < 100) status = 600; PRINTF(DBG_RAW,("* Status = %d\n",status)); if (message && (p = strchr(buf, ' '))) *message = p + 1; if (count) *count = 0; if (word) *word = NULL; if (db) *db = NULL; if (dbname) *dbname = NULL; if (msgid) *msgid = NULL; switch (status) { case CODE_HELLO: if ((start = strrchr(buf, '<')) && (end = strrchr(buf,'>'))) { end[1] = '\0'; *msgid = str_copy( start ); PRINTF(DBG_VERBOSE,("Msgid is \"%s\"\n",*msgid)); } break; case CODE_DATABASE_LIST: case CODE_STRATEGY_LIST: case CODE_DEFINITIONS_FOUND: case CODE_MATCHES_FOUND: cmdline = arg_argify(buf,0); arg_get_vector( cmdline, &argc, &argv ); if (argc > 1 && count) *count = atoi(argv[1]); arg_destroy(cmdline); break; case CODE_DEFINITION_FOLLOWS: cmdline = arg_argify(buf,0); arg_get_vector( cmdline, &argc, &argv ); if (argc > 1 && word) *word = str_find(argv[1]); if (argc > 2 && db) *db = str_find(argv[2]); if (argc > 3 && dbname) *dbname = str_find(argv[3]); arg_destroy(cmdline); break; default: break; } return status; } static struct cmd *make_command( int command, ... ) { va_list ap; struct cmd *c = xmalloc( sizeof( struct cmd ) ); memset( c, 0, sizeof( struct cmd ) ); c->command = command; va_start( ap, command ); switch (command) { case CMD_PRINT: c->comment = va_arg( ap, const char * ); break; case CMD_DEFPRINT: c->database = va_arg( ap, const char * ); c->word = va_arg( ap, const char * ); c->flag = va_arg( ap, int ); break; case CMD_CONNECT: c->host = va_arg( ap, const char * ); c->service = va_arg( ap, const char * ); c->user = va_arg( ap, const char * ); c->key = va_arg( ap, const char * ); break; case CMD_CLIENT: c->client = va_arg( ap, const char * ); break; case CMD_AUTH: break; case CMD_INFO: c->database = va_arg( ap, const char * ); break; case CMD_SERVER: break; case CMD_DBS: break; case CMD_STRATS: break; case CMD_HELP: break; case CMD_MATCH: c->database = va_arg( ap, const char * ); c->strategy = va_arg( ap, const char * ); c->word = va_arg( ap, const char * ); break; case CMD_DEFINE: c->database = va_arg( ap, const char * ); c->word = va_arg( ap, const char * ); break; case CMD_SPELL: c->database = va_arg( ap, const char * ); c->word = va_arg( ap, const char * ); break; case CMD_WIND: c->database = va_arg( ap, const char * ); c->strategy = va_arg( ap, const char * ); c->word = va_arg( ap, const char * ); break; case CMD_CLOSE: break; case CMD_OPTION_MIME: break; default: err_internal( __func__, "Illegal command %d\n", command ); } va_end( ap ); return c; } static void append_command( struct cmd *c ) { if (!cmd_list) cmd_list = lst_create(); lst_append( cmd_list, c ); } static void prepend_command( struct cmd *c ) { if (!cmd_list) cmd_list = lst_create(); lst_push( cmd_list, c ); } static void request( void ) { char b[BUFFERSIZE]; char *buffer = alloca( client_pipesize ); char *p = buffer; lst_Position pos; struct cmd *c = NULL; unsigned char digest[16]; char hex[33]; struct MD5Context ctx; int i; unsigned len; int total = 0; int count = 0; *p = '\0'; c = lst_top(cmd_list); if (c->command == CMD_CONNECT) { cmd_reply.user = c->user; cmd_reply.key = c->key; } LST_ITERATE(cmd_list,pos,c) { b[0] = '\0'; len = 0; PRINTF(DBG_PIPE,("* Looking at request %d\n",c->command)); if (c->sent) { PRINTF(DBG_PIPE,("* Skipping\n")); return; /* FIXME! Keep sending deeper things? */ } ++count; switch( c->command) { case CMD_PRINT: break; case CMD_DEFPRINT: break; case CMD_CONNECT: break; case CMD_AUTH: if (!cmd_reply.key || !cmd_reply.user) break; if (!cmd_reply.msgid) goto end; MD5Init(&ctx); MD5Update(&ctx, (const unsigned char *) cmd_reply.msgid, strlen(cmd_reply.msgid)); MD5Update(&ctx, (const unsigned char *) cmd_reply.key, strlen(cmd_reply.key)); MD5Final(digest, &ctx ); for (i = 0; i < 16; i++) sprintf( hex+2*i, "%02x", digest[i] ); hex[32] = '\0'; snprintf( b, BUFFERSIZE, "auth %s %s\n", cmd_reply.user, hex ); break; case CMD_CLIENT: if (client_text) snprintf( b, BUFFERSIZE, "client \"%s: %s\"\n", c->client, client_text ); else snprintf( b, BUFFERSIZE, "client \"%s\"\n", c->client ); break; case CMD_INFO: snprintf( b, BUFFERSIZE, "show info %s\n", c->database ); break; case CMD_SERVER: snprintf( b, BUFFERSIZE, "show server\n" ); break; case CMD_DBS: snprintf( b, BUFFERSIZE, "show db\n" ); break; case CMD_STRATS: snprintf( b, BUFFERSIZE, "show strat\n" ); break; case CMD_HELP: snprintf( b, BUFFERSIZE, "help\n" ); break; case CMD_MATCH: cmd_reply.word = c->word; snprintf( b, BUFFERSIZE, "match %s %s \"%s\"\n", c->database, c->strategy, c->word ); break; case CMD_DEFINE: cmd_reply.word = c->word; snprintf( b, BUFFERSIZE, "define %s \"%s\"\n", c->database, c->word ); break; case CMD_SPELL: goto end; case CMD_WIND: goto end; case CMD_CLOSE: snprintf( b, BUFFERSIZE, "quit\n" ); break; case CMD_OPTION_MIME: snprintf( b, BUFFERSIZE, "option mime\n" ); break; default: err_internal( __func__, "Unknown command %d\n", c->command ); } len = strlen(b); if (total + len + 3 > client_pipesize) { if (count == 1 && p == buffer && total == 0) { /* The buffer is too small, but we have to send something... */ PRINTF(DBG_PIPE,("* Reallocating buffer to %d bytes\n",len+1)); p = buffer = alloca( len + 1 ); } else { break; } } strcpy( p, b ); p += len; total += len; ++c->sent; if (dbg_test(DBG_SERIAL)) break; /* Don't pipeline. */ } end: /* Ready to send buffer, but are we connected? */ if (!cmd_reply.s) { c = lst_top(cmd_list); if (c->command != CMD_CONNECT) { err_internal( __func__, "Not connected, but no CMD_CONNECT\n" ); } if ((cmd_reply.s = net_connect_tcp( c->host, c->service ? c->service : DICT_DEFAULT_SERVICE )) < 0) { const char *message; switch (cmd_reply.s) { case NET_NOHOST: message = "Can't get host entry for"; break; case NET_NOSERVICE: message = "Can't get service entry for"; break; case NET_NOPROTOCOL: message = "Can't get protocol entry for"; break; case NET_NOCONNECT: message = "Can't connect to"; break; default: message = "Unknown error for"; break; } PRINTF(DBG_VERBOSE,("%s %s.%s\n", message, c->host, c->service ? c->service : DICT_DEFAULT_SERVICE)); if (lst_length(cmd_list) > 1) { c = lst_nth_get(cmd_list,2); if (c->command == CMD_CONNECT) { /* undo pipelining */ cmd_reply.s = 0; if (!dbg_test(DBG_SERIAL)) { LST_ITERATE(cmd_list,pos,c) c->sent = 0; } return; } } client_close_pager(); fprintf (stderr, "Cannot connect to any servers%s\n",\ dbg_test(DBG_VERBOSE) ? "" : " (use -v to see why)" ); exit (EXST_CONNECTION_FAILED); } cmd_reply.host = c->host; cmd_reply.service = c->service ? c->service : DICT_DEFAULT_SERVICE; cmd_reply.user = c->user; cmd_reply.key = c->key; } if ((len = strlen(buffer))) { char *pt; PRINTF(DBG_PIPE,("* Sending %d commands (%d bytes)\n",count,len)); PRINTF(DBG_RAW,("* Send/%d: %s",c->command,buffer)); pt = alloca(2*len); client_crlf(pt,buffer); net_write( cmd_reply.s, pt, strlen(pt) ); } else { PRINTF(DBG_PIPE,("* Sending nothing\n")); PRINTF(DBG_RAW,("* Send/%d\n",c->command)); } } static void process( void ) { struct cmd *c; int expected; const char *message = NULL; int i; int *listed; FILE *old; while ((c = lst_top( cmd_list ))) { request(); /* Send requests */ lst_pop( cmd_list ); expected = CODE_OK; switch (c->command) { case CMD_PRINT: if (!formatted){ if (c->comment) fprintf( dict_output, "%s", c->comment ); } if (cmd_reply.match) client_print_matches( cmd_reply.data, 1, cmd_reply.word ); else if (cmd_reply.listed) client_print_listed( cmd_reply.data ); else client_print_text( cmd_reply.data, 1 ); if (flush){ fflush (dict_output); } client_free_text( cmd_reply.data ); cmd_reply.data = NULL; cmd_reply.matches = cmd_reply.match = cmd_reply.listed = 0; expected = cmd_reply.retcode; break; case CMD_DEFPRINT: if (cmd_reply.count) { if (c->flag) { fprintf( dict_output, "%d definition%s found", cmd_reply.count, cmd_reply.count == 1 ? "" : "s" ); fprintf( dict_output, "\n" ); } for (i = 0; i < cmd_reply.count; i++) { client_print_definitions (&cmd_reply.defs [i]); if (flush){ fflush (dict_output); } client_free_text( cmd_reply.defs[i].data ); cmd_reply.defs[i].data = NULL; } xfree( cmd_reply.defs ); cmd_reply.count = 0; } else if (cmd_reply.matches) { fprintf( dict_error, "No definitions found for \"%s\", perhaps you mean:", c->word ); fprintf( dict_error, "\n" ); old = dict_output; dict_output = dict_error; client_print_matches( cmd_reply.data, 0, c->word ); dict_output = old; if (flush){ fflush (dict_output); } client_free_text( cmd_reply.data ); cmd_reply.data = NULL; cmd_reply.matches = 0; set_ex_status (EXST_APPROX_MATCHES); } else { fprintf( dict_error, "No definitions found for \"%s\"\n", c->word ); set_ex_status (EXST_NO_MATCH); } expected = cmd_reply.retcode; break; case CMD_CONNECT: if (!cmd_reply.s) break; /* Connection failed, continue; */ cmd_reply.retcode = client_read_status( cmd_reply.s, &message, NULL, NULL, NULL, NULL, &cmd_reply.msgid ); if (cmd_reply.retcode == CODE_ACCESS_DENIED) { client_close_pager(); err_fatal( NULL, "Access to server %s.%s denied when connecting\n", cmd_reply.host, cmd_reply.service ); } /* */ host_connected = c -> host; if (c -> service) service_connected = c -> service; else service_connected = DICT_DEFAULT_SERVICE; /* */ expected = CODE_HELLO; while (((struct cmd *)lst_top(cmd_list))->command == CMD_CONNECT) lst_pop(cmd_list); break; case CMD_OPTION_MIME: cmd_reply.retcode = client_read_status( cmd_reply.s, &message, NULL, NULL, NULL, NULL, NULL); if (cmd_reply.retcode != expected && dbg_test(DBG_VERBOSE)) fprintf( dict_error, "Client command gave unexpected status code %d (%s)\n", cmd_reply.retcode, message ? message : "no message" ); expected = cmd_reply.retcode; break; case CMD_CLIENT: cmd_reply.retcode = client_read_status( cmd_reply.s, &message, NULL, NULL, NULL, NULL, NULL); if (cmd_reply.retcode != expected && dbg_test(DBG_VERBOSE)) fprintf( dict_error, "Client command gave unexpected status code %d (%s)\n", cmd_reply.retcode, message ? message : "no message" ); /* set_ex_status (cmd_reply.retcode); */ expected = cmd_reply.retcode; break; case CMD_AUTH: if (!cmd_reply.key || !cmd_reply.user || !cmd_reply.msgid) { expected = cmd_reply.retcode; break; } cmd_reply.retcode = client_read_status( cmd_reply.s, &message, NULL, NULL, NULL, NULL, NULL); expected = CODE_AUTH_OK; if (cmd_reply.retcode == CODE_AUTH_DENIED) { err_warning( NULL, "Authentication to %s.%s denied\n", cmd_reply.host, cmd_reply.service ); expected = CODE_AUTH_DENIED; } break; case CMD_INFO: expected = CODE_DATABASE_INFO; listed = NULL; goto gettext; case CMD_SERVER: expected = CODE_SERVER_INFO; listed = NULL; goto gettext; case CMD_HELP: expected = CODE_HELP; listed = NULL; goto gettext; case CMD_DBS: expected = CODE_DATABASE_LIST; listed = &cmd_reply.listed; goto gettext; case CMD_STRATS: expected = CODE_STRATEGY_LIST; listed = &cmd_reply.listed; goto gettext; gettext: cmd_reply.retcode = client_read_status( cmd_reply.s, &message, listed, NULL, NULL, NULL, NULL); if (cmd_reply.retcode == expected) { cmd_reply.data = client_read_text( cmd_reply.s ); cmd_reply.retcode = client_read_status( cmd_reply.s, &message, NULL,NULL,NULL,NULL,NULL); expected = CODE_OK; } break; case CMD_DEFINE: cmd_reply.retcode = client_read_status( cmd_reply.s, &message, &cmd_reply.count, NULL, NULL, NULL, NULL ); if (!client_defines) tim_start( "define" ); switch (expected = cmd_reply.retcode) { case CODE_DEFINITIONS_FOUND: cmd_reply.defs = xmalloc(cmd_reply.count*sizeof(struct def)); expected = CODE_DEFINITION_FOLLOWS; for (i = 0; i < cmd_reply.count; i++) { ++client_defines; cmd_reply.retcode = client_read_status( cmd_reply.s, &message, NULL, &cmd_reply.defs[i].word, &cmd_reply.defs[i].db, &cmd_reply.defs[i].dbname, NULL ); if (cmd_reply.retcode != expected) goto error; cmd_reply.defs[i].data = client_read_text( cmd_reply.s ); } expected = CODE_OK; cmd_reply.retcode = client_read_status( cmd_reply.s, &message, NULL,NULL,NULL,NULL,NULL ); break; case CODE_NO_MATCH: PRINTF(DBG_VERBOSE, ("No match found for \"%s\" in %s\n",c->word,c->database)); break; case CODE_INVALID_DB: fprintf(stderr, "%s is not a valid database, use -D for a list\n", c->database ); set_ex_status (EXST_INVALID_DB); break; case CODE_NO_DATABASES: fprintf( dict_error, "There are no databases currently available\n" ); set_ex_status (EXST_NO_DATABASES); break; default: expected = CODE_OK; } error: break; case CMD_MATCH: cmd_reply.match = 1; cmd_reply.retcode = client_read_status( cmd_reply.s, &message, &cmd_reply.matches, NULL, NULL, NULL, NULL ); switch (expected = cmd_reply.retcode) { case CODE_MATCHES_FOUND: cmd_reply.data = client_read_text( cmd_reply.s ); expected = CODE_OK; cmd_reply.retcode = client_read_status( cmd_reply.s, &message, NULL,NULL,NULL,NULL,NULL ); break; case CODE_TEMPORARILY_UNAVAILABLE: fprintf (stderr, "Server temporarily unavailable\n"); set_ex_status (EXST_TEMPORARILY_UNAVAILABLE); break; case CODE_NO_MATCH: PRINTF(DBG_VERBOSE, ("No match found in %s for \"%s\" using %s\n", c->database,c->word,c->strategy)); set_ex_status (EXST_NO_MATCH); break; case CODE_INVALID_DB: fprintf( dict_error, "%s is not a valid database, use -D for a list\n", c->database ); set_ex_status (EXST_INVALID_DB); break; case CODE_INVALID_STRATEGY: fprintf( dict_error, "%s is not a valid search strategy, use -S for a list\n", c->strategy ); set_ex_status (EXST_INVALID_STRATEGY); break; case CODE_NO_DATABASES: fprintf( dict_error, "There are no databases currently available\n" ); set_ex_status (EXST_NO_DATABASES); break; case CODE_NO_STRATEGIES: fprintf( dict_error, "There are no search strategies currently available\n" ); set_ex_status (EXST_NO_STRATEGIES); break; default: expected = CODE_OK; } break; case CMD_SPELL: if (cmd_reply.retcode == CODE_NO_MATCH) { prepend_command( make_command( CMD_MATCH, c->database, DEF_STRAT, c->word ) ); } expected = cmd_reply.retcode; break; case CMD_WIND: if (cmd_reply.matches) { if (!cmd_reply.data) err_internal( __func__, "%d matches, but no list\n", cmd_reply.matches ); for (i = cmd_reply.matches; i > 0; --i) { /* skip MIME header */ const char *line = lst_nth_get( cmd_reply.data, i ); arg_List a; const char *orig, *s; char *escaped, *d; if (option_mime){ if (line [0] == 0 || (line [0] == '\r' && line [1] == '\0')) { break; } } /* */ a = arg_argify( line, 0 ); if (arg_count(a) != 2) err_internal( __func__, "MATCH command didn't return 2 args: \"%s\"\n", line ); prepend_command( make_command( CMD_DEFPRINT, str_find(arg_get(a,0)), str_copy(arg_get(a,1)), 0 ) ); /* Escape " and \ in word before sending */ orig = arg_get(a,1); escaped = xmalloc(strlen(orig) * 2 + 1); for (s = orig, d = escaped; *s;) { switch (*s) { case '"': case '\\': *d++ = '\\'; default: *d++ = *s++; } } *d++ = '\0'; prepend_command( make_command( CMD_DEFINE, str_find(arg_get(a,0)), str_copy(escaped), 0 ) ); xfree(escaped); arg_destroy(a); } client_free_text( cmd_reply.data ); cmd_reply.matches = 0; } else { fprintf( dict_error, "No matches found for \"%s\"", c->word ); fprintf( dict_error, "\n" ); set_ex_status (EXST_NO_MATCH); } expected = cmd_reply.retcode; break; case CMD_CLOSE: cmd_reply.retcode = client_read_status( cmd_reply.s, &message, NULL, NULL, NULL, NULL, NULL); expected = CODE_GOODBYE; break; default: err_internal( __func__, "Illegal command %d\n", c->command ); } if (cmd_reply.s && cmd_reply.retcode != expected) { client_close_pager(); unexpected_status_code (expected, cmd_reply.retcode, message); } PRINTF(DBG_RAW,("* Processed %d\n",c->command)); xfree(c); } } #if 0 static void handler( int sig ) { const char *name = NULL; switch (sig) { case SIGHUP: name = "SIGHUP"; break; case SIGINT: name = "SIGINT"; break; case SIGQUIT: name = "SIGQUIT"; break; case SIGILL: name = "SIGILL"; break; case SIGTRAP: name = "SIGTRAP"; break; case SIGTERM: name = "SIGTERM"; break; case SIGPIPE: name = "SIGPIPE"; break; } if (name) err_fatal( __func__, "Caught %s, exiting\n", name ); else err_fatal( __func__, "Caught signal %d, exiting\n", sig ); exit(0); } static void setsig( int sig, void (*f)(int) ) { struct sigaction sa; sa.sa_handler = f; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(sig, &sa, NULL); } #endif static void client_config_print( FILE *stream, lst_List c ) { FILE *s = stream ? stream : stderr; lst_Position p; dictServer *e; printf( "Configuration file:\n" ); LST_ITERATE(dict_Servers,p,e) { if (e->port || e->user || e->secret) { fprintf( s, " server %s {\n", e->host ); if (e->port) fprintf( s, " port %s\n", e->port ); if (e->user) fprintf( s, " user %s %s\n", e->user, e->secret ? "*" : "(none)" ); fprintf( s, " }\n" ); } else { fprintf( s, " server %s\n", e->host ); } } } static const char *id_string (void) { static char buffer[BUFFERSIZE]; snprintf( buffer, BUFFERSIZE, "%s", DICT_VERSION ); return buffer; } static const char *client_get_banner( void ) { static char *buffer= NULL; struct utsname uts; if (buffer) return buffer; uname( &uts ); buffer = xmalloc(256); snprintf( buffer, 256, "%s %s/rf on %s %s", err_program_name (), id_string (), uts.sysname, uts.release ); return buffer; } static void banner( FILE *out_stream ) { fprintf( out_stream , "%s\n", client_get_banner() ); fprintf( out_stream, "Copyright 1997-2002 Rickard E. Faith (faith@dict.org)\n" ); fprintf( out_stream, "Copyright 2002-2007 Aleksey Cheusov (vle@gmx.net)\n" ); fprintf( out_stream, "\n" ); } static void license( void ) { static const char *license_msg[] = { "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 1, 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.", 0 }; const char **p = license_msg; banner ( stdout ); while (*p) fprintf( stdout, " %s\n", *p++ ); } static void help( FILE *out_stream ) { static const char *help_msg[] = { "Usage: dict [options] [word]", "Query a dictd server for the definition of a word", "", "-h --host specify server", "-p --port specify port", "-d --database select a database to search", "-m --match match instead of define", "-s --strategy strategy for matching or defining", "-c --config specify configuration file", "-C --nocorrect disable attempted spelling correction", "-D --dbs show available databases", "-S --strats show available search strategies", "-H --serverhelp show server help", "-i --info show information about a database", "-I --serverinfo show information about the server", "-a --noauth disable authentication", "-u --user username for authentication", "-k --key shared secret for authentication", "-V --version display version information", "-L --license display copyright and license information", " --help display this help", "-v --verbose be verbose", "-r --raw trace raw transaction", " --debug set debugging flag", " --pipesize specify buffer size for pipelining (256)", " --client additional text for client command", "-M --mime send OPTION MIME command if server supports it", "-f --formatted use strict tabbed format of output", 0 }; const char **p = help_msg; banner( out_stream ); while (*p) fprintf( out_stream, "%s\n", *p++ ); } int main( int argc, char **argv ) { int c; const char *host = NULL; const char *service = NULL; const char *user = NULL; const char *key = NULL; const char *database = DEF_DB; const char *strategy = DEF_STRAT; const char *configFile = NULL; const char *word = NULL; int doauth = 1; int docorrect = 1; int offset = 0; int i; enum { DEFINE = 0x0001, MATCH = 0x0002, INFO = 0x0010, SERVER = 0x0020, DBS = 0x0040, STRATS = 0x0080, HELP = 0x0100, OPTION_MIME = 0x0200, } function = DEFINE; struct option longopts[] = { { "host", 1, 0, 'h' }, { "port", 1, 0, 'p' }, { "database", 1, 0, 'd' }, { "info", 1, 0, 'i' }, { "serverinfo", 0, 0, 'I' }, { "match", 0, 0, 'm' }, { "strategy", 1, 0, 's' }, { "nocorrect", 0, 0, 'C' }, { "config", 1, 0, 'c' }, { "dbs", 0, 0, 'D' }, { "strats", 0, 0, 'S' }, { "serverhelp", 0, 0, 'H' }, { "noauth", 0, 0, 'a' }, { "user", 1, 0, 'u' }, { "key", 1, 0, 'k' }, { "version", 0, 0, 'V' }, { "license", 0, 0, 'L' }, { "help", 0, 0, 501 }, { "verbose", 0, 0, 'v' }, { "raw", 0, 0, 'r' }, { "pager", 1, 0, 'P' }, { "debug", 1, 0, 502 }, { "pipesize", 1, 0, 504 }, { "client", 1, 0, 505 }, { "mime", 1, 0, 'M' }, { "formatted", 0, 0, 'f' }, { "flush", 0, 0, 'F' }, { 0, 0, 0, 0 } }; dict_output = stdout; dict_error = stderr; maa_init (argv[0]); dbg_register( DBG_VERBOSE, "verbose" ); dbg_register( DBG_RAW, "raw" ); dbg_register( DBG_SCAN, "scan" ); dbg_register( DBG_PARSE, "parse" ); dbg_register( DBG_PIPE, "pipe" ); dbg_register( DBG_SERIAL, "serial" ); dbg_register( DBG_TIME, "time" ); dbg_register( DBG_URL, "url" ); while ((c = getopt_long( argc, argv, "h:p:d:i:Ims:DSHau:c:Ck:VLvrP:MfF", longopts, NULL )) != EOF) { switch (c) { case 'h': host = optarg; break; case 'p': service = optarg; break; case 'd': database = optarg; break; case 'i': database = optarg; function |= INFO; break; case 'I': function |= SERVER; break; case 'm': function &= ~DEFINE; function |= MATCH; break; case 's': strategy = optarg; break; case 'D': function |= DBS; break; case 'S': function |= STRATS; break; case 'H': function |= HELP; break; case 'M': option_mime = 1; function |= OPTION_MIME; break; case 'c': configFile = optarg; break; case 'C': docorrect = 0; break; case 'a': doauth = 0; break; case 'u': user = optarg; break; case 'k': key = optarg; break; case 'V': banner( stdout ); exit(1); break; case 'L': license(); exit(1); break; case 'v': dbg_set( "verbose" ); break; case 'r': dbg_set( "raw" ); break; case 'P': if (strcmp (optarg, "-")){ fprintf (stderr, "Option --pager is now deprecated"); exit (1); } break; case 505: client_text = optarg; break; case 504: client_pipesize = atoi(optarg); break; case 502: dbg_set( optarg ); break; case 501: help( stdout ); exit(1); break; case 'f': formatted = 1; break; case 'F': flush = 1; break; default: help( stderr ); exit(1); break; } } if (optind == argc && (!(function & ~(DEFINE|MATCH)))) { banner( stderr ); fprintf( stderr, "Use --help for help\n" ); exit(1); } if (client_pipesize > 1000000) client_pipesize = 1000000; if (dbg_test(DBG_PARSE)) prs_set_debug(1); if (dbg_test(DBG_SCAN)) yy_flex_debug = 1; else yy_flex_debug = 0; if (configFile) { prs_file_nocpp( configFile ); } else { char b[256]; char *env = getenv("HOME"); snprintf( b, 256, "%s/%s", env ? env : "./", DICT_RC_NAME ); PRINTF(DBG_VERBOSE,("Trying %s...\n",b)); if (!access(b, R_OK)) { prs_file_nocpp(b); } else { PRINTF(DBG_VERBOSE,("Trying %s...\n", DICT_CONFIG_PATH DICT_CONFIG_NAME)); if (!access( DICT_CONFIG_PATH DICT_CONFIG_NAME, R_OK )) prs_file_nocpp( DICT_CONFIG_PATH DICT_CONFIG_NAME ); } } if (dbg_test(DBG_VERBOSE)) { if (dict_Servers) client_config_print( NULL, dict_Servers ); else fprintf( stderr, "No configuration\n" ); } if (optind < argc && !strncmp(argv[optind],"dict://",7)) { char *p; int state, fin; char *s; /* dict://:@:/d::: 000000 111111111111 222222 333333 4 555555 6666666666 777 dict://:@/d::: 000000 111111111111 222222 4 555555 6666666666 777 dict://:/d::: 000000 111111 4 555555 6666666666 777 dict:///d::: 000000 4 555555 6666666666 777 dict:///d::: 000000 4 555555 6666666666 777 dict://:@:/m:::: 000000 111111111111 222222 333333 4 555555 6666666666 7777777 888 dict://:/m:::: 000000 111111 4 555555 6666666666 7777777 888 dict:///m:::: 000000 4 555555 6666666666 7777777 888 */ for (s = p = argv[optind] + 7, state = 0, fin = 0; !fin; ++p) { switch (*p) { case '\0': ++fin; case ':': switch (state) { case 0: *p = '\0'; host = user = cpy(s); ++state; s=p+1; break; case 2: *p = '\0'; host = cpy(s); ++state; s=p+1; break; case 4: if (s == p - 1) { if (*s == 'd') function = DEFINE; else if (*s == 'm') function = MATCH; else { PRINTF(DBG_URL,("State = %d, s = %s\n",state,s)); client_close_pager(); err_fatal( NULL, "Parse error at %s\n", p ); } ++state; s=p+1; break; } else { PRINTF(DBG_URL,("State = %d, s = %s\n",state,s)); client_close_pager(); err_fatal( NULL, "Parse error at %s\n", p ); } break; case 5: *p = '\0'; word = cpy(s); ++state; s=p+1; break; case 6: *p = '\0'; database = cpy(s); ++state; s=p+1; break; case 7: *p = '\0'; if (function == DEFINE) offset = atoi(s); else strategy = cpy(s); ++state; s=p+1; break; case 8: *p = '\0'; if (function == MATCH) offset = atoi(s); ++state; s=p+1; break; /* FALLTHROUGH */ default: PRINTF(DBG_URL,("State = %d, s = %s\n",state,s)); client_close_pager(); err_fatal( NULL, "Parse error at %s\n", p ); } break; case '@': switch (state) { case 1: *p = '\0'; key = xstrdup(s); ++state; s=p+1; break; default: PRINTF(DBG_URL,("State = %d, s = %s\n",state,s)); client_close_pager(); err_fatal( NULL, "Parse error at %s\n", p ); } break; case '/': switch (state) { case 0: *p = '\0'; host = xstrdup(s); state = 4; s=p+1; break; case 1: *p = '\0'; service = xstrdup(s); state = 4; s=p+1; break; case 2: *p = '\0'; host = xstrdup(s); state = 4; s=p+1; break; default: PRINTF(DBG_URL,("State = %d, s = %s\n",state,s)); client_close_pager(); err_fatal( NULL, "Parse error at %s\n", p ); } break; } } if (!key) user = NULL; if (!database) database = DEF_DB; if (!strategy) strategy = DEF_STRAT; if (dbg_test(DBG_URL)) { printf( "user = %s, passphrase = %s\n", user ? user : "(null)", key ? key : "(null)" ); printf( "host = %s, port = %s\n", host ? host : "(null)", service ? service : "(null)" ); printf( "word = %s, database = %s, strategy = %s\n", word ? word : "(null)", strategy ? strategy : "(null)", database ? database : "(null)" ); } if (host && !host[0]) { /* Empty host causes default to be used. */ xfree((void *)host); host = NULL; } } #if 0 setsig(SIGHUP, handler); setsig(SIGINT, handler); setsig(SIGQUIT, handler); setsig(SIGILL, handler); setsig(SIGTRAP, handler); setsig(SIGTERM, handler); setsig(SIGPIPE, handler); #endif fflush(stdout); fflush(stderr); tim_start("total"); if (host) { append_command( make_command( CMD_CONNECT, host, service, user, key ) ); } else { lst_Position p; dictServer *s; if (dict_Servers) { LST_ITERATE(dict_Servers,p,s) { append_command( make_command( CMD_CONNECT, s->host, s->port, s->user, s->secret ) ); } #ifdef USE_DICT_ORG } append_command(make_command(CMD_CONNECT,"dict.org", NULL,user,key)); append_command(make_command(CMD_CONNECT,"alt0.dict.org",NULL,user,key)); #else }else{ fprintf (stderr, "'dict.conf' doesn't specify any dict server\n"); exit (1); } #endif } append_command( make_command( CMD_CLIENT, client_get_banner() ) ); if (doauth) append_command( make_command( CMD_AUTH ) ); if (function & OPTION_MIME) { append_command( make_command( CMD_OPTION_MIME ) ); append_command( make_command( CMD_PRINT, NULL ) ); } if (function & INFO) { append_command( make_command( CMD_INFO, database ) ); append_command( make_command( CMD_PRINT, NULL ) ); } if (function & SERVER) { append_command( make_command( CMD_SERVER ) ); append_command( make_command( CMD_PRINT, NULL ) ); } if (function & DBS) { append_command( make_command( CMD_DBS ) ); append_command( make_command( CMD_PRINT, "Databases available:\n" ) ); } if (function & STRATS) { append_command( make_command( CMD_STRATS ) ); append_command( make_command( CMD_PRINT, "Strategies available:\n" ) ); } if (function & HELP) { append_command( make_command( CMD_HELP ) ); append_command( make_command( CMD_PRINT, "Server help:\n" ) ); } if (function & MATCH) { if (word) { append_command( make_command( CMD_MATCH, database, strategy, word ) ); append_command( make_command( CMD_PRINT, NULL ) ); } else { for (i = optind; i < argc; i++) { append_command( make_command( CMD_MATCH, database, strategy, argv[i] ) ); append_command( make_command( CMD_PRINT, NULL ) ); } } } else if (function & DEFINE) { if (word) { append_command( make_command( CMD_DEFINE, database, word ) ); append_command( make_command( CMD_DEFPRINT, database, word, 1 ) ); } else { for (i = optind; i < argc; i++) { if (!strcmp(strategy, DEF_STRAT)) { append_command( make_command( CMD_DEFINE, database, argv[i] ) ); if (docorrect) append_command( make_command( CMD_SPELL, database, argv[i])); append_command( make_command(CMD_DEFPRINT,database,argv[i],1) ); } else { append_command( make_command( CMD_MATCH, database, strategy, argv[i] ) ); append_command( make_command( CMD_WIND, database, strategy, argv[i] ) ); } } } } append_command( make_command( CMD_CLOSE ) ); if (!dbg_test(DBG_VERBOSE|DBG_TIME)) client_open_pager(); process(); client_close_pager(); if (dbg_test(DBG_TIME)) { fprintf( dict_output, "\n" ); tim_stop("total"); if (client_defines) { tim_stop("define"); fprintf( stderr, "* %ld definitions in %.2fr %.2fu %.2fs" " => %.1f d/sec\n", client_defines, tim_get_real( "define" ), tim_get_user( "define" ), tim_get_system( "define" ), client_defines / tim_get_real( "define" ) ); } fprintf( stderr, "* %ld bytes total in %.2fr %.2fu %.2fs => %.0f bps\n", client_bytes, tim_get_real( "total" ), tim_get_user( "total" ), tim_get_system( "total" ), client_bytes / tim_get_real( "total" ) ); } return ex_status; } dictd-1.12.1+dfsg.orig/dict.h0000644000000000000000000000426011116777275014353 0ustar rootroot/* dict.h -- * Created: Wed Apr 16 08:44:21 1997 by faith@dict.org * Copyright 1997, 1998, 2000 Rickard E. Faith (faith@dict.org) * Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) * * 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 1, 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. */ #ifndef _DICT_H_ #define _DICT_H_ #include "dictP.h" #include "maa.h" #include "zlib.h" #include "net.h" #include "codes.h" #include #include #define DICT_DEFAULT_SERVICE "2628" /* Also in dictd.h */ #define DICT_CONFIG_NAME "dict.conf" #define DICT_RC_NAME ".dictrc" #define DBG_VERBOSE (0<<30|1<< 0) /* Verbose */ #define DBG_RAW (0<<30|1<< 1) /* Trace client/server interaction */ #define DBG_SCAN (0<<30|1<< 2) /* Debug configuration file scanner */ #define DBG_PARSE (0<<30|1<< 3) /* Debug configuration file parser */ #define DBG_PIPE (0<<30|1<< 4) /* Debug pipelining */ #define DBG_SERIAL (0<<30|1<< 5) /* Disable pipelining */ #define DBG_TIME (0<<30|1<< 6) /* Time transaction */ #define DBG_URL (0<<30|1<< 7) /* URLs */ typedef struct dictServer { const char *host; const char *port; const char *user; const char *secret; } dictServer; typedef struct dictToken { const char *string; int integer; src_Type src; } dictToken; extern lst_List dict_Servers; /* List of servers to try */ /* dmalloc must be last */ #ifdef DMALLOC_FUNC_CHECK # include "dmalloc.h" #endif #endif dictd-1.12.1+dfsg.orig/dictP.h0000644000000000000000000001501111360632116014450 0ustar rootroot /* dictP.h -- * Created: Fri Mar 7 10:54:05 1997 by faith@dict.org * Copyright 1997, 1999, 2000 Rickard E. Faith (faith@dict.org) * Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) * * This program comes with ABSOLUTELY NO WARRANTY. * * 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 1, 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. */ #ifndef _DICTP_H_ #define _DICTP_H_ #ifdef HAVE_CONFIG_H #include "config.h" #endif #if defined(__INTERIX) || defined(__OPENNT) #ifndef _ALL_SOURCE #define _ALL_SOURCE #endif /* _ALL_SOURCE */ #endif /* __OPENNT */ #include #include #include #include #include #include #if defined(HAVE_WCTYPE_H) && defined(SYSTEM_UTF8_FUNCS) #include #endif #ifdef HAVE_CTYPE_H #include #endif /* AIX requires this to be the first thing in the file. */ #if defined(__IRIX__) && defined(__sgi__) && !HAVE_ALLOCA_H # undef HAVE_ALLOCA_H # define HAVE_ALLOCA_H 1 #endif #if HAVE_ALLOCA_H # include #endif #ifndef HAVE_ALLOCA # ifndef alloca /* predefined by HP cc +Olibcalls */ # ifdef _AIX # pragma alloca # else void *alloca(size_t size); # endif # endif #endif /* Get string functions */ #if STDC_HEADERS # include #else # if HAVE_STRINGS_H # include # endif # if !HAVE_STRCHR # define strchr index # define strrchr rindex # endif #endif #if HAVE_SIZE_T #include #else typedef unsigned int size_t; #endif #if !HAVE_SOCKLEN_T typedef int socklen_t; #endif #if !HAVE_STRDUP extern char *strdup( const char * ); #endif #if !HAVE_STRTOL extern long strtol( const char *, char **, int ); #endif #if !HAVE_STRTOUL extern unsigned long int strtoul( const char *, char **, int ); #endif #if !HAVE_SNPRINTF extern int snprintf(char *str, size_t size, const char *format, ...); #endif #if !HAVE_DAEMON extern int daemon(int nochdir, int noclose); #endif #if !HAVE_VSNPRINTF #include extern int vsnprintf(char *str, size_t size, const char *format, va_list ap); #endif #if !HAVE_INET_ATON #define inet_aton(a,b) (b)->s_addr = inet_addr(a) #endif #if HAVE_WINT_T #include #else typedef unsigned int wint_t; #endif #if !HAVE_ISWALNUM extern int iswalnum__ (wint_t wc); #else #define iswalnum__ iswalnum #endif #if !HAVE_ISWSPACE extern int iswspace__ (wint_t wc); #else #define iswspace__ iswspace #endif #if !HAVE_TOWLOWER extern wint_t towlower__ (wint_t wc); #else #define towlower__ towlower #endif #if HAVE_WCHAR_T #include #else typedef unsigned int wchar_t; #endif #if HAVE_DECL_CODESET #include #else extern const char * nl_langinfo (int ITEM); #define CODESET 1234 #endif #ifndef SYSTEM_UTF8_FUNCS #define MB_CUR_MAX__ 6 #else #define MB_CUR_MAX__ MB_CUR_MAX #endif #if HAVE_MBSTATE_T #include #else typedef char mbstate_t; #endif #if !HAVE_STRLCPY extern size_t strlcpy (char *s, const char * wc, size_t size); #endif #if !HAVE_STRLCAT size_t strlcat(char *dst, const char *src, size_t siz); #endif #if !HAVE_WCRTOMB extern size_t wcrtomb__ (char *s, wchar_t wc, mbstate_t *ps); #else #define wcrtomb__ wcrtomb #endif #if !HAVE_WCTOMB extern int wctomb__ (char *s, wchar_t wc); #else #define wctomb__ wctomb #endif #if !HAVE_MBRLEN extern size_t mbrlen__ (const char *s, size_t n, mbstate_t *ps); #else #define mbrlen__ mbrlen #endif #if !HAVE_MBRTOWC extern size_t mbrtowc__ (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps); #else #define mbrtowc__ mbrtowc #endif #if !HAVE_MBSTOWCS extern size_t mbstowcs__ (wchar_t *dest, const char *src, size_t n); #else #define mbstowcs__ mbstowcs #endif #if !HAVE_SETENV extern int setenv(const char *name, const char *value, int overwrite); #endif #if !HAVE_MBTOWC extern int mbtowc__ (wchar_t *pwc, const char *s, size_t n); #else #define mbtowc__ mbtowc #endif #if !HAVE_WCWIDTH #define wcwidth__(x) (1) #endif #if !HAVE_INITGROUPS #define initgroups(a,b) #endif #if defined(HAVE_WAITPID) && !defined(HAVE_WAIT3) #define wait3(status,options,rusage) \ waitpid(-1, (status),(options)) #endif #ifdef USE_PLUGIN # if HAVE_DLFCN_H # include typedef void * lt_dlhandle; # define lt_dlsym dlsym # define lt_dlopen(filename) dlopen(filename, RTLD_NOW) # define lt_dlclose dlclose # define lt_dlerror dlerror # else # include # endif #endif /* Get time functions */ #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif /* Include some standard header files. */ #include #include #include #include /* We actually need a few non-ANSI C things... */ #if defined(__STRICT_ANSI__) extern char *strdup( const char * ); #if !HAVE_FILENO extern int fileno( FILE *stream ); #endif extern FILE *fdopen( int fildes, const char *mode ); #endif #if HAVE_SYS_RESOURCE_H # include #endif /* Provide assert() */ #include /* Provide stdarg support */ #include /* Provide networking stuff */ #if HAVE_SYS_WAIT_H # include #endif #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif #include #include /* Provide mmap stuff */ #ifdef HAVE_MMAP #include #endif #if HAVE_LIMITS_H #include #endif /* Handle getopt correctly */ #if HAVE_GETOPT_H # include #endif /* HAVE_GETOPT_H */ #if !HAVE_GETOPT_LONG struct option { const char *name; int has_arg; int *flag; int val; }; int getopt_long(int argc, char * const argv[], const char *optstring, const struct option *longopts, int *longindex); extern int optind; extern char *optarg; #endif /* HAVE_GETOPT_LONG */ /* Local stuff */ #ifndef max #define max(a,b) ((a)>(b)?(a):(b)) #endif #define HAVE_UTF8 1 #endif /* _DICTP_H_ */ dictd-1.12.1+dfsg.orig/dict_lookup0000644000000000000000000000744511512413711015504 0ustar rootroot#!/bin/sh # Copyright (c) 2010 # Alexander Vorontsov # Aleksey Cheusov # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ############################################################ # Variables settable by user #D_DICT_CMD=$HOME/bin/your-own-dict-program D_AWK_PROG=${D_AWK_PROG-awk} D_XCLIP_PROG=${D_XCLIP_PROG-xclip} D_XTERM_PROG=${D_XTERM_PROG-xterm} D_UTF8_LOCALE=${D_UTF8_LOCALE-en_US.UTF-8} D_DICT_PROG=${D_DICT_PROG-dict} D_DICT_SERVER=${D_DICT_SERVER--h dict.org} D_DICT_PORT=${D_DICT_PORT--p 2628} D_DICT_DB_OPT=${D_DICT_DB_OPT--d foldoc} D_XTERM_CLASS=${D_XTERM_CLASS--class XTerm} D_XTERM_NAME=${D_XTERM_NAME--name xterm_dict} D_XTERM_TITLE=${D_XTERM_TITLE--title dict_lookup} D_TEXT_WIDTH=${D_TEXT_WIDTH-cyrillic_text_width} D_TERM_X=${D_TERM_X-+200} D_TERM_Y=${D_TERM_Y-+200} D_TERM_H=${D_TERM_H-+40} D_PAGER=${D_PAGER-less} if test -z "$COLORIZER"; then colorit_config=$HOME/.colorit.d/dict if test -f "$colorit_config"; then COLORIZER="colorit -P - -c $colorit_config" else COLORIZER=cat fi fi ############################################################ # functions # cyrillic_text_width (){ # This function may not work properly for languages # other than Russian. wcwidth(3) and C language is needed! LC_ALL=C $D_AWK_PROG -v h="$D_TERM_H" ' BEGIN {max = 15} { gsub(/[\300-\337][\200-\277]/, "1") sub(/ +$/, "") curr=length($0) if (curr > max) max=curr } END { print max "x" (NR < h ? NR : h)+1}' "$@" } set_query () { if test -n "$query"; then return 0 fi query=`$D_XCLIP_PROG -o` if test -z "$query"; then exit fi } ############################################################ # main # help (){ cat 1>&2 <<'EOF' usage: dict_lookup [OPTIONS] -h display this help -x X coordinate of xterm -y Y coordinate of xterm -s size of xterm in symbols, e.g. 50x20 -q query EOF } while getopts x:y:s:q:h f do case $f in h) help; exit 0;; x) D_TERM_X=+$OPTARG;; y) D_TERM_Y=+$OPTARG;; s) TERM_WH=$OPTARG;; q) query=$OPTARG;; '?') help; exit 1;; esac done shift `expr $OPTIND - 1` set_query tmp_dir="/tmp/`basename $0`.$$" trap "rm -rf $tmp_dir" 0 1 2 3 15 mkdir -m 700 "$tmp_dir" if test -z "$D_DICT_CMD"; then D_DICT_CMD="$D_DICT_PROG $D_DICT_SERVER $D_DICT_PORT $D_DICT_DB_OPT" fi $D_DICT_CMD "$query" 2>&1 | env LC_ALL=C grep -Ev "definitions? found" > "$tmp_dir/res.txt" if test -z "$TERM_WH"; then TERM_WH=`$D_TEXT_WIDTH "$tmp_dir/res.txt"` fi geometry="-geometry ${TERM_WH}${D_TERM_X}${D_TERM_Y}" unset LC_ALL || true unset LANG || true LC_CTYPE=$D_UTF8_LOCALE $D_XTERM_PROG $geometry \ -u8 $D_XTERM_CLASS $D_XTERM_NAME $D_XTERM_TITLE \ -e "$COLORIZER < $tmp_dir/res.txt | $D_PAGER" dictd-1.12.1+dfsg.orig/dict_lookup.1.in0000644000000000000000000000432511512413711016242 0ustar rootroot.\" dict.1 -- .\" Copyright 2011 Aleksey Cheusov (vle@gmx.net) .TH DICT_LOOKUP 1 "9 January 2011" "" "" .SH NAME dict_lookup \- DICT Protocol Client .SH SYNOPSIS .nf .BI dict_lookuop " [options]" .fi .SH DESCRIPTION .B dict_lookup reads X selection, then open .B terminal emulator and run .B dict client in it allowing user to view content using .BR pager . It makes sense to configure launching dict_lookup on a keyboard shortcut in the window manager. .SH OPTIONS .TP .B \-h display help message. .TP .BI \-x " x" X coordinate of terminal emulator. .TP .BI \-x " Y" Y coordinate of terminal emulator. .TP .BI \-s " WxH" width and height of terminal emulator separated by 'x'. .TP .BI \-q " query" query, if it is specified, X selection is not read. .SH ENVIRONMENT .B dict_lookup recognizes the following environment variables. The default value is specified in square brackets. .TP .B D_AWK_PROG AWK interpreter to use. .RI [ awk ] .TP .B D_XCLIP_PROG xclip application. .RI [ xclip ] .TP .B D_XTERM_PROG xterm or equivalent terminal emulator. .RI [ xterm ] .TP .B D_UTF8_LOCALE UTF-8 locale. .RI [ en_US.UTF-8 ] .TP .B D_DICT_PROG Dictionary client program. .RI [ dict ] .TP .B D_DICT_SERVER Option for dictionary client specifying the server. .RI [ "-h dict.org" ] .TP .B D_DICT_PORT Option for dictionary client specifying the port. .RI [ "-p 2628" ] .TP .B D_DICT_DB_OPT Option for dictionary client specifying the database. .RI [ "-d foldoc" ] .TP .B D_XTERM_CLASS Option for terminal emulator specifying the class. .RI [ "-class XTerm" ] .TP .B D_XTERM_NAME Option for terminal emulator specifying the name. .RI [ "-name xterm_dict" ] .TP .B D_XTERM_TITLE Option for terminal emulator specifying the title. .RI [ "-title dict_lookup" ] .TP .B D_TEXT_WIDTH Program calculating text width for given text. .RI [ cyrillic_text_width ] cyrillic_text_width doesn't work correctly for Japanese, Korean, Chinese and some other languages. .TP .B D_TERM_X Terminal emulator X coordinate. .RI [ +200 ] .TP .B D_TERM_Y Terminal emulator Y coordinate. .RI [ +200 ] .TP .B D_TERM_H Terminal emulator height. .RI [ +40 ] .TP .B D_PAGER Pager. .RI [ less ] .SH "SEE ALSO" .BR dict (1), .BR less (1), .BR xterm (1), .BR dictd (8), .BR http://www.dict.org, .B RFC 2229 dictd-1.12.1+dfsg.orig/dictd.8.in0000644000000000000000000013004011716300514015020 0ustar rootroot.\" dictd.8 -- .\" Created: Mon Mar 10 16:10:03 1997 by faith@dict.org .\" Copyright 1997, 1998, 2002 Rickard E. Faith (faith@dict.org) .\" Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .TH DICTD 8 "29 March 2002" "" "" .SH "NAME" dictd - a dictionary database server .SH "SYNOPSIS" .nf .BI dictd " [options]" .fi .SH "DESCRIPTION" .B dictd is a server for the Dictionary Server Protocol (DICT), a TCP transaction based query/response protocol that allows a client to access dictionary definitions from a set of natural language dictionary databases. .P For security reasons, dictd drops root permissions after startup. If user .B dictd exists on the system, the daemon will run as that user, group .BR dictd ", otherwise it will run as user .BR nobody ", group" .BR nobody " or " nogroup (depending on the operating system distribution). .P Since startup time is significant, the server is designed to run continuously, and should .I not be run from .BR inetd (8). (However, with a fast processor, it is feasible to do so.) .P Databases are distributed separately from the server. .P By default, .B dictd assumes that the index files are sorted alphabetically, and only alphanumeric characters from the 7-bit ASCII character set are used for search. This default may be overridden by a header in the data file. The only such features implemented at this time are the headers "00-database-allchars" which tells .B dictd that non-alphanumeric characters may also be used for search, the header "00-database-utf8" which indicates that the database uses utf8 encoding, and the "00-database-8bit-new" which indicates that the database is encoded and sorted according to a locale that uses an 8-bit encoding. .SH "BACKGROUND" For many years, the Internet community has relied on the "webster" protocol for access to natural language definitions. The webster protocol supports access to a single dictionary and (optionally) to a single thesaurus. In recent years, the number of publicly available webster servers on the Internet has dramatically decreased. .P Fortunately, several freely-distributable dictionaries and lexicons have recently become available on the Internet. However, these freely-distributable databases are not accessible via a uniform interface, and are not accessible from a single site. They are often small and incomplete individually, but would collectively provide an interesting and useful database of English words. Examples include the Jargon file, the WordNet database, MICRA's version of the 1913 Webster's Revised Unabridged Dictionary, and the Free Online Dictionary of Computing. (See the DICT protocol specification (RFC) for references.) Translating and non-English dictionaries are also becoming available (for example, the FOLDOC dictionary is being translated into Spanish). .P The webster protocol is not suitable for providing access to a large number of separate dictionary databases, and extensions to the current webster protocol were not felt to be a clean solution to the dictionary database problem. .P The DICT protocol is designed to provide access to multiple databases. Word definitions can be requested, the word index can be searched (using an easily extended set of algorithms), information about the server can be provided (e.g., which index search strategies are supported, or which databases are available), and information about a database can be provided (e.g., copyright, citation, or distribution information). Further, the DICT protocol has hooks that can be used to restrict access to some or all of the databases. .P .BR dictd (8) is a server that implements the DICT protocol. Bret Martin implemented another server, and several people (including Bret and myself) have implemented clients in a variety of languages. .SH "OPTIONS" .TP .BR \-V " or " \-\-version Display version information. .TP .B \-\-license Display copyright and license information. .TP .BR \-h " or " \-\-help Display help information. .TP .BR \-v " or " \-\-verbose " or " " \-dverbose" Be verbose. .TP .BI \-c " file\fR or " \-\-config " file" Specify configuration file. The default is .I @SYSCONFDIR@/dictd.conf , but may be changed in the .I defs.h file at compile time (DICTD_CONFIG_FILE). .TP .BI \-p " port\fR or " \-\-port " port" Overrides the keyword .B port in .I Global Settings Specification section of configuration file. .TP .BR \-i " or " \-\-inetd Communicate on standard input/output, suitable for use from inetd. Although, due to its rather large startup time, this daemon was not intended to run from inetd, with a fast processor it is feasible to do so. This option also implies \-\-fast-start. .TP .BI \-\-pp " prog" Sets a preprocessor for configuration file. like .I " m4" or .I " cpp". See examples/dictd_complex.conf file from distribution. By default configuration file is parsed without preprocessor. .TP .BI \-\-depth " length" Overrides the keyword .B depth in .I Global Settings Specification section of configuration file. .TP .BI \-\-delay " seconds" Overrides the keyword .B delay in .I Global Settings Specification section of configuration file. .TP .BI \-\-facility " facility" The same as .B syslog_facility keyword in .I Global Settings Specification of configuration files. .TP .BR \-f " or " \-\-force Force the daemon to start even if an instance of the daemon is already running. (This is of little value unless a non-default port is specified with .BR \-p , since, if one instance is bound to a port, the second one fails when it can not bind to the port.) .TP .BI \-\-limit " children" Overrides the keyword .B limit in .I Global Settings Specification section of configuration file. .TP .BI \-\-listen\-to " address" Overrides the keyword .B listen\_to in .I Global Settings Specification section of configuration file. .TP .BI \-\-locale " locale" Overrides the keyword .B locale in .I Global Settings Specification section of configuration file. .TP .B \-s The same as .B syslog keyword in .I Global Settings Specification of configuration files. .TP .BI \-L " file\fR or " \-\-logfile " file" The same as .B log_file keyword in .I Global Settings Specification of configuration files. .TP .BI \-\-pid\-file " file" The same as .B pid_file keyword in .I Global Settings Specification of configuration files. .TP .BI \-m " minutes \fR or "\-\-mark " minutes" Overrides the keyword .B timestamp in .I Global Settings Specification section of configuration file. .TP .BI \-\-default\-strategy " strategy" Overrides the keyword .B default_strategy in .I Global Settings Specification section of configuration file. .TP .BI \-\-without-strategy " strat1,strat2,..." The same as .B without_strategy keyword in .I Global Settings Specification of configuration files. .TP .BI \-\-add-strategy " strategy_name:description" The same as .B add_strategy keyword in .I Global Settings Specification of configuration files. .TP .BI \-\-fast-start The same as .B fast_start keyword in .I Global Settings Specification of configuration files. .TP .B \-\-without-mmap The same as .B without_mmap keyword in .I Global Settings Specification of configuration files. .TP .BR \-\-stdin2stdout When applied with \-\-inetd, each command obtained from stdin is output to stdout. This option is useful for debugging. .TP .BI \-l " option\fR or " \-\-log " option" The same as .B log_option keyword in .I Global Settings Specification of configuration files. .TP .BI \-d " option" The same as .B debug_option keyword in .I Global Settings Specification of configuration files. .RE .SH "CONFIGURATION FILE" .TP .B Introduction The configuration file defaults to .I @SYSCONFDIR@/dictd.conf but can be specified on the command line with the .B \-c option (see above). .RS .P The configuration file is read into memory at startup, and is not referenced again by .B dictd unless a signal 1 .B (SIGHUP) is received, which will cause .B dictd to reread the configuration file. .P The file is divided into sections. The Access Section should come first, followed by the Database Section, and the User Section. The Database Section is required; the others are optional, but they must be in the order listed here. .RE .TP .B Syntax The following keywords are valid in a configuration file: access, allow, deny, group, database, data, index, filter, prefilter, postfilter, name, include, user, authonly, site. Keywords are case sensitive. String arguments that contain spaces should be surrounded by double quotes. Without quoting, strings may contain alphanumeric characters and _, -, ., and *, but not spaces. Strings can be continued between lines. \\", \\\\, \\n, \\ are treated as double quote, backslash, new line and no symbol respectively. Comments start with # and extend to the end of the line. .TP .B Global Settings Section .RS .TP .BI "global {" " global settings specification " "}" Used to set global .B dictd setting such as log file, syslog facility, locale and so on. .TP .B EXAMPLE: See .I examples/dictd4.conf file from the distribution. .RE .TP .B Access Section .RS .TP .BI "access {" " access specification " "}" This section contains access restrictions for the server and all of the databases collectively. Per-database control is specified in the Database Section. .TP .B EXAMPLE: See .I examples/dictd3.conf file from the distribution. .RE .TP .B Database Section .RS .TP .BI database " string " "{ " "database specification " "}" The string specifies the name of the database (e.g., wn or web1913). (This is an arbitrary name selected by the administrator, and is not necessarily related to the file name or any name listed in the data file. A short, easy to type name is often selected for easy use with .BR "dict -d".) .P .RS .B EXAMPLE: See .I examples/dictd*.conf files from the distribution. .RE .RS .P .B NOTE: If the files specified in the database specification do not exist on the system, dictd may silently fail. .RE .TP .BI database_virtual " string " "{ " "virtual database specification " "}" This section specifies the virtual database. The .I string specifies the name of the database (e.g., en-ru or fren). .P .RS .B EXAMPLE: See .I examples/dictd_virtual.conf or .I examples/dictd_complex.conf files from the distribution. .RE .TP .BI database_plugin " string " "{ " "plugin specification " "}" This section specifies the plugin. The .I string specifies the name of the database. .P .RS .B EXAMPLE: See .I examples/dictd_plugin_dbi.conf or .I examples/dictd_complex.conf files from the distribution. .RE .TP .BI database_mime " string " "{ " "mime specification " "}" Traditionally, databases created for .I dictd contained plain text only because .B dictd releases before 1.10.0 didn't have full support of .I OPTION MIME option (consult with RFC-2229). This section describes the special database which behaves differently depending on whether .I OPTION MIME command was received from client or was not, i.e. the database created by this section allows to return to the client either a plain text or specially formatted content depending on whether DICT client supports (or wants to receive) MIMEized content or doesn't. The .I string specifies the name of the database. .RS .P .B NOTE: All this is about .I DEFINE command only. .I MATCH, SHOW DB, SHOW STRAT, SHOW INFO, SHOW SERVER and HELP commands return texts prepended with empty line only. .RE .P .RS .B EXAMPLE: See .I examples/dictd_mime.conf file from the distribution. .RE .TP .BI database_exit Excludes following databases from the '*' database. By default '*' means all databases available. Look at 'examples/dictd_virtual.conf' file for example configuration. .RS .P .B NOTE: If you use 'virtual' dictionaries, you should use this directive, otherwise you will search the same dictionary twice. .RE .TP .B User Section .RS .TP .BI user " string" " string" The first string specifies the username, and the second string specifies the shared secret for this username. When the AUTH command is used, the client will provide the username and a hashed version of the shared secret. If the shared secret matches, the user is said to have authenticated, and will have access to databases whose access specifications allow that user (by name, or by wildcard). If present, this section must appear last in the configuration file. There may be many user entries. The shared secret should be kept secret, as anyone who has access to it can access the shared databases (assuming access is not denied by domain name). .RE .TP .B Access Specification .RS Access specifications may occur in the Access Section or in the Database Section. The access specification will be described here. .P For allow, deny, and authonly, a star (*) may be used as a wild card that matches any number of characters. A question mark (?) may be used as a wildcard that matches a single character. For example, 10.0.0.* and *.edu are valid strings. .P Further, a range of IP addresses and an IP address followed by a netmask may be specified. For example, 10.0.0.0:10.0.0.255, 10.0.0.0/24, and 10.0.0.* all specify the same range of IP numbers. Notation cannot be combined on the same line. If the notation does not make sense, access will be denied by default. Use the .I "--debug auth" option to debug related problems. .P Note that these specifications take only one string per specification line. However, you can have multiple lines of each type. .P The syntax is as follows: .TP .BI allow " string" The string specifies a domain name or IP address which is allowed access to the server (in the Access Section) or to a database (in the Database Section). Note that more than one string is not permitted for a single "allow" line, but more than one "allow" lines are permitted in the configuration file. .TP .BI deny " string" The string specifies a domain name or IP address which is denied access to the server (in the Access Section) or to a database (in the Database Section). Note that if reverse DNS is not working, then only the IP number will be checked. Therefore, it is essential to deny networks based on IP number, since a denial based on domain name may not always be checked. .TP .BI authonly " string" This form is only useful in the Access Section. The string specifies a domain name or IP address which is allowed access to the server but not to any of the databases. All commands are valid except DEFINE, MATCH, and SHOW DB. More specifically AUTH is a valid command, and commands which access the databases are not allowed. .TP .BI user " string" This form is only useful in the Database Section. The string specifies a username that is allowed to access this database after a successful AUTH command is executed. .RE .RE .TP .B Global Settings Specification .RS This section describes the following parameters: .TP .BI port " string\_or\_number" Specifies the port or service name (e.g., 2628). The default is 2628, as specified in the DICT Protocol RFC, but may be changed in the .I defs.h file at compile time (DICT_DEFAULT_SERVICE). .TP .BI site " string" Used to specify the filename for the site information file, a flat text file which will be displayed in response to the SHOW SERVER command. .RS .P .B EXAMPLE: See .I examples/dictd4.conf file from the distribution. .RE .TP .BI site_no_banner " boolean" By default SHOW SERVER command outputs information about .I dictd version and an operating system type. This option disables this. .TP .BI site_no_uptime " boolean" By default SHOW SERVER command outputs information about uptime of .I dictd , a number of forks since startup and forks per hour. This option disables this. .TP .BI site_no_dblist " boolean" By default SHOW SERVER command outputs internal information about databases, such as a number of headwords, index size and so on. This option disables this. .TP .BI delay " number" Specifies the number of seconds a client may be idle before the server will close the connection. Idle time is defined to be the time the server is waiting for input and does not include the time the server spends searching the database. The default is 0 seconds (no limit), but may be changed in the .I defs.h file at compile time (DICT_DEFAULT_DELAY). .P .RS .B NOTE: Setting .I delay option disables .I limit_time option. Only one of them (last specified in .B dictd.conf ) is in effect. .P .B NOTE: Connections are closed without warning since no provision for premature connection termination is specified in the DICT protocol RFC. .RE .TP .BI depth " number" Specify the queue length for .BR listen (2). Specifies the number of pending socket connections which are queued by the operating system. Some operating systems may silently limit this value to 5 (older BSD systems) or 128 (Linux). The default is 10 but may be changed in the .I defs.h file at compile time (DICT_QUEUE_DEPTH). .TP .BI limit_childs " number" Specifies the number of daemons that may be running simultaneously. Each daemon services a single connection. If the limit is exceeded, a (serialized) connection will be made by the server process, and a response code 420 (server temporarily unavailable) will be sent to the client. This parameter should be adjusted to prevent the server machine from being overloaded by dict clients, but should not be set so low that many clients are denied useful connections. The default is 100, but may be changed in the .I defs.h file at compile time (DICT_DAEMON_LIMIT_CHILDS). .TP .BI limit " number" Synonym for .B limit_childs. For backward compatibility only. .TP .BI limit_matches " number" Specifies the maximum number of matches that can be returned by MATCH query. Zero means no limit. The default is 2000. .TP .BI limit_definitions " number" Specifies the maximum number of definitions that can be returned by DEFINE query. Zero means no limit. The default is 200. .TP .BI limit_time " number" Specifies the number of seconds a client may talk to the server before the server will close the connection. The default is 600 seconds (10 minutes), but may be changed in the .I defs.h file at compile time (DICT_DEFAULT_LIMIT_TIME). .RS .P .B NOTE: Setting .I limit_time option disables .I delay option. Only one of them (last specified in .B dictd.conf ) is in effect. .P .B NOTE: Connections are closed without warning since no provision for premature connection termination is specified in the DICT protocol RFC. .RE .TP .BI limit_queries " number" Specifies the number of queries (MATCH, DEFINE, SHOW DB etc.) that client may send to the server before the server will close the connection. Zero means no limit. The default is 2000, but may be changed in the .I defs.h file at compile time (DICT_DEFAULT_LIMIT_QUERIES). .TP .BI timestamp " number" How often a timestamp should be logged (int minutes). (This is effective only if logging has been enabled with the \-s or \-L option, or with a debugging option.) .TP .BI log_option " option" Specify a logging option. This is effective only if logging has been enabled with the .BR \-s " or " \-L option or in configuration file, or logging to the console has been activated with a debugging option (e.g., .BR "\-\-debug nodetach" . Only one option may be set with each invocation of this option; however, multiple invocations of this option may be made in configuration file or dictd command line. For instance: .br dictd -s --log stats --log found --log notfound .br is a valid command line, and sets three logging options. .RS .P Some of the more verbose logging options are used primarily for debugging the server code, and are not practical for normal use. .TP .B server Log server diagnostics. This is extremely verbose. .TP .B connect Log all connections. .TP .B stats Log all children terminations. .TP .B command Log all commands. This is extremely verbose. .TP .B client Log results of CLIENT command. .TP .B found Log all words found in the databases. .TP .B notfound Log all words not found in the databases. .TP .B timestamp When logging to a file, use a full timestamp like that which syslog would produce. Otherwise, no timestamp is made, making the files shorter. .TP .B host Log name of foreign host. .TP .B auth Log authentication failures. .TP .B min Set a minimal number of options. If logging is activated (to a file, or via syslog), and no options are set, then the minimal set of options will be used. If options are set, then only those options specified will be used. .TP .B all Set all of the options. .TP .B none Clear all of the options. .P To facilitate location of interesting information in the log file, entries are marked with initial letters indicating the class of the line being logged: .TP .B I Information about the server, connections, or termination statistics. These lines are generally not designed to be parsed automatically. .TP .B E Error messages. .TP .B C CLIENT command information. .TP .B D Definitions found in the databases searched. .TP .B M Matches found in the database searched. .TP .B N Matches which were not found in the databases searched. .TP .B T Trace of exact line sent by client. .TP .B A Authentication information. .P To preserve anonymity of the client, do .I not use the .B connect or .B host options. Clients may or may not send host information using the CLIENT command, but this should be an option that is selectable on the client side. .RE .TP .BI debug_option " string" Activate a debugging option. There are several, all of which are only useful to developers. They are documented here for completeness. A list can be obtained interactively by using .B \-d with an illegal option. .RS .TP .B verbose The same as .BR \-v " or " \-\-verbose . Adds verbosity to other options. .TP .B scan Debug the scanner for the configuration file. .TP .B parse Debug the parser for the configuration file. .TP .B search Debug the character folding and binary search routines. .TP .B init Report database initialization. .TP .B port Log client-side port number to the log file. .TP .B lev Debug Levenshtein search algorithm. .TP .B auth Debug the authorization routines. .TP .B nodetach Do not detach as a background process. Implies that a copy of the log file will appear on the standard output. .TP .B nofork Do not fork daemons to service requests. Be a single-threaded server. This option implies .BR nodetach , and is most useful for using a debugger to find the point at which daemon processes are dumping core. .TP .B alt Debugs .B altcompare in .IR index.c . .RE .TP .BI locale " string" Specifies the locale used for searching. If no locale is specified, the "C" locale is used. The locale used for the server should be the same as that used for dictfmt when the database was built (specifically, the locale under which the index was sorted). The locale should be specified for both 8-bit and UTF-8 formats. If locale contains utf8 or utf-8 substring, UTF-8 format is expected. Note that if your database is not in ASCII7 or UTF-8 format, then the dictd server will not be compliant to RFC 2229. .RS .P .BI NOTE If utf-8 or 8-bit dictionaries are included in the configuration file, and the appropriate --locale has not been specified, .B dictd will fail to start. This implies that .B dictd will not run with both utf-8 and 8-bit dictionaries in the configuration file. .RE .TP .BI add_strategy " strategy_name" "" " description" Adds strategy .I strategy_name with the description .I description. This new search strategy may be implemented with a help of plugins. Both .I strategy_name and .I description are .I strings. .TP .BI default_strategy " string" Set the server's default search strategy for MATCH search type. The compiled-in default is 'lev'. It is also possible to set default strategy per database. See .I default_strategy keyword in .I Database specification section. .TP .BI disable_strategy " string" Disable specified strategies. By default all implemented search strategies are enabled. It is also possible to disable strategies per database. See .I disable_strategy keyword in .I Database specification section. .TP .BI listen_to " string" Binds socket to the specified address. If you want to allow connections to dict server from localhost only, apply .br .B listen_to 127.0.0.1 .TP .BI syslog " string" Log using the .BR syslog (3) facility. .TP .BI syslog_facility " string" Specifies the syslog facility to use. The use of this option implies the .B \-s option to turn on logging via syslog. When the operating system libraries support SYSLOG_NAMES, the names used for this option should be those listed in .BR syslog.conf (5). Otherwise, the following names are used (assuming the particular facility is defined in the header files): auth, authpriv, cron, daemon, ftp, kern, lpr, mail, news, syslog, user, uucp, local0, local1, local2, local3, local4, local5, local6, and local7. .TP .BI log_file " string" Specify the file for logging. The filename specified is recomputed on each use using the .BR strftime (3) call. For example, a filename ending in ".%Y%m%d" will write to log files ending in the year, month, and date that the log entry was written. .RS .B NOTE: If .B dictd does not have write permission for this file, it will silently fail. .RE .TP .BI pid_file " string" The specified filename will be created to contain the process id of the main .B dictd process. The default is .I /var/run/dictd.pid .TP .BI fast\_start By default, dictd creates (in memory) additional index to make the search faster. This option disables this behaviour and makes startup faster. .TP .BI without\_mmap do not use the mmap(2) function and read entire files into memory instead. Use this option, if you know exactly what you are doing. .RE .TP .B Database Specification .RS The database specification describes the database: .TP .BI data " string" Specifies the filename for the flat text database. If the filename does not begin with '.' or '/', it is prepended with $datadir/. It is a compile time option. You can change this behaviour by editing Makefile or running ./configure --datadir=... .TP .BI index " string" Specifies the filename for the index file. Path matter is similar to that described above in "data" option . .TP .BI index_suffix " string" This is optional index file to make 'suffix' search strategy faster (binary search). It is generated by 'dictfmt_index2suffix'. Run "dictfmt_index2suffix --help" for more information. Path matter is similar to that described above in "data" option . .TP .BI index_word " string" This is optional index file to make 'word' search strategy faster (binary search). It is generated by 'dictfmt_index2word'. Run "dictfmt_index2word --help" for more information. Path matter is similar to that described above in "data" option . .TP .BI prefilter " string" Specifies the prefilter command. When a chunk of the compressed database is read, it will be filtered with this filter before being decompressed. This may be used to provide some additional compression that knows about the data and can provide better compression than the LZ77 algorithm used by zlib. .TP .BI postfilter " string" Specifies the postfilter command. When a chunk of the compressed database is read, it will be filtered with this filter before the offset and length for the entry are used to access data. This is provided for symmetry with the prefilter command, and may also be useful for providing additional database compression. .TP .BI filter " string" Specifies the filter command. After the entry is extracted from the database, it will be filtered with this filter. This may be used to provide formatting for the entry (e.g., for html). .TP .BI name " string" Specifies the short name of the database (e.g., "1913 Webster's"). If the string begins with @, then it specifies the headword to look up in the dictionary to find the short name of the database. The default is "@00-database-short", but this may be changed in the .I defs.h file at compile time (DICT_SHORT_ENTRY_NAME). .TP .BI info " string" Specifies the information about database. If the string begins with @, then it specifies the headword to look up in the dictionary to find information. The default is "@00-database-info", but this may be changed in the .I defs.h file at compile time (DICT_INFO_ENTRY_NAME). .TP .BI invisible Makes dictionary invisible to the clients i.e. this dictionary will not be recognized or shown by DEFINE, MATCH, SHOW INFO, SHOW SERVER and SHOW DB commands. If some definitions or matches are found in invisible dictionary, the name of the upper visible virtual dictionary is returned. Dictionaries '*' and '!' don't include invisible ones. .B NOTE: Invisible dictionaries are completely inaccessible (and invisible) to the client unless they are included to the virtual or MIME dictionary (See .I database_virtual or .I database_mime database sections). .TP .BI disable_strategy " string" Disables the specified strategy for database. This may be useful for slow dictionaries (plugins) or for dictionaries included to virtual ones. For an example see file examples/dictd_complex.conf. .TP .BI default_strategy " string" Specifies the strategy which will be used if the database is accessed using the strategy '.'. I.e. this directive is the way to set the preferred search strategy per database. For example, instead of strategy .I lev , the strategy .I word may be preferred for databases mainly containing the multiword phrases but the single words. .RE .TP .B Virtual Database Specification .RS The virtual database specification describes the virtual database: .TP .BI database_list " string" Specifies a list of databases which are included into the virtual database. Database names are in the string and are separated by comma. .TP .BI name " string" Specifies the short name of the database. See .I database specification .TP .BI info " string" Specifies the information about database. See .I database specification .TP .BI invisible Makes dictionary invisible to the clients. See .I database specification .TP .BI disable_strategy " string" Disables the specified strategy for database. See .I database specification .RE .TP .B Plugin Specification .RS .TP .BI plugin " string" Specifies a filename of the plugin. .TP .BI data " string" Specifies data for initializing plugin. .TP .BI name " string" Specifies the short name of the database. See .I Database Specification for more information. .TP .BI info " string" Specifies the information about database. See .I Database Specification for more information. .TP .BI invisible Makes dictionary invisible to the clients. See .I Database Specification for more information. .TP .BI disable_strategy " string" Disables the specified strategy for database. See .I Database Specification for more information. .TP .BI default_strategy " string" Sets the default search strategy for database. See .I Database Specification for more information. .RE .B Mime Specification .RS .TP .BI dbname_nomime " string" Specifies the real database name which is used in case .I OPTION MIME command was NOT received from a client. .TP .BI dbname_mime " string" Specifies the real database name which is used in case .I OPTION MIME command WAS received from a client. A necessary MIME header is set while creating a database. See .I dictfmt(1) for option .I --mime-header. .TP .BI name " string" Specifies the short name of the database. See .I Database Specification for more information. .TP .BI info " string" Specifies the information about database. See .I Database Specification for more information. .TP .BI invisible Makes dictionary invisible to the clients. See .I Database Specification for more information. .TP .BI disable_strategy " string" Disables the specified strategy for database. See .I Database Specification for more information. .TP .BI default_strategy " string" Sets the default search strategy for database. See .I Database Specification for more information. .RE .TP .BI include " string" The text of the file "string" (usually a database specification) will be read as if it appeared at this location in the configuration file. Nested includes are not permitted. .SH "DETERMINATION OF ACCESS LEVEL" When a client connects, the global access specification is scanned, in order, until a specification matches. If no access specification exists, all access is allowed (e.g., the action is the same as if "allow *" was the only item in the specification). For each item, both the hostname and IP are checked. For example, consider the following access specification: .RS allow 10.42.* .br authonly *.edu .br deny * .RE With this specification, all clients in the 10.42 network will be allowed access to unrestricted databases; all clients from *.edu sites will be allowed to authenticate, but will be denied access to all databases, even those which are otherwise unrestricted; and all other clients will have their connection terminated immediately. The 10.42 network clients can send an AUTH command and gain access to restricted databases. The *.edu clients must send an AUTH command to gain access to any databases, restricted or unrestricted. .P When the AUTH command is sent, the access list for each database is scanned, in order, just as the global access list is scanned. However, after authentication, the client has an associated username. For example, consider the following access specification: .RS user u1 .br deny *.com .br user u2 .br allow * .RE If the client authenticated as u1, then the client will have access to this database, even if the client comes from a *.com site. In contrast, if the client authenticated as u2, the client will only have access if it does not come from a *.com site. In this case, the "user u2" is redundant, since that client would also match "allow *". .P .B Warning: Checks are performed for domain names and for IP addresses. However, if reverse DNS for a specific site is not working, it is possible that a domain name may not be available for checking. Make sure that all denials use IP addresses. (And consider a future enhancement: if a domain name is not available, should denials that depend on a domain name match anything? This is the more conservative viewpoint, but it is not currently implemented.) .SH "SEARCH ALGORITHMS" The DICT standard specifies a few search algorithms that must be implemented, and permits others to be supported on a server-dependent basis. The following search strategies are supported by this server. Note that .I all strategies are case insensitive. Most ignore non-alphanumeric, non-whitespace characters. .TP .B exact An exact match. This algorithm uses a binary search and is one of the fastest search algorithms available. .TP .B lev The Levenshtein algorithm (string edit distance of one). This algorithm searches for all words which are within an edit distance of one from the target word. An "edit" means an insertion, deletion, or transposition. This is a rapid algorithm for correcting spelling errors, since many spelling errors are within a Levenshtein distance of one from the original word. .TP .B prefix Prefix match. This algorithm also uses a binary search and is very fast. .TP .B nprefix Like .I prefix but returns the specified range of matches. For example, when .I prefix strategy returns 1000 matches, you can get only 100 ones skipping the first 800 matches. This is made by specified these limits in a query like this: 800#100#app, where 800 is skip count, 100 is a number of matches you want to get and "app" is your query. This strategy allows to implement DICT client with fast autocompletion (although it is not trivial) just like many standalone dictionary programs do. .P .RS .B NOTE: If you access the dictionary "*" (or virtual one) with .I nprefix strategy, the same range is set for each database in it, but globally for all matches found in all databases. .RE .P .RS .B NOTE: In case you access non-english dictionary the returned matches may be (and mostly will be) NOT ordered in alphabetic order. .RE .TP .B re POSIX 1003.2 (modern) regular expression search. Modern regular expressions are the ones used by .BR egrep (1). These regular expressions allow predefined character classes (e.g., [[:alnum:]], [[:alpha:]], [[:digit:]], and [[:xdigit:]] are useful for this application); uses * to match a sequence 0 or more matches of the previous atom; uses + to match a sequence of 1 or more matches of the previous atom; uses ? to match a sequence of 0 or 1 matches of the previous atom; used ^ to match the beginning of a word, uses $ to match the end of a word, and allows nested subexpression and alternation with () and |. For example, "(foo|bar)" matches all words that contain either "foo" or "bar". To match these special characters, they must be quoted with two backslashes (due to the quoting characteristics of the server). .B Warning: Regular expression matches can take 10 to 300 times longer than substring matches. On a busy server, with many databases, this can required more than 5 minutes of waiting time, depending on the complexity of the regular expression. .TP .B regexp Old (basic) regular expressions. These regular expressions don't support |, +, or ?. Groups use escaped parentheses. While modern regular expressions are generally easier to use, basic regular expressions have a back reference feature. This can be used to match a second occurrence of something that was already matched. For example, the following expression finds all words that begin and end with the same three letters: .RS .nf ^\\\\(...\\\\).*\\\\1$ .fi .P Note the use of the double backslashes to escape the special characters. This is required by the DICT protocol string specification (a single backslash quotes the next character -- we use two to get a single backslash through to the regular expression engine). .B Warning: Note that the use of backtracking is even slower than the use of general regular expressions. .RE .TP .B soundex The Soundex algorithm, a classic algorithm for finding words that sound similar to each other. The algorithm encodes each word using the first letter of the word and up to three digits. Since the first letter is known, this search is relatively fast, and it sometimes good for correcting spelling errors when the Levenshtein algorithm doesn't help. .TP .B substring Match a substring anywhere in the headword. This search strategy uses a modified Boyer-Moore-Horspool algorithm. Since it must search the whole index file, it is not as fast as the exact and prefix matches. .TP .B suffix Suffix match. This search strategy also uses a modified Boyer-Moore-Horspool algorithm, and is as fast as the substring search. If the optional index_suffix string file is listed in the configuration file this search is much faster. .TP .B word Match any single word, even if part of a multi-word entry. If the optional index_word string file is listed in the configuration file this search strategy works much faster. .TP .B first Match the first word that begins a multi-word entry. .TP .B last Match the last word that ends a multi-word entry. If the optional index_suffix string file is listed in the configuration file this search strategy works much faster. .SH "DATABASE FORMAT" Databases for .B dictd are distributed separately. A database consists of two files. One is a flat text file, the other is the index. .P The flat text file contains dictionary entries (or any other suitable data), and the index contains tab-delimited tuples consisting of the headword, the byte offset at which this entry begins in the flat text file, and the length of the entry in bytes. The offset and length are encoded using base 64 encoding using the 64-character subset of International Alphabet IA5 discussed in RFC 1421 (printable encoding) and RFC 1522 (base64 MIME). Encoding the offsets in base 64 saves considerable space when compared with the usual base 10 encoding, while still permitting tab characters (ASCII 9) to be used for delimiting fields in a record. Each record ends with a newline (ASCII 10), so the index file is human readable. .P Some headwords are used by .I dictd especially .P .BI 00-database-info Containts the information about database which is returned by SHOW INFO command, unless it is specified in the configuration file. .P .BI 00-database-short Containts the short name of the database which is returned by SHOW DB command, unless it is specified in the configuration file. See dictfmt -s. .P .BI 00-database-url URL where original dictionary sources were obtained from. See dictfmt -u. This headword is not used by .I dictd .P .BI 00-database-utf8 Presents if dictionary is encoded using UTF-8. See dictfmt --utf8 .P .BI 00-database-8bit-new Presents if dictionary is encoded using 8-BIT character set (not ASCII and not UTF8). See dictfmt --locale. .P The flat text file may be compressed using .BR gzip (1) (not recommended) or .BR dictzip (1) (highly recommended). Optimal speed will be obtained using an uncompressed file. However, the .B gzip compression algorithm works very well on plain text, and can result in space savings typically between 60 and 80%. Using a file compressed with .BR gzip (1) is not recommended, however, because random access on the file can only be accomplished by serially decompressing the whole file, a process which is prohibitively slow. .BR dictzip (1) uses the same compression algorithm and file format as does .BR gzip (1), but provides a table that can be used to randomly access compressed blocks in the file. The use of 50-64kB blocks for compression typically degrades compression by less than 10%, while maintaining acceptable random access capabilities for all data in the file. As an added benefit, files compressed with .BR dictzip (1) can be decompressed with .BR gzip (1) or .BR zcat (1). (Note: recompressing a .BR dictzip 'd file using, for example, .BR znew (1) will destroy the random access characteristics of the file. Always compress data files using .BR dictzip (1).) .SH "SIGNALS" .P .B SIGHUP causes dictd to reread configuration file and reinitialize databases. .P .B SIGUSR1 causes dictd to unload databases. Then .I dictd returns 420 status (instead of 220). To load databases again, send .B SIGHUP signal. Because database files are .I mmap'ed(2) , it is impossible to update them while .I dictd is running. So, if you need to update database files and reread configuration file, first, send .B SIGUSR1 signal to .I dictd to unload databases, update files, and then send .B SUGHUP signal to load them again. .SH "COPYING" The main source files for the .B dictd server and the .B dictzip compression program were written by Rik Faith (faith@dict.org) and are distributed under the terms of the GNU General Public License. If you need to distribute under other terms, write to the author. .P The main libraries used by these programs (zlib, regex, libmaa) are distributed under different terms, so you may be able to use the libraries for applications which are incompatible with the GPL -- please see the copyright notices and license information that come with the libraries for more information, and consult with your attorney to resolve these issues. .SH "BUGS" The regular expression searches do not ignore non-whitespace, non-alphanumeric characters as do the other searches. In practice, this isn't much of a problem. .SH "WARNINGS" Conformance of regular expressions (used by 're' and 'regexp' search strategies) to ERE and BRE depends on library you build dictd with. Whether 're' and 'regex' strategies support utf8 depends on library you build dictd with. .SH "FILES" .TP .I @SYSCONFDIR@/dictd.conf .B dictd configuration file .TP .I @SBINDIR@/dictd .B dictd daemon itself .TP .I /var/run/dictd.pid File for storing pid of .B dictd daemon .TP .I @DATADIR@ The default directory for .B dictd databases (.index and .dict[.dz] files) .SH "SEE ALSO" .BR examples/dictd*.conf, .BR dictfmt (1), .BR dict (1), .BR dictzip (1), .BR gunzip (1), .BR zcat (1), .BR webster (1), .B RFC 2229 dictd-1.12.1+dfsg.orig/dictd.c0000644000000000000000000013154311512364007014500 0ustar rootroot/* dictd.c -- * Created: Fri Feb 21 20:09:09 1997 by faith@dict.org * Copyright 1997-2000, 2002 Rickard E. Faith (faith@dict.org) * Copyright 2002-2008 Aleksey Cheusov (vle@gmx.net) * * 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 1, 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. */ #include "dictd.h" #include "str.h" #include "servparse.h" #include "strategy.h" #include "index.h" #include "data.h" #include "parse.h" #ifdef USE_PLUGIN #include "plugin.h" #endif #include /* initgroups */ #include /* getpwuid */ #include /* setlocale */ #include #include #include #define MAXPROCTITLE 2048 /* Maximum amount of proc title we'll use. */ #undef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) #ifndef UID_NOBODY #define UID_NOBODY 65534 #endif #ifndef GID_NOGROUP #define GID_NOGROUP 65534 #endif #ifndef SA_RESTART /* ... and hope for the best */ #define SA_RESTART 0 #endif extern int yy_flex_debug; static int _dict_daemon; static int _dict_reaps; static char *_dict_argvstart; static int _dict_argvlen; int _dict_forks; int default_strategy_set; /* 1 if set by command line option */ int logOptions = 0; const char *logFile = NULL; int logFile_set; /* 1 if set by command line option */ const char *pidFile = "/var/run/dictd.pid"; int pidFile_set; /* 1 if set by command line option */ const char *daemon_service = DICT_DEFAULT_SERVICE; int daemon_service_set; /* 1 if set by command line option */ int _dict_daemon_limit_childs = DICT_DAEMON_LIMIT_CHILDS; int _dict_daemon_limit_childs_set; /* 1 if set by command line option */ int _dict_daemon_limit_matches = DICT_DAEMON_LIMIT_MATCHES; int _dict_daemon_limit_defs = DICT_DAEMON_LIMIT_DEFS; int _dict_daemon_limit_time = DICT_DAEMON_LIMIT_TIME; int _dict_daemon_limit_queries = DICT_DAEMON_LIMIT_QUERIES; int _dict_markTime = 0; int _dict_markTime_set; /* 1 if set by command line option */ const char *locale = NULL; int locale_set; /* 1 if set by command line option */ int client_delay = DICT_DEFAULT_DELAY; int client_delay_set; /* 1 if set by command line option */ int depth = DICT_QUEUE_DEPTH; int depth_set; /* 1 if set by command line option */ int useSyslog = 0; int syslog_facility_set; /* 1 if set by command line option */ const char *preprocessor = NULL; const char *bind_to = NULL; int bind_to_set; /* 1 if set by command line option */ /* information about dict server, i.e. text returned by SHOW SERVER command */ const char *site_info = NULL; int site_info_no_banner = 0; int site_info_no_uptime = 0; int site_info_no_dblist = 0; int inetd = 0; int need_reload_config = 0; int need_unload_databases = 0; int databases_unloaded = 0; static const char *configFile = DICT_CONFIG_PATH DICTD_CONFIG_NAME; static void dict_close_databases (dictConfig *c); static void sanity (const char *confFile); static void dict_init_databases (dictConfig *c); static void dict_config_print (FILE *stream, dictConfig *c); static void postprocess_filenames (dictConfig *dc); void dict_initsetproctitle( int argc, char **argv, char **envp ) { int i; _dict_argvstart = argv[0]; for (i = 0; envp[i]; i++) continue; if (i) _dict_argvlen = envp[i-1] + strlen(envp[i-1]) - _dict_argvstart; else _dict_argvlen = argv[argc-1] + strlen(argv[argc-1]) - _dict_argvstart; argv[1] = NULL; } void dict_setproctitle( const char *format, ... ) { va_list ap; int len; char buf[MAXPROCTITLE]; va_start( ap, format ); vsnprintf( buf, MAXPROCTITLE, format, ap ); va_end( ap ); if ((len = strlen(buf)) > MAXPROCTITLE-1) err_fatal( __func__, "buffer overflow (%d)\n", len ); buf[ MIN(_dict_argvlen,MAXPROCTITLE) - 1 ] = '\0'; strcpy( _dict_argvstart, buf ); memset( _dict_argvstart+len, 0, _dict_argvlen-len ); } const char *dict_format_time( double t ) { static int current = 0; static char buf[10][128]; /* Rotate 10 buffers */ static char *this; long int s, m, h, d; this = buf[current]; if (++current >= 10) current = 0; if (t < 600) { snprintf( this, sizeof (buf [0]), "%0.3f", t ); } else { s = (long int)t; d = s / (3600*24); s -= d * 3600 * 24; h = s / 3600; s -= h * 3600; m = s / 60; s -= m * 60; if (d) snprintf( this, sizeof (buf [0]), "%ld+%02ld:%02ld:%02ld", d, h, m, s ); else if (h) snprintf( this, sizeof (buf [0]), "%02ld:%02ld:%02ld", h, m, s ); else snprintf( this, sizeof (buf [0]), "%02ld:%02ld", m, s ); } return this; } static int waitpid__exit_status (int status) { if (WIFEXITED(status)){ return WEXITSTATUS(status); }else if (WIFSIGNALED(status)){ return 128 + WTERMSIG(status); }else{ return -1; } } static void reaper( int dummy ) { #if 0 union wait status; #else int status; #endif pid_t pid; while ((pid = wait3(&status, WNOHANG, NULL)) > 0) { ++_dict_reaps; if (flg_test(LOG_SERVER)) log_info( ":I: Reaped %d%s, exit status %i\n", pid, _dict_daemon ? " IN CHILD": "", waitpid__exit_status (status)); } } static int start_daemon( void ) { pid_t pid; ++_dict_forks; switch ((pid = fork())) { case 0: ++_dict_daemon; break; case -1: log_info( ":E: Unable to fork daemon\n" ); alarm(10); /* Can't use sleep() here */ pause(); break; default: if (flg_test(LOG_SERVER)) log_info( ":I: Forked %d\n", pid ); break; } return pid; } static const char * signal2name (int sig) { static char name [50]; switch (sig) { case SIGHUP: return "SIGHUP"; case SIGINT: return "SIGINT"; case SIGQUIT: return "SIGQUIT"; case SIGILL: return "SIGILL"; case SIGTRAP: return "SIGTRAP"; case SIGTERM: return "SIGTERM"; case SIGPIPE: return "SIGPIPE"; case SIGALRM: return "SIGALRM"; default: snprintf (name, sizeof (name), "Signal %d", sig); return name; } } static void log_sig_info (int sig) { log_info ( ":I: %s: c/f = %d/%d; %sr %su %ss\n", signal2name (sig), _dict_comparisons, _dict_forks, dict_format_time (tim_get_real ("dictd")), dict_format_time (tim_get_user ("dictd")), dict_format_time (tim_get_system ("dictd"))); } static void unload_databases (void) { dict_close_databases (DictConfig); DictConfig = NULL; } static void reload_config (void) { dict_close_databases (DictConfig); if (!access(configFile,R_OK)){ prs_file_pp (preprocessor, configFile); postprocess_filenames (DictConfig); } sanity (configFile); if (dbg_test (DBG_VERBOSE)) dict_config_print( NULL, DictConfig ); dict_init_databases (DictConfig); } static void xsigaddset (sigset_t *set, int signo) { if (sigaddset (set, signo)){ log_error ("", "sigaddset(2) failed: %s\n", strerror (errno)); } } static void xsigprocmask (int how, const sigset_t *set, sigset_t *oset) { if (sigprocmask (how, set, oset)){ log_error ("", "sigaddset(2) failed: %s\n", strerror (errno)); } } static void block_signals (void) { sigset_t set; sigemptyset (&set); xsigaddset (&set, SIGALRM); xsigaddset (&set, SIGCHLD); xsigprocmask (SIG_BLOCK, &set, NULL); } static void unblock_signals (void) { sigset_t set; sigemptyset (&set); xsigaddset (&set, SIGALRM); xsigaddset (&set, SIGCHLD); xsigprocmask (SIG_UNBLOCK, &set, NULL); } static void handler( int sig ) { const char *name = NULL; time_t t; name = signal2name (sig); if (_dict_daemon) { daemon_terminate( sig, name ); } else { tim_stop( "dictd" ); switch (sig){ case SIGALRM: if (_dict_markTime > 0){ time(&t); log_info( ":t: %24.24s; %d/%d %sr %su %ss\n", ctime(&t), _dict_forks - _dict_reaps, _dict_forks, dict_format_time( tim_get_real( "dictd" ) ), dict_format_time( tim_get_user( "dictd" ) ), dict_format_time( tim_get_system( "dictd" ) ) ); alarm(_dict_markTime); return; } break; } log_sig_info (sig); } if (!dbg_test(DBG_NOFORK) || sig != SIGALRM) exit(sig+128); } static const char *postprocess_filename (const char *fn, const char *prefix) { char *new_fn; if (!fn) return NULL; if (fn [0] != '/' && fn [0] != '.'){ new_fn = xmalloc (2 + strlen (prefix) + strlen (fn)); strcpy (new_fn, prefix); strcat (new_fn, fn); return new_fn; }else{ return xstrdup (fn); } } const char *postprocess_plugin_filename (const char *fn) { return postprocess_filename (fn, DICT_PLUGIN_PATH); } const char *postprocess_dict_filename (const char *fn) { return postprocess_filename (fn, DICT_DICTIONARY_PATH); } static void postprocess_filenames (dictConfig *dc) { lst_Position p; dictDatabase *db; LST_ITERATE(dc -> dbl, p, db) { db -> dataFilename = postprocess_dict_filename (db -> dataFilename); db -> indexFilename = postprocess_dict_filename (db -> indexFilename); db -> indexsuffixFilename = postprocess_dict_filename (db -> indexsuffixFilename); db -> indexwordFilename = postprocess_dict_filename (db -> indexwordFilename); db -> pluginFilename = postprocess_plugin_filename (db -> pluginFilename); } site_info = postprocess_dict_filename (site_info); } static void handler_sighup (int sig) { log_sig_info (sig); need_reload_config = 1; } static void handler_sigusr1 (int sig) { log_sig_info (sig); need_unload_databases = 1; } static void setsig( int sig, void (*f)(int), int sa_flags ) { struct sigaction sa; sa.sa_handler = f; sigemptyset(&sa.sa_mask); sa.sa_flags = sa_flags; sigaction(sig, &sa, NULL); } struct access_print_struct { FILE *s; int offset; }; static int access_print( const void *datum, void *arg ) { dictAccess *a = (dictAccess *)datum; struct access_print_struct *aps = (struct access_print_struct *)arg; FILE *s = aps->s; int offset = aps->offset; int i; const char *desc; for (i = 0; i < offset; i++) fputc( ' ', s ); switch (a->type) { case DICT_DENY: desc = "deny"; break; case DICT_ALLOW: desc = "allow"; break; case DICT_AUTHONLY: desc = "authonly"; break; case DICT_USER: desc = "user"; break; case DICT_GROUP: desc = "group"; break; /* Not implemented. */ default: desc = "unknown"; break; } fprintf( s, "%s %s\n", desc, a->spec ); return 0; } static void acl_print( FILE *s, lst_List l, int offset) { struct access_print_struct aps; int i; aps.s = s; aps.offset = offset + 3; for (i = 0; i < offset; i++) fputc( ' ', s ); fprintf( s, "access {\n" ); lst_iterate_arg( l, access_print, &aps ); for (i = 0; i < offset; i++) fputc( ' ', s ); fprintf( s, "}\n" ); } static int user_print( const void *key, const void *datum, void *arg ) { const char *username = (const char *)key; const char *secret = (const char *)datum; FILE *s = (FILE *)arg; if (dbg_test(DBG_AUTH)) fprintf( s, "user %s %s\n", username, secret ); else fprintf( s, "user %s *\n", username ); return 0; } static int config_print( const void *datum, void *arg ) { dictDatabase *db = (dictDatabase *)datum; FILE *s = (FILE *)arg; fprintf( s, "database %s {\n", db->databaseName ); if (db->dataFilename) fprintf( s, " data %s\n", db->dataFilename ); if (db->indexFilename) fprintf( s, " index %s\n", db->indexFilename ); if (db->indexsuffixFilename) fprintf( s, " index_suffix %s\n", db->indexsuffixFilename ); if (db->indexwordFilename) fprintf( s, " index_word %s\n", db->indexwordFilename ); if (db->filter) fprintf( s, " filter %s\n", db->filter ); if (db->prefilter) fprintf( s, " prefilter %s\n", db->prefilter ); if (db->postfilter) fprintf( s, " postfilter %s\n", db->postfilter ); if (db->databaseShort) fprintf( s, " name %s\n", db->databaseShort ); if (db->acl) acl_print( s, db->acl, 3 ); fprintf( s, "}\n" ); return 0; } static void dict_config_print( FILE *stream, dictConfig *c ) { FILE *s = stream ? stream : stderr; if (c->acl) acl_print( s, c->acl, 0 ); lst_iterate_arg( c->dbl, config_print, s ); if (c->usl) hsh_iterate_arg( c->usl, user_print, s ); } static const char *get_entry_info( dictDatabase *db, const char *entryName ) { dictWord *dw; lst_List list = lst_create(); char *pt, *buf; size_t len; if ( 0 >= dict_search ( list, entryName, db, DICT_STRAT_EXACT, 0, NULL, NULL, NULL )) { #ifdef USE_PLUGIN call_dictdb_free (DictConfig->dbl); #endif lst_destroy( list ); return NULL; } dw = lst_nth_get( list, 1 ); assert (dw -> database); buf = pt = dict_data_obtain( dw -> database, dw ); if (!strncmp (pt, "00database", 10) || !strncmp (pt, "00-database", 11)){ while (*pt != '\n') ++pt; ++pt; } while (*pt == ' ' || *pt == '\t') ++pt; len = strlen(pt); if (pt [len - 1] == '\n') pt [len - 1] = '\0'; #ifdef USE_PLUGIN call_dictdb_free (DictConfig->dbl); #endif dict_destroy_list( list ); pt = xstrdup (pt); xfree (buf); return pt; } static dictDatabase *dbname2database (const char *dbname) { dictDatabase *db = NULL; lst_Position db_pos = lst_init_position (DictConfig->dbl); while (db_pos){ db = lst_get_position (db_pos); if (!strcmp (db -> databaseName, dbname)){ return db; } db_pos = lst_next_position (db_pos); } return NULL; } static lst_List string2virtual_db_list (char *s) { int len, i; lst_List virtual_db_list; char *p; dictDatabase *db = NULL; p = s; len = strlen (s); virtual_db_list = lst_create (); for (i = 0; i <= len; ++i){ if (s [i] == ',' || s [i] == '\n' || s [i] == '\0'){ s [i] = '\0'; if (*p){ db = dbname2database (p); if (db){ lst_append (virtual_db_list, db); }else{ log_info( ":E: Unknown database '%s'\n", p ); PRINTF(DBG_INIT, (":E: Unknown database '%s'\n", p)); exit (2); } } p = s + i + 1; } } return virtual_db_list; } static int init_virtual_db_list (const void *datum) { lst_List list; dictDatabase *db = (dictDatabase *)datum; dictWord *dw; char *buf; int ret; if (db -> database_list){ buf = xstrdup (db -> database_list); db -> virtual_db_list = string2virtual_db_list (buf); xfree (buf); }else{ if (!db -> index) return 0; list = lst_create(); ret = dict_search ( list, DICT_FLAG_VIRTUAL, db, DICT_STRAT_EXACT, 0, NULL, NULL, NULL); switch (ret){ case 1: case 2: dw = (dictWord *) lst_pop (list); buf = dict_data_obtain (db, dw); dict_destroy_datum (dw); db -> virtual_db_list = string2virtual_db_list (buf); xfree (buf); break; case 0: break; default: err_fatal ( __func__, "index file contains more than one %s entry", DICT_FLAG_VIRTUAL); } dict_destroy_list (list); } return 0; } static int init_mime_db_list (const void *datum) { dictDatabase *db = (dictDatabase *)datum; if (!db -> mime_db) return 0; /* MIME */ if (db -> mime_mimeDbname){ db -> mime_mimeDB = dbname2database (db -> mime_mimeDbname); if (!db -> mime_mimeDB){ err_fatal ( __func__, "Incorrect database name '%s'\n", db -> mime_mimeDbname); } }else{ err_fatal ( __func__, "MIME database '%s' has no mime_dbname keyword\n", db -> databaseName); } /* NO MIME */ if (db -> mime_nomimeDbname){ db -> mime_nomimeDB = dbname2database (db -> mime_nomimeDbname); if (!db -> mime_nomimeDB){ err_fatal ( __func__, "Incorrect database name '%s'\n", db -> mime_nomimeDbname); } }else{ err_fatal ( __func__, "MIME database '%s' has no nomime_dbname keyword\n", db -> databaseName); } return 0; } static int init_plugin( const void *datum ) { #ifdef USE_PLUGIN dictDatabase *db = (dictDatabase *)datum; dict_plugin_init (db); #endif return 0; } void dict_disable_strat (dictDatabase *db, const char* strategy) { int strat = -1; int array_size = get_max_strategy_num () + 1; assert (db); assert (strategy); if (!db -> strategy_disabled){ db -> strategy_disabled = xmalloc (array_size * sizeof (int)); memset (db -> strategy_disabled, 0, array_size * sizeof (int)); } strat = lookup_strategy_ex (strategy); assert (strat >= 0); db -> strategy_disabled [strat] = 1; } static void init_database_alphabet (dictDatabase *db) { int ret; lst_List l; const dictWord *dw; char *data; if (!db -> normal_db) return; l = lst_create (); ret = dict_search_database_ (l, DICT_FLAG_ALPHABET, db, DICT_STRAT_EXACT); if (ret){ dw = (const dictWord *) lst_top (l); data = dict_data_obtain (db, dw); db -> alphabet = data; data = strchr (db -> alphabet, '\n'); if (data) *data = 0; } dict_destroy_list (l); } static void init_database_default_strategy (dictDatabase *db) { int ret; lst_List l; const dictWord *dw; char *data; int def_strat = -1; char *p; if (!db -> normal_db) return; if (db -> default_strategy > 0){ /* already set by `default_strategy' directive*/ return; } l = lst_create (); ret = dict_search_database_ (l, DICT_FLAG_DEFAULT_STRAT, db, DICT_STRAT_EXACT); if (ret){ dw = (const dictWord *) lst_top (l); data = dict_data_obtain (db, dw); for (p=data; *p && isalpha ((unsigned char) *p); ++p){ } *p = '\0'; def_strat = lookup_strategy (data); if (-1 == def_strat){ PRINTF (DBG_INIT, (":I: `%s' is not supported by dictd\n", data)); }else{ db -> default_strategy = def_strat; } xfree (data); } dict_destroy_list (l); } static int init_database_mime_header (const void *datum) { dictDatabase *db = (dictDatabase *) datum; int ret; lst_List l; const dictWord *dw; char *data; if (!db -> normal_db) return 0; if (db -> mime_header){ /* already set by `mime_header' directive*/ return 0; } l = lst_create (); ret = dict_search_database_ (l, DICT_FLAG_MIME_HEADER, db, DICT_STRAT_EXACT); if (ret){ dw = (const dictWord *) lst_top (l); data = dict_data_obtain (db, dw); db -> mime_header = xstrdup (data); xfree (data); } dict_destroy_list (l); return 0; } static int init_database( const void *datum ) { dictDatabase *db = (dictDatabase *)datum; const char *strat_name = NULL; PRINTF (DBG_INIT, (":I: Initializing '%s'\n", db->databaseName)); if (db->indexFilename){ PRINTF (DBG_INIT, (":I: Opening indices\n")); } db->index = dict_index_open( db->indexFilename, 1, NULL ); if (db->indexFilename){ PRINTF (DBG_INIT, (":I: .index \n")); } if (db->index){ db->index_suffix = dict_index_open( db->indexsuffixFilename, 0, db->index); db->index_word = dict_index_open( db->indexwordFilename, 0, db->index); } if (db->index_suffix){ PRINTF (DBG_INIT, (":I: .indexsuffix \n")); db->index_suffix->flag_8bit = db->index->flag_8bit; db->index_suffix->flag_utf8 = db->index->flag_utf8; db->index_suffix->flag_allchars = db->index->flag_allchars; } if (db->index_word){ PRINTF (DBG_INIT, (":I: .indexword \n")); db->index_word->flag_utf8 = db->index->flag_utf8; db->index_word->flag_8bit = db->index->flag_8bit; db->index_word->flag_allchars = db->index->flag_allchars; } if (db->dataFilename){ PRINTF (DBG_INIT, (":I: Opening data\n")); } db->data = dict_data_open( db->dataFilename, 0 ); init_database_alphabet (db); if (db -> alphabet){ PRINTF (DBG_INIT, (":I: alphabet: %s\n", db -> alphabet)); }else{ PRINTF (DBG_INIT, (":I: alphabet: (NULL)\n")); } if (db -> default_strategy){ strat_name = get_strategy (db -> default_strategy) -> name; PRINTF (DBG_INIT, (":I: default_strategy (from conf file): %s\n", strat_name)); }else{ init_database_default_strategy (db); if (db -> default_strategy){ strat_name = get_strategy (db -> default_strategy) -> name; PRINTF (DBG_INIT, (":I: default_strategy (from db): %s\n", strat_name)); }else{ db -> default_strategy = default_strategy; } } if (db->dataFilename){ PRINTF(DBG_INIT, (":I: '%s' initialized\n", db->databaseName)); } return 0; } static int init_database_short (const void *datum) { char *NL; dictDatabase *db = (dictDatabase *) datum; if (!db->databaseShort){ db->databaseShort = get_entry_info( db, DICT_SHORT_ENTRY_NAME ); }else if (*db->databaseShort == '@'){ db->databaseShort = get_entry_info( db, db->databaseShort + 1 ); }else{ db->databaseShort = xstrdup (db->databaseShort); } if (db->databaseShort){ NL = strchr (db->databaseShort, '\n'); if (NL) *NL = 0; } if (!db->databaseShort) db->databaseShort = xstrdup (db->databaseName); return 0; } static int close_plugin (const void *datum) { #ifdef USE_PLUGIN dictDatabase *db = (dictDatabase *)datum; dict_plugin_destroy (db); #endif return 0; } static int close_database (const void *datum) { dictDatabase *db = (dictDatabase *)datum; dict_index_close (db->index); dict_index_close (db->index_suffix); dict_index_close (db->index_word); dict_data_close (db->data); if (db -> databaseShort) xfree ((void *) db -> databaseShort); if (db -> indexFilename) xfree ((void *) db -> indexFilename); if (db -> dataFilename) xfree ((void *) db -> dataFilename); if (db -> indexwordFilename) xfree ((void *) db -> indexwordFilename); if (db -> indexsuffixFilename) xfree ((void *) db -> indexsuffixFilename); if (db -> pluginFilename) xfree ((void *) db -> pluginFilename); if (db -> strategy_disabled) xfree ((void *) db -> strategy_disabled); if (db -> alphabet) xfree ((void *) db -> alphabet); if (db -> mime_header) xfree ((void *) db -> mime_header); return 0; } static int log_database_info( const void *datum ) { dictDatabase *db = (dictDatabase *)datum; const char *pt; unsigned long headwords = 0; if (db->index){ for (pt = db->index->start; pt < db->index->end; pt++) if (*pt == '\n') ++headwords; db->index->headwords = headwords; log_info( ":I: %-12.12s %12lu %12lu %12lu %12lu\n", db->databaseName, headwords, db->index->size, db->data->size, db->data->length ); } return 0; } static void dict_ltdl_init () { #if defined(USE_PLUGIN) && !HAVE_DLFCN_H if (lt_dlinit ()) err_fatal( __func__, "Can not initialize 'ltdl' library\n" ); #endif } static void dict_ltdl_close () { #if defined(USE_PLUGIN) && !HAVE_DLFCN_H if (lt_dlexit ()) err_fatal( __func__, "Can not deinitialize 'ltdl' library\n" ); #endif } /* Makes dictionary_exit db invisible if it is the last visible one */ static void make_dictexit_invisible (dictConfig *c) { lst_Position p; dictDatabase *db; dictDatabase *db_exit = NULL; LST_ITERATE(c -> dbl, p, db) { if (!db -> invisible){ if (db_exit) db_exit -> invisible = 0; db_exit = NULL; } if (db -> exit_db){ db_exit = db; db_exit -> invisible = 1; } } } static void dict_init_databases( dictConfig *c ) { make_dictexit_invisible (c); lst_iterate( c->dbl, init_database ); lst_iterate( c->dbl, init_plugin ); lst_iterate( c->dbl, init_virtual_db_list ); lst_iterate( c->dbl, init_mime_db_list ); lst_iterate( c->dbl, init_database_short ); lst_iterate( c->dbl, init_database_mime_header); lst_iterate( c->dbl, log_database_info ); } static void dict_close_databases (dictConfig *c) { dictDatabase *db; dictAccess *acl; if (!c) return; if (c -> dbl){ while (lst_length (c -> dbl) > 0){ db = (dictDatabase *) lst_pop (c -> dbl); if (db -> virtual_db_list) lst_destroy (db -> virtual_db_list); close_plugin (db); close_database (db); xfree (db); } lst_destroy (c -> dbl); } if (c -> acl){ while (lst_length (c -> acl) > 0){ acl = (dictAccess *) lst_pop (c->acl); xfree (acl); } lst_destroy (c -> acl); } if (site_info) xfree ((void *) site_info); xfree (c); } static const char *id_string (void) { static char buffer [BUFFERSIZE]; snprintf( buffer, BUFFERSIZE, "%s", DICT_VERSION ); return buffer; } const char *dict_get_banner( int shortFlag ) { static char *shortBuffer = NULL; static char *longBuffer = NULL; struct utsname uts; if (shortFlag && shortBuffer) return shortBuffer; if (!shortFlag && longBuffer) return longBuffer; uname( &uts ); shortBuffer = xmalloc(256); snprintf( shortBuffer, 256, "%s %s", err_program_name(), id_string () ); longBuffer = xmalloc(256); snprintf( longBuffer, 256, "%s %s/rf on %s %s", err_program_name(), id_string (), uts.sysname, uts.release ); if (shortFlag) return shortBuffer; return longBuffer; } static void banner( void ) { printf( "%s\n", dict_get_banner(0) ); printf( "Copyright 1997-2002 Rickard E. Faith (faith@dict.org)\n" ); printf( "Copyright 2002-2007 Aleksey Cheusov (vle@gmx.net)\n" ); printf( "\n" ); } static void license( void ) { static const char *license_msg[] = { "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 1, 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.", 0 }; const char **p = license_msg; banner(); while (*p) printf( " %s\n", *p++ ); } static void help( void ) { static const char *help_msg[] = { "Usage: dictd [options]", "Start the dictd daemon", "", "-h --help give this help", " --license display software license", "-v --verbose verbose mode", "-V --version display version number", "-p --port port number", " --delay client timeout in seconds", " --depth TCP/IP queue depth", " --limit maximum simultaneous children", "-c --config configuration file", "-l --log