You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
#include <unistd.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include "dag_data_split.h"
|
|
|
|
#define MAX_BUF (1024 * 1024 * 1) // 1m
|
|
|
|
int main() {
|
|
char *d = malloc(MAX_BUF + 1);
|
|
ssize_t bytes_read = read(0, d, MAX_BUF);
|
|
if (bytes_read < 0) {
|
|
perror("Error reading input");
|
|
return 1;
|
|
}
|
|
|
|
DataNode *dataList = splitData(d, bytes_read);
|
|
if (dataList == NULL) {
|
|
fprintf(stderr, "Failed to split data.\n");
|
|
return 1;
|
|
}
|
|
|
|
const char *firstdata = getDataNodeByIndex(dataList, 1); // Assume this is text data
|
|
const char *seconddata = getDataNodeByIndex(dataList, 2); // Assume this is image data
|
|
|
|
if (firstdata == NULL || seconddata == NULL) {
|
|
fprintf(stderr, "Not enough data.\n");
|
|
freeDataNodes(dataList);
|
|
return 1;
|
|
}
|
|
|
|
// Prepare output string for the text data
|
|
// char output[1024];
|
|
// int len = snprintf(output, sizeof(output), "First data: %s\n", firstdata);
|
|
printf("the fistdata %s", firstdata);
|
|
|
|
// Output the text data
|
|
free(d);
|
|
|
|
// Assuming seconddata contains image data in raw binary form.
|
|
// Directly write image data to stdout.
|
|
// write(1, seconddata, strlen(seconddata));
|
|
|
|
freeDataNodes(dataList);
|
|
|
|
return 0;
|
|
}
|