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
78a7579820d1de8b0917328de4b4222ed16b8199
mcai/Archimulator
tools/cross_compiler/mips-unknown-linux-gnu/mips-unknown-linux-gnu/sys-include/asm/mmu_context.h
[ "MIT" ]
C
init_new_context
int
static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm) { int i; for (i = 0; i < num_online_cpus(); i++) cpu_context(i, mm) = 0; return 0; }
/* * Initialize the context related info for a new mm_struct * instance. */
Initialize the context related info for a new mm_struct instance.
[ "Initialize", "the", "context", "related", "info", "for", "a", "new", "mm_struct", "instance", "." ]
static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm) { int i; for (i = 0; i < num_online_cpus(); i++) cpu_context(i, mm) = 0; return 0; }
[ "static", "inline", "int", "init_new_context", "(", "struct", "task_struct", "*", "tsk", ",", "struct", "mm_struct", "*", "mm", ")", "{", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "num_online_cpus", "(", ")", ";", "i", "++", ")", "cpu_context", "(", "i", ",", "mm", ")", "=", "0", ";", "return", "0", ";", "}" ]
Initialize the context related info for a new mm_struct instance.
[ "Initialize", "the", "context", "related", "info", "for", "a", "new", "mm_struct", "instance", "." ]
[]
[ { "param": "tsk", "type": "struct task_struct" }, { "param": "mm", "type": "struct mm_struct" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tsk", "type": "struct task_struct", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mm", "type": "struct mm_struct", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
78a7579820d1de8b0917328de4b4222ed16b8199
mcai/Archimulator
tools/cross_compiler/mips-unknown-linux-gnu/mips-unknown-linux-gnu/sys-include/asm/mmu_context.h
[ "MIT" ]
C
activate_mm
void
static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next) { unsigned long flags; unsigned int cpu = smp_processor_id(); local_irq_save(flags); /* Unconditionally get a new ASID. */ get_new_mmu_context(next, cpu); write_c0_entryhi(cpu_context(cpu, next)); TLBMISS_HANDLER_SETUP_PGD(next->pgd); /* mark mmu ownership change */ cpu_clear(cpu, prev->cpu_vm_mask); cpu_set(cpu, next->cpu_vm_mask); local_irq_restore(flags); }
/* * After we have set current->mm to a new value, this activates * the context for the new mm so we see the new mappings. */
After we have set current->mm to a new value, this activates the context for the new mm so we see the new mappings.
[ "After", "we", "have", "set", "current", "-", ">", "mm", "to", "a", "new", "value", "this", "activates", "the", "context", "for", "the", "new", "mm", "so", "we", "see", "the", "new", "mappings", "." ]
static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next) { unsigned long flags; unsigned int cpu = smp_processor_id(); local_irq_save(flags); get_new_mmu_context(next, cpu); write_c0_entryhi(cpu_context(cpu, next)); TLBMISS_HANDLER_SETUP_PGD(next->pgd); cpu_clear(cpu, prev->cpu_vm_mask); cpu_set(cpu, next->cpu_vm_mask); local_irq_restore(flags); }
[ "static", "inline", "void", "activate_mm", "(", "struct", "mm_struct", "*", "prev", ",", "struct", "mm_struct", "*", "next", ")", "{", "unsigned", "long", "flags", ";", "unsigned", "int", "cpu", "=", "smp_processor_id", "(", ")", ";", "local_irq_save", "(", "flags", ")", ";", "get_new_mmu_context", "(", "next", ",", "cpu", ")", ";", "write_c0_entryhi", "(", "cpu_context", "(", "cpu", ",", "next", ")", ")", ";", "TLBMISS_HANDLER_SETUP_PGD", "(", "next", "->", "pgd", ")", ";", "cpu_clear", "(", "cpu", ",", "prev", "->", "cpu_vm_mask", ")", ";", "cpu_set", "(", "cpu", ",", "next", "->", "cpu_vm_mask", ")", ";", "local_irq_restore", "(", "flags", ")", ";", "}" ]
After we have set current->mm to a new value, this activates the context for the new mm so we see the new mappings.
[ "After", "we", "have", "set", "current", "-", ">", "mm", "to", "a", "new", "value", "this", "activates", "the", "context", "for", "the", "new", "mm", "so", "we", "see", "the", "new", "mappings", "." ]
[ "/* Unconditionally get a new ASID. */", "/* mark mmu ownership change */" ]
[ { "param": "prev", "type": "struct mm_struct" }, { "param": "next", "type": "struct mm_struct" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "prev", "type": "struct mm_struct", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "next", "type": "struct mm_struct", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
78a7579820d1de8b0917328de4b4222ed16b8199
mcai/Archimulator
tools/cross_compiler/mips-unknown-linux-gnu/mips-unknown-linux-gnu/sys-include/asm/mmu_context.h
[ "MIT" ]
C
drop_mmu_context
void
static inline void drop_mmu_context(struct mm_struct *mm, unsigned cpu) { unsigned long flags; local_irq_save(flags); if (cpu_isset(cpu, mm->cpu_vm_mask)) { get_new_mmu_context(mm, cpu); write_c0_entryhi(cpu_asid(cpu, mm)); } else { /* will get a new context next time */ cpu_context(cpu, mm) = 0; } local_irq_restore(flags); }
/* * If mm is currently active_mm, we can't really drop it. Instead, * we will get a new one for it. */
If mm is currently active_mm, we can't really drop it. Instead, we will get a new one for it.
[ "If", "mm", "is", "currently", "active_mm", "we", "can", "'", "t", "really", "drop", "it", ".", "Instead", "we", "will", "get", "a", "new", "one", "for", "it", "." ]
static inline void drop_mmu_context(struct mm_struct *mm, unsigned cpu) { unsigned long flags; local_irq_save(flags); if (cpu_isset(cpu, mm->cpu_vm_mask)) { get_new_mmu_context(mm, cpu); write_c0_entryhi(cpu_asid(cpu, mm)); } else { cpu_context(cpu, mm) = 0; } local_irq_restore(flags); }
[ "static", "inline", "void", "drop_mmu_context", "(", "struct", "mm_struct", "*", "mm", ",", "unsigned", "cpu", ")", "{", "unsigned", "long", "flags", ";", "local_irq_save", "(", "flags", ")", ";", "if", "(", "cpu_isset", "(", "cpu", ",", "mm", "->", "cpu_vm_mask", ")", ")", "{", "get_new_mmu_context", "(", "mm", ",", "cpu", ")", ";", "write_c0_entryhi", "(", "cpu_asid", "(", "cpu", ",", "mm", ")", ")", ";", "}", "else", "{", "cpu_context", "(", "cpu", ",", "mm", ")", "=", "0", ";", "}", "local_irq_restore", "(", "flags", ")", ";", "}" ]
If mm is currently active_mm, we can't really drop it.
[ "If", "mm", "is", "currently", "active_mm", "we", "can", "'", "t", "really", "drop", "it", "." ]
[ "/* will get a new context next time */" ]
[ { "param": "mm", "type": "struct mm_struct" }, { "param": "cpu", "type": "unsigned" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mm", "type": "struct mm_struct", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cpu", "type": "unsigned", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b9bff8a9358e6cae3c5f3cf665b8f1eb06cb823b
mcai/Archimulator
tools/cross_compiler/mips-unknown-linux-gnu/mips-unknown-linux-gnu/sys-include/asm/pgtable-64.h
[ "MIT" ]
C
pmd_offset
pmd_t
static inline pmd_t *pmd_offset(pgd_t * dir, unsigned long address) { return (pmd_t *) pgd_page(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PMD - 1)); }
/* Find an entry in the second-level page table.. */
Find an entry in the second-level page table
[ "Find", "an", "entry", "in", "the", "second", "-", "level", "page", "table" ]
static inline pmd_t *pmd_offset(pgd_t * dir, unsigned long address) { return (pmd_t *) pgd_page(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PMD - 1)); }
[ "static", "inline", "pmd_t", "*", "pmd_offset", "(", "pgd_t", "*", "dir", ",", "unsigned", "long", "address", ")", "{", "return", "(", "pmd_t", "*", ")", "pgd_page", "(", "*", "dir", ")", "+", "(", "(", "address", ">>", "PMD_SHIFT", ")", "&", "(", "PTRS_PER_PMD", "-", "1", ")", ")", ";", "}" ]
Find an entry in the second-level page table..
[ "Find", "an", "entry", "in", "the", "second", "-", "level", "page", "table", ".." ]
[]
[ { "param": "dir", "type": "pgd_t" }, { "param": "address", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dir", "type": "pgd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ea26c728a6c683394c03fea31e640963268ffc2f
mcai/Archimulator
tools/cross_compiler/mips-unknown-linux-gnu/mips-unknown-linux-gnu/sys-include/asm/i8259.h
[ "MIT" ]
C
i8259_irq
int
static inline int i8259_irq(void) { int irq; spin_lock(&i8259A_lock); /* Perform an interrupt acknowledge cycle on controller 1. */ outb(0x0C, 0x20); /* prepare for poll */ irq = inb(0x20) & 7; if (irq == 2) { /* * Interrupt is cascaded so perform interrupt * acknowledge on controller 2. */ outb(0x0C, 0xA0); /* prepare for poll */ irq = (inb(0xA0) & 7) + 8; } if (unlikely(irq == 7)) { /* * This may be a spurious interrupt. * * Read the interrupt status register (ISR). If the most * significant bit is not set then there is no valid * interrupt. */ outb(0x0B, 0x20); /* ISR register */ if(~inb(0x20) & 0x80) irq = -1; } spin_unlock(&i8259A_lock); return irq; }
/* * Do the traditional i8259 interrupt polling thing. This is for the few * cases where no better interrupt acknowledge method is available and we * absolutely must touch the i8259. */
Do the traditional i8259 interrupt polling thing. This is for the few cases where no better interrupt acknowledge method is available and we absolutely must touch the i8259.
[ "Do", "the", "traditional", "i8259", "interrupt", "polling", "thing", ".", "This", "is", "for", "the", "few", "cases", "where", "no", "better", "interrupt", "acknowledge", "method", "is", "available", "and", "we", "absolutely", "must", "touch", "the", "i8259", "." ]
static inline int i8259_irq(void) { int irq; spin_lock(&i8259A_lock); outb(0x0C, 0x20); irq = inb(0x20) & 7; if (irq == 2) { outb(0x0C, 0xA0); irq = (inb(0xA0) & 7) + 8; } if (unlikely(irq == 7)) { outb(0x0B, 0x20); if(~inb(0x20) & 0x80) irq = -1; } spin_unlock(&i8259A_lock); return irq; }
[ "static", "inline", "int", "i8259_irq", "(", "void", ")", "{", "int", "irq", ";", "spin_lock", "(", "&", "i8259A_lock", ")", ";", "outb", "(", "0x0C", ",", "0x20", ")", ";", "irq", "=", "inb", "(", "0x20", ")", "&", "7", ";", "if", "(", "irq", "==", "2", ")", "{", "outb", "(", "0x0C", ",", "0xA0", ")", ";", "irq", "=", "(", "inb", "(", "0xA0", ")", "&", "7", ")", "+", "8", ";", "}", "if", "(", "unlikely", "(", "irq", "==", "7", ")", ")", "{", "outb", "(", "0x0B", ",", "0x20", ")", ";", "if", "(", "~", "inb", "(", "0x20", ")", "&", "0x80", ")", "irq", "=", "-1", ";", "}", "spin_unlock", "(", "&", "i8259A_lock", ")", ";", "return", "irq", ";", "}" ]
Do the traditional i8259 interrupt polling thing.
[ "Do", "the", "traditional", "i8259", "interrupt", "polling", "thing", "." ]
[ "/* Perform an interrupt acknowledge cycle on controller 1. */", "/* prepare for poll */", "/*\n\t\t * Interrupt is cascaded so perform interrupt\n\t\t * acknowledge on controller 2.\n\t\t */", "/* prepare for poll */", "/*\n\t\t * This may be a spurious interrupt.\n\t\t *\n\t\t * Read the interrupt status register (ISR). If the most\n\t\t * significant bit is not set then there is no valid\n\t\t * interrupt.\n\t\t */", "/* ISR register */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
7ac5f385adec43257a84fdee807d394c412cdc5d
mcai/Archimulator
tools/cross_compiler/mips-unknown-linux-gnu/mips-unknown-linux-gnu/sys-include/asm/io.h
[ "MIT" ]
C
check_signature
int
static inline int check_signature(char *io_addr, const unsigned char *signature, int length) { int retval = 0; do { if (readb(io_addr) != *signature) goto out; io_addr++; signature++; length--; } while (length); retval = 1; out: return retval; }
/* * check_signature - find BIOS signatures * @io_addr: mmio address to check * @signature: signature block * @length: length of signature * * Perform a signature comparison with the mmio address io_addr. This * address should have been obtained by ioremap. * Returns 1 on a match. */
check_signature - find BIOS signatures @io_addr: mmio address to check @signature: signature block @length: length of signature Perform a signature comparison with the mmio address io_addr. This address should have been obtained by ioremap. Returns 1 on a match.
[ "check_signature", "-", "find", "BIOS", "signatures", "@io_addr", ":", "mmio", "address", "to", "check", "@signature", ":", "signature", "block", "@length", ":", "length", "of", "signature", "Perform", "a", "signature", "comparison", "with", "the", "mmio", "address", "io_addr", ".", "This", "address", "should", "have", "been", "obtained", "by", "ioremap", ".", "Returns", "1", "on", "a", "match", "." ]
static inline int check_signature(char *io_addr, const unsigned char *signature, int length) { int retval = 0; do { if (readb(io_addr) != *signature) goto out; io_addr++; signature++; length--; } while (length); retval = 1; out: return retval; }
[ "static", "inline", "int", "check_signature", "(", "char", "*", "io_addr", ",", "const", "unsigned", "char", "*", "signature", ",", "int", "length", ")", "{", "int", "retval", "=", "0", ";", "do", "{", "if", "(", "readb", "(", "io_addr", ")", "!=", "*", "signature", ")", "goto", "out", ";", "io_addr", "++", ";", "signature", "++", ";", "length", "--", ";", "}", "while", "(", "length", ")", ";", "retval", "=", "1", ";", "out", ":", "return", "retval", ";", "}" ]
check_signature - find BIOS signatures @io_addr: mmio address to check @signature: signature block @length: length of signature
[ "check_signature", "-", "find", "BIOS", "signatures", "@io_addr", ":", "mmio", "address", "to", "check", "@signature", ":", "signature", "block", "@length", ":", "length", "of", "signature" ]
[]
[ { "param": "io_addr", "type": "char" }, { "param": "signature", "type": "unsigned char" }, { "param": "length", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "io_addr", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "signature", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "length", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
940ef94c4b86b50263848caa3a470fd0061e9a23
vpcola/testing
components/lmic/esphal.c
[ "Apache-2.0" ]
C
hal_pin_rst
void
void hal_pin_rst (u1_t val) { gpio_config_t io_conf; io_conf.intr_type = GPIO_PIN_INTR_DISABLE; io_conf.pin_bit_mask = (1<<lmic_pins.rst); io_conf.pull_down_en = 0; io_conf.pull_up_en = 0; if(val == 0 || val == 1) { // drive pin io_conf.mode = GPIO_MODE_OUTPUT; gpio_config(&io_conf); gpio_set_level(lmic_pins.rst, val); } else { // keep pin floating io_conf.mode = GPIO_MODE_INPUT; gpio_config(&io_conf); } }
// set radio RST pin to given value (or keep floating!)
set radio RST pin to given value (or keep floating!)
[ "set", "radio", "RST", "pin", "to", "given", "value", "(", "or", "keep", "floating!", ")" ]
void hal_pin_rst (u1_t val) { gpio_config_t io_conf; io_conf.intr_type = GPIO_PIN_INTR_DISABLE; io_conf.pin_bit_mask = (1<<lmic_pins.rst); io_conf.pull_down_en = 0; io_conf.pull_up_en = 0; if(val == 0 || val == 1) { io_conf.mode = GPIO_MODE_OUTPUT; gpio_config(&io_conf); gpio_set_level(lmic_pins.rst, val); } else { io_conf.mode = GPIO_MODE_INPUT; gpio_config(&io_conf); } }
[ "void", "hal_pin_rst", "(", "u1_t", "val", ")", "{", "gpio_config_t", "io_conf", ";", "io_conf", ".", "intr_type", "=", "GPIO_PIN_INTR_DISABLE", ";", "io_conf", ".", "pin_bit_mask", "=", "(", "1", "<<", "lmic_pins", ".", "rst", ")", ";", "io_conf", ".", "pull_down_en", "=", "0", ";", "io_conf", ".", "pull_up_en", "=", "0", ";", "if", "(", "val", "==", "0", "||", "val", "==", "1", ")", "{", "io_conf", ".", "mode", "=", "GPIO_MODE_OUTPUT", ";", "gpio_config", "(", "&", "io_conf", ")", ";", "gpio_set_level", "(", "lmic_pins", ".", "rst", ",", "val", ")", ";", "}", "else", "{", "io_conf", ".", "mode", "=", "GPIO_MODE_INPUT", ";", "gpio_config", "(", "&", "io_conf", ")", ";", "}", "}" ]
set radio RST pin to given value (or keep floating!)
[ "set", "radio", "RST", "pin", "to", "given", "value", "(", "or", "keep", "floating!", ")" ]
[ "// drive pin", "// keep pin floating" ]
[ { "param": "val", "type": "u1_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "val", "type": "u1_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
940ef94c4b86b50263848caa3a470fd0061e9a23
vpcola/testing
components/lmic/esphal.c
[ "Apache-2.0" ]
C
hal_io_check
void
void hal_io_check() { uint32_t io_num; // Block 10 ticks if message is not immediately // available if (xQueueReceive(gpio_evt_queue, &io_num, (TickType_t) 10)) { ESP_LOGI(TAG, "Received interrupt from DIO[%d]!", io_num); radio_irq_handler(io_num); } }
// Called by the os_runloop routing to check // if there are any pending interrupts that need // to be services
Called by the os_runloop routing to check if there are any pending interrupts that need to be services
[ "Called", "by", "the", "os_runloop", "routing", "to", "check", "if", "there", "are", "any", "pending", "interrupts", "that", "need", "to", "be", "services" ]
void hal_io_check() { uint32_t io_num; if (xQueueReceive(gpio_evt_queue, &io_num, (TickType_t) 10)) { ESP_LOGI(TAG, "Received interrupt from DIO[%d]!", io_num); radio_irq_handler(io_num); } }
[ "void", "hal_io_check", "(", ")", "{", "uint32_t", "io_num", ";", "if", "(", "xQueueReceive", "(", "gpio_evt_queue", ",", "&", "io_num", ",", "(", "TickType_t", ")", "10", ")", ")", "{", "ESP_LOGI", "(", "TAG", ",", "\"", "\"", ",", "io_num", ")", ";", "radio_irq_handler", "(", "io_num", ")", ";", "}", "}" ]
Called by the os_runloop routing to check if there are any pending interrupts that need to be services
[ "Called", "by", "the", "os_runloop", "routing", "to", "check", "if", "there", "are", "any", "pending", "interrupts", "that", "need", "to", "be", "services" ]
[ "// Block 10 ticks if message is not immediately", "// available" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
940ef94c4b86b50263848caa3a470fd0061e9a23
vpcola/testing
components/lmic/esphal.c
[ "Apache-2.0" ]
C
hal_disableIRQs
void
void hal_disableIRQs () { if(x_irq_level < 1){ //taskDISABLE_INTERRUPTS(); } x_irq_level++; }
// ----------------------------------------------------------------------------- // IRQ // hal_disableIRQs()/hal_enableIRQs() in LMIC act more like mutex // to prevent execution when one task is using a certain resource (such as the radio). // So we use mutex here in place of truly disabling interrupts.
IRQ hal_disableIRQs()/hal_enableIRQs() in LMIC act more like mutex to prevent execution when one task is using a certain resource (such as the radio). So we use mutex here in place of truly disabling interrupts.
[ "IRQ", "hal_disableIRQs", "()", "/", "hal_enableIRQs", "()", "in", "LMIC", "act", "more", "like", "mutex", "to", "prevent", "execution", "when", "one", "task", "is", "using", "a", "certain", "resource", "(", "such", "as", "the", "radio", ")", ".", "So", "we", "use", "mutex", "here", "in", "place", "of", "truly", "disabling", "interrupts", "." ]
void hal_disableIRQs () { if(x_irq_level < 1){ } x_irq_level++; }
[ "void", "hal_disableIRQs", "(", ")", "{", "if", "(", "x_irq_level", "<", "1", ")", "{", "}", "x_irq_level", "++", ";", "}" ]
IRQ hal_disableIRQs()/hal_enableIRQs() in LMIC act more like mutex to prevent execution when one task is using a certain resource (such as the radio).
[ "IRQ", "hal_disableIRQs", "()", "/", "hal_enableIRQs", "()", "in", "LMIC", "act", "more", "like", "mutex", "to", "prevent", "execution", "when", "one", "task", "is", "using", "a", "certain", "resource", "(", "such", "as", "the", "radio", ")", "." ]
[ "//taskDISABLE_INTERRUPTS();" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
5903603f6486cd992bacd646849a1c0891b61fee
vpcola/testing
components/lmic/oslmic.c
[ "Apache-2.0" ]
C
os_run
void
void os_run () { osjob_t* j = NULL; hal_disableIRQs(); // check for runnable jobs if(OS.runnablejobs) { j = OS.runnablejobs; OS.runnablejobs = j->next; } else if(OS.scheduledjobs && hal_checkTimer(OS.scheduledjobs->deadline)) { // check for expired timed jobs j = OS.scheduledjobs; OS.scheduledjobs = j->next; } else { // nothing pending hal_sleep(); // wake by irq (timer already restarted) } hal_enableIRQs(); // Call hal_iocheck() to find out pending // IRQ's that needs to be serviced. hal_io_check(); if(j) { // run job callback j->func(j); } }
// execute jobs from timer and from run queue
execute jobs from timer and from run queue
[ "execute", "jobs", "from", "timer", "and", "from", "run", "queue" ]
void os_run () { osjob_t* j = NULL; hal_disableIRQs(); if(OS.runnablejobs) { j = OS.runnablejobs; OS.runnablejobs = j->next; } else if(OS.scheduledjobs && hal_checkTimer(OS.scheduledjobs->deadline)) { j = OS.scheduledjobs; OS.scheduledjobs = j->next; } else { hal_sleep(); } hal_enableIRQs(); hal_io_check(); if(j) { j->func(j); } }
[ "void", "os_run", "(", ")", "{", "osjob_t", "*", "j", "=", "NULL", ";", "hal_disableIRQs", "(", ")", ";", "if", "(", "OS", ".", "runnablejobs", ")", "{", "j", "=", "OS", ".", "runnablejobs", ";", "OS", ".", "runnablejobs", "=", "j", "->", "next", ";", "}", "else", "if", "(", "OS", ".", "scheduledjobs", "&&", "hal_checkTimer", "(", "OS", ".", "scheduledjobs", "->", "deadline", ")", ")", "{", "j", "=", "OS", ".", "scheduledjobs", ";", "OS", ".", "scheduledjobs", "=", "j", "->", "next", ";", "}", "else", "{", "hal_sleep", "(", ")", ";", "}", "hal_enableIRQs", "(", ")", ";", "hal_io_check", "(", ")", ";", "if", "(", "j", ")", "{", "j", "->", "func", "(", "j", ")", ";", "}", "}" ]
execute jobs from timer and from run queue
[ "execute", "jobs", "from", "timer", "and", "from", "run", "queue" ]
[ "// check for runnable jobs", "// check for expired timed jobs", "// nothing pending", "// wake by irq (timer already restarted)", "// Call hal_iocheck() to find out pending", "// IRQ's that needs to be serviced.", "// run job callback" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
ed96de7050f74e09331004f2d3b58276c9d68810
sebastianbenoit/rpki-client-portable
src/rpki-client/mft.c
[ "ISC" ]
C
check_validity
time_t
static time_t check_validity(const ASN1_GENERALIZEDTIME *from, const ASN1_GENERALIZEDTIME *until, const char *fn, int force) { time_t now = time(NULL); if (!ASN1_GENERALIZEDTIME_check(from) || !ASN1_GENERALIZEDTIME_check(until)) { warnx("%s: embedded time format invalid", fn); return -1; } /* check that until is not before from */ if (ASN1_STRING_cmp(until, from) < 0) { warnx("%s: bad update interval", fn); return -1; } /* check that now is not before from */ if (X509_cmp_time(from, &now) > 0) { warnx("%s: mft not yet valid %s", fn, gentime2str(from)); return -1; } /* check that now is not after until */ if (X509_cmp_time(until, &now) < 0) { warnx("%s: mft expired on %s%s", fn, gentime2str(until), force ? " (ignoring)" : ""); if (!force) return 0; } return 1; }
/* * Validate and verify the time validity of the mft. * Returns 1 if all is good, 0 if mft is stale, any other case -1. * XXX should use ASN1_time_tm_cmp() once libressl is used. */
Validate and verify the time validity of the mft. Returns 1 if all is good, 0 if mft is stale, any other case -1. XXX should use ASN1_time_tm_cmp() once libressl is used.
[ "Validate", "and", "verify", "the", "time", "validity", "of", "the", "mft", ".", "Returns", "1", "if", "all", "is", "good", "0", "if", "mft", "is", "stale", "any", "other", "case", "-", "1", ".", "XXX", "should", "use", "ASN1_time_tm_cmp", "()", "once", "libressl", "is", "used", "." ]
static time_t check_validity(const ASN1_GENERALIZEDTIME *from, const ASN1_GENERALIZEDTIME *until, const char *fn, int force) { time_t now = time(NULL); if (!ASN1_GENERALIZEDTIME_check(from) || !ASN1_GENERALIZEDTIME_check(until)) { warnx("%s: embedded time format invalid", fn); return -1; } if (ASN1_STRING_cmp(until, from) < 0) { warnx("%s: bad update interval", fn); return -1; } if (X509_cmp_time(from, &now) > 0) { warnx("%s: mft not yet valid %s", fn, gentime2str(from)); return -1; } if (X509_cmp_time(until, &now) < 0) { warnx("%s: mft expired on %s%s", fn, gentime2str(until), force ? " (ignoring)" : ""); if (!force) return 0; } return 1; }
[ "static", "time_t", "check_validity", "(", "const", "ASN1_GENERALIZEDTIME", "*", "from", ",", "const", "ASN1_GENERALIZEDTIME", "*", "until", ",", "const", "char", "*", "fn", ",", "int", "force", ")", "{", "time_t", "now", "=", "time", "(", "NULL", ")", ";", "if", "(", "!", "ASN1_GENERALIZEDTIME_check", "(", "from", ")", "||", "!", "ASN1_GENERALIZEDTIME_check", "(", "until", ")", ")", "{", "warnx", "(", "\"", "\"", ",", "fn", ")", ";", "return", "-1", ";", "}", "if", "(", "ASN1_STRING_cmp", "(", "until", ",", "from", ")", "<", "0", ")", "{", "warnx", "(", "\"", "\"", ",", "fn", ")", ";", "return", "-1", ";", "}", "if", "(", "X509_cmp_time", "(", "from", ",", "&", "now", ")", ">", "0", ")", "{", "warnx", "(", "\"", "\"", ",", "fn", ",", "gentime2str", "(", "from", ")", ")", ";", "return", "-1", ";", "}", "if", "(", "X509_cmp_time", "(", "until", ",", "&", "now", ")", "<", "0", ")", "{", "warnx", "(", "\"", "\"", ",", "fn", ",", "gentime2str", "(", "until", ")", ",", "force", "?", "\"", "\"", ":", "\"", "\"", ")", ";", "if", "(", "!", "force", ")", "return", "0", ";", "}", "return", "1", ";", "}" ]
Validate and verify the time validity of the mft.
[ "Validate", "and", "verify", "the", "time", "validity", "of", "the", "mft", "." ]
[ "/* check that until is not before from */", "/* check that now is not before from */", "/* check that now is not after until */" ]
[ { "param": "from", "type": "ASN1_GENERALIZEDTIME" }, { "param": "until", "type": "ASN1_GENERALIZEDTIME" }, { "param": "fn", "type": "char" }, { "param": "force", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "from", "type": "ASN1_GENERALIZEDTIME", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "until", "type": "ASN1_GENERALIZEDTIME", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fn", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "force", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ed96de7050f74e09331004f2d3b58276c9d68810
sebastianbenoit/rpki-client-portable
src/rpki-client/mft.c
[ "ISC" ]
C
mft_parse_econtent
int
static int mft_parse_econtent(const unsigned char *d, size_t dsz, struct parse *p, int force) { ASN1_SEQUENCE_ANY *seq; const ASN1_TYPE *t; const ASN1_GENERALIZEDTIME *from, *until; int i, rc = -1, validity; if ((seq = d2i_ASN1_SEQUENCE_ANY(NULL, &d, dsz)) == NULL) { cryptowarnx("%s: RFC 6486 section 4.2: Manifest: " "failed ASN.1 sequence parse", p->fn); goto out; } /* The version is optional. */ if (sk_ASN1_TYPE_num(seq) != 5 && sk_ASN1_TYPE_num(seq) != 6) { warnx("%s: RFC 6486 section 4.2: Manifest: " "want 5 or 6 elements, have %d", p->fn, sk_ASN1_TYPE_num(seq)); goto out; } /* Start with optional version. */ i = 0; if (sk_ASN1_TYPE_num(seq) == 6) { t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_INTEGER) { warnx("%s: RFC 6486 section 4.2.1: version: " "want ASN.1 integer, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } } /* Now the manifest sequence number. */ t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_INTEGER) { warnx("%s: RFC 6486 section 4.2.1: manifestNumber: " "want ASN.1 integer, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } /* * Timestamps: this and next update time. * Validate that the current date falls into this interval. * This is required by section 4.4, (3). * If we're after the given date, then the MFT is stale. * This is made super complicated because it usees OpenSSL's * ASN1_GENERALIZEDTIME instead of ASN1_TIME, which we could * compare against the current time trivially. */ t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_GENERALIZEDTIME) { warnx("%s: RFC 6486 section 4.2.1: thisUpdate: " "want ASN.1 generalised time, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } from = t->value.generalizedtime; t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_GENERALIZEDTIME) { warnx("%s: RFC 6486 section 4.2.1: nextUpdate: " "want ASN.1 generalised time, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } until = t->value.generalizedtime; validity = check_validity(from, until, p->fn, force); if (validity != 1) goto out; /* File list algorithm. */ t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_OBJECT) { warnx("%s: RFC 6486 section 4.2.1: fileHashAlg: " "want ASN.1 object time, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } else if (OBJ_obj2nid(t->value.object) != NID_sha256) { warnx("%s: RFC 6486 section 4.2.1: fileHashAlg: " "want SHA256 object, have %s (NID %d)", p->fn, ASN1_tag2str(OBJ_obj2nid(t->value.object)), OBJ_obj2nid(t->value.object)); goto out; } /* Now the sequence. */ t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_SEQUENCE) { warnx("%s: RFC 6486 section 4.2.1: fileList: " "want ASN.1 sequence, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } else if (!mft_parse_flist(p, t->value.octet_string)) goto out; rc = validity; out: sk_ASN1_TYPE_pop_free(seq, ASN1_TYPE_free); return rc; }
/* * Handle the eContent of the manifest object, RFC 6486 sec. 4.2. * Returns <0 on failure, 0 on stale, >0 on success. */
Handle the eContent of the manifest object, RFC 6486 sec.
[ "Handle", "the", "eContent", "of", "the", "manifest", "object", "RFC", "6486", "sec", "." ]
static int mft_parse_econtent(const unsigned char *d, size_t dsz, struct parse *p, int force) { ASN1_SEQUENCE_ANY *seq; const ASN1_TYPE *t; const ASN1_GENERALIZEDTIME *from, *until; int i, rc = -1, validity; if ((seq = d2i_ASN1_SEQUENCE_ANY(NULL, &d, dsz)) == NULL) { cryptowarnx("%s: RFC 6486 section 4.2: Manifest: " "failed ASN.1 sequence parse", p->fn); goto out; } if (sk_ASN1_TYPE_num(seq) != 5 && sk_ASN1_TYPE_num(seq) != 6) { warnx("%s: RFC 6486 section 4.2: Manifest: " "want 5 or 6 elements, have %d", p->fn, sk_ASN1_TYPE_num(seq)); goto out; } i = 0; if (sk_ASN1_TYPE_num(seq) == 6) { t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_INTEGER) { warnx("%s: RFC 6486 section 4.2.1: version: " "want ASN.1 integer, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } } t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_INTEGER) { warnx("%s: RFC 6486 section 4.2.1: manifestNumber: " "want ASN.1 integer, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_GENERALIZEDTIME) { warnx("%s: RFC 6486 section 4.2.1: thisUpdate: " "want ASN.1 generalised time, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } from = t->value.generalizedtime; t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_GENERALIZEDTIME) { warnx("%s: RFC 6486 section 4.2.1: nextUpdate: " "want ASN.1 generalised time, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } until = t->value.generalizedtime; validity = check_validity(from, until, p->fn, force); if (validity != 1) goto out; t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_OBJECT) { warnx("%s: RFC 6486 section 4.2.1: fileHashAlg: " "want ASN.1 object time, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } else if (OBJ_obj2nid(t->value.object) != NID_sha256) { warnx("%s: RFC 6486 section 4.2.1: fileHashAlg: " "want SHA256 object, have %s (NID %d)", p->fn, ASN1_tag2str(OBJ_obj2nid(t->value.object)), OBJ_obj2nid(t->value.object)); goto out; } t = sk_ASN1_TYPE_value(seq, i++); if (t->type != V_ASN1_SEQUENCE) { warnx("%s: RFC 6486 section 4.2.1: fileList: " "want ASN.1 sequence, have %s (NID %d)", p->fn, ASN1_tag2str(t->type), t->type); goto out; } else if (!mft_parse_flist(p, t->value.octet_string)) goto out; rc = validity; out: sk_ASN1_TYPE_pop_free(seq, ASN1_TYPE_free); return rc; }
[ "static", "int", "mft_parse_econtent", "(", "const", "unsigned", "char", "*", "d", ",", "size_t", "dsz", ",", "struct", "parse", "*", "p", ",", "int", "force", ")", "{", "ASN1_SEQUENCE_ANY", "*", "seq", ";", "const", "ASN1_TYPE", "*", "t", ";", "const", "ASN1_GENERALIZEDTIME", "*", "from", ",", "*", "until", ";", "int", "i", ",", "rc", "=", "-1", ",", "validity", ";", "if", "(", "(", "seq", "=", "d2i_ASN1_SEQUENCE_ANY", "(", "NULL", ",", "&", "d", ",", "dsz", ")", ")", "==", "NULL", ")", "{", "cryptowarnx", "(", "\"", "\"", "\"", "\"", ",", "p", "->", "fn", ")", ";", "goto", "out", ";", "}", "if", "(", "sk_ASN1_TYPE_num", "(", "seq", ")", "!=", "5", "&&", "sk_ASN1_TYPE_num", "(", "seq", ")", "!=", "6", ")", "{", "warnx", "(", "\"", "\"", "\"", "\"", ",", "p", "->", "fn", ",", "sk_ASN1_TYPE_num", "(", "seq", ")", ")", ";", "goto", "out", ";", "}", "i", "=", "0", ";", "if", "(", "sk_ASN1_TYPE_num", "(", "seq", ")", "==", "6", ")", "{", "t", "=", "sk_ASN1_TYPE_value", "(", "seq", ",", "i", "++", ")", ";", "if", "(", "t", "->", "type", "!=", "V_ASN1_INTEGER", ")", "{", "warnx", "(", "\"", "\"", "\"", "\"", ",", "p", "->", "fn", ",", "ASN1_tag2str", "(", "t", "->", "type", ")", ",", "t", "->", "type", ")", ";", "goto", "out", ";", "}", "}", "t", "=", "sk_ASN1_TYPE_value", "(", "seq", ",", "i", "++", ")", ";", "if", "(", "t", "->", "type", "!=", "V_ASN1_INTEGER", ")", "{", "warnx", "(", "\"", "\"", "\"", "\"", ",", "p", "->", "fn", ",", "ASN1_tag2str", "(", "t", "->", "type", ")", ",", "t", "->", "type", ")", ";", "goto", "out", ";", "}", "t", "=", "sk_ASN1_TYPE_value", "(", "seq", ",", "i", "++", ")", ";", "if", "(", "t", "->", "type", "!=", "V_ASN1_GENERALIZEDTIME", ")", "{", "warnx", "(", "\"", "\"", "\"", "\"", ",", "p", "->", "fn", ",", "ASN1_tag2str", "(", "t", "->", "type", ")", ",", "t", "->", "type", ")", ";", "goto", "out", ";", "}", "from", "=", "t", "->", "value", ".", "generalizedtime", ";", "t", "=", "sk_ASN1_TYPE_value", "(", "seq", ",", "i", "++", ")", ";", "if", "(", "t", "->", "type", "!=", "V_ASN1_GENERALIZEDTIME", ")", "{", "warnx", "(", "\"", "\"", "\"", "\"", ",", "p", "->", "fn", ",", "ASN1_tag2str", "(", "t", "->", "type", ")", ",", "t", "->", "type", ")", ";", "goto", "out", ";", "}", "until", "=", "t", "->", "value", ".", "generalizedtime", ";", "validity", "=", "check_validity", "(", "from", ",", "until", ",", "p", "->", "fn", ",", "force", ")", ";", "if", "(", "validity", "!=", "1", ")", "goto", "out", ";", "t", "=", "sk_ASN1_TYPE_value", "(", "seq", ",", "i", "++", ")", ";", "if", "(", "t", "->", "type", "!=", "V_ASN1_OBJECT", ")", "{", "warnx", "(", "\"", "\"", "\"", "\"", ",", "p", "->", "fn", ",", "ASN1_tag2str", "(", "t", "->", "type", ")", ",", "t", "->", "type", ")", ";", "goto", "out", ";", "}", "else", "if", "(", "OBJ_obj2nid", "(", "t", "->", "value", ".", "object", ")", "!=", "NID_sha256", ")", "{", "warnx", "(", "\"", "\"", "\"", "\"", ",", "p", "->", "fn", ",", "ASN1_tag2str", "(", "OBJ_obj2nid", "(", "t", "->", "value", ".", "object", ")", ")", ",", "OBJ_obj2nid", "(", "t", "->", "value", ".", "object", ")", ")", ";", "goto", "out", ";", "}", "t", "=", "sk_ASN1_TYPE_value", "(", "seq", ",", "i", "++", ")", ";", "if", "(", "t", "->", "type", "!=", "V_ASN1_SEQUENCE", ")", "{", "warnx", "(", "\"", "\"", "\"", "\"", ",", "p", "->", "fn", ",", "ASN1_tag2str", "(", "t", "->", "type", ")", ",", "t", "->", "type", ")", ";", "goto", "out", ";", "}", "else", "if", "(", "!", "mft_parse_flist", "(", "p", ",", "t", "->", "value", ".", "octet_string", ")", ")", "goto", "out", ";", "rc", "=", "validity", ";", "out", ":", "sk_ASN1_TYPE_pop_free", "(", "seq", ",", "ASN1_TYPE_free", ")", ";", "return", "rc", ";", "}" ]
Handle the eContent of the manifest object, RFC 6486 sec.
[ "Handle", "the", "eContent", "of", "the", "manifest", "object", "RFC", "6486", "sec", "." ]
[ "/* The version is optional. */", "/* Start with optional version. */", "/* Now the manifest sequence number. */", "/*\n\t * Timestamps: this and next update time.\n\t * Validate that the current date falls into this interval.\n\t * This is required by section 4.4, (3).\n\t * If we're after the given date, then the MFT is stale.\n\t * This is made super complicated because it usees OpenSSL's\n\t * ASN1_GENERALIZEDTIME instead of ASN1_TIME, which we could\n\t * compare against the current time trivially.\n\t */", "/* File list algorithm. */", "/* Now the sequence. */" ]
[ { "param": "d", "type": "unsigned char" }, { "param": "dsz", "type": "size_t" }, { "param": "p", "type": "struct parse" }, { "param": "force", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "d", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dsz", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "struct parse", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "force", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ed96de7050f74e09331004f2d3b58276c9d68810
sebastianbenoit/rpki-client-portable
src/rpki-client/mft.c
[ "ISC" ]
C
mft_parse
null
struct mft * mft_parse(X509 **x509, const char *fn, int force) { struct parse p; int c, rc = 0; size_t i, cmsz; unsigned char *cms; memset(&p, 0, sizeof(struct parse)); p.fn = fn; cms = cms_parse_validate(x509, fn, "1.2.840.113549.1.9.16.1.26", NULL, &cmsz); if (cms == NULL) return NULL; assert(*x509 != NULL); if ((p.res = calloc(1, sizeof(struct mft))) == NULL) err(1, NULL); if ((p.res->file = strdup(fn)) == NULL) err(1, NULL); if (!x509_get_ski_aki(*x509, fn, &p.res->ski, &p.res->aki)) goto out; /* * If we're stale, then remove all of the files that the MFT * references as well as marking it as stale. */ if ((c = mft_parse_econtent(cms, cmsz, &p, force)) == 0) { /* * FIXME: it should suffice to just mark this as stale * and have the logic around mft_read() simply ignore * the contents of stale entries, just like it does for * invalid ROAs or certificates. */ p.res->stale = 1; if (p.res->files != NULL) for (i = 0; i < p.res->filesz; i++) free(p.res->files[i].file); free(p.res->files); p.res->filesz = 0; p.res->files = NULL; } else if (c == -1) goto out; rc = 1; out: if (rc == 0) { mft_free(p.res); p.res = NULL; X509_free(*x509); *x509 = NULL; } free(cms); return p.res; }
/* * Parse the objects that have been published in the manifest. * This conforms to RFC 6486. * Note that if the MFT is stale, all referenced objects are stripped * from the parsed content. * The MFT content is otherwise returned. */
Parse the objects that have been published in the manifest. This conforms to RFC 6486. Note that if the MFT is stale, all referenced objects are stripped from the parsed content. The MFT content is otherwise returned.
[ "Parse", "the", "objects", "that", "have", "been", "published", "in", "the", "manifest", ".", "This", "conforms", "to", "RFC", "6486", ".", "Note", "that", "if", "the", "MFT", "is", "stale", "all", "referenced", "objects", "are", "stripped", "from", "the", "parsed", "content", ".", "The", "MFT", "content", "is", "otherwise", "returned", "." ]
struct mft * mft_parse(X509 **x509, const char *fn, int force) { struct parse p; int c, rc = 0; size_t i, cmsz; unsigned char *cms; memset(&p, 0, sizeof(struct parse)); p.fn = fn; cms = cms_parse_validate(x509, fn, "1.2.840.113549.1.9.16.1.26", NULL, &cmsz); if (cms == NULL) return NULL; assert(*x509 != NULL); if ((p.res = calloc(1, sizeof(struct mft))) == NULL) err(1, NULL); if ((p.res->file = strdup(fn)) == NULL) err(1, NULL); if (!x509_get_ski_aki(*x509, fn, &p.res->ski, &p.res->aki)) goto out; if ((c = mft_parse_econtent(cms, cmsz, &p, force)) == 0) { p.res->stale = 1; if (p.res->files != NULL) for (i = 0; i < p.res->filesz; i++) free(p.res->files[i].file); free(p.res->files); p.res->filesz = 0; p.res->files = NULL; } else if (c == -1) goto out; rc = 1; out: if (rc == 0) { mft_free(p.res); p.res = NULL; X509_free(*x509); *x509 = NULL; } free(cms); return p.res; }
[ "struct", "mft", "*", "mft_parse", "(", "X509", "*", "*", "x509", ",", "const", "char", "*", "fn", ",", "int", "force", ")", "{", "struct", "parse", "p", ";", "int", "c", ",", "rc", "=", "0", ";", "size_t", "i", ",", "cmsz", ";", "unsigned", "char", "*", "cms", ";", "memset", "(", "&", "p", ",", "0", ",", "sizeof", "(", "struct", "parse", ")", ")", ";", "p", ".", "fn", "=", "fn", ";", "cms", "=", "cms_parse_validate", "(", "x509", ",", "fn", ",", "\"", "\"", ",", "NULL", ",", "&", "cmsz", ")", ";", "if", "(", "cms", "==", "NULL", ")", "return", "NULL", ";", "assert", "(", "*", "x509", "!=", "NULL", ")", ";", "if", "(", "(", "p", ".", "res", "=", "calloc", "(", "1", ",", "sizeof", "(", "struct", "mft", ")", ")", ")", "==", "NULL", ")", "err", "(", "1", ",", "NULL", ")", ";", "if", "(", "(", "p", ".", "res", "->", "file", "=", "strdup", "(", "fn", ")", ")", "==", "NULL", ")", "err", "(", "1", ",", "NULL", ")", ";", "if", "(", "!", "x509_get_ski_aki", "(", "*", "x509", ",", "fn", ",", "&", "p", ".", "res", "->", "ski", ",", "&", "p", ".", "res", "->", "aki", ")", ")", "goto", "out", ";", "if", "(", "(", "c", "=", "mft_parse_econtent", "(", "cms", ",", "cmsz", ",", "&", "p", ",", "force", ")", ")", "==", "0", ")", "{", "p", ".", "res", "->", "stale", "=", "1", ";", "if", "(", "p", ".", "res", "->", "files", "!=", "NULL", ")", "for", "(", "i", "=", "0", ";", "i", "<", "p", ".", "res", "->", "filesz", ";", "i", "++", ")", "free", "(", "p", ".", "res", "->", "files", "[", "i", "]", ".", "file", ")", ";", "free", "(", "p", ".", "res", "->", "files", ")", ";", "p", ".", "res", "->", "filesz", "=", "0", ";", "p", ".", "res", "->", "files", "=", "NULL", ";", "}", "else", "if", "(", "c", "==", "-1", ")", "goto", "out", ";", "rc", "=", "1", ";", "out", ":", "if", "(", "rc", "==", "0", ")", "{", "mft_free", "(", "p", ".", "res", ")", ";", "p", ".", "res", "=", "NULL", ";", "X509_free", "(", "*", "x509", ")", ";", "*", "x509", "=", "NULL", ";", "}", "free", "(", "cms", ")", ";", "return", "p", ".", "res", ";", "}" ]
Parse the objects that have been published in the manifest.
[ "Parse", "the", "objects", "that", "have", "been", "published", "in", "the", "manifest", "." ]
[ "/*\n\t * If we're stale, then remove all of the files that the MFT\n\t * references as well as marking it as stale.\n\t */", "/*\n\t\t * FIXME: it should suffice to just mark this as stale\n\t\t * and have the logic around mft_read() simply ignore\n\t\t * the contents of stale entries, just like it does for\n\t\t * invalid ROAs or certificates.\n\t\t */" ]
[ { "param": "x509", "type": "X509" }, { "param": "fn", "type": "char" }, { "param": "force", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x509", "type": "X509", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fn", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "force", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ed96de7050f74e09331004f2d3b58276c9d68810
sebastianbenoit/rpki-client-portable
src/rpki-client/mft.c
[ "ISC" ]
C
mft_validfilehash
int
static int mft_validfilehash(const char *fn, const struct mftfile *m) { char filehash[SHA256_DIGEST_LENGTH]; char buffer[8192]; char *cp, *path = NULL; SHA256_CTX ctx; ssize_t nr; int fd; /* Check hash of file now, but first build path for it */ cp = strrchr(fn, '/'); assert(cp != NULL); if (asprintf(&path, "%.*s/%s", (int)(cp - fn), fn, m->file) == -1) err(1, "asprintf"); if ((fd = open(path, O_RDONLY)) == -1) { warn("%s: referenced file %s", fn, m->file); free(path); return 0; } free(path); SHA256_Init(&ctx); while ((nr = read(fd, buffer, sizeof(buffer))) > 0) { SHA256_Update(&ctx, buffer, nr); } close(fd); SHA256_Final(filehash, &ctx); if (memcmp(m->hash, filehash, SHA256_DIGEST_LENGTH) != 0) { warnx("%s: bad message digest for %s", fn, m->file); return 0; } return 1; }
/* * Check the hash value of a file. * Return zero on failure, non-zero on success. */
Check the hash value of a file. Return zero on failure, non-zero on success.
[ "Check", "the", "hash", "value", "of", "a", "file", ".", "Return", "zero", "on", "failure", "non", "-", "zero", "on", "success", "." ]
static int mft_validfilehash(const char *fn, const struct mftfile *m) { char filehash[SHA256_DIGEST_LENGTH]; char buffer[8192]; char *cp, *path = NULL; SHA256_CTX ctx; ssize_t nr; int fd; cp = strrchr(fn, '/'); assert(cp != NULL); if (asprintf(&path, "%.*s/%s", (int)(cp - fn), fn, m->file) == -1) err(1, "asprintf"); if ((fd = open(path, O_RDONLY)) == -1) { warn("%s: referenced file %s", fn, m->file); free(path); return 0; } free(path); SHA256_Init(&ctx); while ((nr = read(fd, buffer, sizeof(buffer))) > 0) { SHA256_Update(&ctx, buffer, nr); } close(fd); SHA256_Final(filehash, &ctx); if (memcmp(m->hash, filehash, SHA256_DIGEST_LENGTH) != 0) { warnx("%s: bad message digest for %s", fn, m->file); return 0; } return 1; }
[ "static", "int", "mft_validfilehash", "(", "const", "char", "*", "fn", ",", "const", "struct", "mftfile", "*", "m", ")", "{", "char", "filehash", "[", "SHA256_DIGEST_LENGTH", "]", ";", "char", "buffer", "[", "8192", "]", ";", "char", "*", "cp", ",", "*", "path", "=", "NULL", ";", "SHA256_CTX", "ctx", ";", "ssize_t", "nr", ";", "int", "fd", ";", "cp", "=", "strrchr", "(", "fn", ",", "'", "'", ")", ";", "assert", "(", "cp", "!=", "NULL", ")", ";", "if", "(", "asprintf", "(", "&", "path", ",", "\"", "\"", ",", "(", "int", ")", "(", "cp", "-", "fn", ")", ",", "fn", ",", "m", "->", "file", ")", "==", "-1", ")", "err", "(", "1", ",", "\"", "\"", ")", ";", "if", "(", "(", "fd", "=", "open", "(", "path", ",", "O_RDONLY", ")", ")", "==", "-1", ")", "{", "warn", "(", "\"", "\"", ",", "fn", ",", "m", "->", "file", ")", ";", "free", "(", "path", ")", ";", "return", "0", ";", "}", "free", "(", "path", ")", ";", "SHA256_Init", "(", "&", "ctx", ")", ";", "while", "(", "(", "nr", "=", "read", "(", "fd", ",", "buffer", ",", "sizeof", "(", "buffer", ")", ")", ")", ">", "0", ")", "{", "SHA256_Update", "(", "&", "ctx", ",", "buffer", ",", "nr", ")", ";", "}", "close", "(", "fd", ")", ";", "SHA256_Final", "(", "filehash", ",", "&", "ctx", ")", ";", "if", "(", "memcmp", "(", "m", "->", "hash", ",", "filehash", ",", "SHA256_DIGEST_LENGTH", ")", "!=", "0", ")", "{", "warnx", "(", "\"", "\"", ",", "fn", ",", "m", "->", "file", ")", ";", "return", "0", ";", "}", "return", "1", ";", "}" ]
Check the hash value of a file.
[ "Check", "the", "hash", "value", "of", "a", "file", "." ]
[ "/* Check hash of file now, but first build path for it */" ]
[ { "param": "fn", "type": "char" }, { "param": "m", "type": "struct mftfile" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fn", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "m", "type": "struct mftfile", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ed96de7050f74e09331004f2d3b58276c9d68810
sebastianbenoit/rpki-client-portable
src/rpki-client/mft.c
[ "ISC" ]
C
mft_check
int
int mft_check(const char *fn, struct mft *p) { size_t i; int rc = 1; for (i = 0; i < p->filesz; i++) if (!mft_validfilehash(fn, &p->files[i])) rc = 0; return rc; }
/* * Check all files and their hashes in a MFT structure. * Return zero on failure, non-zero on success. */
Check all files and their hashes in a MFT structure. Return zero on failure, non-zero on success.
[ "Check", "all", "files", "and", "their", "hashes", "in", "a", "MFT", "structure", ".", "Return", "zero", "on", "failure", "non", "-", "zero", "on", "success", "." ]
int mft_check(const char *fn, struct mft *p) { size_t i; int rc = 1; for (i = 0; i < p->filesz; i++) if (!mft_validfilehash(fn, &p->files[i])) rc = 0; return rc; }
[ "int", "mft_check", "(", "const", "char", "*", "fn", ",", "struct", "mft", "*", "p", ")", "{", "size_t", "i", ";", "int", "rc", "=", "1", ";", "for", "(", "i", "=", "0", ";", "i", "<", "p", "->", "filesz", ";", "i", "++", ")", "if", "(", "!", "mft_validfilehash", "(", "fn", ",", "&", "p", "->", "files", "[", "i", "]", ")", ")", "rc", "=", "0", ";", "return", "rc", ";", "}" ]
Check all files and their hashes in a MFT structure.
[ "Check", "all", "files", "and", "their", "hashes", "in", "a", "MFT", "structure", "." ]
[]
[ { "param": "fn", "type": "char" }, { "param": "p", "type": "struct mft" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fn", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "struct mft", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ed96de7050f74e09331004f2d3b58276c9d68810
sebastianbenoit/rpki-client-portable
src/rpki-client/mft.c
[ "ISC" ]
C
mft_free
void
void mft_free(struct mft *p) { size_t i; if (p == NULL) return; if (p->files != NULL) for (i = 0; i < p->filesz; i++) free(p->files[i].file); free(p->aki); free(p->ski); free(p->file); free(p->files); free(p); }
/* * Free an MFT pointer. * Safe to call with NULL. */
Free an MFT pointer. Safe to call with NULL.
[ "Free", "an", "MFT", "pointer", ".", "Safe", "to", "call", "with", "NULL", "." ]
void mft_free(struct mft *p) { size_t i; if (p == NULL) return; if (p->files != NULL) for (i = 0; i < p->filesz; i++) free(p->files[i].file); free(p->aki); free(p->ski); free(p->file); free(p->files); free(p); }
[ "void", "mft_free", "(", "struct", "mft", "*", "p", ")", "{", "size_t", "i", ";", "if", "(", "p", "==", "NULL", ")", "return", ";", "if", "(", "p", "->", "files", "!=", "NULL", ")", "for", "(", "i", "=", "0", ";", "i", "<", "p", "->", "filesz", ";", "i", "++", ")", "free", "(", "p", "->", "files", "[", "i", "]", ".", "file", ")", ";", "free", "(", "p", "->", "aki", ")", ";", "free", "(", "p", "->", "ski", ")", ";", "free", "(", "p", "->", "file", ")", ";", "free", "(", "p", "->", "files", ")", ";", "free", "(", "p", ")", ";", "}" ]
Free an MFT pointer.
[ "Free", "an", "MFT", "pointer", "." ]
[]
[ { "param": "p", "type": "struct mft" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "struct mft", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ed96de7050f74e09331004f2d3b58276c9d68810
sebastianbenoit/rpki-client-portable
src/rpki-client/mft.c
[ "ISC" ]
C
mft_buffer
void
void mft_buffer(char **b, size_t *bsz, size_t *bmax, const struct mft *p) { size_t i; io_simple_buffer(b, bsz, bmax, &p->stale, sizeof(int)); io_str_buffer(b, bsz, bmax, p->file); io_simple_buffer(b, bsz, bmax, &p->filesz, sizeof(size_t)); for (i = 0; i < p->filesz; i++) { io_str_buffer(b, bsz, bmax, p->files[i].file); io_simple_buffer(b, bsz, bmax, p->files[i].hash, SHA256_DIGEST_LENGTH); } io_str_buffer(b, bsz, bmax, p->aki); io_str_buffer(b, bsz, bmax, p->ski); }
/* * Serialise MFT parsed content into the given buffer. * See mft_read() for the other side of the pipe. */
Serialise MFT parsed content into the given buffer. See mft_read() for the other side of the pipe.
[ "Serialise", "MFT", "parsed", "content", "into", "the", "given", "buffer", ".", "See", "mft_read", "()", "for", "the", "other", "side", "of", "the", "pipe", "." ]
void mft_buffer(char **b, size_t *bsz, size_t *bmax, const struct mft *p) { size_t i; io_simple_buffer(b, bsz, bmax, &p->stale, sizeof(int)); io_str_buffer(b, bsz, bmax, p->file); io_simple_buffer(b, bsz, bmax, &p->filesz, sizeof(size_t)); for (i = 0; i < p->filesz; i++) { io_str_buffer(b, bsz, bmax, p->files[i].file); io_simple_buffer(b, bsz, bmax, p->files[i].hash, SHA256_DIGEST_LENGTH); } io_str_buffer(b, bsz, bmax, p->aki); io_str_buffer(b, bsz, bmax, p->ski); }
[ "void", "mft_buffer", "(", "char", "*", "*", "b", ",", "size_t", "*", "bsz", ",", "size_t", "*", "bmax", ",", "const", "struct", "mft", "*", "p", ")", "{", "size_t", "i", ";", "io_simple_buffer", "(", "b", ",", "bsz", ",", "bmax", ",", "&", "p", "->", "stale", ",", "sizeof", "(", "int", ")", ")", ";", "io_str_buffer", "(", "b", ",", "bsz", ",", "bmax", ",", "p", "->", "file", ")", ";", "io_simple_buffer", "(", "b", ",", "bsz", ",", "bmax", ",", "&", "p", "->", "filesz", ",", "sizeof", "(", "size_t", ")", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "p", "->", "filesz", ";", "i", "++", ")", "{", "io_str_buffer", "(", "b", ",", "bsz", ",", "bmax", ",", "p", "->", "files", "[", "i", "]", ".", "file", ")", ";", "io_simple_buffer", "(", "b", ",", "bsz", ",", "bmax", ",", "p", "->", "files", "[", "i", "]", ".", "hash", ",", "SHA256_DIGEST_LENGTH", ")", ";", "}", "io_str_buffer", "(", "b", ",", "bsz", ",", "bmax", ",", "p", "->", "aki", ")", ";", "io_str_buffer", "(", "b", ",", "bsz", ",", "bmax", ",", "p", "->", "ski", ")", ";", "}" ]
Serialise MFT parsed content into the given buffer.
[ "Serialise", "MFT", "parsed", "content", "into", "the", "given", "buffer", "." ]
[]
[ { "param": "b", "type": "char" }, { "param": "bsz", "type": "size_t" }, { "param": "bmax", "type": "size_t" }, { "param": "p", "type": "struct mft" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "b", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bsz", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bmax", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "struct mft", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ed96de7050f74e09331004f2d3b58276c9d68810
sebastianbenoit/rpki-client-portable
src/rpki-client/mft.c
[ "ISC" ]
C
mft_read
null
struct mft * mft_read(int fd) { struct mft *p = NULL; size_t i; if ((p = calloc(1, sizeof(struct mft))) == NULL) err(1, NULL); io_simple_read(fd, &p->stale, sizeof(int)); io_str_read(fd, &p->file); io_simple_read(fd, &p->filesz, sizeof(size_t)); if ((p->files = calloc(p->filesz, sizeof(struct mftfile))) == NULL) err(1, NULL); for (i = 0; i < p->filesz; i++) { io_str_read(fd, &p->files[i].file); io_simple_read(fd, p->files[i].hash, SHA256_DIGEST_LENGTH); } io_str_read(fd, &p->aki); io_str_read(fd, &p->ski); return p; }
/* * Read an MFT structure from the file descriptor. * Result must be passed to mft_free(). */
Read an MFT structure from the file descriptor. Result must be passed to mft_free().
[ "Read", "an", "MFT", "structure", "from", "the", "file", "descriptor", ".", "Result", "must", "be", "passed", "to", "mft_free", "()", "." ]
struct mft * mft_read(int fd) { struct mft *p = NULL; size_t i; if ((p = calloc(1, sizeof(struct mft))) == NULL) err(1, NULL); io_simple_read(fd, &p->stale, sizeof(int)); io_str_read(fd, &p->file); io_simple_read(fd, &p->filesz, sizeof(size_t)); if ((p->files = calloc(p->filesz, sizeof(struct mftfile))) == NULL) err(1, NULL); for (i = 0; i < p->filesz; i++) { io_str_read(fd, &p->files[i].file); io_simple_read(fd, p->files[i].hash, SHA256_DIGEST_LENGTH); } io_str_read(fd, &p->aki); io_str_read(fd, &p->ski); return p; }
[ "struct", "mft", "*", "mft_read", "(", "int", "fd", ")", "{", "struct", "mft", "*", "p", "=", "NULL", ";", "size_t", "i", ";", "if", "(", "(", "p", "=", "calloc", "(", "1", ",", "sizeof", "(", "struct", "mft", ")", ")", ")", "==", "NULL", ")", "err", "(", "1", ",", "NULL", ")", ";", "io_simple_read", "(", "fd", ",", "&", "p", "->", "stale", ",", "sizeof", "(", "int", ")", ")", ";", "io_str_read", "(", "fd", ",", "&", "p", "->", "file", ")", ";", "io_simple_read", "(", "fd", ",", "&", "p", "->", "filesz", ",", "sizeof", "(", "size_t", ")", ")", ";", "if", "(", "(", "p", "->", "files", "=", "calloc", "(", "p", "->", "filesz", ",", "sizeof", "(", "struct", "mftfile", ")", ")", ")", "==", "NULL", ")", "err", "(", "1", ",", "NULL", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "p", "->", "filesz", ";", "i", "++", ")", "{", "io_str_read", "(", "fd", ",", "&", "p", "->", "files", "[", "i", "]", ".", "file", ")", ";", "io_simple_read", "(", "fd", ",", "p", "->", "files", "[", "i", "]", ".", "hash", ",", "SHA256_DIGEST_LENGTH", ")", ";", "}", "io_str_read", "(", "fd", ",", "&", "p", "->", "aki", ")", ";", "io_str_read", "(", "fd", ",", "&", "p", "->", "ski", ")", ";", "return", "p", ";", "}" ]
Read an MFT structure from the file descriptor.
[ "Read", "an", "MFT", "structure", "from", "the", "file", "descriptor", "." ]
[]
[ { "param": "fd", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fd", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
81b12d8453dd132a56cab1111a87f436446075ba
xiaolanxia/oftest_ofdpa
lib/poll-loop.c
[ "Apache-2.0" ]
C
poll_fd_wait
null
struct poll_waiter * poll_fd_wait(int fd, short int events) { return new_waiter(fd, events); }
/* Registers 'fd' as waiting for the specified 'events' (which should be POLLIN * or POLLOUT or POLLIN | POLLOUT). The following call to poll_block() will * wake up when 'fd' becomes ready for one or more of the requested events. * * The event registration is one-shot: only the following call to poll_block() * is affected. The event will need to be re-registered after poll_block() is * called if it is to persist. */
Registers 'fd' as waiting for the specified 'events' (which should be POLLIN or POLLOUT or POLLIN | POLLOUT). The following call to poll_block() will wake up when 'fd' becomes ready for one or more of the requested events. The event registration is one-shot: only the following call to poll_block() is affected. The event will need to be re-registered after poll_block() is called if it is to persist.
[ "Registers", "'", "fd", "'", "as", "waiting", "for", "the", "specified", "'", "events", "'", "(", "which", "should", "be", "POLLIN", "or", "POLLOUT", "or", "POLLIN", "|", "POLLOUT", ")", ".", "The", "following", "call", "to", "poll_block", "()", "will", "wake", "up", "when", "'", "fd", "'", "becomes", "ready", "for", "one", "or", "more", "of", "the", "requested", "events", ".", "The", "event", "registration", "is", "one", "-", "shot", ":", "only", "the", "following", "call", "to", "poll_block", "()", "is", "affected", ".", "The", "event", "will", "need", "to", "be", "re", "-", "registered", "after", "poll_block", "()", "is", "called", "if", "it", "is", "to", "persist", "." ]
struct poll_waiter * poll_fd_wait(int fd, short int events) { return new_waiter(fd, events); }
[ "struct", "poll_waiter", "*", "poll_fd_wait", "(", "int", "fd", ",", "short", "int", "events", ")", "{", "return", "new_waiter", "(", "fd", ",", "events", ")", ";", "}" ]
Registers 'fd' as waiting for the specified 'events' (which should be POLLIN or POLLOUT or POLLIN | POLLOUT).
[ "Registers", "'", "fd", "'", "as", "waiting", "for", "the", "specified", "'", "events", "'", "(", "which", "should", "be", "POLLIN", "or", "POLLOUT", "or", "POLLIN", "|", "POLLOUT", ")", "." ]
[]
[ { "param": "fd", "type": "int" }, { "param": "events", "type": "short int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fd", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "events", "type": "short int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
81b12d8453dd132a56cab1111a87f436446075ba
xiaolanxia/oftest_ofdpa
lib/poll-loop.c
[ "Apache-2.0" ]
C
poll_timer_wait
void
void poll_timer_wait(int msec) { if (timeout < 0 || msec < timeout) { timeout = MAX(0, msec); if (VLOG_IS_DBG_ENABLED(LOG_MODULE)) { backtrace_capture(&timeout_backtrace); } } }
/* Causes the following call to poll_block() to block for no more than 'msec' * milliseconds. If 'msec' is nonpositive, the following call to poll_block() * will not block at all. * * The timer registration is one-shot: only the following call to poll_block() * is affected. The timer will need to be re-registered after poll_block() is * called if it is to persist. */
Causes the following call to poll_block() to block for no more than 'msec' milliseconds. If 'msec' is nonpositive, the following call to poll_block() will not block at all. The timer registration is one-shot: only the following call to poll_block() is affected. The timer will need to be re-registered after poll_block() is called if it is to persist.
[ "Causes", "the", "following", "call", "to", "poll_block", "()", "to", "block", "for", "no", "more", "than", "'", "msec", "'", "milliseconds", ".", "If", "'", "msec", "'", "is", "nonpositive", "the", "following", "call", "to", "poll_block", "()", "will", "not", "block", "at", "all", ".", "The", "timer", "registration", "is", "one", "-", "shot", ":", "only", "the", "following", "call", "to", "poll_block", "()", "is", "affected", ".", "The", "timer", "will", "need", "to", "be", "re", "-", "registered", "after", "poll_block", "()", "is", "called", "if", "it", "is", "to", "persist", "." ]
void poll_timer_wait(int msec) { if (timeout < 0 || msec < timeout) { timeout = MAX(0, msec); if (VLOG_IS_DBG_ENABLED(LOG_MODULE)) { backtrace_capture(&timeout_backtrace); } } }
[ "void", "poll_timer_wait", "(", "int", "msec", ")", "{", "if", "(", "timeout", "<", "0", "||", "msec", "<", "timeout", ")", "{", "timeout", "=", "MAX", "(", "0", ",", "msec", ")", ";", "if", "(", "VLOG_IS_DBG_ENABLED", "(", "LOG_MODULE", ")", ")", "{", "backtrace_capture", "(", "&", "timeout_backtrace", ")", ";", "}", "}", "}" ]
Causes the following call to poll_block() to block for no more than 'msec' milliseconds.
[ "Causes", "the", "following", "call", "to", "poll_block", "()", "to", "block", "for", "no", "more", "than", "'", "msec", "'", "milliseconds", "." ]
[]
[ { "param": "msec", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "msec", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
81b12d8453dd132a56cab1111a87f436446075ba
xiaolanxia/oftest_ofdpa
lib/poll-loop.c
[ "Apache-2.0" ]
C
poll_immediate_wake
void
void poll_immediate_wake(void) { poll_timer_wait(0); }
/* Causes the following call to poll_block() to wake up immediately, without * blocking. */
Causes the following call to poll_block() to wake up immediately, without blocking.
[ "Causes", "the", "following", "call", "to", "poll_block", "()", "to", "wake", "up", "immediately", "without", "blocking", "." ]
void poll_immediate_wake(void) { poll_timer_wait(0); }
[ "void", "poll_immediate_wake", "(", "void", ")", "{", "poll_timer_wait", "(", "0", ")", ";", "}" ]
Causes the following call to poll_block() to wake up immediately, without blocking.
[ "Causes", "the", "following", "call", "to", "poll_block", "()", "to", "wake", "up", "immediately", "without", "blocking", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
81b12d8453dd132a56cab1111a87f436446075ba
xiaolanxia/oftest_ofdpa
lib/poll-loop.c
[ "Apache-2.0" ]
C
poll_fd_callback
null
struct poll_waiter * poll_fd_callback(int fd, short int events, poll_fd_func *function, void *aux) { struct poll_waiter *pw = new_waiter(fd, events); pw->function = function; pw->aux = aux; return pw; }
/* Registers 'function' to be called with argument 'aux' by poll_block() when * 'fd' becomes ready for one of the events in 'events', which should be POLLIN * or POLLOUT or POLLIN | POLLOUT. * * The callback registration persists until the event actually occurs. At that * point, it is automatically de-registered. The callback function must * re-register the event by calling poll_fd_callback() again within the * callback, if it wants to be called back again later. */
The callback registration persists until the event actually occurs. At that point, it is automatically de-registered. The callback function must re-register the event by calling poll_fd_callback() again within the callback, if it wants to be called back again later.
[ "The", "callback", "registration", "persists", "until", "the", "event", "actually", "occurs", ".", "At", "that", "point", "it", "is", "automatically", "de", "-", "registered", ".", "The", "callback", "function", "must", "re", "-", "register", "the", "event", "by", "calling", "poll_fd_callback", "()", "again", "within", "the", "callback", "if", "it", "wants", "to", "be", "called", "back", "again", "later", "." ]
struct poll_waiter * poll_fd_callback(int fd, short int events, poll_fd_func *function, void *aux) { struct poll_waiter *pw = new_waiter(fd, events); pw->function = function; pw->aux = aux; return pw; }
[ "struct", "poll_waiter", "*", "poll_fd_callback", "(", "int", "fd", ",", "short", "int", "events", ",", "poll_fd_func", "*", "function", ",", "void", "*", "aux", ")", "{", "struct", "poll_waiter", "*", "pw", "=", "new_waiter", "(", "fd", ",", "events", ")", ";", "pw", "->", "function", "=", "function", ";", "pw", "->", "aux", "=", "aux", ";", "return", "pw", ";", "}" ]
Registers 'function' to be called with argument 'aux' by poll_block() when 'fd' becomes ready for one of the events in 'events', which should be POLLIN or POLLOUT or POLLIN | POLLOUT.
[ "Registers", "'", "function", "'", "to", "be", "called", "with", "argument", "'", "aux", "'", "by", "poll_block", "()", "when", "'", "fd", "'", "becomes", "ready", "for", "one", "of", "the", "events", "in", "'", "events", "'", "which", "should", "be", "POLLIN", "or", "POLLOUT", "or", "POLLIN", "|", "POLLOUT", "." ]
[]
[ { "param": "fd", "type": "int" }, { "param": "events", "type": "short int" }, { "param": "function", "type": "poll_fd_func" }, { "param": "aux", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fd", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "events", "type": "short int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "function", "type": "poll_fd_func", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "aux", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
81b12d8453dd132a56cab1111a87f436446075ba
xiaolanxia/oftest_ofdpa
lib/poll-loop.c
[ "Apache-2.0" ]
C
poll_cancel
void
void poll_cancel(struct poll_waiter *pw) { if (pw) { assert(pw != running_cb); list_remove(&pw->node); free(pw->backtrace); free(pw); n_waiters--; } }
/* Cancels the file descriptor event registered with poll_fd_wait() or * poll_fd_callback(). 'pw' must be the struct poll_waiter returned by one of * those functions. * * An event registered with poll_fd_wait() may be canceled from its time of * registration until the next call to poll_block(). At that point, the event * is automatically canceled by the system and its poll_waiter is freed. * * An event registered with poll_fd_callback() may be canceled from its time of * registration until its callback is actually called. At that point, the * event is automatically canceled by the system and its poll_waiter is * freed. */
Cancels the file descriptor event registered with poll_fd_wait() or poll_fd_callback(). 'pw' must be the struct poll_waiter returned by one of those functions. An event registered with poll_fd_wait() may be canceled from its time of registration until the next call to poll_block(). At that point, the event is automatically canceled by the system and its poll_waiter is freed. An event registered with poll_fd_callback() may be canceled from its time of registration until its callback is actually called. At that point, the event is automatically canceled by the system and its poll_waiter is freed.
[ "Cancels", "the", "file", "descriptor", "event", "registered", "with", "poll_fd_wait", "()", "or", "poll_fd_callback", "()", ".", "'", "pw", "'", "must", "be", "the", "struct", "poll_waiter", "returned", "by", "one", "of", "those", "functions", ".", "An", "event", "registered", "with", "poll_fd_wait", "()", "may", "be", "canceled", "from", "its", "time", "of", "registration", "until", "the", "next", "call", "to", "poll_block", "()", ".", "At", "that", "point", "the", "event", "is", "automatically", "canceled", "by", "the", "system", "and", "its", "poll_waiter", "is", "freed", ".", "An", "event", "registered", "with", "poll_fd_callback", "()", "may", "be", "canceled", "from", "its", "time", "of", "registration", "until", "its", "callback", "is", "actually", "called", ".", "At", "that", "point", "the", "event", "is", "automatically", "canceled", "by", "the", "system", "and", "its", "poll_waiter", "is", "freed", "." ]
void poll_cancel(struct poll_waiter *pw) { if (pw) { assert(pw != running_cb); list_remove(&pw->node); free(pw->backtrace); free(pw); n_waiters--; } }
[ "void", "poll_cancel", "(", "struct", "poll_waiter", "*", "pw", ")", "{", "if", "(", "pw", ")", "{", "assert", "(", "pw", "!=", "running_cb", ")", ";", "list_remove", "(", "&", "pw", "->", "node", ")", ";", "free", "(", "pw", "->", "backtrace", ")", ";", "free", "(", "pw", ")", ";", "n_waiters", "--", ";", "}", "}" ]
Cancels the file descriptor event registered with poll_fd_wait() or poll_fd_callback().
[ "Cancels", "the", "file", "descriptor", "event", "registered", "with", "poll_fd_wait", "()", "or", "poll_fd_callback", "()", "." ]
[]
[ { "param": "pw", "type": "struct poll_waiter" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pw", "type": "struct poll_waiter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
91e961bdf34def3f802a5e26e6c500b1d06459bb
xiaolanxia/oftest_ofdpa
lib/dpif.c
[ "Apache-2.0" ]
C
dpif_open
int
int dpif_open(int subscribe_dp_idx, struct dpif *dp) { struct nl_sock *sock; int multicast_group = 0; int retval; retval = nl_lookup_genl_family(DP_GENL_FAMILY_NAME, &openflow_family); if (retval) { return retval; } if (subscribe_dp_idx >= 0) { retval = lookup_openflow_multicast_group(subscribe_dp_idx, &multicast_group); if (retval) { return retval; } } /* Specify a large so_rcvbuf size because we occasionally need to be able * to retrieve large collections of flow records. */ retval = nl_sock_create(NETLINK_GENERIC, multicast_group, 0, 4 * 1024u * 1024, &sock); if (retval) { return retval; } dp->sock = sock; return 0; }
/* Opens a socket for a local datapath, initializing 'dp'. If * 'subscribe_dp_idx' is nonnegative, listens for asynchronous messages * (packet-in, etc.) from the datapath with that number; otherwise, 'dp' will * receive only replies to explicitly initiated requests. */
Opens a socket for a local datapath, initializing 'dp'. If 'subscribe_dp_idx' is nonnegative, listens for asynchronous messages (packet-in, etc.) from the datapath with that number; otherwise, 'dp' will receive only replies to explicitly initiated requests.
[ "Opens", "a", "socket", "for", "a", "local", "datapath", "initializing", "'", "dp", "'", ".", "If", "'", "subscribe_dp_idx", "'", "is", "nonnegative", "listens", "for", "asynchronous", "messages", "(", "packet", "-", "in", "etc", ".", ")", "from", "the", "datapath", "with", "that", "number", ";", "otherwise", "'", "dp", "'", "will", "receive", "only", "replies", "to", "explicitly", "initiated", "requests", "." ]
int dpif_open(int subscribe_dp_idx, struct dpif *dp) { struct nl_sock *sock; int multicast_group = 0; int retval; retval = nl_lookup_genl_family(DP_GENL_FAMILY_NAME, &openflow_family); if (retval) { return retval; } if (subscribe_dp_idx >= 0) { retval = lookup_openflow_multicast_group(subscribe_dp_idx, &multicast_group); if (retval) { return retval; } } retval = nl_sock_create(NETLINK_GENERIC, multicast_group, 0, 4 * 1024u * 1024, &sock); if (retval) { return retval; } dp->sock = sock; return 0; }
[ "int", "dpif_open", "(", "int", "subscribe_dp_idx", ",", "struct", "dpif", "*", "dp", ")", "{", "struct", "nl_sock", "*", "sock", ";", "int", "multicast_group", "=", "0", ";", "int", "retval", ";", "retval", "=", "nl_lookup_genl_family", "(", "DP_GENL_FAMILY_NAME", ",", "&", "openflow_family", ")", ";", "if", "(", "retval", ")", "{", "return", "retval", ";", "}", "if", "(", "subscribe_dp_idx", ">=", "0", ")", "{", "retval", "=", "lookup_openflow_multicast_group", "(", "subscribe_dp_idx", ",", "&", "multicast_group", ")", ";", "if", "(", "retval", ")", "{", "return", "retval", ";", "}", "}", "retval", "=", "nl_sock_create", "(", "NETLINK_GENERIC", ",", "multicast_group", ",", "0", ",", "4", "*", "1024u", "*", "1024", ",", "&", "sock", ")", ";", "if", "(", "retval", ")", "{", "return", "retval", ";", "}", "dp", "->", "sock", "=", "sock", ";", "return", "0", ";", "}" ]
Opens a socket for a local datapath, initializing 'dp'.
[ "Opens", "a", "socket", "for", "a", "local", "datapath", "initializing", "'", "dp", "'", "." ]
[ "/* Specify a large so_rcvbuf size because we occasionally need to be able\n * to retrieve large collections of flow records. */" ]
[ { "param": "subscribe_dp_idx", "type": "int" }, { "param": "dp", "type": "struct dpif" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "subscribe_dp_idx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dp", "type": "struct dpif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
91e961bdf34def3f802a5e26e6c500b1d06459bb
xiaolanxia/oftest_ofdpa
lib/dpif.c
[ "Apache-2.0" ]
C
dpif_send_openflow
int
int dpif_send_openflow(struct dpif *dp, int dp_idx, struct ofpbuf *buffer) { struct ofp_header *oh; unsigned int dump_flag; struct ofpbuf hdr; struct nlattr *nla; uint32_t fixed_buffer[64 / 4]; struct iovec iov[3]; int pad_bytes; int n_iov; int retval; /* The reply to OFPT_MULTIPART_REQUEST may be multiple segments long, so we * need to specify NLM_F_DUMP in the request. */ oh = ofpbuf_at_assert(buffer, 0, sizeof *oh); dump_flag = oh->type == OFPT_MULTIPART_REQUEST ? NLM_F_DUMP : 0; ofpbuf_use(&hdr, fixed_buffer, sizeof fixed_buffer); nl_msg_put_genlmsghdr(&hdr, dp->sock, 32, openflow_family, NLM_F_REQUEST | dump_flag, DP_GENL_C_OPENFLOW, 1); nl_msg_put_u32(&hdr, DP_GENL_A_DP_IDX, dp_idx); nla = ofpbuf_put_uninit(&hdr, sizeof *nla); nla->nla_len = sizeof *nla + buffer->size; nla->nla_type = DP_GENL_A_OPENFLOW; pad_bytes = NLA_ALIGN(nla->nla_len) - nla->nla_len; nl_msg_nlmsghdr(&hdr)->nlmsg_len = hdr.size + buffer->size + pad_bytes; n_iov = 2; iov[0].iov_base = hdr.data; iov[0].iov_len = hdr.size; iov[1].iov_base = buffer->data; iov[1].iov_len = buffer->size; if (pad_bytes) { static char zeros[NLA_ALIGNTO]; n_iov++; iov[2].iov_base = zeros; iov[2].iov_len = pad_bytes; } retval = nl_sock_sendv(dp->sock, iov, n_iov, false); if (retval && retval != EAGAIN) { VLOG_WARN_RL(LOG_MODULE, &rl, "dpif_send_openflow: %s", strerror(retval)); } return retval; }
/* Encapsulates 'msg', which must contain an OpenFlow message, in a Netlink * message, and sends it to the OpenFlow local datapath numbered 'dp_idx' via * 'sock'. * * Returns 0 if successful, otherwise a positive errno value. Returns EAGAIN * if the 'sock' send buffer is full. * * If the send is successful, then the kernel module will receive it, but there * is no guarantee that any reply will not be dropped (see nl_sock_transact() * for details). */
Returns 0 if successful, otherwise a positive errno value. Returns EAGAIN if the 'sock' send buffer is full. If the send is successful, then the kernel module will receive it, but there is no guarantee that any reply will not be dropped for details).
[ "Returns", "0", "if", "successful", "otherwise", "a", "positive", "errno", "value", ".", "Returns", "EAGAIN", "if", "the", "'", "sock", "'", "send", "buffer", "is", "full", ".", "If", "the", "send", "is", "successful", "then", "the", "kernel", "module", "will", "receive", "it", "but", "there", "is", "no", "guarantee", "that", "any", "reply", "will", "not", "be", "dropped", "for", "details", ")", "." ]
int dpif_send_openflow(struct dpif *dp, int dp_idx, struct ofpbuf *buffer) { struct ofp_header *oh; unsigned int dump_flag; struct ofpbuf hdr; struct nlattr *nla; uint32_t fixed_buffer[64 / 4]; struct iovec iov[3]; int pad_bytes; int n_iov; int retval; oh = ofpbuf_at_assert(buffer, 0, sizeof *oh); dump_flag = oh->type == OFPT_MULTIPART_REQUEST ? NLM_F_DUMP : 0; ofpbuf_use(&hdr, fixed_buffer, sizeof fixed_buffer); nl_msg_put_genlmsghdr(&hdr, dp->sock, 32, openflow_family, NLM_F_REQUEST | dump_flag, DP_GENL_C_OPENFLOW, 1); nl_msg_put_u32(&hdr, DP_GENL_A_DP_IDX, dp_idx); nla = ofpbuf_put_uninit(&hdr, sizeof *nla); nla->nla_len = sizeof *nla + buffer->size; nla->nla_type = DP_GENL_A_OPENFLOW; pad_bytes = NLA_ALIGN(nla->nla_len) - nla->nla_len; nl_msg_nlmsghdr(&hdr)->nlmsg_len = hdr.size + buffer->size + pad_bytes; n_iov = 2; iov[0].iov_base = hdr.data; iov[0].iov_len = hdr.size; iov[1].iov_base = buffer->data; iov[1].iov_len = buffer->size; if (pad_bytes) { static char zeros[NLA_ALIGNTO]; n_iov++; iov[2].iov_base = zeros; iov[2].iov_len = pad_bytes; } retval = nl_sock_sendv(dp->sock, iov, n_iov, false); if (retval && retval != EAGAIN) { VLOG_WARN_RL(LOG_MODULE, &rl, "dpif_send_openflow: %s", strerror(retval)); } return retval; }
[ "int", "dpif_send_openflow", "(", "struct", "dpif", "*", "dp", ",", "int", "dp_idx", ",", "struct", "ofpbuf", "*", "buffer", ")", "{", "struct", "ofp_header", "*", "oh", ";", "unsigned", "int", "dump_flag", ";", "struct", "ofpbuf", "hdr", ";", "struct", "nlattr", "*", "nla", ";", "uint32_t", "fixed_buffer", "[", "64", "/", "4", "]", ";", "struct", "iovec", "iov", "[", "3", "]", ";", "int", "pad_bytes", ";", "int", "n_iov", ";", "int", "retval", ";", "oh", "=", "ofpbuf_at_assert", "(", "buffer", ",", "0", ",", "sizeof", "*", "oh", ")", ";", "dump_flag", "=", "oh", "->", "type", "==", "OFPT_MULTIPART_REQUEST", "?", "NLM_F_DUMP", ":", "0", ";", "ofpbuf_use", "(", "&", "hdr", ",", "fixed_buffer", ",", "sizeof", "fixed_buffer", ")", ";", "nl_msg_put_genlmsghdr", "(", "&", "hdr", ",", "dp", "->", "sock", ",", "32", ",", "openflow_family", ",", "NLM_F_REQUEST", "|", "dump_flag", ",", "DP_GENL_C_OPENFLOW", ",", "1", ")", ";", "nl_msg_put_u32", "(", "&", "hdr", ",", "DP_GENL_A_DP_IDX", ",", "dp_idx", ")", ";", "nla", "=", "ofpbuf_put_uninit", "(", "&", "hdr", ",", "sizeof", "*", "nla", ")", ";", "nla", "->", "nla_len", "=", "sizeof", "*", "nla", "+", "buffer", "->", "size", ";", "nla", "->", "nla_type", "=", "DP_GENL_A_OPENFLOW", ";", "pad_bytes", "=", "NLA_ALIGN", "(", "nla", "->", "nla_len", ")", "-", "nla", "->", "nla_len", ";", "nl_msg_nlmsghdr", "(", "&", "hdr", ")", "->", "nlmsg_len", "=", "hdr", ".", "size", "+", "buffer", "->", "size", "+", "pad_bytes", ";", "n_iov", "=", "2", ";", "iov", "[", "0", "]", ".", "iov_base", "=", "hdr", ".", "data", ";", "iov", "[", "0", "]", ".", "iov_len", "=", "hdr", ".", "size", ";", "iov", "[", "1", "]", ".", "iov_base", "=", "buffer", "->", "data", ";", "iov", "[", "1", "]", ".", "iov_len", "=", "buffer", "->", "size", ";", "if", "(", "pad_bytes", ")", "{", "static", "char", "zeros", "[", "NLA_ALIGNTO", "]", ";", "n_iov", "++", ";", "iov", "[", "2", "]", ".", "iov_base", "=", "zeros", ";", "iov", "[", "2", "]", ".", "iov_len", "=", "pad_bytes", ";", "}", "retval", "=", "nl_sock_sendv", "(", "dp", "->", "sock", ",", "iov", ",", "n_iov", ",", "false", ")", ";", "if", "(", "retval", "&&", "retval", "!=", "EAGAIN", ")", "{", "VLOG_WARN_RL", "(", "LOG_MODULE", ",", "&", "rl", ",", "\"", "\"", ",", "strerror", "(", "retval", ")", ")", ";", "}", "return", "retval", ";", "}" ]
Encapsulates 'msg', which must contain an OpenFlow message, in a Netlink message, and sends it to the OpenFlow local datapath numbered 'dp_idx' via 'sock'.
[ "Encapsulates", "'", "msg", "'", "which", "must", "contain", "an", "OpenFlow", "message", "in", "a", "Netlink", "message", "and", "sends", "it", "to", "the", "OpenFlow", "local", "datapath", "numbered", "'", "dp_idx", "'", "via", "'", "sock", "'", "." ]
[ "/* The reply to OFPT_MULTIPART_REQUEST may be multiple segments long, so we\n * need to specify NLM_F_DUMP in the request. */" ]
[ { "param": "dp", "type": "struct dpif" }, { "param": "dp_idx", "type": "int" }, { "param": "buffer", "type": "struct ofpbuf" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dp", "type": "struct dpif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dp_idx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buffer", "type": "struct ofpbuf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
91e961bdf34def3f802a5e26e6c500b1d06459bb
xiaolanxia/oftest_ofdpa
lib/dpif.c
[ "Apache-2.0" ]
C
dpif_add_dp
int
int dpif_add_dp(struct dpif *dp, int dp_idx, const char *dp_name) { return send_mgmt_command(dp, dp_idx, DP_GENL_C_ADD_DP, dp_name); }
/* Creates local datapath numbered 'dp_idx' with the name 'dp_name'. A * 'dp_idx' of -1 or null 'dp_name' will have the kernel module choose values. * (At least one or the other must be provided, however, so that the caller can * identify the datapath that was created.) Returns 0 if successful, otherwise * a positive errno value. */
Creates local datapath numbered 'dp_idx' with the name 'dp_name'. A 'dp_idx' of -1 or null 'dp_name' will have the kernel module choose values. (At least one or the other must be provided, however, so that the caller can identify the datapath that was created.) Returns 0 if successful, otherwise a positive errno value.
[ "Creates", "local", "datapath", "numbered", "'", "dp_idx", "'", "with", "the", "name", "'", "dp_name", "'", ".", "A", "'", "dp_idx", "'", "of", "-", "1", "or", "null", "'", "dp_name", "'", "will", "have", "the", "kernel", "module", "choose", "values", ".", "(", "At", "least", "one", "or", "the", "other", "must", "be", "provided", "however", "so", "that", "the", "caller", "can", "identify", "the", "datapath", "that", "was", "created", ".", ")", "Returns", "0", "if", "successful", "otherwise", "a", "positive", "errno", "value", "." ]
int dpif_add_dp(struct dpif *dp, int dp_idx, const char *dp_name) { return send_mgmt_command(dp, dp_idx, DP_GENL_C_ADD_DP, dp_name); }
[ "int", "dpif_add_dp", "(", "struct", "dpif", "*", "dp", ",", "int", "dp_idx", ",", "const", "char", "*", "dp_name", ")", "{", "return", "send_mgmt_command", "(", "dp", ",", "dp_idx", ",", "DP_GENL_C_ADD_DP", ",", "dp_name", ")", ";", "}" ]
Creates local datapath numbered 'dp_idx' with the name 'dp_name'.
[ "Creates", "local", "datapath", "numbered", "'", "dp_idx", "'", "with", "the", "name", "'", "dp_name", "'", "." ]
[]
[ { "param": "dp", "type": "struct dpif" }, { "param": "dp_idx", "type": "int" }, { "param": "dp_name", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dp", "type": "struct dpif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dp_idx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dp_name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
91e961bdf34def3f802a5e26e6c500b1d06459bb
xiaolanxia/oftest_ofdpa
lib/dpif.c
[ "Apache-2.0" ]
C
dpif_add_port
int
int dpif_add_port(struct dpif *dp, int dp_idx, const char *netdev) { return send_mgmt_command(dp, dp_idx, DP_GENL_C_ADD_PORT, netdev); }
/* Adds the Ethernet device named 'netdev' to the local datapath numbered * 'dp_idx'. Returns 0 if successful, otherwise a positive errno value. */
Adds the Ethernet device named 'netdev' to the local datapath numbered 'dp_idx'. Returns 0 if successful, otherwise a positive errno value.
[ "Adds", "the", "Ethernet", "device", "named", "'", "netdev", "'", "to", "the", "local", "datapath", "numbered", "'", "dp_idx", "'", ".", "Returns", "0", "if", "successful", "otherwise", "a", "positive", "errno", "value", "." ]
int dpif_add_port(struct dpif *dp, int dp_idx, const char *netdev) { return send_mgmt_command(dp, dp_idx, DP_GENL_C_ADD_PORT, netdev); }
[ "int", "dpif_add_port", "(", "struct", "dpif", "*", "dp", ",", "int", "dp_idx", ",", "const", "char", "*", "netdev", ")", "{", "return", "send_mgmt_command", "(", "dp", ",", "dp_idx", ",", "DP_GENL_C_ADD_PORT", ",", "netdev", ")", ";", "}" ]
Adds the Ethernet device named 'netdev' to the local datapath numbered 'dp_idx'.
[ "Adds", "the", "Ethernet", "device", "named", "'", "netdev", "'", "to", "the", "local", "datapath", "numbered", "'", "dp_idx", "'", "." ]
[]
[ { "param": "dp", "type": "struct dpif" }, { "param": "dp_idx", "type": "int" }, { "param": "netdev", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dp", "type": "struct dpif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dp_idx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "netdev", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
91e961bdf34def3f802a5e26e6c500b1d06459bb
xiaolanxia/oftest_ofdpa
lib/dpif.c
[ "Apache-2.0" ]
C
dpif_del_port
int
int dpif_del_port(struct dpif *dp, int dp_idx, const char *netdev) { return send_mgmt_command(dp, dp_idx, DP_GENL_C_DEL_PORT, netdev); }
/* Removes the Ethernet device named 'netdev' from the local datapath numbered * 'dp_idx'. Returns 0 if successful, otherwise a positive errno value. */
Removes the Ethernet device named 'netdev' from the local datapath numbered 'dp_idx'. Returns 0 if successful, otherwise a positive errno value.
[ "Removes", "the", "Ethernet", "device", "named", "'", "netdev", "'", "from", "the", "local", "datapath", "numbered", "'", "dp_idx", "'", ".", "Returns", "0", "if", "successful", "otherwise", "a", "positive", "errno", "value", "." ]
int dpif_del_port(struct dpif *dp, int dp_idx, const char *netdev) { return send_mgmt_command(dp, dp_idx, DP_GENL_C_DEL_PORT, netdev); }
[ "int", "dpif_del_port", "(", "struct", "dpif", "*", "dp", ",", "int", "dp_idx", ",", "const", "char", "*", "netdev", ")", "{", "return", "send_mgmt_command", "(", "dp", ",", "dp_idx", ",", "DP_GENL_C_DEL_PORT", ",", "netdev", ")", ";", "}" ]
Removes the Ethernet device named 'netdev' from the local datapath numbered 'dp_idx'.
[ "Removes", "the", "Ethernet", "device", "named", "'", "netdev", "'", "from", "the", "local", "datapath", "numbered", "'", "dp_idx", "'", "." ]
[]
[ { "param": "dp", "type": "struct dpif" }, { "param": "dp_idx", "type": "int" }, { "param": "netdev", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dp", "type": "struct dpif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dp_idx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "netdev", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
91e961bdf34def3f802a5e26e6c500b1d06459bb
xiaolanxia/oftest_ofdpa
lib/dpif.c
[ "Apache-2.0" ]
C
query_datapath
int
static int query_datapath(int *dp_idx, int *multicast_group, const char *dp_name) { struct nl_sock *sock; struct ofpbuf request, *reply; struct nlattr *attrs[ARRAY_SIZE(openflow_multicast_policy)]; int retval; retval = nl_sock_create(NETLINK_GENERIC, 0, 0, 0, &sock); if (retval) { return retval; } ofpbuf_init(&request, 0); nl_msg_put_genlmsghdr(&request, sock, 0, openflow_family, NLM_F_REQUEST, DP_GENL_C_QUERY_DP, 1); if (*dp_idx != -1) { nl_msg_put_u32(&request, DP_GENL_A_DP_IDX, *dp_idx); } if (dp_name) { nl_msg_put_string(&request, DP_GENL_A_DP_NAME, dp_name); } retval = nl_sock_transact(sock, &request, &reply); ofpbuf_uninit(&request); if (retval) { nl_sock_destroy(sock); return retval; } if (!nl_policy_parse(reply, NLMSG_HDRLEN + GENL_HDRLEN, openflow_multicast_policy, attrs, ARRAY_SIZE(openflow_multicast_policy))) { nl_sock_destroy(sock); ofpbuf_delete(reply); return EPROTO; } *dp_idx = nl_attr_get_u32(attrs[DP_GENL_A_DP_IDX]); *multicast_group = nl_attr_get_u32(attrs[DP_GENL_A_MC_GROUP]); nl_sock_destroy(sock); ofpbuf_delete(reply); return 0; }
/* Looks up the Netlink multicast group and datapath index of a datapath * by either the datapath index or name. If 'dp_idx' points to a value * of '-1', then 'dp_name' is used to lookup the datapath. If successful, * stores the multicast group in '*multicast_group' and the index in * '*dp_idx' and returns 0. Otherwise, returns a positive errno value. */
Looks up the Netlink multicast group and datapath index of a datapath by either the datapath index or name.
[ "Looks", "up", "the", "Netlink", "multicast", "group", "and", "datapath", "index", "of", "a", "datapath", "by", "either", "the", "datapath", "index", "or", "name", "." ]
static int query_datapath(int *dp_idx, int *multicast_group, const char *dp_name) { struct nl_sock *sock; struct ofpbuf request, *reply; struct nlattr *attrs[ARRAY_SIZE(openflow_multicast_policy)]; int retval; retval = nl_sock_create(NETLINK_GENERIC, 0, 0, 0, &sock); if (retval) { return retval; } ofpbuf_init(&request, 0); nl_msg_put_genlmsghdr(&request, sock, 0, openflow_family, NLM_F_REQUEST, DP_GENL_C_QUERY_DP, 1); if (*dp_idx != -1) { nl_msg_put_u32(&request, DP_GENL_A_DP_IDX, *dp_idx); } if (dp_name) { nl_msg_put_string(&request, DP_GENL_A_DP_NAME, dp_name); } retval = nl_sock_transact(sock, &request, &reply); ofpbuf_uninit(&request); if (retval) { nl_sock_destroy(sock); return retval; } if (!nl_policy_parse(reply, NLMSG_HDRLEN + GENL_HDRLEN, openflow_multicast_policy, attrs, ARRAY_SIZE(openflow_multicast_policy))) { nl_sock_destroy(sock); ofpbuf_delete(reply); return EPROTO; } *dp_idx = nl_attr_get_u32(attrs[DP_GENL_A_DP_IDX]); *multicast_group = nl_attr_get_u32(attrs[DP_GENL_A_MC_GROUP]); nl_sock_destroy(sock); ofpbuf_delete(reply); return 0; }
[ "static", "int", "query_datapath", "(", "int", "*", "dp_idx", ",", "int", "*", "multicast_group", ",", "const", "char", "*", "dp_name", ")", "{", "struct", "nl_sock", "*", "sock", ";", "struct", "ofpbuf", "request", ",", "*", "reply", ";", "struct", "nlattr", "*", "attrs", "[", "ARRAY_SIZE", "(", "openflow_multicast_policy", ")", "]", ";", "int", "retval", ";", "retval", "=", "nl_sock_create", "(", "NETLINK_GENERIC", ",", "0", ",", "0", ",", "0", ",", "&", "sock", ")", ";", "if", "(", "retval", ")", "{", "return", "retval", ";", "}", "ofpbuf_init", "(", "&", "request", ",", "0", ")", ";", "nl_msg_put_genlmsghdr", "(", "&", "request", ",", "sock", ",", "0", ",", "openflow_family", ",", "NLM_F_REQUEST", ",", "DP_GENL_C_QUERY_DP", ",", "1", ")", ";", "if", "(", "*", "dp_idx", "!=", "-1", ")", "{", "nl_msg_put_u32", "(", "&", "request", ",", "DP_GENL_A_DP_IDX", ",", "*", "dp_idx", ")", ";", "}", "if", "(", "dp_name", ")", "{", "nl_msg_put_string", "(", "&", "request", ",", "DP_GENL_A_DP_NAME", ",", "dp_name", ")", ";", "}", "retval", "=", "nl_sock_transact", "(", "sock", ",", "&", "request", ",", "&", "reply", ")", ";", "ofpbuf_uninit", "(", "&", "request", ")", ";", "if", "(", "retval", ")", "{", "nl_sock_destroy", "(", "sock", ")", ";", "return", "retval", ";", "}", "if", "(", "!", "nl_policy_parse", "(", "reply", ",", "NLMSG_HDRLEN", "+", "GENL_HDRLEN", ",", "openflow_multicast_policy", ",", "attrs", ",", "ARRAY_SIZE", "(", "openflow_multicast_policy", ")", ")", ")", "{", "nl_sock_destroy", "(", "sock", ")", ";", "ofpbuf_delete", "(", "reply", ")", ";", "return", "EPROTO", ";", "}", "*", "dp_idx", "=", "nl_attr_get_u32", "(", "attrs", "[", "DP_GENL_A_DP_IDX", "]", ")", ";", "*", "multicast_group", "=", "nl_attr_get_u32", "(", "attrs", "[", "DP_GENL_A_MC_GROUP", "]", ")", ";", "nl_sock_destroy", "(", "sock", ")", ";", "ofpbuf_delete", "(", "reply", ")", ";", "return", "0", ";", "}" ]
Looks up the Netlink multicast group and datapath index of a datapath by either the datapath index or name.
[ "Looks", "up", "the", "Netlink", "multicast", "group", "and", "datapath", "index", "of", "a", "datapath", "by", "either", "the", "datapath", "index", "or", "name", "." ]
[]
[ { "param": "dp_idx", "type": "int" }, { "param": "multicast_group", "type": "int" }, { "param": "dp_name", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dp_idx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "multicast_group", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dp_name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
91e961bdf34def3f802a5e26e6c500b1d06459bb
xiaolanxia/oftest_ofdpa
lib/dpif.c
[ "Apache-2.0" ]
C
lookup_openflow_multicast_group
int
static int lookup_openflow_multicast_group(int dp_idx, int *multicast_group) { return query_datapath(&dp_idx, multicast_group, NULL); }
/* Looks up the Netlink multicast group used by datapath 'dp_idx'. If * successful, stores the multicast group in '*multicast_group' and returns 0. * Otherwise, returns a positve errno value. */
Looks up the Netlink multicast group used by datapath 'dp_idx'. If successful, stores the multicast group in '*multicast_group' and returns 0. Otherwise, returns a positve errno value.
[ "Looks", "up", "the", "Netlink", "multicast", "group", "used", "by", "datapath", "'", "dp_idx", "'", ".", "If", "successful", "stores", "the", "multicast", "group", "in", "'", "*", "multicast_group", "'", "and", "returns", "0", ".", "Otherwise", "returns", "a", "positve", "errno", "value", "." ]
static int lookup_openflow_multicast_group(int dp_idx, int *multicast_group) { return query_datapath(&dp_idx, multicast_group, NULL); }
[ "static", "int", "lookup_openflow_multicast_group", "(", "int", "dp_idx", ",", "int", "*", "multicast_group", ")", "{", "return", "query_datapath", "(", "&", "dp_idx", ",", "multicast_group", ",", "NULL", ")", ";", "}" ]
Looks up the Netlink multicast group used by datapath 'dp_idx'.
[ "Looks", "up", "the", "Netlink", "multicast", "group", "used", "by", "datapath", "'", "dp_idx", "'", "." ]
[]
[ { "param": "dp_idx", "type": "int" }, { "param": "multicast_group", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dp_idx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "multicast_group", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
91e961bdf34def3f802a5e26e6c500b1d06459bb
xiaolanxia/oftest_ofdpa
lib/dpif.c
[ "Apache-2.0" ]
C
dpif_get_idx
int
int dpif_get_idx(const char *name) { int dp_idx = -1; int mc_group = 0; if (query_datapath(&dp_idx, &mc_group, name)) { return -1; } return dp_idx; }
/* Looks up the datatpath index based on the name. Returns the index, or * -1 on error. */
Looks up the datatpath index based on the name. Returns the index, or -1 on error.
[ "Looks", "up", "the", "datatpath", "index", "based", "on", "the", "name", ".", "Returns", "the", "index", "or", "-", "1", "on", "error", "." ]
int dpif_get_idx(const char *name) { int dp_idx = -1; int mc_group = 0; if (query_datapath(&dp_idx, &mc_group, name)) { return -1; } return dp_idx; }
[ "int", "dpif_get_idx", "(", "const", "char", "*", "name", ")", "{", "int", "dp_idx", "=", "-1", ";", "int", "mc_group", "=", "0", ";", "if", "(", "query_datapath", "(", "&", "dp_idx", ",", "&", "mc_group", ",", "name", ")", ")", "{", "return", "-1", ";", "}", "return", "dp_idx", ";", "}" ]
Looks up the datatpath index based on the name.
[ "Looks", "up", "the", "datatpath", "index", "based", "on", "the", "name", "." ]
[]
[ { "param": "name", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3f1908dc47187f88b712bf061bfc502a09b14f83
xiaolanxia/oftest_ofdpa
lib/svec.c
[ "Apache-2.0" ]
C
svec_parse_words
void
void svec_parse_words(struct svec *svec, const char *words) { struct ds word = DS_EMPTY_INITIALIZER; const char *p, *q; for (p = words; *p != '\0'; p = q) { int quote = 0; while (isspace((unsigned char) *p)) { p++; } if (*p == '\0') { break; } ds_clear(&word); for (q = p; *q != '\0'; q++) { if (*q == quote) { quote = 0; } else if (*q == '\'' || *q == '"') { quote = *q; } else if (*q == '\\' && (!quote || quote == '"')) { q++; if (*q == '\0') { VLOG_WARN(LOG_MODULE, "%s: ends in trailing backslash", words); break; } ds_put_char(&word, *q); } else if (isspace((unsigned char) *q) && !quote) { q++; break; } else { ds_put_char(&word, *q); } } svec_add(svec, ds_cstr(&word)); if (quote) { VLOG_WARN(LOG_MODULE, "%s: word ends inside quoted string", words); } } ds_destroy(&word); }
/* Breaks 'words' into words at white space, respecting shell-like quoting * conventions, and appends the words to 'svec'. */
Breaks 'words' into words at white space, respecting shell-like quoting conventions, and appends the words to 'svec'.
[ "Breaks", "'", "words", "'", "into", "words", "at", "white", "space", "respecting", "shell", "-", "like", "quoting", "conventions", "and", "appends", "the", "words", "to", "'", "svec", "'", "." ]
void svec_parse_words(struct svec *svec, const char *words) { struct ds word = DS_EMPTY_INITIALIZER; const char *p, *q; for (p = words; *p != '\0'; p = q) { int quote = 0; while (isspace((unsigned char) *p)) { p++; } if (*p == '\0') { break; } ds_clear(&word); for (q = p; *q != '\0'; q++) { if (*q == quote) { quote = 0; } else if (*q == '\'' || *q == '"') { quote = *q; } else if (*q == '\\' && (!quote || quote == '"')) { q++; if (*q == '\0') { VLOG_WARN(LOG_MODULE, "%s: ends in trailing backslash", words); break; } ds_put_char(&word, *q); } else if (isspace((unsigned char) *q) && !quote) { q++; break; } else { ds_put_char(&word, *q); } } svec_add(svec, ds_cstr(&word)); if (quote) { VLOG_WARN(LOG_MODULE, "%s: word ends inside quoted string", words); } } ds_destroy(&word); }
[ "void", "svec_parse_words", "(", "struct", "svec", "*", "svec", ",", "const", "char", "*", "words", ")", "{", "struct", "ds", "word", "=", "DS_EMPTY_INITIALIZER", ";", "const", "char", "*", "p", ",", "*", "q", ";", "for", "(", "p", "=", "words", ";", "*", "p", "!=", "'", "\\0", "'", ";", "p", "=", "q", ")", "{", "int", "quote", "=", "0", ";", "while", "(", "isspace", "(", "(", "unsigned", "char", ")", "*", "p", ")", ")", "{", "p", "++", ";", "}", "if", "(", "*", "p", "==", "'", "\\0", "'", ")", "{", "break", ";", "}", "ds_clear", "(", "&", "word", ")", ";", "for", "(", "q", "=", "p", ";", "*", "q", "!=", "'", "\\0", "'", ";", "q", "++", ")", "{", "if", "(", "*", "q", "==", "quote", ")", "{", "quote", "=", "0", ";", "}", "else", "if", "(", "*", "q", "==", "'", "\\'", "'", "||", "*", "q", "==", "'", "'", ")", "{", "quote", "=", "*", "q", ";", "}", "else", "if", "(", "*", "q", "==", "'", "\\\\", "'", "&&", "(", "!", "quote", "||", "quote", "==", "'", "'", ")", ")", "{", "q", "++", ";", "if", "(", "*", "q", "==", "'", "\\0", "'", ")", "{", "VLOG_WARN", "(", "LOG_MODULE", ",", "\"", "\"", ",", "words", ")", ";", "break", ";", "}", "ds_put_char", "(", "&", "word", ",", "*", "q", ")", ";", "}", "else", "if", "(", "isspace", "(", "(", "unsigned", "char", ")", "*", "q", ")", "&&", "!", "quote", ")", "{", "q", "++", ";", "break", ";", "}", "else", "{", "ds_put_char", "(", "&", "word", ",", "*", "q", ")", ";", "}", "}", "svec_add", "(", "svec", ",", "ds_cstr", "(", "&", "word", ")", ")", ";", "if", "(", "quote", ")", "{", "VLOG_WARN", "(", "LOG_MODULE", ",", "\"", "\"", ",", "words", ")", ";", "}", "}", "ds_destroy", "(", "&", "word", ")", ";", "}" ]
Breaks 'words' into words at white space, respecting shell-like quoting conventions, and appends the words to 'svec'.
[ "Breaks", "'", "words", "'", "into", "words", "at", "white", "space", "respecting", "shell", "-", "like", "quoting", "conventions", "and", "appends", "the", "words", "to", "'", "svec", "'", "." ]
[]
[ { "param": "svec", "type": "struct svec" }, { "param": "words", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "svec", "type": "struct svec", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "words", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
59446bb1f1a2aa3da1baa3055db7d97e1044fd7d
xiaolanxia/oftest_ofdpa
udatapath/group_table.c
[ "Apache-2.0" ]
C
group_table_add
ofl_err
static ofl_err group_table_add(struct group_table *table, struct ofl_msg_group_mod *mod) { struct group_entry *entry; if (hmap_first_with_hash(&table->entries, mod->group_id) != NULL) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_GROUP_EXISTS); } if (table->entries_num == GROUP_TABLE_MAX_ENTRIES) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_OUT_OF_GROUPS); } if (table->buckets_num + mod->buckets_num > GROUP_TABLE_MAX_BUCKETS) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_OUT_OF_BUCKETS); } entry = group_entry_create(table->dp, table, mod); hmap_insert(&table->entries, &entry->node, entry->stats->group_id); table->entries_num++; table->buckets_num += entry->desc->buckets_num; ofl_msg_free_group_mod(mod, false, table->dp->exp); return 0; }
/* Handles group mod messages with ADD command. */
Handles group mod messages with ADD command.
[ "Handles", "group", "mod", "messages", "with", "ADD", "command", "." ]
static ofl_err group_table_add(struct group_table *table, struct ofl_msg_group_mod *mod) { struct group_entry *entry; if (hmap_first_with_hash(&table->entries, mod->group_id) != NULL) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_GROUP_EXISTS); } if (table->entries_num == GROUP_TABLE_MAX_ENTRIES) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_OUT_OF_GROUPS); } if (table->buckets_num + mod->buckets_num > GROUP_TABLE_MAX_BUCKETS) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_OUT_OF_BUCKETS); } entry = group_entry_create(table->dp, table, mod); hmap_insert(&table->entries, &entry->node, entry->stats->group_id); table->entries_num++; table->buckets_num += entry->desc->buckets_num; ofl_msg_free_group_mod(mod, false, table->dp->exp); return 0; }
[ "static", "ofl_err", "group_table_add", "(", "struct", "group_table", "*", "table", ",", "struct", "ofl_msg_group_mod", "*", "mod", ")", "{", "struct", "group_entry", "*", "entry", ";", "if", "(", "hmap_first_with_hash", "(", "&", "table", "->", "entries", ",", "mod", "->", "group_id", ")", "!=", "NULL", ")", "{", "return", "ofl_error", "(", "OFPET_GROUP_MOD_FAILED", ",", "OFPGMFC_GROUP_EXISTS", ")", ";", "}", "if", "(", "table", "->", "entries_num", "==", "GROUP_TABLE_MAX_ENTRIES", ")", "{", "return", "ofl_error", "(", "OFPET_GROUP_MOD_FAILED", ",", "OFPGMFC_OUT_OF_GROUPS", ")", ";", "}", "if", "(", "table", "->", "buckets_num", "+", "mod", "->", "buckets_num", ">", "GROUP_TABLE_MAX_BUCKETS", ")", "{", "return", "ofl_error", "(", "OFPET_GROUP_MOD_FAILED", ",", "OFPGMFC_OUT_OF_BUCKETS", ")", ";", "}", "entry", "=", "group_entry_create", "(", "table", "->", "dp", ",", "table", ",", "mod", ")", ";", "hmap_insert", "(", "&", "table", "->", "entries", ",", "&", "entry", "->", "node", ",", "entry", "->", "stats", "->", "group_id", ")", ";", "table", "->", "entries_num", "++", ";", "table", "->", "buckets_num", "+=", "entry", "->", "desc", "->", "buckets_num", ";", "ofl_msg_free_group_mod", "(", "mod", ",", "false", ",", "table", "->", "dp", "->", "exp", ")", ";", "return", "0", ";", "}" ]
Handles group mod messages with ADD command.
[ "Handles", "group", "mod", "messages", "with", "ADD", "command", "." ]
[]
[ { "param": "table", "type": "struct group_table" }, { "param": "mod", "type": "struct ofl_msg_group_mod" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "table", "type": "struct group_table", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mod", "type": "struct ofl_msg_group_mod", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
59446bb1f1a2aa3da1baa3055db7d97e1044fd7d
xiaolanxia/oftest_ofdpa
udatapath/group_table.c
[ "Apache-2.0" ]
C
group_table_modify
ofl_err
static ofl_err group_table_modify(struct group_table *table, struct ofl_msg_group_mod *mod) { struct group_entry *entry, *new_entry; entry = group_table_find(table, mod->group_id); if (entry == NULL) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_UNKNOWN_GROUP); } if (table->buckets_num - entry->desc->buckets_num + mod->buckets_num > GROUP_TABLE_MAX_BUCKETS) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_OUT_OF_BUCKETS); } if (!is_loop_free(table, mod)) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_LOOP); } new_entry = group_entry_create(table->dp, table, mod); hmap_remove(&table->entries, &entry->node); hmap_insert_fast(&table->entries, &new_entry->node, mod->group_id); table->buckets_num = table->buckets_num - entry->desc->buckets_num + new_entry->desc->buckets_num; /* keep flow references from old group entry */ list_replace(&new_entry->flow_refs, &entry->flow_refs); list_init(&entry->flow_refs); group_entry_destroy(entry); ofl_msg_free_group_mod(mod, false, table->dp->exp); return 0; }
/* Handles group_mod messages with MODIFY command. */
Handles group_mod messages with MODIFY command.
[ "Handles", "group_mod", "messages", "with", "MODIFY", "command", "." ]
static ofl_err group_table_modify(struct group_table *table, struct ofl_msg_group_mod *mod) { struct group_entry *entry, *new_entry; entry = group_table_find(table, mod->group_id); if (entry == NULL) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_UNKNOWN_GROUP); } if (table->buckets_num - entry->desc->buckets_num + mod->buckets_num > GROUP_TABLE_MAX_BUCKETS) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_OUT_OF_BUCKETS); } if (!is_loop_free(table, mod)) { return ofl_error(OFPET_GROUP_MOD_FAILED, OFPGMFC_LOOP); } new_entry = group_entry_create(table->dp, table, mod); hmap_remove(&table->entries, &entry->node); hmap_insert_fast(&table->entries, &new_entry->node, mod->group_id); table->buckets_num = table->buckets_num - entry->desc->buckets_num + new_entry->desc->buckets_num; list_replace(&new_entry->flow_refs, &entry->flow_refs); list_init(&entry->flow_refs); group_entry_destroy(entry); ofl_msg_free_group_mod(mod, false, table->dp->exp); return 0; }
[ "static", "ofl_err", "group_table_modify", "(", "struct", "group_table", "*", "table", ",", "struct", "ofl_msg_group_mod", "*", "mod", ")", "{", "struct", "group_entry", "*", "entry", ",", "*", "new_entry", ";", "entry", "=", "group_table_find", "(", "table", ",", "mod", "->", "group_id", ")", ";", "if", "(", "entry", "==", "NULL", ")", "{", "return", "ofl_error", "(", "OFPET_GROUP_MOD_FAILED", ",", "OFPGMFC_UNKNOWN_GROUP", ")", ";", "}", "if", "(", "table", "->", "buckets_num", "-", "entry", "->", "desc", "->", "buckets_num", "+", "mod", "->", "buckets_num", ">", "GROUP_TABLE_MAX_BUCKETS", ")", "{", "return", "ofl_error", "(", "OFPET_GROUP_MOD_FAILED", ",", "OFPGMFC_OUT_OF_BUCKETS", ")", ";", "}", "if", "(", "!", "is_loop_free", "(", "table", ",", "mod", ")", ")", "{", "return", "ofl_error", "(", "OFPET_GROUP_MOD_FAILED", ",", "OFPGMFC_LOOP", ")", ";", "}", "new_entry", "=", "group_entry_create", "(", "table", "->", "dp", ",", "table", ",", "mod", ")", ";", "hmap_remove", "(", "&", "table", "->", "entries", ",", "&", "entry", "->", "node", ")", ";", "hmap_insert_fast", "(", "&", "table", "->", "entries", ",", "&", "new_entry", "->", "node", ",", "mod", "->", "group_id", ")", ";", "table", "->", "buckets_num", "=", "table", "->", "buckets_num", "-", "entry", "->", "desc", "->", "buckets_num", "+", "new_entry", "->", "desc", "->", "buckets_num", ";", "list_replace", "(", "&", "new_entry", "->", "flow_refs", ",", "&", "entry", "->", "flow_refs", ")", ";", "list_init", "(", "&", "entry", "->", "flow_refs", ")", ";", "group_entry_destroy", "(", "entry", ")", ";", "ofl_msg_free_group_mod", "(", "mod", ",", "false", ",", "table", "->", "dp", "->", "exp", ")", ";", "return", "0", ";", "}" ]
Handles group_mod messages with MODIFY command.
[ "Handles", "group_mod", "messages", "with", "MODIFY", "command", "." ]
[ "/* keep flow references from old group entry */" ]
[ { "param": "table", "type": "struct group_table" }, { "param": "mod", "type": "struct ofl_msg_group_mod" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "table", "type": "struct group_table", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mod", "type": "struct ofl_msg_group_mod", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b116dd790cbec17364dc016f4e9def5243052f28
xiaolanxia/oftest_ofdpa
lib/mac-learning.c
[ "Apache-2.0" ]
C
mac_learning_create
null
struct mac_learning * mac_learning_create(void) { struct mac_learning *ml; int i; ml = xmalloc(sizeof *ml); list_init(&ml->lrus); list_init(&ml->free); for (i = 0; i < MAC_HASH_SIZE; i++) { list_init(&ml->table[i]); } for (i = 0; i < MAC_MAX; i++) { struct mac_entry *s = &ml->entries[i]; list_push_front(&ml->free, &s->lru_node); } ml->secret = random_uint32(); return ml; }
/* Creates and returns a new MAC learning table. */
Creates and returns a new MAC learning table.
[ "Creates", "and", "returns", "a", "new", "MAC", "learning", "table", "." ]
struct mac_learning * mac_learning_create(void) { struct mac_learning *ml; int i; ml = xmalloc(sizeof *ml); list_init(&ml->lrus); list_init(&ml->free); for (i = 0; i < MAC_HASH_SIZE; i++) { list_init(&ml->table[i]); } for (i = 0; i < MAC_MAX; i++) { struct mac_entry *s = &ml->entries[i]; list_push_front(&ml->free, &s->lru_node); } ml->secret = random_uint32(); return ml; }
[ "struct", "mac_learning", "*", "mac_learning_create", "(", "void", ")", "{", "struct", "mac_learning", "*", "ml", ";", "int", "i", ";", "ml", "=", "xmalloc", "(", "sizeof", "*", "ml", ")", ";", "list_init", "(", "&", "ml", "->", "lrus", ")", ";", "list_init", "(", "&", "ml", "->", "free", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "MAC_HASH_SIZE", ";", "i", "++", ")", "{", "list_init", "(", "&", "ml", "->", "table", "[", "i", "]", ")", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "MAC_MAX", ";", "i", "++", ")", "{", "struct", "mac_entry", "*", "s", "=", "&", "ml", "->", "entries", "[", "i", "]", ";", "list_push_front", "(", "&", "ml", "->", "free", ",", "&", "s", "->", "lru_node", ")", ";", "}", "ml", "->", "secret", "=", "random_uint32", "(", ")", ";", "return", "ml", ";", "}" ]
Creates and returns a new MAC learning table.
[ "Creates", "and", "returns", "a", "new", "MAC", "learning", "table", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
b116dd790cbec17364dc016f4e9def5243052f28
xiaolanxia/oftest_ofdpa
lib/mac-learning.c
[ "Apache-2.0" ]
C
mac_learning_lookup_tag
uint32_t
uint32_t mac_learning_lookup_tag(const struct mac_learning *ml, const uint8_t dst[ETH_ADDR_LEN], uint16_t vlan, tag_type *tag) { if (eth_addr_is_multicast(dst)) { return OFPP_FLOOD; } else { struct mac_entry *e = search_bucket(mac_table_bucket(ml, dst, vlan), dst, vlan); if (e) { *tag |= e->tag; return e->port; } else { *tag |= make_unknown_mac_tag(ml, dst, vlan); return OFPP_FLOOD; } } }
/* Looks up MAC 'dst' for VLAN 'vlan' in 'ml'. Returns the port on which a * frame destined for 'dst' should be sent, OFPP_FLOOD if unknown. * * Adds to '*tag' (which the caller must have initialized) the tag that should * be attached to any flow created based on the return value, if any, to allow * those flows to be revalidated when the MAC learning entry changes. */
Adds to '*tag' (which the caller must have initialized) the tag that should be attached to any flow created based on the return value, if any, to allow those flows to be revalidated when the MAC learning entry changes.
[ "Adds", "to", "'", "*", "tag", "'", "(", "which", "the", "caller", "must", "have", "initialized", ")", "the", "tag", "that", "should", "be", "attached", "to", "any", "flow", "created", "based", "on", "the", "return", "value", "if", "any", "to", "allow", "those", "flows", "to", "be", "revalidated", "when", "the", "MAC", "learning", "entry", "changes", "." ]
uint32_t mac_learning_lookup_tag(const struct mac_learning *ml, const uint8_t dst[ETH_ADDR_LEN], uint16_t vlan, tag_type *tag) { if (eth_addr_is_multicast(dst)) { return OFPP_FLOOD; } else { struct mac_entry *e = search_bucket(mac_table_bucket(ml, dst, vlan), dst, vlan); if (e) { *tag |= e->tag; return e->port; } else { *tag |= make_unknown_mac_tag(ml, dst, vlan); return OFPP_FLOOD; } } }
[ "uint32_t", "mac_learning_lookup_tag", "(", "const", "struct", "mac_learning", "*", "ml", ",", "const", "uint8_t", "dst", "[", "ETH_ADDR_LEN", "]", ",", "uint16_t", "vlan", ",", "tag_type", "*", "tag", ")", "{", "if", "(", "eth_addr_is_multicast", "(", "dst", ")", ")", "{", "return", "OFPP_FLOOD", ";", "}", "else", "{", "struct", "mac_entry", "*", "e", "=", "search_bucket", "(", "mac_table_bucket", "(", "ml", ",", "dst", ",", "vlan", ")", ",", "dst", ",", "vlan", ")", ";", "if", "(", "e", ")", "{", "*", "tag", "|=", "e", "->", "tag", ";", "return", "e", "->", "port", ";", "}", "else", "{", "*", "tag", "|=", "make_unknown_mac_tag", "(", "ml", ",", "dst", ",", "vlan", ")", ";", "return", "OFPP_FLOOD", ";", "}", "}", "}" ]
Looks up MAC 'dst' for VLAN 'vlan' in 'ml'.
[ "Looks", "up", "MAC", "'", "dst", "'", "for", "VLAN", "'", "vlan", "'", "in", "'", "ml", "'", "." ]
[]
[ { "param": "ml", "type": "struct mac_learning" }, { "param": "dst", "type": "uint8_t" }, { "param": "vlan", "type": "uint16_t" }, { "param": "tag", "type": "tag_type" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ml", "type": "struct mac_learning", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dst", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vlan", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tag", "type": "tag_type", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fbe1088f5183b08dc1f76bd6209a16e89a0d44e9
xiaolanxia/oftest_ofdpa
lib/stp.c
[ "Apache-2.0" ]
C
stp_port_no
int
int stp_port_no(const struct stp_port *p) { struct stp *stp = p->stp; assert(p >= stp->ports && p < &stp->ports[ARRAY_SIZE(stp->ports)]); return p - stp->ports; }
/* Returns the index of port 'p' within its bridge. */
Returns the index of port 'p' within its bridge.
[ "Returns", "the", "index", "of", "port", "'", "p", "'", "within", "its", "bridge", "." ]
int stp_port_no(const struct stp_port *p) { struct stp *stp = p->stp; assert(p >= stp->ports && p < &stp->ports[ARRAY_SIZE(stp->ports)]); return p - stp->ports; }
[ "int", "stp_port_no", "(", "const", "struct", "stp_port", "*", "p", ")", "{", "struct", "stp", "*", "stp", "=", "p", "->", "stp", ";", "assert", "(", "p", ">=", "stp", "->", "ports", "&&", "p", "<", "&", "stp", "->", "ports", "[", "ARRAY_SIZE", "(", "stp", "->", "ports", ")", "]", ")", ";", "return", "p", "-", "stp", "->", "ports", ";", "}" ]
Returns the index of port 'p' within its bridge.
[ "Returns", "the", "index", "of", "port", "'", "p", "'", "within", "its", "bridge", "." ]
[]
[ { "param": "p", "type": "struct stp_port" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "struct stp_port", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c2668273bef08f2ded3e59693f5e648671160eb5
xiaolanxia/oftest_ofdpa
utilities/dpctl.c
[ "Apache-2.0" ]
C
parse_ext_hdrm
int
static int parse_ext_hdrm(char *str, uint16_t *ext_hdr, uint16_t *mask){ char *saveptr = NULL; char *p; p=strtok_r(str,MASK_SEP,&saveptr); if(parse16(p, NULL, 0, 0x1ff, ext_hdr) !=0){ return -1; } if( *saveptr == NULL){ *mask = 0x1ff; return 0; } else { if (parse16(saveptr, NULL, 0, 0x1ff, mask) !=0){ ofp_fatal(0, "Error parsing ipv6 ext hdr mask: 0x%x.", *mask); } } return 0; }
/*patch by peter huang, let ipv6 ext hdr can parse mask*/
patch by peter huang, let ipv6 ext hdr can parse mask
[ "patch", "by", "peter", "huang", "let", "ipv6", "ext", "hdr", "can", "parse", "mask" ]
static int parse_ext_hdrm(char *str, uint16_t *ext_hdr, uint16_t *mask){ char *saveptr = NULL; char *p; p=strtok_r(str,MASK_SEP,&saveptr); if(parse16(p, NULL, 0, 0x1ff, ext_hdr) !=0){ return -1; } if( *saveptr == NULL){ *mask = 0x1ff; return 0; } else { if (parse16(saveptr, NULL, 0, 0x1ff, mask) !=0){ ofp_fatal(0, "Error parsing ipv6 ext hdr mask: 0x%x.", *mask); } } return 0; }
[ "static", "int", "parse_ext_hdrm", "(", "char", "*", "str", ",", "uint16_t", "*", "ext_hdr", ",", "uint16_t", "*", "mask", ")", "{", "char", "*", "saveptr", "=", "NULL", ";", "char", "*", "p", ";", "p", "=", "strtok_r", "(", "str", ",", "MASK_SEP", ",", "&", "saveptr", ")", ";", "if", "(", "parse16", "(", "p", ",", "NULL", ",", "0", ",", "0x1ff", ",", "ext_hdr", ")", "!=", "0", ")", "{", "return", "-1", ";", "}", "if", "(", "*", "saveptr", "==", "NULL", ")", "{", "*", "mask", "=", "0x1ff", ";", "return", "0", ";", "}", "else", "{", "if", "(", "parse16", "(", "saveptr", ",", "NULL", ",", "0", ",", "0x1ff", ",", "mask", ")", "!=", "0", ")", "{", "ofp_fatal", "(", "0", ",", "\"", "\"", ",", "*", "mask", ")", ";", "}", "}", "return", "0", ";", "}" ]
patch by peter huang, let ipv6 ext hdr can parse mask
[ "patch", "by", "peter", "huang", "let", "ipv6", "ext", "hdr", "can", "parse", "mask" ]
[]
[ { "param": "str", "type": "char" }, { "param": "ext_hdr", "type": "uint16_t" }, { "param": "mask", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ext_hdr", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mask", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ef13b4090254984854fdbc03901056db897f77d
xiaolanxia/oftest_ofdpa
udatapath/pipeline.c
[ "Apache-2.0" ]
C
send_packet_to_controller
void
static void send_packet_to_controller(struct pipeline *pl, struct packet *pkt, uint8_t table_id, uint8_t reason) { struct ofl_msg_packet_in msg; struct ofl_match *m; msg.header.type = OFPT_PACKET_IN; msg.total_len = pkt->buffer->size; msg.reason = reason; msg.table_id = table_id; msg.cookie = 0xffffffffffffffff; msg.data = pkt->buffer->data; /* A max_len of OFPCML_NO_BUFFER means that the complete packet should be sent, and it should not be buffered.*/ if (pl->dp->config.miss_send_len != OFPCML_NO_BUFFER){ dp_buffers_save(pl->dp->buffers, pkt); msg.buffer_id = pkt->buffer_id; msg.data_length = MIN(pl->dp->config.miss_send_len, pkt->buffer->size); }else { msg.buffer_id = OFP_NO_BUFFER; msg.data_length = pkt->buffer->size; } m = xmalloc (sizeof(struct ofl_match)); ofl_structs_match_init(m); /* In this implementation the fields in_port and in_phy_port always will be the same, because we are not considering logical ports */ ofl_structs_match_convert_pktf2oflm(&pkt->handle_std->match.match_fields, m); msg.match = (struct ofl_match_header*)m; dp_send_message(pl->dp, (struct ofl_msg_header *)&msg, NULL); ofl_structs_free_match((struct ofl_match_header* ) m, NULL); }
/* Sends a packet to the controller in a packet_in message */
Sends a packet to the controller in a packet_in message
[ "Sends", "a", "packet", "to", "the", "controller", "in", "a", "packet_in", "message" ]
static void send_packet_to_controller(struct pipeline *pl, struct packet *pkt, uint8_t table_id, uint8_t reason) { struct ofl_msg_packet_in msg; struct ofl_match *m; msg.header.type = OFPT_PACKET_IN; msg.total_len = pkt->buffer->size; msg.reason = reason; msg.table_id = table_id; msg.cookie = 0xffffffffffffffff; msg.data = pkt->buffer->data; if (pl->dp->config.miss_send_len != OFPCML_NO_BUFFER){ dp_buffers_save(pl->dp->buffers, pkt); msg.buffer_id = pkt->buffer_id; msg.data_length = MIN(pl->dp->config.miss_send_len, pkt->buffer->size); }else { msg.buffer_id = OFP_NO_BUFFER; msg.data_length = pkt->buffer->size; } m = xmalloc (sizeof(struct ofl_match)); ofl_structs_match_init(m); ofl_structs_match_convert_pktf2oflm(&pkt->handle_std->match.match_fields, m); msg.match = (struct ofl_match_header*)m; dp_send_message(pl->dp, (struct ofl_msg_header *)&msg, NULL); ofl_structs_free_match((struct ofl_match_header* ) m, NULL); }
[ "static", "void", "send_packet_to_controller", "(", "struct", "pipeline", "*", "pl", ",", "struct", "packet", "*", "pkt", ",", "uint8_t", "table_id", ",", "uint8_t", "reason", ")", "{", "struct", "ofl_msg_packet_in", "msg", ";", "struct", "ofl_match", "*", "m", ";", "msg", ".", "header", ".", "type", "=", "OFPT_PACKET_IN", ";", "msg", ".", "total_len", "=", "pkt", "->", "buffer", "->", "size", ";", "msg", ".", "reason", "=", "reason", ";", "msg", ".", "table_id", "=", "table_id", ";", "msg", ".", "cookie", "=", "0xffffffffffffffff", ";", "msg", ".", "data", "=", "pkt", "->", "buffer", "->", "data", ";", "if", "(", "pl", "->", "dp", "->", "config", ".", "miss_send_len", "!=", "OFPCML_NO_BUFFER", ")", "{", "dp_buffers_save", "(", "pl", "->", "dp", "->", "buffers", ",", "pkt", ")", ";", "msg", ".", "buffer_id", "=", "pkt", "->", "buffer_id", ";", "msg", ".", "data_length", "=", "MIN", "(", "pl", "->", "dp", "->", "config", ".", "miss_send_len", ",", "pkt", "->", "buffer", "->", "size", ")", ";", "}", "else", "{", "msg", ".", "buffer_id", "=", "OFP_NO_BUFFER", ";", "msg", ".", "data_length", "=", "pkt", "->", "buffer", "->", "size", ";", "}", "m", "=", "xmalloc", "(", "sizeof", "(", "struct", "ofl_match", ")", ")", ";", "ofl_structs_match_init", "(", "m", ")", ";", "ofl_structs_match_convert_pktf2oflm", "(", "&", "pkt", "->", "handle_std", "->", "match", ".", "match_fields", ",", "m", ")", ";", "msg", ".", "match", "=", "(", "struct", "ofl_match_header", "*", ")", "m", ";", "dp_send_message", "(", "pl", "->", "dp", ",", "(", "struct", "ofl_msg_header", "*", ")", "&", "msg", ",", "NULL", ")", ";", "ofl_structs_free_match", "(", "(", "struct", "ofl_match_header", "*", ")", "m", ",", "NULL", ")", ";", "}" ]
Sends a packet to the controller in a packet_in message
[ "Sends", "a", "packet", "to", "the", "controller", "in", "a", "packet_in", "message" ]
[ "/* A max_len of OFPCML_NO_BUFFER means that the complete\n packet should be sent, and it should not be buffered.*/", "/* In this implementation the fields in_port and in_phy_port\n always will be the same, because we are not considering logical\n ports */" ]
[ { "param": "pl", "type": "struct pipeline" }, { "param": "pkt", "type": "struct packet" }, { "param": "table_id", "type": "uint8_t" }, { "param": "reason", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pl", "type": "struct pipeline", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pkt", "type": "struct packet", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "table_id", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reason", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
eae1a8c6fcabff24168c41825248968a8124ea09
anaghajoshi/HackerRank
LinkedList/insert_node_at_tail.c
[ "MIT" ]
C
Insert
Node
Node* Insert(Node *head,int data) { Node* temp; temp =(Node*) malloc(sizeof(Node)); temp->data = data; temp->next = NULL; Node* head_temp=head; if(head ==NULL){ head = temp; } else { while(head_temp->next!=NULL){ head_temp = head_temp->next; } head_temp->next = temp; } return head; }
/* Insert Node at the end of a linked list head pointer input could be NULL as well for empty list Node is defined as struct Node { int data; struct Node *next; } */
Insert Node at the end of a linked list head pointer input could be NULL as well for empty list Node is defined as struct Node { int data; struct Node *next; }
[ "Insert", "Node", "at", "the", "end", "of", "a", "linked", "list", "head", "pointer", "input", "could", "be", "NULL", "as", "well", "for", "empty", "list", "Node", "is", "defined", "as", "struct", "Node", "{", "int", "data", ";", "struct", "Node", "*", "next", ";", "}" ]
Node* Insert(Node *head,int data) { Node* temp; temp =(Node*) malloc(sizeof(Node)); temp->data = data; temp->next = NULL; Node* head_temp=head; if(head ==NULL){ head = temp; } else { while(head_temp->next!=NULL){ head_temp = head_temp->next; } head_temp->next = temp; } return head; }
[ "Node", "*", "Insert", "(", "Node", "*", "head", ",", "int", "data", ")", "{", "Node", "*", "temp", ";", "temp", "=", "(", "Node", "*", ")", "malloc", "(", "sizeof", "(", "Node", ")", ")", ";", "temp", "->", "data", "=", "data", ";", "temp", "->", "next", "=", "NULL", ";", "Node", "*", "head_temp", "=", "head", ";", "if", "(", "head", "==", "NULL", ")", "{", "head", "=", "temp", ";", "}", "else", "{", "while", "(", "head_temp", "->", "next", "!=", "NULL", ")", "{", "head_temp", "=", "head_temp", "->", "next", ";", "}", "head_temp", "->", "next", "=", "temp", ";", "}", "return", "head", ";", "}" ]
Insert Node at the end of a linked list head pointer input could be NULL as well for empty list Node is defined as struct Node { int data; struct Node *next; }
[ "Insert", "Node", "at", "the", "end", "of", "a", "linked", "list", "head", "pointer", "input", "could", "be", "NULL", "as", "well", "for", "empty", "list", "Node", "is", "defined", "as", "struct", "Node", "{", "int", "data", ";", "struct", "Node", "*", "next", ";", "}" ]
[]
[ { "param": "head", "type": "Node" }, { "param": "data", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "head", "type": "Node", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f5c5d929e8a34c096d7c600baf19e6da8c5fe9f6
anaghajoshi/HackerRank
LinkedList/insert_node_at_nth_position.c
[ "MIT" ]
C
InsertNth
Node
Node* InsertNth(Node *head, int data, int position) { Node* temp = (Node*)malloc(sizeof(Node)); temp->data = data; temp->next=NULL; Node* prev; prev = head; if(position == 0){ temp->next=head; head=temp; } else{ for(int i =0; i< position-1; i++){ if(prev->next!=NULL) prev = prev->next; } temp->next = prev->next; prev->next = temp; } return head; }
/* Insert Node at a given position in a linked list head can be NULL First element in the linked list is at position 0 Node is defined as struct Node { int data; struct Node *next; } */
Insert Node at a given position in a linked list head can be NULL First element in the linked list is at position 0 Node is defined as struct Node { int data; struct Node *next; }
[ "Insert", "Node", "at", "a", "given", "position", "in", "a", "linked", "list", "head", "can", "be", "NULL", "First", "element", "in", "the", "linked", "list", "is", "at", "position", "0", "Node", "is", "defined", "as", "struct", "Node", "{", "int", "data", ";", "struct", "Node", "*", "next", ";", "}" ]
Node* InsertNth(Node *head, int data, int position) { Node* temp = (Node*)malloc(sizeof(Node)); temp->data = data; temp->next=NULL; Node* prev; prev = head; if(position == 0){ temp->next=head; head=temp; } else{ for(int i =0; i< position-1; i++){ if(prev->next!=NULL) prev = prev->next; } temp->next = prev->next; prev->next = temp; } return head; }
[ "Node", "*", "InsertNth", "(", "Node", "*", "head", ",", "int", "data", ",", "int", "position", ")", "{", "Node", "*", "temp", "=", "(", "Node", "*", ")", "malloc", "(", "sizeof", "(", "Node", ")", ")", ";", "temp", "->", "data", "=", "data", ";", "temp", "->", "next", "=", "NULL", ";", "Node", "*", "prev", ";", "prev", "=", "head", ";", "if", "(", "position", "==", "0", ")", "{", "temp", "->", "next", "=", "head", ";", "head", "=", "temp", ";", "}", "else", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "position", "-", "1", ";", "i", "++", ")", "{", "if", "(", "prev", "->", "next", "!=", "NULL", ")", "prev", "=", "prev", "->", "next", ";", "}", "temp", "->", "next", "=", "prev", "->", "next", ";", "prev", "->", "next", "=", "temp", ";", "}", "return", "head", ";", "}" ]
Insert Node at a given position in a linked list head can be NULL First element in the linked list is at position 0 Node is defined as struct Node { int data; struct Node *next; }
[ "Insert", "Node", "at", "a", "given", "position", "in", "a", "linked", "list", "head", "can", "be", "NULL", "First", "element", "in", "the", "linked", "list", "is", "at", "position", "0", "Node", "is", "defined", "as", "struct", "Node", "{", "int", "data", ";", "struct", "Node", "*", "next", ";", "}" ]
[]
[ { "param": "head", "type": "Node" }, { "param": "data", "type": "int" }, { "param": "position", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "head", "type": "Node", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "position", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
74487b53811795337dc48ed08bdd98b91e49e5c0
jeffro256/csce-410-project-1
unused/msg.c
[ "MIT" ]
C
init_messaging
int
int init_messaging(int num_producers, int num_consumers) { for (int i = 0; i < num_producers; i++) { char* fifo_name = get_pipe_name(MSG_PRODUCER, i); mkfifo(fifo_name, 0660); } for (int i = 0; i < num_consumers; i++) { char* fifo_name = get_pipe_name(MSG_CONSUMER, i); mkfifo(fifo_name, 0660); } return MSG_OKAY; }
// Creates all FIFO files. Should only be called once per group of processes. returns MSG_ERROR_CODE.
Creates all FIFO files. Should only be called once per group of processes.
[ "Creates", "all", "FIFO", "files", ".", "Should", "only", "be", "called", "once", "per", "group", "of", "processes", "." ]
int init_messaging(int num_producers, int num_consumers) { for (int i = 0; i < num_producers; i++) { char* fifo_name = get_pipe_name(MSG_PRODUCER, i); mkfifo(fifo_name, 0660); } for (int i = 0; i < num_consumers; i++) { char* fifo_name = get_pipe_name(MSG_CONSUMER, i); mkfifo(fifo_name, 0660); } return MSG_OKAY; }
[ "int", "init_messaging", "(", "int", "num_producers", ",", "int", "num_consumers", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "num_producers", ";", "i", "++", ")", "{", "char", "*", "fifo_name", "=", "get_pipe_name", "(", "MSG_PRODUCER", ",", "i", ")", ";", "mkfifo", "(", "fifo_name", ",", "0660", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "num_consumers", ";", "i", "++", ")", "{", "char", "*", "fifo_name", "=", "get_pipe_name", "(", "MSG_CONSUMER", ",", "i", ")", ";", "mkfifo", "(", "fifo_name", ",", "0660", ")", ";", "}", "return", "MSG_OKAY", ";", "}" ]
Creates all FIFO files.
[ "Creates", "all", "FIFO", "files", "." ]
[]
[ { "param": "num_producers", "type": "int" }, { "param": "num_consumers", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "num_producers", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num_consumers", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f720346e18be6c70913ab5fb0ceee695b30e1425
Marslanali/CrazyS
rotors_gazebo_plugins/include/rotors_gazebo_plugins/common.h
[ "Apache-2.0" ]
C
updateFilter
T
T updateFilter(T inputState, double samplingTime) { T outputState; if (inputState > previousState_) { // Calcuate the outputState if accelerating. double alphaUp = exp(-samplingTime / timeConstantUp_); // x(k+1) = Ad*x(k) + Bd*u(k) outputState = alphaUp * previousState_ + (1 - alphaUp) * inputState; } else { // Calculate the outputState if decelerating. double alphaDown = exp(-samplingTime / timeConstantDown_); outputState = alphaDown * previousState_ + (1 - alphaDown) * inputState; } previousState_ = outputState; return outputState; }
/// \brief This method will apply a first order filter on the inputState.
\brief This method will apply a first order filter on the inputState.
[ "\\", "brief", "This", "method", "will", "apply", "a", "first", "order", "filter", "on", "the", "inputState", "." ]
T updateFilter(T inputState, double samplingTime) { T outputState; if (inputState > previousState_) { double alphaUp = exp(-samplingTime / timeConstantUp_); outputState = alphaUp * previousState_ + (1 - alphaUp) * inputState; } else { double alphaDown = exp(-samplingTime / timeConstantDown_); outputState = alphaDown * previousState_ + (1 - alphaDown) * inputState; } previousState_ = outputState; return outputState; }
[ "T", "updateFilter", "(", "T", "inputState", ",", "double", "samplingTime", ")", "{", "T", "outputState", ";", "if", "(", "inputState", ">", "previousState_", ")", "{", "double", "alphaUp", "=", "exp", "(", "-", "samplingTime", "/", "timeConstantUp_", ")", ";", "outputState", "=", "alphaUp", "*", "previousState_", "+", "(", "1", "-", "alphaUp", ")", "*", "inputState", ";", "}", "else", "{", "double", "alphaDown", "=", "exp", "(", "-", "samplingTime", "/", "timeConstantDown_", ")", ";", "outputState", "=", "alphaDown", "*", "previousState_", "+", "(", "1", "-", "alphaDown", ")", "*", "inputState", ";", "}", "previousState_", "=", "outputState", ";", "return", "outputState", ";", "}" ]
\brief This method will apply a first order filter on the inputState.
[ "\\", "brief", "This", "method", "will", "apply", "a", "first", "order", "filter", "on", "the", "inputState", "." ]
[ "// Calcuate the outputState if accelerating.", "// x(k+1) = Ad*x(k) + Bd*u(k)", "// Calculate the outputState if decelerating." ]
[ { "param": "inputState", "type": "T" }, { "param": "samplingTime", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "inputState", "type": "T", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "samplingTime", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e9f01026a7a7259642729f9af9de180e8e4facec
bpsm/sudoku-c
sudoku.c
[ "Apache-2.0" ]
C
next_move
pos
pos next_move(solver const *s) { int p = 0, m = 10, i; for (i = 0; i < SUDOKU_SIZE; i++) { int n = SET_SIZE(s->sudoku.free[i]); if (n == 0) { /* * n == 0 implies that the current puzzle configuration is * unsolveable. Our caller will detect this and backtrack. */ p = i; break; } if (n > 1 && n < m) { /* * The primary goal of the surrounding loop is to find * the free position with the fewest degrees of freedom. */ m = n; p = i; } } /* * If we never found (n > 1 && n < m) then we may reach this * point with p referring to a position that is fixed (1 degree * of freedom.) This indicates that the puzzle has been solved. */ return p; }
/* * Find the position which we'll next try to solve for. * * If the position returned has 0 degrees of freedom, then the * puzzle's current configuration violates the rules of sudoku and * cann not be solved. * * If the position returned has 1 degree of freedom, then the puzzle * has been successfully solved. * * If the position returned has 2 or more degrees of freedom, then the * possible digits should be explored until a solution is found. */
Find the position which we'll next try to solve for. If the position returned has 0 degrees of freedom, then the puzzle's current configuration violates the rules of sudoku and cann not be solved. If the position returned has 1 degree of freedom, then the puzzle has been successfully solved. If the position returned has 2 or more degrees of freedom, then the possible digits should be explored until a solution is found.
[ "Find", "the", "position", "which", "we", "'", "ll", "next", "try", "to", "solve", "for", ".", "If", "the", "position", "returned", "has", "0", "degrees", "of", "freedom", "then", "the", "puzzle", "'", "s", "current", "configuration", "violates", "the", "rules", "of", "sudoku", "and", "cann", "not", "be", "solved", ".", "If", "the", "position", "returned", "has", "1", "degree", "of", "freedom", "then", "the", "puzzle", "has", "been", "successfully", "solved", ".", "If", "the", "position", "returned", "has", "2", "or", "more", "degrees", "of", "freedom", "then", "the", "possible", "digits", "should", "be", "explored", "until", "a", "solution", "is", "found", "." ]
pos next_move(solver const *s) { int p = 0, m = 10, i; for (i = 0; i < SUDOKU_SIZE; i++) { int n = SET_SIZE(s->sudoku.free[i]); if (n == 0) { p = i; break; } if (n > 1 && n < m) { m = n; p = i; } } return p; }
[ "pos", "next_move", "(", "solver", "const", "*", "s", ")", "{", "int", "p", "=", "0", ",", "m", "=", "10", ",", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "SUDOKU_SIZE", ";", "i", "++", ")", "{", "int", "n", "=", "SET_SIZE", "(", "s", "->", "sudoku", ".", "free", "[", "i", "]", ")", ";", "if", "(", "n", "==", "0", ")", "{", "p", "=", "i", ";", "break", ";", "}", "if", "(", "n", ">", "1", "&&", "n", "<", "m", ")", "{", "m", "=", "n", ";", "p", "=", "i", ";", "}", "}", "return", "p", ";", "}" ]
Find the position which we'll next try to solve for.
[ "Find", "the", "position", "which", "we", "'", "ll", "next", "try", "to", "solve", "for", "." ]
[ "/*\n * n == 0 implies that the current puzzle configuration is\n * unsolveable. Our caller will detect this and backtrack.\n */", "/*\n * The primary goal of the surrounding loop is to find\n * the free position with the fewest degrees of freedom.\n */", "/*\n * If we never found (n > 1 && n < m) then we may reach this\n * point with p referring to a position that is fixed (1 degree\n * of freedom.) This indicates that the puzzle has been solved.\n */" ]
[ { "param": "s", "type": "solver" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": "solver", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e9f01026a7a7259642729f9af9de180e8e4facec
bpsm/sudoku-c
sudoku.c
[ "Apache-2.0" ]
C
sudoku_to_text
void
void sudoku_to_text(sudoku const *s, char *t) { for (int i = 0; i < SUDOKU_SIZE; i++) { switch(SET_SIZE(s->free[i])) { case 0: t[i] = '#'; break; case 1: for (digit d = MIN_DIGIT; d <= MAX_DIGIT; d++) if (IN_SET(s->free[i], d)) { t[i] = DIGIT_TO_CHAR(d); break; } break; default: t[i] = '.'; } } t[SUDOKU_SIZE] = '\0'; }
/* * Copy a textual representation of the sudoku s to the string pointed * to be t, which must point to at least SUDOKU_SIZE+1 bytes of * storage. */
Copy a textual representation of the sudoku s to the string pointed to be t, which must point to at least SUDOKU_SIZE+1 bytes of storage.
[ "Copy", "a", "textual", "representation", "of", "the", "sudoku", "s", "to", "the", "string", "pointed", "to", "be", "t", "which", "must", "point", "to", "at", "least", "SUDOKU_SIZE", "+", "1", "bytes", "of", "storage", "." ]
void sudoku_to_text(sudoku const *s, char *t) { for (int i = 0; i < SUDOKU_SIZE; i++) { switch(SET_SIZE(s->free[i])) { case 0: t[i] = '#'; break; case 1: for (digit d = MIN_DIGIT; d <= MAX_DIGIT; d++) if (IN_SET(s->free[i], d)) { t[i] = DIGIT_TO_CHAR(d); break; } break; default: t[i] = '.'; } } t[SUDOKU_SIZE] = '\0'; }
[ "void", "sudoku_to_text", "(", "sudoku", "const", "*", "s", ",", "char", "*", "t", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "SUDOKU_SIZE", ";", "i", "++", ")", "{", "switch", "(", "SET_SIZE", "(", "s", "->", "free", "[", "i", "]", ")", ")", "{", "case", "0", ":", "t", "[", "i", "]", "=", "'", "'", ";", "break", ";", "case", "1", ":", "for", "(", "digit", "d", "=", "MIN_DIGIT", ";", "d", "<=", "MAX_DIGIT", ";", "d", "++", ")", "if", "(", "IN_SET", "(", "s", "->", "free", "[", "i", "]", ",", "d", ")", ")", "{", "t", "[", "i", "]", "=", "DIGIT_TO_CHAR", "(", "d", ")", ";", "break", ";", "}", "break", ";", "default", ":", "t", "[", "i", "]", "=", "'", "'", ";", "}", "}", "t", "[", "SUDOKU_SIZE", "]", "=", "'", "\\0", "'", ";", "}" ]
Copy a textual representation of the sudoku s to the string pointed to be t, which must point to at least SUDOKU_SIZE+1 bytes of storage.
[ "Copy", "a", "textual", "representation", "of", "the", "sudoku", "s", "to", "the", "string", "pointed", "to", "be", "t", "which", "must", "point", "to", "at", "least", "SUDOKU_SIZE", "+", "1", "bytes", "of", "storage", "." ]
[]
[ { "param": "s", "type": "sudoku" }, { "param": "t", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": "sudoku", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "t", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9a0f8088c754d6f8ff5ffd95086f8ad1452ac0b
Vipul-Cariappa/py-lua
src/lua_py.h
[ "MIT" ]
C
raise_error
int
static int raise_error(lua_State* L, const char* msg) { if (!PyErr_Occurred()) { return luaL_error(L, msg); } size_t err_max = 1024; char* _err_msg = malloc(err_max); char* err_msg = _err_msg; if (!err_msg) { LUA_MEMORY_ERROR(L); } if ((err_msg += snprintf(err_msg, err_max, "%s\n\nPython Traceback:\n", msg)) < 0) { LUA_MEMORY_ERROR(L); } PyObject* pExcType; PyObject* pExcValue; PyObject* pExcTraceback; PyErr_Fetch(&pExcType, &pExcValue, &pExcTraceback); PyErr_NormalizeException(&pExcType, &pExcValue, &pExcTraceback); if (pExcTraceback && PyTraceBack_Check(pExcTraceback)) { PyTracebackObject* pTrace = (PyTracebackObject*)pExcTraceback; char* traceback_msg = malloc(TRACEBACK_STR_LEN); if (!traceback_msg) { LUA_MEMORY_ERROR(L); } while (pTrace != NULL) { PyFrameObject* frame = pTrace->tb_frame; PyCodeObject* code = frame->f_code; int lineNr = PyFrame_GetLineNumber(frame); const char* codeName = PyUnicode_AsUTF8(code->co_name); const char* fileName = PyUnicode_AsUTF8(code->co_filename); if (snprintf(traceback_msg, TRACEBACK_STR_LEN, "File \"%s\", line %i, in\n %s\n", fileName, lineNr, codeName) < 0) { LUA_MEMORY_ERROR(L); } if ((err_msg += snprintf(err_msg, err_max, "%s", traceback_msg)) < 0) { err_max *= 4; err_msg = err_msg - _err_msg; char* tmp = realloc(_err_msg, err_max); if (tmp) { _err_msg = tmp; err_msg = _err_msg + (long)err_msg; } else { LUA_MEMORY_ERROR(L); } if ((err_msg += snprintf(err_msg, err_max, "%s", traceback_msg)) < 0) { LUA_MEMORY_ERROR(L); } } pTrace = pTrace->tb_next; } free(traceback_msg); } PyObject* str_exc_value = PyObject_Repr(pExcValue); PyObject* pExcValueStr = PyUnicode_AsEncodedString(str_exc_value, "utf-8", "strict"); const char* strExcValue = PyBytes_AS_STRING(pExcValueStr); char* err_name = malloc(EXCEPTION_STR_LEN); if (!err_name) { LUA_MEMORY_ERROR(L); } char* new_strExcValue = str_replace(strExcValue, "\\n", "\n"); if (snprintf(err_name, EXCEPTION_STR_LEN, "\n %s\n", new_strExcValue) < 0) { LUA_MEMORY_ERROR(L); } if (snprintf(err_msg, err_max, "%s", err_name) < 0) { err_max *= 4; err_msg = err_msg - _err_msg; char* tmp = realloc(_err_msg, err_max); if (tmp) { _err_msg = tmp; err_msg = _err_msg + (long)err_msg; } else { LUA_MEMORY_ERROR(L); } if ((err_msg += snprintf(err_msg, err_max, "%s", err_name)) < 0) { LUA_MEMORY_ERROR(L); } } lua_pushstring(L, _err_msg); Py_XDECREF(pExcType); Py_XDECREF(pExcValue); Py_XDECREF(pExcTraceback); Py_XDECREF(str_exc_value); Py_XDECREF(pExcValueStr); free(_err_msg); free(err_name); free(new_strExcValue); return lua_error(L); }
/* raises error to lua interpreter with gien msg */
raises error to lua interpreter with gien msg
[ "raises", "error", "to", "lua", "interpreter", "with", "gien", "msg" ]
static int raise_error(lua_State* L, const char* msg) { if (!PyErr_Occurred()) { return luaL_error(L, msg); } size_t err_max = 1024; char* _err_msg = malloc(err_max); char* err_msg = _err_msg; if (!err_msg) { LUA_MEMORY_ERROR(L); } if ((err_msg += snprintf(err_msg, err_max, "%s\n\nPython Traceback:\n", msg)) < 0) { LUA_MEMORY_ERROR(L); } PyObject* pExcType; PyObject* pExcValue; PyObject* pExcTraceback; PyErr_Fetch(&pExcType, &pExcValue, &pExcTraceback); PyErr_NormalizeException(&pExcType, &pExcValue, &pExcTraceback); if (pExcTraceback && PyTraceBack_Check(pExcTraceback)) { PyTracebackObject* pTrace = (PyTracebackObject*)pExcTraceback; char* traceback_msg = malloc(TRACEBACK_STR_LEN); if (!traceback_msg) { LUA_MEMORY_ERROR(L); } while (pTrace != NULL) { PyFrameObject* frame = pTrace->tb_frame; PyCodeObject* code = frame->f_code; int lineNr = PyFrame_GetLineNumber(frame); const char* codeName = PyUnicode_AsUTF8(code->co_name); const char* fileName = PyUnicode_AsUTF8(code->co_filename); if (snprintf(traceback_msg, TRACEBACK_STR_LEN, "File \"%s\", line %i, in\n %s\n", fileName, lineNr, codeName) < 0) { LUA_MEMORY_ERROR(L); } if ((err_msg += snprintf(err_msg, err_max, "%s", traceback_msg)) < 0) { err_max *= 4; err_msg = err_msg - _err_msg; char* tmp = realloc(_err_msg, err_max); if (tmp) { _err_msg = tmp; err_msg = _err_msg + (long)err_msg; } else { LUA_MEMORY_ERROR(L); } if ((err_msg += snprintf(err_msg, err_max, "%s", traceback_msg)) < 0) { LUA_MEMORY_ERROR(L); } } pTrace = pTrace->tb_next; } free(traceback_msg); } PyObject* str_exc_value = PyObject_Repr(pExcValue); PyObject* pExcValueStr = PyUnicode_AsEncodedString(str_exc_value, "utf-8", "strict"); const char* strExcValue = PyBytes_AS_STRING(pExcValueStr); char* err_name = malloc(EXCEPTION_STR_LEN); if (!err_name) { LUA_MEMORY_ERROR(L); } char* new_strExcValue = str_replace(strExcValue, "\\n", "\n"); if (snprintf(err_name, EXCEPTION_STR_LEN, "\n %s\n", new_strExcValue) < 0) { LUA_MEMORY_ERROR(L); } if (snprintf(err_msg, err_max, "%s", err_name) < 0) { err_max *= 4; err_msg = err_msg - _err_msg; char* tmp = realloc(_err_msg, err_max); if (tmp) { _err_msg = tmp; err_msg = _err_msg + (long)err_msg; } else { LUA_MEMORY_ERROR(L); } if ((err_msg += snprintf(err_msg, err_max, "%s", err_name)) < 0) { LUA_MEMORY_ERROR(L); } } lua_pushstring(L, _err_msg); Py_XDECREF(pExcType); Py_XDECREF(pExcValue); Py_XDECREF(pExcTraceback); Py_XDECREF(str_exc_value); Py_XDECREF(pExcValueStr); free(_err_msg); free(err_name); free(new_strExcValue); return lua_error(L); }
[ "static", "int", "raise_error", "(", "lua_State", "*", "L", ",", "const", "char", "*", "msg", ")", "{", "if", "(", "!", "PyErr_Occurred", "(", ")", ")", "{", "return", "luaL_error", "(", "L", ",", "msg", ")", ";", "}", "size_t", "err_max", "=", "1024", ";", "char", "*", "_err_msg", "=", "malloc", "(", "err_max", ")", ";", "char", "*", "err_msg", "=", "_err_msg", ";", "if", "(", "!", "err_msg", ")", "{", "LUA_MEMORY_ERROR", "(", "L", ")", ";", "}", "if", "(", "(", "err_msg", "+=", "snprintf", "(", "err_msg", ",", "err_max", ",", "\"", "\\n", "\\n", "\\n", "\"", ",", "msg", ")", ")", "<", "0", ")", "{", "LUA_MEMORY_ERROR", "(", "L", ")", ";", "}", "PyObject", "*", "pExcType", ";", "PyObject", "*", "pExcValue", ";", "PyObject", "*", "pExcTraceback", ";", "PyErr_Fetch", "(", "&", "pExcType", ",", "&", "pExcValue", ",", "&", "pExcTraceback", ")", ";", "PyErr_NormalizeException", "(", "&", "pExcType", ",", "&", "pExcValue", ",", "&", "pExcTraceback", ")", ";", "if", "(", "pExcTraceback", "&&", "PyTraceBack_Check", "(", "pExcTraceback", ")", ")", "{", "PyTracebackObject", "*", "pTrace", "=", "(", "PyTracebackObject", "*", ")", "pExcTraceback", ";", "char", "*", "traceback_msg", "=", "malloc", "(", "TRACEBACK_STR_LEN", ")", ";", "if", "(", "!", "traceback_msg", ")", "{", "LUA_MEMORY_ERROR", "(", "L", ")", ";", "}", "while", "(", "pTrace", "!=", "NULL", ")", "{", "PyFrameObject", "*", "frame", "=", "pTrace", "->", "tb_frame", ";", "PyCodeObject", "*", "code", "=", "frame", "->", "f_code", ";", "int", "lineNr", "=", "PyFrame_GetLineNumber", "(", "frame", ")", ";", "const", "char", "*", "codeName", "=", "PyUnicode_AsUTF8", "(", "code", "->", "co_name", ")", ";", "const", "char", "*", "fileName", "=", "PyUnicode_AsUTF8", "(", "code", "->", "co_filename", ")", ";", "if", "(", "snprintf", "(", "traceback_msg", ",", "TRACEBACK_STR_LEN", ",", "\"", "\\\"", "\\\"", "\\n", "\\n", "\"", ",", "fileName", ",", "lineNr", ",", "codeName", ")", "<", "0", ")", "{", "LUA_MEMORY_ERROR", "(", "L", ")", ";", "}", "if", "(", "(", "err_msg", "+=", "snprintf", "(", "err_msg", ",", "err_max", ",", "\"", "\"", ",", "traceback_msg", ")", ")", "<", "0", ")", "{", "err_max", "*=", "4", ";", "err_msg", "=", "err_msg", "-", "_err_msg", ";", "char", "*", "tmp", "=", "realloc", "(", "_err_msg", ",", "err_max", ")", ";", "if", "(", "tmp", ")", "{", "_err_msg", "=", "tmp", ";", "err_msg", "=", "_err_msg", "+", "(", "long", ")", "err_msg", ";", "}", "else", "{", "LUA_MEMORY_ERROR", "(", "L", ")", ";", "}", "if", "(", "(", "err_msg", "+=", "snprintf", "(", "err_msg", ",", "err_max", ",", "\"", "\"", ",", "traceback_msg", ")", ")", "<", "0", ")", "{", "LUA_MEMORY_ERROR", "(", "L", ")", ";", "}", "}", "pTrace", "=", "pTrace", "->", "tb_next", ";", "}", "free", "(", "traceback_msg", ")", ";", "}", "PyObject", "*", "str_exc_value", "=", "PyObject_Repr", "(", "pExcValue", ")", ";", "PyObject", "*", "pExcValueStr", "=", "PyUnicode_AsEncodedString", "(", "str_exc_value", ",", "\"", "\"", ",", "\"", "\"", ")", ";", "const", "char", "*", "strExcValue", "=", "PyBytes_AS_STRING", "(", "pExcValueStr", ")", ";", "char", "*", "err_name", "=", "malloc", "(", "EXCEPTION_STR_LEN", ")", ";", "if", "(", "!", "err_name", ")", "{", "LUA_MEMORY_ERROR", "(", "L", ")", ";", "}", "char", "*", "new_strExcValue", "=", "str_replace", "(", "strExcValue", ",", "\"", "\\\\", "\"", ",", "\"", "\\n", "\"", ")", ";", "if", "(", "snprintf", "(", "err_name", ",", "EXCEPTION_STR_LEN", ",", "\"", "\\n", "\\n", "\"", ",", "new_strExcValue", ")", "<", "0", ")", "{", "LUA_MEMORY_ERROR", "(", "L", ")", ";", "}", "if", "(", "snprintf", "(", "err_msg", ",", "err_max", ",", "\"", "\"", ",", "err_name", ")", "<", "0", ")", "{", "err_max", "*=", "4", ";", "err_msg", "=", "err_msg", "-", "_err_msg", ";", "char", "*", "tmp", "=", "realloc", "(", "_err_msg", ",", "err_max", ")", ";", "if", "(", "tmp", ")", "{", "_err_msg", "=", "tmp", ";", "err_msg", "=", "_err_msg", "+", "(", "long", ")", "err_msg", ";", "}", "else", "{", "LUA_MEMORY_ERROR", "(", "L", ")", ";", "}", "if", "(", "(", "err_msg", "+=", "snprintf", "(", "err_msg", ",", "err_max", ",", "\"", "\"", ",", "err_name", ")", ")", "<", "0", ")", "{", "LUA_MEMORY_ERROR", "(", "L", ")", ";", "}", "}", "lua_pushstring", "(", "L", ",", "_err_msg", ")", ";", "Py_XDECREF", "(", "pExcType", ")", ";", "Py_XDECREF", "(", "pExcValue", ")", ";", "Py_XDECREF", "(", "pExcTraceback", ")", ";", "Py_XDECREF", "(", "str_exc_value", ")", ";", "Py_XDECREF", "(", "pExcValueStr", ")", ";", "free", "(", "_err_msg", ")", ";", "free", "(", "err_name", ")", ";", "free", "(", "new_strExcValue", ")", ";", "return", "lua_error", "(", "L", ")", ";", "}" ]
raises error to lua interpreter with gien msg
[ "raises", "error", "to", "lua", "interpreter", "with", "gien", "msg" ]
[]
[ { "param": "L", "type": "lua_State" }, { "param": "msg", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "L", "type": "lua_State", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "msg", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9a0f8088c754d6f8ff5ffd95086f8ad1452ac0b
Vipul-Cariappa/py-lua
src/lua_py.h
[ "MIT" ]
C
binary_base_pyobj_wrapper
int
static int binary_base_pyobj_wrapper(lua_State* L, binary_op func) { PyLua_PyObject* py_obj = (PyLua_PyObject*)lua_touserdata(L, 1); PyObject* other = PyLua_LuaToPython(L, 2); if (!other) { return raise_error(L, LERR_CONVERT_LUA_TO_PY); } PyObject* pReturn = func(py_obj->object, other); Py_DECREF(other); if (pReturn) { if (PyLua_PythonToLua(L, pReturn) < 0) { Py_DECREF(pReturn); return raise_error(L, LERR_CONVERT_LUA_TO_PY); } Py_DECREF(pReturn); return 1; } return raise_error(L, ERR_CALL_PY); }
/* performs the binary_op on to the top two variables from the lua state by converting them to python types and pushes the return value */
performs the binary_op on to the top two variables from the lua state by converting them to python types and pushes the return value
[ "performs", "the", "binary_op", "on", "to", "the", "top", "two", "variables", "from", "the", "lua", "state", "by", "converting", "them", "to", "python", "types", "and", "pushes", "the", "return", "value" ]
static int binary_base_pyobj_wrapper(lua_State* L, binary_op func) { PyLua_PyObject* py_obj = (PyLua_PyObject*)lua_touserdata(L, 1); PyObject* other = PyLua_LuaToPython(L, 2); if (!other) { return raise_error(L, LERR_CONVERT_LUA_TO_PY); } PyObject* pReturn = func(py_obj->object, other); Py_DECREF(other); if (pReturn) { if (PyLua_PythonToLua(L, pReturn) < 0) { Py_DECREF(pReturn); return raise_error(L, LERR_CONVERT_LUA_TO_PY); } Py_DECREF(pReturn); return 1; } return raise_error(L, ERR_CALL_PY); }
[ "static", "int", "binary_base_pyobj_wrapper", "(", "lua_State", "*", "L", ",", "binary_op", "func", ")", "{", "PyLua_PyObject", "*", "py_obj", "=", "(", "PyLua_PyObject", "*", ")", "lua_touserdata", "(", "L", ",", "1", ")", ";", "PyObject", "*", "other", "=", "PyLua_LuaToPython", "(", "L", ",", "2", ")", ";", "if", "(", "!", "other", ")", "{", "return", "raise_error", "(", "L", ",", "LERR_CONVERT_LUA_TO_PY", ")", ";", "}", "PyObject", "*", "pReturn", "=", "func", "(", "py_obj", "->", "object", ",", "other", ")", ";", "Py_DECREF", "(", "other", ")", ";", "if", "(", "pReturn", ")", "{", "if", "(", "PyLua_PythonToLua", "(", "L", ",", "pReturn", ")", "<", "0", ")", "{", "Py_DECREF", "(", "pReturn", ")", ";", "return", "raise_error", "(", "L", ",", "LERR_CONVERT_LUA_TO_PY", ")", ";", "}", "Py_DECREF", "(", "pReturn", ")", ";", "return", "1", ";", "}", "return", "raise_error", "(", "L", ",", "ERR_CALL_PY", ")", ";", "}" ]
performs the binary_op on to the top two variables from the lua state by converting them to python types and pushes the return value
[ "performs", "the", "binary_op", "on", "to", "the", "top", "two", "variables", "from", "the", "lua", "state", "by", "converting", "them", "to", "python", "types", "and", "pushes", "the", "return", "value" ]
[]
[ { "param": "L", "type": "lua_State" }, { "param": "func", "type": "binary_op" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "L", "type": "lua_State", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "func", "type": "binary_op", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8ecb2b8978cc7e512f12c9293b29db5740e14914
dylancarlson/citplus
msg.h
[ "Unlicense" ]
C
SetFirstMessageInRoom
void
void SetFirstMessageInRoom(r_slot Room, m_index Msg) { assert(FirstMessageInRoom); FirstMessageInRoom[Room] = Msg; }
// These two should only be called when we have exclusive access...
These two should only be called when we have exclusive access
[ "These", "two", "should", "only", "be", "called", "when", "we", "have", "exclusive", "access" ]
void SetFirstMessageInRoom(r_slot Room, m_index Msg) { assert(FirstMessageInRoom); FirstMessageInRoom[Room] = Msg; }
[ "void", "SetFirstMessageInRoom", "(", "r_slot", "Room", ",", "m_index", "Msg", ")", "{", "assert", "(", "FirstMessageInRoom", ")", ";", "FirstMessageInRoom", "[", "Room", "]", "=", "Msg", ";", "}" ]
These two should only be called when we have exclusive access...
[ "These", "two", "should", "only", "be", "called", "when", "we", "have", "exclusive", "access", "..." ]
[]
[ { "param": "Room", "type": "r_slot" }, { "param": "Msg", "type": "m_index" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Room", "type": "r_slot", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "Msg", "type": "m_index", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e6e8196eade6a66b493196fa8897f53ee8cb2e40
uschwes/fcl
include/fcl/knn/nearest_neighbors_GNAT.h
[ "BSD-3-Clause" ]
C
updateRadius
void
void updateRadius(double dist) { if (minRadius_ > dist) minRadius_ = dist; if (maxRadius_ < dist) maxRadius_ = dist; }
/// \brief Update minRadius_ and maxRadius_, given that an element /// was added with distance dist to the pivot.
\brief Update minRadius_ and maxRadius_, given that an element was added with distance dist to the pivot.
[ "\\", "brief", "Update", "minRadius_", "and", "maxRadius_", "given", "that", "an", "element", "was", "added", "with", "distance", "dist", "to", "the", "pivot", "." ]
void updateRadius(double dist) { if (minRadius_ > dist) minRadius_ = dist; if (maxRadius_ < dist) maxRadius_ = dist; }
[ "void", "updateRadius", "(", "double", "dist", ")", "{", "if", "(", "minRadius_", ">", "dist", ")", "minRadius_", "=", "dist", ";", "if", "(", "maxRadius_", "<", "dist", ")", "maxRadius_", "=", "dist", ";", "}" ]
\brief Update minRadius_ and maxRadius_, given that an element was added with distance dist to the pivot.
[ "\\", "brief", "Update", "minRadius_", "and", "maxRadius_", "given", "that", "an", "element", "was", "added", "with", "distance", "dist", "to", "the", "pivot", "." ]
[]
[ { "param": "dist", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dist", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
87b60f62512f88586c4bc93c1cfcd4591ca0943a
luokunecnu/libyami
codecparsers/bitreader.h
[ "Intel" ]
C
bit_reader_get_size_unchecked
uint32_t
static inline uint32_t bit_reader_get_size_unchecked (const BitReader * reader) { return reader->size * 8; }
/* unchecked variants -- do not use */
unchecked variants -- do not use
[ "unchecked", "variants", "--", "do", "not", "use" ]
static inline uint32_t bit_reader_get_size_unchecked (const BitReader * reader) { return reader->size * 8; }
[ "static", "inline", "uint32_t", "bit_reader_get_size_unchecked", "(", "const", "BitReader", "*", "reader", ")", "{", "return", "reader", "->", "size", "*", "8", ";", "}" ]
unchecked variants -- do not use
[ "unchecked", "variants", "--", "do", "not", "use" ]
[]
[ { "param": "reader", "type": "BitReader" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "reader", "type": "BitReader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
87b60f62512f88586c4bc93c1cfcd4591ca0943a
luokunecnu/libyami
codecparsers/bitreader.h
[ "Intel" ]
C
bit_reader_get_size_inline
uint32_t
static inline uint32_t bit_reader_get_size_inline (const BitReader * reader) { RETURN_VAL_IF_FAIL(reader != NULL, 0); return bit_reader_get_size_unchecked (reader); }
/* inlined variants -- do not use directly */
inlined variants -- do not use directly
[ "inlined", "variants", "--", "do", "not", "use", "directly" ]
static inline uint32_t bit_reader_get_size_inline (const BitReader * reader) { RETURN_VAL_IF_FAIL(reader != NULL, 0); return bit_reader_get_size_unchecked (reader); }
[ "static", "inline", "uint32_t", "bit_reader_get_size_inline", "(", "const", "BitReader", "*", "reader", ")", "{", "RETURN_VAL_IF_FAIL", "(", "reader", "!=", "NULL", ",", "0", ")", ";", "return", "bit_reader_get_size_unchecked", "(", "reader", ")", ";", "}" ]
inlined variants -- do not use directly
[ "inlined", "variants", "--", "do", "not", "use", "directly" ]
[]
[ { "param": "reader", "type": "BitReader" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "reader", "type": "BitReader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cd619af45cbb0db8fd3211a9d9096b7cc719e358
luokunecnu/libyami
codecparsers/mpeg4parser.c
[ "Intel" ]
C
h263_parse
Mpeg4ParseResult
Mpeg4ParseResult h263_parse (Mpeg4Packet * packet, const uint8_t * data, uint32_t offset, size_t size) { int32_t off1, off2; ByteReader br; byte_reader_init (&br, data + offset, size - offset); RETURN_VAL_IF_FAIL (packet != NULL, MPEG4_PARSER_ERROR); if (size - offset < 3) { DEBUG ("Can't parse, buffer is to small size %li at offset %d \n", size, offset); return MPEG4_PARSER_ERROR; } off1 = find_psc (&br); if (off1 == -1) { DEBUG ("No start code prefix in this buffer \n"); return MPEG4_PARSER_NO_PACKET; } packet->offset = off1 + offset; packet->data = data; byte_reader_skip_unchecked (&br, 3); off2 = find_psc (&br); if (off2 == -1) { DEBUG ("Packet start %d, No end found \n", off1); packet->size = UINT32_MAX; return MPEG4_PARSER_NO_PACKET_END; } packet->size = (size_t) off2 - off1; DEBUG ("Complete packet found at: %d, Size: %li \n" , packet->offset, packet->size); return MPEG4_PARSER_OK; }
/** * h263_parse: * @packet: The #Mpeg4Packet to fill * @offset: offset from which to start the parsing * @data: The data to parse * @size: The size of the @data to parse * * Parses @data and fills @packet with the information of the next packet * found. * * Note that the type of the packet is meaningless in this case. * * Returns: a #Mpeg4ParseResult */
Parses @data and fills @packet with the information of the next packet found. Note that the type of the packet is meaningless in this case.
[ "Parses", "@data", "and", "fills", "@packet", "with", "the", "information", "of", "the", "next", "packet", "found", ".", "Note", "that", "the", "type", "of", "the", "packet", "is", "meaningless", "in", "this", "case", "." ]
Mpeg4ParseResult h263_parse (Mpeg4Packet * packet, const uint8_t * data, uint32_t offset, size_t size) { int32_t off1, off2; ByteReader br; byte_reader_init (&br, data + offset, size - offset); RETURN_VAL_IF_FAIL (packet != NULL, MPEG4_PARSER_ERROR); if (size - offset < 3) { DEBUG ("Can't parse, buffer is to small size %li at offset %d \n", size, offset); return MPEG4_PARSER_ERROR; } off1 = find_psc (&br); if (off1 == -1) { DEBUG ("No start code prefix in this buffer \n"); return MPEG4_PARSER_NO_PACKET; } packet->offset = off1 + offset; packet->data = data; byte_reader_skip_unchecked (&br, 3); off2 = find_psc (&br); if (off2 == -1) { DEBUG ("Packet start %d, No end found \n", off1); packet->size = UINT32_MAX; return MPEG4_PARSER_NO_PACKET_END; } packet->size = (size_t) off2 - off1; DEBUG ("Complete packet found at: %d, Size: %li \n" , packet->offset, packet->size); return MPEG4_PARSER_OK; }
[ "Mpeg4ParseResult", "h263_parse", "(", "Mpeg4Packet", "*", "packet", ",", "const", "uint8_t", "*", "data", ",", "uint32_t", "offset", ",", "size_t", "size", ")", "{", "int32_t", "off1", ",", "off2", ";", "ByteReader", "br", ";", "byte_reader_init", "(", "&", "br", ",", "data", "+", "offset", ",", "size", "-", "offset", ")", ";", "RETURN_VAL_IF_FAIL", "(", "packet", "!=", "NULL", ",", "MPEG4_PARSER_ERROR", ")", ";", "if", "(", "size", "-", "offset", "<", "3", ")", "{", "DEBUG", "(", "\"", "\\n", "\"", ",", "size", ",", "offset", ")", ";", "return", "MPEG4_PARSER_ERROR", ";", "}", "off1", "=", "find_psc", "(", "&", "br", ")", ";", "if", "(", "off1", "==", "-1", ")", "{", "DEBUG", "(", "\"", "\\n", "\"", ")", ";", "return", "MPEG4_PARSER_NO_PACKET", ";", "}", "packet", "->", "offset", "=", "off1", "+", "offset", ";", "packet", "->", "data", "=", "data", ";", "byte_reader_skip_unchecked", "(", "&", "br", ",", "3", ")", ";", "off2", "=", "find_psc", "(", "&", "br", ")", ";", "if", "(", "off2", "==", "-1", ")", "{", "DEBUG", "(", "\"", "\\n", "\"", ",", "off1", ")", ";", "packet", "->", "size", "=", "UINT32_MAX", ";", "return", "MPEG4_PARSER_NO_PACKET_END", ";", "}", "packet", "->", "size", "=", "(", "size_t", ")", "off2", "-", "off1", ";", "DEBUG", "(", "\"", "\\n", "\"", ",", "packet", "->", "offset", ",", "packet", "->", "size", ")", ";", "return", "MPEG4_PARSER_OK", ";", "}" ]
h263_parse: @packet: The #Mpeg4Packet to fill @offset: offset from which to start the parsing @data: The data to parse @size: The size of the @data to parse
[ "h263_parse", ":", "@packet", ":", "The", "#Mpeg4Packet", "to", "fill", "@offset", ":", "offset", "from", "which", "to", "start", "the", "parsing", "@data", ":", "The", "data", "to", "parse", "@size", ":", "The", "size", "of", "the", "@data", "to", "parse" ]
[]
[ { "param": "packet", "type": "Mpeg4Packet" }, { "param": "data", "type": "uint8_t" }, { "param": "offset", "type": "uint32_t" }, { "param": "size", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "packet", "type": "Mpeg4Packet", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cd619af45cbb0db8fd3211a9d9096b7cc719e358
luokunecnu/libyami
codecparsers/mpeg4parser.c
[ "Intel" ]
C
mpeg4_parse_video_packet_header
Mpeg4ParseResult
Mpeg4ParseResult mpeg4_parse_video_packet_header (Mpeg4VideoPacketHdr * videopackethdr, Mpeg4VideoObjectLayer * vol, Mpeg4VideoObjectPlane * vop, Mpeg4SpriteTrajectory * sprite_trajectory, const uint8_t * data, size_t size) { uint8_t markersize; BitReader br = BIT_READER_INIT (data, size); RETURN_VAL_IF_FAIL (videopackethdr != NULL, MPEG4_PARSER_ERROR); RETURN_VAL_IF_FAIL (vol != NULL, MPEG4_PARSER_ERROR); markersize = compute_resync_marker_size (vop, NULL, NULL); CHECK_REMAINING (&br, markersize); if (bit_reader_get_bits_uint32_unchecked (&br, markersize + 1) != 0x01) goto failed; if (vol->shape != MPEG4_RECTANGULAR) { READ_UINT8 (&br, videopackethdr->header_extension_code, 1); if (vol->sprite_enable == MPEG4_SPRITE_STATIC && vop->coding_type == MPEG4_I_VOP) { CHECK_REMAINING (&br, 56); U_READ_UINT16 (&br, vop->width, 13); CHECK_MARKER (&br); U_READ_UINT16 (&br, vop->height, 13); CHECK_MARKER (&br); U_READ_UINT16 (&br, vop->horizontal_mc_spatial_ref, 13); CHECK_MARKER (&br); U_READ_UINT16 (&br, vop->vertical_mc_spatial_ref, 13); CHECK_MARKER (&br); /* Update macroblock infirmations */ vop->mb_height = (vop->height + 15) / 16; vop->mb_width = (vop->width + 15) / 16; vop->mb_num = vop->mb_height * vop->mb_width; } } READ_UINT16 (&br, videopackethdr->macroblock_number, BIT_STORAGE_CALCULATE (vop->mb_num - 1)); if (vol->shape != MPEG4_BINARY_ONLY) READ_UINT16 (&br, videopackethdr->quant_scale, vol->quant_precision); if (vol->shape == MPEG4_RECTANGULAR) READ_UINT8 (&br, videopackethdr->header_extension_code, 1); if (videopackethdr->header_extension_code) { uint32_t timeincr = 0; uint8_t bit = 0, coding_type; do { READ_UINT8 (&br, bit, 1); timeincr++; } while (bit); vol->vop_time_increment_bits = timeincr; CHECK_MARKER (&br); READ_UINT16 (&br, vop->time_increment, timeincr); CHECK_MARKER (&br); READ_UINT8 (&br, coding_type, 2); vop->coding_type = coding_type; if (vol->shape != MPEG4_RECTANGULAR) { READ_UINT8 (&br, vop->change_conv_ratio_disable, 1); if (vop->coding_type != MPEG4_I_VOP) READ_UINT8 (&br, vop->shape_coding_type, 1); } if (vol->shape != MPEG4_BINARY_ONLY) { READ_UINT8 (&br, vop->intra_dc_vlc_thr, 3); if (sprite_trajectory && vol->sprite_enable == MPEG4_SPRITE_GMG && vop->coding_type == MPEG4_S_VOP && vol->no_of_sprite_warping_points > 0) { parse_sprite_trajectory (&br, sprite_trajectory, vol->no_of_sprite_warping_points); } if (vol->reduced_resolution_vop_enable && vol->shape == MPEG4_RECTANGULAR && (vop->coding_type == MPEG4_P_VOP || vop->coding_type == MPEG4_I_VOP)) READ_UINT8 (&br, vop->reduced_resolution, 1); if (vop->coding_type != MPEG4_I_VOP) { READ_UINT8 (&br, vop->fcode_forward, 3); CHECK_ALLOWED (vop->fcode_forward, 1, 7); } if (vop->coding_type == MPEG4_B_VOP) { READ_UINT8 (&br, vop->fcode_backward, 3); CHECK_ALLOWED (vop->fcode_backward, 1, 7); } } } if (vol->newpred_enable) { uint16_t nbbits = vol->vop_time_increment_bits + 3 < 15 ? vop->time_increment + 3 : 15; READ_UINT16 (&br, vop->id, nbbits); READ_UINT8 (&br, vop->id_for_prediction_indication, 1); if (vop->id_for_prediction_indication) { /* Would be nice if the standard actually told us... */ READ_UINT16 (&br, vop->id, nbbits); CHECK_MARKER (&br); } } videopackethdr->size = bit_reader_get_pos (&br); failed: DEBUG ("Failed to parse video packet header \n"); return MPEG4_PARSER_NO_PACKET; }
/** * mpeg4_parse_video_packet_header: * @videopackethdr: The #Mpeg4VideoPacketHdr structure to fill * @vol: The last parsed #Mpeg4VideoObjectLayer, will be updated * with the informations found during the parsing * @vop: The last parsed #Mpeg4VideoObjectPlane, will be updated * with the informations found during the parsing * @sprite_trajectory: A #Mpeg4SpriteTrajectory to fill or %NULL * with the informations found during the parsing * @data: The data to parse, should be set after the resync marker. * @size: The size of the data to parse * * Parsers @data containing the video packet header * and fills the @videopackethdr structure */
Parsers @data containing the video packet header and fills the @videopackethdr structure
[ "Parsers", "@data", "containing", "the", "video", "packet", "header", "and", "fills", "the", "@videopackethdr", "structure" ]
Mpeg4ParseResult mpeg4_parse_video_packet_header (Mpeg4VideoPacketHdr * videopackethdr, Mpeg4VideoObjectLayer * vol, Mpeg4VideoObjectPlane * vop, Mpeg4SpriteTrajectory * sprite_trajectory, const uint8_t * data, size_t size) { uint8_t markersize; BitReader br = BIT_READER_INIT (data, size); RETURN_VAL_IF_FAIL (videopackethdr != NULL, MPEG4_PARSER_ERROR); RETURN_VAL_IF_FAIL (vol != NULL, MPEG4_PARSER_ERROR); markersize = compute_resync_marker_size (vop, NULL, NULL); CHECK_REMAINING (&br, markersize); if (bit_reader_get_bits_uint32_unchecked (&br, markersize + 1) != 0x01) goto failed; if (vol->shape != MPEG4_RECTANGULAR) { READ_UINT8 (&br, videopackethdr->header_extension_code, 1); if (vol->sprite_enable == MPEG4_SPRITE_STATIC && vop->coding_type == MPEG4_I_VOP) { CHECK_REMAINING (&br, 56); U_READ_UINT16 (&br, vop->width, 13); CHECK_MARKER (&br); U_READ_UINT16 (&br, vop->height, 13); CHECK_MARKER (&br); U_READ_UINT16 (&br, vop->horizontal_mc_spatial_ref, 13); CHECK_MARKER (&br); U_READ_UINT16 (&br, vop->vertical_mc_spatial_ref, 13); CHECK_MARKER (&br); vop->mb_height = (vop->height + 15) / 16; vop->mb_width = (vop->width + 15) / 16; vop->mb_num = vop->mb_height * vop->mb_width; } } READ_UINT16 (&br, videopackethdr->macroblock_number, BIT_STORAGE_CALCULATE (vop->mb_num - 1)); if (vol->shape != MPEG4_BINARY_ONLY) READ_UINT16 (&br, videopackethdr->quant_scale, vol->quant_precision); if (vol->shape == MPEG4_RECTANGULAR) READ_UINT8 (&br, videopackethdr->header_extension_code, 1); if (videopackethdr->header_extension_code) { uint32_t timeincr = 0; uint8_t bit = 0, coding_type; do { READ_UINT8 (&br, bit, 1); timeincr++; } while (bit); vol->vop_time_increment_bits = timeincr; CHECK_MARKER (&br); READ_UINT16 (&br, vop->time_increment, timeincr); CHECK_MARKER (&br); READ_UINT8 (&br, coding_type, 2); vop->coding_type = coding_type; if (vol->shape != MPEG4_RECTANGULAR) { READ_UINT8 (&br, vop->change_conv_ratio_disable, 1); if (vop->coding_type != MPEG4_I_VOP) READ_UINT8 (&br, vop->shape_coding_type, 1); } if (vol->shape != MPEG4_BINARY_ONLY) { READ_UINT8 (&br, vop->intra_dc_vlc_thr, 3); if (sprite_trajectory && vol->sprite_enable == MPEG4_SPRITE_GMG && vop->coding_type == MPEG4_S_VOP && vol->no_of_sprite_warping_points > 0) { parse_sprite_trajectory (&br, sprite_trajectory, vol->no_of_sprite_warping_points); } if (vol->reduced_resolution_vop_enable && vol->shape == MPEG4_RECTANGULAR && (vop->coding_type == MPEG4_P_VOP || vop->coding_type == MPEG4_I_VOP)) READ_UINT8 (&br, vop->reduced_resolution, 1); if (vop->coding_type != MPEG4_I_VOP) { READ_UINT8 (&br, vop->fcode_forward, 3); CHECK_ALLOWED (vop->fcode_forward, 1, 7); } if (vop->coding_type == MPEG4_B_VOP) { READ_UINT8 (&br, vop->fcode_backward, 3); CHECK_ALLOWED (vop->fcode_backward, 1, 7); } } } if (vol->newpred_enable) { uint16_t nbbits = vol->vop_time_increment_bits + 3 < 15 ? vop->time_increment + 3 : 15; READ_UINT16 (&br, vop->id, nbbits); READ_UINT8 (&br, vop->id_for_prediction_indication, 1); if (vop->id_for_prediction_indication) { READ_UINT16 (&br, vop->id, nbbits); CHECK_MARKER (&br); } } videopackethdr->size = bit_reader_get_pos (&br); failed: DEBUG ("Failed to parse video packet header \n"); return MPEG4_PARSER_NO_PACKET; }
[ "Mpeg4ParseResult", "mpeg4_parse_video_packet_header", "(", "Mpeg4VideoPacketHdr", "*", "videopackethdr", ",", "Mpeg4VideoObjectLayer", "*", "vol", ",", "Mpeg4VideoObjectPlane", "*", "vop", ",", "Mpeg4SpriteTrajectory", "*", "sprite_trajectory", ",", "const", "uint8_t", "*", "data", ",", "size_t", "size", ")", "{", "uint8_t", "markersize", ";", "BitReader", "br", "=", "BIT_READER_INIT", "(", "data", ",", "size", ")", ";", "RETURN_VAL_IF_FAIL", "(", "videopackethdr", "!=", "NULL", ",", "MPEG4_PARSER_ERROR", ")", ";", "RETURN_VAL_IF_FAIL", "(", "vol", "!=", "NULL", ",", "MPEG4_PARSER_ERROR", ")", ";", "markersize", "=", "compute_resync_marker_size", "(", "vop", ",", "NULL", ",", "NULL", ")", ";", "CHECK_REMAINING", "(", "&", "br", ",", "markersize", ")", ";", "if", "(", "bit_reader_get_bits_uint32_unchecked", "(", "&", "br", ",", "markersize", "+", "1", ")", "!=", "0x01", ")", "goto", "failed", ";", "if", "(", "vol", "->", "shape", "!=", "MPEG4_RECTANGULAR", ")", "{", "READ_UINT8", "(", "&", "br", ",", "videopackethdr", "->", "header_extension_code", ",", "1", ")", ";", "if", "(", "vol", "->", "sprite_enable", "==", "MPEG4_SPRITE_STATIC", "&&", "vop", "->", "coding_type", "==", "MPEG4_I_VOP", ")", "{", "CHECK_REMAINING", "(", "&", "br", ",", "56", ")", ";", "U_READ_UINT16", "(", "&", "br", ",", "vop", "->", "width", ",", "13", ")", ";", "CHECK_MARKER", "(", "&", "br", ")", ";", "U_READ_UINT16", "(", "&", "br", ",", "vop", "->", "height", ",", "13", ")", ";", "CHECK_MARKER", "(", "&", "br", ")", ";", "U_READ_UINT16", "(", "&", "br", ",", "vop", "->", "horizontal_mc_spatial_ref", ",", "13", ")", ";", "CHECK_MARKER", "(", "&", "br", ")", ";", "U_READ_UINT16", "(", "&", "br", ",", "vop", "->", "vertical_mc_spatial_ref", ",", "13", ")", ";", "CHECK_MARKER", "(", "&", "br", ")", ";", "vop", "->", "mb_height", "=", "(", "vop", "->", "height", "+", "15", ")", "/", "16", ";", "vop", "->", "mb_width", "=", "(", "vop", "->", "width", "+", "15", ")", "/", "16", ";", "vop", "->", "mb_num", "=", "vop", "->", "mb_height", "*", "vop", "->", "mb_width", ";", "}", "}", "READ_UINT16", "(", "&", "br", ",", "videopackethdr", "->", "macroblock_number", ",", "BIT_STORAGE_CALCULATE", "(", "vop", "->", "mb_num", "-", "1", ")", ")", ";", "if", "(", "vol", "->", "shape", "!=", "MPEG4_BINARY_ONLY", ")", "READ_UINT16", "(", "&", "br", ",", "videopackethdr", "->", "quant_scale", ",", "vol", "->", "quant_precision", ")", ";", "if", "(", "vol", "->", "shape", "==", "MPEG4_RECTANGULAR", ")", "READ_UINT8", "(", "&", "br", ",", "videopackethdr", "->", "header_extension_code", ",", "1", ")", ";", "if", "(", "videopackethdr", "->", "header_extension_code", ")", "{", "uint32_t", "timeincr", "=", "0", ";", "uint8_t", "bit", "=", "0", ",", "coding_type", ";", "do", "{", "READ_UINT8", "(", "&", "br", ",", "bit", ",", "1", ")", ";", "timeincr", "++", ";", "}", "while", "(", "bit", ")", ";", "vol", "->", "vop_time_increment_bits", "=", "timeincr", ";", "CHECK_MARKER", "(", "&", "br", ")", ";", "READ_UINT16", "(", "&", "br", ",", "vop", "->", "time_increment", ",", "timeincr", ")", ";", "CHECK_MARKER", "(", "&", "br", ")", ";", "READ_UINT8", "(", "&", "br", ",", "coding_type", ",", "2", ")", ";", "vop", "->", "coding_type", "=", "coding_type", ";", "if", "(", "vol", "->", "shape", "!=", "MPEG4_RECTANGULAR", ")", "{", "READ_UINT8", "(", "&", "br", ",", "vop", "->", "change_conv_ratio_disable", ",", "1", ")", ";", "if", "(", "vop", "->", "coding_type", "!=", "MPEG4_I_VOP", ")", "READ_UINT8", "(", "&", "br", ",", "vop", "->", "shape_coding_type", ",", "1", ")", ";", "}", "if", "(", "vol", "->", "shape", "!=", "MPEG4_BINARY_ONLY", ")", "{", "READ_UINT8", "(", "&", "br", ",", "vop", "->", "intra_dc_vlc_thr", ",", "3", ")", ";", "if", "(", "sprite_trajectory", "&&", "vol", "->", "sprite_enable", "==", "MPEG4_SPRITE_GMG", "&&", "vop", "->", "coding_type", "==", "MPEG4_S_VOP", "&&", "vol", "->", "no_of_sprite_warping_points", ">", "0", ")", "{", "parse_sprite_trajectory", "(", "&", "br", ",", "sprite_trajectory", ",", "vol", "->", "no_of_sprite_warping_points", ")", ";", "}", "if", "(", "vol", "->", "reduced_resolution_vop_enable", "&&", "vol", "->", "shape", "==", "MPEG4_RECTANGULAR", "&&", "(", "vop", "->", "coding_type", "==", "MPEG4_P_VOP", "||", "vop", "->", "coding_type", "==", "MPEG4_I_VOP", ")", ")", "READ_UINT8", "(", "&", "br", ",", "vop", "->", "reduced_resolution", ",", "1", ")", ";", "if", "(", "vop", "->", "coding_type", "!=", "MPEG4_I_VOP", ")", "{", "READ_UINT8", "(", "&", "br", ",", "vop", "->", "fcode_forward", ",", "3", ")", ";", "CHECK_ALLOWED", "(", "vop", "->", "fcode_forward", ",", "1", ",", "7", ")", ";", "}", "if", "(", "vop", "->", "coding_type", "==", "MPEG4_B_VOP", ")", "{", "READ_UINT8", "(", "&", "br", ",", "vop", "->", "fcode_backward", ",", "3", ")", ";", "CHECK_ALLOWED", "(", "vop", "->", "fcode_backward", ",", "1", ",", "7", ")", ";", "}", "}", "}", "if", "(", "vol", "->", "newpred_enable", ")", "{", "uint16_t", "nbbits", "=", "vol", "->", "vop_time_increment_bits", "+", "3", "<", "15", "?", "vop", "->", "time_increment", "+", "3", ":", "15", ";", "READ_UINT16", "(", "&", "br", ",", "vop", "->", "id", ",", "nbbits", ")", ";", "READ_UINT8", "(", "&", "br", ",", "vop", "->", "id_for_prediction_indication", ",", "1", ")", ";", "if", "(", "vop", "->", "id_for_prediction_indication", ")", "{", "READ_UINT16", "(", "&", "br", ",", "vop", "->", "id", ",", "nbbits", ")", ";", "CHECK_MARKER", "(", "&", "br", ")", ";", "}", "}", "videopackethdr", "->", "size", "=", "bit_reader_get_pos", "(", "&", "br", ")", ";", "failed", ":", "DEBUG", "(", "\"", "\\n", "\"", ")", ";", "return", "MPEG4_PARSER_NO_PACKET", ";", "}" ]
mpeg4_parse_video_packet_header: @videopackethdr: The #Mpeg4VideoPacketHdr structure to fill @vol: The last parsed #Mpeg4VideoObjectLayer, will be updated with the informations found during the parsing @vop: The last parsed #Mpeg4VideoObjectPlane, will be updated with the informations found during the parsing @sprite_trajectory: A #Mpeg4SpriteTrajectory to fill or %NULL with the informations found during the parsing @data: The data to parse, should be set after the resync marker.
[ "mpeg4_parse_video_packet_header", ":", "@videopackethdr", ":", "The", "#Mpeg4VideoPacketHdr", "structure", "to", "fill", "@vol", ":", "The", "last", "parsed", "#Mpeg4VideoObjectLayer", "will", "be", "updated", "with", "the", "informations", "found", "during", "the", "parsing", "@vop", ":", "The", "last", "parsed", "#Mpeg4VideoObjectPlane", "will", "be", "updated", "with", "the", "informations", "found", "during", "the", "parsing", "@sprite_trajectory", ":", "A", "#Mpeg4SpriteTrajectory", "to", "fill", "or", "%NULL", "with", "the", "informations", "found", "during", "the", "parsing", "@data", ":", "The", "data", "to", "parse", "should", "be", "set", "after", "the", "resync", "marker", "." ]
[ "/* Update macroblock infirmations */", "/* Would be nice if the standard actually told us... */" ]
[ { "param": "videopackethdr", "type": "Mpeg4VideoPacketHdr" }, { "param": "vol", "type": "Mpeg4VideoObjectLayer" }, { "param": "vop", "type": "Mpeg4VideoObjectPlane" }, { "param": "sprite_trajectory", "type": "Mpeg4SpriteTrajectory" }, { "param": "data", "type": "uint8_t" }, { "param": "size", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "videopackethdr", "type": "Mpeg4VideoPacketHdr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vol", "type": "Mpeg4VideoObjectLayer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vop", "type": "Mpeg4VideoObjectPlane", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sprite_trajectory", "type": "Mpeg4SpriteTrajectory", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b1418b7413f755a2b2bbc31e113beaa99f1311df
luokunecnu/libyami
codecparsers/bitwriter.c
[ "Intel" ]
C
bit_writer_free
void
void bit_writer_free (BitWriter * writer, BOOL free_data) { if (writer == NULL) return; bit_writer_clear (writer, free_data); free (writer); }
/** * bit_writer_free: * @bitwriter: a #BitWriter instance * @free_data: flag to free @data which is allocated inside * * Clear a #BitWriter instance and destroy allocated data inside if * @free_data is %TRUE */
@bitwriter: a #BitWriter instance @free_data: flag to free @data which is allocated inside Clear a #BitWriter instance and destroy allocated data inside if @free_data is %TRUE
[ "@bitwriter", ":", "a", "#BitWriter", "instance", "@free_data", ":", "flag", "to", "free", "@data", "which", "is", "allocated", "inside", "Clear", "a", "#BitWriter", "instance", "and", "destroy", "allocated", "data", "inside", "if", "@free_data", "is", "%TRUE" ]
void bit_writer_free (BitWriter * writer, BOOL free_data) { if (writer == NULL) return; bit_writer_clear (writer, free_data); free (writer); }
[ "void", "bit_writer_free", "(", "BitWriter", "*", "writer", ",", "BOOL", "free_data", ")", "{", "if", "(", "writer", "==", "NULL", ")", "return", ";", "bit_writer_clear", "(", "writer", ",", "free_data", ")", ";", "free", "(", "writer", ")", ";", "}" ]
bit_writer_free: @bitwriter: a #BitWriter instance @free_data: flag to free @data which is allocated inside
[ "bit_writer_free", ":", "@bitwriter", ":", "a", "#BitWriter", "instance", "@free_data", ":", "flag", "to", "free", "@data", "which", "is", "allocated", "inside" ]
[]
[ { "param": "writer", "type": "BitWriter" }, { "param": "free_data", "type": "BOOL" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "writer", "type": "BitWriter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "free_data", "type": "BOOL", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d70723d31b21143acd3803e2f8855543a6269a63
luokunecnu/libyami
codecparsers/h264parser.c
[ "Intel" ]
C
h264_parser_parse_nal
H264ParserResult
H264ParserResult h264_parser_parse_nal (H264NalParser * nalparser, H264NalUnit * nalu) { H264SPS sps; H264PPS pps; switch (nalu->type) { case H264_NAL_SPS: return h264_parser_parse_sps (nalparser, nalu, &sps, FALSE); break; case H264_NAL_PPS: return h264_parser_parse_pps (nalparser, nalu, &pps); } return H264_PARSER_OK; }
/** * h264_parser_parse_nal: * @nalparser: a #H264NalParser * @nalu: The #H264NalUnit to parse * * This function should be called in the case one doesn't need to * parse a specific structure. It is necessary to do so to make * sure @nalparser is up to date. * * Returns: a #H264ParserResult */
@nalparser: a #H264NalParser @nalu: The #H264NalUnit to parse This function should be called in the case one doesn't need to parse a specific structure. It is necessary to do so to make sure @nalparser is up to date.
[ "@nalparser", ":", "a", "#H264NalParser", "@nalu", ":", "The", "#H264NalUnit", "to", "parse", "This", "function", "should", "be", "called", "in", "the", "case", "one", "doesn", "'", "t", "need", "to", "parse", "a", "specific", "structure", ".", "It", "is", "necessary", "to", "do", "so", "to", "make", "sure", "@nalparser", "is", "up", "to", "date", "." ]
H264ParserResult h264_parser_parse_nal (H264NalParser * nalparser, H264NalUnit * nalu) { H264SPS sps; H264PPS pps; switch (nalu->type) { case H264_NAL_SPS: return h264_parser_parse_sps (nalparser, nalu, &sps, FALSE); break; case H264_NAL_PPS: return h264_parser_parse_pps (nalparser, nalu, &pps); } return H264_PARSER_OK; }
[ "H264ParserResult", "h264_parser_parse_nal", "(", "H264NalParser", "*", "nalparser", ",", "H264NalUnit", "*", "nalu", ")", "{", "H264SPS", "sps", ";", "H264PPS", "pps", ";", "switch", "(", "nalu", "->", "type", ")", "{", "case", "H264_NAL_SPS", ":", "return", "h264_parser_parse_sps", "(", "nalparser", ",", "nalu", ",", "&", "sps", ",", "FALSE", ")", ";", "break", ";", "case", "H264_NAL_PPS", ":", "return", "h264_parser_parse_pps", "(", "nalparser", ",", "nalu", ",", "&", "pps", ")", ";", "}", "return", "H264_PARSER_OK", ";", "}" ]
h264_parser_parse_nal: @nalparser: a #H264NalParser @nalu: The #H264NalUnit to parse
[ "h264_parser_parse_nal", ":", "@nalparser", ":", "a", "#H264NalParser", "@nalu", ":", "The", "#H264NalUnit", "to", "parse" ]
[]
[ { "param": "nalparser", "type": "H264NalParser" }, { "param": "nalu", "type": "H264NalUnit" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "nalparser", "type": "H264NalParser", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nalu", "type": "H264NalUnit", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d70723d31b21143acd3803e2f8855543a6269a63
luokunecnu/libyami
codecparsers/h264parser.c
[ "Intel" ]
C
h264_sps_mvc_copy
BOOL
static BOOL h264_sps_mvc_copy (H264SPS * dst_sps, const H264SPS * src_sps) { H264SPSExtMVC *const dst_mvc = &dst_sps->extension.mvc; const H264SPSExtMVC *const src_mvc = &src_sps->extension.mvc; uint32_t i, j, k; assert (dst_sps->extension_type == H264_NAL_EXTENSION_MVC); dst_mvc->num_views_minus1 = src_mvc->num_views_minus1; dst_mvc->view = (H264SPSExtMVCView*) malloc (sizeof (H264SPSExtMVCView) * (dst_mvc->num_views_minus1 + 1)); if (!dst_mvc->view) return FALSE; dst_mvc->view[0].view_id = src_mvc->view[0].view_id; for (i = 1; i <= dst_mvc->num_views_minus1; i++) { H264SPSExtMVCView *const dst_view = &dst_mvc->view[i]; const H264SPSExtMVCView *const src_view = &src_mvc->view[i]; dst_view->view_id = src_view->view_id; dst_view->num_anchor_refs_l0 = src_view->num_anchor_refs_l1; for (j = 0; j < dst_view->num_anchor_refs_l0; j++) dst_view->anchor_ref_l0[j] = src_view->anchor_ref_l0[j]; dst_view->num_anchor_refs_l1 = src_view->num_anchor_refs_l1; for (j = 0; j < dst_view->num_anchor_refs_l1; j++) dst_view->anchor_ref_l1[j] = src_view->anchor_ref_l1[j]; dst_view->num_non_anchor_refs_l0 = src_view->num_non_anchor_refs_l1; for (j = 0; j < dst_view->num_non_anchor_refs_l0; j++) dst_view->non_anchor_ref_l0[j] = src_view->non_anchor_ref_l0[j]; dst_view->num_non_anchor_refs_l1 = src_view->num_non_anchor_refs_l1; for (j = 0; j < dst_view->num_non_anchor_refs_l1; j++) dst_view->non_anchor_ref_l1[j] = src_view->non_anchor_ref_l1[j]; } dst_mvc->num_level_values_signalled_minus1 = src_mvc->num_level_values_signalled_minus1; dst_mvc->level_value = (H264SPSExtMVCLevelValue *) malloc (sizeof (H264SPSExtMVCLevelValue) * (dst_mvc->num_level_values_signalled_minus1 + 1)); if (!dst_mvc->level_value) return FALSE; for (i = 0; i <= dst_mvc->num_level_values_signalled_minus1; i++) { H264SPSExtMVCLevelValue *const dst_value = &dst_mvc->level_value[i]; const H264SPSExtMVCLevelValue *const src_value = &src_mvc->level_value[i]; dst_value->level_idc = src_value->level_idc; dst_value->num_applicable_ops_minus1 = src_value->num_applicable_ops_minus1; dst_value->applicable_op = (H264SPSExtMVCLevelValueOp*) malloc (sizeof (H264SPSExtMVCLevelValueOp) * (dst_value->num_applicable_ops_minus1 + 1)); if (!dst_value->applicable_op) return FALSE; for (j = 0; j <= dst_value->num_applicable_ops_minus1; j++) { H264SPSExtMVCLevelValueOp *const dst_op = &dst_value->applicable_op[j]; const H264SPSExtMVCLevelValueOp *const src_op = &src_value->applicable_op[j]; dst_op->temporal_id = src_op->temporal_id; dst_op->num_target_views_minus1 = src_op->num_target_views_minus1; dst_op->target_view_id = (uint16_t*) malloc (sizeof (uint16_t) * (dst_op->num_target_views_minus1 + 1)); if (!dst_op->target_view_id) return FALSE; for (k = 0; k <= dst_op->num_target_views_minus1; k++) dst_op->target_view_id[k] = src_op->target_view_id[k]; dst_op->num_views_minus1 = src_op->num_views_minus1; } } return TRUE; }
/* Copy MVC-specific data for subset SPS header */
Copy MVC-specific data for subset SPS header
[ "Copy", "MVC", "-", "specific", "data", "for", "subset", "SPS", "header" ]
static BOOL h264_sps_mvc_copy (H264SPS * dst_sps, const H264SPS * src_sps) { H264SPSExtMVC *const dst_mvc = &dst_sps->extension.mvc; const H264SPSExtMVC *const src_mvc = &src_sps->extension.mvc; uint32_t i, j, k; assert (dst_sps->extension_type == H264_NAL_EXTENSION_MVC); dst_mvc->num_views_minus1 = src_mvc->num_views_minus1; dst_mvc->view = (H264SPSExtMVCView*) malloc (sizeof (H264SPSExtMVCView) * (dst_mvc->num_views_minus1 + 1)); if (!dst_mvc->view) return FALSE; dst_mvc->view[0].view_id = src_mvc->view[0].view_id; for (i = 1; i <= dst_mvc->num_views_minus1; i++) { H264SPSExtMVCView *const dst_view = &dst_mvc->view[i]; const H264SPSExtMVCView *const src_view = &src_mvc->view[i]; dst_view->view_id = src_view->view_id; dst_view->num_anchor_refs_l0 = src_view->num_anchor_refs_l1; for (j = 0; j < dst_view->num_anchor_refs_l0; j++) dst_view->anchor_ref_l0[j] = src_view->anchor_ref_l0[j]; dst_view->num_anchor_refs_l1 = src_view->num_anchor_refs_l1; for (j = 0; j < dst_view->num_anchor_refs_l1; j++) dst_view->anchor_ref_l1[j] = src_view->anchor_ref_l1[j]; dst_view->num_non_anchor_refs_l0 = src_view->num_non_anchor_refs_l1; for (j = 0; j < dst_view->num_non_anchor_refs_l0; j++) dst_view->non_anchor_ref_l0[j] = src_view->non_anchor_ref_l0[j]; dst_view->num_non_anchor_refs_l1 = src_view->num_non_anchor_refs_l1; for (j = 0; j < dst_view->num_non_anchor_refs_l1; j++) dst_view->non_anchor_ref_l1[j] = src_view->non_anchor_ref_l1[j]; } dst_mvc->num_level_values_signalled_minus1 = src_mvc->num_level_values_signalled_minus1; dst_mvc->level_value = (H264SPSExtMVCLevelValue *) malloc (sizeof (H264SPSExtMVCLevelValue) * (dst_mvc->num_level_values_signalled_minus1 + 1)); if (!dst_mvc->level_value) return FALSE; for (i = 0; i <= dst_mvc->num_level_values_signalled_minus1; i++) { H264SPSExtMVCLevelValue *const dst_value = &dst_mvc->level_value[i]; const H264SPSExtMVCLevelValue *const src_value = &src_mvc->level_value[i]; dst_value->level_idc = src_value->level_idc; dst_value->num_applicable_ops_minus1 = src_value->num_applicable_ops_minus1; dst_value->applicable_op = (H264SPSExtMVCLevelValueOp*) malloc (sizeof (H264SPSExtMVCLevelValueOp) * (dst_value->num_applicable_ops_minus1 + 1)); if (!dst_value->applicable_op) return FALSE; for (j = 0; j <= dst_value->num_applicable_ops_minus1; j++) { H264SPSExtMVCLevelValueOp *const dst_op = &dst_value->applicable_op[j]; const H264SPSExtMVCLevelValueOp *const src_op = &src_value->applicable_op[j]; dst_op->temporal_id = src_op->temporal_id; dst_op->num_target_views_minus1 = src_op->num_target_views_minus1; dst_op->target_view_id = (uint16_t*) malloc (sizeof (uint16_t) * (dst_op->num_target_views_minus1 + 1)); if (!dst_op->target_view_id) return FALSE; for (k = 0; k <= dst_op->num_target_views_minus1; k++) dst_op->target_view_id[k] = src_op->target_view_id[k]; dst_op->num_views_minus1 = src_op->num_views_minus1; } } return TRUE; }
[ "static", "BOOL", "h264_sps_mvc_copy", "(", "H264SPS", "*", "dst_sps", ",", "const", "H264SPS", "*", "src_sps", ")", "{", "H264SPSExtMVC", "*", "const", "dst_mvc", "=", "&", "dst_sps", "->", "extension", ".", "mvc", ";", "const", "H264SPSExtMVC", "*", "const", "src_mvc", "=", "&", "src_sps", "->", "extension", ".", "mvc", ";", "uint32_t", "i", ",", "j", ",", "k", ";", "assert", "(", "dst_sps", "->", "extension_type", "==", "H264_NAL_EXTENSION_MVC", ")", ";", "dst_mvc", "->", "num_views_minus1", "=", "src_mvc", "->", "num_views_minus1", ";", "dst_mvc", "->", "view", "=", "(", "H264SPSExtMVCView", "*", ")", "malloc", "(", "sizeof", "(", "H264SPSExtMVCView", ")", "*", "(", "dst_mvc", "->", "num_views_minus1", "+", "1", ")", ")", ";", "if", "(", "!", "dst_mvc", "->", "view", ")", "return", "FALSE", ";", "dst_mvc", "->", "view", "[", "0", "]", ".", "view_id", "=", "src_mvc", "->", "view", "[", "0", "]", ".", "view_id", ";", "for", "(", "i", "=", "1", ";", "i", "<=", "dst_mvc", "->", "num_views_minus1", ";", "i", "++", ")", "{", "H264SPSExtMVCView", "*", "const", "dst_view", "=", "&", "dst_mvc", "->", "view", "[", "i", "]", ";", "const", "H264SPSExtMVCView", "*", "const", "src_view", "=", "&", "src_mvc", "->", "view", "[", "i", "]", ";", "dst_view", "->", "view_id", "=", "src_view", "->", "view_id", ";", "dst_view", "->", "num_anchor_refs_l0", "=", "src_view", "->", "num_anchor_refs_l1", ";", "for", "(", "j", "=", "0", ";", "j", "<", "dst_view", "->", "num_anchor_refs_l0", ";", "j", "++", ")", "dst_view", "->", "anchor_ref_l0", "[", "j", "]", "=", "src_view", "->", "anchor_ref_l0", "[", "j", "]", ";", "dst_view", "->", "num_anchor_refs_l1", "=", "src_view", "->", "num_anchor_refs_l1", ";", "for", "(", "j", "=", "0", ";", "j", "<", "dst_view", "->", "num_anchor_refs_l1", ";", "j", "++", ")", "dst_view", "->", "anchor_ref_l1", "[", "j", "]", "=", "src_view", "->", "anchor_ref_l1", "[", "j", "]", ";", "dst_view", "->", "num_non_anchor_refs_l0", "=", "src_view", "->", "num_non_anchor_refs_l1", ";", "for", "(", "j", "=", "0", ";", "j", "<", "dst_view", "->", "num_non_anchor_refs_l0", ";", "j", "++", ")", "dst_view", "->", "non_anchor_ref_l0", "[", "j", "]", "=", "src_view", "->", "non_anchor_ref_l0", "[", "j", "]", ";", "dst_view", "->", "num_non_anchor_refs_l1", "=", "src_view", "->", "num_non_anchor_refs_l1", ";", "for", "(", "j", "=", "0", ";", "j", "<", "dst_view", "->", "num_non_anchor_refs_l1", ";", "j", "++", ")", "dst_view", "->", "non_anchor_ref_l1", "[", "j", "]", "=", "src_view", "->", "non_anchor_ref_l1", "[", "j", "]", ";", "}", "dst_mvc", "->", "num_level_values_signalled_minus1", "=", "src_mvc", "->", "num_level_values_signalled_minus1", ";", "dst_mvc", "->", "level_value", "=", "(", "H264SPSExtMVCLevelValue", "*", ")", "malloc", "(", "sizeof", "(", "H264SPSExtMVCLevelValue", ")", "*", "(", "dst_mvc", "->", "num_level_values_signalled_minus1", "+", "1", ")", ")", ";", "if", "(", "!", "dst_mvc", "->", "level_value", ")", "return", "FALSE", ";", "for", "(", "i", "=", "0", ";", "i", "<=", "dst_mvc", "->", "num_level_values_signalled_minus1", ";", "i", "++", ")", "{", "H264SPSExtMVCLevelValue", "*", "const", "dst_value", "=", "&", "dst_mvc", "->", "level_value", "[", "i", "]", ";", "const", "H264SPSExtMVCLevelValue", "*", "const", "src_value", "=", "&", "src_mvc", "->", "level_value", "[", "i", "]", ";", "dst_value", "->", "level_idc", "=", "src_value", "->", "level_idc", ";", "dst_value", "->", "num_applicable_ops_minus1", "=", "src_value", "->", "num_applicable_ops_minus1", ";", "dst_value", "->", "applicable_op", "=", "(", "H264SPSExtMVCLevelValueOp", "*", ")", "malloc", "(", "sizeof", "(", "H264SPSExtMVCLevelValueOp", ")", "*", "(", "dst_value", "->", "num_applicable_ops_minus1", "+", "1", ")", ")", ";", "if", "(", "!", "dst_value", "->", "applicable_op", ")", "return", "FALSE", ";", "for", "(", "j", "=", "0", ";", "j", "<=", "dst_value", "->", "num_applicable_ops_minus1", ";", "j", "++", ")", "{", "H264SPSExtMVCLevelValueOp", "*", "const", "dst_op", "=", "&", "dst_value", "->", "applicable_op", "[", "j", "]", ";", "const", "H264SPSExtMVCLevelValueOp", "*", "const", "src_op", "=", "&", "src_value", "->", "applicable_op", "[", "j", "]", ";", "dst_op", "->", "temporal_id", "=", "src_op", "->", "temporal_id", ";", "dst_op", "->", "num_target_views_minus1", "=", "src_op", "->", "num_target_views_minus1", ";", "dst_op", "->", "target_view_id", "=", "(", "uint16_t", "*", ")", "malloc", "(", "sizeof", "(", "uint16_t", ")", "*", "(", "dst_op", "->", "num_target_views_minus1", "+", "1", ")", ")", ";", "if", "(", "!", "dst_op", "->", "target_view_id", ")", "return", "FALSE", ";", "for", "(", "k", "=", "0", ";", "k", "<=", "dst_op", "->", "num_target_views_minus1", ";", "k", "++", ")", "dst_op", "->", "target_view_id", "[", "k", "]", "=", "src_op", "->", "target_view_id", "[", "k", "]", ";", "dst_op", "->", "num_views_minus1", "=", "src_op", "->", "num_views_minus1", ";", "}", "}", "return", "TRUE", ";", "}" ]
Copy MVC-specific data for subset SPS header
[ "Copy", "MVC", "-", "specific", "data", "for", "subset", "SPS", "header" ]
[]
[ { "param": "dst_sps", "type": "H264SPS" }, { "param": "src_sps", "type": "H264SPS" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dst_sps", "type": "H264SPS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src_sps", "type": "H264SPS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d70723d31b21143acd3803e2f8855543a6269a63
luokunecnu/libyami
codecparsers/h264parser.c
[ "Intel" ]
C
h264_sps_mvc_free_1
void
static void h264_sps_mvc_free_1 (H264SPS * sps) { H264SPSExtMVC *const mvc = &sps->extension.mvc; uint32_t i, j; assert (sps->extension_type == H264_NAL_EXTENSION_MVC); free (mvc->view); mvc->view = NULL; for (i = 0; i <= mvc->num_level_values_signalled_minus1; i++) { H264SPSExtMVCLevelValue *const level_value = &mvc->level_value[i]; for (j = 0; j <= level_value->num_applicable_ops_minus1; j++) { free (level_value->applicable_op[j].target_view_id); level_value->applicable_op[j].target_view_id = NULL; } free (level_value->applicable_op); level_value->applicable_op = NULL; } free (mvc->level_value); mvc->level_value = NULL; /* All meaningful MVC info are now gone, just pretend to be a * standard AVC struct now */ sps->extension_type = H264_NAL_EXTENSION_NONE; }
/* Free MVC-specific data from subset SPS header */
Free MVC-specific data from subset SPS header
[ "Free", "MVC", "-", "specific", "data", "from", "subset", "SPS", "header" ]
static void h264_sps_mvc_free_1 (H264SPS * sps) { H264SPSExtMVC *const mvc = &sps->extension.mvc; uint32_t i, j; assert (sps->extension_type == H264_NAL_EXTENSION_MVC); free (mvc->view); mvc->view = NULL; for (i = 0; i <= mvc->num_level_values_signalled_minus1; i++) { H264SPSExtMVCLevelValue *const level_value = &mvc->level_value[i]; for (j = 0; j <= level_value->num_applicable_ops_minus1; j++) { free (level_value->applicable_op[j].target_view_id); level_value->applicable_op[j].target_view_id = NULL; } free (level_value->applicable_op); level_value->applicable_op = NULL; } free (mvc->level_value); mvc->level_value = NULL; sps->extension_type = H264_NAL_EXTENSION_NONE; }
[ "static", "void", "h264_sps_mvc_free_1", "(", "H264SPS", "*", "sps", ")", "{", "H264SPSExtMVC", "*", "const", "mvc", "=", "&", "sps", "->", "extension", ".", "mvc", ";", "uint32_t", "i", ",", "j", ";", "assert", "(", "sps", "->", "extension_type", "==", "H264_NAL_EXTENSION_MVC", ")", ";", "free", "(", "mvc", "->", "view", ")", ";", "mvc", "->", "view", "=", "NULL", ";", "for", "(", "i", "=", "0", ";", "i", "<=", "mvc", "->", "num_level_values_signalled_minus1", ";", "i", "++", ")", "{", "H264SPSExtMVCLevelValue", "*", "const", "level_value", "=", "&", "mvc", "->", "level_value", "[", "i", "]", ";", "for", "(", "j", "=", "0", ";", "j", "<=", "level_value", "->", "num_applicable_ops_minus1", ";", "j", "++", ")", "{", "free", "(", "level_value", "->", "applicable_op", "[", "j", "]", ".", "target_view_id", ")", ";", "level_value", "->", "applicable_op", "[", "j", "]", ".", "target_view_id", "=", "NULL", ";", "}", "free", "(", "level_value", "->", "applicable_op", ")", ";", "level_value", "->", "applicable_op", "=", "NULL", ";", "}", "free", "(", "mvc", "->", "level_value", ")", ";", "mvc", "->", "level_value", "=", "NULL", ";", "sps", "->", "extension_type", "=", "H264_NAL_EXTENSION_NONE", ";", "}" ]
Free MVC-specific data from subset SPS header
[ "Free", "MVC", "-", "specific", "data", "from", "subset", "SPS", "header" ]
[ "/* All meaningful MVC info are now gone, just pretend to be a\n * standard AVC struct now */" ]
[ { "param": "sps", "type": "H264SPS" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sps", "type": "H264SPS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
328c92800c6fb29359c5ffb681d853691e240edd
luokunecnu/libyami
codecparsers/bytereader.c
[ "Intel" ]
C
byte_reader_masked_scan_uint32
uint32_t
uint32_t byte_reader_masked_scan_uint32 (const ByteReader * reader, uint32_t mask, uint32_t pattern, uint32_t offset, uint32_t size) { const uint8_t *data; uint32_t state; uint32_t i; RETURN_VAL_IF_FAIL (size > 0, -1); RETURN_VAL_IF_FAIL ((uint64_t) offset + size <= reader->size - reader->byte, -1); /* we can't find the pattern with less than 4 bytes */ if (size < 4) return -1; data = reader->data + reader->byte + offset; /* set the state to something that does not match */ state = ~pattern; /* now find data */ for (i = 0; i < size; i++) { /* throw away one byte and move in the next byte */ state = ((state << 8) | data[i]); if ((state & mask) == pattern) { /* we have a match but we need to have skipped at * least 4 bytes to fill the state. */ if (i >= 3) return offset + i - 3; } } /* nothing found */ return -1; }
/** * byte_reader_masked_scan_uint32: * @reader: a #ByteReader * @mask: mask to apply to data before matching against @pattern * @pattern: pattern to match (after mask is applied) * @offset: offset from which to start scanning, relative to the current * position * @size: number of bytes to scan from offset * * Scan for pattern @pattern with applied mask @mask in the byte reader data, * starting from offset @offset relative to the current position. * * The bytes in @pattern and @mask are interpreted left-to-right, regardless * of endianness. All four bytes of the pattern must be present in the * byte reader data for it to match, even if the first or last bytes are masked * out. * * It is an error to call this function without making sure that there is * enough data (offset+size bytes) in the byte reader. * * Returns: offset of the first match, or -1 if no match was found. * * Example: * <programlisting> * // Assume the reader contains 0x00 0x01 0x02 ... 0xfe 0xff * * byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x00010203, 0, 256); * // -> returns 0 * byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x00010203, 1, 255); * // -> returns -1 * byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x01020304, 1, 255); * // -> returns 1 * byte_reader_masked_scan_uint32 (reader, 0xffff, 0x0001, 0, 256); * // -> returns -1 * byte_reader_masked_scan_uint32 (reader, 0xffff, 0x0203, 0, 256); * // -> returns 0 * byte_reader_masked_scan_uint32 (reader, 0xffff0000, 0x02030000, 0, 256); * // -> returns 2 * byte_reader_masked_scan_uint32 (reader, 0xffff0000, 0x02030000, 0, 4); * // -> returns -1 * </programlisting> * * Since: 0.10.24 */
Scan for pattern @pattern with applied mask @mask in the byte reader data, starting from offset @offset relative to the current position. The bytes in @pattern and @mask are interpreted left-to-right, regardless of endianness. All four bytes of the pattern must be present in the byte reader data for it to match, even if the first or last bytes are masked out. It is an error to call this function without making sure that there is enough data (offset+size bytes) in the byte reader. offset of the first match, or -1 if no match was found. Assume the reader contains 0x00 0x01 0x02 ... 0xfe 0xff
[ "Scan", "for", "pattern", "@pattern", "with", "applied", "mask", "@mask", "in", "the", "byte", "reader", "data", "starting", "from", "offset", "@offset", "relative", "to", "the", "current", "position", ".", "The", "bytes", "in", "@pattern", "and", "@mask", "are", "interpreted", "left", "-", "to", "-", "right", "regardless", "of", "endianness", ".", "All", "four", "bytes", "of", "the", "pattern", "must", "be", "present", "in", "the", "byte", "reader", "data", "for", "it", "to", "match", "even", "if", "the", "first", "or", "last", "bytes", "are", "masked", "out", ".", "It", "is", "an", "error", "to", "call", "this", "function", "without", "making", "sure", "that", "there", "is", "enough", "data", "(", "offset", "+", "size", "bytes", ")", "in", "the", "byte", "reader", ".", "offset", "of", "the", "first", "match", "or", "-", "1", "if", "no", "match", "was", "found", ".", "Assume", "the", "reader", "contains", "0x00", "0x01", "0x02", "...", "0xfe", "0xff" ]
uint32_t byte_reader_masked_scan_uint32 (const ByteReader * reader, uint32_t mask, uint32_t pattern, uint32_t offset, uint32_t size) { const uint8_t *data; uint32_t state; uint32_t i; RETURN_VAL_IF_FAIL (size > 0, -1); RETURN_VAL_IF_FAIL ((uint64_t) offset + size <= reader->size - reader->byte, -1); if (size < 4) return -1; data = reader->data + reader->byte + offset; state = ~pattern; for (i = 0; i < size; i++) { state = ((state << 8) | data[i]); if ((state & mask) == pattern) { if (i >= 3) return offset + i - 3; } } return -1; }
[ "uint32_t", "byte_reader_masked_scan_uint32", "(", "const", "ByteReader", "*", "reader", ",", "uint32_t", "mask", ",", "uint32_t", "pattern", ",", "uint32_t", "offset", ",", "uint32_t", "size", ")", "{", "const", "uint8_t", "*", "data", ";", "uint32_t", "state", ";", "uint32_t", "i", ";", "RETURN_VAL_IF_FAIL", "(", "size", ">", "0", ",", "-1", ")", ";", "RETURN_VAL_IF_FAIL", "(", "(", "uint64_t", ")", "offset", "+", "size", "<=", "reader", "->", "size", "-", "reader", "->", "byte", ",", "-1", ")", ";", "if", "(", "size", "<", "4", ")", "return", "-1", ";", "data", "=", "reader", "->", "data", "+", "reader", "->", "byte", "+", "offset", ";", "state", "=", "~", "pattern", ";", "for", "(", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "state", "=", "(", "(", "state", "<<", "8", ")", "|", "data", "[", "i", "]", ")", ";", "if", "(", "(", "state", "&", "mask", ")", "==", "pattern", ")", "{", "if", "(", "i", ">=", "3", ")", "return", "offset", "+", "i", "-", "3", ";", "}", "}", "return", "-1", ";", "}" ]
byte_reader_masked_scan_uint32: @reader: a #ByteReader @mask: mask to apply to data before matching against @pattern @pattern: pattern to match (after mask is applied) @offset: offset from which to start scanning, relative to the current position @size: number of bytes to scan from offset
[ "byte_reader_masked_scan_uint32", ":", "@reader", ":", "a", "#ByteReader", "@mask", ":", "mask", "to", "apply", "to", "data", "before", "matching", "against", "@pattern", "@pattern", ":", "pattern", "to", "match", "(", "after", "mask", "is", "applied", ")", "@offset", ":", "offset", "from", "which", "to", "start", "scanning", "relative", "to", "the", "current", "position", "@size", ":", "number", "of", "bytes", "to", "scan", "from", "offset" ]
[ "/* we can't find the pattern with less than 4 bytes */", "/* set the state to something that does not match */", "/* now find data */", "/* throw away one byte and move in the next byte */", "/* we have a match but we need to have skipped at\n * least 4 bytes to fill the state. */", "/* nothing found */" ]
[ { "param": "reader", "type": "ByteReader" }, { "param": "mask", "type": "uint32_t" }, { "param": "pattern", "type": "uint32_t" }, { "param": "offset", "type": "uint32_t" }, { "param": "size", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "reader", "type": "ByteReader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mask", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pattern", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
328c92800c6fb29359c5ffb681d853691e240edd
luokunecnu/libyami
codecparsers/bytereader.c
[ "Intel" ]
C
byte_reader_peek_string_utf8
BOOL
BOOL byte_reader_peek_string_utf8 (const ByteReader * reader, const char ** str) { RETURN_VAL_IF_FAIL (reader != NULL, FALSE); RETURN_VAL_IF_FAIL (str != NULL, FALSE); if (byte_reader_scan_string_utf8 (reader) > 0) { *str = (const char *) (reader->data + reader->byte); } else { *str = NULL; } return (*str != NULL); }
/** * byte_reader_peek_string_utf8: * @reader: a #ByteReader instance * @str: (out) (transfer none) (array zero-terminated=1): address of a * #char pointer varieble in which to store the result * * Returns a constant pointer to the current data position if there is * a NUL-terminated string in the data (this could be just a NUL terminator). * The current position will be maintained. This will work for any * NUL-terminated string with a character width of 8 bits, so ASCII, * UTF-8, ISO-8859-N etc. * * No input checking for valid UTF-8 is done. * * This function will fail if no NUL-terminator was found in in the data. * * Returns: %TRUE if a string could be skipped, %FALSE otherwise. * * Since: 0.10.24 */
@reader: a #ByteReader instance @str: (out) (transfer none) (array zero-terminated=1): address of a #char pointer varieble in which to store the result Returns a constant pointer to the current data position if there is a NUL-terminated string in the data (this could be just a NUL terminator). The current position will be maintained. This will work for any NUL-terminated string with a character width of 8 bits, so ASCII, UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done. This function will fail if no NUL-terminator was found in in the data. %TRUE if a string could be skipped, %FALSE otherwise.
[ "@reader", ":", "a", "#ByteReader", "instance", "@str", ":", "(", "out", ")", "(", "transfer", "none", ")", "(", "array", "zero", "-", "terminated", "=", "1", ")", ":", "address", "of", "a", "#char", "pointer", "varieble", "in", "which", "to", "store", "the", "result", "Returns", "a", "constant", "pointer", "to", "the", "current", "data", "position", "if", "there", "is", "a", "NUL", "-", "terminated", "string", "in", "the", "data", "(", "this", "could", "be", "just", "a", "NUL", "terminator", ")", ".", "The", "current", "position", "will", "be", "maintained", ".", "This", "will", "work", "for", "any", "NUL", "-", "terminated", "string", "with", "a", "character", "width", "of", "8", "bits", "so", "ASCII", "UTF", "-", "8", "ISO", "-", "8859", "-", "N", "etc", ".", "No", "input", "checking", "for", "valid", "UTF", "-", "8", "is", "done", ".", "This", "function", "will", "fail", "if", "no", "NUL", "-", "terminator", "was", "found", "in", "in", "the", "data", ".", "%TRUE", "if", "a", "string", "could", "be", "skipped", "%FALSE", "otherwise", "." ]
BOOL byte_reader_peek_string_utf8 (const ByteReader * reader, const char ** str) { RETURN_VAL_IF_FAIL (reader != NULL, FALSE); RETURN_VAL_IF_FAIL (str != NULL, FALSE); if (byte_reader_scan_string_utf8 (reader) > 0) { *str = (const char *) (reader->data + reader->byte); } else { *str = NULL; } return (*str != NULL); }
[ "BOOL", "byte_reader_peek_string_utf8", "(", "const", "ByteReader", "*", "reader", ",", "const", "char", "*", "*", "str", ")", "{", "RETURN_VAL_IF_FAIL", "(", "reader", "!=", "NULL", ",", "FALSE", ")", ";", "RETURN_VAL_IF_FAIL", "(", "str", "!=", "NULL", ",", "FALSE", ")", ";", "if", "(", "byte_reader_scan_string_utf8", "(", "reader", ")", ">", "0", ")", "{", "*", "str", "=", "(", "const", "char", "*", ")", "(", "reader", "->", "data", "+", "reader", "->", "byte", ")", ";", "}", "else", "{", "*", "str", "=", "NULL", ";", "}", "return", "(", "*", "str", "!=", "NULL", ")", ";", "}" ]
byte_reader_peek_string_utf8: @reader: a #ByteReader instance @str: (out) (transfer none) (array zero-terminated=1): address of a #char pointer varieble in which to store the result
[ "byte_reader_peek_string_utf8", ":", "@reader", ":", "a", "#ByteReader", "instance", "@str", ":", "(", "out", ")", "(", "transfer", "none", ")", "(", "array", "zero", "-", "terminated", "=", "1", ")", ":", "address", "of", "a", "#char", "pointer", "varieble", "in", "which", "to", "store", "the", "result" ]
[]
[ { "param": "reader", "type": "ByteReader" }, { "param": "str", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "reader", "type": "ByteReader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
328c92800c6fb29359c5ffb681d853691e240edd
luokunecnu/libyami
codecparsers/bytereader.c
[ "Intel" ]
C
byte_reader_get_string_utf8
BOOL
BOOL byte_reader_get_string_utf8 (ByteReader * reader, const char ** str) { uint32_t size; /* size in bytes including the terminator */ RETURN_VAL_IF_FAIL (reader != NULL, FALSE); RETURN_VAL_IF_FAIL (str != NULL, FALSE); size = byte_reader_scan_string_utf8 (reader); if (size == 0) { *str = NULL; return FALSE; } *str = (const char *) (reader->data + reader->byte); reader->byte += size; return TRUE; }
/** * byte_reader_get_string_utf8: * @reader: a #ByteReader instance * @str: (out) (transfer none) (array zero-terminated=1): address of a * #char pointer varieble in which to store the result * * Returns a constant pointer to the current data position if there is * a NUL-terminated string in the data (this could be just a NUL terminator), * advancing the current position to the byte after the string. This will work * for any NUL-terminated string with a character width of 8 bits, so ASCII, * UTF-8, ISO-8859-N etc. * * No input checking for valid UTF-8 is done. * * This function will fail if no NUL-terminator was found in in the data. * * Returns: %TRUE if a string could be found, %FALSE otherwise. * * Since: 0.10.24 */
@reader: a #ByteReader instance @str: (out) (transfer none) (array zero-terminated=1): address of a #char pointer varieble in which to store the result Returns a constant pointer to the current data position if there is a NUL-terminated string in the data (this could be just a NUL terminator), advancing the current position to the byte after the string. This will work for any NUL-terminated string with a character width of 8 bits, so ASCII, UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done. This function will fail if no NUL-terminator was found in in the data. %TRUE if a string could be found, %FALSE otherwise.
[ "@reader", ":", "a", "#ByteReader", "instance", "@str", ":", "(", "out", ")", "(", "transfer", "none", ")", "(", "array", "zero", "-", "terminated", "=", "1", ")", ":", "address", "of", "a", "#char", "pointer", "varieble", "in", "which", "to", "store", "the", "result", "Returns", "a", "constant", "pointer", "to", "the", "current", "data", "position", "if", "there", "is", "a", "NUL", "-", "terminated", "string", "in", "the", "data", "(", "this", "could", "be", "just", "a", "NUL", "terminator", ")", "advancing", "the", "current", "position", "to", "the", "byte", "after", "the", "string", ".", "This", "will", "work", "for", "any", "NUL", "-", "terminated", "string", "with", "a", "character", "width", "of", "8", "bits", "so", "ASCII", "UTF", "-", "8", "ISO", "-", "8859", "-", "N", "etc", ".", "No", "input", "checking", "for", "valid", "UTF", "-", "8", "is", "done", ".", "This", "function", "will", "fail", "if", "no", "NUL", "-", "terminator", "was", "found", "in", "in", "the", "data", ".", "%TRUE", "if", "a", "string", "could", "be", "found", "%FALSE", "otherwise", "." ]
BOOL byte_reader_get_string_utf8 (ByteReader * reader, const char ** str) { uint32_t size; RETURN_VAL_IF_FAIL (reader != NULL, FALSE); RETURN_VAL_IF_FAIL (str != NULL, FALSE); size = byte_reader_scan_string_utf8 (reader); if (size == 0) { *str = NULL; return FALSE; } *str = (const char *) (reader->data + reader->byte); reader->byte += size; return TRUE; }
[ "BOOL", "byte_reader_get_string_utf8", "(", "ByteReader", "*", "reader", ",", "const", "char", "*", "*", "str", ")", "{", "uint32_t", "size", ";", "RETURN_VAL_IF_FAIL", "(", "reader", "!=", "NULL", ",", "FALSE", ")", ";", "RETURN_VAL_IF_FAIL", "(", "str", "!=", "NULL", ",", "FALSE", ")", ";", "size", "=", "byte_reader_scan_string_utf8", "(", "reader", ")", ";", "if", "(", "size", "==", "0", ")", "{", "*", "str", "=", "NULL", ";", "return", "FALSE", ";", "}", "*", "str", "=", "(", "const", "char", "*", ")", "(", "reader", "->", "data", "+", "reader", "->", "byte", ")", ";", "reader", "->", "byte", "+=", "size", ";", "return", "TRUE", ";", "}" ]
byte_reader_get_string_utf8: @reader: a #ByteReader instance @str: (out) (transfer none) (array zero-terminated=1): address of a #char pointer varieble in which to store the result
[ "byte_reader_get_string_utf8", ":", "@reader", ":", "a", "#ByteReader", "instance", "@str", ":", "(", "out", ")", "(", "transfer", "none", ")", "(", "array", "zero", "-", "terminated", "=", "1", ")", ":", "address", "of", "a", "#char", "pointer", "varieble", "in", "which", "to", "store", "the", "result" ]
[ "/* size in bytes including the terminator */" ]
[ { "param": "reader", "type": "ByteReader" }, { "param": "str", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "reader", "type": "ByteReader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d0668e0959b65bfaa7d65aaa7a3d4d28ba0c7444
luokunecnu/libyami
codecparsers/nalreader.c
[ "Intel" ]
C
nal_reader_get_pos
uint32_t
uint32_t nal_reader_get_pos (const NalReader * reader) { return reader->byte * 8 - reader->bits_in_cache; }
/** * nal_reader_get_pos: * @reader: a #NalReader instance * * Returns the current position of a NalReader instance in bits. * * Returns: The current position in bits * */
@reader: a #NalReader instance Returns the current position of a NalReader instance in bits. The current position in bits
[ "@reader", ":", "a", "#NalReader", "instance", "Returns", "the", "current", "position", "of", "a", "NalReader", "instance", "in", "bits", ".", "The", "current", "position", "in", "bits" ]
uint32_t nal_reader_get_pos (const NalReader * reader) { return reader->byte * 8 - reader->bits_in_cache; }
[ "uint32_t", "nal_reader_get_pos", "(", "const", "NalReader", "*", "reader", ")", "{", "return", "reader", "->", "byte", "*", "8", "-", "reader", "->", "bits_in_cache", ";", "}" ]
nal_reader_get_pos: @reader: a #NalReader instance
[ "nal_reader_get_pos", ":", "@reader", ":", "a", "#NalReader", "instance" ]
[]
[ { "param": "reader", "type": "NalReader" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "reader", "type": "NalReader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d0668e0959b65bfaa7d65aaa7a3d4d28ba0c7444
luokunecnu/libyami
codecparsers/nalreader.c
[ "Intel" ]
C
nal_reader_get_epb_count
uint32_t
uint32_t nal_reader_get_epb_count (const NalReader * reader) { return reader->n_epb; }
/** * nal_reader_get_epb: * @reader: a #NalReader instance * * Returns the total number of emulation prevention bytes. * * Returns: The sum of epb. * */
@reader: a #NalReader instance Returns the total number of emulation prevention bytes. The sum of epb.
[ "@reader", ":", "a", "#NalReader", "instance", "Returns", "the", "total", "number", "of", "emulation", "prevention", "bytes", ".", "The", "sum", "of", "epb", "." ]
uint32_t nal_reader_get_epb_count (const NalReader * reader) { return reader->n_epb; }
[ "uint32_t", "nal_reader_get_epb_count", "(", "const", "NalReader", "*", "reader", ")", "{", "return", "reader", "->", "n_epb", ";", "}" ]
nal_reader_get_epb: @reader: a #NalReader instance
[ "nal_reader_get_epb", ":", "@reader", ":", "a", "#NalReader", "instance" ]
[]
[ { "param": "reader", "type": "NalReader" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "reader", "type": "NalReader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d089df05528d633161a4f601e7e3ac7e92d9761e
luokunecnu/libyami
codecparsers/mpegvideoparser.c
[ "Intel" ]
C
mpeg_video_parse
BOOL
BOOL mpeg_video_parse (MpegVideoPacket * packet, const uint8_t * data, size_t size, uint32_t offset) { int32_t off; ByteReader br; if (!initialized) { initialized = TRUE; } if (size <= offset) { DEBUG ("Can't parse from offset %d, buffer is to small", offset); return FALSE; } size -= offset; byte_reader_init (&br, &data[offset], size); off = scan_for_start_codes (&br, 0, size); if (off < 0) { DEBUG ("No start code prefix in this buffer"); return FALSE; } if (byte_reader_skip (&br, off + 3) == FALSE) goto failed; if (byte_reader_get_uint8 (&br, &packet->type) == FALSE) goto failed; packet->data = data; packet->offset = offset + off + 4; packet->size = -1; /* try to find end of packet */ size -= off + 4; off = scan_for_start_codes (&br, 0, size); if (off > 0) packet->size = off; return TRUE; failed: { WARNING ("Failed to parse"); return FALSE; } }
/** * mpeg_video_parse: * @data: The data to parse * @size: The size of @data * @offset: The offset from which to start parsing * * Parses the MPEG 1/2 video bitstream contained in @data , and returns the * detect packets as a list of #MpegVideoTypeOffsetSize. * * Returns: TRUE if a packet start code was found */
@data: The data to parse @size: The size of @data @offset: The offset from which to start parsing Parses the MPEG 1/2 video bitstream contained in @data , and returns the detect packets as a list of #MpegVideoTypeOffsetSize. TRUE if a packet start code was found
[ "@data", ":", "The", "data", "to", "parse", "@size", ":", "The", "size", "of", "@data", "@offset", ":", "The", "offset", "from", "which", "to", "start", "parsing", "Parses", "the", "MPEG", "1", "/", "2", "video", "bitstream", "contained", "in", "@data", "and", "returns", "the", "detect", "packets", "as", "a", "list", "of", "#MpegVideoTypeOffsetSize", ".", "TRUE", "if", "a", "packet", "start", "code", "was", "found" ]
BOOL mpeg_video_parse (MpegVideoPacket * packet, const uint8_t * data, size_t size, uint32_t offset) { int32_t off; ByteReader br; if (!initialized) { initialized = TRUE; } if (size <= offset) { DEBUG ("Can't parse from offset %d, buffer is to small", offset); return FALSE; } size -= offset; byte_reader_init (&br, &data[offset], size); off = scan_for_start_codes (&br, 0, size); if (off < 0) { DEBUG ("No start code prefix in this buffer"); return FALSE; } if (byte_reader_skip (&br, off + 3) == FALSE) goto failed; if (byte_reader_get_uint8 (&br, &packet->type) == FALSE) goto failed; packet->data = data; packet->offset = offset + off + 4; packet->size = -1; size -= off + 4; off = scan_for_start_codes (&br, 0, size); if (off > 0) packet->size = off; return TRUE; failed: { WARNING ("Failed to parse"); return FALSE; } }
[ "BOOL", "mpeg_video_parse", "(", "MpegVideoPacket", "*", "packet", ",", "const", "uint8_t", "*", "data", ",", "size_t", "size", ",", "uint32_t", "offset", ")", "{", "int32_t", "off", ";", "ByteReader", "br", ";", "if", "(", "!", "initialized", ")", "{", "initialized", "=", "TRUE", ";", "}", "if", "(", "size", "<=", "offset", ")", "{", "DEBUG", "(", "\"", "\"", ",", "offset", ")", ";", "return", "FALSE", ";", "}", "size", "-=", "offset", ";", "byte_reader_init", "(", "&", "br", ",", "&", "data", "[", "offset", "]", ",", "size", ")", ";", "off", "=", "scan_for_start_codes", "(", "&", "br", ",", "0", ",", "size", ")", ";", "if", "(", "off", "<", "0", ")", "{", "DEBUG", "(", "\"", "\"", ")", ";", "return", "FALSE", ";", "}", "if", "(", "byte_reader_skip", "(", "&", "br", ",", "off", "+", "3", ")", "==", "FALSE", ")", "goto", "failed", ";", "if", "(", "byte_reader_get_uint8", "(", "&", "br", ",", "&", "packet", "->", "type", ")", "==", "FALSE", ")", "goto", "failed", ";", "packet", "->", "data", "=", "data", ";", "packet", "->", "offset", "=", "offset", "+", "off", "+", "4", ";", "packet", "->", "size", "=", "-1", ";", "size", "-=", "off", "+", "4", ";", "off", "=", "scan_for_start_codes", "(", "&", "br", ",", "0", ",", "size", ")", ";", "if", "(", "off", ">", "0", ")", "packet", "->", "size", "=", "off", ";", "return", "TRUE", ";", "failed", ":", "{", "WARNING", "(", "\"", "\"", ")", ";", "return", "FALSE", ";", "}", "}" ]
mpeg_video_parse: @data: The data to parse @size: The size of @data @offset: The offset from which to start parsing
[ "mpeg_video_parse", ":", "@data", ":", "The", "data", "to", "parse", "@size", ":", "The", "size", "of", "@data", "@offset", ":", "The", "offset", "from", "which", "to", "start", "parsing" ]
[ "/* try to find end of packet */" ]
[ { "param": "packet", "type": "MpegVideoPacket" }, { "param": "data", "type": "uint8_t" }, { "param": "size", "type": "size_t" }, { "param": "offset", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "packet", "type": "MpegVideoPacket", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d089df05528d633161a4f601e7e3ac7e92d9761e
luokunecnu/libyami
codecparsers/mpegvideoparser.c
[ "Intel" ]
C
mpeg_video_parse_sequence_header
BOOL
BOOL mpeg_video_parse_sequence_header (MpegVideoSequenceHdr * seqhdr, const uint8_t * data, size_t size, uint32_t offset) { BitReader br; uint8_t bits; uint8_t load_intra_flag, load_non_intra_flag; RETURN_VAL_IF_FAIL (seqhdr != NULL, FALSE); size -= offset; if (size < 4) return FALSE; bit_reader_init (&br, &data[offset], size); /* Setting the height/width codes */ READ_UINT16 (&br, seqhdr->width, 12); READ_UINT16 (&br, seqhdr->height, 12); READ_UINT8 (&br, seqhdr->aspect_ratio_info, 4); /* Interpret PAR according to MPEG-1. Needs to be reinterpreted * later, if a sequence_display extension is seen */ set_par_from_asr_mpeg1 (seqhdr, seqhdr->aspect_ratio_info); READ_UINT8 (&br, seqhdr->frame_rate_code, 4); set_fps_from_code (seqhdr, seqhdr->frame_rate_code); READ_UINT32 (&br, seqhdr->bitrate_value, 18); if (seqhdr->bitrate_value == 0x3ffff) { /* VBR stream */ seqhdr->bitrate = 0; } else { /* Value in header is in units of 400 bps */ seqhdr->bitrate *= 400; } READ_UINT8 (&br, bits, 1); if (bits != MARKER_BIT) goto failed; /* VBV buffer size */ READ_UINT16 (&br, seqhdr->vbv_buffer_size_value, 10); /* constrained_parameters_flag */ READ_UINT8 (&br, seqhdr->constrained_parameters_flag, 1); /* load_intra_quantiser_matrix */ READ_UINT8 (&br, load_intra_flag, 1); if (load_intra_flag) { int32_t i; for (i = 0; i < 64; i++) READ_UINT8 (&br, seqhdr->intra_quantizer_matrix[i], 8); } else memcpy (seqhdr->intra_quantizer_matrix, default_intra_quantizer_matrix, 64); /* non intra quantizer matrix */ READ_UINT8 (&br, load_non_intra_flag, 1); if (load_non_intra_flag) { int32_t i; for (i = 0; i < 64; i++) READ_UINT8 (&br, seqhdr->non_intra_quantizer_matrix[i], 8); } else memset (seqhdr->non_intra_quantizer_matrix, 16, 64); /* dump some info */ INFO ("width x height: %d x %d", seqhdr->width, seqhdr->height); INFO ("fps: %d/%d", seqhdr->fps_n, seqhdr->fps_d); INFO ("par: %d/%d", seqhdr->par_w, seqhdr->par_h); INFO ("bitrate: %d", seqhdr->bitrate); return TRUE; /* ERRORS */ failed: { WARNING ("Failed to parse sequence header"); /* clear out stuff */ memset (seqhdr, 0, sizeof (*seqhdr)); return FALSE; } }
/** * mpeg_video_parse_sequence_header: * @seqhdr: (out): The #MpegVideoSequenceHdr structure to fill * @data: The data from which to parse the sequence header * @size: The size of @data * @offset: The offset in byte from which to start parsing @data * * Parses the @seqhdr Mpeg Video Sequence Header structure members from @data * * Returns: %TRUE if the seqhdr could be parsed correctly, %FALSE otherwize. */
Parses the @seqhdr Mpeg Video Sequence Header structure members from @data %TRUE if the seqhdr could be parsed correctly, %FALSE otherwize.
[ "Parses", "the", "@seqhdr", "Mpeg", "Video", "Sequence", "Header", "structure", "members", "from", "@data", "%TRUE", "if", "the", "seqhdr", "could", "be", "parsed", "correctly", "%FALSE", "otherwize", "." ]
BOOL mpeg_video_parse_sequence_header (MpegVideoSequenceHdr * seqhdr, const uint8_t * data, size_t size, uint32_t offset) { BitReader br; uint8_t bits; uint8_t load_intra_flag, load_non_intra_flag; RETURN_VAL_IF_FAIL (seqhdr != NULL, FALSE); size -= offset; if (size < 4) return FALSE; bit_reader_init (&br, &data[offset], size); READ_UINT16 (&br, seqhdr->width, 12); READ_UINT16 (&br, seqhdr->height, 12); READ_UINT8 (&br, seqhdr->aspect_ratio_info, 4); set_par_from_asr_mpeg1 (seqhdr, seqhdr->aspect_ratio_info); READ_UINT8 (&br, seqhdr->frame_rate_code, 4); set_fps_from_code (seqhdr, seqhdr->frame_rate_code); READ_UINT32 (&br, seqhdr->bitrate_value, 18); if (seqhdr->bitrate_value == 0x3ffff) { seqhdr->bitrate = 0; } else { seqhdr->bitrate *= 400; } READ_UINT8 (&br, bits, 1); if (bits != MARKER_BIT) goto failed; READ_UINT16 (&br, seqhdr->vbv_buffer_size_value, 10); READ_UINT8 (&br, seqhdr->constrained_parameters_flag, 1); READ_UINT8 (&br, load_intra_flag, 1); if (load_intra_flag) { int32_t i; for (i = 0; i < 64; i++) READ_UINT8 (&br, seqhdr->intra_quantizer_matrix[i], 8); } else memcpy (seqhdr->intra_quantizer_matrix, default_intra_quantizer_matrix, 64); READ_UINT8 (&br, load_non_intra_flag, 1); if (load_non_intra_flag) { int32_t i; for (i = 0; i < 64; i++) READ_UINT8 (&br, seqhdr->non_intra_quantizer_matrix[i], 8); } else memset (seqhdr->non_intra_quantizer_matrix, 16, 64); INFO ("width x height: %d x %d", seqhdr->width, seqhdr->height); INFO ("fps: %d/%d", seqhdr->fps_n, seqhdr->fps_d); INFO ("par: %d/%d", seqhdr->par_w, seqhdr->par_h); INFO ("bitrate: %d", seqhdr->bitrate); return TRUE; failed: { WARNING ("Failed to parse sequence header"); memset (seqhdr, 0, sizeof (*seqhdr)); return FALSE; } }
[ "BOOL", "mpeg_video_parse_sequence_header", "(", "MpegVideoSequenceHdr", "*", "seqhdr", ",", "const", "uint8_t", "*", "data", ",", "size_t", "size", ",", "uint32_t", "offset", ")", "{", "BitReader", "br", ";", "uint8_t", "bits", ";", "uint8_t", "load_intra_flag", ",", "load_non_intra_flag", ";", "RETURN_VAL_IF_FAIL", "(", "seqhdr", "!=", "NULL", ",", "FALSE", ")", ";", "size", "-=", "offset", ";", "if", "(", "size", "<", "4", ")", "return", "FALSE", ";", "bit_reader_init", "(", "&", "br", ",", "&", "data", "[", "offset", "]", ",", "size", ")", ";", "READ_UINT16", "(", "&", "br", ",", "seqhdr", "->", "width", ",", "12", ")", ";", "READ_UINT16", "(", "&", "br", ",", "seqhdr", "->", "height", ",", "12", ")", ";", "READ_UINT8", "(", "&", "br", ",", "seqhdr", "->", "aspect_ratio_info", ",", "4", ")", ";", "set_par_from_asr_mpeg1", "(", "seqhdr", ",", "seqhdr", "->", "aspect_ratio_info", ")", ";", "READ_UINT8", "(", "&", "br", ",", "seqhdr", "->", "frame_rate_code", ",", "4", ")", ";", "set_fps_from_code", "(", "seqhdr", ",", "seqhdr", "->", "frame_rate_code", ")", ";", "READ_UINT32", "(", "&", "br", ",", "seqhdr", "->", "bitrate_value", ",", "18", ")", ";", "if", "(", "seqhdr", "->", "bitrate_value", "==", "0x3ffff", ")", "{", "seqhdr", "->", "bitrate", "=", "0", ";", "}", "else", "{", "seqhdr", "->", "bitrate", "*=", "400", ";", "}", "READ_UINT8", "(", "&", "br", ",", "bits", ",", "1", ")", ";", "if", "(", "bits", "!=", "MARKER_BIT", ")", "goto", "failed", ";", "READ_UINT16", "(", "&", "br", ",", "seqhdr", "->", "vbv_buffer_size_value", ",", "10", ")", ";", "READ_UINT8", "(", "&", "br", ",", "seqhdr", "->", "constrained_parameters_flag", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "load_intra_flag", ",", "1", ")", ";", "if", "(", "load_intra_flag", ")", "{", "int32_t", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "64", ";", "i", "++", ")", "READ_UINT8", "(", "&", "br", ",", "seqhdr", "->", "intra_quantizer_matrix", "[", "i", "]", ",", "8", ")", ";", "}", "else", "memcpy", "(", "seqhdr", "->", "intra_quantizer_matrix", ",", "default_intra_quantizer_matrix", ",", "64", ")", ";", "READ_UINT8", "(", "&", "br", ",", "load_non_intra_flag", ",", "1", ")", ";", "if", "(", "load_non_intra_flag", ")", "{", "int32_t", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "64", ";", "i", "++", ")", "READ_UINT8", "(", "&", "br", ",", "seqhdr", "->", "non_intra_quantizer_matrix", "[", "i", "]", ",", "8", ")", ";", "}", "else", "memset", "(", "seqhdr", "->", "non_intra_quantizer_matrix", ",", "16", ",", "64", ")", ";", "INFO", "(", "\"", "\"", ",", "seqhdr", "->", "width", ",", "seqhdr", "->", "height", ")", ";", "INFO", "(", "\"", "\"", ",", "seqhdr", "->", "fps_n", ",", "seqhdr", "->", "fps_d", ")", ";", "INFO", "(", "\"", "\"", ",", "seqhdr", "->", "par_w", ",", "seqhdr", "->", "par_h", ")", ";", "INFO", "(", "\"", "\"", ",", "seqhdr", "->", "bitrate", ")", ";", "return", "TRUE", ";", "failed", ":", "{", "WARNING", "(", "\"", "\"", ")", ";", "memset", "(", "seqhdr", ",", "0", ",", "sizeof", "(", "*", "seqhdr", ")", ")", ";", "return", "FALSE", ";", "}", "}" ]
mpeg_video_parse_sequence_header: @seqhdr: (out): The #MpegVideoSequenceHdr structure to fill @data: The data from which to parse the sequence header @size: The size of @data @offset: The offset in byte from which to start parsing @data
[ "mpeg_video_parse_sequence_header", ":", "@seqhdr", ":", "(", "out", ")", ":", "The", "#MpegVideoSequenceHdr", "structure", "to", "fill", "@data", ":", "The", "data", "from", "which", "to", "parse", "the", "sequence", "header", "@size", ":", "The", "size", "of", "@data", "@offset", ":", "The", "offset", "in", "byte", "from", "which", "to", "start", "parsing", "@data" ]
[ "/* Setting the height/width codes */", "/* Interpret PAR according to MPEG-1. Needs to be reinterpreted\n * later, if a sequence_display extension is seen */", "/* VBR stream */", "/* Value in header is in units of 400 bps */", "/* VBV buffer size */", "/* constrained_parameters_flag */", "/* load_intra_quantiser_matrix */", "/* non intra quantizer matrix */", "/* dump some info */", "/* ERRORS */", "/* clear out stuff */" ]
[ { "param": "seqhdr", "type": "MpegVideoSequenceHdr" }, { "param": "data", "type": "uint8_t" }, { "param": "size", "type": "size_t" }, { "param": "offset", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "seqhdr", "type": "MpegVideoSequenceHdr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d089df05528d633161a4f601e7e3ac7e92d9761e
luokunecnu/libyami
codecparsers/mpegvideoparser.c
[ "Intel" ]
C
mpeg_video_parse_sequence_extension
BOOL
BOOL mpeg_video_parse_sequence_extension (MpegVideoSequenceExt * seqext, const uint8_t * data, size_t size, uint32_t offset) { BitReader br; RETURN_VAL_IF_FAIL (seqext != NULL, FALSE); size -= offset; if (size < 6) { DEBUG ("not enough bytes to parse the extension"); return FALSE; } bit_reader_init (&br, &data[offset], size); if (bit_reader_get_bits_uint8_unchecked (&br, 4) != MPEG_VIDEO_PACKET_EXT_SEQUENCE) { DEBUG ("Not parsing a sequence extension"); return FALSE; } /* skip profile and level escape bit */ bit_reader_skip_unchecked (&br, 1); seqext->profile = bit_reader_get_bits_uint8_unchecked (&br, 3); seqext->level = bit_reader_get_bits_uint8_unchecked (&br, 4); /* progressive */ seqext->progressive = bit_reader_get_bits_uint8_unchecked (&br, 1); /* chroma format */ seqext->chroma_format = bit_reader_get_bits_uint8_unchecked (&br, 2); /* resolution extension */ seqext->horiz_size_ext = bit_reader_get_bits_uint8_unchecked (&br, 2); seqext->vert_size_ext = bit_reader_get_bits_uint8_unchecked (&br, 2); seqext->bitrate_ext = bit_reader_get_bits_uint16_unchecked (&br, 12); /* skip marker bits */ bit_reader_skip_unchecked (&br, 1); seqext->vbv_buffer_size_extension = bit_reader_get_bits_uint8_unchecked (&br, 8); seqext->low_delay = bit_reader_get_bits_uint8_unchecked (&br, 1); /* framerate extension */ seqext->fps_n_ext = bit_reader_get_bits_uint8_unchecked (&br, 2); seqext->fps_d_ext = bit_reader_get_bits_uint8_unchecked (&br, 2); return TRUE; }
/** * mpeg_video_parse_sequence_extension: * @seqext: (out): The #MpegVideoSequenceExt structure to fill * @data: The data from which to parse the sequence extension * @size: The size of @data * @offset: The offset in byte from which to start parsing @data * * Parses the @seqext Mpeg Video Sequence Extension structure members from @data * * Returns: %TRUE if the seqext could be parsed correctly, %FALSE otherwize. */
Parses the @seqext Mpeg Video Sequence Extension structure members from @data %TRUE if the seqext could be parsed correctly, %FALSE otherwize.
[ "Parses", "the", "@seqext", "Mpeg", "Video", "Sequence", "Extension", "structure", "members", "from", "@data", "%TRUE", "if", "the", "seqext", "could", "be", "parsed", "correctly", "%FALSE", "otherwize", "." ]
BOOL mpeg_video_parse_sequence_extension (MpegVideoSequenceExt * seqext, const uint8_t * data, size_t size, uint32_t offset) { BitReader br; RETURN_VAL_IF_FAIL (seqext != NULL, FALSE); size -= offset; if (size < 6) { DEBUG ("not enough bytes to parse the extension"); return FALSE; } bit_reader_init (&br, &data[offset], size); if (bit_reader_get_bits_uint8_unchecked (&br, 4) != MPEG_VIDEO_PACKET_EXT_SEQUENCE) { DEBUG ("Not parsing a sequence extension"); return FALSE; } bit_reader_skip_unchecked (&br, 1); seqext->profile = bit_reader_get_bits_uint8_unchecked (&br, 3); seqext->level = bit_reader_get_bits_uint8_unchecked (&br, 4); seqext->progressive = bit_reader_get_bits_uint8_unchecked (&br, 1); seqext->chroma_format = bit_reader_get_bits_uint8_unchecked (&br, 2); seqext->horiz_size_ext = bit_reader_get_bits_uint8_unchecked (&br, 2); seqext->vert_size_ext = bit_reader_get_bits_uint8_unchecked (&br, 2); seqext->bitrate_ext = bit_reader_get_bits_uint16_unchecked (&br, 12); bit_reader_skip_unchecked (&br, 1); seqext->vbv_buffer_size_extension = bit_reader_get_bits_uint8_unchecked (&br, 8); seqext->low_delay = bit_reader_get_bits_uint8_unchecked (&br, 1); seqext->fps_n_ext = bit_reader_get_bits_uint8_unchecked (&br, 2); seqext->fps_d_ext = bit_reader_get_bits_uint8_unchecked (&br, 2); return TRUE; }
[ "BOOL", "mpeg_video_parse_sequence_extension", "(", "MpegVideoSequenceExt", "*", "seqext", ",", "const", "uint8_t", "*", "data", ",", "size_t", "size", ",", "uint32_t", "offset", ")", "{", "BitReader", "br", ";", "RETURN_VAL_IF_FAIL", "(", "seqext", "!=", "NULL", ",", "FALSE", ")", ";", "size", "-=", "offset", ";", "if", "(", "size", "<", "6", ")", "{", "DEBUG", "(", "\"", "\"", ")", ";", "return", "FALSE", ";", "}", "bit_reader_init", "(", "&", "br", ",", "&", "data", "[", "offset", "]", ",", "size", ")", ";", "if", "(", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "4", ")", "!=", "MPEG_VIDEO_PACKET_EXT_SEQUENCE", ")", "{", "DEBUG", "(", "\"", "\"", ")", ";", "return", "FALSE", ";", "}", "bit_reader_skip_unchecked", "(", "&", "br", ",", "1", ")", ";", "seqext", "->", "profile", "=", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "3", ")", ";", "seqext", "->", "level", "=", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "4", ")", ";", "seqext", "->", "progressive", "=", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "1", ")", ";", "seqext", "->", "chroma_format", "=", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "2", ")", ";", "seqext", "->", "horiz_size_ext", "=", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "2", ")", ";", "seqext", "->", "vert_size_ext", "=", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "2", ")", ";", "seqext", "->", "bitrate_ext", "=", "bit_reader_get_bits_uint16_unchecked", "(", "&", "br", ",", "12", ")", ";", "bit_reader_skip_unchecked", "(", "&", "br", ",", "1", ")", ";", "seqext", "->", "vbv_buffer_size_extension", "=", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "8", ")", ";", "seqext", "->", "low_delay", "=", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "1", ")", ";", "seqext", "->", "fps_n_ext", "=", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "2", ")", ";", "seqext", "->", "fps_d_ext", "=", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "2", ")", ";", "return", "TRUE", ";", "}" ]
mpeg_video_parse_sequence_extension: @seqext: (out): The #MpegVideoSequenceExt structure to fill @data: The data from which to parse the sequence extension @size: The size of @data @offset: The offset in byte from which to start parsing @data
[ "mpeg_video_parse_sequence_extension", ":", "@seqext", ":", "(", "out", ")", ":", "The", "#MpegVideoSequenceExt", "structure", "to", "fill", "@data", ":", "The", "data", "from", "which", "to", "parse", "the", "sequence", "extension", "@size", ":", "The", "size", "of", "@data", "@offset", ":", "The", "offset", "in", "byte", "from", "which", "to", "start", "parsing", "@data" ]
[ "/* skip profile and level escape bit */", "/* progressive */", "/* chroma format */", "/* resolution extension */", "/* skip marker bits */", "/* framerate extension */" ]
[ { "param": "seqext", "type": "MpegVideoSequenceExt" }, { "param": "data", "type": "uint8_t" }, { "param": "size", "type": "size_t" }, { "param": "offset", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "seqext", "type": "MpegVideoSequenceExt", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d089df05528d633161a4f601e7e3ac7e92d9761e
luokunecnu/libyami
codecparsers/mpegvideoparser.c
[ "Intel" ]
C
mpeg_video_parse_quant_matrix_extension
BOOL
BOOL mpeg_video_parse_quant_matrix_extension (MpegVideoQuantMatrixExt * quant, const uint8_t * data, size_t size, uint32_t offset) { uint8_t i; BitReader br; RETURN_VAL_IF_FAIL (quant != NULL, FALSE); size -= offset; if (size < 1) { DEBUG ("not enough bytes to parse the extension"); return FALSE; } bit_reader_init (&br, &data[offset], size); if (bit_reader_get_bits_uint8_unchecked (&br, 4) != MPEG_VIDEO_PACKET_EXT_QUANT_MATRIX) { DEBUG ("Not parsing a quant matrix extension"); return FALSE; } READ_UINT8 (&br, quant->load_intra_quantiser_matrix, 1); if (quant->load_intra_quantiser_matrix) { for (i = 0; i < 64; i++) { READ_UINT8 (&br, quant->intra_quantiser_matrix[i], 8); } } READ_UINT8 (&br, quant->load_non_intra_quantiser_matrix, 1); if (quant->load_non_intra_quantiser_matrix) { for (i = 0; i < 64; i++) { READ_UINT8 (&br, quant->non_intra_quantiser_matrix[i], 8); } } READ_UINT8 (&br, quant->load_chroma_intra_quantiser_matrix, 1); if (quant->load_chroma_intra_quantiser_matrix) { for (i = 0; i < 64; i++) { READ_UINT8 (&br, quant->chroma_intra_quantiser_matrix[i], 8); } } READ_UINT8 (&br, quant->load_chroma_non_intra_quantiser_matrix, 1); if (quant->load_chroma_non_intra_quantiser_matrix) { for (i = 0; i < 64; i++) { READ_UINT8 (&br, quant->chroma_non_intra_quantiser_matrix[i], 8); } } return TRUE; failed: WARNING ("error parsing \"Quant Matrix Extension\""); return FALSE; }
/** * mpeg_video_parse_quant_matrix_extension: * @quant: (out): The #MpegVideoQuantMatrixExt structure to fill * @data: The data from which to parse the Quantization Matrix extension * @size: The size of @data * @offset: The offset in byte from which to start the parsing * * Parses the @quant Mpeg Video Quant Matrix Extension structure members from * @data * * Returns: %TRUE if the quant matrix extension could be parsed correctly, * %FALSE otherwize. */
Parses the @quant Mpeg Video Quant Matrix Extension structure members from @data %TRUE if the quant matrix extension could be parsed correctly, %FALSE otherwize.
[ "Parses", "the", "@quant", "Mpeg", "Video", "Quant", "Matrix", "Extension", "structure", "members", "from", "@data", "%TRUE", "if", "the", "quant", "matrix", "extension", "could", "be", "parsed", "correctly", "%FALSE", "otherwize", "." ]
BOOL mpeg_video_parse_quant_matrix_extension (MpegVideoQuantMatrixExt * quant, const uint8_t * data, size_t size, uint32_t offset) { uint8_t i; BitReader br; RETURN_VAL_IF_FAIL (quant != NULL, FALSE); size -= offset; if (size < 1) { DEBUG ("not enough bytes to parse the extension"); return FALSE; } bit_reader_init (&br, &data[offset], size); if (bit_reader_get_bits_uint8_unchecked (&br, 4) != MPEG_VIDEO_PACKET_EXT_QUANT_MATRIX) { DEBUG ("Not parsing a quant matrix extension"); return FALSE; } READ_UINT8 (&br, quant->load_intra_quantiser_matrix, 1); if (quant->load_intra_quantiser_matrix) { for (i = 0; i < 64; i++) { READ_UINT8 (&br, quant->intra_quantiser_matrix[i], 8); } } READ_UINT8 (&br, quant->load_non_intra_quantiser_matrix, 1); if (quant->load_non_intra_quantiser_matrix) { for (i = 0; i < 64; i++) { READ_UINT8 (&br, quant->non_intra_quantiser_matrix[i], 8); } } READ_UINT8 (&br, quant->load_chroma_intra_quantiser_matrix, 1); if (quant->load_chroma_intra_quantiser_matrix) { for (i = 0; i < 64; i++) { READ_UINT8 (&br, quant->chroma_intra_quantiser_matrix[i], 8); } } READ_UINT8 (&br, quant->load_chroma_non_intra_quantiser_matrix, 1); if (quant->load_chroma_non_intra_quantiser_matrix) { for (i = 0; i < 64; i++) { READ_UINT8 (&br, quant->chroma_non_intra_quantiser_matrix[i], 8); } } return TRUE; failed: WARNING ("error parsing \"Quant Matrix Extension\""); return FALSE; }
[ "BOOL", "mpeg_video_parse_quant_matrix_extension", "(", "MpegVideoQuantMatrixExt", "*", "quant", ",", "const", "uint8_t", "*", "data", ",", "size_t", "size", ",", "uint32_t", "offset", ")", "{", "uint8_t", "i", ";", "BitReader", "br", ";", "RETURN_VAL_IF_FAIL", "(", "quant", "!=", "NULL", ",", "FALSE", ")", ";", "size", "-=", "offset", ";", "if", "(", "size", "<", "1", ")", "{", "DEBUG", "(", "\"", "\"", ")", ";", "return", "FALSE", ";", "}", "bit_reader_init", "(", "&", "br", ",", "&", "data", "[", "offset", "]", ",", "size", ")", ";", "if", "(", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "4", ")", "!=", "MPEG_VIDEO_PACKET_EXT_QUANT_MATRIX", ")", "{", "DEBUG", "(", "\"", "\"", ")", ";", "return", "FALSE", ";", "}", "READ_UINT8", "(", "&", "br", ",", "quant", "->", "load_intra_quantiser_matrix", ",", "1", ")", ";", "if", "(", "quant", "->", "load_intra_quantiser_matrix", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "64", ";", "i", "++", ")", "{", "READ_UINT8", "(", "&", "br", ",", "quant", "->", "intra_quantiser_matrix", "[", "i", "]", ",", "8", ")", ";", "}", "}", "READ_UINT8", "(", "&", "br", ",", "quant", "->", "load_non_intra_quantiser_matrix", ",", "1", ")", ";", "if", "(", "quant", "->", "load_non_intra_quantiser_matrix", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "64", ";", "i", "++", ")", "{", "READ_UINT8", "(", "&", "br", ",", "quant", "->", "non_intra_quantiser_matrix", "[", "i", "]", ",", "8", ")", ";", "}", "}", "READ_UINT8", "(", "&", "br", ",", "quant", "->", "load_chroma_intra_quantiser_matrix", ",", "1", ")", ";", "if", "(", "quant", "->", "load_chroma_intra_quantiser_matrix", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "64", ";", "i", "++", ")", "{", "READ_UINT8", "(", "&", "br", ",", "quant", "->", "chroma_intra_quantiser_matrix", "[", "i", "]", ",", "8", ")", ";", "}", "}", "READ_UINT8", "(", "&", "br", ",", "quant", "->", "load_chroma_non_intra_quantiser_matrix", ",", "1", ")", ";", "if", "(", "quant", "->", "load_chroma_non_intra_quantiser_matrix", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "64", ";", "i", "++", ")", "{", "READ_UINT8", "(", "&", "br", ",", "quant", "->", "chroma_non_intra_quantiser_matrix", "[", "i", "]", ",", "8", ")", ";", "}", "}", "return", "TRUE", ";", "failed", ":", "WARNING", "(", "\"", "\\\"", "\\\"", "\"", ")", ";", "return", "FALSE", ";", "}" ]
mpeg_video_parse_quant_matrix_extension: @quant: (out): The #MpegVideoQuantMatrixExt structure to fill @data: The data from which to parse the Quantization Matrix extension @size: The size of @data @offset: The offset in byte from which to start the parsing
[ "mpeg_video_parse_quant_matrix_extension", ":", "@quant", ":", "(", "out", ")", ":", "The", "#MpegVideoQuantMatrixExt", "structure", "to", "fill", "@data", ":", "The", "data", "from", "which", "to", "parse", "the", "Quantization", "Matrix", "extension", "@size", ":", "The", "size", "of", "@data", "@offset", ":", "The", "offset", "in", "byte", "from", "which", "to", "start", "the", "parsing" ]
[]
[ { "param": "quant", "type": "MpegVideoQuantMatrixExt" }, { "param": "data", "type": "uint8_t" }, { "param": "size", "type": "size_t" }, { "param": "offset", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "quant", "type": "MpegVideoQuantMatrixExt", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d089df05528d633161a4f601e7e3ac7e92d9761e
luokunecnu/libyami
codecparsers/mpegvideoparser.c
[ "Intel" ]
C
mpeg_video_parse_picture_extension
BOOL
BOOL mpeg_video_parse_picture_extension (MpegVideoPictureExt * ext, const uint8_t * data, size_t size, uint32_t offset) { BitReader br; RETURN_VAL_IF_FAIL (ext != NULL, FALSE); size -= offset; if (size < 4) return FALSE; bit_reader_init (&br, &data[offset], size); if (bit_reader_get_bits_uint8_unchecked (&br, 4) != MPEG_VIDEO_PACKET_EXT_PICTURE) { DEBUG ("Not parsing a picture extension"); return FALSE; } /* f_code */ READ_UINT8 (&br, ext->f_code[0][0], 4); READ_UINT8 (&br, ext->f_code[0][1], 4); READ_UINT8 (&br, ext->f_code[1][0], 4); READ_UINT8 (&br, ext->f_code[1][1], 4); /* intra DC precision */ READ_UINT8 (&br, ext->intra_dc_precision, 2); /* picture structure */ READ_UINT8 (&br, ext->picture_structure, 2); /* top field first */ READ_UINT8 (&br, ext->top_field_first, 1); /* frame pred frame dct */ READ_UINT8 (&br, ext->frame_pred_frame_dct, 1); /* concealment motion vectors */ READ_UINT8 (&br, ext->concealment_motion_vectors, 1); /* q scale type */ READ_UINT8 (&br, ext->q_scale_type, 1); /* intra vlc format */ READ_UINT8 (&br, ext->intra_vlc_format, 1); /* alternate scan */ READ_UINT8 (&br, ext->alternate_scan, 1); /* repeat first field */ READ_UINT8 (&br, ext->repeat_first_field, 1); /* chroma_420_type */ READ_UINT8 (&br, ext->chroma_420_type, 1); /* progressive_frame */ READ_UINT8 (&br, ext->progressive_frame, 1); /* composite display */ READ_UINT8 (&br, ext->composite_display, 1); if (ext->composite_display) { /* v axis */ READ_UINT8 (&br, ext->v_axis, 1); /* field sequence */ READ_UINT8 (&br, ext->field_sequence, 3); /* sub carrier */ READ_UINT8 (&br, ext->sub_carrier, 1); /* burst amplitude */ READ_UINT8 (&br, ext->burst_amplitude, 7); /* sub_carrier phase */ READ_UINT8 (&br, ext->sub_carrier_phase, 8); } return TRUE; failed: WARNING ("error parsing \"Picture Coding Extension\""); return FALSE; }
/** * mpeg_video_parse_picture_extension: * @ext: (out): The #MpegVideoPictureExt structure to fill * @data: The data from which to parse the picture extension * @size: The size of @data * @offset: The offset in byte from which to start the parsing * * Parse the @ext Mpeg Video Picture Extension structure members from @data * * Returns: %TRUE if the picture extension could be parsed correctly, * %FALSE otherwize. */
Parse the @ext Mpeg Video Picture Extension structure members from @data %TRUE if the picture extension could be parsed correctly, %FALSE otherwize.
[ "Parse", "the", "@ext", "Mpeg", "Video", "Picture", "Extension", "structure", "members", "from", "@data", "%TRUE", "if", "the", "picture", "extension", "could", "be", "parsed", "correctly", "%FALSE", "otherwize", "." ]
BOOL mpeg_video_parse_picture_extension (MpegVideoPictureExt * ext, const uint8_t * data, size_t size, uint32_t offset) { BitReader br; RETURN_VAL_IF_FAIL (ext != NULL, FALSE); size -= offset; if (size < 4) return FALSE; bit_reader_init (&br, &data[offset], size); if (bit_reader_get_bits_uint8_unchecked (&br, 4) != MPEG_VIDEO_PACKET_EXT_PICTURE) { DEBUG ("Not parsing a picture extension"); return FALSE; } READ_UINT8 (&br, ext->f_code[0][0], 4); READ_UINT8 (&br, ext->f_code[0][1], 4); READ_UINT8 (&br, ext->f_code[1][0], 4); READ_UINT8 (&br, ext->f_code[1][1], 4); READ_UINT8 (&br, ext->intra_dc_precision, 2); READ_UINT8 (&br, ext->picture_structure, 2); READ_UINT8 (&br, ext->top_field_first, 1); READ_UINT8 (&br, ext->frame_pred_frame_dct, 1); READ_UINT8 (&br, ext->concealment_motion_vectors, 1); READ_UINT8 (&br, ext->q_scale_type, 1); READ_UINT8 (&br, ext->intra_vlc_format, 1); READ_UINT8 (&br, ext->alternate_scan, 1); READ_UINT8 (&br, ext->repeat_first_field, 1); READ_UINT8 (&br, ext->chroma_420_type, 1); READ_UINT8 (&br, ext->progressive_frame, 1); READ_UINT8 (&br, ext->composite_display, 1); if (ext->composite_display) { READ_UINT8 (&br, ext->v_axis, 1); READ_UINT8 (&br, ext->field_sequence, 3); READ_UINT8 (&br, ext->sub_carrier, 1); READ_UINT8 (&br, ext->burst_amplitude, 7); READ_UINT8 (&br, ext->sub_carrier_phase, 8); } return TRUE; failed: WARNING ("error parsing \"Picture Coding Extension\""); return FALSE; }
[ "BOOL", "mpeg_video_parse_picture_extension", "(", "MpegVideoPictureExt", "*", "ext", ",", "const", "uint8_t", "*", "data", ",", "size_t", "size", ",", "uint32_t", "offset", ")", "{", "BitReader", "br", ";", "RETURN_VAL_IF_FAIL", "(", "ext", "!=", "NULL", ",", "FALSE", ")", ";", "size", "-=", "offset", ";", "if", "(", "size", "<", "4", ")", "return", "FALSE", ";", "bit_reader_init", "(", "&", "br", ",", "&", "data", "[", "offset", "]", ",", "size", ")", ";", "if", "(", "bit_reader_get_bits_uint8_unchecked", "(", "&", "br", ",", "4", ")", "!=", "MPEG_VIDEO_PACKET_EXT_PICTURE", ")", "{", "DEBUG", "(", "\"", "\"", ")", ";", "return", "FALSE", ";", "}", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "f_code", "[", "0", "]", "[", "0", "]", ",", "4", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "f_code", "[", "0", "]", "[", "1", "]", ",", "4", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "f_code", "[", "1", "]", "[", "0", "]", ",", "4", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "f_code", "[", "1", "]", "[", "1", "]", ",", "4", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "intra_dc_precision", ",", "2", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "picture_structure", ",", "2", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "top_field_first", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "frame_pred_frame_dct", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "concealment_motion_vectors", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "q_scale_type", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "intra_vlc_format", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "alternate_scan", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "repeat_first_field", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "chroma_420_type", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "progressive_frame", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "composite_display", ",", "1", ")", ";", "if", "(", "ext", "->", "composite_display", ")", "{", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "v_axis", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "field_sequence", ",", "3", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "sub_carrier", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "burst_amplitude", ",", "7", ")", ";", "READ_UINT8", "(", "&", "br", ",", "ext", "->", "sub_carrier_phase", ",", "8", ")", ";", "}", "return", "TRUE", ";", "failed", ":", "WARNING", "(", "\"", "\\\"", "\\\"", "\"", ")", ";", "return", "FALSE", ";", "}" ]
mpeg_video_parse_picture_extension: @ext: (out): The #MpegVideoPictureExt structure to fill @data: The data from which to parse the picture extension @size: The size of @data @offset: The offset in byte from which to start the parsing
[ "mpeg_video_parse_picture_extension", ":", "@ext", ":", "(", "out", ")", ":", "The", "#MpegVideoPictureExt", "structure", "to", "fill", "@data", ":", "The", "data", "from", "which", "to", "parse", "the", "picture", "extension", "@size", ":", "The", "size", "of", "@data", "@offset", ":", "The", "offset", "in", "byte", "from", "which", "to", "start", "the", "parsing" ]
[ "/* f_code */", "/* intra DC precision */", "/* picture structure */", "/* top field first */", "/* frame pred frame dct */", "/* concealment motion vectors */", "/* q scale type */", "/* intra vlc format */", "/* alternate scan */", "/* repeat first field */", "/* chroma_420_type */", "/* progressive_frame */", "/* composite display */", "/* v axis */", "/* field sequence */", "/* sub carrier */", "/* burst amplitude */", "/* sub_carrier phase */" ]
[ { "param": "ext", "type": "MpegVideoPictureExt" }, { "param": "data", "type": "uint8_t" }, { "param": "size", "type": "size_t" }, { "param": "offset", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ext", "type": "MpegVideoPictureExt", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d089df05528d633161a4f601e7e3ac7e92d9761e
luokunecnu/libyami
codecparsers/mpegvideoparser.c
[ "Intel" ]
C
mpeg_video_parse_picture_header
BOOL
BOOL mpeg_video_parse_picture_header (MpegVideoPictureHdr * hdr, const uint8_t * data, size_t size, uint32_t offset) { BitReader br; size = size - offset; if (size < 4) goto failed; bit_reader_init (&br, &data[offset], size); /* temperal sequence number */ if (!bit_reader_get_bits_uint16 (&br, &hdr->tsn, 10)) goto failed; /* frame type */ if (!bit_reader_get_bits_uint8 (&br, (uint8_t *) & hdr->pic_type, 3)) goto failed; if (hdr->pic_type == 0 || hdr->pic_type > 4) goto failed; /* Corrupted picture packet */ /* skip VBV delay */ if (!bit_reader_skip (&br, 16)) goto failed; if (hdr->pic_type == MPEG_VIDEO_PICTURE_TYPE_P || hdr->pic_type == MPEG_VIDEO_PICTURE_TYPE_B) { READ_UINT8 (&br, hdr->full_pel_forward_vector, 1); READ_UINT8 (&br, hdr->f_code[0][0], 3); hdr->f_code[0][1] = hdr->f_code[0][0]; } else { hdr->full_pel_forward_vector = 0; hdr->f_code[0][0] = hdr->f_code[0][1] = 0; } if (hdr->pic_type == MPEG_VIDEO_PICTURE_TYPE_B) { READ_UINT8 (&br, hdr->full_pel_backward_vector, 1); READ_UINT8 (&br, hdr->f_code[1][0], 3); hdr->f_code[1][1] = hdr->f_code[1][0]; } else { hdr->full_pel_backward_vector = 0; hdr->f_code[1][0] = hdr->f_code[1][1] = 0; } return TRUE; failed: { WARNING ("Failed to parse picture header"); return FALSE; } }
/** * mpeg_video_parse_picture_header: * @hdr: (out): The #MpegVideoPictureHdr structure to fill * @data: The data from which to parse the picture header * @size: The size of @data * @offset: The offset in byte from which to start the parsing * * Parsers the @hdr Mpeg Video Picture Header structure members from @data * * Returns: %TRUE if the picture sequence could be parsed correctly, %FALSE * otherwize. */
Parsers the @hdr Mpeg Video Picture Header structure members from @data %TRUE if the picture sequence could be parsed correctly, %FALSE otherwize.
[ "Parsers", "the", "@hdr", "Mpeg", "Video", "Picture", "Header", "structure", "members", "from", "@data", "%TRUE", "if", "the", "picture", "sequence", "could", "be", "parsed", "correctly", "%FALSE", "otherwize", "." ]
BOOL mpeg_video_parse_picture_header (MpegVideoPictureHdr * hdr, const uint8_t * data, size_t size, uint32_t offset) { BitReader br; size = size - offset; if (size < 4) goto failed; bit_reader_init (&br, &data[offset], size); if (!bit_reader_get_bits_uint16 (&br, &hdr->tsn, 10)) goto failed; if (!bit_reader_get_bits_uint8 (&br, (uint8_t *) & hdr->pic_type, 3)) goto failed; if (hdr->pic_type == 0 || hdr->pic_type > 4) goto failed; if (!bit_reader_skip (&br, 16)) goto failed; if (hdr->pic_type == MPEG_VIDEO_PICTURE_TYPE_P || hdr->pic_type == MPEG_VIDEO_PICTURE_TYPE_B) { READ_UINT8 (&br, hdr->full_pel_forward_vector, 1); READ_UINT8 (&br, hdr->f_code[0][0], 3); hdr->f_code[0][1] = hdr->f_code[0][0]; } else { hdr->full_pel_forward_vector = 0; hdr->f_code[0][0] = hdr->f_code[0][1] = 0; } if (hdr->pic_type == MPEG_VIDEO_PICTURE_TYPE_B) { READ_UINT8 (&br, hdr->full_pel_backward_vector, 1); READ_UINT8 (&br, hdr->f_code[1][0], 3); hdr->f_code[1][1] = hdr->f_code[1][0]; } else { hdr->full_pel_backward_vector = 0; hdr->f_code[1][0] = hdr->f_code[1][1] = 0; } return TRUE; failed: { WARNING ("Failed to parse picture header"); return FALSE; } }
[ "BOOL", "mpeg_video_parse_picture_header", "(", "MpegVideoPictureHdr", "*", "hdr", ",", "const", "uint8_t", "*", "data", ",", "size_t", "size", ",", "uint32_t", "offset", ")", "{", "BitReader", "br", ";", "size", "=", "size", "-", "offset", ";", "if", "(", "size", "<", "4", ")", "goto", "failed", ";", "bit_reader_init", "(", "&", "br", ",", "&", "data", "[", "offset", "]", ",", "size", ")", ";", "if", "(", "!", "bit_reader_get_bits_uint16", "(", "&", "br", ",", "&", "hdr", "->", "tsn", ",", "10", ")", ")", "goto", "failed", ";", "if", "(", "!", "bit_reader_get_bits_uint8", "(", "&", "br", ",", "(", "uint8_t", "*", ")", "&", "hdr", "->", "pic_type", ",", "3", ")", ")", "goto", "failed", ";", "if", "(", "hdr", "->", "pic_type", "==", "0", "||", "hdr", "->", "pic_type", ">", "4", ")", "goto", "failed", ";", "if", "(", "!", "bit_reader_skip", "(", "&", "br", ",", "16", ")", ")", "goto", "failed", ";", "if", "(", "hdr", "->", "pic_type", "==", "MPEG_VIDEO_PICTURE_TYPE_P", "||", "hdr", "->", "pic_type", "==", "MPEG_VIDEO_PICTURE_TYPE_B", ")", "{", "READ_UINT8", "(", "&", "br", ",", "hdr", "->", "full_pel_forward_vector", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "hdr", "->", "f_code", "[", "0", "]", "[", "0", "]", ",", "3", ")", ";", "hdr", "->", "f_code", "[", "0", "]", "[", "1", "]", "=", "hdr", "->", "f_code", "[", "0", "]", "[", "0", "]", ";", "}", "else", "{", "hdr", "->", "full_pel_forward_vector", "=", "0", ";", "hdr", "->", "f_code", "[", "0", "]", "[", "0", "]", "=", "hdr", "->", "f_code", "[", "0", "]", "[", "1", "]", "=", "0", ";", "}", "if", "(", "hdr", "->", "pic_type", "==", "MPEG_VIDEO_PICTURE_TYPE_B", ")", "{", "READ_UINT8", "(", "&", "br", ",", "hdr", "->", "full_pel_backward_vector", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "hdr", "->", "f_code", "[", "1", "]", "[", "0", "]", ",", "3", ")", ";", "hdr", "->", "f_code", "[", "1", "]", "[", "1", "]", "=", "hdr", "->", "f_code", "[", "1", "]", "[", "0", "]", ";", "}", "else", "{", "hdr", "->", "full_pel_backward_vector", "=", "0", ";", "hdr", "->", "f_code", "[", "1", "]", "[", "0", "]", "=", "hdr", "->", "f_code", "[", "1", "]", "[", "1", "]", "=", "0", ";", "}", "return", "TRUE", ";", "failed", ":", "{", "WARNING", "(", "\"", "\"", ")", ";", "return", "FALSE", ";", "}", "}" ]
mpeg_video_parse_picture_header: @hdr: (out): The #MpegVideoPictureHdr structure to fill @data: The data from which to parse the picture header @size: The size of @data @offset: The offset in byte from which to start the parsing
[ "mpeg_video_parse_picture_header", ":", "@hdr", ":", "(", "out", ")", ":", "The", "#MpegVideoPictureHdr", "structure", "to", "fill", "@data", ":", "The", "data", "from", "which", "to", "parse", "the", "picture", "header", "@size", ":", "The", "size", "of", "@data", "@offset", ":", "The", "offset", "in", "byte", "from", "which", "to", "start", "the", "parsing" ]
[ "/* temperal sequence number */", "/* frame type */", "/* Corrupted picture packet */", "/* skip VBV delay */" ]
[ { "param": "hdr", "type": "MpegVideoPictureHdr" }, { "param": "data", "type": "uint8_t" }, { "param": "size", "type": "size_t" }, { "param": "offset", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hdr", "type": "MpegVideoPictureHdr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d089df05528d633161a4f601e7e3ac7e92d9761e
luokunecnu/libyami
codecparsers/mpegvideoparser.c
[ "Intel" ]
C
mpeg_video_parse_gop
BOOL
BOOL mpeg_video_parse_gop (MpegVideoGop * gop, const uint8_t * data, size_t size, uint32_t offset) { BitReader br; RETURN_VAL_IF_FAIL (gop != NULL, FALSE); size -= offset; if (size < 4) return FALSE; bit_reader_init (&br, &data[offset], size); READ_UINT8 (&br, gop->drop_frame_flag, 1); READ_UINT8 (&br, gop->hour, 5); READ_UINT8 (&br, gop->minute, 6); /* skip unused bit */ if (!bit_reader_skip (&br, 1)) return FALSE; READ_UINT8 (&br, gop->second, 6); READ_UINT8 (&br, gop->frame, 6); READ_UINT8 (&br, gop->closed_gop, 1); READ_UINT8 (&br, gop->broken_link, 1); return TRUE; failed: WARNING ("error parsing \"GOP\""); return FALSE; }
/** * mpeg_video_parse_gop: * @gop: (out): The #MpegVideoGop structure to fill * @data: The data from which to parse the gop * @size: The size of @data * @offset: The offset in byte from which to start the parsing * * Parses the @gop Mpeg Video Group of Picture structure members from @data * * Returns: %TRUE if the gop could be parsed correctly, %FALSE otherwize. */
Parses the @gop Mpeg Video Group of Picture structure members from @data %TRUE if the gop could be parsed correctly, %FALSE otherwize.
[ "Parses", "the", "@gop", "Mpeg", "Video", "Group", "of", "Picture", "structure", "members", "from", "@data", "%TRUE", "if", "the", "gop", "could", "be", "parsed", "correctly", "%FALSE", "otherwize", "." ]
BOOL mpeg_video_parse_gop (MpegVideoGop * gop, const uint8_t * data, size_t size, uint32_t offset) { BitReader br; RETURN_VAL_IF_FAIL (gop != NULL, FALSE); size -= offset; if (size < 4) return FALSE; bit_reader_init (&br, &data[offset], size); READ_UINT8 (&br, gop->drop_frame_flag, 1); READ_UINT8 (&br, gop->hour, 5); READ_UINT8 (&br, gop->minute, 6); if (!bit_reader_skip (&br, 1)) return FALSE; READ_UINT8 (&br, gop->second, 6); READ_UINT8 (&br, gop->frame, 6); READ_UINT8 (&br, gop->closed_gop, 1); READ_UINT8 (&br, gop->broken_link, 1); return TRUE; failed: WARNING ("error parsing \"GOP\""); return FALSE; }
[ "BOOL", "mpeg_video_parse_gop", "(", "MpegVideoGop", "*", "gop", ",", "const", "uint8_t", "*", "data", ",", "size_t", "size", ",", "uint32_t", "offset", ")", "{", "BitReader", "br", ";", "RETURN_VAL_IF_FAIL", "(", "gop", "!=", "NULL", ",", "FALSE", ")", ";", "size", "-=", "offset", ";", "if", "(", "size", "<", "4", ")", "return", "FALSE", ";", "bit_reader_init", "(", "&", "br", ",", "&", "data", "[", "offset", "]", ",", "size", ")", ";", "READ_UINT8", "(", "&", "br", ",", "gop", "->", "drop_frame_flag", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "gop", "->", "hour", ",", "5", ")", ";", "READ_UINT8", "(", "&", "br", ",", "gop", "->", "minute", ",", "6", ")", ";", "if", "(", "!", "bit_reader_skip", "(", "&", "br", ",", "1", ")", ")", "return", "FALSE", ";", "READ_UINT8", "(", "&", "br", ",", "gop", "->", "second", ",", "6", ")", ";", "READ_UINT8", "(", "&", "br", ",", "gop", "->", "frame", ",", "6", ")", ";", "READ_UINT8", "(", "&", "br", ",", "gop", "->", "closed_gop", ",", "1", ")", ";", "READ_UINT8", "(", "&", "br", ",", "gop", "->", "broken_link", ",", "1", ")", ";", "return", "TRUE", ";", "failed", ":", "WARNING", "(", "\"", "\\\"", "\\\"", "\"", ")", ";", "return", "FALSE", ";", "}" ]
mpeg_video_parse_gop: @gop: (out): The #MpegVideoGop structure to fill @data: The data from which to parse the gop @size: The size of @data @offset: The offset in byte from which to start the parsing
[ "mpeg_video_parse_gop", ":", "@gop", ":", "(", "out", ")", ":", "The", "#MpegVideoGop", "structure", "to", "fill", "@data", ":", "The", "data", "from", "which", "to", "parse", "the", "gop", "@size", ":", "The", "size", "of", "@data", "@offset", ":", "The", "offset", "in", "byte", "from", "which", "to", "start", "the", "parsing" ]
[ "/* skip unused bit */" ]
[ { "param": "gop", "type": "MpegVideoGop" }, { "param": "data", "type": "uint8_t" }, { "param": "size", "type": "size_t" }, { "param": "offset", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "gop", "type": "MpegVideoGop", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d089df05528d633161a4f601e7e3ac7e92d9761e
luokunecnu/libyami
codecparsers/mpegvideoparser.c
[ "Intel" ]
C
mpeg_video_quant_matrix_get_raster_from_zigzag
void
void mpeg_video_quant_matrix_get_raster_from_zigzag (uint8_t out_quant[64], const uint8_t quant[64]) { uint32_t i; RETURN_IF_FAIL (out_quant != quant); for (i = 0; i < 64; i++) out_quant[mpeg_zigzag_8x8[i]] = quant[i]; }
/** * mpeg_video_quant_matrix_get_raster_from_zigzag: * @out_quant: (out): The resulting quantization matrix * @quant: The source quantization matrix * * Converts quantization matrix @quant from zigzag scan order to * raster scan order and store the resulting factors into @out_quant. * * Note: it is an error to pass the same table in both @quant and * @out_quant arguments. * * Since: 1.2 */
@out_quant: (out): The resulting quantization matrix @quant: The source quantization matrix Converts quantization matrix @quant from zigzag scan order to raster scan order and store the resulting factors into @out_quant. it is an error to pass the same table in both @quant and @out_quant arguments.
[ "@out_quant", ":", "(", "out", ")", ":", "The", "resulting", "quantization", "matrix", "@quant", ":", "The", "source", "quantization", "matrix", "Converts", "quantization", "matrix", "@quant", "from", "zigzag", "scan", "order", "to", "raster", "scan", "order", "and", "store", "the", "resulting", "factors", "into", "@out_quant", ".", "it", "is", "an", "error", "to", "pass", "the", "same", "table", "in", "both", "@quant", "and", "@out_quant", "arguments", "." ]
void mpeg_video_quant_matrix_get_raster_from_zigzag (uint8_t out_quant[64], const uint8_t quant[64]) { uint32_t i; RETURN_IF_FAIL (out_quant != quant); for (i = 0; i < 64; i++) out_quant[mpeg_zigzag_8x8[i]] = quant[i]; }
[ "void", "mpeg_video_quant_matrix_get_raster_from_zigzag", "(", "uint8_t", "out_quant", "[", "64", "]", ",", "const", "uint8_t", "quant", "[", "64", "]", ")", "{", "uint32_t", "i", ";", "RETURN_IF_FAIL", "(", "out_quant", "!=", "quant", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "64", ";", "i", "++", ")", "out_quant", "[", "mpeg_zigzag_8x8", "[", "i", "]", "]", "=", "quant", "[", "i", "]", ";", "}" ]
mpeg_video_quant_matrix_get_raster_from_zigzag: @out_quant: (out): The resulting quantization matrix @quant: The source quantization matrix
[ "mpeg_video_quant_matrix_get_raster_from_zigzag", ":", "@out_quant", ":", "(", "out", ")", ":", "The", "resulting", "quantization", "matrix", "@quant", ":", "The", "source", "quantization", "matrix" ]
[]
[ { "param": "out_quant", "type": "uint8_t" }, { "param": "quant", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out_quant", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "quant", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d089df05528d633161a4f601e7e3ac7e92d9761e
luokunecnu/libyami
codecparsers/mpegvideoparser.c
[ "Intel" ]
C
mpeg_video_quant_matrix_get_zigzag_from_raster
void
void mpeg_video_quant_matrix_get_zigzag_from_raster (uint8_t out_quant[64], const uint8_t quant[64]) { uint32_t i; RETURN_IF_FAIL (out_quant != quant); for (i = 0; i < 64; i++) out_quant[i] = quant[mpeg_zigzag_8x8[i]]; }
/** * mpeg_video_quant_matrix_get_zigzag_from_raster: * @out_quant: (out): The resulting quantization matrix * @quant: The source quantization matrix * * Converts quantization matrix @quant from raster scan order to * zigzag scan order and store the resulting factors into @out_quant. * * Note: it is an error to pass the same table in both @quant and * @out_quant arguments. * * Since: 1.2 */
@out_quant: (out): The resulting quantization matrix @quant: The source quantization matrix Converts quantization matrix @quant from raster scan order to zigzag scan order and store the resulting factors into @out_quant. it is an error to pass the same table in both @quant and @out_quant arguments.
[ "@out_quant", ":", "(", "out", ")", ":", "The", "resulting", "quantization", "matrix", "@quant", ":", "The", "source", "quantization", "matrix", "Converts", "quantization", "matrix", "@quant", "from", "raster", "scan", "order", "to", "zigzag", "scan", "order", "and", "store", "the", "resulting", "factors", "into", "@out_quant", ".", "it", "is", "an", "error", "to", "pass", "the", "same", "table", "in", "both", "@quant", "and", "@out_quant", "arguments", "." ]
void mpeg_video_quant_matrix_get_zigzag_from_raster (uint8_t out_quant[64], const uint8_t quant[64]) { uint32_t i; RETURN_IF_FAIL (out_quant != quant); for (i = 0; i < 64; i++) out_quant[i] = quant[mpeg_zigzag_8x8[i]]; }
[ "void", "mpeg_video_quant_matrix_get_zigzag_from_raster", "(", "uint8_t", "out_quant", "[", "64", "]", ",", "const", "uint8_t", "quant", "[", "64", "]", ")", "{", "uint32_t", "i", ";", "RETURN_IF_FAIL", "(", "out_quant", "!=", "quant", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "64", ";", "i", "++", ")", "out_quant", "[", "i", "]", "=", "quant", "[", "mpeg_zigzag_8x8", "[", "i", "]", "]", ";", "}" ]
mpeg_video_quant_matrix_get_zigzag_from_raster: @out_quant: (out): The resulting quantization matrix @quant: The source quantization matrix
[ "mpeg_video_quant_matrix_get_zigzag_from_raster", ":", "@out_quant", ":", "(", "out", ")", ":", "The", "resulting", "quantization", "matrix", "@quant", ":", "The", "source", "quantization", "matrix" ]
[]
[ { "param": "out_quant", "type": "uint8_t" }, { "param": "quant", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out_quant", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "quant", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
15156cdc2a8cbc8a0b914d8a7844040d281994fc
code-mds/sistemi-operativi
bthreadlib/tsemaphore.c
[ "MIT" ]
C
bthread_sem_init
int
int bthread_sem_init(bthread_sem_t *s, int pshared, int value) { assert(s != NULL); assert(value >= 0); s->value = value; s->waiting_list = NULL; return 0; }
/** * Initialize a Semaphore object * A semaphore is an integer whose value is never allowed to fall below zero * @param s the semaphore to initialize * @param pshared (ignored in bthread) * @param value value to assign to the semaphore s */
Initialize a Semaphore object A semaphore is an integer whose value is never allowed to fall below zero @param s the semaphore to initialize @param pshared (ignored in bthread) @param value value to assign to the semaphore s
[ "Initialize", "a", "Semaphore", "object", "A", "semaphore", "is", "an", "integer", "whose", "value", "is", "never", "allowed", "to", "fall", "below", "zero", "@param", "s", "the", "semaphore", "to", "initialize", "@param", "pshared", "(", "ignored", "in", "bthread", ")", "@param", "value", "value", "to", "assign", "to", "the", "semaphore", "s" ]
int bthread_sem_init(bthread_sem_t *s, int pshared, int value) { assert(s != NULL); assert(value >= 0); s->value = value; s->waiting_list = NULL; return 0; }
[ "int", "bthread_sem_init", "(", "bthread_sem_t", "*", "s", ",", "int", "pshared", ",", "int", "value", ")", "{", "assert", "(", "s", "!=", "NULL", ")", ";", "assert", "(", "value", ">=", "0", ")", ";", "s", "->", "value", "=", "value", ";", "s", "->", "waiting_list", "=", "NULL", ";", "return", "0", ";", "}" ]
Initialize a Semaphore object A semaphore is an integer whose value is never allowed to fall below zero @param s the semaphore to initialize @param pshared (ignored in bthread) @param value value to assign to the semaphore s
[ "Initialize", "a", "Semaphore", "object", "A", "semaphore", "is", "an", "integer", "whose", "value", "is", "never", "allowed", "to", "fall", "below", "zero", "@param", "s", "the", "semaphore", "to", "initialize", "@param", "pshared", "(", "ignored", "in", "bthread", ")", "@param", "value", "value", "to", "assign", "to", "the", "semaphore", "s" ]
[]
[ { "param": "s", "type": "bthread_sem_t" }, { "param": "pshared", "type": "int" }, { "param": "value", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": "bthread_sem_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pshared", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
15156cdc2a8cbc8a0b914d8a7844040d281994fc
code-mds/sistemi-operativi
bthreadlib/tsemaphore.c
[ "MIT" ]
C
bthread_sem_wait
int
int bthread_sem_wait(bthread_sem_t *s) { bthread_block_timer_signal(); if(s->value == 0) { __bthread_scheduler_private* scheduler = bthread_get_scheduler(); volatile __bthread_private* bthread = (__bthread_private*)tqueue_get_data(scheduler->current_item); bthread->state = __BTHREAD_BLOCKED; tqueue_enqueue(&s->waiting_list, (void*)bthread); bthread_yield(); } else { s->value--; } bthread_unblock_timer_signal(); return 0; }
/* * Decrement the semaphore value by one (Lock or wait) * If the value of a semaphore is currently zero, * then a sem_wait operation will block until the value becomes greater than zero. */
Decrement the semaphore value by one (Lock or wait) If the value of a semaphore is currently zero, then a sem_wait operation will block until the value becomes greater than zero.
[ "Decrement", "the", "semaphore", "value", "by", "one", "(", "Lock", "or", "wait", ")", "If", "the", "value", "of", "a", "semaphore", "is", "currently", "zero", "then", "a", "sem_wait", "operation", "will", "block", "until", "the", "value", "becomes", "greater", "than", "zero", "." ]
int bthread_sem_wait(bthread_sem_t *s) { bthread_block_timer_signal(); if(s->value == 0) { __bthread_scheduler_private* scheduler = bthread_get_scheduler(); volatile __bthread_private* bthread = (__bthread_private*)tqueue_get_data(scheduler->current_item); bthread->state = __BTHREAD_BLOCKED; tqueue_enqueue(&s->waiting_list, (void*)bthread); bthread_yield(); } else { s->value--; } bthread_unblock_timer_signal(); return 0; }
[ "int", "bthread_sem_wait", "(", "bthread_sem_t", "*", "s", ")", "{", "bthread_block_timer_signal", "(", ")", ";", "if", "(", "s", "->", "value", "==", "0", ")", "{", "__bthread_scheduler_private", "*", "scheduler", "=", "bthread_get_scheduler", "(", ")", ";", "volatile", "__bthread_private", "*", "bthread", "=", "(", "__bthread_private", "*", ")", "tqueue_get_data", "(", "scheduler", "->", "current_item", ")", ";", "bthread", "->", "state", "=", "__BTHREAD_BLOCKED", ";", "tqueue_enqueue", "(", "&", "s", "->", "waiting_list", ",", "(", "void", "*", ")", "bthread", ")", ";", "bthread_yield", "(", ")", ";", "}", "else", "{", "s", "->", "value", "--", ";", "}", "bthread_unblock_timer_signal", "(", ")", ";", "return", "0", ";", "}" ]
Decrement the semaphore value by one (Lock or wait) If the value of a semaphore is currently zero, then a sem_wait operation will block until the value becomes greater than zero.
[ "Decrement", "the", "semaphore", "value", "by", "one", "(", "Lock", "or", "wait", ")", "If", "the", "value", "of", "a", "semaphore", "is", "currently", "zero", "then", "a", "sem_wait", "operation", "will", "block", "until", "the", "value", "becomes", "greater", "than", "zero", "." ]
[]
[ { "param": "s", "type": "bthread_sem_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": "bthread_sem_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
15156cdc2a8cbc8a0b914d8a7844040d281994fc
code-mds/sistemi-operativi
bthreadlib/tsemaphore.c
[ "MIT" ]
C
bthread_sem_post
int
int bthread_sem_post(bthread_sem_t *s) { bthread_block_timer_signal(); __bthread_private* unlock = tqueue_pop(&s->waiting_list); if (unlock != NULL) { unlock->state = __BTHREAD_READY; bthread_yield(); return 0; } else { s->value++; } bthread_unblock_timer_signal(); return 0; }
/* * Increment the semaphore value by one (Release or signal a semaphore) */
Increment the semaphore value by one (Release or signal a semaphore)
[ "Increment", "the", "semaphore", "value", "by", "one", "(", "Release", "or", "signal", "a", "semaphore", ")" ]
int bthread_sem_post(bthread_sem_t *s) { bthread_block_timer_signal(); __bthread_private* unlock = tqueue_pop(&s->waiting_list); if (unlock != NULL) { unlock->state = __BTHREAD_READY; bthread_yield(); return 0; } else { s->value++; } bthread_unblock_timer_signal(); return 0; }
[ "int", "bthread_sem_post", "(", "bthread_sem_t", "*", "s", ")", "{", "bthread_block_timer_signal", "(", ")", ";", "__bthread_private", "*", "unlock", "=", "tqueue_pop", "(", "&", "s", "->", "waiting_list", ")", ";", "if", "(", "unlock", "!=", "NULL", ")", "{", "unlock", "->", "state", "=", "__BTHREAD_READY", ";", "bthread_yield", "(", ")", ";", "return", "0", ";", "}", "else", "{", "s", "->", "value", "++", ";", "}", "bthread_unblock_timer_signal", "(", ")", ";", "return", "0", ";", "}" ]
Increment the semaphore value by one (Release or signal a semaphore)
[ "Increment", "the", "semaphore", "value", "by", "one", "(", "Release", "or", "signal", "a", "semaphore", ")" ]
[]
[ { "param": "s", "type": "bthread_sem_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": "bthread_sem_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d19a7860e6858ab5ba4e43ef6e99f8f513495044
code-mds/sistemi-operativi
bthreadlib/tqueue.c
[ "MIT" ]
C
tqueue_enqueue
null
unsigned long int tqueue_enqueue(TQueue* q, void* data) { unsigned long int pos = 0; if(q == NULL) return pos; TQueueNode* head = (*q); if(head == NULL) { (*q) = create_node(data); } else { TQueueNode *current= head; while(current->next != head) { pos++; current = current->next; } current->next = create_node(data); current->next->next = head; pos++; } return pos; }
/* Adds a new element at the end of the list, returns its position */
Adds a new element at the end of the list, returns its position
[ "Adds", "a", "new", "element", "at", "the", "end", "of", "the", "list", "returns", "its", "position" ]
unsigned long int tqueue_enqueue(TQueue* q, void* data) { unsigned long int pos = 0; if(q == NULL) return pos; TQueueNode* head = (*q); if(head == NULL) { (*q) = create_node(data); } else { TQueueNode *current= head; while(current->next != head) { pos++; current = current->next; } current->next = create_node(data); current->next->next = head; pos++; } return pos; }
[ "unsigned", "long", "int", "tqueue_enqueue", "(", "TQueue", "*", "q", ",", "void", "*", "data", ")", "{", "unsigned", "long", "int", "pos", "=", "0", ";", "if", "(", "q", "==", "NULL", ")", "return", "pos", ";", "TQueueNode", "*", "head", "=", "(", "*", "q", ")", ";", "if", "(", "head", "==", "NULL", ")", "{", "(", "*", "q", ")", "=", "create_node", "(", "data", ")", ";", "}", "else", "{", "TQueueNode", "*", "current", "=", "head", ";", "while", "(", "current", "->", "next", "!=", "head", ")", "{", "pos", "++", ";", "current", "=", "current", "->", "next", ";", "}", "current", "->", "next", "=", "create_node", "(", "data", ")", ";", "current", "->", "next", "->", "next", "=", "head", ";", "pos", "++", ";", "}", "return", "pos", ";", "}" ]
Adds a new element at the end of the list, returns its position
[ "Adds", "a", "new", "element", "at", "the", "end", "of", "the", "list", "returns", "its", "position" ]
[]
[ { "param": "q", "type": "TQueue" }, { "param": "data", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "TQueue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d19a7860e6858ab5ba4e43ef6e99f8f513495044
code-mds/sistemi-operativi
bthreadlib/tqueue.c
[ "MIT" ]
C
tqueue_pop
void
void* tqueue_pop(TQueue* q) { if(q == NULL) return NULL; TQueueNode* head = (*q); void* data = NULL; if(head != NULL) { data = head->data; if(head == head->next) { // single node in queue *q = NULL; } else { TQueueNode *current = head; // search previous node while(current->next != head) { current = current->next; } // bypass head current->next = head->next; *q = current->next; } free(head); } return data; }
/* Removes and returns the element at the beginning of the list, NULL if the queue is empty */
Removes and returns the element at the beginning of the list, NULL if the queue is empty
[ "Removes", "and", "returns", "the", "element", "at", "the", "beginning", "of", "the", "list", "NULL", "if", "the", "queue", "is", "empty" ]
void* tqueue_pop(TQueue* q) { if(q == NULL) return NULL; TQueueNode* head = (*q); void* data = NULL; if(head != NULL) { data = head->data; if(head == head->next) { *q = NULL; } else { TQueueNode *current = head; while(current->next != head) { current = current->next; } current->next = head->next; *q = current->next; } free(head); } return data; }
[ "void", "*", "tqueue_pop", "(", "TQueue", "*", "q", ")", "{", "if", "(", "q", "==", "NULL", ")", "return", "NULL", ";", "TQueueNode", "*", "head", "=", "(", "*", "q", ")", ";", "void", "*", "data", "=", "NULL", ";", "if", "(", "head", "!=", "NULL", ")", "{", "data", "=", "head", "->", "data", ";", "if", "(", "head", "==", "head", "->", "next", ")", "{", "*", "q", "=", "NULL", ";", "}", "else", "{", "TQueueNode", "*", "current", "=", "head", ";", "while", "(", "current", "->", "next", "!=", "head", ")", "{", "current", "=", "current", "->", "next", ";", "}", "current", "->", "next", "=", "head", "->", "next", ";", "*", "q", "=", "current", "->", "next", ";", "}", "free", "(", "head", ")", ";", "}", "return", "data", ";", "}" ]
Removes and returns the element at the beginning of the list, NULL if the queue is empty
[ "Removes", "and", "returns", "the", "element", "at", "the", "beginning", "of", "the", "list", "NULL", "if", "the", "queue", "is", "empty" ]
[ "// single node in queue", "// search previous node", "// bypass head" ]
[ { "param": "q", "type": "TQueue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "TQueue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d19a7860e6858ab5ba4e43ef6e99f8f513495044
code-mds/sistemi-operativi
bthreadlib/tqueue.c
[ "MIT" ]
C
tqueue_size
null
unsigned long int tqueue_size(TQueue q) { unsigned long int sz = 0; if(q != NULL) { sz++; TQueueNode *head = q; TQueueNode *current = head; while (current->next != head) { sz++; current = current->next; } } return sz; }
/* Returns the number of elements in the list */
Returns the number of elements in the list
[ "Returns", "the", "number", "of", "elements", "in", "the", "list" ]
unsigned long int tqueue_size(TQueue q) { unsigned long int sz = 0; if(q != NULL) { sz++; TQueueNode *head = q; TQueueNode *current = head; while (current->next != head) { sz++; current = current->next; } } return sz; }
[ "unsigned", "long", "int", "tqueue_size", "(", "TQueue", "q", ")", "{", "unsigned", "long", "int", "sz", "=", "0", ";", "if", "(", "q", "!=", "NULL", ")", "{", "sz", "++", ";", "TQueueNode", "*", "head", "=", "q", ";", "TQueueNode", "*", "current", "=", "head", ";", "while", "(", "current", "->", "next", "!=", "head", ")", "{", "sz", "++", ";", "current", "=", "current", "->", "next", ";", "}", "}", "return", "sz", ";", "}" ]
Returns the number of elements in the list
[ "Returns", "the", "number", "of", "elements", "in", "the", "list" ]
[]
[ { "param": "q", "type": "TQueue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "TQueue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d19a7860e6858ab5ba4e43ef6e99f8f513495044
code-mds/sistemi-operativi
bthreadlib/tqueue.c
[ "MIT" ]
C
tqueue_at_offset
TQueue
TQueue tqueue_at_offset(TQueue q, unsigned long int offset) { if(q == NULL) return NULL; for (int i = 0; i < offset; ++i) { q = q->next; } return q; }
/* Returns a 'view' on the list starting at (a positive) offset distance, * NULL if the queue is empty */
Returns a 'view' on the list starting at (a positive) offset distance, * NULL if the queue is empty
[ "Returns", "a", "'", "view", "'", "on", "the", "list", "starting", "at", "(", "a", "positive", ")", "offset", "distance", "*", "NULL", "if", "the", "queue", "is", "empty" ]
TQueue tqueue_at_offset(TQueue q, unsigned long int offset) { if(q == NULL) return NULL; for (int i = 0; i < offset; ++i) { q = q->next; } return q; }
[ "TQueue", "tqueue_at_offset", "(", "TQueue", "q", ",", "unsigned", "long", "int", "offset", ")", "{", "if", "(", "q", "==", "NULL", ")", "return", "NULL", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "offset", ";", "++", "i", ")", "{", "q", "=", "q", "->", "next", ";", "}", "return", "q", ";", "}" ]
Returns a 'view' on the list starting at (a positive) offset distance, * NULL if the queue is empty
[ "Returns", "a", "'", "view", "'", "on", "the", "list", "starting", "at", "(", "a", "positive", ")", "offset", "distance", "*", "NULL", "if", "the", "queue", "is", "empty" ]
[]
[ { "param": "q", "type": "TQueue" }, { "param": "offset", "type": "unsigned long int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "TQueue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "unsigned long int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dc2039ac500361afbf1da11b01c32c1f6d9b0702
code-mds/sistemi-operativi
bthreadlib/tmutex.c
[ "MIT" ]
C
bthread_mutex_init
int
int bthread_mutex_init(bthread_mutex_t* m, const bthread_mutexattr_t *attr) { assert(m != NULL); m->owner = NULL; m->waiting_list = NULL; return 0; }
/** * Initialize a Mutex object * @param m the mutex to initialize * @param attr (ignored) */
Initialize a Mutex object @param m the mutex to initialize @param attr (ignored)
[ "Initialize", "a", "Mutex", "object", "@param", "m", "the", "mutex", "to", "initialize", "@param", "attr", "(", "ignored", ")" ]
int bthread_mutex_init(bthread_mutex_t* m, const bthread_mutexattr_t *attr) { assert(m != NULL); m->owner = NULL; m->waiting_list = NULL; return 0; }
[ "int", "bthread_mutex_init", "(", "bthread_mutex_t", "*", "m", ",", "const", "bthread_mutexattr_t", "*", "attr", ")", "{", "assert", "(", "m", "!=", "NULL", ")", ";", "m", "->", "owner", "=", "NULL", ";", "m", "->", "waiting_list", "=", "NULL", ";", "return", "0", ";", "}" ]
Initialize a Mutex object @param m the mutex to initialize @param attr (ignored)
[ "Initialize", "a", "Mutex", "object", "@param", "m", "the", "mutex", "to", "initialize", "@param", "attr", "(", "ignored", ")" ]
[]
[ { "param": "m", "type": "bthread_mutex_t" }, { "param": "attr", "type": "bthread_mutexattr_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "m", "type": "bthread_mutex_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "attr", "type": "bthread_mutexattr_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dc2039ac500361afbf1da11b01c32c1f6d9b0702
code-mds/sistemi-operativi
bthreadlib/tmutex.c
[ "MIT" ]
C
bthread_mutex_lock
int
int bthread_mutex_lock(bthread_mutex_t* m) { // To avoid race-conditions we must execute mutex procedures atomically with the timer signal disabled. bthread_block_timer_signal(); __bthread_scheduler_private* scheduler = bthread_get_scheduler(); volatile __bthread_private* bthread = (__bthread_private*)tqueue_get_data(scheduler->current_item); if (m->owner == NULL) { m->owner = (void*)bthread; bthread_unblock_timer_signal(); } else { bthread->state = __BTHREAD_BLOCKED; // We re-use our queue to store the list of threads that are currently waiting for the mutex. // When the mutex is released we pick the first thread from the queue and resume its execution. tqueue_enqueue(&m->waiting_list, (void*)bthread); while(bthread->state != __BTHREAD_READY) { bthread_yield(); } } return 0; }
/* * When a thread tries to lock the mutex we check if it's available. * If not, we put the thread in the __BTHREAD_BLOCKED state. */
When a thread tries to lock the mutex we check if it's available. If not, we put the thread in the __BTHREAD_BLOCKED state.
[ "When", "a", "thread", "tries", "to", "lock", "the", "mutex", "we", "check", "if", "it", "'", "s", "available", ".", "If", "not", "we", "put", "the", "thread", "in", "the", "__BTHREAD_BLOCKED", "state", "." ]
int bthread_mutex_lock(bthread_mutex_t* m) { bthread_block_timer_signal(); __bthread_scheduler_private* scheduler = bthread_get_scheduler(); volatile __bthread_private* bthread = (__bthread_private*)tqueue_get_data(scheduler->current_item); if (m->owner == NULL) { m->owner = (void*)bthread; bthread_unblock_timer_signal(); } else { bthread->state = __BTHREAD_BLOCKED; tqueue_enqueue(&m->waiting_list, (void*)bthread); while(bthread->state != __BTHREAD_READY) { bthread_yield(); } } return 0; }
[ "int", "bthread_mutex_lock", "(", "bthread_mutex_t", "*", "m", ")", "{", "bthread_block_timer_signal", "(", ")", ";", "__bthread_scheduler_private", "*", "scheduler", "=", "bthread_get_scheduler", "(", ")", ";", "volatile", "__bthread_private", "*", "bthread", "=", "(", "__bthread_private", "*", ")", "tqueue_get_data", "(", "scheduler", "->", "current_item", ")", ";", "if", "(", "m", "->", "owner", "==", "NULL", ")", "{", "m", "->", "owner", "=", "(", "void", "*", ")", "bthread", ";", "bthread_unblock_timer_signal", "(", ")", ";", "}", "else", "{", "bthread", "->", "state", "=", "__BTHREAD_BLOCKED", ";", "tqueue_enqueue", "(", "&", "m", "->", "waiting_list", ",", "(", "void", "*", ")", "bthread", ")", ";", "while", "(", "bthread", "->", "state", "!=", "__BTHREAD_READY", ")", "{", "bthread_yield", "(", ")", ";", "}", "}", "return", "0", ";", "}" ]
When a thread tries to lock the mutex we check if it's available.
[ "When", "a", "thread", "tries", "to", "lock", "the", "mutex", "we", "check", "if", "it", "'", "s", "available", "." ]
[ "// To avoid race-conditions we must execute mutex procedures atomically with the timer signal disabled.", "// We re-use our queue to store the list of threads that are currently waiting for the mutex.", "// When the mutex is released we pick the first thread from the queue and resume its execution." ]
[ { "param": "m", "type": "bthread_mutex_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "m", "type": "bthread_mutex_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dc2039ac500361afbf1da11b01c32c1f6d9b0702
code-mds/sistemi-operativi
bthreadlib/tmutex.c
[ "MIT" ]
C
bthread_mutex_trylock
int
int bthread_mutex_trylock(bthread_mutex_t* m) { bthread_block_timer_signal(); __bthread_scheduler_private* scheduler = bthread_get_scheduler(); __bthread_private* bthread = (__bthread_private*) tqueue_get_data(scheduler->current_item); if (m->owner == NULL) { m->owner = bthread; bthread_unblock_timer_signal(); } else { bthread_unblock_timer_signal(); return -1; } return 0; }
/* * When a thread tries to lock the mutex we check if it's available. * If available, we assign the mutex to the thread and return 0 * otherwise we return -1 but don't put the thread in Blocking state */
When a thread tries to lock the mutex we check if it's available. If available, we assign the mutex to the thread and return 0 otherwise we return -1 but don't put the thread in Blocking state
[ "When", "a", "thread", "tries", "to", "lock", "the", "mutex", "we", "check", "if", "it", "'", "s", "available", ".", "If", "available", "we", "assign", "the", "mutex", "to", "the", "thread", "and", "return", "0", "otherwise", "we", "return", "-", "1", "but", "don", "'", "t", "put", "the", "thread", "in", "Blocking", "state" ]
int bthread_mutex_trylock(bthread_mutex_t* m) { bthread_block_timer_signal(); __bthread_scheduler_private* scheduler = bthread_get_scheduler(); __bthread_private* bthread = (__bthread_private*) tqueue_get_data(scheduler->current_item); if (m->owner == NULL) { m->owner = bthread; bthread_unblock_timer_signal(); } else { bthread_unblock_timer_signal(); return -1; } return 0; }
[ "int", "bthread_mutex_trylock", "(", "bthread_mutex_t", "*", "m", ")", "{", "bthread_block_timer_signal", "(", ")", ";", "__bthread_scheduler_private", "*", "scheduler", "=", "bthread_get_scheduler", "(", ")", ";", "__bthread_private", "*", "bthread", "=", "(", "__bthread_private", "*", ")", "tqueue_get_data", "(", "scheduler", "->", "current_item", ")", ";", "if", "(", "m", "->", "owner", "==", "NULL", ")", "{", "m", "->", "owner", "=", "bthread", ";", "bthread_unblock_timer_signal", "(", ")", ";", "}", "else", "{", "bthread_unblock_timer_signal", "(", ")", ";", "return", "-1", ";", "}", "return", "0", ";", "}" ]
When a thread tries to lock the mutex we check if it's available.
[ "When", "a", "thread", "tries", "to", "lock", "the", "mutex", "we", "check", "if", "it", "'", "s", "available", "." ]
[]
[ { "param": "m", "type": "bthread_mutex_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "m", "type": "bthread_mutex_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dc2039ac500361afbf1da11b01c32c1f6d9b0702
code-mds/sistemi-operativi
bthreadlib/tmutex.c
[ "MIT" ]
C
bthread_mutex_unlock
int
int bthread_mutex_unlock(bthread_mutex_t* m) { bthread_block_timer_signal(); assert(m->owner != NULL); __bthread_scheduler_private* scheduler = bthread_get_scheduler(); assert(m->owner == tqueue_get_data(scheduler->current_item)); __bthread_private* unlock = tqueue_pop(&m->waiting_list); if (unlock != NULL) { m->owner = unlock; unlock->state = __BTHREAD_READY; bthread_yield(); return 0; } else { m->owner = NULL; } bthread_unblock_timer_signal(); return 0; }
/* * When a thread release the mutex, we assign it to the next thread waiting for the mutex * The thread that receives the mutex is set back to READY state and woken up */
When a thread release the mutex, we assign it to the next thread waiting for the mutex The thread that receives the mutex is set back to READY state and woken up
[ "When", "a", "thread", "release", "the", "mutex", "we", "assign", "it", "to", "the", "next", "thread", "waiting", "for", "the", "mutex", "The", "thread", "that", "receives", "the", "mutex", "is", "set", "back", "to", "READY", "state", "and", "woken", "up" ]
int bthread_mutex_unlock(bthread_mutex_t* m) { bthread_block_timer_signal(); assert(m->owner != NULL); __bthread_scheduler_private* scheduler = bthread_get_scheduler(); assert(m->owner == tqueue_get_data(scheduler->current_item)); __bthread_private* unlock = tqueue_pop(&m->waiting_list); if (unlock != NULL) { m->owner = unlock; unlock->state = __BTHREAD_READY; bthread_yield(); return 0; } else { m->owner = NULL; } bthread_unblock_timer_signal(); return 0; }
[ "int", "bthread_mutex_unlock", "(", "bthread_mutex_t", "*", "m", ")", "{", "bthread_block_timer_signal", "(", ")", ";", "assert", "(", "m", "->", "owner", "!=", "NULL", ")", ";", "__bthread_scheduler_private", "*", "scheduler", "=", "bthread_get_scheduler", "(", ")", ";", "assert", "(", "m", "->", "owner", "==", "tqueue_get_data", "(", "scheduler", "->", "current_item", ")", ")", ";", "__bthread_private", "*", "unlock", "=", "tqueue_pop", "(", "&", "m", "->", "waiting_list", ")", ";", "if", "(", "unlock", "!=", "NULL", ")", "{", "m", "->", "owner", "=", "unlock", ";", "unlock", "->", "state", "=", "__BTHREAD_READY", ";", "bthread_yield", "(", ")", ";", "return", "0", ";", "}", "else", "{", "m", "->", "owner", "=", "NULL", ";", "}", "bthread_unblock_timer_signal", "(", ")", ";", "return", "0", ";", "}" ]
When a thread release the mutex, we assign it to the next thread waiting for the mutex The thread that receives the mutex is set back to READY state and woken up
[ "When", "a", "thread", "release", "the", "mutex", "we", "assign", "it", "to", "the", "next", "thread", "waiting", "for", "the", "mutex", "The", "thread", "that", "receives", "the", "mutex", "is", "set", "back", "to", "READY", "state", "and", "woken", "up" ]
[]
[ { "param": "m", "type": "bthread_mutex_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "m", "type": "bthread_mutex_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d5db3d9e4127c659cc18c2ba3cac9515c491429
code-mds/sistemi-operativi
bthreadlib/tbarrier.c
[ "MIT" ]
C
bthread_barrier_wait
int
int bthread_barrier_wait(bthread_barrier_t *b) { // To avoid race-conditions we must execute mutex procedures atomically with the timer signal disabled. bthread_block_timer_signal(); __bthread_scheduler_private* scheduler = bthread_get_scheduler(); volatile __bthread_private* bthread = (__bthread_private*)tqueue_get_data(scheduler->current_item); if (b->count == b->barrier_size) { // When the barrier size is reached we loop throught the waiting list and set each thread to READY __bthread_private* unlock = tqueue_pop(&b->waiting_list); while (unlock != NULL) { unlock->state = __BTHREAD_READY; unlock = tqueue_pop(&b->waiting_list); } b->barrier_size = 0; bthread_unblock_timer_signal(); } else { b->barrier_size++; bthread->state = __BTHREAD_BLOCKED; // We re-use our queue to store the list of threads that need to be synchronized tqueue_enqueue(&b->waiting_list, (void*)bthread); bthread_yield(); } return 0; }
/** * The bthread_barrier_wait() function shall synchronize participating threads at the barrier referenced by barrier. * The calling thread shall block until the required number of threads have called bthread_barrier_wait() specifying the barrier. * @param b the barrier object */
The bthread_barrier_wait() function shall synchronize participating threads at the barrier referenced by barrier. The calling thread shall block until the required number of threads have called bthread_barrier_wait() specifying the barrier. @param b the barrier object
[ "The", "bthread_barrier_wait", "()", "function", "shall", "synchronize", "participating", "threads", "at", "the", "barrier", "referenced", "by", "barrier", ".", "The", "calling", "thread", "shall", "block", "until", "the", "required", "number", "of", "threads", "have", "called", "bthread_barrier_wait", "()", "specifying", "the", "barrier", ".", "@param", "b", "the", "barrier", "object" ]
int bthread_barrier_wait(bthread_barrier_t *b) { bthread_block_timer_signal(); __bthread_scheduler_private* scheduler = bthread_get_scheduler(); volatile __bthread_private* bthread = (__bthread_private*)tqueue_get_data(scheduler->current_item); if (b->count == b->barrier_size) { __bthread_private* unlock = tqueue_pop(&b->waiting_list); while (unlock != NULL) { unlock->state = __BTHREAD_READY; unlock = tqueue_pop(&b->waiting_list); } b->barrier_size = 0; bthread_unblock_timer_signal(); } else { b->barrier_size++; bthread->state = __BTHREAD_BLOCKED; tqueue_enqueue(&b->waiting_list, (void*)bthread); bthread_yield(); } return 0; }
[ "int", "bthread_barrier_wait", "(", "bthread_barrier_t", "*", "b", ")", "{", "bthread_block_timer_signal", "(", ")", ";", "__bthread_scheduler_private", "*", "scheduler", "=", "bthread_get_scheduler", "(", ")", ";", "volatile", "__bthread_private", "*", "bthread", "=", "(", "__bthread_private", "*", ")", "tqueue_get_data", "(", "scheduler", "->", "current_item", ")", ";", "if", "(", "b", "->", "count", "==", "b", "->", "barrier_size", ")", "{", "__bthread_private", "*", "unlock", "=", "tqueue_pop", "(", "&", "b", "->", "waiting_list", ")", ";", "while", "(", "unlock", "!=", "NULL", ")", "{", "unlock", "->", "state", "=", "__BTHREAD_READY", ";", "unlock", "=", "tqueue_pop", "(", "&", "b", "->", "waiting_list", ")", ";", "}", "b", "->", "barrier_size", "=", "0", ";", "bthread_unblock_timer_signal", "(", ")", ";", "}", "else", "{", "b", "->", "barrier_size", "++", ";", "bthread", "->", "state", "=", "__BTHREAD_BLOCKED", ";", "tqueue_enqueue", "(", "&", "b", "->", "waiting_list", ",", "(", "void", "*", ")", "bthread", ")", ";", "bthread_yield", "(", ")", ";", "}", "return", "0", ";", "}" ]
The bthread_barrier_wait() function shall synchronize participating threads at the barrier referenced by barrier.
[ "The", "bthread_barrier_wait", "()", "function", "shall", "synchronize", "participating", "threads", "at", "the", "barrier", "referenced", "by", "barrier", "." ]
[ "// To avoid race-conditions we must execute mutex procedures atomically with the timer signal disabled.", "// When the barrier size is reached we loop throught the waiting list and set each thread to READY", "// We re-use our queue to store the list of threads that need to be synchronized" ]
[ { "param": "b", "type": "bthread_barrier_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "b", "type": "bthread_barrier_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c60af73f866b1881b10a81c12768d272d6b6a9c3
IngoChou/DiligentCore
Graphics/GraphicsEngine/include/RenderDeviceBase.h
[ "Apache-2.0" ]
C
SetImmediateContext
void
void SetImmediateContext(IDeviceContext* pImmediateContext) { VERIFY(m_wpImmediateContext.Lock() == nullptr, "Immediate context has already been set"); m_wpImmediateContext = pImmediateContext; }
/// Set weak reference to the immediate context
Set weak reference to the immediate context
[ "Set", "weak", "reference", "to", "the", "immediate", "context" ]
void SetImmediateContext(IDeviceContext* pImmediateContext) { VERIFY(m_wpImmediateContext.Lock() == nullptr, "Immediate context has already been set"); m_wpImmediateContext = pImmediateContext; }
[ "void", "SetImmediateContext", "(", "IDeviceContext", "*", "pImmediateContext", ")", "{", "VERIFY", "(", "m_wpImmediateContext", ".", "Lock", "(", ")", "==", "nullptr", ",", "\"", "\"", ")", ";", "m_wpImmediateContext", "=", "pImmediateContext", ";", "}" ]
Set weak reference to the immediate context
[ "Set", "weak", "reference", "to", "the", "immediate", "context" ]
[]
[ { "param": "pImmediateContext", "type": "IDeviceContext" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pImmediateContext", "type": "IDeviceContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c60af73f866b1881b10a81c12768d272d6b6a9c3
IngoChou/DiligentCore
Graphics/GraphicsEngine/include/RenderDeviceBase.h
[ "Apache-2.0" ]
C
SetDeferredContext
void
void SetDeferredContext(size_t Ctx, IDeviceContext* pDeferredCtx) { VERIFY(m_wpDeferredContexts[Ctx].Lock() == nullptr, "Deferred context has already been set"); m_wpDeferredContexts[Ctx] = pDeferredCtx; }
/// Set weak reference to the deferred context
Set weak reference to the deferred context
[ "Set", "weak", "reference", "to", "the", "deferred", "context" ]
void SetDeferredContext(size_t Ctx, IDeviceContext* pDeferredCtx) { VERIFY(m_wpDeferredContexts[Ctx].Lock() == nullptr, "Deferred context has already been set"); m_wpDeferredContexts[Ctx] = pDeferredCtx; }
[ "void", "SetDeferredContext", "(", "size_t", "Ctx", ",", "IDeviceContext", "*", "pDeferredCtx", ")", "{", "VERIFY", "(", "m_wpDeferredContexts", "[", "Ctx", "]", ".", "Lock", "(", ")", "==", "nullptr", ",", "\"", "\"", ")", ";", "m_wpDeferredContexts", "[", "Ctx", "]", "=", "pDeferredCtx", ";", "}" ]
Set weak reference to the deferred context
[ "Set", "weak", "reference", "to", "the", "deferred", "context" ]
[]
[ { "param": "Ctx", "type": "size_t" }, { "param": "pDeferredCtx", "type": "IDeviceContext" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Ctx", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pDeferredCtx", "type": "IDeviceContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
08c42da159e84f498aa5a50af6986a52d8138aac
IngoChou/DiligentCore
Graphics/GraphicsAccessories/interface/GraphicsAccessories.h
[ "Apache-2.0" ]
C
GetValueSize
Uint32
inline Uint32 GetValueSize(VALUE_TYPE Val) { VERIFY_EXPR(Val < _countof(ValueTypeToSizeMap)); return ValueTypeToSizeMap[Val]; }
/// Returns the size of the specified value type
Returns the size of the specified value type
[ "Returns", "the", "size", "of", "the", "specified", "value", "type" ]
inline Uint32 GetValueSize(VALUE_TYPE Val) { VERIFY_EXPR(Val < _countof(ValueTypeToSizeMap)); return ValueTypeToSizeMap[Val]; }
[ "inline", "Uint32", "GetValueSize", "(", "VALUE_TYPE", "Val", ")", "{", "VERIFY_EXPR", "(", "Val", "<", "_countof", "(", "ValueTypeToSizeMap", ")", ")", ";", "return", "ValueTypeToSizeMap", "[", "Val", "]", ";", "}" ]
Returns the size of the specified value type
[ "Returns", "the", "size", "of", "the", "specified", "value", "type" ]
[]
[ { "param": "Val", "type": "VALUE_TYPE" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Val", "type": "VALUE_TYPE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
644971ff67044917a6b1326d7d8f497116517b4d
zekemyapp/K64F_I2C_Accelerometer
source/I2C_Accel.c
[ "MIT" ]
C
I2C_MasterSignalEvent_t
void
void I2C_MasterSignalEvent_t(uint32_t event) { if (event == ARM_I2C_EVENT_TRANSFER_DONE){ completionFlag = true; } if (event == ARM_I2C_EVENT_ADDRESS_NACK) { nakFlag = true; } }
/* I2C Signal Event * Receives Events from the I2C communication */
I2C Signal Event Receives Events from the I2C communication
[ "I2C", "Signal", "Event", "Receives", "Events", "from", "the", "I2C", "communication" ]
void I2C_MasterSignalEvent_t(uint32_t event) { if (event == ARM_I2C_EVENT_TRANSFER_DONE){ completionFlag = true; } if (event == ARM_I2C_EVENT_ADDRESS_NACK) { nakFlag = true; } }
[ "void", "I2C_MasterSignalEvent_t", "(", "uint32_t", "event", ")", "{", "if", "(", "event", "==", "ARM_I2C_EVENT_TRANSFER_DONE", ")", "{", "completionFlag", "=", "true", ";", "}", "if", "(", "event", "==", "ARM_I2C_EVENT_ADDRESS_NACK", ")", "{", "nakFlag", "=", "true", ";", "}", "}" ]
I2C Signal Event Receives Events from the I2C communication
[ "I2C", "Signal", "Event", "Receives", "Events", "from", "the", "I2C", "communication" ]
[]
[ { "param": "event", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "event", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
644971ff67044917a6b1326d7d8f497116517b4d
zekemyapp/K64F_I2C_Accelerometer
source/I2C_Accel.c
[ "MIT" ]
C
I2C_ReadAccelWhoAmI
bool
static bool I2C_ReadAccelWhoAmI(void) { uint8_t who_am_i_reg = ACCEL_WHOAMI_REG; uint8_t who_am_i_value = 0x00; uint8_t accel_addr_array_size = 0x00; bool find_device = false; uint8_t i = 0; // Gets the size of the array of addresses to check accel_addr_array_size = sizeof(g_accel_address) / sizeof(g_accel_address[0]); for (i = 0; i < accel_addr_array_size; i++) { I2C_MASTER.MasterTransmit(g_accel_address[i], &who_am_i_reg, 1, true); /* wait for transfer completed. */ while ((!nakFlag) && (!completionFlag)); nakFlag = false; if (completionFlag == true) { completionFlag = false; find_device = true; g_accel_addr_found = g_accel_address[i]; break; } } if (find_device == true) { I2C_MASTER.MasterReceive(g_accel_addr_found, &who_am_i_value, 1, false); /* wait for transfer completed. */ while ((!nakFlag) && (!completionFlag)); nakFlag = false; if (completionFlag == true) { completionFlag = false; if (who_am_i_value == FXOS8700_WHOAMI) { PRINTF("Found an FXOS8700 on board , the device address is 0x%x . \r\n", g_accel_addr_found); return true; } else if (who_am_i_value == MMA8451_WHOAMI) { PRINTF("Found an MMA8451 on board , the device address is 0x%x . \r\n", g_accel_addr_found); return true; } else { PRINTF("Found a device, the WhoAmI value is 0x%x\r\n", who_am_i_value); PRINTF("It's not MMA8451 or FXOS8700. \r\n"); PRINTF("The device address is 0x%x. \r\n", g_accel_addr_found); return false; } } else { PRINTF("Not a successful i2c communication \r\n"); return false; } } else { PRINTF("\r\n Do not find an accelerometer device ! \r\n"); return false; } }
/* I2C Who Am I * Polls a series of I2C addresses to check if the accelerometer is present */
I2C Who Am I Polls a series of I2C addresses to check if the accelerometer is present
[ "I2C", "Who", "Am", "I", "Polls", "a", "series", "of", "I2C", "addresses", "to", "check", "if", "the", "accelerometer", "is", "present" ]
static bool I2C_ReadAccelWhoAmI(void) { uint8_t who_am_i_reg = ACCEL_WHOAMI_REG; uint8_t who_am_i_value = 0x00; uint8_t accel_addr_array_size = 0x00; bool find_device = false; uint8_t i = 0; accel_addr_array_size = sizeof(g_accel_address) / sizeof(g_accel_address[0]); for (i = 0; i < accel_addr_array_size; i++) { I2C_MASTER.MasterTransmit(g_accel_address[i], &who_am_i_reg, 1, true); while ((!nakFlag) && (!completionFlag)); nakFlag = false; if (completionFlag == true) { completionFlag = false; find_device = true; g_accel_addr_found = g_accel_address[i]; break; } } if (find_device == true) { I2C_MASTER.MasterReceive(g_accel_addr_found, &who_am_i_value, 1, false); while ((!nakFlag) && (!completionFlag)); nakFlag = false; if (completionFlag == true) { completionFlag = false; if (who_am_i_value == FXOS8700_WHOAMI) { PRINTF("Found an FXOS8700 on board , the device address is 0x%x . \r\n", g_accel_addr_found); return true; } else if (who_am_i_value == MMA8451_WHOAMI) { PRINTF("Found an MMA8451 on board , the device address is 0x%x . \r\n", g_accel_addr_found); return true; } else { PRINTF("Found a device, the WhoAmI value is 0x%x\r\n", who_am_i_value); PRINTF("It's not MMA8451 or FXOS8700. \r\n"); PRINTF("The device address is 0x%x. \r\n", g_accel_addr_found); return false; } } else { PRINTF("Not a successful i2c communication \r\n"); return false; } } else { PRINTF("\r\n Do not find an accelerometer device ! \r\n"); return false; } }
[ "static", "bool", "I2C_ReadAccelWhoAmI", "(", "void", ")", "{", "uint8_t", "who_am_i_reg", "=", "ACCEL_WHOAMI_REG", ";", "uint8_t", "who_am_i_value", "=", "0x00", ";", "uint8_t", "accel_addr_array_size", "=", "0x00", ";", "bool", "find_device", "=", "false", ";", "uint8_t", "i", "=", "0", ";", "accel_addr_array_size", "=", "sizeof", "(", "g_accel_address", ")", "/", "sizeof", "(", "g_accel_address", "[", "0", "]", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "accel_addr_array_size", ";", "i", "++", ")", "{", "I2C_MASTER", ".", "MasterTransmit", "(", "g_accel_address", "[", "i", "]", ",", "&", "who_am_i_reg", ",", "1", ",", "true", ")", ";", "while", "(", "(", "!", "nakFlag", ")", "&&", "(", "!", "completionFlag", ")", ")", ";", "nakFlag", "=", "false", ";", "if", "(", "completionFlag", "==", "true", ")", "{", "completionFlag", "=", "false", ";", "find_device", "=", "true", ";", "g_accel_addr_found", "=", "g_accel_address", "[", "i", "]", ";", "break", ";", "}", "}", "if", "(", "find_device", "==", "true", ")", "{", "I2C_MASTER", ".", "MasterReceive", "(", "g_accel_addr_found", ",", "&", "who_am_i_value", ",", "1", ",", "false", ")", ";", "while", "(", "(", "!", "nakFlag", ")", "&&", "(", "!", "completionFlag", ")", ")", ";", "nakFlag", "=", "false", ";", "if", "(", "completionFlag", "==", "true", ")", "{", "completionFlag", "=", "false", ";", "if", "(", "who_am_i_value", "==", "FXOS8700_WHOAMI", ")", "{", "PRINTF", "(", "\"", "\\r", "\\n", "\"", ",", "g_accel_addr_found", ")", ";", "return", "true", ";", "}", "else", "if", "(", "who_am_i_value", "==", "MMA8451_WHOAMI", ")", "{", "PRINTF", "(", "\"", "\\r", "\\n", "\"", ",", "g_accel_addr_found", ")", ";", "return", "true", ";", "}", "else", "{", "PRINTF", "(", "\"", "\\r", "\\n", "\"", ",", "who_am_i_value", ")", ";", "PRINTF", "(", "\"", "\\r", "\\n", "\"", ")", ";", "PRINTF", "(", "\"", "\\r", "\\n", "\"", ",", "g_accel_addr_found", ")", ";", "return", "false", ";", "}", "}", "else", "{", "PRINTF", "(", "\"", "\\r", "\\n", "\"", ")", ";", "return", "false", ";", "}", "}", "else", "{", "PRINTF", "(", "\"", "\\r", "\\n", "\\r", "\\n", "\"", ")", ";", "return", "false", ";", "}", "}" ]
I2C Who Am I Polls a series of I2C addresses to check if the accelerometer is present
[ "I2C", "Who", "Am", "I", "Polls", "a", "series", "of", "I2C", "addresses", "to", "check", "if", "the", "accelerometer", "is", "present" ]
[ "// Gets the size of the array of addresses to check", "/* wait for transfer completed. */", "/* wait for transfer completed. */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
644971ff67044917a6b1326d7d8f497116517b4d
zekemyapp/K64F_I2C_Accelerometer
source/I2C_Accel.c
[ "MIT" ]
C
I2C_WriteAccelReg
bool
static bool I2C_WriteAccelReg(uint8_t device_addr, uint8_t reg_addr, uint8_t value) { uint8_t writedata[2] = {reg_addr, value}; /* direction=write : start+device_write;cmdbuff;xBuff; */ /* direction=recive : start+device_write;cmdbuff;repeatStart+device_read;xBuff; */ I2C_MASTER.MasterTransmit(device_addr, writedata, 2, false); /* wait for transfer completed. */ while ((!nakFlag) && (!completionFlag)) { } nakFlag = false; if (completionFlag == true) { completionFlag = false; return true; } else { return false; } }
/* Write Accelerometer Register * Writes a value to an address in the accelerometer */
Write Accelerometer Register Writes a value to an address in the accelerometer
[ "Write", "Accelerometer", "Register", "Writes", "a", "value", "to", "an", "address", "in", "the", "accelerometer" ]
static bool I2C_WriteAccelReg(uint8_t device_addr, uint8_t reg_addr, uint8_t value) { uint8_t writedata[2] = {reg_addr, value}; I2C_MASTER.MasterTransmit(device_addr, writedata, 2, false); while ((!nakFlag) && (!completionFlag)) { } nakFlag = false; if (completionFlag == true) { completionFlag = false; return true; } else { return false; } }
[ "static", "bool", "I2C_WriteAccelReg", "(", "uint8_t", "device_addr", ",", "uint8_t", "reg_addr", ",", "uint8_t", "value", ")", "{", "uint8_t", "writedata", "[", "2", "]", "=", "{", "reg_addr", ",", "value", "}", ";", "I2C_MASTER", ".", "MasterTransmit", "(", "device_addr", ",", "writedata", ",", "2", ",", "false", ")", ";", "while", "(", "(", "!", "nakFlag", ")", "&&", "(", "!", "completionFlag", ")", ")", "{", "}", "nakFlag", "=", "false", ";", "if", "(", "completionFlag", "==", "true", ")", "{", "completionFlag", "=", "false", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Write Accelerometer Register Writes a value to an address in the accelerometer
[ "Write", "Accelerometer", "Register", "Writes", "a", "value", "to", "an", "address", "in", "the", "accelerometer" ]
[ "/* direction=write : start+device_write;cmdbuff;xBuff; */", "/* direction=recive : start+device_write;cmdbuff;repeatStart+device_read;xBuff; */", "/* wait for transfer completed. */" ]
[ { "param": "device_addr", "type": "uint8_t" }, { "param": "reg_addr", "type": "uint8_t" }, { "param": "value", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device_addr", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reg_addr", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
644971ff67044917a6b1326d7d8f497116517b4d
zekemyapp/K64F_I2C_Accelerometer
source/I2C_Accel.c
[ "MIT" ]
C
I2C_ReadAccelRegs
bool
static bool I2C_ReadAccelRegs(uint8_t device_addr, uint8_t reg_addr, uint8_t *rxBuff, uint32_t rxSize) { /* direction=write : start+device_write;cmdbuff;xBuff; */ /* direction=recive : start+device_write;cmdbuff;repeatStart+device_read;xBuff; */ I2C_MASTER.MasterTransmit(device_addr, &reg_addr, 1, false); while ((!nakFlag) && (!completionFlag)) { } nakFlag = false; completionFlag = false; I2C_MASTER.MasterReceive(device_addr, rxBuff, rxSize, false); /* wait for transfer completed. */ while ((!nakFlag) && (!completionFlag)) { } nakFlag = false; if (completionFlag == true) { completionFlag = false; return true; } else { return false; } }
/* Read Accelerometer Registers * Reads a series of values from an address in the accelerometer */
Read Accelerometer Registers Reads a series of values from an address in the accelerometer
[ "Read", "Accelerometer", "Registers", "Reads", "a", "series", "of", "values", "from", "an", "address", "in", "the", "accelerometer" ]
static bool I2C_ReadAccelRegs(uint8_t device_addr, uint8_t reg_addr, uint8_t *rxBuff, uint32_t rxSize) { I2C_MASTER.MasterTransmit(device_addr, &reg_addr, 1, false); while ((!nakFlag) && (!completionFlag)) { } nakFlag = false; completionFlag = false; I2C_MASTER.MasterReceive(device_addr, rxBuff, rxSize, false); while ((!nakFlag) && (!completionFlag)) { } nakFlag = false; if (completionFlag == true) { completionFlag = false; return true; } else { return false; } }
[ "static", "bool", "I2C_ReadAccelRegs", "(", "uint8_t", "device_addr", ",", "uint8_t", "reg_addr", ",", "uint8_t", "*", "rxBuff", ",", "uint32_t", "rxSize", ")", "{", "I2C_MASTER", ".", "MasterTransmit", "(", "device_addr", ",", "&", "reg_addr", ",", "1", ",", "false", ")", ";", "while", "(", "(", "!", "nakFlag", ")", "&&", "(", "!", "completionFlag", ")", ")", "{", "}", "nakFlag", "=", "false", ";", "completionFlag", "=", "false", ";", "I2C_MASTER", ".", "MasterReceive", "(", "device_addr", ",", "rxBuff", ",", "rxSize", ",", "false", ")", ";", "while", "(", "(", "!", "nakFlag", ")", "&&", "(", "!", "completionFlag", ")", ")", "{", "}", "nakFlag", "=", "false", ";", "if", "(", "completionFlag", "==", "true", ")", "{", "completionFlag", "=", "false", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Read Accelerometer Registers Reads a series of values from an address in the accelerometer
[ "Read", "Accelerometer", "Registers", "Reads", "a", "series", "of", "values", "from", "an", "address", "in", "the", "accelerometer" ]
[ "/* direction=write : start+device_write;cmdbuff;xBuff; */", "/* direction=recive : start+device_write;cmdbuff;repeatStart+device_read;xBuff; */", "/* wait for transfer completed. */" ]
[ { "param": "device_addr", "type": "uint8_t" }, { "param": "reg_addr", "type": "uint8_t" }, { "param": "rxBuff", "type": "uint8_t" }, { "param": "rxSize", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device_addr", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reg_addr", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rxBuff", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rxSize", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
48199babac0224d391ef1384e95fd39c3905cb0a
aarestad/NetHack
src/dokick.c
[ "Intel", "X11" ]
C
kickdmg
void
static void kickdmg(struct monst *mon, boolean clumsy) { int mdx, mdy; int dmg = (ACURRSTR + ACURR(A_DEX) + ACURR(A_CON)) / 15; int specialdmg, kick_skill = P_NONE; boolean trapkilled = FALSE; if (uarmf && uarmf->otyp == KICKING_BOOTS) dmg += 5; /* excessive wt affects dex, so it affects dmg */ if (clumsy) dmg /= 2; /* kicking a dragon or an elephant will not harm it */ if (thick_skinned(mon->data)) dmg = 0; /* attacking a shade is normally useless */ if (mon->data == &mons[PM_SHADE]) dmg = 0; specialdmg = special_dmgval(&g.youmonst, mon, W_ARMF, (long *) 0); if (mon->data == &mons[PM_SHADE] && !specialdmg) { pline_The("%s.", kick_passes_thru); /* doesn't exercise skill or abuse alignment or frighten pet, and shades have no passive counterattack */ return; } if (M_AP_TYPE(mon)) seemimic(mon); check_caitiff(mon); /* squeeze some guilt feelings... */ if (mon->mtame) { abuse_dog(mon); if (mon->mtame) monflee(mon, (dmg ? rnd(dmg) : 1), FALSE, FALSE); else mon->mflee = 0; } if (dmg > 0) { /* convert potential damage to actual damage */ dmg = rnd(dmg); if (martial()) { if (dmg > 1) kick_skill = P_MARTIAL_ARTS; dmg += rn2(ACURR(A_DEX) / 2 + 1); } /* a good kick exercises your dex */ exercise(A_DEX, TRUE); } dmg += specialdmg; /* for blessed (or hypothetically, silver) boots */ if (uarmf) dmg += uarmf->spe; dmg += u.udaminc; /* add ring(s) of increase damage */ if (dmg > 0) mon->mhp -= dmg; if (!DEADMONSTER(mon) && martial() && !bigmonst(mon->data) && !rn2(3) && mon->mcanmove && mon != u.ustuck && !mon->mtrapped) { /* see if the monster has a place to move into */ mdx = mon->mx + u.dx; mdy = mon->my + u.dy; if (goodpos(mdx, mdy, mon, 0)) { pline("%s reels from the blow.", Monnam(mon)); if (m_in_out_region(mon, mdx, mdy)) { remove_monster(mon->mx, mon->my); newsym(mon->mx, mon->my); place_monster(mon, mdx, mdy); newsym(mon->mx, mon->my); set_apparxy(mon); if (mintrap(mon) == 2) trapkilled = TRUE; } } } (void) passive(mon, uarmf, TRUE, !DEADMONSTER(mon), AT_KICK, FALSE); if (DEADMONSTER(mon) && !trapkilled) killed(mon); /* may bring up a dialog, so put this after all messages */ if (kick_skill != P_NONE) /* exercise proficiency */ use_skill(kick_skill, 1); }
/* kicking damage when not poly'd into a form with a kick attack */
kicking damage when not poly'd into a form with a kick attack
[ "kicking", "damage", "when", "not", "poly", "'", "d", "into", "a", "form", "with", "a", "kick", "attack" ]
static void kickdmg(struct monst *mon, boolean clumsy) { int mdx, mdy; int dmg = (ACURRSTR + ACURR(A_DEX) + ACURR(A_CON)) / 15; int specialdmg, kick_skill = P_NONE; boolean trapkilled = FALSE; if (uarmf && uarmf->otyp == KICKING_BOOTS) dmg += 5; if (clumsy) dmg /= 2; if (thick_skinned(mon->data)) dmg = 0; if (mon->data == &mons[PM_SHADE]) dmg = 0; specialdmg = special_dmgval(&g.youmonst, mon, W_ARMF, (long *) 0); if (mon->data == &mons[PM_SHADE] && !specialdmg) { pline_The("%s.", kick_passes_thru); return; } if (M_AP_TYPE(mon)) seemimic(mon); check_caitiff(mon); if (mon->mtame) { abuse_dog(mon); if (mon->mtame) monflee(mon, (dmg ? rnd(dmg) : 1), FALSE, FALSE); else mon->mflee = 0; } if (dmg > 0) { dmg = rnd(dmg); if (martial()) { if (dmg > 1) kick_skill = P_MARTIAL_ARTS; dmg += rn2(ACURR(A_DEX) / 2 + 1); } exercise(A_DEX, TRUE); } dmg += specialdmg; if (uarmf) dmg += uarmf->spe; dmg += u.udaminc; if (dmg > 0) mon->mhp -= dmg; if (!DEADMONSTER(mon) && martial() && !bigmonst(mon->data) && !rn2(3) && mon->mcanmove && mon != u.ustuck && !mon->mtrapped) { mdx = mon->mx + u.dx; mdy = mon->my + u.dy; if (goodpos(mdx, mdy, mon, 0)) { pline("%s reels from the blow.", Monnam(mon)); if (m_in_out_region(mon, mdx, mdy)) { remove_monster(mon->mx, mon->my); newsym(mon->mx, mon->my); place_monster(mon, mdx, mdy); newsym(mon->mx, mon->my); set_apparxy(mon); if (mintrap(mon) == 2) trapkilled = TRUE; } } } (void) passive(mon, uarmf, TRUE, !DEADMONSTER(mon), AT_KICK, FALSE); if (DEADMONSTER(mon) && !trapkilled) killed(mon); if (kick_skill != P_NONE) use_skill(kick_skill, 1); }
[ "static", "void", "kickdmg", "(", "struct", "monst", "*", "mon", ",", "boolean", "clumsy", ")", "{", "int", "mdx", ",", "mdy", ";", "int", "dmg", "=", "(", "ACURRSTR", "+", "ACURR", "(", "A_DEX", ")", "+", "ACURR", "(", "A_CON", ")", ")", "/", "15", ";", "int", "specialdmg", ",", "kick_skill", "=", "P_NONE", ";", "boolean", "trapkilled", "=", "FALSE", ";", "if", "(", "uarmf", "&&", "uarmf", "->", "otyp", "==", "KICKING_BOOTS", ")", "dmg", "+=", "5", ";", "if", "(", "clumsy", ")", "dmg", "/=", "2", ";", "if", "(", "thick_skinned", "(", "mon", "->", "data", ")", ")", "dmg", "=", "0", ";", "if", "(", "mon", "->", "data", "==", "&", "mons", "[", "PM_SHADE", "]", ")", "dmg", "=", "0", ";", "specialdmg", "=", "special_dmgval", "(", "&", "g", ".", "youmonst", ",", "mon", ",", "W_ARMF", ",", "(", "long", "*", ")", "0", ")", ";", "if", "(", "mon", "->", "data", "==", "&", "mons", "[", "PM_SHADE", "]", "&&", "!", "specialdmg", ")", "{", "pline_The", "(", "\"", "\"", ",", "kick_passes_thru", ")", ";", "return", ";", "}", "if", "(", "M_AP_TYPE", "(", "mon", ")", ")", "seemimic", "(", "mon", ")", ";", "check_caitiff", "(", "mon", ")", ";", "if", "(", "mon", "->", "mtame", ")", "{", "abuse_dog", "(", "mon", ")", ";", "if", "(", "mon", "->", "mtame", ")", "monflee", "(", "mon", ",", "(", "dmg", "?", "rnd", "(", "dmg", ")", ":", "1", ")", ",", "FALSE", ",", "FALSE", ")", ";", "else", "mon", "->", "mflee", "=", "0", ";", "}", "if", "(", "dmg", ">", "0", ")", "{", "dmg", "=", "rnd", "(", "dmg", ")", ";", "if", "(", "martial", "(", ")", ")", "{", "if", "(", "dmg", ">", "1", ")", "kick_skill", "=", "P_MARTIAL_ARTS", ";", "dmg", "+=", "rn2", "(", "ACURR", "(", "A_DEX", ")", "/", "2", "+", "1", ")", ";", "}", "exercise", "(", "A_DEX", ",", "TRUE", ")", ";", "}", "dmg", "+=", "specialdmg", ";", "if", "(", "uarmf", ")", "dmg", "+=", "uarmf", "->", "spe", ";", "dmg", "+=", "u", ".", "udaminc", ";", "if", "(", "dmg", ">", "0", ")", "mon", "->", "mhp", "-=", "dmg", ";", "if", "(", "!", "DEADMONSTER", "(", "mon", ")", "&&", "martial", "(", ")", "&&", "!", "bigmonst", "(", "mon", "->", "data", ")", "&&", "!", "rn2", "(", "3", ")", "&&", "mon", "->", "mcanmove", "&&", "mon", "!=", "u", ".", "ustuck", "&&", "!", "mon", "->", "mtrapped", ")", "{", "mdx", "=", "mon", "->", "mx", "+", "u", ".", "dx", ";", "mdy", "=", "mon", "->", "my", "+", "u", ".", "dy", ";", "if", "(", "goodpos", "(", "mdx", ",", "mdy", ",", "mon", ",", "0", ")", ")", "{", "pline", "(", "\"", "\"", ",", "Monnam", "(", "mon", ")", ")", ";", "if", "(", "m_in_out_region", "(", "mon", ",", "mdx", ",", "mdy", ")", ")", "{", "remove_monster", "(", "mon", "->", "mx", ",", "mon", "->", "my", ")", ";", "newsym", "(", "mon", "->", "mx", ",", "mon", "->", "my", ")", ";", "place_monster", "(", "mon", ",", "mdx", ",", "mdy", ")", ";", "newsym", "(", "mon", "->", "mx", ",", "mon", "->", "my", ")", ";", "set_apparxy", "(", "mon", ")", ";", "if", "(", "mintrap", "(", "mon", ")", "==", "2", ")", "trapkilled", "=", "TRUE", ";", "}", "}", "}", "(", "void", ")", "passive", "(", "mon", ",", "uarmf", ",", "TRUE", ",", "!", "DEADMONSTER", "(", "mon", ")", ",", "AT_KICK", ",", "FALSE", ")", ";", "if", "(", "DEADMONSTER", "(", "mon", ")", "&&", "!", "trapkilled", ")", "killed", "(", "mon", ")", ";", "if", "(", "kick_skill", "!=", "P_NONE", ")", "use_skill", "(", "kick_skill", ",", "1", ")", ";", "}" ]
kicking damage when not poly'd into a form with a kick attack
[ "kicking", "damage", "when", "not", "poly", "'", "d", "into", "a", "form", "with", "a", "kick", "attack" ]
[ "/* excessive wt affects dex, so it affects dmg */", "/* kicking a dragon or an elephant will not harm it */", "/* attacking a shade is normally useless */", "/* doesn't exercise skill or abuse alignment or frighten pet,\n and shades have no passive counterattack */", "/* squeeze some guilt feelings... */", "/* convert potential damage to actual damage */", "/* a good kick exercises your dex */", "/* for blessed (or hypothetically, silver) boots */", "/* add ring(s) of increase damage */", "/* see if the monster has a place to move into */", "/* may bring up a dialog, so put this after all messages */", "/* exercise proficiency */" ]
[ { "param": "mon", "type": "struct monst" }, { "param": "clumsy", "type": "boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mon", "type": "struct monst", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "clumsy", "type": "boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
48199babac0224d391ef1384e95fd39c3905cb0a
aarestad/NetHack
src/dokick.c
[ "Intel", "X11" ]
C
ghitm
boolean
boolean ghitm(register struct monst *mtmp, register struct obj *gold) { boolean msg_given = FALSE; if (!likes_gold(mtmp->data) && !mtmp->isshk && !mtmp->ispriest && !mtmp->isgd && !is_mercenary(mtmp->data)) { wakeup(mtmp, TRUE); } else if (!mtmp->mcanmove) { /* too light to do real damage */ if (canseemon(mtmp)) { pline_The("%s harmlessly %s %s.", xname(gold), otense(gold, "hit"), mon_nam(mtmp)); msg_given = TRUE; } } else { long umoney, value = gold->quan * objects[gold->otyp].oc_cost; mtmp->msleeping = 0; finish_meating(mtmp); if (!mtmp->isgd && !rn2(4)) /* not always pleasing */ setmangry(mtmp, TRUE); /* greedy monsters catch gold */ if (cansee(mtmp->mx, mtmp->my)) pline("%s catches the gold.", Monnam(mtmp)); (void) mpickobj(mtmp, gold); gold = (struct obj *) 0; /* obj has been freed */ if (mtmp->isshk) { long robbed = ESHK(mtmp)->robbed; if (robbed) { robbed -= value; if (robbed < 0L) robbed = 0L; pline_The("amount %scovers %s recent losses.", !robbed ? "" : "partially ", mhis(mtmp)); ESHK(mtmp)->robbed = robbed; if (!robbed) make_happy_shk(mtmp, FALSE); } else { if (mtmp->mpeaceful) { ESHK(mtmp)->credit += value; You("have %ld %s in credit.", ESHK(mtmp)->credit, currency(ESHK(mtmp)->credit)); } else verbalize("Thanks, scum!"); } } else if (mtmp->ispriest) { if (mtmp->mpeaceful) verbalize("Thank you for your contribution."); else verbalize("Thanks, scum!"); } else if (mtmp->isgd) { umoney = money_cnt(g.invent); /* Some of these are iffy, because a hostile guard won't become peaceful and resume leading hero out of the vault. If he did do that, player could try fighting, then weasle out of being killed by throwing his/her gold when losing. */ verbalize(umoney ? "Drop the rest and follow me." : hidden_gold(TRUE) ? "You still have hidden gold. Drop it now." : mtmp->mpeaceful ? "I'll take care of that; please move along." : "I'll take that; now get moving."); } else if (is_mercenary(mtmp->data)) { long goldreqd = 0L; if (rn2(3)) { if (mtmp->data == &mons[PM_SOLDIER]) goldreqd = 100L; else if (mtmp->data == &mons[PM_SERGEANT]) goldreqd = 250L; else if (mtmp->data == &mons[PM_LIEUTENANT]) goldreqd = 500L; else if (mtmp->data == &mons[PM_CAPTAIN]) goldreqd = 750L; if (goldreqd) { umoney = money_cnt(g.invent); if (value > goldreqd + (umoney + u.ulevel * rn2(5)) / ACURR(A_CHA)) mtmp->mpeaceful = TRUE; } } if (mtmp->mpeaceful) verbalize("That should do. Now beat it!"); else verbalize("That's not enough, coward!"); } return TRUE; } if (!msg_given) miss(xname(gold), mtmp); return FALSE; }
/* * Return TRUE if caught (the gold taken care of), FALSE otherwise. * The gold object is *not* attached to the fobj chain! */
Return TRUE if caught (the gold taken care of), FALSE otherwise. The gold object is *not* attached to the fobj chain!
[ "Return", "TRUE", "if", "caught", "(", "the", "gold", "taken", "care", "of", ")", "FALSE", "otherwise", ".", "The", "gold", "object", "is", "*", "not", "*", "attached", "to", "the", "fobj", "chain!" ]
boolean ghitm(register struct monst *mtmp, register struct obj *gold) { boolean msg_given = FALSE; if (!likes_gold(mtmp->data) && !mtmp->isshk && !mtmp->ispriest && !mtmp->isgd && !is_mercenary(mtmp->data)) { wakeup(mtmp, TRUE); } else if (!mtmp->mcanmove) { if (canseemon(mtmp)) { pline_The("%s harmlessly %s %s.", xname(gold), otense(gold, "hit"), mon_nam(mtmp)); msg_given = TRUE; } } else { long umoney, value = gold->quan * objects[gold->otyp].oc_cost; mtmp->msleeping = 0; finish_meating(mtmp); if (!mtmp->isgd && !rn2(4)) setmangry(mtmp, TRUE); if (cansee(mtmp->mx, mtmp->my)) pline("%s catches the gold.", Monnam(mtmp)); (void) mpickobj(mtmp, gold); gold = (struct obj *) 0; if (mtmp->isshk) { long robbed = ESHK(mtmp)->robbed; if (robbed) { robbed -= value; if (robbed < 0L) robbed = 0L; pline_The("amount %scovers %s recent losses.", !robbed ? "" : "partially ", mhis(mtmp)); ESHK(mtmp)->robbed = robbed; if (!robbed) make_happy_shk(mtmp, FALSE); } else { if (mtmp->mpeaceful) { ESHK(mtmp)->credit += value; You("have %ld %s in credit.", ESHK(mtmp)->credit, currency(ESHK(mtmp)->credit)); } else verbalize("Thanks, scum!"); } } else if (mtmp->ispriest) { if (mtmp->mpeaceful) verbalize("Thank you for your contribution."); else verbalize("Thanks, scum!"); } else if (mtmp->isgd) { umoney = money_cnt(g.invent); verbalize(umoney ? "Drop the rest and follow me." : hidden_gold(TRUE) ? "You still have hidden gold. Drop it now." : mtmp->mpeaceful ? "I'll take care of that; please move along." : "I'll take that; now get moving."); } else if (is_mercenary(mtmp->data)) { long goldreqd = 0L; if (rn2(3)) { if (mtmp->data == &mons[PM_SOLDIER]) goldreqd = 100L; else if (mtmp->data == &mons[PM_SERGEANT]) goldreqd = 250L; else if (mtmp->data == &mons[PM_LIEUTENANT]) goldreqd = 500L; else if (mtmp->data == &mons[PM_CAPTAIN]) goldreqd = 750L; if (goldreqd) { umoney = money_cnt(g.invent); if (value > goldreqd + (umoney + u.ulevel * rn2(5)) / ACURR(A_CHA)) mtmp->mpeaceful = TRUE; } } if (mtmp->mpeaceful) verbalize("That should do. Now beat it!"); else verbalize("That's not enough, coward!"); } return TRUE; } if (!msg_given) miss(xname(gold), mtmp); return FALSE; }
[ "boolean", "ghitm", "(", "register", "struct", "monst", "*", "mtmp", ",", "register", "struct", "obj", "*", "gold", ")", "{", "boolean", "msg_given", "=", "FALSE", ";", "if", "(", "!", "likes_gold", "(", "mtmp", "->", "data", ")", "&&", "!", "mtmp", "->", "isshk", "&&", "!", "mtmp", "->", "ispriest", "&&", "!", "mtmp", "->", "isgd", "&&", "!", "is_mercenary", "(", "mtmp", "->", "data", ")", ")", "{", "wakeup", "(", "mtmp", ",", "TRUE", ")", ";", "}", "else", "if", "(", "!", "mtmp", "->", "mcanmove", ")", "{", "if", "(", "canseemon", "(", "mtmp", ")", ")", "{", "pline_The", "(", "\"", "\"", ",", "xname", "(", "gold", ")", ",", "otense", "(", "gold", ",", "\"", "\"", ")", ",", "mon_nam", "(", "mtmp", ")", ")", ";", "msg_given", "=", "TRUE", ";", "}", "}", "else", "{", "long", "umoney", ",", "value", "=", "gold", "->", "quan", "*", "objects", "[", "gold", "->", "otyp", "]", ".", "oc_cost", ";", "mtmp", "->", "msleeping", "=", "0", ";", "finish_meating", "(", "mtmp", ")", ";", "if", "(", "!", "mtmp", "->", "isgd", "&&", "!", "rn2", "(", "4", ")", ")", "setmangry", "(", "mtmp", ",", "TRUE", ")", ";", "if", "(", "cansee", "(", "mtmp", "->", "mx", ",", "mtmp", "->", "my", ")", ")", "pline", "(", "\"", "\"", ",", "Monnam", "(", "mtmp", ")", ")", ";", "(", "void", ")", "mpickobj", "(", "mtmp", ",", "gold", ")", ";", "gold", "=", "(", "struct", "obj", "*", ")", "0", ";", "if", "(", "mtmp", "->", "isshk", ")", "{", "long", "robbed", "=", "ESHK", "(", "mtmp", ")", "->", "robbed", ";", "if", "(", "robbed", ")", "{", "robbed", "-=", "value", ";", "if", "(", "robbed", "<", "0L", ")", "robbed", "=", "0L", ";", "pline_The", "(", "\"", "\"", ",", "!", "robbed", "?", "\"", "\"", ":", "\"", "\"", ",", "mhis", "(", "mtmp", ")", ")", ";", "ESHK", "(", "mtmp", ")", "->", "robbed", "=", "robbed", ";", "if", "(", "!", "robbed", ")", "make_happy_shk", "(", "mtmp", ",", "FALSE", ")", ";", "}", "else", "{", "if", "(", "mtmp", "->", "mpeaceful", ")", "{", "ESHK", "(", "mtmp", ")", "->", "credit", "+=", "value", ";", "You", "(", "\"", "\"", ",", "ESHK", "(", "mtmp", ")", "->", "credit", ",", "currency", "(", "ESHK", "(", "mtmp", ")", "->", "credit", ")", ")", ";", "}", "else", "verbalize", "(", "\"", "\"", ")", ";", "}", "}", "else", "if", "(", "mtmp", "->", "ispriest", ")", "{", "if", "(", "mtmp", "->", "mpeaceful", ")", "verbalize", "(", "\"", "\"", ")", ";", "else", "verbalize", "(", "\"", "\"", ")", ";", "}", "else", "if", "(", "mtmp", "->", "isgd", ")", "{", "umoney", "=", "money_cnt", "(", "g", ".", "invent", ")", ";", "verbalize", "(", "umoney", "?", "\"", "\"", ":", "hidden_gold", "(", "TRUE", ")", "?", "\"", "\"", ":", "mtmp", "->", "mpeaceful", "?", "\"", "\"", ":", "\"", "\"", ")", ";", "}", "else", "if", "(", "is_mercenary", "(", "mtmp", "->", "data", ")", ")", "{", "long", "goldreqd", "=", "0L", ";", "if", "(", "rn2", "(", "3", ")", ")", "{", "if", "(", "mtmp", "->", "data", "==", "&", "mons", "[", "PM_SOLDIER", "]", ")", "goldreqd", "=", "100L", ";", "else", "if", "(", "mtmp", "->", "data", "==", "&", "mons", "[", "PM_SERGEANT", "]", ")", "goldreqd", "=", "250L", ";", "else", "if", "(", "mtmp", "->", "data", "==", "&", "mons", "[", "PM_LIEUTENANT", "]", ")", "goldreqd", "=", "500L", ";", "else", "if", "(", "mtmp", "->", "data", "==", "&", "mons", "[", "PM_CAPTAIN", "]", ")", "goldreqd", "=", "750L", ";", "if", "(", "goldreqd", ")", "{", "umoney", "=", "money_cnt", "(", "g", ".", "invent", ")", ";", "if", "(", "value", ">", "goldreqd", "+", "(", "umoney", "+", "u", ".", "ulevel", "*", "rn2", "(", "5", ")", ")", "/", "ACURR", "(", "A_CHA", ")", ")", "mtmp", "->", "mpeaceful", "=", "TRUE", ";", "}", "}", "if", "(", "mtmp", "->", "mpeaceful", ")", "verbalize", "(", "\"", "\"", ")", ";", "else", "verbalize", "(", "\"", "\"", ")", ";", "}", "return", "TRUE", ";", "}", "if", "(", "!", "msg_given", ")", "miss", "(", "xname", "(", "gold", ")", ",", "mtmp", ")", ";", "return", "FALSE", ";", "}" ]
Return TRUE if caught (the gold taken care of), FALSE otherwise.
[ "Return", "TRUE", "if", "caught", "(", "the", "gold", "taken", "care", "of", ")", "FALSE", "otherwise", "." ]
[ "/* too light to do real damage */", "/* not always pleasing */", "/* greedy monsters catch gold */", "/* obj has been freed */", "/* Some of these are iffy, because a hostile guard\n won't become peaceful and resume leading hero\n out of the vault. If he did do that, player\n could try fighting, then weasle out of being\n killed by throwing his/her gold when losing. */" ]
[ { "param": "mtmp", "type": "struct monst" }, { "param": "gold", "type": "struct obj" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mtmp", "type": "struct monst", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gold", "type": "struct obj", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
48199babac0224d391ef1384e95fd39c3905cb0a
aarestad/NetHack
src/dokick.c
[ "Intel", "X11" ]
C
container_impact_dmg
void
void container_impact_dmg(struct obj *obj, xchar x, xchar y) /* coordinates where object was before the impact, not after */ { struct monst *shkp; struct obj *otmp, *otmp2; long loss = 0L; boolean costly, insider, frominv; /* only consider normal containers */ if (!Is_container(obj) || !Has_contents(obj) || Is_mbag(obj)) return; costly = ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) && costly_spot(x, y)); insider = (*u.ushops && inside_shop(u.ux, u.uy) && *in_rooms(x, y, SHOPBASE) == *u.ushops); /* if dropped or thrown, shop ownership flags are set on this obj */ frominv = (obj != g.kickedobj); for (otmp = obj->cobj; otmp; otmp = otmp2) { const char *result = (char *) 0; otmp2 = otmp->nobj; if (objects[otmp->otyp].oc_material == GLASS && otmp->oclass != GEM_CLASS && !obj_resists(otmp, 33, 100)) { result = "shatter"; } else if (otmp->otyp == EGG && !rn2(3)) { result = "cracking"; } if (result) { if (otmp->otyp == MIRROR) change_luck(-2); /* eggs laid by you. penalty is -1 per egg, max 5, * but it's always exactly 1 that breaks */ if (otmp->otyp == EGG && otmp->spe && otmp->corpsenm >= LOW_PM) change_luck(-1); You_hear("a muffled %s.", result); if (costly) { if (frominv && !otmp->unpaid) otmp->no_charge = 1; loss += stolen_value(otmp, x, y, (boolean) shkp->mpeaceful, TRUE); } if (otmp->quan > 1L) { useup(otmp); } else { obj_extract_self(otmp); obfree(otmp, (struct obj *) 0); } /* contents of this container are no longer known */ obj->cknown = 0; } } if (costly && loss) { if (!insider) { You("caused %ld %s worth of damage!", loss, currency(loss)); make_angry_shk(shkp, x, y); } else { You("owe %s %ld %s for objects destroyed.", mon_nam(shkp), loss, currency(loss)); } } }
/* container is kicked, dropped, thrown or otherwise impacted by player. * Assumes container is on floor. Checks contents for possible damage. */
container is kicked, dropped, thrown or otherwise impacted by player. Assumes container is on floor. Checks contents for possible damage.
[ "container", "is", "kicked", "dropped", "thrown", "or", "otherwise", "impacted", "by", "player", ".", "Assumes", "container", "is", "on", "floor", ".", "Checks", "contents", "for", "possible", "damage", "." ]
void container_impact_dmg(struct obj *obj, xchar x, xchar y) { struct monst *shkp; struct obj *otmp, *otmp2; long loss = 0L; boolean costly, insider, frominv; if (!Is_container(obj) || !Has_contents(obj) || Is_mbag(obj)) return; costly = ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) && costly_spot(x, y)); insider = (*u.ushops && inside_shop(u.ux, u.uy) && *in_rooms(x, y, SHOPBASE) == *u.ushops); frominv = (obj != g.kickedobj); for (otmp = obj->cobj; otmp; otmp = otmp2) { const char *result = (char *) 0; otmp2 = otmp->nobj; if (objects[otmp->otyp].oc_material == GLASS && otmp->oclass != GEM_CLASS && !obj_resists(otmp, 33, 100)) { result = "shatter"; } else if (otmp->otyp == EGG && !rn2(3)) { result = "cracking"; } if (result) { if (otmp->otyp == MIRROR) change_luck(-2); if (otmp->otyp == EGG && otmp->spe && otmp->corpsenm >= LOW_PM) change_luck(-1); You_hear("a muffled %s.", result); if (costly) { if (frominv && !otmp->unpaid) otmp->no_charge = 1; loss += stolen_value(otmp, x, y, (boolean) shkp->mpeaceful, TRUE); } if (otmp->quan > 1L) { useup(otmp); } else { obj_extract_self(otmp); obfree(otmp, (struct obj *) 0); } obj->cknown = 0; } } if (costly && loss) { if (!insider) { You("caused %ld %s worth of damage!", loss, currency(loss)); make_angry_shk(shkp, x, y); } else { You("owe %s %ld %s for objects destroyed.", mon_nam(shkp), loss, currency(loss)); } } }
[ "void", "container_impact_dmg", "(", "struct", "obj", "*", "obj", ",", "xchar", "x", ",", "xchar", "y", ")", "{", "struct", "monst", "*", "shkp", ";", "struct", "obj", "*", "otmp", ",", "*", "otmp2", ";", "long", "loss", "=", "0L", ";", "boolean", "costly", ",", "insider", ",", "frominv", ";", "if", "(", "!", "Is_container", "(", "obj", ")", "||", "!", "Has_contents", "(", "obj", ")", "||", "Is_mbag", "(", "obj", ")", ")", "return", ";", "costly", "=", "(", "(", "shkp", "=", "shop_keeper", "(", "*", "in_rooms", "(", "x", ",", "y", ",", "SHOPBASE", ")", ")", ")", "&&", "costly_spot", "(", "x", ",", "y", ")", ")", ";", "insider", "=", "(", "*", "u", ".", "ushops", "&&", "inside_shop", "(", "u", ".", "ux", ",", "u", ".", "uy", ")", "&&", "*", "in_rooms", "(", "x", ",", "y", ",", "SHOPBASE", ")", "==", "*", "u", ".", "ushops", ")", ";", "frominv", "=", "(", "obj", "!=", "g", ".", "kickedobj", ")", ";", "for", "(", "otmp", "=", "obj", "->", "cobj", ";", "otmp", ";", "otmp", "=", "otmp2", ")", "{", "const", "char", "*", "result", "=", "(", "char", "*", ")", "0", ";", "otmp2", "=", "otmp", "->", "nobj", ";", "if", "(", "objects", "[", "otmp", "->", "otyp", "]", ".", "oc_material", "==", "GLASS", "&&", "otmp", "->", "oclass", "!=", "GEM_CLASS", "&&", "!", "obj_resists", "(", "otmp", ",", "33", ",", "100", ")", ")", "{", "result", "=", "\"", "\"", ";", "}", "else", "if", "(", "otmp", "->", "otyp", "==", "EGG", "&&", "!", "rn2", "(", "3", ")", ")", "{", "result", "=", "\"", "\"", ";", "}", "if", "(", "result", ")", "{", "if", "(", "otmp", "->", "otyp", "==", "MIRROR", ")", "change_luck", "(", "-2", ")", ";", "if", "(", "otmp", "->", "otyp", "==", "EGG", "&&", "otmp", "->", "spe", "&&", "otmp", "->", "corpsenm", ">=", "LOW_PM", ")", "change_luck", "(", "-1", ")", ";", "You_hear", "(", "\"", "\"", ",", "result", ")", ";", "if", "(", "costly", ")", "{", "if", "(", "frominv", "&&", "!", "otmp", "->", "unpaid", ")", "otmp", "->", "no_charge", "=", "1", ";", "loss", "+=", "stolen_value", "(", "otmp", ",", "x", ",", "y", ",", "(", "boolean", ")", "shkp", "->", "mpeaceful", ",", "TRUE", ")", ";", "}", "if", "(", "otmp", "->", "quan", ">", "1L", ")", "{", "useup", "(", "otmp", ")", ";", "}", "else", "{", "obj_extract_self", "(", "otmp", ")", ";", "obfree", "(", "otmp", ",", "(", "struct", "obj", "*", ")", "0", ")", ";", "}", "obj", "->", "cknown", "=", "0", ";", "}", "}", "if", "(", "costly", "&&", "loss", ")", "{", "if", "(", "!", "insider", ")", "{", "You", "(", "\"", "\"", ",", "loss", ",", "currency", "(", "loss", ")", ")", ";", "make_angry_shk", "(", "shkp", ",", "x", ",", "y", ")", ";", "}", "else", "{", "You", "(", "\"", "\"", ",", "mon_nam", "(", "shkp", ")", ",", "loss", ",", "currency", "(", "loss", ")", ")", ";", "}", "}", "}" ]
container is kicked, dropped, thrown or otherwise impacted by player.
[ "container", "is", "kicked", "dropped", "thrown", "or", "otherwise", "impacted", "by", "player", "." ]
[ "/* coordinates where object was before the impact, not after */", "/* only consider normal containers */", "/* if dropped or thrown, shop ownership flags are set on this obj */", "/* eggs laid by you. penalty is -1 per egg, max 5,\n * but it's always exactly 1 that breaks */", "/* contents of this container are no longer known */" ]
[ { "param": "obj", "type": "struct obj" }, { "param": "x", "type": "xchar" }, { "param": "y", "type": "xchar" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "struct obj", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "xchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "xchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
48199babac0224d391ef1384e95fd39c3905cb0a
aarestad/NetHack
src/dokick.c
[ "Intel", "X11" ]
C
kickstr
char
static char * kickstr(char *buf, const char *kickobjnam) { const char *what; if (*kickobjnam) what = kickobjnam; else if (g.maploc == &g.nowhere) what = "nothing"; else if (IS_DOOR(g.maploc->typ)) what = "a door"; else if (IS_TREE(g.maploc->typ)) what = "a tree"; else if (IS_STWALL(g.maploc->typ)) what = "a wall"; else if (IS_ROCK(g.maploc->typ)) what = "a rock"; else if (IS_THRONE(g.maploc->typ)) what = "a throne"; else if (IS_FOUNTAIN(g.maploc->typ)) what = "a fountain"; else if (IS_GRAVE(g.maploc->typ)) what = "a headstone"; else if (IS_SINK(g.maploc->typ)) what = "a sink"; else if (IS_ALTAR(g.maploc->typ)) what = "an altar"; else if (IS_DRAWBRIDGE(g.maploc->typ)) what = "a drawbridge"; else if (g.maploc->typ == STAIRS) what = "the stairs"; else if (g.maploc->typ == LADDER) what = "a ladder"; else if (g.maploc->typ == IRONBARS) what = "an iron bar"; else what = "something weird"; return strcat(strcpy(buf, "kicking "), what); }
/* cause of death if kicking kills kicker */
cause of death if kicking kills kicker
[ "cause", "of", "death", "if", "kicking", "kills", "kicker" ]
static char * kickstr(char *buf, const char *kickobjnam) { const char *what; if (*kickobjnam) what = kickobjnam; else if (g.maploc == &g.nowhere) what = "nothing"; else if (IS_DOOR(g.maploc->typ)) what = "a door"; else if (IS_TREE(g.maploc->typ)) what = "a tree"; else if (IS_STWALL(g.maploc->typ)) what = "a wall"; else if (IS_ROCK(g.maploc->typ)) what = "a rock"; else if (IS_THRONE(g.maploc->typ)) what = "a throne"; else if (IS_FOUNTAIN(g.maploc->typ)) what = "a fountain"; else if (IS_GRAVE(g.maploc->typ)) what = "a headstone"; else if (IS_SINK(g.maploc->typ)) what = "a sink"; else if (IS_ALTAR(g.maploc->typ)) what = "an altar"; else if (IS_DRAWBRIDGE(g.maploc->typ)) what = "a drawbridge"; else if (g.maploc->typ == STAIRS) what = "the stairs"; else if (g.maploc->typ == LADDER) what = "a ladder"; else if (g.maploc->typ == IRONBARS) what = "an iron bar"; else what = "something weird"; return strcat(strcpy(buf, "kicking "), what); }
[ "static", "char", "*", "kickstr", "(", "char", "*", "buf", ",", "const", "char", "*", "kickobjnam", ")", "{", "const", "char", "*", "what", ";", "if", "(", "*", "kickobjnam", ")", "what", "=", "kickobjnam", ";", "else", "if", "(", "g", ".", "maploc", "==", "&", "g", ".", "nowhere", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "IS_DOOR", "(", "g", ".", "maploc", "->", "typ", ")", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "IS_TREE", "(", "g", ".", "maploc", "->", "typ", ")", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "IS_STWALL", "(", "g", ".", "maploc", "->", "typ", ")", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "IS_ROCK", "(", "g", ".", "maploc", "->", "typ", ")", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "IS_THRONE", "(", "g", ".", "maploc", "->", "typ", ")", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "IS_FOUNTAIN", "(", "g", ".", "maploc", "->", "typ", ")", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "IS_GRAVE", "(", "g", ".", "maploc", "->", "typ", ")", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "IS_SINK", "(", "g", ".", "maploc", "->", "typ", ")", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "IS_ALTAR", "(", "g", ".", "maploc", "->", "typ", ")", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "IS_DRAWBRIDGE", "(", "g", ".", "maploc", "->", "typ", ")", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "g", ".", "maploc", "->", "typ", "==", "STAIRS", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "g", ".", "maploc", "->", "typ", "==", "LADDER", ")", "what", "=", "\"", "\"", ";", "else", "if", "(", "g", ".", "maploc", "->", "typ", "==", "IRONBARS", ")", "what", "=", "\"", "\"", ";", "else", "what", "=", "\"", "\"", ";", "return", "strcat", "(", "strcpy", "(", "buf", ",", "\"", "\"", ")", ",", "what", ")", ";", "}" ]
cause of death if kicking kills kicker
[ "cause", "of", "death", "if", "kicking", "kills", "kicker" ]
[]
[ { "param": "buf", "type": "char" }, { "param": "kickobjnam", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buf", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "kickobjnam", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
48199babac0224d391ef1384e95fd39c3905cb0a
aarestad/NetHack
src/dokick.c
[ "Intel", "X11" ]
C
impact_drop
void
void impact_drop(struct obj *missile, /* caused impact, won't drop itself */ xchar x, xchar y, /* location affected */ xchar dlev) /* if !0 send to dlev near player */ { schar toloc; register struct obj *obj, *obj2; register struct monst *shkp; long oct, dct, price, debit, robbed; boolean angry, costly, isrock; coord cc; if (!OBJ_AT(x, y)) return; toloc = down_gate(x, y); drop_to(&cc, toloc, x, y); if (!cc.y) return; if (dlev) { /* send objects next to player falling through trap door. * checked in obj_delivery(). */ toloc = MIGR_WITH_HERO; cc.y = dlev; } costly = costly_spot(x, y); price = debit = robbed = 0L; angry = FALSE; shkp = (struct monst *) 0; /* if 'costly', we must keep a record of ESHK(shkp) before * it undergoes changes through the calls to stolen_value. * the angry bit must be reset, if needed, in this fn, since * stolen_value is called under the 'silent' flag to avoid * unsavory pline repetitions. */ if (costly) { if ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0) { debit = ESHK(shkp)->debit; robbed = ESHK(shkp)->robbed; angry = !shkp->mpeaceful; } } isrock = (missile && missile->otyp == ROCK); oct = dct = 0L; for (obj = g.level.objects[x][y]; obj; obj = obj2) { obj2 = obj->nexthere; if (obj == missile) continue; /* number of objects in the pile */ oct += obj->quan; if (obj == uball || obj == uchain) continue; /* boulders can fall too, but rarely & never due to rocks */ if ((isrock && obj->otyp == BOULDER) || rn2(obj->otyp == BOULDER ? 30 : 3)) continue; obj_extract_self(obj); if (costly) { price += stolen_value(obj, x, y, (costly_spot(u.ux, u.uy) && index(u.urooms, *in_rooms(x, y, SHOPBASE))), TRUE); /* set obj->no_charge to 0 */ if (Has_contents(obj)) picked_container(obj); /* does the right thing */ if (obj->oclass != COIN_CLASS) obj->no_charge = 0; } add_to_migration(obj); obj->ox = cc.x; obj->oy = cc.y; obj->owornmask = (long) toloc; /* number of fallen objects */ dct += obj->quan; } if (dct && cansee(x, y)) { /* at least one object fell */ const char *what = (dct == 1L ? "object falls" : "objects fall"); if (missile) pline("From the impact, %sother %s.", dct == oct ? "the " : dct == 1L ? "an" : "", what); else if (oct == dct) pline("%s adjacent %s %s.", dct == 1L ? "The" : "All the", what, g.gate_str); else pline("%s adjacent %s %s.", dct == 1L ? "One of the" : "Some of the", dct == 1L ? "objects falls" : what, g.gate_str); } if (costly && shkp && price) { if (ESHK(shkp)->robbed > robbed) { You("removed %ld %s worth of goods!", price, currency(price)); if (cansee(shkp->mx, shkp->my)) { if (ESHK(shkp)->customer[0] == 0) (void) strncpy(ESHK(shkp)->customer, g.plname, PL_NSIZ); if (angry) pline("%s is infuriated!", Monnam(shkp)); else pline("\"%s, you are a thief!\"", g.plname); } else You_hear("a scream, \"Thief!\""); hot_pursuit(shkp); (void) angry_guards(FALSE); return; } if (ESHK(shkp)->debit > debit) { long amt = (ESHK(shkp)->debit - debit); You("owe %s %ld %s for goods lost.", Monnam(shkp), amt, currency(amt)); } } }
/* player or missile impacts location, causing objects to fall down */
player or missile impacts location, causing objects to fall down
[ "player", "or", "missile", "impacts", "location", "causing", "objects", "to", "fall", "down" ]
void impact_drop(struct obj *missile, xchar x, xchar y, xchar dlev) { schar toloc; register struct obj *obj, *obj2; register struct monst *shkp; long oct, dct, price, debit, robbed; boolean angry, costly, isrock; coord cc; if (!OBJ_AT(x, y)) return; toloc = down_gate(x, y); drop_to(&cc, toloc, x, y); if (!cc.y) return; if (dlev) { toloc = MIGR_WITH_HERO; cc.y = dlev; } costly = costly_spot(x, y); price = debit = robbed = 0L; angry = FALSE; shkp = (struct monst *) 0; if (costly) { if ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0) { debit = ESHK(shkp)->debit; robbed = ESHK(shkp)->robbed; angry = !shkp->mpeaceful; } } isrock = (missile && missile->otyp == ROCK); oct = dct = 0L; for (obj = g.level.objects[x][y]; obj; obj = obj2) { obj2 = obj->nexthere; if (obj == missile) continue; oct += obj->quan; if (obj == uball || obj == uchain) continue; if ((isrock && obj->otyp == BOULDER) || rn2(obj->otyp == BOULDER ? 30 : 3)) continue; obj_extract_self(obj); if (costly) { price += stolen_value(obj, x, y, (costly_spot(u.ux, u.uy) && index(u.urooms, *in_rooms(x, y, SHOPBASE))), TRUE); if (Has_contents(obj)) picked_container(obj); if (obj->oclass != COIN_CLASS) obj->no_charge = 0; } add_to_migration(obj); obj->ox = cc.x; obj->oy = cc.y; obj->owornmask = (long) toloc; dct += obj->quan; } if (dct && cansee(x, y)) { const char *what = (dct == 1L ? "object falls" : "objects fall"); if (missile) pline("From the impact, %sother %s.", dct == oct ? "the " : dct == 1L ? "an" : "", what); else if (oct == dct) pline("%s adjacent %s %s.", dct == 1L ? "The" : "All the", what, g.gate_str); else pline("%s adjacent %s %s.", dct == 1L ? "One of the" : "Some of the", dct == 1L ? "objects falls" : what, g.gate_str); } if (costly && shkp && price) { if (ESHK(shkp)->robbed > robbed) { You("removed %ld %s worth of goods!", price, currency(price)); if (cansee(shkp->mx, shkp->my)) { if (ESHK(shkp)->customer[0] == 0) (void) strncpy(ESHK(shkp)->customer, g.plname, PL_NSIZ); if (angry) pline("%s is infuriated!", Monnam(shkp)); else pline("\"%s, you are a thief!\"", g.plname); } else You_hear("a scream, \"Thief!\""); hot_pursuit(shkp); (void) angry_guards(FALSE); return; } if (ESHK(shkp)->debit > debit) { long amt = (ESHK(shkp)->debit - debit); You("owe %s %ld %s for goods lost.", Monnam(shkp), amt, currency(amt)); } } }
[ "void", "impact_drop", "(", "struct", "obj", "*", "missile", ",", "xchar", "x", ",", "xchar", "y", ",", "xchar", "dlev", ")", "{", "schar", "toloc", ";", "register", "struct", "obj", "*", "obj", ",", "*", "obj2", ";", "register", "struct", "monst", "*", "shkp", ";", "long", "oct", ",", "dct", ",", "price", ",", "debit", ",", "robbed", ";", "boolean", "angry", ",", "costly", ",", "isrock", ";", "coord", "cc", ";", "if", "(", "!", "OBJ_AT", "(", "x", ",", "y", ")", ")", "return", ";", "toloc", "=", "down_gate", "(", "x", ",", "y", ")", ";", "drop_to", "(", "&", "cc", ",", "toloc", ",", "x", ",", "y", ")", ";", "if", "(", "!", "cc", ".", "y", ")", "return", ";", "if", "(", "dlev", ")", "{", "toloc", "=", "MIGR_WITH_HERO", ";", "cc", ".", "y", "=", "dlev", ";", "}", "costly", "=", "costly_spot", "(", "x", ",", "y", ")", ";", "price", "=", "debit", "=", "robbed", "=", "0L", ";", "angry", "=", "FALSE", ";", "shkp", "=", "(", "struct", "monst", "*", ")", "0", ";", "if", "(", "costly", ")", "{", "if", "(", "(", "shkp", "=", "shop_keeper", "(", "*", "in_rooms", "(", "x", ",", "y", ",", "SHOPBASE", ")", ")", ")", "!=", "0", ")", "{", "debit", "=", "ESHK", "(", "shkp", ")", "->", "debit", ";", "robbed", "=", "ESHK", "(", "shkp", ")", "->", "robbed", ";", "angry", "=", "!", "shkp", "->", "mpeaceful", ";", "}", "}", "isrock", "=", "(", "missile", "&&", "missile", "->", "otyp", "==", "ROCK", ")", ";", "oct", "=", "dct", "=", "0L", ";", "for", "(", "obj", "=", "g", ".", "level", ".", "objects", "[", "x", "]", "[", "y", "]", ";", "obj", ";", "obj", "=", "obj2", ")", "{", "obj2", "=", "obj", "->", "nexthere", ";", "if", "(", "obj", "==", "missile", ")", "continue", ";", "oct", "+=", "obj", "->", "quan", ";", "if", "(", "obj", "==", "uball", "||", "obj", "==", "uchain", ")", "continue", ";", "if", "(", "(", "isrock", "&&", "obj", "->", "otyp", "==", "BOULDER", ")", "||", "rn2", "(", "obj", "->", "otyp", "==", "BOULDER", "?", "30", ":", "3", ")", ")", "continue", ";", "obj_extract_self", "(", "obj", ")", ";", "if", "(", "costly", ")", "{", "price", "+=", "stolen_value", "(", "obj", ",", "x", ",", "y", ",", "(", "costly_spot", "(", "u", ".", "ux", ",", "u", ".", "uy", ")", "&&", "index", "(", "u", ".", "urooms", ",", "*", "in_rooms", "(", "x", ",", "y", ",", "SHOPBASE", ")", ")", ")", ",", "TRUE", ")", ";", "if", "(", "Has_contents", "(", "obj", ")", ")", "picked_container", "(", "obj", ")", ";", "if", "(", "obj", "->", "oclass", "!=", "COIN_CLASS", ")", "obj", "->", "no_charge", "=", "0", ";", "}", "add_to_migration", "(", "obj", ")", ";", "obj", "->", "ox", "=", "cc", ".", "x", ";", "obj", "->", "oy", "=", "cc", ".", "y", ";", "obj", "->", "owornmask", "=", "(", "long", ")", "toloc", ";", "dct", "+=", "obj", "->", "quan", ";", "}", "if", "(", "dct", "&&", "cansee", "(", "x", ",", "y", ")", ")", "{", "const", "char", "*", "what", "=", "(", "dct", "==", "1L", "?", "\"", "\"", ":", "\"", "\"", ")", ";", "if", "(", "missile", ")", "pline", "(", "\"", "\"", ",", "dct", "==", "oct", "?", "\"", "\"", ":", "dct", "==", "1L", "?", "\"", "\"", ":", "\"", "\"", ",", "what", ")", ";", "else", "if", "(", "oct", "==", "dct", ")", "pline", "(", "\"", "\"", ",", "dct", "==", "1L", "?", "\"", "\"", ":", "\"", "\"", ",", "what", ",", "g", ".", "gate_str", ")", ";", "else", "pline", "(", "\"", "\"", ",", "dct", "==", "1L", "?", "\"", "\"", ":", "\"", "\"", ",", "dct", "==", "1L", "?", "\"", "\"", ":", "what", ",", "g", ".", "gate_str", ")", ";", "}", "if", "(", "costly", "&&", "shkp", "&&", "price", ")", "{", "if", "(", "ESHK", "(", "shkp", ")", "->", "robbed", ">", "robbed", ")", "{", "You", "(", "\"", "\"", ",", "price", ",", "currency", "(", "price", ")", ")", ";", "if", "(", "cansee", "(", "shkp", "->", "mx", ",", "shkp", "->", "my", ")", ")", "{", "if", "(", "ESHK", "(", "shkp", ")", "->", "customer", "[", "0", "]", "==", "0", ")", "(", "void", ")", "strncpy", "(", "ESHK", "(", "shkp", ")", "->", "customer", ",", "g", ".", "plname", ",", "PL_NSIZ", ")", ";", "if", "(", "angry", ")", "pline", "(", "\"", "\"", ",", "Monnam", "(", "shkp", ")", ")", ";", "else", "pline", "(", "\"", "\\\"", "\\\"", "\"", ",", "g", ".", "plname", ")", ";", "}", "else", "You_hear", "(", "\"", "\\\"", "\\\"", "\"", ")", ";", "hot_pursuit", "(", "shkp", ")", ";", "(", "void", ")", "angry_guards", "(", "FALSE", ")", ";", "return", ";", "}", "if", "(", "ESHK", "(", "shkp", ")", "->", "debit", ">", "debit", ")", "{", "long", "amt", "=", "(", "ESHK", "(", "shkp", ")", "->", "debit", "-", "debit", ")", ";", "You", "(", "\"", "\"", ",", "Monnam", "(", "shkp", ")", ",", "amt", ",", "currency", "(", "amt", ")", ")", ";", "}", "}", "}" ]
player or missile impacts location, causing objects to fall down
[ "player", "or", "missile", "impacts", "location", "causing", "objects", "to", "fall", "down" ]
[ "/* caused impact, won't drop itself */", "/* location affected */", "/* if !0 send to dlev near player */", "/* send objects next to player falling through trap door.\n * checked in obj_delivery().\n */", "/* if 'costly', we must keep a record of ESHK(shkp) before\n * it undergoes changes through the calls to stolen_value.\n * the angry bit must be reset, if needed, in this fn, since\n * stolen_value is called under the 'silent' flag to avoid\n * unsavory pline repetitions.\n */", "/* number of objects in the pile */", "/* boulders can fall too, but rarely & never due to rocks */", "/* set obj->no_charge to 0 */", "/* does the right thing */", "/* number of fallen objects */", "/* at least one object fell */" ]
[ { "param": "missile", "type": "struct obj" }, { "param": "x", "type": "xchar" }, { "param": "y", "type": "xchar" }, { "param": "dlev", "type": "xchar" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "missile", "type": "struct obj", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "xchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "xchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dlev", "type": "xchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
48199babac0224d391ef1384e95fd39c3905cb0a
aarestad/NetHack
src/dokick.c
[ "Intel", "X11" ]
C
ship_object
boolean
boolean ship_object(struct obj *otmp, xchar x, xchar y, boolean shop_floor_obj) { schar toloc; xchar ox, oy; coord cc; struct obj *obj; struct trap *t; boolean nodrop, unpaid, container, impact = FALSE, chainthere = FALSE; long n = 0L; if (!otmp) return FALSE; if ((toloc = down_gate(x, y)) == MIGR_NOWHERE) return FALSE; drop_to(&cc, toloc, x, y); if (!cc.y) return FALSE; /* objects other than attached iron ball always fall down ladder, but have a chance of staying otherwise */ nodrop = (otmp == uball) || (otmp == uchain) || (toloc != MIGR_LADDER_UP && rn2(3)); container = Has_contents(otmp); unpaid = is_unpaid(otmp); if (OBJ_AT(x, y)) { for (obj = g.level.objects[x][y]; obj; obj = obj->nexthere) { if (obj == uchain) chainthere = TRUE; else if (obj != otmp) n += obj->quan; } if (n) impact = TRUE; } /* boulders never fall through trap doors, but they might knock other things down before plugging the hole */ if (otmp->otyp == BOULDER && ((t = t_at(x, y)) != 0) && is_hole(t->ttyp)) { if (impact) impact_drop(otmp, x, y, 0); return FALSE; /* let caller finish the drop */ } if (cansee(x, y)) otransit_msg(otmp, nodrop, chainthere, n); if (nodrop) { if (impact) impact_drop(otmp, x, y, 0); return FALSE; } if (unpaid || shop_floor_obj) { if (unpaid) { (void) stolen_value(otmp, u.ux, u.uy, TRUE, FALSE); } else { ox = otmp->ox; oy = otmp->oy; (void) stolen_value( otmp, ox, oy, (costly_spot(u.ux, u.uy) && index(u.urooms, *in_rooms(ox, oy, SHOPBASE))), FALSE); } /* set otmp->no_charge to 0 */ if (container) picked_container(otmp); /* happens to do the right thing */ if (otmp->oclass != COIN_CLASS) otmp->no_charge = 0; } if (otmp->owornmask) remove_worn_item(otmp, TRUE); /* some things break rather than ship */ if (breaktest(otmp)) { const char *result; if (objects[otmp->otyp].oc_material == GLASS || otmp->otyp == EXPENSIVE_CAMERA) { if (otmp->otyp == MIRROR) change_luck(-2); result = "crash"; } else { /* penalty for breaking eggs laid by you */ if (otmp->otyp == EGG && otmp->spe && otmp->corpsenm >= LOW_PM) change_luck((schar) -min(otmp->quan, 5L)); result = "splat"; } You_hear("a muffled %s.", result); obj_extract_self(otmp); obfree(otmp, (struct obj *) 0); return TRUE; } add_to_migration(otmp); otmp->ox = cc.x; otmp->oy = cc.y; otmp->owornmask = (long) toloc; /* boulder from rolling boulder trap, no longer part of the trap */ if (otmp->otyp == BOULDER) otmp->otrapped = 0; if (impact) { /* the objs impacted may be in a shop other than * the one in which the hero is located. another * check for a shk is made in impact_drop. it is, e.g., * possible to kick/throw an object belonging to one * shop into another shop through a gap in the wall, * and cause objects belonging to the other shop to * fall down a trap door--thereby getting two shopkeepers * angry at the hero in one shot. */ impact_drop(otmp, x, y, 0); newsym(x, y); } return TRUE; }
/* NOTE: ship_object assumes otmp was FREED from fobj or invent. * <x,y> is the point of drop. otmp is _not_ an <x,y> resident: * otmp is either a kicked, dropped, or thrown object. */
ship_object assumes otmp was FREED from fobj or invent. is the point of drop. otmp is _not_ an resident: otmp is either a kicked, dropped, or thrown object.
[ "ship_object", "assumes", "otmp", "was", "FREED", "from", "fobj", "or", "invent", ".", "is", "the", "point", "of", "drop", ".", "otmp", "is", "_not_", "an", "resident", ":", "otmp", "is", "either", "a", "kicked", "dropped", "or", "thrown", "object", "." ]
boolean ship_object(struct obj *otmp, xchar x, xchar y, boolean shop_floor_obj) { schar toloc; xchar ox, oy; coord cc; struct obj *obj; struct trap *t; boolean nodrop, unpaid, container, impact = FALSE, chainthere = FALSE; long n = 0L; if (!otmp) return FALSE; if ((toloc = down_gate(x, y)) == MIGR_NOWHERE) return FALSE; drop_to(&cc, toloc, x, y); if (!cc.y) return FALSE; nodrop = (otmp == uball) || (otmp == uchain) || (toloc != MIGR_LADDER_UP && rn2(3)); container = Has_contents(otmp); unpaid = is_unpaid(otmp); if (OBJ_AT(x, y)) { for (obj = g.level.objects[x][y]; obj; obj = obj->nexthere) { if (obj == uchain) chainthere = TRUE; else if (obj != otmp) n += obj->quan; } if (n) impact = TRUE; } if (otmp->otyp == BOULDER && ((t = t_at(x, y)) != 0) && is_hole(t->ttyp)) { if (impact) impact_drop(otmp, x, y, 0); return FALSE; } if (cansee(x, y)) otransit_msg(otmp, nodrop, chainthere, n); if (nodrop) { if (impact) impact_drop(otmp, x, y, 0); return FALSE; } if (unpaid || shop_floor_obj) { if (unpaid) { (void) stolen_value(otmp, u.ux, u.uy, TRUE, FALSE); } else { ox = otmp->ox; oy = otmp->oy; (void) stolen_value( otmp, ox, oy, (costly_spot(u.ux, u.uy) && index(u.urooms, *in_rooms(ox, oy, SHOPBASE))), FALSE); } if (container) picked_container(otmp); if (otmp->oclass != COIN_CLASS) otmp->no_charge = 0; } if (otmp->owornmask) remove_worn_item(otmp, TRUE); if (breaktest(otmp)) { const char *result; if (objects[otmp->otyp].oc_material == GLASS || otmp->otyp == EXPENSIVE_CAMERA) { if (otmp->otyp == MIRROR) change_luck(-2); result = "crash"; } else { if (otmp->otyp == EGG && otmp->spe && otmp->corpsenm >= LOW_PM) change_luck((schar) -min(otmp->quan, 5L)); result = "splat"; } You_hear("a muffled %s.", result); obj_extract_self(otmp); obfree(otmp, (struct obj *) 0); return TRUE; } add_to_migration(otmp); otmp->ox = cc.x; otmp->oy = cc.y; otmp->owornmask = (long) toloc; if (otmp->otyp == BOULDER) otmp->otrapped = 0; if (impact) { impact_drop(otmp, x, y, 0); newsym(x, y); } return TRUE; }
[ "boolean", "ship_object", "(", "struct", "obj", "*", "otmp", ",", "xchar", "x", ",", "xchar", "y", ",", "boolean", "shop_floor_obj", ")", "{", "schar", "toloc", ";", "xchar", "ox", ",", "oy", ";", "coord", "cc", ";", "struct", "obj", "*", "obj", ";", "struct", "trap", "*", "t", ";", "boolean", "nodrop", ",", "unpaid", ",", "container", ",", "impact", "=", "FALSE", ",", "chainthere", "=", "FALSE", ";", "long", "n", "=", "0L", ";", "if", "(", "!", "otmp", ")", "return", "FALSE", ";", "if", "(", "(", "toloc", "=", "down_gate", "(", "x", ",", "y", ")", ")", "==", "MIGR_NOWHERE", ")", "return", "FALSE", ";", "drop_to", "(", "&", "cc", ",", "toloc", ",", "x", ",", "y", ")", ";", "if", "(", "!", "cc", ".", "y", ")", "return", "FALSE", ";", "nodrop", "=", "(", "otmp", "==", "uball", ")", "||", "(", "otmp", "==", "uchain", ")", "||", "(", "toloc", "!=", "MIGR_LADDER_UP", "&&", "rn2", "(", "3", ")", ")", ";", "container", "=", "Has_contents", "(", "otmp", ")", ";", "unpaid", "=", "is_unpaid", "(", "otmp", ")", ";", "if", "(", "OBJ_AT", "(", "x", ",", "y", ")", ")", "{", "for", "(", "obj", "=", "g", ".", "level", ".", "objects", "[", "x", "]", "[", "y", "]", ";", "obj", ";", "obj", "=", "obj", "->", "nexthere", ")", "{", "if", "(", "obj", "==", "uchain", ")", "chainthere", "=", "TRUE", ";", "else", "if", "(", "obj", "!=", "otmp", ")", "n", "+=", "obj", "->", "quan", ";", "}", "if", "(", "n", ")", "impact", "=", "TRUE", ";", "}", "if", "(", "otmp", "->", "otyp", "==", "BOULDER", "&&", "(", "(", "t", "=", "t_at", "(", "x", ",", "y", ")", ")", "!=", "0", ")", "&&", "is_hole", "(", "t", "->", "ttyp", ")", ")", "{", "if", "(", "impact", ")", "impact_drop", "(", "otmp", ",", "x", ",", "y", ",", "0", ")", ";", "return", "FALSE", ";", "}", "if", "(", "cansee", "(", "x", ",", "y", ")", ")", "otransit_msg", "(", "otmp", ",", "nodrop", ",", "chainthere", ",", "n", ")", ";", "if", "(", "nodrop", ")", "{", "if", "(", "impact", ")", "impact_drop", "(", "otmp", ",", "x", ",", "y", ",", "0", ")", ";", "return", "FALSE", ";", "}", "if", "(", "unpaid", "||", "shop_floor_obj", ")", "{", "if", "(", "unpaid", ")", "{", "(", "void", ")", "stolen_value", "(", "otmp", ",", "u", ".", "ux", ",", "u", ".", "uy", ",", "TRUE", ",", "FALSE", ")", ";", "}", "else", "{", "ox", "=", "otmp", "->", "ox", ";", "oy", "=", "otmp", "->", "oy", ";", "(", "void", ")", "stolen_value", "(", "otmp", ",", "ox", ",", "oy", ",", "(", "costly_spot", "(", "u", ".", "ux", ",", "u", ".", "uy", ")", "&&", "index", "(", "u", ".", "urooms", ",", "*", "in_rooms", "(", "ox", ",", "oy", ",", "SHOPBASE", ")", ")", ")", ",", "FALSE", ")", ";", "}", "if", "(", "container", ")", "picked_container", "(", "otmp", ")", ";", "if", "(", "otmp", "->", "oclass", "!=", "COIN_CLASS", ")", "otmp", "->", "no_charge", "=", "0", ";", "}", "if", "(", "otmp", "->", "owornmask", ")", "remove_worn_item", "(", "otmp", ",", "TRUE", ")", ";", "if", "(", "breaktest", "(", "otmp", ")", ")", "{", "const", "char", "*", "result", ";", "if", "(", "objects", "[", "otmp", "->", "otyp", "]", ".", "oc_material", "==", "GLASS", "||", "otmp", "->", "otyp", "==", "EXPENSIVE_CAMERA", ")", "{", "if", "(", "otmp", "->", "otyp", "==", "MIRROR", ")", "change_luck", "(", "-2", ")", ";", "result", "=", "\"", "\"", ";", "}", "else", "{", "if", "(", "otmp", "->", "otyp", "==", "EGG", "&&", "otmp", "->", "spe", "&&", "otmp", "->", "corpsenm", ">=", "LOW_PM", ")", "change_luck", "(", "(", "schar", ")", "-", "min", "(", "otmp", "->", "quan", ",", "5L", ")", ")", ";", "result", "=", "\"", "\"", ";", "}", "You_hear", "(", "\"", "\"", ",", "result", ")", ";", "obj_extract_self", "(", "otmp", ")", ";", "obfree", "(", "otmp", ",", "(", "struct", "obj", "*", ")", "0", ")", ";", "return", "TRUE", ";", "}", "add_to_migration", "(", "otmp", ")", ";", "otmp", "->", "ox", "=", "cc", ".", "x", ";", "otmp", "->", "oy", "=", "cc", ".", "y", ";", "otmp", "->", "owornmask", "=", "(", "long", ")", "toloc", ";", "if", "(", "otmp", "->", "otyp", "==", "BOULDER", ")", "otmp", "->", "otrapped", "=", "0", ";", "if", "(", "impact", ")", "{", "impact_drop", "(", "otmp", ",", "x", ",", "y", ",", "0", ")", ";", "newsym", "(", "x", ",", "y", ")", ";", "}", "return", "TRUE", ";", "}" ]
NOTE: ship_object assumes otmp was FREED from fobj or invent.
[ "NOTE", ":", "ship_object", "assumes", "otmp", "was", "FREED", "from", "fobj", "or", "invent", "." ]
[ "/* objects other than attached iron ball always fall down ladder,\n but have a chance of staying otherwise */", "/* boulders never fall through trap doors, but they might knock\n other things down before plugging the hole */", "/* let caller finish the drop */", "/* set otmp->no_charge to 0 */", "/* happens to do the right thing */", "/* some things break rather than ship */", "/* penalty for breaking eggs laid by you */", "/* boulder from rolling boulder trap, no longer part of the trap */", "/* the objs impacted may be in a shop other than\n * the one in which the hero is located. another\n * check for a shk is made in impact_drop. it is, e.g.,\n * possible to kick/throw an object belonging to one\n * shop into another shop through a gap in the wall,\n * and cause objects belonging to the other shop to\n * fall down a trap door--thereby getting two shopkeepers\n * angry at the hero in one shot.\n */" ]
[ { "param": "otmp", "type": "struct obj" }, { "param": "x", "type": "xchar" }, { "param": "y", "type": "xchar" }, { "param": "shop_floor_obj", "type": "boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "otmp", "type": "struct obj", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "xchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "xchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "shop_floor_obj", "type": "boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
48199babac0224d391ef1384e95fd39c3905cb0a
aarestad/NetHack
src/dokick.c
[ "Intel", "X11" ]
C
down_gate
schar
schar down_gate(xchar x, xchar y) { struct trap *ttmp; stairway *stway = stairway_at(x, y); g.gate_str = 0; /* this matches the player restriction in goto_level() */ if (on_level(&u.uz, &qstart_level) && !ok_to_quest()) { return MIGR_NOWHERE; } if (stway && !stway->up && !stway->isladder) { g.gate_str = "down the stairs"; return (stway->tolev.dnum == u.uz.dnum) ? MIGR_STAIRS_UP : MIGR_SSTAIRS; } if (stway && !stway->up && stway->isladder) { g.gate_str = "down the ladder"; return MIGR_LADDER_UP; } /* hole will always be flagged as seen; trap drop might or might not */ if ((ttmp = t_at(x, y)) != 0 && ttmp->tseen && is_hole(ttmp->ttyp)) { g.gate_str = (ttmp->ttyp == TRAPDOOR) ? "through the trap door" : "through the hole"; return MIGR_RANDOM; } return MIGR_NOWHERE; }
/* migration destination for objects which fall down to next level */
migration destination for objects which fall down to next level
[ "migration", "destination", "for", "objects", "which", "fall", "down", "to", "next", "level" ]
schar down_gate(xchar x, xchar y) { struct trap *ttmp; stairway *stway = stairway_at(x, y); g.gate_str = 0; if (on_level(&u.uz, &qstart_level) && !ok_to_quest()) { return MIGR_NOWHERE; } if (stway && !stway->up && !stway->isladder) { g.gate_str = "down the stairs"; return (stway->tolev.dnum == u.uz.dnum) ? MIGR_STAIRS_UP : MIGR_SSTAIRS; } if (stway && !stway->up && stway->isladder) { g.gate_str = "down the ladder"; return MIGR_LADDER_UP; } if ((ttmp = t_at(x, y)) != 0 && ttmp->tseen && is_hole(ttmp->ttyp)) { g.gate_str = (ttmp->ttyp == TRAPDOOR) ? "through the trap door" : "through the hole"; return MIGR_RANDOM; } return MIGR_NOWHERE; }
[ "schar", "down_gate", "(", "xchar", "x", ",", "xchar", "y", ")", "{", "struct", "trap", "*", "ttmp", ";", "stairway", "*", "stway", "=", "stairway_at", "(", "x", ",", "y", ")", ";", "g", ".", "gate_str", "=", "0", ";", "if", "(", "on_level", "(", "&", "u", ".", "uz", ",", "&", "qstart_level", ")", "&&", "!", "ok_to_quest", "(", ")", ")", "{", "return", "MIGR_NOWHERE", ";", "}", "if", "(", "stway", "&&", "!", "stway", "->", "up", "&&", "!", "stway", "->", "isladder", ")", "{", "g", ".", "gate_str", "=", "\"", "\"", ";", "return", "(", "stway", "->", "tolev", ".", "dnum", "==", "u", ".", "uz", ".", "dnum", ")", "?", "MIGR_STAIRS_UP", ":", "MIGR_SSTAIRS", ";", "}", "if", "(", "stway", "&&", "!", "stway", "->", "up", "&&", "stway", "->", "isladder", ")", "{", "g", ".", "gate_str", "=", "\"", "\"", ";", "return", "MIGR_LADDER_UP", ";", "}", "if", "(", "(", "ttmp", "=", "t_at", "(", "x", ",", "y", ")", ")", "!=", "0", "&&", "ttmp", "->", "tseen", "&&", "is_hole", "(", "ttmp", "->", "ttyp", ")", ")", "{", "g", ".", "gate_str", "=", "(", "ttmp", "->", "ttyp", "==", "TRAPDOOR", ")", "?", "\"", "\"", ":", "\"", "\"", ";", "return", "MIGR_RANDOM", ";", "}", "return", "MIGR_NOWHERE", ";", "}" ]
migration destination for objects which fall down to next level
[ "migration", "destination", "for", "objects", "which", "fall", "down", "to", "next", "level" ]
[ "/* this matches the player restriction in goto_level() */", "/* hole will always be flagged as seen; trap drop might or might not */" ]
[ { "param": "x", "type": "xchar" }, { "param": "y", "type": "xchar" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": "xchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "xchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b53be961a2b23f31483167af103320c3a3e89ae
IntwineConnect/cta2045-wifi-modules
Aztec/MicroChip/TCPIP_Stack/WiFi/WFConsole.c
[ "BSD-3-Clause" ]
C
WFConsoleProcess
void
void WFConsoleProcess(void) { //UINT8 *pStart = &(cmdline[0]); UINT16 rc; INT8 c; static INT8 escape_sequence[kWFMaxInputEscapeSequence]; static INT8 esc_seq_index; // if this state machine has been disabled if (g_ConsoleContext.bStateMachineLoop == FALSE) { return; } // if a command was entered that is application=specific if (g_ConsoleContext.appConsoleMsgRx == TRUE) { return; // wait until app done before processing further characters } // if no character(s) received if ( (rc = DataRdyUART() ) == 0u ) { return; } // get the character c = (INT8) ReadUART(); // if this is the very first character received by this state machine if (g_ConsoleContext.firstChar == FALSE) { Output_Monitor_Hdr(); g_ConsoleContext.firstChar = TRUE; } switch( GET_RX_STATE() ) { //------------------------------------------ case kSTWaitForChar: //------------------------------------------ // if a 'normal' printable character if (isPrintableCharacter(c)) { InsertCharacter(c); } // else if Delete key else if (c == kWFDelete) { Delete(); } // else if Backspace key else if (c == (INT8)kWFBackspace) { Backspace(); } // else if Enter key else if (c == kWFEnter) { Enter(); } // else if Escape key else if (c == kWFEscape) { /* zero out escape buffer, init with ESC */ memset(escape_sequence, 0x00, sizeof(escape_sequence)); escape_sequence[0] = kWFEscape; esc_seq_index = 1; SET_RX_STATE(kSTWaitForEscSeqSecondChar); } // else if Ctrl C else if (c == kWFCtrl_C) { OutputCommandPrompt(); } else { // Enter(); } break; //------------------------------------------ case kSTWaitForEscSeqSecondChar: //------------------------------------------ /* if an arrow key, home, or end key (which is all that this state machine handles) */ if (c == 0x5b) { escape_sequence[1] = c; SET_RX_STATE(kSTWaitForEscSeqThirdChar); } // else if user pressed escape followed by any printable character else if (isPrintableCharacter(c)) { InsertCharacter(c); SET_RX_STATE(kSTWaitForChar); } // start this command line over else // anything else { OutputCommandPrompt(); SET_RX_STATE(kSTWaitForChar); } break; //------------------------------------------ case kSTWaitForEscSeqThirdChar: //------------------------------------------ escape_sequence[2] = c; ProcessEscapeSequence(escape_sequence); SET_RX_STATE(kSTWaitForChar); break; } // end switch }
/***************************************************************************** * FUNCTION: WFConsoleProcess * * RETURNS: None * * PARAMS: None * * NOTES: State machine called from main loop of app. Handles serial input. * *****************************************************************************/
None State machine called from main loop of app. Handles serial input.
[ "None", "State", "machine", "called", "from", "main", "loop", "of", "app", ".", "Handles", "serial", "input", "." ]
void WFConsoleProcess(void) { UINT16 rc; INT8 c; static INT8 escape_sequence[kWFMaxInputEscapeSequence]; static INT8 esc_seq_index; if (g_ConsoleContext.bStateMachineLoop == FALSE) { return; } if (g_ConsoleContext.appConsoleMsgRx == TRUE) { return; } if ( (rc = DataRdyUART() ) == 0u ) { return; } c = (INT8) ReadUART(); if (g_ConsoleContext.firstChar == FALSE) { Output_Monitor_Hdr(); g_ConsoleContext.firstChar = TRUE; } switch( GET_RX_STATE() ) { case kSTWaitForChar: if (isPrintableCharacter(c)) { InsertCharacter(c); } else if (c == kWFDelete) { Delete(); } else if (c == (INT8)kWFBackspace) { Backspace(); } else if (c == kWFEnter) { Enter(); } else if (c == kWFEscape) { memset(escape_sequence, 0x00, sizeof(escape_sequence)); escape_sequence[0] = kWFEscape; esc_seq_index = 1; SET_RX_STATE(kSTWaitForEscSeqSecondChar); } else if (c == kWFCtrl_C) { OutputCommandPrompt(); } else { } break; case kSTWaitForEscSeqSecondChar: if (c == 0x5b) { escape_sequence[1] = c; SET_RX_STATE(kSTWaitForEscSeqThirdChar); } else if (isPrintableCharacter(c)) { InsertCharacter(c); SET_RX_STATE(kSTWaitForChar); } else { OutputCommandPrompt(); SET_RX_STATE(kSTWaitForChar); } break; case kSTWaitForEscSeqThirdChar: escape_sequence[2] = c; ProcessEscapeSequence(escape_sequence); SET_RX_STATE(kSTWaitForChar); break; } }
[ "void", "WFConsoleProcess", "(", "void", ")", "{", "UINT16", "rc", ";", "INT8", "c", ";", "static", "INT8", "escape_sequence", "[", "kWFMaxInputEscapeSequence", "]", ";", "static", "INT8", "esc_seq_index", ";", "if", "(", "g_ConsoleContext", ".", "bStateMachineLoop", "==", "FALSE", ")", "{", "return", ";", "}", "if", "(", "g_ConsoleContext", ".", "appConsoleMsgRx", "==", "TRUE", ")", "{", "return", ";", "}", "if", "(", "(", "rc", "=", "DataRdyUART", "(", ")", ")", "==", "0u", ")", "{", "return", ";", "}", "c", "=", "(", "INT8", ")", "ReadUART", "(", ")", ";", "if", "(", "g_ConsoleContext", ".", "firstChar", "==", "FALSE", ")", "{", "Output_Monitor_Hdr", "(", ")", ";", "g_ConsoleContext", ".", "firstChar", "=", "TRUE", ";", "}", "switch", "(", "GET_RX_STATE", "(", ")", ")", "{", "case", "kSTWaitForChar", ":", "if", "(", "isPrintableCharacter", "(", "c", ")", ")", "{", "InsertCharacter", "(", "c", ")", ";", "}", "else", "if", "(", "c", "==", "kWFDelete", ")", "{", "Delete", "(", ")", ";", "}", "else", "if", "(", "c", "==", "(", "INT8", ")", "kWFBackspace", ")", "{", "Backspace", "(", ")", ";", "}", "else", "if", "(", "c", "==", "kWFEnter", ")", "{", "Enter", "(", ")", ";", "}", "else", "if", "(", "c", "==", "kWFEscape", ")", "{", "memset", "(", "escape_sequence", ",", "0x00", ",", "sizeof", "(", "escape_sequence", ")", ")", ";", "escape_sequence", "[", "0", "]", "=", "kWFEscape", ";", "esc_seq_index", "=", "1", ";", "SET_RX_STATE", "(", "kSTWaitForEscSeqSecondChar", ")", ";", "}", "else", "if", "(", "c", "==", "kWFCtrl_C", ")", "{", "OutputCommandPrompt", "(", ")", ";", "}", "else", "{", "}", "break", ";", "case", "kSTWaitForEscSeqSecondChar", ":", "if", "(", "c", "==", "0x5b", ")", "{", "escape_sequence", "[", "1", "]", "=", "c", ";", "SET_RX_STATE", "(", "kSTWaitForEscSeqThirdChar", ")", ";", "}", "else", "if", "(", "isPrintableCharacter", "(", "c", ")", ")", "{", "InsertCharacter", "(", "c", ")", ";", "SET_RX_STATE", "(", "kSTWaitForChar", ")", ";", "}", "else", "{", "OutputCommandPrompt", "(", ")", ";", "SET_RX_STATE", "(", "kSTWaitForChar", ")", ";", "}", "break", ";", "case", "kSTWaitForEscSeqThirdChar", ":", "escape_sequence", "[", "2", "]", "=", "c", ";", "ProcessEscapeSequence", "(", "escape_sequence", ")", ";", "SET_RX_STATE", "(", "kSTWaitForChar", ")", ";", "break", ";", "}", "}" ]
FUNCTION: WFConsoleProcess RETURNS: None
[ "FUNCTION", ":", "WFConsoleProcess", "RETURNS", ":", "None" ]
[ "//UINT8 *pStart = &(cmdline[0]);", "// if this state machine has been disabled", "// if a command was entered that is application=specific", "// wait until app done before processing further characters", "// if no character(s) received", "// get the character", "// if this is the very first character received by this state machine", "//------------------------------------------", "//------------------------------------------", "// if a 'normal' printable character", "// else if Delete key", "// else if Backspace key", "// else if Enter key", "// else if Escape key", "/* zero out escape buffer, init with ESC */", "// else if Ctrl C", "// Enter();", "//------------------------------------------", "//------------------------------------------", "/* if an arrow key, home, or end key (which is all that this state machine handles) */", "// else if user pressed escape followed by any printable character", "// start this command line over", "// anything else", "//------------------------------------------", "//------------------------------------------", "// end switch" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
6b53be961a2b23f31483167af103320c3a3e89ae
IntwineConnect/cta2045-wifi-modules
Aztec/MicroChip/TCPIP_Stack/WiFi/WFConsole.c
[ "BSD-3-Clause" ]
C
OutputLine
void
static void OutputLine(INT8 lineChar, UINT8 count) { UINT8 i; for (i = 0; i < count; ++i) { while(BusyUART()); putcUART(lineChar); } putrsUART("\n\r"); }
/*= OutputLine =============================================================== Purpose: Outputs a line of the specified character Inputs: lineChar -- character the comprises the line count -- number of characters in the line Returns: None ============================================================================*/
OutputLine Purpose: Outputs a line of the specified character - character the comprises the line count -- number of characters in the line None
[ "OutputLine", "Purpose", ":", "Outputs", "a", "line", "of", "the", "specified", "character", "-", "character", "the", "comprises", "the", "line", "count", "--", "number", "of", "characters", "in", "the", "line", "None" ]
static void OutputLine(INT8 lineChar, UINT8 count) { UINT8 i; for (i = 0; i < count; ++i) { while(BusyUART()); putcUART(lineChar); } putrsUART("\n\r"); }
[ "static", "void", "OutputLine", "(", "INT8", "lineChar", ",", "UINT8", "count", ")", "{", "UINT8", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "count", ";", "++", "i", ")", "{", "while", "(", "BusyUART", "(", ")", ")", ";", "putcUART", "(", "lineChar", ")", ";", "}", "putrsUART", "(", "\"", "\\n", "\\r", "\"", ")", ";", "}" ]
OutputLine Purpose: Outputs a line of the specified character
[ "OutputLine", "Purpose", ":", "Outputs", "a", "line", "of", "the", "specified", "character" ]
[]
[ { "param": "lineChar", "type": "INT8" }, { "param": "count", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lineChar", "type": "INT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b53be961a2b23f31483167af103320c3a3e89ae
IntwineConnect/cta2045-wifi-modules
Aztec/MicroChip/TCPIP_Stack/WiFi/WFConsole.c
[ "BSD-3-Clause" ]
C
isPrintableCharacter
BOOL
static BOOL isPrintableCharacter(INT8 c) { if ( ((isalpha(c)) || (isdigit(c)) || (isspace(c)) || (ispunct(c))) && (c != (INT8)kWFEnter) && (c != (INT8)kWFTab) ) { return TRUE; } else { return FALSE; } }
/*= is_Printable_Character =================================================== Purpose: Determines if the input character can be output to the screen Inputs: c -- char to test Returns: True if printable, else False ============================================================================*/
is_Printable_Character Purpose: Determines if the input character can be output to the screen c -- char to test True if printable, else False
[ "is_Printable_Character", "Purpose", ":", "Determines", "if", "the", "input", "character", "can", "be", "output", "to", "the", "screen", "c", "--", "char", "to", "test", "True", "if", "printable", "else", "False" ]
static BOOL isPrintableCharacter(INT8 c) { if ( ((isalpha(c)) || (isdigit(c)) || (isspace(c)) || (ispunct(c))) && (c != (INT8)kWFEnter) && (c != (INT8)kWFTab) ) { return TRUE; } else { return FALSE; } }
[ "static", "BOOL", "isPrintableCharacter", "(", "INT8", "c", ")", "{", "if", "(", "(", "(", "isalpha", "(", "c", ")", ")", "||", "(", "isdigit", "(", "c", ")", ")", "||", "(", "isspace", "(", "c", ")", ")", "||", "(", "ispunct", "(", "c", ")", ")", ")", "&&", "(", "c", "!=", "(", "INT8", ")", "kWFEnter", ")", "&&", "(", "c", "!=", "(", "INT8", ")", "kWFTab", ")", ")", "{", "return", "TRUE", ";", "}", "else", "{", "return", "FALSE", ";", "}", "}" ]
is_Printable_Character Purpose: Determines if the input character can be output to the screen
[ "is_Printable_Character", "Purpose", ":", "Determines", "if", "the", "input", "character", "can", "be", "output", "to", "the", "screen" ]
[]
[ { "param": "c", "type": "INT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "c", "type": "INT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }