Sunday, April 8, 2007

Backup took about 2 hours to take, plus a lot of set up time because of networking issues... It was to much bugger working with the install disk as a subsitute R&RO disk.

So booted and dropped to single user, mounted stuff RO after having fsck'd it with the install disk. Dumped it 'cross the network after sorting out a minor issue with PF ! Alls good but next time I think I need more compression and less speed on the gzip.

Only problem is I need to get the archive to a partition I can trust, that would be a FAT32 one but the max file size is 4GB and the backups a bit fatter then that. Tried to copy it to an ext3fs so I could test doing a restore to a Linux partition. While ext3 I think can handle files 16GB++ to a few TB. I could only create a 2GB file on it so bonkers.

If I can bzip or 7z it down to the right size I might be able to burn it to DVD-R. I think my best bet would be to *try* and copy the the dump from the ufs2 slice to my ntfs one using an ifs driver for it on XP.

Caesar

Ok so I'm a crazy stooge !

I spent the night trying to evade my allergies by implementing a simple rot13 program based on some super-short implemnetations of the algorithm from USENET.

Shes got interactive and file based rot13, a -r option set up to use a different rotation then 13... but I havn't implemented those yet hehehe.

Had a lot of fun working on it and learned a few things while working on the manual page that even let me clean up rf.1 !

Saturday, April 7, 2007

Gotta look at: http://synergy2.sourceforge.net/

Taking a dump(8) to - (stdin) and piping it to gzip and using |ssh over the network to use dd to create a backup might not be a bad idea.

dump -0f - / | gzip -2 | ssh -c blowfish Terry@IP dd of=vectra_date.gz

hmm.

Monday, April 2, 2007

later

Got to remember to back up my home directory.

Think it'd be some thing like

cd ~
su
mv Music /somewhere
pax -wf /Backups/_usr-home-Terry.pax ./*
cd /Backups
gzip -9 _user-home-Terry.pax

I'll worry about it later

Sunday, April 1, 2007

peace

Finnally... some time to relax.

This weeks been heck between work, allergies, and business. Little time to even be on the laptop.

Been working my way slowly threw a few books Link1 Link2.

Been working on stuff /w the SNCO project most of the week... been digging into XHTML/CSS with it. I'm starting to write pages XHTML compilent and use the validator to catch typos. Usually missing '/' on end tags in lists.

Had the bosses dog for the weekend while they were out of town.... spent most of it walking 3 dogs and being sat on.


I feel like shaving, showering, and throwing a 'Spidey can go back to work' party and inviting both the RvS and S4 departments lol.. Sad when you need a vacation from your time off work ! Or feel happy to be getting back to work in a day or two.




R&R would be nice....

Sunday, March 25, 2007

Vs

Hmm, what a day.

Ironed out a few more things with my work in the SNCO Project.

Fire & Movement -> Submited
Rules of Engagment -> Submited
Breaching -> Fixing (post submited)
Stacking -> Converted (post submited)
Tactical Aids -> Working
Reloading Drill -> Submited + Tweaked & Resubmited
Equippment Loadouts -> Completed, not submited

Made changes to En4cers changes on basic training, submitted it back to him but no word yet. Maybe I should send it to Rouge since its technically supposed to go through the RSM then to GCHQ. No idea what En4cer is doing these days.... Feeling is mutal I'm sure.

Can't really complete every thing on Room Clearing at the moment (En4cer) and I have little interest in the Planning & Leading one. Although that one might be able to stand as is hehe (y).


Spent most of the day on holiday after finishing some work on it. Joined Lazko & Ranger for some 2 on 1 on a super small map. Abiliterated them using the 40mm and mixing my kit around. Never really they knew what I was going to do, other then strike.

After wards joined Random/Lazko for a game, Random I soon found. Was much to seasoned a cat to fall prey to a Spider. Just as I was a bit to expirenced for Lazko & Ranger to have to much a head start. Since they were very fair and didn't spawn rape much.

Eventually got into a baton war hehe. That blighters the fastest reloading weapon in the game I bet.

Friday, March 23, 2007

I could swear... trying to do any thing in this freaking place. Is harder then trying to have sex with a woman a football fields length away !

I'm sick and tire dof having to do things in the dead of night just to be able to fucking hear my self think.

Monday, March 19, 2007

Evil to do lists

Front burner...

  • Do my home work (ARRGGH)
  • Shift threw the admin to do list
  • Do some home work on the admin matter I'm all ready 'dealing with'
  • Do my moms data entry work (oh joy)
  • Work on my (software) backup plans

Back burner...

  • Finish work in the SNCO project
  • Set up Samba
  • Set up PF, the OpenBSD Packet Filter firewall
  • Finish my private reading (I love books... never get to read'em any more)


edit later as needed.

Diff and Patch

Tests have shown, that using diff to create a patch file and using the patch file to patch the origenal. Have been largly successful so long as the origenal has not been edited since the diff was made.

TDL

Remember to put DD_Snip on the TS list.
Notes

archive: pax -wf archive /what
append to archive: pax -waf archive /more
unpack: pax -rf archive # unpacks in current directory
list: pax -f archive | $PAGER

the -z option adds gzip compression as with tar.

Also the -i and -v options work as per convention.

exclude file with the -c 'file' command or only file with -n 'file'. Like:

pax -rf archive -c 'ignoreme' && pax -rf archive -n 'onlyme'

gzip -# works well for the archives, where # is 0-9 low-high compression.

Quotes

Hehe I think these rock

    * "Unix is simple. It just takes a genius to understand its simplicity." – Dennis Ritchie
    * "UNIX was not designed to stop its users from doing stupid things, as that would also stop them from doing clever things." – Doug Gwyn
    * "Unix never says 'please'." – Rob Pike
    * "Unix is user-friendly. It just isn't promiscuous about which users it's friendly with." – Steven King
    * "Those who don't understand UNIX are condemned to reinvent it, poorly." – Henry Spencer

The funny thing, is th last one is true in a way lol.

Sunday, March 18, 2007

back up war

http://www.phenix.bnl.gov/~purschke/RescueCD/
http://www.cpqlinux.com/ddbackup.html

Some good links for later :-)

*wink*

Friday, March 16, 2007

$MYVIMRC

My current ~/.vimrc file. The {{{ & }}} mark the locations of folds, I elected to ues folding marks for my rc file. And when I have time to read how, I probably will set it to allow sectional jumping.

In short form, the file ensures that Vim does not read my .exrc file, does not try to be strictly vi compatible. Auto reads changes to files, keeps files at 80 char width (see tw), make for a more comfortable movement pattern near EOL. Yank into the clipboard, enable syntax folding on new files (my preference for sources), DOS EOL for new .txt files. Set somes sizes, enable my 'HUD' ^_^, turn on a nice colour scheme, and syntax highlighting. Set fonts, and a few useful keymaps. :help <option> generally works for looking things up in the manual (help can be shortened to he. with no sexist intent.)

"Terry M. P***** personal vimrc file

" vim: set ts=6 sw=6 expandtab foldmethod=marker foldcolumn=1 foldlevelstart=99:
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"    WARNING !!! 
" This file must have UNIX end of lines to avoid errors when starting
" under unix. Use the pdos2unix and punix2dos sh scripts to convert or
"
" perl -p -e 's/\n/\r\n/' inputfile > outputfile  # UNIX to DOS
" perl -p -e 's/\r\n/\n/' inputfile > outputfile  # DOS to UNIX
"
" on the command line
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Abstract
"
" Editing Preferences - set options related to editing tasks
" User Interface Preferences - set options related to appearance
" Keybinds & Commands - mappings / created 


"""""""""""""""""""""""""""""""
"Editing Options {{{
"""""""""""""""""""""""""""""""

"Don't be VI compatible - Keep this at top of file !
set nocompatible
set noexrc

"automatic re-reading of changed open files
set autoread


"ingore case when searching
set ignorecase

" Use the system clipboard as the default register
set clipboard=unnamed

"Buffer related {{{
"Allow backspacing over everything in insert mode
set backspace=indent,eol,start
"Allow to go one space past EOL
set virtualedit=onemore
"Allow left/right movement at EOL to move to start of next line
set whichwrap=hl<>
"Wrap text at n chars with a line break
set textwidth=80
"set wrap
set linebreak

"Folding
if has("gui_running")
      set foldmethod=manual
      set foldcolumn=0
else
      "Use sytanx folding in console mode
      autocmd BufNewFile,BufRead *set foldmethod=syntax foldcolumn=1
endif

"}}}

"Size stuff {{{
"Tab length and shift lengths
set tabstop=8
set shiftwidth=4

"Set min # of spaces for numberwidth. It grows as needed
set numberwidth=2

"Set tab menu 0=never, 1=when more then one, 2=always
set showtabline=1

" Start with folds open
set foldlevelstart=99

"}}}

"File related {{{

"Set prefered line file formats
set ffs=unix,dos,mac
"Enable filetype detection
filetype on
"Turn off ft plugin and indent
filetype plugin off
filetype indent off

" Create new.txt files notepad ready
autocmd BufNewFile *.txt set ff=dos

"Enable syntax highlighting
if &t_Co > 2 || has("gui_running")
      syntax on
endif

" Highlight strings inside C comments
"let c_comment_strings=1


"}}}

" }}}
"""""""""""""""""""""""""""""""
" Keybindings {{{
"""""""""""""""""""""""""""""""

"Maps {{{

"Use the ";" as a duplicate of ":" makes life so much easier
"for some odd reason it cannot be followed with a comment on it's line!
:nma ; :

"F1 turns on spellchecking in current buffer
map  :setlocal spell spelllang=en_us

"F2 turn on line numbering
map  :set number

"F3 turn on self indenting magic
map  :set smartindent autoindent

"F10 rids us of ^M after carriage returns
map  :%s// /g

"}}}

"}}} 
"""""""""""""""""""""""""""""""
"User Interface Options {{{
"""""""""""""""""""""""""""""""

"Always show the status bar with file name e.t.c.
set laststatus=2
"Show %of file in statusbar
set ruler 

"Command line completion lists possible matches
set wildmode=list:full

"Start with mouse support
set mouse=a
"Hide the mouse when typing text
set mousehide 

" Dependant on GUI on/off {{{
if has ("gui_running") 
      "Set colo and options
      colorscheme denim
      " Set 'go' to:
      "autoselect, console dialogs, tabpages, icon, menubar, show grey menu
      "items, tearoff menu items, Toolbar, always right scrollbar.
      set guioptions=aceimgtTr

      "Make pointer an I-Beam in insert mode
      set mouseshape=i:beam
      "for spellchecking
      set mousemodel=popup_setpos
      "set cmd line size
      set cmdheight=2

      "Set windows specifics
      if has("win32")
            "Windows font
            set guifont=Fixedsys:h7:cANSI
      "Set x11 specifics
      elseif has("x11")
            set guifont=Fixed\ Semi-Condensed\ 13 
            set columns=80
            set lines=35
      endif
else
      "set colors for terminal
      colo advantage
      "set cmd line size
      set cmdheight=1
endif

"}}}

" }}}

Thursday, March 15, 2007

Memo 2 Self

Ask Wiz what happened with those icons.

OpenBSD

The day before yesterday I backed up Vectra, /kolab, /etc, /usr/local/etc. And reformatted the computer and installed OpenBSD 4.0.

http://www.openbsd.org/

The worlds most secure OS, with only two remote holes in the default install found in over 10 years. And a heck of a lot of looking !!!

With out a doubt, this is the easiest to install OS I have ever worked with. I downloaded floppy40.fs from one of the FTP Mirrors. There are 40, 40A, and 40B. For most 'Desktop', 'Server', and 'Laptop' hardware sets respectfully.

I put one of my 3.5" Stiffies in floppy disk drive #1 (/dev/fd0). Formated the disk and did a byte exact copy with the dd command.

Vectra# fdformat /dev/fd0
  Format 1440K floppy `/dev/fd0'? (y/n): y
  Processing VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV done.
Vectra# dd if=floppy40.fs of=/dev/rfd0c bs=32k
Vectra# cmp /dev/fd0 floppy40.fs
Vectra#

As per the OpenBSD documentation I used the compare utility to make sure I had a clean disk. Gotta remember about ol'cmp(1) hehe.

I ejected the disk and labeled it, 'OpenBSD 4.0 Floppy40.fs'. Reinserted it and rebooted my computer. (After swapping monitors and keyboards).

The PC booted off the stiff disk, giving me a boot> prompt. Very sweetly I could use 'ls' to see what was on the disk, boot and bsd. Knowing that bsd was the kernel (from reading tfm) I booted it.

boot> boot bsd

Of course it will auto loaded the kernel into memory if you let it sit for a few seconds. Afterwards it asked for an install, upgrade, or shell prompt. I could have used a CD-ROM, but for just making a boot disk with an installer I felt it was kind of wasteful. Especially when Vectra is the only _personal_ computer I have /w a floppy drive. Ma's has one but she'd freak if her PC booted to a getty prompt !

The installer reminds me some what of Slackware GNU/Linux's way of asking which kernel to boot. But for the whole installer xD. I'm sorry to say that OpenBSD, while being the easiest to install OS I have _ever_ seen. Is not for the faint of heart to install !

The installer asked me for a terminal type, defaulting to vt220. I'm not really very smart about the old terminals having never used one. But the internet helps. The vt220 came with a LK201 keyboard with a layout close enough to the modern US Standard keyboard layout for my tastes. The only sad thing is that one cannot press scroll lock and page back to read stuff that flew by. At least on my system so, I'd recommend having the manual handy during partitioning.



The installer prompted for a kbd map, I took the default 'us' layout.

Welcome to the OpenBSD/i386 4.0 install program.

  This program will help you install OpenBSD in a simple and rational way. At
  any prompt except password prompts you can run a shell command by typing
  '!foo', or escape to a shell by typing '!'. Default answers are shown in []'s
  and are selected by pressing RETURN. At any time you can exit this program by
  pressing Control-C and then RETURN, but quitting during an install can leave
  your system in an inconsistent state.

  Specify terminal type: [vt220] 
  kbd(8) mapping? ('L' for list) [none]

OpenBSD even supports using a serial console with a little hanky panky. One of the things, that in my opinion was very professional and a great change. It asked me _if_ I had a backup of my data. Normally (in my exp) you only get a warning about how dangerous it can be to any data on disk (which of course OpenBSD did). We then proceeded into the partitioning phase.

It listed the available disks (wd0) and asked for the root disk. I was prompted to use all of the disk or (default) not to use the whole disk for BSD. Being a dedicated machine, I wanted the whole disk used. If you want to multi-boot or make multiple slices (primary partitions) you'll need to elect for a fdisking nightmare. Generally OpenBSD supports disks up to one Terrabyte, thats about 1,000,000 MB. Wwell, not really but close enough and easier to remember :-P. I chose to use the whole disk, so I was allowed to skip fdisk and go on to disklabel maker 9.0 pro.

I must warn ya, the fdisk/disklabel software has not advanced much in terms of interface. Since the ex(1) line editor was mans best friend. FYI, vi is a 'visual' interface to the 'extended' editor :-)

I created a group of bsd partitions in my slice, following the suggestions most of the time.

From my installed system:
Terry@vectra-$ df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/wd0a      147M   28.0M    112M    20%    /
/dev/wd0h      393M    628K    372M     0%    /home
/dev/wd0d     98.3M    2.0K   93.4M     0%    /tmp
/dev/wd0g      6.7G    426M    5.9G     7%    /usr
/dev/wd0e      148M    5.8M    135M     4%    /var

One can set the offset, size, FS Type, and mount point when adding a new partition. Very lucky for me, it was smart enough to find the offset itself. I don't really like working in cylinders so I was pleased to be able to specify the size in a more friendly manor. Such as 150M for 150 Megabytes :-)

The file system type is '4.2BSD" or swap. wd0a and wd0b default to the root / partition and swap partitions respectfully. Also the wd0c refers to the _entire_ slice (primary partition). When done, I wrote the label and exited. It prompted me to confirm the mount points, kind of handy. After confirming my 5 mount points I issued a 'done'.

Yet again, it wanted me to confirm that I wanted to continue with the formating. It auto formated each partition in the label and took me to the configuration phase.


I have never seen such a simple configuration phase, all it really amounts to is setting up enough data for the machine to attach to the network, or at least use the 'hostname' command. I set the short hostname when prompted to 'vectra'. I then had a boolean problem, do I configure the network or not? Since I don't see any point in waiting till first boot or chrooting after install and doing it before first boot. I decided to set up the network settings. Be warned, the only text editor you have to work with is ed(1). I really hate ed, but its a good little editor when you think about how tight the space is on a 1.44MB boot disk.

I set up my 3Com ethernet NIC (xl0) using DHCP, when prompted and worked the following.

  DNS domain name? (e.g. 'bar.com') [my.domain] my.domain
  DNS nameserver? (IP address or 'none') [my name servers] Enter
  Use the nameserver now? [yes] yeskbd>
  Default route? (IP address, 'dhcp' or 'none') [dhcp] dhcp
  Edit hosts with ed? [no] Enter
  Do you want to do any manual network configuration? [no] yes

A very nice set up, I then used the shell and ed to take a look at my network configuration, all was right. After exiting the shell, I was ordered to set roots password. That completed the configuration phase ! Yeah thats it, all you really have to set up is enough to get a network connection and a password for root.

Not having been able to afford a disk set, when prompted for the install media (i386 supports cd, disk, ftp, and http). I took up an ftp install, electing _not_ to setup ftp/http proxy connection details. As I do not have one to worry about when doing this stuff ^_^

I installed using the ftp.openbsd.org mirror with the default package sets. Be warned it does take a little while for it to connect to the server and let you choose packages. The required are:

  • bsd - The Kernel
  • base40.tgz - The base system (think /bin:/sbin:/usr/bin:/usr/sbin e.t.c)
  • * bsd.mp - Multi-processor (SMP) kernel (only some platforms) * bsd.rd - RAM disk kernel
  • etc40.tgz - System Configuration files (/etc)

The other packages are: comp40, development tools (gcc, headers, libs e.t.c.), man40 (man pages), misc40 (extra docs), games40 (simple games), and a slew of x* packages required for using the X Windows System. Being intended for a SMB/NTP/Print server, I don't need an X Server eating my 8GB disk.


The system fetched and installed each package I selected from the ftp mirror and took me to the 'startup' phase. Where I could adjust settings related to what would turn on automatically at boot. Namely.

Do I want SSHD (default yes), my LAN requires this since I can't get a KVM switch.

Do I want NTPD (default no), I want vectra to be a time server for my lan.

Do I expect to run X (default no), which if yes would tune a few things to make the XxX life easier.

Should the default console be com0, *nix starts numbers at 0, so BSDs com0 is DOS/Winsucks com1 !

And a would've been nicer to ask during configuration: Time Zone setup. I elected for 'Zulu' time. I don't use local time for much, and try to use UTC when ever I can.

A little BSD Magic and vola

CONGRATULATIONS! Your OpenBSD install has been successfully completed!
  To boot the new system, enter halt at the command prompt. Once the
  system has halted, reset the machine and boot from the disk.

The manual did mention chroot'ing and doing configuration before reboot, but I found that it was unnecessary for my needs.

On reboot I had a very good working system, checked the afterboot man page, confirmed I had a solid network connection, added a regular user(s), and could SSH in from it/them.

All was well and good, but after like 10-15 mintues the system would drop off the LAN. I couldn't figure it out, but putting a KB or monitor back on it fixed it. After a poke in the BIOS the next morning. I found a very interesting option :-)

The system was set to stand by after n minutes, I tested with both standby and suspend set to 15 minutes. And sure enough after 15 minutes my SSH session would time out. And I'd have to physically type a key on the keyboard, or insert one into the port. After I cleared this, all was well ! FreeBSD never cared a rats behind but FreeBSD is not OpenBSD :-)

I had thought maybe the kernel thought there was a problem /w the default console, but I figured that'd leave some viable info or a crash. Apparently the BIOS was the problem hehe.

PC-BSD, an easy to install FreeBSD based desktop has a great GUI installer. Very easy and simple, but I think OpenBSDs was easier. Since I elect to do 'advanced' installs with PC-BSD rather then the short basics. Never the less, the effect was the same.

PC-BSD, a fully working KDE Desktop on the first boot.

OpenBSD, a fully working Console System on the first boot.

I didn't really have to configure a bloody thing after running adduser on the OpenBSD box ;-) Of course theres more work to do, but not as a case of getting a _working_ system. I find OpenBSD so far to be a great system.

Monday, March 12, 2007

Yippers

You know... a mixture of tired/bored is very dangerous when you start:

Reading about sockets programming
and learning how to get a dump of pages html via telnet

and sockets start sounding like a very bloody good idea....

Sunday, March 11, 2007

rf.c

Well I've done some correcting to my little back scratcher, including two bug fixes and changes to the man page.

/*-
 * Copyright (C) 2007
 * Terry *. P*****. All rights reserved.
 *
 * permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */


// vim: set noexpandtab ts=8 sw=4 ai :
// vi: set ai nu ts=8 sw=4 :

#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>

struct lnpos {
 long nl;
 struct lnpos *next;
};

static void readall( FILE *, int );
static void readtop( FILE *, int );
static void readbottom( FILE *, int );
static void usage( void );

/*
 * rf - read file to standard out v1.1
 */

int
main( int argc, char *argv[] ) {
 
 char *erptr;
 int t_flag = 0, b_flag = 0;
 int ch, lncnt;
 FILE *fp;

 extern char *optarg;
 extern int optind;
 extern int optopt;
 extern int opterr;
 extern int optreset;

 while ( (ch = getopt(argc, argv, "b:t:")) != -1 ) {
  switch (ch) {
  case 'b':
   b_flag++;
   lncnt = strtol(optarg, &erptr, 10);
   if ( *erptr || lncnt <= 0 )
    errx( 1, "Improper line count -- %s", optarg );
   break;
  case 't':
   t_flag++;
   lncnt = strtol(optarg, &erptr, 10);
   if ( *erptr || lncnt <= 0 )
    errx( 1, "Improper line count -- %s", optarg );
   break;
  case '?':
  default:
   usage();
   return 1;
  }
 }

 if ( (t_flag < 1) && (b_flag < 1) )  {
  fp = fopen( argv[1], "r" );
  if ( fp == NULL ) 
   errx( 1, "File can not be opened or"
         " does not exist -- %s\n", argv[1] );
  readall( fp, lncnt );
 } else if ( t_flag > 0 ) {
  fp = fopen( argv[3], "r" );
  if ( fp == NULL )
   errx( 1, "File can not be opened or"
         " does not exist -- %s\n", argv[3] );
  readtop( fp, lncnt );
 } else if ( b_flag > 0 ) {
  fp = fopen( argv[3], "r" );
  if ( fp == NULL )
   errx( 1, "File can not be opened or"
         " does not exist -- %s\n", argv[3] );
      readbottom( fp, lncnt );
 } else {
  usage();
  /* NOTREACHED */
 }

 fclose( fp );
 return 0;
}

/*
 * print out an open file to standard output
 */

static void 
readall( FILE *fp, int lncnt ) {

 while ( (lncnt = fgetc( fp )) != EOF ) {
  printf( "%c", lncnt );
 }
}

/* Read n lines from the top of the file.
 * note that it was very inspired by the head(1) implementation of BSD
 */
static void
readtop( FILE *fp, int lncnt ) {

 char *cp;
 size_t error, rlen;
 while ( lncnt && (cp = fgetln( fp, &rlen )) != NULL ) {
  error = fwrite( cp, sizeof(char), rlen, stdout );
  if ( error != rlen )
   err( 1, "stdout" );
  lncnt--;
 }
}


/* Read n lines from the bottom of the file
 */
static void
readbottom( FILE *fp, int lncnt ) {

 int hmany = lncnt;
 long nlnum = 0;
 long where;

 struct lnpos *root;
 struct lnpos *cur;

 root = malloc( sizeof(struct lnpos) );
 if ( root == NULL )
  err( 1, "can't init the list" );
 root->next = 0;
 cur = root;

 cur->next = malloc( sizeof(struct lnpos) );
 if ( cur->next == NULL )
  err( 1, "can't add nodes" );
 cur = cur->next;

 /* read the file, count every '\n' and store them in a new member of
  * our linked list.
  */
 while ( (lncnt = fgetc( fp )) != EOF ) {
  if ( lncnt == '\n' ) {
   nlnum++;
   cur->nl = ftell( fp );
   if ( cur->next != NULL ) 
    cur = cur->next;
   cur->next = malloc( sizeof(struct lnpos) );
   if ( cur->next == NULL )
    err( 1, "can't add nodes" );
   cur = cur->next;
  }
 }

 /* rewind our linked-list and seek to b_flag + 1 segments short of the
  * end of the list _before_ calling readall. So readall _starts_ from
  * the correct fseek offset to print till EOF.
  */
 cur = root->next;
 hmany++;
 while ( hmany < nlnum ) {
  cur = cur->next;
  nlnum--;
  
 }

 where = fseek( fp, cur->nl, SEEK_SET );
 if ( where != 0 )
  err( 1, "could not seek through the file\n" );

 readall( fp, lncnt );
}

static void
usage( void ) {
 fprintf( stderr, "usage:\n rf file\n "
         "rf [-t number lines from the top] file\n "
  "rf [ -b number of lines from the bottom ] [ file ]\n" );
}


And the manual which writing got me interested in roff, I'll post when I have time to learn more about it. Basically the problem I had was caused by working on it. Originally under the conditions when 2 + 2 = 5 which is not good, because 2 + 2 is really == 4 !!!! I should never do stuff when I'm like that, but if I don't try nothing gets done.

Saturday, March 10, 2007

Go, what?

Well, to day I was working on some file. And for the first time I asked my self if I should use a 'Goto'. The goto statement is probably one of the most controversial things I've ever read of in computing history.

The problem was, I had the option of repeating several lines of code at several conditionals in a if-elif-else construct. I thought about using a goto to walkk on over to that. So as to only right it once. When I asked my self, Do I even remember the syntax for a Goto ! LMAO !!! I can't even ever remember using a Go to in any language. The only time I recall learning about using was breifly in an historical C tutorial by by Brian W. Kernighan. Then I thought, since I didn't want to clutter things by getting repetitive - Why not get off my lazy arse and wrap it in a function?

Really the only purpose of using goto often I could see would be to avoid using functions at all. The best usage of it I can see, which could still be wrapped in a function if wanted. Although I'm sure thats not always best. I don't see any thing wrong with goto, but I don't see it as an excuse not to use functions, if-elif-else, switch/case, for/while/do-while e.t.c. what ever constructs the language provides.

I think, in my opinion this would be a good clause to use the 'infernal goto'

for condintion
  do
      code
      if true
            goto handle
      else
            skip
 A number of things like this and eventually 

      handle:
            code to handle false
  done

As a method of keeping some exception handling at the end of a loop rather then packing it some where with a nice interface or some thing. I dunno, personally I like doing things in a manor that I know is crystal clear.

For example, column stacking on a door for a bang & clear. It should be clear as can be who is banging, who is openning, and which one enters first, e.t.c.

TDFTN

  • Finish fixing rf.c
  • Work on implementing more realistic CS Gas in S4:TSS
  • Finish that letter
  • Do my home work *snore

Wednesday, March 7, 2007

Post it for the future.

http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html

Big, uh, Fun Gun !

Minigun


Download a Minigun video. Footage from Knob Creek.

Ok... now thats a lot of hot lead.

Rest

My idea of R&R ??

Find me a pair of palm trees. String a hammock between'em and relax in the shade with a nice cold drink.

Mm, maybe some day hehehehe.
Some times I dislike being the only one in this burg I know. With a passion for computers and coding in my age group...

Sheesh man, I was in diapers with a Tandy 1000 and TRS-80 Colour Computer for toys. WebTV introduced me to the World Wide Web. A Computer donated from our Church showed me Windows 98 and got me doing like 8+ hour a day learning stuff via Earthlink Dialup.

Look at me now? I'll be 19 this June. 3 Computers, desktop, desktop turned server, and laptop. Plus Ma's desktop. Stuck living with Windows often. Yet I breath naturally on my FreeBSD / PC-BSD systems. Feels good to long into FreeBSD even if its through PuTTY at times.

No clue wtfrig I started learning programming, I don't even care much for C++ in retrospect. Yet I love C !!! GO figure. When I get to a working vacation in July. I plan on boning up on Pythons standard library. I'm only very familer at that level with C and some of the BSD / POSIX extensions on my system. Most of which, I rather like...

Learning to do stuff at CLI levels, learning, understanding, and mastering complexity == heaven. Flib it, man I don't even _use_ an _IDE_ as most call it. I started with Dev-C++ now? My little bag of tricks. Vi, Vim, Ex, I can use Emacsen but prefer Visen ;-). GCC, the only compiler I've ever used but I like it so far. Although I wish it'd be better at reminding me that I transposed a , /or . although thats a font and many lines later issue. I've found using GCC from the command line much more flexible. GDB for debugging, skip the GUI ! Lint for simplistic code checking, ctags for larger stuff. A bloody fine manual for system calls, the standard library, and ncurses. A very good Bourne Shell implementation for scripting and many choices. BSD & GNU make, and a number of other things I've yet to learn like groff and automake.

Most people my age? Ask'em what C Programming is and they'd probably say forging report cards ! Most probably wouldn't even know what the HTML in index.html stands for.. A lot of my friends are not even the most computer literate.

I've been told in my youth that my mind was like some one older then my years... But I've always valued my uniqueness. How many lusers do you know. Who'd manufacture their own fscking mother board & write device drivers as necessary for if they only knew how !!!!!!!!!!!!! Ok , so I'm a crazy lune... can't help that. But, GOD, I Love to learn about stuff that gets my interest. He's blessed me so much with being able to learn as much as I have. Odds are, if it wasn't for that one computer Robert gave me. When he heard ma wouldn't let me repartion & dual boot ma's computer. I probably never would have gotten into *nix systems as much as I have. If my sister didn't get me my laptop. I'd probably never been able to learn this much for programming. Its been a great blessing, one that I'm very thankful for. To me, its a joy to learn some thing new and interesting every day. I'd be happy some day, to know as much about computers as Mel Kaye did lol.

Yet still... who do I have to share this passion with? Mm, no one.......

Thats what pains me lately.

Spider Stance

You know, its probably the first time in my life. At least that I've noticed it. That I've ever sat, in that 'distinctive' pose of the amazing Spider man.



straighter then that, back erect and arms straight. I was perched on a couch-ledge, so had to fit feet and hands in the same spot. After a minute, I realized who made it famous ^_^

You know some thing, it felt darn good for my back !! I wonder if a generation of Comic Book artists ever thought about that =/


Pictures not exactly what I wanted but its as close to it as I can find without putting one of my comics in the scanner.

Monday, March 5, 2007

How Evil are you?

You Are 14% Evil

You are good. So good, that you make evil people squirm.
Just remember, you may need to turn to the dark side to get what you want!


Wow....
Well I've solved one problem, now to tackle another problem.

Solved:

KMail would crash when ever moving or deleting a message in my SMB mounted mailboxes.

Solution? I backed every thing up by moving them to /tmp. Replaced my .kde/share/config/kmail* and .kde/share/apps/kmail files with roots which was never configured. Then I set up kmail and imported my messages from backup.

That fixed it all but now I have a new problem:

How to access mail from any where on my network.

THe Soultion I'd like, kolab- > KDE Group Ware xD

Man, I don't look forward to source installing that monster on a 500Mhz Pentium III !!! Maybe I can run it in a FreeBSD Jail for security as well.

Sunday, March 4, 2007

I look, at how much there is to be done.. and see how much I still have to go in my learning. Before I could be worth a damn to help.

Mmm.. supper time

Saturday, March 3, 2007

the poseidon adventure

Well, tonight we taped the movie Poseidon. A remake of the Poseidon adventure.

I remember when I was a kid, maybe 5-6 years old. I had officially sworn off the original movie for keeps. I had gotten a tad ill in the stomach watching it. The whole sinking / drowning thing kind of got to me. And really I've never cared much for disaster flicks.

I'm happy to say, like 12-15 years later I'm perfectly fine and the remake was actually pretty good :-)

At least it wasn't as boring as the Titanic remake was...

Friday, March 2, 2007

S4 HiJinks

I don't know if its a curse for living in the RvS Dept to long instead of my beloved SWAT or what.

But some times I have the distinctive feeling that I speak, and oh most no one listens to a word of it!

Both on and off line...... Well there was once upon an off line time.

Sunday, February 25, 2007

NTS

Have a T-Shirt made that shouts:

I don't care about spelling unless it involves Vi !

Saturday, February 24, 2007

Days progress

Null (0)
Eines (1)
Zwei (2)
Drei (3)
Vier (4) - tis one hard to remember lol
Fuenf (5) - properly fünf
Sechs (6)
Sieben (7)
Acht (8)
Neun (9)
Zehn (10)
Elf (11)
Zwoelf (12) - properly zwölf
Dreizehn (13)
Vierzehn (14)
Fuenfzehn (15) - properly fünfzehn
Sechszehn (16)
Siebzehn (17)
Achtzehn (18)
Neunzehn (19)
Zwozig (20) - I wonder if Zweizig would be interrupted as 20. Seems that 'zwo' seems to be used in place of Zwei at times to avoid confusing people.. Probably foreigners lol.
einetausend (1000)

For the most part German numbers seem pretty logical and seem to follow the same convention style as English numbers. I.e. 15 in English is Fift-Teen, rymes with 5th (fifth, Viertel) a fraction and teen being a fairly standard suffix for any thing between ( > 10 && < 20 ). So Siebzehn makes sense for Seventeen. Its more or less 'Seven Ten' which is basically what a 17 is. Or maybe it could just be my backwards mind that finds this all so logical ! hehe I dunno.

Larger numbers seen to follow a similar style but with a und (and) in the middle and changing suffixes as you got, teens, twenties, thirties and so on. But each comparable German suffix seems to end in 'zig' except for Dreissig (dreißig, thirty). Much like how in English many of then have a 'ty' suffix often preceded by an r or ir. Fourty "four'ity" (Vierundvierzig), Seventy (Siebundsiebzig), or Fifty (Fuenfundfuenfzig). Quiet logical imho.

Sechhundertzweiundzwanzig (626) looks about right to me aside from being a mouth full but who says I know any thing. Six hundred Two and Twenty - logical.

It seems while we use a decimal point . In German a comma , seems to be used and pronouced. I wonder how 600,400.01 would be spoken if 3.04 would be like 'Drei Komma null vier'. I think thats some what grammatically correct. 'Komma' always seems to be capitalized, the first word being capitalized the way I wrote it is probably an English'ism. I've yet to learn much for German grammar and punctuation. Instead concentrating on basic spoken communication and reading. I'll worry more about it when I have a rough understanding of how words work out, then I'll worry more about sentences and phases.

So far though the only languages I know my way around well is C and English +S lol sorry to say but I think its in that order :-P

Get this for my BDay

http://www.newegg.com/Product/Product.asp?Item=N82E16820241103

Friday, February 23, 2007

read file

This is a little thing I've been working on this month. Its made to simulate the behavior of 'cat file' and 'head -n' / 'tail -n' more or less scratch a little itch. It works very simple as its supposed to be simple. It parses arguments taking a count to its -t and -b switches. It looks through argv till it finds a file to open. It'll read the entire file out, if it's given the -t switch it will read out up to the count its given. If its given the -b switch, it will read the entire file. Store the location of every newline in a linked-list. Then rewind the list, seek to the specified location (plus padding) and print out the end of the remainder of the file.

Heres a straight copy & paste of it. Portability wise it assumes that the file is in the correct format and requires a number of functions that first appeared in BSD 4.x, namely getopts, fgetln, and err/errx. It also presumes that their should be enough room to store the location of every newline in the file within memory. So if one only has 64K of RAM, it might be a problem to read a few files xD.

I can't say if its well written or not... I don't know of any program with my system that does exactly this other then what this simulates. Rather then wrap around cat/head/tail using system() or including the sources I worked through this as a learning experience. Its more or less written in the style I prefer, the type on a line of its own bit in function declarations is the only 'real' part of it stemming from my occasional reads of stuff in /usr/src alone.

/*
 * rf read file to standard out
 */

// vim: set noexpandtab ts=8 sw=4 ai :
// vi: set ai nu ts=8 sw=4 :

#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>


static void readall( FILE *, int );
static void readtop( FILE *, int );
static int readbottom( FILE *, int );
static void usage( void );

struct lnpos {
 long nl;
 struct lnpos *next;
};

int
main( int argc, char *argv[] ) {
 
 char *erptr;
 int t_flag = 0, b_flag = 0;
 int ch, lncnt;
 FILE *fp;

 extern char *optarg;
 extern int optind;
 extern int optopt;
 extern int opterr;
 extern int optreset;

 while ( (ch = getopt(argc, argv, "b:t:")) != -1 ) {
  switch (ch) {
  case 'b':
   b_flag++;
   lncnt = strtol(optarg, &erptr, 10);
   if ( *erptr || lncnt <= 0 )
    errx( 1, "Improper line count -- %s", optarg );
   break;
  case 't':
   t_flag++;
   lncnt = strtol(optarg, &erptr, 10);
   if ( *erptr || lncnt <= 0 )
    errx( 1, "Improper line count -- %s", optarg );
   break;
  case '?':
  default:
   usage();
   return 1;
  }
  argc -= optind;
  argv += optind;
 }


 /* loop through cli args and find a file to open */
 for ( int i = 0; i <= argc; i++ ) {
  fp = fopen( argv[i], "r" );
  if ( fp == NULL )
   err( 1, "File does not exist or could not be opened "
   "for reading -- %s", optarg );
 }

 if ( (t_flag < 1) && (b_flag < 1) )  {
  readall( fp, lncnt );
 } else if ( t_flag > 0 ) {
  readtop( fp, lncnt );
 } else if ( b_flag > 0 ) {
      readbottom( fp, lncnt );
 } else {
  errx( 1, "flag processing failed" );
 }

 fclose( fp );
 return 0;
}

/*
 * print out an open file to standard output
 */

static void 
readall( FILE *fp, int lncnt ) {

 while ( (lncnt = fgetc( fp )) != EOF ) {
  printf( "%c", lncnt );
 }
}

/* Read n lines from the top of the file.
 * note that it was very inspired by the head(1) implementation of BSD
 */
static void
readtop( FILE *fp, int lncnt ) {

 char *cp;
 size_t error, rlen;
 while ( lncnt && (cp = fgetln( fp, &rlen )) != NULL ) {
  error = fwrite( cp, sizeof(char), rlen, stdout );
  if ( error != rlen )
   err( 1, "stdout" );
  lncnt--;
 }
}


/* Read n lines from the bottom of the file 
 * This function really should be broken up - but I have not learned how yet.
 */
static int
readbottom( FILE *fp, int lncnt ) {

 char *cp;
 int hmany = lncnt;
 long nlnum = 0;
 long where;
 size_t error, rlen;

 struct lnpos *root;
 struct lnpos *cur;

 root = malloc( sizeof(struct lnpos) );
 if ( root == NULL )
  err( 1, "can't init the list" );
 root->next = 0;
 cur = root;

 cur->next = malloc( sizeof(struct lnpos) );
 if ( cur->next == NULL )
  err( 1, "can't add nodes" );
 cur = cur->next;

 /* read the file, count every '\n' and store them in a new member of
  * our linked list.
  */
 while ( (lncnt = fgetc( fp )) != EOF ) {
  if ( lncnt == '\n' ) {
   nlnum++;
   cur->nl = ftell( fp );
   if ( cur->next != NULL ) 
    cur = cur->next;
   cur->next = malloc( sizeof(struct lnpos) );
   if ( cur->next == NULL )
    err( 1, "can't add nodes" );
   cur = cur->next;
  }
 }

  /* rewind our linked-list and seek b_flag + 1 segments short of the
   * end of the list. 
   */
 cur = root->next;
 hmany++;
 while ( hmany < nlnum ) {
  cur = cur->next;
  nlnum--;
  
 }

 where = fseek( fp, cur->nl, SEEK_SET );
 if ( where != 0 )
  err( 1, "could not seek through the file\n" );

 while ( lncnt && (cp = fgetln( fp, &rlen )) != NULL ) {
  error = fwrite( cp, sizeof(char), rlen, stdout );
  if ( error != rlen )
   err( 1, "stdout" );
  lncnt--;
  cur = cur->next;
  if ( cur->next == 0 )
   return 0;
 }
 return 0;
}


static void
usage( void ) {
 fprintf( stderr, "usage:\n rf file\n "
         "rf [-t number lines from the top] file\n "
  "rf [ -b number of lines from the bottom ] [ file ]\n" );
}



Any comments about the file it self or its design is much welcome by this moron who tries to teach him self.

Sunday, February 18, 2007

Nice pair

Pioneer HDJ-1000 headphones /w ear-cup http://www.amazon.com/Pioneer-HDJ-1000-Headphones-ear-cup/dp/B0002DV7Z2

Saturday, February 17, 2007

How to distablize BSD

Be running a system upgrade via remote from a windows machine

when the windows machine crashes while the BSD box is building !


F you Windows.

Friday, February 16, 2007

TD4S

hunt down some flag images

US
UK (british/scottish)
CAN
Norse
Danish
Bel.

??

Wednesday, February 14, 2007

Temptational joke

Three Distros for the Elven-kings under the sky,
Seven for the Dwarf-lords in their halls of stone,
Nine for Mortal Men doomed to die,
One for the Steve Ballmer on his dark throne
In the Land of Redmond where the $hadow$ lie.
One distro to rule them all, One Ring to find them,
One distro to bring them all and in the darkness bind them
In the Land of Redmond where the $hadow$ lie.


There can only be one distro and its MicrosoftSUSE !

