003-welcome.qxd
27.03.2001
13:46 Uhr
Seite 3
COMMENT
General Contacts General Enquiries Fax Subscriptions E-mail Enquiries Letters
01625 855169 01625 855071 www.linux-magazine.co.uk subs@linux-magazine.co.uk edit@linux-magazine.co.uk letters@linux-magazine.co.uk
Editor
John Southern jsouthern@linux-magazine.co.uk
Staff Writers
Keir Thomas, Dave Cusick , Martyn Carroll
Contributors
Alison Davis, Richard Smedley Ivan Anastasovski
International Editors
Harald Milz hmilz@linux-magazin.de Hans-Georg Esser hgesser@linux-user.de Ulrich Wolf uwolf@linux-magazin.de
International Contributors
Simon Budig, Mirko Dölle, Friedrich Dominicus, Matthias Ettrich, Thorsten Fischer, Björn Ganslandt, Dirk Gomez, Hagen Höpfner, Karsten Gunther, Georg Greve, Andreas Huchler, Patricia Jung, Heike Jurzik, Jo Moskalewski, Christian Perle, Christian Reiser, Bernhard Rohrig, Thomas Ruge, Tim Schürmann, Stefanie Teufel, Marianne Wachholz
Design
vero-design Renate Ettenberger, Tym Leckey
Production
Hubertus Vogg, Stefanie Huber Bernadette Taylor
Operations Manager
Pam Shore
Advertising
01625 855169 Derek Coombes Advertisement Director dcoombes@linux-magazine.co.uk Neil Dolan Sales Manager ndolan@linux-magazine.co.uk Verlagsbüro Ohm-Schmidt Osmund@Ohm-Schmidt.de
Publishing Publishing Director
Robin Wilkinson rwilkinson@linux-magazine.co.uk Subscriptions and back issues 01625 850565 Annual Subscription Rate (12 issues) UK: £44.91. Europe (inc Eire) : £73.88 Rest the World: £85.52 Back issues (UK) £6.25
Distributors
COMAG, Tavistock Road, West Drayton, Middlesex England UB7 7QE
R. Oldenbourg
Linux Magazine is published monthly by Linux New Media UK, Europa House, Adlington Park, Macclesfield, Cheshire, England, SK10 4NP. Company registered in England. Copyright and Trademarks (c) 2000 Linux New Media UK Ltd No material may be reproduced in any form whatsoever in whole or in part without the written permission of the publishers. It is assumed that all correspondence sent, for example, letters, e-mails, faxes, photographs, articles, drawings, are supplied for publication or license to third parties on a non-exclusive worldwide basis by Linux New Media unless otherwise stated in writing. ISSN 14715678 Linux is a trademark of Linus Torvalds Linux New Media UK Ltd is a division of Linux New Media AG, Munich, Germany Disclaimer Whilst every care has been taken in the content of the magazine, the publishers cannot be held responsible for the accuracy of the information contained within it or any consequences arising from the use of it. The use of the CD provided with the magazine or any material providied on it is at your own risk. The CD is comprehensively checked for any viruses or errors before reproduction. Technical Support Readers can write in with technical queries which may be answered in the magazine in a future issue, however Linux Magazine is unable to directly provide technical help or support services either written or verbal.
INTRO
Current issues
TICKING THE BOXES In the last few weeks I have noticed a big increase in businesses offering Linux solutions – not just Linux distributions, but everything from standalone software products to consultancy. For so many businesses to put so much faith, not to mention advertising money, into Linux means either they are all jumping on a publicity bandwagon or they see some real fiscal potential. The former would indicate that they are just ticking boxes to be able to say that they offer system solutions across the whole range. This could be a valid business strategy to ensure that they do not miss any potential market. The actual sale could, hopefully, be changed into a product that they already make; alternatively the client could be charged for the development if they insist on Linux. However, the number of business orientated products being announced and shown indicate the latter. Many companies have already spent the development and testing money; a company is not going to spend money without realistically expecting some return. We may all be happy to write and develop software for the greater good, but a company can only survive with a return on its investment. Am I pleased that business has decided Linux is a money-earning market? The answer is yes. I am, however, wary that a business may try to take over and dominate Linux. I am wary that a large company may come along and, by differentiating its products, try to fragment the market. But I have faith that this will not happen. Any business trying to
fragment the market would run into user criticism, and probably a boycott, so financially it wouldn’t be worth the risk. Due to the GPL and other licenses, anyone could start up a Linux company to compete, but as soon as one company tries to dominate it will lose customers. Not that long ago a lot was said about RedHat dominating Linux. Yet since then the number of distributions has grown incredibly; I started out trying to keep my own list but these days there are just too many. Business moving in, however, is a good thing. The more assistance businesses give, the more it will encourage others to support it and end the curse that is the lack of drivers for new hardware. As more companies provide back up, client companies are more likely to feel confident in Linux that support is available. We may know that fast, reliable feedback is always there via User groups and the Internet, but a company wants a solution provided, not so they can blame someone but so that they can get on with running their business and leave the rest to someone else. The advert used to be along the lines of, ”Nobody ever got fired for choosing IBM”. Now that IBM is spending money to ensure Linux works on all its servers and has launched a Linux consultancy with SuSE, it would be more fitting to say, ”Nobody ever got fired for choosing Linux”.
John Southern Editor
We pride ourselves on the origins of our magazine which come from the very start of the Linux revolution. We have been involved with Linux market for six years now through our sister European-based titles Linux Magazine (aimed at professionals) and Linux User (for hobbyists), and through seminars, conferences and events. By purchasing this magazine you are joining an information network that enjoys the benefit of all the knowledge and technical expertise of all the major Linux professionals and enthusiasts. No other UK Linux magazine can offer that pedigree or such close links with the Linux Community. We're not simply reporting on the Linux and open source movement - we're part of it. 8 · 2001 LINUX MAGAZINE 3
NEWS
EBIZ and Linux NetworX merge Vendor neutral open source solution provider EBIZ has announced plans to merge with cluster management tool developer Linux NetworX. Under the terms of the agreement, EBIZ will begin manufacturing Linux NetworX cluster compute nodes in its technology centre in Houston, Texas. Dave Shaw, chief executive of EBIZ said, the merger with Linux NetworX Would benefit EBIZ customers and shareholders as the company moves into the high performance computing space. ”The high performance computing market is growing at a rapid rate. IDC estimates that the high performance computing market has grown from $4.8 billion in 1998 to $5.8 billion in 2000 and that it will grow to $7.5 billion by 2003.” Glen Lowry, president and chief executive of Linux NetworX highlighted The benefits of EBIZ’s established sales channels for his company, which
are expected to speed up product delivery. ”This proposed merger will allow Linux NetworX to more quickly execute its business plan and increase Market penetration for our Linux clustering products through the mature EBIZ sales channels. We will streamline our product delivery and expand markets for our Evolocity cluster systems and ClusterWorX suite of management tools. By combining forces with another established Linux company like EBIZ, we will also be able to provide better services for our customers.” The merger is expected to be completed during the second quarter of this year. ■
Info www.ebizenterprises.com ■
Maya animation ported to RedHat Alias|Wavefront, an SGI company, has announced that it has ported its Suite of Maya 3D effects and animation software products to the Red Hat Linux operating system. The decision to port to Linux comes as a response to requests from the animation world. Chris Ford, Senior Maya Product Manager for Alias|Wavefront said, ”Alias|Wavefront is responding to the needs of its customers by making Maya available on their preferred graphics hardware platforms. With Maya For Linux , IRIX, WindowsNT/Windows 2000 and soon Mac OS X, our users have maximum flexibility to choose the hardware and software configurations that are most appropriate to their creative and business requirements.”
Game developers welcome the news that Maya is now available for Linux, according to Makoto Osaki, director of the AM2 division of CSK Research Institute (formerly AM2 of SEGA), which was one of the beta test sites For the Linux version of Maya. He said: ”Our developers have been very happy with the performance of Maya on Linux. The flexibility, control and familiarity of a Unix-based system combined with Linux’s cost effectiveness, efficient data and network management capabilities and ability to recycle IRIX plug-ins makes for a very powerful solution. Maya on Linux will be Our primary package for 3D CG game content development.” Michael Babcock, software engineer at Jim Henson’s
Creature Shop said: ”We are very excited to be able to run Maya on Linux .” He added: ”The core of our puppeteering control system technology runs on Linux and we love the stability and flexibility it provides. Now that Maya’s superb character tools are available on Linux the Henson Digital Performance Studio is a complete, smooth production pipeline that combines powerful and elegant tools to provide the best in character performance animation.” ■
Info http://www.aliaswavefront.com/ ■
Easier Eazel online Eazel, a software developer that focuses on ease of use for the Linux desktop, has announced an enhanced version of its Software Catalogue service, which makes it simpler for users of Eazel’s Nautilus content and delivery platform to download software packages for the Linux platform. The Software Catalogue service provides a searchable collection of more than 5000 software packages for the Linux platform, including StarOffice, Adobe Acrobat Reader, Macromedia Flash, and Netscape 6.0. Once users have located the software they require, they can download with one click. Enhancements to the service include software reviews from Eazel’s team as well as reviews from Linux Magazine and Linux Orbit magazine. Mike Boich, chief executive officer at Eazel said that one of the most common frustrations people report about their computers related to upgrading software. He added: ”As part of our 6 LINUX MAGAZINE 8 · 2001
mission to make computers easier and more enjoyable to use for technical and non-technical users alike, we have integrated the desktop user environment with Internet services that will help solve this problem, save time and help our customers make the most of their computing experience.” Eazel has also launched the first in its new series of software suites. Eazel plans to deliver a range of these topic-specific suites of Software that can be downloaded together, again with a single click. The first suite focuses on music and consists of a compact disc player, a mp3 player, a music organiser and an encoder for music files. ■
Info http://www.eazel.com/download ■
NEWS
zServer users get SAP
Messaging help International Messaging Associates has launched the beta release of its Internet Exchange Messaging Server 5 at the CeBit Fair in Hannover, Germany along with the promise that support for a number of Linux distributions including those of RedHat Linux, VALinux, Trubolinux and Caldera Systems will be made available. Internet Exchange Messaging Server is the latest addition to IMA’s family of scalable, open architecture. It can be used with a range of email solutions. Tim Kehres, IMA Managing Director said: ”Internet Exchange 5 now conforms to both major operating environments - Linux and Windows. We are currently working on providing support for several Linux distributions.” The package includes free oneyear support and free 25-user license for Its Message Store. Further user licenses may be purchased. ■
Info http://www.ima.com/pdf/iemsoverview.pdf ■
IBM is teaming up with ebusiness solution provider SAP to deliver the mySAP.com ebusiness platform on Linux for the IBM eServer zSeries. This means that mySAP.com will be available on both Linux and z/OS to zSeries customers, giving them the opportunity to deploy open source 64bit virtual storage for their online business. Karl-Heinz Hess, a member of the SAP Extended Executive Board said, ”Since early 1999, SAP has successfully supported Linux as a mature, reliable operating system for e-business solutions. With IBM supporting Linux on the eServer zSeries, customers now benefit immediately from the availability of mySAP.com on this hardware platform. The early SAP commitment to Linux proves to be the right decision.” Dan Colby, general manager, Enterprise Servers, IBM added: ”Linux on
the IBM eServer z900 is a powerful choice for SAP customers seeking a highperformance, open infrastructure for their e-business applications. This combination of technologies - with mySAP.com and the z900 at its core - provides our mutual customers with superior reliability, outstanding systems management, and breadth of applications available on Linux, all at a competitive price.” Heinz-Peter Bröckskes, managing director of ScaleOn GmbH, Germany said that deploying mySAP.com on Linux for IBM eServer zSeries enabled his company to run a comprehensive e-business solution on one server. This combines the high scalability and reliability of a 64-bit zSeries platform with leading-edge innovations of an open source environment.” The solution is due to begin shipping in the second quarter of 2001. ■
Wireless World Wired and wireless application server technology provider Lutris Technologies has announced its new range of targeted wireless consulting services, as well as new heterogeneous wireless client platform support and new enterprise hardware certifications for the Lutris Enhydra Java/XML application server. Lutris Targeted Services enable customers to specify the services they need for their web or wireless application development programs. Lutris Targeted Services cover the areas of wireless planning, Enhydra application architecture assessment and Enhydra application performance assessment. The service offers a two-day executive planning session on developing Wireless web applications, as well as architectural and performance assessments for applications built with Enhydra’s application
server. Yancy Lind, chief executive of Lutris said that Enhydra customers and partners wanted the simplicity of a single, supportable application. ”They want the flexibility to target any of their users’ device types, from HTML to WAP to i-mode to PDAs. With no proprietary languages or vendor lock-in, Lutris Enhydra and our services provide customers with an easy to use and entirely portable application Internet infrastructure.” Lutris now has further targeted services in the pipeline. These will Focus on planning, development and full life cycle management of Enhydra-based Web applications and will include branding, graphic design, usability analysis and platform migration services. ■
Games developers get help Metrowerks has launched its new Analysis Tools Kit (AttaCK) aimed at Games developers. The Analysis Tools Kit promises to expand opportunities for game developers and shorten time to market. The ATtaCK framework was originally created by Metrowerks to build its CodeWarrior Analysis tools suite. Using the tool kit, game developers can custom-build tools to profile, debug and analyse their applications. In this way, they can create their own tools to handle the system-level issues that can affect in games projects. Brian Gildon, director of core technology and games platforms, Metrowerks said: ”The Analysis Tools Kit underscores our commitment to helping game developers reach market as fast as possible with high quality games and content. This is leading-edge tools technology, and combined with our breadth of platform support, it demonstrates how serious we are about the gaming space.” Metrowerks also said it was planning to work with Motorola, Ericsson and Siemens to deliver development tools for a new Universal Mobile Games Platform. The announcements were made at the Games Developers Conference (GDC). There, Metrowerks also demonstrated the new Linux version of its CodeWarrior for PlayStation2 tools. ■ 8 · 2001 LINUX MAGAZINE 7
NEWS
Easier Graphics Paul Nolan Software has launched the new version of its Photogenics Image modification and creation software for Linux and Windows. Photogenics 5.0 enables users to manipulate images from straightforward file format conversion to re-touching a photograph. Features include real-time modification of colour, transparency, image processing mode, and artwork positioning and a range of mouse controlled media tools including Airbrush, Chalk, Pencil, Sponge, Watercolour, Smudge and Smear. Exclusive to the package is Photogenics’ Paint Layer Technology that allows mistakes to be rubbed out using a ”fade out” technique with the right mouse
button, leaving other modifications to the image undisturbed. Paul Nolan, creator of Photogenics commented: ”People just seem to love the ability to erase mistakes with the right mouse button, and do simple yet amazing things like spraying on all of the image processing filters without having to first make tedious masks. It comes as a revelation to those bound to the worn, standard editing paradigm.” The new software’s debut ties in with the opening of the Photogenics eStore. ■
Info http://photogenics.beyond.com ■
RedHat improve revenue Open source developer Red Hat has reported revenue of $27 million for the fourth quarter, which ended on 28 February 2001. The figure represents an increase of 106 percent compared with the revenue of $13.1 million reported for the fourth quarter of fiscal 2000 and an increase of 20 percent over revenues for the third quarter of fiscal 2001. Matthew Szulik, chief executive of Red Hat commented: ”Red Hat expanded its sources of revenue by introducing strategic solutions to our global customers, which contributed to our strong operating results. Our management team has continued to accomplish the operational and financial goals stated a year ago”. ■
Red embedded tools REDSonic, a provider of diversified softwareintegrated hardware solutions for the embedded market, has partnered with the embedded systems solution provider Tri-M Systems to port its REDICE Linux tools to Tri-M Systems’ MZ104. Integral to REDSonic’s REDICE-Linux real time Linux kernel is the rapid embedded system image creation tool and integrated development environment, RED-Builder. RED-Builder provides a graphical user interface that enables system developers to configure, build, and download images to the embedded target. The REDICE-Linux development tool set includes compilers, debuggers, schedule code generators, a target image builder and a real-time event monitor. Andrew Chen, Chief Technology Officer for REDSonic said: ”Tri-M System’s MZ104 Starter Kit is an excellent platform for demonstrating the realtime performance and flexibility available within the REDICE-Linux SDK and tool set. The coupling of the low power, high performance MachZ embedded PCon-a-Chip, utilising the PC104 standard, provides system developers With maximum exploitation of our real-time implementation of the Linux kernel.” ■
Info http://www.redsonic.com/ ■
Farm management made simpler Open source solution provider VA Linux Systems has launched its VA Linux 100 remote management solution for 1U server farms. The VA Linux 100 uses VA’s VACM cluster management software to turn rack of VA Linux 1120 and 1220 1U servers into unified server arrays, enabling systems administrators to manage them securely from anywhere in the world. The VA Linux 100 is part of VA’s management solution that includes VACM and VA SystemImager software. It offers server power management capabilities and a built-in LCD interface. One VA Linux 100 can 8 LINUX MAGAZINE 8 · 2001
manage up to 42 server nodes, while multiple VA Linux 100 systems can be managed through a single VACM interface. Ali Jenab, president and COO, VA Linux Systems commented: ”Scalable management infrastructure is critical for our enterprise-level customers. Used with our 1120 and 1220 servers, VACM and the VA Linux 100 are designed to manage thousands of servers distributed among data centres.” Chuck Boeheim is assistant director of Stanford Linear Accelerator Centre (SLAC) Computing Services, which uses VA Linux to provide a cluster of 280 1U servers and
deployed VA Linux 100 systems to provide systems management. He commented: ”Remote management is critical to us, operating over a thousand servers in a lightsout environment. VA Linux had the most complete cluster management package that we evaluated. It was also the most affordable solution we were offered, and along with VA’s outstanding Linux software expertise, it was the clear choice for us.”■
Info http://valinux.com/systems/productinfo.html ■
NEWS
New places to get certified
ISPs get virtual servers freeVSD, the world’s only GPL virtual server solution for Linux, is announcing the release of version 1.4.6 which now provides full support for Red Hat 7.0, and includes the latest true `thin client’ administration interface for virtual servers, VSDClient. freeVSD, an open source project sponsored by Idaya Ltd, was released in its first version under GPL license in Spring 2000. The software enables ISPs to securely partition their physical servers into many `virtual servers’, each capable of running popular hosting applications such as Apache, Sendmail and MySQL. ■
Info www.freevsd.org ■
Red Hat Europe an open source solution provider for the Internet infrastructure, has announced additional locations for its RHCE training and certification programme, as well as other Red Hat courses. Red Hat training is now available in facilities in Dublin, Madrid, Manchester and Rome, in addition to the course centres previously announced in Berlin, Essen, Guildford, Hamburg, Milan, Munich, Paris and Stuttgart. New courses on Red Hat’s syllabus include Apache web server, firewalling, HA clustering and embedded system engineering. RHCEs are expected to pass a performance-based exam that tests their real world abilities with Linux systems and network administration on live computer equipment. Jasmine Huxtable-Wright, EMEA Training and Business Development Manager said: ”These new locations extend Red Hat’s training and certification programmes to more cities, giving our customers greater access right where they live and work. IT professionals and their employers have recognised the value and consistency of the RHCE Programme, as well as our commitment to providing the highest quality programmes on Linux systems administration, open source applications and development.” ■
SUN PULLS OUT BLADE AND TURBOLINUX SHOWS ITS ATTACKS WINTEL SPACE CARING SIDE Sun Microsystems has announced the release of its new Sun Blade 1000 workstation. The company claims that its focus on network services gives it an edge over price/performance-focused Wintel workstation vendors such as Compaq and Dell, but that hasn’t stopped it shouting about the Sun Blade 1000. Pitching it as the first 64-bit Unix workstation to be available for under £1,000. Based on the 500MHz UltraSparc IIe processor with the Solaris 8 operating environment, 2GB of memory, and the Sun PCi II coprocessor card and its new Sun Expert3D-Lite graphics accelerator board. The company is offering a bundled solution with the IPlanet Suite and Forte for C, C++ and Java for just £3,050 until the end of June. With the PCi II coprocessor, Sun workstation users can run Microsoft Windows applications natively on a 600MHz Intel Celeron 10 LINUX MAGAZINE 8 · 2001
processor, which makes The Sun Blade an ideal environment for developing and testing multi-platform applications, according to the company’s Sun Blade 1000 product manager, George Iwaki. Unix’s share of the workstation market is generally perceived as sliding, under pressure from the price/performance of Wintel products, but Kohout denies this is the case. When it comes to mission critical workstations handling sensitive financial data or doing complex development, modelling and design, Unix is holding its own, he claims. Far from an attempt to undercut the Wintel vendors, Sun is instead attempting to steal market share from other Unix workstation vendors such as SGI, HP and IBM, he says. Nevertheless, while Sun can currently boast to be the runaway leader in The 64-bit workstation space, with the arrival of Windows XP and Intel’s 64-bit processors this year, that lead may not last for long. ■
Asia-Pacific Linux distributor Turbolinux has announced that it is to acquire leading Linux business services company Linuxcare for an undisclosed sum. The combined company of Turbolinux and Linuxcare now boasts US customers such as JP Morgan Chase, Amazon, KPMG and First Interstate Bank. Turbolinux has added Linuxcare’s professional services organisation, technical support team, subscription-based managed services, professional training and independent testing labs to its portfolio. The new company, which will be known as Turbolinux, will maintain Linuxcare’s support of 21 Linux distributions including Red Hat, Caldera, SuSE, Debian GNU/Linux and Corel. Paul Thomas, Turbolinux CEO, retains his position, while Linuxcare CEO and co-founder Arthur Tyde becomes chief technology officer. The combined company also boasts the backing of industry heavyweights such as Oracle, Sun, Compaq, Dell, HP, Fujitsu, Motorola, Intel, IBM, NEC, Novell, SGI, Hitachi and Toshiba. ■
NEWS
New Open Hardware boards Aleph One Ltd of Cambridge and Remote 12 Systems Ltd of London, are now shipping LART and KSB Development Boards, for Linux applications on StrongARM processors, complete with a User Guide, software and cables. The LART board and its daughters were developed and made public by the Technical University in Delft, Netherlands. The group of boards continue to be developed, and details are available under the Open Hardware approach The boards are small, light and low-powered enough to make them a good platform for developing a huge variety of applications like wearable computers, robot controllers, wireless multimedia systems, in-car infotainment systems, process monitoring, PDA’s and so on. The hardware design is transparent so
unneeded functions can be dropped and new functions added before redesigning for the final application. They will be of interest to all those exploiting the high-performance low-power ARM and Intel StrongARM processors, by taking advantage of the huge resources of the Linux development environment. The 100x75mm boards have a 220MHz Intel StrongARM 1100 processor, 32MB of EDO RAM and 4MB of Flash RAM, and, with the KSB, consume less than a watt to achieve about 200MIPS. ■
Info http://www.lart.tudelft.nl ■
VISUAL NUMERICS PORTS IMSL FORTRAN 90 LIBRARY TO RED HAT LINUX Visual Numerics, a developer of web-enabled numerical analysis, data visualisation and enterprise software solutions, has announced that it has ported its IMSL Fortran 90 Library to Red Hat Linux. IMSL Fortran 90 Library is a collection of more than 1,000 mathematical and statistical analysis functions written in Fortran that programmers can embed directly into their applications. The Library’s platformoptimised functions, which are the most accurate and reliable on the market, support distributed computing environments or run on a stand-alone desktop computer. ■
Info www.vni.com ■
Borland Speeds Linux¨ Development Into The Mainstream With Kylix Kylix is the first native rapid application development (RAD) environment for the Linux operating system. Kylix combines an intuitive visual design environment, optimising native code compiler, interactive debugger and comprehensive component suite to give developers the tools they need to deliver Web, desktop and database applications on Linux fast. Corporate and individual developers can now take advantage of the flexibility of
cross-platform capabilities and a native RAD environment. ”We expect Kylix to have a dramatic impact on the Linux marketplace,” said Dale L. Fuller, president and CEO, Borland. ”Millions of users developing today with Borland Delphi and Microsoft Visual Basic will now the ability to easily move their skills, knowledge and applications to the Linux platform and, as a result, catapult Linux into the corporate mainstream.” ■
New support with F-SecureAnti-Virus for Firewalls on Linux Risto Siilasmaa, President and CEO of F-Secure Corporation said, ”The reliability of the Linux operating system has given great impetus to the open source movement, attracting a worldwide community of zealous developers. As a result of increasing adoptions and requests by our customers, F-Secure brings our anti-virus solution to this important environment, and in the process makes Linux a safer, more desirable platform on which to base mission critical applications.” A world-renowned anti-virus research team enables F-Secure to update virus databases daily. The content scanning server can receive database updates automatically without manual intervention by the system administrator, further assuring that all systems are current with the highest level of protection. ■ 8 · 2001 LINUX MAGAZINE 11
NEWS
New OpenLinux from Caldera Caldera Systems has reported that its OpenLinux server product, codenamed Project 42, and its OpenLinux Workstation 3.1 have entered open beta and are now available for download. Project 42 is based on the new Linux 2.4 kernel. Aimed at OEMs and VARs, the product features a secure Web server, a file and print server, and a set of network infrastructure servers, including DHCP, DNS, and firewall. Project 42 supports both UNIX and Samba file and print servers, Project 42 can run alone or on top of UnixWare. Other features of Project 42 include security enhancements, LSB 1.0 implementation, Java SDK version 1.3, and a Caldera Volution deployment agent. OpenLinux Workstation is the develop-on platform for Caldera. It is aimed at Open Source developers looking to deploy on Caldera enterprise platforms. Built on the new Linux 2.4 kernel, OpenLinux Workstation replaces OpenLinux eDesktop 2.4. Features include KDE 2.1, glibc 2.2.1 and Xfree86 4.0.2. The beta version’s open source development tools include gcc 2.95.2, g++ 2.95.2, Perl 5.6.0, OpenSSL 0.9.6 and Sun Java 2 SDK, Standard Edition, version 1.3. Caldera plans to ship a set of commercial development tools with the
IBM and Sendmail announce partnership Sendmail Inc, who produce the commercial Sendmail Internet mail server have announced a partnership with IBM. With over 700,000 sendmail servers in uses and the email volume predicted to grow by over 40 per cent next five years. The partnership will give rise to a secure and reliable ebusiness infrastructure. Support is available 24x7 Nortel Networks, Caterpillar, KPMG and Double Click are amongst Sendmails customers. Sendmail is available for Linux on diverse platforms up to IBM S/390’s. ■
final version of Workstation. Drew Spencer, chief technology officer for Caldera Systems said: ”Project 42, our first develop on platform, is our latest generation Linux-based server product and will be the base for future Linux and UNIX integration products.” He said that OpenLinux Workstation provided an ideal developon environment to write applications for Linux or to UnixWare via the Linux Kernel Personality (LKP) technology. ”Developers run the same operating system on their desktop as they deploy on the server. The product is particularly suited to developers that need to deploy their applications in a secure, supported, scalable, server setting - in an easy to use environment.” Ron Herman, president of Blue Chip Computer Systems, beta-site for Project 42 added: ”Caldera’s new server will enable Blue Chip Computer Systems to save time when setting up servers for our clients and make money by providing our customers an excellent quality product. Its install was straightforward, and it’s incredibly easy to manage.”
Info http://www.calderasystems.com/products/beta/ ■
Legato NetWorker now Supports Four Enterprise storage management software provider Legato Systems has added support for the latest version of TurboLinux - TurboLinux 6.0 - to its NetWorker 6.0.1 storage management product and its Legato NetWorker Module 3.1 for Oracle. Legato NetWorker 6.0.1 supports Linux at the server, storage node, client level as well as at the critical application level. Aimed at enterprise, service provider, and e-commerce customers, it provides them with a flexible solution for protecting their Linux data with such features as advanced backup/restore operations including the saveset level browse and retention policies, saveset consolidation, backup staging, remote recovery and directed cross-platform browse. Jerry Greenberg, senior vice president of marketing at Turbolinux said he expects the growth in the Linux market to continue with the support of data protection solutions such as that offered by Legato. ”Legato NetWorker for Linux offers a significant advantage to Turbolinux users who require a reliable and scalable data protection solution.” David L. Beamer, executive vice president of worldwide sales and marketing at Legato Systems
12 LINUX MAGAZINE 8 · 2001
added: ”We are extremely pleased to announce support for Turbolinux, a key player in the Linux marketplace today. We anticipate an expanding market for Legato NetWorker on Turbolinux as more companies trust their data to Linux servers and require sophisticated, reliable data management tools.” Dan Kusnetzky, IDC’s Vice President of system software research commented on the growing importance of enterprise backup solutions for the Linux market. ”Oracle was one of the earliest commercial database offerings on Linux. As Linux is increasingly used as a platform for database-based applications, it is clear that enterprise backup solutions supporting Linux and Oracle on Linux will also become increasingly important. Products such as Legato’s NetWorker 6.0.1 and NetWorker Module 3.1 for Oracle are sure to be well received.”
Info www.legato.com/eval ■
NEWS
LYNUXWORKS AND NEOMAGIC PROVIDE SYSTEM-ON-CHIP SOLUTION Open source and real time embedded solution provider LynuxWorks is working with embedded DRAM and logic technology developer NeoMagic to provide LynuxWorks’ embedded BlueCat Linux for NeoMagic’s forthcoming System-on-Chip (SoC) platform for smart handheld devices. NeoMagic’s SoC solution delivers enhanced graphics, audio and video playback in a compact form. Designed for low power consumption, the product aims to offer a cost effective personal entertainment device. Economy was a key factor in Neomagic’s decision to work with LynuxWorks, explains Jason Chiang, product marketing manager at NeoMagic. ”We found the open-source nature of LynuxWorks’
More support for North Wales
BlueCat Linux, and their aggressive porting services, quite suitable for keeping our development and deployment costs to a minimum. BlueCat also enables increased design validation and test coverage of the SoC during the product development phase, and therefore helps to reduce the time-to-market cycle.” Greg Rose, director of product management for LynuxWorks. ”The support for LynuxWorks’ BlueCat on NeoMagic’s SoC will provide our customers with best-of-breed products and services for developing next generation smart devices. The reference design will extend LynuxWorks’ commitment to embedded markets for Internet-based, consumer information and entertainment devices.” ■
Paul Kersey-Smith has formed a new Linux based support company North Wales Linux Services.
Info Details from www.northwaleslinux.co.uk ■
SuSE Linux has appointed three new members to its supervisory board The three appointees, all industry experts, are Heinrich Rodewig, partner of the law firm Haarmann, Hemmelrath and Partner, who will be the new Chairman of the Supervisory Board; Michael Laurim, managing director of Silicon Graphics in Germany; and Peter Mark Droste, Managing Director of Compaq in Germany. Commenting on SuSE’s choice of new supervisory board members, Roland Dyroff, chief executive officer of SuSE Linux said: ”Heinrich Rodewig is an experienced international legal expert and the perfect fit as chairman of the supervisory board. With company executives Michael Laurim and Peter Mark Droste, we succeeded in gaining two leaders of the German IT sector, further emphasising the growing importance of Linux and our business model based on the open source philosophy. The appointment of Laurim and Droste is the result of our mutually beneficial partnerships with SGI and Compaq.”
Silicon Graphics and Compaq are newcomers to the ranks of SuSE’s strategic investors. ”The clear commitment of Compaq and SGI in Linux has lead to a know-how transfer from which all involved parties benefited,” said Dyroff. Johannes Nussbickel, chief financial officer at SuSE Linux said: ”The new members enhance the supervisory board of SuSE Linux with their extensive IT know-how and comprehensive legal competency. This will contribute considerably to an increase in company value.” Heinrich Rodewig the new chairman of the supervisory board said: ”SuSE Linux AG has played a major role in the development of the European Linux market,” SuSE’s professional and highly motivated management team and staff have provided an essential contribution in this respect. With my extensive professional experience in large and medium-scale companies, I am pleased to assist in the further development of SuSE Linux.” ■
Argus Systems Group Announces Additional Linux Support. Argus Systems Group, Inc., announced the availability of its PitBull intrusion prevention security technology on additional versions of Linux. PitBull LX is will be available on Red Hat 7.0 and SuSe 7.1. PitBull LX for Linux is designed to protect webfacing servers from malicious attack to alter data and web pages, steal proprietary information or monetary assets, violate consumer privacy protections, launch denial of service attacks, and otherwise tamper with system and data resources. Simple to install, PitBull LX supports a totally revamped, completely intuitive security policy. Security administration has been greatly simplified and is totally non-intrusive.
PitBull LX for Red Hat 6.2 is available now free of charge for a 60-day evaluation period from the Argus website. Intrusion prevention systems based on operating system-level security like PitBull LX are increasingly recognised as mandatory elements of secure and responsible e-business systems by leading experts such as the US National Security Agency, the Gartner Group, and other independent industry analysts. Randy Sandone, president and CEO of Argus Systems Group, Inc. said ”PitBull LX for Linux will allow Linux into security-sensitive, mission-critical environments, extending the open source economics into these environments.” ■ 8 · 2001 LINUX MAGAZINE 13
■
014-school.qxd
28.03.2001
17:29 Uhr
REPORT
Seite 14
NEW GROUP FOR LINUX IN SCHOOLS
Bringing education back to schools.
OPEN SOURCE IN EDUCATION RICHARD SMEDLEY
At last the many groups involved in promoting Free Software as an educational tool are gathered round a single banner. Penguins, gnus and bsd devils are going back to the schools that turned out the current generation of programmers. The aim is to to put education before training. The past two years has seen a real groundswell in the efforts of disparate individuals and organisations to get Free Software into schools. This has been covered recently here and elsewhere. The one thing that these efforts have lacked has been a cohesive central focus. Discussion amongst many of the individuals involved on various mailing lists and Usenet groups - in particular the list hosted by SuSE - lead to a meeting, in Salisbury, on March 12 this year. The meeting was hosted at Westwood St Thomas School, Salisbury, by Paul Taylor - a frequent contributor to SuSE’s schools list. It was well attended, with more than two dozen people making the journey from as far afield as West Wales, East Anglia and the North West. Many people are working on projects in their own time, as is the way in the Open Source world. Commercial representation was also good.
OSiE - a new group The meeting was started with a joint proposal from SuSE Linux’ Roger Whittaker and Michael Brown, of new Linux managed services company Fen Systems, 14 LINUX MAGAZINE 8 · 2001
for an Open Source In Education (OSiE) initiative. A national group to both promote and support Free Software in UK schools. Whittaker began by outlining the recent history of GNU/Linux in schools. Talking about SuSE’s initial contact with schools at BETT (the educational technology show) and the attempted involvement of Becta. Wearing his UK Unix Users Group (ukuug) hat, Whittaker proposed that organisation as a neutral parent organisation for OSiE, and offered the SuSE schools mailing list as a forum for discussion of aims and sorting out the administration. After outlining the ”challenges” facing Linux for schools, Michael Brown set out a proposal for OSiE as an ”umbrella group”, providing on its Web site directories of schools and vendors, a resource library and a ”knowledge base.” Unaware of the Open Source for Education Web site set up by Malcolm Herbert, when at Becta, Brown had registered the osie.org and osie.org.uk domains, ready to host the group if the name was agreed upon. After all it is very frustrating to get a group to agree on the name for a project only to find that there is no suitable url for the Web site!
014-school.qxd
28.03.2001
17:29 Uhr
Seite 15
NEW GROUP FOR LINUX IN SCHOOLS
The knowledge The beginnings of the knowledge base are already online. Brown has donated the tutorials and information amassed for his company’s Web site. Group discussion highlighted a desire for this resource to be professionally managed and edited, presenting information ”by practitioners for practitioners”. Too many ”resources” are redundant collections of newsgroup archives, difficult to search and extremely uninviting. To this end an editorial team will be almost as important as the original contributors. Many of the decision makers in education are non-technical people. With this in mind much of the site will be aimed at providing easy access to solutions. New trial sites, as well as long-term Free Software-users such as Felsted school (see below), will contribute case studies. Those struggling to convince their manager of the viability of Free Software will be able to point to these ”real-world” examples. Lively discussion followed this presentation, much of which had covered administrative details. Concerns were raised over issues at the very heart of the Free Software debate: The philosophies behind Open Source and Free Software; possible conflicts of interest between commercial and noncommercial concerns; over-emphasis on support at the expense of advocacy. The open nature of the discussions served well to lay the foundations for a balanced organisation. The morning was rounded off with an introduction to the extremely interesting set up at Felsted, a private school in Essex. It boasts one of the most economical, diverse and stable networks in any UK school. BBC and Acorn Archimedes computers, as well as pupils’ own Pentium IV PCs are all served by a robust free BSD setup. Thin clients are distributed throughout the school, giving students ready access to their work and e-mail. After lunch a KDE desktop was served up remotely, from Felsted. This was hampered, in true ”live demo” style, by local difficulties - in this case on Westwood School’s own network. However a telnet session showed the attendees much of Felsted’s system. The meeting was closed by Phil Jones, with a demonstration of his impressive suite of tools,
REPORT
developed as the Linux for Schools Project (lfsp), and featured previously in Linux Magazine. These tools enable pupils to work collaboratively, at the Linux command line, from their MS Windows desktops and provide for easy administration of per user web space on the server. The Gethelp utility orients the new users to the command line and pupils are soon ”chatting” with other remote users. Jones demonstrated a Windows desktop with a KDE taskbar and GIMP both running on the Linux server. All agreed that tools such as these, enabling schools’ current Windows arrangement to work with Linux machines, would be vital for many schools to start the transition to Free Software. Other attendees included Kevin Taylor, maintainer of the Linux Schools Howto, Miles Berry of the Linux-using girls preparatory school St Ives, in Haslemere, Surrey; Debian’s Phil Hands and representatives of several LEAs, schools, companies and other projects.
Far from listless OSiE has since been set up as a project on Sourceforge. This gives a ready made infrastructure for group development in order for members to concentrate on the aims of the group rather than the details of how to organise the structure. Several mailing lists have been started. The general discussion list being the liveliest. The council of the ukuug has agreed to the affiliation of OSiE, without the need for formal ukuug membership on the part of OSiE members. This affiliation should help to uphold the neutrality of the group as the commercial market for Linux solutions in schools grows, leading to inevitable pressures. At the time of going to press help was needed in many areas. There can be few readers who do not have an interest in education. The nature of the group’s organisation - as a Sourceforge project readily lends itself to individual involvement. Meanwhile, as OSiE builds grassroots support, what will be the response of the DfEE, Becta, NESTA and the TC Trust, who decide whether taxpayers’ money should go to open solutions for education or foreign companies for office software licences? ■
info OSiE Web site: http://www.osie.org.uk/ OSiE project pages: http://sourceforge.net/projects /osie/ OSiE discussion archives: http://www.geocrawler.com/lis ts/3/SourceForge/10686/0/ Linux User online article: http://www.linuxuser.co.uk/art icles/issue8/index.html SuSE school page: http://www.suse.de/uk/schools/ index.html UK schools howto: http://www.northants.lug.org. uk/projects/schools/index.html lfsp - Linux Magazine 5, February 2001,, p30 ”Lessons in Linux” Felsted School: http://www.felsted.essex.sch.u k/guides/ RedHat’s move into education: http://www.europe.redhat.co m/news/article/136.html ■
The author The author spent nine hours in a tiny hire car, with just a Leonard Cohen tape for company, in order to attend the meeting. He is otherwise harmless and, when not playing rugby with his children, spends much of his time with php and python.
photographic credits Mike Robinson: http://www.btinternet.com/~ mike_r/ ■
[right] Accessing Linux files from the Windows desktop [left] Two days of the round table” Only three beards? Are they real Unix users? 8 · 2001 LINUX MAGAZINE 15
016-book.qxd
28.03.2001
10:14 Uhr
Seite 16
BOOKS
REVIEW
THE SUSE LINUX SERVER BY PAUL G SERY & MOHAMMED J KABIR ALISON DAVIES
The SuSE Linux Server is a good technical, heavyweight book on how to install and get the best out of SuSE Linux. Its twenty chapters are divided into six sections. Part 1 guides the reader through a basic installation, setting up standard SuSE, although omitting X server for reasons of security and performance. Part 2 covers the usual YaST configuration tool. It includes setting up user accounts, starting and stopping deamons, and networks, including (unusually) a basic background to networks. Part 3 deals with the Internet and Intranet with the usual email, web and FTP servers. It has very detailed sections on the DNS and web server configurations. Part 4 is a quick introduction to
Info ISBN 0-7645-4765-8 £36.99 MandTbooks 620pp. Includes SuSE 7.0 evaluation version CD-ROMs ■
Samba, NFS server and simple SQL database servers. Part 5 is one of the most interesting sections and deals with security. It covers the basics with authentication giving examples and uses and a second chapter covers network security with examples such as Squid Proxy server and how to run a port scan. The final part covers customising the kernel and includes a detailed chapter on building a web server farm. At the end of the book are appendices on where to get more information, printing, configuration scripts and, of course, the contents of the CD-ROM. The book is well written with lots of background information. It explains why you do something as well as how to do it in a straightforward manner with plenty of examples. It works as a good tutorial on installing SuSE even if you do not want to do everything it suggests. The SuSE Linux Server would be a useful addition to the bookshelf of anyone who uses SuSE Linux at home or at work and would be an invaluable help to anyone installing for the first time. ■
INTERVIEW WITH DEEPAK ADVANI, IBM WORLDWIDE LINUX STRATEGY LM:How do you see the Linux market developing in both the long and short term? DA:In the near term there will be an increase in the workload capability. We currently see workloads on Internet related systems such as webservers. This will extend to distributed systems; retail, banks and other financial distribution models, where servers are at differing geographical locations. The market will develop with scalability through clustering as well as horizontal scaling. In the long term 8-RAID and 16-RAID scalability will enable the move beyond webservers via applications to data servers. LM:What are the main reasons that IBM is banking on Linux? DA:Linux is viewed as a key standard in the ebusiness world. The world is becoming more hetrogeneous. Linux can do for applications what TCP did for the Internet. In universities Linux is popular. Linux will be on billions of pervasive devices. LM:Where does IBM see a business advantage in being a Linux leader? DA:IBM like it that way. Appliactions are needed. ISV’s need volume so to port once and sell many. IBM needs to provide complete solutions and therefore 16 LINUX MAGAZINE 8 · 2001
we need a common OS across platforms. IBM has no desire to differentiate at OS level. LM:Does IBM’s interest in Linux harm the AIX market? DA:During the last quarter AIX sales have risen by 44%. AIX is more for high end and mid range so the workloads compared to Linux are different. LM:Where do you see IBM focusing its announced $1Billion investment? DA:Advancing technology. Over 200 people in Linux technology centres. Open source Enterprise capable porting centres. Global consulting and training. A dedicated sales front and OEM business micro devices. LM:Do you see Linux ready for the desktop? DA:We are already deploying lots of clients with our own version of a thin client. Linux is currently lacking in some office applications. LM:Where do you see Linux in five years time? Open Source is maturing rapidly. It will play a stronger role with servers deployed being the core element. Linux is flexible and will enable new disruptive technology to enter the marketplace. The IT industry will look different with dense servers and intelligence within networks. ■
018-Database.qxd
27.03.2001
16:42 Uhr
COVER FEATURE
Seite 18
DATABASE DESIGN
Designing Data Models
DATA WORKSHOP BERNHARD ROHRIG
Before the completion of a perfectly programmed database we have the hard work of database modelling. This article shows ways and means of achieving a clean database design.
Computing reality is not imaginable without databases. The dynamic Web applications that are so popular these days could not manage without them. There is now a large selection of server software, tools and development environments in which to operate database systems under Linux. But before the implementation of a specific database server can be discussed, it is necessary to agree on the model that can be represented in the data structures. Put simply, a database is a collection of nonredundant data that is used by different applications in parallel and simultaneously. Compared to classic data storage forms, where each application had its means of storing data, they offer the following advantages:
18 LINUX MAGAZINE 8 · 2001
• Applications are protected against any extension of the base data and changes in their structure. • Application development is independent of the way the data is organised and accessed. • Applications are no longer linked in terms of changes to individual applications. • Data consistency is provided centrally by the database itself. This allows more flexible data utilisation, avoids wasting disk space and saves a lot of program maintenance and development time.
Down with redundancy Why is it so important to eliminate redundancy? Redundancy in this context means that the same
018-Database.qxd
27.03.2001
16:42 Uhr
Seite 19
DATABASE DESIGN
COVER FEATURE
information is stored several times in the same database. Should individual representations occur of the same fact that contradict each other (amendments carried out in one place, no amendment in another), we call this data inconsistency. Once a database has become inconsistent it takes a lot of effort to restore the desired integrity. By avoiding redundancy in the first place, inconsistencies can be ruled out from the start. A considerable number of processes have been developed to eliminate data redundancy. Many of these are based on complicated mathematical procedures (relational algebra) and the resulting models are not always very clear. However, for practical purposes it is sufficient to know the most important methods with which to avoid a large proportion of redundancy-pitfalls, as these are not always apparent at first glance. A central tool in this is entity relationship modelling on the one hand, and the use of normalisation theory on the other.
First approaches As a database developer you are faced first of all with producing a more or less exact description of the section of reality which is going to be represented in the data structures you are developing. We shall use the administration of data relating to PCs and operating systems as an example. Let’s assume that you like to experiment with different Linux distributions and other operating systems, and that you own several PCs for this purpose. Since the built-in hard disks are normally not sufficient for such experiments some of the PCs have hot swap facilities, which allow the easy installation of hard disks. It is of course also possible to install several operating systems on one hard disk. In order to represent real objects and their relationships to each other as a structured data set, the colloquial terms need to be classified. That is a first step on the way from chaotic diversity to a model based strictly on logic. It is useful to classify according to object class, attribute and relationship. Table 1 shows a suggestion for our example. If you tried to draw up this sort of overview yourself, you might come up Table 1: Classification of modelling objects Real Term Object Class PC x Hard Disk x PC Type Hard Disk Type Vendor x PC Hard Disk Vendor Address Operating System x Operating System Supplier Operating System on Hard Disk
Figure 1: A simple structural model (entity relationship)
with different results, because the assignment cannot always be unambiguous. If a given fact is classified as a relationship in one context, it can also appear as an object in another, just as a seemingly independent object can suddenly become merely a simple attribute of another object or vice versa. An example: on the one hand, the object vendor is an object class that has specific attributes (for instance address, telephone number). On the other hand it can sometimes be sufficient to regard vendor as an attribute of PC. What this means is that the model doesn’t have to be correct, it has to be consistent. This is not about truth, but rather functionality. The same or a roughly similar section of the real world can be modelled quite differently in two separate databases - and both models could still serve their purpose. In the rest of this article, the information from table 1 is used to draw up a rough structural diagram, the entity relationship model, or ER model for short.
Elements and relationships An entity relationship is a technique that makes it possible to express the relationships between facts
Attribute
Relationship
x x x x x x x 8 · 2001 LINUX MAGAZINE 19
018-Database.qxd
27.03.2001
16:42 Uhr
COVER FEATURE
Figure 2: ER model for administration of PC/operating system
Seite 20
DATABASE DESIGN
and transactions in the real world within a data model. The defined object classes with their attributes are regarded as units or entities, between which a certain relationship exists. This relationship is represented in ER-diagrams, where we distinguish between four classes of relationships, listed in table 2. You can see the ER-diagrams for the relationships between the object classes PC and vendor in figure 1. The following relationships exist:
Table 2: Association types in ER models Symbol Type of relationship Example 1 to one Each PC has one vendor. c to one or none Each hard disk is in one PC or in none. m to at least one Each PC has at least one hard disk. mc to none, one or several An operating system is on no, one or several hard disks. Table 3: Basic relation PC Attribute PCID vendor type purdate
Content PC identification, primary key PC manufacturer PC type Purchase date
Table 4: Basic relation HD (Hard Disk) Attribute Content HDID Hard disk identification, primary key vendor Hard disk manufacturer type Hard disk type capMB Hard disk capacity in MB PCID Built into which PC? Table 5: Basic relation OS (Operating System) Attribute Content OSID Operating system ID, primary key vendor Manufacturer/distributor namev Name/version of operating system HDID Installed on which hard disk? date Date of OS installation 20 LINUX MAGAZINE 8 · 2001
• One PC has one or more hard disks (m). • Every hard disk is installed on a PC or lying in a cupboard (c). Overall, a relationship of the type c : m (c to m) exists between hard disk and PC. Such relationships are then defined for all object classes of the data model and summarised in a structural ER-diagram (see figure 2). Again, there is no definitive solution. Different database designers arrive at different layouts given the same facts. The only important thing is that the resulting model is suitable for the intended purpose and that any redundancy is avoided. In this type of diagram you will find three main forms of interrelations: • hose featuring relationship type 1. • Those featuring relationship type c, but not relationship type 1. • Those featuring only relationship types m and mc. Relationships 1, 3 and 4 in figure 2 belong to the first category, relationship 2 to the second and relationship 5 to the third. Their subsequent handling depends on the category. However, this requires us to know a bit more about the internal structure of the data model.
A look inside In relational data models (SQL databases) the data of each object class are collected in a sort of table, called a relationship. The table rows, also called data tuples or data records, store the object details, while the columns - also called fields or attributes contain the respective value for each attribute. This is similar for post-relational or object oriented databases, except that storage is not two but multidimensional. It is important to note that the storage sequence of the rows and the field is of no external significance; they are also referred to as unordered tuples or unordered attributes. Object attributes are identified through the relevant field names , objects through the primary key. A primary key is a sort of index that has a unique value or combination of values for each data record. Normally an additional attribute is introduced for this purpose, whose value is often automatically assigned by the database when a record is created. Using this primary key, each data record in a table can be uniquely identified. This also means that a primary key field must not contain a NULL marker, indicating no value, in any of the records. Table 6: Basic relation Vendor Attribute Content VID Vendor ID, primary key vname Vendor company vaddress Address vcity Town vzip Postcode vtel Telephone number
018-Database.qxd
27.03.2001
16:42 Uhr
Seite 21
DATABASE DESIGN
COVER FEATURE
The primary key also allows links with related data records in other tables using a foreign key. This is simply a reference to the primary key of one table through a corresponding value in a field of another table. The database has to know, of course, which field is related to which other field. The individual SQL dialects offer appropriate facilities for this purpose. An important rule for all foreign key relationships is referential integrity, which stipulates that foreign key fields in a dependant table must only contain NULL values and values that already exist as primary key values in the referenced table, but never other values which might possibly appear there at some point in the future. Any good database system will monitor the compliance with referential integrity independently, which frees application programmers from this task.
Basic relations in detail The relationships between primary and foreign keys for our data objects can now be defined on the basis of the ER model. The first step is to list all object classes with their corresponding attributes according to tables 3 to 5. To start off, we are going to assume that the attribute vendor is common to the three object classes. This results in a relatively simple data model. It is apparent that the relationships of the objects to each other can be represented by rather simple key relations. Each table contains a numeric data record ID as its unique primary key field. Hard disks are linked to the corresponding data records in the PC table through the PC-ID. This makes it possible to have more than one hard disk per PC and to represent this fact in the database. The relationship between the individual operating systems and the hard disks on which they are installed is organised in a similar way. As pretty as this model is to look at, it does have its hidden dangers, which we are now going to expose and remove step by step.
Consolidating the model Even at first glance we can spot one redundancy, which could cause a lot of aggravation later during the operation of the database. The attribute vendor for the manufacturer, distributor or supplier of a device or program is only unproblematic as long as its values are not repeated in one or more tables. However, this is bound to happen once the latest version of a much loved (or hated) operating system is released, if not before, for instance when the letters IBM appear in a second table.
What happens if a manufacturer’s name or an address that is stored with it changes? The corresponding fields in all affected databases must be amended. If just one of them is forgotten, the data will be inconsistent. This redundancy is resolved relatively easily, by introducing an additional object class vendor. The corresponding basic relation is shown in table 6. The attribute vendor in the three other tables needs to be changed to the foreign key VID accordingly. Other redundancy problems are not quite so easy to spot. Therefore we will fall back on methods from ER modelling and normalization theory. The ER model enables us to create clean primary/foreign key relations with three simple rules: • Rule 1 applies to all 1:x relationships; in figure 2 those are relations 1, 3 and 4. This rule states that the primary key on the 1-side - here always VID from vendor - must be included as a foreign key attribute in the basic relation on the x-side, where we have either m, c or mc. NULL markers are not permitted for these foreign keys. We have already complied with this rule in the previous step. • Rule 2 applies to all relationships that have c on at least one side, with the exception of 1:c relationships, which are already covered by rule 1. This rule states that the primary key attribute on the c-side will be included as a foreign key attribute into the basic relation on the other side (m, mc) of the relationship. NULL markers are permitted for these foreign key attributes. To comply with this rule we must allow the property NULL marker permitted for the attribute PCID in the basic relation HD. In MySQL, probably the most widespread SQL version under Linux, this is achieved by the following type of definition:
Figure 3: Resolving the mc:mc relationship in the ER model
create table HD ... PCID int null;
Table 7: Additional basic relation INSTALLATION Attribute Content INSTID ID of the OS installation, primary key OSID foreign key, ID of the installed operating system HDID foreign key, ID of the hard disk, on which OS has been installed 8 · 2001 LINUX MAGAZINE 21
018-Database.qxd
27.03.2001
16:43 Uhr
COVER FEATURE
Info Dr. Bernhard Rohrig: Datenbanken mit Linux. C&L Verlag, Vaterstetten, 1998. ISBN 3-932311-32-9 ■
Seite 22
DATABASE DESIGN
• Rule 3 applies to the remaining relationships in the ER model, those that do not feature a 1 or cside. An example is relation 5 in figure 2, a mc:mc relationship. Each hard disk can contain one or more operating systems, and sometimes it can be empty, while each operating system is installed on one or more hard disks or lying around unused. This somewhat complicated relationship must be untangled a bit for a proper relational model, as it cannot be established quite so simply using primary and foreign keys. Rather, we require an additional interim table, which apart from its own primary key contains nothing except the combined primary keys of the two other tables. Let’s resolve the mc:mc relationship into two 1:mc relationships by introducing a new basic relation INSTALLATION along the lines of table 7. The relationship between the entities hard disk, operating system and installation can now be expressed as shown in figure 3. At the same time the attribute HDID must be removed from the operating system table, as there is no longer a direct link between an operating system and the hard disk on which it is installed.
How normal would you like it?
The author Dr. Bernhard Rohrig has written several books on Linux and Unix and can be contacted via the Internet under http://www.roehrig.com. You can also find out there what else he gets up to apart from writing books.
To put the finishing touches to our data model the individual basic relations have to be normalized. This means processing them according to certain formal mathematical criteria that have become known as normalization theory. These contribute to the detection of hidden redundancies within the model and thereby help to avoid inconsistencies in the underlying data. There are several normal forms of base tables. For practical application it is sufficient to check compliance with the first, second and third normal form for each of the tables involved. Normally the database designer will use a large quantity of test data supplied by the client. These should contain as many characteristic combinations of attribute values for the individual object properties as possible. There is no space here for a more detailed description, just some methodological hints. A relation is considered to be in the first normal form when it does not contain any attributes with multiple values. These are fields in a table containing several values. It is possible to imagine a violation of the first normal form by table 3, if there are several PCs of different types from one vendor, and the corresponding entries are in one and the same row. This can be easily avoided by consistently assigning each PC its own row in the table. The other data objects (tables) should be treated in a similar way to comply with the first normal form. This requirement may appear trivial, as it is usually adhered to instinctively by most database designers. However, it is useful to be aware of it in order to recognise a possible violation of the requirement in an actual set of data and to avoid it.
22 LINUX MAGAZINE 8 · 2001
A table is in the second normal form if it has a primary key that consists of a single attribute. It is therefore useful always to work with such primary keys, as we have done in our example. You can find other possibilities in the literature. You can also find out there how to convert non-compliant tables into second normal form. Compliance with the third normal form means that no attribute (table field) must be functionally dependent on any other attribute apart from the primary key. This is hard to determine without actual data.
The finished data model A few comments about the tables in our example. Table 7 is in the third normal form from the beginning, due to its structure. Table 6 could lead to inconsistencies with large data volumes, as for instance the post code can be functionally dependant on the address. We can put a stop to that without any problems by simply splitting the table further. In the same way it would be possible to create the facility to store several telephone numbers for one vendor (without violating the first normal form). Table 5 will be in the third normal form as soon as one vendor offers at least two operating systems - which has been known to happen. It is just as simply to prove compliance with the third normal form for table 4. The only chance of a violation would be a fixed assignment between PCID and HDID; as the combination of the other attributes would then also seem to depend on HDID. However, this is ruled out by the assumption that we are using swappable hard disks in at least some of the PCs. Finally, with the appropriate data, it would be possible to prove for table 3 that no attribute is dependant from any other apart from the PCID. Thus our data model is solid and the way is clear for a conversion using one of the current databases. Admittedly things don’t always go as smoothly as in our example. Solutions and suggestions for more complicated cases can be found in the literature. ■
023-PostSQL.qxd
28.03.2001
19:06 Uhr
Seite 23
POSTGRES VERSUS MYSQL
COVER FEATURE
HEAD TO HEAD Postgres and MySQL in direct comparison
DIRK GOMEZ, HAGEN HÖPFNER
MySQL and Postgres are database systems that have long been available as open Postgres (official title: PostgreSQL) is an objectrelational database Management System (DBMS), whose source code and documentation are freely available under the BSD licence and which is being worked on by numerous developers all over the world. It runs on almost all platforms such as Solaris, SunOS, HPUX, AIX, Linux, Irix, FreeBSD and most Unix variants. The current stable version is 7.0.3. Development of Postgres began in 1977 at Berkeley University under the name of Ingres. From 1986 to 1995 Michael Stonebraker, a professor at this university, was working on the development of an object-relational DBMS named Postgres (after-
Ingres). The firm Illustra marketed the code as a commercial product and was later bought up by Informix. In 1994 two Berkeley doctoral students, Jolly Chen and Andrew Yu, added the ODBMS SQL and renamed it Postgres95. Relatively quickly, it became clear to them how much interest there is in an open source DBMS: The mailing list had by then already signed up over 1000 subscribers. With a total of 250,000 lines of C code, though, it takes some time to get used to, so it was necessary ”to find a few people with lots of time, rather than finding a lot of people with a bit of time” (Jolly Chen). Today there are some 15 master developers, who supervise the code of their own
source and are especially popular as back ends for web applications. In this direct comparison, both of them have to show what they can do.
8 · 2001 LINUX MAGAZINE 23
023-PostSQL.qxd
28.03.2001
19:06 Uhr
COVER FEATURE
Seite 24
POSTGRES VERSUS MYSQL
PHP PGAdmin, the PHP-supported web front end for Postgres in action.
respective modules, and numerous additional voluntary developers. New features can be added quickly due to the large number of developers.
Postgres Installation Installation of Postgres is simple, most Linux distributions contain corresponding packages. In some distributions, for example Mandrake 7.x, the installation program installs Postgres in full. Otherwise the source can be downloaded from the Postgres website and you can compile it yourself. Constructing databases is also very simple and is well described in the excellent documentation.
Postgres Standard functions Postgres largely adheres to the SQL92 standard. Transactions, foreign keys and user views are no problem; nor, since Version 7.0.2, are outer joins.
Glossary A couple of important terms from the domain of databases: A database (DB) is actually nothing more than a loose collection of data, regardless of their storage method. The term of database management system (DBMS) encompasses all software modules necessary to manage a database. A database application (DBA) is an application program that sets up a database management system. If DBA and DBMS are considered together, this is called a database system (DBS).
24 LINUX MAGAZINE 8 · 2001
Nested queries, so-called Subselects using SELECT, are possible: SELECT city FROM weather WHERE temp_lo = (SELECT max(temp_lo) FROU M weather);
Postgres Data integrity/Transactions Foreign keys help the developer to determine the correctness of data using database resources: Foreign Key Constraints produce a dependency between one or more columns of a table with one or more columns. When data is changed, this dependency is checked, so inconsistent changes are no longer possible. Postgres is an ACID database (see box ”Transactions...”: • Atomicity • Consistency • Isolation • Durability Transactions are supported at row level and secured by an internal version management system (Multi Version Concurrency Control), a process which is considerably harder and more time-consuming to implement than the usual locking of other database systems. With the MVCC process, readers do not wait for writers: Each transaction sees a corresponding database snapshot, data changes made by change transactions running concurrently are not followed up in this snapshot.
Postgres Expanded functionality As in almost all professional database systems, triggers and stored procedures are familiar. On the
023-PostSQL.qxd
28.03.2001
19:06 Uhr
Seite 25
POSTGRES VERSUS MYSQL
other hand, the option of replicating databases is not currently implemented. Postgres is catalogue based. In the catalogue, not only the tables, but also data types, functions and access methods are stored. This makes this database system easy to expand. Even inheritance is possible: CREATE TABLE cities ( name text, population float, altitude int ); CREATE TABLE capitals ( state char(2) ) INHERITS (cities); The instances in the table capitals inherit all attributes of the parent node cities (name, population, altitude). In order to query all cities – including capital cities – that are located at a height of over 500 metres, the SQL statement specified on the next page can be used: SELECT c.name, c.altitude FROM cities* c WHERE c.altitude >500; The asterisk * tells the SQL parser that the query is interrogating the table cities and all tables descended from it in the class hierarchy. The relational model has only atomic attributes, but Postgres also has arrays: CREATE TABLE SAL_EMP ( name text, pay_by_quarter int4[], schedule text[][] ); INSERT INTO SAL_EMP VALUES (`Ulrich’, `{10000,12312, 9423, 18400}’, `{{"meeting", "beer"}, {}}’);
COVER FEATURE
INSERT INTO SAL_EMP VALUES (`Tom’, `{14000,11000, 9200, 12000}’, `{{"meeting", "lunch"}, {}}’); SELECT name FROM SAL_EMP WHERE SAL_EMP.pay_by_quarter[1] < SAL_EMP.pay_by_quarter[2]; A table with a one-dimensional and a twodimensional array is created, to which a line is added. After that all names of colleagues are queried, who earned more in the second quarter than in the first quarter.
Triggers and Stored Procedures Triggers and stored procedures are used in networks to minimise server round trips. Both are executed within the database, there is no network traffic between application and database. In a normalised data model triggers are mainly needed for auditing and to improve performance, if they are to be transparent for the application: • Auditing is the storage of change accesses to objects: A statement changes a dataset, a trigger saves these changes in an audit table. • Data models are often made non-standard in order to improve performance. The information is made redundant, because then faster accesses are possible with corresponding indices. Stored procedures are another means of moving application logic within the database. These are proper programs with control structures that are executed within the database and can deliver results. So for example an HTML page can be prepared within the database and sent complete back to the web server. Triggers and stored procedures are created in a programming language called PG/SQL, which is based on Oracle’s PL/SQL, or in PL/Tcl or PL/Perl. So it
Benchmarks Great Bridge, a firm offering professional support for Postgres, issued a press release in August 2000 about a TPC-C-Benchmark, where Postgres performed better than MySQL and two commercial DBMSes. Postgres had no problem keeping up with its commercial competitors, while the other two open source products (MySQL and Interbase) fell behind sharply as their load increased. But the benchmark software used ODBC – this test is therefore to be evaluated with caution, because many ODBC drivers are poorly programmed. Tim Perdue of Sourceforge and PHPBuilder reports on a somewhat more realistic test, where he uses Postgres to stand in for MySQL for part of a PHP-based web site. In this case, Postgres itself scaled about three times better, though page generation does take considerably longer. In the insert test MySQL rapidly collapsed, as it is based on table locking, while Postgres has no problems even with long insert transactions, due to its smart locking algorithm. MySQL also shows, at http://www.mysql.com/information/benchmarks.html numerous benchmark comparisons of database systems, all based on the test suite developed by MySQL itself, and which were also sometimes executed with ODBC.
8 · 2001 LINUX MAGAZINE 25
023-PostSQL.qxd
28.03.2001
19:06 Uhr
COVER FEATURE
Seite 26
POSTGRES VERSUS MYSQL
is possible to develop within the database with these two script languages. Overall, the PostgresSQL dialect and the database’s own programming language are almost of equal value to those of commercial databases and applications can be ported at reasonable expense.
Postgres. Often, though, the developers have taken MySQL as their starting point, so that Postgresspecific features have only insufficient support.
Second Candidate: MySQL
Postgres - interfaces and clients Postgres offers numerous interfaces to other programming languages or systems, including: • LIBPQ, LIBPQEASY • ECPG and LIBPQ++ for C++ • ODBC • TCL • Python • Ruby • JDBC • Perl • PHP • Delphi The migration tools from Microsoft Access are of interest for those migrating. But PHP PGAdmin, the Postgres equivalent to PHP MyAdmin, the popular web front end for MySQL, is still at the nursery stage. It is certainly not that easy to emulate the greater complexity of Postgres on an ergonomic web interface. The acceptance of Postgres will, however, benefit enormously from such a tool. Anyone who wants to can go to http://pgdemo.acucore.com, where you can make databases and tables to your heart’s content and thereby become more familiar with the interface and the database. Most graphical front ends such as Glider and GtkSQL as well as KSQL also work with
Info on Postgres The FAQ-Maintainer Bruce Momjian: PostgreSQL: Introduction and Concepts, Addison Wesley, ISBN:0201703319, online in HTML format: http://www.postgresql.org/docs/awbook.html Postgres sites: http://www.postgresql.org/ and http://www.pgsql.com/ Bruce Momjian’s website: http://candle.pha.pa.us/ Professional support: http://www.greatbridge.com/ TPC-C-Benchmark: http://www.tpc.org Apache today on the benchmark: http://apachetoday.com/news_story.php3 Tim Perdue on MySQL and Postgres: http://www.phpbuilder.com/columns/tim20000705.php3 ■
Transactions: The ACID model Transactions are required to meet the ACID characteristic requirements. ACID stands for Atomicity, Consistency, Isolation and Durability. This means: All operations in a transaction must either be executed in full or not at all, must not create any inconsistent database condition and not be affected by other transactions. The changes resulting from the successful execution of a transaction must also be durably stored in the database.
26 LINUX MAGAZINE 8 · 2001
MySQL is a relational database management system (DBMS) under the GPL. Its origin lies in the database tool UNIREG developed in 1979 by Michael Widenius for the Swedish firm TcX. In 1994 MySQL arose from this project, and this is still being developed today. MySQL now comes in versions for Linux, FreeBSD, Solaris and other commercial Unix variants, the 32bit versions of Windows and also OS/2. The official pronunciation is My-es-cue-ell. People who say ”My Sequel” are not, however, liable to be prosecuted. MySQL has been available for a long time for private users under Linux free of charge and has developed into a near standard for web databases. Since last year, MySQL has been under the GPL. This means ambitious users now have the option of adding the components that are still lacking. But please note that the older versions of MySQL are still subject to the old and highly complicated licence conditions. There is still the option of acquiring current versions of MySQL under a commercial licence, when the components of the database software are intended to be integrated into commercial proprietary products. But there is a legal problem when it comes to what the firm MySQL AB as holder of the copyright understands by the term Linking: For this, it is enough, in fact, if a proprietary, commercially available product relies on MySQL in order to function.
MySQL - Installation MySQL is part of all common Linux distributions. If you want, the installation programs will also set up the database system. There are binaries as tarballs for all common Unix systems and as RPMs for Linux on Intel architecture. The installation is described in great detail for all architectures in the documentation.
MySQL – Standard functions MySQL offers conformity to Standard Entry Level SQL92. Newer MySQL versions support transactions, but user views and nested queries are not provided by MySQL, so these have to be emulated. Take the following example: Person(Person_ID, Name, Forename, Address) Telephone call (Telephone call_ID, Person_IU D, Telephone number) There are two tables, Person and Telephone call with the corresponding attributes. With nested queries, it would be possible without further ado to
023-PostSQL.qxd
28.03.2001
19:06 Uhr
Seite 27
AD
MySQLGUI is the official GUI front end of MySQL.
find out the Name and Forename as well as the Address of the person who dialled a certain Telephone number. A corresponding query looks like this: SELECT Person.Name, Person.Forename, Person.Address FROM Person WHERE Person.Person_ID IN ( SELECT Telephone call.Person_IU D FROM Telephone call WHERE Telephone call.TelU ephone number="0207" ) This is not possible in MySQL and often has to be resolved on the application side. To do this interim results should be stored and evaluated. It becomes problematic when the database changes during this process. Fortunately nested queries can be emulated with MySQL. In the documentation it says in this respect that queries in the form (1) SELECT * FROM table1 WHERE id IN (SELECT id FROM table2); (2) SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM taU ble2); are not supported. The same effect can however be achieved as follows: (1) SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id; (2) SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=taU ble2.id WHERE table2.id IS NULL;
MySQL – Data integrity/Transactions The guarantee of data integrity when using MySQL is incumbent on the application programmer. He must design his database application with sufficient knowledge of the database schema in such a way that the data’s integrity is not jeopardised. In our Person-Telephone call database he can first ascertain with a query in the form
023-PostSQL.qxd
28.03.2001
19:06 Uhr
COVER FEATURE
Seite 28
POSTGRES VERSUS MYSQL
Info on MySQL MySQL Online-Reference: http://www.mysql.com/documentation/mysql/bychapter/ MySQL-Homepage: http://www.mysql.com MySQL PHP-API: http://www.php.net/manual/en/ref.mysql.php mysql.pas: http://www.fichtner.net/delphi/mysql.delphi.phtml Python Interface to MySQL: http://dustman.net/andy/python/MySQLdb/ MySQL++: http://www.mysql.com/downloads/api-mysql++.html MyODBC: http://www.mysql.com/downloads/api-myodbc.html Perl DBI: http://www.mysql.com/downloads/api-dbi.html MM MySQL: http://mmmysql.sourceforge.net/ MyTLC: http://www.mytcl.cx/ Delphi-Interface: http://www.productivity.org/projects/mysql/ Optimization: http://www.mysql.com/news/article-26.html ■ SELECT * FROM Person WHERE Person_ID="100"; that a person with the Person_ID 100 exists. In the next step a telephone call which was conducted by the person with the Person_ID 100 can then be entered in the telephone call table. If no such person exists, a corresponding error message can be generated. The key word FOREIGN KEY is certainly accepted by MySQL - but no error message is given - it is completely ignored. For transactions the current versions of MySQL use secure-transaction tables from the Berkeley Database (DBD). This type of table must be explicitly stated when it is created. Later conversions by means of ALTER TABLE are also possible; for syntax and details, please see the documentation.
MySQL - Expanded functionality MySQL offers lots of syntactical goodies to make life easier for the application developer. For example REPLACE instead of DELETE and INSERT, the SHOW statement, to get information about tables. Even accesses to tables from other databases than the current one are possible. A complete list of all expansions is included in the documentation. Anyone who relies on portability should only use this function with the utmost caution, as it does not work in other databases, or works differently than it is meant to.
Referential Integrity With so-called foreign keys it is possible to guarantee data integrity during the execution of database operations. Thus an address can only be added to a database if there is already additional information on the corresponding person in the database. Foreign key constraints create an error message, if they are violated.
28 LINUX MAGAZINE 8 · 2001
Triggers and stored procedures are not currently implemented, but the latter should be possible in one of the future versions. One clear plus compared with Postgres is the replicability of databases. A slave database can be created on the basis of a master database, and queries can be passed on to the former if necessary. The master creates a binary logfile for this, which the slave updates during a connect. This procedure increases both performance and failure security. Write-accesses to the database must, however, always be done to the master. MySQL has no user views. But these can easily be emulated by the database application. After all, the application program has to read the data out of the database anyway, in order then to display it. So there may be another pre-processing step between reading and displaying, to filter out the relevant data for the user.
MySQL - interfaces and clients As a rule, no halfway-normal user wants to type in SQL instructions purely by hand. (Exceptions prove the rule.) Also, for example, a biologist cannot be expected to learn SQL, in order to insert the findings from his experiments in a database. After all, a database application (see box ”Glossary”) has to be programmed. For the user to be able to manipulate the data in the database via this application program, appropriate interfaces (Application Programming Interfaces, APIs) have to be provided. In MySQL, these are the following: C API JDBC Pascal API PHP API TCL API C++ API ODBC Perl DBI API Python API Delphi API For interactive web content, sites ranging from the private to the serious commercial have proven the value of so-called LAMP projects. LAMP stands for: Linux, Apache, MySQL, PHP. The web front end PHP MyAdmin has been making life easier for MySQL administrators for some time now. Gnome-based and Gtk-based front ends called Glider and GtkSQL respectively can be obtained from Sourceforge. MySQLGUI can be downloaded direct from the MySQL website. This tool needs the FLTK toolkit and serves in the monitoring and administration of MySQL databases. The KSQL Project, which has set itself the goal of creating a database-independent front end for the KDE desktop, is already well advanced. MySQL functions are at present those best supported.
023-PostSQL.qxd
28.03.2001
19:06 Uhr
Seite 29
POSTGRES VERSUS MYSQL
Conclusion Both candidates are reliable and stable open source databases, which are especially but not exclusively suitable as back ends for dynamic websites. Postgres does, however, offer considerably more options than MySQL, which does not meet all the standard requirements for a relational data management system. Postgres on the other hand, with object-relational features such as inheritance and free datatype definitions, actually goes beyond them. So it is better suited than MySQL for the compilation of complex data models. Postgres development is now in full swing again since Version 7.0.x and many administrators are currently investigating the possibility of migrating to this system. MySQL does have the plus points of a very large user community, which has developed an untold number of web applications, especially in connection with PHP. In many cases all one needs is a simple and relatively static data structure and redundancies can also be taken in stride. Then, in some circumstances, MySQL even offers performance advantages, which can even be expanded further to various hosts, if there is a great deal of traffic, with the new option of replicability. Anyone who develops only free software is on the safe side in terms of licence law with both databases. Because of the generous BSD Licence, nor need one worry about commercial applications based on Postgres. But anyone wanting to sell proprietary products with MySQL should look very carefully at the licence conditions on the MySQL website. Earlier versions of Postgres were often unstable and quite often there were even data losses. The Postgres developer team has invested a great deal of time in regression tests, which guarantee high stability and data security. Releases now only occur after longer Beta phases. The new versions of Postgres have become considerably more effective (see box ”Benchmarks”). There are not known to be any serious stability problems with MySQL. With the new feature of replicability, the system has taken another major step in the direction of increased failure safety. Especially in conjunction with PHP, MySQL achieves good performance values in web applications (see box ”Benchmarks”). A paper by the founder of MySQL, Michael Widenius on performance optimisation is recommended in this respect
Swings and roundabouts Where can MySQL and Postgres be put to best use? Both are excellent choices for two large domains: These are firstly program development and secondly Internet databases. Commercial database management systems such as Oracle or
COVER FEATURE
DB2 may be more powerful, but are also more expensive. So as a rule it makes no sense to buy such a product before any applications have been developed for it. This is a great opportunity for free databases. The complete development of database applications can be done on both MySQL and on Postgres. This is made possible for example in PHP applications by transferring all queries in SQL. With skilful programming, in the event of a later porting onto a large database management system, it is only the program-specific functions that are replaced by the corresponding functions of this DBMS. The second domain of application is the already mentioned Internet databases. On the Internet, good performance is what matters most. Also, write operations on databases on the Internet are fairly rare. This is where MySQL’s missing functionality is actually helpful: The less checking that needs to be done, the faster a DBMS is as a rule. Should the respective Internet application become fairly complex, though, and for example also realise insertions in several tables, then Postgres is definitely the better choice. At this point, the disadvantages of the missing functions tip the balance. But at this point, again, (see box ”Benchmarks”) it has to be said that all these performance measurements have their own tricks. All too often, one finds that each system is the best according to one special benchmark. ■
The authors Hagen Höpfner is an IT student at the Otto-von-Guericke University in Magdeburg. In his spare time he is an enthusiastic father and plays guitar in a rock band. (http://www.gutefrage.de) Dirk Gomez has been developing database applications for almost ten years and works at ArsDigita, a supplier of web-based community systems.
Requirements for a DBMS (Codd’s Rules) A certain basic functionality is demanded of databases, which goes beyond simply storing and retrieving data. Over time, a catalogue of functions has come to set the standard. These nine Codd’s Rules are: • Integration: Storage of redundant data leads inevitably to conflicts. So one of the tasks of a DBMS is to avoid redundancies. • Operations: A DBMS must enable the storage, searching and changing of data. • Catalogue: The catalogue stores all the information on the structure of the data. • User Views: These allow data to be filtered. The user of a view is shown only the data necessary to him. Another user can be shown the same data in another context in a different way. • Consistency monitoring: This is intended to make it as hard as possible for the user to violate the integrity of the database. • Access control: A DBMS must ensure that only authorised users gain access to the database. • Transactions: A transaction is combination of various database operations, which must comply with the ACID characteristics (see box ”ACID”). • Synchronisation: In multi-user operation the DBMS must synchronise concurrent database operations. • Data protection: in this connection, data protection means that a DBMS must enable the regeneration of the database – for example, after a system failure.
8 · 2001 LINUX MAGAZINE 29
030-SQLbasic.qxd
27.03.2001
13:58 Uhr
COVER FEATURE
Seite 30
SQL
SQL in brief
NOTES ON QUERIES ULRICH WOLF
Getting started with relational databases can be easier than you might think. Once you have created your data model it has to be converted to SQL. The following two pages will help SQL novices to do just that.
The ”Structured Query Language” SQL is the lingua franca of the database world. Almost all relational databases understand SQL these days, and it is not difficult to learn, either. The language originated in the IBM research laboratories, where it was developed in the seventies. There has been a common standard from the American standardisation authorities, ISO and ANSI, since 1992: SQL-92. Most databases introduced in this magazine conform to a subset, Entry Level SQL-92. There are two aspects to the tasks of database languages: creation of data structures (data definition) and data manipulation. Purists therefore distinguish between ”Data Definition Languages (DDL)” and ”Data Manipulation Languages (DML)”. SQL however is both. The following article will therefore be covering both aspects of the language. We will be take a data model as an example, and we will be converting using PostgreSQL. The version used must be 7.0 or later, as earlier versions cannot cope with foreign keys, which are a part of this data model. To enable us to communicate with the database we need a front end. In the simplest case that will be the program psql; however, simple graphical or Web-based interfaces exist as well. Whichever we are going to use, we have to start by building a data structure, that is to say, by creating tables or relations. We will now create the simplest table: CREATE TABLE vendor ( vid INTEGER, vname VARCHAR(40), 30 LINUX MAGAZINE 8 · 2001
vaddress VARCHAR(100), vcity VARCHAR(40), vzip VARCHAR(7), vtel VARCHAR(40), PRIMARY KEY (vid)); As you can see, the syntax is simple: the name (”attribute” in database language) is followed by the data type, and optionally by the field length. Afterwards we have the option of determining which attribute is to be used as the primary key. None of the entries are case-sensitive, upper case is used here only to differentiate between command syntax and attributes. Each SQL command ends with a semicolon and can extend over several lines. If it does, the psql prompt will change from database name=> to database name (->, to indicate that the command is not complete. In the relation pc below, a foreign key indicated by the keyword references appears in addition to the primary key. We have also introduced the data type DATE: CREATE TABLE pc ( pcid INTEGER, vid INTEGER REFERENCES vendor, type VARCHAR, purdate DATE, PRIMARY KEY (pcid)); As we are only concerned with syntax, these two tables should be sufficient. Now it’s time to provide some content for them. In most cases the command INSERT INTO is used for this purpose:
030-SQLbasic.qxd
27.03.2001
13:58 Uhr
Seite 31
SQL
Listing 1: Two small tables with simple queries osadmin=> select * from pc; pcid | vid | type | purdate ———+——-+————————————-+—————— 1 | 4 | Desktop PC | 20/01/1999 2 | 4 | Laptop | 24/12/2000 3 | 5 | Sun server | 06/08/1992 (3 rows) osadmin=> select * from vendor; vid | vname | vaddress | vcity ——-+————-+————————————+——————-+———-+——————1 | Red Hat | 10 Alan Turing Road | Guildford 2 | SuSE | Theobald Street | Borehamwood 3 | VA Linux | Whitehill Way | Swindon 4 | IBM | PO Box 41 | Portsmouth 5 | Sun | Guillemont Park | Camberley (5 rows) INSERT INTO vendor VALUES ( 1,’Red Hat’,’10 Alan Turing Road’, `Guildford’,’GU2 7YF ‘01483300169’); Postgres also provides the COPY command, which unfortunately does not conform to the standard. This is an easy way of reading in data from ASCII files that have for example been exported from a spreadsheet. Ultimately it is not data entry options that distinguish databases, but the diversity of query facilities, in the case of SQL using the SELECT command. In its simplest form SELECT * FROM table; returns a complete table with all computers and all vendors, as in Listing 1. That is of course not sufficient. Listing 2 therefore presents a more useful query, which returns all computers manufactured by Sun, together with the purchase dates. As you can see, there is only one. Nested queries are possible in almost all database systems. In MySQL they have to be written differently; this is described in the comparison between Postgres and MySQL elsewhere in this issue. The SELECT command is the heart of SQL and offers an enormous range of possibilities: sorting by specific criteria, grouping of results, pattern matching with LIKE and many more, which are beyond the scope of this article. We will just give one more short example of how entries can be amended with a combination of UPDATE and SELECT, after all, that is part and parcel of database functionality. In the admittedly somewhat contrived
| vzip
|
| | | | |
| | | | |
GU2 7YF WD6 4PJ SN5 6QR PO6 3AU GU17 9QG
COVER FEATURE
vtel 01483300169 02083874088 08702412813 0990426426 01276451440
case that we only remember the purchase date of the server, but now the telephone number of the vendor, who we do not know has changed, we can update it as shown in Listing 3. Finally two options for getting rid of data. Complete tables are removed without any fuss using DROP tables;, individual rows with DELETE where conditions can be set in the same way as for UPDATE. A simple example: The Notebook has been sold and we are going to remove its record from the database:
Info SQL Tutorial: http://dblabor.f4.fhtwberlin.de/morcinek/sqltutor
DELETE FROM pc WHERE type = ‘Laptop’; There are a number of pitfalls to watch out for, especially something called cascading deletion when using foreign keys. Nevertheless, these few glimpses of SQL should be enough for you to take your first steps, and then get more deeply involved if necessary. The subject can be more exciting than you might think, and SQL has hardly become unfashionable, despite object orientation and XML. There is no shortage of literature on SQL. ■
PostgreSQL Homepage: http://www.postgresql.org For creating online Postgres databases and ”playing”: http://pgdemo.acucore.com ■
Listing 2: Using SELECT osadmin=> select type, purdate from pc where vid = osadmin-> (select vid from vendor osadmin(> where vname = `Sun’); type | purdate —————————————+—————Sun server | 06/08/1992 (1 row)
Listing 3: UPDATE combined with SELECT osadmin=> update vendor SET vtel = ‘01252421730’ WHERE osadmin-> vid = osadmin-> (SELECT vid from pc where purdate = ‘06/08/1992’); UPDATE 1 osadmin=> select * from vendor osadmin-> ; vid | vname | vaddress | vcity | vzip ——-+—————+————————————-+———————-+———-+————— 1 | Red Hat | 10 Alan Turing Road | Guildford | GU2 7YF 2 | SuSE | Theobald Street | Borehamwood | WD6 4PJ 3 | VA Linux | Whitehill Way | Swindon | SN5 6QR 4 | IBM | PO Box 41 | Portsmouth | PO6 3AU 5 | Sun | Guillemont Park | Camberley | GU17 9QG (5 rows)
| | | | | |
vtel 01483300169 02083874088 08702412813 0990426426 01252421730
8 · 2001 LINUX MAGAZINE 31
032-vmware.qxd
28.03.2001
8:30 Uhr
Seite 32
ON TEST
EMULATORS
Win4Lin versus VMware Express
TOURIST GUIDE
THOMAS DRILLING
Emulators allow programs from guest operating systems to run under Linux. The two commercial solutions Win4Linux 2.0 Desktop and VMware Express are direct competitors – we compare and contrast them here.
Win4Lin from Netraverse is available in Version 2.0. The Express economy version of the popular hardware emulator VMware is aimed at the same market segment. Unlike the Workstation version, this only allows the use of Windows 9x as guest operating system. To run native Windows32 programs under Linux, there are currently three solutions: Wine, VMware and Win4Lin. While Wine copies Windows system commands, so is a sort of pure API emulator, Vmware emulates a complete virtual PC with BIOS, peripherals and so on in an X-window, so is a true hardware emulator.
Win4Lin hybrid Win4Lin is halfway between the two extremes. With Win4Lin, Windows 9x can be installed in an Xwindow. Windows programs will then run at close to their original speed. Also, the Window-Windows boots faster than a real one. Unlike Vmware, Win4Lin reproduces Windows file systems direct into the Linux file system relating to the home directory of the user. Win4Lin is especially suitable for the efficient execution of native Windows applications, so that Win4Lin, in comparison with Vmware, manages with considerably more modest hardware. Unlike 32 LINUX MAGAZINE 8 · 2001
version 1.0, version 2.0 now also supports SMP, sound and European versions of Windows 9x. For networkers, this may be of interest: Win4Lin registers the original Windows CAB files on a Win4Lin shared directory of the Linux host. For additional user-specific Windows installations, no CD is required, just the Windows licence key. But the Windows licence is not included in the price. The latest Win4Lin version 2.0 can be obtained from Netraverse for $90 at https://www.netraverse. com/frame_index.php?screen=shop. Netraverse also offers (as does VMware) a 30-day test version at http://www.netraverse.com for downloading. The demo version can be released later with a licence key for 60 US dollars, which saves a bit compared with the CD version. Win4Lin runs at least with SuSE-Linux 6.x, Red Hat 6.x and 7.0, Caldera 2.2 and 2.3, Caldera eDesktop 2.4 and Mandrake 6.1 to 7.1.
Installing Win4Lin The complicated and time-consuming installation of Win4Lin was the main fault in version 1.0. Unfortunately, this has not really improved much. The installation scripts only work for the CD version. The download version displayed a few snags in a test installation.
032-vmware.qxd
28.03.2001
8:30 Uhr
Seite 33
EMULATORS
In principle, the Win4Lin installation (regardless of whether it’s the CD or download version) is carried out according to the following pattern: First a kernel specially adapted for Win4Lin must be installed, and a few other preparations may also be necessary, such as a Glibc Update. Netraverse provides the appropriately adapted kernel for the most common distributions and updates and patches (Red Hat Erratas) on its FTP server. Next, boot up with the Win4Lin kernel, where the kernel installation script of Win4Lin automatically adjusts the Lilo configuration. Other boot configurations (such as Bootdisk or Grub) are not taken into account at present. Next, install the Win4Lin binaries and put in the licence file.
Hooks and eyes: Installation in practice To register the evaluation licence, to download the demo-version itself, and for the installation of the Win4Lin kernel, Netraverse provides the script quickdownload.sh online. After that, reconnect to the Netraverse server on the host on which the Win4Lin is to be installed and start the script quickdownload.sh locally. It analyses the existing system environment and creates from it the necessary download files. Sadly, this won’t work if you do not intend to install Win4Lin on the same computer as the one with Internet access. In the next step the Win4Lin Linux kernel adapted for the version of Linux in use should be installed, though in one or two distributions this only works if a few patches, also found on the Netraverse server, and/or system expansions, have been installed first. For the kernel installation the manufacturer provides an installation script on the FTP server, which can be found at $HOME/downloads/ Win4Lin/Linux_Kernels/install_kernel. The script analyses the actual system to find out whether kernel adaptation patches or updates are necessary, installs the modified Win4Lin kernel and adapts the Lilo configuration. So much for theory. The script is only intended for the CD version and does not run through with the download version. But it is certainly useful for determining the system requirements. On a RedHat test computer for example it complained about the lack of the RedHat Errata updates due to the faulty Glibc version in Red Hat 7.0. The requisite updates were obtained from the Netraverse server and it was also possible to install them. Of course, this also works with a regular RedHat Errata.
ON TEST
kernel via Lilo on the hard drive. So anyone who installs Lilo on a boot disk or uses a different bootloader is going to feel pretty lonely. The adapted Lilo configuration should then be written manually on the boot disk (Lilo option boot=/dev/fd0). Using the parameters install=/boot/boot.b and map=/boot/map the Lilo boot sectors can also respond directly to the diskette, provide these have previously been copied thereto with dd.
Win4Lin binaries After rebooting, you can execute the actual Win4Lin installation script under $HOME/downloads/ Win4Lin/Win4Lin2.0eval/Win4Lin/ install-Win4Lin.sh. Since it is searching for the Win4Lin CD, the testers tried out their RPM command line know-how. While the installation of RPM is in progress, the end user licence, EULA, is displayed and has to be confirmed before being unpacked any further. In the final step of Win4Lin installation, an existing Windows CD should be read in. To register the Windows CD the Win4Lin configuration module winsetup can be used (as root). To do this, you go to the main menu item System-Wide
The CAB files from the Windows original CD are loaded only once onto the Win4Lin shared drive J: and are available for additional installations.
Lilo manual labour The kernel installation script also writes an adapted lilo.conf file under /etc for booting the Win4Lin 8 · 2001 LINUX MAGAZINE 33
032-vmware.qxd
28.03.2001
8:30 Uhr
ON TEST
Seite 34
EMULATORS
/var/Win4Lin/install. A Windows session is started with win, the configuration module with winsetup.
Win4Lin configuration
With Winsetup, Win4Lin can be configured fairly easily.
VMware emulates the whole PC exactly in an Xwindow, on which Windows 98 then installs itself as on a real PC.
Win4Lin Administration and there select submenu Load Windows CD. To complete the installation of the Win4Lin download version, all that is now needed is the licence file. This is sent via email, if you have registered online and is to be put in under
Windows installation in a Win4Lin session goes perfectly. 34 LINUX MAGAZINE 8 · 2001
After installation, Win4Lin is ready to use, as long as you are willing to live with the default configuration. All users apart from root can start a windows session by entering win. With the first win the Windows installation in the Win-Box is commenced. The graphical Win4Lin configuration tool winsetup serves to adapt the multi-faceted drive and path allocations for Windows sessions as well as the waiting hardware devices, such as ports or printer. This is also the point when the behaviour of the VGA mode is adjusted. Winsetup is divided into a system-wide part (as root) and a user-specific part, in which each user configures his own sessions. The personal Windows drive, C: is reflected under $HOME/win under Linux. In the system wide part the Windows CD can be read in, among other things. The graphical user interface of Winsetup is certainly fairly clear but is also knitted to a very simple pattern – it doesn’t compare with the modern and pleasant wizards in the VMwareExpress configuration. The actual Windows installation runs similarly to that on a native Windows system. The simplest thing is to call up Personal Win4Lin-Session.... in Winsetup. Your personal drive starts with the Start button. The same thing is achieved from the menu item Personal Windows setup or win on the Linux command line.
032-vmware.qxd
28.03.2001
8:30 Uhr
Seite 35
Linux IT
032-vmware.qxd
28.03.2001
8:30 Uhr
Seite 36
ON TEST
EMULATORS
and drop between guest and host, diverse network modes (VPN, LAN, Dial-UP, Samba), sound, Highcolor-VGA and lots more. The hardware requirements, apart from that for memory, are moderate in view of the functional principle, but considerably higher than in Win4Lin. A standard PC at 266 MHz and at least 500MB disk space to accommodate the emulated EIDE-hard disk is sufficient. The speed of VMware profits in a particular way from the size of the main memory on the host, since host and guest share the physical memory hardware. An absolute minimum would be 128MB, but otherwise remember: the bigger, the better. VMware was tested with SuSE and Red Hat 6.x to 7.0, Caldera 2.x and TurboLinux.
Alphabet soup
The Personal Drive of Win4Lin is also emulated in the Linux file system.
Win4Lin confronts the user after installation in the first instance with a bewildering maze of different drive letters. After studying the excellent English documentation it all quickly becomes clear: As the basis for the Windows-9x installation, one C: drive serves as the so-called Personal Drive per user. In the Linux file system this drive is emulated under $HOME/win. If there are space problems – though a standard Windows must fit in each case – it might help to have symbolic links to other partitions. There is also a J: drive each, which as the shared drive, provides DOS and Win4Lin system files for all users. It also records the Windows-CAB files from the installation CD, so that any Win4Linux user without a Windows CD can create his own Windows sessions on his Personal Drive. The location of J: in the Linux file system is /var/Win4Lin. Apart from the obligatory floppy drives A: and B: it is also possible to configure access to a Linux CD-ROM drive in the system-wide Win4Lin configuration with the drive letter N:. Also, Win4Lin can set up any DOS sessions you like on the basis of a virtual drive or a native DOS partition. As a template, Win4Lin provides the virtual DOS device D: with a rudimentary DOS 7.0 system.
Vmware Express VMware Express is not really a new product, but a variant of VMware, which is restricted to the use of Windows9x as guest operating system. But on the other hand the price, at about £85(for example from Linux Emporium) is considerably lower compared with the Workstation version at £275. VMware is a hardware emulator, which means the software virtually emulates a complete standard PC environment in an X-window. Then you can install Windows 95, 98 or 98SE as guest operating system. VMware also controls file sharing via drag
Installation and configuration of Vmware Express The installation and start of operation of VMware Express are child’s play, compared with the contortions in Win4Lin. Both the installation of the host with the aid of the Perl script VMwareconfig.pl, and that of the Windows guest systems with the aid of graphical assistants, went without a hitch. In principle, the installation of Vmware is done according to the following steps: 1. Installation of the RPM binaries of the host software. 2. Configuration of the hosts/guest with the script VMware-config.pl. 3. Configuration of the virtual PC with the aid of the Vmware configuration wizard or of the Vmware configuration editor and adjustments in the Phoenix BIOS of the virtual PC 4. Installation of the guest operating system Windows. After that, the virtual PC can be started with Power On. But no operating system has been installed yet, which means the virtual PC acts like an ordinary PC with no operating system. For Windows installation from CD you switch the boot sequence in the BIOS of the virtual PC to CD.
Measurement technique and conclusion In the 2D graphics domain, both emulators offer adequate reserves for practical working with Word
CPU– Benchmark
Video–Benchmark
900 0
175
800
150
700 125
MB/s
600 500
100
400
75
300 50 200 25
100 0 Fill
36 LINUX MAGAZINE 8 · 2001
Move
Copy
Integer
Pointer
Vektor Hardstones Softstones
0 Pixel*1000/ms
Bitmaps/s
Icons*100/s
Zeichen/ms
Polygone*100/s
032-vmware.qxd
28.03.2001
8:30 Uhr
Seite 37
EMULATORS
ON TEST
Vmware provides a handy assistant for the client installation, the ”VMware Configuration Wizard”.
& Co. Nevertheless, on the subject of VGA performance, the following facts are worth mentioning: Win4Lin is currently having massive problems in practical use with its image-refresh. Often image areas overwritten by Linux-window are simply not restored. It may be possible to alleviate this situation somewhat by means of VGA optimisation. The image output in VMware is certainly torturously slow after the basic installation, but error-free. For this, VMware delivers its well-known graphics tools as part of the package, and these are now an integral part of the product and no longer have to be loaded separately from the Vmware server. It is easy to put them into operation, thanks to wizards. After that, VMware ran on our test computer at 1600 resolution in high colour with impressive graphics performance.
Win4Lin plays its speed trump at file level A physical hard disk benchmark by means of blockwise disk-I/O can only be executed with the emulators on the basis of the virtual devices. But one of these is not necessary in the default configuration of Win4Lin. Equally telling is the logical disk-I/O at file system level (C-drive benchmark). This is where Win4Lin plays its trump and impressively confirms the subjective impression of the testers. On the basis of the emulation of the logical Windows file system in the Linux file system, it is precisely in connection with its write buffer that a greater access speed is achieved than with native Windows.
The disk-I/O on the virtual devices of VMware is certainly considerably behind in comparison with Win4Lin and also native Windows, but viewed subjectively is still tolerable. Nevertheless in the virtual image files of Vmware, again, the read-cache of the Ext2 host system gives an extremely positive impression. Last of all, it has to be said for Win4Lin 2.0 that a Windows session is booted up sensationally quickly. VMware comes in last when booting, too. Nevertheless, on balance the conclusion remains: VMware is the only Windows emulator with which truly practical work can be done, because it works plainly and simply. Win4Lin certainly does offer some rather fascinating technology, but will never be taken seriously by users until Word & Co. can be used on a daily basis. ■
Conceptual differences While VMware foresaw, from the original development concept, access to DOS/Windows file systems solely via virtual devices, which for their part mirror the complete FAT file system of the guest operating system in an image file based on the Linux file system (similar to the Cooked Files of a DBMS), raw disk support, which means direct access to native DOS partitions in Vmware, was only implemented later on. One advantage of the image file method is that the image file can be seen in the Linux file system and can thus be handled. Win4Lin can in fact also cope with virtual devices, but pursues a different concept: It models the Windows file system on the Linux file system, which is linked with some technical expense (see Samba). In the case of Win4Lin the user finds all Windows directories in the Linux directory tree. Win4Lin has three types of drive: Windows directories mapped to drive letters, native DOS devices (physical DOS partitions) and so-called virtual DOS devices, similar to the VMware method.
8 · 2001 LINUX MAGAZINE 37
038-Viavoice.qxd
28.03.2001
17:17 Uhr
ON TEST
Seite 38
VIA VOICE
Speech Recognition
LISTEN AND LEARN IVAN ANASTASOVSKI
I am not a touch typist. Actually I am not a typist at all. For me, typing is a slow and laborious process involving two fingers, much frustration and mostly imperfect results. When I type I hit the keyboard hard. For punishment. All those among you feeling the same have much reason to rejoice - the dictation software is finally available for Linux.
The userguru is used to start the software training session
IBM’s ViaVoice dictation package for Linux comes with a special active microphone that provides for filtration of background noise. The software included on the CD also provides text to speech functionality. Unfortunately, JAVA runtime necessary for proper functioning of the software is not on the CD. What we need is JAVA runtime for
Linux from the blackdown.org site. http://www. blackdown.org/java-linux.html. The version of Java this ViaVoice release has been tested with is JRE1.2.2 revision RC4. I first downloaded JAVA runtime from Blackdown and installed it under /usr/local The next step is to change your path to include PATH to JAVA runtime (to make it permanent, change the appropriate bash configuration file) # export PATH=/usr/local/jre1.2.2/bin:$PATH Now we install IBM ViaVoice Software: # mount /mnt/cdrom # cd /mnt/cdrom # ./vvsetup There will be a licence agreement to read and click through, it will check for the presence of the Java runtime and it will, at the end of it all, give you your prompt back. Unmount the CD-ROM. # umount /mnt/cdrom And on to the configuration - change to your normal user account, fix your PATH to stumble across your brand new JAVA runtime before finding any other hiding in the nooks and crannies of your
38 LINUX MAGAZINE 8 · 2001
038-Viavoice.qxd
28.03.2001
17:17 Uhr
Seite 39
VIA VOICE
ON TEST
vast hard drive (geeks dream too), and invoke: # vvstartuserguru The first screen allows you to choose a Profile Name under which the training session will be saved. From there you go to the screen which gives rather precise instructions on just how to adjust your microphone for the best possible results. The next screen allows you to test the playback capability of your sound card and to adjust its volume to a comfortable level. If all is not well, you need to get your sound card properly configured. Older cards are probably best configured using #sndconfig utility, while for the modern cards you are best off using the ALSA drivers. Now we come to the often treacherous bit microphone configuration. You click on the start button and read the given paragraph of text repeatedly until it beeps at you. If everything is OK it will beep very quickly and pronounce the quality of the sound excellent. The worst case is if it tells you that there was no output. Check your microphone connection to the sound card, keeping the wire away from any sources of electromagnetic interference’s and adjust the mixer settings. Right click on the microphone slider and make it the recording source, increase the microphone volume and gain and check if decreasing the volume of various other inputs lowers the line noise. If none of this works, it is very likely that your sound card is misconfigured. Look in the boxouts for examples. Once you get your microphone to behave, you are ready to start a training session. Now just who is training whom is not entirely clear but the process should contribute to a long and fruitful future away from the keyboard (eventually). The result of this encounter is called Personal Voice Model. There are four texts to choose from - two short ones and two long ones, one of each being somewhat technical and the other one being somewhat literary. Choosing
the long one results in better understanding between the parties involved. Being the only one who can press Ctrl+C and therefore having the upper hand (or the illusion of), I have chosen the short somewhat technical one. As you read it, the program highlights the parts corresponding to your vocalisation. If it gets stuck, it beeps at you, at which point you are meant to go back to the first non highlighted word and start again from there. Once it has enough data it will go and play with the recording for a while (it estimates its playtime at 15 to 35 minutes - it actually took about three or four minutes on the test machine). When it comes back, it should be just familiar enough with your particular speech patterns to make dictation sessions accurate enough to keep you using it while it learns more about you and becomes better at its task. To start a dictation session, we issue a command: $ vvstartdictation
Choosing a story to train.
Adjusting the microphone settings
8 · 2001 LINUX MAGAZINE 39
038-Viavoice.qxd
28.03.2001
17:17 Uhr
ON TEST
The word processor supplied
Seite 40
VIA VOICE
do the corrections is to use the voice commands to move about and edit. These commands together with commands to enter symbols are nicely grouped in a ”What Can I Say” Window that can be displayed conveniently aside the main window. This is probably better left to the fortunate ones who are already good friends with this dictation software. Another of the features is the Correction window. It allows the addition of phrases to a Personal Profile, thereby customising the software to the user and improving accuracy. Dictation program can also do text-to-speech conversion. It can do it in one of two ways. It can play the highlighted text back to you in your own voice and in your own words exactly, or it can read to you its own take on what you dictated instead (in a voice somewhat resembling Stephen Hawking on an off day, and with an American accent). This feature is actually very useful - you can dictate a long peace from your bed, and even if there were a lot of mistakes in the captured text, you can still replay the original and do the corrections. A window pops up. Among all the usual and expected window dressings, it contains an icon of a microphone. When it is green the window accepts the input from the microphone. As you speak, the words get recognised in short bursts of activity. It appears that the program does not work with single words, but with groups of words that it considers belong together. There are several ways to make the corrections - one of which is by highlighting and then speaking - quite often, even though you spoke only one word, it will still overwrite with several words which it thinks belong together. This presumably improves with usage. Another way to
Finally all working
40 LINUX MAGAZINE 8 · 2001
Conclusion: Providing the hardware is properly configured, and one does not diverge significantly from the recommended versions of other necessary software, installation is fairly painless. This does not happen very often. The software uses features on the sound cards rarely used by other applications. Even when a sound card appears to be working correctly with other applications it still often fails with ViaVoice. This is not IBM’s fault, but a deficiency on the side of configuration utilities in current distributions.
038-Viavoice.qxd
28.03.2001
17:17 Uhr
Seite 41
VIA VOICE
However, what is IBM’s fault is the absence of the technical support in general and especially the nonexistence of the hardware compatibility list that includes necessary settings to put in /etc/modules.conf to make it all work with minimum of trouble for everybody involved. On the usage side, it feels very agile, light on its legs and surprisingly quick to follow. To start with, considering very minimal Profiling phase it is not too accurate. If used properly, with constantly feeding it all the corrections it improves quickly. To start with, the most disconcerting feature to me, was its usage of phrases instead of the single words in taking the dictations but even more so in doing the corrections. In a while one gets used to it - if one pays the attention, it can even give him an insight or two into the structure of the language as we employ it in everyday usage. On the test machine, after an easy and mostly trouble free installation of software on top of fully and correctly configured hardware the ViaVoice worked well. However, the xterm from which I started it, filled with error messages regarding missing fonts as well as some very strange looking symbols, for the lack of better word. It didn’t affect the functionality. I also tried installing it on a Mandrake 7.2 machine with SoundBlaster 128 PCI card which was incompletely configured. After sorting the proper configuration using ALSA drivers the installation and the profiling of software went well. However when I tried to run the dictation software it crashed with messages about language incompatibilities - I had US version of ViaVoice and the machine was installed with UK localisation. Strangely, this didn’t happen on the Test RedHat 6.2 machine also with UK localisation. This peace of software is something that I personally always wanted to have. It fits very well with my typing skills (or rather the lack off), and with my pattern of keyboard usage. It is excellent for people who use a keyboard mostly as a command console and rarely for typing and therefore are not touch typists, but still occasionally need to enter long textual input. It is not good for people who share the office with others, or for people like programmers who often move about their code between various files full of strange formatting. It is ideal for professionals like solicitors and doctors as well as for authors - one can lie in the bed and dictate for ours - as it doesn’t feel to have the finality of putting things in black and white, it can do wonders for alleviating the writers block. It is probably most useful to the people with physical disabilities for obvious reasons. In short, from me ViaVoice gets a thumb up - if it gets the hardware compatibility and configuration list it gets both thumbs up - I will be doing my dictations from my bed. ■
ON TEST
SoundBlaster 128 PCI configuration I tried to install ViaVoice using this card on a machine with Mandrake 7.2, only to find that Mandrake installer configured the soundcard only partially causing it to fail. These settings worked for me allowing full installation and the initial training of ViaVoice. When I tried starting the dictation program itself, it failed complaining about wrong language - the test software is an early US version and the machine had an UK localisation. I am working on it :). /etc/modules.conf: alias char-major-116 snd alias char-major-14 soundcore alias snd-card-0 snd-card-ens1371 alias sound-slot-0 snd-card-0 alias sound-service-0-0 snd-mixer-oss #alias sound-service-0-1 snd-seq-oss alias sound-service-0-3 snd-pcm-oss #alias sound-service-0-8 snd-seq-oss alias sound-service-0-12 snd-pcm-oss
IBM installation requirements Hardware: Processor performance equivalent to Intel Pentium 233MHz with MMX with 256K L2 cache 128MB of RAM in total 140MB available hard disk space Linux compatible 16 bit sound card of good recording quality (with microphone input jack) CD-ROM drive Andrea NC-61 Microphone or equivalent Software: Red Hat Linux, Version 6.2 with sound installed and enabled Java, version JRE-1.2.2 revision RC4 http://www.blackdown.org/java-linux.html Actual Test Hardware used: Intel Pentium 650MHz with MMX with 256K L2 cache 128MB of RAM SoundBlaster 16 CD-ROM drive Andrea NC-61 Microphone {included} Software: Red Hat Linux, Version 6.2 with sound installed and enabled Java, version JRE-1.2.2 revision RC4 http://www.blackdown.org/java-linux.html Test System Sound Card Configuration /etc/conf.modules(modules.conf): alias sound-slot-0 sb options sound dmabuf=1 alias midi opl3 options opl3 io=0x388 options sb io=0x220 irq=5 dma=0 dma16=5 mpu_io=0x330 The sound card I used is an old ISA SoundBlaster 16. All the settings are self explanatory except for dmabuf=1. ISA cards need the memory under 16MB for DMA access, and this setting reserves the required amount after the Kernel boots up and before other memory munching programs eat it all up
8 · 2001 LINUX MAGAZINE 41
042-USBprinter.qxd
28.03.2001
7:48 Uhr
ON TEST
Seite 42
USB PRINTER
USB Scanner and Printer on Test
WORDS AND PICTURES CHRISTIAN REISER
Thanks to kernel 2.4, problems with USB devices should now be a thing of the past. This is also largely true for printers, but in the case of USB scanners one has
to use discrimination, as
our combined test shows.
Absolutely SOHOcompatible: But the Lexmark Optra E312 can only produce 10 pages per minute in combination with a fast computer
Without a Postscript expansion module the HP DeskJet 1220C cannot quite fulfil its potential
The time has finally come: 2.4.0 is here! Of course, we also took this into account in our test: All devices were tested with both series 2.2 and with the series 2.4. Let’s get one thing out of the way right from the start: If one considers only USB, then the printer test was a hundred percent successful. Each printer was recognised immediately, and data could be sent to each printer. Unfortunately, creating this data was not always simple, and the necessary filters did not always deliver a perfect print image (only the Optra M410 required no special filters). In the case of colour printing it was always necessary to experiment with
42 LINUX MAGAZINE 8 · 2001
various filters and settings, and the differences in quality of the results could be enormous. With black/white, though, the print image was satisfactory right from the start on all the models tested. The inkjet printers all have two cartridges: a black/white and a 3-colour, which in some devices can be swapped for a photo cartridge (6 colours).
Canon BJC-2100 The BJC-2100 is the cheapest model from Canon. Just like the Epson, it has no on/off switch, but it does at least have a button for ejecting paper (with subsequent resetting of the printer). There is also a sensor indicating that the flap to the printer unit is open. So inserting cartridges is no problem. The
042-USBprinter.qxd
28.03.2001
7:48 Uhr
Seite 43
USB PRINTER
first sample print with Ghostscript worked straight off: then the cartridges were cleaned in just under half a minute. After that the printer produced 2 pages per minute. Subsequent print jobs also started without the cleaning procedure, immediately after the start of the transfer. Documents in colour were printed handsomely, although some major weaknesses came to light during the colour transitions: The contrast when changing from the colour to the black/white cartridges is incalculable. For a printer driver, bjc2000 from Gimp-Print is recommended, although this only produces sufficiently good results on the paper setting ”Glossy Photo Paper”.
Epson Stylus Color 580 The plastic housing of the Epson Stylus Color 580 has not a single button or knob nor even any status indicators such as LCDs or LEDs. It was also an adventurous undertaking to insert the ink cartridges: For Windows there is presumably an appropriate software tool, but with Linux the only option is to take the plug out of the mains during initialisation, in order to get the print head, which is going crazy, into an appropriate position to install the ink containers. After that, the hunt for drivers begins, and strikes lucky on the Epson homepage: Here there is a reference to xw_tools - a commercial product, for which you have to pay extra. Not a nice stroke for Epson to pull, because when a printer costs around £60, 15 Euros is a relatively large sum. But sadly there is no alternative: it is just a GDI printer, with which it is not even possible to print out ordinary ASCII text. With xw_tools normal document printing is quite passable. But a colour print out at a resolution of 720 dpi takes about 18 minutes. Every other printer in the test was considerably quicker here. Images take even longer. The printer always pushes the paper through the printer at the same rate. The compress option does speed up the print procedure somewhat, but at 15 minutes it’s never going to break any records. The biggest problem with this is the main memory usage ofxw_print, the actual filters. Thus, this program needs a whole 204MB of memory for one page at 720 dpi, as the complete page first has to be constructed in the memory and is only then sent to the printer. With too little memory and a big swap partition the printing of a ten-page document becomes a full evening’s work. Which is why the Epson Stylus Color 580 is not recommended for the normal user.
ON TEST
Lexmark Z52 The current top model from Lexmark was the best device in the test. With the driver supplied by the manufacturer, the printer was recognised immediately at start-up and the photo print-out is unequalled. The tgz packet includes an rpm file together with the obligatory README with a brief description of the install procedure and the software. After a simple rpm -i lexmarkz52-1.0-1.i386.rpm the necessary files are then found in the directory /usr/local/lexmark/z52. The settings can be saved in /var/spool/lexmark/z52.conf or in the home directory of the user, as required (~/.lexmark/z52.conf). Installation of the rpm packet has to be done with the X-server running, because then the configuration program (/usr/local/lexmark/z52/lexmarkz52) is also started automatically. This makes it easy to calibrate the printer and produce a test page. Settings relating to size and type of paper are also possible at this point. As ”Input filter” you must specify /usr/local/lexmark/z52/z52.sh, and then off you go. As long as you are only printing black/white, the Lexmark Z52 barely differs from the other devices. But when it comes to colour and photo printing a clear difference in quality becomes apparent. The near-photo quality achieved is spoilt only by rare and yet also rather cute white horizontal stripes. The colour stability matches the original like no
Filter for Epson Stylus Color 580 #!/bin/bash TMPFILE=`mktemp /tmp/epson.XXXXXX` cat > $TMPFILE gs -sDEVICE=ppmraw -q -dNOPAUSE -dBATCH -r720 -sOutputFile=- $TMPFILE | U /usr/local/bin/xw_print -usbEps -dev epsC580 -density 720 -compress
HP Deskjet 840: Optimum photo printing only if the images are manually pre-processed
Linux always makes friends fastest with a real Postscript printer here with the Lexmark Optra M410
8 · 2001 LINUX MAGAZINE 43
042-USBprinter.qxd
28.03.2001
7:49 Uhr
ON TEST
Only partly Linux compatible: The driver software of the Epson Stylus Color 580 gobbles up too much memory
Seite 44
USB PRINTER
other printer in our test. For this reasons, it is easy to get over the fact that speed of black/white printing lies in the lower average range (approx. 1 min/page). The binary-only driver runs as user-space program and therefore has no effect on system stability. But anyone who does not trust the closedsource product can use Gimp-Print as an alternative, although this does not quite match the quality of the manufacturer’s driver.
Lexmark Optra E312L The Optra E312L is the cheapest Lexmark laser printer. For this reason, it is also supplied with the economy measures common to this class: Horizontal paper trays, no menus and just two
controls: A button for Reset and an On/Off switch. The latter commendably really does isolate the printer from the mains. The quality of the text printout is subjectively very good. Although the printer unit can only come up with 600x600 dpi, the electronics can also process 1200x1200 dpi, although with a pure grey there were some slight irregularities visible. As print filter it is best to use ljet4 from Ghostview: The printer speaks PCL 6. The speed is perfectly adequate for use at home and in small offices. At a measured rate of six pages per minute even large documents are childsplay and the paper out tray is big enough for over 100 sheets with no problem, which means the printer can certainly be left for 20 minutes to print unsupervised. The manufacturer’s specifications give ten pages per minute, which could well be correct. For this speed, though, a 700MHz computer is recommended in terms of coping with the requirements of the software printer filter.
Printing under Linux/Unix Printing under Linux/Unix is firmly linked with Postscript. This ”programming language” was developed in the mid-80s by Adobe and has become a standard in the professional print domain. This language provides a wide variety of commands such as the positioning of letters and the drawing of simple geometrical bodies. Postscript printers always have a powerful and specially-cultivated processor, in order to be able to process the drawing commands quickly to be ready for printing. Hence it is usually enough merely to send a professional printer a Postscript file. The only printer in our test which can directly process Postscript is the Lexmark Optra M410. Under Linux/Unix, basically, every program which wants to print produces Postscript code. In an ideal case this is simply sent to the printer port. But since the printer manufacturers want to save money, it is becoming rarer for them to equip their printers with intrinsic intelligence and they are transferring the Postscript interpretation and thereby the creation of the actual print image into the computer itself. With the Epson for example this interpretation takes up to one minute per page (an dthat is with a 1GHz processor). The processor integrated in the Optra M410 on the other hand manages ten pages per minute. For conversion there are several different printer filters; the two main free open-source projects in this domain are Gimp-Print and Ghostscript. Both can create a large number of different printer dialects. In this article, though, there are still two more printer filters to look into: xw_tools and the Z52 driver from Lexmark. A rough guideline as to which filter should be used for which printer can be found at Linux-printing.
44 LINUX MAGAZINE 8 · 2001
042-USBprinter.qxd
28.03.2001
7:49 Uhr
Seite 45
USB PRINTER
ON TEST
Lexmark Optra M410 This device behaves as one would expect of a Postscript printer: A simple test using cat myfile.ps >/dev/usblp0 immediately brought the required document to light - no setting and optimisation of print filters necessary. Here the print unit matches the manufacturer’s specifications: 10 pages per minute are completely realistic. The printed image is immaculate. It is only the grey shades at 1200 dpi which are not always one hundred per cent homogenous. The device we tested had a 16MB expansion, as the result of which most text documents are completed for the spooler very shortly after the print command, although the printer carried on printing merrily for several minutes. (For a better estimate: A one-page Latex document usually needs no more than 50KB). All options of the printer can be changed directly via an LCD menu on the device. The only minus point: With big print jobs (more than 50 pages) the outputs stack up poorly so that following pages get creased or others are pushed out of the stack.
HP DeskJet 840C The DeskJet 840C (incidentally of the same construction as the 843C) is one of the cheapest colour inkjet printers from Hewlett Packard. For about £70 you get a printer which produces good print-outs under Linux, too, at up to 600 dpi. As ever, the choice of driver is crucial. For text (meaning: solid colours only) the cdj670 driver from Ghostscript is suitable, for photos it’s better to use the cdj970. But when it comes to photo print-outs there is still some manual labour to be done: a bit
The printers in overview Printer Epson Stylus Color 580 Canon BJC-2100 Lexmark Optra M410 Lexmark Optra E312L Lexmark Z52 HP DeskJet 840C HP DeskJet 1220C
For the Lexmark Z52 the manufacturer has a Linux driver up his sleeve, hence the brilliant print image is convincing
more cyan and a little more contrast make the result come very close to the desired image. Printing out via Gimp-Print incidentally goes beyond good and evil. In addition the printer has an external power supply as well as its own feed for envelopes, where the change-over can only be done on the device itself for hardware reasons.
HP DeskJet 1220C We did actually ask HP for a DeskJet 1220C/PS. The correct packing came too, but unfortunately it contained only a model without the Postscript-Interpreter. And so the question arose as to which filter to use: the answer was to try them
Connection types USB USB/Parallel USB/Parallel USB/Parallel USB/Parallel USB/Parallel USB/Parallel
print time/page 15Min 30Sec 6Sec 9Sec 60 Sec 30 Sec 40 Sec
Canon bjc-2100: Not perfect, but can be used well enough with Linux
approx. price £60 £55 £450 £270 £110 £70 £275
Gimp-Print Gimp-Print is a relatively new software project. It is just 13 months old. But there is a very active team behind it. The popularity of the image processing program Gimp on all platforms is another reason for this: lots of people look at this software and write proper bug reports as and when required. Gimp does not even have to be installed for this because Gimp-Print also optionally works with Ghostscript and now with CUPS too. As one might guess from its genesis, this program is primarily used for printing out graphics and photos. In the test the print quality with Gimp-Print was normally even better than with the Ghostview drivers.
8 · 2001 LINUX MAGAZINE 45
042-USBprinter.qxd
28.03.2001
7:49 Uhr
ON TEST
Seite 46
USB PRINTER
all in sequence. In the case of black/white printing, one can’t really go wrong. Practically every DeskJet driver works here (for example the cdj880). Nor were there any problems with monochrome areas. Unfortunately, with photos it’s not so simple: after long experimentation we ended up with the cdj1600 driver (from Ghostscript). The images are rather dark when reproduced. This can be changed, though, either directly on the image or, better, with Ghostscript parameters. On the other hand Gimp-Print lacks colour. The image loses brilliance, which can be partly corrected by changing the print parameters (more cyan, less yellow). The A3 format on the other hand causes no problems whatsoever. As with all inkjet printers, the lack of a mains switch is something to criticise. The power switch is only ”soft”. One delightful aspect of the 1220C was something we only noticed right at the end: The printhead is fitted with a blue lamp, which shines through the transparent cover. Unfortunately this is not activated under Linux. Only the self-cleaning print head brings enlightenment.
Scanners
Nice scanners, but unfortunately not currently Linuxcompatible: Umax Astra 2100U, HP ScanJet 3300C and HP Photosmart S20
For Linux there is really only one solution for scanning: SANE (Scanner Access Now Easy). The latest version (1.0.4) is split into two packets: Sane front ends and Sane back ends, where the very name shows that here only the user interface (the front end) has been separated from the actual ”driver” (the back end). To test a configuration, first of all only the back end is necessary, which is addressed using the program Scanimage. SANE now supports over 100 scanners, including some USB models, too. The websites below mention that the Epson USB scanner is supposed to work best with Linux. Unfortunately it was impossible for Epson to send
Approximate scan rate of the 6300C Time/Sec Mode 15 B/W 40 S/W 160 S/W 40 Colour 270 Colour >30 Min Colour
46 LINUX MAGAZINE 8 · 2001
us a test model before the end of the test so we will have to leave this claim as it stands, without comment. The ones which turned up for the test were: Agfa Snapscan 1212U, HP ScanJet 3300C, HP ScannJet 6300C and Umax Astra 2100U Umax. We did actually ask the last-named manufacturer for a model 1200U, because this end-of-line model is the only Umax-USB scanner, which will do its duty with Linux – unfortunately Umax is no longer publishing any specifications on the current devices. Agfa is, incidentally, no better in this respect: The driver for the Snapscan is based on reverse engineering. Unfortunately there are two versions of this scanner, which are both sold under the type designation Snapscan 1212U. So the inevitable happened. We had our hands on the wrong device. So obviously it was not possible for us to wheedle anything out of the scanner. Anyone who already has this scanner model to call his own, can download the driver and try it out.
Hewlett Packard We did in fact have several models from HP. The Scanjet 3300C was, contrary to claims, not compatible with the Avision model, and the Photosmart S20 also made no effort to read in images. And so we come now to the only USB scanner which worked in our test: the Scanjet 6300C. The device, which is not exactly cheap (approx. £235) managed a resolution of up to 1200 dpi (hardware: 2400x1200), at 36 bit colour depth. The five buttons on the front of the housing could unfortunately not be used via USB. The option ”Front Button Wait” may be present, but it does not start the scanner process as expected. The initialisation of the scanner is done with a simple insmod scanner This module should by the way work with all scanners. Communication between scanner and computer via USB is standardised. But unfortunately not the format in which the data are transferred. Configuration of SANE is very simple: after installation (which is easiest using the distributionspecific utility program) all you have to do is add to the file hp.conf at /usr/local/etc/sane.d/ the following entry: /dev/usbscanner option connect-device
Resolution/dpi 300 600 1200 300 600 12000
Transfer volume/MB 1M 4.2M 17M 25M 102M 409M
042-USBprinter.qxd
28.03.2001
7:49 Uhr
Seite 47
USB PRINTER
To speed up the search procedure of SANE at the start, it is advisable to deselect all other drivers (back ends). This is done by simply writing a ”#” before all the lines with the exception of ”hp”. Then simply do a test: :# scanimage -h Usage: scanimage [OPTION]... [...] List of available devices: hp:/dev/usbscanner
ON TEST
the industry’s lack of interest with respect to Linux in this domain. On the other hand, the USB printers passed their tests with flying colours! All devices could be persuaded to produce pages, sometimes with very high quality and speed. In the next and last article of our USB test series we will be taking a close look at communications devices, such as ISDN modems and Ethernet adapters. ■
[left] Scanning under Linux made easy, thanks to xscan [middle] Gimp Print is at present the only a true alternative to Ghostscript with certain printers [right] Exemplary: Lexmark offers, in addition to good driver software, a setup program for the Z52.
So the scanner has been recognised. Now you can start a scan with scanimage > /home/test/out.pnm The standard parameters are used for this (300 dpi, b/w). If you want a higher resolution, then simply apply the option – resolution 600. Obviously the process is easier to do using a graphic scan program, such as xsane, which can also if necessary be used as a Gimp plug-in. Scanned in images are then immediately available in the application and do not have to follow the explicit diversion via the hard disk. Unfortunately there are two versions of the Agfa Snapscan 1212U and chance promptly sent us the one which is not supported
Printing wow, scanning yuck! Either we had extremely bad luck when we prepared the test devices, or else the extremely low success rate does actually reflect the level of support of USB scanners. At the very least this clearly shows
URLS
The only functioning scanner in the test: the HP ScanJet 6300C
■
xw_tools Homepage http://xwtools.automatix.de/startE.htm Driver for the Lexmark Z52 ftp://ftp.lexmarkeurope.com/drivers/Printer/International_English/lexmarkz52-english_UK.tar.gz Ghostscript Homepage http://www.ghostscript.com/ Gimp-Print http://gimp-print.sourceforge.net/ Which filter for which printer? http://www.linux-printing.org/ Scanner Access Now Easy (SANE) http://panda.mostang.com/sane/ Supported scanners http://panda.mostang.com/sane/sane-backends.html Supported USB scanners http://www.buzzard.org.uk/jonathan/scanners-usb.html Agfa Snapscan USB driver http://hem.fyristorg.com/henrikj/snapscan/ xsane - a front end for Sane http://www.wolfsburg.de/~rauch/sane/sanexsane.html
8 · 2001 LINUX MAGAZINE 47
048-gimp.qxd
27.03.2001
14:31 Uhr
Seite 48
FEATURE
GIMP 1.2
What’s new in Gimp 1.2
GIMP SIMON BUDIG
In the new version, the image processing unit of Gimp 1.2 is noticeably faster, and there are also lots more functions and tools. Gimp developer and propagandist Simon Budig explains the features of the new version. On the first day of Christmas 2000 we were presented with version 1.2.0 of the GNU Image Manipulation Program, better known as Gimp. This means that more than two and a half years had gone by since version 1.0. I will be describing the main changes in this article. Nevertheless, Gimp is still recognisable. Not much has happened with the last developers’ releases. Since the distributors have long since decided that even developer versions of Gimp have to be presentable, many of the features listed here will seem familiar to you. But there may also be one or two here which you have not yet stumbled across. Incidentally: The first bugfix release Gimp 1.2.1 has also just come out, which is important, especially for Gimp users on non-Linux systems such as Solaris. They will be disappointed with Gimp 1.2.0, since due to a bug it comes up to the limit for open files. This and a few other bugs have been removed. So now lines over the upper and lower edge of an image are also painted without rounding errors.
News from the toolbox The toolbox (see Figure 1) is now bigger by four buttons. The ink tool is a new painting tool that emulates some aspects of quill pens. Various forms and sizes of pen can be set. The tool reacts to several parameters: So for example, the line becomes thinner when you move it faster. With 48 LINUX MAGAZINE 8 · 2001
graphics tablets (see also the section headed ”Graphics tablets for creatives”) it also reacts to stylus pressure and stylus angle. The next tool serves in the so-called dodging and re-exposure of certain image areas. The principle for this comes from the photo lab, where during exposure of the photo paper the image areas concerned are briefly covered. This dodging causes shorter exposure and thus a brighter image, while reexposure on the other hand makes the image darker. The smudge tool has an appropriate name: It wipes away parts of images. It is very useful for imitating watercolours or achieving watercolour type effects. In conjunction with selecting and masking, it is easy to create irregular image borders with this. As the last of the new tools, there is also the measurement tool. It has no direct effect on the image content, but it is useful for determining distances within an image and placing artificial lines. If for example, someone is looking at an image taken by a scanning electron microscope and wants to measure certain image elements, he can adjust the image to the right resolution – measured in dots per inch (dpi) – and it is then easy to use this tool to measure the distance between two points or an angle. With the Ctrl and Alt keys, artificial lines can then be placed at the specified points. But the old tools have also been improved: With the colour scale tool, it is now possible to create spiral scales. When you think about the hypnotic
048-gimp.qxd
27.03.2001
14:31 Uhr
Seite 49
GIMP 1.2
eyes in many comics, it gives you some idea of what can be done with this. The old paintbrush tool has undergone enormous change: It can now, like a real paintbrush, gradually lose colour and draw lines which are more and more transparent. It is also possible, instead of using the foreground colour, to paint with the colours from a colour scale. When you do this, the colours are selected from left to right from the current colour scale. The transformation tool now also, depending on the setting, has a corrective action. So for example, to turn a crooked scan straight, all you need now is to adapt a grid to the straight lines in the scanned image. Distortions of perspective can also be corrected in this way (see Figure 2).
Daubing Stylus, paintbrush tool and airbrush can now also cope with special coloured paintbrushes. Since the paintbrush brings its own colour information with it in this case, the foreground colour is ignored. Gimp presents the image of a green pepper, but you can also produce useful coloured paintbrushes yourself, by saving an image with alpha channel in the GBR format (Gimp Brush) and filing it in the directory ~/.gimp-1.2/brushes/. For traditional paintbrushes, which paint with the current foreground colour, it is enough to save a grey shade image in this way. With brushstyles, motion comes into play. You could imagine these as quantities of paintbrushes, from which a paintbrush is sought according to specified criteria. This now sounds exactly as if a mathematician had formulated it, so here’s an example: let’s take the brushstyle Vine, which comes with Gimp 1.2. When you click on the image area with the paintbrush tool, you see that, unlike the green pepper, six different images are painted one after another onto the image, and this occurs in a specified sequence (see Figure 3). Longer lines appear somewhat livelier, because different paintbrushes are being used all the time. This is strongly reminiscent of the animated
FEATURE
paintbrush from Deluxe Paint III for the Amiga - only Gimp is, of course, much more flexible. A brushstyle can in fact not only be simply played out in a fixed sequence, but can also depend on other conditions. The brushstyle Pencil Sketch simulates hatching. Here, the regularity of the Vine brushstyle would certainly have a negative effect, because the human eye is highly conditioned for pattern recognition and would inevitably see certain patterns in the hatching produced. Therefore these brushstyles are random, which means the paintbrush is selected at random, so the hatching does not look quite so artificial. Brushstyles can also depend on the direction in which one is currently painting. So for example one can lay down simple footprints. It is also possible to make use of the printing and inclination information of a graphics tablet in this way. And last of all, everything can be combined with everything else, as described at length in the box ”Creating brushstyles”. If one level is split into several cells, the cells will run through in the same sequence as when reading a text. With three levels (A, B, C), which are split respectively into two columns (l, r) and two lines (o, u), the process described would be based on the sequence Alo-Aro-Alu-Aru-Blo-Bro-Blu-Bro-CloCro-Clu-Cru. If you have read this far with interest, that’s a good sign. Now simply try out the tools. If you manage to make a good paintbrush, we would be happy to include it in the Gimp distribution.
New functions Seen it before: Gimp can now also save, together with the image, data on the resolution of the image and cope with various units of measurement. The most important interface for settings is the Scaling dialog. The box Print size and display unit has no direct effect on the image data, but merely defines its resolution. If one then deselects, in the View menu, the mode Point for point, the image is controlled with
Figure 1: Gimp 1.2 in its full glory. Top left, the toolbox, under it the options of the ink tool. Figure 2: The transformation tool can correct distortions of perspective.
8 · 2001 LINUX MAGAZINE 49
048-gimp.qxd
27.03.2001
14:31 Uhr
Seite 50
FEATURE
GIMP 1.2
Figure 3: A few Gimp brushstyles in Action. Figure 4: How to make brushstyles - but you should still read the box.
the correct measurements and also printed out. If the resolution of the monitor has been correctly calibrated, the image also appears on the monitor at the right size. Other things which make dealing with images easier, are firstly, thumbnails, which Gimp automatically saves if required. Gimp uses the same format here as the classic image viewer xv. If you look for an image later and are not quite sure of the file name, you can get your bearings in the Open dialog from the little thumbnail images. It often used to happen to beginners that they created a complex image with various levels and then saved it as a JPEG file. In most cases, only the
level was saved which was currently active (JPEG can only handle one level), and the rest of the image data was lost. Gimp is now aware of this and suggests exporting the image, such as, condensing a copy of the image down to the capabilities of the format and then saving it. In this way, the original image data is retained and can easily be saved in Gimp’s own XCF format. When doing this it is worth saving the image as .xcf.gz, as this way the uncompressed image data of the XCF format is again put through a compression routine. Also new, compared with Gimp 1.0, is the flexibility with Bezier paths. The dialog Levels &
Creating brushstyles A brushstyle is really just a sequence of paintbrushes. They are created by saving an image with several levels in GIH format. Since the GIH plug-in has a hideous graphical user interface, I will have to clarify a couple of terms at this point. A cell is an image in a brushstyle, thus an individual paintbrush. Let’s assume an image consists of twelve levels. To begin with our cells are as large as the image, so there are twelve cells (each level contains one cell). By varying the cell size, one can make one level hold several cells. So to find the number of cells, one has to multiply the number of levels by the number of cells which fit completely into one level. Then these cells are spread over up to four dimensions. In the simplest case, over one dimension, which then contains all cells, so has the rank of 12. If two or more dimensions are assigned, the product of the respective ranks must not be greater than the number of cells. With twelve cells one can create either a one-dimensional style with the rank of twelve, one two-dimensional style with the ranks two and six or the ranks four and three together with a three-dimensional style with the ranks two, two and three. If one constructs style, one must bear in mind that the dimensions in the dialog further to the far left build stacks of cells in larger steps. Each dimension is now assigned another function: • incremental: work through in sequence • angular: depending on the angle in which painting is currently being done • random: chosen at random • velocity: should depend on the speed, but does not work • n pressure: for graphics tablets, depends on the pressure on the tablet • n x/ytilt: in high-end graphics tablets, depends on the angle of the stylus. For example: We have an image with six levels (A, B, C, D, E, F) and want to make a brushstyle that depends on the pressure of the stylus and also works through in sequence. We will now assign the first dimension pressure (with two stages: light and heavy, rank two) and the second dimension incremental with three stages (rank 3). After saving the brushstyle (and the pressing Update in the paintbrush dialog) it is now ready for us to use. If we now paint a line using light pressure, we shall see the following paintbrushes appear in sequence: ABCABCABCA... With firm pressure, on the other hand, these are the paintbrushes DEFDEFDEFD... If we had arranged the dimensions the other way round (thus, first incremental and then pressure the image would look as follows: ACEACEACEA... with light pressure and BDFBDFBDFB... with firm pressure (see Figure 4).
50 LINUX MAGAZINE 8 · 2001
048-gimp.qxd
27.03.2001
14:31 Uhr
Seite 51
GIMP 1.2
channels has been given an extra field: Paths. Here, painted paths can, using the path tool, be managed, copied, changed into selections and so on. Previously this only worked with a single path. Gimp 1.2 greets the new user on first start up now with an exhaustive dialog, which refers to especially important settings (see Figure 5). Here for example one can measure exactly the resolution of the monitor and regulate the memory usage of Gimp. The FAQ ”I have 512MB RAM, but Gimp uses only 10MB, what should I do?” will now, hopefully, be read less often.
Internal Gimp 1.2 is also noticeably faster than Gimp 1.0. Here, the COW patches (Copy On Write) are of crucial importance, as now for example when copying levels, image data is only copied if it is actually to be changed. A subjective acceleration comes from the idle renderer: The display of the image on the monitor is updated whenever Gimp has nothing else to do. Levels are now no longer just symbolised by a triangle when being moved, but Gimp makes use of every quantum of computing time left over to update the display live. The so-called parasites are more important internally. These are simply small amounts of data, which are attached either to the whole image or to an individual level. So a plug-in can recall specific parameters. The plug-in IFS-Compose (Iterated Functions Systems) for example, which creates natural looking fractal images, stores the parameters for the respective fractal in this way. Next time the plug-in is invoked at this level it takes its parameters from these parasites. The artist now no longer has to struggle to recreate these settings exactly. The plug-in Dynamic Text uses this mechanism to realise editable text. If the text elements of an image are created with this plug-in and filed in their own levels, each of them remains editable, as the plug-in files the text, together with information about the selected font and the size, in a parasite. This means that at a later date typing errors can be corrected or additions made without any great trouble.
FEATURE
window - space on the screen is often a particularly rare resource. It is also possible to set whether the cursor should display which tool is currently active, and whether when doing so a triangular arrow or cross-wires should be displayed. Even the format of the window name can be configured. Of course, as was the case in the first version, all key shortcuts can be redefined. Unfortunately this is a largely unknown feature: simply move the mouse cursor over a menu item and press the new key combination. If you need space on the screen fast, you can hide and retrieve various dialog boxes with the Tab key, and with Alt+Tab you can toggle back and forth between the levels of an image. Some new buttons have been added around the image window: There is a navigation button at bottom right, with which one can rapidly reach a different section of the image. At bottom left are the Quickmask buttons, with the aid of which the current selection can be rapidly converted into a channel in order to work on it with the usual painting tools. With another click on these buttons the respective channel is then turned back into a selection. One nice feature is the Journal dialog. It displays the last work steps and makes it possible to perform several undo-steps at a stroke and so to compare two different versions of the image directly with each other. Drag & drop works in many places. For example one can drag colours into an image and so fill it with this colour. Levels can be sorted in the dialog Levels & channels by drag & drop. If they are dragged into an image window, a copy of the level is added to this image. Files can be dragged out of a file manager onto the toolbox, Gimp then opening the file. And URLs of images can thus be directly loaded into Gimp. The menus (for many newbies, just a desert of text) have been restructured. Unfortunately it is not possible to organise them in such a way that everyone is happy. But the menu structure is better than before, at least in the opinion of the developers. Figure 5: Gimp installs your personal data directory.
Home-made User Interfaces While things like parasites scarcely change the appearance of Gimp, the changes in the user interface are considerably more far-reaching and also depend very much on one’s personal taste. Not least for this reason, there is a saying among Gimp developers: ”Make it configurable”, when they can’t agree on which is the best way to structure the GUI or integrate a new function. So it is possible to adjust whether the new ruler and status bar should be visible around the image 8 · 2001 LINUX MAGAZINE 51
048-gimp.qxd
27.03.2001
14:32 Uhr
Seite 52
FEATURE
GIMP 1.2
Figure 6: An example of the capabilities of Gimpressionist.
define within which parameters this image element rotates and scales and according to which strategy it is placed. A surface structure can then be laid over this image, such as marble or linen. With a bit of experimenting this can lead to grandiose effects. While the plug-in for lens reflections defines the position and intensity of bright points according to a physical points of view, the Gflare plug-in takes a construction kit approach. You can compose the light reflection out of three parts here (main reflection, rays and secondary reflection). Each component can also be configured (see Figures 7 and 8). Both plug-ins offer so many parameters, that it is impossible to remember all the combinations which have been tried. So once found, good combinations should be saved. Vidar Madsen, the author of Gimpressionist, requests that especially successful settings are sent to him, so that they can be integrated into the next Gimp version. By the way, in order to activate a composition in Gimpressionist, you must first click on the name and then on Apply. With that, the settings are included in the individual dialogs. One important area is of course the output of images on paper. Here a group has formed around Robert Krawitz and, with the plug-in Gimp Print, presented a very good piece of work. The team is now also working very closely with the Ghostscript team. The output quality on several printers (especially various Epson, Canon and HP printers) can certainly compare with the results from the corresponding Windows drivers.
Expansions by Script-Fu, Perl or with plug-ins Figure 7: Here the light reflection is adapted to the image.
It is, however, still very deeply nested. For this reason, menus can be placed permanently on the screen to save time. One click on the dotted line on the top edge pulls down the desired menu. If one then selects a menu item from it, this always relates to the image (window) in which one last pressed a key or a mouse button.
New effects with new plug-ins Since the source code for the plug-ins is open, it was already really easy to develop new ones off one’s own bat. Since Gimp 1.0 a few gems have been produced in this way, These have now been included in the Gimp package. In all, there are over 150 plug-ins. I can only go into three new plug-ins here. First, Gimpressionist, which can cover images with a structure (see Figure 6). What may sound very simple is in reality a very complex plug-in, with which impressive effects are possible. The basic concept is to compose a new image out of one image element repeated many times (a chalk line or spheres or little hearts...). One can 52 LINUX MAGAZINE 8 · 2001
Sometimes there are tasks that are hard to handle even with the plug-ins which are part of the package. Then one learns to appreciate it when the functionality of a program can be expanded accordingly. Gimp is especially flexible on this: If one wants to automate work processes, then Script-Fu is the obvious choice - a scheme dialect. It probably takes some getting used to, but there is currently a series running in Linux Magazine on the subject of schemes. Anyone familiar with Perl can also use this language to paste some new menu items onto Gimp. Here Perl Data Language (PDL) is especially helpful when it comes to performing certain image operations particularly quickly. But when it really comes to performance or one’s own libraries have to be used, you can write your own plug-in (technically, by the way, Gimp Perl and Script-Fu are plug-ins). Gimp offers the Libgimp for this, which organises communication between Gimp and the plug-in. Since the documentation is also needed for this, Libgimp was written with the Gtk doc system. So you can look for the appropriate function in easy, linked HTML pages.
048-gimp.qxd
27.03.2001
14:32 Uhr
Seite 53
GIMP 1.2
FEATURE
Graphics tablets for creatives
Figure 9: The start screen of Gimp is no longer reserved solely for Unix users.
Something that existed for Gimp 1.0 only in the form of immature, unofficial patches, has an important position in Gimp 1.2: support for graphics tablets. With graphics tablets, one paints completely in the classic style with a stylus on a smooth surface, where the pressure and sometimes even the tilt of the stylus are measured and passed on to the computer. With the corresponding driver support Gimp can evaluate this data and convert it into natural-looking paintbrush strokes. This is extremely obvious in the quill tool: Here the stylus form adapts dynamically and calligraphic effects become very simple. But the old Gimp tools, too, can evaluate at least the pressure information. The classic variant is the regulation of the covering power of the paintbrush. But it is also possible, depending on the pressure, to select the colour from a scale or to vary the size of the paintbrush. You can now select precisely what you want in the tool options that appear following a double click on a tool icon. I would recommend to anyone who has any artistic ambition that they try out a graphics tablet. Working with these is completely different from working with a mouse: you just try signing your name with the mouse - if what comes out bears even a passing similarity to your signature, you must be good. After a short period of familiarisation, this is no problem with a graphics tablet.
Gimp for the MS world, too You will already have seen this from the screenshots: Gimp speaks German. Or to be more precise: Gimp speaks Danish, German, English (American and British), Finnish, French, Gaelic, Galician, Dutch, Italian, Japanese, Catalan, Croatian, Korean, Norwegian, Polish, Portuguese (Brazilian), Russian, Swedish, Slovakian, Spanish, Czech, Ukrainian, Hungarian – hopefully, I have interpreted all the country abbreviations correctly. Gimp uses Gettext, thus automatically adapting itself by default to the language of the rest of the system. Anyone wanting to set a different language has to set the environmental variable LANG to the corresponding value. de_DE for example, stands for the German variant, no for Norwegian. Gimp has been ported – and this is an important step for free software in my view - onto Windows (95/98/NT/2000). Tor Lillqvist has also put a lot of work into porting Gtk+, so that in Gimp only at a few places, closely related to the system, does this platform have to be taken into account. Since both versions arise from the same source code, Gimp for Windows, too, is always up to date. But since the typical Windows users cannot be expected to do a ./configure ; make ; make install
they will have to wait, in the circumstances, until a new packet (with installer) is built. Gimp under Windows has the same Look & Feel as under Unix, so it takes a bit of getting used to for Windows users, especially since Windows as window manager performs only light duties. Central things such as virtual screens or desktops have to be tacked on using external programs. But since there is only one person working on the Windows porting, a second interface, in line with Windows conventions, is not feasible. What matters for a program to gain acceptance is a good help function: F1 activates context-sensitive help in every nook and cranny. So you want to know what a certain menu item does? Move the mouse cursor over the menu entry and press F1. You don’t quite understand a certain parameter in a dialog? F1 helps again. Unfortunately the help has not been completely written, but a team has been formed and is working hard on writing the documentation. If the online help is not enough, there are now lots of books which describe fairly current versions of Gimp and so can also be used for Gimp 1.2. In the UK alone there are at least five different books, so there should be something to suit every taste. Lastly, I would just like to point out that you can find at least one Easter egg in Gimp. But where, obviously I’m not telling. ■
Figure 8: With this dialog, the appearance of the light reflection is adjusted.
The author Simon Budig has been involved in the free software scene since Linux 1.2.13 and Gimp 0.99.10. He got the stimulus to get involved in this in Unix-AG, a voluntary work group at the University in Siegen. He now has to watch out that his maths degree does not suffer as the result of the diverse Gimp lectures.
8 · 2001 LINUX MAGAZINE 53
054-xchat.qxd
28.03.2001
9:14 Uhr
Seite 54
FEATURE
IRC WITH X-CHAT
At home in the IRC
X-CHAT HANS-GEORG ESSER
Internet Relay Chat (IRC) is a worldwide chat system, consisting of a large number of linked chat servers, which any user with the appropriate client software can log onto. Participants can then meet in chat forums (rooms) and put the world to rights there. X-Chat is an easy-touse client, which we will be presenting at length in this article.
between the participants, in principle you need no graphics program for this task; with X-Chat, though, chatting is much easier – the mouse helps.
Installation
There are lots of ways to go astray in a chat forum (in IRC-talk: on a Channel), because IRC offers this kind of conversation channel on all conceivable topics. Do you have a question about Linux kernel compilation or would you like to talk about the latest concert by your favourite group? Simply look for the appropriate IRC channel, and there you will meet other people with the same interests. Since, when chatting, only text is transmitted
Channel: A channel in the IRC is a discussion forum, which you can join with the command /join #channel. Everything you write in the input line after joining the channel appears not only in front of you, but is also visible to all the other users who are on this channel. So it’s possible to have a conversation with a very large circle of people. ■ 54 LINUX MAGAZINE 8 · 2001
If X-Chat is not yet installed, there are as usual two ways of getting the program onto your computer: • As an RPM or Debian packet it is played in by the root system administrator with the usual commands (rpm -i xchat-1.6.2-1.i586.rpm or dpkg -i xchat_1.4.3-0.1.deb ). • If it is in the form of a source packet, the usual threestep installation ./configure; make; make install takes place (see Installation from sources boxout).
Speak my language X-Chat uses the Gtk library and (like all GNOME programs) can be used with various languages in menus and dialogs by setting the environmental variable $LANG. Please note that setting the variable via the start file only comes into effect when you have restarted the shell (or the terminal program), for example with . .bashrc or xterm &.
054-xchat.qxd
28.03.2001
9:14 Uhr
Seite 55
IRC WITH X-CHAT
FEATURE
First contact: Making the connection Before making contact with other chatters, there first has to be a connection between your chat program and one of the IRC servers on the Internet. For this purpose, at every program start a window opens immediately with a selection of these servers and the option of selecting your own so-called Nickname. X-Chat’s server list is divided up by networks here; a few of these networks are IRCnet, UnderNet and OtherNet. Click in the server list on the plus sign in front of one of the networks to display the associated server. By double- clicking on one of the servers, X-Chat now makes a connection to this IRC server – the window with the server list is closed, and all you see now is the actual chat window. IRCnet is the classic; in most cases you will therefore want to connect to one of the IRCnet servers. None of the servers specified in the list of XChat under IRCNet are unfortunately reachable any more, however you can always try any of the following: • lineone.uk.eu.dal.net • chat.btinternet.com • irc.u-net.com • eris.bt.net • chat.bt.net • irc.warwick.ac.uk • ircnet.demon.co.uk • irc.easynet.co.uk • irc.netcom.net.uk
If you want to add additional servers, click on the New Server button (this whole mask has obviously not been localised) and under Server and Port, enter the address of the IRC server. The port is usually 6667, which is why X-Chat also sets this as default; but the value can differ. Under Name state what the new server is to be called in the list.
Figure 1: Selecting the IRC server the pre-defined entries for the IRCnet do not work; instead, use lineone.uk.eu.dal.net, chat.btinternet.com, irc.u-net.com, eris.bt.net or chat.bt.net
Which channels? Using the command /LIST It is possible at any time to call up a list of all open (and visible) channels on the IRC server, although in
Installation from sources In order to compile and install X-Chat yourself from the source texts, proceed as follows: Change to the directory /usr/local/src/, where you can turn into the root system administrator (with the command su) and unpack the source text archive with the command tar xIf /cdrom/LinuxUser/xchat/xchat-1.6.2.tar.bz2 Then change to the new subdirectory xchat-1.6.2 and there execute the command ./configure configure is a script which searches your system for existing compilers, libraries and other things necessary to the creation of the executable X-Chat program. At the end of the script execution, a summary appears in the form xchat 1.6.2 Building interfaces: GTK+ TEXT gnome-libs .......... : yes 1.2.0 gnome panel ......... : no zvt shell tab ....... : yes gdk-pixbuf........... : yes perl ................ : yes
python .............. : yes 1.5 plugin interface .... : yes link with socks5 .... : no link with openssl ... : no nls/gettext ......... : yes translation tables... : yes glib replace ........ : no hebrew support ...... : no The binary will be installed in /usr/bin configure complete, now type ‘make’ and pray. As you can now see from the last line the next step is to enter make This step will take somewhat longer: The program source texts are now being compiled. If this has gone through without any error message, you should now enter make install to copy all the program files into the right directories. That completes the installation, and you can leave and delete the directory xchat-1.6.2: cd .. ; rm -rf xchat-1.6.2
8 · 2001 LINUX MAGAZINE 55
054-xchat.qxd
28.03.2001
9:14 Uhr
Seite 56
FEATURE
IRC WITH X-CHAT
Nick(name): This is issued only once per IRC server. When starting X-Chat the program offers you your login name from your own computer. If the name has already been taken by another user, the next option is to add an underscore, etc. You can of course modify and adapt the entries as you wish. In most cases these nicknames must not exceed nine characters in length.
larger networks this is so long that X-Chat takes several minutes to download and display it – and nor is the listing especially informative. What is more interesting, though, is the use of a search function, such as the one offered for the IRCnet by the site http://www.ludd.luth.se/irc/list.html. Figure 3 shows the results from a query using the search term #*linux*: the current Channel topic is displayed next to the channel name. In the IRCnet you will always find Linux users on the channel #linux Before you get stuck in, maybe you should start with a few tests: Think up the name of a channel
■
Figure 2: Entering new servers
Figure 3: Searching for Linux channels 56 LINUX MAGAZINE 8 · 2001
which definitely does not exist, such as a combination of your forename and surname... in the input line, enter /join #forename.surname channel names always begin with ”#” and may include a few special characters such as ”.”, ”-”, ”+”, ”/” etc. Spaces and quotation marks are not allowed. So now you are (alone) on your test channel. XChat displays all users who are on the channel in the right hand column – in this case, therefore, just your own nickname. To the left of your nickname you will see a green spot: This indicates that you are the operator, ”Op” for short, on the channel. Channelops have certain special rights, some of which you can try out now. As a rule, every user has the right to write in the channel. Try it: Type a line of text in (which must not begin with a slash ”/”), and press [Return], to send off the line. The text then appears in the black area, and your nickname is placed before your line in pointed brackets, like so: <linuxuser> A little test
054-xchat.qxd
28.03.2001
9:14 Uhr
Seite 57
IRC WITH X-CHAT
FEATURE
If there were more users on this channel, then the line would also be displayed to them in the IRC program, and they could reply to your contribution. If you want to express an action, such as the fact that you are about to leave the channel or think something over, then you can use the IRC command /me. Enter something like /me is writing an article, and it will appear as
• You can set a topic, such as specify a theme for the channel. The topic then appears in the top line (right under the menu line). The command is
* linuxuser is writing an article
/op nickname /deop nickname
The asterisk expresses an action; other IRC programs may show this slightly differently. BitchX for example also mentions (unless configured otherwise) the channel name.
Private query If you shy away from the openness of a channel, you can also meet another user of IRC in the socalled ‘query’: If you know the nickname of the desired conversational partner, simply enter /query nickname and a new tab will open. This is not a channel, but a one-to-one conversation: No-one can listen to you here, unless someone is eavesdropping on the connection to the IRC server...
Op is top! A lot of fuss is made in the IRC about op status: As Channel Operator you have certain special rights compared with non-privileged users on the channel; this is comparable to the root account on your Linux system. As op you have, among other things, the following options:
/topic title • You can make other users on the channel into op or take away their op status; the commands for this are
• Troublemakers can be kicked off the channel (literally: leave the room). Since something like this should not be done without good reason, you can announce any message you like when throwing out a user, which he then receives as a kick message. /kick nickname reason The kick reason can contain several words and does not have to be in special brackets or quotation marks. For example: /kick idiot28 Let’s have some peace. After a kick the user can come back onto the channel, which is why kicks are usually only in the nature of a warning; sometimes, too, one comes across ops who like to kick people out just for ‘fun’. • If you are really feeling hassled, you can also ban someone. To do this, use the command /ban nickname You will receive a confirmation in the form Linuxuser sets ban on *!*@192.168.1.* What has happened here? A so-called Hostmask is being used here, which is entered in the ban list of Figure 4: Chatting in the channel. Black background: the actual chat zone; right column: Display of nicknames on this channel; below: text input and tabs for selection of channel or query
8 · 2001 LINUX MAGAZINE 57
054-xchat.qxd
28.03.2001
9:14 Uhr
Seite 58
FEATURE
IRC WITH X-CHAT
the channel. To ban the user permanently, X-Chat proceeds in a very rigid fashion here: Assuming that the troublemaker has been recognised by the IRC system as idiot@192.168.1.26, all users with any username whatsoever (* after the !) and any nickname whatsoever (* before the !) are barred, who are on line via a computer whose IP address matches the first three parts – so in this case 192.168.1.1 to 192.168.1.254. This ensures that the user cannot simply change his nickname or change his user name in his IRC program. To lift a ban, in some versions of X-Chat there is the command /unban, but not in the latest one. As a matter of fact /ban is really just a macro: X-Chat evaluates this and (in the above example) sends the following command to the IRC-Server:
Hostmask: The hostmask serves to identify an IRC user. Obviously the nickname is little suited to this, as this can be changed with a simple /nick abcde... at any time into any currently unused nickname. Therefore the IP address (or if recognisable the non-numeric name) of the computer and the username used there are used as well. A Hostmask looks like an extended email address and has the structure nick!user@host Asterisks (*)can be used here, which have the same meaning as in file names: They stand for any character. So something like *!*esser@*.linuxmagazine.co.uk stands for users with any nickname, a log-in name ending in esser, and a computer name which belongs to the domain linuxmagazine.co.uk. In the case of numeric IP addresses the asterisk comes last, as with these the first parts of the address are identical if there are several computers on a network. Auto-Rejoin: Many IRC programs can be configured in such a way that after a kick one can return to the channel immediately. This is known as auto-rejoin and is selected in X-Chat via the menu item Usermodes/Auto Rejoin after kick. On many channels there are Bots, which react to this behaviour and reward every autorejoin with a ban for several minutes. Bot: A bot, short for robot, is a program which logs in like a normal user to the IRC, usually obtains channel op-privileges and then oversees compliance with certain rules on this channel (or in the simplest case just gives its owner op-status, when he comes onto the channel). The bot program Eggdrop is very popular. Be careful: Many networks do not allow the implementation of bots. So you should check first whether you are allowed to use a bot, if you are playing with this idea. The configuration of an Eggdrop does, however, require advanced knowledge and is also really only useful if you have a permanent Internet connection (dedicated line; not flat rate, where the connection is regularly broken). DCC: Direct Client to Client is a special protocol which was developed for IRC clients. This can be used to get round a few restrictions to which IRC is subject. DCC uses the TCP connection (Transmission Control Protocol) to transfer data between two clients. Data packets can be sent and received in this way at the maximum possible rate. There are two different ways to make intelligent use of DCC: /dcc chat nickname and /dcc send nickname file. One of the two parties involved has to submit an offer, such as /dcc chat nickname. The other party receives a message with information about the user, his IP number and a port number and can now make the connection using the command /dcc chat other_nickname. The advantage of this is that the connection is now no longer running via the IRC server, there are none of the minor hesitations caused by the server, and the transmission continues after leaving a server. You can leave the DCC with the command /dcc close chat other_nickname. The commands for transferring files are similar: /dcc send nickname file, make a connection with /dcc get other_nickname. ■ 58 LINUX MAGAZINE 8 · 2001
/mode #channel +b *!*@192.168.1.* To cut a long story short: /mode is a very general command, with which various modes (operating methods) of the channel can be set. This stipulates that a new ban (+b) should be entered into the ban list. This can be revoked with -b: /mode #channel -b *!*@192.168.1.* You can take a look at the current ban list with the (obvious) command /banlist. • As a rule a ban is always accompanied by a kick: The combination of the two commands in X-Chat is called a /kickban and is called up in exactly the same way as /kick: /kickban nickname reason In this case the ban is executed before the kick, since a fast IRC client, which is set to Auto-Rejoin, would otherwise immediately bring the user back onto the channel – even before the ban came into effect.
Login, logout? Log it all!?? One interesting feature of X-Chat is that you can make logfiles. This is deselected by default and can be selected using the menu item Settings/Settings/IRC/Logbooks: To do so, click on the dialog in the Logbooks boxout. Under Mask for logbooks enter how the filenames of the logfiles are to be constructed. The pre-set here is ”%s,%c.xchatlog” – when using the IRC server chat.bt.net (which logs on using the name ”bt.net”) you will then receive logfiles in the form bt.net,#channel.xchatlog for channel logs and bt.net,nickname.xchatlog for the logs of private dialogs (queries or DCC chats). All logfiles are stored in the directory ~/.xchat/xchatlogs/, which is not made until a first logfile is created. But when using logfiles be aware that your partner in conversation may not appreciate it if you record everything: Apart from potential legal considerations (data protection) it is also a question of courtesy, to ask for permission before logging.
The window on the world of IRC... Behind the Window menu there are some additional functions hidden, the value of which you may only appreciate when you have worked with XChat for some time. • The URL grabber window contains all URLs, email addresses or names of other IRC servers which have been given by other participants – addresses named by you do not end up in here. With this feature, you therefore have no need to scramble to save the sources of data mentioned by the other party in URL form via copy and paste, but after the conversation you simply switch over to
054-xchat.qxd
28.03.2001
9:14 Uhr
Seite 59
IRC WITH X-CHAT
the URL grabber window and there select Save to keep the URL list. • Using the Raw Log window (unformatted log) you can see what communication is actually taking place between X-Chat and the IRC-Server – practical, when something unexpected happens or you would simply like to take a peek behind the scenes. • The Notify and Ignore windows help you to configure lists with nicknames, about whose logging on and off you wish to be informed, or whose messages you no longer wish to read. There are a large number of options for adaptation of the last point. So it is possible to prohibit just private messages to you, or you can completely screen out a user and thereby also no longer see any messages which they write in the channel.
Documentation The documentation supplied with the X-Chat sources is still at the 1999 stage and identifies itself
FEATURE
as belong to X-Chat 1.2. The HTML files are located, after unpacking the program sources, in the subdirectory doc, when installing the RPM packet in /usr/doc/xchat-1.6.2 and with the Debian packet, in /usr/doc/xchat/html/. The next article will be about IRC clients for the command line, especially BitchX, a really easy-to-use representative of this category. ■
Configuration files X-Chat stores the user-specific configuration files in the subdirectory .xchat/ of your home directory, where you will find the following files: • buttons.conf contains the functions assigned to the buttons displayed in the right hand part of a channel window (under the information zone). • commands.conf contains user-defined IRC commands: for example, the command /chat is defined here as an abbreviation for /dcc chat. • ctcpreply.conf specifies the answers which X-Chat should give when it receives a CTCP signal from other IRC programs (CTCP = Client To Client Protocol). • ignore.conf contains your own personal Ignore lists: These are the entries for other IRC users whose personal messages or postings on the channel you no longer wish to see. The entries are made using /ignore mask. • keybindings.conf defines key combinations; it is easiest to change these settings in X-Chat itself. • notify.conf contains all the entries from users about whose joining or leaving of the IRC network you wish to be informed. If a user listed here logs on to the IRC, you receive a message in the form Notify: user is online (Server). New Notify-entries are made using the command /notify nickname, but cannot be removed in this way – to remove them select the menu item Windows/Notify window, there select the entry to be removed and click on Remove. • palette.conf saves the colour settings. • pevents.conf saves the formulations by which X-Chat informs you about events. • In popup.conf you can define which menu items the context menu contains, which you obtain by a right mouse click on an entry in the user list. • replace.conf contains the automatic replacements; pre-sets here are just teh/the, r/are and u/you – these have been specially set up for the English language. • serverlist.conf: In this file, X-Chat stores the server definitions – apart from server name and port the nickname to be used on this server, any password, the Flags to be set and all channels which are to be entered automatically are stored. • urlhandlers.conf: X-Chat recognises standard URLs of the form http://www...., ftp://ftp.... or name@computer – here, too, programs can be configured, which are to be started when such a URL is clicked on. • usermenu.conf defines the entries in the User Menu in the menu list. • xchat.conf is the main configuration file – here, among other things, your user data (real name, standard nickname) are stored.
Figure 5: The URL grabber remembers all the URLs mentioned by other parties in the conversation
Flag: Special properties or attributes which can be set for a channel or nickname. If the channel-op executes the command /mode #channel +i (invite only), only users can come onto the channel who have been invited to do so by the Op with /invite nickname. This +i flag can also be set for your own nickname: /mode nickname +i – in this case it stands for ‘invisible’. This means you are now only ‘visible’ for participants who know your nickname precisely. ■
Info X-Chat homepage: http://www.xchat.org Info about IRC (incl. FAQ): http://www.irchelp.org ■
8 · 2001 LINUX MAGAZINE 59
060-firewall.qxd
28.03.2001
8:41 Uhr
FEATURE
Seite 60
SECURITY WORKSHOP
Protecting Linux systems from attacks: Part 1
BATTEN DOWN THE HATCHES! MIRKO DÖLLE
When asked about potential attacks on the free operating system, many people simply reply ”Linux is secure”. But even with the standard installation of a distribution, you could be leaving loopholes the size of barn doors.
Daemons: Utility programs started either when the system is booted up or by a specific event and are not to be confused with the dark powers, or demons. They are usually recognisable by the ‘d’ on the end of their name, for example in httpd, the Apache Web server. Linux has dozens of daemons, which perform a wide variety of tasks. Thus cron makes it possible to execute constantly recurring actions according to a schedule, while the ftpd allows you to log onto a computer from outside and download any waiting files. System-related events are also taken care of by daemons, such as for example changing PC cards in notebooks by cardmgr. inetd: The Internet Super-Server Daemon is responsible for starting additional daemons when specific queries come from the Internet. Port number and desired protocol of the query are then compared with the entries in /etc/inetd.conf and the utility registered there is invoked. ■ 60 LINUX MAGAZINE 8 · 2001
Many users employ the standard installation of the respective distribution in the implicit belief that all the necessary programs are installed and set up here. But some packets are neither necessary in normal operation nor are they anything like completely safe, and you ought to be aware of their risks and side effects before letting them loose on the Internet. These are the so-called daemons, utilities that either run constantly in the background or are started completely automatically when certain computer resources are accessed. After a standard installation these frolic about by the dozen on your home PC. Figure 1 shows the process list of a computer with SuSE 7.0. In the last column you will find the file name of the respective daemon, in the first is the name of the user with whose rights this utility is running. In the case of httpd this will sometimes be root and sometimes wwwrun. A process running as root is potentially problematic, because it has all the rights of the administrator. In the process list shown (which you get with ps auxww) though, only programs currently running are listed. Daemons that are only started on demand from outside are not found here. These are started from inetd, the Internet Super-Server Daemon, using grep -v "^#" /etc/inetd.conf We risk a look into the configuration file of inetd, where comments and deactivated utilities – their lines always start with a hash – are not displayed. In Figure 2 you can see the enabled utilities of the SuSE standard installation. In the first column you can find the name of the utility, in the last the associated command to start the daemon. The fifth column is especially important and extremely critical: Here is the name of the user with whose rights the respective
060-firewall.qxd
28.03.2001
8:41 Uhr
Seite 61
SECURITY WORKSHOP
daemon is started. In principle all utilities, especially those with root privileges, are a potential security risk. There is no such thing as a totally secure computer, no matter how desirable this may be, and there is no prospect of there ever being one. Operating systems alone have now become much too complex (the current kernel 2.4.1 includes around 3.5 million lines, printed out on 55,000 pages of A4 or around 16 kilometres of continuous paper!), for an individual or a small group to be able to get in and sound it out for security risks. The fact is that now only especially suspect points are tested, which means in principle that after every change (patch) a complete retest ought to be necessary.
Evil Internet A certain amount of paranoia is fully justified at this point. Crackers used to keep mostly to serveroperators, to accommodate their attack tools, socalled root-kits, and to spy out data from there or simply mount a DoS attack to cripple other machines. Most administrators got wise after a few losses and have increased the security on their computers. With the expansion of the flat rate, the crackers have discovered a new playing field: Many computers are on line permanently, or with only short breaks, so are almost always accessible. The sole drawback in comparison with true Internet servers is the changing addresses (IP) and lower bandwidth – but both are more than made up for by the considerably larger number of private computers. Nor is it a problem to find a computer ready to go: flat rate offers mean the user is bound to one provider and so are relatively easy to identify. The greatest advantage from the point of view of the attacker is that many computers are not protected at all, or have totally inadequate protection, users don’t really know their way around the system and often use totally outdated software with long-since discovered security loopholes. Nor are the distributors completely blameless here, as obsolescent packets are found here, there and everywhere, for which attack scenarios (Exploits) have already been published and which anyone can find.
FEATURE
Crackers: Computer experts, who, unlike hackers, do not break into computers to highlight security loopholes, but to loot data, cripple computers or to install programs to collect passwords or sabotage other computers. root-kit: A collection of programs with which a cracker keeps control of other computers. Usually coupled with other sabotage programs. DoS and DDoS: Short for denial of service and distributed denial of service. Not to be confused with the operating system, DOS. In a DoS an attempt is made to prevent another system from performing its regular work – for example by bombarding an Internet search engine with thousands of meaningless queries. By now, the administrators responsible for the system under attack are reacting very quickly and simply ignoring all the data packets from a certain computer or group of computers. Attackers can get round this by using a Distributed DoS, in which not only individual computers attack, but hundreds of thousands, scattered all over the world. Often this uses the computers of Internet users who have no idea what is going on – so-called root-kits have been installed on their computers, and these attack one or more targets by remote control, without the owner knowing anything about it. Since the queries are now coming from all over the world, the administrators have to batten down all their hatches – and thus take their computer off the Net or shut it down. Exploit: Program which takes advantage of a security loophole in a utility or a computer and breaks in. They serve as a demonstration and proof that an attack in a certain way is possible and will succeed. Most exploits are generally available to the public. ■ own computer. The system thus turns into a ticking time bomb, which, together with other primed computers, can cripple entire networks at an unnoticed command. Most security loopholes in the daemons are due to programmer errors or ignored boundary conditions. Often the programmer expects the user to be too good-natured and fails to take account of the fact that instead of giving him one file
[top] Figure 1: Colourful activities: Most daemons can be recognised by the ‘d’ on the end, but also include portmap, cardmgr and cron [above] Figure 2: Utilities which (almost) no-one needs: In /etc/inetd.conf too, there are hidden daemons, which are started completely automatically
Unauthorised users Especially dangerous are utilities which either provide information about their own system or enable an access. And all other daemons, in particular those with administrator privileges, represent a high security risk. An attacker always uses the same approach: Find out which operating system is running, look for insecure or wrongly installed utilities and finally take advantage of weak points. The worst-case scenario for the user in this event is certainly not the loss of personal data – but that it is now almost impossible for normal users, even to trace good root-kits on their 8 · 2001 LINUX MAGAZINE 61
060-firewall.qxd
28.03.2001
8:41 Uhr
FEATURE
Seite 62
SECURITY WORKSHOP
name to enter, in reality he is being handed the content of an entire hard disk. In particular via buffer overflows, where entries are simply considerably larger than anticipated by the programmer, access to a shell has been achieved via diverse utilities – preferably with root privileges.
Full cover
buffer overflow: When a storage area is filled with more data than it can accommodate, there is an overflow: The data is simply written beyond the end of the area and can overwrite other program parts. In almost all cases this is the fault of the programmer, who has forgotten to include a corresponding overflow check in his program. By continuing to write beyond the boundaries of the area, in some circumstances computer commands can infiltrate, which in turn allow access to the system. In the past, buffer overflows were found in many common Linux utilities, especially in FTP and mail servers. Client: Client computers are usually workstations, which obtain data for example from a server. Client applications are programs called up and used directly by the user, in order to access data or communicate with a server. Typical client applications are browsers, FTP and mail programs. Server: or assistant. Server computers often serve the workstations as a central data store or provide it with Internet and other utilities. No users normally work on it. Server utilities provide the corresponding client applications with the necessary data – so an FTP daemon allows logging in and reading out of files using the FTPprogram, while a mail server passes on the user’s emails. Daemons are almost without exception server utilities. ■
So the motto has to be: Shut down anything which is not totally necessary, and protect everything else as well as possible. This will not bring you complete security, but it should make life as difficult as possible for attackers. The most important part of this is making as little information as possible about the system that is running available to the cracker. The front line here is held by the finger daemon, which carries information about the user registered in the system into the outside world. The corresponding line in the /etc/inetd.conf should therefore be decommented on all computers, by placing a hash (#) at the beginning. There are also various tools, which differ from distribution to distribution, for editing the /etc/inetd.conf, but in most cases these cause more confusion than benefit – at this point, we recommend making changes properly using text editors such as kedit or emacs. The same fate as finger should also await the utilities also entered in the /etc/inetd.conf, telnet, shell and login. These allow unprotected and unencrypted access from outside, where the password entered wanders, completely open and explicitly identified as such, throughout the entire Internet. In particular, access via telnet is still one of the biggest security loopholes overall. Even today, many Internet providers still offer Telnet accesses, even though they are well aware that thousands of programs filter the data traffic day after day and are just spying out such passwords (sniffing) in order to infiltrate the system at the next opportunity. Here you should insist on an encrypted access via SSH, and you can find out more on this in the SSH & Co. boxout. The POP3 utility also allows a log-in onto your system, even if it is a bit rough and ready, but in the past this was also a point of attack. You only need this if other computers are collecting mails from you, for example because you have constructed a home network. In all other cases, the line beginning with pop3 should be provided with a hash and thus be decommented. The talk daemon is entered under talk and ntalk. If this is running, a connection can be made from local and remote computers via talk to users on your machine. We really do feel this is not a good idea: If the output of messages has not been expressly deactivated with mesg no in xterm or on the console, the connection request of the remote station is displayed at the cursor position – completely regardless of whether you are currently editing a text or copying files in Midnight Commander. This regularly messes up the screen and also makes the computer bleep. In our view,
62 LINUX MAGAZINE 8 · 2001
this is an unnecessary bother, which can be countered by decommenting both lines in the /etc/inetd.conf. Apart from this the Talk program is anything but easy to use, which is why most users prefer IRC (Internet relay chat). Last but not least, by decommenting talk and ntalk we are closing another potential security loophole – because the daemon in.talkd is also started with root privileges.
SuSE Help One utility, which has been found, especially in SuSE distributions, for years, is hidden away behind httprman. This is a Web attachment for the rman command, which converts manual pages into other file formats. It is used for the internal SuSE help system, which displays man pages with it. Unfortunately this utility can be accessed from outside. Even if it is running as user nobody, even if an attacker breaks in, he still has limited access to the system and can look for further opportunities to pilfer some administrator privileges. If you use the SuSE help system, you should protect it with the firewall described in the next issue. Even though no specific attacks are known, nevertheless they are still possible. Only SuSE users are affected by this peculiarity. All that remains now are the two time entries, ftp and swat. Since very few users take the time and date for their own computers from one of the Internet servers, the two time entries are only needed in exceptional cases. Even though we are not aware of any successful attack so far, one should usually shut down utilities which are not in use.
The thing about FTP The File Transfer Protocol, FTP for short, is often used to transfer files between two computers. To call up files on a server, one uses a Client, an application program, with which one looks for files and can then download them. An FTP server is only needed by the other side which provides the data. The great advantage of FTP servers compared with other solutions is that anonymous users can be granted access. Unlike a normal user known to the server, in an anonymous access only the files made available in a special directory can be accessed. In the past few months, though, more and more errors have been found in various FTP daemons, via which in case of doubt, administrator privileges could have been obtained. This is why we recommend that whenever possible you shut down FTP access by decommenting in the /etc/inetd.conf. When regular users want to transfer files, they can do so with the command scp, as described in the SSH & Co. boxout.
Big-mouth Swat You should also deactivate the last remaining candidates, the configuration program swat from the Samba Project. Firstly, swat allows
060-firewall.qxd
28.03.2001
8:41 Uhr
Seite 63
SECURITY WORKSHOP
reconfiguration from outside, which means even sensitive data areas of your hard drive could be open to the whole world. Also, an attacker can gather important information about your system by eavesdropping on your connection to swat. The greatest problem, though, is that when you use the tool you log on as root and have to enter your root password – this is then transferred, completely unencrypted and clearly marked as a password. This is something akin to hanging up your house key with an address label at a railway station in the hope that nobody will make use of it. If you still want to use swat to configure your Samba system, you should at least install a firewall to the Internet, as described below, so that swat can no longer be reached from outside.
Dubious linuxconf The linuxconf found in Red Hat and Mandrake is also suspect on security grounds. As with swat the password is transferred unencrypted in linuxconf, which obviously opens the door to any attacker. Since linuxconf also manages almost the entire system, this one tool is all an attacker needs to cause a lot of damage to the computer. If you need linuxconf, you should at least protect it with a firewall, or again, deactivate it by placing a hash at the start of the line in the /etc/inetd.conf . In Figure 3 you can see the fruits of our work by the example of /etc/inetd.conf in our SuSE system with activated http-rman and swat (standing in for linuxconf).
Shutting down utilities This means that in an ideal case the /etc/inetd.conf would be empty, and we could even shut down inetd. Depending on the distribution being used, there are various configuration tools for this. In SuSE Linux, in the graphic YaST 2, set Network/Utilities switch inetd on/off to Off, do not start inetd. In Mandrake you do this via the tool DrakConf, found there under Startup-utilities (Figure 4). It’s easier to use the command line: in (almost) all distributions the start scripts of the individual utilities are stored under /etc/rc.d in the subdirectory init.d and references to the respective start scripts are stored in the subdirectories rc0.d to rc5.d. Ultimately the utility is started during boot up by means of these references. The utility runs constantly, which is why it should firstly be stopped in an orderly fashion. To do this, call up the script manually, here for example is how it is done with inetd: /etc/rc.d/init.d/inetd stop If you would now like to shut down a utility permanently, all you need is to change the name of the respective start script in /etc/rc.d/init.d: mv /etc/rc.d/init.d/inetd /etc/rc.d/init.d/iU netd.no
FEATURE
The ending ”.no” has been selected at random. This means that the references from the other subdirectories will be running in a vacuum, and the utility will no longer be started. To reactivate, simply rename the start script again with the original name. Bear in mind that you still need root privileges for all these actions.
Ghostbusting: portmap Even with inetd shut down, you still mustn’t be lulled into a false sense of security. There are still half a dozen other daemons running, some of them
SSH & Co. Telnet is still often used to log in on an outside computer. This passes on your own keyboard inputs to the remote station and displays the data from the remote station on your own screen. It is almost as if you had laid a long keyboard and monitor cable to the remote computer. But the connection is transferred in clear text, one-to-one so anyone sitting between your own computer and the remote station (the entire Internet) can follow your progress. The main problem is that even the password necessary to log in is transferred in clear text. Anyone who snaps it up can impersonate you and cause damage at the remote station. The secure shell, SSH for short, remedies this. It works with various encryption procedures that are used right from the start. So an eavesdropper picks up nothing right from the start. In principle, it is in fact possible to encrypt the connection afterwards, but even on large computers this still takes weeks or even months. Also, SSH takes a fingerprint from each computer when a connection is first made. If this does not match at any time, this could indicate an attack on the remote station, with someone else pretending to be the server. In such cases SSH gives a corresponding warning. In addition, with SSH connections it is also possible to call up graphics programs such as a browser on the remote machine – it is still shown on your own monitor, but SSH transfers only the mouse movements and keyboard inputs. The call up from SSH is done according to the pattern: ssh User@Computer
Secure Copy The FTP utility, with which files can be exchanged between two computers, is also very insecure. As with Telnet, the whole connection is unencrypted and can be understood by anyone. So long as it is an anonymous FTP, where one logs on as anonymous user and needs no password, this is not a big problem. But if a regular user wants to transfer his data from the server to his home, he must enter his username and the password – again leaving him wide open to eavesdroppers. Instead of FTP, you can use the command scp: scp User@Computer: file file With this you are copying the file from the remote computer onto your own, where it will be stored as ‘file’. The whole thing also works the other way round, as in this concrete example: scp Article.txt modelle@linuxmagazine.co.uk:/home/modelle/Article.txt This causes Article.txt to land on our editorial server. Incidentally scp works in exactly the same way as cp, you can even copy files locally. Generally you should insist on encrypted transfer paths for all connections for which you have to enter passwords so as to make life as hard as possible for attackers.
8 · 2001 LINUX MAGAZINE 63
060-firewall.qxd
28.03.2001
8:41 Uhr
FEATURE
Seite 64
SECURITY WORKSHOP
Cowboys and Indians
Figure 3: Almost all utilities were superfluous: we need http-rman for the SuSE help system, swat stands in for the system administration program linuxconf of other distributions.
with root privileges. So the next thing to do is to collar the ”ghosts” which run frequently. The portmap daemon is the first one we tackle. This is only required when you want to make parts of your own hard drive available to others over the network. In most cases, you do not. First stop portmap with /etc/rc.d/init.d/portmap stop, then rename, as shown by the example of inetd, the file /etc/rc.d/init.d/portmap: mv /etc/rc.d/init.d/portmap /etc/rc.d/init.dU /portmap.no
Name Server Cache Daemon nscd, the Name Server Cache Daemon, is a buffer memory for name queries, but also for user and password queries. It is interesting for workstation operation, where the directories of the user are stored in a central server and there is no user information on the local computers. As you can see from Figure 1, it has started precisely seven times on our system. nscd is not absolutely necessary to run a single computer and can be removed without any risk: /etc/rc.d/init.d/nscd stop mv /etc/rc.d/init.d/nscd /etc/rc.d/init.d/nsU cd.no One thing you will barely notice is atd, which unlike cron only controls one-off events. But this really useful daemon is rarely used in practice – anyone not using it can also shut it down: /etc/rc.d/init.d/at stop mv /etc/rc.d/init.d/at /etc/rc.d/init.d/at.no
Rascal Cron
Figure 4: Activation and deactivation is done differently from one distribution to another – here for example in linuxconf under Red Hat (above) and DrakConf under Mandrake.
Highly suspect, although only in the event of attacks from the local machine, is the cron daemon. This allows constantly recurring tasks to be automated such as for example doing a complete back-up every first Monday in the month or calling up new emails every 10 minutes. But not only root can allocate such tasks, so can any normal user. The snag is that cron sends the screen tasks, which a program would normally do, by mail to the respective order-giver. With this, by a few contortions, root privileges can be obtained, which is why if there are several users, this should, if possible, be shut down: /etc/rc.d/init.d/cron stop mv /etc/rc.d/init.d/cron /etc/rc.d/init.d/crU on.no
64 LINUX MAGAZINE 8 · 2001
In SuSE distributions in particular an Apache Web server is installed as standard and rudimentarily configured. SuSE uses it as part of the help system in order to make help pages or examples accessible via the browser. In the process list, which can be seen in Figure 1, it is hiding behind httpd. We feel it is relatively uncritical to allow the Apache server to run, especially since this is also very good for appraising one’s own HTML drafts. Nevertheless, an outsider rarely has to look for anything here – and since in any case you get a new address every time you connect to the Internet via modem or ISDN, nor is it that easy to find again. So the Apache can reliably be protected from outside attacks by a firewall – anything which cannot be accessed will be hard to hack. Internally, this has no effects, so the pages can still be viewed by a browser as before. Anyone who really has no use for the Apache might just as well deactivate it and so save a good chunk of memory: /etc/rc.d/init.d/apache stop mv /etc/rc.d/init.d/apache /etc/rc.d/init.d/U apache.no
Courier The last risky utility is sendmail. It is still used on many systems for sending emails, although it is often not needed. The problem with sendmail is that in the past some security loopholes came to light, with which in some circumstances one can obtain administrator privileges. Whether or not you need sendmail depends among other things on the mail programs you use. In most cases emails are collected, via a POP access, from the provider and stored on the local machine. First off, sendmail is not necessary to do this. But when sending, many email programs such as pine or mutt simply pass on the messages to sendmail, which takes care of passing them on. On the other hand anyone using Netscape Messenger can pass mails on directly to the server of the provider – sendmail is then no longer necessary and can be shut down: /etc/rc.d/init.d/sendmail stop mv /etc/rc.d/init.d/sendmail /etc/rc.d/init.U d/sendmail.no In all other cases you should at least prevent access from outside to sendmail by using a firewall.
Firewall In the next section on the subject of system security we will look at the installation of a simple firewall for domestic purposes. Together with shutting down your utilities, you will then achieve a usable, secured system. ■
065-qtprog.qxd
28.03.2001
8:48 Uhr
Seite 65
QT PROGRAMMING
PROGRAMMING
Integrating graphics into Qt programs
GRAPHICAL REVOLUTION MATTHIAS ETTRICH
Now that programming with Gtk/Gnome has been comprehensively examined, it is time to take a look at Qt as well. In this article we show how graphics can be built into a program quickly and easily with QCanvas.
Qt is an application development framework, written from the ground up as object-oriented in C++. Apart from Linux, it is also available on various other Unix platforms and also – in the professional version – under MS-Windows 95/98/NT/2000. As a true multiplatform framework, Qt guarantees single-source compatibility: A Linux application written with pure Qt compiles and runs without any code changes under MS-Windows, too. It looks exactly the same there and also behaves just like any other MS-Windows application – it may even be a bit faster and more stable. To make this possible, Qt encases not only graphical elements in objects, but also the other operating system functionalities such as files, printer or even network connections.
Basis and superstructure Qt is the basis of KDE, so if you have installed KDE 2, there must automatically be a current version of Qt on your computer. If not, download the Qt source code direct from the manufacturer Troll Tech. Before we pounce on the graphics, first comes the obligatory Hello World (see Listing 1). We use a QLabel to display the string Hello world in its own window. In lines 1 and 2, the necessary header files are integrated. QApplication is indispensable at this point, as this class is responsible for the event handling of the window system.
By command So that the application can be controlled by command line parameters, the application object a
is initialised in line 6 with the arguments argc and argv. Lastly, in line 8 we create the label and set the desired text string. The first parameter of each class constructor in this case is always a pointer to the parent object, usually a groupbox, a main window or a dialog. Since the label in this example is to be used as its own window, without a parent, we simply assign a null pointer here. In line 11 we set the label of the application as main widget. The result of this is that under X11 common command line parameters such as -geometry are applied to the label and when the window is closed the application is ended. Finally, the label in line 12 is made visible and control is handed over using a.exec() to the event loop of the application. If you would like to try out the example, save it as hello.cpp and compile it with: g++ -O2 -o hello hello.cpp \-I$QTDIR/includU e -L$QTDIR/lib -lqt
Listing 1: hello1.cpp 1:#include <qapplication.h> 2:#include <qlabel.h> 3: 4:intmain(intargc,char*argv[]) 5:{ 6:QApplicationa(argc,argv); 7: 8:QLabell(0); 9:l.setText("HelloWorld"); 10: 11:a.setMainWidget(&l); 12:l.show(); 13:returna.exec(); 14:} 8 · 2001 LINUX MAGAZINE 65
065-qtprog.qxd
28.03.2001
8:48 Uhr
PROGRAMMING
Seite 66
QT PROGRAMMING
OK, that was an easy text – now for the graphics. Copy your favourite image into the same directory as hello.cpp, in the example we are using qtlogo.png. Line 9 of the program flies out and in its place we create a pixmap with QPixmap pm( "qtlogo.png" ); and set this on the label with: l.setPixmap( pm ); So that this code will also compile, it will also need an #include </qpixmap.h> at the start of the program. As a little gimmick we have also set the property ScaledContents to TRUE. This means that the image will always be adapted to the size of the window. Listing 2 shows the completed program. Naturally, the pixmap object does not load the Listing 2: hello2.cpp 1:#include <qapplication.h> 2:#include <qlabel.h> 3:#include <qpixmap.h> 4: 5:intmain(intargc,char*argv[]) 6:{ 7:QApplicationa(argc,argv); 8: 9:QLabell(0); 10:QPixmappm("qtlogo.png"); 11:l.setPixmap(pm); 12:l.setScaledContents(TRUE); 13: 14:a.setMainWidget(&l); 15:l.show(); 16:returna.exec(); 17:} A typical application for QCanvas: An animated graph editor. The implementation is just some 100 lines in length.
66 LINUX MAGAZINE 8 · 2001
image itself, it merely encases this functionality. Image formats are implemented in Qt’s dynamic image-IO-system. This makes it possible to add drivers for additional image formats.
Driving force of development PNG, BMP, XBM, XPM and PNM are supported as standard, and drivers for JPEG, MNG and GIF can, if required, be compiled into the Qt library. At http://www.trolltech.com/qtprogs you will also find a link to the free library Free Image from Floris van der Berg. These expand the image-IOsystem by adding drivers for example for TARGA and TIFF. If, in the program, you replace every mention of Pixmap with Movie, you can also load and display animated GIFs and MNGs (if Qt was compiled with the appropriate options). Even more so than with images, one can also start with a canvas. A canvas is an optimised 2D graphics area, on which any so-called items can exist. These can be more or less anything, texts, polygons, circles or again, animated images – socalled Sprites. QCanvas is one such graphic area, and what’s more it is fairly powerful. Qt comes with a neat example called Canvas, which clarifies the options of the class. Examples of applications for QCanvas are of course games, but also vector-oriented drawing programs, diagram or graph editors, presentation programs and practically everything that requires dynamic 2D graphics.
065-qtprog.qxd
28.03.2001
8:48 Uhr
Seite 67
QT PROGRAMMING
A broad canvas In view of this flexibility of QCanvas it is interesting to know that the class was originally called QwSpriteField and was developed by Warwick Allison, who at that time was still outside TrollTech. Target applications were primarily 2D games, for example Qt Net Hack or the Kasteroids game from KDE. Warwick has now become head developer at TrollTech Australia and is in charge of Qt/Embedded development. QCanvas as generalised Spritefield has been an official component of Qt since Version 2.2.0. The C++ class in Listing 3 defines a Logo sprite. The sprite moves freely about the canvas and turns automatically when it reaches the edge or comes across another sprite. The implementation of Logo is not complicated (around 65 lines), but does not make much of a contribution to understanding at this point. For reasons of space we have therefore omitted it, but the complete listing is on this month’s coverdisc. Here is just a brief description of the individual methods: initPos() selects an initial position at random, initSpeed() a random speed. Both functions use the Linux random number generator rand(3) for this.
Spritely animation It starts to get really interesting in advance(). This method works out the animation of the sprite. It is triggered by the canvas itself, so you don’t need to call it up manually. Canvas supports animations as a standard feature. To make sprites fly around, all you need to do, using setVelocity(x,y), is to define a horizontal and a vertical speed. This is certainly enough for simple objects such as for example the bullets in an arcade game, but otherwise it is fairly boring. This is where advance() comes into play. The aim of this method is to adapt movements of an item to the current situation on the canvas. advance() takes a parameter stage for this, which is either 0 or 1. The canvas firstly calls up all animated items advance() with 0 (Phase 0) and then with 1 (Phase 1).
The clash In Phase 0 the items should, if at all possible, not move their position but start calculations for further motion, for example in collision with other
PROGRAMMING
items. QCanvasItem offers a function for this, collisions(), which sends back a list of all items which would collide with the item being called up if their speed remained constant. In Phase 1 the items then execute the previously calculated movement. This two-phase approach makes it possible to maintain a certain fairness. Otherwise sprites added first to Canvas might take precedence in collisions, which does not, however, necessarily correspond to the physical conditions of a game world. Listing 3: logos.cpp 01: #include <qapplication.h> 02: #include <qcanvas.h> 03: #include <stdlib.h> 04: 05: classLogo:publicQCanvasSprite{ 06: voidinitPos(); 07: voidinitSpeed(); 08: public: 09: Logo(QCanvasPixmapArray*pm,QCanvas*c); 10: voidadvance(intstage); 11: }; 12: 13: intmain(intargc,char*argv[]) 14: { 15: QApplicationa(argc,argv); 16: QCanvascanvas(800,600); 17: QCanvasPixmapArraypm("qtlogo.png"); 18: 19: for(inti=0;i<6;i++) 20: (newLogo(&pm,&canvas))->show(); 21: 22: canvas.setAdvancePeriod(30); 23: 24: QCanvasViewcview(&canvas); 25: a.setMainWidget(&cview); 26: cview.show(); 27: returna.exec(); 28: } In main() six logo sprites are created and made visible in a simple loop. The speed of animation is set using canvas.setAdvancePeriod(), in the example this is 30 milliseconds. A sprite does not only have to consist of an image, as in the example. You can specify a whole array of images (hence QCanvasPixmapArray) and switch between these during run time with setFrame(). This makes it easy to implement running men, rotating boulders, exploding rockets and similar things. You can find further information on QCanvas in the reference documentation supplied with Qt or online. One tutorial of special interest for games programmers has appeared at zez.org. ■
Info Qt source code: http://www.trolltech.com/products/download/freelicense/qtfree-dl.html Source code for the examples: logo.png: Animated, wandering and rebounding Qt logos Reference material on QCanvas: http://doc.trolltech.com/qcanvas.html Tutorial for games programmers: http://zez.org/article/articleview/2/ ■ 8 · 2001 LINUX MAGAZINE 67
068-opengl.qxd
28.03.2001
9:01 Uhr
PROGRAMMING
Seite 68
OPENGL
OpenGL Course, Part 1
HELLO 3D WORLD THOMAS G E RUGE
Here we present the first in a series covering an OpenGL programming course. Using simple, easy-to-understand examples, we will lead you into the exciting and complex world of 3D programming.
After a broad overview and a little bit of theory, the first part of the course shows how OpenGL programs are constructed, using Hello World as an example. OpenGL was originally developed by SGI and in ages long past was called IrisGL. The primary aim of developing IrisGL was to develop a programmable interface for the graphics workstations of SGI. This programmable interface was initially intended to be hardware-independent, future-proof and to meet the special demands of 3D graphics programming. It soon emerged that IrisGL is not only of interest for SGI workstations, but can also help other workstations to get up and running in terms of graphics. The OpenGL Architectural Review Board (ARB) was founded in 1992 by major manufacturers of graphics workstations such as SGI, Sun, Hewlett-Packard and others. The task of the ARB is to guide the further development of OpenGL and introduce new functionalities in later versions. OpenGL has now become the commonest hardware-independent interface for 3D programming. The latest version is OpenGL 1.2. There are OpenGL implementations for Irix, Solaris, HP-UX, Linux, Windows and a few other operating systems. In the Linux world the OpenGL clone Mesa is the most common one. The American Brian Paul 68 LINUX MAGAZINE 8 ¡ 2001
breathed life into Mesa, and the library has since been further developed by him and many other developers all over the world.
Principles OpenGL is always in a defined state, which is set by condition variables; this means that OpenGL is a State Machine. An example of a condition variable is the current colour with which the individual primitives are rendered (drawn). These are set using the command glColor3f(red, green, blue) and this then applies for all drawn objects until a second glColor3f(..) command changes the colour. All objects under OpenGL must be composed from 10 different primitives. The instruction set in the library comprises some 200 commands, all starting with gl. OpenGL does in fact contain all the simple operations for programming interactive 3D graphics, but it cannot do real 3D bodies such as cylinders and dice, only points, lines and polygons. All complex bodies have to be constructed by the 3D developer out of simple primitives. To make the work a bit simpler for the applications developer, hard-working 3D experts have developed some programming libraries, a few of which we shall be introducing in the course of this series of articles. The two most important expansions are
068-opengl.qxd
28.03.2001
9:01 Uhr
Seite 69
OPENGL
PROGRAMMING
3D transformations The elementary transformations in 3D graphics programming are translation, rotation and scaling of points in 3D space. So that these operations are shown in a standard format and can be programmed easily, transformations take the general form: b = M • a. So as to display not only rotations or scalings, but also translations in this linear form, a homogenous co-ordinate xw is inserted into the space of the transformations. In mathematical jargon, we have embedded the affine space R3 in the projective space P(R4) and can thereby display any affine figure (transformation) through a matrix multiplication. ax a a= y az aw
1 0 0 0 cos α sin α 0 0 R( e x , α ) = 0 − sin α cos α 0 0 0 1 0
cos α 0 − sin α 0 0 1 0 0 R( e y , α ) = sin α 0 cos α 0 0 0 1 0
cos α sin α 0 0 − sin α cos α 0 0 R( e z , α ) = 0 0 1 0 0 0 1 0
Rotations about any axis can be assembled from rotations about the co-ordinate axes:
bx b b= y bz bw t xx t yx M= t zx t wx
Rotations about the three axes of the co-ordinate grid by the angle a:
R(p , α ) = R( e x , α ) ⋅ R( e y , α ) ⋅ R( e z , α )
t xy t yy t zy t wy
t xw t yw t zw t ww
t xz t yz t zz t wz
The three transformations referred to above then look like this:
Translations
Rotation about any point The rotation matrices described above define rotations about the origin, but often an object needs to be rotated about a different point u. To do this, we link together translations and rotation in such a way that the point about which the rotation takes place serves as origin. This means that we make a change to the co-ordinate system:
We can displace objects in space at will with translations 1 0 b = T t a = 0 0
0 0 tx ax ax + tx 1 0 ty ay ay + ty ⋅ = 0 1 tz az az + tz 0 0 1 1 1
()
b = T(u) ⋅ R(p ,α ) ⋅ T(u) −1 ⋅ a
Scalings Scalings make objects bigger and smaller s x 0 b = Sa = 0 0
0 sy
0 a x s x ⋅ a x 0 a y s y ⋅ a y ⋅ = 0 a z s z ⋅ a z 1 1 1
0 0 sz
0 0
0
Rotations about the origin Rotations change the orientation of objects. If we want to rotate the point a about an axis p by the angle a, the associated transformation matrix R(p,a) in its commonest form looks like this: rxx r R(p ,α) = yx rzx 0
rxy
rxz
ryy rzy
ryz rzz
0
0
0 0 0 1
Figuratively speaking, we have first displaced the point a by the vector -u then rotated it by a and finally pushed the point back again. In graphics programming the programmer needs such assembled matrices over and over again, so that the 3D objects appear where they belong. OpenGL relieves the developer of a great deal of work in the creation and treatment of transformation matrices. After all the transformations we finally want to work against with three-dimensional co-ordinates: Where aw = 0, the point lies at infinity. ax / aw a3 = a y / a w a / a z w
8 · 2001 LINUX MAGAZINE 69
068-opengl.qxd
28.03.2001
9:01 Uhr
PROGRAMMING
Seite 70
OPENGL
How the output of the program HelloOpenGL ought to look
GLU (OpenGL Utility Library) and GLUT (OpenGL Utility Toolkit). GLU makes it easier to create projection calculations and to construct complex surfaces,
using, among others, Nurbs (Non-uniform-rational B-Splines). GLUT is an operating systemindependent tool for simpler handling of OpenGL windows and provides the application developer with routines to respond to user events from the mouse or keyboard. Anyone wanting to become a real 3D graphics expert will have to overcome a few mathematical obstacles. For a better understanding, some knowledge of linear algebra is useful and terms such as vectors or matrices should not be a complete and utter mystery to the reader. The most important terms that crop up time and time again in OpenGL are set out in the 3D transformations boxout. Anyone with a yen for higher mathematics can learn more with the Open GL Programming Guide Installing the OpenGL clone Mesa doesn’t take much. In most distributions Mesa is also installed by default. Those users who have previously had no OpenGL/Mesa environment on their computers, or want to use the latest version of Mesa can find the
Listing 1: HelloOpenGL.c #include /stdio.h> #include /stdlib.h> #include /GL/glut.h> void DrawScene(void) { //set background colour (dark red) glClearColor (0.5, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); // Set colour of pentagon, (blue) glColor3f(0.0, 0.1, 1.0); //Polygon progression of the pentagon glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f( 0.5, 0.5); glVertex2f( 0.8, 0.0); glVertex2f( 0.5, -0.5); glEnd(); //draw previous GL commands glFlush(); } int main(int argc, char *argv[]) { // initialises GLUT glutInit(argc, argv); // initialise output window (Single Buffer, RBG colour model) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); // set window position and size glutInitWindowPosition (100, 100); glutInitWindowSize (500, 500); // create window glutCreateWindow (argv[0]); // Set callback function to draw GL object glutDisplayFunc(DrawScene); // Main loop glutMainLoop(); return EXIT_SUCCESS; } 70 LINUX MAGAZINE 8 · 2001
068-opengl.qxd
28.03.2001
9:01 Uhr
Seite 71
latest binary and source packets at the Mesa homepage.
Hello OpenGL with the OpenGL Utility Toolkit The first program has not much to do with 3D as yet, as OpenGL can in fact also draw twodimensional objects – and that’s enough for a start. To simplify window management we are making use of the OpenGL expansion GLUT. OpenGL puts together all 2D and 3D objects from primitives and in the first program example we are simply going to draw an arrow in an OpenGL window. The program (Listing: Hello-OpenGL.c) consists of the functions DrawScene(..) and main(..).main (..) contains only calls from GLUT and helps us to draw the graphics, which are created in DrawScene(..), in a window. The first command glutInit(argc, argv) initialises the GLUT library and takes over X-parameters such as -display or -iconic. With glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB) we are agreeing that our OpenGL window uses only one graphics buffer and uses RGB as the colour model. Buffer is that area of memory in which drawing takes place. GLUT_SINGLE tells the function that we only want to use one buffer. The memory that is visible on the monitor and the area in which we are drawing are identical. This means that the onlooker sees how the individual OpenGL objects are drawn. glutInitWindowPosition(100,100) sets the OpenGL window to the position (x = 100, y = 100) of the X-server. glutInitWindowSize(500,500) sets the size of the OpenGL window. The window is created by the command glutCreateWindow(argv[0]), but is not yet visible. As the result of the argument argv[0] the window receives as name the program invocation. The instruction glutDisplayFunc (DrawScene) ensures that every time the OpenGL window is to be redrawn, the callback function DrawScene() is called up. Events which make such a redrawing necessary are for example the displacement, enlargement or reduction in size of the window and the explicit call up of the function glutPostRedisplay(). The main loop is invoked using glutMainLoop(). Within this loop the OpenGL program responds to all possible user events and intercepts mouse and keyboard events. Thanks to the seven GLUT commands, we no longer need to bother about making any changes whatsoever to our window or about actions by the user. GLUT takes over these tasks. The programmer only has to write the callback functions, so that their program responds as required to external events. We can thus now concentrate completely on the actual OpenGL programming which occurs in DrawScene(). The command glClearColor(0.5, 0.0, 0.0, 0.0) in
AD DrawScene() specifies that the graphics buffer is cleared with a dark red. glClear(GL_COLOR_BUFFER_BIT) performs the clearing of the graphics buffer. The next command glColor3f(0.0, 0.1, 1.0) makes sure that henceforth all subsequent objects are coloured blue. The definition of the arrow starts with glBegin(GL_POLYGON). GL_POLYGON firstly specifies that the following co-ordinates are to be interpreted as a closed polygon progression. The following glVertex2f(x, y) commands define the position of the corners of the polygon. glVertex2f defines the arrow in only two dimensions, and in order to describe the object with three-dimensional co-ordinates, glVertex2f(x, y) would just have to be replaced by glVertex3f (x, y ,z); glEnd() ends the definition of the arrow. With glFlush we ensure that all previous OpenGL commands are executed, in our example the buffer is first coloured in red, then the arrow is drawn. After the program stops, it is time for the compilation: gcc -I . -c HelloOpenGL.c gcc -o HelloOpenGL HelloOpenGL.o \ -lGL -lglut -lGLU When executing ./HelloOpenGL a window with a blue arrow on a red background should be visible (see Figure). The first example is, nothing particularly spectacular and nor is a 3D scene visible, but it already includes all the important components of an OpenGL program. GLUT has firstly defined which characteristics the OpenGL window possesses and how it responds to events. We have then defined the appearance of the scene within DrawScene().
A full 3D pot The sample program Teapot.c (Listing 2), with the aid of the GLU library, paints a three-dimensional teapot and responds to events from mouse and keyboard. The program consists, apart from the
068-opengl.qxd
28.03.2001
9:01 Uhr
Seite 72
PROGRAMMING
OPENGL
main function main(..) and the initialisation function myinit(), of the callback functions mouse(..), motion(..), keyb(..), recalcModelPos() and DrawScene(). In comparison with the first sample program main() uses three new callback functions and evaluates the depth information. Listing 2:Teapot.c #include <stdio.h> #include <stdlib.h>
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) initialises the OpenGLwindow with foreground and background buffer and a depth buffer. The foreground buffer is shown in the OpenGL window. Drawing is done in the invisible background buffer. When rendering is
{ glLoadIdentity(); glTranslatef(posx, posy, posz); glRotatef(xangle, 1.0, 0.0, 0.0); glRotatef(yangle, 0.0, 1.0, 0.0);
#include <GL/glut.h> // Condition variable // mouse movement int mousemotion; int mousex, mousey;
}
// Initialise model orientation GLfloat xangle = 4; /* for rotation */ GLfloat yangle = 120; //Model position GLfloat posx = 0, posy = 0, posz = 0; //Callback Function: Reaction of mouse clicks void mouse(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { mousemotion = 1; mousex = x; mousey = y; } if (button == GLUT_LEFT_BUTTON && state == GLUT_UP) { mousemotion = 0; } } //Callback Function: Reaction of mouse movement void motion(int x, int y) { if (mousemotion) { xangle = xangle - (y - mousey); yangle = yangle - (x - mousex); mousex = x; mousey = y; // Draw a new display glutPostRedisplay(); } } //Callback Function: Reaction of keypress void keyb( unsigned char keyPressed, int x, int y ) { switch( keyPressed ) {
void DrawScene(void) { // Delete buffers glClearColor (0.5, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Calculation of new model coordinates recalcModelPos(); // Teapot painting glutSolidTeapot(0.6); // Foreground and background buffer change glutSwapBuffers(); } //Initialising function void myinit() { GLfloat light_position[] = {0.0, 0.0, -1.0, 1.0 }; //First GL-Light fall glLightfv( GL_LIGHT0, GL_POSITION, light_position ); glEnable(GL_LIGHT0); //Z-buffer activation glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); } int main(int argc, char *argv[]) { //GLUT initialisation window glutInit(&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); // Initialisation myinit();
case ‘l’: // Light activation glEnable(GL_LIGHTING); glutPostRedisplay(); break;
//Callbacks set: Reaction of mouse clicks, movements and keyboard activity glutMouseFunc(mouse); glutMotionFunc(motion); glutKeyboardFunc(keyb);
case ‘o’: // Light deactivation glDisable(GL_LIGHTING); glutPostRedisplay(); break; } } //new Model position calculation void recalcModelPos(void)
72 LINUX MAGAZINE 8 · 2001
//Callback for drawing the GL-Function glutDisplayFunc(DrawScene); glutMainLoop(); return EXIT_SUCCESS; }
068-opengl.qxd
28.03.2001
9:01 Uhr
Seite 73
OPENGL
complete, we swap foreground and background buffers, so the image just drawn can be seen. The depth or z-buffer ensures that areas covered by other areas cannot be seen. In the zbuffer each pixel in the OpenGL window is assigned a z-value. If a new pixel is to be set during rendering, a check is made as to whether its z-value is greater than that of a pixel that has already been set. If so, the new pixel comes before the old one and can be drawn, otherwise not. If all parameters have been set and if the OpenGL window has been created, an initialisation function myinit() is called up. This function was introduced for better legibility of the program. The next step is to set the diverse callback functions. So glutMouseFunc(mouse) sets the function to be called up when pressing or releasing a mouse button. glutMotionFunc(motion) sets the callback function for mouse movements. So that the program also responds to keyboard events, we also call up glutKeyboardFunc(keyb). The rest of main() is equivalent to HelloOpenGL.
Callback functions in detail In void mouse(int button, int state, int x, int y) the position of the mouse in the OpenGL window is queried, buffered in x and y and registers whether the left mouse button was pressed. The function makes a note with mousemotion of the condition of the left mouse button and takes it into account later in the function motion(int x, int y). The function motion(..) calculates, from the current mouse position (x,y) and the mouse position at the time when the left mouse button has been pressed (mousex, mousey), the angle about which the object should be rotated (xangle, yangle). The call up of glutPostRedisplay() ensures that the scene is actually redrawn and by calling up DrawScene() the new position of the teapot is calculated in recalcModelPos(). The callback function keyb(unsigned char keyPressed, int x, int y) responds to the two letters l and o. When the user enters l the light calculation is activated with glEnable(GL_LIGHTING), o deactivates the light again with the aid of glDisable(GL_LIGHTING). These three callback functions cover all events that the program has to process. The next function recalcModelPos() is called up by DrawScene() to calculate the new position of the teapot. Generally every transformation (rotation, displacement, scaling) can be described using fourdimensional matrix-vector multiplications. This is explained in more detail in the 3D transformations boxout. OpenGL uses the matrix stack for such multiplications. In recalcModelPos() with glLoadIdentity() the identity matrix is loaded onto the stack. glTranslatef (posx, posy, posz) multiplies this matrix by a matrix which displaces an object by the co-ordinates posx, posy, posz. But since they all contain 0 this step
PROGRAMMING
could also be omitted. These displacements will also be discussed later on in this series of articles. With glRotatef(xangle, 1.0, 0.0, 0.0) and glRotatef(yangle, 0.0, 1.0, 0.0) we multiply the matrix again with rotations about the x and the yaxis. This matrix is then used later in DrawScene(). In this function, the buffer must first be cleared, as well as the z-buffer, so as not to receive any incorrect depth information. Next, with recalcModelPos() the matrix is calculated with the new model co-ordinates. This matrix is then to be multiplied by all points of the teapot. The teapot is created, as the result of the instruction glutSolidTeapot(0.6), with a size 0.6. There is nothing behind this command but the placing of polygons, similar to the way we called up the arrow in the first program with glVertex2f. GLUT has more fixed, pre-defined objects. If you’d like to experiment with other objects, try out glutWireTorus(..) or glutSolidDodecahedron(..). The teapot was drawn in the invisible background buffer and appears with the command glutSwapBuffers() in the foreground. In the initialisation function myinit() we create, using glLightfv(GL_ LIGHT0, GL_POSITION, light_position), a light at the position (0, 0, -1) and switch it on using glEnable(GL_ LIGHT0). The last two commands set the z-buffer mode. glDepthFunc(GL_LEQUAL) draws only pixels whose z-value is less than that of the pixel already drawn. glEnable(GL_DEPTH_TEST) activates the z-buffer calculation. Finally, the compilation:
The author Thomas G E Ruge has been a converted Linux fan since Kernel 0.98 and is interested in everything to do with 3D or virtual reality. He has been driving forward the technical construction of the Virtual Reality Laboratory in the research department of Siemens AG for nearly six years and is involved in the possibilities of high-end VR with Linux clusters.
gcc -I . -c Teapot.c gcc -o Teapot Teapot.o -lGL \ -lGL -lglut -lGLU If everything fits, when you call up teapot, as in the picture, a white teapot should appear, which responds to the input of the letters l and o and to mouse actions.
What’s next? That’s the end of our journey into the realms of OpenGL and GLUT. We have looked at the options for responses to the various inputs by the user and conjuring and moving polygons on the screen. The next installment will be about the primitives of OpenGL, how the world can become a bit more colourful and how edges can be smoothed with the aid of normal vectors. ■
Info Woo, Neider, Davis, Shreiner: Open GL Programming Guide 3rd ed., Verlag Addison Wesley Longman Inc.,1999 J. Encarnacao : Graphische DV 1, Oldenbourg Verlag GmbH OpenGL homepage: http://www.opengl.org Mesa homepage: http://www.mesa3d.org ■ 8 · 2001 LINUX MAGAZINE 73
074-schemeNEW.qxd
28.03.2001
10:59 Uhr
PROGRAMMING
Seite 74
SCHEME
Shell Scripting with Scheme
A CHANGE ON THE BRIDGE FRIEDRICH DOMINICUS
Thinking about scripting, the ”usual suspects” like Bash, Korn Shell, Python, etc. will probably come to mind. However, scripting is also possible with Scheme. The focus of this article is therefore on shell programming, as well as ”programming for the Internet”.
The Scheme shell (Scsh; http://wwwswiss.ai.mit.edu/ftpdir/scsh/) was designed specifically for Unix scripting; in its current form it is not nearly as suitable for interactive use as for instance the Bash or Z shell. There are other implementations in Lisp languages, die-hard Emacs fans could check out Eshell, a shell for Emacs in Emacs Lisp (http://www.emacs.org/~johnw/eshell.tar.gz). Debian installation users have access to a DEB package of the Scheme shell, users of RPM-based distributions have to go via the following sources ftp://ftp-swiss.ai.mit.edu/pub/su/scsh/scsh.tar.gz. Other Scheme dialects can also be used for scripting, however, the Scsh offers the integration into the Unix tools. So why should you resort to 74 LINUX MAGAZINE 8 · 2001
Scheme for shell programming? The author of the Scheme shell, Olin Shivers, has the following to say on the subject: ”Unix shells are real programming languages. They have variables [...]. But they are terrible programming languages. The data structures typically consist only of integers and vectors of strings. The facilities for procedural abstraction are minimal to non-existent. The lexical and syntactic structures are multi-phased, unprincipled and baroque.” This fairly harsh criticism is aimed mainly at the programming language aspect. Also ignored are the many functions which make working on the command line so agreeable. This is the area in which the Scsh has great weaknesses. The length of
074-schemeNEW.qxd
28.03.2001
10:59 Uhr
Seite 75
SCHEME
the Unix FAQ indicates that shell programming is not an easy subject.
Renaming a number of files The question regarding the renaming of a number of files can also be found under 2.6 of the Unix FAQ, so it isn’t a trivial question, otherwise it certainly wouldn’t have ended up there. Here is a possibility for a Bourne shell: function rename_1 (){ from=$1 to=$2 mv $from $(echo $to |\ tr `[A-Z]’ `[a-z]’).html } for f in *.HTM; do base=`basename $f .HTM` rename_1 $f $base done Let’s apply this to the following files: T1.HTM, T2.HTM, ”with blank.HTM” and T3.HTM. The resulting output is: mv: when moving several files the last argument must be a directory. Well, this error message is not exactly helpful. Let’s have a look at what might have gone wrong. Using ls, we can see that the renaming has worked for all files apart from the one with blanks. The problem is therefore one of blank spaces in filenames, and we can forget about the reference to a directory. So let’s try it a different way: function rename_2 (){ from=$1; to=$2 mv $from ”$(echo $to |\ tr `[A-Z]’ `[a-z]’).html” } The following files exist: t1.html, t2.html, with blank.html and t3.html. The second method seems to work. However, to use umlauts or other strange characters in file names you need to know a lot about quoting, process substitution and special characters. Now here’s the whole thing in the Scheme shell: #!/usr/local/bin/scsh \ -l ./stringhax.scm -s !# (define (rename-them) (let ((file-list (glob ”*.HTM”))) (for-each (lambda(x) (rename-file x (replace-extension (downcase-string x) ”.html”))) file-list))) (rename-them) Applied to the same files we get the expected result directly. Now let’s have a look at the structure of a Scsh script: as in every script, the first line specifies what sort of program is to process this script. The following lines are command line arguments for the
PROGRAMMING
Scsh, as listed in chapter 2 of the Scsh reference manual. In the example we are first loading a file (stringhax.scm) that contains some extensions for handling character strings; the only thing required here is the procedure downcase-string. -s limits the extended command line and must always be the last option before !#. We are going to define the procedure renamethem. glob pattern generates a list, whose elements correspond to pattern. Subsequently each individual file in the list is renamed in a loop. This requires several procedures: one to rename the files, one to replace the extension and the third to change the file names to lower case. The call to the newly defined procedure completes the script.
Scheme shell characteristics Perhaps this example has managed to convince you that shell programming can be simplified by using a Listing 1: Exception handling in the Scsh (define (error-handling-test) (let ((dir "dir")) (create-directory "dir") (with-errno-handler ((e1 d1) ((errno/exist) (format #t "errno-msg = ~A~% syscall = ~A~%data = ~A~%~% Directory exists~%" (nth d1 0) (nth d1 1) (nth d1 2))) (else (error "Do not know what to do now, giving up\n"))) (create-directory dir)) (with-errno-handler ((e2 d2) ((errno/isdir) (display "Oops, was a directory so running delete-directory instead\n") (delete-directory dir))) (delete-file dir)))) Listing 2: Awk, the Scheme way #!/usr/local/bin/scsh -s !# ;;; Add the numbers of kb of free and used disk space for all the volumes ;;; reported by df(1) (define (df-free+used) (let ((df-read (field-reader))) ;df 1 (exec-epf (| (df) ;df 2 (begin (read-line) ; skip first line of df ;df 3 (awk (df-read) (line fields) ;df 4 ((used-kb 0) (free-kb 0)) ;df 5 (#t ;df 6 (values (+ used-kb (string->number (nth fields 2))) (+ free-kb (string->number (nth fields 3))))) (after (values `(`used-mb ,(/ used-kb 1024.0)) ;df 7 `(`free-mb ,(/ free-kb 1024.0)))))))))) (receive (used-list free-list) (df-free+used) ; df 8 (format #t ” ~A MB are being used and ~A MB are still free.~%” (cadr used-list) (cadr free-list))) 8 · 2001 LINUX MAGAZINE 75
074-schemeNEW.qxd
28.03.2001
10:59 Uhr
PROGRAMMING
Seite 76
SCHEME
fully-fledged programming language. For a link to the underlying system the Scsh offers: • mechanisms for integrating data from Unix programs and the Shell • a POSIX-API converted to Scsh.
such as procedures for diverting input/output, job control and pipes. Here is an example of a pipe with the Scsh: (run (|(cat foo bar) (grep -n "\\<foo\\>")) (> foo_lines))
Process control Normally, every program started under Unix becomes a separate process. Shell programs often consist of a combination of several programs, linked, for instance, by pipes. The Scsh therefore requires channels for linking the programs. Here is a simple example: (define (example-1-copy from to) (run (cat ,@from) (> ,to))) The procedure is expecting a list of files to be concatenated with cat and written to to. run, together with other process control elements, is implicitly backquoted. For example, a file t1.txt can be accessed in the three following ways: * (run (cat "t1.txt")) * (run (cat t1.txt)) * (define file "t1.txt") (run (cat ,file)) Capitalisation is important in the Scsh (unlike ”standard Scheme”), as Unices differentiate between upper and lower case. This extension seems appropriate in order for the Scsh to adapt to that requirement. A mechanism such as run is not sufficient for integration, which is why there are additional procedures available for process control, Listing 3: Creating a colourful table (load (string-append laml-dir "laml.scm")) (laml-style "simple-html4.0-loose") (generic-page-1 "A page with a very colourful table" (con-par "This pages shows some elements from the HTML 4.0 convenience library" (em "Emphasis is not a problem" (b "bold") "also works.") "Here is another colourful table, keep your eyes open ;-)" (table-1 2 ; border (list 70 100 100 100) ; four columns (list (make-color 106 90 205) (make-color 0 255 255) (make-color 127 255 212) (make-color 238 121 159)) ; "wonderful" colours; (list (list "Here" "a" "table" "with") (list "the" "most" "tasteful" "colours" "a") (list "work" "of" "enduring" "value")) ; text in table "middle") (b "Here ends this `nice’ page, but not without") (con "referring to another `masterpiece’" (a-tag "simple.html" "simple"))) ; a link ;; colours for this page (make-color 255 255 191) (make-color 205 105 201) blue red ) (end-laml) 76 LINUX MAGAZINE 8 · 2001
Exchange of data between service programs and Scheme If you want to access all Unix programs you need the facility of making service program data available to the Scheme shell. This is achieved using the run/xxx procedures. If, for instance, you require a list of the files in the current directory, you enter (run/strings (ls)). The result is a list of character strings with the names of the files which can be processed by all Scheme programming elements. Other run/xxx commands are used to write to ports or temporary files, or to convert the output into a single character string. For instance, (run/string (cat foo bar)) gives you a character string consisting of all lines of the two files. An interesting example for Linux is the command run/port+proc, which return additional information on the split process, such as output status, current status, and others. (define (run/port+proc-test) (receive (port process) (run/port+proc (ls -l)) (let ((out (port->string port)) (exit-status (wait process))) (display "the pid of the process was ") (display (proc:pid process)) (display ", exit status = ") (display exit-status) (newline) out))) The Scsh uses the form receive to bind several return values. The binding parameters are contained in the first list (here port and process), afterwards the procedure which will return these values is called (run/port+proc). In our example the output from ls -l is written to the port, and, using port->string, this output is converted to a character string, which constitutes the return value of this procedure. The output status of the program started with run/port+proc is recorded using exit-status. proc:pid accesses the element pid in the proc structure, so the Scsh handles this differently from DrScheme.
Exceptions Basically the Scheme shell wraps all POSIX system calls in Scheme syntax. Should error occur, exceptions are raised which can be processed (see listing 1). Exceptions are processed as follows: The rump of the exception is executed first, such as, the procedure create-directory in the first error handling routine, and delete-file in the second.
074-schemeNEW.qxd
28.03.2001
10:59 Uhr
Seite 77
SCHEME
Should an exception occur, the first parameter of the error handling form (e1) is bound to the value of errno, the second parameter (e2) to a list. The latter consist of an error message which equates to the output perror errno, the failed system procedure (this parameter can be used to call the failed method again) as well as other information which differs according to the system procedure involved. Afterwards the individual error handling cases are examined in turn, with the return value of the executed branch becoming the value of the entire error handling. In our example we skip the creation of the directory and return an error message where a directory of the same name already exists. If it is not possible to delete the directory in the second part, an unsuitable procedure (delete-file) is called, which will inevitably generate an exception error. To remedy this the correct delete procedure (delete-directory) is then called.
System calls and additional procedures The Scsh offers a great deals of other procedures for a range of different areas, which can only be mentioned briefly here: • input/output (Scheme standard procedures and extensions) • file/directory processing and information • globbing • other process control elements • Signals and interruptions • time-handling procedures • environment variables • terminal control • regular expressions • network programming • bit manipulations Especially interesting is the conversion of so-called ”little” languages into Scheme syntax, for example the awk macro of the Scsh. In our example (see listing 2) the total used and free disk space on the hard disk is calculated. For individual partitions this could be done using df, however, there is no service program that will show you used and free disk space for an entire hard disk. The returning of Scheme expressions (; df 7) follows a recommendation from Olin Shivers. He remarked that this makes it easier to process data in other procedures, as you can utilise the read functionality. Let’s examine the program a little more closely: the output of df is subject to a consistent format (file system ”Total Size ” ”Bytes Used” ”Bytes Free” ..\n”). These are several fields which are separated by spaces. In the Scheme shell the reading in of lines has been separated from the processing of the current line. The reading in is performed by what are called ”field readers” (; df 1). The output from df is ”piped” to Scheme (; df 2). Since the first line of the df output contains text which is irrelevant for the capacity calculations, it is simply ignored (; df 3).
PROGRAMMING
The Scsh ”field reader” returns two values: the complete line as well as a list of individual elements. The lines are split into words using specific field separators. Where no particular characters are specified, white spaces are regarded as separators. We define two variables (; df 5), which will contain the total of used and free kilobyte. In order to understand the rest of awk you have to imagine the way in which the original awk works. An awk script is surrounded by a loop that reads in data line by line (or even several lines at a time, depending on the field separator). awk scripts are also based on an implicit case differentiation, in which the current line is compared with regular expressions. In the Scsh equivalent of awk additional elements can be used: Boolean values, regular expressions and Scheme expressions. In our case we are interested in all lines, as each line lists the used and free bytes of the corresponding file system. Therefore we are simply using #t (; df 6) for testing, as that applies to each individual line. The local variables are updated for each line that is read in. The third element of the list is added to used-kb (it is almost always equivalent to the used kilobytes in the file system that is currently being examined). The fourth list element and freekb are dealt with in a similar way. Finally the kilobytes are converted to megabytes (; df 7) and two return values in the form of (symbol ,(calculated Mbytes)) are returned. The call to the newly defined procedure (; df 8) forms the conclusion of this script. The output on my computer is: 3976.94 MB are being used and 2885.82 MB arU e still free, so there is still a bit of space for a few more articles ;-). Since the interaction of the procedures for reading in the data and processing by the awk macro is confusing at first glance I would recommend reading chapter 8 of the Scsh reference manual, where this interaction is documented in detail.
Network programming The Scsh offers a few procedures for this as well. These can be divided into ”basic procedures” and ”usability procedures” based on the basic ones. Using the latter, it is pretty easy to create a Scheme server (see box Scheme server and client) It really is a Scheme server in only 23 lines of program.
Scheme and the Internet Functional or declarative languages like Scheme are tailor-made for use in today’s Internet services. You have seen the basic elements in the previous example, however, based on this, Scheme enthusiasts have implemented a number of additional services. For example a HTTP server, 8 · 2001 LINUX MAGAZINE 77
074-schemeNEW.qxd
28.03.2001
10:59 Uhr
PROGRAMMING
Seite 78
SCHEME
procedures for mail handling, modules for HTMLformatted output and CGI-programming. There are further service programs in the DrScheme net collection for SMTP, NNTP, DNS, POP3 and IMAP. So even for those programs you do not have to resort to other scripting languages.
Scheme as a markup language The most prominent example of a markup language at the moment is HTML. The term ”language” is misleading, however, as HTML is not a programming language but a tool for describing
Scheme server and client
Client (define (send-to-server form) (let* ((sock (socket-connect protocol-family/internet socket-type/stream "localhost" test-port)) (op (socket:outport sock))) (format #t "I’ll send ~A~%" form) (cond ((number? form) (write (number->string form) op)) (else (write form op))) (force-output op) ;(sleep 1)a (let ((result (read (socket:inport sock)))) (format #t "I got ~A from the Server~%" result) (force-output (current-output-port))) (close-socket sock)))
Server (define test-port 1111) ;sk 1 (define (scheme-server) (let* ((log-file-name "./scheme-server.log") ;sk2 (log-file (open-output-file log-file-name (bitwise-ior open/append open/create)))) ;sk2 (bind-listen-accept-loop protocol-family/internet (lambda (sock addr) (let* ((op (socket:outport sock)) (input (read (socket:inport sock)))) (format log-file "Got: ~A~%" input) ;sk 2 (force-output log-file) (let ((output (eval input (interaction-environment)))) (format log-file "Wrote: ~A~%" output) ;sk 2 (force-output log-file) (cond ((number? output) (write (number->string output) op)) (else (write output op))) (force-output op)))) test-port))) The server in this example waits for requests at port 1111 (; sk1). No error handling is provided, however, the entire data exchange is logged (; sk2). The procedure bind-listenaccept-loop is a wrapper around basic procedures such as create-socket, connect-socket, bind-socket and others. Extensions like receive-message and send-message are available for the output to sockets; or you could simply use standard Scheme procedures, like read and write in our case. Some application examples: (send-to-server "foo") -> I got foo from the Server (sent-to-server `(+ 1 2)) -> I got 3 from the Server (send-to-server `(map (lambda (x) (+ 1 x)) `(1 2 3))) -> I got (2 3 4) from the Server
78 LINUX MAGAZINE 8 · 2001
074-schemeNEW.qxd
28.03.2001
10:59 Uhr
Seite 79
SCHEME
PROGRAMMING
[left] Figure 1: A table generated by LAML [right] Figure 2: Lecture template
pages. For more advanced elements (such as loops and case differentiation) you will have to fall back on a real programming language. How about adding markup elements to a programming language? That’s exactly what Kurt Normark thought, and so he developed LAML (Lisp Abstracted Markup Language). LAML is divided into separate layers. The lowest one contains only ”wrappers” around the different HTML tags. You can read about how the layers are structured in the comprehensive documentation of LAML. Here a first example of LAML: LAML files are translated to HTML using a suitable Scheme implementation, while MzScheme is currently the LAML development Scheme. How you translate the files depends on the environment in which you are working. There is a laml-mode for the (X)Emacs, with which you can start the translation of LAML files directly from the editor. Alternatively you can call the LAML script (this is a MzScheme script) or load the appropriate files into a Scheme and call the LAML procedure (laml ”file.laml”). Another example for the use of LAML can be found in listing 3. I’m sure you will agree with me that the colour selection in the table is easy on the eye. The LAML sources contain a number of examples and good documentation. Some of the examples are pretty clever templates, amongst other things a slide show, documentation tools for Scheme, a calendar and schedules. Finally, please have a look at the following page, which is derived from a lecture template.
Summary This part has introduced Scheme as a ”scripting” and markup language. The examples show how flexibly Scheme can be used. Learning Scheme provides you with a tool that allows you to replace a number of other ones. The seamless conversion of the various elements is certainly another advantage of Scheme. You are always
able to fall back on the full functionality of a programming language, there are practically no limitations such as you can encounter with other programs. In my opinion these are reasons for learning Scheme.
Outlook In the next part about Scheme the focus is once again on the Internet. We will also be using Scheme for CGI programming and in connection with Java. There are Schemes that have been developed specially for the interaction with Java and which allow you seamless access to Java classes. As always I would be happy about any comments and suggestions, my email address is: frido@q-softwaresolutions.com ■
Info ”A Scheme Shell”, Olin Shivers, SCSH Paper (part of the sources) ”Scsh Reference Manual”, Olin Shivers (also part of the sources) Unix FAQ: ftp://rtfm.mit.edu/pub/usenet-by-hierarchy/comp/unix/answers/unixfaq/ SCSH Home Page: http://www-swiss.ai.mit.edu/ftpdir/scsh/ LAML Home Page: http://www.cs.auc.dk/~normark/laml/ ■
First steps in LAML (load (string-append laml-dir "laml.scm")) (laml-style "simple") (generic-page-1 "Greetings from LAML" "Especially for you one of the most impressive masterpieces of LAMLic programming ;-)") (end-laml)
8 · 2001 LINUX MAGAZINE 79
080-gnomeprogNEW.qxd
28.03.2001
18:23 Uhr
PROGRAMMING
Seite 80
GNOME
Database register
CLASS REGISTRATION THORSTEN FISCHER
Which Windows user does not know the beloved registry, in which the system and diverse programs store configuration data – or again, maybe not, or only partly. In any case, this application is very easy to use with a mouse. It can be made even simpler. As always, everything – and this is a promise – will get better and nicer. This time, what’s involved is the possibility of storing, managing and querying configuration data for programs at a single, central location – at the start of a program for instance. Gnome developers have begun to bring a mechanism for this to the start line, which they have named GConf. GConf is to make a proper entrance in Version 2.0 of Gnome, but is already available in a packet in the unstable tree of the source code. A few new programs (Nautilus and Evolution among them) already demand GConf for their compilation. The library will not remain limited to Gnome however, but will ultimately also be able to be used for pure Gtk+ and X-applications, KDE programs and even from the command line. According to Havoc Pennington, Gnome is at the stage of Windows 3.x in terms of the configuration of applications, because each program stores its own settings in separate files.
Model – View – Controller (MVC) This three-stage concept consists of a model, one or more views keyed to this model, and finally one or more controllers. These components perform the following tasks: • In one model, the structure of the data is conceived. For GConf that means, firstly, designing the entire database, and secondly, giving some detailed thought as to the keys which are to be included. • A view is a specific way of looking at data. This view can correspond to the model, in that all data is simply made accessible, or (and this would usually be the case) a certain section is shown. Whenever the model changes, the views also have to be adapted. • Finally, data can be changed from outside using a controller.
80 LINUX MAGAZINE 8 · 2001
The registration database under Win9x may be a shrewd step, but it does have diverse restrictions: According to the article, GConf wants to use a two-rail system to provide both a library and an architecture, which is to be designed as follows.
The concept In theory GConf ought to offer a whole heap of advantages, once it is finished and refined. And so it does: We are talking about free software in the initial stages with considerable claims to what will eventually come about. This begins with the independence of the back end, in which the actual data is to be stored. The current implementation stores everything in XML files, which are best suited to hierarchical organisations, if only files are involved. But a binary format should also be possible as in the registry, and anyone who wants to get really stuck in can also control access via LDAP or even any SQL database of their choice. The idea behind this is that the administrator of a network can simply seek out whatever suits their needs in terms of infrastructure. Data is stored in key/value pairs, similarly to the method used in the registry. The individual keys should each be given their own field for documentation, which is then shown by means of an application with which the values can be changed. In addition to this, other information should be stored, such as when the key was last altered. It is not apparent, from the documentation so far available, whether there might be a mechanism provided which could prevent or privilege the editing of certain keys. There is also going to be a data notification service. In an age of components, when every
080-gnomeprogNEW.qxd
28.03.2001
18:23 Uhr
Seite 81
GNOME
program can communicate with every other program, it makes sense to propagate changes in the network so that all applications for which it is desirable are reconfigured accordingly. This concept is also of interest because this method can be used to reconfigure running programs. For example, with a setting which stipulates that all toolbars should no longer display icons, and ensures that this change immediately takes effect in all programs. I do not know, however, whether I am the only person for whom this sounds like an extremely interesting way to upset a whole network of computers. Each key has, as under Windows, an unequivocal name. To show the hierarchy, a system is used which is reminiscent of the file system under Unix: a key could for example be called /programs/editor/window/font. The values are tagged, so are defined in advance, such as for example string, integer or by another data type.
PROGRAMMING
More than just a daemon To be able to use GConf, a daemon named Gconfd must be running. There should always be exactly one daemon per user, which can communicate via CORBA with applications. A high level of abstraction, which comes into play, for example, with some widgets in the Gnome Application Library, bears the name MVC. Its concept is explained in more detail in the Model – View – Controller boxout. There are several different types of data with which one can fiddle around in Gconf: GConfEngine, is used to address a configuration database, in most cases this involves connection to a running Gconfd daemon. Then there are GConfValue, a structure which encases the tagged values from a key/value pair, and GConfClient, a client which can communicate with a GConfEngine, plus various tasty titbits such as caching and finally GConfError, a structure for handling errors.
Listing 1: The client 1: 2: #include <gconf/gconf-client.h> 3: #include <gtk/gtk.h> 4: 5: void callback (GtkWidget* entry, gpointer user_data) 6: { 7: GConfClient *gclient; 8: gchar *str; 9: 10: client = GCONF_CLIENT (user_data); 11: 12: str = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); 13: 14: gconf_client_set_string (client, "/extra/uk/thefrog/linuxmagazine/gconf", str, NULL); 15: 16: g_free(str); 17: } 18: 19: int main(int argc, char *argv []) 20: { 21: GtkWidget *window; 22: GtkWidget *entry; 23: GConfClient *gclient; 24: 25: gtk_init (&argc, &argv); 26: gconf_init (argc, argv, NULL); 27: 28: window = gtk_window_new (GTK_WINDOW_TOPLEVEL); 29: entry = gtk_entry_new (); 30: 31: gtk_container_add (GTK_CONTAINER (window), entry); 32: 33: gclient = gconf_client_new (); 34: 35: gconf_client_add_dir (gclient, "/extra/uk/thefrog/linuxmagazine/gconf", GCONF_CLIENT_PRU ELOAD_NONE, NULL); 36: 37: gtk_signal_connect (GTK_OBJECT (entry), "activate", GTK_SIGNAL_FUNC (calU lback), gclient); 38: 39: gtk_widget_show_all (window); 40: 41: gtk_main(); 42: 43: return 0; 44: } 8 · 2001 LINUX MAGAZINE 81
080-gnomeprogNEW.qxd
28.03.2001
18:23 Uhr
PROGRAMMING
Seite 82
GNOME
Example Now it’s time for a little example. The two listings, 1 and 2, contain a client and a controller demonstrating the function of GConf. GConf does have to be installed for this, either by doing it explicitly as described briefly in the following
The author Thorsten Fischer is supposed to be studying IT and/or Media Consultancy. He also works as a developer at MapMedia.
Installation boxout, or by having installed the Ximian desktop. GConf has to be initialised like Gtk+. This then creates a new client, which is transferred via the connection with a signal to the callback function. If one now types some text into the input box and finishes with the Return key, the content of the box is read out
Listing 2: The controller 1: #include <gconf/gconf-client.h> 2: #include <gtk/gtk.h> 3: 4: void callback (GConfClient* client, guint cnxn_id, const gchar* key, GConfValue* value, gboU olean is_default, gpointer user_data) 5: { 6: GtkWidget *label; 7: 8: label = GTK_WIDGET (user_data); 9: 10: if (value == NULL) 11: { 12: gtk_label_set(GTK_LABEL(label), " leer "); 13: } else { 14: if (value->type == GCONF_VALUE_STRING) 15: { 16: gtk_label_set (GTK_LABEL (label), gconf_value_string(value)); 17: } else { 18: gtk_label_set (GTK_LABEL (label), " wrong type! "); 19: } 20: } 21: } 22: 23: int main(int argc, char *argv []) 24: { 25: GtkWidget *window; 26: GtkWidget *label; 27: GConfClient *gclient; 28: gchar *str; 29: 30: gtk_init (&amp;argc, &amp;argv); 31: gconf_init (argc, argv, NULL); 32: 33: gclient = gconf_client_new(); 34: window = gtk_window_new (GTK_WINDOW_TOPLEVEL); 35: 36: str = gconf_client_get_string (gclient, "/extra/uk/thefrog/linuxmagazine/gconf", NULL); 37: 38: if (str) 39: { 40: label = gtk_label_new (" leer "); 41: } else { 42: label = gtk_label_new (str); 43: } 44: 45: if (str) 46: { 47: g_free (str); 48: } 49: 50: gtk_container_add (GTK_CONTAINER (window), label); 51: 52: gconf_client_add_dir (gclient, "/extra/uk/thefrog/linuxmagazine", GCONF_CLIENT_PRELOAU D_NONE, NULL); 53: gconf_client_notify_add (gclient, "/extra/uk/thefrog/linuxmagazine/gconf", callback, laU bel, NULL, NULL); 54: 55: gtk_widget_show_all (window); 56: 57: gtk_main(); 58: 59: return 0; 60: }
82 LINUX MAGAZINE 8 · 2001
080-gnomeprogNEW.qxd
28.03.2001
18:23 Uhr
Seite 83
GNOME
and written into the callback as a value in the key. As can be seen from the Include-lines, GConf is not actually Gnome-dependent. GConfClient still needs, at the moment, the link to Gtk+, but this defect will soon be consigned to oblivion. In the second listing only any already existing key will be read out and shown in a label. At this point it is important to throw away the pointer str with g_free() again, as one gets a copy back. Once the label has been inserted into the window, the program is instructed to react to changes in the respective directory. Then the callback function is invoked if the client in Listing 1 is used. The remaining lines in the callback essentially serve to test the read-out value for the correct type – a string. If the key contains no string as value, a corresponding pointer is inserted. If no value whatsoever has been set, a reference is also made to this. The key used can be found under the extra hierarchy, which has been installed for additions by third parties. I think a further subdivision through domain names, could also be very sensible.
GConf in Gnome 2.0 It has already been mentioned that GConf will only be fully integrated into Gnome in Version 2.0. This also involves the installation of a few little things. Firstly, a global client for a logged-on user is going to run, which
PROGRAMMING
can be addressed via simple functions of the GnomeAPI. Then there will be dialogs in the style of Gnome and diverse other functions, which are necessary in order to use Gconf with ease as a programmer. Happy Gnoming! ■
Info Feature article on GConf by Havoc Pennington: http://developer.gnome.org/feature/current/index.html GConf API Documentation:http://developer.gnome.org/doc/API/gconf/index.html Gnome FTP: ftp://ftp.gnome.org/pub/GNOME/unstable/sources/GConf/ Ximian website:http://www.ximian.com ■
GConf installation There are no great surprises in the installation: After obtaining the source code from the FTP site, all you need is the instruction: tar xzvf GConf-0.x.x.tar.gz cd GConf-0.x.x ./configure make make install Here, of course, the final step must be performed by a privileged user, normally root. Please take note of the instructions that appear at the end of the execution of the installation script.
AD
8 · 2001 LINUX MAGAZINE 83
084-KOfficeNEW.qxd
28.03.2001
17:37 Uhr
BEGINNERS
Seite 84
KOFFICE-WORKSHOP
Koffice Workshop, Part 1
PRACTICAL EXERCISES WITH K. IN THE OFFICE TIM SCHURMANN
The long-awaited Version 2.0 of the popular desktop environment KDE is now accompanied for the first time by a small, almost complete office packet. Like KDE itself, KOffice - as it is called - is subject to the GNU Public Licence (GPL). This means that there is, at last, a second free office suite under Linux apart from StarOffice. Unfortunately the documentation in the packet is full of gaps, which is reason enough for us to try and familiarise you with the use of the individual office components in a series of workshop articles. In this first part we will start with the word processor, Kword.
The whole Koffice packet is sold with the new desktop environment KDE2 as standard. If you are not yet using any of the more recent distributions,
Workshop Schedule 1. Word processing with Kword – Part 1: A business letter 2. Word processing with Kword – Part 2: A newspaper 3. Tables and Diagrams with Kspread and Kchart 4. Graphics and Images with Killustrator 5. Presentations with Kpresenter
84 LINUX MAGAZINE 8 · 2001
which already contain this as standard, you can download the appropriate version for your distribution free of charge from http://www.kde.org. Anyone who shies away from downloading should be able to find it on many cover CDs. KOffice has been completely integrated into the KDE2 desktop environment. Although under some circumstances it can be started under a different desktop, such as the old KDE or GNOME, inexperienced users or less-ambitious hobbyists should steer clear of this. In the worst case, some facilities could end up being unusable or unpleasant disruption could occur throughout all phases of operation. For these reasons, we generally advise you always to use KDE2 as the basis for the implementation of KOffice.
084-KOfficeNEW.qxd
28.03.2001
17:37 Uhr
Seite 85
KOFFICE-WORKSHOP
BEGINNERS
Eyes on the future The first two parts of the Workshop are concerned solely with the word processing package, Kword. Using two small examples that you can join in with, it will become clear how the program functions and how to use it. In this first part, we will do this by producing a business letter, which in addition to appropriate formatting will also include a small table. Please note that at present, the whole Koffice packet is still at the development stage. Crashes of the individual applications are not uncommon, so you should not entrust important data to any of the current Koffice components (see Problems and Future Prospects).
All in the box Unlike all other popular word processor programs, such as StarOffice or Applixware, Kword makes use of a concept which at first seems a bit strange. While the first two applications mentioned both have a page-oriented method of working, Kword acts as a so-called frame-based word processor. In an ordinary word processing program, you always enter your text straight onto the page. And all additional objects such as images, tables, etc, are usually also placed straight onto the page. Kword, on the other hand, always works on the basis of an empty page, on which you can arrange the frames. These frames, in turn, include the actual contents, such as graphics or – and this is what’s new – all text. For each of these objects there is always an individual, appropriate frame type. The developers of Kword want this concept to take a definite step towards a desktop publishing program. The ultimate purpose here is that the user can create more complex documents, such as a newspaper, actually in Kword, without having to bring in an additional, external application. The high price for this flexibility lies in what is, at first, less beginner friendly. But don’t worry: Our introduction below will shed some light into the jungle of terms and operations.
Start
With a publishing template, on the other hand, you can decide for yourself right from the start how many frames, in what size you wish to position in your document, and where. But more on that in the next Workshop instalment. For our letter, select the template A4 and confirm your choice by then clicking on OK. Kword should now start and display the standard A4 page. If you wish to make additional page settings, you can select from the main menu the item Format/Page. The settings window which now appears allows you, among other things, to turn the page landscape, or set up additional columns. For our business letter, you should leave all the default settings as they are for the time being. If the page view in the main window seems too small or too large for you, you can change the enlargement factor, with which the page is displayed on the monitor, to your own requirements. Using either View/Zoom or by selecting a corresponding entry from the list headed with 100 per cent from one of the symbol bars.
Figure 1: Kword once started
Figure 2: Symbol bars in Kword
To be able to join in this Workshop, you should now start Kword either via the Koffice workstation (see box ”KOShell or everything is exchangeable”) or via the KDE start menu under Office programs/Kword. A window should now open, in which you can select a template, open an existing file or begin with a blank document. As you can see from the two register pages, there are two categories of templates: Normal and Publishing. For all normal templates, a large text frame is automatically created for each new page in your document, which cannot subsequently be simply deleted. Kword then behaves almost like one of the ordinary word processor programs. 8 · 2001 LINUX MAGAZINE 85
084-KOfficeNEW.qxd
28.03.2001
17:37 Uhr
BEGINNERS
Seite 86
KOFFICE-WORKSHOP
The toolbar is on the left. Since this is used to create and edit the various frames, the symbols listed on it will play an important role in the next Workshop instalment.
The first time [left] Figure 3: Input of a sample letter [right] Figure 4: The altered subject line
Symbolic Under the menu bar you should find some symbol bars, which at first glance look somewhat chaotic. Each line displayed there consists of several of these symbol bars. The start of a new bar is recognisable by the two double bars placed between a few symbols. In the top line, immediately below the menu bar, you will find all the frequently needed, more common functions, such as the file functions (for example Open, Save), and also often-used clipboard functions (for example Copy or Insert). The symbol bars below contain functions which relate to formatting, firstly of text and secondly to tables. Incidentally, the latter can be applied to the individual lines in the text.
Kword works with two different input modes: in the text editing mode, switched on by default, you can change the content of the individual frames, which in this case means entering your text as usual, while on the other hand the frame editing mode is used to arrange all the frames included in the document such as inserted images. This second mode thus serves to change the page layout. Now you can enter a sample letter, as you may be accustomed to doing in other word processing programs, similar to the one shown in Figure 3. For the time being leave out all the special formatting, such as italics, and concentrate completely on the content. For the date in your document to appear exactly as in Figure 3, two little tricks are necessary. First off, there’s no need to write out the date yourself. For these types of values, which are often used in everyday documents, such as date, time or
KOShell or everything is exchangeable The facility of mutual integration of the individual Koffice modules is an essential functional characteristic of the free office packet. So it is possible, for example to build a table from Kspread directly into a text document from Kword. Depending on which element you are currently working on in your document, an application responsible for processing will be loaded and displayed. It was the professed aim of the developers here that the user would not even notice which application he was working in. The best example of this integration facility is offered by the so-called KOffice Workstation, which is often found under the name of KOShell. This application is also part of the Koffice packet and is intended to serve as a sort of switchboard or starting point, similar to the Desktop under StarOffice. After starting via the corresponding menu Office programs in the KDE2 startlist, a window opens which is at first empty, where on the left side a symbol bar with all available Koffice components is displayed. You can now create a new document by clicking on the associated application with the mouse or selecting File/New from the menu. In the same way, via File/Open you can open any existing document. In both cases the workstation automatically starts the appropriate application and integrates it into its own interface. One advantage of the workstation is that the symbol bar on the left edge continues to be visible, so that in any situation you can rapidly access individual office components.
86 LINUX MAGAZINE 8 · 2001
084-KOfficeNEW.qxd
28.03.2001
17:37 Uhr
Seite 87
KOFFICE-WORKSHOP
BEGINNERS
Figure 5: The completed sample letter with table inserted
the current page number, Kword provides so-called variables, found under Insert/Variable. A variable after an entry there means that once inserted this variable will always be automatically updated by Kword. For example, a date inserted in this way would always display the actual date of your computer after the document was opened. So that you can still tell, even after later editing, which symbols in your document are part of a variable, the text thus added is backed in grey in your document. So that the date appears indented, as in Figure 3, you can use the tabulators provided by Kword. To jump forward by one tab stop at a time, press the
tab key the corresponding number of times. You can see where these individual marks are located from the ruler: wherever a black tick is placed, is where such a tab stop lies. To change the position of the existing tab stops, click on the corresponding ticks with the left mouse button, hold it down and simply drag the tab stop to the desired position. To help you to do this, a broken line is inserted.
Defining tab stops If you enter the date for our sample letter at the corresponding tab stop, you will notice that the text
Problems and Future Prospects Below is a brief list of the problems which struck us as unpleasant on our test computer when working withKword (Version pre-BETA 1 (KDE2.0)): • Kword frequently crashes abruptly during work, so you should save your documents often. • The Help file for Kword is only in English and also has too many gaps. • Representation errors can crop up in the text, if the right or left edge of the page does not fit completely into the window. If this happens, increase the resolution or enlarge the window. • If parts of text are marked using the mouse, the marking might be shown as graphically incorrect. • The import filters offer only a rudimentary import of Word97 documents. • Working with graphics can provoke very rapid crashes. It can also happen that graphics frames disappear forever after processing. • In future versions all stability problems should obviously be corrected and a few more features, especially with respect to the area of import filters, are to be added. To find out more about the future of Kword, take a look at the Koffice homepage at http://koffice.kde.org.
8 · 2001 LINUX MAGAZINE 87
084-KOfficeNEW.qxd
28.03.2001
17:37 Uhr
BEGINNERS
Seite 88
KOFFICE-WORKSHOP
The author Tim Schurmann is an IT student at the University of Dortmund.
is always lined up to the right of this stop. If you want to alter this action, you must create a new stop with the correct, special characteristics. For this, at the top left, where the two ruler lines meet, there is a small triangle with a symbol. This symbol indicates which tabs are subsequently created in each case. By simply clicking on them with the mouse you can change the current type in Kword. In order then to finally create the tab stops, simply click with your mouse at the desired place on the ruler. If you go wrong and want to get rid of these tabs, simply click again on them, hold down the mouse button and drag them downwards. Once the mouse pointer has left the ruler and you release the mouse button again, Kword should immediately make the edited tabs disappear. As you will certainly have noticed by now, in the horizontal ruler, where the left side of the page begins, there are two more, smaller triangles. With the upper one you can define the precise point at which the first line of a paragraph should appear. On the other hand, the lower triangle shows how far the other lines of the paragraph should be moved out or be indented. Incidentally, these two triangles are moved about in exactly the same way as the tabs. When working with the ruler, you should take note that the changes always relate only to the line or paragraph in which the cursor is positioned at the time. The exception to this is the last entered line of your document: all settings applied to this always apply for all subsequent ones. The method just presented for creating and/or moving tabs and the paragraph format by mouse is very easy, but in many cases it is a bit too imprecise. Via Format/Paragraph, you can reach a window in which you can define and adjust all the elements addressed above by entering values directly.
This is where it gets interesting
Info KOffice-Homepage: http://koffice.kde.org Homepage of the KDE Project: http://www.kde.org ■
Now the subject line will be designed a bit more ambitiously. To do this, mark it either with the mouse, or alternatively move the cursor to the corresponding line, hold down the [Shift] key and mark the respective text using the arrow keys. Using the symbol bar for text formatting at the top edge of the screen, assign the text just marked, a different font size (second button from left), a different font (using the third button from the left) and a different colour (via the A symbol with the bin). Similarly, you can also select from the menu the item Format/Font or Format/Colour and make all the settings mentioned in the windows which pop-up in each case. By the way, the fonts available to you now should be precisely those that KDE already has.
Finally In our sample letter, there is still no table. To create one of these rectangular collections of cells, there are just two options available under Kword: either 88 LINUX MAGAZINE 8 · 2001
insert a Kspread table or rely on a considerably less effective table from Kword. Please bear in mind that a Kword table is designed only for formatting - it is not possible to perform calculations in it. For our example, though, this simple table from Kword is perfectly adequate. To create it, click in the tool bar on the symbol ”create table” (fourth from bottom). With the symbol underneath, you can insert a Kspread table in the same way. Alternatively, instead of the symbol bar, you will find the corresponding commands in the main menu under Tools. In any case, a window should now open, in which you should limit the size of the table for our example to three rows and three columns. After clicking on OK the mouse pointer turns into a set of cross hairs. Move this pointer to the position in your document at which the table in to be inserted. Now hold down the left mouse button, drag up a frame and then release the mouse button. The size of the frame does not matter by the way in this case, as in the previous window, the value Automatic was already set by default in both lists on the left side of the window. If the inserted table gets in the way of text, Kword will automatically move this. If the table does not meet your expectations, you can delete it using the menu item Table/Delete table. Under this menu item you will, incidentally, also find some more commands with which you can quickly add or remove lines or columns to or from an existing table. Now enter, roughly as shown in Figure 5, a few fantasy values in the individual table fields. You reach the next table field either by clicking on the mouse or pressing the [Down arrow] key. To finish off, give the whole table a more interesting look, using the functions from the last of the symbol bars on the top edge. Important: first select a line type in the big list (click on the long button, far right) and only then assign the line, via the four left, smaller buttons, to the actual cell. This brings us to the end of the first section of our five-part Koffice Workshop. But we are not quite ready to take our leave of word processing: Next time we will look at the somewhat more complex functions, where dealing with frames will play an especially important role. Using a newspaper as an example, we will then be coming back to Kword. ■
These tabs are available The symbol which resembles an L, after jumping to this text mark, always formats the text entered there left-justified, while on the other hand the reversed L always makes it right-justified. The upside-down T is especially useful for figures as all text at this tab mark is centred. If a dot is added to the T, the decimal point of the figure entered there is always lined up on this tab.
090-drlinux.qxd
27.03.2001
16:23 Uhr
BEGINNERS
Seite 90
DR. LINUX
Dr. Linux
KERNEL STORIES MARIANNE WACHHOLZ
Surgery is open again! The good doctor observes the patients in Linux newsgroups, issues prescriptions and cures Linux kernel ailments.
Make it!
Dr. Linux: Unlike many commands, which are simply entered on a command line for execution, regardless of the current working directory, to execute this command you have to be in the directory with the kernel source (usually /usr/src/linux). If you still get the error message after a
I was just trying to compile a kernel, but after the entry root# make menuconfig I kept getting the message make: *** No rule to make target `menuconfiU g'. Stop. The command make xconfig also gives me the corresponding error message. What’s going wrong here?
Kernel: The operating system kernel consists of the components which comprise the actual operating system. Only this has direct access to the resources of the computer (disk space, memory and computing time, keyboard etc). If a command is sent or a program started, the requisite program code is loaded in the main memory and started. This program is now referred to as a task. Tasks have no access to the resources: they request these as required from the kernel. The Linux operating system kernel allocates the necessary computing time and the memory so lightning-fast that it gives the impression that programs can start in an instant. Compiling: If a source code file is transferred to a compiler (gcc), the original code (readable by humans) turns into a object file (readable by machines). The object file is in turn linked with the necessary libraries and then a program that is ready to run is created. Libraries contain standard functions, which are used by many programs, such as for screen output. The result of this is that all these functions do not have to be rewritten all the time for every single program. Sources: Often also referred to as source code or source text. This is the text a programmer has written (in a programming language such as C++). It is only through compilers known as conversion programs that the text which humans can read is turned into a binary program or a file that the machine can execute. ■ 90 LINUX MAGAZINE 8 · 2001
root# cd /usr/src/linux the sources of the kernel (often also called kernel sources) are missing altogether and will have to be installed. Because these are very large, they are not usually automatically included in the system during a standard installation. For SuSE users, from SuSE Linux 6.2 the automatic installation of the kernel sources is also no longer done by default. The kernel sources for your actual system can be found in the most common distributions on the installation medium. From there, depending on the system; YaST, gnorpm or dselect these can be installed later. On the Internet you can find packed kernel archive as tar.gz or tar.bz2 among others at http://www.kernel.org/
Over and out I have installed SuSE 7.0 on my computer. Now I want my computer to switch itself off after power down, as happens with Red Hat. Can this be done with the SuSE distribution? Dr. Linux: If you want to use APM (advanced power management) SuSE provides you with a special kernel from Version 6.3. This is precompiled and can be installed with YaST. SuSE gives you information on this in the support database on your
090-drlinux.qxd
27.03.2001
16:24 Uhr
Seite 91
DR. LINUX
system or at http://sdb.suse.de/sdb/de/html/ index.html under the keywords APM, ATX. The prerequisite for this kernel to work perfectly is that the APM functions in the BIOS of your computer must be activated. If you start YaST as root, have your installation CD to hand, because by the time you get to kernel selection you will be asked to insert this CD. Via the menus Administration of the system/kernel and boot configuration/Select boot kernel you will reach the appropriate selection window, where you will find among other things the Kernel with APM support (Figure 2). If you select yes in the next dialog window (Figure 3), YaST creates a new /usr/src/linux/.config with the description of the APM kernel. To finish, you will receive a message confirming the kernel installation, and YaST reinstalls LILO (Linux Loader), so that the kernel which has just been placed on your hard disk is also ready when you boot up. Normally you confirm this in turn with ‘yes’. Experienced users may wish to edit the LILO configuration file /etc/lilo.conf thus created personally and inform the boot manager, by calling up the /sbin/lilo program, about the new kernel. If you are using a boot manager other than LILO, please follow the appropriate instructions. And now you’ve done it – the new kernel will become active when you next boot up. Before you
BEGINNERS
BIOS: (basic input/output system) The basic software of computers. When booting up the computer this program performs a self-test, which among other things, determines the graphics mode and checks the motherboard and the main memory. Users can make changes to the BIOS settings. You can find precise details in the manuals, which come with the computer and/or motherboard when you buy them. You can also find more detailed information on the website http://www.sysopt.com/bios.html ■ do so, though, and install the APM kernel on your computer, one more last tip: On my computer, bought from a department store, the installation of this kernel with SuSE 7.0 did not in fact work very well, but it is still sensible to find out about the (later) installation of modules in your manual, so that you can cope with any error messages. Users of SuSE version 6.3 should (as described in the manual in chapter 3, ‘YaST’), also reinstall the packet kernmod from series a after installing the kernel. If you want to build the kernel yourself, you can of course also include advanced power management. You can create the kernel configuration on a graphical user interface with the command root# make xconfig The APM functions can be found under the menu
[top left] Figure 1: The path to kernel selection in YaST [top right] Figure 2: Kernel selection of SuSE 7.0 in YaST [bottom left] Figure 4: The boot manager has to be reinstalled [bottom right] Figure 4a: Finally you will see the entries of your LILO boot configuration
8 · 2001 LINUX MAGAZINE 91
090-drlinux.qxd
27.03.2001
16:24 Uhr
Seite 92
BEGINNERS
DR. LINUX
Real mode: When a computer is switched on a code starts the BIOS, which after its (successful) checks reports back with ‘OK’. Only then does the search begin for the operating system. Depending on the sequence set in the BIOS the first sectors of disk, CD-ROM or hard drives are searched for a boot loader (e.g. LILO). If a loader is found and activated, the kernel begins to load. This starts the operating system, and the CPU can switch from Real Mode into Protected Mode. It is only in the second of these that a computer can contact its whole memory. Modules: Drivers which are only loaded as needed into a (modularised) kernel. The advantage of such a kernel over the monolithic kernel, which has all drivers integrated permanently, is that only drivers which are needed during running time are loaded and take up no memory space when not in use.
Basic settings (Figure 5). This also applies, of course, if you configure your kernel with the command root# make menuconfig (Figure 6).
In at the deep end I would love to build a kernel, but I’m afraid that with my level of Linux skill, something could go wrong. Is there a safe method? Dr. Linux: Get hold of plenty of information on the subject of kernel conversion, so that you are not taken by surprise by problems which suddenly crop up. One source of information is the kernel HOWTO. If you have not installed this on your system, then you can find it at http://www.linuxdoc.org/HOWTO/KernelHOWTO.html. Your system also usually offers you comprehensive texts for self study in the directory /usr/src/linux/Documentation. In order to avoid errors due to excitement or volatility, I put all of my kernels onto a boot disk first to test that they were working. This allows you to take a fairly nonchalant view of any error messages and if necessary, start again at the beginning. You should also have a boot disk that has been proven to work. Using root# make zdisk or
■
root# make bzdisk
over the permissible upper limit of 512K. This maximum size is due to the fact that the kernel loader is started in Real mode, where there is no more memory available. But with the latest versions of Linux it is no longer necessary to create a kernel image which keeps within these limits: The latest versions of LILO or Loadlin also cope with a bigger kernel – although only if it has been specially created. The corresponding command for this reads root# make bzImage The b stands for ‘big’. Incidentally, you also get a big kernel like this if you use the commands root# make bzlilo or the aforementioned root# make bzdisk make bzlilo not only builds your new kernel, but also takes over the entry in the boot manager LILO. The prerequisite for this is that you do not use any alternative Linux boot loaders (grub for example) and that the program lilo is located in /sbin. It may sound simple, but make bzlilo is not the best choice for a newbie kernel. You should first read up on how to edit /etc/lilo.conf in the event of problems and enter your old, functioning kernel as a precautionary boot alternative. If you want to stay with make zImage when the error message appears all you can do is swap several drivers as modules to trim down your kernel image. ■
You can place a new kernel directly onto disk, where the kernel is first created, then compressed and finally copied onto the disk.
System too big? It’s not possible to compile a kernel on my system. After the command root# make zImage I get the message System is too big. Try using bzImage or modules. Dr. Linux: This message or, again, the message ‘kernel too big’ means that your kernel image is
Figure 5: Setting APM support with make xconfig
Figure 3: Kernel installation on the fly with YaST
Figure 6: ... and with make menuconfig
92 LINUX MAGAZINE 8 · 2001
093-pcorner.qxd
28.03.2001
9:43 Uhr
Seite 93
PROGRAMMING CORNER
BEGINNERS
Part 3: String Processing and Regular Expressions
SCRAPS OF WORDS MIRKO DÖLLE
Let’s start with separating parts of a string, let’s say Hello, you beautiful world. Even if some of you might not necessarily wish to subscribe to this point of view, we are going to expand it a bit more. Firstly we break down our phrase: #!/bin/bash set="Hello, you beautiful world" echo "${set:0:5} ${set:21}" The result is our old friend ‘Hello world’, which we have derived from our phrase with the command ”${variable:offset:length}”. This command delivers a section (Substring) of the specified character string. The offset states how many characters from the beginning we are starting. In the case of Hello it starts with the first character, thus with an offset of zero, while to reach the first letter of world, we have to leap over 16 characters – hence, here we have an offset of 16. If you like, you can also count back from the end of a string, as in the following example: #!/bin/bash set="Hello, you beautiful world" echo "${set:0:5} ${set: -5}" Whenever you specify a negative offset, the count is done forwards from the end. But be careful with colons and minus signs: If these are not separated by a blank space, Bash recognises the command ”${variable:-string}”, which we discussed in the last instalment of Programming Corner. In the example, we have come across both forms of application of the substring function. Variable and offset must always be specified; without the length specification the substring will be derived from the specified position to the end. Knowing this, we are now able to convert: #!/bin/bash set="Hello, you beautiful world" echo "${set:0:5} ${set: -5}${set:5:2} [you] are so ${set:11:9}." One great advantage of this method is that we always have to know the position of the words – if we were to use Hi instead of Hello, our whole program would go into a spin. In fact we really want to swap whole words and not just letters, so we have to recognise the limits of words.
characters which are to apply as separators between program names and parameters. The standard rule is that these are blanks, tabulator and Enter. For our purposes, only the blank space is the required separator between two words. The following program separates our phrase into words using blank spaces and stores each word in a different variable. The result is then the same as in the previous listing, i.e. our converted phrase:
We laid down the fundamentals of
#!/bin/bash IFS=" " set="Hello, you beautiful world" set -- $set echo "$1 $4, $2 [you] are so ${3:0:5}."
character strings in the last issue. This time though, we will not be
The fourth line is new, the set command. Without specifying parameters it lists all variables which have been set. Otherwise set can be used to change various settings for the run-time of Bash. Here we are using the third domain of application: We are filling our parameter variables (positional parameters), which we would not otherwise be able to alter, with new values. The double minus characters as first parameter are important. set has its own range of options, which all begin with a minus sign followed by a letter. The double minus is defined as the end character of all options, which means that nothing following it can be a parameter. Any minus signs that may occur in our text are thus not misinterpreted. Using the variable IFS we have told set that parameters are separated by blank spaces. This means that for set every individual word is a parameter; these are filed in sequence in our special variables from $1 on upwards. By the way, it is not possible to fill only individual ones of these variables or to start with a specified number.
Bite-size arrays Now we can try out the other action of the command ${variable:offset:length}, namely in connection with arrays. To do this, we are using the array $*, which contains all parameter variables such as $0, $1 and $2:
Breaking down into words
#!/bin/bash set -- Hello world - you are so beautiful. echo ${*:1:2}
To do this, we can use the special variable mentioned in the last issue, IFS – this includes all the
The result is our old friend, ‘Hello world’. When using arrays we obtain a portion of the elements
settling for simple dry runs or length specifications, but will be mixing our strings vigorously together.
Substring: Part of a character string. Offset: Displacement with respect to the zero point or start. There can basically be positive and negative offsets, negative values being counted back from the end. Positional parameters: In the variables $0, $1, $2 etc. all parameters of a program command are stored separately. Nothing can be assigned to them directly – reloading is possible only with set. ■
8 · 2001 LINUX MAGAZINE 93
093-pcorner.qxd
28.03.2001
9:43 Uhr
Seite 94
BEGINNERS
PROGRAMMING CORNER
instead of, as with character strings, a part of the letters. In the example we start with element number 1 and fish out a total of two elements. Arrays normally start at element 0. But the program name of Bash is in $0, so we find the first element of the parameter variables, exceptionally, in $1.
variables, namely the first to the second-to-last ones (”$#” is the number of parameter variables, 1 is deducted from it) separated by spaces, and stores them afresh using set under $1 to $3.
Dirname and basename are home-built
Now we want the directory name separated, not with blank spaces, but in the usual way with slashes. To do this we exploit the fact that ”$*” delivers all parameters – in our case $1 to $3 – one after the other, separated by the first characters from IFS. We set IFS as equal to slash once again and with line eight we get back the readable directory name. But in the conversion the first slash has gone astray, which is why we must place it in front. Line nine is still very important, even if it is not apparent at first glance. If the slash was in line 10 in IFS, then echo would be given back our path (also separated by slashes) as individual parameter – and echo always displays parameters separated by spaces.
Now let’s turn to a new example, and separate the absolute path and the file name from each other – ”/usr/X11R6/bin/X” should turn into ”/usr/X11R6/bin” and ”X”. There are ready-made programs to do this, dirname delivers us the directory and basename the file name. Now you need to copy both commands using the resources of Bash. To do this, we can apply the method of substring function we have just learnt to arrays:
pattern matching: pattern comparison, where a pattern consisting of wildcards, special characters and normal characters is compared with a character string. wildcards: Joker characters, for example question mark and star. These stand for any character or as many characters as you like. These can be used to form complex patterns and regular expressions. ■
001 002 003 004 005 006 007 008 009 010 011
#!/bin/bash IFS="/" set -- $1 file="${*: -1:1}" IFS=" " set -- ${*:1:$[$#-1]} IFS="/" directory=/"$*" IFS=" " echo directory: $directory echo file: $file
This listing needs some explanation, even if no new commands occur in it – a bit of thought has gone into these eleven lines, which you will not immediately grasp at first glance. This is a good example of a listing requiring exhaustive documentation.
Path separation with IFS At this point we are going to make use of the special variable IFS, whose content will be interpreted as separator between program name and parameters. In the second line, we set IFS as equal to slash – now the parameters of a program command are no longer separated from each other by blank spaces, but by slashes. This is also where the unusual notation of the third line comes from: The command set receives, as first parameter, the double minus, and after this comes our path specification. The slashes seen there are interpreted as separators between the parameters, so that we then have $1 to $5, where $1 is empty. The trick for determining the file name is that it must stand immediately behind the last slash – so it is in the last parameter variable. In line four it is stored under file. We still have to define the directory: This is written – even if without slashes – in the previous parameter variable. So we need them all but the last one. To get rid of the variable with the file name, we set IFS on the blank space. Line six now provides us with a part of our parameter
94 LINUX MAGAZINE 8 · 2001
Constructing a path specification
Pattern recognition The final example serves not only as consolidation but is also intended to show you how to make life considerably easier for yourself by using the right commands. The following listing produces exactly the same result as the previous one: #!/bin/bash directory="${1%/*}" file="${1##*/}" echo directory: $directory echo file: $file Now we are dealing with two new commands, ${variable%pattern} and ${variable##pattern}. Both work by pattern matching. The pattern in line two is ”/*” and stands for a character string, which starts with a slash and is then followed by as many characters as you like. In this case, as many as you like means: from none up to an infinite number. Bash has additional control symbols for pattern matching, so-called wildcards – the most important ones are the question mark and star. The question mark stands for any character at all, while the star covers as many characters as you like. The command itself searches the variable from back to front and checks when the pattern matches for the first time – thus when, seen from the back, a slash occurs and either nothing or something is behind it. Then it deletes the pattern it has just found, meaning the slash and any characters behind this are removed. We use this to get the directory. We know that the program name stands directly after the last slash, and have to remove this to get the directory. The last slash itself is – as in the previous example – also removed. To get the file name, we must do the exact opposite: We remove everything as far as the last
093-pcorner.qxd
28.03.2001
9:44 Uhr
Seite 95
PROGRAMMING CORNER
slash. To do this we have turned the pattern around, we are now seeking any number of characters, behind which a slash stands. The command ${variable##pattern} searches from the front, beginning after the first match of the pattern. The effect of the double hash is that it is not satisfied with the first match, but tries to remove as much as possible at once. In the example of path=/usr/ X11R6/bin/X, ${Path#*/} would settle for ”/” (the star here stands for no characters, followed by the slash), while ${Path##*/} greedily removes ”/usr/X11R6/bin/” (the star stands for ”/usr/X11R6/bin”, followed by the slash). Pattern comparison from back and front followed by removal comes in the following variants: a moderate (${variable%pattern} and ${variable#pattern}) and a greedy (${variable %%pattern} and ${variable##pattern}) variant. But back to our program. In the second line we get the directory in which, searching from the back, we want to have the pattern ”/*” removed. In our case, thus ”/X” is deleted, leaving ”/usr/X11R6/ bin”. In line three we use the greedy method and search from the beginning to have the pattern ”*/” deleted – ”/usr/X11R6/bin/” is thereby excepted, which leaves ”X” as the file name.
Regular expressions There is also a third way of separating the file name from the directory, using regular expressions: #!/bin/bash file="${1//#*\//}" directory=”${1/%\/[^\/]//}” echo directory: $directory echo file: $file The second line is the greedy version of the ”Search/Replace” command, usually written as ${variable//searchpattern/replacement}. Our search pattern is ”#*\/”, which looks complicated at first glance. The hash at the beginning means that the following pattern must appear at the start of the
BEGINNERS
variable. The star stands for any sequence of characters, and ”\/” is nothing but a protected slash – otherwise it would be misinterpreted as the start of the replacement. So the search pattern ”#*/” is effective for any character string followed by a slash, which must stand at the start of the variable. Since this is the greedy version of the command, in ”/usr/X11R6/bin/X” it lays claim to the character sequence ”/usr/X11R6/bin/”. The pattern found will now be exchanged for the replacement – in our case, this is empty (two slashes in succession), hence the matching substring is removed. This leaves ”X”, the file name. The next line provides us with the directory. A search is made for the pattern ”%\/[^\/]”, where again the slashes protected by backslashes can be seen – the simplified form of the search pattern is ”%/[^/]”. The percentage character means that the following pattern must stand at the end of the variable, in order to match. In the square brackets there is a series of characters which may occur as an alternative – ”[123]” means that 1, 2 or 3 matches at this point. In our case a caret and the slash stand in the brackets, but the caret itself has a special position. If it stands at the beginning, the following listed characters must not come before the brackets. ”[^/]” thus means all characters as far as the slash. The whole pattern together thus matches a character string beginning with a slash, then contains any characters (with the exception of an additional slash) and stands right at the end of the variable. This notation, which is admittedly not very enlightening, becomes necessary because when doing a Search/Replace, evaluation always starts from the beginning. A ”/*” would have encompassed”/usr/X11R6/bin/X” in the third line, despite using the moderate method, and the result would have been to leave an empty string. It was only by knowing that the name of the program stands after the last slash, so it contains any characters with the exception of the slash, that we were able to solve this case by search/replace. ■
Regular expression: Also called ”regex” for short, is the generic term for pattern. Text patterns are described by a regular expression, almost like a little programming language. This means regular expressions can be used for both searching and also replacing text patterns. ■
Commands for string processing ${#variable} Length of the variable in characters. ${variable:?string} outputs string, when variable is empty or does not exist. ${variable:-string} Result is string, when variable is empty or does not exist, otherwise variable is sent back. ${variable:=string} string is assigned variable, when variable is empty or does not exist, otherwise variable is sent back. ${variable:+string} Result is string, if variable exists and is not empty, otherwise nothing is sent back. ${variable:offset} Delivers the content of variable from position offset to the end. If variable is an array, all elements from offset to the end of the array are given back. ${variable:offset:length} Delivers length characters of the content of variable from position offset. If variable is an array, length elements from element offset are returned. ${variable:#pattern} Removes the smallest matching pattern from variable (moderate). Searches from front to back. ${variable:##pattern} Removes the largest matching pattern from variable (greedy). Searches from front to back. ${variable:%pattern} Removes the smallest matching pattern from variable (moderate). Searches from back to front. ${variable:%%pattern} Removes the largest matching pattern from variable (greedy). Searches from back to front. ${variable/pattern} Searches variable from front to back and removes the first matching pattern. ${variable//pattern} Searches variable from front to back and removes all matching patterns. ${variable/pattern/string} Searches variable from front to back and replaces the first matching pattern with string. ${variable//pattern/string} Searches variable from front to back and replaces all matching patterns with string. 8 · 2001 LINUX MAGAZINE 95
096-KTools.qxd
27.03.2001
15:13 Uhr
Seite 96
BEGINNERS
KORNER
K-tools
BABYLONIAN BABBLE STEFANIE TEUFEL
Not for nothing do we talk about the global village, since on the World Wide Web you can now find every language under the sun. A land of milk and honey for linguists, a nightmare for all those who daydreamed through their French or German classes. Anyone who has ever stumbled over a site in a foreign language which looked very interesting, but was hard to decipher due to the lack of language knowledge knows the only remedy is to swot up vocabulary and grammar.
Translate me
QTrans 0.0.3
On the other hand, it is much cleverer to use a little helper such as QTrans to outwit the cognoscenti elegantly. Behind this slightly cryptic name hides an instant translator for KDE, based on the Babylon dictionaries and the program of the same name for Windows. To bring some order to the Babylonian babble, you first need to obtain the current version, qtrans 0.0.3, from http://digilander.iol.it/merlim/qtrans0.0.3.tar.gz. Unfortunately - or perhaps thankfully, due to their size - the dictionaries are not included in the packet, so you still need to make a brief sidetrip to the Babylon site at http://www.babylon.com/. By the by: If you have already used Babylon in the
K-tools In this column we present tools, which have proven to be especially useful when working under KDE, solve a problem which otherwise is deliberately ignored, or are just some of the nicer things in life, which - once discovered - you wouldn’t want to do without.
96 LINUX MAGAZINE 8 · 2001
offline version under Windows, you can save yourself this trip and use the files/dictionaries on your windows partition in QTrans. Everyone else is now faced with a fairly hefty download. Go to the Babylon site and search, in the section Glossary Index/Languages for the appropriate dictionaries, so that you can get going. I settled on the German variant and in the German sector, immediately downloaded the first glossary full_ger_dict50.exe. At around 5MB, a solid chunk, but worth the effort, as you are about to see. Please note that you are getting hold of an exe file. It is only these self-extracting archives which contain the dic files which QTrans needs to work. Behind the other files are hidden so-called Babylon glossaries, which QTrans cannot read yet. The author of the program is, however, according to his own claims, working feverishly on glossary support. If you have finally got the file full_ger_dict50.exe onto your harddisk, unpack it with a user-friendly unzip full_ger_dict_50.exe. After that, among others, the following files should appear on your computer: ENGLISH.DIC, ENGLISH2.DIC and ENGTOGER.DIC. If you like, you can of course also unpack the file at any time under Windows. It is also possible that you see the file names written in lower case rather than upper. But this doesn’t matter, all that counts is that they are on your computer.
096-KTools.qxd
27.03.2001
15:13 Uhr
Seite 97
KORNER
BEGINNERS
[left] Figure 1: Configuring the dictionaries [right] Figure 2: Translation made easy [below] Figure 3: It depends on the result
The joy of configuration Let’s now look at the translator itself. Install QTrans using the good old Linux three-step ./configure, make, an su root and make install. Finished? Then we simply start the program with a qtrans & in a terminal emulation of your choice or via the K start menu, Applications/QTrans. You will be greeted by the QTrans configuration window (Figure 1), in which you should now enter as quickly as possible the paths to the respective dictionaries. This also applies, by the way, if the files concerned are hidden away on a windows partition. This just has to be mounted, meaning you have to be able to access this partition with Linux. In our example, in the field English dic, you enter /path/to/file/ENGLISH.DIC. The zone Specific dic is adorned with the entry /path/to/file/ENGTOGER.DIC. Another click on Apply, and that’s it. Also interesting are the entries in the tab Misc. Click on any of the fields here. QTrans then automatically docks with the panel, starts minimised and does not shut down when you click on the Exit button of the window. Instead of this, it lies in wait as an icon in the panel for the words it has yet to translate. The function Enable Auto PopUp, from version 0.0.3, has had the effect that the QTrans window only pops up out of the panel on your desktop, when the program has found an appropriate translation for the selected word. The way the electronic dictionary works is brilliantly simple. Just enter the corresponding word in the box next to the arrow button (Figure 2), click on the arrow button, and then enjoy the result, as in Figure 3.
Your eavesdropper in the panel Sometimes it is not even necessary to enter the words into the translation tool at all. If the program with which you are currently working (and from which you wish to translate something), is a KDE application such as for example Konqueror, all you have to do is highlight the word concerned with the mouse. QTrans observes your KDE clipboard and immediately sets about translating, as soon as its content changes. If you ever want to shut down the program, just click with the right mouse button on
the arrow icon in the panel and there select the item Exit (Figures 4 and 5). A click with the left mouse button on this icon retrieves the program window at any time from its self-imposed exile in the panel on your desktop. ■
su: The su command stands for ”substitute user”, or swap the user. It allows you to change your identity while working under Linux. Normal activities such as mailing, surfing etc. should always be done for security reasons with a simple user account. But since it would be extremely tiresome to have to log off and log on again as root for each and every administrative action, you can also use su to become administrator as you go along. You can easily tell the status has changed from the altered shell prompt: Instead of $ there now appears # as the prompt. Terminal emulation: Expression referring to a program which imitates a text terminal. Under Linux this can be either a representation in true VGA mode or one of the terminal emulators for the X-Window system (konsole, kvt, xterm, etc.). Path: The way to a file in the file tree, thus a listing of all directories via which one must pass to reach the file. Mount: This is the name for integrating a storage medium (such as disks or partitions) in the Linux file tree. If there is no appropriate entry in the configuration file /etc/fstab, this integration can only be performed by the system administrator root.
Figure 4: Docked
Figure 5: If you ever want to leave QTrans...
■ 8 · 2001 LINUX MAGAZINE 97
098-gnomogram.qxd
27.03.2001
15:22 Uhr
BEGINNERS
Seite 98
GNOMOGRAM
News from the GNOME garden
GNOMOGRAM BJÖRN GANSLANDT
GNOME and GTK have been attracting more and more followers in recent years. There are now programs for almost every task and new ones are being added daily. Our monthly Gnomogram column is the place to find information on the pearls among the GNOME tools and the latest GNOME rumours.
Helix Code evolves into Ximian
The author Björn Ganslandt is a student and a passionate bandwidth squanderer. When he is not busy trying out new programs, he reads books or plays the saxophone.
Helix Code has changed its name to Ximian (the X is pronounced as a Z), in order to gain a better legal handle over freeloaders like Helixcode UK. The new, protected name is derived from simian, or ape-like, and to that extent goes well with the old image. Apart from the name, nothing else is changing for the time being. Investors appear not to be bothered by either the new name or the not-so-rosy situation affecting Linux start-ups – according to the news item (third address in URLs boxout) Battery and Charles River Ventures have kitted out Ximian with an additional 15 million US dollars.
Preview of GTK+ 2.0 A little foretaste of the options opened by XFree86 4.0.2 is offered by the screenshots at http:// people.redhat.com/otaylor/gtk/render/. Not only is the text in soft focus, but Unicode symbols for texts which are read from right to left are also shown. The architecture, with which this was made
LZH-Archive: LZH is an outdated archive format, which was very popular under MS-DOS. As in zip or tar.gz archives, here, too, there are several files or whole directory trees in compressed form. The tool for creating and unpacking lzh files under Linux is called lha and also supports Unix-type file attributes (owner, group, access rights). ■ 98 LINUX MAGAZINE 8 · 2001
possible is called Pango and will in future become part of GTK+. Again with soft focus text, but created independently of X Window are the screenshots at http://www.lysator.liu.se/~ alla/files/diafb.png and http://news.gnome. org/gnome-news/978625013/. With the aid of GtkFB, writing is done directly into the framebuffer, an abstraction from the graphical hardware, which is of particular interest to the embedded domain. Although it will be possible with this to compile GTK applications for the framebuffer, a framebuffer version of GNOME seems unlikely for the time being – GNOME is still based in many respects on X Window.
Cinematic GNOME As the film Antitrust demonstrates, the open source phenomenon has now even reached Hollywood. The film shows a young programmer, who after a bit of hesitation goes to work for a big software firm, where he finds out just how tough competition can be. Apart from stars like Tim Robbins, the film also includes walk-on parts for GNOME icons Miguel de Icaza, Sun’s CEO Scott McNealy and the GNOME desktop itself. But whether that’s good enough reason to actually watch the film remains to be seen.
Gtktalog In the oodles of sparsely-described CDs, which many people now own, it can turn into a real chore to find a certain file. Gtktalog has the remedy; it sets up a
098-gnomogram.qxd
27.03.2001
15:22 Uhr
Seite 99
GNOMOGRAM
database with the content of CDs and directories. Apart from the name of the respective file, you can also specify categories and descriptions of the individual files. With the aid of plugins Gtktalog also reads information such as tags from Mp3s or the titles of HTML pages and stores them. Archives are shown in virtual subdirectories by Gtktalog, similarly to Midnight Commander, and can be searched. By default only the file names of archives are read out – for a date of change and other details, you have to select Complete VFS search in Settings/Search Options, which results in a larger database.
BEGINNERS
URLs http://www.ximian.com http://www.helixcode.co.uk http://www.ximian.com/newsitems/2ndroundfunding.php3 http://people.redhat.com/otaylor/gtk/render/ http://www.pango.org http://www.lysator.liu.se/~alla/files/diafb.png http://news.gnome.org/gnome-news/978625013/ http://www.antitrustthemovie.com http://gtktalog.sourceforge.net http://www.ecs.soton.ac.uk/~njl98r/code/kiss/ http://www.otakuworld.com/kiss/
GnomeKiSS GnomeKiSS is an implementation of KiSS, the Kisekae Set System, for GNOME and is one of the comparatively few GNOME programs with which even children can get to grips. Kisekae is derived from the Japanese Kisekae Ningju, which means roughly ‘play dress-up with dolls’. Like their paper counterparts, the dolls can have their clothes changed using drag and drop. The KiSS Set itself is usually an LZH archive, which GnomeKiSS unpacks with the aid of lha, with several pictures as well as a colour palette and a configuration file, describing how the individual pictures are arranged. There are numerous expansions of this system, with varying degrees of support from GnomeKiSS: Cherry-KiSS for example offers larger palettes, French-KiSS extends the programmability of KiSS and thus allows for more interactivity. A whole scene of designers has sprung up around KiSS, whose dolls can be found on the Internet – especially popular are the heroines and heroes from the Japanese Anime series, which have now become known in the UK. Many of the very different dolls include hidden effects such as the obligatory blinking of the dolls and little animations together with sound effects. All you need to watch out for is that there are no X-rated ones among the many dolls, but as a rule these are identified as such.
Sawfish offers considerably more options for key combinations under Windowmanager Sawfish/Key shortcuts: There, most functions of Sawfish and a few of GNOME can be assigned keys. New key combinations are created using Add, specifying a key and a command. (Numlock status does not matter in this case). The commands xterm and run shell command are especially useful: The former starts a terminal program specified under Windowmanager Sawfish/Other, and the second can be used to call up any program you like. ■
[top] Figure 1: All Mp3s at a glance with Gtktalog [above] Figure 2: Sam & Max from the adventure of the same name
Key combinations under GNOME Apart from GNOME itself, above all Sawfish offers the option of storing functions as key combinations. Windows keys are especially suitable for this but you must first assign these a key name in the file ~/.Xmodmap. In the example, the left Windows logo is assigned F28, the right F29 and the menu key F30: keycode 115 = F28 keycode 116 = F29 keycode 117 = F30 These key names can then be specified in the GNOME control centre under Panel/General, to open the menu or the Execute dialog. The only annoying thing is that it makes a difference whether numlock, capslock etc. are active or not. So, for a key with numlock set, one has to specify Mod2-keyname, or for a key combination with Ctrl Control-Keyname. 8 · 2001 LINUX MAGAZINE 99
100-command.qxd
27.03.2001
16:10 Uhr
BEGINNERS
Seite 100
COMMAND
Painless configuration file creation
DOTFILE GENERATOR KARSTEN GUNTHER
Using Dotfile generator makes creating configuration files for many standard Linux tools easy.
Figure 1: Module selection
Under Linux, the configurability of programs is a given, provided they have achieved a certain level of complexity. The robust format of the configuration files is typical of Unix (because they are legible and can be edited using a text editor). The vast majority of Linux software is adapted in this way to the requirements of its users. Unfortunately, until now there has been no binding syntax for the various configuration files. Blank lines are usually ignored. Comments are introduced with a hash symbol (#) and extend to the end of that line. But in some configuration files under X (such as resource files) the exclamation mark is used to introduce comments. Keywords and variables, to which a value has been assigned (numeric or as text) can usually be used in configuration files. In many cases new functions can also be declared. But that’s pretty much as far as it goes, for the general format of configuration files.
Dotfile Generator The structural similarity of configuration files was recognised a few years ago by Jesper Kjœr Figure 2: Which Bash version?
Pedersen, who set himself the task of creating a graphical user interface to make such files. He succeeded remarkably well, with The Dotfile Generator (TDG). Even difficult settings for the programs supported can be made with just a few mouse clicks. Since 1997 the program has been available for free download in Version 2.0 on the homepage http://www.imada.ou.dk/~blackie/ dotfile/. The concept of the Generator provides a modular construction, so that for the configuration of additional programs the Dotfile Generator can be used unchanged, and only the corresponding module has to be rewritten. So far there are modules for Bash, the mail reader Elm, the window managers fvwm1 and fvwm2, ipfwadm (module for IP-Firewall, Forwarding and Masquerading), procmail (to filter mails), rtin (a newsreader) and the new C-shell tcsh. The module for configuring Bash stems from Per Zacho and is currently available in version 1.02. It is one of the oldest ones and goes right back to the year 1997. The Dotfile Generator needs at least tcl7.4 and TK4.0. All the current distributions meet these requirements.
Installation Sadly, the Dotfile Generator is not yet among the standard tools in most distributions, the software has to be downloaded from the homepage. Before implementing the program, it must be compiled. To do this, first the corresponding tar archive has to be unpacked and the configuration done:
100 LINUX MAGAZINE 8 · 2001
100-command.qxd
27.03.2001
16:10 Uhr
Seite 101
COMMAND
BEGINNERS
Figure 3:
$> tar -xvzf dotfile Installation consists simply of calling up the ./configure script: $> ./configure creating cache./config.cache ########################################### ########################################### If the configure script does not work, then please report to blackie@imada.ou.dk, and edit configure.in. ########################################### ########################################### checking for wish8.2jp... no checking for wish8.2... no ... checking for ln... /bin/ln Which language should The Dotfile Generator use as default? 1: English 2: Japanese At this point you have to enter your choice of language, which is then set: 1[Return] Now the program can be started, without even needing to be installed first. $> ./dotfile
Configuration In the main window, the user selects the desired configuration module (Figure 1), and in the next step the Bash version for which the configuration is to be done can be defined (Figure 2). Whenever possible, the Dotfile Generator seeks out the necessary information itself (such as the version of Bash) and displays the result in the centre of the window. But the user still has the option of creating a configuration for the older Bash version. Helpful tips are often given in the lower part of the dialog window. Secondly, it is possible to load certain proven defaults for the configuration. A few modules even allow the reading-in of existing configuration files. Unfortunately, this is not possible for Bash due to the complex syntax. The help button always leads to the extensive and easyto-understand online help. For menu items, a help function can be reached via the right mouse button (Figure 3). The next menu shows the available configuration dialogs (pages) in overview (Figure 4). In the menu item Setup/Options... the user can choose whether the configuration file created should contain entries from all pages (the default setting) or just from selected pages. The first variant should be selected here. In the lower part of the dialog window, the mode is displayed. Hidden behind every displayed menu item, there is again a more or less comprehensive dialog. By breaking down the menu it is easy to find the items you
want. All relevant configuration options are taken into account, but this also applies to some lesser known ones. This is shown, for example, by the seldom-used option of recording keyboard macros in the configuration file (Figure 5). To record a new entry in the configuration file, the corresponding dialog box must first be activated using the Add button. Then the desired entry simply has to be selected (by clicking on it) or has to be entered in the text box. Once all the dialogs have been dealt with, the configuration file can be generated via the menu item File/Generate. The result is then shown (Box 1) A configuration file is created by default under the name ~/.bashrc-dotfile or ~/.inputrc-dotfile. Via the File/Save As menu, the configuration files can also be saved using different paths. The first file can be read into the file .bashrc using the command source .bashrc-dotfile, while the content of the second is usually attached to the file .inputrc in the home directory of the user. Alternatively, the file can also be read in via $include statement.
Figure 4:
Conclusion The configuration of Bash (and other programs) with the Dotfile Generator is a gratifying venture. Because of the clear structure of the program, the features of the software can be set really easily and comprehensibly. And along the way, by chance, one stumbles over some function or other that might otherwise be easily overlooked. ■
Figure 5:Defining keyboard macros
Box 1: The Dot File ### This file has been auto generated ### by the Bash module for the Dotfile Generator ### on Tue Jun 27 12:56:42 MEST 2000 ... ### Primary prompt export PS1="\u@\h \w >" ... ###—————>User<->Bash interface/Command aliases<————— ### Command aliases alias ll=’ls -l’ ... ###—————>User<->Bash interface/Command history<————— ### Command history export HISTCONTROL=ignoreboth export HISTSIZE=1500 export HISTFILESIZE=1500 shopt -s cmdhist ...
8 · 2001 LINUX MAGAZINE 101
102-desktopia.qxd
27.03.2001
15:38 Uhr
BEGINNERS
Seite 102
DESKTOPIA
Jo’s Alternative Desktop
SAPPHIRE JO MOSKALEWSKI
DeskTOPia takes you once more on a journey into the land of window managers and desktop environments, presenting useful viewers and colourful, pretty toys. One theme-capable little gem, which is still largely unknown in the land of the Linux desktop, is Sapphire.
You would be forgiven for thinking that the name Sapphire refers to a precious stone – but if you notice the second ‘p’ in the name and pick up a dictionary, the trail leads back some 2,600 years to the Greek island of Lesbos and its poetess, Sappho. She composed poems about her life and her liking for her female students. Sapphire is also about love and the amalgamation of two things. Take a look at the homepage: http://sapphire.sourceforge.net/. The program author was inspired by the code of the window manager aewm, which he used as the basis for his project, and a few features of the window manager Blackbox, which he gradually integrated. The result of this love is what he now calls Sapphire.
Window what?
Figure 1: The Sapphire toolbar
A window manager does just what the name suggests – manages the windows on the desktop. As a rule, this also includes providing an application with a frame – usually in the form of a bar with buttons for closing and minimising. Some also offer a task list or taskbar (via which, for example, minimised windows are made visible again) along with a start menu. It’s also worth knowing that a window manager actually needs a graphical user interface (and not, as many believe, itself acting as the graphical user interface) — under Linux this is X. Even interfaces such as KDE or GNOME operate according to the knitting pattern: X-server, window manager, application. So a window manager is
102 LINUX MAGAZINE 8 · 2001
nothing but an optional application intended to simplify the use of a graphical user interface and improve appearance.
Getting the menu The strength of Sapphire does not lie in its configurability or equipment, but in its use – it is easy and definitely pleasant to work with. In the middle of the lower edge of the desktop there is a small bar (toolbar). The toolbar makes all menus accessible with one button, starting with the Icon menu (a list of minimised windows), via the Window menu (a list of active programs) to the Root menu (Start menu, themes and end). All menus can also be seen by clicking on a free space on the desktop. Two buttons on the toolbar scroll up or down through the opened windows and four more manage virtual desktops in case space suddenly starts to run out. The date and time are also shown. What really works well is the window decoration. The header offers a button on the left to close the window and one on the right that reduces the window to its own header – a practical feature once you get used to it. The desktop itself stays constantly in view in many open applications. The middle of the three right-hand window buttons minimises. You can open up the application again either with the middle mouse button on the free desktop or via the toolbar. The fourth button maximises – a feature that will surely be used rarely with today’s monitor sizes. Much more important here is another and less obvious decoration on the right hand edge of the window. This bar is used to adjust the size of an application individually. The latest window (or the one with the focus on it) is the one which registers keyboard inputs. In the foreground, though, there has to be a mouse click first – the range of the focus does not extend this
102-desktopia.qxd
27.03.2001
15:38 Uhr
Seite 103
DESKTOPIA
BEGINNERS
far. In addition Sapphire is theme-capable and also sets an appropriate background colour, if this is provided by the theme. With a bit of tinkering, you can also conjure up a graphic onto the desktop (see the Personal Edition section). The demands made on the system are very low. Sapphire is very fast and takes up just 1.4MB of RAM for itself. But it’s not just in terms of hardware that this window manager behaves modestly – it also makes few demands on the environment into which it is integrated.
On your marks... Your own hard drive has to come up with a compiler (gcc) as well as with the header files for X (the packet with these is usually called xdevel). If these requirements have been met, the archive on the cover CD must first be unpacked. After that the script configure checks the system installation and creates a makefile based on the results, on the basis of which the compiler finds out (via the command make) what exactly needs to be done. Only after that is the program converted for your own computer and can be installed with make install. In addition, a standard configuration is set up with the script data.inst: jo@planet $ jo@planet $ jo@planet $ jo@planet $ jo@planet $ Password: root@planet root@planet root@planet
tar -xvzf sapphire-0.15.6.tar.gz cd sapphire-0.15.6 ./configure make su # make install # ./data.inst # logout
... get set, go! For the first attempts in any case – if it is used – the graphical log-in (xdm, kdm or gdm) should be deactivated. In the case of SuSE this is done by using Yast, for other distributions you should look in your manual. To stay with SuSE: After the computer has now presented the text console, the following command should get you to the finish line:
Figure 2: Sapphire window decoration with a menu
Personal Edition There is not much else to say, the entire configuration is laid down for the whole system and not for the individual users. All relevant files are in the directory /usr/local/share/sapphire/ and are simply edited with your own favourite editor. This is really clear and simple and easy to understand at first glance: While the Root menu is selfexplanatory, the themes do need a bit of introduction. The Default theme is always started – so if you want to use another one, either the previous one has to be edited or the desired one simply renamed. What’s interesting about themes is also the undocumented feature command:, with this command (similar to an autostart) other desktop systems can be executed. For example, to set a graphic as desktop background with the tool qiv, you can proceed as follows: In the theme file the entry root.background: is set to false. Then enhance the file with the following line: command: qiv -z /path/to/graphic/graphic.jpg And now, have lots of fun designing your lyrical desktops with Sapphire!
■
Figure 3: A desktop with Sapphire
jo@planet ~> WINDOWMANAGER=epiwm; export WINU DOWMANAGER jo@planet ~> startx With other distributions, simply type startx sapphire. This command should work on any Linux system – unless the user has a file called ~/.xinitrc: If this is present, it will in any case be heeded and when X is started, will be read out via the command startx. As a last entry in this optional file, call up the window manager. Because if this file has already been run through, X shuts itself down and thus also the window manager. So with the shutdown of the window manager the last entry of this file is ended – and as a result, the graphical user interface too. The file ~/.xsession is equivalent to ~/.xinitrc, which is also evaluated during the graphical log-in. 8 · 2001 LINUX MAGAZINE 103
104-ootb New.qxd
27.03.2001
16:01 Uhr
SOFTWARE
Seite 104
OUT OF THE BOX
Digitising Discs
JAZZED CHRISTIAN PERLE
One or two readers may have a record player or even a gramophone still lying around. There’s certainly something nostalgic about playing sound media on such devices, but this doesn’t make shellac or vinyl discs sound any better.
Why not digitise your favourite pieces with the aid of a computer and thus get rid of a bit of the crackling? The GramoFile, which comes under the GPL, was written by Anne Bezemer for just this purpose.
Gramofile 1.6 Source text and Mandrake-RPM
Before recording Not much is necessary to install GramoFile: • the GNU C compiler (gcc), • make and • the ncurses library with the associated Header files. Now it is time to download the GramoFile source text archive from http://panic.et.tudelft.nl/~costar/gramofile/; you will of course also find it on the cover CD. The following steps are necessary to convert the program:
Digitising: Converting a continuous analogue signal into a series of digital values. In computers, the analogue/digital converter on the sound card takes over this task. GPL: The GNU General Public Licence. A software licence allowing the program to be passed on, on condition that the source text always remains available. Equally permissible and expressly desired is the fact that you can make your own improvements to the software and republish it. Linux itself is also under the GPL. make: Program for sequence control when converting source texts. The configuration file of make (the Makefile) contains, for example, information about dependencies between the individual program modules. Library: Files containing a collection of useful C-functions for specific purposes. So there are such things as libm, which provides mathematical functions, or libncurses, which realises functions for terminal-dependent text outputs. Often libraries are used jointly by several programs (shared). Header Files: In header files (also called Include files) there are lists of the functions available in a library together with parameters. The C-compiler needs this information when converting a program. In the most common distributions a header packet belonging to a library usually includes the add-on dev or devel in its name. Source text: The form of any software which can be read by humans. By converting (compiling) with a Compiler this is turned into an executable program. ■ 104 LINUX MAGAZINE 8 · 2001
tar xzf gramofile-1.6.tar.gz cd gramofile-1.6 make strip gramofile bplay_gramo chmod 755 gramofile bplay_gramo su (enter root password) cp gramofile bplay_gramo brec_gramo /usr/locU al/bin exit The Mandrake-RPM archive (which can sometimes also be used for other distributions too) can be installed with the command rpm -i gramofile-1.6-1mdk.i586.rpm from the directory /mnt/cdrom/LinuxUser/gramofile/.
Sound off In an xterm or another terminal emulator, you should now enter the command gramofile. After briefly showing a start logo, the program should now greet us with the main menu (Figure 1). You can jump back and forth between the menu items using the cursor keys and the Tab key. Return selects a menu entry. Before anything can be recorded with GramoFile, you should look at the mixer settings for the sound card and make sure there is enough disk space available for the recording. In any case, you will need just under 10MB per minute. When you select 1. Record audio to a sound file, the program firstly wants to know the name of the new audio file. (Figure 2). Recording will continue until you press Return. You can confidently record a whole side of a disc with several pieces of music as GramoFile has a very reliable function to find pauses (Track location). This is precisely the function we are going to use next.
Hack it to pieces! Now select, from the main menu, 3. Locate tracks. After the obligatory file selection, there is some
104-ootb New.qxd
27.03.2001
16:01 Uhr
Seite 105
OUT OF THE BOX
SOFTWARE
[left] Figure 1: The main menu [right] Figure 2: File select
configuration data (Figure 3). Reasonable defaults are found here. In the so-called RMS-(”Root Mean Square”-)file the weighted average values of a block (4410 values) are written. This information is required by GramoFile for most functions and should therefore be created in any case. The procedure can take a while, then GramoFile proudly announces how many tracks it has found (Figure 4), and stores the locations found in a text file with the ending .tracks. You can find out the precise method of this function in the file Tracksplit2.txt. At this point, the audio file has not yet been broken down. All that exists are the positions in the .tracks file, which you can, if necessary, also finetune with a text editor. The basic name of the .tracks file is the one entered in the file selection. Listing 1 shows an extract from a sample file.
Smooth as silk We can otherwise split the audio file into individual pieces in one pass thereby decrackling it. GramoFile provides various filters to do this, which are hidden behind the menu item 4. Process the audio signal. The function Split tracks should always be ticked (Figure 5), unless the recorded LP or single side consists of only one piece anyway. On the left, you will find all the available filters. These are marked using the cursor keys and included in the selection on the right side by using Return. The pre-set Conditional Median Filter II is the best choice in most situations. Listing 1: Extract from a .tracks file Number_of_tracks=3 # Track 1 - blocks 8 to 2514 - length: 0:04:U 10.700 Track01start=0:00:00.800 Track01end=0:04:11.500 # Track 2 - blocks 2535 to 4187 - length: 0:0U 2:45.300 Track02start=0:04:13.500 Track02end=0:06:58.800 # Track 3 - blocks 4212 to 6218 - length: 0:0U 3:20.700 Track03start=0:07:01.200 Track03end=0:10:21.900
Figure 3: Find pauses with Track location
If you want to simply split the recording into individual parts instead, but leave the signal otherwise unaltered, select the filter Copy Only. There are also additional parameter settings for most filters, which you can reach by pressing Return on a filter that has already been selected. For those who like to experiment, there is a filter which – with adequate knowledge of C – you can program yourself (Experimenting Filter).
Not yet implemented In the main menu you will notice that the items 2. Copy sound from an audio CD to a file and 5. Write an audio CD have no function yet. But GramoFile would not be open source software, if an industrious developer was not going to look into this in the foreseeable future and integrate the tools cdparanoia and cdrecord. What started as a classwork project, does not have to end with Version 1.6... ■
[top] Figure 4: Three items found [bottom] Figure 5: Filters in GramoFile
How do I connect the record player to the computer? In most cases the output from the record player cannot be connected directly to the input of the sound card, because the output signal has to be equalised first. An equaliser-pre-amp or if necessary the line-out output of the amplifier to which the record player is connected, should be used here. It is best to use line-in as the input to the sound card.
8 · 2001 LINUX MAGAZINE 105
109-gnuworldNew.qxd
28.03.2001
11:26 Uhr
Seite 109
BRAVE GNU WORLD
COMMUNITY
The monthly GNU Column
BRAVE GNU WORLD GEORG C.F.GREVE
GNU-Darwin The GNU-Darwin project works on porting the GNU system to Darwin, the basis of the proprietary MacOS X. Darwin itself is based on FreeBSD and Mach 3.0 and currently runs on PowerPC-based architectures. Apple is working on a port for Intel-architectures, however. So after GNU/Linux and GNU/Hurd there will be a third GNU-based system available. A very interesting feature of the GNU-Darwin system is to be able to run Macintosh applications parallel to the well-known Unix-programs. This allows the direct comparison of Macintosh & GNUbased programs, something that has been impossible before. So this feature makes GNUDarwin very well suited for Mac/Unix hybridstructures and with the port of SAMBA to GNUDarwin heterogenous networks with Mac/Unix/Windows will be easy to implement. But of course the main use of GNU-Darwin is not to be able to run proprietary software. It will rather create another bridge between the Macintosh platform and Free Software as the user will quickly realise that there is more Free Software for his computer than there is proprietary software. Software developed on GNU-Darwin is better-suited for interoperability with MacOS X, too, so Free Software can be brought into this world. The big amount of available Unix-based Free Software and the unique capabilities for heterogenous structures and parallel development are strong arguments for GNU-Darwin instead of MacOS X. In addition, GNU-Darwin offers several advantages over the LinuxPPC-Project which is the reason why a user-migration to GNU-Darwin can be seen. First of all GNU-Darwin is (like GNU/Hurd) microkernel-based which gives it capabilities that the Linux kernel cannot match. Also the hardware support for Darwin is done by Apple itself as it also is the basis for MacOS X. So a better hardware support is to be expected here. But not everything is better. Although the contributions of the GNU-Darwin project are of course released under the GNU General Public License, Darwin itself has been released by Apple under the Apple Public Source License (APSL). In
version 1.1 this license did not qualify as Free Software for three important reasons. First of all it was forbidden to make changes for personal use without making those changes public. In the perception of the GNU Project, the right to change things for personal use only is closely related with the right for privacy; that is why the GPL was designed to allow this. Furthermore the developer and non-scientific user of a modified version was forced to report to a specified institution (in this case Apple). This central control is in direct contradiction to the thought of Free Software. And finally there was a disclaimer that allowed Apple to terminate the license and stop the further use of the software at any point if copyright or patent claims are being made against Apple. This made every user on this planet dependent on the very problematic U.S. patent-system. Version 1.2 of the APSL was released in January 2001 and it solves a big part of the problems - the restriction on private modifications and the disrespect for privacy remains, however. So in a way the APSL takes step after step into the direction of the NPL which is definitely a Free Software license although it does allow a proprietarisation of the source-code. Even if the APSL finally gets to the point of the NPL, it would still be less than satisfactory as it would probably still be incompatible with the most often used Free Software license, the GPL. So the situation is comparable to that of KDE a few years ago in a way, as it is about a clean Free Software project built on a weak fundament and hence in danger of being cut off at the knees by legal means. Because of this the GNU-Darwin project takes a stand to release Darwin under the GNU General Public License. Especially for this advocacy work, Michael L. Love, one of the participants of GNUDarwin, asks for support from the community. In the eyes of the GNU-Darwin project, GNU-Darwin will only be truly free once Darwin is GPL’ed. The current technical issues are porting more packages to GNU-Darwin and the creation of a CDDistribution. In the long run it is planned to put the special abilities of GNU-Darwin to good use.
Welcome to another issue of Georg’s Brave GNU World. This month, a project aiming to carry GNU into the Apple world will be our starting point.
8 · 2001 LINUX MAGAZINE 109
109-gnuworldNew.qxd
28.03.2001
11:26 Uhr
COMMUNITY
Seite 110
BRAVE GNU WORLD
As the team currently consists of only six active developers, there is a wide field of possible activities for interested people to choose from. Especially developers with experiences regarding Mozilla, SDL, GNOME & Audio-Support (ALSA) will be received with open arms. By the way: the origin of GNU-Darwin is the desire of Michael L. Love to use his Apple for proteincrystallography as this is his normal occupation. Which brings me to a handful of small but rather useful projects.
get_file
[below] Gimp is already running on GNU-Darwin [bottom] GNU Global
Daniel E. Singer wrote get_file, a small fileselector written in Bourne Shell. The use of this project is apparent to everyone who every tried to have the user select files in a shell-script. Although being called by other scripts is obviously the main use of get_file, it can also be used as a commandline tool. Since it is entirely written as Bash-Shellscript it doesn’t have to be compiled and is easy to
customise. Additionally it has the capability to associate escape-sequences with certain objects, can change file-modes, execute programs and deal with wildcards. It also has an online-help. Even if it isn’t very efficient because of being a shell-script, this project should prove useful for ”on the fly” solutions.
GNU GLOBAL GNU GLOBAL is a system source-code tag system that makes administration and referencing of source code easy. It has been written by Shigio Yamaguchi who published it under the GNU General Public License, which made its recent declaration as an official GNU project unproblematic. Big amounts of ”flat” source-code distributed over different directories quickly become extremely hard to keep track of. With GNU GLOBAL a user can reference C, C++, Yacc and Java source-codes in order to be used as reference material by shellcommandline, less, nvi, elvis, EMACS or the web. Especially for large projects this makes keeping track of and getting into a project much easier. GNU GLOBAL already possesses a pretty impressive amount of features - it can not just localize object-definitions but also references, searches the paths of libraries, understands POSIX regular expressions, has a compressed format to save disk space and much more. But of course not every problem is solved already. The biggest current problem is the fact that the detection of data-type and macro definition does not yet work completely automatic. Enabling this is a primary goal for further development. Support for more languages and editors is also planned. Since current CVS version of GNU automake already has a GTAGS target (the tag-file format used by GNU GLOBAL), it is to be expected that using GNU GLOBAL will be very easy in the near future. The next project has a comparable goal but has a different focus.
HeaderBrowser The HeaderBrowser by Amaury Bouchard is also a project for the better documentation of sourcecode. It has been developed with the HeaderViewer of NeXT in mind, because Amaury liked it a lot and wanted to reimplement an improved Unix-version. Similar to GNU GLOBAL, the HeaderBrowser gets rid of the ”flat” structure of the source-code and creates a navigationable documentation of the API of a program through processing the header files. Right now the HeaderBrowser supports C and C++ as programming languages and has outputbackends to HTML, Texinfo and man-pages. Plans for the future include adding alphabetical navigation to the functions; and a user-suggested idea of writing a tool that would analyse headerfiles and create empty HeaderBrowser comments 110 LINUX MAGAZINE 8 · 2001
109-gnuworldNew.qxd
28.03.2001
11:26 Uhr
Seite 111
BRAVE GNU WORLD
that would only have to be filled by the developer. Since most developers have a rather tense relationship to documentation, this might increase the quality of many programs. Licenses used for the HeaderBrowser are the GNU General Public License (GPL) and all documentation is released under the GNU Free Documentation License (FDL), so the program is truly Free in the best meaning of the word.
GNUTLS GNUTLS is a pretty young project with the goal of implementing a transport layer security (TLS) library under the GNU General Public License. This library will grant access to the SSL 3.0 and TLS 1.0 layers and should enable programmers to easily add a security-layer to their programs. Currently GNUTLS is still inferior to the OpenSSL library as it has not been as thoroughly tested and not really used in real life. But the layout of GNUTLS is thread-safe and a much easier interface. Besides that it is good to have a TLS implentation in the GNU Project that is clearly compatibly with the GNU General Public License. At the moment GNUTLS is not ready for daily use. First of all an ASN.1 parser for x509 certificates is still missing, but this should change relatively soon as the current author, Nikos Mavroyanopoulos, is working on it at the moment. Since the other developer, Tarun Upadhyay had to leave the project because of timing-problems, help is very much welcome. Further goals for development are implementation of the extensions specified in the ”Wireless Extensions to TLS” internet draft and OpenPGP support is planned, which is something no other free TLS implementation has. For obvious reasons GNUTLS is based on libgcrypt, the library of the GNU Privacy Guard Project by Werner Koch, which has become rather well-known for its support by the German government. Now I’m coming to a project that is of paramount importance to all of us.
GNU.FREE The ”Free Referenda & Elections Electronically” (FREE) Project, which has originally been started by the University of Warwick (U.S.A.), and is now being maintained by Jason Kitcat, has also been dubbed an official GNU Project recently. The project goal is to create a secure electronic voting system that will be secure and protect privacy. The concept of the project is already two years old, so it is not a reaction triggered by the election fiasco in Florida as one could be inclined to suspect. But this obvious manipulation of a public election has brought the principles of democracy and the questions about voting and the counting of votes back into the public awareness.
COMMUNITY
There are a lot of different opinions about edemocracy and I am not sure myself that it is a good idea to establish an even more direct system, as it will most probably give demagogues more power than they already have. As far as I am concerned, the question whether ”electronic voting” is desirable has not been answered satisfactory. But experience shows that we have to expect a strong tendency towards e-democracy and I don’t think we can afford to ignore this development just because we have doubts about its sense. In a conventional system noone would seriously suggest letting a private company do the elections for the government. Imagine: the voter would go to an office of that company, enter his or her vote and in the evening the winner is announced by the company without any possibility of checking those results. Transferred to the digital domain with its much bigger possibilities of manipulation, the majority suddenly doesn’t consider this a problem anymore. I made this experience beginning of February, when I was at the Transmediale in Berlin, Germany where I participated in a panel on ”Social Software.” An example basically matching the one given above was happily welcomed. Social software must be Free Software - only that way human rights can be maintained in an increasingly digital culture. So independent of the personal opinion on the sense of e-democracy, it is important that GNU.FREE does exist. So let’s get back to the technical issues. The system has been designed in a way that lets it scale well. Jason has been thinking of democracies the size in India (the biggest democracy in the world) - with GNU.FREE elections from small board elections to the elections for the European Parliament can be held. Of course the preservation of privacy and security issues had top priority during development and according to Jason, it does pretty well in these aspects already. If correctly configured, nothing short of a physical destruction of the servers by fire or other catastrophes could endanger an election and this would also be a problem for more conventional election systems. The project is relatively small for its rather big goals. Besides Jason there have been contributions to GNU.FREE by Rajagopal C.V., Thomas Muller, Ceki Gulcu, Neil Ferguson and Paul Voller. Help is needed and wanted especially for testing and finding possible security problems. The improvement of security through additional layers of encryption and bug-fixes is a constant goal of GNU.FREE. Besides this it is planned to implement different election systems as currently only a direct comparison between the amount of votes for certain candidates is possible. see you... Okay, that’s it for this month. As usual I would like to ask for lots of comments, ideas, questions and project descriptions under the standard address. ■
Info Send ideas, comments and questions to Brave GNU World column@brave-gnu-world.org Home page of the GNU Project http://www.gnu.org/ Home page of Georg’s Brave GNU World http://brave-gnuworld.org ”We run GNU” initiative http://www.gnu.org/bravegnuworld/rungnu/rungnu.en.html GNU-Darwin home page http://gnu-darwin.org Apple Darwin home page http://www.publicsource.apple. com/projects/darwin/ Why the APSL is not a Free Software license http://www.gnu.org/philosoph y/apsl.html get_file FTP address ftp://ftp.cs.duke.edu/pub/des/sc ripts/get_file GNU GLOBAL home page http://www.tamacom.com/glob al/ HeaderBrowser home page http://www.headerbrowser.org GNUTLS home page http://gnutls.hellug.gr/ GNU.FREE home page http://www.thecouch.org/free/ ■
8 · 2001 LINUX MAGAZINE 111