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 |
|---|---|---|---|---|---|---|
start_rule(bp, s_lineno)
register bucket *bp;
int s_lineno;
{
if (bp->class == TERM)
terminal_lhs(s_lineno);
bp->class = NONTERM;
if (nrules >= maxrules)
expand_rules();
plhs[nrules] = bp;
rprec[nrules] = UNDEFINED;
rassoc[nrules] = TOKEN;
} | false | false | false | false | false | 0 |
centre(Coordinate& centre) const
{
if (isNull()) return false;
centre.x=(getMinX() + getMaxX()) / 2.0;
centre.y=(getMinY() + getMaxY()) / 2.0;
return true;
} | false | false | false | false | false | 0 |
egg_column_model_is_column_first (EggColumnModel *model, GtkTreeIter *iter)
{
g_return_val_if_fail (model->stamp == iter->stamp, FALSE);
return (((GList *)iter->user_data)->prev == NULL);
} | false | false | false | false | false | 0 |
writememoryarea (int fd, Area *area, int stack_was_seen,
int vsyscall_exists)
{
static void * orig_stack = NULL;
/* Write corresponding descriptor to the file */
if (orig_stack == NULL && 0 == strcmp(area -> name, "[stack]"))
orig_stack = area -> addr + area -> size;
if (0 == strcmp(area -> name, "[vdso]") && !stack_was_seen)
DPRINTF("skipping over [vdso] section"
" %p at %p\n", area -> size, area -> addr);
else if (0 == strcmp(area -> name, "[vsyscall]") && !stack_was_seen)
DPRINTF("skipping over [vsyscall] section"
" %p at %p\n", area -> size, area -> addr);
else if (0 == strcmp(area -> name, "[stack]") &&
orig_stack != area -> addr + area -> size)
/* Kernel won't let us munmap this. But we don't need to restore it. */
DPRINTF("skipping over [stack] segment"
" %X at %pi (not the orig stack)\n", area -> size, area -> addr);
else if (!(area -> flags & MAP_ANONYMOUS))
DPRINTF("save %p at %p from %s + %X\n",
area -> size, area -> addr, area -> name, area -> offset);
else if (area -> name[0] == '\0')
DPRINTF("save anonymous %p at %p\n", area -> size, area -> addr);
else DPRINTF("save anonymous %p at %p from %s + %X\n",
area -> size, area -> addr, area -> name, area -> offset);
if ((area -> name[0]) == '\0') {
char *brk = mtcp_sys_brk(NULL);
if (brk > area -> addr && brk <= area -> addr + area -> size)
mtcp_sys_strcpy(area -> name, "[heap]");
}
if (area->prot == 0 ||
(area->name[0] == '\0' &&
((area->flags & MAP_ANONYMOUS) != 0) &&
((area->flags & MAP_PRIVATE) != 0))) {
/* Detect zero pages and do not write them to ckpt image.
* Currently, we detect zero pages in non-rwx mapping and anonymous
* mappings only
*/
mtcp_write_non_rwx_pages(fd, area);
} else if ( 0 != strcmp(area -> name, "[vsyscall]")
&& ( (0 != strcmp(area -> name, "[vdso]")
|| vsyscall_exists /* which implies vdso can be overwritten */
|| !stack_was_seen ))) /* If vdso appeared before stack, it can be
replaced */
{
#ifndef FAST_CKPT_RST_VIA_MMAP
mtcp_writecs (fd, CS_AREADESCRIP);
mtcp_writefile (fd, area, sizeof *area);
#endif
/* Anonymous sections need to have their data copied to the file,
* as there is no file that contains their data
* We also save shared files to checkpoint file to handle shared memory
* implemented with backing files
*/
if (area -> flags & MAP_ANONYMOUS || area -> flags & MAP_SHARED) {
#ifdef FAST_CKPT_RST_VIA_MMAP
fastckpt_write_mem_region(fd, area);
#else
mtcp_writecs (fd, CS_AREACONTENTS);
mtcp_writefile (fd, area -> addr, area -> size);
#endif
} else {
MTCP_PRINTF("UnImplemented");
mtcp_abort();
}
}
} | false | false | false | false | false | 0 |
FuncIO_readdir(Obj self)
{
Obj res;
Int olderrno;
if (ourDIR == 0) {
SyClearErrorNo();
return Fail;
}
olderrno = errno;
ourdirent = readdir(ourDIR);
if (ourdirent == 0) {
/* This is a bit of a hack, but how should this be done? */
if (errno == EBADF && olderrno != EBADF) {
SySetErrorNo();
return Fail;
} else {
SyClearErrorNo();
return False;
}
}
C_NEW_STRING(res,strlen(ourdirent->d_name),ourdirent->d_name);
return res;
} | false | false | false | false | false | 0 |
aisleriot_conf_get_statistic (const char *game_module,
AisleriotStatistic *statistic)
{
#ifdef HAVE_GNOME
AisleriotStatistic *game_stat;
char *game_name;
game_name = game_module_to_game_name (game_module);
game_stat = g_hash_table_lookup (stats, game_name);
if (!game_stat) {
char *display_name;
/* Previous versions used the localised name as key, so try it as fall-back.
* See bug #406267 and bug #525177.
*/
display_name = ar_filename_to_display_name (game_module);
game_stat = g_hash_table_lookup (stats, display_name);
g_free (display_name);
}
if (game_stat) {
*statistic = *game_stat;
} else {
memset (statistic, 0, sizeof (AisleriotStatistic));
}
g_free (game_name);
#else
int *values;
gsize len = 0;
GError *error = NULL;
char *game_name;
game_name = game_module_to_game_name (game_module);
memset (statistic, 0, sizeof (AisleriotStatistic));
values = ar_conf_get_integer_list (game_name, "Statistic", &len, &error);
if (error) {
g_error_free (error);
g_free (game_name);
return;
}
if (len != 4) {
g_free (values);
g_free (game_name);
return;
}
statistic->wins = values[0];
statistic->total = values[1];
/* Sanitise values to fix statistics from bug #474615 */
if (values[2] > 0 && values[2] <= 6000) {
statistic->best = values[2];
} else {
statistic->best = 0;
}
if (values[3] > 0 && values[3] <= 6000) {
statistic->worst = values[3];
} else {
statistic->worst = 0;
}
g_free (values);
g_free (game_name);
#endif /* HAVE_GNOME */
} | false | false | false | false | false | 0 |
do_fiddle_smime_message(BODY *b, long msgno, char *section)
{
int modified_the_body = 0;
if(!b)
return 0;
dprint((9, "do_fiddle_smime_message(msgno=%ld type=%d subtype=%s section=%s)", msgno, b->type, b->subtype ? b->subtype : "NULL", (section && *section) ? section : (section != NULL) ? "Top" : "NULL"));
if(is_pkcs7_body(b)){
if(do_decoding(b, msgno, section)){
/*
* b should now be a multipart message:
* fiddle it too in case it's been multiply-encrypted!
*/
/* fallthru */
modified_the_body = 1;
}
}
if(b->type==TYPEMULTIPART || MIME_MSG(b->type, b->subtype)){
PART *p;
int partNum;
char newSec[100];
if(MIME_MULT_SIGNED(b->type, b->subtype)){
/*
* Ahah. We have a multipart signed entity.
*
* Multipart/signed
* part 1 (signed thing)
* part 2 (the pkcs7 signature)
*
* We're going to convert that to
*
* Multipart/OUR_PKCS7_ENCLOSURE_SUBTYPE
* part 1 (signed thing)
* part 2 has been freed
*
* We also extract the signature from part 2 and save it
* in the multipart body->sparep, and we add a description
* in the multipart body->description.
*
*
* The results of a decrypted message will be similar. It
* will be
*
* Multipart/OUR_PKCS7_ENCLOSURE_SUBTYPE
* part 1 (decrypted thing)
*/
modified_the_body += do_detached_signature_verify(b, msgno, section);
}
else if(MIME_MSG(b->type, b->subtype)){
modified_the_body += do_fiddle_smime_message(b->nested.msg->body, msgno, section);
}
else{
for(p=b->nested.part,partNum=1; p; p=p->next,partNum++){
/* Append part number to the section string */
snprintf(newSec, sizeof(newSec), "%s%s%d", section, *section ? "." : "", partNum);
modified_the_body += do_fiddle_smime_message(&p->body, msgno, newSec);
}
}
}
return modified_the_body;
} | true | true | false | false | false | 1 |
guess_init(void)
{
dbstore_kv_t kv = { sizeof(gnet_host_t), gnet_host_length,
sizeof(struct qkdata),
sizeof(struct qkdata) + sizeof(uint8) + MAX_INT_VAL(uint8) };
dbstore_packing_t packing =
{ serialize_qkdata, deserialize_qkdata, free_qkdata };
if (!GNET_PROPERTY(enable_guess))
return;
if (db_qkdata != NULL)
return; /* GUESS layer already initialized */
g_assert(NULL == guess_qk_prune_ev);
db_qkdata = dbstore_open(db_qkdata_what, settings_gnet_db_dir(),
db_qkdata_base, kv, packing, GUESS_QK_DB_CACHE_SIZE,
gnet_host_hash, gnet_host_eq, FALSE);
dbmw_set_map_cache(db_qkdata, GUESS_QK_MAP_CACHE_SIZE);
guess_02_cache.hs =
hset_create_any(gnet_host_hash, gnet_host_hash2, gnet_host_eq);
guess_qk_prune_old();
guess_qk_prune_ev = cq_periodic_main_add(
GUESS_QK_PRUNE_PERIOD, guess_qk_periodic_prune, NULL);
guess_check_ev = cq_periodic_main_add(
GUESS_CHECK_PERIOD, guess_periodic_check, NULL);
guess_sync_ev = cq_periodic_main_add(
GUESS_SYNC_PERIOD, guess_periodic_sync, NULL);
guess_load_ev = cq_periodic_main_add(
GUESS_DBLOAD_PERIOD, guess_periodic_load, NULL);
guess_bw_ev = cq_periodic_main_add(1000, guess_periodic_bw, NULL);
gqueries = hevset_create_any(
offsetof(guess_t, gid), nid_hash, nid_hash2, nid_equal);
gmuid = hikset_create(
offsetof(guess_t, muid), HASH_KEY_FIXED, GUID_RAW_SIZE);
link_cache = hash_list_new(gnet_host_hash, gnet_host_eq);
alive_cache = hash_list_new(gnet_host_hash, gnet_host_eq);
load_pending = hash_list_new(pointer_hash, NULL);
pending = htable_create_any(guess_rpc_key_hash, NULL, guess_rpc_key_eq);
guess_qk_reqs = aging_make(GUESS_QK_FREQ,
gnet_host_hash, gnet_host_eq, gnet_host_free_atom2);
guess_alien = aging_make(GUESS_ALIEN_FREQ,
gnet_host_hash, gnet_host_eq, gnet_host_free_atom2);
guess_load_link_cache();
guess_check_link_cache();
} | false | false | false | false | false | 0 |
agp_alloc_bridge(void)
{
struct agp_bridge_data *bridge;
bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
if (!bridge)
return NULL;
atomic_set(&bridge->agp_in_use, 0);
atomic_set(&bridge->current_memory_agp, 0);
if (list_empty(&agp_bridges))
agp_bridge = bridge;
return bridge;
} | false | false | false | false | false | 0 |
isl_args_free(struct isl_args *args, void *opt)
{
if (!opt)
return;
free_args(args->args, opt);
free(opt);
} | false | false | false | false | false | 0 |
free_krb5_pa_pk_as_rep(krb5_pa_pk_as_rep **in)
{
if (*in == NULL) return;
switch ((*in)->choice) {
case choice_pa_pk_as_rep_dhInfo:
krb5_free_data(NULL, (*in)->u.dh_Info.kdfID);
free((*in)->u.dh_Info.dhSignedData.data);
break;
case choice_pa_pk_as_rep_encKeyPack:
free((*in)->u.encKeyPack.data);
break;
default:
break;
}
free(*in);
} | false | false | false | false | false | 0 |
operator=(const FieldElement& a)
{
if(this==&a)
{
flog2 fprintf(Stderr,"FieldElement - selfassignment\n");
return *this;
}
if(implementingObject&& 0==(--(implementingObject->refCount)))
{
delete implementingObject;
// fprintf(Stderr,"DELETE\n");
flog2 fprintf(Stderr,"FieldElement - deleting old implementing\n");
}
//assert(a.implementingObject);
if(a.implementingObject)
{
implementingObject=a.implementingObject;
implementingObject->refCount++;
}
else
{
implementingObject=0;
}
flog2 fprintf(Stderr,"FieldElement - assignment\n");
return *this;
} | false | false | false | false | false | 0 |
putspriteimage ( int x1, int y1, void* pic )
{
char* src = (char*) pic;
if ( agmp->windowstatus == 100 ) {
trleheader* hd = (trleheader*) pic;
char* buf = (char*) (agmp->scanlinelength * y1 + x1 * agmp->byteperpix + agmp->linearaddress);
if ( hd->id == 16973 ) {
collategraphicoperations cgo ( x1, y1, x1+hd->x, y1+hd->y );
int spacelength = agmp->scanlinelength - hd->x - 1;
src += sizeof ( *hd );
int x = 0;
for ( int c = 0; c < hd->size; c++ ) {
if ( *src == hd->rle ) {
x += src[1];
if ( src[2] != 255 ) {
for ( int i = src[1]; i > 0; i-- )
*(buf++) = src[2];
} else
buf += src[1];
src += 3;
c+=2;
} else {
if ( *src != 255 )
*buf = *src;
buf++;
src++;
x++;
}
if ( x > hd->x ) {
buf += spacelength;
x = 0;
}
}
} else {
Uint16* w = (Uint16*) pic;
collategraphicoperations cgo ( x1, y1, x1+w[0], y1+w[1] );
int spacelength = agmp->scanlinelength - *w - 1;
src += 4;
for ( int y = w[1] + 1; y > 0; y-- ) {
for ( int x = w[0]+1; x > 0; x-- ) {
char d = *(src++);
if ( d != 255 )
*buf = d;
buf++;
}
buf+=spacelength;
}
}
}
} | false | false | false | false | false | 0 |
rq_completed(struct mapped_device *md, int rw, bool run_queue)
{
atomic_dec(&md->pending[rw]);
/* nudge anyone waiting on suspend queue */
if (!md_in_flight(md))
wake_up(&md->wait);
/*
* Run this off this callpath, as drivers could invoke end_io while
* inside their request_fn (and holding the queue lock). Calling
* back into ->request_fn() could deadlock attempting to grab the
* queue lock again.
*/
if (!md->queue->mq_ops && run_queue)
blk_run_queue_async(md->queue);
/*
* dm_put() must be at the end of this function. See the comment above
*/
dm_put(md);
} | false | false | false | false | false | 0 |
sdsull2str(char *s, unsigned long long v) {
char *p, aux;
size_t l;
/* Generate the string representation, this method produces
* an reversed string. */
p = s;
do {
*p++ = '0'+(v%10);
v /= 10;
} while(v);
/* Compute length and add null term. */
l = p-s;
*p = '\0';
/* Reverse the string. */
p--;
while(s < p) {
aux = *s;
*s = *p;
*p = aux;
s++;
p--;
}
return l;
} | false | false | false | false | false | 0 |
free_rstorage(JCR *jcr)
{
if (jcr->rstorage) {
delete jcr->rstorage;
jcr->rstorage = NULL;
}
jcr->rstore = NULL;
} | false | false | false | false | false | 0 |
writeIndent(int depth) const
{
for (int i = 0; i < depth; ++i)
writeMarkup(_indent);
} | false | false | false | false | false | 0 |
server_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
gf_common_rsp rsp = {0,};
rpcsvc_request_t *req = NULL;
server_state_t *state = NULL;
req = frame->local;
state = CALL_STATE(frame);
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
if (op_ret == -1)
gf_log (this->name, GF_LOG_INFO,
"%"PRId64": SETXATTR %s (%s) ==> %"PRId32" (%s)",
frame->root->unique, state->loc.path,
state->loc.inode ? uuid_utoa (state->loc.inode->gfid) :
"--", op_ret, strerror (op_errno));
GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val),
rsp.xdata.xdata_len, op_errno, out);
out:
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
server_submit_reply (frame, req, &rsp, NULL, 0, NULL,
(xdrproc_t)xdr_gf_common_rsp);
if (rsp.xdata.xdata_val)
GF_FREE (rsp.xdata.xdata_val);
return 0;
} | false | false | false | false | false | 0 |
cf_pair2xml(FILE *fp, const CONF_PAIR *cp)
{
fprintf(fp, "<%s>", cp->attr);
if (cp->value) {
char buffer[2048];
char *p = buffer;
const char *q = cp->value;
while (*q && (p < (buffer + sizeof(buffer) - 1))) {
if (q[0] == '&') {
memcpy(p, "&", 4);
p += 5;
} else if (q[0] == '<') {
memcpy(p, "<", 4);
p += 4;
} else if (q[0] == '>') {
memcpy(p, ">", 4);
p += 4;
} else {
*(p++) = *q;
}
q++;
}
*p = '\0';
fprintf(fp, "%s", buffer);
}
fprintf(fp, "</%s>\n", cp->attr);
return 1;
} | false | false | false | false | false | 0 |
resolve_section (const char *name,
asection *sections,
bfd_vma *result)
{
asection *curr;
unsigned int len;
for (curr = sections; curr; curr = curr->next)
if (strcmp (curr->name, name) == 0)
{
*result = curr->vma;
return TRUE;
}
/* Hmm. still haven't found it. try pseudo-section names. */
for (curr = sections; curr; curr = curr->next)
{
len = strlen (curr->name);
if (len > strlen (name))
continue;
if (strncmp (curr->name, name, len) == 0)
{
if (strncmp (".end", name + len, 4) == 0)
{
*result = curr->vma + curr->size;
return TRUE;
}
/* Insert more pseudo-section names here, if you like. */
}
}
return FALSE;
} | false | false | false | false | false | 0 |
Clear(RNScalar value)
{
// Set all grid values to value
RNScalar *grid_valuep = grid_values;
for (int i = 0; i < grid_size; i++)
*(grid_valuep++) = value;
} | false | false | false | false | false | 0 |
chase_scanname(dns_name_t *name, dns_rdatatype_t type, dns_rdatatype_t covers)
{
dns_rdataset_t *rdataset = NULL;
dig_message_t * msg;
for (msg = ISC_LIST_HEAD(chase_message_list2); msg != NULL;
msg = ISC_LIST_NEXT(msg, link)) {
if (dns_message_firstname(msg->msg, DNS_SECTION_ANSWER)
== ISC_R_SUCCESS)
rdataset = chase_scanname_section(msg->msg, name,
type, covers,
DNS_SECTION_ANSWER);
if (rdataset != NULL)
return (rdataset);
if (dns_message_firstname(msg->msg, DNS_SECTION_AUTHORITY)
== ISC_R_SUCCESS)
rdataset =
chase_scanname_section(msg->msg, name,
type, covers,
DNS_SECTION_AUTHORITY);
if (rdataset != NULL)
return (rdataset);
if (dns_message_firstname(msg->msg, DNS_SECTION_ADDITIONAL)
== ISC_R_SUCCESS)
rdataset =
chase_scanname_section(msg->msg, name, type,
covers,
DNS_SECTION_ADDITIONAL);
if (rdataset != NULL)
return (rdataset);
}
return (NULL);
} | false | false | false | false | false | 0 |
_prefsListener( XAP_Prefs *pPrefs, UT_StringPtrMap * /*phChanges*/, void *data )
{
AP_LeftRuler *pLeftRuler = static_cast<AP_LeftRuler *>(data);
UT_ASSERT( data && pPrefs );
const gchar *pszBuffer;
pPrefs->getPrefsValue(static_cast<const gchar *>(AP_PREF_KEY_RulerUnits), &pszBuffer );
// or should I just default to inches or something?
UT_Dimension dim = UT_determineDimension( pszBuffer, DIM_none );
UT_ASSERT( dim != DIM_none );
if ( dim != pLeftRuler->getDimension() )
pLeftRuler->setDimension( dim );
} | false | false | false | false | false | 0 |
hhash_sorted_iter_next(hhash_iter_t* i)
{
if (hhash_iter_finished(i)) {
return;
}
++i->i;
} | false | false | false | false | false | 0 |
xmlSecNssSymKeyDataKlassCheck(xmlSecKeyDataKlass* klass) {
#ifndef XMLSEC_NO_DES
if(klass == xmlSecNssKeyDataDesId) {
return(1);
}
#endif /* XMLSEC_NO_DES */
#ifndef XMLSEC_NO_AES
if(klass == xmlSecNssKeyDataAesId) {
return(1);
}
#endif /* XMLSEC_NO_AES */
#ifndef XMLSEC_NO_HMAC
if(klass == xmlSecNssKeyDataHmacId) {
return(1);
}
#endif /* XMLSEC_NO_HMAC */
return(0);
} | false | false | false | false | false | 0 |
createControls()
{
mTrayMgr->createLabel(TL_TOPLEFT, "JuliaParamLabel", "Julia Parameters", 200);
mTrayMgr->createThickSlider(TL_TOPLEFT, "RealSlider", "Real", 200, 80, -1, 1, 50)->setValue(global_real, false);
mTrayMgr->createThickSlider(TL_TOPLEFT, "ImagSlider", "Imag", 200, 80, -1, 1, 50)->setValue(global_imag, false);
mTrayMgr->createThickSlider(TL_TOPLEFT, "ThetaSlider", "Theta", 200, 80, -1, 1, 50)->setValue(global_theta, false);
mTrayMgr->showCursor();
} | false | false | false | false | false | 0 |
cli_add_alternate_server(struct cli_session* cs, const char* pn)
{
if(cs && cs->ts && pn && *pn) {
add_alternate_server(pn);
}
} | false | false | false | false | false | 0 |
operator()(const Statistic *LHS, const Statistic *RHS) const {
int Cmp = std::strcmp(LHS->getName(), RHS->getName());
if (Cmp != 0) return Cmp < 0;
// Secondary key is the description.
return std::strcmp(LHS->getDesc(), RHS->getDesc()) < 0;
} | false | false | false | false | false | 0 |
afs_zap_data(struct afs_vnode *vnode)
{
_enter("{%x:%u}", vnode->fid.vid, vnode->fid.vnode);
/* nuke all the non-dirty pages that aren't locked, mapped or being
* written back in a regular file and completely discard the pages in a
* directory or symlink */
if (S_ISREG(vnode->vfs_inode.i_mode))
invalidate_remote_inode(&vnode->vfs_inode);
else
invalidate_inode_pages2(vnode->vfs_inode.i_mapping);
} | false | false | false | false | false | 0 |
gabedit_text_goto_end(GtkWidget *text)
{
GtkTextIter start;
GtkTextIter end;
GtkTextBuffer *buffer;
if(!GTK_IS_TEXT_VIEW (text)) return;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
gtk_text_buffer_get_bounds (buffer, &start, &end);
gtk_text_buffer_place_cursor(buffer, &end);
gtk_text_view_scroll_mark_onscreen (GTK_TEXT_VIEW(text),gtk_text_buffer_get_insert(buffer));
} | false | false | false | false | false | 0 |
channel_ready_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
TpChannel *channel = TP_CHANNEL (source);
InspectChannelData *data = user_data;
guint handle_type, handle;
gchar *channel_type;
gchar **interfaces, **iter;
GError *error = NULL;
if (!tp_proxy_prepare_finish (channel, result, &error))
{
g_warning ("%s", error->message);
data->exit_status = 1;
g_main_loop_quit (data->main_loop);
g_clear_error (&error);
return;
}
g_object_get (channel,
"channel-type", &channel_type,
"handle-type", &handle_type,
"handle", &handle,
"interfaces", &interfaces,
NULL);
printf ("Type: %s\n", channel_type);
printf ("Handle: of type %u, #%u\n", handle_type, handle);
puts ("Interfaces:");
for (iter = interfaces; iter != NULL && *iter != NULL; iter++)
{
printf ("\t%s\n", *iter);
}
g_free (channel_type);
g_strfreev (interfaces);
if (tp_proxy_has_interface_by_id (channel,
TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP))
{
GPtrArray *members = tp_channel_group_dup_members_contacts (channel);
guint i;
printf ("Group members:\n");
for (i = 0; i < members->len; i++)
{
TpContact *member = g_ptr_array_index (members, i);
printf ("\tcontact #%u %s\n",
tp_contact_get_handle (member),
tp_contact_get_identifier (member));
}
g_ptr_array_unref (members);
}
data->exit_status = 0;
g_main_loop_quit (data->main_loop);
} | false | false | false | false | false | 0 |
onKeyRelease(FXObject*,FXSelector,void* ptr){
FXEvent* event=(FXEvent*)ptr;
if(!isEnabled()) return 0;
if(target && target->tryHandle(this,FXSEL(SEL_KEYRELEASE,message),ptr)) return 1;
switch(event->code){
case KEY_Shift_L:
case KEY_Shift_R:
case KEY_Control_L:
case KEY_Control_R:
case KEY_Alt_L:
case KEY_Alt_R:
if(flags&FLAG_DODRAG){handle(this,FXSEL(SEL_DRAGGED,0),ptr);}
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
GetRecordHeader(SSL* ssl, const byte* input, word32* inOutIdx,
RecordLayerHeader* rh, word16 *size)
{
if (!ssl->options.dtls) {
XMEMCPY(rh, input + *inOutIdx, RECORD_HEADER_SZ);
*inOutIdx += RECORD_HEADER_SZ;
ato16(rh->length, size);
}
else {
#ifdef CYASSL_DTLS
/* type and version in same sport */
XMEMCPY(rh, input + *inOutIdx, ENUM_LEN + VERSION_SZ);
*inOutIdx += ENUM_LEN + VERSION_SZ;
*inOutIdx += 4; /* skip epoch and first 2 seq bytes for now */
ato32(input + *inOutIdx, &ssl->keys.dtls_peer_sequence_number);
*inOutIdx += 4; /* advance past rest of seq */
ato16(input + *inOutIdx, size);
*inOutIdx += LENGTH_SZ;
#endif
}
/* catch version mismatch */
if (rh->version.major != ssl->version.major ||
rh->version.minor != ssl->version.minor) {
if (ssl->options.side == SERVER_END &&
ssl->options.acceptState == ACCEPT_BEGIN)
CYASSL_MSG("Client attempting to connect with different version");
else if (ssl->options.side == CLIENT_END && ssl->options.downgrade &&
ssl->options.connectState < FIRST_REPLY_DONE)
CYASSL_MSG("Server attempting to accept with different version");
else {
CYASSL_MSG("SSL version error");
return VERSION_ERROR; /* only use requested version */
}
}
/* record layer length check */
if (*size > (MAX_RECORD_SIZE + MAX_COMP_EXTRA + MAX_MSG_EXTRA))
return LENGTH_ERROR;
/* verify record type here as well */
switch ((enum ContentType)rh->type) {
case handshake:
case change_cipher_spec:
case application_data:
case alert:
break;
case no_type:
default:
CYASSL_MSG("Unknown Record Type");
return UNKNOWN_RECORD_TYPE;
}
return 0;
} | false | false | false | false | false | 0 |
virtblk_restore(struct virtio_device *vdev)
{
struct virtio_blk *vblk = vdev->priv;
int ret;
ret = init_vq(vdev->priv);
if (ret)
return ret;
virtio_device_ready(vdev);
blk_mq_start_stopped_hw_queues(vblk->disk->queue, true);
return 0;
} | false | false | false | false | false | 0 |
Clone(FCDEntity* _clone, bool cloneChildren) const
{
FCDImage* clone = NULL;
if (_clone == NULL) _clone = clone = new FCDImage(const_cast<FCDocument*>(GetDocument()));
else if (_clone->HasType(FCDImage::GetClassType())) clone = (FCDImage*) _clone;
FCDEntity::Clone(_clone, cloneChildren);
if (clone != NULL)
{
clone->width = width;
clone->height = height;
clone->depth = depth;
clone->filename = filename;
clone->SetVideoFlag(GetVideoFlag());
}
return _clone;
} | false | false | false | false | false | 0 |
picasso_FillRect (TrapContext *ctx)
{
uaecptr renderinfo = m68k_areg (regs, 1);
uae_u32 X = (uae_u16)m68k_dreg (regs, 0);
uae_u32 Y = (uae_u16)m68k_dreg (regs, 1);
uae_u32 Width = (uae_u16)m68k_dreg (regs, 2);
uae_u32 Height = (uae_u16)m68k_dreg (regs, 3);
uae_u32 Pen = m68k_dreg (regs, 4);
uae_u8 Mask = (uae_u8)m68k_dreg (regs, 5);
RGBFTYPE RGBFormat = (RGBFTYPE)m68k_dreg (regs, 7);
uae_u8 *oldstart;
int Bpp;
struct RenderInfo ri;
uae_u32 result = 0;
if (NOBLITTER)
return 0;
if (CopyRenderInfoStructureA2U (renderinfo, &ri) && Y != 0xFFFF) {
Bpp = GetBytesPerPixel (RGBFormat);
P96TRACE((_T("FillRect(%d, %d, %d, %d) Pen 0x%x BPP %d BPR %d Mask 0x%x\n"),
X, Y, Width, Height, Pen, Bpp, ri.BytesPerRow, Mask));
if(Bpp > 1)
Mask = 0xFF;
if (Mask == 0xFF) {
/* Do the fill-rect in the frame-buffer */
do_fillrect_frame_buffer (&ri, X, Y, Width, Height, Pen, Bpp);
result = 1;
} else {
/* We get here only if Mask != 0xFF */
if (Bpp != 1) {
write_log (_T("WARNING - FillRect() has unhandled mask 0x%x with Bpp %d. Using fall-back routine.\n"), Mask, Bpp);
} else {
Pen &= Mask;
Mask = ~Mask;
oldstart = ri.Memory + Y * ri.BytesPerRow + X * Bpp;
{
uae_u8 *start = oldstart;
uae_u8 *end = start + Height * ri.BytesPerRow;
for (; start != end; start += ri.BytesPerRow) {
uae_u8 *p = start;
unsigned long cols;
for (cols = 0; cols < Width; cols++) {
uae_u32 tmpval = do_get_mem_byte (p + cols) & Mask;
do_put_mem_byte (p + cols, (uae_u8)(Pen | tmpval));
}
}
}
result = 1;
}
}
}
return result;
} | false | false | false | false | false | 0 |
createDIB(void *&data,
const unsigned long size,
const unsigned long frame,
const int bits,
const int upsideDown,
const int padding)
{
if (RGBColorModel && (InterData != NULL))
{
if (size == 0)
data = NULL;
if ((bits == 24) || (bits == 32))
return InterData->createDIB(data, size, Columns, Rows, frame, getBits() /*fromBits*/, 8 /*toBits*/, bits /*mode*/, upsideDown, padding);
}
return 0;
} | false | false | false | false | false | 0 |
_wrap_lfc_startsess(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
RETURNCODE result;
if (!PyArg_ParseTuple(args,(char *)"OO:lfc_startsess",&obj0,&obj1)) SWIG_fail;
{
if (obj0 == Py_None) {
arg1 = NULL;
} else {
arg1 = PyString_AsString (obj0);
if (arg1 && arg1[0] == 0) arg1 = NULL;
}
}
{
if (obj1 == Py_None) {
arg2 = NULL;
} else {
arg2 = PyString_AsString (obj1);
if (arg2 && arg2[0] == 0) arg2 = NULL;
}
}
result = (RETURNCODE)lfc_startsess(arg1,arg2);
if (result < 0) {
PyErr_SetString (serrno2pyexc (serrno), serrbuf);
return (NULL);
}
is_returncode = 1;
resultobj = Py_None;
return resultobj;
fail:
return NULL;
} | false | false | false | false | false | 0 |
fdtv_start_feed(struct dvb_demux_feed *dvbdmxfeed)
{
struct firedtv *fdtv = dvbdmxfeed->demux->priv;
int pidc, c, ret;
u16 pids[16];
switch (dvbdmxfeed->type) {
case DMX_TYPE_TS:
case DMX_TYPE_SEC:
break;
default:
dev_err(fdtv->device, "can't start dmx feed: invalid type %u\n",
dvbdmxfeed->type);
return -EINVAL;
}
if (mutex_lock_interruptible(&fdtv->demux_mutex))
return -EINTR;
if (dvbdmxfeed->type == DMX_TYPE_TS) {
switch (dvbdmxfeed->pes_type) {
case DMX_PES_VIDEO:
case DMX_PES_AUDIO:
case DMX_PES_TELETEXT:
case DMX_PES_PCR:
case DMX_PES_OTHER:
c = alloc_channel(fdtv);
break;
default:
dev_err(fdtv->device,
"can't start dmx feed: invalid pes type %u\n",
dvbdmxfeed->pes_type);
ret = -EINVAL;
goto out;
}
} else {
c = alloc_channel(fdtv);
}
if (c > 15) {
dev_err(fdtv->device, "can't start dmx feed: busy\n");
ret = -EBUSY;
goto out;
}
dvbdmxfeed->priv = (typeof(dvbdmxfeed->priv))(unsigned long)c;
fdtv->channel_pid[c] = dvbdmxfeed->pid;
collect_channels(fdtv, &pidc, pids);
if (dvbdmxfeed->pid == 8192) {
ret = avc_tuner_get_ts(fdtv);
if (ret) {
dealloc_channel(fdtv, c);
dev_err(fdtv->device, "can't get TS\n");
goto out;
}
} else {
ret = avc_tuner_set_pids(fdtv, pidc, pids);
if (ret) {
dealloc_channel(fdtv, c);
dev_err(fdtv->device, "can't set PIDs\n");
goto out;
}
}
out:
mutex_unlock(&fdtv->demux_mutex);
return ret;
} | false | false | false | false | false | 0 |
StandbyRecoverPreparedTransactions(bool overwriteOK)
{
DIR *cldir;
struct dirent *clde;
cldir = AllocateDir(TWOPHASE_DIR);
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
{
if (strlen(clde->d_name) == 8 &&
strspn(clde->d_name, "0123456789ABCDEF") == 8)
{
TransactionId xid;
char *buf;
TwoPhaseFileHeader *hdr;
TransactionId *subxids;
int i;
xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
/* Already processed? */
if (TransactionIdDidCommit(xid) || TransactionIdDidAbort(xid))
{
ereport(WARNING,
(errmsg("removing stale two-phase state file \"%s\"",
clde->d_name)));
RemoveTwoPhaseFile(xid, true);
continue;
}
/* Read and validate file */
buf = ReadTwoPhaseFile(xid, true);
if (buf == NULL)
{
ereport(WARNING,
(errmsg("removing corrupt two-phase state file \"%s\"",
clde->d_name)));
RemoveTwoPhaseFile(xid, true);
continue;
}
/* Deconstruct header */
hdr = (TwoPhaseFileHeader *) buf;
if (!TransactionIdEquals(hdr->xid, xid))
{
ereport(WARNING,
(errmsg("removing corrupt two-phase state file \"%s\"",
clde->d_name)));
RemoveTwoPhaseFile(xid, true);
pfree(buf);
continue;
}
/*
* Examine subtransaction XIDs ... they should all follow main
* XID.
*/
subxids = (TransactionId *)
(buf + MAXALIGN(sizeof(TwoPhaseFileHeader)));
for (i = 0; i < hdr->nsubxacts; i++)
{
TransactionId subxid = subxids[i];
Assert(TransactionIdFollows(subxid, xid));
SubTransSetParent(xid, subxid, overwriteOK);
}
}
}
FreeDir(cldir);
} | false | false | false | false | false | 0 |
mprLoadNativeModule(MprModule *mp)
{
MprModuleEntry fn;
MprPath info;
char *at;
void *handle;
mprAssert(mp);
/*
Search the image incase the module has been statically linked
*/
#ifdef RTLD_MAIN_ONLY
handle = RTLD_MAIN_ONLY;
#else
#ifdef RTLD_DEFAULT
handle = RTLD_DEFAULT;
#else
handle = 0;
#endif
#endif
if (!mp->entry || handle == 0 || !dlsym(handle, mp->entry)) {
if ((at = mprSearchForModule(mp->path)) == 0) {
mprError("Can't find module \"%s\", cwd: \"%s\", search path \"%s\"", mp->path, mprGetCurrentPath(),
mprGetModuleSearchPath());
return 0;
}
mp->path = at;
mprGetPathInfo(mp->path, &info);
mp->modified = info.mtime;
mprLog(2, "Loading native module %s from %s", mp->name, mp->path);
if ((handle = dlopen(mp->path, RTLD_LAZY | RTLD_GLOBAL)) == 0) {
mprError("Can't load module %s\nReason: \"%s\"", mp->path, dlerror());
return MPR_ERR_CANT_OPEN;
}
mp->handle = handle;
} else if (mp->entry) {
mprLog(2, "Activating native module %s", mp->name);
}
if (mp->entry) {
if ((fn = (MprModuleEntry) dlsym(handle, mp->entry)) != 0) {
if ((fn)(mp->moduleData, mp) < 0) {
mprError("Initialization for module %s failed", mp->name);
dlclose(handle);
return MPR_ERR_CANT_INITIALIZE;
}
} else {
mprError("Can't load module %s\nReason: can't find function \"%s\"", mp->path, mp->entry);
dlclose(handle);
return MPR_ERR_CANT_READ;
}
}
return 0;
} | false | false | false | true | true | 1 |
breaks_set_enabled_for_file(const char *file, gboolean enabled)
{
GList *breaks;
enum dbs state = debug_get_state();
/* do not process async break manipulation on modules
that do not support async interuppt */
if (DBS_RUNNING == state && !debug_supports_async_breaks())
return;
breaks = breaks_get_for_document(file);
/* handle switching instantly if debugger is idle or stopped
and request debug module interruption overwise */
if (DBS_IDLE == state)
{
on_set_enabled_list(breaks, enabled);
g_list_free(breaks);
config_set_debug_changed();
}
else if (DBS_STOPPED == state)
enabled ? breaks_set_enabled_list_debug(breaks) : breaks_set_disabled_list_debug(breaks);
else if (DBS_STOP_REQUESTED != state)
debug_request_interrupt((bs_callback)(enabled ? breaks_set_enabled_list_debug : breaks_set_disabled_list_debug), (gpointer)breaks);
} | false | false | false | false | false | 0 |
dereference_iter_node(rbtdb_dbiterator_t *rbtdbiter) {
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)rbtdbiter->common.db;
dns_rbtnode_t *node = rbtdbiter->node;
nodelock_t *lock;
if (node == NULL)
return;
lock = &rbtdb->node_locks[node->locknum].lock;
NODE_LOCK(lock, isc_rwlocktype_read);
decrement_reference(rbtdb, node, 0, isc_rwlocktype_read,
rbtdbiter->tree_locked, ISC_FALSE);
NODE_UNLOCK(lock, isc_rwlocktype_read);
rbtdbiter->node = NULL;
} | false | false | false | false | false | 0 |
__cpuidle_unset_driver(struct cpuidle_driver *drv)
{
if (drv == cpuidle_curr_driver)
cpuidle_curr_driver = NULL;
} | false | false | false | false | false | 0 |
getY()
{
if (m_snakeParts.isEmpty())
{
kDebug() << "Requested coordinate of inexistant snake";
return 0;
}
return m_snakeParts.last().getY();
} | false | false | false | false | false | 0 |
topMargin(void) const
{return _topPixel==5?0.0:(double)_topPixel/MSPointsPerInch;} | false | false | false | false | false | 0 |
snd_info_card_id_change(struct snd_card *card)
{
mutex_lock(&info_mutex);
if (card->proc_root_link) {
proc_remove(card->proc_root_link);
card->proc_root_link = NULL;
}
if (strcmp(card->id, card->proc_root->name))
card->proc_root_link = proc_symlink(card->id,
snd_proc_root->p,
card->proc_root->name);
mutex_unlock(&info_mutex);
} | false | false | false | false | false | 0 |
max8997_irq_resume(struct max8997_dev *max8997)
{
if (max8997->irq && max8997->irq_domain)
max8997_irq_thread(0, max8997);
return 0;
} | false | false | false | false | false | 0 |
gw_pm_get_catalog_plugin ( gchar* name) {
GWCatalogPlugin * catalog_plugin = NULL;
if ( my_plugins_manager.catalog_plugins != NULL) {
GWPlugin *plugin = g_hash_table_lookup ( my_plugins_manager.catalog_plugins, name);
if ( plugin != NULL) {
catalog_plugin = plugin->data;
} else {}
} else {}
return catalog_plugin;
} | false | false | false | false | false | 0 |
OnNavigationKey(wxNavigationKeyEvent& event)
{
if (!event.IsWindowChange())
{
event.Skip();
return;
}
AdvanceTab(event.GetDirection());
} | false | false | false | false | false | 0 |
draw_rev_graph(struct rev_graph *graph)
{
struct rev_filler {
chtype separator, line;
};
enum { DEFAULT, RSHARP, RDIAG, LDIAG };
static struct rev_filler fillers[] = {
{ ' ', REVGRAPH_LINE },
{ '`', '.' },
{ '\'', ' ' },
{ '/', ' ' },
};
chtype symbol = get_rev_graph_symbol(graph);
struct rev_filler *filler;
size_t i;
filler = &fillers[DEFAULT];
for (i = 0; i < graph->pos; i++) {
append_to_rev_graph(graph, filler->line);
if (graph_parent_is_merge(graph->prev) &&
graph->prev->pos == i)
filler = &fillers[RSHARP];
append_to_rev_graph(graph, filler->separator);
}
/* Place the symbol for this revision. */
append_to_rev_graph(graph, symbol);
if (graph->prev->size > graph->size)
filler = &fillers[RDIAG];
else
filler = &fillers[DEFAULT];
i++;
for (; i < graph->size; i++) {
append_to_rev_graph(graph, filler->separator);
append_to_rev_graph(graph, filler->line);
if (graph_parent_is_merge(graph->prev) &&
i < graph->prev->pos + graph->parents->size)
filler = &fillers[RSHARP];
if (graph->prev->size > graph->size)
filler = &fillers[LDIAG];
}
if (graph->prev->size > graph->size) {
append_to_rev_graph(graph, filler->separator);
if (filler->line != ' ')
append_to_rev_graph(graph, filler->line);
}
} | false | false | false | false | false | 0 |
symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
symlist_t *symlist_src2)
{
symbol_node_t *node;
*symlist_dest = *symlist_src1;
while((node = SLIST_FIRST(symlist_src2)) != NULL) {
SLIST_REMOVE_HEAD(symlist_src2, links);
SLIST_INSERT_HEAD(symlist_dest, node, links);
}
/* These are now empty */
SLIST_INIT(symlist_src1);
SLIST_INIT(symlist_src2);
} | false | false | false | false | false | 0 |
gt_multithread(GtThreadFunc function, void *data, GT_UNUSED GtError *err)
{
unsigned int i;
gt_error_check(err);
gt_assert(function);
for (i = 0; i < gt_jobs; i++)
function(data);
return 0;
} | false | false | false | false | false | 0 |
ApplyN(Matrix m, int n, POINT_TYPE *in, POINT_TYPE *out)
{
int i, j;
for (i = 0; i < n; i++)
{
out[i] = m.b[i];
for (j = 0; j < n; j++)
out[i] += in[j] * m.A[j][i];
}
return;
} | false | false | false | false | false | 0 |
ZuinIsEntering( ZuinData *pZuin )
{
int i;
if ( pZuin->kbtype >= KB_HANYU_PINYIN ) {
if ( pZuin->pinYinData.keySeq[0] )
return 1;
} else {
for ( i = 0; i < ZUIN_SIZE; i++ )
if ( pZuin->pho_inx[ i ] )
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
dc_sp_custom(int script, int* yield, int* preturnint, char* key, int sprite, int val)
{
RETURN_NEG_IF_BAD_SPRITE(sprite);
if (spr[sprite].active == 0)
{
*preturnint = -1;
}
else
{
// Set the value
if (val != -1)
dinkc_sp_custom_set(spr[sprite].custom, key, val);
*preturnint = dinkc_sp_custom_get(spr[sprite].custom, key);
}
} | false | false | false | false | false | 0 |
run(Module &M,
ModuleAnalysisManager *AM) {
LazyCallGraph &G = AM->getResult<LazyCallGraphAnalysis>(M);
OS << "Printing the call graph for module: " << M.getModuleIdentifier()
<< "\n\n";
SmallPtrSet<LazyCallGraph::Node *, 16> Printed;
for (LazyCallGraph::Node &N : G)
if (Printed.insert(&N).second)
printNodes(OS, N, Printed);
for (LazyCallGraph::SCC &SCC : G.postorder_sccs())
printSCC(OS, SCC);
return PreservedAnalyses::all();
} | false | false | false | false | false | 0 |
autohelperaa_attackpat8(int trans, int move, int color, int action)
{
int b, A;
UNUSED(color);
UNUSED(action);
b = AFFINE_TRANSFORM(722, trans, move);
A = AFFINE_TRANSFORM(646, trans, move);
return countlib(A)==2 && accuratelib(b, color, MAX_LIBERTIES, NULL)>1;
} | false | false | false | false | false | 0 |
isSafeAndProfitableToSinkLoad(LoadInst *L) {
BasicBlock::iterator BBI = L, E = L->getParent()->end();
for (++BBI; BBI != E; ++BBI)
if (BBI->mayWriteToMemory())
return false;
// Check for non-address taken alloca. If not address-taken already, it isn't
// profitable to do this xform.
if (AllocaInst *AI = dyn_cast<AllocaInst>(L->getOperand(0))) {
bool isAddressTaken = false;
for (Value::use_iterator UI = AI->use_begin(), E = AI->use_end();
UI != E; ++UI) {
User *U = *UI;
if (isa<LoadInst>(U)) continue;
if (StoreInst *SI = dyn_cast<StoreInst>(U)) {
// If storing TO the alloca, then the address isn't taken.
if (SI->getOperand(1) == AI) continue;
}
isAddressTaken = true;
break;
}
if (!isAddressTaken && AI->isStaticAlloca())
return false;
}
// If this load is a load from a GEP with a constant offset from an alloca,
// then we don't want to sink it. In its present form, it will be
// load [constant stack offset]. Sinking it will cause us to have to
// materialize the stack addresses in each predecessor in a register only to
// do a shared load from register in the successor.
if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(L->getOperand(0)))
if (AllocaInst *AI = dyn_cast<AllocaInst>(GEP->getOperand(0)))
if (AI->isStaticAlloca() && GEP->hasAllConstantIndices())
return false;
return true;
} | false | false | false | false | false | 0 |
conf_set_service_name(void *data)
{
struct Client *target_p;
const char *s;
char *tmp;
int dots = 0;
for(s = data; *s != '\0'; s++)
{
if(!IsServChar(*s))
{
conf_report_error("Ignoring service::name "
"-- bogus servername.");
return;
}
else if(*s == '.')
dots++;
}
if(!dots)
{
conf_report_error("Ignoring service::name -- must contain '.'");
return;
}
tmp = rb_strdup(data);
rb_dlinkAddAlloc(tmp, &service_list);
if((target_p = find_server(NULL, tmp)))
target_p->flags |= FLAGS_SERVICE;
} | false | false | false | false | false | 0 |
zDNAScorePairLUT (zScanner *scanner, zDNA* genomic, zDNA* cdna, coor_t gpos, coor_t cpos) {
coor_t i, p, index, length;
coor_t gfocus = gpos - scanner->model->focus;
coor_t cfocus = cpos - scanner->model->focus;
/* user defines and boundaries */
if ((gpos < scanner->min_gpos) || (gpos > scanner->max_pos) ||
(cpos < scanner->min_pos) || (cpos > scanner->max_pos))
return MIN_SCORE;
/* scoring */
if (scanner->model->length == 2) { /* Bypass for the basic version where we dont need the complex loops that take time */
index = scanner->model->symbols*zGetDNAS5(genomic, gfocus) + zGetDNAS5(cdna, cfocus);
return scanner->model->data[index];
}
length = scanner->model->length / 2;
/* scoring */
index = 0;
/* Conditional probs */
for (i = 0; i < length; i++) {
p = zPOWER[scanner->model->symbols][i];
index += (p * zGetDNAS5(genomic, gfocus - i));
}
index *= zPOWER[scanner->model->symbols][length];
for (i = 0; i < length; i++) {
p = zPOWER[scanner->model->symbols][i];
index += (p * zGetDNAS5(cdna, cfocus - i));
}
return scanner->model->data[index];
} | false | false | false | false | false | 0 |
arrayExpressiondoInline(Expressions *a, InlineDoState *ids)
{ Expressions *newa = NULL;
if (a)
{
newa = new Expressions();
newa->setDim(a->dim);
for (size_t i = 0; i < a->dim; i++)
{ Expression *e = (*a)[i];
if (e)
e = e->doInline(ids);
(*newa)[i] = e;
}
}
return newa;
} | false | false | false | false | false | 0 |
getcompressedteximage_error_check(struct gl_context *ctx, GLenum target,
GLint level, GLsizei clientMemSize, GLvoid *img)
{
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
const GLint maxLevels = _mesa_max_texture_levels(ctx, target);
GLuint compressedSize;
if (!legal_getteximage_target(ctx, target)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImage(target=0x%x)",
target);
return GL_TRUE;
}
assert(maxLevels != 0);
if (level < 0 || level >= maxLevels) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glGetCompressedTexImageARB(bad level = %d)", level);
return GL_TRUE;
}
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)");
return GL_TRUE;
}
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
if (!texImage) {
/* probably invalid mipmap level */
_mesa_error(ctx, GL_INVALID_VALUE,
"glGetCompressedTexImageARB(level)");
return GL_TRUE;
}
if (!_mesa_is_format_compressed(texImage->TexFormat)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetCompressedTexImageARB(texture is not compressed)");
return GL_TRUE;
}
compressedSize = _mesa_format_image_size(texImage->TexFormat,
texImage->Width,
texImage->Height,
texImage->Depth);
if (!_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
/* do bounds checking on writing to client memory */
if (clientMemSize < (GLsizei) compressedSize) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetnCompressedTexImageARB(out of bounds access:"
" bufSize (%d) is too small)", clientMemSize);
return GL_TRUE;
}
} else {
/* do bounds checking on PBO write */
if ((const GLubyte *) img + compressedSize >
(const GLubyte *) ctx->Pack.BufferObj->Size) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetCompressedTexImage(out of bounds PBO access)");
return GL_TRUE;
}
/* make sure PBO is not mapped */
if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetCompressedTexImage(PBO is mapped)");
return GL_TRUE;
}
}
return GL_FALSE;
} | false | false | false | false | false | 0 |
H5Tarray_create2(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */])
{
H5T_t *base; /* base datatype */
H5T_t *dt = NULL; /* new array datatype */
unsigned u; /* local index variable */
hid_t ret_value; /* return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("i", "iIu*h", base_id, ndims, dim);
/* Check args */
if(ndims < 1 || ndims > H5S_MAX_RANK)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimensionality")
if(!dim)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified")
for(u = 0; u < ndims; u++)
if(!(dim[u] > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero-sized dimension specified")
if(NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype")
/* Create the array datatype */
if(NULL == (dt = H5T__array_create(base, ndims, dim)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create datatype")
/* Atomize the type */
if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype")
done:
if(ret_value < 0) {
if(dt && H5T_close(dt) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't release datatype")
} /* end if */
FUNC_LEAVE_API(ret_value)
} | false | false | false | false | false | 0 |
L2()
{register object *base=vs_base;
register object *sup=base+VM2; VC2
vs_check;vs_top=sup;
{object V2=base[0]->c.c_cdr;
base[2]= (V2->c.c_car);
V2=V2->c.c_cdr;
base[3]= (V2->c.c_car);}
base[4]= list(3,((object)VV[3]),base[2],list(3,((object)VV[4]),base[2],base[3]));
vs_top=(vs_base=base+4)+1;
return;
} | false | false | false | false | false | 0 |
i8042_aux_write(struct serio *serio, unsigned char c)
{
struct i8042_port *port = serio->port_data;
return i8042_command(&c, port->mux == -1 ?
I8042_CMD_AUX_SEND :
I8042_CMD_MUX_SEND + port->mux);
} | false | false | false | false | false | 0 |
vt_group_free(MPI_Group group)
{
if (last_group == 1 && groups[0].group == group)
{
groups[0].refcnt--;
if (groups[0].refcnt == 0)
last_group--;
}
else if (last_group > 1)
{
uint32_t i;
if ((i = group_search(group)) != (uint32_t)-1)
{
/* decrease reference count on entry */
groups[i].refcnt--;
/* check if entry can be deleted */
if (groups[i].refcnt == 0)
groups[i] = groups[--last_group];
}
else
{
vt_error_msg("vt_group_free1: Cannot find group");
}
}
else
{
vt_error_msg("vt_group_free2: Cannot find group");
}
} | false | false | false | false | false | 0 |
xsh_model_binxy(xsh_xs_3* p_xs_3,
int bin_X,
int bin_Y)
{
XSH_INSTRCONFIG* instr_config=NULL;
xsh_instrument* instr = NULL;
if (bin_X!=1 || bin_Y!=1) {
instr = xsh_instrument_new();
//printf("%lf %lf %lf %d %d %lf %lf \n ",p_xs_3->pix_X,p_xs_3->pix_Y,p_xs_3->pix,p_xs_3->ASIZE,p_xs_3->BSIZE,p_xs_3->chipxpix,p_xs_3->chipypix);
if (p_xs_3->arm==0) {
xsh_instrument_set_arm(instr, XSH_ARM_UVB);
cpl_msg_info(__func__,"Setting %d x %d binning for UVB arm",bin_X,bin_Y);
p_xs_3->xsize_corr=UVB_xsize_corr;
p_xs_3->ysize_corr=UVB_ysize_corr;
}
else if (p_xs_3->arm==1) {
xsh_instrument_set_arm(instr, XSH_ARM_VIS);
cpl_msg_info(__func__,"Setting %d x %d binning for VIS arm",bin_X,bin_Y);
p_xs_3->xsize_corr=VIS_xsize_corr;
p_xs_3->ysize_corr=VIS_ysize_corr;
}
else {
xsh_instrument_set_arm(instr, XSH_ARM_NIR);
cpl_msg_warning(__func__,"NIR arm does not support binned data");
p_xs_3->xsize_corr=NIR_xsize_corr;
p_xs_3->ysize_corr=NIR_ysize_corr;
bin_X=1;
bin_Y=1;
}
instr_config=xsh_instrument_get_config(instr);
p_xs_3->pix_X=p_xs_3->pix*(float)(bin_X);
p_xs_3->pix_Y=p_xs_3->pix*(float)(bin_Y);
p_xs_3->ASIZE=instr_config->nx;
p_xs_3->ASIZE/=bin_X;
p_xs_3->BSIZE=instr_config->ny;
p_xs_3->BSIZE/=bin_Y;
p_xs_3->SIZE=instr_config->ny;
p_xs_3->SIZE/=bin_Y;
p_xs_3->chipxpix=(float)(instr_config->nx);
p_xs_3->chipxpix/=(float)(bin_X);
p_xs_3->chipypix=(float)(instr_config->ny);
p_xs_3->chipypix/=(float)(bin_Y);
p_xs_3->xsize_corr/=(float)(bin_X);
p_xs_3->ysize_corr/=(float)(bin_Y);
//printf("%lf %lf %lf %d %d %lf %lf \n ",p_xs_3->pix_X,p_xs_3->pix_Y,p_xs_3->pix,p_xs_3->ASIZE,p_xs_3->BSIZE,p_xs_3->chipxpix,p_xs_3->chipypix);
xsh_instrument_free(&instr);
}
return;
} | false | false | false | false | false | 0 |
giggle_view_shell_get_selected (GiggleViewShell *shell)
{
int page_num;
GtkWidget *page;
g_return_val_if_fail (GIGGLE_IS_VIEW_SHELL (shell), NULL);
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (shell));
page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (shell), page_num);
if (GIGGLE_IS_VIEW (page))
return GIGGLE_VIEW (page);
return NULL;
} | false | false | false | false | false | 0 |
log_io_complete_checkpoint(void)
/*============================*/
{
mutex_enter(&(log_sys->mutex));
ut_ad(log_sys->n_pending_checkpoint_writes > 0);
log_sys->n_pending_checkpoint_writes--;
if (log_sys->n_pending_checkpoint_writes == 0) {
log_complete_checkpoint();
}
mutex_exit(&(log_sys->mutex));
} | false | false | false | false | false | 0 |
utf8_build( unsigned int value, unsigned char out[6], int in_pos, int out_pos )
{
unsigned int in_mask, out_mask;
int byte = 0;
while ( in_pos < 32 ) {
in_mask = 1 << ( 31 - in_pos );
out_mask = 1 << ( 7 - out_pos );
if ( value & in_mask ) out[byte] |= out_mask;
in_pos++;
out_pos++;
if ( out_pos > 7 ) {
out_pos=2;
byte++;
}
}
} | true | true | false | false | false | 1 |
msi_bus_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct pci_bus *subordinate = pdev->subordinate;
return sprintf(buf, "%u\n", subordinate ?
!(subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI)
: !pdev->no_msi);
} | false | true | false | false | false | 1 |
output(const Char *s, size_t n, OutputByteStream *sb)
{
#ifdef SP_BIG_ENDIAN
if (sizeof(Char) == 2) {
sb->sputn((char *)s, n*2);
return;
}
#endif
allocBuf(n*2);
for (size_t i = 0; i < n; i++) {
buf_[i*2] = (s[i] >> 8) & 0xff;
buf_[i*2 + 1] = s[i] & 0xff;
}
sb->sputn(buf_, n*2);
} | false | false | false | false | false | 0 |
internal_bpchar_pattern_compare(BpChar *arg1, BpChar *arg2)
{
int result;
int len1,
len2;
len1 = bcTruelen(arg1);
len2 = bcTruelen(arg2);
result = strncmp(VARDATA_ANY(arg1), VARDATA_ANY(arg2), Min(len1, len2));
if (result != 0)
return result;
else if (len1 < len2)
return -1;
else if (len1 > len2)
return 1;
else
return 0;
} | false | false | false | false | false | 0 |
show_funcname_line(struct grep_opt *opt, const char *name,
char *buf, char *bol, unsigned lno)
{
while (bol > buf) {
char *eol = --bol;
while (bol > buf && bol[-1] != '\n')
bol--;
lno--;
if (lno <= opt->last_shown)
break;
if (match_funcname(opt, bol, eol)) {
show_line(opt, bol, eol, name, lno, '=');
break;
}
}
} | false | false | false | false | true | 1 |
identify_update_path(ExtensionControlFile *control,
const char *oldVersion, const char *newVersion)
{
List *result;
List *evi_list;
ExtensionVersionInfo *evi_start;
ExtensionVersionInfo *evi_target;
/* Extract the version update graph from the script directory */
evi_list = get_ext_ver_list(control);
/* Initialize start and end vertices */
evi_start = get_ext_ver_info(oldVersion, &evi_list);
evi_target = get_ext_ver_info(newVersion, &evi_list);
/* Find shortest path */
result = find_update_path(evi_list, evi_start, evi_target, false);
if (result == NIL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("extension \"%s\" has no update path from version \"%s\" to version \"%s\"",
control->name, oldVersion, newVersion)));
return result;
} | false | false | false | false | false | 0 |
fake_writephonebook(gn_data *data, struct gn_statemachine *state)
{
int len, ofs;
char req[256], *tmp;
char number[64];
memset(number, 0, sizeof(number));
#if 1
fake_encode(AT_CHAR_UCS2, number, sizeof(number),
data->phonebook_entry->number,
strlen(data->phonebook_entry->number));
#else
strncpy(number, data->phonebook_entry->number, sizeof(number));
#endif
ofs = snprintf(req, sizeof(req), "AT+CPBW=%d,\"%s\",%s,\"",
data->phonebook_entry->location,
number,
data->phonebook_entry->number[0] == '+' ? "145" : "129");
tmp = req + ofs;
len = fake_encode(AT_CHAR_UCS2, tmp, sizeof(req) - ofs - 3,
data->phonebook_entry->name,
strlen(data->phonebook_entry->name));
tmp[len-1] = '"';
tmp[len++] = '\r';
tmp[len] = '\0';
dprintf("%s\n", req);
return GN_ERR_NONE;
} | true | true | false | false | false | 1 |
searchRangeTableForCol(ParseState *pstate, const char *alias, char *colname,
int location)
{
ParseState *orig_pstate = pstate;
FuzzyAttrMatchState *fuzzystate = palloc(sizeof(FuzzyAttrMatchState));
fuzzystate->distance = MAX_FUZZY_DISTANCE + 1;
fuzzystate->rfirst = NULL;
fuzzystate->rsecond = NULL;
fuzzystate->first = InvalidAttrNumber;
fuzzystate->second = InvalidAttrNumber;
while (pstate != NULL)
{
ListCell *l;
foreach(l, pstate->p_rtable)
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
int fuzzy_rte_penalty = 0;
/*
* Typically, it is not useful to look for matches within join
* RTEs; they effectively duplicate other RTEs for our purposes,
* and if a match is chosen from a join RTE, an unhelpful alias is
* displayed in the final diagnostic message.
*/
if (rte->rtekind == RTE_JOIN)
continue;
/*
* If the user didn't specify an alias, then matches against one
* RTE are as good as another. But if the user did specify an
* alias, then we want at least a fuzzy - and preferably an exact
* - match for the range table entry.
*/
if (alias != NULL)
fuzzy_rte_penalty =
varstr_levenshtein(alias, strlen(alias),
rte->eref->aliasname,
strlen(rte->eref->aliasname),
1, 1, 1);
/*
* Scan for a matching column; if we find an exact match, we're
* done. Otherwise, update fuzzystate.
*/
if (scanRTEForColumn(orig_pstate, rte, colname, location,
fuzzy_rte_penalty, fuzzystate)
&& fuzzy_rte_penalty == 0)
{
fuzzystate->rfirst = rte;
fuzzystate->first = InvalidAttrNumber;
fuzzystate->rsecond = NULL;
fuzzystate->second = InvalidAttrNumber;
return fuzzystate;
}
}
pstate = pstate->parentParseState;
}
return fuzzystate;
} | false | false | false | false | false | 0 |
nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp)
{
if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle))
return nfserr_bad_stateid;
return nfs_ok;
} | false | false | false | false | false | 0 |
resourceAvailable(const Jid& jid, const Resource& r)
{
if (r.status().hasPhotoHash()) {
QString hash = r.status().photoHash();
if (!vcard_avatars_.contains(jid.bare())) {
vcard_avatars_[jid.bare()] = new VCardAvatar(this, jid);
connect(vcard_avatars_[jid.bare()],SIGNAL(avatarChanged(const Jid&)),this,SLOT(updateAvatar(const Jid&)));
}
vcard_avatars_[jid.bare()]->updateHash(hash);
}
} | false | false | false | false | false | 0 |
error_thin_bio_list(struct thin_c *tc, struct bio_list *master, int error)
{
struct bio_list bios;
unsigned long flags;
bio_list_init(&bios);
spin_lock_irqsave(&tc->lock, flags);
__merge_bio_list(&bios, master);
spin_unlock_irqrestore(&tc->lock, flags);
error_bio_list(&bios, error);
} | false | false | false | false | false | 0 |
update()
{
ui.findButton->setEnabled(! ui.findEdit->text().isEmpty());
} | false | false | false | false | false | 0 |
updateStringAttributeValue(DcmItem *dataset, const DcmTagKey &key, OFString &value)
{
DcmStack stack;
DcmTag tag(key);
OFCondition cond = EC_Normal;
cond = dataset->search(key, stack, ESM_fromHere, OFFalse);
if (cond != EC_Normal) {
OFLOG_ERROR(storescuLogger, "updateStringAttributeValue: cannot find: " << tag.getTagName()
<< " " << key << ": " << cond.text());
return OFFalse;
}
DcmElement *elem = OFstatic_cast(DcmElement *, stack.top());
DcmVR vr(elem->ident());
if (elem->getLength() > vr.getMaxValueLength()) {
OFLOG_ERROR(storescuLogger, "updateStringAttributeValue: INTERNAL ERROR: " << tag.getTagName()
<< " " << key << ": value too large (max " << vr.getMaxValueLength()
<< ") for " << vr.getVRName() << " value: " << value);
return OFFalse;
}
cond = elem->putOFStringArray(value);
if (cond != EC_Normal) {
OFLOG_ERROR(storescuLogger, "updateStringAttributeValue: cannot put string in attribute: " << tag.getTagName()
<< " " << key << ": " << cond.text());
return OFFalse;
}
return OFTrue;
} | false | false | false | false | false | 0 |
widget_pokemem_print_list( unsigned int left_edge, unsigned int width )
{
char buf[32];
unsigned int i, page_limit;
entry_t *entry;
trainer_t *trainer;
if( store && pokemem_count ) {
page_limit = top_index + page_size;
for( i = top_index; i < pokemem_count && i < page_limit; i++ ) {
entry = &g_array_index( store, entry_t, i );
trainer = entry->trainer;
snprintf( buf, sizeof( buf ), "%s", trainer->name );
widget_pokemem_print_trainer( left_edge, width, i - top_index,
trainer->disabled, entry->checked, buf );
}
if( top_index ) widget_up_arrow( left_edge, 3, WIDGET_COLOUR_FOREGROUND );
if( i < pokemem_count )
widget_down_arrow( left_edge, page_size + 2, WIDGET_COLOUR_FOREGROUND );
}
widget_display_lines( 3, page_size );
} | false | false | false | false | false | 0 |
read_aist_tree(const guchar **p, gsize *size, AistContext *context)
{
gboolean is_data_node;
gchar *name = NULL;
guint i, nchildren;
gboolean ok = FALSE;
if (!read_qt_bool(p, size, &is_data_node))
goto fail;
if (is_data_node) {
gwy_debug("reading data");
if (!read_aist_data(p, size, context))
goto fail;
}
if (!read_qt_string(p, size, &name)
|| !read_qt_int(p, size, &nchildren))
goto fail;
for (i = 0; i < nchildren; i++) {
gwy_debug("recursing");
ok = read_aist_tree(p, size, context);
gwy_debug("returned");
if (!ok)
goto fail;
}
ok = TRUE;
fail:
g_free(name);
return ok;
} | false | false | false | false | false | 0 |
_gnutls_hex2bin (const opaque * hex_data, int hex_size, opaque * bin_data,
size_t * bin_size)
{
int i, j;
opaque hex2_data[3];
unsigned long val;
hex2_data[2] = 0;
for (i = j = 0; i < hex_size;)
{
if (!isxdigit (hex_data[i])) /* skip non-hex such as the ':' in 00:FF */
{
i++;
continue;
}
if (j > *bin_size)
{
gnutls_assert ();
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
hex2_data[0] = hex_data[i];
hex2_data[1] = hex_data[i + 1];
i += 2;
val = strtoul ((char *) hex2_data, NULL, 16);
if (val == ULONG_MAX)
{
gnutls_assert ();
return GNUTLS_E_PARSING_ERROR;
}
bin_data[j] = val;
j++;
}
*bin_size = j;
return 0;
} | false | false | false | false | false | 0 |
go_down(struct state *st)
{
st->frame++;
if (st->frame > st->maxframe)
st->frame = 0;
jumpwin(st);
} | false | false | false | false | false | 0 |
gt_ranked_list_new(unsigned long maxsize,
GtCompareWithData comparefunction,
GtFree free_func,
void *compareinfo)
{
GtRankedList *ranked_list;
gt_assert(maxsize > 0 && comparefunction != NULL);
ranked_list = gt_malloc(sizeof (*ranked_list));
ranked_list->currentsize = 0;
ranked_list->maxsize = maxsize;
ranked_list->free_func = free_func;
ranked_list->comparefunction = comparefunction;
ranked_list->compareinfo = compareinfo;
/* ranked_list->root = gt_rbtree_new(comparefunction, free_func, NULL); */
ranked_list->worstelement = NULL;
ranked_list->list = gt_dlist_new_with_data(comparefunction, compareinfo);
return ranked_list;
} | false | false | false | false | false | 0 |
bnetLevelDFS(
BnetNetwork * net,
BnetNode * node)
{
int i;
BnetNode *auxnd;
if (node->visited == 1) {
return(1);
}
node->visited = 1;
/* Graphical sources have level 0. This is the final value if the
** node has no fan-ins. Otherwise the successive loop will
** increase the level. */
node->level = 0;
for (i = 0; i < node->ninp; i++) {
if (!st_lookup(net->hash, node->inputs[i], &auxnd)) {
return(0);
}
if (!bnetLevelDFS(net,auxnd)) {
return(0);
}
if (auxnd->level >= node->level) node->level = 1 + auxnd->level;
}
return(1);
} | false | false | false | false | false | 0 |
unset_var (const char *name)
{
VARIABLE var;
for (var=variable_list; var && strcmp (var->name, name); var = var->next)
;
if (!var)
return;
/* fprintf (stderr, "unsetting `%s'\n", name); */
if (var->type == VARTYPE_FD && var->value)
{
int fd;
fd = atoi (var->value);
if (fd != -1 && fd != 0 && fd != 1 && fd != 2)
close (fd);
}
free (var->value);
var->value = NULL;
var->type = 0;
var->count = 0;
} | false | false | false | false | false | 0 |
add_placeholders_to_base_rels(PlannerInfo *root)
{
ListCell *lc;
foreach(lc, root->placeholder_list)
{
PlaceHolderInfo *phinfo = (PlaceHolderInfo *) lfirst(lc);
Relids eval_at = phinfo->ph_eval_at;
if (bms_membership(eval_at) == BMS_SINGLETON)
{
int varno = bms_singleton_member(eval_at);
RelOptInfo *rel = find_base_rel(root, varno);
if (bms_nonempty_difference(phinfo->ph_needed, rel->relids))
rel->reltargetlist = lappend(rel->reltargetlist,
copyObject(phinfo->ph_var));
}
}
} | false | false | false | false | false | 0 |
Module_hexchat_hook_timer(PyObject *self, PyObject *args, PyObject *kwargs)
{
int timeout;
PyObject *callback;
PyObject *userdata = Py_None;
PyObject *plugin;
Hook *hook;
char *kwlist[] = {"timeout", "callback", "userdata", 0};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO|O:hook_timer",
kwlist, &timeout, &callback,
&userdata))
return NULL;
plugin = Plugin_GetCurrent();
if (plugin == NULL)
return NULL;
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "callback is not callable");
return NULL;
}
hook = Plugin_AddHook(HOOK_XCHAT, plugin, callback, userdata, NULL, NULL);
if (hook == NULL)
return NULL;
BEGIN_XCHAT_CALLS(NONE);
hook->data = (void*)hexchat_hook_timer(ph, timeout,
Callback_Timer, hook);
END_XCHAT_CALLS();
return PyLong_FromVoidPtr(hook);
} | false | false | false | false | false | 0 |
n_setfont(int a)
{
int i, j;
if (a)
i = getrq();
else
i = getsn();
if (!i || i == 'P') {
j = font1;
goto s0;
}
if (i == 'S' || i == '0')
return;
if ((j = findft(i)) == -1)
return;
s0:
font1 = font;
font = j;
mchbits();
} | false | false | false | false | false | 0 |
sge_security_verify_user(const char *host, const char *commproc, u_long32 id,
const char *admin_user, const char *gdi_user, const char *progname)
{
DENTER(TOP_LAYER, "sge_security_verify_user");
if (gdi_user == NULL || host == NULL || commproc == NULL) {
DPRINTF(("gdi user name or host or commproc is NULL\n"));
DRETURN(False);
}
if (is_daemon(commproc)
&& (strcmp(gdi_user, admin_user) != 0)
&& (sge_is_user_superuser(gdi_user) == false)) {
DRETURN(False);
}
if (!is_daemon(commproc)) {
if (false == sge_security_verify_unique_identifier(false, gdi_user, progname, 0,
host, commproc, id)) {
DRETURN(False);
}
} else {
if (false == sge_security_verify_unique_identifier(true, admin_user, progname, 0,
host, commproc, id)) {
DRETURN(False);
}
}
#ifdef KERBEROS
if (krb_verify_user(host, commproc, id, user) < 0) {
DRETURN(False);
}
#endif /* KERBEROS */
DRETURN(true);
} | false | false | false | false | false | 0 |
decrByByte( off_t n )
{
// check for underflow
if (n > _byteOffset)
return OutOfRange;
else
_byteOffset -= n;
return _byteOffset;
} | false | false | false | false | false | 0 |
PK11_IsInternalKeySlot(PK11SlotInfo *slot)
{
PK11SlotInfo *int_slot;
PRBool result;
if (!slot->isInternal) {
return PR_FALSE;
}
int_slot = PK11_GetInternalKeySlot();
result = (int_slot == slot) ? PR_TRUE : PR_FALSE;
PK11_FreeSlot(int_slot);
return result;
} | false | false | false | false | false | 0 |
gdip_region_bitmap_from_tree (GpPathTree *tree)
{
GpRegionBitmap *result;
if (!tree)
return NULL;
/* each item has... */
if (tree->path) {
/* (a) only a path (the most common case) */
result = gdip_region_bitmap_from_path (tree->path);
} else {
/* (b) two items with an binary operation */
GpRegionBitmap *bitmap1 = gdip_region_bitmap_from_tree (tree->branch1);
GpRegionBitmap *bitmap2 = gdip_region_bitmap_from_tree (tree->branch2);
result = gdip_region_bitmap_combine (bitmap1, bitmap2, tree->mode);
if (bitmap1)
gdip_region_bitmap_free (bitmap1);
if (bitmap2)
gdip_region_bitmap_free (bitmap2);
}
return result;
} | false | false | false | false | false | 0 |
Ns_ConnFlush(Ns_Conn *conn, char *buf, int len, int stream)
{
Conn *connPtr = (Conn *) conn;
NsServer *servPtr = connPtr->servPtr;
Tcl_Encoding encoding;
Tcl_DString enc, gzip;
char *ahdr;
int status;
Tcl_DStringInit(&enc);
Tcl_DStringInit(&gzip);
if (len < 0) {
len = strlen(buf);
}
/*
* Encode content to the expected charset.
*/
encoding = Ns_ConnGetEncoding(conn);
if (encoding != NULL) {
Tcl_UtfToExternalDString(encoding, buf, len, &enc);
buf = enc.string;
len = enc.length;
}
/*
* GZIP the content when not streaming if enabled and the content
* length is above the minimum.
*/
if (!stream
&& (conn->flags & NS_CONN_GZIP)
&& (servPtr->opts.flags & SERV_GZIP)
&& (len > (int) servPtr->opts.gzipmin)
&& (ahdr = Ns_SetIGet(conn->headers, "Accept-Encoding")) != NULL
&& strstr(ahdr, "gzip") != NULL
&& Ns_Gzip(buf, len, servPtr->opts.gziplevel, &gzip) == NS_OK) {
buf = gzip.string;
len = gzip.length;
Ns_ConnCondSetHeaders(conn, "Content-Encoding", "gzip");
}
/*
* Flush content.
*/
status = Ns_ConnFlushDirect(conn, buf, len, stream);
Tcl_DStringFree(&enc);
Tcl_DStringFree(&gzip);
return status;
} | false | false | false | false | false | 0 |
ena_alloc_skb(struct ena_ring *rx_ring, bool frags)
{
struct sk_buff *skb;
if (frags)
skb = napi_get_frags(rx_ring->napi);
else
skb = netdev_alloc_skb_ip_align(rx_ring->netdev,
rx_ring->rx_copybreak);
if (unlikely(!skb)) {
u64_stats_update_begin(&rx_ring->syncp);
rx_ring->rx_stats.skb_alloc_fail++;
u64_stats_update_end(&rx_ring->syncp);
netif_dbg(rx_ring->adapter, rx_err, rx_ring->netdev,
"Failed to allocate skb. frags: %d\n", frags);
return NULL;
}
return skb;
} | false | false | false | false | false | 0 |
closeEvent( QCloseEvent* e )
{
if( d->topLevel )
e->ignore(); // mainly for the fallback mode
else
QMenuBar::closeEvent( e );
} | false | false | false | false | false | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.