feed   myspace   facebook   last.fm   send an email   twitter   tumblr   send a message via aim to graykicksass

Posts tagged ‘apache’

Writing webapps in QuickBasic 4.5

Disclaimer: I realize this has no real valuable use whatsoever.

First off, credit where credit is due, when I initially had to setup the CGI I ran into a problem solved buy a guy on reddit, who managed to write a website clone in quickbasic. You have to do a simple C++ stub app that can direct the output from quickbasic apps into the server.

In order to pull this off, you’ll need a copy of the following tools:
1. Dev C++ (For compiling the stub app, to make your life easier, grab the one with a compiler built into the install) here

2.Quickbasic 4.5 (capable of generating EXE files) here

I also recommend xampp, very quick installation, works perfectly for this example. Grab it here


Now, to actually install quickbasic from this zip on windows, you have to create a fake A drive, or copy the files to a floppy.

The trick to doing this is a command line trick called subst

So, copy the quickbasic disk1 folder from the download, place it in a folder on C: like, FLOPPY1 and run this:
subst a: C:\FLOPPY1

Run the quickbasic setup app on the fake disk, when prompted to insert another disk, copy the contents of disk2 into the fake drive. Hopefully you’ll be able to run quickbasic now, and be greeted by this screen:

QuickBasic 4.5 welcome screen

QuickBasic 4.5 welcome screen

Once your in quickbasic, navigate the menus with ALT or your mouse, type out this simple program:

PRINT “Content-Type: text/html”
PRINT “”
PRINT “”
PRINT “
<h1>Hello World!</h1>

PRINT “”

Move over to the run menu and hit make EXE file, save your app. The app will be in the saved file directory, take it, rename it something simple (e.g. ‘app.exe’) and close.

Now, open up dev C++, navigate to File->New->Project and select console application, select C++ for the language, copy and paste this code into main.cpp:

#include <iostream>
#include <string>
#include <stdio.h>
int main(int argc, char *argv[])
{
std::string piper;
FILE* data = popen(“app.exe”,”r”);

for(char c = getc(data);c != EOF;c = getc(data))
{
piper.push_back(c);
}
pclose(data);

std::cout << piper;
return 0;
}

Press ctrl+F9 to compile or select compile from the menu. Open the directory where you saved the project, and copy the generated EXE file over to your cgi-bin directory (in htdocs for apache, with xampp it’s in the root directory of xampp/cgi-bin).

Now, with the stub in cgi-bin, rename your compiled quickbasic app to ‘app.exe’, and copy it to cgi-bin. Navigate to http://localhost/cgi-bin/stub.exe where stub.exe is whatever your compiled C++ application is called, you should now see a screen something like this:

hello world from quickbasic

hello world from quickbasic

Now you can run your webapps and display output in the browser, all you need now is to parse CGI variables, which is done via the ENVIRON$ function.

PRINT “Content-Type: text/html”
PRINT “”
PRINT “”
PRINT “
<h1>Hello World!</h1>

PRINT ENVIRON$(“QUERY_STRING”)
PRINT “”

QUERY_STRING is set by the CGI gateway, accessing this page with a url like http://localhost/cgi-bin/qload.exe?bla would print:
“Hello World! bla”

This has no real practical use anymore, but it’s just interesting to try out. Also, sorry about the code blocks here being screwed up, wordpress managed to mangle them.

X-ID3 header in modern web servers

I’ll keep this post short and straight to the point, it just seems like this idea should have followed suit right after streaming media became a common feature in HTTP Servers (e.g. lighthttpd).

With the standard format for online music being MP3 files, and the versatile format of streaming MP3’s (can be played while downloading), I see no reason why we shouldn’t be able to add some minimal support for these files in the web server.

It seems like a good idea to me to build an apache module in for MP3 metadata. It could be configured / disabled & enabled via the apache.conf file, preferably something that works with ID3 and HTTP headers. Which is why I propose the x-id3 header standard.

It should be simple enough, basically parsed Mp3 metadata in the Id3 format, passed in the HTTP headers in the following format:

x-id3-(id3 field name): Content

Just like every other HTTP header, I don’t know. Seems pretty basic and overlooked to me. I’d like to hear your thoughts though, so leave a comment with your opinion / ideas.

[Disclaimer: wrote this after pulling an all-nighter, so if it's written poorly, my bad]