#include "daemon/worker.h"
#include "daemon/zimport.h"
-#include <unistd.h>
-
/** @internal return cache, or throw lua error if not open */
struct kr_cache * cache_assert_open(lua_State *L)
{
int ret = kr_cache_open(&engine->resolver.cache, api, &opts, engine->pool);
if (ret != 0) {
char cwd[PATH_MAX];
- if(getcwd(cwd, sizeof(cwd)) == NULL) {
- const char errprefix[] = "<invalid working directory>";
- strncpy(cwd, errprefix, sizeof(cwd));
- }
+ get_workdir(cwd, sizeof(cwd));
return luaL_error(L, "can't open cache path '%s'; working directory '%s'", opts.path, cwd);
}
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
+#include <unistd.h>
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
return res.tv_sec * 1000 + res.tv_usec / 1000;
}
+/** Get current working directory with fallback value. */
+static inline void get_workdir(char *out, size_t len) {
+ if(getcwd(out, len) == NULL) {
+ static const char errprefix[] = "<invalid working directory>";
+ strncpy(out, errprefix, len);
+ }
+}
+
/** @cond internal Array types */
struct kr_context;