The R Project SVN R

Rev

Rev 53611 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 53611 Rev 72823
Line 1... Line 1...
1
#include <stdlib.h>
1
#include <stdlib.h>
2
#include <stdio.h>
2
#include <stdio.h>
3
#include <string.h>
3
#include <string.h>
4
 
4
 
-
 
5
#ifdef _WIN32 /* for sleep function */
-
 
6
 
-
 
7
#include <windows.h>
-
 
8
 
-
 
9
void mysleep(int sec) {
-
 
10
    Sleep((DWORD)sec * 1000);
-
 
11
}
-
 
12
 
-
 
13
#else /* Unix/POSIX */
-
 
14
 
-
 
15
#include <unistd.h>
-
 
16
 
-
 
17
void mysleep(int sec) {
-
 
18
    /* could use nanosleep, but on Solaris it needs -lrt  */
-
 
19
    sleep(sec);
-
 
20
}
-
 
21
#endif
-
 
22
 
5
int main(int argc, char* argv[])
23
int main(int argc, char* argv[])
6
{
24
{
7
    int status = 0;
25
    int status = 0;
8
    char line[1000];
26
    char line[1000];
9
 
27
 
Line 14... Line 32...
14
    if (argc > 1 && strcmp(argv[1], "1") == 0) {
32
    if (argc > 1 && strcmp(argv[1], "1") == 0) {
15
	while(fgets(line, 1000, stdin)) printf("stdin: %s", line);
33
	while(fgets(line, 1000, stdin)) printf("stdin: %s", line);
16
	fflush(stdout);
34
	fflush(stdout);
17
    }
35
    }
18
    if (argc > 1 && strcmp(argv[1], "1")) {
36
    if (argc > 1 && strcmp(argv[1], "1")) {
19
	status = atof(argv[1]);
37
	status = atoi(argv[1]);
-
 
38
    }
-
 
39
    if (argc > 1 && strcmp(argv[1], "infinite_loop") == 0) {
-
 
40
	printf("Going to infinite loop...\n");
-
 
41
	fflush(stdout);
-
 
42
	while(1); /* infinite loop */
-
 
43
    }
-
 
44
    if (argc > 2 && strcmp(argv[1], "sleep") == 0) {
-
 
45
	int sec = atoi(argv[2]);
-
 
46
	printf("Sleeping for %d seconds...\n", sec);
-
 
47
	fflush(stdout);
-
 
48
	mysleep(sec);
-
 
49
	printf("Done sleeping for %d seconds.\n", sec);
-
 
50
	fflush(stdout);
20
    }
51
    }
21
    
52
    
22
    exit(status);
53
    exit(status);
23
}
54
}