Commit 40317df3 authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Rename API to PluginAPI

parent 872ee776
...@@ -37,7 +37,7 @@ BatteryMeter.c Process.c ProcessList.c RichString.c ScreenManager.c Settings.c \ ...@@ -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 \ SignalsPanel.c StringUtils.c SwapMeter.c TasksMeter.c UptimeMeter.c ScreensPanel.c \
TraceScreen.c UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c \ TraceScreen.c UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c \
HostnameMeter.c OpenFilesScreen.c Affinity.c IncSet.c Action.c EnvScreen.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 \ myhtopheaders = AvailableColumnsPanel.h AvailableMetersPanel.h \
CategoriesPanel.h CheckItem.h ClockMeter.h ColorsPanel.h ColumnsPanel.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 ...@@ -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 \ ScreenManager.h Settings.h SignalsPanel.h StringUtils.h SwapMeter.h ScreensPanel.h \
TasksMeter.h UptimeMeter.h TraceScreen.h UsersTable.h Vector.h Process.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 \ 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 if HTOP_LINUX
htop_CFLAGS += -rdynamic htop_CFLAGS += -rdynamic
......
#include "config.h" #include "config.h"
#include "API.h" #include "PluginAPI.h"
#include "Process.h" #include "Process.h"
#ifdef HAVE_LUA #ifdef HAVE_LUA
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
}*/ }*/
int API_newColumn(lua_State* L) { int PluginAPI_newColumn(lua_State* L) {
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
check_field("name", LUA_TSTRING, "expected 'name' field of type string"); check_field("name", LUA_TSTRING, "expected 'name' field of type string");
...@@ -58,19 +58,19 @@ int API_newColumn(lua_State* L) { ...@@ -58,19 +58,19 @@ int API_newColumn(lua_State* L) {
return 1; return 1;
} }
static luaL_Reg API_functions[] = { static luaL_Reg PluginAPI_functions[] = {
{ .name = "new_column", .func = API_newColumn }, { .name = "new_column", .func = PluginAPI_newColumn },
{ .name = NULL, .func = NULL }, { .name = NULL, .func = NULL },
}; };
int API_new(lua_State* L) { int PluginAPI_new(lua_State* L) {
lua_settop(L, 0); lua_settop(L, 0);
lua_newtable(L); lua_newtable(L);
lua_setfield(L, LUA_REGISTRYINDEX, "htop_columns"); lua_setfield(L, LUA_REGISTRYINDEX, "htop_columns");
lua_newtable(L); lua_newtable(L);
luaL_setfuncs(L, API_functions, 0); luaL_setfuncs(L, PluginAPI_functions, 0);
return 1; return 1;
} }
......
/* Do not edit this file. It was automatically generated. */ /* Do not edit this file. It was automatically generated. */
#ifndef HEADER_API #ifndef HEADER_PluginAPI
#define HEADER_API #define HEADER_PluginAPI
#ifdef HAVE_LUA #ifdef HAVE_LUA
...@@ -30,9 +30,9 @@ ...@@ -30,9 +30,9 @@
} while(0) } 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 #endif
......
...@@ -10,7 +10,7 @@ in the source distribution for its full text. ...@@ -10,7 +10,7 @@ in the source distribution for its full text.
#include "CRT.h" #include "CRT.h"
#include "StringUtils.h" #include "StringUtils.h"
#include "API.h" #include "PluginAPI.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -87,10 +87,6 @@ ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidWhiteList, uid_t user ...@@ -87,10 +87,6 @@ ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidWhiteList, uid_t user
void ProcessList_delete(ProcessList* pl); void ProcessList_delete(ProcessList* pl);
void ProcessList_goThroughEntries(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) { ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
...@@ -138,12 +134,12 @@ void ProcessList_done(ProcessList* this) { ...@@ -138,12 +134,12 @@ void ProcessList_done(ProcessList* this) {
#ifdef HAVE_LUA #ifdef HAVE_LUA
void ProcessList_initScripting(ProcessList* this) { void ProcessList_initPlugins(ProcessList* this) {
lua_State* L = luaL_newstate(); lua_State* L = luaL_newstate();
luaL_openlibs(L); luaL_openlibs(L);
this->L = L; this->L = L;
luaL_requiref(L, "htop", API_new, 0); luaL_requiref(L, "htop", PluginAPI_new, 0);
lua_pop(L, 1); lua_pop(L, 1);
for (int i = 0; i < this->settings->nPlugins; i++) { for (int i = 0; i < this->settings->nPlugins; i++) {
char* plugin = this->settings->plugins[i]; char* plugin = this->settings->plugins[i];
......
...@@ -80,10 +80,6 @@ ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidWhiteList, uid_t user ...@@ -80,10 +80,6 @@ ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidWhiteList, uid_t user
void ProcessList_delete(ProcessList* pl); void ProcessList_delete(ProcessList* pl);
void ProcessList_goThroughEntries(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); ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
...@@ -91,7 +87,7 @@ void ProcessList_done(ProcessList* this); ...@@ -91,7 +87,7 @@ void ProcessList_done(ProcessList* this);
#ifdef HAVE_LUA #ifdef HAVE_LUA
void ProcessList_initScripting(ProcessList* this); void ProcessList_initPlugins(ProcessList* this);
#endif #endif
void ProcessList_setPanel(ProcessList* this, Panel* panel); void ProcessList_setPanel(ProcessList* this, Panel* panel);
......
...@@ -196,7 +196,7 @@ int main(int argc, char** argv) { ...@@ -196,7 +196,7 @@ int main(int argc, char** argv) {
pl->settings = settings; pl->settings = settings;
#ifdef HAVE_LUA #ifdef HAVE_LUA
ProcessList_initScripting(pl); ProcessList_initPlugins(pl);
settings->L = pl->L; settings->L = pl->L;
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment