nsprpub/pr/tests/op_2long.c

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /***********************************************************************
michael@0 7 **
michael@0 8 ** Name: op_2long.c
michael@0 9 **
michael@0 10 ** Description: Test Program to verify the PR_NAME_TOO_LONG_ERROR
michael@0 11 **
michael@0 12 ** Modification History:
michael@0 13 ** 03-June-97 AGarcia- Initial version
michael@0 14 ***********************************************************************/
michael@0 15
michael@0 16 /***********************************************************************
michael@0 17 ** Includes
michael@0 18 ***********************************************************************/
michael@0 19 /* Used to get the command line option */
michael@0 20 #include "prinit.h"
michael@0 21 #include "prmem.h"
michael@0 22 #include "prio.h"
michael@0 23 #include "prerror.h"
michael@0 24 #include <stdio.h>
michael@0 25 #include "plerror.h"
michael@0 26 #include "plgetopt.h"
michael@0 27
michael@0 28 static PRFileDesc *t1;
michael@0 29 PRIntn error_code;
michael@0 30
michael@0 31 /*
michael@0 32 * should exceed any system's maximum file name length
michael@0 33 * Note: was set at 4096. This is legal on some unix (Linux 2.1+) platforms.
michael@0 34 *
michael@0 35 */
michael@0 36 #define TOO_LONG 5000
michael@0 37
michael@0 38 int main(int argc, char **argv)
michael@0 39 {
michael@0 40 char nameTooLong[TOO_LONG];
michael@0 41 int i;
michael@0 42
michael@0 43 /* Generate a really long pathname */
michael@0 44 for (i = 0; i < TOO_LONG - 1; i++) {
michael@0 45 if (i % 10 == 0) {
michael@0 46 nameTooLong[i] = '/';
michael@0 47 } else {
michael@0 48 nameTooLong[i] = 'a';
michael@0 49 }
michael@0 50 }
michael@0 51 nameTooLong[TOO_LONG - 1] = 0;
michael@0 52
michael@0 53 PR_STDIO_INIT();
michael@0 54 t1 = PR_Open(nameTooLong, PR_RDWR, 0666);
michael@0 55 if (t1 == NULL) {
michael@0 56 if (PR_GetError() == PR_NAME_TOO_LONG_ERROR) {
michael@0 57 PL_PrintError("error code is");
michael@0 58 printf ("PASS\n");
michael@0 59 return 0;
michael@0 60 }
michael@0 61 else {
michael@0 62 PL_PrintError("error code is");
michael@0 63 printf ("FAIL\n");
michael@0 64 return 1;
michael@0 65 }
michael@0 66 }
michael@0 67
michael@0 68 else {
michael@0 69 printf ("Test passed\n");
michael@0 70 return 0;
michael@0 71 }
michael@0 72
michael@0 73
michael@0 74
michael@0 75 }

mercurial