-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
562d5af
commit f2ca360
Showing
29 changed files
with
455 additions
and
889 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
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 |
---|---|---|
@@ -1,37 +1,21 @@ | ||
/* | ||
* $Id: charin.c,v 1.6 2008/07/15 07:40:54 bnv Exp $ | ||
* $Log: charin.c,v $ | ||
* Revision 1.6 2008/07/15 07:40:54 bnv | ||
* #include changed from <> to "" | ||
* | ||
* Revision 1.5 2004/03/26 22:50:22 bnv | ||
* *** empty log message *** | ||
* | ||
* Revision 1.4 2002/06/11 12:37:15 bnv | ||
* Added: CDECL | ||
* | ||
* Revision 1.3 2001/06/25 18:49:48 bnv | ||
* Header changed to Id | ||
* | ||
* Revision 1.2 1999/11/26 09:53:14 bnv | ||
* Changed: To use the new macros. | ||
* | ||
* Revision 1.1 1998/07/02 17:17:00 bnv | ||
* Initial revision | ||
* | ||
*/ | ||
|
||
/* VM/370 CMS and GCCLIB charin.c */ | ||
#include <stdio.h> | ||
#include "lstring.h" | ||
|
||
/* ---------------- Lcharin ------------------- */ | ||
void __CDECL | ||
Lcharin( FILEP f, const PLstr line, const long start, const long length ) | ||
{ | ||
if (start>=1) | ||
FSEEK(f,start-1,SEEK_SET); | ||
if (length<=0) { | ||
LZEROSTR(*line); | ||
return; | ||
} | ||
Lread(f,line,length); | ||
int l; | ||
|
||
if (start>=1) { | ||
l = fseek(f,start-1,SEEK_SET); | ||
if (l) | ||
Lerror(ERR_NOT_RANDOM_ACCESS,0); | ||
} | ||
if (length<=0) { | ||
LZEROSTR(*line); | ||
return; | ||
} | ||
Lread(f,line,length); | ||
} /* Lcharin */ |
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,16 @@ | ||
/* | ||
* $Id: chars.c,v 1.7 2008/07/15 07:40:54 bnv Exp $ | ||
* $Log: chars.c,v $ | ||
* Revision 1.7 2008/07/15 07:40:54 bnv | ||
* #include changed from <> to "" | ||
* | ||
* Revision 1.6 2008/07/14 13:08:16 bnv | ||
* MVS,CMS support | ||
* | ||
* Revision 1.5 2004/03/26 22:50:22 bnv | ||
* Modified to handle FIFO, Devices and files | ||
* | ||
* Revision 1.4 2002/06/11 12:37:15 bnv | ||
* Added: CDECL | ||
* | ||
* Revision 1.3 2001/06/25 18:49:48 bnv | ||
* Header changed to Id | ||
* | ||
* Revision 1.2 1999/11/26 09:53:28 bnv | ||
* Changed: To use the new macros. | ||
* | ||
* Revision 1.1 1998/07/02 17:17:00 bnv | ||
* Initial revision | ||
* | ||
*/ | ||
|
||
#if !defined(WIN) && !defined(__CMS__) && !defined(__MVS__) | ||
# include <sys/stat.h> | ||
# include <unistd.h> | ||
#endif | ||
/* VM/370 CMS and GCCLIB chars.c */ | ||
|
||
#include <stdio.h> | ||
#include "lstring.h" | ||
|
||
/* ---------------- Lchars ------------------- */ | ||
long __CDECL | ||
Lchars( FILEP f ) | ||
long Lchars( FILEP f ) | ||
{ | ||
#if defined(WCE) && !defined(__BORLANDC__) | ||
return GetFileSize(f->handle,NULL) - FTELL(f); | ||
#else | ||
long l,chs; | ||
|
||
#if !defined(WIN) && !defined(__CMS__) && !defined(__MVS__) | ||
struct stat buf; | ||
fstat(fileno(f),&buf); | ||
if (S_ISCHR(buf.st_mode) || S_ISFIFO(buf.st_mode)) | ||
return !FEOF(f); | ||
#endif | ||
|
||
l = FTELL(f); /* read current position */ | ||
FSEEK(f,0L,SEEK_END); /* seek at the end */ | ||
chs = FTELL(f) - l ; | ||
FSEEK(f,l,SEEK_SET); | ||
return chs; | ||
#endif | ||
long l; | ||
l = ftell(f); /* read current position */ | ||
if (l==-1) { | ||
/* File does not support character counting */ | ||
return !fateof(f); | ||
} | ||
return fgetlen(f) - l; | ||
} /* Lchars */ |
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
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
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,46 @@ | ||
/* | ||
* $Id: linein.c,v 1.6 2008/07/15 07:40:54 bnv Exp $ | ||
* $Log: linein.c,v $ | ||
* Revision 1.6 2008/07/15 07:40:54 bnv | ||
* #include changed from <> to "" | ||
* | ||
* Revision 1.5 2002/06/11 12:37:15 bnv | ||
* Added: CDECL | ||
* | ||
* Revision 1.4 2001/06/25 18:49:48 bnv | ||
* Header changed to Id | ||
* | ||
* Revision 1.3 1999/11/26 12:52:25 bnv | ||
* Changed: To use the new macros. | ||
* | ||
* Revision 1.2 1999/03/15 15:25:53 bnv | ||
* Corrected: initial value to prev | ||
* | ||
* Revision 1.1 1998/07/02 17:18:00 bnv | ||
* Initial Version | ||
* | ||
*/ | ||
/* VM/370 CMS and GCCLIB linein.c */ | ||
|
||
#include <stdio.h> | ||
#include <errno.h> | ||
#include "lstring.h" | ||
|
||
|
||
/* ---------------- Llinein ------------------- */ | ||
void __CDECL | ||
Llinein( FILEP f, const PLstr line, long *curline, long start, long length ) | ||
Llinein( FILEP f, const PLstr line, long start, long length ) | ||
{ | ||
int ch,prev='\n'; | ||
Lstr aux; | ||
int l, i; | ||
char *c; | ||
|
||
/* initialise line */ | ||
LZEROSTR(*line); | ||
/* initialise line */ | ||
LZEROSTR(*line); | ||
|
||
/* find current line */ | ||
if (start>=0) { | ||
if (*curline>start) { | ||
*curline = 1; | ||
FSEEK(f,0,SEEK_SET); | ||
} | ||
while (start>*curline) { | ||
ch = FGETC(f); | ||
if (ch==EOF) { | ||
if (prev!='\n') (*curline)++; | ||
break; | ||
} | ||
if (ch=='\n') (*curline)++; | ||
prev = ch; | ||
/* find start line */ | ||
if (start>=0) { | ||
if (!fsetrec(f,start)) { | ||
if (errno==ENOTBLK) Lerror(ERR_NOT_RECORD_ACCESS,0); | ||
else Lerror(ERR_INCORRECT_CALL,0); | ||
} | ||
} | ||
if (start > *curline) return; | ||
} | ||
|
||
if (length<=0) return; | ||
if (length<=0) return; | ||
|
||
else if (length==1) Lread(f,line,LREADLINE); | ||
|
||
if (length==1) { | ||
Lread(f,line,LREADLINE); | ||
(*curline)++; | ||
} else { | ||
LINITSTR(aux); | ||
while (length) { | ||
Lread(f,&aux,LREADLINE); | ||
Lstrcat(line,&aux); | ||
if (length>1) | ||
Lcat(line,"\n"); | ||
(*curline)++; | ||
length--; | ||
else { | ||
Lfx(line,LREADINCSIZE); | ||
l = 0; | ||
while (length && (i=nextrecLen(f))>0) { | ||
if (l+i > LMAXLEN(*line)) { | ||
Lfx(line, (size_t)(l+i+LREADINCSIZE)); | ||
} | ||
c = LSTR(*line) + l; | ||
fgets(c, i+1, f); | ||
l+=i; | ||
length--; | ||
} | ||
Lfx(line,l); /* Give back unwanted memory */ | ||
LLEN(*line) = l; | ||
LTYPE(*line) = LSTRING_TY; | ||
} | ||
LFREESTR(aux); | ||
} | ||
} /* Llinein */ |
Oops, something went wrong.