A c++ thing i am doing

Discuss Programming
Post Reply
Doogee
administrator
administrator
Posts: 261
Joined: Fri Jan 10, 2003 1:40 am

A c++ thing i am doing

Post by Doogee »

Ok want to happen is that when the user types in cd.. once you get to c:\windows it will take you back to C:\

Heres the source anyway :

Code: Select all

#include <iostream.h>
/*
 *Microsoft DOS 98 Source Code - Credits to X11 for his Dos XP project which this is based on
*/ 

int ver()
{
cout << "Microsoft DOS 98 Home Build 20031502\n"
"Copyright Microsoft Corp 2003\n"
"=============================\n\n";
return 0;
}

// Main Function
// This contains the main features, how ever I will move the command loop
// or the commands into different function(s).
int main(char* args[], int nargs)
{
char cmdi[200]; //sets a char array for the Command Input
char cd[100]; // sets char array for the cd command
char cdcom[50]; // sets char array for the commands inside the cd command
int exitlevel; //Sets the exitlevel
int errorlevel; //Sets the errorlevel
int cdlevel;

ver(); //Prints Version.
exitlevel = 0; //sets exitlevel to 0
errorlevel = 0; //Sets errorlevel to 0
cdlevel = 0;
while (exitlevel == 0) //Starts the "Command Loop"
{ //(Which might be moved into a function.
errorlevel = 1;
cout << "C:\\>"; //Writes C:\>
cin >> cmdi; //Input thingy

if (strcmp(cmdi, "exit") == 0) // The Exit Command
{
exitlevel = 1; // Sets exitlevel
errorlevel = 0; //sets errorlevel
}
if (strcmp(cmdi, "ver") == 0) //prints the version
{
ver();
errorlevel = 0;
}
if (strcmp(cmdi, "help") == 0) //prints the help (not yet done
{ //will become help() function!
cout << "Microsoft DOS 98 Help:\nNo help availiable at this time, work it out yourself";
errorlevel = 0;
}
if (strcmp(cmdi, "credits") == 0)
{
cout << "Mostly 'borrowed' from X11's DOS XP Project and added to by Doogee - doogee@punkass.com\n";
errorlevel = 0;
}

if (strcmp(cmdi, "cd") == 0)
cout << "cd to where:specify a directory\nDirectory: ";
cin >> cd;
if (strcmp(cd, "windows") == 0)
while (cdlevel == 0)
{
cout << "C:\\windows\\>";
cin >> cdcom;
if (strcmp(cdcom, "dir") == 0)
{
cout << "Directory contents of c:\\windows:\n";
}
if (strcmp(cdcom, "cd..") == 0)
 // This is where i want it to go back to C:\\>
}

if (errorlevel == 1) //Prints errorlevel
{
cout << "Bad Command or file name\n\n";
errorlevel = 0;
}

}
cout << "Thankyou for using Dos 98...\n\nKERNEL FAILURE in MCDCTRL.DLL at 0e3FF 44PGE\nContact you're hardware vendor\n";
return 0;
}

Master of Reality
guru
guru
Posts: 562
Joined: Thu Jan 09, 2003 8:25 pm

Post by Master of Reality »

erm.....
note: the name of this category "Linux Programming".
note: the command "cd.." in DOS will already take u down a directory

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

Master of Reality wrote:erm.....
note: the name of this category "Linux Programming".
note: the command "cd.." in DOS will already take u down a directory
I almost posted the same message and then I realized that he is just trying to make a DOS COMMAND emulator which you should be able to compile and run in Linux. It's not a bad way to learn how to program..

Doogee
administrator
administrator
Posts: 261
Joined: Fri Jan 10, 2003 1:40 am

Post by Doogee »

im just trying to make a mockery of it, although you can see it yet, but i will get to the funny stuff after i get the most common DOS commands down pat.

Also it is Linux Programming, im editing the program in gedit, comiling it with g++ and running it from a gnome terminal. in my books you can't really get more linux than that.

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Post by X11 »

Doogee, fix that code (tab it out) i cant work with squshed oops you know.

meanwhile....

Code: Select all

#include <iostream.h>
#include <stdlib.h>
/* 
 * John Tate - Dumbix
 * Theres many unixs out there well heres a wannabe, its just plain _dumb_.
 * inspired by doogees attepts at making a program. Which where inspiered by
 * my dos xp.
 * */

int main()
{
	cout << "DUBM (Dumb Unified Boot Loader)\n"
		<< "booting kernel";
	system("sleep 1");
	cout    << "kernel image loaded\n"
		<< "version: 2.3\n"
		<< "fetching system bogomips...\n";
		system("cat /proc/cpuinfo | grep bogomips");
	cout	<< "hard disks: hda hdb\n"
		<< "pci bus: slot0 slot1 slot2 slot4\n"
		<< "	slot0: ethernet\n"
		<< "		system ethernet adapter\n"
		<< "		eth0: 00:10:B4:0D:5D:21\n"
		<< "		type: eepro100\n"
		<< "	slot1: video\n"
		<< "		system video (vga)\n"
		<< "		vga0: standard vesa driver\n"
		<< "	slot2: scsi controller\n"
		<< "		scsi0: generic driver\n"
		<< "	slot4: atapi interface\n"
		<< "		wd0: wd10\n"
		<< "init loading system\n";
	system("ps aux");
	system("cat /proc/meminfo");
	system("cat /proc/partitions");
	system("clear");
	char cmd_in_dumbix[8000];
	while(1)
	{
		cout << "$ ";
		cin >> cmd_in_dumbix;
		system(cmd_in_dumbix);
	}
	return 0;
}

Post Reply