-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlongline.h
More file actions
42 lines (31 loc) · 1.26 KB
/
longline.h
File metadata and controls
42 lines (31 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include "alloc.h"
/*Routines for reading/writing strings of arbitrary length.
Copyright (C) 2000,2001,2002 Brian Langenberger
Released under the terms of the GNU Public License.
See the file "COPYING" for full details.*/
#define BLOCKLENGTH 1024
struct StringBlock {
char block[BLOCKLENGTH];
int length;
struct StringBlock *next;
};
/*This prints the entire list of blocks to the given stream.*/
void printLongLine(FILE *stream, struct StringBlock *block);
/*This reads in one or more blocks from the stream, or returns NULL
if EOF is reached.*/
struct StringBlock *readBlocks(FILE *stream);
/*This frees up all the allocated space in the given blocks.*/
void freeBlocks(struct StringBlock *block);
/*This returns the length of the string.*/
int lineLength(struct StringBlock *block);
/*This is a strcmp for long lines.*/
int cmpLongLine(struct StringBlock *a, struct StringBlock *b);
/*This converts the list of blocks to a normal string.*/
char *buildString(struct StringBlock *block);
/*This returns a long string from the given stream, which must
be free()ed later on.*/
char *readLongLine(FILE *stream);
/*This is a wrapper around readBlocks that strips out comments
and blank lines.*/
struct StringBlock *readStrippedBlocks(FILE *file);