Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various improvements eg rc file (.quirc)
- Loading branch information
Sound and Fury
committed
Jul 27, 2010
1 parent
5a53f10
commit 709dc6b
Showing
6 changed files
with
155 additions
and
40 deletions.
There are no files selected for viewing
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,4 @@ | |||
*~ | *~ | ||
quirc | quirc | ||
*.o | *.o | ||
.quirc-shadow |
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
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,36 @@ | |||
#include "bits.h" | |||
|
|||
char * fgetl(FILE *fp) | |||
{ | |||
char * lout = (char *)malloc(81); | |||
int i=0; | |||
signed int c; | |||
while(!feof(fp)) | |||
{ | |||
c=fgetc(fp); | |||
if(c==EOF) // EOF without '\n' - we'd better put an '\n' in | |||
c='\n'; | |||
if(c!=0) | |||
{ | |||
lout[i++]=c; | |||
if((i%80)==0) | |||
{ | |||
if((lout=(char *)realloc(lout, i+81))==NULL) | |||
{ | |||
printf("\nNot enough memory to store input!\n"); | |||
free(lout); | |||
return(NULL); | |||
} | |||
} | |||
} | |||
if(c=='\n') // we do want to keep them this time | |||
break; | |||
} | |||
lout[i]=0; | |||
char *nlout=(char *)realloc(lout, i+1); | |||
if(nlout==NULL) | |||
{ | |||
return(lout); // it doesn't really matter (assuming realloc is a decent implementation and hasn't nuked the original pointer), we'll just have to temporarily waste a bit of memory | |||
} | |||
return(nlout); | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
/* | |||
quIRC - simple terminal-based IRC client | |||
Copyright (C) 2010 Edward Cree | |||
See quirc.c for license information | |||
bits: general helper functions | |||
*/ | |||
|
|||
#include <stdio.h> | |||
#include <stdlib.h> | |||
|
|||
char * fgetl(FILE *); // gets a line of string data; returns a malloc-like pointer (preserves trailing \n) |
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
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