diff --git a/jcl/TXTWKR01.jcl b/jcl/TXTWKR01.jcl index fae4722..dbc788d 100644 --- a/jcl/TXTWKR01.jcl +++ b/jcl/TXTWKR01.jcl @@ -2,4 +2,4 @@ // NOTIFY=@05054,CLASS=A,MSGCLASS=H, // MSGLEVEL=(1,1),REGION=4M,TIME=1440 //STEP1 EXEC JCCCLG,INFILE='@05054.SRCLIB.C(TXTWKR01)' -//GO.TESTDD DD DSN=@05054.DATA(TESTMEM),DISP=SHR \ No newline at end of file +//GO.TESTDD DD DSN=@05054.DATA(TESTMEM),DISP=SHR diff --git a/src/TXTWKR01.c b/src/TXTWKR01.c index 7ab86bc..4037096 100644 --- a/src/TXTWKR01.c +++ b/src/TXTWKR01.c @@ -1,49 +1,22 @@ #include -#include - -#define BUFFER_SIZE 256 - -/* Simple program to read and append to a single PDS member via DD name. */ -/* Author: Greg Gauthier */ -/* Date: 2026-02-08 */ -/* NOTE: No single-line comments due to MVS SYSIN/JCL interpretation. */ int main() { - FILE *fp_read; - FILE *fp_append; - char buffer[BUFFER_SIZE]; + FILE *fp; + char buf[256]; - /* First: open for reading only to dump current content */ - fp_read = fopen("dd:TESTDD", "r"); - if (fp_read == NULL) - { - perror("fopen read failed"); - printf("errno = %d\n", __errno()); + fp = fopen("dd:TESTDD", "r"); + if (fp == NULL) { + printf((char *)"fopen read failed\n"); return 1; } - printf("Existing content:\n"); - while (fgets(buffer, BUFFER_SIZE, fp_read) != NULL) - { - printf("%s", buffer); + printf((char *)"Existing content:\n"); + while (fgets(buf, 256, fp) != NULL) { + printf((char *)"%s", buf); } - fclose(fp_read); - - /* Second: open for append only to add the new line */ - fp_append = fopen("dd:TESTDD", "a"); - if (fp_append == NULL) - { - perror("fopen append failed"); - printf("errno = %d\n", __errno()); - return 1; - } - - fprintf(fp_append, "Appended from C program!\n"); - fclose(fp_append); - - printf("Append complete.\n"); + fclose(fp); + printf((char *)"Read complete.\n"); return 0; -} - +} \ No newline at end of file