You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.5 KiB

  1. From 7dd8a1b6f4efab84025c735195ad9d84f6477359 Mon Sep 17 00:00:00 2001
  2. From: Jonathan Bennett <JBennett@incomsystems.biz>
  3. Date: Mon, 16 Oct 2017 11:59:23 -0500
  4. Subject: [PATCH] Adds the --inline option, which omits the xml tag for SVG
  5. output.
  6. ---
  7. qrenc.c | 11 +++++++++--
  8. 1 file changed, 9 insertions(+), 2 deletions(-)
  9. diff --git a/qrenc.c b/qrenc.c
  10. index ed83d8a..373352e 100644
  11. --- a/qrenc.c
  12. +++ b/qrenc.c
  13. @@ -45,6 +45,7 @@ static int structured = 0;
  14. static int rle = 0;
  15. static int svg_path = 0;
  16. static int micro = 0;
  17. +static int inline_svg = 0;
  18. static QRecLevel level = QR_ECLEVEL_L;
  19. static QRencodeMode hint = QR_MODE_8;
  20. static unsigned char fg_color[4] = {0, 0, 0, 255};
  21. @@ -80,6 +81,7 @@ static const struct option options[] = {
  22. {"margin" , required_argument, NULL, 'm'},
  23. {"dpi" , required_argument, NULL, 'd'},
  24. {"type" , required_argument, NULL, 't'},
  25. + {"inline" , no_argument , NULL, 'I'},
  26. {"structured" , no_argument , NULL, 'S'},
  27. {"kanji" , no_argument , NULL, 'k'},
  28. {"casesensitive", no_argument , NULL, 'c'},
  29. @@ -95,7 +97,7 @@ static const struct option options[] = {
  30. {NULL, 0, NULL, 0}
  31. };
  32. -static char *optstring = "ho:r:l:s:v:m:d:t:Skci8MV";
  33. +static char *optstring = "ho:r:l:s:v:m:d:t:ISkci8MV";
  34. static void usage(int help, int longopt, int status)
  35. {
  36. @@ -132,6 +134,7 @@ static void usage(int help, int longopt, int status)
  37. " -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8},\n"
  38. " --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
  39. " specify the type of the generated image. (default=PNG)\n\n"
  40. +" -I, --inline Only useful for SVG output, generates an svg without the XML tag\n"
  41. " -S, --structured\n"
  42. " make structured symbols. Version must be specified.\n\n"
  43. " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n"
  44. @@ -551,7 +554,8 @@ static int writeSVG(const QRcode *qrcode, const char *outfile)
  45. bg_opacity = (float)bg_color[3] / 255;
  46. /* XML declaration */
  47. - fputs( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n", fp );
  48. + if (!inline_svg)
  49. + fputs( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n", fp );
  50. /* DTD
  51. No document type specified because "while a DTD is provided in [the SVG]
  52. @@ -1324,6 +1328,9 @@ int main(int argc, char **argv)
  53. exit(EXIT_FAILURE);
  54. }
  55. break;
  56. + case 'I':
  57. + inline_svg = 1;
  58. + break;
  59. case 'S':
  60. structured = 1;
  61. break;