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 |
|---|---|---|---|---|---|---|
init_key(uint8_t key[34], const string& key_file)
{
if ( key_file.empty() )
read_key(key, "/dev/random");
else
{
if ( file_exists(key_file.c_str()) )
read_key(key, key_file.c_str());
else
{
printf("Generating key...");
read_key(key, "/dev/random");
write_key(key, key_file.c_str());
printf(" done.\n");
}
}
} | false | false | false | false | false | 0 |
write(const char *data, unsigned int size)
{
int n;
/*
printf("WRITE(%3d): ", size);
for (int i = 0; i < size; i++)
printf("0x%x %c", data[i], data[i]);
printf("\n");
*/
if (myPort >= 0)
{
n = ::write(myPort, data, size);
if (n == -1)
{
if (errno == EAGAIN) /* try it again, for USB/serial */
{
usleep(10);
n = ::write(myPort, data, size);
if (n >= 0)
return n;
}
ArLog::log(ArLog::Terse, "ArSerialConnection::write: Error on writing.");
perror("ArSerialConnection::write:");
}
return n;
}
ArLog::log(ArLog::Terse, "ArSerialConnection::write: Connection invalid.");
return -1;
} | false | false | false | false | false | 0 |
storeCleanupDoubleCheck(StoreEntry * e)
{
SwapDir *SD = &Config.cacheSwap.swapDirs[e->swap_dirn];
if (SD->dblcheck)
return (SD->dblcheck(SD, e));
return 0;
} | false | false | false | false | false | 0 |
AddFeatures(
const Word* leftWord, const Word* rightWord, const FactorList& factors, const string& side,
ScoreComponentCollection* scores) const {
for (size_t i = 0; i < factors.size(); ++i) {
ostringstream name;
name << side << ":";
name << factors[i];
name << ":";
if (leftWord) {
name << leftWord->GetFactor(factors[i])->GetString();
} else {
name << BOS_;
}
name << ":";
if (rightWord) {
name << rightWord->GetFactor(factors[i])->GetString();
} else {
name << EOS_;
}
scores->PlusEquals(this,name.str(),1);
}
} | false | false | false | false | false | 0 |
set_txidle(MGSLPC_INFO * info, int idle_mode)
{
unsigned long flags;
if (debug_level >= DEBUG_LEVEL_INFO)
printk("set_txidle(%s,%d)\n", info->device_name, idle_mode);
spin_lock_irqsave(&info->lock, flags);
info->idle_mode = idle_mode;
tx_set_idle(info);
spin_unlock_irqrestore(&info->lock, flags);
return 0;
} | false | false | false | false | false | 0 |
avail_expr_eq (const void *p1, const void *p2)
{
gimple stmt1 = ((const struct expr_hash_elt *)p1)->stmt;
const struct hashable_expr *expr1 = &((const struct expr_hash_elt *)p1)->expr;
const struct expr_hash_elt *stamp1 = ((const struct expr_hash_elt *)p1)->stamp;
gimple stmt2 = ((const struct expr_hash_elt *)p2)->stmt;
const struct hashable_expr *expr2 = &((const struct expr_hash_elt *)p2)->expr;
const struct expr_hash_elt *stamp2 = ((const struct expr_hash_elt *)p2)->stamp;
/* This case should apply only when removing entries from the table. */
if (stamp1 == stamp2)
return true;
/* FIXME tuples:
We add stmts to a hash table and them modify them. To detect the case
that we modify a stmt and then search for it, we assume that the hash
is always modified by that change.
We have to fully check why this doesn't happen on trunk or rewrite
this in a more reliable (and easier to understand) way. */
if (((const struct expr_hash_elt *)p1)->hash
!= ((const struct expr_hash_elt *)p2)->hash)
return false;
/* In case of a collision, both RHS have to be identical and have the
same VUSE operands. */
if (hashable_expr_equal_p (expr1, expr2)
&& types_compatible_p (expr1->type, expr2->type))
{
/* Note that STMT1 and/or STMT2 may be NULL. */
return ((stmt1 ? gimple_vuse (stmt1) : NULL_TREE)
== (stmt2 ? gimple_vuse (stmt2) : NULL_TREE));
}
return false;
} | false | false | false | false | false | 0 |
bcm_sysport_suspend(struct device *d)
{
struct net_device *dev = dev_get_drvdata(d);
struct bcm_sysport_priv *priv = netdev_priv(dev);
unsigned int i;
int ret = 0;
u32 reg;
if (!netif_running(dev))
return 0;
bcm_sysport_netif_stop(dev);
phy_suspend(priv->phydev);
netif_device_detach(dev);
/* Disable UniMAC RX */
umac_enable_set(priv, CMD_RX_EN, 0);
ret = rdma_enable_set(priv, 0);
if (ret) {
netdev_err(dev, "RDMA timeout!\n");
return ret;
}
/* Disable RXCHK if enabled */
if (priv->rx_chk_en) {
reg = rxchk_readl(priv, RXCHK_CONTROL);
reg &= ~RXCHK_EN;
rxchk_writel(priv, reg, RXCHK_CONTROL);
}
/* Flush RX pipe */
if (!priv->wolopts)
topctrl_writel(priv, RX_FLUSH, RX_FLUSH_CNTL);
ret = tdma_enable_set(priv, 0);
if (ret) {
netdev_err(dev, "TDMA timeout!\n");
return ret;
}
/* Wait for a packet boundary */
usleep_range(2000, 3000);
umac_enable_set(priv, CMD_TX_EN, 0);
topctrl_writel(priv, TX_FLUSH, TX_FLUSH_CNTL);
/* Free RX/TX rings SW structures */
for (i = 0; i < dev->num_tx_queues; i++)
bcm_sysport_fini_tx_ring(priv, i);
bcm_sysport_fini_rx_ring(priv);
/* Get prepared for Wake-on-LAN */
if (device_may_wakeup(d) && priv->wolopts)
ret = bcm_sysport_suspend_to_wol(priv);
return ret;
} | false | false | false | false | false | 0 |
push_byte(int8_t b)
{
int16_t n = b;
uint16_t value = (n & 0xffff);
CHECK_STACK();
fprintf(out, " li r%d, 0x%02x\n", REG_STACK(reg), value);
reg++;
return 0;
} | false | false | false | false | false | 0 |
CalcConUI(Const_table *lCon, Const_table *rCon, qr_operator ope,
int invertl, int invertr)
{
unsigned int l=0, r=0;
l = const_table_unsigned_value(lCon);
r = const_table_unsigned_value(rCon);
switch(ope){
case OPE_ADD:
if(!(invertl) && !(invertr)) return l + r;
if(!(invertl) && invertr) return l - r;
if(invertl && !(invertr)) return r - l;
if(invertl && invertr) return -r - l;
case OPE_SUB:
if(!(invertl) && !(invertr)) return l - r;
if(!(invertl) && invertr) return l + r;
if(invertl && !(invertr)) return -l - r;
if(invertl && invertr) return r - l;
case OPE_MUL:
if(!(invertl) && !(invertr)) return l * r;
if(!(invertl) && invertr) return l / r;
if(invertl && !(invertr)) return r / l;
if(invertl && invertr) return 1/(l*r);
case OPE_DIV:
return l / r;
default:
perror("Don't match operator!\n");
exit(-1);
}
} | false | false | false | false | false | 0 |
gst_rtsp_media_seek (GstRTSPMedia * media, GstRTSPTimeRange * range)
{
GstSeekFlags flags;
gboolean res;
gint64 start, stop;
GstSeekType start_type, stop_type;
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), FALSE);
g_return_val_if_fail (range != NULL, FALSE);
if (range->unit != GST_RTSP_RANGE_NPT)
goto not_supported;
/* depends on the current playing state of the pipeline. We might need to
* queue this until we get EOS. */
flags = GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_KEY_UNIT;
start_type = stop_type = GST_SEEK_TYPE_NONE;
switch (range->min.type) {
case GST_RTSP_TIME_NOW:
start = -1;
break;
case GST_RTSP_TIME_SECONDS:
/* only seek when something changed */
if (media->range.min.seconds == range->min.seconds) {
start = -1;
} else {
start = range->min.seconds * GST_SECOND;
start_type = GST_SEEK_TYPE_SET;
}
break;
case GST_RTSP_TIME_END:
default:
goto weird_type;
}
switch (range->max.type) {
case GST_RTSP_TIME_SECONDS:
/* only seek when something changed */
if (media->range.max.seconds == range->max.seconds) {
stop = -1;
} else {
stop = range->max.seconds * GST_SECOND;
stop_type = GST_SEEK_TYPE_SET;
}
break;
case GST_RTSP_TIME_END:
stop = -1;
stop_type = GST_SEEK_TYPE_SET;
break;
case GST_RTSP_TIME_NOW:
default:
goto weird_type;
}
if (start != -1 || stop != -1) {
GST_INFO ("seeking to %" GST_TIME_FORMAT " - %" GST_TIME_FORMAT,
GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
res = gst_element_seek (media->pipeline, 1.0, GST_FORMAT_TIME,
flags, start_type, start, stop_type, stop);
/* and block for the seek to complete */
GST_INFO ("done seeking %d", res);
gst_element_get_state (media->pipeline, NULL, NULL, -1);
GST_INFO ("prerolled again");
collect_media_stats (media);
} else {
GST_INFO ("no seek needed");
res = TRUE;
}
return res;
/* ERRORS */
not_supported:
{
GST_WARNING ("seek unit %d not supported", range->unit);
return FALSE;
}
weird_type:
{
GST_WARNING ("weird range type %d not supported", range->min.type);
return FALSE;
}
} | false | false | false | false | false | 0 |
ReadPersistent(const int fd, void *buf, const size_t count) {
CHECK_GE(fd, 0);
char *buf0 = reinterpret_cast<char *>(buf);
ssize_t num_bytes = 0;
while (num_bytes < count) {
ssize_t len;
NO_INTR(len = read(fd, buf0 + num_bytes, count - num_bytes));
if (len < 0) { // There was an error other than EINTR.
return -1;
}
if (len == 0) { // Reached EOF.
break;
}
num_bytes += len;
}
CHECK(num_bytes <= count);
return num_bytes;
} | false | false | false | false | false | 0 |
ensureParameterArrayAllocated(Parameter *currentArray) {
if (currentArray == NULL)
currentArray = allocateParameterArray(MAXENTITY);
else
clearParameterArray(currentArray);
return currentArray;
} | false | false | false | false | false | 0 |
H5Zregister(const void *cls)
{
const H5Z_class2_t *cls_real = (const H5Z_class2_t *) cls; /* "Real" class pointer */
H5Z_class2_t cls_new; /* Translated class struct */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "*x", cls);
/* Check args */
if (cls_real==NULL)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter class")
/* Check H5Z_class_t version number; this is where a function to convert
* from an outdated version should be called.
*
* If the version number is invalid, we assume that the target of cls is the
* old style "H5Z_class1_t" structure, which did not contain a version
* field. In this structure, the first field is the id. Since both version
* and id are integers they will have the same value, and since id must be
* at least 256, there should be no overlap and the version of the struct
* can be determined by the value of the first field.
*/
if(cls_real->version != H5Z_CLASS_T_VERS) {
#ifndef H5_NO_DEPRECATED_SYMBOLS
/* Assume it is an old "H5Z_class1_t" instead */
const H5Z_class1_t *cls_old = (const H5Z_class1_t *) cls;
/* Translate to new H5Z_class2_t */
cls_new.version = H5Z_CLASS_T_VERS;
cls_new.id = cls_old->id;
cls_new.encoder_present = 1;
cls_new.decoder_present = 1;
cls_new.name = cls_old->name;
cls_new.can_apply = cls_old->can_apply;
cls_new.set_local = cls_old->set_local;
cls_new.filter = cls_old->filter;
/* Set cls_real to point to the translated structure */
cls_real = &cls_new;
#else /* H5_NO_DEPRECATED_SYMBOLS */
/* Deprecated symbols not allowed, throw an error */
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5Z_class_t version number");
#endif /* H5_NO_DEPRECATED_SYMBOLS */
} /* end if */
if (cls_real->id<0 || cls_real->id>H5Z_FILTER_MAX)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number")
if (cls_real->id<H5Z_FILTER_RESERVED)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters")
if (cls_real->filter==NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no filter function specified")
/* Do it */
if (H5Z_register (cls_real)<0)
HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
done:
FUNC_LEAVE_API(ret_value)
} | false | false | false | false | false | 0 |
knh_write_mline(CTX ctx, kOutputStream *w, kmethodn_t mn, kline_t uline)
{
kuri_t uri = ULINE_uri(uline);
kuintptr_t line = ULINE_line(uline);
if(uline != 0 && uri != URI_unknown && line != 0) {
if(mn == MN_) {
knh_write_cline(ctx, w, FILENAME__(uri), line);
}
else {
knh_putc(ctx, w, '(');
knh_write_mn(ctx, w, mn);
knh_putc(ctx, w, ':');
knh_write_dfmt(ctx, w, K_INTPTR_FMT, line);
knh_putc(ctx, w, ')');
knh_putc(ctx, w, ' ');
}
}
} | false | false | false | false | false | 0 |
setIdColAcol() {
// Set flavours.
setId( id1, id2, id3Sav, id4Sav);
// Set color flow (random for now)
double R = rndmPtr->flat();
if (R < 0.5) setColAcol( 1, 2, 2, 3, 1, 0, 0, 3);
else setColAcol( 1, 2, 3, 1, 3, 0, 0, 2);
} | false | false | false | false | false | 0 |
tree_view_button_press_event (GtkTreeView *view,
GdkEventButton *event,
GgdDoctypeSelector *selector)
{
gboolean handled = FALSE;
/* Ignore double-clicks and triple-clicks */
if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
GtkTreePath *path;
/* select row under the cursor before poping the menu up */
if (gtk_tree_view_get_path_at_pos (view, (gint)event->x, (gint)event->y,
&path, NULL, NULL, NULL)) {
gtk_tree_selection_select_path (gtk_tree_view_get_selection (view), path);
gtk_tree_view_scroll_to_cell (view, path, NULL, FALSE, 0.0, 0.0);
gtk_tree_path_free (path);
}
do_popup_menu (selector, event);
handled = TRUE;
}
return handled;
} | false | false | false | false | false | 0 |
CheckMissileImpact(mobj_t * mobj)
{
int i;
if (!numspechit || !(mobj->flags & MF_MISSILE) || !mobj->target)
{
return;
}
if (!mobj->target->player)
{
return;
}
for (i = numspechit - 1; i >= 0; i--)
{
P_ShootSpecialLine(mobj->target, spechit[i]);
}
} | false | false | false | false | false | 0 |
ferode_1_29(l_uint32 *datad,
l_int32 w,
l_int32 h,
l_int32 wpld,
l_uint32 *datas,
l_int32 wpls)
{
l_int32 i;
register l_int32 j, pwpls;
register l_uint32 *sptr, *dptr;
l_int32 wpls2, wpls3;
wpls2 = 2 * wpls;
wpls3 = 3 * wpls;
pwpls = (l_uint32)(w + 31) / 32; /* proper wpl of src */
for (i = 0; i < h; i++) {
sptr = datas + i * wpls;
dptr = datad + i * wpld;
for (j = 0; j < pwpls; j++, sptr++, dptr++) {
*dptr = (*(sptr - wpls3)) &
(*(sptr - wpls2)) &
(*(sptr - wpls)) &
(*sptr) &
(*(sptr + wpls)) &
(*(sptr + wpls2));
}
}
} | false | false | false | false | false | 0 |
dump_type (tree t, int flags)
{
if (t == NULL_TREE)
return;
if (TYPE_PTRMEMFUNC_P (t))
goto offset_type;
switch (TREE_CODE (t))
{
case UNKNOWN_TYPE:
pp_identifier (cxx_pp, "<unknown type>");
break;
case TREE_LIST:
/* A list of function parms. */
dump_parameters (t, flags);
break;
case IDENTIFIER_NODE:
pp_tree_identifier (cxx_pp, t);
break;
case TREE_VEC:
dump_type (BINFO_TYPE (t), flags);
break;
case RECORD_TYPE:
case UNION_TYPE:
case ENUMERAL_TYPE:
dump_aggr_type (t, flags);
break;
case TYPE_DECL:
if (flags & TFF_CHASE_TYPEDEF)
{
dump_type (DECL_ORIGINAL_TYPE (t)
? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), flags);
break;
}
/* Else fall through. */
case TEMPLATE_DECL:
case NAMESPACE_DECL:
dump_decl (t, flags & ~TFF_DECL_SPECIFIERS);
break;
case INTEGER_TYPE:
case REAL_TYPE:
case VOID_TYPE:
case BOOLEAN_TYPE:
case COMPLEX_TYPE:
case VECTOR_TYPE:
pp_base (cxx_pp)->padding = pp_none;
pp_type_specifier_seq (cxx_pp, t);
break;
case TEMPLATE_TEMPLATE_PARM:
/* For parameters inside template signature. */
if (TYPE_IDENTIFIER (t))
pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
else
pp_cxx_canonical_template_parameter (cxx_pp, t);
break;
case BOUND_TEMPLATE_TEMPLATE_PARM:
{
tree args = TYPE_TI_ARGS (t);
dump_qualifiers (t, after);
pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
pp_template_argument_list_start (cxx_pp);
dump_template_argument_list (args, flags);
pp_template_argument_list_end (cxx_pp);
}
break;
case TEMPLATE_TYPE_PARM:
dump_qualifiers (t, after);
if (TYPE_IDENTIFIER (t))
pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
else
pp_cxx_canonical_template_parameter
(cxx_pp, TEMPLATE_TYPE_PARM_INDEX (t));
break;
/* This is not always necessary for pointers and such, but doing this
reduces code size. */
case ARRAY_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
case OFFSET_TYPE:
offset_type:
case FUNCTION_TYPE:
case METHOD_TYPE:
{
dump_type_prefix (t, flags);
dump_type_suffix (t, flags);
break;
}
case TYPENAME_TYPE:
dump_qualifiers (t, after);
pp_string (cxx_pp, "typename ");
dump_typename (t, flags);
break;
case UNBOUND_CLASS_TEMPLATE:
dump_type (TYPE_CONTEXT (t), flags);
pp_colon_colon (cxx_pp);
pp_identifier (cxx_pp, "template ");
dump_type (DECL_NAME (TYPE_NAME (t)), flags);
break;
case TYPEOF_TYPE:
pp_string (cxx_pp, "__typeof (");
dump_expr (TYPE_FIELDS (t), flags & ~TFF_EXPR_IN_PARENS);
pp_right_paren (cxx_pp);
break;
default:
pp_unsupported_tree (cxx_pp, t);
/* Fall through to error. */
case ERROR_MARK:
pp_identifier (cxx_pp, "<type error>");
break;
}
} | false | false | false | false | false | 0 |
mailimap_date_day_fixed_send(mailstream * fd, int day)
{
int r;
if (day < 10) {
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_number_send(fd, day);
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
}
else
return mailimap_number_send(fd, day);
} | false | false | false | false | false | 0 |
lzma_upack_esi_54(struct lzmastate *p, uint32_t old_eax, uint32_t *old_ecx, char **old_edx, uint32_t *retval, char *bs, uint32_t bl)
{
uint32_t ret, loc_eax = old_eax;
*old_ecx = ((*old_ecx)&0xffffff00)|8;
ret = lzma_upack_esi_00 (p, *old_edx, bs, bl);
*old_edx = ((*old_edx) + 4);
loc_eax = (loc_eax&0xffffff00)|1;
if (ret)
{
ret = lzma_upack_esi_00 (p, *old_edx, bs, bl);
loc_eax |= 8; /* mov al, 9 */
if (ret)
{
*old_ecx <<= 5;
loc_eax = 0x11; /* mov al, 11 */
}
}
ret = loc_eax;
if (lzma_upack_esi_50(p, 1, *old_ecx, old_edx, *old_edx + (loc_eax << 2), &loc_eax, bs, bl) == 0xffffffff)
return 0xffffffff;
*retval = ret + loc_eax;
return 0;
} | false | false | false | false | false | 0 |
dce_v8_0_audio_init(struct amdgpu_device *adev)
{
int i;
if (!amdgpu_audio)
return 0;
adev->mode_info.audio.enabled = true;
if (adev->asic_type == CHIP_KAVERI) /* KV: 4 streams, 7 endpoints */
adev->mode_info.audio.num_pins = 7;
else if ((adev->asic_type == CHIP_KABINI) ||
(adev->asic_type == CHIP_MULLINS)) /* KB/ML: 2 streams, 3 endpoints */
adev->mode_info.audio.num_pins = 3;
else if ((adev->asic_type == CHIP_BONAIRE) ||
(adev->asic_type == CHIP_HAWAII))/* BN/HW: 6 streams, 7 endpoints */
adev->mode_info.audio.num_pins = 7;
else
adev->mode_info.audio.num_pins = 3;
for (i = 0; i < adev->mode_info.audio.num_pins; i++) {
adev->mode_info.audio.pin[i].channels = -1;
adev->mode_info.audio.pin[i].rate = -1;
adev->mode_info.audio.pin[i].bits_per_sample = -1;
adev->mode_info.audio.pin[i].status_bits = 0;
adev->mode_info.audio.pin[i].category_code = 0;
adev->mode_info.audio.pin[i].connected = false;
adev->mode_info.audio.pin[i].offset = pin_offsets[i];
adev->mode_info.audio.pin[i].id = i;
/* disable audio. it will be set up later */
/* XXX remove once we switch to ip funcs */
dce_v8_0_audio_enable(adev, &adev->mode_info.audio.pin[i], false);
}
return 0;
} | false | false | false | false | false | 0 |
gtkaml_namespace_visitor_get_using_directives (GtkamlNamespaceVisitor* self) {
ValaList* result = NULL;
ValaList* _tmp0_;
ValaList* _tmp1_;
g_return_val_if_fail (self != NULL, NULL);
_tmp0_ = self->priv->using_directives;
_tmp1_ = _vala_iterable_ref0 (_tmp0_);
result = _tmp1_;
return result;
} | false | false | false | false | false | 0 |
query_1_0_0(lam_ssi_t *coll, MPI_Comm comm, int *priority)
{
const lam_ssi_coll_actions_1_0_0_t *actions100;
lam_ssi_coll_1_0_0_t *coll100 = (lam_ssi_coll_1_0_0_t *) coll;
actions100 = coll100->lsc_query(comm, priority);
if (actions100 != NULL)
convert_actions_1_0_0_to_1_1_0(actions100, &actions110);
return &actions110;
} | false | false | false | false | false | 0 |
_upload_file (SwServiceSmugmug *self,
MediaType upload_type,
const gchar *filename,
GHashTable *extra_fields,
RestProxyCallUploadCallback upload_cb,
GError **error)
{
SwServiceSmugmugPrivate *priv = self->priv;
RestProxyCall *call = NULL;
RestParam *param;
gchar *basename = NULL;
gchar *content_type = NULL;
gchar *bytecount = NULL;
gchar *collection_id = NULL;
GMappedFile *map = NULL;
gint opid = -1;
GChecksum *checksum = NULL;
g_return_val_if_fail (priv->upload_proxy != NULL, -1);
/* Open the file */
map = g_mapped_file_new (filename, FALSE, error);
if (*error != NULL) {
g_warning ("Error opening file %s: %s", filename, (*error)->message);
goto OUT;
}
/* Get the file information */
basename = g_path_get_basename (filename);
content_type = g_content_type_guess (
filename,
(const guchar*) g_mapped_file_get_contents (map),
g_mapped_file_get_length (map),
NULL);
call = rest_proxy_new_call (priv->upload_proxy);
bytecount = g_strdup_printf ("%lud",
(guint64) g_mapped_file_get_length (map));
checksum = g_checksum_new (G_CHECKSUM_MD5);
g_checksum_update (checksum, (guchar *) g_mapped_file_get_contents (map),
g_mapped_file_get_length (map));
rest_proxy_call_add_param (call, "MD5Sum", g_checksum_get_string (checksum));
rest_proxy_call_add_param (call, "ResponseType", "REST");
rest_proxy_call_add_param (call, "ByteCount", bytecount);
collection_id = g_hash_table_lookup (extra_fields, "collection");
if (collection_id == NULL) {
g_set_error (error, SW_SERVICE_ERROR, SW_SERVICE_ERROR_NOT_SUPPORTED,
"must provide a collection ID");
goto OUT;
} else if (!g_str_has_prefix (collection_id, ALBUM_PREFIX) ||
g_strstr_len (collection_id, -1, "_") == NULL) {
g_set_error (error, SW_SERVICE_ERROR, SW_SERVICE_ERROR_NOT_SUPPORTED,
"collection (%s) must be in the format: %salbumkey_albumid",
collection_id, ALBUM_PREFIX);
goto OUT;
} else {
rest_proxy_call_add_param (call, "AlbumID",
g_strstr_len (collection_id, -1, "_") + 1);
}
sw_service_map_params (upload_params, extra_fields,
(SwServiceSetParamFunc) rest_proxy_call_add_param,
call);
g_mapped_file_ref (map);
param = rest_param_new_with_owner (basename,
g_mapped_file_get_contents (map),
g_mapped_file_get_length (map),
content_type,
basename,
map,
(GDestroyNotify)g_mapped_file_unref);
rest_proxy_call_add_param_full (call, param);
rest_proxy_call_set_method (call, "POST");
opid = sw_next_opid ();
SW_DEBUG (SMUGMUG, "Uploading %s (%s)", basename, bytecount);
rest_proxy_call_upload (call,
upload_cb,
G_OBJECT (self),
GINT_TO_POINTER (opid),
NULL);
OUT:
g_free (basename);
g_free (content_type);
g_free (bytecount);
if (checksum != NULL)
g_checksum_free (checksum);
if (call != NULL)
g_object_unref (call);
if (map != NULL)
g_mapped_file_unref (map);
return opid;
} | false | false | false | false | false | 0 |
plOptUsage(void)
{
if (usage == NULL)
fprintf(stderr, "\nUsage:\n %s [options]\n", program);
else
fputs(usage, stderr);
Syntax();
fprintf(stderr, "\n\nType %s -h for a full description.\n\n",
program);
} | false | false | false | false | false | 0 |
bogons_load(FILE *f)
{
char line[1024];
uint32 ip, netmask;
int linenum = 0;
int bits;
iprange_err_t error;
filestat_t buf;
bogons_db = iprange_new();
if (-1 == fstat(fileno(f), &buf)) {
g_warning("cannot stat %s: %m", bogons_file);
} else {
bogons_mtime = buf.st_mtime;
}
while (fgets(line, sizeof line, f)) {
linenum++;
/*
* Remove all trailing spaces in string.
* Otherwise, lines which contain only spaces would cause a warning.
*/
if (!file_line_chomp_tail(line, sizeof line, NULL)) {
g_warning("%s, line %d: too long a line", bogons_file, linenum);
break;
}
if (file_line_is_skipable(line))
continue;
if (!string_to_ip_and_mask(line, &ip, &netmask)) {
g_warning("%s, line %d: invalid IP or netmask \"%s\"",
bogons_file, linenum, line);
continue;
}
bits = netmask_to_cidr(netmask);
error = iprange_add_cidr(bogons_db, ip, bits, 1);
switch (error) {
case IPR_ERR_OK:
break;
/* FALL THROUGH */
default:
g_warning("%s, line %d: rejected entry \"%s\" (%s/%d): %s",
bogons_file, linenum, line, ip_to_string(ip), bits,
iprange_strerror(error));
continue;
}
}
iprange_sync(bogons_db);
if (GNET_PROPERTY(reload_debug)) {
g_debug("loaded %u bogus IP ranges (%u hosts)",
iprange_get_item_count(bogons_db),
iprange_get_host_count4(bogons_db));
}
return iprange_get_item_count(bogons_db);
} | false | false | false | false | false | 0 |
vlan_free_res(struct mlx4_dev *dev, int slave, int op, int cmd,
u64 in_param, u64 *out_param, int port)
{
struct mlx4_priv *priv = mlx4_priv(dev);
struct mlx4_slave_state *slave_state = priv->mfunc.master.slave_state;
int err = 0;
port = mlx4_slave_convert_port(
dev, slave, port);
if (port < 0)
return -EINVAL;
switch (op) {
case RES_OP_RESERVE_AND_MAP:
if (slave_state[slave].old_vlan_api)
return 0;
if (!port)
return -EINVAL;
vlan_del_from_slave(dev, slave, in_param, port);
__mlx4_unregister_vlan(dev, port, in_param);
break;
default:
err = -EINVAL;
break;
}
return err;
} | false | false | false | false | false | 0 |
GetRecord(const char *table)
{
vtkSQLQuery *query = this->GetQueryInstance();
vtkStdString text("PRAGMA table_info ('");
text += table;
text += "')";
query->SetQuery(text.c_str() );
bool status = query->Execute();
if (!status)
{
vtkErrorMacro(<< "GetRecord(" << table << "): Database returned error: "
<< vtk_sqlite3_errmsg(this->SQLiteInstance) );
query->Delete();
return NULL;
}
else
{
// Each row in the results that come back from this query
// describes a single column in the table. The format of each row
// is as follows:
//
// columnID columnName columnType ??? defaultValue nullForbidden
//
// (I don't know what the ??? column is. It's probably maximum
// length.)
vtkStringArray *results = vtkStringArray::New();
while (query->NextRow() )
{
results->InsertNextValue(query->DataValue(1).ToString() );
}
query->Delete();
return results;
}
} | false | false | false | false | false | 0 |
gnm_xml_prep_style_parser (GsfXMLIn *xin,
xmlChar const **attrs,
GnmXmlStyleHandler handler,
gpointer user)
{
static GsfXMLInNode dtd[] = {
GSF_XML_IN_NODE (STYLE_STYLE, STYLE_STYLE, GNM, "Style", GSF_XML_NO_CONTENT, &xml_sax_style_start, NULL),
/* Nodes added below. */
GSF_XML_IN_NODE_END
};
GsfXMLInDoc *doc = gsf_xml_in_doc_new (dtd, NULL);
XMLSaxParseState *state = g_new0 (XMLSaxParseState, 1);
read_file_init_state (state, NULL, NULL, NULL);
state->style_handler = handler;
state->style_handler_user = user;
state->style_handler_doc = doc;
state->style = gnm_style_new_default ();
/* Not a full style, just those parts that do not require a sheet. */
gnm_xml_in_doc_add_subset (doc, gnumeric_1_0_dtd,
"STYLE_FONT",
"STYLE_STYLE");
gnm_xml_in_doc_add_subset (doc, gnumeric_1_0_dtd,
"STYLE_BORDER",
"STYLE_STYLE");
gsf_xml_in_push_state (xin, doc, state,
(GsfXMLInExtDtor)style_parser_done, attrs);
} | false | false | false | false | false | 0 |
get_adc_configmask(unsigned int reg)
{
if (mValidCfgBits <= 0xf) // use config bit table
{
return (m_configuration_bits[(reg >> mCfgBitShift) & mValidCfgBits]);
}
else // register directly gives Analog ports (18f1220)
{
return (~(reg >> mCfgBitShift) & mValidCfgBits);
}
} | false | false | false | false | false | 0 |
pio_handler_set(Pio *p_pio, uint32_t ul_id, uint32_t ul_mask,
uint32_t ul_attr, void (*p_handler) (uint32_t, uint32_t))
{
struct s_interrupt_source *pSource;
if (gs_ul_nb_sources >= MAX_INTERRUPT_SOURCES)
return 1;
/* Define new source */
pSource = &(gs_interrupt_sources[gs_ul_nb_sources]);
pSource->id = ul_id;
pSource->mask = ul_mask;
pSource->attr = ul_attr;
pSource->handler = p_handler;
gs_ul_nb_sources++;
/* Configure interrupt mode */
pio_configure_interrupt(p_pio, ul_mask, ul_attr);
return 0;
} | false | false | false | false | false | 0 |
LM93_INTERVAL_TO_REG(long interval)
{
int i;
for (i = 0; i < 9; i++)
if (interval <= lm93_interval_map[i])
break;
/* can fall through with i==9 */
return (u8)i;
} | false | false | false | false | false | 0 |
set_syserr(n, name)
int n;
const char *name;
{
VALUE error;
if (!st_lookup(syserr_tbl, n, &error)) {
error = rb_define_class_under(rb_mErrno, name, rb_eSystemCallError);
rb_define_const(error, "Errno", INT2NUM(n));
st_add_direct(syserr_tbl, n, error);
}
else {
rb_define_const(rb_mErrno, name, error);
}
return error;
} | false | false | false | false | false | 0 |
style_shape_get (struct style *style, gchar *name)
{
START_FUNC
GSList *item=style->shapes;
struct shape *ret=NULL;
if (name) {
while (item && strcmp(((struct shape *)item->data)->name, name)) item=g_slist_next(item);
if (item) ret=(struct shape *)item->data;
else {
flo_warn(_("Shape %s doesn't exist for selected style."), name);
ret=style->default_shape;
}
} else ret=style->default_shape;
END_FUNC
return ret;
} | false | false | false | false | false | 0 |
fd_ref (fd_t *fd)
{
fd_t *refed_fd = NULL;
if (!fd) {
gf_log_callingfn ("fd", GF_LOG_ERROR, "null fd");
return NULL;
}
LOCK (&fd->inode->lock);
refed_fd = __fd_ref (fd);
UNLOCK (&fd->inode->lock);
return refed_fd;
} | false | false | false | false | false | 0 |
AxesOrder(int *filter, int *axes, int nDim)
{
int flags[MAX_DIMENSION];
int max, i, j;
memset(flags, 1, nDim*sizeof(int));
for (i = 0; i < nDim; i++)
{
max = -1;
for (j = 0; j < nDim; j++)
if (flags[j] && max < filter[j])
{
axes[i] = j;
max = filter[j];
}
flags[axes[i]] = 0;
}
} | false | false | false | false | false | 0 |
cyrusdb_convert(const char *fromfname, const char *tofname,
struct cyrusdb_backend *frombackend,
struct cyrusdb_backend *tobackend)
{
struct db *fromdb, *todb;
struct convert_rock cr;
struct txn *fromtid = NULL;
int r;
/* open both databases (create todb) */
r = (frombackend->open)(fromfname, 0, &fromdb);
if (r != CYRUSDB_OK)
fatal("can't open old database", EC_TEMPFAIL);
r = (tobackend->open)(tofname, CYRUSDB_CREATE, &todb);
if (r != CYRUSDB_OK)
fatal("can't open new database", EC_TEMPFAIL);
/* set up the copy rock */
cr.backend = tobackend;
cr.db = todb;
cr.tid = NULL;
/* copy each record to the destination DB (transactional for speed) */
(frombackend->foreach)(fromdb, "", 0, NULL, converter_cb, &cr, &fromtid);
/* commit both transactions */
if (fromtid) (frombackend->commit)(fromdb, fromtid);
if (cr.tid) (tobackend->commit)(todb, cr.tid);
/* and close the DBs */
(frombackend->close)(fromdb);
(tobackend->close)(todb);
} | true | true | false | false | true | 1 |
wstrcmp(s1, s2)
wchar *s1, *s2;
{
while (*s1 && *s1 == *s2)
s1++, s2++;
return (int)(*s1 - *s2);
} | false | false | false | false | false | 0 |
tracker_property_get_table_name (TrackerProperty *property)
{
TrackerPropertyPrivate *priv;
g_return_val_if_fail (TRACKER_IS_PROPERTY (property), NULL);
priv = GET_PRIV (property);
if (!priv->table_name) {
if (tracker_property_get_multiple_values (property)) {
priv->table_name = g_strdup_printf ("%s_%s",
tracker_class_get_name (tracker_property_get_domain (property)),
tracker_property_get_name (property));
} else {
priv->table_name = g_strdup (tracker_class_get_name (tracker_property_get_domain (property)));
}
}
return priv->table_name;
} | false | false | false | false | false | 0 |
OnConnect(talk_base::AsyncPacketSocket* socket) {
ASSERT(socket == socket_);
LOG_J(LS_VERBOSE, this) << "Connection established to "
<< socket->GetRemoteAddress().ToString();
set_connected(true);
} | false | false | false | false | false | 0 |
libewf_sector_range_get(
libewf_sector_range_t *sector_range,
uint64_t *start_sector,
uint64_t *number_of_sectors,
libcerror_error_t **error )
{
static char *function = "libewf_sector_range_get";
if( sector_range == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid session value.",
function );
return( -1 );
}
if( start_sector == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid start sector.",
function );
return( -1 );
}
if( number_of_sectors == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid number of sectors.",
function );
return( -1 );
}
*start_sector = sector_range->start_sector;
*number_of_sectors = sector_range->number_of_sectors;
return( 1 );
} | false | false | false | false | false | 0 |
__qla4_8xxx_minidump_process_rdmem(struct scsi_qla_host *ha,
struct qla8xxx_minidump_entry_hdr *entry_hdr,
uint32_t **d_ptr)
{
uint32_t r_addr, r_value, r_data;
uint32_t i, j, loop_cnt;
struct qla8xxx_minidump_entry_rdmem *m_hdr;
unsigned long flags;
uint32_t *data_ptr = *d_ptr;
DEBUG2(ql4_printk(KERN_INFO, ha, "Entering fn: %s\n", __func__));
m_hdr = (struct qla8xxx_minidump_entry_rdmem *)entry_hdr;
r_addr = m_hdr->read_addr;
loop_cnt = m_hdr->read_data_size/16;
DEBUG2(ql4_printk(KERN_INFO, ha,
"[%s]: Read addr: 0x%x, read_data_size: 0x%x\n",
__func__, r_addr, m_hdr->read_data_size));
if (r_addr & 0xf) {
DEBUG2(ql4_printk(KERN_INFO, ha,
"[%s]: Read addr 0x%x not 16 bytes aligned\n",
__func__, r_addr));
return QLA_ERROR;
}
if (m_hdr->read_data_size % 16) {
DEBUG2(ql4_printk(KERN_INFO, ha,
"[%s]: Read data[0x%x] not multiple of 16 bytes\n",
__func__, m_hdr->read_data_size));
return QLA_ERROR;
}
DEBUG2(ql4_printk(KERN_INFO, ha,
"[%s]: rdmem_addr: 0x%x, read_data_size: 0x%x, loop_cnt: 0x%x\n",
__func__, r_addr, m_hdr->read_data_size, loop_cnt));
write_lock_irqsave(&ha->hw_lock, flags);
for (i = 0; i < loop_cnt; i++) {
ha->isp_ops->wr_reg_indirect(ha, MD_MIU_TEST_AGT_ADDR_LO,
r_addr);
r_value = 0;
ha->isp_ops->wr_reg_indirect(ha, MD_MIU_TEST_AGT_ADDR_HI,
r_value);
r_value = MIU_TA_CTL_ENABLE;
ha->isp_ops->wr_reg_indirect(ha, MD_MIU_TEST_AGT_CTRL, r_value);
r_value = MIU_TA_CTL_START_ENABLE;
ha->isp_ops->wr_reg_indirect(ha, MD_MIU_TEST_AGT_CTRL, r_value);
for (j = 0; j < MAX_CTL_CHECK; j++) {
ha->isp_ops->rd_reg_indirect(ha, MD_MIU_TEST_AGT_CTRL,
&r_value);
if ((r_value & MIU_TA_CTL_BUSY) == 0)
break;
}
if (j >= MAX_CTL_CHECK) {
printk_ratelimited(KERN_ERR
"%s: failed to read through agent\n",
__func__);
write_unlock_irqrestore(&ha->hw_lock, flags);
return QLA_SUCCESS;
}
for (j = 0; j < 4; j++) {
ha->isp_ops->rd_reg_indirect(ha,
MD_MIU_TEST_AGT_RDDATA[j],
&r_data);
*data_ptr++ = cpu_to_le32(r_data);
}
r_addr += 16;
}
write_unlock_irqrestore(&ha->hw_lock, flags);
DEBUG2(ql4_printk(KERN_INFO, ha, "Leaving fn: %s datacount: 0x%x\n",
__func__, (loop_cnt * 16)));
*d_ptr = data_ptr;
return QLA_SUCCESS;
} | false | false | false | false | false | 0 |
create_edge_and_update_destination_phis (struct redirection_data *rd,
basic_block bb)
{
edge e = make_edge (bb, rd->outgoing_edge->dest, EDGE_FALLTHRU);
rescan_loop_exit (e, true, false);
e->probability = REG_BR_PROB_BASE;
e->count = bb->count;
if (rd->outgoing_edge->aux)
{
e->aux = XNEWVEC (edge, 2);
THREAD_TARGET(e) = THREAD_TARGET (rd->outgoing_edge);
THREAD_TARGET2(e) = THREAD_TARGET2 (rd->outgoing_edge);
}
else
{
e->aux = NULL;
}
/* If there are any PHI nodes at the destination of the outgoing edge
from the duplicate block, then we will need to add a new argument
to them. The argument should have the same value as the argument
associated with the outgoing edge stored in RD. */
copy_phi_args (e->dest, rd->outgoing_edge, e);
} | false | false | false | false | false | 0 |
build_tools_set_enabled (BuildTools* self, gint tool_num, gboolean enabled) {
gint _tmp0_ = 0;
gboolean _tmp1_ = FALSE;
BuildTool tool = {0};
GeeLinkedList* _tmp2_ = NULL;
gint _tmp3_ = 0;
gpointer _tmp4_ = NULL;
BuildTool* _tmp5_ = NULL;
BuildTool _tmp6_ = {0};
BuildTool _tmp7_ = {0};
BuildTool _tmp8_ = {0};
gboolean _tmp9_ = FALSE;
gboolean _tmp10_ = FALSE;
g_return_if_fail (self != NULL);
_tmp0_ = tool_num;
_tmp1_ = build_tools_is_valid_index (self, _tmp0_);
g_return_if_fail (_tmp1_);
_tmp2_ = self->_build_tools;
_tmp3_ = tool_num;
_tmp4_ = gee_abstract_list_get ((GeeAbstractList*) _tmp2_, _tmp3_);
_tmp5_ = (BuildTool*) _tmp4_;
build_tool_copy (_tmp5_, &_tmp6_);
_tmp7_ = _tmp6_;
_build_tool_free0 (_tmp5_);
tool = _tmp7_;
_tmp8_ = tool;
_tmp9_ = _tmp8_.enabled;
_tmp10_ = enabled;
if (_tmp9_ != _tmp10_) {
gboolean _tmp11_ = FALSE;
GeeLinkedList* _tmp12_ = NULL;
gint _tmp13_ = 0;
BuildTool _tmp14_ = {0};
_tmp11_ = enabled;
tool.enabled = _tmp11_;
_tmp12_ = self->_build_tools;
_tmp13_ = tool_num;
_tmp14_ = tool;
gee_abstract_list_set ((GeeAbstractList*) _tmp12_, _tmp13_, &_tmp14_);
g_signal_emit_by_name (self, "modified");
}
build_tool_destroy (&tool);
} | false | false | false | false | false | 0 |
Description()
{
//Adds the SMARTS string to the description
static string txt;
txt = _descr;
txt += "\n\t SMARTS: ";
txt += _smarts;
txt += "\nSmartsDescriptor is definable";
return txt.c_str();
} | false | false | false | false | false | 0 |
job_signal_status (job)
int job;
{
register PROCESS *p;
WAIT s;
p = jobs[job]->pipe;
do
{
s = p->status;
if (WIFSIGNALED(s) || WIFSTOPPED(s))
break;
p = p->next;
}
while (p != jobs[job]->pipe);
return s;
} | false | false | false | false | false | 0 |
internet_address_cat (CamelAddress *dest,
CamelAddress *source)
{
gint i;
g_assert (CAMEL_IS_INTERNET_ADDRESS (source));
for (i = 0; i < source->addresses->len; i++) {
struct _address *addr = g_ptr_array_index (source->addresses, i);
camel_internet_address_add ((CamelInternetAddress *) dest, addr->name, addr->address);
}
return i;
} | false | false | false | false | false | 0 |
ng_ratio_fixup(int *width, int *height, int *xoff, int *yoff)
{
int h = *height;
int w = *width;
if (0 == ng_ratio_x || 0 == ng_ratio_y)
return;
if (w * ng_ratio_y < h * ng_ratio_x) {
*height = *width * ng_ratio_y / ng_ratio_x;
if (yoff)
*yoff += (h-*height)/2;
} else if (w * ng_ratio_y > h * ng_ratio_x) {
*width = *height * ng_ratio_x / ng_ratio_y;
if (yoff)
*xoff += (w-*width)/2;
}
} | false | false | false | false | false | 0 |
setflags( int argc, char **argv, char *version )
/*----------------------------------------------------------------------------*/
/******************************************************************************/
/* Name: setflags */
/* Function: read flags from argv; return argindex of first non arg. */
/*Copyright (C) 2009 The Scripps Research Institute. All rights reserved. */
/*----------------------------------------------------------------------------*/
/* Author: Garrett Matthew Morris, TSRI. */
/* (Adapted from code supplied by Bruce Duncan, TSRI.) */
/* Date: 06/11/92 */
/*----------------------------------------------------------------------------*/
/* Inputs: argc,argv,version */
/* Returns: argindex */
/* Globals: *GPF; */
/* *logFile; */
/* *programname; */
/* grid_param_fn[]; */
/*----------------------------------------------------------------------------*/
/* Modification Record */
/* Date Inits Comments */
/* 06/11/92 GMM Modified for Autogrid flags: */
/* -p = Parameter filename; */
/* -l = Log filename; */
/* -o = Use old PDBq format (q in columns 55-61) */
/* 04/01/93 GMM Created for use in makefile. */
/******************************************************************************/
{
int argindex;
/*----------------------------------------------------------------------------*/
/* Initialize */
/*----------------------------------------------------------------------------*/
argindex = 1;
programname = argv[0];
GPF = stdin;
logFile = stdout;
/*----------------------------------------------------------------------------*/
/* Loop over arguments */
/*----------------------------------------------------------------------------*/
while((argc > 1) && (argv[1][0] == '-')){
if (argv[1][1] == '-') argv[1]++;
switch(argv[1][1]){
#ifdef FOO
case 'n':
ncount = atoi(argv[2]);
argv++;
argc--;
argindex++;
break;
#endif
case 'd':
debug++;
break;
case 'u':
case 'h':
fprintf(stdout, "usage: AutoGrid %s\n", AutoGridHelp);
exit(EXIT_SUCCESS);
break;
case 'l':
if (argc < 3){
fprintf(stderr, "\n%s: Sorry, -l requires a filename.\n\t%s\n", programname, AutoGridHelp);
exit(EXIT_FAILURE);
}
if ( (logFile = ad_fopen(argv[2], "w")) == NULL ) {
fprintf(stderr, "\n%s: Sorry, I can't create the log file \"%s\"\n", programname, argv[2]);
fprintf(stderr, "\n%s: Unsuccessful Completion.\n\n", programname);
exit(EXIT_FAILURE);
}
argv++;
argc--;
argindex++;
break;
case 'p':
if (argc < 3){
fprintf(stderr, "\n%s: Sorry, -p requires a filename.\n\t%s\n", programname, AutoGridHelp);
exit(EXIT_FAILURE);
}
strncpy(grid_param_fn, argv[2], PATH_MAX);
grid_param_fn[PATH_MAX-1] = '\0';
if ( (GPF = ad_fopen(argv[2], "r")) == NULL ) {
fprintf(stderr, "\n%s: Sorry, I can't find or open Grid Parameter File \"%s\"\n", programname, argv[2]);
fprintf(stderr, "\n%s: Unsuccessful Completion.\n\n", programname);
exit(EXIT_FAILURE);
}
argv++;
argc--;
argindex++;
break;
case 'v':
fprintf(stdout, "AutoGrid %-8s\n", version);
fprintf(stdout, " Copyright (C) 2009 The Scripps Research Institute.\n");
// GNU BEGIN (see maintenance script update_license_de-GNU)
fprintf(stdout, " License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n");
fprintf(stdout, " This is free software: you are free to change and redistribute it.\n");
// GNU END (see maintenance script update_license_de-GNU)
fprintf(stdout, " There is NO WARRANTY, to the extent permitted by law.\n");
exit(EXIT_SUCCESS);
break;
default:
fprintf(stderr,"%s: unknown switch -%c\n",programname,argv[1][1]);
exit(EXIT_FAILURE);
break;
}
argindex++;
argc--;
argv++;
}
//no gpf specified and input is terminal, very likely an error
if (GPF==stdin && isatty(fileno(stdin))){
fprintf(stdout, "usage: AutoGrid %s\n", AutoGridHelp);
exit(EXIT_FAILURE);
}
return(argindex);
} | false | false | false | false | false | 0 |
dime_quien_soy( void )
{
int tmp;
tmp = ((cliente.random<<1 ) ^ (cliente.random>>1)) % rnombres;
if(tmp < 0)
tmp=-tmp;
strncpy( cliente.mi_nombre, robot_nombres[tmp].nombre, sizeof(cliente.mi_nombre) );
cliente.ai = robot_nombres[tmp].ai;
} | false | false | false | false | false | 0 |
dpms_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct drm_connector *connector = to_drm_connector(device);
int dpms;
dpms = READ_ONCE(connector->dpms);
return snprintf(buf, PAGE_SIZE, "%s\n",
drm_get_dpms_name(dpms));
} | false | false | false | false | false | 0 |
HpmfwupgValidateImageIntegrity(struct HpmfwupgUpgradeCtx *pFwupgCtx)
{
struct HpmfwupgImageHeader *pImageHeader = (struct HpmfwupgImageHeader*)pFwupgCtx->pImageData;
md5_state_t ctx;
static unsigned char md[HPMFWUPG_MD5_SIGNATURE_LENGTH];
unsigned char *pMd5Sig = pFwupgCtx->pImageData
+ (pFwupgCtx->imageSize - HPMFWUPG_MD5_SIGNATURE_LENGTH);
/* Validate MD5 checksum */
memset(md, 0, HPMFWUPG_MD5_SIGNATURE_LENGTH);
memset(&ctx, 0, sizeof(md5_state_t));
md5_init(&ctx);
md5_append(&ctx, pFwupgCtx->pImageData,
pFwupgCtx->imageSize - HPMFWUPG_MD5_SIGNATURE_LENGTH);
md5_finish(&ctx, md);
if (memcmp(md, pMd5Sig, HPMFWUPG_MD5_SIGNATURE_LENGTH) != 0) {
lprintf(LOG_NOTICE, "\n Invalid MD5 signature");
return HPMFWUPG_ERROR;
}
/* Validate Header signature */
if(strncmp(pImageHeader->signature,
HPMFWUPG_IMAGE_SIGNATURE,
HPMFWUPG_HEADER_SIGNATURE_LENGTH) != 0) {
lprintf(LOG_NOTICE,"\n Invalid image signature");
return HPMFWUPG_ERROR;
}
/* Validate Header image format version */
if (pImageHeader->formatVersion != HPMFWUPG_IMAGE_HEADER_VERSION) {
lprintf(LOG_NOTICE,"\n Unrecognized image version");
return HPMFWUPG_ERROR;
}
/* Validate header checksum */
if (HpmfwupgCalculateChecksum((unsigned char*)pImageHeader,
sizeof(struct HpmfwupgImageHeader)
+ pImageHeader->oemDataLength
+ sizeof(unsigned char)/*checksum*/) != 0) {
lprintf(LOG_NOTICE,"\n Invalid header checksum");
return HPMFWUPG_ERROR;
}
return HPMFWUPG_SUCCESS;
} | true | true | false | false | false | 1 |
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
int p1, blkn;
BITREAD_STATE_VARS;
/* Process restart marker if needed; may have to suspend */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
if (! process_restart(cinfo))
return FALSE;
}
/* Not worth the cycles to check insufficient_data here,
* since we will not change the data anyway if we read zeroes.
*/
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
/* Outer loop handles each block in the MCU */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
/* Encoded data is simply the next bit of the two's-complement DC value */
CHECK_BIT_BUFFER(br_state, 1, return FALSE);
if (GET_BITS(1))
MCU_data[blkn][0][0] |= p1;
/* Note: since we use |=, repeating the assignment later is safe */
}
/* Completed MCU, so update state */
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
/* Account for restart interval (no-op if not using restarts) */
entropy->restarts_to_go--;
return TRUE;
} | false | false | false | false | false | 0 |
gst_buffer_memcmp (GstBuffer * buffer, gsize offset, gconstpointer mem,
gsize size)
{
gsize i, len;
const guint8 *ptr = mem;
gint res = 0;
g_return_val_if_fail (GST_IS_BUFFER (buffer), 0);
g_return_val_if_fail (mem != NULL, 0);
GST_CAT_LOG (GST_CAT_BUFFER,
"buffer %p, offset %" G_GSIZE_FORMAT ", size %" G_GSIZE_FORMAT, buffer,
offset, size);
if (G_UNLIKELY (gst_buffer_get_size (buffer) < offset + size))
return -1;
len = GST_BUFFER_MEM_LEN (buffer);
for (i = 0; i < len && size > 0 && res == 0; i++) {
GstMapInfo info;
gsize tocmp;
GstMemory *mem;
mem = _get_mapped (buffer, i, &info, GST_MAP_READ);
if (info.size > offset) {
/* we have enough */
tocmp = MIN (info.size - offset, size);
res = memcmp (ptr, (guint8 *) info.data + offset, tocmp);
size -= tocmp;
ptr += tocmp;
offset = 0;
} else {
/* offset past buffer, skip */
offset -= info.size;
}
gst_memory_unmap (mem, &info);
}
return res;
} | false | false | false | false | false | 0 |
seckey_ExtractPublicKey(const CERTSubjectPublicKeyInfo *spki)
{
SECKEYPublicKey *pubk;
SECItem os, newOs, newParms;
SECStatus rv;
PLArenaPool *arena;
SECOidTag tag;
arena = PORT_NewArena (DER_DEFAULT_CHUNKSIZE);
if (arena == NULL)
return NULL;
pubk = (SECKEYPublicKey *) PORT_ArenaZAlloc(arena, sizeof(SECKEYPublicKey));
if (pubk == NULL) {
PORT_FreeArena (arena, PR_FALSE);
return NULL;
}
pubk->arena = arena;
pubk->pkcs11Slot = 0;
pubk->pkcs11ID = CK_INVALID_HANDLE;
/* Convert bit string length from bits to bytes */
os = spki->subjectPublicKey;
DER_ConvertBitString (&os);
tag = SECOID_GetAlgorithmTag(&spki->algorithm);
/* copy the DER into the arena, since Quick DER returns data that points
into the DER input, which may get freed by the caller */
rv = SECITEM_CopyItem(arena, &newOs, &os);
if ( rv == SECSuccess )
switch ( tag ) {
case SEC_OID_X500_RSA_ENCRYPTION:
case SEC_OID_PKCS1_RSA_ENCRYPTION:
pubk->keyType = rsaKey;
prepare_rsa_pub_key_for_asn1(pubk);
rv = SEC_QuickDERDecodeItem(arena, pubk, SECKEY_RSAPublicKeyTemplate, &newOs);
if (rv == SECSuccess)
return pubk;
break;
case SEC_OID_ANSIX9_DSA_SIGNATURE:
case SEC_OID_SDN702_DSA_SIGNATURE:
pubk->keyType = dsaKey;
prepare_dsa_pub_key_for_asn1(pubk);
rv = SEC_QuickDERDecodeItem(arena, pubk, SECKEY_DSAPublicKeyTemplate, &newOs);
if (rv != SECSuccess) break;
rv = seckey_DSADecodePQG(arena, pubk,
&spki->algorithm.parameters);
if (rv == SECSuccess) return pubk;
break;
case SEC_OID_X942_DIFFIE_HELMAN_KEY:
pubk->keyType = dhKey;
prepare_dh_pub_key_for_asn1(pubk);
rv = SEC_QuickDERDecodeItem(arena, pubk, SECKEY_DHPublicKeyTemplate, &newOs);
if (rv != SECSuccess) break;
/* copy the DER into the arena, since Quick DER returns data that points
into the DER input, which may get freed by the caller */
rv = SECITEM_CopyItem(arena, &newParms, &spki->algorithm.parameters);
if ( rv != SECSuccess )
break;
rv = SEC_QuickDERDecodeItem(arena, pubk, SECKEY_DHParamKeyTemplate,
&newParms);
if (rv == SECSuccess) return pubk;
break;
case SEC_OID_ANSIX962_EC_PUBLIC_KEY:
pubk->keyType = ecKey;
pubk->u.ec.size = 0;
/* Since PKCS#11 directly takes the DER encoding of EC params
* and public value, we don't need any decoding here.
*/
rv = SECITEM_CopyItem(arena, &pubk->u.ec.DEREncodedParams,
&spki->algorithm.parameters);
if ( rv != SECSuccess )
break;
rv = SECITEM_CopyItem(arena, &pubk->u.ec.publicValue, &newOs);
if (rv == SECSuccess) return pubk;
break;
default:
PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG);
rv = SECFailure;
break;
}
SECKEY_DestroyPublicKey (pubk);
return NULL;
} | false | false | false | false | false | 0 |
sheet_style_foreach (Sheet const *sheet, GFunc func, gpointer user_data)
{
GSList *styles;
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (sheet->style_data != NULL);
styles = sh_all_styles (sheet->style_data->style_hash);
styles = g_slist_sort (styles, (GCompareFunc)gnm_style_cmp);
g_slist_foreach (styles, func, user_data);
g_slist_free (styles);
} | false | false | false | false | false | 0 |
numaGetHistogramStats(NUMA *nahisto,
l_float32 startx,
l_float32 deltax,
l_float32 *pxmean,
l_float32 *pxmedian,
l_float32 *pxmode,
l_float32 *pxvariance)
{
PROCNAME("numaGetHistogramStats");
if (pxmean) *pxmean = 0.0;
if (pxmedian) *pxmedian = 0.0;
if (pxmode) *pxmode = 0.0;
if (pxvariance) *pxvariance = 0.0;
if (!nahisto)
return ERROR_INT("nahisto not defined", procName, 1);
return numaGetHistogramStatsOnInterval(nahisto, startx, deltax, 0, 0,
pxmean, pxmedian, pxmode,
pxvariance);
} | false | false | false | false | false | 0 |
Init(const char* name, Interactor* i) {
if (name != nil) {
SetInstance(name);
}
enabled_ = true;
parent_ = nil;
state_ = new ControlState;
state_->Attach(this);
input = new Sensor;
input->Catch(EnterEvent);
input->Catch(LeaveEvent);
input->Catch(DownEvent);
input->Catch(UpEvent);
if (i != nil) {
Insert(i);
}
} | false | false | false | false | false | 0 |
test_config_write__delete_value_at_specific_level(void)
{
git_config *cfg, *cfg_specific;
int32_t i;
cl_git_pass(git_config_open_ondisk(&cfg, "config15"));
cl_git_pass(git_config_get_int32(&i, cfg, "core.dummy2"));
cl_assert(i == 7);
git_config_free(cfg);
cl_git_pass(git_config_new(&cfg));
cl_git_pass(git_config_add_file_ondisk(cfg, "config9",
GIT_CONFIG_LEVEL_LOCAL, 0));
cl_git_pass(git_config_add_file_ondisk(cfg, "config15",
GIT_CONFIG_LEVEL_GLOBAL, 0));
cl_git_pass(git_config_open_level(&cfg_specific, cfg, GIT_CONFIG_LEVEL_GLOBAL));
cl_git_pass(git_config_delete_entry(cfg_specific, "core.dummy2"));
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config15"));
cl_assert(git_config_get_int32(&i, cfg, "core.dummy2") == GIT_ENOTFOUND);
cl_git_pass(git_config_set_int32(cfg, "core.dummy2", 7));
git_config_free(cfg_specific);
git_config_free(cfg);
} | false | false | false | false | false | 0 |
swf_bifs_action(SWFReader *read, SWFAction *act)
{
GF_List *dst;
MFURL url;
SFURL sfurl;
Bool bval;
GF_Node *n;
Double time;
dst = read->bifs_au->commands;
if (read->btn) {
if (act->button_mask & GF_SWF_COND_OVERUP_TO_OVERDOWN) dst = read->btn_active;
else if (act->button_mask & GF_SWF_COND_IDLE_TO_OVERUP) dst = read->btn_over;
else if (act->button_mask & GF_SWF_COND_OVERUP_TO_IDLE) dst = read->btn_not_over;
else dst = read->btn_not_active;
}
switch (act->type) {
case GF_SWF_AS3_WAIT_FOR_FRAME:
/*while correct, this is not optimal, we set the wait-frame upon GOTO frame*/
// read->wait_frame = act->frame_number;
break;
case GF_SWF_AS3_GOTO_FRAME:
if (act->frame_number>read->current_frame)
read->wait_frame = act->frame_number;
time = act->frame_number ? act->frame_number +1: 0;
time /= read->frame_rate;
s2b_control_sprite(read, dst, read->current_sprite_id, 0, 1, time, 0);
break;
case GF_SWF_AS3_GET_URL:
n = gf_sg_find_node_by_name(read->load->scene_graph, "MOVIE_URL");
sfurl.OD_ID = 0; sfurl.url = act->url;
url.count = 1; url.vals = &sfurl;
s2b_set_field(read, dst, n, "url", -1, GF_SG_VRML_MFURL, &url, 0);
s2b_set_field(read, dst, n, "parameter", -1, GF_SG_VRML_MFSTRING, &url, 0);
bval = 1;
s2b_set_field(read, dst, n, "activate", -1, GF_SG_VRML_SFBOOL, &bval, 0);
break;
case GF_SWF_AS3_PLAY:
s2b_control_sprite(read, dst, read->current_sprite_id, 0, 1, -1, 0);
break;
case GF_SWF_AS3_STOP:
s2b_control_sprite(read, dst, read->current_sprite_id, 1, 0, 0, 0);
break;
default:
return 0;
}
return 1;
} | false | true | false | false | true | 1 |
updatepidfile(void)
{
int fd;
char buf[42];
if (SNCHECK(snprintf(buf, sizeof buf, "%lu\n",
(unsigned long) getpid()), sizeof buf)) {
return;
}
if (unlink(pid_file) != 0 && errno != ENOENT) {
return;
}
if ((fd = open(pid_file, O_CREAT | O_WRONLY | O_TRUNC |
O_NOFOLLOW, (mode_t) 0644)) == -1) {
return;
}
if (safe_write(fd, buf, strlen(buf)) != 0) {
(void) ftruncate(fd, (off_t) 0);
}
(void) close(fd);
} | true | true | false | false | true | 1 |
draw(GeometryBuffer& buffer,
const Vector2& position,
const ColourRect* mod_colours,
const Rect* clip_rect) const
{
Vector2 draw_pos(position);
for (size_t i = 0; i < d_renderedString->getLineCount(); ++i)
{
d_renderedString->draw(i, buffer, draw_pos, mod_colours, clip_rect, 0.0f);
draw_pos.d_y += d_renderedString->getPixelSize(i).d_height;
}
} | false | false | false | false | false | 0 |
adi_init_input(struct adi *adi, struct adi_port *port, int half)
{
struct input_dev *input_dev;
char buf[ADI_MAX_NAME_LENGTH];
int i, t;
adi->dev = input_dev = input_allocate_device();
if (!input_dev)
return -ENOMEM;
t = adi->id < ADI_ID_MAX ? adi->id : ADI_ID_MAX;
snprintf(buf, ADI_MAX_PHYS_LENGTH, adi_names[t], adi->id);
snprintf(adi->name, ADI_MAX_NAME_LENGTH, "Logitech %s [%s]", buf, adi->cname);
snprintf(adi->phys, ADI_MAX_PHYS_LENGTH, "%s/input%d", port->gameport->phys, half);
adi->abs = adi_abs[t];
adi->key = adi_key[t];
input_dev->name = adi->name;
input_dev->phys = adi->phys;
input_dev->id.bustype = BUS_GAMEPORT;
input_dev->id.vendor = GAMEPORT_ID_VENDOR_LOGITECH;
input_dev->id.product = adi->id;
input_dev->id.version = 0x0100;
input_dev->dev.parent = &port->gameport->dev;
input_set_drvdata(input_dev, port);
input_dev->open = adi_open;
input_dev->close = adi_close;
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++)
set_bit(adi->abs[i], input_dev->absbit);
for (i = 0; i < adi->buttons; i++)
set_bit(adi->key[i], input_dev->keybit);
return 0;
} | true | true | false | false | true | 1 |
sanitize_path(struct request *r)
{
char *p, *q, c;
enum {
sp_normal,
sp_slash,
sp_slashdot,
sp_slashdotdot
} s;
if (debug)
log_d("sanitize_path: old path: %s", r->path);
p = q = r->path;
s = sp_normal;
do {
c = *p++;
switch (s) {
case sp_normal:
if (c == '/')
s = sp_slash;
break;
case sp_slash:
switch (c) {
case '/':
/*
* replace '//' with '/'
*/
--q;
break;
case '.':
s = sp_slashdot;
break;
default:
s = sp_normal;
break;
}
break;
case sp_slashdot:
switch (c) {
case '/':
/*
* replace '/./' with '/'
*/
q -= 2;
s = sp_slash;
break;
case '.':
s = sp_slashdotdot;
break;
default:
s = sp_normal;
break;
}
break;
case sp_slashdotdot:
switch (c) {
case '/':
/*
* replace '/foo/../' with '/'
*/
q -= 3;
while (q > r->path && q[-1] != '/')
--q;
if (q > r->path)
--q;
s = sp_slash;
break;
default:
s = sp_normal;
break;
}
break;
}
*q++ = c;
} while (c);
if (debug)
log_d("sanitize_path: new path: %s", r->path);
} | false | false | false | false | false | 0 |
skipUWhiteSpace(const UnicodeString& text, int32_t pos) {
while (pos < text.length()) {
UChar32 c = text.char32At(pos);
if (!u_isUWhiteSpace(c)) {
break;
}
pos += U16_LENGTH(c);
}
return pos;
} | false | false | false | false | false | 0 |
MouseInMail(int x, int y)
{
int maill = win_width - stwin_width + clock_width + 2;
int mailr = win_width - (do_check_mail ? 0 : 3);
return (x>=maill && x<mailr && y>1 && y<RowHeight-2);
} | false | false | false | false | false | 0 |
cselib_record_autoinc_cb (rtx mem ATTRIBUTE_UNUSED, rtx op ATTRIBUTE_UNUSED,
rtx dest, rtx src, rtx srcoff, void *arg)
{
struct cselib_record_autoinc_data *data;
data = (struct cselib_record_autoinc_data *)arg;
data->sets[data->n_sets].dest = dest;
if (srcoff)
data->sets[data->n_sets].src = gen_rtx_PLUS (GET_MODE (src), src, srcoff);
else
data->sets[data->n_sets].src = src;
data->n_sets++;
return -1;
} | false | false | false | false | false | 0 |
fcsSetBackupActiveFlag(
HFDB hDb,
FLMBOOL bBackupActive)
{
FDB * pDb = (FDB *)hDb;
RCODE rc = FERR_OK;
flmAssert( IsInCSMode( hDb));
fdbInitCS( pDb);
CS_CONTEXT * pCSContext = pDb->pCSContext;
FCL_WIRE Wire( pCSContext, pDb);
if( !pCSContext->bConnectionGood)
{
rc = RC_SET( FERR_BAD_SERVER_CONNECTION);
goto Transmission_Error;
}
if( RC_BAD( rc = Wire.sendOp(
FCS_OPCLASS_DATABASE, FCS_OP_DB_SET_BACKUP_FLAG)))
{
goto Exit;
}
if (RC_BAD( rc = Wire.sendNumber( WIRE_VALUE_BOOLEAN, bBackupActive)))
{
goto Transmission_Error;
}
if( RC_BAD( rc = Wire.sendTerminate()))
{
goto Transmission_Error;
}
/* Read the response. */
if (RC_BAD( rc = Wire.read()))
{
goto Transmission_Error;
}
if( RC_BAD( rc = Wire.getRCode()))
{
goto Exit;
}
goto Exit;
Transmission_Error:
pCSContext->bConnectionGood = FALSE;
goto Exit;
Exit:
fdbExit( pDb);
return( rc);
} | false | false | false | false | false | 0 |
e1000_setup_link_82543(struct e1000_hw *hw)
{
u32 ctrl_ext;
s32 ret_val;
u16 data;
DEBUGFUNC("e1000_setup_link_82543");
/*
* Take the 4 bits from NVM word 0xF that determine the initial
* polarity value for the SW controlled pins, and setup the
* Extended Device Control reg with that info.
* This is needed because one of the SW controlled pins is used for
* signal detection. So this should be done before phy setup.
*/
if (hw->mac.type == e1000_82543) {
ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG, 1, &data);
if (ret_val) {
DEBUGOUT("NVM Read Error\n");
ret_val = -E1000_ERR_NVM;
goto out;
}
ctrl_ext = ((data & NVM_WORD0F_SWPDIO_EXT_MASK) <<
NVM_SWDPIO_EXT_SHIFT);
E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
}
ret_val = e1000_setup_link_generic(hw);
out:
return ret_val;
} | false | false | false | false | false | 0 |
load(void)
{
ACodeHeader tmphdr;
Aword crc = 0;
char err[100];
readTemporaryHeader(&tmphdr);
checkVersion(&tmphdr);
/* Allocate and load memory */
if (littleEndian())
reverseHdr(&tmphdr);
if (tmphdr.size <= sizeof(ACodeHeader)/sizeof(Aword))
syserr("Malformed game file. Too small.");
loadAndCheckMemory(tmphdr, crc, err);
reverseMemory();
setupHeader(tmphdr);
} | false | false | false | false | true | 1 |
ztype0_adjust_FDepVector(gs_font_type0 * pfont)
{
gs_memory_t *mem = pfont->memory;
/* HACK: We know the font was allocated by the interpreter. */
gs_ref_memory_t *imem = (gs_ref_memory_t *)mem;
gs_font **pdep = pfont->data.FDepVector;
ref newdep;
uint fdep_size = pfont->data.fdep_size;
ref *prdep;
uint i;
int code = gs_alloc_ref_array(imem, &newdep, a_readonly, fdep_size,
"ztype0_adjust_matrix");
if (code < 0)
return code;
for (prdep = newdep.value.refs, i = 0; i < fdep_size; i++, prdep++) {
const ref *pdict = pfont_dict(pdep[i]);
ref_assign(prdep, pdict);
r_set_attrs(prdep, imemory_new_mask(imem));
}
/*
* The FDepVector is an existing key in the parent's dictionary,
* so it's safe to pass NULL as the dstack pointer to dict_put_string.
*/
return dict_put_string(pfont_dict(pfont), "FDepVector", &newdep, NULL);
} | false | false | false | false | false | 0 |
status_touch(void)
{
unsigned i;
for (i = 0; i < SSZ; i++) {
status_line[i].changed = True;
(void) memset(status_line[i].d2b, 0,
status_line[i].len * sizeof(XChar2b));
}
status_changed = True;
} | false | false | false | false | false | 0 |
Perl_filter_read(pTHX_ int idx, SV *buf_sv, int maxlen)
{
dVAR;
filter_t funcp;
SV *datasv = NULL;
/* This API is bad. It should have been using unsigned int for maxlen.
Not sure if we want to change the API, but if not we should sanity
check the value here. */
unsigned int correct_length
= maxlen < 0 ?
#ifdef PERL_MICRO
0x7FFFFFFF
#else
INT_MAX
#endif
: maxlen;
PERL_ARGS_ASSERT_FILTER_READ;
if (!PL_parser || !PL_rsfp_filters)
return -1;
if (idx > AvFILLp(PL_rsfp_filters)) { /* Any more filters? */
/* Provide a default input filter to make life easy. */
/* Note that we append to the line. This is handy. */
DEBUG_P(PerlIO_printf(Perl_debug_log,
"filter_read %d: from rsfp\n", idx));
if (correct_length) {
/* Want a block */
int len ;
const int old_len = SvCUR(buf_sv);
/* ensure buf_sv is large enough */
SvGROW(buf_sv, (STRLEN)(old_len + correct_length + 1)) ;
if ((len = PerlIO_read(PL_rsfp, SvPVX(buf_sv) + old_len,
correct_length)) <= 0) {
if (PerlIO_error(PL_rsfp))
return -1; /* error */
else
return 0 ; /* end of file */
}
SvCUR_set(buf_sv, old_len + len) ;
SvPVX(buf_sv)[old_len + len] = '\0';
} else {
/* Want a line */
if (sv_gets(buf_sv, PL_rsfp, SvCUR(buf_sv)) == NULL) {
if (PerlIO_error(PL_rsfp))
return -1; /* error */
else
return 0 ; /* end of file */
}
}
return SvCUR(buf_sv);
}
/* Skip this filter slot if filter has been deleted */
if ( (datasv = FILTER_DATA(idx)) == &PL_sv_undef) {
DEBUG_P(PerlIO_printf(Perl_debug_log,
"filter_read %d: skipped (filter deleted)\n",
idx));
return FILTER_READ(idx+1, buf_sv, correct_length); /* recurse */
}
if (SvTYPE(datasv) != SVt_PVIO) {
if (correct_length) {
/* Want a block */
const STRLEN remainder = SvLEN(datasv) - SvCUR(datasv);
if (!remainder) return 0; /* eof */
if (correct_length > remainder) correct_length = remainder;
sv_catpvn(buf_sv, SvEND(datasv), correct_length);
SvCUR_set(datasv, SvCUR(datasv) + correct_length);
} else {
/* Want a line */
const char *s = SvEND(datasv);
const char *send = SvPVX(datasv) + SvLEN(datasv);
while (s < send) {
if (*s == '\n') {
s++;
break;
}
s++;
}
if (s == send) return 0; /* eof */
sv_catpvn(buf_sv, SvEND(datasv), s-SvEND(datasv));
SvCUR_set(datasv, s-SvPVX(datasv));
}
return SvCUR(buf_sv);
}
/* Get function pointer hidden within datasv */
funcp = DPTR2FPTR(filter_t, IoANY(datasv));
DEBUG_P(PerlIO_printf(Perl_debug_log,
"filter_read %d: via function %p (%s)\n",
idx, (void*)datasv, SvPV_nolen_const(datasv)));
/* Call function. The function is expected to */
/* call "FILTER_READ(idx+1, buf_sv)" first. */
/* Return: <0:error, =0:eof, >0:not eof */
return (*funcp)(aTHX_ idx, buf_sv, correct_length);
} | false | false | false | false | false | 0 |
_gss_import_export_name(OM_uint32 *minor_status,
const gss_buffer_t input_name_buffer,
gss_name_t *output_name)
{
OM_uint32 major_status;
unsigned char *p = input_name_buffer->value;
size_t len = input_name_buffer->length;
size_t t;
gss_OID_desc mech_oid;
gssapi_mech_interface m;
struct _gss_name *name;
gss_name_t new_canonical_name;
int composite = 0;
*minor_status = 0;
*output_name = 0;
/*
* Make sure that TOK_ID is {4, 1}.
*/
if (len < 2)
return (GSS_S_BAD_NAME);
if (p[0] != 4)
return (GSS_S_BAD_NAME);
switch (p[1]) {
case 1: /* non-composite name */
break;
case 2: /* composite name */
composite = 1;
break;
default:
return (GSS_S_BAD_NAME);
}
p += 2;
len -= 2;
/*
* Get the mech length and the name length and sanity
* check the size of of the buffer.
*/
if (len < 2)
return (GSS_S_BAD_NAME);
t = (p[0] << 8) + p[1];
p += 2;
len -= 2;
/*
* Check the DER encoded OID to make sure it agrees with the
* length we just decoded.
*/
if (p[0] != 6) /* 6=OID */
return (GSS_S_BAD_NAME);
p++;
len--;
t--;
if (p[0] & 0x80) {
int digits = p[0];
p++;
len--;
t--;
mech_oid.length = 0;
while (digits--) {
mech_oid.length = (mech_oid.length << 8) | p[0];
p++;
len--;
t--;
}
} else {
mech_oid.length = p[0];
p++;
len--;
t--;
}
if (mech_oid.length != t)
return (GSS_S_BAD_NAME);
mech_oid.elements = p;
if (len < t + 4)
return (GSS_S_BAD_NAME);
p += t;
len -= t;
t = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
p += 4;
len -= 4;
if (!composite && len != t)
return (GSS_S_BAD_NAME);
m = __gss_get_mechanism(&mech_oid);
if (!m)
return (GSS_S_BAD_MECH);
/*
* Ask the mechanism to import the name.
*/
major_status = m->gm_import_name(minor_status,
input_name_buffer, GSS_C_NT_EXPORT_NAME, &new_canonical_name);
if (major_status != GSS_S_COMPLETE) {
_gss_mg_error(m, major_status, *minor_status);
return major_status;
}
/*
* Now we make a new name and mark it as an MN.
*/
name = _gss_make_name(m, new_canonical_name);
if (!name) {
m->gm_release_name(minor_status, &new_canonical_name);
return (GSS_S_FAILURE);
}
*output_name = (gss_name_t) name;
*minor_status = 0;
return (GSS_S_COMPLETE);
} | false | false | false | false | false | 0 |
skl_get_queue_index(struct skl_module_pin *mpin,
struct skl_module_inst_id id, int max)
{
int i;
for (i = 0; i < max; i++) {
if (mpin[i].id.module_id == id.module_id &&
mpin[i].id.instance_id == id.instance_id)
return i;
}
return -EINVAL;
} | false | false | false | false | false | 0 |
cb_sheet_label_drag_end (GtkWidget *widget, GdkDragContext *context,
WBCGtk *wbcg)
{
GtkWidget *arrow;
g_return_if_fail (IS_WORKBOOK_CONTROL (wbcg));
/* Destroy the arrow. */
arrow = g_object_get_data (G_OBJECT (widget), "arrow");
gtk_widget_destroy (arrow);
g_object_unref (arrow);
g_object_set_data (G_OBJECT (widget), "arrow", NULL);
} | false | false | false | false | false | 0 |
event(QEvent *e)
{
if (e->type() == static_cast<QEvent::Type>(DOMCFResizeEvent)) {
dispatchWindowEvent(EventImpl::RESIZE_EVENT, false, false);
e->accept();
return true;
}
return QObject::event(e);
} | false | false | false | false | false | 0 |
InitPass1()
{
mMax=0.0;
// Integer format tracks require headroom to avoid clipping
// when saved between passes (bug 619)
if (mbNormalize) // don't need to calculate this if only doing one pass.
{
// Up to (gain + 6dB) headroom required for treble boost (experimental).
mPreGain = (dB_treble > 0)? (dB_treble + 6.0) : 0.0;
if (dB_bass >= 0)
{
mPreGain = (mPreGain > dB_bass)? mPreGain : dB_bass;
} else {
// Up to 6 dB headroom reaquired for bass cut (experimental)
mPreGain = (mPreGain > 6.0)? mPreGain : 6.0;
}
mPreGain = (exp (log(10.0) * mPreGain / 20)); // to linear
} else {
mPreGain = 1.0; // Unity gain
}
if (!mbNormalize)
DisableSecondPass();
return true;
} | false | false | false | false | false | 0 |
urbs_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd);
struct urbp *urbp;
size_t size = 0;
unsigned long flags;
spin_lock_irqsave(&dum_hcd->dum->lock, flags);
list_for_each_entry(urbp, &dum_hcd->urbp_list, urbp_list) {
size_t temp;
temp = show_urb(buf, PAGE_SIZE - size, urbp->urb);
buf += temp;
size += temp;
}
spin_unlock_irqrestore(&dum_hcd->dum->lock, flags);
return size;
} | false | false | false | false | false | 0 |
acpi_sbs_init(void)
{
int result = 0;
if (acpi_disabled)
return -ENODEV;
result = acpi_bus_register_driver(&acpi_sbs_driver);
if (result < 0)
return -ENODEV;
return 0;
} | false | false | false | false | false | 0 |
clutter_pan_action_get_interpolated_coords (ClutterPanAction *self,
gfloat *interpolated_x,
gfloat *interpolated_y)
{
ClutterPanActionPrivate *priv;
g_return_if_fail (CLUTTER_IS_PAN_ACTION (self));
priv = self->priv;
if (interpolated_x)
*interpolated_x = priv->release_x + priv->interpolated_x;
if (interpolated_y)
*interpolated_y = priv->release_y + priv->interpolated_y;
} | false | false | false | false | false | 0 |
refresh_choice(struct choice *c)
{
int w=c->w+BUT_BUTSPACE;
int h=dri.dri_Font->ascent+dri.dri_Font->descent+BUT_VSPACE;
XSetForeground(dpy, gc, dri.dri_Pens[TEXTPEN]);
XDrawString(dpy, c->win, gc, BUT_BUTSPACE/2,
dri.dri_Font->ascent+BUT_VSPACE/2, c->text, c->l);
XSetForeground(dpy, gc, dri.dri_Pens[(c==selected && depressed)?
SHADOWPEN:SHINEPEN]);
XDrawLine(dpy, c->win, gc, 0, 0, w-2, 0);
XDrawLine(dpy, c->win, gc, 0, 0, 0, h-2);
XSetForeground(dpy, gc, dri.dri_Pens[(c==selected && depressed)?
SHINEPEN:SHADOWPEN]);
XDrawLine(dpy, c->win, gc, 1, h-1, w-1, h-1);
XDrawLine(dpy, c->win, gc, w-1, 1, w-1, h-1);
XSetForeground(dpy, gc, dri.dri_Pens[BACKGROUNDPEN]);
XDrawPoint(dpy, c->win, gc, w-1, 0);
XDrawPoint(dpy, c->win, gc, 0, h-1);
} | false | false | false | false | false | 0 |
PyEval_GetLocals(void)
{
PyFrameObject *current_frame = PyEval_GetFrame();
if (current_frame == NULL)
return NULL;
PyFrame_FastToLocals(current_frame);
return current_frame->f_locals;
} | false | false | false | false | false | 0 |
e_int_config_mime_edit_done(void *data)
{
E_Config_Dialog_Data *cfdata;
cfdata = data;
if (!cfdata) return;
if (cfdata->edit_dlg)
cfdata->edit_dlg = NULL;
_tlist_cb_change(cfdata);
} | false | false | false | false | false | 0 |
DeleteItem(unsigned char *data, int len) {
int pos = 0, tag;
while (pos < len) {
item *op;
tag = GetInt_String(data+pos); pos += 4;
op = locate_item(tag);
if (op != NULL) {
remove_item(op);
} else {
LOG(LOG_WARNING, "common::DeleteItem", "Cannot find tag %d", tag);
}
}
if (pos > len) {
LOG(LOG_WARNING, "common::DeleteItem", "Overread buffer: %d > %d", pos, len);
}
} | false | false | false | false | false | 0 |
CheckNewConnection( void ) const
{
tASSERT( IsOpen() );
int available=-1;
// see if the playback has anything to say
//if ( tRecorder::Playback( recordingSectionConnect, available ) )
// return this;
// always return this when recoring or playback are running
if ( tRecorder::IsRunning() )
return this;
#ifdef DEBUG
if ( sn_ResetSocket )
{
sn_ResetSocket = false;
Reset();
}
#endif
// for ( SocketArray::iterator iter = sockets.begin(); iter != sockets.end(); ++iter )
int ret = ioctl (socket_, FIONREAD, &available);
if ( ret == -1)
{
switch ( ANET_Error() )
{
case nSocketError_Reset:
Reset();
break;
case nSocketError_Ignore:
break;
default:
Sys_Error ("UDP: ioctlsocket (FIONREAD) failed\n");
break;
}
}
if ( ret >= 0 )
{
// record result
// tRecorder::Record( recordingSectionConnect, available );
return this;
}
return NULL;
} | false | false | false | false | false | 0 |
notrootedtorooted()
{
node *newbase, *temp;
/* root halfway along leftmost branch of unrooted tree */
/* create a new triad for the new base */
maketemptriad(&newbase,nonodes+1);
/* Take left branch and make it the left branch of newbase */
newbase->next->back = root->next->back;
newbase->next->next->back = root;
/* If needed, divide length between left and right branches */
if (newbase->next->back->haslength) {
newbase->next->back->length /= 2.0;
newbase->next->next->back->length =
newbase->next->back->length;
newbase->next->next->back->haslength = true;
}
/* remove leftmost ring node from old base ring */
temp = root->next->next;
chuck(&grbg, root->next);
root->next = temp;
/* point root at new base and write the tree */
root = newbase;
treeout(root,true,0.0, 0);
/* (since tree mods are to simplified tree and will not be used
for general purpose tree editing, much initialization can be
skipped.) */
} | false | false | false | false | false | 0 |
thread_hash_init(void)
{
int thr_ret;
thr_ret = pthread_key_create (&thread_hash_key, NULL);
g_assert (thr_ret == 0);
thr_ret = pthread_key_create (&thread_attached_key,
thread_attached_exit);
g_assert (thr_ret == 0);
} | false | false | false | false | false | 0 |
nGetMcr2( AT_RANK *nEqArray, AT_RANK n )
{
AT_RANK n1, n2, mcr; /* recursive version is much shorter. */
INCHI_HEAPCHK
n1=nEqArray[(int)n];
if ( n == n1 ) {
return n;
}
/* 1st pass: find mcr */
while ( n1 != (n2=nEqArray[(int)n1])) {
n1 = n2;
}
/* 2nd pass: copy mcr to each element of the set starting from nEqArray[n] */
mcr = n1;
n1 = n;
while ( /*n1*/ mcr != (n2=nEqArray[(int)n1]) ) {
nEqArray[(int)n1]=mcr;
n1 = n2;
}
INCHI_HEAPCHK
return ( mcr );
} | false | false | false | false | false | 0 |
ll_get_or_alloc_list(wp)
win_T *wp;
{
if (IS_LL_WINDOW(wp))
/* For a location list window, use the referenced location list */
return wp->w_llist_ref;
/*
* For a non-location list window, w_llist_ref should not point to a
* location list.
*/
ll_free_all(&wp->w_llist_ref);
if (wp->w_llist == NULL)
wp->w_llist = ll_new_list(); /* new location list */
return wp->w_llist;
} | false | false | false | false | false | 0 |
setToAllocation(void)
{
setWidth(m_MyAllocation.width);
if(fp_VerticalContainer::getHeight() != m_MyAllocation.height)
{
//
// clear and delete broken tables before their height changes.
// Doing this clear at this point makes a table flicker when changing
// height but it does remove the last the pixel dirt with tables.
//
deleteBrokenTables(true,true);
}
setHeight(getTotalTableHeight());
setMaxHeight(getTotalTableHeight());
xxx_UT_DEBUGMSG(("SEVIOR: Height is set to %d \n",m_MyAllocation.height));
fp_CellContainer * pCon = static_cast<fp_CellContainer *>(getNthCon(0));
while(pCon)
{
pCon->setToAllocation();
pCon = static_cast<fp_CellContainer *>(pCon->getNext());
}
pCon = static_cast<fp_CellContainer *>(getNthCon(0));
while(pCon)
{
pCon->setLineMarkers();
pCon->doVertAlign();
pCon = static_cast<fp_CellContainer *>(pCon->getNext());
}
setYBottom(getTotalTableHeight());
} | false | false | false | false | false | 0 |
s_T_kill(KILL_NODE *node, ARTICLE *articles, SUBJECT *subj)
{
long n = 0;
while (subj) {
ARTICLE *thr = subj->thread;
int has_unread = THREAD_HAS_UNREAD(subj);
do {
if (has_unread &&
regexec(node->expr_re, subj->subject, 0, NULL, 0) == 0) {
n += mark_thread_read(subj->thread, False, True);
has_unread = False;
}
subj = subj->next;
} while (subj && subj->thread == thr);
}
return n;
} | false | false | false | false | false | 0 |
expose(XEvent *e) {
Monitor *m;
XExposeEvent *ev = &e->xexpose;
if(ev->count == 0 && (m = wintomon(ev->window)))
drawbar(m);
} | false | false | false | false | false | 0 |
test_links(hid_t fapl)
{
hid_t file; /* File ID */
char obj_name[NAMELEN]; /* Names of the object in group */
ssize_t name_len; /* Length of object's name */
hid_t gid, gid1;
H5G_info_t ginfo; /* Buffer for querying object's info */
hsize_t i;
herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Soft and Hard Link Iteration Functionality\n"));
/* Create the test file with the datasets */
file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
CHECK(file, FAIL, "H5Fcreate");
/* create groups */
gid = H5Gcreate2(file, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(gid, FAIL, "H5Gcreate2");
gid1 = H5Gcreate2(file, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(gid1, FAIL, "H5Gcreate2");
/* create soft and hard links to the group "/g1". */
ret = H5Lcreate_soft("something", gid, "softlink", H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lcreate_soft");
ret = H5Lcreate_hard(gid, "/g1", H5L_SAME_LOC, "hardlink", H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lcreate_hard");
ret = H5Gget_info(gid, &ginfo);
CHECK(ret, FAIL, "H5Gget_info");
VERIFY(ginfo.nlinks, 3, "H5Gget_info");
/* Test these two functions, H5Oget_info_by_idx and H5Lget_name_by_idx */
for(i = 0; i < ginfo.nlinks; i++) {
H5O_info_t oinfo; /* Object info */
H5L_info_t linfo; /* Link info */
/* Get link name */
name_len = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, i, obj_name, (size_t)NAMELEN, H5P_DEFAULT);
CHECK(name_len, FAIL, "H5Lget_name_by_idx");
/* Get link type */
ret = H5Lget_info_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &linfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lget_info_by_idx");
/* Get object type */
if(linfo.type == H5L_TYPE_HARD) {
ret = H5Oget_info_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_idx");
} /* end if */
if(!HDstrcmp(obj_name, "g1.1"))
VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx");
else if(!HDstrcmp(obj_name, "hardlink"))
VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx");
else if(!HDstrcmp(obj_name, "softlink"))
VERIFY(linfo.type, H5L_TYPE_SOFT, "H5Lget_name_by_idx");
else
CHECK(0, 0, "unknown object name");
} /* end for */
ret = H5Gclose(gid);
CHECK(ret, FAIL, "H5Gclose");
ret = H5Gclose(gid1);
CHECK(ret, FAIL, "H5Gclose");
ret = H5Fclose(file);
CHECK(ret, FAIL, "H5Fclose");
} | true | true | true | false | true | 1 |
e_gadcon_popup_new(E_Gadcon_Client *gcc)
{
E_Gadcon_Popup *pop;
Evas_Object *o;
E_Zone *zone;
pop = E_OBJECT_ALLOC(E_Gadcon_Popup, E_GADCON_POPUP_TYPE, _e_gadcon_popup_free);
if (!pop) return NULL;
zone = e_gadcon_client_zone_get(gcc);
pop->win = e_popup_new(zone, 0, 0, 0, 0);
e_popup_layer_set(pop->win, E_LAYER_POPUP);
o = edje_object_add(pop->win->evas);
e_theme_edje_object_set(o, "base/theme/gadman", "e/gadman/popup");
evas_object_show(o);
evas_object_move(o, 0, 0);
e_popup_edje_bg_object_set(pop->win, o);
pop->o_bg = o;
pop->gcc = gcc;
pop->gadcon_lock = 1;
pop->gadcon_was_locked = 0;
return pop;
} | false | false | false | false | false | 0 |
gnutls_pkcs11_reinit (void)
{
int rv;
rv = p11_kit_initialize_registered ();
if (rv != CKR_OK)
{
gnutls_assert ();
_gnutls_debug_log ("Cannot initialize registered module: %s\n",
p11_kit_strerror (rv));
return GNUTLS_E_INTERNAL_ERROR;
}
return 0;
} | false | false | false | false | false | 0 |
nfs_page_group_lock(struct nfs_page *req, bool nonblock)
{
struct nfs_page *head = req->wb_head;
WARN_ON_ONCE(head != head->wb_head);
if (!test_and_set_bit(PG_HEADLOCK, &head->wb_flags))
return 0;
if (!nonblock)
return wait_on_bit_lock(&head->wb_flags, PG_HEADLOCK,
TASK_UNINTERRUPTIBLE);
return -EAGAIN;
} | false | false | false | false | false | 0 |
load_di( const std::string &path, NodeRef dst ) {
// construct list of paths to search
std::string found_path = path;
if (!file_exists(found_path)) {
// in this case, try additional
// paths with the NITRO_DI_PATH var
char *env = getenv ( "NITRO_DI_PATH" );
if (env) {
std::string envpath ( env ); // don't modify env
std::istringstream in ( envpath );
while (in.good()) {
std::getline(in, envpath, ':');
if (!in.bad()) {
found_path = xjoin ( envpath, path );
if (file_exists(found_path)) break;
}
}
} else throw Exception ( PATH_LOOKUP );
}
XmlReader reader ( found_path );
reader.read(dst);
return dst;
} | false | false | false | false | false | 0 |
hash_keyval( char const * key, int const size )
{
unsigned int const magic = 2147059363;
unsigned int hash = 0;
unsigned int i;
for ( i = 0; i < size / sizeof( unsigned int ); ++i )
{
unsigned int val;
memcpy( &val, key, sizeof( unsigned int ) );
hash = hash * magic + val;
key += sizeof( unsigned int );
}
{
unsigned int val = 0;
memcpy( &val, key, size % sizeof( unsigned int ) );
hash = hash * magic + val;
}
return hash + ( hash >> 17 );
} | 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.