Jump to content
Clubplanet Nightlife Community

I hate programming


Recommended Posts

One of my projects from last semester. Operating Systems. We had to write a unix shell. Single line interpreter that supports pipes and redirectors. Obviously I didn't do this myself. Ended up dropping the class: fuck.cpp

#include<stdio.h>

#include<stdlib.h>

#include<unistd.h>

const char *pmpt = "myshell%% ";

int tokenizer (char *rawinput, char *argv[]);

void prompt(char *argv[]);

int parser (int argc, char *argv[]);

void shitproccessor (int &argc, char *argv[]);

void printer (int argc, char *argv[]);

void printer (int argc, char *argv[])

{

int index;

index = 0;

printf ("%d", argc + 320);

while (index <= argc - 1)

{

printf("\n");

printf("%d", index);

printf("%s", argv[index]);

index++;

}

printf ("%s", "Printer Done\n\n");

parser (argc, argv);

}

int tokenizer (char *rawi, char *argv[])

{

int rindex;

int aindex;

int argd;

rindex = 0;

aindex = 0;

argd = 0;

argv[0] = (char *)malloc(100 * sizeof(char *));

while (rawi[rindex] != '\0')

{

if (rawi[rindex] == ' ')

{

if ((rawi[rindex + 1] != ' ') && (rawi[rindex + 1] != '\0'))

{

argv[argd][aindex] = '\0';

aindex = 0;

argd++;

argv[argd] = (char *)malloc(100 * sizeof(char *));

}

}

else if ((rawi[rindex] == '<') | (rawi[rindex] == '|') | (rawi[rindex] == '>'))

{

if (aindex > 0)

{

argv[argd][aindex] = '\0';

aindex = 0;

argd++;

argv[argd] = (char *)malloc(10 * sizeof(char *));

argv[argd][0] = rawi[rindex];

argv[argd][1] = '\0';

if (rawi[rindex + 1] != '\0')

{

argd++;

argv[argd] = (char *)malloc(100 * sizeof(char *));

}

}

else

{

argv[argd][0] = rawi[0];

argv[argd][1] = '\0';

argv[argd] = (char *)malloc(100 * sizeof(char *));

}

}

else

{

argv[argd][aindex] = rawi[rindex];

aindex++;

}

rindex++;

}

argv[argd][aindex] = '\0';

argd++;

printf("\n");

printf("%d", argd);

printf("\n");

printer (argd, argv);

return argd;

}

int parser (int argc, char *argv[])

{

int index;

int redirectors;

int pipes;

int commands;

int arguments;

int seperator;

int sel;

printf ("%s", "Parser Begin");

// sel = 0;

redirectors = 0;

pipes = 0;

commands = 0;

arguments = 0;

seperator = 1;

index = 0;

printf ("%s", "Parser While");

while (index < argc)

{

if ((argv[index][0] == '>') | (argv[index][0] == '<'))

{

redirectors++;

seperator = 1;

}

else if (argv[index][0] == '|')

{

pipes++;

seperator = 1;

}

else

{

if (seperator == 1)

{

commands++;

seperator = 0;

}

else

{

arguments++;

printf("%s", argv[index][0]);

}

}

index++;

}

if (redirectors > 1)

{

printf("%s", "\nEntry Error: Too Many Redirectors");

return -1;

}

printf("%s", "\n");

printf("%s", "Selected String: ");

// printf("%s", argv[sel]);

printf("%s", "Program Contents:");

printf("%s%d", "\nCommands : ", commands);

printf("%s%d", "\nArguments : ", arguments);

printf("%s%d", "\nRedirectors: ", redirectors);

printf("%s%d", "\nPipes : ", pipes);

printf("\n");

}

void shitproccessor (int &argc, char *argv[])

{

char *firstcmd;

int index;

firstcmd = argv[0];

printf("%s", argv[argc]);

//parser(argc, argv);

argc--;

index = 1;

while (index <= argc)

{

argv[index - 1] = argv[index];

index++;

}

argv[argc + 1] = '\0';

execvp(firstcmd, argv);

}

void prompt(char *argv[])

{

char *rawinput;

int argc;

rawinput = (char *)malloc(100 * sizeof(char*));

printf (pmpt);

gets(rawinput);

argc = tokenizer (rawinput, argv);

shitproccessor(argc, argv);

}

void main(int &argc, char *argv[], char *envp[])

{

prompt(argv);

}

Link to comment
Share on other sites

Originally posted by teklord310

One of my projects from last semester. Operating Systems. We had to write a unix shell. Single line interpreter that supports pipes and redirectors. Obviously I didn't do this myself. Ended up dropping the class: fuck.cpp

that was our very first project at my OS class back in school. We had 10 days to write a shell. We had one month to write a full kernel (with all syscalls) and another to write the filesystem for it. I didn't get to go out too much that semester. :mad:

Link to comment
Share on other sites

