/
githubmirror
/
libcbor
Обзор
Документация
Войти
/
githubmirror
/
libcbor
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v0.1.0
examples/readfile.c
25 строк
650 B
PJK
Streaming parser example, null callbacks defaults
30 апр 2015, 19:29
30 апр 2015, 19:29
098340b
Код
Авторство
О чём код?
/* * Copyright (c) 2014-2015 Pavel Kalvoda <me@pavelkalvoda.com> * * libcbor is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See LICENSE for details. */ #include "cbor.h" #include <fcntl.h> #include <sys/mman.h> #include <sys/stat.h> int main(int argc, char * argv[]) { int fd = open(argv[1], O_RDONLY); struct stat info; fstat(fd, &info); unsigned char * buffer = mmap(NULL, info.st_size, PROT_READ, MAP_PRIVATE, fd, 0); struct cbor_load_result result; cbor_item_t * item = cbor_load(buffer, info.st_size, &result); cbor_describe(item, stdout); fflush(stdout); cbor_decref(&item); }