syck.c File Reference
`#include "ruby/ruby.h"`
`#include <stdio.h>`
`#include <string.h>`
`#include "syck.h"`

Go to the source code of this file.

## Data Structures

struct | bytestring_t

## Functions

void | syck_parser_pop_level (SyckParser *)
void | syck_assert (const char *file_name, unsigned line_num, const char *expr)
char * | syck_strndup (const char *buf, long len)
long | syck_io_file_read (char *buf, SyckIoFile *file, long max_size, long skip)
long | syck_io_str_read (char *buf, SyckIoStr *str, long max_size, long skip)
void | syck_parser_reset_levels (SyckParser *p)
void | syck_parser_reset_cursor (SyckParser *p)
void | syck_parser_set_root_on_error (SyckParser *p, SYMID roer)
SyckParser * | syck_new_parser (void)
int | syck_add_sym (SyckParser *p, void *data)
int | syck_lookup_sym (SyckParser *p, SYMID id, void **datap)
int | syck_st_free_nodes (char *key, SyckNode *n, char *arg)
void | syck_st_free (SyckParser *p)
int | syck_st_free_syms (void *key, bytestring_t *sav, void *dummy)
void | syck_free_parser (SyckParser *p)
void | syck_parser_handler (SyckParser *p, SyckNodeHandler hdlr)
void | syck_parser_implicit_typing (SyckParser *p, int flag)
void | syck_parser_taguri_expansion (SyckParser *p, int flag)
void | syck_parser_error_handler (SyckParser *p, SyckErrorHandler hdlr)
void | syck_parser_bad_anchor_handler (SyckParser *p, SyckBadAnchorHandler hdlr)
void | syck_parser_set_input_type (SyckParser *p, enum syck_parser_input input_type)
void | syck_parser_file (SyckParser *p, FILE *fp, SyckIoFileRead read)
void | syck_parser_str (SyckParser *p, char *ptr, long len, SyckIoStrRead read)
void | syck_parser_str_auto (SyckParser *p, char *ptr, SyckIoStrRead read)
SyckLevel * | syck_parser_current_level (SyckParser *p)
void | syck_parser_add_level (SyckParser *p, int len, enum syck_level_status status)
void | free_any_io (SyckParser *p)
long | syck_move_tokens (SyckParser *p)
void | syck_check_limit (SyckParser *p, long len)
long | syck_parser_read (SyckParser *p)
long | syck_parser_readlen (SyckParser *p, long max_size)
SYMID | syck_parse (SyckParser *p)
void | syck_default_error_handler (SyckParser *p, const char *msg)

## Function Documentation

void free_any_io | ( | SyckParser * | p | ) |

Definition at line 400 of file syck.c.

References ASSERT, _syck_parser::file, _syck_parser::io, _syck_parser::io_type, NULL, S_FREE, _syck_parser::str, syck_io_file, and syck_io_str.

Referenced by syck_free_parser(), syck_parser_file(), and syck_parser_str().

int syck_add_sym | ( | SyckParser * | p,
|  | void * | data
| ) |  |

Definition at line 180 of file syck.c.

References id, NULL, st_table::num_entries, st_init_numtable, st_insert, SYMID, and _syck_parser::syms.

Referenced by syck_yaml2byte_handler().

void syck_assert | ( | const char * | file_name,
|  | unsigned | line_num,
|  | const char * | expr
| ) |  |

Definition at line 21 of file syck.c.

References NULL.

void syck_check_limit | ( | SyckParser * | p,
|  | long | len
| ) |  |

Definition at line 449 of file syck.c.

References _syck_parser::buffer, _syck_parser::cursor, len, _syck_parser::limit, _syck_parser::linectptr, _syck_parser::lineptr, _syck_parser::marker, and NULL.

Referenced by syck_parser_read(), and syck_parser_readlen().

void syck_default_error_handler | ( | SyckParser * | p,
|  | const char * | msg
| ) |  |

Definition at line 517 of file syck.c.

References _syck_parser::cursor, _syck_parser::linect, _syck_parser::lineptr, and PRIdPTRDIFF.

Referenced by syckerror().

void syck_free_parser | ( | SyckParser * | p | ) |

Definition at line 249 of file syck.c.

References _syck_parser::buffer, _syck_level::domain, free_any_io(), _syck_parser::levels, NULL, S_FREE, st_foreach, st_free_table, syck_parser_reset_levels(), syck_st_free(), syck_st_free_syms(), and _syck_parser::syms.

Referenced by rb_syck_compile(), rb_syck_free_parser(), and syck_yaml2byte().

long syck_io_file_read | ( | char * | buf,
|  | SyckIoFile * | file,
|  | long | max_size,
|  | long | skip
| ) |  |

Definition at line 46 of file syck.c.

References ASSERT, len, NULL, and _syck_file::ptr.

Referenced by syck_parser_file().

long syck_io_str_read | ( | char * | buf,
|  | SyckIoStr * | str,
|  | long | max_size,
|  | long | skip
| ) |  |

