1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 Dan Everton (safetydan)
11 * String function implementations taken from dietlibc 0.31 (GPLv2 License)
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
24 #define _ROCKCONF_H_ /* Protect against unwanted include */
27 #if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
31 char *strerror(int errnum
)
35 DEBUGF("strerror(%d)\n", errnum
);
40 long rb_pow(long x
, long n
)
51 return x
!= 0 ? 1/x
: 0;
71 int strcoll(const char * str1
, const char * str2
)
73 return rb
->strcmp(str1
, str2
);
76 const char* get_current_path(lua_State
*L
, int level
)
78 static char buffer
[MAX_PATH
];
81 if(lua_getstack(L
, level
, &ar
))
83 /* Try determining the base path of the current Lua chunk
84 and write it to dest. */
85 lua_getinfo(L
, "S", &ar
);
87 char* curfile
= (char*) &ar
.source
[1];
88 char* pos
= rb
->strrchr(curfile
, '/');
91 unsigned int len
= (unsigned int)(pos
- curfile
);
92 len
= len
+ 1 > sizeof(buffer
) ? sizeof(buffer
) - 1 : len
;
95 memcpy(buffer
, curfile
, len
);