Originally posted by dr0ne

that was our very first project at my OS class back in school. We had 10 days to write a shell. We had one month to write a full kernel (with all syscalls) and another to write the filesystem for it. I didn't get to go out too much that semester. :mad:

WOW! That is pretty nuts, I have to take and pass this class this coming year in order to graduate. Maybe i'll get some help from u :D And I thought this was a bitch... I don't know why, but the program that the TA wrote was 15 pages long. I think the average on this assignment was a 20/50.

Link to comment
Share on other sites

Originally posted by teklord310

WOW! That is pretty nuts, I have to take and pass this class this coming year in order to graduate. Maybe i'll get some help from u :D And I thought this was a bitch... I don't know why, but the program that the TA wrote was 15 pages long. I think the average on this assignment was a 20/50.

thats cuz rutgers kids party too much :)

i got fucked on the shell cuz my partner was a dumbfuck and we split the work evenly. then i pretty much decided to shove him to the side and do all work myself in order to pass the class.....end result:

shell - 60%

terminal driver - 95%

kernel - 98%

filesystem - 97%

:D

Link to comment
Share on other sites

Fuuuuuuuck Computer Programming. I remember back in the day when I thought I would be a Computer Science major. lmao:laugh: :laugh: :laugh: I dropped the first course, Comp Sci 111(but I heard 111 and 112 are the hardest ones).

Link to comment
Share on other sites

Originally posted by teklord310

Yo... do u mind if I take "Intro to Alcoholism 01:210:101" with you?? :laugh:

Werd.. it's a good class.. we went on a field trip to Centro the other day and drank our faces off.. you should join, it's a lot of independent study work and whatnot.

Link to comment
Share on other sites

Originally posted by codica3

Werd.. it's a good class.. we went on a field trip to Centro the other day and drank our faces off.. you should join, it's a lot of independent study work and whatnot.

Count me in, field trips rule! Can I study with you this time around? Let's start before classes resume, meet me at Alexander tonight at 9pm in front of the Undergrad reserve desk. :cool:

Link to comment
Share on other sites

Originally posted by teklord310

Count me in, field trips rule! Can I study with you this time around? Let's start before classes resume, meet me at Alexander tonight at 9pm in front of the Undergrad reserve desk. :cool:

Excuse me? :rolleyes: :rolleyes:

Link to comment
Share on other sites

think thats ruff? try being a network admin and having the hard drive on the PDC crash as you search through a closet looking for that backup tape drive so that you can get the network back up as you have 100 people askin you why their computers arent working and your boss is screaming at you that hes gonna fire you if you dont get the network back up in 5 minutes. time is money.

Link to comment
Share on other sites

Originally posted by scoob-e

think thats ruff? try being a network admin and having the hard drive on the PDC crash as you search through a closet looking for that backup tape drive so that you can get the network back up as you have 100 people askin you why their computers arent working and your boss is screaming at you that hes gonna fire you if you dont get the network back up in 5 minutes. time is money.

Hardware is my thing, i'd much rather deal with hardware problems over software anyway. I'd like to become MCSE certified, maybe CCNE too. Hopefully I can get those done this year, gotta get up off my ass and do something.

Link to comment
Share on other sites

*bump*

you think thats bad? my job at the moment consists of editing 3 linked C librarys totalling almost 40,000 lines of code that was last updated in 1987, and has a total of like 6 comments.

all so i can fuckin use the librarys in a bigger project.

:knife:

lets see... only 6 more hours till i can go home...

Link to comment
Share on other sites

Originally posted by gmoneyjive

I have OS coming up this fall... its definitely gonna be my hardest and most hated class in college - I hate coding in the first place. :knife: I'm seriously considering paying someone to write the 4 programs for me (I can handle the tests) :grenade:

Indeed, i've got to take it again either next semester or the following semester. We'll see what happens. The comp sci dept at my school is all high tech, they run a code checker on all our programs and see if two students used similar code. Changing the variables doesn't work :( Gluck man!

Link to comment
Share on other sites

Originally posted by teklord310

Indeed, i've got to take it again either next semester or the following semester. We'll see what happens. The comp sci dept at my school is all high tech, they run a code checker on all our programs and see if two students used similar code. Changing the variables doesn't work :( Gluck man!

yeah they use code comparing programs here to... so u gotta go beyond just variables... but you can do it if you change a lotta other stuff too... I've come to the conclusion that copying code and changing it takes about as long as writing it yourself, but you don't have to think ;)

Link to comment
Share on other sites

Originally posted by gmoneyjive

yeah they use code comparing programs here to... so u gotta go beyond just variables... but you can do it if you change a lotta other stuff too... I've come to the conclusion that copying code and changing it takes about as long as writing it yourself, but you don't have to think ;)

So you see my point.. It's the whole thinking thing that makes it worth it. Try to think as little as possible. Thinking is stressful.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...