Definition at line 64 of file syck.c.

References ASSERT, _syck_str::end, len, NULL, _syck_str::ptr, and S_MEMCPY.

Referenced by syck_parser_str().

int syck_lookup_sym | ( | SyckParser * | p,
|  | SYMID | id,
|  | void ** | datap
| ) |  |

Definition at line 193 of file syck.c.

References emitter_xtra::data, NULL, st_lookup, and _syck_parser::syms.

Referenced by rb_syck_compile(), syck_yaml2byte(), and syck_yaml2byte_handler().

long syck_move_tokens | ( | SyckParser * | p | ) |

Definition at line 424 of file syck.c.

References ASSERT, _syck_parser::buffer, count, _syck_parser::cursor, _syck_parser::limit, _syck_parser::linectptr, _syck_parser::lineptr, _syck_parser::marker, NULL, S_MEMMOVE, _syck_parser::token, and _syck_parser::toktmp.

Referenced by syck_parser_read(), and syck_parser_readlen().

SyckParser* syck_new_parser | ( | void |  | ) |

Definition at line 157 of file syck.c.

References ALLOC_CT, _syck_parser::anchors, _syck_parser::bad_anchors, _syck_parser::buffer, _syck_parser::bufsize, _syck_parser::implicit_typing, _syck_parser::input_type, _syck_parser::io, _syck_parser::io_type, _syck_parser::levels, _syck_parser::lvl_capa, _syck_parser::lvl_idx, NULL, p, S_ALLOC, S_ALLOC_N, S_MEMZERO, _syck_parser::str, SYCK_BUFFERSIZE, syck_io_str, syck_parser_reset_levels(), syck_yaml_utf8, _syck_parser::syms, and _syck_parser::taguri_expansion.

Referenced by rb_syck_compile(), syck_parser_s_alloc(), and syck_yaml2byte().

SYMID syck_parse | ( | SyckParser * | p | ) |

Definition at line 506 of file syck.c.

References ASSERT, NULL, _syck_parser::root, syck_parser_reset_levels(), syck_st_free(), and syckparse().

Referenced by rb_syck_compile(), syck_parser_load(), syck_parser_load_documents(), and syck_yaml2byte().

void syck_parser_add_level | ( | SyckParser * | p,
|  | int | len,
|  | enum syck_level_status | status
| ) |  |

Definition at line 382 of file syck.c.

References ALLOC_CT, ASSERT, _syck_level::domain, len, _syck_parser::levels, _syck_parser::lvl_capa, _syck_parser::lvl_idx, _syck_level::ncount, NULL, S_REALLOC_N, _syck_level::spaces, _syck_level::status, strlen(), and syck_strndup().

void syck_parser_bad_anchor_handler | ( | SyckParser * | p,
|  | SyckBadAnchorHandler | hdlr
| ) |  |

Definition at line 304 of file syck.c.

References ASSERT, _syck_parser::bad_anchor_handler, and NULL.

Referenced by syck_set_model().

SyckLevel* syck_parser_current_level | ( | SyckParser * | p | ) |

Definition at line 364 of file syck.c.

References _syck_parser::levels, and _syck_parser::lvl_idx.

void syck_parser_error_handler | ( | SyckParser * | p,
|  | SyckErrorHandler | hdlr
| ) |  |

Definition at line 297 of file syck.c.

References ASSERT, _syck_parser::error_handler, and NULL.

Referenced by rb_syck_compile(), syck_set_model(), and syck_yaml2byte().

void syck_parser_file | ( | SyckParser * | p,
|  | FILE * | fp,
|  | SyckIoFileRead | read
| ) |  |

Definition at line 318 of file syck.c.

References ASSERT, _syck_parser::file, free_any_io(), _syck_parser::io, _syck_parser::io_type, NULL, _syck_file::ptr, _syck_file::read, S_ALLOC, syck_io_file, syck_io_file_read(), and syck_parser_reset_cursor().

void syck_parser_handler | ( | SyckParser * | p,
|  | SyckNodeHandler | hdlr
| ) |  |

Definition at line 278 of file syck.c.

References ASSERT, _syck_parser::handler, and NULL.

Referenced by rb_syck_compile(), syck_set_model(), and syck_yaml2byte().

void syck_parser_implicit_typing | ( | SyckParser * | p,
|  | int | flag
| ) |  |

Definition at line 285 of file syck.c.

References _syck_parser::implicit_typing.

Referenced by rb_syck_compile(), syck_set_model(), and syck_yaml2byte().

void syck_parser_pop_level | ( | SyckParser * | p | ) |

Definition at line 370 of file syck.c.

References ASSERT, _syck_level::domain, free(), _syck_parser::levels, _syck_parser::lvl_idx, and NULL.

Referenced by syck_parser_reset_levels().

long syck_parser_read | ( | SyckParser * | p | ) |

Definition at line 462 of file syck.c.

References ASSERT, _syck_parser::buffer, _syck_parser::file, _syck_parser::io, _syck_parser::io_type, len, NULL, _syck_file::read, _syck_str::read, _syck_parser::str, SYCK_BUFFERSIZE, syck_check_limit(), syck_io_file, syck_io_str, and syck_move_tokens().

Referenced by sycklex_bytecode_utf8(), and sycklex_yaml_utf8().

long syck_parser_readlen | ( | SyckParser * | p,
|  | long | max_size
| ) |  |

Definition at line 484 of file syck.c.

References ASSERT, _syck_parser::buffer, _syck_parser::file, _syck_parser::io, _syck_parser::io_type, len, NULL, _syck_file::read, _syck_str::read, _syck_parser::str, syck_check_limit(), syck_io_file, syck_io_str, and syck_move_tokens().

void syck_parser_reset_cursor | ( | SyckParser * | p | ) |

Definition at line 119 of file syck.c.

References _syck_parser::buffer, _syck_parser::bufsize, _syck_parser::cursor, _syck_parser::eof, _syck_parser::force_token, _syck_parser::last_token, _syck_parser::limit, _syck_parser::linect, _syck_parser::linectptr, _syck_parser::lineptr, _syck_parser::marker, NULL, _syck_parser::root, _syck_parser::root_on_error, S_ALLOC_N, S_MEMZERO, _syck_parser::token, and _syck_parser::toktmp.

Referenced by syck_parser_file(), and syck_parser_str().

void syck_parser_reset_levels | ( | SyckParser * | p | ) |

Definition at line 101 of file syck.c.

References _syck_level::domain, _syck_parser::levels, _syck_parser::lvl_idx, _syck_level::ncount, _syck_level::spaces, _syck_level::status, syck_lvl_header, syck_parser_pop_level(), and syck_strndup().

Referenced by syck_free_parser(), syck_new_parser(), and syck_parse().

void syck_parser_set_input_type | ( | SyckParser * | p,
|  | enum syck_parser_input | input_type
| ) |  |

Definition at line 311 of file syck.c.

References ASSERT, _syck_parser::input_type, and NULL.

Referenced by syck_set_model().

void syck_parser_set_root_on_error | ( | SyckParser * | p,
|  | SYMID | roer
| ) |  |

Definition at line 148 of file syck.c.

References _syck_parser::root_on_error.

Referenced by syck_parser_s_alloc().

void syck_parser_str | ( | SyckParser * | p,
|  | char * | ptr,
|  | long | len,
|  | SyckIoStrRead | read
| ) |  |

Definition at line 337 of file syck.c.

References ASSERT, _syck_str::beg, _syck_str::end, free_any_io(), _syck_parser::io, _syck_parser::io_type, len, NULL, _syck_str::ptr, _syck_str::read, S_ALLOC, _syck_parser::str, syck_io_str, syck_io_str_read(), and syck_parser_reset_cursor().

Referenced by syck_parser_assign_io(), and syck_parser_str_auto().

void syck_parser_str_auto | ( | SyckParser * | p,
|  | char * | ptr,
|  | SyckIoStrRead | read
| ) |  |

Definition at line 358 of file syck.c.

References strlen(), and syck_parser_str().

Referenced by syck_yaml2byte().

void syck_parser_taguri_expansion | ( | SyckParser * | p,
|  | int | flag
| ) |  |

Definition at line 291 of file syck.c.

References _syck_parser::taguri_expansion.

Referenced by rb_syck_compile(), syck_set_model(), and syck_yaml2byte().

void syck_st_free | ( | SyckParser * | p | ) |

Definition at line 212 of file syck.c.

References _syck_parser::anchors, _syck_parser::bad_anchors, NULL, st_foreach, st_free_table, and syck_st_free_nodes().

Referenced by syck_free_parser(), and syck_parse().

int syck_st_free_nodes | ( | char * | key,
|  | SyckNode * | n,
|  | char * | arg
| ) |  |

Definition at line 204 of file syck.c.

References NULL, ST_CONTINUE, and syck_free_node().

Referenced by syck_st_free().

int syck_st_free_syms | ( | void * | key,
|  | bytestring_t * | sav,
|  | void * | dummy
| ) |  |

Definition at line 241 of file syck.c.

References bytestring_t::buffer, S_FREE, and ST_CONTINUE.

Referenced by syck_free_parser().

char* syck_strndup | ( | const char * | buf,
|  | long | len
| ) |  |

Definition at line 34 of file syck.c.

References S_ALLOC_N, S_MEMCPY, and S_MEMZERO.

Referenced by rb_syck_bad_anchor_handler(), syck_base64dec(), syck_emitter_add_level(), syck_emitter_reset_levels(), syck_node_transform(), syck_node_type_id_set(), syck_parser_add_level(), syck_parser_reset_levels(), syck_scalar_value_set(), syck_tagcmp(), syck_type_id_to_uri(), sycklex_bytecode_utf8(), sycklex_yaml_utf8(), try_tag_implicit(), and yyparse().