hexsha
stringlengths
40
40
repo
stringlengths
5
105
path
stringlengths
3
173
license
sequence
language
stringclasses
1 value
identifier
stringlengths
1
438
return_type
stringlengths
1
106
original_string
stringlengths
21
40.7k
original_docstring
stringlengths
18
13.4k
docstring
stringlengths
11
3.24k
docstring_tokens
sequence
code
stringlengths
14
20.4k
code_tokens
sequence
short_docstring
stringlengths
0
4.36k
short_docstring_tokens
sequence
comment
sequence
parameters
list
docstring_params
dict
dc3d5d1f194a5b1231eccfe3ff65a60ed374735a
acronis/pcs-io
libpcs_io/pool_allocator.c
[ "MIT" ]
C
pool_allocator_init
int
int pool_allocator_init(struct pool_allocator* a, unsigned size) { unsigned chunks; memset(a, 0, sizeof(*a)); if (!size) return -1; chunks = (PAGE_SIZE - POOL_ALIGN(sizeof(struct pool_page_hdr))) / POOL_ALIGN(size); if (chunks < MEM_POOL_MIN_ALLOCS_PER_PAGE) return -1; #ifdef MAX_CHUNKS_PER_PAGE if (chunks > MAX_CHUNKS_PER_PAGE) chunks = MAX_CHUNKS_PER_PAGE; #endif a->chunks_per_page = chunks; a->size = size; cd_list_init(&a->pgs_used); cd_list_init(&a->pgs_full); return 0; }
/* Initialize pool allocator, may return -1 if the size is not suitable for the pool allocation. */
Initialize pool allocator, may return -1 if the size is not suitable for the pool allocation.
[ "Initialize", "pool", "allocator", "may", "return", "-", "1", "if", "the", "size", "is", "not", "suitable", "for", "the", "pool", "allocation", "." ]
int pool_allocator_init(struct pool_allocator* a, unsigned size) { unsigned chunks; memset(a, 0, sizeof(*a)); if (!size) return -1; chunks = (PAGE_SIZE - POOL_ALIGN(sizeof(struct pool_page_hdr))) / POOL_ALIGN(size); if (chunks < MEM_POOL_MIN_ALLOCS_PER_PAGE) return -1; #ifdef MAX_CHUNKS_PER_PAGE if (chunks > MAX_CHUNKS_PER_PAGE) chunks = MAX_CHUNKS_PER_PAGE; #endif a->chunks_per_page = chunks; a->size = size; cd_list_init(&a->pgs_used); cd_list_init(&a->pgs_full); return 0; }
[ "int", "pool_allocator_init", "(", "struct", "pool_allocator", "*", "a", ",", "unsigned", "size", ")", "{", "unsigned", "chunks", ";", "memset", "(", "a", ",", "0", ",", "sizeof", "(", "*", "a", ")", ")", ";", "if", "(", "!", "size", ")", "return", "-1", ";", "chunks", "=", "(", "PAGE_SIZE", "-", "POOL_ALIGN", "(", "sizeof", "(", "struct", "pool_page_hdr", ")", ")", ")", "/", "POOL_ALIGN", "(", "size", ")", ";", "if", "(", "chunks", "<", "MEM_POOL_MIN_ALLOCS_PER_PAGE", ")", "return", "-1", ";", "#ifdef", "MAX_CHUNKS_PER_PAGE", "if", "(", "chunks", ">", "MAX_CHUNKS_PER_PAGE", ")", "chunks", "=", "MAX_CHUNKS_PER_PAGE", ";", "#endif", "a", "->", "chunks_per_page", "=", "chunks", ";", "a", "->", "size", "=", "size", ";", "cd_list_init", "(", "&", "a", "->", "pgs_used", ")", ";", "cd_list_init", "(", "&", "a", "->", "pgs_full", ")", ";", "return", "0", ";", "}" ]
Initialize pool allocator, may return -1 if the size is not suitable for the pool allocation.
[ "Initialize", "pool", "allocator", "may", "return", "-", "1", "if", "the", "size", "is", "not", "suitable", "for", "the", "pool", "allocation", "." ]
[]
[ { "param": "a", "type": "struct pool_allocator" }, { "param": "size", "type": "unsigned" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": "struct pool_allocator", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "unsigned", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dc3d5d1f194a5b1231eccfe3ff65a60ed374735a
acronis/pcs-io
libpcs_io/pool_allocator.c
[ "MIT" ]
C
prealloc_pages
null
static unsigned prealloc_pages(struct mem_pool* p) { void* ptr; unsigned i, pgs; struct pool_page_hdr* pg; for (pgs = MEM_POOL_PREALLOC_PGS; pgs; pgs /= 2) { unsigned sz = pgs * PAGE_SIZE; #ifndef __WINDOWS__ int res; ptr = mmap(0, sz, PROT_READ|PROT_WRITE, MMAP_ATTR, -1, 0); if (!ptr || ptr == MAP_FAILED) continue; res = madvise(ptr, sz, MADV_RANDOM); BUG_ON(res); #else ptr = VirtualAlloc(0, sz, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (!ptr) continue; #endif break; } if (!pgs) return 0; BUG_ON((long)ptr & (PAGE_SIZE - 1)); pg = (struct pool_page_hdr*)ptr; for (i = 0; i < pgs; ++i) { add_free_page(p, pg); pg = (struct pool_page_hdr*)((char*)pg + PAGE_SIZE); } p->pgs_allocated += pgs; return pgs; }
/* Allocate the number of free pages */
Allocate the number of free pages
[ "Allocate", "the", "number", "of", "free", "pages" ]
static unsigned prealloc_pages(struct mem_pool* p) { void* ptr; unsigned i, pgs; struct pool_page_hdr* pg; for (pgs = MEM_POOL_PREALLOC_PGS; pgs; pgs /= 2) { unsigned sz = pgs * PAGE_SIZE; #ifndef __WINDOWS__ int res; ptr = mmap(0, sz, PROT_READ|PROT_WRITE, MMAP_ATTR, -1, 0); if (!ptr || ptr == MAP_FAILED) continue; res = madvise(ptr, sz, MADV_RANDOM); BUG_ON(res); #else ptr = VirtualAlloc(0, sz, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (!ptr) continue; #endif break; } if (!pgs) return 0; BUG_ON((long)ptr & (PAGE_SIZE - 1)); pg = (struct pool_page_hdr*)ptr; for (i = 0; i < pgs; ++i) { add_free_page(p, pg); pg = (struct pool_page_hdr*)((char*)pg + PAGE_SIZE); } p->pgs_allocated += pgs; return pgs; }
[ "static", "unsigned", "prealloc_pages", "(", "struct", "mem_pool", "*", "p", ")", "{", "void", "*", "ptr", ";", "unsigned", "i", ",", "pgs", ";", "struct", "pool_page_hdr", "*", "pg", ";", "for", "(", "pgs", "=", "MEM_POOL_PREALLOC_PGS", ";", "pgs", ";", "pgs", "/=", "2", ")", "{", "unsigned", "sz", "=", "pgs", "*", "PAGE_SIZE", ";", "#ifndef", "__WINDOWS__", "int", "res", ";", "ptr", "=", "mmap", "(", "0", ",", "sz", ",", "PROT_READ", "|", "PROT_WRITE", ",", "MMAP_ATTR", ",", "-1", ",", "0", ")", ";", "if", "(", "!", "ptr", "||", "ptr", "==", "MAP_FAILED", ")", "continue", ";", "res", "=", "madvise", "(", "ptr", ",", "sz", ",", "MADV_RANDOM", ")", ";", "BUG_ON", "(", "res", ")", ";", "#else", "ptr", "=", "VirtualAlloc", "(", "0", ",", "sz", ",", "MEM_COMMIT", ",", "PAGE_EXECUTE_READWRITE", ")", ";", "if", "(", "!", "ptr", ")", "continue", ";", "#endif", "break", ";", "}", "if", "(", "!", "pgs", ")", "return", "0", ";", "BUG_ON", "(", "(", "long", ")", "ptr", "&", "(", "PAGE_SIZE", "-", "1", ")", ")", ";", "pg", "=", "(", "struct", "pool_page_hdr", "*", ")", "ptr", ";", "for", "(", "i", "=", "0", ";", "i", "<", "pgs", ";", "++", "i", ")", "{", "add_free_page", "(", "p", ",", "pg", ")", ";", "pg", "=", "(", "struct", "pool_page_hdr", "*", ")", "(", "(", "char", "*", ")", "pg", "+", "PAGE_SIZE", ")", ";", "}", "p", "->", "pgs_allocated", "+=", "pgs", ";", "return", "pgs", ";", "}" ]
Allocate the number of free pages
[ "Allocate", "the", "number", "of", "free", "pages" ]
[]
[ { "param": "p", "type": "struct mem_pool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "struct mem_pool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dc3d5d1f194a5b1231eccfe3ff65a60ed374735a
acronis/pcs-io
libpcs_io/pool_allocator.c
[ "MIT" ]
C
alloc_from_page
void
static void* alloc_from_page(struct pool_allocator* a, struct pool_page_hdr* pg) { struct pool_chunk_hdr* ch; BUG_ON(pg->chunks_used >= a->chunks_per_page); BUG_ON(!pg->free_chunks); ch = pg->free_chunks; pg->free_chunks = ch->next; ++pg->chunks_used; if (!pg->free_chunks) { /* No free chunks left */ BUG_ON(pg->chunks_used != a->chunks_per_page); cd_list_del(&pg->node); cd_list_add(&pg->node, &a->pgs_full); } return ch; }
/* Allocate chunk from the particular pool page */
Allocate chunk from the particular pool page
[ "Allocate", "chunk", "from", "the", "particular", "pool", "page" ]
static void* alloc_from_page(struct pool_allocator* a, struct pool_page_hdr* pg) { struct pool_chunk_hdr* ch; BUG_ON(pg->chunks_used >= a->chunks_per_page); BUG_ON(!pg->free_chunks); ch = pg->free_chunks; pg->free_chunks = ch->next; ++pg->chunks_used; if (!pg->free_chunks) { BUG_ON(pg->chunks_used != a->chunks_per_page); cd_list_del(&pg->node); cd_list_add(&pg->node, &a->pgs_full); } return ch; }
[ "static", "void", "*", "alloc_from_page", "(", "struct", "pool_allocator", "*", "a", ",", "struct", "pool_page_hdr", "*", "pg", ")", "{", "struct", "pool_chunk_hdr", "*", "ch", ";", "BUG_ON", "(", "pg", "->", "chunks_used", ">=", "a", "->", "chunks_per_page", ")", ";", "BUG_ON", "(", "!", "pg", "->", "free_chunks", ")", ";", "ch", "=", "pg", "->", "free_chunks", ";", "pg", "->", "free_chunks", "=", "ch", "->", "next", ";", "++", "pg", "->", "chunks_used", ";", "if", "(", "!", "pg", "->", "free_chunks", ")", "{", "BUG_ON", "(", "pg", "->", "chunks_used", "!=", "a", "->", "chunks_per_page", ")", ";", "cd_list_del", "(", "&", "pg", "->", "node", ")", ";", "cd_list_add", "(", "&", "pg", "->", "node", ",", "&", "a", "->", "pgs_full", ")", ";", "}", "return", "ch", ";", "}" ]
Allocate chunk from the particular pool page
[ "Allocate", "chunk", "from", "the", "particular", "pool", "page" ]
[ "/* No free chunks left */" ]
[ { "param": "a", "type": "struct pool_allocator" }, { "param": "pg", "type": "struct pool_page_hdr" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": "struct pool_allocator", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pg", "type": "struct pool_page_hdr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d8ac059d99ed151d75ecc687d636f6098710fb1a
acronis/pcs-io
libpcs_io/pcs_numeric.h
[ "MIT" ]
C
muldiv_safe
u64
static inline u64 muldiv_safe(u64 a, u64 b, u64 c) { u64 v; /* The arithmetic width */ s32 const w = 8 * sizeof(v), hw = w / 2; /* How many bits are occupied by operands */ s32 a_ = 1 + _log2l(a), b_ = 1 + _log2l(b), c_, x_; if (a_ + b_ <= w) /* No overflow, trivial case */ return a * b / c; c_ = 1 + _log2l(c); if (a_ + b_ - c_ > w) /* Result overflow, returns max representable value */ return ~0UL; /* How many excessive bits the a*b has */ x_ = a_ + b_ - w; /* Right shift a, b operands so a*b will occupy exactly w bits. * Note that we are loosing at most 2^-hw of precision here. */ if (a_ > hw) { if (b_ > hw) { a >>= (a_ - hw); b >>= (b_ - hw); } else { a >>= x_; } } else { b >>= x_; } /* Now we can safely multiply. The result will occupy exactly w bits. */ v = a * b; if (c_ > hw) { /* Right shift c to hw bits so the reminder will occupy hw bits as well. * So we are loosing at most 2^-hw of precision on deletion. */ s32 sht = c_ - hw; if (sht > x_) sht = x_; c >>= sht; x_ -= sht; } /* Calculate the ultimate result */ return (v / c) << x_; }
/* Calculate a * b / c avoiding overflow */
Calculate a * b / c avoiding overflow
[ "Calculate", "a", "*", "b", "/", "c", "avoiding", "overflow" ]
static inline u64 muldiv_safe(u64 a, u64 b, u64 c) { u64 v; s32 const w = 8 * sizeof(v), hw = w / 2; s32 a_ = 1 + _log2l(a), b_ = 1 + _log2l(b), c_, x_; if (a_ + b_ <= w) return a * b / c; c_ = 1 + _log2l(c); if (a_ + b_ - c_ > w) return ~0UL; x_ = a_ + b_ - w; if (a_ > hw) { if (b_ > hw) { a >>= (a_ - hw); b >>= (b_ - hw); } else { a >>= x_; } } else { b >>= x_; } v = a * b; if (c_ > hw) { s32 sht = c_ - hw; if (sht > x_) sht = x_; c >>= sht; x_ -= sht; } return (v / c) << x_; }
[ "static", "inline", "u64", "muldiv_safe", "(", "u64", "a", ",", "u64", "b", ",", "u64", "c", ")", "{", "u64", "v", ";", "s32", "const", "w", "=", "8", "*", "sizeof", "(", "v", ")", ",", "hw", "=", "w", "/", "2", ";", "s32", "a_", "=", "1", "+", "_log2l", "(", "a", ")", ",", "b_", "=", "1", "+", "_log2l", "(", "b", ")", ",", "c_", ",", "x_", ";", "if", "(", "a_", "+", "b_", "<=", "w", ")", "return", "a", "*", "b", "/", "c", ";", "c_", "=", "1", "+", "_log2l", "(", "c", ")", ";", "if", "(", "a_", "+", "b_", "-", "c_", ">", "w", ")", "return", "~", "0UL", ";", "x_", "=", "a_", "+", "b_", "-", "w", ";", "if", "(", "a_", ">", "hw", ")", "{", "if", "(", "b_", ">", "hw", ")", "{", "a", ">>=", "(", "a_", "-", "hw", ")", ";", "b", ">>=", "(", "b_", "-", "hw", ")", ";", "}", "else", "{", "a", ">>=", "x_", ";", "}", "}", "else", "{", "b", ">>=", "x_", ";", "}", "v", "=", "a", "*", "b", ";", "if", "(", "c_", ">", "hw", ")", "{", "s32", "sht", "=", "c_", "-", "hw", ";", "if", "(", "sht", ">", "x_", ")", "sht", "=", "x_", ";", "c", ">>=", "sht", ";", "x_", "-=", "sht", ";", "}", "return", "(", "v", "/", "c", ")", "<<", "x_", ";", "}" ]
Calculate a * b / c avoiding overflow
[ "Calculate", "a", "*", "b", "/", "c", "avoiding", "overflow" ]
[ "/* The arithmetic width */", "/* How many bits are occupied by operands */", "/* No overflow, trivial case */", "/* Result overflow, returns max representable value */", "/* How many excessive bits the a*b has */", "/* Right shift a, b operands so a*b will occupy exactly w bits.\n\t * Note that we are loosing at most 2^-hw of precision here.\n\t */", "/* Now we can safely multiply. The result will occupy exactly w bits. */", "/* Right shift c to hw bits so the reminder will occupy hw bits as well.\n\t\t * So we are loosing at most 2^-hw of precision on deletion.\n\t\t */", "/* Calculate the ultimate result */" ]
[ { "param": "a", "type": "u64" }, { "param": "b", "type": "u64" }, { "param": "c", "type": "u64" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": "u64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b", "type": "u64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "c", "type": "u64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7d3370b1bfb8d22e706f096de1aa0272587eab5e
acronis/pcs-io
libpcs_io/crc64.c
[ "MIT" ]
C
crc_table_init
void
static void crc_table_init(crcfn64 crcfn, uint64_t table[8][256]) { uint64_t crc; int n, k; /* generate CRCs for all single byte sequences */ for (n = 0; n < 256; n++) { unsigned char c = (unsigned char)n; table[0][n] = crcfn(0, &c, 1); } /* generate nested CRC table for future slice-by-8 lookup */ for (n = 0; n < 256; n++) { crc = table[0][n]; for (k = 1; k < 8; k++) { crc = table[0][crc & 0xff] ^ (crc >> 8); table[k][n] = crc; } } /* Transform to the big endian table if needed */ for (k = 0; k < 8; k++) for (n = 0; n < 256; n++) table[k][n] = le64_to_cpu(table[k][n]); }
/* Fill in a CRC constants table. */
Fill in a CRC constants table.
[ "Fill", "in", "a", "CRC", "constants", "table", "." ]
static void crc_table_init(crcfn64 crcfn, uint64_t table[8][256]) { uint64_t crc; int n, k; for (n = 0; n < 256; n++) { unsigned char c = (unsigned char)n; table[0][n] = crcfn(0, &c, 1); } for (n = 0; n < 256; n++) { crc = table[0][n]; for (k = 1; k < 8; k++) { crc = table[0][crc & 0xff] ^ (crc >> 8); table[k][n] = crc; } } for (k = 0; k < 8; k++) for (n = 0; n < 256; n++) table[k][n] = le64_to_cpu(table[k][n]); }
[ "static", "void", "crc_table_init", "(", "crcfn64", "crcfn", ",", "uint64_t", "table", "[", "8", "]", "[", "256", "]", ")", "{", "uint64_t", "crc", ";", "int", "n", ",", "k", ";", "for", "(", "n", "=", "0", ";", "n", "<", "256", ";", "n", "++", ")", "{", "unsigned", "char", "c", "=", "(", "unsigned", "char", ")", "n", ";", "table", "[", "0", "]", "[", "n", "]", "=", "crcfn", "(", "0", ",", "&", "c", ",", "1", ")", ";", "}", "for", "(", "n", "=", "0", ";", "n", "<", "256", ";", "n", "++", ")", "{", "crc", "=", "table", "[", "0", "]", "[", "n", "]", ";", "for", "(", "k", "=", "1", ";", "k", "<", "8", ";", "k", "++", ")", "{", "crc", "=", "table", "[", "0", "]", "[", "crc", "&", "0xff", "]", "^", "(", "crc", ">>", "8", ")", ";", "table", "[", "k", "]", "[", "n", "]", "=", "crc", ";", "}", "}", "for", "(", "k", "=", "0", ";", "k", "<", "8", ";", "k", "++", ")", "for", "(", "n", "=", "0", ";", "n", "<", "256", ";", "n", "++", ")", "table", "[", "k", "]", "[", "n", "]", "=", "le64_to_cpu", "(", "table", "[", "k", "]", "[", "n", "]", ")", ";", "}" ]
Fill in a CRC constants table.
[ "Fill", "in", "a", "CRC", "constants", "table", "." ]
[ "/* generate CRCs for all single byte sequences */", "/* generate nested CRC table for future slice-by-8 lookup */", "/* Transform to the big endian table if needed */" ]
[ { "param": "crcfn", "type": "crcfn64" }, { "param": "table", "type": "uint64_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "crcfn", "type": "crcfn64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "table", "type": "uint64_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7d3370b1bfb8d22e706f096de1aa0272587eab5e
acronis/pcs-io
libpcs_io/crc64.c
[ "MIT" ]
C
crcspeed64big
uint64_t
static uint64_t crcspeed64big(uint64_t big_table[8][256], uint64_t crc, void *buf, unsigned int len) { unsigned char *next = buf; crc = cpu_to_le64(crc); while (len && ((uintptr_t)next & 7) != 0) { crc = big_table[0][(crc >> 56) ^ *next++] ^ (crc << 8); len--; } while (len >= 8) { crc ^= *(uint64_t *)next; crc = big_table[0][crc & 0xff] ^ big_table[1][(crc >> 8) & 0xff] ^ big_table[2][(crc >> 16) & 0xff] ^ big_table[3][(crc >> 24) & 0xff] ^ big_table[4][(crc >> 32) & 0xff] ^ big_table[5][(crc >> 40) & 0xff] ^ big_table[6][(crc >> 48) & 0xff] ^ big_table[7][crc >> 56]; next += 8; len -= 8; } while (len) { crc = big_table[0][(crc >> 56) ^ *next++] ^ (crc << 8); len--; } return le64_to_cpu(crc); }
/* Calculate a non-inverted CRC eight bytes at a time on a big-endian * architecture. */
Calculate a non-inverted CRC eight bytes at a time on a big-endian architecture.
[ "Calculate", "a", "non", "-", "inverted", "CRC", "eight", "bytes", "at", "a", "time", "on", "a", "big", "-", "endian", "architecture", "." ]
static uint64_t crcspeed64big(uint64_t big_table[8][256], uint64_t crc, void *buf, unsigned int len) { unsigned char *next = buf; crc = cpu_to_le64(crc); while (len && ((uintptr_t)next & 7) != 0) { crc = big_table[0][(crc >> 56) ^ *next++] ^ (crc << 8); len--; } while (len >= 8) { crc ^= *(uint64_t *)next; crc = big_table[0][crc & 0xff] ^ big_table[1][(crc >> 8) & 0xff] ^ big_table[2][(crc >> 16) & 0xff] ^ big_table[3][(crc >> 24) & 0xff] ^ big_table[4][(crc >> 32) & 0xff] ^ big_table[5][(crc >> 40) & 0xff] ^ big_table[6][(crc >> 48) & 0xff] ^ big_table[7][crc >> 56]; next += 8; len -= 8; } while (len) { crc = big_table[0][(crc >> 56) ^ *next++] ^ (crc << 8); len--; } return le64_to_cpu(crc); }
[ "static", "uint64_t", "crcspeed64big", "(", "uint64_t", "big_table", "[", "8", "]", "[", "256", "]", ",", "uint64_t", "crc", ",", "void", "*", "buf", ",", "unsigned", "int", "len", ")", "{", "unsigned", "char", "*", "next", "=", "buf", ";", "crc", "=", "cpu_to_le64", "(", "crc", ")", ";", "while", "(", "len", "&&", "(", "(", "uintptr_t", ")", "next", "&", "7", ")", "!=", "0", ")", "{", "crc", "=", "big_table", "[", "0", "]", "[", "(", "crc", ">>", "56", ")", "^", "*", "next", "++", "]", "^", "(", "crc", "<<", "8", ")", ";", "len", "--", ";", "}", "while", "(", "len", ">=", "8", ")", "{", "crc", "^=", "*", "(", "uint64_t", "*", ")", "next", ";", "crc", "=", "big_table", "[", "0", "]", "[", "crc", "&", "0xff", "]", "^", "big_table", "[", "1", "]", "[", "(", "crc", ">>", "8", ")", "&", "0xff", "]", "^", "big_table", "[", "2", "]", "[", "(", "crc", ">>", "16", ")", "&", "0xff", "]", "^", "big_table", "[", "3", "]", "[", "(", "crc", ">>", "24", ")", "&", "0xff", "]", "^", "big_table", "[", "4", "]", "[", "(", "crc", ">>", "32", ")", "&", "0xff", "]", "^", "big_table", "[", "5", "]", "[", "(", "crc", ">>", "40", ")", "&", "0xff", "]", "^", "big_table", "[", "6", "]", "[", "(", "crc", ">>", "48", ")", "&", "0xff", "]", "^", "big_table", "[", "7", "]", "[", "crc", ">>", "56", "]", ";", "next", "+=", "8", ";", "len", "-=", "8", ";", "}", "while", "(", "len", ")", "{", "crc", "=", "big_table", "[", "0", "]", "[", "(", "crc", ">>", "56", ")", "^", "*", "next", "++", "]", "^", "(", "crc", "<<", "8", ")", ";", "len", "--", ";", "}", "return", "le64_to_cpu", "(", "crc", ")", ";", "}" ]
Calculate a non-inverted CRC eight bytes at a time on a big-endian architecture.
[ "Calculate", "a", "non", "-", "inverted", "CRC", "eight", "bytes", "at", "a", "time", "on", "a", "big", "-", "endian", "architecture", "." ]
[]
[ { "param": "big_table", "type": "uint64_t" }, { "param": "crc", "type": "uint64_t" }, { "param": "buf", "type": "void" }, { "param": "len", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "big_table", "type": "uint64_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "crc", "type": "uint64_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1b6ebaab5af714e80b534aa36553242c72b8cf96
acronis/pcs-io
libpcs_io/pcs_profiler.c
[ "MIT" ]
C
pcs_profiler_block
void
void pcs_profiler_block(struct pcs_evloop * evloop, sigset_t * oldmask) { if (__pcs_profiler_enabled) { sigset_t mask; sigemptyset(&mask); sigaddset(&mask, PROFILER_SIGNO); pthread_sigmask(SIG_BLOCK, &mask, oldmask); } }
/* This maybe needed to block profiler e.g. to give fork() a chance to complete w/o being interrupted by a timer signal and restarting constantly */
This maybe needed to block profiler e.g. to give fork() a chance to complete w/o being interrupted by a timer signal and restarting constantly
[ "This", "maybe", "needed", "to", "block", "profiler", "e", ".", "g", ".", "to", "give", "fork", "()", "a", "chance", "to", "complete", "w", "/", "o", "being", "interrupted", "by", "a", "timer", "signal", "and", "restarting", "constantly" ]
void pcs_profiler_block(struct pcs_evloop * evloop, sigset_t * oldmask) { if (__pcs_profiler_enabled) { sigset_t mask; sigemptyset(&mask); sigaddset(&mask, PROFILER_SIGNO); pthread_sigmask(SIG_BLOCK, &mask, oldmask); } }
[ "void", "pcs_profiler_block", "(", "struct", "pcs_evloop", "*", "evloop", ",", "sigset_t", "*", "oldmask", ")", "{", "if", "(", "__pcs_profiler_enabled", ")", "{", "sigset_t", "mask", ";", "sigemptyset", "(", "&", "mask", ")", ";", "sigaddset", "(", "&", "mask", ",", "PROFILER_SIGNO", ")", ";", "pthread_sigmask", "(", "SIG_BLOCK", ",", "&", "mask", ",", "oldmask", ")", ";", "}", "}" ]
This maybe needed to block profiler e.g.
[ "This", "maybe", "needed", "to", "block", "profiler", "e", ".", "g", "." ]
[]
[ { "param": "evloop", "type": "struct pcs_evloop" }, { "param": "oldmask", "type": "sigset_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "evloop", "type": "struct pcs_evloop", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "oldmask", "type": "sigset_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3f8d1e06670ebac03aef10bc4ffd25af6727ec5a
acronis/pcs-io
libpcs_io/pcs_random.c
[ "MIT" ]
C
pcs_get_urandom
int
int pcs_get_urandom(void *buf, int sz) { #ifndef __WINDOWS__ pcs_fd_t fd; int ret = pcs_sync_open("/dev/urandom", O_RDONLY, 0, &fd); if (ret) { pcs_log_syserror(LOG_ERR, ret, "Unable open /dev/urandom"); return -1; } ret = pcs_sync_sread(fd, buf, sz); pcs_sync_close(fd); if (ret < 0) { pcs_log_syserror(LOG_ERR, ret, "Can't read from /dev/urandom"); return -1; } if (ret != sz) { pcs_log(LOG_ERR, "Truncated read from /dev/urandom"); return -1; } #else if (!RtlGenRandom(buf, sz)) { pcs_log(LOG_ERR, "RtlGenRandom failed"); return -1; } #endif return 0; }
/* Fill buffer with pseudo random content. Returns 0 on success and -1 otherwise */
Fill buffer with pseudo random content. Returns 0 on success and -1 otherwise
[ "Fill", "buffer", "with", "pseudo", "random", "content", ".", "Returns", "0", "on", "success", "and", "-", "1", "otherwise" ]
int pcs_get_urandom(void *buf, int sz) { #ifndef __WINDOWS__ pcs_fd_t fd; int ret = pcs_sync_open("/dev/urandom", O_RDONLY, 0, &fd); if (ret) { pcs_log_syserror(LOG_ERR, ret, "Unable open /dev/urandom"); return -1; } ret = pcs_sync_sread(fd, buf, sz); pcs_sync_close(fd); if (ret < 0) { pcs_log_syserror(LOG_ERR, ret, "Can't read from /dev/urandom"); return -1; } if (ret != sz) { pcs_log(LOG_ERR, "Truncated read from /dev/urandom"); return -1; } #else if (!RtlGenRandom(buf, sz)) { pcs_log(LOG_ERR, "RtlGenRandom failed"); return -1; } #endif return 0; }
[ "int", "pcs_get_urandom", "(", "void", "*", "buf", ",", "int", "sz", ")", "{", "#ifndef", "__WINDOWS__", "pcs_fd_t", "fd", ";", "int", "ret", "=", "pcs_sync_open", "(", "\"", "\"", ",", "O_RDONLY", ",", "0", ",", "&", "fd", ")", ";", "if", "(", "ret", ")", "{", "pcs_log_syserror", "(", "LOG_ERR", ",", "ret", ",", "\"", "\"", ")", ";", "return", "-1", ";", "}", "ret", "=", "pcs_sync_sread", "(", "fd", ",", "buf", ",", "sz", ")", ";", "pcs_sync_close", "(", "fd", ")", ";", "if", "(", "ret", "<", "0", ")", "{", "pcs_log_syserror", "(", "LOG_ERR", ",", "ret", ",", "\"", "\"", ")", ";", "return", "-1", ";", "}", "if", "(", "ret", "!=", "sz", ")", "{", "pcs_log", "(", "LOG_ERR", ",", "\"", "\"", ")", ";", "return", "-1", ";", "}", "#else", "if", "(", "!", "RtlGenRandom", "(", "buf", ",", "sz", ")", ")", "{", "pcs_log", "(", "LOG_ERR", ",", "\"", "\"", ")", ";", "return", "-1", ";", "}", "#endif", "return", "0", ";", "}" ]
Fill buffer with pseudo random content.
[ "Fill", "buffer", "with", "pseudo", "random", "content", "." ]
[]
[ { "param": "buf", "type": "void" }, { "param": "sz", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buf", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sz", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a645ed7c16e3472a088cf87a0343514fec38e0e7
acronis/pcs-io
libpcs_io/pcs_aio.c
[ "MIT" ]
C
route
null
static inline struct pcs_aio_worker * route(struct pcs_aio * aio, struct pcs_aioreq * req) { u32 hash; hash = jhash3(req->client.val>>32, req->client.val&0xFFFFFFFF, req->iocontext, aio->salt); return aio->workers + (hash & (aio->threads - 1)); }
/* We use _fixed_ hashing of client's iocontext to threads. No balancing. * The goal of executing aio from threads is to get proper CFQ iocontext, * if we switch between threads we would lose idle state. */
We use _fixed_ hashing of client's iocontext to threads. No balancing. The goal of executing aio from threads is to get proper CFQ iocontext, if we switch between threads we would lose idle state.
[ "We", "use", "_fixed_", "hashing", "of", "client", "'", "s", "iocontext", "to", "threads", ".", "No", "balancing", ".", "The", "goal", "of", "executing", "aio", "from", "threads", "is", "to", "get", "proper", "CFQ", "iocontext", "if", "we", "switch", "between", "threads", "we", "would", "lose", "idle", "state", "." ]
static inline struct pcs_aio_worker * route(struct pcs_aio * aio, struct pcs_aioreq * req) { u32 hash; hash = jhash3(req->client.val>>32, req->client.val&0xFFFFFFFF, req->iocontext, aio->salt); return aio->workers + (hash & (aio->threads - 1)); }
[ "static", "inline", "struct", "pcs_aio_worker", "*", "route", "(", "struct", "pcs_aio", "*", "aio", ",", "struct", "pcs_aioreq", "*", "req", ")", "{", "u32", "hash", ";", "hash", "=", "jhash3", "(", "req", "->", "client", ".", "val", ">>", "32", ",", "req", "->", "client", ".", "val", "&", "0xFFFFFFFF", ",", "req", "->", "iocontext", ",", "aio", "->", "salt", ")", ";", "return", "aio", "->", "workers", "+", "(", "hash", "&", "(", "aio", "->", "threads", "-", "1", ")", ")", ";", "}" ]
We use _fixed_ hashing of client's iocontext to threads.
[ "We", "use", "_fixed_", "hashing", "of", "client", "'", "s", "iocontext", "to", "threads", "." ]
[]
[ { "param": "aio", "type": "struct pcs_aio" }, { "param": "req", "type": "struct pcs_aioreq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "aio", "type": "struct pcs_aio", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "req", "type": "struct pcs_aioreq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c5d82b0d36c6683594219d8abeb55b863455ca86
acronis/pcs-io
libpcs_io/logrotate.c
[ "MIT" ]
C
parse_file_path
void
static void parse_file_path(char *path, char **dname, char **fname) { *fname = strrchr(path, PCS_PATH_SEP); if (*fname) { **fname = '\0'; (*fname)++; *dname = *path ? path : "/"; } else { *fname = path; *dname = "."; } }
/* Split path on filesystem 'path' into directory name and file name. * 'path' may be modified. */
Split path on filesystem 'path' into directory name and file name. 'path' may be modified.
[ "Split", "path", "on", "filesystem", "'", "path", "'", "into", "directory", "name", "and", "file", "name", ".", "'", "path", "'", "may", "be", "modified", "." ]
static void parse_file_path(char *path, char **dname, char **fname) { *fname = strrchr(path, PCS_PATH_SEP); if (*fname) { **fname = '\0'; (*fname)++; *dname = *path ? path : "/"; } else { *fname = path; *dname = "."; } }
[ "static", "void", "parse_file_path", "(", "char", "*", "path", ",", "char", "*", "*", "dname", ",", "char", "*", "*", "fname", ")", "{", "*", "fname", "=", "strrchr", "(", "path", ",", "PCS_PATH_SEP", ")", ";", "if", "(", "*", "fname", ")", "{", "*", "*", "fname", "=", "'", "\\0", "'", ";", "(", "*", "fname", ")", "++", ";", "*", "dname", "=", "*", "path", "?", "path", ":", "\"", "\"", ";", "}", "else", "{", "*", "fname", "=", "path", ";", "*", "dname", "=", "\"", "\"", ";", "}", "}" ]
Split path on filesystem 'path' into directory name and file name.
[ "Split", "path", "on", "filesystem", "'", "path", "'", "into", "directory", "name", "and", "file", "name", "." ]
[]
[ { "param": "path", "type": "char" }, { "param": "dname", "type": "char" }, { "param": "fname", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dname", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fname", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
35f4b19a3d2981a50e98d5e14caee54d1f416d43
acronis/pcs-io
libpcs_io/pcs_malloc.c
[ "MIT" ]
C
__pcs_alloc_account
void
void __pcs_alloc_account(void *block, ptrdiff_t size) { if (!pcs_malloc_enabled) return; if (block == NULL) return; struct mem_header* hdr = (struct mem_header*)block - 1; struct malloc_item *mi = hdr->caller; pthread_mutex_lock(&mi->mutex); BUG_ON(size < 0 && hdr->size < -size); hdr->size += size; pcs_account_alloc_locked(mi, size); pthread_mutex_unlock(&mi->mutex); }
/* add accounted bytes to existing allocation */
add accounted bytes to existing allocation
[ "add", "accounted", "bytes", "to", "existing", "allocation" ]
void __pcs_alloc_account(void *block, ptrdiff_t size) { if (!pcs_malloc_enabled) return; if (block == NULL) return; struct mem_header* hdr = (struct mem_header*)block - 1; struct malloc_item *mi = hdr->caller; pthread_mutex_lock(&mi->mutex); BUG_ON(size < 0 && hdr->size < -size); hdr->size += size; pcs_account_alloc_locked(mi, size); pthread_mutex_unlock(&mi->mutex); }
[ "void", "__pcs_alloc_account", "(", "void", "*", "block", ",", "ptrdiff_t", "size", ")", "{", "if", "(", "!", "pcs_malloc_enabled", ")", "return", ";", "if", "(", "block", "==", "NULL", ")", "return", ";", "struct", "mem_header", "*", "hdr", "=", "(", "struct", "mem_header", "*", ")", "block", "-", "1", ";", "struct", "malloc_item", "*", "mi", "=", "hdr", "->", "caller", ";", "pthread_mutex_lock", "(", "&", "mi", "->", "mutex", ")", ";", "BUG_ON", "(", "size", "<", "0", "&&", "hdr", "->", "size", "<", "-", "size", ")", ";", "hdr", "->", "size", "+=", "size", ";", "pcs_account_alloc_locked", "(", "mi", ",", "size", ")", ";", "pthread_mutex_unlock", "(", "&", "mi", "->", "mutex", ")", ";", "}" ]
add accounted bytes to existing allocation
[ "add", "accounted", "bytes", "to", "existing", "allocation" ]
[]
[ { "param": "block", "type": "void" }, { "param": "size", "type": "ptrdiff_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "ptrdiff_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
13add96fa3b9fbc9da275b0205029640efaf8e79
acronis/pcs-io
libpcs_io/pcs_mr_malloc.c
[ "MIT" ]
C
mr_hash
int
static int mr_hash(size_t size) { size_t kb = size >> 10; size_t mb = kb >> 10; if (mb) return 1024 + (mb & 1023); else return kb & 1023; }
/* relies on MR_HASH_SIZE to be 2048 */
relies on MR_HASH_SIZE to be 2048
[ "relies", "on", "MR_HASH_SIZE", "to", "be", "2048" ]
static int mr_hash(size_t size) { size_t kb = size >> 10; size_t mb = kb >> 10; if (mb) return 1024 + (mb & 1023); else return kb & 1023; }
[ "static", "int", "mr_hash", "(", "size_t", "size", ")", "{", "size_t", "kb", "=", "size", ">>", "10", ";", "size_t", "mb", "=", "kb", ">>", "10", ";", "if", "(", "mb", ")", "return", "1024", "+", "(", "mb", "&", "1023", ")", ";", "else", "return", "kb", "&", "1023", ";", "}" ]
relies on MR_HASH_SIZE to be 2048
[ "relies", "on", "MR_HASH_SIZE", "to", "be", "2048" ]
[]
[ { "param": "size", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
07eb6c0476e1b497714f035dadb3c14bab92ed96
acronis/pcs-io
libpcs_io/pcs_splice.c
[ "MIT" ]
C
pcs_splice_buf_recv
int
int pcs_splice_buf_recv(struct pcs_splice_buf * b, int fd, int size) { int total = 0; while (size > 0) { ssize_t n; n = splice(fd, NULL, b->desc, NULL, size, SPLICE_F_NONBLOCK); if (n < 0) { if (errno == EINTR) continue; return total ? : -errno; } if (n == 0) break; size -= n; BUG_ON(size < 0); b->bytes += n; total += n; } return total; }
/* Receive data from socket/pipe/chardev to splice buffer */
Receive data from socket/pipe/chardev to splice buffer
[ "Receive", "data", "from", "socket", "/", "pipe", "/", "chardev", "to", "splice", "buffer" ]
int pcs_splice_buf_recv(struct pcs_splice_buf * b, int fd, int size) { int total = 0; while (size > 0) { ssize_t n; n = splice(fd, NULL, b->desc, NULL, size, SPLICE_F_NONBLOCK); if (n < 0) { if (errno == EINTR) continue; return total ? : -errno; } if (n == 0) break; size -= n; BUG_ON(size < 0); b->bytes += n; total += n; } return total; }
[ "int", "pcs_splice_buf_recv", "(", "struct", "pcs_splice_buf", "*", "b", ",", "int", "fd", ",", "int", "size", ")", "{", "int", "total", "=", "0", ";", "while", "(", "size", ">", "0", ")", "{", "ssize_t", "n", ";", "n", "=", "splice", "(", "fd", ",", "NULL", ",", "b", "->", "desc", ",", "NULL", ",", "size", ",", "SPLICE_F_NONBLOCK", ")", ";", "if", "(", "n", "<", "0", ")", "{", "if", "(", "errno", "==", "EINTR", ")", "continue", ";", "return", "total", "?", "", ":", "-", "errno", ";", "}", "if", "(", "n", "==", "0", ")", "break", ";", "size", "-=", "n", ";", "BUG_ON", "(", "size", "<", "0", ")", ";", "b", "->", "bytes", "+=", "n", ";", "total", "+=", "n", ";", "}", "return", "total", ";", "}" ]
Receive data from socket/pipe/chardev to splice buffer
[ "Receive", "data", "from", "socket", "/", "pipe", "/", "chardev", "to", "splice", "buffer" ]
[]
[ { "param": "b", "type": "struct pcs_splice_buf" }, { "param": "fd", "type": "int" }, { "param": "size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "b", "type": "struct pcs_splice_buf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fd", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
07eb6c0476e1b497714f035dadb3c14bab92ed96
acronis/pcs-io
libpcs_io/pcs_splice.c
[ "MIT" ]
C
pcs_splice_buf_send
int
int pcs_splice_buf_send(int fd, struct pcs_splice_buf * b, int size) { int total = 0; while (size > 0) { ssize_t n; BUG_ON(size > b->bytes); n = splice(b->desc, NULL, fd, NULL, size, SPLICE_F_NONBLOCK); if (n < 0) { if (errno == EINTR) continue; return total ? : -errno; } if (n == 0) break; b->bytes -= n; size -= n; b->tag += n; total += n; } return total; }
/* Send data from splice buffer to socket/pipe/chardev */
Send data from splice buffer to socket/pipe/chardev
[ "Send", "data", "from", "splice", "buffer", "to", "socket", "/", "pipe", "/", "chardev" ]
int pcs_splice_buf_send(int fd, struct pcs_splice_buf * b, int size) { int total = 0; while (size > 0) { ssize_t n; BUG_ON(size > b->bytes); n = splice(b->desc, NULL, fd, NULL, size, SPLICE_F_NONBLOCK); if (n < 0) { if (errno == EINTR) continue; return total ? : -errno; } if (n == 0) break; b->bytes -= n; size -= n; b->tag += n; total += n; } return total; }
[ "int", "pcs_splice_buf_send", "(", "int", "fd", ",", "struct", "pcs_splice_buf", "*", "b", ",", "int", "size", ")", "{", "int", "total", "=", "0", ";", "while", "(", "size", ">", "0", ")", "{", "ssize_t", "n", ";", "BUG_ON", "(", "size", ">", "b", "->", "bytes", ")", ";", "n", "=", "splice", "(", "b", "->", "desc", ",", "NULL", ",", "fd", ",", "NULL", ",", "size", ",", "SPLICE_F_NONBLOCK", ")", ";", "if", "(", "n", "<", "0", ")", "{", "if", "(", "errno", "==", "EINTR", ")", "continue", ";", "return", "total", "?", "", ":", "-", "errno", ";", "}", "if", "(", "n", "==", "0", ")", "break", ";", "b", "->", "bytes", "-=", "n", ";", "size", "-=", "n", ";", "b", "->", "tag", "+=", "n", ";", "total", "+=", "n", ";", "}", "return", "total", ";", "}" ]
Send data from splice buffer to socket/pipe/chardev
[ "Send", "data", "from", "splice", "buffer", "to", "socket", "/", "pipe", "/", "chardev" ]
[]
[ { "param": "fd", "type": "int" }, { "param": "b", "type": "struct pcs_splice_buf" }, { "param": "size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fd", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b", "type": "struct pcs_splice_buf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
07eb6c0476e1b497714f035dadb3c14bab92ed96
acronis/pcs-io
libpcs_io/pcs_splice.c
[ "MIT" ]
C
pcs_splice_buf_pwrite
int
int pcs_splice_buf_pwrite(int fd, off_t pos, struct pcs_splice_buf * b) { int total = 0; while (b->bytes) { ssize_t n; n = splice(b->desc, NULL, fd, &pos, b->bytes, SPLICE_F_NONBLOCK); if (n < 0) { if (errno == EINTR) continue; return total ? : -errno; } if (n == 0) break; b->bytes -= n; b->tag += n; pos += n; total += n; } return total; }
/* Write data from splice buffer to seekable file */
Write data from splice buffer to seekable file
[ "Write", "data", "from", "splice", "buffer", "to", "seekable", "file" ]
int pcs_splice_buf_pwrite(int fd, off_t pos, struct pcs_splice_buf * b) { int total = 0; while (b->bytes) { ssize_t n; n = splice(b->desc, NULL, fd, &pos, b->bytes, SPLICE_F_NONBLOCK); if (n < 0) { if (errno == EINTR) continue; return total ? : -errno; } if (n == 0) break; b->bytes -= n; b->tag += n; pos += n; total += n; } return total; }
[ "int", "pcs_splice_buf_pwrite", "(", "int", "fd", ",", "off_t", "pos", ",", "struct", "pcs_splice_buf", "*", "b", ")", "{", "int", "total", "=", "0", ";", "while", "(", "b", "->", "bytes", ")", "{", "ssize_t", "n", ";", "n", "=", "splice", "(", "b", "->", "desc", ",", "NULL", ",", "fd", ",", "&", "pos", ",", "b", "->", "bytes", ",", "SPLICE_F_NONBLOCK", ")", ";", "if", "(", "n", "<", "0", ")", "{", "if", "(", "errno", "==", "EINTR", ")", "continue", ";", "return", "total", "?", "", ":", "-", "errno", ";", "}", "if", "(", "n", "==", "0", ")", "break", ";", "b", "->", "bytes", "-=", "n", ";", "b", "->", "tag", "+=", "n", ";", "pos", "+=", "n", ";", "total", "+=", "n", ";", "}", "return", "total", ";", "}" ]
Write data from splice buffer to seekable file
[ "Write", "data", "from", "splice", "buffer", "to", "seekable", "file" ]
[]
[ { "param": "fd", "type": "int" }, { "param": "pos", "type": "off_t" }, { "param": "b", "type": "struct pcs_splice_buf" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fd", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pos", "type": "off_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b", "type": "struct pcs_splice_buf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
07eb6c0476e1b497714f035dadb3c14bab92ed96
acronis/pcs-io
libpcs_io/pcs_splice.c
[ "MIT" ]
C
pcs_splice_buf_pread
int
int pcs_splice_buf_pread(struct pcs_splice_buf * b, int fd, off_t pos, int size) { int total = 0; while (size > 0) { ssize_t n; n = splice(fd, &pos, b->desc, NULL, size, SPLICE_F_NONBLOCK); if (n < 0) { if (errno == EINTR) continue; return total ? : -errno; } if (n == 0) break; size -= n; b->bytes += n; pos += n; total += n; } return total; }
/* Read data from seekable file to splice buffer */
Read data from seekable file to splice buffer
[ "Read", "data", "from", "seekable", "file", "to", "splice", "buffer" ]
int pcs_splice_buf_pread(struct pcs_splice_buf * b, int fd, off_t pos, int size) { int total = 0; while (size > 0) { ssize_t n; n = splice(fd, &pos, b->desc, NULL, size, SPLICE_F_NONBLOCK); if (n < 0) { if (errno == EINTR) continue; return total ? : -errno; } if (n == 0) break; size -= n; b->bytes += n; pos += n; total += n; } return total; }
[ "int", "pcs_splice_buf_pread", "(", "struct", "pcs_splice_buf", "*", "b", ",", "int", "fd", ",", "off_t", "pos", ",", "int", "size", ")", "{", "int", "total", "=", "0", ";", "while", "(", "size", ">", "0", ")", "{", "ssize_t", "n", ";", "n", "=", "splice", "(", "fd", ",", "&", "pos", ",", "b", "->", "desc", ",", "NULL", ",", "size", ",", "SPLICE_F_NONBLOCK", ")", ";", "if", "(", "n", "<", "0", ")", "{", "if", "(", "errno", "==", "EINTR", ")", "continue", ";", "return", "total", "?", "", ":", "-", "errno", ";", "}", "if", "(", "n", "==", "0", ")", "break", ";", "size", "-=", "n", ";", "b", "->", "bytes", "+=", "n", ";", "pos", "+=", "n", ";", "total", "+=", "n", ";", "}", "return", "total", ";", "}" ]
Read data from seekable file to splice buffer
[ "Read", "data", "from", "seekable", "file", "to", "splice", "buffer" ]
[]
[ { "param": "b", "type": "struct pcs_splice_buf" }, { "param": "fd", "type": "int" }, { "param": "pos", "type": "off_t" }, { "param": "size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "b", "type": "struct pcs_splice_buf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fd", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pos", "type": "off_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
07eb6c0476e1b497714f035dadb3c14bab92ed96
acronis/pcs-io
libpcs_io/pcs_splice.c
[ "MIT" ]
C
pcs_splice_buf_getbytes
int
int pcs_splice_buf_getbytes(struct pcs_splice_buf * b, char * buf, int size) { int total = 0; BUG_ON(size > b->bytes); while (size) { ssize_t n; n = read(b->desc, buf, size); if (n < 0) { if (errno == EINTR) continue; return total ? : -errno; } if (n == 0) break; size -= n; b->bytes -= n; b->tag += n; buf += n; total += n; } return total; }
/* Transfer data from splice buffer to user memory buffer */
Transfer data from splice buffer to user memory buffer
[ "Transfer", "data", "from", "splice", "buffer", "to", "user", "memory", "buffer" ]
int pcs_splice_buf_getbytes(struct pcs_splice_buf * b, char * buf, int size) { int total = 0; BUG_ON(size > b->bytes); while (size) { ssize_t n; n = read(b->desc, buf, size); if (n < 0) { if (errno == EINTR) continue; return total ? : -errno; } if (n == 0) break; size -= n; b->bytes -= n; b->tag += n; buf += n; total += n; } return total; }
[ "int", "pcs_splice_buf_getbytes", "(", "struct", "pcs_splice_buf", "*", "b", ",", "char", "*", "buf", ",", "int", "size", ")", "{", "int", "total", "=", "0", ";", "BUG_ON", "(", "size", ">", "b", "->", "bytes", ")", ";", "while", "(", "size", ")", "{", "ssize_t", "n", ";", "n", "=", "read", "(", "b", "->", "desc", ",", "buf", ",", "size", ")", ";", "if", "(", "n", "<", "0", ")", "{", "if", "(", "errno", "==", "EINTR", ")", "continue", ";", "return", "total", "?", "", ":", "-", "errno", ";", "}", "if", "(", "n", "==", "0", ")", "break", ";", "size", "-=", "n", ";", "b", "->", "bytes", "-=", "n", ";", "b", "->", "tag", "+=", "n", ";", "buf", "+=", "n", ";", "total", "+=", "n", ";", "}", "return", "total", ";", "}" ]
Transfer data from splice buffer to user memory buffer
[ "Transfer", "data", "from", "splice", "buffer", "to", "user", "memory", "buffer" ]
[]
[ { "param": "b", "type": "struct pcs_splice_buf" }, { "param": "buf", "type": "char" }, { "param": "size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "b", "type": "struct pcs_splice_buf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2559fcfc2de5d1090c193f3158b39eb1f874735d
acronis/pcs-io
libpcs_io/pcs_error.c
[ "MIT" ]
C
pcs_strerror
char
const char *pcs_strerror(pcs_err_t errnum) { if ((int)errnum < 0 || errnum >= ARR_SZ(prot_err_list)) return "Unknown error"; return prot_err_list[errnum]; }
/* Get long description of the error */
Get long description of the error
[ "Get", "long", "description", "of", "the", "error" ]
const char *pcs_strerror(pcs_err_t errnum) { if ((int)errnum < 0 || errnum >= ARR_SZ(prot_err_list)) return "Unknown error"; return prot_err_list[errnum]; }
[ "const", "char", "*", "pcs_strerror", "(", "pcs_err_t", "errnum", ")", "{", "if", "(", "(", "int", ")", "errnum", "<", "0", "||", "errnum", ">=", "ARR_SZ", "(", "prot_err_list", ")", ")", "return", "\"", "\"", ";", "return", "prot_err_list", "[", "errnum", "]", ";", "}" ]
Get long description of the error
[ "Get", "long", "description", "of", "the", "error" ]
[]
[ { "param": "errnum", "type": "pcs_err_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "errnum", "type": "pcs_err_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4662e7a3633c6a78c1f1bd0b423f8290349c63b1
acronis/pcs-io
libpcs_io/pcs_shaper.h
[ "MIT" ]
C
pcs_tba_shaper_pass
int
static inline int pcs_tba_shaper_pass(struct pcs_tba_shaper *s, u64 units) { if (!s->out_rate) /* no limit to apply */ return 1; BUG_ON(units > s->cbs); if (s->capacity < units) return 0; s->capacity -= units; return 1; }
/* pass units through shaper, return non zero value if units are allowed to processing */
pass units through shaper, return non zero value if units are allowed to processing
[ "pass", "units", "through", "shaper", "return", "non", "zero", "value", "if", "units", "are", "allowed", "to", "processing" ]
static inline int pcs_tba_shaper_pass(struct pcs_tba_shaper *s, u64 units) { if (!s->out_rate) return 1; BUG_ON(units > s->cbs); if (s->capacity < units) return 0; s->capacity -= units; return 1; }
[ "static", "inline", "int", "pcs_tba_shaper_pass", "(", "struct", "pcs_tba_shaper", "*", "s", ",", "u64", "units", ")", "{", "if", "(", "!", "s", "->", "out_rate", ")", "return", "1", ";", "BUG_ON", "(", "units", ">", "s", "->", "cbs", ")", ";", "if", "(", "s", "->", "capacity", "<", "units", ")", "return", "0", ";", "s", "->", "capacity", "-=", "units", ";", "return", "1", ";", "}" ]
pass units through shaper, return non zero value if units are allowed to processing
[ "pass", "units", "through", "shaper", "return", "non", "zero", "value", "if", "units", "are", "allowed", "to", "processing" ]
[ "/* no limit to apply */" ]
[ { "param": "s", "type": "struct pcs_tba_shaper" }, { "param": "units", "type": "u64" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": "struct pcs_tba_shaper", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "units", "type": "u64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f63e7200b7f68c6f818e907e888ae6efaf17505
Arkq/winpefix
src/MainWindowWin.h
[ "MIT" ]
C
useDefaultPosition
BOOL
BOOL useDefaultPosition() { WNDCLASS wc = { 0 }; WINDOWPLACEMENT wp = { 0 }; wc.lpfnWndProc = DefWindowProc; wc.lpszClassName = TEXT("defaultPosition"); wp.length = sizeof(WINDOWPLACEMENT); RegisterClass(&wc); HWND hWnd = CreateWindow(wc.lpszClassName, NULL, WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, 350, 150, NULL, NULL, NULL, NULL); GetWindowPlacement(hWnd, &wp); DestroyWindow(hWnd); UnregisterClass(wc.lpszClassName, NULL); return SetWindowPos(hDlg, 0, wp.rcNormalPosition.left, wp.rcNormalPosition.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER); }
/* It seems, that there is no other way to place dialog window in the * system default location, than creating temporary invisible window * and then fetching its position. */
It seems, that there is no other way to place dialog window in the system default location, than creating temporary invisible window and then fetching its position.
[ "It", "seems", "that", "there", "is", "no", "other", "way", "to", "place", "dialog", "window", "in", "the", "system", "default", "location", "than", "creating", "temporary", "invisible", "window", "and", "then", "fetching", "its", "position", "." ]
BOOL useDefaultPosition() { WNDCLASS wc = { 0 }; WINDOWPLACEMENT wp = { 0 }; wc.lpfnWndProc = DefWindowProc; wc.lpszClassName = TEXT("defaultPosition"); wp.length = sizeof(WINDOWPLACEMENT); RegisterClass(&wc); HWND hWnd = CreateWindow(wc.lpszClassName, NULL, WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, 350, 150, NULL, NULL, NULL, NULL); GetWindowPlacement(hWnd, &wp); DestroyWindow(hWnd); UnregisterClass(wc.lpszClassName, NULL); return SetWindowPos(hDlg, 0, wp.rcNormalPosition.left, wp.rcNormalPosition.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER); }
[ "BOOL", "useDefaultPosition", "(", ")", "{", "WNDCLASS", "wc", "=", "{", "0", "}", ";", "WINDOWPLACEMENT", "wp", "=", "{", "0", "}", ";", "wc", ".", "lpfnWndProc", "=", "DefWindowProc", ";", "wc", ".", "lpszClassName", "=", "TEXT", "(", "\"", "\"", ")", ";", "wp", ".", "length", "=", "sizeof", "(", "WINDOWPLACEMENT", ")", ";", "RegisterClass", "(", "&", "wc", ")", ";", "HWND", "hWnd", "=", "CreateWindow", "(", "wc", ".", "lpszClassName", ",", "NULL", ",", "WS_OVERLAPPED", ",", "CW_USEDEFAULT", ",", "CW_USEDEFAULT", ",", "350", ",", "150", ",", "NULL", ",", "NULL", ",", "NULL", ",", "NULL", ")", ";", "GetWindowPlacement", "(", "hWnd", ",", "&", "wp", ")", ";", "DestroyWindow", "(", "hWnd", ")", ";", "UnregisterClass", "(", "wc", ".", "lpszClassName", ",", "NULL", ")", ";", "return", "SetWindowPos", "(", "hDlg", ",", "0", ",", "wp", ".", "rcNormalPosition", ".", "left", ",", "wp", ".", "rcNormalPosition", ".", "top", ",", "0", ",", "0", ",", "SWP_NOSIZE", "|", "SWP_NOZORDER", ")", ";", "}" ]
It seems, that there is no other way to place dialog window in the system default location, than creating temporary invisible window and then fetching its position.
[ "It", "seems", "that", "there", "is", "no", "other", "way", "to", "place", "dialog", "window", "in", "the", "system", "default", "location", "than", "creating", "temporary", "invisible", "window", "and", "then", "fetching", "its", "position", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
550fecc4cd552127e65414ddb49fcbb35038305c
john-m-liu/mongo
src/mongo/util/hex.h
[ "Apache-2.0" ]
C
fromHex
int
inline int fromHex(char c) { if ('0' <= c && c <= '9') return c - '0'; if ('a' <= c && c <= 'f') return c - 'a' + 10; if ('A' <= c && c <= 'F') return c - 'A' + 10; verify(false); return 0xff; }
// can't use hex namespace because it conflicts with hex iostream function
can't use hex namespace because it conflicts with hex iostream function
[ "can", "'", "t", "use", "hex", "namespace", "because", "it", "conflicts", "with", "hex", "iostream", "function" ]
inline int fromHex(char c) { if ('0' <= c && c <= '9') return c - '0'; if ('a' <= c && c <= 'f') return c - 'a' + 10; if ('A' <= c && c <= 'F') return c - 'A' + 10; verify(false); return 0xff; }
[ "inline", "int", "fromHex", "(", "char", "c", ")", "{", "if", "(", "'", "'", "<=", "c", "&&", "c", "<=", "'", "'", ")", "return", "c", "-", "'", "'", ";", "if", "(", "'", "'", "<=", "c", "&&", "c", "<=", "'", "'", ")", "return", "c", "-", "'", "'", "+", "10", ";", "if", "(", "'", "'", "<=", "c", "&&", "c", "<=", "'", "'", ")", "return", "c", "-", "'", "'", "+", "10", ";", "verify", "(", "false", ")", ";", "return", "0xff", ";", "}" ]
can't use hex namespace because it conflicts with hex iostream function
[ "can", "'", "t", "use", "hex", "namespace", "because", "it", "conflicts", "with", "hex", "iostream", "function" ]
[]
[ { "param": "c", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "c", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2f4c17a8781ba6d20cbfcf03eaf12f538e7cb820
CobbleVisionAlpha/CobbleVision_SDK_GO_C_CPlusPlus
CobbleVision_SDK.h
[ "MIT" ]
C
deleteMediaFile
char
char deleteMediaFile(char IDArray[]){ char endpoint = "media" if(BaseURL.charAt(sizeOf(BaseURL)-1) != "/"){ printf("BaseURL must end with slash"); exit(0) } bool validResult = checkIDArrayForInvalidIDs(IDArray) if(validResult == false){ printf("Provided Media IDs which are not valid!") exit(0) } cJSONArray json_idArray = cJSON_Parse(IDArray) char response = sendRequestToAPI("DELETE", null, BaseURL + endpoint + "?id=" + cJSON_Print(json_idArray)) return response }
// # This function deletes Media from CobbleVision // # @sync // # @function deleteMediaFile() // # @param {array} IDArray Array of ID's as Strings // # @returns {Response} This return the DeleteMediaResponse. The body is in JSON format.
This function deletes Media from CobbleVision @sync @function deleteMediaFile() @param {array} IDArray Array of ID's as Strings @returns {Response} This return the DeleteMediaResponse. The body is in JSON format.
[ "This", "function", "deletes", "Media", "from", "CobbleVision", "@sync", "@function", "deleteMediaFile", "()", "@param", "{", "array", "}", "IDArray", "Array", "of", "ID", "'", "s", "as", "Strings", "@returns", "{", "Response", "}", "This", "return", "the", "DeleteMediaResponse", ".", "The", "body", "is", "in", "JSON", "format", "." ]
char deleteMediaFile(char IDArray[]){ char endpoint = "media" if(BaseURL.charAt(sizeOf(BaseURL)-1) != "/"){ printf("BaseURL must end with slash"); exit(0) } bool validResult = checkIDArrayForInvalidIDs(IDArray) if(validResult == false){ printf("Provided Media IDs which are not valid!") exit(0) } cJSONArray json_idArray = cJSON_Parse(IDArray) char response = sendRequestToAPI("DELETE", null, BaseURL + endpoint + "?id=" + cJSON_Print(json_idArray)) return response }
[ "char", "deleteMediaFile", "(", "char", "IDArray", "[", "]", ")", "{", "char", "endpoint", "=", "\"", "\"", "", "if", "(", "BaseURL", ".", "charAt", "(", "sizeOf", "(", "BaseURL", ")", "-", "1", ")", "!=", "\"", "\"", ")", "{", "printf", "(", "\"", "\"", ")", ";", "exit", "(", "0", ")", "", "}", "bool", "validResult", "=", "checkIDArrayForInvalidIDs", "(", "IDArray", ")", "", "if", "(", "validResult", "==", "false", ")", "{", "printf", "(", "\"", "\"", ")", "", "exit", "(", "0", ")", "", "}", "cJSONArray", "json_idArray", "=", "cJSON_Parse", "(", "IDArray", ")", "", "char", "response", "=", "sendRequestToAPI", "(", "\"", "\"", ",", "null", ",", "BaseURL", "+", "endpoint", "+", "\"", "\"", "+", "cJSON_Print", "(", "json_idArray", ")", ")", "", "return", "response", "", "}" ]
This function deletes Media from CobbleVision @sync @function deleteMediaFile() @param {array} IDArray Array of ID's as Strings @returns {Response} This return the DeleteMediaResponse.
[ "This", "function", "deletes", "Media", "from", "CobbleVision", "@sync", "@function", "deleteMediaFile", "()", "@param", "{", "array", "}", "IDArray", "Array", "of", "ID", "'", "s", "as", "Strings", "@returns", "{", "Response", "}", "This", "return", "the", "DeleteMediaResponse", "." ]
[]
[ { "param": "IDArray", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "IDArray", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2f4c17a8781ba6d20cbfcf03eaf12f538e7cb820
CobbleVisionAlpha/CobbleVision_SDK_GO_C_CPlusPlus
CobbleVision_SDK.h
[ "MIT" ]
C
launchCalculation
char
char launchCalculation(char algorithms[], char media[], char type, char notificationURL){ char endpoint = "calculation" if(BaseURL.charAt(sizeOf(BaseURL)-1) != "/"){ printf("BaseURL must end with slash"); exit(0) } bool validMedia = checkIDArrayForInvalidIDs(media) if(validMedia == false){ printf("Provided Media IDs which are not valid!") exit(0) } bool validAlgorithms = checkIDArrayForInvalidIDs(algorithms) if(validMedia == false){ printf("Provided Media IDs which are not valid!") exit(0) } //Verify the strchar function on char []. usually used on chars, not char []. if(!strchar(valid_job_types,type)){ printf("Job Type is not valid!") exit(0) } cJSON jsonObject = CJSON_CreateObject() cJSON_AddArrayToObject(jsonObject, "algorithms", algorithms) cJSON_AddArrayToObject(jsonObject, "media", media) cJSON_AddStringToObject(jsonObject, "type", type) cJSON_AddStringToObject(jsonObject, "notificationURL", notificationURL) char response = sendRequestToAPI("POST", jsonObject, BaseURL + endpoint) return response }
// # Launch a calculation with CobbleVision's Web API. Returns a response object with body, response and headers properties, deducted from npm request module; // # @sync // # @function launchCalculation() // # @param {array} algorithms Array of Algorithm Names // # @param {array} media Array of Media ID's // # @param {string} type Type of Job - Currently Always "QueuedJob" // # @param {string} [notificationURL] Optional - Notify user upon finishing calculation! // # @returns {Response} This returns the LaunchCalculationResponse. The body is in JSON format.
Launch a calculation with CobbleVision's Web API.
[ "Launch", "a", "calculation", "with", "CobbleVision", "'", "s", "Web", "API", "." ]
char launchCalculation(char algorithms[], char media[], char type, char notificationURL){ char endpoint = "calculation" if(BaseURL.charAt(sizeOf(BaseURL)-1) != "/"){ printf("BaseURL must end with slash"); exit(0) } bool validMedia = checkIDArrayForInvalidIDs(media) if(validMedia == false){ printf("Provided Media IDs which are not valid!") exit(0) } bool validAlgorithms = checkIDArrayForInvalidIDs(algorithms) if(validMedia == false){ printf("Provided Media IDs which are not valid!") exit(0) } if(!strchar(valid_job_types,type)){ printf("Job Type is not valid!") exit(0) } cJSON jsonObject = CJSON_CreateObject() cJSON_AddArrayToObject(jsonObject, "algorithms", algorithms) cJSON_AddArrayToObject(jsonObject, "media", media) cJSON_AddStringToObject(jsonObject, "type", type) cJSON_AddStringToObject(jsonObject, "notificationURL", notificationURL) char response = sendRequestToAPI("POST", jsonObject, BaseURL + endpoint) return response }
[ "char", "launchCalculation", "(", "char", "algorithms", "[", "]", ",", "char", "media", "[", "]", ",", "char", "type", ",", "char", "notificationURL", ")", "{", "char", "endpoint", "=", "\"", "\"", "", "if", "(", "BaseURL", ".", "charAt", "(", "sizeOf", "(", "BaseURL", ")", "-", "1", ")", "!=", "\"", "\"", ")", "{", "printf", "(", "\"", "\"", ")", ";", "exit", "(", "0", ")", "", "}", "bool", "validMedia", "=", "checkIDArrayForInvalidIDs", "(", "media", ")", "", "if", "(", "validMedia", "==", "false", ")", "{", "printf", "(", "\"", "\"", ")", "", "exit", "(", "0", ")", "", "}", "bool", "validAlgorithms", "=", "checkIDArrayForInvalidIDs", "(", "algorithms", ")", "", "if", "(", "validMedia", "==", "false", ")", "{", "printf", "(", "\"", "\"", ")", "", "exit", "(", "0", ")", "", "}", "if", "(", "!", "strchar", "(", "valid_job_types", ",", "type", ")", ")", "{", "printf", "(", "\"", "\"", ")", "", "exit", "(", "0", ")", "", "}", "cJSON", "jsonObject", "=", "CJSON_CreateObject", "(", ")", "", "cJSON_AddArrayToObject", "(", "jsonObject", ",", "\"", "\"", ",", "algorithms", ")", "", "cJSON_AddArrayToObject", "(", "jsonObject", ",", "\"", "\"", ",", "media", ")", "", "cJSON_AddStringToObject", "(", "jsonObject", ",", "\"", "\"", ",", "type", ")", "", "cJSON_AddStringToObject", "(", "jsonObject", ",", "\"", "\"", ",", "notificationURL", ")", "", "char", "response", "=", "sendRequestToAPI", "(", "\"", "\"", ",", "jsonObject", ",", "BaseURL", "+", "endpoint", ")", "", "return", "response", "", "}" ]
Launch a calculation with CobbleVision's Web API.
[ "Launch", "a", "calculation", "with", "CobbleVision", "'", "s", "Web", "API", "." ]
[ "//Verify the strchar function on char []. usually used on chars, not char []." ]
[ { "param": "algorithms", "type": "char" }, { "param": "media", "type": "char" }, { "param": "type", "type": "char" }, { "param": "notificationURL", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "algorithms", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "media", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "type", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "notificationURL", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2f4c17a8781ba6d20cbfcf03eaf12f538e7cb820
CobbleVisionAlpha/CobbleVision_SDK_GO_C_CPlusPlus
CobbleVision_SDK.h
[ "MIT" ]
C
waitForCalculationCompletion
char
char waitForCalculationCompletion(char IDArray[]){ char endpoint = "calculation" if(BaseURL.charAt(sizeOf(BaseURL)-1) != "/"){ printf("BaseURL must end with slash"); exit(0) } bool validResult = checkIDArrayForInvalidIDs(IDArray) if(validResult == false){ printf("Provided Calculation IDs which are not valid!") exit(0) } cJSONArray json_idArray = cJSON_Parse(IDArray) bool calculationFinishedBool = false; while(!calculationFinishedBool(){ char response = sendRequestToAPI("GET", null, BaseURL + endpoint + "?id=" + cJSON_print(json_idArray), + "&returnOnlyStatusBool=true") cJSONArray responseArray = cJSON_Parse(response) if(cJSON_IsArray(responseArray)){ for(int i=0; i<cJSON_GetArraySize(responseArray); i++){ if(responseArray[i].status){ if(responseArray[i].status != "finished"){ calculationFinishedBool = false } }else{ calculationFinishedBool = false; break; } } }else{ responseJSON = cJSON_Parse(response) if(responseJSON.error){ calculationFinishedBool = true } } } return response }
// # This function waits until the given calculation ID's are ready to be downloaded! // # @sync // # @function waitForCalculationCompletion() // # @param {array} calculationIDArray Array of Calculation ID's // # @returns {Response} This returns the WaitForCalculationResponse. The body is in JSON format.
This function waits until the given calculation ID's are ready to be downloaded. @sync @function waitForCalculationCompletion() @param {array} calculationIDArray Array of Calculation ID's @returns {Response} This returns the WaitForCalculationResponse. The body is in JSON format.
[ "This", "function", "waits", "until", "the", "given", "calculation", "ID", "'", "s", "are", "ready", "to", "be", "downloaded", ".", "@sync", "@function", "waitForCalculationCompletion", "()", "@param", "{", "array", "}", "calculationIDArray", "Array", "of", "Calculation", "ID", "'", "s", "@returns", "{", "Response", "}", "This", "returns", "the", "WaitForCalculationResponse", ".", "The", "body", "is", "in", "JSON", "format", "." ]
char waitForCalculationCompletion(char IDArray[]){ char endpoint = "calculation" if(BaseURL.charAt(sizeOf(BaseURL)-1) != "/"){ printf("BaseURL must end with slash"); exit(0) } bool validResult = checkIDArrayForInvalidIDs(IDArray) if(validResult == false){ printf("Provided Calculation IDs which are not valid!") exit(0) } cJSONArray json_idArray = cJSON_Parse(IDArray) bool calculationFinishedBool = false; while(!calculationFinishedBool(){ char response = sendRequestToAPI("GET", null, BaseURL + endpoint + "?id=" + cJSON_print(json_idArray), + "&returnOnlyStatusBool=true") cJSONArray responseArray = cJSON_Parse(response) if(cJSON_IsArray(responseArray)){ for(int i=0; i<cJSON_GetArraySize(responseArray); i++){ if(responseArray[i].status){ if(responseArray[i].status != "finished"){ calculationFinishedBool = false } }else{ calculationFinishedBool = false; break; } } }else{ responseJSON = cJSON_Parse(response) if(responseJSON.error){ calculationFinishedBool = true } } } return response }
[ "char", "waitForCalculationCompletion", "(", "char", "IDArray", "[", "]", ")", "{", "char", "endpoint", "=", "\"", "\"", "", "if", "(", "BaseURL", ".", "charAt", "(", "sizeOf", "(", "BaseURL", ")", "-", "1", ")", "!=", "\"", "\"", ")", "{", "printf", "(", "\"", "\"", ")", ";", "exit", "(", "0", ")", "", "}", "bool", "validResult", "=", "checkIDArrayForInvalidIDs", "(", "IDArray", ")", "", "if", "(", "validResult", "==", "false", ")", "{", "printf", "(", "\"", "\"", ")", "", "exit", "(", "0", ")", "", "}", "cJSONArray", "json_idArray", "=", "cJSON_Parse", "(", "IDArray", ")", "", "bool", "calculationFinishedBool", "=", "false", ";", "while", "(", "!", "calculationFinishedBool", "(", ")", "", "{", "char", "response", "=", "sendRequestToAPI", "(", "\"", "\"", ",", "null", ",", "BaseURL", "+", "endpoint", "+", "\"", "\"", "+", "cJSON_print", "(", "json_idArray", ")", ",", "+", "\"", "\"", ")", "", "cJSONArray", "responseArray", "=", "cJSON_Parse", "(", "response", ")", "", "if", "(", "cJSON_IsArray", "(", "responseArray", ")", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cJSON_GetArraySize", "(", "responseArray", ")", ";", "i", "++", ")", "{", "if", "(", "responseArray", "[", "i", "]", ".", "status", ")", "{", "if", "(", "responseArray", "[", "i", "]", ".", "status", "!=", "\"", "\"", ")", "{", "calculationFinishedBool", "=", "false", "", "}", "}", "else", "{", "calculationFinishedBool", "=", "false", ";", "break", ";", "}", "}", "}", "else", "{", "responseJSON", "=", "cJSON_Parse", "(", "response", ")", "", "if", "(", "responseJSON", ".", "error", ")", "{", "calculationFinishedBool", "=", "true", "", "}", "}", "}", "return", "response", "", "}" ]
This function waits until the given calculation ID's are ready to be downloaded!
[ "This", "function", "waits", "until", "the", "given", "calculation", "ID", "'", "s", "are", "ready", "to", "be", "downloaded!" ]
[]
[ { "param": "IDArray", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "IDArray", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2f4c17a8781ba6d20cbfcf03eaf12f538e7cb820
CobbleVisionAlpha/CobbleVision_SDK_GO_C_CPlusPlus
CobbleVision_SDK.h
[ "MIT" ]
C
deleteCalculation
char
char deleteCalculation(char IDArray[]){ char endpoint = "calculation" if(BaseURL.charAt(sizeOf(BaseURL)-1) != "/"){ printf("BaseURL must end with slash"); exit(0) } bool validResult = checkIDArrayForInvalidIDs(IDArray) if(validResult == false){ printf("Provided Calculation IDs which are not valid!") exit(0) } cJSONArray json_idArray = cJSON_Parse(IDArray) char response = sendRequestToAPI("DELETE", null, BaseURL + endpoint + "?id=" + cJSON_Print(json_idArray)) return response }
// # This function deletes Result Files or calculations in status "waiting" from CobbleVision. You cannot delete finished jobs beyond their result files, as we keep them for billing purposes. // # @sync // # @function deleteCalculation() // # @param {array} IDArray Array of ID's as Strings // # @returns {Response} This returns the DeleteCalculationResponse. The body is in JSON format.
This function deletes Result Files or calculations in status "waiting" from CobbleVision. You cannot delete finished jobs beyond their result files, as we keep them for billing purposes. @sync @function deleteCalculation() @param {array} IDArray Array of ID's as Strings @returns {Response} This returns the DeleteCalculationResponse. The body is in JSON format.
[ "This", "function", "deletes", "Result", "Files", "or", "calculations", "in", "status", "\"", "waiting", "\"", "from", "CobbleVision", ".", "You", "cannot", "delete", "finished", "jobs", "beyond", "their", "result", "files", "as", "we", "keep", "them", "for", "billing", "purposes", ".", "@sync", "@function", "deleteCalculation", "()", "@param", "{", "array", "}", "IDArray", "Array", "of", "ID", "'", "s", "as", "Strings", "@returns", "{", "Response", "}", "This", "returns", "the", "DeleteCalculationResponse", ".", "The", "body", "is", "in", "JSON", "format", "." ]
char deleteCalculation(char IDArray[]){ char endpoint = "calculation" if(BaseURL.charAt(sizeOf(BaseURL)-1) != "/"){ printf("BaseURL must end with slash"); exit(0) } bool validResult = checkIDArrayForInvalidIDs(IDArray) if(validResult == false){ printf("Provided Calculation IDs which are not valid!") exit(0) } cJSONArray json_idArray = cJSON_Parse(IDArray) char response = sendRequestToAPI("DELETE", null, BaseURL + endpoint + "?id=" + cJSON_Print(json_idArray)) return response }
[ "char", "deleteCalculation", "(", "char", "IDArray", "[", "]", ")", "{", "char", "endpoint", "=", "\"", "\"", "", "if", "(", "BaseURL", ".", "charAt", "(", "sizeOf", "(", "BaseURL", ")", "-", "1", ")", "!=", "\"", "\"", ")", "{", "printf", "(", "\"", "\"", ")", ";", "exit", "(", "0", ")", "", "}", "bool", "validResult", "=", "checkIDArrayForInvalidIDs", "(", "IDArray", ")", "", "if", "(", "validResult", "==", "false", ")", "{", "printf", "(", "\"", "\"", ")", "", "exit", "(", "0", ")", "", "}", "cJSONArray", "json_idArray", "=", "cJSON_Parse", "(", "IDArray", ")", "", "char", "response", "=", "sendRequestToAPI", "(", "\"", "\"", ",", "null", ",", "BaseURL", "+", "endpoint", "+", "\"", "\"", "+", "cJSON_Print", "(", "json_idArray", ")", ")", "", "return", "response", "", "}" ]
This function deletes Result Files or calculations in status "waiting" from CobbleVision.
[ "This", "function", "deletes", "Result", "Files", "or", "calculations", "in", "status", "\"", "waiting", "\"", "from", "CobbleVision", "." ]
[]
[ { "param": "IDArray", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "IDArray", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
edc9e647d0629f9ca2e15a4b9922a3a95fc2d3a9
Yu-Wei-Chang/lab0-c
queue.c
[ "BSD-2-Clause" ]
C
q_free
void
void q_free(queue_t *q) { if (!q) return; if (q->head) { list_ele_t *eleh, *elen; /* element head and next */ eleh = q->head; while (eleh) { elen = eleh->next; free(eleh->value); free(eleh); if (elen) eleh = elen; else eleh = NULL; } } /* Free queue structure */ free(q); }
/* Free all storage used by queue */
Free all storage used by queue
[ "Free", "all", "storage", "used", "by", "queue" ]
void q_free(queue_t *q) { if (!q) return; if (q->head) { list_ele_t *eleh, *elen; eleh = q->head; while (eleh) { elen = eleh->next; free(eleh->value); free(eleh); if (elen) eleh = elen; else eleh = NULL; } } free(q); }
[ "void", "q_free", "(", "queue_t", "*", "q", ")", "{", "if", "(", "!", "q", ")", "return", ";", "if", "(", "q", "->", "head", ")", "{", "list_ele_t", "*", "eleh", ",", "*", "elen", ";", "eleh", "=", "q", "->", "head", ";", "while", "(", "eleh", ")", "{", "elen", "=", "eleh", "->", "next", ";", "free", "(", "eleh", "->", "value", ")", ";", "free", "(", "eleh", ")", ";", "if", "(", "elen", ")", "eleh", "=", "elen", ";", "else", "eleh", "=", "NULL", ";", "}", "}", "free", "(", "q", ")", ";", "}" ]
Free all storage used by queue
[ "Free", "all", "storage", "used", "by", "queue" ]
[ "/* element head and next */", "/* Free queue structure */" ]
[ { "param": "q", "type": "queue_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "queue_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
edc9e647d0629f9ca2e15a4b9922a3a95fc2d3a9
Yu-Wei-Chang/lab0-c
queue.c
[ "BSD-2-Clause" ]
C
q_insert_head
bool
bool q_insert_head(queue_t *q, char *s) { list_ele_t *newh; if (!q) return false; if ((newh = malloc(sizeof(list_ele_t))) == NULL) return false; if ((newh->value = malloc(strlen(s) + 1)) == NULL) { /* Free this element if we allocat value space failed. */ free(newh); return false; } strncpy(newh->value, s, strlen(s) + 1); newh->value[strlen(s)] = '\0'; /* LIFO */ newh->next = q->head; q->head = newh; /* Points tail to this element if this is the first element. */ if (q->size == 0) q->tail = newh; q->size++; return true; }
/* * Attempt to insert element at head of queue. * Return true if successful. * Return false if q is NULL or could not allocate space. * Argument s points to the string to be stored. * The function must explicitly allocate space and copy the string into it. */
Attempt to insert element at head of queue. Return true if successful. Return false if q is NULL or could not allocate space. Argument s points to the string to be stored. The function must explicitly allocate space and copy the string into it.
[ "Attempt", "to", "insert", "element", "at", "head", "of", "queue", ".", "Return", "true", "if", "successful", ".", "Return", "false", "if", "q", "is", "NULL", "or", "could", "not", "allocate", "space", ".", "Argument", "s", "points", "to", "the", "string", "to", "be", "stored", ".", "The", "function", "must", "explicitly", "allocate", "space", "and", "copy", "the", "string", "into", "it", "." ]
bool q_insert_head(queue_t *q, char *s) { list_ele_t *newh; if (!q) return false; if ((newh = malloc(sizeof(list_ele_t))) == NULL) return false; if ((newh->value = malloc(strlen(s) + 1)) == NULL) { free(newh); return false; } strncpy(newh->value, s, strlen(s) + 1); newh->value[strlen(s)] = '\0'; newh->next = q->head; q->head = newh; if (q->size == 0) q->tail = newh; q->size++; return true; }
[ "bool", "q_insert_head", "(", "queue_t", "*", "q", ",", "char", "*", "s", ")", "{", "list_ele_t", "*", "newh", ";", "if", "(", "!", "q", ")", "return", "false", ";", "if", "(", "(", "newh", "=", "malloc", "(", "sizeof", "(", "list_ele_t", ")", ")", ")", "==", "NULL", ")", "return", "false", ";", "if", "(", "(", "newh", "->", "value", "=", "malloc", "(", "strlen", "(", "s", ")", "+", "1", ")", ")", "==", "NULL", ")", "{", "free", "(", "newh", ")", ";", "return", "false", ";", "}", "strncpy", "(", "newh", "->", "value", ",", "s", ",", "strlen", "(", "s", ")", "+", "1", ")", ";", "newh", "->", "value", "[", "strlen", "(", "s", ")", "]", "=", "'", "\\0", "'", ";", "newh", "->", "next", "=", "q", "->", "head", ";", "q", "->", "head", "=", "newh", ";", "if", "(", "q", "->", "size", "==", "0", ")", "q", "->", "tail", "=", "newh", ";", "q", "->", "size", "++", ";", "return", "true", ";", "}" ]
Attempt to insert element at head of queue.
[ "Attempt", "to", "insert", "element", "at", "head", "of", "queue", "." ]
[ "/* Free this element if we allocat value space failed. */", "/* LIFO */", "/* Points tail to this element if this is the first element. */" ]
[ { "param": "q", "type": "queue_t" }, { "param": "s", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "queue_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "s", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
edc9e647d0629f9ca2e15a4b9922a3a95fc2d3a9
Yu-Wei-Chang/lab0-c
queue.c
[ "BSD-2-Clause" ]
C
q_insert_tail
bool
bool q_insert_tail(queue_t *q, char *s) { list_ele_t *newh; if (!q) return false; if ((newh = malloc(sizeof(list_ele_t))) == NULL) return false; if ((newh->value = malloc(strlen(s) + 1)) == NULL) { /* Free this element if we allocat value space failed. */ free(newh); return false; } strncpy(newh->value, s, strlen(s) + 1); newh->value[strlen(s)] = '\0'; /* FIFO */ newh->next = NULL; if (q->size == 0) { /* Points head to this element if this is the first element. */ q->head = newh; } else q->tail->next = newh; q->tail = newh; q->size++; return true; }
/* * Attempt to insert element at tail of queue. * Return true if successful. * Return false if q is NULL or could not allocate space. * Argument s points to the string to be stored. * The function must explicitly allocate space and copy the string into it. */
Attempt to insert element at tail of queue. Return true if successful. Return false if q is NULL or could not allocate space. Argument s points to the string to be stored. The function must explicitly allocate space and copy the string into it.
[ "Attempt", "to", "insert", "element", "at", "tail", "of", "queue", ".", "Return", "true", "if", "successful", ".", "Return", "false", "if", "q", "is", "NULL", "or", "could", "not", "allocate", "space", ".", "Argument", "s", "points", "to", "the", "string", "to", "be", "stored", ".", "The", "function", "must", "explicitly", "allocate", "space", "and", "copy", "the", "string", "into", "it", "." ]
bool q_insert_tail(queue_t *q, char *s) { list_ele_t *newh; if (!q) return false; if ((newh = malloc(sizeof(list_ele_t))) == NULL) return false; if ((newh->value = malloc(strlen(s) + 1)) == NULL) { free(newh); return false; } strncpy(newh->value, s, strlen(s) + 1); newh->value[strlen(s)] = '\0'; newh->next = NULL; if (q->size == 0) { q->head = newh; } else q->tail->next = newh; q->tail = newh; q->size++; return true; }
[ "bool", "q_insert_tail", "(", "queue_t", "*", "q", ",", "char", "*", "s", ")", "{", "list_ele_t", "*", "newh", ";", "if", "(", "!", "q", ")", "return", "false", ";", "if", "(", "(", "newh", "=", "malloc", "(", "sizeof", "(", "list_ele_t", ")", ")", ")", "==", "NULL", ")", "return", "false", ";", "if", "(", "(", "newh", "->", "value", "=", "malloc", "(", "strlen", "(", "s", ")", "+", "1", ")", ")", "==", "NULL", ")", "{", "free", "(", "newh", ")", ";", "return", "false", ";", "}", "strncpy", "(", "newh", "->", "value", ",", "s", ",", "strlen", "(", "s", ")", "+", "1", ")", ";", "newh", "->", "value", "[", "strlen", "(", "s", ")", "]", "=", "'", "\\0", "'", ";", "newh", "->", "next", "=", "NULL", ";", "if", "(", "q", "->", "size", "==", "0", ")", "{", "q", "->", "head", "=", "newh", ";", "}", "else", "q", "->", "tail", "->", "next", "=", "newh", ";", "q", "->", "tail", "=", "newh", ";", "q", "->", "size", "++", ";", "return", "true", ";", "}" ]
Attempt to insert element at tail of queue.
[ "Attempt", "to", "insert", "element", "at", "tail", "of", "queue", "." ]
[ "/* Free this element if we allocat value space failed. */", "/* FIFO */", "/* Points head to this element if this is the first element. */" ]
[ { "param": "q", "type": "queue_t" }, { "param": "s", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "queue_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "s", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
edc9e647d0629f9ca2e15a4b9922a3a95fc2d3a9
Yu-Wei-Chang/lab0-c
queue.c
[ "BSD-2-Clause" ]
C
q_remove_head
bool
bool q_remove_head(queue_t *q, char *sp, size_t bufsize) { list_ele_t *ele; if (!q || !q->head) return false; ele = q->head; q->head = q->head->next; q->size--; if (q->size == 0) q->tail = NULL; if (sp) { if (strlen(ele->value) > bufsize) { strncpy(sp, ele->value, bufsize - 1); sp[bufsize - 1] = '\0'; } else { strncpy(sp, ele->value, strlen(ele->value)); sp[strlen(ele->value)] = '\0'; } } free(ele->value); free(ele); return true; }
/* * Attempt to remove element from head of queue. * Return true if successful. * Return false if queue is NULL or empty. * If sp is non-NULL and an element is removed, copy the removed string to *sp * (up to a maximum of bufsize-1 characters, plus a null terminator.) * The space used by the list element and the string should be freed. */
Attempt to remove element from head of queue. Return true if successful. Return false if queue is NULL or empty. If sp is non-NULL and an element is removed, copy the removed string to *sp (up to a maximum of bufsize-1 characters, plus a null terminator.) The space used by the list element and the string should be freed.
[ "Attempt", "to", "remove", "element", "from", "head", "of", "queue", ".", "Return", "true", "if", "successful", ".", "Return", "false", "if", "queue", "is", "NULL", "or", "empty", ".", "If", "sp", "is", "non", "-", "NULL", "and", "an", "element", "is", "removed", "copy", "the", "removed", "string", "to", "*", "sp", "(", "up", "to", "a", "maximum", "of", "bufsize", "-", "1", "characters", "plus", "a", "null", "terminator", ".", ")", "The", "space", "used", "by", "the", "list", "element", "and", "the", "string", "should", "be", "freed", "." ]
bool q_remove_head(queue_t *q, char *sp, size_t bufsize) { list_ele_t *ele; if (!q || !q->head) return false; ele = q->head; q->head = q->head->next; q->size--; if (q->size == 0) q->tail = NULL; if (sp) { if (strlen(ele->value) > bufsize) { strncpy(sp, ele->value, bufsize - 1); sp[bufsize - 1] = '\0'; } else { strncpy(sp, ele->value, strlen(ele->value)); sp[strlen(ele->value)] = '\0'; } } free(ele->value); free(ele); return true; }
[ "bool", "q_remove_head", "(", "queue_t", "*", "q", ",", "char", "*", "sp", ",", "size_t", "bufsize", ")", "{", "list_ele_t", "*", "ele", ";", "if", "(", "!", "q", "||", "!", "q", "->", "head", ")", "return", "false", ";", "ele", "=", "q", "->", "head", ";", "q", "->", "head", "=", "q", "->", "head", "->", "next", ";", "q", "->", "size", "--", ";", "if", "(", "q", "->", "size", "==", "0", ")", "q", "->", "tail", "=", "NULL", ";", "if", "(", "sp", ")", "{", "if", "(", "strlen", "(", "ele", "->", "value", ")", ">", "bufsize", ")", "{", "strncpy", "(", "sp", ",", "ele", "->", "value", ",", "bufsize", "-", "1", ")", ";", "sp", "[", "bufsize", "-", "1", "]", "=", "'", "\\0", "'", ";", "}", "else", "{", "strncpy", "(", "sp", ",", "ele", "->", "value", ",", "strlen", "(", "ele", "->", "value", ")", ")", ";", "sp", "[", "strlen", "(", "ele", "->", "value", ")", "]", "=", "'", "\\0", "'", ";", "}", "}", "free", "(", "ele", "->", "value", ")", ";", "free", "(", "ele", ")", ";", "return", "true", ";", "}" ]
Attempt to remove element from head of queue.
[ "Attempt", "to", "remove", "element", "from", "head", "of", "queue", "." ]
[]
[ { "param": "q", "type": "queue_t" }, { "param": "sp", "type": "char" }, { "param": "bufsize", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "queue_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sp", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bufsize", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
edc9e647d0629f9ca2e15a4b9922a3a95fc2d3a9
Yu-Wei-Chang/lab0-c
queue.c
[ "BSD-2-Clause" ]
C
q_reverse
void
void q_reverse(queue_t *q) { list_ele_t *ele_prev, *ele_cur, *ele_next; if (!q || !q->head) return; ele_prev = NULL; q->tail = ele_cur = q->head; while (ele_cur) { ele_next = ele_cur->next; ele_cur->next = ele_prev; ele_prev = ele_cur; ele_cur = ele_next; } q->head = ele_prev; }
/* * Reverse elements in queue * No effect if q is NULL or empty * This function should not allocate or free any list elements * (e.g., by calling q_insert_head, q_insert_tail, or q_remove_head). * It should rearrange the existing ones. */
Reverse elements in queue No effect if q is NULL or empty This function should not allocate or free any list elements . It should rearrange the existing ones.
[ "Reverse", "elements", "in", "queue", "No", "effect", "if", "q", "is", "NULL", "or", "empty", "This", "function", "should", "not", "allocate", "or", "free", "any", "list", "elements", ".", "It", "should", "rearrange", "the", "existing", "ones", "." ]
void q_reverse(queue_t *q) { list_ele_t *ele_prev, *ele_cur, *ele_next; if (!q || !q->head) return; ele_prev = NULL; q->tail = ele_cur = q->head; while (ele_cur) { ele_next = ele_cur->next; ele_cur->next = ele_prev; ele_prev = ele_cur; ele_cur = ele_next; } q->head = ele_prev; }
[ "void", "q_reverse", "(", "queue_t", "*", "q", ")", "{", "list_ele_t", "*", "ele_prev", ",", "*", "ele_cur", ",", "*", "ele_next", ";", "if", "(", "!", "q", "||", "!", "q", "->", "head", ")", "return", ";", "ele_prev", "=", "NULL", ";", "q", "->", "tail", "=", "ele_cur", "=", "q", "->", "head", ";", "while", "(", "ele_cur", ")", "{", "ele_next", "=", "ele_cur", "->", "next", ";", "ele_cur", "->", "next", "=", "ele_prev", ";", "ele_prev", "=", "ele_cur", ";", "ele_cur", "=", "ele_next", ";", "}", "q", "->", "head", "=", "ele_prev", ";", "}" ]
Reverse elements in queue No effect if q is NULL or empty This function should not allocate or free any list elements (e.g., by calling q_insert_head, q_insert_tail, or q_remove_head).
[ "Reverse", "elements", "in", "queue", "No", "effect", "if", "q", "is", "NULL", "or", "empty", "This", "function", "should", "not", "allocate", "or", "free", "any", "list", "elements", "(", "e", ".", "g", ".", "by", "calling", "q_insert_head", "q_insert_tail", "or", "q_remove_head", ")", "." ]
[]
[ { "param": "q", "type": "queue_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "queue_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
edc9e647d0629f9ca2e15a4b9922a3a95fc2d3a9
Yu-Wei-Chang/lab0-c
queue.c
[ "BSD-2-Clause" ]
C
q_sort
void
void q_sort(queue_t *q) { if (!q || !q->head) return; if (q->size <= 1) return; q->head = q_mergeSort(q->head); q->tail = q->head; while (q->tail->next) { q->tail = q->tail->next; } }
/* * Sort elements of queue in ascending order * No effect if q is NULL or empty. In addition, if q has only one * element, do nothing. */
Sort elements of queue in ascending order No effect if q is NULL or empty. In addition, if q has only one element, do nothing.
[ "Sort", "elements", "of", "queue", "in", "ascending", "order", "No", "effect", "if", "q", "is", "NULL", "or", "empty", ".", "In", "addition", "if", "q", "has", "only", "one", "element", "do", "nothing", "." ]
void q_sort(queue_t *q) { if (!q || !q->head) return; if (q->size <= 1) return; q->head = q_mergeSort(q->head); q->tail = q->head; while (q->tail->next) { q->tail = q->tail->next; } }
[ "void", "q_sort", "(", "queue_t", "*", "q", ")", "{", "if", "(", "!", "q", "||", "!", "q", "->", "head", ")", "return", ";", "if", "(", "q", "->", "size", "<=", "1", ")", "return", ";", "q", "->", "head", "=", "q_mergeSort", "(", "q", "->", "head", ")", ";", "q", "->", "tail", "=", "q", "->", "head", ";", "while", "(", "q", "->", "tail", "->", "next", ")", "{", "q", "->", "tail", "=", "q", "->", "tail", "->", "next", ";", "}", "}" ]
Sort elements of queue in ascending order No effect if q is NULL or empty.
[ "Sort", "elements", "of", "queue", "in", "ascending", "order", "No", "effect", "if", "q", "is", "NULL", "or", "empty", "." ]
[]
[ { "param": "q", "type": "queue_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "queue_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a466fc5308b20428b60d6b141e1596e00928fa4e
pellucida/jsonlz4_json
src/json_jsonlz4.c
[ "CC0-1.0" ]
C
file_load
int
static int file_load (FILE* input, char** memp, size_t* sizep) { int result = -ENOMEM; int ch = 0; size_t i = 0; size_t finish = -1; char* buffer = 0; size_t buffer_size = 0; while (i!=finish) { ch = fgetc (input); if (ch == EOF) { result = ok; *memp = buffer; *sizep = i; finish = i; } else if (i < buffer_size) { buffer [i++] = ch; } else { size_t newsize = buffer_size ? 2 * buffer_size : MALLOC_START; char* newbuf = realloc (buffer, newsize); if (newbuf) { buffer_size = newsize; buffer = newbuf; buffer [i++] = ch; } else { i = finish; } } } return result; }
// // Read a file into malloc()ed storage //
Read a file into malloc()ed storage
[ "Read", "a", "file", "into", "malloc", "()", "ed", "storage" ]
static int file_load (FILE* input, char** memp, size_t* sizep) { int result = -ENOMEM; int ch = 0; size_t i = 0; size_t finish = -1; char* buffer = 0; size_t buffer_size = 0; while (i!=finish) { ch = fgetc (input); if (ch == EOF) { result = ok; *memp = buffer; *sizep = i; finish = i; } else if (i < buffer_size) { buffer [i++] = ch; } else { size_t newsize = buffer_size ? 2 * buffer_size : MALLOC_START; char* newbuf = realloc (buffer, newsize); if (newbuf) { buffer_size = newsize; buffer = newbuf; buffer [i++] = ch; } else { i = finish; } } } return result; }
[ "static", "int", "file_load", "(", "FILE", "*", "input", ",", "char", "*", "*", "memp", ",", "size_t", "*", "sizep", ")", "{", "int", "result", "=", "-", "ENOMEM", ";", "int", "ch", "=", "0", ";", "size_t", "i", "=", "0", ";", "size_t", "finish", "=", "-1", ";", "char", "*", "buffer", "=", "0", ";", "size_t", "buffer_size", "=", "0", ";", "while", "(", "i", "!=", "finish", ")", "{", "ch", "=", "fgetc", "(", "input", ")", ";", "if", "(", "ch", "==", "EOF", ")", "{", "result", "=", "ok", ";", "*", "memp", "=", "buffer", ";", "*", "sizep", "=", "i", ";", "finish", "=", "i", ";", "}", "else", "if", "(", "i", "<", "buffer_size", ")", "{", "buffer", "[", "i", "++", "]", "=", "ch", ";", "}", "else", "{", "size_t", "newsize", "=", "buffer_size", "?", "2", "*", "buffer_size", ":", "MALLOC_START", ";", "char", "*", "newbuf", "=", "realloc", "(", "buffer", ",", "newsize", ")", ";", "if", "(", "newbuf", ")", "{", "buffer_size", "=", "newsize", ";", "buffer", "=", "newbuf", ";", "buffer", "[", "i", "++", "]", "=", "ch", ";", "}", "else", "{", "i", "=", "finish", ";", "}", "}", "}", "return", "result", ";", "}" ]
Read a file into malloc()ed storage
[ "Read", "a", "file", "into", "malloc", "()", "ed", "storage" ]
[]
[ { "param": "input", "type": "FILE" }, { "param": "memp", "type": "char" }, { "param": "sizep", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "input", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "memp", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sizep", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a466fc5308b20428b60d6b141e1596e00928fa4e
pellucida/jsonlz4_json
src/json_jsonlz4.c
[ "CC0-1.0" ]
C
put_uint32_le_t
uint32_t
static uint32_t put_uint32_le_t (uint32_t le) { uint32_t result = 0; unsigned char x[sizeof(result)]; x[0] = le & 0xff; x[1] = (le >> 8) & 0xff; x[2] = (le >> 8*2) & 0xff; x[3] = (le >> 8*3) & 0xff; memcpy (&result, x, sizeof(x)); return result; }
// // Original size is in Intel little endian byte order // ie LSB first
Original size is in Intel little endian byte order ie LSB first
[ "Original", "size", "is", "in", "Intel", "little", "endian", "byte", "order", "ie", "LSB", "first" ]
static uint32_t put_uint32_le_t (uint32_t le) { uint32_t result = 0; unsigned char x[sizeof(result)]; x[0] = le & 0xff; x[1] = (le >> 8) & 0xff; x[2] = (le >> 8*2) & 0xff; x[3] = (le >> 8*3) & 0xff; memcpy (&result, x, sizeof(x)); return result; }
[ "static", "uint32_t", "put_uint32_le_t", "(", "uint32_t", "le", ")", "{", "uint32_t", "result", "=", "0", ";", "unsigned", "char", "x", "[", "sizeof", "(", "result", ")", "]", ";", "x", "[", "0", "]", "=", "le", "&", "0xff", ";", "x", "[", "1", "]", "=", "(", "le", ">>", "8", ")", "&", "0xff", ";", "x", "[", "2", "]", "=", "(", "le", ">>", "8", "*", "2", ")", "&", "0xff", ";", "x", "[", "3", "]", "=", "(", "le", ">>", "8", "*", "3", ")", "&", "0xff", ";", "memcpy", "(", "&", "result", ",", "x", ",", "sizeof", "(", "x", ")", ")", ";", "return", "result", ";", "}" ]
Original size is in Intel little endian byte order ie LSB first
[ "Original", "size", "is", "in", "Intel", "little", "endian", "byte", "order", "ie", "LSB", "first" ]
[]
[ { "param": "le", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "le", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e666c5b6d87e8e0bbc120ea8f800cc47e70526c6
pellucida/jsonlz4_json
src/jsonlz4_json.c
[ "CC0-1.0" ]
C
file_load
int
static int file_load (FILE* input, char** memp, size_t* sizep) { int result = -ENOMEM; int ch = 0; size_t i = 0; size_t finish = err; char* buffer = 0; size_t buffer_size = 0; while (i!=finish) { ch = fgetc (input); if (ch == EOF) { result = ok; *memp = buffer; *sizep = i; finish = i; } else if (i < buffer_size) { buffer [i++] = ch; } else { size_t newsize = buffer_size ? 2 * buffer_size : MALLOC_START; char* newbuf = realloc (buffer, newsize); if (newbuf) { buffer_size = newsize; buffer = newbuf; buffer [i++] = ch; } else { i = finish; } } } return result; }
// // Read a file into malloc()ed storage //
Read a file into malloc()ed storage
[ "Read", "a", "file", "into", "malloc", "()", "ed", "storage" ]
static int file_load (FILE* input, char** memp, size_t* sizep) { int result = -ENOMEM; int ch = 0; size_t i = 0; size_t finish = err; char* buffer = 0; size_t buffer_size = 0; while (i!=finish) { ch = fgetc (input); if (ch == EOF) { result = ok; *memp = buffer; *sizep = i; finish = i; } else if (i < buffer_size) { buffer [i++] = ch; } else { size_t newsize = buffer_size ? 2 * buffer_size : MALLOC_START; char* newbuf = realloc (buffer, newsize); if (newbuf) { buffer_size = newsize; buffer = newbuf; buffer [i++] = ch; } else { i = finish; } } } return result; }
[ "static", "int", "file_load", "(", "FILE", "*", "input", ",", "char", "*", "*", "memp", ",", "size_t", "*", "sizep", ")", "{", "int", "result", "=", "-", "ENOMEM", ";", "int", "ch", "=", "0", ";", "size_t", "i", "=", "0", ";", "size_t", "finish", "=", "err", ";", "char", "*", "buffer", "=", "0", ";", "size_t", "buffer_size", "=", "0", ";", "while", "(", "i", "!=", "finish", ")", "{", "ch", "=", "fgetc", "(", "input", ")", ";", "if", "(", "ch", "==", "EOF", ")", "{", "result", "=", "ok", ";", "*", "memp", "=", "buffer", ";", "*", "sizep", "=", "i", ";", "finish", "=", "i", ";", "}", "else", "if", "(", "i", "<", "buffer_size", ")", "{", "buffer", "[", "i", "++", "]", "=", "ch", ";", "}", "else", "{", "size_t", "newsize", "=", "buffer_size", "?", "2", "*", "buffer_size", ":", "MALLOC_START", ";", "char", "*", "newbuf", "=", "realloc", "(", "buffer", ",", "newsize", ")", ";", "if", "(", "newbuf", ")", "{", "buffer_size", "=", "newsize", ";", "buffer", "=", "newbuf", ";", "buffer", "[", "i", "++", "]", "=", "ch", ";", "}", "else", "{", "i", "=", "finish", ";", "}", "}", "}", "return", "result", ";", "}" ]
Read a file into malloc()ed storage
[ "Read", "a", "file", "into", "malloc", "()", "ed", "storage" ]
[]
[ { "param": "input", "type": "FILE" }, { "param": "memp", "type": "char" }, { "param": "sizep", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "input", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "memp", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sizep", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e666c5b6d87e8e0bbc120ea8f800cc47e70526c6
pellucida/jsonlz4_json
src/jsonlz4_json.c
[ "CC0-1.0" ]
C
header_load
int
static int header_load (FILE* input, MOZLZ4_HDR* hdr, size_t hdrsize) { int result = err; if (fread (hdr, 1, hdrsize, input) == hdrsize) result = ok; return result; }
// // MOZLZ4 header load/verify magic/get original size //
MOZLZ4 header load/verify magic/get original size
[ "MOZLZ4", "header", "load", "/", "verify", "magic", "/", "get", "original", "size" ]
static int header_load (FILE* input, MOZLZ4_HDR* hdr, size_t hdrsize) { int result = err; if (fread (hdr, 1, hdrsize, input) == hdrsize) result = ok; return result; }
[ "static", "int", "header_load", "(", "FILE", "*", "input", ",", "MOZLZ4_HDR", "*", "hdr", ",", "size_t", "hdrsize", ")", "{", "int", "result", "=", "err", ";", "if", "(", "fread", "(", "hdr", ",", "1", ",", "hdrsize", ",", "input", ")", "==", "hdrsize", ")", "result", "=", "ok", ";", "return", "result", ";", "}" ]
MOZLZ4 header load/verify magic/get original size
[ "MOZLZ4", "header", "load", "/", "verify", "magic", "/", "get", "original", "size" ]
[]
[ { "param": "input", "type": "FILE" }, { "param": "hdr", "type": "MOZLZ4_HDR" }, { "param": "hdrsize", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "input", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "hdr", "type": "MOZLZ4_HDR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "hdrsize", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a895c1389c272a4e74eac993cad9844130d06c34
dahlbyk/libgit2
src/transports/git.c
[ "Apache-2.0" ]
C
gen_proto
int
static int gen_proto(git_buf *request, const char *cmd, const char *url) { char *delim, *repo; char host[] = "host="; size_t len; delim = strchr(url, '/'); if (delim == NULL) { giterr_set(GITERR_NET, "Malformed URL"); return -1; } repo = delim; delim = strchr(url, ':'); if (delim == NULL) delim = strchr(url, '/'); len = 4 + strlen(cmd) + 1 + strlen(repo) + 1 + strlen(host) + (delim - url) + 1; git_buf_grow(request, len); git_buf_printf(request, "%04x%s %s%c%s", (unsigned int)(len & 0x0FFFF), cmd, repo, 0, host); git_buf_put(request, url, delim - url); git_buf_putc(request, '\0'); if (git_buf_oom(request)) return -1; return 0; }
/* * Create a git protocol request. * * For example: 0035git-upload-pack /libgit2/libgit2\0host=github.com\0 */
Create a git protocol request.
[ "Create", "a", "git", "protocol", "request", "." ]
static int gen_proto(git_buf *request, const char *cmd, const char *url) { char *delim, *repo; char host[] = "host="; size_t len; delim = strchr(url, '/'); if (delim == NULL) { giterr_set(GITERR_NET, "Malformed URL"); return -1; } repo = delim; delim = strchr(url, ':'); if (delim == NULL) delim = strchr(url, '/'); len = 4 + strlen(cmd) + 1 + strlen(repo) + 1 + strlen(host) + (delim - url) + 1; git_buf_grow(request, len); git_buf_printf(request, "%04x%s %s%c%s", (unsigned int)(len & 0x0FFFF), cmd, repo, 0, host); git_buf_put(request, url, delim - url); git_buf_putc(request, '\0'); if (git_buf_oom(request)) return -1; return 0; }
[ "static", "int", "gen_proto", "(", "git_buf", "*", "request", ",", "const", "char", "*", "cmd", ",", "const", "char", "*", "url", ")", "{", "char", "*", "delim", ",", "*", "repo", ";", "char", "host", "[", "]", "=", "\"", "\"", ";", "size_t", "len", ";", "delim", "=", "strchr", "(", "url", ",", "'", "'", ")", ";", "if", "(", "delim", "==", "NULL", ")", "{", "giterr_set", "(", "GITERR_NET", ",", "\"", "\"", ")", ";", "return", "-1", ";", "}", "repo", "=", "delim", ";", "delim", "=", "strchr", "(", "url", ",", "'", "'", ")", ";", "if", "(", "delim", "==", "NULL", ")", "delim", "=", "strchr", "(", "url", ",", "'", "'", ")", ";", "len", "=", "4", "+", "strlen", "(", "cmd", ")", "+", "1", "+", "strlen", "(", "repo", ")", "+", "1", "+", "strlen", "(", "host", ")", "+", "(", "delim", "-", "url", ")", "+", "1", ";", "git_buf_grow", "(", "request", ",", "len", ")", ";", "git_buf_printf", "(", "request", ",", "\"", "\"", ",", "(", "unsigned", "int", ")", "(", "len", "&", "0x0FFFF", ")", ",", "cmd", ",", "repo", ",", "0", ",", "host", ")", ";", "git_buf_put", "(", "request", ",", "url", ",", "delim", "-", "url", ")", ";", "git_buf_putc", "(", "request", ",", "'", "\\0", "'", ")", ";", "if", "(", "git_buf_oom", "(", "request", ")", ")", "return", "-1", ";", "return", "0", ";", "}" ]
Create a git protocol request.
[ "Create", "a", "git", "protocol", "request", "." ]
[]
[ { "param": "request", "type": "git_buf" }, { "param": "cmd", "type": "char" }, { "param": "url", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "request", "type": "git_buf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cmd", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "url", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3984f3fe743b3973aa6227df990009d4d2f65248
dahlbyk/libgit2
tests-clar/clone/nonetwork.c
[ "Apache-2.0" ]
C
build_local_file_url
void
static void build_local_file_url(git_buf *out, const char *fixture) { const char *in_buf; git_buf path_buf = GIT_BUF_INIT; cl_git_pass(git_path_prettify_dir(&path_buf, fixture, NULL)); cl_git_pass(git_buf_puts(out, "file://")); #ifdef GIT_WIN32 /* * A FILE uri matches the following format: file://[host]/path * where "host" can be empty and "path" is an absolute path to the resource. * * In this test, no hostname is used, but we have to ensure the leading triple slashes: * * *nix: file:///usr/home/... * Windows: file:///C:/Users/... */ cl_git_pass(git_buf_putc(out, '/')); #endif in_buf = git_buf_cstr(&path_buf); /* * A very hacky Url encoding that only takes care of escaping the spaces */ while (*in_buf) { if (*in_buf == ' ') cl_git_pass(git_buf_puts(out, "%20")); else cl_git_pass(git_buf_putc(out, *in_buf)); in_buf++; } git_buf_free(&path_buf); }
// TODO: This is copy/pasted from network/remotelocal.c.
This is copy/pasted from network/remotelocal.c.
[ "This", "is", "copy", "/", "pasted", "from", "network", "/", "remotelocal", ".", "c", "." ]
static void build_local_file_url(git_buf *out, const char *fixture) { const char *in_buf; git_buf path_buf = GIT_BUF_INIT; cl_git_pass(git_path_prettify_dir(&path_buf, fixture, NULL)); cl_git_pass(git_buf_puts(out, "file://")); #ifdef GIT_WIN32 cl_git_pass(git_buf_putc(out, '/')); #endif in_buf = git_buf_cstr(&path_buf); while (*in_buf) { if (*in_buf == ' ') cl_git_pass(git_buf_puts(out, "%20")); else cl_git_pass(git_buf_putc(out, *in_buf)); in_buf++; } git_buf_free(&path_buf); }
[ "static", "void", "build_local_file_url", "(", "git_buf", "*", "out", ",", "const", "char", "*", "fixture", ")", "{", "const", "char", "*", "in_buf", ";", "git_buf", "path_buf", "=", "GIT_BUF_INIT", ";", "cl_git_pass", "(", "git_path_prettify_dir", "(", "&", "path_buf", ",", "fixture", ",", "NULL", ")", ")", ";", "cl_git_pass", "(", "git_buf_puts", "(", "out", ",", "\"", "\"", ")", ")", ";", "#ifdef", "GIT_WIN32", "cl_git_pass", "(", "git_buf_putc", "(", "out", ",", "'", "'", ")", ")", ";", "#endif", "in_buf", "=", "git_buf_cstr", "(", "&", "path_buf", ")", ";", "while", "(", "*", "in_buf", ")", "{", "if", "(", "*", "in_buf", "==", "'", "'", ")", "cl_git_pass", "(", "git_buf_puts", "(", "out", ",", "\"", "\"", ")", ")", ";", "else", "cl_git_pass", "(", "git_buf_putc", "(", "out", ",", "*", "in_buf", ")", ")", ";", "in_buf", "++", ";", "}", "git_buf_free", "(", "&", "path_buf", ")", ";", "}" ]
TODO: This is copy/pasted from network/remotelocal.c.
[ "TODO", ":", "This", "is", "copy", "/", "pasted", "from", "network", "/", "remotelocal", ".", "c", "." ]
[ "/*\n\t * A FILE uri matches the following format: file://[host]/path\n\t * where \"host\" can be empty and \"path\" is an absolute path to the resource.\n\t *\n\t * In this test, no hostname is used, but we have to ensure the leading triple slashes:\n\t *\n\t * *nix: file:///usr/home/...\n\t * Windows: file:///C:/Users/...\n\t */", "/*\n\t * A very hacky Url encoding that only takes care of escaping the spaces\n\t */" ]
[ { "param": "out", "type": "git_buf" }, { "param": "fixture", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out", "type": "git_buf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fixture", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d7df50137f05753c8e88785fd9e69fa3973dfef8
dahlbyk/libgit2
src/iterator.h
[ "Apache-2.0" ]
C
git_iterator_current
nan
GIT_INLINE(int) git_iterator_current( git_iterator *iter, const git_index_entry **entry) { return iter->current(iter, entry); }
/* Entry is not guaranteed to be fully populated. For a tree iterator, * we will only populate the mode, oid and path, for example. For a workdir * iterator, we will not populate the oid. * * You do not need to free the entry. It is still "owned" by the iterator. * Once you call `git_iterator_advance`, then content of the old entry is * no longer guaranteed to be valid. */
Entry is not guaranteed to be fully populated. For a tree iterator, we will only populate the mode, oid and path, for example. For a workdir iterator, we will not populate the oid. You do not need to free the entry. It is still "owned" by the iterator. Once you call `git_iterator_advance`, then content of the old entry is no longer guaranteed to be valid.
[ "Entry", "is", "not", "guaranteed", "to", "be", "fully", "populated", ".", "For", "a", "tree", "iterator", "we", "will", "only", "populate", "the", "mode", "oid", "and", "path", "for", "example", ".", "For", "a", "workdir", "iterator", "we", "will", "not", "populate", "the", "oid", ".", "You", "do", "not", "need", "to", "free", "the", "entry", ".", "It", "is", "still", "\"", "owned", "\"", "by", "the", "iterator", ".", "Once", "you", "call", "`", "git_iterator_advance", "`", "then", "content", "of", "the", "old", "entry", "is", "no", "longer", "guaranteed", "to", "be", "valid", "." ]
GIT_INLINE(int) git_iterator_current( git_iterator *iter, const git_index_entry **entry) { return iter->current(iter, entry); }
[ "GIT_INLINE", "(", "int", ")", "git_iterator_current", "(", "git_iterator", "*", "iter", ",", "const", "git_index_entry", "*", "*", "entry", ")", "{", "return", "iter", "->", "current", "(", "iter", ",", "entry", ")", ";", "}" ]
Entry is not guaranteed to be fully populated.
[ "Entry", "is", "not", "guaranteed", "to", "be", "fully", "populated", "." ]
[]
[ { "param": "iter", "type": "git_iterator" }, { "param": "entry", "type": "git_index_entry" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "iter", "type": "git_iterator", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "entry", "type": "git_index_entry", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5a3252a86b454d87bfb4f38d14dc0723849c0e32
j1elo/IronAHRS
src/avr/board/IMU6410_SPI.c
[ "Apache-2.0" ]
C
Init_SPI_Master
void
void Init_SPI_Master(void) { // Set MOSI, SCK and SS output, all others input // PB7-SCK, PB6-MISO, PB5-MOSI, PB4-SS, PB3-uSD CS DDRB |= ((1<<PB7)|(1<<PB5)|(1<<PB4)|(1<<PB3)); PORTB |= 0xBC; // Set bits MOSI & SCK // Enable SPI, Master, set clock rate fck // Select SPI Mode 3 - CPOL=1, CPHA=1 clk/8 // SPCR = (1<<SPE)|(1<<MSTR)|(1<<CPOL)|(1<<CPHA)|(1<<SPR0); // Select SPI Mode 3 - CPOL=1, CPHA=1 clk/2 SPCR = (1<<SPE)|(1<<MSTR)|(1<<CPOL)|(1<<CPHA); // Select SPI Mode 0 - CPOL=0, CPHA=0 clk/64 // SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0); // Select SPI Mode 0 - CPOL=0, CPHA=0 clk/2 // SPCR = (1<<SPE)|(1<<MSTR); SPSR = (1 << SPI2X); // Chan's code // SPCR = 0x50; // SPSR = (1 << SPI2X); }
// Initialize SPI Master - note that ADXL345 needs Mode 3 // and uSD usually needs Mode 0 but most SD disk seem to // to work fine with Mode 3 so leave as Mode 3. Also note // that uSD's don't like SPI receive with transmit register // containing 0x00 - set to 0xFF - otherwise CMD8 returns 0x82.
Initialize SPI Master - note that ADXL345 needs Mode 3 and uSD usually needs Mode 0 but most SD disk seem to to work fine with Mode 3 so leave as Mode 3. Also note that uSD's don't like SPI receive with transmit register containing 0x00 - set to 0xFF - otherwise CMD8 returns 0x82.
[ "Initialize", "SPI", "Master", "-", "note", "that", "ADXL345", "needs", "Mode", "3", "and", "uSD", "usually", "needs", "Mode", "0", "but", "most", "SD", "disk", "seem", "to", "to", "work", "fine", "with", "Mode", "3", "so", "leave", "as", "Mode", "3", ".", "Also", "note", "that", "uSD", "'", "s", "don", "'", "t", "like", "SPI", "receive", "with", "transmit", "register", "containing", "0x00", "-", "set", "to", "0xFF", "-", "otherwise", "CMD8", "returns", "0x82", "." ]
void Init_SPI_Master(void) { DDRB |= ((1<<PB7)|(1<<PB5)|(1<<PB4)|(1<<PB3)); PORTB |= 0xBC; SPCR = (1<<SPE)|(1<<MSTR)|(1<<CPOL)|(1<<CPHA); SPSR = (1 << SPI2X); }
[ "void", "Init_SPI_Master", "(", "void", ")", "{", "DDRB", "|=", "(", "(", "1", "<<", "PB7", ")", "|", "(", "1", "<<", "PB5", ")", "|", "(", "1", "<<", "PB4", ")", "|", "(", "1", "<<", "PB3", ")", ")", ";", "PORTB", "|=", "0xBC", ";", "SPCR", "=", "(", "1", "<<", "SPE", ")", "|", "(", "1", "<<", "MSTR", ")", "|", "(", "1", "<<", "CPOL", ")", "|", "(", "1", "<<", "CPHA", ")", ";", "SPSR", "=", "(", "1", "<<", "SPI2X", ")", ";", "}" ]
Initialize SPI Master - note that ADXL345 needs Mode 3 and uSD usually needs Mode 0 but most SD disk seem to to work fine with Mode 3 so leave as Mode 3.
[ "Initialize", "SPI", "Master", "-", "note", "that", "ADXL345", "needs", "Mode", "3", "and", "uSD", "usually", "needs", "Mode", "0", "but", "most", "SD", "disk", "seem", "to", "to", "work", "fine", "with", "Mode", "3", "so", "leave", "as", "Mode", "3", "." ]
[ "// Set MOSI, SCK and SS output, all others input", "// PB7-SCK, PB6-MISO, PB5-MOSI, PB4-SS, PB3-uSD CS", "// Set bits MOSI & SCK", "// Enable SPI, Master, set clock rate fck", "// Select SPI Mode 3 - CPOL=1, CPHA=1 clk/8", "//\tSPCR = (1<<SPE)|(1<<MSTR)|(1<<CPOL)|(1<<CPHA)|(1<<SPR0);", "// Select SPI Mode 3 - CPOL=1, CPHA=1 clk/2", "// Select SPI Mode 0 - CPOL=0, CPHA=0 clk/64", "//\tSPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0);", "// Select SPI Mode 0 - CPOL=0, CPHA=0 clk/2", "//\tSPCR = (1<<SPE)|(1<<MSTR);", "// Chan's code", "//\tSPCR = 0x50;", "// SPSR = (1 << SPI2X);" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
22adecc29638eb02f5d66d6808a6856d23d8fcb9
j1elo/IronAHRS
src/heading/razor_math.c
[ "Apache-2.0" ]
C
Vector_Dot_Product
double
double Vector_Dot_Product(double v1[3], double v2[3]) { double result = 0; for (int c = 0; c < 3; c++) { result += v1[c] * v2[c]; } return result; }
// Computes the dot product of two vectors
Computes the dot product of two vectors
[ "Computes", "the", "dot", "product", "of", "two", "vectors" ]
double Vector_Dot_Product(double v1[3], double v2[3]) { double result = 0; for (int c = 0; c < 3; c++) { result += v1[c] * v2[c]; } return result; }
[ "double", "Vector_Dot_Product", "(", "double", "v1", "[", "3", "]", ",", "double", "v2", "[", "3", "]", ")", "{", "double", "result", "=", "0", ";", "for", "(", "int", "c", "=", "0", ";", "c", "<", "3", ";", "c", "++", ")", "{", "result", "+=", "v1", "[", "c", "]", "*", "v2", "[", "c", "]", ";", "}", "return", "result", ";", "}" ]
Computes the dot product of two vectors
[ "Computes", "the", "dot", "product", "of", "two", "vectors" ]
[]
[ { "param": "v1", "type": "double" }, { "param": "v2", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "v1", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v2", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
22adecc29638eb02f5d66d6808a6856d23d8fcb9
j1elo/IronAHRS
src/heading/razor_math.c
[ "Apache-2.0" ]
C
Vector_Cross_Product
void
void Vector_Cross_Product(double out[3], double v1[3], double v2[3]) { out[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]); out[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]); out[2] = (v1[0] * v2[1]) - (v1[1] * v2[0]); }
// Computes the cross product of two vectors // out has to different from v1 and v2 (no in-place)!
Computes the cross product of two vectors out has to different from v1 and v2 (no in-place)!
[ "Computes", "the", "cross", "product", "of", "two", "vectors", "out", "has", "to", "different", "from", "v1", "and", "v2", "(", "no", "in", "-", "place", ")", "!" ]
void Vector_Cross_Product(double out[3], double v1[3], double v2[3]) { out[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]); out[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]); out[2] = (v1[0] * v2[1]) - (v1[1] * v2[0]); }
[ "void", "Vector_Cross_Product", "(", "double", "out", "[", "3", "]", ",", "double", "v1", "[", "3", "]", ",", "double", "v2", "[", "3", "]", ")", "{", "out", "[", "0", "]", "=", "(", "v1", "[", "1", "]", "*", "v2", "[", "2", "]", ")", "-", "(", "v1", "[", "2", "]", "*", "v2", "[", "1", "]", ")", ";", "out", "[", "1", "]", "=", "(", "v1", "[", "2", "]", "*", "v2", "[", "0", "]", ")", "-", "(", "v1", "[", "0", "]", "*", "v2", "[", "2", "]", ")", ";", "out", "[", "2", "]", "=", "(", "v1", "[", "0", "]", "*", "v2", "[", "1", "]", ")", "-", "(", "v1", "[", "1", "]", "*", "v2", "[", "0", "]", ")", ";", "}" ]
Computes the cross product of two vectors out has to different from v1 and v2 (no in-place)!
[ "Computes", "the", "cross", "product", "of", "two", "vectors", "out", "has", "to", "different", "from", "v1", "and", "v2", "(", "no", "in", "-", "place", ")", "!" ]
[]
[ { "param": "out", "type": "double" }, { "param": "v1", "type": "double" }, { "param": "v2", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v1", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v2", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
22adecc29638eb02f5d66d6808a6856d23d8fcb9
j1elo/IronAHRS
src/heading/razor_math.c
[ "Apache-2.0" ]
C
Vector_Scale
void
void Vector_Scale(double out[3], double v[3], double scale) { for(int c = 0; c < 3; c++) { out[c] = v[c] * scale; } }
// Multiply the vector by a scalar
Multiply the vector by a scalar
[ "Multiply", "the", "vector", "by", "a", "scalar" ]
void Vector_Scale(double out[3], double v[3], double scale) { for(int c = 0; c < 3; c++) { out[c] = v[c] * scale; } }
[ "void", "Vector_Scale", "(", "double", "out", "[", "3", "]", ",", "double", "v", "[", "3", "]", ",", "double", "scale", ")", "{", "for", "(", "int", "c", "=", "0", ";", "c", "<", "3", ";", "c", "++", ")", "{", "out", "[", "c", "]", "=", "v", "[", "c", "]", "*", "scale", ";", "}", "}" ]
Multiply the vector by a scalar
[ "Multiply", "the", "vector", "by", "a", "scalar" ]
[]
[ { "param": "out", "type": "double" }, { "param": "v", "type": "double" }, { "param": "scale", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "scale", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
22adecc29638eb02f5d66d6808a6856d23d8fcb9
j1elo/IronAHRS
src/heading/razor_math.c
[ "Apache-2.0" ]
C
init_rotation_matrix
void
void init_rotation_matrix(double m[3][3], double yaw, double pitch, double roll) { double c1 = cos(roll); double s1 = sin(roll); double c2 = cos(pitch); double s2 = sin(pitch); double c3 = cos(yaw); double s3 = sin(yaw); // Euler angles, right-handed, intrinsic, XYZ convention // (which means: rotate around body axes Z, Y', X'') m[0][0] = c2 * c3; m[0][1] = c3 * s1 * s2 - c1 * s3; m[0][2] = s1 * s3 + c1 * c3 * s2; m[1][0] = c2 * s3; m[1][1] = c1 * c3 + s1 * s2 * s3; m[1][2] = c1 * s2 * s3 - c3 * s1; m[2][0] = -s2; m[2][1] = c2 * s1; m[2][2] = c1 * c2; }
// Init rotation matrix using euler angles
Init rotation matrix using euler angles
[ "Init", "rotation", "matrix", "using", "euler", "angles" ]
void init_rotation_matrix(double m[3][3], double yaw, double pitch, double roll) { double c1 = cos(roll); double s1 = sin(roll); double c2 = cos(pitch); double s2 = sin(pitch); double c3 = cos(yaw); double s3 = sin(yaw); m[0][0] = c2 * c3; m[0][1] = c3 * s1 * s2 - c1 * s3; m[0][2] = s1 * s3 + c1 * c3 * s2; m[1][0] = c2 * s3; m[1][1] = c1 * c3 + s1 * s2 * s3; m[1][2] = c1 * s2 * s3 - c3 * s1; m[2][0] = -s2; m[2][1] = c2 * s1; m[2][2] = c1 * c2; }
[ "void", "init_rotation_matrix", "(", "double", "m", "[", "3", "]", "[", "3", "]", ",", "double", "yaw", ",", "double", "pitch", ",", "double", "roll", ")", "{", "double", "c1", "=", "cos", "(", "roll", ")", ";", "double", "s1", "=", "sin", "(", "roll", ")", ";", "double", "c2", "=", "cos", "(", "pitch", ")", ";", "double", "s2", "=", "sin", "(", "pitch", ")", ";", "double", "c3", "=", "cos", "(", "yaw", ")", ";", "double", "s3", "=", "sin", "(", "yaw", ")", ";", "m", "[", "0", "]", "[", "0", "]", "=", "c2", "*", "c3", ";", "m", "[", "0", "]", "[", "1", "]", "=", "c3", "*", "s1", "*", "s2", "-", "c1", "*", "s3", ";", "m", "[", "0", "]", "[", "2", "]", "=", "s1", "*", "s3", "+", "c1", "*", "c3", "*", "s2", ";", "m", "[", "1", "]", "[", "0", "]", "=", "c2", "*", "s3", ";", "m", "[", "1", "]", "[", "1", "]", "=", "c1", "*", "c3", "+", "s1", "*", "s2", "*", "s3", ";", "m", "[", "1", "]", "[", "2", "]", "=", "c1", "*", "s2", "*", "s3", "-", "c3", "*", "s1", ";", "m", "[", "2", "]", "[", "0", "]", "=", "-", "s2", ";", "m", "[", "2", "]", "[", "1", "]", "=", "c2", "*", "s1", ";", "m", "[", "2", "]", "[", "2", "]", "=", "c1", "*", "c2", ";", "}" ]
Init rotation matrix using euler angles
[ "Init", "rotation", "matrix", "using", "euler", "angles" ]
[ "// Euler angles, right-handed, intrinsic, XYZ convention", "// (which means: rotate around body axes Z, Y', X'')" ]
[ { "param": "m", "type": "double" }, { "param": "yaw", "type": "double" }, { "param": "pitch", "type": "double" }, { "param": "roll", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "m", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "yaw", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pitch", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "roll", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
43f9870debc364dfa481696909b131760bcff326
fallnet/shallot
src/math.c
[ "MIT" ]
C
easygen
RSA
RSA *easygen(uint16_t num, uint8_t len, uint8_t *der, uint8_t edl, SHA_CTX *ctx) { uint8_t der_len; RSA *rsa; for(;;) { // ugly, I know, but better than using goto IMHO rsa = RSA_generate_key(num, 3, NULL, NULL); if(!rsa) // if key generation fails (no [P]RNG seed?) return rsa; // encode RSA key in X.690 DER format uint8_t *tmp = der; der_len = i2d_RSAPublicKey(rsa, &tmp); if(der_len == edl - len + 1) break; // encoded key was the correct size, keep going RSA_free(rsa); // encoded key was the wrong size, try again } // adjust for the actual size of e der[RSA_ADD_DER_OFF] += len - 1; der[der_len - 2] += len - 1; // and prepare our hash context SHA1_Init(ctx); SHA1_Update(ctx, der, der_len - 1); return rsa; }
// wraps RSA key generation, DER encoding, and initial SHA-1 hashing
wraps RSA key generation, DER encoding, and initial SHA-1 hashing
[ "wraps", "RSA", "key", "generation", "DER", "encoding", "and", "initial", "SHA", "-", "1", "hashing" ]
RSA *easygen(uint16_t num, uint8_t len, uint8_t *der, uint8_t edl, SHA_CTX *ctx) { uint8_t der_len; RSA *rsa; for(;;) { rsa = RSA_generate_key(num, 3, NULL, NULL); if(!rsa) return rsa; uint8_t *tmp = der; der_len = i2d_RSAPublicKey(rsa, &tmp); if(der_len == edl - len + 1) break; RSA_free(rsa); } der[RSA_ADD_DER_OFF] += len - 1; der[der_len - 2] += len - 1; SHA1_Init(ctx); SHA1_Update(ctx, der, der_len - 1); return rsa; }
[ "RSA", "*", "easygen", "(", "uint16_t", "num", ",", "uint8_t", "len", ",", "uint8_t", "*", "der", ",", "uint8_t", "edl", ",", "SHA_CTX", "*", "ctx", ")", "{", "uint8_t", "der_len", ";", "RSA", "*", "rsa", ";", "for", "(", ";", ";", ")", "{", "rsa", "=", "RSA_generate_key", "(", "num", ",", "3", ",", "NULL", ",", "NULL", ")", ";", "if", "(", "!", "rsa", ")", "return", "rsa", ";", "uint8_t", "*", "tmp", "=", "der", ";", "der_len", "=", "i2d_RSAPublicKey", "(", "rsa", ",", "&", "tmp", ")", ";", "if", "(", "der_len", "==", "edl", "-", "len", "+", "1", ")", "break", ";", "RSA_free", "(", "rsa", ")", ";", "}", "der", "[", "RSA_ADD_DER_OFF", "]", "+=", "len", "-", "1", ";", "der", "[", "der_len", "-", "2", "]", "+=", "len", "-", "1", ";", "SHA1_Init", "(", "ctx", ")", ";", "SHA1_Update", "(", "ctx", ",", "der", ",", "der_len", "-", "1", ")", ";", "return", "rsa", ";", "}" ]
wraps RSA key generation, DER encoding, and initial SHA-1 hashing
[ "wraps", "RSA", "key", "generation", "DER", "encoding", "and", "initial", "SHA", "-", "1", "hashing" ]
[ "// ugly, I know, but better than using goto IMHO", "// if key generation fails (no [P]RNG seed?)", "// encode RSA key in X.690 DER format", "// encoded key was the correct size, keep going", "// encoded key was the wrong size, try again", "// adjust for the actual size of e", "// and prepare our hash context" ]
[ { "param": "num", "type": "uint16_t" }, { "param": "len", "type": "uint8_t" }, { "param": "der", "type": "uint8_t" }, { "param": "edl", "type": "uint8_t" }, { "param": "ctx", "type": "SHA_CTX" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "num", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "der", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "edl", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": "SHA_CTX", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
72088bc10683f1ca22c078f73697885df071ef5a
qimchen/Apollo_Jimmy
modules/planning/common/indexed_list.h
[ "Apache-2.0" ]
C
Find
T
T* Find(const I id) { auto iter = object_dict_.find(id); if (iter == object_dict_.end()) { return nullptr; } else { return &iter->second; } }
/** * @brief Find object by id in the container * @param id the id of the object * @return the raw pointer to the object if found. * @return nullptr if the object is not found. */
@brief Find object by id in the container @param id the id of the object @return the raw pointer to the object if found. @return nullptr if the object is not found.
[ "@brief", "Find", "object", "by", "id", "in", "the", "container", "@param", "id", "the", "id", "of", "the", "object", "@return", "the", "raw", "pointer", "to", "the", "object", "if", "found", ".", "@return", "nullptr", "if", "the", "object", "is", "not", "found", "." ]
T* Find(const I id) { auto iter = object_dict_.find(id); if (iter == object_dict_.end()) { return nullptr; } else { return &iter->second; } }
[ "T", "*", "Find", "(", "const", "I", "id", ")", "{", "auto", "iter", "", "=", "object_dict_", ".", "find", "(", "id", ")", ";", "if", "(", "iter", "==", "object_dict_", ".", "end", "(", ")", ")", "{", "return", "nullptr", ";", "}", "else", "{", "return", "&", "iter", "->", "second", ";", "}", "}" ]
@brief Find object by id in the container @param id the id of the object @return the raw pointer to the object if found.
[ "@brief", "Find", "object", "by", "id", "in", "the", "container", "@param", "id", "the", "id", "of", "the", "object", "@return", "the", "raw", "pointer", "to", "the", "object", "if", "found", "." ]
[]
[ { "param": "id", "type": "I" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "id", "type": "I", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
eb17fb4a23eb8291fa3ce63d01a84fd63fd38c31
dixyes-bot/libcat
deps/libuv/src/unix/fs.c
[ "Apache-2.0" ]
C
uv__is_buggy_cephfs
int
static int uv__is_buggy_cephfs(int fd) { struct statfs s; if (-1 == fstatfs(fd, &s)) return 0; if (s.f_type != /* CephFS */ 0xC36400) return 0; return uv__kernel_version() < /* 4.20.0 */ 0x041400; }
/* Pre-4.20 kernels have a bug where CephFS uses the RADOS copy-from command * in copy_file_range() when it shouldn't. There is no workaround except to * fall back to a regular copy. */
Pre-4.20 kernels have a bug where CephFS uses the RADOS copy-from command in copy_file_range() when it shouldn't. There is no workaround except to fall back to a regular copy.
[ "Pre", "-", "4", ".", "20", "kernels", "have", "a", "bug", "where", "CephFS", "uses", "the", "RADOS", "copy", "-", "from", "command", "in", "copy_file_range", "()", "when", "it", "shouldn", "'", "t", ".", "There", "is", "no", "workaround", "except", "to", "fall", "back", "to", "a", "regular", "copy", "." ]
static int uv__is_buggy_cephfs(int fd) { struct statfs s; if (-1 == fstatfs(fd, &s)) return 0; if (s.f_type != 0xC36400) return 0; return uv__kernel_version() < 0x041400; }
[ "static", "int", "uv__is_buggy_cephfs", "(", "int", "fd", ")", "{", "struct", "statfs", "s", ";", "if", "(", "-1", "==", "fstatfs", "(", "fd", ",", "&", "s", ")", ")", "return", "0", ";", "if", "(", "s", ".", "f_type", "!=", "0xC36400", ")", "return", "0", ";", "return", "uv__kernel_version", "(", ")", "<", "0x041400", ";", "}" ]
Pre-4.20 kernels have a bug where CephFS uses the RADOS copy-from command in copy_file_range() when it shouldn't.
[ "Pre", "-", "4", ".", "20", "kernels", "have", "a", "bug", "where", "CephFS", "uses", "the", "RADOS", "copy", "-", "from", "command", "in", "copy_file_range", "()", "when", "it", "shouldn", "'", "t", "." ]
[ "/* CephFS */", "/* 4.20.0 */" ]
[ { "param": "fd", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fd", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6c63ac902452a1eb7ebf275fb0721f1d3aaca4dc
dixyes-bot/libcat
src/cat_error.c
[ "Apache-2.0" ]
C
cat_translate_unix_error
cat_errno_t
cat_errno_t cat_translate_unix_error(int error){ #define CAT_ERROR_GEN(name, _)\ if(error == name){\ return CAT_##name;\ } ORIG_ERRNO_MAP(CAT_ERROR_GEN) #undef CAT_ERROR_GEN return CAT_UNCODED; }
/* return uv errno from posix errno */ /* why so WET */
return uv errno from posix errno why so WET
[ "return", "uv", "errno", "from", "posix", "errno", "why", "so", "WET" ]
cat_errno_t cat_translate_unix_error(int error){ #define CAT_ERROR_GEN(name, _)\ if(error == name){\ return CAT_##name;\ } ORIG_ERRNO_MAP(CAT_ERROR_GEN) #undef CAT_ERROR_GEN return CAT_UNCODED; }
[ "cat_errno_t", "cat_translate_unix_error", "(", "int", "error", ")", "{", "#define", "CAT_ERROR_GEN", "(", "name", ",", "_", ")", "\\\n if(error == name){\\\n return CAT_##name;\\\n }", "\n\n", "ORIG_ERRNO_MAP", "(", "CAT_ERROR_GEN", ")", "", "#undef", " CAT_ERROR_GEN", "\n\n", "return", "CAT_UNCODED", ";", "}" ]
return uv errno from posix errno why so WET
[ "return", "uv", "errno", "from", "posix", "errno", "why", "so", "WET" ]
[]
[ { "param": "error", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "error", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
88602c7ee8623f16f87398cf3ffd1f71555fc1a0
dixyes-bot/libcat
deps/libuv/src/win/util.c
[ "Apache-2.0" ]
C
uv__util_init
void
void uv__util_init(void) { LARGE_INTEGER perf_frequency; /* Initialize process title access mutex. */ InitializeCriticalSection(&process_title_lock); /* Retrieve high-resolution timer frequency * and precompute its reciprocal. */ if (QueryPerformanceFrequency(&perf_frequency)) { hrtime_frequency_ = perf_frequency.QuadPart; } else { uv_fatal_error(GetLastError(), "QueryPerformanceFrequency"); } }
/* * One-time initialization code for functionality defined in util.c. */
One-time initialization code for functionality defined in util.c.
[ "One", "-", "time", "initialization", "code", "for", "functionality", "defined", "in", "util", ".", "c", "." ]
void uv__util_init(void) { LARGE_INTEGER perf_frequency; InitializeCriticalSection(&process_title_lock); if (QueryPerformanceFrequency(&perf_frequency)) { hrtime_frequency_ = perf_frequency.QuadPart; } else { uv_fatal_error(GetLastError(), "QueryPerformanceFrequency"); } }
[ "void", "uv__util_init", "(", "void", ")", "{", "LARGE_INTEGER", "perf_frequency", ";", "InitializeCriticalSection", "(", "&", "process_title_lock", ")", ";", "if", "(", "QueryPerformanceFrequency", "(", "&", "perf_frequency", ")", ")", "{", "hrtime_frequency_", "=", "perf_frequency", ".", "QuadPart", ";", "}", "else", "{", "uv_fatal_error", "(", "GetLastError", "(", ")", ",", "\"", "\"", ")", ";", "}", "}" ]
One-time initialization code for functionality defined in util.c.
[ "One", "-", "time", "initialization", "code", "for", "functionality", "defined", "in", "util", ".", "c", "." ]
[ "/* Initialize process title access mutex. */", "/* Retrieve high-resolution timer frequency\n * and precompute its reciprocal.\n */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
88602c7ee8623f16f87398cf3ffd1f71555fc1a0
dixyes-bot/libcat
deps/libuv/src/win/util.c
[ "Apache-2.0" ]
C
uv__convert_utf8_to_utf16
int
int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16) { int bufsize; if (utf8 == NULL) return UV_EINVAL; /* Check how much space we need */ bufsize = MultiByteToWideChar(CP_UTF8, 0, utf8, utf8len, NULL, 0); if (bufsize == 0) return uv_translate_sys_error(GetLastError()); /* Allocate the destination buffer adding an extra byte for the terminating * NULL. If utf8len is not -1 MultiByteToWideChar will not add it, so * we do it ourselves always, just in case. */ *utf16 = uv__malloc(sizeof(WCHAR) * (bufsize + 1)); if (*utf16 == NULL) return UV_ENOMEM; /* Convert to UTF-16 */ bufsize = MultiByteToWideChar(CP_UTF8, 0, utf8, utf8len, *utf16, bufsize); if (bufsize == 0) { uv__free(*utf16); *utf16 = NULL; return uv_translate_sys_error(GetLastError()); } (*utf16)[bufsize] = L'\0'; return 0; }
/* * Converts a UTF-8 string into a UTF-16 one. The resulting string is * null-terminated. * * If utf8 is null terminated, utf8len can be set to -1, otherwise it must * be specified. */
Converts a UTF-8 string into a UTF-16 one. The resulting string is null-terminated. If utf8 is null terminated, utf8len can be set to -1, otherwise it must be specified.
[ "Converts", "a", "UTF", "-", "8", "string", "into", "a", "UTF", "-", "16", "one", ".", "The", "resulting", "string", "is", "null", "-", "terminated", ".", "If", "utf8", "is", "null", "terminated", "utf8len", "can", "be", "set", "to", "-", "1", "otherwise", "it", "must", "be", "specified", "." ]
int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16) { int bufsize; if (utf8 == NULL) return UV_EINVAL; bufsize = MultiByteToWideChar(CP_UTF8, 0, utf8, utf8len, NULL, 0); if (bufsize == 0) return uv_translate_sys_error(GetLastError()); *utf16 = uv__malloc(sizeof(WCHAR) * (bufsize + 1)); if (*utf16 == NULL) return UV_ENOMEM; bufsize = MultiByteToWideChar(CP_UTF8, 0, utf8, utf8len, *utf16, bufsize); if (bufsize == 0) { uv__free(*utf16); *utf16 = NULL; return uv_translate_sys_error(GetLastError()); } (*utf16)[bufsize] = L'\0'; return 0; }
[ "int", "uv__convert_utf8_to_utf16", "(", "const", "char", "*", "utf8", ",", "int", "utf8len", ",", "WCHAR", "*", "*", "utf16", ")", "{", "int", "bufsize", ";", "if", "(", "utf8", "==", "NULL", ")", "return", "UV_EINVAL", ";", "bufsize", "=", "MultiByteToWideChar", "(", "CP_UTF8", ",", "0", ",", "utf8", ",", "utf8len", ",", "NULL", ",", "0", ")", ";", "if", "(", "bufsize", "==", "0", ")", "return", "uv_translate_sys_error", "(", "GetLastError", "(", ")", ")", ";", "*", "utf16", "=", "uv__malloc", "(", "sizeof", "(", "WCHAR", ")", "*", "(", "bufsize", "+", "1", ")", ")", ";", "if", "(", "*", "utf16", "==", "NULL", ")", "return", "UV_ENOMEM", ";", "bufsize", "=", "MultiByteToWideChar", "(", "CP_UTF8", ",", "0", ",", "utf8", ",", "utf8len", ",", "*", "utf16", ",", "bufsize", ")", ";", "if", "(", "bufsize", "==", "0", ")", "{", "uv__free", "(", "*", "utf16", ")", ";", "*", "utf16", "=", "NULL", ";", "return", "uv_translate_sys_error", "(", "GetLastError", "(", ")", ")", ";", "}", "(", "*", "utf16", ")", "[", "bufsize", "]", "=", "L'", "\\0", "'", ";", "return", "0", ";", "}" ]
Converts a UTF-8 string into a UTF-16 one.
[ "Converts", "a", "UTF", "-", "8", "string", "into", "a", "UTF", "-", "16", "one", "." ]
[ "/* Check how much space we need */", "/* Allocate the destination buffer adding an extra byte for the terminating\n * NULL. If utf8len is not -1 MultiByteToWideChar will not add it, so\n * we do it ourselves always, just in case. */", "/* Convert to UTF-16 */" ]
[ { "param": "utf8", "type": "char" }, { "param": "utf8len", "type": "int" }, { "param": "utf16", "type": "WCHAR" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "utf8", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "utf8len", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "utf16", "type": "WCHAR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf4f1f6a5180ab4f6ef6776bc3f854c0c9fe67cd
dixyes-bot/libcat
deps/libuv/src/unix/fsevents.c
[ "Apache-2.0" ]
C
uv__fsevents_push_event
void
static void uv__fsevents_push_event(uv_fs_event_t* handle, QUEUE* events, int err) { assert(events != NULL || err != 0); uv_mutex_lock(&handle->cf_mutex); /* Concatenate two queues */ if (events != NULL) QUEUE_ADD(&handle->cf_events, events); /* Propagate error */ if (err != 0) handle->cf_error = err; uv_mutex_unlock(&handle->cf_mutex); uv_async_send(handle->cf_cb); }
/* Runs in CF thread, pushed event into handle's event list */
Runs in CF thread, pushed event into handle's event list
[ "Runs", "in", "CF", "thread", "pushed", "event", "into", "handle", "'", "s", "event", "list" ]
static void uv__fsevents_push_event(uv_fs_event_t* handle, QUEUE* events, int err) { assert(events != NULL || err != 0); uv_mutex_lock(&handle->cf_mutex); if (events != NULL) QUEUE_ADD(&handle->cf_events, events); if (err != 0) handle->cf_error = err; uv_mutex_unlock(&handle->cf_mutex); uv_async_send(handle->cf_cb); }
[ "static", "void", "uv__fsevents_push_event", "(", "uv_fs_event_t", "*", "handle", ",", "QUEUE", "*", "events", ",", "int", "err", ")", "{", "assert", "(", "events", "!=", "NULL", "||", "err", "!=", "0", ")", ";", "uv_mutex_lock", "(", "&", "handle", "->", "cf_mutex", ")", ";", "if", "(", "events", "!=", "NULL", ")", "QUEUE_ADD", "(", "&", "handle", "->", "cf_events", ",", "events", ")", ";", "if", "(", "err", "!=", "0", ")", "handle", "->", "cf_error", "=", "err", ";", "uv_mutex_unlock", "(", "&", "handle", "->", "cf_mutex", ")", ";", "uv_async_send", "(", "handle", "->", "cf_cb", ")", ";", "}" ]
Runs in CF thread, pushed event into handle's event list
[ "Runs", "in", "CF", "thread", "pushed", "event", "into", "handle", "'", "s", "event", "list" ]
[ "/* Concatenate two queues */", "/* Propagate error */" ]
[ { "param": "handle", "type": "uv_fs_event_t" }, { "param": "events", "type": "QUEUE" }, { "param": "err", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "handle", "type": "uv_fs_event_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "events", "type": "QUEUE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "err", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf4f1f6a5180ab4f6ef6776bc3f854c0c9fe67cd
dixyes-bot/libcat
deps/libuv/src/unix/fsevents.c
[ "Apache-2.0" ]
C
uv__fsevents_event_cb
void
static void uv__fsevents_event_cb(const FSEventStreamRef streamRef, void* info, size_t numEvents, void* eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) { size_t i; int len; char** paths; char* path; char* pos; uv_fs_event_t* handle; QUEUE* q; uv_loop_t* loop; uv__cf_loop_state_t* state; uv__fsevents_event_t* event; FSEventStreamEventFlags flags; QUEUE head; loop = info; state = loop->cf_state; assert(state != NULL); paths = eventPaths; /* For each handle */ uv_mutex_lock(&state->fsevent_mutex); QUEUE_FOREACH(q, &state->fsevent_handles) { handle = QUEUE_DATA(q, uv_fs_event_t, cf_member); QUEUE_INIT(&head); /* Process and filter out events */ for (i = 0; i < numEvents; i++) { flags = eventFlags[i]; /* Ignore system events */ if (flags & kFSEventsSystem) continue; path = paths[i]; len = strlen(path); if (handle->realpath_len == 0) continue; /* This should be unreachable */ /* Filter out paths that are outside handle's request */ if (len < handle->realpath_len) continue; /* Make sure that realpath actually named a directory, * (unless watching root, which alone keeps a trailing slash on the realpath) * or that we matched the whole string */ if (handle->realpath_len != len && handle->realpath_len > 1 && path[handle->realpath_len] != '/') continue; if (memcmp(path, handle->realpath, handle->realpath_len) != 0) continue; if (!(handle->realpath_len == 1 && handle->realpath[0] == '/')) { /* Remove common prefix, unless the watched folder is "/" */ path += handle->realpath_len; len -= handle->realpath_len; /* Ignore events with path equal to directory itself */ if (len <= 1 && (flags & kFSEventStreamEventFlagItemIsDir)) continue; if (len == 0) { /* Since we're using fsevents to watch the file itself, * realpath == path, and we now need to get the basename of the file back * (for commonality with other codepaths and platforms). */ while (len < handle->realpath_len && path[-1] != '/') { path--; len++; } /* Created and Removed seem to be always set, but don't make sense */ flags &= ~kFSEventsRenamed; } else { /* Skip forward slash */ path++; len--; } } /* Do not emit events from subdirectories (without option set) */ if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != '\0') { pos = strchr(path + 1, '/'); if (pos != NULL) continue; } event = uv__malloc(sizeof(*event) + len); if (event == NULL) break; memset(event, 0, sizeof(*event)); memcpy(event->path, path, len + 1); event->events = UV_RENAME; if (0 == (flags & kFSEventsRenamed)) { if (0 != (flags & kFSEventsModified) || 0 == (flags & kFSEventStreamEventFlagItemIsDir)) event->events = UV_CHANGE; } QUEUE_INSERT_TAIL(&head, &event->member); } if (!QUEUE_EMPTY(&head)) uv__fsevents_push_event(handle, &head, 0); } uv_mutex_unlock(&state->fsevent_mutex); }
/* Runs in CF thread, when there're events in FSEventStream */
Runs in CF thread, when there're events in FSEventStream
[ "Runs", "in", "CF", "thread", "when", "there", "'", "re", "events", "in", "FSEventStream" ]
static void uv__fsevents_event_cb(const FSEventStreamRef streamRef, void* info, size_t numEvents, void* eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) { size_t i; int len; char** paths; char* path; char* pos; uv_fs_event_t* handle; QUEUE* q; uv_loop_t* loop; uv__cf_loop_state_t* state; uv__fsevents_event_t* event; FSEventStreamEventFlags flags; QUEUE head; loop = info; state = loop->cf_state; assert(state != NULL); paths = eventPaths; uv_mutex_lock(&state->fsevent_mutex); QUEUE_FOREACH(q, &state->fsevent_handles) { handle = QUEUE_DATA(q, uv_fs_event_t, cf_member); QUEUE_INIT(&head); for (i = 0; i < numEvents; i++) { flags = eventFlags[i]; if (flags & kFSEventsSystem) continue; path = paths[i]; len = strlen(path); if (handle->realpath_len == 0) continue; if (len < handle->realpath_len) continue; if (handle->realpath_len != len && handle->realpath_len > 1 && path[handle->realpath_len] != '/') continue; if (memcmp(path, handle->realpath, handle->realpath_len) != 0) continue; if (!(handle->realpath_len == 1 && handle->realpath[0] == '/')) { path += handle->realpath_len; len -= handle->realpath_len; if (len <= 1 && (flags & kFSEventStreamEventFlagItemIsDir)) continue; if (len == 0) { while (len < handle->realpath_len && path[-1] != '/') { path--; len++; } flags &= ~kFSEventsRenamed; } else { path++; len--; } } if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != '\0') { pos = strchr(path + 1, '/'); if (pos != NULL) continue; } event = uv__malloc(sizeof(*event) + len); if (event == NULL) break; memset(event, 0, sizeof(*event)); memcpy(event->path, path, len + 1); event->events = UV_RENAME; if (0 == (flags & kFSEventsRenamed)) { if (0 != (flags & kFSEventsModified) || 0 == (flags & kFSEventStreamEventFlagItemIsDir)) event->events = UV_CHANGE; } QUEUE_INSERT_TAIL(&head, &event->member); } if (!QUEUE_EMPTY(&head)) uv__fsevents_push_event(handle, &head, 0); } uv_mutex_unlock(&state->fsevent_mutex); }
[ "static", "void", "uv__fsevents_event_cb", "(", "const", "FSEventStreamRef", "streamRef", ",", "void", "*", "info", ",", "size_t", "numEvents", ",", "void", "*", "eventPaths", ",", "const", "FSEventStreamEventFlags", "eventFlags", "[", "]", ",", "const", "FSEventStreamEventId", "eventIds", "[", "]", ")", "{", "size_t", "i", ";", "int", "len", ";", "char", "*", "*", "paths", ";", "char", "*", "path", ";", "char", "*", "pos", ";", "uv_fs_event_t", "*", "handle", ";", "QUEUE", "*", "q", ";", "uv_loop_t", "*", "loop", ";", "uv__cf_loop_state_t", "*", "state", ";", "uv__fsevents_event_t", "*", "event", ";", "FSEventStreamEventFlags", "flags", ";", "QUEUE", "head", ";", "loop", "=", "info", ";", "state", "=", "loop", "->", "cf_state", ";", "assert", "(", "state", "!=", "NULL", ")", ";", "paths", "=", "eventPaths", ";", "uv_mutex_lock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "QUEUE_FOREACH", "(", "q", ",", "&", "state", "->", "fsevent_handles", ")", "", "{", "handle", "=", "QUEUE_DATA", "(", "q", ",", "uv_fs_event_t", ",", "cf_member", ")", ";", "QUEUE_INIT", "(", "&", "head", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "numEvents", ";", "i", "++", ")", "{", "flags", "=", "eventFlags", "[", "i", "]", ";", "if", "(", "flags", "&", "kFSEventsSystem", ")", "continue", ";", "path", "=", "paths", "[", "i", "]", ";", "len", "=", "strlen", "(", "path", ")", ";", "if", "(", "handle", "->", "realpath_len", "==", "0", ")", "continue", ";", "if", "(", "len", "<", "handle", "->", "realpath_len", ")", "continue", ";", "if", "(", "handle", "->", "realpath_len", "!=", "len", "&&", "handle", "->", "realpath_len", ">", "1", "&&", "path", "[", "handle", "->", "realpath_len", "]", "!=", "'", "'", ")", "continue", ";", "if", "(", "memcmp", "(", "path", ",", "handle", "->", "realpath", ",", "handle", "->", "realpath_len", ")", "!=", "0", ")", "continue", ";", "if", "(", "!", "(", "handle", "->", "realpath_len", "==", "1", "&&", "handle", "->", "realpath", "[", "0", "]", "==", "'", "'", ")", ")", "{", "path", "+=", "handle", "->", "realpath_len", ";", "len", "-=", "handle", "->", "realpath_len", ";", "if", "(", "len", "<=", "1", "&&", "(", "flags", "&", "kFSEventStreamEventFlagItemIsDir", ")", ")", "continue", ";", "if", "(", "len", "==", "0", ")", "{", "while", "(", "len", "<", "handle", "->", "realpath_len", "&&", "path", "[", "-1", "]", "!=", "'", "'", ")", "{", "path", "--", ";", "len", "++", ";", "}", "flags", "&=", "~", "kFSEventsRenamed", ";", "}", "else", "{", "path", "++", ";", "len", "--", ";", "}", "}", "if", "(", "(", "handle", "->", "cf_flags", "&", "UV_FS_EVENT_RECURSIVE", ")", "==", "0", "&&", "*", "path", "!=", "'", "\\0", "'", ")", "{", "pos", "=", "strchr", "(", "path", "+", "1", ",", "'", "'", ")", ";", "if", "(", "pos", "!=", "NULL", ")", "continue", ";", "}", "event", "=", "uv__malloc", "(", "sizeof", "(", "*", "event", ")", "+", "len", ")", ";", "if", "(", "event", "==", "NULL", ")", "break", ";", "memset", "(", "event", ",", "0", ",", "sizeof", "(", "*", "event", ")", ")", ";", "memcpy", "(", "event", "->", "path", ",", "path", ",", "len", "+", "1", ")", ";", "event", "->", "events", "=", "UV_RENAME", ";", "if", "(", "0", "==", "(", "flags", "&", "kFSEventsRenamed", ")", ")", "{", "if", "(", "0", "!=", "(", "flags", "&", "kFSEventsModified", ")", "||", "0", "==", "(", "flags", "&", "kFSEventStreamEventFlagItemIsDir", ")", ")", "event", "->", "events", "=", "UV_CHANGE", ";", "}", "QUEUE_INSERT_TAIL", "(", "&", "head", ",", "&", "event", "->", "member", ")", ";", "}", "if", "(", "!", "QUEUE_EMPTY", "(", "&", "head", ")", ")", "uv__fsevents_push_event", "(", "handle", ",", "&", "head", ",", "0", ")", ";", "}", "uv_mutex_unlock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "}" ]
Runs in CF thread, when there're events in FSEventStream
[ "Runs", "in", "CF", "thread", "when", "there", "'", "re", "events", "in", "FSEventStream" ]
[ "/* For each handle */", "/* Process and filter out events */", "/* Ignore system events */", "/* This should be unreachable */", "/* Filter out paths that are outside handle's request */", "/* Make sure that realpath actually named a directory,\n * (unless watching root, which alone keeps a trailing slash on the realpath)\n * or that we matched the whole string */", "/* Remove common prefix, unless the watched folder is \"/\" */", "/* Ignore events with path equal to directory itself */", "/* Since we're using fsevents to watch the file itself,\n * realpath == path, and we now need to get the basename of the file back\n * (for commonality with other codepaths and platforms). */", "/* Created and Removed seem to be always set, but don't make sense */", "/* Skip forward slash */", "/* Do not emit events from subdirectories (without option set) */" ]
[ { "param": "streamRef", "type": "FSEventStreamRef" }, { "param": "info", "type": "void" }, { "param": "numEvents", "type": "size_t" }, { "param": "eventPaths", "type": "void" }, { "param": "eventFlags", "type": "FSEventStreamEventFlags" }, { "param": "eventIds", "type": "FSEventStreamEventId" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "streamRef", "type": "FSEventStreamRef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "info", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "numEvents", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "eventPaths", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "eventFlags", "type": "FSEventStreamEventFlags", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "eventIds", "type": "FSEventStreamEventId", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf4f1f6a5180ab4f6ef6776bc3f854c0c9fe67cd
dixyes-bot/libcat
deps/libuv/src/unix/fsevents.c
[ "Apache-2.0" ]
C
uv__fsevents_reschedule
void
static void uv__fsevents_reschedule(uv_fs_event_t* handle, uv__cf_loop_signal_type_t type) { uv__cf_loop_state_t* state; QUEUE* q; uv_fs_event_t* curr; CFArrayRef cf_paths; CFStringRef* paths; unsigned int i; int err; unsigned int path_count; state = handle->loop->cf_state; paths = NULL; cf_paths = NULL; err = 0; /* NOTE: `i` is used in deallocation loop below */ i = 0; /* Optimization to prevent O(n^2) time spent when starting to watch * many files simultaneously */ uv_mutex_lock(&state->fsevent_mutex); if (state->fsevent_need_reschedule == 0) { uv_mutex_unlock(&state->fsevent_mutex); goto final; } state->fsevent_need_reschedule = 0; uv_mutex_unlock(&state->fsevent_mutex); /* Destroy previous FSEventStream */ uv__fsevents_destroy_stream(handle->loop); /* Any failure below will be a memory failure */ err = UV_ENOMEM; /* Create list of all watched paths */ uv_mutex_lock(&state->fsevent_mutex); path_count = state->fsevent_handle_count; if (path_count != 0) { paths = uv__malloc(sizeof(*paths) * path_count); if (paths == NULL) { uv_mutex_unlock(&state->fsevent_mutex); goto final; } q = &state->fsevent_handles; for (; i < path_count; i++) { q = QUEUE_NEXT(q); assert(q != &state->fsevent_handles); curr = QUEUE_DATA(q, uv_fs_event_t, cf_member); assert(curr->realpath != NULL); paths[i] = pCFStringCreateWithFileSystemRepresentation(NULL, curr->realpath); if (paths[i] == NULL) { uv_mutex_unlock(&state->fsevent_mutex); goto final; } } } uv_mutex_unlock(&state->fsevent_mutex); err = 0; if (path_count != 0) { /* Create new FSEventStream */ cf_paths = pCFArrayCreate(NULL, (const void**) paths, path_count, NULL); if (cf_paths == NULL) { err = UV_ENOMEM; goto final; } err = uv__fsevents_create_stream(handle->loop, cf_paths); } final: /* Deallocate all paths in case of failure */ if (err != 0) { if (cf_paths == NULL) { while (i != 0) pCFRelease(paths[--i]); uv__free(paths); } else { /* CFArray takes ownership of both strings and original C-array */ pCFRelease(cf_paths); } /* Broadcast error to all handles */ uv_mutex_lock(&state->fsevent_mutex); QUEUE_FOREACH(q, &state->fsevent_handles) { curr = QUEUE_DATA(q, uv_fs_event_t, cf_member); uv__fsevents_push_event(curr, NULL, err); } uv_mutex_unlock(&state->fsevent_mutex); } /* * Main thread will block until the removal of handle from the list, * we must tell it when we're ready. * * NOTE: This is coupled with `uv_sem_wait()` in `uv__fsevents_close` */ if (type == kUVCFLoopSignalClosing) uv_sem_post(&state->fsevent_sem); }
/* Runs in CF thread, when there're new fsevent handles to add to stream */
Runs in CF thread, when there're new fsevent handles to add to stream
[ "Runs", "in", "CF", "thread", "when", "there", "'", "re", "new", "fsevent", "handles", "to", "add", "to", "stream" ]
static void uv__fsevents_reschedule(uv_fs_event_t* handle, uv__cf_loop_signal_type_t type) { uv__cf_loop_state_t* state; QUEUE* q; uv_fs_event_t* curr; CFArrayRef cf_paths; CFStringRef* paths; unsigned int i; int err; unsigned int path_count; state = handle->loop->cf_state; paths = NULL; cf_paths = NULL; err = 0; i = 0; uv_mutex_lock(&state->fsevent_mutex); if (state->fsevent_need_reschedule == 0) { uv_mutex_unlock(&state->fsevent_mutex); goto final; } state->fsevent_need_reschedule = 0; uv_mutex_unlock(&state->fsevent_mutex); uv__fsevents_destroy_stream(handle->loop); err = UV_ENOMEM; uv_mutex_lock(&state->fsevent_mutex); path_count = state->fsevent_handle_count; if (path_count != 0) { paths = uv__malloc(sizeof(*paths) * path_count); if (paths == NULL) { uv_mutex_unlock(&state->fsevent_mutex); goto final; } q = &state->fsevent_handles; for (; i < path_count; i++) { q = QUEUE_NEXT(q); assert(q != &state->fsevent_handles); curr = QUEUE_DATA(q, uv_fs_event_t, cf_member); assert(curr->realpath != NULL); paths[i] = pCFStringCreateWithFileSystemRepresentation(NULL, curr->realpath); if (paths[i] == NULL) { uv_mutex_unlock(&state->fsevent_mutex); goto final; } } } uv_mutex_unlock(&state->fsevent_mutex); err = 0; if (path_count != 0) { cf_paths = pCFArrayCreate(NULL, (const void**) paths, path_count, NULL); if (cf_paths == NULL) { err = UV_ENOMEM; goto final; } err = uv__fsevents_create_stream(handle->loop, cf_paths); } final: if (err != 0) { if (cf_paths == NULL) { while (i != 0) pCFRelease(paths[--i]); uv__free(paths); } else { pCFRelease(cf_paths); } uv_mutex_lock(&state->fsevent_mutex); QUEUE_FOREACH(q, &state->fsevent_handles) { curr = QUEUE_DATA(q, uv_fs_event_t, cf_member); uv__fsevents_push_event(curr, NULL, err); } uv_mutex_unlock(&state->fsevent_mutex); } if (type == kUVCFLoopSignalClosing) uv_sem_post(&state->fsevent_sem); }
[ "static", "void", "uv__fsevents_reschedule", "(", "uv_fs_event_t", "*", "handle", ",", "uv__cf_loop_signal_type_t", "type", ")", "{", "uv__cf_loop_state_t", "*", "state", ";", "QUEUE", "*", "q", ";", "uv_fs_event_t", "*", "curr", ";", "CFArrayRef", "cf_paths", ";", "CFStringRef", "*", "paths", ";", "unsigned", "int", "i", ";", "int", "err", ";", "unsigned", "int", "path_count", ";", "state", "=", "handle", "->", "loop", "->", "cf_state", ";", "paths", "=", "NULL", ";", "cf_paths", "=", "NULL", ";", "err", "=", "0", ";", "i", "=", "0", ";", "uv_mutex_lock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "if", "(", "state", "->", "fsevent_need_reschedule", "==", "0", ")", "{", "uv_mutex_unlock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "goto", "final", ";", "}", "state", "->", "fsevent_need_reschedule", "=", "0", ";", "uv_mutex_unlock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "uv__fsevents_destroy_stream", "(", "handle", "->", "loop", ")", ";", "err", "=", "UV_ENOMEM", ";", "uv_mutex_lock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "path_count", "=", "state", "->", "fsevent_handle_count", ";", "if", "(", "path_count", "!=", "0", ")", "{", "paths", "=", "uv__malloc", "(", "sizeof", "(", "*", "paths", ")", "*", "path_count", ")", ";", "if", "(", "paths", "==", "NULL", ")", "{", "uv_mutex_unlock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "goto", "final", ";", "}", "q", "=", "&", "state", "->", "fsevent_handles", ";", "for", "(", ";", "i", "<", "path_count", ";", "i", "++", ")", "{", "q", "=", "QUEUE_NEXT", "(", "q", ")", ";", "assert", "(", "q", "!=", "&", "state", "->", "fsevent_handles", ")", ";", "curr", "=", "QUEUE_DATA", "(", "q", ",", "uv_fs_event_t", ",", "cf_member", ")", ";", "assert", "(", "curr", "->", "realpath", "!=", "NULL", ")", ";", "paths", "[", "i", "]", "=", "pCFStringCreateWithFileSystemRepresentation", "(", "NULL", ",", "curr", "->", "realpath", ")", ";", "if", "(", "paths", "[", "i", "]", "==", "NULL", ")", "{", "uv_mutex_unlock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "goto", "final", ";", "}", "}", "}", "uv_mutex_unlock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "err", "=", "0", ";", "if", "(", "path_count", "!=", "0", ")", "{", "cf_paths", "=", "pCFArrayCreate", "(", "NULL", ",", "(", "const", "void", "*", "*", ")", "paths", ",", "path_count", ",", "NULL", ")", ";", "if", "(", "cf_paths", "==", "NULL", ")", "{", "err", "=", "UV_ENOMEM", ";", "goto", "final", ";", "}", "err", "=", "uv__fsevents_create_stream", "(", "handle", "->", "loop", ",", "cf_paths", ")", ";", "}", "final", ":", "if", "(", "err", "!=", "0", ")", "{", "if", "(", "cf_paths", "==", "NULL", ")", "{", "while", "(", "i", "!=", "0", ")", "pCFRelease", "(", "paths", "[", "--", "i", "]", ")", ";", "uv__free", "(", "paths", ")", ";", "}", "else", "{", "pCFRelease", "(", "cf_paths", ")", ";", "}", "uv_mutex_lock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "QUEUE_FOREACH", "(", "q", ",", "&", "state", "->", "fsevent_handles", ")", "", "{", "curr", "=", "QUEUE_DATA", "(", "q", ",", "uv_fs_event_t", ",", "cf_member", ")", ";", "uv__fsevents_push_event", "(", "curr", ",", "NULL", ",", "err", ")", ";", "}", "uv_mutex_unlock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "}", "if", "(", "type", "==", "kUVCFLoopSignalClosing", ")", "uv_sem_post", "(", "&", "state", "->", "fsevent_sem", ")", ";", "}" ]
Runs in CF thread, when there're new fsevent handles to add to stream
[ "Runs", "in", "CF", "thread", "when", "there", "'", "re", "new", "fsevent", "handles", "to", "add", "to", "stream" ]
[ "/* NOTE: `i` is used in deallocation loop below */", "/* Optimization to prevent O(n^2) time spent when starting to watch\n * many files simultaneously\n */", "/* Destroy previous FSEventStream */", "/* Any failure below will be a memory failure */", "/* Create list of all watched paths */", "/* Create new FSEventStream */", "/* Deallocate all paths in case of failure */", "/* CFArray takes ownership of both strings and original C-array */", "/* Broadcast error to all handles */", "/*\n * Main thread will block until the removal of handle from the list,\n * we must tell it when we're ready.\n *\n * NOTE: This is coupled with `uv_sem_wait()` in `uv__fsevents_close`\n */" ]
[ { "param": "handle", "type": "uv_fs_event_t" }, { "param": "type", "type": "uv__cf_loop_signal_type_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "handle", "type": "uv_fs_event_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "type", "type": "uv__cf_loop_signal_type_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf4f1f6a5180ab4f6ef6776bc3f854c0c9fe67cd
dixyes-bot/libcat
deps/libuv/src/unix/fsevents.c
[ "Apache-2.0" ]
C
uv__cf_loop_runner
void
static void* uv__cf_loop_runner(void* arg) { uv_loop_t* loop; uv__cf_loop_state_t* state; loop = arg; state = loop->cf_state; state->loop = pCFRunLoopGetCurrent(); pCFRunLoopAddSource(state->loop, state->signal_source, *pkCFRunLoopDefaultMode); uv_sem_post(&loop->cf_sem); pCFRunLoopRun(); pCFRunLoopRemoveSource(state->loop, state->signal_source, *pkCFRunLoopDefaultMode); state->loop = NULL; return NULL; }
/* Runs in CF thread. This is the CF loop's body */
Runs in CF thread. This is the CF loop's body
[ "Runs", "in", "CF", "thread", ".", "This", "is", "the", "CF", "loop", "'", "s", "body" ]
static void* uv__cf_loop_runner(void* arg) { uv_loop_t* loop; uv__cf_loop_state_t* state; loop = arg; state = loop->cf_state; state->loop = pCFRunLoopGetCurrent(); pCFRunLoopAddSource(state->loop, state->signal_source, *pkCFRunLoopDefaultMode); uv_sem_post(&loop->cf_sem); pCFRunLoopRun(); pCFRunLoopRemoveSource(state->loop, state->signal_source, *pkCFRunLoopDefaultMode); state->loop = NULL; return NULL; }
[ "static", "void", "*", "uv__cf_loop_runner", "(", "void", "*", "arg", ")", "{", "uv_loop_t", "*", "loop", ";", "uv__cf_loop_state_t", "*", "state", ";", "loop", "=", "arg", ";", "state", "=", "loop", "->", "cf_state", ";", "state", "->", "loop", "=", "pCFRunLoopGetCurrent", "(", ")", ";", "pCFRunLoopAddSource", "(", "state", "->", "loop", ",", "state", "->", "signal_source", ",", "*", "pkCFRunLoopDefaultMode", ")", ";", "uv_sem_post", "(", "&", "loop", "->", "cf_sem", ")", ";", "pCFRunLoopRun", "(", ")", ";", "pCFRunLoopRemoveSource", "(", "state", "->", "loop", ",", "state", "->", "signal_source", ",", "*", "pkCFRunLoopDefaultMode", ")", ";", "state", "->", "loop", "=", "NULL", ";", "return", "NULL", ";", "}" ]
Runs in CF thread.
[ "Runs", "in", "CF", "thread", "." ]
[]
[ { "param": "arg", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "arg", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf4f1f6a5180ab4f6ef6776bc3f854c0c9fe67cd
dixyes-bot/libcat
deps/libuv/src/unix/fsevents.c
[ "Apache-2.0" ]
C
uv__cf_loop_signal
int
int uv__cf_loop_signal(uv_loop_t* loop, uv_fs_event_t* handle, uv__cf_loop_signal_type_t type) { uv__cf_loop_signal_t* item; uv__cf_loop_state_t* state; item = uv__malloc(sizeof(*item)); if (item == NULL) return UV_ENOMEM; item->handle = handle; item->type = type; uv_mutex_lock(&loop->cf_mutex); QUEUE_INSERT_TAIL(&loop->cf_signals, &item->member); state = loop->cf_state; assert(state != NULL); pCFRunLoopSourceSignal(state->signal_source); pCFRunLoopWakeUp(state->loop); uv_mutex_unlock(&loop->cf_mutex); return 0; }
/* Runs in UV loop to notify CF thread */
Runs in UV loop to notify CF thread
[ "Runs", "in", "UV", "loop", "to", "notify", "CF", "thread" ]
int uv__cf_loop_signal(uv_loop_t* loop, uv_fs_event_t* handle, uv__cf_loop_signal_type_t type) { uv__cf_loop_signal_t* item; uv__cf_loop_state_t* state; item = uv__malloc(sizeof(*item)); if (item == NULL) return UV_ENOMEM; item->handle = handle; item->type = type; uv_mutex_lock(&loop->cf_mutex); QUEUE_INSERT_TAIL(&loop->cf_signals, &item->member); state = loop->cf_state; assert(state != NULL); pCFRunLoopSourceSignal(state->signal_source); pCFRunLoopWakeUp(state->loop); uv_mutex_unlock(&loop->cf_mutex); return 0; }
[ "int", "uv__cf_loop_signal", "(", "uv_loop_t", "*", "loop", ",", "uv_fs_event_t", "*", "handle", ",", "uv__cf_loop_signal_type_t", "type", ")", "{", "uv__cf_loop_signal_t", "*", "item", ";", "uv__cf_loop_state_t", "*", "state", ";", "item", "=", "uv__malloc", "(", "sizeof", "(", "*", "item", ")", ")", ";", "if", "(", "item", "==", "NULL", ")", "return", "UV_ENOMEM", ";", "item", "->", "handle", "=", "handle", ";", "item", "->", "type", "=", "type", ";", "uv_mutex_lock", "(", "&", "loop", "->", "cf_mutex", ")", ";", "QUEUE_INSERT_TAIL", "(", "&", "loop", "->", "cf_signals", ",", "&", "item", "->", "member", ")", ";", "state", "=", "loop", "->", "cf_state", ";", "assert", "(", "state", "!=", "NULL", ")", ";", "pCFRunLoopSourceSignal", "(", "state", "->", "signal_source", ")", ";", "pCFRunLoopWakeUp", "(", "state", "->", "loop", ")", ";", "uv_mutex_unlock", "(", "&", "loop", "->", "cf_mutex", ")", ";", "return", "0", ";", "}" ]
Runs in UV loop to notify CF thread
[ "Runs", "in", "UV", "loop", "to", "notify", "CF", "thread" ]
[]
[ { "param": "loop", "type": "uv_loop_t" }, { "param": "handle", "type": "uv_fs_event_t" }, { "param": "type", "type": "uv__cf_loop_signal_type_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "uv_loop_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "handle", "type": "uv_fs_event_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "type", "type": "uv__cf_loop_signal_type_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bf4f1f6a5180ab4f6ef6776bc3f854c0c9fe67cd
dixyes-bot/libcat
deps/libuv/src/unix/fsevents.c
[ "Apache-2.0" ]
C
uv__fsevents_init
int
int uv__fsevents_init(uv_fs_event_t* handle) { int err; uv__cf_loop_state_t* state; err = uv__fsevents_loop_init(handle->loop); if (err) return err; /* Get absolute path to file */ handle->realpath = realpath(handle->path, NULL); if (handle->realpath == NULL) return UV__ERR(errno); handle->realpath_len = strlen(handle->realpath); /* Initialize event queue */ QUEUE_INIT(&handle->cf_events); handle->cf_error = 0; /* * Events will occur in other thread. * Initialize callback for getting them back into event loop's thread */ handle->cf_cb = uv__malloc(sizeof(*handle->cf_cb)); if (handle->cf_cb == NULL) { err = UV_ENOMEM; goto fail_cf_cb_malloc; } handle->cf_cb->data = handle; uv_async_init(handle->loop, handle->cf_cb, uv__fsevents_cb); handle->cf_cb->flags |= UV_HANDLE_INTERNAL; uv_unref((uv_handle_t*) handle->cf_cb); err = uv_mutex_init(&handle->cf_mutex); if (err) goto fail_cf_mutex_init; /* Insert handle into the list */ state = handle->loop->cf_state; uv_mutex_lock(&state->fsevent_mutex); QUEUE_INSERT_TAIL(&state->fsevent_handles, &handle->cf_member); state->fsevent_handle_count++; state->fsevent_need_reschedule = 1; uv_mutex_unlock(&state->fsevent_mutex); /* Reschedule FSEventStream */ assert(handle != NULL); err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalRegular); if (err) goto fail_loop_signal; return 0; fail_loop_signal: uv_mutex_destroy(&handle->cf_mutex); fail_cf_mutex_init: uv__free(handle->cf_cb); handle->cf_cb = NULL; fail_cf_cb_malloc: uv__free(handle->realpath); handle->realpath = NULL; handle->realpath_len = 0; return err; }
/* Runs in UV loop to initialize handle */
Runs in UV loop to initialize handle
[ "Runs", "in", "UV", "loop", "to", "initialize", "handle" ]
int uv__fsevents_init(uv_fs_event_t* handle) { int err; uv__cf_loop_state_t* state; err = uv__fsevents_loop_init(handle->loop); if (err) return err; handle->realpath = realpath(handle->path, NULL); if (handle->realpath == NULL) return UV__ERR(errno); handle->realpath_len = strlen(handle->realpath); QUEUE_INIT(&handle->cf_events); handle->cf_error = 0; handle->cf_cb = uv__malloc(sizeof(*handle->cf_cb)); if (handle->cf_cb == NULL) { err = UV_ENOMEM; goto fail_cf_cb_malloc; } handle->cf_cb->data = handle; uv_async_init(handle->loop, handle->cf_cb, uv__fsevents_cb); handle->cf_cb->flags |= UV_HANDLE_INTERNAL; uv_unref((uv_handle_t*) handle->cf_cb); err = uv_mutex_init(&handle->cf_mutex); if (err) goto fail_cf_mutex_init; state = handle->loop->cf_state; uv_mutex_lock(&state->fsevent_mutex); QUEUE_INSERT_TAIL(&state->fsevent_handles, &handle->cf_member); state->fsevent_handle_count++; state->fsevent_need_reschedule = 1; uv_mutex_unlock(&state->fsevent_mutex); assert(handle != NULL); err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalRegular); if (err) goto fail_loop_signal; return 0; fail_loop_signal: uv_mutex_destroy(&handle->cf_mutex); fail_cf_mutex_init: uv__free(handle->cf_cb); handle->cf_cb = NULL; fail_cf_cb_malloc: uv__free(handle->realpath); handle->realpath = NULL; handle->realpath_len = 0; return err; }
[ "int", "uv__fsevents_init", "(", "uv_fs_event_t", "*", "handle", ")", "{", "int", "err", ";", "uv__cf_loop_state_t", "*", "state", ";", "err", "=", "uv__fsevents_loop_init", "(", "handle", "->", "loop", ")", ";", "if", "(", "err", ")", "return", "err", ";", "handle", "->", "realpath", "=", "realpath", "(", "handle", "->", "path", ",", "NULL", ")", ";", "if", "(", "handle", "->", "realpath", "==", "NULL", ")", "return", "UV__ERR", "(", "errno", ")", ";", "handle", "->", "realpath_len", "=", "strlen", "(", "handle", "->", "realpath", ")", ";", "QUEUE_INIT", "(", "&", "handle", "->", "cf_events", ")", ";", "handle", "->", "cf_error", "=", "0", ";", "handle", "->", "cf_cb", "=", "uv__malloc", "(", "sizeof", "(", "*", "handle", "->", "cf_cb", ")", ")", ";", "if", "(", "handle", "->", "cf_cb", "==", "NULL", ")", "{", "err", "=", "UV_ENOMEM", ";", "goto", "fail_cf_cb_malloc", ";", "}", "handle", "->", "cf_cb", "->", "data", "=", "handle", ";", "uv_async_init", "(", "handle", "->", "loop", ",", "handle", "->", "cf_cb", ",", "uv__fsevents_cb", ")", ";", "handle", "->", "cf_cb", "->", "flags", "|=", "UV_HANDLE_INTERNAL", ";", "uv_unref", "(", "(", "uv_handle_t", "*", ")", "handle", "->", "cf_cb", ")", ";", "err", "=", "uv_mutex_init", "(", "&", "handle", "->", "cf_mutex", ")", ";", "if", "(", "err", ")", "goto", "fail_cf_mutex_init", ";", "state", "=", "handle", "->", "loop", "->", "cf_state", ";", "uv_mutex_lock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "QUEUE_INSERT_TAIL", "(", "&", "state", "->", "fsevent_handles", ",", "&", "handle", "->", "cf_member", ")", ";", "state", "->", "fsevent_handle_count", "++", ";", "state", "->", "fsevent_need_reschedule", "=", "1", ";", "uv_mutex_unlock", "(", "&", "state", "->", "fsevent_mutex", ")", ";", "assert", "(", "handle", "!=", "NULL", ")", ";", "err", "=", "uv__cf_loop_signal", "(", "handle", "->", "loop", ",", "handle", ",", "kUVCFLoopSignalRegular", ")", ";", "if", "(", "err", ")", "goto", "fail_loop_signal", ";", "return", "0", ";", "fail_loop_signal", ":", "uv_mutex_destroy", "(", "&", "handle", "->", "cf_mutex", ")", ";", "fail_cf_mutex_init", ":", "uv__free", "(", "handle", "->", "cf_cb", ")", ";", "handle", "->", "cf_cb", "=", "NULL", ";", "fail_cf_cb_malloc", ":", "uv__free", "(", "handle", "->", "realpath", ")", ";", "handle", "->", "realpath", "=", "NULL", ";", "handle", "->", "realpath_len", "=", "0", ";", "return", "err", ";", "}" ]
Runs in UV loop to initialize handle
[ "Runs", "in", "UV", "loop", "to", "initialize", "handle" ]
[ "/* Get absolute path to file */", "/* Initialize event queue */", "/*\n * Events will occur in other thread.\n * Initialize callback for getting them back into event loop's thread\n */", "/* Insert handle into the list */", "/* Reschedule FSEventStream */" ]
[ { "param": "handle", "type": "uv_fs_event_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "handle", "type": "uv_fs_event_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
40d6b0c19728aa85ff7aa47cd5996fcf9129576b
FuchsiaOS/Fuchsia-SDK
pkg/scenic_cpp/include/lib/ui/scenic/cpp/resources.h
[ "BSD-3-Clause" ]
C
SetViewProperties
void
void SetViewProperties(float min_x, float min_y, float min_z, float max_x, float max_y, float max_z, float in_min_x, float in_min_y, float in_min_z, float in_max_x, float in_max_y, float in_max_z) { SetViewProperties((float[3]){min_x, min_y, min_z}, (float[3]){max_x, max_y, max_z}, (float[3]){in_min_x, in_min_y, in_min_z}, (float[3]){in_max_x, in_max_y, in_max_z}); }
// Set properties of the attached view.
Set properties of the attached view.
[ "Set", "properties", "of", "the", "attached", "view", "." ]
void SetViewProperties(float min_x, float min_y, float min_z, float max_x, float max_y, float max_z, float in_min_x, float in_min_y, float in_min_z, float in_max_x, float in_max_y, float in_max_z) { SetViewProperties((float[3]){min_x, min_y, min_z}, (float[3]){max_x, max_y, max_z}, (float[3]){in_min_x, in_min_y, in_min_z}, (float[3]){in_max_x, in_max_y, in_max_z}); }
[ "void", "SetViewProperties", "(", "float", "min_x", ",", "float", "min_y", ",", "float", "min_z", ",", "float", "max_x", ",", "float", "max_y", ",", "float", "max_z", ",", "float", "in_min_x", ",", "float", "in_min_y", ",", "float", "in_min_z", ",", "float", "in_max_x", ",", "float", "in_max_y", ",", "float", "in_max_z", ")", "{", "SetViewProperties", "(", "(", "float", "[", "3", "]", ")", "{", "min_x", ",", "min_y", ",", "min_z", "}", ",", "(", "float", "[", "3", "]", ")", "{", "max_x", ",", "max_y", ",", "max_z", "}", ",", "(", "float", "[", "3", "]", ")", "{", "in_min_x", ",", "in_min_y", ",", "in_min_z", "}", ",", "(", "float", "[", "3", "]", ")", "{", "in_max_x", ",", "in_max_y", ",", "in_max_z", "}", ")", ";", "}" ]
Set properties of the attached view.
[ "Set", "properties", "of", "the", "attached", "view", "." ]
[]
[ { "param": "min_x", "type": "float" }, { "param": "min_y", "type": "float" }, { "param": "min_z", "type": "float" }, { "param": "max_x", "type": "float" }, { "param": "max_y", "type": "float" }, { "param": "max_z", "type": "float" }, { "param": "in_min_x", "type": "float" }, { "param": "in_min_y", "type": "float" }, { "param": "in_min_z", "type": "float" }, { "param": "in_max_x", "type": "float" }, { "param": "in_max_y", "type": "float" }, { "param": "in_max_z", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "min_x", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "min_y", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "min_z", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "max_x", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "max_y", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "max_z", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "in_min_x", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "in_min_y", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "in_min_z", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "in_max_x", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "in_max_y", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "in_max_z", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
364c5b69da79ed69c46572fbb91382a7c0289923
Custom-ROM/system-core
init/devices.c
[ "MIT" ]
C
find_pci_device_prefix
int
static int find_pci_device_prefix(const char *path, char *buf, ssize_t buf_sz) { const char *start, *end; if (strncmp(path, "/devices/pci", 12)) return -1; /* Beginning of the prefix is the initial "pci" after "/devices/" */ start = path + 9; /* End of the prefix is two path '/' later, capturing the domain/bus number * and the peripheral ID. Example: pci0000:00/0000:00:1f.2 */ end = strchr(start, '/'); if (!end) return -1; end = strchr(end + 1, '/'); if (!end) return -1; /* Make sure we have enough room for the string plus null terminator */ if (end - start + 1 > buf_sz) return -1; strncpy(buf, start, end - start); buf[end - start] = '\0'; return 0; }
/* Given a path that may start with a PCI device, populate the supplied buffer * with the PCI domain/bus number and the peripheral ID and return 0. * If it doesn't start with a PCI device, or there is some error, return -1 */
Given a path that may start with a PCI device, populate the supplied buffer with the PCI domain/bus number and the peripheral ID and return 0. If it doesn't start with a PCI device, or there is some error, return -1
[ "Given", "a", "path", "that", "may", "start", "with", "a", "PCI", "device", "populate", "the", "supplied", "buffer", "with", "the", "PCI", "domain", "/", "bus", "number", "and", "the", "peripheral", "ID", "and", "return", "0", ".", "If", "it", "doesn", "'", "t", "start", "with", "a", "PCI", "device", "or", "there", "is", "some", "error", "return", "-", "1" ]
static int find_pci_device_prefix(const char *path, char *buf, ssize_t buf_sz) { const char *start, *end; if (strncmp(path, "/devices/pci", 12)) return -1; start = path + 9; end = strchr(start, '/'); if (!end) return -1; end = strchr(end + 1, '/'); if (!end) return -1; if (end - start + 1 > buf_sz) return -1; strncpy(buf, start, end - start); buf[end - start] = '\0'; return 0; }
[ "static", "int", "find_pci_device_prefix", "(", "const", "char", "*", "path", ",", "char", "*", "buf", ",", "ssize_t", "buf_sz", ")", "{", "const", "char", "*", "start", ",", "*", "end", ";", "if", "(", "strncmp", "(", "path", ",", "\"", "\"", ",", "12", ")", ")", "return", "-1", ";", "start", "=", "path", "+", "9", ";", "end", "=", "strchr", "(", "start", ",", "'", "'", ")", ";", "if", "(", "!", "end", ")", "return", "-1", ";", "end", "=", "strchr", "(", "end", "+", "1", ",", "'", "'", ")", ";", "if", "(", "!", "end", ")", "return", "-1", ";", "if", "(", "end", "-", "start", "+", "1", ">", "buf_sz", ")", "return", "-1", ";", "strncpy", "(", "buf", ",", "start", ",", "end", "-", "start", ")", ";", "buf", "[", "end", "-", "start", "]", "=", "'", "\\0", "'", ";", "return", "0", ";", "}" ]
Given a path that may start with a PCI device, populate the supplied buffer with the PCI domain/bus number and the peripheral ID and return 0.
[ "Given", "a", "path", "that", "may", "start", "with", "a", "PCI", "device", "populate", "the", "supplied", "buffer", "with", "the", "PCI", "domain", "/", "bus", "number", "and", "the", "peripheral", "ID", "and", "return", "0", "." ]
[ "/* Beginning of the prefix is the initial \"pci\" after \"/devices/\" */", "/* End of the prefix is two path '/' later, capturing the domain/bus number\n * and the peripheral ID. Example: pci0000:00/0000:00:1f.2 */", "/* Make sure we have enough room for the string plus null terminator */" ]
[ { "param": "path", "type": "char" }, { "param": "buf", "type": "char" }, { "param": "buf_sz", "type": "ssize_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf_sz", "type": "ssize_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
169818dbdb93c8ba33e5524058343852976997ac
Custom-ROM/system-core
init/builtins.c
[ "MIT" ]
C
__chown_chmod_recur
int
static int __chown_chmod_recur(enum builtin_cmds action, const char *matching_path, unsigned int uid, unsigned int gid, mode_t mode, const char *cur_path, int depth) { DIR* dirp; struct dirent *de; char* child_path = NULL; int len; int ret = 0; if (!matching_path) { return -1; } if (!cur_path) { return -1; } if (depth > MAX_RECUR_DEPTH) { /* prevent this from doing infinitely recurison */ return 0; } dirp = opendir(cur_path); if (dirp) { while ((de = readdir(dirp))) { if ((de->d_type == DT_DIR) && (de->d_name[0] == '.') && ((de->d_name[1] == '\0') || ((de->d_name[1] == '.') && (de->d_name[2] == '\0')))) { /* ignore directories "." and ".." */ continue; } /* prepare path */ len = asprintf(&child_path, "%s/%s", cur_path, de->d_name); if (len != -1) { if (de->d_type == DT_DIR) { /* recurse into lowering level directory */ ret += __chown_chmod_recur(action, matching_path, uid, gid, mode, child_path, (depth + 1)); } else { if (fnmatch(matching_path, child_path, FNM_PATHNAME) == 0) { /* FNM_PATHNAME: need to have the same number of '/' */ ret += __chown_chmod_one(action, child_path, uid, gid, mode); } } free(child_path); child_path = NULL; } else { /* failed to allocate space for child_path, */ /* count as one failure. */ ret += -1; } } closedir(dirp); } return ret; }
/* do chown or chmod recursively with pattern matching */
do chown or chmod recursively with pattern matching
[ "do", "chown", "or", "chmod", "recursively", "with", "pattern", "matching" ]
static int __chown_chmod_recur(enum builtin_cmds action, const char *matching_path, unsigned int uid, unsigned int gid, mode_t mode, const char *cur_path, int depth) { DIR* dirp; struct dirent *de; char* child_path = NULL; int len; int ret = 0; if (!matching_path) { return -1; } if (!cur_path) { return -1; } if (depth > MAX_RECUR_DEPTH) { return 0; } dirp = opendir(cur_path); if (dirp) { while ((de = readdir(dirp))) { if ((de->d_type == DT_DIR) && (de->d_name[0] == '.') && ((de->d_name[1] == '\0') || ((de->d_name[1] == '.') && (de->d_name[2] == '\0')))) { continue; } len = asprintf(&child_path, "%s/%s", cur_path, de->d_name); if (len != -1) { if (de->d_type == DT_DIR) { ret += __chown_chmod_recur(action, matching_path, uid, gid, mode, child_path, (depth + 1)); } else { if (fnmatch(matching_path, child_path, FNM_PATHNAME) == 0) { ret += __chown_chmod_one(action, child_path, uid, gid, mode); } } free(child_path); child_path = NULL; } else { ret += -1; } } closedir(dirp); } return ret; }
[ "static", "int", "__chown_chmod_recur", "(", "enum", "builtin_cmds", "action", ",", "const", "char", "*", "matching_path", ",", "unsigned", "int", "uid", ",", "unsigned", "int", "gid", ",", "mode_t", "mode", ",", "const", "char", "*", "cur_path", ",", "int", "depth", ")", "{", "DIR", "*", "dirp", ";", "struct", "dirent", "*", "de", ";", "char", "*", "child_path", "=", "NULL", ";", "int", "len", ";", "int", "ret", "=", "0", ";", "if", "(", "!", "matching_path", ")", "{", "return", "-1", ";", "}", "if", "(", "!", "cur_path", ")", "{", "return", "-1", ";", "}", "if", "(", "depth", ">", "MAX_RECUR_DEPTH", ")", "{", "return", "0", ";", "}", "dirp", "=", "opendir", "(", "cur_path", ")", ";", "if", "(", "dirp", ")", "{", "while", "(", "(", "de", "=", "readdir", "(", "dirp", ")", ")", ")", "{", "if", "(", "(", "de", "->", "d_type", "==", "DT_DIR", ")", "&&", "(", "de", "->", "d_name", "[", "0", "]", "==", "'", "'", ")", "&&", "(", "(", "de", "->", "d_name", "[", "1", "]", "==", "'", "\\0", "'", ")", "||", "(", "(", "de", "->", "d_name", "[", "1", "]", "==", "'", "'", ")", "&&", "(", "de", "->", "d_name", "[", "2", "]", "==", "'", "\\0", "'", ")", ")", ")", ")", "{", "continue", ";", "}", "len", "=", "asprintf", "(", "&", "child_path", ",", "\"", "\"", ",", "cur_path", ",", "de", "->", "d_name", ")", ";", "if", "(", "len", "!=", "-1", ")", "{", "if", "(", "de", "->", "d_type", "==", "DT_DIR", ")", "{", "ret", "+=", "__chown_chmod_recur", "(", "action", ",", "matching_path", ",", "uid", ",", "gid", ",", "mode", ",", "child_path", ",", "(", "depth", "+", "1", ")", ")", ";", "}", "else", "{", "if", "(", "fnmatch", "(", "matching_path", ",", "child_path", ",", "FNM_PATHNAME", ")", "==", "0", ")", "{", "ret", "+=", "__chown_chmod_one", "(", "action", ",", "child_path", ",", "uid", ",", "gid", ",", "mode", ")", ";", "}", "}", "free", "(", "child_path", ")", ";", "child_path", "=", "NULL", ";", "}", "else", "{", "ret", "+=", "-1", ";", "}", "}", "closedir", "(", "dirp", ")", ";", "}", "return", "ret", ";", "}" ]
do chown or chmod recursively with pattern matching
[ "do", "chown", "or", "chmod", "recursively", "with", "pattern", "matching" ]
[ "/* prevent this from doing infinitely recurison */", "/* ignore directories \".\" and \"..\" */", "/* prepare path */", "/* recurse into lowering level directory */", "/* FNM_PATHNAME: need to have the same number of '/' */", "/* failed to allocate space for child_path, */", "/* count as one failure. */" ]
[ { "param": "action", "type": "enum builtin_cmds" }, { "param": "matching_path", "type": "char" }, { "param": "uid", "type": "unsigned int" }, { "param": "gid", "type": "unsigned int" }, { "param": "mode", "type": "mode_t" }, { "param": "cur_path", "type": "char" }, { "param": "depth", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "action", "type": "enum builtin_cmds", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "matching_path", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "uid", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gid", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mode", "type": "mode_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cur_path", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "depth", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
169818dbdb93c8ba33e5524058343852976997ac
Custom-ROM/system-core
init/builtins.c
[ "MIT" ]
C
do_mount_all
int
int do_mount_all(int nargs, char **args) { pid_t pid; int ret = -1; int child_ret = -1; int status; const char *prop; struct fstab *fstab; if (nargs != 2) { return -1; } /* * Call fs_mgr_mount_all() to mount all filesystems. We fork(2) and * do the call in the child to provide protection to the main init * process if anything goes wrong (crash or memory leak), and wait for * the child to finish in the parent. */ pid = fork(); if (pid > 0) { /* Parent. Wait for the child to return */ int wp_ret = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)); if (wp_ret < 0) { /* Unexpected error code. We will continue anyway. */ NOTICE("waitpid failed rc=%d, errno=%d\n", wp_ret, errno); } if (WIFEXITED(status)) { ret = WEXITSTATUS(status); } else { ret = -1; } } else if (pid == 0) { char *prop_val; /* child, call fs_mgr_mount_all() */ klog_set_level(6); /* So we can see what fs_mgr_mount_all() does */ prop_val = expand_references(args[1]); if (!prop_val) { ERROR("cannot expand '%s'\n", args[1]); return -1; } fstab = fs_mgr_read_fstab(prop_val); free(prop_val); child_ret = fs_mgr_mount_all(fstab); fs_mgr_free_fstab(fstab); if (child_ret == -1) { ERROR("fs_mgr_mount_all returned an error\n"); } _exit(child_ret); } else { /* fork failed, return an error */ return -1; } if (ret == FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION) { property_set("vold.decrypt", "trigger_encryption"); } else if (ret == FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED) { property_set("ro.crypto.state", "encrypted"); property_set("vold.decrypt", "trigger_default_encryption"); } else if (ret == FS_MGR_MNTALL_DEV_NOT_ENCRYPTED) { property_set("ro.crypto.state", "unencrypted"); /* If fs_mgr determined this is an unencrypted device, then trigger * that action. */ action_for_each_trigger("nonencrypted", action_add_queue_tail); } else if (ret == FS_MGR_MNTALL_DEV_NEEDS_RECOVERY) { /* Setup a wipe via recovery, and reboot into recovery */ ERROR("fs_mgr_mount_all suggested recovery, so wiping data via recovery.\n"); ret = wipe_data_via_recovery(); /* If reboot worked, there is no return. */ } else if (ret > 0) { ERROR("fs_mgr_mount_all returned unexpected error %d\n", ret); } /* else ... < 0: error */ return ret; }
/* * This function might request a reboot, in which case it will * not return. */
This function might request a reboot, in which case it will not return.
[ "This", "function", "might", "request", "a", "reboot", "in", "which", "case", "it", "will", "not", "return", "." ]
int do_mount_all(int nargs, char **args) { pid_t pid; int ret = -1; int child_ret = -1; int status; const char *prop; struct fstab *fstab; if (nargs != 2) { return -1; } pid = fork(); if (pid > 0) { int wp_ret = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)); if (wp_ret < 0) { NOTICE("waitpid failed rc=%d, errno=%d\n", wp_ret, errno); } if (WIFEXITED(status)) { ret = WEXITSTATUS(status); } else { ret = -1; } } else if (pid == 0) { char *prop_val; klog_set_level(6); prop_val = expand_references(args[1]); if (!prop_val) { ERROR("cannot expand '%s'\n", args[1]); return -1; } fstab = fs_mgr_read_fstab(prop_val); free(prop_val); child_ret = fs_mgr_mount_all(fstab); fs_mgr_free_fstab(fstab); if (child_ret == -1) { ERROR("fs_mgr_mount_all returned an error\n"); } _exit(child_ret); } else { return -1; } if (ret == FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION) { property_set("vold.decrypt", "trigger_encryption"); } else if (ret == FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED) { property_set("ro.crypto.state", "encrypted"); property_set("vold.decrypt", "trigger_default_encryption"); } else if (ret == FS_MGR_MNTALL_DEV_NOT_ENCRYPTED) { property_set("ro.crypto.state", "unencrypted"); action_for_each_trigger("nonencrypted", action_add_queue_tail); } else if (ret == FS_MGR_MNTALL_DEV_NEEDS_RECOVERY) { ERROR("fs_mgr_mount_all suggested recovery, so wiping data via recovery.\n"); ret = wipe_data_via_recovery(); } else if (ret > 0) { ERROR("fs_mgr_mount_all returned unexpected error %d\n", ret); } return ret; }
[ "int", "do_mount_all", "(", "int", "nargs", ",", "char", "*", "*", "args", ")", "{", "pid_t", "pid", ";", "int", "ret", "=", "-1", ";", "int", "child_ret", "=", "-1", ";", "int", "status", ";", "const", "char", "*", "prop", ";", "struct", "fstab", "*", "fstab", ";", "if", "(", "nargs", "!=", "2", ")", "{", "return", "-1", ";", "}", "pid", "=", "fork", "(", ")", ";", "if", "(", "pid", ">", "0", ")", "{", "int", "wp_ret", "=", "TEMP_FAILURE_RETRY", "(", "waitpid", "(", "pid", ",", "&", "status", ",", "0", ")", ")", ";", "if", "(", "wp_ret", "<", "0", ")", "{", "NOTICE", "(", "\"", "\\n", "\"", ",", "wp_ret", ",", "errno", ")", ";", "}", "if", "(", "WIFEXITED", "(", "status", ")", ")", "{", "ret", "=", "WEXITSTATUS", "(", "status", ")", ";", "}", "else", "{", "ret", "=", "-1", ";", "}", "}", "else", "if", "(", "pid", "==", "0", ")", "{", "char", "*", "prop_val", ";", "klog_set_level", "(", "6", ")", ";", "prop_val", "=", "expand_references", "(", "args", "[", "1", "]", ")", ";", "if", "(", "!", "prop_val", ")", "{", "ERROR", "(", "\"", "\\n", "\"", ",", "args", "[", "1", "]", ")", ";", "return", "-1", ";", "}", "fstab", "=", "fs_mgr_read_fstab", "(", "prop_val", ")", ";", "free", "(", "prop_val", ")", ";", "child_ret", "=", "fs_mgr_mount_all", "(", "fstab", ")", ";", "fs_mgr_free_fstab", "(", "fstab", ")", ";", "if", "(", "child_ret", "==", "-1", ")", "{", "ERROR", "(", "\"", "\\n", "\"", ")", ";", "}", "_exit", "(", "child_ret", ")", ";", "}", "else", "{", "return", "-1", ";", "}", "if", "(", "ret", "==", "FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION", ")", "{", "property_set", "(", "\"", "\"", ",", "\"", "\"", ")", ";", "}", "else", "if", "(", "ret", "==", "FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED", ")", "{", "property_set", "(", "\"", "\"", ",", "\"", "\"", ")", ";", "property_set", "(", "\"", "\"", ",", "\"", "\"", ")", ";", "}", "else", "if", "(", "ret", "==", "FS_MGR_MNTALL_DEV_NOT_ENCRYPTED", ")", "{", "property_set", "(", "\"", "\"", ",", "\"", "\"", ")", ";", "action_for_each_trigger", "(", "\"", "\"", ",", "action_add_queue_tail", ")", ";", "}", "else", "if", "(", "ret", "==", "FS_MGR_MNTALL_DEV_NEEDS_RECOVERY", ")", "{", "ERROR", "(", "\"", "\\n", "\"", ")", ";", "ret", "=", "wipe_data_via_recovery", "(", ")", ";", "}", "else", "if", "(", "ret", ">", "0", ")", "{", "ERROR", "(", "\"", "\\n", "\"", ",", "ret", ")", ";", "}", "return", "ret", ";", "}" ]
This function might request a reboot, in which case it will not return.
[ "This", "function", "might", "request", "a", "reboot", "in", "which", "case", "it", "will", "not", "return", "." ]
[ "/*\n * Call fs_mgr_mount_all() to mount all filesystems. We fork(2) and\n * do the call in the child to provide protection to the main init\n * process if anything goes wrong (crash or memory leak), and wait for\n * the child to finish in the parent.\n */", "/* Parent. Wait for the child to return */", "/* Unexpected error code. We will continue anyway. */", "/* child, call fs_mgr_mount_all() */", "/* So we can see what fs_mgr_mount_all() does */", "/* fork failed, return an error */", "/* If fs_mgr determined this is an unencrypted device, then trigger\n * that action.\n */", "/* Setup a wipe via recovery, and reboot into recovery */", "/* If reboot worked, there is no return. */", "/* else ... < 0: error */" ]
[ { "param": "nargs", "type": "int" }, { "param": "args", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "nargs", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "args", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e05f32b5030adbbd2e577c0dbaca6db83174d390
ashryaagr/JagScript
ReadGrammar.c
[ "MIT" ]
C
readGrammar
void
void readGrammar(char *fileName, Node *llist) { FILE *fp = fopen(fileName, "r"); // Exit if file could not be opened if (fp == NULL) { printf("Could not read %s\n", fileName); exit(0); } int line = 0; char eachLine[1000]; // Read the file line by line while (fscanf(fp, " %[^\n]", eachLine) != EOF) { char *delim = " "; char *token; // Extract the leftmost non-terminal of the rule token = strtok(eachLine, delim); llist[line].element = (char *)malloc(sizeof(char) * (strlen(token) + 1)); strcpy(llist[line].element, token); llist[line].nxt = NULL; Node *curr = &llist[line]; token = strtok(NULL, delim); int ruleSize = 0; while (token != NULL) { if (strcmp(ARROW, token) != 0) { Node *next = (Node *)malloc(sizeof(Node)); next->element = (char *)malloc(sizeof(char) * (strlen(token) + 1)); strcpy(next->element, token); next->ruleSize = 0; next->nxt = NULL; curr->nxt = next; curr = next; ruleSize++; } token = strtok(NULL, delim); } curr = &llist[line]; curr->ruleSize = ruleSize; line++; } fclose(fp); }
// This function populates the llist by reading the grammer text file
This function populates the llist by reading the grammer text file
[ "This", "function", "populates", "the", "llist", "by", "reading", "the", "grammer", "text", "file" ]
void readGrammar(char *fileName, Node *llist) { FILE *fp = fopen(fileName, "r"); if (fp == NULL) { printf("Could not read %s\n", fileName); exit(0); } int line = 0; char eachLine[1000]; while (fscanf(fp, " %[^\n]", eachLine) != EOF) { char *delim = " "; char *token; token = strtok(eachLine, delim); llist[line].element = (char *)malloc(sizeof(char) * (strlen(token) + 1)); strcpy(llist[line].element, token); llist[line].nxt = NULL; Node *curr = &llist[line]; token = strtok(NULL, delim); int ruleSize = 0; while (token != NULL) { if (strcmp(ARROW, token) != 0) { Node *next = (Node *)malloc(sizeof(Node)); next->element = (char *)malloc(sizeof(char) * (strlen(token) + 1)); strcpy(next->element, token); next->ruleSize = 0; next->nxt = NULL; curr->nxt = next; curr = next; ruleSize++; } token = strtok(NULL, delim); } curr = &llist[line]; curr->ruleSize = ruleSize; line++; } fclose(fp); }
[ "void", "readGrammar", "(", "char", "*", "fileName", ",", "Node", "*", "llist", ")", "{", "FILE", "*", "fp", "=", "fopen", "(", "fileName", ",", "\"", "\"", ")", ";", "if", "(", "fp", "==", "NULL", ")", "{", "printf", "(", "\"", "\\n", "\"", ",", "fileName", ")", ";", "exit", "(", "0", ")", ";", "}", "int", "line", "=", "0", ";", "char", "eachLine", "[", "1000", "]", ";", "while", "(", "fscanf", "(", "fp", ",", "\"", "\\n", "\"", ",", "eachLine", ")", "!=", "EOF", ")", "{", "char", "*", "delim", "=", "\"", "\"", ";", "char", "*", "token", ";", "token", "=", "strtok", "(", "eachLine", ",", "delim", ")", ";", "llist", "[", "line", "]", ".", "element", "=", "(", "char", "*", ")", "malloc", "(", "sizeof", "(", "char", ")", "*", "(", "strlen", "(", "token", ")", "+", "1", ")", ")", ";", "strcpy", "(", "llist", "[", "line", "]", ".", "element", ",", "token", ")", ";", "llist", "[", "line", "]", ".", "nxt", "=", "NULL", ";", "Node", "*", "curr", "=", "&", "llist", "[", "line", "]", ";", "token", "=", "strtok", "(", "NULL", ",", "delim", ")", ";", "int", "ruleSize", "=", "0", ";", "while", "(", "token", "!=", "NULL", ")", "{", "if", "(", "strcmp", "(", "ARROW", ",", "token", ")", "!=", "0", ")", "{", "Node", "*", "next", "=", "(", "Node", "*", ")", "malloc", "(", "sizeof", "(", "Node", ")", ")", ";", "next", "->", "element", "=", "(", "char", "*", ")", "malloc", "(", "sizeof", "(", "char", ")", "*", "(", "strlen", "(", "token", ")", "+", "1", ")", ")", ";", "strcpy", "(", "next", "->", "element", ",", "token", ")", ";", "next", "->", "ruleSize", "=", "0", ";", "next", "->", "nxt", "=", "NULL", ";", "curr", "->", "nxt", "=", "next", ";", "curr", "=", "next", ";", "ruleSize", "++", ";", "}", "token", "=", "strtok", "(", "NULL", ",", "delim", ")", ";", "}", "curr", "=", "&", "llist", "[", "line", "]", ";", "curr", "->", "ruleSize", "=", "ruleSize", ";", "line", "++", ";", "}", "fclose", "(", "fp", ")", ";", "}" ]
This function populates the llist by reading the grammer text file
[ "This", "function", "populates", "the", "llist", "by", "reading", "the", "grammer", "text", "file" ]
[ "// Exit if file could not be opened", "// Read the file line by line", "// Extract the leftmost non-terminal of the rule" ]
[ { "param": "fileName", "type": "char" }, { "param": "llist", "type": "Node" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fileName", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "llist", "type": "Node", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d1ec3521a3d97f468989314e2e5c8cf009b78e64
ashryaagr/JagScript
tokenizer.c
[ "MIT" ]
C
isNum
int
int isNum(char *token) { char *ptr = token; for (; *ptr != '\0'; ptr++) { char ch = *ptr; if (!(ch >= '0' && ch <= '9')) { return 0; } } return 1; }
//check if the token is an integer
check if the token is an integer
[ "check", "if", "the", "token", "is", "an", "integer" ]
int isNum(char *token) { char *ptr = token; for (; *ptr != '\0'; ptr++) { char ch = *ptr; if (!(ch >= '0' && ch <= '9')) { return 0; } } return 1; }
[ "int", "isNum", "(", "char", "*", "token", ")", "{", "char", "*", "ptr", "=", "token", ";", "for", "(", ";", "*", "ptr", "!=", "'", "\\0", "'", ";", "ptr", "++", ")", "{", "char", "ch", "=", "*", "ptr", ";", "if", "(", "!", "(", "ch", ">=", "'", "'", "&&", "ch", "<=", "'", "'", ")", ")", "{", "return", "0", ";", "}", "}", "return", "1", ";", "}" ]
check if the token is an integer
[ "check", "if", "the", "token", "is", "an", "integer" ]
[]
[ { "param": "token", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "token", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d1ec3521a3d97f468989314e2e5c8cf009b78e64
ashryaagr/JagScript
tokenizer.c
[ "MIT" ]
C
isID
int
int isID(char *token) { char *ptr = token; char ch = *ptr; if (!(ch == '_' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) { return 0; } ptr++; for (; *ptr != '\0'; ptr++) { ch = *ptr; if (!(ch == '_' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) { return 0; } } return 1; }
//check if the token id an ID
check if the token id an ID
[ "check", "if", "the", "token", "id", "an", "ID" ]
int isID(char *token) { char *ptr = token; char ch = *ptr; if (!(ch == '_' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) { return 0; } ptr++; for (; *ptr != '\0'; ptr++) { ch = *ptr; if (!(ch == '_' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) { return 0; } } return 1; }
[ "int", "isID", "(", "char", "*", "token", ")", "{", "char", "*", "ptr", "=", "token", ";", "char", "ch", "=", "*", "ptr", ";", "if", "(", "!", "(", "ch", "==", "'", "'", "||", "(", "ch", ">=", "'", "'", "&&", "ch", "<=", "'", "'", ")", "||", "(", "ch", ">=", "'", "'", "&&", "ch", "<=", "'", "'", ")", ")", ")", "{", "return", "0", ";", "}", "ptr", "++", ";", "for", "(", ";", "*", "ptr", "!=", "'", "\\0", "'", ";", "ptr", "++", ")", "{", "ch", "=", "*", "ptr", ";", "if", "(", "!", "(", "ch", "==", "'", "'", "||", "(", "ch", ">=", "'", "'", "&&", "ch", "<=", "'", "'", ")", "||", "(", "ch", ">=", "'", "'", "&&", "ch", "<=", "'", "'", ")", "||", "(", "ch", ">=", "'", "'", "&&", "ch", "<=", "'", "'", ")", ")", ")", "{", "return", "0", ";", "}", "}", "return", "1", ";", "}" ]
check if the token id an ID
[ "check", "if", "the", "token", "id", "an", "ID" ]
[]
[ { "param": "token", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "token", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d1ec3521a3d97f468989314e2e5c8cf009b78e64
ashryaagr/JagScript
tokenizer.c
[ "MIT" ]
C
findCorrectToken
TokenName
TokenName findCorrectToken(char *token) { if (strcmp(token, "program") == 0) { return PROGRAM; } else if (strcmp(token, "(") == 0) { return RBOP; } else if (strcmp(token, ")") == 0) { return RBCL; } else if (strcmp(token, "{") == 0) { return CBOP; } else if (strcmp(token, "}") == 0) { return CBCL; } else if (strcmp(token, "[") == 0) { return SBOP; } else if (strcmp(token, "]") == 0) { return SBCL; } else if (strcmp(token, "declare") == 0) { return DECLARE; } else if (strcmp(token, "list") == 0) { return LIST; } else if (strcmp(token, "of") == 0) { return OF; } else if (strcmp(token, "variables") == 0) { return VARIABLES; } else if (strcmp(token, "array") == 0) { return ARRAY; } else if (strcmp(token, "jagged") == 0) { return JAGGED; } else if (strcmp(token, "size") == 0) { return SIZE; } else if (strcmp(token, "values") == 0) { return VALUES; } else if (strcmp(token, "integer") == 0) { return INTEGER; } else if (strcmp(token, "real") == 0) { return REAL; } else if (strcmp(token, "boolean") == 0) { return BOOLEAN; } else if (strcmp(token, ":") == 0) { return COLON; } else if (strcmp(token, ";") == 0) { return SEMICOLON; } else if (strcmp(token, "+") == 0) { return PLUS; } else if (strcmp(token, "-") == 0) { return MINUS; } else if (strcmp(token, "*") == 0) { return MULT; } else if (strcmp(token, "/") == 0) { return DIV; } else if (strcmp(token, "&&&") == 0) { return AND; } else if (strcmp(token, "|||") == 0) { return OR; } else if (strcmp(token, "..") == 0) { return TWODOT; } else if (strcmp(token, "R1") == 0) { return R; } else if (strcmp(token, "=") == 0) { return EQUALS; } else if (isNum(token)) { return NUM; } else if (isID(token)) { return ID; } else { return ERR; } }
// Takes input as a token and returns the appropriate TokenName
Takes input as a token and returns the appropriate TokenName
[ "Takes", "input", "as", "a", "token", "and", "returns", "the", "appropriate", "TokenName" ]
TokenName findCorrectToken(char *token) { if (strcmp(token, "program") == 0) { return PROGRAM; } else if (strcmp(token, "(") == 0) { return RBOP; } else if (strcmp(token, ")") == 0) { return RBCL; } else if (strcmp(token, "{") == 0) { return CBOP; } else if (strcmp(token, "}") == 0) { return CBCL; } else if (strcmp(token, "[") == 0) { return SBOP; } else if (strcmp(token, "]") == 0) { return SBCL; } else if (strcmp(token, "declare") == 0) { return DECLARE; } else if (strcmp(token, "list") == 0) { return LIST; } else if (strcmp(token, "of") == 0) { return OF; } else if (strcmp(token, "variables") == 0) { return VARIABLES; } else if (strcmp(token, "array") == 0) { return ARRAY; } else if (strcmp(token, "jagged") == 0) { return JAGGED; } else if (strcmp(token, "size") == 0) { return SIZE; } else if (strcmp(token, "values") == 0) { return VALUES; } else if (strcmp(token, "integer") == 0) { return INTEGER; } else if (strcmp(token, "real") == 0) { return REAL; } else if (strcmp(token, "boolean") == 0) { return BOOLEAN; } else if (strcmp(token, ":") == 0) { return COLON; } else if (strcmp(token, ";") == 0) { return SEMICOLON; } else if (strcmp(token, "+") == 0) { return PLUS; } else if (strcmp(token, "-") == 0) { return MINUS; } else if (strcmp(token, "*") == 0) { return MULT; } else if (strcmp(token, "/") == 0) { return DIV; } else if (strcmp(token, "&&&") == 0) { return AND; } else if (strcmp(token, "|||") == 0) { return OR; } else if (strcmp(token, "..") == 0) { return TWODOT; } else if (strcmp(token, "R1") == 0) { return R; } else if (strcmp(token, "=") == 0) { return EQUALS; } else if (isNum(token)) { return NUM; } else if (isID(token)) { return ID; } else { return ERR; } }
[ "TokenName", "findCorrectToken", "(", "char", "*", "token", ")", "{", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "PROGRAM", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "RBOP", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "RBCL", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "CBOP", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "CBCL", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "SBOP", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "SBCL", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "DECLARE", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "LIST", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "OF", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "VARIABLES", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "ARRAY", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "JAGGED", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "SIZE", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "VALUES", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "INTEGER", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "REAL", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "BOOLEAN", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "COLON", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "SEMICOLON", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "PLUS", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "MINUS", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "MULT", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "DIV", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "AND", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "OR", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "TWODOT", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "R", ";", "}", "else", "if", "(", "strcmp", "(", "token", ",", "\"", "\"", ")", "==", "0", ")", "{", "return", "EQUALS", ";", "}", "else", "if", "(", "isNum", "(", "token", ")", ")", "{", "return", "NUM", ";", "}", "else", "if", "(", "isID", "(", "token", ")", ")", "{", "return", "ID", ";", "}", "else", "{", "return", "ERR", ";", "}", "}" ]
Takes input as a token and returns the appropriate TokenName
[ "Takes", "input", "as", "a", "token", "and", "returns", "the", "appropriate", "TokenName" ]
[]
[ { "param": "token", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "token", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8b4b64df0c61a362211eb99048393898d21c682f
mseng10/MultipleImageIterator
include/itkMultipleImageIterator.h
[ "Apache-2.0" ]
C
IsAtEnd
bool
bool IsAtEnd() { #ifdef NDEBUG return m_Iterators[0].IsAtEnd(); #else assert(m_Iterators.size()); bool retval = m_Iterators[0].IsAtEnd(); for (unsigned int i = 0; i < m_Iterators.size(); ++i) assert(m_Iterators[i].IsAtEnd() == retval); return retval; #endif }
/** Check if the first iterator is at end. In debug mode, additionally check * that at least one iterator is present and that all iterators' IsAtEnd() * methods return the same thing */
Check if the first iterator is at end. In debug mode, additionally check that at least one iterator is present and that all iterators' IsAtEnd() methods return the same thing
[ "Check", "if", "the", "first", "iterator", "is", "at", "end", ".", "In", "debug", "mode", "additionally", "check", "that", "at", "least", "one", "iterator", "is", "present", "and", "that", "all", "iterators", "'", "IsAtEnd", "()", "methods", "return", "the", "same", "thing" ]
bool IsAtEnd() { #ifdef NDEBUG return m_Iterators[0].IsAtEnd(); #else assert(m_Iterators.size()); bool retval = m_Iterators[0].IsAtEnd(); for (unsigned int i = 0; i < m_Iterators.size(); ++i) assert(m_Iterators[i].IsAtEnd() == retval); return retval; #endif }
[ "bool", "IsAtEnd", "(", ")", "{", "#ifdef", "NDEBUG", "return", "m_Iterators", "[", "0", "]", ".", "IsAtEnd", "(", ")", ";", "#else", "assert", "(", "m_Iterators", ".", "size", "(", ")", ")", ";", "bool", "retval", "=", "m_Iterators", "[", "0", "]", ".", "IsAtEnd", "(", ")", ";", "for", "(", "unsigned", "int", "i", "=", "0", ";", "i", "<", "m_Iterators", ".", "size", "(", ")", ";", "++", "i", ")", "assert", "(", "m_Iterators", "[", "i", "]", ".", "IsAtEnd", "(", ")", "==", "retval", ")", ";", "return", "retval", ";", "#endif", "}" ]
Check if the first iterator is at end.
[ "Check", "if", "the", "first", "iterator", "is", "at", "end", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
4233f12a03a7908c2be8da038808781e7dafbc34
novas0x2a/watchdog
src/watchdog_fsevents.c
[ "Apache-2.0" ]
C
watchdog_FSEventStreamCallback
void
static void watchdog_FSEventStreamCallback(ConstFSEventStreamRef stream_ref, StreamCallbackInfo *stream_callback_info_ref, size_t num_events, const char *event_paths[], const FSEventStreamEventFlags event_flags[], const FSEventStreamEventId event_ids[]) { size_t i = 0; PyObject *callback_result = NULL; PyObject *path = NULL; PyObject *flags = NULL; PyObject *py_event_flags = NULL; PyObject *py_event_paths = NULL; PyThreadState *saved_thread_state = NULL; /* Acquire interpreter lock and save original thread state. */ PyEval_AcquireLock(); saved_thread_state = PyThreadState_Swap(stream_callback_info_ref->thread_state); /* Convert event flags and paths to Python ints and strings. */ py_event_paths = PyList_New(num_events); py_event_flags = PyList_New(num_events); if (G_NOT(py_event_paths && py_event_flags)) { Py_DECREF(py_event_paths); Py_DECREF(py_event_flags); return /*NULL*/; } for (i = 0; i < num_events; ++i) { path = PyString_FromString(event_paths[i]); flags = PyInt_FromLong(event_flags[i]); if (G_NOT(path && flags)) { Py_DECREF(py_event_paths); Py_DECREF(py_event_flags); return /*NULL*/; } PyList_SET_ITEM(py_event_paths, i, path); PyList_SET_ITEM(py_event_flags, i, flags); } /* Call the Python callback function supplied by the stream information * struct. The Python callback function should accept two arguments, * both being Python lists: * * def python_callback(event_paths, event_flags): * pass */ callback_result = \ PyObject_CallFunction(stream_callback_info_ref->python_callback, "OO", py_event_paths, py_event_flags); if (G_IS_NULL(callback_result)) { if (G_NOT(PyErr_Occurred())) { PyErr_SetString(PyExc_ValueError, ERROR_CANNOT_CALL_CALLBACK); } CFRunLoopStop(stream_callback_info_ref->run_loop_ref); } /* Release the lock and restore thread state. */ PyThreadState_Swap(saved_thread_state); PyEval_ReleaseLock(); }
/** * This is the callback passed to the FSEvents API, which calls * the Python callback function, in turn, by passing in event data * as Python objects. * * :param stream_ref: * A pointer to an ``FSEventStream`` instance. * :param stream_callback_info_ref: * Callback context information passed by the FSEvents API. * This contains a reference to the Python callback that this * function calls in turn with information about the events. * :param num_events: * An unsigned integer representing the number of events * captured by the FSEvents API. * :param event_paths: * An array of NUL-terminated C strings representing event paths. * :param event_flags: * An array of ``FSEventStreamEventFlags`` unsigned integral * mask values. * :param event_ids: * An array of 64-bit unsigned integers representing event * identifiers. */
This is the callback passed to the FSEvents API, which calls the Python callback function, in turn, by passing in event data as Python objects. :param stream_ref: A pointer to an ``FSEventStream`` instance. :param stream_callback_info_ref: Callback context information passed by the FSEvents API. This contains a reference to the Python callback that this function calls in turn with information about the events. :param num_events: An unsigned integer representing the number of events captured by the FSEvents API. :param event_paths: An array of NUL-terminated C strings representing event paths. :param event_flags: An array of ``FSEventStreamEventFlags`` unsigned integral mask values. :param event_ids: An array of 64-bit unsigned integers representing event identifiers.
[ "This", "is", "the", "callback", "passed", "to", "the", "FSEvents", "API", "which", "calls", "the", "Python", "callback", "function", "in", "turn", "by", "passing", "in", "event", "data", "as", "Python", "objects", ".", ":", "param", "stream_ref", ":", "A", "pointer", "to", "an", "`", "`", "FSEventStream", "`", "`", "instance", ".", ":", "param", "stream_callback_info_ref", ":", "Callback", "context", "information", "passed", "by", "the", "FSEvents", "API", ".", "This", "contains", "a", "reference", "to", "the", "Python", "callback", "that", "this", "function", "calls", "in", "turn", "with", "information", "about", "the", "events", ".", ":", "param", "num_events", ":", "An", "unsigned", "integer", "representing", "the", "number", "of", "events", "captured", "by", "the", "FSEvents", "API", ".", ":", "param", "event_paths", ":", "An", "array", "of", "NUL", "-", "terminated", "C", "strings", "representing", "event", "paths", ".", ":", "param", "event_flags", ":", "An", "array", "of", "`", "`", "FSEventStreamEventFlags", "`", "`", "unsigned", "integral", "mask", "values", ".", ":", "param", "event_ids", ":", "An", "array", "of", "64", "-", "bit", "unsigned", "integers", "representing", "event", "identifiers", "." ]
static void watchdog_FSEventStreamCallback(ConstFSEventStreamRef stream_ref, StreamCallbackInfo *stream_callback_info_ref, size_t num_events, const char *event_paths[], const FSEventStreamEventFlags event_flags[], const FSEventStreamEventId event_ids[]) { size_t i = 0; PyObject *callback_result = NULL; PyObject *path = NULL; PyObject *flags = NULL; PyObject *py_event_flags = NULL; PyObject *py_event_paths = NULL; PyThreadState *saved_thread_state = NULL; PyEval_AcquireLock(); saved_thread_state = PyThreadState_Swap(stream_callback_info_ref->thread_state); py_event_paths = PyList_New(num_events); py_event_flags = PyList_New(num_events); if (G_NOT(py_event_paths && py_event_flags)) { Py_DECREF(py_event_paths); Py_DECREF(py_event_flags); return ; } for (i = 0; i < num_events; ++i) { path = PyString_FromString(event_paths[i]); flags = PyInt_FromLong(event_flags[i]); if (G_NOT(path && flags)) { Py_DECREF(py_event_paths); Py_DECREF(py_event_flags); return ; } PyList_SET_ITEM(py_event_paths, i, path); PyList_SET_ITEM(py_event_flags, i, flags); } callback_result = \ PyObject_CallFunction(stream_callback_info_ref->python_callback, "OO", py_event_paths, py_event_flags); if (G_IS_NULL(callback_result)) { if (G_NOT(PyErr_Occurred())) { PyErr_SetString(PyExc_ValueError, ERROR_CANNOT_CALL_CALLBACK); } CFRunLoopStop(stream_callback_info_ref->run_loop_ref); } PyThreadState_Swap(saved_thread_state); PyEval_ReleaseLock(); }
[ "static", "void", "watchdog_FSEventStreamCallback", "(", "ConstFSEventStreamRef", "stream_ref", ",", "StreamCallbackInfo", "*", "stream_callback_info_ref", ",", "size_t", "num_events", ",", "const", "char", "*", "event_paths", "[", "]", ",", "const", "FSEventStreamEventFlags", "event_flags", "[", "]", ",", "const", "FSEventStreamEventId", "event_ids", "[", "]", ")", "{", "size_t", "i", "=", "0", ";", "PyObject", "*", "callback_result", "=", "NULL", ";", "PyObject", "*", "path", "=", "NULL", ";", "PyObject", "*", "flags", "=", "NULL", ";", "PyObject", "*", "py_event_flags", "=", "NULL", ";", "PyObject", "*", "py_event_paths", "=", "NULL", ";", "PyThreadState", "*", "saved_thread_state", "=", "NULL", ";", "PyEval_AcquireLock", "(", ")", ";", "saved_thread_state", "=", "PyThreadState_Swap", "(", "stream_callback_info_ref", "->", "thread_state", ")", ";", "py_event_paths", "=", "PyList_New", "(", "num_events", ")", ";", "py_event_flags", "=", "PyList_New", "(", "num_events", ")", ";", "if", "(", "G_NOT", "(", "py_event_paths", "&&", "py_event_flags", ")", ")", "{", "Py_DECREF", "(", "py_event_paths", ")", ";", "Py_DECREF", "(", "py_event_flags", ")", ";", "return", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "num_events", ";", "++", "i", ")", "{", "path", "=", "PyString_FromString", "(", "event_paths", "[", "i", "]", ")", ";", "flags", "=", "PyInt_FromLong", "(", "event_flags", "[", "i", "]", ")", ";", "if", "(", "G_NOT", "(", "path", "&&", "flags", ")", ")", "{", "Py_DECREF", "(", "py_event_paths", ")", ";", "Py_DECREF", "(", "py_event_flags", ")", ";", "return", ";", "}", "PyList_SET_ITEM", "(", "py_event_paths", ",", "i", ",", "path", ")", ";", "PyList_SET_ITEM", "(", "py_event_flags", ",", "i", ",", "flags", ")", ";", "}", "callback_result", "=", "PyObject_CallFunction", "(", "stream_callback_info_ref", "->", "python_callback", ",", "\"", "\"", ",", "py_event_paths", ",", "py_event_flags", ")", ";", "if", "(", "G_IS_NULL", "(", "callback_result", ")", ")", "{", "if", "(", "G_NOT", "(", "PyErr_Occurred", "(", ")", ")", ")", "{", "PyErr_SetString", "(", "PyExc_ValueError", ",", "ERROR_CANNOT_CALL_CALLBACK", ")", ";", "}", "CFRunLoopStop", "(", "stream_callback_info_ref", "->", "run_loop_ref", ")", ";", "}", "PyThreadState_Swap", "(", "saved_thread_state", ")", ";", "PyEval_ReleaseLock", "(", ")", ";", "}" ]
This is the callback passed to the FSEvents API, which calls the Python callback function, in turn, by passing in event data as Python objects.
[ "This", "is", "the", "callback", "passed", "to", "the", "FSEvents", "API", "which", "calls", "the", "Python", "callback", "function", "in", "turn", "by", "passing", "in", "event", "data", "as", "Python", "objects", "." ]
[ "/* Acquire interpreter lock and save original thread state. */", "/* Convert event flags and paths to Python ints and strings. */", "/*NULL*/", "/*NULL*/", "/* Call the Python callback function supplied by the stream information\n * struct. The Python callback function should accept two arguments,\n * both being Python lists:\n *\n * def python_callback(event_paths, event_flags): \n * pass\n */", "/* Release the lock and restore thread state. */" ]
[ { "param": "stream_ref", "type": "ConstFSEventStreamRef" }, { "param": "stream_callback_info_ref", "type": "StreamCallbackInfo" }, { "param": "num_events", "type": "size_t" }, { "param": "event_paths", "type": "char" }, { "param": "event_flags", "type": "FSEventStreamEventFlags" }, { "param": "event_ids", "type": "FSEventStreamEventId" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "stream_ref", "type": "ConstFSEventStreamRef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "stream_callback_info_ref", "type": "StreamCallbackInfo", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num_events", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event_paths", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event_flags", "type": "FSEventStreamEventFlags", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event_ids", "type": "FSEventStreamEventId", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4233f12a03a7908c2be8da038808781e7dafbc34
novas0x2a/watchdog
src/watchdog_fsevents.c
[ "Apache-2.0" ]
C
watchdog_FSEventStreamCreate
FSEventStreamRef
static FSEventStreamRef watchdog_FSEventStreamCreate(StreamCallbackInfo *stream_callback_info_ref, PyObject *py_paths, FSEventStreamCallback callback) { CFAbsoluteTime stream_latency = 0.01; CFMutableArrayRef paths = NULL; FSEventStreamRef stream_ref = NULL; /* Check arguments. */ G_RETURN_NULL_IF_NULL(py_paths); G_RETURN_NULL_IF_NULL(callback); /* Convert the Python paths list to a CFMutableArray. */ paths = watchdog_CFMutableArrayRef_from_PyStringList(py_paths); G_RETURN_NULL_IF_NULL(paths); /* Create the event stream. */ FSEventStreamContext stream_context = { 0, stream_callback_info_ref, NULL, NULL, NULL }; stream_ref = FSEventStreamCreate(kCFAllocatorDefault, callback, &stream_context, paths, kFSEventStreamEventIdSinceNow, stream_latency, kFSEventStreamCreateFlagNoDefer); CFRelease(paths); return stream_ref; }
/** * Creates an instance of ``FSEventStream`` and returns a pointer * to the instance. * * :param stream_callback_info_ref: * Pointer to the callback context information that will be * passed by the FSEvents API to the callback handler specified * by the ``callback`` argument to this function. This * information contains a reference to the Python callback that * it must call in turn passing on the event information * as Python objects to the the Python callback. * :param py_paths: * A Python list of Python strings representing path names * to monitor. * :param callback: * A function pointer of type ``FSEventStreamCallback``. * :returns: * A pointer to an ``FSEventStream`` instance (that is, it returns * an ``FSEventStreamRef``). */
Creates an instance of ``FSEventStream`` and returns a pointer to the instance. :param stream_callback_info_ref: Pointer to the callback context information that will be passed by the FSEvents API to the callback handler specified by the ``callback`` argument to this function. This information contains a reference to the Python callback that it must call in turn passing on the event information as Python objects to the the Python callback. :param py_paths: A Python list of Python strings representing path names to monitor. :param callback: A function pointer of type ``FSEventStreamCallback``.
[ "Creates", "an", "instance", "of", "`", "`", "FSEventStream", "`", "`", "and", "returns", "a", "pointer", "to", "the", "instance", ".", ":", "param", "stream_callback_info_ref", ":", "Pointer", "to", "the", "callback", "context", "information", "that", "will", "be", "passed", "by", "the", "FSEvents", "API", "to", "the", "callback", "handler", "specified", "by", "the", "`", "`", "callback", "`", "`", "argument", "to", "this", "function", ".", "This", "information", "contains", "a", "reference", "to", "the", "Python", "callback", "that", "it", "must", "call", "in", "turn", "passing", "on", "the", "event", "information", "as", "Python", "objects", "to", "the", "the", "Python", "callback", ".", ":", "param", "py_paths", ":", "A", "Python", "list", "of", "Python", "strings", "representing", "path", "names", "to", "monitor", ".", ":", "param", "callback", ":", "A", "function", "pointer", "of", "type", "`", "`", "FSEventStreamCallback", "`", "`", "." ]
static FSEventStreamRef watchdog_FSEventStreamCreate(StreamCallbackInfo *stream_callback_info_ref, PyObject *py_paths, FSEventStreamCallback callback) { CFAbsoluteTime stream_latency = 0.01; CFMutableArrayRef paths = NULL; FSEventStreamRef stream_ref = NULL; G_RETURN_NULL_IF_NULL(py_paths); G_RETURN_NULL_IF_NULL(callback); paths = watchdog_CFMutableArrayRef_from_PyStringList(py_paths); G_RETURN_NULL_IF_NULL(paths); FSEventStreamContext stream_context = { 0, stream_callback_info_ref, NULL, NULL, NULL }; stream_ref = FSEventStreamCreate(kCFAllocatorDefault, callback, &stream_context, paths, kFSEventStreamEventIdSinceNow, stream_latency, kFSEventStreamCreateFlagNoDefer); CFRelease(paths); return stream_ref; }
[ "static", "FSEventStreamRef", "watchdog_FSEventStreamCreate", "(", "StreamCallbackInfo", "*", "stream_callback_info_ref", ",", "PyObject", "*", "py_paths", ",", "FSEventStreamCallback", "callback", ")", "{", "CFAbsoluteTime", "stream_latency", "=", "0.01", ";", "CFMutableArrayRef", "paths", "=", "NULL", ";", "FSEventStreamRef", "stream_ref", "=", "NULL", ";", "G_RETURN_NULL_IF_NULL", "(", "py_paths", ")", ";", "G_RETURN_NULL_IF_NULL", "(", "callback", ")", ";", "paths", "=", "watchdog_CFMutableArrayRef_from_PyStringList", "(", "py_paths", ")", ";", "G_RETURN_NULL_IF_NULL", "(", "paths", ")", ";", "FSEventStreamContext", "stream_context", "=", "{", "0", ",", "stream_callback_info_ref", ",", "NULL", ",", "NULL", ",", "NULL", "}", ";", "stream_ref", "=", "FSEventStreamCreate", "(", "kCFAllocatorDefault", ",", "callback", ",", "&", "stream_context", ",", "paths", ",", "kFSEventStreamEventIdSinceNow", ",", "stream_latency", ",", "kFSEventStreamCreateFlagNoDefer", ")", ";", "CFRelease", "(", "paths", ")", ";", "return", "stream_ref", ";", "}" ]
Creates an instance of ``FSEventStream`` and returns a pointer to the instance.
[ "Creates", "an", "instance", "of", "`", "`", "FSEventStream", "`", "`", "and", "returns", "a", "pointer", "to", "the", "instance", "." ]
[ "/* Check arguments. */", "/* Convert the Python paths list to a CFMutableArray. */", "/* Create the event stream. */" ]
[ { "param": "stream_callback_info_ref", "type": "StreamCallbackInfo" }, { "param": "py_paths", "type": "PyObject" }, { "param": "callback", "type": "FSEventStreamCallback" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "stream_callback_info_ref", "type": "StreamCallbackInfo", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "py_paths", "type": "PyObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback", "type": "FSEventStreamCallback", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4233f12a03a7908c2be8da038808781e7dafbc34
novas0x2a/watchdog
src/watchdog_fsevents.c
[ "Apache-2.0" ]
C
watchdog_module_add_attributes
void
static void watchdog_module_add_attributes(PyObject *module) { PyObject *version_tuple = Py_BuildValue("(iii)", WATCHDOG_VERSION_MAJOR, WATCHDOG_VERSION_MINOR, WATCHDOG_VERSION_BUILD); PyModule_AddIntConstant(module, "POLLIN", kCFFileDescriptorReadCallBack); PyModule_AddIntConstant(module, "POLLOUT", kCFFileDescriptorWriteCallBack); /* Adds version information. */ PyModule_AddObject(module, "__version__", version_tuple); PyModule_AddObject(module, "version_string", Py_BuildValue("s", WATCHDOG_VERSION_STRING)); }
/** * Adds various attributes to the Python module. * * :param module: * A pointer to the Python module object to inject * the attributes into. */
Adds various attributes to the Python module. :param module: A pointer to the Python module object to inject the attributes into.
[ "Adds", "various", "attributes", "to", "the", "Python", "module", ".", ":", "param", "module", ":", "A", "pointer", "to", "the", "Python", "module", "object", "to", "inject", "the", "attributes", "into", "." ]
static void watchdog_module_add_attributes(PyObject *module) { PyObject *version_tuple = Py_BuildValue("(iii)", WATCHDOG_VERSION_MAJOR, WATCHDOG_VERSION_MINOR, WATCHDOG_VERSION_BUILD); PyModule_AddIntConstant(module, "POLLIN", kCFFileDescriptorReadCallBack); PyModule_AddIntConstant(module, "POLLOUT", kCFFileDescriptorWriteCallBack); PyModule_AddObject(module, "__version__", version_tuple); PyModule_AddObject(module, "version_string", Py_BuildValue("s", WATCHDOG_VERSION_STRING)); }
[ "static", "void", "watchdog_module_add_attributes", "(", "PyObject", "*", "module", ")", "{", "PyObject", "*", "version_tuple", "=", "Py_BuildValue", "(", "\"", "\"", ",", "WATCHDOG_VERSION_MAJOR", ",", "WATCHDOG_VERSION_MINOR", ",", "WATCHDOG_VERSION_BUILD", ")", ";", "PyModule_AddIntConstant", "(", "module", ",", "\"", "\"", ",", "kCFFileDescriptorReadCallBack", ")", ";", "PyModule_AddIntConstant", "(", "module", ",", "\"", "\"", ",", "kCFFileDescriptorWriteCallBack", ")", ";", "PyModule_AddObject", "(", "module", ",", "\"", "\"", ",", "version_tuple", ")", ";", "PyModule_AddObject", "(", "module", ",", "\"", "\"", ",", "Py_BuildValue", "(", "\"", "\"", ",", "WATCHDOG_VERSION_STRING", ")", ")", ";", "}" ]
Adds various attributes to the Python module.
[ "Adds", "various", "attributes", "to", "the", "Python", "module", "." ]
[ "/* Adds version information. */" ]
[ { "param": "module", "type": "PyObject" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "module", "type": "PyObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4233f12a03a7908c2be8da038808781e7dafbc34
novas0x2a/watchdog
src/watchdog_fsevents.c
[ "Apache-2.0" ]
C
init_watchdog_fsevents
void
void init_watchdog_fsevents(void) { PyObject *module = Py_InitModule3(MODULE_NAME, watchdog_fsevents_methods, watchdog_fsevents_module__doc__); watchdog_module_add_attributes(module); watchdog_module_init(); }
/** * Initialize the Python 2.x module. */
Initialize the Python 2.x module.
[ "Initialize", "the", "Python", "2", ".", "x", "module", "." ]
void init_watchdog_fsevents(void) { PyObject *module = Py_InitModule3(MODULE_NAME, watchdog_fsevents_methods, watchdog_fsevents_module__doc__); watchdog_module_add_attributes(module); watchdog_module_init(); }
[ "void", "init_watchdog_fsevents", "(", "void", ")", "{", "PyObject", "*", "module", "=", "Py_InitModule3", "(", "MODULE_NAME", ",", "watchdog_fsevents_methods", ",", "watchdog_fsevents_module__doc__", ")", ";", "watchdog_module_add_attributes", "(", "module", ")", ";", "watchdog_module_init", "(", ")", ";", "}" ]
Initialize the Python 2.x module.
[ "Initialize", "the", "Python", "2", ".", "x", "module", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
4233f12a03a7908c2be8da038808781e7dafbc34
novas0x2a/watchdog
src/watchdog_fsevents.c
[ "Apache-2.0" ]
C
PyInit__watchdog_fsevents
PyMODINIT_FUNC
PyMODINIT_FUNC PyInit__watchdog_fsevents(void){ PyObject *module = PyModule_Create(&watchdog_fsevents_module); watchdog_module_add_attributes(module); watchdog_module_init(); return module; }
/** * Initialize the Python 3.x module. */
Initialize the Python 3.x module.
[ "Initialize", "the", "Python", "3", ".", "x", "module", "." ]
PyMODINIT_FUNC PyInit__watchdog_fsevents(void){ PyObject *module = PyModule_Create(&watchdog_fsevents_module); watchdog_module_add_attributes(module); watchdog_module_init(); return module; }
[ "PyMODINIT_FUNC", "PyInit__watchdog_fsevents", "(", "void", ")", "{", "PyObject", "*", "module", "=", "PyModule_Create", "(", "&", "watchdog_fsevents_module", ")", ";", "watchdog_module_add_attributes", "(", "module", ")", ";", "watchdog_module_init", "(", ")", ";", "return", "module", ";", "}" ]
Initialize the Python 3.x module.
[ "Initialize", "the", "Python", "3", ".", "x", "module", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
7e5feed8605bf29f7c9ddfac0040beeb757cc24a
izzimat/pigweed
pw_protobuf/public/pw_protobuf/decoder.h
[ "Apache-2.0" ]
C
ReadFloat
Status
Status ReadFloat(uint32_t field_number, float* out) { static_assert(sizeof(float) == sizeof(uint32_t), "Float and uint32_t must be the same size for protobufs"); return ReadFixed(field_number, out); }
// Reads a proto float value from the current cursor.
Reads a proto float value from the current cursor.
[ "Reads", "a", "proto", "float", "value", "from", "the", "current", "cursor", "." ]
Status ReadFloat(uint32_t field_number, float* out) { static_assert(sizeof(float) == sizeof(uint32_t), "Float and uint32_t must be the same size for protobufs"); return ReadFixed(field_number, out); }
[ "Status", "ReadFloat", "(", "uint32_t", "field_number", ",", "float", "*", "out", ")", "{", "static_assert", "(", "sizeof", "(", "float", ")", "==", "sizeof", "(", "uint32_t", ")", ",", "\"", "\"", ")", ";", "return", "ReadFixed", "(", "field_number", ",", "out", ")", ";", "}" ]
Reads a proto float value from the current cursor.
[ "Reads", "a", "proto", "float", "value", "from", "the", "current", "cursor", "." ]
[]
[ { "param": "field_number", "type": "uint32_t" }, { "param": "out", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "field_number", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "out", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7e5feed8605bf29f7c9ddfac0040beeb757cc24a
izzimat/pigweed
pw_protobuf/public/pw_protobuf/decoder.h
[ "Apache-2.0" ]
C
ReadDouble
Status
Status ReadDouble(uint32_t field_number, double* out) { static_assert(sizeof(double) == sizeof(uint64_t), "Double and uint64_t must be the same size for protobufs"); return ReadFixed(field_number, out); }
// Reads a proto double value from the current cursor.
Reads a proto double value from the current cursor.
[ "Reads", "a", "proto", "double", "value", "from", "the", "current", "cursor", "." ]
Status ReadDouble(uint32_t field_number, double* out) { static_assert(sizeof(double) == sizeof(uint64_t), "Double and uint64_t must be the same size for protobufs"); return ReadFixed(field_number, out); }
[ "Status", "ReadDouble", "(", "uint32_t", "field_number", ",", "double", "*", "out", ")", "{", "static_assert", "(", "sizeof", "(", "double", ")", "==", "sizeof", "(", "uint64_t", ")", ",", "\"", "\"", ")", ";", "return", "ReadFixed", "(", "field_number", ",", "out", ")", ";", "}" ]
Reads a proto double value from the current cursor.
[ "Reads", "a", "proto", "double", "value", "from", "the", "current", "cursor", "." ]
[]
[ { "param": "field_number", "type": "uint32_t" }, { "param": "out", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "field_number", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "out", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b6cf2ec07390114df7b3fa7e8055ae0a63e7ae68
emotionbug/wine
dlls/ntdll/locale.c
[ "MIT" ]
C
canonical_order_string
void
static void canonical_order_string( const struct norm_table *info, WCHAR *str, unsigned int len ) { unsigned int ch, i, r, next = 0; for (i = 0; i < len; i += r) { if (!(r = get_utf16( str + i, len - i, &ch ))) return; if (i && is_starter( info, ch )) { if (i > next + 1) /* at least two successive non-starters */ canonical_order_substring( info, str + next, i - next ); next = i + r; } } if (i > next + 1) canonical_order_substring( info, str + next, i - next ); }
/**************************************************************************** * canonical_order_string * * Reorder the string into canonical order - D108/D109. * * Starters (chars with combining class == 0) don't move, so look for continuous * substrings of non-starters and only reorder those. */
canonical_order_string Reorder the string into canonical order - D108/D109. Starters (chars with combining class == 0) don't move, so look for continuous substrings of non-starters and only reorder those.
[ "canonical_order_string", "Reorder", "the", "string", "into", "canonical", "order", "-", "D108", "/", "D109", ".", "Starters", "(", "chars", "with", "combining", "class", "==", "0", ")", "don", "'", "t", "move", "so", "look", "for", "continuous", "substrings", "of", "non", "-", "starters", "and", "only", "reorder", "those", "." ]
static void canonical_order_string( const struct norm_table *info, WCHAR *str, unsigned int len ) { unsigned int ch, i, r, next = 0; for (i = 0; i < len; i += r) { if (!(r = get_utf16( str + i, len - i, &ch ))) return; if (i && is_starter( info, ch )) { if (i > next + 1) canonical_order_substring( info, str + next, i - next ); next = i + r; } } if (i > next + 1) canonical_order_substring( info, str + next, i - next ); }
[ "static", "void", "canonical_order_string", "(", "const", "struct", "norm_table", "*", "info", ",", "WCHAR", "*", "str", ",", "unsigned", "int", "len", ")", "{", "unsigned", "int", "ch", ",", "i", ",", "r", ",", "next", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "len", ";", "i", "+=", "r", ")", "{", "if", "(", "!", "(", "r", "=", "get_utf16", "(", "str", "+", "i", ",", "len", "-", "i", ",", "&", "ch", ")", ")", ")", "return", ";", "if", "(", "i", "&&", "is_starter", "(", "info", ",", "ch", ")", ")", "{", "if", "(", "i", ">", "next", "+", "1", ")", "canonical_order_substring", "(", "info", ",", "str", "+", "next", ",", "i", "-", "next", ")", ";", "next", "=", "i", "+", "r", ";", "}", "}", "if", "(", "i", ">", "next", "+", "1", ")", "canonical_order_substring", "(", "info", ",", "str", "+", "next", ",", "i", "-", "next", ")", ";", "}" ]
canonical_order_string Reorder the string into canonical order - D108/D109.
[ "canonical_order_string", "Reorder", "the", "string", "into", "canonical", "order", "-", "D108", "/", "D109", "." ]
[ "/* at least two successive non-starters */" ]
[ { "param": "info", "type": "struct norm_table" }, { "param": "str", "type": "WCHAR" }, { "param": "len", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "info", "type": "struct norm_table", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str", "type": "WCHAR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b6cf2ec07390114df7b3fa7e8055ae0a63e7ae68
emotionbug/wine
dlls/ntdll/locale.c
[ "MIT" ]
C
decode_utf8_char
null
static unsigned int decode_utf8_char( unsigned char ch, const char **str, const char *strend ) { /* number of following bytes in sequence based on first byte value (for bytes above 0x7f) */ static const char utf8_length[128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80-0x8f */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90-0x9f */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xa0-0xaf */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xb0-0xbf */ 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xc0-0xcf */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xd0-0xdf */ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, /* 0xe0-0xef */ 3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0 /* 0xf0-0xff */ }; /* first byte mask depending on UTF-8 sequence length */ static const unsigned char utf8_mask[4] = { 0x7f, 0x1f, 0x0f, 0x07 }; unsigned int len = utf8_length[ch - 0x80]; unsigned int res = ch & utf8_mask[len]; const char *end = *str + len; if (end > strend) { *str = end; return ~0; } switch (len) { case 3: if ((ch = end[-3] ^ 0x80) >= 0x40) break; res = (res << 6) | ch; (*str)++; if (res < 0x10) break; case 2: if ((ch = end[-2] ^ 0x80) >= 0x40) break; res = (res << 6) | ch; if (res >= 0x110000 >> 6) break; (*str)++; if (res < 0x20) break; if (res >= 0xd800 >> 6 && res <= 0xdfff >> 6) break; case 1: if ((ch = end[-1] ^ 0x80) >= 0x40) break; res = (res << 6) | ch; (*str)++; if (res < 0x80) break; return res; } return ~0; }
/* helper for the various utf8 mbstowcs functions */
helper for the various utf8 mbstowcs functions
[ "helper", "for", "the", "various", "utf8", "mbstowcs", "functions" ]
static unsigned int decode_utf8_char( unsigned char ch, const char **str, const char *strend ) { static const char utf8_length[128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0 }; static const unsigned char utf8_mask[4] = { 0x7f, 0x1f, 0x0f, 0x07 }; unsigned int len = utf8_length[ch - 0x80]; unsigned int res = ch & utf8_mask[len]; const char *end = *str + len; if (end > strend) { *str = end; return ~0; } switch (len) { case 3: if ((ch = end[-3] ^ 0x80) >= 0x40) break; res = (res << 6) | ch; (*str)++; if (res < 0x10) break; case 2: if ((ch = end[-2] ^ 0x80) >= 0x40) break; res = (res << 6) | ch; if (res >= 0x110000 >> 6) break; (*str)++; if (res < 0x20) break; if (res >= 0xd800 >> 6 && res <= 0xdfff >> 6) break; case 1: if ((ch = end[-1] ^ 0x80) >= 0x40) break; res = (res << 6) | ch; (*str)++; if (res < 0x80) break; return res; } return ~0; }
[ "static", "unsigned", "int", "decode_utf8_char", "(", "unsigned", "char", "ch", ",", "const", "char", "*", "*", "str", ",", "const", "char", "*", "strend", ")", "{", "static", "const", "char", "utf8_length", "[", "128", "]", "=", "{", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "2", ",", "3", ",", "3", ",", "3", ",", "3", ",", "3", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", "}", ";", "static", "const", "unsigned", "char", "utf8_mask", "[", "4", "]", "=", "{", "0x7f", ",", "0x1f", ",", "0x0f", ",", "0x07", "}", ";", "unsigned", "int", "len", "=", "utf8_length", "[", "ch", "-", "0x80", "]", ";", "unsigned", "int", "res", "=", "ch", "&", "utf8_mask", "[", "len", "]", ";", "const", "char", "*", "end", "=", "*", "str", "+", "len", ";", "if", "(", "end", ">", "strend", ")", "{", "*", "str", "=", "end", ";", "return", "~", "0", ";", "}", "switch", "(", "len", ")", "{", "case", "3", ":", "if", "(", "(", "ch", "=", "end", "[", "-3", "]", "^", "0x80", ")", ">=", "0x40", ")", "break", ";", "res", "=", "(", "res", "<<", "6", ")", "|", "ch", ";", "(", "*", "str", ")", "++", ";", "if", "(", "res", "<", "0x10", ")", "break", ";", "case", "2", ":", "if", "(", "(", "ch", "=", "end", "[", "-2", "]", "^", "0x80", ")", ">=", "0x40", ")", "break", ";", "res", "=", "(", "res", "<<", "6", ")", "|", "ch", ";", "if", "(", "res", ">=", "0x110000", ">>", "6", ")", "break", ";", "(", "*", "str", ")", "++", ";", "if", "(", "res", "<", "0x20", ")", "break", ";", "if", "(", "res", ">=", "0xd800", ">>", "6", "&&", "res", "<=", "0xdfff", ">>", "6", ")", "break", ";", "case", "1", ":", "if", "(", "(", "ch", "=", "end", "[", "-1", "]", "^", "0x80", ")", ">=", "0x40", ")", "break", ";", "res", "=", "(", "res", "<<", "6", ")", "|", "ch", ";", "(", "*", "str", ")", "++", ";", "if", "(", "res", "<", "0x80", ")", "break", ";", "return", "res", ";", "}", "return", "~", "0", ";", "}" ]
helper for the various utf8 mbstowcs functions
[ "helper", "for", "the", "various", "utf8", "mbstowcs", "functions" ]
[ "/* number of following bytes in sequence based on first byte value (for bytes above 0x7f) */", "/* 0x80-0x8f */", "/* 0x90-0x9f */", "/* 0xa0-0xaf */", "/* 0xb0-0xbf */", "/* 0xc0-0xcf */", "/* 0xd0-0xdf */", "/* 0xe0-0xef */", "/* 0xf0-0xff */", "/* first byte mask depending on UTF-8 sequence length */" ]
[ { "param": "ch", "type": "unsigned char" }, { "param": "str", "type": "char" }, { "param": "strend", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ch", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "strend", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4778f749dfd41ab8e5650b979b3450b1269910f8
Max-Mobility/PushTracker
src/src/ble.c
[ "MIT" ]
C
gatt_attribute_value_callback
void
void gatt_attribute_value_callback(uint8 connection, uint16 handle,enum attributes_attribute_change_reason cb_type,uint16 offset,const uint8*data,uint8 len) { //save connection handle, is always 0 if only slave curr_connection=connection; // Check if OTA control point attribute is written by the remote device and execute the command // Command 0 : Erase flash block 0 (0x0-0x1FFFF) // Command 1 : Erase flash block 1 (0x10000-0x3FFFF) // Command 2 : Reset DFU data pointer // Command 3 : Boot to DFU mode // In case of errors application error code 0x80 is returned to the remote device // In case the flash comms fails error code 0x90 is returned to the remote device if (handle == ota_control ) { //attribute is user attribute, reason is always write_request_user if (len >1 || offset >0 ) // Not a valid command -> report application error code : 0x80 gatt_user_write_rsp(connection, 0x80); else { command=data[0]; if(command > 4) { // Unknown command -> report application error code : 0x80 gatt_user_write_rsp(curr_connection, 0x80); } else { if(command == 3) { // Command 3 received -> Boot to DFU mode hw_reset(1); } else { ps_data_temp[0]=0x01; ps_save(ps_cleaning,ps_data_temp,1); dfu_pointer = FIRST_USER_PAGE_ADDRESS; /* Other commands are not used, but still accepted in order to be compatible with the external flash OTA implementation */ gatt_user_write_rsp(curr_connection, 0x00); } } } } // Check if OTA data attribute is written which carries the firmware update if( (handle == BG_ATT_ota_data )&&((dfu_pointer+len) <=(FIRST_USER_PAGE_ADDRESS+(uint32)128*(uint32)1024) )) { flash_write((dfu_pointer >> 2), data, len); dfu_pointer += (len); } }
// for OTA update by ble dongle
for OTA update by ble dongle
[ "for", "OTA", "update", "by", "ble", "dongle" ]
void gatt_attribute_value_callback(uint8 connection, uint16 handle,enum attributes_attribute_change_reason cb_type,uint16 offset,const uint8*data,uint8 len) { curr_connection=connection; if (handle == ota_control ) { if (len >1 || offset >0 ) gatt_user_write_rsp(connection, 0x80); else { command=data[0]; if(command > 4) { gatt_user_write_rsp(curr_connection, 0x80); } else { if(command == 3) { hw_reset(1); } else { ps_data_temp[0]=0x01; ps_save(ps_cleaning,ps_data_temp,1); dfu_pointer = FIRST_USER_PAGE_ADDRESS; gatt_user_write_rsp(curr_connection, 0x00); } } } } if( (handle == BG_ATT_ota_data )&&((dfu_pointer+len) <=(FIRST_USER_PAGE_ADDRESS+(uint32)128*(uint32)1024) )) { flash_write((dfu_pointer >> 2), data, len); dfu_pointer += (len); } }
[ "void", "gatt_attribute_value_callback", "(", "uint8", "connection", ",", "uint16", "handle", ",", "enum", "attributes_attribute_change_reason", "cb_type", ",", "uint16", "offset", ",", "const", "uint8", "*", "data", ",", "uint8", "len", ")", "{", "curr_connection", "=", "connection", ";", "if", "(", "handle", "==", "ota_control", ")", "{", "if", "(", "len", ">", "1", "||", "offset", ">", "0", ")", "gatt_user_write_rsp", "(", "connection", ",", "0x80", ")", ";", "else", "{", "command", "=", "data", "[", "0", "]", ";", "if", "(", "command", ">", "4", ")", "{", "gatt_user_write_rsp", "(", "curr_connection", ",", "0x80", ")", ";", "}", "else", "{", "if", "(", "command", "==", "3", ")", "{", "hw_reset", "(", "1", ")", ";", "}", "else", "{", "ps_data_temp", "[", "0", "]", "=", "0x01", ";", "ps_save", "(", "ps_cleaning", ",", "ps_data_temp", ",", "1", ")", ";", "dfu_pointer", "=", "FIRST_USER_PAGE_ADDRESS", ";", "gatt_user_write_rsp", "(", "curr_connection", ",", "0x00", ")", ";", "}", "}", "}", "}", "if", "(", "(", "handle", "==", "BG_ATT_ota_data", ")", "&&", "(", "(", "dfu_pointer", "+", "len", ")", "<=", "(", "FIRST_USER_PAGE_ADDRESS", "+", "(", "uint32", ")", "128", "*", "(", "uint32", ")", "1024", ")", ")", ")", "{", "flash_write", "(", "(", "dfu_pointer", ">>", "2", ")", ",", "data", ",", "len", ")", ";", "dfu_pointer", "+=", "(", "len", ")", ";", "}", "}" ]
for OTA update by ble dongle
[ "for", "OTA", "update", "by", "ble", "dongle" ]
[ "//save connection handle, is always 0 if only slave\r", "// Check if OTA control point attribute is written by the remote device and execute the command\r", "// Command 0 : Erase flash block 0 (0x0-0x1FFFF)\r", "// Command 1 : Erase flash block 1 (0x10000-0x3FFFF)\r", "// Command 2 : Reset DFU data pointer\r", "// Command 3 : Boot to DFU mode\r", "// In case of errors application error code 0x80 is returned to the remote device\r", "// In case the flash comms fails error code 0x90 is returned to the remote device\r", "//attribute is user attribute, reason is always write_request_user\r", "// Not a valid command -> report application error code : 0x80\r", "// Unknown command -> report application error code : 0x80\r", "// Command 3 received -> Boot to DFU mode\r", "/* Other commands are not used, but still accepted in order\r\n to be compatible with the external flash OTA\r\n implementation */", "// Check if OTA data attribute is written which carries the firmware update\r" ]
[ { "param": "connection", "type": "uint8" }, { "param": "handle", "type": "uint16" }, { "param": "cb_type", "type": "enum attributes_attribute_change_reason" }, { "param": "offset", "type": "uint16" }, { "param": "data", "type": "uint8" }, { "param": "len", "type": "uint8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "connection", "type": "uint8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "handle", "type": "uint16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cb_type", "type": "enum attributes_attribute_change_reason", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "uint16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "uint8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "uint8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4778f749dfd41ab8e5650b979b3450b1269910f8
Max-Mobility/PushTracker
src/src/ble.c
[ "MIT" ]
C
connection_disconnect_callback
void
void connection_disconnect_callback(uint8 conn, uint8 reason) { disconnect_count=0; connection_count = 0; ble_state_changed_flag =1; if(conn== connection_handle_app) { connected &=~connection_app; AppConnectionStatus=AppRadioOff; connection_lost_app=1; connection_handle_app =255; if((reason ==0)||(reason==0x13)||(reason==0x16))// user disconnected connection { AppState=App_off; } else { if((AppState==App_on)&&(ble_radio_state==Radio_on)) { scanningApp_start(); } else { AppState=App_off; } } } if(conn== connection_handle_du) { DuConnectionStatus=DuRadioOff; if((SD_status==SD_on)&&(ble_radio_state==Radio_on)) { scanningDu_start(); if( motorStatus == motor_on) { errorInfo.year = currentTime.year; errorInfo.month = currentTime.month; errorInfo.day = currentTime.day; errorInfo.hour = currentTime.hour; errorInfo.minute = currentTime.minute; errorInfo.second = currentTime.second; errorInfo.error_type = Packet_Error_BLEDisconnect; errorInfo.error_BLEDisconnect++; if((connected&connection_app) && (appInitDone)) { wb_data[0]=Packet_Type_Data; wb_data[1]=Packet_Data_ErrorInfo; packet_data.errorInfo = errorInfo; memcpy(&wb_data[2],packet_data.bytes,sizeof(packet_data.errorInfo)); gatt_write_attribute(connection_handle_app,att_handle_app_WB_data,wb_data,sizeof(packet_data.errorInfo)+2); ps_reset_error(); } else { ps_save_error(); } } } connected &=~connection_du; connection_lost_du=1; motorStatus = motor_off; connection_handle_du =255; if((ble_radio_state==Radio_pairing)&&(pairing_mx2plus)) { scanningDu_start(); } set_led_event(); } if(conn== connection_handle_dg) { connected &=~connection_dongle; connection_lost_dg=1; connection_handle_dg =255; } if(ble_radio_state==Radio_off) // bluetooth off state. turn off all connected device { ble_state=STATE_STANDBY; disconnect_device(); } }
// disconnected event handler (copied from stubs.c)
disconnected event handler (copied from stubs.c)
[ "disconnected", "event", "handler", "(", "copied", "from", "stubs", ".", "c", ")" ]
void connection_disconnect_callback(uint8 conn, uint8 reason) { disconnect_count=0; connection_count = 0; ble_state_changed_flag =1; if(conn== connection_handle_app) { connected &=~connection_app; AppConnectionStatus=AppRadioOff; connection_lost_app=1; connection_handle_app =255; if((reason ==0)||(reason==0x13)||(reason==0x16)) { AppState=App_off; } else { if((AppState==App_on)&&(ble_radio_state==Radio_on)) { scanningApp_start(); } else { AppState=App_off; } } } if(conn== connection_handle_du) { DuConnectionStatus=DuRadioOff; if((SD_status==SD_on)&&(ble_radio_state==Radio_on)) { scanningDu_start(); if( motorStatus == motor_on) { errorInfo.year = currentTime.year; errorInfo.month = currentTime.month; errorInfo.day = currentTime.day; errorInfo.hour = currentTime.hour; errorInfo.minute = currentTime.minute; errorInfo.second = currentTime.second; errorInfo.error_type = Packet_Error_BLEDisconnect; errorInfo.error_BLEDisconnect++; if((connected&connection_app) && (appInitDone)) { wb_data[0]=Packet_Type_Data; wb_data[1]=Packet_Data_ErrorInfo; packet_data.errorInfo = errorInfo; memcpy(&wb_data[2],packet_data.bytes,sizeof(packet_data.errorInfo)); gatt_write_attribute(connection_handle_app,att_handle_app_WB_data,wb_data,sizeof(packet_data.errorInfo)+2); ps_reset_error(); } else { ps_save_error(); } } } connected &=~connection_du; connection_lost_du=1; motorStatus = motor_off; connection_handle_du =255; if((ble_radio_state==Radio_pairing)&&(pairing_mx2plus)) { scanningDu_start(); } set_led_event(); } if(conn== connection_handle_dg) { connected &=~connection_dongle; connection_lost_dg=1; connection_handle_dg =255; } if(ble_radio_state==Radio_off) { ble_state=STATE_STANDBY; disconnect_device(); } }
[ "void", "connection_disconnect_callback", "(", "uint8", "conn", ",", "uint8", "reason", ")", "{", "disconnect_count", "=", "0", ";", "connection_count", "=", "0", ";", "ble_state_changed_flag", "=", "1", ";", "if", "(", "conn", "==", "connection_handle_app", ")", "{", "connected", "&=", "~", "connection_app", ";", "AppConnectionStatus", "=", "AppRadioOff", ";", "connection_lost_app", "=", "1", ";", "connection_handle_app", "=", "255", ";", "if", "(", "(", "reason", "==", "0", ")", "||", "(", "reason", "==", "0x13", ")", "||", "(", "reason", "==", "0x16", ")", ")", "{", "AppState", "=", "App_off", ";", "}", "else", "{", "if", "(", "(", "AppState", "==", "App_on", ")", "&&", "(", "ble_radio_state", "==", "Radio_on", ")", ")", "{", "scanningApp_start", "(", ")", ";", "}", "else", "{", "AppState", "=", "App_off", ";", "}", "}", "}", "if", "(", "conn", "==", "connection_handle_du", ")", "{", "DuConnectionStatus", "=", "DuRadioOff", ";", "if", "(", "(", "SD_status", "==", "SD_on", ")", "&&", "(", "ble_radio_state", "==", "Radio_on", ")", ")", "{", "scanningDu_start", "(", ")", ";", "if", "(", "motorStatus", "==", "motor_on", ")", "{", "errorInfo", ".", "year", "=", "currentTime", ".", "year", ";", "errorInfo", ".", "month", "=", "currentTime", ".", "month", ";", "errorInfo", ".", "day", "=", "currentTime", ".", "day", ";", "errorInfo", ".", "hour", "=", "currentTime", ".", "hour", ";", "errorInfo", ".", "minute", "=", "currentTime", ".", "minute", ";", "errorInfo", ".", "second", "=", "currentTime", ".", "second", ";", "errorInfo", ".", "error_type", "=", "Packet_Error_BLEDisconnect", ";", "errorInfo", ".", "error_BLEDisconnect", "++", ";", "if", "(", "(", "connected", "&", "connection_app", ")", "&&", "(", "appInitDone", ")", ")", "{", "wb_data", "[", "0", "]", "=", "Packet_Type_Data", ";", "wb_data", "[", "1", "]", "=", "Packet_Data_ErrorInfo", ";", "packet_data", ".", "errorInfo", "=", "errorInfo", ";", "memcpy", "(", "&", "wb_data", "[", "2", "]", ",", "packet_data", ".", "bytes", ",", "sizeof", "(", "packet_data", ".", "errorInfo", ")", ")", ";", "gatt_write_attribute", "(", "connection_handle_app", ",", "att_handle_app_WB_data", ",", "wb_data", ",", "sizeof", "(", "packet_data", ".", "errorInfo", ")", "+", "2", ")", ";", "ps_reset_error", "(", ")", ";", "}", "else", "{", "ps_save_error", "(", ")", ";", "}", "}", "}", "connected", "&=", "~", "connection_du", ";", "connection_lost_du", "=", "1", ";", "motorStatus", "=", "motor_off", ";", "connection_handle_du", "=", "255", ";", "if", "(", "(", "ble_radio_state", "==", "Radio_pairing", ")", "&&", "(", "pairing_mx2plus", ")", ")", "{", "scanningDu_start", "(", ")", ";", "}", "set_led_event", "(", ")", ";", "}", "if", "(", "conn", "==", "connection_handle_dg", ")", "{", "connected", "&=", "~", "connection_dongle", ";", "connection_lost_dg", "=", "1", ";", "connection_handle_dg", "=", "255", ";", "}", "if", "(", "ble_radio_state", "==", "Radio_off", ")", "{", "ble_state", "=", "STATE_STANDBY", ";", "disconnect_device", "(", ")", ";", "}", "}" ]
disconnected event handler (copied from stubs.c)
[ "disconnected", "event", "handler", "(", "copied", "from", "stubs", ".", "c", ")" ]
[ "// user disconnected connection\r", "// bluetooth off state. turn off all connected device\r" ]
[ { "param": "conn", "type": "uint8" }, { "param": "reason", "type": "uint8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "conn", "type": "uint8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reason", "type": "uint8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a1f05d6439dfe6b8870607f565c707e5a1b415ba
malisal/bfdpie
bfdpie.c
[ "MIT" ]
C
extract_bfd_capsule
int
int extract_bfd_capsule(PyObject *obj, void *dst) { // Is this obj a PyCapsule? if(PyCapsule_IsValid(obj, "pybfd.bfd")) { // Extract the bfd * from the capsule *((bfd **) dst) = PyCapsule_GetPointer(obj, "pybfd.bfd"); // The conversion was successful return 1; } else { PyErr_SetString(PyExc_TypeError, "Invalid parameter(s)"); } // The conversion failed return 0; }
// Passed as a converter function to PyArg_ParseTuple
Passed as a converter function to PyArg_ParseTuple
[ "Passed", "as", "a", "converter", "function", "to", "PyArg_ParseTuple" ]
int extract_bfd_capsule(PyObject *obj, void *dst) { if(PyCapsule_IsValid(obj, "pybfd.bfd")) { *((bfd **) dst) = PyCapsule_GetPointer(obj, "pybfd.bfd"); return 1; } else { PyErr_SetString(PyExc_TypeError, "Invalid parameter(s)"); } return 0; }
[ "int", "extract_bfd_capsule", "(", "PyObject", "*", "obj", ",", "void", "*", "dst", ")", "{", "if", "(", "PyCapsule_IsValid", "(", "obj", ",", "\"", "\"", ")", ")", "{", "*", "(", "(", "bfd", "*", "*", ")", "dst", ")", "=", "PyCapsule_GetPointer", "(", "obj", ",", "\"", "\"", ")", ";", "return", "1", ";", "}", "else", "{", "PyErr_SetString", "(", "PyExc_TypeError", ",", "\"", "\"", ")", ";", "}", "return", "0", ";", "}" ]
Passed as a converter function to PyArg_ParseTuple
[ "Passed", "as", "a", "converter", "function", "to", "PyArg_ParseTuple" ]
[ "// Is this obj a PyCapsule?", "// Extract the bfd * from the capsule", "// The conversion was successful", "// The conversion failed" ]
[ { "param": "obj", "type": "PyObject" }, { "param": "dst", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "PyObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dst", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cc248b86e4028967e5bc3b60497e229275af2f14
tianylijun/tinyMatirxMul
src/sgemm.c
[ "MIT" ]
C
internalPackB4
void
void internalPackB4(int L, float* packB, float* B, int ldb){ float *bp = B; float *packBptr = packB; for(int i = 0; i < L; ++i){ vst1q_f32(packBptr, vld1q_f32(bp)); packBptr += 4; bp += ldb; } }
/* * Helpers that packs A and B in their continguous accessing pattern. */
Helpers that packs A and B in their continguous accessing pattern.
[ "Helpers", "that", "packs", "A", "and", "B", "in", "their", "continguous", "accessing", "pattern", "." ]
void internalPackB4(int L, float* packB, float* B, int ldb){ float *bp = B; float *packBptr = packB; for(int i = 0; i < L; ++i){ vst1q_f32(packBptr, vld1q_f32(bp)); packBptr += 4; bp += ldb; } }
[ "void", "internalPackB4", "(", "int", "L", ",", "float", "*", "packB", ",", "float", "*", "B", ",", "int", "ldb", ")", "{", "float", "*", "bp", "=", "B", ";", "float", "*", "packBptr", "=", "packB", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "L", ";", "++", "i", ")", "{", "vst1q_f32", "(", "packBptr", ",", "vld1q_f32", "(", "bp", ")", ")", ";", "packBptr", "+=", "4", ";", "bp", "+=", "ldb", ";", "}", "}" ]
Helpers that packs A and B in their continguous accessing pattern.
[ "Helpers", "that", "packs", "A", "and", "B", "in", "their", "continguous", "accessing", "pattern", "." ]
[]
[ { "param": "L", "type": "int" }, { "param": "packB", "type": "float" }, { "param": "B", "type": "float" }, { "param": "ldb", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "L", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "packB", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "B", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ldb", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_usedp
byte
byte libaroma_window_usedp(byte isdp){ if (isdp==1){ _libaroma_window_measurement_dp=1; } else if (!isdp){ _libaroma_window_measurement_dp=0; } return _libaroma_window_measurement_dp; }
/* * Function : libaroma_window_usedp * Return Value: byte * Descriptions: use dp for measurement */
Function : libaroma_window_usedp Return Value: byte Descriptions: use dp for measurement
[ "Function", ":", "libaroma_window_usedp", "Return", "Value", ":", "byte", "Descriptions", ":", "use", "dp", "for", "measurement" ]
byte libaroma_window_usedp(byte isdp){ if (isdp==1){ _libaroma_window_measurement_dp=1; } else if (!isdp){ _libaroma_window_measurement_dp=0; } return _libaroma_window_measurement_dp; }
[ "byte", "libaroma_window_usedp", "(", "byte", "isdp", ")", "{", "if", "(", "isdp", "==", "1", ")", "{", "_libaroma_window_measurement_dp", "=", "1", ";", "}", "else", "if", "(", "!", "isdp", ")", "{", "_libaroma_window_measurement_dp", "=", "0", ";", "}", "return", "_libaroma_window_measurement_dp", ";", "}" ]
Function : libaroma_window_usedp Return Value: byte Descriptions: use dp for measurement
[ "Function", ":", "libaroma_window_usedp", "Return", "Value", ":", "byte", "Descriptions", ":", "use", "dp", "for", "measurement" ]
[]
[ { "param": "isdp", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "isdp", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_measure_calculate
int
int libaroma_window_measure_calculate( int cv, int pos, int max, int is_size, int x){ if (is_size){ if (pos<=0){ switch (pos){ case LIBAROMA_POS_HALF: return (max / 2)-x; break; case LIBAROMA_POS_1P3: return (max / 3)-x; break; case LIBAROMA_POS_2P3: return (max * 2 / 3)-x; break; case LIBAROMA_POS_1P4: return (max / 4)-x; break; case LIBAROMA_POS_3P4: return (max * 3 / 4)-x; break; case LIBAROMA_SIZE_FULL: return max; break; case LIBAROMA_SIZE_HALF: return max / 2; break; case LIBAROMA_SIZE_THIRD: return max / 3; break; case LIBAROMA_SIZE_QUARTER: return max / 4; break; default: return abs(pos); } } } else{ if (pos<0){ switch (pos){ case LIBAROMA_POS_HALF: return max / 2; break; case LIBAROMA_POS_1P3: return max / 3; break; case LIBAROMA_POS_2P3: return max * 2 / 3; break; case LIBAROMA_POS_1P4: return max / 4; break; case LIBAROMA_POS_3P4: return max * 3 / 4; break; default: return abs(pos); } } } return cv; }
/* * Function : libaroma_window_measure_calculate * Return Value: int * Descriptions: calculate measurement */
Function : libaroma_window_measure_calculate Return Value: int Descriptions: calculate measurement
[ "Function", ":", "libaroma_window_measure_calculate", "Return", "Value", ":", "int", "Descriptions", ":", "calculate", "measurement" ]
int libaroma_window_measure_calculate( int cv, int pos, int max, int is_size, int x){ if (is_size){ if (pos<=0){ switch (pos){ case LIBAROMA_POS_HALF: return (max / 2)-x; break; case LIBAROMA_POS_1P3: return (max / 3)-x; break; case LIBAROMA_POS_2P3: return (max * 2 / 3)-x; break; case LIBAROMA_POS_1P4: return (max / 4)-x; break; case LIBAROMA_POS_3P4: return (max * 3 / 4)-x; break; case LIBAROMA_SIZE_FULL: return max; break; case LIBAROMA_SIZE_HALF: return max / 2; break; case LIBAROMA_SIZE_THIRD: return max / 3; break; case LIBAROMA_SIZE_QUARTER: return max / 4; break; default: return abs(pos); } } } else{ if (pos<0){ switch (pos){ case LIBAROMA_POS_HALF: return max / 2; break; case LIBAROMA_POS_1P3: return max / 3; break; case LIBAROMA_POS_2P3: return max * 2 / 3; break; case LIBAROMA_POS_1P4: return max / 4; break; case LIBAROMA_POS_3P4: return max * 3 / 4; break; default: return abs(pos); } } } return cv; }
[ "int", "libaroma_window_measure_calculate", "(", "int", "cv", ",", "int", "pos", ",", "int", "max", ",", "int", "is_size", ",", "int", "x", ")", "{", "if", "(", "is_size", ")", "{", "if", "(", "pos", "<=", "0", ")", "{", "switch", "(", "pos", ")", "{", "case", "LIBAROMA_POS_HALF", ":", "return", "(", "max", "/", "2", ")", "-", "x", ";", "break", ";", "case", "LIBAROMA_POS_1P3", ":", "return", "(", "max", "/", "3", ")", "-", "x", ";", "break", ";", "case", "LIBAROMA_POS_2P3", ":", "return", "(", "max", "*", "2", "/", "3", ")", "-", "x", ";", "break", ";", "case", "LIBAROMA_POS_1P4", ":", "return", "(", "max", "/", "4", ")", "-", "x", ";", "break", ";", "case", "LIBAROMA_POS_3P4", ":", "return", "(", "max", "*", "3", "/", "4", ")", "-", "x", ";", "break", ";", "case", "LIBAROMA_SIZE_FULL", ":", "return", "max", ";", "break", ";", "case", "LIBAROMA_SIZE_HALF", ":", "return", "max", "/", "2", ";", "break", ";", "case", "LIBAROMA_SIZE_THIRD", ":", "return", "max", "/", "3", ";", "break", ";", "case", "LIBAROMA_SIZE_QUARTER", ":", "return", "max", "/", "4", ";", "break", ";", "default", ":", "return", "abs", "(", "pos", ")", ";", "}", "}", "}", "else", "{", "if", "(", "pos", "<", "0", ")", "{", "switch", "(", "pos", ")", "{", "case", "LIBAROMA_POS_HALF", ":", "return", "max", "/", "2", ";", "break", ";", "case", "LIBAROMA_POS_1P3", ":", "return", "max", "/", "3", ";", "break", ";", "case", "LIBAROMA_POS_2P3", ":", "return", "max", "*", "2", "/", "3", ";", "break", ";", "case", "LIBAROMA_POS_1P4", ":", "return", "max", "/", "4", ";", "break", ";", "case", "LIBAROMA_POS_3P4", ":", "return", "max", "*", "3", "/", "4", ";", "break", ";", "default", ":", "return", "abs", "(", "pos", ")", ";", "}", "}", "}", "return", "cv", ";", "}" ]
Function : libaroma_window_measure_calculate Return Value: int Descriptions: calculate measurement
[ "Function", ":", "libaroma_window_measure_calculate", "Return", "Value", ":", "int", "Descriptions", ":", "calculate", "measurement" ]
[]
[ { "param": "cv", "type": "int" }, { "param": "pos", "type": "int" }, { "param": "max", "type": "int" }, { "param": "is_size", "type": "int" }, { "param": "x", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cv", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pos", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "max", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "is_size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_measure_size
byte
byte libaroma_window_measure_size(LIBAROMA_WINDOWP win){ if (win){ if (win->parent!=NULL){ ALOGW("window_resize cannot be used for child window"); return 0; } if (_libaroma_window_measurement_dp){ win->x = libaroma_dp(win->rx); win->y = libaroma_dp(win->ry); win->w = libaroma_dp(win->rw); win->h = libaroma_dp(win->rh); } else{ win->x = win->rx; win->y = win->ry; win->w = win->rw; win->h = win->rh; } win->ax=win->x; win->ay=win->y; win->x=libaroma_window_measure_calculate( win->x, win->rx, libaroma_wm()->w, 0, 0 ); win->y=libaroma_window_measure_calculate( win->y, win->ry, libaroma_wm()->h, 0, 0 ); win->w=libaroma_window_measure_calculate( win->w, win->rw, libaroma_wm()->w, 1, win->x ); win->h=libaroma_window_measure_calculate( win->h, win->rh, libaroma_wm()->h, 1, win->y ); if (win->w+win->x>libaroma_wm()->w){ win->w = libaroma_wm()->w-win->x; } if (win->h+win->y>libaroma_wm()->h){ win->h = libaroma_wm()->h-win->y; } _libaroma_window_measure_save(win,NULL); LIBAROMA_MSG _msg; libaroma_window_process_event(win,libaroma_wm_compose( &_msg, LIBAROMA_MSG_WIN_MEASURED, NULL, 0, 0) ); return 1; } return 0; }
/* * Function : libaroma_window_measure_size * Return Value: byte * Descriptions: measure window size */
Function : libaroma_window_measure_size Return Value: byte Descriptions: measure window size
[ "Function", ":", "libaroma_window_measure_size", "Return", "Value", ":", "byte", "Descriptions", ":", "measure", "window", "size" ]
byte libaroma_window_measure_size(LIBAROMA_WINDOWP win){ if (win){ if (win->parent!=NULL){ ALOGW("window_resize cannot be used for child window"); return 0; } if (_libaroma_window_measurement_dp){ win->x = libaroma_dp(win->rx); win->y = libaroma_dp(win->ry); win->w = libaroma_dp(win->rw); win->h = libaroma_dp(win->rh); } else{ win->x = win->rx; win->y = win->ry; win->w = win->rw; win->h = win->rh; } win->ax=win->x; win->ay=win->y; win->x=libaroma_window_measure_calculate( win->x, win->rx, libaroma_wm()->w, 0, 0 ); win->y=libaroma_window_measure_calculate( win->y, win->ry, libaroma_wm()->h, 0, 0 ); win->w=libaroma_window_measure_calculate( win->w, win->rw, libaroma_wm()->w, 1, win->x ); win->h=libaroma_window_measure_calculate( win->h, win->rh, libaroma_wm()->h, 1, win->y ); if (win->w+win->x>libaroma_wm()->w){ win->w = libaroma_wm()->w-win->x; } if (win->h+win->y>libaroma_wm()->h){ win->h = libaroma_wm()->h-win->y; } _libaroma_window_measure_save(win,NULL); LIBAROMA_MSG _msg; libaroma_window_process_event(win,libaroma_wm_compose( &_msg, LIBAROMA_MSG_WIN_MEASURED, NULL, 0, 0) ); return 1; } return 0; }
[ "byte", "libaroma_window_measure_size", "(", "LIBAROMA_WINDOWP", "win", ")", "{", "if", "(", "win", ")", "{", "if", "(", "win", "->", "parent", "!=", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "_libaroma_window_measurement_dp", ")", "{", "win", "->", "x", "=", "libaroma_dp", "(", "win", "->", "rx", ")", ";", "win", "->", "y", "=", "libaroma_dp", "(", "win", "->", "ry", ")", ";", "win", "->", "w", "=", "libaroma_dp", "(", "win", "->", "rw", ")", ";", "win", "->", "h", "=", "libaroma_dp", "(", "win", "->", "rh", ")", ";", "}", "else", "{", "win", "->", "x", "=", "win", "->", "rx", ";", "win", "->", "y", "=", "win", "->", "ry", ";", "win", "->", "w", "=", "win", "->", "rw", ";", "win", "->", "h", "=", "win", "->", "rh", ";", "}", "win", "->", "ax", "=", "win", "->", "x", ";", "win", "->", "ay", "=", "win", "->", "y", ";", "win", "->", "x", "=", "libaroma_window_measure_calculate", "(", "win", "->", "x", ",", "win", "->", "rx", ",", "libaroma_wm", "(", ")", "->", "w", ",", "0", ",", "0", ")", ";", "win", "->", "y", "=", "libaroma_window_measure_calculate", "(", "win", "->", "y", ",", "win", "->", "ry", ",", "libaroma_wm", "(", ")", "->", "h", ",", "0", ",", "0", ")", ";", "win", "->", "w", "=", "libaroma_window_measure_calculate", "(", "win", "->", "w", ",", "win", "->", "rw", ",", "libaroma_wm", "(", ")", "->", "w", ",", "1", ",", "win", "->", "x", ")", ";", "win", "->", "h", "=", "libaroma_window_measure_calculate", "(", "win", "->", "h", ",", "win", "->", "rh", ",", "libaroma_wm", "(", ")", "->", "h", ",", "1", ",", "win", "->", "y", ")", ";", "if", "(", "win", "->", "w", "+", "win", "->", "x", ">", "libaroma_wm", "(", ")", "->", "w", ")", "{", "win", "->", "w", "=", "libaroma_wm", "(", ")", "->", "w", "-", "win", "->", "x", ";", "}", "if", "(", "win", "->", "h", "+", "win", "->", "y", ">", "libaroma_wm", "(", ")", "->", "h", ")", "{", "win", "->", "h", "=", "libaroma_wm", "(", ")", "->", "h", "-", "win", "->", "y", ";", "}", "_libaroma_window_measure_save", "(", "win", ",", "NULL", ")", ";", "LIBAROMA_MSG", "_msg", ";", "libaroma_window_process_event", "(", "win", ",", "libaroma_wm_compose", "(", "&", "_msg", ",", "LIBAROMA_MSG_WIN_MEASURED", ",", "NULL", ",", "0", ",", "0", ")", ")", ";", "return", "1", ";", "}", "return", "0", ";", "}" ]
Function : libaroma_window_measure_size Return Value: byte Descriptions: measure window size
[ "Function", ":", "libaroma_window_measure_size", "Return", "Value", ":", "byte", "Descriptions", ":", "measure", "window", "size" ]
[]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window
LIBAROMA_WINDOWP
LIBAROMA_WINDOWP libaroma_window( char * bg_theme_name, int x, int y, int w, int h ){ __CHECK_WM(NULL); LIBAROMA_WINDOWP win = (LIBAROMA_WINDOWP) calloc(sizeof(LIBAROMA_WINDOW),1); if (!win){ ALOGW("libaroma_window alloc window data failed"); return NULL; } if (bg_theme_name){ snprintf(win->theme_bg,256,"%s",bg_theme_name); } else{ win->theme_bg[0]=0; } win->rx = x; win->ry = y; win->rw = w; win->rh = h; win->onpool=1; win->prev_screen = libaroma_fb_snapshoot_canvas(); win->ui_thread = _libaroma_window_ui_thread; libaroma_window_measure_size(win); return win; }
/* * Function : libaroma_window * Return Value: LIBAROMA_WINDOWP * Descriptions: creates a new window */
Function : libaroma_window Return Value: LIBAROMA_WINDOWP Descriptions: creates a new window
[ "Function", ":", "libaroma_window", "Return", "Value", ":", "LIBAROMA_WINDOWP", "Descriptions", ":", "creates", "a", "new", "window" ]
LIBAROMA_WINDOWP libaroma_window( char * bg_theme_name, int x, int y, int w, int h ){ __CHECK_WM(NULL); LIBAROMA_WINDOWP win = (LIBAROMA_WINDOWP) calloc(sizeof(LIBAROMA_WINDOW),1); if (!win){ ALOGW("libaroma_window alloc window data failed"); return NULL; } if (bg_theme_name){ snprintf(win->theme_bg,256,"%s",bg_theme_name); } else{ win->theme_bg[0]=0; } win->rx = x; win->ry = y; win->rw = w; win->rh = h; win->onpool=1; win->prev_screen = libaroma_fb_snapshoot_canvas(); win->ui_thread = _libaroma_window_ui_thread; libaroma_window_measure_size(win); return win; }
[ "LIBAROMA_WINDOWP", "libaroma_window", "(", "char", "*", "bg_theme_name", ",", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "__CHECK_WM", "(", "NULL", ")", ";", "LIBAROMA_WINDOWP", "win", "=", "(", "LIBAROMA_WINDOWP", ")", "calloc", "(", "sizeof", "(", "LIBAROMA_WINDOW", ")", ",", "1", ")", ";", "if", "(", "!", "win", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "NULL", ";", "}", "if", "(", "bg_theme_name", ")", "{", "snprintf", "(", "win", "->", "theme_bg", ",", "256", ",", "\"", "\"", ",", "bg_theme_name", ")", ";", "}", "else", "{", "win", "->", "theme_bg", "[", "0", "]", "=", "0", ";", "}", "win", "->", "rx", "=", "x", ";", "win", "->", "ry", "=", "y", ";", "win", "->", "rw", "=", "w", ";", "win", "->", "rh", "=", "h", ";", "win", "->", "onpool", "=", "1", ";", "win", "->", "prev_screen", "=", "libaroma_fb_snapshoot_canvas", "(", ")", ";", "win", "->", "ui_thread", "=", "_libaroma_window_ui_thread", ";", "libaroma_window_measure_size", "(", "win", ")", ";", "return", "win", ";", "}" ]
Function : libaroma_window Return Value: LIBAROMA_WINDOWP Descriptions: creates a new window
[ "Function", ":", "libaroma_window", "Return", "Value", ":", "LIBAROMA_WINDOWP", "Descriptions", ":", "creates", "a", "new", "window" ]
[]
[ { "param": "bg_theme_name", "type": "char" }, { "param": "x", "type": "int" }, { "param": "y", "type": "int" }, { "param": "w", "type": "int" }, { "param": "h", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bg_theme_name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "w", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "h", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
_libaroma_window_updatebg
byte
byte _libaroma_window_updatebg(LIBAROMA_WINDOWP win){ if (win==NULL){ ALOGW("window_recalculate win is NULL"); return 0; } if (win->handler!=NULL){ if (win->handler->updatebg!=NULL){ if (win->handler->updatebg(win)){ if (win->onupdatebg){ win->onupdatebg(win,win->bg); } return 1; } return 0; } } if (win->parent!=NULL){ return 0; } int w = win->w; int h = win->h; /* draw background */ if (win->bg!=NULL){ if ((win->bg->w==w)&&(win->bg->h==h)){ /* not need recreate background */ return 1; } libaroma_canvas_free(win->bg); } win->bg = libaroma_canvas(w,h); /* default canvas color */ libaroma_canvas_setcolor( win->bg, libaroma_colorget(NULL,win)->window_bg, 0xff ); /* from theme canvas */ if (win->theme_bg[0]!=0){ libaroma_wm_draw_theme( win->bg, win->theme_bg, 0, 0, win->bg->w, win->bg->h, NULL ); } /* from updatebg callback */ if (win->onupdatebg!=NULL){ win->onupdatebg(win,win->bg); } return 1; }
/* * Function : _libaroma_window_updatebg * Return Value: byte * Descriptions: update window background */
Function : _libaroma_window_updatebg Return Value: byte Descriptions: update window background
[ "Function", ":", "_libaroma_window_updatebg", "Return", "Value", ":", "byte", "Descriptions", ":", "update", "window", "background" ]
byte _libaroma_window_updatebg(LIBAROMA_WINDOWP win){ if (win==NULL){ ALOGW("window_recalculate win is NULL"); return 0; } if (win->handler!=NULL){ if (win->handler->updatebg!=NULL){ if (win->handler->updatebg(win)){ if (win->onupdatebg){ win->onupdatebg(win,win->bg); } return 1; } return 0; } } if (win->parent!=NULL){ return 0; } int w = win->w; int h = win->h; if (win->bg!=NULL){ if ((win->bg->w==w)&&(win->bg->h==h)){ return 1; } libaroma_canvas_free(win->bg); } win->bg = libaroma_canvas(w,h); libaroma_canvas_setcolor( win->bg, libaroma_colorget(NULL,win)->window_bg, 0xff ); if (win->theme_bg[0]!=0){ libaroma_wm_draw_theme( win->bg, win->theme_bg, 0, 0, win->bg->w, win->bg->h, NULL ); } if (win->onupdatebg!=NULL){ win->onupdatebg(win,win->bg); } return 1; }
[ "byte", "_libaroma_window_updatebg", "(", "LIBAROMA_WINDOWP", "win", ")", "{", "if", "(", "win", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "win", "->", "handler", "!=", "NULL", ")", "{", "if", "(", "win", "->", "handler", "->", "updatebg", "!=", "NULL", ")", "{", "if", "(", "win", "->", "handler", "->", "updatebg", "(", "win", ")", ")", "{", "if", "(", "win", "->", "onupdatebg", ")", "{", "win", "->", "onupdatebg", "(", "win", ",", "win", "->", "bg", ")", ";", "}", "return", "1", ";", "}", "return", "0", ";", "}", "}", "if", "(", "win", "->", "parent", "!=", "NULL", ")", "{", "return", "0", ";", "}", "int", "w", "=", "win", "->", "w", ";", "int", "h", "=", "win", "->", "h", ";", "if", "(", "win", "->", "bg", "!=", "NULL", ")", "{", "if", "(", "(", "win", "->", "bg", "->", "w", "==", "w", ")", "&&", "(", "win", "->", "bg", "->", "h", "==", "h", ")", ")", "{", "return", "1", ";", "}", "libaroma_canvas_free", "(", "win", "->", "bg", ")", ";", "}", "win", "->", "bg", "=", "libaroma_canvas", "(", "w", ",", "h", ")", ";", "libaroma_canvas_setcolor", "(", "win", "->", "bg", ",", "libaroma_colorget", "(", "NULL", ",", "win", ")", "->", "window_bg", ",", "0xff", ")", ";", "if", "(", "win", "->", "theme_bg", "[", "0", "]", "!=", "0", ")", "{", "libaroma_wm_draw_theme", "(", "win", "->", "bg", ",", "win", "->", "theme_bg", ",", "0", ",", "0", ",", "win", "->", "bg", "->", "w", ",", "win", "->", "bg", "->", "h", ",", "NULL", ")", ";", "}", "if", "(", "win", "->", "onupdatebg", "!=", "NULL", ")", "{", "win", "->", "onupdatebg", "(", "win", ",", "win", "->", "bg", ")", ";", "}", "return", "1", ";", "}" ]
Function : _libaroma_window_updatebg Return Value: byte Descriptions: update window background
[ "Function", ":", "_libaroma_window_updatebg", "Return", "Value", ":", "byte", "Descriptions", ":", "update", "window", "background" ]
[ "/* draw background */", "/* not need recreate background */", "/* default canvas color */", "/* from theme canvas */", "/* from updatebg callback */" ]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
_libaroma_window_recalculate
byte
byte _libaroma_window_recalculate(LIBAROMA_WINDOWP win){ if (win==NULL){ ALOGW("window_recalculate win is NULL"); return 0; } if (libaroma_window_isactive(win)){ _libaroma_window_updatebg(win); libaroma_window_invalidate(win, 1); } return 1; }
/* * Function : _libaroma_window_recalculate * Return Value: byte * Descriptions: recalculate client size */
Function : _libaroma_window_recalculate Return Value: byte Descriptions: recalculate client size
[ "Function", ":", "_libaroma_window_recalculate", "Return", "Value", ":", "byte", "Descriptions", ":", "recalculate", "client", "size" ]
byte _libaroma_window_recalculate(LIBAROMA_WINDOWP win){ if (win==NULL){ ALOGW("window_recalculate win is NULL"); return 0; } if (libaroma_window_isactive(win)){ _libaroma_window_updatebg(win); libaroma_window_invalidate(win, 1); } return 1; }
[ "byte", "_libaroma_window_recalculate", "(", "LIBAROMA_WINDOWP", "win", ")", "{", "if", "(", "win", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "libaroma_window_isactive", "(", "win", ")", ")", "{", "_libaroma_window_updatebg", "(", "win", ")", ";", "libaroma_window_invalidate", "(", "win", ",", "1", ")", ";", "}", "return", "1", ";", "}" ]
Function : _libaroma_window_recalculate Return Value: byte Descriptions: recalculate client size
[ "Function", ":", "_libaroma_window_recalculate", "Return", "Value", ":", "byte", "Descriptions", ":", "recalculate", "client", "size" ]
[]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_resize
byte
byte libaroma_window_resize( LIBAROMA_WINDOWP win, int x, int y, int w, int h ){ if (!win){ return 0; } if (win->parent!=NULL){ ALOGW("window_resize cannot be used for child window"); return 0; } win->rx = x; win->ry = y; win->rw = w; win->rh = h; if (libaroma_window_measure_size(win)){ return _libaroma_window_ready(win); } return 0; }
/* * Function : libaroma_window_resize * Return Value: byte * Descriptions: resize window */
Function : libaroma_window_resize Return Value: byte Descriptions: resize window
[ "Function", ":", "libaroma_window_resize", "Return", "Value", ":", "byte", "Descriptions", ":", "resize", "window" ]
byte libaroma_window_resize( LIBAROMA_WINDOWP win, int x, int y, int w, int h ){ if (!win){ return 0; } if (win->parent!=NULL){ ALOGW("window_resize cannot be used for child window"); return 0; } win->rx = x; win->ry = y; win->rw = w; win->rh = h; if (libaroma_window_measure_size(win)){ return _libaroma_window_ready(win); } return 0; }
[ "byte", "libaroma_window_resize", "(", "LIBAROMA_WINDOWP", "win", ",", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "if", "(", "!", "win", ")", "{", "return", "0", ";", "}", "if", "(", "win", "->", "parent", "!=", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "win", "->", "rx", "=", "x", ";", "win", "->", "ry", "=", "y", ";", "win", "->", "rw", "=", "w", ";", "win", "->", "rh", "=", "h", ";", "if", "(", "libaroma_window_measure_size", "(", "win", ")", ")", "{", "return", "_libaroma_window_ready", "(", "win", ")", ";", "}", "return", "0", ";", "}" ]
Function : libaroma_window_resize Return Value: byte Descriptions: resize window
[ "Function", ":", "libaroma_window_resize", "Return", "Value", ":", "byte", "Descriptions", ":", "resize", "window" ]
[]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "x", "type": "int" }, { "param": "y", "type": "int" }, { "param": "w", "type": "int" }, { "param": "h", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "w", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "h", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_isactive
byte
byte libaroma_window_isactive(LIBAROMA_WINDOWP win){ if (win!=NULL){ LIBAROMA_WINDOWP w = win; while(w->parent){ w=w->parent; } return ((w==libaroma_wm_get_active_window())?1:0); } return 0; }
/* * Function : libaroma_window_isactive * Return Value: byte * Descriptions: check if window is active */
Function : libaroma_window_isactive Return Value: byte Descriptions: check if window is active
[ "Function", ":", "libaroma_window_isactive", "Return", "Value", ":", "byte", "Descriptions", ":", "check", "if", "window", "is", "active" ]
byte libaroma_window_isactive(LIBAROMA_WINDOWP win){ if (win!=NULL){ LIBAROMA_WINDOWP w = win; while(w->parent){ w=w->parent; } return ((w==libaroma_wm_get_active_window())?1:0); } return 0; }
[ "byte", "libaroma_window_isactive", "(", "LIBAROMA_WINDOWP", "win", ")", "{", "if", "(", "win", "!=", "NULL", ")", "{", "LIBAROMA_WINDOWP", "w", "=", "win", ";", "while", "(", "w", "->", "parent", ")", "{", "w", "=", "w", "->", "parent", ";", "}", "return", "(", "(", "w", "==", "libaroma_wm_get_active_window", "(", ")", ")", "?", "1", ":", "0", ")", ";", "}", "return", "0", ";", "}" ]
Function : libaroma_window_isactive Return Value: byte Descriptions: check if window is active
[ "Function", ":", "libaroma_window_isactive", "Return", "Value", ":", "byte", "Descriptions", ":", "check", "if", "window", "is", "active" ]
[]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_add
byte
byte libaroma_window_add( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl ){ __CHECK_WM(0); if (win==NULL){ ALOGW("window_add win is NULL"); return 0; } if (ctl==NULL){ ALOGW("window_add ctl is NULL"); return 0; } if (ctl->window != NULL){ ALOGW("window_add ctl already have window"); return 0; } libaroma_window_measure(win, ctl); if (win->childn==0){ win->childs = (LIBAROMA_CONTROLP *) malloc(sizeof(LIBAROMA_CONTROLP)); if (!win->childs){ ALOGW("window_add malloc failed"); win->childs=NULL; return 0; } win->childs[0]=ctl; } else{ LIBAROMA_CONTROLP * newchilds = (LIBAROMA_CONTROLP *) realloc(win->childs, sizeof(LIBAROMA_CONTROLP)*(win->childn+1)); if (!newchilds){ ALOGW("window_add realloc failed"); return 0; } win->childs = newchilds; win->childs[win->childn] = ctl; } ctl->window = win; win->childn++; _libaroma_window_recalculate(win); return 1; }
/* * Function : libaroma_window_add * Return Value: byte * Descriptions: add control into window */
Function : libaroma_window_add Return Value: byte Descriptions: add control into window
[ "Function", ":", "libaroma_window_add", "Return", "Value", ":", "byte", "Descriptions", ":", "add", "control", "into", "window" ]
byte libaroma_window_add( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl ){ __CHECK_WM(0); if (win==NULL){ ALOGW("window_add win is NULL"); return 0; } if (ctl==NULL){ ALOGW("window_add ctl is NULL"); return 0; } if (ctl->window != NULL){ ALOGW("window_add ctl already have window"); return 0; } libaroma_window_measure(win, ctl); if (win->childn==0){ win->childs = (LIBAROMA_CONTROLP *) malloc(sizeof(LIBAROMA_CONTROLP)); if (!win->childs){ ALOGW("window_add malloc failed"); win->childs=NULL; return 0; } win->childs[0]=ctl; } else{ LIBAROMA_CONTROLP * newchilds = (LIBAROMA_CONTROLP *) realloc(win->childs, sizeof(LIBAROMA_CONTROLP)*(win->childn+1)); if (!newchilds){ ALOGW("window_add realloc failed"); return 0; } win->childs = newchilds; win->childs[win->childn] = ctl; } ctl->window = win; win->childn++; _libaroma_window_recalculate(win); return 1; }
[ "byte", "libaroma_window_add", "(", "LIBAROMA_WINDOWP", "win", ",", "LIBAROMA_CONTROLP", "ctl", ")", "{", "__CHECK_WM", "(", "0", ")", ";", "if", "(", "win", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "ctl", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "ctl", "->", "window", "!=", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "libaroma_window_measure", "(", "win", ",", "ctl", ")", ";", "if", "(", "win", "->", "childn", "==", "0", ")", "{", "win", "->", "childs", "=", "(", "LIBAROMA_CONTROLP", "*", ")", "malloc", "(", "sizeof", "(", "LIBAROMA_CONTROLP", ")", ")", ";", "if", "(", "!", "win", "->", "childs", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "win", "->", "childs", "=", "NULL", ";", "return", "0", ";", "}", "win", "->", "childs", "[", "0", "]", "=", "ctl", ";", "}", "else", "{", "LIBAROMA_CONTROLP", "*", "newchilds", "=", "(", "LIBAROMA_CONTROLP", "*", ")", "realloc", "(", "win", "->", "childs", ",", "sizeof", "(", "LIBAROMA_CONTROLP", ")", "*", "(", "win", "->", "childn", "+", "1", ")", ")", ";", "if", "(", "!", "newchilds", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "win", "->", "childs", "=", "newchilds", ";", "win", "->", "childs", "[", "win", "->", "childn", "]", "=", "ctl", ";", "}", "ctl", "->", "window", "=", "win", ";", "win", "->", "childn", "++", ";", "_libaroma_window_recalculate", "(", "win", ")", ";", "return", "1", ";", "}" ]
Function : libaroma_window_add Return Value: byte Descriptions: add control into window
[ "Function", ":", "libaroma_window_add", "Return", "Value", ":", "byte", "Descriptions", ":", "add", "control", "into", "window" ]
[]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "ctl", "type": "LIBAROMA_CONTROLP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctl", "type": "LIBAROMA_CONTROLP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_del
byte
byte libaroma_window_del( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl ){ __CHECK_WM(0); if (ctl==NULL){ ALOGW("window_del ctl is null"); return 0; } if (win==NULL){ ALOGW("window_del win is null"); return 0; } if (win != ctl->window){ return 0; } if (win->childn<=0){ ALOGW("window_del window data corrupt doesn't have childs??"); return 0; } else if (win->childn==1){ if (win->childs[0]==ctl){ ctl->window = NULL; win->childn=0; free(win->childs); win->childs=NULL; _libaroma_window_recalculate(win); return 1; } else{ ALOGW("window_del ctl not found in window"); return 0; } } LIBAROMA_CONTROLP * newchilds = (LIBAROMA_CONTROLP *) malloc(sizeof(LIBAROMA_CONTROLP)*(win->childn-1)); if (!newchilds){ ALOGW("window_del malloc temp childs failed"); return 0; } int j = 0; int i; for (i=0;i<win->childn;i++){ if (win->childs[i]!=ctl){ newchilds[j++]=win->childs[i]; if (j==win->childn-2){ /* current ctl not found */ free(newchilds); ALOGW("window_del ctl not found in window"); return 0; } } } free(win->childs); win->childs=newchilds; win->childn--; _libaroma_window_recalculate(win); return 1; }
/* * Function : libaroma_window_del * Return Value: byte * Descriptions: delete control from window */
Function : libaroma_window_del Return Value: byte Descriptions: delete control from window
[ "Function", ":", "libaroma_window_del", "Return", "Value", ":", "byte", "Descriptions", ":", "delete", "control", "from", "window" ]
byte libaroma_window_del( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl ){ __CHECK_WM(0); if (ctl==NULL){ ALOGW("window_del ctl is null"); return 0; } if (win==NULL){ ALOGW("window_del win is null"); return 0; } if (win != ctl->window){ return 0; } if (win->childn<=0){ ALOGW("window_del window data corrupt doesn't have childs??"); return 0; } else if (win->childn==1){ if (win->childs[0]==ctl){ ctl->window = NULL; win->childn=0; free(win->childs); win->childs=NULL; _libaroma_window_recalculate(win); return 1; } else{ ALOGW("window_del ctl not found in window"); return 0; } } LIBAROMA_CONTROLP * newchilds = (LIBAROMA_CONTROLP *) malloc(sizeof(LIBAROMA_CONTROLP)*(win->childn-1)); if (!newchilds){ ALOGW("window_del malloc temp childs failed"); return 0; } int j = 0; int i; for (i=0;i<win->childn;i++){ if (win->childs[i]!=ctl){ newchilds[j++]=win->childs[i]; if (j==win->childn-2){ free(newchilds); ALOGW("window_del ctl not found in window"); return 0; } } } free(win->childs); win->childs=newchilds; win->childn--; _libaroma_window_recalculate(win); return 1; }
[ "byte", "libaroma_window_del", "(", "LIBAROMA_WINDOWP", "win", ",", "LIBAROMA_CONTROLP", "ctl", ")", "{", "__CHECK_WM", "(", "0", ")", ";", "if", "(", "ctl", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "win", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "win", "!=", "ctl", "->", "window", ")", "{", "return", "0", ";", "}", "if", "(", "win", "->", "childn", "<=", "0", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "else", "if", "(", "win", "->", "childn", "==", "1", ")", "{", "if", "(", "win", "->", "childs", "[", "0", "]", "==", "ctl", ")", "{", "ctl", "->", "window", "=", "NULL", ";", "win", "->", "childn", "=", "0", ";", "free", "(", "win", "->", "childs", ")", ";", "win", "->", "childs", "=", "NULL", ";", "_libaroma_window_recalculate", "(", "win", ")", ";", "return", "1", ";", "}", "else", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "}", "LIBAROMA_CONTROLP", "*", "newchilds", "=", "(", "LIBAROMA_CONTROLP", "*", ")", "malloc", "(", "sizeof", "(", "LIBAROMA_CONTROLP", ")", "*", "(", "win", "->", "childn", "-", "1", ")", ")", ";", "if", "(", "!", "newchilds", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "int", "j", "=", "0", ";", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "win", "->", "childn", ";", "i", "++", ")", "{", "if", "(", "win", "->", "childs", "[", "i", "]", "!=", "ctl", ")", "{", "newchilds", "[", "j", "++", "]", "=", "win", "->", "childs", "[", "i", "]", ";", "if", "(", "j", "==", "win", "->", "childn", "-", "2", ")", "{", "free", "(", "newchilds", ")", ";", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "}", "}", "free", "(", "win", "->", "childs", ")", ";", "win", "->", "childs", "=", "newchilds", ";", "win", "->", "childn", "--", ";", "_libaroma_window_recalculate", "(", "win", ")", ";", "return", "1", ";", "}" ]
Function : libaroma_window_del Return Value: byte Descriptions: delete control from window
[ "Function", ":", "libaroma_window_del", "Return", "Value", ":", "byte", "Descriptions", ":", "delete", "control", "from", "window" ]
[ "/* current ctl not found */" ]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "ctl", "type": "LIBAROMA_CONTROLP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctl", "type": "LIBAROMA_CONTROLP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_measure
byte
byte libaroma_window_measure(LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl){ if (win&&ctl){ if (_libaroma_window_measurement_dp){ ctl->x = libaroma_dp(ctl->rx); ctl->y = libaroma_dp(ctl->ry); ctl->w = libaroma_dp(ctl->rw); ctl->h = libaroma_dp(ctl->rh); } else{ ctl->x = ctl->rx; ctl->y = ctl->ry; ctl->w = ctl->rw; ctl->h = ctl->rh; } ctl->x=libaroma_window_measure_calculate( ctl->x, ctl->rx, win->w, 0, 0 ); ctl->y=libaroma_window_measure_calculate( ctl->y, ctl->ry, win->h, 0, 0 ); ctl->w=libaroma_window_measure_calculate( ctl->w,ctl->rw, win->w, 1, ctl->x ); ctl->h=libaroma_window_measure_calculate( ctl->h,ctl->rh, win->h, 1, ctl->y ); if (ctl->w+ctl->x>win->w){ ctl->w = win->w-ctl->x; } if (ctl->h+ctl->y>win->h){ ctl->h = win->h-ctl->y; } if (ctl->w<ctl->minw){ ctl->w=ctl->minw; } if (ctl->h<ctl->minh){ ctl->h=ctl->minh; } _libaroma_window_measure_save(NULL,ctl); if (ctl->handler->message){ LIBAROMA_MSG _msg; ctl->handler->message(ctl, libaroma_wm_compose( &_msg, LIBAROMA_MSG_WIN_MEASURED, NULL, 0, 0) ); return 1; } } return 0; }
/* * Function : libaroma_window_measure * Return Value: byte * Descriptions: measure control size */
Function : libaroma_window_measure Return Value: byte Descriptions: measure control size
[ "Function", ":", "libaroma_window_measure", "Return", "Value", ":", "byte", "Descriptions", ":", "measure", "control", "size" ]
byte libaroma_window_measure(LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl){ if (win&&ctl){ if (_libaroma_window_measurement_dp){ ctl->x = libaroma_dp(ctl->rx); ctl->y = libaroma_dp(ctl->ry); ctl->w = libaroma_dp(ctl->rw); ctl->h = libaroma_dp(ctl->rh); } else{ ctl->x = ctl->rx; ctl->y = ctl->ry; ctl->w = ctl->rw; ctl->h = ctl->rh; } ctl->x=libaroma_window_measure_calculate( ctl->x, ctl->rx, win->w, 0, 0 ); ctl->y=libaroma_window_measure_calculate( ctl->y, ctl->ry, win->h, 0, 0 ); ctl->w=libaroma_window_measure_calculate( ctl->w,ctl->rw, win->w, 1, ctl->x ); ctl->h=libaroma_window_measure_calculate( ctl->h,ctl->rh, win->h, 1, ctl->y ); if (ctl->w+ctl->x>win->w){ ctl->w = win->w-ctl->x; } if (ctl->h+ctl->y>win->h){ ctl->h = win->h-ctl->y; } if (ctl->w<ctl->minw){ ctl->w=ctl->minw; } if (ctl->h<ctl->minh){ ctl->h=ctl->minh; } _libaroma_window_measure_save(NULL,ctl); if (ctl->handler->message){ LIBAROMA_MSG _msg; ctl->handler->message(ctl, libaroma_wm_compose( &_msg, LIBAROMA_MSG_WIN_MEASURED, NULL, 0, 0) ); return 1; } } return 0; }
[ "byte", "libaroma_window_measure", "(", "LIBAROMA_WINDOWP", "win", ",", "LIBAROMA_CONTROLP", "ctl", ")", "{", "if", "(", "win", "&&", "ctl", ")", "{", "if", "(", "_libaroma_window_measurement_dp", ")", "{", "ctl", "->", "x", "=", "libaroma_dp", "(", "ctl", "->", "rx", ")", ";", "ctl", "->", "y", "=", "libaroma_dp", "(", "ctl", "->", "ry", ")", ";", "ctl", "->", "w", "=", "libaroma_dp", "(", "ctl", "->", "rw", ")", ";", "ctl", "->", "h", "=", "libaroma_dp", "(", "ctl", "->", "rh", ")", ";", "}", "else", "{", "ctl", "->", "x", "=", "ctl", "->", "rx", ";", "ctl", "->", "y", "=", "ctl", "->", "ry", ";", "ctl", "->", "w", "=", "ctl", "->", "rw", ";", "ctl", "->", "h", "=", "ctl", "->", "rh", ";", "}", "ctl", "->", "x", "=", "libaroma_window_measure_calculate", "(", "ctl", "->", "x", ",", "ctl", "->", "rx", ",", "win", "->", "w", ",", "0", ",", "0", ")", ";", "ctl", "->", "y", "=", "libaroma_window_measure_calculate", "(", "ctl", "->", "y", ",", "ctl", "->", "ry", ",", "win", "->", "h", ",", "0", ",", "0", ")", ";", "ctl", "->", "w", "=", "libaroma_window_measure_calculate", "(", "ctl", "->", "w", ",", "ctl", "->", "rw", ",", "win", "->", "w", ",", "1", ",", "ctl", "->", "x", ")", ";", "ctl", "->", "h", "=", "libaroma_window_measure_calculate", "(", "ctl", "->", "h", ",", "ctl", "->", "rh", ",", "win", "->", "h", ",", "1", ",", "ctl", "->", "y", ")", ";", "if", "(", "ctl", "->", "w", "+", "ctl", "->", "x", ">", "win", "->", "w", ")", "{", "ctl", "->", "w", "=", "win", "->", "w", "-", "ctl", "->", "x", ";", "}", "if", "(", "ctl", "->", "h", "+", "ctl", "->", "y", ">", "win", "->", "h", ")", "{", "ctl", "->", "h", "=", "win", "->", "h", "-", "ctl", "->", "y", ";", "}", "if", "(", "ctl", "->", "w", "<", "ctl", "->", "minw", ")", "{", "ctl", "->", "w", "=", "ctl", "->", "minw", ";", "}", "if", "(", "ctl", "->", "h", "<", "ctl", "->", "minh", ")", "{", "ctl", "->", "h", "=", "ctl", "->", "minh", ";", "}", "_libaroma_window_measure_save", "(", "NULL", ",", "ctl", ")", ";", "if", "(", "ctl", "->", "handler", "->", "message", ")", "{", "LIBAROMA_MSG", "_msg", ";", "ctl", "->", "handler", "->", "message", "(", "ctl", ",", "libaroma_wm_compose", "(", "&", "_msg", ",", "LIBAROMA_MSG_WIN_MEASURED", ",", "NULL", ",", "0", ",", "0", ")", ")", ";", "return", "1", ";", "}", "}", "return", "0", ";", "}" ]
Function : libaroma_window_measure Return Value: byte Descriptions: measure control size
[ "Function", ":", "libaroma_window_measure", "Return", "Value", ":", "byte", "Descriptions", ":", "measure", "control", "size" ]
[]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "ctl", "type": "LIBAROMA_CONTROLP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctl", "type": "LIBAROMA_CONTROLP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_attach
LIBAROMA_CONTROLP
LIBAROMA_CONTROLP libaroma_window_attach( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl){ /* attach into window */ if (win){ if (libaroma_window_add(win,ctl)){ return ctl; } ALOGW("window_attach cannot attach into window"); libaroma_control_free(ctl); return NULL; } return ctl; }
/* * Function : libaroma_window_attach * Return Value: LIBAROMA_CONTROLP * Descriptions: attach control into window */
Function : libaroma_window_attach Return Value: LIBAROMA_CONTROLP Descriptions: attach control into window
[ "Function", ":", "libaroma_window_attach", "Return", "Value", ":", "LIBAROMA_CONTROLP", "Descriptions", ":", "attach", "control", "into", "window" ]
LIBAROMA_CONTROLP libaroma_window_attach( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl){ if (win){ if (libaroma_window_add(win,ctl)){ return ctl; } ALOGW("window_attach cannot attach into window"); libaroma_control_free(ctl); return NULL; } return ctl; }
[ "LIBAROMA_CONTROLP", "libaroma_window_attach", "(", "LIBAROMA_WINDOWP", "win", ",", "LIBAROMA_CONTROLP", "ctl", ")", "{", "if", "(", "win", ")", "{", "if", "(", "libaroma_window_add", "(", "win", ",", "ctl", ")", ")", "{", "return", "ctl", ";", "}", "ALOGW", "(", "\"", "\"", ")", ";", "libaroma_control_free", "(", "ctl", ")", ";", "return", "NULL", ";", "}", "return", "ctl", ";", "}" ]
Function : libaroma_window_attach Return Value: LIBAROMA_CONTROLP Descriptions: attach control into window
[ "Function", ":", "libaroma_window_attach", "Return", "Value", ":", "LIBAROMA_CONTROLP", "Descriptions", ":", "attach", "control", "into", "window" ]
[ "/* attach into window */" ]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "ctl", "type": "LIBAROMA_CONTROLP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctl", "type": "LIBAROMA_CONTROLP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_getid
LIBAROMA_CONTROLP
LIBAROMA_CONTROLP libaroma_window_getid( LIBAROMA_WINDOWP win, word id){ __CHECK_WM(NULL); if (win==NULL){ ALOGW("window_control_id win is null"); return NULL; } int i; for (i=0;i<win->childn;i++){ if (win->childs[i]->id==id){ return win->childs[i]; } } return NULL; /* not found */ }
/* * Function : libaroma_window_getid * Return Value: LIBAROMA_CONTROLP * Descriptions: get control by id */
Function : libaroma_window_getid Return Value: LIBAROMA_CONTROLP Descriptions: get control by id
[ "Function", ":", "libaroma_window_getid", "Return", "Value", ":", "LIBAROMA_CONTROLP", "Descriptions", ":", "get", "control", "by", "id" ]
LIBAROMA_CONTROLP libaroma_window_getid( LIBAROMA_WINDOWP win, word id){ __CHECK_WM(NULL); if (win==NULL){ ALOGW("window_control_id win is null"); return NULL; } int i; for (i=0;i<win->childn;i++){ if (win->childs[i]->id==id){ return win->childs[i]; } } return NULL; }
[ "LIBAROMA_CONTROLP", "libaroma_window_getid", "(", "LIBAROMA_WINDOWP", "win", ",", "word", "id", ")", "{", "__CHECK_WM", "(", "NULL", ")", ";", "if", "(", "win", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "NULL", ";", "}", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "win", "->", "childn", ";", "i", "++", ")", "{", "if", "(", "win", "->", "childs", "[", "i", "]", "->", "id", "==", "id", ")", "{", "return", "win", "->", "childs", "[", "i", "]", ";", "}", "}", "return", "NULL", ";", "}" ]
Function : libaroma_window_getid Return Value: LIBAROMA_CONTROLP Descriptions: get control by id
[ "Function", ":", "libaroma_window_getid", "Return", "Value", ":", "LIBAROMA_CONTROLP", "Descriptions", ":", "get", "control", "by", "id" ]
[ "/* not found */" ]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "id", "type": "word" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "id", "type": "word", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_setfocus
LIBAROMA_CONTROLP
LIBAROMA_CONTROLP libaroma_window_setfocus( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl){ if (win==NULL){ ALOGW("window_setfocus window is null"); return NULL; } if (ctl!=NULL){ /* set */ if (win!=ctl->window){ ALOGW("window_setfocus control is not window child"); return NULL; } if (ctl->handler->focus!=NULL){ if (win->focused==ctl){ return ctl; } if (ctl->handler->focus(ctl,1)){ if (win->focused){ win->focused->handler->focus(win->focused,0); } win->focused=ctl; return ctl; } } return NULL; } else{ /* find focus */ if (win->focused){ return win->focused; } int i; for (i=0;i<win->childn;i++){ if (win->childs[i]->handler->focus!=NULL){ return libaroma_window_setfocus(win,win->childs[i]); } } } return NULL; }
/* * Function : libaroma_window_setfocus * Return Value: LIBAROMA_CONTROLP * Descriptions: set control focus */
Function : libaroma_window_setfocus Return Value: LIBAROMA_CONTROLP Descriptions: set control focus
[ "Function", ":", "libaroma_window_setfocus", "Return", "Value", ":", "LIBAROMA_CONTROLP", "Descriptions", ":", "set", "control", "focus" ]
LIBAROMA_CONTROLP libaroma_window_setfocus( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl){ if (win==NULL){ ALOGW("window_setfocus window is null"); return NULL; } if (ctl!=NULL){ if (win!=ctl->window){ ALOGW("window_setfocus control is not window child"); return NULL; } if (ctl->handler->focus!=NULL){ if (win->focused==ctl){ return ctl; } if (ctl->handler->focus(ctl,1)){ if (win->focused){ win->focused->handler->focus(win->focused,0); } win->focused=ctl; return ctl; } } return NULL; } else{ if (win->focused){ return win->focused; } int i; for (i=0;i<win->childn;i++){ if (win->childs[i]->handler->focus!=NULL){ return libaroma_window_setfocus(win,win->childs[i]); } } } return NULL; }
[ "LIBAROMA_CONTROLP", "libaroma_window_setfocus", "(", "LIBAROMA_WINDOWP", "win", ",", "LIBAROMA_CONTROLP", "ctl", ")", "{", "if", "(", "win", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "NULL", ";", "}", "if", "(", "ctl", "!=", "NULL", ")", "{", "if", "(", "win", "!=", "ctl", "->", "window", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "NULL", ";", "}", "if", "(", "ctl", "->", "handler", "->", "focus", "!=", "NULL", ")", "{", "if", "(", "win", "->", "focused", "==", "ctl", ")", "{", "return", "ctl", ";", "}", "if", "(", "ctl", "->", "handler", "->", "focus", "(", "ctl", ",", "1", ")", ")", "{", "if", "(", "win", "->", "focused", ")", "{", "win", "->", "focused", "->", "handler", "->", "focus", "(", "win", "->", "focused", ",", "0", ")", ";", "}", "win", "->", "focused", "=", "ctl", ";", "return", "ctl", ";", "}", "}", "return", "NULL", ";", "}", "else", "{", "if", "(", "win", "->", "focused", ")", "{", "return", "win", "->", "focused", ";", "}", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "win", "->", "childn", ";", "i", "++", ")", "{", "if", "(", "win", "->", "childs", "[", "i", "]", "->", "handler", "->", "focus", "!=", "NULL", ")", "{", "return", "libaroma_window_setfocus", "(", "win", ",", "win", "->", "childs", "[", "i", "]", ")", ";", "}", "}", "}", "return", "NULL", ";", "}" ]
Function : libaroma_window_setfocus Return Value: LIBAROMA_CONTROLP Descriptions: set control focus
[ "Function", ":", "libaroma_window_setfocus", "Return", "Value", ":", "LIBAROMA_CONTROLP", "Descriptions", ":", "set", "control", "focus" ]
[ "/* set */", "/* find focus */" ]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "ctl", "type": "LIBAROMA_CONTROLP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctl", "type": "LIBAROMA_CONTROLP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_sync
byte
byte libaroma_window_sync(LIBAROMA_WINDOWP win, int x, int y, int w, int h){ __CHECK_WM(0); if (win==NULL){ ALOGW("libaroma_window_sync win is null"); return 0; } if (win->handler!=NULL){ if (win->handler->sync!=NULL){ return win->handler->sync(win,x,y,w,h); } } if (win->parent!=NULL){ return 0; } if (!win->lock_sync){ if (!libaroma_window_isactive(win)){ ALOGW("libaroma_window_sync win is not active window"); return 0; } if (win->dc==NULL){ ALOGW("window_invalidate dc is null"); return 0; } /* sync workspace */ libaroma_wm_sync(win->x+x,win->y+y,w,h); } return 1; }
/* * Function : libaroma_window_sync * Return Value: byte * Descriptions: sync window canvas */
Function : libaroma_window_sync Return Value: byte Descriptions: sync window canvas
[ "Function", ":", "libaroma_window_sync", "Return", "Value", ":", "byte", "Descriptions", ":", "sync", "window", "canvas" ]
byte libaroma_window_sync(LIBAROMA_WINDOWP win, int x, int y, int w, int h){ __CHECK_WM(0); if (win==NULL){ ALOGW("libaroma_window_sync win is null"); return 0; } if (win->handler!=NULL){ if (win->handler->sync!=NULL){ return win->handler->sync(win,x,y,w,h); } } if (win->parent!=NULL){ return 0; } if (!win->lock_sync){ if (!libaroma_window_isactive(win)){ ALOGW("libaroma_window_sync win is not active window"); return 0; } if (win->dc==NULL){ ALOGW("window_invalidate dc is null"); return 0; } libaroma_wm_sync(win->x+x,win->y+y,w,h); } return 1; }
[ "byte", "libaroma_window_sync", "(", "LIBAROMA_WINDOWP", "win", ",", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "__CHECK_WM", "(", "0", ")", ";", "if", "(", "win", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "win", "->", "handler", "!=", "NULL", ")", "{", "if", "(", "win", "->", "handler", "->", "sync", "!=", "NULL", ")", "{", "return", "win", "->", "handler", "->", "sync", "(", "win", ",", "x", ",", "y", ",", "w", ",", "h", ")", ";", "}", "}", "if", "(", "win", "->", "parent", "!=", "NULL", ")", "{", "return", "0", ";", "}", "if", "(", "!", "win", "->", "lock_sync", ")", "{", "if", "(", "!", "libaroma_window_isactive", "(", "win", ")", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "win", "->", "dc", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "libaroma_wm_sync", "(", "win", "->", "x", "+", "x", ",", "win", "->", "y", "+", "y", ",", "w", ",", "h", ")", ";", "}", "return", "1", ";", "}" ]
Function : libaroma_window_sync Return Value: byte Descriptions: sync window canvas
[ "Function", ":", "libaroma_window_sync", "Return", "Value", ":", "byte", "Descriptions", ":", "sync", "window", "canvas" ]
[ "/* sync workspace */" ]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "x", "type": "int" }, { "param": "y", "type": "int" }, { "param": "w", "type": "int" }, { "param": "h", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "w", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "h", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_invalidate
byte
byte libaroma_window_invalidate(LIBAROMA_WINDOWP win, byte sync){ __CHECK_WM(0); if (win==NULL){ ALOGW("window_invalidate win is null"); return 0; } if (win->handler!=NULL){ if (win->handler->invalidate!=NULL){ return win->handler->invalidate(win,sync); } } if (win->parent!=NULL){ return 0; } if (!libaroma_window_isactive(win)){ ALOGW("window_invalidate win is not active window"); return 0; } if (win->dc==NULL){ ALOGW("window_invalidate dc is null"); return 0; } if ((!win->lock_sync)||(sync==10)){ /* draw bg */ libaroma_draw( win->dc, win->bg, 0, 0, 1); /* draw childs */ int i; #ifdef LIBAROMA_CONFIG_OPENMP #pragma omp parallel for #endif for (i=0;i<win->childn;i++){ /* draw no sync */ libaroma_control_draw(win->childs[i], 0); } /* sync */ if (sync){ libaroma_window_sync(win, 0, 0, win->w, win->h); } } return 1; }
/* * Function : libaroma_window_invalidate * Return Value: byte * Descriptions: invalidate window drawing */
Function : libaroma_window_invalidate Return Value: byte Descriptions: invalidate window drawing
[ "Function", ":", "libaroma_window_invalidate", "Return", "Value", ":", "byte", "Descriptions", ":", "invalidate", "window", "drawing" ]
byte libaroma_window_invalidate(LIBAROMA_WINDOWP win, byte sync){ __CHECK_WM(0); if (win==NULL){ ALOGW("window_invalidate win is null"); return 0; } if (win->handler!=NULL){ if (win->handler->invalidate!=NULL){ return win->handler->invalidate(win,sync); } } if (win->parent!=NULL){ return 0; } if (!libaroma_window_isactive(win)){ ALOGW("window_invalidate win is not active window"); return 0; } if (win->dc==NULL){ ALOGW("window_invalidate dc is null"); return 0; } if ((!win->lock_sync)||(sync==10)){ libaroma_draw( win->dc, win->bg, 0, 0, 1); int i; #ifdef LIBAROMA_CONFIG_OPENMP #pragma omp parallel for #endif for (i=0;i<win->childn;i++){ libaroma_control_draw(win->childs[i], 0); } if (sync){ libaroma_window_sync(win, 0, 0, win->w, win->h); } } return 1; }
[ "byte", "libaroma_window_invalidate", "(", "LIBAROMA_WINDOWP", "win", ",", "byte", "sync", ")", "{", "__CHECK_WM", "(", "0", ")", ";", "if", "(", "win", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "win", "->", "handler", "!=", "NULL", ")", "{", "if", "(", "win", "->", "handler", "->", "invalidate", "!=", "NULL", ")", "{", "return", "win", "->", "handler", "->", "invalidate", "(", "win", ",", "sync", ")", ";", "}", "}", "if", "(", "win", "->", "parent", "!=", "NULL", ")", "{", "return", "0", ";", "}", "if", "(", "!", "libaroma_window_isactive", "(", "win", ")", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "win", "->", "dc", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "(", "!", "win", "->", "lock_sync", ")", "||", "(", "sync", "==", "10", ")", ")", "{", "libaroma_draw", "(", "win", "->", "dc", ",", "win", "->", "bg", ",", "0", ",", "0", ",", "1", ")", ";", "int", "i", ";", "#ifdef", "LIBAROMA_CONFIG_OPENMP", "#pragma", " omp parallel for", "\n", "#endif", "for", "(", "i", "=", "0", ";", "i", "<", "win", "->", "childn", ";", "i", "++", ")", "{", "libaroma_control_draw", "(", "win", "->", "childs", "[", "i", "]", ",", "0", ")", ";", "}", "if", "(", "sync", ")", "{", "libaroma_window_sync", "(", "win", ",", "0", ",", "0", ",", "win", "->", "w", ",", "win", "->", "h", ")", ";", "}", "}", "return", "1", ";", "}" ]
Function : libaroma_window_invalidate Return Value: byte Descriptions: invalidate window drawing
[ "Function", ":", "libaroma_window_invalidate", "Return", "Value", ":", "byte", "Descriptions", ":", "invalidate", "window", "drawing" ]
[ "/* draw bg */", "/* draw childs */", "/* draw no sync */", "/* sync */" ]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "sync", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sync", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_calculate_pos
void
void libaroma_window_calculate_pos( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl, int * x, int * y ){ if (win!=NULL){ *x-=win->x; *y-=win->y; } else if ((ctl!=NULL)&&(ctl->window!=NULL)){ *x-=ctl->window->x; *y-=ctl->window->y; } if (ctl!=NULL){ *x-=ctl->x; *y-=ctl->y; } /* *x-=libaroma_wm()->x; *y-=libaroma_wm()->y; */ }
/* * Function : libaroma_window_calculate_pos * Return Value: void * Descriptions: calculate screen position to window/control position */
Function : libaroma_window_calculate_pos Return Value: void Descriptions: calculate screen position to window/control position
[ "Function", ":", "libaroma_window_calculate_pos", "Return", "Value", ":", "void", "Descriptions", ":", "calculate", "screen", "position", "to", "window", "/", "control", "position" ]
void libaroma_window_calculate_pos( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl, int * x, int * y ){ if (win!=NULL){ *x-=win->x; *y-=win->y; } else if ((ctl!=NULL)&&(ctl->window!=NULL)){ *x-=ctl->window->x; *y-=ctl->window->y; } if (ctl!=NULL){ *x-=ctl->x; *y-=ctl->y; } }
[ "void", "libaroma_window_calculate_pos", "(", "LIBAROMA_WINDOWP", "win", ",", "LIBAROMA_CONTROLP", "ctl", ",", "int", "*", "x", ",", "int", "*", "y", ")", "{", "if", "(", "win", "!=", "NULL", ")", "{", "*", "x", "-=", "win", "->", "x", ";", "*", "y", "-=", "win", "->", "y", ";", "}", "else", "if", "(", "(", "ctl", "!=", "NULL", ")", "&&", "(", "ctl", "->", "window", "!=", "NULL", ")", ")", "{", "*", "x", "-=", "ctl", "->", "window", "->", "x", ";", "*", "y", "-=", "ctl", "->", "window", "->", "y", ";", "}", "if", "(", "ctl", "!=", "NULL", ")", "{", "*", "x", "-=", "ctl", "->", "x", ";", "*", "y", "-=", "ctl", "->", "y", ";", "}", "}" ]
Function : libaroma_window_calculate_pos Return Value: void Descriptions: calculate screen position to window/control position
[ "Function", ":", "libaroma_window_calculate_pos", "Return", "Value", ":", "void", "Descriptions", ":", "calculate", "screen", "position", "to", "window", "/", "control", "position" ]
[ "/*\n\t*x-=libaroma_wm()->x;\n\t*y-=libaroma_wm()->y;\n\t*/" ]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "ctl", "type": "LIBAROMA_CONTROLP" }, { "param": "x", "type": "int" }, { "param": "y", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctl", "type": "LIBAROMA_CONTROLP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_calculate_pos_abs
void
void libaroma_window_calculate_pos_abs( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl, int * x, int * y ){ if (ctl!=NULL){ *x-=ctl->x; *y-=ctl->y; win=ctl->window; } while (win!=NULL){ *x-=win->ax; *y-=win->ay; win=win->parent; } }
/* * Function : libaroma_window_calculate_pos_abs * Return Value: void * Descriptions: calculate absolute screen position to top window position */
Function : libaroma_window_calculate_pos_abs Return Value: void Descriptions: calculate absolute screen position to top window position
[ "Function", ":", "libaroma_window_calculate_pos_abs", "Return", "Value", ":", "void", "Descriptions", ":", "calculate", "absolute", "screen", "position", "to", "top", "window", "position" ]
void libaroma_window_calculate_pos_abs( LIBAROMA_WINDOWP win, LIBAROMA_CONTROLP ctl, int * x, int * y ){ if (ctl!=NULL){ *x-=ctl->x; *y-=ctl->y; win=ctl->window; } while (win!=NULL){ *x-=win->ax; *y-=win->ay; win=win->parent; } }
[ "void", "libaroma_window_calculate_pos_abs", "(", "LIBAROMA_WINDOWP", "win", ",", "LIBAROMA_CONTROLP", "ctl", ",", "int", "*", "x", ",", "int", "*", "y", ")", "{", "if", "(", "ctl", "!=", "NULL", ")", "{", "*", "x", "-=", "ctl", "->", "x", ";", "*", "y", "-=", "ctl", "->", "y", ";", "win", "=", "ctl", "->", "window", ";", "}", "while", "(", "win", "!=", "NULL", ")", "{", "*", "x", "-=", "win", "->", "ax", ";", "*", "y", "-=", "win", "->", "ay", ";", "win", "=", "win", "->", "parent", ";", "}", "}" ]
Function : libaroma_window_calculate_pos_abs Return Value: void Descriptions: calculate absolute screen position to top window position
[ "Function", ":", "libaroma_window_calculate_pos_abs", "Return", "Value", ":", "void", "Descriptions", ":", "calculate", "absolute", "screen", "position", "to", "top", "window", "position" ]
[]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "ctl", "type": "LIBAROMA_CONTROLP" }, { "param": "x", "type": "int" }, { "param": "y", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctl", "type": "LIBAROMA_CONTROLP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_post_command
byte
byte libaroma_window_post_command(dword cmd){ return libaroma_msg_post( LIBAROMA_MSG_WIN_DIRECTMSG, 0, 0, (int) cmd, 0, NULL ); }
/* * Function : libaroma_window_post_command * Return Value: byte * Descriptions: post direct command */
Function : libaroma_window_post_command Return Value: byte Descriptions: post direct command
[ "Function", ":", "libaroma_window_post_command", "Return", "Value", ":", "byte", "Descriptions", ":", "post", "direct", "command" ]
byte libaroma_window_post_command(dword cmd){ return libaroma_msg_post( LIBAROMA_MSG_WIN_DIRECTMSG, 0, 0, (int) cmd, 0, NULL ); }
[ "byte", "libaroma_window_post_command", "(", "dword", "cmd", ")", "{", "return", "libaroma_msg_post", "(", "LIBAROMA_MSG_WIN_DIRECTMSG", ",", "0", ",", "0", ",", "(", "int", ")", "cmd", ",", "0", ",", "NULL", ")", ";", "}" ]
Function : libaroma_window_post_command Return Value: byte Descriptions: post direct command
[ "Function", ":", "libaroma_window_post_command", "Return", "Value", ":", "byte", "Descriptions", ":", "post", "direct", "command" ]
[]
[ { "param": "cmd", "type": "dword" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "dword", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_post_command_ex
byte
byte libaroma_window_post_command_ex(dword cmd, byte state, int key, int y, voidp d){ return libaroma_msg_post( LIBAROMA_MSG_WIN_DIRECTMSG, state, key, (int) cmd, y, d ); }
/* * Function : libaroma_window_post_command_ex * Return Value: byte * Descriptions: post direct command extended */
Function : libaroma_window_post_command_ex Return Value: byte Descriptions: post direct command extended
[ "Function", ":", "libaroma_window_post_command_ex", "Return", "Value", ":", "byte", "Descriptions", ":", "post", "direct", "command", "extended" ]
byte libaroma_window_post_command_ex(dword cmd, byte state, int key, int y, voidp d){ return libaroma_msg_post( LIBAROMA_MSG_WIN_DIRECTMSG, state, key, (int) cmd, y, d ); }
[ "byte", "libaroma_window_post_command_ex", "(", "dword", "cmd", ",", "byte", "state", ",", "int", "key", ",", "int", "y", ",", "voidp", "d", ")", "{", "return", "libaroma_msg_post", "(", "LIBAROMA_MSG_WIN_DIRECTMSG", ",", "state", ",", "key", ",", "(", "int", ")", "cmd", ",", "y", ",", "d", ")", ";", "}" ]
Function : libaroma_window_post_command_ex Return Value: byte Descriptions: post direct command extended
[ "Function", ":", "libaroma_window_post_command_ex", "Return", "Value", ":", "byte", "Descriptions", ":", "post", "direct", "command", "extended" ]
[]
[ { "param": "cmd", "type": "dword" }, { "param": "state", "type": "byte" }, { "param": "key", "type": "int" }, { "param": "y", "type": "int" }, { "param": "d", "type": "voidp" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "dword", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "d", "type": "voidp", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_process_event
dword
dword libaroma_window_process_event(LIBAROMA_WINDOWP win, LIBAROMA_MSGP msg){ __CHECK_WM(0); if (win==NULL){ ALOGW("window_event win is null"); return 0; } if (win->parent!=NULL){ ALOGW("window_event cannot used for child window..."); return 0; } dword ret = 0; if (win->handler){ if (win->handler->message_hooker){ if (win->handler->message_hooker(win,msg,&ret)){ return ret; } } } switch (msg->msg){ case LIBAROMA_MSG_WIN_ACTIVE: { /* set current window size */ win->focused=NULL; win->touched=NULL; if (msg->x!=10){ _libaroma_window_ready(win); } if ((!win->lock_sync)||(msg->x==10)){ if ((!win->active)||(msg->x==10)){ int i; win->active=1; /* signal child */ for (i=0;i<win->childn;i++){ if (win->childs[i]->handler->message){ win->childs[i]->handler->message(win->childs[i], msg); } } } } } break; case LIBAROMA_MSG_WIN_RESIZE: { int i; _libaroma_window_ready(win); for (i=0;i<win->childn;i++){ if (win->childs[i]->handler->message){ win->childs[i]->handler->message(win->childs[i], msg); } } } break; case LIBAROMA_MSG_WIN_INACTIVE: { if (win->active){ /* stop thread manager */ win->active=0; /* send inactive message to child */ int i; for (i=0;i<win->childn;i++){ if (win->childs[i]->handler->message){ win->childs[i]->handler->message(win->childs[i], msg); } } win->focused=NULL; win->touched=NULL; } } break; case LIBAROMA_MSG_WIN_MEASURED: { /* remeasured all childs */ int i; for (i=0;i<win->childn;i++){ libaroma_window_measure(win,win->childs[i]); } } break; case LIBAROMA_MSG_WIN_DIRECTMSG: { return (dword) msg->x; } break; case LIBAROMA_MSG_WIN_INVALIDATE: { libaroma_window_invalidate(win, 1); } break; case LIBAROMA_MSG_TOUCH: { /* touch handler */ if (msg->state==LIBAROMA_HID_EV_STATE_DOWN){ win->touched = NULL; int x = msg->x; int y = msg->y; libaroma_window_calculate_pos(win,NULL,&x,&y); int i; for (i=0;i<win->childn;i++){ if (_libaroma_window_is_inside(win->childs[i],x,y)){ win->touched = win->childs[i]; break; } } if (win->touched!=NULL){ if (win->touched->handler->message){ ret=win->touched->handler->message(win->touched, msg); } } } else if (win->touched!=NULL){ if (msg->state==LIBAROMA_HID_EV_STATE_MOVE){ if (win->touched->handler->message){ ret=win->touched->handler->message(win->touched, msg); } } else if (msg->state==LIBAROMA_HID_EV_STATE_UP){ if (win->touched->handler->message){ ret=win->touched->handler->message(win->touched, msg); } win->touched=NULL; } } } break; } return ret; }
/* * Function : libaroma_window_process_event * Return Value: dword * Descriptions: process message */
Function : libaroma_window_process_event Return Value: dword Descriptions: process message
[ "Function", ":", "libaroma_window_process_event", "Return", "Value", ":", "dword", "Descriptions", ":", "process", "message" ]
dword libaroma_window_process_event(LIBAROMA_WINDOWP win, LIBAROMA_MSGP msg){ __CHECK_WM(0); if (win==NULL){ ALOGW("window_event win is null"); return 0; } if (win->parent!=NULL){ ALOGW("window_event cannot used for child window..."); return 0; } dword ret = 0; if (win->handler){ if (win->handler->message_hooker){ if (win->handler->message_hooker(win,msg,&ret)){ return ret; } } } switch (msg->msg){ case LIBAROMA_MSG_WIN_ACTIVE: { win->focused=NULL; win->touched=NULL; if (msg->x!=10){ _libaroma_window_ready(win); } if ((!win->lock_sync)||(msg->x==10)){ if ((!win->active)||(msg->x==10)){ int i; win->active=1; for (i=0;i<win->childn;i++){ if (win->childs[i]->handler->message){ win->childs[i]->handler->message(win->childs[i], msg); } } } } } break; case LIBAROMA_MSG_WIN_RESIZE: { int i; _libaroma_window_ready(win); for (i=0;i<win->childn;i++){ if (win->childs[i]->handler->message){ win->childs[i]->handler->message(win->childs[i], msg); } } } break; case LIBAROMA_MSG_WIN_INACTIVE: { if (win->active){ win->active=0; int i; for (i=0;i<win->childn;i++){ if (win->childs[i]->handler->message){ win->childs[i]->handler->message(win->childs[i], msg); } } win->focused=NULL; win->touched=NULL; } } break; case LIBAROMA_MSG_WIN_MEASURED: { int i; for (i=0;i<win->childn;i++){ libaroma_window_measure(win,win->childs[i]); } } break; case LIBAROMA_MSG_WIN_DIRECTMSG: { return (dword) msg->x; } break; case LIBAROMA_MSG_WIN_INVALIDATE: { libaroma_window_invalidate(win, 1); } break; case LIBAROMA_MSG_TOUCH: { if (msg->state==LIBAROMA_HID_EV_STATE_DOWN){ win->touched = NULL; int x = msg->x; int y = msg->y; libaroma_window_calculate_pos(win,NULL,&x,&y); int i; for (i=0;i<win->childn;i++){ if (_libaroma_window_is_inside(win->childs[i],x,y)){ win->touched = win->childs[i]; break; } } if (win->touched!=NULL){ if (win->touched->handler->message){ ret=win->touched->handler->message(win->touched, msg); } } } else if (win->touched!=NULL){ if (msg->state==LIBAROMA_HID_EV_STATE_MOVE){ if (win->touched->handler->message){ ret=win->touched->handler->message(win->touched, msg); } } else if (msg->state==LIBAROMA_HID_EV_STATE_UP){ if (win->touched->handler->message){ ret=win->touched->handler->message(win->touched, msg); } win->touched=NULL; } } } break; } return ret; }
[ "dword", "libaroma_window_process_event", "(", "LIBAROMA_WINDOWP", "win", ",", "LIBAROMA_MSGP", "msg", ")", "{", "__CHECK_WM", "(", "0", ")", ";", "if", "(", "win", "==", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "if", "(", "win", "->", "parent", "!=", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "dword", "ret", "=", "0", ";", "if", "(", "win", "->", "handler", ")", "{", "if", "(", "win", "->", "handler", "->", "message_hooker", ")", "{", "if", "(", "win", "->", "handler", "->", "message_hooker", "(", "win", ",", "msg", ",", "&", "ret", ")", ")", "{", "return", "ret", ";", "}", "}", "}", "switch", "(", "msg", "->", "msg", ")", "{", "case", "LIBAROMA_MSG_WIN_ACTIVE", ":", "{", "win", "->", "focused", "=", "NULL", ";", "win", "->", "touched", "=", "NULL", ";", "if", "(", "msg", "->", "x", "!=", "10", ")", "{", "_libaroma_window_ready", "(", "win", ")", ";", "}", "if", "(", "(", "!", "win", "->", "lock_sync", ")", "||", "(", "msg", "->", "x", "==", "10", ")", ")", "{", "if", "(", "(", "!", "win", "->", "active", ")", "||", "(", "msg", "->", "x", "==", "10", ")", ")", "{", "int", "i", ";", "win", "->", "active", "=", "1", ";", "for", "(", "i", "=", "0", ";", "i", "<", "win", "->", "childn", ";", "i", "++", ")", "{", "if", "(", "win", "->", "childs", "[", "i", "]", "->", "handler", "->", "message", ")", "{", "win", "->", "childs", "[", "i", "]", "->", "handler", "->", "message", "(", "win", "->", "childs", "[", "i", "]", ",", "msg", ")", ";", "}", "}", "}", "}", "}", "break", ";", "case", "LIBAROMA_MSG_WIN_RESIZE", ":", "{", "int", "i", ";", "_libaroma_window_ready", "(", "win", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "win", "->", "childn", ";", "i", "++", ")", "{", "if", "(", "win", "->", "childs", "[", "i", "]", "->", "handler", "->", "message", ")", "{", "win", "->", "childs", "[", "i", "]", "->", "handler", "->", "message", "(", "win", "->", "childs", "[", "i", "]", ",", "msg", ")", ";", "}", "}", "}", "break", ";", "case", "LIBAROMA_MSG_WIN_INACTIVE", ":", "{", "if", "(", "win", "->", "active", ")", "{", "win", "->", "active", "=", "0", ";", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "win", "->", "childn", ";", "i", "++", ")", "{", "if", "(", "win", "->", "childs", "[", "i", "]", "->", "handler", "->", "message", ")", "{", "win", "->", "childs", "[", "i", "]", "->", "handler", "->", "message", "(", "win", "->", "childs", "[", "i", "]", ",", "msg", ")", ";", "}", "}", "win", "->", "focused", "=", "NULL", ";", "win", "->", "touched", "=", "NULL", ";", "}", "}", "break", ";", "case", "LIBAROMA_MSG_WIN_MEASURED", ":", "{", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "win", "->", "childn", ";", "i", "++", ")", "{", "libaroma_window_measure", "(", "win", ",", "win", "->", "childs", "[", "i", "]", ")", ";", "}", "}", "break", ";", "case", "LIBAROMA_MSG_WIN_DIRECTMSG", ":", "{", "return", "(", "dword", ")", "msg", "->", "x", ";", "}", "break", ";", "case", "LIBAROMA_MSG_WIN_INVALIDATE", ":", "{", "libaroma_window_invalidate", "(", "win", ",", "1", ")", ";", "}", "break", ";", "case", "LIBAROMA_MSG_TOUCH", ":", "{", "if", "(", "msg", "->", "state", "==", "LIBAROMA_HID_EV_STATE_DOWN", ")", "{", "win", "->", "touched", "=", "NULL", ";", "int", "x", "=", "msg", "->", "x", ";", "int", "y", "=", "msg", "->", "y", ";", "libaroma_window_calculate_pos", "(", "win", ",", "NULL", ",", "&", "x", ",", "&", "y", ")", ";", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "win", "->", "childn", ";", "i", "++", ")", "{", "if", "(", "_libaroma_window_is_inside", "(", "win", "->", "childs", "[", "i", "]", ",", "x", ",", "y", ")", ")", "{", "win", "->", "touched", "=", "win", "->", "childs", "[", "i", "]", ";", "break", ";", "}", "}", "if", "(", "win", "->", "touched", "!=", "NULL", ")", "{", "if", "(", "win", "->", "touched", "->", "handler", "->", "message", ")", "{", "ret", "=", "win", "->", "touched", "->", "handler", "->", "message", "(", "win", "->", "touched", ",", "msg", ")", ";", "}", "}", "}", "else", "if", "(", "win", "->", "touched", "!=", "NULL", ")", "{", "if", "(", "msg", "->", "state", "==", "LIBAROMA_HID_EV_STATE_MOVE", ")", "{", "if", "(", "win", "->", "touched", "->", "handler", "->", "message", ")", "{", "ret", "=", "win", "->", "touched", "->", "handler", "->", "message", "(", "win", "->", "touched", ",", "msg", ")", ";", "}", "}", "else", "if", "(", "msg", "->", "state", "==", "LIBAROMA_HID_EV_STATE_UP", ")", "{", "if", "(", "win", "->", "touched", "->", "handler", "->", "message", ")", "{", "ret", "=", "win", "->", "touched", "->", "handler", "->", "message", "(", "win", "->", "touched", ",", "msg", ")", ";", "}", "win", "->", "touched", "=", "NULL", ";", "}", "}", "}", "break", ";", "}", "return", "ret", ";", "}" ]
Function : libaroma_window_process_event Return Value: dword Descriptions: process message
[ "Function", ":", "libaroma_window_process_event", "Return", "Value", ":", "dword", "Descriptions", ":", "process", "message" ]
[ "/* set current window size */", "/* signal child */", "/* stop thread manager */", "/* send inactive message to child */", "/* remeasured all childs */", "/* touch handler */" ]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "msg", "type": "LIBAROMA_MSGP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "msg", "type": "LIBAROMA_MSGP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a9b176e43374e8a22658992534157c241afa6e07
MLXProjects/libaroma
src/aroma/ui/window.c
[ "Apache-2.0" ]
C
libaroma_window_pool
dword
dword libaroma_window_pool( LIBAROMA_WINDOWP win, LIBAROMA_MSGP msg){ if (!win){ return 0; } if (win->parent!=NULL){ ALOGW("cannot pool child window..."); return 0; } LIBAROMA_MSG _msg; LIBAROMA_MSGP cmsg=(msg!=NULL)?msg:&_msg; byte ret = libaroma_wm_getmessage(cmsg); if (ret){ return libaroma_window_process_event(win,cmsg); } return 0; }
/* * Function : libaroma_window_pool * Return Value: dword * Descriptions: poll window messages */
Function : libaroma_window_pool Return Value: dword Descriptions: poll window messages
[ "Function", ":", "libaroma_window_pool", "Return", "Value", ":", "dword", "Descriptions", ":", "poll", "window", "messages" ]
dword libaroma_window_pool( LIBAROMA_WINDOWP win, LIBAROMA_MSGP msg){ if (!win){ return 0; } if (win->parent!=NULL){ ALOGW("cannot pool child window..."); return 0; } LIBAROMA_MSG _msg; LIBAROMA_MSGP cmsg=(msg!=NULL)?msg:&_msg; byte ret = libaroma_wm_getmessage(cmsg); if (ret){ return libaroma_window_process_event(win,cmsg); } return 0; }
[ "dword", "libaroma_window_pool", "(", "LIBAROMA_WINDOWP", "win", ",", "LIBAROMA_MSGP", "msg", ")", "{", "if", "(", "!", "win", ")", "{", "return", "0", ";", "}", "if", "(", "win", "->", "parent", "!=", "NULL", ")", "{", "ALOGW", "(", "\"", "\"", ")", ";", "return", "0", ";", "}", "LIBAROMA_MSG", "_msg", ";", "LIBAROMA_MSGP", "cmsg", "=", "(", "msg", "!=", "NULL", ")", "?", "msg", ":", "&", "_msg", ";", "byte", "ret", "=", "libaroma_wm_getmessage", "(", "cmsg", ")", ";", "if", "(", "ret", ")", "{", "return", "libaroma_window_process_event", "(", "win", ",", "cmsg", ")", ";", "}", "return", "0", ";", "}" ]
Function : libaroma_window_pool Return Value: dword Descriptions: poll window messages
[ "Function", ":", "libaroma_window_pool", "Return", "Value", ":", "dword", "Descriptions", ":", "poll", "window", "messages" ]
[]
[ { "param": "win", "type": "LIBAROMA_WINDOWP" }, { "param": "msg", "type": "LIBAROMA_MSGP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "win", "type": "LIBAROMA_WINDOWP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "msg", "type": "LIBAROMA_MSGP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
416d4d12ca8acc0c6919feb4fada84ad9f466996
MLXProjects/libaroma
src/aroma/controls/listitem/listitem_check.c
[ "Apache-2.0" ]
C
libaroma_listitem_isoption
byte
byte libaroma_listitem_isoption( LIBAROMA_CTL_LIST_ITEMP item ){ if (item->handler!=&_libaroma_listitem_check_handler){ return 0; } if (item->flags&LIBAROMA_LISTITEM_CHECK_OPTION){ return 1; } return 0; }
/* * Function : libaroma_listitem_isoption * Return Value: byte * Descriptions: check if item is option checkbox */
Function : libaroma_listitem_isoption Return Value: byte Descriptions: check if item is option checkbox
[ "Function", ":", "libaroma_listitem_isoption", "Return", "Value", ":", "byte", "Descriptions", ":", "check", "if", "item", "is", "option", "checkbox" ]
byte libaroma_listitem_isoption( LIBAROMA_CTL_LIST_ITEMP item ){ if (item->handler!=&_libaroma_listitem_check_handler){ return 0; } if (item->flags&LIBAROMA_LISTITEM_CHECK_OPTION){ return 1; } return 0; }
[ "byte", "libaroma_listitem_isoption", "(", "LIBAROMA_CTL_LIST_ITEMP", "item", ")", "{", "if", "(", "item", "->", "handler", "!=", "&", "_libaroma_listitem_check_handler", ")", "{", "return", "0", ";", "}", "if", "(", "item", "->", "flags", "&", "LIBAROMA_LISTITEM_CHECK_OPTION", ")", "{", "return", "1", ";", "}", "return", "0", ";", "}" ]
Function : libaroma_listitem_isoption Return Value: byte Descriptions: check if item is option checkbox
[ "Function", ":", "libaroma_listitem_isoption", "Return", "Value", ":", "byte", "Descriptions", ":", "check", "if", "item", "is", "option", "checkbox" ]
[]
[ { "param": "item", "type": "LIBAROMA_CTL_LIST_ITEMP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "item", "type": "LIBAROMA_CTL_LIST_ITEMP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }