openenvutils/commandshell/shell/test/src/cat.c
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 10:12:00 +0200
changeset 0 2e3d3ce01487
permissions -rw-r--r--
Revision: 201002 Kit: 201005

/*
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/


#include <stdio.h>

/**
* External command cat to display the contents of a file
*/
int main(int *argc, char *argv[])
{
	int ret=0;
	int c;
	FILE *fp;
	printf("Cat external command\n");
	fp = fopen(*(argv+1), "r");
	if(!fp)
		{
		printf("File %s not found\n",*(argv+1));
		return 1;
		}
	while((c=fgetc(fp)) != EOF)
	{
		putchar(c);
	}
	fclose(fp);
	return 0;
}