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 |
|---|---|---|---|---|---|---|
babl_extension_load_dir (const char *base_path)
{
DIR *dir;
if ((dir = opendir (base_path)))
{
struct dirent *dentry;
while ((dentry = readdir (dir)) != NULL)
{
if (dentry->d_name[0] != '.')
{
char *path = NULL;
struct stat st;
char *extension;
path = babl_strcat (path, base_path);
path = babl_strcat (path, BABL_DIR_SEPARATOR);
path = babl_strcat (path, dentry->d_name);
stat (path, &st);
if ((extension = strrchr (dentry->d_name, '.')) != NULL &&
!strcmp (extension, SHREXT))
{
babl_extension_load (path);
}
babl_free (path);
}
}
closedir (dir);
}
} | false | false | false | false | false | 0 |
NewerThan(time_t t) const
{
return((defined&DATE) && date>t);
} | false | false | false | false | false | 0 |
validatePage()
{
if (!serverWidget->connectionSucceeded())
return false;
// get grants on database for the user
Utils::Database::Grants grants = serverWidget->grantsOnLastConnectedDatabase();
// if grants not suffisant -> warning dialog
if (!((grants & Utils::Database::Grant_Select) &&
(grants & Utils::Database::Grant_Update) &&
(grants & Utils::Database::Grant_Insert) &&
(grants & Utils::Database::Grant_Delete) &&
(grants & Utils::Database::Grant_Create) &&
(grants & Utils::Database::Grant_Drop) &&
(grants & Utils::Database::Grant_Alter) &&
(grants & Utils::Database::Grant_CreateUser)
)) {
Utils::warningMessageBox(tr("Connection to the server: User rights inadequate"),
tr("You need to connect with another user that have rights to "
"select, udpate, delete, insert, create, drop, alter and create user.\n"
"Please contact your server administrator."));
Q_EMIT completeChanged();
return false;
}
// execute the server configuration SQL script
{
QSqlDatabase mysql = QSqlDatabase::addDatabase("QMYSQL", "__APP_CONNECTION_TESTER");
mysql.setHostName(serverWidget->hostName());
mysql.setPort(serverWidget->port());
mysql.setUserName(serverWidget->login());
mysql.setPassword(serverWidget->password());
mysql.setDatabaseName("mysql");
if (!mysql.open()) {
LOG_ERROR(tkTr(Trans::Constants::UNABLE_TO_OPEN_DATABASE_1_ERROR_2).arg(mysql.connectionName()).arg(mysql.lastError().text()));
QSqlDatabase::removeDatabase("__APP_CONNECTION_TESTER");
Q_EMIT completeChanged();
return false;
}
// execute script : server configurator
QSqlQuery query(mysql);
if (query.exec("SELECT * FROM `user` where User='fmf_admin';")) {
if (query.next()) {
LOG("Server already configured");
Utils::informativeMessageBox(tr("Server already configured"), tr("The server is already configured for FreeMedForms."));
} else {
LOG("Executing server configuration SQL script");
QString error;
if (!Utils::Database::executeSqlFile("__APP_CONNECTION_TESTER", serverConfigurationSqlScript(), &error)) {
LOG_ERROR("Server configuration script not processed");
Utils::warningMessageBox(tr("An error occured..."),
tr("An error occured when trying to execute the script configuration script.\n"
"Please check out the log files and contact your administrator."),
error);
} else {
LOG("Server successfully configured");
Utils::informativeMessageBox(tr("Server configured"), tr("The server was successfully configured."));
}
}
}
}
QSqlDatabase::removeDatabase("__APP_CONNECTION_TESTER");
return true;
} | false | false | false | false | false | 0 |
MakePtyBuffers()
{
int fd=ssh->getfd();
if(fd==-1)
return;
ssh->Kill(SIGCONT);
send_buf=new IOBufferFDStream(new FDStream(ssh->getfd_pipe_out(),"pipe-out"),IOBuffer::PUT);
recv_buf=new IOBufferFDStream(new FDStream(ssh->getfd_pipe_in(),"pipe-in"),IOBuffer::GET);
pty_send_buf=new IOBufferFDStream(ssh.borrow(),IOBuffer::PUT);
pty_recv_buf=new IOBufferFDStream(new FDStream(fd,"pseudo-tty"),IOBuffer::GET);
} | false | false | false | false | false | 0 |
rtl92d_phy_set_poweron(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
unsigned long flags;
u8 value8;
u16 i;
u32 mac_reg = (rtlhal->interfaceindex == 0 ? REG_MAC0 : REG_MAC1);
/* notice fw know band status 0x81[1]/0x53[1] = 0: 5G, 1: 2G */
if (rtlhal->current_bandtype == BAND_ON_2_4G) {
value8 = rtl_read_byte(rtlpriv, mac_reg);
value8 |= BIT(1);
rtl_write_byte(rtlpriv, mac_reg, value8);
} else {
value8 = rtl_read_byte(rtlpriv, mac_reg);
value8 &= (~BIT(1));
rtl_write_byte(rtlpriv, mac_reg, value8);
}
if (rtlhal->macphymode == SINGLEMAC_SINGLEPHY) {
value8 = rtl_read_byte(rtlpriv, REG_MAC0);
rtl_write_byte(rtlpriv, REG_MAC0, value8 | MAC0_ON);
} else {
spin_lock_irqsave(&globalmutex_power, flags);
if (rtlhal->interfaceindex == 0) {
value8 = rtl_read_byte(rtlpriv, REG_MAC0);
rtl_write_byte(rtlpriv, REG_MAC0, value8 | MAC0_ON);
} else {
value8 = rtl_read_byte(rtlpriv, REG_MAC1);
rtl_write_byte(rtlpriv, REG_MAC1, value8 | MAC1_ON);
}
value8 = rtl_read_byte(rtlpriv, REG_POWER_OFF_IN_PROCESS);
spin_unlock_irqrestore(&globalmutex_power, flags);
for (i = 0; i < 200; i++) {
if ((value8 & BIT(7)) == 0) {
break;
} else {
udelay(500);
spin_lock_irqsave(&globalmutex_power, flags);
value8 = rtl_read_byte(rtlpriv,
REG_POWER_OFF_IN_PROCESS);
spin_unlock_irqrestore(&globalmutex_power,
flags);
}
}
if (i == 200)
RT_ASSERT(false, "Another mac power off over time\n");
}
} | false | false | false | false | false | 0 |
pre_expr_reaches_here_p_work (occr_bb, expr, bb, visited)
basic_block occr_bb;
struct expr *expr;
basic_block bb;
char *visited;
{
edge pred;
for (pred = bb->pred; pred != NULL; pred = pred->pred_next)
{
basic_block pred_bb = pred->src;
if (pred->src == ENTRY_BLOCK_PTR
/* Has predecessor has already been visited? */
|| visited[pred_bb->index])
;/* Nothing to do. */
/* Does this predecessor generate this expression? */
else if (TEST_BIT (comp[pred_bb->index], expr->bitmap_index))
{
/* Is this the occurrence we're looking for?
Note that there's only one generating occurrence per block
so we just need to check the block number. */
if (occr_bb == pred_bb)
return 1;
visited[pred_bb->index] = 1;
}
/* Ignore this predecessor if it kills the expression. */
else if (! TEST_BIT (transp[pred_bb->index], expr->bitmap_index))
visited[pred_bb->index] = 1;
/* Neither gen nor kill. */
else
{
visited[pred_bb->index] = 1;
if (pre_expr_reaches_here_p_work (occr_bb, expr, pred_bb, visited))
return 1;
}
}
/* All paths have been checked. */
return 0;
} | false | false | false | false | false | 0 |
trampoline_handler(struct pt_regs *regs)
{
struct kretprobe_instance *ri = NULL;
struct hlist_head *head, empty_rp;
struct hlist_node *tmp;
unsigned long flags, orig_ret_address = 0;
unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline;
kprobe_opcode_t *correct_ret_addr = NULL;
INIT_HLIST_HEAD(&empty_rp);
kretprobe_hash_lock(current, &head, &flags);
/* fixup registers */
#ifdef CONFIG_X86_64
regs->cs = __KERNEL_CS;
#else
regs->cs = __KERNEL_CS | get_kernel_rpl();
regs->gs = 0;
#endif
regs->ip = trampoline_address;
regs->orig_ax = ~0UL;
/*
* It is possible to have multiple instances associated with a given
* task either because multiple functions in the call path have
* return probes installed on them, and/or more than one
* return probe was registered for a target function.
*
* We can handle this because:
* - instances are always pushed into the head of the list
* - when multiple return probes are registered for the same
* function, the (chronologically) first instance's ret_addr
* will be the real return address, and all the rest will
* point to kretprobe_trampoline.
*/
hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current)
/* another task is sharing our hash bucket */
continue;
orig_ret_address = (unsigned long)ri->ret_addr;
if (orig_ret_address != trampoline_address)
/*
* This is the real return address. Any other
* instances associated with this task are for
* other calls deeper on the call stack
*/
break;
}
kretprobe_assert(ri, orig_ret_address, trampoline_address);
correct_ret_addr = ri->ret_addr;
hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current)
/* another task is sharing our hash bucket */
continue;
orig_ret_address = (unsigned long)ri->ret_addr;
if (ri->rp && ri->rp->handler) {
__this_cpu_write(current_kprobe, &ri->rp->kp);
get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE;
ri->ret_addr = correct_ret_addr;
ri->rp->handler(ri, regs);
__this_cpu_write(current_kprobe, NULL);
}
recycle_rp_inst(ri, &empty_rp);
if (orig_ret_address != trampoline_address)
/*
* This is the real return address. Any other
* instances associated with this task are for
* other calls deeper on the call stack
*/
break;
}
kretprobe_hash_unlock(current, &flags);
hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist);
kfree(ri);
}
return (void *)orig_ret_address;
} | false | false | false | true | true | 1 |
Lgraphic_char_p()
{
# line 41 "character.d"
int i;
int narg;
register object *DPPbase=vs_base;
#define c DPPbase[0]
narg = vs_top - vs_base;
check_arg(1);
# line 43 "character.d"
check_type_character(&c);
if (char_font(c) != 0 || char_bits(c) != 0)
{
vs_base[0] = Cnil;
vs_top = vs_base + 1;
return;
}
# line 46 "character.d"
i = char_code(c);
if (' ' <= i && i < '\177')
{
vs_base[0] = Ct;
vs_top = vs_base + 1;
return;
}
# line 49 "character.d"
{
vs_base[0] = Cnil;
vs_top = vs_base + 1;
return;
}
# line 50 "character.d"
#undef c
} | false | false | false | false | false | 0 |
report()
{
QString url = appsettings->cvalue(main->cyclist, GC_DVURL, "").toString();
if (url == "") return false; // not configured
QNetworkRequest request = QNetworkRequest(QUrl(url));
QByteArray *queryText = new QByteArray("<x1:calendar-query xmlns:x1=\"urn:ietf:params:xml:ns:caldav\">"
"<x0:prop xmlns:x0=\"DAV:\">"
"<x0:getetag/>"
"<x1:calendar-data/>"
"</x0:prop>"
"<x1:filter>"
"<x1:comp-filter name=\"VCALENDAR\">"
"<x1:comp-filter name=\"VEVENT\">"
"<x1:time-range end=\"21001231\" start=\"20000101T000000Z\"/>"
"</x1:comp-filter>"
"</x1:comp-filter>"
"</x1:filter>"
"</x1:calendar-query>");
QBuffer *query = new QBuffer(queryText);
mode = Report;
QNetworkReply *reply = nam->sendCustomRequest(request, "REPORT", query);
if (reply->error() != QNetworkReply::NoError) {
QMessageBox::warning(main, tr("CalDAV REPORT url error"), reply->errorString());
mode = None;
return false;
}
return true;
} | false | false | false | false | false | 0 |
rb_f_trace_var(int argc, VALUE *argv)
{
VALUE var, cmd;
struct global_entry *entry;
struct trace_var *trace;
rb_secure(4);
if (rb_scan_args(argc, argv, "11", &var, &cmd) == 1) {
cmd = rb_block_proc();
}
if (NIL_P(cmd)) {
return rb_f_untrace_var(argc, argv);
}
entry = rb_global_entry(rb_to_id(var));
if (OBJ_TAINTED(cmd)) {
rb_raise(rb_eSecurityError, "Insecure: tainted variable trace");
}
trace = ALLOC(struct trace_var);
trace->next = entry->var->trace;
trace->func = rb_trace_eval;
trace->data = cmd;
trace->removed = 0;
entry->var->trace = trace;
return Qnil;
} | false | false | false | false | false | 0 |
eel_editable_label_accessible_get_name (AtkObject *accessible)
{
if (accessible->name != NULL)
return accessible->name;
else
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget == NULL)
/* State is defunct */
return NULL;
g_assert (EEL_IS_EDITABLE_LABEL (widget));
return eel_editable_label_get_text (EEL_EDITABLE_LABEL (widget));
}
} | false | false | false | false | false | 0 |
ReorderFieldDefns( int* panMap )
{
if (nFieldCount == 0)
return OGRERR_NONE;
OGRErr eErr = OGRCheckPermutation(panMap, nFieldCount);
if (eErr != OGRERR_NONE)
return eErr;
OGRFieldDefn** papoFieldDefnNew = (OGRFieldDefn**)
CPLMalloc(sizeof(OGRFieldDefn*) * nFieldCount);
for(int i=0;i<nFieldCount;i++)
{
papoFieldDefnNew[i] = papoFieldDefn[panMap[i]];
}
CPLFree(papoFieldDefn);
papoFieldDefn = papoFieldDefnNew;
return OGRERR_NONE;
} | false | false | false | false | false | 0 |
print_ref_list(int kinds, int detached, int verbose, int abbrev, struct commit_list *with_commit)
{
int i;
struct append_ref_cb cb;
struct ref_list ref_list;
memset(&ref_list, 0, sizeof(ref_list));
ref_list.kinds = kinds;
ref_list.verbose = verbose;
ref_list.abbrev = abbrev;
ref_list.with_commit = with_commit;
if (merge_filter != NO_FILTER)
init_revisions(&ref_list.revs, NULL);
cb.ref_list = &ref_list;
cb.ret = 0;
for_each_rawref(append_ref, &cb);
if (merge_filter != NO_FILTER) {
struct commit *filter;
filter = lookup_commit_reference_gently(merge_filter_ref, 0);
filter->object.flags |= UNINTERESTING;
add_pending_object(&ref_list.revs,
(struct object *) filter, "");
ref_list.revs.limited = 1;
prepare_revision_walk(&ref_list.revs);
if (verbose)
ref_list.maxwidth = calc_maxwidth(&ref_list);
}
qsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp);
detached = (detached && (kinds & REF_LOCAL_BRANCH));
if (detached)
show_detached(&ref_list);
for (i = 0; i < ref_list.index; i++) {
int current = !detached &&
(ref_list.list[i].kind == REF_LOCAL_BRANCH) &&
!strcmp(ref_list.list[i].name, head);
char *prefix = (kinds != REF_REMOTE_BRANCH &&
ref_list.list[i].kind == REF_REMOTE_BRANCH)
? "remotes/" : "";
print_ref_item(&ref_list.list[i], ref_list.maxwidth, verbose,
abbrev, current, prefix);
}
free_ref_list(&ref_list);
if (cb.ret)
error(_("some refs could not be read"));
return cb.ret;
} | false | false | false | false | false | 0 |
cupsArrayClear(cups_array_t *a) /* I - Array */
{
/*
* Range check input...
*/
if (!a)
return;
/*
* Free the existing elements as needed..
*/
if (a->freefunc)
{
int i; /* Looping var */
void **e; /* Current element */
for (i = a->num_elements, e = a->elements; i > 0; i --, e ++)
(a->freefunc)(*e, a->data);
}
/*
* Set the number of elements to 0; we don't actually free the memory
* here - that is done in cupsArrayDelete()...
*/
a->num_elements = 0;
a->current = -1;
a->insert = -1;
a->unique = 1;
a->num_saved = 0;
} | false | false | false | false | false | 0 |
isUpperCaseName() const
{
if (!isName())
return false;
for (size_t i = 0; i < _str.length(); ++i) {
if (std::islower(_str[i]))
return false;
}
return true;
} | false | false | false | false | false | 0 |
start (gboolean showpref)
{
if (!showpref)
if (biff_->value_uint ("check_mode") == AUTOMATIC_CHECK)
biff_->start_monitoring (3);
} | false | false | false | false | false | 0 |
wb_mode_query(const void *mode, int request, void *ptr)
{
const SpeexSBMode *m = (const SpeexSBMode*)mode;
switch (request)
{
case SPEEX_MODE_FRAME_SIZE:
*((int*)ptr)=2*m->frameSize;
break;
case SPEEX_SUBMODE_BITS_PER_FRAME:
if (*((int*)ptr)==0)
*((int*)ptr) = SB_SUBMODE_BITS+1;
else if (m->submodes[*((int*)ptr)]==NULL)
*((int*)ptr) = -1;
else
*((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;
break;
default:
speex_warning_int("Unknown wb_mode_query request: ", request);
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
recoveryStopsAfter(XLogReaderState *record)
{
uint8 info;
uint8 xact_info;
uint8 rmid;
TimestampTz recordXtime;
info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
rmid = XLogRecGetRmid(record);
/*
* There can be many restore points that share the same name; we stop at
* the first one.
*/
if (recoveryTarget == RECOVERY_TARGET_NAME &&
rmid == RM_XLOG_ID && info == XLOG_RESTORE_POINT)
{
xl_restore_point *recordRestorePointData;
recordRestorePointData = (xl_restore_point *) XLogRecGetData(record);
if (strcmp(recordRestorePointData->rp_name, recoveryTargetName) == 0)
{
recoveryStopAfter = true;
recoveryStopXid = InvalidTransactionId;
(void) getRecordTimestamp(record, &recoveryStopTime);
strlcpy(recoveryStopName, recordRestorePointData->rp_name, MAXFNAMELEN);
ereport(LOG,
(errmsg("recovery stopping at restore point \"%s\", time %s",
recoveryStopName,
timestamptz_to_str(recoveryStopTime))));
return true;
}
}
if (rmid != RM_XACT_ID)
return false;
xact_info = info & XLOG_XACT_OPMASK;
if (xact_info == XLOG_XACT_COMMIT ||
xact_info == XLOG_XACT_COMMIT_PREPARED ||
xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
TransactionId recordXid;
/* Update the last applied transaction timestamp */
if (getRecordTimestamp(record, &recordXtime))
SetLatestXTime(recordXtime);
/* Extract the XID of the committed/aborted transaction */
if (xact_info == XLOG_XACT_COMMIT_PREPARED)
{
xl_xact_commit *xlrec = (xl_xact_commit *) XLogRecGetData(record);
xl_xact_parsed_commit parsed;
ParseCommitRecord(XLogRecGetInfo(record),
xlrec,
&parsed);
recordXid = parsed.twophase_xid;
}
else if (xact_info == XLOG_XACT_ABORT_PREPARED)
{
xl_xact_abort *xlrec = (xl_xact_abort *) XLogRecGetData(record);
xl_xact_parsed_abort parsed;
ParseAbortRecord(XLogRecGetInfo(record),
xlrec,
&parsed);
recordXid = parsed.twophase_xid;
}
else
recordXid = XLogRecGetXid(record);
/*
* There can be only one transaction end record with this exact
* transactionid
*
* when testing for an xid, we MUST test for equality only, since
* transactions are numbered in the order they start, not the order
* they complete. A higher numbered xid will complete before you about
* 50% of the time...
*/
if (recoveryTarget == RECOVERY_TARGET_XID && recoveryTargetInclusive &&
recordXid == recoveryTargetXid)
{
recoveryStopAfter = true;
recoveryStopXid = recordXid;
recoveryStopTime = recordXtime;
recoveryStopName[0] = '\0';
if (xact_info == XLOG_XACT_COMMIT ||
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
(errmsg("recovery stopping after commit of transaction %u, time %s",
recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
(errmsg("recovery stopping after abort of transaction %u, time %s",
recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
}
}
/* Check if we should stop as soon as reaching consistency */
if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE && reachedConsistency)
{
ereport(LOG,
(errmsg("recovery stopping after reaching consistency")));
recoveryStopAfter = true;
recoveryStopXid = InvalidTransactionId;
recoveryStopTime = 0;
recoveryStopName[0] = '\0';
return true;
}
return false;
} | false | false | false | false | false | 0 |
init_transput_buffers (NODE_T * p)
{
int k;
for (k = 0; k < MAX_TRANSPUT_BUFFER; k++) {
ref_transput_buffer[k] = heap_generator (p, MODE (ROWS), 2 * ALIGNED_SIZE_OF (A68_INT) + TRANSPUT_BUFFER_SIZE);
BLOCK_GC_HANDLE (&ref_transput_buffer[k]);
set_transput_buffer_size (k, TRANSPUT_BUFFER_SIZE);
reset_transput_buffer (k);
}
/* Last buffers are available for FILE values */
for (k = FIXED_TRANSPUT_BUFFERS; k < MAX_TRANSPUT_BUFFER; k++) {
unblock_transput_buffer (k);
}
} | false | false | false | false | false | 0 |
knh_NameSpace_gettype(CTX ctx, kNameSpace *ns, kbytes_t name)
{
if(name.utext[0] == 'v') {
if(name.len == 4 && name.utext[1] == 'o' &&
name.utext[2] == 'i' && name.utext[3] == 'd') return TYPE_void;
if(name.len == 3 && name.utext[1] == 'a' && name.utext[2] == 'r') {
return TYPE_var;
}
}
return knh_NameSpace_getcid(ctx, ns, name);
} | false | false | false | false | false | 0 |
heap_sift(HeapElem *h, int root, int size)
{
while(root*2+1 < size) {
int child = root*2+1;
if(child < size-1 && h[child].val > h[child+1].val)
child++;
if(h[root].val > h[child].val) {
FFSWAP(HeapElem, h[root], h[child]);
root = child;
} else
break;
}
} | false | false | false | false | false | 0 |
Entries_Close (List *list)
{
if (list)
{
if (!noexec)
{
if (isfile (CVSADM_ENTLOG))
write_entries (list);
}
dellist (&list);
}
} | false | false | false | false | false | 0 |
send_session_cancellation_to_relay(turnsession_id sid)
{
int ret = 0;
struct message_to_relay sm;
ns_bzero(&sm,sizeof(struct message_to_relay));
sm.t = RMT_CANCEL_SESSION;
turnserver_id id = (turnserver_id)(sid / TURN_SESSION_ID_FACTOR);
struct relay_server *rs = NULL;
if(id>=TURNSERVER_ID_BOUNDARY_BETWEEN_TCP_AND_UDP) {
size_t dest = id-TURNSERVER_ID_BOUNDARY_BETWEEN_TCP_AND_UDP;
if(dest >= get_real_udp_relay_servers_number()) {
TURN_LOG_FUNC(
TURN_LOG_LEVEL_ERROR,
"%s: Too large UDP relay number: %d, total=%d\n",
__FUNCTION__,(int)dest,(int)get_real_udp_relay_servers_number());
ret = -1;
goto err;
}
rs = udp_relay_servers[dest];
if(!rs) {
TURN_LOG_FUNC(
TURN_LOG_LEVEL_ERROR,
"%s: Wrong UDP relay number: %d, total=%d\n",
__FUNCTION__,(int)dest,(int)get_real_udp_relay_servers_number());
ret = -1;
goto err;
}
} else {
size_t dest = id;
if(dest >= get_real_general_relay_servers_number()) {
TURN_LOG_FUNC(
TURN_LOG_LEVEL_ERROR,
"%s: Too large general relay number: %d, total=%d\n",
__FUNCTION__,(int)dest,(int)get_real_general_relay_servers_number());
ret = -1;
goto err;
}
rs = general_relay_servers[dest];
if(!rs) {
TURN_LOG_FUNC(
TURN_LOG_LEVEL_ERROR,
"%s: Wrong general relay number: %d, total=%d\n",
__FUNCTION__,(int)dest,(int)get_real_general_relay_servers_number());
ret = -1;
goto err;
}
}
sm.relay_server = rs;
sm.m.csm.id = sid;
{
struct evbuffer *output = bufferevent_get_output(rs->out_buf);
if(output) {
evbuffer_add(output,&sm,sizeof(struct message_to_relay));
} else {
TURN_LOG_FUNC(
TURN_LOG_LEVEL_ERROR,
"%s: Empty output buffer\n",
__FUNCTION__);
ret = -1;
}
}
err:
return ret;
} | false | false | false | false | false | 0 |
onCmdBackColor(FXObject*,FXSelector sel,void* ptr){
FXColor color=(FXColor)(FXuval)ptr;
background[0]=background[1]=color;
if(FXSELTYPE(sel)==SEL_COMMAND || !turbomode){
update();
}
return 1;
} | false | false | false | false | false | 0 |
data(const QModelIndex& index, int role) const
{
const Node* node = nodeFromIndex(index);
if (node == NULL || node->data() == NULL)
return 0;
if (node->data()->type() == StyleNode) {
// Get the lexer and style ID for this node.
StyleData* data = static_cast<StyleData*>(node->data());
QsciLexer* lexer = data->lexer_;
int style = data->style_;
switch (index.column()) {
case 0:
// Show language name or style name in the first column.
if (role == Qt::DisplayRole) {
if (style == lexer->defaultStyle())
return lexer->language();
return lexer->description(style);
}
break;
case 1:
// Show a formatted text string in the second column, using the
// style's properties.
return styleData(node, role);
}
}
else {
// Get the lexer and style ID for this node.
PropertyData* data = static_cast<PropertyData*>(node->data());
switch (index.column()) {
case 0:
if (role == Qt::DisplayRole)
return propertyName(data->prop_);
break;
case 1:
return propertyData(data, role);
}
}
return QVariant();
} | false | false | false | false | false | 0 |
snd_usb_lock_shutdown(struct snd_usb_audio *chip)
{
int err;
atomic_inc(&chip->usage_count);
if (atomic_read(&chip->shutdown)) {
err = -EIO;
goto error;
}
err = snd_usb_autoresume(chip);
if (err < 0)
goto error;
return 0;
error:
if (atomic_dec_and_test(&chip->usage_count))
wake_up(&chip->shutdown_wait);
return err;
} | false | false | false | false | false | 0 |
gst_rtp_L16_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstRtpL16Depay *rtpL16depay;
gint clock_rate, payload;
gint channels;
GstCaps *srccaps;
gboolean res;
const gchar *channel_order;
const GstRTPChannelOrder *order;
rtpL16depay = GST_RTP_L16_DEPAY (depayload);
structure = gst_caps_get_structure (caps, 0);
payload = 96;
gst_structure_get_int (structure, "payload", &payload);
switch (payload) {
case GST_RTP_PAYLOAD_L16_STEREO:
channels = 2;
clock_rate = 44100;
break;
case GST_RTP_PAYLOAD_L16_MONO:
channels = 1;
clock_rate = 44100;
break;
default:
/* no fixed mapping, we need clock-rate */
channels = 0;
clock_rate = 0;
break;
}
/* caps can overwrite defaults */
clock_rate =
gst_rtp_L16_depay_parse_int (structure, "clock-rate", clock_rate);
if (clock_rate == 0)
goto no_clockrate;
channels =
gst_rtp_L16_depay_parse_int (structure, "encoding-params", channels);
if (channels == 0) {
channels = gst_rtp_L16_depay_parse_int (structure, "channels", channels);
if (channels == 0) {
/* channels defaults to 1 otherwise */
channels = 1;
}
}
depayload->clock_rate = clock_rate;
rtpL16depay->rate = clock_rate;
rtpL16depay->channels = channels;
srccaps = gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BIG_ENDIAN,
"signed", G_TYPE_BOOLEAN, TRUE,
"width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16,
"rate", G_TYPE_INT, clock_rate, "channels", G_TYPE_INT, channels, NULL);
/* add channel positions */
channel_order = gst_structure_get_string (structure, "channel-order");
order = gst_rtp_channels_get_by_order (channels, channel_order);
if (order) {
gst_audio_set_channel_positions (gst_caps_get_structure (srccaps, 0),
order->pos);
} else {
GstAudioChannelPosition *pos;
GST_ELEMENT_WARNING (rtpL16depay, STREAM, DECODE,
(NULL), ("Unknown channel order '%s' for %d channels",
GST_STR_NULL (channel_order), channels));
/* create default NONE layout */
pos = gst_rtp_channels_create_default (channels);
gst_audio_set_channel_positions (gst_caps_get_structure (srccaps, 0), pos);
g_free (pos);
}
res = gst_pad_set_caps (depayload->srcpad, srccaps);
gst_caps_unref (srccaps);
return res;
/* ERRORS */
no_clockrate:
{
GST_ERROR_OBJECT (depayload, "no clock-rate specified");
return FALSE;
}
} | false | false | false | false | false | 0 |
mypopen(char *cmd, char *mode)
{
#ifdef __DJGPP__
/* HBB 20010312: Has its own implementation of popen(), which
* is better suited to the platform than cscope's */
return (popen)(cmd, mode);
#else
int p[2];
pid_t *poptr;
int myside, yourside;
pid_t pid;
if(pipe(p) < 0)
return(NULL);
myside = tst(p[WTR], p[RDR]);
yourside = tst(p[RDR], p[WTR]);
if((pid = fork()) == 0) {
/* myside and yourside reverse roles in child */
int stdio;
/* close all pipes from other popen's */
for (poptr = popen_pid; poptr < popen_pid+20; poptr++) {
if(*poptr)
(void) close(poptr - popen_pid);
}
stdio = tst(0, 1);
close(myside);
close(stdio);
#if V9
dup2(yourside, stdio);
#else
fcntl(yourside, F_DUPFD, stdio);
#endif
close(yourside);
execlp(shell, mybasename(shell), "-c", cmd, (void *)0);
_exit(1);
} else if (pid > 0)
tstat = signal(SIGTSTP, SIG_DFL);
if(pid == -1)
return(NULL);
popen_pid[myside] = pid;
(void) close(yourside);
return(fdopen(myside, mode));
#endif /* DJGPP */
} | false | false | false | false | true | 1 |
pcihp_is_ejectable(acpi_handle handle)
{
acpi_status status;
unsigned long long removable;
if (!acpi_has_method(handle, "_ADR"))
return 0;
if (acpi_has_method(handle, "_EJ0"))
return 1;
status = acpi_evaluate_integer(handle, "_RMV", NULL, &removable);
if (ACPI_SUCCESS(status) && removable)
return 1;
return 0;
} | false | false | false | false | false | 0 |
write_frame( hnd_t handle, uint8_t *p_nalu, int i_size, x264_picture_t *p_picture )
{
flv_hnd_t *p_flv = handle;
flv_buffer *c = p_flv->c;
#define convert_timebase_ms( timestamp, timebase ) (int64_t)((timestamp) * (timebase) * 1000 + 0.5)
if( !p_flv->i_framenum )
{
p_flv->i_delay_time = p_picture->i_dts * -1;
if( !p_flv->b_dts_compress && p_flv->i_delay_time )
x264_cli_log( "flv", X264_LOG_INFO, "initial delay %"PRId64" ms\n",
convert_timebase_ms( p_picture->i_pts + p_flv->i_delay_time, p_flv->d_timebase ) );
}
int64_t dts;
int64_t cts;
int64_t offset;
if( p_flv->b_dts_compress )
{
if( p_flv->i_framenum == 1 )
p_flv->i_init_delta = convert_timebase_ms( p_picture->i_dts + p_flv->i_delay_time, p_flv->d_timebase );
dts = p_flv->i_framenum > p_flv->i_delay_frames
? convert_timebase_ms( p_picture->i_dts, p_flv->d_timebase )
: p_flv->i_framenum * p_flv->i_init_delta / (p_flv->i_delay_frames + 1);
cts = convert_timebase_ms( p_picture->i_pts, p_flv->d_timebase );
}
else
{
dts = convert_timebase_ms( p_picture->i_dts + p_flv->i_delay_time, p_flv->d_timebase );
cts = convert_timebase_ms( p_picture->i_pts + p_flv->i_delay_time, p_flv->d_timebase );
}
offset = cts - dts;
if( p_flv->i_framenum )
{
if( p_flv->i_prev_dts == dts )
x264_cli_log( "flv", X264_LOG_WARNING, "duplicate DTS %"PRId64" generated by rounding\n"
" decoding framerate cannot exceed 1000fps\n", dts );
if( p_flv->i_prev_cts == cts )
x264_cli_log( "flv", X264_LOG_WARNING, "duplicate CTS %"PRId64" generated by rounding\n"
" composition framerate cannot exceed 1000fps\n", cts );
}
p_flv->i_prev_dts = dts;
p_flv->i_prev_cts = cts;
// A new frame - write packet header
flv_put_byte( c, FLV_TAG_TYPE_VIDEO );
flv_put_be24( c, 0 ); // calculated later
flv_put_be24( c, dts );
flv_put_byte( c, dts >> 24 );
flv_put_be24( c, 0 );
p_flv->start = c->d_cur;
flv_put_byte( c, p_picture->b_keyframe ? FLV_FRAME_KEY : FLV_FRAME_INTER );
flv_put_byte( c, 1 ); // AVC NALU
flv_put_be24( c, offset );
if( p_flv->sei )
{
flv_append_data( c, p_flv->sei, p_flv->sei_len );
free( p_flv->sei );
p_flv->sei = NULL;
}
flv_append_data( c, p_nalu, i_size );
unsigned length = c->d_cur - p_flv->start;
flv_rewrite_amf_be24( c, length, p_flv->start - 10 );
flv_put_be32( c, 11 + length ); // Last tag size
CHECK( flv_flush_data( c ) );
p_flv->i_framenum++;
return i_size;
} | false | false | false | false | false | 0 |
atk_table_get_index_at (AtkTable *table,
gint row,
gint column)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), -1);
g_return_val_if_fail (row >= 0, -1);
g_return_val_if_fail (column >= 0, -1);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_index_at)
return (iface->get_index_at) (table, row, column);
else
return -1;
} | false | false | false | false | false | 0 |
_parse_playlistmark(BITSTREAM *bits, MPLS_PL *pl)
{
int ii;
MPLS_PLM *plm = NULL;
bs_seek_byte(bits, pl->mark_pos);
// Skip the length field, I don't use it
bs_skip(bits, 32);
// Then get the number of marks
pl->mark_count = bs_read(bits, 16);
plm = calloc(pl->mark_count, sizeof(MPLS_PLM));
for (ii = 0; ii < pl->mark_count; ii++) {
plm[ii].mark_id = bs_read(bits, 8);
plm[ii].mark_type = bs_read(bits, 8);
plm[ii].play_item_ref = bs_read(bits, 16);
plm[ii].time = bs_read(bits, 32);
plm[ii].entry_es_pid = bs_read(bits, 16);
plm[ii].duration = bs_read(bits, 32);
}
pl->play_mark = plm;
return 1;
} | false | false | false | false | false | 0 |
connect_drag_signals (BonoboDock *dock,
GtkWidget *item)
{
if (BONOBO_IS_DOCK_ITEM (item))
{
DEBUG (("here"));
g_signal_connect (item, "dock_drag_begin",
G_CALLBACK (drag_begin), dock);
g_signal_connect (item, "dock_drag_motion",
G_CALLBACK (drag_motion), dock);
g_signal_connect (item, "dock_drag_end",
G_CALLBACK (drag_end), dock);
}
} | false | false | false | false | false | 0 |
nextToken(OptionsParser::TokenType type)
{
if (m_it == m_end) {
if (type == OptionsParser::RequiredToken) {
m_hasError = true;
if (m_errorString)
*m_errorString = QCoreApplication::translate("PluginManager",
"The option %1 requires an argument.").arg(m_currentArg);
}
return false;
}
m_currentArg = *m_it;
++m_it;
return true;
} | false | false | false | false | false | 0 |
weight(struct obj *obj)
{
int wt = objects[obj->otyp].oc_weight;
if (obj->otyp == LARGE_BOX && obj->spe == 1) /* Schroedinger's Cat */
wt += mons[PM_HOUSECAT].cwt;
if (Is_container(obj) || obj->otyp == STATUE) {
struct obj *contents;
int cwt = 0;
if (obj->otyp == STATUE && obj->corpsenm >= LOW_PM)
wt = (int)obj->quan *
((int)mons[obj->corpsenm].cwt * 3 / 2);
for(contents=obj->cobj; contents; contents=contents->nobj)
cwt += weight(contents);
/*
* The weight of bags of holding is calculated as the weight
* of the bag plus the weight of the bag's contents modified
* as follows:
*
* Bag status Weight of contents
* ---------- ------------------
* cursed 2x
* blessed x/4 + 1
* otherwise x/2 + 1
*
* The macro DELTA_CWT in pickup.c also implements these
* weight equations.
*
* Note: The above checks are performed in the given order.
* this means that if an object is both blessed and
* cursed (not supposed to happen), it will be treated
* as cursed.
*/
if (obj->otyp == BAG_OF_HOLDING)
cwt = obj->cursed ? (cwt * 2) :
(1 + (cwt / (obj->blessed ? 4 : 2)));
return wt + cwt;
}
if (obj->otyp == CORPSE && obj->corpsenm >= LOW_PM) {
long long_wt = obj->quan * (long) mons[obj->corpsenm].cwt;
wt = (long_wt > LARGEST_INT) ? LARGEST_INT : (int)long_wt;
if (obj->oeaten) wt = eaten_stat(wt, obj);
return wt;
} else if (obj->oclass == FOOD_CLASS && obj->oeaten) {
return eaten_stat((int)obj->quan * wt, obj);
} else if (obj->oclass == COIN_CLASS)
return (int)((obj->quan + 50L) / 100L);
else if (obj->otyp == HEAVY_IRON_BALL && obj->owt != 0)
return (int) obj->owt; /* kludge for "very" heavy iron ball */
return(wt ? wt*(int)obj->quan : ((int)obj->quan + 1)>>1);
} | false | true | false | false | false | 1 |
av_get_q(void *obj, const char *name, const AVOption **o_out){
int64_t intnum=1;
double num=1;
int den=1;
av_get_number(obj, name, o_out, &num, &den, &intnum);
if(num == 1.0 && (int)intnum == intnum)
return (AVRational){intnum, den};
else
return av_d2q(num*intnum/den, 1<<24);
} | false | false | false | false | false | 0 |
getCodecDesc() const
{
CodecDesc desc;
// init file type
desc.fileType = "TIFF";
// init pixel types
desc.pixelTypes.resize(9);
desc.pixelTypes[0] = "BILEVEL";
desc.pixelTypes[1] = "UINT8";
desc.pixelTypes[2] = "INT8";
desc.pixelTypes[3] = "UINT16";
desc.pixelTypes[4] = "INT16";
desc.pixelTypes[5] = "UINT32";
desc.pixelTypes[6] = "INT32";
desc.pixelTypes[7] = "FLOAT";
desc.pixelTypes[8] = "DOUBLE";
// init compression types
desc.compressionTypes.resize(6);
desc.compressionTypes[0] = "NONE";
desc.compressionTypes[1] = "RLE";
desc.compressionTypes[2] = "PACKBITS";
desc.compressionTypes[3] = "JPEG";
desc.compressionTypes[4] = "LZW";
desc.compressionTypes[5] = "DEFLATE";
// init magic strings
#if TIFFLIB_VERSION > 20070712
desc.magicStrings.resize(3);
#else
desc.magicStrings.resize(2);
#endif
desc.magicStrings[0].resize(4);
desc.magicStrings[0][0] = '\115';
desc.magicStrings[0][1] = '\115';
desc.magicStrings[0][2] = '\000';
desc.magicStrings[0][3] = '\052';
desc.magicStrings[1].resize(4);
desc.magicStrings[1][0] = '\111';
desc.magicStrings[1][1] = '\111';
desc.magicStrings[1][2] = '\052';
desc.magicStrings[1][3] = '\000';
#if TIFFLIB_VERSION > 20070712
// magic for bigtiff
desc.magicStrings[2].resize(4);
desc.magicStrings[2][0] = '\111';
desc.magicStrings[2][1] = '\111';
desc.magicStrings[2][2] = '\053';
desc.magicStrings[2][3] = '\000';
#endif
// init file extensions
desc.fileExtensions.resize(2);
desc.fileExtensions[0] = "tif";
desc.fileExtensions[1] = "tiff";
desc.bandNumbers.resize(4);
desc.bandNumbers[0] = 1;
desc.bandNumbers[1] = 2;
desc.bandNumbers[2] = 3;
desc.bandNumbers[3] = 4;
return desc;
} | false | false | false | false | false | 0 |
hwloc_export_obj_userdata(void *reserved,
struct hwloc_topology *topology __hwloc_attribute_unused, struct hwloc_obj *obj __hwloc_attribute_unused,
const char *name, const void *buffer, size_t length)
{
hwloc__xml_export_state_t state = reserved;
if ((name && hwloc__xml_export_check_buffer(name, strlen(name)) < 0)
|| hwloc__xml_export_check_buffer(buffer, length) < 0) {
errno = EINVAL;
return -1;
}
hwloc__export_obj_userdata(state, 0, name, length, buffer, length);
return 0;
} | false | false | false | false | false | 0 |
cache_action(void)
{
switch (cache_behavior) {
case PLPA_NAME_CAPS(CACHE_USE):
if (NULL == map_processor_id_to_tuple) {
load_cache();
}
break;
case PLPA_NAME_CAPS(CACHE_IGNORE):
clear_cache();
load_cache();
break;
default:
return EINVAL;
}
return 0;
} | false | false | false | false | false | 0 |
i8k_hwmon_show_fan(struct device *dev,
struct device_attribute *devattr,
char *buf)
{
int index = to_sensor_dev_attr(devattr)->index;
int fan_speed;
fan_speed = i8k_get_fan_speed(index);
if (fan_speed < 0)
return fan_speed;
return sprintf(buf, "%d\n", fan_speed);
} | false | true | false | false | false | 1 |
SFSplineCharCreate(SplineFont *sf) {
SplineChar *sc = SplineCharCreate(sf==NULL?2:sf->layer_cnt);
int i;
if ( sf==NULL ) {
sc->layers[ly_back].background = true;
sc->layers[ly_fore].background = false;
} else {
for ( i=0; i<sf->layer_cnt; ++i ) {
sc->layers[i].background = sf->layers[i].background;
sc->layers[i].order2 = sf->layers[i].order2;
}
sc->parent = sf;
}
return( sc );
} | false | false | false | false | false | 0 |
decode_osc_bits(struct acpi_pci_root *root, char *msg, u32 word,
struct pci_osc_bit_struct *table, int size)
{
char buf[80];
int i, len = 0;
struct pci_osc_bit_struct *entry;
buf[0] = '\0';
for (i = 0, entry = table; i < size; i++, entry++)
if (word & entry->bit)
len += snprintf(buf + len, sizeof(buf) - len, "%s%s",
len ? " " : "", entry->desc);
dev_info(&root->device->dev, "_OSC: %s [%s]\n", msg, buf);
} | false | false | false | false | false | 0 |
select_p_step_finish(struct step_record *step_ptr)
{
select_jobinfo_t *jobinfo = step_ptr->select_jobinfo->data;
if (slurmctld_conf.select_type_param & CR_NHC_STEP_NO) {
debug3("NHC_No_Steps set not running NHC on steps.");
other_step_finish(step_ptr);
/* free resources on the job */
post_job_step(step_ptr);
return SLURM_SUCCESS;
}
/* The NHC needs to be ran after each step even if the job is
about to run the NHC for the allocation. The NHC
developers feel this is needed. If it ever changes just
remove the below commented code.
*/
/* else if (IS_JOB_COMPLETING(step_ptr->job_ptr)) { */
/* debug3("step completion %u.%u was received after job " */
/* "allocation is already completing, no extra NHC needed.", */
/* step_ptr->job_ptr->job_id, step_ptr->step_id); */
/* other_step_finish(step_ptr); */
/* /\* free resources on the job *\/ */
/* post_job_step(step_ptr); */
/* return SLURM_SUCCESS; */
/* } */
jobinfo->cleaning = 1;
_spawn_cleanup_thread(step_ptr, _step_fini);
return SLURM_SUCCESS;
} | false | false | false | false | false | 0 |
jpeg_fdct_4x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
{
INT32 tmp0, tmp1;
INT32 tmp10, tmp11;
DCTELEM *dataptr;
JSAMPROW elemptr;
int ctr;
SHIFT_TEMPS
/* Pre-zero output coefficient block. */
MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
/* Pass 1: process rows. */
/* Note results are scaled up by sqrt(8) compared to a true DCT; */
/* furthermore, we scale the results by 2**PASS1_BITS. */
/* We must also scale the output by (8/4)**2 = 2**2, which we add here. */
/* cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT]. */
dataptr = data;
for (ctr = 0; ctr < 4; ctr++) {
elemptr = sample_data[ctr] + start_col;
/* Even part */
tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]);
tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]);
tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
/* Apply unsigned->signed conversion */
dataptr[0] = (DCTELEM)
((tmp0 + tmp1 - 4 * CENTERJSAMPLE) << (PASS1_BITS+2));
dataptr[2] = (DCTELEM) ((tmp0 - tmp1) << (PASS1_BITS+2));
/* Odd part */
tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
/* Add fudge factor here for final descale. */
tmp0 += ONE << (CONST_BITS-PASS1_BITS-3);
dataptr[1] = (DCTELEM)
RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
CONST_BITS-PASS1_BITS-2);
dataptr[3] = (DCTELEM)
RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
CONST_BITS-PASS1_BITS-2);
dataptr += DCTSIZE; /* advance pointer to next row */
}
/* Pass 2: process columns.
* We remove the PASS1_BITS scaling, but leave the results scaled up
* by an overall factor of 8.
*/
dataptr = data;
for (ctr = 0; ctr < 4; ctr++) {
/* Even part */
/* Add fudge factor here for final descale. */
tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*3] + (ONE << (PASS1_BITS-1));
tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*2];
tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*3];
tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*2];
dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp0 + tmp1, PASS1_BITS);
dataptr[DCTSIZE*2] = (DCTELEM) RIGHT_SHIFT(tmp0 - tmp1, PASS1_BITS);
/* Odd part */
tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
/* Add fudge factor here for final descale. */
tmp0 += ONE << (CONST_BITS+PASS1_BITS-1);
dataptr[DCTSIZE*1] = (DCTELEM)
RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
CONST_BITS+PASS1_BITS);
dataptr[DCTSIZE*3] = (DCTELEM)
RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
CONST_BITS+PASS1_BITS);
dataptr++; /* advance pointer to next column */
}
} | false | false | false | false | false | 0 |
rotate(unsigned char *a, int rot_amount, long long abytes) {
int rot_bytes = rot_amount / 8;
int rot_bits = rot_amount - (rot_bytes * 8);
int i;
unsigned char temp[abytes];
memcpy(temp, a, abytes);
for (i = 0; i < abytes; i++) {
a[(i + rot_bytes) % abytes] = temp[i];
}
memcpy(temp, a, abytes);
for (i = 1; i < abytes; i++) {
a[i] = (temp[i - 1] << (8 - rot_bits)) | (temp[i] >> rot_bits);
}
a[0] = (temp[abytes - 1] << (8 - rot_bits)) | (temp[0] >> rot_bits);
} | false | false | false | false | false | 0 |
decoder_query_generic_fold (GstPad * item, GValue * ret, QueryFold * fold)
{
gboolean res;
if ((res = gst_pad_query (item, fold->query))) {
g_value_set_boolean (ret, TRUE);
GST_DEBUG_OBJECT (item, "answered query %p", fold->query);
}
gst_object_unref (item);
/* and stop as soon as we have a valid result */
return !res;
} | false | false | false | false | false | 0 |
qmonCreateARControl(
Widget parent
) {
Widget ar_submit, ar_update, ar_done,
ar_main_link, ar_pending, ar_folder;
#ifdef AR_PENDING
static Widget pw[2];
#endif
static Widget rw[2];
DENTER(GUI_LAYER, "qmonCreateARControl");
qmon_ar = XmtBuildQueryToplevel( parent,
"qmon_ar",
"ar_running_ars", &ar_running_ars,
#ifdef AR_PENDING
"ar_pending_ars", &ar_pending_ars,
#endif
"ar_delete", &ar_delete,
"ar_select_all", &ar_select_all,
"ar_update", &ar_update,
"ar_customize", &ar_customize,
"ar_submit", &ar_submit,
"ar_done", &ar_done,
"ar_main_link", &ar_main_link,
"ar_folder", &ar_folder,
"ar_pending", &ar_pending,
"ar_force", &force_toggle,
NULL);
#ifdef AR_PENDING
pw[0] = ar_pending_ars;
pw[1] = NULL;
#endif
rw[0] = ar_running_ars;
rw[1] = NULL;
/* start the needed timers and the corresponding update routines */
XtAddCallback(qmon_ar, XmNpopupCallback,
qmonARStartUpdate, NULL);
XtAddCallback(qmon_ar, XmNpopdownCallback,
qmonARStopUpdate, NULL);
XtAddCallback(ar_folder, XmNvalueChangedCallback,
qmonARFolderChange, NULL);
XmTabSetTabWidget(ar_folder, ar_pending, True);
XtAddCallback(ar_delete, XmNactivateCallback,
qmonDeleteARCB, NULL);
XtAddCallback(ar_select_all, XmNactivateCallback,
qmonSelectAllARCB, NULL);
XtAddCallback(ar_update, XmNactivateCallback,
updateARListCB, NULL);
XtAddCallback(ar_customize, XmNactivateCallback,
qmonPopupARCU, NULL);
XtAddCallback(ar_submit, XmNactivateCallback,
qmonARSubPopup, NULL);
XtAddCallback(ar_done, XmNactivateCallback,
qmonARPopdown, NULL);
XtAddCallback(ar_main_link, XmNactivateCallback,
qmonMainControlRaise, NULL);
/* XtAddCallback(ar_running_ars, XmNresizeColumnCallback, */
/* qmonResizeCB, NULL); */
XtAddCallback(ar_running_ars, XmNenterCellCallback,
qmonARNoEdit, NULL);
XtAddCallback(ar_running_ars, XmNselectCellCallback,
qmonMatrixSelect, (XtPointer) rw);
XtAddCallback(ar_running_ars, XmNlabelActivateCallback,
qmonARSort, NULL);
/* Event Handler to display additional ar info */
XtAddEventHandler(ar_running_ars, PointerMotionMask,
False, qmonARHandleEnterLeave,
NULL);
#ifdef AR_PENDING
XtAddCallback(ar_pending_ars, XmNenterCellCallback,
qmonARNoEdit, NULL);
XtAddCallback(ar_pending_ars, XmNselectCellCallback,
qmonMatrixSelect, (XtPointer) pw);
XtAddCallback(ar_pending_ars, XmNlabelActivateCallback,
qmonARSort, NULL);
/* Event Handler to display additional ar info */
XtAddEventHandler(ar_pending_ars, PointerMotionMask,
False, qmonARHandleEnterLeave,
NULL);
current_matrix = ar_pending_ars;
#else
current_matrix = ar_running_ars;
#endif
/* initialising sort order to decreasing priority then increasing ar number */
field_sort_by = AR_id;
field_sort_direction = AR_sort_ascending;
arnum_sort_direction = AR_sort_ascending;
DEXIT;
} | false | false | false | false | false | 0 |
newList()
{
bool done = false;
bool ok = false;
QString name;
while (!done) {
name = QInputDialog::getText(this, tr("New List"), tr("Enter the name of the new list:"), QLineEdit::Normal, "", &ok);
if (!ok) {
done = true;
}
else if (ui_.cb_lists->findText(name) != -1) {
QMessageBox::critical(this, tr("Error"), tr("A list with this name already exists."));
}
else if (!name.isEmpty()) {
done = true;
}
}
if (ok) {
if (ui_.cb_lists->currentIndex() != -1 && model_.list().isEmpty()) {
ui_.cb_lists->removeItem(ui_.cb_lists->currentIndex());
}
ui_.cb_lists->addItem(name);
ui_.cb_lists->setCurrentItem(ui_.cb_lists->findText(name));
model_.setList(PrivacyList(name));
newList_ = true;
rememberSettings();
}
} | false | false | false | false | false | 0 |
print_system_equation (const int *list, const DATASET *dset,
PRN *prn)
{
int i, v;
pputs(prn, "equation");
for (i=1; i<=list[0]; i++) {
v = list[i];
if (v == LISTSEP) {
pputs(prn, " ;");
} else if (v > 0 && v < dset->v) {
pprintf(prn, " %s", dset->varname[v]);
} else {
pprintf(prn, " %d", v);
}
}
pputc(prn, '\n');
} | false | false | false | false | false | 0 |
readinframes_as_double(char *movieFile,double *stimuli, unsigned long Ntrials,int dimx, int dimy, int x0, int y0, int Nh, int Nv, int cx, int cy)
{
int nmax,i,j,Ntcurrent=0;
unsigned long k;
int fsize=(int)((Nv*Nh)/(cx*cy));
double sum;
void erroropen(char *);
double *b;
double *tstpatch;
tstpatch=dvector(0,fsize-1);
b=dvector(0,dimx*dimy-1);
FILE *inf;
Patch ptc(dimx, dimy, x0-1, y0-1, Nh, Nv, cx, cy);
inf=fopen(movieFile,"rb");
if (inf ==NULL) erroropen(movieFile);
runChecks(inf, Ntrials, dimx, dimy, x0, y0, Nh, Nv, cx, cy, sizeof(double));
for(i=1;i<=Ntrials;i++){
fread(b,sizeof(double),dimx*dimy,inf);
if (ferror(inf)) myerror("error reading from movie file.");
ptc.dConvert(b,tstpatch);
for(j=1;j<=fsize;j++){
stimuli[(i-1)*fsize+j]= tstpatch[j-1];
}
}
fclose(inf);
free_dvector(b,0,dimx*dimy-1);
free_dvector(tstpatch,0,fsize-1);
} | false | false | false | false | false | 0 |
utf32_strcmp(const uint32 *s1, const uint32 *s2)
{
uint32 uc;
g_assert(NULL != s1);
g_assert(NULL != s2);
while (0x0000 != (uc = *s1++) && *s2 == uc)
s2++;
return uc - *s2;
} | false | false | false | false | false | 0 |
piezoInit()
{
if (isInit)
return;
//Init structures
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
//Clock the gpio and the timers
RCC_AHB1PeriphClockCmd(PIEZO_GPIO_POS_PERIF | PIEZO_GPIO_NEG_PERIF, ENABLE);
RCC_APB1PeriphClockCmd(PIEZO_TIM_PERIF, ENABLE);
// Configure the GPIO for the timer output
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Pin = PIEZO_GPIO_POS_PIN;
GPIO_Init(PIEZO_GPIO_POS_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PIEZO_GPIO_NEG_PIN;
GPIO_Init(PIEZO_GPIO_NEG_PORT, &GPIO_InitStructure);
//Map timers to alternate functions
GPIO_PinAFConfig(PIEZO_GPIO_POS_PORT, PIEZO_GPIO_AF_POS_PIN, PIEZO_GPIO_AF_POS);
GPIO_PinAFConfig(PIEZO_GPIO_NEG_PORT, PIEZO_GPIO_AF_NEG_PIN, PIEZO_GPIO_AF_NEG);
//Timer configuration
TIM_TimeBaseStructure.TIM_Period = PIEZO_PWM_PERIOD;
TIM_TimeBaseStructure.TIM_Prescaler = PIEZO_PWM_PRESCALE;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(PIEZO_TIM, &TIM_TimeBaseStructure);
// PWM channels configuration
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 0;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
// Configure OC3
TIM_OC3Init(PIEZO_TIM, &TIM_OCInitStructure);
TIM_OC3PreloadConfig(PIEZO_TIM, TIM_OCPreload_Enable);
// Configure OC4 inverted
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC4Init(PIEZO_TIM, &TIM_OCInitStructure);
TIM_OC4PreloadConfig(PIEZO_TIM, TIM_OCPreload_Enable);
//Enable the timer PWM outputs
TIM_CtrlPWMOutputs(PIEZO_TIM, ENABLE);
TIM_SetCompare3(PIEZO_TIM, 0x00);
TIM_SetCompare4(PIEZO_TIM, 0x00);
//Enable the timer
TIM_Cmd(PIEZO_TIM, ENABLE);
isInit = true;
} | false | false | false | false | false | 0 |
run_inner(server_ty *sp, string_ty *)
const
{
string_list_ty wl;
get_list(wl);
server_response_queue(sp, new response_valid_requests(&wl));
server_ok(sp);
} | false | false | false | false | false | 0 |
h261_loop_filter_c(uint8_t *src, int stride){
int x,y,xy,yz;
int temp[64];
for(x=0; x<8; x++){
temp[x ] = 4*src[x ];
temp[x + 7*8] = 4*src[x + 7*stride];
}
for(y=1; y<7; y++){
for(x=0; x<8; x++){
xy = y * stride + x;
yz = y * 8 + x;
temp[yz] = src[xy - stride] + 2*src[xy] + src[xy + stride];
}
}
for(y=0; y<8; y++){
src[ y*stride] = (temp[ y*8] + 2)>>2;
src[7+y*stride] = (temp[7+y*8] + 2)>>2;
for(x=1; x<7; x++){
xy = y * stride + x;
yz = y * 8 + x;
src[xy] = (temp[yz-1] + 2*temp[yz] + temp[yz+1] + 8)>>4;
}
}
} | false | false | false | false | false | 0 |
gv_graph_state(GVJ_t *job, graph_t *g)
{
int j;
Agsym_t *a;
gv_argvlist_t *list;
list = &(job->selected_obj_type_name);
j = 0;
if (g == agroot(g)) {
if (agisdirected(g))
gv_argvlist_set_item(list, j++, s_digraph);
else
gv_argvlist_set_item(list, j++, s_graph);
}
else {
gv_argvlist_set_item(list, j++, s_subgraph);
}
gv_argvlist_set_item(list, j++, agnameof(g));
list->argc = j;
list = &(job->selected_obj_attributes);
a = NULL;
while ((a = agnxtattr(g, AGRAPH, a))) {
gv_argvlist_set_item(list, j++, a->name);
gv_argvlist_set_item(list, j++, agxget(g, a));
gv_argvlist_set_item(list, j++, (char*)GVATTR_STRING);
}
list->argc = j;
a = agfindgraphattr(g, s_href);
if (!a)
a = agfindgraphattr(g, s_URL);
if (a)
job->selected_href = strdup_and_subst_obj(agxget(g, a), (void*)g);
} | false | false | false | false | false | 0 |
Prediction(const TwoDArray < ValueType > & dcdata,
const TwoDArray < PredMode > & preddata) const
{
std::vector < int > nbrs;
PredMode pmode;
ValueType result = 0;
if (m_b_xp > 0 && m_b_yp > 0)
{
pmode = preddata[m_b_yp-1][m_b_xp];
if (pmode == INTRA)
nbrs.push_back( (int) dcdata[m_b_yp-1][m_b_xp] );
pmode = preddata[m_b_yp-1][m_b_xp-1];
if (pmode == INTRA)
nbrs.push_back((int)dcdata[m_b_yp-1][m_b_xp-1] );
pmode = preddata[m_b_yp][m_b_xp-1];
if (pmode == INTRA)
nbrs.push_back( (int) dcdata[m_b_yp][m_b_xp-1] );
if (nbrs.size() > 0)
result = ValueType(GetSMean(nbrs));
}
else if (m_b_xp > 0 && m_b_yp == 0)
{
pmode = preddata[0][m_b_xp-1];
if (pmode == INTRA)
result = dcdata[0][m_b_xp-1];
}
else if (m_b_xp == 0 && m_b_yp > 0)
{
pmode = preddata[m_b_yp-1][0];
if (pmode == INTRA)
result = dcdata[m_b_yp-1][0];
}
return result;
} | false | false | false | false | false | 0 |
parse_udp (packetinfo *pi)
{
update_asset(pi);
//if (is_set_guess_upd_direction(config)) {
udp_guess_direction(pi); // fix DNS server transfers?
// Check for Passive DNS
static char ip_addr_s[INET6_ADDRSTRLEN];
u_ntop_src(pi, ip_addr_s);
if ( ntohs(pi->s_port) == 53 ) {
// For now - Proof of Concept! - Fix output way
if(config.cflags & CONFIG_PDNS)
dump_dns(pi->payload, pi->plen, stdout, "\n", ip_addr_s, pi->pheader->ts.tv_sec);
}
// if (IS_COSET(&config,CO_DNS) && (pi->sc == SC_SERVER && ntohs(pi->s_port) == 53)) passive_dns (pi);
if (IS_CSSET(&config,CS_UDP_SERVICES)) {
if (pi->af == AF_INET) {
if (!ISSET_DONT_CHECK_SERVICE(pi)||!ISSET_DONT_CHECK_CLIENT(pi)) {
// Check for UDP SERVICE
service_udp4(pi, config.sig_serv_udp);
}
// UPD Fingerprinting
if (IS_COSET(&config,CO_UDP)) fp_udp4(pi, pi->ip4, pi->udph, pi->end_ptr);
} else if (pi->af == AF_INET6) {
if (!ISSET_DONT_CHECK_SERVICE(pi)||!ISSET_DONT_CHECK_CLIENT(pi)) {
service_udp6(pi, config.sig_client_udp);
}
/* fp_udp(ip6, ttl, ipopts, len, id, ipflags, df); */
}
return;
} else {
vlog(0x3, "[*] - NOT CHECKING UDP PACKAGE\n");
return;
}
} | false | false | false | false | false | 0 |
require_size(PyArrayObject* ary, npy_intp* size, int n) {
int i;
int success = 1;
int len;
char desired_dims[255] = "[";
char s[255];
char actual_dims[255] = "[";
for(i=0; i < n;i++) {
if (size[i] != -1 && size[i] != array_size(ary,i)) {
success = 0;
}
}
if (!success) {
for (i = 0; i < n; i++) {
if (size[i] == -1) {
sprintf(s, "*,");
}
else
{
sprintf(s,"%" NPY_INTP_FMT ",", size[i]);
}
strcat(desired_dims,s);
}
len = strlen(desired_dims);
desired_dims[len-1] = ']';
for (i = 0; i < n; i++) {
sprintf(s,"%" NPY_INTP_FMT ",", array_size(ary,i));
strcat(actual_dims,s);
}
len = strlen(actual_dims);
actual_dims[len-1] = ']';
PyErr_Format(PyExc_TypeError,
"Array must be have shape of %s. Given array has shape of %s",
desired_dims, actual_dims);
}
return success;
} | false | false | false | false | false | 0 |
S_gen_constant_list(pTHX_ OP *o)
{
dVAR;
OP *curop;
const I32 oldtmps_floor = PL_tmps_floor;
list(o);
if (PL_parser && PL_parser->error_count)
return o; /* Don't attempt to run with errors */
PL_op = curop = LINKLIST(o);
o->op_next = 0;
CALL_PEEP(curop);
Perl_pp_pushmark(aTHX);
CALLRUNOPS(aTHX);
PL_op = curop;
assert (!(curop->op_flags & OPf_SPECIAL));
assert(curop->op_type == OP_RANGE);
Perl_pp_anonlist(aTHX);
PL_tmps_floor = oldtmps_floor;
o->op_type = OP_RV2AV;
o->op_ppaddr = PL_ppaddr[OP_RV2AV];
o->op_flags &= ~OPf_REF; /* treat \(1..2) like an ordinary list */
o->op_flags |= OPf_PARENS; /* and flatten \(1..2,3) */
o->op_opt = 0; /* needs to be revisited in rpeep() */
curop = ((UNOP*)o)->op_first;
((UNOP*)o)->op_first = newSVOP(OP_CONST, 0, SvREFCNT_inc_NN(*PL_stack_sp--));
#ifdef PERL_MAD
op_getmad(curop,o,'O');
#else
op_free(curop);
#endif
LINKLIST(o);
return list(o);
} | false | false | false | false | false | 0 |
qd_get(struct gfs2_sbd *sdp, struct kqid qid,
struct gfs2_quota_data **qdp)
{
struct gfs2_quota_data *qd, *new_qd;
unsigned int hash = gfs2_qd_hash(sdp, qid);
rcu_read_lock();
*qdp = qd = gfs2_qd_search_bucket(hash, sdp, qid);
rcu_read_unlock();
if (qd)
return 0;
new_qd = qd_alloc(hash, sdp, qid);
if (!new_qd)
return -ENOMEM;
spin_lock(&qd_lock);
spin_lock_bucket(hash);
*qdp = qd = gfs2_qd_search_bucket(hash, sdp, qid);
if (qd == NULL) {
*qdp = new_qd;
list_add(&new_qd->qd_list, &sdp->sd_quota_list);
hlist_bl_add_head_rcu(&new_qd->qd_hlist, &qd_hash_table[hash]);
atomic_inc(&sdp->sd_quota_count);
}
spin_unlock_bucket(hash);
spin_unlock(&qd_lock);
if (qd) {
gfs2_glock_put(new_qd->qd_gl);
kmem_cache_free(gfs2_quotad_cachep, new_qd);
}
return 0;
} | false | false | false | false | false | 0 |
GetKeyCount(string SectionName)
{
map< string, map<string,string> >::iterator it;
it = stConfigDataTable.find(SectionName);
if (it == stConfigDataTable.end())
{
return -1;
}
map<string,string> tmpMap = it->second;
return tmpMap.size();
} | false | false | false | false | false | 0 |
dump(int i)
{
indent(i);
printf("%p %s func=%s type=%s e1=%p\n", this, Token::toChars(op), func->toChars(), type_print(type), e1);
if (e1)
e1->dump(i + 2);
} | false | false | false | false | false | 0 |
consume_until_comma_or_semi (bool immediate)
{
if (immediate && token () != ',' && token () != ';')
require2 (',', ';');
for (;;)
switch (token ())
{
case ',': advance (); return true;
case ';': advance (); return false;
default: advance (); break;
case '(': consume_balanced ('(',')'); break;
case '[': consume_balanced ('[',']'); break;
case '{': consume_balanced ('{','}'); break;
case '}':
case ']':
case ')':
parse_error ("unmatched '%s' while scanning for ',' or ';'",
print_cur_token ());
return false;
case EOF_TOKEN:
parse_error ("unexpected end of file while scanning for ',' or ';'");
return false;
}
} | false | false | false | false | false | 0 |
cond_alloc(void)
{
cond *c;
if (cond_free_list)
{
c = cond_free_list;
cond_free_list = c->next;
}
else
c = (cond *)mem_alloc(sizeof(cond));
return c;
} | false | false | false | false | false | 0 |
get_pvc(int itf,int *vci)
{
struct sockaddr_atmpvc addr;
struct atm_qos qos;
int s,error;
if ((s = socket(PF_ATMPVC,SOCK_DGRAM,0)) < 0)
diag(COMPONENT,DIAG_FATAL,"get_pvc: %s",strerror(errno));
memset(&qos,0,sizeof(qos));
qos.aal = ATM_AAL5;
qos.rxtp.traffic_class = qos.txtp.traffic_class = ATM_UBR;
qos.rxtp.max_sdu = qos.txtp.max_sdu = 1; /* smallest possible SDU size */
if (setsockopt(s,SOL_ATM,SO_ATMQOS,&qos,sizeof(qos)) < 0)
diag(COMPONENT,DIAG_FATAL,"setsockopt SO_ATMQOS: %s",strerror(errno));
memset(&addr,0,sizeof(addr));
addr.sap_family = AF_ATMPVC;
addr.sap_addr.itf = itf;
addr.sap_addr.vpi = 0; /* @@@ */
addr.sap_addr.vci = ATM_VCI_ANY;
error = 0;
if (bind(s,(struct sockaddr *) &addr,sizeof(addr)) < 0) error = errno;
else {
socklen_t size;
size = sizeof(addr);
if (getsockname(s,(struct sockaddr *) &addr,&size) < 0)
diag(COMPONENT,DIAG_FATAL,"get_pvc: %s",strerror(errno));
*vci = addr.sap_addr.vci;
return s;
}
(void) close(s);
return -error;
} | false | false | false | false | false | 0 |
WriteAppendedPiece(int index,
vtkIndent indent)
{
// Write the point data and cell data arrays.
vtkDataSet* input = this->GetInputAsDataSet();
this->WritePointDataAppended(input->GetPointData(), indent,
&this->PointDataOM->GetPiece(index));
if (this->ErrorCode == vtkErrorCode::OutOfDiskSpaceError)
{
return;
}
this->WriteCellDataAppended(input->GetCellData(), indent,
&this->CellDataOM->GetPiece(index));
if (this->ErrorCode == vtkErrorCode::OutOfDiskSpaceError)
{
return;
}
} | false | false | false | false | false | 0 |
hostlist_resize(hostlist_t hl, size_t newsize)
{
int i;
size_t oldsize;
assert(hl != NULL);
assert(hl->magic == HOSTLIST_MAGIC);
oldsize = hl->size;
hl->size = newsize;
hl->hr = realloc((void *) hl->hr, hl->size*sizeof(hostrange_t));
if (!(hl->hr))
return 0;
for (i = oldsize; i < newsize; i++)
hl->hr[i] = NULL;
return 1;
} | false | false | false | false | false | 0 |
gst_flups_demux_reset_psm (GstFluPSDemux * demux)
{
gint i;
#define FILL_TYPE(start, stop, type) \
for (i=start; i <= stop; i++) \
demux->psm[i] = type;
FILL_TYPE (0x00, 0x1f, -1);
FILL_TYPE (0x20, 0x3f, ST_PS_DVD_SUBPICTURE);
FILL_TYPE (0x40, 0x7f, -1);
FILL_TYPE (0x80, 0x87, ST_PS_AUDIO_AC3);
FILL_TYPE (0x88, 0x9f, ST_PS_AUDIO_DTS);
FILL_TYPE (0xa0, 0xaf, ST_PS_AUDIO_LPCM);
FILL_TYPE (0xbd, 0xbd, -1);
FILL_TYPE (0xc0, 0xdf, ST_AUDIO_MPEG1);
FILL_TYPE (0xe0, 0xef, ST_GST_VIDEO_MPEG1_OR_2);
FILL_TYPE (0xf0, 0xff, -1);
#undef FILL_TYPE
} | false | false | false | false | false | 0 |
hashFindPointer(hash_ *h, char *key, void ***record)
{
record_ *recs;
unsigned int off, ind, size;
unsigned int code;
ReturnErrIf(h == NULL);
ReturnErrIf(key == NULL);
ReturnErrIf(record == NULL);
code = strhash(key);
recs = h->records;
size = sizes[h->size_index];
ind = code % size;
off = 0;
/* search on hash which remains even if a record has been removed,
* so hash_remove() does not need to move any collision records
*/
while (recs[ind].hash) {
if ((code == recs[ind].hash) && (recs[ind].key != NULL)) {
if(!strcmp(key, recs[ind].key)) {
*record = &recs[ind].record;
return 0;
}
}
ind = (code + (int)pow(++off,2)) % size;
}
/* Couldn't find the key */
*record = NULL;
return 0;
} | false | false | false | false | false | 0 |
ad1889_channel_reset(struct snd_ad1889 *chip, unsigned int channel)
{
u16 reg;
if (channel & AD_CHAN_WAV) {
/* Disable wave channel */
reg = ad1889_readw(chip, AD_DS_WSMC) & ~AD_DS_WSMC_WAEN;
ad1889_writew(chip, AD_DS_WSMC, reg);
chip->wave.reg = reg;
/* disable IRQs */
reg = ad1889_readw(chip, AD_DMA_WAV);
reg &= AD_DMA_IM_DIS;
reg &= ~AD_DMA_LOOP;
ad1889_writew(chip, AD_DMA_WAV, reg);
/* clear IRQ and address counters and pointers */
ad1889_load_wave_buffer_address(chip, 0x0);
ad1889_load_wave_buffer_count(chip, 0x0);
ad1889_load_wave_interrupt_count(chip, 0x0);
/* flush */
ad1889_readw(chip, AD_DMA_WAV);
}
if (channel & AD_CHAN_ADC) {
/* Disable ADC channel */
reg = ad1889_readw(chip, AD_DS_RAMC) & ~AD_DS_RAMC_ADEN;
ad1889_writew(chip, AD_DS_RAMC, reg);
chip->ramc.reg = reg;
reg = ad1889_readw(chip, AD_DMA_ADC);
reg &= AD_DMA_IM_DIS;
reg &= ~AD_DMA_LOOP;
ad1889_writew(chip, AD_DMA_ADC, reg);
ad1889_load_adc_buffer_address(chip, 0x0);
ad1889_load_adc_buffer_count(chip, 0x0);
ad1889_load_adc_interrupt_count(chip, 0x0);
/* flush */
ad1889_readw(chip, AD_DMA_ADC);
}
} | false | false | false | false | false | 0 |
_e2_pane_focus_action (gpointer from, E2_ActionRuntime *art)
{
E2_PaneRuntime *rt = (E2_PaneRuntime *)art->action->data;
if (rt != NULL && rt != curr_pane)
{
e2_pane_activate_other ();
return TRUE;
}
else if (rt == NULL)
{
gtk_widget_grab_focus (curr_view->treeview);
return TRUE;
}
return FALSE;
} | false | false | false | false | false | 0 |
dim_vector_set_one(Dim_vector *p,
int *nested_id, int nest,
void *body)
{
int i, n = 0;
for (i = 0; i < nest; i++) {
#if 0
assert(nested_id[i] < size[i]);
#endif
n += nested_id[i] * p->stride[i];
}
p->dim_vec[n] = body;
} | false | false | false | false | false | 0 |
e_gdbus_async_call_opid_ready_cb (GObject *source_proxy,
GAsyncResult *result,
gpointer user_data)
{
GVariant *_result;
GError *error = NULL;
AsyncOpData *op_data = user_data;
_result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_proxy), result, &error);
if (_result != NULL && !error) {
EGdbusAsyncOpKeeper *op_keeper = E_GDBUS_ASYNC_OP_KEEPER (source_proxy);
GHashTable *pending_ops;
gboolean add_pending = TRUE;
g_return_if_fail (op_keeper != NULL);
pending_ops = e_gdbus_async_op_keeper_get_pending_ops (op_keeper);
g_return_if_fail (pending_ops != NULL);
g_variant_get (_result, "(u)", &op_data->opid);
g_variant_unref (_result);
if (op_data->cancellable && !g_cancellable_set_error_if_cancelled (op_data->cancellable, &error))
op_data->cancel_id = g_cancellable_connect (op_data->cancellable, G_CALLBACK (e_gdbus_op_cancelled_cb), op_data, NULL);
else
add_pending = op_data->cancellable == NULL;
/* add to pending ops, waiting for associated 'done' signal */
if (add_pending)
g_hash_table_insert (pending_ops, GUINT_TO_POINTER (op_data->opid), op_data);
} else if (_result) {
g_variant_unref (_result);
}
if (error) {
async_op_complete (op_data, error, FALSE);
g_error_free (error);
}
} | false | false | false | false | false | 0 |
thex_download_free(struct thex_download **ptr)
{
struct thex_download *ctx = *ptr;
if (ctx) {
if (ctx->rx) {
rx_free(ctx->rx);
ctx->rx = NULL;
}
HFREE_NULL(ctx->data);
G_FREE_NULL(ctx->leaves);
atom_sha1_free_null(&ctx->sha1);
atom_tth_free_null(&ctx->tth);
WFREE(ctx);
*ptr = NULL;
}
} | false | false | false | false | false | 0 |
installCValueSymbols()
{
cValueSymbols_[0] = makeFalse();
cValueSymbols_[1] = makeTrue();
for (size_t i = 2; i < FOTBuilder::nSymbols; i++) {
SymbolObj *sym = makeSymbol(makeStringC(FOTBuilder::symbolName(FOTBuilder::Symbol(i))));
sym->setCValue(FOTBuilder::Symbol(i));
cValueSymbols_[i] = sym;
}
} | false | false | false | false | false | 0 |
parse_mteTriggerTable(const char *token, char *line)
{
char owner[MTE_STR1_LEN+1];
char tname[MTE_STR1_LEN+1];
void *vp;
size_t len;
struct mteTrigger *entry;
DEBUGMSGTL(("disman:event:conf", "Parsing previous mteTriggerTable config... "));
/*
* Read in the index information for this entry
* and create a (non-fixed) data structure for it.
*/
memset( owner, 0, sizeof(owner));
memset( tname, 0, sizeof(tname));
len = MTE_STR1_LEN; vp = owner;
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len);
len = MTE_STR1_LEN; vp = tname;
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len);
entry = _find_mteTrigger_entry( owner, tname );
DEBUGMSG(("disman:event:conf", "(%s, %s) ", owner, tname));
/*
* Read in the accessible column values for each table in turn...
* (similar, though not identical to the newer style).
*/
line = _parse_mteTCols( line, entry, 1 );
line = _parse_mteTDCols( line, entry, 1 );
line = _parse_mteTExCols( line, entry, 1 );
line = _parse_mteTBlCols( line, entry, 1 );
line = _parse_mteTThCols( line, entry, 1 );
/*
* ... and then read in the "local internal variables"
* XXX - TODO
*/
entry->flags |= MTE_TRIGGER_FLAG_VALID;
/* XXX - mte_enable_trigger(); ??? */
DEBUGMSG(("disman:event:conf", "\n"));
} | false | false | false | false | false | 0 |
USB_ReqGetStatus (void) {
uint32_t n, m;
uint16_t* ep0 = (uint16_t __attribute__((packed)) *)EP0Buf;
switch (SetupPacket.bmRequestType.BM.Recipient) {
case REQUEST_TO_DEVICE:
EP0Data.pData = (uint8_t *)&USB_DeviceStatus;
break;
case REQUEST_TO_INTERFACE:
if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) {
*ep0 = 0;
EP0Data.pData = EP0Buf;
} else {
return (FALSE);
}
break;
case REQUEST_TO_ENDPOINT:
n = SetupPacket.wIndex.WB.L & 0x8F;
m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
if (((USB_Configuration != 0) || ((n & 0x0F) == 0)) && (USB_EndPointMask & m)) {
*ep0 = (USB_EndPointHalt & m) ? 1 : 0;
EP0Data.pData = EP0Buf;
} else {
return (FALSE);
}
break;
default:
return (FALSE);
}
return (TRUE);
} | false | false | false | false | false | 0 |
simple_object_coff_find_sections (simple_object_read *sobj,
int (*pfn) (void *, const char *,
off_t offset, off_t length),
void *data,
int *err)
{
struct simple_object_coff_read *ocr =
(struct simple_object_coff_read *) sobj->data;
size_t scnhdr_size;
unsigned char *scnbuf;
const char *errmsg;
unsigned int (*fetch_32) (const unsigned char *);
unsigned int nscns;
char *strtab;
size_t strtab_size;
unsigned int i;
scnhdr_size = sizeof (struct external_scnhdr);
scnbuf = XNEWVEC (unsigned char, scnhdr_size * ocr->nscns);
if (!simple_object_internal_read (sobj->descriptor,
sobj->offset + ocr->scnhdr_offset,
scnbuf, scnhdr_size * ocr->nscns, &errmsg,
err))
{
XDELETEVEC (scnbuf);
return errmsg;
}
fetch_32 = (ocr->is_big_endian
? simple_object_fetch_big_32
: simple_object_fetch_little_32);
nscns = ocr->nscns;
strtab = NULL;
strtab_size = 0;
for (i = 0; i < nscns; ++i)
{
unsigned char *scnhdr;
unsigned char *scnname;
char namebuf[SCNNMLEN + 1];
char *name;
off_t scnptr;
unsigned int size;
scnhdr = scnbuf + i * scnhdr_size;
scnname = scnhdr + offsetof (struct external_scnhdr, s_name);
memcpy (namebuf, scnname, SCNNMLEN);
namebuf[SCNNMLEN] = '\0';
name = &namebuf[0];
if (namebuf[0] == '/')
{
size_t strindex;
char *end;
strindex = strtol (namebuf + 1, &end, 10);
if (*end == '\0')
{
/* The real section name is found in the string
table. */
if (strtab == NULL)
{
strtab = simple_object_coff_read_strtab (sobj,
&strtab_size,
&errmsg, err);
if (strtab == NULL)
{
XDELETEVEC (scnbuf);
return errmsg;
}
}
if (strindex < 4 || strindex >= strtab_size)
{
XDELETEVEC (strtab);
XDELETEVEC (scnbuf);
*err = 0;
return "section string index out of range";
}
name = strtab + strindex;
}
}
scnptr = fetch_32 (scnhdr + offsetof (struct external_scnhdr, s_scnptr));
size = fetch_32 (scnhdr + offsetof (struct external_scnhdr, s_size));
if (!(*pfn) (data, name, scnptr, size))
break;
}
if (strtab != NULL)
XDELETEVEC (strtab);
XDELETEVEC (scnbuf);
return NULL;
} | false | false | false | false | false | 0 |
latex_post_processor_push_file_on_stack (LatexPostProcessor* self, const gchar* filename, gboolean reliable) {
LatexPostProcessorFileInStack file = {0};
gboolean _tmp0_ = FALSE;
gchar* clean_filename = NULL;
gchar* bad_suffix = NULL;
gchar* _tmp1_ = NULL;
const gchar* _tmp2_ = NULL;
const gchar* _tmp3_ = NULL;
gboolean _tmp4_ = FALSE;
gchar* path = NULL;
const gchar* _tmp12_ = NULL;
gchar* _tmp13_ = NULL;
const gchar* _tmp14_ = NULL;
LatexPostProcessorFileInStack _tmp19_ = {0};
LatexPostProcessorFileInStack _tmp20_ = {0};
LatexPostProcessorFileInStack* _tmp21_ = NULL;
g_return_if_fail (self != NULL);
g_return_if_fail (filename != NULL);
memset (&file, 0, sizeof (LatexPostProcessorFileInStack));
_tmp0_ = reliable;
file.reliable = _tmp0_;
_tmp1_ = g_strdup ("pdfTeX");
bad_suffix = _tmp1_;
_tmp2_ = filename;
_tmp3_ = bad_suffix;
_tmp4_ = g_str_has_suffix (_tmp2_, _tmp3_);
if (_tmp4_) {
const gchar* _tmp5_ = NULL;
const gchar* _tmp6_ = NULL;
gint _tmp7_ = 0;
gint _tmp8_ = 0;
gchar* _tmp9_ = NULL;
_tmp5_ = filename;
_tmp6_ = bad_suffix;
_tmp7_ = strlen (_tmp6_);
_tmp8_ = _tmp7_;
_tmp9_ = string_slice (_tmp5_, (glong) 0, (glong) (-_tmp8_));
_g_free0 (clean_filename);
clean_filename = _tmp9_;
} else {
const gchar* _tmp10_ = NULL;
gchar* _tmp11_ = NULL;
_tmp10_ = filename;
_tmp11_ = g_strdup (_tmp10_);
_g_free0 (clean_filename);
clean_filename = _tmp11_;
}
_tmp12_ = clean_filename;
_tmp13_ = latex_post_processor_get_path_if_file_exists (self, _tmp12_);
path = _tmp13_;
_tmp14_ = path;
if (_tmp14_ != NULL) {
const gchar* _tmp15_ = NULL;
gchar* _tmp16_ = NULL;
_tmp15_ = path;
_tmp16_ = g_strdup (_tmp15_);
_g_free0 (file.filename);
file.filename = _tmp16_;
file.exists = TRUE;
} else {
const gchar* _tmp17_ = NULL;
gchar* _tmp18_ = NULL;
_tmp17_ = clean_filename;
_tmp18_ = g_strdup (_tmp17_);
_g_free0 (file.filename);
file.filename = _tmp18_;
file.exists = FALSE;
}
_tmp19_ = file;
_tmp20_ = _tmp19_;
_tmp21_ = _latex_post_processor_file_in_stack_dup0 (&_tmp20_);
self->priv->stack_files = g_slist_prepend (self->priv->stack_files, _tmp21_);
_g_free0 (path);
_g_free0 (bad_suffix);
_g_free0 (clean_filename);
latex_post_processor_file_in_stack_destroy (&file);
} | false | false | false | false | false | 0 |
operator==(const Dictionary::Id & rhs, const Dictionary::Id & lhs)
{
if (rhs.ptr == 0 || lhs.ptr == 0) {
if (rhs.file_name == 0 || lhs.file_name == 0)
return false;
#ifdef USE_FILE_INO
return rhs.ino == lhs.ino && rhs.dev == lhs.dev;
#else
return strcmp(rhs.file_name, lhs.file_name) == 0;
#endif
} else {
return rhs.ptr == lhs.ptr;
}
} | false | false | false | false | false | 0 |
save_quetzal(zterp_io *savefile, int is_meta)
{
if(setjmp(exception) != 0) return 0;
size_t local_written = 0;
size_t game_len;
uint32_t memsize;
uint8_t *compressed;
uint8_t *mem = memory;
long stks_pos;
size_t stack_size;
WRITEID("FORM");
WRITEID(" "); /* to be filled in */
WRITEID(is_meta ? "BFMS" : "IFZS");
WRITEID("IFhd");
WRITE32(13);
WRITE16(header.release);
zterp_io_write(savefile, header.serial, 6);
local_written += 6;
WRITE16(header.checksum);
WRITE8(pc >> 16);
WRITE8(pc >> 8);
WRITE8(pc & 0xff);
WRITE8(0); /* padding */
/* Store the filename in an IntD chunk. */
game_len = 12 + strlen(game_file);
WRITEID("IntD");
WRITE32(game_len);
WRITEID("UNIX");
WRITE8(0x02);
WRITE8(0);
WRITE16(0);
WRITEID(" ");
zterp_io_write(savefile, game_file, game_len - 12);
local_written += (game_len - 12);
if(game_len & 1) WRITE8(0);
memsize = compress_memory(&compressed);
/* It is possible for the compressed memory size to be larger than
* uncompressed; in this case, just store the uncompressed memory.
*/
if(memsize > 0 && memsize < header.static_start)
{
mem = compressed;
WRITEID("CMem");
}
else
{
memsize = header.static_start;
WRITEID("UMem");
}
WRITE32(memsize);
zterp_io_write(savefile, mem, memsize);
local_written += memsize;
if(memsize & 1) WRITE8(0); /* padding */
free(compressed);
WRITEID("Stks");
stks_pos = zterp_io_tell(savefile);
WRITEID(" "); /* to be filled in */
stack_size = quetzal_write_stack(savefile);
local_written += stack_size;
if(stack_size & 1) WRITE8(0); /* padding */
zterp_io_seek(savefile, 4, SEEK_SET);
WRITE32(local_written - 8); /* entire file size minus 8 (FORM + size) */
zterp_io_seek(savefile, stks_pos, SEEK_SET);
WRITE32(stack_size); /* size of the stacks chunk */
return 1;
} | false | false | false | false | true | 1 |
cxd2820r_get_frontend_t2(struct dvb_frontend *fe)
{
struct cxd2820r_priv *priv = fe->demodulator_priv;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret;
u8 buf[2];
ret = cxd2820r_rd_regs(priv, 0x0205c, buf, 2);
if (ret)
goto error;
switch ((buf[0] >> 0) & 0x07) {
case 0:
c->transmission_mode = TRANSMISSION_MODE_2K;
break;
case 1:
c->transmission_mode = TRANSMISSION_MODE_8K;
break;
case 2:
c->transmission_mode = TRANSMISSION_MODE_4K;
break;
case 3:
c->transmission_mode = TRANSMISSION_MODE_1K;
break;
case 4:
c->transmission_mode = TRANSMISSION_MODE_16K;
break;
case 5:
c->transmission_mode = TRANSMISSION_MODE_32K;
break;
}
switch ((buf[1] >> 4) & 0x07) {
case 0:
c->guard_interval = GUARD_INTERVAL_1_32;
break;
case 1:
c->guard_interval = GUARD_INTERVAL_1_16;
break;
case 2:
c->guard_interval = GUARD_INTERVAL_1_8;
break;
case 3:
c->guard_interval = GUARD_INTERVAL_1_4;
break;
case 4:
c->guard_interval = GUARD_INTERVAL_1_128;
break;
case 5:
c->guard_interval = GUARD_INTERVAL_19_128;
break;
case 6:
c->guard_interval = GUARD_INTERVAL_19_256;
break;
}
ret = cxd2820r_rd_regs(priv, 0x0225b, buf, 2);
if (ret)
goto error;
switch ((buf[0] >> 0) & 0x07) {
case 0:
c->fec_inner = FEC_1_2;
break;
case 1:
c->fec_inner = FEC_3_5;
break;
case 2:
c->fec_inner = FEC_2_3;
break;
case 3:
c->fec_inner = FEC_3_4;
break;
case 4:
c->fec_inner = FEC_4_5;
break;
case 5:
c->fec_inner = FEC_5_6;
break;
}
switch ((buf[1] >> 0) & 0x07) {
case 0:
c->modulation = QPSK;
break;
case 1:
c->modulation = QAM_16;
break;
case 2:
c->modulation = QAM_64;
break;
case 3:
c->modulation = QAM_256;
break;
}
ret = cxd2820r_rd_reg(priv, 0x020b5, &buf[0]);
if (ret)
goto error;
switch ((buf[0] >> 4) & 0x01) {
case 0:
c->inversion = INVERSION_OFF;
break;
case 1:
c->inversion = INVERSION_ON;
break;
}
return ret;
error:
dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
return ret;
} | false | false | false | false | false | 0 |
ho_objlist_new ()
{
ho_objlist *new_hocr_object_list;
/* allocate memory for struct */
new_hocr_object_list = (ho_objlist *) malloc (sizeof (ho_objlist));
/* check for new memory */
if (!new_hocr_object_list)
return NULL;
/* init struct values */
new_hocr_object_list->size = 0;
new_hocr_object_list->allocated_size = 1000;
/* allocate memory for objects */
new_hocr_object_list->objects =
(ho_obj *) malloc (sizeof (ho_obj) * new_hocr_object_list->allocated_size);
/* if no memeory for objects free the struct */
if (!new_hocr_object_list->objects)
{
free (new_hocr_object_list);
return NULL;
}
return new_hocr_object_list;
} | false | true | false | false | false | 1 |
sfx_derivespecialcodesonthefly(Sfxiterator *sfi)
{
GtCodetype code;
unsigned int prefixindex;
unsigned long stidx;
Enumcodeatposition *ecp;
Specialcontext specialcontext;
for (prefixindex=1U; prefixindex < sfi->prefixlength; prefixindex++)
{
ecp = gt_Enumcodeatposition_new(sfi->encseq,sfi->readmode,
sfi->prefixlength,
sfi->numofchars);
while (gt_Enumcodeatposition_next(&specialcontext,ecp))
{
if (prefixindex <= specialcontext.maxprefixindex)
{
if (gt_Enumcodeatposition_filledqgramcodestopatmax(
&code,
ecp,
prefixindex,
specialcontext.position-prefixindex,
sfi->currentmaxcode))
{
gt_assert(code <= sfi->currentmaxcode);
if (code >= sfi->currentmincode)
{
gt_bcktab_updatespecials(sfi->bcktab,code,prefixindex);
gt_assert(code > 0);
stidx = gt_bcktab_leftborder_insertionindex(sfi->leftborder,code);
/* from right to left */
gt_suffixsortspace_set(sfi->suffixsortspace,0,stidx,
specialcontext.position - prefixindex);
}
}
}
}
gt_Enumcodeatposition_delete(ecp);
ecp = NULL;
}
} | false | false | false | false | false | 0 |
free_undo (int count)
{
undo_t *p;
if (count > undo_count)
count = undo_count;
while (count--) {
p = first_undo;
if (curr_undo == first_undo)
curr_undo = curr_undo->next;
first_undo = first_undo->next;
free (p);
undo_count--;
}
if (first_undo)
first_undo->prev = NULL;
else
last_undo = NULL;
} | false | false | false | false | false | 0 |
json_array_deep_copy(json_t *array)
{
json_t *result;
unsigned int i;
result = json_array();
if(!result)
return NULL;
for(i = 0; i < json_array_size(array); i++)
json_array_append_new(result, json_deep_copy(json_array_get(array, i)));
return result;
} | false | false | false | false | false | 0 |
hmm_add_pseudo_phones(HTK_HMM_INFO *hmminfo)
{
HMM_Logical *lg;
char buf[MAX_HMMNAME_LEN];
boolean ok_p = TRUE;
hmminfo->totalpseudonum = 0;
/* add pseudo monophone */
for (lg = hmminfo->lgstart; lg; lg = lg->next) {
if (lg->is_pseudo) continue;
if (hmm_add_pseudo_phones_sub(hmminfo, center_name(lg->name, buf)) == FALSE) {
jlog("Error: hmm_lookup: failed to add \"%s\" as logical\n", center_name(lg->name, buf));
ok_p = FALSE;
}
}
/* add pseudo biphone, i.e. "a-k" etc. */
for (lg = hmminfo->lgstart; lg; lg = lg->next) {
if (lg->is_pseudo) continue;
if (hmm_add_pseudo_phones_sub(hmminfo, leftcenter_name(lg->name, buf)) == FALSE) {
jlog("Error: hmm_lookup: failed to add \"%s\" as logical\n", leftcenter_name(lg->name, buf));
ok_p = FALSE;
}
}
/* add pseudo biphone, i.e. "k+e" etc. */
for (lg = hmminfo->lgstart; lg; lg = lg->next) {
if (lg->is_pseudo) continue;
if (hmm_add_pseudo_phones_sub(hmminfo, rightcenter_name(lg->name, buf)) == FALSE) {
jlog("Error: hmm_lookup: failed to add \"%s\" as logical\n", rightcenter_name(lg->name, buf));
ok_p = FALSE;
}
}
jlog("Stat: hmm_lookup: %d pseudo phones are added to logical HMM list\n", hmminfo->totalpseudonum);
/* re-count total number */
hmm_count_logical_num(hmminfo);
} | false | false | false | false | false | 0 |
_e_xsettings_start(void)
{
Eina_List *l;
E_Manager *man;
if (running) return;
_e_xsettings_theme_set();
_e_xsettings_icon_theme_set();
_e_xsettings_font_set();
_e_xsettings_cursor_path_set();
EINA_LIST_FOREACH(e_manager_list(), l, man)
{
Settings_Manager *sm = E_NEW(Settings_Manager, 1);
sm->man = man;
if (!_e_xsettings_activate(sm))
_e_xsettings_retry(sm);
managers = eina_list_append(managers, sm);
}
running = EINA_TRUE;
} | false | false | false | false | false | 0 |
installDerivations(Globals & globals,
const Strings & args, const Path & profile)
{
debug(format("installing derivations"));
/* Get the set of user environment elements to be installed. */
DrvInfos newElems;
queryInstSources(globals.state, globals.instSource, args, newElems, true);
StringSet newNames;
for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i) {
/* `forceName' is a hack to get package names right in some
one-click installs, namely those where the name used in the
path is not the one we want (e.g., `java-front' versus
`java-front-0.9pre15899'). */
if (globals.forceName != "")
i->name = globals.forceName;
newNames.insert(DrvName(i->name).name);
}
/* Add in the already installed derivations, unless they have the
same name as a to-be-installed element. */
while (true) {
string lockToken = optimisticLockProfile(profile);
DrvInfos installedElems = queryInstalled(globals.state, profile);
DrvInfos allElems(newElems);
foreach (DrvInfos::iterator, i, installedElems) {
DrvName drvName(i->name);
MetaInfo meta = i->queryMetaInfo(globals.state);
if (!globals.preserveInstalled &&
newNames.find(drvName.name) != newNames.end() &&
!keep(meta))
printMsg(lvlInfo,
format("replacing old `%1%'") % i->name);
else
allElems.push_back(*i);
}
foreach (DrvInfos::iterator, i, newElems)
printMsg(lvlInfo, format("installing `%1%'") % i->name);
printMissing(globals.state, newElems);
if (globals.dryRun) return;
if (createUserEnv(globals.state, allElems,
profile, globals.keepDerivations, lockToken)) break;
}
} | false | false | false | false | false | 0 |
libgnac_metadata_process_video_info(LibgnacMetadata *md)
{
GList *video_info = gst_discoverer_info_get_video_streams(md->priv->info);
if (!video_info) return;
libgnac_metadata_add_boolean_value(md, GNAC_TAG_HAS_VIDEO, TRUE);
GList *first = g_list_first(video_info);
GstDiscovererVideoInfo *video = (GstDiscovererVideoInfo *) first->data;
guint height = gst_discoverer_video_info_get_height(video);
libgnac_metadata_add_uint_value(md, GNAC_TAG_HEIGHT, height);
guint width = gst_discoverer_video_info_get_width(video);
libgnac_metadata_add_uint_value(md, GNAC_TAG_WIDTH, width);
guint depth = gst_discoverer_video_info_get_depth(video);
libgnac_metadata_add_uint_value(md, GNAC_TAG_VIDEO_DEPTH, depth);
guint rate_num = gst_discoverer_video_info_get_framerate_num(video);
guint rate_denom = gst_discoverer_video_info_get_framerate_denom(video);
libgnac_metadata_add_fraction_value(md, GNAC_TAG_FRAMERATE,
rate_num, rate_denom);
if (gst_discoverer_video_info_is_interlaced(video)) {
libgnac_metadata_add_boolean_value(md, GNAC_TAG_INTERLACED, TRUE);
}
guint par_num = gst_discoverer_video_info_get_par_num(video);
guint par_denom = gst_discoverer_video_info_get_par_denom(video);
libgnac_metadata_add_fraction_value(md, GNAC_TAG_PAR, par_num, par_denom);
gst_discoverer_stream_info_list_free(video_info);
} | false | false | false | false | false | 0 |
DoneWithGetTemplatePtrs() {
WriterMutexLock ml(mutex_);
for (TemplateCallMap::iterator it = get_template_calls_->begin();
it != get_template_calls_->end(); ++it) {
it->first->DecRefN(it->second); // it.second: # of times GetTpl was called
}
get_template_calls_->clear();
} | false | false | false | false | false | 0 |
cob_move_all (cob_field *src, cob_field *dst)
{
size_t i;
size_t digcount;
cob_field temp;
cob_field_attr attr;
COB_ATTR_INIT (COB_TYPE_ALPHANUMERIC, 0, 0, 0, NULL);
if (COB_FIELD_IS_NUMERIC(dst)) {
digcount = 18;
attr.type = COB_TYPE_NUMERIC_DISPLAY;
attr.digits = 18;
/*
if (COB_FIELD_TYPE(dst) & COB_TYPE_NUMERIC_EDITED) {
digcount = dst->size;
} else {
digcount = COB_FIELD_DIGITS(dst);
}
*/
} else {
digcount = dst->size;
}
if (digcount > lastsize) {
free (lastdata);
lastdata = cob_malloc (digcount);
lastsize = digcount;
}
temp.size = digcount;
temp.data = lastdata;
temp.attr = &attr;
if (likely(src->size == 1)) {
memset (lastdata, src->data[0], digcount);
} else {
for (i = 0; i < digcount; ++i) {
lastdata[i] = src->data[i % src->size];
}
}
cob_move (&temp, dst);
} | false | false | false | false | false | 0 |
changed_cb(struct btrfs_root *left_root,
struct btrfs_root *right_root,
struct btrfs_path *left_path,
struct btrfs_path *right_path,
struct btrfs_key *key,
enum btrfs_compare_tree_result result,
void *ctx)
{
int ret = 0;
struct send_ctx *sctx = ctx;
if (result == BTRFS_COMPARE_TREE_SAME) {
if (key->type == BTRFS_INODE_REF_KEY ||
key->type == BTRFS_INODE_EXTREF_KEY) {
ret = compare_refs(sctx, left_path, key);
if (!ret)
return 0;
if (ret < 0)
return ret;
} else if (key->type == BTRFS_EXTENT_DATA_KEY) {
return maybe_send_hole(sctx, left_path, key);
} else {
return 0;
}
result = BTRFS_COMPARE_TREE_CHANGED;
ret = 0;
}
sctx->left_path = left_path;
sctx->right_path = right_path;
sctx->cmp_key = key;
ret = finish_inode_if_needed(sctx, 0);
if (ret < 0)
goto out;
/* Ignore non-FS objects */
if (key->objectid == BTRFS_FREE_INO_OBJECTID ||
key->objectid == BTRFS_FREE_SPACE_OBJECTID)
goto out;
if (key->type == BTRFS_INODE_ITEM_KEY)
ret = changed_inode(sctx, result);
else if (key->type == BTRFS_INODE_REF_KEY ||
key->type == BTRFS_INODE_EXTREF_KEY)
ret = changed_ref(sctx, result);
else if (key->type == BTRFS_XATTR_ITEM_KEY)
ret = changed_xattr(sctx, result);
else if (key->type == BTRFS_EXTENT_DATA_KEY)
ret = changed_extent(sctx, result);
out:
return ret;
} | false | false | false | false | false | 0 |
drawexplosions(void)
{
int i, any;
/* We'll say if there are any more or not: */
any = 0;
for (i = 0; i < NUM_EXPLOSIONS; i++)
{
if (explosions[i].exist == YES)
{
/* (There are some!) */
any = 1;
/* There's an animation slow-down... */
explosions[i].animrate++;
if (explosions[i].animrate >= EXPLOSION_SLOW_VAL)
{
explosions[i].animrate = 0;
explosions[i].anim++;
if (explosions[i].anim >= NUM_EXPLOSION_GFX)
{
/* It's gone! Draw whatever was/is behind it: */
explosions[i].exist = NO;
drawblock(explosions[i].x, explosions[i].y);
}
else if (explosions[i].anim >= 0)
{
/* Draw the animation frame: */
drawblockgraphic(explosions[i].x * 48, explosions[i].y * 48,
NUM_ALL_BLOCKS + NUM_SPECIALS + 1 +
explosions[i].anim);
}
}
}
}
return(any);
} | false | false | false | false | false | 0 |
from_string( const char *pv)
{
int h = -1;
channel = h;
char p[21], v[81]; // make it 20
if ( 3 == sscanf( pv, "%u:%20[a-z_]:%80s", &h, p, v) && h != -1 ) {
channel = h - 1; // base 0
if ( strcmp( p, "label") == 0 ) {
sigfile::SChannel X (p);
if ( X.type() != sigfile::SChannel::TType::eeg )
printf( "Note: Channel label \"%s\" does not follow System 10-20\n", v);
which = ch_label;
} else if ( strcmp( p, "transducer_type") == 0 ) {
which = ch_transducer_type;
} else if ( strcmp( p, "physical_dim") == 0 ) {
which = ch_physical_dim;
} else if ( strcmp( p, "physical_min") == 0 ) {
stod(v);
which = ch_physical_min;
} else if ( strcmp( p, "physical_max") == 0 ) {
stod(v);
which = ch_physical_max;
} else if ( strcmp( p, "digital_min") == 0 ) {
stoi(v);
which = ch_digital_min;
} else if ( strcmp( p, "digital_max") == 0 ) {
stoi(v);
which = ch_digital_max;
} else if ( strcmp( p, "filtering_info") == 0 ) {
which = ch_filtering_info;
} else if ( strcmp( p, "reserved") == 0 ) {
which = ch_reserved;
} else
return -3;
} else if ( 2 == sscanf( pv, "%20[a-z_]:%80s", p, v) ) {
if ( strcmp( p, "version_number") == 0 )
which = version_number;
else if ( strcmp( p, "patient_id") == 0 )
which = patient_id;
else if ( strcmp( p, "recording_id") == 0 )
which = recording_id;
else if ( strcmp( p, "recording_date") == 0 )
which = recording_date;
else if ( strcmp( p, "recording_time") == 0 )
which = recording_time;
else if ( strcmp( p, "reserved") == 0 )
which = reserved;
else
return -2;
} else {
return -1;
}
value.assign( v);
return 0;
}
} | false | false | false | false | false | 0 |
search_points_to_pointer_type(Type_table *org_type,
Type_table *new_pointed_type)
{
Type_table *tpt;
for (tpt = type_head; tpt != NULL; tpt = tpt->next) {
if (tpt->type == TYPE_PTR
&& tpt->val.ptr.ref_type == new_pointed_type->type
&& tpt->val.ptr.type_entry == new_pointed_type
&& tpt->const_flg == org_type->const_flg
&& tpt->restrict_flg == org_type->restrict_flg
&& tpt->volatile_flg == org_type->volatile_flg
&& (tpt->val.ptr.dim ?
tpt->val.ptr.dim->dim == org_type->val.ptr.dim->dim :
tpt->val.ptr.dim == org_type->val.ptr.dim)) {
int i;
Boolean match = TRUE;
if (tpt->val.ptr.dim == NULL) break;
for (i = 0; i < tpt->val.ptr.dim->dim; i++) {
if (tpt->val.ptr.dim->bas.ct[i] != org_type->val.ptr.dim->bas.ct[i]
|| tpt->val.ptr.dim->lim.ct[i] != org_type->val.ptr.dim->lim.ct[i]) {
match = FALSE;
break;
}
}
if (match) break;
}
}
return tpt;
} | false | false | false | false | false | 0 |
IntOrAsign(struct Expression * exp, struct Operand * op1, struct Operand * op2)
{
int value2 = op2->i;
exp->type = 2;
exp->string = PrintInt(op1->i |= value2);
if(!exp->expType)
{
exp->expType = op1->type;
if(op1->type)
op1->type->refCount++;
}
return 0x1;
} | false | false | false | false | false | 0 |
mm_TLSSock_check_cert_alive(PyObject *self, PyObject *args, PyObject *kwargs)
{
/* ???? Should be threadified? */
time_t now;
X509 *cert = NULL;
SSL *ssl = NULL;
assert(mm_TLSSock_Check(self));
FAIL_IF_ARGS();
ssl = ((mm_TLSSock*)self)->ssl;
if (!(cert = SSL_get_peer_certificate(ssl))) {
mm_SSL_ERR(0); return NULL;
}
/* Check expiration times. */
now = time(NULL);
if (X509_cmp_time(X509_get_notBefore(cert), &now) > 0) {
MM_TLS_ERR("Certificate is not yet valid");
goto error;
}
if (X509_cmp_time(X509_get_notAfter(cert), &now) < 0) {
MM_TLS_ERR("Certificate has expired");
goto error;
}
X509_free(cert);
Py_INCREF(Py_None);
return Py_None;
error:
X509_free(cert);
return NULL;
} | false | false | false | false | false | 0 |
keyboard_rebind(void)
{
KeyBindingTree *old;
old = keyboard_firstnode;
keyboard_firstnode = NULL;
if (old)
node_rebind(old);
tree_destroy(old);
set_curpos(NULL);
grab_keys(TRUE);
} | false | false | false | false | false | 0 |
int104_div_uint (Int104 *x,
guint y)
{
guint carry, tmp, i;
carry = 0;
for ( i = 0; i < 13; i++ )
{
tmp = x->byte[i] + (carry<<8);
x->byte[i] = tmp / y;
carry = tmp % y;
}
return carry;
} | 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.