This repository has been archived by the owner on Jul 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
GeneralGuy4872
committed
Dec 5, 2019
1 parent
4d87b2a
commit b8ce3e8
Showing
7 changed files
with
670 additions
and
264 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
struct singlestringlistyp * singlegetline (char * path) { | ||
FILE * openfile = fopen(path,"r"); | ||
char[BUFFERMAX] buffer; | ||
struct singlestringlsityp * head; | ||
struct singlestringlistyp * prev; | ||
struct singlestringlistyp * this; | ||
if (fgets(buffer,BUFFERMAX-1,openfile) != NULL) { | ||
head = malloc(sizeof(struct singlestringlistyp)); | ||
head->next = NULL; | ||
head->lineno = 1; | ||
head->text = calloc(strlen(buffer) + 1,sizeof(char)); | ||
prev = head; | ||
for (int n = 2;fgets(buffer,BUFFERMAX - 1,openfile) != NULL;n++) { | ||
this = malloc(sizeof(struct singlestringlistyp)); | ||
prev->next = this; | ||
this->next = NULL; | ||
this->lineno = n; | ||
this->text = calloc(strlen(buffer) + 1,sizeof(char)); | ||
prev = this; | ||
} | ||
return head; | ||
} | ||
else { | ||
return NULL; | ||
} | ||
} | ||
|
||
char ** singlegetlinearray (char * path,ushort nlines,ushort * skip) { | ||
char ** output = calloc(nlines,sizeof(char *)); | ||
struct singlestringlistyp * line = singlegetline(path); | ||
int nextskip = 0; | ||
int x = 0; | ||
if skip != NULL { | ||
while ((x < nlines) && (line != NULL) && (skip[nextskip] != 0)) { | ||
if (line->lineno != skip[nextskip]) { | ||
output[x] = line->text; | ||
} | ||
else { | ||
nextskip++; | ||
} | ||
line = line->next; | ||
x++;} | ||
} | ||
while ((x < nlines) && (line != NULL)) { | ||
output[x] = line->text; | ||
line = line->next; | ||
x++;} | ||
return output; | ||
} | ||
|
Oops, something went wrong.