Skip to content

Instantly share code, notes, and snippets.

@LatinSuD
Last active May 15, 2017 10:15
Show Gist options
  • Select an option

  • Save LatinSuD/4b64e877af325d0b83938d23b8574e0b to your computer and use it in GitHub Desktop.

Select an option

Save LatinSuD/4b64e877af325d0b83938d23b8574e0b to your computer and use it in GitHub Desktop.

Revisions

  1. LatinSuD revised this gist May 15, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions filterMTR.c
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,9 @@ MTR is an enhanced traceroute tool for Linux and friends
    Cygwin (tested with 32 bit version, 2017-05-10).
    MTR built from https://github.com/traviscross/mtr
    Simple compiling:
    gcc -o procesarmtr.exe procesarmtr.c
    Invoke mtr using:
    real-mtr -b "$@" | procesarmtr.exe | cat
    (where real-mtr is the path to the actual mtr binary)
  2. LatinSuD revised this gist May 15, 2017. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions filterMTR.c
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,16 @@
    /*
    MTR is an enhanced traceroute tool for Linux and friends
    Needs:
    Cygwin (tested with 32 bit version, 2017-05-10).
    MTR built from https://github.com/traviscross/mtr
    Invoke mtr using:
    real-mtr -b "$@" | procesarmtr.exe | cat
    (where real-mtr is the path to the actual mtr binary)
    */

    #include <stdio.h>

    int main(int argc, char **argv) {
  3. LatinSuD revised this gist May 13, 2017. No changes.
  4. LatinSuD revised this gist May 13, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions filterMTR.c
    Original file line number Diff line number Diff line change
    @@ -28,6 +28,7 @@ int main(int argc, char **argv) {
    maxfilas=filas;
    }

    // Interceptar ?47h al principio para que no borre la pantalla
    if (a2=='\x1b' && a3=='[' && a4=='?' && a5=='4' && a6=='7' && a7=='h') {
    a7='l';
    }
  5. LatinSuD revised this gist May 13, 2017. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions filterMTR.c
    Original file line number Diff line number Diff line change
    @@ -28,6 +28,10 @@ int main(int argc, char **argv) {
    maxfilas=filas;
    }

    if (a2=='\x1b' && a3=='[' && a4=='?' && a5=='4' && a6=='7' && a7=='h') {
    a7='l';
    }

    // Interceptar 2J (limpiar pantalla al final)
    if (a5=='[' && a6=='2' && a7=='J') {
    // Convertirlo en: 2C H 15B. (2C=nada, H=ir al inicio, 15B=bajar 15)
  6. LatinSuD created this gist May 13, 2017.
    44 changes: 44 additions & 0 deletions filterMTR.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #include <stdio.h>

    int main(int argc, char **argv) {
    int a1,a2,a3,a4,a5,a6,a7;
    int filas;
    int maxfilas=10;

    setbuf(stdout,0);

    do {
    a1=a2;
    a2=a3;
    a3=a4;
    a4=a5;
    a5=a6;
    a6=a7;
    a7=getchar();

    // Contar las filas, ej: "ESC[12;5H" son 12 filas
    if (a1=='\x1b' && a2=='[' &&
    a3>='0' && a3<='9' &&
    a4>='0' && a4<='9' &&
    a5==';' &&
    a6=='5' && a7=='H'
    ) {
    filas = (a3-'0')*10 + a4-'0';
    if (filas > maxfilas)
    maxfilas=filas;
    }

    // Interceptar 2J (limpiar pantalla al final)
    if (a5=='[' && a6=='2' && a7=='J') {
    // Convertirlo en: 2C H 15B. (2C=nada, H=ir al inicio, 15B=bajar 15)
    printf("C\x1b[H\x1b[");
    printf("%d",maxfilas+1);
    printf("B");
    return 0;
    }

    if (a7 != EOF)
    putchar(a7);

    } while (a7 != EOF);
    }