Binary data including unprintable characters

2010-01-18
2013-10-10
  • Hello,

    Because I wanted to extract binary data embedded in a bar code with zbarimg, I slightly modified the source. Here I attached a patch against zbarimg.c.

     --- zbarimg.c  2010-01-07 03:37:17.000000000 +0900
    +++ zbarimg.c.mine  2010-01-18 15:52:49.063251786 +0900
    @@ -172,8 +172,14 @@
                            zbar_get_symbol_name(typ),
                            zbar_get_addon_name(typ),
                            zbar_symbol_get_data(sym));
    -            else if(xmllvl < 0)
    +            else if(xmllvl == -1 )
                     printf("%s\n", zbar_symbol_get_data(sym));
    +           else if(xmllvl < -1) {
    +               fwrite(zbar_symbol_get_data(sym),
    +                      zbar_symbol_get_data_length(sym),
    +                      1,
    +                      stdout);
    +           }
                 else {
                     if(xmllvl < 3) {
                         xmllvl++;
    @@ -290,6 +296,7 @@
                     !strcmp(arg, "--xml") ||
                     !strcmp(arg, "--noxml") ||
                     !strcmp(arg, "--raw") ||
    +                !strcmp(arg, "--bin") ||
                     !strncmp(arg, "--set=", 6))
                 continue;
             else if(!strcmp(arg, "--")) {
    @@ -350,7 +357,7 @@
                     printf("%s", xml_head);
                 }
             }
    -        else if(!strcmp(arg, "--noxml") || !strcmp(arg, "--raw")) {
    +        else if(!strcmp(arg, "--noxml") || !strcmp(arg, "--raw") || !strcmp(arg, "--bin")) {
                 if(xmllvl > 0) {
                     xmllvl = 0;
                     printf("%s", xml_foot);
    @@ -359,8 +366,12 @@
                     _setmode(_fileno(stdout), _O_TEXT);
     #endif
                 }
    -            if(!strcmp(arg, "--raw")) {
    -                xmllvl = -1;
    +            if(!strcmp(arg, "--raw") || !strcmp(arg, "--bin")) {
    +               if(!strcmp(arg, "--raw")) {
    +                   xmllvl = -1;
    +               } else {
    +                   xmllvl = -2;
    +               }
     #ifdef _WIN32
                     fflush(stdout);
                     _setmode(_fileno(stdout), _O_BINARY);
    
     
  • spadix
    spadix
    2010-01-23

    this should be fixed in hg (rev e262ad7ec633).  i didn't see the need for a new flag - the -raw option is intended to support this (please let me know if i missed something).  i also fixed zbarcam and updated the XML output to base64 encode binary symbol data.

    thanks for the patch!

     
  • LeadSuccess
    LeadSuccess
    2013-10-10

    Sorry for maybe dumb questions (using ZBar for a while now, but new to this forum):
    is this also applicable for the iOS SDK?
    If so, from which version on?
    And how to use it then?