From 7f456a625db5bdd186ebe7d6c37b982e98da9df3 Mon Sep 17 00:00:00 2001 From: gferg <> Date: Sat, 23 Dec 2000 00:32:23 +0000 Subject: [PATCH] updated --- LDP/howto/linuxdoc/C++Programming-HOWTO.sgml | 70 +++++++++++++------ .../linuxdoc/LILO-crash-rescue-HOWTO.sgml | 55 +++++++++------ LDP/howto/linuxdoc/PHP-HOWTO.sgml | 4 +- 3 files changed, 83 insertions(+), 46 deletions(-) diff --git a/LDP/howto/linuxdoc/C++Programming-HOWTO.sgml b/LDP/howto/linuxdoc/C++Programming-HOWTO.sgml index ec733285..cdc3ea43 100644 --- a/LDP/howto/linuxdoc/C++Programming-HOWTO.sgml +++ b/LDP/howto/linuxdoc/C++Programming-HOWTO.sgml @@ -42,7 +42,7 @@ C++ Programming HOW-TO Al Dev (Alavoor Vasudevan) -v26.0, 18 Dec 2000 +v27.0, 26 Dec 2000 This document discusses methods to avoid memory problems in C++ and also will help you to program properly in C++ language. @@ -1419,36 +1419,45 @@ click on Open Books. --> C++ Coding Standards

