From e946be71d1777715fc3df6b80615d41fa1c97df2 Mon Sep 17 00:00:00 2001 From: Gabor de Mooij Date: Sat, 4 Aug 2018 01:44:09 +0200 Subject: [PATCH] Check language mismatch. --- citrine.h | 4 ++++ plugins/request/request.c | 1 + util.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/citrine.h b/citrine.h index fabde8fac..8bb42bd5a 100644 --- a/citrine.h +++ b/citrine.h @@ -1,8 +1,10 @@ #ifdef langNL #include "i18n/nl/dictionarynl.h" +#include "i18n/nl/msgnl.h" #else #include "dictionary.h" +#include "i18n/en_us/msg.h" #endif #include @@ -727,3 +729,5 @@ extern void ctr_clex_move_code_pointer(int movement); extern int ctr_clex_forward_scan( char* codePointer, char* bytes, ctr_size* newCodePointer ); extern int ctr_clex_backward_scan( char* codePointer, char* bytes, ctr_size* newCodePointer, ctr_size limit ); extern void ctr_print_error(char* error, int code); + +extern void ctr_plugin_check_language( char* code ); diff --git a/plugins/request/request.c b/plugins/request/request.c index df731813e..78a1fb834 100644 --- a/plugins/request/request.c +++ b/plugins/request/request.c @@ -317,6 +317,7 @@ ctr_object* ctr_request_serve(ctr_object* myself, ctr_argument* argumentList) { * Adds the Request object to the World. */ void begin(){ + ctr_plugin_check_language( CTR_MSG_LANG_CODE ); ctr_object* requestObject = ctr_internal_create_object(CTR_OBJECT_TYPE_OTOBJECT); requestObject->link = CtrStdObject; ctr_internal_create_func(requestObject, ctr_build_string_from_cstring( CTR_DICT_HTTP_REQUEST_GET_SET ), &ctr_request_get_string ); diff --git a/util.c b/util.c index cc71d13e3..77e887b87 100644 --- a/util.c +++ b/util.c @@ -166,6 +166,22 @@ ctr_object* ctr_error_text( char* message ) { return CtrStdFlow; } +/** + * @internal + * + * Checks the language of the build with the language + * of the plugin. + */ +void ctr_plugin_check_language( char* code ) { + int l = strlen(code); + if ( l == strlen(CTR_MSG_LANG_CODE) ) { + if ( strncmp( code, CTR_MSG_LANG_CODE, l ) == 0 ) { + return; + } + } + ctr_print_error("Language mismatch.", 1); +} + /** * @internal *