FreeCalypso > hg > freecalypso-tools
view rvinterf/libprint/back_esc.c @ 1001:7df4c9ae6ba4
loadtools/scripts: w220.{config,init} => chimei.{config,init}
Motorola W220, first touched by FreeCalypso in 2019-05, is an ODM phone
made by Chi-Mei, and its peculiar property of relevance to loadtools
is that it has XRAM on Calypso nCS3 instead of the usual nCS1 - which
matters for fc-xram. We are now discovering other Chi-Mei phones
including Sony Ericsson J120, and they share the same quirk of XRAM
on nCS3 - hence we rename this loadtools target from w220 to chimei.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 09 Dec 2023 17:53:44 +0000 |
parents | 6a0aa8d36d06 |
children |
line wrap: on
line source
/* * The function implemented in this module prints a potentially-dirty string * into a buffer with C-style backslash escapes, including doubling of any * already-present backslashes. The output buffer must be sized for up to * 4x expansion, plus the terminating NUL. */ #include <sys/types.h> #include <ctype.h> #include <stdio.h> void safe_print_trace(src, srclen, dest) u_char *src; char *dest; { int i, c; char *dp; dp = dest; for (i = 0; i < srclen; i++) { c = src[i]; switch (c) { case '\\': *dp++ = '\\'; *dp++ = '\\'; continue; case '\r': *dp++ = '\\'; *dp++ = 'r'; continue; case '\n': *dp++ = '\\'; *dp++ = 'n'; continue; } if (c >= ' ' && c <= '~') *dp++ = c; else if (c <= 7 && (i+1 == srclen || !isdigit(src[i+1]))) { sprintf(dp, "\\%d", c); dp += 2; } else { sprintf(dp, "\\x%02X", c); dp += 4; } } *dp = '\0'; }