-Coding standard is very essential for readability and maitainence of programs. The GNU -C++ compiler must enforce coding discipline. The following is suggested : +Coding standard is very essential for readability and maitainence of programs. And +it also greatly inproves the productivity of the programmer. The GNU +C++ compiler must enforce coding discipline. The following is suggested - +inside class definition: - All public variables must begin with any m like mFooVar - All protected variables must begin with mt, like mtFooVar and methods with t - All private variables must begin with mv, like mvFooVar and methods with v - All public, protected and private variables must begin with uppercase after m like F in mFooVar + All public variables must begin with m like mFooVar. +The m stands for member. + All protected variables must begin with mt, +like mtFooVar and methods with t, like tFooNum(). +The t stands for protected. + All private variables must begin with mv, like mvFooVar and +methods with v, like vFooLone(). The v stands for private. + All public, protected and private variables must begin with +uppercase after m like F in mFooVar. All pointer variables must be prefixed with p, like - Public variables pFooVar - Protected variables mtpFooVar and methods with t - Private variables mvpFooVar and methods with v + Public variables mpFooVar and methods like FooNum() + Protected variables mtpFooVar and methods with t like tFooNum() + Private variables mvpFooVar and methods with v like vFooNum() -The compiler should generate error if the code does not follow standard. +The compiler should generate error if the code does not follow above standard. The C++ compiler can provide a flag option to bypass strict coding standard to compile old source code, and for all new code being developed will follow the uniform world-wide coding standard. -In sample code given below t stands for protected, +In the sample code given below t stands for protected, v stands for private, m stands for member-variable and p stands for pointer. -class SomeFunName +class SomeFunMuncho { public: - int mZimboniMacho; - float *mpArrayNumbers; + int mTempZimboniMacho; // Only temporary variables should be public as per OOP + float *mpTempArrayNumbers; int HandleError(); + float getBonyBox(); // Public accessor as per OOP design + float setBonyBox(); // Public accessor as per OOP design protected: float mtBonyBox; int *mtpBonyHands; @@ -1462,19 +1471,32 @@ class SomeFunName int vGetNumbers(); }; +When your program grows by millions of lines of code, then you will greatly +appreciate the naming convention as above. The readability of code improves, +because just by looking at the variable name like mvFirstName you can +tell that it is member of a class and is a private variable. Visit the C++ Coding Standards URLs C++ FAQ Lite - Coding standards - Rice univ - C++ coding standard + Rice university coding standard + Identifiers to avoid in C++ Programs Coding standards from Possibility - Coding standards from Ambysoft - +and + Coding standards for Java and C++ from Ambysoft Rules and recommendations Indent and annotate Elemental rules C++ style doc + C++ Coding Standards by Brett Scolcum + Logikos C++ Coding Standards + NRad C++ coding standards + BEJUG C++ coding standards +

+See also + For rapid navigation with ctags + + To improve productivity see Other Formats of this Document

-This document is published in 11 different formats namely - DVI, Postscript, +This document is published in 12 different formats namely - DVI, Postscript, Latex, Adobe Acrobat PDF, -LyX, GNU-info, HTML, RTF(Rich Text Format), Plain-text, Unix man pages and SGML. +LyX, GNU-info, HTML, RTF(Rich Text Format), Plain-text, Unix man pages, +single HTML file and SGML. You can get this HOWTO document as a single file tar ball in HTML, DVI, @@ -3094,6 +3117,7 @@ You can download all programs as a single tar.gz file from and give the following command to unpack +bash$ man tar bash$ tar ztvf C++Programming-HOWTO.tar.gz This will list the table of contents diff --git a/LDP/howto/linuxdoc/LILO-crash-rescue-HOWTO.sgml b/LDP/howto/linuxdoc/LILO-crash-rescue-HOWTO.sgml index 0260bc41..86ddc352 100644 --- a/LDP/howto/linuxdoc/LILO-crash-rescue-HOWTO.sgml +++ b/LDP/howto/linuxdoc/LILO-crash-rescue-HOWTO.sgml @@ -43,7 +43,7 @@ LILO, Linux Crash Rescue HOW-TO Al Dev (Alavoor Vasudevan) -v5.0, 05 Dec 2000 +v6.0, 25 Dec 2000 This document discusses methods to recover from Linux system failures. Various reasons for linux system failures can be - @@ -99,7 +99,8 @@ Follow these steps to recover from LILO or system failures. root partition by doing this - bash# fdisk /dev/hda -bash# mkdir /dev/hda1 /test +bash# mkdir /test +bash# mount /dev/hda1 /test bash# ls /test You should see root-partition list like this - bin fd lib mnt proc sbin usr @@ -107,16 +108,17 @@ boot dev etc home lost+found opt root tmp var If this is not a root partition, then try the next partition /dev/hda2. Next try hda3, hda4, hda5, etc.. untill you find the root partition. - Still not found then repeat for other devices like hdb, hdc, hdd etc.. + Still not found in hda then repeat the above steps for other devices + like hdb, hdc, hdd etc.. Also the /usr, /var, and /boot partition are needed as these are required to create new lilo configuration. -In my case the root partition is /dev/hda4 which is used in examples below: +In my case the root partition is /dev/hda4 which is used in the examples below: bash# mkdir /hda4 bash# mount /dev/hda4 /hda4 bash# cat /hda4/etc/fstab -Read the output of fstab and mount partitions as below - + Read the output of fstab and mount partitions as per fstab file, see below - bash# mount /dev/hda5 /hda4/boot bash# mount /dev/hda6 /hda4/usr bash# mount /dev/hda7 /hda4/var @@ -124,9 +126,12 @@ bash# mount /dev/hda8 /hda4/opt bash# mount /dev/hda9 /hda4/root bash# mount /dev/hda10 /hda4/home +In my case, as per fstab file hda5 was boot, hda6 was usr, hda7 was var, hda8 was opt, +hda9 was root, hda10 was home and hda11 was windows95 directory. Edit /etc/fstab (not /hda4/etc/fstab) and put (sample code given here) - + /dev/hda4 /hda4 ext2 defaults 1 1 /dev/hda5 /hda4/boot ext2 defaults 1 1 /dev/hda6 /hda4/usr ext2 defaults 1 1 /dev/hda7 /hda4/var ext2 defaults 1 1 @@ -134,22 +139,22 @@ Edit /etc/fstab (not /hda4/etc/fstab) and put (sample code given here) - /dev/hda9 /hda4/root ext2 defaults 1 1 /dev/hda10 /hda4/home ext2 defaults 1 1 /dev/hda11 /hda4/win95part vfat defaults 1 1 -On my computer hda4 contains the linux boot/root partition and + +On my computer hda4 contains the linux root partition, hda5 had boot partition and hda11 has windows 95 vfat system. bash# mkdir /hda4/win95part bash# mount /hda4/win95part -And repair the system using fsck or e2fsck commands. + And repair the system using fsck or e2fsck commands. bash# man fsck bash# man e2fsck

SCENE 2: If LILO is not working..

- Follow scene 1 above, if that fails then + Follow scene 1 above, if that fails then follow these steps. Now you should have +already mounted /hda4 and have created /etc/fstab file. -bash# mkdir /hda4 -bash# mount /hda4 bash# mount -a bash# chroot /hda4 /sbin/lilo -q bash# man chroot @@ -157,7 +162,7 @@ bash# chroot /hda4 /sbin/lilo Alternatively, you can directly use /sbin/lilo instead of chroot. The -r option of lilo actually does chroot. -It is very strongly recommended that you use chroot, instead of lilo -r, +It is very strongly recommended that you use chroot, instead of lilo -r, as it is more convenient and can catch errors more easily. bash# man lilo @@ -188,17 +193,24 @@ bash# mkbootdisk /dev/fd0 Make sure you move the /etc/lilo-original.conf back to /etc/lilo.conf!! And then take this floppy and goto scene 3

- SCENE 5: If scenes 1, 2, 3 and 4 above fails then + SCENE 5: This is the worst scenerio, hopefully you do not come to this +stage. Scenes from 1 to 4 take care of majority of cases. But in case above +scenes 1, 2, 3 and 4 all fail then -

Step 1: Boot tomsrtbt and mount the partitions and backup the root partition to another partition having disk space with comamnds - - Edit /etc/fstab and put (sample code given here) - - /dev/hdb1 /b1 vfat defaults 1 1 + Edit /etc/fstab and put (sample code given here, you may have to + change as per your disk layout) - + /dev/hda4 /hda4 ext2 defaults 1 1 + /dev/hda11 /b1 vfat defaults 1 1 +bash$ mkdir /hda4; mount /hda4 bash$ mkdir /b1; mount /b1 bash$ cd / -bash$ tar cvf /b1/root-a4.tar a4 +bash$ df + And see that there is enough disk space in /b1 to tar up the root partition +bash$ tar cvf /b1/root-hda4.tar /hda4

Step 2: @@ -218,10 +230,9 @@ bash# cp /etc/lilo.conf /etc/lilo-original.conf bash# mkbootdisk /dev/fd0 bash# cp /etc/lilo-original.conf /etc/lilo.conf - Take this floppy to problem machine and - test this boot floppy to see that this works and then + Test this boot floppy to see that this works and then restore back the all the files which you backedup using tar on - /b1/root-a4.tar as in step 1 above. + /b1/root-hda4.tar as in step 1 above. Removing LILO

-You can replace the boot sector with the DOS boot loader by issuing the DOS command: +You can replace the boot sector with the DOS boot loader by issuing the DOS +command at MS DOS prompt: FDISK /MBR @@ -289,7 +301,7 @@ uninstalling the LILO. And see also 'man lilo'. --> Common mistakes

-After making changes to /etc/lilo.conf you MUST run lilo to make changes +After making changes to /etc/lilo.conf you MUST run lilo to make changes to go in effect. It is a very common mistake committed by newusers. Type - bash# lilo -v -v -v @@ -337,7 +349,8 @@ Visit following locators which are related to LILO, Rescue Linux, crash recovery

This document is published in 11 different formats namely - DVI, Postscript, Latex, Adobe Acrobat PDF, -LyX, GNU-info, HTML, RTF(Rich Text Format), Plain-text, Unix man pages and SGML. +LyX, GNU-info, HTML, RTF(Rich Text Format), Plain-text, Unix man pages, +single HTML file and SGML. You can get this HOWTO document as a single file tar ball in HTML, DVI, diff --git a/LDP/howto/linuxdoc/PHP-HOWTO.sgml b/LDP/howto/linuxdoc/PHP-HOWTO.sgml index bf456388..3fadf882 100644 --- a/LDP/howto/linuxdoc/PHP-HOWTO.sgml +++ b/LDP/howto/linuxdoc/PHP-HOWTO.sgml @@ -796,10 +796,10 @@ main(int argc, char **argv) for ( ; fgets(buff, BUFF_LEN, fpin) != NULL; ) { char aa[BUFF_LEN + 100]; - char *aapointer; + char aapointer[BUFF_LEN + 100]; memset(aa, 0, BUFF_LEN +10); strcpy(aa, buff); - aapointer = ltrim(aa); + strcpy(aapointer, ltrim(aa)); strcpy(aa, aapointer); // Remove the trailing new line..