This is a discussion on fgets() equivalent? - Unix ; HS> fgets() is standard in C file I/O. HS> HS> The only issue you need to pay attention too, is HS> RAW (binary) vs COOK mode. It will relate the HS> EOL (end of line) definitions of MS-DOS HS> ( ...
HS> fgets() is standard in C file I/O.
HS> The only issue you need to pay attention too, is
HS> RAW (binary) vs COOK mode. It will relate the
HS> EOL (end of line) definitions of MS-DOS
) vs Unix ( ). Depending on
HS> your application that may or may no pertain.
HS> More examples:
HS> // opens the file in text mode, cooked.
HS> FILE *fvt = fopen("crap1.txt","wt");
HS> fprintf(fvt,"%s\n",string); <-- note \n
HS> // opens the file in binary mode, raw
HS> FILE *fvb = fopen("crap2.txt","wb");
HS> fprintf(fvb,"%s\r\n",string); <-- note \r\n
TR> This is a handy definition, but it is NOT CORRECT.
TR> Cooked mode in a Unix terminal program means
TR> "line at a time". The program cannot read anything
TR> until the user has pressed Return or Enter. Raw
TR> mode means "character at a time". Each keypress
TR> is returned to the program as soon as it is
HS> I would like to see an official definition of that. By
HS> your definition, TELNET and all telecommunication
HS> programs in the annals of computers is both RAW
HS> and COOKED. [...]
If you want to see an official definition then run, do not walk, to
your nearest copy of the _Single UNIX (R) Specification, Version 2_ and
read about canonical and non-canonical input modes, in the General
Terminal Interface chapter of the XBD section. Then read the
Interface Overview of the XCURSES section.
TR> The raw vs cooked distinction in Unix is VERY
TR> different from the binary vs text distinction in
TR> MS-DOS. As others have tried to point out,
TR> raw vs cooked mode in Unix applies ONLY to
TR> terminals. It has no meaning for text files.
HS> Not quite and its probably not worth your time
HS> and mine, debating it.
HS> COOK vs RAW is what it is, COOK is a
HS> translation of some kind being done,
HS> RAW means its no translation.
HS> In terminal servers, hitting
HS> could be that the CLIENT software
HS> will send the
HS> pair. [...]
You are still, as M. Roberts and others have pointed out, confusing
text file newline conventions (and C language stream modes) with Unix
terminal input processing modes.