Nine Inch Runes
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Guild forum for Nine Inch Runes
 
HomeLatest imagesRegisterLog in
May 2024
MonTueWedThuFriSatSun
  12345
6789101112
13141516171819
20212223242526
2728293031  
CalendarCalendar

 

 Linux script that conts down the time of lightbearer basins

Go down 
AuthorMessage
Mave
Elder
Mave


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

Linux script that conts down the time of lightbearer basins Empty
PostSubject: Linux script that conts down the time of lightbearer basins   Linux script that conts down the time of lightbearer basins EmptySat 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
Back to top Go down
 
Linux script that conts down the time of lightbearer basins
Back to top 
Page 1 of 1

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