summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/strftime.c
diff options
context:
space:
mode:
authorThomas Jarosch <tomj@simonv.com>2012-01-03 22:33:47 +0000
committerThomas Jarosch <tomj@simonv.com>2012-01-03 22:33:47 +0000
commit949e6398c89e3c277a4c542f67a5ee788c6f642d (patch)
tree4929442f838dacf82e8bdbd1a3d36bf38a363d88 /apps/plugins/lua/strftime.c
parentf36f7825d7d219304fac22021b9f060a666ddc3b (diff)
downloadrockbox-949e6398c89e3c277a4c542f67a5ee788c6f642d.zip
rockbox-949e6398c89e3c277a4c542f67a5ee788c6f642d.tar.gz
rockbox-949e6398c89e3c277a4c542f67a5ee788c6f642d.tar.bz2
rockbox-949e6398c89e3c277a4c542f67a5ee788c6f642d.tar.xz
FS #11859: Enable optimizations for SDL application builds.
Only disable them for the simulator (like before). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31547 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lua/strftime.c')
0 files changed, 0 insertions, 0 deletions
d='n125' href='#n125'>125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
/*
** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $
** Standard Operating System library
** See Copyright Notice in lua.h
*/


#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#define loslib_c
#define LUA_LIB

#include "lua.h"

#include "lauxlib.h"
#include "lualib.h"


static int os_pushresult (lua_State *L, int i, const char *filename) {
  int en = errno;  /* calls to Lua API may change this value */
  if (i) {
    lua_pushboolean(L, 1);
    return 1;
  }
  else {
    lua_pushnil(L);
    lua_pushfstring(L, "%s: %s", filename, strerror(en));
    lua_pushinteger(L, en);
    return 3;
  }
}


static int os_remove (lua_State *L) {
  const char *filename = luaL_checkstring(L, 1);
  return os_pushresult(L, rb->remove(filename) == 0, filename);
}


static int os_rename (lua_State *L) {
  const char *fromname = luaL_checkstring(L, 1);
  const char *toname = luaL_checkstring(L, 2);
  return os_pushresult(L, rb->rename(fromname, toname) == 0, fromname);
}


/*
** {======================================================
** Time/Date operations
** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S,
**   wday=%w+1, yday=%j, isdst=? }
** =======================================================
*/

static void setfield (lua_State *L, const char *key, int value) {
  lua_pushinteger(L, value);
  lua_setfield(L, -2, key);
}

static void setboolfield (lua_State *L, const char *key, int value) {
  if (value < 0)  /* undefined? */
    return;  /* does not set field */
  lua_pushboolean(L, value);
  lua_setfield(L, -2, key);
}

#if CONFIG_RTC
static int getboolfield (lua_State *L, const char *key) {
  int res;
  lua_getfield(L, -1, key);
  res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1);
  lua_pop(L, 1);
  return res;
}


static int getfield (lua_State *L, const char *key, int d) {
  int res;
  lua_getfield(L, -1, key);