Implemented dummy functionality

This commit is contained in:
Pierre Pronchery 2006-08-21 17:41:29 +00:00
parent eb7a662cc2
commit 5f699e75a5

View File

@ -6,6 +6,33 @@
#include <stdio.h>
/* cpp */
static int _cpp_error(char const * message, int ret);
static int _cpp(char const * filename)
{
FILE * fp;
char buf[BUFSIZ];
size_t len;
int ret = 0;
if((fp = fopen(filename, "r")) == NULL)
return _cpp_error(filename, 1);
while((len = fread(buf, sizeof(char), sizeof(buf), fp)) > 0)
fwrite(buf, sizeof(char), len, stdout);
if(len == 0 && !feof(fp))
ret = _cpp_error(filename, 1);
fclose(fp);
return ret;
}
static int _cpp_error(char const * message, int ret)
{
fprintf(stderr, "%s", "cpp: ");
perror(message);
return ret;
}
/* usage */
static int _usage(void)
{
@ -25,5 +52,7 @@ int main(int argc, char * argv[])
default:
return _usage();
}
return 2;
if(argc - optind != 1)
return _usage();
return _cpp(argv[optind]) == 0 ? 0 : 2;
}