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 |
|---|---|---|---|---|---|---|
instantiation( const SubstitutionMap& subst,
const problem_t& problem ) const
{
int n = arity();
if( n == 0 )
return( effect().instantiation( subst, problem ) );
else
{
SubstitutionMap args( subst );
std::vector<ObjectList> arguments( n, ObjectList() );
std::vector<ObjectList::const_iterator> next_arg;
for( int i = 0; i < n; ++i )
{
problem.compatible_objects( arguments[i],
problem.terms().type( parameter(i) ) );
if( arguments[i].empty() ) return( *new ConjunctiveEffect() );
next_arg.push_back( arguments[i].begin() );
}
ConjunctiveEffect* conj = new ConjunctiveEffect();
std::stack<const Effect*> conjuncts;
conjuncts.push( &effect().instantiation( args, problem ) );
for( int i = 0; i < n; )
{
SubstitutionMap pargs;
pargs.insert( std::make_pair( parameter(i), *next_arg[i] ) );
const Effect& conjunct = conjuncts.top()->instantiation( pargs,
problem );
conjuncts.push( &conjunct );
if( i + 1 == n )
{
conj->add_conjunct( conjunct );
for( int j = i; j >= 0; --j )
{
if( j < i ) Effect::unregister_use( conjuncts.top() );
conjuncts.pop();
++next_arg[j];
if( next_arg[j] == arguments[j].end() )
{
if( j == 0 )
{
i = n;
break;
}
else
next_arg[j] = arguments[j].begin();
}
else
{
i = j;
break;
}
}
}
else
{
++i;
}
}
while( !conjuncts.empty() )
{
Effect::unregister_use( conjuncts.top() );
conjuncts.pop();
}
return( *conj );
}
} | false | false | false | false | false | 0 |
gst_rtp_gst_pay_class_init (GstRtpGSTPayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->set_property = gst_rtp_gst_pay_set_property;
gobject_class->get_property = gst_rtp_gst_pay_get_property;
gobject_class->finalize = gst_rtp_gst_pay_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass),
PROP_CONFIG_INTERVAL,
g_param_spec_uint ("config-interval",
"Caps/Tags Send Interval",
"Interval for sending caps and TAG events in seconds (0 = disabled)",
0, 3600, DEFAULT_CONFIG_INTERVAL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
);
gstelement_class->change_state = gst_rtp_gst_pay_change_state;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_gst_pay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_gst_pay_sink_template));
gst_element_class_set_static_metadata (gstelement_class,
"RTP GStreamer payloader", "Codec/Payloader/Network/RTP",
"Payload GStreamer buffers as RTP packets",
"Wim Taymans <wim.taymans@gmail.com>");
gstrtpbasepayload_class->set_caps = gst_rtp_gst_pay_setcaps;
gstrtpbasepayload_class->handle_buffer = gst_rtp_gst_pay_handle_buffer;
gstrtpbasepayload_class->sink_event = gst_rtp_gst_pay_sink_event;
GST_DEBUG_CATEGORY_INIT (gst_rtp_pay_debug, "rtpgstpay", 0,
"rtpgstpay element");
} | false | false | false | false | false | 0 |
awt_create_selection_box(AW_window *aws, const char *awar_prefix,const char *at_prefix,const char *pwd, bool show_dir, bool allow_wildcards)
{
AW_root *aw_root = aws->get_root();
struct adawcbstruct *acbs = new adawcbstruct;
memset(acbs, 0, sizeof(*acbs));
acbs->aws = (AW_window *)aws;
acbs->awr = aw_root;
acbs->pwd = strdup(pwd);
{
char *multiple_dirs_in_pwd = strchr(acbs->pwd, '^');
if (multiple_dirs_in_pwd) {
multiple_dirs_in_pwd[0] = 0;
acbs->pwdx = multiple_dirs_in_pwd+1;
}
else {
acbs->pwdx = 0;
}
}
acbs->show_dir = show_dir;
acbs->def_name = GBS_string_eval(awar_prefix,"*=*/file_name",0);
acbs->previous_filename = 0;
acbs->leave_wildcards = allow_wildcards;
aw_root->awar(acbs->def_name)->add_callback((AW_RCB1)awt_selection_box_changed_filename,(AW_CL)acbs);
acbs->def_dir = GBS_string_eval(awar_prefix,"*=*/directory",0);
aw_root->awar(acbs->def_dir)->add_callback((AW_RCB1)awt_create_selection_box_cb,(AW_CL)acbs);
acbs->def_filter = GBS_string_eval(awar_prefix,"*=*/filter",0);
aw_root->awar(acbs->def_filter)->add_callback((AW_RCB1)awt_create_selection_box_changed_filter,(AW_CL)acbs);
aw_root->awar(acbs->def_filter)->add_callback((AW_RCB1)awt_selection_box_changed_filename,(AW_CL)acbs);
aw_root->awar(acbs->def_filter)->add_callback((AW_RCB1)awt_create_selection_box_cb,(AW_CL)acbs);
char buffer[1024];
sprintf(buffer,"%sfilter",at_prefix);
if (aws->at_ifdef(buffer)){
aws->at(buffer);
aws->create_input_field(acbs->def_filter,5);
}
sprintf(buffer,"%sfile_name",at_prefix);
if (aws->at_ifdef(buffer)){
aws->at(buffer);
aws->create_input_field(acbs->def_name,20);
}
sprintf(buffer,"%sbox",at_prefix);
aws->at(buffer);
acbs->id = aws->create_selection_list(acbs->def_name,0,"",2,2);
awt_create_selection_box_cb(0,acbs);
awt_selection_box_changed_filename(0, acbs); // this fixes the path name
awt_selbox_install_autorefresh(acbs);
} | false | false | false | false | false | 0 |
edit_startup(File *file)
{
int chg1 = False, chg2 = False;
if (mod_usebg &&
(delstr(file, "\n"
"PIDFILE=/var/run/kdmdesktop-$DISPLAY.pid\n"
"if [[] -f $PIDFILE ] ; then\n"
" kill `cat $PIDFILE`\n"
"fi\n") ||
delstr(file, "\n"
"PIDFILE=/var/run/kdmdesktop-$DISPLAY.pid\n"
"test -f $PIDFILE && kill `cat $PIDFILE`\n")))
chg1 = True;
if (oldver < 0x0203) {
chg2 =
#ifdef _AIX
delstr(file, "\n"
"# We create a pseudodevice for finger. (host:0 becomes [kx]dm/host_0)\n");
"# Without it, finger errors out with \"Cannot stat /dev/host:0\".\n"
"#\n"
"if [[] -f /usr/lib/X11/xdm/sessreg ]; then\n"
" devname=`echo $DISPLAY | /usr/bin/sed -e 's/[[]:\\.]/_/g' | /usr/bin/cut -c1-8`\n"
" hostname=`echo $DISPLAY | /usr/bin/cut -d':' -f1`\n"
"\n"
" if [[] -z \"$devname\" ]; then\n"
" devname=\"unknown\"\n"
" fi\n"
" if [[] ! -d /dev/[kx]dm ]; then\n"
" /usr/bin/mkdir /dev/[kx]dm\n"
" /usr/bin/chmod 755 /dev/[kx]dm\n"
" fi\n"
" /usr/bin/touch /dev/[kx]dm/$devname\n"
" /usr/bin/chmod 644 /dev/[kx]dm/$devname\n"
"\n"
" if [[] -z \"$hostname\" ]; then\n"
" exec /usr/lib/X11/xdm/sessreg -a -l [kx]dm/$devname $USER\n"
" else\n"
" exec /usr/lib/X11/xdm/sessreg -a -l [kx]dm/$devname -h $hostname $USER\n"
" fi\n"
"fi\n") |
#else
# ifdef BSD
delstr(file, "\n"
"exec sessreg -a -l $DISPLAY -x */Xservers -u " _PATH_UTMP " $USER\n") |
# endif
#endif /* _AIX */
delstr(file, "\n"
"exec sessreg -a -l $DISPLAY"
#ifdef BSD
" -x */Xservers"
#endif
" $USER\n") |
delstr(file, "\n"
"exec sessreg -a -l $DISPLAY -u /var/run/utmp -x */Xservers $USER\n");
putVal("UseSessReg", chg2 ? "true" : "false");
}
return chg1 | chg2;
} | false | false | false | false | false | 0 |
entry_find_oldest(void *data, void *cookie)
{
struct cache_entry *entry = (struct cache_entry *) data;
struct cache_entry **oldest = (struct cache_entry **) cookie;
if (*oldest == NULL) {
*oldest = entry;
return;
}
if (entry->data->refcount > (*oldest)->data->refcount)
return;
if (entry->lastused > (*oldest)->lastused)
return;
*oldest = data;
} | false | false | false | false | false | 0 |
ui_draw_status(char *filename,char *misc,
char *author,int track,char *playingstr)
{
static gchar buf[256];
char *ptr=strrchr(filename,'/');
int tbl_row=0;
if(!window) return;
gtk_label_set_text(GTK_LABEL(detaillabel[tbl_row]),ptr?ptr+1:filename);
tbl_row++;
gtk_label_set_text(GTK_LABEL(detaillabel[tbl_row]),misc);
tbl_row++;
gtk_label_set_text(GTK_LABEL(detaillabel[tbl_row]),author);
tbl_row++;
g_snprintf(buf,sizeof(buf),"%d",aydata.num_tracks);
gtk_label_set_text(GTK_LABEL(detaillabel[tbl_row]),buf);
tbl_row++;
g_snprintf(buf,sizeof(buf),"%d - %s",track,playingstr);
gtk_label_set_text(GTK_LABEL(detaillabel[tbl_row]),buf);
gtk_label_set_text(GTK_LABEL(label_for_status),
paused?"paused ":(playing?"playing":"stopped"));
if(!stopafter)
gtk_label_set_text(GTK_LABEL(label_for_stopafter),"--:--");
else
{
g_snprintf(buf,sizeof(buf),"%2d:%02d",stopafter/60,stopafter%60);
gtk_label_set_text(GTK_LABEL(label_for_stopafter),buf);
}
g_snprintf(buf,sizeof(buf),"%2d sec",fadetime);
gtk_label_set_text(GTK_LABEL(label_for_fadetime),buf);
} | false | false | false | false | false | 0 |
addFilters(Object *dict, int recursion) {
Object obj, obj2;
Object params, params2;
Stream *str;
int i;
str = this;
dict->dictLookup("Filter", &obj, recursion);
if (obj.isNull()) {
obj.free();
dict->dictLookup("F", &obj);
}
dict->dictLookup("DecodeParms", ¶ms, recursion);
if (params.isNull()) {
params.free();
dict->dictLookup("DP", ¶ms);
}
if (obj.isName()) {
str = makeFilter(obj.getName(), str, ¶ms, recursion, dict);
} else if (obj.isArray()) {
for (i = 0; i < obj.arrayGetLength(); ++i) {
obj.arrayGet(i, &obj2, recursion);
if (params.isArray())
params.arrayGet(i, ¶ms2, recursion);
else
params2.initNull();
if (obj2.isName()) {
str = makeFilter(obj2.getName(), str, ¶ms2, recursion);
} else {
error(errSyntaxError, getPos(), "Bad filter name");
str = new EOFStream(str);
}
obj2.free();
params2.free();
}
} else if (!obj.isNull()) {
error(errSyntaxError, getPos(), "Bad 'Filter' attribute in stream");
}
obj.free();
params.free();
return str;
} | false | false | false | false | false | 0 |
SUBR_neg(ushort code)
{
static void *jump[] = {
&&__VARIANT, &&__BOOLEAN, &&__BYTE, &&__SHORT, &&__INTEGER, &&__LONG, &&__SINGLE, &&__FLOAT, &&__ERROR
};
VALUE *P1;
TYPE type;
P1 = SP - 1;
type = code & 0x0F;
goto *jump[type];
__BOOLEAN:
return;
__BYTE:
P1->_integer.value = (unsigned char)(-P1->_integer.value); return;
__SHORT:
P1->_integer.value = (short)(-P1->_integer.value); return;
__INTEGER:
P1->_integer.value = (-P1->_integer.value); return;
__LONG:
P1->_long.value = (-P1->_long.value); return;
__SINGLE:
P1->_single.value = (-P1->_single.value); return;
__FLOAT:
P1->_float.value = (-P1->_float.value); return;
__VARIANT:
MANAGE_VARIANT(SUBR_neg);
__ERROR:
THROW(E_TYPE, "Number", TYPE_get_name(type));
} | false | false | false | false | false | 0 |
stp_escp2_get_media_type(const stp_vars_t *v, int ignore_res)
{
stpi_escp2_printer_t *printdef = stp_escp2_get_printer(v);
const stp_string_list_t *p = printdef->papers;
if (p)
{
const char *name = stp_get_string_parameter(v, "MediaType");
if (name)
return get_media_type_named(v, name, ignore_res);
}
return NULL;
} | false | false | false | false | false | 0 |
nextipage ( IFILE *f, int dp )
{
int err=0 ;
char *message ;
#ifdef ENABLE_NLS
gsize written = 0 ;
char *conv_fname ;
#endif
int ( *reset [NPFORMATS] ) ( IFILE * ) = {
raw_reset, fax_reset, pbm_reset, text_reset, pcx_reset
}, (*pf)(IFILE*) ;
/* close current file if any and set to NULL */
if ( f->f ) {
fclose ( f->f ) ;
f->f = 0 ;
}
/* if requested, point to next page and check if done */
if ( dp ) {
f->page++ ;
}
if ( f->page > f->lastpage ) {
err = 1 ;
}
/* open the file and seek to start of image data */
if ( ! err ) {
f->f = fopen ( f->page->fname, (f->page->format == P_TEXT) ? "r" : "rb" ) ;
if ( ! f->f ) {
message = strdup2 ( "ES2 ", gettext ( "can't open file %s:" ) ) ;
if ( message ) {
#ifdef ENABLE_NLS
if ( use_utf8 && !g_utf8_validate ( f->page->fname, -1, NULL ) ) {
conv_fname = g_filename_to_utf8 ( f->page->fname, -1, NULL, &written, NULL ) ;
if ( conv_fname ) {
err = msg ( message, conv_fname ) ;
g_free ( conv_fname ) ;
}
} else {
err = msg ( message, f->page->fname ) ;
}
#else
err = msg ( message, f->page->fname ) ;
#endif
free ( message ) ;
}
}
}
if ( ! err && fseek ( f->f, f->page->offset, SEEK_SET ) )
err = msg ( "ES2 seek failed" ) ;
/* default initializations */
f->lines = f->page->h ;
/* coding-specific initializations for this page */
if ( ! err ) {
pf = reset[f->page->format] ;
if ( pf )
err = (*pf)(f) ;
}
return err ;
} | false | false | false | false | true | 1 |
nss_SetError ( PRUint32 error)
{
error_stack *es;
if( 0 == error ) {
nss_ClearErrorStack();
return;
}
es = error_get_my_stack();
if( (error_stack *)NULL == es ) {
/* Oh, well. */
return;
}
if (es->header.count < es->header.space) {
es->stack[ es->header.count++ ] = error;
} else {
memmove(es->stack, es->stack + 1,
(es->header.space - 1) * (sizeof es->stack[0]));
es->stack[ es->header.space - 1 ] = error;
}
return;
} | false | false | false | false | true | 1 |
VehicleTypeSelectionItemFactory( Resources plantResources, const Container& types, const Player& player )
: actplayer(player), showResourcesForUnit(true), original_items( types )
{
restart();
setAvailableResource( plantResources );
} | false | false | false | false | false | 0 |
_PyLong_NumBits(PyObject *vv)
{
PyLongObject *v = (PyLongObject *)vv;
size_t result = 0;
Py_ssize_t ndigits;
assert(v != NULL);
assert(PyLong_Check(v));
ndigits = ABS(Py_SIZE(v));
assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0);
if (ndigits > 0) {
digit msd = v->ob_digit[ndigits - 1];
if ((size_t)(ndigits - 1) > PY_SIZE_MAX / (size_t)PyLong_SHIFT)
goto Overflow;
result = (size_t)(ndigits - 1) * (size_t)PyLong_SHIFT;
do {
++result;
if (result == 0)
goto Overflow;
msd >>= 1;
} while (msd);
}
return result;
Overflow:
PyErr_SetString(PyExc_OverflowError, "int has too many bits "
"to express in a platform size_t");
return (size_t)-1;
} | false | false | false | false | false | 0 |
drm_bridge_mode_set(struct drm_bridge *bridge,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
if (!bridge)
return;
if (bridge->funcs->mode_set)
bridge->funcs->mode_set(bridge, mode, adjusted_mode);
drm_bridge_mode_set(bridge->next, mode, adjusted_mode);
} | false | false | false | false | false | 0 |
gst_base_video_decoder_get_frame (GstBaseVideoDecoder * base_video_decoder,
int frame_number)
{
GList *g;
GstVideoFrame *frame = NULL;
GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
for (g = g_list_first (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames);
g; g = g_list_next (g)) {
GstVideoFrame *tmp = g->data;
if (frame->system_frame_number == frame_number) {
frame = tmp;
break;
}
}
GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
return frame;
} | false | false | false | true | false | 1 |
recent(I,resp,wt,p,s,x)
double *I, *resp, *wt, x;
INT p, s;
{ INT i, j;
/* first, use W taylor series I -> resp */
for (i=0; i<=p; i++)
{ resp[i] = 0.0;
for (j=0; j<s; j++) resp[i] += wt[j]*I[i+j];
}
/* now, recenter x -> 0 */
if (x==0) return;
for (j=0; j<=p; j++) for (i=p; i>j; i--) resp[i] += x*resp[i-1];
} | false | false | false | false | false | 0 |
CMod_LoadLeafBrushes (lump_t *l)
{
int i;
unsigned short *out;
unsigned short *in;
int count;
in = (void *)(cmod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Com_Error (ERR_DROP, "CMod_LoadLeafBrushes: funny lump size");
count = l->filelen / sizeof(*in);
if (count < 1)
Com_Error (ERR_DROP, "Map with no leafbrushes");
// need to save space for box planes
if (count > MAX_MAP_LEAFBRUSHES)
Com_Error (ERR_DROP, "Map has too many leafbrushes");
out = map_leafbrushes;
numleafbrushes = count;
for ( i=0 ; i<count ; i++, in++, out++)
*out = LittleShort (*in);
} | false | false | false | false | false | 0 |
perspectiveMessCallback(void *data, t_symbol *, int argc, t_atom *argv)
{
if (argc != 6)
{
GetMyClass(data)->error("perspec message needs 6 arguments");
return;
}
GemMan::m_perspect[0] = atom_getfloat(&argv[0]); // left
GemMan::m_perspect[1] = atom_getfloat(&argv[1]); // right
GemMan::m_perspect[2] = atom_getfloat(&argv[2]); // bottom
GemMan::m_perspect[3] = atom_getfloat(&argv[3]); // top
GemMan::m_perspect[4] = atom_getfloat(&argv[4]); // front
GemMan::m_perspect[5] = atom_getfloat(&argv[5]); // back
} | false | false | false | false | false | 0 |
Process(void)
{
if (g_parser)
{
g_parser->Close();
if (!g_parser->Open(g_strPort.c_str()))
{
PrintToStdOut("Failed to reconnect\n");
g_bExit = true;
}
}
return NULL;
} | false | false | false | false | false | 0 |
session_query_cname(dns_session_t *session, dns_msg_question_t *q, dns_cache_rrset_t *rrset, int nlevel)
{
dns_cache_res_t *cache;
dns_cache_rrset_t *rr_cname;
dns_config_zone_t *zone;
dns_msg_question_t q_cname;
if (nlevel > DNS_CNAME_NEST_MAX) {
plog(LOG_DEBUG, "%s: CNAME nested too deep", MODULE);
return;
}
/* we don't support multiple-cnames */
if ((cache = DNS_CACHE_LIST_HEAD(&rrset->rrset_list_cname)) == NULL)
return;
memcpy(&q_cname, q, sizeof(q_cname));
dns_msg_parse_name(q_cname.mq_name, &cache->cache_res);
memcpy(&session->sess_qlast, &q_cname, sizeof(q_cname));
if ((zone = dns_config_find_zone(&session->sess_zone_exact,
q_cname.mq_name, q_cname.mq_class)) == NULL) {
session->sess_iflags |= SESSION_NO_NEGCACHE;
return;
}
plog(LOG_DEBUG, "%s: restart query for CNAME: %s", MODULE, q_cname.mq_name);
if ((rr_cname = session_query_recursive(session, zone, &q_cname, nlevel)) != NULL) {
plog(LOG_DEBUG, "%s: %d answers for CNAME", MODULE, dns_list_count(&rr_cname->rrset_list_answer));
dns_cache_merge(rrset, q, rr_cname, &session->sess_tls);
dns_cache_release(rr_cname, &session->sess_tls);
}
} | false | true | false | false | false | 1 |
gallop_right(PyObject *key, PyObject **a, Py_ssize_t n, Py_ssize_t hint)
{
Py_ssize_t ofs;
Py_ssize_t lastofs;
Py_ssize_t k;
assert(key && a && n > 0 && hint >= 0 && hint < n);
a += hint;
lastofs = 0;
ofs = 1;
IFLT(key, *a) {
/* key < a[hint] -- gallop left, until
* a[hint - ofs] <= key < a[hint - lastofs]
*/
const Py_ssize_t maxofs = hint + 1; /* &a[0] is lowest */
while (ofs < maxofs) {
IFLT(key, *(a-ofs)) {
lastofs = ofs;
ofs = (ofs << 1) + 1;
if (ofs <= 0) /* int overflow */
ofs = maxofs;
}
else /* a[hint - ofs] <= key */
break;
}
if (ofs > maxofs)
ofs = maxofs;
/* Translate back to positive offsets relative to &a[0]. */
k = lastofs;
lastofs = hint - ofs;
ofs = hint - k;
}
else {
/* a[hint] <= key -- gallop right, until
* a[hint + lastofs] <= key < a[hint + ofs]
*/
const Py_ssize_t maxofs = n - hint; /* &a[n-1] is highest */
while (ofs < maxofs) {
IFLT(key, a[ofs])
break;
/* a[hint + ofs] <= key */
lastofs = ofs;
ofs = (ofs << 1) + 1;
if (ofs <= 0) /* int overflow */
ofs = maxofs;
}
if (ofs > maxofs)
ofs = maxofs;
/* Translate back to offsets relative to &a[0]. */
lastofs += hint;
ofs += hint;
}
a -= hint;
assert(-1 <= lastofs && lastofs < ofs && ofs <= n);
/* Now a[lastofs] <= key < a[ofs], so key belongs somewhere to the
* right of lastofs but no farther right than ofs. Do a binary
* search, with invariant a[lastofs-1] <= key < a[ofs].
*/
++lastofs;
while (lastofs < ofs) {
Py_ssize_t m = lastofs + ((ofs - lastofs) >> 1);
IFLT(key, a[m])
ofs = m; /* key < a[m] */
else
lastofs = m+1; /* a[m] <= key */
}
assert(lastofs == ofs); /* so a[ofs-1] <= key < a[ofs] */
return ofs;
fail:
return -1;
} | false | false | false | false | false | 0 |
vmspphot_create(cpl_plugin *plugin)
{
cpl_recipe *recipe = (cpl_recipe *)plugin;
cpl_parameter *p;
cxint status = 0;
/*
* Create the list of options we accept and hook it into the
* recipe interface.
*/
recipe->parameters = cpl_parameterlist_new();
if (recipe->parameters == NULL) {
return 1;
}
/*
* Fill the parameter list
*/
p = cpl_parameter_new_value("vimos.Parameters.flux.response",
CPL_TYPE_BOOL,
"Apply instrument response.",
"vimos.Parameters",
TRUE);
cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ApplyResponse");
cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "ApplyResponse");
cpl_parameterlist_append(recipe->parameters, p);
/*
* Initialize the VIMOS recipe subsystems (configuration data base,
* alias tables, messaging facilities) from the current CPL setup.
*/
status = vmCplRecipeStart(cpl_plugin_get_name(plugin), VERSION);
if (status) {
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
cache_user_id( KBNODE keyblock )
{
user_id_db_t r;
const char *uid;
size_t uidlen;
keyid_list_t keyids = NULL;
KBNODE k;
for (k=keyblock; k; k = k->next ) {
if ( k->pkt->pkttype == PKT_PUBLIC_KEY
|| k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
keyid_list_t a = xmalloc_clear ( sizeof *a );
/* Hmmm: For a long list of keyids it might be an advantage
* to append the keys */
keyid_from_pk( k->pkt->pkt.public_key, a->keyid );
/* first check for duplicates */
for(r=user_id_db; r; r = r->next ) {
keyid_list_t b = r->keyids;
for ( b = r->keyids; b; b = b->next ) {
if( b->keyid[0] == a->keyid[0]
&& b->keyid[1] == a->keyid[1] ) {
if( DBG_CACHE )
log_debug("cache_user_id: already in cache\n");
release_keyid_list ( keyids );
xfree ( a );
return;
}
}
}
/* now put it into the cache */
a->next = keyids;
keyids = a;
}
}
if ( !keyids )
BUG (); /* No key no fun */
uid = get_primary_uid ( keyblock, &uidlen );
if( uid_cache_entries >= MAX_UID_CACHE_ENTRIES ) {
/* fixme: use another algorithm to free some cache slots */
r = user_id_db;
user_id_db = r->next;
release_keyid_list ( r->keyids );
xfree(r);
uid_cache_entries--;
}
r = xmalloc( sizeof *r + uidlen-1 );
r->keyids = keyids;
r->len = uidlen;
memcpy(r->name, uid, r->len);
r->next = user_id_db;
user_id_db = r;
uid_cache_entries++;
} | false | false | false | false | false | 0 |
areBlanks(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
int blank_chars) {
int i, ret;
xmlNodePtr lastChild;
/*
* Don't spend time trying to differentiate them, the same callback is
* used !
*/
if (ctxt->sax->ignorableWhitespace == ctxt->sax->characters)
return(0);
/*
* Check for xml:space value.
*/
if ((ctxt->space == NULL) || (*(ctxt->space) == 1) ||
(*(ctxt->space) == -2))
return(0);
/*
* Check that the string is made of blanks
*/
if (blank_chars == 0) {
for (i = 0;i < len;i++)
if (!(IS_BLANK_CH(str[i]))) return(0);
}
/*
* Look if the element is mixed content in the DTD if available
*/
if (ctxt->node == NULL) return(0);
if (ctxt->myDoc != NULL) {
ret = xmlIsMixedElement(ctxt->myDoc, ctxt->node->name);
if (ret == 0) return(1);
if (ret == 1) return(0);
}
/*
* Otherwise, heuristic :-\
*/
if ((RAW != '<') && (RAW != 0xD)) return(0);
if ((ctxt->node->children == NULL) &&
(RAW == '<') && (NXT(1) == '/')) return(0);
lastChild = xmlGetLastChild(ctxt->node);
if (lastChild == NULL) {
if ((ctxt->node->type != XML_ELEMENT_NODE) &&
(ctxt->node->content != NULL)) return(0);
} else if (xmlNodeIsText(lastChild))
return(0);
else if ((ctxt->node->children != NULL) &&
(xmlNodeIsText(ctxt->node->children)))
return(0);
return(1);
} | false | false | false | false | false | 0 |
yuv_bgr24_c(SHORTLINEARGS)
{
const yuv* s = (const yuv*) src;
col* d = (col*) dest;
while (w--)
*d++ = *s++;
} | false | false | false | false | false | 0 |
test_threaded_job_successful (void)
{
UDisksThreadedJob *job;
job = udisks_threaded_job_new (threaded_job_successful_func, NULL, NULL, NULL, NULL);
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_success), NULL);
g_object_unref (job);
} | false | false | false | false | false | 0 |
make_object_born (ira_object_t obj)
{
live_range_t lr = OBJECT_LIVE_RANGES (obj);
sparseset_set_bit (objects_live, OBJECT_CONFLICT_ID (obj));
IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj), hard_regs_live);
IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), hard_regs_live);
if (lr == NULL
|| (lr->finish != curr_point && lr->finish + 1 != curr_point))
ira_add_live_range_to_object (obj, curr_point, -1);
} | false | false | false | false | false | 0 |
gar_lbl_init_obj_counts(struct gar_subfile *sub, struct hdr_lbl_t *lbl)
{
if (lbl->lbl2_rec_size)
sub->lbl_countries = lbl->lbl2_length/lbl->lbl2_rec_size;
if (lbl->lbl3_rec_size)
sub->lbl_regions = lbl->lbl3_length/lbl->lbl3_rec_size;
if (lbl->lbl4_rec_size)
sub->lbl_cities = lbl->lbl4_length/lbl->lbl4_rec_size;
if (lbl->lbl8_rec_size)
sub->lbl_zips = lbl->lbl8_length/lbl->lbl8_rec_size;
log(1, "Have %d countries, %d regions, %d cities, %d zip codes\n",
sub->lbl_countries, sub->lbl_regions,
sub->lbl_cities, sub->lbl_zips);
return 0;
} | false | false | false | false | false | 0 |
ptaaAddPta(PTAA *ptaa,
PTA *pta,
l_int32 copyflag)
{
l_int32 n;
PTA *ptac;
PROCNAME("ptaaAddPta");
if (!ptaa)
return ERROR_INT("ptaa not defined", procName, 1);
if (!pta)
return ERROR_INT("pta not defined", procName, 1);
if (copyflag == L_INSERT) {
ptac = pta;
} else if (copyflag == L_COPY) {
if ((ptac = ptaCopy(pta)) == NULL)
return ERROR_INT("ptac not made", procName, 1);
} else if (copyflag == L_CLONE) {
if ((ptac = ptaClone(pta)) == NULL)
return ERROR_INT("pta clone not made", procName, 1);
} else {
return ERROR_INT("invalid copyflag", procName, 1);
}
n = ptaaGetCount(ptaa);
if (n >= ptaa->nalloc)
ptaaExtendArray(ptaa);
ptaa->pta[n] = ptac;
ptaa->n++;
return 0;
} | false | false | false | false | false | 0 |
storeRegToStackSlot(MachineBasicBlock &MBB,
MachineBasicBlock::iterator MI,
unsigned SrcReg, bool isKill, int FrameIdx,
const TargetRegisterClass *RC,
const TargetRegisterInfo *TRI) const {
DebugLoc DL;
if (MI != MBB.end()) DL = MI->getDebugLoc();
MachineFunction &MF = *MBB.getParent();
MachineFrameInfo &MFI = *MF.getFrameInfo();
MachineMemOperand *MMO = MF.getMachineMemOperand(
MachinePointerInfo::getFixedStack(MF, FrameIdx),
MachineMemOperand::MOStore, MFI.getObjectSize(FrameIdx),
MFI.getObjectAlignment(FrameIdx));
if (RC == &MSP430::GR16RegClass)
BuildMI(MBB, MI, DL, get(MSP430::MOV16mr))
.addFrameIndex(FrameIdx).addImm(0)
.addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO);
else if (RC == &MSP430::GR8RegClass)
BuildMI(MBB, MI, DL, get(MSP430::MOV8mr))
.addFrameIndex(FrameIdx).addImm(0)
.addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO);
else
llvm_unreachable("Cannot store this register to stack slot!");
} | false | false | false | false | false | 0 |
Cns_insert_lnk_entry(dbfd, lnk_entry)
struct Cns_dbfd *dbfd;
struct Cns_symlinks *lnk_entry;
{
char escaped_name[CA_MAXPATHLEN*2+1];
char fileid_str[21];
char func[21];
static char insert_stmt[] =
"INSERT INTO Cns_symlinks \
(FILEID, LINKNAME) \
VALUES \
(%s, '%s')";
PGresult *res;
char sql_stmt[2130];
strcpy (func, "Cns_insert_lnk_entry");
PQescapeStringConn (dbfd->Pconn, escaped_name, lnk_entry->linkname,
strlen (lnk_entry->linkname), NULL);
sprintf (sql_stmt, insert_stmt,
u64tostr (lnk_entry->fileid, fileid_str, -1), escaped_name);
res = PQexec (dbfd->Pconn, sql_stmt);
if (PQresultStatus (res) != PGRES_COMMAND_OK) {
if (strstr (PQresultErrorMessage (res), "duplicate")) {
serrno = EEXIST;
PQclear (res);
} else
Cns_libpq_error (func, "INSERT", res, dbfd);
return (-1);
}
PQclear (res);
return (0);
} | false | false | false | false | false | 0 |
at76_config(struct ieee80211_hw *hw, u32 changed)
{
struct at76_priv *priv = hw->priv;
at76_dbg(DBG_MAC80211, "%s(): channel %d",
__func__, hw->conf.chandef.chan->hw_value);
at76_dbg_dump(DBG_MAC80211, priv->bssid, ETH_ALEN, "bssid:");
mutex_lock(&priv->mtx);
priv->channel = hw->conf.chandef.chan->hw_value;
if (is_valid_ether_addr(priv->bssid))
at76_join(priv);
else
at76_start_monitor(priv);
mutex_unlock(&priv->mtx);
return 0;
} | false | false | false | false | false | 0 |
add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind,
const char *lbl_id)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
if (dwarf_split_debug_info)
attr.dw_attr_val.val_entry
= add_addr_table_entry (attr.dw_attr_val.v.val_lbl_id,
ate_kind_label);
add_dwarf_attr (die, &attr);
} | false | false | false | false | false | 0 |
AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
{
u_long flags;
switch (mt) {
case CARD_RESET:
spin_lock_irqsave(&cs->lock, flags);
byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, 0x00);
HZDELAY(HZ / 5 + 1);
byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, ASL0_W_RESET);
HZDELAY(HZ / 5 + 1);
byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, 0x00);
spin_unlock_irqrestore(&cs->lock, flags);
return 0;
case CARD_RELEASE:
/* free_irq is done in HiSax_closecard(). */
/* free_irq(cs->irq, cs); */
return 0;
case CARD_INIT:
spin_lock_irqsave(&cs->lock, flags);
byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, ASL0_W_TDISABLE | ASL0_W_TRESET | ASL0_W_IRQENABLE);
clear_pending_isac_ints(cs);
clear_pending_hscx_ints(cs);
inithscxisac(cs, 1);
inithscxisac(cs, 2);
spin_unlock_irqrestore(&cs->lock, flags);
return 0;
case CARD_TEST:
/* we really don't need it for the PCMCIA Version */
return 0;
default:
/* all card drivers ignore others, so we do the same */
return 0;
}
return 0;
} | false | false | false | false | false | 0 |
shared_open (ACE_SOCK_SEQPACK_Association &new_association,
int protocol_family,
int protocol,
int reuse_addr)
{
ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::shared_open");
// Only open a new socket if we don't already have a valid handle.
if (new_association.get_handle () == ACE_INVALID_HANDLE &&
#if defined (ACE_HAS_LKSCTP)
new_association.open (SOCK_STREAM,
#else
new_association.open (SOCK_SEQPACKET,
#endif /* ACE_HAS_LKSCTP */
protocol_family,
protocol,
reuse_addr) == -1)
return -1;
else
return 0;
} | false | false | false | false | false | 0 |
vStoreChar(ULONG ulChar, BOOL bChangeAllowed, output_type *pOutput)
{
char szResult[4];
size_t tIndex, tLen;
fail(pOutput == NULL);
if (tOptions.eEncoding == encoding_utf_8 && bChangeAllowed) {
DBG_HEX_C(ulChar > 0xffff, ulChar);
fail(ulChar > 0xffff);
tLen = tUcs2Utf8(ulChar, szResult, sizeof(szResult));
for (tIndex = 0; tIndex < tLen; tIndex++) {
vStoreByte((UCHAR)szResult[tIndex], pOutput);
}
} else {
DBG_HEX_C(ulChar > 0xff, ulChar);
fail(ulChar > 0xff);
vStoreByte((UCHAR)ulChar, pOutput);
tLen = 1;
}
pOutput->lStringWidth += lComputeStringWidth(
pOutput->szStorage + pOutput->tNextFree - tLen,
tLen,
pOutput->tFontRef,
pOutput->usFontSize);
} | false | false | false | false | false | 0 |
put_directory(const char *dirname, const char *remotedirname, struct work_queue *q, struct work_queue_worker *w, int taskid, INT64_T * total_bytes, int flags) {
DIR *dir = opendir(dirname);
if(!dir)
return 0;
struct dirent *file;
char buffer[WORK_QUEUE_LINE_MAX];
char *localname, *remotename;
int result;
struct stat local_info;
if(stat(dirname, &local_info) < 0)
return 0;
/* normalize the mode so as not to set up invalid permissions */
local_info.st_mode |= 0700;
local_info.st_mode &= 0777;
// When putting a file its parent directories are automatically
// created by the worker, so no need to manually create them.
while((file = readdir(dir))) {
char *filename = file->d_name;
if(!strcmp(filename, ".") || !strcmp(filename, "..")) {
continue;
}
*buffer = '\0';
sprintf(buffer, "%s/%s", dirname, filename);
localname = xxstrdup(buffer);
*buffer = '\0';
sprintf(buffer, "%s/%s", remotedirname, filename);
remotename = xxstrdup(buffer);
if(stat(localname, &local_info) < 0) {
closedir(dir);
return 0;
}
if(local_info.st_mode & S_IFDIR) {
result = put_directory(localname, remotename, q, w, taskid, total_bytes, flags);
} else {
result = put_file(localname, remotename, 0, 0, q, w, taskid, total_bytes, flags);
}
if(result == 0) {
closedir(dir);
return 0;
}
free(localname);
free(remotename);
}
closedir(dir);
return 1;
} | true | true | false | false | false | 1 |
process_pipe_term ()
{
if (endpoint)
endpoint->detach_outpipe (this);
reader_t *p = peer;
peer = NULL;
send_pipe_term_ack (p);
} | false | false | false | false | false | 0 |
allRowsForTrack( const Meta::TrackPtr& track ) const
{
QSet<int> proxyModelRows;
foreach( int sourceModelRow, m_belowModel->allRowsForTrack( track ) )
{
int proxyModelRow = rowFromSource( sourceModelRow );
if ( proxyModelRow != -1 )
proxyModelRows.insert( proxyModelRow );
}
return proxyModelRows;
} | false | false | false | false | false | 0 |
print_usage(char *argv0, int print_level)
{
int c;
printf("Usage: %s [--version] [--print-config] [--help] [--long-help] [options] [config files]\n\n",
argv0);
printf("Options:\n");
for (c = 0; config_names[c].name != NULL; c++) {
if (config_names[c].long_only > print_level)
continue;
printf(" %s %s\n", (config_names[c].option == NULL ?
"(configfile only option)" : config_names[c].option),
((config_names[c].type == NULL || config_names[c].option == NULL) ?
"" : config_names[c].type));
print_desc(" ", config_names[c].desc);
if (config_names[c].get_def != NULL)
printf(" Default: %s\n", config_names[c].get_def());
printf(" conf-variable: %s%s\n", config_names[c].name,
(config_names[c].type == NULL ? "" : config_names[c].type));
printf("\n");
}
if (!print_level)
printf("Use --long-help to see all options\n\n");
printf("Report bugs to vpnc@unix-ag.uni-kl.de\n");
} | false | false | false | false | false | 0 |
timblogiw_enuminput(struct file *file, void *priv,
struct v4l2_input *inp)
{
struct video_device *vdev = video_devdata(file);
int i;
dev_dbg(&vdev->dev, "%s: Entry\n", __func__);
if (inp->index != 0)
return -EINVAL;
inp->index = 0;
strncpy(inp->name, "Timb input 1", sizeof(inp->name) - 1);
inp->type = V4L2_INPUT_TYPE_CAMERA;
inp->std = 0;
for (i = 0; i < ARRAY_SIZE(timblogiw_tvnorms); i++)
inp->std |= timblogiw_tvnorms[i].std;
return 0;
} | false | false | false | false | false | 0 |
set_grid()
{
TBOOLEAN explicit_change = FALSE;
c_token++;
#define GRID_MATCH(axis, string) \
if (almost_equals(c_token, string+2)) { \
if (string[2] == 'm') \
axis_array[axis].gridminor = TRUE; \
else \
axis_array[axis].gridmajor = TRUE; \
explicit_change = TRUE; \
++c_token; \
} else if (almost_equals(c_token, string)) { \
if (string[2] == 'm') \
axis_array[axis].gridminor = FALSE; \
else \
axis_array[axis].gridmajor = FALSE; \
explicit_change = TRUE; \
++c_token; \
}
while (!END_OF_COMMAND) {
GRID_MATCH(FIRST_X_AXIS, "nox$tics")
else GRID_MATCH(FIRST_Y_AXIS, "noy$tics")
else GRID_MATCH(FIRST_Z_AXIS, "noz$tics")
else GRID_MATCH(SECOND_X_AXIS, "nox2$tics")
else GRID_MATCH(SECOND_Y_AXIS, "noy2$tics")
else GRID_MATCH(FIRST_X_AXIS, "nomx$tics")
else GRID_MATCH(FIRST_Y_AXIS, "nomy$tics")
else GRID_MATCH(FIRST_Z_AXIS, "nomz$tics")
else GRID_MATCH(SECOND_X_AXIS, "nomx2$tics")
else GRID_MATCH(SECOND_Y_AXIS, "nomy2$tics")
else GRID_MATCH(COLOR_AXIS, "nocb$tics")
else GRID_MATCH(COLOR_AXIS, "nomcb$tics")
else GRID_MATCH(POLAR_AXIS, "nor$tics")
else if (almost_equals(c_token,"po$lar")) {
if (!some_grid_selected())
axis_array[POLAR_AXIS].gridmajor = TRUE;
polar_grid_angle = 30*DEG2RAD;
c_token++;
if (isanumber(c_token) || type_udv(c_token) == INTGR || type_udv(c_token) == CMPLX)
polar_grid_angle = ang2rad*real_expression();
} else if (almost_equals(c_token,"nopo$lar")) {
polar_grid_angle = 0; /* not polar grid */
c_token++;
} else if (equals(c_token,"back")) {
grid_layer = 0;
c_token++;
} else if (equals(c_token,"front")) {
grid_layer = 1;
c_token++;
} else if (almost_equals(c_token,"layerd$efault")) {
grid_layer = -1;
c_token++;
} else { /* only remaining possibility is a line type */
int save_token = c_token;
lp_parse(&grid_lp, TRUE, FALSE);
if (equals(c_token,",")) {
c_token++;
lp_parse(&mgrid_lp, TRUE, FALSE);
} else if (save_token != c_token)
mgrid_lp = grid_lp;
if (save_token == c_token)
break;
}
}
if (!explicit_change && !some_grid_selected()) {
/* no axis specified, thus select default grid */
if (polar) {
axis_array[POLAR_AXIS].gridmajor = TRUE;
} else {
axis_array[FIRST_X_AXIS].gridmajor = TRUE;
axis_array[FIRST_Y_AXIS].gridmajor = TRUE;
}
}
} | false | false | false | false | false | 0 |
vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
{
struct vxlan_dev *vxlan = netdev_priv(dev);
struct ip_tunnel_info *info = skb_tunnel_info(skb);
__be16 sport, dport;
sport = udp_flow_src_port(dev_net(dev), skb, vxlan->cfg.port_min,
vxlan->cfg.port_max, true);
dport = info->key.tp_dst ? : vxlan->cfg.dst_port;
if (ip_tunnel_info_af(info) == AF_INET) {
if (!vxlan->vn4_sock)
return -EINVAL;
return egress_ipv4_tun_info(dev, skb, info, sport, dport);
} else {
#if IS_ENABLED(CONFIG_IPV6)
struct dst_entry *ndst;
if (!vxlan->vn6_sock)
return -EINVAL;
ndst = vxlan6_get_route(vxlan, skb, 0,
&info->key.u.ipv6.dst,
&info->key.u.ipv6.src);
if (IS_ERR(ndst))
return PTR_ERR(ndst);
dst_release(ndst);
info->key.tp_src = sport;
info->key.tp_dst = dport;
#else /* !CONFIG_IPV6 */
return -EPFNOSUPPORT;
#endif
}
return 0;
} | false | false | false | false | false | 0 |
openoverlay_cb(Fl_Object *, void *i)
{
IMAGEPARM *pp = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID);
static const char *currentfile = 0, *p = 0;
#ifdef HAVE_NATIVE_CHOOSER
char locfilename[DFLTSTRLEN];
ImviewNFC->type(Fl_Native_File_Chooser::BROWSE_FILE);
ImviewNFC->title("Open overlay");
switch ( ImviewNFC->show() ) {
case -1: // ERROR
warnprintf("** native chooser show() failed:%s\n", ImviewNFC->errmsg());
break;
case 1: // CANCEL
dbgprintf("native chooser cancel\n");
break;
default: // USER PICKED A FILE
dbgprintf("Overlay: '%s'\n", ImviewNFC->filename());
fl_filename_expand(locfilename, sizeof(locfilename), ImviewNFC->filename());
pp->ovlpath = strdup(locfilename);
// apply overlay to current image
int retval = IOBlackBox->readOverlay(currentfile);
if (retval == 0) {
// redisplay image with overlay present
// don't call this
//IOBlackBox->applyOverlayToCurrentImage();
// call that instead
IOBlackBox->applyImageParameters(pp, 0, 0, true);
mainViewer->displayCurrentImage();
}
openimage(locfilename);
break;
}
#else
dbgprintf("Open overlay dialog callback with option %ld\n", (long) i);
p = fl_file_chooser("Open Overlay Image","*",currentfile);
if (p)
currentfile = p;
if (p == 0) {
dbgprintf("User cancelled choice\n");
} else {
dbgprintf("User chose %s\n", currentfile);
pp->ovlpath = strdup(p);
// apply overlay to current image
int retval = IOBlackBox->readOverlay(currentfile);
if (retval == 0) {
// redisplay image with overlay present
// don't call this
//IOBlackBox->applyOverlayToCurrentImage();
// call that instead
IOBlackBox->applyImageParameters(pp, 0, 0, true);
mainViewer->displayCurrentImage();
}
}
#endif
return;
} | false | false | false | false | false | 0 |
setMarker1Position(double mrk_pos)
{
marker_1_position = mrk_pos;
if(marker_1_position > 1.01) marker_1_position = 1.01;
if(marker_1_position < 0.0001) marker_1_position = 0.0001;
update();
} | false | false | false | false | false | 0 |
findPackage (const string &name) {
Package *pkg ;
int npkgs ;
Scope *scope = currentScope ;
while (scope != NULL) {
if ((pkg = scope->findPackage (name, npkgs)) != NULL) {
if (npkgs != 1) {
error ("Ambiguous use of %s, I can find %d of them", name.c_str(), npkgs) ;
}
return pkg ;
}
scope = scope->parentScope ;
}
return NULL ;
} | false | false | false | false | false | 0 |
get_Length() const
{
double dfLength = 0.0;
for( int iGeom = 0; iGeom < nGeomCount; iGeom++ )
{
OGRGeometry* geom = papoGeoms[iGeom];
switch( wkbFlatten(geom->getGeometryType()) )
{
case wkbLinearRing:
case wkbLineString:
dfLength += ((OGRCurve *) geom)->get_Length();
break;
case wkbGeometryCollection:
dfLength +=((OGRGeometryCollection *) geom)->get_Length();
break;
default:
break;
}
}
return dfLength;
} | false | false | false | false | false | 0 |
gnumeric_r_dnbinom (GnmFuncEvalInfo *ei, GnmValue const * const *args)
{
gnm_float x = value_get_as_float (args[0]);
gnm_float n = value_get_as_float (args[1]);
gnm_float psuc = value_get_as_float (args[2]);
gboolean give_log = args[3] ? value_get_as_checked_bool (args[3]) : FALSE;
return value_new_float (dnbinom (x, n, psuc, give_log));
} | false | false | false | false | false | 0 |
optst(struct vars * v,
struct subre * t)
{
if (t == NULL)
return;
/* recurse through children */
if (t->left != NULL)
optst(v, t->left);
if (t->right != NULL)
optst(v, t->right);
} | false | false | false | false | false | 0 |
gkrellm_disk_assign_data_by_device(gint device_number, gint unit_number,
guint64 rb, guint64 wb, gboolean virtual)
{
DiskMon *disk;
gchar *name;
gint order = -1;
assign_method = DISK_ASSIGN_BY_DEVICE;
disk = lookup_disk_by_device(device_number, unit_number);
if (!disk && name_from_device)
{
name = (*name_from_device)(device_number, unit_number, &order);
if (name)
disk = add_disk(name, name, device_number, unit_number, order);
}
disk_assign_data(disk, rb, wb, virtual);
} | false | false | false | false | false | 0 |
vevop(l,r,f)
vari *l, *r;
double (*f)();
{ INT i, n;
vari *v;
double z;
if ((l==NULL) | (r==NULL)) return(NULL);
n = vlength(l);
if (n<vlength(r)) n = vlength(r);
v = createvar("_vevop",STHIDDEN,n,VDOUBLE);
if (lf_error) return(NULL);
for (i=0; i<n; i++)
{ z = f(vitem(l,i),vitem(r,i));
vassn(v,i,z);
}
deleteifhidden(l);
deleteifhidden(r);
return(v);
} | false | false | false | false | false | 0 |
extract_key(__isl_keep isl_stream *s,
struct isl_token *tok)
{
int type;
char *name;
enum isl_schedule_key key;
isl_ctx *ctx;
ctx = isl_stream_get_ctx(s);
type = isl_token_get_type(tok);
if (type != ISL_TOKEN_IDENT && type != ISL_TOKEN_STRING) {
isl_stream_error(s, tok, "expecting key");
return isl_schedule_key_error;
}
name = isl_token_get_str(ctx, tok);
if (!strcmp(name, "child"))
key = isl_schedule_key_child;
else if (!strcmp(name, "coincident"))
key = isl_schedule_key_coincident;
else if (!strcmp(name, "context"))
key = isl_schedule_key_context;
else if (!strcmp(name, "contraction"))
key = isl_schedule_key_contraction;
else if (!strcmp(name, "domain"))
key = isl_schedule_key_domain;
else if (!strcmp(name, "expansion"))
key = isl_schedule_key_expansion;
else if (!strcmp(name, "filter"))
key = isl_schedule_key_filter;
else if (!strcmp(name, "leaf"))
key = isl_schedule_key_leaf;
else if (!strcmp(name, "mark"))
key = isl_schedule_key_mark;
else if (!strcmp(name, "options"))
key = isl_schedule_key_options;
else if (!strcmp(name, "schedule"))
key = isl_schedule_key_schedule;
else if (!strcmp(name, "sequence"))
key = isl_schedule_key_sequence;
else if (!strcmp(name, "set"))
key = isl_schedule_key_set;
else if (!strcmp(name, "permutable"))
key = isl_schedule_key_permutable;
else
isl_die(ctx, isl_error_invalid, "unknown key",
key = isl_schedule_key_error);
free(name);
return key;
} | false | false | false | false | false | 0 |
widget( QWidget* parent )
{
QWidget *widget = new QWidget( parent );
QVBoxLayout *layout = new QVBoxLayout( widget );
QLabel *imageLabel = new QLabel();
imageLabel->setPixmap( QPixmap( KStandardDirs::locate( "data", "amarok/images/echonest.png" ) ) );
QLabel *label = new QLabel( i18n( "<a href=\"http://the.echonest.com/\">the echonest</a> thinks the artist is similar to" ) );
QRadioButton *rb1 = new QRadioButton( i18n( "the previous track's artist" ) );
QRadioButton *rb2 = new QRadioButton( i18n( "one of the artist in the current playlist" ) );
rb1->setChecked( m_match == PreviousTrack );
rb2->setChecked( m_match == Playlist );
connect( rb2, SIGNAL(toggled(bool)),
this, SLOT(setMatchTypePlaylist(bool)) );
layout->addWidget( imageLabel );
layout->addWidget( label );
layout->addWidget( rb1 );
layout->addWidget( rb2 );
return widget;
} | false | false | false | false | false | 0 |
qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
QtLuaPainter *_t = static_cast<QtLuaPainter *>(_o);
switch (_id) {
case 0: _t->showpage(); break;
case 1: _t->refresh(); break;
case 2: { QImage _r = _t->image();
if (_a[0]) *reinterpret_cast< QImage*>(_a[0]) = _r; } break;
case 3: { QPixmap _r = _t->pixmap();
if (_a[0]) *reinterpret_cast< QPixmap*>(_a[0]) = _r; } break;
case 4: { QWidget* _r = _t->widget();
if (_a[0]) *reinterpret_cast< QWidget**>(_a[0]) = _r; } break;
case 5: { QPaintDevice* _r = _t->device();
if (_a[0]) *reinterpret_cast< QPaintDevice**>(_a[0]) = _r; } break;
case 6: { QtLuaPrinter* _r = _t->printer();
if (_a[0]) *reinterpret_cast< QtLuaPrinter**>(_a[0]) = _r; } break;
case 7: { QPainter* _r = _t->painter();
if (_a[0]) *reinterpret_cast< QPainter**>(_a[0]) = _r; } break;
case 8: { QRect _r = _t->rect();
if (_a[0]) *reinterpret_cast< QRect*>(_a[0]) = _r; } break;
case 9: { QSize _r = _t->size();
if (_a[0]) *reinterpret_cast< QSize*>(_a[0]) = _r; } break;
case 10: _t->close(); break;
default: ;
}
}
} | false | false | false | false | false | 0 |
df_lr_bb_local_compute (unsigned int bb_index)
{
basic_block bb = BASIC_BLOCK (bb_index);
struct df_lr_bb_info *bb_info = df_lr_get_bb_info (bb_index);
rtx insn;
df_ref *def_rec;
df_ref *use_rec;
/* Process the registers set in an exception handler. */
for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
{
df_ref def = *def_rec;
if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0)
{
unsigned int dregno = DF_REF_REGNO (def);
bitmap_set_bit (&bb_info->def, dregno);
bitmap_clear_bit (&bb_info->use, dregno);
}
}
/* Process the hardware registers that are always live. */
for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++)
{
df_ref use = *use_rec;
/* Add use to set of uses in this BB. */
if ((DF_REF_FLAGS (use) & DF_REF_AT_TOP) == 0)
bitmap_set_bit (&bb_info->use, DF_REF_REGNO (use));
}
FOR_BB_INSNS_REVERSE (bb, insn)
{
unsigned int uid = INSN_UID (insn);
if (!NONDEBUG_INSN_P (insn))
continue;
for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
{
df_ref def = *def_rec;
/* If the def is to only part of the reg, it does
not kill the other defs that reach here. */
if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
{
unsigned int dregno = DF_REF_REGNO (def);
bitmap_set_bit (&bb_info->def, dregno);
bitmap_clear_bit (&bb_info->use, dregno);
}
}
for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
{
df_ref use = *use_rec;
/* Add use to set of uses in this BB. */
bitmap_set_bit (&bb_info->use, DF_REF_REGNO (use));
}
}
/* Process the registers set in an exception handler or the hard
frame pointer if this block is the target of a non local
goto. */
for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
{
df_ref def = *def_rec;
if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
{
unsigned int dregno = DF_REF_REGNO (def);
bitmap_set_bit (&bb_info->def, dregno);
bitmap_clear_bit (&bb_info->use, dregno);
}
}
#ifdef EH_USES
/* Process the uses that are live into an exception handler. */
for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++)
{
df_ref use = *use_rec;
/* Add use to set of uses in this BB. */
if (DF_REF_FLAGS (use) & DF_REF_AT_TOP)
bitmap_set_bit (&bb_info->use, DF_REF_REGNO (use));
}
#endif
/* If the df_live problem is not defined, such as at -O0 and -O1, we
still need to keep the luids up to date. This is normally done
in the df_live problem since this problem has a forwards
scan. */
if (!df_live)
df_recompute_luids (bb);
} | false | false | false | false | false | 0 |
assignment(LexState*ls,struct LHS_assign*lh,int nvars){
expdesc e;
check_condition(ls,VLOCAL<=lh->v.k&&lh->v.k<=VINDEXED,
"syntax error");
if(testnext(ls,',')){
struct LHS_assign nv;
nv.prev=lh;
primaryexp(ls,&nv.v);
if(nv.v.k==VLOCAL)
check_conflict(ls,lh,&nv.v);
luaY_checklimit(ls->fs,nvars,200-ls->L->nCcalls,
"variables in assignment");
assignment(ls,&nv,nvars+1);
}
else{
int nexps;
checknext(ls,'=');
nexps=explist1(ls,&e);
if(nexps!=nvars){
adjust_assign(ls,nvars,nexps,&e);
if(nexps>nvars)
ls->fs->freereg-=nexps-nvars;
}
else{
luaK_setoneret(ls->fs,&e);
luaK_storevar(ls->fs,&lh->v,&e);
return;
}
}
init_exp(&e,VNONRELOC,ls->fs->freereg-1);
luaK_storevar(ls->fs,&lh->v,&e);
} | false | false | false | false | false | 0 |
g2_FIG_polygon(int pid, void *pdp, int N, int *points)
{
g2_FIG_device *fig=&g2_FIG_dev[pid];
int i;
if(N<2) {
return -1;
}
fprintf(fig->fp,"2 3 %d %d %d -1 1 1 -1 %d 1 0 -1 0 0 %d\n",
fig->line_style, fig->thickness, fig->pen_color, fig->style_val, N+1);
for(i=0;i<2*N;i+=2) {
fprintf(fig->fp, " %d %d\n", points[i], points[i+1]);
}
fprintf(fig->fp, " %d %d\n", points[0], points[1]);
return 0;
} | false | false | false | false | false | 0 |
crypto_init_ablkcipher_ops(struct crypto_tfm *tfm, u32 type,
u32 mask)
{
struct ablkcipher_alg *alg = &tfm->__crt_alg->cra_ablkcipher;
struct ablkcipher_tfm *crt = &tfm->crt_ablkcipher;
if (alg->ivsize > PAGE_SIZE / 8)
return -EINVAL;
crt->setkey = setkey;
crt->encrypt = alg->encrypt;
crt->decrypt = alg->decrypt;
if (!alg->ivsize) {
crt->givencrypt = skcipher_null_givencrypt;
crt->givdecrypt = skcipher_null_givdecrypt;
}
crt->base = __crypto_ablkcipher_cast(tfm);
crt->ivsize = alg->ivsize;
return 0;
} | false | false | false | false | false | 0 |
WaitForSection(ifstream& fileData, const string& match) {
string line;
while (! fileData.eof() )
{
getline (fileData,line);
if (TrimStr(line) == match) return;
}
} | false | false | false | false | false | 0 |
swap_bytes(unsigned char *item1_p, unsigned char *item2_p,
int ele_size)
{
unsigned char char_temp;
for (; ele_size > 0; ele_size--) {
char_temp = *item1_p;
*item1_p = *item2_p;
*item2_p = char_temp;
item1_p++;
item2_p++;
}
} | false | false | false | false | false | 0 |
RemoveSelected()
{
long item;
item = m_pPanel->GetListCtrl()->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
while (item != -1)
{
m_texts.erase(m_pPanel->GetListCtrl()->GetItemText(item));
m_pPanel->GetListCtrl()->DeleteItem(item);
// -1 because the indices were shifted by DeleteItem()
item = m_pPanel->GetListCtrl()->GetNextItem(item - 1,
wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
}
m_pHighlighter->TextsChanged();
} | false | false | false | false | false | 0 |
pop_scope (tree t)
{
if (t == NULL_TREE)
return;
if (TREE_CODE (t) == NAMESPACE_DECL)
pop_decl_namespace ();
else if CLASS_TYPE_P (t)
pop_nested_class ();
} | false | false | false | false | false | 0 |
store_selargs_to_rec(PART_PRUNE_PARAM *ppar, SEL_ARG **start,
int num)
{
KEY_PART *parts= ppar->range_param.key_parts;
for (SEL_ARG **end= start + num; start != end; start++)
{
SEL_ARG *sel_arg= (*start);
store_key_image_to_rec(sel_arg->field, sel_arg->min_value,
parts[sel_arg->part].length);
}
} | false | false | false | false | false | 0 |
EVP_PBE_find(int type, int pbe_nid,
int *pcnid, int *pmnid, EVP_PBE_KEYGEN **pkeygen)
{
EVP_PBE_CTL *pbetmp = NULL, pbelu;
int i;
if (pbe_nid == NID_undef)
return 0;
pbelu.pbe_type = type;
pbelu.pbe_nid = pbe_nid;
if (pbe_algs)
{
i = sk_EVP_PBE_CTL_find(pbe_algs, &pbelu);
if (i != -1)
pbetmp = sk_EVP_PBE_CTL_value (pbe_algs, i);
}
if (pbetmp == NULL)
{
pbetmp = OBJ_bsearch_pbe2(&pbelu, builtin_pbe,
sizeof(builtin_pbe)/sizeof(EVP_PBE_CTL));
}
if (pbetmp == NULL)
return 0;
if (pcnid)
*pcnid = pbetmp->cipher_nid;
if (pmnid)
*pmnid = pbetmp->md_nid;
if (pkeygen)
*pkeygen = pbetmp->keygen;
return 1;
} | false | false | false | false | false | 0 |
piece_button_press (GooCanvasItem *item,
GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
GooCanvas *canvas;
GooCanvasItem **board;
GooCanvasItem *text G_GNUC_UNUSED;
int num G_GNUC_UNUSED, pos, newpos;
int x, y;
double dx = 0.0, dy = 0.0;
int move;
canvas = goo_canvas_item_get_canvas (item);
board = g_object_get_data (G_OBJECT (canvas), "board");
num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "piece_num"));
pos = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "piece_pos"));
text = g_object_get_data (G_OBJECT (item), "text");
#if 0
g_print ("In piece_event pos: %i,%i num: %i\n", pos % 4, pos / 4,
num + 1);
#endif
y = pos / 4;
x = pos % 4;
move = TRUE;
if ((y > 0) && (board[(y - 1) * 4 + x] == NULL)) {
dx = 0.0;
dy = -1.0;
y--;
} else if ((y < 3) && (board[(y + 1) * 4 + x] == NULL)) {
dx = 0.0;
dy = 1.0;
y++;
} else if ((x > 0) && (board[y * 4 + x - 1] == NULL)) {
dx = -1.0;
dy = 0.0;
x--;
} else if ((x < 3) && (board[y * 4 + x + 1] == NULL)) {
dx = 1.0;
dy = 0.0;
x++;
} else
move = FALSE;
if (move) {
newpos = y * 4 + x;
board[pos] = NULL;
board[newpos] = item;
g_object_set_data (G_OBJECT (item), "piece_pos", GINT_TO_POINTER (newpos));
goo_canvas_item_translate (item, dx * PIECE_SIZE,
dy * PIECE_SIZE);
test_win (board);
}
return FALSE;
} | false | false | false | false | false | 0 |
cpl_propertylist_has(const cpl_propertylist *self, const char *name)
{
if (self == NULL || name == NULL) {
cpl_error_set_(CPL_ERROR_NULL_INPUT);
return 0;
}
return _cpl_propertylist_get(self, name) != NULL ? 1 : 0;
} | false | false | false | false | false | 0 |
clear_modify_mem_tables (void)
{
unsigned i;
bitmap_iterator bi;
EXECUTE_IF_SET_IN_BITMAP (modify_mem_list_set, 0, i, bi)
{
VEC_free (rtx, heap, modify_mem_list[i]);
VEC_free (modify_pair, heap, canon_modify_mem_list[i]);
}
bitmap_clear (modify_mem_list_set);
bitmap_clear (blocks_with_calls);
} | false | false | false | false | false | 0 |
my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess,
void *useptr )
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
int locknum;
(void)handle;
(void)laccess;
switch ( data ) {
case CURL_LOCK_DATA_SHARE:
what = "share";
locknum = 0;
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
locknum = 1;
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
locknum = 2;
break;
default:
fprintf(stderr, "lock: no such data: %d\n", (int)data);
return;
}
/* detect locking of locked locks */
if(lock[locknum]) {
printf("lock: double locked %s\n", what);
return;
}
lock[locknum]++;
printf("lock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
} | false | false | false | false | false | 0 |
printAnnotation(raw_ostream &OS, StringRef Annot) {
if (!Annot.empty()) {
if (CommentStream) {
(*CommentStream) << Annot;
// By definition (see MCInstPrinter.h), CommentStream must end with
// a newline after each comment.
if (Annot.back() != '\n')
(*CommentStream) << '\n';
} else
OS << " " << MAI.getCommentString() << " " << Annot;
}
} | false | false | false | false | false | 0 |
textbuffer_view_create(TEXT_BUFFER_REC *buffer,
int width, int height,
int scroll, int utf8)
{
TEXT_BUFFER_VIEW_REC *view;
g_return_val_if_fail(buffer != NULL, NULL);
g_return_val_if_fail(width > 0, NULL);
view = g_new0(TEXT_BUFFER_VIEW_REC, 1);
view->buffer = buffer;
view->siblings = textbuffer_get_views(buffer);
view->width = width;
view->height = height;
view->scroll = scroll;
view->utf8 = utf8;
view->cache = textbuffer_cache_get(view->siblings, width);
textbuffer_view_init_bottom(view);
view->startline = view->bottom_startline;
view->subline = view->bottom_subline;
view->bottom = TRUE;
textbuffer_view_init_ypos(view);
view->bookmarks = g_hash_table_new((GHashFunc) g_str_hash,
(GCompareFunc) g_str_equal);
views = g_slist_append(views, view);
return view;
} | false | false | false | false | false | 0 |
fast_disconnect(int str1, int str2, int *move)
{
int result;
int save_limit = connection_node_limit;
int save_verbose = verbose;
if (board[str1] == EMPTY || board[str2] == EMPTY)
return WIN;
str1 = find_origin(str1);
str2 = find_origin(str2);
if (str1 > str2) {
int tmp = str1;
str1 = str2;
str2 = tmp;
}
modify_depth_values(-3);
connection_node_limit /= 4;
if (verbose > 0)
verbose--;
result = recursive_disconnect2(str1, str2, move, 0);
verbose = save_verbose;
connection_node_limit = save_limit;
modify_depth_values(3);
return result;
} | false | false | false | false | false | 0 |
ar5523_hwconfig(struct ieee80211_hw *hw, u32 changed)
{
struct ar5523 *ar = hw->priv;
ar5523_dbg(ar, "config called\n");
mutex_lock(&ar->mutex);
if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
ar5523_dbg(ar, "Do channel switch\n");
ar5523_flush_tx(ar);
ar5523_switch_chan(ar);
}
mutex_unlock(&ar->mutex);
return 0;
} | false | false | false | false | false | 0 |
php_replace_controlchars_ex(char *str, int len)
{
unsigned char *s = (unsigned char *)str;
unsigned char *e = (unsigned char *)str + len;
if (!str) {
return (NULL);
}
while (s < e) {
if (iscntrl(*s)) {
*s='_';
}
s++;
}
return (str);
} | false | false | false | false | false | 0 |
pkt_iosched_process_queue(struct pktcdvd_device *pd)
{
if (atomic_read(&pd->iosched.attention) == 0)
return;
atomic_set(&pd->iosched.attention, 0);
for (;;) {
struct bio *bio;
int reads_queued, writes_queued;
spin_lock(&pd->iosched.lock);
reads_queued = !bio_list_empty(&pd->iosched.read_queue);
writes_queued = !bio_list_empty(&pd->iosched.write_queue);
spin_unlock(&pd->iosched.lock);
if (!reads_queued && !writes_queued)
break;
if (pd->iosched.writing) {
int need_write_seek = 1;
spin_lock(&pd->iosched.lock);
bio = bio_list_peek(&pd->iosched.write_queue);
spin_unlock(&pd->iosched.lock);
if (bio && (bio->bi_iter.bi_sector ==
pd->iosched.last_write))
need_write_seek = 0;
if (need_write_seek && reads_queued) {
if (atomic_read(&pd->cdrw.pending_bios) > 0) {
pkt_dbg(2, pd, "write, waiting\n");
break;
}
pkt_flush_cache(pd);
pd->iosched.writing = 0;
}
} else {
if (!reads_queued && writes_queued) {
if (atomic_read(&pd->cdrw.pending_bios) > 0) {
pkt_dbg(2, pd, "read, waiting\n");
break;
}
pd->iosched.writing = 1;
}
}
spin_lock(&pd->iosched.lock);
if (pd->iosched.writing)
bio = bio_list_pop(&pd->iosched.write_queue);
else
bio = bio_list_pop(&pd->iosched.read_queue);
spin_unlock(&pd->iosched.lock);
if (!bio)
continue;
if (bio_data_dir(bio) == READ)
pd->iosched.successive_reads +=
bio->bi_iter.bi_size >> 10;
else {
pd->iosched.successive_reads = 0;
pd->iosched.last_write = bio_end_sector(bio);
}
if (pd->iosched.successive_reads >= HI_SPEED_SWITCH) {
if (pd->read_speed == pd->write_speed) {
pd->read_speed = MAX_SPEED;
pkt_set_speed(pd, pd->write_speed, pd->read_speed);
}
} else {
if (pd->read_speed != pd->write_speed) {
pd->read_speed = pd->write_speed;
pkt_set_speed(pd, pd->write_speed, pd->read_speed);
}
}
atomic_inc(&pd->cdrw.pending_bios);
generic_make_request(bio);
}
} | false | false | false | false | false | 0 |
client_challenge( GuiWidget *widget, GuiEvent *event )
{
#ifdef NETWORK_ENABLED
if ( event->type != GUI_CLICKED ) return;
/* everything valid? */
if ( client_user == 0 ) {
client_popup_info( _("You must select a user for a challenge.") );
return;
}
if ( client_levelset == 0 ) {
client_popup_info( _("You must select a levelset for a challenge.") );
return;
}
if ( client_user->id == client_id ) {
client_popup_info( _("You can't challenge yourself.") );
return;
}
strcpy( mp_peer_name, client_user->name );
mp_peer_id = client_user->id;
strcpy( mp_levelset, client_levelset );
mp_diff = config.mp_diff;
mp_rounds = config.mp_rounds;
mp_balls = config.mp_balls;
mp_frags = config.mp_frags;
/* challenger, challenged, levelset, diff, rounds, frags, balls */
msg_begin_writing( msgbuf, &msglen, MAX_MSG_SIZE );
msg_write_int8( MSG_OPEN_GAME );
msg_write_int32( mp_peer_id );
msg_write_string( mp_levelset );
msg_write_int8( mp_diff );
msg_write_int8( mp_rounds );
msg_write_int8( mp_frags );
msg_write_int8( mp_balls );
client_transmit( CODE_BLUE, msglen, msgbuf );
client_popup_info( _("You have challenged %s. Let's see what (s)he says..."), mp_peer_name );
client_state = CLIENT_AWAIT_ANSWER;
#endif
} | false | true | false | false | false | 1 |
_cr_notify_step_launch(slurm_step_ctx_t *ctx)
{
int fd, len, rc = 0;
char *cr_sock_addr = NULL;
cr_sock_addr = getenv("SLURM_SRUN_CR_SOCKET");
if (cr_sock_addr == NULL) { /* not run under srun_cr */
return 0;
}
if ((fd = _connect_srun_cr(cr_sock_addr)) < 0) {
debug2("failed connecting srun_cr. take it not running under "
"srun_cr.");
return 0;
}
if (write(fd, &ctx->job_id, sizeof(uint32_t)) != sizeof(uint32_t)) {
error("failed writing job_id to srun_cr: %m");
rc = -1;
goto out;
}
if (write(fd, &ctx->step_resp->job_step_id, sizeof(uint32_t)) !=
sizeof(uint32_t)) {
error("failed writing job_step_id to srun_cr: %m");
rc = -1;
goto out;
}
len = strlen(ctx->step_resp->step_layout->node_list);
if (write(fd, &len, sizeof(int)) != sizeof(int)) {
error("failed writing nodelist length to srun_cr: %m");
rc = -1;
goto out;
}
if (write(fd, ctx->step_resp->step_layout->node_list, len + 1) !=
(len + 1)) {
error("failed writing nodelist to srun_cr: %m");
rc = -1;
}
out:
close (fd);
return rc;
} | false | false | false | false | true | 1 |
print_uptime(const struct ap_session *ses, char *buf)
{
time_t uptime;
int day,hour,min,sec;
char time_str[14];
if (ses->stop_time)
uptime = ses->stop_time - ses->start_time;
else {
uptime = _time();
uptime -= ses->start_time;
}
day = uptime/ (24*60*60); uptime %= (24*60*60);
hour = uptime / (60*60); uptime %= (60*60);
min = uptime / 60;
sec = uptime % 60;
if (day)
snprintf(time_str, 13, "%i.%02i:%02i:%02i", day, hour, min, sec);
else
snprintf(time_str, 13, "%02i:%02i:%02i", hour, min, sec);
sprintf(buf, "%s", time_str);
} | true | true | false | false | false | 1 |
mod_fill_do_entry_changed(PlayQueuePlugin * self)
{
const gchar *text2 = gtk_entry_get_text(GTK_ENTRY(self->priv->filter_entry));
if (strlen(text2) > 0)
{
MpdData *data = NULL;
data = advanced_search(text2, TRUE);
gmpc_mpddata_model_set_mpd_data(GMPC_MPDDATA_MODEL(self->priv->mod_fill), data);
self->priv->quick_search = TRUE;
gtk_tree_view_set_model(GTK_TREE_VIEW(self->priv->pl3_cp_tree), self->priv->mod_fill);
gtk_widget_show(self->priv->filter_entry);
} else
{
gtk_tree_view_set_model(GTK_TREE_VIEW(self->priv->pl3_cp_tree), playlist);
gmpc_mpddata_model_set_mpd_data(GMPC_MPDDATA_MODEL(self->priv->mod_fill), NULL);
if (!self->priv->search_keep_open)
{
self->priv->quick_search = 0;
gtk_widget_hide(self->priv->filter_entry);
gtk_widget_grab_focus(self->priv->pl3_cp_tree);
}
}
self->priv->quick_search_timeout = 0;
return FALSE;
} | false | false | false | false | false | 0 |
clutter_desaturate_effect_init (ClutterDesaturateEffect *self)
{
ClutterDesaturateEffectClass *klass = CLUTTER_DESATURATE_EFFECT_GET_CLASS (self);
if (G_UNLIKELY (klass->base_pipeline == NULL))
{
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
CoglSnippet *snippet;
klass->base_pipeline = cogl_pipeline_new (ctx);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
desaturate_glsl_declarations,
desaturate_glsl_source);
cogl_pipeline_add_snippet (klass->base_pipeline, snippet);
cogl_object_unref (snippet);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
0, /* layer number */
COGL_TEXTURE_TYPE_2D);
}
self->pipeline = cogl_pipeline_copy (klass->base_pipeline);
self->factor_uniform =
cogl_pipeline_get_uniform_location (self->pipeline, "factor");
self->factor = 1.0;
update_factor_uniform (self);
} | false | false | false | false | false | 0 |
sb_put(SB *sb, const char *bytes, int count)
{
sb_need(sb, count);
memcpy(sb->cur, bytes, count);
sb->cur += count;
} | false | false | false | false | false | 0 |
dht_is_subvol_filled (xlator_t *this, xlator_t *subvol)
{
int i = 0;
dht_conf_t *conf = NULL;
gf_boolean_t subvol_filled_inodes = _gf_false;
gf_boolean_t subvol_filled_space = _gf_false;
gf_boolean_t is_subvol_filled = _gf_false;
conf = this->private;
/* Check for values above specified percent or free disk */
LOCK (&conf->subvolume_lock);
{
for (i = 0; i < conf->subvolume_cnt; i++) {
if (subvol == conf->subvolumes[i]) {
if (conf->disk_unit == 'p') {
if (conf->du_stats[i].avail_percent <
conf->min_free_disk) {
subvol_filled_space = _gf_true;
break;
}
} else {
if (conf->du_stats[i].avail_space <
conf->min_free_disk) {
subvol_filled_space = _gf_true;
break;
}
}
if (conf->du_stats[i].avail_inodes <
conf->min_free_inodes) {
subvol_filled_inodes = _gf_true;
break;
}
}
}
}
UNLOCK (&conf->subvolume_lock);
if (subvol_filled_space && conf->subvolume_status[i]) {
if (!(conf->du_stats[i].log++ % (GF_UNIVERSAL_ANSWER * 10))) {
gf_log (this->name, GF_LOG_WARNING,
"disk space on subvolume '%s' is getting "
"full (%.2f %%), consider adding more nodes",
subvol->name,
(100 - conf->du_stats[i].avail_percent));
}
}
if (subvol_filled_inodes && conf->subvolume_status[i]) {
if (!(conf->du_stats[i].log++ % (GF_UNIVERSAL_ANSWER * 10))) {
gf_log (this->name, GF_LOG_CRITICAL,
"inodes on subvolume '%s' are at "
"(%.2f %%), consider adding more nodes",
subvol->name,
(100 - conf->du_stats[i].avail_inodes));
}
}
is_subvol_filled = (subvol_filled_space || subvol_filled_inodes);
return is_subvol_filled;
} | false | false | false | false | false | 0 |
load_single_tx( GncSqlBackend* be, GncSqlRow* row )
{
const GncGUID* guid;
GncGUID tx_guid;
Transaction* pTx;
g_return_val_if_fail( be != NULL, NULL );
g_return_val_if_fail( row != NULL, NULL );
guid = gnc_sql_load_guid( be, row );
if ( guid == NULL ) return NULL;
tx_guid = *guid;
// Don't overwrite the transaction if it's already been loaded (and possibly modified).
pTx = xaccTransLookup( &tx_guid, be->book );
if ( pTx != NULL )
{
return NULL;
}
pTx = xaccMallocTransaction( be->book );
xaccTransBeginEdit( pTx );
gnc_sql_load_object( be, row, GNC_ID_TRANS, pTx, tx_col_table );
g_assert( pTx == xaccTransLookup( &tx_guid, be->book ) );
return pTx;
} | false | false | false | false | false | 0 |
storeUnlockObjectDebug(StoreEntry * e, const char *file, const int line)
{
e->lock_count--;
debug(20, 3) ("storeUnlockObject: (%s:%d): key '%s' count=%d\n", file, line,
storeKeyText(e->hash.key), e->lock_count);
if (e->lock_count)
return (int) e->lock_count;
if (e->store_status == STORE_PENDING)
EBIT_SET(e->flags, RELEASE_REQUEST);
assert(storePendingNClients(e) == 0);
if (EBIT_TEST(e->flags, RELEASE_REQUEST))
storeRelease(e);
else if (storeKeepInMemory(e)) {
storeEntryDereferenced(e);
storeSetMemStatus(e, IN_MEMORY);
requestUnlink(e->mem_obj->request);
e->mem_obj->request = NULL;
} else {
storePurgeMem(e);
storeEntryDereferenced(e);
if (EBIT_TEST(e->flags, KEY_PRIVATE))
debug(20, 1) ("WARNING: %s:%d: found KEY_PRIVATE\n", __FILE__, __LINE__);
}
return 0;
} | false | false | false | false | false | 0 |
gtk_meter_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer data)
{
GtkMeter *meter;
g_return_if_fail (adjustment != NULL);
g_return_if_fail (data != NULL);
meter = GTK_METER (data);
if (meter->old_value != adjustment->value)
{
gtk_meter_update (meter);
meter->old_value = adjustment->value;
}
} | false | false | false | false | false | 0 |
netsys_queue_add(struct nqueue *q, void *elem)
{
int code;
unsigned long new_end;
new_end = q->table_end + 1;
if (new_end == q->table_size) new_end = 0;
if (new_end == q->table_start) {
/* We have to resize */
struct nqueue q1;
int n;
code = netsys_queue_init(&q1, q->table_size * 2);
if (code != 0) return code;
if (q->table_start <= q->table_end) {
n = q->table_end - q->table_start;
memcpy(q1.table,
q->table + q->table_start,
n * sizeof(void *));
}
else {
int n1;
n1 = q->table_size - q->table_start;
memcpy(q1.table,
q->table + q->table_start,
n1 * sizeof(void *));
memcpy(q1.table + n1,
q->table,
q->table_end * sizeof(void *));
n = n1 + q->table_end;
}
free(q->table);
q->table = q1.table;
q->table_size = q1.table_size;
q->table_start = 0;
q->table_end = n;
new_end = n+1;
}
*(q->table + q->table_end) = elem;
q->table_end = new_end;
return 0;
} | false | true | false | false | false | 1 |
eval_D2_uh_fast(const REAL_D Lambda[N_LAMBDA],
const REAL *uh_loc,
const REAL (*D2_phi)[N_LAMBDA][N_LAMBDA],
int n_bas_fcts, REAL_DD D2_uh)
{
static REAL_DD D2;
int i, j, k, l;
REAL (*val)[DIM_OF_WORLD], D2_tmp[N_LAMBDA][N_LAMBDA] = {{0}};
val = D2_uh ? D2_uh : D2;
for (i = 0; i < n_bas_fcts; i++)
for (k = 0; k < N_LAMBDA; k++)
for (l = k; l < N_LAMBDA; l++)
D2_tmp[k][l] += uh_loc[i]*D2_phi[i][k][l];
for (i = 0; i < DIM_OF_WORLD; i++)
{
for (j = i; j < DIM_OF_WORLD; j++)
{
val[i][j] = 0.0;
for (k = 0; k < N_LAMBDA; k++)
{
val[i][j] += Lambda[k][i]*Lambda[k][j]*D2_tmp[k][k];
for (l = k+1; l < N_LAMBDA; l++)
{
val[i][j] +=
(Lambda[k][i]*Lambda[l][j] + Lambda[l][i]*Lambda[k][j])*D2_tmp[k][l];
}
}
val[j][i] = val[i][j]; /* the Hessian is symmetric */
}
}
return((const REAL_D *) val);
} | false | false | false | false | false | 0 |
gnapplet_write_phonebook(gn_data *data, struct gn_statemachine *state)
{
gn_phonebook_subentry *se;
int i, need_defnumber;
REQUEST_DEF;
if (!data->phonebook_entry) return GN_ERR_INTERNALERROR;
if (!data->phonebook_entry->name[0])
return gnapplet_delete_phonebook(data, state);
need_defnumber = 1;
for (i = 0; i < data->phonebook_entry->subentries_count; i++) {
se = data->phonebook_entry->subentries + i;
if (se->entry_type == GN_PHONEBOOK_ENTRY_Number && strcmp(se->data.number, data->phonebook_entry->number) == 0) {
need_defnumber = 0;
break;
}
}
pkt_put_uint16(&pkt, GNAPPLET_MSG_PHONEBOOK_WRITE_REQ);
pkt_put_uint16(&pkt, data->phonebook_entry->memory_type);
pkt_put_uint32(&pkt, data->phonebook_entry->location);
pkt_put_uint16(&pkt, data->phonebook_entry->subentries_count + 1 + need_defnumber);
pkt_put_uint16(&pkt, GN_PHONEBOOK_ENTRY_Name);
pkt_put_uint16(&pkt, 0);
pkt_put_string(&pkt, data->phonebook_entry->name);
if (need_defnumber) {
pkt_put_uint16(&pkt, GN_PHONEBOOK_ENTRY_Number);
pkt_put_uint16(&pkt, GN_PHONEBOOK_NUMBER_General);
pkt_put_string(&pkt, data->phonebook_entry->number);
}
for (i = 0; i < data->phonebook_entry->subentries_count; i++) {
se = data->phonebook_entry->subentries + i;
pkt_put_uint16(&pkt, se->entry_type);
pkt_put_uint16(&pkt, se->number_type);
pkt_put_string(&pkt, se->data.number);
}
SEND_MESSAGE_BLOCK(GNAPPLET_MSG_PHONEBOOK);
} | false | false | false | false | false | 0 |
is_hrule(uint8_t *data, size_t size)
{
size_t i = 0, n = 0;
uint8_t c;
/* skipping initial spaces */
if (size < 3) return 0;
if (data[0] == ' ') { i++;
if (data[1] == ' ') { i++;
if (data[2] == ' ') { i++; } } }
/* looking at the hrule uint8_t */
if (i + 2 >= size
|| (data[i] != '*' && data[i] != '-' && data[i] != '_'))
return 0;
c = data[i];
/* the whole line must be the char or whitespace */
while (i < size && data[i] != '\n') {
if (data[i] == c) n++;
else if (data[i] != ' ')
return 0;
i++;
}
return n >= 3;
} | false | false | false | false | false | 0 |
from_iovec (struct Mono_Posix_Iovec *iov, gint32 iovcnt)
{
struct iovec* v;
gint32 i;
if (iovcnt < 0) {
errno = EINVAL;
return NULL;
}
v = malloc (iovcnt * sizeof (struct iovec));
if (!v) {
return NULL;
}
for (i = 0; i < iovcnt; i++) {
if (Mono_Posix_FromIovec (&iov[i], &v[i]) != 0) {
free (v);
return NULL;
}
}
return v;
} | false | false | false | false | false | 0 |
ctl_pdu_to_str(dchat_pdu_t* pdu, char** value)
{
// check if content-length is valid
if (!is_valid_content_length(pdu->content_length))
{
return -1;
}
*value = malloc(MAX_INT_STR + 1);
if (*value == NULL)
{
ui_fatal("Memory allocation for content-length failed!");
}
snprintf(*value, MAX_INT_STR, "%d", pdu->content_length);
return 0;
} | false | false | false | false | false | 0 |
weighted_interleave(double* weights, int n, int k, int* v, int* count) {
double *x = (double*) calloc(n, sizeof(double));
int i;
for (i=0; i<n; i++) {
// make sure apps with no weight get no slots
if (weights[i] == 0) {
x[i] = 1e-100;
}
count[i] = 0;
}
for (i=0; i<k; i++) {
int best = 0;
for (int j=1; j<n; j++) {
if (x[j] > x[best]) {
best = j;
}
}
v[i] = best;
x[best] -= 1/weights[best];
count[best]++;
}
free(x);
} | false | false | false | false | false | 0 |
deprecated_attr_warn(const char *name)
{
pr_warn_once("%d (%s) Attribute %s (and others) will be removed. %s\n",
task_pid_nr(current),
current->comm,
name,
"See zram documentation.");
} | false | false | false | false | false | 0 |
password20_commit (const char *section_name,
const struct config_keyvalue *kv,
void *arg)
{
bmc_config_state_data_t *state_data;
uint8_t userid;
fiid_obj_t obj_cmd_rs = NULL;
config_err_t rv = CONFIG_ERR_FATAL_ERROR;
assert (section_name);
assert (kv);
assert (arg);
state_data = (bmc_config_state_data_t *)arg;
userid = atoi (section_name + strlen ("User"));
if (!(obj_cmd_rs = fiid_obj_create (tmpl_cmd_set_user_password_rs)))
{
pstdout_fprintf (state_data->pstate,
stderr,
"fiid_obj_create: %s\n",
strerror (errno));
goto cleanup;
}
if (ipmi_cmd_set_user_password (state_data->ipmi_ctx,
userid,
IPMI_PASSWORD_SIZE_20_BYTES,
IPMI_PASSWORD_OPERATION_SET_PASSWORD,
kv->value_input,
strlen (kv->value_input),
obj_cmd_rs) < 0)
{
config_err_t ret;
if (state_data->prog_data->args->config_args.common.debug)
pstdout_fprintf (state_data->pstate,
stderr,
"ipmi_cmd_set_user_password: %s\n",
ipmi_ctx_errormsg (state_data->ipmi_ctx));
if (config_is_non_fatal_error (state_data->ipmi_ctx,
obj_cmd_rs,
&ret))
rv = ret;
goto cleanup;
}
rv = CONFIG_ERR_SUCCESS;
cleanup:
fiid_obj_destroy (obj_cmd_rs);
return (rv);
} | false | false | false | false | true | 1 |
ois_expand_gsm7(char *raw8, const char *raw7, int len)
{
int i;
char bits[8*(BUFLEN+1)];
SAY2(3, "ois_expand_gsm7 len=%d", len);
/* yeah, there are also better algorithms, but... */
/* well, at least this is fairly portable and ok for small messages... */
ois_expand_gsm7_to_bits(bits, raw7, len);
for (i = 0; i < len; ++i) {
raw8[i] = ois_expand_gsm7_from_bits(bits, i);
}
SAY2(5, "ois_expand_gsm7 gave [%s]", ois_debug_str(raw8, i));
return i;
} | true | true | false | false | false | 1 |
serport_serio_close(struct serio *serio)
{
struct serport *serport = serio->port_data;
unsigned long flags;
spin_lock_irqsave(&serport->lock, flags);
clear_bit(SERPORT_ACTIVE, &serport->flags);
set_bit(SERPORT_DEAD, &serport->flags);
spin_unlock_irqrestore(&serport->lock, flags);
wake_up_interruptible(&serport->wait);
} | false | false | false | false | false | 0 |
tp_base_contact_list_delete_group_by_handle_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
TpBaseContactList *self = TP_BASE_CONTACT_LIST (source);
GError *error = NULL;
g_return_if_fail (TP_IS_BASE_CONTACT_LIST (source));
if (tp_base_contact_list_remove_group_finish (self, result, &error))
{
DEBUG ("Removing group '%s' succeeded", (gchar *) user_data);
}
else
{
DEBUG ("Removing group '%s' failed: %s #%d: %s", (gchar *) user_data,
g_quark_to_string (error->domain), error->code, error->message);
g_clear_error (&error);
}
g_free (user_data);
} | false | false | false | false | false | 0 |
isInCurrentFrame(VarDeclaration *v)
{
if (v->isDataseg() && !v->isCTFE())
return false; // It's a global
return v->ctfeAdrOnStack >= framepointer;
} | false | false | false | false | false | 0 |
fromutf8(std::string str)
{
return mail::iconvert::convert(str, "utf-8",
unicode_default_chset());
} | false | false | false | false | false | 0 |
areNeighbours( GenericFightCell * cell1, GenericFightCell * cell2 )
{
bool ret = false;
if( !cell1 || !cell2 ) {
return ret;
}
if( ( getNeighbour1( cell1 ) == cell2 ) ||
( getNeighbour2( cell1 ) == cell2 ) ||
( getNeighbour3( cell1 ) == cell2 ) ||
( getNeighbour4( cell1 ) == cell2 ) ||
( getNeighbour5( cell1 ) == cell2 ) ||
( getNeighbour6( cell1 ) == cell2 ) ||
( cell1 == cell2 )){
ret = true;
}
return ret;
} | false | false | false | false | false | 0 |
GetPixelData(int x1, int y1,
int x2, int y2,
int front, unsigned char* data)
{
int y_low, y_hi;
int x_low, x_hi;
// set the current window
this->MakeCurrent();
if (y1 < y2)
{
y_low = y1;
y_hi = y2;
}
else
{
y_low = y2;
y_hi = y1;
}
if (x1 < x2)
{
x_low = x1;
x_hi = x2;
}
else
{
x_low = x2;
x_hi = x1;
}
// Must clear previous errors first.
while(glGetError() != GL_NO_ERROR)
{
;
}
if (front)
{
glReadBuffer(static_cast<GLenum>(this->GetFrontLeftBuffer()));
}
else
{
glReadBuffer(static_cast<GLenum>(this->GetBackLeftBuffer()));
}
glDisable( GL_SCISSOR_TEST );
#if defined(sparc) && !defined(GL_VERSION_1_2)
// We need to read the image data one row at a time and convert it
// from RGBA to RGB to get around a bug in Sun OpenGL 1.1
long xloop, yloop;
unsigned char *buffer;
unsigned char *p_data = NULL;
buffer = new unsigned char [4*(x_hi - x_low + 1)];
p_data = data;
for (yloop = y_low; yloop <= y_hi; yloop++)
{
// read in a row of pixels
glReadPixels(x_low,yloop,(x_hi-x_low+1),1,
GL_RGBA, GL_UNSIGNED_BYTE, buffer);
for (xloop = 0; xloop <= x_hi-x_low; xloop++)
{
*p_data = buffer[xloop*4]; p_data++;
*p_data = buffer[xloop*4+1]; p_data++;
*p_data = buffer[xloop*4+2]; p_data++;
}
}
delete [] buffer;
#else
// If the Sun bug is ever fixed, then we could use the following
// technique which provides a vast speed improvement on the SGI
// Turn of texturing in case it is on - some drivers have a problem
// getting / setting pixels with texturing enabled.
glDisable( GL_TEXTURE_2D );
// Calling pack alignment ensures that we can grab the any size window
glPixelStorei( GL_PACK_ALIGNMENT, 1 );
glReadPixels(x_low, y_low, x_hi-x_low+1, y_hi-y_low+1, GL_RGB,
GL_UNSIGNED_BYTE, data);
#endif
if (glGetError() != GL_NO_ERROR)
{
return VTK_ERROR;
}
else
{
return VTK_OK;
}
} | 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.