Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "point_list.h"
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char *argv[]) {
- (void)argc;
- intrusive_list list;
- intrusive_list* l = &list;
- init_list(l);
- char *loadfmt = argv[1];
- char *infile = argv[2];
- FILE *fin = fopen(infile, "r");
- if (strcmp(loadfmt, "loadtext") == 0) {
- readtext(&list, fin);
- }
- else {
- readbin(&list, fin);
- }
- fclose(fin);
- char *action = argv[3];
- if (strcmp(action, "savetext") == 0) {
- char *outfile = argv[4];
- FILE *fout = fopen(outfile, "w");
- apply(&list, printtext, fout);
- fclose(fout);
- }
- if (strcmp(action, "savebin") == 0) {
- char *outfile = argv[4];
- FILE *fout = fopen(outfile, "w");
- apply(&list, printbin, fout);
- fclose(fout);
- }
- if (strcmp(action, "print") == 0) {
- char *fmt = argv[4];
- apply(&list, print, fmt);
- }
- if (strcmp(action, "count") == 0) {
- int counter = 0;
- apply(&list, count, &counter);
- printf("%d", counter);
- }
- remove_all_points(l);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement