Guild forum for Nine Inch Runes
 
HomeFAQRegisterLog in
October 2017
MonTueWedThuFriSatSun
      1
2345678
9101112131415
16171819202122
23242526272829
3031     
CalendarCalendar

Share | 
 

 Linux script that conts down the time of lightbearer basins

View previous topic View next topic Go down 
AuthorMessage
Mave
Elder
avatar

Number of posts : 923
Age : 25
Vocation : Royal Paladin
Level : 469
Registration date : 2008-03-06

PostSubject: Linux script that conts down the time of lightbearer basins   Sat Nov 13, 2010 8:03 pm

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <time.h>

char buffer[10];
char buffer2 [256];
char ent1[10];

int times[10];
int ret, i, ent, ent2;
int j;


void comment() {
sprintf(buffer2,"I am here %d\n",j);
write(1,buffer2, strlen(buffer2));
++j;
}

void writelight() {
sprintf(buffer2,"Hellspawns: %d.\n",times[0]);
write(1,buffer2, strlen(buffer2));
sprintf(buffer2,"Forbidden lands: %d.\n",times[1]);
write(1,buffer2, strlen(buffer2));
sprintf(buffer2,"Formorgar glacier: %d.\n",times[2]);
write(1,buffer2, strlen(buffer2));
sprintf(buffer2,"Edron: %d.\n",times[3]);
write(1,buffer2, strlen(buffer2));
sprintf(buffer2,"Bonebeasts island: %d.\n",times[4]);
write(1,buffer2, strlen(buffer2));
sprintf(buffer2,"Drefia: %d.\n",times[5]);
write(1,buffer2, strlen(buffer2));
sprintf(buffer2,"Hellgate: %d.\n",times[6]);
write(1,buffer2, strlen(buffer2));
sprintf(buffer2,"Poh: %d.\n",times[7]);
write(1,buffer2, strlen(buffer2));
sprintf(buffer2,"Kazordoon: %d.\n",times[8]);
write(1,buffer2, strlen(buffer2));
sprintf(buffer2,"Tarpit: %d.\n\n\n",times[9]);
write(1,buffer2, strlen(buffer2));
}

void funcio_alarm(int signal) {
for (i= 0; i <10;++i) {
times[i] = times[i]-1;
}
writelight();
alarm(60);
}

void funcio_write(int signal) {
writelight();

}

