target
int64
0
1
func
stringlengths
7
484k
func_no_comments
stringlengths
7
484k
idx
int64
1
368k
0
static void qdev_print_props ( Monitor * mon , DeviceState * dev , Property * props , const char * prefix , int indent ) { char buf [ 64 ] ; if ( ! props ) return ; while ( props -> name ) { if ( props -> info -> print ) { props -> info -> print ( dev , props , buf , sizeof ( buf ) ) ; qdev_printf ( "%s-prop: %s = %s\n" , prefix , props -> name , buf ) ; } props ++ ; } }
static void qdev_print_props ( Monitor * mon , DeviceState * dev , Property * props , const char * prefix , int indent ) { char buf [ 64 ] ; if ( ! props ) return ; while ( props -> name ) { if ( props -> info -> print ) { props -> info -> print ( dev , props , buf , sizeof ( buf ) ) ; qdev_printf ( "%s-prop: %s = %s\n" , prefix , props -> name , buf ) ; } props ++ ; } }
394
1
int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, int len, int write, int force, struct page **pages, struct vm_area_struct **vmas) { int i; unsigned int vm_flags; if (len <= 0) return 0; /* * Require read or write permissions. * If 'force' is set, we only require the "MAY" flags. */ vm_flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD); vm_flags &= force ? (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE); i = 0; do { struct vm_area_struct *vma; unsigned int foll_flags; vma = find_extend_vma(mm, start); if (!vma && in_gate_area(tsk, start)) { unsigned long pg = start & PAGE_MASK; struct vm_area_struct *gate_vma = get_gate_vma(tsk); pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t *pte; if (write) /* user gate pages are read-only */ return i ? : -EFAULT; if (pg > TASK_SIZE) pgd = pgd_offset_k(pg); else pgd = pgd_offset_gate(mm, pg); BUG_ON(pgd_none(*pgd)); pud = pud_offset(pgd, pg); BUG_ON(pud_none(*pud)); pmd = pmd_offset(pud, pg); if (pmd_none(*pmd)) return i ? : -EFAULT; pte = pte_offset_map(pmd, pg); if (pte_none(*pte)) { pte_unmap(pte); return i ? : -EFAULT; } if (pages) { struct page *page = vm_normal_page(gate_vma, start, *pte); pages[i] = page; if (page) get_page(page); } pte_unmap(pte); if (vmas) vmas[i] = gate_vma; i++; start += PAGE_SIZE; len--; continue; } if (!vma || (vma->vm_flags & (VM_IO | VM_PFNMAP)) || !(vm_flags & vma->vm_flags)) return i ? : -EFAULT; if (is_vm_hugetlb_page(vma)) { i = follow_hugetlb_page(mm, vma, pages, vmas, &start, &len, i, write); continue; } foll_flags = FOLL_TOUCH; if (pages) foll_flags |= FOLL_GET; if (!write && !(vma->vm_flags & VM_LOCKED) && (!vma->vm_ops || !vma->vm_ops->fault)) foll_flags |= FOLL_ANON; do { struct page *page; /* * If tsk is ooming, cut off its access to large memory * allocations. It has a pending SIGKILL, but it can't * be processed until returning to user space. */ if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE))) return -ENOMEM; if (write) foll_flags |= FOLL_WRITE; cond_resched(); while (!(page = follow_page(vma, start, foll_flags))) { int ret; ret = handle_mm_fault(mm, vma, start, foll_flags & FOLL_WRITE); if (ret & VM_FAULT_ERROR) { if (ret & VM_FAULT_OOM) return i ? i : -ENOMEM; else if (ret & VM_FAULT_SIGBUS) return i ? i : -EFAULT; BUG(); } if (ret & VM_FAULT_MAJOR) tsk->maj_flt++; else tsk->min_flt++; /* * The VM_FAULT_WRITE bit tells us that * do_wp_page has broken COW when necessary, * even if maybe_mkwrite decided not to set * pte_write. We can thus safely do subsequent * page lookups as if they were reads. */ if (ret & VM_FAULT_WRITE) foll_flags &= ~FOLL_WRITE; cond_resched(); } if (pages) { pages[i] = page; flush_anon_page(vma, page, start); flush_dcache_page(page); } if (vmas) vmas[i] = vma; i++; start += PAGE_SIZE; len--; } while (len && start < vma->vm_end); } while (len); return i; }
int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, int len, int write, int force, struct page **pages, struct vm_area_struct **vmas) { int i; unsigned int vm_flags; if (len <= 0) return 0; vm_flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD); vm_flags &= force ? (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE); i = 0; do { struct vm_area_struct *vma; unsigned int foll_flags; vma = find_extend_vma(mm, start); if (!vma && in_gate_area(tsk, start)) { unsigned long pg = start & PAGE_MASK; struct vm_area_struct *gate_vma = get_gate_vma(tsk); pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t *pte; if (write) return i ? : -EFAULT; if (pg > TASK_SIZE) pgd = pgd_offset_k(pg); else pgd = pgd_offset_gate(mm, pg); BUG_ON(pgd_none(*pgd)); pud = pud_offset(pgd, pg); BUG_ON(pud_none(*pud)); pmd = pmd_offset(pud, pg); if (pmd_none(*pmd)) return i ? : -EFAULT; pte = pte_offset_map(pmd, pg); if (pte_none(*pte)) { pte_unmap(pte); return i ? : -EFAULT; } if (pages) { struct page *page = vm_normal_page(gate_vma, start, *pte); pages[i] = page; if (page) get_page(page); } pte_unmap(pte); if (vmas) vmas[i] = gate_vma; i++; start += PAGE_SIZE; len--; continue; } if (!vma || (vma->vm_flags & (VM_IO | VM_PFNMAP)) || !(vm_flags & vma->vm_flags)) return i ? : -EFAULT; if (is_vm_hugetlb_page(vma)) { i = follow_hugetlb_page(mm, vma, pages, vmas, &start, &len, i, write); continue; } foll_flags = FOLL_TOUCH; if (pages) foll_flags |= FOLL_GET; if (!write && !(vma->vm_flags & VM_LOCKED) && (!vma->vm_ops || !vma->vm_ops->fault)) foll_flags |= FOLL_ANON; do { struct page *page; if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE))) return -ENOMEM; if (write) foll_flags |= FOLL_WRITE; cond_resched(); while (!(page = follow_page(vma, start, foll_flags))) { int ret; ret = handle_mm_fault(mm, vma, start, foll_flags & FOLL_WRITE); if (ret & VM_FAULT_ERROR) { if (ret & VM_FAULT_OOM) return i ? i : -ENOMEM; else if (ret & VM_FAULT_SIGBUS) return i ? i : -EFAULT; BUG(); } if (ret & VM_FAULT_MAJOR) tsk->maj_flt++; else tsk->min_flt++; if (ret & VM_FAULT_WRITE) foll_flags &= ~FOLL_WRITE; cond_resched(); } if (pages) { pages[i] = page; flush_anon_page(vma, page, start); flush_dcache_page(page); } if (vmas) vmas[i] = vma; i++; start += PAGE_SIZE; len--; } while (len && start < vma->vm_end); } while (len); return i; }
396
0
int rpc_type_of_NPNVariable(int variable) { int type; switch (variable) { case NPNVjavascriptEnabledBool: case NPNVasdEnabledBool: case NPNVisOfflineBool: case NPNVSupportsXEmbedBool: case NPNVSupportsWindowless: case NPNVprivateModeBool: case NPNVsupportsAdvancedKeyHandling: type = RPC_TYPE_BOOLEAN; break; case NPNVToolkit: case NPNVnetscapeWindow: type = RPC_TYPE_UINT32; break; case NPNVWindowNPObject: case NPNVPluginElementNPObject: type = RPC_TYPE_NP_OBJECT; break; default: type = RPC_ERROR_GENERIC; break; } return type; }
int rpc_type_of_NPNVariable(int variable) { int type; switch (variable) { case NPNVjavascriptEnabledBool: case NPNVasdEnabledBool: case NPNVisOfflineBool: case NPNVSupportsXEmbedBool: case NPNVSupportsWindowless: case NPNVprivateModeBool: case NPNVsupportsAdvancedKeyHandling: type = RPC_TYPE_BOOLEAN; break; case NPNVToolkit: case NPNVnetscapeWindow: type = RPC_TYPE_UINT32; break; case NPNVWindowNPObject: case NPNVPluginElementNPObject: type = RPC_TYPE_NP_OBJECT; break; default: type = RPC_ERROR_GENERIC; break; } return type; }
397
0
int rpc_type_of_NPPVariable(int variable) { int type; switch (variable) { case NPPVpluginNameString: case NPPVpluginDescriptionString: case NPPVformValue: // byte values of 0 does not appear in the UTF-8 encoding but for U+0000 case NPPVpluginNativeAccessibleAtkPlugId: type = RPC_TYPE_STRING; break; case NPPVpluginWindowSize: case NPPVpluginTimerInterval: type = RPC_TYPE_INT32; break; case NPPVpluginNeedsXEmbed: case NPPVpluginWindowBool: case NPPVpluginTransparentBool: case NPPVjavascriptPushCallerBool: case NPPVpluginKeepLibraryInMemory: case NPPVpluginUrlRequestsDisplayedBool: case NPPVpluginWantsAllNetworkStreams: case NPPVpluginCancelSrcStream: case NPPVSupportsAdvancedKeyHandling: type = RPC_TYPE_BOOLEAN; break; case NPPVpluginScriptableNPObject: type = RPC_TYPE_NP_OBJECT; break; default: type = RPC_ERROR_GENERIC; break; } return type; }
int rpc_type_of_NPPVariable(int variable) { int type; switch (variable) { case NPPVpluginNameString: case NPPVpluginDescriptionString: case NPPVformValue: case NPPVpluginNativeAccessibleAtkPlugId: type = RPC_TYPE_STRING; break; case NPPVpluginWindowSize: case NPPVpluginTimerInterval: type = RPC_TYPE_INT32; break; case NPPVpluginNeedsXEmbed: case NPPVpluginWindowBool: case NPPVpluginTransparentBool: case NPPVjavascriptPushCallerBool: case NPPVpluginKeepLibraryInMemory: case NPPVpluginUrlRequestsDisplayedBool: case NPPVpluginWantsAllNetworkStreams: case NPPVpluginCancelSrcStream: case NPPVSupportsAdvancedKeyHandling: type = RPC_TYPE_BOOLEAN; break; case NPPVpluginScriptableNPObject: type = RPC_TYPE_NP_OBJECT; break; default: type = RPC_ERROR_GENERIC; break; } return type; }
398
1
static int do_pages_stat(struct mm_struct *mm, struct page_to_node *pm) { down_read(&mm->mmap_sem); for ( ; pm->node != MAX_NUMNODES; pm++) { struct vm_area_struct *vma; struct page *page; int err; err = -EFAULT; vma = find_vma(mm, pm->addr); if (!vma) goto set_status; page = follow_page(vma, pm->addr, 0); err = -ENOENT; /* Use PageReserved to check for zero page */ if (!page || PageReserved(page)) goto set_status; err = page_to_nid(page); set_status: pm->status = err; } up_read(&mm->mmap_sem); return 0; }
static int do_pages_stat(struct mm_struct *mm, struct page_to_node *pm) { down_read(&mm->mmap_sem); for ( ; pm->node != MAX_NUMNODES; pm++) { struct vm_area_struct *vma; struct page *page; int err; err = -EFAULT; vma = find_vma(mm, pm->addr); if (!vma) goto set_status; page = follow_page(vma, pm->addr, 0); err = -ENOENT; if (!page || PageReserved(page)) goto set_status; err = page_to_nid(page); set_status: pm->status = err; } up_read(&mm->mmap_sem); return 0; }
399
0
static bool scsi_target_emulate_inquiry(SCSITargetReq *r) { assert(r->req.dev->lun != r->req.lun); scsi_target_alloc_buf(&r->req, SCSI_INQUIRY_LEN); if (r->req.cmd.buf[1] & 0x2) { /* Command support data - optional, not implemented */ return false; } if (r->req.cmd.buf[1] & 0x1) { /* Vital product data */ uint8_t page_code = r->req.cmd.buf[2]; r->buf[r->len++] = page_code ; /* this page */ r->buf[r->len++] = 0x00; switch (page_code) { case 0x00: /* Supported page codes, mandatory */ { int pages; pages = r->len++; r->buf[r->len++] = 0x00; /* list of supported pages (this page) */ r->buf[pages] = r->len - pages - 1; /* number of pages */ break; } default: return false; } /* done with EVPD */ assert(r->len < r->buf_len); r->len = MIN(r->req.cmd.xfer, r->len); return true; } /* Standard INQUIRY data */ if (r->req.cmd.buf[2] != 0) { return false; } /* PAGE CODE == 0 */ r->len = MIN(r->req.cmd.xfer, SCSI_INQUIRY_LEN); memset(r->buf, 0, r->len); if (r->req.lun != 0) { r->buf[0] = TYPE_NO_LUN; } else { r->buf[0] = TYPE_NOT_PRESENT | TYPE_INACTIVE; r->buf[2] = 5; /* Version */ r->buf[3] = 2 | 0x10; /* HiSup, response data format */ r->buf[4] = r->len - 5; /* Additional Length = (Len - 1) - 4 */ r->buf[7] = 0x10 | (r->req.bus->info->tcq ? 0x02 : 0); /* Sync, TCQ. */ memcpy(&r->buf[8], "QEMU ", 8); memcpy(&r->buf[16], "QEMU TARGET ", 16); pstrcpy((char *) &r->buf[32], 4, qemu_get_version()); } return true; }
static bool scsi_target_emulate_inquiry(SCSITargetReq *r) { assert(r->req.dev->lun != r->req.lun); scsi_target_alloc_buf(&r->req, SCSI_INQUIRY_LEN); if (r->req.cmd.buf[1] & 0x2) { return false; } if (r->req.cmd.buf[1] & 0x1) { uint8_t page_code = r->req.cmd.buf[2]; r->buf[r->len++] = page_code ; r->buf[r->len++] = 0x00; switch (page_code) { case 0x00: { int pages; pages = r->len++; r->buf[r->len++] = 0x00; r->buf[pages] = r->len - pages - 1; break; } default: return false; } assert(r->len < r->buf_len); r->len = MIN(r->req.cmd.xfer, r->len); return true; } if (r->req.cmd.buf[2] != 0) { return false; } r->len = MIN(r->req.cmd.xfer, SCSI_INQUIRY_LEN); memset(r->buf, 0, r->len); if (r->req.lun != 0) { r->buf[0] = TYPE_NO_LUN; } else { r->buf[0] = TYPE_NOT_PRESENT | TYPE_INACTIVE; r->buf[2] = 5; r->buf[3] = 2 | 0x10; r->buf[4] = r->len - 5; r->buf[7] = 0x10 | (r->req.bus->info->tcq ? 0x02 : 0); memcpy(&r->buf[8], "QEMU ", 8); memcpy(&r->buf[16], "QEMU TARGET ", 16); pstrcpy((char *) &r->buf[32], 4, qemu_get_version()); } return true; }
400
1
spnego_gss_inquire_context( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, gss_name_t *src_name, gss_name_t *targ_name, OM_uint32 *lifetime_rec, gss_OID *mech_type, OM_uint32 *ctx_flags, int *locally_initiated, int *opened) { OM_uint32 ret = GSS_S_COMPLETE; ret = gss_inquire_context(minor_status, context_handle, src_name, targ_name, lifetime_rec, mech_type, ctx_flags, locally_initiated, opened); return (ret); }
spnego_gss_inquire_context( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, gss_name_t *src_name, gss_name_t *targ_name, OM_uint32 *lifetime_rec, gss_OID *mech_type, OM_uint32 *ctx_flags, int *locally_initiated, int *opened) { OM_uint32 ret = GSS_S_COMPLETE; ret = gss_inquire_context(minor_status, context_handle, src_name, targ_name, lifetime_rec, mech_type, ctx_flags, locally_initiated, opened); return (ret); }
402
1
spnego_gss_inquire_sec_context_by_oid( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, const gss_OID desired_object, gss_buffer_set_t *data_set) { OM_uint32 ret; ret = gss_inquire_sec_context_by_oid(minor_status, context_handle, desired_object, data_set); return (ret); }
spnego_gss_inquire_sec_context_by_oid( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, const gss_OID desired_object, gss_buffer_set_t *data_set) { OM_uint32 ret; ret = gss_inquire_sec_context_by_oid(minor_status, context_handle, desired_object, data_set); return (ret); }
403
0
const char *string_of_NPNVariable(int variable) { const char *str; switch (variable) { #define _(VAL) case VAL: str = #VAL; break; _(NPNVxDisplay); _(NPNVxtAppContext); _(NPNVnetscapeWindow); _(NPNVjavascriptEnabledBool); _(NPNVasdEnabledBool); _(NPNVisOfflineBool); _(NPNVserviceManager); _(NPNVDOMElement); _(NPNVDOMWindow); _(NPNVToolkit); _(NPNVSupportsXEmbedBool); _(NPNVWindowNPObject); _(NPNVPluginElementNPObject); _(NPNVSupportsWindowless); _(NPNVprivateModeBool); _(NPNVsupportsAdvancedKeyHandling); #undef _ default: switch (variable & 0xff) { #define _(VAL, VAR) case VAL: str = #VAR; break _(10, NPNVserviceManager); _(11, NPNVDOMElement); _(12, NPNVDOMWindow); _(13, NPNVToolkit); #undef _ default: str = "<unknown variable>"; break; } break; } return str; }
const char *string_of_NPNVariable(int variable) { const char *str; switch (variable) { #define _(VAL) case VAL: str = #VAL; break; _(NPNVxDisplay); _(NPNVxtAppContext); _(NPNVnetscapeWindow); _(NPNVjavascriptEnabledBool); _(NPNVasdEnabledBool); _(NPNVisOfflineBool); _(NPNVserviceManager); _(NPNVDOMElement); _(NPNVDOMWindow); _(NPNVToolkit); _(NPNVSupportsXEmbedBool); _(NPNVWindowNPObject); _(NPNVPluginElementNPObject); _(NPNVSupportsWindowless); _(NPNVprivateModeBool); _(NPNVsupportsAdvancedKeyHandling); #undef _ default: switch (variable & 0xff) { #define _(VAL, VAR) case VAL: str = #VAR; break _(10, NPNVserviceManager); _(11, NPNVDOMElement); _(12, NPNVDOMWindow); _(13, NPNVToolkit); #undef _ default: str = "<unknown variable>"; break; } break; } return str; }
405
0
void OPPROTO op_movl_npc_T0(void) { env->npc = T0; }
void OPPROTO op_movl_npc_T0(void) { env->npc = T0; }
406
0
const char *string_of_NPPVariable(int variable) { const char *str; switch (variable) { #define _(VAL) case VAL: str = #VAL; break; _(NPPVpluginNameString); _(NPPVpluginDescriptionString); _(NPPVpluginWindowBool); _(NPPVpluginTransparentBool); _(NPPVjavaClass); _(NPPVpluginWindowSize); _(NPPVpluginTimerInterval); _(NPPVpluginScriptableInstance); _(NPPVpluginScriptableIID); _(NPPVjavascriptPushCallerBool); _(NPPVpluginKeepLibraryInMemory); _(NPPVpluginNeedsXEmbed); _(NPPVpluginScriptableNPObject); _(NPPVformValue); _(NPPVpluginUrlRequestsDisplayedBool); _(NPPVpluginWantsAllNetworkStreams); _(NPPVpluginNativeAccessibleAtkPlugId); _(NPPVpluginCancelSrcStream); _(NPPVSupportsAdvancedKeyHandling); #undef _ default: switch (variable & 0xff) { #define _(VAL, VAR) case VAL: str = #VAR; break _(10, NPPVpluginScriptableInstance); #undef _ default: str = "<unknown variable>"; break; } break; } return str; }
const char *string_of_NPPVariable(int variable) { const char *str; switch (variable) { #define _(VAL) case VAL: str = #VAL; break; _(NPPVpluginNameString); _(NPPVpluginDescriptionString); _(NPPVpluginWindowBool); _(NPPVpluginTransparentBool); _(NPPVjavaClass); _(NPPVpluginWindowSize); _(NPPVpluginTimerInterval); _(NPPVpluginScriptableInstance); _(NPPVpluginScriptableIID); _(NPPVjavascriptPushCallerBool); _(NPPVpluginKeepLibraryInMemory); _(NPPVpluginNeedsXEmbed); _(NPPVpluginScriptableNPObject); _(NPPVformValue); _(NPPVpluginUrlRequestsDisplayedBool); _(NPPVpluginWantsAllNetworkStreams); _(NPPVpluginNativeAccessibleAtkPlugId); _(NPPVpluginCancelSrcStream); _(NPPVSupportsAdvancedKeyHandling); #undef _ default: switch (variable & 0xff) { #define _(VAL, VAR) case VAL: str = #VAR; break _(10, NPPVpluginScriptableInstance); #undef _ default: str = "<unknown variable>"; break; } break; } return str; }
407
0
void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce) { TemporalNoiseShaping *tns = &sce->tns; int w, g, order, sfb_start, sfb_len, coef_start, shift[MAX_LPC_ORDER], count = 0; const int is8 = sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE; const int tns_max_order = is8 ? 7 : s->profile == FF_PROFILE_AAC_LOW ? 12 : TNS_MAX_ORDER; const float freq_mult = mpeg4audio_sample_rates[s->samplerate_index]/(1024.0f/sce->ics.num_windows)/2.0f; float max_coef = 0.0f; sce->tns.present = 0; return; for (coef_start = 0; coef_start < 1024; coef_start++) max_coef = FFMAX(max_coef, sce->pcoeffs[coef_start]); for (w = 0; w < sce->ics.num_windows; w++) { int filters = 1, start = 0, coef_len = 0; int32_t conv_coeff[1024] = {0}; int32_t coefs_t[MAX_LPC_ORDER][MAX_LPC_ORDER] = {{0}}; /* Determine start sfb + coef - excludes anything below threshold */ for (g = 0; g < sce->ics.num_swb; g++) { if (start*freq_mult > TNS_LOW_LIMIT) { sfb_start = w*16+g; sfb_len = (w+1)*16 + g - sfb_start; coef_start = sce->ics.swb_offset[sfb_start]; coef_len = sce->ics.swb_offset[sfb_start + sfb_len] - coef_start; break; } start += sce->ics.swb_sizes[g]; } if (coef_len <= 0) continue; conv_to_int32(conv_coeff, &sce->pcoeffs[coef_start], coef_len, max_coef); /* LPC */ order = ff_lpc_calc_coefs(&s->lpc, conv_coeff, coef_len, TNS_MIN_PRED_ORDER, tns_max_order, 32, coefs_t, shift, FF_LPC_TYPE_LEVINSON, 10, ORDER_METHOD_EST, MAX_LPC_SHIFT, 0) - 1; /* Works surprisingly well, remember to tweak MAX_LPC_SHIFT if you want to play around with this */ if (shift[order] > 3) { int direction = 0; float tns_coefs_raw[TNS_MAX_ORDER]; tns->n_filt[w] = filters++; conv_to_float(tns_coefs_raw, coefs_t[order], order); for (g = 0; g < tns->n_filt[w]; g++) { process_tns_coeffs(tns, tns_coefs_raw, order, w, g); apply_tns_filter(&sce->coeffs[coef_start], sce->pcoeffs, order, direction, tns->coef[w][g], sce->ics.ltp.present, w, g, coef_start, coef_len); tns->order[w][g] = order; tns->length[w][g] = sfb_len; tns->direction[w][g] = direction; } count++; } } sce->tns.present = !!count; }
void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce) { TemporalNoiseShaping *tns = &sce->tns; int w, g, order, sfb_start, sfb_len, coef_start, shift[MAX_LPC_ORDER], count = 0; const int is8 = sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE; const int tns_max_order = is8 ? 7 : s->profile == FF_PROFILE_AAC_LOW ? 12 : TNS_MAX_ORDER; const float freq_mult = mpeg4audio_sample_rates[s->samplerate_index]/(1024.0f/sce->ics.num_windows)/2.0f; float max_coef = 0.0f; sce->tns.present = 0; return; for (coef_start = 0; coef_start < 1024; coef_start++) max_coef = FFMAX(max_coef, sce->pcoeffs[coef_start]); for (w = 0; w < sce->ics.num_windows; w++) { int filters = 1, start = 0, coef_len = 0; int32_t conv_coeff[1024] = {0}; int32_t coefs_t[MAX_LPC_ORDER][MAX_LPC_ORDER] = {{0}}; for (g = 0; g < sce->ics.num_swb; g++) { if (start*freq_mult > TNS_LOW_LIMIT) { sfb_start = w*16+g; sfb_len = (w+1)*16 + g - sfb_start; coef_start = sce->ics.swb_offset[sfb_start]; coef_len = sce->ics.swb_offset[sfb_start + sfb_len] - coef_start; break; } start += sce->ics.swb_sizes[g]; } if (coef_len <= 0) continue; conv_to_int32(conv_coeff, &sce->pcoeffs[coef_start], coef_len, max_coef); order = ff_lpc_calc_coefs(&s->lpc, conv_coeff, coef_len, TNS_MIN_PRED_ORDER, tns_max_order, 32, coefs_t, shift, FF_LPC_TYPE_LEVINSON, 10, ORDER_METHOD_EST, MAX_LPC_SHIFT, 0) - 1; if (shift[order] > 3) { int direction = 0; float tns_coefs_raw[TNS_MAX_ORDER]; tns->n_filt[w] = filters++; conv_to_float(tns_coefs_raw, coefs_t[order], order); for (g = 0; g < tns->n_filt[w]; g++) { process_tns_coeffs(tns, tns_coefs_raw, order, w, g); apply_tns_filter(&sce->coeffs[coef_start], sce->pcoeffs, order, direction, tns->coef[w][g], sce->ics.ltp.present, w, g, coef_start, coef_len); tns->order[w][g] = order; tns->length[w][g] = sfb_len; tns->direction[w][g] = direction; } count++; } } sce->tns.present = !!count; }
408
1
static void dump_one_vdso_page(struct page *pg, struct page *upg) { printk("kpg: %p (c:%d,f:%08lx)", __va(page_to_pfn(pg) << PAGE_SHIFT), page_count(pg), pg->flags); if (upg/* && pg != upg*/) { printk(" upg: %p (c:%d,f:%08lx)", __va(page_to_pfn(upg) << PAGE_SHIFT), page_count(upg), upg->flags); } printk("\n"); }
static void dump_one_vdso_page(struct page *pg, struct page *upg) { printk("kpg: %p (c:%d,f:%08lx)", __va(page_to_pfn(pg) << PAGE_SHIFT), page_count(pg), pg->flags); if (upg ) { printk(" upg: %p (c:%d,f:%08lx)", __va(page_to_pfn(upg) << PAGE_SHIFT), page_count(upg), upg->flags); } printk("\n"); }
410
0
YCPBoolean IniAgent::Write(const YCPPath &path, const YCPValue& value, const YCPValue& arg) { if (!parser.isStarted()) { y2warning("Can't execute Write before being mounted."); return YCPBoolean (false); } // no need to update if modified, we are changing value bool ok = false; // is the _path_ ok? // return value YCPBoolean b (true); if (0 == path->length ()) { if (value->isString() && value->asString()->value() == "force") parser.inifile.setDirty(); else if (value->isString () && value->asString()->value() == "clean") parser.inifile.clean (); if (0 != parser.write ()) b = false; ok = true; } else { if (( parser.repeatNames () && value->isList ()) || (!parser.repeatNames () && (value->isString () || value->isBoolean() || value->isInteger())) || path->component_str(0) == "all" ) { ok = true; if (parser.inifile.Write (path, value, parser.HaveRewrites ())) b = false; } else if (value->isVoid ()) { int wb = -1; string del_sec = ""; ok = true; if (2 == path->length ()) { string pc = path->component_str(0); if ("s" == pc || "section" == pc) { // request to delete section. Find the file name del_sec = path->component_str (1); wb = parser.inifile.getSubSectionRewriteBy (del_sec.c_str()); } } if (parser.inifile.Delete (path)) b = false; else if (del_sec != "") { parser.deleted_sections.insert (parser.getFileName (del_sec, wb)); } } else { ycp2error ("Wrong value for path %s: %s", path->toString ().c_str (), value->toString ().c_str ()); b = false; } } if (!ok) { ycp2error ( "Wrong path '%s' in Write().", path->toString().c_str () ); } return b; }
YCPBoolean IniAgent::Write(const YCPPath &path, const YCPValue& value, const YCPValue& arg) { if (!parser.isStarted()) { y2warning("Can't execute Write before being mounted."); return YCPBoolean (false); } bool ok = false; YCPBoolean b (true); if (0 == path->length ()) { if (value->isString() && value->asString()->value() == "force") parser.inifile.setDirty(); else if (value->isString () && value->asString()->value() == "clean") parser.inifile.clean (); if (0 != parser.write ()) b = false; ok = true; } else { if (( parser.repeatNames () && value->isList ()) || (!parser.repeatNames () && (value->isString () || value->isBoolean() || value->isInteger())) || path->component_str(0) == "all" ) { ok = true; if (parser.inifile.Write (path, value, parser.HaveRewrites ())) b = false; } else if (value->isVoid ()) { int wb = -1; string del_sec = ""; ok = true; if (2 == path->length ()) { string pc = path->component_str(0); if ("s" == pc || "section" == pc) { del_sec = path->component_str (1); wb = parser.inifile.getSubSectionRewriteBy (del_sec.c_str()); } } if (parser.inifile.Delete (path)) b = false; else if (del_sec != "") { parser.deleted_sections.insert (parser.getFileName (del_sec, wb)); } } else { ycp2error ("Wrong value for path %s: %s", path->toString ().c_str (), value->toString ().c_str ()); b = false; } } if (!ok) { ycp2error ( "Wrong path '%s' in Write().", path->toString().c_str () ); } return b; }
412
0
static void test_keys ( ELG_secret_key * sk , unsigned int nbits ) { ELG_public_key pk ; MPI test = mpi_alloc ( 0 ) ; MPI out1_a = mpi_alloc ( mpi_nlimb_hint_from_nbits ( nbits ) ) ; MPI out1_b = mpi_alloc ( mpi_nlimb_hint_from_nbits ( nbits ) ) ; MPI out2 = mpi_alloc ( mpi_nlimb_hint_from_nbits ( nbits ) ) ; pk . p = sk -> p ; pk . g = sk -> g ; pk . y = sk -> y ; { char * p = get_random_bits ( nbits , 0 , 0 ) ; mpi_set_buffer ( test , p , ( nbits + 7 ) / 8 , 0 ) ; xfree ( p ) ; } do_encrypt ( out1_a , out1_b , test , & pk ) ; decrypt ( out2 , out1_a , out1_b , sk ) ; if ( mpi_cmp ( test , out2 ) ) log_fatal ( "Elgamal operation: encrypt, decrypt failed\n" ) ; mpi_free ( test ) ; mpi_free ( out1_a ) ; mpi_free ( out1_b ) ; mpi_free ( out2 ) ; }
static void test_keys ( ELG_secret_key * sk , unsigned int nbits ) { ELG_public_key pk ; MPI test = mpi_alloc ( 0 ) ; MPI out1_a = mpi_alloc ( mpi_nlimb_hint_from_nbits ( nbits ) ) ; MPI out1_b = mpi_alloc ( mpi_nlimb_hint_from_nbits ( nbits ) ) ; MPI out2 = mpi_alloc ( mpi_nlimb_hint_from_nbits ( nbits ) ) ; pk . p = sk -> p ; pk . g = sk -> g ; pk . y = sk -> y ; { char * p = get_random_bits ( nbits , 0 , 0 ) ; mpi_set_buffer ( test , p , ( nbits + 7 ) / 8 , 0 ) ; xfree ( p ) ; } do_encrypt ( out1_a , out1_b , test , & pk ) ; decrypt ( out2 , out1_a , out1_b , sk ) ; if ( mpi_cmp ( test , out2 ) ) log_fatal ( "Elgamal operation: encrypt, decrypt failed\n" ) ; mpi_free ( test ) ; mpi_free ( out1_a ) ; mpi_free ( out1_b ) ; mpi_free ( out2 ) ; }
413
1
struct page *follow_page(struct vm_area_struct *vma, unsigned long address, unsigned int flags) { pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t *ptep, pte; spinlock_t *ptl; struct page *page; struct mm_struct *mm = vma->vm_mm; page = follow_huge_addr(mm, address, flags & FOLL_WRITE); if (!IS_ERR(page)) { BUG_ON(flags & FOLL_GET); goto out; } page = NULL; pgd = pgd_offset(mm, address); if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd))) goto no_page_table; pud = pud_offset(pgd, address); if (pud_none(*pud) || unlikely(pud_bad(*pud))) goto no_page_table; pmd = pmd_offset(pud, address); if (pmd_none(*pmd)) goto no_page_table; if (pmd_huge(*pmd)) { BUG_ON(flags & FOLL_GET); page = follow_huge_pmd(mm, address, pmd, flags & FOLL_WRITE); goto out; } if (unlikely(pmd_bad(*pmd))) goto no_page_table; ptep = pte_offset_map_lock(mm, pmd, address, &ptl); if (!ptep) goto out; pte = *ptep; if (!pte_present(pte)) goto unlock; if ((flags & FOLL_WRITE) && !pte_write(pte)) goto unlock; page = vm_normal_page(vma, address, pte); if (unlikely(!page)) goto unlock; if (flags & FOLL_GET) get_page(page); if (flags & FOLL_TOUCH) { if ((flags & FOLL_WRITE) && !pte_dirty(pte) && !PageDirty(page)) set_page_dirty(page); mark_page_accessed(page); } unlock: pte_unmap_unlock(ptep, ptl); out: return page; no_page_table: /* * When core dumping an enormous anonymous area that nobody * has touched so far, we don't want to allocate page tables. */ if (flags & FOLL_ANON) { page = ZERO_PAGE(0); if (flags & FOLL_GET) get_page(page); BUG_ON(flags & FOLL_WRITE); } return page; }
struct page *follow_page(struct vm_area_struct *vma, unsigned long address, unsigned int flags) { pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t *ptep, pte; spinlock_t *ptl; struct page *page; struct mm_struct *mm = vma->vm_mm; page = follow_huge_addr(mm, address, flags & FOLL_WRITE); if (!IS_ERR(page)) { BUG_ON(flags & FOLL_GET); goto out; } page = NULL; pgd = pgd_offset(mm, address); if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd))) goto no_page_table; pud = pud_offset(pgd, address); if (pud_none(*pud) || unlikely(pud_bad(*pud))) goto no_page_table; pmd = pmd_offset(pud, address); if (pmd_none(*pmd)) goto no_page_table; if (pmd_huge(*pmd)) { BUG_ON(flags & FOLL_GET); page = follow_huge_pmd(mm, address, pmd, flags & FOLL_WRITE); goto out; } if (unlikely(pmd_bad(*pmd))) goto no_page_table; ptep = pte_offset_map_lock(mm, pmd, address, &ptl); if (!ptep) goto out; pte = *ptep; if (!pte_present(pte)) goto unlock; if ((flags & FOLL_WRITE) && !pte_write(pte)) goto unlock; page = vm_normal_page(vma, address, pte); if (unlikely(!page)) goto unlock; if (flags & FOLL_GET) get_page(page); if (flags & FOLL_TOUCH) { if ((flags & FOLL_WRITE) && !pte_dirty(pte) && !PageDirty(page)) set_page_dirty(page); mark_page_accessed(page); } unlock: pte_unmap_unlock(ptep, ptl); out: return page; no_page_table: if (flags & FOLL_ANON) { page = ZERO_PAGE(0); if (flags & FOLL_GET) get_page(page); BUG_ON(flags & FOLL_WRITE); } return page; }
414
0
int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec) { _Bool exp = 0; if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init) return 0; if (lockmgr_cb) { if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) return -1; } if (atomic_fetch_add(&entangled_thread_counter, 1)) { av_log(log_ctx, AV_LOG_ERROR, "Insufficient thread locking. At least %d threads are " "calling avcodec_open2() at the same time right now.\n", atomic_load(&entangled_thread_counter)); if (!lockmgr_cb) av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set, please see av_lockmgr_register()\n"); atomic_store(&ff_avcodec_locked, 1); ff_unlock_avcodec(codec); return AVERROR(EINVAL); } av_assert0(atomic_compare_exchange_strong(&ff_avcodec_locked, &exp, 1)); return 0; }
int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec) { _Bool exp = 0; if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init) return 0; if (lockmgr_cb) { if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) return -1; } if (atomic_fetch_add(&entangled_thread_counter, 1)) { av_log(log_ctx, AV_LOG_ERROR, "Insufficient thread locking. At least %d threads are " "calling avcodec_open2() at the same time right now.\n", atomic_load(&entangled_thread_counter)); if (!lockmgr_cb) av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set, please see av_lockmgr_register()\n"); atomic_store(&ff_avcodec_locked, 1); ff_unlock_avcodec(codec); return AVERROR(EINVAL); } av_assert0(atomic_compare_exchange_strong(&ff_avcodec_locked, &exp, 1)); return 0; }
415
0
static void put_payload_header ( AVFormatContext * s , ASFStream * stream , int64_t presentation_time , int m_obj_size , int m_obj_offset , int payload_len , int flags ) { ASFContext * asf = s -> priv_data ; AVIOContext * pb = & asf -> pb ; int val ; val = stream -> num ; if ( flags & AV_PKT_FLAG_KEY ) val |= ASF_PL_FLAG_KEY_FRAME ; avio_w8 ( pb , val ) ; avio_w8 ( pb , stream -> seq ) ; avio_wl32 ( pb , m_obj_offset ) ; avio_w8 ( pb , ASF_PAYLOAD_REPLICATED_DATA_LENGTH ) ; avio_wl32 ( pb , m_obj_size ) ; avio_wl32 ( pb , ( uint32_t ) presentation_time ) ; if ( asf -> multi_payloads_present ) { avio_wl16 ( pb , payload_len ) ; } }
static void put_payload_header ( AVFormatContext * s , ASFStream * stream , int64_t presentation_time , int m_obj_size , int m_obj_offset , int payload_len , int flags ) { ASFContext * asf = s -> priv_data ; AVIOContext * pb = & asf -> pb ; int val ; val = stream -> num ; if ( flags & AV_PKT_FLAG_KEY ) val |= ASF_PL_FLAG_KEY_FRAME ; avio_w8 ( pb , val ) ; avio_w8 ( pb , stream -> seq ) ; avio_wl32 ( pb , m_obj_offset ) ; avio_w8 ( pb , ASF_PAYLOAD_REPLICATED_DATA_LENGTH ) ; avio_wl32 ( pb , m_obj_size ) ; avio_wl32 ( pb , ( uint32_t ) presentation_time ) ; if ( asf -> multi_payloads_present ) { avio_wl16 ( pb , payload_len ) ; } }
416
1
void FUNCC(ff_h264_idct_add)(uint8_t *_dst, int16_t *_block, int stride) { int i; pixel *dst = (pixel*)_dst; dctcoef *block = (dctcoef*)_block; stride >>= sizeof(pixel)-1; block[0] += 1 << 5; for(i=0; i<4; i++){ const int z0= block[i + 4*0] + block[i + 4*2]; const int z1= block[i + 4*0] - block[i + 4*2]; const int z2= (block[i + 4*1]>>1) - block[i + 4*3]; const int z3= block[i + 4*1] + (block[i + 4*3]>>1); block[i + 4*0]= z0 + z3; block[i + 4*1]= z1 + z2; block[i + 4*2]= z1 - z2; block[i + 4*3]= z0 - z3; } for(i=0; i<4; i++){ const int z0= block[0 + 4*i] + block[2 + 4*i]; const int z1= block[0 + 4*i] - block[2 + 4*i]; const int z2= (block[1 + 4*i]>>1) - block[3 + 4*i]; const int z3= block[1 + 4*i] + (block[3 + 4*i]>>1); dst[i + 0*stride]= av_clip_pixel(dst[i + 0*stride] + ((z0 + z3) >> 6)); dst[i + 1*stride]= av_clip_pixel(dst[i + 1*stride] + ((z1 + z2) >> 6)); dst[i + 2*stride]= av_clip_pixel(dst[i + 2*stride] + ((z1 - z2) >> 6)); dst[i + 3*stride]= av_clip_pixel(dst[i + 3*stride] + ((z0 - z3) >> 6)); } memset(block, 0, 16 * sizeof(dctcoef)); }
void FUNCC(ff_h264_idct_add)(uint8_t *_dst, int16_t *_block, int stride) { int i; pixel *dst = (pixel*)_dst; dctcoef *block = (dctcoef*)_block; stride >>= sizeof(pixel)-1; block[0] += 1 << 5; for(i=0; i<4; i++){ const int z0= block[i + 4*0] + block[i + 4*2]; const int z1= block[i + 4*0] - block[i + 4*2]; const int z2= (block[i + 4*1]>>1) - block[i + 4*3]; const int z3= block[i + 4*1] + (block[i + 4*3]>>1); block[i + 4*0]= z0 + z3; block[i + 4*1]= z1 + z2; block[i + 4*2]= z1 - z2; block[i + 4*3]= z0 - z3; } for(i=0; i<4; i++){ const int z0= block[0 + 4*i] + block[2 + 4*i]; const int z1= block[0 + 4*i] - block[2 + 4*i]; const int z2= (block[1 + 4*i]>>1) - block[3 + 4*i]; const int z3= block[1 + 4*i] + (block[3 + 4*i]>>1); dst[i + 0*stride]= av_clip_pixel(dst[i + 0*stride] + ((z0 + z3) >> 6)); dst[i + 1*stride]= av_clip_pixel(dst[i + 1*stride] + ((z1 + z2) >> 6)); dst[i + 2*stride]= av_clip_pixel(dst[i + 2*stride] + ((z1 - z2) >> 6)); dst[i + 3*stride]= av_clip_pixel(dst[i + 3*stride] + ((z0 - z3) >> 6)); } memset(block, 0, 16 * sizeof(dctcoef)); }
418
1
int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, int len, int write, int force, struct page **pages, struct vm_area_struct **vmas) { int i; unsigned int vm_flags; if (len <= 0) return 0; /* * Require read or write permissions. * If 'force' is set, we only require the "MAY" flags. */ vm_flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD); vm_flags &= force ? (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE); i = 0; do { struct vm_area_struct *vma; unsigned int foll_flags; vma = find_extend_vma(mm, start); if (!vma && in_gate_area(tsk, start)) { unsigned long pg = start & PAGE_MASK; struct vm_area_struct *gate_vma = get_gate_vma(tsk); pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t *pte; if (write) /* user gate pages are read-only */ return i ? : -EFAULT; if (pg > TASK_SIZE) pgd = pgd_offset_k(pg); else pgd = pgd_offset_gate(mm, pg); BUG_ON(pgd_none(*pgd)); pud = pud_offset(pgd, pg); BUG_ON(pud_none(*pud)); pmd = pmd_offset(pud, pg); if (pmd_none(*pmd)) return i ? : -EFAULT; pte = pte_offset_map(pmd, pg); if (pte_none(*pte)) { pte_unmap(pte); return i ? : -EFAULT; } if (pages) { struct page *page = vm_normal_page(gate_vma, start, *pte); pages[i] = page; if (page) get_page(page); } pte_unmap(pte); if (vmas) vmas[i] = gate_vma; i++; start += PAGE_SIZE; len--; continue; } if (!vma || (vma->vm_flags & (VM_IO | VM_PFNMAP)) || !(vm_flags & vma->vm_flags)) return i ? : -EFAULT; if (is_vm_hugetlb_page(vma)) { i = follow_hugetlb_page(mm, vma, pages, vmas, &start, &len, i, write); continue; } foll_flags = FOLL_TOUCH; if (pages) foll_flags |= FOLL_GET; if (!write && !(vma->vm_flags & VM_LOCKED) && (!vma->vm_ops || !vma->vm_ops->fault)) foll_flags |= FOLL_ANON; do { struct page *page; /* * If tsk is ooming, cut off its access to large memory * allocations. It has a pending SIGKILL, but it can't * be processed until returning to user space. */ if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE))) return -ENOMEM; if (write) foll_flags |= FOLL_WRITE; cond_resched(); while (!(page = follow_page(vma, start, foll_flags))) { int ret; ret = handle_mm_fault(mm, vma, start, foll_flags & FOLL_WRITE); if (ret & VM_FAULT_ERROR) { if (ret & VM_FAULT_OOM) return i ? i : -ENOMEM; else if (ret & VM_FAULT_SIGBUS) return i ? i : -EFAULT; BUG(); } if (ret & VM_FAULT_MAJOR) tsk->maj_flt++; else tsk->min_flt++; /* * The VM_FAULT_WRITE bit tells us that * do_wp_page has broken COW when necessary, * even if maybe_mkwrite decided not to set * pte_write. We can thus safely do subsequent * page lookups as if they were reads. */ if (ret & VM_FAULT_WRITE) foll_flags &= ~FOLL_WRITE; cond_resched(); } if (IS_ERR(page)) return i ? i : PTR_ERR(page); if (pages) { pages[i] = page; flush_anon_page(vma, page, start); flush_dcache_page(page); } if (vmas) vmas[i] = vma; i++; start += PAGE_SIZE; len--; } while (len && start < vma->vm_end); } while (len); return i; }
int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, int len, int write, int force, struct page **pages, struct vm_area_struct **vmas) { int i; unsigned int vm_flags; if (len <= 0) return 0; vm_flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD); vm_flags &= force ? (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE); i = 0; do { struct vm_area_struct *vma; unsigned int foll_flags; vma = find_extend_vma(mm, start); if (!vma && in_gate_area(tsk, start)) { unsigned long pg = start & PAGE_MASK; struct vm_area_struct *gate_vma = get_gate_vma(tsk); pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t *pte; if (write) return i ? : -EFAULT; if (pg > TASK_SIZE) pgd = pgd_offset_k(pg); else pgd = pgd_offset_gate(mm, pg); BUG_ON(pgd_none(*pgd)); pud = pud_offset(pgd, pg); BUG_ON(pud_none(*pud)); pmd = pmd_offset(pud, pg); if (pmd_none(*pmd)) return i ? : -EFAULT; pte = pte_offset_map(pmd, pg); if (pte_none(*pte)) { pte_unmap(pte); return i ? : -EFAULT; } if (pages) { struct page *page = vm_normal_page(gate_vma, start, *pte); pages[i] = page; if (page) get_page(page); } pte_unmap(pte); if (vmas) vmas[i] = gate_vma; i++; start += PAGE_SIZE; len--; continue; } if (!vma || (vma->vm_flags & (VM_IO | VM_PFNMAP)) || !(vm_flags & vma->vm_flags)) return i ? : -EFAULT; if (is_vm_hugetlb_page(vma)) { i = follow_hugetlb_page(mm, vma, pages, vmas, &start, &len, i, write); continue; } foll_flags = FOLL_TOUCH; if (pages) foll_flags |= FOLL_GET; if (!write && !(vma->vm_flags & VM_LOCKED) && (!vma->vm_ops || !vma->vm_ops->fault)) foll_flags |= FOLL_ANON; do { struct page *page; if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE))) return -ENOMEM; if (write) foll_flags |= FOLL_WRITE; cond_resched(); while (!(page = follow_page(vma, start, foll_flags))) { int ret; ret = handle_mm_fault(mm, vma, start, foll_flags & FOLL_WRITE); if (ret & VM_FAULT_ERROR) { if (ret & VM_FAULT_OOM) return i ? i : -ENOMEM; else if (ret & VM_FAULT_SIGBUS) return i ? i : -EFAULT; BUG(); } if (ret & VM_FAULT_MAJOR) tsk->maj_flt++; else tsk->min_flt++; if (ret & VM_FAULT_WRITE) foll_flags &= ~FOLL_WRITE; cond_resched(); } if (IS_ERR(page)) return i ? i : PTR_ERR(page); if (pages) { pages[i] = page; flush_anon_page(vma, page, start); flush_dcache_page(page); } if (vmas) vmas[i] = vma; i++; start += PAGE_SIZE; len--; } while (len && start < vma->vm_end); } while (len); return i; }
419
1
spnego_gss_pseudo_random(OM_uint32 *minor_status, gss_ctx_id_t context, int prf_key, const gss_buffer_t prf_in, ssize_t desired_output_len, gss_buffer_t prf_out) { OM_uint32 ret; ret = gss_pseudo_random(minor_status, context, prf_key, prf_in, desired_output_len, prf_out); return (ret); }
spnego_gss_pseudo_random(OM_uint32 *minor_status, gss_ctx_id_t context, int prf_key, const gss_buffer_t prf_in, ssize_t desired_output_len, gss_buffer_t prf_out) { OM_uint32 ret; ret = gss_pseudo_random(minor_status, context, prf_key, prf_in, desired_output_len, prf_out); return (ret); }
420
1
static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque, uint64_t flags) { RDMAControlHeader reg_resp = { .len = sizeof(RDMARegisterResult), .type = RDMA_CONTROL_REGISTER_RESULT, .repeat = 0, }; RDMAControlHeader unreg_resp = { .len = 0, .type = RDMA_CONTROL_UNREGISTER_FINISHED, .repeat = 0, }; RDMAControlHeader blocks = { .type = RDMA_CONTROL_RAM_BLOCKS_RESULT, .repeat = 1 }; QEMUFileRDMA *rfile = opaque; RDMAContext *rdma = rfile->rdma; RDMALocalBlocks *local = &rdma->local_ram_blocks; RDMAControlHeader head; RDMARegister *reg, *registers; RDMACompress *comp; RDMARegisterResult *reg_result; static RDMARegisterResult results[RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE]; RDMALocalBlock *block; void *host_addr; int ret = 0; int idx = 0; int count = 0; int i = 0; CHECK_ERROR_STATE(); do { DDDPRINTF("Waiting for next request %" PRIu64 "...\n", flags); ret = qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_NONE); if (ret < 0) { break; } if (head.repeat > RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE) { fprintf(stderr, "rdma: Too many requests in this message (%d)." "Bailing.\n", head.repeat); ret = -EIO; break; } switch (head.type) { case RDMA_CONTROL_COMPRESS: comp = (RDMACompress *) rdma->wr_data[idx].control_curr; network_to_compress(comp); DDPRINTF("Zapping zero chunk: %" PRId64 " bytes, index %d, offset %" PRId64 "\n", comp->length, comp->block_idx, comp->offset); block = &(rdma->local_ram_blocks.block[comp->block_idx]); host_addr = block->local_host_addr + (comp->offset - block->offset); ram_handle_compressed(host_addr, comp->value, comp->length); break; case RDMA_CONTROL_REGISTER_FINISHED: DDDPRINTF("Current registrations complete.\n"); goto out; case RDMA_CONTROL_RAM_BLOCKS_REQUEST: DPRINTF("Initial setup info requested.\n"); if (rdma->pin_all) { ret = qemu_rdma_reg_whole_ram_blocks(rdma); if (ret) { fprintf(stderr, "rdma migration: error dest " "registering ram blocks!\n"); goto out; } } /* * Dest uses this to prepare to transmit the RAMBlock descriptions * to the source VM after connection setup. * Both sides use the "remote" structure to communicate and update * their "local" descriptions with what was sent. */ for (i = 0; i < local->nb_blocks; i++) { rdma->block[i].remote_host_addr = (uint64_t)(local->block[i].local_host_addr); if (rdma->pin_all) { rdma->block[i].remote_rkey = local->block[i].mr->rkey; } rdma->block[i].offset = local->block[i].offset; rdma->block[i].length = local->block[i].length; remote_block_to_network(&rdma->block[i]); } blocks.len = rdma->local_ram_blocks.nb_blocks * sizeof(RDMARemoteBlock); ret = qemu_rdma_post_send_control(rdma, (uint8_t *) rdma->block, &blocks); if (ret < 0) { fprintf(stderr, "rdma migration: error sending remote info!\n"); goto out; } break; case RDMA_CONTROL_REGISTER_REQUEST: DDPRINTF("There are %d registration requests\n", head.repeat); reg_resp.repeat = head.repeat; registers = (RDMARegister *) rdma->wr_data[idx].control_curr; for (count = 0; count < head.repeat; count++) { uint64_t chunk; uint8_t *chunk_start, *chunk_end; reg = &registers[count]; network_to_register(reg); reg_result = &results[count]; DDPRINTF("Registration request (%d): index %d, current_addr %" PRIu64 " chunks: %" PRIu64 "\n", count, reg->current_index, reg->key.current_addr, reg->chunks); block = &(rdma->local_ram_blocks.block[reg->current_index]); if (block->is_ram_block) { host_addr = (block->local_host_addr + (reg->key.current_addr - block->offset)); chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) host_addr); } else { chunk = reg->key.chunk; host_addr = block->local_host_addr + (reg->key.chunk * (1UL << RDMA_REG_CHUNK_SHIFT)); } chunk_start = ram_chunk_start(block, chunk); chunk_end = ram_chunk_end(block, chunk + reg->chunks); if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *)host_addr, NULL, &reg_result->rkey, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get rkey!\n"); ret = -EINVAL; goto out; } reg_result->host_addr = (uint64_t) block->local_host_addr; DDPRINTF("Registered rkey for this request: %x\n", reg_result->rkey); result_to_network(reg_result); } ret = qemu_rdma_post_send_control(rdma, (uint8_t *) results, &reg_resp); if (ret < 0) { fprintf(stderr, "Failed to send control buffer!\n"); goto out; } break; case RDMA_CONTROL_UNREGISTER_REQUEST: DDPRINTF("There are %d unregistration requests\n", head.repeat); unreg_resp.repeat = head.repeat; registers = (RDMARegister *) rdma->wr_data[idx].control_curr; for (count = 0; count < head.repeat; count++) { reg = &registers[count]; network_to_register(reg); DDPRINTF("Unregistration request (%d): " " index %d, chunk %" PRIu64 "\n", count, reg->current_index, reg->key.chunk); block = &(rdma->local_ram_blocks.block[reg->current_index]); ret = ibv_dereg_mr(block->pmr[reg->key.chunk]); block->pmr[reg->key.chunk] = NULL; if (ret != 0) { perror("rdma unregistration chunk failed"); ret = -ret; goto out; } rdma->total_registrations--; DDPRINTF("Unregistered chunk %" PRIu64 " successfully.\n", reg->key.chunk); } ret = qemu_rdma_post_send_control(rdma, NULL, &unreg_resp); if (ret < 0) { fprintf(stderr, "Failed to send control buffer!\n"); goto out; } break; case RDMA_CONTROL_REGISTER_RESULT: fprintf(stderr, "Invalid RESULT message at dest.\n"); ret = -EIO; goto out; default: fprintf(stderr, "Unknown control message %s\n", control_desc[head.type]); ret = -EIO; goto out; } } while (1); out: if (ret < 0) { rdma->error_state = ret; } return ret; }
static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque, uint64_t flags) { RDMAControlHeader reg_resp = { .len = sizeof(RDMARegisterResult), .type = RDMA_CONTROL_REGISTER_RESULT, .repeat = 0, }; RDMAControlHeader unreg_resp = { .len = 0, .type = RDMA_CONTROL_UNREGISTER_FINISHED, .repeat = 0, }; RDMAControlHeader blocks = { .type = RDMA_CONTROL_RAM_BLOCKS_RESULT, .repeat = 1 }; QEMUFileRDMA *rfile = opaque; RDMAContext *rdma = rfile->rdma; RDMALocalBlocks *local = &rdma->local_ram_blocks; RDMAControlHeader head; RDMARegister *reg, *registers; RDMACompress *comp; RDMARegisterResult *reg_result; static RDMARegisterResult results[RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE]; RDMALocalBlock *block; void *host_addr; int ret = 0; int idx = 0; int count = 0; int i = 0; CHECK_ERROR_STATE(); do { DDDPRINTF("Waiting for next request %" PRIu64 "...\n", flags); ret = qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_NONE); if (ret < 0) { break; } if (head.repeat > RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE) { fprintf(stderr, "rdma: Too many requests in this message (%d)." "Bailing.\n", head.repeat); ret = -EIO; break; } switch (head.type) { case RDMA_CONTROL_COMPRESS: comp = (RDMACompress *) rdma->wr_data[idx].control_curr; network_to_compress(comp); DDPRINTF("Zapping zero chunk: %" PRId64 " bytes, index %d, offset %" PRId64 "\n", comp->length, comp->block_idx, comp->offset); block = &(rdma->local_ram_blocks.block[comp->block_idx]); host_addr = block->local_host_addr + (comp->offset - block->offset); ram_handle_compressed(host_addr, comp->value, comp->length); break; case RDMA_CONTROL_REGISTER_FINISHED: DDDPRINTF("Current registrations complete.\n"); goto out; case RDMA_CONTROL_RAM_BLOCKS_REQUEST: DPRINTF("Initial setup info requested.\n"); if (rdma->pin_all) { ret = qemu_rdma_reg_whole_ram_blocks(rdma); if (ret) { fprintf(stderr, "rdma migration: error dest " "registering ram blocks!\n"); goto out; } } for (i = 0; i < local->nb_blocks; i++) { rdma->block[i].remote_host_addr = (uint64_t)(local->block[i].local_host_addr); if (rdma->pin_all) { rdma->block[i].remote_rkey = local->block[i].mr->rkey; } rdma->block[i].offset = local->block[i].offset; rdma->block[i].length = local->block[i].length; remote_block_to_network(&rdma->block[i]); } blocks.len = rdma->local_ram_blocks.nb_blocks * sizeof(RDMARemoteBlock); ret = qemu_rdma_post_send_control(rdma, (uint8_t *) rdma->block, &blocks); if (ret < 0) { fprintf(stderr, "rdma migration: error sending remote info!\n"); goto out; } break; case RDMA_CONTROL_REGISTER_REQUEST: DDPRINTF("There are %d registration requests\n", head.repeat); reg_resp.repeat = head.repeat; registers = (RDMARegister *) rdma->wr_data[idx].control_curr; for (count = 0; count < head.repeat; count++) { uint64_t chunk; uint8_t *chunk_start, *chunk_end; reg = &registers[count]; network_to_register(reg); reg_result = &results[count]; DDPRINTF("Registration request (%d): index %d, current_addr %" PRIu64 " chunks: %" PRIu64 "\n", count, reg->current_index, reg->key.current_addr, reg->chunks); block = &(rdma->local_ram_blocks.block[reg->current_index]); if (block->is_ram_block) { host_addr = (block->local_host_addr + (reg->key.current_addr - block->offset)); chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) host_addr); } else { chunk = reg->key.chunk; host_addr = block->local_host_addr + (reg->key.chunk * (1UL << RDMA_REG_CHUNK_SHIFT)); } chunk_start = ram_chunk_start(block, chunk); chunk_end = ram_chunk_end(block, chunk + reg->chunks); if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *)host_addr, NULL, &reg_result->rkey, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get rkey!\n"); ret = -EINVAL; goto out; } reg_result->host_addr = (uint64_t) block->local_host_addr; DDPRINTF("Registered rkey for this request: %x\n", reg_result->rkey); result_to_network(reg_result); } ret = qemu_rdma_post_send_control(rdma, (uint8_t *) results, &reg_resp); if (ret < 0) { fprintf(stderr, "Failed to send control buffer!\n"); goto out; } break; case RDMA_CONTROL_UNREGISTER_REQUEST: DDPRINTF("There are %d unregistration requests\n", head.repeat); unreg_resp.repeat = head.repeat; registers = (RDMARegister *) rdma->wr_data[idx].control_curr; for (count = 0; count < head.repeat; count++) { reg = &registers[count]; network_to_register(reg); DDPRINTF("Unregistration request (%d): " " index %d, chunk %" PRIu64 "\n", count, reg->current_index, reg->key.chunk); block = &(rdma->local_ram_blocks.block[reg->current_index]); ret = ibv_dereg_mr(block->pmr[reg->key.chunk]); block->pmr[reg->key.chunk] = NULL; if (ret != 0) { perror("rdma unregistration chunk failed"); ret = -ret; goto out; } rdma->total_registrations--; DDPRINTF("Unregistered chunk %" PRIu64 " successfully.\n", reg->key.chunk); } ret = qemu_rdma_post_send_control(rdma, NULL, &unreg_resp); if (ret < 0) { fprintf(stderr, "Failed to send control buffer!\n"); goto out; } break; case RDMA_CONTROL_REGISTER_RESULT: fprintf(stderr, "Invalid RESULT message at dest.\n"); ret = -EIO; goto out; default: fprintf(stderr, "Unknown control message %s\n", control_desc[head.type]); ret = -EIO; goto out; } } while (1); out: if (ret < 0) { rdma->error_state = ret; } return ret; }
421
0
int IniSection::Write (const YCPPath&p, const YCPValue&v, bool rewrite) { if (ip->isFlat ()) return setValueFlat (p, v); if (p->length() >= 1 && p->component_str (0) == "all") { return setAll (p, v, 1); } if (p->length() < 2) { y2error ("I do not know what to write to %s.", p->toString().c_str()); return -1; } string s = p->component_str (0); if (s == "v" || s == "value") return setValue (p, v, 0, 1); if (s == "vc" || s == "value_comment" || s == "valuecomment") return setValue (p, v, 1, 1); if (s == "vt" || s == "value_type" || s == "valuetype") return setValue (p, v, 2, 1); if (s == "s" || s == "section" || s == "sc" || s == "section_comment" || s == "sectioncomment") return setSectionProp (p, v, 0, 1); if (s == "st" || s == "section_type" || s == "sectiontype") return setSectionProp (p, v, rewrite? 1:2, 1); if (s == "section_private") return setSectionProp (p, v, 3, 1); return -1; }
int IniSection::Write (const YCPPath&p, const YCPValue&v, bool rewrite) { if (ip->isFlat ()) return setValueFlat (p, v); if (p->length() >= 1 && p->component_str (0) == "all") { return setAll (p, v, 1); } if (p->length() < 2) { y2error ("I do not know what to write to %s.", p->toString().c_str()); return -1; } string s = p->component_str (0); if (s == "v" || s == "value") return setValue (p, v, 0, 1); if (s == "vc" || s == "value_comment" || s == "valuecomment") return setValue (p, v, 1, 1); if (s == "vt" || s == "value_type" || s == "valuetype") return setValue (p, v, 2, 1); if (s == "s" || s == "section" || s == "sc" || s == "section_comment" || s == "sectioncomment") return setSectionProp (p, v, 0, 1); if (s == "st" || s == "section_type" || s == "sectiontype") return setSectionProp (p, v, rewrite? 1:2, 1); if (s == "section_private") return setSectionProp (p, v, 3, 1); return -1; }
423
1
int udp_get_port(struct sock *sk, unsigned short snum, int (*scmp)(const struct sock *, const struct sock *)) { return __udp_lib_get_port(sk, snum, udp_hash, &udp_port_rover, scmp); }
int udp_get_port(struct sock *sk, unsigned short snum, int (*scmp)(const struct sock *, const struct sock *)) { return __udp_lib_get_port(sk, snum, udp_hash, &udp_port_rover, scmp); }
426
1
static int read_data(void *opaque, uint8_t *buf, int buf_size) { struct playlist *v = opaque; HLSContext *c = v->parent->priv_data; int ret, i; int just_opened = 0; restart: if (!v->needed) return AVERROR_EOF; if (!v->input) { int64_t reload_interval; struct segment *seg; /* Check that the playlist is still needed before opening a new * segment. */ if (v->ctx && v->ctx->nb_streams) { v->needed = 0; for (i = 0; i < v->n_main_streams; i++) { if (v->main_streams[i]->discard < AVDISCARD_ALL) { v->needed = 1; break; } } } if (!v->needed) { av_log(v->parent, AV_LOG_INFO, "No longer receiving playlist %d\n", v->index); return AVERROR_EOF; } /* If this is a live stream and the reload interval has elapsed since * the last playlist reload, reload the playlists now. */ reload_interval = default_reload_interval(v); reload: reload_count++; if (reload_count > c->max_reload) return AVERROR_EOF; if (!v->finished && av_gettime_relative() - v->last_load_time >= reload_interval) { if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) { av_log(v->parent, AV_LOG_WARNING, "Failed to reload playlist %d\n", v->index); return ret; } /* If we need to reload the playlist again below (if * there's still no more segments), switch to a reload * interval of half the target duration. */ reload_interval = v->target_duration / 2; } if (v->cur_seq_no < v->start_seq_no) { av_log(NULL, AV_LOG_WARNING, "skipping %d segments ahead, expired from playlists\n", v->start_seq_no - v->cur_seq_no); v->cur_seq_no = v->start_seq_no; } if (v->cur_seq_no >= v->start_seq_no + v->n_segments) { if (v->finished) return AVERROR_EOF; while (av_gettime_relative() - v->last_load_time < reload_interval) { if (ff_check_interrupt(c->interrupt_callback)) return AVERROR_EXIT; av_usleep(100*1000); } /* Enough time has elapsed since the last reload */ goto reload; } seg = current_segment(v); /* load/update Media Initialization Section, if any */ ret = update_init_section(v, seg); if (ret) return ret; ret = open_input(c, v, seg); if (ret < 0) { if (ff_check_interrupt(c->interrupt_callback)) return AVERROR_EXIT; av_log(v->parent, AV_LOG_WARNING, "Failed to open segment of playlist %d\n", v->index); v->cur_seq_no += 1; goto reload; } just_opened = 1; } if (v->init_sec_buf_read_offset < v->init_sec_data_len) { /* Push init section out first before first actual segment */ int copy_size = FFMIN(v->init_sec_data_len - v->init_sec_buf_read_offset, buf_size); memcpy(buf, v->init_sec_buf, copy_size); v->init_sec_buf_read_offset += copy_size; return copy_size; } ret = read_from_url(v, current_segment(v), buf, buf_size, READ_NORMAL); if (ret > 0) { if (just_opened && v->is_id3_timestamped != 0) { /* Intercept ID3 tags here, elementary audio streams are required * to convey timestamps using them in the beginning of each segment. */ intercept_id3(v, buf, buf_size, &ret); } return ret; } ff_format_io_close(v->parent, &v->input); v->cur_seq_no++; c->cur_seq_no = v->cur_seq_no; goto restart; }
static int read_data(void *opaque, uint8_t *buf, int buf_size) { struct playlist *v = opaque; HLSContext *c = v->parent->priv_data; int ret, i; int just_opened = 0; restart: if (!v->needed) return AVERROR_EOF; if (!v->input) { int64_t reload_interval; struct segment *seg; if (v->ctx && v->ctx->nb_streams) { v->needed = 0; for (i = 0; i < v->n_main_streams; i++) { if (v->main_streams[i]->discard < AVDISCARD_ALL) { v->needed = 1; break; } } } if (!v->needed) { av_log(v->parent, AV_LOG_INFO, "No longer receiving playlist %d\n", v->index); return AVERROR_EOF; } reload_interval = default_reload_interval(v); reload: reload_count++; if (reload_count > c->max_reload) return AVERROR_EOF; if (!v->finished && av_gettime_relative() - v->last_load_time >= reload_interval) { if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) { av_log(v->parent, AV_LOG_WARNING, "Failed to reload playlist %d\n", v->index); return ret; } reload_interval = v->target_duration / 2; } if (v->cur_seq_no < v->start_seq_no) { av_log(NULL, AV_LOG_WARNING, "skipping %d segments ahead, expired from playlists\n", v->start_seq_no - v->cur_seq_no); v->cur_seq_no = v->start_seq_no; } if (v->cur_seq_no >= v->start_seq_no + v->n_segments) { if (v->finished) return AVERROR_EOF; while (av_gettime_relative() - v->last_load_time < reload_interval) { if (ff_check_interrupt(c->interrupt_callback)) return AVERROR_EXIT; av_usleep(100*1000); } goto reload; } seg = current_segment(v); ret = update_init_section(v, seg); if (ret) return ret; ret = open_input(c, v, seg); if (ret < 0) { if (ff_check_interrupt(c->interrupt_callback)) return AVERROR_EXIT; av_log(v->parent, AV_LOG_WARNING, "Failed to open segment of playlist %d\n", v->index); v->cur_seq_no += 1; goto reload; } just_opened = 1; } if (v->init_sec_buf_read_offset < v->init_sec_data_len) { int copy_size = FFMIN(v->init_sec_data_len - v->init_sec_buf_read_offset, buf_size); memcpy(buf, v->init_sec_buf, copy_size); v->init_sec_buf_read_offset += copy_size; return copy_size; } ret = read_from_url(v, current_segment(v), buf, buf_size, READ_NORMAL); if (ret > 0) { if (just_opened && v->is_id3_timestamped != 0) { intercept_id3(v, buf, buf_size, &ret); } return ret; } ff_format_io_close(v->parent, &v->input); v->cur_seq_no++; c->cur_seq_no = v->cur_seq_no; goto restart; }
427
0
hb_set_t * hb_set_reference ( hb_set_t * set ) { return hb_object_reference ( set ) ; }
hb_set_t * hb_set_reference ( hb_set_t * set ) { return hb_object_reference ( set ) ; }
428
1
spnego_gss_set_sec_context_option( OM_uint32 *minor_status, gss_ctx_id_t *context_handle, const gss_OID desired_object, const gss_buffer_t value) { OM_uint32 ret; ret = gss_set_sec_context_option(minor_status, context_handle, desired_object, value); return (ret); }
spnego_gss_set_sec_context_option( OM_uint32 *minor_status, gss_ctx_id_t *context_handle, const gss_OID desired_object, const gss_buffer_t value) { OM_uint32 ret; ret = gss_set_sec_context_option(minor_status, context_handle, desired_object, value); return (ret); }
429
1
int IniSection::setSectionProp (const YCPPath&p,const YCPValue&in, int what, int depth) { string k = ip->changeCase (p->component_str (depth)); // Find the matching sections. // If we need to recurse, choose one, creating if necessary // Otherwise set properties of all of the leaf sections, // creating and deleting if the number of them does not match pair <IniSectionIdxIterator, IniSectionIdxIterator> r = isections.equal_range (k); IniSectionIdxIterator xi = r.first, xe = r.second; if (depth + 1 < p->length()) { // recurse IniIterator si; if (xi == xe) { // not found, need to add it; y2debug ("Write: adding recursively %s to %s", k.c_str (), p->toString().c_str()); IniSection s (ip, k); container.push_back (IniContainerElement (s)); isections.insert (IniSectionIndex::value_type (k, --container.end ())); si = --container.end (); } else { // there's something, choose last si = (--xe)->second; } return si->s ().setSectionProp (p, in, what, depth+1); } else { // bottom level // make sure we have a list of values YCPList props; if (ip->repeatNames ()) { props = as_list (in, "property of section with repeat_names"); if (props.isNull()) return -1; } else { props->add (in); } int pi = 0, pe = props->size (); // Go simultaneously through the found sections // and the list of parameters, while _either_ lasts // Fewer sections-> add them, more sections-> delete them while (pi != pe || xi != xe) { // watch out for validity of iterators! if (pi == pe) { // deleting a section delSection1 (xi++); // no ++pi } else { YCPValue prop = props->value (pi); IniIterator si; if (xi == xe) { ///need to add a section ... y2debug ("Adding section %s", p->toString().c_str()); // prepare it to have its property set // create it IniSection s (ip, k); s.dirty = true; // insert and index container.push_back (IniContainerElement (s)); isections.insert (IniSectionIndex::value_type (k, --container.end ())); si = --container.end (); } else { si = xi->second; } // set a section's property IniSection & s = si->s (); if (what == 0) { YCPString str = as_string (prop, "section_comment"); if (str.isNull()) return -1; s.setComment (str->value_cstr()); } else if (what == 1) { YCPInteger i = as_integer (prop, "section_rewrite"); if (i.isNull()) return -1; s.setRewriteBy (i->value()); } else { YCPInteger i = as_integer (prop, "section_type"); if (i.isNull()) return -1; s.setReadBy (i->value()); } if (xi != xe) { ++xi; } ++pi; } // iterators have been advanced already } return 0; } }
int IniSection::setSectionProp (const YCPPath&p,const YCPValue&in, int what, int depth) { string k = ip->changeCase (p->component_str (depth)); pair <IniSectionIdxIterator, IniSectionIdxIterator> r = isections.equal_range (k); IniSectionIdxIterator xi = r.first, xe = r.second; if (depth + 1 < p->length()) { IniIterator si; if (xi == xe) { y2debug ("Write: adding recursively %s to %s", k.c_str (), p->toString().c_str()); IniSection s (ip, k); container.push_back (IniContainerElement (s)); isections.insert (IniSectionIndex::value_type (k, --container.end ())); si = --container.end (); } else { si = (--xe)->second; } return si->s ().setSectionProp (p, in, what, depth+1); } else { YCPList props; if (ip->repeatNames ()) { props = as_list (in, "property of section with repeat_names"); if (props.isNull()) return -1; } else { props->add (in); } int pi = 0, pe = props->size (); while (pi != pe || xi != xe) { if (pi == pe) { delSection1 (xi++); } else { YCPValue prop = props->value (pi); IniIterator si; if (xi == xe) { y2debug ("Adding section %s", p->toString().c_str()); IniSection s (ip, k); s.dirty = true; container.push_back (IniContainerElement (s)); isections.insert (IniSectionIndex::value_type (k, --container.end ())); si = --container.end (); } else { si = xi->second; } IniSection & s = si->s (); if (what == 0) { YCPString str = as_string (prop, "section_comment"); if (str.isNull()) return -1; s.setComment (str->value_cstr()); } else if (what == 1) { YCPInteger i = as_integer (prop, "section_rewrite"); if (i.isNull()) return -1; s.setRewriteBy (i->value()); } else { YCPInteger i = as_integer (prop, "section_type"); if (i.isNull()) return -1; s.setReadBy (i->value()); } if (xi != xe) { ++xi; } ++pi; } } return 0; } }
430
1
static void put_swf_matrix(ByteIOContext *pb, int a, int b, int c, int d, int tx, int ty) { PutBitContext p; uint8_t buf[256]; init_put_bits(&p, buf, sizeof(buf)); put_bits(&p, 1, 1); /* a, d present */ put_bits(&p, 5, 20); /* nb bits */ put_bits(&p, 20, a); put_bits(&p, 20, d); put_bits(&p, 1, 1); /* b, c present */ put_bits(&p, 5, 20); /* nb bits */ put_bits(&p, 20, c); put_bits(&p, 20, b); put_bits(&p, 5, 20); /* nb bits */ put_bits(&p, 20, tx); put_bits(&p, 20, ty); flush_put_bits(&p); put_buffer(pb, buf, pbBufPtr(&p) - p.buf); }
static void put_swf_matrix(ByteIOContext *pb, int a, int b, int c, int d, int tx, int ty) { PutBitContext p; uint8_t buf[256]; init_put_bits(&p, buf, sizeof(buf)); put_bits(&p, 1, 1); put_bits(&p, 5, 20); put_bits(&p, 20, a); put_bits(&p, 20, d); put_bits(&p, 1, 1); put_bits(&p, 5, 20); put_bits(&p, 20, c); put_bits(&p, 20, b); put_bits(&p, 5, 20); put_bits(&p, 20, tx); put_bits(&p, 20, ty); flush_put_bits(&p); put_buffer(pb, buf, pbBufPtr(&p) - p.buf); }
431
0
int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame) { NVDECContext *ctx = avctx->internal->hwaccel_priv_data; FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data; NVDECFrame *cf = NULL; int ret; ctx->bitstream_len = 0; ctx->nb_slices = 0; if (fdd->hwaccel_priv) return 0; cf = av_mallocz(sizeof(*cf)); if (!cf) return AVERROR(ENOMEM); cf->decoder_ref = av_buffer_ref(ctx->decoder_ref); if (!cf->decoder_ref) goto fail; cf->idx_ref = av_buffer_pool_get(ctx->decoder_pool); if (!cf->idx_ref) { av_log(avctx, AV_LOG_ERROR, "No decoder surfaces left\n"); ret = AVERROR(ENOMEM); goto fail; } cf->idx = *(unsigned int*)cf->idx_ref->data; fdd->hwaccel_priv = cf; fdd->hwaccel_priv_free = nvdec_fdd_priv_free; fdd->post_process = nvdec_retrieve_data; return 0; fail: nvdec_fdd_priv_free(cf); return ret; }
int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame) { NVDECContext *ctx = avctx->internal->hwaccel_priv_data; FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data; NVDECFrame *cf = NULL; int ret; ctx->bitstream_len = 0; ctx->nb_slices = 0; if (fdd->hwaccel_priv) return 0; cf = av_mallocz(sizeof(*cf)); if (!cf) return AVERROR(ENOMEM); cf->decoder_ref = av_buffer_ref(ctx->decoder_ref); if (!cf->decoder_ref) goto fail; cf->idx_ref = av_buffer_pool_get(ctx->decoder_pool); if (!cf->idx_ref) { av_log(avctx, AV_LOG_ERROR, "No decoder surfaces left\n"); ret = AVERROR(ENOMEM); goto fail; } cf->idx = *(unsigned int*)cf->idx_ref->data; fdd->hwaccel_priv = cf; fdd->hwaccel_priv_free = nvdec_fdd_priv_free; fdd->post_process = nvdec_retrieve_data; return 0; fail: nvdec_fdd_priv_free(cf); return ret; }
433
1
int __udp_lib_get_port(struct sock *sk, unsigned short snum, struct hlist_head udptable[], int *port_rover, int (*saddr_comp)(const struct sock *sk1, const struct sock *sk2 ) ) { struct hlist_node *node; struct hlist_head *head; struct sock *sk2; int error = 1; write_lock_bh(&udp_hash_lock); if (snum == 0) { int best_size_so_far, best, result, i; if (*port_rover > sysctl_local_port_range[1] || *port_rover < sysctl_local_port_range[0]) *port_rover = sysctl_local_port_range[0]; best_size_so_far = 32767; best = result = *port_rover; for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) { int size; head = &udptable[result & (UDP_HTABLE_SIZE - 1)]; if (hlist_empty(head)) { if (result > sysctl_local_port_range[1]) result = sysctl_local_port_range[0] + ((result - sysctl_local_port_range[0]) & (UDP_HTABLE_SIZE - 1)); goto gotit; } size = 0; sk_for_each(sk2, node, head) { if (++size >= best_size_so_far) goto next; } best_size_so_far = size; best = result; next: ; } result = best; for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) { if (result > sysctl_local_port_range[1]) result = sysctl_local_port_range[0] + ((result - sysctl_local_port_range[0]) & (UDP_HTABLE_SIZE - 1)); if (! __udp_lib_lport_inuse(result, udptable)) break; } if (i >= (1 << 16) / UDP_HTABLE_SIZE) goto fail; gotit: *port_rover = snum = result; } else { head = &udptable[snum & (UDP_HTABLE_SIZE - 1)]; sk_for_each(sk2, node, head) if (sk2->sk_hash == snum && sk2 != sk && (!sk2->sk_reuse || !sk->sk_reuse) && (!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if || sk2->sk_bound_dev_if == sk->sk_bound_dev_if) && (*saddr_comp)(sk, sk2) ) goto fail; } inet_sk(sk)->num = snum; sk->sk_hash = snum; if (sk_unhashed(sk)) { head = &udptable[snum & (UDP_HTABLE_SIZE - 1)]; sk_add_node(sk, head); sock_prot_inc_use(sk->sk_prot); } error = 0; fail: write_unlock_bh(&udp_hash_lock); return error; }
int __udp_lib_get_port(struct sock *sk, unsigned short snum, struct hlist_head udptable[], int *port_rover, int (*saddr_comp)(const struct sock *sk1, const struct sock *sk2 ) ) { struct hlist_node *node; struct hlist_head *head; struct sock *sk2; int error = 1; write_lock_bh(&udp_hash_lock); if (snum == 0) { int best_size_so_far, best, result, i; if (*port_rover > sysctl_local_port_range[1] || *port_rover < sysctl_local_port_range[0]) *port_rover = sysctl_local_port_range[0]; best_size_so_far = 32767; best = result = *port_rover; for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) { int size; head = &udptable[result & (UDP_HTABLE_SIZE - 1)]; if (hlist_empty(head)) { if (result > sysctl_local_port_range[1]) result = sysctl_local_port_range[0] + ((result - sysctl_local_port_range[0]) & (UDP_HTABLE_SIZE - 1)); goto gotit; } size = 0; sk_for_each(sk2, node, head) { if (++size >= best_size_so_far) goto next; } best_size_so_far = size; best = result; next: ; } result = best; for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) { if (result > sysctl_local_port_range[1]) result = sysctl_local_port_range[0] + ((result - sysctl_local_port_range[0]) & (UDP_HTABLE_SIZE - 1)); if (! __udp_lib_lport_inuse(result, udptable)) break; } if (i >= (1 << 16) / UDP_HTABLE_SIZE) goto fail; gotit: *port_rover = snum = result; } else { head = &udptable[snum & (UDP_HTABLE_SIZE - 1)]; sk_for_each(sk2, node, head) if (sk2->sk_hash == snum && sk2 != sk && (!sk2->sk_reuse || !sk->sk_reuse) && (!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if || sk2->sk_bound_dev_if == sk->sk_bound_dev_if) && (*saddr_comp)(sk, sk2) ) goto fail; } inet_sk(sk)->num = snum; sk->sk_hash = snum; if (sk_unhashed(sk)) { head = &udptable[snum & (UDP_HTABLE_SIZE - 1)]; sk_add_node(sk, head); sock_prot_inc_use(sk->sk_prot); } error = 0; fail: write_unlock_bh(&udp_hash_lock); return error; }
434
0
YCPBoolean as_boolean (const YCPValue& v, const char * context) { if (v->isBoolean ()) return v->asBoolean (); ycp2error ("Expected a boolean for %s, got %s %s", context, v->valuetype_str(), v->toString().c_str()); return YCPNull (); }
YCPBoolean as_boolean (const YCPValue& v, const char * context) { if (v->isBoolean ()) return v->asBoolean (); ycp2error ("Expected a boolean for %s, got %s %s", context, v->valuetype_str(), v->toString().c_str()); return YCPNull (); }
436
0
void proto_reg_handoff_zbee_zcl_basic ( void ) { dissector_handle_t basic_handle ; basic_handle = find_dissector ( ZBEE_PROTOABBREV_ZCL_BASIC ) ; dissector_add_uint ( "zbee.zcl.cluster" , ZBEE_ZCL_CID_BASIC , basic_handle ) ; zbee_zcl_init_cluster ( proto_zbee_zcl_basic , ett_zbee_zcl_basic , ZBEE_ZCL_CID_BASIC , hf_zbee_zcl_basic_attr_id , hf_zbee_zcl_basic_srv_rx_cmd_id , - 1 , ( zbee_zcl_fn_attr_data ) dissect_zcl_basic_attr_data ) ; }
void proto_reg_handoff_zbee_zcl_basic ( void ) { dissector_handle_t basic_handle ; basic_handle = find_dissector ( ZBEE_PROTOABBREV_ZCL_BASIC ) ; dissector_add_uint ( "zbee.zcl.cluster" , ZBEE_ZCL_CID_BASIC , basic_handle ) ; zbee_zcl_init_cluster ( proto_zbee_zcl_basic , ett_zbee_zcl_basic , ZBEE_ZCL_CID_BASIC , hf_zbee_zcl_basic_attr_id , hf_zbee_zcl_basic_srv_rx_cmd_id , - 1 , ( zbee_zcl_fn_attr_data ) dissect_zcl_basic_attr_data ) ; }
437
1
static inline int __udp_lib_lport_inuse(__u16 num, struct hlist_head udptable[]) { struct sock *sk; struct hlist_node *node; sk_for_each(sk, node, &udptable[num & (UDP_HTABLE_SIZE - 1)]) if (sk->sk_hash == num) return 1; return 0; }
static inline int __udp_lib_lport_inuse(__u16 num, struct hlist_head udptable[]) { struct sock *sk; struct hlist_node *node; sk_for_each(sk, node, &udptable[num & (UDP_HTABLE_SIZE - 1)]) if (sk->sk_hash == num) return 1; return 0; }
438
1
spnego_gss_unwrap( OM_uint32 *minor_status, gss_ctx_id_t context_handle, gss_buffer_t input_message_buffer, gss_buffer_t output_message_buffer, int *conf_state, gss_qop_t *qop_state) { OM_uint32 ret; ret = gss_unwrap(minor_status, context_handle, input_message_buffer, output_message_buffer, conf_state, qop_state); return (ret); }
spnego_gss_unwrap( OM_uint32 *minor_status, gss_ctx_id_t context_handle, gss_buffer_t input_message_buffer, gss_buffer_t output_message_buffer, int *conf_state, gss_qop_t *qop_state) { OM_uint32 ret; ret = gss_unwrap(minor_status, context_handle, input_message_buffer, output_message_buffer, conf_state, qop_state); return (ret); }
439
0
IniSection (const IniParser *p, string n) : IniBase (n), ip (p), end_comment (), is_private(false), rewrite_by(0), container(), ivalues (), isections () {}
IniSection (const IniParser *p, string n) : IniBase (n), ip (p), end_comment (), is_private(false), rewrite_by(0), container(), ivalues (), isections () {}
440
0
static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) { MOVFragment *frag = &c->fragment; AVStream *st = c->fc->streams[frag->track_id-1]; MOVStreamContext *sc = st->priv_data; uint64_t offset; int64_t dts; int data_offset = 0; unsigned entries, first_sample_flags = frag->flags; int flags, distance, i; if (sc->pseudo_stream_id+1 != frag->stsd_id) return 0; if (!st->nb_index_entries) return -1; get_byte(pb); /* version */ flags = get_be24(pb); entries = get_be32(pb); dprintf(c->fc, "flags 0x%x entries %d\n", flags, entries); if (flags & 0x001) data_offset = get_be32(pb); if (flags & 0x004) first_sample_flags = get_be32(pb); if (flags & 0x800) { if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data)) return -1; sc->ctts_data = av_realloc(sc->ctts_data, (entries+sc->ctts_count)*sizeof(*sc->ctts_data)); if (!sc->ctts_data) return AVERROR(ENOMEM); } dts = st->duration; offset = frag->base_data_offset + data_offset; distance = 0; dprintf(c->fc, "first sample flags 0x%x\n", first_sample_flags); for (i = 0; i < entries; i++) { unsigned sample_size = frag->size; int sample_flags = i ? frag->flags : first_sample_flags; unsigned sample_duration = frag->duration; int keyframe; if (flags & 0x100) sample_duration = get_be32(pb); if (flags & 0x200) sample_size = get_be32(pb); if (flags & 0x400) sample_flags = get_be32(pb); if (flags & 0x800) { sc->ctts_data[sc->ctts_count].count = 1; sc->ctts_data[sc->ctts_count].duration = get_be32(pb); sc->ctts_count++; } if ((keyframe = st->codec->codec_type == CODEC_TYPE_AUDIO || (flags & 0x004 && !i && !sample_flags) || sample_flags & 0x2000000)) distance = 0; av_add_index_entry(st, offset, dts, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0); dprintf(c->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", " "size %d, distance %d, keyframe %d\n", st->index, sc->sample_count+i, offset, dts, sample_size, distance, keyframe); distance++; assert(sample_duration % sc->time_rate == 0); dts += sample_duration / sc->time_rate; offset += sample_size; } frag->moof_offset = offset; sc->sample_count = st->nb_index_entries; st->duration = dts; return 0; }
static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) { MOVFragment *frag = &c->fragment; AVStream *st = c->fc->streams[frag->track_id-1]; MOVStreamContext *sc = st->priv_data; uint64_t offset; int64_t dts; int data_offset = 0; unsigned entries, first_sample_flags = frag->flags; int flags, distance, i; if (sc->pseudo_stream_id+1 != frag->stsd_id) return 0; if (!st->nb_index_entries) return -1; get_byte(pb); flags = get_be24(pb); entries = get_be32(pb); dprintf(c->fc, "flags 0x%x entries %d\n", flags, entries); if (flags & 0x001) data_offset = get_be32(pb); if (flags & 0x004) first_sample_flags = get_be32(pb); if (flags & 0x800) { if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data)) return -1; sc->ctts_data = av_realloc(sc->ctts_data, (entries+sc->ctts_count)*sizeof(*sc->ctts_data)); if (!sc->ctts_data) return AVERROR(ENOMEM); } dts = st->duration; offset = frag->base_data_offset + data_offset; distance = 0; dprintf(c->fc, "first sample flags 0x%x\n", first_sample_flags); for (i = 0; i < entries; i++) { unsigned sample_size = frag->size; int sample_flags = i ? frag->flags : first_sample_flags; unsigned sample_duration = frag->duration; int keyframe; if (flags & 0x100) sample_duration = get_be32(pb); if (flags & 0x200) sample_size = get_be32(pb); if (flags & 0x400) sample_flags = get_be32(pb); if (flags & 0x800) { sc->ctts_data[sc->ctts_count].count = 1; sc->ctts_data[sc->ctts_count].duration = get_be32(pb); sc->ctts_count++; } if ((keyframe = st->codec->codec_type == CODEC_TYPE_AUDIO || (flags & 0x004 && !i && !sample_flags) || sample_flags & 0x2000000)) distance = 0; av_add_index_entry(st, offset, dts, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0); dprintf(c->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", " "size %d, distance %d, keyframe %d\n", st->index, sc->sample_count+i, offset, dts, sample_size, distance, keyframe); distance++; assert(sample_duration % sc->time_rate == 0); dts += sample_duration / sc->time_rate; offset += sample_size; } frag->moof_offset = offset; sc->sample_count = st->nb_index_entries; st->duration = dts; return 0; }
441
1
static inline void native_set_ldt(const void *addr, unsigned int entries) { if (likely(entries == 0)) asm volatile("lldt %w0"::"q" (0)); else { unsigned cpu = smp_processor_id(); ldt_desc ldt; set_tssldt_descriptor(&ldt, (unsigned long)addr, DESC_LDT, entries * sizeof(ldt) - 1); write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, &ldt, DESC_LDT); asm volatile("lldt %w0"::"q" (GDT_ENTRY_LDT*8)); } }
static inline void native_set_ldt(const void *addr, unsigned int entries) { if (likely(entries == 0)) asm volatile("lldt %w0"::"q" (0)); else { unsigned cpu = smp_processor_id(); ldt_desc ldt; set_tssldt_descriptor(&ldt, (unsigned long)addr, DESC_LDT, entries * sizeof(ldt) - 1); write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, &ldt, DESC_LDT); asm volatile("lldt %w0"::"q" (GDT_ENTRY_LDT*8)); } }
442
0
void mpv_decode_mb_internal(MpegEncContext *s, int16_t block[12][64], int is_mpeg12) { const int mb_xy = s->mb_y * s->mb_stride + s->mb_x; #if FF_API_XVMC FF_DISABLE_DEPRECATION_WARNINGS if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){ ff_xvmc_decode_mb(s);//xvmc uses pblocks return; } FF_ENABLE_DEPRECATION_WARNINGS #endif /* FF_API_XVMC */ if(s->avctx->debug&FF_DEBUG_DCT_COEFF) { /* print DCT coefficients */ int i,j; av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y); for(i=0; i<6; i++){ for(j=0; j<64; j++){ av_log(s->avctx, AV_LOG_DEBUG, "%5d", block[i][s->idsp.idct_permutation[j]]); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); } } s->current_picture.qscale_table[mb_xy] = s->qscale; /* update DC predictors for P macroblocks */ if (!s->mb_intra) { if (!is_mpeg12 && (s->h263_pred || s->h263_aic)) { if(s->mbintra_table[mb_xy]) ff_clean_intra_table_entries(s); } else { s->last_dc[0] = s->last_dc[1] = s->last_dc[2] = 128 << s->intra_dc_precision; } } else if (!is_mpeg12 && (s->h263_pred || s->h263_aic)) s->mbintra_table[mb_xy]=1; if ((s->avctx->flags & AV_CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type == AV_PICTURE_TYPE_B) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { // FIXME precalc uint8_t *dest_y, *dest_cb, *dest_cr; int dct_linesize, dct_offset; op_pixels_func (*op_pix)[4]; qpel_mc_func (*op_qpix)[16]; const int linesize = s->current_picture.f->linesize[0]; //not s->linesize as this would be wrong for field pics const int uvlinesize = s->current_picture.f->linesize[1]; const int readable= s->pict_type != AV_PICTURE_TYPE_B || s->encoding || s->avctx->draw_horiz_band; const int block_size = 8; /* avoid copy if macroblock skipped in last frame too */ /* skip only during decoding as we might trash the buffers during encoding a bit */ if(!s->encoding){ uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy]; if (s->mb_skipped) { s->mb_skipped= 0; assert(s->pict_type!=AV_PICTURE_TYPE_I); *mbskip_ptr = 1; } else if(!s->current_picture.reference) { *mbskip_ptr = 1; } else{ *mbskip_ptr = 0; /* not skipped */ } } dct_linesize = linesize << s->interlaced_dct; dct_offset = s->interlaced_dct ? linesize : linesize * block_size; if(readable){ dest_y= s->dest[0]; dest_cb= s->dest[1]; dest_cr= s->dest[2]; }else{ dest_y = s->sc.b_scratchpad; dest_cb= s->sc.b_scratchpad+16*linesize; dest_cr= s->sc.b_scratchpad+32*linesize; } if (!s->mb_intra) { /* motion handling */ /* decoding or more than one mb_type (MC was already done otherwise) */ if(!s->encoding){ if(HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) { if (s->mv_dir & MV_DIR_FORWARD) { ff_thread_await_progress(&s->last_picture_ptr->tf, lowest_referenced_row(s, 0), 0); } if (s->mv_dir & MV_DIR_BACKWARD) { ff_thread_await_progress(&s->next_picture_ptr->tf, lowest_referenced_row(s, 1), 0); } } op_qpix= s->me.qpel_put; if ((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){ op_pix = s->hdsp.put_pixels_tab; }else{ op_pix = s->hdsp.put_no_rnd_pixels_tab; } if (s->mv_dir & MV_DIR_FORWARD) { ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f->data, op_pix, op_qpix); op_pix = s->hdsp.avg_pixels_tab; op_qpix= s->me.qpel_avg; } if (s->mv_dir & MV_DIR_BACKWARD) { ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f->data, op_pix, op_qpix); } } /* skip dequant / idct if we are really late ;) */ if(s->avctx->skip_idct){ if( (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) || s->avctx->skip_idct >= AVDISCARD_ALL) goto skip_idct; } /* add dct residue */ if(s->encoding || !( s->msmpeg4_version || s->codec_id==AV_CODEC_ID_MPEG1VIDEO || s->codec_id==AV_CODEC_ID_MPEG2VIDEO || (s->codec_id==AV_CODEC_ID_MPEG4 && !s->mpeg_quant))){ add_dequant_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale); add_dequant_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale); add_dequant_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale); add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale); if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { if (s->chroma_y_shift){ add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale); add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale); }else{ dct_linesize >>= 1; dct_offset >>=1; add_dequant_dct(s, block[4], 4, dest_cb, dct_linesize, s->chroma_qscale); add_dequant_dct(s, block[5], 5, dest_cr, dct_linesize, s->chroma_qscale); add_dequant_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale); add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale); } } } else if(is_mpeg12 || (s->codec_id != AV_CODEC_ID_WMV2)){ add_dct(s, block[0], 0, dest_y , dct_linesize); add_dct(s, block[1], 1, dest_y + block_size, dct_linesize); add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize); add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize); if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { if(s->chroma_y_shift){//Chroma420 add_dct(s, block[4], 4, dest_cb, uvlinesize); add_dct(s, block[5], 5, dest_cr, uvlinesize); }else{ //chroma422 dct_linesize = uvlinesize << s->interlaced_dct; dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize * 8; add_dct(s, block[4], 4, dest_cb, dct_linesize); add_dct(s, block[5], 5, dest_cr, dct_linesize); add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize); add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize); if(!s->chroma_x_shift){//Chroma444 add_dct(s, block[8], 8, dest_cb+8, dct_linesize); add_dct(s, block[9], 9, dest_cr+8, dct_linesize); add_dct(s, block[10], 10, dest_cb+8+dct_offset, dct_linesize); add_dct(s, block[11], 11, dest_cr+8+dct_offset, dct_linesize); } } }//fi gray } else if (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) { ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr); } } else { /* dct only in intra block */ if(s->encoding || !(s->codec_id==AV_CODEC_ID_MPEG1VIDEO || s->codec_id==AV_CODEC_ID_MPEG2VIDEO)){ put_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale); put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale); put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale); put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale); if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { if(s->chroma_y_shift){ put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale); put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale); }else{ dct_offset >>=1; dct_linesize >>=1; put_dct(s, block[4], 4, dest_cb, dct_linesize, s->chroma_qscale); put_dct(s, block[5], 5, dest_cr, dct_linesize, s->chroma_qscale); put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale); put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale); } } }else{ s->idsp.idct_put(dest_y, dct_linesize, block[0]); s->idsp.idct_put(dest_y + block_size, dct_linesize, block[1]); s->idsp.idct_put(dest_y + dct_offset, dct_linesize, block[2]); s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]); if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { if(s->chroma_y_shift){ s->idsp.idct_put(dest_cb, uvlinesize, block[4]); s->idsp.idct_put(dest_cr, uvlinesize, block[5]); }else{ dct_linesize = uvlinesize << s->interlaced_dct; dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize * 8; s->idsp.idct_put(dest_cb, dct_linesize, block[4]); s->idsp.idct_put(dest_cr, dct_linesize, block[5]); s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]); s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]); if(!s->chroma_x_shift){//Chroma444 s->idsp.idct_put(dest_cb + 8, dct_linesize, block[8]); s->idsp.idct_put(dest_cr + 8, dct_linesize, block[9]); s->idsp.idct_put(dest_cb + 8 + dct_offset, dct_linesize, block[10]); s->idsp.idct_put(dest_cr + 8 + dct_offset, dct_linesize, block[11]); } } }//gray } } skip_idct: if(!readable){ s->hdsp.put_pixels_tab[0][0](s->dest[0], dest_y , linesize,16); s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], dest_cb, uvlinesize,16 >> s->chroma_y_shift); s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[2], dest_cr, uvlinesize,16 >> s->chroma_y_shift); } } }
void mpv_decode_mb_internal(MpegEncContext *s, int16_t block[12][64], int is_mpeg12) { const int mb_xy = s->mb_y * s->mb_stride + s->mb_x; #if FF_API_XVMC FF_DISABLE_DEPRECATION_WARNINGS if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){ ff_xvmc_decode_mb(s);
443
0
static void draw_line ( uint8_t * buf , int sx , int sy , int ex , int ey , int w , int h , int stride , int color ) { int x , y , fr , f ; sx = av_clip ( sx , 0 , w - 1 ) ; sy = av_clip ( sy , 0 , h - 1 ) ; ex = av_clip ( ex , 0 , w - 1 ) ; ey = av_clip ( ey , 0 , h - 1 ) ; buf [ sy * stride + sx ] += color ; if ( FFABS ( ex - sx ) > FFABS ( ey - sy ) ) { if ( sx > ex ) { FFSWAP ( int , sx , ex ) ; FFSWAP ( int , sy , ey ) ; } buf += sx + sy * stride ; ex -= sx ; f = ( ( ey - sy ) << 16 ) / ex ; for ( x = 0 ; x <= ex ; x ++ ) { y = ( x * f ) >> 16 ; fr = ( x * f ) & 0xFFFF ; buf [ y * stride + x ] += ( color * ( 0x10000 - fr ) ) >> 16 ; buf [ ( y + 1 ) * stride + x ] += ( color * fr ) >> 16 ; } } else { if ( sy > ey ) { FFSWAP ( int , sx , ex ) ; FFSWAP ( int , sy , ey ) ; } buf += sx + sy * stride ; ey -= sy ; if ( ey ) f = ( ( ex - sx ) << 16 ) / ey ; else f = 0 ; for ( y = 0 ; y = ey ; y ++ ) { x = ( y * f ) >> 16 ; fr = ( y * f ) & 0xFFFF ; buf [ y * stride + x ] += ( color * ( 0x10000 - fr ) ) >> 16 ; buf [ y * stride + x + 1 ] += ( color * fr ) >> 16 ; } } }
static void draw_line ( uint8_t * buf , int sx , int sy , int ex , int ey , int w , int h , int stride , int color ) { int x , y , fr , f ; sx = av_clip ( sx , 0 , w - 1 ) ; sy = av_clip ( sy , 0 , h - 1 ) ; ex = av_clip ( ex , 0 , w - 1 ) ; ey = av_clip ( ey , 0 , h - 1 ) ; buf [ sy * stride + sx ] += color ; if ( FFABS ( ex - sx ) > FFABS ( ey - sy ) ) { if ( sx > ex ) { FFSWAP ( int , sx , ex ) ; FFSWAP ( int , sy , ey ) ; } buf += sx + sy * stride ; ex -= sx ; f = ( ( ey - sy ) << 16 ) / ex ; for ( x = 0 ; x <= ex ; x ++ ) { y = ( x * f ) >> 16 ; fr = ( x * f ) & 0xFFFF ; buf [ y * stride + x ] += ( color * ( 0x10000 - fr ) ) >> 16 ; buf [ ( y + 1 ) * stride + x ] += ( color * fr ) >> 16 ; } } else { if ( sy > ey ) { FFSWAP ( int , sx , ex ) ; FFSWAP ( int , sy , ey ) ; } buf += sx + sy * stride ; ey -= sy ; if ( ey ) f = ( ( ex - sx ) << 16 ) / ey ; else f = 0 ; for ( y = 0 ; y = ey ; y ++ ) { x = ( y * f ) >> 16 ; fr = ( y * f ) & 0xFFFF ; buf [ y * stride + x ] += ( color * ( 0x10000 - fr ) ) >> 16 ; buf [ y * stride + x + 1 ] += ( color * fr ) >> 16 ; } } }
444
1
IniSection (const IniParser *p, string n) : IniBase (n), ip (p), end_comment (), rewrite_by(0), container(), ivalues (), isections () {}
IniSection (const IniParser *p, string n) : IniBase (n), ip (p), end_comment (), rewrite_by(0), container(), ivalues (), isections () {}
445
0
static void sha256_transform(uint32_t *state, const uint8_t buffer[64]) { unsigned int i, a, b, c, d, e, f, g, h; uint32_t block[64]; uint32_t T1; a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4]; f = state[5]; g = state[6]; h = state[7]; #if CONFIG_SMALL for (i = 0; i < 64; i++) { uint32_t T2; if (i < 16) T1 = blk0(i); else T1 = blk(i); T1 += h + Sigma1_256(e) + Ch(e, f, g) + K256[i]; T2 = Sigma0_256(a) + Maj(a, b, c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; } #else for (i = 0; i < 16;) { ROUND256_0_TO_15(a, b, c, d, e, f, g, h); ROUND256_0_TO_15(h, a, b, c, d, e, f, g); ROUND256_0_TO_15(g, h, a, b, c, d, e, f); ROUND256_0_TO_15(f, g, h, a, b, c, d, e); ROUND256_0_TO_15(e, f, g, h, a, b, c, d); ROUND256_0_TO_15(d, e, f, g, h, a, b, c); ROUND256_0_TO_15(c, d, e, f, g, h, a, b); ROUND256_0_TO_15(b, c, d, e, f, g, h, a); } for (; i < 64;) { ROUND256_16_TO_63(a, b, c, d, e, f, g, h); ROUND256_16_TO_63(h, a, b, c, d, e, f, g); ROUND256_16_TO_63(g, h, a, b, c, d, e, f); ROUND256_16_TO_63(f, g, h, a, b, c, d, e); ROUND256_16_TO_63(e, f, g, h, a, b, c, d); ROUND256_16_TO_63(d, e, f, g, h, a, b, c); ROUND256_16_TO_63(c, d, e, f, g, h, a, b); ROUND256_16_TO_63(b, c, d, e, f, g, h, a); } #endif state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; state[5] += f; state[6] += g; state[7] += h; }
static void sha256_transform(uint32_t *state, const uint8_t buffer[64]) { unsigned int i, a, b, c, d, e, f, g, h; uint32_t block[64]; uint32_t T1; a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4]; f = state[5]; g = state[6]; h = state[7]; #if CONFIG_SMALL for (i = 0; i < 64; i++) { uint32_t T2; if (i < 16) T1 = blk0(i); else T1 = blk(i); T1 += h + Sigma1_256(e) + Ch(e, f, g) + K256[i]; T2 = Sigma0_256(a) + Maj(a, b, c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; } #else for (i = 0; i < 16;) { ROUND256_0_TO_15(a, b, c, d, e, f, g, h); ROUND256_0_TO_15(h, a, b, c, d, e, f, g); ROUND256_0_TO_15(g, h, a, b, c, d, e, f); ROUND256_0_TO_15(f, g, h, a, b, c, d, e); ROUND256_0_TO_15(e, f, g, h, a, b, c, d); ROUND256_0_TO_15(d, e, f, g, h, a, b, c); ROUND256_0_TO_15(c, d, e, f, g, h, a, b); ROUND256_0_TO_15(b, c, d, e, f, g, h, a); } for (; i < 64;) { ROUND256_16_TO_63(a, b, c, d, e, f, g, h); ROUND256_16_TO_63(h, a, b, c, d, e, f, g); ROUND256_16_TO_63(g, h, a, b, c, d, e, f); ROUND256_16_TO_63(f, g, h, a, b, c, d, e); ROUND256_16_TO_63(e, f, g, h, a, b, c, d); ROUND256_16_TO_63(d, e, f, g, h, a, b, c); ROUND256_16_TO_63(c, d, e, f, g, h, a, b); ROUND256_16_TO_63(b, c, d, e, f, g, h, a); } #endif state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; state[5] += f; state[6] += g; state[7] += h; }
447
0
IniSection (const IniParser *p) : IniBase (-1), ip (p), end_comment (), is_private(false), rewrite_by(-1), container (), ivalues (), isections () {}
IniSection (const IniParser *p) : IniBase (-1), ip (p), end_comment (), is_private(false), rewrite_by(-1), container (), ivalues (), isections () {}
448
0
static void decode_flush ( AVCodecContext * avctx ) { RALFContext * ctx = avctx -> priv_data ; ctx -> has_pkt = 0 ; }
static void decode_flush ( AVCodecContext * avctx ) { RALFContext * ctx = avctx -> priv_data ; ctx -> has_pkt = 0 ; }
449
1
static void device_finalize(Object *obj) { NamedGPIOList *ngl, *next; DeviceState *dev = DEVICE(obj); qemu_opts_del(dev->opts); QLIST_FOREACH_SAFE(ngl, &dev->gpios, node, next) { QLIST_REMOVE(ngl, node); qemu_free_irqs(ngl->in, ngl->num_in); g_free(ngl->name); g_free(ngl); /* ngl->out irqs are owned by the other end and should not be freed * here */ } }
static void device_finalize(Object *obj) { NamedGPIOList *ngl, *next; DeviceState *dev = DEVICE(obj); qemu_opts_del(dev->opts); QLIST_FOREACH_SAFE(ngl, &dev->gpios, node, next) { QLIST_REMOVE(ngl, node); qemu_free_irqs(ngl->in, ngl->num_in); g_free(ngl->name); g_free(ngl); } }
451
0
static GList * completion_joinlist ( GList * list1 , GList * list2 ) { GList * old ; old = list2 ; while ( list2 != NULL ) { if ( ! glist_find_icase_string ( list1 , list2 -> data ) ) list1 = g_list_append ( list1 , list2 -> data ) ; else g_free ( list2 -> data ) ; list2 = list2 -> next ; } g_list_free ( old ) ; return list1 ; }
static GList * completion_joinlist ( GList * list1 , GList * list2 ) { GList * old ; old = list2 ; while ( list2 != NULL ) { if ( ! glist_find_icase_string ( list1 , list2 -> data ) ) list1 = g_list_append ( list1 , list2 -> data ) ; else g_free ( list2 -> data ) ; list2 = list2 -> next ; } g_list_free ( old ) ; return list1 ; }
452
1
IniSection (const IniParser *p) : IniBase (-1), ip (p), end_comment (), rewrite_by(-1), container (), ivalues (), isections () {}
IniSection (const IniParser *p) : IniBase (-1), ip (p), end_comment (), rewrite_by(-1), container (), ivalues (), isections () {}
453
1
static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *symname) { int error; int len; struct inode *inode; struct page *page = NULL; char *kaddr; struct shmem_inode_info *info; len = strlen(symname) + 1; if (len > PAGE_CACHE_SIZE) return -ENAMETOOLONG; inode = shmem_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0); if (!inode) return -ENOSPC; error = security_inode_init_security(inode, dir, NULL, NULL, NULL); if (error) { if (error != -EOPNOTSUPP) { iput(inode); return error; } error = 0; } info = SHMEM_I(inode); inode->i_size = len-1; if (len <= (char *)inode - (char *)info) { /* do it inline */ memcpy(info, symname, len); inode->i_op = &shmem_symlink_inline_operations; } else { error = shmem_getpage(inode, 0, &page, SGP_WRITE, NULL); if (error) { iput(inode); return error; } unlock_page(page); inode->i_op = &shmem_symlink_inode_operations; kaddr = kmap_atomic(page, KM_USER0); memcpy(kaddr, symname, len); kunmap_atomic(kaddr, KM_USER0); set_page_dirty(page); page_cache_release(page); } if (dir->i_mode & S_ISGID) inode->i_gid = dir->i_gid; dir->i_size += BOGO_DIRENT_SIZE; dir->i_ctime = dir->i_mtime = CURRENT_TIME; d_instantiate(dentry, inode); dget(dentry); return 0; }
static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *symname) { int error; int len; struct inode *inode; struct page *page = NULL; char *kaddr; struct shmem_inode_info *info; len = strlen(symname) + 1; if (len > PAGE_CACHE_SIZE) return -ENAMETOOLONG; inode = shmem_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0); if (!inode) return -ENOSPC; error = security_inode_init_security(inode, dir, NULL, NULL, NULL); if (error) { if (error != -EOPNOTSUPP) { iput(inode); return error; } error = 0; } info = SHMEM_I(inode); inode->i_size = len-1; if (len <= (char *)inode - (char *)info) { memcpy(info, symname, len); inode->i_op = &shmem_symlink_inline_operations; } else { error = shmem_getpage(inode, 0, &page, SGP_WRITE, NULL); if (error) { iput(inode); return error; } unlock_page(page); inode->i_op = &shmem_symlink_inode_operations; kaddr = kmap_atomic(page, KM_USER0); memcpy(kaddr, symname, len); kunmap_atomic(kaddr, KM_USER0); set_page_dirty(page); page_cache_release(page); } if (dir->i_mode & S_ISGID) inode->i_gid = dir->i_gid; dir->i_size += BOGO_DIRENT_SIZE; dir->i_ctime = dir->i_mtime = CURRENT_TIME; d_instantiate(dentry, inode); dget(dentry); return 0; }
454
1
IniSection (const IniSection &s) : IniBase (s), ip (s.ip), end_comment (s.end_comment), rewrite_by (s.rewrite_by), container (s.container) { reindex (); }
IniSection (const IniSection &s) : IniBase (s), ip (s.ip), end_comment (s.end_comment), rewrite_by (s.rewrite_by), container (s.container) { reindex (); }
455
1
spnego_gss_unwrap_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, int *conf_state, gss_qop_t *qop_state, gss_iov_buffer_desc *iov, int iov_count) { OM_uint32 ret; ret = gss_unwrap_iov(minor_status, context_handle, conf_state, qop_state, iov, iov_count); return (ret); }
spnego_gss_unwrap_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, int *conf_state, gss_qop_t *qop_state, gss_iov_buffer_desc *iov, int iov_count) { OM_uint32 ret; ret = gss_unwrap_iov(minor_status, context_handle, conf_state, qop_state, iov, iov_count); return (ret); }
457
0
static void dct_unquantize_h263_inter_c ( MpegEncContext * s , int16_t * block , int n , int qscale ) { int i , level , qmul , qadd ; int nCoeffs ; assert ( s -> block_last_index [ n ] >= 0 ) ; qadd = ( qscale - 1 ) | 1 ; qmul = qscale << 1 ; nCoeffs = s -> inter_scantable . raster_end [ s -> block_last_index [ n ] ] ; for ( i = 0 ; i <= nCoeffs ; i ++ ) { level = block [ i ] ; if ( level ) { if ( level < 0 ) { level = level * qmul - qadd ; } else { level = level * qmul + qadd ; } block [ i ] = level ; } } }
static void dct_unquantize_h263_inter_c ( MpegEncContext * s , int16_t * block , int n , int qscale ) { int i , level , qmul , qadd ; int nCoeffs ; assert ( s -> block_last_index [ n ] >= 0 ) ; qadd = ( qscale - 1 ) | 1 ; qmul = qscale << 1 ; nCoeffs = s -> inter_scantable . raster_end [ s -> block_last_index [ n ] ] ; for ( i = 0 ; i <= nCoeffs ; i ++ ) { level = block [ i ] ; if ( level ) { if ( level < 0 ) { level = level * qmul - qadd ; } else { level = level * qmul + qadd ; } block [ i ] = level ; } } }
458
1
void __cpuinit cpu_init (void) { int cpu = stack_smp_processor_id(); struct tss_struct *t = &per_cpu(init_tss, cpu); struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu); unsigned long v; char *estacks = NULL; struct task_struct *me; int i; /* CPU 0 is initialised in head64.c */ if (cpu != 0) { pda_init(cpu); zap_low_mappings(cpu); } else estacks = boot_exception_stacks; me = current; if (cpu_test_and_set(cpu, cpu_initialized)) panic("CPU#%d already initialized!\n", cpu); printk("Initializing CPU#%d\n", cpu); clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE); /* * Initialize the per-CPU GDT with the boot GDT, * and set up the GDT descriptor: */ if (cpu) memcpy(cpu_gdt(cpu), cpu_gdt_table, GDT_SIZE); cpu_gdt_descr[cpu].size = GDT_SIZE; asm volatile("lgdt %0" :: "m" (cpu_gdt_descr[cpu])); asm volatile("lidt %0" :: "m" (idt_descr)); memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8); syscall_init(); wrmsrl(MSR_FS_BASE, 0); wrmsrl(MSR_KERNEL_GS_BASE, 0); barrier(); check_efer(); /* * set up and load the per-CPU TSS */ for (v = 0; v < N_EXCEPTION_STACKS; v++) { static const unsigned int order[N_EXCEPTION_STACKS] = { [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER, [DEBUG_STACK - 1] = DEBUG_STACK_ORDER }; if (cpu) { estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]); if (!estacks) panic("Cannot allocate exception stack %ld %d\n", v, cpu); } estacks += PAGE_SIZE << order[v]; orig_ist->ist[v] = t->ist[v] = (unsigned long)estacks; } t->io_bitmap_base = offsetof(struct tss_struct, io_bitmap); /* * <= is required because the CPU will access up to * 8 bits beyond the end of the IO permission bitmap. */ for (i = 0; i <= IO_BITMAP_LONGS; i++) t->io_bitmap[i] = ~0UL; atomic_inc(&init_mm.mm_count); me->active_mm = &init_mm; if (me->mm) BUG(); enter_lazy_tlb(&init_mm, me); set_tss_desc(cpu, t); load_TR_desc(); load_LDT(&init_mm.context); /* * Clear all 6 debug registers: */ set_debugreg(0UL, 0); set_debugreg(0UL, 1); set_debugreg(0UL, 2); set_debugreg(0UL, 3); set_debugreg(0UL, 6); set_debugreg(0UL, 7); fpu_init(); }
void __cpuinit cpu_init (void) { int cpu = stack_smp_processor_id(); struct tss_struct *t = &per_cpu(init_tss, cpu); struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu); unsigned long v; char *estacks = NULL; struct task_struct *me; int i; if (cpu != 0) { pda_init(cpu); zap_low_mappings(cpu); } else estacks = boot_exception_stacks; me = current; if (cpu_test_and_set(cpu, cpu_initialized)) panic("CPU#%d already initialized!\n", cpu); printk("Initializing CPU#%d\n", cpu); clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE); if (cpu) memcpy(cpu_gdt(cpu), cpu_gdt_table, GDT_SIZE); cpu_gdt_descr[cpu].size = GDT_SIZE; asm volatile("lgdt %0" :: "m" (cpu_gdt_descr[cpu])); asm volatile("lidt %0" :: "m" (idt_descr)); memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8); syscall_init(); wrmsrl(MSR_FS_BASE, 0); wrmsrl(MSR_KERNEL_GS_BASE, 0); barrier(); check_efer(); for (v = 0; v < N_EXCEPTION_STACKS; v++) { static const unsigned int order[N_EXCEPTION_STACKS] = { [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER, [DEBUG_STACK - 1] = DEBUG_STACK_ORDER }; if (cpu) { estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]); if (!estacks) panic("Cannot allocate exception stack %ld %d\n", v, cpu); } estacks += PAGE_SIZE << order[v]; orig_ist->ist[v] = t->ist[v] = (unsigned long)estacks; } t->io_bitmap_base = offsetof(struct tss_struct, io_bitmap); for (i = 0; i <= IO_BITMAP_LONGS; i++) t->io_bitmap[i] = ~0UL; atomic_inc(&init_mm.mm_count); me->active_mm = &init_mm; if (me->mm) BUG(); enter_lazy_tlb(&init_mm, me); set_tss_desc(cpu, t); load_TR_desc(); load_LDT(&init_mm.context); set_debugreg(0UL, 0); set_debugreg(0UL, 1); set_debugreg(0UL, 2); set_debugreg(0UL, 3); set_debugreg(0UL, 6); set_debugreg(0UL, 7); fpu_init(); }
459
1
static void i440fx_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->no_hotplug = 1; k->init = i440fx_initfn; k->config_write = i440fx_write_config; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_82441; k->revision = 0x02; k->class_id = PCI_CLASS_BRIDGE_HOST; dc->desc = "Host bridge"; dc->no_user = 1; dc->vmsd = &vmstate_i440fx; }
static void i440fx_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->no_hotplug = 1; k->init = i440fx_initfn; k->config_write = i440fx_write_config; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_82441; k->revision = 0x02; k->class_id = PCI_CLASS_BRIDGE_HOST; dc->desc = "Host bridge"; dc->no_user = 1; dc->vmsd = &vmstate_i440fx; }
460
0
IniSection (const IniSection &s) : IniBase (s), ip (s.ip), end_comment (s.end_comment), is_private(s.is_private), rewrite_by (s.rewrite_by), container (s.container) { reindex (); }
IniSection (const IniSection &s) : IniBase (s), ip (s.ip), end_comment (s.end_comment), is_private(s.is_private), rewrite_by (s.rewrite_by), container (s.container) { reindex (); }
461
0
static unsigned int hashname ( const char * name ) { unsigned int hash = 0 ; while ( * name ) { unsigned int extra = ( hash >> 27 ) ; hash <<= 5 ; hash += * name & 0x1f ; hash ^= extra ; ++ name ; } return ( hash % 257 ) ; }
static unsigned int hashname ( const char * name ) { unsigned int hash = 0 ; while ( * name ) { unsigned int extra = ( hash >> 27 ) ; hash <<= 5 ; hash += * name & 0x1f ; hash ^= extra ; ++ name ; } return ( hash % 257 ) ; }
462
1
int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation) { const int isRgb = isBGR(c->dstFormat); const int bpp = fmt_depth(c->dstFormat); int i; uint8_t table_Y[1024]; uint32_t *table_32 = 0; uint16_t *table_16 = 0; uint8_t *table_8 = 0; uint8_t *table_332 = 0; uint8_t *table_121 = 0; uint8_t *table_1 = 0; int entry_size = 0; void *table_r = 0, *table_g = 0, *table_b = 0; void *table_start; int64_t crv = inv_table[0]; int64_t cbu = inv_table[1]; int64_t cgu = -inv_table[2]; int64_t cgv = -inv_table[3]; int64_t cy = 1<<16; int64_t oy = 0; //printf("%lld %lld %lld %lld %lld\n", cy, crv, cbu, cgu, cgv); if(!fullRange){ cy= (cy*255) / 219; oy= 16<<16; }else{ crv= (crv*224) / 255; cbu= (cbu*224) / 255; cgu= (cgu*224) / 255; cgv= (cgv*224) / 255; } cy = (cy *contrast )>>16; crv= (crv*contrast * saturation)>>32; cbu= (cbu*contrast * saturation)>>32; cgu= (cgu*contrast * saturation)>>32; cgv= (cgv*contrast * saturation)>>32; //printf("%lld %lld %lld %lld %lld\n", cy, crv, cbu, cgu, cgv); oy -= 256*brightness; for (i = 0; i < 1024; i++) { int j; j= (cy*(((i - 384)<<16) - oy) + (1<<31))>>32; j = (j < 0) ? 0 : ((j > 255) ? 255 : j); table_Y[i] = j; } switch (bpp) { case 32: table_start= table_32 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); entry_size = sizeof (uint32_t); table_r = table_32 + 197; table_b = table_32 + 197 + 685; table_g = table_32 + 197 + 2*682; for (i = -197; i < 256+197; i++) ((uint32_t *)table_r)[i] = table_Y[i+384] << (isRgb ? 16 : 0); for (i = -132; i < 256+132; i++) ((uint32_t *)table_g)[i] = table_Y[i+384] << 8; for (i = -232; i < 256+232; i++) ((uint32_t *)table_b)[i] = table_Y[i+384] << (isRgb ? 0 : 16); break; case 24: table_start= table_8 = av_malloc ((256 + 2*232) * sizeof (uint8_t)); entry_size = sizeof (uint8_t); table_r = table_g = table_b = table_8 + 232; for (i = -232; i < 256+232; i++) ((uint8_t * )table_b)[i] = table_Y[i+384]; break; case 15: case 16: table_start= table_16 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); entry_size = sizeof (uint16_t); table_r = table_16 + 197; table_b = table_16 + 197 + 685; table_g = table_16 + 197 + 2*682; for (i = -197; i < 256+197; i++) { int j = table_Y[i+384] >> 3; if (isRgb) j <<= ((bpp==16) ? 11 : 10); ((uint16_t *)table_r)[i] = j; } for (i = -132; i < 256+132; i++) { int j = table_Y[i+384] >> ((bpp==16) ? 2 : 3); ((uint16_t *)table_g)[i] = j << 5; } for (i = -232; i < 256+232; i++) { int j = table_Y[i+384] >> 3; if (!isRgb) j <<= ((bpp==16) ? 11 : 10); ((uint16_t *)table_b)[i] = j; } break; case 8: table_start= table_332 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); entry_size = sizeof (uint8_t); table_r = table_332 + 197; table_b = table_332 + 197 + 685; table_g = table_332 + 197 + 2*682; for (i = -197; i < 256+197; i++) { int j = (table_Y[i+384 - 16] + 18)/36; if (isRgb) j <<= 5; ((uint8_t *)table_r)[i] = j; } for (i = -132; i < 256+132; i++) { int j = (table_Y[i+384 - 16] + 18)/36; if (!isRgb) j <<= 1; ((uint8_t *)table_g)[i] = j << 2; } for (i = -232; i < 256+232; i++) { int j = (table_Y[i+384 - 37] + 43)/85; if (!isRgb) j <<= 6; ((uint8_t *)table_b)[i] = j; } break; case 4: case 4|128: table_start= table_121 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); entry_size = sizeof (uint8_t); table_r = table_121 + 197; table_b = table_121 + 197 + 685; table_g = table_121 + 197 + 2*682; for (i = -197; i < 256+197; i++) { int j = table_Y[i+384 - 110] >> 7; if (isRgb) j <<= 3; ((uint8_t *)table_r)[i] = j; } for (i = -132; i < 256+132; i++) { int j = (table_Y[i+384 - 37]+ 43)/85; ((uint8_t *)table_g)[i] = j << 1; } for (i = -232; i < 256+232; i++) { int j =table_Y[i+384 - 110] >> 7; if (!isRgb) j <<= 3; ((uint8_t *)table_b)[i] = j; } break; case 1: table_start= table_1 = av_malloc (256*2 * sizeof (uint8_t)); entry_size = sizeof (uint8_t); table_g = table_1; table_r = table_b = NULL; for (i = 0; i < 256+256; i++) { int j = table_Y[i + 384 - 110]>>7; ((uint8_t *)table_g)[i] = j; } break; default: table_start= NULL; av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp); //free mem? return -1; } for (i = 0; i < 256; i++) { c->table_rV[i] = (uint8_t *)table_r + entry_size * div_round (crv * (i-128), 76309); c->table_gU[i] = (uint8_t *)table_g + entry_size * div_round (cgu * (i-128), 76309); c->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309); c->table_bU[i] = (uint8_t *)table_b + entry_size * div_round (cbu * (i-128), 76309); } av_free(c->yuvTable); c->yuvTable= table_start; return 0; }
int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation) { const int isRgb = isBGR(c->dstFormat); const int bpp = fmt_depth(c->dstFormat); int i; uint8_t table_Y[1024]; uint32_t *table_32 = 0; uint16_t *table_16 = 0; uint8_t *table_8 = 0; uint8_t *table_332 = 0; uint8_t *table_121 = 0; uint8_t *table_1 = 0; int entry_size = 0; void *table_r = 0, *table_g = 0, *table_b = 0; void *table_start; int64_t crv = inv_table[0]; int64_t cbu = inv_table[1]; int64_t cgu = -inv_table[2]; int64_t cgv = -inv_table[3]; int64_t cy = 1<<16; int64_t oy = 0;
464
0
bool isPrivate() const { return is_private; }
bool isPrivate() const { return is_private; }
465
0
static guint16 de_nw_call_ctrl_cap ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len _U_ , gchar * add_string _U_ , int string_len _U_ ) { guint32 curr_offset ; curr_offset = offset ; proto_tree_add_bits_item ( tree , hf_gsm_a_spare_bits , tvb , ( curr_offset << 3 ) , 7 , ENC_BIG_ENDIAN ) ; proto_tree_add_item ( tree , hf_gsm_a_dtap_mcs , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ; curr_offset ++ ; EXTRANEOUS_DATA_CHECK ( len , curr_offset - offset , pinfo , & ei_gsm_a_dtap_extraneous_data ) ; return ( len ) ; }
static guint16 de_nw_call_ctrl_cap ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len _U_ , gchar * add_string _U_ , int string_len _U_ ) { guint32 curr_offset ; curr_offset = offset ; proto_tree_add_bits_item ( tree , hf_gsm_a_spare_bits , tvb , ( curr_offset << 3 ) , 7 , ENC_BIG_ENDIAN ) ; proto_tree_add_item ( tree , hf_gsm_a_dtap_mcs , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ; curr_offset ++ ; EXTRANEOUS_DATA_CHECK ( len , curr_offset - offset , pinfo , & ei_gsm_a_dtap_extraneous_data ) ; return ( len ) ; }
466
1
static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, struct nameidata *nd) { struct dentry * result; struct inode *dir = parent->d_inode; mutex_lock(&dir->i_mutex); /* * First re-do the cached lookup just in case it was created * while we waited for the directory semaphore.. * * FIXME! This could use version numbering or similar to * avoid unnecessary cache lookups. * * The "dcache_lock" is purely to protect the RCU list walker * from concurrent renames at this point (we mustn't get false * negatives from the RCU list walk here, unlike the optimistic * fast walk). * * so doing d_lookup() (with seqlock), instead of lockfree __d_lookup */ result = d_lookup(parent, name); if (!result) { struct dentry * dentry = d_alloc(parent, name); result = ERR_PTR(-ENOMEM); if (dentry) { result = dir->i_op->lookup(dir, dentry, nd); if (result) dput(dentry); else result = dentry; } mutex_unlock(&dir->i_mutex); return result; } /* * Uhhuh! Nasty case: the cache was re-populated while * we waited on the semaphore. Need to revalidate. */ mutex_unlock(&dir->i_mutex); if (result->d_op && result->d_op->d_revalidate) { result = do_revalidate(result, nd); if (!result) result = ERR_PTR(-ENOENT); } return result; }
static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, struct nameidata *nd) { struct dentry * result; struct inode *dir = parent->d_inode; mutex_lock(&dir->i_mutex); result = d_lookup(parent, name); if (!result) { struct dentry * dentry = d_alloc(parent, name); result = ERR_PTR(-ENOMEM); if (dentry) { result = dir->i_op->lookup(dir, dentry, nd); if (result) dput(dentry); else result = dentry; } mutex_unlock(&dir->i_mutex); return result; } mutex_unlock(&dir->i_mutex); if (result->d_op && result->d_op->d_revalidate) { result = do_revalidate(result, nd); if (!result) result = ERR_PTR(-ENOENT); } return result; }
467
0
static void sig_complete_unalias ( GList * * list , WINDOW_REC * window , const char * word , const char * line , int * want_space ) { g_return_if_fail ( list != NULL ) ; g_return_if_fail ( word != NULL ) ; * list = completion_get_aliases ( word ) ; if ( * list != NULL ) signal_stop ( ) ; }
static void sig_complete_unalias ( GList * * list , WINDOW_REC * window , const char * word , const char * line , int * want_space ) { g_return_if_fail ( list != NULL ) ; g_return_if_fail ( word != NULL ) ; * list = completion_get_aliases ( word ) ; if ( * list != NULL ) signal_stop ( ) ; }
468
1
target_ulong helper_udiv(target_ulong a, target_ulong b) { uint64_t x0; uint32_t x1; x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32); x1 = (b & 0xffffffff); if (x1 == 0) { raise_exception(TT_DIV_ZERO); } x0 = x0 / x1; if (x0 > 0xffffffff) { env->cc_src2 = 1; return 0xffffffff; } else { env->cc_src2 = 0; return x0; } }
target_ulong helper_udiv(target_ulong a, target_ulong b) { uint64_t x0; uint32_t x1; x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32); x1 = (b & 0xffffffff); if (x1 == 0) { raise_exception(TT_DIV_ZERO); } x0 = x0 / x1; if (x0 > 0xffffffff) { env->cc_src2 = 1; return 0xffffffff; } else { env->cc_src2 = 0; return x0; } }
469
1
static struct dentry *__lookup_hash(struct qstr *name, struct dentry *base, struct nameidata *nd) { struct dentry *dentry; struct inode *inode; int err; inode = base->d_inode; /* * See if the low-level filesystem might want * to use its own hash.. */ if (base->d_op && base->d_op->d_hash) { err = base->d_op->d_hash(base, name); dentry = ERR_PTR(err); if (err < 0) goto out; } dentry = cached_lookup(base, name, nd); if (!dentry) { struct dentry *new = d_alloc(base, name); dentry = ERR_PTR(-ENOMEM); if (!new) goto out; dentry = inode->i_op->lookup(inode, new, nd); if (!dentry) dentry = new; else dput(new); } out: return dentry; }
static struct dentry *__lookup_hash(struct qstr *name, struct dentry *base, struct nameidata *nd) { struct dentry *dentry; struct inode *inode; int err; inode = base->d_inode; if (base->d_op && base->d_op->d_hash) { err = base->d_op->d_hash(base, name); dentry = ERR_PTR(err); if (err < 0) goto out; } dentry = cached_lookup(base, name, nd); if (!dentry) { struct dentry *new = d_alloc(base, name); dentry = ERR_PTR(-ENOMEM); if (!new) goto out; dentry = inode->i_op->lookup(inode, new, nd); if (!dentry) dentry = new; else dput(new); } out: return dentry; }
470
0
void operator = (const IniSection &s) { if (&s == this) { return; } IniBase::operator = (s); ip = s.ip; end_comment = s.end_comment; is_private = s.is_private; rewrite_by = s.rewrite_by; container = s.container; reindex (); }
void operator = (const IniSection &s) { if (&s == this) { return; } IniBase::operator = (s); ip = s.ip; end_comment = s.end_comment; is_private = s.is_private; rewrite_by = s.rewrite_by; container = s.container; reindex (); }
471
1
static direntry_t *create_short_filename(BDRVVVFATState *s, const char *filename, unsigned int directory_start) { int i, j = 0; direntry_t *entry = array_get_next(&(s->directory)); const gchar *p, *last_dot = NULL; gunichar c; bool lossy_conversion = false; char tail[11]; if (!entry) { return NULL; } memset(entry->name, 0x20, sizeof(entry->name)); /* copy filename and search last dot */ for (p = filename; ; p = g_utf8_next_char(p)) { c = g_utf8_get_char(p); if (c == '\0') { break; } else if (c == '.') { if (j == 0) { /* '.' at start of filename */ lossy_conversion = true; } else { if (last_dot) { lossy_conversion = true; } last_dot = p; } } else if (!last_dot) { /* first part of the name; copy it */ uint8_t v = to_valid_short_char(c); if (j < 8 && v) { entry->name[j++] = v; } else { lossy_conversion = true; } } } /* copy extension (if any) */ if (last_dot) { j = 0; for (p = g_utf8_next_char(last_dot); ; p = g_utf8_next_char(p)) { c = g_utf8_get_char(p); if (c == '\0') { break; } else { /* extension; copy it */ uint8_t v = to_valid_short_char(c); if (j < 3 && v) { entry->name[8 + (j++)] = v; } else { lossy_conversion = true; } } } } if (entry->name[0] == DIR_KANJI) { entry->name[0] = DIR_KANJI_FAKE; } /* numeric-tail generation */ for (j = 0; j < 8; j++) { if (entry->name[j] == ' ') { break; } } for (i = lossy_conversion ? 1 : 0; i < 999999; i++) { direntry_t *entry1; if (i > 0) { int len = sprintf(tail, "~%d", i); memcpy(entry->name + MIN(j, 8 - len), tail, len); } for (entry1 = array_get(&(s->directory), directory_start); entry1 < entry; entry1++) { if (!is_long_name(entry1) && !memcmp(entry1->name, entry->name, 11)) { break; /* found dupe */ } } if (entry1 == entry) { /* no dupe found */ return entry; } } return NULL; }
static direntry_t *create_short_filename(BDRVVVFATState *s, const char *filename, unsigned int directory_start) { int i, j = 0; direntry_t *entry = array_get_next(&(s->directory)); const gchar *p, *last_dot = NULL; gunichar c; bool lossy_conversion = false; char tail[11]; if (!entry) { return NULL; } memset(entry->name, 0x20, sizeof(entry->name)); for (p = filename; ; p = g_utf8_next_char(p)) { c = g_utf8_get_char(p); if (c == '\0') { break; } else if (c == '.') { if (j == 0) { lossy_conversion = true; } else { if (last_dot) { lossy_conversion = true; } last_dot = p; } } else if (!last_dot) { uint8_t v = to_valid_short_char(c); if (j < 8 && v) { entry->name[j++] = v; } else { lossy_conversion = true; } } } if (last_dot) { j = 0; for (p = g_utf8_next_char(last_dot); ; p = g_utf8_next_char(p)) { c = g_utf8_get_char(p); if (c == '\0') { break; } else { uint8_t v = to_valid_short_char(c); if (j < 3 && v) { entry->name[8 + (j++)] = v; } else { lossy_conversion = true; } } } } if (entry->name[0] == DIR_KANJI) { entry->name[0] = DIR_KANJI_FAKE; } for (j = 0; j < 8; j++) { if (entry->name[j] == ' ') { break; } } for (i = lossy_conversion ? 1 : 0; i < 999999; i++) { direntry_t *entry1; if (i > 0) { int len = sprintf(tail, "~%d", i); memcpy(entry->name + MIN(j, 8 - len), tail, len); } for (entry1 = array_get(&(s->directory), directory_start); entry1 < entry; entry1++) { if (!is_long_name(entry1) && !memcmp(entry1->name, entry->name, 11)) { break; } } if (entry1 == entry) { return entry; } } return NULL; }
472
1
spnego_gss_verify_mic_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, gss_qop_t *qop_state, gss_iov_buffer_desc *iov, int iov_count) { return gss_verify_mic_iov(minor_status, context_handle, qop_state, iov, iov_count); }
spnego_gss_verify_mic_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, gss_qop_t *qop_state, gss_iov_buffer_desc *iov, int iov_count) { return gss_verify_mic_iov(minor_status, context_handle, qop_state, iov, iov_count); }
473
1
void operator = (const IniSection &s) { if (&s == this) { return; } IniBase::operator = (s); ip = s.ip; end_comment = s.end_comment; rewrite_by = s.rewrite_by; container = s.container; reindex (); }
void operator = (const IniSection &s) { if (&s == this) { return; } IniBase::operator = (s); ip = s.ip; end_comment = s.end_comment; rewrite_by = s.rewrite_by; container = s.container; reindex (); }
475
0
static void init_sql_statement_names ( ) { char * first_com = ( char * ) offsetof ( STATUS_VAR , com_stat [ 0 ] ) ; char * last_com = ( char * ) offsetof ( STATUS_VAR , com_stat [ ( uint ) SQLCOM_END ] ) ; int record_size = ( char * ) offsetof ( STATUS_VAR , com_stat [ 1 ] ) - ( char * ) offsetof ( STATUS_VAR , com_stat [ 0 ] ) ; char * ptr ; uint i ; uint com_index ; for ( i = 0 ; i < ( ( uint ) SQLCOM_END + 1 ) ; i ++ ) sql_statement_names [ i ] = empty_lex_str ; SHOW_VAR * var = & com_status_vars [ 0 ] ; while ( var -> name != NULL ) { ptr = var -> value ; if ( ( first_com <= ptr ) && ( ptr <= last_com ) ) { com_index = ( ( int ) ( ptr - first_com ) ) / record_size ; DBUG_ASSERT ( com_index < ( uint ) SQLCOM_END ) ; sql_statement_names [ com_index ] . str = const_cast < char * > ( var -> name ) ; sql_statement_names [ com_index ] . length = strlen ( var -> name ) ; } var ++ ; } DBUG_ASSERT ( strcmp ( sql_statement_names [ ( uint ) SQLCOM_SELECT ] . str , "select" ) == 0 ) ; DBUG_ASSERT ( strcmp ( sql_statement_names [ ( uint ) SQLCOM_SIGNAL ] . str , "signal" ) == 0 ) ; sql_statement_names [ ( uint ) SQLCOM_END ] . str = const_cast < char * > ( "error" ) ; }
static void init_sql_statement_names ( ) { char * first_com = ( char * ) offsetof ( STATUS_VAR , com_stat [ 0 ] ) ; char * last_com = ( char * ) offsetof ( STATUS_VAR , com_stat [ ( uint ) SQLCOM_END ] ) ; int record_size = ( char * ) offsetof ( STATUS_VAR , com_stat [ 1 ] ) - ( char * ) offsetof ( STATUS_VAR , com_stat [ 0 ] ) ; char * ptr ; uint i ; uint com_index ; for ( i = 0 ; i < ( ( uint ) SQLCOM_END + 1 ) ; i ++ ) sql_statement_names [ i ] = empty_lex_str ; SHOW_VAR * var = & com_status_vars [ 0 ] ; while ( var -> name != NULL ) { ptr = var -> value ; if ( ( first_com <= ptr ) && ( ptr <= last_com ) ) { com_index = ( ( int ) ( ptr - first_com ) ) / record_size ; DBUG_ASSERT ( com_index < ( uint ) SQLCOM_END ) ; sql_statement_names [ com_index ] . str = const_cast < char * > ( var -> name ) ; sql_statement_names [ com_index ] . length = strlen ( var -> name ) ; } var ++ ; } DBUG_ASSERT ( strcmp ( sql_statement_names [ ( uint ) SQLCOM_SELECT ] . str , "select" ) == 0 ) ; DBUG_ASSERT ( strcmp ( sql_statement_names [ ( uint ) SQLCOM_SIGNAL ] . str , "signal" ) == 0 ) ; sql_statement_names [ ( uint ) SQLCOM_END ] . str = const_cast < char * > ( "error" ) ; }
476
0
void show_setup_info ( tvbuff_t * tvb , proto_tree * tree , t38_conv * p_t38_conversation ) { proto_tree * t38_setup_tree ; proto_item * ti ; if ( ! p_t38_conversation || p_t38_conversation -> setup_frame_number == 0 ) { return ; } ti = proto_tree_add_string_format ( tree , hf_t38_setup , tvb , 0 , 0 , "" , "Stream setup by %s (frame %u)" , p_t38_conversation -> setup_method , p_t38_conversation -> setup_frame_number ) ; PROTO_ITEM_SET_GENERATED ( ti ) ; t38_setup_tree = proto_item_add_subtree ( ti , ett_t38_setup ) ; if ( t38_setup_tree ) { proto_item * item = proto_tree_add_uint ( t38_setup_tree , hf_t38_setup_frame , tvb , 0 , 0 , p_t38_conversation -> setup_frame_number ) ; PROTO_ITEM_SET_GENERATED ( item ) ; item = proto_tree_add_string ( t38_setup_tree , hf_t38_setup_method , tvb , 0 , 0 , p_t38_conversation -> setup_method ) ; PROTO_ITEM_SET_GENERATED ( item ) ; } }
void show_setup_info ( tvbuff_t * tvb , proto_tree * tree , t38_conv * p_t38_conversation ) { proto_tree * t38_setup_tree ; proto_item * ti ; if ( ! p_t38_conversation || p_t38_conversation -> setup_frame_number == 0 ) { return ; } ti = proto_tree_add_string_format ( tree , hf_t38_setup , tvb , 0 , 0 , "" , "Stream setup by %s (frame %u)" , p_t38_conversation -> setup_method , p_t38_conversation -> setup_frame_number ) ; PROTO_ITEM_SET_GENERATED ( ti ) ; t38_setup_tree = proto_item_add_subtree ( ti , ett_t38_setup ) ; if ( t38_setup_tree ) { proto_item * item = proto_tree_add_uint ( t38_setup_tree , hf_t38_setup_frame , tvb , 0 , 0 , p_t38_conversation -> setup_frame_number ) ; PROTO_ITEM_SET_GENERATED ( item ) ; item = proto_tree_add_string ( t38_setup_tree , hf_t38_setup_method , tvb , 0 , 0 , p_t38_conversation -> setup_method ) ; PROTO_ITEM_SET_GENERATED ( item ) ; } }
477
1
void ff_print_debug_info(MpegEncContext *s, Picture *p) { AVFrame *pict; if (s->avctx->hwaccel || !p || !p->mb_type) return; pict = &p->f; if (s->avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) { int x,y; av_log(s->avctx,AV_LOG_DEBUG,"New frame, type: "); switch (pict->pict_type) { case AV_PICTURE_TYPE_I: av_log(s->avctx,AV_LOG_DEBUG,"I\n"); break; case AV_PICTURE_TYPE_P: av_log(s->avctx,AV_LOG_DEBUG,"P\n"); break; case AV_PICTURE_TYPE_B: av_log(s->avctx,AV_LOG_DEBUG,"B\n"); break; case AV_PICTURE_TYPE_S: av_log(s->avctx,AV_LOG_DEBUG,"S\n"); break; case AV_PICTURE_TYPE_SI: av_log(s->avctx,AV_LOG_DEBUG,"SI\n"); break; case AV_PICTURE_TYPE_SP: av_log(s->avctx,AV_LOG_DEBUG,"SP\n"); break; } for (y = 0; y < s->mb_height; y++) { for (x = 0; x < s->mb_width; x++) { if (s->avctx->debug & FF_DEBUG_SKIP) { int count = s->mbskip_table[x + y * s->mb_stride]; if (count > 9) count = 9; av_log(s->avctx, AV_LOG_DEBUG, "%1d", count); } if (s->avctx->debug & FF_DEBUG_QP) { av_log(s->avctx, AV_LOG_DEBUG, "%2d", p->qscale_table[x + y * s->mb_stride]); } if (s->avctx->debug & FF_DEBUG_MB_TYPE) { int mb_type = p->mb_type[x + y * s->mb_stride]; // Type & MV direction if (IS_PCM(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "P"); else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "A"); else if (IS_INTRA4x4(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "i"); else if (IS_INTRA16x16(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "I"); else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "d"); else if (IS_DIRECT(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "D"); else if (IS_GMC(mb_type) && IS_SKIP(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "g"); else if (IS_GMC(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "G"); else if (IS_SKIP(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "S"); else if (!USES_LIST(mb_type, 1)) av_log(s->avctx, AV_LOG_DEBUG, ">"); else if (!USES_LIST(mb_type, 0)) av_log(s->avctx, AV_LOG_DEBUG, "<"); else { assert(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1)); av_log(s->avctx, AV_LOG_DEBUG, "X"); } // segmentation if (IS_8X8(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "+"); else if (IS_16X8(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "-"); else if (IS_8X16(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "|"); else if (IS_INTRA(mb_type) || IS_16X16(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, " "); else av_log(s->avctx, AV_LOG_DEBUG, "?"); if (IS_INTERLACED(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "="); else av_log(s->avctx, AV_LOG_DEBUG, " "); } } av_log(s->avctx, AV_LOG_DEBUG, "\n"); } } }
void ff_print_debug_info(MpegEncContext *s, Picture *p) { AVFrame *pict; if (s->avctx->hwaccel || !p || !p->mb_type) return; pict = &p->f; if (s->avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) { int x,y; av_log(s->avctx,AV_LOG_DEBUG,"New frame, type: "); switch (pict->pict_type) { case AV_PICTURE_TYPE_I: av_log(s->avctx,AV_LOG_DEBUG,"I\n"); break; case AV_PICTURE_TYPE_P: av_log(s->avctx,AV_LOG_DEBUG,"P\n"); break; case AV_PICTURE_TYPE_B: av_log(s->avctx,AV_LOG_DEBUG,"B\n"); break; case AV_PICTURE_TYPE_S: av_log(s->avctx,AV_LOG_DEBUG,"S\n"); break; case AV_PICTURE_TYPE_SI: av_log(s->avctx,AV_LOG_DEBUG,"SI\n"); break; case AV_PICTURE_TYPE_SP: av_log(s->avctx,AV_LOG_DEBUG,"SP\n"); break; } for (y = 0; y < s->mb_height; y++) { for (x = 0; x < s->mb_width; x++) { if (s->avctx->debug & FF_DEBUG_SKIP) { int count = s->mbskip_table[x + y * s->mb_stride]; if (count > 9) count = 9; av_log(s->avctx, AV_LOG_DEBUG, "%1d", count); } if (s->avctx->debug & FF_DEBUG_QP) { av_log(s->avctx, AV_LOG_DEBUG, "%2d", p->qscale_table[x + y * s->mb_stride]); } if (s->avctx->debug & FF_DEBUG_MB_TYPE) { int mb_type = p->mb_type[x + y * s->mb_stride];
478
1
static void file_add_remove(struct diff_options *options, int addremove, unsigned mode, const unsigned char *sha1, const char *base, const char *path) { int diff = REV_TREE_DIFFERENT; /* * Is it an add of a new file? It means that the old tree * didn't have it at all, so we will turn "REV_TREE_SAME" -> * "REV_TREE_NEW", but leave any "REV_TREE_DIFFERENT" alone * (and if it already was "REV_TREE_NEW", we'll keep it * "REV_TREE_NEW" of course). */ if (addremove == '+') { diff = tree_difference; if (diff != REV_TREE_SAME) return; diff = REV_TREE_NEW; } tree_difference = diff; if (tree_difference == REV_TREE_DIFFERENT) DIFF_OPT_SET(options, HAS_CHANGES); }
static void file_add_remove(struct diff_options *options, int addremove, unsigned mode, const unsigned char *sha1, const char *base, const char *path) { int diff = REV_TREE_DIFFERENT; if (addremove == '+') { diff = tree_difference; if (diff != REV_TREE_SAME) return; diff = REV_TREE_NEW; } tree_difference = diff; if (tree_difference == REV_TREE_DIFFERENT) DIFF_OPT_SET(options, HAS_CHANGES); }
479
0
void setPrivate(bool p) { is_private = p; }
void setPrivate(bool p) { is_private = p; }
480
0
static int SpoolssSetForm_q ( tvbuff_t * tvb , int offset , packet_info * pinfo , proto_tree * tree , dcerpc_info * di , guint8 * drep _U_ ) { char * name = NULL ; guint32 level ; proto_item * hidden_item ; hidden_item = proto_tree_add_uint ( tree , hf_form , tvb , offset , 0 , 1 ) ; PROTO_ITEM_SET_HIDDEN ( hidden_item ) ; offset = dissect_nt_policy_hnd ( tvb , offset , pinfo , tree , di , drep , hf_hnd , NULL , NULL , FALSE , FALSE ) ; offset = dissect_ndr_cvstring ( tvb , offset , pinfo , tree , di , drep , sizeof ( guint16 ) , hf_form_name , TRUE , & name ) ; if ( name ) col_append_fstr ( pinfo -> cinfo , COL_INFO , ", %s" , name ) ; offset = dissect_ndr_uint32 ( tvb , offset , pinfo , tree , di , drep , hf_form_level , & level ) ; col_append_fstr ( pinfo -> cinfo , COL_INFO , ", level %d" , level ) ; offset = dissect_FORM_CTR ( tvb , offset , pinfo , tree , di , drep ) ; return offset ; }
static int SpoolssSetForm_q ( tvbuff_t * tvb , int offset , packet_info * pinfo , proto_tree * tree , dcerpc_info * di , guint8 * drep _U_ ) { char * name = NULL ; guint32 level ; proto_item * hidden_item ; hidden_item = proto_tree_add_uint ( tree , hf_form , tvb , offset , 0 , 1 ) ; PROTO_ITEM_SET_HIDDEN ( hidden_item ) ; offset = dissect_nt_policy_hnd ( tvb , offset , pinfo , tree , di , drep , hf_hnd , NULL , NULL , FALSE , FALSE ) ; offset = dissect_ndr_cvstring ( tvb , offset , pinfo , tree , di , drep , sizeof ( guint16 ) , hf_form_name , TRUE , & name ) ; if ( name ) col_append_fstr ( pinfo -> cinfo , COL_INFO , ", %s" , name ) ; offset = dissect_ndr_uint32 ( tvb , offset , pinfo , tree , di , drep , hf_form_level , & level ) ; col_append_fstr ( pinfo -> cinfo , COL_INFO , ", level %d" , level ) ; offset = dissect_FORM_CTR ( tvb , offset , pinfo , tree , di , drep ) ; return offset ; }
481
1
static int show_modified(struct oneway_unpack_data *cbdata, struct cache_entry *old, struct cache_entry *new, int report_missing, int cached, int match_missing) { unsigned int mode, oldmode; const unsigned char *sha1; struct rev_info *revs = cbdata->revs; if (get_stat_data(new, &sha1, &mode, cached, match_missing, cbdata) < 0) { if (report_missing) diff_index_show_file(revs, "-", old, old->sha1, old->ce_mode); return -1; } if (revs->combine_merges && !cached && (hashcmp(sha1, old->sha1) || hashcmp(old->sha1, new->sha1))) { struct combine_diff_path *p; int pathlen = ce_namelen(new); p = xmalloc(combine_diff_path_size(2, pathlen)); p->path = (char *) &p->parent[2]; p->next = NULL; p->len = pathlen; memcpy(p->path, new->name, pathlen); p->path[pathlen] = 0; p->mode = mode; hashclr(p->sha1); memset(p->parent, 0, 2 * sizeof(struct combine_diff_parent)); p->parent[0].status = DIFF_STATUS_MODIFIED; p->parent[0].mode = new->ce_mode; hashcpy(p->parent[0].sha1, new->sha1); p->parent[1].status = DIFF_STATUS_MODIFIED; p->parent[1].mode = old->ce_mode; hashcpy(p->parent[1].sha1, old->sha1); show_combined_diff(p, 2, revs->dense_combined_merges, revs); free(p); return 0; } oldmode = old->ce_mode; if (mode == oldmode && !hashcmp(sha1, old->sha1) && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER)) return 0; diff_change(&revs->diffopt, oldmode, mode, old->sha1, sha1, old->name, NULL); return 0; }
static int show_modified(struct oneway_unpack_data *cbdata, struct cache_entry *old, struct cache_entry *new, int report_missing, int cached, int match_missing) { unsigned int mode, oldmode; const unsigned char *sha1; struct rev_info *revs = cbdata->revs; if (get_stat_data(new, &sha1, &mode, cached, match_missing, cbdata) < 0) { if (report_missing) diff_index_show_file(revs, "-", old, old->sha1, old->ce_mode); return -1; } if (revs->combine_merges && !cached && (hashcmp(sha1, old->sha1) || hashcmp(old->sha1, new->sha1))) { struct combine_diff_path *p; int pathlen = ce_namelen(new); p = xmalloc(combine_diff_path_size(2, pathlen)); p->path = (char *) &p->parent[2]; p->next = NULL; p->len = pathlen; memcpy(p->path, new->name, pathlen); p->path[pathlen] = 0; p->mode = mode; hashclr(p->sha1); memset(p->parent, 0, 2 * sizeof(struct combine_diff_parent)); p->parent[0].status = DIFF_STATUS_MODIFIED; p->parent[0].mode = new->ce_mode; hashcpy(p->parent[0].sha1, new->sha1); p->parent[1].status = DIFF_STATUS_MODIFIED; p->parent[1].mode = old->ce_mode; hashcpy(p->parent[1].sha1, old->sha1); show_combined_diff(p, 2, revs->dense_combined_merges, revs); free(p); return 0; } oldmode = old->ce_mode; if (mode == oldmode && !hashcmp(sha1, old->sha1) && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER)) return 0; diff_change(&revs->diffopt, oldmode, mode, old->sha1, sha1, old->name, NULL); return 0; }
482
1
int IniParser::write() { int bugs = 0; if (!inifile.isDirty()) { y2debug ("File %s did not change. Not saving.", multiple_files ? files[0].c_str () : file.c_str ()); return 0; } if (read_only) { y2debug ("Attempt to write file %s that was mounted read-only. Not saving.", multiple_files ? files[0].c_str () : file.c_str ()); return 0; } UpdateIfModif (); if (multiple_files) { IniIterator ci = inifile.getContainerBegin (), ce = inifile.getContainerEnd (); for (;ci != ce; ++ci) { if (ci->t () == SECTION) { IniSection&s = ci->s (); int wb = s.getRewriteBy (); // bug #19066 string filename = getFileName (s.getName (), wb); // This is the only place where we unmark a // section for deletion - when it is a file // that got some data again. We can do it // because we only erase the files afterwards. deleted_sections.erase (filename); if (!s.isDirty ()) { y2debug ("Skipping file %s that was not changed.", filename.c_str()); continue; } s.initReadBy (); // ensure that the directories exist Pathname pn (filename); PathInfo::assert_dir (pn.dirname ()); ofstream of(filename.c_str()); if (!of.good()) { bugs++; y2error ("Can not open file %s for write", filename.c_str()); continue; } write_helper (s, of, 0); s.clean(); of.close (); } else { y2error ("Value %s encountered at multifile top level", ci->e ().getName ()); } } // FIXME: update time stamps of files... // erase removed files... for (set<string>::iterator i = deleted_sections.begin (); i!=deleted_sections.end();i++) if (multi_files.find (*i) != multi_files.end ()) { y2debug ("Removing file %s\n", (*i).c_str()); unlink ((*i).c_str()); } } else { // ensure that the directories exist Pathname pn (file); PathInfo::assert_dir (pn.dirname ()); ofstream of(file.c_str()); if (!of.good()) { y2error ("Can not open file %s for write", file.c_str()); return -1; } write_helper (inifile, of, 0); of.close(); timestamp = getTimeStamp (); } inifile.clean (); return bugs ? -1 : 0; }
int IniParser::write() { int bugs = 0; if (!inifile.isDirty()) { y2debug ("File %s did not change. Not saving.", multiple_files ? files[0].c_str () : file.c_str ()); return 0; } if (read_only) { y2debug ("Attempt to write file %s that was mounted read-only. Not saving.", multiple_files ? files[0].c_str () : file.c_str ()); return 0; } UpdateIfModif (); if (multiple_files) { IniIterator ci = inifile.getContainerBegin (), ce = inifile.getContainerEnd (); for (;ci != ce; ++ci) { if (ci->t () == SECTION) { IniSection&s = ci->s (); int wb = s.getRewriteBy (); string filename = getFileName (s.getName (), wb); deleted_sections.erase (filename); if (!s.isDirty ()) { y2debug ("Skipping file %s that was not changed.", filename.c_str()); continue; } s.initReadBy (); Pathname pn (filename); PathInfo::assert_dir (pn.dirname ()); ofstream of(filename.c_str()); if (!of.good()) { bugs++; y2error ("Can not open file %s for write", filename.c_str()); continue; } write_helper (s, of, 0); s.clean(); of.close (); } else { y2error ("Value %s encountered at multifile top level", ci->e ().getName ()); } } for (set<string>::iterator i = deleted_sections.begin (); i!=deleted_sections.end();i++) if (multi_files.find (*i) != multi_files.end ()) { y2debug ("Removing file %s\n", (*i).c_str()); unlink ((*i).c_str()); } } else { Pathname pn (file); PathInfo::assert_dir (pn.dirname ()); ofstream of(file.c_str()); if (!of.good()) { y2error ("Can not open file %s for write", file.c_str()); return -1; } write_helper (inifile, of, 0); of.close(); timestamp = getTimeStamp (); } inifile.clean (); return bugs ? -1 : 0; }
483
1
spnego_gss_wrap( OM_uint32 *minor_status, gss_ctx_id_t context_handle, int conf_req_flag, gss_qop_t qop_req, gss_buffer_t input_message_buffer, int *conf_state, gss_buffer_t output_message_buffer) { OM_uint32 ret; ret = gss_wrap(minor_status, context_handle, conf_req_flag, qop_req, input_message_buffer, conf_state, output_message_buffer); return (ret); }
spnego_gss_wrap( OM_uint32 *minor_status, gss_ctx_id_t context_handle, int conf_req_flag, gss_qop_t qop_req, gss_buffer_t input_message_buffer, int *conf_state, gss_buffer_t output_message_buffer) { OM_uint32 ret; ret = gss_wrap(minor_status, context_handle, conf_req_flag, qop_req, input_message_buffer, conf_state, output_message_buffer); return (ret); }
484
1
static int xan_huffman_decode(unsigned char *dest, const unsigned char *src, int dest_len) { unsigned char byte = *src++; unsigned char ival = byte + 0x16; const unsigned char * ptr = src + byte*2; unsigned char val = ival; unsigned char *dest_end = dest + dest_len; GetBitContext gb; init_get_bits(&gb, ptr, 0); // FIXME: no src size available while ( val != 0x16 ) { val = src[val - 0x17 + get_bits1(&gb) * byte]; if ( val < 0x16 ) { if (dest + 1 > dest_end) return 0; *dest++ = val; val = ival; } } return 0; }
static int xan_huffman_decode(unsigned char *dest, const unsigned char *src, int dest_len) { unsigned char byte = *src++; unsigned char ival = byte + 0x16; const unsigned char * ptr = src + byte*2; unsigned char val = ival; unsigned char *dest_end = dest + dest_len; GetBitContext gb; init_get_bits(&gb, ptr, 0);
485
1
static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const char *base, int baselen, struct diff_options *opt) { unsigned mode1, mode2; const char *path1, *path2; const unsigned char *sha1, *sha2; int cmp, pathlen1, pathlen2; sha1 = tree_entry_extract(t1, &path1, &mode1); sha2 = tree_entry_extract(t2, &path2, &mode2); pathlen1 = tree_entry_len(path1, sha1); pathlen2 = tree_entry_len(path2, sha2); cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2); if (cmp < 0) { show_entry(opt, "-", t1, base, baselen); return -1; } if (cmp > 0) { show_entry(opt, "+", t2, base, baselen); return 1; } if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2) return 0; /* * If the filemode has changed to/from a directory from/to a regular * file, we need to consider it a remove and an add. */ if (S_ISDIR(mode1) != S_ISDIR(mode2)) { show_entry(opt, "-", t1, base, baselen); show_entry(opt, "+", t2, base, baselen); return 0; } if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) { int retval; char *newbase = malloc_base(base, baselen, path1, pathlen1); if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) opt->change(opt, mode1, mode2, sha1, sha2, base, path1); retval = diff_tree_sha1(sha1, sha2, newbase, opt); free(newbase); return retval; } opt->change(opt, mode1, mode2, sha1, sha2, base, path1); return 0; }
static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const char *base, int baselen, struct diff_options *opt) { unsigned mode1, mode2; const char *path1, *path2; const unsigned char *sha1, *sha2; int cmp, pathlen1, pathlen2; sha1 = tree_entry_extract(t1, &path1, &mode1); sha2 = tree_entry_extract(t2, &path2, &mode2); pathlen1 = tree_entry_len(path1, sha1); pathlen2 = tree_entry_len(path2, sha2); cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2); if (cmp < 0) { show_entry(opt, "-", t1, base, baselen); return -1; } if (cmp > 0) { show_entry(opt, "+", t2, base, baselen); return 1; } if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2) return 0; if (S_ISDIR(mode1) != S_ISDIR(mode2)) { show_entry(opt, "-", t1, base, baselen); show_entry(opt, "+", t2, base, baselen); return 0; } if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) { int retval; char *newbase = malloc_base(base, baselen, path1, pathlen1); if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) opt->change(opt, mode1, mode2, sha1, sha2, base, path1); retval = diff_tree_sha1(sha1, sha2, newbase, opt); free(newbase); return retval; } opt->change(opt, mode1, mode2, sha1, sha2, base, path1); return 0; }
487
1
static int kvm_log_stop(CPUPhysMemoryClient *client, target_phys_addr_t phys_addr, ram_addr_t size) { return kvm_dirty_pages_log_change(phys_addr, size, false); }
static int kvm_log_stop(CPUPhysMemoryClient *client, target_phys_addr_t phys_addr, ram_addr_t size) { return kvm_dirty_pages_log_change(phys_addr, size, false); }
489
0
int IniParser::write_file(const string & filename, IniSection & section) { // ensure that the directories exist Pathname pn(filename); PathInfo::assert_dir (pn.dirname ()); mode_t file_umask = section.isPrivate()? 0077: 0022; mode_t orig_umask = umask(file_umask); // rewriting an existing file wouldnt change its mode unlink(filename.c_str()); ofstream of(filename.c_str()); if (!of.good()) { y2error ("Can not open file %s for write", filename.c_str()); return -1; } write_helper (section, of, 0); of.close(); umask(orig_umask); return 0; }
int IniParser::write_file(const string & filename, IniSection & section) { Pathname pn(filename); PathInfo::assert_dir (pn.dirname ()); mode_t file_umask = section.isPrivate()? 0077: 0022; mode_t orig_umask = umask(file_umask); unlink(filename.c_str()); ofstream of(filename.c_str()); if (!of.good()) { y2error ("Can not open file %s for write", filename.c_str()); return -1; } write_helper (section, of, 0); of.close(); umask(orig_umask); return 0; }
490
1
static void diff_index_show_file(struct rev_info *revs, const char *prefix, struct cache_entry *ce, const unsigned char *sha1, unsigned int mode) { diff_addremove(&revs->diffopt, prefix[0], mode, sha1, ce->name, NULL); }
static void diff_index_show_file(struct rev_info *revs, const char *prefix, struct cache_entry *ce, const unsigned char *sha1, unsigned int mode) { diff_addremove(&revs->diffopt, prefix[0], mode, sha1, ce->name, NULL); }
491
1
void MPV_common_end(MpegEncContext *s) { int i; if (s->motion_val) free(s->motion_val); if (s->h263_pred) { free(s->dc_val[0]); free(s->ac_val[0]); free(s->coded_block); free(s->mbintra_table); } if (s->mbskip_table) free(s->mbskip_table); for(i=0;i<3;i++) { free(s->last_picture_base[i]); free(s->next_picture_base[i]); if (s->has_b_frames) free(s->aux_picture_base[i]); } s->context_initialized = 0; }
void MPV_common_end(MpegEncContext *s) { int i; if (s->motion_val) free(s->motion_val); if (s->h263_pred) { free(s->dc_val[0]); free(s->ac_val[0]); free(s->coded_block); free(s->mbintra_table); } if (s->mbskip_table) free(s->mbskip_table); for(i=0;i<3;i++) { free(s->last_picture_base[i]); free(s->next_picture_base[i]); if (s->has_b_frames) free(s->aux_picture_base[i]); } s->context_initialized = 0; }
492
1
spnego_gss_wrap_aead(OM_uint32 *minor_status, gss_ctx_id_t context_handle, int conf_req_flag, gss_qop_t qop_req, gss_buffer_t input_assoc_buffer, gss_buffer_t input_payload_buffer, int *conf_state, gss_buffer_t output_message_buffer) { OM_uint32 ret; ret = gss_wrap_aead(minor_status, context_handle, conf_req_flag, qop_req, input_assoc_buffer, input_payload_buffer, conf_state, output_message_buffer); return (ret); }
spnego_gss_wrap_aead(OM_uint32 *minor_status, gss_ctx_id_t context_handle, int conf_req_flag, gss_qop_t qop_req, gss_buffer_t input_assoc_buffer, gss_buffer_t input_payload_buffer, int *conf_state, gss_buffer_t output_message_buffer) { OM_uint32 ret; ret = gss_wrap_aead(minor_status, context_handle, conf_req_flag, qop_req, input_assoc_buffer, input_payload_buffer, conf_state, output_message_buffer); return (ret); }
494
0
rfbBool rfbFilenameTranslate2UNIX ( rfbClientPtr cl , char * path , char * unixPath , size_t unixPathMaxLen ) { int x ; char * home = NULL ; FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN ( "" , cl , FALSE ) ; if ( strlen ( path ) >= unixPathMaxLen ) return FALSE ; if ( path [ 0 ] == 'C' && path [ 1 ] == ':' ) strcpy ( unixPath , & path [ 2 ] ) ; else { home = getenv ( "HOME" ) ; if ( home != NULL ) { if ( ( strlen ( path ) + strlen ( home ) + 1 ) >= unixPathMaxLen ) return FALSE ; strcpy ( unixPath , home ) ; strcat ( unixPath , "/" ) ; strcat ( unixPath , path ) ; } else strcpy ( unixPath , path ) ; } for ( x = 0 ; x < strlen ( unixPath ) ; x ++ ) if ( unixPath [ x ] == '\\' ) unixPath [ x ] = '/' ; return TRUE ; }
rfbBool rfbFilenameTranslate2UNIX ( rfbClientPtr cl , char * path , char * unixPath , size_t unixPathMaxLen ) { int x ; char * home = NULL ; FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN ( "" , cl , FALSE ) ; if ( strlen ( path ) >= unixPathMaxLen ) return FALSE ; if ( path [ 0 ] == 'C' && path [ 1 ] == ':' ) strcpy ( unixPath , & path [ 2 ] ) ; else { home = getenv ( "HOME" ) ; if ( home != NULL ) { if ( ( strlen ( path ) + strlen ( home ) + 1 ) >= unixPathMaxLen ) return FALSE ; strcpy ( unixPath , home ) ; strcat ( unixPath , "/" ) ; strcat ( unixPath , path ) ; } else strcpy ( unixPath , path ) ; } for ( x = 0 ; x < strlen ( unixPath ) ; x ++ ) if ( unixPath [ x ] == '\\' ) unixPath [ x ] = '/' ; return TRUE ; }
495
1
static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options) { BDRVBlkdebugState *s = bs->opaque; QDict *opts; const QDictEntry *e; bool force_json = false; for (e = qdict_first(options); e; e = qdict_next(options, e)) { if (strcmp(qdict_entry_key(e), "config") && strcmp(qdict_entry_key(e), "x-image")) { force_json = true; break; } } if (force_json && !bs->file->bs->full_open_options) { /* The config file cannot be recreated, so creating a plain filename * is impossible */ return; } if (!force_json && bs->file->bs->exact_filename[0]) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "blkdebug:%s:%s", s->config_file ?: "", bs->file->bs->exact_filename); } opts = qdict_new(); qdict_put_str(opts, "driver", "blkdebug"); QINCREF(bs->file->bs->full_open_options); qdict_put(opts, "image", bs->file->bs->full_open_options); for (e = qdict_first(options); e; e = qdict_next(options, e)) { if (strcmp(qdict_entry_key(e), "x-image")) { qobject_incref(qdict_entry_value(e)); qdict_put_obj(opts, qdict_entry_key(e), qdict_entry_value(e)); } } bs->full_open_options = opts; }
static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options) { BDRVBlkdebugState *s = bs->opaque; QDict *opts; const QDictEntry *e; bool force_json = false; for (e = qdict_first(options); e; e = qdict_next(options, e)) { if (strcmp(qdict_entry_key(e), "config") && strcmp(qdict_entry_key(e), "x-image")) { force_json = true; break; } } if (force_json && !bs->file->bs->full_open_options) { return; } if (!force_json && bs->file->bs->exact_filename[0]) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "blkdebug:%s:%s", s->config_file ?: "", bs->file->bs->exact_filename); } opts = qdict_new(); qdict_put_str(opts, "driver", "blkdebug"); QINCREF(bs->file->bs->full_open_options); qdict_put(opts, "image", bs->file->bs->full_open_options); for (e = qdict_first(options); e; e = qdict_next(options, e)) { if (strcmp(qdict_entry_key(e), "x-image")) { qobject_incref(qdict_entry_value(e)); qdict_put_obj(opts, qdict_entry_key(e), qdict_entry_value(e)); } } bs->full_open_options = opts; }
496
1
static inline int usb_bt_fifo_dequeue(struct usb_hci_in_fifo_s *fifo, USBPacket *p) { int len; if (likely(!fifo->len)) return USB_RET_STALL; len = MIN(p->len, fifo->fifo[fifo->start].len); memcpy(p->data, fifo->fifo[fifo->start].data, len); if (len == p->len) { fifo->fifo[fifo->start].len -= len; fifo->fifo[fifo->start].data += len; } else { fifo->start ++; fifo->start &= CFIFO_LEN_MASK; fifo->len --; } fifo->dstart += len; fifo->dlen -= len; if (fifo->dstart >= fifo->dsize) { fifo->dstart = 0; fifo->dsize = DFIFO_LEN_MASK + 1; } return len; }
static inline int usb_bt_fifo_dequeue(struct usb_hci_in_fifo_s *fifo, USBPacket *p) { int len; if (likely(!fifo->len)) return USB_RET_STALL; len = MIN(p->len, fifo->fifo[fifo->start].len); memcpy(p->data, fifo->fifo[fifo->start].data, len); if (len == p->len) { fifo->fifo[fifo->start].len -= len; fifo->fifo[fifo->start].data += len; } else { fifo->start ++; fifo->start &= CFIFO_LEN_MASK; fifo->len --; } fifo->dstart += len; fifo->dlen -= len; if (fifo->dstart >= fifo->dsize) { fifo->dstart = 0; fifo->dsize = DFIFO_LEN_MASK + 1; } return len; }
498
1
static void show_entry(struct diff_options *opt, const char *prefix, struct tree_desc *desc, const char *base, int baselen) { unsigned mode; const char *path; const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode); if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) { enum object_type type; int pathlen = tree_entry_len(path, sha1); char *newbase = malloc_base(base, baselen, path, pathlen); struct tree_desc inner; void *tree; unsigned long size; tree = read_sha1_file(sha1, &type, &size); if (!tree || type != OBJ_TREE) die("corrupt tree sha %s", sha1_to_hex(sha1)); init_tree_desc(&inner, tree, size); show_tree(opt, prefix, &inner, newbase, baselen + 1 + pathlen); free(tree); free(newbase); } else { opt->add_remove(opt, prefix[0], mode, sha1, base, path); } }
static void show_entry(struct diff_options *opt, const char *prefix, struct tree_desc *desc, const char *base, int baselen) { unsigned mode; const char *path; const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode); if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) { enum object_type type; int pathlen = tree_entry_len(path, sha1); char *newbase = malloc_base(base, baselen, path, pathlen); struct tree_desc inner; void *tree; unsigned long size; tree = read_sha1_file(sha1, &type, &size); if (!tree || type != OBJ_TREE) die("corrupt tree sha %s", sha1_to_hex(sha1)); init_tree_desc(&inner, tree, size); show_tree(opt, prefix, &inner, newbase, baselen + 1 + pathlen); free(tree); free(newbase); } else { opt->add_remove(opt, prefix[0], mode, sha1, base, path); } }
499
1
spnego_gss_wrap_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, int conf_req_flag, gss_qop_t qop_req, int *conf_state, gss_iov_buffer_desc *iov, int iov_count) { OM_uint32 ret; ret = gss_wrap_iov(minor_status, context_handle, conf_req_flag, qop_req, conf_state, iov, iov_count); return (ret); }
spnego_gss_wrap_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, int conf_req_flag, gss_qop_t qop_req, int *conf_state, gss_iov_buffer_desc *iov, int iov_count) { OM_uint32 ret; ret = gss_wrap_iov(minor_status, context_handle, conf_req_flag, qop_req, conf_state, iov, iov_count); return (ret); }
500
0
void proto_item_prepend_text ( proto_item * pi , const char * format , ... ) { field_info * fi = NULL ; char representation [ ITEM_LABEL_LENGTH ] ; va_list ap ; TRY_TO_FAKE_THIS_REPR_VOID ( pi ) ; fi = PITEM_FINFO ( pi ) ; if ( fi == NULL ) { return ; } if ( ! PROTO_ITEM_IS_HIDDEN ( pi ) ) { if ( fi -> rep == NULL ) { ITEM_LABEL_NEW ( PNODE_POOL ( pi ) , fi -> rep ) ; proto_item_fill_label ( fi , representation ) ; } else g_strlcpy ( representation , fi -> rep -> representation , ITEM_LABEL_LENGTH ) ; va_start ( ap , format ) ; g_vsnprintf ( fi -> rep -> representation , ITEM_LABEL_LENGTH , format , ap ) ; va_end ( ap ) ; g_strlcat ( fi -> rep -> representation , representation , ITEM_LABEL_LENGTH ) ; } }
void proto_item_prepend_text ( proto_item * pi , const char * format , ... ) { field_info * fi = NULL ; char representation [ ITEM_LABEL_LENGTH ] ; va_list ap ; TRY_TO_FAKE_THIS_REPR_VOID ( pi ) ; fi = PITEM_FINFO ( pi ) ; if ( fi == NULL ) { return ; } if ( ! PROTO_ITEM_IS_HIDDEN ( pi ) ) { if ( fi -> rep == NULL ) { ITEM_LABEL_NEW ( PNODE_POOL ( pi ) , fi -> rep ) ; proto_item_fill_label ( fi , representation ) ; } else g_strlcpy ( representation , fi -> rep -> representation , ITEM_LABEL_LENGTH ) ; va_start ( ap , format ) ; g_vsnprintf ( fi -> rep -> representation , ITEM_LABEL_LENGTH , format , ap ) ; va_end ( ap ) ; g_strlcat ( fi -> rep -> representation , representation , ITEM_LABEL_LENGTH ) ; } }
501
0
SystemAgent::Execute (const YCPPath& path, const YCPValue& value, const YCPValue& arg) { y2debug ("Execute (%s)", path->toString().c_str()); if (path->isRoot ()) { return YCPError ("Execute () called without sub-path"); } if (value.isNull ()) { return YCPError (string("Execute (")+path->toString()+") without argument."); } const string cmd = path->component_str (0); // just a shortcut // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // .bash* if (cmd == "bash" || cmd == "bash_output" || cmd == "bash_background") { YCPValue environment = YCPVoid(); if (!arg.isNull()) environment = arg; /** * @builtin Execute (.target.bash, string command, map environment) -> integer * @builtin Execute (.target.bash_background, string command, map environment) -> integer * @builtin Execute (.target.bash_output, string command, map environment) -> map * * Runs a bash command. The command is stated as string. * The map variables can be used to give initial environment * definitions to the target. The keys have to be strings, * the values can be of any type. If you use string values, * the strings may _not_ contain single quotes. Escape them * with double backqoute, if you need them. This is subject * to change. * * The return value will be either an integer with the exitcode of * the shell script or a map:<pre> * $[ * <dd> "exit" : &lt;integer&gt;, //exitcode from shell script * <dd> "stdout" : &lt;string&gt;, //stdout of the command * <dd> "stderr" : &lt;string&gt; //stderr of the command * ]</pre> * * @example Execute (.target.bash, "/bin/touch $FILE ; exit 5", $["FILE":"/somedir/somefile"]) -> 5 * @example Execute (.target.bash_output, "/bin/touch $FILE ; exit 5", $["FILE":"/somedir/somefile"]) -> $[ "exit" : 5, "stdout" : "", "stderr" : ""] * */ if (value.isNull() || !value->isString()) { return YCPError ("Bad command argument to Execute (.bash, string command [, map env])"); } /* shell command must have rooted path */ string bashcommand = value->asString()->value(); #if 0 if (bashcommand[0] != '/') { ycp2warning ("", 0, "Execute (.bash, ...) without full path !"); } #endif /* check for and construct shell enviroment */ YCPMap variables; if (environment->isMap()) { variables = environment->asMap(); } string exports = ""; for (YCPMap::const_iterator pos = variables->begin(); pos != variables->end(); ++pos) { const YCPValue& key = pos->first; const YCPValue& value = pos->second; if (!key->isString()) { return YCPError (string("Invalid value '") + key->toString() + "' for target variable name, which must be a string"); } exports += "export " + key->asString()->value() + "='"; string valstr; if (value->isString()) { valstr = value->asString()->value(); } else { valstr = value->toString(); } exports += valstr + "'\n"; } /* execute script and return YCP{Integer|Map} */ if (cmd == "bash") { return YCPInteger (shellcommand (exports + bashcommand)); } else if (cmd == "bash_output") { return shellcommand_output (exports + bashcommand, tempdir); } else if (cmd == "bash_background") { return YCPInteger (shellcommand_background (exports + bashcommand)); } } // .bash* // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (cmd == "bash_input") { /** * @builtin Execute (.target.bash_input, string command, string input) -> integer * * Note: Function has only one used within YaST2 and is subject to * sudden change or removal. */ if (value.isNull() || !value->isString()) { return YCPError ("Bad command argument to Execute (.bash_input, string " "command, string stdin"); } if (arg.isNull() || !arg->isString()) { return YCPError ("Bad command argument to Execute (.bash_input, string " "command, string stdin"); } string command = value->asString ()->value (); command += ">/dev/null 2>&1"; string input = arg->asString ()->value (); input += "\n"; FILE* p = popen (command.c_str (), "w"); if (!p) { return YCPError ("popen failed"); } fwrite (input.c_str (), input.length (), 1, p); int ret = pclose (p); if (WIFEXITED (ret)) return YCPInteger (WEXITSTATUS (ret)); return YCPInteger (WTERMSIG (ret) + 128); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (cmd == "symlink") { /** * @builtin Execute (.target.symlink, string oldpath, string newpath) -> boolean * * Creates a symbolic link named newpath which contains the * string oldpath. * * Symbolic links are interpreted at run-time as if the contents * of the link had been substituted into the path being * followed to find a file or directory. * * The return value is true or false, depending of the success. * * @example Execute (.target.symlink, "/lib/YaST2", "Y2") */ if (value.isNull () || arg.isNull () || !value->isString () || !arg->isString ()) { return YCPError ("Bad arguments to Execute (.symlink, string old, string new)"); } const char *oldpath = value->asString()->value_cstr(); const string newpath = arg->asString()->value(); y2milestone ("symlink %s -> %s", oldpath, newpath.c_str()); remove (newpath.c_str()); return YCPBoolean (symlink (oldpath, newpath.c_str()) == 0); } // .symlink // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (cmd == "mkdir") { /** * @builtin Execute (.target.mkdir, string path <, integer mode>)) -> boolean * * Creates a directory and all its parents, if necessary. * All created elements will have mode 0755 if mode is omitted. * * The return value is true or false, depending of the success, ie if * the directory exists afterwards. * * @example Execute (.target.mkdir, "/var/adm/mount") */ if (value.isNull() || !value->isString()) { return YCPError ("Bad path argument to Execute (.mkdir, string path)"); } string path = value->asString()->value(); int mode = 0755; if (!arg.isNull()) { if (arg->isInteger()) { mode = arg->asInteger()->value(); } else { return YCPError ("Bad mode argument to Execute (.mkdir, string path, integer mode)"); } } size_t pos = 0; y2milestone ("mkdir %s", path.c_str()); // Create leading components while (pos = path.find('/', pos + 1), pos != string::npos) { mkdir (path.substr(0, pos).c_str(), mode); } // Create the last part mkdir (path.substr(0, pos).c_str(), mode); struct stat sb; return YCPBoolean(stat(path.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (cmd == "mount") { /** * @builtin Execute (.target.mount, [ string device, string mountpoint <, string logfile>], [, string options])) -> boolean * * Mounts a (block) device at a mountpoint. * If logfile is given, the stderr of the mount cmd will be appended to * this file * * The return value is true or false, depending of the success * * @example Execute (.target.mount, ["/dev/fd0", "/floppy"], "-t msdos") * @example Execute (.target.mount, ["/dev/fd0", "/floppy", "/var/log/y2mountlog"], "-t msdos") */ if (value.isNull() || !value->isList()) { return YCPError ("Bad path argument to Execute (.mount, [ string device, string mountpoint <, string y2mountlog> ])"); } YCPList mountlist = value->asList(); if (mountlist->size() < 2 || !mountlist->value(0)->isString() || !mountlist->value(1)->isString()) { return YCPError ("Bad list values in argument to Execute (.mount, [ string device, string mountpoint ])"); } string mountcmd = "/bin/mount "; // arg is mount options, this is optional if (!arg.isNull()) { if (arg->isString()) { mountcmd += arg->asString()->value() + " "; } else { return YCPError ("Bad type of mode argument to Execute (.mount, string|list path, string mode)", YCPBoolean (false)); } } // device mountcmd += mountlist->value(0)->asString()->value() + " "; // mountpoint mountcmd += mountlist->value(1)->asString()->value(); if (mountlist->size() == 3) { if (mountlist->value(2)->isString()) { mountcmd += " 2> " + mountlist->value(2)->asString()->value(); } else { return YCPError ("Bad logfile argument to Execute (.mount, [ string device, string mountpoint, string logfile ])", YCPBoolean (false)); } } return YCPBoolean (shellcommand (mountcmd) == 0); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (cmd == "smbmount") { /** * @builtin Execute (.target.smbmount, [ string server_and_dir, string mountpoint <, string logfile>], [, string options])) -> boolean * * Mounts a SMB share at a mountpoint. * if logfile is given, the stderr of the mount cmd will be appended to * this file * * The return value is true or false, depending of the success * * @example Execute (.target.smbmount, ["//windows/crap", "/crap"], "-o guest") * @example Execute (.target.smbmount, ["//smb/share", "/smbshare", "/var/log/y2mountlog"]) */ if (value.isNull() || !value->isList()) { return YCPError ("Bad share argument to Execute (.smbmount, [ string share, string mountpoint <, string y2mountlog> ])"); } YCPList mountlist = value->asList(); if (mountlist->size() < 2 || !mountlist->value(0)->isString() || !mountlist->value(1)->isString()) { return YCPError ("Bad list values in argument to Execute (.smbmount, [ string share, string mountpoint ])"); } string mountcmd = "/usr/bin/smbmount "; if (!arg.isNull() && arg->isString()) { mountcmd += arg->asString()->value() + " "; } else { return YCPError ("Bad mode argument to Execute (.smbmount, string path, integer mode)"); } // share mountcmd += mountlist->value(0)->asString()->value() + " "; // mountpoint mountcmd += mountlist->value(1)->asString()->value(); // logfile if (mountlist->size() == 3) { if (mountlist->value(2)->isString()) { mountcmd += " 2> " + mountlist->value(2)->asString()->value(); } else { return YCPError ("Bad logfile argument to Execute (.smbmount, [ string device, string mountpoint, string logfile ])"); } } return YCPBoolean (shellcommand (mountcmd) == 0); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (cmd == "umount") { /** * @builtin Execute (.target.umount, string mountpoint) -> boolean * Unmounts a (block) device at a mountpoint. * * The return value is true or false, depending of the success. * * @example Execute (.target.umount, "/floppy") */ if (value.isNull() || !value->isString()) { return YCPError ("Bad mountpoint in Execute (.umount, string mountpoint)"); } string umountcmd = "/bin/umount " + value->asString()->value(); return YCPBoolean (shellcommand (umountcmd) == 0); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (cmd == "remove") { /** * @builtin Execute (.target.remove, string file) -> boolean * Remove a file. * * The return value is true or false depending on the success. * * @example Execute (.target.remove, "/tmp/xyz") */ if (value.isNull() || !value->isString()) { return YCPError ("Bad file in Execute (.remove, string file)"); } int ret = unlink (value->asString ()->value_cstr ()); return YCPBoolean (ret == 0); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (cmd == "insmod") { /** * @builtin Execute (.target.insmod, string module, string options) -> boolean * Load module in target system. * * The return value is true or false, depending of the success. * * @example Execute (.target.insmod, "a_module", "an option") */ if (value.isNull() || !value->isString()) { return YCPError ("Bad source in Execute (.insmod, string module, string options)"); } string insmodcmd = "/sbin/insmod " + value->asString()->value(); if (!arg.isNull() && arg->isString()) { insmodcmd += string (" ") + arg->asString()->value(); } return YCPBoolean (shellcommand (insmodcmd) == 0); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (cmd == "modprobe") { /** * @builtin Execute (.target.modprobe, string module, string options) -> boolean * Load module in target system. * * The return value is true or false, depending of the success. * * @example Execute (.target.modprobe, "a_module", "an option") */ if (value.isNull() || !value->isString()) { return YCPError ("Bad source in Execute (.modprobe, string module, string options)", YCPBoolean (false)); } string modprobecmd = "/sbin/modprobe " + value->asString()->value(); if (!arg.isNull() && arg->isString()) { modprobecmd += string (" ") + arg->asString()->value(); } return YCPBoolean (shellcommand (modprobecmd) == 0); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (cmd == "kill") { /** * @builtin Execute(.target.kill, integer pid [, integer signal]) -> boolean * Kill process with signal (SIGTERM if not specified). * * The return value is true or false, depending of the success. * * @example Execute (.target.kill, 1, 9) */ if (value.isNull() || !value->isInteger()) return YCPError("Bad PID in Execute (.kill, integer pid, integer signal)", YCPBoolean(false)); int signal = 15; int pid = value->asInteger()->value(); if (!arg.isNull() && arg->isInteger()) signal = arg->asInteger()->value(); return YCPBoolean (kill(pid,signal) != -1); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (cmd == "control") { if (path->length()<2) return YCPError(string("Undefined subpath for Execute (.control.")); if (path->component_str(1) == "printer_reset") { /** * @builtin Execute (.target.control.printer_reset, string device) -> boolean * Reset the given printer (trigger ioctl) * * The return value is true or false, depending of the success * */ if (value.isNull() || !value->isString()) { return YCPError ("Bad filename in Execute (.control.printer_reset, string device"); } string device = value->asString()->value(); int fd = open(device.c_str(), O_RDWR); if (fd < 0) { return YCPError (string("Open failed: \"" + device + "\" " + string(strerror(errno)?:""))); } int ret = ioctl(fd, LPRESET, NULL); close(fd); return YCPBoolean (ret == 0); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - return YCPError (string("Undefined subpath for Execute (") + path->toString() + ")"); }
SystemAgent::Execute (const YCPPath& path, const YCPValue& value, const YCPValue& arg) { y2debug ("Execute (%s)", path->toString().c_str()); if (path->isRoot ()) { return YCPError ("Execute () called without sub-path"); } if (value.isNull ()) { return YCPError (string("Execute (")+path->toString()+") without argument."); } const string cmd = path->component_str (0); if (cmd == "bash" || cmd == "bash_output" || cmd == "bash_background") { YCPValue environment = YCPVoid(); if (!arg.isNull()) environment = arg; if (value.isNull() || !value->isString()) { return YCPError ("Bad command argument to Execute (.bash, string command [, map env])"); } string bashcommand = value->asString()->value(); #if 0 if (bashcommand[0] != '/') { ycp2warning ("", 0, "Execute (.bash, ...) without full path !"); } #endif YCPMap variables; if (environment->isMap()) { variables = environment->asMap(); } string exports = ""; for (YCPMap::const_iterator pos = variables->begin(); pos != variables->end(); ++pos) { const YCPValue& key = pos->first; const YCPValue& value = pos->second; if (!key->isString()) { return YCPError (string("Invalid value '") + key->toString() + "' for target variable name, which must be a string"); } exports += "export " + key->asString()->value() + "='"; string valstr; if (value->isString()) { valstr = value->asString()->value(); } else { valstr = value->toString(); } exports += valstr + "'\n"; } if (cmd == "bash") { return YCPInteger (shellcommand (exports + bashcommand)); } else if (cmd == "bash_output") { return shellcommand_output (exports + bashcommand, tempdir); } else if (cmd == "bash_background") { return YCPInteger (shellcommand_background (exports + bashcommand)); } } else if (cmd == "bash_input") { if (value.isNull() || !value->isString()) { return YCPError ("Bad command argument to Execute (.bash_input, string " "command, string stdin"); } if (arg.isNull() || !arg->isString()) { return YCPError ("Bad command argument to Execute (.bash_input, string " "command, string stdin"); } string command = value->asString ()->value (); command += ">/dev/null 2>&1"; string input = arg->asString ()->value (); input += "\n"; FILE* p = popen (command.c_str (), "w"); if (!p) { return YCPError ("popen failed"); } fwrite (input.c_str (), input.length (), 1, p); int ret = pclose (p); if (WIFEXITED (ret)) return YCPInteger (WEXITSTATUS (ret)); return YCPInteger (WTERMSIG (ret) + 128); } else if (cmd == "symlink") { if (value.isNull () || arg.isNull () || !value->isString () || !arg->isString ()) { return YCPError ("Bad arguments to Execute (.symlink, string old, string new)"); } const char *oldpath = value->asString()->value_cstr(); const string newpath = arg->asString()->value(); y2milestone ("symlink %s -> %s", oldpath, newpath.c_str()); remove (newpath.c_str()); return YCPBoolean (symlink (oldpath, newpath.c_str()) == 0); } else if (cmd == "mkdir") { if (value.isNull() || !value->isString()) { return YCPError ("Bad path argument to Execute (.mkdir, string path)"); } string path = value->asString()->value(); int mode = 0755; if (!arg.isNull()) { if (arg->isInteger()) { mode = arg->asInteger()->value(); } else { return YCPError ("Bad mode argument to Execute (.mkdir, string path, integer mode)"); } } size_t pos = 0; y2milestone ("mkdir %s", path.c_str()); while (pos = path.find('/', pos + 1), pos != string::npos) { mkdir (path.substr(0, pos).c_str(), mode); } mkdir (path.substr(0, pos).c_str(), mode); struct stat sb; return YCPBoolean(stat(path.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)); } else if (cmd == "mount") { if (value.isNull() || !value->isList()) { return YCPError ("Bad path argument to Execute (.mount, [ string device, string mountpoint <, string y2mountlog> ])"); } YCPList mountlist = value->asList(); if (mountlist->size() < 2 || !mountlist->value(0)->isString() || !mountlist->value(1)->isString()) { return YCPError ("Bad list values in argument to Execute (.mount, [ string device, string mountpoint ])"); } string mountcmd = "/bin/mount "; if (!arg.isNull()) { if (arg->isString()) { mountcmd += arg->asString()->value() + " "; } else { return YCPError ("Bad type of mode argument to Execute (.mount, string|list path, string mode)", YCPBoolean (false)); } } mountcmd += mountlist->value(0)->asString()->value() + " "; mountcmd += mountlist->value(1)->asString()->value(); if (mountlist->size() == 3) { if (mountlist->value(2)->isString()) { mountcmd += " 2> " + mountlist->value(2)->asString()->value(); } else { return YCPError ("Bad logfile argument to Execute (.mount, [ string device, string mountpoint, string logfile ])", YCPBoolean (false)); } } return YCPBoolean (shellcommand (mountcmd) == 0); } else if (cmd == "smbmount") { if (value.isNull() || !value->isList()) { return YCPError ("Bad share argument to Execute (.smbmount, [ string share, string mountpoint <, string y2mountlog> ])"); } YCPList mountlist = value->asList(); if (mountlist->size() < 2 || !mountlist->value(0)->isString() || !mountlist->value(1)->isString()) { return YCPError ("Bad list values in argument to Execute (.smbmount, [ string share, string mountpoint ])"); } string mountcmd = "/usr/bin/smbmount "; if (!arg.isNull() && arg->isString()) { mountcmd += arg->asString()->value() + " "; } else { return YCPError ("Bad mode argument to Execute (.smbmount, string path, integer mode)"); } mountcmd += mountlist->value(0)->asString()->value() + " "; mountcmd += mountlist->value(1)->asString()->value(); if (mountlist->size() == 3) { if (mountlist->value(2)->isString()) { mountcmd += " 2> " + mountlist->value(2)->asString()->value(); } else { return YCPError ("Bad logfile argument to Execute (.smbmount, [ string device, string mountpoint, string logfile ])"); } } return YCPBoolean (shellcommand (mountcmd) == 0); } else if (cmd == "umount") { if (value.isNull() || !value->isString()) { return YCPError ("Bad mountpoint in Execute (.umount, string mountpoint)"); } string umountcmd = "/bin/umount " + value->asString()->value(); return YCPBoolean (shellcommand (umountcmd) == 0); } else if (cmd == "remove") { if (value.isNull() || !value->isString()) { return YCPError ("Bad file in Execute (.remove, string file)"); } int ret = unlink (value->asString ()->value_cstr ()); return YCPBoolean (ret == 0); } else if (cmd == "insmod") { if (value.isNull() || !value->isString()) { return YCPError ("Bad source in Execute (.insmod, string module, string options)"); } string insmodcmd = "/sbin/insmod " + value->asString()->value(); if (!arg.isNull() && arg->isString()) { insmodcmd += string (" ") + arg->asString()->value(); } return YCPBoolean (shellcommand (insmodcmd) == 0); } else if (cmd == "modprobe") { if (value.isNull() || !value->isString()) { return YCPError ("Bad source in Execute (.modprobe, string module, string options)", YCPBoolean (false)); } string modprobecmd = "/sbin/modprobe " + value->asString()->value(); if (!arg.isNull() && arg->isString()) { modprobecmd += string (" ") + arg->asString()->value(); } return YCPBoolean (shellcommand (modprobecmd) == 0); } else if (cmd == "kill") { if (value.isNull() || !value->isInteger()) return YCPError("Bad PID in Execute (.kill, integer pid, integer signal)", YCPBoolean(false)); int signal = 15; int pid = value->asInteger()->value(); if (!arg.isNull() && arg->isInteger()) signal = arg->asInteger()->value(); return YCPBoolean (kill(pid,signal) != -1); } else if (cmd == "control") { if (path->length()<2) return YCPError(string("Undefined subpath for Execute (.control.")); if (path->component_str(1) == "printer_reset") { if (value.isNull() || !value->isString()) { return YCPError ("Bad filename in Execute (.control.printer_reset, string device"); } string device = value->asString()->value(); int fd = open(device.c_str(), O_RDWR); if (fd < 0) { return YCPError (string("Open failed: \"" + device + "\" " + string(strerror(errno)?:""))); } int ret = ioctl(fd, LPRESET, NULL); close(fd); return YCPBoolean (ret == 0); } } return YCPError (string("Undefined subpath for Execute (") + path->toString() + ")"); }
502
1
static int block_load(QEMUFile *f, void *opaque, int version_id) { static int banner_printed; int len, flags; char device_name[256]; int64_t addr; BlockDriverState *bs; uint8_t *buf; do { addr = qemu_get_be64(f); flags = addr & ~BDRV_SECTOR_MASK; addr >>= BDRV_SECTOR_BITS; if (flags & BLK_MIG_FLAG_DEVICE_BLOCK) { int ret; /* get device name */ len = qemu_get_byte(f); qemu_get_buffer(f, (uint8_t *)device_name, len); device_name[len] = '\0'; bs = bdrv_find(device_name); if (!bs) { fprintf(stderr, "Error unknown block device %s\n", device_name); return -EINVAL; } buf = qemu_malloc(BLOCK_SIZE); qemu_get_buffer(f, buf, BLOCK_SIZE); ret = bdrv_write(bs, addr, buf, BDRV_SECTORS_PER_DIRTY_CHUNK); qemu_free(buf); if (ret < 0) { return ret; } } else if (flags & BLK_MIG_FLAG_PROGRESS) { if (!banner_printed) { printf("Receiving block device images\n"); banner_printed = 1; } printf("Completed %d %%%c", (int)addr, (addr == 100) ? '\n' : '\r'); fflush(stdout); } else if (!(flags & BLK_MIG_FLAG_EOS)) { fprintf(stderr, "Unknown flags\n"); return -EINVAL; } if (qemu_file_has_error(f)) { return -EIO; } } while (!(flags & BLK_MIG_FLAG_EOS)); return 0; }
static int block_load(QEMUFile *f, void *opaque, int version_id) { static int banner_printed; int len, flags; char device_name[256]; int64_t addr; BlockDriverState *bs; uint8_t *buf; do { addr = qemu_get_be64(f); flags = addr & ~BDRV_SECTOR_MASK; addr >>= BDRV_SECTOR_BITS; if (flags & BLK_MIG_FLAG_DEVICE_BLOCK) { int ret; len = qemu_get_byte(f); qemu_get_buffer(f, (uint8_t *)device_name, len); device_name[len] = '\0'; bs = bdrv_find(device_name); if (!bs) { fprintf(stderr, "Error unknown block device %s\n", device_name); return -EINVAL; } buf = qemu_malloc(BLOCK_SIZE); qemu_get_buffer(f, buf, BLOCK_SIZE); ret = bdrv_write(bs, addr, buf, BDRV_SECTORS_PER_DIRTY_CHUNK); qemu_free(buf); if (ret < 0) { return ret; } } else if (flags & BLK_MIG_FLAG_PROGRESS) { if (!banner_printed) { printf("Receiving block device images\n"); banner_printed = 1; } printf("Completed %d %%%c", (int)addr, (addr == 100) ? '\n' : '\r'); fflush(stdout); } else if (!(flags & BLK_MIG_FLAG_EOS)) { fprintf(stderr, "Unknown flags\n"); return -EINVAL; } if (qemu_file_has_error(f)) { return -EIO; } } while (!(flags & BLK_MIG_FLAG_EOS)); return 0; }
503
0
SystemAgent::Write (const YCPPath& path, const YCPValue& value, const YCPValue& arg) { y2debug ("Write (%s)", path->toString().c_str()); if (path->isRoot()) { ycp2error ("Write () called without sub-path"); return YCPBoolean (false); } const string cmd = path->component_str (0); // just a shortcut if (cmd == "passwd") { /** * @builtin Write (.target.passwd.&lt;name&gt;, string cryptval) -> bool * .passwd can be used to set or modify the encrypted password * of an already existing user in /etc/passwd and /etc/shadow. * * This call returns true on success and false, if it fails. * * @example Write (.target.passwd.root, crypt (a_passwd)) */ if (path->length() != 2) { ycp2error ("Bad path argument in call to Write (.passwd.name)"); return YCPBoolean (false); } if (value.isNull() || !value->isString()) { ycp2error ("Bad password argument in call to Write (.passwd)"); return YCPBoolean (false); } string passwd = value->asString()->value(); string bashcommand = string ("/bin/echo '") + path->component_str (1).c_str () + ":" + passwd + "' |/usr/sbin/chpasswd -e >/dev/null 2>&1"; // Don't write the password into the log - even though it's crypted // y2debug("Executing: '%s'", bashcommand.c_str()); int exitcode = system(bashcommand.c_str()); return YCPBoolean (WIFEXITED (exitcode) && WEXITSTATUS (exitcode) == 0); } else if (cmd == "string") { /** * @builtin Write (.target.string, string filename, string value) -> boolean * @builtin Write (.target.string, [string filename, integer filemode] , string value) -> boolean * Writes the string <tt>value</tt> into a file. If the file already * exists, the existing file is overwritten. The return value is * true, if the file has been written successfully. * * @example Write(.target.string, "/etc/papersize", "a4") -> true * @example Write(.target.string, ["/etc/rsyncd.secrets", 0600], "user:passwd") -> true */ if (value.isNull() || !(value->isString() || value->isList())) { ycp2error ("Bad filename arg for Write (.string ...)"); return YCPBoolean (false); } string filename; mode_t filemode = 0644; if (value->isString()) { filename = value->asString()->value(); } else { // value is list YCPList flist = value->asList(); if ((flist->size() != 2) || (!flist->value(0)->isString()) || (!flist->value(1)->isInteger())) { ycp2error ("Bad [filename, mode] list in call to Write (%s, [ string filename, integer mode ], ...)", cmd.c_str ()); return YCPBoolean (false); } filename = flist->value(0)->asString()->value(); filemode = (int)(flist->value(1)->asInteger()->value()); } if (arg.isNull() || !arg->isString()) { ycp2error ("Bad string value for Write (.string ...)"); return YCPBoolean (false); } int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, filemode); if (fd >= 0) { string cont = arg->asString()->value(); const char *buffer = cont.c_str(); size_t length = cont.length(); size_t written = write(fd, buffer, length); close(fd); return YCPBoolean (written == length); } ycp2error ("Write (.string, \"%s\") failed: %s", filename.c_str (), strerror (errno)); return YCPBoolean(false); } else if (cmd == "byte") { /** * @builtin Write (.target.byte, string filename, byteblock) -> boolean * Write a byteblock into a file. */ if (value.isNull () || !value->isString ()) { ycp2error ("Bad filename arg for Write (.byte, ...)"); return YCPBoolean (false); } if (arg.isNull () || !arg->isByteblock ()) { ycp2error ("Bad value for Write (.byte, filename, byteblock)"); return YCPBoolean (false); } string filename = value->asString ()->value (); YCPByteblock byteblock = arg->asByteblock (); int fd = open (filename.c_str (), O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd >= 0) { size_t size = byteblock->size (); size_t write_size = write (fd, byteblock->value (), size); close (fd); return YCPBoolean (write_size == size); } ycp2error ("Write (.byte, \"%s\") failed: %s", filename.c_str (), strerror (errno)); return YCPBoolean (false); } else if (cmd == "ycp" || cmd == "yast2") { /** * @builtin Write (.target.ycp, string filename, any value) -> boolean * Opens a file for writing and prints the value <tt>value</tt> in * YCP syntax to that file. Returns true, if the file has * been written, false otherwise. The newly created file gets * the mode 0644 minus umask. Furthermore any missing directory in the * pathname <tt>filename</tt> is created automatically. */ /** * @builtin Write (.target.ycp, [ string filename, integer mode], any value) -> boolean * Opens a file for writing and prints the value <tt>value</tt> in * YCP syntax to that file. Returns true, if the file has * been written, false otherwise. The newly created file gets * the mode mode minus umask. Furthermore any missing directory in the * pathname <tt>filename</tt> is created automatically. */ // either string or list if (value.isNull() || !(value->isString() || value->isList())) { ycp2error ("Bad arguments to Write (%s, string filename ...)", cmd.c_str ()); return YCPBoolean (false); } string filename; mode_t filemode = 0644; if (value->isString()) { filename = value->asString()->value(); } else { // value is list YCPList flist = value->asList(); if ((flist->size() != 2) || (!flist->value(0)->isString()) || (!flist->value(1)->isInteger())) { ycp2error ("Bad [filename, mode] list in call to Write (%s, [ string filename, integer mode ], ...)", cmd.c_str ()); return YCPBoolean (false); } filename = flist->value(0)->asString()->value(); filemode = (int)(flist->value(1)->asInteger()->value()); } if (filename.length() == 0) { ycp2error ("Invalid empty filename in Write (%s, ...)", cmd.c_str ()); return YCPBoolean (false); } // Create directory, if missing size_t pos = 0; while (pos = filename.find('/', pos + 1), pos != string::npos) mkdir (filename.substr(0, pos).c_str(), 0775); // Remove file, if existing remove (filename.c_str()); int fd = open (filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC , filemode); bool success = false; if (fd < 0) { ycp2error ("Error opening '%s': %s", filename.c_str (), strerror (errno)); return YCPBoolean (false); } // string contents = (arg.isNull() ? "" : arg->toString()); string contents = (arg.isNull() ? "" : dump_value(0, arg)); ssize_t size = contents.length(); if (size == write(fd, contents.c_str(), size) && write(fd, "\n", 1) == 1) success = true; close(fd); return YCPBoolean(success); } ycp2error ("Undefined subpath for Write (%s)", path->toString ().c_str ()); return YCPBoolean (false); }
SystemAgent::Write (const YCPPath& path, const YCPValue& value, const YCPValue& arg) { y2debug ("Write (%s)", path->toString().c_str()); if (path->isRoot()) { ycp2error ("Write () called without sub-path"); return YCPBoolean (false); } const string cmd = path->component_str (0); if (cmd == "passwd") { if (path->length() != 2) { ycp2error ("Bad path argument in call to Write (.passwd.name)"); return YCPBoolean (false); } if (value.isNull() || !value->isString()) { ycp2error ("Bad password argument in call to Write (.passwd)"); return YCPBoolean (false); } string passwd = value->asString()->value(); string bashcommand = string ("/bin/echo '") + path->component_str (1).c_str () + ":" + passwd + "' |/usr/sbin/chpasswd -e >/dev/null 2>&1"; int exitcode = system(bashcommand.c_str()); return YCPBoolean (WIFEXITED (exitcode) && WEXITSTATUS (exitcode) == 0); } else if (cmd == "string") { if (value.isNull() || !(value->isString() || value->isList())) { ycp2error ("Bad filename arg for Write (.string ...)"); return YCPBoolean (false); } string filename; mode_t filemode = 0644; if (value->isString()) { filename = value->asString()->value(); } else { YCPList flist = value->asList(); if ((flist->size() != 2) || (!flist->value(0)->isString()) || (!flist->value(1)->isInteger())) { ycp2error ("Bad [filename, mode] list in call to Write (%s, [ string filename, integer mode ], ...)", cmd.c_str ()); return YCPBoolean (false); } filename = flist->value(0)->asString()->value(); filemode = (int)(flist->value(1)->asInteger()->value()); } if (arg.isNull() || !arg->isString()) { ycp2error ("Bad string value for Write (.string ...)"); return YCPBoolean (false); } int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, filemode); if (fd >= 0) { string cont = arg->asString()->value(); const char *buffer = cont.c_str(); size_t length = cont.length(); size_t written = write(fd, buffer, length); close(fd); return YCPBoolean (written == length); } ycp2error ("Write (.string, \"%s\") failed: %s", filename.c_str (), strerror (errno)); return YCPBoolean(false); } else if (cmd == "byte") { if (value.isNull () || !value->isString ()) { ycp2error ("Bad filename arg for Write (.byte, ...)"); return YCPBoolean (false); } if (arg.isNull () || !arg->isByteblock ()) { ycp2error ("Bad value for Write (.byte, filename, byteblock)"); return YCPBoolean (false); } string filename = value->asString ()->value (); YCPByteblock byteblock = arg->asByteblock (); int fd = open (filename.c_str (), O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd >= 0) { size_t size = byteblock->size (); size_t write_size = write (fd, byteblock->value (), size); close (fd); return YCPBoolean (write_size == size); } ycp2error ("Write (.byte, \"%s\") failed: %s", filename.c_str (), strerror (errno)); return YCPBoolean (false); } else if (cmd == "ycp" || cmd == "yast2") { if (value.isNull() || !(value->isString() || value->isList())) { ycp2error ("Bad arguments to Write (%s, string filename ...)", cmd.c_str ()); return YCPBoolean (false); } string filename; mode_t filemode = 0644; if (value->isString()) { filename = value->asString()->value(); } else { YCPList flist = value->asList(); if ((flist->size() != 2) || (!flist->value(0)->isString()) || (!flist->value(1)->isInteger())) { ycp2error ("Bad [filename, mode] list in call to Write (%s, [ string filename, integer mode ], ...)", cmd.c_str ()); return YCPBoolean (false); } filename = flist->value(0)->asString()->value(); filemode = (int)(flist->value(1)->asInteger()->value()); } if (filename.length() == 0) { ycp2error ("Invalid empty filename in Write (%s, ...)", cmd.c_str ()); return YCPBoolean (false); } size_t pos = 0; while (pos = filename.find('/', pos + 1), pos != string::npos) mkdir (filename.substr(0, pos).c_str(), 0775); remove (filename.c_str()); int fd = open (filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC , filemode); bool success = false; if (fd < 0) { ycp2error ("Error opening '%s': %s", filename.c_str (), strerror (errno)); return YCPBoolean (false); } string contents = (arg.isNull() ? "" : dump_value(0, arg)); ssize_t size = contents.length(); if (size == write(fd, contents.c_str(), size) && write(fd, "\n", 1) == 1) success = true; close(fd); return YCPBoolean(success); } ycp2error ("Undefined subpath for Write (%s)", path->toString ().c_str ()); return YCPBoolean (false); }
504
1
static void file_change(struct diff_options *options, unsigned old_mode, unsigned new_mode, const unsigned char *old_sha1, const unsigned char *new_sha1, const char *base, const char *path) { tree_difference = REV_TREE_DIFFERENT; DIFF_OPT_SET(options, HAS_CHANGES); }
static void file_change(struct diff_options *options, unsigned old_mode, unsigned new_mode, const unsigned char *old_sha1, const unsigned char *new_sha1, const char *base, const char *path) { tree_difference = REV_TREE_DIFFERENT; DIFF_OPT_SET(options, HAS_CHANGES); }
507
0
static void mark_desktop_file_executable_task_thread_func ( GTask * task , gpointer source_object , gpointer task_data , GCancellable * cancellable ) { MarkTrustedJob * job = task_data ; CommonJob * common ; common = ( CommonJob * ) job ; nautilus_progress_info_start ( job -> common . progress ) ; mark_desktop_file_executable ( common , cancellable , job -> file , job -> interactive ) ; }
static void mark_desktop_file_executable_task_thread_func ( GTask * task , gpointer source_object , gpointer task_data , GCancellable * cancellable ) { MarkTrustedJob * job = task_data ; CommonJob * common ; common = ( CommonJob * ) job ; nautilus_progress_info_start ( job -> common . progress ) ; mark_desktop_file_executable ( common , cancellable , job -> file , job -> interactive ) ; }
508
1
SystemAgent::Write (const YCPPath& path, const YCPValue& value, const YCPValue& arg) { y2debug ("Write (%s)", path->toString().c_str()); if (path->isRoot()) { ycp2error ("Write () called without sub-path"); return YCPBoolean (false); } const string cmd = path->component_str (0); // just a shortcut if (cmd == "passwd") { /** * @builtin Write (.target.passwd.&lt;name&gt;, string cryptval) -> bool * .passwd can be used to set or modify the encrypted password * of an already existing user in /etc/passwd and /etc/shadow. * * This call returns true on success and false, if it fails. * * @example Write (.target.passwd.root, crypt (a_passwd)) */ if (path->length() != 2) { ycp2error ("Bad path argument in call to Write (.passwd.name)"); return YCPBoolean (false); } if (value.isNull() || !value->isString()) { ycp2error ("Bad password argument in call to Write (.passwd)"); return YCPBoolean (false); } string passwd = value->asString()->value(); string bashcommand = string ("/bin/echo '") + path->component_str (1).c_str () + ":" + passwd + "' |/usr/sbin/chpasswd -e >/dev/null 2>&1"; // Don't write the password into the log - even though it's crypted // y2debug("Executing: '%s'", bashcommand.c_str()); int exitcode = system(bashcommand.c_str()); return YCPBoolean (WIFEXITED (exitcode) && WEXITSTATUS (exitcode) == 0); } else if (cmd == "string") { /** * @builtin Write (.target.string, string filename, string value) -> boolean * Writes the string <tt>value</tt> into a file. If the file already * exists, the existing file is overwritten. The return value is * true, if the file has been written successfully. */ if (value.isNull() || !value->isString()) { ycp2error ("Bad filename arg for Write (.string ...)"); return YCPBoolean (false); } if (arg.isNull() || !arg->isString()) { ycp2error ("Bad string value for Write (.string ...)"); return YCPBoolean (false); } string filename = value->asString()->value(); int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd >= 0) { string cont = arg->asString()->value(); const char *buffer = cont.c_str(); size_t length = cont.length(); size_t written = write(fd, buffer, length); close(fd); return YCPBoolean (written == length); } ycp2error ("Write (.string, \"%s\") failed: %s", filename.c_str (), strerror (errno)); return YCPBoolean(false); } else if (cmd == "byte") { /** * @builtin Write (.target.byte, string filename, byteblock) -> boolean * Write a byteblock into a file. */ if (value.isNull () || !value->isString ()) { ycp2error ("Bad filename arg for Write (.byte, ...)"); return YCPBoolean (false); } if (arg.isNull () || !arg->isByteblock ()) { ycp2error ("Bad value for Write (.byte, filename, byteblock)"); return YCPBoolean (false); } string filename = value->asString ()->value (); YCPByteblock byteblock = arg->asByteblock (); int fd = open (filename.c_str (), O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd >= 0) { size_t size = byteblock->size (); size_t write_size = write (fd, byteblock->value (), size); close (fd); return YCPBoolean (write_size == size); } ycp2error ("Write (.byte, \"%s\") failed: %s", filename.c_str (), strerror (errno)); return YCPBoolean (false); } else if (cmd == "ycp" || cmd == "yast2") { /** * @builtin Write (.target.ycp, string filename, any value) -> boolean * Opens a file for writing and prints the value <tt>value</tt> in * YCP syntax to that file. Returns true, if the file has * been written, false otherwise. The newly created file gets * the mode 0644 minus umask. Furthermore any missing directory in the * pathname <tt>filename</tt> is created automatically. */ /** * @builtin Write (.target.ycp, [ string filename, integer mode], any value) -> boolean * Opens a file for writing and prints the value <tt>value</tt> in * YCP syntax to that file. Returns true, if the file has * been written, false otherwise. The newly created file gets * the mode mode minus umask. Furthermore any missing directory in the * pathname <tt>filename</tt> is created automatically. */ // either string or list if (value.isNull() || !(value->isString() || value->isList())) { ycp2error ("Bad arguments to Write (%s, string filename ...)", cmd.c_str ()); return YCPBoolean (false); } string filename; mode_t filemode = 0644; if (value->isString()) { filename = value->asString()->value(); } else { // value is list YCPList flist = value->asList(); if ((flist->size() != 2) || (!flist->value(0)->isString()) || (!flist->value(1)->isInteger())) { ycp2error ("Bad [filename, mode] list in call to Write (%s, [ string filename, integer mode ], ...)", cmd.c_str ()); return YCPBoolean (false); } filename = flist->value(0)->asString()->value(); filemode = (int)(flist->value(1)->asInteger()->value()); } if (filename.length() == 0) { ycp2error ("Invalid empty filename in Write (%s, ...)", cmd.c_str ()); return YCPBoolean (false); } // Create directory, if missing size_t pos = 0; while (pos = filename.find('/', pos + 1), pos != string::npos) mkdir (filename.substr(0, pos).c_str(), 0775); // Remove file, if existing remove (filename.c_str()); int fd = open (filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC , filemode); bool success = false; if (fd < 0) { ycp2error ("Error opening '%s': %s", filename.c_str (), strerror (errno)); return YCPBoolean (false); } // string contents = (arg.isNull() ? "" : arg->toString()); string contents = (arg.isNull() ? "" : dump_value(0, arg)); ssize_t size = contents.length(); if (size == write(fd, contents.c_str(), size) && write(fd, "\n", 1) == 1) success = true; close(fd); return YCPBoolean(success); } ycp2error ("Undefined subpath for Write (%s)", path->toString ().c_str ()); return YCPBoolean (false); }
SystemAgent::Write (const YCPPath& path, const YCPValue& value, const YCPValue& arg) { y2debug ("Write (%s)", path->toString().c_str()); if (path->isRoot()) { ycp2error ("Write () called without sub-path"); return YCPBoolean (false); } const string cmd = path->component_str (0); if (cmd == "passwd") { if (path->length() != 2) { ycp2error ("Bad path argument in call to Write (.passwd.name)"); return YCPBoolean (false); } if (value.isNull() || !value->isString()) { ycp2error ("Bad password argument in call to Write (.passwd)"); return YCPBoolean (false); } string passwd = value->asString()->value(); string bashcommand = string ("/bin/echo '") + path->component_str (1).c_str () + ":" + passwd + "' |/usr/sbin/chpasswd -e >/dev/null 2>&1"; int exitcode = system(bashcommand.c_str()); return YCPBoolean (WIFEXITED (exitcode) && WEXITSTATUS (exitcode) == 0); } else if (cmd == "string") { if (value.isNull() || !value->isString()) { ycp2error ("Bad filename arg for Write (.string ...)"); return YCPBoolean (false); } if (arg.isNull() || !arg->isString()) { ycp2error ("Bad string value for Write (.string ...)"); return YCPBoolean (false); } string filename = value->asString()->value(); int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd >= 0) { string cont = arg->asString()->value(); const char *buffer = cont.c_str(); size_t length = cont.length(); size_t written = write(fd, buffer, length); close(fd); return YCPBoolean (written == length); } ycp2error ("Write (.string, \"%s\") failed: %s", filename.c_str (), strerror (errno)); return YCPBoolean(false); } else if (cmd == "byte") { if (value.isNull () || !value->isString ()) { ycp2error ("Bad filename arg for Write (.byte, ...)"); return YCPBoolean (false); } if (arg.isNull () || !arg->isByteblock ()) { ycp2error ("Bad value for Write (.byte, filename, byteblock)"); return YCPBoolean (false); } string filename = value->asString ()->value (); YCPByteblock byteblock = arg->asByteblock (); int fd = open (filename.c_str (), O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd >= 0) { size_t size = byteblock->size (); size_t write_size = write (fd, byteblock->value (), size); close (fd); return YCPBoolean (write_size == size); } ycp2error ("Write (.byte, \"%s\") failed: %s", filename.c_str (), strerror (errno)); return YCPBoolean (false); } else if (cmd == "ycp" || cmd == "yast2") { if (value.isNull() || !(value->isString() || value->isList())) { ycp2error ("Bad arguments to Write (%s, string filename ...)", cmd.c_str ()); return YCPBoolean (false); } string filename; mode_t filemode = 0644; if (value->isString()) { filename = value->asString()->value(); } else { YCPList flist = value->asList(); if ((flist->size() != 2) || (!flist->value(0)->isString()) || (!flist->value(1)->isInteger())) { ycp2error ("Bad [filename, mode] list in call to Write (%s, [ string filename, integer mode ], ...)", cmd.c_str ()); return YCPBoolean (false); } filename = flist->value(0)->asString()->value(); filemode = (int)(flist->value(1)->asInteger()->value()); } if (filename.length() == 0) { ycp2error ("Invalid empty filename in Write (%s, ...)", cmd.c_str ()); return YCPBoolean (false); } size_t pos = 0; while (pos = filename.find('/', pos + 1), pos != string::npos) mkdir (filename.substr(0, pos).c_str(), 0775); remove (filename.c_str()); int fd = open (filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC , filemode); bool success = false; if (fd < 0) { ycp2error ("Error opening '%s': %s", filename.c_str (), strerror (errno)); return YCPBoolean (false); } string contents = (arg.isNull() ? "" : dump_value(0, arg)); ssize_t size = contents.length(); if (size == write(fd, contents.c_str(), size) && write(fd, "\n", 1) == 1) success = true; close(fd); return YCPBoolean(success); } ycp2error ("Undefined subpath for Write (%s)", path->toString ().c_str ()); return YCPBoolean (false); }
511
0
IN_PROC_BROWSER_TEST_F ( FramebustBlockBrowserTest , ModelAllowsRedirection ) { const GURL blocked_urls [ ] = { GURL ( chrome : : kChromeUIHistoryURL ) , GURL ( chrome : : kChromeUISettingsURL ) , GURL ( chrome : : kChromeUIVersionURL ) , } ; auto * helper = GetFramebustTabHelper ( ) ; for ( const GURL & url : blocked_urls ) { helper -> AddBlockedUrl ( url , base : : BindOnce ( & FramebustBlockBrowserTest : : OnClick , base : : Unretained ( this ) ) ) ; } EXPECT_TRUE ( helper -> HasBlockedUrls ( ) ) ; ContentSettingFramebustBlockBubbleModel framebust_block_bubble_model ( browser ( ) -> content_setting_bubble_model_delegate ( ) , GetWebContents ( ) , browser ( ) -> profile ( ) ) ; EXPECT_FALSE ( clicked_index_ . has_value ( ) ) ; EXPECT_FALSE ( clicked_url_ . has_value ( ) ) ; content : : TestNavigationObserver observer ( GetWebContents ( ) ) ; framebust_block_bubble_model . OnListItemClicked ( 1 , ui : : EF_LEFT_MOUSE_BUTTON ) ; observer . Wait ( ) ; EXPECT_TRUE ( clicked_index_ . has_value ( ) ) ; EXPECT_TRUE ( clicked_url_ . has_value ( ) ) ; EXPECT_EQ ( 1u , clicked_index_ . value ( ) ) ; EXPECT_EQ ( GURL ( chrome : : kChromeUISettingsURL ) , clicked_url_ . value ( ) ) ; EXPECT_FALSE ( helper -> HasBlockedUrls ( ) ) ; EXPECT_EQ ( blocked_urls [ 1 ] , GetWebContents ( ) -> GetLastCommittedURL ( ) ) ; }
IN_PROC_BROWSER_TEST_F ( FramebustBlockBrowserTest , ModelAllowsRedirection ) { const GURL blocked_urls [ ] = { GURL ( chrome : : kChromeUIHistoryURL ) , GURL ( chrome : : kChromeUISettingsURL ) , GURL ( chrome : : kChromeUIVersionURL ) , } ; auto * helper = GetFramebustTabHelper ( ) ; for ( const GURL & url : blocked_urls ) { helper -> AddBlockedUrl ( url , base : : BindOnce ( & FramebustBlockBrowserTest : : OnClick , base : : Unretained ( this ) ) ) ; } EXPECT_TRUE ( helper -> HasBlockedUrls ( ) ) ; ContentSettingFramebustBlockBubbleModel framebust_block_bubble_model ( browser ( ) -> content_setting_bubble_model_delegate ( ) , GetWebContents ( ) , browser ( ) -> profile ( ) ) ; EXPECT_FALSE ( clicked_index_ . has_value ( ) ) ; EXPECT_FALSE ( clicked_url_ . has_value ( ) ) ; content : : TestNavigationObserver observer ( GetWebContents ( ) ) ; framebust_block_bubble_model . OnListItemClicked ( 1 , ui : : EF_LEFT_MOUSE_BUTTON ) ; observer . Wait ( ) ; EXPECT_TRUE ( clicked_index_ . has_value ( ) ) ; EXPECT_TRUE ( clicked_url_ . has_value ( ) ) ; EXPECT_EQ ( 1u , clicked_index_ . value ( ) ) ; EXPECT_EQ ( GURL ( chrome : : kChromeUISettingsURL ) , clicked_url_ . value ( ) ) ; EXPECT_FALSE ( helper -> HasBlockedUrls ( ) ) ; EXPECT_EQ ( blocked_urls [ 1 ] , GetWebContents ( ) -> GetLastCommittedURL ( ) ) ; }
512
0
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { CSmartPtr<CWebSession> spSession = WebSock.GetSession(); if (sPageName == "settings") { // Admin Check if (!spSession->IsAdmin()) { return false; } return SettingsPage(WebSock, Tmpl); } else if (sPageName == "adduser") { // Admin Check if (!spSession->IsAdmin()) { return false; } return UserPage(WebSock, Tmpl); } else if (sPageName == "addnetwork") { CUser* pUser = SafeGetUserFromParam(WebSock); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } if (pUser) { return NetworkPage(WebSock, Tmpl, pUser); } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "editnetwork") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || !pNetwork || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (!pNetwork) { WebSock.PrintErrorPage("No such username or network"); return true; } return NetworkPage(WebSock, Tmpl, pNetwork->GetUser(), pNetwork); } else if (sPageName == "delnetwork") { CString sUser = WebSock.GetParam("user"); if (sUser.empty() && !WebSock.IsPost()) { sUser = WebSock.GetParam("user", false); } CUser* pUser = CZNC::Get().FindUser(sUser); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } return DelNetwork(WebSock, pUser, Tmpl); } else if (sPageName == "editchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || !pNetwork || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (!pNetwork) { WebSock.PrintErrorPage("No such username or network"); return true; } CString sChan = WebSock.GetParam("name"); if(sChan.empty() && !WebSock.IsPost()) { sChan = WebSock.GetParam("name", false); } CChan* pChan = pNetwork->FindChan(sChan); if (!pChan) { WebSock.PrintErrorPage("No such channel"); return true; } return ChanPage(WebSock, Tmpl, pNetwork, pChan); } else if (sPageName == "addchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || !pNetwork || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (pNetwork) { return ChanPage(WebSock, Tmpl, pNetwork); } WebSock.PrintErrorPage("No such username or network"); return true; } else if (sPageName == "delchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || !pNetwork || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (pNetwork) { return DelChan(WebSock, pNetwork); } WebSock.PrintErrorPage("No such username or network"); return true; } else if (sPageName == "deluser") { if (!spSession->IsAdmin()) { return false; } if (!WebSock.IsPost()) { // Show the "Are you sure?" page: CString sUser = WebSock.GetParam("user", false); CUser* pUser = CZNC::Get().FindUser(sUser); if (!pUser) { WebSock.PrintErrorPage("No such username"); return true; } Tmpl.SetFile("del_user.tmpl"); Tmpl["Username"] = sUser; return true; } // The "Are you sure?" page has been submitted with "Yes", // so we actually delete the user now: CString sUser = WebSock.GetParam("user"); CUser* pUser = CZNC::Get().FindUser(sUser); if (pUser && pUser == spSession->GetUser()) { WebSock.PrintErrorPage("Please don't delete yourself, suicide is not the answer!"); return true; } else if (CZNC::Get().DeleteUser(sUser)) { WebSock.Redirect("listusers"); return true; } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "edituser") { CString sUserName = SafeGetUserNameParam(WebSock); CUser* pUser = CZNC::Get().FindUser(sUserName); if(!pUser) { if(sUserName.empty()) { pUser = spSession->GetUser(); } // else: the "no such user" message will be printed. } // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } if (pUser) { return UserPage(WebSock, Tmpl, pUser); } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "listusers" && spSession->IsAdmin()) { return ListUsersPage(WebSock, Tmpl); } else if (sPageName == "traffic" && spSession->IsAdmin()) { return TrafficPage(WebSock, Tmpl); } else if (sPageName == "index") { return true; } else if (sPageName == "add_listener") { // Admin Check if (!spSession->IsAdmin()) { return false; } return AddListener(WebSock, Tmpl); } else if (sPageName == "del_listener") { // Admin Check if (!spSession->IsAdmin()) { return false; } return DelListener(WebSock, Tmpl); } return false; }
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { CSmartPtr<CWebSession> spSession = WebSock.GetSession(); if (sPageName == "settings") { if (!spSession->IsAdmin()) { return false; } return SettingsPage(WebSock, Tmpl); } else if (sPageName == "adduser") { if (!spSession->IsAdmin()) { return false; } return UserPage(WebSock, Tmpl); } else if (sPageName == "addnetwork") { CUser* pUser = SafeGetUserFromParam(WebSock); if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } if (pUser) { return NetworkPage(WebSock, Tmpl, pUser); } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "editnetwork") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); if (!spSession->IsAdmin() && (!spSession->GetUser() || !pNetwork || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (!pNetwork) { WebSock.PrintErrorPage("No such username or network"); return true; } return NetworkPage(WebSock, Tmpl, pNetwork->GetUser(), pNetwork); } else if (sPageName == "delnetwork") { CString sUser = WebSock.GetParam("user"); if (sUser.empty() && !WebSock.IsPost()) { sUser = WebSock.GetParam("user", false); } CUser* pUser = CZNC::Get().FindUser(sUser); if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } return DelNetwork(WebSock, pUser, Tmpl); } else if (sPageName == "editchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); if (!spSession->IsAdmin() && (!spSession->GetUser() || !pNetwork || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (!pNetwork) { WebSock.PrintErrorPage("No such username or network"); return true; } CString sChan = WebSock.GetParam("name"); if(sChan.empty() && !WebSock.IsPost()) { sChan = WebSock.GetParam("name", false); } CChan* pChan = pNetwork->FindChan(sChan); if (!pChan) { WebSock.PrintErrorPage("No such channel"); return true; } return ChanPage(WebSock, Tmpl, pNetwork, pChan); } else if (sPageName == "addchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); if (!spSession->IsAdmin() && (!spSession->GetUser() || !pNetwork || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (pNetwork) { return ChanPage(WebSock, Tmpl, pNetwork); } WebSock.PrintErrorPage("No such username or network"); return true; } else if (sPageName == "delchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); if (!spSession->IsAdmin() && (!spSession->GetUser() || !pNetwork || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (pNetwork) { return DelChan(WebSock, pNetwork); } WebSock.PrintErrorPage("No such username or network"); return true; } else if (sPageName == "deluser") { if (!spSession->IsAdmin()) { return false; } if (!WebSock.IsPost()) { CString sUser = WebSock.GetParam("user", false); CUser* pUser = CZNC::Get().FindUser(sUser); if (!pUser) { WebSock.PrintErrorPage("No such username"); return true; } Tmpl.SetFile("del_user.tmpl"); Tmpl["Username"] = sUser; return true; } CString sUser = WebSock.GetParam("user"); CUser* pUser = CZNC::Get().FindUser(sUser); if (pUser && pUser == spSession->GetUser()) { WebSock.PrintErrorPage("Please don't delete yourself, suicide is not the answer!"); return true; } else if (CZNC::Get().DeleteUser(sUser)) { WebSock.Redirect("listusers"); return true; } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "edituser") { CString sUserName = SafeGetUserNameParam(WebSock); CUser* pUser = CZNC::Get().FindUser(sUserName); if(!pUser) { if(sUserName.empty()) { pUser = spSession->GetUser(); } } if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } if (pUser) { return UserPage(WebSock, Tmpl, pUser); } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "listusers" && spSession->IsAdmin()) { return ListUsersPage(WebSock, Tmpl); } else if (sPageName == "traffic" && spSession->IsAdmin()) { return TrafficPage(WebSock, Tmpl); } else if (sPageName == "index") { return true; } else if (sPageName == "add_listener") { if (!spSession->IsAdmin()) { return false; } return AddListener(WebSock, Tmpl); } else if (sPageName == "del_listener") { if (!spSession->IsAdmin()) { return false; } return DelListener(WebSock, Tmpl); } return false; }
513
1
int run_diff_files(struct rev_info *revs, unsigned int option) { int entries, i; int diff_unmerged_stage = revs->max_count; int silent_on_removed = option & DIFF_SILENT_ON_REMOVED; unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED) ? CE_MATCH_RACY_IS_DIRTY : 0); char symcache[PATH_MAX]; if (diff_unmerged_stage < 0) diff_unmerged_stage = 2; entries = active_nr; symcache[0] = '\0'; for (i = 0; i < entries; i++) { struct stat st; unsigned int oldmode, newmode; struct cache_entry *ce = active_cache[i]; int changed; if (DIFF_OPT_TST(&revs->diffopt, QUIET) && DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES)) break; if (!ce_path_match(ce, revs->prune_data)) continue; if (ce_stage(ce)) { struct combine_diff_path *dpath; int num_compare_stages = 0; size_t path_len; path_len = ce_namelen(ce); dpath = xmalloc(combine_diff_path_size(5, path_len)); dpath->path = (char *) &(dpath->parent[5]); dpath->next = NULL; dpath->len = path_len; memcpy(dpath->path, ce->name, path_len); dpath->path[path_len] = '\0'; hashclr(dpath->sha1); memset(&(dpath->parent[0]), 0, sizeof(struct combine_diff_parent)*5); changed = check_removed(ce, &st); if (!changed) dpath->mode = ce_mode_from_stat(ce, st.st_mode); else { if (changed < 0) { perror(ce->name); continue; } if (silent_on_removed) continue; } while (i < entries) { struct cache_entry *nce = active_cache[i]; int stage; if (strcmp(ce->name, nce->name)) break; /* Stage #2 (ours) is the first parent, * stage #3 (theirs) is the second. */ stage = ce_stage(nce); if (2 <= stage) { int mode = nce->ce_mode; num_compare_stages++; hashcpy(dpath->parent[stage-2].sha1, nce->sha1); dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode); dpath->parent[stage-2].status = DIFF_STATUS_MODIFIED; } /* diff against the proper unmerged stage */ if (stage == diff_unmerged_stage) ce = nce; i++; } /* * Compensate for loop update */ i--; if (revs->combine_merges && num_compare_stages == 2) { show_combined_diff(dpath, 2, revs->dense_combined_merges, revs); free(dpath); continue; } free(dpath); dpath = NULL; /* * Show the diff for the 'ce' if we found the one * from the desired stage. */ diff_unmerge(&revs->diffopt, ce->name, 0, null_sha1); if (ce_stage(ce) != diff_unmerged_stage) continue; } if (ce_uptodate(ce)) continue; changed = check_removed(ce, &st); if (changed) { if (changed < 0) { perror(ce->name); continue; } if (silent_on_removed) continue; diff_addremove(&revs->diffopt, '-', ce->ce_mode, ce->sha1, ce->name, NULL); continue; } changed = ce_match_stat(ce, &st, ce_option); if (!changed) { ce_mark_uptodate(ce); if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER)) continue; } oldmode = ce->ce_mode; newmode = ce_mode_from_stat(ce, st.st_mode); diff_change(&revs->diffopt, oldmode, newmode, ce->sha1, (changed ? null_sha1 : ce->sha1), ce->name, NULL); } diffcore_std(&revs->diffopt); diff_flush(&revs->diffopt); return 0; }
int run_diff_files(struct rev_info *revs, unsigned int option) { int entries, i; int diff_unmerged_stage = revs->max_count; int silent_on_removed = option & DIFF_SILENT_ON_REMOVED; unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED) ? CE_MATCH_RACY_IS_DIRTY : 0); char symcache[PATH_MAX]; if (diff_unmerged_stage < 0) diff_unmerged_stage = 2; entries = active_nr; symcache[0] = '\0'; for (i = 0; i < entries; i++) { struct stat st; unsigned int oldmode, newmode; struct cache_entry *ce = active_cache[i]; int changed; if (DIFF_OPT_TST(&revs->diffopt, QUIET) && DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES)) break; if (!ce_path_match(ce, revs->prune_data)) continue; if (ce_stage(ce)) { struct combine_diff_path *dpath; int num_compare_stages = 0; size_t path_len; path_len = ce_namelen(ce); dpath = xmalloc(combine_diff_path_size(5, path_len)); dpath->path = (char *) &(dpath->parent[5]); dpath->next = NULL; dpath->len = path_len; memcpy(dpath->path, ce->name, path_len); dpath->path[path_len] = '\0'; hashclr(dpath->sha1); memset(&(dpath->parent[0]), 0, sizeof(struct combine_diff_parent)*5); changed = check_removed(ce, &st); if (!changed) dpath->mode = ce_mode_from_stat(ce, st.st_mode); else { if (changed < 0) { perror(ce->name); continue; } if (silent_on_removed) continue; } while (i < entries) { struct cache_entry *nce = active_cache[i]; int stage; if (strcmp(ce->name, nce->name)) break; stage = ce_stage(nce); if (2 <= stage) { int mode = nce->ce_mode; num_compare_stages++; hashcpy(dpath->parent[stage-2].sha1, nce->sha1); dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode); dpath->parent[stage-2].status = DIFF_STATUS_MODIFIED; } if (stage == diff_unmerged_stage) ce = nce; i++; } i--; if (revs->combine_merges && num_compare_stages == 2) { show_combined_diff(dpath, 2, revs->dense_combined_merges, revs); free(dpath); continue; } free(dpath); dpath = NULL; diff_unmerge(&revs->diffopt, ce->name, 0, null_sha1); if (ce_stage(ce) != diff_unmerged_stage) continue; } if (ce_uptodate(ce)) continue; changed = check_removed(ce, &st); if (changed) { if (changed < 0) { perror(ce->name); continue; } if (silent_on_removed) continue; diff_addremove(&revs->diffopt, '-', ce->ce_mode, ce->sha1, ce->name, NULL); continue; } changed = ce_match_stat(ce, &st, ce_option); if (!changed) { ce_mark_uptodate(ce); if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER)) continue; } oldmode = ce->ce_mode; newmode = ce_mode_from_stat(ce, st.st_mode); diff_change(&revs->diffopt, oldmode, newmode, ce->sha1, (changed ? null_sha1 : ce->sha1), ce->name, NULL); } diffcore_std(&revs->diffopt); diff_flush(&revs->diffopt); return 0; }
514
1
static uint32_t m5206_mbar_readb(void *opaque, target_phys_addr_t offset) { m5206_mbar_state *s = (m5206_mbar_state *)opaque; offset &= 0x3ff; if (offset > 0x200) { hw_error("Bad MBAR read offset 0x%x", (int)offset); } if (m5206_mbar_width[offset >> 2] > 1) { uint16_t val; val = m5206_mbar_readw(opaque, offset & ~1); if ((offset & 1) == 0) { val >>= 8; } return val & 0xff; } return m5206_mbar_read(s, offset, 1); }
static uint32_t m5206_mbar_readb(void *opaque, target_phys_addr_t offset) { m5206_mbar_state *s = (m5206_mbar_state *)opaque; offset &= 0x3ff; if (offset > 0x200) { hw_error("Bad MBAR read offset 0x%x", (int)offset); } if (m5206_mbar_width[offset >> 2] > 1) { uint16_t val; val = m5206_mbar_readw(opaque, offset & ~1); if ((offset & 1) == 0) { val >>= 8; } return val & 0xff; } return m5206_mbar_read(s, offset, 1); }
515
1
static void prepare_attr_stack(const char *path, int dirlen) { struct attr_stack *elem, *info; int len; char pathbuf[PATH_MAX]; /* * At the bottom of the attribute stack is the built-in * set of attribute definitions. Then, contents from * .gitattribute files from directories closer to the * root to the ones in deeper directories are pushed * to the stack. Finally, at the very top of the stack * we always keep the contents of $GIT_DIR/info/attributes. * * When checking, we use entries from near the top of the * stack, preferring $GIT_DIR/info/attributes, then * .gitattributes in deeper directories to shallower ones, * and finally use the built-in set as the default. */ if (!attr_stack) bootstrap_attr_stack(); /* * Pop the "info" one that is always at the top of the stack. */ info = attr_stack; attr_stack = info->prev; /* * Pop the ones from directories that are not the prefix of * the path we are checking. */ while (attr_stack && attr_stack->origin) { int namelen = strlen(attr_stack->origin); elem = attr_stack; if (namelen <= dirlen && !strncmp(elem->origin, path, namelen)) break; debug_pop(elem); attr_stack = elem->prev; free_attr_elem(elem); } /* * Read from parent directories and push them down */ if (!is_bare_repository()) { while (1) { char *cp; len = strlen(attr_stack->origin); if (dirlen <= len) break; memcpy(pathbuf, path, dirlen); memcpy(pathbuf + dirlen, "/", 2); cp = strchr(pathbuf + len + 1, '/'); strcpy(cp + 1, GITATTRIBUTES_FILE); elem = read_attr(pathbuf, 0); *cp = '\0'; elem->origin = strdup(pathbuf); elem->prev = attr_stack; attr_stack = elem; debug_push(elem); } } /* * Finally push the "info" one at the top of the stack. */ info->prev = attr_stack; attr_stack = info; }
static void prepare_attr_stack(const char *path, int dirlen) { struct attr_stack *elem, *info; int len; char pathbuf[PATH_MAX]; if (!attr_stack) bootstrap_attr_stack(); info = attr_stack; attr_stack = info->prev; while (attr_stack && attr_stack->origin) { int namelen = strlen(attr_stack->origin); elem = attr_stack; if (namelen <= dirlen && !strncmp(elem->origin, path, namelen)) break; debug_pop(elem); attr_stack = elem->prev; free_attr_elem(elem); } if (!is_bare_repository()) { while (1) { char *cp; len = strlen(attr_stack->origin); if (dirlen <= len) break; memcpy(pathbuf, path, dirlen); memcpy(pathbuf + dirlen, "/", 2); cp = strchr(pathbuf + len + 1, '/'); strcpy(cp + 1, GITATTRIBUTES_FILE); elem = read_attr(pathbuf, 0); *cp = '\0'; elem->origin = strdup(pathbuf); elem->prev = attr_stack; attr_stack = elem; debug_push(elem); } } info->prev = attr_stack; attr_stack = info; }
516
0
gint proto_registrar_get_length ( const int n ) { header_field_info * hfinfo ; PROTO_REGISTRAR_GET_NTH ( n , hfinfo ) ; return ftype_length ( hfinfo -> type ) ; }
gint proto_registrar_get_length ( const int n ) { header_field_info * hfinfo ; PROTO_REGISTRAR_GET_NTH ( n , hfinfo ) ; return ftype_length ( hfinfo -> type ) ; }
517