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

Function quote_string

backend/ipp.c:3095–3138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3093 */
3094
3095static const char * /* O - Quoted string */
3096quote_string(const char *s, /* I - String */
3097 char *q, /* I - Quoted string buffer */
3098 size_t qsize) /* I - Size of quoted string buffer */
3099{
3100 char *qptr, /* Pointer into string buffer */
3101 *qend; /* End of string buffer */
3102
3103
3104 qptr = q;
3105 qend = q + qsize - 5;
3106
3107 if (qend < q)
3108 {
3109 *q = '\0';
3110 return (q);
3111 }
3112
3113 *qptr++ = '\'';
3114 *qptr++ = '\"';
3115
3116 while (*s && qptr < qend)
3117 {
3118 if (*s == '\\' || *s == '\"' || *s == '\'')
3119 {
3120 if (qptr < (qend - 4))
3121 {
3122 *qptr++ = '\\';
3123 *qptr++ = '\\';
3124 *qptr++ = '\\';
3125 }
3126 else
3127 break;
3128 }
3129
3130 *qptr++ = *s++;
3131 }
3132
3133 *qptr++ = '\"';
3134 *qptr++ = '\'';
3135 *qptr = '\0';
3136
3137 return (q);
3138}
3139
3140
3141/*

Callers 2

password_cbFunction · 0.70
report_attrFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected