Lines Matching refs:w
359 writer_init( Writer* w, const char* fn ) in writer_init() argument
361 w->p = w->buff; in writer_init()
362 w->end = w->buff + sizeof(w->buff); in writer_init()
364 w->fd = creat( fn, 0755 ); in writer_init()
365 if (w->fd < 0) in writer_init()
369 _setmode( w->fd, _O_BINARY ); in writer_init()
375 writer_write( Writer* w, const char* src, int len ) in writer_write() argument
378 int avail = w->end - w->p; in writer_write()
383 memcpy( w->p, src, avail ); in writer_write()
387 w->p += avail; in writer_write()
388 if (w->p == w->end) { in writer_write()
391 ret = write( w->fd, w->buff, w->p - w->buff ); in writer_write()
395 w->p = w->buff; in writer_write()
401 writer_done( Writer* w ) in writer_done() argument
403 if (w->p > w->buff) { in writer_done()
406 ret = write( w->fd, w->buff, w->p - w->buff ); in writer_done()
409 close( w->fd ); in writer_done()
413 writer_margin( Writer* w, int margin) in writer_margin() argument
417 writer_write(w,spaces,10); in writer_margin()
421 writer_write(w,spaces,margin); in writer_margin()
425 writer_c(Writer* w, char c) in writer_c() argument
427 writer_write(w, &c, 1); in writer_c()
431 writer_str(Writer* w, const char* str) in writer_str() argument
433 writer_write(w, str, strlen(str)); in writer_str()
437 writer_node(Writer* w, AConfig* node, int margin) in writer_node() argument
439 writer_margin(w,margin); in writer_node()
440 writer_str(w, node->name); in writer_node()
441 writer_c(w,' '); in writer_node()
444 writer_str(w, node->value); in writer_node()
445 writer_c(w,'\n'); in writer_node()
451 writer_c(w, '{'); in writer_node()
452 writer_c(w, '\n'); in writer_node()
455 writer_node(w,child,margin+4); in writer_node()
457 writer_margin(w,margin); in writer_node()
458 writer_c(w,'}'); in writer_node()
459 writer_c(w,'\n'); in writer_node()
467 Writer w[1]; in aconfig_save_file() local
469 if (writer_init(w,fn) < 0) in aconfig_save_file()
473 writer_node(w,child,0); in aconfig_save_file()
475 writer_done(w); in aconfig_save_file()