MCPcopy Create free account
hub / github.com/OpenPrinting/cups / print_xml_string

Function print_xml_string

tools/ipptool.c:4050–4137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4048 */
4049
4050static void
4051print_xml_string(cups_file_t *outfile, /* I - Test data */
4052 const char *element, /* I - Element name or NULL */
4053 const char *s) /* I - String to print */
4054{
4055 if (element)
4056 cupsFilePrintf(outfile, "<%s>", element);
4057
4058 while (*s)
4059 {
4060 if (*s == '&')
4061 cupsFilePuts(outfile, "&amp;");
4062 else if (*s == '<')
4063 cupsFilePuts(outfile, "&lt;");
4064 else if (*s == '>')
4065 cupsFilePuts(outfile, "&gt;");
4066 else if ((*s & 0xe0) == 0xc0)
4067 {
4068 /*
4069 * Validate UTF-8 two-byte sequence...
4070 */
4071
4072 if ((s[1] & 0xc0) != 0x80)
4073 {
4074 cupsFilePutChar(outfile, '?');
4075 s ++;
4076 }
4077 else
4078 {
4079 cupsFilePutChar(outfile, *s++);
4080 cupsFilePutChar(outfile, *s);
4081 }
4082 }
4083 else if ((*s & 0xf0) == 0xe0)
4084 {
4085 /*
4086 * Validate UTF-8 three-byte sequence...
4087 */
4088
4089 if ((s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80)
4090 {
4091 cupsFilePutChar(outfile, '?');
4092 s += 2;
4093 }
4094 else
4095 {
4096 cupsFilePutChar(outfile, *s++);
4097 cupsFilePutChar(outfile, *s++);
4098 cupsFilePutChar(outfile, *s);
4099 }
4100 }
4101 else if ((*s & 0xf8) == 0xf0)
4102 {
4103 /*
4104 * Validate UTF-8 four-byte sequence...
4105 */
4106
4107 if ((s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80 ||

Callers 3

do_testFunction · 0.85
print_attrFunction · 0.85
print_xml_trailerFunction · 0.85

Calls 3

cupsFilePrintfFunction · 0.85
cupsFilePutsFunction · 0.85
cupsFilePutCharFunction · 0.85

Tested by

no test coverage detected