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 |
|---|---|---|---|---|---|---|
set_entry (htab, key, keylen, newval)
hash_table *htab;
const void *key;
size_t keylen;
void *newval;
{
hash_entry *table = (hash_entry *) htab->table;
size_t idx = lookup (htab, key, keylen, compute_hashval (key, keylen));
if (table[idx].used == 0)
return -1;
table[idx].data = newval;
return 0;
} | false | false | false | false | false | 0 |
addPreISel() {
const AMDGPUSubtarget &ST = *getAMDGPUTargetMachine().getSubtargetImpl();
addPass(createFlattenCFGPass());
if (ST.IsIRStructurizerEnabled())
addPass(createStructurizeCFGPass());
return false;
} | false | false | false | false | false | 0 |
irtrans_flush(Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
LCDCOMMAND buf;
STATUSBUFFER stat;
if (!memcmp(p->shadow_buf, p->framebuf, p->width * p->height))
return;
if ((time(0) - p->last_time) < p->timeout)
return;
memcpy(buf.framebuffer, p->framebuf, p->width * p->height);
buf.wid = p->width;
buf.hgt = p->height;
buf.netcommand = COMMAND_LCD;
buf.adress = 'L';
buf.lcdcommand = LCD_TEXT | p->backlight;
buf.protocol_version = IRTRANS_PROTOCOL_VERSION;
SendCommand(drvthis, &buf, &stat); // Error Handling
memcpy(p->shadow_buf, p->framebuf, p->width * p->height);
p->last_time = time(0);
} | false | true | false | false | false | 1 |
cs5535_mfgpt_free_timer(struct cs5535_mfgpt_timer *timer)
{
unsigned long flags;
uint16_t val;
/* timer can be made available again only if never set up */
val = cs5535_mfgpt_read(timer, MFGPT_REG_SETUP);
if (!(val & MFGPT_SETUP_SETUP)) {
spin_lock_irqsave(&timer->chip->lock, flags);
__set_bit(timer->nr, timer->chip->avail);
spin_unlock_irqrestore(&timer->chip->lock, flags);
}
kfree(timer);
} | false | false | false | false | false | 0 |
snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname, const char *sname, int mode)
{
snd_ctl_t *ctl;
snd_ctl_shm_t *shm = NULL;
snd_client_open_request_t *req;
snd_client_open_answer_t ans;
size_t snamelen, reqlen;
int err;
int result;
int sock = -1;
snd_ctl_shm_ctrl_t *ctrl = NULL;
snamelen = strlen(sname);
if (snamelen > 255)
return -EINVAL;
result = make_local_socket(sockname);
if (result < 0) {
SNDERR("server for socket %s is not running", sockname);
goto _err;
}
sock = result;
reqlen = sizeof(*req) + snamelen;
req = alloca(reqlen);
memcpy(req->name, sname, snamelen);
req->dev_type = SND_DEV_TYPE_CONTROL;
req->transport_type = SND_TRANSPORT_TYPE_SHM;
req->stream = 0;
req->mode = mode;
req->namelen = snamelen;
err = write(sock, req, reqlen);
if (err < 0) {
SNDERR("write error");
result = -errno;
goto _err;
}
if ((size_t) err != reqlen) {
SNDERR("write size error");
result = -EINVAL;
goto _err;
}
err = read(sock, &ans, sizeof(ans));
if (err < 0) {
SNDERR("read error");
result = -errno;
goto _err;
}
if (err != sizeof(ans)) {
SNDERR("read size error");
result = -EINVAL;
goto _err;
}
result = ans.result;
if (result < 0)
goto _err;
ctrl = shmat(ans.cookie, 0, 0);
if (!ctrl) {
result = -errno;
goto _err;
}
shm = calloc(1, sizeof(snd_ctl_shm_t));
if (!shm) {
result = -ENOMEM;
goto _err;
}
shm->socket = sock;
shm->ctrl = ctrl;
err = snd_ctl_new(&ctl, SND_CTL_TYPE_SHM, name);
if (err < 0) {
result = err;
goto _err;
}
ctl->ops = &snd_ctl_shm_ops;
ctl->private_data = shm;
err = snd_ctl_shm_poll_descriptor(ctl);
if (err < 0) {
snd_ctl_close(ctl);
return err;
}
ctl->poll_fd = err;
*handlep = ctl;
return 0;
_err:
close(sock);
if (ctrl)
shmdt(ctrl);
free(shm);
return result;
} | false | true | true | false | true | 1 |
P_PointOnLineSide
( fixed_t x,
fixed_t y,
line_t* line )
{
fixed_t dx;
fixed_t dy;
fixed_t left;
fixed_t right;
if (!line->dx)
{
if (x <= line->v1->x)
return line->dy > 0;
return line->dy < 0;
}
if (!line->dy)
{
if (y <= line->v1->y)
return line->dx < 0;
return line->dx > 0;
}
dx = (x - line->v1->x);
dy = (y - line->v1->y);
left = FixedMul ( line->dy>>FRACBITS , dx );
right = FixedMul ( dy , line->dx>>FRACBITS );
if (right < left)
return 0; // front side
return 1; // back side
} | false | false | false | false | false | 0 |
gth_hook_remove_callback (const char *name,
GCallback callback)
{
GthHook *hook;
GHook *function;
hook = GET_HOOK (name);
function = g_hook_find_func (hook->list, TRUE, callback);
if (function == NULL) {
g_warning ("callback not found in hook '%s'", name);
return;
}
g_hook_destroy_link (hook->list, function);
} | false | false | false | false | false | 0 |
maddr_ins(struct ma_info **lst, struct ma_info *m)
{
struct ma_info *mp;
for (; (mp = *lst) != NULL; lst = &mp->next) {
if (mp->index > m->index)
break;
}
m->next = *lst;
*lst = m;
} | false | false | false | false | false | 0 |
AppendProperty(const char* prop, const char* value,
bool asString)
{
if (!prop)
{
return;
}
// handle special props
std::string propname = prop;
if ( propname == "INCLUDE_DIRECTORIES" )
{
std::vector<std::string> varArgsExpanded;
cmSystemTools::ExpandListArgument(value, varArgsExpanded);
for(std::vector<std::string>::const_iterator vi = varArgsExpanded.begin();
vi != varArgsExpanded.end(); ++vi)
{
this->AddIncludeDirectory(vi->c_str());
}
return;
}
if ( propname == "LINK_DIRECTORIES" )
{
std::vector<std::string> varArgsExpanded;
cmSystemTools::ExpandListArgument(value, varArgsExpanded);
for(std::vector<std::string>::const_iterator vi = varArgsExpanded.begin();
vi != varArgsExpanded.end(); ++vi)
{
this->AddLinkDirectory(vi->c_str());
}
return;
}
this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString);
} | false | false | false | false | false | 0 |
lp8788_alarm_irq_register(struct platform_device *pdev,
struct lp8788_rtc *rtc)
{
struct resource *r;
struct lp8788 *lp = rtc->lp;
struct irq_domain *irqdm = lp->irqdm;
int irq;
rtc->irq = 0;
/* even the alarm IRQ number is not specified, rtc time should work */
r = platform_get_resource_byname(pdev, IORESOURCE_IRQ, LP8788_ALM_IRQ);
if (!r)
return 0;
if (rtc->alarm == LP8788_ALARM_1)
irq = r->start;
else
irq = r->end;
rtc->irq = irq_create_mapping(irqdm, irq);
return devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
lp8788_alarm_irq_handler,
0, LP8788_ALM_IRQ, rtc);
} | false | false | false | false | false | 0 |
isl_local_space_flatten_range(
__isl_take isl_local_space *ls)
{
if (!ls)
return NULL;
if (!ls->dim->nested[1])
return ls;
ls = isl_local_space_cow(ls);
if (!ls)
return NULL;
ls->dim = isl_space_flatten_range(ls->dim);
if (!ls->dim)
return isl_local_space_free(ls);
return ls;
} | false | false | false | false | false | 0 |
SetDocRoot(char *name)
{ char file[CF_BUFSIZE];
FILE *fout,*fin;
struct stat sb;
if (LOOKUP)
{
CfOut(cf_verbose, "","Ignoring document root in lookup mode");
return;
}
snprintf(file,CF_BUFSIZE-1,"%s/document_root.dat",CFWORKDIR);
MapName(file);
if (cfstat(file,&sb) == -1 && strlen(name) > 0)
{
if ((fout = fopen(file,"w")) == NULL)
{
CfOut(cf_error,"fopen","Unable to write document root file! (%s)",file);
return;
}
fprintf(fout,"%s",name);
fclose(fout);
CfOut(cf_verbose,""," -> Setting document root for a knowledge base to %s",name);
strcpy(DOCROOT,name);
NewScalar("sys","doc_root",DOCROOT,cf_str);
}
else
{
if ((fin = fopen(file,"r")) == NULL)
{
}
else
{
file[0] = 0;
fscanf(fin,"%255s",file);
fclose(fin);
CfOut(cf_verbose,""," -> Assuming document root for a knowledge base in %s",file);
strcpy(DOCROOT,name);
NewScalar("sys","doc_root",DOCROOT,cf_str);
}
}
} | true | true | false | false | true | 1 |
__libc_dlsym_private (struct link_map *map, const char *name)
{
struct do_dlsym_args sargs;
sargs.map = map;
sargs.name = name;
if (! dlerror_run (do_dlsym_private, &sargs))
return DL_SYMBOL_ADDRESS (sargs.loadbase, sargs.ref);
return NULL;
} | false | false | false | false | false | 0 |
wtp_pdu_dump(WTP_PDU *pdu, int level) {
char *dbg = "wap.wtp";
switch (pdu->type) {
#define PDU(name, docstring, fields, is_valid) \
case name: { \
struct name *p = &pdu->u.name; \
debug(dbg, 0, "%*sWTP %s PDU at %p:", \
level, "", #name, (void *)pdu); \
fields \
} break;
#define UINT(field, docstring, bits) \
debug(dbg, 0, "%*s %s: %lu", level, "", docstring, p->field);
#define UINTVAR(field, docstring) \
debug(dbg, 0, "%*s %s: %lu", level, "", docstring, p->field);
#define OCTSTR(field, docstring, lengthfield) \
debug(dbg, 0, "%*s %s:", level, "", docstring); \
octstr_dump(p->field, level + 1);
#define REST(field, docstring) \
debug(dbg, 0, "%*s %s:", level, "", docstring); \
octstr_dump(p->field, level + 1);
#define TYPE(bits, value)
#define RESERVED(bits)
#define TPI(confield) dump_tpis(pdu->options, level);
#include "wtp_pdu.def"
#undef TPI
#undef RESERVED
#undef TYPE
#undef REST
#undef OCTSTR
#undef UINTVAR
#undef UINT
#undef PDU
default:
debug(dbg, 0, "%*sWTP PDU at %p:", level, "", (void *)pdu);
debug(dbg, 0, "%*s unknown type %u", level, "", pdu->type);
break;
}
} | false | false | false | false | false | 0 |
wrap_hex_pdu_construct (GType object_type, const gchar* hexpdu, guint tpdulen) {
WrapHexPdu* self = NULL;
const gchar* _tmp0_ = NULL;
gchar* _tmp1_ = NULL;
guint _tmp2_ = 0U;
g_return_val_if_fail (hexpdu != NULL, NULL);
self = (WrapHexPdu*) g_type_create_instance (object_type);
_tmp0_ = hexpdu;
_tmp1_ = g_strdup (_tmp0_);
_g_free0 (self->hexpdu);
self->hexpdu = _tmp1_;
_tmp2_ = tpdulen;
self->tpdulen = _tmp2_;
self->transaction_index = -1;
return self;
} | false | false | false | false | false | 0 |
Decrypt(const std::string & key,
const mpz_class & tweak,
uint32_t tweak_len_in_bits,
const mpz_class & cihpertext,
uint32_t cihpertext_len_bits,
mpz_class * plaintext) {
// [FFX2] pg 3., line 21
if (!ValidateKey(key)) {
return false;
}
mpz_class & retval = *plaintext;
// [FFX2] pg 3., line 24-25
uint32_t n = cihpertext_len_bits;
uint32_t l = cihpertext_len_bits / 2;
uint32_t r = kDefaultFfxRounds;
mpz_class A, B;
BitMask(cihpertext, cihpertext_len_bits, 0, l - 1, &A);
BitMask(cihpertext, cihpertext_len_bits, l, n - 1, &B);
uint32_t B_len = n - l;
mpz_class C = 0;
mpz_class D = 0;
uint32_t m = 0;
mpz_class modulus = 0;
// [FFX2] pg 3., line 26
for (int32_t i = r - 1; i >= 0; --i) {
if ((i & 1) == 0) {
m = n / 2;
} else {
m = ceil(n / 2.0);
}
mpz_ui_pow_ui(modulus.get_mpz_t(), 2, m);
C = B;
B = A;
RoundFunction(key, n, tweak, tweak_len_in_bits, i, B, m, &D);
mpz_sub(A.get_mpz_t(),
C.get_mpz_t(),
D.get_mpz_t());
while(A < 0) A += modulus;
A = A % modulus;
}
// [FFX2] pg 3., line 29
retval = (A << B_len) + B;
mpz_ui_pow_ui(modulus.get_mpz_t(), 2, cihpertext_len_bits);
retval = retval % modulus;
return true;
} | false | false | false | false | false | 0 |
ratio_column_print(LHAFileHeader *header)
{
if (!strcmp(header->compress_method, "-lhd-")) {
printf("******");
} else {
printf("%5.1f%%", compression_percent(header->compressed_length,
header->length));
}
} | false | false | false | false | false | 0 |
FixupOrdering()
{
int i;
/* -------------------------------------------------------------------- */
/* Recurse ordering children. */
/* -------------------------------------------------------------------- */
for( i = 0; i < GetChildCount(); i++ )
GetChild(i)->FixupOrdering();
if( GetChildCount() < 3 )
return OGRERR_NONE;
/* -------------------------------------------------------------------- */
/* Is this a node for which an ordering rule exists? */
/* -------------------------------------------------------------------- */
const char * const * papszRule = NULL;
for( i = 0; apszOrderingRules[i] != NULL; i++ )
{
if( EQUAL(apszOrderingRules[i][0],pszValue) )
{
papszRule = apszOrderingRules[i] + 1;
break;
}
}
if( papszRule == NULL )
return OGRERR_NONE;
/* -------------------------------------------------------------------- */
/* If we have a rule, apply it. We create an array */
/* (panChildPr) with the priority code for each child (derived */
/* from the rule) and we then bubble sort based on this. */
/* -------------------------------------------------------------------- */
int *panChildKey = (int *) CPLCalloc(sizeof(int),GetChildCount());
for( i = 1; i < GetChildCount(); i++ )
{
panChildKey[i] = CSLFindString( (char**) papszRule,
GetChild(i)->GetValue() );
if( panChildKey[i] == -1 )
{
CPLDebug( "OGRSpatialReference",
"Found unexpected key %s when trying to order SRS nodes.",
GetChild(i)->GetValue() );
}
}
/* -------------------------------------------------------------------- */
/* Sort - Note we don't try to do anything with the first child */
/* which we assume is a name string. */
/* -------------------------------------------------------------------- */
int j, bChange = TRUE;
for( i = 1; bChange && i < GetChildCount()-1; i++ )
{
bChange = FALSE;
for( j = 1; j < GetChildCount()-i; j++ )
{
if( panChildKey[j] == -1 || panChildKey[j+1] == -1 )
continue;
if( panChildKey[j] > panChildKey[j+1] )
{
OGR_SRSNode *poTemp = papoChildNodes[j];
int nKeyTemp = panChildKey[j];
papoChildNodes[j] = papoChildNodes[j+1];
papoChildNodes[j+1] = poTemp;
nKeyTemp = panChildKey[j];
panChildKey[j] = panChildKey[j+1];
panChildKey[j+1] = nKeyTemp;
bChange = TRUE;
}
}
}
CPLFree( panChildKey );
return OGRERR_NONE;
} | false | false | false | false | false | 0 |
Space(char *n)
{
int i;
i = strlen(n);
if( i < 1) return "\t\t\t";
if( i < 8 ) return "\t\t";
return "\t";
} | false | false | false | false | false | 0 |
CorrectEndDXT1(ILushort *ex0, ILushort *ex1, ILboolean HasAlpha)
{
ILushort Temp;
if (HasAlpha) {
if (*ex0 > *ex1) {
Temp = *ex0;
*ex0 = *ex1;
*ex1 = Temp;
}
}
else {
if (*ex0 < *ex1) {
Temp = *ex0;
*ex0 = *ex1;
*ex1 = Temp;
}
}
return;
} | false | false | false | false | false | 0 |
snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw,
struct snd_hwdep_dsp_image *dsp)
{
struct usX2Ydev *priv = hw->private_data;
int lret, err = -EINVAL;
snd_printdd( "dsp_load %s\n", dsp->name);
if (access_ok(VERIFY_READ, dsp->image, dsp->length)) {
struct usb_device* dev = priv->dev;
char *buf;
buf = memdup_user(dsp->image, dsp->length);
if (IS_ERR(buf))
return PTR_ERR(buf);
err = usb_set_interface(dev, 0, 1);
if (err)
snd_printk(KERN_ERR "usb_set_interface error \n");
else
err = usb_bulk_msg(dev, usb_sndbulkpipe(dev, 2), buf, dsp->length, &lret, 6000);
kfree(buf);
}
if (err)
return err;
if (dsp->index == 1) {
msleep(250); // give the device some time
err = usX2Y_AsyncSeq04_init(priv);
if (err) {
snd_printk(KERN_ERR "usX2Y_AsyncSeq04_init error \n");
return err;
}
err = usX2Y_In04_init(priv);
if (err) {
snd_printk(KERN_ERR "usX2Y_In04_init error \n");
return err;
}
err = usX2Y_create_alsa_devices(hw->card);
if (err) {
snd_printk(KERN_ERR "usX2Y_create_alsa_devices error %i \n", err);
snd_card_free(hw->card);
return err;
}
priv->chip_status |= USX2Y_STAT_CHIP_INIT;
snd_printdd("%s: alsa all started\n", hw->name);
}
return err;
} | false | false | false | false | false | 0 |
adjustPosition( qreal pos, const QGradientStops &stops )
{
QGradientStops::const_iterator itr = stops.constBegin();
const qreal smallDiff = 0.00001;
while ( itr != stops.constEnd() ) {
const QGradientStop &stop = *itr;
++itr;
bool atEnd = ( itr != stops.constEnd() );
if ( qFuzzyCompare( pos, stop.first ) ) {
if ( atEnd || !qFuzzyCompare( pos + smallDiff, ( *itr ).first ) ) {
return qMin(pos + smallDiff, qreal(1.0));
}
}
}
return pos;
} | false | false | false | false | false | 0 |
cut_sub_process_new (const char *test_directory, CutTestContext *test_context)
{
CutSubProcess *sub_process;
CutRunContext *parent_run_context = NULL;
CutRunContext *pipeline;
if (test_context)
parent_run_context = cut_test_context_get_run_context(test_context);
pipeline = cut_pipeline_new();
cut_run_context_set_source_directory(pipeline, test_directory);
cut_run_context_set_test_directory(pipeline, test_directory);
if (parent_run_context) {
gint max_threads;
if (cut_run_context_get_multi_thread(parent_run_context))
cut_run_context_set_multi_thread(pipeline, TRUE);
max_threads = cut_run_context_get_max_threads(parent_run_context);
cut_run_context_set_max_threads(pipeline, max_threads);
cut_run_context_delegate_signals(pipeline, parent_run_context);
}
sub_process = g_object_new(CUT_TYPE_SUB_PROCESS,
"test-context", test_context,
"pipeline", pipeline,
NULL);
g_object_unref(pipeline);
return sub_process;
} | false | false | false | false | false | 0 |
QuadTree_get_supernodes_internal(QuadTree qt, real bh, real *point, int nodeid, int *nsuper, int *nsupermax, real **center, real **supernode_wgts, real **distances, real *counts, int *flag){
SingleLinkedList l;
real *coord, dist;
int dim, i;
(*counts)++;
if (!qt) return;
dim = qt->dim;
l = qt->l;
if (l){
while (l){
check_or_realloc_arrays(dim, nsuper, nsupermax, center, supernode_wgts, distances);
if (node_data_get_id(SingleLinkedList_get_data(l)) != nodeid){
coord = node_data_get_coord(SingleLinkedList_get_data(l));
for (i = 0; i < dim; i++){
(*center)[dim*(*nsuper)+i] = coord[i];
}
(*supernode_wgts)[*nsuper] = node_data_get_weight(SingleLinkedList_get_data(l));
(*distances)[*nsuper] = point_distance(point, coord, dim);
(*nsuper)++;
}
l = SingleLinkedList_get_next(l);
}
}
if (qt->qts){
dist = point_distance(qt->center, point, dim);
if (qt->width < bh*dist){
check_or_realloc_arrays(dim, nsuper, nsupermax, center, supernode_wgts, distances);
for (i = 0; i < dim; i++){
(*center)[dim*(*nsuper)+i] = qt->average[i];
}
(*supernode_wgts)[*nsuper] = qt->total_weight;
(*distances)[*nsuper] = point_distance(qt->average, point, dim);
(*nsuper)++;
} else {
for (i = 0; i < 1<<dim; i++){
QuadTree_get_supernodes_internal(qt->qts[i], bh, point, nodeid, nsuper, nsupermax, center,
supernode_wgts, distances, counts, flag);
}
}
}
} | false | false | false | false | false | 0 |
rb_num2ll(VALUE val)
{
if (NIL_P(val)) {
rb_raise(rb_eTypeError, "no implicit conversion from nil");
}
if (FIXNUM_P(val)) return (LONG_LONG)FIX2LONG(val);
switch (TYPE(val)) {
case T_FLOAT:
if (RFLOAT_VALUE(val) < LLONG_MAX_PLUS_ONE
&& RFLOAT_VALUE(val) > LLONG_MIN_MINUS_ONE) {
return (LONG_LONG)(RFLOAT_VALUE(val));
}
else {
char buf[24];
char *s;
snprintf(buf, sizeof(buf), "%-.10g", RFLOAT_VALUE(val));
if ((s = strchr(buf, ' ')) != 0) *s = '\0';
rb_raise(rb_eRangeError, "float %s out of range of long long", buf);
}
case T_BIGNUM:
return rb_big2ll(val);
case T_STRING:
rb_raise(rb_eTypeError, "no implicit conversion from string");
return Qnil; /* not reached */
case T_TRUE:
case T_FALSE:
rb_raise(rb_eTypeError, "no implicit conversion from boolean");
return Qnil; /* not reached */
default:
val = rb_to_int(val);
return NUM2LL(val);
}
} | false | false | false | false | false | 0 |
readSharedColorAtom (Display *disp,
Colormap *cmap, /* The colormap ID */
int *lutStart, /* The first available LUT value */
int *nPC) /* The number of pseudocolor values used */
{
Atom colormapAtom; /* Atom for specifying colormap info to server */
int status;
Atom actualType;
int actualFormat;
unsigned long nitems;
unsigned long bytesAfter;
struct XColorSharedStruct *theColorShared=NULL;
#ifdef DEBUG
printf("readSharedColorAtom\n");
#endif
/* Create the atom */
colormapAtom = XInternAtom (disp, "VIEW_COLORMAP", True);
if (colormapAtom == None) {
#ifdef DEBUG
printf("ERROR in readSharedColorAtom: XInternAtom returned None (%d)\n",
(unsigned int)colormapAtom);
#endif
cmap = NULL;
*lutStart = *nPC = 0;
return BadAtom;
}
status = XGetWindowProperty (disp, root_window, colormapAtom,
0L, 1000L, False, AnyPropertyType,
&actualType, &actualFormat, &nitems,
&bytesAfter,(unsigned char **)&theColorShared);
if ((status == Success) && (theColorShared != NULL)) {
*cmap = theColorShared->cmap;
*lutStart = theColorShared->lutStart;
*nPC = theColorShared->nPC;
XFree (theColorShared);
theColorShared=NULL;
return status;
}
else {
switch (status) {
case Success:
if (actualType == None) {
/* printf ("actualType=None\n"); */
return BadAtom;
}
break;
case BadAtom :
printf("bad atom\n");
break;
case BadMatch :
printf("bad match\n");
break;
case BadValue :
printf("bad value\n");
break;
case BadWindow :
printf("bad window\n");
break;
default:
printf("bad other\n");
break;
} /* End of switch (status) */
printf("ERROR in readSharedColorAtom: XGetWindowProperty returned %d\n",
status);
cmap = NULL;
*lutStart = *nPC = 0;
return status;
}
} | false | false | false | false | false | 0 |
receiveData (int *cmd, int len)
{
int i;
int reg;
/* send header */
reg = registerRead (0x19) & 0xF8;
/* send bytes */
i = 0;
while (((reg == 0xD0) || (reg == 0xC0)) && (i < len))
{
/* write byte */
cmd[i] = registerRead (0x1C);
reg = registerRead (0x19) & 0xF8;
i++;
}
DBG (16, "receiveData, reg19=0x%02X (%s:%d)\n", reg, __FILE__, __LINE__);
if ((reg != 0xC0) && (reg != 0xD0))
{
DBG (0, "sendData failed got 0x%02X instead of 0xC0 or 0xD0 (%s:%d)\n",
reg, __FILE__, __LINE__);
DBG (0, "Blindly going on .....\n");
}
/* check if 'finished status' received to early */
if (((reg == 0xC0) || (reg == 0xD0)) && (i != len))
{
DBG (0,
"receiveData failed: received only %d bytes out of %d (%s:%d)\n",
i, len, __FILE__, __LINE__);
return 0;
}
reg = registerRead (0x1C);
DBG (16, "receiveData, reg1C=0x%02X (%s:%d)\n", reg, __FILE__, __LINE__);
/* model 0x07 has always the last bit set to 1 */
scannerStatus = reg & 0xF8;
reg = reg & 0x10;
if ((reg != 0x10) && (scannerStatus != 0x68) && (scannerStatus != 0xA8))
{
DBG (0, "receiveData failed: acknowledge not received (%s:%d)\n",
__FILE__, __LINE__);
return 0;
}
return 1;
} | false | false | false | false | false | 0 |
time_allocation(double time, double inc, int movestogo) {
ASSERT(time>0);
ASSERT(inc>=-1.0);
ASSERT(movestogo>=-1);
double time_max, alloc;
// dynamic allocation
time_max = time * 0.95 - 1.0;
if (time_max < 0.0) time_max = 0.0;
alloc = (time_max + inc * double(movestogo-1)) / double(movestogo);
alloc *= (option_get_bool("Ponder") ? PonderRatio : NormalRatio);
if (alloc > time_max) alloc = time_max;
SearchInput->time_limit_1 = alloc;
alloc = (time_max + inc * double(movestogo-1)) * 0.5;
if (alloc < SearchInput->time_limit_1) alloc = SearchInput->time_limit_1;
if (alloc > time_max) alloc = time_max;
SearchInput->time_limit_2 = alloc;
alloc = (time_max + inc * double(movestogo-1)) * 0.25;
if (alloc < SearchInput->time_limit_1) alloc = SearchInput->time_limit_1;
if (alloc > time_max) alloc = time_max;
SearchInput->time_limit_3 = alloc;
} | false | false | false | false | false | 0 |
__ecereMethod___ecereNameSpace__eda__CSVReport_AddPage(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__Instance * page)
{
struct __ecereNameSpace__ecere__sys__Size __simpleStruct1;
struct __ecereNameSpace__ecere__sys__Size __simpleStruct0 =
{
(((int)0x7fffffff)) - 10, (((int)0x7fffffff)) - 10
};
struct __ecereNameSpace__eda__CSVReport * __ecerePointer___ecereNameSpace__eda__CSVReport = (struct __ecereNameSpace__eda__CSVReport *)(this ? (((char *)this) + __ecereClass___ecereNameSpace__eda__CSVReport->offset) : 0);
int h;
if(((struct __ecereNameSpace__eda__ReportDestination *)(((char *)this + __ecereClass___ecereNameSpace__eda__ReportDestination->offset)))->pageCount && __ecereProp___ecereNameSpace__ecere__gui__Window_Get_display(this))
__ecereMethod___ecereNameSpace__ecere__gfx__Display_NextPage(__ecereProp___ecereNameSpace__ecere__gui__Window_Get_display(this));
__ecerePointer___ecereNameSpace__eda__CSVReport->lastPage = page;
__ecereProp___ecereNameSpace__ecere__gui__Window_Set_master(page, this);
__ecereProp___ecereNameSpace__ecere__gui__Window_Set_parent(page, this);
__ecereProp___ecereNameSpace__ecere__gui__Window_Set_size(page, &__simpleStruct0);
h = (int)(__ecereProp___ecereNameSpace__ecere__gui__Window_Get_size(page, &__simpleStruct1), __simpleStruct1).h;
((struct __ecereNameSpace__eda__ReportDestination *)(((char *)this + __ecereClass___ecereNameSpace__eda__ReportDestination->offset)))->pageCount++;
__ecereMethod___ecereNameSpace__ecere__gui__Window_Create(page);
} | false | false | false | true | false | 1 |
CreateFixedSpillStackObject(uint64_t Size,
int64_t SPOffset) {
unsigned Align = MinAlign(SPOffset, StackAlignment);
Align = clampStackAlignment(!StackRealignable || !RealignOption, Align,
StackAlignment);
Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset,
/*Immutable*/ true,
/*isSS*/ true,
/*Alloca*/ nullptr,
/*isAliased*/ false));
return -++NumFixedObjects;
} | false | false | false | false | false | 0 |
next_Area(int parsed, list l, g_areas g, msg * m)
{
if (parsed == NORMAL) {
if (l->size == 0)
return 0;
else {
msg tmp;
memcpy(&tmp, l->head->m, sizeof(msg));
*m = tmp;
removeNode(l);
return 1;
}
}
else {
return next(g, m);
}
} | false | false | false | false | false | 0 |
service_udp4(packetinfo *pi, signature* sig_serv_udp)
{
int rc; /* PCRE */
int ovector[15];
int tmplen;
signature *tmpsig;
bstring app, service_name;
app = service_name = NULL;
if (pi->plen < 5 ) return;
/* should make a config.tcp_client_flowdept etc
* a range between 500-1000 should be good!
*/
if (pi->plen > 600) tmplen = 600;
else tmplen = pi->plen;
tmpsig = sig_serv_udp;
while (tmpsig != NULL) {
rc = pcre_exec(tmpsig->regex, tmpsig->study, (const char*) pi->payload, pi->plen, 0, 0,
ovector, 15);
if (rc != -1) {
app = get_app_name(tmpsig, pi->payload, ovector, rc);
//printf("[*] - MATCH SERVICE IPv4/UDP: %s\n",(char *)bdata(app));
update_asset_service(pi, tmpsig->service, app);
pi->cxt->check |= CXT_SERVICE_DONT_CHECK;
bdestroy(app);
return;
}
tmpsig = tmpsig->next;
}
/*
* If no sig is found/mached, use default port to determin.
*/
if (pi->sc == SC_CLIENT && !ISSET_CLIENT_UNKNOWN(pi)) {
if ((service_name = (bstring) check_known_port(IP_PROTO_UDP,ntohs(pi->d_port))) !=NULL ) {
update_asset_service(pi, UNKNOWN, service_name);
pi->cxt->check |= CXT_CLIENT_UNKNOWN_SET;
bdestroy(service_name);
} else if ((service_name = (bstring) check_known_port(IP_PROTO_UDP,ntohs(pi->s_port))) !=NULL ) {
reverse_pi_cxt(pi);
pi->d_port = pi->udph->src_port;
update_asset_service(pi, UNKNOWN, service_name);
pi->d_port = pi->udph->dst_port;
pi->cxt->check |= CXT_CLIENT_UNKNOWN_SET;
bdestroy(service_name);
}
} else if (pi->sc == SC_SERVER && !ISSET_SERVICE_UNKNOWN(pi)) {
if ((service_name = (bstring) check_known_port(IP_PROTO_UDP,ntohs(pi->s_port))) !=NULL ) {
update_asset_service(pi, UNKNOWN, service_name);
pi->cxt->check |= CXT_SERVICE_UNKNOWN_SET;
bdestroy(service_name);
} else if ((service_name = (bstring) check_known_port(IP_PROTO_UDP,ntohs(pi->d_port))) !=NULL ) {
reverse_pi_cxt(pi);
update_asset_service(pi, UNKNOWN, service_name);
pi->cxt->check |= CXT_SERVICE_UNKNOWN_SET;
bdestroy(service_name);
}
}
} | false | false | false | false | false | 0 |
mouseReleaseEvent(QMouseEvent *e)
{
// only accept click if it was inside this cube
if(e->x()< 0 || e->x() > width() || e->y() < 0 || e->y() > height())
return;
if(e->button() == Qt::LeftButton && _clicksAllowed) {
e->accept();
emit clicked (m_row, m_col);
}
} | false | false | false | false | false | 0 |
partial_get_filename(const gchar *server, const gchar *login,
const gchar *muidl)
{
gchar *path;
gchar *result = NULL;
FILE *fp;
gchar buf[POPBUFSIZE];
gchar uidl[POPBUFSIZE];
time_t recv_time;
time_t now;
gchar *sanitized_uid = g_strdup(login);
subst_for_filename(sanitized_uid);
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
"uidl", G_DIR_SEPARATOR_S,
server, "-", sanitized_uid, NULL);
if ((fp = g_fopen(path, "rb")) == NULL) {
if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
g_free(path);
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
"uidl-", server,
"-", sanitized_uid, NULL);
if ((fp = g_fopen(path, "rb")) == NULL) {
if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
g_free(sanitized_uid);
g_free(path);
return result;
}
}
g_free(sanitized_uid);
g_free(path);
now = time(NULL);
while (fgets(buf, sizeof(buf), fp) != NULL) {
gchar tmp[POPBUFSIZE];
strretchomp(buf);
recv_time = RECV_TIME_NONE;
if (sscanf(buf, "%s\t%ld\t%s", uidl, (long int *) &recv_time,
tmp) < 2) {
if (sscanf(buf, "%s", uidl) != 1)
continue;
else {
recv_time = now;
}
}
if (!strcmp(muidl, uidl)) {
result = g_strdup(tmp);
break;
}
}
fclose(fp);
return result;
} | false | false | false | false | false | 0 |
nautilus_window_slot_go_home (NautilusWindowSlot *slot,
NautilusWindowOpenFlags flags)
{
GFile *home;
g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));
home = g_file_new_for_path (g_get_home_dir ());
nautilus_window_slot_open_location (slot, home, flags);
g_object_unref (home);
} | false | false | false | false | false | 0 |
decrypt_payloads(private_message_t *this, keymat_t *keymat)
{
payload_t *payload, *previous = NULL;
enumerator_t *enumerator;
payload_rule_t *rule;
payload_type_t type;
status_t status = SUCCESS;
char *was_encrypted = NULL;
enumerator = this->payloads->create_enumerator(this->payloads);
while (enumerator->enumerate(enumerator, &payload))
{
type = payload->get_type(payload);
DBG2(DBG_ENC, "process payload of type %N", payload_type_names, type);
if (type == PLV2_ENCRYPTED || type == PLV1_ENCRYPTED ||
type == PLV2_FRAGMENT)
{
if (was_encrypted)
{
DBG1(DBG_ENC, "%s can't contain other payloads of type %N",
was_encrypted, payload_type_names, type);
status = VERIFY_ERROR;
break;
}
}
if (type == PLV2_ENCRYPTED || type == PLV1_ENCRYPTED)
{
encrypted_payload_t *encryption;
DBG2(DBG_ENC, "found an encrypted payload");
encryption = (encrypted_payload_t*)payload;
this->payloads->remove_at(this->payloads, enumerator);
if (enumerator->enumerate(enumerator, NULL))
{
DBG1(DBG_ENC, "encrypted payload is not last payload");
encryption->destroy(encryption);
status = VERIFY_ERROR;
break;
}
status = decrypt_and_extract(this, keymat, previous, encryption);
encryption->destroy(encryption);
if (status != SUCCESS)
{
break;
}
was_encrypted = "encrypted payload";
}
else if (type == PLV2_FRAGMENT)
{
encrypted_fragment_payload_t *fragment;
DBG2(DBG_ENC, "found an encrypted fragment payload");
fragment = (encrypted_fragment_payload_t*)payload;
if (enumerator->enumerate(enumerator, NULL))
{
DBG1(DBG_ENC, "encrypted fragment payload is not last payload");
status = VERIFY_ERROR;
break;
}
status = decrypt_fragment(this, keymat, fragment);
if (status != SUCCESS)
{
break;
}
was_encrypted = "encrypted fragment payload";
}
if (payload_is_known(type, this->major_version) && !was_encrypted &&
!is_connectivity_check(this, payload) &&
this->exchange_type != AGGRESSIVE)
{
rule = get_payload_rule(this, type);
if ((!rule || rule->encrypted) &&
!accept_unencrypted_mm(this, type))
{
DBG1(DBG_ENC, "payload type %N was not encrypted",
payload_type_names, type);
status = FAILED;
break;
}
}
previous = payload;
}
enumerator->destroy(enumerator);
return status;
} | false | false | false | false | false | 0 |
write_agg_replacement_chain (struct output_block *ob, struct cgraph_node *node)
{
int node_ref;
unsigned int count = 0;
lto_symtab_encoder_t encoder;
struct ipa_agg_replacement_value *aggvals, *av;
aggvals = ipa_get_agg_replacements_for_node (node);
encoder = ob->decl_state->symtab_node_encoder;
node_ref = lto_symtab_encoder_encode (encoder, (symtab_node) node);
streamer_write_uhwi (ob, node_ref);
for (av = aggvals; av; av = av->next)
count++;
streamer_write_uhwi (ob, count);
for (av = aggvals; av; av = av->next)
{
struct bitpack_d bp;
streamer_write_uhwi (ob, av->offset);
streamer_write_uhwi (ob, av->index);
stream_write_tree (ob, av->value, true);
bp = bitpack_create (ob->main_stream);
bp_pack_value (&bp, av->by_ref, 1);
streamer_write_bitpack (&bp);
}
} | false | false | false | false | false | 0 |
od_get_esd(GF_ObjectDescriptor *OD, u16 ESID)
{
GF_ESD *esd;
u32 i = 0;
while ((esd = (GF_ESD *)gf_list_enum(OD->ESDescriptors, &i)) ) {
if (esd->ESID==ESID) return esd;
}
return NULL;
} | false | false | false | false | false | 0 |
select_del(void *arg, struct event *ev)
{
struct selectop *sop = arg;
check_selectop(sop);
if (ev->ev_events & EV_SIGNAL)
return (evsignal_del(ev));
if (sop->event_fds < ev->ev_fd) {
check_selectop(sop);
return (0);
}
if (ev->ev_events & EV_READ) {
FD_CLR(ev->ev_fd, sop->event_readset_in);
sop->event_r_by_fd[ev->ev_fd] = NULL;
}
if (ev->ev_events & EV_WRITE) {
FD_CLR(ev->ev_fd, sop->event_writeset_in);
sop->event_w_by_fd[ev->ev_fd] = NULL;
}
check_selectop(sop);
return (0);
} | false | false | false | false | false | 0 |
str_starts_with(const char * string, const char * prefix) {
const char * string_ptr = string;
const char * prefix_ptr = prefix;
while (*string_ptr != '\0' && *prefix_ptr != '\0') {
if (*string_ptr != *prefix_ptr) {
return false;
}
string_ptr++;
prefix_ptr++;
}
if (*string_ptr == '\0' && *prefix_ptr != '\0') {
return false;
}
return true;
} | false | false | false | false | false | 0 |
__videobuf_iolock(struct videobuf_queue *q,
struct videobuf_buffer *vb,
struct v4l2_framebuffer *fbuf)
{
struct videobuf_vmalloc_memory *mem = vb->priv;
int pages;
BUG_ON(!mem);
MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM);
switch (vb->memory) {
case V4L2_MEMORY_MMAP:
dprintk(1, "%s memory method MMAP\n", __func__);
/* All handling should be done by __videobuf_mmap_mapper() */
if (!mem->vaddr) {
printk(KERN_ERR "memory is not alloced/mmapped.\n");
return -EINVAL;
}
break;
case V4L2_MEMORY_USERPTR:
pages = PAGE_ALIGN(vb->size);
dprintk(1, "%s memory method USERPTR\n", __func__);
if (vb->baddr) {
printk(KERN_ERR "USERPTR is currently not supported\n");
return -EINVAL;
}
/* The only USERPTR currently supported is the one needed for
* read() method.
*/
mem->vaddr = vmalloc_user(pages);
if (!mem->vaddr) {
printk(KERN_ERR "vmalloc (%d pages) failed\n", pages);
return -ENOMEM;
}
dprintk(1, "vmalloc is at addr %p (%d pages)\n",
mem->vaddr, pages);
#if 0
int rc;
/* Kernel userptr is used also by read() method. In this case,
there's no need to remap, since data will be copied to user
*/
if (!vb->baddr)
return 0;
/* FIXME: to properly support USERPTR, remap should occur.
The code below won't work, since mem->vma = NULL
*/
/* Try to remap memory */
rc = remap_vmalloc_range(mem->vma, (void *)vb->baddr, 0);
if (rc < 0) {
printk(KERN_ERR "mmap: remap failed with error %d", rc);
return -ENOMEM;
}
#endif
break;
case V4L2_MEMORY_OVERLAY:
default:
dprintk(1, "%s memory method OVERLAY/unknown\n", __func__);
/* Currently, doesn't support V4L2_MEMORY_OVERLAY */
printk(KERN_ERR "Memory method currently unsupported.\n");
return -EINVAL;
}
return 0;
} | false | false | false | false | false | 0 |
process(const NodePtr &node, FOTBuilder &fotb)
{
ProcessContext context(*interpreter_, fotb);
context.process(node);
} | false | false | false | false | false | 0 |
binding_to_template_parms_of_scope_p (cxx_binding *binding,
cp_binding_level *scope)
{
tree binding_value, tmpl, tinfo;
int level;
if (!binding || !scope || !scope->this_entity)
return false;
binding_value = binding->value ? binding->value : binding->type;
tinfo = get_template_info (scope->this_entity);
/* BINDING_VALUE must be a template parm. */
if (binding_value == NULL_TREE
|| (!DECL_P (binding_value)
|| !DECL_TEMPLATE_PARM_P (binding_value)))
return false;
/* The level of BINDING_VALUE. */
level =
template_type_parameter_p (binding_value)
? TEMPLATE_PARM_LEVEL (TEMPLATE_TYPE_PARM_INDEX
(TREE_TYPE (binding_value)))
: TEMPLATE_PARM_LEVEL (DECL_INITIAL (binding_value));
/* The template of the current scope, iff said scope is a primary
template. */
tmpl = (tinfo
&& PRIMARY_TEMPLATE_P (TI_TEMPLATE (tinfo))
? TI_TEMPLATE (tinfo)
: NULL_TREE);
/* If the level of the parm BINDING_VALUE equals the depth of TMPL,
then BINDING_VALUE is a parameter of TMPL. */
return (tmpl && level == TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (tmpl)));
} | false | false | false | false | false | 0 |
wrap_check()
{ edge_id e_id;
facet_id f_id;
int numerr = 0;
int count = 0;
int i;
if ( web.torus_flag )
FOR_ALL_EDGES(e_id)
{ WRAPTYPE wrap = get_edge_wrap(e_id);
for ( i = 0 ; i < SDIM ; i++, wrap >>= TWRAPBITS )
switch ( wrap & WRAPMASK )
{
case NEGWRAP : break;
case 0 : break;
case POSWRAP : break;
default :
sprintf(errmsg,"Big wrap %d on edge %s period %d\n",
WRAPNUM(wrap&WRAPMASK),ELNAME(e_id),i+1);
erroutstring(errmsg);
numerr++;
break;
}
}
FOR_ALL_FACETS(f_id)
{
facetedge_id fe,start_fe;
int wrap = 0;
fe = start_fe = get_facet_fe(f_id);
count = 0;
if ( valid_id(fe) )
do
{ if ( get_vattr(get_fe_tailv(fe)) & AXIAL_POINT )
{ wrap = 0; break; }
wrap = (*sym_compose)(wrap,get_fe_wrap(fe));
fe = get_next_edge(fe);
count++;
if ( count > 2*web.skel[EDGE].count )
{ sprintf(errmsg,"Facet %s has unclosed edge loop.\n",ELNAME(f_id));
erroutstring(errmsg);
numerr++;
break;
}
} while ( valid_id(fe) && !equal_id(fe,start_fe) );
if ( valid_id(fe) && (wrap != 0) )
{ sprintf(errmsg,"Wraps around facet %s not consistent.\n",ELNAME(f_id));
kb_error(2000,errmsg,WARNING);
numerr++;
}
}
return numerr;
} | false | false | false | false | false | 0 |
TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *def_policy)
{
if (ctx->default_policy) ASN1_OBJECT_free(ctx->default_policy);
if (!(ctx->default_policy = OBJ_dup(def_policy))) goto err;
return 1;
err:
TSerr(TS_F_TS_RESP_CTX_SET_DEF_POLICY, ERR_R_MALLOC_FAILURE);
return 0;
} | false | false | false | false | false | 0 |
run_command(const gchar *command, const gchar *file_name,
const gchar *file_type, const gchar *func_name)
{
gchar *result = NULL;
gchar **argv;
if (g_shell_parse_argv(command, NULL, &argv, NULL))
{
GError *error = NULL;
gchar **env;
file_name = (file_name != NULL) ? file_name : "";
file_type = (file_type != NULL) ? file_type : "";
func_name = (func_name != NULL) ? func_name : "";
env = utils_copy_environment(NULL,
"GEANY_FILENAME", file_name,
"GEANY_FILETYPE", file_type,
"GEANY_FUNCNAME", func_name,
NULL);
if (! utils_spawn_sync(NULL, argv, env, G_SPAWN_SEARCH_PATH,
NULL, NULL, &result, NULL, NULL, &error))
{
g_warning("templates_replace_command: %s", error->message);
g_error_free(error);
return NULL;
}
g_strfreev(argv);
g_strfreev(env);
}
return result;
} | false | false | false | false | false | 0 |
handle_subunit_info(struct avctp *session,
uint8_t transaction, uint8_t *code,
uint8_t *subunit, uint8_t *operands,
size_t operand_count, void *user_data)
{
if (*code != AVC_CTYPE_STATUS) {
*code = AVC_CTYPE_REJECTED;
return 0;
}
*code = AVC_CTYPE_STABLE;
/* The first operand should be 0x07 for the UNITINFO response.
* Neither AVRCP (section 22.1, page 117) nor AVC Digital
* Interface Command Set (section 9.2.1, page 45) specs
* explain this value but both use it */
if (operand_count >= 2)
operands[1] = AVC_SUBUNIT_PANEL << 3;
DBG("reply to AVC_OP_SUBUNITINFO");
return operand_count;
} | false | false | false | false | false | 0 |
hi_diff_get_hunk(hi_diff *diff,
hi_file *file,
off_t pos)
{
hi_diff_hunk *found;
hi_diff_hunk search_hunk = {
.src_start = pos,
.dst_start = pos,
.src_end = 0,
.dst_end = 0
};
if (diff->src == file)
{
search_hunk.type = HI_DIFF_FIND_SRC;
}
else
{
search_hunk.type = HI_DIFF_FIND_DST;
}
/* Check to see if it's the same hunk as last time */
if (compare_diff_hunks(&search_hunk, diff->last_hunk) == 0)
{
return diff->last_hunk;
}
found = g_tree_lookup(diff->hunks, &search_hunk);
if (NULL != found)
{
diff->last_hunk = found;
#if 0
DPRINTF("Found %lu", pos);
dump_hunk(found);
#endif
}
return found;
} | false | false | false | false | false | 0 |
dict_create(long size_hint, void (*destroy_value)(void *))
{
Dict *dict;
long i;
dict = gw_malloc(sizeof(*dict));
/*
* Hash tables tend to work well until they are fill to about 50%.
*/
dict->size = size_hint * 2;
dict->tab = gw_malloc(sizeof(dict->tab[0]) * dict->size);
for (i = 0; i < dict->size; ++i)
dict->tab[i] = NULL;
dict->lock = mutex_create();
dict->destroy_value = destroy_value;
dict->key_count = 0;
return dict;
} | false | false | false | false | false | 0 |
directory_get_directories(const std::string & dir,
std::list<std::string> & files)
{
if(!Glib::file_test(dir, Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_DIR)) {
return;
}
Glib::Dir d(dir);
for(Glib::Dir::iterator iter = d.begin(); iter != d.end(); ++iter) {
const std::string file(dir + "/" + *iter);
if(Glib::file_test(file, Glib::FILE_TEST_IS_DIR)) {
files.push_back(file);
}
}
} | false | false | false | false | false | 0 |
ax88172a_reset(struct usbnet *dev)
{
struct asix_data *data = (struct asix_data *)&dev->data;
struct ax88172a_private *priv = dev->driver_priv;
int ret;
u16 rx_ctl;
ax88172a_reset_phy(dev, priv->use_embdphy);
msleep(150);
rx_ctl = asix_read_rx_ctl(dev);
netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl);
ret = asix_write_rx_ctl(dev, 0x0000);
if (ret < 0)
goto out;
rx_ctl = asix_read_rx_ctl(dev);
netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl);
msleep(150);
ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0,
AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
AX88772_IPG2_DEFAULT, 0, NULL);
if (ret < 0) {
netdev_err(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret);
goto out;
}
/* Rewrite MAC address */
memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN);
ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
data->mac_addr);
if (ret < 0)
goto out;
/* Set RX_CTL to default values with 2k buffer, and enable cactus */
ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL);
if (ret < 0)
goto out;
rx_ctl = asix_read_rx_ctl(dev);
netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n",
rx_ctl);
rx_ctl = asix_read_medium_status(dev);
netdev_dbg(dev->net, "Medium Status is 0x%04x after all initializations\n",
rx_ctl);
/* Connect to PHY */
snprintf(priv->phy_name, 20, PHY_ID_FMT,
priv->mdio->id, priv->phy_addr);
priv->phydev = phy_connect(dev->net, priv->phy_name,
&ax88172a_adjust_link,
PHY_INTERFACE_MODE_MII);
if (IS_ERR(priv->phydev)) {
netdev_err(dev->net, "Could not connect to PHY device %s\n",
priv->phy_name);
ret = PTR_ERR(priv->phydev);
goto out;
}
netdev_info(dev->net, "Connected to phy %s\n", priv->phy_name);
/* During power-up, the AX88172A set the power down (BMCR_PDOWN)
* bit of the PHY. Bring the PHY up again.
*/
genphy_resume(priv->phydev);
phy_start(priv->phydev);
return 0;
out:
return ret;
} | false | false | false | false | false | 0 |
_reg_segment(map_segment_t *s, int *num_btl)
{
int rc = OSHMEM_SUCCESS;
int my_pe;
int nprocs;
nprocs = oshmem_num_procs();
my_pe = oshmem_my_proc_id();
s->mkeys_cache = (sshmem_mkey_t **) calloc(nprocs,
sizeof(sshmem_mkey_t *));
if (NULL == s->mkeys_cache) {
MEMHEAP_ERROR("Failed to allocate memory for remote segments");
rc = OSHMEM_ERROR;
}
if (!rc) {
s->mkeys = MCA_SPML_CALL(register((void *)(unsigned long)s->seg_base_addr,
(uintptr_t)s->end - (uintptr_t)s->seg_base_addr,
s->seg_id,
num_btl));
if (NULL == s->mkeys) {
free(s->mkeys_cache);
s->mkeys_cache = NULL;
MEMHEAP_ERROR("Failed to register segment");
rc = OSHMEM_ERROR;
}
}
if (OSHMEM_SUCCESS == rc) {
s->mkeys_cache[my_pe] = s->mkeys;
MAP_SEGMENT_SET_VALID(s);
}
return rc;
} | false | false | false | false | false | 0 |
regulator_find_supply_alias(
struct device *dev, const char *supply)
{
struct regulator_supply_alias *map;
list_for_each_entry(map, ®ulator_supply_alias_list, list)
if (map->src_dev == dev && strcmp(map->src_supply, supply) == 0)
return map;
return NULL;
} | false | false | false | false | false | 0 |
wap_appl_init(Cfg *cfg)
{
gw_assert(run_status == limbo);
queue = gwlist_create();
fetches = counter_create();
gwlist_add_producer(queue);
run_status = running;
charsets = wml_charsets();
caller = http_caller_create();
gwthread_create(main_thread, NULL);
gwthread_create(return_replies_thread, NULL);
if (cfg != NULL)
have_ppg = 1;
else
have_ppg = 0;
} | false | false | false | false | false | 0 |
__Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
PyObject *method, *result = NULL;
method = __Pyx_PyObject_GetAttrStr(obj, method_name);
if (unlikely(!method)) goto bad;
#if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyMethod_Check(method))) {
PyObject *self = PyMethod_GET_SELF(method);
if (likely(self)) {
PyObject *function = PyMethod_GET_FUNCTION(method);
result = __Pyx_PyObject_CallOneArg(function, self);
Py_DECREF(method);
return result;
}
}
#endif
result = __Pyx_PyObject_CallNoArg(method);
Py_DECREF(method);
bad:
return result;
} | false | false | false | false | false | 0 |
dragDrop(const QString &text, ContactViewItem *i)
{
if(!d->pa->loggedIn())
return;
// get group
ContactViewItem *gr;
if(i->type() == ContactViewItem::Group)
gr = i;
else
gr = (ContactViewItem *)static_cast<Q3ListViewItem *>(i)->parent();
Jid j(text);
if(!j.isValid())
return;
Entry *e = findEntry(j);
if(!e)
return;
const UserListItem &u = e->u;
QStringList gl = u.groups();
// already in the general group
if(gr->groupType() == ContactViewItem::gGeneral && gl.isEmpty())
return;
// already in this user group
if(gr->groupType() == ContactViewItem::gUser && u.inGroup(gr->groupName()))
return;
//printf("putting [%s] into group [%s]\n", u.jid().full().latin1(), gr->groupName().latin1());
// remove all other groups from this contact
for(QStringList::ConstIterator it = gl.begin(); it != gl.end(); ++it) {
actionGroupRemove(u.jid(), *it);
}
if(gr->groupType() == ContactViewItem::gUser) {
// add the new group
actionGroupAdd(u.jid(), gr->groupName());
}
} | false | false | false | false | false | 0 |
posix_sysconf(PyObject *self, PyObject *args)
{
PyObject *result = NULL;
int name;
if (PyArg_ParseTuple(args, "O&:sysconf", conv_sysconf_confname, &name)) {
int value;
errno = 0;
value = sysconf(name);
if (value == -1 && errno != 0)
posix_error();
else
result = PyInt_FromLong(value);
}
return result;
} | false | false | false | false | false | 0 |
pixOctcubeQuantFromCmapLUT(PIX *pixs,
PIXCMAP *cmap,
l_int32 mindepth,
l_int32 *cmaptab,
l_uint32 *rtab,
l_uint32 *gtab,
l_uint32 *btab)
{
l_int32 i, j, w, h, depth, wpls, wpld;
l_int32 rval, gval, bval, index;
l_uint32 octindex;
l_uint32 *lines, *lined, *datas, *datad;
PIX *pixd;
PIXCMAP *cmapc;
PROCNAME("pixOctcubeQuantFromCmapLUT");
if (!pixs)
return (PIX *)ERROR_PTR("pixs not defined", procName, NULL);
if (pixGetDepth(pixs) != 32)
return (PIX *)ERROR_PTR("pixs not 32 bpp", procName, NULL);
if (!cmap)
return (PIX *)ERROR_PTR("cmap not defined", procName, NULL);
if (mindepth != 2 && mindepth != 4 && mindepth != 8)
return (PIX *)ERROR_PTR("invalid mindepth", procName, NULL);
if (!rtab || !gtab || !btab || !cmaptab)
return (PIX *)ERROR_PTR("tables not all defined", procName, NULL);
/* Init dest pix (with minimum bpp depending on cmap) */
pixcmapGetMinDepth(cmap, &depth);
depth = L_MAX(depth, mindepth);
pixGetDimensions(pixs, &w, &h, NULL);
if ((pixd = pixCreate(w, h, depth)) == NULL)
return (PIX *)ERROR_PTR("pixd not made", procName, NULL);
cmapc = pixcmapCopy(cmap);
pixSetColormap(pixd, cmapc);
pixCopyResolution(pixd, pixs);
pixCopyInputFormat(pixd, pixs);
/* Insert the colormap index of the color nearest to the input pixel */
datas = pixGetData(pixs);
datad = pixGetData(pixd);
wpls = pixGetWpl(pixs);
wpld = pixGetWpl(pixd);
for (i = 0; i < h; i++) {
lines = datas + i * wpls;
lined = datad + i * wpld;
for (j = 0; j < w; j++) {
extractRGBValues(lines[j], &rval, &gval, &bval);
/* Map from rgb to octcube index */
getOctcubeIndexFromRGB(rval, gval, bval, rtab, gtab, btab,
&octindex);
/* Map from octcube index to nearest colormap index */
index = cmaptab[octindex];
if (depth == 2)
SET_DATA_DIBIT(lined, j, index);
else if (depth == 4)
SET_DATA_QBIT(lined, j, index);
else /* depth == 8 */
SET_DATA_BYTE(lined, j, index);
}
}
return pixd;
} | false | false | false | false | false | 0 |
mini_parse_debug_options (void)
{
const char *options = g_getenv ("MONO_DEBUG");
gchar **args, **ptr;
if (!options)
return;
args = g_strsplit (options, ",", -1);
for (ptr = args; ptr && *ptr; ptr++) {
const char *arg = *ptr;
if (!strcmp (arg, "handle-sigint"))
debug_options.handle_sigint = TRUE;
else if (!strcmp (arg, "keep-delegates"))
debug_options.keep_delegates = TRUE;
else if (!strcmp (arg, "reverse-pinvoke-exceptions"))
debug_options.reverse_pinvoke_exceptions = TRUE;
else if (!strcmp (arg, "collect-pagefault-stats"))
debug_options.collect_pagefault_stats = TRUE;
else if (!strcmp (arg, "break-on-unverified"))
debug_options.break_on_unverified = TRUE;
else if (!strcmp (arg, "no-gdb-backtrace"))
debug_options.no_gdb_backtrace = TRUE;
else if (!strcmp (arg, "suspend-on-sigsegv"))
debug_options.suspend_on_sigsegv = TRUE;
else if (!strcmp (arg, "suspend-on-unhandled"))
debug_options.suspend_on_unhandled = TRUE;
else if (!strcmp (arg, "dont-free-domains"))
mono_dont_free_domains = TRUE;
else if (!strcmp (arg, "dyn-runtime-invoke"))
debug_options.dyn_runtime_invoke = TRUE;
else if (!strcmp (arg, "gdb"))
debug_options.gdb = TRUE;
else if (!strcmp (arg, "explicit-null-checks"))
debug_options.explicit_null_checks = TRUE;
else if (!strcmp (arg, "gen-seq-points"))
debug_options.gen_seq_points = TRUE;
else if (!strcmp (arg, "init-stacks"))
debug_options.init_stacks = TRUE;
else if (!strcmp (arg, "casts"))
debug_options.better_cast_details = TRUE;
else if (!strcmp (arg, "soft-breakpoints"))
debug_options.soft_breakpoints = TRUE;
else {
fprintf (stderr, "Invalid option for the MONO_DEBUG env variable: %s\n", arg);
fprintf (stderr, "Available options: 'handle-sigint', 'keep-delegates', 'reverse-pinvoke-exceptions', 'collect-pagefault-stats', 'break-on-unverified', 'no-gdb-backtrace', 'dont-free-domains', 'suspend-on-sigsegv', 'suspend-on-unhandled', 'dyn-runtime-invoke', 'gdb', 'explicit-null-checks', 'init-stacks'\n");
exit (1);
}
}
g_strfreev (args);
} | false | false | false | false | false | 0 |
add_color_selector(GtkWidget *page, gchar *name, gchar *gconf_path, MultiloadApplet *ma)
{
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *color_picker;
GdkColor color;
gchar *color_string;
color_string = panel_applet_gconf_get_string(ma->applet, gconf_path, NULL);
if (!color_string)
color_string = g_strdup ("#000000");
color.red = (g_ascii_xdigit_value(color_string[1]) * 16
+ g_ascii_xdigit_value(color_string[2])) * 256;
color.green = (g_ascii_xdigit_value(color_string[3]) * 16
+ g_ascii_xdigit_value(color_string[4])) * 256;
color.blue = (g_ascii_xdigit_value(color_string[5]) * 16
+ g_ascii_xdigit_value(color_string[6])) * 256;
g_free (color_string);
vbox = gtk_vbox_new (FALSE, 6);
label = gtk_label_new_with_mnemonic(name);
color_picker = gtk_color_button_new();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), color_picker);
gtk_box_pack_start(GTK_BOX(vbox), color_picker, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(page), vbox, FALSE, FALSE, 0);
g_object_set_data (G_OBJECT (color_picker), "MultiloadApplet", ma);
gtk_color_button_set_color(GTK_COLOR_BUTTON(color_picker), &color);
g_signal_connect(G_OBJECT(color_picker), "color_set", G_CALLBACK(color_picker_set_cb), gconf_path);
if ( ! key_writable (ma->applet, gconf_path))
hard_set_sensitive (vbox, FALSE);
return;
} | false | false | false | false | false | 0 |
sigmaKin() {
// Get S(x) values for G amplitude.
complex sS(0., 0.);
complex sT(0., 0.);
complex sU(0., 0.);
if (eDopMode == 0) {
sS = ampLedS( sH/pow2(eDLambdaT), eDnGrav, eDLambdaT, eDMD);
sT = ampLedS( tH/pow2(eDLambdaT), eDnGrav, eDLambdaT, eDMD);
sU = ampLedS( uH/pow2(eDLambdaT), eDnGrav, eDLambdaT, eDMD);
} else {
// Form factor.
double effLambda = eDLambdaT;
if ((eDcutoff == 2) || (eDcutoff == 3)) {
double ffterm = sqrt(Q2RenSave) / (eDtff * eDLambdaT);
double exp = double(eDnGrav) + 2.;
double formfa = 1. + pow(ffterm, exp);
effLambda *= pow(formfa,0.25);
}
sS = 4.*M_PI/pow(effLambda,4);
sT = 4.*M_PI/pow(effLambda,4);
sU = 4.*M_PI/pow(effLambda,4);
if (eDnegInt == 1) {
sS *= -1.;
sT *= -1.;
sU *= -1.;
}
}
// Pick new flavour.
idNew = 1 + int( nQuarkNew * rndmPtr->flat() );
mNew = particleDataPtr->m0(idNew);
m2New = mNew*mNew;
// Calculate kinematics dependence.
sigTS = 0.;
sigUS = 0.;
if (sH > 4. * m2New) {
double tH3 = tH*tH2;
double uH3 = uH*uH2;
sigTS = (16. * pow2(M_PI) * pow2(alpS))
* ((1./6.) * uH / tH - (3./8.) * uH2 / sH2)
- 0.5 * M_PI * alpS * uH2 * sS.real()
+ (3./16.) * uH3 * tH * real(sS*conj(sS));
sigUS = (16. * pow2(M_PI) * pow2(alpS))
* ((1./6.) * tH / uH - (3./8.) * tH2 / sH2)
- 0.5 * M_PI * alpS * tH2 * sS.real()
+ (3./16.) * tH3 * uH * real(sS*conj(sS));
}
sigSum = sigTS + sigUS;
// Answer is proportional to number of outgoing flavours.
sigma = nQuarkNew * sigSum / (16. * M_PI * sH2);
} | false | false | false | false | false | 0 |
fixname(s)
char *s;
{
while (*s) {
if (!isalpha(*s) && !isdigit(*s))
*s = '_';
s++;
}
} | false | false | false | false | false | 0 |
test_submodule_modify__sync(void)
{
git_submodule *sm1, *sm2, *sm3;
git_config *cfg;
const char *str;
#define SM1 "sm_unchanged"
#define SM2 "sm_changed_head"
#define SM3 "sm_added_and_uncommited"
/* look up some submodules */
cl_git_pass(git_submodule_lookup(&sm1, g_repo, SM1));
cl_git_pass(git_submodule_lookup(&sm2, g_repo, SM2));
cl_git_pass(git_submodule_lookup(&sm3, g_repo, SM3));
/* At this point, the .git/config URLs for the submodules have
* not be rewritten with the absolute paths (although the
* .gitmodules have. Let's confirm that they DO NOT match
* yet, then we can do a sync to make them match...
*/
/* check submodule info does not match before sync */
cl_git_pass(git_repository_config(&cfg, g_repo));
cl_git_pass(git_config_get_string(&str, cfg, "submodule."SM1".url"));
cl_assert(strcmp(git_submodule_url(sm1), str) != 0);
cl_git_pass(git_config_get_string(&str, cfg, "submodule."SM2".url"));
cl_assert(strcmp(git_submodule_url(sm2), str) != 0);
cl_git_pass(git_config_get_string(&str, cfg, "submodule."SM3".url"));
cl_assert(strcmp(git_submodule_url(sm3), str) != 0);
git_config_free(cfg);
/* sync all the submodules */
cl_git_pass(git_submodule_foreach(g_repo, sync_one_submodule, NULL));
/* check that submodule config is updated */
assert_submodule_url_is_synced(
sm1, "submodule."SM1".url", "branch.origin.remote");
assert_submodule_url_is_synced(
sm2, "submodule."SM2".url", "branch.origin.remote");
assert_submodule_url_is_synced(
sm3, "submodule."SM3".url", "branch.origin.remote");
git_submodule_free(sm1);
git_submodule_free(sm2);
git_submodule_free(sm3);
} | false | false | false | false | false | 0 |
ACL_ListFind (NSErr_t *errp, ACLListHandle_t *acl_list, char *acl_name, int flags )
{
ACLHandle_t *result = NULL;
ACLWrapper_t *wrapper;
Symbol_t *sym;
if ( acl_list == NULL || acl_name == NULL )
return( result );
/*
* right now the symbol table exists if there hasn't been
* any collisions based on using case insensitive names.
* if there are any collisions then the table will be
* deleted and we will look up using list search.
*
* we should probably create two hash tables, one for case
* sensitive lookups and the other for insensitive.
*/
if ( acl_list->acl_sym_table ) {
if ( symTableFindSym(acl_list->acl_sym_table,
acl_name, ACLSYMACL, (void **) &sym) >= 0 ) {
result = (ACLHandle_t *) sym->sym_data;
if ( result && (flags & ACL_CASE_SENSITIVE) &&
strcmp(result->tag, acl_name) ) {
result = NULL; /* case doesn't match */
}
}
return( result );
}
if ( flags & ACL_CASE_INSENSITIVE ) {
for ( wrapper = acl_list->acl_list_head; wrapper != NULL;
wrapper = wrapper->wrap_next ) {
if ( wrapper->acl->tag &&
strcasecmp( wrapper->acl->tag, acl_name ) == 0 ) {
result = wrapper->acl;
break;
}
}
} else {
for ( wrapper = acl_list->acl_list_head; wrapper != NULL;
wrapper = wrapper->wrap_next ) {
if ( wrapper->acl->tag &&
strcmp( wrapper->acl->tag, acl_name ) == 0 ) {
result = wrapper->acl;
break;
}
}
}
return( result );
} | false | false | false | false | false | 0 |
find_language_template(const char *languageName)
{
PLTemplate *result;
Relation rel;
SysScanDesc scan;
ScanKeyData key;
HeapTuple tup;
rel = heap_open(PLTemplateRelationId, AccessShareLock);
ScanKeyInit(&key,
Anum_pg_pltemplate_tmplname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(languageName));
scan = systable_beginscan(rel, PLTemplateNameIndexId, true,
SnapshotNow, 1, &key);
tup = systable_getnext(scan);
if (HeapTupleIsValid(tup))
{
Form_pg_pltemplate tmpl = (Form_pg_pltemplate) GETSTRUCT(tup);
Datum datum;
bool isnull;
result = (PLTemplate *) palloc0(sizeof(PLTemplate));
result->tmpltrusted = tmpl->tmpltrusted;
/* Remaining fields are variable-width so we need heap_getattr */
datum = heap_getattr(tup, Anum_pg_pltemplate_tmplhandler,
RelationGetDescr(rel), &isnull);
if (!isnull)
result->tmplhandler =
DatumGetCString(DirectFunctionCall1(textout, datum));
datum = heap_getattr(tup, Anum_pg_pltemplate_tmplvalidator,
RelationGetDescr(rel), &isnull);
if (!isnull)
result->tmplvalidator =
DatumGetCString(DirectFunctionCall1(textout, datum));
datum = heap_getattr(tup, Anum_pg_pltemplate_tmpllibrary,
RelationGetDescr(rel), &isnull);
if (!isnull)
result->tmpllibrary =
DatumGetCString(DirectFunctionCall1(textout, datum));
/* Ignore template if handler or library info is missing */
if (!result->tmplhandler || !result->tmpllibrary)
result = NULL;
}
else
result = NULL;
systable_endscan(scan);
heap_close(rel, AccessShareLock);
return result;
} | false | false | false | false | false | 0 |
acdPromptMatrix(AcdPAcd thys)
{
static ajint count = 0;
AjBool protein = ajFalse;
const AjPStr knowntype;
acdAttrToBool(thys, "protein", ajFalse, &protein);
knowntype = acdKnowntypeDesc(thys);
if(ajStrGetLen(knowntype))
{
count++;
acdPromptStandardS(thys, knowntype);
if(!ajStrSuffixC(knowntype, " file"))
acdPromptStandardAppend(thys, " file");
}
else
{
if(acdDoValid)
acdPromptStandard(thys, "comparison matrix file",
&count);
else
{
if(protein)
acdPromptStandard(thys, "(protein) comparison matrix file",
&count);
else
acdPromptStandard(thys, "(nucleotide) comparison matrix file",
&count);
}
}
if(!acdAttrTestDefined(thys, "default") &&
acdAttrTestDefined(thys, "nullok"))
acdPromptStandardAppend(thys, " (optional)");
return thys->StdPrompt;
} | false | false | false | false | false | 0 |
incr_sub_inclusive_time_ix(pTHX_ void *subr_entry_ix_void)
{
/* recover the I32 ix that was stored as a void pointer */
I32 save_ix = (I32)PTR2IV(subr_entry_ix_void);
incr_sub_inclusive_time(aTHX_ subr_entry_ix_ptr(save_ix));
} | false | false | false | false | false | 0 |
decode_quoted_printable(char *dest,
char *src,
size_t *size)
{
int cc;
size_t i=0;
while (*src != 0 && i < *size) {
if (*src == '=') {
src++;
if (!*src) {
break;
}
/* remove soft line breaks*/
if ((*src == '\n') || (*src == '\r')){
src++;
if ((*src == '\n') || (*src == '\r')){
src++;
}
continue;
}
cc = isdigit(*src) ? (*src - '0') : (*src - 55);
cc *= 0x10;
src++;
if (!*src) {
break;
}
cc += isdigit(*src) ? (*src - '0') : (*src - 55);
*dest = cc;
} else {
*dest = *src;
}
dest++;
src++;
i++;
}
*dest = '\0';
*size = i;
return(dest);
} | false | false | false | false | false | 0 |
setColumnDraggingEnabled(bool setting)
{
if (d_movingEnabled != setting)
{
d_movingEnabled = setting;
// make the setting change for all component segments.
for (uint i = 0; i <getColumnCount(); ++i)
{
d_segments[i]->setDragMovingEnabled(d_movingEnabled);
}
// Fire setting changed event.
WindowEventArgs args(this);
onDragMoveSettingChanged(args);
}
} | false | false | false | false | false | 0 |
lpc18xx_uart_serial_out(struct uart_port *p, int offset, int value)
{
/*
* For DMA mode one must ensure that the UART_FCR_DMA_SELECT
* bit is set when FIFO is enabled. Even if DMA is not used
* setting this bit doesn't seem to affect anything.
*/
if (offset == UART_FCR && (value & UART_FCR_ENABLE_FIFO))
value |= UART_FCR_DMA_SELECT;
offset = offset << p->regshift;
writel(value, p->membase + offset);
} | false | false | false | false | false | 0 |
build_nt VPARAMS ((enum tree_code code, ...))
{
tree t;
int length;
int i;
VA_OPEN (p, code);
VA_FIXEDARG (p, enum tree_code, code);
t = make_node (code);
length = TREE_CODE_LENGTH (code);
for (i = 0; i < length; i++)
TREE_OPERAND (t, i) = va_arg (p, tree);
VA_CLOSE (p);
return t;
} | false | false | false | false | true | 1 |
filter_store_populate(void)
{
GList *work;
if (!filter_store) return;
gtk_list_store_clear(filter_store);
work = filter_get_list();
while (work)
{
FilterEntry *fe;
GtkTreeIter iter;
fe = work->data;
work = work->next;
gtk_list_store_append(filter_store, &iter);
gtk_list_store_set(filter_store, &iter, 0, fe, -1);
}
} | false | false | false | false | false | 0 |
dlg_open_with (FrWindow *window,
GList *file_list)
{
OpenData *o_data;
GtkWidget *app_chooser;
o_data = g_new0 (OpenData, 1);
o_data->window = window;
o_data->file_list = file_list;
app_chooser = gtk_app_chooser_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_MODAL,
G_FILE (file_list->data));
g_signal_connect (app_chooser,
"response",
G_CALLBACK (app_chooser_response_cb),
o_data);
gtk_widget_show (app_chooser);
} | false | false | false | false | false | 0 |
skip_row_internal( source & s, const int width )
{
int numOutBytes = 0;
rle_decoder::byte b;
bool re = false; // read error
while( numOutBytes < width && !re && !s.eof() )
{
const int check = s.read( &b, 1 );
if( check != 1 ) re = true;
if( b >= 0 /*&& b <= 127*/ ) /* 2nd is always true */
{
char buffer[128];
const int nbytes = s.read( buffer, b + 1 );
if( nbytes != b + 1 ) re = true;
numOutBytes += nbytes;
}
else if( b <= -1 && b >= -127 )
{
rle_decoder::byte nextByte;
const int nbytes = s.read( &nextByte, 1 );
if( nbytes != 1 ) re = true;
numOutBytes += -b + 1;
}
/* else b == -128 */
}
return numOutBytes == width && !re && !s.eof() ? true : false;
} | false | false | false | false | false | 0 |
_clutter_im_module_create (const gchar *context_id)
{
ClutterIMModule *im_module;
ClutterIMContext *context = NULL;
if (!contexts_hash)
clutter_im_module_initialize ();
if (strcmp (context_id, SIMPLE_ID) != 0)
{
im_module = g_hash_table_lookup (contexts_hash, context_id);
if (!im_module)
{
g_warning ("Attempt to load unknown IM context type '%s'", context_id);
}
else
{
if (g_type_module_use (G_TYPE_MODULE (im_module)))
{
context = im_module->create (context_id);
g_type_module_unuse (G_TYPE_MODULE (im_module));
}
if (!context)
g_warning ("Loading IM context type '%s' failed", context_id);
}
}
if (!context)
return clutter_im_context_simple_new ();
else
return context;
} | false | false | false | false | false | 0 |
popbuffer() {
struct buffer_el *el = ppop(&bufferstack);
currbuffer = el;
free(result);
if (!el) return;
result = el->buffer;
resultsize = el->size;
} | true | true | false | false | false | 1 |
ipoctal_copy_write_buffer(struct ipoctal_channel *channel,
const unsigned char *buf,
int count)
{
unsigned long flags;
int i;
unsigned int *pointer_read = &channel->pointer_read;
/* Copy the bytes from the user buffer to the internal one */
for (i = 0; i < count; i++) {
if (i <= (PAGE_SIZE - channel->nb_bytes)) {
spin_lock_irqsave(&channel->lock, flags);
channel->tty_port.xmit_buf[*pointer_read] = buf[i];
*pointer_read = (*pointer_read + 1) % PAGE_SIZE;
channel->nb_bytes++;
spin_unlock_irqrestore(&channel->lock, flags);
} else {
break;
}
}
return i;
} | false | false | false | false | false | 0 |
sectionAt(int sectionIndex) const
{
if(sectionIndex < 0 || sectionIndex >= mConfig.getNumSections())
{
throwError("FindSectionError", tr("Invalid section index"));
return QString();
}
return mConfig.getSectionNameAt(sectionIndex);
} | false | false | false | false | false | 0 |
ReadPhone (const AreaCodeDesc* Desc, long Index)
/* Read the phone number that is located at the given index. If we have a
* part of the table already loaded into memory, use the memory copy, else
* read the phone number from disk.
*/
{
if (Desc->Table && Index >= Desc->First && Index <= Desc->Last) {
/* Use the already loaded table, but don't forget to swap bytes */
return ByteSwapIfNeeded (Desc->Table [Index - Desc->First], Desc);
} else {
/* Load the value from the file */
fseek (Desc->F, Desc->AreaCodeStart + Index * sizeof (u32), SEEK_SET);
return Load_u32 (Desc);
}
} | false | false | false | false | false | 0 |
send_message(URLTranslation *trans, Msg *msg)
{
int max_msgs;
Octstr *header, *footer, *suffix, *split_chars;
int catenate;
unsigned long msg_sequence, msg_count;
List *list;
Msg *part;
gw_assert(msg != NULL);
gw_assert(msg_type(msg) == sms);
if (trans != NULL)
max_msgs = urltrans_max_messages(trans);
else
max_msgs = 1;
if (max_msgs == 0) {
info(0, "No reply sent, denied.");
return 0;
}
/*
* Encode our smsbox-id to the msg structure.
* This will allow bearerbox to return specific answers to the
* same smsbox, mainly for DLRs and SMS proxy modes.
*/
if (smsbox_id != NULL) {
msg->sms.boxc_id = octstr_duplicate(smsbox_id);
}
/*
* Empty message? Two alternatives have to be handled:
* a) it's a HTTP sms-service reply: either ignore it or
* substitute the "empty" warning defined
* b) it's a sendsms HTTP interface call: leave the message empty
*/
if (octstr_len(msg->sms.msgdata) == 0 && msg->sms.sms_type == mt_reply) {
if (trans != NULL && urltrans_omit_empty(trans))
return 0;
else
msg->sms.msgdata = octstr_duplicate(reply_emptymessage);
}
if (trans == NULL) {
header = NULL;
footer = NULL;
suffix = NULL;
split_chars = NULL;
catenate = 0;
} else {
header = urltrans_header(trans);
footer = urltrans_footer(trans);
suffix = urltrans_split_suffix(trans);
split_chars = urltrans_split_chars(trans);
catenate = urltrans_concatenation(trans);
}
if (catenate)
msg_sequence = counter_increase(catenated_sms_counter) & 0xFF;
else
msg_sequence = 0;
list = sms_split(msg, header, footer, suffix, split_chars, catenate,
msg_sequence, max_msgs, sms_max_length);
msg_count = gwlist_len(list);
debug("sms", 0, "message length %ld, sending %ld messages",
octstr_len(msg->sms.msgdata), msg_count);
/*
* In order to get catenated msgs work properly, we
* have moved catenation to bearerbox.
* So here we just need to put splitted msgs into one again and send
* to bearerbox that will care about catenation.
*/
if (catenate) {
Msg *new_msg = msg_duplicate(msg);
octstr_delete(new_msg->sms.msgdata, 0, octstr_len(new_msg->sms.msgdata));
while((part = gwlist_extract_first(list)) != NULL) {
octstr_append(new_msg->sms.msgdata, part->sms.msgdata);
msg_destroy(part);
}
write_to_bearerbox(new_msg);
} else {
/* msgs are the independed parts so sent those as is */
while ((part = gwlist_extract_first(list)) != NULL)
write_to_bearerbox(part);
}
gwlist_destroy(list, NULL);
return msg_count;
} | false | false | false | false | false | 0 |
free_chunklist (CodeChunk *chunk)
{
CodeChunk *dead;
#if defined(HAVE_VALGRIND_MEMCHECK_H) && defined (VALGRIND_JIT_UNREGISTER_MAP)
int valgrind_unregister = 0;
if (RUNNING_ON_VALGRIND)
valgrind_unregister = 1;
#define valgrind_unregister(x) do { if (valgrind_unregister) { VALGRIND_JIT_UNREGISTER_MAP(NULL,x); } } while (0)
#else
#define valgrind_unregister(x)
#endif
for (; chunk; ) {
dead = chunk;
mono_profiler_code_chunk_destroy ((gpointer) dead->data);
chunk = chunk->next;
if (dead->flags == CODE_FLAG_MMAP) {
codechunk_vfree (dead->data, dead->size);
/* valgrind_unregister(dead->data); */
} else if (dead->flags == CODE_FLAG_MALLOC) {
dlfree (dead->data);
}
code_memory_used -= dead->size;
free (dead);
}
} | false | false | false | false | false | 0 |
edit_entry_form(GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file){
// Presents the user with an editable form containing details of entry denoted by CGI variable entry_no*/
int entry_no, cred_no, i, admin=0, timestamp=atol(GRSThttpGetCGI("timestamp"));
GRSTgaclAcl *acl;
GRSTgaclEntry *entry;
GRSTgaclCred *cred;
GRSThttpBody bp;
if (!GRSTgaclPermHasAdmin(perm)) GRSThttpError ("403 Forbidden");
// Load ACL from file
acl = GRSTgaclAclLoadFile(GRSTgaclFileFindAclname(dir_path));
// Get pointer to the entry and check okay
entry_no=atol(GRSThttpGetCGI("entry_no"));
entry = GACLreturnEntry(acl, entry_no);
if(entry==NULL || entry_no<1 || entry_no>GACLentriesInAcl(acl) ){
GRSThttpError ("500 Unable to read from ACL file");
return;
}
StartHTML(&bp, dir_uri, dir_path);
GRSThttpPrintf (&bp, "<b><font size=\"4\">EDITING ENTRY %d IN ACL FOR %s </font></b></p>\n", entry_no, dir_uri);
// Start with first credential in the entry and display them in order*/
cred=entry->firstcred;
cred_no=1;
StartForm(&bp, dir_uri, dir_path, admin_file, timestamp, "edit_entry");
GRSThttpPrintf (&bp, "<input type=\"hidden\" name=\"entry_no\" value=\"%d\">\n", entry_no);
GRSTgaclCredTableStart(&bp);
while (cred!=NULL){
// Start with the first namevalue in the credential
GRSTgaclCredTableAdd(user, entry, cred, cred_no, entry_no, admin, timestamp, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file);
// Change to next credential
cred=cred->next;
cred_no++;
}
GRSTgaclCredTableEnd (entry, entry_no, admin, timestamp, &bp, dn, perm, help_uri, dir_path, file, dir_uri, admin_file);
GRSThttpPrintf (&bp, "<input type=\"hidden\" name=\"last_cred_no\" value=\"%d\">\n", cred_no-1);
EndForm(&bp);
admin_continue(dn, perm, help_uri, dir_path, file, dir_uri, admin_file, &bp);
return;
} | false | false | false | false | true | 1 |
homebank_upgrade_to_v02(void)
{
GList *list;
DB( g_print("\n[hb-xml] homebank_upgrade_to_v02\n") );
list = g_list_first(GLOBALS->ope_list);
while (list != NULL)
{
Transaction *entry = list->data;
entry->kacc++;
entry->kxferacc++;
list = g_list_next(list);
}
list = g_list_first(GLOBALS->arc_list);
while (list != NULL)
{
Archive *entry = list->data;
entry->kacc++;
entry->kxferacc++;
list = g_list_next(list);
}
} | false | false | false | false | false | 0 |
Cns_get_usrinfo_by_uid(dbfd, uid, user_entry, lock, rec_addr)
struct Cns_dbfd *dbfd;
uid_t uid;
struct Cns_userinfo *user_entry;
int lock;
Cns_dbrec_addr *rec_addr;
{
char func[23];
int i = 0;
static char query[] =
"SELECT USERID, USERNAME, USER_CA, BANNED FROM Cns_userinfo \
WHERE userid = %d";
static char query4upd[] =
"SELECT ROWID, USERID, USERNAME, USER_CA, BANNED FROM Cns_userinfo \
WHERE userid = %d FOR UPDATE";
MYSQL_RES *res;
MYSQL_ROW row;
char sql_stmt[1024];
strcpy (func, "Cns_get_usrinfo_by_uid");
dm_snprintf (sql_stmt, sizeof(sql_stmt), lock ? query4upd : query, uid);
if (Cns_exec_query (func, dbfd, sql_stmt, &res))
return (-1);
if ((row = mysql_fetch_row (res)) == NULL) {
mysql_free_result (res);
serrno = ENOENT;
return (-1);
}
if (lock)
strcpy (*rec_addr, row[i++]);
user_entry->userid = atoi (row[i++]);
strcpy (user_entry->username, row[i++]);
strcpy (user_entry->user_ca, row[i] ? row[i] : "");
i++;
user_entry->banned = row[i] ? atoi (row[i]) : 0;
mysql_free_result (res);
return (0);
} | false | false | false | false | false | 0 |
make_metaclass(VALUE klass)
{
VALUE super;
VALUE metaclass = rb_class_boot(Qundef);
FL_SET(metaclass, FL_SINGLETON);
rb_singleton_class_attached(metaclass, klass);
if (META_CLASS_OF_CLASS_CLASS_P(klass)) {
METACLASS_OF(klass) = METACLASS_OF(metaclass) = metaclass;
}
else {
VALUE tmp = METACLASS_OF(klass); /* for a meta^(n)-class klass, tmp is meta^(n)-class of Class class */
METACLASS_OF(klass) = metaclass;
METACLASS_OF(metaclass) = ENSURE_EIGENCLASS(tmp);
}
super = RCLASS_SUPER(klass);
while (RB_TYPE_P(super, T_ICLASS)) super = RCLASS_SUPER(super);
RCLASS_SUPER(metaclass) = super ? ENSURE_EIGENCLASS(super) : rb_cClass;
OBJ_INFECT(metaclass, RCLASS_SUPER(metaclass));
return metaclass;
} | false | false | false | false | false | 0 |
prtext(unsigned char *p, int leng) {
int n, c;
int pos = 25;
printf("\"");
for ( n=0; n<leng; n++ ) {
c = *p++;
if (fold && pos >= fold) {
printf ("\\\n\t");
pos = 13; /* tab + \xab + \ */
if (c == ' ' || c == '\t') {
putchar ('\\');
++pos;
}
}
switch (c) {
case '\\':
case '"':
printf ("\\%c", c);
pos += 2;
break;
case '\r':
printf ("\\r");
pos += 2;
break;
case '\n':
printf ("\\n");
pos += 2;
break;
case '\0':
printf ("\\0");
pos += 2;
break;
default:
if (isprint(c)) {
putchar(c);
++pos;
} else {
printf("\\x%02x" , c);
pos += 4;
}
}
}
printf("\"\n");
} | false | false | false | false | false | 0 |
read_restart(FILE *fp)
{
allocate();
if (comm->me == 0) {
fread(&k[1],sizeof(double),atom->ndihedraltypes,fp);
fread(&multiplicity[1],sizeof(int),atom->ndihedraltypes,fp);
fread(&shift[1],sizeof(int),atom->ndihedraltypes,fp);
fread(&weight[1],sizeof(double),atom->ndihedraltypes,fp);
fread(&weightflag,sizeof(int),1,fp);
}
MPI_Bcast(&k[1],atom->ndihedraltypes,MPI_DOUBLE,0,world);
MPI_Bcast(&multiplicity[1],atom->ndihedraltypes,MPI_INT,0,world);
MPI_Bcast(&shift[1],atom->ndihedraltypes,MPI_INT,0,world);
MPI_Bcast(&weight[1],atom->ndihedraltypes,MPI_DOUBLE,0,world);
MPI_Bcast(&weightflag,1,MPI_INT,0,world);
for (int i = 1; i <= atom->ndihedraltypes; i++) {
setflag[i] = 1;
cos_shift[i] = cos(MY_PI*shift[i]/180.0);
sin_shift[i] = sin(MY_PI*shift[i]/180.0);
}
} | false | false | false | false | false | 0 |
get16_and_mask(char *from, uint16_t *to, uint16_t *mask, int base)
{
char *p, *buffer;
int i;
if ( (p = strrchr(from, '/')) != NULL) {
*p = '\0';
i = strtol(p+1, &buffer, base);
if (*buffer != '\0' || i < 0 || i > 65535)
return -1;
*mask = htons((uint16_t)i);
} else
*mask = 65535;
i = strtol(from, &buffer, base);
if (*buffer != '\0' || i < 0 || i > 65535)
return -1;
*to = htons((uint16_t)i);
return 0;
} | false | false | false | false | false | 0 |
get_position (void)
{
GList *tmp;
gint64 position;
gst_element_query_position (GST_ELEMENT (pipeline), GST_FORMAT_TIME,
&position);
tmp = seeks;
GST_LOG ("Current position: %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
while (tmp) {
SeekInfo *seek = tmp->data;
if ((position >= (seek->seeking_position - seek_tol))
&& (position <= (seek->seeking_position + seek_tol))) {
if (!got_async_done) {
GST_INFO ("Still not received ASYNC_DONE, keep going");
return TRUE;
}
got_async_done = FALSE;
GST_INFO ("seeking to: %" GST_TIME_FORMAT,
GST_TIME_ARGS (seek->position));
seeked_position = seek->position;
if (seek_paused) {
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
GST_LOG ("Set state playing");
gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, -1);
GST_LOG ("Done wainting");
}
if (seek_paused_noplay) {
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, -1);
}
fail_unless (gst_element_seek_simple (GST_ELEMENT (pipeline),
GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, seek->position));
if (seek_paused) {
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, -1);
}
seeks = g_list_remove_link (seeks, tmp);
g_slice_free (SeekInfo, seek);
g_list_free (tmp);
break;
}
tmp = tmp->next;
}
/* if seeking paused without playing and we reached the last seek, just play
* till the end */
return TRUE;
} | false | false | false | false | false | 0 |
index_select(struct index_state *state)
{
index_tellexists(state);
/* always print flags */
index_checkflags(state, 1);
if (state->firstnotseen)
prot_printf(state->out, "* OK [UNSEEN %u] Ok\r\n",
state->firstnotseen);
prot_printf(state->out, "* OK [UIDVALIDITY %u] Ok\r\n",
state->mailbox->i.uidvalidity);
prot_printf(state->out, "* OK [UIDNEXT %lu] Ok\r\n",
state->last_uid + 1);
prot_printf(state->out, "* OK [HIGHESTMODSEQ " MODSEQ_FMT "] Ok\r\n",
state->highestmodseq);
prot_printf(state->out, "* OK [URLMECH INTERNAL] Ok\r\n");
} | false | false | false | false | false | 0 |
gridGenWeights(int gridID, double *grid_area, double *grid_wgts)
{
int i, nvals, gridsize, gridtype;
int status = 0;
int *grid_mask = NULL;
double total_area;
gridtype = gridInqType(gridID);
gridsize = gridInqSize(gridID);
if ( gridtype == GRID_GME )
{
gridID = gridToUnstructured(gridID, 1);
grid_mask = (int *) malloc(gridsize*sizeof(int));
gridInqMaskGME(gridID, grid_mask);
}
total_area = 0;
nvals = 0;
for ( i = 0; i < gridsize; i++ )
{
if ( grid_mask )
if ( grid_mask[i] == 0 ) continue;
total_area += grid_area[i];
nvals++;
}
if ( cdoVerbose ) cdoPrint("Total area = %g steradians", total_area);
for ( i = 0; i < gridsize; i++ )
{
if ( grid_mask )
if ( grid_mask[i] == 0 )
{
grid_wgts[i] = 0;
continue;
}
grid_wgts[i] = grid_area[i] / total_area;
}
if ( grid_mask ) free(grid_mask);
return (status);
} | false | false | false | false | false | 0 |
kget_chap(uint64_t transport_handle, uint32_t host_no,
uint16_t chap_tbl_idx, uint32_t num_entries,
char *chap_buf, uint32_t *valid_chap_entries)
{
int rc = 0;
int ev_size;
struct iscsi_uevent ev;
struct iovec iov[2];
char nlm_ev[NLMSG_SPACE(sizeof(struct iscsi_uevent))];
struct nlmsghdr *nlh;
memset(&ev, 0, sizeof(struct iscsi_uevent));
ev.type = ISCSI_UEVENT_GET_CHAP;
ev.transport_handle = transport_handle;
ev.u.get_chap.host_no = host_no;
ev.u.get_chap.chap_tbl_idx = chap_tbl_idx;
ev.u.get_chap.num_entries = num_entries;
iov[1].iov_base = &ev;
iov[1].iov_len = sizeof(ev);
rc = __kipc_call(iov, 2);
if (rc < 0)
return rc;
if ((rc = nl_read(ctrl_fd, nlm_ev,
NLMSG_SPACE(sizeof(struct iscsi_uevent)),
MSG_PEEK)) < 0) {
log_error("can not read nlm_ev, error %d", rc);
return rc;
}
nlh = (struct nlmsghdr *)nlm_ev;
ev_size = nlh->nlmsg_len - NLMSG_ALIGN(sizeof(struct nlmsghdr));
if ((rc = nlpayload_read(ctrl_fd, (void *)chap_buf, ev_size, 0)) < 0) {
log_error("can not read from NL socket, error %d", rc);
return rc;
}
*valid_chap_entries = ev.u.get_chap.num_entries;
return rc;
} | false | false | false | false | false | 0 |
DrawAndBlit(void)
{
// Change the view size if needed
if (setsizeneeded)
{
R_ExecuteSetViewSize();
}
// Do buffered drawing
switch (gamestate)
{
case GS_LEVEL:
if (!gametic)
{
break;
}
if (automapactive)
{
AM_Drawer();
}
else
{
R_RenderPlayerView(&players[displayplayer]);
}
CT_Drawer();
UpdateState |= I_FULLVIEW;
SB_Drawer();
break;
case GS_INTERMISSION:
IN_Drawer();
break;
case GS_FINALE:
F_Drawer();
break;
case GS_DEMOSCREEN:
PageDrawer();
break;
}
if (testcontrols)
{
V_DrawMouseSpeedBox(testcontrols_mousespeed);
}
if (paused && !MenuActive && !askforquit)
{
if (!netgame)
{
V_DrawPatch(160, viewwindowy + 5, W_CacheLumpName("PAUSED",
PU_CACHE));
}
else
{
V_DrawPatch(160, 70, W_CacheLumpName("PAUSED", PU_CACHE));
}
}
// Draw current message
DrawMessage();
// Draw Menu
MN_Drawer();
// Send out any new accumulation
NetUpdate();
// Flush buffered stuff to screen
I_FinishUpdate();
} | false | false | false | false | false | 0 |
SetOptionValue(const char* optionName,
const char* name,
const char* value,
bool createMissingArgument)
{
OptionVector::iterator it = m_OptionVector.begin();
while(it != m_OptionVector.end())
{
if((*it).name == optionName)
{
(*it).userDefined = true;
METAIO_STL::vector<Field> & fields = (*it).fields;
METAIO_STL::vector<Field>::iterator itField = fields.begin();
while(itField != fields.end())
{
if((*itField).name == name)
{
(*itField).userDefined = true;
(*itField).value = value;
return true;
}
itField++;
}
}
it++;
}
if(createMissingArgument)
{
Option option;
option.tag = "";
option.longtag = optionName;
option.name = optionName;
option.required = false;
option.description = "";
option.userDefined = true;
option.complete = false;
Field field;
field.name = name;
field.externaldata = DATA_NONE;
field.type = STRING;
field.value = value;
field.userDefined = true;
field.required = false;
field.rangeMin = "";
field.rangeMax = "";
option.fields.push_back(field);
m_OptionVector.push_back(option);
}
return false;
} | false | false | false | false | false | 0 |
gth_browser_activate_action_catalog_remove (GtkAction *action,
GthBrowser *browser)
{
GthFileData *file_data;
GSettings *settings;
file_data = gth_browser_get_folder_popup_file_data (browser);
settings = g_settings_new (GTHUMB_MESSAGES_SCHEMA);
if (g_settings_get_boolean (settings, PREF_MSG_CONFIRM_DELETION)) {
char *prompt;
GtkWidget *d;
prompt = g_strdup_printf (_("Are you sure you want to remove \"%s\"?"), g_file_info_get_display_name (file_data->info));
d = _gtk_message_dialog_new (GTK_WINDOW (browser),
GTK_DIALOG_MODAL,
GTK_STOCK_DIALOG_QUESTION,
prompt,
NULL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_REMOVE, GTK_RESPONSE_YES,
NULL);
g_signal_connect (d, "response", G_CALLBACK (remove_catalog_response_cb), file_data);
gtk_widget_show (d);
g_free (prompt);
}
else {
remove_catalog (GTK_WINDOW (browser), file_data);
g_object_unref (file_data);
}
g_object_unref (settings);
} | false | false | false | false | false | 0 |
extractItem(const char *filesPath, const char *outName, int32_t idx, char outType) {
char filename[1024];
UDataSwapper *ds;
FILE *file;
Item *pItem;
int32_t fileLength;
uint8_t itemCharset, outCharset;
UBool itemIsBigEndian, outIsBigEndian;
if(idx<0 || itemCount<=idx) {
return;
}
pItem=items+idx;
// swap the data to the outType
// outType==0: don't swap
if(outType!=0 && pItem->type!=outType) {
// open the swapper
UErrorCode errorCode=U_ZERO_ERROR;
makeTypeProps(pItem->type, itemCharset, itemIsBigEndian);
makeTypeProps(outType, outCharset, outIsBigEndian);
ds=udata_openSwapper(itemIsBigEndian, itemCharset, outIsBigEndian, outCharset, &errorCode);
if(U_FAILURE(errorCode)) {
fprintf(stderr, "icupkg: udata_openSwapper(item %ld) failed - %s\n",
(long)idx, u_errorName(errorCode));
exit(errorCode);
}
ds->printError=printPackageError;
ds->printErrorContext=stderr;
// swap the item from its platform properties to the desired ones
udata_swap(ds, pItem->data, pItem->length, pItem->data, &errorCode);
if(U_FAILURE(errorCode)) {
fprintf(stderr, "icupkg: udata_swap(item %ld) failed - %s\n", (long)idx, u_errorName(errorCode));
exit(errorCode);
}
udata_closeSwapper(ds);
}
// create the file and write its contents
makeFullFilenameAndDirs(filesPath, outName, filename, (int32_t)sizeof(filename));
file=fopen(filename, "wb");
if(file==NULL) {
fprintf(stderr, "icupkg: unable to create file \"%s\"\n", filename);
exit(U_FILE_ACCESS_ERROR);
}
fileLength=(int32_t)fwrite(pItem->data, 1, pItem->length, file);
if(ferror(file) || fileLength!=pItem->length) {
fprintf(stderr, "icupkg: unable to write complete file \"%s\"\n", filename);
exit(U_FILE_ACCESS_ERROR);
}
fclose(file);
} | false | false | false | false | true | 1 |
make_parsing_routine(int32 routine_address)
{
/* This routine is used only in grammar version 1: the corresponding
table is left empty in GV2. */
int l;
for (l=0; l<no_grammar_token_routines; l++)
if (grammar_token_routine[l] == routine_address)
return l;
grammar_token_routine[l] = routine_address;
return(no_grammar_token_routines++);
} | false | false | false | false | false | 0 |
__print_p2p_messages(FILE*stream)
{
int i;
__print_p2p_message_header(stream);
for(i=0;i<NB_TRACES; i++) {
/* reduce each trace counter */
p_eztrace_container p_cont = GET_PROCESS_CONTAINER(i);
__print_p2p_messages_recurse(stream, 0, p_cont);
}
} | false | false | false | false | false | 0 |
vacm_context_handler(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
subtree_context_cache *context_ptr;
for(; requests; requests = requests->next) {
netsnmp_variable_list *var = requests->requestvb;
if (requests->processed != 0)
continue;
context_ptr = (subtree_context_cache *)
netsnmp_extract_iterator_context(requests);
if (context_ptr == NULL) {
snmp_log(LOG_ERR,
"vacm_context_handler called without data\n");
continue;
}
switch (reqinfo->mode) {
case MODE_GET:
/*
* if here we should have a context_ptr passed in already
*/
/*
* only one column should ever reach us, so don't check it
*/
snmp_set_var_typed_value(var, ASN_OCTET_STR,
context_ptr->context_name,
strlen(context_ptr->context_name));
break;
default:
/*
* We should never get here, getnext already have been
* handled by the table_iterator and we're read_only
*/
snmp_log(LOG_ERR,
"vacm_context table accessed as mode=%d. We're improperly registered!",
reqinfo->mode);
break;
}
}
return SNMP_ERR_NOERROR;
} | false | false | false | false | false | 0 |
xml_open_doc(gchar * xml_filename, FILE * study_file,
guint64 location, guint64 size,
gchar ** perror_buf) {
xmlDocPtr doc;
gchar * xml_buffer;
long location_long;
size_t size_size;
size_t bytes_read;
if (study_file == NULL) { /* directory format */
if ((doc = xmlParseFile(xml_filename)) == NULL) {
amitk_append_str_with_newline(perror_buf,_("Couldn't Parse AMIDE xml file %s"),xml_filename);
return NULL;
}
} else { /* flat file format */
/* check for file size problems */
if (!xml_check_file_32bit_okay(location)) {
g_warning(_("File to large to read on 32bit platform."));
return NULL;
}
location_long = location;
if (!xml_check_file_32bit_okay(size)) {
g_warning(_("File to large to read on 32bit platform."));
return NULL;
}
size_size = size;
xml_buffer = g_try_new(gchar, size_size);
g_return_val_if_fail(xml_buffer != NULL, NULL);
if (fseek(study_file, location_long,SEEK_SET) != 0) {
amitk_append_str_with_newline(perror_buf, _("Could not seek to location %lx in file."), location_long);
return NULL;
}
bytes_read = fread(xml_buffer, sizeof(gchar), size_size, study_file);
if (bytes_read != size_size) {
amitk_append_str_with_newline(perror_buf, _("Only read %x bytes from file, expected %x"), bytes_read, size_size);
return NULL;
}
/* and actually process the xml */
doc = xmlParseMemory(xml_buffer, size_size);
g_free(xml_buffer);
}
return doc;
} | 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.