aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins.c
blob: f2f8d145bd9cea4546fdf5a91023eb9723fbaa28 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "plugins.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

#include <sys/types.h>
#include <dirent.h>

struct ptx__plugin_manager_tag
{
  size_t sz_plugins;
  ptx_plugin_t *plugins;
};

struct ptx__plugin_handle_tag
{
  char *path;
};

ptx_plugin_manager_t *ptx_plugin_manager_new(void)
{
  ptx_plugin_manager_t *mgr = malloc(sizeof(ptx_plugin_manager_t));
  if (!mgr) return NULL;

  /* do init */
  mgr->sz_plugins = 0;
  mgr->plugins = NULL;

  return mgr;
}

void ptx_plugin_manager_free(ptx_plugin_manager_t *mgr)
{
  if (!mgr) return;

  /* do cleanup */

  free(mgr);
  return;
}

int ptx_plugin_manager_load_dir(ptx_plugin_manager_t *mgr, const char *dirnam)
{
  struct dirent *ent;
  DIR *dir = opendir(dirnam);

  if (!dir) {
    fprintf(stderr, "Failed to load plugins from %s (opendir): %s\n", dirnam, strerror(errno));
    return -1;
  }

  while ((errno = 0, ent = readdir(dir))) {
    
  }

  if (errno != 0) {
    fprintf(stderr, "Error reading entries from %s (readdir): %s\n", dirnam, strerror(errno));
    return -1;
  }

  return 0;
}