comparison src/core/ngx_string.c @ 338:0376cffa29e6

nginx-0.0.3-2004-05-20-21:33:52 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 20 May 2004 17:33:52 +0000
parents 87e73f067470
children 8c5b69141dfd
comparison
equal deleted inserted replaced
337:4feff829a849 338:0376cffa29e6
61 value = value * 10 + (*line - '0'); 61 value = value * 10 + (*line - '0');
62 } 62 }
63 63
64 if (value < 0) { 64 if (value < 0) {
65 return NGX_ERROR; 65 return NGX_ERROR;
66
67 } else {
68 return value;
69 }
70 }
71
72
73 ngx_int_t ngx_hextoi(u_char *line, size_t n)
74 {
75 u_char ch;
76 ngx_int_t value;
77
78 if (n == 0) {
79 return NGX_ERROR;
80 }
81
82 for (value = 0; n--; line++) {
83 ch = *line;
84
85 if (ch >= '0' && ch <= '9') {
86 value = value * 16 + (ch - '0');
87 continue;
88 }
89
90 if (ch >= 'A' && ch <= 'F') {
91 value = value * 16 + (*line - 'A');
92 continue;
93 }
94
95 if (ch >= 'a' && ch <= 'f') {
96 value = value * 16 + (*line - 'a');
97 continue;
98 }
99
100 return NGX_ERROR;
101 }
102
103 if (value < 0) {
104 return NGX_ERROR;
105
66 } else { 106 } else {
67 return value; 107 return value;
68 } 108 }
69 } 109 }
70 110