The World of Mayukh Bose

<< Back to Main Page Mayukh's world: e-mail me | about
Mayukh's World: C/C++ Freebies Monday, May 22, 2017
My Free Software
  • Delphi/C++ Builder
  • Pocket PC
  • FreeSpeech Chat
  • C/C++ Freebies
  • Perl
  • Python
  • Ruby
  • C/C++ Software
  • Simple SMTP Mailer
  • MOO Interpreter
  • CSV Parser Class
  • libcURL Wrapper
  • Dynamic C Array
  • C/C++ Free Software e-mail me

    Welcome to my C/C++ Software Page. Here are some pieces of code that I developed a while ago. Some of them are still works in progress, but they're still functional pieces of code.
    LEGAL DISCLAIMER: Note that there is NO WARRANTY for this software and the author assumes no responsibilities for any damages or losses caused by these programs. The code is released under the BSD License, and the terms and conditions may be found here.

    Simple SMTP Mailer

    The SMTP routines presented here enable you to send an e-mail message via the SMTP protocol. The code was written to be as cross-platform as possible. The code has been tested on the following platforms/compilers:
    • Windows 2000 Professional with Visual C++ 6.0
    • Windows 98 First Edition with Visual C++ 6.0
    • Windows 2000 Professional with Visual C++ .NET 2003
    • RedHat Linux 7.3 with gcc version 2.95
    • RedHat Linux 9.0 with gcc version 3.2.2
    • Fedora Core 1 with gcc version 3.3.2
    • Fedora Core 2 with gcc version 3.3.3
    • Slackware Linux 9.0 with gcc version 3.2.2
    • FreeBSD 4.9 - 4.10 with gcc version 2.95.3
    • OpenBSD 3.4 - 3.6 with gcc version 2.95.3 (propolice extensions)
    • NetBSD 1.6.1 with gcc version 2.95.3
    • OpenBSD 3.5 on sparc64 with gcc version 3.3.2 (propolice extensions)

    You will need to edit the code in SMTP Demo.cpp to specify your own mail server, sender and recepient. To compile the code in Linux, FreeBSD, OpenBSD or NetBSD, you should use something like this:

    mv "SMTP Demo.cpp" main.c
    gcc -o mailer main.c smtpfuncs.c

    If you don't rename the .cpp file, gcc tries to treat it as C++ rather than C code. So you might get compile errors from gcc, if you don't rename the file :).

    CHECK IT OUT
    Click here to download source code for the SMTP mailer. The source code is in ZIP format and you'll need WinZIP, unzip or some similar program to unzip the contents of the file. You will also need a C compiler such as Visual C++, Visual Studio .NET, or gcc to compile the code. The code was written to be easy to port, so it may be possible to use other compilers as well. If you've managed to get the code to compile in other environments, please let me know.

    CREDITS
    Here's a smooth shout out to the following people, who helped test/add to the code.
    • Allen G. Nimmo for testing the code out on Windows 98.
    • Chris Lacy-Hulbert for testing the code on RH 7.3 and Slackware, and also adding the Reply-To functionality to the code.
    • Luke T. Gilbert for suggesting the extra \n in the header and pointing me to the section for RFC 822 compliance.
    TOP


    MOO Interpreter

    So what is MOO, you ask? Well, MOO is an interpreter I wrote one fine day, just because I felt like writing some code. Why the funny name, you ask? Well, I decided to write it in C++ to keep my Object Oriented skills up. MOO stands for Mayukh's Objectionally Oriented Language. It should have been called MOOL, but I lost the L somewhere early on. Before you ask, the language itself is not object oriented at all. However, it is a weird mixture of pascal, python and C and is the product of my fertile (and somewhat warped!) imagination. The code has been tested on the following compilers/environments:
    • gcc 2.9.5 on FreeBSD 4.8, FreeBSD 4.9, OpenBSD 3.2, OpenBSD 3.3, OpenBSD 3.4 and Red Hat 7.1
    • gcc 3.2.2 on Red Hat 9
    • Visual C++ 6.0 on Windows 2000.
    DOCUMENTATION / FEATURES
    Haven't yet got the time to write anything formally as yet, but there are a couple of sample moo programs included and you should have no trouble figuring out the language. Some of the features are:
    • Two data types (integer and string).
    • The language is weakly typed, so variable types are not explicitly specified. It is actually possible to declare an integer and a string variable with the same name!
    • First line of any MOO program is always ignored. This allows you to use the first line to document what the program is about!.
    • Expressions are evaluated right-to-left and there's NO other operator precedence!
    • The language has no comments!
    • As of Jan 25th 2005, I broke down and implemented a WHILE and INPUT constructs as well.
    CHECK IT OUT
    Click here to download the MOO source code. To compile the source, do the following:
    tar -zxvf moo.tar.gz
    cd moo-interpreter
    make

    You can then run a moo program like this:
    ./moo test.moo

    Two sample moo programs are included with the source code, so that you can study them and get a feel for the language syntax.

    BUGS / IMPROVEMENTS
    There are NO bugs :). Anything you see that may be buggy, is actually A FEATURE!! However, there are some improvements that are planned for the future.
    • Comprehensive Documentation.
    • Better error handling.
    TOP


    CSV Parsing Class

    The CSV parsing class is a handy little class I wrote some years ago, to help in parsing CSV files. The code has been tested to work on various versions of FreeBSD and Linux also with Visual C++ on Windows.

    DOCUMENTATION / FEATURES
    The source code for the class is in two files (csvparser.cpp and csvparser.h) and there is a sample program provided (Makefile, main.cpp, sample.csv) that uses this class. The code to use this class is remarkably simple:
        CSVParser parser;
        string sInputLine, sColumn1, sColumn2;
        double fColumn3; 
        int iColumn4;
    
        parser << sInputLine; // Pass in a line
        parser >> sColumn1 >> sColumn2 >> fColumn3 >> iColumn4; // Read out columns
    
    The code handles three datatypes currently (integer, double and string). Feel free to add more types as needed.

    CHECK IT OUT
    Click here to download the CSV Parser Class source code. To compile the source, do the following:

    tar -zxvf csvclass.tar.gz
    cd csvclass
    make
    ./csvdemo

    The code should read the data from sample.csv and parse out the columns.

    CREDITS
    The following people deserve special mention, so here's a smooth shout out to:
    • Keith Oxenrider for reviewing this code and testing on Visual C++.

    TOP

    libcURL Wrapper Functions

    libcURL is a free library to retrieve data from the internet. It supports a variety of protocols such as FTP, FTPS, HTTP, HTTPS, GOPHER etc. I wrote a few functions to encapsulate the HTTP and HTTPS protocols within some C++ code. These functions make retrieving data a breeze. The code works on various versions of Linux, FreeBSD, OpenBSD and on Windows 2000 using Visual C++ 6.0 and 7.0.

    DOCUMENTATION / FEATURES
    The source code for the class is in two files (curlfuncs.cpp and curlfuncs.h) and there is a sample program provided (Makefile, main.cpp) that uses this class. Complete documentation for all the wrapper functions is also provided in DOCS.txt. To give you an idea of how simple it is to retrieve data, here's a sample:
        string sHtml;
        CurlGetFile("http://www.mayukhbose.com/", &sHtml);
        cout << sHtml << endl;   
    

    CHECK IT OUT
    Click here to download the libcURL Wrapper source code. To compile the source, do the following:

    Install libcURL, if you haven't done so yet
    tar -zxvf curlwrapper.tar.gz
    cd curlwrapper
    make
    ./curldemo

    The code should retrieve some data and print out the first 100 characters from the webpage.

    CREDITS
    The following people deserve special mention, so here's a smooth shout out to:
    • Keith Oxenrider for reviewing this code and testing with Visual C++.

    TOP

    Dynamic C Arrays

    The dynamic array functions are something I wrote for fun. I know apache provides a perfectly good set of APR array functions, but I figured the world could use something which doesn't require a lot of other functions as well. The following code has been tested to work on various versions of Linux and OpenBSD and should work on Windows as well

    DOCUMENTATION / FEATURES
    The source code for the functions is in two files (dyn_array.c and dyn_array.h) and there is a sample program provided (Makefile, test_arrays.c) that use these functions. You can learn a lot by studying the comments in test_arrays.c and checking the documentation of every function in dyn_array.c

    CHECK IT OUT
    Click here to download the Dynamic Array source code. To compile the source, do the following:

    tar -zxvf dyn_array.tar.gz
    cd dyn_array
    make
    ./test_arrays

    The code should allocate an array, push data for 200 students on to it, retrieve the data, then pop the last 5 students off the end of the array.

    TOP