mirror of
https://github.com/lexborisov/Modest
synced 2024-11-22 05:41:32 +03:00
This commit is contained in:
parent
43ab0fd013
commit
729665ede4
2
Makefile
2
Makefile
@ -12,7 +12,7 @@ CC ?= gcc
|
|||||||
|
|
||||||
.DEFAULT_GOAL := all
|
.DEFAULT_GOAL := all
|
||||||
|
|
||||||
DESCRIPTION := Modest is a fast HTML renderer implemented as a pure C99 library with no outside dependencies
|
DESCRIPTION := fast HTML renderer library with no outside dependency
|
||||||
|
|
||||||
#********************
|
#********************
|
||||||
# other Makefile
|
# other Makefile
|
||||||
|
@ -148,16 +148,18 @@ void * mycore_realloc(void* dst, size_t size);
|
|||||||
void * mycore_calloc(size_t num, size_t size);
|
void * mycore_calloc(size_t num, size_t size);
|
||||||
void * mycore_free(void* dst);
|
void * mycore_free(void* dst);
|
||||||
|
|
||||||
/**
|
/* io */
|
||||||
* Platform-specific hdef performance clock queries.
|
FILE * mycore_fopen(const char *filename, const char *mode);
|
||||||
* Implemented in perf.c
|
int mycore_fclose(FILE *stream);
|
||||||
*/
|
|
||||||
|
size_t mycore_fread(void *buffer, size_t size, size_t count, FILE *stream);
|
||||||
///** Get clock resolution */
|
size_t mycore_fwrite(const void *buffer, size_t size, size_t count, FILE *stream);
|
||||||
//uint64_t mycore_hperf_res(mystatus_t *status);
|
int mycore_fflush(FILE *stream);
|
||||||
//
|
int mycore_fseek(FILE* stream, long offset, int origin);
|
||||||
///** Get current value in clock ticks */
|
long mycore_ftell(FILE* stream);
|
||||||
//uint64_t mycore_hperf_clock(mystatus_t *status);
|
int mycore_ferror(FILE *stream);
|
||||||
|
|
||||||
|
void mycore_setbuf(FILE *stream, char *buffer);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@ -148,16 +148,18 @@ void * mycore_realloc(void* dst, size_t size);
|
|||||||
void * mycore_calloc(size_t num, size_t size);
|
void * mycore_calloc(size_t num, size_t size);
|
||||||
void * mycore_free(void* dst);
|
void * mycore_free(void* dst);
|
||||||
|
|
||||||
/**
|
/* io */
|
||||||
* Platform-specific hdef performance clock queries.
|
FILE * mycore_fopen(const char *filename, const char *mode);
|
||||||
* Implemented in perf.c
|
int mycore_fclose(FILE *stream);
|
||||||
*/
|
|
||||||
|
size_t mycore_fread(void *buffer, size_t size, size_t count, FILE *stream);
|
||||||
///** Get clock resolution */
|
size_t mycore_fwrite(const void *buffer, size_t size, size_t count, FILE *stream);
|
||||||
//uint64_t mycore_hperf_res(mystatus_t *status);
|
int mycore_fflush(FILE *stream);
|
||||||
//
|
int mycore_fseek(FILE* stream, long offset, int origin);
|
||||||
///** Get current value in clock ticks */
|
long mycore_ftell(FILE* stream);
|
||||||
//uint64_t mycore_hperf_clock(mystatus_t *status);
|
int mycore_ferror(FILE *stream);
|
||||||
|
|
||||||
|
void mycore_setbuf(FILE *stream, char *buffer);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@ -109,46 +109,46 @@ mystatus_t myfont_load_from_file(myfont_font_t *mf, const char *filepath, uint8_
|
|||||||
|
|
||||||
size_t file_data_size;
|
size_t file_data_size;
|
||||||
|
|
||||||
FILE *fh = fopen(filepath, "rb");
|
FILE *fh = mycore_fopen(filepath, "rb");
|
||||||
if(fh == NULL)
|
if(fh == NULL)
|
||||||
return MyFONT_STATUS_ERROR_FILE_OPEN;
|
return MyFONT_STATUS_ERROR_FILE_OPEN;
|
||||||
|
|
||||||
if(fseek(fh, 0L, SEEK_END)) {
|
if(mycore_fseek(fh, 0L, SEEK_END)) {
|
||||||
fclose(fh);
|
mycore_fclose(fh);
|
||||||
return MyFONT_STATUS_ERROR_FILE_SEEK;
|
return MyFONT_STATUS_ERROR_FILE_SEEK;
|
||||||
}
|
}
|
||||||
|
|
||||||
long file_size = ftell(fh);
|
long file_size = mycore_ftell(fh);
|
||||||
if(file_size == -1) {
|
if(file_size == -1) {
|
||||||
fclose(fh);
|
mycore_fclose(fh);
|
||||||
return MyFONT_STATUS_ERROR_FILE_TELL;
|
return MyFONT_STATUS_ERROR_FILE_TELL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fseek(fh, 0L, SEEK_SET)) {
|
if(mycore_fseek(fh, 0L, SEEK_SET)) {
|
||||||
fclose(fh);
|
mycore_fclose(fh);
|
||||||
return MyFONT_STATUS_ERROR_FILE_SEEK;
|
return MyFONT_STATUS_ERROR_FILE_SEEK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_size > 0)
|
if(file_size > 0)
|
||||||
file_data_size = (size_t)file_size;
|
file_data_size = (size_t)file_size;
|
||||||
else {
|
else {
|
||||||
fclose(fh);
|
mycore_fclose(fh);
|
||||||
return MyFONT_STATUS_ERROR_FILE_TOO_SMALL;
|
return MyFONT_STATUS_ERROR_FILE_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* data = (uint8_t*)mycore_malloc(file_size);
|
uint8_t* data = (uint8_t*)mycore_malloc(file_size);
|
||||||
|
|
||||||
if(data == NULL) {
|
if(data == NULL) {
|
||||||
fclose(fh);
|
mycore_fclose(fh);
|
||||||
return MyFONT_STATUS_ERROR_MEMORY_ALLOCATION;
|
return MyFONT_STATUS_ERROR_MEMORY_ALLOCATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fread(data, 1, file_size, fh) != file_size) {
|
if(fread(data, 1, file_size, fh) != file_size) {
|
||||||
fclose(fh);
|
mycore_fclose(fh);
|
||||||
return MyFONT_STATUS_ERROR_FILE_READ;
|
return MyFONT_STATUS_ERROR_FILE_READ;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fh);
|
mycore_fclose(fh);
|
||||||
|
|
||||||
if(return_data)
|
if(return_data)
|
||||||
*return_data = data;
|
*return_data = data;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* FILE */
|
/* FILE */
|
||||||
FILE * mycore_fopen(const char *restrict filename, const char *restrict mode)
|
FILE * mycore_fopen(const char *filename, const char *mode)
|
||||||
{
|
{
|
||||||
return fopen(filename, mode);
|
return fopen(filename, mode);
|
||||||
}
|
}
|
||||||
@ -32,12 +32,12 @@ int mycore_fclose(FILE *stream)
|
|||||||
return fclose(stream);
|
return fclose(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t mycore_fread(void *restrict buffer, size_t size, size_t count, FILE *restrict stream)
|
size_t mycore_fread(void *buffer, size_t size, size_t count, FILE *stream)
|
||||||
{
|
{
|
||||||
return fread(buffer, size, count, stream);
|
return fread(buffer, size, count, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t mycore_fwrite(const void *restrict buffer, size_t size, size_t count, FILE *restrict stream)
|
size_t mycore_fwrite(const void *buffer, size_t size, size_t count, FILE *stream)
|
||||||
{
|
{
|
||||||
return fwrite(buffer, size, count, stream);
|
return fwrite(buffer, size, count, stream);
|
||||||
}
|
}
|
||||||
@ -47,15 +47,23 @@ int mycore_fflush(FILE *stream)
|
|||||||
return fflush(stream);
|
return fflush(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mycore_fseek(FILE* stream, long offset, int origin)
|
||||||
|
{
|
||||||
|
return fseek(stream, offset, origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
long mycore_ftell(FILE* stream)
|
||||||
|
{
|
||||||
|
return ftell(stream);
|
||||||
|
}
|
||||||
|
|
||||||
int mycore_ferror(FILE *stream)
|
int mycore_ferror(FILE *stream)
|
||||||
{
|
{
|
||||||
return ferror(stream);
|
return ferror(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setbuf */
|
/* setbuf */
|
||||||
void mycore_setbuf(FILE *restrict stream, char *restrict buffer)
|
void mycore_setbuf(FILE *stream, char *buffer)
|
||||||
{
|
{
|
||||||
setbuf(stream, buffer);
|
setbuf(stream, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,6 +47,16 @@ int mycore_fflush(FILE *stream)
|
|||||||
return fflush(stream);
|
return fflush(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mycore_fseek(FILE* stream, long offset, int origin)
|
||||||
|
{
|
||||||
|
return fseek(stream, offset, origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
long mycore_ftell(FILE* stream)
|
||||||
|
{
|
||||||
|
return ftell(stream);
|
||||||
|
}
|
||||||
|
|
||||||
int mycore_ferror(FILE *stream)
|
int mycore_ferror(FILE *stream)
|
||||||
{
|
{
|
||||||
return ferror(stream);
|
return ferror(stream);
|
||||||
|
Loading…
Reference in New Issue
Block a user