void main (int argc,char * argv[]) {
j = 0;
signal(SIGALRM,funcio_alarm);
signal(SIGUSR1,funcio_write);
fprintf(stdout, "Hellspawns:\n");
ret = read(0,&buffer, sizeof(int));
times[0] = atoi(buffer);
fprintf(stdout, "Forbidden lands:\n");
ret = read(0,&buffer, sizeof(int));
times[1] = atoi(buffer);
fprintf(stdout, "Formorgar glacier:\n");
ret = read(0,&buffer, sizeof(int));
times[2] = atoi(buffer);
fprintf(stdout, "Edron:\n");
ret = read(0,&buffer, sizeof(int));
times[3] = atoi(buffer);
fprintf(stdout, "Bonebeasts island:\n");
ret = read(0,&buffer, sizeof(int));
times[4] = atoi(buffer);
fprintf(stdout, "Drefia:\n");
ret = read(0,&buffer, sizeof(int));
times[5] = atoi(buffer);
fprintf(stdout, "Hellgate:\n");
ret = read(0,&buffer, sizeof(int));
times[6] = atoi(buffer);
fprintf(stdout, "Poh:\n");
ret = read(0,&buffer, sizeof(int));
times[7] = atoi(buffer);
fprintf(stdout, "Kazordoon:\n");
ret = read(0,&buffer, sizeof(int));
times[8] = atoi(buffer);
fprintf(stdout, "Tarpit:\n");
ret = read(0,&buffer, sizeof(int));
times[9] = atoi(buffer);
writelight();
alarm(60);
while(1) {
//100 100 100 100 100 100 100 100 100 100

ret = read(0,&ent1, sizeof(int));
ent = atoi(ent1);
if (ent == 1) {
sprintf(buffer2,"Hellspawns: ");
write(1,buffer2, strlen(buffer2));;
ret = read(0,&ent1, sizeof(int));
ent2 = atoi(ent1);
if (ent2 > 0 && ent2 < 121) {
times[ent-1] = ent2;
}
} else if (ent == 2) {
sprintf(buffer2,"Forbidden lands: ");
write(1,buffer2, strlen(buffer2));
ret = read(0,&ent1, sizeof(int));
ent2 = atoi(ent1);
if (ent2 > 0 && ent2 < 121) {
times[ent-1] = ent2;
}
} else if (ent == 3) {
sprintf(buffer2,"Formorgar glacier: ");
write(1,buffer2, strlen(buffer2));
ret = read(0,&ent1, sizeof(int));
ent2 = atoi(ent1);
if (ent2 > 0 && ent2 < 121) {
times[ent-1] = ent2;
}
} else if (ent == 4) {
sprintf(buffer2,"Edron: ");
write(1,buffer2, strlen(buffer2));
ret = read(0,&ent1, sizeof(int));
ent2 = atoi(ent1);
if (ent2 > 0 && ent2 < 121) {
times[ent-1] = ent2;
}
} else if (ent == 5) {
sprintf(buffer2,"Bonebeasts island: ");
write(1,buffer2, strlen(buffer2));
ret = read(0,&ent1, sizeof(int));
ent2 = atoi(ent1);
if (ent2 > 0 && ent2 < 121) {
times[ent-1] = ent2;
}
} else if (ent == 6) {
sprintf(buffer2,"Drefia: ");
write(1,buffer2, strlen(buffer2));
ret = read(0,&ent1, sizeof(int));
ent2 = atoi(ent1);
if (ent2 > 0 && ent2 < 121) {
times[ent-1] = ent2;
}
} else if (ent == 7) {
sprintf(buffer2,"Hellgate: ");
write(1,buffer2, strlen(buffer2));
ret = read(0,&ent1, sizeof(int));
ent2 = atoi(ent1);
if (ent2 > 0 && ent2 < 121) {
times[ent-1] = ent2;
}
} else if (ent == Cool {
sprintf(buffer2,"Poh: ");
write(1,buffer2, strlen(buffer2));
ret = read(0,&ent1, sizeof(int));
ent2 = atoi(ent1);
if (ent2 > 0 && ent2 < 121) {
times[ent-1] = ent2;
}
} else if (ent == 9) {
sprintf(buffer2,"Kazordoon: ");
write(1,buffer2, strlen(buffer2));
ret = read(0,&ent1, sizeof(int));
ent2 = atoi(ent1);
if (ent2 > 0 && ent2 < 121) {
times[ent-1] = ent2;
}
} else if (ent == 10) {
sprintf(buffer2,"Tarpit: ");
write(1,buffer2, strlen(buffer2));
ret = read(0,&ent1, sizeof(int));
ent2 = atoi(ent1);
if (ent2 > 0 && ent2 < 121) {
times[ent-1] = ent2;
}
} else {
sprintf(buffer2,"It does not exist.\n");
write(1,buffer2, strlen(buffer2));
}
}
}

//compile it gcc -c Lightbearer.c
//then gcc -o Lightbearer Lightbearer.o

_________________
Signed, Mave.
In memory of th most uncereal man of the world;
15
bounce
Back to top Go down
 
Linux script that conts down the time of lightbearer basins
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» At what time do you wake up on the weekends?
» Ironside theme time
» Time Paradox - part 0.0037 (comic attemp #1)
» Bracken Tor to Explore The Time Of Tooth and Claw
» Your Top Ten Animated series of all time.

Permissions in this forum:You cannot reply to topics in this forum
Nine Inch Runes :: Public Board-
Jump to: