From 0bd5a8a3314b1b6b8047dc31113bd5ead59d706e Mon Sep 17 00:00:00 2001 From: Bill Chatfield Date: Sun, 30 Jul 2017 19:51:23 -0400 Subject: [PATCH] Made corrections according to review comments --- doc/apple2enh.sgml | 105 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 3 deletions(-) diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 672f5d6aa..c7be9b474 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -519,9 +519,108 @@ url="ca65.html" name="assembler manual">. Specifying file types for fopen

-See section - -in the apple2 docoumentation. + + + Explanation of File Types + + ProDOS associates a file type and an auxiliary type with each file. + These type specifications are separate from the file's name, unlike + Windows which uses the file name's suffix (a.k.a. + extension) to specify the file type. For example, Specifying the File Type and Auxiliary Type + + There are two global variables provided that allow the file type + and auxiliary type to be specified before a call to + + extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ + extern unsigned int _auxtype; /* Default: 0 */ + + + + The header file Example + + A text file cannot be created with just the + standard C functions because they default to the binary type + + + #include <stdio.h> + #include <string.h> + #include <errno.h> + #include <apple2.h> + + void main(void) + { + FILE *out; + char *name = "MY.FAVS"; + + /*-----------------------------*/ + + _filetype = PRODOS_T_TXT; + _auxtype = PRODOS_AUX_T_TXT_SEQ; + + /*-----------------------------*/ + + if ((out = fopen(name, "w")) != NULL) { + fputs("Jorah Mormont\r", out); + fputs("Brienne of Tarth\r", out); + fputs("Daenerys Targaryen\r", out); + fputs("Sandor Clegane\r", out); + if (fclose(out) == EOF) { + fprintf(stderr, "fclose failed for %s: %s", name, strerror(errno)); + } + } + else { + fprintf(stderr, "fopen failed for %s: %s", name, strerror(errno)); + } + } + + + +

+ +