Move LINELIST to util.c

This commit is contained in:
Augusto Gunsch 2020-11-20 20:31:31 -03:00
parent aa1898fd66
commit e456ace07b
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
5 changed files with 22 additions and 13 deletions

8
main.c
View File

@ -12,14 +12,6 @@ char* getoutname(char* fname, int fnamelen) {
return outf;
}
void printlns(LINELIST* lns, FILE* stream) {
LINELIST* curln = lns;
while(curln != NULL) {
fprintf(stream, "%s\n", curln->content);
curln = curln->next;
}
}
int main(int argc, char* argv[]) {
if(argc < 2) {
printf("Usage: %s {input}\n", argv[0]);

View File

@ -4,6 +4,7 @@
#include <stdlib.h>
#include <ctype.h>
#include "parser.h"
#include "util.h"
void pushln(LINELIST** curln, char* tmpln, int lnind, int truen) {
int size = (lnind+1)*sizeof(char);

View File

@ -1,14 +1,11 @@
#ifndef PARSER_H
#define PARSER_H
#include <stdio.h>
#include "util.h"
#define INST_LIMIT 1<<15
typedef struct lnls {
char* content;
int truen;
struct lnls* next;
} LINELIST;
typedef struct {
FILE* input;

8
util.c
View File

@ -22,3 +22,11 @@ int countplaces(int n) {
}
return places;
}
void printlns(LINELIST* lns, FILE* stream) {
LINELIST* curln = lns;
while(curln != NULL) {
fprintf(stream, "%s\n", curln->content);
curln = curln->next;
}
}

11
util.h
View File

@ -1,5 +1,16 @@
#ifndef UTIL_H
#define UTIL_H
#include <stdio.h>
char* heapstr(const char* str, int len);
int countplaces(int n);
typedef struct lnls {
char* content;
int truen;
struct lnls* next;
} LINELIST;
void printlns(LINELIST* lns, FILE* stream);
#endif