Implemented dummy functionality
This commit is contained in:
parent
eb7a662cc2
commit
5f699e75a5
31
src/cpp.c
31
src/cpp.c
|
@ -6,6 +6,33 @@
|
||||||
#include <stdio.h>
|
#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 */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
|
@ -25,5 +52,7 @@ int main(int argc, char * argv[])
|
||||||
default:
|
default:
|
||||||
return _usage();
|
return _usage();
|
||||||
}
|
}
|
||||||
return 2;
|
if(argc - optind != 1)
|
||||||
|
return _usage();
|
||||||
|
return _cpp(argv[optind]) == 0 ? 0 : 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user