COMMENT
General Contacts General Enquiries Fax Subscriptions Email Enquiries Letters CD
01625 855169 01625 855071 www.linux-magazine.co.uk subs@linux-magazine.co.uk edit@linux-magazine.co.uk letters@linux-magazine.co.uk cd@linux-magazine.co.uk
Editor
John Southern jsouthern@linux-magazine.co.uk
Assistant Editor
Colin Murphy cmurphy@linux-magazine.co.uk
Contributors
Alison Davis, Richard Ibbotson, Jason Walsh, Steven Goodwin, Janet Roebuck, Lesley Dixon, Simon Naish, Bruce Richardson, David Johnson, Jack Owen, Jono Bacon
International Editors
Harald Milz hmilz@linux-magazin.de Hans-Georg Esser hgesser@linux-user.de Ulrich Wolf uwolf@linux-magazin.de
International Contributors Jan Kleinert, Frank Wieduwilt, Andreas Bauer, Andreas Jung, Björn Ganslandt, Georg Greve, Jo Moskalewski, Christian Perle, Stefanie Teufel Design
Advanced Design
Production
Rosie Schuster
Operations Manager
Pam Shore
Advertising
01625 855169 Carl Jackson Sales Manager cjackson@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) : £59.80 Rest the World: £77.00 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 Ltd, Europa House, Adlington Park, Macclesfield, Cheshire, England, SK10 4NP. Company registered in England. Copyright and Trademarks (c) 2001 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, emails, 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.
Current issues
CRITICAL MASS
P
laying with obscure operating systems you sometimes find a world-beating idea that is well thought out but sadly, in time, the project fails. Those that survive manage to do this by achieving enough support from users so that development continues. Suddenly the support reaches a stage where development starts to snowball. Linux development has been through this and it is now starting to show in retailing. Walking into a shop asking for Linux-compatible products is not high on my list of things to do for fun. But somewhere along the way it is beginning to sink in with retailers, who are realising that there is money in penguin products. Argos, the catalogue shop, is not someone who you would immediately think of to openly advertise a Linux product. Only one admittedly, but it is a start. Usually, I have to check the hardware compatibility lists before I go shopping but more and more manufacturers are saying that their products are supported. While browsing at a computer show in the centre of London within five minutes I managed to find a SCSI adapter, network card, motherboard, CPU, Graphics card, and hard drive that all stated they were Linux-compatible on the box. Most are manufactured in the Far East and that indicates either they have all just heard of Linux in the last few days or that momentum is building. In the coming year I expect we will find more products and all Open Source. Happy coding!
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.
Issue 17 • 2002
LINUX MAGAZINE
3
NEWS
LINUX NEWS Red Hat 7.2 for Compaq AlphaServers Compaq has announced that Red Hat 7.2 will be ported to the Compaq Computer Corporation’s Alpha processors. According to Paul Cormier, Vice President of Engineering at Red Hat: “Compaq’s AlphaServer platform is a popular RISC 64-bit platform in the Linux community, and Red Hat is glad to be continuing its long-time collaboration with Compaq with this upcoming release. We see this association as an integral part of our strategy to deliver capabilities for the most challenging computing applications in the enterprise and in high performance computing”. The release is expected to take place in the first quarter of the year.
New VP at MontaVista MontaVista Software, Inc. has appointed Cees Boshuizen as Vice President for the company’s European operations. An industry veteran with more than 25 years experience in hardware and software sales and management, Boshuizen has helped several American companies penetrate various international markets. He will be based at MontaVista’s European headquarters in the Netherlands and will report to Trent Winegar, MontaVista’s Vice President for worldwide sales. Prior to joining MontaVista, Boshuizen held senior sales and management positions with Sybase and EFI (Electronics For Imaging), both US companies. He has held assignments in the US and in various European countries with blue chip companies such as Digital Equipment Corp., Apollo Computer/HP and NeXT Computer. MontaVista Software, Inc. powers the embedded revolution by providing Open Source systems software solutions for embedded developers. Founded in 1999 by real-time operating system (RTOS) pioneer James Ready, MontaVista’s principal products include Hard Hat Linux, a Linux-based embedded source and binary distribution and cross development platform and a set of tool kits for x86/IA32, PowerPC, StrongARM, MIPS, SH, ARM, XScale and other microprocessor architectures.
6
LINUX MAGAZINE
Issue 17 • 2002
“Compaq is committed to coupling our highavailability AlphaServers systems and industrystandard ProLiant servers with leading software, such as Red Hat 7.2, to offer our customers a broad range of server and software solutions that support the right Linux operating environment for their business,” said Bill Blake, Vice President of High Performance Technical Computing for Compaq Computer Corporation. “Red Hat Linux 7.2 delivers the latest kernel enhancements for performance and stability valued by the high performance cluster customers that run Compaq’s AlphaServer-based Linux clusters”.
Open Source not fully exploited in UK Open Source technologies should soon be able to stand shoulder to shoulder with their more restrictive brethren as a result of the UK’s Department of Trade and Industry report “Open Source: the UK Opportunity”, for which we are indebted to the National Computing Centre for their efforts. The report provides a uniquely authoritative and independent overview of the issues surrounding Open Source Software (OSS). It details the views expressed by IT professionals on the future of, and the opportunities offered by, Open technologies and identifies actions necessary to convert potential business benefits into reality. The report records heightened interest in OSS in light of recent increases in proprietary software licence costs. Current use of OSS is patchy and the potential benefits are not being fully exploited. There is much work to do before OSS becomes a viable alternative to packaged software products. Respondents who come from a crosssection of UK industry sectors identify their prime concerns as: ● Uncertainty over what Open Source actually is. ● Uncertainty over support and what the risks are. ● Lack of clear marketing positioning for Open Source products ● Difficulties in identifying the right OSS for a given requirement NCC believes the UK would benefit greatly from the establishment of a stable alternative to the use of proprietary software, both in terms of business effectiveness and competitiveness. NCC are already engaging with users and government and given that they have a “not for profit” status and expertise, it is hoped that they are ideally placed to turn these suggestions into reality.
NEWS
Physics for Game Developers Physics-based realism is not new to gaming; in fact, many games on the shelves these days advertise their physics engines. By applying the laws of physics – specifically mechanics – game developers can realistically model nearly anything that moves to create compelling, believable content for computer games. David Bourg’s new book, Physics for Game Developers, uses the example of designing a hunting game, complete with first-person 3D, beautiful textures, and an awesome soundtrack to set the mood. According to Bourg, knowledge of physics-based realism will be crucially important for programmers who want to compete in developing ever more sophisticated games.
Red Hat Certified Engineer program takes first place Red Hat is proudly telling the world that their Certified Engineer (RHCE) program received first place rankings in three out of eight quality categories in Certification Magazine’s January 2002 Salary Survey. In five other categories RHCE ranked in the top three programs in IT, making RHCE the quality leader overall in the survey. In the survey, conducted by Fairfield Research, Inc., nearly 4,000 IT professionals were asked to rate their training and certification experiences in terms of quality of learning materials, instructors, comprehensiveness of programs and related tests, overall educational quality, perceived price and value, quality per dollar, and overall quality. The 2002 rankings for quality are just the latest in a series of independent reviews and surveys released by Computer Reseller News, CertCities, Certification Magazine, and TechRepublic, all of whom rank RHCE as one of the top 10 IT certifications for quality, value, salary increase, and/or level of interest among IT professionals. “For the RHCE program to receive the most top rankings and place first for overall quality in only its third year of existence is an enormous accomplishment,” said Pete Childers, vice president of global learning services at Red Hat, Inc.
8
LINUX MAGAZINE
Issue 17 • 2002
“It’s important for game developers to realise that there is an awful lot of information available that will help them add physics to their games,” Bourg explains, “but this information won’t necessarily be found in ‘traditional’ game development
sources. Sure, you can scour the Internet, trade journals and magazines for how tos or fish out an old physics text and start from scratch, but you’ll likely find that the information is too general to be applied directly or too advanced.” In Physics for Game Developers, Bourg pulls together the information game developers need to enrich their games’ content with physicsbased realism, but don’t know where to start. For more information visit http://www.oreilly.com/catalog/ physicsgame. Author Publisher Price ISBN
David M. Bourg O’Reilly £18.50 0-596-00006-5
XFree86 4.2.0 is out XFree86 4.2.0 is the fifth full release in the XFree86 4 series. XFree86 release 4 is a major re-design of the basic architectural underpinnings of XFree86’s implementation of the original X Consortium’s Xserver. This redesign allows for a modular interaction between the hardware drivers and the XFree86 core X server. With 4.x, upgrades to the Xserver with new and unsupported hardware can be easily done and installed without undergoing the previous process of rebuilding an Xserver. All that is required is installing the new driver module and updating the configuration file. The road to XFree86 release 4 began as an architectural concept in mid-1997, with the serious framework being implemented in code in the beginning of 1998. There were several snapshots on the road to 4.0, which are now part of the 4.0 base release. The 4.2.0 version is an upgrade to 4.1.0, which include more hardware ports, code enhancements and bug fixes. While some driver available in the old 3.3.x release series have not been converted over to the 4.x series, those required for most modern video hardware are available. Further video driver enhancements include support added to the ATI radeon driver for Radeon 7500 (2D and 3D), Radeon 8500 (2D only), and Rage128ProII, support added for the Matrox G550, including dual-head support and the nVidia nv driver now has preliminary powerpc support for the NV11 and NV20. Input driver enhancements include replugable mouse events for PS/2 mice, USB keyboard access is fixed when no PS/2 controller is present and added support for calcomp, DMC and hyperpen input devices. See http://www.xfree.org/4.2.0/.
NEWS
Embedix in bed with Motorola
Lineo, Metrowerks and Motorola Broadband are to join forces and form Triarc Content Labs, which will help with the design and development of Linux-based, advanced-interactive television software applications on Motorola’s DCT5000 family of advanced-interactive digital set-tops. Contributing to the joint venture, Lineo will provide its Lineo Embedix Digital Media core: an embedded Linux system software platform for settop terminals that enables delivery of advanced interactive digital content. Metrowerks will supply CodeWarrior development tools, which are widely used in the wireless and consumer products industries to create applications and content. Motorola, in addition to its DCT5000 family running the Embedix platform, will also provide its expertise in advanced-interactive digital cable technology, systems integration, and deployment. The companies are forming Triarc Content Labs to provide the broadband industry with an independent source for development, testing and integration of Linux-based content and applications. This resource is expected to speed time-to-market of new and interactive services such as pay-per-view (PPV), video-on-demand (VOD), games, Web browsers, program guides, personal video recorders (PVR), home networking and streaming media. “The broadband industry is migrating toward Linux as the software platform for games, interactive content, programming guides, personal video recorders and video on demand,” said Matthew Harris, CEO of Lineo. “Content and application providers require seamless compatibility between their products and the Lineo Embedix Digital Media core integrated with the Motorola DCT5000 family. Triarc will have the expertise to facilitate the development of robust solutions in this environment, thereby ensuring a user-friendly and feature-rich offering for the cable operator”. Triarc Content Labs is expected to be operational in mid-2002. Additional information about Triarc Content Labs and availability of products and support will be released later this month. Customers interested in receiving immediate information may send an email to info@triarclabs.com.
Issue 17 • 2002
LINUX MAGAZINE
9
NEWS
Logical PARtitions in practice Churchill China, plc. recently entered the world of e-commerce with Wizz400. Their customer-focused system has been a great success and will now be significantly extended. Wizz400 will run in an LPAR environment (Logical PARtitions), dynamically interacting with Churchill’s ERP system, behind a Linux firewall on a new iSeries model 820, supplied by Byford. All three elements will run under the covers of one iSeries server. Demonstrating its product quality and customer service, Churchill China has added a licence to produce Warner Brothers Harry Potter chinaware. This follows Jeff Banks’ Ports of Call, Looney Tunes and Tom & Jerry; the Royal Horticultural Society; and Historic Royal Palaces. Churchill China has always invested in information technology believing this to be a key factor in managing the business and meeting customer expectations. To meet these challenges the company needed a robust and scalable e-commerce and e-supply chain management system – and chose Wizz400.
Churchill China has already delighted its trade customers with an innovative CRM system built with Wizz400. The new project will support: ● Trade outlets placing orders directly into Churchill’s systems via the Internet, whilst allowing monitoring and visibility by the customers’ central purchasing departments. ● Credit card processing. ● XML document exchange for orders, invoices, and other documents that require interaction with the Customer. According to David Garnett, IT Director of Churchill China, “Wizz400 is very powerful and very closely integrated into our existing systems. The key factor in e-commerce is accuracy. We offer 24-hour delivery and Wizz400(tm) on iSeries guarantees that we get orders right every time”. A unique feature of the new installation is the use of a LINUX logical partition to run the firewall. LPAR allows separate applications to use the full resources of the iSeries, and therefore eliminates the need for multiple servers. Churchill has consolidated down from three servers to a single IBM iSeries.
DaimlerChrysler choose AMD-based Linux cluster DaimlerChrysler AG has implemented a server powered by the AMD Athlon MP processor 1800+ in its Mercedes-Benz Technology Center (MTC) in Germany. The company uses the strength of several hundred AMD Athlon MP processors in one of the largest high-performance Linux clusters in the German automotive industry, to run state of the art crash simulations for Mercedes-Benz vehicles. DaimlerChrysler’s crash simulation team selected the AMD Athlon MP processor-based solution because it delivers superior performance and stability on single and dual processor-based servers for enterprise class applications. The AMD Athlon MP processor is a seventhgeneration x86 processor designed for highperformance multiprocessing servers and high-end workstations. A key advantage of AMD’s multiprocessing platform is Smart MP technology, which greatly enhances overall platform performance by increasing data movement between the two 10
LINUX MAGAZINE
Issue 17 • 2002
CPUs, chipset and memory system. Smart MP technology features dual point-to-point, high-speed 266MHz system buses with Error Correcting Code (ECC) support designed to provide up to 2.1Gb per second per CPU of bus bandwidth in a dualprocessor system. “We evaluated many solutions and concluded that the AMD Athlon MP processor-based server was the best choice in terms of performance and stability,” said Dr. Johannes Luginsland, Manager of IT infrastructure for Safety and Comfort Simulation, DaimlerChrysler. “The AMD Athlon MP processor’s extraordinary floating point capabilities coupled with AMD’s Smart MP technology deliver the superior performance we need for missioncritical supercomputing. Shortened product development processes made possible by gains in computer aided engineering require increasingly demanding simulations that must be carried out in less time. This demands the appropriate computer processing capability”.
NEWS
SuSE Linux Enterprise Server 7 for Itanium SuSE Linux Enterprise Server 7 for the Intel Itanium Processor Family is now available. Described as having high scalability and extreme failsafe features, this is a product that should be considered as a choice for mission-critical applications. In addition to an operating system optimised for stability and security, this mature server solution provides all server services relevant under Linux. Systems based on Itanium processors are designed for use with high-profile applications in the enterprise or the technology sectors that require maximum performance. This includes the management of large databases as well as complex e-commerce transactions or scientific/research applications that consume massive amounts of computing power. The development of the SuSE Linux operating system for the Intel Itanium processor family was a process that started a long time ago. Over a period of 30 months, SuSE developers and Intel engineers, who provided the latest prototypes and hardware specifications, worked on this Linux version. As a result, in May 2001 SuSE was the first Linux provider to present a Linux solution for application developers that enabled rapid ports of application software to
the 64-bit platform. “The close technological collaboration between SuSE and Intel started more than two years ago and goes back to the early stages of Itanium Processor development,” said Steve Chase, Director Business and Communication Solutions, Europe, Middle East and Africa at Intel Corp. “Through SuSE Linux Enterprise Server 7 for IPF, enterprise customers benefit from a technologically trend-setting complete solution, in which hardware and software are perfectly tuned”. “Our cooperation with Intel is based on the joint goal of providing professional users with the best solutions for mission-critical deployment,” added Gerhard Burtscher, CEO of SuSE Linux AG. “We will continue to pursue this objective in the future and further intensify our joint projects”. SuSE Linux Enterprise Server 7 for IPF is based on kernel 2.4.7 and the program library glibc 2.2.4 and includes XFree86 4.0.3. The Logical Volume Manager, the journaling filesystem ReiserFS, and Large File System Support comprise part of the package that could be considered as a platform for mission-critical e-business transactions.
Creature comforts Linux Game Publishing, which aims to bring top quality Linux games to the market by providing reseller channels for games ported to Linux, as well as for games especially written for our favourite OS, is well on the way to distributing Creatures Internet Edition, which includes both Creature 3 and the Creatures Docking Station expansion. LGP were also pleased to tell us that they have recently signed a deal with Cyberlore Studios in which they obtained the rights to complete a Linux version of Majesty, along with its expansion pack, The Northern Expansion. Majesty is a groundbreaking Fantasy Kingdom Simulation, which won several awards with the Windows 2000 version. The game sees you as the leader of a medieval kingdom, which you must defend from rampaging magical creatures and entice heroes to join your cause. Unlike other games where you simply control what happens, in Majesty you have to make your minions WANT to do what you ask! [A bit like me and a Shell prompt – Asst. Ed]. For more information see http://www.linuxgamepublishing.com.
Another hat thrown in the ring From the house of PomPom comes Space Tripper, described as “the ultimate” [what, another one – Ed.] in shoot-em-up arcade action, is now available for Linux. With more than 10 years experience in the games industry, PomPom feel that the time is now set for the re-emergence of classic games, where playability not complex plots are the order of the day. Retro gameplay is on the way back! Space Tripper takes for its inspiration Williams’ Defender – a classic in a league of its own. The delicate gameplay of Defender is brought bang up to date with exotic enemies and diverse environments, visualized in a state-of-the-art 3D engine. Check out PomPom and Space Tripper at http://www.pompom.co.uk/. Issue 17 • 2002
LINUX MAGAZINE
11
GNOME NEWS
GNOMOGRAM
GNOME BASE ALPHA This month Gnomogram looks at the alpha version of GNOME 2, news from the GNOME foundation, Ximian ISO images, Mozilla’s new licence, Ximian’s recruitment drive, Gtranslator and GWCC
GNOME 2 Platform Alpha After much hard work the first alpha version of the GNOME 2 platform was finally released at the beginning of October. This release was just the first chapter in the GNOME 2 story, and offered developers the chance to become familiar with the new platform, and to port their programs. With a bit of luck, GNOME 2 should be completed by midFebruary (around the time you’re reading this), which will mean it follows close behind KDE 3.0. The alpha version is not yet user-compatible, since only the second platform alpha can be installed completely parallel to GNOME 1.4.1; and nor are there any usable programs of any kind yet. What’s new about the GNOME 2 platform is of course GTK+ 2, which offers anti-aliasing and – via Pango – better support for exotic fonts. With ATK a framework for a disability-friendly interface will also be introduced. Many libraries have been split up and can now be used independently of the actual interface. Together with the new libraries, for XSLT or packet configuration for example, this does not necessarily contribute to the clarity of the platform, which is still problematic. Other parts of the platform, such as Bonobo, Gconf, the XML-il8n-Tools and OAF, should all be familiar to users of Nautilus or Evolution, even if OAF has changed its name to Bonobo-activation, and the XML-il8n-Tools will in future be known as Intltools.
The majority of the work will now be in porting and stabilising the GNOME programs on the new platform. A few big innovations to do with the GNOME programs are still outstanding for the time being, so the completely new panel will probably be dropped on the grounds of time. There should be more features in GNOME 2.x, which leaves hope for more regular releases.
Ximian ISO images All those who find it too fiddly to convert their distribution to Ximian will be pleased to note that http://www.cofradia.org has ready-converted ISO images of the most popular distributions. At the moment only Red Hat 7.1 + Ximian is available, under the name XR. Mandrake and Debian versions are currently being worked on.
Mozilla under new licence Originally Mozilla was largely distributed under the non GPL-compatible MPL licence, and the somewhat less Free NPL. This rapidly led to problems, as some GPL programs were built on Mozilla and thus infringed the GPL. In the case of Galeon, for example, this led to an addition to the GPL, which exempted Mozilla from some restrictions.
Libraries needed Gtranslator: Gal >= 0.11.99, Gconf >= 1.0, Gnome-VFS >= 0.4.1, Scrollkeeper >= 0.1.4 GWCC: Standard GNOME libraries only
News from the GNOME Foundation Now well into its second term, the GNOME foundation is developing a draft of new policies, clarifying who gets space on the GNOME Web site at http://www.gnome.org, for example. In future, even those who are not collaborating with GNOME
12
LINUX MAGAZINE
Issue 17 • 2002
will be able to put their names on the GNOME site. To do this Tim Ney has initiated the donor program “Friends of GNOME”, under which donations, depending on their amount, will be awarded with little gifts.
GNOME NEWS
Netscape has now decided to place Mozilla under three licences, namely MPL/GPL/LGPL or under NPL/GPL/LGPL, which solves the licence problem for many GNOME programs. This relicensing was relatively simple in the case of the NPL, since this already contained a clause allowing Netscape to relicense. For the MPL, the agreement of all developers involved was necessary, which is why it can take somewhat longer. To make the licensing chaos complete, there are still some files in Mozilla under BSD licences, but since these are compatible with the GPL they are not being changed. The problem with this scheme is that the NPL continues to exist as part of the threefold licensing. In the long run, according to http:///mozilla.org, there are plans to replace this with the MPL.
Ximian continues to recruit Ximian has expanded its management with two new additions, namely Mitchell Karpor and Kevin Harrison. Both bring a wealth of experience to the team, particularly Karpor who has worked for both Lotus and Personal Software Inc., the distributor of Visicalc, and is co-founder of the EFF. Harrison occupies the post of Sales Vice President and it is intended that he will be working on gaining new markets for Ximian’s service products. Karpor has a seat on the board of directors of the company.
Gtranslator The translation of a GNOME program can be one of the most important factors in its user friendliness. Luckily, the many translators don’t have to search for and capture whole character strings in the source text, since a program named xgettext takes over this task and extracts all strings marked by the programmer into a pot file. Each translator can then copy this file, rename it and fill it with translations – the name for an English translation file, for example, would be en.po. These .po and .pot files must of course be synchronised at regular intervals, which in addition to untranslated sections of text, can lead to “fuzzy” translations. The idea of Gtranslator is to edit the .po files thus produced. The practical thing about this, for new translations, is that Gtranslator can try to complete the file with the aid of existing translations from other programs. Gtranslator also refers to “learned” translations via a UMTF file. This file is filled during translation and/or via the command gtranslator -nl name.po from an existing .po file. You can also find some readymade Learn-Buffers on the Gtranslator homepage, which make it easier for beginners to avoid colliding with existing translation conventions. Another useful feature is that Gtranslator can sort the individual character strings according to their status and the file head is automatically completed with the translator’s data. The program Pozilla, which comes with Gtranslator, is intended more for program maintainers. Translators can use this script to find out in advance about releases and thus have the opportunity of delivering on schedule.
GWCC The GNOME Workstation Command Center – GWCC for short – is a front-end for a whole range of command line programs, which enables their outputs to be saved and printed. The respective options of these programs can be changed, which is especially advantageous for newbies. The GWCC is organised in a number of tabs and shows the system status from the main memory to network interfaces. It also enables the use of the standard network tools traceroute and dig. As with top, one can also select and abandon processes from a list. GWCC also supports searching within the process list, as with ps | grep.
Figure 1: There is a free choice of colour schemes for the Gtranslator editor
Info GNOME release schedule The GNOME Foundation gnome.org account policy Ximian ISO images Mozilla homepage Mozilla relicensing FAQ Ximian homepage Gtranslator homepage GWCC homepage
developer.gnome.org/dotplan/schedule foundation.gnome.org/membership-policy.html primates.ximian.com/~federico/docs/gnome-org-policies/ uuxii.cofradia.org www.mozilla.org www.mozilla.org/MPL/relicensing-faq.html www.ximian.com www.gtranslator.org gwcc.sourceforge.net
Figure 2: GWCC also displays system information
Issue 17 • 2002
LINUX MAGAZINE
13
NEWS
K-splitter
SAFE & FREE Stefanie Teufel takes
Better safe than sorry
a look into the latest
IT security experts are increasingly devoting themselves – and their hardware – to email security, and now it seems that KDE is joining the party. A new project has been launched to develop Free software components for email encryption. The contract for this project was awarded to three well known Open Source companies, namely g10 Code GmbH (Werner Koch), Klarälvdalens Datakonsult AB (Kalle Dalheimer) and Intevation GmbH (Bernhard Reiter), who are to work together on creating the basis for the initiation of free email programs. Kalle Dalheimer in particular may be a familiar name to one or two of you, as one of the KDE pioneers. Specifically, the popular applications mutt and KMail are being expanded within the newly set up project. In particular, OpenPGP initiation and the address book of KMail are earmarked for improvement. The expansions will obviously be released under the GNU GPL. Interested developers can find out at http://www.gnupg.org/aegypten about the progress of the project. The results should be in by CeBIT 2002 at the latest.
happenings in the world of KDE and shines a spotlights on some new projects, new prizes and new splash-screens
Yet more prizes No K-splitter comes without new prizes for KDE. In the readers’ poll for the “Linux New Media Award 2001”, Konqueror and KDevelop left the competition standing in the categories “Best client’s Open Source software” and “Best development software”. The two programs respectively won over 47 and 45 per cent of the Linux User and Linux Magazine readers and the Linux community who took part in the vote. The readers of “Linux Journel” also had their say. In the “2001 Readers’ Choice Awards” a number of KDE applications made it to the winners’ podium. The KDE project itself swept to a landslide victory in the category “Favourite Desktop Environment”. Second place prizes went to Koffice, in the category “Favourite Office Suite”, and Kmail, for “Favourite Email Client”. Third prizes were won by Kdevelop, in the category “Favourite Development Tool”, the Konqueror, in the field of “Favourite Web Browser”, and Kword, for “Favourite Word Processor”. Many congratulations. 14
LINUX MAGAZINE
Issue 17 • 2002
Figure 1: A real rogue
No playing around The newly-founded KDE project “KDE Edutainment” wants to prove that learning can be fun, too. The aim of the project is to produce educational software based on the KDE platform, thus making up for the shortage of child-oriented software under Linux. The plan is to integrate the kdeedu module into future releases of KDE. Anyone who doesn’t want to wait for that, but wants to show their younger relatives right now how entertaining it can be to work on a computer, should surf as fast as they can to the site http://edu.kde.org. The makers are currently offering over a dozen applications for download, including: KHangMan (Figure 1), a game whose name is self-explanatory; KEduca, with which multiple-choice tasks can be created and tested; KLatin, a training program for Latin; KLettres, a French language program for very young children; KTouch, with which little ones can practise tenfinger typing; KMessedWords, where one has to sort out letters to find the correct word (Figure 2); and KGeo, is an interactive Geometry program (Figure 3). The site operators are also eagerly seeking more support. If you would like to make some kind of contribution, an email to kde-edu@kde.org is all it takes. If you would like to keep up to date with the progress and problems of the project, you can subscribe to the two newly-created mailing lists
NEWS
Figure 2: Your own dialogs are the nicest
Figure 2: Nicely sorted
this you can change the greeting image (via the Splash Screen tab) and also the icons (by means of the Icons tab) at the click of a mouse.
Faked If your boss wants you to use NT, but you would rather continue working with your Linux box, then help is on the way. At http://www.shadowcom.net/ Software/kss/kcad you can find a new screensaver named KCAD (Control-Alt-Delete), which should help you fool your boss without too much effort (see Figure 4).
Figure 3: Going round in circles
http://mail.kde.org/mailman/listinfo/kde-edu and http://mail.kde.org/mailman/listinfo/kde-edu-news.
A sight for sore eyes If you’re looking for fun and games for a slightly older audience then look no further than the new site http://www.kde-look.org. Everything you need to make your own desktop twice as colourful can be found here. Even those who want to alter the KDE welcome screen will find something to please. To do so, simply download the KSplash packet http://www.kde-look.org/content/files/230-ksplashml0.20.tgz, which, after installation, replaces the program originally responsible for the splash-screen. After the usual ./configure make you should always first make a back up copy of KSplash, before you swap it with a make install. You can easily find out in which directory the KSplash binary is located on your computer with a which ksplash. The new splash screen is configured via the KDE control centre, where you will find the new entry “KDE Splash Screen” under the Display item. With
Anyone who wants to play safe should make the following entry in the file $HOME/.kde/share/ config/kcad.kss:
Figure 4: Sometimes appearances can be deceptive
[Settings] NtLike=1 According to the author, this will fool even the most suspicious of managers.
KDE Edutainment Some of the Edutainment packages have been included on this month’s coverdisc.
Issue 17 • 2002
LINUX MAGAZINE
15
FEATURE
SuSE training
START AT THE BEGINNING I’ve you ever wondered what goes on at Linux training courses then wonder no longer. Lesley Dixon fills us in on what goes on behind closed doors
A
s a relative newcomer to Linux it was with some trepidation that I enrolled on the SuSE Linux For Users course at Computer Park Ltd. This is a three-day course with the aim of introducing the beginner to Linux, including applications such as word processing, spreadsheets and presentation packages, and to give an insight into file and directory structures on both local and networked systems. No previous knowledge is required for this course although some experience of using a personal computer is obviously helpful. The company also offers a general Linux For Beginners one-day course, which covers the basic use of the programs, but I felt that this might not give me the time or practice I needed to come to grips with an entire operating system. Computer Park Ltd. has been running courses since 1982 and so has plenty of experience in training. They do courses covering standard
PC applications, such as Excel and general personnel skills such as time management, as well as the Linuxbased courses. Although the course is specifically tailored to SuSE Linux most of the content can be applied to other distributions and so the course is worth considering even if you have decided not to use SuSE. The site, at Broughton Grange near Kettering, is picturesque, if a little off the beaten track. Lunch and coffee breaks are taken in a large conservatory with stunning views over the countryside – perfect to relax in after a morning struggling with programming. Lunch was also excellent though I had to be careful not to eat too much and fall asleep in the afternoon session!
Absolute beginners The course opened with a brief overview and history of Linux and then moved on to the file structure and how to login to a session. Much of the course concentrated on the command line and only covered the graphical interface as a specific topic. This was quite a shock to my system as the last time I can remember typing commands was in the late 1980s 16
LINUX MAGAZINE
Issue 17 • 2001
FEATURE
an a BBC computer at school. Although the tutor was very helpful it did strengthen my conviction to stick to a system with a good graphical interface and not to go wandering off into the realms of more command-led programming. Having started us off gently enough we then dived into the filesystem, learning how to navigate directories, how to create files and how to change permissions to enable others to read them (or not). Once we could create files we were shown the use of vi, as an example of a text editor, and learned how to generate text files. Other text editors were only touched upon briefly, due to the pressures of time, but I was not left a convert to vi! At the end of each topic we were given time to work through the exercises given in the course manual, so we were able to practice what we had learned – something I find necessary to prevent information from going in one ear and out the other.
A little variety Over the next couple of days we went on to cover a wide range of subjects, many using the networked computers to send files to each other. We learned how to search files, print them, redirect them and work on a remote computer. We also learned about printers, CD-ROMs and floppy drives. Various applications were covered for word processing, spreadsheets and presentations, Due to the small number of people on the course we were able to deviate from the manual from time to time and concentrate on a topic which one of us considered to be useful to them. In my case we were shown how to transfer files to and from a Windows system and how the various applications compared to their Windows equivalents. With a different set of students they could cover quite different questions depending on their particular needs. Although I was very happy with what was taught on the course I was slightly disappointed not to have more practice in Xwindows, as that’s what I will probably be using. However I do realise that it is necessary to understand the underlying processes before taking the easy option. I would have liked to have used GNOME and been shown around that and similar programs but I realise that would be a course in itself.
Waving, not drowning The topics covered were dealt with in enough detail to give us confidence but not so much that we were swamped with unnecessary detail. Once or twice we strayed onto subjects that the tutor admitted were from the systems administrator course but he felt it was necessary for us to understand the background and it was relevant to the work that some of the students were doing. A few times I felt my eyes glazing over as the topics became very technical, but
fortunately we soon returned to subjects on my level and I did not feel as if I was drowning for very long. All of the subjects were covered in sufficient detail that we felt confident in them by the time the course was over. There was enough time allowed in the course that we could take the time to practice what we needed. Fortunately because of the small number of students there was ample time to spend on whatever we needed to and we were able to finish early every day, which would be a help if you were commuting daily as Kettering is a fair drive from most places. I stayed overnight and was able to find a very comfortable B&B. The number of people on the course is kept small so that individual needs can be met. The staff at Computer Park are very friendly and happy to help whenever necessary. They will also tailor-make courses for companies if they do not already do a suitable one. The set of networked computers runs the latest version of SuSE, in this case 7.3, which had only just been released. This led to a few problems when the files needed to demonstrate functions had been moved to different locations and so had been omitted from the install. My advice would be to try not to go on the course just after a major version update but to let it sort itself out first and find all the bugs before hand. These teething troubles aside, the course was competently run with an effort to maintain interest for the full three days. Time and effort was spent on ensuring that we were all happy with what we had learned. At the end of the course I felt confident that I would be able to navigate my way around SuSE – and by way of extension, any version of Linux. Although I was disappointed not to have used Xwindows more I was ready and eager to go home and put my newfound skills to the test. As an introduction to using Linux the course is to be recommended and if you have not already committed to a distribution then you will be converted to SuSE by its breadth of coverage and value for money. Issue 17 • 2001
The number of people on the course is kept small so that individual needs can be met
LINUX MAGAZINE
17
FEATURE
Office of the Future
STAROFFICE 6.0 FIRST IMPRESSIONS The integrated desktop is gone and many new functions have been added, while others have been improved. Jan Kleinert takes a closer look at Sun’s shining star
D
o we really need Office packages under Linux, when we already have Emacs and TeX? Engaging in this debate gets you about as far as discussing the pros and cons of abstract art. When it comes down to the crunch, you can use Linux applications to perform all office functions without needing to resort to using an office package. However, those who want to expand the quantitative usefulness of Linux as a desktop operating system should welcome applications such as StarOffice. Sun, the manufacturer of StarOffice, hopes that it’s latest incarnation, version 6.0, will be given a warm welcome when it’s launched on the market later this year. At the time of its release, the previous version (5.2) will be pushing the one and a half years old mark. StarOffice is now based on the LGPL project OpenOffice.org, which was started up by Sun in October 2000. Sun brought in approximately nine million lines of additional source code and places increased value on the openness of API and file format (XML). This brought the project another license: the Sun Industry Standard Source License (SISSL). The only advantages the bought StarOffice 6.0 will have over the freely downloadable version will be the non-Open sections such as dictionaries and the database (and at present all language Star Office 6.0 Supplier License Price
Sun Microsystems Not Free Download version free of charge, CD-ROM with manual probably 50 euros Web: http://www.sun.com/staroffice/6.0beta Requirements Pentium (compatible) CCU, 64Mb RAM, 300-500Mb free disk space, Kernel 2.2.13, Glibc2 2.1.2 Current status: Beta, final version second quarter 2002 Alternatives OpenOffice.org, Corel WordPerfect Office 2000, Abi Word, Koffice
rating
18
LINUX MAGAZINE
Issue 17 • 2002
The install is underway.
modules except English). For our test we used the official StarOffice 6.0 Beta version and a Sun internal beta version.
No unpleasant surprises The installation of StarOffice 6.0 is similar to the previous version. In the simplest case, i.e. for a single station installation, the ./setup file must be called up. For the multi-user installation, which is usually the most sensible for Linux systems, ./setup net is used as root. It can be assumed that rpm and deb packages will also be included in future distributions of StarOffice 6.0. The CD version of StarOffice 6.0 contains extra language modules, in addition to the dictionaries contained in the download installation package. Sun states its installation requirements as a Pentium-compatible PC with 64Mb RAM, a 2.2.13 or higher kernel and a glibc2 of version 2.1.2 or better. As with all the earlier versions, it is advisable to really bulk up on RAM. StarOffice 6.0 can also be installed parallel to an older version. If StarOffice 5.2 is installed on the system, the 6.0 installation
FEATURE
Figure 3: After each user has entered his or her contact details, the setup program looks for a suitable Java environment
Figure 2: User details, most of which is optional
program offers the possibility of migrating all your existing data. The program’s setup is done with a graphic interface Wizard. The multi-user installation uses the home directory of the installer, i.e. root, as its target. This specification was inherited from the previous version. Copying the files onto the hard drive took barely three and a half minutes in our test and took up 310Mb of disk space. The next task is to install the relational Adabas D 11.0 database, included in the StarOffice CD. This is either executed automatically in the course of the StarOffice installation or started manually by the administrator under ./adabas. You will need to specify a sensible installation target, wait one and a half minutes for the 60Mb to install. This is without doubt a rather basic version of the program, with three parallel database connections and a maximum database size of 100Mb being the limits of this single user database.
One workstation installation per user As with earlier versions, a workstation installation is required for each user. This is done per user by starting StarOffice-directory/program/setup. After each user has entered his or her contact details into a template (see Figure 2), the setup program looks for a Java environment suitable for StarOffice 6.0. If nothing is found or successfully verified, the Install button helps with setting up the Sun Java runtime files (see Figures 3 and 4). When starting the actual application for the first time you will be confronted with a Wizard, which enables you to import existing address data. In addition to supporting Netscape and Mozilla address books, the program also now supports LDAP addresses. With a minimum of manipulation, contact data from dBase, Adabas or ODBC sources can also be imported.
No integrated desktop After the installation has been completed, the uninitiated may look for StarOffice in the window
Figure 4: If not previously installed or successfully verified, the Install button will then try to set up a Sun Java runtime
manager of their choice. However, this search will be to no avail. The reason for this is that Sun has abolished the integrated office desktop, which the Star division marketed as an outstanding feature in its time. Sun justifies this omission as following the wishes of its users, however it would have been nice to be given the individual user the choice of whether or not to use this feature. A more serious omission is that of the date planner, which in earlier releases even had the ability to organise group dates. Sun is allegedly working on a replacement for this feature. What you will find the in the StarOffice 6.0 menu of KDE or GNOME are: StarOffice Writer (text documents), StarOffice Calc (tables), StarOffice Impress (presentations), the HTML editor (HTML documents) and StarOffice Draw (drawings). In addition to these are the submenus Autopilot (various wizards), Information and set up (StarOffice and printer setup) and Others (for label and business card creation, the formula editor and global documents).
Mainstays: Writer and Calc Users who have migrated from Microsoft Office will have no problems getting up to speed with the menus (and tool bars) of Writer and Calc. The tools cannot be torn off and repositioned, however some tools fold out into secondary tool bars. Sun has done a particularly good job with the menus for formatting characters and paragraphs in Writer. These were comparatively clear, if not clearer, than those in the latest Microsoft suites. In our tests the Margins, Spacing and Initials register cards were Issue 17 • 2002
LINUX MAGAZINE
19
FEATURE
Figure 5: One new function is the possibility of rotating text
which better facilitates the import of complex Excel files. One highlight is the ability of Calc 6 (like Excel) to embed external data from the Internet, which is then automatically updated – particularly practical for stock market data, for example. A small window has replaced the annoying help assistant that popped up in Star Office 5.2 at every possible opportunity. Mr. Help greets us now only from a distance and after a while of not being used, quietly disappears again.
Graphically: Impress and Draw particularly pleasing. Writer has also made new innovations in font special effects that place very high demands on the font management of monitors and printers. Writer can now rotate text 90 degrees (see Figure 5), control kerning and execute various other font special effects like interrupted underlining. The Writer beta test also offered the opportunity to check the automatic re-creation function after a program crash. It works – with exception of the last typed entry – the open text document was saved. Calc has received many new arithmetic functions,
Table 1: Comparison of loading times and file sizes of Star Office Starting application Desktop Writer Calc Impress
Star Office 5.2
5.2 and 6.0 Beta (1) Star Office 6.0 Beta
27s 5s 3s 5s
N.A. 35s / 9s (2) 36s / 7s (2) 36s / 9s (2)
File size: StarOffice files SDW/SXW 724Kb SDC/SXC 120Kb SDD/SXI 93Kb
746Kb 11Kb 31Kb
Loading time: StarOffice files SDW/SXW 5s SDC/SXC 7s SDD/SXI 8s
3s Crashes 7s
Import of MS Office files DOC (126Kb) 7s XLS (16Kb) 16s PPT (61Kb) 2s HTML (76Kb (3)) 3.5s
9s 23s 1.5s 8s
The presentation program Impress has not been substantially developed, which is not necessarily a bad thing. With its many effects (such as fading in and out), useful templates and a Draw toolbar, you’re not likely to be stuck for options or ideas for that critical presentation. Draw is highly useful, whether as an independent drawing program or within another application. It possesses all the most important graphic tools and can offers rudimentary support for layers. It’s not in the same league as Corel Draw but can deal with the design of letterheads or simple overview diagrams (both typical office applications) effectively and with ease. You may have noticed that at first glance, a pixeloriented graphic program seems to be missing. Upon closer inspection we discovered that this is not the case. As soon as you insert a picture into a document – it doesn’t matter in which StarOffice program – and click on it, the lower, context-sensitive toolbar transforms into a raster graphics toolbar (see Figure 6). A second bar is hidden behind the triangle button on the right.
Adabas D As we mentioned above in the Installation section, StarOffice 6.0 again features the relational SQL database Adabas, from the German Software AG. Those who already have Adabas 11 on their system need not update this. To create a new database for StarOffice conditions
Footnotes (1) tested on Celeron 450 MHz, 196 MB RAM, Matrox Mysique, Mandrake (2) Star Office 6.0: Loading time from scratch / loading time when another Star Office application had been started and quit (3) HTML document contained 9 files.
20
LINUX MAGAZINE
Issue 17 • 2002
Figure 6: When you click on a picture, the lower, contextsensitive tool bar transforms into a raster graphics toolbar
FEATURE
Figures 7 and 8: In version 5.2, subsequent modifications to links did not change their functions. This bug has now been eliminated (right)
you’ll need to access the Tools/Data sources/New data sources menu from within any of the StarOffice applications. Under Database type, the user can select between several database types and interfaces. Besides Adabas and the simpler dBase-compatible Star database, ODBC, JDBC, Address book, Table document and Text can also be chosen. Table document refers to accessible Calc spreadsheet files.
Sun’s HTML editor cannot be compared with the top standalone editors such as Macromedia’s Dreamweaver. It doesn’t take long for the user to notice that important processing functions, namely Java scripting and site management, are missing. In the end, the HTML editor is essentially just a reworked word processor.
Import and export filter Internet functions not included Sun has apparently given up its desire to integrate various Internet functions into StarOffice. For example, the email module (POP and IMAP capable) has been omitted. Sun has probably capitulated on this point due to the instabilities of the Mail module experienced with large mailboxes. The loss of the news client from the old StarOffice will probably be as painful for most as that of the feeble Web browser. Due to these changes, the client services now require external programs, such as Netscape Communicator, to take care of them. This at least makes it possible to send a document from each Office application by email, or to link to an external browser by mouse click (though this function is not available in the beta version). Here the programmer have directly eliminated a bug: in the old version, subsequent modifications to links did not change their functions (see Figures 7 and 8). It is at first impossible to tell the difference between the HTML editor and Writer when opening an HTML file. It is only when you click inside the page (structured as a typical table) that the second tool bar changes, thereby allowing for the formatting of tables (cells). The representation is very similar to that in a genuine browser – including animated GIFs. The page designers have really succeeded here. Another very nice feature is the Autopilot (with Microsoft, it would be probably called a Wizard), which runs in its own window and creates HTML files to a given style or template. Simply click on a template or a style and the result is displayed straight away in the editor window. The word processor’s source text mode also pleases with its highlighting of syntax.
Even those who don’t use any Microsoft products will not be able to ignore this paragraph, for hardly a day goes by when one doesn’t receive some document in the Word, Excel or PowerPoint format by email. StarOffice 5.2 did extremely well in this department, and this was Sun’s main advertising argument for an upgrade from Star Office 5.1 to 5.2. The current version has taken another step forward in the area of MS data exchange. (As a small aside: some uncommon multimedia text attributes of Microsoft Office 2000 cannot be transferred to StarOffice 5.2). Table 1 gives a first impression of the loading times when importing. These could change for the final version however, which may perhaps run faster. One special improvement (for Linux and Solaris) is in the interaction with OLE objects in MS Office documents. In Figure 6, a Word 2000 document with an embedded picture is correctly displayed in StarOffice 6.0, whilst in the previous version it would have displayed incorrectly. The export formats from Star Office 5.2 are all available for version 6.0. The fax solution and Ghostscript in PDF mode, both available in the Linux system, can also serve as printer drives. Both can be set up, as can TrueType font management, using the SPAdmin printer setup tool. The Star-specific genuine printer driver could not be tested because the beta version crashed (a well-known error under Sun).
Format of the future: XML The technically outstanding characteristic of StarOffice 6.0 is its file format, XML. It is, in this respect, right up there with Koffice. The extensions are accordingly: SXW for Writer, SXC for Calc, SXI for Impress and SXD for Draw. You can view a Issue 17 • 2002
LINUX MAGAZINE
21
FEATURE
comparison of the file sizes and loading times between the old and new versions in Table 1. For all of you who are not yet up to speed on the theory of the meta-language of the future, take a look at our XML feature on page 30. StarOffice stores XML files as (GNU)zip archives in standardised form. DTDs are not included. They are situated in the directory Office-directory/share/ dtd/officedocument/1_01. The file office.xml can be found under this path. A quick attempt to have a look at the contents of this, using an XML editor (Xmetal 2.0 from SoftQuad), failed due to incompatibility. Thus StarOffice seems, in contrast to
Info StarOffice 5.2
http://www.sun.com/software/star/staroffice/ 5.2/features.html OpenOffice http://www.openoffice.org Licences from OpenOffice http://www.openoffice.org/license StarOffice 6.0 Beta http://www.sun.com/software/star/staroffice/ 6.0beta/get.html OpenOffice API FAQ snapshot of www.api.openoffice.org/faq.html ODK http://udk.openoffice.org/udk_package.html
22
LINUX MAGAZINE
Issue 17 • 2002
the XML editor, to have included its DTD modules not in the order of incorporation, but in blocks. By the way, the formula editor, which has been absolutely neglected in this article, saves its files with the ending SXM. This content is fully compatible with the MathML standard.
Multi-platform architecture and a new API This is the third architecture in the history of StarOffice in which the manufacturer permits the interface with different platforms. Less than 10 per cent of the C++ code is dependent on the target platform. StarOffice and OpenOffice.org are logically structured in a system abstraction layer, infrastructure layer, framework layer and application layer. A FAQ at http://www.openoffice.org explains the details. For programmers, StarOffice is interesting (OpenOffice.org even more so) because all ports are left open. The API can be docked into via C, C++ and Java. The API of StarOffice 5.x was object-oriented – the new kid in town is by contrast componentoriented. More information (with a view to practical applications) for interested system developers can be gleaned from the Office Development Kit ODK.
FEATURE
Dual head: two monitors on one computer
DOUBLE VISION F
rom version 4, XFree86 has allowed several graphics cards to be used at the same time; so another older PCI card can be added onto the AGP card in the computer in order to drive a second monitor. An similar arrangement can be achieved using a dual head graphics card with two monitor ports. In this article we describe how you can run two monitors in parallel with two graphics cards, or one dual head card (with two VGA outputs). To be able to use this feature, you must already be working with XFree86 4.x – we did our tests with the latest version; 4.1.0. XFree86 3.x cannot handle dual head operation.
Installing two cards After installing an additional PCI card you first need to find out in what sequence the computer deals with these. This is easy: connect the two monitors and start the computer; the card displaying the BIOS messages is the “first”. If you don’t like the order, as well as swapping the monitors around you may also have the option of setting the bus sequence in the BIOS (AGP/PCI or PCI/AGP). Now start to run Linux at a run level in which X is not activated; in Red Hat and Mandrake, run level 3 is appropriate, whilst for SuSE run level 2 is the one you need. A few distributions will recognise the new graphics card when the system starts and will automatically integrate it (Mandrake Linux 8, for example, immediately proposed a configuration with both cards). We will do it ourselves below. After logging on as root, first check whether both cards have been correctly recognised by Linux. To do this, search for graphics cards with lspci. In our example computer, with a Matrox G400 and an ATI Rage PCI card, it looks like this: [Test@dual dual]$ lspci | grep VGA 00:0a.0 VGA compatible controller: ATI Technologies Inc 3D Rage IIC 215IIC [Mach64 GT IIC] (rev 3a) 01:00.0 VGA compatible controller: Matrox Graphics, Inc. MGA G400 AGP (rev 04)
The output reveals two things: firstly, both graphics cards were recognised by the kernel, and secondly we learn for each card, in the form “xx:yy.z”, how it
Two desktops from one machine. Both have a KDE panel but only one has desktop icons
can be addressed. xx in this case is the bus ID (00 is the PCI bus, 01 the AGP bus); yy is the device ID (in hexadecimal notation – 0a is 10 in the decimal system); and z is the “function”, usually 0. We will now need these figures to describe the cards in the XFree86 configuration. To find out this information, lspci interrogates PCI and AGP bus and looks up the device IDs in the file /usr/share/pci.ids. Now create a backup copy of the XFree86 configuration file (often called /etc/X11/XF86Config4, to differentiate it from the corresponding file for XFree 3.x), and open this in an editor of your choice. Look for the Device section. If X was correctly installed before the addition of the second graphics card, then the AGP card should already be configured. Since we will want to use two cards from here on in, in the first instance we should complete a “Bus ID” entry, which receives the value for the AGP card “PCI:1:0:0”. This specification corresponds to the lspci output “01:00.0”.
From version 4, Xfree86 has allowed several graphics cards to be used at once; enabling even those without dual head graphics cards to run multiple monitors. Hans-Georg Esser looks at the pros and pitfalls of dual displays
# Graphics device section Section “Device” Identifier “Matrox Millennium G400” VendorName “Matrox” BoardName “Millennium G400” Driver “mga” Option “DPMS” BusID “PCI:1:0:0” EndSection
Issue 17 • 2002
LINUX MAGAZINE
23
FEATURE
Under this device section, add a second entry; in our case we are configuring an ATI card. The device section looks almost exactly as would be the case if this was the only card present – here again we specify the Bus ID: “00:0a.0” (from lspci), which now becomes “PCI:0:10:0”. Section “Device” Identifier “ATI Mach64 3D RAGE II” VendorName “ATI” BoardName “Rage II” Driver “ati” Option “DPMS” BusID “PCI:0:10:0” EndSection
As the next step, we must define the two monitors to be connected to the cards. The only unusual thing here is that there are two “Monitor” sections:
To offer more clarity we have provided the two “Screen” sections with the identifiers “left” and “right”. The maximum resolutions of the two screens are different in this case: the left display will start at 1280x1024, while the right display offers only 1024x768 pixels. Finally, the X-Server still has to be told which screens are used in which layout – this is done via a Server Layout section:
# Monitor section Section “Monitor” Identifier “monitor1” VendorName “Unknown” ModelName “Unknown” HorizSync 30-96 VertRefresh 48-120 EndSection
# Server Layout Section “ServerLayout” Identifier “layout1” Screen “left” Screen “right” RightOf “left” InputDevice “Mouse1” “CorePointer” InputDevice “Keyboard1” “CoreKeyboard” EndSection
Section “Monitor” Identifier “monitor2” VendorName “Unknown” ModelName “Unknown” HorizSync 30-96 VertRefresh 48-120 EndSection Monitor1 should in this case be the left-hand monitor; monitor2, the right. Next comes the definition of the two screen sections. A screen consists of a combination consisting of “Device” and “Monitor” and the settings for resolution and colour depth. These sections also look quite normal: # Screen sections Section “Screen” Identifier “left” Device “Matrox Millennium G400” Monitor “monitor1” DefaultColorDepth 16 Subsection “Display” Depth 16 Modes “1280x1024” “1024x768” “800x600” “640x480” ViewPort 0 0 EndSubsection EndSection Section “Screen” Identifier “right”
24
LINUX MAGAZINE
Device “ATI Mach64 3D RAGE II” Monitor “monitor2” DefaultColorDepth 16 Subsection “Display” Depth 16 Modes “1024x768” “800x600” “640x480” ViewPort 0 0 EndSubsection EndSection
Issue 17 • 2002
The keyword “RightOf” does exactly what it says: the right screen is arranged on the right of the left one. We have not listed all the other sections of the X configuration file here – obviously mouse, keyboard and fonts modules need to be configured, but this is done in exactly the same way as you would for a single card.
Xinerama There are two different options available to you when using multiple monitors. One of these is called Xinerama, which creates a large common desktop on which windows can be moved back and forth between the two monitors; at the same time one window can lie on the edge so that a part of it shows in each of the two displays. The Xinerama option is only worth pursuing if both of your monitors run at the same resolution. Since a desktop is always rectangular, if there are two different resolutions the smaller display (in the case of the left-right arrangement) will be treated as if it has the same number of lines and the larger one. As a result, part of the desktop (a half line in the righthand area, for example) will not be visible. In KDE and GNOME this affects the start menu, which is located by default on the bottom edge of the desktop, so that this cannot be made out on the smaller monitor. If both monitors are used at the same resolution then there’s no reason not to use Xinerama. The
FEATURE
ServerLayout section should then be supplemented by one extra option: # Server Layout Section “ServerLayout” Identifier “layout1” Screen “left” Screen “right” RightOf “left” Option “Xinerama” “on” InputDevice “Mouse1” “CorePointer” InputDevice “Keyboard1” “CoreKeyboard” EndSection Those who waive the Xinerama option will instead get a separate desktop on each of the two monitors. KDE 2.2 then also creates an additional KDE directory Desktop1 in the home directory for Desktop. This houses the icon placements for your second desktop. In addition to the desktop configuration file, kdesktoprc, a second file called kdesktop-screen-1rc is also created in .kde/share/config. This ensures that both desktops are installed completely separately. The second desktop also offers a separate start menu. One small bug in this setup came to light when activating the screensaver: although both desktops are barred to inputs until the password is entered, the second desktop remains in view. Therefore, if you want to stop nosy people seeing the window of the second monitor, you should first minimise this or else switch to a clear desktop.
Displays :0.0 and :0.1 The $DISPLAY variable under X provides information about the X-Server on which an application is being displayed. This is normally “:0.0”. With two separate desktops, two X-displays can also now be activated – these are called “:0.0” and “:0.1”. To check that this is correct, simply open a terminal program on each of the two desktops and enter the command
the case of two graphics cards: here two “Device”, “Monitor” and “Screen” sections will also be needed. There is just one difference in the “Device” inputs, because the same graphics card has to be addressed twice. There is also the additional keyword “Screen”, by which the two VGA outputs of the card are distinguished. Appropriate “Device” sections look like this: Section “Device” Identifier “G400_1” Driver “mga” BusID “PCI:1:0:0” Screen 0 EndSection Section “Device” Identifier “G400_2” Driver “mga” BusID “PCI:1:0:0” Screen 1 EndSection For this card there are modules and configuration tools on the Matrox FTP server, which must be installed; the two archives are called mga-133_143.tgz and mgapdesk-1_00-7beta_i386.rpm. The first contains the modules mga_drv.o, mga_hal_drv.o and mga_dri.so (for XFree86 4.1.0 and 4.0.3). These replace (and supplement) the module mga_drv.o, which is an integral part of XFree86. In the test this worked really well, although with one problematic limitation: if one changes to a text console (via Ctrl+Alt+F1, for example) and then back to X, the computer hangs completely and has to be restarted. This is obviously liable to lead to data loss so should be avoided... This problem arose under both XFree86 4.0.2 and 4.1.0 (with the respective Matrox drivers).
Easy and effective echo $DISPLAY If you now specifically want to open a window on the left or right desktop, you can use the standard X option “-display”: xterm -display :0.0 will make an xterm appear on the left monitor, while with “:0.1” instead of “:0.0” the right monitor will be activated.
Dual head cards As an alternative to using two graphics cards you can also use a dual head card: these contain two graphics chips and accordingly, two monitor ports – effectively saving you one slot. We tried this out feature using the Matrox Millennium G400. The X-configuration here runs in a similar way to
Anyone who has an old PCI graphics card and a monitor to spare can quickly double their Linux desktop with XFree86 4.x: Unlike the virtual desktops provided by KDE and GNOME, a dual display has the advantage of being able to show two-fold content at the same time. Whether for software development, excessive Web consumption with lots of open Netscape windows or simply to display the television picture on the second monitor: with two desktops, work is twice as much fun. Best of luck with the configuration.
Hexadecimal The hexadecimal number system, unlike our normal decimal system, possesses 16 numbers: 0-9 and the letters a to f, representing 10 to 15. A hexadecimal number, such as “01f3”, will be converted as 0 * 16^3 + 1 * 16^2 + 15 * 16^1 + 3 * 16^0 = 499 in the decimal system.
Issue 17 • 2002
LINUX MAGAZINE
25
FEATURE
3D simulation games
LET THE GAMES COMMENCE As Linux develops so do the games available. No longer are we limited to text adventures or
I
t’s been all work, work, work here at Linux Magazine recently, so we decided it was about time we gave ourselves a little time out to test the latest batch of 3D graphical simulation games. In previous issues we’ve taken a look at Railroad Tycoon II, which let you simulate a train empire, as well as two games in the SimCity genre, Mobility and Free Reign – the former being a shareware program and the latter freeware.
graphical puzzle games. Jack Owen takes a look at some of the latest 3D graphic-rich games crying out for a chance to waste your time
City building with Free Reign
about to perform tasks. The Sims has earned itself a loyal following under Windows and it’s easy to see why. So is Mandrake Gaming Edition worth the money? If you play games, then the answer is probably yes. The technology that Mandrake has incorporated into this distribution is a version of WineX from Transgaming – who may be about to change Linux gaming by using WineX and enabling subscribers to vote on what should be worked on. Transgaming are already making substantial inroads into getting Windows games running under Linux. Does the system work? Well, yes and no. The range of games up and running is large and steadily growing. As a test we tried Fallout from Interplay and it did work. Where it fails is with some modern games, which use copy protection that the WineX software isn’t yet compatible with. However, we’re all going to have a fantastic year finding out which games do work. Subscription to Transgaming is $10 per month, although you do get three months free with The Sims.
Good housekeeping MandrakeSoft has decided to diversify, catering not only for the home and business markets, but also for gamers. Mandrake Gaming Edition comes with three CDs – a full Mandrake distribution – plus a fourth CD containing a Linux-based version of the Electronic Arts game, The Sims. Installation of the distribution is the same as any version of Mandrake, and The Sims game loads flawlessly once the security number is entered. Starting the game brings up a full screen version of The Sims and before you know it, several hours will have passed. When playing in KDE we did encounter a minor error, namely that the panel seems to draw over part of the playing area. Unfortunately, this part of the screen includes some of the game’s important controls. This flaw was not encountered under GNOME. In this simulation, rather than controlling an entire city, your actions are focussed on a single household. Gameplay is well timed so that you’re always doing something, such as moving the household characters 26
LINUX MAGAZINE
Issue 17 • 2002
The Sims under Mandrake Gaming Edition
Flight of fancy After many weeks of playing The Sims and failing to get the characters to kiss (to improve their morale, honest!) we decided to move on to some of the other games for Linux. FlightGear has been around for a while now and was originally proposed in 1996. Like most other simulators, and Free software in
FEATURE
(drawing airport scenery and the surrounding land is more intensive than blue sky). You can fly either full screen with no plane panel or even switch to a military style Head Up Display. Should you have the equipment then networking will allow multiple screens to be used at once.
Still want more?
Playing FlightGear on multiple monitors
general, it has only improved with age. This multiplatform (it works with Windows, Mac and Irix as well as Linux) project aims to be the best Open Source flight simulator available by allowing anyone to contribute to its improvement. This really is a wonderful working example of an Open Source project working as its best. An outlay of 40Mb of disk space gets the basic flight simulator and scenery up and running, and this alone is wonderful. You can however download additional scenery such as the whole of the UK in a 19Mb file, or airport overlays. The scenery is based on satellite imagery and so is very accurate. Astronomical code is also present so the Sun, moon and stars are all accurately drawn. For frame rate speed, the simulator relies on Open GL and a 3D accelerated graphics card. An MS Sidewinder joystick was fully supported but as the configuration files are in text format, other types and setups are easily configured. FlightGear can be started via the KDE menu or from the command-line with:
FlightGear is not the only flight simulator for Linux. There is a small but growing bunch with some unusual features. XPlane is currently being ported, and once complete this will enable you to fly in a wide variety of environments, including over the surface of Mars. Current beta programs available include the Plane-Maker and World-Maker, although not the simulator itself. Silent Wings is a simulator for gliders, whilst Fachoda Complex is ideal for those of you who want to attack each other via a network. Fachoda complex is a toy plane simulator that doesn’t rely on 3D graphic accelerator cards. You can bomb targets and trade up different planes. If helicopters are more your thing then you might want to get your hands on Search and Rescue, which is based on Mesa graphics libraries. At this point we thought simulators could not become anymore accurate. Then we found Racer...
run fgfs If you wanted to you can alter the settings to fly a hot air balloon or an X15 rocket plane. The default plumps for the more standard option of a small plane, based in Arizona. The number of different options is so large that we could spend weeks exploring each but our main task was to play the game, so running with the default options we started to taxi down the runway. The number of keyboard shortcut combinations can be a little confusing but a printout of the manual at the side of the keyboard soon solved this. Ctrl+U is the most important code as this instantly adds 1,000 feet to your altitude – hopefully giving you the chance to learn the other keys without crashing. With a 750MHz CPU, GeForce 2 graphics card and plenty of RAM the frame rate per second was around 60, and so was very playable. This rate drops depending on what conditions you are flying in (fog being the worst) and how low you are flying
Play the hero with Search and Rescue
Info Racer (on the CD) Transgaming Railway Tycoon II Mobility SimCity 3000 Free Reign The Sims FlightGear Xplane Silent Wings Fachoda Complex Search and Rescue
http://www.linuxracer.racesim.net http://www.transgaming.com http://www.lokigames.com/products/rt2 http://linux.mobility-online.de http://www.lokigames.com/products/sc3k http://freereign.sourceforge.net/index.shtml http://www.mandrakesoft.com/products/81/gaming-edition http://flightgear.org http://www.x-plane.com http://home.online.no/~tseval/sw http://rixed.free.fr http://wolfpack.twu.net/SearchAndRescue
Issue 17 • 2002
LINUX MAGAZINE
27
ON TEST
Racer
REAL DRIVING SIMULATORS “Real driving” simulators have been all the rage on the consoles over the past few years, but there’s a new contender coming up on the outside. Simon Naish takes the Linux version of the real driving simulator, Racer, for a test drive
28
LINUX MAGAZINE
T
here have been many so-called “real driving” simulators over the past few years, the best known of which being the Gran Turismo series on the PSX and PS2. However these games aren’t really all they’re cracked up to be – after all, what good would a flight simulator be if the planes bounced when they hit the ground at 200mph? Back in 1998, Sierra released Grand Prix Legends (GPL), a driving simulator based upon the 1967 Formula 1 season. 1967 was the last year that the cars didn’t have wings or the associated downforce and the science of race tyre technology was still in its infancy. The result of this was very fast cars on very dangerous tracks with no downforce and hardly any grip. Needless to say the driver’s skill was enormous, the racing extraordinary and frequently lethal. The problem Sierra, and designer Papyrys, faced was that in 1998 no-one had a home computer that even came close to the power needed to do the concept justice. Nevertheless, GPL was exactly what a few very dedicated petrol heads were looking for, and innumerable Internet leagues formed. What’s more, people started to make new graphics for the cars as machines became powerful enough to run them. New or more historically accurate reworkings of the original tracks were made, as were track conversion utilities. In short, the game prospered and still does,
Issue 17 • 2002
thanks to a huge Internet community constantly working to improve it.
Enter Racer That’s all well and good, you may be saying, but nothing on these lines runs on Linux. Nothing except Racer, that is – a Free driving simulator written by Ruud van Gaal. His vision was to create a new GPLstyle racer that would also enable people to add their own cars and tracks, whilst modelling the physics of the real machines as closely as possible. Luckily for us, he decided to make it cross-platform from the outset. Although much of the development is progressing quicker on the Windows version (features such as force feedback aren’t handled by Linux yet), the Linux version is definitely keeping up. The initial Racer download is two files; a data tar.gz and an executable tar.gz. The executable was compiled on ‘Best Linux’ with kernel 2.2.16-24 and XFree86 4.0.1 with the nVidia OpenGL drivers. You can download and compile the source code yourself, get it at http://www.linuxracer.racesim.net. The download also includes a track editor, car modeller and tyre modeller. Unfortunately, these aren’t stable on our test Linux box, though the Windows versions seem fine. The real beauty of this type of game/simulator and
ON TEST
undrivable, and it feels like a lot of these would remain pretty undrivable even with a steering wheel. Maybe I’m just being pessimistic, but I’ll only know for sure once I buy a force feedback wheel.
Fine tuning
its community is the wealth of add-ons: so far we’ve found 26 cars and 21 tracks. As you might expect, these vary hugely in terms of quality, stability and drivability, but that’s half the fun of downloading them. Our advice would be to stick to the cars and tracks on the linuxracer Web site to begin with. We especially like the Celicas, which are very fast and look amazing. If these aren’t to your taste there are models of new Minis, Ferraris (lots of Ferraris), F1 cars, a Volvo estate, GT cars and rally cars.
All about control The first thing to get set up is joystick input. Linux will readily cope with a huge array of joysticks/steering wheels or whatever other input device you’d prefer to use. Whether or not they are any good in a driving simulator is a different matter. There are tips for setting up a joystick configuration file if, like me, you want to try something with an inordinate number of buttons. I successfully configured a gamepad using the same buttons as I would use in Gran Turismo in a very short time. If you don’t have a joystick or steering wheel the game defaults at start up to mouse control. The problems inherent in using a gamepad become evident as soon as you try to play. To generate full lock in a real car, you must turn the wheel at least one and a half times in either direction. In a racing car this is often reduced to under half a turn. The brake foot must deliver a sizeable thrust to lock the brakes and the accelerator may be depressed several inches. On a gamepad you can normally achieve full look in about two centimetres of travel in either direction; maximum breaking may be achieved in the same distance, as can acceleration. All this means the cars can be impossible to drive. If you were to almost instantly apply full lock in a car travelling at say, 80mph, it won’t turn, as you will have exceeded the limit of the tyre’s grip. Instead you’ll simply skid forwards in a straight line. Breaking and accelerating with a gamepad generally provides equally disastrous results. This is all faithfully modelled in Racer and the results are rarely pretty. Some cars are very forgiving, but other are rendered
Putting aside my poor choice in controller, you’ll find that a lot of what you’ll find in Racer is very good indeed. The physics model seems excellent, though the tyres could grip a little more, for us mere mortals. The superior car models also move in a very convincing fashion and drifting is possible after some practice. Of course, a lot seems to depend on your choice of car and track. Comparisons between the Windows and Linux versions are inevitable, and in this case worthwhile. Under Linux I got consistently higher frame rates, with more graphics options on than in Windows. However importing cars and tracks proved more problematic under Linux. As the track editor wouldn’t work I couldn’t add track cameras, and all tracks now require at least one. A lot of the additional cars were designed on Windows, which doesn’t have a case sensitive filesystem. As such, it’s often necessary to change the case of some of the filenames. Check for QLOG.txt in the car directory. This will list any errors and tell you the name of the files Racer was looking for but couldn’t find. It’s also well worth fiddling with the audio.ini file. I didn’t realise that the sounds were playing incorrectly until I tried the program under Windows, whereupon it became clear that the horrible skid sound was actually a nice sound played back incorrectly – a problem that was quickly fixed. Lastly playing with the settings in gfx.ini can improve the look of the game a lot with fog, mipmapping and motion blur on the menu to name just a few of the options. Of course you have to have a graphics card capable of delivering the goods. Racer is very impressive and it isn’t anywhere near finished yet. There is no damage model or four-wheel drive yet, and multiplayer racing isn’t fully implemented as cars can’t crash into each other, but these things will come. As development continues, the car models and tracks will inevitably become more refined, especially the physics and handling side, and we have all this to look forward to.
Racer Supplier Racer Price Free Web http://www.linuxracer. racesim.net For For Very impressive and expandable Against Hard to control with a gamepad
rating
Info Linux Input Drivers homepage (for more information on joysticks and driver) http://atrey.karlin.mff.cuni.cz/~vojtech/input Racer homepage http://www.marketgraph.nl/gallery/racer
Issue 17 • 2002
LINUX MAGAZINE
29
FEATURE
XML-Editor KXMLEditor
THE X FACTOR XML is becoming more important all the time and KXMLEditor makes it easier to handle this data format. Frank Wieduwilt shows us how
F
reely translated, XML stands for EXtensible Markup Language. It’s well suited to the management of structured data, such as smaller databases, and is used as the file format for a huge variety of programs, including word processors (Kword and Abiword), graphics programs (Kontour and Sodipodi) and spreadsheets (Gnumeric and Kspread). Anyone looking at an XML document might be reminded of the source code of Web pages, as the ASCII text in it contains tags in pointed brackets, where there must always be an initial and an end tag. For example:
X
<author>Joe Hacker</author>
From the arrangement of the two tags, it becomes clear that the words Joe Hacker in the document should be formatted as the name of an author. If we don’t want Joe Hacker’s name to appear in the text, we could instead use a tag with attributes: <author surname=”Hacker” forename=”Joe”/>
PDF: Portable Document Format. A file format for exchanging formatted text.
Since in this case no text has to be enclosed by initial and end tags, both are combined by inserting the end symbol before the final bracket, thus /. While HTML is concerned with both structuring and formatting a document, XML is concerned exclusively with structure. Formatting is taken care of by a separate template, known as a “Style Sheet”. The effects of separating structure and formatting can be seen in the simple database (Listing 1), which we have developed in Figure 1 in
Installation
To compile off your own bat, you will need the file kxmleditor-0.7.1.tar.gz from the program homepage or our coverdisc. Unpack this file with the command: tar -xzvf kxmleditor-0.7.1.tar.gz
and change to the newly created directory kxmleditor-0.7.1. Install the program there by entering ./configure; start compilation with make and finally install it as root by entering make install. A 750MHz AMD Duron using Red Hat 7.1 was used as the test system for this article.
30
LINUX MAGAZINE
Issue 17 • 2002
Figure 1: An XML file in Konqueror
an XML-compatible browser (e.g. Konqueror). Without a style sheet it displays the content of the database completely unformatted. XML editors such as KXMLEditor place the file content in a tree-like structure, known as the Document tree, due to the fact that individual elements of an XML file branch out more and more after starting from a root tag. A tag that contains additional sub-tags is referred to as a node. Style sheets are created using a separate language called XSLT (EXtensible Stylesheet Language Transformation). With the help of this you can transform the content of an XML document into various output formats, such as HTML or PDF. Sometimes an XML file also needs a DTD, or Document Type Definition, in which the use of the individual tags are defined. For example, with the aid of a DTD it’s possible to check whether an XML document is only using attributes that are permitted for a specified tag, or whether tags are being interlocked which aren’t allowed to be interlocked with each other. A good introduction to working with XML can be found at http://www.webdeveloper.com As with any ASCII mark-up format, XML can be written with any word processing program of your choice. KXMLEditor makes it easier to create and to edit XML documents, as its tree representation offers the user an overview of the document tree at all times. It’s very easy to copy entire branches within the document. However, KXMLEditor does not yet create DTDs or style sheets.
XML assistant
The KXMLEditor program can be found at http://kxmleditor.sourceforge.net. Red Hat 7.x users
FEATURE
file. To do this, select File/Open from the KXMLEditor menu and load a file from Abiword, Kword or a similar XML-based application. Its structure will now be displayed in the tree view. In Figure 4 the tag pagesize is selected. In the right-hand pane of the work area, under the Attributes tab, you’ll see which attributes this tag possesses and their values. As an example of a new XML file, we’ll use an address database, as address details have a structure in which the individual attributes of forename, surname, street, postcode, town and telephone number are assigned to respective persons. To do this, first create a new XML document with File/New. Every XML file must start with the line:
X
Figure 3: The functions of the XML toolbar
<?xml version=”1.0”?>
Figure 2: KXMLEditor
can play in the appropriate rpm packet as root with the command rpm -Uvh kxmleditor-0.7.1-0.1.RH7.i686.rpm
The installation boxout explains how to install the software from the source text. To start the program, enter kxmleditor & in a console or select Applications/ KXMLEditor in the K menu. The KXMLEditor program window is split into three sections (Figure 2). Under the menu line there are two toolbars; the upper one is the general toolbar whilst the one underneath is a navigation line, which displays the active element in the XML file. In the lower part of the program window you’ll see the XML toolbar on the left; a tree view in the middle, in which the content of the opened file is displayed; and on the right is an input area with two tabs for the parameters of the tags and their contents. The interface elements are currently only marked in English, but work is in progress on translation into other languages. Figure 3 explains the meaning of each of the buttons on the XML toolbar.
Editing XML files
The simplest way to familiarise yourself with KXMLEditor is to practise working on an existing XML
which is known as the prologue. To enter this, select XML/Insert proc. instruction from the menu, or press Ctrl+R. In the dialogue that appears, enter xml in the Target field and version = “1.0” in the Data field. Click OK and the first line of your document will be created in the tree view. After the prologue, insert the root element of your XML file. Each XML file can have only one such root element, from which all additional elements are derived. In our example the root element is called addresses. Select XML/Insert Element from the menu or press Ctrl+E. In the dialogue which now appears (see Figure 5), enter the name of the element in the Element field. In the Insert: list at bottom left, select root, in order to mark the element as root element. After this preliminary work, the elements for the records can be defined. To do this, select the addresses element with the mouse, and insert an additional element named “record”. To insert an element at the top of the document, click on the Insert drop-down list in the XML Element dialogue, and select “at top”. You can define all of the elements in your individual data fields in this manner until you see a complete record in the tree view, as in Figure 6. You can now copy this empty record by marking the record tag and selecting Edit/Copy from the menu, or by pressing Ctrl+C. Select the database tag
source text: The files containing the program commands in a programming language. In order for the program to be executed by the computer, this must first be translated (or “compiled”).
Well-formed and valid XML The terms “well-formed” and “valid” crop up constantly in connection with XML. An XML document is well-formed when it has no DTD of its own, but each tag is completed by an end tag. However, it is not valid until it has a DTD, whose rules its content obeys. With KXMLEditor you can only create well-formed XML documents, since it does not offer the option of programming a DTD or of linking an XML file to an already existing DTD. Figure 4: An AbiWord file in KXMLEditor
Issue 17 • 2002
LINUX MAGAZINE
31
FEATURE
Table 1: Important key combinations
Info Information on XML http://www.webdeveloper. com/xml
Figure 5: Inserting an XML element
and insert a new, identically constructed record with the command Edit/Paste, or by pressing Ctrl+V. The database now contains two records, which are both still empty. To fill the data fields with content, mark the desired field and select XML/Edit content from the menu. In the dialogue box, enter your information in the Content field – this information can cover more than one line. From the Type drop-down list, select whether the data entered is to be considered as text, a comment or CDATA (Character Data). Before displaying your new addition, the XML parser checks to see whether the content and defined type correspond with each other; comments are ignored when the file is outputted. If you select the CDATA type, the parser checks to see whether there really are only numbers and letters present. If text is chosen this check is left out. You can now gradually fill all the data fields with content and insert new records as required. The sequence of the records can be changed by selecting a record tag and altering its position with the aid of the two buttons Move element up and Move element down, from the XML toolbar. If you’ve followed the examples so far, you should now have a well-formed XML file (Listing 1),
Figure 6: A complete record
32
LINUX MAGAZINE
Issue 17 • 2002
Action Open file Save file Close file End program Insert element Insert attribute Insert content Set bookmark
Key shortcut Ctrl+O Ctrl+S Ctrl+W Ctrl+Q Ctrl+E Ctrl+A Ctrl+C Ctrl+B
although you won’t have a DTD or style sheet as yet. You must create both of these in a text editor of your choice and insert them in the XML file by hand, as KXMLEditor does not yet have a corresponding functionality.
Strengths and limitations The program is therefore suitable for viewing and editing small XML files, but not for large databases or heavily formatted documents. KXMLEditor is very stable and is easy to use via the keyboard. In the program help, all program functions are explained; but there is no introduction to XML, which is necessary to understand the software.
Listing 1: The example database <?xml version = ‘1.0’ ?> <addresses> <record> <surname>Hacker</surname> <forename>Joe</forename> <street></street> <postcode></postcode> <town></town> <tel></tel> </record> <record> <surname>Guru</surname> <forename>Graham</forename> <street>12 Any Lane</street> <postcode>12345</postcode> <town>Bigtown</town> <tel></tel> </record> <record> <surname>Lovelace</surname> <forename>Ada</forename> <street>1 Engine View</street> <postcode>12543</postcode> <town>London</town> <tel></tel> </record> </addresses>
FEATURE
Open Source database systems
TAME YOUR DATA B efore you start looking at expensive proprietary database solutions, it’s worth considering Open Source candidates. In this article we would like to introduce the concept of Free databases and explain the practical application of the appropriate tools. The use of larger database management systems (DBMS) requires that you have at least some idea of what to expect from that sort of system. Typical characteristics include data security, integrity, performance, external interfaces and the user interface to the DBMS itself. A common misconception is that a spreadsheet, such as Excel or StarCalc, and a DBMS provide similar functionality. As you’ll see this isn’t the case at all. When looking for suitable applications you will mainly come across the names of the following wellestablished Open Source systems: MySQL, mSQL and PostgreSQL. Each of the systems mentioned is perfectly usable, though you’ll find some are stronger in certain areas than others. You can find more information on this under http://www.postgresql.org and http://www.mysql.org.
When your address
initdb -D /usr/local/pgsql/data You are now ready to start the server for the first time. Stay logged in as postgres and enter the following start command on the console: postmaster -i -D /usr/local/pgsql/data & This completes the setup. PostgreSQL is now ready.
book is full and your card file is packed to bursting, it’s time to start looking for a more suitable database system.
The famous address book So as not to overcomplicate things we are going to use the familiar and simple concept of address management for our sample application. As postgres, you create this with the following command:
Andreas Bauer takes a look at your options
createdb Addresses
Spoilt for choice In this article we have decided to investigate PostgreSQL more closely. Not because we think that it is superior to any of the others, but because the basic functionality is the same as that of most SQL databases. Initially called Ingres and later Postgres95, PostgreSQL originated at Berkley University and has been developed by a worldwide group of Open Source programmers since 1996. PostgreSQL is the only Free database that has always supported complex processing techniques such as transactions (see the Transactions box for more details).
Database creation Each database requires either a whole partition on the hard disk or at least a clearly defined area of the filesystem in which to store information. Some rpm packages of PostgreSQL automatically create /var/lib/ pgsql/data for this purpose. Otherwise, it normally makes sense to deposit data in /usr/local/pgsql/data. mkdir /usr/local/pgsql/data chown postgres /usr/local/pgsql/data Now change your user identity to that of the user “postgres” with su postgres and create the skeleton of your database:
This command only defines the name of the database. You will need to specify later what sort of information the address management system is going to contain. For this purpose we have worked out a selfexplanatory database layout (see Figure 1), which can be easily transferred to any CD or recipe collection.
Transactions Transactions are a useful DBMS feature when it comes to ensuring integrity during changes to data. For example, imagine Mr. Miller would like to transfer £50,000 to Mrs. Jones. The database will first of all attempt to subtract this amount from Mr. Miller’s account. Once this is completed successfully, the database can then add the amount to Mrs. Jones’ account as a second step. These are essentially two separate operations. However, if there should be a power failure after the first step then Mr. Miller would be £50,000 poorer but Mrs. Jones would still be waiting for her money. This scenario would not have happened with a transaction, as both operations would be executed simultaneously, once the DBMS has ensured that the transaction is permissible. In the case of a system failure or other problem, partial operations are simply reversed (rolled-back) so that no inconsistencies can arise. Transactions aren’t unique to PostgreSQL, of course; these days MySQL also supports this facility, with minor limitations.
Issue 17 • 2002
LINUX MAGAZINE
33
FEATURE
Program installation Many Linux distributions already contain PostgreSQL. If the packages have not already been set up on your system you can simply use the normal CD-ROM installer. Alternatively, you can also download the appropriate files in various package formats, from one of the mirror sites. The source files are also available, but compiling such extensive programs is best left to computer buffs and is not necessary for our purposes.
PostgreSQL, like MySQL and mSQL, is a server process that runs constantly in the background. For security reasons it is therefore important that it’s not started by the administrator, root. After the installation you should create a dummy (if one does not already exist) with which to start the PostgreSQL server, using the command adduser postgres
Structured query language
Figure 1: Database layout “Address management”
Advanced systems like PostgreSQL or MySQL have powerful entry and query facilities, for which SQL has pretty much established itself as the standard (see the SQL box). If you already have some knowledge of this descriptive language you will be able to use familiar commands in PostgreSQL. Even if you’ve never heard of SQL there’s no need to despair, as Open Source database systems are supported by various graphical front-ends that don’t require the use of complicated commands. We should mention at this point that these frontends are often less polished than you might be used to from the likes of Microsoft Access or Filemaker. Even though those commercial products do have an SQL-enabled core, this is thoroughly shielded from the user. In the Open Source arena there are some more promising attempts, but in many situations some hands-on work in the SQL interpreter simply can’t be avoided.
SQL SQL (Structured Query Language) is a descriptive language, i.e. its commands describe specific data (records) that are to be retrieved, deleted or edited. For example, in order to find everyone with the first name “Albert” in the data table Personal you would enter the following command in the SQL interpreter:
Figure 2: Creating new tables and fields
The user-friendly approach The good news for PostgreSQL users is that the server comes complete with one of the better database front-ends. If you’ve installed all the packages correctly, you should have the Tcl/Tk application pgaccess on your hard disk. Start pgaccess under your normal login (postgres) and open the newly created empty database Addresses via the menu Database/Open. New data tables are created with the New button on the upper menu bar. Figure 2 shows a new table created according to our pre-defined layout. The fields that are preceded by a ‘*’ are primary keys (in the database layout these are indicated with underscores). Together they uniquely identify a data record, in a similar way to a serial or ID number. The data types used are varchar, a character string, and int4, an integer numeral. The option NOT NULL ensures that this field is not accidentally omitted during the entry of new data. Now proceed in a similar way for the table Personal, keeping precisely to the layout as defined in Figure 1. The connections between the two tables require a slightly different approach. You need to create a third table, for instance LivesIn, which allocates the people to the places. Don’t worry, such connections are always created according to the same principle: you take the primary keys of the two tables and create a single new table with them all. You’ve now created a database on your PostgreSQL server that is ready for you to use. Double-clicking on a table opens it and enables you to edit its content. The great thing is that you’ve not had to use any SQL
SELECT Name, Surname, Number, Street, Town FROM Personal WHERE U Name=’Albert’; Instead of specifying the fields you are interested in following SELECT, you can simply use ‘*’ to see all the fields in a table. The search criteria are contained in the WHERE clause; modifications and even nesting are permitted. Another short example: SELECT * FROM Personal WHERE Name=’Albert’ AND Surname=’Einstein’; You can find detailed information on SQL and command overviews on the Internet, as well as in the manuals for PostgreSQL. Figure 3: The relation “LivesIn”
34
LINUX MAGAZINE
Issue 17 • 2002
FEATURE
yet, nor will you need to for these basic functions. Nevertheless, we would like to introduce you to the SQL process at this point, because it is universal and very similar in each SQL database.
Command line Although beginners may find it a little tricky, databases can be created more directly using SQL commands. PostgreSQL has an interpreter called psql for this very purpose. As user postgres you can log onto the database server with the following command: psql Addresses The result doesn’t look particularly impressive, but don’t be fooled – you are now linked directly to the database and can manually create and edit tables. To save you some time we have prepared three short, self-explanatory scripts, that you will also find on the coverdisc (create_tables.sql, fill_tables.sql, delete_tables.sql). These scripts can be loaded and executed using the following commands: \i create_tables.sql \i fill_tables.sql
direct contact with the DBMS. This means that you’ll need to decide how you want your data to be presented externally, and who will be working on it. The PHP system has become the established way of creating Web-based database applications. In most cases HTML forms are sufficient for data entry and simple query functions. Unlike commercial databases, Open Source solutions hardly ever enable users to create suitable applications using the system itself. One of the advantages of PostgreSQL is that you can decide how you are going to create your database and which additional programs and applications will have access to it. There are, for example, Free drivers for the languages PHP, Java and Tcl. Accessing your data in C or C++ is also no problem. There are a few readymade examples that we wouldn’t want to deprive you of. For instance, the GNOME Photo Collector (a GNOME application for managing photo albums), or the PHP version, PhpPgGBox, which needs a Web browser to power the display. More general front-ends for data manipulation are also available. One of them is dbMetrix, which is also very similar to pgaccess, but has the advantage of supporting many different database servers, including MySQL.
Conclusion At this point we are not going to go into the content of these scripts. They are simple ASCII text files, which you can view with any editor. The SQL commands they contain could, of course, be just as easily entered manually, but that would take time and effort, especially as you’ll want to experiment with the database. Should anything go wrong and you want to return the database to its original state that’s not a problem. Simply execute the script delete_tables.sql and start again. \i delete_tables.sql As you can see, this manual approach is very elegant and above all portable. No matter whether you end up working with MySQL, mSQL or Oracle, the commands in the three scripts will be interpreted correctly by any of these systems. Even the graphical front-end pgaccess only performs the SQL commands that are represented by your actions on the interface. Try to take a bit of time at this point to experiment with the interpreter. Insert data with the INSERT command, or use SELECT to find data records. Aside from the sample scripts, the links listed below are particularly good starting points for your first steps in using this descriptive language. To leave psql use \q.
Practical application Normally the database server stores our information and some sort of software provides the appropriate graphical interface, without the user coming into
Using a proper database is completely different to working with a spreadsheet or an electronic scheduler. The decision on whether you really want to administer your data in such a complex system should be based on how important it is to you that the stored information can be processed further or made accessible to other system components (Web pages, programs, scripts, etc.). Database servers like PostgreSQL also impress through their multi-user capabilities, scalability, robustness and openness. However, these characteristics are not required in every case. This article is intended primarily to provide a simple introduction to the subject and to show you that an Open Source DBMS is more than able to meet even professional requirements. What’s more, a Free solution based on SQL is a future-proof system. Do compare different Free database servers, however, it may even be worth investing in an introductory SQL book.
PHP PHP is an HTMLembedded scripting language, which is similar to Perl and in terms of syntax, related slightly to C. It provides a simple way of creating dynamically generated pages using a database for building up the page content.
The author Andreas Bauer is studying Information Technology and Psychology at Munich University. He also created a Web-based student database system at the Australian National University, Canberra, based entirely on free software. He can be contacted at baueran@in.tum.de.
Figure 4: Overview of all tables
Information PostgreSQL site Download mirror MySQL site SQL tutorials SQL tutorials PHP site Gnome Photo Collector Photo Gallery Data manipulation
http://www.postgresql.org/ ftp://ftp.ie.postgresql.org/mirrors/ftp.postgresql.org http://www.mysql.org/ http://www.sqlcourse.com/ http://w3.one.net/~jhoffman/sqltut.htm http://www.php.net/ http://gpc.sourceforge.net/ http://madness.bira.gen.tr/proj/PhpPgGBox/ http://www.tamos.net/sw/dbMetrix/
Issue 17 • 2002
LINUX MAGAZINE
35
FEATURE
Lego Mindstorm Dreaming of electric sheep
BRICKS AND PIECES Robotics is a minefield of a subject due to the many different avenues of exploration. Despite limited time and resources, John Southern bites the bullet and plays with Lego...
36
LINUX MAGAZINE
Y
ou can spend your time building hardware or you can concentrate on the programming. You can even do it all virtually such as the University of West Florida’s robot modelling site. Hardware wise most of the kits available depend on the Parallax BasicStamp, which is a PIC microcontroller. Unfortunately it is Windows controlled but by the time this is published a new C environment should be available. The BasicStamp allows simple circuits to be built and controlled giving rise to many third party kits. What I wanted was something ready made so I could play with the software. A wet Saturday afternoon meant a trip to the local Toys’R’Us to see what we could find to while away the afternoon. Lego
Issue 17 • 2001
A simple rover
Mindstorm cried out but we were cautious. Lego released the Mindstorm a few years ago inspired by the MIT programmable brick. The main programmable block (RCX) based on a Hitachi H8/3292 microcontroller is available in three versions (1.0, 1.5 and 2.0). In the UK you can buy either the Lego Robotic Invention System 1.5 or 2.0. The difference lies not the RCX brick but with the infrared controller. In version 2.0 the controller is USB while 1.5 is serial. The most recent stock in the shop was version 1.5 with a RCX 2.0. The RCX version does not really matter as it can be upgraded and using LegOS can be replaced. The first hour was spent just opening lots of bags of Lego and playing. Finally deciding to build a robot to follow a path we face our first challenge. Without a Windows machine in the house the supplied software is of no use. We can spend Saturday night installing Windows or turn to the Web for help. After just a couple of minutes on the Web we were faced with an array of choices. We can use the Lego RCX built-in software and run a Linux-based programming tool or we can download a new programming language into the RCX and again control it from Linux. Starting with the inbuilt software we can then choose from a range of programming languages such as Forth or NQC (Not Quite C). We opt for NQC as the Forth primer is somewhere upstairs and lazyness has taken over. The NQC is command line based and the latest version (2.3r1) is a 188K download. The package contains a test file to check that the system is
FEATURE
Seek the light and avoid the cat
working and you have everything connected. It is probably worth downloading the NQC package just for this test as it puts your mind at ease over the hardware. To control the RCX brick we first write our NQC in a simple text editor. We save the file with a .nqc extension and the command nqc test.nqc compiles the code. Now by adding the -d switch we can send the complied code to the RCX brick. nqc -d test.nqc Similar to C or C++ the NQC follows very similar syntax: task main() { SetSensor(SENSOR_1, SENSOR_PULSE); while(true) { if (SENSOR_1 ==2) { PlaySound(SOUND_FAST_UP); ClearSensor(SENSOR_1); } } }
As can be seen from the above example no surprises appear in the coding. The real surprise is that the sensors and output ports (three of each on the RCX brick) are not just digital on/off but analogue and can be used to sense a range from 0 to 1023. This means with just a few logic gates we could expand the number of sensors, but that’s for another weekend. From the above example we can see that there is a sound generator on board. With a little work with the PlayTone command we can get the brick to sing, so long as we are careful to not let the buffer queue overflow (every eighth note we have to pause until the buffer is empty). Actually more time was spent on building the robots, due to the huge amount of parts in the box and the constant hunt for the correct brick shape. The robots can be initially built by using the easy to follow booklet supplied with the kit – just remember to allow more time to find all the parts. Having tested that the Linux box could control the RCX brick and had fun making little models dance, sing and even head towards the light (Warning: Cat owners should note that the robot is easily knocked over by an angry feline), we couldn’t resist updating the firmware. Our first choice was the pbFORTH but in practice we settled for LegOS. Both of these routes enable you to replace the firmware inside the RCX brick and thus give you far more control over the unit. To update the firmware we need to use a firmware
downloader. One was at hand from the NCQ with the -firmware switch. The LegOS gives much more control and we can now program the tiny LCD screen. We wrote a simple C text file and complied it. First mistake. You need to set the makefiles TARGET environment variable otherwise you will wonder where the .srec files go. Second mistake. Make sure the serial port is correctly set, as the default is ttyS0. Third mistake. Getting the error message “no response from RCX” does not necessarily mean the RCX brick is faulty or out of range. It may be that the IR control unit’s battery has finally died. With the LegOS finally running and after recompiling code to remove errors we find all sorts of extra functions. Motor speeds can be subdivided into 255 units. A brake function enables us to lock a wheel while the off function lets it freewheel. The only disappointment with the kit was to do with the number of pieces included. While it may have taken ages to find parts because they are so numerous, the number of pieces is cleverly limited to only just build the robots in the supplied booklet. Now serious consideration must be put to asking Father Christmas for more pieces. Who knows maybe next time the smaller Lego Scout module may appear.
Info http://www.enteract.com/~dbaum/lego/nqc/ http://www.legOS.sourceforge.net/
Issue 17 • 2001
LINUX MAGAZINE
37
FEATURE
ROBOTS: Extra sensors
QUICK FIXES The sensors that come with the MindStorm are limited. So John Southern decided to make some of his own
How to hook us easily to the Lego connectors
Temperature probe
38
LINUX MAGAZINE
H
aving finally read the whole of Luis Villa’s MiniHOWTO on Lego MindStorm with Linux, and received lots of emails back from those who asked for the PDF files of the previous article that should have been printed in December, the biggest request was for DIY sensors and actuators, as the range with the MindStorm is considered small. Sensors consist of two parts: the first connects to the RX brick and the latter is the actual sensor. Like most people I want to do things quick, so I’m prepared to cut corners if the time saved outweighs the flimsiness of the product. When making extra sensors I should have produced wonderful connectors by using a lathe, turning down machine screws and mounting these inside a Lego brick to make good connectors. If I had that much spare time I would do something more constructive such as watch TV. A quick look through the spares box finds mini crocodile clips, which clip onto the Lego RCX and hold quite well. Hurrah! The easy part of the sensor, done in a minute.
slowly to choose the correct path and we had to drive the buggy, wait, test the temperature and compare this with the previous result to see any change. Another quick fix to make it a waterproof sensor was to cover it in hotmelt glue.
The heat is on
Orienteering
Now for the actual sensor. The first we build is a temperature sensor in the hope of making the buggy move towards heat. Adding a thermistor to the other ends of the crocodile clips is the quickest way we can make a temperature sensor. The only problem that arises from this, is that it needs a temperature offset constant to make it accurate. After two days of playing with this, we found that the crocodile clips give variable contact resistance – so what works one day fails to be accurate the next time we build. Rather than be forever adjusting the program data each time we build, we can fudge the sensor by putting a variable potentiometer in line with the thermistor. We can now easily adjust the resistance in the connecting cable so the thermistor gives an accurate reading. At this point the buggy sort of works, except that changes in temperature are actually very small and the thermistor requires time to settle on a temperature. This meant it worked very
Next up is an angle sensor. Here we simply link a ski on the bottom of the buggy to a variable potentiometer. As the ski changes angle with the terrain so too does the resistance through the potentiometer. This is much easier that our other sensors, and means we can also now work out the gradient. At this point we were still plagued with cats thinking the buggy was their personal plaything so we will investigate imaging next time.
Issue 17 • 2001
The motion of the ocean The next quick fix sensor is a mercury tilt switch. This works as a simple contact when turned in a set orientation. These are great fun, as by putting them in series with resistors in parallel we are able to make a motion detector. Changing the orientation proved to be tricky, but hotmelt glue came to the rescue. With one mercury switch we could sense if the buggy was travelling on a level surface or on a slope. With two mercury switches we have enough data to determine whether it’s travelling uphill or downhill. This is done by positioning one sensor so it only contacts when the bugging is climbing and one that makes contact when running level. If sensor one is connected then the buggy is going up hill; if the second sensor is connected the buggy is running level; and if neither sensor is connected the buggy is travelling downhill.
Hot glue – the quick fix solution. Angle sensor using a potentiometer
FEATURE
ROBOTS: Extra sensors
QUICK FIXES The sensors that come with the MindStorm are limited. So John Southern decided to make some of his own
How to hook us easily to the Lego connectors
Temperature probe
38
LINUX MAGAZINE
H
aving finally read the whole of Luis Villa’s MiniHOWTO on Lego MindStorm with Linux, and received lots of emails back from those who asked for the PDF files of the previous article that should have been printed in December, the biggest request was for DIY sensors and actuators, as the range with the MindStorm is considered small. Sensors consist of two parts: the first connects to the RX brick and the latter is the actual sensor. Like most people I want to do things quick, so I’m prepared to cut corners if the time saved outweighs the flimsiness of the product. When making extra sensors I should have produced wonderful connectors by using a lathe, turning down machine screws and mounting these inside a Lego brick to make good connectors. If I had that much spare time I would do something more constructive such as watch TV. A quick look through the spares box finds mini crocodile clips, which clip onto the Lego RCX and hold quite well. Hurrah! The easy part of the sensor, done in a minute.
slowly to choose the correct path and we had to drive the buggy, wait, test the temperature and compare this with the previous result to see any change. Another quick fix to make it a waterproof sensor was to cover it in hotmelt glue.
The heat is on
Orienteering
Now for the actual sensor. The first we build is a temperature sensor in the hope of making the buggy move towards heat. Adding a thermistor to the other ends of the crocodile clips is the quickest way we can make a temperature sensor. The only problem that arises from this, is that it needs a temperature offset constant to make it accurate. After two days of playing with this, we found that the crocodile clips give variable contact resistance – so what works one day fails to be accurate the next time we build. Rather than be forever adjusting the program data each time we build, we can fudge the sensor by putting a variable potentiometer in line with the thermistor. We can now easily adjust the resistance in the connecting cable so the thermistor gives an accurate reading. At this point the buggy sort of works, except that changes in temperature are actually very small and the thermistor requires time to settle on a temperature. This meant it worked very
Next up is an angle sensor. Here we simply link a ski on the bottom of the buggy to a variable potentiometer. As the ski changes angle with the terrain so too does the resistance through the potentiometer. This is much easier that our other sensors, and means we can also now work out the gradient. At this point we were still plagued with cats thinking the buggy was their personal plaything so we will investigate imaging next time.
Issue 17 • 2001
The motion of the ocean The next quick fix sensor is a mercury tilt switch. This works as a simple contact when turned in a set orientation. These are great fun, as by putting them in series with resistors in parallel we are able to make a motion detector. Changing the orientation proved to be tricky, but hotmelt glue came to the rescue. With one mercury switch we could sense if the buggy was travelling on a level surface or on a slope. With two mercury switches we have enough data to determine whether it’s travelling uphill or downhill. This is done by positioning one sensor so it only contacts when the bugging is climbing and one that makes contact when running level. If sensor one is connected then the buggy is going up hill; if the second sensor is connected the buggy is running level; and if neither sensor is connected the buggy is travelling downhill.
Hot glue – the quick fix solution. Angle sensor using a potentiometer
KNOW HOW
SuSE Linux 7.1 PowerPC Edition vs. Yellow Dog Linux 2.0
MAC
VERSUS
MAC To follow up our recent series of articles on running Linux on Apple
U
pon opening the SuSE box you’re confronted with no less than six CD-ROMs. Unsurprisingly, they’re not all for the Mac with some being dedicated to more esoteric PowerPC systems such as the IBM RS/6000 and Motorola MTX PreP-based machines. Nevertheless, there are an awful lot of programs on these discs, with SuSE putting the tally at over 6,000. We’ll have to take their word for this as we were in no way inclined to count them! By comparison Yellow Dog Linux’s (YDL) three CDs seem Spartan, but this is a misplaced impression as YDL comes with an almost equally vast array of software and works on the aforementioned PPC systems as well as the new Briq server.
Macintosh systems, Jason Walsh takes an in-depth look at two popular Linux Distributions for Power PC computers. The test machine is an iMac Revision B (233MHz, 64Mb RAM, 30Gb 7,200RPM hard
Documentation The difference between the documentation supplied with these two distributions couldn’t be more vast. Both come supplied with masses of documentation on the CDs, but whilst Yellow Dog Linux comes with a terse installation booklet, SuSE 7.1 comes with 514page manual. The SuSE manual can be heavy going at times, but it does include everything you need to know about installation, booting, networking, printing, PCI, ISA
drive). and PCMCIA cards, ISDN, security and whole lot more. Apart from this, SuSE kindly provide a couple of stickers and a rather natty looking pin badge. When all is said and one however, the YDL booklet is really quite comprehensive and covers the majority of scenarios you will encounter. Like SuSE, YDL include some esoteric additions in the box in the form of bumper stickers. Issue 16 • 2002
LINUX MAGAZINE
39
KNOW HOW
SuSE PPC desktop
As far as the SuSE manual goes, there are a few errors, but nothing of any consequence, just the odd word mistranslated from the original German and a needless section on using WinModems.
Installation How you go about installing Linux on your Mac depends on the age of your hardware. In simple terms, if your Mac is ‘platinum’ (Applespeak for grey plastic) in colour it uses an ‘Old World’ ROM, whereas if it is one of Apple’s recent coloured machines, such as the iMac, Power Mac G4 or TiBook, it is based on the more recent ‘New World’ ROM. On a New World machine all that you should have
to do is partition your hard disk, install the MacOS and then reboot your Mac from the SuSE CD. Installation with YAST2 (Yet Another Setup Tool) should follow, unless you’re short of RAM, in which YAST will be used instead. For no apparent reason the SuSE CD failed to boot on the test machine, which we can only presume was because of a firmware update, as the machine was an ordinary iMac – the only modification being 32 Mb of extra RAM and a speedy, capacious IDE hard drive. All was not lost however, as there was an alternative method. Linux requires a tiny boot partition in HFS format. Following the instruction in the SuSE manual the suseboot folder was copied from the CD onto the boot partition. Next the Startup Volume control panel was launched and the boot partition selected. After a reboot, installation commenced without a hitch, though with the older YAST text interface rather than the graphical YAST2. From here on in it was just like installing on an Intel system, basically a case of selecting one of the standard installations or choosing you own packages in mix and match fashion. After the problems we faced in installing SuSE, I decided (for some reason unbeknownst even to me) to take a rather cavalier attitude to installation with YDL and simply stuck the CD in the drive and restarted the machine whilst holding down the C key in order to invoke booting from the CD drive. Unbelievably, the CD not only booted directly into Linux, but also installed flawlessly. It really was as simple as that. Still, if you also want to run the MacOS alongside Linux you will have to partition the hard drive first, reinstall the MacOS and then install YDL.
Alternative distributions LinuxPPC – Linux PPC was once the premier distribution for the Mac, but the site has been quiet for some time now, however, it can still be downloaded from their servers. http://www.linuxppc.com http://www.linuxppc.org MKLinux – This still updated version of Linux was once officially supported by Apple as they treaded water before confirming NeXT and BSD as the basis of their next generation OS. Unusually for Linux, it’s based on a Mach micro kernel. Not the most popular distribution, but the only one that supports the older PowerPC Performa machines. http://www.mklinux.com Debian – The godfathers of the GNU movement maintain their own PowerPC version. You’ll know if you want to run this already, as it is as powerful, yet complex, as their x86 distribution. http://www.debian.org Mandrake – Much is expected of this newcomer to the Mac scene. Just as the Intel version requires a Pentium or better, Mandrake PPC requires a G3 or G4. http://www.linux-mandrake.com
40
LINUX MAGAZINE
Issue 16 • 2002
KNOW HOW
First impressions Should you be using an Old World Mac, upon starting the machine you will be presented with a rather nifty little application named BootX, which graphically enables you to select either the MacOS or Linux. This program is actually a MacOS system file, which shoe horns itself into the boot process, temporarily halting it and enabling you to redirect into Linux. New World machines are instead presented with the less aesthetically pleasing, but also less kludgelike LILO text interface – identical to that on Intel systems. SuSE includes the alternative MiBoot, which allows you to boot directly into Linux on Old World systems, in much the same way as LILO does on New World machines. However, this is not supported, as it is a technology under heavy development. Both distros install KDE as standard, but also come with GNOME, Enlightenment and the rest of the usual suspects. All the standard applications come with both SuSE and YDL, including the GIMP, AbiWord, KOffice, Emacs, GNUmeric and so on. Perfect for the home or small office user. Both SuSE and Yellow Dog were remarkably responsive on a machine that has, by today’s standards, a rather minimal amount of RAM and we were able to customise the desktop to our hearts’ content, making it almost, but not quite, Mac-like.
Digging deeper The most interesting Linux application on the PPC actually has very little to do with Linux. Mac on Linux is an environment in which you can run your favourite MacOS applications without rebooting. Mac on Linux has been covered elsewhere in this magazine in more detail, so suffice it to say that the relevant packages are included with both distros and are a doodle to configure. As always, the PPC distributions lag slightly behind their Intel brethren, but given the ubiquity of the x86 chipset this is not in the least surprising. What is in fact so surprising is the tiny degree by which they lag: PowerPC developers must be an industrious lot indeed. The only things of note that are lacking from PPC/Linux are a journaling filesystem and nondestructive partitioning. Work is no doubt underway on both. A big problem for Mac owners is the one button mouse, though of course this is not the fault of either SuSE or Yellow Dog. Despite all that has been said, I am a firm believer that mice should never have had more than one button – multi button mice are a strange idea, rather like those cheap pens with four coloured inks. Still, you’ll struggle to get the most out of Xwindows with a single button, so it’s off to the shop for you. Newer Macs, of course, offer USB support so getting a cheap mouse is no problem. Owners of machines which use the ADB (Apple
Desktop Bus) connector and protocol will probably have to go to their local Apple Centre or try one of the many mail order outlets specialising in Apple equipment – a small price to pay for years of successful and productive Linux computing.
Yellow Dog desktop
Overall It is difficult to qualify this decision, but I personally prefer YDL, however, I suspect that this is due to the complete lack of installation hassles. As far as actual use goes, both distros seem to perform equally well and it should of course be noted that SuSE comes with over 6,000 applications on the CDs. If printed documentation is your thing, then I have no hesitation in recommending SuSE, despite my personal preference for Yellow Dog’s offering. The most important factor in choosing which distro to use is of course, compatibility, and though both will work with the majority of Power Macs you would be advised to check out the respective Web sites before handing over your cash. After the review both Yellow Dog and SuSE have updated their versions. The SuSE 7.2 now ships with eight CDs and two manuals – one of which is a networking manual. Installation ran smoothly first time with YAST2 and it now supports journaling filesystems. Gracious thanks to SuSE UK and Yellow Dog Linux for supplying the test software.
The author Jason Walsh is a freelance graphic artist and is currently studying for a PhD in Information Architecture. He has worked as an administrator of a mixed Macintosh, Windows and Linux network.
Issue 16 • 2002
LINUX MAGAZINE
41
KNOW HOW
Linux Authentication: Part 1
PLUGGABLE AUTHENTICATION MODULES The traditional Unix
Plug in, swap out
security model is
Traditionally, any Unix application that needed to authenticate users was compiled against a specific authentication library. Many Linux apps still do just that. If you want to use a different authentication method with such an application, you have to rewrite and recompile it using the new library. PAM (Pluggable Authentication Modules) changes this: once an application has been compiled against the PAM libraries[1], the authentication method it uses can be reconfigured or replaced without any alteration to the app itself. It does this by making the authentication process transparent to the application. When an application needs to perform an authentication-related task (changing a user password, for example) it calls a generic PAM function. PAM then selects the actual module to perform the function (based on settings in the PAM config files) and returns the result to the application. The application knows nothing of the actual method used and simply acts on the result. This flexibility offers a range of advantages over traditional Unix authentication:
reliable but crude compared to the complexities of NDS or Active Directory. In this series of articles, Bruce Richardson will show how you can build security systems that put proprietary systems to shame
● You can reconfigure and replace authentication methods at will. ● Authentication methods can be chained together in complex ways. ● New methods can be added by simply installing the appropriate module, enabling you to add new methods as they are developed and to upgrade existing modules as they are improved or as security patches become necessary. ● Authentication policies can be created that control the way a whole range of applications (or your entire system) is secured.
In one aspect PAM is a thoroughly traditional Unix system: all of this can be achieved by editing a few text files.
Installing PAM The libraries
My advice: if they aren’t already installed, don’t bother. PAM is an integral part of almost all Linux distributions and as such is installed as part of the core libraries. If your distribution does not use PAM then not only will you have to install the PAM libraries but you will also have to recompile all the core utilities (login, su, passwd etc), which should use PAM if you are to make full use of the PAM security model. If you are determined to install PAM on a distribution that doesn’t use it by default, consult the documentation for that distribution carefully. Changing a system’s security model is by no means a trivial task.
The modules The most commonly used modules will have been installed with the PAM libraries. Most other modules should be available as standard packages for your distribution. If you download source tarballs for PAM modules, be sure to install the development files for PAM (which will also be available as a standard package) before compiling them.
PAM module types PAM provides functions to cover a wide range of authentication tasks (account verification, password checking etc) These tasks and the modules that service them are divided into four types:
Authentication Auth modules do two things:
These advantages have proved so compelling that almost all Linux distributions have integrated PAM into their setup – Slackware being the notable exception. 42
LINUX MAGAZINE
Issue 17 • 2002
1 They establish the identity of the user. This will usually involve a name/password challenge but
KNOW HOW
could use any alternative method (smart card or retinal scanning, for example). Some auth modules (such as kerberos) may additionally grant the user an authentication token, which they can use as proof of identity to request certain services. 2 They can grant additional privileges (such as group membership) based on the established identity. When identifying a user, any challenge or message to the user is initiated by the PAM module not the application. The application simply provides a means of passing messages to the user and returning their response to the module (by registering a conversation function). Therefore the user may not be challenged for a password if the auth module(s) can be satisfied by other means.
Account Account modules grant or deny access based on factors other than the user’s authenticated identity and perform other account management functions. The pam_time module, for instance, grants or denies access according to the time of day or the day of the week.
Session Session modules perform any tasks that are needed before or after a user accesses a service. This may include setting environment variables, mounting drives and so on.
Control flags The control flag determines how the success or failure of an individual module affects subsequent modules in the stack and the overall result. The allowed flags and their meanings are as follows: ● required: The module must succeed for the task to succeed. Regardless of the result, the execution of the stack continues. ● requisite: The module must succeed for the task to succeed. If it fails control returns immediately to the application and no more modules in the stack are called. ● sufficient: If the module succeeds the task succeeds and the rest of the stack is ignored. Otherwise the stack continues to execute. ● optional: Has no effect on the task’s success or failure unless no other module returns a positive or negative result. Stack execution continues. Note: there is an alternative, more complex syntax for control flags. This enables you to specify how a module affects the stack depending on the exit code returned by the module and also allows you to create complex stacks with alternate paths of execution. There isn’t space to discuss this method in this article, however. The simple syntax is amply sufficient for most needs while the complex syntax requires a good knowledge of the internals of PAM and PAM modules.
and each line has five columns (except for comments and empty lines, of course), thus: # # /etc/pam.conf #
Password These modules change the user’s authentication token (password, retinal print, smart-card ID number or whatever). Some modules contain components for more than one type of task. The pam_unix module, which emulates the standard Unix security model, contains components for all four task types. Not every application requires all four task types: some utilities (such as sudo) only need an auth task, though most require at least an auth and an account setting (thus allowing the administrator to limit the service to those with valid Unix accounts on the machine).
service-name module-type control-flag module arguments In the second method, seperate files for each application are placed in /etc/pam.d/. The contents are almost identical to those of /etc/pam.conf: # # /etc/pam.d/service-name # module-type control-flag module arguments These fields function as follows:
Configuring PAM
service-name
To configure a PAM-enabled application you must associate at least one module with each task-type that the application requires. Each line in the PAM configuration file(s) associates a module with an application and a task and provides configuration arguments. There are two formats for configuring PAM applications: the /etc/pam.conf file (deprecated) or the /etc/pam.d/ directory. In the first method there is one configuration file
Each PAM-enabled application identifies itself to PAM by this name, which is usually compiled into the program. In the second configuration method the service-name becomes the name of the application’s config file in /etc/pam.d.
Allowing the administrator to limit the service to those with valid Unix accounts
module-type This identifies the task for which the module is used. It can have the values auth, account, session or password. Issue 17 • 2002
LINUX MAGAZINE
43
KNOW HOW
Example 1: Default config (old)
Example 3: Deny by default
# # /etc/pam.conf # other auth required pam_unix_auth.so other account required pam_unix_acct.so other password required pam_unix_passwd.so other session required pam_unix_session.so
# # /etc/pam.d/other # auth required pam_deny.so account required pam_deny.so password required pam_deny.so session required pam_deny.so
control-flag Keyword(s) which determine how the module affects the overall success or failure of the authentication task. See the sidebar Control flags.
module The pathname/filename of the module. If it starts with ⁄ then it is an absolute path, otherwise it is a relative path, starting from the default location for PAM modules[2].
arguments The arguments that are passed to the module. Some are generic, others are specific to individual modules. Consult the application’s documentation or source to find out which tasks it requires and what servicename it uses. Most applications come with a sample configuration file or install a default one.
Mixing config methods Depending on how PAM was compiled on your system, you may be able to mix both /etc/pam.conf and /etc/pam.d configuration formats. In one compilation mode the pam.conf file is ignored if /etc/pam.d is present, even if the directory is empty (DANGER! DANGER!). In the other mode both configuration sources are read but settings from /etc/pam.d override settings in pam.conf. Which mode was used depends on your distribution but there is no gain in using the older, deprecated method so I recommend you use only the newer /etc/pam.d system.
Configuring settings If PAM has no configuration settings for a specific service it uses the settings for “other”. A typical
Example 2: Default config (new) # # /etc/pam.d/other # auth required pam_unix.so account required pam_unix.so password required pam_unix.so session required pam_unix.so
44
LINUX MAGAZINE
configuration for “other” is shown in the older style in Example 1 and the newer style in Example 2. Both setups use the pam_unix module[3], which emulates the traditional Unix authentication methods. So now any unconfigured service will use a traditional login process (password from /etc/passwd, group membership from /etc/groups etc).
Substituting modules The simplest way to alter a PAM setup is to replace the specified modules. For example, a more secure default configuration is shown in Example 3. Here the pam_unix module has been replaced with the pam_deny module, which always returns failure. Any unconfigured service will now refuse all access.
Stacking modules More subtle variations can be created by stacking modules. Each task type can have more than one entry for each service, the set of entries for any one task type forming a stack. The modules within a stack are invoked in the order in which they are listed. In Example 4 the pam_warn module, which logs details about the authenticating user, has been added to the auth and password stacks.
Example 4: Stacking # # /etc/pam.d/other # auth required pam_deny.so auth required pam_warn.so account required pam_deny.so password required pam_deny.so password required pam_warn.so session required pam_deny.so
Each module in a stack may affect the execution of the stack and its ultimate result, according to the control flag. The Control flags sidebar explains the different flags and Table 1 lists some of the more unusual modules you might use in your stacks.
Setting policies An easy way to create a consistent security policy across a range of applications is to create a configuration file in /etc/pam.d and create symlinks to Issue 17 • 2002
KNOW HOW
Example 5: Login configuration # # /etc/pam.d/login # auth required pam_issue.so issue=/etc/issue auth requisite pam_securetty.so auth required pam_nologin.so auth required pam_env.so auth required pam_unix.so nullok account required pam_unix.so session required pam_unix.so session optional pam_lastlog.so session optional pam_motd.so session optional pam_mail.so standard noenv password required pam_unix.so nullok obscure min=4 max=8 md5
it matching the service-name of each app. This can be done even if they do not all require the same range of task types: it does no harm to configure a task that an app will never use: an app that only requires auth settings can share a config file with an app that uses all four task types.
Things to watch Cover yourself
Always set a default (other) configuration and make it a secure one. This protects you if you forget to configure an application.
Practical examples Logging in with PAM
Example 5 shows a typical PAM configuration for the login. First, a walkthrough of the auth stack: 1 The pam_issue module prints the greeting in /etc/issue[4]. 2 The pam_securetty module checks to see if the authenticating user is root: if so the module will abort the stack unless they are logging in on a tty listed in /etc/securetty. 3 The pam_nologin module checks for the existence of /etc/nologin: if found it returns failure (and so prevents login) unless the authenticating user is root. 4 The pam_env module creates any environment variables listed in /etc/environment[4] or defined by the rules in /etc/security/pam_env.conf[4]. 5 Finally, the pam_unix module performs standard Unix password authentication. The nullok argument means that passwordless accounts are allowed.
It does no harm to configure an app we will never use
The account component of the pam_unix module checks the user settings in /etc/shadow to see whether the account is disabled, the password is due for changing etc. Finally, if both the auth and account stacks have returned success then the session stack executes:
Donâ&#x20AC;&#x2122;t trip over the extra modules
Table 1: Interesting modules
Modules like pam_env, which perform supplementary tasks that should not affect the success or failure of a stack, are supposed to return neutral result codes. To be extra safe, always use the optional control flag with such modules.
Module pam_cracklib
Components password
Shadow security
pam_permit
auth, account, session, password
pam_listfile
auth
pam_rootok
auth
If you are using shadow passwords (and if not, why not?) then applications which do not run with superuser priveleges will not be able to use modules such as pam_unix that authenticate against the standard password system. So Apache cannot use modules which authenticate against shadow passwords unless you either run it as root (not a great idea) or weaken the file security on /etc/shadow (a terrible idea).
Locking yourself out If you make a mistake configuring PAM then you may find that you cannot login to your system at all. If that happens then you will have to reboot the machine in single-user mode and fix what you broke. With this in mind it is a good idea to make a copy of your original PAM configuration files before beginning to tinker.
Description Include this in your password stack and it checks any proposed new password for weaknesses. Has an extensive set of arguments to allow you to specify a password policy. The reverse of pam_deny: does nothing and returns success. So the auth component waves the user through without prompting for a password, the password component falsely reports that the password has been changed etc. Grants access to services by consulting a text file to see if the user matches a list. Depending on the arguments passed the file may list usernames, groups, ttys, remote hosts, remote usernames or login shells and the module may either reject those listed and accept all others or vice versa. Returns success if the user is root. To give root password-free access to a service, place this before any password-requesting modules and flag it sufficient. Used in the standard config for su).
Issue 17 â&#x20AC;˘ 2002
LINUX MAGAZINE
45
KNOW HOW
Example 6: Restricted Apache access # # /etc/pam.d/httpd # auth requisite pam_listfile.so item=user \ sense=allow onerr=fail file=/etc/Apache-ssl/users auth required pam_ncp_auth.so server=AZURE account required pam_permit.so
Example 7: NT or Netware # # /etc/pam.d/httpd # auth sufficient pam_smb_auth.so debug nolocal auth sufficient pam_ncp_auth.so server=AZURE \ use_first_pass auth optional pam_warn.so account required pam_permit.so
1 The pam_unix module logs the username and service-name to syslog. 2 The pam_lastlog module prints information about the previous login. 3 The pam_motd module prints the contents of /etc/motd[4]. 4 The pam_mail module prints the status of the user’s mailbox.
Apache and PAM These examples are from my workplace. Both involve Apache and authentication across a network (we run both Netware 4 and an NT domain). To enable Apache to use PAM I installed the mod_auth_pam Apache module. In the first example the machine uses apache-ssl to serve up network administration pages. Only certain IT staff should access them and I wanted them to be able to use their Netware passwords. To achieve this I created /etc/pam.d/httpd as shown in Example 6. Here the listfile module checks to see if the user is listed in /etc/apache-ssl/users: only if this returns success does the pam_ncp_auth module authenticate against a Netware server. The second example, shown in Example 7, involves
Info Primary site Mailing list mod_auth_pam
46
LINUX MAGAZINE
Issue 17 • 2002
http://www.kernel.org/pub/ linux/libs/pam/ http://www.redhat.com/ mailing-lists/pam-list/index.html http://pam.sourceforge.net/ mod_auth_pam/
Notes [1] For an application to use PAM it must be explicitly (re)written to use the PAM libraries. There is no magic wand that can make a non-PAM application PAM-aware. [2] /lib/security on most current systems [3] The pam_unix module combines the functions of four older modules, which in newer set-ups have been replaced by symlinks pointing to pam_unix.so [4]This value can be changed by passing the module an appropriate argument.
an Intranet server hosting applications for our users, some of whom are on the Netware network while others are on an NT domain. First the pam_smb_auth module checks the username and password against the domain. If this succeeds, then execution halts there (because of the sufficient control flag). If there is no match, however, the pam_ncp_auth module tries Netware authentication. If that also returns failure then the failed attempt is logged. Two points of interest: 1 The debug keyword is a generic option that may be passed to any PAM module, causing it to write verbose information to syslog. I had some problems with the NT domain and this helped me. 2 The use_first_pass keyword is another generic option. It tells a module to use the password given to the previous module. If it were not used here, the user would have to retype their password before being authenticated against the Netware server. It wasn’t needed in the previous example because the listfile module doesn’t use a password.
In conclusion PAM allows you to configure the authenticating services on your machine in an extremely flexible way. It enables you to upgrade or replace authentication methods painlessly and to set general policies. The wide range of modules available make it possible for you to integrate your Linux machines into a varied networking environment. This is no trivial thing: certain proprietary software companies would like to own all authentication methods on your network, because then they own you. The other articles in this series will deal with specific authentication methods – and there’s a PAM module for all of them.
REPORT
GROUP DYNAMICS The South West (UK) LUG held its inaugural meeting on 30 November 2001 at The Crawford Hotel, Exeter. David Johnson reports
A
round 10 people gathered for the first ever meeting of the South West LUG at the Crawford Hotel function room in November. We had various demonstrations on show covering all things Linux. We brought along a few demonstration machines for people to mess with: the main one was running Red Hat 7.2 with SuSE 7.3 running in a VMWare Virtual Machine. There was also a laptop running Mandrake 8.1. Demonstrations included using a firewall on Red Hat, VMWare and mail clients in Linux (including Ximian’s Evolution). Various other distributions also put in an appearance and there was loads of information on offer including Linux Certification from SAIR and O’Reilly book catalogues (which we can offer a discount on). By far the biggest attraction of the meeting was the pile of freebies including SuSE 7.1 Professional (of which we brought 20). There was also a presentation from Rick Timmis, of local company SuperTramp (www.supertramp.co.uk), who told us about his company’s ongoing Windows to Linux migration which is underway with the help of ylem (www.ylem.co.uk). Rick explained the pros and cons of Linux for SuperTramp and needless to say the pros rather outweighed the cons. Particularly interesting were the costs of switching the whole company to Linux compared to costs of keeping Windows... As you might expect, much of the meeting was spent chatting (or rather debating in some cases). The topic of conversation was varied and included Linux, Windows, minimal Microsoft bashing (of course), the pronunciation of Linux (I knew that was going to happen) through to the composition of the universe (no-one knows how that started...). All in all I think everyone learnt at least something and it was certainly a worthwhile meeting, which has paved the way for many future meetings.
Info SWLUG – South West (UK) Linux User Group www.southwest.lug.org.uk
Issue 17 • 2001
LINUX MAGAZINE
47
ON TEST
MATROX MILLENNIUM G550 Jack Owen tests Matrox’s latest graphics card to offer dual head functionality
Millenium G550 Supplier Price Web For Against
Matrox £87.11 (plus VAT) http://www.shopmatrox.com Dual head functionality Poor 3D performance
rating
48
LINUX MAGAZINE
T
he new G550 graphics card is Matrox’s attempt to steal back its thunder from nVidia and ATi who have both launched a whole host of graphics cards in recent months. Whilst the G550 may be billed as the successor to the G450, from a hardware perspective the two cards are almost identical. The G550’s single processor controls both an HD-15 and a DVI port. Essentially this means that the card has two video sockets, enabling you to connect up two screens to your machine. The HD15 port is the standard analogue monitor connection, whilst the DVI port enables you to hook your computer up to the latest digital flat screen monitors (or another analogue monitor or TV with the adapters supplied). This AGP graphics card is not intended for intensive game use but more as a general workhorse: The 3D graphics engine is based on the G400 and comes with 32Mb of DDR (Double Data Rate) memory. The clock speed has been increased over the G450, so there is a marginal improvement in handling screens – ranging from 14 to 33 per cent depending on the screen resolution. The primary RAMDAC is set at 360MHz and the secondary at 230MHz. In reality, if you’re always playing the latest high-res games then this isn’t the card for you. If you’re only an occasional gamer then it can cope. As a comparison of the card’s graphics capabilities we tried out TuxRacer on an old PC with an ATi Rage card fitted. The game would load and play but only showed every tenth screen and proved completely unplayable. When we swapped to the G550 every screen was shown and the game became very playable. This was all due to the memory on the card and the RAMDAC speed. However, 3D support throughout the G400 series is poor. TuxRacer gave an incompletely rendered Tux, for example – he had a full outline but the lack of a black fill gave him a ghostly appearance. Although Issue 17 • 2002
this did not detract from the game such failings may be a drawback with the new 3D games coming online. Where the G550 does stand out is in its dual head capabilities. In the past I had used twin screens with two PCI cards (always a pain to configure) then with one AGP and one PCI. With the G550, the agony of configuring two graphics cards is dispensed with. Installation under Mandrake gave the option to configure dual monitors without prompting. Once you’ve set up two monitors on one machine, using the system becomes a wholly different experience. Your work habits quickly change and going back to one screen will soon be out of the question. New possibilities keep occurring and the extra screen real estate is simply marvellous. Blender or video editing now becomes wonderful and the ability to have a terminal screen always at hand is just amazing. How about having VMware running Windows on one screen whilst the other is reserved for your real system? On the Windows side, the card ships with a feature called HeadCasting, which enables you to use 3D models (generated from photos of yourself, or one of the supplied masks) in videoconferencing via the Internet. One of the best aspects of Matrox products is their Linux support. Matrox are particularly proactive and their messaging forums show fast responses and a helpful style. Here you can find quick fixes such as using insmod agpgart agp_try_unsupported=1 to load in the mga module. The G550’s resolutions are also impressive, ranging up to 2048x1536 at 32bit colour 85Hz (Vert) 110Hz (Horz) for the primary display and 1280x1024 at 32bit colour for the secondary. Overall if you spend your life playing Quake then this is not the card for you. If you want to get work done – and believe me twin screens is a dream – then this is the card for you.
KNOW HOW
QT
GETTING STARTED WITH QT L
ast issue we covered some of the ways we can add controls to our programs, and how we can have automatic layout managers. In this issue we will begin using an interface-building tool, called Qt Designer, to create our interfaces quickly and easily, and look into ways that we can embed these interfaces into our code. Before we get started though, lets look into some theory of how all this fits together. Today we are going to first create a simple form in Qt Designer and then merging it with our code so it will be displayed. This involves a few processes: ● 1. ● 2. ● 3. ● 4.
Create the form Create the code Add the form to the build system Compile
The first step is to create the form. This is done using the graphical Qt Designer. Qt Designer gives us the opportunity to select what kind of form we will be creating. There are options for a Widget, Dialog, Configuration Dialog, Wizard and more. Each of these templates gives us a form, which we can then draw on more widgets that we can use. When we save this form, Qt Designer stores it as an XML formatted file, which ends in .ui. This *.ui file contains a number of formatting commands that specify to another program (uic) how our form is organised. The purpose of uic is to take our *.ui file and to create a header and source code file with the C++ code needed to create the form. This code can then be utilised in your project to create the form. That’s the basics of how we will create the form and embed it in our code. We will now go ahead and look at each step in detail, and I will guide you through fitting the pieces together.
Getting going with Qt Designer In this article I do not have the space to give a complete step-by-step tutorial on using Qt Designer, but rest assured, it comes with a plentiful supply of documentation, which can be accessed via the help menu. I will however go through the main points to get started and cover the (few) pitfalls you may
encounter. Qt Designer has been well designed by Trolltech, so I am sure you will find it fairly straightforward. First of all, load up Qt Designer by selecting it from your GUI menu or by typing designer in a terminal. The main Qt Designer window will load up, and you will see a number of icons, toolbars and some status displays. The first thing we need to do is to create a new form from one of the templates. This can be done by clicking File/ New on the menu bar. You can then select the type of form to use. Click on the Widget option and you will then be presented with a form inside the Qt Designer window. This form is where you can add your buttons, text, input boxes and more. To get us started, we will be build the interface, as shown in Figure 1. In this form we have a frame, a button, a text entry box (called a line edit) and a label. To create these items, we use the toolbar buttons to select the relevant tool and then draw on the form. You can then use the Property Editor (activated with the Window menu) to set the widget’s properties and fine tune it. For the time being we don’t really need to set any properties, as we will discuss this later. Although we don’t really need to set any widget properties, there is one property you should set on EVERY form you make, and this is the name property for the form. This property is displayed when you click on the form background and look at the Property Editor. The reason why this is so important is that this name is the name that will be used for the class in the generated code uic makes. When you have created your form, select File/ Save and save it to the directory where your project is. The general naming convention for Qt Designer files is to call it the same name as the class name (the text you entered in the form’s name property, a little while back). Make sure you put .ui at the end of the filename.
We’ve come a long way since our tentative steps in the first article of this series. For our latest instalment, Jono Bacon shows us how create interfaces with Qt Designer
Adding the form to your project To add the form to your project, you can do it either manually or via your IDE. If you are using KDevelop, you can use the Add File To Project dialog to add the Issue 17 • 2001
LINUX MAGAZINE
49
KNOW HOW
.ui file (ensure you deselect the checkbox for adding header information). To add it to a Makefile.am (the configuration file for Automake), check near the top of the file and add it to the sources list. For example: qtprog_SOURCES = myclass.cpp main.cpp myform.ui
The input box built
The clever thing about this is that when you add your .ui file to a Makefile.am, uic is automatically run for you to convert your .ui file into code. If you’re not using Makefiles at all, you can manually convert the code as such: uic -o myform.h MyForm.ui uic -i myform.h -o myform.cpp MyForm.ui Now this has all been generated, the last step is to implement it into our program. This is where a little bit of clever C++ comes into play, and I will explain why.
Late binding and Qt Designer When using Qt Designer to create our interfaces we have a problem on our hands. The problem is that when you modify your *.ui file in Qt Designer, the XML *.ui is updated and therefore uic must be rerun on it to regenerate your C++ code. The problem with this is that you cannot then edit your generated *.cpp and *.h source files each time you update the interface. The main problem with this is how to add your slot methods to the class when they will be destroyed when the interface is updated. To resolve this problem you need to use a C++ technique called late binding. The idea behind this is that you create another class called an implementation class, which inherits your generated interface class. When you call the slot from the interface class it really calls the slot from the implementation class. This is best explained with an example, and we will use MyForm.ui interface that we developed earlier. Add the following code to your project:
File: myclass.h: 1 #include “myform.h” 2 3 #ifndef MYCLASS_H 4 #define MYCLASS_H 5 6 class MyClass : public MyForm 7 { 8 public: 9 MyClass( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 10 ~MyClass(); 11 }; 12 13 #endif
50
LINUX MAGAZINE
Issue 17 • 2001
File: myclass.cpp: 1 #include “myclass.h” 2 3 MyClass::MyClass( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ) 4 : MyForm( parent, name, fl ) 5 { 6 } 7 8 MyClass::~MyClass() 9 { 10 } When implemented into your build system, these files will show your interface, but do not have any slots. Let’s first discuss how it shows our interface. First, in myclass.h on line 6 we inherit MyForm, which is the name of the Form that we set in the Properties Editor in Qt Designer. As we inherit from this class, we need to line our constructors up so they pass the right arguments across. This is done on line 9 in myform.h and we can see the constructor in myclass.cpp passes the arguments from the MyForm constructor. If you check in your generated code for the form you can see it is built in the constructor, so by us inheriting MyForm, the MyForm constructor is called first and builds the interface. If this is confusing you, I suggest you get a decent book on C++; a good one is C++ FAQs 2nd Edition. OK, so now the interface is up, we need to add our slots. We can do this in Qt Designer. Let’s assume that we wish to have the button on our form call a slot called slotMySlot(). First click on the button and set the name in the Properties Editor. Next we need to actually create a connection between a signal and a slot. Luckily this is very simple in Qt Designer. Click on the Connections icon or select Edit/ Connections, and your mouse pointer will change to a crosshair. This crosshair can then be used to click on the button and drag the mouse so the red outline covers the form. This outline indicates which signals/slots will be used. You will then be presented with the Edit Conenctions dialog box. On the left-hand side we can see the signals available for the button, and on the right is the selection of slots we can use. At the moment we have not created any slots so the list is empty. We can add a slot by clicking on the Edit Slots button. Click on New Slot and add slotMySlot() in the text box. Click on OK to finish. You can then select the clicked() signal on the slotMySlot() slot and the connection is made automatically. Click OK to finish. You can now save your *.ui file. We then modify the above files so we can add the slots. Are files are now:
File: myclass.h 1 2 3
#include “myform.h” #ifndef MYCLASS_H
KNOW HOW
Linux Semi
4 #define MYCLASS_H 5 6 class MyClass : public MyForm 7 { 8 Q_OBJECT 9 10 public: 11 MyClass( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 12 ~MyClass(); 13 14 public slots: 15 virtual void slotMySlot(); 16 }; 17 18 #endif
Still not sure about the use of Linux in your business or school or university ? Then why not come to our Linux seminar in Sheffield on the 21st of February. We will have several speakers from various parts of the world who are established experts in their own
File: myclass.cpp 1 #include <qmessagebox.h> 2 #include “myclass.h” 3 4 MyClass::MyClass( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ) 5 : MyForm( parent, name, fl ) 6 { 7 } 8 9 MyClass::~MyClass() 10 { 11 } 12 13 void MyClass::slotMySlot() 14 { 16 QMessageBox::information( this, “Notice”, “Woohoo! slotMySlot() has been called!”); 17 }
● Georg Greve who is the President of the European Free Software Foundation will explain some aspects of free software in the world of commerce. ● Roger Whittaker will give a talk about the developments in Linux in the past ten years. ● Jeremy Allison describes how to put it all together and also something about Samba. Samba is the networking software that is a free replacement for NT4 and Windows 2000. Jeremy who is originally from Sheffield will be flying in from California to give his presentation.
The modifications here are in the addition of the Q_OBJECT and public slots to the myclass.h, and on line 15 we can see the slot. Note the addition of the keyword virtual. This keyword says that this slot will be called using the class of the object that calls it. So if, for example, we have an object called aObj which is created from class A and bObj which is created from class B, both classes can have a slotMySlot() but aObj/ slotMySlot() will call A::slotMySlot() and bObj/ slotMySlot() will call B::slotMySlot. This is why when we create an instance of MyClass in main.cpp, the MyClass version of slotMySlot() is called.
Wrapping things up
The seminar will start at about 10 a.m and finish at about 5pm. The venue is the Sheffield Wednesday football ground at Hillsborough in Sheffield. Later on in the same evening we will move to Sheffield Hallam University to continue with a British Computing Society meeting and some more presentations from the speakers. For more information and a map go to
Today you have learned some complex concepts in C++ and how to apply these concepts to building interfaces in a rapid fashion with Qt Designer. Again, I suggest you supplement this information by using resources on the Internet, and maybe visiting #qt on irc.openproject.net. We will be finishing this series in the next issue where I will be looking at some of the other remaining features of Qt that may be useful to you. Have fun! Issue 17 • 2001
LINUX MAGAZINE
51
KNOW HOW
Tips & tricks
PROBLEM SOLVED Linux and its many associated programs can present a number of problems to even the most seasoned of users. Thankfully, Linux Magazine’s team of experts is here to point you in the right direction
StarOffice 5.2 Question: Is there an option under StarOffice Calc for rapidly moving a larger area of cells to another position? As I am working on documents where I often have to do this, I find the clipboard method too time-consuming. Answer: An area selected under StarOffice Calc can be moved very easily using drag-anddrop. To do this, first mark the area you wish to move and then click with the left mouse button in this area. Hold down the mouse button. As soon as you move the mouse, the content of the entire marked area moves with it. When the data arrives in the right place, simply let go of the left mouse button. Question: I have to position objects, such as graphics, in my text document with millimetre precision. But my mouse control is too fuzzy for me. Is there any remedy for this? Answer: Under StarOffice Writer it’s possible to blend in a freely-configurable grid, on which
StarWriter character chooser
52
LINUX MAGAZINE
Issue 17 • 2002
you can align your objects. It works in a similar way to graph paper and even has the property that its individual dots can “attract” objects while moving. To activate the grid, go to the Tools/Options... menu and from the window that now appears select Text document->Grid in the left-hand list. By selecting the Visible grid item you can now activate the grid. With Snap to grid you instruct StarOffice to allow all objects to be attracted by the grid points. Question: I often have to insert lots of images into StarOffice-Writer documents. This makes my documents pretty big when it comes to saving. Is there any option for keeping this within reasonable limits? Answer: When you add a graphic to a document using Insert/Graphics/From file, you can activate the Link button on the bottom edge of the file selection window. This means that only a reference to the corresponding graphics file will be saved in your document. This obviously has a positive
KNOW HOW
Installation Question: I am running Red Hat 7.1 and tried to upgrade my Mozilla browser. I used the command rpm -ivh mozilla-0.9.70.i386.rpm but it did not work. I am using a PIII and not a 386.
and then install XP and still access files on the windows partition from Linux? Answer: Firstly, do not delete your Windows 98 installation as the Windows XP upgrade requires it to install, otherwise you would need the Windows XP full version. When upgrading make sure you choose FAT32 partitioning for the Windows XP and not NTFS (which is the default) so that the Linux can access it. Question: I installed Linux and answered all the questions. When the machine rebooted it came back with LIL and stops. Why and what causes this?
GNOrpm running. Much easier than trying to remember all the witch values
Answer: The i386 part of the rpm name indicates that it is built for Intel (or compatible) 386 (or compatible) processors. Your PIII is backwardly compatible and so this is fine. Your Red Hat 7.1 already has mozilla running and so you need to upgrade the files. Use the command rpm -Uvh mozilla-0.9.7-0.i386.rpm. The U switch is for Upgrade and the vh gives an easy to read log of what is happening. Using one of the graphical package handling systems, such as GNOrmp, may be easier. Question: I use Red Hat 5.1 and boot from a floppy. I broke the floppy but want the information on the hard disk. Does anyone make the floppies for sale? Answer: Use a modern distribution floppy disk or CD to boot into the rescue mode. Once in, mount the hard disk partitions and use chroot to the mounted directory. You can then use the mkbootdisk command to generate a new boot floppy for yourself. Question: I currently dual boot Linux and Windows 98. I bought the new Windows XP upgrade. How do I delete 98
effect on the size of your document but bear in mind that when archiving or passing on the text document, the corresponding graphics file must not be left out. Question: I would like to transfer tables from an old dBase database into a new database using StarOffice Base. How should I do this? Answer: First, make sure that the old database is accessible in the Explorer window. Now select New/Database and enter the name of the new database in the properties dialogue. Under the Type heading select the format in which the old database is stored. Click on the Search button and select the file or directory representing the old database. After clicking on Open change to the register
Answer: LIL is an error message from the LILO boot loader. The type of error is represented in the number of characters printed. LIL indicates a geometry mismatch in the hard disk as the second stage of the boot loader has started. Use a rescue floppy disk or CD and rerun the LILO. Question: I am about to do a second install on the same machine. What should I do to make sure I do not lose my currently installed system? Answer: Make a boot disk with all the modules needed by running: ls /lib/modules this returns the version number of the kernel you are currently using. Now use mkbootdisk followed by the version number you have just found. Question: How do I physically test my RAM under Linux? Answer: You can create a floppy disk with a RAM test utility. This can be downloaded from http://www.teresaudio.com/memtest86
Tables and put a cross against all tables which are to be used later. Complete this process by clicking OK. Finally, in the Explorer window, drag the required table out of the old database to the Tables entry in the newly created database. Question: How do I type funny characters? Answer: In StarOffice use Insert/Special Character and select what you need. In the KDE panel there is an applet called Character Picker, which has ten of the most common symbols that when highlighted can be copied with Ctrl+V. You can edit these by right clicking just to the left of the applet and choosing preferences. Then you only have to remember the AltGr combination to add others. Issue 17 â&#x20AC;˘ 2002
LINUX MAGAZINE
53
KNOW HOW
WordPerfect Office 2000 Question: WordPerfect keeps crashing on my computer when it has been in use for a long time. Firstly, WordPerfect marks correctly spelt words as incorrect then tells me that I no longer have the right to save the document – making it impossible to back up my changes. Only after a new start does WordPerfect appear to revert to the initial position. Answer: This problem appears to be due to a program error in the Synchronisation interrogation. This is responsible for automatically displaying a proposed correction for mis-spelt words in the lowest toolbar. After some time, this automatic function appears to trigger strange behaviour throughout the entire program. The only way to correct this problem is by completely deactivating this function under Extras/Proofreading/Synchronisation interrogation. Question: WordPerfect offers the option of exporting documents as PDF files. When I do this I have problems with images I have previously inserted into my WordPerfect document. Sometimes these do not appear at all in the PDF file or the Acrobat Reader reports an error when displaying the page. How can I export my images correctly? Answer: Documents containing images cannot be simply converted into PDF format under WordPerfect. The most common problems are those with images in the WPG format, i.e. vector images. You can get round this by integrating all the images
into your WordPerfect document as BMP files. You can do the appropriate format conversion with Corel Presentations, which comes with the Corel WordPerfect Office package. Another reason for missing images can be an incorrect reference. In order to check that they are correct, first click on the image with the right mouse button and then select Content from the drop-down menu. In the upper area you should now see the path to the original file inside the input field. If this field is empty it may be responsible for the errors in the resulting PDF file. To correct this problem, click on the symbol to the right of the input field and select the inserted file again. Question: I want to save a large text document in WordPerfect in PDF format. WordPerfect finishes its task very quickly, but when trying to open the file, Acrobat Reader reports that it is damaged. Have I stumbled across a program bug in WordPerfect? Answer: Even if it appears that WordPerfect has successfully completed the conversion procedure it can still takes a bit of time until the PDF file has been completely created in the background, especially with large documents. You will just have to wait a moment and then try once again to open the document. You can also follow the creation procedure inside a file manager (such as Konqueror). To do this, change to the directory in which the PDF file is being made, mark it and then keep clicking at short intervals on the update button. Keep an eye on the file size: when it stops growing, the file is complete.
Corel PhotoPaint 9 Question: PhotoPaint needs a FontTastic server, which is available for glibc-2.1 and glibc-2.0. The installation under Red Hat and Mandrake has been going wrong since the conversion to glibc-2.2. However, it works with SuSE, which also uses glibc2.2, so there must be a workaround. I have installed PhotoPaint by means of the corresponding installation routine. It is not until I start accessing Wine that the FontTastic server is missed. How can I get PhotoPaint to run with these aforementioned distributions?
Answer: The cause of this problem is not in the glibc libraries, but a conflict with an already existing symbolic link, init.d, in the directory /etc. In a similar manner to linking under Windows, a symbolic link is a file which points to another file or a directory. Under Red Hat and Mandrake the symbolic link init.d points to a directory containing script files which are executed in the start procedure of the Linux system. init.d is added to your system automatically by Red Hat or Mandrake on installation. PhotoPaint also brings the same link with it in the Fontserver packet and tries to overwrite the existing one. This attempt fails on the aforementioned distributions and the installation is interrupted without any return information. This problem can be corrected as follows: Install PhotoPaint as usual. Then open a terminal window and enter the command: rpm -i ––excludepath /etc <path to U PhotoPaint-Installation program>/dists/U redhat/i386/fonttastic-glibc-2.1-U 2000.06.22.14.00-1.i386.rpm
54
LINUX MAGAZINE
Issue 17 • 2002
KNOW HOW
Sound the correct driver is being used. The reason the level is so low is due to the sound mixers being incorrectly set. Start one of the mixers such as xmixer or kmix and adjust the levels then rerun sndconfig. Question: On my Windows setup I play lots of MP3 files that I have downloaded. Nullsoft say they may port Winamp 3 to Linux but I want to play them now. How do I convert the files so they will work under Linux? Answer: MP3 files will play fine under Linux. The debate is still ongoing over which player is the best but certainly xmms from http://www.xmms.org or Kmediaplayer work well. You can convert the MP3 files, if you want, into Ogg Vorbis or .wav files with commandline utilities such as mp32ogg or mpg123. You will not gain any quality and .wav files are much larger. The kmix mixer can be used to set output to the speakers
Question: I am trying to set up my soundcard. I run sndconfig and it tells me the right sound chip is found. It plays someone speaking but very quietly even though I have turned the speaker volume all the way up. I am using RH 7.2 with a SoundBlaster Live 1024 card and Prism Joy speakers? Answer: That someone speaking is none other than Linus Torvalds and he is prounouncing “Linux”. As sndconfig has found your sound chip and you can hear some sound shows that
xmms running
Display For example, if the setup program is in the directory /mnt/cdrom/PhotoPaint9, then the command will be: rpm -i ––excludepath /etc /mnt/cdrom/U PhotoPaint9/dists/redhat/i386/fonttastic-U glibc-2.1-2000.06.22.14.00-1.i386.rpm When you do this make sure that you enter the spaces correctly. If you’re using an older distribution (one year or more), which is based on the old glibc 2.0 library, then in the above command you’ll have to swap the numbers 2.1 after glibc- for 2.0. You should find the version number in the documentation for your distribution. After pressing the Enter key, a few error messages will now appear, which you can ignore. Now start PhotoPaint from the Start menu. When you do so, the program first attempts to start the Fontserver, which is also displayed in a corresponding window. After another initialisation PhotoPaint should report in, ready for use.
Question: I have tried to install Mandrake 8.1 and everything seems fine. I am using a nVidia GeForce2 64Mb MX400 graphics card. On starting the screen keeps flashing then says it has respawned too many times. After five minutes it starts flashing again. I have tried the install three times and it always ends up the same. Answer: Mandrake will recognise the card and install the driver. Start the machine and when it stops flashing, run the xf86setup program in a console. This will find the card and install it correctly. Alternatively, when it stops flashing login in as root and run XFdrak ––expert –noauto. Question: My Red Hat 7.2 starts in text mode only. To get KDE working I have to use startKDE. How do I get this to work without the effort? Answer: You need to create the file .xsession containing a single line with the command startkde. Issue 17 • 2002
LINUX MAGAZINE
55
KNOW HOW
Question: Mandrake 8.1 starts KDE but no cursor is shown. I know it is there as I can start tasks but it is being drawn invisibly. How do I change it to something more visible, as without it KDE is not useable. Answer: Edit the /etc/X11/XF86Config-4 file and remove the # from in front of the software cursor line. Now restart KDE and the cursor should be visible. Question: How do I change the resolution of my desktop. Do I really need to run Xconfigurator everytime? Answer: You may have to run Xconfigurator one more time to set up all the possible resolutions that you require. To change between differing resolutions, for example to play some games, use the Ctrl, Alt and +/- keys where the “+” key (or “-” key) is the one on the numerical keypad on the keyboard. Question: I have seen people running desktops for different logins under X at the same time. How is this possible? Answer: You can run more than one X server by simply starting another one. If you have just one desktop currently running, use the Ctrl+Alt+F1 combination to get back to another virtual console and log in. To start a new X server use the command: startx — :2 You can now switch between the two X servers with Ctrl+Alt+F7 for the first and Ctrl+Alt+F8 for the second.
test the printer output
Utilities Question: How can I tell if my printer is working properly? Answer: Well you could try printing a file. From the K panel choose Configuration/ Printing/Kups. This will enable you to send a test page to the printer. Question: I am running KDE as my desktop but I want my own links on the bar at the bottom. Is there a tool for configuring this? I need Netscape to be included. Answer: The KDE panel is easily configured clicking on the panel with the right mouse button. Choose Panel/Add/Button and search for Netscape.
Commands Question: What are Md5sum files and why should I download them when I want to get updates to files? Answer: md5sum files are a way of knowing the file you have downloaded is not corrupt. The md5sum file can be thought of as a checksum calculation and by comparing it to the original file you will be able to tell if your download was without errors. To check a file, change directory to where both the downloaded file and the md5sum file is located. Run: md5sum
downloadfile
and you will be told if it is fine. You can then delete the md5sum file. Question: I have downloaded some games that end with tar.gz and .tgz how do I install them? Answer: The tar or t part of the extension means it is in a tape archive format. The gz part means that it is also compressed under GnuZip. Change directories to where the files
56
LINUX MAGAZINE
Issue 17 • 2002
are located. Type tar -zxvf filename.tar.gz or tar -zxvf filename.tgz. The x means extract the file, the z switch means unzip the file first. If the file ended in just .tar you would not need the z switch. Question: At a user group meeting I watched someone using the shell. He typed too quickly for me to follow half the time, but I am sure he didn’t actually type that fast. Answer: What you saw was most probably the use of the history and completion functions. In the shell, if you press the up arrow on the keyboard the last entered shell command is typed for you. Press the up arrow again and the command is replaced with the prior command to that. The Tab key acts as an auto completion key. If we have a directory with three files a.txt, b.txt and b.rpm. We can type a then press the Tab key and the .txt is filled in for us. If we type b then the tab key the “.” is completed for us but no more, as the autocompletion cannot choose. If we press r and Tab again the pm is completed for us. With long file names this becomes invaluable.
KNOW HOW
Online Question: How do I convert my address book and email from Eudora to a Linux system. I want to run Mandrake and not have to use VMware to read my mail.
lock file will report back with the job number still running. Open up a shell and use the kill -9 1234
Answer: The address book file in Eudora is called nndbase.txt. Open this file in a text editor and delete the first two fields for each address. This will then leave the name and email address fields. Save this file in your .kde/share/apps/kmail/ addressbook folder. Eudora uses Unix-style mailboxes (mbox format) so you can just copy the files ending .mbx from your Windows system over to your new Linux system and KMail will be able to browse them. Question: Netscape stopped loading a page and appears to hang with no activity. I closed it down but when I restarted it said that it was already running. The bar at the bottom had no box for a Netscape session running. I had to turn the machine off. How do I stop this happening? Answer: The Web page is question forked to fire off another Netscape session that is running in the background. Although this is hidden when you try to start another session the
command where 1234 is the job number. You can use kill -12 1234 if you want to close the bookmark and history files first. Question: I need a tool that is capable of getting my Hotmail emails and putting them onto my SuSE PC Linux box. I really want it to log on as me and retrieve it all so I can read it later. Answer: Hotmail allows POP3 access so to retrieve the mail you need to run Fetchmail. This can be set up with the fetchmailconf tool. Once you have this working using the fetchmail command you will be able to automate the process with the cron daemon. You can set the timing to pick up the mail as often as you want to connect.
Question: Is there a LapLink equivalent program for Linux? I want to transfer some files from an old DOS machine and I don’t have a network. Answer: The program you are looking for is PLIP which relies on having a parallel to parallel cable. If you only have serial to serial cables available you may want to try SLIP, though this will obviously be slower. Question: I need to type in insmod agpgart.o when I boot before I can start X. How do I get the module loaded everytime? Answer: You could recompile the kernel (honestly, it’s not hard) or more simply edit the /etc/rc.d/rc.modules file to include the module. Question: How do I change the shell colours? I am partially sighted and black on white is too bright for me to focus on. Answer: With xterm you can set the colours quite easily. In a terminal use xterm -bg black -fg white & and see if this is acceptable. Keep changing the colours until you are happy. Once you have found
different colour schemes
your perfect combination you need to set it as the default configuration for every time you start the xterm, by editing or creating an Xresources file. For the above option you need the lines xterm*background: black xtrem*foreground: whiteman xterm In Konsole this is easily changed by using the settings button then Schema to choose the settings you want. In GNOME terminal you can use the colour selector under settings. Issue 17 • 2002
LINUX MAGAZINE
57
FEATURE
Maximising multimedia on the web
BROWSER PLUG-INS Static, fixed, web pages are dead: it’s now a world of streamed audio and video. So what does a Linux user need to make use of all this? Colin Murphy explains
I
’m personally quite happy with static Web pages. For the main part they’re informative, always quick to load even if resources are in short supply, and they helped the Internet becomes what it is today. But not for much longer, or so it seems – you can’t go near a site these days without being blinded by graphics, both fixed and moving, being shoved at you. The technology is there to send out this information so out it goes, whether you want to receive it or not. This is all well and good for advertisers – the eye and ear-catching nature of these pyrotechnics are ideal for those intent on making you look at their wares just long enough for the name and product to slip into your sub-conscious – but this just made me all the keener to avoid it. However, now, much more than ever, the information that you actually want is going to be found on Web sites that rely on you working your way through these flashy sites. Increasingly, the very thing you’re looking for may be noisy or moving,
which means that you need to make sure that your Web browser can deal with these forms of data, with a little help from plug-ins.
Plug-ins There is a wide range of different plug-ins in use on the Internet today, but not all of them are available for Linux straight off. Much of the information out there in Internet land is provided in a proprietary format, which usually means that you need to pay someone to make full use of the data held in that format by buying a plug-in. For example, you can listen to radio via the Internet: broadcasters provide their output as a stream of data, which gets pushed out over the network. For most Internet radio broadcasts, this information is sent in the proprietary Real Audio format. To be able to listen to the radio in this format you need to have access to a Real Audio plug-in. Luckily enough, there is a Real Audio plug-in Linux
Java as a plug-in
Plug-ins Tools to enhance and extend the operation and functionality of an application. With Internet browsers, this enables you to use types of data not originally associated with Web pages. It usually frees you from the chore of having to download a chunk of data, only to then have to run it in some external application.
58
LINUX MAGAZINE
Java is a platform independent object-oriented programming language, used for writing applets that are downloaded from the Internet by a client and run on the client’s machine – usually by the browser. The data that you download is run by the Java client, but inside the browser. Take a look at http://www.magenet.com/~julie/java/rubik to see some Java in action (see Figure 3). You might find that you need to install Java yourself. There is an Open Source version of Java called Kaffe, which is supplied with most of the Linux distributions. However, most people seem to prefer to use the version provided by Blackdown Java. Unless you plan on developing Java applications you will only need the Java Runtime Environment, or jre, a copy of which you’ll find on the coverdisc. Figure 3: A Java-enabled Konqueror
Issue 17 • 2001
FEATURE
Users can use, which is maintained by the Linux community. However, because of its proprietary nature, you will only get the Real Audio plug-in included in a Linux Distribution if you get one of the more expensive boxed sets. This means it won’t be set up by default if you’re using a distribution you got from CheapBytes, for instance. You will have to go and download it yourself, which is not ideal.
Ogg Vorbis Luckily, work is in hand to produce non-proprietary audio streams, thanks to the developers of Ogg Vorbis. The challenge is now to get the broadcasters to use and accept this alternative streaming format. The BBC is currently running Ogg Vorbis trials, so with a little campaigning and persuasion, the dream of all of the BBC output being broadcast in a stream we can all appreciate might just become a reality. Take a look at http://support.bbc.co.uk/ogg and maybe even email oggfeedback@bbc.co.uk. The browser needs to be configured to make use of a plug-in, and this will often happen automatically during the installation. The Ogg Vorbis plug-in is included with most distributions these days, and so is likely to be configured for you. The Real Audio plug-in will configure itself automatically for Netscape during its installation, but you will need to take manual steps to get it to work with other browsers like Mozilla or Opera. Luckily these browsers have details in their documentation describing how this is done.
DjVu – a world without paper? This new world of information isn’t only video and audio-based, according to the people at DjVu, 90 per cent of world information is on paper. Bringing this wealth of information to the Internet has had its problems. The high resolution needed to read a scanned-in document means that files sizes grow to beyond manageable proportions. The DjVu image compression technology developed at the AT&T Labs offers a solution to this problem. With DjVu, it seems that a 31Mb TIFF file can be reduced to just 70Kb. There’s a browser plug-in for Linux – DjVuLibre – that enables you to view this information and manipulate it all in your browser. When viewing a DjVu document in an enabled browser you are given a range of facilities to help you view it better. In Figure 1, an area of text has been highlighted, at the release of the mouse key the view from Figure 2 can been seen. The image isn’t being reloaded, rather the browser is redisplaying it to our requirements. This plug-in is compatible with all of the browsers you’re likely to use: Netscape, Mozilla, Konqueror and more. Figure 1: Some text in DjVu format, with a region highlighted for enlargement
xmms – the sound of a planet One Linux program that uses plug-ins is xmms, the multimedia player that comes with most installations. You will most likely have called upon the services of xmms should you have selected any of the Ogg Vorbis links on the BBC Web site. If your speaker system includes a sub-woofer, you can put it through its paces with the “tone” plug-in. With xmms running press Ctrl+L to open up the Location to play box and enter the location tone://30. This calls upon the Sine Wave generator plug-in and produces a 30Hz tone. Wait and see how long it takes for the neighbours to come and complain at full volume. The test is to see how far they come from.
Figure 2: The previously selected text enlarged. Also note the control buttons that appear from an auto-hiding menu
What’s not available? There are lots of different plug-ins, some are more use than others. But the only plug-in that we really miss out on is that for QuickTime, though even here there is a solution. A product call Crossover will enable you to use many of the Windows plug-ins, including QuickTime.
asp – Shockwave and Flash Macromedia Flash files (they have a suffix .spl) are designed to deliver low-bandwidth animation and presentations. There is a browser plug-in for Linux, but this time it is only compatible with Netscape and Opera – there’s no support for Konqueror. You may also come across Shockwave files (with a suffix .swf), which luckily enough are dealt with by the same plug-in. It can be a bit confusing as the Macromedia site offers downloads for both formats, but then offers you the same file.
Info xmms http://www.xmms.org Flash and Shockwave http://www.macromedia.com/shockwave/download/ alternates DjVu http://djvu.sourceforge.net Blackdown JDK Linux http://www.blackdown.org Crossover http://www.codeweavers.com/products/crossover
Issue 17 • 2001
LINUX MAGAZINE
59
REPORT
David Woodhouse
JFFS2 Richard Ibbotson caught up with Red Hat’s David Woodhouse to get the lowdown on the JFFS2 filesystem
D
avid lives in Cambridge and describes himself as a “born and bred Norfolk countryman”. His interest in programming developed from an early age when he began hacking BASIC. David is now a contractor for Red Hat working on embedded GNU/Linux projects and is responsible for the kernel drivers for memory technology devices. He hopes that one day he will become a kernel hacker. David’s latest creation, JFFS2, might not sound all that glamorous but it will make some useful changes to the hard disks of many people when it becomes a part of the ordinary GNU/Linux based system.
What’s it all about? Until recently the usual approach for using flash memory technology in embedded devices was to use a pseudo-filesystem on the flash chips to emulate a block device. The original JFFS was a log-structured filesystem, developed by Axis Communications AB in Sweden, specifically for use on flash devices in embedded systems. Later on Red Hat came along and did some more development work on it. JFFS2 is the end result of their labours. It’s aware of the restrictions imposed by flash technology and operates directly on the flash hardware thereby avoiding the problems of having two journaling filesystems running on top of each other. There are plans to port it to eCos.
Flash memory Flash is a particular type of EEPROM memory which is available in the NOR version, or you can also get hold of the newer NAND version at lower cost. Both types can set a bit in a clean chip to a logical one and both can be set to zero by a write operation such as storage of data. In order to provide for wear levelling and reliable operation without problems, sectors of the block device (hard drive to your ordinary PC user) are stored in various places on the medium and a translation layer is used to keep track of the location of sector. This layer is effectively a type of journaling filesystem. The flash translation layer is a part of the PCMCIA 60
LINUX MAGAZINE
Issue 17 • 2002
David Woodhouse at the West Yorkshire Linux User Group meeting in December
specification, which is used in most laptops. It’s an unfortunate fact of life that this and similar technologies are held together with patents that more or less prevent further development, or if development is allowed then the legal ramifications are so extreme that it makes life as an engineer or developer very hard indeed. GNU/Linux supports FTL and similar technologies but it’s use is deprecated and is really only meant to be there for backward compatibility. Even if the patent issue could be circumvented the technology itself is not seen as the best solution to a complex list of technical issues. It would be much better if there were no extra translation layers in between. In the design and implementation stages, the original JFFS included the useful thinking that the users of the finished hardware would probably do some very stupid things to it – things like the power being suddenly switched off by a user who didn’t know how to close down a computer properly. Or to
JFFS2 Common Node Header
REPORT
put it another way, battery-powered devices are just seen as simple appliances like the common kitchen kettle or iron and they are treated in a similar way. Such design ideas are often the province of your average electrical engineer or design engineer. Many man hours are spent on deliberating over these kinds of issues. The design of the French and Japanese rail systems contain many examples of this way of doing things. Whether it’s Concorde or just a chip on a board then quality control must be a part of the design process.
The original JFFS was a log structured filesystem or LFS. Nodes containing data moved along the data storage device in a linear fashion until all of the storage space had been used. There is only one type of node in the log, which is referred to as ‘struct jffs_raw_inode’. When the medium is mounted, all of the data is read and each inode reconstructs the data tree and the amount of information that is available for use by an operator. This is all very simple so far and most people could probably understand what all of this is about. JFFS1 also does garbage collection. This takes care of old writes to the media by collecting the data from the tail of the log and putting it at the front end of the log. This takes care of old inodes, which might just be taking up dirty space, which were left behind by old writes. Kernel threads usually take care of this kind of activity. However, the developers of the technology will tell you that this may not be the best way to do things. Certain aspects of JFFS had not been tested in Axis products and writing data other than at the end of the file did not work, and deleting a file while a process still had a valid descriptor for it could cause a kernel oops. Not the sort of thing that wins friends and influences people! JFFS did reach a point in a few weeks after testing where it was stable and reliable. There were however thought to be problems with garbage collection, compression and hard links which needed to be sorted out.
allowed to in JFFS1. This makes for increased efficiencies in the garbage collection code. More intelligent decisions are carried out and a particular location for collection may be more favourable than another. Erase blocks will be on a clean_list or a dirty_list. There is also a free_list, which contains a valid mode to show that the block was correctly erased. There is what is referred to as a third change when JFFS2 is looked into when compared with JFFS1. There is a separation between directory entries and inodes. At the time that this was written there are three types of nodes defined and in use with JFFS2. These are: JFFS2_NODETYPE_INODE, JFFS2_NODETYPE_DIRENT and JFFS2_NODETYPE_NODEMARKER. JFFS2 works by examining a heuristic threshold and garbage collection starts mounting the filesystem with a multi stage process. First of all a physical scan is made which builds a full map of what’s happening followed by a second scan which detects inodes that have no remaining links on the filesystem and a deletion is made. A third pass is made to free the temporary information which was cached for each inode. Future plans for JFFS2 include improved fault tolerance. There are several other aspects of the project which are in the minds of the developers for improvement, of which transaction support is one. Although JFFS2 is still in its early days it has quickly grown up and is seen to be a worthwhile technology, which can be relied upon for its stability. Improvements can only draw more attention to it in the coming months and years. JFFS was merged into the GNU/Linux kernel prior to the release of the 2.4 kernel. Its future as an Open Source project rather than a dusty and forgotten object of desire is assured.
A new solution
Getting involved
JFFS2 was the solution to these perceived problems. In January 2001 a discussion began as to how to completely re-implement the original design so that something called JFFS 2 would be brought into the R&D arena and eventually sold on to a prospective end user. A number of different things were tried out before the version that is around at the time of writing was arrived at. Various node headers proved to be slightly unreliable and a CRC was added at a later stage. Also the bugs caused by garbage collection in a strict order were sorted out by allowing each erasable block to be treated individually. The nodes are also not allowed to overlap block boundaries as they were
If you want to get involved with JFFS2, or you want to know more about it, why not have a look at some of the web pages mentioned below? You should find David’s email address on at least one of them.
In the beginning
Raw node reference lists.
The author Richard Ibbotson is the Chairman and organiser for Sheffield Linux User’s Group – you can view their web site at http://www. sheflug.co.uk
Info Original JFFS JFFS2 eCos JFFS mail archive
http://developer.axis.com/software/jffs http://sources.redhat.com/jffs2 http://www.redhat.com/embedded/technologies/ecos http://mhonarc.axis.se/jffs-dev/threads.html http://lists.infradead.org/mailman/listinfo/linux-mtd
Issue 17 • 2002
LINUX MAGAZINE
61
PROGRAMMING
Jython: integrating Python and Java
COFFEE AND SNAKE Implementing the Python interpreter in Java instead of C brings advantages for both languages. Andreas Jung shows us just some of the possibilities that Jython offers
A
s programming languages go, it may appear that Python and Java have nothing in common. Take a closer look and you’ll find that’s not so. Both languages are object-oriented and organise their extensions in modules or libraries, which they import at runtime. For this reason alone it makes sense to combine the advantages of both languages. A Python interpreter makes it very easy to provide Java applications with extensive scripting facilities and on the other side of the coin, the odd Java class can be very useful in Python programs. Consequently, a Java implementation of the Python scripting language has been developed over the last few years. It’s equivalent to the C-Python version maintained by Guido van Rossum; the aim of the developers being to provide the same functionality as C-Python in the Java version. Initially the project was named Jpython; nowadays it is now simply as Jython.
Graphical installer Jython is currently in version 2.1a3 and this can be downloaded from http://www.jython.com. The version numbers always follow the official Python releases, so that the features and functionality of the Java variant should always mirror those of the C version. Due to its very nature, Jython requires the installation of a Java environment, such as the JDK from Blackdown or IBM under Linux. Under Windows the JDK from Sun or Microsoft’s VM (Virtal Machine), also known as Jview, are the most suitable alternatives. To install Jython you’ll need the file jython21a3.class; the link for downloading this can be found on the Jython Web page. You can start the installation process with the following command: java -cp . jython-21a3
Table 1: Jython options Option -i -jar jar-file -c cmd file args
Description Starts the Jython interpreter in interactive mode as soon as a script that has also been specified is finished Starts the program “_run_.py” in the jar archive Starts the program passed as argument “cmd” Starts the file “file” as a program Reads the program from standard input Jython will pass all subsequent arguments to the program that is to be executed
Table 2: Method parameters Java data type char boolean byte, short, int, long float, double java.lang.String, byte[], char[]
62
LINUX MAGAZINE
permitted Python data type string (length = 1) int (true != 0) int float string
Issue 17 • 2001
A wizard will then lead you through the installation process. Once it is complete Jython can be started in interactive mode using the command jython. The familiar Python shell appears: >> a=2; b=4 >> print a,b 2 4 >> print a+b 6 >> import sys >> print sys.path [‘’, ‘/home/ajung/.’, ‘/opt/jython-2.1/Lib’]
The Jython program you have called is only a shell wrapper that starts the JDK with the appropriate classes. Table 1 shows the most important options and arguments when calling Jython.
Importing Java classes Up to this point everything looks fairly familiar, so what’s the point? Well, to take one example, Jython can import Java classes directly. Classes in Java are arranged hierarchically into packages. An import
PROGRAMMING
Table 3: Return values Java data type of return value char boolean byte, short, int, long float, double java.lang.String java.lang.Class Foo[] org.python.corePyObject Foo
converted Python data type string (length = 1) int (true = 1, false = 0) int float string instance of Java class list with Foo objects or objects derived from Foo No conversion Java instance representing Foo class
Listing 1: treedemo.py
Figure 1: Some Jython classes displayed with the Tree widget from the Java package “Swing”. The program creating this tree is a Python script
command enables the current class to also use classes from other packages without having to specify the package name every time: import java.util.* import java.awt.Frame
A similar mechanism exists in Python, which also uses a hierarchy of packages. Jython, too, is able to access Java classes using an import command: from java.util import * import java.awt.Frame
Method calls Things get a bit more complicated when calling the methods of Java classes. Although this process is identical in both Jython and Java, the two languages’ different data types make a conversion from Python to Java necessary. The same is true for the reverse process of returning results to Python. In Jython this type conversion, also called “coercing”, happens automatically. Table 2 gives an overview of which Python data types are permitted for which Java data types; Table 3 relates to the representation of Java in Python when returning results.
A simple example Jython programs can use any Java classes. Listing 1 shows how simple it is to build and display a tree
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
from pawt import swing data = { ‘PyObject’: { ‘PyInteger’:None, ‘PyFloat’:None, ‘PyComplex’:None, ‘PySequence’: { ‘PyArray’:None, ‘PyList’:None, ‘PyTuple’:None, ‘PyString’:None, }, ‘PyClass’: { ‘PyJavaClass’:None, }, }, ‘sys’:None, ‘Py’:None, ‘PyException’:None, ‘_builtin_’:None, ‘ThreadState’:None, } Node = swing.tree.DefaultMutableTreeNode def addNode(tree, key, value): node = Node(key) tree.add(node) if value: addLeaves(node, value.items()) def addLeaves(node, items): items.sort() for key, value in items: addNode(node, key, value) def makeTree(name, data): tree = Node(‘Some Jython-Classes’) addLeaves(tree, data.items()) return tree if _ _name_ _ == ‘_ _main_ _’: tree = makeTree(‘Some Jython-Classes’, data) swing.test(swing.JScrollPane(swing.JTree(tree)))
with Jython and Swing. The tree’s structure is defined with data in nested dictionaries. The function makeTree, with the help of functions addNode and addLeaves, generates the appropriate structure of swing.tree.DefaultMutableTreeNode instances, required by Swing to display the tree (see Figure 1). Issue 17 • 2001
LINUX MAGAZINE
63
PROGRAMMING
Listing 2: PyInJava.java 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21
import org.python.util.PythonInterpreter; import org.python.core.*; public class PyInJava{ public static void main(String []args) throws PyException { PythonInterpreter P = new PythonInterpreter(); P.exec(“import sys”); P.set(“a”, new PyInteger(10)); P.set(“b”, new PyFloat(32.0)); P.exec(“s=a+b”); P.exec(“print s”); PyObject x = P.get(“s”); System.out.println(“Total: “+x); } }
Jython resolves this dilemma by sorting the methods according to their signatures and then selecting the most appropriate.
Java arrays Arrays are another problem area. Many Java methods use array parameters, but Python doesn’t contain any relevant data types. Using the jarray module, Python sequence types can be converted into a PyArray, which can then be passed directly to a Java method. For this, the “array()” method requires a Python sequence as its first parameter and the basic type of the Java array (“h”=short, “d”=double, “c”=char, etc.) as the second. from jarray import array print array( (1,2,3,4),’h’) print array( (1,2,3,4),’d’) print array( ‘linux’,’c’) This little program produces the following output:
Python embedded in Java The combination of Java and Python in the opposite direction is also very promising. It is often desirable to build a Python interpreter into a Java application (embedding) in order to provide that application with scripting functions. The example in Listing 2 demonstrates this integration using the class “PythonInterpreter”.
Small but important differences With all these advantages it’s almost inevitable that there’s a downside. The differences between Jython and C-Python are caused on one hand by ambiguities within Python’s language definition in the Language Reference, and on the other by Java limitations. The most important differences between Jython and CPython are:
The author Python expert Andreas Jung currently lives near Washington D.C. and works for Zope Corporation (formerly Digital Creations) as a software engineer in the Zope core team.
64
LINUX MAGAZINE
● Extension modules written in C do not work with Jython. ● Key words can also be used as identifiers in Jython. ● Every Jython object is an instance of a class (in C-Python this will only be implemented with version 2.2). ● The functionality of file objects is limited. ● Some of the extension modules included with C-Python are missing or have only been partially implemented. Java and Python also differ regarding the overloading of methods. Java permits methods with the same name and different signatures – i.e. differences in the number of arguments and their types. Python doesn’t allow overloading because its lack of typing and variable function parameters would interfere with the clarity of the semantics. Issue 17 • 2001
array([1, 2, 3, 4], short) array([1.0, 2.0, 3.0, 4.0], double) array([‘l’, ‘i’, ‘n’, ‘u’, ‘x’], char)
Speed is not everything The speed of Jython primarily depends on the Java VM used. A VM with an integrated just-in-time compiler is significantly faster than one without. Under Windows, using Microsoft’s Jview, Jython achieves about 80 per cent of the C-version’s performance (measured with Pystone benchmark). Under Linux, however, the speed can be as low as 20 to 30 per cent, for instance with the Blackdown VM. Jython is very well suited for integrating Python into an existing Java infrastructure. It is also a simple way of familiarising yourself with Java and its class libraries, as the interactive mode lets you play with the Java components on the fly, without having to use an editor or Java compiler. Jython can also communicate with external systems for which there is no C-Python extension, for instance through RMI or with JDBC database drivers.
Info Jython Web site http://www.jython.org/ Blackdown JDK Linux http://www.blackdown.org IBM Linux JDK 1.3.0 http://www-106.ibm.com/ developerworks/java/jdk/ linux130/?dwzone=java Python Language Reference http://www.python. org/doc/ref
COMMUNITY
SAIR LINUX AND GNU CERTIFICATION Level II: Core concepts and practices
T
his is the next in the series of study guides designed to get you through the Sair/GNU Linux certification program. This volume covers the core concepts and practices part of the exam, which is compulsory. The other volumes deal with the three elective subjects, Apache and Web servers (which we reviewed in Issue 15), Samba and resource sharing, and Sendmail and mail systems. The first part of the book contains a detailed explanation of the core concepts, covering installation and configuration, system administration, networking and security. Part two consists of labs and exercises. Each of the twelve labs covers a different part of the core concepts, starting with a step-by-step guide to downloading and installing Debian; continuing with partitioning and configuration; and
ending up with various exercises on security. The final part of the book has practice questions (multiple choice) with the answers and a detailed glossary. This is intended as an examination tutorial and revision guide and so assumes basic knowledge from the reader, although less common vocabulary is explained in the glossary. The explanations are clear and include some interesting historical notes (such as the development of the CPU) so that the examinee gains a good background knowledge as well as the facts necessary to do the job. URLs are given so that any programs needed can be downloaded. The book is written by the team behind the certification program and should have all you need to pass the core concepts part of the exam.
Author Publisher Price ISBN
Sair Development Team Wiley Computer Publishing £29.95 0-471-40538-8
LINUX NETWORKING CLEARLY EXPLAINED S
plit into five sections, this book takes a step-by-step approach to understanding and creating a TCP/IPbased Linux-driven local area network. Part one, “Connecting to the Internet”, takes you through the issues of buying a modem that will work, to setting up and configuring a dial-up connection with both graphical tools like KPPP and less graphically with VWDial. There is then a guide to using some of the Internet applications, Web browsers and email readers. The second part, “Building Your Local Area Network”, covers the essential concepts of networking, detailing the software and hardware
requirements. The next two sections show you how to put the network to use – explaining how resources like printers and Internet connections can be shared over the network. The final part deals with troubleshooting’ and security, covering both IP tables and IP chains. With 392 pages, 7 of which make a useful reference index, this book has a flowing style and covers everything you need to know in order to create a Linux network. Author Publisher Price ISBN
Bryan Pfaffennerger Morgan Kaufmann £29.95 0-12-533171-1
Issue 17 • 2002
LINUX MAGAZINE
65
PROGRAMMING
C: Part 4
LANGUAGE OF THE ‘C’ Electric Counterpoint
Of all the elements in ‘C’ programming, pointers are known to cause the most problems. They needn’t. In this article, I’ll show you why.
So what can pointers do, and why are they so useful? Well, pointers (as the name suggests) point to a location in memory that holds information we are interested in. In keeping with the themes of this series, that information is a temperature! Used appropriately they can help keep the code clean and save processing time, since we pass pointers to data into functions, instead of the data itself. It might be obvious, but I shall state it for the record - pointers have to point to something. This must be our own valid data (in our own data segment, see last months Memory access boxout ) or we will core dump. If the pointer has no valid data to point to it should be set to zero. This is termed a NULL pointer. Pointers, like structures, arrays before them, and variables before them, can not be changed once created! An integer pointer will always point to integers, but it can point to a number of different
Listing 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <stdio.h> int main(int argc, char *argv[]) { int *pMyList; int *pNum1, *pNum2; long *pAListOfLongs = NULL; int iValue = 4; pNum1 = &iValue; printf(“Value at the pNum1 ptr is %d\n”, *pNum1); *pNum1 = 3; printf(“Value at the pNum1 ptr is %d\n”, *pNum1); printf(“iValue is now %d\n”, iValue); return 0; }
66
LINUX MAGAZINE
Issue 17 • 2002
integers during its lifetime. Although there is nothing to stop you pointing it at floating point numbers, you can only read that data from memory as integers which produces strange looking numbers! Let’s start with some simple examples: *(listing 1) Line 5 declares a pointer to an integer. It doesn’t declare the integer itself, just a pointer to one. It could be referencing anything, from anywhere, because (like all local variables) ‘C’ does not automatically initialise them to sensible values. This is called a ‘dangling’ pointer. If we try to use pNum1 without pointing it to something we are very likely to core dump (in fact, you would be incredibly lucky not to core dump!). Line 10 (explained later) shows how we point it to something. Line 6 contains two pointer declarations. Note that each variable needs the ‘*’ prefix, if it is to become a pointer. Omitting this is a common newbie mistake, although the compiler is good enough to point this out to us if we try to use a normal int as an int pointer! Wherever a variable type (like int) is valid - a return type or function parameter - a pointer to a type is also valid. We see the initialisation of a NULL pointer in line 7. This is the safest way to declare a pointer as we can check its validity with: if (pAListOfLongs) { /* this pointer is valid */ } However, should we forget to check the NULL pointer, we can guarantee a core dump when its contents are studied! Line 10 is more interesting. This points ‘pNum1’ to somewhere valid - in this case, the address of the integer variable declared at line 8, iValue. The ampersand can be used in front of any variable name type (regardless of its type) to produce the address in
PROGRAMMING
memory of that variable. And because the variable has the number four, our pointer also points to the number four. To read the information from the pointer we have to dereference it. This is done by prefixing the pointer’s name with an ‘*’, as in lines 11 & 13. We can also use this syntax to write information back into that memory location, as with line 12: 12 *pNum1 = 3; You will notice that because pNum1 and iValue both reference the same memory location (and not just the same value) changing the data of either one, affects the other; which is why line 14 will report iValue to being 3 despite the fact we never change it explicitly.
Anticoh Arrow In addition to dereferencing basic variable types (like int, long and float), we can do exactly the same thing with structures. You probably wouldn’t be surprised by the code? float Convert(float fValue, struct sConversion *pConv) { return (fValue * *pConv.fMultiplier) + *pConv.fAddition; } We dereference ‘pConv’ with ‘*’, making the type of ‘*pConv’ a structure; and since structures use ‘.’ to retrieve individual elements, we write ‘*pConv.fMultiplier’. It’s not really that strange. (You must remember to put a space between the two ‘*’s, otherwise ‘C’ will try and understand the symbol ‘**’ - which it can’t - and complain heartily!) At this point, the bright kid at the back of the class raises his hand, “Isn’t there a neater way, sir?” Well, yes. There is. Because this type of operation is very common, we have a special symbol that combines the ‘*’ and the ‘.’ into one. For the lazy typists amongst you, I’m afraid it still has two characters, but it does look like a spaceship - making it infinitely cooler! That symbol is ‘->’, and is called the ‘pointer to’ operator. It can be used directly in place of ‘*’ and ‘.’, turning the above function into: float Convert(float fValue, struct sConversion *pConv) { return (fValue * pConv->fMultiplier) + pConv->fAddition; } As well as passing data in, it is possible to pass a
Incrementation When an expression like, *pTempList++ is evaluated there is the question of ‘when exactly does the pTempList variable get incremented’? The actual answer varies for every compiler you might use! All the ‘C’ standard expects is that the incrementation will occur at some point before the next sequence point (the ‘;’). But it does not specify when. Usually, this isn’t a problem. But if your code changes the same variable twice before the next sequence point - it is! iResult = iValue++ * iValue++;U /* Very bad code ! */ Only the compiler know if this is treated as: Get iValue1 Increment iValue Get iValue2 Increment iValue Add them Multiply Assign to iResult (sequence point here) or Get iValue1 Get iValue2 Add them Multiply Increment iValue Increment iValue Assign to iResult (sequence point here)
the code like that! The same ambiguity is true for the expression: iValue = iValue++;U /* also, very bad code! */ ‘ iValue++’ evaluates to whatever value ‘ iValue’ is (post-increment, remember), this is remembered (usually in a register, or on the stack), and used later when it comes to performing the assignment ‘ iValue =?’. Using the above notation: Get iValueRHS Store iValue in iStackTemp Increment iValue Assign iStackTemp to iValueLHS (sequence point here) or Get iValueRHS Store iValue in iStackTemp Assign iStackTemp to iValueLHS Increment iValue (sequence point here) The first version leaves iValue unchanged, whilst the second version would increment it. Naturally, this is very ungood, and is not encouraged! (*pTempList)++
Only the compiler knows what it’s going to do - and you are not the compiler, so you shouldn’t be writing
This creation will cause the compiler to dereference pTempList, and increment the value - at that memory location. This saves copying data from memory, incrementing, and copying it back.
structure out of a function using a pointer. It’s much better than returning all the data on the stack (which requires copying memory) and allows the function to write its results directly into the structure.
Your Latest Trick Pointers can be kept simple by making sure the left and right hand sides of each expression have matching types. So, if the variable on the left hand side is a ‘float *’, make sure the right hand side is one too (either another ‘float *’, or the address of a float variable). Be careful though, once you have a Issue 17 • 2002
LINUX MAGAZINE
67
PROGRAMMING
Working In A Coalmine
Listing 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char szFullname[] = “Sandra Bullock”; char * pSurname; pSurname = strchr(szFullname, ‘ ‘); if (pSurname) /* person may not have a surname! */ { pSurname++; /* skip the space */ strcpy(pSurname, “Goodwin”); } printf(“Full name is now %s\n”, szFullname);
Now we have a pointer, we need to do something with it. We know how to handle data in the memory it points to, and we know how to initialise it, but so far we haven’t worked out how to modify the pointer. Since a pointer is like any other variable we can re-assign it, or use one of the arithmetic operators (like ‘+’ or ‘—’). This is both legal and useful. However, multiplication of pointers doesn’t make any sense (nor does division). So stick to the sensible ones; ‘+’, ‘-’, ‘++’, ‘-’, ‘+=’ and ‘-=’. Assuming we have an array of hourly temperatures in ‘fTemperateEachHour’, and ‘pTempList’ points to the first one, we can reference the second temperature easily because the array is always sequential. There are several ways of doing this: t = pTempList[1]
return 0; }
We act like it’s an array. Valid, but is not good practise because it implies an array - which it isn’t. pointer, don’t take the address of it! t = *(pTempList+1) pNum1 = &iValue; pNum2 = pNum1; pNum2 = &pNum1;
/* Good! */ /* Good! */ /* Bad! pNum1 is U already a pointer! */ pNum2 = pAListOfLongs; /* Bad! We have a intU * on the left, and U long * on the right */
Angels vs Animals (or Pointers vs Arrays) Before we move on, there’s one more assignment we should cover. Arrays. Like other variables, they exist in memory, so we should be able to assign a pointer to point to them. The question, is how? The answer, is simple! float fTemperateEachHour[24]; float *pTempList; pTempList = &fTemperateEachHour[0]; pTempList = fTemperateEachHour; Both examples produce the same result, but the second uses a synonym (or syntactic sugar!) within the language. The array name is (by design) the location in memory where the array data was created; making it similar to a pointer. And, because the array name is treated as a single variable, it can be passed into functions like we saw (but didn’t explain) last month with strings. However, the differences between an array and pointer are many (see the comp.lang.c FAQ), but primarily, a pointer can point to any chunk of memory (valid or not) but does not allocate that memory. The array, on the other hand, will allocate some memory, but can only point to it - nowhere else. 68
LINUX MAGAZINE
Issue 17 • 2002
Directly equivalent to the method above. Here we treat the pointer like a variable, adding ‘1’ to it. This will move on one element. (If we point to floats, one element is the size of one floating point number, so we never need to know the size of each element in bytes). The data is then dereferenced from memory with the usual ‘*’ notation. ++pTempList; t = *pTempList; After then first instruction pTempList points to the second array element, which we can dereference with a single ‘*’. t = *(++pTempList); Exactly the same as above. We’ve just joined both lines into one, using brackets to ensure the correct evaluation order. The most usual way to read a block of data using pointers is with a variation of the last example. for(i=0;i<24;i++) printf(“Temp at index %d is %f\n”,U i, *pTempList++); (I hope we are all comfortable dropping the braces when there’s only one statement, since this is more usual) So what happens in ‘*pTempList++’? Well, it is the same as *(pTempList++), as opposed to (*pTempList)++ (see BOXOUT: (*pTempList)++). The post-increment part (pTempList++) evaluates to the
PROGRAMMING
Most of these examples use floating point numbers because we’d like decimal places in our temperatures. Unfortunately, floating point numbers are inaccurate since it is not possible to represent every value exactly with them. This means you will see some strange numbers in places, for example 9/5 is 1.8. But 32+1.8 is not 33.8, but 33.799999 because the processor can not represent 33.8. For this reason it is (very) rare to compare floating point numbers directly with ‘==’, rather it is better to say ‘if two numbers are within 0.0001 of each other, they are the same’. This small value is called the epsilon.
value of ‘pTempList’ before the variable is incremented. This value is then dereferenced by the ‘*’ operator. It occurs in this order because of precedence. But that is a more complex topic, so will be dealt with in later issues. Also see BOXOUT: Incrementation. After completion, pTempList has been incremented beyond the end of valid data. To run the loop again, we must rewind the pointer with: pTempList = &fTemperateEachHour[0]; You have now learnt enough to re-write all the string functions we saw last month, and understand all the others! The strcpy function, for example, might be: void MyStringCopy(char *pStringDest, U char *pStringSrc) { while(*pStringSrc) /* until we reach U the NULL terminator */ *pStringDest++ = *pStringSrc++; *pStringDest = ‘\0’; /* add a new NULL U terminator */ }
Sonata Number 2 for Flute and Strings in C# Minor In part three, I briefly remarked about writing the BASIC instruction LEFT$ with one simple line of ‘C’. It would have been possible to produce versions of MID$ and RIGHT$ fairly easily. It would have also been a waste of time! Why? Strings are rarely manipulated in that manner because we have more powerful methods at our disposal, notably pointers. Your gateway to this fountain of proverbial knowledge is: 1. A string is a pointer to NULL terminated data. 2. A pointer to a character within a string is still a string, because of 1.
Well, that’s it explained in zen-style language. What about in the ‘C’ language?! char szFullname[] = “Sandra Bullock”; char *pSurname = &szFullname[7]; Our new string (pSurname) can be treated like any another (since if szFullname ends in NULL, so must pSurname), meaning we can use all the normal string functions, like strcpy, on it. strcpy(pSurname, “Goodwin”); Sandra decides to marry me! */ printf(szFullname);
/* for when
We must be very careful when building strings in this manner. If our original string doesn’t have enough space for the new surname, we’ll overrun the szFullname buffer, causing the overrun problems mentioned last month. However, it doesn’t matter if we underrun. Most people will declaring strings with 128 or 256 characters in them, knowing that any string manipulation will not be so large as to overrun. It is very dangerous
Listing 3 1 #include <stdio.h> 2 3 void ConvertToFahrenheit(int iNumElements, float *pTemperatures) 4 { 5 float fFahrenheit, fCelsius; 6 int i; 7 8 for(i=0;i<iNumElements;i++) 9 { 10 fCelsius = *pTemperatures; 11 fFahrenheit = fCelsius*(9.0f/5.0f) + 32.0f; 12 *pTemperatures++ = fFahrenheit; 13 } 14} 15 16 int main(int argc, char *argv[]) 17 { 18 float fTempList[] = { 19 20, 18, 17, 16, 15, 17, 18, 19, 20, 21, 22, 23, 20 24, 25, 26, 27, 28, 29, 27, 26, 25, 24, 23, 22, 21 }; 22 int iNumHours = sizeof(fTempList)/sizeof(fTempList[0]); 23 int i; 24 25 ConvertToFahrenheit(iNumHours, &fTempList[0]); 26 for(i=0;i<iNumHours;i++) 27 printf(“Element %d is %f\n”, i, fTempList[i]); 28 29 return 0; 30 }
Issue 17 • 2002
LINUX MAGAZINE
69
PROGRAMMING
Listing 4 1 #include <stdio.h> 2 3 void ToFahrenheit(float fTemp) 4 { 5 printf(“%f c => %f f\n”, fTemp, fTemp*(9.0f/5.0f)+32.0f); 6 } 7 8 void ToKelvin(float fTemp) 9 { 10 printf(“%f c => %f K\n”, fTemp, fTemp+273.15f); 11 } 12 13 void ConvertTemperatureRange(int iWhichFn) 14 { 15 void (*pFunction)(float); 16 float fTemp; 17 18 switch(iWhichFn ) 19 { 20 case 0: 21 pFunction = ToFahrenheit; 22 break; 23 case 1: 24 pFunction = ToKelvin; 25 break; 26 } 27 28 for(fTemp=-100;fTemp<=100;fTemp+=10) 29 (*pFunction)(fTemp); 30 } 31 32 int main(int argc, char *argv[]) 33 { 34 ConvertTemperatureRange(0); 35 ConvertTemperatureRange(1); 36 return 0; 37 }
assumption, and only acceptable in casual, noncritical, code. One of the functions mentioned last month is strchr. This function searches a string for a particular character (a single, literal, character, that is) and returns a pointer to the first occurrence. If no character could be found, it returns a NULL pointer. We could use this function to generalise our above code, thus see listing 2.
Pass The Dutchie Pointers are often used as parameters to functions. This lets us modularise our data and algorithms, since we can say ‘do your processing, with our data’. And, as mentioned before, by supplying pointers to data, we don’t need to waste time making a special copy of the data see listing 3. 70
LINUX MAGAZINE
Issue 17 • 2002
We have seen all of this code before, in some form or another. We have seen dereferenced pointers (lines 10 & 12), the incrementing pointer (12), the automatic array size (18-21), and the size of operator (22). You should be able to say why we don’t increment the pointer in line 10. You should also be able to say how we could enhance this example so we don’t loose the original ‘temperature in Celsius’ data. Finally a word of warning. If you intend to pass a pointer back from a function (and there are several reasons why you’d want to) then make sure the data it points to will still exist when the function exits. Local variables will not! They are created on the stack, and will leave your calling routine with a dangling pointer, looking at an invalid area of memory.
Take A Bow When you call a function, the processors program counter is set to the memory location of the function. Simple. But why should the compiler be limited to such operations? What if we (as the programmer) knew the address in memory of a function - what stops us from using it to call that function? In ‘C’ nothing! We can declare such a variable by taking the function prototype, void PrintMessage(void); and replacing the function name like so: void (*pFunction)(void); The declaration enforces the only limitation with pointers to functions. That is, the variable can only point to functions with exactly the same prototype. To ease readability, this could also be typedefed as in listing 4. When a function name is used as part of an expression (as in lines 21 and 24), a function pointer is generated, and can be stored in a variable (as it is here), or passed to another function for processing. A call to that function is made by dereferencing it, (line 29). This is how a number of fractal generators are written: there is a common ‘for all pixels in image’ loop which calls (with a pointer to function) the program code for a particular fractal. This prevents duplicating the ‘for all pixels in image’ code, and allows new modules to be added easily to the program. Providing a new fractal type requires, perhaps, four lines of code! Next month?IO: how to handle files, the keyboard and the screen.
BEGINNERS
G-TOOLS: Digging deeper to find the gems
PHONE HOME In our inaugural GNOME tools, we take a look at the Rubrica address book, Gabber instant messenger and a SETI applet
Rubrica Rubrica has now reached version 0.8.2 and has received a rare five cow award from the Tucows (http://mclink.linuxberg.com/x11html/preview/172990 .html) download site. It is a GNOME-aware address book, which has a very crisp and clean looking user interface and was written by Nicola Fragale to practise Gtk+ programming. Packages can be downloaded from http://digilander.iol.it/nfragale/download_gb.html and the Red Hat binary loads without fault. Starting from a shell with:
G-tools This new column to Linux Magazine features a monthly round-up of some of the best tools available from the gnome.org Web site. Whether they be essential tools for everyday GNOME users or interesting curiosities, you’re sure to fond them here.
[fred@box /]$ rubrica & we are greeted with the opening screen (Figure 1). As would be expected we can then start to input our first address book card. Rubrica saves its address book output as .rub files Figure 4:A card completed
and you can import data from Gnomecard and previous versions of Rubrica. Both Netscape and KDE address book import is planned along with exporting functions. The project is a work in progress with requests for local language translations.
Figure 1: Rubrica starting
Figure 2: Inputting data
72
LINUX MAGAZINE
Figure 3:More information
Issue 17 • 2002
Gabber Gabber is the GNOME Jabber client, which is an instant messaging system. Jabber.com and Jabber.org have a wide range of clients and servers for many platforms. Jabber has recently been chosen by BellSouth and French Telecom so it’s not a fly-bynight system. The binaries from http://gabber.sourceforge.net/download.php are some 1.6Mb in size. On first running you are asked for some details so the client can register you with jabber.com. Once this is done we are presented with a window similar to those of LICQ et al. From here we can add contact friends, supposedly including those from other instant messaging systems. Supposedly being the key word here. We managed to add a contact from the ICQ network
BEGINNERS
Somewhere out there... The SETI project is the Search for Extra Terrestrial Intelligence, that looks at all the data generated by the world’s radio telescopes. This mammoth task has been broken down into the clever Seti@Home project. In this, volunteers using data downloaded from the Seti@Home site use their own PC time to analyse the data. Where the project wins is that lots of PC processing time is not normally used (while you make a drink of Yerba MatÈ or just spend the time deep in thought). Seti@Home operates in this otherwise idle time and by harnessing millions of volunteers, aims to make an impact on the data. Linux users have been able to help by using the Seti client. You can download the compressed file from http://setiathome.ssl.
Figure 11: Nearly one unit completed
happening. Restarting with the command [fred@box /]$ setiathome -verbose
Figure 10: Setting options
berkeley.edu/unix.html. Note: if you are using a K6 processor you need the i386 download and not the i686. Unpacking the file we find two files. The first is a text file explaining the options, while the second is the client. In the shell we start this with [fred@box /]$ setiathome
Figure 9: The Setiathome running in a shell
We are then asked for some personal details and if we want it to be available to others on the Seti site. The client now communicates with the Seti site and downloads a small piece of data to be worked on. At this point you are left wondering if anything is
now gives us a little indication that something is happening. The GNOME Seti applet can be now downloaded from http://seti-applet. sourceforge.net/ and the rpm package installs as expected. From a shell start with [fred@box /]$ seti_applet This starts the applet but you must first configure it to point to the directory where the setiathome client is located and then connect to Seti. This is done by clicking the right mouse button on the applet. Advanced features let you modify the priority of the applet. The radio telescope icon changes from red to green when active. The Seti data is slow to process. At maximum priority and no other tasks it ticks over at about 10 per cent per hour on a 1GHz machine.
Figure 5:Inputting details Figure 6:The main Gabber client Figure 7:Jabber chat rooms
where they were using an old protocol, but both Yahoo and MSN failed. Disappointed, we chatted to a few Windows users who were shocked that we had managed to connect to an ICQ user as under three different WinClients this was practically impossible. The Gabber client also lets you access Jabber rooms. These are IRC-type rooms that allow group discussions and can be useful for conference talks.
Figure 8:Not everything runs smooth
Issue 17 • 2002
LINUX MAGAZINE
73
BEGINNERS
Desktopia
BACKGROUND MENU I
This month, Jo Moskalewski
like fast food as much as the next person – it’s convenient and saves me time that I’d much rather spend in front of my computer – but can you live on burgers and noodles, day in, day out? What we need is a bit more variety in our diets, and the same applies to your desktop.
presents one
Aperitif
possible solution to
At some point you’re bound to get tired of looking at your once-perfect desktop and will yearn for a change of wallpaper. But what are you going to try this time? Do you replace the funny picture of tux with your sweetheart again, or would it be nicer to run through the colour spectrum from yellow to purple? You can avoid the agony of choice by appointing ChBg (Change Background) as your desktop chef. On the basis of your specifications, ChBG cooks up a scene on the desktop background. This can consist of graphics, colours and so-called gradients (which will be familiar from the image processing program Gimp), finely flavoured with a pinch of chance. If you so choose, a new sequence can be served every few
the eternal search for the ultimate desktop background
desktopia Only you can decide how your Linux desktop looks. With deskTOPia we regularly take you with us on a journey into the land of window managers and desktop environments, presenting the useful and the colourful, viewers and pretty toys. minutes. If this has whetted your appetite, visit the ChBg Web site http://chbg.sourceforge.net.
The full works Unfortunately, ChBg is not exactly tailored for simple systems. The installation requires certain components to be installed on your system, such as the GTK+ library (at least version 1.2), which is also used by Gimp and GNOME. Other ingredients you’ll need include libpng, libz (often also known as zlib) and imlib (alternatively gdk-pixbuf). These are libraries, which make their functions available centrally to diverse applications (and thus ChBg). Complete RPM packets can now be installed via the distribution’s own packet manager or else with the command rpm -i chbg-1.5-*.rpm. If on the other hand you access the ChBg packet with the uncompiled source code, your hard disk will not only have to keep the normal packets for the necessary libraries in stock, but also the respective associated Devel-packets (developer packets). It is only with these that programs which use a corresponding library can be compiled out of the source code; with “normal” packets only complete binaries can be executed. If all the requirements have been met, unpack the archive by entering tar -xvzf chbg-1.5.tgz and change to the newly added source directory using cd chbg-1.5. In order to compile and install the source code there, all you need under ChBg is the well-known command sequence ./configure, make and make install.
Season to taste Figure 1: Colour selection for effects – output in a window
74
LINUX MAGAZINE
Issue 17 • 2002
Now you can check the taste of what has just been installed: the program starts after you enter chbg from an X-terminal (e.g. xterm). Once started, it first
BEGINNERS
Action/Start, and a unique desktop background is computed and displayed.
Fast food Cooking your own soup in this way is huge fun, but the declared goal at the start of this article was that of no longer wanting to bother about a new background. As such the whole thing has to be automated. If acceptable settings have been found, simply save your recipe. The menu item File/Save scenario... does this at the touch of a button. If you now start the command Figure 2: Even an rxvt can be used for output
presents us with the configuration screen, which can also be called up manually using the command line parameter -setup. You should now do some serious experimentation with this configuration window. It takes a bit of practice for the interaction of the options to become clear. Not because the author has cooked up an inadequate interface; it’s more that the countless levers, switches and recipes lead to ever more different results. ChBg can serve its creations itself in an rxvt (an xterm alternative), as Figure 2 shows. Anyone trying this must not start off the rxvt with any colour options – it’s too easy for a newly-generated background to make a font unreadable, and the rxvt window has to go for recycling. Colour selection with ChBg is also a time-consuming undertaking when you do this. The original idea of ChBg was – like a slideshow – to display changing graphics on the desktop background. However, images often have a different format than the desktop and so ChBg is also capable of expanding the scene by a decorative and randomly generated border. Now this “frame” can also be used as a freestanding background graphic: The menu item Cycle blank screens in the Setup tab makes this possible. The pre-set tool-tips explain how it works (Figure 3). The Picture list must not display any entry, and in the Effects tab the Background shading effect must be set at Random. Another mouse click on
chbg -scenario recipe file then you will no longer see a configuration window, and the desktop background periodically changes according to your specifications. If the graphical configuration interface does appear then your scene probably doesn’t contain graphics even though ChBg is expecting one. This can be remedied by using a transparent GIF, as contained on the cover CD, which obviously can’t be seen. If you intend the background to change several times during an X-session, you will need a corresponding number of dummy graphics. This is to do with the fact the ChBg goes off duty once it reaches the end of the Picture list. A repeat function is thus right at the top of the wish list for future versions.
Something special Unfortunately, the KDE team has some highly individual ideas about the proper guests to invite to the table, and so a frameless window is painted over the usual desktop background (which in turn serves KDE2 as background). This is why there is simply nothing to be seen of the culinary arts of ChBg in KDE. However, there is still the option of diverting the output (instead of onto the desktop behind the KDE desktop) into a PNG file. This can then be used with KDE2. The simplest way to get the tool to start automatically is via the Autostart function of your graphical user interface. In your case, this could be a special folder, menu item in the configuration of your window manager or else the file .xinitrc or .xsession. If you want to change quickly to other settings – no problem: ChBg can cope with all the options via the command line cue. chbg - -help | less or the manpage (man chbg) will explain.
Marks for taste
Figure 3: Additional effects can be used even without background graphic
Although this tool requires a bit of practice in order to master it (despite the fact that the author has clearly devoted a lot of thought and effort to it) the end result on the desktop still works. What’s more, because it’s so fascinating anyone who uses ChBg will clear away their entire desktop from time to time just to see what has been created. Issue 17 • 2002
LINUX MAGAZINE
75
BEGINNERS
OUT OF THE BOX
GET THE BALL ROLLING Out of the box
Even though the Christmas baubles have been packed away for another year, it doesn’t mean you can’t have fun playing with shiny balls. Christian Perle takes a look at Kugel by Vlatko Primorac – a perfect game for cold winter evenings
C
an you remember Solitaire? No, I don’t mean the addictive game that all secretarial staff play to pass the time until the next Windows crash, but the Solitaire played with marbles, which are removed by jumping over them. If you now add Tetris to this and mix well, then you’ll have something like the game plan of Kugel (which means Sphere). The point of this game is to remove spheres from the playing field for as long as possible, which is done by forming rows of the same colour. To do this, you move the spheres that are already on the playing field to other positions, which must be reachable without passing barriers. Each row removed increases your score. However the program does make things a little trickier by randomly placing spheres in the empty fields, effectively blocking off your options. When the playing field ends up full, the game ends.
There are thousands of tools and utilities for Linux. “Out of the box” takes the pick of the bunch and each month suggests a little program, which we feel is either absolutely indispensable or unduly ignored.
Interpreted Since Kugel is written in the script language Perl, you don’t have anything to compile on installation; the Perl Interpreter handles all this for you. The graphic display is taken care of by Tk, which although originally conceived as an expansion of the script language Tcl, can now also be used with both Perl and Python. To integrate Tk into Perl you may need to install the packet perl-tk, which comes with all modern distributions. As such, the installation procedure is limited to copying a few files. At the URL http://www.ibiblio.org/ pub/Linux/games/strategy/kugel-2.4.tar.gz you will find the tarball necessary for installation. Copy the file kugel-2.4.tar.gz together with the script into a common directory. Give yourself root rights with the command su, and start it with sh kugelinst.sh. So as to give back the superuser identity afterwards finish with exit.
Rules and tactics After installation call up the program from a terminal window with Kugel &. The playing field should look like Figure 1, but with fewer spheres. Now you must move spheres in such a way that rows of five or more spheres of the same colour are created – horizontally, vertically or diagonally. Spheres can be moved by clicking on one and then clicking upon the target field where you want to move it to. An unblocked route must exist between the source and destination fields in order for the sphere to travel between them. Figure 2 shows two different moves, represented by arrows. Only when the first removes the brown row of spheres from the board is there a clear run for
Figure 1: The Kugel playing field
76
LINUX MAGAZINE
Issue 17 • 2002
BEGINNERS
Compiling A program is not executable by the operating system in source text form. It is only by compiling (“translating”) it with a compiler that it turns into a form that can be executed by the respective processor. Interpreter Contrary to the compiler-based programming languages, in this case the source text is read anew and directly executed every time the program is started. This may be slower than compiled code, but during development there is no need for the compiler run.
Figure 2: A question of strategy
the pale green sphere, which in move 2 completes a row. The removal of a row increases your score based upon the number of spheres removed (removing five spheres gives you five points). For each turn where a row is not removed from the board, the game adds three new spheres (seen in the preview to the left of the main playing field) at random into previously empty fields. This gradually restricts the player’s freedom of movement. Nevertheless, when playing Kugel you should not concentrate too hard on any individual row of spheres. It’s better to pursue several “building sites” at the same time. This increases the chances of completing a row.
Adaptable If the Kugel window is swallowing up too much space on your desktop, you should look at the items in the View menu. A lot of the game’s features can be minimised from here. In the Colors menu you can choose between various background colours. The Options menu enables you to adjust the size of the playing field and values such as the minimum length of a row or the number of “penalty” spheres. With
Tarball tar is an ordinary archiving tool under Unix. A collection of files packed together by this, referred to in slang as a tarball, usually bears the file ending .tar.gz or .tgz. This is because such archives are firstly assembled with tar and then compressed with the program gzip. & The ampersand, entered as the last character in the command line, serves to execute a command in the background. Otherwise the shell remains blocked until the command is completed. POV-Ray A freely copyable raytracing (3D graphics) program, which is at home on many operating systems – including Linux.
Sphere Choice you also get alternative sphere sets to choose from (Figure 3). All moves are saved internally by Kugel until you leave the program. If you have just played an especially good game, you can save the moves made by Kugel with the Save option in the File menu. With Load you can read such a sequence of moves back in. With Undo and Redo you can then follow the Kugel game’s history.
Bonus If you have been searching in vain for the glass spheres from Figure 2 in the sets, this sphere-set is one I created with POV-Ray. It can also be found on the cover CD and is installed with the following commands: tar xzf povset.tgz su (enter root password) rm -f /usr/local/lib/kugel/images/set2/*.gif cp [0-7].gif /usr/local/lib/kugel/images/set2/ exit
If you still need a reason to play: My highest score so far is 192 – and you have all of the weekend to beat this.
Info Kugel homepage POV-Ray
http://www.vlptel.com/~ vlatko/kugel http://www.povray.org/
Figure 3: Spheres also need a change of wallpaper
Issue 17 • 2002
LINUX MAGAZINE
77
BEGINNERS
K-TOOLS: Kdict
NOW TRANSLATE If you don’t feel like poring over a paper dictionary, don’t worry. As Stefanie Teufel explains, with Kdict at hand, an online alternative may not be far off
H
owever good your knowledge of English, French or jargon may be, you’re still likely to forget the meaning of a word every now and then. For cases like these, there’s Kdict – the dictionary for KDE. Formerly available as an individual application, from version 2.2 Kdict is now a permanent part of the kdenetwork packet so you don’t even have to install it separately. This virtual translation aid uses the DICT protocol (http://www.dict.org) in order to search for definitions in databases on diverse Internet servers. Anyone who has previously taken a look at the program will be in for a surprise because in addition to porting onto version 2.2 of KDE, the developers have also installed features in the new edition that make working with this tool even better. The opportunity to embed Kdict in the panel is particularly useful.
A reference work for you alone If the words “on diverse Internet servers” have already made you think anxiously about your phone bill, don’t worry: you don’t need to be permanently online. With the DICT daemon it’s possible to run a Webster Webster’s Revised Unabridged Dictionary, 1913 Edition is a purely English-language dictionary with refined search options (wildcards, etc.), which now encompasses over 100,000 words. WordNet Work began on WordNet in 1985 and is still going on today. Those involved in its development are mainly psychologists and linguists from the University of Princeton, USA. The structure of this lexicon is oriented towards psycholinguistic theories about human memory, unlike the more usual dictionaries, which are organised on the basis of alphabetical order or in classes of synonyms. Therefore, words are shown with the distinction between the form of the word and the meaning of the word. The meaning of the word is thereby represented by a number of synonymous word forms. WordNet is not limited to any specific field and currently comprises over 95,600 English word forms. This thesaurus is especially recommended as an aid to writing English texts. Jargon File Eric Raymond’s The New Hacker’s Dictionary (which is the official name) is the best reference work for the latest Internet and hacker slang. It lists and defines – in often ironic fashion – terms to do with the Net and the computer.
78
LINUX MAGAZINE
Issue 17 • 2002
K-tools In this column we present tools, month by month, 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.
DICT server on your own computer. As well as providing faster access speeds and cost saving (for those without a true flat rate Internet service, at least), this kind of local server also offers the option to install extra databases. Before you start up your own virtual dictionary, you’ll first need to install the dictd server and the associated utility programs. The simplest way to do this is to use the deb or rpm packets appropriate for your distribution. Both Debian and Mandrake contain the appropriate packets, and you can easily track down those for other rpm-based distributions at http://rpmfind.net. Alternatively, you can also compile dictd yourself. To do this you’ll need the packet dictd-1.5.5.tar.gz, which you can download from ftp://ftp.dict.org/pub/dict. Unpack this and install it with our old friends ./configure, make and make install. We now ought to download a couple more dictionary databases, without which the server makes little sense. The usual suspects such as Webster (dictweb1913), WordNet (dict-wn) or the Jargon File (jargon) can be found at http://www.dict.org/links.html. It’s also worth a visit to http://www.freedict.de/, which provides you with bilingual glossaries in more than 15 languages. Although http://www.dict.org hosts many other databases, most of these are in a format which dictd cannot deal with. Every DICTD database must consist of two files: .index contains the index and .dict the actual data or words. Unpack the database archive into a directory which you have created specifically for this purpose, such as /usr/local/db. If the data is
BEGINNERS
present, the local DICT access should be configured. If, in addition to Kdict, you would still like to use the command line program dict to hunt through your local databases, the file dict.conf should contain the following simple but effective line: server localhost We will now use the file dictd.conf to configure the local server. Firstly, use the access command to define who will have access to this in the future. The best way to do this is to decide something like access {allow localhost deny *} This means that you are only permitting local access. All that you need to do now is specify which databases you would like dictd to use. There were the files we carefully hunted out and placed in the /usr/local/db directory. Our dictd.conf looks as follows: database Latin { data “/usr/local/db/U lat-eng.dict.dz” index “/usr/local/U db/lat-eng.index” } database English{ data “/usr/local/db/U eng-lat.dict.dz” index “/usr/local/U db/eng-lat.index” } database Jargon { dataU “/usr/local/db/jargon.dict.dz” index “/usr/local/db/U jargon.index” } Should you wish to use additional databases (such as Webster), you can expand dictd.conf at any time by adding a command for your new database. Our example would look something like this:
Figure 1: Welcome
dictd command in any terminal. Using this, access with dict, or in our case Kdict, ought to work.
Verbose After all this installing and configuring, you must by now be dying to finally see Kdict in action. Nothing could be easier; simply start your dictionary with the kdict & command in any terminal emulation or alternatively via K-Menu/Utilities/Kdict. Don’t be too shocked by the rather empty window (Figure 1) that will then confront you – this will fill up faster than you think. Before you start assiduously looking up missing words in Kdict, you will need to adjust with the settings of your personal translator. To do this, open the settings dialogue via Settings/Install Kdict (Figure 2). If you’ve decided on a local server, change the default from dict.org to localhost and then click on the Apply button. You can happily accept all the other settings under this item, as specifications for
database web1913 { data “/usr/local/db/U web1913.dict.dz” index “/usr/local/db/U web1913.index” } Now start your dictionary server by entering a simple
Figure 2: This server is known as the local host
Figure 3: This is what your server has to offer
Issue 17 • 2002
LINUX MAGAZINE
79
BEGINNERS
Figure 5: Any amount of information
the Timeout and so on only make sense for online queries. Incidentally, Timeout defines how long Kdict should wait for a reply from the server. In order to play safe, it’s wise to test your configuration by invoking Server/Server Information. Kdict will then provide you with a few bits of information regarding the status of your server (Figure 3). Next, start Server/Get Capabilities to provide Kdict with a list of available databases and search strategies from the server set (in our case localhost). In future the dictionary front-end will show you all the available databases and strategies in its selection menus. As you can imagine, the Kdict electronic reference library is very easy to use. If you want to look for a word or definition, enter it in the Look for: field and then press the Enter key, or click on the magnifying glass icon on the toolbar. In the pull-down list next to the Look for: field you can also define the available databases in which Kdict should search. As a fully-fledged KDE application, Kdict is adept at finding its way around the KDE clipboard and can look up its contents should you wish. To do this, select the menu item Edit/Match Clipboard content. If you regularly use this feature it’s advisable to create your own keyboard shortcut via Settings/Configure key bindings. Alternatively, you can mark a word with the left mouse and then click on the Kdict window with the middle mouse button to start the search. As it often makes sense to conduct a search in just one part of the databases, Kdict gives you the option to define your own set of databases. These are free compilations of the existing databases, such as all English-Latin dictionaries, which appear as virtual databases in the database selection list. To create this type of set, select Server/Edit Database sets and assemble your own database combination using the
Figure 4: A database as you like it
Figure 6: Swallowed
80
LINUX MAGAZINE
Issue 17 • 2002
arrow keys (Figure 4). Whether you use a pre-defined dictionary or one of your own concoction, Kdict will display the result of your search in a window, as in Figure 5. The program also defends itself against the error gremlins that will always try to slip in. If Kdict finds no suitable term in its databases it offers you a list of similarsounding words on the right-hand side of the window, from which you may find your term. If so, look it up immediately by marking it and choosing the Load selection button. If you want to look up all the alternatives in one go, the Load all button will satisfy your needs. Don’t be surprised if some words appear in blue in the definition. This is due to another of Kdict’s useful features. If you click on one of these highlighted words, Kdict immediately shows you the associated definition of this term – hyperlinks à la Kdict.
Panel & Co. One of the new options offered by Kdict, lets you embed the program in the panel. In order to do this, select Configure Panel/Add/Applet/Dcitionary from the K menu. You will then immediately see an applet as in Figure 6. If in future you are studying a Web site, manpage or readme file and there are a number of terms you are unfamiliar with, you can simply enter them into this box; Kdict looks up the term and presents you with the results of its efforts in the usual way. If, on the other hand, you just want to quickly look up a word, you can make use of the command line options of your little helper. In this case, start Kdict in the following way: kdict word_you_want_to_find If you want to look up several terms in one go, you must place them in quotation marks. With a kdict -c or kdict - -clipboard, Kdict looks up the content of the clipboard. A kdict -h gives you an exact overview of the additional command line options.
COMMUNITY
Internet
THE RIGHT PAGES Mobile UniX systems http://MobiliX.org MobiliX (Mobile Computers and Unix) links to a wealth of useful hands-on information about installing and running Linux, BSD and other Unixes on laptops, PDAs and other mobile computer devices. It’s many pages include the Linux-Mobile-Guide and the Infrared-HOWTO, a survey of supported PCMCIA cards, other mobile hardware surveys, some databases of stolen laptops, software for mobile computers, a linux-laptop mailing list and much more.
Northern Light search engine http://www.northernlight.com The Northern Light search engine offers a collection of journals and articles that are unavailable elsewhere, although they do charge for this service. The search engine itself is fast and free to access.
I’ve installed Linux what next? http://www.firstlinux.com/articles/WhatNext.shtml This is a good site for Linux newbies who have installed a distribution and want to know what to do next.
Userlocal.com http://www.userlocal.com UserLocal is designed and run by volunteers, as a help, advice and news resource for other Slackware users.
Fix Unix http://fixunix.com Fix Unix has recently gained a new Web master, so it may be a few months before all the content is updated. However, it still remains a good portal for HOWTO manuals.
When we’re not hard
Jobs in Linux http://www.hotlinuxjobs.com Okay, so we all want more money but we also want to do the right thing. The job tips section is certainly worth a read, just to make sure.
Secure password technology
at work producing the magazine, we like to spend our time searching out software and news on the Internet. In the
http://www.cryptocard.com If you’re at all concerned with security, then CRYPTOCard’s secure password technology may well be of interest. It’s cheaper than an RSA/SecurID setup and well worth a look.
office we all have our
New Linux laptop
latest finds that we
http://www.emperorlinux. com/gazelle.html If you’re in the market for a new Linux laptop, you may want to check out the Gazelle. It’s based on a slim Sony Vaio GR with Linux preloaded and ready to rock.
feel are important
favourite bookmarks. Janet Roebuck sifts through some of the
and useful
3Dsia for Linux http://threedsia. sourceforge.net Create 3D virtual worlds as envisioned by William Gibson. Burning Chrome, here I come.
RFC 2795 Infinite Monkey Protocol http://www.faqs.org/ rfcs/rfc2795.html It’s always useful to look at RFCs to see how a protocol should work. We used this protocol to produce much of this issue. Issue 17 • 2002
LINUX MAGAZINE
81
COMMUNITY
The monthly GNU Column
BRAVE GNU WORLD Welcome to another issue of Georg CF Greve’s Brave GNU
BZFlag
World. In LM14 we
BZFlag
introduced FreeCIV and asked for other examples of Free games. Here are some of the games that were suggested
88
LINUX MAGAZINE
It doesn’t take a lot of time to explain the concept behind this issue’s first game, BZFlag. Every player drives a tank through a 3D landscape trying to shoot other players, capture enemy flags and pick up gadgets. This makes it a classic shoot ‘em up game for multiple opponents who can play over a LAN or via the Internet. BZFlag originated in 1992 in the Program of Computer Graphics at Cornell University, where Chris Schoenemann discovered it was an effective way of avoiding work on his thesis. With the participation of other students, BZFlag was evolved quickly and soon became the favourite means of wasting time for many students. In the beginning, the game was written for HP-UX workstations using an IRIS GL-like graphics library but when the third SGI Indizone Contest came up, Chris rewrote it completely, improving the graphics and adding sound. BZFlag subsequently won in its category. After further enhancements, Chris ported it to GNU/Linux and Win32 and released it as Free Software under the GNU General Public License. Tim Riker has now taken over as the BZFlag maintainer and more than a dozen developers work Issue 17 • 2002
on it with him on SourceForge, where it made it into the top ten of the most active projects on multiple occasions. According to Chris, the engaging gameplay and the balanced dynamics are what makes BZFlag particularly special. The forward-, rotation-, shoot and reload speed of the tanks are tuned so that a duel between experienced opponents can end up as complicated dance where a small tactical mistake decides everything. Comments on the homepage seem to second this: it seems that even people in the US Army Combat Maneuver Training Center like playing BZFlag. A problematic part of BZFlag is the networking code. The game was originally designed for local networks (LAN), on which it transmitted fast-changing information by multicast or broadcast, while the communication with the server was done by TCP to make sure no information about captured flags and such was lost. In order to allow Internet play, UDP packets were also transmitted through TCP, which created massive timing problems. UDP packets are now transmitted by the server through UDP but it is planned to replace all usage of TCP, as it tends to block the connection in case of transmission problems. The next release will aim to reduce the latency problems created by networking. It will also have fewer bugs and be more cheat-proof. In the long term, an overhaul of the graphics engine and more modes of play appear useful. Help is wanted with the port to Macintosh, which isn’t progressing as well as Chris would like. The networking protocol is not the only part of BZFlag which could be improved: the graphics, artificial intelligence of computer foes and the physical model are all aspects worthy of attention.
COMMUNITY
XShipWars Anyone who played the space fight simulation Elite some years ago will most likely be fascinated by XShipWars. In a similar vein to Elite, the player takes over the role of a space ship captain who must survive a big universe with the help of diplomacy, trade and combat. The game mainly consists of a client and a server. The server handles the universe and allows clients to interact with the universe and other players. The universe itself is largely created by the interaction of the players; players with special permissions can even create new objects and shape the universe. Additionally, special modules exist to give computercontrolled ships artificial intelligence (AI). Depending on their empire, these ships may help other players or attack them. The game originated in 1995/1996 as the purely text-based ShipWars and only became graphical in 1998. Whilst the textbased version had been written in Fortran, only C/C++ is used today. (X)ShipWars is developed by Wolfpack Entertainment, a loosely-knit group of computer graphics specialists and programmers that have, as they say themselves, “somehow managed to work together on this project for 5 years” and release it under the GNU
XShipWars
General Public License. By products of this development are two other projects, which are being used outside XShipWars. The libjsw library is a high-performance joystick library and YIFF is an audio-server geared towards games. When these projects were started, neither GTK nor ESD were even being thought of. Taura Milana, who answered the questionnaire about XShipWars, believes the weakness of XShipWars to be the graphics, which are not quite up to modern standards – fast and fluent gameplay were considered to be more important. Also the decisions necessary in a dogfight might be too much for a beginner to handle. Other than that, XShipWars is very
mature and stable and the balance of action and strategy is something Taura is especially fond of. The current development of XShipWars is more geared towards little gadgets than real functional expansions. More interesting than the plans for XShipWars are plans for a “ShipWars 3D”, which will be the third generation of the game. For this, a complete reimplementation based on OpenGL and modern techniques is planned. Those who would like to join the fray immediately don’t have to wait that long because even without OpenGL support, XShipWars is a lot of fun. Currently, the largest XShipWars universe is Terminus by Stein Vrale. Thanks to the motivation of the XShipWars community, the Terminus universe evolved into a place where every system, every planet and every ship are unique, there is no repetition. Players have a big universe to explore and in which they can trade and upgrade their ships. Enough games for this month. I’d like to provide some more options to waste long winter nights with Free Software, so if you know other games or happen to work on them, please let me know.
Arkanae Our next Free games is the role playing adventure, Arkanae. In this game the player becomes a hero who has to save a world terrorised by seven incredibly powerful beings, known as the Arcances. These beings were once trapped by a powerful crystal for the sake of humanity and are now roaming free again. The quality of the game’s 3D graphics may surprise some, as will the widely non-linear plot. The player can chose whether to fight for good or evil and how to find the hidden treasures, solve the quests and fight monsters. Arkanae is programmed in Java and uses the Opale.Soya Java 3D engine, written specifically for the game, which allows Arkanae to use 3D hardware acceleration. On a side note, this engine is now being used by the Fraunhofer Institute for 3D visualisation in the biomodelling part of the M3 project (Man Model Measurement). As the game uses Java, the project is fairly platform independent and runs on GNU/Linux, Mac OS X and Windows, although at the same time it does have the
usual Java problems. This means that getting the right installation of Java is sometimes a gamble and there is still no Free Java implementation offering the full range of features. Arkanae, for instance, is dependent on the Sun JVM 1.3 or BlackDown, neither of which are Free Software. This means that Arkanae, being licensed under the GNU General Public License as Free Software, is Issue 17 • 2002
LINUX MAGAZINE
89
COMMUNITY
preparing a 3D engine in C. Jean-Baptiste discovered Python and wants to realise some projects in it. Help with Arkanae would be especially useful in form of more levels. A level editor does exist, although it is rather complicated to use, therefore Bertrand offers an introductory course for would-be level designers. Enough said, fans of role playing games should take a look.
TRAMP Arkanae
dependent on a proprietary platform prone to some technical problems. Even though this is not as critical for a game as certain other applications, it does show that the Free Software community should be more conscious about either furthering the Free Java implementations or doing without Java completely. As the idea behind Java seems useful, it is probably better to strengthen the Free alternatives. An introduction can be found on the “GNU and Java” homepage. Anyone interested in trying out Arkanae should not let their fun be diminished by this, as Arkanae has quite a bit to offer and is already available in French, English, German and Italian. The problem child of Arkanae is the Windows platform, as keyboard management and music suffer from the lack of thread support. The authors, Bertrand Lamy, Jean-Baptiste Lamy and Althea Chia, plan to complete Arkanae soon and finish the scenario. Betrand’s future plans include writing another game for which he is currently
cdargs cdargs is an extension of the cd shell command written by Stefan Kamphausen in C++. It extends the cd command with bookmarks as well as a directory browser. cdargs also provides an integrated interface to administrate the bookmarks, although they are simply saved as lines in an ASCII file so they can be conveniently edited with any text editor. Stefan got the idea for this project when he saw an article in the German computer magazine iX, in which Michael Schilli implemented similar (although not quite as advanced) features in a Perl script. Since the script was under a nonFree license, Stefan picked up the idea and implemented it anew with some more features under the GNU General Public License. For further development in terms of internationalisation, documentation, portability, case-insensitive pattern matching and configurable keymaps, Stefan is receiving help mostly from Claus Brunzema and Tomi Ollila. New releases are to be expected soon.
90
LINUX MAGAZINE
Issue 17 • 2002
The TRAMP (Transparent Remote (file) Access, Multiple Protocol) project should be of interest to many Emacs users. With it, Kai Großjohann provides a GPL add-on to Emacs that bears certain similarities to Ange-FTP. In a networked environment, having to edit a file on another machine is a typical necessity. Ange-FTP enables users to transfer a file through FTP, edit it locally and transfer it back to its origin. Instead of relying on FTP, TRAMP supports shellbased transmission protocols like ssh, telnet and rlogin as well as su and sudo. TRAMP is also designed in a way that should make it reasonably easy to add other ways of accessing a machine, should the need arise. Through the shell connection, TRAMP first checks whether the file exists, what its permissions are and so on. For editing the file, TRAMP offers two possibilities. Files can be modified directly through the shell connection, which is the so-called “inline” method or transferred to the local host, which is similar to the working of Ange-FTP. Kai calls this method “out-of-band”. Additionally, TRAMP has limited remote-execution capabilities. This allows integration with the Version Control (VC) mechanisms, so a file under CVS control can be remotely edited through TRAMP and committed to the repository with the usual C-x v v key sequence. Theoretically, it is also possible to use TRAMP for editing files on Unix via a Windows machine, but getting the configuration right is a bit tricky; it appears to require a very special version of ssh, for instance. Kai cannot provide detailed instructions for this at the moment so if anyone feels capable of giving him a few more details, please do. The opposite case, using a Unix-Emacs to edit files stored on a Windows machine, is even more complicated as TRAMP assumes a Unix-like environment on the remote host. The different Unix-implementations are sometimes quite different, so in order to be as stable as possible, TRAMP always tries multiple ways to assess the file status, for instance. There should be no problem with any of the standard Unix-variants. TRAMP already has quite a bit of history: in earlier versions, its name was rssh.el and then rcp.el. Right now Daniel Pittman is working on a
COMMUNITY
reimplementation of TRAMP, which Kai likes a lot. Future plans also include supporting asynchronous/interactive shell-commands and making the setup of connections more intelligent. Kai would also like to finally assign the copyright to the Free Software Foundation, so TRAMP can become an official part of the GNU Emacs.
Kopi The Kopi project of Decision Management Systems GbmH (DMS) provides a development environment for database applications under Java, JDBC and JFC/Swing. As far as Thomas Graf, the compiler and flagship of the project, is aware, KJC is the only Free Java compiler entirely written in Java itself to fully support the recent Java specifications. The Kopi environment also offers an assembler and disassembler for the Java Virtual Machine (JVM), a library for the generation and modification of JVM class files and XKJC, a compiler for embedded SQL in Java. The finishing touch is Visual Kopi, an application framework providing a special high-level language for creating database applications. Thomas Graf sees the biggest strength of Kopi to be the high quality and speed of the KJC, which beats other compilers like that of Sun (Javac) or IBM (Jikes) in the Jacks (Jikes Automated Compiler Killing Suite) test suite. If you prefer hard numbers, according to the Kopi team, the KJC in client/server mode executes the Jacks test suite (1,845 compilations) in less than 37 seconds on a 1GHz Athlon with Red Hat GNU/Linux 7.1. Also the KJC provides complete diagnostic messages of different types pointing out dangerous/redundant code, “dirty,” old or unreadable syntax or possible optimisations. This should make it much easier for any developer to maintain the code. Keeping Kopi up to date with current specifications is one of the main goals for the future, which is why DMS hired Martin Lackner, who developed several extensions of the upcoming Java 1.4 specification in his thesis at the TU Vienna. Mamisoa Rajosvah is also working on the Developers Guide for Visual Kopi, which should be finished soon. Similar to the GNU Compiler Collection (GCC), the Kopi runtime libraries are released under the GNU Lesser General Public License, while the rest is released under the GNU General Public License. At the end of this issue I’d like to quickly introduce two small but interesting projects.
Enough for today One question that reaches me occasionally is: “How much publicity will a Brave GNU World feature create for me?” Unfortunately there is no final answer to this question.
cdloop Claus Brunzema also wrote the cdloop project, which is a CD player with special looping capabilities. The normal users of this software would be musicians writing down parts of a CD in notation or playing along with them. Normally, AB loop markers can only be set, but not modified afterwards, so everything depends on pushing the button at the exact right moment. cdloop enables users to adjust the marks and even save them as bookmarks. cdloop was written in C++ with Guile and Guile-gtk and is available under the GNU General Public License. Thanks to Guile it is possible to program and configure cdloop in pretty much any imaginable way, so even very unusual applications should not be a problem.
Most projects never inform me whether a significant increase in interest has occurred; although I did receive a very happy mail telling me the interest in a particular project increased significantly – from a few hundred visitors to a few thousand within a few days. Although there are no hard numbers, from my experience I am quite certain that a feature in the Brave GNU World will raise the profile of a project and sometimes create connections that would not have been created otherwise. So like every time, I’m asking for ideas, comments, feedback, questions and project descriptions to the usual address.
Info Send ideas, comments and questions to Brave GNU World Homepage of the GNU Project Homepage of Georg’s Brave GNU World “We run GNU” initiative BZFlag homepage Arkanae homepage Opale.Soya Java 3D engine GNU and Java homepage XShipWars homepage libjsw homepage YIFF homepage Terminus XShipWars universe TRAMP homepage Kopi homepage cdargs homepage cdloop home page
column@brave-gnu-world.org http://www.gnu.org http://brave-gnu-world.org http://www.gnu.org/brave-gnuworld/rungnu/rungnu.en.html http://bzflag.org http://arkanae.tuxfamily.org http://opale.soya.tuxfamily.org http://www.gnu.org/software/java http://wolfpack.twu.net/ShipWars/ XShipWars http://wolfpack.twu.net/libjsw http://wolfpack.twu.net/YIFF http://xsw.terminator.net http://tramp.sourceforge.net http://www.dms.at/kopi http://www.skamphausen.de/ software/cdargs http://www.cbrunzema.de/software. html#cdloop
Issue 17 • 2002
LINUX MAGAZINE
91
COMMUNITY
Want to know more about FreeBSD?
FREE WORLD I
In this issue of Free World Richard Ibbotson take a closer look at installing and configuring FreeBSD and what you might be able to do with this version of BSD
f you speak to experienced BSD users, they’ll probably advise you to start with FreeBSD before progressing to NetBSD or OpenBSD. If you’re well experienced in the world of IT, then this probably doesn’t apply to you but it’s worth bearing in mind before starting a project. Another point of interest is that this version of BSD has a copyright that means you may not be able to do certain things with it if you want to alter the software before redistributing it. Many FreeBSD users will contest that this isn’t so and go on to prove it to you, but if you are a programmer you should check out the copyright before proceeding. FreeBSD is also covered by the GNU public license. If you take a look at the FreeBSD Web site you’ll find many multi-lingual clones of the site so you don’t have to rely purely on the English language version. The FreeBSD documentation project also makes the Linux documentation project look a bit tame. As such it’s well worth taking a look at the Web site.
Getting started If you’re considering installing your first BSD system, there is a Complete FreeBSD boxed set available from the FreeBSD Mall, which includes an excellent easy to use manual. If you’re just experimenting with BSD you can also get hold of your CDs from the Linux Emporium. They also offer the manual, which you can buy later if you want to find out more. At the time that this article was written FreeBSD 4.4 was the latest version available on CD – the next version is presently being tested prior to release. The hardware used for FreeBSD is nearly always based around the i386 architecture such as the Pentium or AMD cpus and associated motherboards. This article was written with the assumption that the interested Free BSD user would be using that kind of hardware.
Figure 1: The Kernel Configuration screen
Installing FreeBSD In order to simplify things we’ll assume that you are booting from the first CD to install your BSD system. If you’ve not done this before, simply start your machine and press and hold the delete key while it boots. You should see a blue BIOS screen. Change the settings from IDEO to boot from CD-ROM then restart your computer. As you’ll find with a lot of Debian/GNU/Linux software the installation process can be confusing. The good news for potential FreeBSD users is that help is at hand in the shape of some extremely useful information on the FreeBSD site. If you go to http://www.freebsd.org/doc/en_US.ISO88591/books/handbook/install.html you’ll find absolutely everything you might need in the way of support. After your computer boots from the CD you will see something like this on the screen: Verifying DMI Pool Data ........ Boot from ATAPI CD-ROM : 1. FD 2.88MB System Type-(00)
Figure 2: Identifying conflicts
92
LINUX MAGAZINE
Issue 17 • 2002
COMMUNITY
Configuring your hardware in the setup
Starting to probe for drives
/boot.config: -P Keyboard: yes BTX loader 1.00 BTX version is 1.01 Console: internal video/keyboard BIOS drive A: is disk0 BIOS drive B: is disk1 BIOS drive C: is disk2 BIOS drive C: is disk3 BIOS 639kB/64512kB available memory FreeBSD/i386 bootstrap loader, Revision 0.8 (jkh@bento.FreeBSD.org, Mon Nov 20 U 11:41:23 GMT 2000) Hit [Enter] to boot immediately, or anyU other key for command prompt. Booting [kernel] in 9 seconds... Once the kernel has booted the Kernel Configuration screen (Figure 1) will launch. Press the return key on one of these options. The next screen (Figure 2) may display some conflicts. According to the folks at FreeBSD the best way to resolve these is by pressing X, which will reveal an expanded driver list. Disable the drivers that you don’t want to use then progress on to the sysinstall menu (Figure 3). If you don’t have the FreeBSD manual then it’s best to refer to the information on the previously mentioned Web page at this point. After allocating drive space to your FreeBSD installation, you’ll be asked to install “sets”, which refers to any software that you may wish to install. For example, you’ll probably want either KDE or GNOME unless you’re
Figure 3: The FreeBSD sysinstall menu
Choosing what you applications you want
Starting XF86Setup to configure your graphics
planning a minimal installation for a firewall or secure server. You’ll now need to choose your installation media – the best option is to select a CD-ROM install. Even if you work on a standalone machine, it’s worth looking at the internal network interface configuration as this also configures network options such as FTP. Issues like security options and time zone selection are then presented. The installer will also ask you whether you want to run Linux software on your newly installed FreeBSD computer. Mouse configuration is followed by the choice of X-windows or no X-windows. The next screen (Figure 4) asks you which desktop you would like, if you’ve made up your mind that the command line console isn’t for you. Linux users may be impressed to see that you can even use the Sawfish desktop with FreeBSD. The next step is to set up a user, which should be familiar from most Linux installations. Once this is Issue 17 • 2002
LINUX MAGAZINE
93
COMMUNITY
Figure 4: Selecting a desktop
complete you can now exit the install screens and choose a root password. If nothing went wrong, and assuming you set up X-windows correctly, you should be able to type in startx and your chosen desktop will load. It should do all of the things that your Red Hat, SuSE or Debian system can do and probably a few things that Linux can’t. If you do encounter any problems during installation it’s useful to know that the online documentation mentioned above includes a helpful troubleshooting section. One issue that you should be aware of is that you may have to produce your own configuration files for /etc/inetd.conf, /etc/hosts.allow or /etc/hosts.deny. Other niggles to do with configuration may also crop up that don’t occur on a newly installed Linux system.
Networking These days most people will either want to connect their computer to an internal network, or more usually to the Internet, with all the security issues this entails. Most Internet connections centre upon a 56K modem, ISDN terminal adapter, cable modem or in
Info FreeBSD site Resources and online documentation
http://www.freebsd.org http://www.freebsd.org/support.html#mailing-list http://www.freebsd.org/doc/en_ US.ISO8859-1/books/handbook/eresources.html For newbies http://www.freebsd.org/projects/newbies.html Unix Gurus http://www.ugu.com Daemon News http://www.daemonnews.org Linux Emporium – for CDs http://www.linuxemporium.co.uk FreeBSD Mall http://www.freebsdmall.com The complete FreeBSD http://www.bsdcentral.com/catalog/index. php?product=1002 Security issues http://www.securityfocus.com/unix Firewalls http://www.obfuscation.org/ipf/ipf-howto.txt
94
LINUX MAGAZINE
Issue 17 • 2002
the case of broadband, an Alcatel ADSL modem. I mention the latter because in recent times the drivers for BSD and broadband have improved greatly and are rock solid – something that can’t be said of Windows ADSL or ISDN drivers. If you do want to use ADSL with BSD then take a look at http://mailbox.univie.ac.at/~le/freebsd+adslhowto_e.html and http://www.xsproject.org/speedtouch/. When it comes to ISDN, things are a lot easier. The i4b package has been around for some time and many on the ISDN cards that aren’t supported elsewhere work just fine under BSD. One of the best ISDN pages on the Internet is Dan Kegel’s page at Caltech (http://www.alumni.caltech.edu/~dank/isdn). With a 56K modem things tend to be slick and problem free – for example, I’ve been able to get some modems working with BSD that simply refuse to work with Linux. After fitting your external or internal modem, the boot messages will show you that your new hardware has been recognised by FreeBSD. You can then proceed to the final configuration, which will most likely include an internal network card and the address of the machine on your network. Before you can connect to the Internet you will also need some basic information from your Internet Service Provider, namely your login password and user name. You’ll also need the first and second DNS IP addresses, also known as nameserver addresses.
Security Computer security is a little like driving, in that you have to be aware of what is behind you (in the past few weeks or years) as well as what may appear in front of you in the not-too-distant future. To deal with previous security issues, check with the BSD site and other sites on the Internet for any updates and security issues that may be relevant to you. To deal with the ongoing security of your system, you should be using things like security tools and firewalls. Useful tools might be portsentry and libsafe and you may also want to look at snort. There are many other useful tools available and you can find these by searching on the Internet.
Next month Next month we take a look at NetBSD, which has become more popular in recent times. It can be used on most types of hardware and it’s thought to be more secure than Linux by its proponents.
The author Richard is the Chairman and Organiser for Sheffield Linux User Groups. To view their site have a look at http://www.sheflug.co.uk.