mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-30 11:39:14 -07:00
introduce PREFIX for pm3 system directory and move to common.h
This commit is contained in:
parent
ab38130c3e
commit
595b8a1885
4 changed files with 23 additions and 19 deletions
|
@ -90,15 +90,15 @@ static int CmdScriptList(const char *Cmd) {
|
|||
}
|
||||
char *userpath = getenv("HOME");
|
||||
if (userpath != NULL) {
|
||||
char script_directory_path[strlen(userpath) + strlen(LUA_PM3_USER_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + 1];
|
||||
char script_directory_path[strlen(userpath) + strlen(PM3_USER_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + 1];
|
||||
strcpy(script_directory_path, userpath);
|
||||
strcat(script_directory_path, LUA_PM3_USER_DIRECTORY);
|
||||
strcat(script_directory_path, PM3_USER_DIRECTORY);
|
||||
strcat(script_directory_path, LUA_SCRIPTS_DIRECTORY);
|
||||
scriptlist(script_directory_path);
|
||||
}
|
||||
{
|
||||
char script_directory_path[strlen(LUA_PM3_SYSTEM_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + 1];
|
||||
strcpy(script_directory_path, LUA_PM3_SYSTEM_DIRECTORY);
|
||||
char script_directory_path[strlen(PM3_SYSTEM_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + 1];
|
||||
strcpy(script_directory_path, PM3_SYSTEM_DIRECTORY);
|
||||
strcat(script_directory_path, LUA_SCRIPTS_DIRECTORY);
|
||||
scriptlist(script_directory_path);
|
||||
}
|
||||
|
@ -161,9 +161,9 @@ static int CmdScriptRun(const char *Cmd) {
|
|||
}
|
||||
char *userpath = getenv("HOME");
|
||||
if ((!found) && (userpath != NULL)) {
|
||||
char script_path[strlen(userpath) + strlen(LUA_PM3_USER_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(script_name) + strlen(suffix) + 1];
|
||||
char script_path[strlen(userpath) + strlen(PM3_USER_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(script_name) + strlen(suffix) + 1];
|
||||
strcpy(script_path, userpath);
|
||||
strcat(script_path, LUA_PM3_USER_DIRECTORY);
|
||||
strcat(script_path, PM3_USER_DIRECTORY);
|
||||
strcat(script_path, LUA_SCRIPTS_DIRECTORY);
|
||||
strcat(script_path, script_name);
|
||||
strcat(script_path, suffix);
|
||||
|
@ -177,8 +177,8 @@ static int CmdScriptRun(const char *Cmd) {
|
|||
}
|
||||
}
|
||||
if (!found) {
|
||||
char script_path[strlen(LUA_PM3_SYSTEM_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(script_name) + strlen(suffix) + 1];
|
||||
strcpy(script_path, LUA_PM3_SYSTEM_DIRECTORY);
|
||||
char script_path[strlen(PM3_SYSTEM_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(script_name) + strlen(suffix) + 1];
|
||||
strcpy(script_path, PM3_SYSTEM_DIRECTORY);
|
||||
strcat(script_path, LUA_SCRIPTS_DIRECTORY);
|
||||
strcat(script_path, script_name);
|
||||
strcat(script_path, suffix);
|
||||
|
|
|
@ -1151,32 +1151,32 @@ int set_pm3_libraries(lua_State *L) {
|
|||
char *user_path = getenv("HOME");
|
||||
if (user_path != NULL) {
|
||||
// from the ~/.proxmark3/luascripts/ directory
|
||||
char scripts_path[strlen(user_path) + strlen(LUA_PM3_USER_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
char scripts_path[strlen(user_path) + strlen(PM3_USER_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(scripts_path, user_path);
|
||||
strcat(scripts_path, LUA_PM3_USER_DIRECTORY);
|
||||
strcat(scripts_path, PM3_USER_DIRECTORY);
|
||||
strcat(scripts_path, LUA_SCRIPTS_DIRECTORY);
|
||||
strcat(scripts_path, LUA_LIBRARIES_WILDCARD);
|
||||
setLuaPath(L, scripts_path);
|
||||
|
||||
// from the ~/.proxmark3/lualib/ directory
|
||||
char libraries_path[strlen(user_path) + strlen(LUA_PM3_USER_DIRECTORY) + strlen(LUA_LIBRARIES_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
char libraries_path[strlen(user_path) + strlen(PM3_USER_DIRECTORY) + strlen(LUA_LIBRARIES_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(libraries_path, user_path);
|
||||
strcat(libraries_path, LUA_PM3_USER_DIRECTORY);
|
||||
strcat(libraries_path, PM3_USER_DIRECTORY);
|
||||
strcat(libraries_path, LUA_LIBRARIES_DIRECTORY);
|
||||
strcat(libraries_path, LUA_LIBRARIES_WILDCARD);
|
||||
setLuaPath(L, libraries_path);
|
||||
}
|
||||
|
||||
if (strlen(LUA_PM3_SYSTEM_DIRECTORY) != 0 || strlen(LUA_SCRIPTS_DIRECTORY) != 0 || strlen(LUA_LIBRARIES_WILDCARD) != 0 ) {
|
||||
if (strlen(PM3_SYSTEM_DIRECTORY) != 0 || strlen(LUA_SCRIPTS_DIRECTORY) != 0 || strlen(LUA_LIBRARIES_WILDCARD) != 0 ) {
|
||||
// from the /usr/local/share/proxmark3/luascripts/ directory
|
||||
char scripts_path[strlen(LUA_PM3_SYSTEM_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(scripts_path, LUA_PM3_SYSTEM_DIRECTORY);
|
||||
char scripts_path[strlen(PM3_SYSTEM_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(scripts_path, PM3_SYSTEM_DIRECTORY);
|
||||
strcat(scripts_path, LUA_SCRIPTS_DIRECTORY);
|
||||
strcat(scripts_path, LUA_LIBRARIES_WILDCARD);
|
||||
setLuaPath(L, scripts_path);
|
||||
// from the /usr/local/share/proxmark3/lualib/ directory
|
||||
char libraries_path[strlen(LUA_PM3_SYSTEM_DIRECTORY) + strlen(LUA_LIBRARIES_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(libraries_path, LUA_PM3_SYSTEM_DIRECTORY);
|
||||
char libraries_path[strlen(PM3_SYSTEM_DIRECTORY) + strlen(LUA_LIBRARIES_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(libraries_path, PM3_SYSTEM_DIRECTORY);
|
||||
strcat(libraries_path, LUA_LIBRARIES_DIRECTORY);
|
||||
strcat(libraries_path, LUA_LIBRARIES_WILDCARD);
|
||||
setLuaPath(L, libraries_path);
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
//#include <lualib.h>
|
||||
//#include <lauxlib.h>
|
||||
|
||||
#define LUA_PM3_SYSTEM_DIRECTORY "/usr/local/share/proxmark3/"
|
||||
#define LUA_PM3_USER_DIRECTORY "/.proxmark3/"
|
||||
#define LUA_LIBRARIES_DIRECTORY "lualibs/"
|
||||
#define LUA_SCRIPTS_DIRECTORY "luascripts/"
|
||||
#define LUA_LIBRARIES_WILDCARD "?.lua"
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef PREFIX
|
||||
# define PREFIX "/usr/local/"
|
||||
#endif
|
||||
#define PM3_SYSTEM_DIRECTORY PREFIX "share/proxmark3/"
|
||||
#define PM3_USER_DIRECTORY "/.proxmark3/"
|
||||
|
||||
#define PACKED __attribute__((packed))
|
||||
|
||||
// debug
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue