Subversion Repositories Okuu

Rev

Rev 13 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13 Rev 15
Line 1... Line 1...
1
/* $Id: news.c 13 2024-09-12 15:29:22Z nishi $ */
1
/* $Id: news.c 15 2024-09-13 16:13:27Z nishi $ */
2
 
2
 
3
#define OK_NEWS_SRC
3
#define OK_NEWS_SRC
4
#include "ok_news.h"
4
#include "ok_news.h"
5
 
5
 
6
#include "ok_util.h"
6
#include "ok_util.h"
Line 52... Line 52...
52
	struct stat s;
52
	struct stat s;
53
	if(stat(path, &s) == 0) {
53
	if(stat(path, &s) == 0) {
54
		char* boundary = NULL;
54
		char* boundary = NULL;
55
		char* buffer = malloc(s.st_size + 1);
55
		char* buffer = malloc(s.st_size + 1);
56
		buffer[s.st_size] = 0;
56
		buffer[s.st_size] = 0;
57
		FILE* f = fopen(path, "r");
57
		FILE* f = fopen(path, "rb");
-
 
58
		if(f == NULL){
-
 
59
			free(buffer);
-
 
60
			return 1;
-
 
61
		}
58
		fread(buffer, s.st_size, 1, f);
62
		fread(buffer, s.st_size, 1, f);
59
 
63
 
60
		uint64_t i;
64
		uint64_t i;
61
		bool newline = false;
65
		bool newline = false;
62
		int incr = 0;
66
		int incr = 0;
Line 217... Line 221...
217
			}
221
			}
218
		}
222
		}
219
		free(l);
223
		free(l);
220
 
224
 
221
		free(buffer);
225
		free(buffer);
-
 
226
		fclose(f);
222
		if(boundary != NULL) free(boundary);
227
		if(boundary != NULL) free(boundary);
223
		return 0;
228
		return 0;
224
	} else {
229
	} else {
225
		return 1;
230
		return 1;
226
	}
231
	}