1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00

Add quick'n dirty abi check.

This commit is contained in:
Dave Davenport 2017-02-14 18:12:07 +01:00
parent fb05409365
commit 9bd4096346
2 changed files with 19 additions and 4 deletions

View file

@ -1,6 +1,8 @@
#ifndef ROFI_MODE_PRIVATE_H #ifndef ROFI_MODE_PRIVATE_H
#define ROFI_MODE_PRIVATE_H #define ROFI_MODE_PRIVATE_H
#define ABI_VERSION 0x00000001
/** /**
* @param data Pointer to #Mode object. * @param data Pointer to #Mode object.
* *
@ -98,6 +100,8 @@ typedef char* ( *_mode_preprocess_input )( Mode *sw, const char *input );
*/ */
struct rofi_mode struct rofi_mode
{ {
/** Used for external plugins. */
unsigned int abi_version;
/** Name (max 31 char long) */ /** Name (max 31 char long) */
char name[32]; char name[32];
char cfg_name_key[128]; char cfg_name_key[128];

View file

@ -48,6 +48,7 @@
#include <libgwater-xcb.h> #include <libgwater-xcb.h>
#include "xcb-internal.h" #include "xcb-internal.h"
#include "xkb-internal.h" #include "xkb-internal.h"
@ -69,6 +70,10 @@
#include "timings.h" #include "timings.h"
// Plugin abi version.
// TODO: move this check to mode.c
#include "mode-private.h"
// Pidfile. // Pidfile.
char *pidfile = NULL; char *pidfile = NULL;
const char *cache_dir = NULL; const char *cache_dir = NULL;
@ -450,10 +455,16 @@ static int add_mode ( const char * token )
// Load module. // Load module.
GModule *mod = g_module_open ( token, G_MODULE_BIND_LAZY|G_MODULE_BIND_LOCAL ); GModule *mod = g_module_open ( token, G_MODULE_BIND_LAZY|G_MODULE_BIND_LOCAL );
if ( mod ) { if ( mod ) {
gpointer m = NULL; Mode *m = NULL;
if ( g_module_symbol ( mod, "mode", &m) ){ if ( g_module_symbol ( mod, "mode", (gpointer *)&m) ){
modi[num_modi] = m; // Simple abi check.
num_modi++; if ( m->abi_version != ABI_VERSION ){
fprintf(stderr, "ABI version of plugin does not match: %08X expecting: %08X\n", m->abi_version, ABI_VERSION);
g_module_close ( mod );
} else {
modi[num_modi] = m;
num_modi++;
}
} else { } else {
fprintf(stderr, "Symbol 'mode' not found in module: %s\n", token); fprintf(stderr, "Symbol 'mode' not found in module: %s\n", token);
g_module_close ( mod ); g_module_close ( mod );