Sorrry, I couldn't resist doing that just for the laughs !!!

Tuesday, February 13, 2007

SSMTP/Getmail how-to part III

back to part II

The getmail documentation said that was the best way to automate it, and its bloody better then buling up getmail with 'daemon mode' code. But also like the documentation said if we want to 'stop' this daemon like mail checking we need a script for cron to run getmail through and program it to not run getmail if a file is pressent. Now we can do this many ways, heck we could set a enviroment variable if we want.

I've written a little script that can be run with a users cron jobs and skip over all mail or only the given account. You need one rcfile per account and you can tweak it to follow any conventions you want. My RCFiles follow the convention of getmailrc-shortaccountname, hence getmailrc-bell and getmailrc-sas for my bellsouth and sasclan accounts. This script should work on any system that has a bourneshell compatible /bin/sh. Just edit the shebang if you need to run it as another shell (such as /bin/ksh).

#!/bin/sh

# Use getmail to check my E-Mail account using the RC variable
# This script has the advantage that one can save it as another file, change
# one variable and set a cron job to check each account at different times (1
# cron job per script). Then not only use a file in their .getmail folder to
# stop all the scripts from running getmail or use a file to stop one script
# from checking its account. It also keeps a log which will be trimmed by
# another script

# Name of the getmailrc file to use
RC=getmailrc-sas

# log to a file when mail is checked
LOGFILE=${HOME}/.getmail/cronjobs.log

#
# If a nomail or nocheck file is found in ~/.getmail/ exit without checking
# else look for a no file. Where  is equal to every thing that
# comes after the getmailrc- in $RC. If none of these files exsist check mail
# using the $RC file.
#
if [ -e ${HOME}/.getmail/nomail ]
then
        LOG=$(echo "Skipping mail for $RC")
        exit 1
elif [ -e ${HOME}/.getmail/nocheck ]
then
        LOG=$(echo "Skipping mail for $RC")
        exit 1
else
        DIE=$(ls ${HOME}/.getmail| grep $RC | cut -d '-' -f 2)
        if [ -e ${HOME}/.getmail/no${DIE} ]
        then
                LOG=$(echo "You have desided not to check this mailbox - $DIE")
        else
                LOG=$(echo `date` "checked mailbox with $RC")
                getmail -r$RC
        fi
fi

# Update log with the result
echo $LOG >> $LOGFILE 2> /dev/null

if you want to use the script copy and paste it into a text file and mark it executible. I saved them as ~/.getmail/check-.sh and chmod'd them 0700

Ok, let us make a cron job, because this is allready a big long post that took me forever to write with the way my house is. I'm not detailing cron(8) so please read the handbook or read the fine manual.

I created this crontab file to run my scripts to check my accounts every 5 and 4 hours respecfully and to 'trim' my log file every week.

# rstf's crontab
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
HOME=/usr/home/rstf/
MAILTO=""
#
#minute hour    mday    month   wday    who     command
#
# check sas every 5hr
5     *       *       *       *       rstf    ${HOME}/.getmail/check-sas.sh
#
# check bell every 4hr
4     *       *       *       *       rstf    ${HOME}/.getmail/check-bell.sh
#
# trim log @weekly
0     0       *       *       0       rstf    ${HOME}/sh/trim-getmail-cronlog
#

The trim-getmail-cronlog script is thus

#!/bin/sh

# Rotate my logfile for running get mail via cron

LOGFILE=${HOME}/.getmail/cronjobs.log
TMPDIR=/tmp/

if [ -e $LOGFILE ]
then
        tail $LOGFILE > $TMPDIR/gmlog.$$
        rm $LOGFILE
        mv $TMPDIR/gmlog.$$ $LOGFILE
else
        exit 1
fi

To load my crontab file into crons system i.e. /var/run/tabs/${USER} all I have to do is run a simple command.

crontab ~/rstf-contrab

SSMTP/Getmail how-to part II

Back to Part I

It should've taken like two minutes to install or so. The getmail program is very nice and it follows the concept of do one ting and do it well + allows for a great level of modularity. We can use it with a number of protocols and other softwares like procmail, spamasassion, clamav e.t.c.

Setting up getmail is very easy and theres great documentation so far I've been very happy with it. Lets go to our home directory, we do *not* want to be the root user for this.

I'm gong to use a console because thats how i like it, so I'll short how to do it via that way. If you want to use a GUI app like Konqueror to do it be my guest, you should be able to easy enough.

Make a directory your home directory called .getmail and set the permissions so that only you have access.

mkdir -m 0700 ~/.getmail That ammounts to the owner having read, write, and execute but no one else but the root user being able to enter the directory. Lets cd over to our ~/.getmail folder and create a rc file. By default getmail reads the ${HOME}/.getmail/getmailrc file but we can create multiple rc files and have getmail use the one we choose.

getmail -rRCFILENAME

if its not in our .getmail/ folder we need to supply the path to the rc file, if its in .getmail we can skip it.

The syntax of the file reminds me alot of .ini files on Win32, to be perfectly honest the getmailrc file syntax is the easist I've seen. Heres a copy of one of the RC files I use complete with anotations of what the ooptions do. After this I'll go into more detail about the options to help you get a owrking rc file.

[retriever]
# This file is getmailrc-sas which is for checking my @sasclan.org account
type = SimplePOP3SSLRetriever
server = mail.host.tld
username = my_emailaddr@sasclan.org
password = My_Password

[destination]

# This destination is just for my e-mail not the systems local mboxes.
type = Maildir 
path = ~/Mail/
user = rstf
filemode = 0600

[options]
# Note that '0' means disable for all integar values.

# (int) 0-warn/err only, 1-retriv/delete only, 2-every thing
verbose = 1
# (bool) true = fetch all, false = only what getmail has not seen before
read_all = true
# (bool) true = delete messages after downloading, will override delete_after
delete = true
# (int) delete messages from server after int days
#delete_after = 1
# (int) max server reported message *total* size to download per session
max_bytes_per_session = 0
# (int) do not retreve messsages larger then this number of bytes
max_message_size = 0
# (int) max number of messages to process
max_messages_per_session = 0
# (bool) adds Delivered-To: header field to the message.
delivered_to = true
# (bool) add received: header field to the message
received = true
# (str) log to file
#message_log
# (bool) use system logger
message_log_syslog = false

as a reminder so I wouldn't have to check the documentation in /usr/local/share/doc/getmail/ or online. I put comment notes in the file briefing discribing what each option does and the type of setting, namely bool (i.e. true/false), int(eger) i.e. 0 1 or 435 e.t.c., or str(ing) likethis. Basically you need to have a [retriever] and a [destination] section. Under retriever we tell getmail what type of protocol to use, taken from the documentation heres the options.


  • SimplePOP3Retriever
    — for single-user POP3 mail accounts.

  • BrokenUIDLPOP3Retriever
    — for broken POP3 servers that do not support the
    UIDL
    command, or which do not uniquely identify messages; this provides basic
    support for single-user POP3 mail accounts on such servers.

  • SimpleIMAPRetriever
    — for single-user IMAP mail accounts.

  • SimplePOP3SSLRetriever
    — same as SimplePOP3Retriever, but uses SSL encryption.

  • BrokenUIDLPOP3SSLRetriever
    — same as BrokenUIDLPOP3Retriever, but uses SSL encryption.

  • SimpleIMAPSSLRetriever
    — same as SimpleIMAPRetriever, but uses SSL encryption.

  • MultidropPOP3Retriever
    — for domain mailbox (multidrop) POP3 mail accounts.

  • MultidropPOP3SSLRetriever
    — same as MultidropPOP3Retriever, but uses SSL encryption.

  • MultidropSDPSRetriever
    — for domain mailbox
    SDPS mail accounts,
    as provided by the UK ISP Demon.

  • MultidropIMAPRetriever
    — for domain mailbox (multidrop) IMAP mail accounts.

  • MultidropIMAPSSLRetriever
    — same as MultidropIMAPRetriever, but uses SSL encryption.

Odds are if you don't know what you need, its probably SimplePOP3Retriever. If you've ever set up a mail client before you should know it, your ISP or webhost should be able to tell you as well. Next we gotta tell getmail what server to fetch mail off of with the server option. If your ISP is some thing like charter, its probably mail.charter.net. I don't have charter but all the mail servers I've seen have been mail.ispname.topleveldomain lol.

We need to set the username and password so the server knows its us and which mailbox we want. Other wise it will tell us to go 'eff off.

Now we need to tell getmail what to do with our mail once it checks the incoming mail server. This is what the destination section is for. You basically have two big options here, Maildir or MBox. I've always used mboxrd since thats what Mozilla Mail&Newsgroups, Mozilla Thunderbird, and Seamonkey Mail&Newsgroups used. Plus the systems local mailboxes are mbox format as well. Theres various 'variations' of mbox and probably maildir but compatible enough for our needs I'd say. Other options for 'type' allow us to use an

External Message Delivery Agent (MDA) like procmail.
Mutilple Destinations, using multiple maildir/mbox/externMDAs e.t.c.
Mutiple message sorting
Sort mitple messages into geussed destinations
And to use qmail-local to deliver messages as instructed in the .qmail file.

The exact specifics and how to set getmail to use these features are in the manual, go read it if you want to know more. I suggest ether mbox or maildir personally.

Maildir is pretty simple there is a folder containing new, cur, and tmp directories full of e-mails. If you plan on checking e-mail often or automating it (as I do) this is probably for you. Each e-mail gets its own file in one of those directories which I personally think makes it better suited sharing messages but bad for FAT32 file systems (i.e. many small files).

We can make a mail directory like this on the command line, assuming we want ~/Mail. Or just make four directories in a GUI file manager.

mkdir -p ~/Mail/{new,cur,tmp}

You'll need to set the path to the mail directory as well to use Maildir. You can also set the user and file permissions to use. You've got to use the unix octal format, i.e. 0755 instead of u=rwx g=rx o=rw or some thing.

[destination]
type = Maildir 
path = ~/Mail/
user = rstf
filemode = 0600
Setting filemode to 0600 means only I and the root user have read-write permission to my mail.

Now if we want to use mboxrd we have to specify the type and path to the mbox file as well. The user option works here too. Also you need to consider the locktype option. It takes a string argument and you have a choice of 'lockf' which uses fcntl locking or 'flock' default as of this writing (getmail v4.7.0) is lockf.

[destination]
type = Mboxrd
path = ~/Mail/inbox
user = rstf
locktype = lockf

We can also set up filter sections to use stuff like clamav & spam assasion on our e-mail. Considering that the odds of a virus or trojan that can invect a windows machine through being ssh'd into a freebsd box that is using mutt to view mail fetched with getmail from a server that filters spam (optional /w my ISP) and scans for viruses (nice ISP). I don't blood ythink I need to filiter things through an Anti-Virus ! But if you like go read the documentation on how to set that up.

I think I'll be looking into spam assasion for my ISP account though so maybe I'll have some thing topost there.

The options section I don't think is required but I'd suggest you set your read_all and ether delete or delete_after options.

My suggestions

[options]
# fetch all mail on the server
read_all = true
# then delete it after its in our Maidir or Mboxrd destination(s)
delete = true

[options]
# fetch mail getmail has not seen before
read_all = false
# then delete old messages after 1 day
delete_after = 1

The bottom option deletes the messages you download today from your mail server (not your destination) the next time getmail checks for mail and sees that the old messages are '1' day old. Any integer number will do but not a floating point number. i.e. 4675 will work but 2.43 will not.

I have two getmail rc files one for each account
$ ls -R ~/.getmail                                             20:21
getmailrc-bell
getmailrc-sas
oldmail-mail.host.tld-110-username
oldmail-mail.host.tld-995-username
So I can run getmail and tell it which file to use so Ican deside which mailbox to check. I've made a pair of shell aliases in my shells rc file to save typing.

alias gm-bell='getmail -rgetmailrc-bell'
alias gm-sas='getmail -rgetmailrc-sas'

Ok, lets run getmail (I'll skip the alias), it will take a few seconds bu t if it takes a really long time you might want to make sure your system is configured correctly to resolve the hostnames.

rstf@Vectra$ getmail -rgetmailrc-sas                                                       20:22
getmail version 4.7.0
Copyright (C) 1998-2006 Charles Cazabon.  Licensed under the GNU GPL version 2.
SimplePOP3SSLRetriever:My_EmailAddr@sasclan.org@OurMailServer:
  0 messages retrieved, 0 skipped

Looks like I have no new mail in the account.

Ok, lets try some automation we can set cron jobs to run getmail -rRCFILE when ever we want on one or all of our files.

SSMTP/Getmail how-to part I

This is a short how to for kicking sendmail in the buttocks and setting up a micro-replacement for send-only usage on a FreeBSD (post 5.x) system. Plus using the getmail utility to check for new messages. I spent long enough screwing with it after I miss-read some documentation (fbsd handbook/ssmtp).

The goal is to be able to use utilties such as mailx, mutt, and other MUA's dependant on sendmail (or exteneral) MTA(s) and be able to check mail easy and automaticly. I assume you at least know how to setup a mail client such as Mozilla Thunderbird or Outlook Express (or can get the relivent info) and know how to edit files as root when needed.


First we have to kill sendmail. For this we need to edit the /etc/rc.conf file, since I've cleaned mine up to place various options in related 'sections' heres the relivent one from my rf.cofing. Note all the sendmail_* options at the bottom.

#########################################################################
#                               SERVICES                                #
#########################################################################


#cupsd_enable="YES"
#background_cupsd="YES"

samba_enable="YES"

ntpdate_enable="NO"
ntpd_enable="YES"
ntpd_falgs="-c /etc/ntp.conf -f /var/db/ntpd.drift"

# Completly kill sendmail
sendmail_enable="NONE"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

Save rf.config with those sendmail lines in it and we can stop sendmail from working. Sendmails probably the worlds most used Mail Transfer Agent but for a desktop we don't really need it. While its well known for its history of security problems according to some OpenBSD people, at least they still patch it. Now with sendmail gone we have two problems.

  1. Daily run messages are usually mailed to root and this might break that a tad.
  2. MUA's dependant on external MTA or utils dependant on sendmail may require configuration changes or stop working

Now to fix this we want some thing small that will allow us to send e-mail through some thing sendmail compatible'ish. I'll assume that you have ports installed or know how - so go do it and update them. Personally I try to update my ports tree every few days or just before building a port if I rarly install stuff on the machine. I also prefer cvsup/csup :-)

Ok, now that you have ports ready to go lets install some software. Open a shell (or use a GUI) to cd into /usr/ports/mail/sstmp/ so we can build it. Run the commands

make install replace clean

it shouldn't take long to install so no need to go on coffee break :-P
In case your wondering what ssmtp is heres the pkg-descr:
A secure, effective and simple way of getting mail off a system to your
mail hub. It contains no suid-binaries or other dangerous things - no mail
spool to poke around in, and no daemons running in the background. Mail is
simply forwarded to the configured mailhost. Extremely easy configuration.

WARNING: the above is all it does; it does not receive mail, expand aliases
or manage a queue. That belongs on a mail hub with a system administrator.

WWW: http://packages.debian.org/testing/mail/ssmtp.html

Basically it doesn't handle fetching or checking mail or reading it but it lets you send it. While some thing like sendmail, qmail, or postfix should at least provide send/recieve if you want to go bugger setting up a full blown mail server be my guest :-)

sSMTP is really s send-only app that tries to emulate sendmail, most of the command line options to sendmail are accepted but many are just ignored. Some MUA's can check mail for us, mutt springs to mind but I rather like using getmail so far. At first I thought I would use sendmail/fetchmail/ but I saw an app called 'getmail' in ports and checked it out. Its not as buggy as fetchmail is *said* to be, its got great documentation, and its really simple. So if your going to use getmail once ssmtp is done building start on /usr/ports/mail/getmail/ while we open another terminal to configure ssmtp while getmail compiles.

Using a shell or file manager like konqueror cd over to /usr/local/etc/ssmtp/ . We can ether use the .sample files here or create new ones from scratch. We to create a ssmtp.conf file that tells ssmtp how to send e-mail to our out going mail server. The config file syntax is a cake walk, its key=value and # for comments to end of line like many a language or file has.

# Your E-Mail _address_
root=email_username@isp.net
# Your outgoing mail server, normally the TLD is .net, .com, or .org
mailhub=mail.isp.topleveldomain
# Where mail looks like it came from, just stick in your e-mail address.
rewriteDomain=email_username@isp.net
# Your hostname, your e-mail address should be fine if your not a mail server
hostname=email_username@isp.net
# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
FromLineOverride=YES

save as /usr/local/etc/ssmtp/ssmtp.config and that takes care of that. You might want to nuke sendmail or reboot of course for this to take effect. Now since we do want our daily run stuff to still work we will set up an alias so mail sent to our user account locally will actually be sent to our e-mail address. We'll do this with the revaliases file in the same directory.

This ones a little bit og a bug but its not once you figure out how. Basically the syntax is like this

your_login_name_on_this_computer:your_email_address_to_send_to:the_out_going_mailhub_to_use

# Alias e-mail to the system root account to go to my private e-mail
root:myemailaddr@myisp.tld:mail.myisp.tld
# Alias my_username to my email address so I get my cron-job reports
my_username:myemailaddr@myisp.tld:mail.myisp.tld

This way the daily run and cron e-mail messages will still work and they will be in my e-mail rather then /var/mail/${USER} where I often forget to check 8=)

I've yet to figure out how to set up ssmtp for multiple outgoing mail servers but I'll figure it out later & post it.

Ok, now lets get back to getmail

Monday, February 12, 2007

To do this week

My monster list in short form.
  • My normal work week
  • I have *GOT* to get a test out for school
  • Get my printer functioning over th enetwork (Vectra)
  • Get my E-Mail working again, probably move things over to Vectra and ssh in to use a CLI mail client. Best start telling peoople to stop sending me HTML E-Mail 8=)
  • Consolidate my data backups
  • Check for a WinSucks equiv to mount_smbfs or a more reliable method then Windows XP's own handling of SMB
  • Set up a FTP server on my local LAN
  • Get a LDAP based Address Book solution going if at all possible
  • Clean up my system configurations, ssh, sendmail, cups, samba e.t.c.
  • Keep up with business as SSM, RvS Dept. 22nd [SAS] EVR
  • Deal with being an associate web master
  • Finish my coding project in C
  • Put together that thing for Shield
  • Boost my studies in PHP and JavaScript

Sunday, February 11, 2007

broken bones

Well, since my USB flashdrive died for all intents and purpsoes today. Lucky I did get a full backup while I could still get it to mount on occasion.

I cracked the sucker open, yanked out the PCB (printed circuit board) from the looks of it. Nice little thing /w a few DIMM'ish things on it. Ones probably the 1gb of disk space and the other a *real* microprocessor. Maybe even a picoprocessor if you think about how big some desktop PC's CPUs are with a heat sink on top of them.

The USB connector was just clipped on, with a few metal prongs coming out of it and into the board. Looked like they might slide out so I pulled it off, sure enough the things didn't slide out and they broke off from the looks of it. Although I think I'd need a magnifer to be sure of 3 of them. One is clearly destroyed.

The funny thing, is when I stuck it all back together and put the tape back 'round the case. It sat just right, before it died. Well it got a bit bent at the port one day & started to split the case. Hence the tape...

I think assuming that I broke all 4 connectors instead of just 3. I might've been able to save the bloody thing. Oh well I got the data backup and thats what counts. Not to mention I got to have a look see just what is inside a USB Flash Drive :-)


Now if only Windows could be trusted to access my SMB shares 24/7 and I could get a nice little 20GB PATA drive for Vectra I could complete the more Network Centric restructings I wanted to work on. Only I didn't think I'd need to !.

Gonna have to start using ftpd to or find a winsucks == of mount_smbfs.

N2S

Talk with Wiz about modules during my 'coding hour'
Well I found the anwser to my problem by kicking around rather then kicking my self.

(t_flag < 1) && (b_flag < 1)

*not*

((t_flag) && (b_flag) < 1)

*smacks self* sleepy idiot !
Well, I hit the point for destruction or construction....

ether go insane and smash stuff or do some thing useful. So I ripped apart my room probing for a rough idea of how to sor things and rearranged every thing.

GOD, I've been wanting to get that shelf out of here for years. Got things rearranged and even a little work station for me set up. After all I did start off trying to figure out how to get my self a little microcomputer lab going.

I also got to throw out a crap load of stuff, yeah I'm a pack rat...

Saturday, February 10, 2007

I t hink I'msnapping..

I've tried switching to my laptop, practiclly locking my self in a room on the other side of the house.

Putting my laptops volume to the max with near max HW volume + 50+ % on Amarok & blasting music

Turning the TV volume as high as it goes and the Cable Box up so you not only can here me accross the house but probably in the next apartment and the apartment building !

AND I STILL CAN'T BE LEFT ALONE TO DO MY WORK !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


For petes frigging sake I should make these people read K&R Cover to cover and write a bloody operating system kernel and see how they like torture !

Dying a mad mans death bit by bit.

Morning:

Can't do shit, have to walk dogs, clean up, do stuff, deal with ma's computer functional illiteracy.

Afternoon:

Lunch, forums, first login, web-chores. Can't do shit - dog and bird driving me batty.

Evening:

Dinner followed by can't do shit

Wee Hours of the morning:

Freedom, can work till I collapse.

If working - probably can't do shit, have to get up early.


TRYING TO DO ANY THING IN THIS HOUSE IS LIKE TRYING TO STUFF MY PH|-||_|{|<1|\|6 HEAD IN THE STREET IN THE PATH OF A FRIGGING 18-WHEELER AND LIVING AFTER BEING RAN OVER !!!



I'm going f***ing crazy here.

Peopole get paid to work for then 60 fucking hours a week on this shit and they won't even alot me a few hours a day to work in piece. Even if I switch to my room, use the laptop. Kick the TV up so you can here it outside put headphones on and blast heavy metal till my ears hurt. THEY WONT FUC@ING LET ME SIT THE FSCK DOWN AND THINK ABOUT WHAT THE F&CK I'M DOING !!!!!


Its intolerable ! and moving out is not even a frigging hope let along an option.

Friday, February 9, 2007

Force Building

An old hobby of mine, designing military hardware and organizing units. Maybe
its one of the reasons I got into the CBT (Classic BattleTech) side of things in
my MechWarrior career and love RTS (Real Time Strategy) games.

Any ways what I've been pondering over to night.

A simple 'Element' being the lowest level of the fighting force. Consisting of
ether 8 Infantry, 4 Land Vehicles, 2 Air/Sea/Space Craft under 500 Tons, or one
ship over 500 tons.

Two classes of infantry, soft armored and battle armored. Soft armored would be
more or less what we have to day. Using soft-body armor or hardened ceramic
armors (think Marines from ALIENS) and standard weapons. While battle armored
infantry would be fitted with a suit of armor. Figure avg trooper becomes
about 2 meters tall with a 3 meter jump height using the heating/cooling
management systems to assist the trooper. Armed with 6.2mm Rifles and 10mm
Pistols. And enough hard armor to shrug off a few standard rounds.

I remember reading that a round has to be > 22Cal but < 30Cal to really be
effective so I think a 6.2x48mm rifle round would be an interesting experiment.
As a trade off between 9mm and .45Cal pistols 10mm is also interesting in
concept. Instead of normal ammo the rifles would fire a special round. A 6.2mm
armor piecing round thats designed to explode when hitting hard objects. Like
walls or cars. Yet made to fragment instead of go kaboom when hitting soft
targets like people. If you figure the blast could have enough force to take
most of an arm off. Its much more humane to just kill the sap not blow them up.
And to have the balence that the micro HE stock is good reason for the enemy
to rethink how they armor their own troops while improving joe rifle mans
ability to hurt armored fighting vehicles :-)

I think being centered around the idea of a Combined Arms Operations Company is
the best plan.

4 x Mechs, 1 Support unit, 1 Command unit, 2 Assaulter's.
3 x Main Battle Tank
1 x Command/Control/Communications/Intelligence vehicle which can tow a pair of
field guns for use as part of an artillery unit.
1 x Self-propelled missile artillery or Infantry Fighting Vehicle (IFV).
8 x Infantry in battle armor or gun crews.
2 x Close Air Support units.

My ideal configuration would be. 8 Battle suited infantry supported by a
tracked or hover-craft driven IFV /w 4-tube Anti-Tank missile launcher & 45mm
Autocannon. Toss on a pair of 12.7mm Anti-Near-Anything fifty cals on the top
for balance.

3 Main Battle Tanks maybe 45-75 Tons each. 135-142mm rifled cannon with 40-60
shells. 3 12.7mm MG, two top mounted + one coax with about 1600 Rounds. A pair
of triple tube smoke discharges on the front of the turret plus a pair of
single shot recoilless anti-tank rocket tubes on the sides of it.

Yes I'm kind of a nut about packing in as many weapons as possible followed by
as much armor as she'll hold without losing the desired level of agility/speed.
:-) Hehehe

Two CAS units consisting of STOL (Short Take Off & Landing) capable strike
fighters powered with dual-engines. A pair of 25mm Vulcan cannons, pair of wing
tip mounted Air-To-Air medium range missiles al cine to real world AMRAAMs.
4 Internal bays for deploying two 3-tube micro-missile stations and two
stations holding two smart bombs or 3 air-to-ground missiles. (HRTSG-ATG) 2
Under wing stations (per wing) for 2x bombs or 3 x air-to-air /or air-to-ground
missiles + 1 more under wing stations (per wing) for an Air-To-Air missile. All
of these under wing stuff being at the cost of stealth that is. More or less a
pair of harrier jump jets on steroids !

Or even a pair of helicopters packing a 17mm chin gun slaved to the gunners
head. Dual 12.7mm electronically fired forward mounted machine guns for the
pilots use. Wing tip mounted 5-Tube rocket pods and two stations for 4x
Missiles on each stub wing. Where thers a mixture of TV guided wire controlled
fine stabilized anti-armor missiles and Hybrid Radar / Thermal Semi-self
Guiding Air-To-Ground (HRTSG-ATG) missiles. Now thats a painful combo hehe.

A 'Mech element with a support unit with long range missiles, heavy cannon, or
long range weapons like a super long range sniper rifle/laser. Two general
battle configured 'Mechs of the line, CQB Configurations, or Spec Ops Raiders.
Plus a Commanders 'Mech.

Wheeled or Hovercraft based truck with AA ability to provide a mobile
command/control post with lots of communications and intelligence gathering
tools. Plus it could tow a few cannon for arty units.

8 Infantry in battle armor or a gun crew.

A Multiple Launch Rocket System (MLRS) like self-propelled missile artillery
unit for close'ish arty support on the go.

Total of about 4 mech, 3 tank, 1 MLRS, 1 command post, 8 infantry, 2 vtol/stol
units for air support.

A Lance Captain in charge backed by a lieutenant and a Gunnery Sergeant to run
the show. About 30 combat personal. Able to bring a lot of fire power to bear
on the enemy. Plus having enough combined arms to deal with most threats.


Now organize these CAOC into battalions of six + one company is full of
support personal and equipment. We have a big enough force to consider when one
counts armor and air power as the prime assets and infantry more so for close
in MOUT and Commando work.

24 'Mechs
18 Main Battle Tank
at least 6 pieces of missile artillery.
12 Attack Choppers / Fighter-Bombers
48 Infantry with battle armor
6 Command Trunks to provide logistics and communications.

Per battalion. Now if we organized the force into regional commands based on
Regiments of 2-4 Battalions where preferably we have a battalion capable of
operating on its own and a regiment capable of transporting itself any where in
or around the planet.

Organize logistics, support, and command systems around a Divisional level with
the Regimental Combat Teams making up the back bone of the military force. And
I think we might have a fun CBT style game to play, or a funky study in future
military tech.

Plus a naval unit to supply sea and space based operations. Plus air power like
what the USAF would be tasked with. You could say its my
battletech/gundam/macross loving background but I consider 'Mechs and air power
the prime focus of a modular combined arms task force.

Hmm, if I had the time I think I'd write a TBS (Turn Based Strategy) game on
this...

UNIX Rules & DOS Drools !

In my cousre of trying to brush up on DOS CLI work I've come to a cacussion. Its a quick and dirty product that must have been written very fast or half hazardly. Because UNIX makes it look like a moronic idiot with 10bytes of RAM ! I just... can't stand DOS give me a decent Unix any day... A real operating system.

Thursday, February 8, 2007

Ahhh Rubin sandwhiches, a cheese bear claw and a litre of Mug root beer + a zonk'd out nap. Now thats how to take it easy after 3 sortes. Took the bosses dogs to the vet, came home got our dogs. Whent to work then dropped our dogs off at home. Then picked up the bosses dogs at the vet and took them to work. 0.o

Tuesday, February 6, 2007

