tclose_block.c - tomb - the crypto undertaker
HTML git clone git://parazyd.org/tomb.git
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
tclose_block.c (796B)
---
1 /*
2 * Small program which simply opens a file in a tomb to block the
3 * $ tomb close
4 * operation
5 *
6 * Hard coded assumption on command line arguments
7 * 2) Path to open
8 * 3) How long to open the file (in seconds and can be optional)
9 */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <unistd.h>
14
15
16 int main(int argc, char const *argv[]) {
17 FILE *file_ptr;
18 unsigned int to_wait=10;
19
20 if ( argc < 2 ) {
21 fprintf(stderr, "Usage: %s path [time]\n", argv[0]);
22 exit(EXIT_FAILURE);
23 }
24
25 if ( argc == 3 ) {
26 to_wait = atoi(argv[2]);
27 }
28
29 file_ptr = fopen(argv[1],"w");
30
31 if ( file_ptr == NULL ) {
32 fprintf(stderr, "Error while opening the file.\n");
33 exit(EXIT_FAILURE);
34 }
35
36 sleep(to_wait);
37
38 fclose(file_ptr);
39
40 return 0;
41 }