/* The configure-generated path macros might have '@' at the beginning, indicating the runtime directory. */ void maybe_prepend_install_dir(const char *orig, char *buf, int buflen, void (*errfn)(const char *, ...)) { if (*orig == '@') { int len = get_install_dir(buf, buflen, errfn); if (len + (int)strlen(orig) > buflen) { errfn("Pathname too long: %s", orig); } strcat(buf, orig+1); } else { if ((int)strlen(orig) >= buflen-1) { errfn("Pathname too long: %s", orig); } strcpy(buf, orig); } }
static WCHAR *mbs2wcs(const char *s, int use_gc, void (*errfn)(const char *, ...)) { WCHAR *wb; int nc = MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0); if (nc == 0) { errfn("Windows error %d on MultiByteToWideChar", GetLastError()); } #if defined(GAUCHE_H) if (use_gc) wb = SCM_NEW_ATOMIC_ARRAY(WCHAR, nc); else wb = (WCHAR*)malloc(nc * sizeof(WCHAR)); #else wb = (WCHAR*)malloc(nc * sizeof(WCHAR)); #endif if (MultiByteToWideChar(CP_UTF8, 0, s, -1, wb, nc) == 0) { errfn("Windows error %d on MultiByteToWideChar", GetLastError()); } return wb; }
static const char *wcs2mbs(const WCHAR *s, int use_gc, void (*errfn)(const char*, ...)) { char *mb; int nb = WideCharToMultiByte(CP_UTF8, 0, s, -1, NULL, 0, 0, 0); if (nb == 0) { errfn("Windows error %d on WideCharToMultiByte", GetLastError()); } #if defined(GAUCHE_H) if (use_gc) mb = SCM_NEW_ATOMIC_ARRAY(char, nb); else mb = (char*)malloc(nb);
void _lgtd_err(void (*errfn)(int, const char *, ...), int eval, const char *fmt, ...) { int errsave = errno; va_list ap; va_start(ap, fmt); // lgtd_cleanup is probably going to free some of the arguments we got, so // let's print to a buffer before we call err. char errmsg[LGTD_ERROR_MSG_BUFSIZE]; vsnprintf(errmsg, sizeof(errmsg), fmt, ap); va_end(ap); lgtd_cleanup(); lgtd_log_header("ERR", false); errno = errsave; errfn(eval, errmsg); }
static int get_install_dir(char *buf, int buflen, void (*errfn)(const char *, ...)) { errfn("We can't obtain runtime pathname on this platform"); return 0; }