Login | ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/ipe_artfile_utils/trunk/utils.c
Revision: 2
Committed: Thu Nov 8 11:19:36 2018 UTC (16 months, 2 weeks ago) by daniel-marschall
Content type: text/x-csrc
File size: 657 byte(s)
Log Message:
Initial release to SVN

File Contents

# Content
1 #include <stdlib.h>
2 #include <stdio.h>
3
4 #include "utils.h"
5
6 size_t file_size(FILE* fp) {
7 size_t pos = ftell(fp);
8 fseek(fp, 0, SEEK_END);
9 size_t len = ftell(fp);
10 fseek(fp, pos, SEEK_SET);
11 return len;
12 }
13
14 char* sanitize_filename(char* picname) {
15 // Remove invalid windows characters
16 // TODO: not yet implemented. not necessary for the regular ART files, though
17 return picname;
18 }
19
20 void* app_zero_alloc(long bytes) {
21 char* ptr = (char*)malloc(bytes);
22 int i;
23 for (i=0; i<bytes; ++i) ptr[i] = 0;
24 return (void*)ptr;
25 }
26
27 unsigned char read_byte(FILE *file) {
28 int ch = getc(file);
29 if (ch == EOF)
30 ch = 0;
31 return ch;
32 }
33

Properties

Name Value
svn:mime-type text/x-csrc