Added a message-everyone scheme function.
This commit is contained in:
parent
adc036a1ae
commit
6b01917c11
|
@ -12,13 +12,33 @@ SCM scheme_create_skill(SCM string, SCM skilllist)
|
|||
return SCM_BOOL_T;
|
||||
}
|
||||
|
||||
SCM scheme_message_everyone(SCM sendername, SCM messagecontent, SCM outputqueue)
|
||||
{
|
||||
outputMessage * newOutputMessage = calloc(1, sizeof(userMessage));
|
||||
userMessage * newMessage = calloc(1, sizeof(userMessage));
|
||||
newOutputMessage->content = newMessage;
|
||||
newOutputMessage->recipientsCount = 0;
|
||||
newOutputMessage->recipients = NULL;
|
||||
|
||||
scm_to_locale_stringbuf(sendername, newMessage->senderName, 31);
|
||||
newMessage->senderName[31] = '\0';
|
||||
scm_to_locale_stringbuf(messagecontent, newMessage->messageContent, MAX - 1);
|
||||
newMessage->messageContent[MAX - 1] = '\0';
|
||||
|
||||
userNameSanatize(newMessage->senderName, 32);
|
||||
userInputSanatize(newMessage->messageContent, MAX);
|
||||
pushQueue(scm_to_pointer(outputqueue), newOutputMessage, OUTPUT_MESSAGE);
|
||||
return SCM_BOOL_T;
|
||||
}
|
||||
void * schemeHandler(void * parameters)
|
||||
{
|
||||
SchemeThreadParameters * schemeThreadParameters = parameters;
|
||||
|
||||
scm_init_guile();
|
||||
scm_c_define_gsubr("create-skill", 2, 0, 0, &scheme_create_skill);
|
||||
scm_c_define_gsubr("message-everyone", 3, 0, 0, &scheme_message_everyone);
|
||||
scm_c_define("skill-list", scm_from_pointer(schemeThreadParameters->skillList, NULL));
|
||||
scm_c_define("output-queue", scm_from_pointer(schemeThreadParameters->outputQueue, NULL));
|
||||
scm_shell(0, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -228,6 +228,7 @@ int main(int argc, char ** argv)
|
|||
|
||||
SchemeThreadParameters * schemeParameters = malloc(sizeof(SchemeThreadParameters));
|
||||
schemeParameters->skillList = globalSkillList;
|
||||
schemeParameters->outputQueue = outputQueue;
|
||||
slowPrint("\tScheme Thread is:\t\033[32;40mGREEN.\033[0m\n", delay);
|
||||
slowPrint("=====\n", delay);
|
||||
pthread_create(&schemeThread, NULL, &schemeHandler, schemeParameters);
|
||||
|
|
Loading…
Reference in New Issue