diff options
author | onefang | 2021-08-19 21:21:51 +1000 |
---|---|---|
committer | onefang | 2021-08-19 21:21:51 +1000 |
commit | b9ccbdff485d560534a2a3784cf09858d48965aa (patch) | |
tree | 83fb2c315490f6f5c4f964c29fa50527012ab887 | |
parent | No more create function for sledjchisl. (diff) | |
download | opensim-SC-b9ccbdff485d560534a2a3784cf09858d48965aa.zip opensim-SC-b9ccbdff485d560534a2a3784cf09858d48965aa.tar.gz opensim-SC-b9ccbdff485d560534a2a3784cf09858d48965aa.tar.bz2 opensim-SC-b9ccbdff485d560534a2a3784cf09858d48965aa.tar.xz |
Debug versions of shellMe sledjchisl internal functions.
-rw-r--r-- | src/sledjchisl/sledjchisl.c | 139 |
1 files changed, 92 insertions, 47 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 15184d8..52c746f 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c | |||
@@ -539,53 +539,6 @@ qhashtbl_t *mimeTypes; | |||
539 | qlist_t *dbRequests; | 539 | qlist_t *dbRequests; |
540 | 540 | ||
541 | 541 | ||
542 | int shellMeFail(char *format, ...) | ||
543 | { | ||
544 | va_list va, va2; | ||
545 | int len; | ||
546 | char *ret; | ||
547 | int result; | ||
548 | |||
549 | va_start(va, format); | ||
550 | va_copy(va2, va); | ||
551 | // How long is it? | ||
552 | len = vsnprintf(0, 0, format, va); | ||
553 | len++; | ||
554 | va_end(va); | ||
555 | // Allocate and do the sprintf() | ||
556 | ret = xmalloc(len); | ||
557 | vsnprintf(ret, len, format, va2); | ||
558 | va_end(va2); | ||
559 | |||
560 | result = !WIFEXITED(system(ret)); | ||
561 | free(ret); | ||
562 | return result; | ||
563 | } | ||
564 | |||
565 | int shellMe(char *format, ...) | ||
566 | { | ||
567 | va_list va, va2; | ||
568 | int len; | ||
569 | char *ret; | ||
570 | int result; | ||
571 | |||
572 | va_start(va, format); | ||
573 | va_copy(va2, va); | ||
574 | // How long is it? | ||
575 | len = vsnprintf(0, 0, format, va); | ||
576 | len++; | ||
577 | va_end(va); | ||
578 | // Allocate and do the sprintf() | ||
579 | ret = xmalloc(len); | ||
580 | vsnprintf(ret, len, format, va2); | ||
581 | va_end(va2); | ||
582 | |||
583 | result = system(ret); | ||
584 | free(ret); | ||
585 | return result; | ||
586 | } | ||
587 | |||
588 | |||
589 | // TODO - log to file. The problem is we don't know where to log until after we have loaded the configs, and before that we are spewing log messages. | 542 | // TODO - log to file. The problem is we don't know where to log until after we have loaded the configs, and before that we are spewing log messages. |
590 | // Now that we are using spawn-fcgi, all the logs are going to STDERR, which we can capture and write to a file. | 543 | // Now that we are using spawn-fcgi, all the logs are going to STDERR, which we can capture and write to a file. |
591 | // Unfortunately spawn-fcgi in deamon mode sends all the output to /dev/null or something. | 544 | // Unfortunately spawn-fcgi in deamon mode sends all the output to /dev/null or something. |
@@ -654,6 +607,98 @@ void logMe(int v, char *format, ...) | |||
654 | #define t(...) logMe(8, __VA_ARGS__) | 607 | #define t(...) logMe(8, __VA_ARGS__) |
655 | 608 | ||
656 | 609 | ||
610 | int shellMeFailVf(char *format, ...) | ||
611 | { | ||
612 | va_list va, va2; | ||
613 | int len; | ||
614 | char *ret; | ||
615 | int result = FALSE; | ||
616 | |||
617 | va_start(va, format); | ||
618 | va_copy(va2, va); | ||
619 | // How long is it? | ||
620 | len = vsnprintf(0, 0, format, va); | ||
621 | len++; | ||
622 | va_end(va); | ||
623 | // Allocate and do the sprintf() | ||
624 | ret = xmalloc(len); | ||
625 | vsnprintf(ret, len, format, va2); | ||
626 | va_end(va2); | ||
627 | |||
628 | V(ret); | ||
629 | free(ret); | ||
630 | return result; | ||
631 | } | ||
632 | int shellMeFailVt(char *format, ...) | ||
633 | { | ||
634 | va_list va, va2; | ||
635 | int len; | ||
636 | char *ret; | ||
637 | int result = TRUE; | ||
638 | |||
639 | va_start(va, format); | ||
640 | va_copy(va2, va); | ||
641 | // How long is it? | ||
642 | len = vsnprintf(0, 0, format, va); | ||
643 | len++; | ||
644 | va_end(va); | ||
645 | // Allocate and do the sprintf() | ||
646 | ret = xmalloc(len); | ||
647 | vsnprintf(ret, len, format, va2); | ||
648 | va_end(va2); | ||
649 | |||
650 | V(ret); | ||
651 | free(ret); | ||
652 | return result; | ||
653 | } | ||
654 | |||
655 | int shellMeFail(char *format, ...) | ||
656 | { | ||
657 | va_list va, va2; | ||
658 | int len; | ||
659 | char *ret; | ||
660 | int result; | ||
661 | |||
662 | va_start(va, format); | ||
663 | va_copy(va2, va); | ||
664 | // How long is it? | ||
665 | len = vsnprintf(0, 0, format, va); | ||
666 | len++; | ||
667 | va_end(va); | ||
668 | // Allocate and do the sprintf() | ||
669 | ret = xmalloc(len); | ||
670 | vsnprintf(ret, len, format, va2); | ||
671 | va_end(va2); | ||
672 | |||
673 | result = !WIFEXITED(system(ret)); | ||
674 | free(ret); | ||
675 | return result; | ||
676 | } | ||
677 | |||
678 | int shellMe(char *format, ...) | ||
679 | { | ||
680 | va_list va, va2; | ||
681 | int len; | ||
682 | char *ret; | ||
683 | int result; | ||
684 | |||
685 | va_start(va, format); | ||
686 | va_copy(va2, va); | ||
687 | // How long is it? | ||
688 | len = vsnprintf(0, 0, format, va); | ||
689 | len++; | ||
690 | va_end(va); | ||
691 | // Allocate and do the sprintf() | ||
692 | ret = xmalloc(len); | ||
693 | vsnprintf(ret, len, format, va2); | ||
694 | va_end(va2); | ||
695 | |||
696 | result = system(ret); | ||
697 | free(ret); | ||
698 | return result; | ||
699 | } | ||
700 | |||
701 | |||
657 | static void addStrL(qlist_t *list, char *s) | 702 | static void addStrL(qlist_t *list, char *s) |
658 | { | 703 | { |
659 | list->addlast(list, s, strlen(s) + 1); | 704 | list->addlast(list, s, strlen(s) + 1); |