Sigh, what do you do when life hands you a $\>1+ burger and tells you to chow down ? To bad we can't just send it back to the cook... I've got work extra early so I have to get to sleep ASAP, yeah like thats gonna happen. I know my self better then that. We've got to take 3 of the bosses dogs to get their teeth done. Then start a new job, then pick up the dogs. And Thursday not only do I have to do our biggest work day. But we also got to take the bosses other 3 dogs to the vet. Joy, me and Barny getting sat on and licked to death my Macy while Leo fiddles about... Barny is nearly 20 years old, blind and nearly deaf. Macy is bigger then me had if shes an ounce lighter then 70lbs I'd be shocked. Dogs the kind you give a WIDE birth and avoid getting sat on. But sweet as can be. Leo's just a big loveable mutt of about 55-65lbs. And I'm gonna get sat on I know it, I just know it lol. I get up, I work, I try to get to sit on my ass for af ew. Try & get a few games in, do my work /w the [SAS] e.t.c. and its heck at times. While my moms 'active' on or off her couch. I can't do a lot. Because I'm the errend boy and what ever I'm doing no matter what. Is and can never be more important then any thing she wants. Yeah, thats it. I see the FreeBSD kernel as a work of art to read, a thing of beauty. To my mom? Bah she'd probably call it worthless trash. When its just as much art as the works of Michelangelo (di Lodovico Buonarroti Simoni) Michelangelo had a talent with his hands and heart taken to sculpture. Just the same, in code form and engineering design from where I stand. So is the FreeBSD kernels sources. Damn its like reading the work of a master. Sigh, no coding to night. Since I have to go to bed.. not like I'm likely to sleep worth a fart in the wind. How can one sleep when ones mind is free in torment ? I dunno. Heck if I was a drinking man. I think I'd be stone cold by now, sad thing I'm not maybe.. *SIGH* Why, why... can't things just work. I work like a dog, and what do I have to show for it? I've seen a do be treated better. Now thats kind of sad isn't it? lol. ph|_|{|<. In a way, I miss times since past. Yet at the same times hate them with ernest. No longer a pet spider, not enslaved yet still forced to toil.. well I now I'm not making much sense but. To make a long story short. Don't ask, just leave 'pet spider' alone, its an emotion thats not going any where fast. I remember, being able to spend hard times in the company of som eone ho cared.. it was a good thing. Who knows maybe I'll again share such a thing with some one special. I know the relationship we had was, I admit in the end not the way it had began. Lol, the tease put out of conmission by the one who wouldn't flex. Uhh never mind that too. Life was kinda good for awhile, but it did teach a very good lesson. When they stop complaining after you havn't shaved a week and things heat up even more. Be alarmed, be very very alarmed. ph|_|{|< only one to get me to exersie. What the frig was I thinking man.. like I don't get enough of that at work ha ! I dunno any more. Was life really any better that way then it is like this ? Some times I wonder..but I think it is, or at least no worse. Oh well, at least shes not around to tempt me... man I wish I could dive into some code for the night.. but no I've got to get to bed.

Sunday, February 4, 2007

ASAP to do

Sort the files form the SAS James mappack Check my backup CD's for a copy of the (CS) de_dust RvS Map. Send to Wiz.

Saturday, February 3, 2007

late night

Well I spent an interessting night, still havn't solved the issue of whats wrong but I did accomlish a few things. Better code checking with gcc How to use lint How to use the GNU Debugger Personally I think that graphical front ends can have some very great advantages. But one should be able to use the basic tools by hand when/if necessary. As being able to live in a shell (no gui enviroment) is a part of my studies. So Being able to use a debugger on the CLI is important to me. Oh well each in turn. Most IDE's provide some sort of user interface to wrap around the make and debuging tools. The basic idea that most compilers (so I've heard) follow including the GNU Compiler Collection gcc/g++ (gnu c/c++ compiler) use. Are as follows. gcc source.file -o outfile Now we don't need the -o outfile if we like for example to compile our source.file into an execuitable named a.out in this case ! With the -o option we can choose a name for the execuitable. So 'gcc rf.c -o rf' would create an executible named 'rf' instead of 'a.out' from our rf.c source file. Is this any harder then Build->Compile in an IDE /w a mouse? Not really in my humble opinoin. Especially if you can sider that CLI access is embedded in many editors and many editors work in the CLI. Lets turn on some simple warnings gcc source.file -Wall -o outfile Now while one might argue any code that compiles and works is good enough. But what if it doesn't work as exspected or it's not very good? The -Wall option will at least give us a stronger warnings and errors about bad practices. Since -Wall turns on a bunch of warnings I'll walk through some of them at the end. I personally have used -Wall since I found out there was an all switch (Thank you FreeBSD KNF Style manual!). And when it trips a warning message it usually reminds me I'm doing some thing wrong or I need to go correct a magic typomatical error. I noticed a few other niffty things in the OpenBSD KNF style guide. gcc -Wall -W -Wpointer-arith -Wbad-function-cast source.file -o outfile Gives us plenty of useless-to-semi-useful-to-useful information at times. Theres even more options. Since this is a lot more to type and I'm to lazy to whip up a little Makefile for all my stuff. I made a shell alias for it. I think its worth while to explore the available warning options and sort them as one needs. Note to self, work on some Makefile templets. Another intereing tool I always wanted to toy with, is lint. lint is a code checker for trying to detect features in C sources that are likely to be bugs, non-portable, or wasteful, e.t.c. The lint program h as a good enouhg manual which documents its command line switches but the basic useage is. lint source.c So far I like the -cehuz options most often and have an alias for it. And the -s and -p options from time to time have use hehehe. One thing I found odd about lint, is that it complaned about my // comments. rf.c(5): warning: ANSI C does not support // comments [312] Normally I use only /**/ comments and occasionally a few // in C++. Or I'll mix /**/ and // comments if I'm leaving my self comments of diffrent types in a non-source file. Like /* Change done to something */ What I changed // Note for later for a meeting about it When I'm writing up files for things as I do'em. In this partuclar file how ever, since rf.c has been floating between systems a bit and editors I placed a pair of mode lines in it to set some options for my editors.
/*
 * rf read file to standard out
 */

// vim: set noexpandtab ts=8 sw=4 ai :
// vi: set ai nu sw=4 :
Basically turn on line numbering in Vi and make sure my indentation settings are consistant, then turn on auto-indent in case I want it. (I don't often use it). I remember, why I started using strictly /* Comments */ when I had always used // comments before. Was because I was told that some (older) compilers had problems with the newer // Comments. To use the GNU Debugger gdb to debug a program, first we need to enable the debugging symbols in GCC. We can do this by appending a -ggdb option some where in our compilation. gcc -Wall source.c -o outfile -ggdb Then we can run gdb outfile to start the debugger. At first when I tried looking at the debugger ages ago I didn't have much luck with it. But after reading the manual like I usually do _before_ toying with CLI software it makes much more sense. You can get a topic list by typing help and more specific help like help breakpoints With GDB we can step through the program line by line, set break points at lines and/or functions. Examine data since as what value does variable foo have ? Run backtraces, look at the stack, set the command line arguments and all kinds of stuff. Really GDB deserves its own attention to the subject. Its long been my practice to save and pump code through GCC every few minutes or routines just to see if I missed any syntax errors I may have made. You don't want to know how many times I've been preplexed just because I used a comma instead of a period or a period instead of a comma. And after hours infront of an editor couldn't see the difference in my font lol - yes I am looking for a better fixed-width font ^_^ Now with lint and the various options of GCC I can do more for less :-) Since trying todo ANY THING during day light is pointless in this family. And trust me, when your the kind that inhales good manuals. And it takes you 30 minutes just to get through the first paragraph of a manual on PHP Syntax you know you have a fucking problem. So si nce I can't code during the day. I have to do it late at night and I can't do shit for long. So like 0735 in the morning these tools do kind of help me correct errors. From man 1 gcc Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there may have been an error. The -Wall option I listed turns on all this according to the manual Warn whenever a declaration does not specify a type. Warn whenever a function is used before being declared. Warn if the main function is declared or defined with a suspicious type. Warn whenever a function is defined with a return-type that defaults to int. Also warn about any return statement with no return-value in a function whose return-type is not void. Warn whenever a local variable is unused aside from its declaration, whenever a function is declared static but never defined, and whenever a statement computes a result that is explicitly not used. Warn whenever a switch statement has an index of enumeral type and lacks a case for one or more of the named codes of that enumeration. (The presence of a default label prevents this warning.) case labels outside the enumeration range also provoke warnings when this option is used. Warn whenever a comment-start sequence `/*' appears in a comment. Warn if any trigraphs are encountered (assuming they are enabled). Check calls to printf and scanf, etc., to make sure that the arguments supplied have types appropriate to the format string specified. Warn if an array subscript has type char. This is a common cause of error, as programmers often forget that this type is signed on some machines. Some optimization related stuff. Warn if parentheses are omitted in certain contexts. When using templates in a C++ program, warn if debugging is not yet fully available (C++ only). From man 1 gcc: The remaining `-W...' options are not implied by `-Wall' because they warn about constructions that we consider reasonable to use, on occa sion, in clean programs. And here they are stright from the fine manual.
-Wtraditional
              Warn  about certain constructs that behave differently in tradi-
              tional and ANSI C.

          o   Macro arguments occurring within string constants in  the  macro
              body.  These would substitute the argument in traditional C, but
              are part of the constant in ANSI C.

          o   A function declared external in one block and  then  used  after
              the end of the block.

          o   A switch statement has an operand of type long.


       -Wshadow
              Warn whenever a local variable shadows another local variable.

       -Wid-clash-len
              Warn  whenever  two  distinct identifiers match in the first len
              characters.  This may help you prepare a program that will  com-
              pile with certain obsolete, brain-damaged compilers.

       -Wpointer-arith
              Warn  about  anything  that  depends on the "size of" a function
              type or of void.  GNU C assigns these types a  size  of  1,  for
              convenience in calculations with void * pointers and pointers to
              functions.

       -Wcast-qual
              Warn whenever a pointer is cast so as to remove a type qualifier
              from  the  target  type.  For example, warn if a const char * is
              cast to an ordinary char *.

       -Wcast-align
              Warn whenever a pointer is cast such that the required alignment
              of  the  target  is increased.  For example, warn if a char * is
              cast to an int * on machines where integers can only be accessed
              at two- or four-byte boundaries.

       -Wwrite-strings
              Give  string constants the type const char[length] so that copy-
              ing the address of one into a non-const char * pointer will  get
              a  warning.   These  warnings will help you find at compile time
              code that can try to write into a string constant, but  only  if
              you have been very careful about using const in declarations and
              prototypes.  Otherwise, it will just be a nuisance; this is  why
              we did not make `-Wall' request these warnings.

       -Wconversion
              Warn  if  a prototype causes a type conversion that is different
              from what would happen to the same argument in the absence of  a
              prototype.  This includes conversions of fixed point to floating
              and vice versa, and conversions changing the width or signedness
              of  a  fixed  point argument except when the same as the default
              promotion.

       -Waggregate-return
              Warn if any functions that return structures or unions  are  de-
              fined  or  called.  (In languages where you can return an array,
              this also elicits a warning.)

       -Wstrict-prototypes
              Warn if a function is declared or defined without specifying the
              argument  types.  (An old-style function definition is permitted
              without a warning if preceded by a declaration  which  specifies
              the argument types.)

       -Wmissing-prototypes
              Warn  if  a global function is defined without a previous proto-
              type declaration.  This warning is issued even if the definition
              itself  provides a prototype.  The aim is to detect global func-
              tions that fail to be declared in header files.

       -Wmissing-declarations
              Warn if a global function is defined without a previous declara-
              tion.  Do so even if the definition itself provides a prototype.
              Use this option to detect global functions that are not declared
              in header files.

       -Wredundant-decls
              Warn  if  anything is declared more than once in the same scope,
              even in cases where multiple declaration is  valid  and  changes
              nothing.

       -Wnested-externs
              Warn  if an extern declaration is encountered within a function.

       -Wenum-clash
              Warn about conversion between different enumeration  types  (C++
              only).

       -Wlong-long
              Warn  if  long  long type is used.  This is default.  To inhibit
              the  warning  messages,  use   flag   `-Wno-long-long'.    Flags
              `-W-long-long'  and `-Wno-long-long' are taken into account only
              when flag `-pedantic' is used.

       -Woverloaded-virtual
              (C++ only.)  In a derived  class,  the  definitions  of  virtual
              functions  must  match  the type signature of a virtual function
              declared in the base class.  Use this option to request warnings
              when  a  derived  class declares a function that may be an erro-
              neous attempt to define a virtual function: that is, warn when a
              function  with  the  same name as a virtual function in the base
              class, but with a type signature that doesn't match any  virtual
              functions from the base class.

       -Winline
              Warn  if  a  function  can not be inlined, and either it was de-
              clared as inline, or else the -finline-functions option was giv-
              en.

       -Werror
              Treat warnings as errors; abort compilation after any warning.

Friday, February 2, 2007

Ever think about some thing and not be able to get it out of ya head? Then when you try to you can't remeber the details ? Hah I'm crazy. Oh well back to BBC Radio 1 and some ANSI C.