Been there, done that...

Coding for fun



Warning! This page is always out of date, too.
-- WANG Cong



Code for Data Structures

Since my first year in university, I have been learning datastructures all by myself. I found that the code in nearly every book that introduces datastructures is ugly. So I rewrote them. Now, the code is available here and it is free.

Single Linking Lists

slist.h     slist.c

Double Linking Lists

dlist.h    dlist.c

Circular Lists

clist.h    clist.c

FILO Stacks

stack.h    stack.c

FIFO Queues

queue.h    queue.c

Deques

deque.h    deque.c

Binary Search Trees

bintree.h    bintree.c

Hash tables

hash.h    hash.c

Sorting functions

sort.h    sort.c

A Simple Shell

Hmm, I wrote a simple shell in our practice several months ago. It can parse simple command lines even including wildcards, pipes and redirections.

Download: sshell.tar.gz

A Java Scanner

Download the source code here and please use it freely.



An interesting topic: Self-printing Programs

I wrote two self-printing programs in C, one of them is accidentally similar to quine and the other one is absolutely new and is worthy your attention. :-P

selfprint.c   selfprint2.c

This one is in the same way, but using Perl.
selfprint.pl

Another interesting topic: Obfuscated Code

I tried to write one little program in C, which is very suitable for writing obfuscated code. This program is used to solve a simple puzzle. Please GUESS what it does. The source file is here. If you can understand that, please send a mail to me!

A Linux Serial Program

Recently, I program a micro controller using C51. But I don't want to show that code here. I write another program for my Linux to communicate with that micro controller. The program is simple, just sends user's input and shows it's response. The only one fresh thing is controlling serial ports on Linux. [serial.c] Hack it for your own purpose,

Kernel Modules

Hello, world!

This is the first kernel module I wrote. Just a simple hello-world.
Note that makefiles of all modules are also provided, you can get them in the tar ball. After uncompressing, get into that dir and just type make modules to compile the module. These modules are all tested on Linux kernel 2.6.17.7 and I think they will work fine on all the 2.6.* kernel.

/proc/clock

I was inspired by the book Kernel Projects for Linux to write this program. It implements a file named clock in the dir /proc. When you read it, it tells you the current system time in the form of "sec usec". And no one can write it. The test program for it comes along.

Perl Code

c2html.pl

This Perl program converts C source files to proper HTML files and also has grammar highlights. However, it is not so satisfying. Anyone who wants to hack it is welcome!

pcalc.pl

This program is little but useful. It is used to do some simple calculation between numbers of different index and display the result in bin/hex/oct/dec forms.

sstr.pl

This Perl program is useful. It searches the specified string in the current directory or replaces it with another specified string if exists.

procinfo.pl

Hmmm, this program can collect some useful information of your Linux machine. Enjoy it!

selfcopy.pl

Be careful! This script is dangerous! Run it on your own risk!


Python Code

SPyFTP

This is a small ftp client written in Python. But I plan to add more features to it, including GUI features. Hopefully, you can find it useful for you. ;)

convert_comments.py

It is a small tool to be used to convert your C99 style comments to K&R style. It was intended for Linux kernel source code, since there are lots of comments written in uncompatible C99 style.


Shell Code

ppp.sh

This script is co-written by DONG Pu and me, it is used to .... Touch on your own risk!





Back Home