Initial Commit
[Projects.git] / server / source / read.c
blob8ce0a2b54823be249808f849df9243a0dd2ce574
1 #include "api.h"
3 #include <stdio.h>
4 #include <stdlib.h>
6 char * READ(char * a, char * b){
7 char path[1024];
8 sprintf(path, "%s%s", a, b);
9 if (path!=""){
10 FILE * f;
11 f=fopen(path, "r");
12 if (f==NULL){
13 static char msg[1024];
14 sprintf(msg,"Path not found %s",path);
15 return msg;
17 long lSize;
18 char * str;
19 size_t result;
20 fseek(f, 0, SEEK_END);
21 lSize = ftell(f);
22 rewind(f);
23 str = (char*) malloc (sizeof(char)*lSize);
24 result = fread(str,1,lSize,f);
25 fclose(f);
26 return str;
27 } else {
28 return "No path specified";