/* * ! \brief escape a UTF-8 encoded string into an ASCII. * usually used * for path-names only. * counterpart to unescape_path * * This function * allocates memory which must be freed by the caller. */ char *escape_path(const char *path, const char *flags) { /* * escape path if required. */ char *escaped_path; int processedBytes; if (serverInfo.LogLevel < LL_DEBUG) fprintf(serverInfo.LogFile, "escape_path: got path %s\n", path); if (have_flag("U") || serverInfo.do_encode) { escaped_path = malloc(MAX_FILENAME_LEN * sizeof(char)); if (escaped_path == NULL) { fprintf(serverInfo.LogFile, "%s:%d:: malloc error.", __FILE__, __LINE__); return NULL; } processedBytes = u8_escape(escaped_path, MAX_FILENAME_LEN, (char *)path, 1); if (serverInfo.LogLevel < LL_DEBUG) fprintf(serverInfo.LogFile, "escape_path: path=\"%s\", processedBytes=%d, strlen=%zd\n", path, processedBytes, strlen(path)); return escaped_path; } return (char *)path; }
if (c == '\\') outsn("\\\\", f, 2); else if (c == '"') outsn("\\\"", f, 2); else if (c >= 32 && c < 0x7f) outc(c, f); else { outsn("\\x", f, 2); outc(hexdig[c>>4], f); outc(hexdig[c&0xf], f); } } } else { while (i < sz) { size_t n = u8_escape(buf, sizeof(buf), str, &i, sz, 1, 0); outsn(buf, f, n-1); } } outc('"', f); } static numerictype_t sym_to_numtype(value_t type); #ifndef _OS_WINDOWS_ #define __USE_GNU #include <dlfcn.h> #undef __USE_GNU #endif #define sign_bit(r) ((*(int64_t*)&(r)) & BIT63) #define DFINITE(d) (((*(int64_t*)&(d))&0x7ff0000000000000LL)!=0x7ff0000000000000LL)