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 |
|---|---|---|---|---|---|---|
Curl_cookie_getlist(struct CookieInfo *c,
const char *host, const char *path,
bool secure)
{
struct Cookie *newco;
struct Cookie *co;
time_t now = time(NULL);
struct Cookie *mainco=NULL;
size_t matches = 0;
if(!c || !c->cookies)
return NULL; /* no cookie struct or no cookies in the struct */
/* at first, remove expired cookies */
remove_expired(c);
co = c->cookies;
while(co) {
/* only process this cookie if it is not expired or had no expire
date AND that if the cookie requires we're secure we must only
continue if we are! */
if((!co->expires || (co->expires > now)) &&
(co->secure?secure:TRUE)) {
/* now check if the domain is correct */
if(!co->domain ||
(co->tailmatch && tailmatch(co->domain, host)) ||
(!co->tailmatch && Curl_raw_equal(host, co->domain)) ) {
/* the right part of the host matches the domain stuff in the
cookie data */
/* now check the left part of the path with the cookies path
requirement */
if(!co->spath || pathmatch(co->spath, path) ) {
/* and now, we know this is a match and we should create an
entry for the return-linked-list */
newco = malloc(sizeof(struct Cookie));
if(newco) {
/* first, copy the whole source cookie: */
memcpy(newco, co, sizeof(struct Cookie));
/* then modify our next */
newco->next = mainco;
/* point the main to us */
mainco = newco;
matches++;
}
else {
fail:
/* failure, clear up the allocated chain and return NULL */
while(mainco) {
co = mainco->next;
free(mainco);
mainco = co;
}
return NULL;
}
}
}
}
co = co->next;
}
if(matches) {
/* Now we need to make sure that if there is a name appearing more than
once, the longest specified path version comes first. To make this
the swiftest way, we just sort them all based on path length. */
struct Cookie **array;
size_t i;
/* alloc an array and store all cookie pointers */
array = malloc(sizeof(struct Cookie *) * matches);
if(!array)
goto fail;
co = mainco;
for(i=0; co; co = co->next)
array[i++] = co;
/* now sort the cookie pointers in path length order */
qsort(array, matches, sizeof(struct Cookie *), cookie_sort);
/* remake the linked list order according to the new order */
mainco = array[0]; /* start here */
for(i=0; i<matches-1; i++)
array[i]->next = array[i+1];
array[matches-1]->next = NULL; /* terminate the list */
free(array); /* remove the temporary data again */
}
return mainco; /* return the new list */
} | false | false | false | false | false | 0 |
eio_monitor_backend_add(Eio_Monitor *monitor)
{
Eio_Monitor_Backend *backend;
int mask =
IN_ATTRIB |
IN_CLOSE_WRITE |
IN_MOVED_FROM |
IN_MOVED_TO |
IN_DELETE |
IN_CREATE |
IN_MODIFY |
IN_DELETE_SELF |
IN_MOVE_SELF |
IN_UNMOUNT;
if (!_inotify_fdh)
{
eio_monitor_fallback_add(monitor);
return;
}
backend = calloc(1, sizeof (Eio_Monitor_Backend));
if (!backend)
{
eio_monitor_fallback_add(monitor);
return;
}
backend->parent = monitor;
backend->hwnd = inotify_add_watch(ecore_main_fd_handler_fd_get(_inotify_fdh), monitor->path, mask);
if (!backend->hwnd)
{
eio_monitor_fallback_add(monitor);
free(backend);
return;
}
monitor->backend = backend;
eina_hash_direct_add(_inotify_monitors, &backend->hwnd, backend);
} | false | false | false | false | false | 0 |
errors_store(struct md_rdev *rdev, const char *buf, size_t len)
{
unsigned int n;
int rv;
rv = kstrtouint(buf, 10, &n);
if (rv < 0)
return rv;
atomic_set(&rdev->corrected_errors, n);
return len;
} | false | false | false | false | false | 0 |
PyObject_DelItemString(PyObject *o, char *key)
{
PyObject *okey;
int ret;
if (o == NULL || key == NULL) {
null_error();
return -1;
}
okey = PyString_FromString(key);
if (okey == NULL)
return -1;
ret = PyObject_DelItem(o, okey);
Py_DECREF(okey);
return ret;
} | false | false | false | false | false | 0 |
ts_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
struct dvb_device *dvbdev = file->private_data;
struct ngene_channel *chan = dvbdev->priv;
struct ngene *dev = chan->dev;
if (wait_event_interruptible(dev->tsout_rbuf.queue,
dvb_ringbuffer_free
(&dev->tsout_rbuf) >= count) < 0)
return 0;
dvb_ringbuffer_write_user(&dev->tsout_rbuf, buf, count);
return count;
} | false | false | false | false | false | 0 |
ISNSAppendAttr (ISNS_Msg * msg, int tag, int size, char *p_value, int value)
{
ISNS_Attr *attr;
if (msg == NULL)
{
__LOG_ERROR ("Message is NULL");
return (ERROR);
}
/* add room for error code */
if (msg->hdr.msg_len == 0)
{
msg->hdr.msg_len = 4;
msg->hdr.msg_len += ISNS_SIZEOF_TAG; // add delimiter
}
/* Jump to the end */
attr = (ISNS_Attr *)((char *) &msg->payload + msg->hdr.msg_len);
/* insert */
attr->tag = tag;
attr->len = size;
if (p_value)
{
__ISNS_COPY (&attr->val, sizeof(attr->val), p_value, attr->len);
}
else if (attr->len == 8)
{
/* Special time format */
attr->val.timestamp.t_pad = 0;
attr->val.timestamp.t_time = htonl (value);
}
else
{
*(uint32_t *) & attr->val = value;
}
msg->hdr.msg_len += attr->len + ISNS_SIZEOF_TAG;
attr = (ISNS_Attr *)((char *) attr + attr->len + ISNS_SIZEOF_TAG);
return (ISNS_NO_ERR);
} | false | false | false | false | false | 0 |
Construct( IDirectFBImageProvider *thiz,
... )
{
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
IDirectFBDataBuffer *buffer;
CoreDFB *core;
va_list tag;
DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IDirectFBImageProvider_JPEG)
va_start( tag, thiz );
buffer = va_arg( tag, IDirectFBDataBuffer * );
core = va_arg( tag, CoreDFB * );
va_end( tag );
data->ref = 1;
data->buffer = buffer;
data->core = core;
buffer->AddRef( buffer );
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = jpeglib_panic;
if (setjmp(jerr.setjmp_buffer)) {
D_ERROR( "ImageProvider/JPEG: Error while reading headers!\n" );
jpeg_destroy_decompress(&cinfo);
buffer->Release( buffer );
DIRECT_DEALLOCATE_INTERFACE( thiz );
return DFB_FAILURE;
}
jpeg_create_decompress(&cinfo);
jpeg_buffer_src(&cinfo, buffer, 1);
jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo);
data->width = cinfo.output_width;
data->height = cinfo.output_height;
jpeg_abort_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
thiz->AddRef = IDirectFBImageProvider_JPEG_AddRef;
thiz->Release = IDirectFBImageProvider_JPEG_Release;
thiz->RenderTo = IDirectFBImageProvider_JPEG_RenderTo;
thiz->SetRenderCallback = IDirectFBImageProvider_JPEG_SetRenderCallback;
thiz->GetImageDescription =IDirectFBImageProvider_JPEG_GetImageDescription;
thiz->GetSurfaceDescription =
IDirectFBImageProvider_JPEG_GetSurfaceDescription;
return DFB_OK;
} | false | false | false | false | false | 0 |
caml_lazy_make_forward (value v)
{
CAMLparam1 (v);
CAMLlocal1 (res);
res = caml_alloc_small (1, Forward_tag);
Field (res, 0) = v;
CAMLreturn (res);
} | false | false | false | false | false | 0 |
e_text_bounds (GnomeCanvasItem *item,
gdouble *x1,
gdouble *y1,
gdouble *x2,
gdouble *y2)
{
EText *text;
gdouble width, height;
text = E_TEXT (item);
*x1 = 0;
*y1 = 0;
width = text->width;
height = text->height;
if (text->clip) {
if (text->clip_width >= 0)
width = text->clip_width;
if (text->clip_height >= 0)
height = text->clip_height;
}
*x2 = *x1 + width;
*y2 = *y1 + height;
} | false | false | false | false | false | 0 |
hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data)
{
struct tveeprom tv;
tveeprom_hauppauge_analog(&dev->i2c_client, &tv, eeprom_data);
dev->board.tuner_type = tv.tuner_type;
/* Make sure we support the board model */
switch (tv.model) {
case 72000: /* WinTV-HVR950q (Retail, IR, ATSC/QAM */
case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
case 72101: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
case 72201: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
case 72211: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */
case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
case 72261: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */
case 72271: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */
case 72281: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */
case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and analog video */
case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */
break;
default:
pr_warn("%s: warning: unknown hauppauge model #%d\n",
__func__, tv.model);
break;
}
pr_info("%s: hauppauge eeprom: model=%d\n",
__func__, tv.model);
} | false | false | false | false | false | 0 |
lookup(nc_class objectclass, Symbol* pattern)
{
Symbol* grp;
if(pattern == NULL) return NULL;
grp = lookupgroup(pattern->prefix);
if(grp == NULL) return NULL;
return lookupingroup(objectclass,pattern->name,grp);
} | false | false | false | false | false | 0 |
ArtTextDumpToFile(Widget gw, FILE *file)
{
ArtTextWidget w = (ArtTextWidget)gw;
TSNode *node;
char *c = NULL;
for (node = w->arttext.stream ; node ; node = node->gen.next) {
switch (node->gen.type) {
case LineTypeString:
c = node->str.str;
break;
case LineTypeWString:
c = NULL;
break;
case LineTypeSeparator:
c = "------------------------------------------------";
break;
case LineTypeClickable:
c = node->cli.str;
break;
case LineTypeImage:
c = "[IMAGE]";
break;
}
if (c && fprintf(file, "%s\n", c) == EOF)
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
mimeGetEntry(const char *fn, int skip_encodings)
{
mimeEntry *m;
char *t;
char *name = xstrdup(fn);
try_again:
for (m = MimeTable; m; m = m->next) {
if (regexec(&m->compiled_pattern, name, 0, 0, 0) == 0)
break;
}
if (!skip_encodings)
(void) 0;
else if (m == NULL)
(void) 0;
else if (strcmp(m->content_type, dash_str))
(void) 0;
else if (!strcmp(m->content_encoding, dash_str))
(void) 0;
else {
/* Assume we matched /\.\w$/ and cut off the last extension */
if ((t = strrchr(name, '.'))) {
*t = '\0';
goto try_again;
}
/* What? A encoding without a extension? */
m = NULL;
}
xfree(name);
return m;
} | false | false | false | false | false | 0 |
parseContentType(String& params, MaterialScriptContext& context)
{
StringVector vecparams = StringUtil::tokenise(params, " \t");
if (vecparams.empty())
{
logParseError("No content_type specified", context);
return false;
}
String& paramType = vecparams[0];
if (paramType == "named")
{
context.textureUnit->setContentType(TextureUnitState::CONTENT_NAMED);
}
else if (paramType == "shadow")
{
context.textureUnit->setContentType(TextureUnitState::CONTENT_SHADOW);
}
else if (paramType == "compositor")
{
context.textureUnit->setContentType(TextureUnitState::CONTENT_COMPOSITOR);
if (vecparams.size() == 3)
{
context.textureUnit->setCompositorReference(vecparams[1], vecparams[2]);
}
else if (vecparams.size() == 4)
{
context.textureUnit->setCompositorReference(vecparams[1], vecparams[2],
StringConverter::parseUnsignedInt(vecparams[3]));
}
else
{
logParseError("compositor content_type requires 2 or 3 extra params", context);
}
}
else
{
logParseError("Invalid content_type specified : " + paramType, context);
}
return false;
} | false | false | false | false | false | 0 |
match_find_resv(const char *name)
{
dlink_node *ptr = NULL;
if (EmptyString(name))
return NULL;
DLINK_FOREACH(ptr, resv_channel_list.head)
{
struct ResvChannel *chptr = ptr->data;
if (match_chan(name, chptr->name))
return chptr;
}
return NULL;
} | false | false | false | false | false | 0 |
AddPlugin( WokXMLTag *tag )
{
if( LoadPlugIn(tag->GetAttr("filename")))
tag->AddAttr("outcome", "good");
else
tag->AddAttr("outcome", "bad");
return 1;
} | false | false | false | false | false | 0 |
run_defparams(Design*des)
{
{ NetScope*cur = sub_;
while (cur) {
cur->run_defparams(des);
cur = cur->sib_;
}
}
while (! defparams.empty()) {
pair<pform_name_t,NetExpr*> pp = defparams.front();
defparams.pop_front();
pform_name_t path = pp.first;
NetExpr*val = pp.second;
perm_string perm_name = peek_tail_name(path);
path.pop_back();
list<hname_t> eval_path = eval_scope_path(des, this, path);
/* If there is no path on the name, then the targ_scope
is the current scope. */
NetScope*targ_scope = des->find_scope(this, eval_path);
if (targ_scope == 0) {
// Push the defparam onto a list for retry
// later. It is possible for the scope lookup to
// fail if the scope being defparam'd into is
// generated by an index array for generate.
eval_path.push_back(hname_t(perm_name));
defparams_later.push_back(make_pair(eval_path,val));
continue;
}
// Once placed in the parameter map, the expression may
// be deleted when evaluated, so give it a copy of this
// expression, not the original.
val = val->dup_expr();
bool flag = targ_scope->replace_parameter(perm_name, val);
if (! flag) {
cerr << val->get_fileline() << ": warning: parameter "
<< perm_name << " not found in "
<< scope_path(targ_scope) << "." << endl;
}
}
// If some of the defparams didn't find a scope in the name,
// then try again later. It may be that the target scope is
// created later by generate scheme or instance array.
if (! defparams_later.empty())
des->defparams_later.insert(this);
} | false | false | false | false | false | 0 |
MGD77_Path_Init (struct MGD77_CONTROL *F)
{
size_t n_alloc = GMT_SMALL_CHUNK;
char file[BUFSIZ], line[BUFSIZ];
FILE *fp = NULL;
MGD77_Set_Home (F);
sprintf (file, "%s/mgd77_paths.txt", F->MGD77_HOME);
F->n_MGD77_paths = 0;
if ((fp = GMT_fopen (file, "r")) == NULL) {
fprintf (stderr, "%s: Warning: path file %s for MGD77 files not found\n", GMT_program, file);
fprintf (stderr, "%s: (Will only look in current directory and %s for such files)\n", GMT_program, F->MGD77_HOME);
F->MGD77_datadir = (char **) GMT_memory (VNULL, 1, sizeof (char *), "MGD77_path_init");
F->MGD77_datadir[0] = GMT_memory (VNULL, (size_t)1, (size_t)(strlen (F->MGD77_HOME)+1), "MGD77_path_init");
strcpy (F->MGD77_datadir[0], F->MGD77_HOME);
F->n_MGD77_paths = 1;
return;
}
F->MGD77_datadir = (char **) GMT_memory (VNULL, n_alloc, sizeof (char *), "MGD77_path_init");
while (GMT_fgets (line, BUFSIZ, fp)) {
if (line[0] == '#') continue; /* Comments */
if (line[0] == ' ' || line[0] == '\0') continue; /* Blank line, \n included in count */
GMT_chop (line);
#ifdef WIN32
DOS_path_fix (line);
#endif
F->MGD77_datadir[F->n_MGD77_paths] = GMT_memory (VNULL, (size_t)1, (size_t)(strlen (line)+1), "MGD77_path_init");
strcpy (F->MGD77_datadir[F->n_MGD77_paths], line);
F->n_MGD77_paths++;
if (F->n_MGD77_paths == (int)n_alloc) {
n_alloc <<= 1;
F->MGD77_datadir = (char **) GMT_memory ((void *)F->MGD77_datadir, n_alloc, sizeof (char *), "MGD77_path_init");
}
}
GMT_fclose (fp);
F->MGD77_datadir = (char **) GMT_memory ((void *)F->MGD77_datadir, (size_t)F->n_MGD77_paths, sizeof (char *), "MGD77_path_init");
} | true | true | false | false | false | 1 |
hashvar(const char *p)
{
unsigned hashval;
hashval = ((unsigned char) *p) << 4;
while (*p && *p != '=')
hashval += (unsigned char) *p++;
return &vartab[hashval % VTABSIZE];
} | false | false | false | false | false | 0 |
dwc2_hsotg_map_dma(struct dwc2_hsotg *hsotg,
struct dwc2_hsotg_ep *hs_ep,
struct usb_request *req)
{
struct dwc2_hsotg_req *hs_req = our_req(req);
int ret;
/* if the length is zero, ignore the DMA data */
if (hs_req->req.length == 0)
return 0;
ret = usb_gadget_map_request(&hsotg->gadget, req, hs_ep->dir_in);
if (ret)
goto dma_error;
return 0;
dma_error:
dev_err(hsotg->dev, "%s: failed to map buffer %p, %d bytes\n",
__func__, req->buf, req->length);
return -EIO;
} | false | false | false | false | false | 0 |
s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
{
struct s5p_mfc_dev *dev = ctx->dev;
unsigned long flags;
struct s5p_mfc_buf *dst_mb;
struct s5p_mfc_buf *src_mb;
unsigned long src_y_addr, src_c_addr, dst_addr;
/*
unsigned int src_y_size, src_c_size;
*/
unsigned int dst_size;
spin_lock_irqsave(&dev->irqlock, flags);
if (list_empty(&ctx->src_queue) && ctx->state != MFCINST_FINISHING) {
mfc_debug(2, "no src buffers.\n");
spin_unlock_irqrestore(&dev->irqlock, flags);
return -EAGAIN;
}
if (list_empty(&ctx->dst_queue)) {
mfc_debug(2, "no dst buffers.\n");
spin_unlock_irqrestore(&dev->irqlock, flags);
return -EAGAIN;
}
if (list_empty(&ctx->src_queue)) {
/* send null frame */
s5p_mfc_set_enc_frame_buffer_v6(ctx, 0, 0);
src_mb = NULL;
} else {
src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
src_mb->flags |= MFC_BUF_FLAG_USED;
if (src_mb->b->vb2_buf.planes[0].bytesused == 0) {
s5p_mfc_set_enc_frame_buffer_v6(ctx, 0, 0);
ctx->state = MFCINST_FINISHING;
} else {
src_y_addr = vb2_dma_contig_plane_dma_addr(&src_mb->b->vb2_buf, 0);
src_c_addr = vb2_dma_contig_plane_dma_addr(&src_mb->b->vb2_buf, 1);
mfc_debug(2, "enc src y addr: 0x%08lx\n", src_y_addr);
mfc_debug(2, "enc src c addr: 0x%08lx\n", src_c_addr);
s5p_mfc_set_enc_frame_buffer_v6(ctx, src_y_addr, src_c_addr);
if (src_mb->flags & MFC_BUF_FLAG_EOS)
ctx->state = MFCINST_FINISHING;
}
}
dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
dst_mb->flags |= MFC_BUF_FLAG_USED;
dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
s5p_mfc_set_enc_stream_buffer_v6(ctx, dst_addr, dst_size);
spin_unlock_irqrestore(&dev->irqlock, flags);
dev->curr_ctx = ctx->num;
s5p_mfc_encode_one_frame_v6(ctx);
return 0;
} | false | false | false | false | false | 0 |
runOnModule(Module &M) {
bool Changed = false;
bool LocalChange = true;
// FIXME: instead of using smart algorithms, we just iterate until we stop
// making changes.
while (LocalChange) {
LocalChange = false;
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (!I->isDeclaration()) {
// Delete any klingons.
I->removeDeadConstantUsers();
if (I->hasLocalLinkage())
LocalChange |= PropagateConstantsIntoArguments(*I);
Changed |= PropagateConstantReturn(*I);
}
Changed |= LocalChange;
}
return Changed;
} | false | false | false | false | false | 0 |
set_suc_set_in_dep_info(Block *layer_block, Dep_info **pp)
{
int no, i, total_num = layer_block->mt_num;
for (no = 1; no <= total_num; no++) {
IntSet pre_set = pp[no]->pre_set;
if (!empty_IntSet(pre_set)) {
for (i = min_IntSet(pre_set);
i > 0;
i = next1_IntSet(pre_set, i))
add1_IntSet(pp[i]->suc_set, no);
}
}
} | false | false | false | false | false | 0 |
__sql_add_constraints(GString *sql, MidgardQueryBuilder *builder)
{
GSList *clist = NULL;
GSList *jlist = NULL;
guint j = 0;
for(clist = builder->priv->constraints;
clist != NULL; clist = clist->next) {
if(j > 0)
g_string_append(sql, " AND ");
g_string_append(sql,
MIDGARD_CORE_QUERY_CONSTRAINT(clist->data)->priv->condition);
for(jlist = ((MidgardCoreQueryConstraint*)clist->data)->priv->joins;
jlist != NULL; jlist = jlist->next) {
g_string_append(sql, " AND ");
g_string_append(sql,
((MidgardCoreQueryConstraintPrivate*)jlist->data)->condition);
}
j++;
}
if(builder->priv->constraints == NULL
&& builder->priv->groups == NULL)
g_string_append(sql, "1=1");
} | false | false | false | false | false | 0 |
restore_custom_agacolors (uae_u8 *src)
{
int i;
for (i = 0; i < 256; i++) {
#ifdef AGA
uae_u32 v = RL;
color_regs_aga_genlock[i] = 0;
if (v & 0x80000000)
color_regs_aga_genlock[i] = 1;
v &= 0x00ffffff;
current_colors.color_regs_aga[i] = v;
#else
RL;
#endif
}
return src;
} | false | false | false | false | false | 0 |
c_finish_case (void)
{
struct c_switch *cs = switch_stack;
/* If we've not seen any case labels (or a default), we may still
need to chain any statements that were seen as the SWITCH_BODY. */
if (SWITCH_BODY (cs->switch_stmt) == NULL)
{
SWITCH_BODY (cs->switch_stmt) = TREE_CHAIN (cs->switch_stmt);
TREE_CHAIN (cs->switch_stmt) = NULL_TREE;
}
/* Rechain the next statements to the SWITCH_STMT. */
last_tree = cs->switch_stmt;
/* Pop the stack. */
switch_stack = switch_stack->next;
splay_tree_delete (cs->cases);
free (cs);
} | false | false | false | false | true | 1 |
mark_set_cb (GtkTextBuffer *buffer,
GtkTextIter *cursoriter,
GtkTextMark *mark,
GtkSourceView *view)
{
if (mark == gtk_text_buffer_get_insert (buffer))
{
update_cursor_position_info (buffer, view);
}
} | false | false | false | false | false | 0 |
serverMakeName(arg, cmd)
char_u *arg;
char *cmd;
{
char_u *p;
if (arg != NULL && *arg != NUL)
p = vim_strsave_up(arg);
else
{
p = vim_strsave_up(gettail((char_u *)cmd));
/* Remove .exe or .bat from the name. */
if (p != NULL && vim_strchr(p, '.') != NULL)
*vim_strchr(p, '.') = NUL;
}
return p;
} | false | false | false | false | false | 0 |
simpl_dcl(tqual, addr_of, sym)
char *tqual;
int addr_of;
struct sym_entry *sym;
{
init_ilc(); /* initialize code list and string buffer */
prt_str(tqual, 0);
ilc_str(tqual);
if (addr_of) {
prt_str("*", 0);
ilc_str("*");
}
prt_str(sym->image, 0);
ilc_str(sym->image);
prt_str(";", 0);
ForceNl();
flush_str(); /* flush string buffer to code list */
return ilc_base.next;
} | false | false | false | false | false | 0 |
mktwiddle(enum wakefulness wakefulness, P *p)
{
INT i;
INT n = p->n, nb = p->nb;
R *w, *W;
E nbf = (E)nb;
p->w = w = (R *) MALLOC(2 * n * sizeof(R), TWIDDLES);
p->W = W = (R *) MALLOC(2 * nb * sizeof(R), TWIDDLES);
bluestein_sequence(wakefulness, n, w);
for (i = 0; i < nb; ++i)
W[2*i] = W[2*i+1] = K(0.0);
W[0] = w[0] / nbf;
W[1] = w[1] / nbf;
for (i = 1; i < n; ++i) {
W[2*i] = W[2*(nb-i)] = w[2*i] / nbf;
W[2*i+1] = W[2*(nb-i)+1] = w[2*i+1] / nbf;
}
{
plan_dft *cldf = (plan_dft *)p->cldf;
/* cldf must be awake */
cldf->apply(p->cldf, W, W+1, W, W+1);
}
} | false | false | false | false | false | 0 |
set_broadcast_params(M2TSProgram *prog, u16 esid, u32 period, u32 ts_delta, u16 aggregate_on_stream, Bool adjust_carousel_time, Bool force_rap, Bool aggregate_au, Bool discard_pending, Bool signal_rap, Bool signal_critical, Bool version_inc)
{
u32 i=0;
GF_ESIStream *priv=NULL;
GF_ESInterface *esi=NULL;
/*locate our stream*/
if (esid) {
while (i<prog->nb_streams) {
if (prog->streams[i].stream_id == esid){
priv = (GF_ESIStream *)prog->streams[i].input_udta;
esi = &prog->streams[i];
break;
}
else{
i++;
}
}
/*TODO: stream not found*/
}
/*TODO - set/reset the ESID for the parsers*/
if (!priv) return NULL;
/*TODO - if discard is set, abort current carousel*/
if (discard_pending) {
}
/*remember RAP flag*/
priv->rap = signal_rap;
priv->critical = signal_critical;
priv->vers_inc = version_inc;
priv->ts_delta = ts_delta;
priv->adjust_carousel_time = adjust_carousel_time;
/*change stream aggregation mode*/
if ((aggregate_on_stream != (u16)-1) && (priv->aggregate_on_stream != aggregate_on_stream)) {
gf_seng_enable_aggregation(prog->seng, esid, aggregate_on_stream);
priv->aggregate_on_stream = aggregate_on_stream;
}
/*change stream aggregation mode*/
if (priv->aggregate_on_stream==esi->stream_id) {
if (priv->aggregate_on_stream && (period!=(u32)-1) && (esi->repeat_rate != period)) {
esi->repeat_rate = period;
}
} else {
esi->repeat_rate = 0;
}
return priv;
} | false | false | false | false | false | 0 |
perform_c2(InfAdoptedOperation** begin,
InfAdoptedOperation** end,
test_result* result)
{
InfAdoptedOperation** _1;
InfAdoptedOperation** _2;
InfAdoptedOperation** _3;
for(_1 = begin; _1 != end; ++ _1)
{
for(_2 = begin; _2 != end; ++ _2)
{
for(_3 = begin; _3 != end; ++ _3)
{
if(_1 != _2 && _1 != _3 && _2 != _3)
{
++ result->total;
if(test_c2(*_1, *_2, *_3, cid(_1, _2), cid(_1, _3), cid(_2, _3)))
++ result->passed;
}
}
}
}
} | false | false | false | false | false | 0 |
lp_star (lua_State *L) {
int size1;
int n = luaL_checkint(L, 2);
TTree *tree1 = gettree(L, 1, &size1);
if (n >= 0) { /* seq tree1 (seq tree1 ... (seq tree1 (rep tree1))) */
TTree *tree = newtree(L, (n + 1) * (size1 + 1));
if (nullable(tree1))
luaL_error(L, "loop body may accept empty string");
while (n--) /* repeat 'n' times */
tree = seqaux(tree, tree1, size1);
tree->tag = TRep;
memcpy(sib1(tree), tree1, size1 * sizeof(TTree));
}
else { /* choice (seq tree1 ... choice tree1 true ...) true */
TTree *tree;
n = -n;
/* size = (choice + seq + tree1 + true) * n, but the last has no seq */
tree = newtree(L, n * (size1 + 3) - 1);
for (; n > 1; n--) { /* repeat (n - 1) times */
tree->tag = TChoice; tree->u.ps = n * (size1 + 3) - 2;
sib2(tree)->tag = TTrue;
tree = sib1(tree);
tree = seqaux(tree, tree1, size1);
}
tree->tag = TChoice; tree->u.ps = size1 + 1;
sib2(tree)->tag = TTrue;
memcpy(sib1(tree), tree1, size1 * sizeof(TTree));
}
copyktable(L, 1);
return 1;
} | false | false | false | false | false | 0 |
set_mode(void)
{
/*
* flags
*/
fl_fdesc = ao_taken(ad, "f");
fl_verbose = ao_taken(ad, "v");
if (ao_taken(ad, "nw"))
fl_wait = 0;
/*
* followed options
*/
nprocs = -1;
if (ao_taken(ad, "c")) {
ao_intparam(ad, "c", 0, 0, &nprocs);
fl_nprocs = 1;
} else if (ao_taken(ad, "np")) {
ao_intparam(ad, "np", 0, 0, &nprocs);
fl_nprocs = 1;
}
if (ao_taken(ad, "wd")) {
wrkdir = ao_param(ad, "wd", 0, 0);
}
/*
* runtime flags
*/
if (fl_wait)
rtf |= RTF_WAIT;
if (ao_taken(ad, "D"))
rtf |= RTF_APPWD;
if (ao_taken(ad, "O"))
rtf |= RTF_HOMOG;
if (isatty(1))
rtf |= RTF_TTYOUT;
if (!fl_fdesc)
rtf |= RTF_IO;
if (!ao_taken(ad, "npty"))
rtf |= RTF_PTYS;
return(0);
} | false | false | false | false | false | 0 |
humminbird_write_rtept(const waypoint* wpt)
{
int i;
if (humrte == NULL) {
return;
}
i = gb_ptr2int(wpt->extra_data);
if (i <= 0) {
return;
}
if (humrte->count < MAX_RTE_POINTS) {
humrte->points[humrte->count] = i - 1;
humrte->count++;
} else {
warning(MYNAME ": Sorry, routes are limited to %d points!\n", MAX_RTE_POINTS);
fatal(MYNAME ": You can use our simplify filter to reduce the number of route points.\n");
}
} | false | false | false | false | false | 0 |
cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type,
cso_state_callback func, void *user_data)
{
struct cso_hash *hash = _cso_hash_for_type(sc, type);
struct cso_hash_iter iter;
iter = cso_hash_first_node(hash);
while (!cso_hash_iter_is_null(iter)) {
void *state = cso_hash_iter_data(iter);
iter = cso_hash_iter_next(iter);
if (state) {
func(state, user_data);
}
}
} | false | false | false | false | false | 0 |
server_getspec (rpcsvc_request_t *req)
{
int32_t ret = -1;
int32_t op_errno = 0;
int32_t spec_fd = -1;
size_t file_len = 0;
char filename[ZR_PATH_MAX] = {0,};
struct stat stbuf = {0,};
char *volume = NULL;
int cookie = 0;
gf_getspec_req args = {0,};
gf_getspec_rsp rsp = {0,};
if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gf_getspec_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto fail;
}
volume = args.key;
ret = build_volfile_path (volume, filename, sizeof (filename));
if (ret > 0) {
/* to allocate the proper buffer to hold the file data */
ret = stat (filename, &stbuf);
if (ret < 0){
gf_log ("glusterd", GF_LOG_ERROR,
"Unable to stat %s (%s)",
filename, strerror (errno));
goto fail;
}
spec_fd = open (filename, O_RDONLY);
if (spec_fd < 0) {
gf_log ("glusterd", GF_LOG_ERROR,
"Unable to open %s (%s)",
filename, strerror (errno));
goto fail;
}
ret = file_len = stbuf.st_size;
} else {
op_errno = ENOENT;
}
if (file_len) {
rsp.spec = CALLOC (file_len+1, sizeof (char));
if (!rsp.spec) {
ret = -1;
op_errno = ENOMEM;
goto fail;
}
ret = read (spec_fd, rsp.spec, file_len);
close (spec_fd);
}
/* convert to XDR */
fail:
rsp.op_ret = ret;
if (op_errno)
rsp.op_errno = gf_errno_to_error (op_errno);
if (cookie)
rsp.op_errno = cookie;
if (!rsp.spec)
rsp.spec = "";
glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
(xdrproc_t)xdr_gf_getspec_rsp);
if (args.key)
free (args.key);//malloced by xdr
if (rsp.spec && (strcmp (rsp.spec, "")))
free (rsp.spec);
return 0;
} | false | false | false | false | false | 0 |
ReskinInterface() {
wxLogTrace(wxT("Function Start/End"), wxT("CSimpleProjectPanel::ReskinInterface - Function Begin"));
CMainDocument* pDoc = wxGetApp().GetDocument();
ProjectSelectionData* selData;
PROJECT* project;
char* ctrl_url;
CSimplePanelBase::ReskinInterface();
// Check to see if we need to reload the project icon
int ctrlCount = m_ProjectSelectionCtrl->GetCount();
for(int j=0; j<ctrlCount; j++) {
selData = (ProjectSelectionData*)m_ProjectSelectionCtrl->GetClientData(j);
ctrl_url = selData->project_url;
project = pDoc->state.lookup_project(ctrl_url);
wxBitmap* projectBM = GetProjectSpecificBitmap(ctrl_url);
m_ProjectSelectionCtrl->SetItemBitmap(j, *projectBM);
}
wxLogTrace(wxT("Function Start/End"), wxT("CSimpleProjectPanel::ReskinInterface - Function Begin"));
} | false | false | false | false | false | 0 |
adf4350_read(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
char *buf)
{
struct adf4350_state *st = iio_priv(indio_dev);
unsigned long long val;
int ret = 0;
mutex_lock(&indio_dev->mlock);
switch ((u32)private) {
case ADF4350_FREQ:
val = (u64)((st->r0_int * st->r1_mod) + st->r0_fract) *
(u64)st->fpfd;
do_div(val, st->r1_mod * (1 << st->r4_rf_div_sel));
/* PLL unlocked? return error */
if (gpio_is_valid(st->pdata->gpio_lock_detect))
if (!gpio_get_value(st->pdata->gpio_lock_detect)) {
dev_dbg(&st->spi->dev, "PLL un-locked\n");
ret = -EBUSY;
}
break;
case ADF4350_FREQ_REFIN:
if (st->clk)
st->clkin = clk_get_rate(st->clk);
val = st->clkin;
break;
case ADF4350_FREQ_RESOLUTION:
val = st->chspc;
break;
case ADF4350_PWRDOWN:
val = !!(st->regs[ADF4350_REG2] & ADF4350_REG2_POWER_DOWN_EN);
break;
default:
ret = -EINVAL;
val = 0;
}
mutex_unlock(&indio_dev->mlock);
return ret < 0 ? ret : sprintf(buf, "%llu\n", val);
} | false | false | false | false | false | 0 |
sc_on_tree_row_activated(GtkTreeView *treeview, GtkTreePath *path,
GtkTreeViewColumn *col, gpointer user_data)
{
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(sc_store);
if (gtk_tree_model_get_iter(model, &iter, path))
{
/* only hide dialog if selection was not a category */
if (sc_insert(model, &iter))
gtk_widget_hide(sc_dialog);
else
{ /* double click on a category to toggle the expand or collapse it */
if (gtk_tree_view_row_expanded(sc_tree, path))
gtk_tree_view_collapse_row(sc_tree, path);
else
gtk_tree_view_expand_row(sc_tree, path, FALSE);
}
}
} | false | false | false | false | false | 0 |
group_parse (struct group *group, struct argp_state *state, int key, char *arg)
{
if (group->parser)
{
error_t err;
state->hook = group->hook;
state->input = group->input;
state->child_inputs = group->child_inputs;
state->arg_num = group->args_processed;
err = (*group->parser)(key, arg, state);
group->hook = state->hook;
return err;
}
else
return EBADKEY;
} | false | false | false | false | false | 0 |
mini_get_shared_method_full (MonoMethod *method, gboolean all_vt, gboolean is_gsharedvt)
{
MonoGenericContext shared_context;
MonoMethod *declaring_method, *res;
gboolean partial = FALSE;
gboolean gsharedvt = FALSE;
MonoGenericContainer *class_container, *method_container = NULL;
if (method->is_generic || (method->klass->generic_container && !method->is_inflated)) {
declaring_method = method;
} else {
declaring_method = mono_method_get_declaring_generic_method (method);
}
if (declaring_method->is_generic)
shared_context = mono_method_get_generic_container (declaring_method)->context;
else
shared_context = declaring_method->klass->generic_container->context;
/* Handle gsharedvt/partial sharing */
if ((method != declaring_method && method->is_inflated && !mono_method_is_generic_sharable_full (method, FALSE, FALSE, TRUE)) ||
is_gsharedvt || mini_is_gsharedvt_sharable_method (method)) {
MonoGenericContext *context = mono_method_get_context (method);
MonoGenericInst *inst;
partial = mono_method_is_generic_sharable_full (method, FALSE, TRUE, FALSE);
gsharedvt = is_gsharedvt || (!partial && mini_is_gsharedvt_sharable_method (method));
class_container = declaring_method->klass->generic_container;
method_container = mono_method_get_generic_container (declaring_method);
/*
* Create the shared context by replacing the ref type arguments with
* type parameters, and keeping the rest.
*/
if (context)
inst = context->class_inst;
else
inst = shared_context.class_inst;
if (inst)
shared_context.class_inst = get_shared_inst (inst, shared_context.class_inst, class_container, all_vt, gsharedvt);
if (context)
inst = context->method_inst;
else
inst = shared_context.method_inst;
if (inst)
shared_context.method_inst = get_shared_inst (inst, shared_context.method_inst, method_container, all_vt, gsharedvt);
partial = TRUE;
}
res = mono_class_inflate_generic_method (declaring_method, &shared_context);
if (!partial) {
/* The result should be an inflated method whose parent is not inflated */
g_assert (!res->klass->is_inflated);
}
return res;
} | false | false | false | false | false | 0 |
event_music_pause()
{
if ( Event_music_enabled == FALSE ) {
nprintf(("EVENTMUSIC", "EVENTMUSIC ==> Requested a song switch when event music is not enabled\n"));
return;
}
if ( Event_music_level_inited == FALSE ) {
nprintf(("EVENTMUSIC", "EVENTMUSIC ==> Event music is not enabled\n"));
return;
}
if (Current_pattern == -1)
return;
Assert( Current_pattern >= 0 && Current_pattern < MAX_PATTERNS );
if ( audiostream_is_playing(Patterns[Current_pattern].handle) ) {
audiostream_stop(Patterns[Current_pattern].handle, 0); // stop current and don't rewind
}
} | false | false | false | false | false | 0 |
GetClassFromMacro(const wxString& macro)
{
wxString real(macro);
if (GetRealTypeIfTokenIsMacro(real))
{
Token* tk = TokenExists(real, nullptr, tkClass);
if (tk)
return tk->m_Name;
}
TRACE(_T("GetClassFromMacro() : macro='%s' -> real='%s'."), macro.wx_str(), real.wx_str());
return real;
} | false | false | false | false | false | 0 |
et_unrealize (GtkWidget *widget)
{
scroll_off (E_TABLE (widget));
if (GTK_WIDGET_CLASS (e_table_parent_class)->unrealize)
GTK_WIDGET_CLASS (e_table_parent_class)->unrealize (widget);
} | false | false | false | false | false | 0 |
tsi721_irqhandler(int irq, void *ptr)
{
struct rio_mport *mport = (struct rio_mport *)ptr;
struct tsi721_device *priv = mport->priv;
u32 dev_int;
u32 dev_ch_int;
u32 intval;
u32 ch_inte;
/* For MSI mode disable all device-level interrupts */
if (priv->flags & TSI721_USING_MSI)
iowrite32(0, priv->regs + TSI721_DEV_INTE);
dev_int = ioread32(priv->regs + TSI721_DEV_INT);
if (!dev_int)
return IRQ_NONE;
dev_ch_int = ioread32(priv->regs + TSI721_DEV_CHAN_INT);
if (dev_int & TSI721_DEV_INT_SR2PC_CH) {
/* Service SR2PC Channel interrupts */
if (dev_ch_int & TSI721_INT_SR2PC_CHAN(IDB_QUEUE)) {
/* Service Inbound Doorbell interrupt */
intval = ioread32(priv->regs +
TSI721_SR_CHINT(IDB_QUEUE));
if (intval & TSI721_SR_CHINT_IDBQRCV)
tsi721_dbell_handler(mport);
else
dev_info(&priv->pdev->dev,
"Unsupported SR_CH_INT %x\n", intval);
/* Clear interrupts */
iowrite32(intval,
priv->regs + TSI721_SR_CHINT(IDB_QUEUE));
ioread32(priv->regs + TSI721_SR_CHINT(IDB_QUEUE));
}
}
if (dev_int & TSI721_DEV_INT_SMSG_CH) {
int ch;
/*
* Service channel interrupts from Messaging Engine
*/
if (dev_ch_int & TSI721_INT_IMSG_CHAN_M) { /* Inbound Msg */
/* Disable signaled OB MSG Channel interrupts */
ch_inte = ioread32(priv->regs + TSI721_DEV_CHAN_INTE);
ch_inte &= ~(dev_ch_int & TSI721_INT_IMSG_CHAN_M);
iowrite32(ch_inte, priv->regs + TSI721_DEV_CHAN_INTE);
/*
* Process Inbound Message interrupt for each MBOX
*/
for (ch = 4; ch < RIO_MAX_MBOX + 4; ch++) {
if (!(dev_ch_int & TSI721_INT_IMSG_CHAN(ch)))
continue;
tsi721_imsg_handler(priv, ch);
}
}
if (dev_ch_int & TSI721_INT_OMSG_CHAN_M) { /* Outbound Msg */
/* Disable signaled OB MSG Channel interrupts */
ch_inte = ioread32(priv->regs + TSI721_DEV_CHAN_INTE);
ch_inte &= ~(dev_ch_int & TSI721_INT_OMSG_CHAN_M);
iowrite32(ch_inte, priv->regs + TSI721_DEV_CHAN_INTE);
/*
* Process Outbound Message interrupts for each MBOX
*/
for (ch = 0; ch < RIO_MAX_MBOX; ch++) {
if (!(dev_ch_int & TSI721_INT_OMSG_CHAN(ch)))
continue;
tsi721_omsg_handler(priv, ch);
}
}
}
if (dev_int & TSI721_DEV_INT_SRIO) {
/* Service SRIO MAC interrupts */
intval = ioread32(priv->regs + TSI721_RIO_EM_INT_STAT);
if (intval & TSI721_RIO_EM_INT_STAT_PW_RX)
tsi721_pw_handler(mport);
}
#ifdef CONFIG_RAPIDIO_DMA_ENGINE
if (dev_int & TSI721_DEV_INT_BDMA_CH) {
int ch;
if (dev_ch_int & TSI721_INT_BDMA_CHAN_M) {
dev_dbg(&priv->pdev->dev,
"IRQ from DMA channel 0x%08x\n", dev_ch_int);
for (ch = 0; ch < TSI721_DMA_MAXCH; ch++) {
if (!(dev_ch_int & TSI721_INT_BDMA_CHAN(ch)))
continue;
tsi721_bdma_handler(&priv->bdma[ch]);
}
}
}
#endif
/* For MSI mode re-enable device-level interrupts */
if (priv->flags & TSI721_USING_MSI) {
dev_int = TSI721_DEV_INT_SR2PC_CH | TSI721_DEV_INT_SRIO |
TSI721_DEV_INT_SMSG_CH | TSI721_DEV_INT_BDMA_CH;
iowrite32(dev_int, priv->regs + TSI721_DEV_INTE);
}
return IRQ_HANDLED;
} | false | false | false | false | false | 0 |
arena_run_reg_alloc(arena_run_t *run, arena_bin_t *bin)
{
void *ret;
unsigned i, mask, bit, regind;
assert(run->magic == ARENA_RUN_MAGIC);
assert(run->regs_minelm < bin->regs_mask_nelms);
/*
* Move the first check outside the loop, so that run->regs_minelm can
* be updated unconditionally, without the possibility of updating it
* multiple times.
*/
i = run->regs_minelm;
mask = run->regs_mask[i];
if (mask != 0) {
/* Usable allocation found. */
bit = ffs((int)mask) - 1;
regind = ((i << (SIZEOF_INT_2POW + 3)) + bit);
assert(regind < bin->nregs);
ret = (void *)(((uintptr_t)run) + bin->reg0_offset
+ (bin->reg_size * regind));
/* Clear bit. */
mask ^= (1U << bit);
run->regs_mask[i] = mask;
return (ret);
}
for (i++; i < bin->regs_mask_nelms; i++) {
mask = run->regs_mask[i];
if (mask != 0) {
/* Usable allocation found. */
bit = ffs((int)mask) - 1;
regind = ((i << (SIZEOF_INT_2POW + 3)) + bit);
assert(regind < bin->nregs);
ret = (void *)(((uintptr_t)run) + bin->reg0_offset
+ (bin->reg_size * regind));
/* Clear bit. */
mask ^= (1U << bit);
run->regs_mask[i] = mask;
/*
* Make a note that nothing before this element
* contains a free region.
*/
run->regs_minelm = i; /* Low payoff: + (mask == 0); */
return (ret);
}
}
/* Not reached. */
assert(0);
return (NULL);
} | false | false | false | false | true | 1 |
GetRGBACharPixelData(int x1, int y1,
int x2, int y2,
int front,
unsigned char* data)
{
int y_low, y_hi;
int x_low, x_hi;
int width, height;
// set the current window
this->MakeCurrent();
if (y1 < y2)
{
y_low = y1;
y_hi = y2;
}
else
{
y_low = y2;
y_hi = y1;
}
if (x1 < x2)
{
x_low = x1;
x_hi = x2;
}
else
{
x_low = x2;
x_hi = x1;
}
// Must clear previous errors first.
while(glGetError() != GL_NO_ERROR)
{
;
}
if (front)
{
glReadBuffer(static_cast<GLenum>(this->GetFrontLeftBuffer()));
}
else
{
glReadBuffer(static_cast<GLenum>(this->GetBackLeftBuffer()));
}
width = abs(x_hi - x_low) + 1;
height = abs(y_hi - y_low) + 1;
glDisable( GL_SCISSOR_TEST );
// Turn of texturing in case it is on - some drivers have a problem
// getting / setting pixels with texturing enabled.
glDisable( GL_TEXTURE_2D );
glReadPixels( x_low, y_low, width, height, GL_RGBA, GL_UNSIGNED_BYTE,
data);
if (glGetError() != GL_NO_ERROR)
{
return VTK_ERROR;
}
else
{
return VTK_OK;
}
} | false | false | false | false | false | 0 |
need_delay(void)
{
static gint64 time_prev = 0; /* time in microseconds */
gint64 time_now;
GTimeVal t;
const gint timeout = 500; /* delay in milliseconds */
g_get_current_time(&t);
time_now = ((gint64) t.tv_sec * G_USEC_PER_SEC) + t.tv_usec;
/* delay keypresses for 0.5 seconds */
if (time_now < (time_prev + (timeout * 1000)))
return TRUE;
if (check_line_data.check_while_typing_idle_source_id == 0)
{
check_line_data.check_while_typing_idle_source_id =
plugin_timeout_add(geany_plugin, timeout, check_lines, NULL);
}
/* set current time for the next key press */
time_prev = time_now;
return FALSE;
} | false | false | false | false | false | 0 |
cconnect(void *vp)
{
char *cp, *cq;
int omsgCount = msgCount;
if (mb.mb_type == MB_IMAP && mb.mb_sock.s_fd > 0) {
fprintf(stderr, "Already connected.\n");
return 1;
}
unset_allow_undefined = 1;
unset_internal("disconnected");
cp = protbase(mailname);
if (strncmp(cp, "imap://", 7) == 0)
cp += 7;
else if (strncmp(cp, "imaps://", 8) == 0)
cp += 8;
if ((cq = strchr(cp, ':')) != NULL)
*cq = '\0';
unset_internal(savecat("disconnected-", cp));
unset_allow_undefined = 0;
if (mb.mb_type == MB_CACHE) {
imap_setfile1(mailname, 0, edit, 1);
if (msgCount > omsgCount)
newmailinfo(omsgCount);
}
return 0;
} | false | false | false | false | false | 0 |
xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg)
{
if (seg->trbs) {
dma_pool_free(xhci->segment_pool, seg->trbs, seg->dma);
seg->trbs = NULL;
}
kfree(seg);
} | false | false | false | false | false | 0 |
pprogramdef(def)
definition *def;
{
version_list *vers;
proc_list *proc;
puldefine(def->def_name, def->def.pr.prog_num);
for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
puldefine(vers->vers_name, vers->vers_num);
for (proc = vers->procs; proc != NULL; proc = proc->next) {
if (!define_printed(proc, def->def.pr.versions)) {
puldefine(proc->proc_name, proc->proc_num);
}
pprocdef(proc, vers);
}
}
} | false | false | false | false | false | 0 |
getFEN() {
static string fen;
int i,j,ec;
piece p,c=EMPTY;
char n=0;
fen="\0";
for(i=7;i>=0;i--) {
ec=0;
for(j=0;j<8;j++) {
p=square[j][i]&PIECE_MASK;
c=square[j][i]&COLOR_MASK;
if ((p!=EMPTY)&&(ec)) {
fen+=(char)('0'+ec);
ec=0;
}
switch(p) {
case PAWN: n='P'; break;
case ROOK: n='R'; break;
case KNIGHT: n='N'; break;
case BISHOP: n='B'; break;
case QUEEN: n='Q'; break;
case KING: n='K'; break;
case EMPTY:
++ec;
n=0;
break;
}
if (n) {
if (c==BLACK)
n=(char)tolower(n);
fen+=n;
}
}
if (ec) fen+=(char)('0'+ec);
if (i>0) fen+='/';
}
if (sidehint)
fen+=" w ";
else
fen+=" b ";
ec=0;
if (maycastle[0]) { fen+="K"; ++ec; }
if (maycastle[2]) { fen+="Q"; ++ec; }
if (maycastle[1]) { fen+="k"; ++ec; }
if (maycastle[3]) { fen+="q"; ++ec; }
if (!ec) fen+="-";
fen+=" ";
if (ep[0]>=0) { fen+='a'+ep[0]; fen+='1'+ep[1]; }
else { fen+='-'; }
fen+=" ";
fen+="0 1";
return(fen);
} | false | false | false | false | false | 0 |
PyCurses_Init_Pair(PyObject *self, PyObject *args)
{
short pair, f, b;
PyCursesInitialised;
PyCursesInitialisedColor;
if (PyTuple_Size(args) != 3) {
PyErr_SetString(PyExc_TypeError, "init_pair requires 3 arguments");
return NULL;
}
if (!PyArg_ParseTuple(args, "hhh;pair, f, b", &pair, &f, &b)) return NULL;
return PyCursesCheckERR(init_pair(pair, f, b), "init_pair");
} | false | false | false | false | false | 0 |
Init(PLStream *pls)
{
XwDev *dev = (XwDev *) pls->dev;
XwDisplay *xwd = (XwDisplay *) dev->xwd;
Window root;
int x, y;
dbug_enter("Init");
/* If not plotting into a child window, need to create main window now */
if (pls->window_id == 0) {
dev->is_main = TRUE;
InitMain(pls);
}
else {
dev->is_main = FALSE;
dev->window = pls->window_id;
}
/* Initialize colors */
if (noinitcolors == 0) InitColors(pls);
XSetWindowColormap( xwd->display, dev->window, xwd->map );
/* Set up GC for ordinary draws */
if ( ! dev->gc)
dev->gc = XCreateGC(xwd->display, dev->window, 0, 0);
/* Set up GC for rubber-band draws */
if ( ! xwd->gcXor) {
XGCValues gcValues;
unsigned long mask;
gcValues.background = xwd->cmap0[0].pixel;
gcValues.foreground = 0xFF;
gcValues.function = GXxor;
mask = GCForeground | GCBackground | GCFunction;
xwd->gcXor = XCreateGC(xwd->display, dev->window, mask, &gcValues);
}
/* Get initial drawing area dimensions */
(void) XGetGeometry(xwd->display, dev->window, &root, &x, &y,
&dev->width, &dev->height, &dev->border, &xwd->depth);
dev->init_width = dev->width;
dev->init_height = dev->height;
/* Set up flags that determine what we are writing to */
/* If nopixmap is set, ignore db */
if (pls->nopixmap) {
dev->write_to_pixmap = 0;
pls->db = 0;
}
else {
dev->write_to_pixmap = 1;
}
dev->write_to_window = ! pls->db;
/* Create pixmap for holding plot image (for expose events). */
if (dev->write_to_pixmap)
CreatePixmap(pls);
/* Set drawing color */
plD_state_xw(pls, PLSTATE_COLOR0);
XSetWindowBackground(xwd->display, dev->window, xwd->cmap0[0].pixel);
XSetBackground(xwd->display, dev->gc, xwd->cmap0[0].pixel);
/* If main window, need to map it and wait for exposure */
if (dev->is_main)
MapMain(pls);
} | false | false | false | false | false | 0 |
parse_keys(struct nl_msg *msg, char **argv, int argc)
{
struct nlattr *keys;
int i = 0;
bool have_default = false;
char keybuf[13];
if (!argc)
return 1;
NLA_PUT_FLAG(msg, NL80211_ATTR_PRIVACY);
keys = nla_nest_start(msg, NL80211_ATTR_KEYS);
if (!keys)
return -ENOBUFS;
do {
char *arg = *argv;
int pos = 0, keylen;
struct nlattr *key = nla_nest_start(msg, ++i);
char *keydata;
if (!key)
return -ENOBUFS;
if (arg[pos] == 'd') {
NLA_PUT_FLAG(msg, NL80211_KEY_DEFAULT);
pos++;
if (arg[pos] == ':')
pos++;
have_default = true;
}
if (!isdigit(arg[pos]))
goto explain;
NLA_PUT_U8(msg, NL80211_KEY_IDX, arg[pos++] - '0');
if (arg[pos++] != ':')
goto explain;
keydata = arg + pos;
switch (strlen(keydata)) {
case 10:
keydata = hex2bin(keydata, keybuf);
case 5:
NLA_PUT_U32(msg, NL80211_KEY_CIPHER, 0x000FAC01);
keylen = 5;
break;
case 26:
keydata = hex2bin(keydata, keybuf);
case 13:
NLA_PUT_U32(msg, NL80211_KEY_CIPHER, 0x000FAC05);
keylen = 13;
break;
default:
goto explain;
}
if (!keydata)
goto explain;
NLA_PUT(msg, NL80211_KEY_DATA, keylen, keydata);
argv++;
argc--;
/* one key should be TX key */
if (!have_default && !argc)
NLA_PUT_FLAG(msg, NL80211_KEY_DEFAULT);
nla_nest_end(msg, key);
} while (argc);
nla_nest_end(msg, keys);
return 0;
nla_put_failure:
return -ENOBUFS;
explain:
fprintf(stderr, "key must be [d:]index:data where\n"
" 'd:' means default (transmit) key\n"
" 'index:' is a single digit (0-3)\n"
" 'data' must be 5 or 13 ascii chars\n"
" or 10 or 26 hex digits\n"
"for example: d:2:6162636465 is the same as d:2:abcde\n");
return 2;
} | false | false | false | false | true | 1 |
ownSelection(ipw)
IMProtocolWidget ipw;
{
Display *dpy = XtDisplay((Widget)ipw);
Time time = XtLastTimestampProcessed(dpy);
TRACE(("IMProtocolWidget:ownSelection()\n"));
if (!XtOwnSelection((Widget)ipw, ipw->imp.server_atom, time,
convertSelection, loseSelection,
(XtSelectionDoneProc)NULL)) {
DPRINT(("cannot own selection"));
return -1;
}
DPRINT(("selection atom:%ld owner: %08lx (%ld)\n", ipw->imp.server_atom,
XtWindow((Widget)ipw), XtWindow((Widget)ipw)));
return 0;
} | false | false | false | false | false | 0 |
get_Vth()
{
/**/
if(verbose & 1)
cout << name() << " get_Vth OC"
<< " driving=" << getDriving()
<< " DrivingState=" << getDrivingState()
<< " bDrivenState=" << bDrivenState
<< " Vth=" << Vth
<< " VthIn=" << VthIn
<< " bPullUp=" << bPullUp << endl;
/**/
if(getDriving() && !getDrivingState())
return 0.0;
return bPullUp ? Vpullup : VthIn;
} | false | false | false | false | false | 0 |
qla2x00_write_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t data)
{
int rval;
mbx_cmd_t mc;
mbx_cmd_t *mcp = &mc;
if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) &&
!IS_QLA27XX(vha->hw))
return QLA_FUNCTION_FAILED;
ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1182,
"Entered %s.\n", __func__);
mcp->mb[0] = MBC_WRITE_SERDES;
mcp->mb[1] = addr;
if (IS_QLA2031(vha->hw))
mcp->mb[2] = data & 0xff;
else
mcp->mb[2] = data;
mcp->mb[3] = 0;
mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
mcp->in_mb = MBX_0;
mcp->tov = MBX_TOV_SECONDS;
mcp->flags = 0;
rval = qla2x00_mailbox_command(vha, mcp);
if (rval != QLA_SUCCESS) {
ql_dbg(ql_dbg_mbx, vha, 0x1183,
"Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
} else {
ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1184,
"Done %s.\n", __func__);
}
return rval;
} | false | false | false | false | false | 0 |
tr_ilg(saidx_t n) {
#if defined(BUILD_DIVSUFSORT64)
return (n >> 32) ?
((n >> 48) ?
((n >> 56) ?
56 + lg_table[(n >> 56) & 0xff] :
48 + lg_table[(n >> 48) & 0xff]) :
((n >> 40) ?
40 + lg_table[(n >> 40) & 0xff] :
32 + lg_table[(n >> 32) & 0xff])) :
((n & 0xffff0000) ?
((n & 0xff000000) ?
24 + lg_table[(n >> 24) & 0xff] :
16 + lg_table[(n >> 16) & 0xff]) :
((n & 0x0000ff00) ?
8 + lg_table[(n >> 8) & 0xff] :
0 + lg_table[(n >> 0) & 0xff]));
#else
return (n & 0xffff0000) ?
((n & 0xff000000) ?
24 + lg_table[(n >> 24) & 0xff] :
16 + lg_table[(n >> 16) & 0xff]) :
((n & 0x0000ff00) ?
8 + lg_table[(n >> 8) & 0xff] :
0 + lg_table[(n >> 0) & 0xff]);
#endif
} | false | false | false | false | false | 0 |
print_hindexed(int dtype, struct trdtype **dtrace, int nlev, int fl_idx)
{
int i; /* favourite index */
int count; /* datatype count */
indent(nlev);
count = (*dtrace)->trd_count;
++(*dtrace);
sprintf(fmtbuf, "%s (%d)", dtbasic[dtype], count);
if (obuf) strcat(obuf, fmtbuf);
else printf("%s", fmtbuf);
colcount += strlen(fmtbuf);
for (i = 0; i < count; ++i) {
sprintf(fmtbuf, " (%d, %d)", (*dtrace)->trd_length,
DISP(fl_idx, (*dtrace)->trd_disp));
if (obuf) strcat(obuf, fmtbuf);
else printf("%s", fmtbuf);
colcount += strlen(fmtbuf);
++(*dtrace);
}
nlifconst = 1;
print_datatype(dtrace, nlev + 1);
} | false | true | false | false | false | 1 |
changeMode(GYRO_MODE _newMode)
{
m_mode = _newMode;
char commande[3];
switch(m_mode)
{
case RATE :
commande[0] = 'R';
break;
case INTEGRATED_ANGLE :
commande[0] = 'P';
break;
case INCREMENTAL_ANGLE :
commande[0] = 'A'; // incremental.
break;
}
commande[1] = 0x0A; commande[2] = 0;
// we send the command four times to be sure that the command will be interpreted by the sensor.
if(m_serialPort->Write( commande, 3*sizeof(char)) <= 0)
{
THROW_EXCEPTION("can't write on serial port");
}
} | false | false | false | false | false | 0 |
headingAlignment(unsigned long alignment_)
{
if (headingAlignment()!=alignment_)
{
freeze();
unsigned i,n=numColumns();
for (i=0;i<n;i++) if (tableColumn(i)->headingAlignment()==headingAlignment()) tableColumn(i)->headingAlignment(alignment_);
n=hiddenColumnList()->count();
for (i=0;i<n;i++)
{
MSTableColumn *tc=(MSTableColumn *)hiddenColumnList()->array(i);
if (tc->headingAlignment()==headingAlignment()) tc->headingAlignment(alignment_);
}
_headingAlignment=alignment_;
unfreeze();
}
} | false | false | false | false | false | 0 |
asus_wmi_hwmon_init(struct asus_wmi *asus)
{
struct device *hwmon;
hwmon = hwmon_device_register_with_groups(&asus->platform_device->dev,
"asus", asus,
hwmon_attribute_groups);
if (IS_ERR(hwmon)) {
pr_err("Could not register asus hwmon device\n");
return PTR_ERR(hwmon);
}
return 0;
} | false | false | false | false | false | 0 |
ParseSwitch(Instruction *&Inst, PerFunctionState &PFS) {
LocTy CondLoc, BBLoc;
Value *Cond;
BasicBlock *DefaultBB;
if (ParseTypeAndValue(Cond, CondLoc, PFS) ||
ParseToken(lltok::comma, "expected ',' after switch condition") ||
ParseTypeAndBasicBlock(DefaultBB, BBLoc, PFS) ||
ParseToken(lltok::lsquare, "expected '[' with switch table"))
return true;
if (!Cond->getType()->isIntegerTy())
return Error(CondLoc, "switch condition must have integer type");
// Parse the jump table pairs.
SmallPtrSet<Value*, 32> SeenCases;
SmallVector<std::pair<ConstantInt*, BasicBlock*>, 32> Table;
while (Lex.getKind() != lltok::rsquare) {
Value *Constant;
BasicBlock *DestBB;
if (ParseTypeAndValue(Constant, CondLoc, PFS) ||
ParseToken(lltok::comma, "expected ',' after case value") ||
ParseTypeAndBasicBlock(DestBB, PFS))
return true;
if (!SeenCases.insert(Constant))
return Error(CondLoc, "duplicate case value in switch");
if (!isa<ConstantInt>(Constant))
return Error(CondLoc, "case value is not a constant integer");
Table.push_back(std::make_pair(cast<ConstantInt>(Constant), DestBB));
}
Lex.Lex(); // Eat the ']'.
SwitchInst *SI = SwitchInst::Create(Cond, DefaultBB, Table.size());
for (unsigned i = 0, e = Table.size(); i != e; ++i)
SI->addCase(Table[i].first, Table[i].second);
Inst = SI;
return false;
} | false | false | false | false | false | 0 |
addphcon(phfig_list *ptfig, char orient, const char *cname, long x, long y, char layer, long width)
{
phcon_list *ptcon, *ptscan;
chain_list *pt, *ptchain = NULL;
long index;
char *conname;
conname = namealloc(cname);
/* check consistency */
if (layer < 0 || layer > LAST_LAYER) {
(void)fflush(stdout);
(void)fprintf(stderr, "\n*** mbk error *** illegal addphcon\n");
(void)fprintf(stderr, "figure : %s\n", ptfig->NAME);
(void)fprintf(stderr, "code layer is %ld in %s\n", (long)layer, conname);
EXIT(1);
}
if (orient != NORTH && orient != EAST && orient != SOUTH &&
orient != WEST) {
(void)fflush(stdout);
(void)fprintf(stderr, "\n*** mbk error *** illegal addphcon\n");
(void)fprintf(stderr, "figure : %s\n", ptfig->NAME);
(void)fprintf(stderr, "orientation is %ld in : %s\n", (long)orient,
conname);
EXIT(1);
}
#if 0
if (x < ptfig->XAB1 || x > ptfig->XAB2 || y < ptfig->YAB1
|| y > ptfig->YAB2) {
(void)fflush(stdout);
(void)fprintf(stderr, "\n*** mbk error *** illegal addphcon\n");
(void)fprintf(stderr, "connector %s (%ld, %ld) not in abutement box\n",
conname, x, y);
EXIT(1);
}
#endif
/* update connector list */
ptcon = (phcon_list *)mbkalloc(sizeof(phcon_list));
ptcon->INDEX = 0;
ptcon->XCON = x;
ptcon->YCON = y;
ptcon->WIDTH = width;
ptcon->ORIENT = orient;
ptcon->NAME = conname;
ptcon->LAYER = layer;
ptcon->USER = NULL;
ptcon->NEXT = ptfig->PHCON;
ptfig->PHCON = ptcon;
/* update index list with topological sort */
for (ptscan = ptfig->PHCON; ptscan; ptscan = ptscan->NEXT) {
if (conname == ptscan->NAME) /* if such a connector already exists*/
ptchain = addsorted(ptchain, ptscan);
}
for (pt = ptchain, index = 0; pt != NULL; index++, pt = pt->NEXT)
((phcon_list *)pt->DATA)->INDEX = index;
freechain(ptchain);
if (TRACE_MODE == 'Y') {
(void)fprintf(stdout, "--- mbk --- addphcon : ");
(void)fprintf(stdout, "%s.%ld x=%ld y=%ld w=%ld layer=%d\n", conname,
index, x, y, width, layer);
}
return ptcon;
} | false | false | false | false | false | 0 |
zGetSeqBlock(zSequence* seq, coor_t pos){
zSeqBlock* block;
block = zListMoveFirst(&seq->seq);
while(block != NULL){
if((block->pos <= pos) && (block->pos + block->size > pos)){
zListMoveCurrentToFirst(&seq->seq);
return block;
}
block = zListMoveNext(&seq->seq);
}
return zLoadSeq(seq,pos);
} | false | false | false | false | false | 0 |
allGray() const
{
#ifndef QT_NO_IMAGE_TRUECOLOR
if (depth()==32) {
int p = width()*height();
QRgb* b = (QRgb*)bits();
while (p--)
if (!isGray(*b++))
return false;
#ifndef QT_NO_IMAGE_16_BIT
} else if (depth()==16) {
int p = width()*height();
ushort* b = (ushort*)bits();
while (p--)
if (!is16BitGray(*b++))
return false;
#endif
} else
#endif //QT_NO_IMAGE_TRUECOLOR
{
if (!data->ctbl) return true;
for (int i=0; i<numColors(); i++)
if (!isGray(data->ctbl[i]))
return false;
}
return false;
} | false | false | false | false | false | 0 |
ex_cd(eap)
exarg_T *eap;
{
char_u *new_dir;
char_u *tofree;
new_dir = eap->arg;
#if !defined(UNIX) && !defined(VMS)
/* for non-UNIX ":cd" means: print current directory */
if (*new_dir == NUL)
ex_pwd(NULL);
else
#endif
{
#ifdef FEAT_AUTOCMD
if (allbuf_locked())
return;
#endif
if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged()
&& !eap->forceit)
{
EMSG(_("E747: Cannot change directory, buffer is modified (add ! to override)"));
return;
}
/* ":cd -": Change to previous directory */
if (STRCMP(new_dir, "-") == 0)
{
if (prev_dir == NULL)
{
EMSG(_("E186: No previous directory"));
return;
}
new_dir = prev_dir;
}
/* Save current directory for next ":cd -" */
tofree = prev_dir;
if (mch_dirname(NameBuff, MAXPATHL) == OK)
prev_dir = vim_strsave(NameBuff);
else
prev_dir = NULL;
#if defined(UNIX) || defined(VMS)
/* for UNIX ":cd" means: go to home directory */
if (*new_dir == NUL)
{
/* use NameBuff for home directory name */
# ifdef VMS
char_u *p;
p = mch_getenv((char_u *)"SYS$LOGIN");
if (p == NULL || *p == NUL) /* empty is the same as not set */
NameBuff[0] = NUL;
else
vim_strncpy(NameBuff, p, MAXPATHL - 1);
# else
expand_env((char_u *)"$HOME", NameBuff, MAXPATHL);
# endif
new_dir = NameBuff;
}
#endif
if (new_dir == NULL || vim_chdir(new_dir))
EMSG(_(e_failed));
else
{
post_chdir(eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir);
/* Echo the new current directory if the command was typed. */
if (KeyTyped || p_verbose >= 5)
ex_pwd(eap);
}
vim_free(tofree);
}
} | false | false | false | false | false | 0 |
heim_ntlm_v1_base_session(void *key, size_t len,
struct ntlm_buf *session)
{
EVP_MD_CTX *m;
session->length = MD4_DIGEST_LENGTH;
session->data = malloc(session->length);
if (session->data == NULL) {
session->length = 0;
return ENOMEM;
}
m = EVP_MD_CTX_create();
if (m == NULL) {
heim_ntlm_free_buf(session);
return ENOMEM;
}
EVP_DigestInit_ex(m, EVP_md4(), NULL);
EVP_DigestUpdate(m, key, len);
EVP_DigestFinal_ex(m, session->data, NULL);
EVP_MD_CTX_destroy(m);
return 0;
} | false | false | false | false | false | 0 |
reverse(string& base) {
string result;
string::const_iterator i=base.begin();
const string::const_iterator n = base.end();
while ( i != n) {
if ((*i & 0x80) == 0x00) {
result.insert(result.begin(),*i);
i++;
}
else if ((*i & 0xe0) == 0xc0 && i + 1 != n && (i[1] & 0xc0) == 0x80) {
result.insert(result.begin(),i,i+2);
i += 2;
}
else if ((*i & 0xf0) == 0xe0 && i + 1 != n && i + 2 != n && (i[1] & 0xc0) == 0x80 && (i[2] & 0xc0) == 0x80) {
result.insert(result.begin(),i,i+3);
i += 3;
}
else {
return false;
}
}
base=result;
return true;
} | false | false | false | false | false | 0 |
span(parse_iterator first,
parse_iterator last, char const* name)
{
out << "<phrase role=\"" << name << "\">";
while (first != last)
detail::print_char(*first++, out.get());
out << "</phrase>";
} | false | false | false | false | false | 0 |
tomoyo_poll_control(struct file *file, poll_table *wait)
{
struct tomoyo_io_buffer *head = file->private_data;
if (head->poll)
return head->poll(file, wait) | POLLOUT | POLLWRNORM;
return POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM;
} | false | false | false | false | false | 0 |
uppercase(lenpos_t subPos, lenpos_t subLen) {
if ((subLen == measure_length) || (subPos + subLen > sLen)) {
subLen = sLen - subPos; // don't apply past end of string
}
for (lenpos_t i = subPos; i < subPos + subLen; i++) {
if (s[i] < 'a' || s[i] > 'z')
continue;
else
s[i] = static_cast<char>(s[i] - 'a' + 'A');
}
return *this;
} | false | false | false | false | false | 0 |
ReadNodeTransformation( Node* pNode, TransformType pType)
{
if( mReader->isEmptyElement())
return;
std::string tagName = mReader->getNodeName();
Transform tf;
tf.mType = pType;
// read SID
int indexSID = TestAttribute( "sid");
if( indexSID >= 0)
tf.mID = mReader->getAttributeValue( indexSID);
// how many parameters to read per transformation type
static const unsigned int sNumParameters[] = { 9, 4, 3, 3, 7, 16 };
const char* content = GetTextContent();
// read as many parameters and store in the transformation
for( unsigned int a = 0; a < sNumParameters[pType]; a++)
{
// read a number
content = fast_atoreal_move<float>( content, tf.f[a]);
// skip whitespace after it
SkipSpacesAndLineEnd( &content);
}
// place the transformation at the queue of the node
pNode->mTransforms.push_back( tf);
// and consume the closing tag
TestClosing( tagName.c_str());
} | false | false | false | false | false | 0 |
InitNewLine(char* NewLine, const int ColsPerPage){
memset( NewLine, ' ', ColsPerPage);
NewLine[ColsPerPage] = '\0';
CTermCharAttr DefAttr; DefAttr.SetToDefault(); DefAttr.SetNeedUpdate(true);
memset16( GetLineAttr(NewLine, ColsPerPage), DefAttr.AsShort(), ColsPerPage);
} | false | false | false | false | false | 0 |
write(dimeOutput * const file)
{
bool ret = true;
if (!this->isDeleted()) {
this->preWrite(file);
this->writeCoords(file);
if (flags != 0) {
file->writeGroupCode(70);
file->writeInt16(flags);
}
ret = dimeEntity::write(file);
}
return ret;
} | false | false | false | false | false | 0 |
check_static_variable_definition (tree decl, tree type)
{
/* Can't check yet if we don't know the type. */
if (dependent_type_p (type))
return 0;
/* If DECL is declared constexpr, we'll do the appropriate checks
in check_initializer. */
if (DECL_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl))
return 0;
else if (cxx_dialect >= cxx0x && !INTEGRAL_OR_ENUMERATION_TYPE_P (type))
{
if (!COMPLETE_TYPE_P (type))
error ("in-class initialization of static data member %q#D of "
"incomplete type", decl);
else if (literal_type_p (type))
permerror (input_location,
"%<constexpr%> needed for in-class initialization of "
"static data member %q#D of non-integral type", decl);
else
error ("in-class initialization of static data member %q#D of "
"non-literal type", decl);
return 1;
}
/* Motion 10 at San Diego: If a static const integral data member is
initialized with an integral constant expression, the initializer
may appear either in the declaration (within the class), or in
the definition, but not both. If it appears in the class, the
member is a member constant. The file-scope definition is always
required. */
if (!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE)
{
error ("invalid in-class initialization of static data member "
"of non-integral type %qT",
type);
return 1;
}
else if (!CP_TYPE_CONST_P (type))
error ("ISO C++ forbids in-class initialization of non-const "
"static member %qD",
decl);
else if (!INTEGRAL_OR_ENUMERATION_TYPE_P (type))
pedwarn (input_location, OPT_Wpedantic, "ISO C++ forbids initialization of member constant "
"%qD of non-integral type %qT", decl, type);
return 0;
} | false | false | false | false | false | 0 |
get_free_rreg (struct i915_fragment_program *p,
GLuint live_regs)
{
int bit = ffs(~live_regs);
if (!bit) {
i915_program_error(p, "Can't find free R reg");
return UREG_BAD;
}
return UREG(REG_TYPE_R, bit - 1);
} | false | false | false | false | false | 0 |
writeStringItem(const std::string & name, const std::string & data)
{
if( m_comma )
m_socket << ",";
if( name != "" )
m_socket << name << ":";
m_socket << "\"" << encodeString( data ) << "\"";
} | false | false | false | false | false | 0 |
createOpenRecentMenu() {
m_openRecentFileMenu = new QMenu(tr("&Open Recent Files"), this);
for (int i = 0; i < MaxRecentFiles; ++i) {
m_openRecentFileActs[i] = new QAction(this);
m_openRecentFileActs[i]->setVisible(false);
connect(m_openRecentFileActs[i], SIGNAL(triggered()),this, SLOT(openRecentOrExampleFile()));
}
for (int i = 0; i < MaxRecentFiles; ++i) {
m_openRecentFileMenu->addAction(m_openRecentFileActs[i]);
}
updateRecentFileActions();
} | false | false | false | false | false | 0 |
prefs_themes_free_names(ThemesData *tdata)
{
GList *names;
names = tdata->names;
while (names != NULL) {
ThemeName *tn = (ThemeName *)(names->data);
tn->item = NULL;
g_free(tn->name);
g_free(tn);
names = g_list_next(names);
}
g_list_free(names);
tdata->names = NULL;
} | false | false | false | false | false | 0 |
abi_widget_set_style(AbiWidget * w, gchar * szName)
{
UT_return_val_if_fail ( w != NULL, FALSE );
UT_return_val_if_fail ( IS_ABI_WIDGET(w), FALSE );
UT_return_val_if_fail ( w->priv->m_pFrame, FALSE );
UT_return_val_if_fail ( szName, false );
AP_UnixFrame * pFrame = (AP_UnixFrame *) w->priv->m_pFrame;
UT_return_val_if_fail(pFrame, false);
FV_View * pView = static_cast<FV_View *>(pFrame->getCurrentView());
UT_return_val_if_fail(pView, false);
bool res = pView->setStyle(szName, false);
pView->notifyListeners(AV_CHG_MOTION | AV_CHG_HDRFTR); // I stole this mask from ap_EditMethods; looks weird to me though - MARCM
return res;
} | false | false | false | false | false | 0 |
CreateTexture_3DGS_MDL4(const unsigned char* szData,
unsigned int iType,
unsigned int* piSkip)
{
ai_assert(NULL != piSkip);
const MDL::Header *pcHeader = (const MDL::Header*)mBuffer; //the endianess is allready corrected in the InternReadFile_3DGS_MDL345 function
if (iType == 1 || iType > 3)
{
DefaultLogger::get()->error("Unsupported texture file format");
return;
}
const bool bNoRead = *piSkip == UINT_MAX;
// allocate a new texture object
aiTexture* pcNew = new aiTexture();
pcNew->mWidth = pcHeader->skinwidth;
pcNew->mHeight = pcHeader->skinheight;
if (bNoRead)pcNew->pcData = bad_texel;
ParseTextureColorData(szData,iType,piSkip,pcNew);
// store the texture
if (!bNoRead)
{
if (!this->pScene->mNumTextures)
{
pScene->mNumTextures = 1;
pScene->mTextures = new aiTexture*[1];
pScene->mTextures[0] = pcNew;
}
else
{
aiTexture** pc = pScene->mTextures;
pScene->mTextures = new aiTexture*[pScene->mNumTextures+1];
for (unsigned int i = 0; i < this->pScene->mNumTextures;++i)
pScene->mTextures[i] = pc[i];
pScene->mTextures[pScene->mNumTextures] = pcNew;
pScene->mNumTextures++;
delete[] pc;
}
}
else {
pcNew->pcData = NULL;
delete pcNew;
}
return;
} | false | false | false | false | false | 0 |
gsb_currency_link_config_create_list ( void )
{
GtkListStore * model;
GtkWidget * treeview;
gint i;
gchar *title[] = {
"",
_("First currency"),
"",
_("Exchange"),
_("Second currency"),
_("Modified date"),
_("Invalid"),
};
GtkCellRenderer *cell_renderer;
/* Create tree store
LINK_1_COLUMN,
LINK_CURRENCY1_COLUMN,
LINK_EQUAL_COLUMN,
LINK_EXCHANGE_COLUMN,
LINK_CURRENCY2_COLUMN,
LINK_DATE_COLUMN,
LINK_NUMBER_COLUMN */
model = gtk_list_store_new ( NUM_LINKS_COLUMNS,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_INT );
/* Create tree tree_view */
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL(model));
g_object_unref (G_OBJECT(model));
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE);
/* for all the columns it's a text */
cell_renderer = gtk_cell_renderer_text_new ();
g_object_set ( G_OBJECT ( cell_renderer),
"xalign", 0.5,
NULL );
/* fill the columns : set LINK_NUMBER_COLUMN and not NUM_LINKS_COLUMNS because
* the last value of the model mustn't be to text...
* so LINK_NUMBER_COLUMN must be the first column after the last column showed */
for (i=0 ; i< LINK_NUMBER_COLUMN; i++ )
{
GtkTreeViewColumn *column = NULL;
if ( i == LINK_INVALID_COLUMN )
{
column = gtk_tree_view_column_new_with_attributes ( title[i],
gtk_cell_renderer_pixbuf_new (),
"stock-id", i,
NULL );
;
}
else
{
column = gtk_tree_view_column_new_with_attributes ( title[i],
cell_renderer,
"text", i,
NULL );
gtk_tree_view_column_set_sizing ( column,
GTK_TREE_VIEW_COLUMN_AUTOSIZE );
gtk_tree_view_column_set_expand ( column, TRUE );
}
gtk_tree_view_column_set_expand ( column, TRUE );
gtk_tree_view_append_column ( GTK_TREE_VIEW(treeview),
column );
}
/* Sort columns accordingly */
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(model),
LINK_CURRENCY1_COLUMN, GTK_SORT_ASCENDING);
return treeview;
} | false | false | false | false | false | 0 |
osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * STp, char * name)
{
struct device *osst_member;
int err;
osst_member = device_create(osst_sysfs_class, device, dev, STp,
"%s", name);
if (IS_ERR(osst_member)) {
printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
return PTR_ERR(osst_member);
}
err = device_create_file(osst_member, &dev_attr_ADR_rev);
if (err)
goto err_out;
err = device_create_file(osst_member, &dev_attr_media_version);
if (err)
goto err_out;
err = device_create_file(osst_member, &dev_attr_capacity);
if (err)
goto err_out;
err = device_create_file(osst_member, &dev_attr_BOT_frame);
if (err)
goto err_out;
err = device_create_file(osst_member, &dev_attr_EOD_frame);
if (err)
goto err_out;
err = device_create_file(osst_member, &dev_attr_file_count);
if (err)
goto err_out;
return 0;
err_out:
osst_sysfs_destroy(dev);
return err;
} | false | false | false | false | false | 0 |
cr_entry_plague_risk(const struct city *pcity,
const void *data)
{
static char buf[8];
if (!game.info.illness_on) {
fc_snprintf(buf, sizeof(buf), " -.-");
} else {
fc_snprintf(buf, sizeof(buf), "%4.1f",
(float)city_illness_calc(pcity, NULL, NULL, NULL, NULL)/10.0);
}
return buf;
} | false | false | false | false | false | 0 |
execute(Window *window)
{
KHTMLPart *part = qobject_cast<KHTMLPart*>(window->m_frame->m_part);
if (!part || !part->jScriptEnabled())
return false;
ScriptInterpreter *interpreter = static_cast<ScriptInterpreter *>(part->jScript()->interpreter());
interpreter->setProcessingTimerCallback(true);
//kDebug(6070) << "ScheduledAction::execute " << this;
if (isFunction) {
if (func->implementsCall()) {
// #### check this
Q_ASSERT( part );
if ( part )
{
KJS::Interpreter *interpreter = part->jScript()->interpreter();
ExecState *exec = interpreter->globalExec();
Q_ASSERT( window == interpreter->globalObject() );
JSObject *obj( window );
func->call(exec,obj,args); // note that call() creates its own execution state for the func call
if (exec->hadException())
exec->clearException();
// Update our document's rendering following the execution of the timeout callback.
part->document().updateRendering();
}
}
}
else {
part->executeScript(DOM::Node(), code);
}
interpreter->setProcessingTimerCallback(false);
return true;
} | false | false | false | false | false | 0 |
aim_odc_connect(aim_session_t *sess, const char *sn,
const char *addr, const fu8_t *cookie)
{
aim_conn_t *newconn;
struct aim_odc_intdata *intdata;
if (!sess || !sn)
return NULL;
if (!(intdata = calloc(1, sizeof(struct aim_odc_intdata))))
return NULL;
memcpy(intdata->cookie, cookie, 8);
strncpy(intdata->sn, sn, sizeof(intdata->sn));
if (addr)
strncpy(intdata->ip, addr, sizeof(intdata->ip));
/* XXX - verify that non-blocking connects actually work */
if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS, addr))) {
free(intdata);
return NULL;
}
newconn->internal = intdata;
newconn->subtype = AIM_CONN_SUBTYPE_OFT_DIRECTIM;
return newconn;
} | false | false | false | false | false | 0 |
efx_free_rx_buffers(struct efx_rx_queue *rx_queue,
struct efx_rx_buffer *rx_buf,
unsigned int num_bufs)
{
do {
if (rx_buf->page) {
put_page(rx_buf->page);
rx_buf->page = NULL;
}
rx_buf = efx_rx_buf_next(rx_queue, rx_buf);
} while (--num_bufs);
} | false | false | false | false | false | 0 |
setupdown(const string& s, bool *enable, int *dataset, bool *percentage, double *upval) {
*dataset = 0;
*enable = true;
*percentage = false;
*upval = 0.0;
unsigned int len = s.size();
if (len == 0) {
*enable = false;
} else if (len >= 1 && toupper(s[0]) == 'D') {
// dataset identifier
*dataset = get_dataset_identifier(s.c_str(), false);
} else if (str_i_str(s, "%") != -1) {
// percentage
*percentage = true;
*upval = atof(s.c_str());
} else {
// absolute value
*upval = atof(s.c_str());
}
} | false | false | false | false | false | 0 |
param(std::string name) {
OpParam par;
par._name = name;
par._gimpType.type = GIMP_PDB_INT32;
par._gimpType.data.d_int32 = 0;
par._guiType = OpParam::Menu;
_params.push_back(par);
return _params.back();
} | false | false | false | false | false | 0 |
LODSD32_EAXXd(bxInstruction_c *i)
{
Bit32u esi = ESI;
RAX = read_virtual_dword(i->seg(), esi);
if (BX_CPU_THIS_PTR get_DF()) {
esi -= 4;
}
else {
esi += 4;
}
// zero extension of RSI
RSI = esi;
} | false | false | false | false | false | 0 |
resize_later(gMainWindow *data)
{
data->bufW = data->_next_w;
data->bufH = data->_next_h;
data->_next_timer = 0;
data->configure();
data->performArrange();
if (data->onResize)
data->onResize(data);
//data->refresh();
return false;
} | false | false | false | false | false | 0 |
skippastURL(OutBuffer *buf, size_t i)
{ size_t length = buf->offset - i;
utf8_t *p = &buf->data[i];
size_t j;
unsigned sawdot = 0;
if (length > 7 && Port::memicmp((char *)p, "http://", 7) == 0)
{
j = 7;
}
else if (length > 8 && Port::memicmp((char *)p, "https://", 8) == 0)
{
j = 8;
}
else
goto Lno;
for (; j < length; j++)
{ utf8_t c = p[j];
if (isalnum(c))
continue;
if (c == '-' || c == '_' || c == '?' ||
c == '=' || c == '%' || c == '&' ||
c == '/' || c == '+' || c == '#' ||
c == '~')
continue;
if (c == '.')
{
sawdot = 1;
continue;
}
break;
}
if (sawdot)
return i + j;
Lno:
return i;
} | false | false | false | false | false | 0 |
dump_entries(ENTRY *list)
{
static const char *flag_name[] = {
"???", "com", "PERM", "PUBL", /* 0x0001-0x0008 */
"trailers", "netmask", "dontpub", "magic", /* 0x0010-0x0080 */
"???", "???", "???", "???", /* 0x0100-0x0800 */
"NULL", "ARPSRV", "NOVC", "???" }; /* 0x1000-0x8000 */
/* lower case flags are not used by ATMARP */
ENTRY *entry;
char addr_buf[MAX_ATM_ADDR_LEN+1];
char qos_buf[MAX_ATM_QOS_LEN+1];
char tmp[100]; /* large enough for all flags */
unsigned char *ipp;
int i;
for (entry = list; entry ; entry = entry->next) {
if (!entry->addr) strcpy(addr_buf,"<none>");
else if (atm2text(addr_buf,MAX_ATM_ADDR_LEN+1,
(struct sockaddr *) entry->addr,pretty) < 0)
strcpy(addr_buf,"<error>");
ipp = (unsigned char *) &entry->ip;
*tmp = 0;
for (i = 0; i < 16; i++)
if (entry->flags & (1 << i)) {
if (*tmp) strcat(tmp,",");
strcat(tmp,flag_name[i]);
}
output("IP %d.%d.%d.%d, state %s, addr %s, flags 0x%x<%s>",ipp[0],
ipp[1],ipp[2],ipp[3],entry_state_name[entry->state],addr_buf,
entry->flags,tmp);
if (entry->itf && !qos_equal(&entry->itf->qos,&entry->qos)) {
if (qos2text(qos_buf,sizeof(qos_buf),&entry->qos,0) < 0)
strcpy(qos_buf,"<error>");
output(" QOS: %s",qos_buf);
}
if (entry->itf && entry->sndbuf && entry->sndbuf != entry->itf->sndbuf)
output(" Send buffer: %d",entry->sndbuf);
if (entry->notify) {
NOTIFY *notify;
int count;
count = 0;
for (notify = entry->notify; notify; notify = notify->next) count++;
output(" %d quer%s pending",count,count == 1 ? "y" : "ies");
}
dump_vccs(entry->vccs);
}
} | true | true | false | false | false | 1 |
d_builtin_function (tree decl)
{
if (!flag_no_builtin && DECL_ASSEMBLER_NAME_SET_P (decl))
vec_safe_push (gcc_builtins_libfuncs, decl);
vec_safe_push (gcc_builtins_functions, decl);
return decl;
} | false | false | false | false | false | 0 |
ad1848_output_block(int dev, unsigned long buf, int count, int intrflag)
{
unsigned long flags, cnt;
ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc;
ad1848_port_info *portc = (ad1848_port_info *) audio_devs[dev]->portc;
cnt = count;
if (portc->audio_format == AFMT_IMA_ADPCM)
{
cnt /= 4;
}
else
{
if (portc->audio_format & (AFMT_S16_LE | AFMT_S16_BE)) /* 16 bit data */
cnt >>= 1;
}
if (portc->channels > 1)
cnt >>= 1;
cnt--;
if ((devc->audio_mode & PCM_ENABLE_OUTPUT) && (audio_devs[dev]->flags & DMA_AUTOMODE) &&
intrflag &&
cnt == devc->xfer_count)
{
devc->audio_mode |= PCM_ENABLE_OUTPUT;
devc->intr_active = 1;
return; /*
* Auto DMA mode on. No need to react
*/
}
spin_lock_irqsave(&devc->lock,flags);
ad_write(devc, 15, (unsigned char) (cnt & 0xff));
ad_write(devc, 14, (unsigned char) ((cnt >> 8) & 0xff));
devc->xfer_count = cnt;
devc->audio_mode |= PCM_ENABLE_OUTPUT;
devc->intr_active = 1;
spin_unlock_irqrestore(&devc->lock,flags);
} | false | false | false | false | false | 0 |
addFloat128Sigs(float128 a, float128 b, int zSign, float_status_t &status)
{
Bit32s aExp, bExp, zExp;
Bit64u aSig0, aSig1, bSig0, bSig1, zSig0, zSig1, zSig2;
Bit32s expDiff;
aSig1 = extractFloat128Frac1(a);
aSig0 = extractFloat128Frac0(a);
aExp = extractFloat128Exp(a);
bSig1 = extractFloat128Frac1(b);
bSig0 = extractFloat128Frac0(b);
bExp = extractFloat128Exp(b);
expDiff = aExp - bExp;
if (0 < expDiff) {
if (aExp == 0x7FFF) {
if (aSig0 | aSig1) return propagateFloat128NaN(a, b, status);
return a;
}
if (bExp == 0) --expDiff;
else bSig0 |= BX_CONST64(0x0001000000000000);
shift128ExtraRightJamming(bSig0, bSig1, 0, expDiff, &bSig0, &bSig1, &zSig2);
zExp = aExp;
}
else if (expDiff < 0) {
if (bExp == 0x7FFF) {
if (bSig0 | bSig1) return propagateFloat128NaN(a, b, status);
return packFloat128(zSign, 0x7FFF, 0, 0);
}
if (aExp == 0) ++expDiff;
else aSig0 |= BX_CONST64(0x0001000000000000);
shift128ExtraRightJamming(aSig0, aSig1, 0, -expDiff, &aSig0, &aSig1, &zSig2);
zExp = bExp;
}
else {
if (aExp == 0x7FFF) {
if (aSig0 | aSig1 | bSig0 | bSig1)
return propagateFloat128NaN(a, b, status);
return a;
}
add128(aSig0, aSig1, bSig0, bSig1, &zSig0, &zSig1);
if (aExp == 0) return packFloat128(zSign, 0, zSig0, zSig1);
zSig2 = 0;
zSig0 |= BX_CONST64(0x0002000000000000);
zExp = aExp;
goto shiftRight1;
}
aSig0 |= BX_CONST64(0x0001000000000000);
add128(aSig0, aSig1, bSig0, bSig1, &zSig0, &zSig1);
--zExp;
if (zSig0 < BX_CONST64(0x0002000000000000)) goto roundAndPack;
++zExp;
shiftRight1:
shift128ExtraRightJamming(zSig0, zSig1, zSig2, 1, &zSig0, &zSig1, &zSig2);
roundAndPack:
return roundAndPackFloat128(zSign, zExp, zSig0, zSig1, zSig2, status);
} | false | false | false | false | false | 0 |
RemoveMidpoint(
const EdgeEndpoints &edge)
{
vtkInternal::MapType::iterator iter = this->Internal->Map.find(edge);
if (iter != this->Internal->Map.end())
{
this->Internal->Map.erase(iter);
}
} | 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.