-int url_add(const char * link_name, int link_name_length, const char * target, int target_length, int x, int y) {
- if (!init_ok) return -1;
-
- Url_t *tmp = NULL;
- int i = 0;
-
- if (list) {
- tmp = list;
- while (tmp->next) {
- tmp = tmp->next;
- i++;
- }
- tmp->next = malloc(sizeof(Url_t));
- assert(tmp->next);
- tmp = tmp->next;
- } else {
- list = malloc(sizeof(Url_t));
- tmp = list;
- assert(tmp);
- }
-
- tmp -> link_name = calloc(link_name_length, sizeof(char));
- assert(tmp->link_name);
- strncpy(tmp->link_name, link_name, link_name_length);
-
- tmp->target = calloc(target_length, sizeof(char));
- assert(tmp->target);
- strncpy(tmp->target, target, target_length);
-
- tmp->x = x;
- tmp->y = y;
- tmp->next = NULL;
-
- index_max++;
-
- return index_max-1;
+int url_add(const wchar_t *link_name, int link_name_length, const wchar_t *target, int target_length, int x, int y) {
+ if (!init_ok) return -1;
+
+ url_t *tmp = NULL;
+ int i = 0;
+
+ if (list) {
+ tmp = list;
+ while (tmp->next) {
+ tmp = tmp->next;
+ i++;
+ }
+ tmp->next = malloc(sizeof(url_t));
+ assert(tmp->next);
+ tmp = tmp->next;
+ } else {
+ list = malloc(sizeof(url_t));
+ tmp = list;
+ assert(tmp);
+ }
+
+ tmp -> link_name = calloc(link_name_length+1, sizeof(wchar_t));
+ assert(tmp->link_name);
+ wcsncpy(tmp->link_name, link_name, link_name_length);
+ tmp->link_name[link_name_length] = '\0';
+
+ tmp->target = calloc(target_length+1, sizeof(wchar_t));
+ assert(tmp->target);
+ wcsncpy(tmp->target, target, target_length);
+ tmp->target[target_length] = '\0';
+
+ tmp->x = x;
+ tmp->y = y;
+ tmp->next = NULL;
+
+ index_max++;
+
+ return index_max-1;