/*
* Macros for manipulating actx->errbuf. actx_error() translates and formats a
- * string for you; actx_error_str() appends a string directly without
- * translation.
+ * string for you, actx_error_internal() is the untranslated equivalent, and
+ * actx_error_str() appends a string directly (also without translation).
*/
#define actx_error(ACTX, FMT, ...) \
appendPQExpBuffer(&(ACTX)->errbuf, libpq_gettext(FMT), ##__VA_ARGS__)
+#define actx_error_internal(ACTX, FMT, ...) \
+ appendPQExpBuffer(&(ACTX)->errbuf, FMT, ##__VA_ARGS__)
+
#define actx_error_str(ACTX, S) \
appendPQExpBufferStr(&(ACTX)->errbuf, S)
#define oauth_parse_set_error(ctx, fmt, ...) \
appendPQExpBuffer((ctx)->errbuf, libpq_gettext(fmt), ##__VA_ARGS__)
+#define oauth_parse_set_error_internal(ctx, fmt, ...) \
+ appendPQExpBuffer((ctx)->errbuf, fmt, ##__VA_ARGS__)
+
static void
report_type_mismatch(struct oauth_parse *ctx)
{
if (ctx->active)
{
Assert(false);
- oauth_parse_set_error(ctx,
- "internal error: started field '%s' before field '%s' was finished",
- name, ctx->active->name);
+ oauth_parse_set_error_internal(ctx,
+ "internal error: started field \"%s\" before field \"%s\" was finished",
+ name, ctx->active->name);
return JSON_SEM_ACTION_FAILED;
}
if (!ctx->nested && ctx->active)
{
Assert(false);
- oauth_parse_set_error(ctx,
- "internal error: field '%s' still active at end of object",
- ctx->active->name);
+ oauth_parse_set_error_internal(ctx,
+ "internal error: field \"%s\" still active at end of object",
+ ctx->active->name);
return JSON_SEM_ACTION_FAILED;
}
if (ctx->nested != 2 || ctx->active->type != JSON_TOKEN_ARRAY_START)
{
Assert(false);
- oauth_parse_set_error(ctx,
- "internal error: found unexpected array end while parsing field '%s'",
- ctx->active->name);
+ oauth_parse_set_error_internal(ctx,
+ "internal error: found unexpected array end while parsing field \"%s\"",
+ ctx->active->name);
return JSON_SEM_ACTION_FAILED;
}
if (ctx->nested != 1)
{
Assert(false);
- oauth_parse_set_error(ctx,
- "internal error: scalar target found at nesting level %d",
- ctx->nested);
+ oauth_parse_set_error_internal(ctx,
+ "internal error: scalar target found at nesting level %d",
+ ctx->nested);
return JSON_SEM_ACTION_FAILED;
}
if (*field->scalar)
{
Assert(false);
- oauth_parse_set_error(ctx,
- "internal error: scalar field '%s' would be assigned twice",
- ctx->active->name);
+ oauth_parse_set_error_internal(ctx,
+ "internal error: scalar field \"%s\" would be assigned twice",
+ ctx->active->name);
return JSON_SEM_ACTION_FAILED;
}
if (ctx->nested != 2)
{
Assert(false);
- oauth_parse_set_error(ctx,
- "internal error: array member found at nesting level %d",
- ctx->nested);
+ oauth_parse_set_error_internal(ctx,
+ "internal error: array member found at nesting level %d",
+ ctx->nested);
return JSON_SEM_ACTION_FAILED;
}
actx->mux = epoll_create1(EPOLL_CLOEXEC);
if (actx->mux < 0)
{
- actx_error(actx, "failed to create epoll set: %m");
+ actx_error_internal(actx, "failed to create epoll set: %m");
return false;
}
actx->timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
if (actx->timerfd < 0)
{
- actx_error(actx, "failed to create timerfd: %m");
+ actx_error_internal(actx, "failed to create timerfd: %m");
return false;
}
if (epoll_ctl(actx->mux, EPOLL_CTL_ADD, actx->timerfd, &ev) < 0)
{
- actx_error(actx, "failed to add timerfd to epoll set: %m");
+ actx_error_internal(actx, "failed to add timerfd to epoll set: %m");
return false;
}
actx->mux = kqueue();
if (actx->mux < 0)
{
- /*- translator: the term "kqueue" (kernel queue) should not be translated */
- actx_error(actx, "failed to create kqueue: %m");
+ actx_error_internal(actx, "failed to create kqueue: %m");
return false;
}
actx->timerfd = kqueue();
if (actx->timerfd < 0)
{
- actx_error(actx, "failed to create timer kqueue: %m");
+ actx_error_internal(actx, "failed to create timer kqueue: %m");
return false;
}
break;
default:
- actx_error(actx, "unknown libcurl socket operation: %d", what);
+ actx_error_internal(actx, "unknown libcurl socket operation: %d", what);
return -1;
}
switch (op)
{
case EPOLL_CTL_ADD:
- actx_error(actx, "could not add to epoll set: %m");
+ actx_error_internal(actx, "could not add to epoll set: %m");
break;
case EPOLL_CTL_DEL:
- actx_error(actx, "could not delete from epoll set: %m");
+ actx_error_internal(actx, "could not delete from epoll set: %m");
break;
default:
- actx_error(actx, "could not update epoll set: %m");
+ actx_error_internal(actx, "could not update epoll set: %m");
}
return -1;
break;
default:
- actx_error(actx, "unknown libcurl socket operation: %d", what);
+ actx_error_internal(actx, "unknown libcurl socket operation: %d", what);
return -1;
}
res = kevent(actx->mux, ev, nev, ev_out, nev, &timeout);
if (res < 0)
{
- actx_error(actx, "could not modify kqueue: %m");
+ actx_error_internal(actx, "could not modify kqueue: %m");
return -1;
}
switch (what)
{
case CURL_POLL_REMOVE:
- actx_error(actx, "could not delete from kqueue: %m");
+ actx_error_internal(actx, "could not delete from kqueue: %m");
break;
default:
- actx_error(actx, "could not add to kqueue: %m");
+ actx_error_internal(actx, "could not add to kqueue: %m");
}
return -1;
}
*/
if (kevent(actx->mux, NULL, 0, &ev, 1, &timeout) < 0)
{
- actx_error(actx, "could not comb kqueue: %m");
+ actx_error_internal(actx, "could not comb kqueue: %m");
return false;
}
if (timerfd_settime(actx->timerfd, 0 /* no flags */ , &spec, NULL) < 0)
{
- actx_error(actx, "setting timerfd to %ld: %m", timeout);
+ actx_error_internal(actx, "setting timerfd to %ld: %m", timeout);
return false;
}
EV_SET(&ev, 1, EVFILT_TIMER, EV_DELETE, 0, 0, 0);
if (kevent(actx->timerfd, &ev, 1, NULL, 0, NULL) < 0 && errno != ENOENT)
{
- actx_error(actx, "deleting kqueue timer: %m");
+ actx_error_internal(actx, "deleting kqueue timer: %m");
return false;
}
EV_SET(&ev, actx->timerfd, EVFILT_READ, EV_DELETE, 0, 0, 0);
if (kevent(actx->mux, &ev, 1, NULL, 0, NULL) < 0 && errno != ENOENT)
{
- actx_error(actx, "removing kqueue timer from multiplexer: %m");
+ actx_error_internal(actx, "removing kqueue timer from multiplexer: %m");
return false;
}
EV_SET(&ev, 1, EVFILT_TIMER, (EV_ADD | EV_ONESHOT), 0, timeout, 0);
if (kevent(actx->timerfd, &ev, 1, NULL, 0, NULL) < 0)
{
- actx_error(actx, "setting kqueue timer to %ld: %m", timeout);
+ actx_error_internal(actx, "setting kqueue timer to %ld: %m", timeout);
return false;
}
EV_SET(&ev, actx->timerfd, EVFILT_READ, EV_ADD, 0, 0, 0);
if (kevent(actx->mux, &ev, 1, NULL, 0, NULL) < 0)
{
- actx_error(actx, "adding kqueue timer to multiplexer: %m");
+ actx_error_internal(actx, "adding kqueue timer to multiplexer: %m");
return false;
}