Added catch command to hello.c
This commit is contained in:
parent
19ceb35c71
commit
dac5b0a7de
@ -15,17 +15,30 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <aos/aos.h>
|
#include <aos/aos.h>
|
||||||
|
|
||||||
|
#define HELLO_CATCH_COMMAND "catch"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
printf("Hello, world! from userspace\n");
|
printf("Hello, world!\n");
|
||||||
|
|
||||||
printf("argv:\n");
|
printf("argv:\n");
|
||||||
for(int i = 0; i < argc; ++i) {
|
for(int i = 0; i < argc; ++i) {
|
||||||
printf(" %d -> %s\n", i, argv[i]);
|
printf(" %d -> %s\n", i, argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we receive the catch command, RUN!
|
||||||
|
if (argc > 1 && !strncmp(argv[1], HELLO_CATCH_COMMAND, sizeof(HELLO_CATCH_COMMAND))) {
|
||||||
|
while(1) {
|
||||||
|
printf("Catch me if you can!\n");
|
||||||
|
// wait for 1 second
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user