Added create-skill to the Scheme intepreter.
This commit is contained in:
parent
8dab8bfd06
commit
adc036a1ae
|
@ -3,9 +3,22 @@
|
||||||
#include <libguile.h>
|
#include <libguile.h>
|
||||||
#include "schemeintegration.h"
|
#include "schemeintegration.h"
|
||||||
|
|
||||||
|
SCM scheme_create_skill(SCM string, SCM skilllist)
|
||||||
|
{
|
||||||
|
size_t skillNameLength = 0;
|
||||||
|
char * skillName = scm_to_latin1_stringn(string, &skillNameLength);
|
||||||
|
createSkill(scm_to_pointer(skilllist), skillName, skillNameLength, false);
|
||||||
|
free(skillName);
|
||||||
|
return SCM_BOOL_T;
|
||||||
|
}
|
||||||
|
|
||||||
void * schemeHandler(void * parameters)
|
void * schemeHandler(void * parameters)
|
||||||
{
|
{
|
||||||
|
SchemeThreadParameters * schemeThreadParameters = parameters;
|
||||||
|
|
||||||
scm_init_guile();
|
scm_init_guile();
|
||||||
|
scm_c_define_gsubr("create-skill", 2, 0, 0, &scheme_create_skill);
|
||||||
|
scm_c_define("skill-list", scm_from_pointer(schemeThreadParameters->skillList, NULL));
|
||||||
scm_shell(0, NULL);
|
scm_shell(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,16 @@
|
||||||
// Barra Ó Catháin, 2023.
|
// Barra Ó Catháin, 2023.
|
||||||
#ifndef SCHEMEINTEGRATION_H
|
#ifndef SCHEMEINTEGRATION_H
|
||||||
#define SCHEMEINTEGRATION_H
|
#define SCHEMEINTEGRATION_H
|
||||||
|
#include "queue.h"
|
||||||
#include "linkedlist.h"
|
#include "linkedlist.h"
|
||||||
|
|
||||||
typedef struct list list;
|
typedef struct list list;
|
||||||
|
typedef struct queue queue;
|
||||||
|
|
||||||
typedef struct SchemeThreadParameters
|
typedef struct SchemeThreadParameters
|
||||||
{
|
{
|
||||||
list * areaList, * skillList;
|
list * areaList, * skillList;
|
||||||
|
queue * inputQueue, * outputQueue;
|
||||||
} SchemeThreadParameters;
|
} SchemeThreadParameters;
|
||||||
|
|
||||||
void * schemeHandler(void * parameters);
|
void * schemeHandler(void * parameters);
|
||||||
|
|
|
@ -226,11 +226,12 @@ int main(int argc, char ** argv)
|
||||||
pthread_create(&outputThread, NULL, &outputThreadHandler, outputParameters);
|
pthread_create(&outputThread, NULL, &outputThreadHandler, outputParameters);
|
||||||
slowPrint("\tOutput Thread is:\t\033[32;40mGREEN.\033[0m\n", delay);
|
slowPrint("\tOutput Thread is:\t\033[32;40mGREEN.\033[0m\n", delay);
|
||||||
|
|
||||||
|
SchemeThreadParameters * schemeParameters = malloc(sizeof(SchemeThreadParameters));
|
||||||
pthread_create(&schemeThread, NULL, &schemeHandler, NULL);
|
schemeParameters->skillList = globalSkillList;
|
||||||
slowPrint("\tScheme Thread is:\t\033[32;40mGREEN.\033[0m\n", delay);
|
slowPrint("\tScheme Thread is:\t\033[32;40mGREEN.\033[0m\n", delay);
|
||||||
|
|
||||||
slowPrint("=====\n", delay);
|
slowPrint("=====\n", delay);
|
||||||
|
pthread_create(&schemeThread, NULL, &schemeHandler, schemeParameters);
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
// Clear the set of file descriptors and add the master socket:
|
// Clear the set of file descriptors and add the master socket:
|
||||||
|
@ -280,7 +281,7 @@ int main(int argc, char ** argv)
|
||||||
if (clientSockets[index] == 0)
|
if (clientSockets[index] == 0)
|
||||||
{
|
{
|
||||||
clientSockets[index] = connectionFileDesc;
|
clientSockets[index] = connectionFileDesc;
|
||||||
printf("Adding to list of sockets as %d.\n", index);
|
//printf("Adding to list of sockets as %d.\n", index);
|
||||||
gnutls_transport_set_int(tlssessions[index], clientSockets[index]);
|
gnutls_transport_set_int(tlssessions[index], clientSockets[index]);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue