12 #include "lib/php/str_contains.h"
14 #include <sys/variable.h>
17 size_t C_VARIABLE = 0;
21 for (
int i = 0; i < 512;i++){
23 if (
strcmpn(G_VARIABLE[i].Key,Key))
return i;
24 if (G_VARIABLE[i].Ready == 0 && Key404)
return i;
25 if (i == 511 && !Key404){
33 int variable_write(
char* Key,
char* Value){
34 qemu_log(
"[Variable] [Write] %s=%s",Key,Value);
37 qemu_log(
"[Variable] [Error] Return index: %d",inx);
40 if (G_VARIABLE[inx].Ready == 1 &&
strlen(Value) == 0){
42 }
else if (G_VARIABLE[inx].Ready == 0 &&
strlen(Value) != 0){
45 G_VARIABLE[inx].Ready = (
strlen(Value) == 0?0:1);
51 char* variable_read(
char* Key){
52 qemu_log(
"[Variable] [Read] %s",Key);
53 for (
int i = 0; i < 512;i++){
54 if (G_VARIABLE[i].Ready &&
strcmpn(G_VARIABLE[i].Key,Key)){
55 qemu_log(
"[Variable] [Read] %s=%s",G_VARIABLE[i].Key,G_VARIABLE[i].Value);
56 return G_VARIABLE[i].Value;
59 qemu_log(
"[Variable] [Read] %s=NULL",Key);
63 VARIABLE* variable_list(
char* Search){
64 qemu_log(
"[Variable] [List] [ALL=%d] Search: %s",C_VARIABLE,Search);
67 for (
int i = 0; i < 512;i++){
68 if (G_VARIABLE[i].Ready == 0)
continue;
69 qemu_log(
"[%d] Ready: %d | Search:%d | Key:%s",inx, G_VARIABLE[i].Ready, str_contains(G_VARIABLE[i].Key,Search), G_VARIABLE[i].Key);
70 if (str_contains(G_VARIABLE[i].Key,Search) == 0)
continue;
72 memcpy(list[inx].Key,G_VARIABLE[i].Key,
strlen(G_VARIABLE[i].Key));
73 memcpy(list[inx].Value,G_VARIABLE[i].Value,
strlen(G_VARIABLE[i].Value));
size_t strlen(const char *str)
Возращает длину строки
bool strcmpn(const char *str1, const char *str2)
Сравнение строк
void * memcpy(void *restrict destination, const void *restrict source, size_t n)
Копирование непересекающихся массивов используя SSE.
size_t variable_freeID(char *Key)