Lines Matching refs:rp
68 lws_ranges_next(struct lws_range_parsing *rp) in lws_ranges_next() argument
74 char c = rp->buf[rp->pos]; in lws_ranges_next()
76 switch (rp->state) { in lws_ranges_next()
82 rp->state = LWSRS_COMPLETED; in lws_ranges_next()
86 if (c != beq[rp->pos]) { in lws_ranges_next()
87 rp->state = LWSRS_SYNTAX; in lws_ranges_next()
90 if (rp->pos == 5) in lws_ranges_next()
91 rp->state = LWSRS_FIRST; in lws_ranges_next()
95 rp->start = 0; in lws_ranges_next()
96 rp->end = 0; in lws_ranges_next()
97 rp->start_valid = 0; in lws_ranges_next()
98 rp->end_valid = 0; in lws_ranges_next()
100 rp->state = LWSRS_STARTING; in lws_ranges_next()
106 rp->state = LWSRS_ENDING; in lws_ranges_next()
111 rp->state = LWSRS_SYNTAX; in lws_ranges_next()
114 …rp->start = (unsigned long long)(((unsigned long long)rp->start * 10) + (unsigned long long)(c - '… in lws_ranges_next()
115 rp->start_valid = 1; in lws_ranges_next()
120 rp->state = LWSRS_FIRST; in lws_ranges_next()
122 rp->pos++; in lws_ranges_next()
129 if (!rp->start_valid) { /* eg, -500 */ in lws_ranges_next()
130 if (rp->end > rp->extent) in lws_ranges_next()
131 rp->end = rp->extent; in lws_ranges_next()
133 rp->start = rp->extent - rp->end; in lws_ranges_next()
134 rp->end = rp->extent - 1; in lws_ranges_next()
136 if (!rp->end_valid) in lws_ranges_next()
137 rp->end = rp->extent - 1; in lws_ranges_next()
139 rp->did_try = 1; in lws_ranges_next()
142 if (rp->end < rp->start) { in lws_ranges_next()
145 rp->state = LWSRS_COMPLETED; in lws_ranges_next()
153 rp->state = LWSRS_SYNTAX; in lws_ranges_next()
156 …rp->end = (unsigned long long)(((unsigned long long)rp->end * 10) + (unsigned long long)(c - '0')); in lws_ranges_next()
157 rp->end_valid = 1; in lws_ranges_next()
161 rp->pos++; in lws_ranges_next()
166 lws_ranges_reset(struct lws_range_parsing *rp) in lws_ranges_reset() argument
168 rp->pos = 0; in lws_ranges_reset()
169 rp->ctr = 0; in lws_ranges_reset()
170 rp->start = 0; in lws_ranges_reset()
171 rp->end = 0; in lws_ranges_reset()
172 rp->start_valid = 0; in lws_ranges_reset()
173 rp->end_valid = 0; in lws_ranges_reset()
174 rp->state = LWSRS_BYTES_EQ; in lws_ranges_reset()
181 lws_ranges_init(struct lws *wsi, struct lws_range_parsing *rp, in lws_ranges_init() argument
184 rp->agg = 0; in lws_ranges_init()
185 rp->send_ctr = 0; in lws_ranges_init()
186 rp->inside = 0; in lws_ranges_init()
187 rp->count_ranges = 0; in lws_ranges_init()
188 rp->did_try = 0; in lws_ranges_init()
189 lws_ranges_reset(rp); in lws_ranges_init()
190 rp->state = LWSRS_COMPLETED; in lws_ranges_init()
192 rp->extent = extent; in lws_ranges_init()
194 if (lws_hdr_copy(wsi, (char *)rp->buf, sizeof(rp->buf), in lws_ranges_init()
198 rp->state = LWSRS_BYTES_EQ; in lws_ranges_init()
200 while (lws_ranges_next(rp)) { in lws_ranges_init()
201 rp->count_ranges++; in lws_ranges_init()
202 rp->agg += rp->end - rp->start + 1; in lws_ranges_init()
205 lwsl_debug("%s: count %d\n", __func__, rp->count_ranges); in lws_ranges_init()
206 lws_ranges_reset(rp); in lws_ranges_init()
208 if (rp->did_try && !rp->count_ranges) in lws_ranges_init()
211 lws_ranges_next(rp); in lws_ranges_init()
213 return rp->count_ranges; in lws_ranges_init()