Skip to content

Instantly share code, notes, and snippets.

@albinoloverats
Last active August 29, 2015 14:18

Revisions

  1. albinoloverats revised this gist Jun 30, 2015. 1 changed file with 4 additions and 13 deletions.
    17 changes: 4 additions & 13 deletions qrcurses.c
    Original file line number Diff line number Diff line change
    @@ -17,12 +17,9 @@ static void qr_print(QRcode *qr)
    return;
    LINE(2);
    printf("%s", BLOCK);
    for (int y = 0; y < qr->width; y++)
    {
    for (int y = 0; y < qr->width; y += (printf("%s\n%s", BLOCK, BLOCK), 1))
    for (int x = 0; x < qr->width; x++)
    printf("%s", qr->data[y * qr->width + x] & 0x01 ? " " : BLOCK);
    printf("%s\n%s", BLOCK, BLOCK);
    }
    LINE(1);
    return;
    }
    @@ -34,22 +31,16 @@ int main(int argc, char **argv)

    if (argc > 1)
    {
    for (int i = 1; i < argc; i++)
    {
    for (int i = 1; i < argc; i += (strcat(data, argv[i]), 1))
    if (i > 1)
    strcat(data, " ");
    strcat(data, argv[i]);
    }
    qr = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
    }
    else
    {
    size_t len = read(STDIN_FILENO, data, sizeof data);
    qr = QRcode_encodeData(len, (unsigned char *)data, 0, QR_ECLEVEL_L);
    }
    qr = QRcode_encodeData(read(STDIN_FILENO, data, sizeof data), (unsigned char *)data, 0, QR_ECLEVEL_L);

    qr_print(qr);
    QRcode_free(qr);

    return EXIT_SUCCESS;
    }
    }
  2. albinoloverats revised this gist Jun 12, 2015. 1 changed file with 0 additions and 54 deletions.
    54 changes: 0 additions & 54 deletions qrcurses.c
    Original file line number Diff line number Diff line change
    @@ -2,13 +2,6 @@
    * gcc -lqrencode -Wall -Wextra -std=c99 -O3 -o qrcurses qrcurses.c
    */

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>/*
    * gcc -lqrencode -Wall -Wextra -std=c99 -O3 -o qrcurses qrcurses.c
    */

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    @@ -59,51 +52,4 @@ int main(int argc, char **argv)
    QRcode_free(qr);

    return EXIT_SUCCESS;
    }
    #include <qrencode.h>

    #define BLOCK "\x1b[47m \x1b[0m"
    #define LINE(z) for (int y = 0; y < qr->width + z; y++) printf("%s", BLOCK); printf("\n")

    static void qr_print(QRcode *qr)
    {
    if (!qr)
    return;
    LINE(2);
    printf("%s", BLOCK);
    for (int y = 0; y < qr->width; y++)
    {
    for (int x = 0; x < qr->width; x++)
    printf("%s", qr->data[y * qr->width + x] & 0x01 ? " " : BLOCK);
    printf("%s\n%s", BLOCK, BLOCK);
    }
    LINE(1);
    return;
    }

    int main(int argc, char **argv)
    {
    char data[7089] = { 0x0 };
    QRcode *qr = NULL;

    if (argc > 1)
    {
    for (int i = 1; i < argc; i++)
    {
    if (i > 1)
    strcat(data, " ");
    strcat(data, argv[i]);
    }
    qr = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
    }
    else
    {
    size_t len = read(STDIN_FILENO, data, sizeof data);
    qr = QRcode_encodeData(len, (unsigned char *)data, 0, QR_ECLEVEL_L);
    }

    qr_print(qr);
    QRcode_free(qr);

    return EXIT_SUCCESS;
    }
  3. albinoloverats revised this gist Jun 12, 2015. 1 changed file with 54 additions and 0 deletions.
    54 changes: 54 additions & 0 deletions qrcurses.c
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,13 @@
    * gcc -lqrencode -Wall -Wextra -std=c99 -O3 -o qrcurses qrcurses.c
    */

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>/*
    * gcc -lqrencode -Wall -Wextra -std=c99 -O3 -o qrcurses qrcurses.c
    */

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    @@ -11,6 +18,53 @@
    #define BLOCK "\x1b[47m \x1b[0m"
    #define LINE(z) for (int y = 0; y < qr->width + z; y++) printf("%s", BLOCK); printf("\n")

    static void qr_print(QRcode *qr)
    {
    if (!qr)
    return;
    LINE(2);
    printf("%s", BLOCK);
    for (int y = 0; y < qr->width; y++)
    {
    for (int x = 0; x < qr->width; x++)
    printf("%s", qr->data[y * qr->width + x] & 0x01 ? " " : BLOCK);
    printf("%s\n%s", BLOCK, BLOCK);
    }
    LINE(1);
    return;
    }

    int main(int argc, char **argv)
    {
    char data[7089] = { 0x0 };
    QRcode *qr = NULL;

    if (argc > 1)
    {
    for (int i = 1; i < argc; i++)
    {
    if (i > 1)
    strcat(data, " ");
    strcat(data, argv[i]);
    }
    qr = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
    }
    else
    {
    size_t len = read(STDIN_FILENO, data, sizeof data);
    qr = QRcode_encodeData(len, (unsigned char *)data, 0, QR_ECLEVEL_L);
    }

    qr_print(qr);
    QRcode_free(qr);

    return EXIT_SUCCESS;
    }
    #include <qrencode.h>

    #define BLOCK "\x1b[47m \x1b[0m"
    #define LINE(z) for (int y = 0; y < qr->width + z; y++) printf("%s", BLOCK); printf("\n")

    static void qr_print(QRcode *qr)
    {
    if (!qr)
  4. albinoloverats revised this gist Apr 2, 2015. 1 changed file with 1 addition and 4 deletions.
    5 changes: 1 addition & 4 deletions qrcurses.c
    Original file line number Diff line number Diff line change
    @@ -29,14 +29,11 @@ static void qr_print(QRcode *qr)

    int main(int argc, char **argv)
    {
    size_t len = 0;
    char data[7089] = { 0x0 };
    QRcode *qr = NULL;

    if (argc > 1)
    {
    for (int i = 1; i < argc; i++)
    len += strlen(argv[i]) + 1;
    for (int i = 1; i < argc; i++)
    {
    if (i > 1)
    @@ -47,7 +44,7 @@ int main(int argc, char **argv)
    }
    else
    {
    len = read(STDIN_FILENO, data, sizeof data);
    size_t len = read(STDIN_FILENO, data, sizeof data);
    qr = QRcode_encodeData(len, (unsigned char *)data, 0, QR_ECLEVEL_L);
    }

  5. albinoloverats created this gist Apr 1, 2015.
    58 changes: 58 additions & 0 deletions qrcurses.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    /*
    * gcc -lqrencode -Wall -Wextra -std=c99 -O3 -o qrcurses qrcurses.c
    */

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>
    #include <qrencode.h>

    #define BLOCK "\x1b[47m \x1b[0m"
    #define LINE(z) for (int y = 0; y < qr->width + z; y++) printf("%s", BLOCK); printf("\n")

    static void qr_print(QRcode *qr)
    {
    if (!qr)
    return;
    LINE(2);
    printf("%s", BLOCK);
    for (int y = 0; y < qr->width; y++)
    {
    for (int x = 0; x < qr->width; x++)
    printf("%s", qr->data[y * qr->width + x] & 0x01 ? " " : BLOCK);
    printf("%s\n%s", BLOCK, BLOCK);
    }
    LINE(1);
    return;
    }

    int main(int argc, char **argv)
    {
    size_t len = 0;
    char data[7089] = { 0x0 };
    QRcode *qr = NULL;

    if (argc > 1)
    {
    for (int i = 1; i < argc; i++)
    len += strlen(argv[i]) + 1;
    for (int i = 1; i < argc; i++)
    {
    if (i > 1)
    strcat(data, " ");
    strcat(data, argv[i]);
    }
    qr = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
    }
    else
    {
    len = read(STDIN_FILENO, data, sizeof data);
    qr = QRcode_encodeData(len, (unsigned char *)data, 0, QR_ECLEVEL_L);
    }

    qr_print(qr);
    QRcode_free(qr);

    return EXIT_SUCCESS;
    }