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 |
|---|---|---|---|---|---|---|
ComputeHash(const std::string & filename)
{
struct stat results;
if (stat(filename.c_str(), &results) == 0)
{
// Treat the mtime + inode as a proxy for the contents
std::ostringstream fasthash;
fasthash << results.st_ino << ":";
fasthash << results.st_mtime;
return fasthash.str();
}
return "";
} | false | false | false | false | false | 0 |
OGRGeoJSONWriteLineCoords( OGRLineString* poLine, int nCoordPrecision )
{
json_object* poObjPoint = NULL;
json_object* poObjCoords = json_object_new_array();
const int nCount = poLine->getNumPoints();
for( int i = 0; i < nCount; ++i )
{
if( poLine->getCoordinateDimension() == 2 )
poObjPoint = OGRGeoJSONWriteCoords( poLine->getX(i), poLine->getY(i), nCoordPrecision );
else
poObjPoint = OGRGeoJSONWriteCoords( poLine->getX(i), poLine->getY(i), poLine->getZ(i), nCoordPrecision );
json_object_array_add( poObjCoords, poObjPoint );
}
return poObjCoords;
} | false | false | false | false | false | 0 |
handle_reply(int http_op_retval) {
char filename[256];
int nitems;
if (!rfp) return; // op was canceled
if (http_op_retval) {
if (log_flags.notice_debug) {
msg_printf(0, MSG_INFO,
"[notice] fetch of %s failed: %d", rfp->url, http_op_retval
);
}
return;
}
if (log_flags.notice_debug) {
msg_printf(0, MSG_INFO,
"[notice] handling reply from %s", rfp->url
);
}
rfp->feed_file_name(filename);
FILE* f = fopen(filename, "r");
if (!f) {
msg_printf(0, MSG_INTERNAL_ERROR,
"RSS feed file '%s' not found", filename
);
return;
}
MIOFILE fin;
fin.init_file(f);
XML_PARSER xp(&fin);
int retval = rfp->parse_items(xp, nitems);
if (retval) {
if (log_flags.notice_debug) {
msg_printf(0, MSG_INFO,
"[notice] RSS parse error: %d", retval
);
}
}
fclose(f);
notices.write_archive(rfp);
} | false | false | false | false | false | 0 |
ProcessDTRCACHE_CHECKED(DTR_ptr request){
// There's no need to check additionally for cache error
// If the error has occurred -- we just proceed the normal
// workflow as if it was not cached at all.
// But we should clear error flag if it was set by the pre-processor
request->reset_error_status();
if (request->get_cache_state() == CACHEABLE) DtrList.caching_started(request);
if(request->get_cache_state() == CACHE_ALREADY_PRESENT){
// File is on place already. After the post-processor
// the DTR is DONE.
request->get_logger()->msg(Arc::VERBOSE, "Destination file is in cache");
request->set_status(DTRStatus::PROCESS_CACHE);
} else if (request->get_source()->IsIndex() || request->get_destination()->IsIndex()) {
// The Normal workflow -- RESOLVE
request->get_logger()->msg(Arc::VERBOSE, "Source and/or destination is index service, will resolve replicas");
request->set_status(DTRStatus::RESOLVE);
} else {
request->get_logger()->msg(Arc::VERBOSE, "Neither source nor destination are index services, will skip resolving replicas");
request->set_status(DTRStatus::RESOLVED);
}
} | false | false | false | false | false | 0 |
static_ok_view (gamgi_direction *direction,
gamgi_window *window)
{
GtkWidget *dialog = window->dialog0;
GtkWidget *entry;
const char *name;
/***********************
* get direction color *
***********************/
entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "entry_red");
name = gtk_entry_get_text (GTK_ENTRY (entry));
if (gamgi_io_token_float_scan (name, &direction->red, 0.0, 1.0) == FALSE)
{
gamgi_gtk_dialog_message_create ("Error", "Invalid Plane Color", window);
gamgi_engine_remove_direction (direction);
return FALSE;
}
entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "entry_green");
name = gtk_entry_get_text (GTK_ENTRY (entry));
if (gamgi_io_token_float_scan (name, &direction->green, 0.0, 1.0) == FALSE)
{
gamgi_gtk_dialog_message_create ("Error", "Invalid Plane Color", window);
gamgi_engine_remove_direction (direction);
return FALSE;
}
entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "entry_blue");
name = gtk_entry_get_text (GTK_ENTRY (entry));
if (gamgi_io_token_float_scan (name, &direction->blue, 0.0, 1.0) == FALSE)
{
gamgi_gtk_dialog_message_create ("Error", "Invalid Plane Color", window);
gamgi_engine_remove_direction (direction);
return FALSE;
}
/***********************
* get direction scale *
***********************/
entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "entry_scale");
name = gtk_entry_get_text (GTK_ENTRY (entry));
if (gamgi_io_token_double_scan (name, &direction->object.scale,
GAMGI_MESA_SCALE_LOWER, GAMGI_MESA_SCALE_UPPER) == FALSE)
{
gamgi_gtk_dialog_message_create ("Error", "Invalid Scale Data", window);
gamgi_engine_remove_direction (direction);
return FALSE;
}
return TRUE;
} | false | false | false | false | false | 0 |
intel_dc21285_init(struct pci_dev *dev, struct map_pci_info *map)
{
unsigned long base, len;
base = pci_resource_start(dev, PCI_ROM_RESOURCE);
len = pci_resource_len(dev, PCI_ROM_RESOURCE);
if (!len || !base) {
/*
* No ROM resource
*/
base = pci_resource_start(dev, 2);
len = pci_resource_len(dev, 2);
/*
* We need to re-allocate PCI BAR2 address range to the
* PCI ROM BAR, and disable PCI BAR2.
*/
} else {
/*
* Hmm, if an address was allocated to the ROM resource, but
* not enabled, should we be allocating a new resource for it
* or simply enabling it?
*/
pci_enable_rom(dev);
printk("%s: enabling expansion ROM\n", pci_name(dev));
}
if (!len || !base)
return -ENXIO;
map->map.bankwidth = 4;
map->map.read = mtd_pci_read32,
map->map.write = mtd_pci_write32,
map->map.size = len;
map->base = ioremap_nocache(base, len);
if (!map->base)
return -ENOMEM;
return 0;
} | false | false | false | false | false | 0 |
clear_entries()
{
int i;
for(i=0; i<4; i++) {
ignore_changed_signal = TRUE;
gtk_entry_set_text(GTK_ENTRY(entry[i]), "");
}
accumulator = 0;
} | false | false | false | false | false | 0 |
is_min4_four_centre(int v)
/* return 1 if v is the centre of a four-reduction, 0 if not.
*/
{
EDGE *e;
if (degree[v] != 4) return 0;
e = firstedge[v];
if (degree[e->prev->end] >= 5 && degree[e->next->end] >= 5
|| degree[e->end] >= 5 && degree[e->next->next->end] >= 5)
return 1;
else
return 0;
} | false | false | false | false | false | 0 |
lp8788_irq_unregister(struct platform_device *pdev,
struct lp8788_charger *pchg)
{
int i;
int irq;
for (i = 0; i < pchg->num_irqs; i++) {
irq = pchg->irqs[i].virq;
if (!irq)
continue;
free_irq(irq, pchg);
}
} | false | false | false | false | false | 0 |
node_is_authentic(const char *vendor, const header_t *head)
{
if (vendor) {
if (is_strcaseprefix(vendor, "limewire/")) {
return !header_get(head, "Bye-Packet") &&
header_get(head, "Remote-IP") &&
header_get(head, "Vendor-Message") &&
header_get(head, "Accept-Encoding");
}
}
return TRUE;
} | false | false | false | false | false | 0 |
optimize(int result, bool keepLvalue)
{ Expression *e;
//printf("SliceExp::optimize(result = %d) %s\n", result, toChars());
e = this;
e1 = e1->optimize(WANTvalue | (result & WANTexpand));
if (!lwr)
{ if (e1->op == TOKstring)
{ // Convert slice of string literal into dynamic array
Type *t = e1->type->toBasetype();
if (t->nextOf())
e = e1->castTo(NULL, t->nextOf()->arrayOf());
}
return e;
}
e1 = fromConstInitializer(result, e1);
// We might know $ now
setLengthVarIfKnown(lengthVar, e1);
lwr = lwr->optimize(WANTvalue);
upr = upr->optimize(WANTvalue);
e = Slice(type, e1, lwr, upr);
if (e == EXP_CANT_INTERPRET)
e = this;
//printf("-SliceExp::optimize() %s\n", e->toChars());
return e;
} | false | false | false | false | false | 0 |
add_ic_call(struct compilation_unit *cu, struct insn *insn)
{
struct ic_call *ic_call;
ic_call = malloc(sizeof(struct ic_call));
if (!ic_call)
return -ENOMEM;
ic_call->insn = insn;
list_add_tail(&ic_call->list_node, &cu->ic_call_list);
return 0;
} | false | false | false | false | false | 0 |
ack_pkt(git_pkt **out, const char *line, size_t len)
{
git_pkt_ack *pkt;
GIT_UNUSED(line);
GIT_UNUSED(len);
pkt = git__calloc(1, sizeof(git_pkt_ack));
GITERR_CHECK_ALLOC(pkt);
pkt->type = GIT_PKT_ACK;
line += 3;
len -= 3;
if (len >= GIT_OID_HEXSZ) {
git_oid_fromstr(&pkt->oid, line + 1);
line += GIT_OID_HEXSZ + 1;
len -= GIT_OID_HEXSZ + 1;
}
if (len >= 7) {
if (!git__prefixcmp(line + 1, "continue"))
pkt->status = GIT_ACK_CONTINUE;
if (!git__prefixcmp(line + 1, "common"))
pkt->status = GIT_ACK_COMMON;
if (!git__prefixcmp(line + 1, "ready"))
pkt->status = GIT_ACK_READY;
}
*out = (git_pkt *) pkt;
return 0;
} | false | false | false | false | false | 0 |
cli_print_brick_status (cli_volume_status_t *status)
{
int fieldlen = CLI_VOL_STATUS_BRICK_LEN;
int bricklen = 0;
char *p = NULL;
int num_tabs = 0;
p = status->brick;
bricklen = strlen (p);
while (bricklen > 0) {
if (bricklen > fieldlen) {
cli_out ("%.*s", fieldlen, p);
p += fieldlen;
bricklen -= fieldlen;
} else {
num_tabs = (fieldlen - bricklen) / CLI_TAB_LENGTH + 1;
printf ("%s", p);
while (num_tabs-- != 0)
printf ("\t");
if (status->port) {
if (status->online)
cli_out ("%d\t%c\t%s",
status->port,
status->online?'Y':'N',
status->pid_str);
else
cli_out ("%s\t%c\t%s",
"N/A",
status->online?'Y':'N',
status->pid_str);
}
else
cli_out ("%s\t%c\t%s",
"N/A", status->online?'Y':'N',
status->pid_str);
bricklen = 0;
}
}
return 0;
} | false | false | false | false | false | 0 |
audio_wave_format(int wid, audio_formats_t fmt, int fs)
{
unsigned old_xsize, new_size;
wid = audio_wave_alloc(wid);
if(wid < 0)
return wid;
old_xsize = wavetab[wid].xsize;
wavetab[wid].format = fmt;
wavetab[wid].rate = fs;
if(wavetab[wid].data.si8)
{
new_size = _calc_xsize(wid);
if(wavetab[wid].xsize != old_xsize)
{
void *ndata = realloc(wavetab[wid].data.si8, new_size);
if(!ndata)
return -3;
wavetab[wid].data.si8 = ndata;
_calc_info(wid);
}
}
return wid;
} | false | false | false | false | false | 0 |
Mtr_SwapGroups(
MtrNode * first /* first node to be swapped */,
MtrNode * second /* second node to be swapped */)
{
MtrNode *node;
MtrNode *parent;
int sizeFirst;
int sizeSecond;
if (second->younger == first) { /* make first first */
node = first;
first = second;
second = node;
} else if (first->younger != second) { /* non-adjacent */
return(0);
}
sizeFirst = first->size;
sizeSecond = second->size;
/* Swap the two nodes. */
parent = first->parent;
if (parent == NULL || second->parent != parent) return(0);
if (parent->child == first) {
parent->child = second;
} else { /* first->elder != NULL */
first->elder->younger = second;
}
if (second->younger != NULL) {
second->younger->elder = first;
}
first->younger = second->younger;
second->elder = first->elder;
first->elder = second;
second->younger = first;
/* Adjust the high and low fields. */
if (!mtrShiftHL(first,sizeSecond)) return(0);
if (!mtrShiftHL(second,-sizeFirst)) return(0);
return(1);
} | false | false | false | false | false | 0 |
dvr_add_pcb(struct adapter_s *a, unsigned int pid, unsigned int type,
unsigned int pidt, void (*callback)(void *data, void *arg), void *arg) {
struct pidcallback_s *pcb;
logwrite(LOG_DEBUG, "dvr: Add %s callback for PID %4d (0x%04x) type %d (%s)",
((type == DVRCB_TS) ? "TS" : "Section"), pid, pid, pidt, pidtnames[pidt]);
/* FIXME - check for error of malloc */
pcb=malloc(sizeof(struct pidcallback_s));
pcb->pid=pid;
pcb->callback=callback;
pcb->arg=arg;
pcb->pidt=pidt;
pcb->type=type;
/* Joined pseudo pid 0x2000 e.g. input full */
if (pid == PID_MAX+1) {
/* FIXME: How to detect we need to join 0x2000? */
a->dvr.fullcb=g_list_append(a->dvr.fullcb, pcb);
return pcb;
}
if (type == DVRCB_SECTION) {
a->dvr.pidtable[pid].secuser++;
if (!a->dvr.pidtable[pid].section)
a->dvr.pidtable[pid].section=psi_section_new();
}
if (!a->dvr.pidtable[pid].callback)
dmx_join_pid(a, pid, DMX_PES_OTHER);
a->dvr.pidtable[pid].callback=g_list_append(a->dvr.pidtable[pid].callback, pcb);
return pcb;
} | false | false | false | false | false | 0 |
isVariableChanged(const Token *start, const Token *end, const unsigned int varid)
{
for (const Token *tok = start; tok != end; tok = tok->next()) {
if (tok->varId() == varid) {
if (Token::Match(tok, "%var% ="))
return true;
const Token *parent = tok->astParent();
while (Token::Match(parent, ".|::"))
parent = parent->astParent();
if (parent && parent->type() == Token::eIncDecOp)
return true;
}
}
return false;
} | false | false | false | false | false | 0 |
IsNexusInCore(const Cache cache,const NexusInfo *nexus_info)
{
MagickPassFail
status=MagickFail;
const CacheInfo
* restrict cache_info=(const CacheInfo *) cache;
if (cache_info && (cache_info->storage_class != UndefinedClass))
{
if (cache_info->type == PingCache)
{
status=MagickPass;
}
else
{
magick_off_t
offset;
offset=nexus_info->region.y*
(magick_off_t) cache_info->columns+nexus_info->region.x;
if (nexus_info->pixels == (cache_info->pixels+offset))
status=MagickPass;
}
}
return(status);
} | false | false | false | false | false | 0 |
ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x)
{
BUF_MEM *b = NULL;
const unsigned char *p;
void *ret=NULL;
int len;
len = asn1_d2i_read_bio(in, &b);
if(len < 0) goto err;
p=(const unsigned char *)b->data;
ret=ASN1_item_d2i(x,&p,len, it);
err:
if (b != NULL) BUF_MEM_free(b);
return(ret);
} | false | false | false | false | false | 0 |
close_pl(PG_FUNCTION_ARGS)
{
Point *pt = PG_GETARG_POINT_P(0);
LINE *line = PG_GETARG_LINE_P(1);
Point *result;
LINE *tmp;
double invm;
result = (Point *) palloc(sizeof(Point));
if (FPzero(line->B)) /* vertical? */
{
result->x = line->C;
result->y = pt->y;
PG_RETURN_POINT_P(result);
}
if (FPzero(line->A)) /* horizontal? */
{
result->x = pt->x;
result->y = line->C;
PG_RETURN_POINT_P(result);
}
/* drop a perpendicular and find the intersection point */
/* invert and flip the sign on the slope to get a perpendicular */
invm = line->B / line->A;
tmp = line_construct_pm(pt, invm);
result = line_interpt_internal(tmp, line);
Assert(result != NULL);
PG_RETURN_POINT_P(result);
} | false | false | false | false | false | 0 |
disp_total()
{
//--- calculate the total income and expense ----//
float totalIncome = (float) 0;
float totalExpense = (float) 0;
Nation* nationPtr = nation_array[info.viewing_nation_recno];
int i;
for( i=0 ; i<INCOME_TYPE_COUNT ; i++ )
totalIncome += nationPtr->income_365days(i);
for( i=0 ; i<EXPENSE_TYPE_COUNT ; i++ )
totalExpense += nationPtr->expense_365days(i);
//---------- display total income ----------//
vga_back.d3_panel_up(INCOME_BROWSE_X1, INCOME_BROWSE_Y2-18, INCOME_BROWSE_X2, INCOME_BROWSE_Y2 );
int x=INCOME_BROWSE_X1+9;
int y=INCOME_BROWSE_Y2-16;
font_san.put( x, y, "Total Yearly Income" );
font_san.put( x+370, y, misc.format( (int) totalIncome, 2 ) );
//---------- display total expense ----------//
vga_back.d3_panel_up(EXPENSE_BROWSE_X1, EXPENSE_BROWSE_Y2-18, EXPENSE_BROWSE_X2, EXPENSE_BROWSE_Y2 );
x=EXPENSE_BROWSE_X1+9;
y=EXPENSE_BROWSE_Y2-16;
font_san.put( x, y, "Total Yearly Expenses" );
font_san.put( x+370, y, misc.format( (int) totalExpense, 2 ) );
//----------- display the balance --------//
y=EXPENSE_BROWSE_Y2+7;
vga_back.d3_panel_up(EXPENSE_BROWSE_X1, EXPENSE_BROWSE_Y2+4, EXPENSE_BROWSE_X2, ZOOM_Y2-6 );
font_san.put( x, y, "Yearly Balance" );
font_san.put( x+370, y, misc.format( (int)(totalIncome-totalExpense), 2 ) );
} | false | false | false | false | false | 0 |
mc_get_pub_by_slot(TCPA_KEY_HANDLE tpm_handle)
{
struct key_mem_cache *tmp;
TCPA_STORE_PUBKEY *ret;
if (tpm_handle == NULL_TPM_HANDLE)
return NULL;
for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
LogDebugFn("TCSD mem_cached handle: 0x%x",
tmp->tcs_handle);
if (tmp->tpm_handle == tpm_handle) {
ret = tmp->blob ? &tmp->blob->pubKey : NULL;
return ret;
}
}
LogDebugFn("returning NULL TCPA_STORE_PUBKEY");
return NULL;
} | false | false | false | false | false | 0 |
__ieee754_sinhl(long double x)
{
long double t,w,h;
u_int32_t jx,ix,i0,i1;
/* Words of |x|. */
GET_LDOUBLE_WORDS(jx,i0,i1,x);
ix = jx&0x7fff;
/* x is INF or NaN */
if(__builtin_expect(ix==0x7fff, 0)) return x+x;
h = 0.5;
if (jx & 0x8000) h = -h;
/* |x| in [0,25], return sign(x)*0.5*(E+E/(E+1))) */
if (ix < 0x4003 || (ix == 0x4003 && i0 <= 0xc8000000)) { /* |x|<25 */
if (ix<0x3fdf) /* |x|<2**-32 */
if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
t = __expm1l(fabsl(x));
if(ix<0x3fff) return h*(2.0*t-t*t/(t+one));
return h*(t+t/(t+one));
}
/* |x| in [25, log(maxdouble)] return 0.5*exp(|x|) */
if (ix < 0x400c || (ix == 0x400c && i0 < 0xb17217f7))
return h*__ieee754_expl(fabsl(x));
/* |x| in [log(maxdouble), overflowthreshold] */
if (ix<0x400c || (ix == 0x400c && (i0 < 0xb174ddc0
|| (i0 == 0xb174ddc0
&& i1 <= 0x31aec0ea)))) {
w = __ieee754_expl(0.5*fabsl(x));
t = h*w;
return t*w;
}
/* |x| > overflowthreshold, sinhl(x) overflow */
return x*shuge;
} | false | false | false | false | false | 0 |
setup_cli_server(void)
{
ns_bzero(&cliserver,sizeof(struct cli_server));
cliserver.listen_fd = -1;
cliserver.verbose = turn_params.verbose;
if(pthread_create(&(cliserver.thr), NULL, run_cli_server_thread, &cliserver)<0) {
perror("Cannot create cli thread\n");
exit(-1);
}
pthread_detach(cliserver.thr);
} | false | false | false | false | false | 0 |
drisw_create_screen(struct drisw_loader_funcs *lf)
{
struct sw_winsys *winsys = NULL;
struct pipe_screen *screen = NULL;
winsys = dri_create_sw_winsys(lf);
if (winsys == NULL)
return NULL;
screen = sw_screen_create(winsys);
if (!screen)
goto fail;
screen = debug_screen_wrap(screen);
return screen;
fail:
if (winsys)
winsys->destroy(winsys);
return NULL;
} | false | false | false | false | false | 0 |
smi_dvb_init(struct smi_port *port)
{
int ret;
struct dvb_adapter *adap = &port->dvb_adapter;
struct dvb_demux *dvbdemux = &port->demux;
dev_dbg(&port->dev->pci_dev->dev,
"%s, port %d\n", __func__, port->idx);
ret = dvb_register_adapter(adap, "SMI_DVB", THIS_MODULE,
&port->dev->pci_dev->dev,
adapter_nr);
if (ret < 0) {
dev_err(&port->dev->pci_dev->dev, "Fail to register DVB adapter.\n");
return ret;
}
ret = my_dvb_dmx_ts_card_init(dvbdemux, "SW demux",
smi_start_feed,
smi_stop_feed, port);
if (ret < 0)
goto err_del_dvb_register_adapter;
ret = my_dvb_dmxdev_ts_card_init(&port->dmxdev, &port->demux,
&port->hw_frontend,
&port->mem_frontend, adap);
if (ret < 0)
goto err_del_dvb_dmx;
ret = dvb_net_init(adap, &port->dvbnet, port->dmxdev.demux);
if (ret < 0)
goto err_del_dvb_dmxdev;
return 0;
err_del_dvb_dmxdev:
dvbdemux->dmx.close(&dvbdemux->dmx);
dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &port->hw_frontend);
dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &port->mem_frontend);
dvb_dmxdev_release(&port->dmxdev);
err_del_dvb_dmx:
dvb_dmx_release(&port->demux);
err_del_dvb_register_adapter:
dvb_unregister_adapter(&port->dvb_adapter);
return ret;
} | false | false | false | false | false | 0 |
send_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd )
{
int bufl, litplus;
const char *buffmt;
char buf[1024];
cmd->tag = ++ctx->nexttag;
if (!cmd->param.data) {
buffmt = "%d %s\r\n";
litplus = 0;
} else if ((cmd->param.to_trash && ctx->trashnc == TrashUnknown) || !CAP(LITERALPLUS)) {
buffmt = "%d %s{%d}\r\n";
litplus = 0;
} else {
buffmt = "%d %s{%d+}\r\n";
litplus = 1;
}
bufl = nfsnprintf( buf, sizeof(buf), buffmt,
cmd->tag, cmd->cmd, cmd->param.data_len );
if (DFlags & VERBOSE) {
if (ctx->num_in_progress)
printf( "(%d in progress) ", ctx->num_in_progress );
if (memcmp( cmd->cmd, "LOGIN", 5 ))
printf( "%s>>> %s", ctx->label, buf );
else
printf( "%s>>> %d LOGIN <user> <pass>\n", ctx->label, cmd->tag );
fflush( stdout );
}
if (socket_write( &ctx->conn, buf, bufl, KeepOwn ) < 0)
goto bail;
if (litplus) {
char *p = cmd->param.data;
cmd->param.data = 0;
if (socket_write( &ctx->conn, p, cmd->param.data_len, GiveOwn ) < 0 ||
socket_write( &ctx->conn, "\r\n", 2, KeepOwn ) < 0)
goto bail;
}
if (cmd->param.to_trash && ctx->trashnc == TrashUnknown)
ctx->trashnc = TrashChecking;
cmd->next = 0;
*ctx->in_progress_append = cmd;
ctx->in_progress_append = &cmd->next;
ctx->num_in_progress++;
return 0;
bail:
done_imap_cmd( ctx, cmd, RESP_CANCEL );
return -1;
} | false | false | false | false | false | 0 |
g450_preinit(struct matrox_fb_info *minfo)
{
u_int32_t c2ctl;
u_int8_t curctl;
u_int8_t c1ctl;
/* minfo->hw.MXoptionReg = minfo->values.reg.opt; */
minfo->hw.MXoptionReg &= 0xC0000100;
minfo->hw.MXoptionReg |= 0x00000020;
if (minfo->devflags.novga)
minfo->hw.MXoptionReg &= ~0x00000100;
if (minfo->devflags.nobios)
minfo->hw.MXoptionReg &= ~0x40000000;
if (minfo->devflags.nopciretry)
minfo->hw.MXoptionReg |= 0x20000000;
minfo->hw.MXoptionReg |= minfo->values.reg.opt & 0x03400040;
pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, minfo->hw.MXoptionReg);
/* Init system clocks */
/* stop crtc2 */
c2ctl = mga_inl(M_C2CTL);
mga_outl(M_C2CTL, c2ctl & ~1);
/* stop cursor */
curctl = inDAC1064(minfo, M1064_XCURCTRL);
outDAC1064(minfo, M1064_XCURCTRL, 0);
/* stop crtc1 */
c1ctl = mga_readr(M_SEQ_INDEX, 1);
mga_setr(M_SEQ_INDEX, 1, c1ctl | 0x20);
g450_mclk_init(minfo);
g450_memory_init(minfo);
/* set legacy VGA clock sources for DOSEmu or VMware... */
matroxfb_g450_setclk(minfo, 25175, M_PIXEL_PLL_A);
matroxfb_g450_setclk(minfo, 28322, M_PIXEL_PLL_B);
/* restore crtc1 */
mga_setr(M_SEQ_INDEX, 1, c1ctl);
/* restore cursor */
outDAC1064(minfo, M1064_XCURCTRL, curctl);
/* restore crtc2 */
mga_outl(M_C2CTL, c2ctl);
return;
} | false | false | false | false | false | 0 |
lua_copy (lua_State *L, int fromidx, int toidx) {
TValue *fr, *to;
lua_lock(L);
fr = index2addr(L, fromidx);
to = index2addr(L, toidx);
api_checkvalidindex(to);
setobj(L, to, fr);
if (isupvalue(toidx)) /* function upvalue? */
luaC_barrier(L, clCvalue(L->ci->func), fr);
/* LUA_REGISTRYINDEX does not need gc barrier
(collector revisits it before finishing collection) */
lua_unlock(L);
} | false | false | false | false | false | 0 |
mpz_poly_fread(mpz_poly_t poly, FILE* f)
{
// read poly length
unsigned long length;
if (!fscanf(f, "%ld", &length))
return 0;
poly->length = 0;
mpz_poly_ensure_alloc(poly, length);
// read coefficients
for (unsigned long i = 0; i < length; i++)
{
if (!mpz_inp_str(poly->coeffs[i], f, 10))
return 0;
poly->length++;
}
mpz_poly_normalise(poly);
return 1;
} | false | false | false | false | false | 0 |
build_probe_list(struct inode *inode,
struct vm_area_struct *vma,
unsigned long start, unsigned long end,
struct list_head *head)
{
loff_t min, max;
struct rb_node *n, *t;
struct uprobe *u;
INIT_LIST_HEAD(head);
min = vaddr_to_offset(vma, start);
max = min + (end - start) - 1;
spin_lock(&uprobes_treelock);
n = find_node_in_range(inode, min, max);
if (n) {
for (t = n; t; t = rb_prev(t)) {
u = rb_entry(t, struct uprobe, rb_node);
if (u->inode != inode || u->offset < min)
break;
list_add(&u->pending_list, head);
get_uprobe(u);
}
for (t = n; (t = rb_next(t)); ) {
u = rb_entry(t, struct uprobe, rb_node);
if (u->inode != inode || u->offset > max)
break;
list_add(&u->pending_list, head);
get_uprobe(u);
}
}
spin_unlock(&uprobes_treelock);
} | false | false | false | false | false | 0 |
main(int argc, char** argv) {
char buf[256];
FILE* in, *out;
fprintf(stderr, "worker starting\n");
in = fopen("in", "r");
if (!in) {
fprintf(stderr, "missing input file\n");
exit(1);
}
out = fopen("out", "w");
if (!out) {
fprintf(stderr, "can't open output file\n");
exit(1);
}
fgets(buf, 256, in);
fputs(buf, out);
fgets(buf, 256, stdin);
fputs(buf, stdout);
int start = (int)time(0);
int nsec = 10;
if (argc > 1) nsec = atoi(argv[1]);
int i=0;
while (time(0) < start+nsec) {
do_a_giga_flop(i++);
}
fputs("done!\n", stdout);
return 0;
} | false | false | false | false | true | 1 |
razf_end_flush(RAZF *rz){
uint32_t tout;
if(rz->buf_len){
_razf_write(rz, rz->inbuf, rz->buf_len);
rz->buf_off = rz->buf_len = 0;
}
while(1){
tout = rz->stream->avail_out;
deflate(rz->stream, Z_FINISH);
rz->out += tout - rz->stream->avail_out;
if(rz->stream->avail_out < RZ_BUFFER_SIZE){
#ifdef _USE_KNETFILE
write(rz->x.fpw, rz->outbuf, RZ_BUFFER_SIZE - rz->stream->avail_out);
#else
write(rz->filedes, rz->outbuf, RZ_BUFFER_SIZE - rz->stream->avail_out);
#endif
rz->stream->avail_out = RZ_BUFFER_SIZE;
rz->stream->next_out = rz->outbuf;
} else break;
}
} | false | false | false | false | false | 0 |
System_ShellOpen(char * fileName, va_list args)
{
bool result = false;
char filePath[MAX_F_STRING*4];
int len;
#if defined(__WIN32__)
filePath[0] = '"';
vsnprintf(filePath+1, sizeof(filePath)-2,fileName, args);
#else
vsnprintf(filePath, sizeof(filePath), fileName, args);
#endif
filePath[sizeof(filePath)-1] = 0;
len = strlen(filePath);
#if defined(__WIN32__)
filePath[len] = '"';
filePath[len+1] = '\0';
#else
filePath[len] = '\0';
#endif
#if !defined(__WIN32__)
{
char command[MAX_LOCATION] = "";
char desktop[MAX_F_STRING];
__ecereNameSpace__ecere__sys__GetEnvironment("ECERE_DESKTOP", desktop, sizeof(desktop));
if(__ecereNameSpace__ecere__sys__SearchString(desktop, 0, "ecere", false, false))
sprintf(command, "ede-open \"%s\" &", filePath);
else
{
__ecereNameSpace__ecere__sys__GetEnvironment("DESKTOP_SESSION", desktop, sizeof(desktop));
if(__ecereNameSpace__ecere__sys__SearchString(desktop, 0, "gnome", false, false))
sprintf(command, "gnome-open \"%s\" &", filePath);
else if(__ecereNameSpace__ecere__sys__SearchString(desktop, 0, "kde", false, false))
sprintf(command, "kde-open \"%s\" &", filePath);
else
sprintf(command, "xdg-open \"%s\" &", filePath);
}
if(command[0] && system(command) != -1)
result = true;
}
#elif defined(ECERE_VANILLA)
{
uint16 * _wfilePath = __ecereNameSpace__ecere__sys__UTF8toUTF16(filePath, null);
if(_wsystem(_wfilePath) != -1)
result = true;
__ecereNameSpace__ecere__com__eSystem_Delete(_wfilePath);
}
#else
{
uint16 * _wfilePath = __ecereNameSpace__ecere__sys__UTF8toUTF16(filePath, null);
char curDir[MAX_LOCATION];
uint16 * _wcurDir;
__ecereNameSpace__ecere__sys__StripLastDirectory(filePath, curDir);
_wcurDir = __ecereNameSpace__ecere__sys__UTF8toUTF16(curDir, null);
//if(ShellExecute(null, "open", _wfilePath, null, curDir, SW_SHOWNORMAL) > 32)
if((void *)ShellExecute(null, null, _wfilePath, null, _wcurDir, SW_SHOWNORMAL) > (void *)32)
result = true;
__ecereNameSpace__ecere__com__eSystem_Delete(_wfilePath);
__ecereNameSpace__ecere__com__eSystem_Delete(_wcurDir);
}
#endif
return result;
} | false | false | false | false | false | 0 |
LoadConstants (LoadState* S, Proto* f)
{
int i,n;
n=LoadInt(S);
f->k=luaM_newvector(S->L,n,TObject);
f->sizek=n;
for (i=0; i<n; i++)
{
TObject* o=&f->k[i];
int t=LoadByte(S);
switch (t)
{
case LUA_TNUMBER:
setnvalue(o,LoadNumber(S));
break;
case LUA_TSTRING:
setsvalue2n(o,LoadString(S));
break;
case LUA_TNIL:
setnilvalue(o);
break;
default:
luaG_runerror(S->L,"bad constant type (%d) in %s",t,S->name);
break;
}
}
n=LoadInt(S);
f->p=luaM_newvector(S->L,n,Proto*);
f->sizep=n;
for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
} | false | false | false | false | false | 0 |
DoTraffic(void *p)
{
static unsigned uLedBitsOld=0;
static long lAllPacketsPrior=0;
static struct timeval tWhenPrior;
struct timeval tWhenNow;
struct timeval tWhenDiff;
#if HAVE_GETIFADDRS
struct ifaddrs *pIfAddrs;
struct ifaddrs *pThisIfAddrs;
#endif
long lAllPackets=0L;
long lRate;
unsigned uLedBits;
//Read clock, no timezone
if (gettimeofday(&tWhenNow,NULL))
return;
#if HAVE_GETIFADDRS
if (getifaddrs(&pIfAddrs))
return;
for (pThisIfAddrs=pIfAddrs;pThisIfAddrs; pThisIfAddrs=pThisIfAddrs->ifa_next)
if (pThisIfAddrs->ifa_addr && AF_MAC == pThisIfAddrs->ifa_addr->sa_family)
if (0 == memcmp(pThisIfAddrs->ifa_name, ETHDEV "0",1+sizeof(ETHDEV)) ||
0 == memcmp(pThisIfAddrs->ifa_name, ETHDEV "1",1+sizeof(ETHDEV)) ||
0 == memcmp(pThisIfAddrs->ifa_name, ETHDEV "2",1+sizeof(ETHDEV)) ||
0 == memcmp(pThisIfAddrs->ifa_name, ETHDEV "3",1+sizeof(ETHDEV)))
lAllPackets+= INOUT_PACKETS(pThisIfAddrs->ifa_data);
freeifaddrs(pIfAddrs);
#else
#if !HAVE_GETIFADDRS && defined(__linux__)
lAllPackets=GetPacketCount();
#else
#error "No input method found for TRAFFIC"
#endif
#endif
if (0L == lAllPackets)
return;
if (0L != lAllPacketsPrior)
{
//Rate is number of packets since last time divided by time diff since last time
//Normalize rate by dividing by 64 (64 packets per second is 1 LED)
GetTimeDiff (&tWhenPrior, &tWhenNow, &tWhenDiff);
if (0 == tWhenDiff.tv_sec && 0 == tWhenDiff.tv_usec) //Avoid div by zero
return;
lRate=(lAllPackets-lAllPacketsPrior)*1000000/64/(tWhenDiff.tv_sec*1000000+tWhenDiff.tv_usec);
// 8192 packets per second and above is 8 LEDs
if (lRate > 8192/64)
lRate=8192/64; //Anything higher than 8192 packets/second is all LEDs
//compute the logarithm of the rate the cheap way (find the highest bit set to 1)
for (uLedBits=1;lRate>0;uLedBits=uLedBits<<1)
lRate=lRate>>1;
//Apply the style modifyer
if (uStackStyle & STACK_LINE)
uLedBits>>=1;
if (uStackStyle & STACK_BAR)
uLedBits--;
if (uStackStyle & STACK_RAW)
uLedBits=(lAllPackets/64)&0xFF; //This displays the low byte of 64 packet _count_ (not _rate_) in binary
if (uStackStyle & STACK_REVERSE)
uLedBits^=0xFF;
//Only update LEDs if necessary
if (uLedBits != uLedBitsOld)
{
uLedBitsOld=uLedBits;
DrvSetLeds(LED_NO_TRAFFIC+uLedBits);
}
}
//Set time and count baseline for next run
lAllPacketsPrior=lAllPackets;
tWhenPrior=tWhenNow;
} | false | false | false | false | false | 0 |
get_mutable_buffer(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable)
{
size_t length = size / sizeof(char_t);
if (is_mutable)
{
out_buffer = static_cast<char_t*>(const_cast<void*>(contents));
out_length = length;
}
else
{
char_t* buffer = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
if (!buffer) return false;
memcpy(buffer, contents, length * sizeof(char_t));
buffer[length] = 0;
out_buffer = buffer;
out_length = length + 1;
}
return true;
} | false | false | false | false | false | 0 |
serial_loop(WORKER_INFO *info, ESL_SQFILE *dbfp)
{
int sstatus;
ESL_SQ *dbsq = NULL; /* one target sequence (digital) */
dbsq = esl_sq_CreateDigital(info->om->abc);
/* Main loop: */
while ((sstatus = esl_sqio_Read(dbfp, dbsq)) == eslOK)
{
p7_pli_NewSeq(info->pli, dbsq);
p7_bg_SetLength(info->bg, dbsq->n);
p7_oprofile_ReconfigLength(info->om, dbsq->n);
p7_Pipeline(info->pli, info->om, info->bg, dbsq, info->th);
esl_sq_Reuse(dbsq);
p7_pipeline_Reuse(info->pli);
}
esl_sq_Destroy(dbsq);
return sstatus;
} | false | false | false | false | false | 0 |
add_all_nodes(const std::string& what)
{
for (NODE_MAP::const_iterator
i = CARD_LIST::card_list.nodes()->begin();
i != CARD_LIST::card_list.nodes()->end();
++i) {
if ((i->first != "0") && (i->first.find('.') == std::string::npos)) {
NODE* node = i->second;
assert (node);
push_new_probe(what, node);
}else{
}
}
} | false | false | false | false | false | 0 |
cx24123_read_status(struct dvb_frontend *fe, enum fe_status *status)
{
struct cx24123_state *state = fe->demodulator_priv;
int sync = cx24123_readreg(state, 0x14);
*status = 0;
if (state->config->dont_use_pll) {
u32 tun_status = 0;
if (fe->ops.tuner_ops.get_status)
fe->ops.tuner_ops.get_status(fe, &tun_status);
if (tun_status & TUNER_STATUS_LOCKED)
*status |= FE_HAS_SIGNAL;
} else {
int lock = cx24123_readreg(state, 0x20);
if (lock & 0x01)
*status |= FE_HAS_SIGNAL;
}
if (sync & 0x02)
*status |= FE_HAS_CARRIER; /* Phase locked */
if (sync & 0x04)
*status |= FE_HAS_VITERBI;
/* Reed-Solomon Status */
if (sync & 0x08)
*status |= FE_HAS_SYNC;
if (sync & 0x80)
*status |= FE_HAS_LOCK; /*Full Sync */
return 0;
} | false | false | false | false | false | 0 |
compute_CP_length(const int snumber,
StatementDataTable* statement_data)
{ int i;
int j;
int successor_max;
int max;
#ifdef DEBUG_MKTG
if (snumber == 0)
{ fprintf(stderr, "%s %d : *** Oops! "
"A Statement does not find. Why?\n"
"Because there are bugs! ;-p\n", __FILE__, __LINE__);
abort();
}
#endif
max = 0;
for (i=snumber; i>0; i--)
{ successor_max = 0;
for (j=i+1; j<=snumber; j++)
{ if (in_IntSet(statement_data[i].successor, j))
{ if (successor_max < statement_data[j].cp_length)
{ successor_max = statement_data[j].cp_length;
}
}
}
j = statement_data[i].cp_length
= successor_max + statement_data[i].cost;
if (j > max)
{ max = j;
}
}
#ifdef DEBUG_MORE_MKTG
printf("\nBLock CP Length : %d\n", max);
for (i=1; i<=snumber; i++)
{ printf("Statement No. %d. (CP %d)\n", i, statement_data[i].cp_length);
}
#endif
return max;
} | false | false | false | false | false | 0 |
mca_pml_bfo_recv_request_reset(mca_pml_bfo_recv_request_t* match) {
int i;
assert(true != match->req_recv.req_base.req_pml_complete);
/* Free up any resources that were reserved for this receive. This
* was copied from the receive completion code. */
for(i = 0; i < (int)match->req_rdma_cnt; i++) {
mca_mpool_base_registration_t* btl_reg = match->req_rdma[i].btl_reg;
if( NULL != btl_reg && btl_reg->mpool != NULL) {
btl_reg->mpool->mpool_deregister( btl_reg->mpool, btl_reg );
}
}
match->req_rdma_cnt = 0;
/* This code is mostly copied from mca_pml_bfo_recv_req_start.
* Note 1: Leave req_bytes_expected as the original value. No
* need to adjust this as it is set when convertor is created.
* Note 2: Leave req_bytes_delivered as the original value.
* This is created when the convertor is created and represents
* the expected bytes from the user. */
assert(0 == match->req_events);
match->req_errstate = 0;
match->req_lock = 0;
match->req_pipeline_depth = 0;
match->req_bytes_received = 0;
match->req_rdma_idx = 0;
match->req_rdma_offset = 0;
match->req_send_offset = 0;
match->req_pending = false;
match->req_ack_sent = false;
match->req_restartseq++;
/* These really should not need to be set, but this matches some
* of the initialization within MCA_PML_BASE_RECV_START. */
match->req_recv.req_base.req_pml_complete = false;
match->req_recv.req_base.req_ompi.req_complete = false;
match->req_recv.req_base.req_ompi.req_state = OMPI_REQUEST_ACTIVE;
/* Reset the convertor */
opal_convertor_set_position(&match->req_recv.req_base.req_convertor,
&match->req_rdma_offset);
return;
} | false | false | false | false | false | 0 |
rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter)
{
u16 btusedbytes;
u16 efuse_addr;
u8 bank, startBank;
u8 hoffset = 0, hworden = 0;
u8 efuse_data, word_cnts = 0;
u16 retU2 = 0;
struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
btusedbytes = pHalData->BTEfuseUsedBytes;
efuse_addr = (u16) ((btusedbytes % EFUSE_BT_REAL_BANK_CONTENT_LEN));
startBank = (u8) (1 + (btusedbytes / EFUSE_BT_REAL_BANK_CONTENT_LEN));
DBG_8723A("%s: start from bank =%d addr = 0x%X\n", __func__, startBank,
efuse_addr);
EFUSE_GetEfuseDefinition23a(padapter, EFUSE_BT,
TYPE_AVAILABLE_EFUSE_BYTES_BANK, &retU2);
for (bank = startBank; bank < EFUSE_MAX_BANK; bank++) {
if (hal_EfuseSwitchToBank(padapter, bank) == false) {
DBG_8723A(KERN_ERR "%s: switch bank(%d) Fail!!\n",
__func__, bank);
bank = EFUSE_MAX_BANK;
break;
}
/* only when bank is switched we have to reset
the efuse_addr. */
if (bank != startBank)
efuse_addr = 0;
while (AVAILABLE_EFUSE_ADDR(efuse_addr)) {
if (efuse_OneByteRead23a(padapter, efuse_addr,
&efuse_data) == _FAIL) {
DBG_8723A(KERN_ERR "%s: efuse_OneByteRead23a Fail!"
" addr = 0x%X !!\n",
__func__, efuse_addr);
bank = EFUSE_MAX_BANK;
break;
}
if (efuse_data == 0xFF)
break;
if (EXT_HEADER(efuse_data)) {
hoffset = GET_HDR_OFFSET_2_0(efuse_data);
efuse_addr++;
efuse_OneByteRead23a(padapter, efuse_addr,
&efuse_data);
if (ALL_WORDS_DISABLED(efuse_data)) {
efuse_addr++;
continue;
}
hoffset |= ((efuse_data & 0xF0) >> 1);
hworden = efuse_data & 0x0F;
} else {
hoffset = (efuse_data >> 4) & 0x0F;
hworden = efuse_data & 0x0F;
}
word_cnts = Efuse_CalculateWordCnts23a(hworden);
/* read next header */
efuse_addr += (word_cnts * 2) + 1;
}
/* Check if we need to check next bank efuse */
if (efuse_addr < retU2)
break; /* don't need to check next bank. */
}
retU2 = ((bank - 1) * EFUSE_BT_REAL_BANK_CONTENT_LEN) + efuse_addr;
pHalData->BTEfuseUsedBytes = retU2;
DBG_8723A("%s: CurrentSize =%d\n", __func__, retU2);
return retU2;
} | false | false | false | false | false | 0 |
ITR_indexTT(tkitr_t *itr, kterm_t tt, int def)
{
int i;
for(i = itr->c; i < itr->e; i++) {
if(TT_(itr->ts[i]) == tt) return i;
}
return def;
} | false | false | false | false | false | 0 |
propertySetXMLRead(const std::string &el,
std::map<std::string, std::string> map,
Property::Set &set,
Property::Property *¤tProp) {
if (el == "property") {
std::string propName = map["name"];
std::string propType = map["type"];
int dimension = atoi(map["dimension"].c_str());
currentProp = set.fetchProperty(propName, false);
if(!currentProp) {
if (propType == "int") {
currentProp = new Property::Int(propName, dimension, false, 0);
} else if (propType == "string") {
currentProp = new Property::String(propName, dimension, false, "");
} else if (propType == "double") {
currentProp = new Property::Double(propName, dimension, false, 0);
} else if (propType == "pointer") {
currentProp = new Property::Pointer(propName, dimension, false, 0);
}
set.addProperty(currentProp);
}
return;
}
if (el == "value" && currentProp) {
int index = atoi(map["index"].c_str());
std::string value = map["value"];
switch (currentProp->getType()) {
case Property::eInt:
set.setIntProperty(currentProp->getName(), atoi(value.c_str()), index);
break;
case Property::eString:
set.setStringProperty(currentProp->getName(), value, index);
break;
case Property::eDouble:
set.setDoubleProperty(currentProp->getName(), atof(value.c_str()), index);
break;
case Property::ePointer:
break;
default:
break;
}
return;
}
std::cout << "got unrecognised key " << el << "\n";
assert(false);
} | false | false | false | false | false | 0 |
write(hsStream* S) {
S->writeShort(fName.len());
S->writeStr(fName);
S->writeInt(fVars.getSize());
S->writeBool(fServerMayDelete);
for (size_t i=0; i<fVars.getSize(); i++)
fVars[i].write(S);
} | false | false | false | false | false | 0 |
save_custom_extra (int *len, uae_u8 *dstptr)
{
uae_u8 *dstbak, *dst;
if (dstptr)
dstbak = dst = dstptr;
else
dstbak = dst = xmalloc (uae_u8, 1000);
SL ((currprefs.cs_compatible << 24) | (&get_mem_bank (0) != &chipmem_bank ? 2 : 0) | 1);
SB (currprefs.genlock ? 1 : 0);
SB (currprefs.cs_rtc);
SL (currprefs.cs_rtc_adjust);
SB (currprefs.cs_a1000ram ? 1 : 0);
SB (currprefs.cs_slowmemisfast ? 1 : 0);
SB (currprefs.cs_a2091 ? 1 : 0);
SB (currprefs.cs_a4091 ? 1 : 0);
SB (currprefs.cs_cdtvscsi ? 1 : 0);
SB (currprefs.cs_pcmcia ? 1 : 0);
SB (currprefs.cs_ciaatod);
SB (currprefs.cs_ciaoverlay ? 1 : 0);
SB (currprefs.cs_agnusbltbusybug ? 1 : 0);
SB (currprefs.cs_denisenoehb ? 1 : 0);
SB (currprefs.cs_agnusrev);
SB (currprefs.cs_deniserev);
SB (currprefs.cs_fatgaryrev);
SB (currprefs.cs_ramseyrev);
SB (currprefs.cs_cd32c2p);
SB (currprefs.cs_cd32cd);
SB (currprefs.cs_cd32nvram);
SB (currprefs.cs_cdtvcd ? 1 : 0);
SB (currprefs.cs_cdtvram ? 1 : 0);
SB (currprefs.cs_cdtvcard);
SB (currprefs.cs_df0idhw ? 1 : 0);
SB (currprefs.cs_dipagnus ? 1 : 0);
SB (currprefs.cs_ide);
SB (currprefs.cs_mbdmac);
SB (currprefs.cs_ksmirror_a8 ? 1 : 0);
SB (currprefs.cs_ksmirror_e0 ? 1 : 0);
SB (currprefs.cs_resetwarning ? 1 : 0);
*len = dst - dstbak;
return dstbak;
} | false | false | false | false | false | 0 |
parseVideoTag(const FLVTag& flvtag, const FLVVideoTag& videotag, boost::uint32_t thisTagPos)
{
if ( ! _video ) {
log_error(_("Unexpected video tag found at offset %d of FLV stream "
"advertising no video in header. We'll warn only once per "
"FLV, expecting any further video tag."), thisTagPos);
_video = true; // TOCHECK: is this safe ?
}
bool header = false;
boost::uint32_t bodyLength = flvtag.body_size;
switch(videotag.codec) {
case VIDEO_CODEC_VP6:
case VIDEO_CODEC_VP6A:
{
_stream->read_byte();
--bodyLength;
break;
}
case VIDEO_CODEC_H264:
{
boost::uint8_t packettype = _stream->read_byte();
IF_VERBOSE_PARSE( log_debug(_("AVC packet type: %d"),
(unsigned)packettype) );
header = (packettype == 0);
// 24-bits value for composition time offset ignored for now.
boost::uint8_t tmp[3];
_stream->read(tmp, 3);
bodyLength -= 4;
break;
}
default:
break;
}
std::auto_ptr<EncodedVideoFrame> frame = readVideoFrame(bodyLength-1,
flvtag.timestamp);
if ( ! frame.get() ) {
log_error(_("could not read video frame?"));
}
// If this is the first videoframe no info about the
// video format has been noted, so we do that now
if ( ! _videoInfo.get() ) {
_videoInfo.reset(new VideoInfo(videotag.codec, 0, 0, 0, 0,
CODEC_TYPE_FLASH));
if (header) {
// The frame is 0-padded up to the end. It may be larger than
// this if fewer bytes were read than requested, but it is
// never smaller.
const size_t bufSize = frame->dataSize() + paddingBytes;
boost::uint8_t* data = new boost::uint8_t[bufSize];
std::copy(frame->data(), frame->data() + bufSize, data);
_videoInfo->extra.reset(
new ExtraVideoInfoFlv(data, frame->dataSize())
);
// Don't bother emitting the header buffer.
frame.reset();
}
}
return frame;
} | false | false | false | false | false | 0 |
DoAlarmAction(void)
{
if (hide_taskbar_alarm)
{
hide_taskbar_alarm = False;
HideTaskBar();
}
if (stick_taskbar_alarm)
{
stick_taskbar_alarm = False;
WarpTaskBar(auto_stick_y);
}
if (tip_window_alarm)
{
tip_window_alarm = False;
if (AutoHide && WindowState == 0)
{
Window dummy_rt, dummy_c;
int abs_x, abs_y, pos_x, pos_y;
unsigned int dummy;
XEvent sevent;
/* We are now "sure" that the TaskBar is not hidden for the
Event loop. We send a motion notify for activating tips */
WindowState = 1;
if (FQueryPointer(dpy, win, &dummy_rt,&dummy_c, &abs_x, &abs_y,
&pos_x, &pos_y, &dummy) == False)
{
/* pointer is on a different screen */
abs_x = 0;
abs_y = 0;
}
sevent.xmotion.x = pos_x;
sevent.xmotion.y = pos_y;
sevent.xany.type = MotionNotify;
sevent.xmotion.state = 0;
FSendEvent(dpy, win, False, EnterWindowMask, &sevent);
Tip.type = NO_TIP;
}
else
ShowTipWindow(1);
}
} | false | false | false | false | false | 0 |
mousePressEvent(QMouseEvent *e)
{
if (Qt::LeftButton!=e->button())
return;
e->accept();
for (int index = 0; index < m_tabs.count(); ++index) {
if (tabRect(index).contains(e->pos())) {
m_currentIndex = index;
update();
m_triggerTimer.start(0);
break;
}
}
} | false | false | false | false | false | 0 |
data(Type t) const
{
ByteVector v;
switch(t) {
case Latin1:
{
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++)
v.append(char(*it));
break;
}
case UTF8:
{
std::string s = to8Bit(true);
v.setData(s.c_str(), s.length());
break;
}
case UTF16:
{
// Assume that if we're doing UTF16 and not UTF16BE that we want little
// endian encoding. (Byte Order Mark)
v.append(char(0xff));
v.append(char(0xfe));
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
char c1 = *it & 0xff;
char c2 = *it >> 8;
v.append(c1);
v.append(c2);
}
break;
}
case UTF16BE:
{
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
char c1 = *it >> 8;
char c2 = *it & 0xff;
v.append(c1);
v.append(c2);
}
break;
}
case UTF16LE:
{
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
char c1 = *it & 0xff;
char c2 = *it >> 8;
v.append(c1);
v.append(c2);
}
break;
}
}
return v;
} | false | false | false | false | false | 0 |
extract_hostnames(struct remote *rp, GtkWidget *hwig, GtkWidget *awig)
{
const gchar *h = gtk_entry_get_text(GTK_ENTRY(hwig));
const gchar *a = gtk_entry_get_text(GTK_ENTRY(awig));
netid_t resip;
enum IPatype htype;
if (strlen(h) >= HOSTNSIZE) {
doerror(toplevel, "Sorry host name %s is too long", h);
return 0;
}
if (strlen(a) >= HOSTNSIZE) {
doerror(toplevel, "Sorry alias name %s is too long", a);
return 0;
}
htype = validhostname(h, &resip);
if (htype == NO_IPADDR)
return 0;
if (htype == IPADDR_IP) {
char *c;
if (strlen(a) == 0) {
doerror(toplevel, "Alias must be given with numeric host %s", h);
return 0;
}
if (hnameclashes(a) && strcmp(a, rp->alias) != 0) {
doerror(toplevel, "Alias name %s clashes with existing name", a);
return 0;
}
c = ipclashes(resip);
if (c && resip != rp->hostid) {
doerror(toplevel, "IP address clashes with existing IP for %s", c);
return 0;
}
rp->hostid = resip;
rp->ht_flags = HT_HOSTISIP;
}
else {
char *c;
if (hnameclashes(h) && strcmp(h, rp->hostname) != 0) {
doerror(toplevel, "Host name %s clashes with an existing name", h);
return 0;
}
c = ipclashes(resip);
if (c && resip != rp->hostid) {
doerror(toplevel, "IP address clashes with existing for %s", c);
return 0;
}
if (strlen(a) != 0 && hnameclashes(a) && strcmp(a, rp->alias) != 0) {
doerror(toplevel, "Alias name %s clashes with an existing name", a);
return 0;
}
rp->ht_flags = 0;
rp->hostid = resip;
}
strncpy(rp->hostname, h, HOSTNSIZE-1);
strncpy(rp->alias, a, HOSTNSIZE-1);
return 1;
} | false | true | false | false | false | 1 |
mbfl_identify_encoding_name(mbfl_string *string, enum mbfl_no_encoding *elist, int elistsz, int strict)
{
const mbfl_encoding *encoding;
encoding = mbfl_identify_encoding(string, elist, elistsz, strict);
if (encoding != NULL &&
encoding->no_encoding > mbfl_no_encoding_charset_min &&
encoding->no_encoding < mbfl_no_encoding_charset_max) {
return encoding->name;
} else {
return NULL;
}
} | false | false | false | false | false | 0 |
vf_selection_get_list_by_index(ViewFile *vf)
{
GList *list = NULL;
switch (vf->type)
{
case FILEVIEW_LIST: list = vflist_selection_get_list_by_index(vf); break;
case FILEVIEW_ICON: list = vficon_selection_get_list_by_index(vf); break;
}
return list;
} | false | false | false | false | false | 0 |
show_one_toolset(FILE *toolfile, int toolnum, word32 addr)
{
word32 rout_addr;
int num_routs;
int i;
num_routs = dis_get_memory_ptr(addr);
fprintf(toolfile, "Tool 0x%02x, table: 0x%06x, num_routs:%03x\n",
toolnum, addr, num_routs);
for(i = 1; i < num_routs; i++) {
rout_addr = dis_get_memory_ptr(addr + 4*i);
fprintf(toolfile, "%06x = %02x%02x\n", rout_addr, i, toolnum);
}
} | false | false | false | false | false | 0 |
clip(int x, int y, int w, int h)
{
if (graphics_disabled) return;
ex = x;
ey = y;
ew = w;
eh = h;
if (ew < 0) ew = 0;
if (eh < 0) eh = 0;
if (ex < 0)
{
ew += ex;
ex = 0;
}
if (ey < 0)
{
eh += ey;
ey = 0;
}
if (ex+ew > table_width)
ew = table_width - ex;
if (ey+eh > table_height)
eh = table_height - ey;
reset_clip();
} | false | false | false | false | false | 0 |
apol_infoflow_analysis_append_class_perm(const apol_policy_t * p,
apol_infoflow_analysis_t * ia, const char *class_name, const char *perm_name)
{
apol_obj_perm_t *op = NULL;
size_t i;
if (p == NULL || ia == NULL) {
ERR(p, "%s", strerror(EINVAL));
errno = EINVAL;
return -1;
}
if (class_name == NULL) {
apol_vector_destroy(&ia->class_perms);
return 0;
}
if (perm_name == NULL) {
ERR(p, "%s", strerror(EINVAL));
errno = EINVAL;
return -1;
}
if (ia->class_perms == NULL && (ia->class_perms = apol_vector_create(apol_obj_perm_free)) == NULL) {
ERR(p, "%s", strerror(errno));
return -1;
}
if (apol_vector_get_index(ia->class_perms, (void *)class_name, compare_class_perm_by_class_name, NULL, &i) < 0) {
if (perm_name) {
if ((op = apol_obj_perm_create()) == NULL) {
ERR(p, "%s", strerror(errno));
return -1;
}
if (apol_obj_perm_set_obj_name(op, class_name) ||
apol_obj_perm_append_perm(op, perm_name) || apol_vector_append(ia->class_perms, op)) {
ERR(p, "%s", strerror(errno));
apol_obj_perm_free(op);
return -1;
}
} else {
return 0; /* nothing to clear; done */
}
} else {
op = apol_vector_get_element(ia->class_perms, i);
if (apol_obj_perm_append_perm(op, perm_name)) {
ERR(p, "%s", strerror(errno));
return -1;
}
}
return 0;
} | false | false | false | false | false | 0 |
gkd_secret_objects_dispatch (GkdSecretObjects *self, DBusMessage *message)
{
GckBuilder builder = GCK_BUILDER_INIT;
DBusMessage *reply = NULL;
GError *error = NULL;
GList *objects;
GckSession *session;
gchar *c_ident;
gchar *i_ident;
gboolean is_item;
const char *path;
g_return_val_if_fail (GKD_SECRET_IS_OBJECTS (self), NULL);
g_return_val_if_fail (message, NULL);
path = dbus_message_get_path (message);
g_return_val_if_fail (path, NULL);
if (!parse_object_path (self, path, &c_ident, &i_ident) || !c_ident)
return gkd_secret_error_no_such_object (message);
/* The session we're using to access the object */
session = gkd_secret_service_get_pkcs11_session (self->service, dbus_message_get_sender (message));
g_return_val_if_fail (session, NULL);
if (i_ident) {
is_item = TRUE;
gck_builder_add_ulong (&builder, CKA_CLASS, CKO_SECRET_KEY);
gck_builder_add_string (&builder, CKA_G_COLLECTION, c_ident);
gck_builder_add_string (&builder, CKA_ID, i_ident);
} else {
is_item = FALSE;
gck_builder_add_ulong (&builder, CKA_CLASS, CKO_G_COLLECTION);
gck_builder_add_string (&builder, CKA_ID, c_ident);
}
objects = gck_session_find_objects (session, gck_builder_end (&builder), NULL, &error);
g_free (c_ident);
g_free (i_ident);
if (error != NULL) {
g_warning ("couldn't lookup object: %s: %s", path, egg_error_message (error));
g_clear_error (&error);
}
if (!objects)
return gkd_secret_error_no_such_object (message);
if (is_item)
reply = item_message_handler (self, objects->data, message);
else
reply = collection_message_handler (self, objects->data, message);
gck_list_unref_free (objects);
return reply;
} | false | false | false | false | false | 0 |
globus_l_gram_audit_write_timestamp(
FILE * f,
time_t when,
const char * delim)
{
int rc;
char * t;
char * tmp;
struct tm tmv;
struct tm * tm_p;
#ifndef BUILD_LITE
char tbuf[26];
#endif
if (when == 0)
{
rc = fprintf(f, "\"NULL\"%s", delim);
return rc >= 0 ? GLOBUS_SUCCESS : GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES;
}
tm_p = globus_libc_gmtime_r(&when, &tmv);
if (tm_p == NULL)
{
return GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES;
}
t = asctime_r(tm_p, tbuf);
if (t == NULL)
{
return GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES;
}
tmp = strchr(t, '\n');
if (tmp)
{
*tmp = '\0';
}
tmp = strrchr(t, ' ');
*tmp = '\0';
rc = fprintf(f, "\"%s UTC %s\"%s", t, tmp+1, delim);
return rc >= 0 ? GLOBUS_SUCCESS : GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES;
} | true | true | false | false | false | 1 |
check_for_overlaps (VEC (fieldoff_s,heap) *fieldstack)
{
fieldoff_s *fo = NULL;
unsigned int i;
HOST_WIDE_INT lastoffset = -1;
FOR_EACH_VEC_ELT (fieldoff_s, fieldstack, i, fo)
{
if (fo->offset == lastoffset)
return true;
lastoffset = fo->offset;
}
return false;
} | false | false | false | false | false | 0 |
findInodeInfo(
unixFile *pFile, /* Unix file with file desc used in the key */
unixInodeInfo **ppInode /* Return the unixInodeInfo object here */
){
int rc; /* System call return code */
int fd; /* The file descriptor for pFile */
struct unixFileId fileId; /* Lookup key for the unixInodeInfo */
struct stat statbuf; /* Low-level file information */
unixInodeInfo *pInode = 0; /* Candidate unixInodeInfo object */
/* Get low-level information about the file that we can used to
** create a unique name for the file.
*/
fd = pFile->h;
rc = fstat(fd, &statbuf);
if( rc!=0 ){
pFile->lastErrno = errno;
#ifdef EOVERFLOW
if( pFile->lastErrno==EOVERFLOW ) return UNQLITE_NOTIMPLEMENTED;
#endif
return UNQLITE_IOERR;
}
#ifdef __APPLE__
/* On OS X on an msdos filesystem, the inode number is reported
** incorrectly for zero-size files. See ticket #3260. To work
** around this problem (we consider it a bug in OS X, not SQLite)
** we always increase the file size to 1 by writing a single byte
** prior to accessing the inode number. The one byte written is
** an ASCII 'S' character which also happens to be the first byte
** in the header of every SQLite database. In this way, if there
** is a race condition such that another thread has already populated
** the first page of the database, no damage is done.
*/
if( statbuf.st_size==0 && (pFile->fsFlags & UNQLITE_FSFLAGS_IS_MSDOS)!=0 ){
rc = write(fd, "S", 1);
if( rc!=1 ){
pFile->lastErrno = errno;
return UNQLITE_IOERR;
}
rc = fstat(fd, &statbuf);
if( rc!=0 ){
pFile->lastErrno = errno;
return UNQLITE_IOERR;
}
}
#endif
SyZero(&fileId,sizeof(fileId));
fileId.dev = statbuf.st_dev;
fileId.ino = statbuf.st_ino;
pInode = inodeList;
while( pInode && SyMemcmp((const void *)&fileId,(const void *)&pInode->fileId, sizeof(fileId)) ){
pInode = pInode->pNext;
}
if( pInode==0 ){
pInode = (unixInodeInfo *)unqlite_malloc( sizeof(*pInode) );
if( pInode==0 ){
return UNQLITE_NOMEM;
}
SyZero(pInode,sizeof(*pInode));
SyMemcpy((const void *)&fileId,(void *)&pInode->fileId,sizeof(fileId));
pInode->nRef = 1;
pInode->pNext = inodeList;
pInode->pPrev = 0;
if( inodeList ) inodeList->pPrev = pInode;
inodeList = pInode;
}else{
pInode->nRef++;
}
*ppInode = pInode;
return UNQLITE_OK;
} | false | false | false | false | false | 0 |
GetClippingPlaneInDataCoords(
vtkMatrix4x4 *propMatrix, int i, double hnormal[4])
{
vtkPlaneCollection *clipPlanes = this->ClippingPlanes;
const double *mat = *propMatrix->Element;
if (clipPlanes)
{
int n = clipPlanes->GetNumberOfItems();
if (i >= 0 && i < n)
{
// Get the plane
vtkPlane *plane = clipPlanes->GetItem(i);
double *normal = plane->GetNormal();
double *origin = plane->GetOrigin();
// Compute the plane equation
double v1 = normal[0];
double v2 = normal[1];
double v3 = normal[2];
double v4 = -(v1*origin[0] + v2*origin[1] + v3*origin[2]);
// Transform normal from world to data coords
hnormal[0] = v1*mat[0] + v2*mat[4] + v3*mat[8] + v4*mat[12];
hnormal[1] = v1*mat[1] + v2*mat[5] + v3*mat[9] + v4*mat[13];
hnormal[2] = v1*mat[2] + v2*mat[6] + v3*mat[10] + v4*mat[14];
hnormal[3] = v1*mat[3] + v2*mat[7] + v3*mat[11] + v4*mat[15];
return;
}
}
vtkErrorMacro("Clipping plane index " << i << " is out of range.");
} | false | false | false | false | true | 1 |
scale_vec(double scalefactor, long nvals, double *restrict values)
{
long n;
#if defined(_OPENMP)
#pragma omp parallel for default(none) shared(nvals, scalefactor, values)
#endif
for ( n = 0; n < nvals; ++n )
{
values[n] *= scalefactor;
}
} | false | false | false | false | false | 0 |
max14577_muic_chg_handler(struct max14577_muic_info *info)
{
int chg_type;
bool attached;
int ret = 0;
chg_type = max14577_muic_get_cable_type(info,
MAX14577_CABLE_GROUP_CHG, &attached);
dev_dbg(info->dev,
"external connector is %s(chg_type:0x%x, prev_chg_type:0x%x)\n",
attached ? "attached" : "detached",
chg_type, info->prev_chg_type);
switch (chg_type) {
case MAX14577_CHARGER_TYPE_USB:
/* PATH:AP_USB */
ret = max14577_muic_set_path(info, info->path_usb, attached);
if (ret < 0)
return ret;
extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
break;
case MAX14577_CHARGER_TYPE_DEDICATED_CHG:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_DCP,
attached);
break;
case MAX14577_CHARGER_TYPE_DOWNSTREAM_PORT:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_CDP,
attached);
break;
case MAX14577_CHARGER_TYPE_SPECIAL_500MA:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SLOW,
attached);
break;
case MAX14577_CHARGER_TYPE_SPECIAL_1A:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_FAST,
attached);
break;
case MAX14577_CHARGER_TYPE_NONE:
case MAX14577_CHARGER_TYPE_DEAD_BATTERY:
break;
default:
dev_err(info->dev,
"failed to detect %s accessory (chg_type:0x%x)\n",
attached ? "attached" : "detached", chg_type);
return -EINVAL;
}
return 0;
} | false | false | false | false | false | 0 |
deliver()
{
m_server->incomingMessage( m_message );
m_delivered = true;
} | false | false | false | false | false | 0 |
bilinear_magnify_make_weights (PixopsFilterDimension *dim,
double scale)
{
double *pixel_weights;
int n;
int offset;
int i;
if (scale > 1.0) /* Linear */
{
n = 2;
dim->offset = 0.5 * (1 / scale - 1);
}
else /* Tile */
{
n = ceil (1.0 + 1.0 / scale);
dim->offset = 0.0;
}
dim->n = n;
dim->weights = g_try_malloc_n (sizeof (double) * SUBSAMPLE, n);
if (dim->weights == NULL)
return FALSE;
pixel_weights = dim->weights;
for (offset=0; offset < SUBSAMPLE; offset++)
{
double x = (double)offset / SUBSAMPLE;
if (scale > 1.0) /* Linear */
{
for (i = 0; i < n; i++)
*(pixel_weights++) = (((i == 0) ? (1 - x) : x) / scale) * scale;
}
else /* Tile */
{
double a = x + 1 / scale;
/* x
* ---------|--.-|----|--.-|------- SRC
* ------------|---------|--------- DEST
*/
for (i = 0; i < n; i++)
{
if (i < x)
{
if (i + 1 > x)
*(pixel_weights++) = (MIN (i + 1, a) - x) * scale;
else
*(pixel_weights++) = 0;
}
else
{
if (a > i)
*(pixel_weights++) = (MIN (i + 1, a) - i) * scale;
else
*(pixel_weights++) = 0;
}
}
}
}
return TRUE;
} | false | false | false | false | false | 0 |
getRowFromIdPos(int id, int pos) const
{
bool foundid = false;
// this loop finds the last *nonempty* row with the same id
// and position <= pos
RowList::const_iterator bestrow = rowlist.begin();
RowList::const_iterator it = rowlist.begin();
RowList::const_iterator const end = rowlist.end();
for (; it != end; ++it) {
if (it->id() == id && it->pos() <= pos) {
foundid = true;
if (bestrow->id() != id || it->pos() > bestrow->pos())
bestrow = it;
} else if (foundid)
break;
}
if (!foundid)
return rowlist.size();
return distance(rowlist.begin(), bestrow) + 1;
} | false | false | false | false | false | 0 |
Alignment_print_sugar_block(Alignment *alignment,
Sequence *query, Sequence *target, FILE *fp){
fprintf(fp, "%s %d %d %c %s %d %d %c %d",
query->id,
Alignment_get_coordinate(alignment, query, target,
TRUE, TRUE),
Alignment_get_coordinate(alignment, query, target,
TRUE, FALSE),
Sequence_get_strand_as_char(query),
target->id,
Alignment_get_coordinate(alignment, query, target,
FALSE, TRUE),
Alignment_get_coordinate(alignment, query, target,
FALSE, FALSE),
Sequence_get_strand_as_char(target),
alignment->score);
return;
} | false | false | false | false | false | 0 |
arcnet_unregister_proto(struct ArcProto *proto)
{
int count;
if (arc_proto_default == proto)
arc_proto_default = &arc_proto_null;
if (arc_bcast_proto == proto)
arc_bcast_proto = arc_proto_default;
if (arc_raw_proto == proto)
arc_raw_proto = arc_proto_default;
for (count = 0; count < 256; count++) {
if (arc_proto_map[count] == proto)
arc_proto_map[count] = arc_proto_default;
}
} | false | false | false | false | false | 0 |
cavan_window_init(struct cavan_window *win, struct cavan_application_context *context)
{
int ret;
struct cavan_display_device *display;
if (context == NULL)
{
pr_red_info("context == NULL");
return -EINVAL;
}
ret = pthread_mutex_init(&win->lock, NULL);
if (ret < 0)
{
pr_error_info("pthread_mutex_init");
return ret;
}
ret = double_link_init(&win->child_link, MEMBER_OFFSET(struct cavan_window, node));
if (ret < 0)
{
pr_red_info("double_link_init");
goto out_pthread_mutex_destroy;
}
double_link_node_init(&win->node);
win->parent = NULL;
win->border_width = 2;
win->context = context;
win->on_destroy = NULL;
win->on_paint = NULL;
win->on_clicked = NULL;
win->on_double_clicked = NULL;
win->on_move = NULL;
win->on_entry = NULL;
win->on_exit = NULL;
win->on_key_pressed = NULL;
win->pressed = false;
win->visible = true;
win->active = true;
win->move_mask = 0;
win->touch_mask = 0;
win->destroy_handler = cavan_window_destroy_handler;
win->paint_handler = cavan_window_paint_handler;
win->click_handler = cavan_window_click_handler;
win->move_handler = cavan_window_move_handler;
win->entry_handler = cavan_window_entry_handler;
win->exit_handler = cavan_window_exit_handler;
win->key_handler = cavan_window_key_handler;
win->get_rect_handler = cavan_window_get_rect_handler;
display = context->display;
win->back_color = cavan_display_build_color3f(display, 0, 0, 0);
win->fore_color = cavan_display_build_color3f(display, 1.0, 1.0, 1.0);
win->border_color = cavan_display_build_color3f(display, 1.0, 1.0, 1.0);
return 0;
out_pthread_mutex_destroy:
pthread_mutex_destroy(&win->lock);
return ret;
} | false | false | false | false | false | 0 |
is_cardinal_tileset_dir(const struct tileset *t,
enum direction8 dir)
{
if (t->hex_width > 0 || t->hex_height > 0) {
return is_valid_tileset_dir(t, dir);
} else {
return (dir == DIR8_NORTH || dir == DIR8_EAST
|| dir == DIR8_SOUTH || dir == DIR8_WEST);
}
} | true | true | false | false | false | 1 |
gsb_scheduler_list_fill_transaction_row ( GtkTreeStore *store,
GtkTreeIter *iter,
const gchar *line[SCHEDULER_COL_VISIBLE_COLUMNS] )
{
gchar *color_str = NULL;
gint i;
if ( line[COL_NB_AMOUNT] && g_utf8_strchr ( line[COL_NB_AMOUNT], -1, '-' ) )
color_str = "red";
else
{
g_free ( color_str );
color_str = NULL;
}
for ( i=0 ; i<SCHEDULER_COL_VISIBLE_COLUMNS ; i++ )
{
if ( i == 6 )
gtk_tree_store_set ( store, iter, i, line[i], SCHEDULER_COL_NB_AMOUNT_COLOR, color_str, -1 );
else
gtk_tree_store_set ( store, iter, i, line[i], -1 );
}
return FALSE;
} | false | false | false | false | true | 1 |
deviceClassIntegrate(device_ *r)
{
devicePrivate_ *p;
double Veq, R, i0;
ReturnErrIf(r == NULL);
p = r->private;
ReturnErrIf(p == NULL);
Debug("Integrating %s %s %p", r->class->type, r->refdes, r);
/* Modified Nodal Analysis Stamp
*
* |_Vk_Vj_Ir_|_rhs_|
* k | -- -- 1 | -- | + /\ Rn -
* j | -- -- -1 | -- | k__ / \__/\/\/\__j
* r | 1 -1 -Rn|-Veq | \ /
* \/ Veq
*/
i0 = rowGetSolution(p->rowR);
ReturnErrIf(isnan(i0));
ReturnErrIf(integratorIntegrate(p->integrator, i0, &R, &Veq));
/* Set-up Matrices based on MNA Stamp Above*/
ReturnErrIf(nodeDataPlus(p->nodeRR, -(R - p->R)));
p->R = R;
ReturnErrIf(rowRHSPlus(p->rowR, -(Veq - p->Veq)));
p->Veq = Veq;
return 0;
} | false | false | false | false | false | 0 |
_rtl92d_phy_pimode_switch(struct ieee80211_hw *hw, bool pi_mode)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
u32 mode;
RTPRINT(rtlpriv, FINIT, INIT_IQK,
"BB Switch to %s mode!\n", pi_mode ? "PI" : "SI");
mode = pi_mode ? 0x01000100 : 0x01000000;
rtl_set_bbreg(hw, 0x820, MASKDWORD, mode);
rtl_set_bbreg(hw, 0x828, MASKDWORD, mode);
} | false | false | false | false | false | 0 |
print_comment(FILE *file, CloogOptions *options,
const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
if (options->language == LANGUAGE_FORTRAN) {
fprintf(file, "! ");
vfprintf(file, fmt, args);
fprintf(file, "\n");
} else {
fprintf(file, "/* ");
vfprintf(file, fmt, args);
fprintf(file, " */\n");
}
} | false | false | false | false | false | 0 |
SWIG_Tcl_GetModule(Tcl_Interp *interp) {
const char *data;
swig_module_info *ret = 0;
/* first check if pointer already created */
data = Tcl_GetVar(interp, (char *)"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TCL_GLOBAL_ONLY);
if (data) {
SWIG_UnpackData(data, &ret, sizeof(swig_type_info **));
}
return ret;
} | false | false | false | false | false | 0 |
write_ratio_db(PyObject *self, PyObject *args){
PyObject *ratio_dict;
PyObject *dict_key, *dict_value;
DBT key, data;
DB *rdb;
double ratio;
simprof sp;
Py_ssize_t ppos;
int i;
DB_BTREE_STAT *stat;
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
if(!PyArg_ParseTuple(args, "O", &ratio_dict))
return NULL;
Py_INCREF(ratio_dict);
printf("dict_check: %d\n", PyDict_Check(ratio_dict));
printf("dict_size: %d\n", (int)PyDict_Size(ratio_dict));
sqlite_db_env_open(NULL);
sqlite_db_primary_open(&rdb, "ratios", DB_BTREE, 4*1024, DB_CREATE, 0, NULL);
printf("opened db!\n");
ppos = 0;
while(PyDict_Next(ratio_dict, &ppos, &dict_key, &dict_value)){
for(i=0; i < NUM_COMPS; ++i){
*(int*)(((char*)&sp)+sp_offsets[i]) = (int)PyInt_AsLong(PyTuple_GetItem(dict_key, (Py_ssize_t)i));
}
ratio = PyFloat_AsDouble(dict_value);
key.data = &sp;
key.size = sizeof(sp);
data.data = ∶
data.size = sizeof(double);
rdb->put(rdb, NULL, &key, &data, 0);
}
rdb->stat(rdb, NULL, &stat, 0);
//printf("numkeys: %lu\n", (u_long)stat->bt_nkeys);
free(stat);
rdb->close(rdb, 0);
sqlite_db_env_close();
Py_DECREF(ratio_dict);
Py_INCREF(Py_None);
return Py_None;
} | false | false | false | false | false | 0 |
gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode,
const gchar * tag, va_list var_args)
{
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (gst_tag_list_is_writable (list));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
g_return_if_fail (tag != NULL);
if (mode == GST_TAG_MERGE_REPLACE_ALL) {
gst_structure_remove_all_fields (GST_TAG_LIST_STRUCTURE (list));
}
while (tag != NULL) {
GstTagInfo *info;
info = gst_tag_lookup (tag);
if (G_UNLIKELY (info == NULL)) {
g_warning ("unknown tag '%s'", tag);
return;
}
gst_tag_list_add_value_internal (list, mode, tag, va_arg (var_args,
GValue *), info);
tag = va_arg (var_args, gchar *);
}
} | false | false | false | false | false | 0 |
pass_establish(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
{
struct iwch_ep *ep = ctx;
struct cpl_pass_establish *req = cplhdr(skb);
PDBG("%s ep %p\n", __func__, ep);
ep->snd_seq = ntohl(req->snd_isn);
ep->rcv_seq = ntohl(req->rcv_isn);
set_emss(ep, ntohs(req->tcp_opt));
dst_confirm(ep->dst);
state_set(&ep->com, MPA_REQ_WAIT);
start_ep_timer(ep);
return CPL_RET_BUF_DONE;
} | false | false | false | false | false | 0 |
ac_out(U16B low, U16B high, U16B tot) {
register U32B r;
r=(U32B)(h-l)+1;
h=(U16B)(r*high/tot-1)+l;
l+=(U16B)(r*low/tot);
if (!((h^l)&0x8000)) {
putbit(l&0x8000);
while(s) {
--s;
putbit(~l&0x8000);
}
l<<=1;
h<<=1;
h|=1;
while (!((h^l)&0x8000)) {
putbit(l&0x8000);
l<<=1;
h<<=1;
h|=1;
}
}
while ((l&0x4000)&&!(h&0x4000)) {
++s;
l<<=1;
l&=0x7fff;
h<<=1;
h|=0x8001;
}
} | false | false | false | false | false | 0 |
nilfs_collect_dat_data(struct nilfs_sc_info *sci,
struct buffer_head *bh, struct inode *inode)
{
int err;
err = nilfs_bmap_propagate(NILFS_I(inode)->i_bmap, bh);
if (err < 0)
return err;
err = nilfs_segctor_add_file_block(sci, bh, inode, sizeof(__le64));
if (!err)
sci->sc_datablk_cnt++;
return err;
} | false | false | false | false | false | 0 |
fix_notes(const char *name, char *notes)
{
char *cleft, *cright, *cback, *ctmp;
if ((! name) || (! notes)) {
return notes;
}
/* do we have a BACKSLASH in shortname ? */
cback = strchr(name, '\\');
if ((! cback) || (cback == name)) {
return notes;
}
/* do we have left, but no right parenthesis in notes ? */
if (!(cleft = strchr(notes, '('))) {
return notes;
}
cright = strchr(notes, ')');
if (cright && (cright > cleft)) {
return notes;
}
/* now contruct the new name */
ctmp = lrtrim(xstrndup(notes, cleft - notes));
xfree(notes);
xasprintf(¬es, "%s (%*.*s)", ctmp, cback - name, cback - name, name);
xfree(ctmp);
return notes;
} | false | false | false | false | false | 0 |
ssa_analyze_liveness(struct compilation_unit *cu)
{
int err = 0;
err = init_sets(cu);
if (err)
goto out;
analyze_use_def(cu);
err = analyze_live_sets(cu);
out:
return err;
} | false | false | false | false | false | 0 |
odb_cache(git_odb *odb)
{
if (odb->rc.owner != NULL) {
git_repository *owner = odb->rc.owner;
return &owner->objects;
}
return &odb->own_cache;
} | false | false | false | false | false | 0 |
Cpdt(Task *task)
{
task->clock = 0.0;
ReadytaskChk_for_Dt(task);
comp_cand_tasks(task);
comp_cand_pc(task);
while (check_end(task)) {
while (task->Readys > 0
&& number_IntSet(task->cand_pc) > 0) {
Makectt(task);
ReadySel(task);
TaskAssign(task);
#ifdef __DEALING_WITH_COST_ZERO__
if (task->Exectime[task->SelectTask] == 0) {
add1_IntSet(task->TaskEndF, task->SelectTask);
ReadytaskChk_for_Dt(task);
comp_cand_pc(task);
} else {
#endif /* __DEALING_WITH_COST_ZERO__ */
update_cand_pc(task);
update_readytask(task);
#ifdef __DEALING_WITH_COST_ZERO__
}
#endif /* __DEALING_WITH_COST_ZERO__ */
comp_cand_tasks(task);
}
update_clock(task);
set_task_end_flag(task);
ReadytaskChk_for_Dt(task);
comp_cand_tasks(task);
comp_cand_pc(task);
}
} | false | false | false | false | false | 0 |
set_value(std::string val, CdlValueFormat new_format)
{
CYG_REPORT_FUNCNAME("CdlSimpleValue::set_value (string)");
CYG_REPORT_FUNCARG1XV(this);
value = val;
int_value = 0;
double_value = 0.0;
valid_flags = string_valid;
format = new_format;
} | false | false | false | false | false | 0 |
usm_handle_report(void *sessp,
netsnmp_transport *transport, netsnmp_session *session,
int result, netsnmp_pdu *pdu)
{
/*
* handle reportable errors
*/
/* this will get in our way */
usm_free_usmStateReference(pdu->securityStateRef);
pdu->securityStateRef = NULL;
switch (result) {
case SNMPERR_USM_AUTHENTICATIONFAILURE:
{
int res = session->s_snmp_errno;
session->s_snmp_errno = result;
if (session->callback) {
session->callback(NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE,
session, pdu->reqid, pdu,
session->callback_magic);
}
session->s_snmp_errno = res;
}
/* fallthrough */
case SNMPERR_USM_UNKNOWNENGINEID:
case SNMPERR_USM_UNKNOWNSECURITYNAME:
case SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL:
case SNMPERR_USM_NOTINTIMEWINDOW:
case SNMPERR_USM_DECRYPTIONERROR:
if (SNMP_CMD_CONFIRMED(pdu->command) ||
(pdu->command == 0
&& (pdu->flags & SNMP_MSG_FLAG_RPRT_BIT))) {
netsnmp_pdu *pdu2;
int flags = pdu->flags;
pdu->flags |= UCD_MSG_FLAG_FORCE_PDU_COPY;
pdu2 = snmp_clone_pdu(pdu);
pdu->flags = pdu2->flags = flags;
snmpv3_make_report(pdu2, result);
if (0 == snmp_sess_send(sessp, pdu2)) {
snmp_free_pdu(pdu2);
/*
* TODO: indicate error
*/
}
}
break;
}
} | false | false | false | false | false | 0 |
toggleFullscreen()
{
if ( !GetScreen() )
return false;
int w = GetScreen()->w;
int h = GetScreen()->h;
// queueOperation( new MouseVisibility( false ), true );
int flags = SDL_SWSURFACE;
if ( !fullScreen )
flags |= SDL_FULLSCREEN;
queueOperation( new InitScreenOp( w,h,bitsperpixel,flags, InitScreenOp::ScreenRegistrationFunctor( this, &ASC_PG_App::SetNewScreenSurface )), true );
fullScreen = GetScreen()->flags & SDL_FULLSCREEN;
/*
SDL_Surface* screen = SDL_SetVideoMode(w, h, bitsperpixel, flags);
if (screen == NULL) {
screen = SDL_SetVideoMode(w, h, bitsperpixel, 0);
fullScreen = false;
} else
fullScreen = !fullScreen;
SetScreen(screen);
*/
PG_Widget::UpdateScreen();
// queueOperation( new MouseVisibility( true ), true );
return true;
} | false | false | false | false | false | 0 |
search_find_again(gboolean change_direction)
{
GeanyDocument *doc = document_get_current();
g_return_if_fail(doc != NULL);
if (search_data.text)
{
gboolean forward = ! search_data.backwards;
gint result = document_find_text(doc, search_data.text, search_data.original_text, search_data.flags,
change_direction ? forward : !forward, FALSE, NULL);
if (result > -1)
editor_display_current_line(doc->editor, 0.3F);
if (search_data.search_bar)
ui_set_search_entry_background(
toolbar_get_widget_child_by_name("SearchEntry"), (result > -1));
}
} | false | false | false | false | false | 0 |
encode_cb_sequence_res(struct svc_rqst *rqstp,
struct xdr_stream *xdr,
const struct cb_sequenceres *res)
{
__be32 *p;
__be32 status = res->csr_status;
if (unlikely(status != 0))
goto out;
status = encode_sessionid(xdr, &res->csr_sessionid);
if (status)
goto out;
p = xdr_reserve_space(xdr, 4 * sizeof(uint32_t));
if (unlikely(p == NULL))
return htonl(NFS4ERR_RESOURCE);
*p++ = htonl(res->csr_sequenceid);
*p++ = htonl(res->csr_slotid);
*p++ = htonl(res->csr_highestslotid);
*p++ = htonl(res->csr_target_highestslotid);
out:
dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
return status;
} | false | false | false | false | false | 0 |
LM_UploadBlock (void)
{
int texture = gl_lms.current_lightmap_texture;
GL_SelectTexture (GL_TEXTURE0);
// FIXME: OH FFS this is so stupid: tell the GL_Bind batching mechanism
// that texture unit 0 has been re-bound, as it most certainly has been.
gl_state.currenttextures[gl_state.currenttmu] = -1;
GL_Bind( gl_state.lightmap_textures + texture );
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
qglTexImage2D( GL_TEXTURE_2D,
0,
GL_RGBA,
LIGHTMAP_SIZE, LIGHTMAP_SIZE,
0,
GL_LIGHTMAP_FORMAT,
GL_UNSIGNED_INT_8_8_8_8_REV,
gl_lms.lightmap_buffer );
#if 0
height = 0;
for (i = 0; i < LIGHTMAP_SIZE; i++)
{
if (gl_lms.allocated[i] > height)
height = gl_lms.allocated[i];
}
Com_Printf (" LIGHTMAP %d HEIGHT %d\n", gl_lms.current_lightmap_texture, height);
#endif
if ( ++gl_lms.current_lightmap_texture == MAX_LIGHTMAPS )
Com_Error( ERR_DROP, "LM_UploadBlock() - MAX_LIGHTMAPS exceeded\n" );
} | false | false | false | false | false | 0 |
CheckMult(int nindex1, int indexarray1[],
int nindex2, int indexarray2[],
int nindex3, int indexarray3[],
int &nindexr, int indexarrayr[]) const
{
int i, i2, i3;
nindexr=0;
int sortindexarray1[mx_array_dim], sortindexarray2[mx_array_dim],
sortindexarray3[mx_array_dim];
int contractionarray[2*mx_array_dim], contractnindex;
selectionSort(indexarray1, sortindexarray1, nindex1);
selectionSort(indexarray2, sortindexarray2, nindex2);
selectionSort(indexarray3, sortindexarray3, nindex3);
/*check contraction index of array*/
/*merge two arrays*/
i2=i3=0;
contractnindex=0;
while (i2<nindex2 && i3<nindex3)
{
if (sortindexarray2[i2]>sortindexarray3[i3])
contractionarray[contractnindex++]=sortindexarray3[i3++];
else if (sortindexarray2[i2]<sortindexarray3[i3])
contractionarray[contractnindex++]=sortindexarray2[i2++];
else /*==*/
{
indexarrayr[nindexr++]=sortindexarray2[i2];
i2++;
i3++;
}
}
while (i2<nindex2)
contractionarray[contractnindex++]=sortindexarray2[i2++];
while (i3<nindex3)
contractionarray[contractnindex++]=sortindexarray3[i3++];
/*compare array1 and calculated contraction array*/
if (nindex1!=contractnindex)
{
outerror(glno, "error in contraction index.");
return -2;
}
for (i=0; i<nindex1; i++)
{
if (contractionarray[i]!=sortindexarray1[i])
{
outerror(glno, "contraction array doesn't match.");
return -1;
}
}
return 0;
} | false | false | false | false | false | 0 |
ckinit(size_t size, size_t reserved, bool leaking)
{
void *arena;
ckhunk_t *ck;
g_assert(size >= reserved);
size = size_saturate_add(size, ckalloc_round(sizeof(struct ckhunk)));
g_assert(size_is_positive(size));
g_assert(size_is_non_negative(reserved));
arena = leaking ? vmm_core_alloc(size) : vmm_core_alloc_not_leaking(size);
ck = arena;
ZERO(ck);
ck->magic = CKHUNK_MAGIC;
ck->size = round_pagesize(size); /* Size allocated by the VMM layer */
ck->reserved = reserved;
ck->arena = arena;
ck->end = ck->arena + ck->size;
ck->avail = ck->arena + ckalloc_round(sizeof(struct ckhunk));
g_assert(ptr_cmp(ck->end, ck->avail) > 0);
return ck;
} | false | false | false | false | false | 0 |
e132xs_mul(void)
{
INT32 op1, op2;
INT32 single_word;
op1 = op2 = 0;
//PC or SR aren't denoted, else result is undefined
if( (S_CODE == PC_CODE && !S_BIT) || (S_CODE == SR_CODE && !S_BIT) || (D_CODE == PC_CODE && !D_BIT) || (D_CODE == SR_CODE && !D_BIT) )
{
verboselog( 1, "Denoted PC or SR in MUL instruction @ x\n", PC );
}
else
{
if( S_BIT )
{
op1 = GET_L_REG(S_CODE);
}
else
{
op1 = GET_G_REG(S_CODE);
}
if( D_BIT )
{
op2 = GET_L_REG(D_CODE);
}
else
{
op2 = GET_G_REG(D_CODE);
}
single_word = (op1 * op2) & 0xffffffff; //only the low-order word is taken
SET_RD(single_word, NOINC);
SET_Z((single_word == 0 ? 1: 0));
SET_N(SIGN_BIT(single_word)); //sign
// SET_V(); //undefined
// SET_C(); //undefined
}
if( ( op1 >= 0xffff8000 && op1 <= 0x7fff ) && ( op2 >= 0xffff8000 && op2 <= 0x7fff ) )
e132xs_ICount -= 3;
else
e132xs_ICount -= 5;
} | false | false | false | false | false | 0 |
sp_color_preview_set_rgba32 (SPColorPreview *cp, guint32 rgba)
{
cp->rgba = rgba;
if (GTK_WIDGET_DRAWABLE (cp)) {
gtk_widget_queue_draw (GTK_WIDGET (cp));
}
} | false | false | false | false | false | 0 |
pinentry_active_p (ctrl_t ctrl, int waitseconds)
{
(void)ctrl;
if (waitseconds > 0)
{
pth_event_t evt;
int rc;
evt = pth_event (PTH_EVENT_TIME, pth_timeout (waitseconds, 0));
if (!pth_mutex_acquire (&entry_lock, 0, evt))
{
if (pth_event_occurred (evt))
rc = gpg_error (GPG_ERR_TIMEOUT);
else
rc = gpg_error (GPG_ERR_INTERNAL);
pth_event_free (evt, PTH_FREE_THIS);
return rc;
}
pth_event_free (evt, PTH_FREE_THIS);
}
else
{
if (!pth_mutex_acquire (&entry_lock, 1, NULL))
return gpg_error (GPG_ERR_LOCKED);
}
if (!pth_mutex_release (&entry_lock))
log_error ("failed to release the entry lock at %d\n", __LINE__);
return 0;
} | false | false | false | false | false | 0 |
COM_Standard_color(int number)
{
struct color_rgb rgb;
if (number < 0 || number >= G_num_standard_colors())
return;
rgb = G_standard_color_rgb(number);
COM_Color_RGB(rgb.r, rgb.g, rgb.b);
} | false | false | false | false | false | 0 |
dobatch_r2hc(const P *ego, R *I, R *O, R *buf, INT batchsz)
{
X(cpy2d_ci)(I, buf,
ego->n, ego->rs0, WS(ego->bcsr /* hack */, 1),
batchsz, ego->ivs, 1, 1);
if (IABS(WS(ego->csr, 1)) < IABS(ego->ovs)) {
/* transform directly to output */
ego->k(buf, buf + WS(ego->bcsr /* hack */, 1),
O, O + ego->ioffset,
ego->brs, ego->csr, ego->csi,
batchsz, 1, ego->ovs);
} else {
/* transform to buffer and copy back */
ego->k(buf, buf + WS(ego->bcsr /* hack */, 1),
buf, buf + ego->bioffset,
ego->brs, ego->bcsr, ego->bcsi,
batchsz, 1, 1);
X(cpy2d_co)(buf, O,
ego->n, WS(ego->bcsr, 1), WS(ego->csr, 1),
batchsz, 1, ego->ovs, 1);
}
} | false | false | false | false | false | 0 |
RelocateField(BinaryObject &BO, uint32_t Offset,
int64_t Value, unsigned Size) {
if (Size == 32)
BO.fixWord32(Value, Offset);
else if (Size == 64)
BO.fixWord64(Value, Offset);
else
llvm_unreachable("don't know howto patch relocatable field");
} | 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.