#include #include #include #include #include #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; }