File tree 2 files changed +6
-84
lines changed
2 files changed +6
-84
lines changed Original file line number Diff line number Diff line change @@ -239,58 +239,19 @@ $ make
239
239
``` c
240
240
#include " tbox/tbox.h"
241
241
242
- int main (int argc, char** argv)
243
- {
244
- // init tbox
242
+ int main (int argc, char** argv) {
245
243
if (!tb_init(tb_null, tb_null)) return 0;
246
244
247
- // trace
248
- tb_trace_i("hello tbox");
249
-
250
- // init vector
251
245
tb_vector_ref_t vector = tb_vector_init(0, tb_element_str(tb_true));
252
- if (vector)
253
- {
254
- // insert item
246
+ if (vector) {
255
247
tb_vector_insert_tail(vector, "hello");
256
248
tb_vector_insert_tail(vector, "tbox");
257
249
258
- // dump all items
259
- tb_for_all (tb_char_t const*, cstr, vector)
260
- {
261
- // trace
250
+ tb_for_all (tb_char_t const*, cstr, vector) {
262
251
tb_trace_i("%s", cstr);
263
252
}
264
-
265
- // exit vector
266
253
tb_vector_exit(vector);
267
254
}
268
-
269
- // init stream
270
- tb_stream_ref_t stream = tb_stream_init_from_url("http://www.xxx.com/file.txt");
271
- if (stream)
272
- {
273
- // open stream
274
- if (tb_stream_open(stream))
275
- {
276
- // read line
277
- tb_long_t size = 0;
278
- tb_char_t line[TB_STREAM_BLOCK_MAXN];
279
- while ((size = tb_stream_bread_line(stream, line, sizeof(line))) >= 0)
280
- {
281
- // trace
282
- tb_trace_i("line: %s", line);
283
- }
284
- }
285
-
286
- // exit stream
287
- tb_stream_exit(stream);
288
- }
289
-
290
- // wait
291
- tb_getchar();
292
-
293
- // exit tbox
294
255
tb_exit();
295
256
return 0;
296
257
}
Original file line number Diff line number Diff line change @@ -246,58 +246,19 @@ $ make
246
246
``` c
247
247
#include " tbox/tbox.h"
248
248
249
- int main (int argc, char** argv)
250
- {
251
- // init tbox
249
+ int main (int argc, char** argv) {
252
250
if (!tb_init(tb_null, tb_null)) return 0;
253
251
254
- // trace
255
- tb_trace_i("hello tbox");
256
-
257
- // init vector
258
252
tb_vector_ref_t vector = tb_vector_init(0, tb_element_str(tb_true));
259
- if (vector)
260
- {
261
- // insert item
253
+ if (vector) {
262
254
tb_vector_insert_tail(vector, "hello");
263
255
tb_vector_insert_tail(vector, "tbox");
264
256
265
- // dump all items
266
- tb_for_all (tb_char_t const*, cstr, vector)
267
- {
268
- // trace
257
+ tb_for_all (tb_char_t const*, cstr, vector) {
269
258
tb_trace_i("%s", cstr);
270
259
}
271
-
272
- // exit vector
273
260
tb_vector_exit(vector);
274
261
}
275
-
276
- // init stream
277
- tb_stream_ref_t stream = tb_stream_init_from_url("http://www.xxx.com/file.txt");
278
- if (stream)
279
- {
280
- // open stream
281
- if (tb_stream_open(stream))
282
- {
283
- // read line
284
- tb_long_t size = 0;
285
- tb_char_t line[TB_STREAM_BLOCK_MAXN];
286
- while ((size = tb_stream_bread_line(stream, line, sizeof(line))) >= 0)
287
- {
288
- // trace
289
- tb_trace_i("line: %s", line);
290
- }
291
- }
292
-
293
- // exit stream
294
- tb_stream_exit(stream);
295
- }
296
-
297
- // wait
298
- tb_getchar();
299
-
300
- // exit tbox
301
262
tb_exit();
302
263
return 0;
303
264
}
You can’t perform that action at this time.
0 commit comments