static int push_file_error(lua_State *L, lua_apr_file *file, apr_status_t status) { char message[LUA_APR_MSGSIZE]; apr_strerror(status, message, count(message)); lua_pushnil(L); if (file->path != NULL) lua_pushfstring(L, "%s: %s", file->path, message); else lua_pushstring(L, message); status_to_name(L, status); return 3; }
static gchar * search_icon_path (CutTestResultStatus status, gboolean success) { GList *candiate_icon_names = NULL, *node; const gchar *icons_dir = NULL; const gchar *icon_theme = "kinotan"; gchar *icon_path = NULL; candiate_icon_names = g_list_append(candiate_icon_names, (gchar *)status_to_name(status)); if (success) { candiate_icon_names = g_list_append(candiate_icon_names, "pass"); } else { switch (status) { case CUT_TEST_RESULT_FAILURE: candiate_icon_names = g_list_append(candiate_icon_names, "error"); break; case CUT_TEST_RESULT_ERROR: candiate_icon_names = g_list_append(candiate_icon_names, "failure"); break; default: break; } } candiate_icon_names = g_list_append(candiate_icon_names, "default"); icons_dir = g_getenv("CUT_ICONS_DIR"); if (!icons_dir) { #ifdef G_OS_WIN32 icons_dir = cut_win32_icons_dir(); #else icons_dir = ICONS_DIR; #endif } for (node = candiate_icon_names; node; node = g_list_next(node)) { const gchar *icon_name = node->data; gchar *icon_base_path; icon_base_path = g_strdup_printf("%s.png", icon_name); icon_path = g_build_filename(icons_dir, icon_theme, icon_base_path, NULL); g_free(icon_base_path); if (g_file_test(icon_path, G_FILE_TEST_IS_REGULAR)) { break; } else { g_free(icon_path); icon_path = NULL; } } return icon_path; }
static int push_ldap_error(lua_State *L, apr_status_t status, apr_ldap_err_t *error) { if (error == NULL) return push_error_status(L, status); lua_pushnil(L); if (error->reason != NULL && error->msg != NULL) { /* "reason" is from APR and "msg" is from the LDAP SDK. */ lua_pushfstring(L, "%s (%s)", error->reason, error->msg); lua_pushinteger(L, error->rc); } else if (error->reason != NULL) { /* Some APR functions fill in "reason" but not "msg". */ lua_pushstring(L, error->reason); lua_pushinteger(L, error->rc); } else { /* Not sure this is needed. */ status_to_message(L, status); status_to_name(L, status); } return 3; }