| @@ -45,7 +45,7 @@ https://e2li.org -> menu : Projet Prosecco. | |||
| #include <arpa/inet.h> | |||
| #include <pthread.h> | |||
| #define Version "1.03" | |||
| #define Version "1.04" | |||
| #define F_GETPIPE_SZ 1032 | |||
| #define F_SETPIPE_SZ 1031 | |||
| @@ -336,7 +336,7 @@ int t,v; | |||
| if (t==0) return 1; | |||
| if ((v=isCidr(w)) > 0) { /* test si CIDR */ | |||
| addCidr(w); | |||
| NbAddCidrs += (int)(1<<(32-v)); | |||
| NbAddCidrs += (int)(1<<v); | |||
| return 1; | |||
| } | |||
| if ((v=isCidr6(w)) > 0) { /* test si CIDR6 */ | |||
| @@ -472,12 +472,15 @@ int i,n=0; | |||
| #define EX_NOOUT 1 | |||
| #define EX_NOERR 2 | |||
| #define EX_DUREE 4 | |||
| #define EX_SILENT EX_NOOUT|EX_NOERR | |||
| int comsh(char *com,int mode) | |||
| { | |||
| pid_t pid; | |||
| int ret; | |||
| int ret,i=0; | |||
| char *c="|/-\\"; | |||
| if (mode & EX_DUREE) { printf(" ...\r"); fflush(stdout); } | |||
| if ((pid = fork()) < 0) { | |||
| perror("fork2"); return 99; | |||
| } | |||
| @@ -489,7 +492,14 @@ int ret; | |||
| execl("/bin/sh", "sh", "-c", com, (char *) 0); | |||
| perror("execl2"); return 98; | |||
| } | |||
| waitpid(pid,&ret,0); | |||
| if (mode & EX_DUREE) { | |||
| while (waitpid(pid,&ret,WNOHANG) != pid) { | |||
| sleep(1); | |||
| printf("%c\r",c[i++]); | |||
| fflush(stdout); | |||
| if (i==4) i=0; | |||
| } | |||
| } else waitpid(pid,&ret,0); | |||
| return WEXITSTATUS(ret); | |||
| } | |||
| @@ -670,11 +680,6 @@ int n; | |||
| } | |||
| } | |||
| void pr_encours(void) | |||
| { | |||
| printf(" ...\r"); fflush(stdout); | |||
| } | |||
| #define SUNIC "|sort|uniq" | |||
| #define JCTLSYS "journalctl --system" | |||
| #define JCTLSYSG JCTLSYS"|grep " | |||
| @@ -845,14 +850,12 @@ pid_t pid; | |||
| case 'r' : | |||
| if (*(cmd+1) != '\0') printf("ignore %s\n",cmd+1); | |||
| sprintf(com,"%s -L %s|grep %s%s%s",IPT,OUTP,DREJ,AWK5,SUNIC); | |||
| pr_encours(); | |||
| comsh(com,EX_NOERR); | |||
| comsh(com,EX_NOERR|EX_DUREE); | |||
| break; | |||
| case 'R' : | |||
| if (*(cmd+1) != '\0') printf("ignore %s\n",cmd+1); | |||
| sprintf(com,"%s -L|grep %s%s%s",IP6T,DREJ,AWK4,SUNIC); | |||
| pr_encours(); | |||
| comsh(com,EX_NOERR); | |||
| comsh(com,EX_NOERR|EX_DUREE); | |||
| break; | |||
| case 'N' : | |||
| if (*(cmd+1) != '\0') printf("ignore %s\n",cmd+1); | |||
| @@ -871,8 +874,7 @@ pid_t pid; | |||
| case 'v' : | |||
| if (*(cmd+1) != '\0') printf("ignore %s\n",cmd+1); | |||
| sprintf(com,"%s -L %s|grep %s%s%s",IPT,MYCH,DACC,AWK5,SUNIC); | |||
| pr_encours(); | |||
| comsh(com,EX_NOERR); | |||
| comsh(com,EX_NOERR|EX_DUREE); | |||
| break; | |||
| case ' ' : | |||
| if (*(cmd+1) != '\0') comsh(cmd+1,0); | |||