Written by: Helio Loureiro
Category: Blog
Hits: 5566

Fiz um pequeno programa para ajudar aos novos estagiários a entender o "modus operandi" da empresa. Os efeitos superaram as expectativas, como comprovaram meus amigos de NRO (network rollout):


(15:00:55) Adriano_ASA @ at work SP: que porra é essa ???? 
(15:01:55) Adriano_ASA @ at work SP: responde essa merda !!! 
(15:02:00) Adriano_ASA @ at work SP: seu fdp !!! 
(15:02:12) Adriano_ASA @ at work SP: tá formatando o IO do NRG de cliente !!! 
(15:02:23) helio: hahahahahaha 
(15:02:32) helio: ele não faz nada 
(15:02:37) helio: é pra dar trote nos estags 
(15:02:41) helio: e nos manés!!!! 
(15:02:44) helio: hahahahahaha 
(15:02:46) helio: peguei!!! 
(15:02:55) Adriano_ASA @ at work SP: hehehehe... 
(15:03:02) Adriano_ASA @ at work SP: legal !! 
(15:03:09) helio: pega os caras aí 
(15:03:39) Adriano_ASA @ at work SP: seu viado !!! 
(15:07:46) Adriano_ASA @ at work SP: Vai correr atrás de mulher !!! 
(15:08:01) Adriano_ASA @ at work SP: fica gastando tempo com estas porras !!! 
(15:11:41) helio: hahahahaha 
(15:11:47) helio: tá todo mundo do GSDC sabendo 
(15:11:51) helio: fracasso miserável 
(15:13:12) Adriano_ASA @ at work SP has closed the conversation window.

Chamei de "counter.c", e pode ser compilado com "gcc -o counter counter.c". Os efeitos são hi-lá-ri-os!!!



#include  
#include  
#include  

void start_msg( int ); 
void print_point( int ); 

int main() { 
   char response[128]; 
   int progress = 0;
   struct sigaction sa;
   sa.sa_handler = SIG_IGN;
   sa.sa_flags = 0;
   sigemptyset(&sa.sa_mask);
   sigaction(SIGCHLD, &sa, NULL);
   sigaction(SIGTERM, &sa, NULL);
   sigaction(SIGKILL, &sa, NULL);
   sigaction(SIGINT, &sa, NULL);
   sigaction(SIGTRAP, &sa, NULL);
   sigaction(SIGSTOP, &sa, NULL);
   sigaction(SIGTSTP, &sa, NULL);
   sigaction(SIGTTIN, &sa, NULL);
   sigaction(SIGTTOU, &sa, NULL);
   start_msg(500);
   printf("Do you want to format your hard disk c:\\ ? [yes/no]: yes\n");
   printf("Are you really sure you want to do this? [yes/no]: ");
   scanf(response);
   start_msg(1);
   printf("Do you want to format your hard disk c:\? [yes/no]: yes\n");
   printf("Are you really sure you want to do this? [ yes/no]: yes\n");
   printf("\nProceeding with disk formatting.\n");
   printf("All your data will be erased and lost.\n");
   printf("Stop the process in case you didn´t create a backup.\n");
   printf("Formatting");
   for (progress = 10; progress <= 100 ; progress += 10) { 
      print_point(10);
      printf("%d%c", progress,'%');
   }
printf("\nHard disk successfuly formatted\n\n\n\n");
printf("System rebooting....");
fflush(NULL);
sleep(60*3);
return 0;
}

void start_msg(int timeout ) {
   int i, counter = 30;
   system("clear");
   printf("\n#####################################################################\n");
   printf("# Disk Formatter - Use with caution!!!! #\n");
   printf("# DISCLOSURE: There isn´t responsabilities for any damage caused #\n");
   printf("# this program. The usage and responsability, as any prosecution #\n");
   printf("# belongs exclusively to the user. #\n");
   printf("# Be sure about the impacts and use with caution. #\n");
   printf("#####################################################################\n\n\n");
   printf("Formatting system startup");
   for (i=0; i < counter; i++){
      printf(".");
      usleep(timeout);
   }
   printf(" ready!\n");
}

void print_point(int n) {
   int i;
   for (i=0; i <= n; i++) {
      printf(".");
      fflush(NULL);
      sleep(3);
   }
}