parent
f7b3fcbf3a
commit
14ab26edd4
|
@ -71,6 +71,8 @@ extern "C" {
|
||||||
void embryo_swap_32(unsigned int *v);
|
void embryo_swap_32(unsigned int *v);
|
||||||
Embryo_Function embryo_program_function_find(Embryo_Program *ep, char *name);
|
Embryo_Function embryo_program_function_find(Embryo_Program *ep, char *name);
|
||||||
Embryo_Cell embryo_program_variable_find(Embryo_Program *ep, char *name);
|
Embryo_Cell embryo_program_variable_find(Embryo_Program *ep, char *name);
|
||||||
|
int embryo_program_variable_count_get(Embryo_Program *ep);
|
||||||
|
Embryo_Cell embryo_program_variable_get(Embryo_Program *ep, int num);
|
||||||
void embryo_program_error_set(Embryo_Program *ep, int error);
|
void embryo_program_error_set(Embryo_Program *ep, int error);
|
||||||
int embryo_program_error_get(Embryo_Program *ep);
|
int embryo_program_error_get(Embryo_Program *ep);
|
||||||
void embryo_program_data_set(Embryo_Program *ep, void *data);
|
void embryo_program_data_set(Embryo_Program *ep, void *data);
|
||||||
|
|
|
@ -468,6 +468,32 @@ embryo_program_variable_find(Embryo_Program *ep, char *name)
|
||||||
return EMBRYO_CELL_NONE;
|
return EMBRYO_CELL_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
embryo_program_variable_count_get(Embryo_Program *ep)
|
||||||
|
{
|
||||||
|
Embryo_Header *hdr;
|
||||||
|
|
||||||
|
if (!ep) return 0;
|
||||||
|
if (!ep->base) return 0;
|
||||||
|
hdr = (Embryo_Header *)ep->base;
|
||||||
|
return NUMENTRIES(hdr, pubvars, tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
Embryo_Cell
|
||||||
|
embryo_program_variable_get(Embryo_Program *ep, int num)
|
||||||
|
{
|
||||||
|
Embryo_Header *hdr;
|
||||||
|
Embryo_Cell paddr;
|
||||||
|
char pname[sNAMEMAX + 1];
|
||||||
|
|
||||||
|
if (!ep) return EMBRYO_CELL_NONE;
|
||||||
|
if (!ep->base) return EMBRYO_CELL_NONE;
|
||||||
|
hdr = (Embryo_Header *)ep->base;
|
||||||
|
if (_embryo_var_get(ep, num, pname, &paddr) == EMBRYO_ERROR_NONE)
|
||||||
|
return paddr;
|
||||||
|
return EMBRYO_CELL_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
embryo_program_error_set(Embryo_Program *ep, int error)
|
embryo_program_error_set(Embryo_Program *ep, int error)
|
||||||
{
|
{
|
||||||
|
|
|
@ -257,7 +257,7 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params)
|
||||||
if (!s2) return -1;
|
if (!s2) return -1;
|
||||||
s2[0] = 0;
|
s2[0] = 0;
|
||||||
pnum = (params[0] / sizeof(Embryo_Cell)) - 3;
|
pnum = (params[0] / sizeof(Embryo_Cell)) - 3;
|
||||||
for (p = 0, o = 0; (s1[i]) && (o < (params[2] - 1)) && (p < pnum); i++)
|
for (p = 0, o = 0, i = 0; (s1[i]) && (o < (params[2] - 1)) && (p < (pnum + 1)); i++)
|
||||||
{
|
{
|
||||||
if ((!inesc) && (!insub))
|
if ((!inesc) && (!insub))
|
||||||
{
|
{
|
||||||
|
@ -271,6 +271,8 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Embryo_Cell *cptr;
|
||||||
|
|
||||||
if (inesc)
|
if (inesc)
|
||||||
{
|
{
|
||||||
switch (s1[i])
|
switch (s1[i])
|
||||||
|
@ -290,7 +292,7 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params)
|
||||||
}
|
}
|
||||||
inesc = 0;
|
inesc = 0;
|
||||||
}
|
}
|
||||||
if (insub)
|
if ((insub) && (p < pnum))
|
||||||
{
|
{
|
||||||
switch (s1[i])
|
switch (s1[i])
|
||||||
{
|
{
|
||||||
|
@ -299,7 +301,8 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params)
|
||||||
o++;
|
o++;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
s2[o] = params[4 + p];
|
cptr = embryo_data_address_get(ep, params[4 + p]);
|
||||||
|
if (cptr) s2[o] = (char)(*cptr);
|
||||||
p++;
|
p++;
|
||||||
o++;
|
o++;
|
||||||
break;
|
break;
|
||||||
|
@ -316,7 +319,8 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params)
|
||||||
else if (s1[i] == 'd') strcpy(fmt, "%d");
|
else if (s1[i] == 'd') strcpy(fmt, "%d");
|
||||||
else if (s1[i] == 'x') strcpy(fmt, "%x");
|
else if (s1[i] == 'x') strcpy(fmt, "%x");
|
||||||
else if (s1[i] == 'X') strcpy(fmt, "%08x");
|
else if (s1[i] == 'X') strcpy(fmt, "%08x");
|
||||||
snprintf(tmp, sizeof(tmp), fmt, params[4 + p]);
|
cptr = embryo_data_address_get(ep, params[4 + p]);
|
||||||
|
if (cptr) snprintf(tmp, sizeof(tmp), fmt, (int)(*cptr));
|
||||||
l = strlen(tmp);
|
l = strlen(tmp);
|
||||||
if ((o + l) > (params[2] - 1))
|
if ((o + l) > (params[2] - 1))
|
||||||
{
|
{
|
||||||
|
@ -324,7 +328,7 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params)
|
||||||
if (l < 0) l = 0;
|
if (l < 0) l = 0;
|
||||||
tmp[l] = 0;
|
tmp[l] = 0;
|
||||||
}
|
}
|
||||||
strcat(s2, tmp);
|
strcpy(s2 + o, tmp);
|
||||||
o += l;
|
o += l;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
@ -334,7 +338,8 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params)
|
||||||
char tmp[256] = "";
|
char tmp[256] = "";
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
snprintf(tmp, sizeof(tmp), "%f", EMBRYO_CELL_TO_FLOAT(params[4 + p]));
|
cptr = embryo_data_address_get(ep, params[4 + p]);
|
||||||
|
if (cptr) snprintf(tmp, sizeof(tmp), "%f", (double)EMBRYO_CELL_TO_FLOAT(*cptr));
|
||||||
l = strlen(tmp);
|
l = strlen(tmp);
|
||||||
if ((o + l) > (params[2] - 1))
|
if ((o + l) > (params[2] - 1))
|
||||||
{
|
{
|
||||||
|
@ -342,7 +347,7 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params)
|
||||||
if (l < 0) l = 0;
|
if (l < 0) l = 0;
|
||||||
tmp[l] = 0;
|
tmp[l] = 0;
|
||||||
}
|
}
|
||||||
strcat(s2, tmp);
|
strcpy(s2 + o, tmp);
|
||||||
o += l;
|
o += l;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
@ -360,7 +365,7 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params)
|
||||||
if (l < 0) l = 0;
|
if (l < 0) l = 0;
|
||||||
tmp[l] = 0;
|
tmp[l] = 0;
|
||||||
}
|
}
|
||||||
strcat(s2, tmp);
|
strcpy(s2 + o, tmp);
|
||||||
o += l;
|
o += l;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
@ -370,6 +375,8 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params)
|
||||||
}
|
}
|
||||||
insub = 0;
|
insub = 0;
|
||||||
}
|
}
|
||||||
|
else if (insub)
|
||||||
|
insub = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s2[o] = 0;
|
s2[o] = 0;
|
||||||
|
|
Loading…
Reference in New Issue