functionSource
stringlengths
20
97.4k
CWE-119
bool
2 classes
CWE-120
bool
2 classes
CWE-469
bool
2 classes
CWE-476
bool
2 classes
CWE-other
bool
2 classes
combine
int64
0
1
immerse_clamp_detail_offset(ImmerseControls *controls, gdouble xpos, gdouble ypos) { xpos = CLAMP(xpos, 0.0, controls->xmax); ypos = CLAMP(ypos, 0.0, controls->ymax); if (xpos != controls->args->xpos || ypos != controls->args->ypos) { gchar *s; controls->args->xpos = xpos; controls->args->ypos = ypos; s = g_strdup_printf("(%.*f, %.*f) %s", controls->vf->precision + 1, xpos/controls->vf->magnitude, controls->vf->precision + 1, ypos/controls->vf->magnitude, controls->vf->units); gtk_label_set_text(GTK_LABEL(controls->pos), s); g_free(s); if (GTK_WIDGET_DRAWABLE(controls->view)) gtk_widget_queue_draw(controls->view); return TRUE; } return FALSE; }
false
false
false
false
false
0
create_particular(void) { char buf[BUFSZ], *bufp, monclass = MAXMCLASSES; int which, tries, i; struct permonst *whichpm; struct monst *mtmp; bool madeany = false; bool maketame, makepeaceful, makehostile; tries = 0; do { which = urole.malenum; /* an arbitrary index into mons[] */ maketame = makepeaceful = makehostile = false; getlin("Create what kind of monster? [type the name or symbol]", buf); bufp = mungspaces(buf); if (*bufp == '\033') return false; /* allow the initial disposition to be specified */ if (!strncmpi(bufp, "tame ", 5)) { bufp += 5; maketame = true; } else if (!strncmpi(bufp, "peaceful ", 9)) { bufp += 9; makepeaceful = true; } else if (!strncmpi(bufp, "hostile ", 8)) { bufp += 8; makehostile = true; } /* decide whether a valid monster was chosen */ if (strlen(bufp) == 1) { monclass = def_char_to_monclass(*bufp); if (monclass != MAXMCLASSES) break; /* got one */ } else { which = name_to_mon(bufp); if (which >= LOW_PM) break; /* got one */ } /* no good; try again... */ pline("I've never heard of such monsters."); } while (++tries < 5); if (tries == 5) { pline(thats_enough_tries); } else { cant_create(&which, false); whichpm = &mons[which]; for (i = 0; i <= multi; i++) { if (monclass != MAXMCLASSES) { whichpm = mkclass(monclass, 0); } if (maketame) { mtmp = makemon(whichpm, u.ux, u.uy, MM_EDOG); if (mtmp) { initedog(mtmp); set_malign(mtmp); } } else { mtmp = makemon(whichpm, u.ux, u.uy, NO_MM_FLAGS); if ((makepeaceful || makehostile) && mtmp) { mtmp->mtame = 0; /* sanity precaution */ mtmp->mpeaceful = makepeaceful ? 1 : 0; set_malign(mtmp); } } if (mtmp) madeany = true; } } return madeany; }
false
false
false
false
false
0
matrix_reorg (void) { struct cgraph_node *node; if (profile_info) check_transpose_p = true; else check_transpose_p = false; /* If there are hand written vectors, we skip this optimization. */ for (node = cgraph_nodes; node; node = node->next) if (!may_flatten_matrices (node)) return 0; matrices_to_reorg = htab_create (37, mtt_info_hash, mtt_info_eq, mat_free); /* Find and record all potential matrices in the program. */ find_matrices_decl (); /* Analyze the accesses of the matrices (escaping analysis). */ for (node = cgraph_nodes; node; node = node->next) if (node->analyzed) { tree temp_fn; temp_fn = current_function_decl; current_function_decl = node->decl; push_cfun (DECL_STRUCT_FUNCTION (node->decl)); bitmap_obstack_initialize (NULL); gimple_register_cfg_hooks (); if (!gimple_in_ssa_p (cfun)) { free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); pop_cfun (); current_function_decl = temp_fn; bitmap_obstack_release (NULL); return 0; } #ifdef ENABLE_CHECKING verify_flow_info (); #endif if (!matrices_to_reorg) { free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); pop_cfun (); current_function_decl = temp_fn; bitmap_obstack_release (NULL); return 0; } /* Create htap for phi nodes. */ htab_mat_acc_phi_nodes = htab_create (37, mat_acc_phi_hash, mat_acc_phi_eq, free); if (!check_transpose_p) find_sites_in_func (false); else { find_sites_in_func (true); loop_optimizer_init (LOOPS_NORMAL); if (current_loops) scev_initialize (); htab_traverse (matrices_to_reorg, analyze_transpose, NULL); if (current_loops) { scev_finalize (); loop_optimizer_finalize (); current_loops = NULL; } } /* If the current function is the allocation function for any of the matrices we check its allocation and the escaping level. */ htab_traverse (matrices_to_reorg, check_allocation_function, NULL); free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); pop_cfun (); current_function_decl = temp_fn; bitmap_obstack_release (NULL); } htab_traverse (matrices_to_reorg, transform_allocation_sites, NULL); /* Now transform the accesses. */ for (node = cgraph_nodes; node; node = node->next) if (node->analyzed) { /* Remember that allocation sites have been handled. */ tree temp_fn; temp_fn = current_function_decl; current_function_decl = node->decl; push_cfun (DECL_STRUCT_FUNCTION (node->decl)); bitmap_obstack_initialize (NULL); gimple_register_cfg_hooks (); record_all_accesses_in_func (); htab_traverse (matrices_to_reorg, transform_access_sites, NULL); cgraph_rebuild_references (); free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); pop_cfun (); current_function_decl = temp_fn; bitmap_obstack_release (NULL); } htab_traverse (matrices_to_reorg, dump_matrix_reorg_analysis, NULL); current_function_decl = NULL; set_cfun (NULL); matrices_to_reorg = NULL; return 0; }
false
false
false
false
false
0
channel_direct_tcpip(LIBSSH2_SESSION * session, const char *host, int port, const char *shost, int sport) { LIBSSH2_CHANNEL *channel; unsigned char *s; if (session->direct_state == libssh2_NB_state_idle) { session->direct_host_len = strlen(host); session->direct_shost_len = strlen(shost); /* host_len(4) + port(4) + shost_len(4) + sport(4) */ session->direct_message_len = session->direct_host_len + session->direct_shost_len + 16; _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Requesting direct-tcpip session to from %s:%d to %s:%d", shost, sport, host, port); s = session->direct_message = LIBSSH2_ALLOC(session, session->direct_message_len); if (!session->direct_message) { _libssh2_error(session, LIBSSH2_ERROR_ALLOC, "Unable to allocate memory for direct-tcpip connection"); return NULL; } _libssh2_store_str(&s, host, session->direct_host_len); _libssh2_store_u32(&s, port); _libssh2_store_str(&s, shost, session->direct_shost_len); _libssh2_store_u32(&s, sport); } channel = _libssh2_channel_open(session, "direct-tcpip", sizeof("direct-tcpip") - 1, LIBSSH2_CHANNEL_WINDOW_DEFAULT, LIBSSH2_CHANNEL_PACKET_DEFAULT, session->direct_message, session->direct_message_len); if (!channel && libssh2_session_last_errno(session) == LIBSSH2_ERROR_EAGAIN) { /* The error code is still set to LIBSSH2_ERROR_EAGAIN, set our state to created to avoid re-creating the package on next invoke */ session->direct_state = libssh2_NB_state_created; return NULL; } /* by default we set (keep?) idle state... */ session->direct_state = libssh2_NB_state_idle; LIBSSH2_FREE(session, session->direct_message); session->direct_message = NULL; return channel; }
false
false
false
false
false
0
SparseMatrix_export_binary(char *name, SparseMatrix A, int *flag){ FILE *f; *flag = 0; f = fopen(name, "wb"); if (!f) { *flag = 1; return; } fwrite(&(A->m), sizeof(int), 1, f); fwrite(&(A->n), sizeof(int), 1, f); fwrite(&(A->nz), sizeof(int), 1, f); fwrite(&(A->nzmax), sizeof(int), 1, f); fwrite(&(A->type), sizeof(int), 1, f); fwrite(&(A->format), sizeof(int), 1, f); fwrite(&(A->property), sizeof(int), 1, f); fwrite(&(A->size), sizeof(size_t), 1, f); if (A->format == FORMAT_COORD){ fwrite(A->ia, sizeof(int), A->nz, f); } else { fwrite(A->ia, sizeof(int), A->m + 1, f); } fwrite(A->ja, sizeof(int), A->nz, f); if (A->size > 0) fwrite(A->a, A->size, A->nz, f); fclose(f); }
false
false
false
false
true
1
sci_controller_start(struct isci_host *ihost, u32 timeout) { enum sci_status result; u16 index; if (ihost->sm.current_state_id != SCIC_INITIALIZED) { dev_warn(&ihost->pdev->dev, "%s invalid state: %d\n", __func__, ihost->sm.current_state_id); return SCI_FAILURE_INVALID_STATE; } /* Build the TCi free pool */ BUILD_BUG_ON(SCI_MAX_IO_REQUESTS > 1 << sizeof(ihost->tci_pool[0]) * 8); ihost->tci_head = 0; ihost->tci_tail = 0; for (index = 0; index < ihost->task_context_entries; index++) isci_tci_free(ihost, index); /* Build the RNi free pool */ sci_remote_node_table_initialize(&ihost->available_remote_nodes, ihost->remote_node_entries); /* * Before anything else lets make sure we will not be * interrupted by the hardware. */ sci_controller_disable_interrupts(ihost); /* Enable the port task scheduler */ sci_controller_enable_port_task_scheduler(ihost); /* Assign all the task entries to ihost physical function */ sci_controller_assign_task_entries(ihost); /* Now initialize the completion queue */ sci_controller_initialize_completion_queue(ihost); /* Initialize the unsolicited frame queue for use */ sci_controller_initialize_unsolicited_frame_queue(ihost); /* Start all of the ports on this controller */ for (index = 0; index < ihost->logical_port_entries; index++) { struct isci_port *iport = &ihost->ports[index]; result = sci_port_start(iport); if (result) return result; } sci_controller_start_next_phy(ihost); sci_mod_timer(&ihost->timer, timeout); sci_change_state(&ihost->sm, SCIC_STARTING); return SCI_SUCCESS; }
false
false
false
false
false
0
print_node(heap_node *node){ printf("\n[%d, %d] (lcp = %d) [%d] mem: ", node->key, node->ESA[node->u_idx].sa, node->ESA[node->u_idx].lcp, node->ESA[node->u_idx].bwt); int8 *pt = node->c_buffer; size_t i = 0; for( ; i < 2*C_BUFFER_SIZE+2; i++){ if(i < C_BUFFER_SIZE){ printf("|%d| ", *(pt++)); } if(i == C_BUFFER_SIZE){ printf("-%d- ", *(pt++)); pt = node->c_overflow; } if(i > C_BUFFER_SIZE){ printf(" %d ", *(pt++)); } } printf("\n"); return 0; }
false
false
false
false
false
0
lm78_update_device(struct device *dev) { struct lm78_data *data = dev_get_drvdata(dev); int i; mutex_lock(&data->update_lock); if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || !data->valid) { dev_dbg(dev, "Starting lm78 update\n"); for (i = 0; i <= 6; i++) { data->in[i] = lm78_read_value(data, LM78_REG_IN(i)); data->in_min[i] = lm78_read_value(data, LM78_REG_IN_MIN(i)); data->in_max[i] = lm78_read_value(data, LM78_REG_IN_MAX(i)); } for (i = 0; i < 3; i++) { data->fan[i] = lm78_read_value(data, LM78_REG_FAN(i)); data->fan_min[i] = lm78_read_value(data, LM78_REG_FAN_MIN(i)); } data->temp = lm78_read_value(data, LM78_REG_TEMP); data->temp_over = lm78_read_value(data, LM78_REG_TEMP_OVER); data->temp_hyst = lm78_read_value(data, LM78_REG_TEMP_HYST); i = lm78_read_value(data, LM78_REG_VID_FANDIV); data->vid = i & 0x0f; if (data->type == lm79) data->vid |= (lm78_read_value(data, LM78_REG_CHIPID) & 0x01) << 4; else data->vid |= 0x10; data->fan_div[0] = (i >> 4) & 0x03; data->fan_div[1] = i >> 6; data->alarms = lm78_read_value(data, LM78_REG_ALARM1) + (lm78_read_value(data, LM78_REG_ALARM2) << 8); data->last_updated = jiffies; data->valid = 1; data->fan_div[2] = 1; } mutex_unlock(&data->update_lock); return data; }
false
false
false
false
false
0
AllocateExternalArray(int length, ExternalArrayType array_type, void* external_pointer, PretenureFlag pretenure) { AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; Object* result = AllocateRaw(ExternalArray::kAlignedSize, space, OLD_DATA_SPACE); if (result->IsFailure()) return result; reinterpret_cast<ExternalArray*>(result)->set_map( MapForExternalArrayType(array_type)); reinterpret_cast<ExternalArray*>(result)->set_length(length); reinterpret_cast<ExternalArray*>(result)->set_external_pointer( external_pointer); return result; }
false
false
false
false
false
0
draw_decal_label(MeminfoMeter *mm, gint draw_to_screen) { GkrellmDecal *d; GkrellmTextstyle ts_save; gchar buf[128]; gint x_off, w; d = mm->decal_label; if (! mm->label_is_data) { gkrellm_decal_text_set_offset(d, mm->x_label, 0); gkrellm_draw_decal_text(mm->panel, d, mm->label, 0); } else { ts_save = d->text_style; d->text_style = *gkrellm_meter_alt_textstyle(mm->style_id); format_meminfo_data(mm, mm->data_format_shadow, buf, sizeof(buf)); gkrellm_decal_scroll_text_set_markup(mm->panel, d, buf); gkrellm_decal_scroll_text_get_size(d, &w, NULL); if (w > d->w) x_off = d->w / 3 - x_scroll; else x_off = 0; gkrellm_decal_text_set_offset(d, x_off, 0); d->text_style = ts_save; } if (draw_to_screen) gkrellm_draw_panel_layers(mm->panel); return w; }
false
false
false
false
false
0
start_if_ready (GoaTpAccountLinker *self) { GoaTpAccountLinkerPrivate *priv = self->priv; GList *goa_accounts = NULL; GList *tp_accounts = NULL; GList *l = NULL; GHashTableIter iter; gpointer key, value; if (priv->goa_client == NULL || priv->account_manager == NULL || !tp_proxy_is_prepared (priv->account_manager, TP_ACCOUNT_MANAGER_FEATURE_CORE)) { /* Not everything is ready yet */ return; } goa_debug ("Both GOA and Tp are ready, starting tracking of accounts"); /* GOA */ goa_accounts = goa_client_get_accounts (priv->goa_client); for (l = goa_accounts; l != NULL; l = l->next) goa_account_added_cb (priv->goa_client, l->data, self); g_list_free_full (goa_accounts, g_object_unref); g_signal_connect_object (priv->goa_client, "account-added", G_CALLBACK (goa_account_added_cb), self, 0); g_signal_connect_object (priv->goa_client, "account-removed", G_CALLBACK (goa_account_removed_cb), self, 0); /* Telepathy */ tp_accounts = tp_account_manager_dup_valid_accounts (priv->account_manager); for (l = tp_accounts; l != NULL; l = l->next) tp_account_added (self, l->data); g_list_free_full (tp_accounts, g_object_unref); g_signal_connect_object (priv->account_manager, "account-validity-changed", G_CALLBACK (tp_account_validity_changed_cb), self, 0); g_signal_connect_object (priv->account_manager, "account-removed", G_CALLBACK (tp_account_removed_cb), self, 0); /* Now we check if any Telepathy account was deleted while goa-daemon * was not running. */ g_hash_table_iter_init (&iter, priv->goa_accounts); while (g_hash_table_iter_next (&iter, &key, &value)) { const gchar *id = key; GoaObject *goa_object = value; if (!g_hash_table_lookup (priv->tp_accounts, id)) { goa_warning ("The Telepathy account %s was removed while the daemon " "was not running, removing the corresponding GOA account", id); goa_account_call_remove (goa_object_peek_account (goa_object), NULL, /* cancellable */ goa_account_removed_by_us_cb, NULL); /* user data */ } } }
false
false
false
false
false
0
rowCount(const QModelIndex& parent) const { if ((Section)parent.column() == Name || !parent.isValid()) { if (flat_) { return (parent.isValid() ? 0 : tree_->getChildOptionNames("",false,false).count()); } else { QString option; if (parent.isValid()) option = indexToOptionName(parent); return tree_->getChildOptionNames(option,true,true).count(); } } return 0; }
false
false
false
false
false
0
PrepareForWrite() { // We're ready if we're the only owner. if(p->second == 1) return; // Then make a clone. p_t *newtree = new p_t(p->first, 1); // Forget the old Dealloc(); // Keep the new p = newtree; }
false
false
false
false
false
0
getByKey2(const char *key, const char *subKey, UErrorCode& status) { if(U_FAILURE(status)) { return NULL; } if(fBundle) { #if defined (U_DEBUG_CALDATA) fprintf(stderr, "%p: //\n"); #endif fFillin = ures_getByKeyWithFallback(fBundle, key, fFillin, &status); fOtherFillin = ures_getByKeyWithFallback(fFillin, U_FORMAT_KEY, fOtherFillin, &status); fFillin = ures_getByKeyWithFallback(fOtherFillin, subKey, fFillin, &status); #if defined (U_DEBUG_CALDATA) fprintf(stderr, "%p: get %s/format/%s -> %s - from MAIN %s\n", this, key, subKey, u_errorName(status), ures_getLocale(fFillin, &status)); #endif } if(fFallback && (status == U_MISSING_RESOURCE_ERROR)) { status = U_ZERO_ERROR; // retry with fallback (gregorian) fFillin = ures_getByKeyWithFallback(fFallback, key, fFillin, &status); fOtherFillin = ures_getByKeyWithFallback(fFillin, U_FORMAT_KEY, fOtherFillin, &status); fFillin = ures_getByKeyWithFallback(fOtherFillin, subKey, fFillin, &status); #if defined (U_DEBUG_CALDATA) fprintf(stderr, "%p: get %s/format/%s -> %s - from FALLBACK %s\n",this, key, subKey, u_errorName(status), ures_getLocale(fFillin,&status)); #endif } //// handling of 'default' keyword on failure: Commented out for 3.0. // if((status == U_MISSING_RESOURCE_ERROR) && // uprv_strcmp(subKey,U_DEFAULT_KEY)) { // avoid recursion // #if defined (U_DEBUG_CALDATA) // fprintf(stderr, "%p: - attempting fallback -\n", this); // fflush(stderr); // #endif // UErrorCode subStatus = U_ZERO_ERROR; // int32_t len; // char kwBuf[128] = ""; // const UChar *kw; // /* fFillin = */ getByKey2(key, U_DEFAULT_KEY, subStatus); // kw = ures_getString(fFillin, &len, &subStatus); // if(len>126) { // too big // len = 0; // } // if(U_SUCCESS(subStatus) && (len>0)) { // u_UCharsToChars(kw, kwBuf, len+1); // if(*kwBuf && uprv_strcmp(kwBuf,subKey)) { // #if defined (U_DEBUG_CALDATA) // fprintf(stderr, "%p: trying %s/format/default -> \"%s\"\n",this, key, kwBuf); // #endif // // now try again with the default // status = U_ZERO_ERROR; // /* fFillin = */ getByKey2(key, kwBuf, status); // } // #if defined (U_DEBUG_CALDATA) // } else { // fprintf(stderr, "%p: could not load %s/format/default - fail out (%s)\n",this, key, kwBuf, u_errorName(status)); // #endif // } // } return fFillin; }
false
false
false
false
false
0
VisitSubtreeWrapper(Object** p, uint16_t class_id) { if (in_groups_.Contains(*p)) return; Isolate* isolate = Isolate::Current(); v8::RetainedObjectInfo* info = isolate->heap_profiler()->ExecuteWrapperClassCallback(class_id, p); if (info == NULL) return; GetListMaybeDisposeInfo(info)->Add(HeapObject::cast(*p)); }
false
false
false
false
false
0
pi_next(opj_pi_iterator_t * pi) { switch (pi->poc.prg) { case LRCP: return pi_next_lrcp(pi); case RLCP: return pi_next_rlcp(pi); case RPCL: return pi_next_rpcl(pi); case PCRL: return pi_next_pcrl(pi); case CPRL: return pi_next_cprl(pi); case PROG_UNKNOWN: return OPJ_FALSE; } return OPJ_FALSE; }
false
false
false
false
false
0
dump_timestamp(int64_t ts) { if(ts > 0) bgav_dprintf("%"PRId64" (%f)", ts, (float)ts / 90000.0); else bgav_dprintf("Unknown"); }
false
false
false
false
false
0
_ipmi_oem_quanta_get_extended_config_string (ipmi_oem_state_data_t *state_data, uint8_t configuration_id, uint8_t attribute_id, uint8_t index, char *buf, unsigned int buflen) { uint8_t bytes_rq[IPMI_OEM_MAX_BYTES]; uint8_t bytes_rs[IPMI_OEM_MAX_BYTES]; int rs_len; uint8_t reservation_id; int rv = -1; assert (state_data); assert (buf); assert (buflen); /* Quanta S99Q/Dell FS12-TY OEM * * Get Extended Configuration Request * * 0x30 - OEM network function * 0x02 - OEM cmd * 0x?? - Reservation ID * 0x?? - Configuration ID * 0x?? - Attribute ID * 0x00 - Index * 0x00 - Data Offset - LSB (unused here??) * 0x00 = Data Offset - MSB (unused here??) * 0xFF - Bytes to read (0xFF = all) * * Get Extended Configuration Response * * 0x02 - OEM cmd * 0x?? - Completion Code * 0x?? - Configuration ID * 0x?? - Attribute ID * 0x00 - Index * 0x?? - number of bytes returned * bytes ... */ if (_quanta_get_reservation (state_data, &reservation_id) < 0) goto cleanup; bytes_rq[0] = IPMI_CMD_OEM_QUANTA_GET_EXTENDED_CONFIGURATION; bytes_rq[1] = reservation_id; bytes_rq[2] = configuration_id; bytes_rq[3] = attribute_id; bytes_rq[4] = index; bytes_rq[5] = 0x00; bytes_rq[6] = 0x00; bytes_rq[7] = IPMI_OEM_QUANTA_EXTENDED_CONFIG_READ_ALL_BYTES; if ((rs_len = ipmi_cmd_raw (state_data->ipmi_ctx, 0, /* lun */ IPMI_NET_FN_OEM_QUANTA_GENERIC_RQ, /* network function */ bytes_rq, /* data */ 8, /* num bytes */ bytes_rs, IPMI_OEM_MAX_BYTES)) < 0) { pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_raw: %s\n", ipmi_ctx_errormsg (state_data->ipmi_ctx)); goto cleanup; } if (ipmi_oem_check_response_and_completion_code (state_data, bytes_rs, rs_len, 6, IPMI_CMD_OEM_QUANTA_GET_EXTENDED_CONFIGURATION, IPMI_NET_FN_OEM_QUANTA_GENERIC_RS, NULL) < 0) goto cleanup; memset (buf, '\0', buflen); if ((rs_len - 6) > 0) { uint8_t len; /* According to docs - all strings are stored as P-strings */ len = bytes_rs[6]; if (len != (rs_len - 7)) { pstdout_fprintf (state_data->pstate, stderr, "P-string length returned invalid: len = %u, rs_len = %u\n", len, rs_len); goto cleanup; } if ((rs_len - 7) > buflen) { pstdout_fprintf (state_data->pstate, stderr, "internal buffer overflow: rs_len = %u, buflen = %u\n", rs_len, buflen); goto cleanup; } memcpy (buf, &bytes_rs[7], rs_len - 7); } rv = 0; cleanup: return (rv); }
false
false
false
false
false
0
OnListBox(wxCommandEvent& event) { if(event.GetEventObject() == NULL) return; if(event.GetEventObject() == levellist) { if(event.GetClientData() != NULL) { CountedPtr<Level> newlevel = (Level*) event.GetClientData(); if(event.GetEventType() == wxEVT_COMMAND_LISTBOX_DOUBLECLICKED) { NewView(newlevel); } else { SetLevel(newlevel); AddIdleRedraw(DRAW_MAP); OnChangeFilename(); } } } }
false
false
false
false
false
0
sample(int t0, int b0, int l0, int r0, char *name, char *name1, char *name2, double *msc) { int btn, d, fmask; double tmp; /* IN name = name of raster map to be set up name1 = name of overlay vector map name2 = name of overlay site map msc[0]= cols of region/width of screen msc[1]= rows of region/height of screen t0 = top row of sampling frame b0 = bottom row of sampling frame l0 = left col of sampling frame r0 = right col of sampling frame */ /* determine whether the user will use the keyboard or mouse to setup the sampling units */ keyboard: fprintf(stderr, "\n\n HOW WILL YOU SPECIFY SAMPLING UNITS?\n"); fprintf(stderr, "\n Use keyboard to enter sampling unit dimensions 1"); fprintf(stderr, "\n Use mouse to draw sampling units 2\n"); fprintf(stderr, "\n Which Number? "); numtrap(1, &tmp); d = (int)(tmp); if (d < 1 || d > 2) { fprintf(stderr, " You did not enter a 1 or 2, try again\n"); goto keyboard; } if (d == 1 || d == 2) { /* return a value > 0 to fmask if there is a MASK present */ fprintf(stderr, "\n If a MASK is not present (see r.mask) a beep may sound\n"); fprintf(stderr, " and a WARNING may be printed that can be ignored.\n"); fprintf(stderr, " If a MASK is present there will be no warning.\n"); fmask = G_open_cell_old("MASK", G_mapset()); fprintf(stderr, "\n"); /* call the routine to setup sampling units manually */ if (d == 1) man_unit(t0, b0, l0, r0, name, name1, name2, msc, fmask); /* call the routine to setup sampling units graphically */ else if (d == 2) graph_unit(t0, b0, l0, r0, name, name1, name2, msc, fmask); G_close_cell(fmask); } /* if neither, then exit */ else exit(0); return; }
false
false
false
false
false
0
numaAddBorder(NUMA *nas, l_int32 left, l_int32 right, l_float32 val) { l_int32 i, n, len; l_float32 startx, delx; l_float32 *fas, *fad; NUMA *nad; PROCNAME("numaAddBorder"); if (!nas) return (NUMA *)ERROR_PTR("nas not defined", procName, NULL); if (left < 0) left = 0; if (right < 0) right = 0; if (left == 0 && right == 0) return numaCopy(nas); n = numaGetCount(nas); len = n + left + right; nad = numaMakeConstant(val, len); numaGetParameters(nas, &startx, &delx); numaSetParameters(nad, startx - delx * left, delx); fas = numaGetFArray(nas, L_NOCOPY); fad = numaGetFArray(nad, L_NOCOPY); for (i = 0; i < n; i++) fad[left + i] = fas[i]; return nad; }
false
false
false
false
false
0
pop_datafd() { if ( include_depth <= 1 ) { include_depth = 0; data_fd = NULL;} else fclose(data_fd); if ( include_depth > 0 ) { data_fd = datafile_stack[--include_depth-1].fd; line_no = datafile_stack[include_depth-1].line; } else data_fd = NULL; }
false
false
false
false
false
0
psk_server_callback(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len) { unsigned int psk_len; fr_tls_server_conf_t *conf; conf = (fr_tls_server_conf_t *)SSL_get_ex_data(ssl, FR_TLS_EX_INDEX_CONF); if (!conf) return 0; /* * FIXME: Look up the PSK password based on the identity! */ if (strcmp(identity, conf->psk_identity) != 0) { return 0; } psk_len = strlen(conf->psk_password); if (psk_len > (2 * max_psk_len)) return 0; return fr_hex2bin(conf->psk_password, psk, psk_len); }
false
false
false
false
false
0
qla4xxx_wait_login_resp_boot_tgt(struct scsi_qla_host *ha) { struct ddb_entry *ddb_entry; struct dev_db_entry *fw_ddb_entry = NULL; dma_addr_t fw_ddb_entry_dma; unsigned long wtime; uint32_t ddb_state; int max_ddbs, idx, ret; max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX : MAX_DEV_DB_ENTRIES; fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), &fw_ddb_entry_dma, GFP_KERNEL); if (!fw_ddb_entry) { ql4_printk(KERN_ERR, ha, "%s: Unable to allocate dma buffer\n", __func__); goto exit_login_resp; } wtime = jiffies + (HZ * BOOT_LOGIN_RESP_TOV); for (idx = 0; idx < max_ddbs; idx++) { ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx); if (ddb_entry == NULL) continue; if (test_bit(DF_BOOT_TGT, &ddb_entry->flags)) { DEBUG2(ql4_printk(KERN_INFO, ha, "%s: DDB index [%d]\n", __func__, ddb_entry->fw_ddb_index)); do { ret = qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, fw_ddb_entry, fw_ddb_entry_dma, NULL, NULL, &ddb_state, NULL, NULL, NULL); if (ret == QLA_ERROR) goto exit_login_resp; if ((ddb_state == DDB_DS_SESSION_ACTIVE) || (ddb_state == DDB_DS_SESSION_FAILED)) break; schedule_timeout_uninterruptible(HZ); } while ((time_after(wtime, jiffies))); if (!time_after(wtime, jiffies)) { DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Login response wait timer expired\n", __func__)); goto exit_login_resp; } } } exit_login_resp: if (fw_ddb_entry) dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), fw_ddb_entry, fw_ddb_entry_dma); }
false
false
false
false
false
0
run() { m_serverSocket = new QTcpServer; connect(this, SIGNAL(messageReceived(int,Jolie::Message)), m_server, SLOT(messageReceived(int,Jolie::Message))); connect(m_serverSocket, SIGNAL(newConnection()), this, SLOT(onIncomingConnection()), Qt::QueuedConnection); m_serverSocket->listen(QHostAddress::Any, m_port); exec(); delete m_serverSocket; }
false
false
false
false
false
0
_dhcp_down(interface_defn *ifd, execfn *exec) { if ( execable("/sbin/dhclient") ) { if (!execute("dhclient -6 -r -pf /run/dhclient6.%iface%.pid -lf /var/lib/dhcp/dhclient6.%iface%.leases %iface%", ifd, exec)) return 0; } if ( iface_is_link() ) { if (!execute("ip link set dev %iface% down", ifd, exec)) return 0; } return 1; }
false
false
false
false
false
0
get(const std::string& key) const { static std::string emptyString=""; if (count(key)==1) return attributes_.find(key)->second; else return emptyString; // Throw an exception? }
false
false
false
false
false
0
get_drag_data (NemoTreeViewDragDest *dest, GdkDragContext *context, guint32 time) { GdkAtom target; target = gtk_drag_dest_find_target (GTK_WIDGET (dest->details->tree_view), context, NULL); if (target == GDK_NONE) { return FALSE; } if (target == gdk_atom_intern (NEMO_ICON_DND_XDNDDIRECTSAVE_TYPE, FALSE) && !dest->details->drop_occurred) { dest->details->drag_type = NEMO_ICON_DND_XDNDDIRECTSAVE; dest->details->have_drag_data = TRUE; return TRUE; } gtk_drag_get_data (GTK_WIDGET (dest->details->tree_view), context, target, time); return TRUE; }
false
false
false
false
false
0
indicesToPointers(const int* map) { #define IDX2PTR(_p_,_b_) map?(&(_b_)[map[(((char*)_p_)-(char*)0)]]): \ (&(_b_)[(((char*)_p_)-(char*)0)]) btSoftBody::Node* base=&m_nodes[0]; int i,ni; for(i=0,ni=m_nodes.size();i<ni;++i) { if(m_nodes[i].m_leaf) { m_nodes[i].m_leaf->data=&m_nodes[i]; } } for(i=0,ni=m_links.size();i<ni;++i) { m_links[i].m_n[0]=IDX2PTR(m_links[i].m_n[0],base); m_links[i].m_n[1]=IDX2PTR(m_links[i].m_n[1],base); } for(i=0,ni=m_faces.size();i<ni;++i) { m_faces[i].m_n[0]=IDX2PTR(m_faces[i].m_n[0],base); m_faces[i].m_n[1]=IDX2PTR(m_faces[i].m_n[1],base); m_faces[i].m_n[2]=IDX2PTR(m_faces[i].m_n[2],base); if(m_faces[i].m_leaf) { m_faces[i].m_leaf->data=&m_faces[i]; } } for(i=0,ni=m_anchors.size();i<ni;++i) { m_anchors[i].m_node=IDX2PTR(m_anchors[i].m_node,base); } for(i=0,ni=m_notes.size();i<ni;++i) { for(int j=0;j<m_notes[i].m_rank;++j) { m_notes[i].m_nodes[j]=IDX2PTR(m_notes[i].m_nodes[j],base); } } #undef IDX2PTR }
false
false
false
false
false
0
GetAlignment(const std::string& widgettype, const std::string& object, const std::string& name, PG_Label::TextAlign& align) { long b = -1; GetProperty(widgettype, object, name, b); if(b == -1) { return; } switch(b) { case 0: align = PG_Label::LEFT; break; case 1: align = PG_Label::CENTER; break; case 2: align = PG_Label::RIGHT; break; } return; }
false
false
false
false
false
0
channel_x_off(PLCI *plci, byte ch, byte flag) { DIVA_CAPI_ADAPTER *a = plci->adapter; if ((a->ch_flow_control[ch] & N_RX_FLOW_CONTROL_MASK) == 0) { a->ch_flow_control[ch] |= (N_CH_XOFF | flag); a->ch_flow_plci[ch] = plci->Id; a->ch_flow_control_pending++; } }
false
false
false
false
false
0
main ( int agc, char ** argv ) { int NbrIteration = 1 ; int Min; int OPTIONS; char * FileName; FileName = LitOptions ( agc, argv, &OPTIONS ) ; // Charge le Graph contenu ds le fichier do { /* 1 */ if ( OPTIONS & VERB ) { RED printf ( "\n( %d ) PARCOUR LE FLOT ", NbrIteration ) ; DEFAULT_COLOR } Init_Marquage () ; // Reinitialise le marquage des sommets if ( OPTIONS & PROF ) Parcour_Proffondeur ( 0, OPTIONS ); else if ( OPTIONS & LARG ) Parcour_Largeur ( 0, OPTIONS ); /* 2 */ if ( OPTIONS & VERB ) { RED printf ( "\n( %d ) RECHERCHE CHAINE AUGMENTANTE ", NbrIteration ) ; DEFAULT_COLOR } if ( OPTIONS & VERB ) AfficheParcour ( OPTIONS ) ; Min = RechercheParcour () ; /* 3 */ if ( OPTIONS & VERB ) { RED printf( "\n( %d ) APPLIQUE CHAINE AUGMENTANTE DE \033[1;33m%d ", NbrIteration, Min ) ; DEFAULT_COLOR } AppliqueParcour ( Min ) ; if ( OPTIONS & G_VERB ) AfficheConso () ; NbrIteration ++ ; } while ( Min != 0 ) ; if ( OPTIONS & VERB ) { CYAN printf( "\n\n -----------------------------------" ); printf( "\n ---- RESULTAT FINAL ----" ); } DEFAULT_COLOR AfficheConso () ; AfficheTotal () ; if ( OPTIONS & EXPORT ) { FILE * ptr ; if ( (ptr=fopen(Change_Extention(FileName, ".res"), "w") ) != NULL ) Write_matrix_to_file( ptr, NBR_SOMMET, NomSommet, Matrice_Max, Matrice_Conso, 1, OPTIONS & CONSO ); else exit( EXIT_FAILURE ); } return 0; }
false
false
false
false
true
1
DataSetContour(vtkDataSet *input, vtkPolyData *output) { int numContours=this->ContourValues->GetNumberOfContours(); double *values=this->ContourValues->GetValues(); vtkContourFilter *contour = vtkContourFilter::New(); contour->SetInput((vtkImageData *)input); contour->SetComputeNormals (this->ComputeNormals); contour->SetComputeGradients (this->ComputeGradients); contour->SetComputeScalars (this->ComputeScalars); contour->SetDebug(this->Debug); contour->SetNumberOfContours(numContours); for (int i=0; i < numContours; i++) { contour->SetValue(i,values[i]); } contour->Update(); output->ShallowCopy(contour->GetOutput()); this->SetOutput(output); contour->Delete(); }
false
false
false
false
false
0
fpm_clipboard_clear(GtkClipboard *clip, gpointer data) { fpm_clipboard *clipboard = data; if(clipboard->no_clear) { clipboard->no_clear = FALSE; } else { g_free(clipboard); } }
false
false
false
false
false
0
luaX_next (LexState *ls) { ls->lastline = ls->linenumber; if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ ls->t = ls->lookahead; /* use this one */ ls->lookahead.token = TK_EOS; /* and discharge it */ } else ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ }
false
false
false
false
false
0
load_rax(void* value) { EnsureSpace ensure_space(this); emit(0x48); // REX.W emit(0xA1); emitq(reinterpret_cast<uintptr_t> (value)); }
false
false
false
false
false
0
gfs2_symlink(struct inode *dir, struct dentry *dentry, const char *symname) { struct gfs2_sbd *sdp = GFS2_SB(dir); unsigned int size; size = strlen(symname); if (size > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode) - 1) return -ENAMETOOLONG; return gfs2_create_inode(dir, dentry, NULL, S_IFLNK | S_IRWXUGO, 0, symname, size, 0, NULL); }
false
false
false
false
false
0
edwin_new(struct xio *xio, struct vbi *vbi, int pgno, int subno) { struct edwin *w; struct vt_page *vtp; u8 buf[64]; int i; if (not(w = malloc(sizeof(*w)))) goto fail1; if (not(w->xw = xio_open_win(xio, 0))) goto fail2; w->pgno = pgno; w->subno = subno; vtp = vbi_query_page(vbi, pgno, subno); if (vtp) for (i = 0; i < 25; ++i) xio_put_line(w->xw, i, vtp->data[i]); else xio_clear_win(w->xw); w->mode = 1; w->edline = 0; if (w->subno == ANY_SUB) sprintf(buf, "Editor %03x", w->pgno); else sprintf(buf, "Editor %03x/%x", w->pgno, w->subno); xio_title(w->xw, buf); xio_set_concealed(w->xw, w->reveal = 1); xio_set_handler(w->xw, edwin_event, w); cursor(w, W/2, H/2); return w; fail2: free(w); fail1: return 0; }
false
false
false
false
false
0
glob_set(URLGlob *glob, char **patternp, size_t *posp, unsigned long *amount, int globindex) { /* processes a set expression with the point behind the opening '{' ','-separated elements are collected until the next closing '}' */ URLPattern *pat; bool done = FALSE; char *buf = glob->glob_buffer; char *pattern = *patternp; char *opattern = pattern; size_t opos = *posp-1; pat = &glob->pattern[glob->size]; /* patterns 0,1,2,... correspond to size=1,3,5,... */ pat->type = UPTSet; pat->content.Set.size = 0; pat->content.Set.ptr_s = 0; pat->content.Set.elements = NULL; pat->globindex = globindex; while(!done) { switch (*pattern) { case '\0': /* URL ended while set was still open */ return GLOBERROR("unmatched brace", opos, GLOB_ERROR); case '{': case '[': /* no nested expressions at this time */ return GLOBERROR("nested brace", *posp, GLOB_ERROR); case '}': /* set element completed */ if(opattern == pattern) return GLOBERROR("empty string within braces", *posp, GLOB_ERROR); /* add 1 to size since it'll be incremented below */ if(multiply(amount, pat->content.Set.size+1)) return GLOBERROR("range overflow", 0, GLOB_ERROR); /* fall-through */ case ',': *buf = '\0'; if(pat->content.Set.elements) { char **new_arr = realloc(pat->content.Set.elements, (pat->content.Set.size + 1) * sizeof(char*)); if(!new_arr) return GLOBERROR("out of memory", 0, GLOB_NO_MEM); pat->content.Set.elements = new_arr; } else pat->content.Set.elements = malloc(sizeof(char*)); if(!pat->content.Set.elements) return GLOBERROR("out of memory", 0, GLOB_NO_MEM); pat->content.Set.elements[pat->content.Set.size] = strdup(glob->glob_buffer); if(!pat->content.Set.elements[pat->content.Set.size]) return GLOBERROR("out of memory", 0, GLOB_NO_MEM); ++pat->content.Set.size; if(*pattern == '}') { pattern++; /* pass the closing brace */ done = TRUE; continue; } buf = glob->glob_buffer; ++pattern; ++(*posp); break; case ']': /* illegal closing bracket */ return GLOBERROR("unexpected close bracket", *posp, GLOB_ERROR); case '\\': /* escaped character, skip '\' */ if(pattern[1]) { ++pattern; ++(*posp); } /* intentional fallthrough */ default: *buf++ = *pattern++; /* copy character to set element */ ++(*posp); } } *patternp = pattern; /* return with the new position */ return GLOB_OK; }
false
false
false
false
false
0
main(int argc, char **argv) { try { printf(" observations2map - Part of the MRPT\n"); printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str()); printf("-------------------------------------------------------------------\n"); // Process arguments: if ((argc!=4 && argc!=6) || (argc==6 && 0!=mrpt::system::os::_strcmp(argv[4],"-s") ) ) { cout << "Use: observations2map <config_file.ini> <observations.simplemap> <outputmap_prefix> [-s INI_FILE_SECTION_NAME] " << endl; cout << " Default: INI_FILE_SECTION_NAME = MappingApplication" << endl; cout << "Push any key to exit..." << endl; os::getch(); return -1; } string configFile = std::string( argv[1] ); string inputFile = std::string( argv[2] ); string outprefix = std::string( argv[3] ); if (argc>4) { METRIC_MAP_CONFIG_SECTION = string(argv[5]); } // Load simplemap: cout << "Loading simplemap..."; mrpt::maps::CSimpleMap simplemap; CFileGZInputStream f( inputFile.c_str() ); f >> simplemap; cout <<"done: " << simplemap.size() << " observations." << endl; // Create metric maps: TSetOfMetricMapInitializers mapCfg; mapCfg.loadFromConfigFile( CConfigFile( configFile ), METRIC_MAP_CONFIG_SECTION ); CMultiMetricMap metricMap; metricMap.setListOfMaps( &mapCfg ); // Build metric maps: cout << "Building metric maps..."; metricMap.loadFromProbabilisticPosesAndObservations( simplemap ); cout << "done." << endl; // Save metric maps: // --------------------------- metricMap.saveMetricMapRepresentationToFile( outprefix ); // grid maps: size_t i; for (i=0;i<metricMap.m_gridMaps.size();i++) { string str = format( "%s_gridmap_no%02u.gridmap", outprefix.c_str(), (unsigned)i ); cout << "Saving gridmap #" << i << " to " << str << endl; CFileGZOutputStream f(str); f << *metricMap.m_gridMaps[i]; cout << "done." << endl; } return 0; } catch (std::exception &e) { std::cerr << e.what() << std::endl << "Program finished for an exception!!" << std::endl; mrpt::system::pause(); return -1; } catch (...) { std::cerr << "Untyped exception!!" << std::endl; mrpt::system::pause(); return -1; } }
false
false
false
false
false
0
ATRewriteTables(List **wqueue, LOCKMODE lockmode) { ListCell *ltab; /* Go through each table that needs to be checked or rewritten */ foreach(ltab, *wqueue) { AlteredTableInfo *tab = (AlteredTableInfo *) lfirst(ltab); /* Foreign tables have no storage. */ if (tab->relkind == RELKIND_FOREIGN_TABLE) continue; /* * If we change column data types or add/remove OIDs, the operation * has to be propagated to tables that use this table's rowtype as a * column type. tab->newvals will also be non-NULL in the case where * we're adding a column with a default. We choose to forbid that * case as well, since composite types might eventually support * defaults. * * (Eventually we'll probably need to check for composite type * dependencies even when we're just scanning the table without a * rewrite, but at the moment a composite type does not enforce any * constraints, so it's not necessary/appropriate to enforce them just * during ALTER.) */ if (tab->newvals != NIL || tab->rewrite) { Relation rel; rel = heap_open(tab->relid, NoLock); find_composite_type_dependencies(rel->rd_rel->reltype, rel, NULL); heap_close(rel, NoLock); } /* * We only need to rewrite the table if at least one column needs to * be recomputed, or we are adding/removing the OID column. */ if (tab->rewrite) { /* Build a temporary relation and copy data */ Relation OldHeap; Oid OIDNewHeap; Oid NewTableSpace; OldHeap = heap_open(tab->relid, NoLock); /* * We don't support rewriting of system catalogs; there are too * many corner cases and too little benefit. In particular this * is certainly not going to work for mapped catalogs. */ if (IsSystemRelation(OldHeap)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot rewrite system relation \"%s\"", RelationGetRelationName(OldHeap)))); /* * Don't allow rewrite on temp tables of other backends ... their * local buffer manager is not going to cope. */ if (RELATION_IS_OTHER_TEMP(OldHeap)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot rewrite temporary tables of other sessions"))); /* * Select destination tablespace (same as original unless user * requested a change) */ if (tab->newTableSpace) NewTableSpace = tab->newTableSpace; else NewTableSpace = OldHeap->rd_rel->reltablespace; heap_close(OldHeap, NoLock); /* Create transient table that will receive the modified data */ OIDNewHeap = make_new_heap(tab->relid, NewTableSpace); /* * Copy the heap data into the new table with the desired * modifications, and test the current data within the table * against new constraints generated by ALTER TABLE commands. */ ATRewriteTable(tab, OIDNewHeap, lockmode); /* * Swap the physical files of the old and new heaps, then rebuild * indexes and discard the old heap. We can use RecentXmin for * the table's new relfrozenxid because we rewrote all the tuples * in ATRewriteTable, so no older Xid remains in the table. Also, * we never try to swap toast tables by content, since we have no * interest in letting this code work on system catalogs. */ finish_heap_swap(tab->relid, OIDNewHeap, false, false, true, RecentXmin); } else { /* * Test the current data within the table against new constraints * generated by ALTER TABLE commands, but don't rebuild data. */ if (tab->constraints != NIL || tab->new_notnull) ATRewriteTable(tab, InvalidOid, lockmode); /* * If we had SET TABLESPACE but no reason to reconstruct tuples, * just do a block-by-block copy. */ if (tab->newTableSpace) ATExecSetTableSpace(tab->relid, tab->newTableSpace, lockmode); } } /* * Foreign key constraints are checked in a final pass, since (a) it's * generally best to examine each one separately, and (b) it's at least * theoretically possible that we have changed both relations of the * foreign key, and we'd better have finished both rewrites before we try * to read the tables. */ foreach(ltab, *wqueue) { AlteredTableInfo *tab = (AlteredTableInfo *) lfirst(ltab); Relation rel = NULL; ListCell *lcon; foreach(lcon, tab->constraints) { NewConstraint *con = lfirst(lcon); if (con->contype == CONSTR_FOREIGN) { Constraint *fkconstraint = (Constraint *) con->qual; Relation refrel; if (rel == NULL) { /* Long since locked, no need for another */ rel = heap_open(tab->relid, NoLock); } refrel = heap_open(con->refrelid, RowShareLock); validateForeignKeyConstraint(fkconstraint->conname, rel, refrel, con->refindid, con->conid); /* * No need to mark the constraint row as validated, we did * that when we inserted the row earlier. */ heap_close(refrel, NoLock); } } if (rel) heap_close(rel, NoLock); } }
false
false
false
false
false
0
installedTask() { Task::installedTask(); if (myserver->getfd() >= 0) { loggedIn("+OK Already logged in."); // Already return; } currentHandler= &LoginTask::greetingHandler; myserver->pop3LoginInfo = myserver->savedLoginInfo; string errmsg=myserver-> socketConnect(myserver->pop3LoginInfo, "pop3", "pop3s"); if (errmsg.size() > 0) { fail(errmsg.c_str()); return; } }
false
false
false
false
false
0
mdio_write(struct nic *nic __unused, int phy_id, int location, int value) { int i; int cmd = (0x5002 << 16) | (phy_id << 23) | (location<<18) | value; long mdio_addr = ioaddr + CSR9; whereami("mdio_write\n"); if (tp->chip_id == LC82C168) { int i = 1000; outl(cmd, ioaddr + 0xA0); do if ( ! (inl(ioaddr + 0xA0) & 0x80000000)) break; while (--i > 0); return; } if (tp->chip_id == COMET) { if (phy_id != 1) return; if (location < 7) outl(value, ioaddr + 0xB4 + (location<<2)); else if (location == 17) outl(value, ioaddr + 0xD0); else if (location >= 29 && location <= 31) outl(value, ioaddr + 0xD4 + ((location-29)<<2)); return; } /* Establish sync by sending 32 logic ones. */ for (i = 32; i >= 0; i--) { outl(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr); mdio_delay(); outl(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr); mdio_delay(); } /* Shift the command bits out. */ for (i = 31; i >= 0; i--) { int dataval = (cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0; outl(MDIO_ENB | dataval, mdio_addr); mdio_delay(); outl(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr); mdio_delay(); } /* Clear out extra bits. */ for (i = 2; i > 0; i--) { outl(MDIO_ENB_IN, mdio_addr); mdio_delay(); outl(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr); mdio_delay(); } }
false
false
false
false
false
0
gx_set_dclk_frequency(struct fb_info *info) { const struct gx_pll_entry *pll_table; int pll_table_len; int i, best_i; long min, diff; u64 dotpll, sys_rstpll; int timeout = 1000; /* Rev. 1 Geode GXs use a 14 MHz reference clock instead of 48 MHz. */ if (cpu_data(0).x86_mask == 1) { pll_table = gx_pll_table_14MHz; pll_table_len = ARRAY_SIZE(gx_pll_table_14MHz); } else { pll_table = gx_pll_table_48MHz; pll_table_len = ARRAY_SIZE(gx_pll_table_48MHz); } /* Search the table for the closest pixclock. */ best_i = 0; min = abs(pll_table[0].pixclock - info->var.pixclock); for (i = 1; i < pll_table_len; i++) { diff = abs(pll_table[i].pixclock - info->var.pixclock); if (diff < min) { min = diff; best_i = i; } } rdmsrl(MSR_GLCP_SYS_RSTPLL, sys_rstpll); rdmsrl(MSR_GLCP_DOTPLL, dotpll); /* Program new M, N and P. */ dotpll &= 0x00000000ffffffffull; dotpll |= (u64)pll_table[best_i].dotpll_value << 32; dotpll |= MSR_GLCP_DOTPLL_DOTRESET; dotpll &= ~MSR_GLCP_DOTPLL_BYPASS; wrmsrl(MSR_GLCP_DOTPLL, dotpll); /* Program dividers. */ sys_rstpll &= ~( MSR_GLCP_SYS_RSTPLL_DOTPREDIV2 | MSR_GLCP_SYS_RSTPLL_DOTPREMULT2 | MSR_GLCP_SYS_RSTPLL_DOTPOSTDIV3 ); sys_rstpll |= pll_table[best_i].sys_rstpll_bits; wrmsrl(MSR_GLCP_SYS_RSTPLL, sys_rstpll); /* Clear reset bit to start PLL. */ dotpll &= ~(MSR_GLCP_DOTPLL_DOTRESET); wrmsrl(MSR_GLCP_DOTPLL, dotpll); /* Wait for LOCK bit. */ do { rdmsrl(MSR_GLCP_DOTPLL, dotpll); } while (timeout-- && !(dotpll & MSR_GLCP_DOTPLL_LOCK)); }
false
false
false
false
false
0
occurrencesOf(const char *pSearchString,unsigned searchLen,unsigned startPos) const { unsigned count=0; while ((startPos=_pBuffer->indexOf(pSearchString,searchLen,startPos))<_pBuffer->length()) { count++; startPos+=searchLen; } return count; }
false
false
false
false
false
0
sync_annot_list_add(struct sync_annot_list *l, const char *entry, const char *userid, const char *value) { struct sync_annot *item = xzmalloc(sizeof(struct sync_annot)); item->entry = xstrdup(entry); item->userid = xstrdup(userid); item->value = xstrdup(value); item->mark = 0; if (l->tail) l->tail = l->tail->next = item; else l->head = l->tail = item; l->count++; }
false
false
false
false
false
0
up_device_unifying_finalize (GObject *object) { UpDeviceUnifying *unifying; g_return_if_fail (object != NULL); g_return_if_fail (UP_IS_DEVICE_UNIFYING (object)); unifying = UP_DEVICE_UNIFYING (object); g_return_if_fail (unifying->priv != NULL); if (unifying->priv->poll_timer_id > 0) g_source_remove (unifying->priv->poll_timer_id); if (unifying->priv->hidpp_device != NULL) g_object_unref (unifying->priv->hidpp_device); G_OBJECT_CLASS (up_device_unifying_parent_class)->finalize (object); }
false
false
false
false
false
0
_wrap_new_apol_context_t(PyObject *self, PyObject *args) { int argc; PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = args ? (int)PyObject_Length(args) : 0; for (ii = 0; (ii < 2) && (ii < argc); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 0) { return _wrap_new_apol_context_t__SWIG_0(self, args); } if (argc == 1) { int _v; int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_apol_context_t__SWIG_2(self, args); } } if (argc == 2) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_apol_policy_t, 0); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_qpol_context_t, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_apol_context_t__SWIG_1(self, args); } } } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_apol_context_t'.\n" " Possible C/C++ prototypes are:\n" " apol_context_t::apol_context_t()\n" " apol_context_t::apol_context_t(apol_policy_t *,qpol_context_t *)\n" " apol_context_t::apol_context_t(char const *)\n"); return 0; }
false
false
false
false
false
0
_cmsCreateMutex(cmsContext ContextID) { _cmsMutexPluginChunkType* ptr = (_cmsMutexPluginChunkType*) _cmsContextGetClientChunk(ContextID, MutexPlugin); if (ptr ->CreateMutexPtr == NULL) return NULL; return ptr ->CreateMutexPtr(ContextID); }
false
false
false
false
false
0
index_pruneheader(char *buf, struct strlist *headers, struct strlist *headers_not) { char *p, *colon, *nextheader; int goodheader; char *endlastgood = buf; struct strlist *l; p = buf; while (*p && *p != '\r') { colon = strchr(p, ':'); if (colon && headers_not) { goodheader = 1; for (l = headers_not; l; l = l->next) { if ((size_t) (colon - p) == strlen(l->s) && !strncasecmp(p, l->s, colon - p)) { goodheader = 0; break; } } } else { goodheader = 0; } if (colon) { for (l = headers; l; l = l->next) { if ((size_t) (colon - p) == strlen(l->s) && !strncasecmp(p, l->s, colon - p)) { goodheader = 1; break; } } } nextheader = p; do { nextheader = strchr(nextheader, '\n'); if (nextheader) nextheader++; else nextheader = p + strlen(p); } while (*nextheader == ' ' || *nextheader == '\t'); if (goodheader) { if (endlastgood != p) { /* memmove and not strcpy since this is all within a * single buffer */ memmove(endlastgood, p, strlen(p) + 1); nextheader -= p - endlastgood; } endlastgood = nextheader; } p = nextheader; } *endlastgood = '\0'; }
false
false
false
false
false
0
to_XChar2b (object font, XFontStruct* font_info, const chart* src, XChar2b* dst, unsigned int count) { object encoding; pushSTACK(font); pushSTACK(O(object_xlib__encoding)); funcall(L(slot_value), 2); encoding = value1; if (font_info->min_byte1 == 0 && font_info->max_byte1 == 0) { /* Linear addressing */ if (!nullp(encoding)/*&& TheEncoding(encoding)->max_bytes_per_char==1*/) { /* Special hack: use the font's encoding */ if (count > 0) { cstombs(encoding,src,count,(uintB*)dst,count); return 1; } } else while (count > 0) { unsigned int c = as_cint(*src); if (c >= font_info->min_char_or_byte2 && c <= font_info->max_char_or_byte2) dst->byte2 = c; else dst->byte2 = font_info->default_char; dst->byte1 = 0; src++; dst++; count--; } } else { /* Matrix addressing */ unsigned int d = font_info->max_char_or_byte2 - font_info->min_char_or_byte2 + 1; while (count > 0) { unsigned int c = as_cint(*src); dst->byte1 = (c/d) + font_info->min_byte1; dst->byte2 = (c%d) + font_info->min_char_or_byte2; src++; dst++; count--; } } return 2; }
false
false
false
false
false
0
phrtsd(const char *const phrase, FourByteLong *const seed1, FourByteLong *const seed2) // not used in AutoDock code /* ********************************************************************** void phrtsd(char* phrase,FourByteLong *seed1,FourByteLong *seed2) PHRase To SeeDs Function Uses a phrase (character string) to generate two seeds for the RGN random number generator. Arguments phrase --> Phrase to be used for random number generation seed1 <-- First seed for generator seed2 <-- Second seed for generator Note Trailing blanks are eliminated before the seeds are generated. Generated seed values will fall in the range 1..2^30 (1..1,073,741,824) ********************************************************************** */ { static char table[] = "abcdefghijklmnopqrstuvwxyz\ ABCDEFGHIJKLMNOPQRSTUVWXYZ\ 0123456789\ !@#$%^&*()_+[];:'\\\"<>?,./"; FourByteLong ix; static FourByteLong twop30 = 1073741824L; static FourByteLong shift[5] = { 1L,64L,4096L,262144L,16777216L }; static FourByteLong i,ichr,j,lphr,values[5]; FourByteLong lennob(const char *const str); *seed1 = 1234567890L; *seed2 = 123456789L; lphr = lennob(phrase); if(lphr < 1) return; for (i=0; i<=(lphr-1); i++) { for (ix=0; table[ix]; ix++) if (*(phrase+i) == table[ix]) break; if (!table[ix]) ix = 0; ichr = ix % 64; if(ichr == 0) ichr = 63; for (j=1; j<=5; j++) { *(values+j-1) = ichr-j; if(*(values+j-1) < 1) *(values+j-1) += 63; } for (j=1; j<=5; j++) { *seed1 = ( *seed1+*(shift+j-1)**(values+j-1) ) % twop30; /*gmm 2-24-98 *seed2 = ( *seed2+*(shift+j-1)**(values+6-j-1)) % twop30;*/ *seed2 = ( *seed2+*(shift+j-1)**(values+5-j) ) % twop30; } } #undef twop30 }
false
false
false
false
false
0
stir421x_patch_device(struct irda_usb_cb *self) { unsigned int i; int ret; char stir421x_fw_name[12]; const struct firmware *fw; const unsigned char *fw_version_ptr; /* pointer to version string */ unsigned long fw_version = 0; /* * Known firmware patch file names for STIR421x dongles * are "42101001.sb" or "42101002.sb" */ sprintf(stir421x_fw_name, "4210%4X.sb", le16_to_cpu(self->usbdev->descriptor.bcdDevice)); ret = request_firmware(&fw, stir421x_fw_name, &self->usbdev->dev); if (ret < 0) return ret; /* We get a patch from userspace */ net_info_ratelimited("%s(): Received firmware %s (%zu bytes)\n", __func__, stir421x_fw_name, fw->size); ret = -EINVAL; /* Get the bcd product version */ if (!memcmp(fw->data, STIR421X_PATCH_PRODUCT_VER, sizeof(STIR421X_PATCH_PRODUCT_VER) - 1)) { fw_version_ptr = fw->data + sizeof(STIR421X_PATCH_PRODUCT_VER) - 1; /* Let's check if the product version is dotted */ if (fw_version_ptr[3] == '.' && fw_version_ptr[7] == '.') { unsigned long major, minor, build; major = simple_strtoul(fw_version_ptr, NULL, 10); minor = simple_strtoul(fw_version_ptr + 4, NULL, 10); build = simple_strtoul(fw_version_ptr + 8, NULL, 10); fw_version = (major << 12) + (minor << 8) + ((build / 10) << 4) + (build % 10); pr_debug("%s(): Firmware Product version %ld\n", __func__, fw_version); } } if (self->usbdev->descriptor.bcdDevice == cpu_to_le16(fw_version)) { /* * If we're here, we've found a correct patch * The actual image starts after the "STMP" keyword * so forward to the firmware header tag */ for (i = 0; i < fw->size && fw->data[i] != STIR421X_PATCH_END_OF_HDR_TAG; i++) ; /* here we check for the out of buffer case */ if (i < STIR421X_PATCH_CODE_OFFSET && i < fw->size && STIR421X_PATCH_END_OF_HDR_TAG == fw->data[i]) { if (!memcmp(fw->data + i + 1, STIR421X_PATCH_STMP_TAG, sizeof(STIR421X_PATCH_STMP_TAG) - 1)) { /* We can upload the patch to the target */ i += sizeof(STIR421X_PATCH_STMP_TAG); ret = stir421x_fw_upload(self, &fw->data[i], fw->size - i); } } } release_firmware(fw); return ret; }
false
false
false
false
false
0
fz_stroke_flush(struct sctx *s, fz_linecap start_cap, fz_linecap end_cap) { if (s->sn == 2) { fz_add_line_cap(s, s->beg[1], s->beg[0], start_cap); fz_add_line_cap(s, s->seg[0], s->seg[1], end_cap); } else if (s->dot) { fz_add_line_dot(s, s->beg[0]); } }
false
false
false
false
false
0
is_root_dn_pw( const char *dn, const Slapi_Value *cred ) { int rv= 0; char *rootpw = config_get_rootpw(); if ( rootpw == NULL || !slapi_dn_isroot( dn ) ) { rv = 0; } else { Slapi_Value rdnpwbv; Slapi_Value *rdnpwvals[2]; slapi_value_init_string(&rdnpwbv,rootpw); rdnpwvals[ 0 ] = &rdnpwbv; rdnpwvals[ 1 ] = NULL; rv = slapi_pw_find_sv( rdnpwvals, cred ) == 0; value_done(&rdnpwbv); } slapi_ch_free_string( &rootpw ); return rv; }
false
false
false
false
false
0
npc_in_room (sc_gameref_t game, sc_int npc, sc_int room) { if (npc_trace) { sc_trace ("NPC: checking NPC %ld in room %ld (NPC is in %ld)\n", npc, room, gs_npc_location (game, npc)); } return gs_npc_location (game, npc) - 1 == room; }
false
false
false
false
false
0
search(le_uint16 value, const le_uint16 array[], le_int32 count) { le_int32 power = 1 << highBit(count); le_int32 extra = count - power; le_int32 probe = power; le_int32 index = 0; if (value >= array[extra]) { index = extra; } while (probe > (1 << 0)) { probe >>= 1; if (value >= array[index + probe]) { index += probe; } } return index; }
false
false
false
false
false
0
netsnmp_access_route_entry_create(void) { netsnmp_route_entry *entry = SNMP_MALLOC_TYPEDEF(netsnmp_route_entry); if(NULL == entry) { snmp_log(LOG_ERR, "could not allocate route entry\n"); return NULL; } entry->oid_index.oids = &entry->ns_rt_index; entry->oid_index.len = 1; entry->rt_metric1 = -1; entry->rt_metric2 = -1; entry->rt_metric3 = -1; entry->rt_metric4 = -1; entry->rt_metric5 = -1; /** entry->row_status? */ return entry; }
false
false
false
false
false
0
JPEGEncodeImage(const ImageInfo *image_info, Image *image) { unsigned char *blob; size_t length; MagickPassFail status=MagickFail; blob=ImageToJPEGBlob(image,image_info,&length,&image->exception); if (blob != (unsigned char *) NULL) { register const unsigned char *p; register size_t i; Ascii85Initialize(image); for (p=(const unsigned char*) blob,i=0; i < length; i++) Ascii85Encode(image,(unsigned long) p[i]); Ascii85Flush(image); MagickFreeMemory(blob); status=MagickPass; } return status; }
false
false
false
false
false
0
cacheGeometry() const { d_cachedGeometryValid = true; d_geometry->reset(); // if no image, nothing more to do. if (!d_cursorImage) return; if (d_customSize.d_width != 0.0f || d_customSize.d_height != 0.0f) { calculateCustomOffset(); d_cursorImage->draw(*d_geometry, d_customOffset, d_customSize, 0); } else { d_cursorImage->draw(*d_geometry, Vector2(0, 0), 0); } }
false
false
false
false
false
0
my_memlen(const char *buf, size_t count) { if (count > 0 && buf[count-1] == '\n') return count - 1; else return count; }
false
false
false
false
false
0
rl_vi_end_word (count, key) int count, key; { if (count < 0) { rl_ding (); return -1; } if (_rl_uppercase_p (key)) rl_vi_eWord (count, key); else rl_vi_eword (count, key); return (0); }
false
false
false
false
false
0
glulxe_retained_unregister(void *array, glui32 len, char *typecode, gidispatch_rock_t objrock) { arrayref_t *arref = NULL; arrayref_t **aptr; glui32 ix, addr2, val; if (typecode[4] != 'I' || array == NULL) { /* We only retain integer arrays. */ return; } for (aptr=(&arrays); (*aptr); aptr=(&((*aptr)->next))) { if ((*aptr)->array == array) break; } arref = *aptr; if (!arref) fatal_error("Unable to re-find array argument in Glk call."); if (arref != objrock.ptr) fatal_error("Mismatched array reference in Glk call."); if (!arref->retained) fatal_error("Unretained array reference in Glk call."); if (arref->elemsize != 4 || arref->len != len) fatal_error("Mismatched array argument in Glk call."); *aptr = arref->next; arref->next = NULL; for (ix=0, addr2=arref->addr; ix<arref->len; ix++, addr2+=4) { val = ((glui32 *)array)[ix]; MemW4(addr2, val); } glulx_free(array); glulx_free(arref); }
false
false
false
false
false
0
gtk_source_gutter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GtkSourceGutter *self = GTK_SOURCE_GUTTER (object); switch (prop_id) { case PROP_VIEW: set_view (self, GTK_SOURCE_VIEW (g_value_get_object (value))); break; case PROP_WINDOW_TYPE: self->priv->window_type = g_value_get_enum (value); break; case PROP_XPAD: set_xpad (self, g_value_get_int (value), TRUE); break; case PROP_YPAD: set_ypad (self, g_value_get_int (value), TRUE); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
false
false
false
false
false
0
par_timesdivide(root) TREE *root; { TREE *newroot; while(symbol == times || symbol == ptimes || symbol == divide) { newroot = newtree(); LEFT(newroot) = root; switch(symbol) { case times: VDATA(newroot) = opr_mul; break; case ptimes: VDATA(newroot) = opr_pmul; break; case divide: VDATA(newroot) = opr_div; break; } ETYPE(newroot) = ETYPE_OPER; root = newroot; scan(); RIGHT(newroot) = nameorvar(); switch(symbol) { case power: RIGHT(newroot) = par_pow(RIGHT(newroot)); break; case transpose: RIGHT(newroot) = par_trans(RIGHT(newroot)); break; case apply: case not: RIGHT(newroot) = par_apply(RIGHT(newroot)); break; } } return newroot; }
false
false
false
false
false
0
ComputeLength() { Packet::ComputeLength(); length+=4+strlen(oldpath)+4+strlen(newpath); if(protocol_version>=5) length+=4; // flags }
false
false
false
false
false
0
rgbe_mapped_file_remaining (GMappedFile *f, const void *data) { g_return_val_if_fail (f, 0); g_return_val_if_fail (GPOINTER_TO_UINT (data) > GPOINTER_TO_UINT (g_mapped_file_get_contents (f)), 0); return GPOINTER_TO_UINT (data) - GPOINTER_TO_UINT (g_mapped_file_get_contents (f)) - g_mapped_file_get_length (f); }
false
false
false
false
false
0
run (void) { if (this->open () == -1) return 1; if (option[BINARYSEARCH]) { if (this->compute_binary_search () == -1) return 1; } else if (option[LINEARSEARCH]) { if (this->compute_linear_search () == -1) return 1; } else { if (this->compute_perfect_hash () == -1) return 1; // Sorts the key word list by hash value, and then outputs the // list. The generated hash table code is only output if the // early stage of processing turned out O.K. this->key_list.sort (); } this->key_list.output (); return 0; }
false
false
false
false
false
0
add_item_cb (const char *type, gpointer data_p, gpointer be_data_p) { GncXmlDataType_t *data = data_p; struct file_backend *be_data = be_data_p; g_return_if_fail (type && data && be_data); g_return_if_fail (data->version == GNC_FILE_BACKEND_VERS); if (be_data->ok) return; if (!g_strcmp0 (be_data->tag, data->type_name)) { if (data->add_item) (data->add_item)(be_data->gd, be_data->data); be_data->ok = TRUE; } }
false
false
false
false
false
0
cht_ti_jack_event(struct notifier_block *nb, unsigned long event, void *data) { struct snd_soc_jack *jack = (struct snd_soc_jack *)data; struct snd_soc_dapm_context *dapm = &jack->card->dapm; if (event & SND_JACK_MICROPHONE) { snd_soc_dapm_force_enable_pin(dapm, "SHDN"); snd_soc_dapm_force_enable_pin(dapm, "MICBIAS"); snd_soc_dapm_sync(dapm); } else { snd_soc_dapm_disable_pin(dapm, "MICBIAS"); snd_soc_dapm_disable_pin(dapm, "SHDN"); snd_soc_dapm_sync(dapm); } return 0; }
false
false
false
false
false
0
slotToggleProviderButton() { QString filter; QActionList checkedActions; foreach( const Playlists::PlaylistProvider *p, m_providerActions.keys() ) { QAction *action = m_providerActions.value( p ); if( action->isChecked() ) { QString escapedName = QRegExp::escape( p->prettyName() ).replace( " ", "\\ " ); filter += QString( filter.isEmpty() ? "%1" : "|%1" ).arg( escapedName ); checkedActions << action; action->setEnabled( true ); } } //if all are enabled the filter can be completely disabled. if( checkedActions.count() == m_providerActions.count() ) filter = QString(); m_filterProxy->setFilterRegExp( filter ); //don't allow the last visible provider to be hidden if( checkedActions.count() == 1 ) checkedActions.first()->setEnabled( false ); }
false
false
false
false
false
0
import_environment_set_x (SCM env, SCM sym, SCM val) #define FUNC_NAME "import_environment_set_x" { SCM owner = import_environment_lookup (env, sym); if (SCM_UNBNDP (owner)) { return SCM_UNDEFINED; } else if (scm_is_pair (owner)) { SCM resolve = import_environment_conflict (env, sym, owner); if (SCM_ENVIRONMENT_P (resolve)) return SCM_ENVIRONMENT_SET (resolve, sym, val); else return SCM_ENVIRONMENT_LOCATION_IMMUTABLE; } else { return SCM_ENVIRONMENT_SET (owner, sym, val); } }
false
false
false
false
false
0
toString() const { string s=""; int i; for (i=0; i<3; i++) { if (i > 0) s.append(":",1); string ss; string::iterator b, e; switch (i) { case 0: ss=path; break; case 1: ss=hiersep; break; default: ss=name; break; } b=ss.begin(); e=ss.end(); while (b != e) { if (*b == '\\' || *b == ':') s.append("\\", 1); s.append(&*b, 1); b++; } } s += ":"; if (hasMessages()) s += "S"; if (hasSubFolders()) s += "C"; return s; }
false
false
false
false
false
0
cmd_window_move(const char *data, SERVER_REC *server, WI_ITEM_REC *item) { if (!is_numeric(data, 0)) { command_runsub("window move", data, server, item); return; } active_window_move_to(atoi(data)); }
false
false
false
false
true
1
af9005_rc_query(struct dvb_usb_device *d, u32 * event, int *state) { struct af9005_device_state *st = d->priv; int ret, len; u8 obuf[5]; u8 ibuf[256]; *state = REMOTE_NO_KEY_PRESSED; if (rc_decode == NULL) { /* it shouldn't never come here */ return 0; } /* deb_info("rc_query\n"); */ obuf[0] = 3; /* rest of packet length low */ obuf[1] = 0; /* rest of packet lentgh high */ obuf[2] = 0x40; /* read remote */ obuf[3] = 1; /* rest of packet length */ obuf[4] = st->sequence++; /* sequence number */ ret = dvb_usb_generic_rw(d, obuf, 5, ibuf, 256, 0); if (ret) { err("rc query failed"); return ret; } if (ibuf[2] != 0x41) { err("rc query bad header."); return -EIO; } if (ibuf[4] != obuf[4]) { err("rc query bad sequence."); return -EIO; } len = ibuf[5]; if (len > 246) { err("rc query invalid length"); return -EIO; } if (len > 0) { deb_rc("rc data (%d) ", len); debug_dump((ibuf + 6), len, deb_rc); ret = rc_decode(d, &ibuf[6], len, event, state); if (ret) { err("rc_decode failed"); return ret; } else { deb_rc("rc_decode state %x event %x\n", *state, *event); if (*state == REMOTE_KEY_REPEAT) *event = d->last_event; } } return 0; }
false
false
false
false
false
0
grep_config(const char *var, const char *value, void *cb) { struct grep_opt *opt = cb; char *color = NULL; switch (userdiff_config(var, value)) { case 0: break; case -1: return -1; default: return 0; } if (!strcmp(var, "grep.extendedregexp")) { if (git_config_bool(var, value)) opt->regflags |= REG_EXTENDED; else opt->regflags &= ~REG_EXTENDED; return 0; } if (!strcmp(var, "grep.linenumber")) { opt->linenum = git_config_bool(var, value); return 0; } if (!strcmp(var, "color.grep")) opt->color = git_config_colorbool(var, value, -1); else if (!strcmp(var, "color.grep.context")) color = opt->color_context; else if (!strcmp(var, "color.grep.filename")) color = opt->color_filename; else if (!strcmp(var, "color.grep.function")) color = opt->color_function; else if (!strcmp(var, "color.grep.linenumber")) color = opt->color_lineno; else if (!strcmp(var, "color.grep.match")) color = opt->color_match; else if (!strcmp(var, "color.grep.selected")) color = opt->color_selected; else if (!strcmp(var, "color.grep.separator")) color = opt->color_sep; else return git_color_default_config(var, value, cb); if (color) { if (!value) return config_error_nonbool(var); color_parse(value, var, color); } return 0; }
false
false
false
false
false
0
setupHeuristics(CbcModel & model) { // Allow rounding heuristic CbcRounding heuristic1(model); heuristic1.setHeuristicName("rounding"); int numberHeuristics = model.numberHeuristics(); int iHeuristic; bool found; found = false; for (iHeuristic = 0; iHeuristic < numberHeuristics; iHeuristic++) { CbcHeuristic * heuristic = model.heuristic(iHeuristic); CbcRounding * cgl = dynamic_cast<CbcRounding *>(heuristic); if (cgl) { found = true; break; } } if (!found) model.addHeuristic(&heuristic1); if ((model.moreSpecialOptions()&32768)!=0) { // Allow join solutions CbcHeuristicLocal heuristic2(model); heuristic2.setHeuristicName("join solutions"); //sheuristic2.setSearchType(1); found = false; for (iHeuristic = 0; iHeuristic < numberHeuristics; iHeuristic++) { CbcHeuristic * heuristic = model.heuristic(iHeuristic); CbcHeuristicLocal * cgl = dynamic_cast<CbcHeuristicLocal *>(heuristic); if (cgl) { found = true; break; } } if (!found) model.addHeuristic(&heuristic2); // Allow RINS CbcHeuristicRINS heuristic5(model); heuristic5.setHeuristicName("RINS"); heuristic5.setFractionSmall(0.5); heuristic5.setDecayFactor(5.0); //heuristic5.setSearchType(1); found = false; for (iHeuristic = 0; iHeuristic < numberHeuristics; iHeuristic++) { CbcHeuristic * heuristic = model.heuristic(iHeuristic); CbcHeuristicLocal * cgl = dynamic_cast<CbcHeuristicLocal *>(heuristic); if (cgl) { found = true; break; } } if (!found) model.addHeuristic(&heuristic5); } }
false
false
false
false
false
0
uniform () { /* Component 1 */ double p1 = a12 * Cg[1] - a13n * Cg[0]; int k = p1 / m1; p1 -= k * m1; if (p1 < 0.0) p1 += m1; Cg[0] = Cg[1]; Cg[1] = Cg[2]; Cg[2] = p1; /* Component 2 */ double p2 = a21 * Cg[5] - a23n * Cg[3]; k = p2 / m2; p2 -= k * m2; if (p2 < 0.0) p2 += m2; Cg[3] = Cg[4]; Cg[4] = Cg[5]; Cg[5] = p2; /* Combination */ return ((p1 > p2) ? (p1 - p2) * norm : (p1 - p2 + m1) * norm); }
false
false
false
false
false
0
showredcdata(void) { REDC_CACHE *rcp; long i; for (i = 0, rcp = redc_cache; i < MAXREDC; i++, rcp++) { if (rcp->age > 0) { printf("%-8ld%-8ld", i, rcp->age); qprintnum(rcp->rnum, 0); printf("\n"); } } }
false
false
false
false
false
0
handle_eth_ud_smac_index(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp, struct mlx4_qp_context *context) { u64 u64_mac; int smac_index; u64_mac = atomic64_read(&dev->iboe.mac[qp->port - 1]); context->pri_path.sched_queue = MLX4_IB_DEFAULT_SCHED_QUEUE | ((qp->port - 1) << 6); if (!qp->pri.smac && !qp->pri.smac_port) { smac_index = mlx4_register_mac(dev->dev, qp->port, u64_mac); if (smac_index >= 0) { qp->pri.candidate_smac_index = smac_index; qp->pri.candidate_smac = u64_mac; qp->pri.candidate_smac_port = qp->port; context->pri_path.grh_mylmc = 0x80 | (u8) smac_index; } else { return -ENOENT; } } return 0; }
false
false
false
false
false
0
rt73usb_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct rt2x00_dev *rt2x00dev = hw->priv; u64 tsf; u32 reg; rt2x00usb_register_read(rt2x00dev, TXRX_CSR13, &reg); tsf = (u64) rt2x00_get_field32(reg, TXRX_CSR13_HIGH_TSFTIMER) << 32; rt2x00usb_register_read(rt2x00dev, TXRX_CSR12, &reg); tsf |= rt2x00_get_field32(reg, TXRX_CSR12_LOW_TSFTIMER); return tsf; }
false
false
false
false
false
0
NITFUncompressVQTile( NITFImage *psImage, GByte *pabyVQBuf, GByte *pabyResult ) { int i, j, t, iSrcByte = 0; for (i = 0; i < 256; i += 4) { for (j = 0; j < 256; j += 8) { GUInt16 firstByte = pabyVQBuf[iSrcByte++]; GUInt16 secondByte = pabyVQBuf[iSrcByte++]; GUInt16 thirdByte = pabyVQBuf[iSrcByte++]; /* * because dealing with half-bytes is hard, we * uncompress two 4x4 tiles at the same time. (a * 4x4 tile compressed is 12 bits ) * this little code was grabbed from openmap software. */ /* Get first 12-bit value as index into VQ table */ GUInt16 val1 = (firstByte << 4) | (secondByte >> 4); /* Get second 12-bit value as index into VQ table*/ GUInt16 val2 = ((secondByte & 0x000F) << 8) | thirdByte; for ( t = 0; t < 4; ++t) { GByte *pabyTarget = pabyResult + (i+t) * 256 + j; memcpy( pabyTarget, psImage->apanVQLUT[t] + val1, 4 ); memcpy( pabyTarget+4, psImage->apanVQLUT[t] + val2, 4); } } /* for j */ } /* for i */ }
false
true
false
false
false
1
AddInstancePropertyAccessor( v8::Handle<String> name, AccessorGetter getter, AccessorSetter setter, v8::Handle<Value> data, v8::AccessControl settings, v8::PropertyAttribute attributes) { if (IsDeadCheck("v8::FunctionTemplate::AddInstancePropertyAccessor()")) { return; } ENTER_V8; HandleScope scope; i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, getter, setter, data, settings, attributes); i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors()); if (list->IsUndefined()) { list = NeanderArray().value(); Utils::OpenHandle(this)->set_property_accessors(*list); } NeanderArray array(list); array.add(obj); }
false
false
false
false
false
0
check_request(struct dundi_request *dr) { struct dundi_request *cur; AST_LIST_LOCK(&peers); AST_LIST_TRAVERSE(&requests, cur, list) { if (cur == dr) break; } AST_LIST_UNLOCK(&peers); return cur ? 1 : 0; }
true
true
false
false
false
1
v4lconvert_vflip_yuv420(unsigned char *src, unsigned char *dest, struct v4l2_format *fmt) { int y; /* First flip the Y plane */ src += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline; for (y = 0; y < fmt->fmt.pix.height; y++) { src -= fmt->fmt.pix.bytesperline; memcpy(dest, src, fmt->fmt.pix.width); dest += fmt->fmt.pix.width; } /* Now flip the U plane */ src += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline * 5 / 4; for (y = 0; y < fmt->fmt.pix.height / 2; y++) { src -= fmt->fmt.pix.bytesperline / 2; memcpy(dest, src, fmt->fmt.pix.width / 2); dest += fmt->fmt.pix.width / 2; } /* Last flip the V plane */ src += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline / 2; for (y = 0; y < fmt->fmt.pix.height / 2; y++) { src -= fmt->fmt.pix.bytesperline / 2; memcpy(dest, src, fmt->fmt.pix.width / 2); dest += fmt->fmt.pix.width / 2; } }
false
false
false
false
false
0
unbind_ports(void) { SERVICE_OPTIONS *opt; #ifdef HAVE_STRUCT_SOCKADDR_UN struct stat st; /* buffer for stat */ #endif s_poll_init(fds); s_poll_add(fds, signal_pipe[0], 1, 0); for(opt=service_options.next; opt; opt=opt->next) { s_log(LOG_DEBUG, "Closing service [%s]", opt->servname); if(opt->option.accept && opt->fd>=0) { closesocket(opt->fd); s_log(LOG_DEBUG, "Service [%s] closed (FD=%d)", opt->servname, opt->fd); opt->fd=-1; #ifdef HAVE_STRUCT_SOCKADDR_UN if(opt->local_addr.sa.sa_family==AF_UNIX) { if(lstat(opt->local_addr.un.sun_path, &st)) sockerror(opt->local_addr.un.sun_path); else if(!S_ISSOCK(st.st_mode)) s_log(LOG_ERR, "Not a socket: %s", opt->local_addr.un.sun_path); else if(unlink(opt->local_addr.un.sun_path)) sockerror(opt->local_addr.un.sun_path); else s_log(LOG_DEBUG, "Socket removed: %s", opt->local_addr.un.sun_path); } #endif } else if(opt->option.program && opt->option.remote) { /* create exec+connect services */ /* FIXME: this is just a crude workaround */ /* is it better to kill the service? */ opt->option.retry=0; } if(opt->ctx) { s_log(LOG_DEBUG, "Sessions cached before flush: %ld", SSL_CTX_sess_number(opt->ctx)); SSL_CTX_flush_sessions(opt->ctx, (long)time(NULL)+opt->session_timeout+1); s_log(LOG_DEBUG, "Sessions cached after flush: %ld", SSL_CTX_sess_number(opt->ctx)); } s_log(LOG_DEBUG, "Service [%s] closed", opt->servname); } }
false
false
false
false
false
0
e1000_run_loopback_test(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct e1000_tx_ring *txdr = &adapter->test_tx_ring; struct e1000_rx_ring *rxdr = &adapter->test_rx_ring; struct pci_dev *pdev = adapter->pdev; int i, j, k, l, lc, good_cnt, ret_val = 0; unsigned long time; ew32(RDT, rxdr->count - 1); /* Calculate the loop count based on the largest descriptor ring * The idea is to wrap the largest ring a number of times using 64 * send/receive pairs during each loop */ if (rxdr->count <= txdr->count) lc = ((txdr->count / 64) * 2) + 1; else lc = ((rxdr->count / 64) * 2) + 1; k = l = 0; for (j = 0; j <= lc; j++) { /* loop count loop */ for (i = 0; i < 64; i++) { /* send the packets */ e1000_create_lbtest_frame(txdr->buffer_info[i].skb, 1024); dma_sync_single_for_device(&pdev->dev, txdr->buffer_info[k].dma, txdr->buffer_info[k].length, DMA_TO_DEVICE); if (unlikely(++k == txdr->count)) k = 0; } ew32(TDT, k); E1000_WRITE_FLUSH(); msleep(200); time = jiffies; /* set the start time for the receive */ good_cnt = 0; do { /* receive the sent packets */ dma_sync_single_for_cpu(&pdev->dev, rxdr->buffer_info[l].dma, E1000_RXBUFFER_2048, DMA_FROM_DEVICE); ret_val = e1000_check_lbtest_frame( rxdr->buffer_info[l].rxbuf.data + NET_SKB_PAD + NET_IP_ALIGN, 1024); if (!ret_val) good_cnt++; if (unlikely(++l == rxdr->count)) l = 0; /* time + 20 msecs (200 msecs on 2.4) is more than * enough time to complete the receives, if it's * exceeded, break and error off */ } while (good_cnt < 64 && time_after(time + 20, jiffies)); if (good_cnt != 64) { ret_val = 13; /* ret_val is the same as mis-compare */ break; } if (time_after_eq(jiffies, time + 2)) { ret_val = 14; /* error code for time out error */ break; } } /* end loop count loop */ return ret_val; }
false
false
false
false
false
0
get_block_list_match_tlg_and_dlg_tag(Block *block_head, const int tlg_tag, const int dlg_tag) { Block *bpt; List *head = NULL; for (bpt = block_head; bpt != NULL; bpt = bpt->next) { if (block_match_tlg_and_dlg_tag(bpt, tlg_tag, dlg_tag)) { head = list_append(head, bpt); } } return head; }
false
false
false
false
false
0
ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const { // FIXME: Does .section .bss/.data/.text work everywhere?? if (Name == ".text" || Name == ".data" || (Name == ".bss" && !MAI.usesELFSectionDirectiveForBSS())) return true; return false; }
false
false
false
false
false
0
sinfo_pro_save_ims( cpl_imagelist * ims, cpl_frameset * ref, cpl_frameset * set, const char * out_file, const char * pro_catg, cpl_table * qclog, const char * recid, cpl_parameterlist* parlist) { char * name_o=NULL; char * name_p=NULL; cpl_propertylist * plist=NULL ; cpl_frame* first_frame=NULL; char* ref_file=NULL; /* Get the reference file */ first_frame = cpl_frameset_get_first(ref) ; ref_file = cpl_strdup(cpl_frame_get_filename(first_frame)) ; name_o = cpl_malloc(FILE_NAME_SZ * sizeof(char)); name_p = cpl_malloc(FILE_NAME_SZ * sizeof(char)); sinfo_check_name(out_file, &name_o, CPL_FRAME_TYPE_IMAGE, &name_p); sinfo_msg( "Writing ims %s pro catg %s" , name_o, pro_catg) ; /* Get FITS header from reference file */ if ((cpl_error_code)((plist = cpl_propertylist_load(ref_file, 0)) == NULL)) { sinfo_msg_error( "getting header from ims frame %s",ref_file); cpl_propertylist_delete(plist) ; cpl_free(ref_file); cpl_free(name_o); cpl_free(name_p); return -1 ; } sinfo_clean_header(&plist); if ( ( strstr(pro_catg,"STD") != NULL ) || ( strstr(pro_catg,"PSF") != NULL ) || ( strstr(pro_catg,"OBJ") != NULL ) ) { sinfo_clean_cube_header(&plist); } /* Add DataFlow keywords and log the saved file in the input frameset */ sinfo_log_pro(name_o, pro_catg, CPL_FRAME_TYPE_IMAGE, ref,&set,&plist,parlist,recid); if(qclog != NULL) { sinfo_pfits_put_qc(plist, qclog) ; } /* Save the file */ if (cpl_imagelist_save(ims, name_o, CPL_BPP_IEEE_FLOAT, plist,CPL_IO_DEFAULT)!=CPL_ERROR_NONE) { sinfo_msg_error( "Cannot save the product %s",name_o); cpl_propertylist_delete(plist) ; cpl_free(ref_file); cpl_free(name_o); cpl_free(name_p); return -1 ; } /* THE PAF FILE FOR QC PARAMETERS if (qclog != NULL) { sinfo_save_paf(name_p,recid,qclog,plist,pro_catg); } */ cpl_propertylist_delete(plist) ; cpl_msg_indent_less() ; cpl_free(name_o); cpl_free(name_p); cpl_free(ref_file); return 0 ; }
false
false
false
false
false
0
parse_switch(int fd, char *line) { Node *nd; Switch *sw; Port *port; char *nodeid; char *nodedesc; int nports, r, esp0 = 0; if (!(nports = parse_node_ports(line + 6)) || !(nodeid = parse_node_id(line, &line))) return 0; nodedesc = parse_node_desc(line, &line); if (!(nd = new_node(SWITCH_NODE, nodeid, nodedesc, nports))) return 0; if (line) esp0 = parse_switch_esp0(line); if (!(sw = new_switch(nd, esp0))) return 0; nd->sw = sw; r = parse_ports(fd, nd, SWITCH_NODE, nports); port = node_get_port(nd, 0); if (line && parse_port_lid_and_lmc(port, line) < 0) { IBWARN("cannot parse switch lid, lmc"); return -1; } // return number of lines + 1 for the header line PDEBUG("%d ports found", r); if (r >= 0) return r + 1; return r - 1; }
false
false
false
false
false
0
key_addition_8to32(const UINT8 *txt, UINT32 *keys, UINT32 *out) { const UINT8 *ptr; int i, j; UINT32 val; ptr = txt; for (i=0; i<4; i++) { val = 0; for (j=0; j<4; j++) val |= (*ptr++ << 8*j); out[i] = keys[i]^val; } }
false
false
false
false
false
0
draw_sprites(struct mame_bitmap *bitmap,const struct rectangle *cliprect) { int offs; for (offs = 0;offs < spriteram_size/2;offs += 4) { int sx,sy,code,color,flipx,flipy,height,y; sx = spriteram16[offs + 2]; sy = spriteram16[offs + 0]; code = spriteram16[offs + 1]; color = spriteram16[offs + 2] >> 9; height = 1 << ((spriteram16[offs + 0] & 0x0600) >> 9); flipx = spriteram16[offs + 0] & 0x2000; flipy = spriteram16[offs + 0] & 0x4000; for (y = 0;y < height;y++) { drawgfx(bitmap,Machine->gfx[1], code + (flipy ? height-1 - y : y), color, flipx,flipy, 0x140-5 - ((sx + 0x10) & 0x1ff),0x100+1 - ((sy + 0x10 * (height - y)) & 0x1ff), cliprect,TRANSPARENCY_PEN,0); } } }
false
false
false
false
false
0
gwy_si_unit_clone_real(GObject *source, GObject *copy) { GwySIUnit *si_unit, *clone; g_return_if_fail(GWY_IS_SI_UNIT(source)); g_return_if_fail(GWY_IS_SI_UNIT(copy)); si_unit = GWY_SI_UNIT(source); clone = GWY_SI_UNIT(copy); if (gwy_si_unit_equal(si_unit, clone)) return; g_array_set_size(clone->units, 0); g_array_append_vals(clone->units, si_unit->units->data, si_unit->units->len); clone->power10 = si_unit->power10; g_signal_emit(copy, si_unit_signals[VALUE_CHANGED], 0); }
false
false
false
false
false
0
gridDefMask(int gridID, const int *mask) { long size, i; grid_t *gridptr; if ( reshGetStatus ( gridID, &gridOps ) == CLOSED ) { xwarning("%s", "Operation not executed."); return; } gridptr = ( grid_t *) reshGetVal ( gridID, &gridOps ); size = gridptr->size; if ( size == 0 ) Error("Size undefined for gridID = %d", gridID); if ( mask == NULL ) { if ( gridptr->mask ) { free(gridptr->mask); gridptr->mask = NULL; } } else { if ( gridptr->mask == NULL ) gridptr->mask = (mask_t *) malloc(size*sizeof(mask_t)); else if ( CDI_Debug ) Warning("grid mask already defined!"); for ( i = 0; i < size; ++i ) gridptr->mask[i] = mask[i]; } }
false
false
false
false
false
0
showMultiMap(const MultiMap& mm) { for (MultiMap::const_iterator i = mm.begin(); i != mm.end(); ++i) { cout << (*i).first << "==" << (*i).second << "|" << endl; } }
false
false
false
false
false
0
_cdk_stream_get_opaque (cdk_stream_t s, int fid) { struct stream_filter_s *f; if (!s) return NULL; for (f = s->filters; f; f = f->next) { if ((int) f->type == fid) return f->opaque; } return NULL; }
false
false
false
false
false
0
Restore() { assert("pre: context_is_set" && this->Context!=0); assert("pre: current_context_matches" && this->Context->IsCurrent()); if(this->DisplayListUnderCreationInCompileMode()) { vtkgl::UseProgram(0); this->SavedId=0; } else { GLint value; glGetIntegerv(vtkgl::CURRENT_PROGRAM,&value); if(static_cast<GLuint>(value)==static_cast<GLuint>(this->Id)) { vtkgl::UseProgram(static_cast<GLuint>(this->SavedId)); this->SavedId=0; } else { vtkWarningMacro(<<"cannot restore because the program in use (id=" << value << ") is not the id of the vtkShaderProgram2 object (id=" << this->Id << ")."); } } }
false
false
false
false
false
0
ccss_selector_get_importance (ccss_selector_t const *self) { g_assert (self); return self->importance; }
false
false
false
false
false
0
update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr) { int i, rc=0; Elf64_Phdr *phdr_ptr; Elf64_Nhdr *nhdr_ptr; phdr_ptr = (Elf64_Phdr *)(ehdr_ptr + 1); for (i = 0; i < ehdr_ptr->e_phnum; i++, phdr_ptr++) { void *notes_section; u64 offset, max_sz, sz, real_sz = 0; if (phdr_ptr->p_type != PT_NOTE) continue; max_sz = phdr_ptr->p_memsz; offset = phdr_ptr->p_offset; notes_section = kmalloc(max_sz, GFP_KERNEL); if (!notes_section) return -ENOMEM; rc = elfcorehdr_read_notes(notes_section, max_sz, &offset); if (rc < 0) { kfree(notes_section); return rc; } nhdr_ptr = notes_section; while (nhdr_ptr->n_namesz != 0) { sz = sizeof(Elf64_Nhdr) + (((u64)nhdr_ptr->n_namesz + 3) & ~3) + (((u64)nhdr_ptr->n_descsz + 3) & ~3); if ((real_sz + sz) > max_sz) { pr_warn("Warning: Exceeded p_memsz, dropping PT_NOTE entry n_namesz=0x%x, n_descsz=0x%x\n", nhdr_ptr->n_namesz, nhdr_ptr->n_descsz); break; } real_sz += sz; nhdr_ptr = (Elf64_Nhdr*)((char*)nhdr_ptr + sz); } kfree(notes_section); phdr_ptr->p_memsz = real_sz; if (real_sz == 0) { pr_warn("Warning: Zero PT_NOTE entries found\n"); } } return 0; }
false
false
false
false
false
0