Changes for io functions

This commit is contained in:
lexborisov 2017-03-10 15:11:35 +03:00
parent 32a34c02f1
commit 4c7b823274
9 changed files with 59 additions and 59 deletions

View File

@ -96,7 +96,7 @@ void mycss_an_plus_b_serialization(mycss_an_plus_b_entry_t* anb_entry, mycss_cal
char data[512];
if(anb_entry->a != 0) {
int len = snprintf(data, 512, "%ld", anb_entry->a);
int len = mycore_snprintf(data, 512, "%ld", anb_entry->a);
if(len > 0)
callback(data, (size_t)len, context);
@ -108,7 +108,7 @@ void mycss_an_plus_b_serialization(mycss_an_plus_b_entry_t* anb_entry, mycss_cal
if(anb_entry->b >= 0)
callback("+", 1, context);
int len = snprintf(data, 512, "%ld", anb_entry->b);
int len = mycore_snprintf(data, 512, "%ld", anb_entry->b);
if(len > 0)
callback(data, (size_t)len, context);

View File

@ -49,7 +49,7 @@ void mycss_namespace_serialization_entry(mycss_namespace_t* ns, mycss_namespace_
callback(ns_entry->name->data, ns_entry->name->length, context);
}
else if(ns_entry->ns_id == MyHTML_NAMESPACE_ANY)
return; //fprintf(fh, "*");
return; //mycore_fprintf(fh, "*");
else if(ns_entry->ns_id == MyHTML_NAMESPACE_UNDEF) {
/* some print */
}

View File

@ -28,7 +28,7 @@ void mycss_selectors_serialization_chain(mycss_selectors_t* selectors, mycss_sel
if(selector->combinator == MyCSS_SELECTORS_COMBINATOR_DESCENDANT)
callback(" ", 1, context);
else if(selector->combinator == MyCSS_SELECTORS_COMBINATOR_UNDEF) {
/* fprintf(fh, "") */
/* mycore_fprintf(fh, "") */
}
else {
callback(" ", 1, context);

View File

@ -42,11 +42,11 @@ void mycss_values_serialization_number(mycss_values_number_t* value, mycss_callb
char buff[512];
if(value->is_float) {
int len = snprintf(buff, 512, "%0.4f", value->f);
int len = mycore_snprintf(buff, 512, "%0.4f", value->f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
int len = snprintf(buff, 512, "%d", value->i);
int len = mycore_snprintf(buff, 512, "%d", value->i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
}
@ -59,11 +59,11 @@ void mycss_values_serialization_length(mycss_values_length_t* value, mycss_callb
char buff[512];
if(value->is_float) {
int len = snprintf(buff, 512, "%0.4f", value->f);
int len = mycore_snprintf(buff, 512, "%0.4f", value->f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
int len = snprintf(buff, 512, "%d", value->i);
int len = mycore_snprintf(buff, 512, "%d", value->i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
@ -81,11 +81,11 @@ void mycss_values_serialization_angle(mycss_values_angle_t* value, mycss_callbac
char buff[512];
if(value->is_float) {
int len = snprintf(buff, 512, "%0.4f", value->f);
int len = mycore_snprintf(buff, 512, "%0.4f", value->f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
int len = snprintf(buff, 512, "%d", value->i);
int len = mycore_snprintf(buff, 512, "%d", value->i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
@ -103,11 +103,11 @@ void mycss_values_serialization_resolution(mycss_values_resolution_t* value, myc
char buff[512];
if(value->is_float) {
int len = snprintf(buff, 512, "%0.4f", value->f);
int len = mycore_snprintf(buff, 512, "%0.4f", value->f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
int len = snprintf(buff, 512, "%d", value->i);
int len = mycore_snprintf(buff, 512, "%d", value->i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
@ -125,11 +125,11 @@ void mycss_values_serialization_percentage(mycss_values_percentage_t* value, myc
char buff[512];
if(value->is_float) {
int len = snprintf(buff, 512, "%0.4f%%", value->f);
int len = mycore_snprintf(buff, 512, "%0.4f%%", value->f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
int len = snprintf(buff, 512, "%d%%", value->i);
int len = mycore_snprintf(buff, 512, "%d%%", value->i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
}

View File

@ -304,7 +304,7 @@ void myfont_font_print_exists_table(myfont_font_t *mf, FILE *file)
for(i = 0; i < MyFONT_TKEY_LAST_KEY; i++)
{
if(mf->cache.tables_offset[i]) {
fprintf(file, "%s = %u\n", myfont_table_name[i], mf->cache.tables_offset[i]);
mycore_fprintf(file, "%s = %u\n", myfont_table_name[i], mf->cache.tables_offset[i]);
}
}
}

View File

@ -150,14 +150,14 @@ void myhtml_tag_print(myhtml_tag_t* tags, FILE* fh)
{
const myhtml_tag_context_t *ctx = myhtml_tag_get_by_id(tags, i);
fprintf(fh, "<%s id=\"" MyCORE_FMT_Z "\">\n", ctx->name, i);
mycore_fprintf(fh, "<%s id=\"" MyCORE_FMT_Z "\">\n", ctx->name, i);
}
for(i = (MyHTML_TAG_LAST_ENTRY + 1); i < tags->tags_count; i++)
{
const myhtml_tag_context_t *ctx = myhtml_tag_get_by_id(tags, i);
fprintf(fh, "<%s id=\"" MyCORE_FMT_Z "\">\n", ctx->name, i);
mycore_fprintf(fh, "<%s id=\"" MyCORE_FMT_Z "\">\n", ctx->name, i);
}
}

View File

@ -870,21 +870,21 @@ void myhtml_token_set_replacement_character_for_null_token(myhtml_tree_t* tree,
void myhtml_token_print_param_by_idx(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out)
{
if(node->type & MyHTML_TOKEN_TYPE_CLOSE) {
fprintf(out, "</");
mycore_fprintf(out, "</");
}
else {
fprintf(out, "<");
mycore_fprintf(out, "<");
}
fprintf(out, "tag_id=" MyCORE_FMT_Z "; body_begin=" MyCORE_FMT_Z "; body_length=" MyCORE_FMT_Z "; attr_first=0x%p; attr_last=0x%p",
mycore_fprintf(out, "tag_id=" MyCORE_FMT_Z "; body_begin=" MyCORE_FMT_Z "; body_length=" MyCORE_FMT_Z "; attr_first=0x%p; attr_last=0x%p",
node->tag_id, node->raw_begin, node->raw_length,
node->attr_first, node->attr_last);
if(node->type & MyHTML_TOKEN_TYPE_CLOSE_SELF) {
fprintf(out, " />\n");
mycore_fprintf(out, " />\n");
}
else {
fprintf(out, ">\n");
mycore_fprintf(out, ">\n");
}
}
@ -896,31 +896,31 @@ void myhtml_token_print_by_idx(myhtml_tree_t* tree, myhtml_token_node_t* node, F
node->tag_id == MyHTML_TAG__COMMENT)
{
if(node->str.length) {
fprintf(out, "%.*s: %.*s\n", (int)ctx->name_length, ctx->name,
mycore_fprintf(out, "%.*s: %.*s\n", (int)ctx->name_length, ctx->name,
(int)node->str.length, node->str.data);
}
else {
fprintf(out, "%.*s is empty\n", (int)ctx->name_length, ctx->name);
mycore_fprintf(out, "%.*s is empty\n", (int)ctx->name_length, ctx->name);
}
}
else
{
if(node->type & MyHTML_TOKEN_TYPE_CLOSE) {
fprintf(out, "</");
mycore_fprintf(out, "</");
}
else {
fprintf(out, "<");
mycore_fprintf(out, "<");
}
fprintf(out, "%.*s tagid=\"" MyCORE_FMT_Z "\"", (int)ctx->name_length, ctx->name, node->tag_id);
mycore_fprintf(out, "%.*s tagid=\"" MyCORE_FMT_Z "\"", (int)ctx->name_length, ctx->name, node->tag_id);
myhtml_token_print_attr(tree, node, out);
if(node->type & MyHTML_TOKEN_TYPE_CLOSE_SELF) {
fprintf(out, " />\n");
mycore_fprintf(out, " />\n");
}
else {
fprintf(out, ">\n");
mycore_fprintf(out, ">\n");
}
}
}
@ -931,34 +931,34 @@ void myhtml_token_print_attr(myhtml_tree_t* tree, myhtml_token_node_t* node, FIL
while(attr)
{
fprintf(out, " %s", attr->key.data);
mycore_fprintf(out, " %s", attr->key.data);
if(attr->ns != MyHTML_NAMESPACE_HTML)
{
switch (attr->ns) {
case MyHTML_NAMESPACE_SVG:
fprintf(out, ":svg");
mycore_fprintf(out, ":svg");
break;
case MyHTML_NAMESPACE_MATHML:
fprintf(out, ":math");
mycore_fprintf(out, ":math");
break;
case MyHTML_NAMESPACE_XLINK:
fprintf(out, ":xlink");
mycore_fprintf(out, ":xlink");
break;
case MyHTML_NAMESPACE_XML:
fprintf(out, ":xml");
mycore_fprintf(out, ":xml");
break;
case MyHTML_NAMESPACE_XMLNS:
fprintf(out, ":xmlns");
mycore_fprintf(out, ":xmlns");
break;
default:
fprintf(out, ":UNDEF");
mycore_fprintf(out, ":UNDEF");
break;
}
}
if(attr->value.length) {
fprintf(out, "=\"%s\"", attr->value.data);
mycore_fprintf(out, "=\"%s\"", attr->value.data);
}
attr = attr->next;

View File

@ -1681,7 +1681,7 @@ bool myhtml_tree_adoption_agency_algorithm(myhtml_tree_t* tree, myhtml_token_nod
// step 8
//if(afe_last != list[i])
// fprintf(stderr, "oh");
// mycore_fprintf(stderr, "oh");
// step 9
myhtml_tree_node_t* current_node = myhtml_tree_current_node(tree);
@ -1763,7 +1763,7 @@ bool myhtml_tree_adoption_agency_algorithm(myhtml_tree_t* tree, myhtml_token_nod
if(node_index > 0)
node_index--;
else {
fprintf(stderr, "ERROR: adoption agency algorithm; decrement node_index, node_index is null");
mycore_fprintf(stderr, "ERROR: adoption agency algorithm; decrement node_index, node_index is null");
return false;
}
@ -2161,54 +2161,54 @@ void myhtml_tree_print_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE*
node->tag_id == MyHTML_TAG__COMMENT)
{
if(node->token)
fprintf(out, "<%.*s>: %.*s\n", (int)ctx->name_length, ctx->name,
mycore_fprintf(out, "<%.*s>: %.*s\n", (int)ctx->name_length, ctx->name,
(int)node->token->str.length, node->token->str.data);
else
fprintf(out, "<%.*s>\n", (int)ctx->name_length, ctx->name);
mycore_fprintf(out, "<%.*s>\n", (int)ctx->name_length, ctx->name);
}
else if(node->tag_id == MyHTML_TAG__DOCTYPE)
{
fprintf(out, "<!DOCTYPE");
mycore_fprintf(out, "<!DOCTYPE");
if(tree->doctype.attr_name) {
fprintf(out, " %s", tree->doctype.attr_name);
mycore_fprintf(out, " %s", tree->doctype.attr_name);
}
if(tree->doctype.attr_public) {
fprintf(out, " %s", tree->doctype.attr_public);
mycore_fprintf(out, " %s", tree->doctype.attr_public);
}
if(tree->doctype.attr_system) {
fprintf(out, " %s", tree->doctype.attr_system);
mycore_fprintf(out, " %s", tree->doctype.attr_system);
}
fprintf(out, ">\n");
mycore_fprintf(out, ">\n");
}
else
{
if(node->token && node->token->type & MyHTML_TOKEN_TYPE_CLOSE) {
fprintf(out, "</%.*s", (int)ctx->name_length, ctx->name);
mycore_fprintf(out, "</%.*s", (int)ctx->name_length, ctx->name);
}
else {
fprintf(out, "<%.*s", (int)ctx->name_length, ctx->name);
mycore_fprintf(out, "<%.*s", (int)ctx->name_length, ctx->name);
}
if(node->ns != MyHTML_NAMESPACE_HTML) {
switch (node->ns) {
case MyHTML_NAMESPACE_SVG:
fprintf(out, ":svg");
mycore_fprintf(out, ":svg");
break;
case MyHTML_NAMESPACE_MATHML:
fprintf(out, ":math");
mycore_fprintf(out, ":math");
break;
case MyHTML_NAMESPACE_XLINK:
fprintf(out, ":xlink");
mycore_fprintf(out, ":xlink");
break;
case MyHTML_NAMESPACE_XML:
fprintf(out, ":xml");
mycore_fprintf(out, ":xml");
break;
case MyHTML_NAMESPACE_XMLNS:
fprintf(out, ":xmlns");
mycore_fprintf(out, ":xmlns");
break;
default:
break;
@ -2218,7 +2218,7 @@ void myhtml_tree_print_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE*
if(node->token)
myhtml_token_print_attr(tree, node->token, out);
fprintf(out, ">\n");
mycore_fprintf(out, ">\n");
}
}
@ -2232,7 +2232,7 @@ void _myhtml_tree_print_node_children(myhtml_tree_t* tree, myhtml_tree_node_t* n
while(node)
{
for(i = 0; i < inc; i++)
fprintf(out, "\t");
mycore_fprintf(out, "\t");
myhtml_tree_print_node(tree, node, out);
_myhtml_tree_print_node_children(tree, node->child, out, (inc + 1));

View File

@ -250,10 +250,10 @@ uint64_t mycore_hperf_clock(mystatus_t *status)
#define _MyCORE_CHECK_STATUS_AND_PRINT_ERROR \
if(status == MyCORE_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF) { \
fprintf(fh, "MyCORE: Library compiled without perf source. Please, build library with -DMyCORE_WITH_PERF flag\n"); \
mycore_fprintf(fh, "MyCORE: Library compiled without perf source. Please, build library with -DMyCORE_WITH_PERF flag\n"); \
} \
else if(status) { \
fprintf(fh, "MyCORE: Something wrong! Perhaps, your platform does not support the measurement of performance\n"); \
mycore_fprintf(fh, "MyCORE: Something wrong! Perhaps, your platform does not support the measurement of performance\n"); \
} \
else
@ -264,7 +264,7 @@ mystatus_t mycore_hperf_print(const char *name, uint64_t x, uint64_t y, FILE *fh
if(freq) {
_MyCORE_CHECK_STATUS_AND_PRINT_ERROR {
fprintf(fh, "%s: %0.5f\n", name, (((float)(y - x) / (float)freq)));
mycore_fprintf(fh, "%s: %0.5f\n", name, (((float)(y - x) / (float)freq)));
}
}
@ -278,7 +278,7 @@ mystatus_t mycore_hperf_print_by_val(const char *name, uint64_t x, FILE *fh) {
if(freq) {
_MyCORE_CHECK_STATUS_AND_PRINT_ERROR {
fprintf(fh, "%s: %0.5f\n", name, ((float)x / (float)freq));
mycore_fprintf(fh, "%s: %0.5f\n", name, ((float)x / (float)freq));
}
}