diff options
author | jsing <> | 2014-04-16 16:34:09 +0000 |
---|---|---|
committer | jsing <> | 2014-04-16 16:34:09 +0000 |
commit | 08763273632988a5aee000dcd9d4f4f4a463aa77 (patch) | |
tree | 8a019c8c8de42453bfde72031d25919dcfff07a5 /src/lib | |
parent | 8a381b5ec35fe14b08d8825424ca84279b60deb5 (diff) | |
download | openbsd-08763273632988a5aee000dcd9d4f4f4a463aa77.tar.gz openbsd-08763273632988a5aee000dcd9d4f4f4a463aa77.tar.bz2 openbsd-08763273632988a5aee000dcd9d4f4f4a463aa77.zip |
More KNF.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libssl/src/apps/app_rand.c | 122 | ||||
-rw-r--r-- | src/lib/libssl/src/apps/apps.c | 97 |
2 files changed, 119 insertions, 100 deletions
diff --git a/src/lib/libssl/src/apps/app_rand.c b/src/lib/libssl/src/apps/app_rand.c index 66e47c417c..59fab2e269 100644 --- a/src/lib/libssl/src/apps/app_rand.c +++ b/src/lib/libssl/src/apps/app_rand.c | |||
@@ -5,21 +5,21 @@ | |||
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -63,7 +63,7 @@ | |||
63 | * are met: | 63 | * are met: |
64 | * | 64 | * |
65 | * 1. Redistributions of source code must retain the above copyright | 65 | * 1. Redistributions of source code must retain the above copyright |
66 | * notice, this list of conditions and the following disclaimer. | 66 | * notice, this list of conditions and the following disclaimer. |
67 | * | 67 | * |
68 | * 2. Redistributions in binary form must reproduce the above copyright | 68 | * 2. Redistributions in binary form must reproduce the above copyright |
69 | * notice, this list of conditions and the following disclaimer in | 69 | * notice, this list of conditions and the following disclaimer in |
@@ -119,76 +119,78 @@ | |||
119 | static int seeded = 0; | 119 | static int seeded = 0; |
120 | static int egdsocket = 0; | 120 | static int egdsocket = 0; |
121 | 121 | ||
122 | int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn) | 122 | int |
123 | { | 123 | app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn) |
124 | { | ||
124 | int consider_randfile = (file == NULL); | 125 | int consider_randfile = (file == NULL); |
125 | char buffer[200]; | 126 | char buffer[200]; |
126 | 127 | ||
127 | 128 | ||
128 | if (file == NULL) | 129 | if (file == NULL) |
129 | file = RAND_file_name(buffer, sizeof buffer); | 130 | file = RAND_file_name(buffer, sizeof buffer); |
130 | else if (RAND_egd(file) > 0) | 131 | else if (RAND_egd(file) > 0) { |
131 | { | ||
132 | /* we try if the given filename is an EGD socket. | 132 | /* we try if the given filename is an EGD socket. |
133 | if it is, we don't write anything back to the file. */ | 133 | if it is, we don't write anything back to the file. */ |
134 | egdsocket = 1; | 134 | egdsocket = 1; |
135 | return 1; | 135 | return 1; |
136 | } | 136 | } |
137 | if (file == NULL || !RAND_load_file(file, -1)) | 137 | if (file == NULL || !RAND_load_file(file, -1)) { |
138 | { | 138 | if (RAND_status() == 0) { |
139 | if (RAND_status() == 0) | 139 | if (!dont_warn) { |
140 | { | 140 | BIO_printf(bio_e, "unable to load 'random state'\n"); |
141 | if (!dont_warn) | 141 | BIO_printf(bio_e, "This means that the random number generator has not been seeded\n"); |
142 | { | 142 | BIO_printf(bio_e, "with much random data.\n"); |
143 | BIO_printf(bio_e,"unable to load 'random state'\n"); | ||
144 | BIO_printf(bio_e,"This means that the random number generator has not been seeded\n"); | ||
145 | BIO_printf(bio_e,"with much random data.\n"); | ||
146 | if (consider_randfile) /* explanation does not apply when a file is explicitly named */ | 143 | if (consider_randfile) /* explanation does not apply when a file is explicitly named */ |
147 | { | 144 | { |
148 | BIO_printf(bio_e,"Consider setting the RANDFILE environment variable to point at a file that\n"); | 145 | BIO_printf(bio_e, "Consider setting the RANDFILE environment variable to point at a file that\n"); |
149 | BIO_printf(bio_e,"'random' data can be kept in (the file will be overwritten).\n"); | 146 | BIO_printf(bio_e, "'random' data can be kept in (the file will be overwritten).\n"); |
150 | } | ||
151 | } | 147 | } |
152 | return 0; | ||
153 | } | 148 | } |
149 | return 0; | ||
154 | } | 150 | } |
151 | } | ||
155 | seeded = 1; | 152 | seeded = 1; |
156 | return 1; | 153 | return 1; |
157 | } | 154 | } |
158 | 155 | ||
159 | long app_RAND_load_files(char *name) | 156 | long |
160 | { | 157 | app_RAND_load_files(char *name) |
161 | char *p,*n; | 158 | { |
159 | char *p, *n; | ||
162 | int last; | 160 | int last; |
163 | long tot=0; | 161 | long tot = 0; |
164 | int egd; | 162 | int egd; |
165 | |||
166 | for (;;) | ||
167 | { | ||
168 | last=0; | ||
169 | for (p=name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++); | ||
170 | if (*p == '\0') last=1; | ||
171 | *p='\0'; | ||
172 | n=name; | ||
173 | name=p+1; | ||
174 | if (*n == '\0') break; | ||
175 | 163 | ||
176 | egd=RAND_egd(n); | 164 | for (;;) { |
165 | last = 0; | ||
166 | for (p = name; | ||
167 | ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++); | ||
168 | if (*p == '\0') | ||
169 | last = 1; | ||
170 | *p = '\0'; | ||
171 | n = name; | ||
172 | name = p + 1; | ||
173 | if (*n == '\0') | ||
174 | break; | ||
175 | |||
176 | egd = RAND_egd(n); | ||
177 | if (egd > 0) | 177 | if (egd > 0) |
178 | tot+=egd; | 178 | tot += egd; |
179 | else | 179 | else |
180 | tot+=RAND_load_file(n,-1); | 180 | tot += RAND_load_file(n, -1); |
181 | if (last) break; | 181 | if (last) |
182 | } | 182 | break; |
183 | } | ||
183 | if (tot > 512) | 184 | if (tot > 512) |
184 | app_RAND_allow_write_file(); | 185 | app_RAND_allow_write_file(); |
185 | return(tot); | 186 | return (tot); |
186 | } | 187 | } |
187 | 188 | ||
188 | int app_RAND_write_file(const char *file, BIO *bio_e) | 189 | int |
189 | { | 190 | app_RAND_write_file(const char *file, BIO *bio_e) |
191 | { | ||
190 | char buffer[200]; | 192 | char buffer[200]; |
191 | 193 | ||
192 | if (egdsocket || !seeded) | 194 | if (egdsocket || !seeded) |
193 | /* If we did not manage to read the seed file, | 195 | /* If we did not manage to read the seed file, |
194 | * we should not write a low-entropy seed file back -- | 196 | * we should not write a low-entropy seed file back -- |
@@ -198,15 +200,15 @@ int app_RAND_write_file(const char *file, BIO *bio_e) | |||
198 | 200 | ||
199 | if (file == NULL) | 201 | if (file == NULL) |
200 | file = RAND_file_name(buffer, sizeof buffer); | 202 | file = RAND_file_name(buffer, sizeof buffer); |
201 | if (file == NULL || !RAND_write_file(file)) | 203 | if (file == NULL || !RAND_write_file(file)) { |
202 | { | 204 | BIO_printf(bio_e, "unable to write 'random state'\n"); |
203 | BIO_printf(bio_e,"unable to write 'random state'\n"); | ||
204 | return 0; | 205 | return 0; |
205 | } | ||
206 | return 1; | ||
207 | } | 206 | } |
207 | return 1; | ||
208 | } | ||
208 | 209 | ||
209 | void app_RAND_allow_write_file(void) | 210 | void |
210 | { | 211 | app_RAND_allow_write_file(void) |
212 | { | ||
211 | seeded = 1; | 213 | seeded = 1; |
212 | } | 214 | } |
diff --git a/src/lib/libssl/src/apps/apps.c b/src/lib/libssl/src/apps/apps.c index 47347678e5..8a65754795 100644 --- a/src/lib/libssl/src/apps/apps.c +++ b/src/lib/libssl/src/apps/apps.c | |||
@@ -191,21 +191,24 @@ args_from_file(char *file, int *argc, char **argv[]) | |||
191 | *argc = 0; | 191 | *argc = 0; |
192 | *argv = NULL; | 192 | *argv = NULL; |
193 | 193 | ||
194 | if (buf != NULL) OPENSSL_free(buf); | 194 | if (buf != NULL) |
195 | buf = (char *)OPENSSL_malloc(len + 1); | 195 | OPENSSL_free(buf); |
196 | buf = (char *)OPENSSL_malloc(len + 1); | ||
196 | if (buf == NULL) | 197 | if (buf == NULL) |
197 | return (0); | 198 | return (0); |
198 | 199 | ||
199 | len = fread(buf, 1, len, fp); | 200 | len = fread(buf, 1, len, fp); |
200 | if (len <= 1) return (0); | 201 | if (len <= 1) |
201 | buf[len] = '\0'; | 202 | return (0); |
203 | buf[len] = '\0'; | ||
202 | 204 | ||
203 | i = 0; | 205 | i = 0; |
204 | for (p = buf; *p; p++) | 206 | for (p = buf; *p; p++) |
205 | if (*p == '\n') | 207 | if (*p == '\n') |
206 | i++; | 208 | i++; |
207 | if (arg != NULL) OPENSSL_free(arg); | 209 | if (arg != NULL) |
208 | arg = (char **)OPENSSL_malloc(sizeof(char *)*(i*2)); | 210 | OPENSSL_free(arg); |
211 | arg = (char **)OPENSSL_malloc(sizeof(char *)*(i*2)); | ||
209 | 212 | ||
210 | *argv = arg; | 213 | *argv = arg; |
211 | num = 0; | 214 | num = 0; |
@@ -384,7 +387,7 @@ chopup_args(ARGS *arg, char *buf, int *argc, char **argv[]) | |||
384 | if ((*p == '\'') || (*p == '\"')) /* scan for closing quote */ | 387 | if ((*p == '\'') || (*p == '\"')) /* scan for closing quote */ |
385 | { | 388 | { |
386 | i= *(p++); | 389 | i= *(p++); |
387 | arg->data[num-1]++; /* jump over quote */ | 390 | arg->data[num - 1]++; /* jump over quote */ |
388 | while (*p && (*p != i)) | 391 | while (*p && (*p != i)) |
389 | p++; | 392 | p++; |
390 | *p = '\0'; | 393 | *p = '\0'; |
@@ -448,7 +451,7 @@ ui_read(UI *ui, UI_STRING *uis) | |||
448 | case UIT_VERIFY: | 451 | case UIT_VERIFY: |
449 | { | 452 | { |
450 | const char *password = | 453 | const char *password = |
451 | ((PW_CB_DATA *)UI_get0_user_data(ui))->password; | 454 | ((PW_CB_DATA *)UI_get0_user_data(ui))->password; |
452 | if (password && password[0] != '\0') { | 455 | if (password && password[0] != '\0') { |
453 | UI_set_result(ui, uis, password); | 456 | UI_set_result(ui, uis, password); |
454 | return 1; | 457 | return 1; |
@@ -590,18 +593,23 @@ int | |||
590 | app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2) | 593 | app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2) |
591 | { | 594 | { |
592 | int same; | 595 | int same; |
593 | if (!arg2 || !arg1 || strcmp(arg1, arg2)) same = 0; | 596 | if (!arg2 || !arg1 || strcmp(arg1, arg2)) |
594 | else | 597 | same = 0; |
598 | else | ||
595 | same = 1; | 599 | same = 1; |
596 | if (arg1) { | 600 | if (arg1) { |
597 | *pass1 = app_get_pass(err, arg1, same); | 601 | *pass1 = app_get_pass(err, arg1, same); |
598 | if (!*pass1) return 0; | 602 | if (!*pass1) |
599 | } else if (pass1) *pass1 = NULL; | 603 | return 0; |
600 | if (arg2) { | 604 | } else if (pass1) |
605 | *pass1 = NULL; | ||
606 | if (arg2) { | ||
601 | *pass2 = app_get_pass(err, arg2, same ? 2 : 0); | 607 | *pass2 = app_get_pass(err, arg2, same ? 2 : 0); |
602 | if (!*pass2) return 0; | 608 | if (!*pass2) |
603 | } else if (pass2) *pass2 = NULL; | 609 | return 0; |
604 | return 1; | 610 | } else if (pass2) |
611 | *pass2 = NULL; | ||
612 | return 1; | ||
605 | } | 613 | } |
606 | 614 | ||
607 | static char * | 615 | static char * |
@@ -639,7 +647,8 @@ app_get_pass(BIO *err, char *arg, int keepbio) | |||
639 | } else if (!strncmp(arg, "fd:", 3)) { | 647 | } else if (!strncmp(arg, "fd:", 3)) { |
640 | BIO *btmp; | 648 | BIO *btmp; |
641 | i = atoi(arg + 3); | 649 | i = atoi(arg + 3); |
642 | if (i >= 0) pwdbio = BIO_new_fd(i, BIO_NOCLOSE); | 650 | if (i >= 0) |
651 | pwdbio = BIO_new_fd(i, BIO_NOCLOSE); | ||
643 | if ((i < 0) || !pwdbio) { | 652 | if ((i < 0) || !pwdbio) { |
644 | BIO_printf(err, "Can't access file descriptor %s\n", arg + 3); | 653 | BIO_printf(err, "Can't access file descriptor %s\n", arg + 3); |
645 | return NULL; | 654 | return NULL; |
@@ -669,8 +678,9 @@ app_get_pass(BIO *err, char *arg, int keepbio) | |||
669 | return NULL; | 678 | return NULL; |
670 | } | 679 | } |
671 | tmp = strchr(tpass, '\n'); | 680 | tmp = strchr(tpass, '\n'); |
672 | if (tmp) *tmp = 0; | 681 | if (tmp) |
673 | return BUF_strdup(tpass); | 682 | *tmp = 0; |
683 | return BUF_strdup(tpass); | ||
674 | } | 684 | } |
675 | 685 | ||
676 | int | 686 | int |
@@ -790,7 +800,7 @@ load_cert(BIO *err, const char *file, int format, const char *pass, ENGINE *e, | |||
790 | (pem_password_cb *)password_callback, NULL); | 800 | (pem_password_cb *)password_callback, NULL); |
791 | else if (format == FORMAT_PKCS12) { | 801 | else if (format == FORMAT_PKCS12) { |
792 | if (!load_pkcs12(err, cert, cert_descrip, NULL, NULL, | 802 | if (!load_pkcs12(err, cert, cert_descrip, NULL, NULL, |
793 | NULL, &x, NULL)) | 803 | NULL, &x, NULL)) |
794 | goto end; | 804 | goto end; |
795 | } else { | 805 | } else { |
796 | BIO_printf(err, "bad input format specified for %s\n", | 806 | BIO_printf(err, "bad input format specified for %s\n", |
@@ -802,8 +812,9 @@ end: | |||
802 | BIO_printf(err, "unable to load certificate\n"); | 812 | BIO_printf(err, "unable to load certificate\n"); |
803 | ERR_print_errors(err); | 813 | ERR_print_errors(err); |
804 | } | 814 | } |
805 | if (cert != NULL) BIO_free(cert); | 815 | if (cert != NULL) |
806 | return (x); | 816 | BIO_free(cert); |
817 | return (x); | ||
807 | } | 818 | } |
808 | 819 | ||
809 | EVP_PKEY * | 820 | EVP_PKEY * |
@@ -978,9 +989,10 @@ load_pubkey(BIO *err, const char *file, int format, int maybe_stdin, | |||
978 | goto end; | 989 | goto end; |
979 | } | 990 | } |
980 | end: | 991 | end: |
981 | if (key != NULL) BIO_free(key); | 992 | if (key != NULL) |
982 | if (pkey == NULL) | 993 | BIO_free(key); |
983 | BIO_printf(err, "unable to load %s\n", key_descrip); | 994 | if (pkey == NULL) |
995 | BIO_printf(err, "unable to load %s\n", key_descrip); | ||
984 | return (pkey); | 996 | return (pkey); |
985 | } | 997 | } |
986 | 998 | ||
@@ -1273,8 +1285,9 @@ set_multi_opts(unsigned long *flags, const char *arg, const NAME_EX_TBL *in_tbl) | |||
1273 | STACK_OF(CONF_VALUE) *vals; | 1285 | STACK_OF(CONF_VALUE) *vals; |
1274 | CONF_VALUE *val; | 1286 | CONF_VALUE *val; |
1275 | int i, ret = 1; | 1287 | int i, ret = 1; |
1276 | if (!arg) return 0; | 1288 | if (!arg) |
1277 | vals = X509V3_parse_list(arg); | 1289 | return 0; |
1290 | vals = X509V3_parse_list(arg); | ||
1278 | for (i = 0; i < sk_CONF_VALUE_num(vals); i++) { | 1291 | for (i = 0; i < sk_CONF_VALUE_num(vals); i++) { |
1279 | val = sk_CONF_VALUE_value(vals, i); | 1292 | val = sk_CONF_VALUE_value(vals, i); |
1280 | if (!set_table_opts(flags, val->name, in_tbl)) | 1293 | if (!set_table_opts(flags, val->name, in_tbl)) |
@@ -1560,9 +1573,11 @@ load_serial(char *serialfile, int create, ASN1_INTEGER **retai) | |||
1560 | ai = NULL; | 1573 | ai = NULL; |
1561 | } | 1574 | } |
1562 | err: | 1575 | err: |
1563 | if (in != NULL) BIO_free(in); | 1576 | if (in != NULL) |
1564 | if (ai != NULL) ASN1_INTEGER_free(ai); | 1577 | BIO_free(in); |
1565 | return (ret); | 1578 | if (ai != NULL) |
1579 | ASN1_INTEGER_free(ai); | ||
1580 | return (ret); | ||
1566 | } | 1581 | } |
1567 | 1582 | ||
1568 | int | 1583 | int |
@@ -1934,8 +1949,9 @@ void | |||
1934 | free_index(CA_DB *db) | 1949 | free_index(CA_DB *db) |
1935 | { | 1950 | { |
1936 | if (db) { | 1951 | if (db) { |
1937 | if (db->db) TXT_DB_free(db->db); | 1952 | if (db->db) |
1938 | OPENSSL_free(db); | 1953 | TXT_DB_free(db->db); |
1954 | OPENSSL_free(db); | ||
1939 | } | 1955 | } |
1940 | } | 1956 | } |
1941 | 1957 | ||
@@ -2641,8 +2657,9 @@ WIN32_rename(const char *from, const char *to) | |||
2641 | err: | 2657 | err: |
2642 | ret = -1; | 2658 | ret = -1; |
2643 | ok: | 2659 | ok: |
2644 | if (tfrom != NULL && tfrom != (TCHAR *)from) free(tfrom); | 2660 | if (tfrom != NULL && tfrom != (TCHAR *)from) |
2645 | return ret; | 2661 | free(tfrom); |
2662 | return ret; | ||
2646 | } | 2663 | } |
2647 | #endif | 2664 | #endif |
2648 | 2665 | ||
@@ -2662,10 +2679,11 @@ app_tminterval(int stop, int usertime) | |||
2662 | if (check_winnt()) | 2679 | if (check_winnt()) |
2663 | proc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, | 2680 | proc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, |
2664 | GetCurrentProcessId()); | 2681 | GetCurrentProcessId()); |
2665 | if (proc == NULL) proc = (HANDLE) - 1; | 2682 | if (proc == NULL) |
2666 | } | 2683 | proc = (HANDLE) - 1; |
2684 | } | ||
2667 | 2685 | ||
2668 | if (usertime && proc != (HANDLE) - 1) { | 2686 | if (usertime && proc != (HANDLE) - 1) { |
2669 | FILETIME junk; | 2687 | FILETIME junk; |
2670 | GetProcessTimes(proc, &junk, &junk, &junk, &now); | 2688 | GetProcessTimes(proc, &junk, &junk, &junk, &now); |
2671 | } else | 2689 | } else |
@@ -2685,8 +2703,7 @@ app_tminterval(int stop, int usertime) | |||
2685 | if (stop == TM_START) { | 2703 | if (stop == TM_START) { |
2686 | tmstart.u.LowPart = now.dwLowDateTime; | 2704 | tmstart.u.LowPart = now.dwLowDateTime; |
2687 | tmstart.u.HighPart = now.dwHighDateTime; | 2705 | tmstart.u.HighPart = now.dwHighDateTime; |
2688 | } | 2706 | } else { |
2689 | else { | ||
2690 | ULARGE_INTEGER tmstop; | 2707 | ULARGE_INTEGER tmstop; |
2691 | 2708 | ||
2692 | tmstop.u.LowPart = now.dwLowDateTime; | 2709 | tmstop.u.LowPart = now.dwLowDateTime; |
@@ -2817,7 +2834,7 @@ app_tminterval(int stop, int usertime) | |||
2817 | tmstart = now; | 2834 | tmstart = now; |
2818 | else | 2835 | else |
2819 | ret = ((now.tv_sec + now.tv_usec * 1e-6) - | 2836 | ret = ((now.tv_sec + now.tv_usec * 1e-6) - |
2820 | (tmstart.tv_sec + tmstart.tv_usec * 1e-6) ); | 2837 | (tmstart.tv_sec + tmstart.tv_usec * 1e-6)); |
2821 | 2838 | ||
2822 | return ret; | 2839 | return ret; |
2823 | } | 2840 | } |