Gert Hulselmans
2010-May-04 00:07 UTC
[syslinux] [PATCH] cat.c32: check if filename exists
cat.c32: check if filename exists. Signed-off-by: Gert Hulselmans <gerth at zytor.com> --- com32/samples/cat.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/com32/samples/cat.c b/com32/samples/cat.c index 16380b0..3930f74 100644 --- a/com32/samples/cat.c +++ b/com32/samples/cat.c @@ -15,13 +15,18 @@ int main(int argc, char *argv[]) printf("argv[%d] = %p = \"%s\"\n", i, argv[i], argv[i]); if (argc < 2) { - fprintf(stderr, "Missing file name!\n"); - exit(1); + fprintf(stderr, "Usage: cat.c32 filename\n"); + return 1; } printf("File = %s\n", argv[1]); f = fopen(argv[1], "r"); + if (!f) { + fprintf(stderr, "File name \"%s\" does not exist.\n", argv[1]); + return 1; + } + while ((ch = getc(f)) != EOF) putchar(ch); -- 1.6.0.4
Michael D. Setzer II
2010-May-04 04:27 UTC
[syslinux] [PATCH] cat.c32: check if filename exists
On 3 May 2010 at 17:07, Gert Hulselmans wrote: Date sent: Mon, 3 May 2010 17:07:43 -0700 From: "Gert Hulselmans" <gerth at zytor.com> To: "For discussion of Syslinux and tftp-hpa" <syslinux at zytor.com> Subject: [syslinux] [PATCH] cat.c32: check if filename exists Send reply to: For discussion of Syslinux and tftp-hpa <syslinux at zytor.com> <mailto:syslinux- request at zytor.com?subject=unsubscribe> <mailto:syslinux-request at zytor.com?subject=subscribe>> cat.c32: check if filename exists. >Related to this. I have used a modified version of cat.c32 to display some text files from the isolinux menu. Just built a new image using the pre-40, and it locks when trying to display the file. I also have the original display.c32 and tried it from the command prompt, and it freezes as well. Ctrl-Alt-Del doesn't restart it. Power off only. Two other issues? At the very beginning, it flashes a Hello, World from (hello.c) message? The hdt when displaying the syslinux information seems to get a new line before the version, and throws of the screen. The syslinux seems to work fine with the rest of the menus? Tested on an AMD FX cpu system.> Signed-off-by: Gert Hulselmans <gerth at zytor.com> > --- > com32/samples/cat.c | 9 +++++++-- > 1 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/com32/samples/cat.c b/com32/samples/cat.c > index 16380b0..3930f74 100644 > --- a/com32/samples/cat.c > +++ b/com32/samples/cat.c > @@ -15,13 +15,18 @@ int main(int argc, char *argv[]) > printf("argv[%d] = %p = \"%s\"\n", i, argv[i], argv[i]); > > if (argc < 2) { > - fprintf(stderr, "Missing file name!\n"); > - exit(1); > + fprintf(stderr, "Usage: cat.c32 filename\n"); > + return 1; > } > > printf("File = %s\n", argv[1]); > > f = fopen(argv[1], "r"); > + if (!f) { > + fprintf(stderr, "File name \"%s\" does not exist.\n", argv[1]); > + return 1; > + } > + > while ((ch = getc(f)) != EOF) > putchar(ch); > > -- > 1.6.0.4 > > _______________________________________________ > Syslinux mailing list > Submissions to Syslinux at zytor.com > Unsubscribe or set options at: > http://www.zytor.com/mailman/listinfo/syslinux > Please do not send private replies to mailing list traffic. >+----------------------------------------------------------+ Michael D. Setzer II - Computer Science Instructor Guam Community College Computer Center mailto:mikes at kuentos.guam.net mailto:msetzerii at gmail.com http://www.guam.net/home/mikes Guam - Where America's Day Begins +----------------------------------------------------------+ http://setiathome.berkeley.edu (Original) Number of Seti Units Returned: 19,471 Processing time: 32 years, 290 days, 12 hours, 58 minutes (Total Hours: 287,489) BOINC at HOME CREDITS SETI 9628412.959704 | EINSTEIN 3959636.800851 ROSETTA 1894882.412180 | ABC 790361.739164