openenvutils/commandshell/shell/test/src/cat.c
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <stdio.h>
       
    20 
       
    21 /**
       
    22 * External command cat to display the contents of a file
       
    23 */
       
    24 int main(int *argc, char *argv[])
       
    25 {
       
    26 	int ret=0;
       
    27 	int c;
       
    28 	FILE *fp;
       
    29 	printf("Cat external command\n");
       
    30 	fp = fopen(*(argv+1), "r");
       
    31 	if(!fp)
       
    32 		{
       
    33 		printf("File %s not found\n",*(argv+1));
       
    34 		return 1;
       
    35 		}
       
    36 	while((c=fgetc(fp)) != EOF)
       
    37 	{
       
    38 		putchar(c);
       
    39 	}
       
    40 	fclose(fp);
       
    41 	return 0;
       
    42 }