aboutsummaryrefslogtreecommitdiff
path: root/src/set_install_directories.cc
blob: 9163480ed6e3a9e32ba95f8d0341f4c968171042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include "lua_state.hh"
#include "set_install_directories.hh"
#include "vars.hh"

void set_install_directories() {
  init_lua_state();
  lua_State *L = get_lua_state();

  lua_getglobal(L, "install_directories");

  if (!lua_istable(L, -1)) {
    std::cout << print_error << "lua variable 'install_directories' is not a table.\n";
  }

  lua_pushnil(L);

  while (lua_next(L, -2) != 0) {
    const char *key = lua_tostring(L, -2);
    const char *value = lua_tostring(L, -1);

    install_directories[key] = value;

    lua_pop(L, 1);
  }
}