From 40317df3848735b25774570b8fb6b93f12ddc561 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sun, 28 Jan 2018 17:51:49 -0200 Subject: [PATCH] Rename API to PluginAPI --- Makefile.am | 4 ++-- API.c => PluginAPI.c | 12 ++++++------ API.h => PluginAPI.h | 8 ++++---- ProcessList.c | 10 +++------- ProcessList.h | 6 +----- htop.c | 2 +- 6 files changed, 17 insertions(+), 25 deletions(-) rename API.c => PluginAPI.c (89%) rename API.h => PluginAPI.h (87%) diff --git a/Makefile.am b/Makefile.am index 69f7f03..fca5092 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,7 +37,7 @@ BatteryMeter.c Process.c ProcessList.c RichString.c ScreenManager.c Settings.c \ SignalsPanel.c StringUtils.c SwapMeter.c TasksMeter.c UptimeMeter.c ScreensPanel.c \ TraceScreen.c UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c \ HostnameMeter.c OpenFilesScreen.c Affinity.c IncSet.c Action.c EnvScreen.c \ -InfoScreen.c XAlloc.c API.c +InfoScreen.c XAlloc.c PluginAPI.c myhtopheaders = AvailableColumnsPanel.h AvailableMetersPanel.h \ CategoriesPanel.h CheckItem.h ClockMeter.h ColorsPanel.h ColumnsPanel.h \ @@ -47,7 +47,7 @@ BatteryMeter.h Meter.h MetersPanel.h Object.h Panel.h ProcessList.h RichString.h ScreenManager.h Settings.h SignalsPanel.h StringUtils.h SwapMeter.h ScreensPanel.h \ TasksMeter.h UptimeMeter.h TraceScreen.h UsersTable.h Vector.h Process.h \ AffinityPanel.h HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h \ -EnvScreen.h InfoScreen.h XAlloc.h API.h +EnvScreen.h InfoScreen.h XAlloc.h PluginAPI.h if HTOP_LINUX htop_CFLAGS += -rdynamic diff --git a/API.c b/PluginAPI.c similarity index 89% rename from API.c rename to PluginAPI.c index 8eecbf4..c1e9c1a 100644 --- a/API.c +++ b/PluginAPI.c @@ -1,6 +1,6 @@ #include "config.h" -#include "API.h" +#include "PluginAPI.h" #include "Process.h" #ifdef HAVE_LUA @@ -32,7 +32,7 @@ }*/ -int API_newColumn(lua_State* L) { +int PluginAPI_newColumn(lua_State* L) { luaL_checktype(L, 1, LUA_TTABLE); check_field("name", LUA_TSTRING, "expected 'name' field of type string"); @@ -58,19 +58,19 @@ int API_newColumn(lua_State* L) { return 1; } -static luaL_Reg API_functions[] = { - { .name = "new_column", .func = API_newColumn }, +static luaL_Reg PluginAPI_functions[] = { + { .name = "new_column", .func = PluginAPI_newColumn }, { .name = NULL, .func = NULL }, }; -int API_new(lua_State* L) { +int PluginAPI_new(lua_State* L) { lua_settop(L, 0); lua_newtable(L); lua_setfield(L, LUA_REGISTRYINDEX, "htop_columns"); lua_newtable(L); - luaL_setfuncs(L, API_functions, 0); + luaL_setfuncs(L, PluginAPI_functions, 0); return 1; } diff --git a/API.h b/PluginAPI.h similarity index 87% rename from API.h rename to PluginAPI.h index 5efd171..e5ff653 100644 --- a/API.h +++ b/PluginAPI.h @@ -1,7 +1,7 @@ /* Do not edit this file. It was automatically generated. */ -#ifndef HEADER_API -#define HEADER_API +#ifndef HEADER_PluginAPI +#define HEADER_PluginAPI #ifdef HAVE_LUA @@ -30,9 +30,9 @@ } while(0) -int API_newColumn(lua_State* L); +int PluginAPI_newColumn(lua_State* L); -int API_new(lua_State* L); +int PluginAPI_new(lua_State* L); #endif diff --git a/ProcessList.c b/ProcessList.c index 6dc47ad..5eda84f 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -10,7 +10,7 @@ in the source distribution for its full text. #include "CRT.h" #include "StringUtils.h" -#include "API.h" +#include "PluginAPI.h" #include #include @@ -87,10 +87,6 @@ ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidWhiteList, uid_t user void ProcessList_delete(ProcessList* pl); void ProcessList_goThroughEntries(ProcessList* pl); -#ifdef HAVE_LUA -void ProcessList_enableScripting(ProcessList* pl, lua_State* L); -#endif - }*/ ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { @@ -138,12 +134,12 @@ void ProcessList_done(ProcessList* this) { #ifdef HAVE_LUA -void ProcessList_initScripting(ProcessList* this) { +void ProcessList_initPlugins(ProcessList* this) { lua_State* L = luaL_newstate(); luaL_openlibs(L); this->L = L; - luaL_requiref(L, "htop", API_new, 0); + luaL_requiref(L, "htop", PluginAPI_new, 0); lua_pop(L, 1); for (int i = 0; i < this->settings->nPlugins; i++) { char* plugin = this->settings->plugins[i]; diff --git a/ProcessList.h b/ProcessList.h index 4014b0c..223dce7 100644 --- a/ProcessList.h +++ b/ProcessList.h @@ -80,10 +80,6 @@ ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidWhiteList, uid_t user void ProcessList_delete(ProcessList* pl); void ProcessList_goThroughEntries(ProcessList* pl); -#ifdef HAVE_LUA -void ProcessList_enableScripting(ProcessList* pl, lua_State* L); -#endif - ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId); @@ -91,7 +87,7 @@ void ProcessList_done(ProcessList* this); #ifdef HAVE_LUA -void ProcessList_initScripting(ProcessList* this); +void ProcessList_initPlugins(ProcessList* this); #endif void ProcessList_setPanel(ProcessList* this, Panel* panel); diff --git a/htop.c b/htop.c index 1564d45..22d7fb6 100644 --- a/htop.c +++ b/htop.c @@ -196,7 +196,7 @@ int main(int argc, char** argv) { pl->settings = settings; #ifdef HAVE_LUA - ProcessList_initScripting(pl); + ProcessList_initPlugins(pl); settings->L = pl->L; #endif -- GitLab