summaryrefslogtreecommitdiffstats
path: root/src/uis.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/uis.c')
-rw-r--r--src/uis.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/uis.c b/src/uis.c
index 51ea512..a2a4946 100644
--- a/src/uis.c
+++ b/src/uis.c
@@ -15,4 +15,49 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define _XOPEN_SOURCE 500
+
+#include <string.h>
+
#include "suil_internal.h"
+
+SUIL_API
+SuilUIs
+suil_uis_new(const char* plugin_uri)
+{
+ SuilUIs uis = (SuilUIs)malloc(sizeof(struct _SuilUIs));
+ uis->plugin_uri = strdup(plugin_uri);
+ uis->uis = malloc(sizeof(SuilUI));
+ uis->uis[0] = (SuilUI)NULL;
+ uis->n_uis = 0;
+ return uis;
+}
+
+SUIL_API
+void
+suil_uis_free(SuilUIs uis)
+{
+ free(uis->plugin_uri);
+ free(uis);
+}
+
+SUIL_API
+void
+suil_uis_add(SuilUIs uis,
+ const char* uri,
+ const char* type_uri,
+ const char* bundle_path,
+ const char* binary_path)
+{
+ SuilUI ui = (SuilUI)malloc(sizeof(struct _SuilUI));
+ ui->uri = strdup(uri);
+ ui->type_uri = strdup(type_uri);
+ ui->bundle_path = strdup(bundle_path);
+ ui->binary_path = strdup(binary_path);
+
+ ++uis->n_uis;
+ uis->uis = realloc(uis->uis, sizeof(SuilUI) * (uis->n_uis + 1));
+ assert(uis->uis[uis->n_uis - 1] == NULL);
+ uis->uis[uis->n_uis - 1] = ui;
+ uis->uis[uis->n_uis] = NULL;
+}