Name: Tamer Embaby
Email: te (at) tsemba (dot) org
Facebook: http://www.facebook.com/tsemba
Flickr (Photography gallaries): http://flickr.com/tsemba
PGP: pkp-key


My old, no-longer-maintained page is here
 

C code

NOTE: all programs listed here lack manual pages/documentation for the current time

  • cheir

    This program print function calls hierarchy within another C programs. The target program could be a group of C files in a directory or single C file or it could be read from stdin. cheir can be instructed to begin function tarcing from certain function or list of functions, or from main by default.

    cheir is capable of extracting function code from the program, it also extracts all other functions that get called from the desired routine. However, it's not capable of identifing global variables, preprocessor marcos/defines, etc.

    cheir is not very fast, it builds multiple linked lists and walks through them many times to link all the pieces togther. But it's useful for understanding program flow, function dependency, and even extracting portions of code that can do certain tasks eliminating the need to include large programs in your code.

    In source extraction mode, cheir generated makefile to compile the resultant files, and even tries its best to include C header files used within the extracted code, which of course not guaranteed to compile!. NOTE: better result can be achieved if used after unifdef to remove complex constructs that can cause cheir to panic, although it tries its best to resolve such situations.

    Target platforms:
    OpenBSD, NetBSD, FreeBSD
    Windows 2000
    Linux (probably)

    current version: 1.0.8

    NOTE: the program name should read chier not cheir as of the word hierarchy, it was a typo, and I got too lazy to fix it.

    License: BSD

  • fh

    fh fetches HTML documents over HTTP protocol and save them on local directories. It can work behind HTTP proxy servers. fh can take advantage of HTTP 1.1 and open multiple connections to download the same document simultanuosly, which may help in accelerating the download speed.

    fh can open maximum of 8 connections to the HTTP server. It is a multithreaded agent built on preemptive pthread library, or with native kernel thread on Windows platforms.

    Current version of fh includes SSL support.

    Target platforms:
    OpenBSD, FreeBSD, NetBSD
    Windows 2000

    current version: 1.1.2-MT-SSL

    License: BSD

  • ss

    ss is yet another port scanner. I wrote ss for one reason, to learn the aspects of low level network programming. ss perform SYN/FIN scanning, ARP requests. It has interactive mode that allow its user to build TCP/IP headers and send a single packet and see its response.

    It's well designed, code is easy to understand, and easy to extend to add new functionality. It doesn't use libpcap since it's directly access BPF interface.

    Target platforms:
    OpenBSD, NetBSD, FreeBSD
    Windows 2000
    Windows NT (not tested)

    current version: 1.2.1-alpha_pre9

    License: BSD

  • ftplib

    This FTP library is written by Thomas Pfau, I found the code while searching the Internet for FTP library and found that the code dated back to 1998 and lack some important pieces like download resuming and working behind FTP proxy support. The original library was at version 3.1.

    I extended the library to include proxy server support, download resuming, upload resuming, directory listing parsing, cleared the code, fixed some issues about user callbacks and other stuff, changed the API names to more UNIXish names.

    Target platforms:
    OpenBSD
    Windows 2000
    Solaris 8
    It can esly ported to any other platform. I just need the time.

    current version: 4.4

    License: GNU

  • wsync

    This program synchronize local directory with remote directory heirarchy using FTP (ftplib), it can also replicate it to other local directory. wsync will then track changed files and uploads (synchronize) them without the need to re-upload the whole directory tree. It then keeps this information in a file in the local directory called .wsync.conf. It will keep these files remotely under the same directory name as the local one.

    wsync track changes to files by modification time. When first run (by issuing: cd target_directory && wsync) it will ask the user for list of file names/patterns to exclude from uploading, and will ignore these files. Some files are ignore by default, like the mentioned .wsync.conf since it could contain sensitive information.
    wsync will then allow the user to enter destination directory information like whether it is on local or ftp filesystem, active or passive FTP connections (to work behind firewalls), proxy information, FTP username and password, and optionally, a file name to load this information from. It saves this file read/write permissions to its owner only and never upload/replicate it to remote destination. wsync will never ask for this information again.

    wsync is capable of generating HTML file containing listing of files (name and size) in a hyperlinked way (wsync -g) and saves it in a file named index.html. The below directory listing, all source code uploads in this page is maintained by wsync.

    Target platforms:
    OpenBSD
    Solaris 8

    current version: 1.1.0

    License: BSD

  • getline.c
    char	*getline(FILE *file);
    

    A utility function that read a line from a file and returns a dynamiclly allocated memory pointer to it. getline allocates memory, so there is no restriction on line length. Also it strips '\n' character from the line.

    Target platforms:
    Any

    current version: CVS revision: 1.1

    License: Free

  • loc.c

    This program count the lines of code of other C programs. It operates on single C files or on directories containing C projects. loc reports the lines of code, empty lines, and number of lines in C/C++ style comments.

    loc can be instructed to exclude certain directories via the .locrc file, as:

    exclude=Attic
    exclude=other_dir/file.c
    

    Target platforms:
    OpenBSD, NetBSD, FreeBSD
    Windows
    Linux

    current version: CVS revision: 1.9

    License: Free

  • base64.c

    base64 does as the name says, base64 encode and decode files.

    Usage:

         $ base64 -e file     # Base64 encodes file, produces file.b64
         $ base64 -e - file   # dumps output on terminal
    
         $ base64 -d file.b64 # produces file
    

    Target platforms:
    OpenBSD, FreeBSD, NetBSD
    Windows 2000
    Linux

    current version: CVS revision: 1.3

    License: BSD

  • winerr_na.c

    This utility program extract information from Windows WinErr.h file about error codes and errors description and output the result in three different format:

    • Plain text file
    • CA-VO array
    • C array of structures
    So it can be embedded in any program project. It can recognize any Windows error description file following the WinErr.h format like oledberr.h.

    In C output mode, it generate fast binary search function code to provide a fast search among the array for a particular error code. It also generate C header file that includes a define for the total number of errors and a prototype for the binary search function.

    This program uses two external files: getline.c and utypes.h (found on this page).

    Target platforms:
    Windows 2000
    The code is clean and can be ported to any other platform.

    current version: Windows RCS revision: 1.12

    License: Free

  • getopt.c getopt.h

    This impelementation is taken from BSD Net/2, with the header file created to be used on systems that lack getopt() (e.g., Windows).

    Target platforms:
    Any

    License: BSD

  • strlib.c strlib.h

    C source file containing necessary string/memory manipulation routines, like splitv() which takes as argument a C string and return multidimentional array of pointers to tokenized strings based on a given delimiters or linear white space. And also strndup(), strcont(), etc.

    strlib.c contains key/value extraction routine kvparse() which extract key/value pair from a given line. It returns a pointer to a NULL terminated array of character pointers to a NUL terminated character string similar to argv (kvparse internally uses splitv) and returns kvp_t structure. See sources for more information.

    Target platforms:
    Any

    current version: CVS revision: 1.8

    License: BSD

  • ubuf.h

    ubuf is C structure that is used for manipulating variable length input. The set of macros defined in this file can easily expand the ubuf size by chaining multiple buffers togther. So ubuf can be used, for example, instead of writing to temporary files.

    The macros are designed so that it can be easily integrated with pre-allocated memory pools allocators/deallocators for fast memory allocation. Pre-allocated memory improves performance about 50% in speed than using C's malloc/free.

    The payload size of ubuf is defined to be 512 bytes which I think is suitable for user programs, but it can be redefined by user.

    Target platforms:
    Any

    current version: CVS revision: 1.6

    License: BSD

  • utypes.h

    Definitions of unsigned C types, bit types for platforms that don't define it (Windows).

    Target platforms:
    Windows
    Already exist in UNIX

    current version: CVS revision: 1.1

    License: BSD

  • bsd_list.h

    Excerpts from BSD's <sys/queue.h> file for systems that lack it (Windows/Linux).

    Target platforms:
    Windows
    Linux
    Exist in BSDs

    current version: CVS revision: 1.1

    License: BSD

  • cp2iso.c

    Reads input from stdin and convert characters in Windows-1256 Arabic code page to ISO-8859-6. This file needs utypes.h in order to compile.

    Target platforms:
    Windows
    Easily ported to any UNIX system

    current version: CVS revision: 1.1

    License: BSD

  • file2c.c

    Reads input from stdin and print output to stdout formatted suitable for using in C char arrays. I added hexadicimal output support.

    Target platforms:
    Any

    current version: CVS revision: 1.1

    License: BEER-WARE

  • soundex.c

    Computes the soundex code for string given as command line argument.

    Target platforms:
    Any

    current version: CVS revision: 1.1

    License: BSD

  • split.c

    Same as UNIX split but for Windows, and operate on binary files.

    Target platforms:
    Windows

    current version: CVS revision: 1.1

    License: BSD

  • stack.c stack.h

    Stack implemntation. Internally the stack is maintained as doubly linked list, so it's size is unlimited, but can be prefixed by the argument to newstack() routine. Stack data is void pointer, so it can hold any type of data.

    Stack operations are pointers to functions found in the stack structure itself, they can be accessed directly or used by provided convinience macros.

    Target platforms:
    Any

    current version: CVS revision: 1.1

    License: BSD

  • list.c list.h

    Provide generic doubly linked list attach, detach, freelist routines.

    Target platforms:
    Any

    current version: CVS revision: 1.2

    License: Free

  • ip_icmp.c.diff icmp_var.h.diff

    Two patches against OpenBSD 3.0 kernel that let the kernel ignore ICMP echo requests (pings) and timestamp request via sysctl request. Changed files:

    /usr/src/sys/netinet/ip_icmp.c
    /usr/src/sys/netinet/icmp_var.h
    
    Sysctl will have to be recompiled with icmp_var.h copied to: /usr/include/netinet.

    Then using sysctl:

    	$ sysctl net.inet.icmp.echoreqignore
    	net.inet.icmp.echoreqignore = 0
    	$ sudo sysctl -w net.inet.icmp.echoreqignore=1
    	net.inet.icmp.echoreqignore: 0 -> 1
    

    Target platforms:
    OpenBSD 3.0

    current version: CVS revision: 1.2

    License: BSD

  • machdep.c.patch

    Patch for machdep.c in OpenBSD 3.0 that let the system print system uptime on shutdown.
    /usr/src/sys/arch/i386/i386/machdep.c

    Target platforms:
    OpenBSD 3.0

    current version: CVS revision: 1.1

    License: BSD

  • m_pool.c m_pool.h my_bitstring.h

    Implementing memory pools for allocating fixed size chunks of memory, allocation is faster then regular malloc library calls. It returns chunks aligned by the machine word size.

    Target platforms:
    Any

    current version: CVS revision: 1.7

    License: BSD

  • log.c log.h

    A simple logger capable of logging to a file and/or stdout.

    Target platforms:
    Any

    current version: CVS revision: 1.9

    License: BSD

  • mailto

    mailto accepts email address(es) as command line argument and encode them to HTML character reference (&#XXXX; notation).

    	$ mailto user@site.com
    	mailto:&#117&#115&#101&#114&#64&#115&#105&#116&#101&#46&#99&#111&#109
    	$
    
    So it can be embedded in web pages. This will hopefully resist e-mail search engines, and hence SPAM while leaving email addresses readable.

    Target platforms:
    Any

    current version: CVS revision: 1.1

    License: BSD

  • memwatch

    Memory watching C modules, it's meant to detect memory leaks. See comments in mem_watch.c for detailed information.

    Target platforms:
    Any

    current version: CVS revision: 1.1

    License: BSD


Directory listings

$Id: index.html,v 1.70 2010/09/02 17:15:37 te Exp $