Beispiel #1
0
void main() {
    char *inputBuffer;
    char *outputBuffer;
    
    size_t inputSize = load_csv_to_buffer(INPUT_FILEPATH, 
            &inputBuffer);
    
    outputBuffer = malloc(NUM_COORDINATES * MAX_OUTPUT_LINE_SIZE *
            sizeof(char));
    
    // convert the csv file
    size_t outputSize = convert_to_csv(inputBuffer, &outputBuffer);
    
    write_csv_file(OUTPUT_FILEPATH, outputBuffer, 
            outputSize);
    
    printf("%s", outputBuffer);
    
    free(inputBuffer);
    free(outputBuffer);
}
Beispiel #2
0
int main() {
    char *fileBuffer;
    char *csvBuffer;
    
    size_t fileLength = load_plt_to_buffer("000/20081023025304.plt", &fileBuffer);
    // printf("%s", fileBuffer);
    int numCoordinates = count_GPS_coordinates(fileBuffer);
    
    csvBuffer = malloc(numCoordinates * MAX_LINE_SIZE * sizeof(char));
    
    int fileSize = convert_to_csv(fileBuffer, numCoordinates, &csvBuffer);
    
    write_csv_file(csvBuffer, fileSize);
    
    printf("%s", csvBuffer);
    
    free(fileBuffer);
    free(csvBuffer);
    
    return 0;

}
Beispiel #3
0
json_t * stats_generate(json_t * obj)
{
        char * interface = (char *)json_string_value(json_object_get(obj,"interface"));
        char * command;
	srand(time(NULL));
	int r = rand();
	json_t * ret=json_array();
	char * picname;
        command = (char *)calloc(SIZE,sizeof(char));
	picname = (char *)calloc(SIZE,sizeof(char));
        sprintf(command,"/rom/mnt/cust/etc/vnstatigenerate %s %d",interface,r);
        system(command);
        sprintf(command,"/rom/mnt/cust/etc/darkstatgenerate %s",interface);
	system(command);
	//Copying files from darkstat backup
	system("rm -rf /etc/statistics/darkstat/files.txt");
	sprintf(command,"echo Current > /tmp/statistics/darkstat/files.txt && ls /etc/statistics/darkstat/*_%s.txt|sed 's/\\/etc\\/statistics\\/darkstat\\///g'|sed 's/\_hosts\_.\*.txt//g' >> /tmp/statistics/darkstat/files.txt",interface);
	//printf("This is the command: %s\n",command);
	system(command);
	//
        free(command);
	//Compression
	convert_to_csv(interface);
	sprintf(picname,"vnstat_d_%d.png",r);
	json_array_append_new(ret,json_string(picname));
        sprintf(picname,"vnstat_h_%d.png",r);
        json_array_append_new(ret,json_string(picname));
	sprintf(picname,"vnstat_m_%d.png",r);
        json_array_append_new(ret,json_string(picname));
	sprintf(picname,"vnstat_s_%d.png",r);
        json_array_append_new(ret,json_string(picname));
	sprintf(picname,"vnstat_t_%d.png",r);
        json_array_append_new(ret,json_string(picname));
	json_object_set(obj,"images",ret);
	compress_for_download(interface);
	free(picname);
	return(ret);
}