Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
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_nofil.c |
michael@0 | 9 | ** |
michael@0 | 10 | ** Description: Test Program to verify the PR_FILE_NOT_FOUND_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 "plgetopt.h" |
michael@0 | 26 | |
michael@0 | 27 | /* |
michael@0 | 28 | * A file name that cannot exist |
michael@0 | 29 | */ |
michael@0 | 30 | #define NO_SUCH_FILE "/no/such/file.tmp" |
michael@0 | 31 | |
michael@0 | 32 | static PRFileDesc *t1; |
michael@0 | 33 | |
michael@0 | 34 | int main(int argc, char **argv) |
michael@0 | 35 | { |
michael@0 | 36 | PR_STDIO_INIT(); |
michael@0 | 37 | t1 = PR_Open(NO_SUCH_FILE, PR_RDONLY, 0666); |
michael@0 | 38 | if (t1 == NULL) { |
michael@0 | 39 | if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) { |
michael@0 | 40 | printf ("error code is PR_FILE_NOT_FOUND_ERROR, as expected\n"); |
michael@0 | 41 | printf ("PASS\n"); |
michael@0 | 42 | return 0; |
michael@0 | 43 | } else { |
michael@0 | 44 | printf ("error code is %d \n", PR_GetError()); |
michael@0 | 45 | printf ("FAIL\n"); |
michael@0 | 46 | return 1; |
michael@0 | 47 | } |
michael@0 | 48 | } |
michael@0 | 49 | printf ("File %s exists on this machine!?\n", NO_SUCH_FILE); |
michael@0 | 50 | if (PR_Close(t1) == PR_FAILURE) { |
michael@0 | 51 | printf ("cannot close file\n"); |
michael@0 | 52 | printf ("error code is %d \n", PR_GetError()); |
michael@0 | 53 | } |
michael@0 | 54 | printf ("FAIL\n"); |
michael@0 | 55 | return 1; |
michael@0 | 56 | } |