michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /*********************************************************************** michael@0: ** michael@0: ** Name: op_2long.c michael@0: ** michael@0: ** Description: Test Program to verify the PR_NAME_TOO_LONG_ERROR michael@0: ** michael@0: ** Modification History: michael@0: ** 03-June-97 AGarcia- Initial version michael@0: ***********************************************************************/ michael@0: michael@0: /*********************************************************************** michael@0: ** Includes michael@0: ***********************************************************************/ michael@0: /* Used to get the command line option */ michael@0: #include "prinit.h" michael@0: #include "prmem.h" michael@0: #include "prio.h" michael@0: #include "prerror.h" michael@0: #include michael@0: #include "plerror.h" michael@0: #include "plgetopt.h" michael@0: michael@0: static PRFileDesc *t1; michael@0: PRIntn error_code; michael@0: michael@0: /* michael@0: * should exceed any system's maximum file name length michael@0: * Note: was set at 4096. This is legal on some unix (Linux 2.1+) platforms. michael@0: * michael@0: */ michael@0: #define TOO_LONG 5000 michael@0: michael@0: int main(int argc, char **argv) michael@0: { michael@0: char nameTooLong[TOO_LONG]; michael@0: int i; michael@0: michael@0: /* Generate a really long pathname */ michael@0: for (i = 0; i < TOO_LONG - 1; i++) { michael@0: if (i % 10 == 0) { michael@0: nameTooLong[i] = '/'; michael@0: } else { michael@0: nameTooLong[i] = 'a'; michael@0: } michael@0: } michael@0: nameTooLong[TOO_LONG - 1] = 0; michael@0: michael@0: PR_STDIO_INIT(); michael@0: t1 = PR_Open(nameTooLong, PR_RDWR, 0666); michael@0: if (t1 == NULL) { michael@0: if (PR_GetError() == PR_NAME_TOO_LONG_ERROR) { michael@0: PL_PrintError("error code is"); michael@0: printf ("PASS\n"); michael@0: return 0; michael@0: } michael@0: else { michael@0: PL_PrintError("error code is"); michael@0: printf ("FAIL\n"); michael@0: return 1; michael@0: } michael@0: } michael@0: michael@0: else { michael@0: printf ("Test passed\n"); michael@0: return 0; michael@0: } michael@0: michael@0: michael@0: michael@0: }