Segfault Logo

çódê

Libaries

Utilities

University Stuff

Theme Selection

Code

This page has links to various pieces of code that I have written (and have found useful enough to distribute). They're written either in C or in Java, there's one in C++, but it just uses C++-style comments :P - this was back when I did not understand what OOP was all about. Most, if not all, C code is written in ANSI C (C89). On rare occasions, assignments have required me to use Solaris specific functionality (for example, for profiling and the use of high-resolution timers) - even so, as I develop on Linux at home, the code uses #ifdefs enforced by the make targets. While makefiles have been provided for GNU Make, it should be fairly trivial to port to other build systems, or for MS Windows, consider getting cygwin. The code has been broadly categorized into:

Bugs

If you encounter bugs, do inform me of them, whether you can reproduce it or not, what you think triggered it, and so on. Having said that, I am not currently taking patches (sorry), as these are my pet projects, a way to hone my programming skills. But the license is non-restrictive, you may derive your own work if you feel unhappy with mine and need an urgent fix. I definitely welcome suggestions to improving algorithms, code structure, and so on - my knowledge is not even one-billionth of what is out there, it would be an honour to receive constructive input.

Licensing

Unless otherwise stated, all code is released under the revised (no-advertising) BSD License. Essentially, you are free to do what you will with it, except claiming it to be your own. You are also required to acknowledge me in derivative works - you do NOT have to put it in an 'About' box in your application (though that is appreciated too), but it must be there in a visible place such as your documentation. Also, the code is without warranty whatsoever - as it is the norm to add jokes to this line, I shall do so: if the code drowns your yacht, kills your cat, fires your secretary, punches your boss, burns down your PS2, crashes your uber-stable boxen, puts you in the hospital, commits murder/assassination/acts of terror, causes your german shephard to have a toothache (wt?!), etc., etc. - I AM NOT RESPONSIBLE FOR IT. Now that we have that minor issue out of the way, enjoy the code :P.

Here is the full license:

BSD License

Copyright ©2004, Kamal Advani
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Libraries

VoidLibs

This is an attempt to make generic ANSI C-based containers, it makes heavy use of the void*, and function pointers. Newbies to C may find the syntax a bit overwhelming, and find the libraries relatively hard to use (compared to collections in newer languages); I still believe there's merit to developing such libraries in C for C programs. Currently an uber-functional linked list, and a vector with core functionality are ready with test drivers. The vector's test driver is a bit disorganized though.
Download

Utilities

meow

A unix `cat`-like utility - it concatenates files. It does not support any of the command line options that `cat` does; I wrote it because I wanted to be able to send chunks of a file to windows users over slow connections (I still use dial-up :( ), this way they have a tool to reconstruct the file. One could argue that there's cygwin, but most non-programmers will probably not have this installed. Written in ANSI C.
Download

evo2csv

This is a simple hack of a vcard to csv (comma-separated values) converter. A very limited one too! But it does the trick (for me anyway :P), at the time I wanted to upload my address book (Ximian Evolution vcards) to a web-based mail provider, and they only accepted comma-separated values. An hour or two later evo2csv was born of the ashes. Written in ANSI C.
Download

Numerical Integration Demo

This code demonstrates the use of numerical integration through the use of the Simpson and Trapezoidal methods. It was written as a university assignment when I was doing my diploma in Computer Science. Written in ANSI C++ (the one with the C++-style comments but essentially everything is C - or if you wish, written in ANSI C99 where // comments are allowed!).
Download

Simplex Method Demo

This code demonstrates the use of the Simplex Method to find solutions to Maximizing problems, a topic in Operations Research. Also a university assignment when I was doing my diploma. Written in Java (J2SDK 1.2 onwards required, uses Swing).
Download

Taylor Series Demo

This code demonstrates the use of the Taylor Series to approximate values of sine and cosine. Written as a university assignment when I was doing my diploma. Written in Java (J2SDK 1.2 onwards required, uses Swing).
Download

Error Snap

ErrorSnap is a simple utility for capturing stderr to file. It's pretty useless today. I wrote it when I began learning Java on Win98. It was frustrating to not be able to scroll in a win98 command shell, or even redirect stderr to see compile-time errors! NT provided the capability, but not Win98. ErrorSnap is now a relic, useful only for code inspection (as a demo of the java.lang.Runtime class for example). On the hyper-slim chance that anyone still uses Win98 (me) AND develops Java-based apps on it (not me, phew!), ErrorSnap may come in handy, so here you are.
Download

University Stuff

Audio Filter

This was written as a class project in, I think a subject called Computer Management, it requires Matlab to be of any use - it's basically a demo audio filter, making use of Matlab's FFT (fast fourier transforms) functions, to switch between time and frequency domains. Neat stuff, damn, I miss those diploma days!
Download

Network Programming

This is an assignment in a subject on Network Programming, it's written in C and uses the Berkeley Sockets API. It simulates a network of vending machines, connected over UDP, and special clients connected over TCP which gather sales info. Check either the 'final', or 'submit' directories for the final submitted version.
Download

Operating Systems

This subject involved 2 assignments, the first had to do with connecting and coordinating fork()ed 'nodes' using Unix IPC (inter-process communication); and the next was a small piece of code that made use of semaphores and pthreads to coordinate printing particular characters. Written in C with Unix specific features, and pthreads.
Download

Programming Principles 2A (Basic C)

This subject involved 2 assignments, the first had to do with developing an array to hold words and performing various operations on it. The next one served the same purpose but required creating a linked list as a container, while keeping the interface constant - finally a small word-finder application was used to test both array and linked list implementations. Written in ANSI C.
Download

Programming Principles 2B (Data Structures in C)

This subject involved 2 assignments, the first was implementing a sparse matrix to allow a spreadsheet-like structure with rows and columns - this was done using a linked list of linked lists. The next assignment implemented the same matrix using linear hashing. The code was profiled, and a report written. Written in ANSI C except for timing functions which used Solaris-specific calls.
Download

Unix Systems Administration

This subject had 2 assignments (deja vu!), both of them involved bash scripting. The first had to do with examining the passwd and shadow files, checking for users' expiry dates, and prompting them to change passwords, etc. The next one was to write a script to find duplicate files as an aid to reduce disk usage.
Download

©2004, Kamal Advani, technophobe [at] warpmail [dot] net