diff options
author | Ton Voon <ton.voon@opsera.com> | 2010-06-21 13:03:24 +0100 |
---|---|---|
committer | Ton Voon <ton.voon@opsera.com> | 2010-06-21 13:03:24 +0100 |
commit | 602896277c76298bcbc152312d915dec306eda27 (patch) | |
tree | c37f9ec63b2a08915da3582e1ebbc9796de6f88f /lib | |
parent | f58aa8e66bbb4ecf23cf6add7efc574abb733d3a (diff) | |
download | monitoring-plugins-602896277c76298bcbc152312d915dec306eda27.tar.gz |
Change np_state_write_string() to not be a pointer
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tests/test_utils.c | 10 | ||||
-rw-r--r-- | lib/utils_base.c | 6 | ||||
-rw-r--r-- | lib/utils_base.h | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c index 6e04bfc7..e90d4fb5 100644 --- a/lib/tests/test_utils.c +++ b/lib/tests/test_utils.c | |||
@@ -355,7 +355,7 @@ main (int argc, char **argv) | |||
355 | unlink("var/generated"); | 355 | unlink("var/generated"); |
356 | temp_state_key->_filename="var/generated"; | 356 | temp_state_key->_filename="var/generated"; |
357 | current_time=1234567890; | 357 | current_time=1234567890; |
358 | np_state_write_string(¤t_time, "String to read"); | 358 | np_state_write_string(current_time, "String to read"); |
359 | ok(system("cmp var/generated var/statefile")==0, "Generated file same as expected"); | 359 | ok(system("cmp var/generated var/statefile")==0, "Generated file same as expected"); |
360 | 360 | ||
361 | 361 | ||
@@ -365,20 +365,20 @@ main (int argc, char **argv) | |||
365 | unlink("var/generated_directory"); | 365 | unlink("var/generated_directory"); |
366 | temp_state_key->_filename="var/generated_directory/statefile"; | 366 | temp_state_key->_filename="var/generated_directory/statefile"; |
367 | current_time=1234567890; | 367 | current_time=1234567890; |
368 | np_state_write_string(¤t_time, "String to read"); | 368 | np_state_write_string(current_time, "String to read"); |
369 | ok(system("cmp var/generated_directory/statefile var/statefile")==0, "Have created directory"); | 369 | ok(system("cmp var/generated_directory/statefile var/statefile")==0, "Have created directory"); |
370 | 370 | ||
371 | /* This test to check cannot write to dir - can't automate yet */ | 371 | /* This test to check cannot write to dir - can't automate yet */ |
372 | /* | 372 | /* |
373 | unlink("var/generated_bad_dir"); | 373 | unlink("var/generated_bad_dir"); |
374 | mkdir("var/generated_bad_dir", S_IRUSR); | 374 | mkdir("var/generated_bad_dir", S_IRUSR); |
375 | np_state_write_string(¤t_time, "String to read"); | 375 | np_state_write_string(current_time, "String to read"); |
376 | */ | 376 | */ |
377 | 377 | ||
378 | 378 | ||
379 | temp_state_key->_filename="var/generated"; | 379 | temp_state_key->_filename="var/generated"; |
380 | time(¤t_time); | 380 | time(¤t_time); |
381 | np_state_write_string(NULL, "String to read"); | 381 | np_state_write_string(0, "String to read"); |
382 | temp_state_data = np_state_read(temp_state_key); | 382 | temp_state_data = np_state_read(temp_state_key); |
383 | /* Check time is set to current_time */ | 383 | /* Check time is set to current_time */ |
384 | ok(system("cmp var/generated var/statefile > /dev/null")!=0, "Generated file should be different this time"); | 384 | ok(system("cmp var/generated var/statefile > /dev/null")!=0, "Generated file should be different this time"); |
@@ -388,7 +388,7 @@ main (int argc, char **argv) | |||
388 | /* Don't know how to automatically test this. Need to be able to redefine die and catch the error */ | 388 | /* Don't know how to automatically test this. Need to be able to redefine die and catch the error */ |
389 | /* | 389 | /* |
390 | temp_state_key->_filename="/dev/do/not/expect/to/be/able/to/write"; | 390 | temp_state_key->_filename="/dev/do/not/expect/to/be/able/to/write"; |
391 | np_state_write_string(NULL, "Bad file"); | 391 | np_state_write_string(0, "Bad file"); |
392 | */ | 392 | */ |
393 | 393 | ||
394 | 394 | ||
diff --git a/lib/utils_base.c b/lib/utils_base.c index 5eaf57bd..e6b20c87 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c | |||
@@ -519,7 +519,7 @@ int _np_state_read_file(FILE *f) { | |||
519 | * two things writing to same key at same time. | 519 | * two things writing to same key at same time. |
520 | * Will die with UNKNOWN if errors | 520 | * Will die with UNKNOWN if errors |
521 | */ | 521 | */ |
522 | void np_state_write_string(time_t *data_time, char *data_string) { | 522 | void np_state_write_string(time_t data_time, char *data_string) { |
523 | FILE *fp; | 523 | FILE *fp; |
524 | char *temp_file=NULL; | 524 | char *temp_file=NULL; |
525 | int fd=0, result=0; | 525 | int fd=0, result=0; |
@@ -528,10 +528,10 @@ void np_state_write_string(time_t *data_time, char *data_string) { | |||
528 | char *directories=NULL; | 528 | char *directories=NULL; |
529 | char *p=NULL; | 529 | char *p=NULL; |
530 | 530 | ||
531 | if(data_time==NULL) | 531 | if(data_time==0) |
532 | time(¤t_time); | 532 | time(¤t_time); |
533 | else | 533 | else |
534 | current_time=*data_time; | 534 | current_time=data_time; |
535 | 535 | ||
536 | /* If file doesn't currently exist, create directories */ | 536 | /* If file doesn't currently exist, create directories */ |
537 | if(access(this_nagios_plugin->state->_filename,F_OK)!=0) { | 537 | if(access(this_nagios_plugin->state->_filename,F_OK)!=0) { |
diff --git a/lib/utils_base.h b/lib/utils_base.h index 12576d7e..8f2f6649 100644 --- a/lib/utils_base.h +++ b/lib/utils_base.h | |||
@@ -95,7 +95,7 @@ char *np_extract_value(const char*, const char*, char); | |||
95 | 95 | ||
96 | void np_enable_state(char *, int); | 96 | void np_enable_state(char *, int); |
97 | state_data *np_state_read(); | 97 | state_data *np_state_read(); |
98 | void np_state_write_string(time_t *, char *); | 98 | void np_state_write_string(time_t, char *); |
99 | 99 | ||
100 | void np_init(char *); | 100 | void np_init(char *); |
101 | void np_cleanup(); | 101 | void np_cleanup(); |