comparison dbutil.c @ 801:7dcb46da72d9 ecc

merge in HEAD
author Matt Johnston <matt@ucc.asn.au>
date Tue, 21 May 2013 12:09:35 +0800
parents 2202e854d187 d63ef1e211ea
children 4095b6d7c9fc
comparison
equal deleted inserted replaced
799:c344607b7341 801:7dcb46da72d9
136 } 136 }
137 137
138 138
139 #ifdef DEBUG_TRACE 139 #ifdef DEBUG_TRACE
140 void dropbear_trace(const char* format, ...) { 140 void dropbear_trace(const char* format, ...) {
141
142 va_list param; 141 va_list param;
142 struct timeval tv;
143 143
144 if (!debug_trace) { 144 if (!debug_trace) {
145 return; 145 return;
146 } 146 }
147 147
148 gettimeofday(&tv, NULL);
149
148 va_start(param, format); 150 va_start(param, format);
149 fprintf(stderr, "TRACE (%d): ", getpid()); 151 fprintf(stderr, "TRACE (%d) %d.%d: ", getpid(), tv.tv_sec, tv.tv_usec);
152 vfprintf(stderr, format, param);
153 fprintf(stderr, "\n");
154 va_end(param);
155 }
156
157 void dropbear_trace2(const char* format, ...) {
158 static int trace_env = -1;
159 va_list param;
160 struct timeval tv;
161
162 if (trace_env == -1) {
163 trace_env = getenv("DROPBEAR_TRACE2") ? 1 : 0;
164 }
165
166 if (!(debug_trace && trace_env)) {
167 return;
168 }
169
170 gettimeofday(&tv, NULL);
171
172 va_start(param, format);
173 fprintf(stderr, "TRACE2 (%d) %d.%d: ", getpid(), tv.tv_sec, tv.tv_usec);
150 vfprintf(stderr, format, param); 174 vfprintf(stderr, format, param);
151 fprintf(stderr, "\n"); 175 fprintf(stderr, "\n");
152 va_end(param); 176 va_end(param);
153 } 177 }
154 #endif /* DEBUG_TRACE */ 178 #endif /* DEBUG_TRACE */
731 #if defined(DROPBEAR_CLIENT) || defined(ENABLE_SVR_PUBKEY_AUTH) 755 #if defined(DROPBEAR_CLIENT) || defined(ENABLE_SVR_PUBKEY_AUTH)
732 int buf_getline(buffer * line, FILE * authfile) { 756 int buf_getline(buffer * line, FILE * authfile) {
733 757
734 int c = EOF; 758 int c = EOF;
735 759
736 TRACE(("enter buf_getline"))
737
738 buf_setpos(line, 0); 760 buf_setpos(line, 0);
739 buf_setlen(line, 0); 761 buf_setlen(line, 0);
740 762
741 while (line->pos < line->size) { 763 while (line->pos < line->size) {
742 764
756 out: 778 out:
757 779
758 780
759 /* if we didn't read anything before EOF or error, exit */ 781 /* if we didn't read anything before EOF or error, exit */
760 if (c == EOF && line->pos == 0) { 782 if (c == EOF && line->pos == 0) {
761 TRACE(("leave buf_getline: failure"))
762 return DROPBEAR_FAILURE; 783 return DROPBEAR_FAILURE;
763 } else { 784 } else {
764 TRACE(("leave buf_getline: success"))
765 buf_setpos(line, 0); 785 buf_setpos(line, 0);
766 return DROPBEAR_SUCCESS; 786 return DROPBEAR_SUCCESS;
767 } 787 }
768 788
769 } 789 }