loading file int gtktextview widget
This is relevant to both C programming and Linux. I decided to post here.
I Have that port monitor UI I wrote and that i am building on. Now I wanted to load a file into a gtktextview widget.
How would I go about doing this?
I have thought about loading the file into a buffer, with C programming.
Something like this
Code:
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
FILE *file;
char buffer[4096];
file = fopen("/home/annonymous/Documents/netstat.txt", "r+");
if(file == NULL) {
printf("FOPEN(NULL) error --> %s.\n", strerror(errno));
exit(EXIT_FAILURE);
}
file = fopen("/home/annonymous/Documents/netstat.txt", "r+");
if(file < 0) {
printf("FOPEN(-1) error --> %s", strerror(errno));
exit(EXIT_FAILURE);
}
fread(buffer, sizeof(buffer), 1, file);
if(file < 0) {
printf("FREAD(-1) error --> %s", strerror(errno));
exit(EXIT_FAILURE);
}
printf("%s", buffer);
return 0;
}
Then incorporate it into the UI. I ran into some conflicting types though. The buffer needed for the UI is of type struct. While the C buffer is obviously not. I am looking for a different way. More specifically a function made for just this. Thanks.
FOR ALL THE PEOPLE WHO HELPED ON THE BASH SCRIPT; Ultimately I will want all the opened ports other than 443 and 80 displayed in the UI. Thanks again!
Ideas? Thanks.