just trying to read a goddamned file
Some checks failed
MVS Delete Members / delete-members (push) Failing after 13s
MVS Submit & Execute / upload-and-run (push) Failing after 44s

This commit is contained in:
Greg Gauthier 2026-02-08 16:14:06 +00:00
parent c30bdcebc9
commit e14f9f9db0
2 changed files with 34 additions and 15 deletions

View File

@ -1,6 +1,5 @@
//TXTWKR01 JOB (JCC),'JCC File I/O Test', //TXTWKR01 JOB (GCC),'File I/O Test',NOTIFY=@05054,CLASS=A,MSGCLASS=H,
// NOTIFY=@05054,CLASS=A,MSGCLASS=H,
// MSGLEVEL=(1,1),REGION=4M,TIME=1440 // MSGLEVEL=(1,1),REGION=4M,TIME=1440
//STEP1 EXEC JCCCLG,INFILE='@05054.SRCLIB.C(TXTWKR01)' //STEP1 EXEC GCCCG,INFILE='@05054.SRCLIB.C(TXTWKR01)'
//GO.TESTDD DD DSN=@05054.DATA(TESTMEM),DISP=SHR, //GO.TESTDD DD DSN=@05054.DATA(TESTMEM),DISP=SHR,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS) // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS)

View File

@ -1,26 +1,46 @@
#include <stdio> #include <stdio.h>
#include <string.h>
int main() #define MAX_LINES 100
#define LINE_LEN 256
int main(void)
{ {
printf((char *)"Program starting - about to fopen(dd:TESTDD, \"r\")\n");
FILE *fp; FILE *fp;
char buf[256]; char lines[MAX_LINES][LINE_LEN];
int count = 0;
char buf[LINE_LEN];
/* === Read phase === */
fp = fopen("dd:TESTDD", "r"); fp = fopen("dd:TESTDD", "r");
if (fp == NULL) { if (fp == NULL) {
printf((char *)"fopen returned NULL\n"); fputs("Cannot open for read\n", stdout);
printf((char *)"fopen read failed\n");
return 1; return 1;
} }
printf((char *)"fopen succeeded!\n"); fputs("Existing content:\n", stdout);
printf((char *)"Existing content:\n"); while (fgets(buf, LINE_LEN, fp) && count < MAX_LINES) {
while (fgets(buf, 256, fp) != NULL) { fputs(buf, stdout); /* echo to JES */
printf((char *)"%s", buf); strncpy(lines[count], buf, LINE_LEN-1);
lines[count][LINE_LEN-1] = '\0';
count++;
} }
fclose(fp); fclose(fp);
printf((char *)"Read complete.\n"); /* === Write phase (rewrite everything + append) === */
fp = fopen("dd:TESTDD", "w");
if (fp == NULL) {
fputs("Cannot open for write\n", stdout);
return 1;
}
for (int i = 0; i < count; i++) {
fputs(lines[i], fp);
}
fputs("Appended from C program!\n", fp);
fclose(fp);
fputs("Append complete (via rewrite).\n", stdout);
return 0; return 0;
} }